@rubytech/taskmaster 1.23.1 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,23 @@
1
- var Vu=Object.defineProperty;var Qu=(e,t,n)=>t in e?Vu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var q=(e,t,n)=>Qu(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 Ju="modulepreload",Yu=function(e,t){return new URL(e,t).href},ar={},ae=function(t,n,i){let s=Promise.resolve();if(n&&n.length>0){let d=function(h){return Promise.all(h.map(u=>Promise.resolve(u).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=d(n.map(h=>{if(h=Yu(h,i),h in ar)return;ar[h]=!0;const u=h.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(i)for(let $=a.length-1;$>=0;$--){const S=a[$];if(S.href===h&&(!u||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${p}`))return;const v=document.createElement("link");if(v.rel=u?"stylesheet":Ju,u||(v.as="script"),v.crossOrigin="",v.href=h,l&&v.setAttribute("nonce",l),document.head.appendChild(v),u)return new Promise(($,S)=>{v.addEventListener("load",$),v.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,Go=Si.ShadowRoot&&(Si.ShadyCSS===void 0||Si.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Vo=Symbol(),rr=new WeakMap;let Ol=class{constructor(t,n,i){if(this._$cssResult$=!0,i!==Vo)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(Go&&t===void 0){const i=n!==void 0&&n.length===1;i&&(t=rr.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&rr.set(n,t))}return t}toString(){return this.cssText}};const Xu=e=>new Ol(typeof e=="string"?e:e+"",void 0,Vo),Zu=(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 Ol(n,e,Vo)},ep=(e,t)=>{if(Go)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)}},lr=Go?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const i of t.cssRules)n+=i.cssText;return Xu(n)})(e):e;const{is:tp,defineProperty:np,getOwnPropertyDescriptor:ip,getOwnPropertyNames:sp,getOwnPropertySymbols:op,getPrototypeOf:ap}=Object,ot=globalThis,cr=ot.trustedTypes,rp=cr?cr.emptyScript:"",Ms=ot.reactiveElementPolyfillSupport,Cn=(e,t)=>e,Ri={toAttribute(e,t){switch(t){case Boolean:e=e?rp: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}},Qo=(e,t)=>!tp(e,t),dr={attribute:!0,type:String,converter:Ri,reflect:!1,useDefault:!1,hasChanged:Qo};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),ot.litPropertyMetadata??(ot.litPropertyMetadata=new WeakMap);let Ht=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=dr){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&&np(this.prototype,t,s)}}static getPropertyDescriptor(t,n,i){const{get:s,set:o}=ip(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)??dr}static _$Ei(){if(this.hasOwnProperty(Cn("elementProperties")))return;const t=ap(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=[...sp(n),...op(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(lr(s))}else t!==void 0&&n.push(lr(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 ep(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:Ri).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:Ri;this._$Em=s;const d=l.fromAttribute(n,r.type);this[s]=d??((a=this._$Ej)==null?void 0:a.get(s))??d,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??Qo)(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){}};Ht.elementStyles=[],Ht.shadowRootOptions={mode:"open"},Ht[Cn("elementProperties")]=new Map,Ht[Cn("finalized")]=new Map,Ms==null||Ms({ReactiveElement:Ht}),(ot.reactiveElementVersions??(ot.reactiveElementVersions=[])).push("2.1.2");const En=globalThis,ur=e=>e,Li=En.trustedTypes,pr=Li?Li.createPolicy("lit-html",{createHTML:e=>e}):void 0,Fl="$lit$",st=`lit$${Math.random().toFixed(9).slice(2)}$`,Ul="?"+st,lp=`<${Ul}>`,At=document,Fn=()=>At.createComment(""),Un=e=>e===null||typeof e!="object"&&typeof e!="function",Jo=Array.isArray,cp=e=>Jo(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",Ps=`[
2
- \f\r]`,hn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,hr=/-->/g,fr=/>/g,pt=RegExp(`>|${Ps}(?:([^\\s"'>=/]+)(${Ps}*=${Ps}*(?:[^
3
- \f\r"'\`<>=]|("|')|))|$)`,"g"),gr=/'/g,mr=/"/g,Wl=/^(?:script|style|textarea|title)$/i,dp=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),c=dp(1),rt=Symbol.for("lit-noChange"),w=Symbol.for("lit-nothing"),yr=new WeakMap,yt=At.createTreeWalker(At,129);function zl(e,t){if(!Jo(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return pr!==void 0?pr.createHTML(t):t}const up=(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 d,h,u=-1,p=0;for(;p<l.length&&(a.lastIndex=p,h=a.exec(l),h!==null);)p=a.lastIndex,a===hn?h[1]==="!--"?a=hr:h[1]!==void 0?a=fr:h[2]!==void 0?(Wl.test(h[2])&&(s=RegExp("</"+h[2],"g")),a=pt):h[3]!==void 0&&(a=pt):a===pt?h[0]===">"?(a=s??hn,u=-1):h[1]===void 0?u=-2:(u=a.lastIndex-h[2].length,d=h[1],a=h[3]===void 0?pt:h[3]==='"'?mr:gr):a===mr||a===gr?a=pt:a===hr||a===fr?a=hn:(a=pt,s=void 0);const v=a===pt&&e[r+1].startsWith("/>")?" ":"";o+=a===hn?l+lp:u>=0?(i.push(d),l.slice(0,u)+Fl+l.slice(u)+st+v):l+st+(u===-2?r:v)}return[zl(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let vo=class Kl{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let o=0,a=0;const r=t.length-1,l=this.parts,[d,h]=up(t,n);if(this.el=Kl.createElement(d,i),yt.currentNode=this.el.content,n===2||n===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(s=yt.nextNode())!==null&&l.length<r;){if(s.nodeType===1){if(s.hasAttributes())for(const u of s.getAttributeNames())if(u.endsWith(Fl)){const p=h[a++],v=s.getAttribute(u).split(st),$=/([.?@])?(.*)/.exec(p);l.push({type:1,index:o,name:$[2],strings:v,ctor:$[1]==="."?hp:$[1]==="?"?fp:$[1]==="@"?gp:is}),s.removeAttribute(u)}else u.startsWith(st)&&(l.push({type:6,index:o}),s.removeAttribute(u));if(Wl.test(s.tagName)){const u=s.textContent.split(st),p=u.length-1;if(p>0){s.textContent=Li?Li.emptyScript:"";for(let v=0;v<p;v++)s.append(u[v],Fn()),yt.nextNode(),l.push({type:2,index:++o});s.append(u[p],Fn())}}}else if(s.nodeType===8)if(s.data===Ul)l.push({type:2,index:o});else{let u=-1;for(;(u=s.data.indexOf(st,u+1))!==-1;)l.push({type:7,index:o}),u+=st.length-1}o++}}static createElement(t,n){const i=At.createElement("template");return i.innerHTML=t,i}};function Qt(e,t,n=e,i){var a,r;if(t===rt)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=Qt(e,s._$AS(e,t.values),s,i)),t}class pp{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)??At).importNode(n,!0);yt.currentNode=s;let o=yt.nextNode(),a=0,r=0,l=i[0];for(;l!==void 0;){if(a===l.index){let d;l.type===2?d=new ns(o,o.nextSibling,this,t):l.type===1?d=new l.ctor(o,l.name,l.strings,this,t):l.type===6&&(d=new mp(o,this,t)),this._$AV.push(d),l=i[++r]}a!==(l==null?void 0:l.index)&&(o=yt.nextNode(),a++)}return yt.currentNode=At,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 ns=class Hl{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=Qt(this,t,n),Un(t)?t===w||t==null||t===""?(this._$AH!==w&&this._$AR(),this._$AH=w):t!==this._$AH&&t!==rt&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):cp(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(At.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=vo.createElement(zl(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 pp(s,this),r=a.u(this.options);a.p(n),this.T(r),this._$AH=a}}_$AC(t){let n=yr.get(t.strings);return n===void 0&&yr.set(t.strings,n=new vo(t)),n}k(t){Jo(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 Hl(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=ur(t).nextSibling;ur(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class is{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=Qt(this,t,n,0),a=!Un(t)||t!==this._$AH&&t!==rt,a&&(this._$AH=t);else{const r=t;let l,d;for(t=o[0],l=0;l<o.length-1;l++)d=Qt(this,r[i+l],n,l),d===rt&&(d=this._$AH[l]),a||(a=!Un(d)||d!==this._$AH[l]),d===w?t=w:t!==w&&(t+=(d??"")+o[l+1]),this._$AH[l]=d}a&&!s&&this.j(t)}j(t){t===w?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let hp=class extends is{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===w?void 0:t}},fp=class extends is{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==w)}},gp=class extends is{constructor(t,n,i,s,o){super(t,n,i,s,o),this.type=5}_$AI(t,n=this){if((t=Qt(this,t,n,0)??w)===rt)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)}},mp=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){Qt(this,t)}};const yp={I:ns},Is=En.litHtmlPolyfillSupport;Is==null||Is(vo,ns),(En.litHtmlVersions??(En.litHtmlVersions=[])).push("3.3.2");const vp=(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 ns(t.insertBefore(Fn(),o),o,void 0,n??{})}return s._$AI(e),s};const xt=globalThis;let Gt=class extends Ht{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=vp(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 rt}};var Nl;Gt._$litElement$=!0,Gt.finalized=!0,(Nl=xt.litElementHydrateSupport)==null||Nl.call(xt,{LitElement:Gt});const Rs=xt.litElementPolyfillSupport;Rs==null||Rs({LitElement:Gt});(xt.litElementVersions??(xt.litElementVersions=[])).push("4.2.2");const ql=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const bp={attribute:!0,type:String,converter:Ri,reflect:!1,hasChanged:Qo},wp=(e=bp,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 ss(e){return(t,n)=>typeof n=="object"?wp(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 m(e){return ss({...e,state:!0,attribute:!1})}const kp=50,xp=200,$p="Assistant";function vr(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function bo(e){const t=vr(e==null?void 0:e.name,kp)??$p,n=vr((e==null?void 0:e.avatar)??void 0,xp)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function Sp(){return bo(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const Ap="Taskmaster",Cp="/taskmaster-icon.png",Ep="#00d4ff",Tp="";let ai=null;function Xe(){return ai||(ai={name:window.__TASKMASTER_BRAND_NAME__||Ap,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||Cp,accentColor:window.__TASKMASTER_ACCENT_COLOR__||Ep,backgroundColor:window.__TASKMASTER_BACKGROUND_COLOR__||Tp},ai)}function Fe(){return window.__TASKMASTER_WORKSPACE_BRANDS__??{}}function jl(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 _p(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 Gl(e){const t=jl(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=_p(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=(d,h)=>Math.round(parseInt(i[d],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 Vl(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=jl(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=Xe(),n=Fe(),i=e?n[e]:void 0,s=(i==null?void 0:i.accentColor)??t.accentColor;Gl(s);const o=(i==null?void 0:i.backgroundColor)??t.backgroundColor;Vl(o)}const Di="taskmaster.control.settings.v1",Ql="taskmaster.account.settings.";function _n(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const zt={gatewayUrl:_n(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},nt={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function Mp(){try{const e=localStorage.getItem(Di);if(!e)return{...zt,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:zt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:zt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:zt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:zt.navGroupsCollapsed}}catch{return{...zt,gatewayUrl:_n()}}}function Pp(e){if(!e)return{...nt};try{const t=localStorage.getItem(Ql+e);if(!t)return{...nt};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():nt.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||nt.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:nt.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:nt.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:nt.splitRatio}}catch{return{...nt}}}let Bi=null;function br(e){Bi=e}function Ls(){return{...Mp(),...Pp(Bi)}}function Ip(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(Di,JSON.stringify(t)),Bi){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(Ql+Bi,JSON.stringify(n))}}const Rp="taskmaster.draft.";function Yo(e,t){return Rp+e+"."+t}function Wn(e,t,n){try{const i=Yo(e,t);n?localStorage.setItem(i,n):localStorage.removeItem(i)}catch{}}function zn(e,t){try{return localStorage.getItem(Yo(e,t))??""}catch{return""}}function Lp(e,t){try{localStorage.removeItem(Yo(e,t))}catch{}}let vt=null,Ce=null;function wr(e,t,n){Ce={workspace:e,sessionKey:t,text:n},vt!=null&&clearTimeout(vt),vt=setTimeout(()=>{Ce&&Wn(Ce.workspace,Ce.sessionKey,Ce.text),Ce=null,vt=null},300)}function wo(){vt!=null&&clearTimeout(vt),vt=null,Ce&&(Wn(Ce.workspace,Ce.sessionKey,Ce.text),Ce=null)}(function(){try{const t=localStorage.getItem(Di);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(Di,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 Dp=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,li=/<\s*\/?\s*final\b[^>]*>/gi,kr=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Bp(e,t){return e.trimStart()}function Np(e,t){if(!e||!Dp.test(e))return e;let n=e;li.test(n)?(li.lastIndex=0,n=n.replace(li,"")):li.lastIndex=0,kr.lastIndex=0;let i="",s=0,o=!1;for(const a of n.matchAll(kr)){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),Bp(i)}function Yl(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function os(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 d=Math.round(l/60);return d<48?`in ${d}h`:`in ${Math.round(d/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 Xo(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 Op(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Xl(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 Ni(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Ds(e){return Np(e)}const Fp=/^\[([^\]]+)\]\s*/,Up=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Bs=new WeakMap,Ns=new WeakMap;function Wp(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:Up.some(t=>e.startsWith(`${t} `))}function Os(e){const t=e.match(Fp);if(!t)return e;const n=t[1]??"";return Wp(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"?Ds(i):Os(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
- `);return n==="assistant"?Ds(o):Os(o)}}return typeof t.text=="string"?n==="assistant"?Ds(t.text):Os(t.text):null}function Zl(e){if(!e||typeof e!="object")return Mn(e);const t=e;if(Bs.has(t))return Bs.get(t)??null;const n=Mn(e);return Bs.set(t,n),n}function xr(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 d=l.thinking.trim();d&&i.push(d)}}if(i.length>0)return i.join(`
1
+ var Vu=Object.defineProperty;var Qu=(e,t,n)=>t in e?Vu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var q=(e,t,n)=>Qu(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 Ju="modulepreload",Yu=function(e,t){return new URL(e,t).href},rr={},ae=function(t,n,i){let s=Promise.resolve();if(n&&n.length>0){let d=function(h){return Promise.all(h.map(u=>Promise.resolve(u).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=d(n.map(h=>{if(h=Yu(h,i),h in rr)return;rr[h]=!0;const u=h.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(i)for(let $=a.length-1;$>=0;$--){const S=a[$];if(S.href===h&&(!u||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${p}`))return;const v=document.createElement("link");if(v.rel=u?"stylesheet":Ju,u||(v.as="script"),v.crossOrigin="",v.href=h,l&&v.setAttribute("nonce",l),document.head.appendChild(v),u)return new Promise(($,S)=>{v.addEventListener("load",$),v.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,Jo=Si.ShadowRoot&&(Si.ShadyCSS===void 0||Si.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Yo=Symbol(),lr=new WeakMap;let Fl=class{constructor(t,n,i){if(this._$cssResult$=!0,i!==Yo)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(Jo&&t===void 0){const i=n!==void 0&&n.length===1;i&&(t=lr.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&lr.set(n,t))}return t}toString(){return this.cssText}};const Xu=e=>new Fl(typeof e=="string"?e:e+"",void 0,Yo),Zu=(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 Fl(n,e,Yo)},ep=(e,t)=>{if(Jo)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)}},cr=Jo?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const i of t.cssRules)n+=i.cssText;return Xu(n)})(e):e;const{is:tp,defineProperty:np,getOwnPropertyDescriptor:ip,getOwnPropertyNames:sp,getOwnPropertySymbols:op,getPrototypeOf:ap}=Object,ot=globalThis,dr=ot.trustedTypes,rp=dr?dr.emptyScript:"",Is=ot.reactiveElementPolyfillSupport,Cn=(e,t)=>e,Ri={toAttribute(e,t){switch(t){case Boolean:e=e?rp: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}},Xo=(e,t)=>!tp(e,t),ur={attribute:!0,type:String,converter:Ri,reflect:!1,useDefault:!1,hasChanged:Xo};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),ot.litPropertyMetadata??(ot.litPropertyMetadata=new WeakMap);let Ht=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=ur){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&&np(this.prototype,t,s)}}static getPropertyDescriptor(t,n,i){const{get:s,set:o}=ip(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)??ur}static _$Ei(){if(this.hasOwnProperty(Cn("elementProperties")))return;const t=ap(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=[...sp(n),...op(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(cr(s))}else t!==void 0&&n.push(cr(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 ep(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:Ri).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:Ri;this._$Em=s;const d=l.fromAttribute(n,r.type);this[s]=d??((a=this._$Ej)==null?void 0:a.get(s))??d,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??Xo)(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){}};Ht.elementStyles=[],Ht.shadowRootOptions={mode:"open"},Ht[Cn("elementProperties")]=new Map,Ht[Cn("finalized")]=new Map,Is==null||Is({ReactiveElement:Ht}),(ot.reactiveElementVersions??(ot.reactiveElementVersions=[])).push("2.1.2");const En=globalThis,pr=e=>e,Li=En.trustedTypes,hr=Li?Li.createPolicy("lit-html",{createHTML:e=>e}):void 0,Ul="$lit$",st=`lit$${Math.random().toFixed(9).slice(2)}$`,Wl="?"+st,lp=`<${Wl}>`,At=document,Fn=()=>At.createComment(""),Un=e=>e===null||typeof e!="object"&&typeof e!="function",Zo=Array.isArray,cp=e=>Zo(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",Rs=`[
2
+ \f\r]`,hn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,fr=/-->/g,gr=/>/g,pt=RegExp(`>|${Rs}(?:([^\\s"'>=/]+)(${Rs}*=${Rs}*(?:[^
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),mr=/'/g,yr=/"/g,zl=/^(?:script|style|textarea|title)$/i,dp=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),c=dp(1),rt=Symbol.for("lit-noChange"),w=Symbol.for("lit-nothing"),vr=new WeakMap,yt=At.createTreeWalker(At,129);function Kl(e,t){if(!Zo(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return hr!==void 0?hr.createHTML(t):t}const up=(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 d,h,u=-1,p=0;for(;p<l.length&&(a.lastIndex=p,h=a.exec(l),h!==null);)p=a.lastIndex,a===hn?h[1]==="!--"?a=fr:h[1]!==void 0?a=gr:h[2]!==void 0?(zl.test(h[2])&&(s=RegExp("</"+h[2],"g")),a=pt):h[3]!==void 0&&(a=pt):a===pt?h[0]===">"?(a=s??hn,u=-1):h[1]===void 0?u=-2:(u=a.lastIndex-h[2].length,d=h[1],a=h[3]===void 0?pt:h[3]==='"'?yr:mr):a===yr||a===mr?a=pt:a===fr||a===gr?a=hn:(a=pt,s=void 0);const v=a===pt&&e[r+1].startsWith("/>")?" ":"";o+=a===hn?l+lp:u>=0?(i.push(d),l.slice(0,u)+Ul+l.slice(u)+st+v):l+st+(u===-2?r:v)}return[Kl(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let wo=class Hl{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let o=0,a=0;const r=t.length-1,l=this.parts,[d,h]=up(t,n);if(this.el=Hl.createElement(d,i),yt.currentNode=this.el.content,n===2||n===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(s=yt.nextNode())!==null&&l.length<r;){if(s.nodeType===1){if(s.hasAttributes())for(const u of s.getAttributeNames())if(u.endsWith(Ul)){const p=h[a++],v=s.getAttribute(u).split(st),$=/([.?@])?(.*)/.exec(p);l.push({type:1,index:o,name:$[2],strings:v,ctor:$[1]==="."?hp:$[1]==="?"?fp:$[1]==="@"?gp:os}),s.removeAttribute(u)}else u.startsWith(st)&&(l.push({type:6,index:o}),s.removeAttribute(u));if(zl.test(s.tagName)){const u=s.textContent.split(st),p=u.length-1;if(p>0){s.textContent=Li?Li.emptyScript:"";for(let v=0;v<p;v++)s.append(u[v],Fn()),yt.nextNode(),l.push({type:2,index:++o});s.append(u[p],Fn())}}}else if(s.nodeType===8)if(s.data===Wl)l.push({type:2,index:o});else{let u=-1;for(;(u=s.data.indexOf(st,u+1))!==-1;)l.push({type:7,index:o}),u+=st.length-1}o++}}static createElement(t,n){const i=At.createElement("template");return i.innerHTML=t,i}};function Qt(e,t,n=e,i){var a,r;if(t===rt)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=Qt(e,s._$AS(e,t.values),s,i)),t}class pp{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)??At).importNode(n,!0);yt.currentNode=s;let o=yt.nextNode(),a=0,r=0,l=i[0];for(;l!==void 0;){if(a===l.index){let d;l.type===2?d=new ss(o,o.nextSibling,this,t):l.type===1?d=new l.ctor(o,l.name,l.strings,this,t):l.type===6&&(d=new mp(o,this,t)),this._$AV.push(d),l=i[++r]}a!==(l==null?void 0:l.index)&&(o=yt.nextNode(),a++)}return yt.currentNode=At,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 ss=class ql{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=Qt(this,t,n),Un(t)?t===w||t==null||t===""?(this._$AH!==w&&this._$AR(),this._$AH=w):t!==this._$AH&&t!==rt&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):cp(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(At.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=wo.createElement(Kl(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 pp(s,this),r=a.u(this.options);a.p(n),this.T(r),this._$AH=a}}_$AC(t){let n=vr.get(t.strings);return n===void 0&&vr.set(t.strings,n=new wo(t)),n}k(t){Zo(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 ql(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=pr(t).nextSibling;pr(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class os{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=Qt(this,t,n,0),a=!Un(t)||t!==this._$AH&&t!==rt,a&&(this._$AH=t);else{const r=t;let l,d;for(t=o[0],l=0;l<o.length-1;l++)d=Qt(this,r[i+l],n,l),d===rt&&(d=this._$AH[l]),a||(a=!Un(d)||d!==this._$AH[l]),d===w?t=w:t!==w&&(t+=(d??"")+o[l+1]),this._$AH[l]=d}a&&!s&&this.j(t)}j(t){t===w?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let hp=class extends os{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===w?void 0:t}},fp=class extends os{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==w)}},gp=class extends os{constructor(t,n,i,s,o){super(t,n,i,s,o),this.type=5}_$AI(t,n=this){if((t=Qt(this,t,n,0)??w)===rt)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)}},mp=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){Qt(this,t)}};const yp={I:ss},Ls=En.litHtmlPolyfillSupport;Ls==null||Ls(wo,ss),(En.litHtmlVersions??(En.litHtmlVersions=[])).push("3.3.2");const vp=(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 ss(t.insertBefore(Fn(),o),o,void 0,n??{})}return s._$AI(e),s};const xt=globalThis;let Gt=class extends Ht{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=vp(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 rt}};var Ol;Gt._$litElement$=!0,Gt.finalized=!0,(Ol=xt.litElementHydrateSupport)==null||Ol.call(xt,{LitElement:Gt});const Ds=xt.litElementPolyfillSupport;Ds==null||Ds({LitElement:Gt});(xt.litElementVersions??(xt.litElementVersions=[])).push("4.2.2");const jl=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const bp={attribute:!0,type:String,converter:Ri,reflect:!1,hasChanged:Xo},wp=(e=bp,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 as(e){return(t,n)=>typeof n=="object"?wp(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 m(e){return as({...e,state:!0,attribute:!1})}const kp=50,xp=200,$p="Assistant";function br(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function ko(e){const t=br(e==null?void 0:e.name,kp)??$p,n=br((e==null?void 0:e.avatar)??void 0,xp)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function Sp(){return ko(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const Ap="Taskmaster",Cp="/taskmaster-icon.png",Ep="#00d4ff",Tp="";let ai=null;function Xe(){return ai||(ai={name:window.__TASKMASTER_BRAND_NAME__||Ap,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||Cp,accentColor:window.__TASKMASTER_ACCENT_COLOR__||Ep,backgroundColor:window.__TASKMASTER_BACKGROUND_COLOR__||Tp},ai)}function Fe(){return window.__TASKMASTER_WORKSPACE_BRANDS__??{}}function Gl(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 _p(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 Vl(e){const t=Gl(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=_p(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=(d,h)=>Math.round(parseInt(i[d],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=Gl(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=Xe(),n=Fe(),i=e?n[e]:void 0,s=(i==null?void 0:i.accentColor)??t.accentColor;Vl(s);const o=(i==null?void 0:i.backgroundColor)??t.backgroundColor;Ql(o)}const Di="taskmaster.control.settings.v1",Jl="taskmaster.account.settings.";function _n(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const zt={gatewayUrl:_n(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},nt={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function Mp(){try{const e=localStorage.getItem(Di);if(!e)return{...zt,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:zt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:zt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:zt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:zt.navGroupsCollapsed}}catch{return{...zt,gatewayUrl:_n()}}}function Pp(e){if(!e)return{...nt};try{const t=localStorage.getItem(Jl+e);if(!t)return{...nt};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():nt.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||nt.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:nt.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:nt.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:nt.splitRatio}}catch{return{...nt}}}let Bi=null;function wr(e){Bi=e}function Bs(){return{...Mp(),...Pp(Bi)}}function Ip(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(Di,JSON.stringify(t)),Bi){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(Jl+Bi,JSON.stringify(n))}}const Rp="taskmaster.draft.";function ea(e,t){return Rp+e+"."+t}function Wn(e,t,n){try{const i=ea(e,t);n?localStorage.setItem(i,n):localStorage.removeItem(i)}catch{}}function zn(e,t){try{return localStorage.getItem(ea(e,t))??""}catch{return""}}function Lp(e,t){try{localStorage.removeItem(ea(e,t))}catch{}}let vt=null,Ce=null;function kr(e,t,n){Ce={workspace:e,sessionKey:t,text:n},vt!=null&&clearTimeout(vt),vt=setTimeout(()=>{Ce&&Wn(Ce.workspace,Ce.sessionKey,Ce.text),Ce=null,vt=null},300)}function xo(){vt!=null&&clearTimeout(vt),vt=null,Ce&&(Wn(Ce.workspace,Ce.sessionKey,Ce.text),Ce=null)}(function(){try{const t=localStorage.getItem(Di);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(Di,JSON.stringify(i))}catch{}})();function Yl(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 Dp=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,li=/<\s*\/?\s*final\b[^>]*>/gi,xr=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Bp(e,t){return e.trimStart()}function Np(e,t){if(!e||!Dp.test(e))return e;let n=e;li.test(n)?(li.lastIndex=0,n=n.replace(li,"")):li.lastIndex=0,xr.lastIndex=0;let i="",s=0,o=!1;for(const a of n.matchAll(xr)){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),Bp(i)}function Xl(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function rs(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 d=Math.round(l/60);return d<48?`in ${d}h`:`in ${Math.round(d/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 ta(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 Op(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Zl(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 Ni(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Ns(e){return Np(e)}const Fp=/^\[([^\]]+)\]\s*/,Up=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Os=new WeakMap,Fs=new WeakMap;function Wp(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:Up.some(t=>e.startsWith(`${t} `))}function Us(e){const t=e.match(Fp);if(!t)return e;const n=t[1]??"";return Wp(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"?Ns(i):Us(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
+ `);return n==="assistant"?Ns(o):Us(o)}}return typeof t.text=="string"?n==="assistant"?Ns(t.text):Us(t.text):null}function ec(e){if(!e||typeof e!="object")return Mn(e);const t=e;if(Os.has(t))return Os.get(t)??null;const n=Mn(e);return Os.set(t,n),n}function $r(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 d=l.thinking.trim();d&&i.push(d)}}if(i.length>0)return i.join(`
5
5
  `);const s=Kp(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
- `):null}function zp(e){if(!e||typeof e!="object")return xr(e);const t=e;if(Ns.has(t))return Ns.get(t)??null;const n=xr(e);return Ns.set(t,n),n}function Kp(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(`
6
+ `):null}function zp(e){if(!e||typeof e!="object")return $r(e);const t=e;if(Fs.has(t))return Fs.get(t)??null;const n=$r(e);return Fs.set(t,n),n}function Kp(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 Hp(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 qp=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,jp=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,Gp=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,Vp=/^A new session was started via \/new or \/reset\./;function Qp(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"&&qp.test(s)||n==="assistant"&&jp.test(s)||n==="user"&&Vp.test(s)||n==="assistant"&&Gp.test(s)):!1}function ec(e){return e.filter(t=>!Qp(t))}function tc(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(u=>{const v=String(u.type??"").toLowerCase();return v==="toolresult"||v==="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(u=>({type:u.type||"text",text:u.text,name:u.name,args:u.args||u.arguments})):typeof t.text=="string"&&(l=[{type:"text",text:t.text}]);const d=typeof t.timestamp=="number"?t.timestamp:Date.now(),h=typeof t.id=="string"?t.id:void 0;return{role:n,content:l,timestamp:d,id:h}}function nc(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 ic(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function $r(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 Jp(){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 as(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),$r(t)}return $r(Jp())}const nn=50;async function Jt(e,t){if(!e.client||!e.connected)return;e.chatLoading=!0,e.lastError=null;const n=(t==null?void 0:t.limit)??nn;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=ec(s);e.chatMessages=a,e.chatHistoryTotal=o,e.chatHistoryHasMore=o>s.length,e.chatVerboseLevel=typeof i.verboseLevel=="string"?i.verboseLevel:null}catch(i){e.lastError=String(i)}finally{e.chatLoading=!1}}async function Yp(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:nn,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=ec(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 Xp(e){const t=/^data:(.+?);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function sc(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(v=>!v.fileName),r=(n??[]).filter(v=>v.fileName),l=[],d=r.map(v=>v.fileName).filter(Boolean);if(d.length>0){const v=i?`${d.join(", ")}
8
+ `):""}const qp=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,jp=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,Gp=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,Vp=/^A new session was started via \/new or \/reset\./;function Qp(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"&&qp.test(s)||n==="assistant"&&jp.test(s)||n==="user"&&Vp.test(s)||n==="assistant"&&Gp.test(s)):!1}function tc(e){return e.filter(t=>!Qp(t))}function nc(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(u=>{const v=String(u.type??"").toLowerCase();return v==="toolresult"||v==="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(u=>({type:u.type||"text",text:u.text,name:u.name,args:u.args||u.arguments})):typeof t.text=="string"&&(l=[{type:"text",text:t.text}]);const d=typeof t.timestamp=="number"?t.timestamp:Date.now(),h=typeof t.id=="string"?t.id:void 0;return{role:n,content:l,timestamp:d,id:h}}function ic(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 sc(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function Sr(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 Jp(){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 ls(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),Sr(t)}return Sr(Jp())}const nn=50;async function Jt(e,t){if(!e.client||!e.connected)return;e.chatLoading=!0,e.lastError=null;const n=(t==null?void 0:t.limit)??nn;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=tc(s);e.chatMessages=a,e.chatHistoryTotal=o,e.chatHistoryHasMore=o>s.length,e.chatVerboseLevel=typeof i.verboseLevel=="string"?i.verboseLevel:null}catch(i){e.lastError=String(i)}finally{e.chatLoading=!1}}async function Yp(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:nn,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=tc(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 Xp(e){const t=/^data:(.+?);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function oc(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(v=>!v.fileName),r=(n??[]).filter(v=>v.fileName),l=[],d=r.map(v=>v.fileName).filter(Boolean);if(d.length>0){const v=i?`${d.join(", ")}
9
9
 
10
- ${i}`:d.join(", ");l.push({type:"text",text:v})}else i&&l.push({type:"text",text:i});for(const v of a)l.push({type:"image",source:{type:"base64",media_type:v.mimeType,data:v.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:l,timestamp:o}],e.chatSending=!0,e.lastError=null;const h=as();e.chatRunId=h,e.chatStream="",e.chatStreamStartedAt=o;const u=[...a,...r],p=u.length>0?u.map(v=>{if(v.textContent)return{type:"document",mimeType:v.mimeType||"text/plain",fileName:v.fileName,content:btoa(unescape(encodeURIComponent(v.textContent)))};const $=Xp(v.dataUrl);return $?{type:v.fileName?"document":"image",mimeType:$.mimeType,fileName:v.fileName,content:$.content}:null}).filter(v=>v!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:i,deliver:!1,idempotencyKey:h,attachments:p}),!0}catch(v){const $=String(v);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 oc(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 ac(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}
10
+ ${i}`:d.join(", ");l.push({type:"text",text:v})}else i&&l.push({type:"text",text:i});for(const v of a)l.push({type:"image",source:{type:"base64",media_type:v.mimeType,data:v.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:l,timestamp:o}],e.chatSending=!0,e.lastError=null;const h=ls();e.chatRunId=h,e.chatStream="",e.chatStreamStartedAt=o;const u=[...a,...r],p=u.length>0?u.map(v=>{if(v.textContent)return{type:"document",mimeType:v.mimeType||"text/plain",fileName:v.fileName,content:btoa(unescape(encodeURIComponent(v.textContent)))};const $=Xp(v.dataUrl);return $?{type:v.fileName?"document":"image",mimeType:$.mimeType,fileName:v.fileName,content:$.content}:null}).filter(v=>v!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:i,deliver:!1,idempotencyKey:h,attachments:p}),!0}catch(v){const $=String(v);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 ac(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 rc(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
- ${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 Oi=Object.freeze(Object.defineProperty({__proto__:null,CHAT_PAGE_SIZE:nn,abortChatRun:oc,handleChatEvent:ac,loadChatHistory:Jt,loadOlderChatHistory:Yp,sendChatMessage:sc},Symbol.toStringTag,{value:"Module"}));async function rc(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=Ni(e.sessionsFilterActive??"",0),i=Ni(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}}}const Sr=50,Zp=80,eh=12e4;function th(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 Ar(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=th(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=Xl(n,eh);return i.truncated?`${i.text}
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 Oi=Object.freeze(Object.defineProperty({__proto__:null,CHAT_PAGE_SIZE:nn,abortChatRun:ac,handleChatEvent:rc,loadChatHistory:Jt,loadOlderChatHistory:Yp,sendChatMessage:oc},Symbol.toStringTag,{value:"Module"}));async function lc(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=Ni(e.sessionsFilterActive??"",0),i=Ni(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}}}const Ar=50,Zp=80,eh=12e4;function th(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 Cr(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=th(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=Zl(n,eh);return i.truncated?`${i.text}
14
14
 
15
- … truncated (${i.total} chars, showing first ${i.text.length}).`:i.text}function nh(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 ih(e){if(e.toolStreamOrder.length<=Sr)return;const t=e.toolStreamOrder.length-Sr,n=e.toolStreamOrder.splice(0,t);for(const i of n)e.toolStreamById.delete(i)}function sh(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function ko(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),sh(e)}function oh(e,t=!1){if(t){ko(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>ko(e),Zp))}function Zo(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],ko(e)}const ah=5e3;function rh(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},ah))}function lh(e,t){if(!t)return;if(t.stream==="compaction"){rh(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"?Ar(i.partialResult):a==="result"?Ar(i.result):void 0,d=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=d):(h={toolCallId:s,runId:t.runId,sessionKey:n,name:o,args:r,output:l,startedAt:typeof t.ts=="number"?t.ts:d,updatedAt:d,message:{}},e.toolStreamById.set(s,h),e.toolStreamOrder.push(s)),h.message=nh(h),ih(e),oh(e,a==="result")}let ci=0;function sn(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=++ci,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===ci&&(e.chatScrollFrame=requestAnimationFrame(()=>{if(e.chatScrollFrame=null,n!==ci)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!==ci)return;const l=i();if(!l)return;const d=l.scrollHeight-l.scrollTop-l.clientHeight;(t||e.chatUserNearBottom||d<200)&&(l.scrollTop=l.scrollHeight,e.chatUserNearBottom=!0)},r)}))})}function lc(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 ch(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 dh(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 uh(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function ph(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function hh(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function fh(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
15
+ … truncated (${i.total} chars, showing first ${i.text.length}).`:i.text}function nh(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 ih(e){if(e.toolStreamOrder.length<=Ar)return;const t=e.toolStreamOrder.length-Ar,n=e.toolStreamOrder.splice(0,t);for(const i of n)e.toolStreamById.delete(i)}function sh(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function $o(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),sh(e)}function oh(e,t=!1){if(t){$o(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>$o(e),Zp))}function na(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],$o(e)}const ah=5e3;function rh(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},ah))}function lh(e,t){if(!t)return;if(t.stream==="compaction"){rh(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"?Cr(i.partialResult):a==="result"?Cr(i.result):void 0,d=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=d):(h={toolCallId:s,runId:t.runId,sessionKey:n,name:o,args:r,output:l,startedAt:typeof t.ts=="number"?t.ts:d,updatedAt:d,message:{}},e.toolStreamById.set(s,h),e.toolStreamOrder.push(s)),h.message=nh(h),ih(e),oh(e,a==="result")}let ci=0;function sn(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=++ci,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===ci&&(e.chatScrollFrame=requestAnimationFrame(()=>{if(e.chatScrollFrame=null,n!==ci)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!==ci)return;const l=i();if(!l)return;const d=l.scrollHeight-l.scrollTop-l.clientHeight;(t||e.chatUserNearBottom||d<200)&&(l.scrollTop=l.scrollHeight,e.chatUserNearBottom=!0)},r)}))})}function So(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 ch(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 dh(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 uh(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function ph(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function hh(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function fh(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 gh(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 mh(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 lt(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Ct(e){return`${JSON.stringify(e,null,2).trimEnd()}
20
- `}function cc(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 We(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});vh(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function dc(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});yh(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function yh(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function vh(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?Ct(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=Ct(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=lt(t.config??{}),e.configFormOriginal=lt(t.config??{}),e.configRawOriginal=n)}async function bh(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?Ct(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 We(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function on(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 uc(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=Ni(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 pc(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=Ni(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function wh(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=uc(e.cronForm),i=pc(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 on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function kh(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 on(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function xh(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 xo(e,t.id)}catch(n){e.cronError=String(n),e.cronRunResult={status:"error",error:String(n)}}finally{e.cronBusy=!1}}}function $h(e,t){e.cronRunModalJobId&&t.jobId===e.cronRunModalJobId&&t.action==="finished"&&(e.cronRunResult={status:t.status??"unknown",durationMs:t.durationMs,summary:t.summary,outputText:t.outputText,error:t.error})}async function Sh(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 on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}function Ah(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 Ch(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=uc(e.cronForm),i=pc(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 on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function xo(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("cron.runs",{id:t,limit:50});e.cronRunsJobId=t,e.cronRuns=Array.isArray(n.entries)?n.entries:[]}catch(n){e.cronError=String(n)}}async function Z(e,t){if(!(!e.client||!e.connected)&&!e.channelsLoading){e.channelsLoading=!0,e.channelsError=null;try{const n=await e.client.request("channels.status",{probe:t,timeoutMs:8e3});e.channelsSnapshot=n,e.channelsLastSuccess=Date.now()}catch(n){e.channelsError=String(n)}finally{e.channelsLoading=!1}}}async function ea(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 hc(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 fc(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 gc(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=lt(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 d=s.hash;if(!d){e.whatsappAccountError="Config hash missing; reload and retry.";return}const h=Ct(o);await e.client.request("config.set",{raw:h,baseHash:d}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await Z(e,!0),await ea(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function mc(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=lt(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 u=h.match;return!u||u.channel!=="whatsapp"?!0:u.accountId!==t}));const l=n.hash;if(!l){e.whatsappAccountError="Config hash missing; reload and retry.";return}const d=Ct(i);await e.client.request("config.set",{raw:d,baseHash:l}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await Z(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const Eh=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:gc,loadChannels:Z,logoutWhatsApp:fc,removeWhatsAppAccount:mc,startWhatsAppLogin:ea,waitWhatsAppLogin:hc},Symbol.toStringTag,{value:"Module"}));async function ta(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 na="taskmaster-access-session",yc={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function ia(){try{return localStorage.getItem(na)}catch{return null}}function vc(e){try{localStorage.setItem(na,e)}catch{}}function Th(){try{localStorage.removeItem(na)}catch{}}async function Cr(e){if(e.client)try{const t=ia(),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 _h(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?(vc(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 Mh(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?(vc(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 Ph(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 Ih(e){const t=ia();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}Th(),e.accessState={...yc,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}const Rh=2e3,Lh=new Set(["trace","debug","info","warn","error","fatal"]);function Dh(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 Lh.has(t)?t:null}function bc(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=Dh(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 bt(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,date:e.logsDate??void 0,accessToken:ia()??void 0}),o=(Array.isArray(i.lines)?i.lines.filter(r=>typeof r=="string"):[]).map(bc),a=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=a?o:[...e.logsEntries,...o].slice(-Rh),typeof i.cursor=="number"&&(e.logsCursor=i.cursor),typeof i.file=="string"&&(e.logsFile=i.file),Array.isArray(i.availableDates)&&(e.logsAvailableDates=i.availableDates.filter(r=>typeof r=="string")),e.logsTruncated=!!i.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t!=null&&t.quiet||(e.logsLoading=!1)}}}const Nh=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:bt,parseLogLine:bc},Symbol.toStringTag,{value:"Module"}));const wc={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ue,n:Ai,Gx:Er,Gy:Tr,a:Fs,d:Us,h:Oh}=wc,Et=32,sa=64,Fh=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},re=(e="")=>{const t=new Error(e);throw Fh(t,re),t},Uh=e=>typeof e=="bigint",Wh=e=>typeof e=="string",zh=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",ct=(e,t,n="")=>{const i=zh(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}`;re(a+"expected Uint8Array"+r+", got "+l)}return e},rs=e=>new Uint8Array(e),kc=e=>Uint8Array.from(e),xc=(e,t)=>e.toString(16).padStart(t,"0"),$c=e=>Array.from(ct(e)).map(t=>xc(t,2)).join(""),Ge={_0:48,_9:57,A:65,F:70,a:97,f:102},_r=e=>{if(e>=Ge._0&&e<=Ge._9)return e-Ge._0;if(e>=Ge.A&&e<=Ge.F)return e-(Ge.A-10);if(e>=Ge.a&&e<=Ge.f)return e-(Ge.a-10)},Sc=e=>{const t="hex invalid";if(!Wh(e))return re(t);const n=e.length,i=n/2;if(n%2)return re(t);const s=rs(i);for(let o=0,a=0;o<i;o++,a+=2){const r=_r(e.charCodeAt(a)),l=_r(e.charCodeAt(a+1));if(r===void 0||l===void 0)return re(t);s[o]=r*16+l}return s},Ac=()=>globalThis==null?void 0:globalThis.crypto,Kh=()=>{var e;return((e=Ac())==null?void 0:e.subtle)??re("crypto.subtle must be defined, consider polyfill")},Kn=(...e)=>{const t=rs(e.reduce((i,s)=>i+ct(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},Hh=(e=Et)=>Ac().getRandomValues(rs(e)),Fi=BigInt,gt=(e,t,n,i="bad number: out of range")=>Uh(e)&&t<=e&&e<n?e:re(i),L=(e,t=ue)=>{const n=e%t;return n>=0n?n:t+n},Cc=e=>L(e,Ai),qh=(e,t)=>{(e===0n||t<=0n)&&re("no inverse n="+e+" mod="+t);let n=L(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?L(s,t):re("no inverse")},jh=e=>{const t=Mc[e];return typeof t!="function"&&re("hashes."+e+" not set"),t},Ws=e=>e instanceof Tt?e:re("Point expected"),$o=2n**256n,Ue=class Ue{constructor(t,n,i,s){q(this,"X");q(this,"Y");q(this,"Z");q(this,"T");const o=$o;this.X=gt(t,0n,o),this.Y=gt(n,0n,o),this.Z=gt(i,1n,o),this.T=gt(s,0n,o),Object.freeze(this)}static CURVE(){return wc}static fromAffine(t){return new Ue(t.x,t.y,1n,L(t.x*t.y))}static fromBytes(t,n=!1){const i=Us,s=kc(ct(t,Et)),o=t[31];s[31]=o&-129;const a=Tc(s);gt(a,0n,n?$o:ue);const l=L(a*a),d=L(l-1n),h=L(i*l+1n);let{isValid:u,value:p}=Vh(d,h);u||re("bad point: y not sqrt");const v=(p&1n)===1n,$=(o&128)!==0;return!n&&p===0n&&$&&re("bad point: x==0, isLastByteOdd"),$!==v&&(p=L(-p)),new Ue(p,a,1n,L(p*a))}static fromHex(t,n){return Ue.fromBytes(Sc(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Fs,n=Us,i=this;if(i.is0())return re("bad point: ZERO");const{X:s,Y:o,Z:a,T:r}=i,l=L(s*s),d=L(o*o),h=L(a*a),u=L(h*h),p=L(l*t),v=L(h*L(p+d)),$=L(u+L(n*L(l*d)));if(v!==$)return re("bad point: equation left != right (1)");const S=L(s*o),M=L(a*r);return S!==M?re("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:a,Z:r}=Ws(t),l=L(n*r),d=L(o*s),h=L(i*r),u=L(a*s);return l===d&&h===u}is0(){return this.equals(jt)}negate(){return new Ue(L(-this.X),this.Y,this.Z,L(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=Fs,o=L(t*t),a=L(n*n),r=L(2n*L(i*i)),l=L(s*o),d=t+n,h=L(L(d*d)-o-a),u=l+a,p=u-r,v=l-a,$=L(h*p),S=L(u*v),M=L(h*v),y=L(p*u);return new Ue($,S,y,M)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:a,Y:r,Z:l,T:d}=Ws(t),h=Fs,u=Us,p=L(n*a),v=L(i*r),$=L(o*u*d),S=L(s*l),M=L((n+i)*(a+r)-p-v),y=L(S-$),b=L(S+$),k=L(v-h*p),A=L(M*y),E=L(b*k),T=L(M*k),P=L(y*b);return new Ue(A,E,P,T)}subtract(t){return this.add(Ws(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return jt;if(gt(t,1n,Ai),t===1n)return this;if(this.equals(_t))return af(t).p;let i=jt,s=_t;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=qh(i,ue);L(i*s)!==1n&&re("invalid inverse");const o=L(t*s),a=L(n*s);return{x:o,y:a}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=Ec(n);return i[31]|=t&1n?128:0,i}toHex(){return $c(this.toBytes())}clearCofactor(){return this.multiply(Fi(Oh),!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(Ue,"BASE"),q(Ue,"ZERO");let Tt=Ue;const _t=new Tt(Er,Tr,1n,L(Er*Tr)),jt=new Tt(0n,1n,1n,0n);Tt.BASE=_t;Tt.ZERO=jt;const Ec=e=>Sc(xc(gt(e,0n,$o),sa)).reverse(),Tc=e=>Fi("0x"+$c(kc(ct(e)).reverse())),De=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=ue;return n},Gh=e=>{const n=e*e%ue*e%ue,i=De(n,2n)*n%ue,s=De(i,1n)*e%ue,o=De(s,5n)*s%ue,a=De(o,10n)*o%ue,r=De(a,20n)*a%ue,l=De(r,40n)*r%ue,d=De(l,80n)*l%ue,h=De(d,80n)*l%ue,u=De(h,10n)*o%ue;return{pow_p_5_8:De(u,2n)*e%ue,b2:n}},Mr=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Vh=(e,t)=>{const n=L(t*t*t),i=L(n*n*t),s=Gh(e*i).pow_p_5_8;let o=L(e*n*s);const a=L(t*o*o),r=o,l=L(o*Mr),d=a===e,h=a===L(-e),u=a===L(-e*Mr);return d&&(o=r),(h||u)&&(o=l),(L(o)&1n)===1n&&(o=L(-o)),{isValid:d||h,value:o}},So=e=>Cc(Tc(e)),oa=(...e)=>Mc.sha512Async(Kn(...e)),Qh=(...e)=>jh("sha512")(Kn(...e)),_c=e=>{const t=e.slice(0,Et);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Et,sa),i=So(t),s=_t.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},aa=e=>oa(ct(e,Et)).then(_c),Jh=e=>_c(Qh(ct(e,Et))),Yh=e=>aa(e).then(t=>t.pointBytes),Xh=e=>oa(e.hashable).then(e.finish),Zh=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=So(t),a=_t.multiply(o).toBytes();return{hashable:Kn(a,i,n),finish:d=>{const h=Cc(o+So(d)*s);return ct(Kn(a,Ec(h)),sa)}}},ef=async(e,t)=>{const n=ct(e),i=await aa(t),s=await oa(i.prefix,n);return Xh(Zh(i,s,n))},Mc={sha512Async:async e=>{const t=Kh(),n=Kn(e);return rs(await t.digest("SHA-512",n.buffer))},sha512:void 0},tf=(e=Hh(Et))=>e,nf={getExtendedPublicKeyAsync:aa,getExtendedPublicKey:Jh,randomSecretKey:tf},Ui=8,sf=256,Pc=Math.ceil(sf/Ui)+1,Ao=2**(Ui-1),of=()=>{const e=[];let t=_t,n=t;for(let i=0;i<Pc;i++){n=t,e.push(n);for(let s=1;s<Ao;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Pr;const Ir=(e,t)=>{const n=t.negate();return e?n:t},af=e=>{const t=Pr||(Pr=of());let n=jt,i=_t;const s=2**Ui,o=s,a=Fi(s-1),r=Fi(Ui);for(let l=0;l<Pc;l++){let d=Number(e&a);e>>=r,d>Ao&&(d-=o,e+=1n);const h=l*Ao,u=h,p=h+Math.abs(d)-1,v=l%2!==0,$=d<0;d===0?i=i.add(Ir(v,t[u])):n=n.add(Ir($,t[p]))}return e!==0n&&re("invalid wnaf"),{p:n,f:i}},zs="taskmaster-device-identity-v1";function Co(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Ic(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 rf(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Rc(e){const t=await crypto.subtle.digest("SHA-256",e);return rf(new Uint8Array(t))}async function lf(){const e=nf.randomSecretKey(),t=await Yh(e);return{deviceId:await Rc(t),publicKey:Co(t),privateKey:Co(e)}}async function cf(){try{const n=localStorage.getItem(zs);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 Rc(Ic(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(zs,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 lf(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(zs,JSON.stringify(t)),e}async function df(e,t){const n=Ic(e),i=new TextEncoder().encode(t),s=await ef(i,n);return Co(s)}const Lc="taskmaster.device.auth.v1";function ra(e){return e.trim()}function uf(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 la(){try{const e=window.localStorage.getItem(Lc);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 Dc(e){try{window.localStorage.setItem(Lc,JSON.stringify(e))}catch{}}function pf(e){const t=la();if(!t||t.deviceId!==e.deviceId)return null;const n=ra(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function hf(e){const t=ra(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=la();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:uf(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,Dc(n),s}function ff(e){const t=la();if(!t||t.deviceId!==e.deviceId)return;const n=ra(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],Dc(i)}async function ca(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 da(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 gf(e){return{method:"exec.approvals.get",params:{}}}async function mf(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=gf(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);yf(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function yf(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=lt(t.file??{}))}async function Bc(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 xe(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function $e(e){return e instanceof Error?e.message:String(e)}function Hn(){return{name:"",skillContent:"",references:[],alwaysActive:!1}}async function Pe(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=$e(n)}finally{e.skillsLoading=!1}}}function Nc(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Oc(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 Pe(e),xe(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=$e(i);e.skillsError=s,xe(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Fc(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 Pe(e),xe(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=$e(n);e.skillsError=i,xe(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Uc(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 Pe(e),xe(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=$e(s);e.skillsError=o,xe(e,t,{kind:"error",message:o})}finally{e.skillsBusyKey=null}}}async function Wc(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=$e(n)}}function zc(e){e.skillDetail=null,e.skillDetailTab=""}function Kc(e,t){e.skillDetailTab=t}async function Hc(e){if(e.skillAddModal=!0,e.skillAddForm=Hn(),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 qc(e){e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[]}function jc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n})),alwaysActive:!1},e.skillAddFormSource="draft"}async function Gc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n})),alwaysActive:!1},e.skillAddFormSource="installed",await ua(e)}async function ua(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,alwaysActive:t.alwaysActive}),e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillDrafts=[],await Pe(e),xe(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=Hn(),e.skillAddFormSource="draft",e.skillDrafts=[],xe(e,i,{kind:"success",message:"Draft saved"}))}catch(n){e.skillsError=$e(n)}finally{e.skillsBusyKey=null}}}async function Vc(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=$e(n)}}async function Qc(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})),alwaysActive:n.alwaysActive??!1},e.skillAddFormSource="installed",e.skillAddModal=!0,e.skillDrafts=[]}catch(n){e.skillsError=$e(n)}}function Jc(e,t){const n=e.skillDetail;n&&(e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i})),alwaysActive:n.alwaysActive??!1},e.skillAddFormSource="installed",e.skillEditTab=t&&t!=="SKILL.md"?t:"SKILL.md",e.skillDetail=null,e.skillDetailTab="",e.skillAddModal=!0,e.skillDrafts=[])}function Yc(e,t,n){e.skillAddForm={...e.skillAddForm,references:e.skillAddForm.references.map(i=>i.name===t?{...i,content:n}:i)}}function Xc(e,t){e.skillEditTab=t}async function Zc(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const i=await e.client.request("skills.read",{name:t});if(!i)return;const s=i.references.filter(o=>o.name.trim()&&o.content.trim()).map(o=>({name:o.name.trim(),content:o.content}));await e.client.request("skills.create",{name:t,skillContent:i.content,references:s.length>0?s:void 0,alwaysActive:n}),await Pe(e),xe(e,t,{kind:"success",message:n?"Skill is now always active":"Skill loads on demand"})}catch(i){e.skillsError=$e(i),xe(e,t,{kind:"error",message:$e(i)})}finally{e.skillsBusyKey=null}}}async function ed(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.update",{skillKey:t,agents:n}),await Pe(e),xe(e,t,{kind:"success",message:"Agent access updated"})}catch(i){const s=$e(i);e.skillsError=s,xe(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function td(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.delete",{name:t}),await Pe(e)}catch(n){e.skillsError=$e(n)}finally{e.skillsBusyKey=null}}}const vf=Object.freeze(Object.defineProperty({__proto__:null,closeAddSkillModal:qc,closeSkillDetail:zc,deleteDraft:Vc,deleteSkill:td,editDetailSkill:Jc,editSkill:Qc,emptyAddForm:Hn,importDraft:jc,installDraft:Gc,installSkill:Uc,loadSkills:Pe,openAddSkillModal:Hc,saveNewSkill:ua,saveSkillApiKey:Fc,setEditTab:Xc,setSkillDetailTab:Kc,toggleAlwaysActive:Zc,updateFormReference:Yc,updateSkillAgents:ed,updateSkillEdit:Nc,updateSkillEnabled:Oc,viewSkillDetail:Wc},Symbol.toStringTag,{value:"Module"})),nd={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},id=new Map(Object.entries(nd).map(([e,t])=>[t,e]));function ls(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function qn(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 bf(e,t=""){const n=ls(t),i=nd[e];return n?`${n}${i}`:i}function sd(e,t=""){const n=ls(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=qn(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":id.get(s)??null}function wf(e){let t=qn(e);if(t.endsWith("/index.html")&&(t=qn(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(id.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function kf(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function pa(e){return e==="system"?kf():e}const di=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,xf=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,ui=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},$f=({nextTheme:e,applyTheme:t,context:n,currentTheme:i})=>{var d;if(i===e)return;const s=globalThis.document??null;if(!s){t();return}const o=s.documentElement,a=s,r=xf();if(!!a.startViewTransition&&!r){let h=.5,u=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")h=di(n.pointerClientX/window.innerWidth),u=di(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=di((p.left+p.width/2)/window.innerWidth),u=di((p.top+p.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${h*100}%`),o.style.setProperty("--theme-switch-y",`${u*100}%`),o.classList.add("theme-transition");try{const p=(d=a.startViewTransition)==null?void 0:d.call(a,()=>{t()});p!=null&&p.finished?p.finished.finally(()=>ui(o)):ui(o)}catch{ui(o),t()}return}t(),ui(o)},Sf=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(-Sf),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 od=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:Pn},Symbol.toStringTag,{value:"Module"}));async function ad(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 Af(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function ze(e){return e instanceof Error?e.message:String(e)}let pi=null;function an(e,t){pi&&clearTimeout(pi),e.filesMessage={kind:"success",text:t},pi=setTimeout(()=>{e.filesMessage=null,pi=null},3e3)}async function rn(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=ze(n)}finally{e.filesLoading=!1}}}}async function Cf(e,t,n){e.filesSelectedPaths=new Set([t]),await rd(e,t,n)}async function Ef(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 rd(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function Tf(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 ld(e,o,t),i++}catch(a){s=ze(a)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:an(e,`${i} file${i!==1?"s":""} downloaded`)}async function _f(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await Rf(e,t,o,i)}async function rd(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=ze(i)}finally{e.filesPreviewLoading=!1}}}async function ld(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),d=>d.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:ze(i)}}}async function Mf(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,u)=>h+String.fromCharCode(u),"")),d={path:t,name:a.name,data:l};i&&(d.agentId=i),await e.client.request("files.upload",d),s++}catch(r){o=ze(r)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:an(e,`${s} file${s!==1?"s":""} uploaded`),await rn(e,i)}async function Pf(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),an(e,`Created ${s}`),await rn(e,i),e.filesExpandedDirs=new Set([...e.filesExpandedDirs,s]),e.filesCurrentDir=s}catch(o){e.filesMessage={kind:"error",text:ze(o)}}}async function If(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),an(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await rn(e,n)}catch(i){e.filesMessage={kind:"error",text:ze(i)}}}}async function Rf(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),an(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await rn(e,i)}catch(s){e.filesMessage={kind:"error",text:ze(s)}}}}async function cs(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 Lf(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;an(e,`Re-indexed: ${s} files, ${o} chunks`),await cs(e,t)}catch(n){e.filesMessage={kind:"error",text:ze(n)}}finally{e.filesReindexBusy=!1}}}function Df(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:ze(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function Nf(e){e.filesSearchQuery="",e.filesSearchResults=null}function Of(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{da(e,{quiet:!0})},5e3))}function Ff(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function ha(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&e.logsDate==null&&bt(e,{quiet:!0})},2e3))}function fa(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function ga(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 ma(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function ya(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&ta(e)},3e3))}function va(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Uf(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{ad(e)},3e4))}function Wf(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function zf(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{const t=e;t.filesPage&&cs(t,t.filesResolvedAgentId)},3e3))}function Kf(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function at(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,Ip(n),t.theme!==e.theme&&(e.theme=t.theme,ds(e,pa(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function cd(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&at(e,{...e.settings,lastActiveSessionKey:n})}function Hf(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&&at(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,at(e,{...e.settings,sessionKey:l,lastActiveSessionKey:l}))}if(o!=null){const l=o.trim();l&&l!==e.settings.gatewayUrl&&at(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 qf(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?ga(e):ha(e):(fa(e),ma(e)),t==="debug"?ya(e):va(e),Wi(e),ud(e,t,!1)}function jf(e,t,n){$f({nextTheme:t,applyTheme:()=>{e.theme=t,at(e,{...e.settings,theme:t}),ds(e,pa(t))},context:n,currentTheme:e.theme})}async function Wi(e){if(e.tab==="overview"&&await pd(e),e.tab==="channels"&&await Zf(e),e.tab==="instances"&&await Bc(e),e.tab==="cron"&&await hd(e),e.tab==="skills"&&await Pe(e),e.tab==="nodes"&&(await da(e),await ca(e),await We(e),await mf(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await sg(e),sn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await dc(e),await We(e)),e.tab==="debug"&&(await ta(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await ae(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>od);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await bt(e,{reset:!0});lc(e,!0)}}function Gf(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?ls(e):wf(window.location.pathname)}function Vf(e){e.theme=e.settings.theme??"system",ds(e,pa(e.theme))}function ds(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function Qf(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"&&ds(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Jf(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 Yf(e,t){if(typeof window>"u")return;const n=sd(window.location.pathname,e.basePath)??"chat";dd(e,n),ud(e,n,t)}function Xf(e){var s;if(typeof window>"u")return;const t=sd(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,at(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),dd(e,t)}function dd(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?ga(e):ha(e):(fa(e),ma(e)),t==="debug"?ya(e):va(e),e.connected&&Wi(e)}function ud(e,t,n){if(typeof window>"u")return;const i=qn(bf(t,e.basePath)),s=qn(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 pd(e){await Promise.all([Z(e,!1),Bc(e),rc(e),on(e),ta(e)])}async function Zf(e){await Promise.all([Z(e,!0),dc(e),We(e)])}async function hd(e){await Promise.all([Z(e,!1),on(e),jn(e)])}function fd(e){return e.chatSending||!!e.chatRunId}function eg(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 gd(e){e.connected&&(e.chatMessage="",await oc(e))}function tg(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:as(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],sn(e))}async function md(e,t,n){var s,o;Zo(e);const i=await sc(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&&cd(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),sn(e),i&&!e.chatRunId&&yd(e),i}async function yd(e){if(!e.connected||fd(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await md(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function ng(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function ig(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(eg(s)){await gd(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[],Lp(e.selectedWorkspace??"",e.sessionKey)),fd(e)){tg(e,s,a);return}await md(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 sg(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,nn);await Promise.all([Jt(t,{limit:n}),rc(t),Eo(e)]),sn(e,!0)}const og=yd;function ag(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 rg(e,t){const n=ls(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Eo(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=ag(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=rg(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 I={messageSquare:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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>`,user:c`<svg viewBox="0 0 24 24"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>`,menu:c`<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:c`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:c`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:c`<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:c`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:c`<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:c`<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:c`<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:c`<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>`,refreshCw:c`<svg viewBox="0 0 24 24"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/></svg>`,download:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:c`<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:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:c`<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:c`<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:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,chevronLeft:c`<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>`,chevronRight:c`<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>`,film:c`<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:c`<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:c`<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:c`<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:c`<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>`},lg=c`<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>`,cg=c`<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>`,dg=c`<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 Rr=!1;function ug(){Rr||(Rr=!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 u;const n=(p,v)=>p===e?c`<span class="sp-page-nav-current">${p}</span>`:c`<a href=${v}>${p}</a>`,i=c`
20
+ `}function cc(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 We(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});vh(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function dc(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});yh(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function yh(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function vh(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?Ct(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=Ct(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=lt(t.config??{}),e.configFormOriginal=lt(t.config??{}),e.configRawOriginal=n)}async function bh(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?Ct(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 We(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function on(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 uc(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=Ni(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 pc(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=Ni(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function wh(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=uc(e.cronForm),i=pc(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 on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function kh(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 on(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function xh(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 Ao(e,t.id)}catch(n){e.cronError=String(n),e.cronRunResult={status:"error",error:String(n)}}finally{e.cronBusy=!1}}}function $h(e,t){e.cronRunModalJobId&&t.jobId===e.cronRunModalJobId&&t.action==="finished"&&(e.cronRunResult={status:t.status??"unknown",durationMs:t.durationMs,summary:t.summary,outputText:t.outputText,error:t.error})}async function Sh(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 on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}function Ah(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 Ch(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=uc(e.cronForm),i=pc(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 on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Ao(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("cron.runs",{id:t,limit:50});e.cronRunsJobId=t,e.cronRuns=Array.isArray(n.entries)?n.entries:[]}catch(n){e.cronError=String(n)}}async function Z(e,t){if(!(!e.client||!e.connected)&&!e.channelsLoading){e.channelsLoading=!0,e.channelsError=null;try{const n=await e.client.request("channels.status",{probe:t,timeoutMs:8e3});e.channelsSnapshot=n,e.channelsLastSuccess=Date.now()}catch(n){e.channelsError=String(n)}finally{e.channelsLoading=!1}}}async function ia(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 hc(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 fc(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 gc(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=lt(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 d=s.hash;if(!d){e.whatsappAccountError="Config hash missing; reload and retry.";return}const h=Ct(o);await e.client.request("config.set",{raw:h,baseHash:d}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await Z(e,!0),await ia(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function mc(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=lt(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 u=h.match;return!u||u.channel!=="whatsapp"?!0:u.accountId!==t}));const l=n.hash;if(!l){e.whatsappAccountError="Config hash missing; reload and retry.";return}const d=Ct(i);await e.client.request("config.set",{raw:d,baseHash:l}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await Z(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const Eh=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:gc,loadChannels:Z,logoutWhatsApp:fc,removeWhatsAppAccount:mc,startWhatsAppLogin:ia,waitWhatsAppLogin:hc},Symbol.toStringTag,{value:"Module"}));async function sa(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 oa="taskmaster-access-session",yc={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function aa(){try{return localStorage.getItem(oa)}catch{return null}}function vc(e){try{localStorage.setItem(oa,e)}catch{}}function Th(){try{localStorage.removeItem(oa)}catch{}}async function Er(e){if(e.client)try{const t=aa(),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 _h(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?(vc(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 Mh(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?(vc(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 Ph(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 Ih(e){const t=aa();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}Th(),e.accessState={...yc,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}const Rh=2e3,Lh=new Set(["trace","debug","info","warn","error","fatal"]);function Dh(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 Lh.has(t)?t:null}function bc(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=Dh(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 bt(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,date:e.logsDate??void 0,accessToken:aa()??void 0}),o=(Array.isArray(i.lines)?i.lines.filter(r=>typeof r=="string"):[]).map(bc),a=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=a?o:[...e.logsEntries,...o].slice(-Rh),typeof i.cursor=="number"&&(e.logsCursor=i.cursor),typeof i.file=="string"&&(e.logsFile=i.file),Array.isArray(i.availableDates)&&(e.logsAvailableDates=i.availableDates.filter(r=>typeof r=="string")),e.logsTruncated=!!i.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t!=null&&t.quiet||(e.logsLoading=!1)}}}const Nh=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:bt,parseLogLine:bc},Symbol.toStringTag,{value:"Module"}));const wc={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ue,n:Ai,Gx:Tr,Gy:_r,a:Ws,d:zs,h:Oh}=wc,Et=32,ra=64,Fh=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},re=(e="")=>{const t=new Error(e);throw Fh(t,re),t},Uh=e=>typeof e=="bigint",Wh=e=>typeof e=="string",zh=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",ct=(e,t,n="")=>{const i=zh(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}`;re(a+"expected Uint8Array"+r+", got "+l)}return e},cs=e=>new Uint8Array(e),kc=e=>Uint8Array.from(e),xc=(e,t)=>e.toString(16).padStart(t,"0"),$c=e=>Array.from(ct(e)).map(t=>xc(t,2)).join(""),Ge={_0:48,_9:57,A:65,F:70,a:97,f:102},Mr=e=>{if(e>=Ge._0&&e<=Ge._9)return e-Ge._0;if(e>=Ge.A&&e<=Ge.F)return e-(Ge.A-10);if(e>=Ge.a&&e<=Ge.f)return e-(Ge.a-10)},Sc=e=>{const t="hex invalid";if(!Wh(e))return re(t);const n=e.length,i=n/2;if(n%2)return re(t);const s=cs(i);for(let o=0,a=0;o<i;o++,a+=2){const r=Mr(e.charCodeAt(a)),l=Mr(e.charCodeAt(a+1));if(r===void 0||l===void 0)return re(t);s[o]=r*16+l}return s},Ac=()=>globalThis==null?void 0:globalThis.crypto,Kh=()=>{var e;return((e=Ac())==null?void 0:e.subtle)??re("crypto.subtle must be defined, consider polyfill")},Kn=(...e)=>{const t=cs(e.reduce((i,s)=>i+ct(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},Hh=(e=Et)=>Ac().getRandomValues(cs(e)),Fi=BigInt,gt=(e,t,n,i="bad number: out of range")=>Uh(e)&&t<=e&&e<n?e:re(i),L=(e,t=ue)=>{const n=e%t;return n>=0n?n:t+n},Cc=e=>L(e,Ai),qh=(e,t)=>{(e===0n||t<=0n)&&re("no inverse n="+e+" mod="+t);let n=L(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?L(s,t):re("no inverse")},jh=e=>{const t=Mc[e];return typeof t!="function"&&re("hashes."+e+" not set"),t},Ks=e=>e instanceof Tt?e:re("Point expected"),Co=2n**256n,Ue=class Ue{constructor(t,n,i,s){q(this,"X");q(this,"Y");q(this,"Z");q(this,"T");const o=Co;this.X=gt(t,0n,o),this.Y=gt(n,0n,o),this.Z=gt(i,1n,o),this.T=gt(s,0n,o),Object.freeze(this)}static CURVE(){return wc}static fromAffine(t){return new Ue(t.x,t.y,1n,L(t.x*t.y))}static fromBytes(t,n=!1){const i=zs,s=kc(ct(t,Et)),o=t[31];s[31]=o&-129;const a=Tc(s);gt(a,0n,n?Co:ue);const l=L(a*a),d=L(l-1n),h=L(i*l+1n);let{isValid:u,value:p}=Vh(d,h);u||re("bad point: y not sqrt");const v=(p&1n)===1n,$=(o&128)!==0;return!n&&p===0n&&$&&re("bad point: x==0, isLastByteOdd"),$!==v&&(p=L(-p)),new Ue(p,a,1n,L(p*a))}static fromHex(t,n){return Ue.fromBytes(Sc(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Ws,n=zs,i=this;if(i.is0())return re("bad point: ZERO");const{X:s,Y:o,Z:a,T:r}=i,l=L(s*s),d=L(o*o),h=L(a*a),u=L(h*h),p=L(l*t),v=L(h*L(p+d)),$=L(u+L(n*L(l*d)));if(v!==$)return re("bad point: equation left != right (1)");const S=L(s*o),M=L(a*r);return S!==M?re("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:a,Z:r}=Ks(t),l=L(n*r),d=L(o*s),h=L(i*r),u=L(a*s);return l===d&&h===u}is0(){return this.equals(jt)}negate(){return new Ue(L(-this.X),this.Y,this.Z,L(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=Ws,o=L(t*t),a=L(n*n),r=L(2n*L(i*i)),l=L(s*o),d=t+n,h=L(L(d*d)-o-a),u=l+a,p=u-r,v=l-a,$=L(h*p),S=L(u*v),M=L(h*v),y=L(p*u);return new Ue($,S,y,M)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:a,Y:r,Z:l,T:d}=Ks(t),h=Ws,u=zs,p=L(n*a),v=L(i*r),$=L(o*u*d),S=L(s*l),M=L((n+i)*(a+r)-p-v),y=L(S-$),b=L(S+$),k=L(v-h*p),A=L(M*y),E=L(b*k),T=L(M*k),P=L(y*b);return new Ue(A,E,P,T)}subtract(t){return this.add(Ks(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return jt;if(gt(t,1n,Ai),t===1n)return this;if(this.equals(_t))return af(t).p;let i=jt,s=_t;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=qh(i,ue);L(i*s)!==1n&&re("invalid inverse");const o=L(t*s),a=L(n*s);return{x:o,y:a}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=Ec(n);return i[31]|=t&1n?128:0,i}toHex(){return $c(this.toBytes())}clearCofactor(){return this.multiply(Fi(Oh),!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(Ue,"BASE"),q(Ue,"ZERO");let Tt=Ue;const _t=new Tt(Tr,_r,1n,L(Tr*_r)),jt=new Tt(0n,1n,1n,0n);Tt.BASE=_t;Tt.ZERO=jt;const Ec=e=>Sc(xc(gt(e,0n,Co),ra)).reverse(),Tc=e=>Fi("0x"+$c(kc(ct(e)).reverse())),De=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=ue;return n},Gh=e=>{const n=e*e%ue*e%ue,i=De(n,2n)*n%ue,s=De(i,1n)*e%ue,o=De(s,5n)*s%ue,a=De(o,10n)*o%ue,r=De(a,20n)*a%ue,l=De(r,40n)*r%ue,d=De(l,80n)*l%ue,h=De(d,80n)*l%ue,u=De(h,10n)*o%ue;return{pow_p_5_8:De(u,2n)*e%ue,b2:n}},Pr=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Vh=(e,t)=>{const n=L(t*t*t),i=L(n*n*t),s=Gh(e*i).pow_p_5_8;let o=L(e*n*s);const a=L(t*o*o),r=o,l=L(o*Pr),d=a===e,h=a===L(-e),u=a===L(-e*Pr);return d&&(o=r),(h||u)&&(o=l),(L(o)&1n)===1n&&(o=L(-o)),{isValid:d||h,value:o}},Eo=e=>Cc(Tc(e)),la=(...e)=>Mc.sha512Async(Kn(...e)),Qh=(...e)=>jh("sha512")(Kn(...e)),_c=e=>{const t=e.slice(0,Et);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Et,ra),i=Eo(t),s=_t.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},ca=e=>la(ct(e,Et)).then(_c),Jh=e=>_c(Qh(ct(e,Et))),Yh=e=>ca(e).then(t=>t.pointBytes),Xh=e=>la(e.hashable).then(e.finish),Zh=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=Eo(t),a=_t.multiply(o).toBytes();return{hashable:Kn(a,i,n),finish:d=>{const h=Cc(o+Eo(d)*s);return ct(Kn(a,Ec(h)),ra)}}},ef=async(e,t)=>{const n=ct(e),i=await ca(t),s=await la(i.prefix,n);return Xh(Zh(i,s,n))},Mc={sha512Async:async e=>{const t=Kh(),n=Kn(e);return cs(await t.digest("SHA-512",n.buffer))},sha512:void 0},tf=(e=Hh(Et))=>e,nf={getExtendedPublicKeyAsync:ca,getExtendedPublicKey:Jh,randomSecretKey:tf},Ui=8,sf=256,Pc=Math.ceil(sf/Ui)+1,To=2**(Ui-1),of=()=>{const e=[];let t=_t,n=t;for(let i=0;i<Pc;i++){n=t,e.push(n);for(let s=1;s<To;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Ir;const Rr=(e,t)=>{const n=t.negate();return e?n:t},af=e=>{const t=Ir||(Ir=of());let n=jt,i=_t;const s=2**Ui,o=s,a=Fi(s-1),r=Fi(Ui);for(let l=0;l<Pc;l++){let d=Number(e&a);e>>=r,d>To&&(d-=o,e+=1n);const h=l*To,u=h,p=h+Math.abs(d)-1,v=l%2!==0,$=d<0;d===0?i=i.add(Rr(v,t[u])):n=n.add(Rr($,t[p]))}return e!==0n&&re("invalid wnaf"),{p:n,f:i}},Hs="taskmaster-device-identity-v1";function _o(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Ic(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 rf(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Rc(e){const t=await crypto.subtle.digest("SHA-256",e);return rf(new Uint8Array(t))}async function lf(){const e=nf.randomSecretKey(),t=await Yh(e);return{deviceId:await Rc(t),publicKey:_o(t),privateKey:_o(e)}}async function cf(){try{const n=localStorage.getItem(Hs);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 Rc(Ic(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(Hs,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 lf(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Hs,JSON.stringify(t)),e}async function df(e,t){const n=Ic(e),i=new TextEncoder().encode(t),s=await ef(i,n);return _o(s)}const Lc="taskmaster.device.auth.v1";function da(e){return e.trim()}function uf(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 ua(){try{const e=window.localStorage.getItem(Lc);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 Dc(e){try{window.localStorage.setItem(Lc,JSON.stringify(e))}catch{}}function pf(e){const t=ua();if(!t||t.deviceId!==e.deviceId)return null;const n=da(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function hf(e){const t=da(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=ua();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:uf(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,Dc(n),s}function ff(e){const t=ua();if(!t||t.deviceId!==e.deviceId)return;const n=da(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],Dc(i)}async function pa(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 ha(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 gf(e){return{method:"exec.approvals.get",params:{}}}async function mf(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=gf(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);yf(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function yf(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=lt(t.file??{}))}async function Bc(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 xe(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function $e(e){return e instanceof Error?e.message:String(e)}function Hn(){return{name:"",skillContent:"",references:[],alwaysActive:!1}}async function Pe(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=$e(n)}finally{e.skillsLoading=!1}}}function Nc(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Oc(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 Pe(e),xe(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=$e(i);e.skillsError=s,xe(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Fc(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 Pe(e),xe(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=$e(n);e.skillsError=i,xe(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Uc(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 Pe(e),xe(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=$e(s);e.skillsError=o,xe(e,t,{kind:"error",message:o})}finally{e.skillsBusyKey=null}}}async function Wc(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=$e(n)}}function zc(e){e.skillDetail=null,e.skillDetailTab=""}function Kc(e,t){e.skillDetailTab=t}async function Hc(e){if(e.skillAddModal=!0,e.skillAddForm=Hn(),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 qc(e){e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[]}function jc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n})),alwaysActive:!1},e.skillAddFormSource="draft"}async function Gc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n})),alwaysActive:!1},e.skillAddFormSource="installed",await fa(e)}async function fa(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,alwaysActive:t.alwaysActive}),e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillDrafts=[],await Pe(e),xe(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=Hn(),e.skillAddFormSource="draft",e.skillDrafts=[],xe(e,i,{kind:"success",message:"Draft saved"}))}catch(n){e.skillsError=$e(n)}finally{e.skillsBusyKey=null}}}async function Vc(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=$e(n)}}async function Qc(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})),alwaysActive:n.alwaysActive??!1},e.skillAddFormSource="installed",e.skillAddModal=!0,e.skillDrafts=[]}catch(n){e.skillsError=$e(n)}}function Jc(e,t){const n=e.skillDetail;n&&(e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i})),alwaysActive:n.alwaysActive??!1},e.skillAddFormSource="installed",e.skillEditTab=t&&t!=="SKILL.md"?t:"SKILL.md",e.skillDetail=null,e.skillDetailTab="",e.skillAddModal=!0,e.skillDrafts=[])}function Yc(e,t,n){e.skillAddForm={...e.skillAddForm,references:e.skillAddForm.references.map(i=>i.name===t?{...i,content:n}:i)}}function Xc(e,t){e.skillEditTab=t}async function Zc(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const i=await e.client.request("skills.read",{name:t});if(!i)return;const s=i.references.filter(o=>o.name.trim()&&o.content.trim()).map(o=>({name:o.name.trim(),content:o.content}));await e.client.request("skills.create",{name:t,skillContent:i.content,references:s.length>0?s:void 0,alwaysActive:n}),await Pe(e),xe(e,t,{kind:"success",message:n?"Skill is now always active":"Skill loads on demand"})}catch(i){e.skillsError=$e(i),xe(e,t,{kind:"error",message:$e(i)})}finally{e.skillsBusyKey=null}}}async function ed(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.update",{skillKey:t,agents:n}),await Pe(e),xe(e,t,{kind:"success",message:"Agent access updated"})}catch(i){const s=$e(i);e.skillsError=s,xe(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function td(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.delete",{name:t}),await Pe(e)}catch(n){e.skillsError=$e(n)}finally{e.skillsBusyKey=null}}}const vf=Object.freeze(Object.defineProperty({__proto__:null,closeAddSkillModal:qc,closeSkillDetail:zc,deleteDraft:Vc,deleteSkill:td,editDetailSkill:Jc,editSkill:Qc,emptyAddForm:Hn,importDraft:jc,installDraft:Gc,installSkill:Uc,loadSkills:Pe,openAddSkillModal:Hc,saveNewSkill:fa,saveSkillApiKey:Fc,setEditTab:Xc,setSkillDetailTab:Kc,toggleAlwaysActive:Zc,updateFormReference:Yc,updateSkillAgents:ed,updateSkillEdit:Nc,updateSkillEnabled:Oc,viewSkillDetail:Wc},Symbol.toStringTag,{value:"Module"})),nd={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},id=new Map(Object.entries(nd).map(([e,t])=>[t,e]));function ds(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function qn(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 bf(e,t=""){const n=ds(t),i=nd[e];return n?`${n}${i}`:i}function sd(e,t=""){const n=ds(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=qn(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":id.get(s)??null}function wf(e){let t=qn(e);if(t.endsWith("/index.html")&&(t=qn(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(id.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function kf(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function ga(e){return e==="system"?kf():e}const di=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,xf=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,ui=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},$f=({nextTheme:e,applyTheme:t,context:n,currentTheme:i})=>{var d;if(i===e)return;const s=globalThis.document??null;if(!s){t();return}const o=s.documentElement,a=s,r=xf();if(!!a.startViewTransition&&!r){let h=.5,u=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")h=di(n.pointerClientX/window.innerWidth),u=di(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=di((p.left+p.width/2)/window.innerWidth),u=di((p.top+p.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${h*100}%`),o.style.setProperty("--theme-switch-y",`${u*100}%`),o.classList.add("theme-transition");try{const p=(d=a.startViewTransition)==null?void 0:d.call(a,()=>{t()});p!=null&&p.finished?p.finished.finally(()=>ui(o)):ui(o)}catch{ui(o),t()}return}t(),ui(o)},Sf=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(-Sf),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 od=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:Pn},Symbol.toStringTag,{value:"Module"}));async function ad(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 Af(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function ze(e){return e instanceof Error?e.message:String(e)}let pi=null;function an(e,t){pi&&clearTimeout(pi),e.filesMessage={kind:"success",text:t},pi=setTimeout(()=>{e.filesMessage=null,pi=null},3e3)}async function rn(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=ze(n)}finally{e.filesLoading=!1}}}}async function Cf(e,t,n){e.filesSelectedPaths=new Set([t]),await rd(e,t,n)}async function Ef(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 rd(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function Tf(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 ld(e,o,t),i++}catch(a){s=ze(a)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:an(e,`${i} file${i!==1?"s":""} downloaded`)}async function _f(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await Rf(e,t,o,i)}async function rd(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=ze(i)}finally{e.filesPreviewLoading=!1}}}async function ld(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),d=>d.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:ze(i)}}}async function Mf(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,u)=>h+String.fromCharCode(u),"")),d={path:t,name:a.name,data:l};i&&(d.agentId=i),await e.client.request("files.upload",d),s++}catch(r){o=ze(r)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:an(e,`${s} file${s!==1?"s":""} uploaded`),await rn(e,i)}async function Pf(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),an(e,`Created ${s}`),await rn(e,i),e.filesExpandedDirs=new Set([...e.filesExpandedDirs,s]),e.filesCurrentDir=s}catch(o){e.filesMessage={kind:"error",text:ze(o)}}}async function If(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),an(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await rn(e,n)}catch(i){e.filesMessage={kind:"error",text:ze(i)}}}}async function Rf(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),an(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await rn(e,i)}catch(s){e.filesMessage={kind:"error",text:ze(s)}}}}async function us(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 Lf(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;an(e,`Re-indexed: ${s} files, ${o} chunks`),await us(e,t)}catch(n){e.filesMessage={kind:"error",text:ze(n)}}finally{e.filesReindexBusy=!1}}}function Df(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:ze(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function Nf(e){e.filesSearchQuery="",e.filesSearchResults=null}function Of(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{ha(e,{quiet:!0})},5e3))}function Ff(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function Wi(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")&&e.logsSubTab!=="session"&&e.logsDate==null&&bt(e,{quiet:!0})},2e3))}function ma(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function zi(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||Pn(e,{quiet:!0,reset:!0})},3e3))}function ya(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function va(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&sa(e)},3e3))}function ba(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Uf(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{ad(e)},3e4))}function Wf(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function zf(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{const t=e;t.filesPage&&us(t,t.filesResolvedAgentId)},3e3))}function Kf(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function at(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,Ip(n),t.theme!==e.theme&&(e.theme=t.theme,ps(e,ga(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function cd(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&at(e,{...e.settings,lastActiveSessionKey:n})}function Hf(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&&at(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,at(e,{...e.settings,sessionKey:l,lastActiveSessionKey:l}))}if(o!=null){const l=o.trim();l&&l!==e.settings.gatewayUrl&&at(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 qf(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?zi(e):Wi(e):(ma(e),ya(e)),t==="debug"?va(e):ba(e),Ki(e),ud(e,t,!1)}function jf(e,t,n){$f({nextTheme:t,applyTheme:()=>{e.theme=t,at(e,{...e.settings,theme:t}),ps(e,ga(t))},context:n,currentTheme:e.theme})}async function Ki(e){if(e.tab==="overview"&&await pd(e),e.tab==="channels"&&await Zf(e),e.tab==="instances"&&await Bc(e),e.tab==="cron"&&await hd(e),e.tab==="skills"&&await Pe(e),e.tab==="nodes"&&(await ha(e),await pa(e),await We(e),await mf(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await sg(e),sn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await dc(e),await We(e)),e.tab==="debug"&&(await sa(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await ae(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>od);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await bt(e,{reset:!0});So(e,!0)}}function Gf(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?ds(e):wf(window.location.pathname)}function Vf(e){e.theme=e.settings.theme??"system",ps(e,ga(e.theme))}function ps(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function Qf(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"&&ps(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Jf(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 Yf(e,t){if(typeof window>"u")return;const n=sd(window.location.pathname,e.basePath)??"chat";dd(e,n),ud(e,n,t)}function Xf(e){var s;if(typeof window>"u")return;const t=sd(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,at(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),dd(e,t)}function dd(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?zi(e):Wi(e):(ma(e),ya(e)),t==="debug"?va(e):ba(e),e.connected&&Ki(e)}function ud(e,t,n){if(typeof window>"u")return;const i=qn(bf(t,e.basePath)),s=qn(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 pd(e){await Promise.all([Z(e,!1),Bc(e),lc(e),on(e),sa(e)])}async function Zf(e){await Promise.all([Z(e,!0),dc(e),We(e)])}async function hd(e){await Promise.all([Z(e,!1),on(e),jn(e)])}function fd(e){return e.chatSending||!!e.chatRunId}function eg(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 gd(e){e.connected&&(e.chatMessage="",await ac(e))}function tg(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:ls(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],sn(e))}async function md(e,t,n){var s,o;na(e);const i=await oc(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&&cd(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),sn(e),i&&!e.chatRunId&&yd(e),i}async function yd(e){if(!e.connected||fd(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await md(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function ng(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function ig(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(eg(s)){await gd(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[],Lp(e.selectedWorkspace??"",e.sessionKey)),fd(e)){tg(e,s,a);return}await md(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 sg(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,nn);await Promise.all([Jt(t,{limit:n}),lc(t),Mo(e)]),sn(e,!0)}const og=yd;function ag(e){var s,o,a;const t=Yl(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 rg(e,t){const n=ds(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Mo(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=ag(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=rg(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 I={messageSquare:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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>`,user:c`<svg viewBox="0 0 24 24"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>`,menu:c`<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:c`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:c`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:c`<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:c`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:c`<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:c`<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:c`<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:c`<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>`,refreshCw:c`<svg viewBox="0 0 24 24"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/></svg>`,download:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:c`<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:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:c`<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:c`<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:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,chevronLeft:c`<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>`,chevronRight:c`<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>`,film:c`<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:c`<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:c`<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:c`<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:c`<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>`},lg=c`<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>`,cg=c`<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>`,dg=c`<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 Lr=!1;function ug(){Lr||(Lr=!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 u;const n=(p,v)=>p===e?c`<span class="sp-page-nav-current">${p}</span>`:c`<a href=${v}>${p}</a>`,i=c`
21
21
  ${n("Setup","/setup")}
22
22
  ${n("Chat","/chat")}
23
23
  ${n("Admins","/admins")}
@@ -210,7 +210,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
210
210
  <p>Connecting to gateway...</p>
211
211
  </div>
212
212
  </div>
213
- `}const zi="application/x-taskmaster-file-path";let ht=null;function vd(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function bd(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function gg(e,t,n){var o,a;e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("sp-drop-target");const i=(o=e.dataTransfer)==null?void 0:o.getData(zi);if(i){bd(i)!==t&&n.onMoveToDir(i,t);return}const s=(a=e.dataTransfer)==null?void 0:a.files;if(s&&s.length>0){const r=Array.from(s).filter(l=>l.name.toLowerCase().endsWith(".md"));r.length>0&&n.onUpload(t,r)}}function wd(e,t,n){var l;const i=e.type==="directory"||e.type==="symlink"&&e.children!=null,s=t.expandedDirs.has(e.path),o=t.selectedPaths.has(e.path),a=t.currentDir===e.path,r=n*20+12;return i?c`
213
+ `}const Hi="application/x-taskmaster-file-path";let ht=null;function vd(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function bd(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function gg(e,t,n){var o,a;e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("sp-drop-target");const i=(o=e.dataTransfer)==null?void 0:o.getData(Hi);if(i){bd(i)!==t&&n.onMoveToDir(i,t);return}const s=(a=e.dataTransfer)==null?void 0:a.files;if(s&&s.length>0){const r=Array.from(s).filter(l=>l.name.toLowerCase().endsWith(".md"));r.length>0&&n.onUpload(t,r)}}function wd(e,t,n){var l;const i=e.type==="directory"||e.type==="symlink"&&e.children!=null,s=t.expandedDirs.has(e.path),o=t.selectedPaths.has(e.path),a=t.currentDir===e.path,r=n*20+12;return i?c`
214
214
  <div
215
215
  class="sp-tree-item sp-tree-dir ${s?"expanded":""} ${a?"current":""}"
216
216
  style="padding-left: ${r}px;"
@@ -235,7 +235,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
235
235
  style="padding-left: ${r}px;"
236
236
  draggable="true"
237
237
  @click=${d=>{d.metaKey||d.ctrlKey?t.onToggleSelectFile(e.path):t.onSelectFile(e.path)}}
238
- @dragstart=${d=>{d.dataTransfer&&(d.dataTransfer.effectAllowed="move",d.dataTransfer.setData(zi,e.path),d.dataTransfer.setData("text/plain",e.name))}}
238
+ @dragstart=${d=>{d.dataTransfer&&(d.dataTransfer.effectAllowed="move",d.dataTransfer.setData(Hi,e.path),d.dataTransfer.setData("text/plain",e.name))}}
239
239
  >
240
240
  <span class="sp-tree-icon">${I.fileText}</span>
241
241
  <span class="sp-tree-name">${e.name}</span>
@@ -396,8 +396,8 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
396
396
 
397
397
  ${e.searchResults!==null?bg(e):c`<div
398
398
  class="sp-file-tree"
399
- @dragover=${n=>{n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(zi)?"move":"copy")}}
400
- @drop=${n=>{var o,a;n.preventDefault();const i=(o=n.dataTransfer)==null?void 0:o.getData(zi);if(i){bd(i)!=="."&&e.onMoveToDir(i,".");return}const s=(a=n.dataTransfer)==null?void 0:a.files;if(s&&s.length>0){const r=Array.from(s).filter(l=>l.name.toLowerCase().endsWith(".md"));r.length>0&&e.onUpload(t,r)}}}
399
+ @dragover=${n=>{n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(Hi)?"move":"copy")}}
400
+ @drop=${n=>{var o,a;n.preventDefault();const i=(o=n.dataTransfer)==null?void 0:o.getData(Hi);if(i){bd(i)!=="."&&e.onMoveToDir(i,".");return}const s=(a=n.dataTransfer)==null?void 0:a.files;if(s&&s.length>0){const r=Array.from(s).filter(l=>l.name.toLowerCase().endsWith(".md"));r.length>0&&e.onUpload(t,r)}}}
401
401
  >
402
402
  ${e.tree.length===0&&!e.loading?c`<div style="padding: 24px; color: var(--tasker-muted-grey); text-align: center;">No files found. Drop .md files here to upload.</div>`:e.tree.map(n=>wd(n,e,0))}
403
403
  </div>`}
@@ -413,7 +413,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
413
413
  <p>Connecting to gateway...</p>
414
414
  </div>
415
415
  </div>
416
- `}const ba="taskmaster_uninstall_done";async function kg(e){var t,n;if(!(!e.client||!e.connected)&&!e.uninstallBusy){e.uninstallBusy=!0,e.uninstallError=null,(t=e.requestUpdate)==null||t.call(e),xg();try{await e.client.request("system.uninstall",{scopes:["service","state","workspace"],purge:!0})}catch{}e.uninstallBusy=!1,e.uninstallDone=!0,(n=e.requestUpdate)==null||n.call(e)}}function Ki(){try{return localStorage.getItem(ba)==="1"}catch{return!1}}function wa(){try{localStorage.removeItem(ba)}catch{}}function xg(){try{localStorage.setItem(ba,"1")}catch{}}const Lr=Object.freeze(Object.defineProperty({__proto__:null,checkUninstallDone:Ki,clearUninstallDone:wa,runUninstall:kg},Symbol.toStringTag,{value:"Module"}));function Q(e){return c`
416
+ `}const wa="taskmaster_uninstall_done";async function kg(e){var t,n;if(!(!e.client||!e.connected)&&!e.uninstallBusy){e.uninstallBusy=!0,e.uninstallError=null,(t=e.requestUpdate)==null||t.call(e),xg();try{await e.client.request("system.uninstall",{scopes:["service","state","workspace"],purge:!0})}catch{}e.uninstallBusy=!1,e.uninstallDone=!0,(n=e.requestUpdate)==null||n.call(e)}}function qi(){try{return localStorage.getItem(wa)==="1"}catch{return!1}}function ka(){try{localStorage.removeItem(wa)}catch{}}function xg(){try{localStorage.setItem(wa,"1")}catch{}}const Dr=Object.freeze(Object.defineProperty({__proto__:null,checkUninstallDone:qi,clearUninstallDone:ka,runUninstall:kg},Symbol.toStringTag,{value:"Module"}));function Q(e){return c`
417
417
  <span
418
418
  class="setup-status-light"
419
419
  style="background: ${{good:"#22c55e",bad:"#ef4444",partial:"#eab308",unknown:"#6b7280"}[e]}"
@@ -432,7 +432,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
432
432
  <code style="font-size: 12px; color: var(--tasker-white); word-break: break-all; flex: 1;">${l}</code>
433
433
  <button class="setup-info-btn" title="Copy refresh token" @click=${async d=>{const h=d.currentTarget;try{await navigator.clipboard.writeText(r)}catch{const u=document.createElement("textarea");u.value=r,u.style.position="fixed",u.style.opacity="0",document.body.appendChild(u),u.select(),document.execCommand("copy"),document.body.removeChild(u)}h.classList.add("copied"),setTimeout(()=>h.classList.remove("copied"),1500)}}>${I.copy}</button>
434
434
  </div>
435
- `}break}case"license":{const o=e.licenseStoredKey?`…${e.licenseStoredKey.slice(-12)}`:"N/A";t="License",n=[{label:"Status",value:e.licenseValid?"Active":"Inactive"},{label:"What",value:"Your Taskmaster license key, tied to this specific device"},{label:"Key",value:o},{label:"Tier",value:e.licenseTier||"Standard"},{label:"Device ID",value:e.licenseDeviceId||"N/A",copyable:!!e.licenseDeviceId}];break}case"whatsapp":{const o=Lt(e),a=o?us(o,e):null;t="WhatsApp",n=[{label:"Status",value:a!=null&&a.connected?"Connected":"Disconnected"},{label:"What",value:"WhatsApp integration — receive and respond to customer messages through WhatsApp"},{label:"How",value:"Links to your WhatsApp account by scanning a QR code, then routes messages to your AI assistant"},{label:"Account",value:(a==null?void 0:a.name)||(a==null?void 0:a.accountId)||"Default"},{label:"Phone",value:((s=a==null?void 0:a.self)==null?void 0:s.e164)||"Not paired"},{label:"Linked",value:a!=null&&a.linked?"Yes":"No"},...a!=null&&a.lastError?[{label:"Last Error",value:ka(a.lastError)}]:[]];break}case"imessage":{const{thisWsOwns:o}=xa(e);t="iMessage",n=[{label:"Status",value:o&&e.imessageConnected?"Connected":"Disconnected"},{label:"What",value:"iMessage integration — communicate with your AI assistant through Apple Messages"},{label:"How",value:"Uses the Mac's built-in Messages app; only one account can own the iMessage channel at a time"},{label:"Assigned To",value:e.imessageOwnerWorkspace??"Not assigned"},{label:"Mode",value:"Self-chat only"},...e.imessageLastError?[{label:"Last Error",value:e.imessageLastError}]:[]];break}case"update":{t="Software Update",n=[{label:"Status",value:e.updateAvailable===null?"Not checked":e.updateAvailable?"Update available":"Up to date"},{label:"What",value:"Checks for new versions of Taskmaster and lets you update from the control panel"},{label:"Current",value:e.currentVersion?`v${e.currentVersion}`:"Unknown"},{label:"Latest",value:e.latestVersion?`v${e.latestVersion}`:"Unknown"},...e.updateMessage?[{label:"Message",value:e.updateMessage}]:[]];break}case"remote-access":{const o=e.tailscaleStatus,a=o?o.installed?o.loggedIn?o.serveEnabled&&o.serveActive?"Active":o.serveEnabled&&!o.serveActive?"Enabled but not active":"Off":"Not connected":"Not installed":"Checking...";if(t="Remote Access",n=[{label:"Status",value:a},{label:"What",value:"Access this control panel from anywhere — your phone, another computer, or while away from home"},{label:"How",value:"Uses Tailscale to create a private, encrypted connection with a trusted HTTPS certificate (no browser warnings)"},{label:"Requires",value:"Tailscale installed on this device and on any device you want to access the control panel from, all logged into the same Tailscale account"},{label:"Internet Access",value:"Enable internet access (globe icon) to make Public Chat reachable from the web"},{label:"Cost",value:"Tailscale is free for personal use (up to 100 devices)"}],o!=null&&o.tailnetUrl){const r=o.tailnetUrl;i=c`
435
+ `}break}case"license":{const o=e.licenseStoredKey?`…${e.licenseStoredKey.slice(-12)}`:"N/A";t="License",n=[{label:"Status",value:e.licenseValid?"Active":"Inactive"},{label:"What",value:"Your Taskmaster license key, tied to this specific device"},{label:"Key",value:o},{label:"Tier",value:e.licenseTier||"Standard"},{label:"Device ID",value:e.licenseDeviceId||"N/A",copyable:!!e.licenseDeviceId}];break}case"whatsapp":{const o=Lt(e),a=o?hs(o,e):null;t="WhatsApp",n=[{label:"Status",value:a!=null&&a.connected?"Connected":"Disconnected"},{label:"What",value:"WhatsApp integration — receive and respond to customer messages through WhatsApp"},{label:"How",value:"Links to your WhatsApp account by scanning a QR code, then routes messages to your AI assistant"},{label:"Account",value:(a==null?void 0:a.name)||(a==null?void 0:a.accountId)||"Default"},{label:"Phone",value:((s=a==null?void 0:a.self)==null?void 0:s.e164)||"Not paired"},{label:"Linked",value:a!=null&&a.linked?"Yes":"No"},...a!=null&&a.lastError?[{label:"Last Error",value:xa(a.lastError)}]:[]];break}case"imessage":{const{thisWsOwns:o}=$a(e);t="iMessage",n=[{label:"Status",value:o&&e.imessageConnected?"Connected":"Disconnected"},{label:"What",value:"iMessage integration — communicate with your AI assistant through Apple Messages"},{label:"How",value:"Uses the Mac's built-in Messages app; only one account can own the iMessage channel at a time"},{label:"Assigned To",value:e.imessageOwnerWorkspace??"Not assigned"},{label:"Mode",value:"Self-chat only"},...e.imessageLastError?[{label:"Last Error",value:e.imessageLastError}]:[]];break}case"update":{t="Software Update",n=[{label:"Status",value:e.updateAvailable===null?"Not checked":e.updateAvailable?"Update available":"Up to date"},{label:"What",value:"Checks for new versions of Taskmaster and lets you update from the control panel"},{label:"Current",value:e.currentVersion?`v${e.currentVersion}`:"Unknown"},{label:"Latest",value:e.latestVersion?`v${e.latestVersion}`:"Unknown"},...e.updateMessage?[{label:"Message",value:e.updateMessage}]:[]];break}case"remote-access":{const o=e.tailscaleStatus,a=o?o.installed?o.loggedIn?o.serveEnabled&&o.serveActive?"Active":o.serveEnabled&&!o.serveActive?"Enabled but not active":"Off":"Not connected":"Not installed":"Checking...";if(t="Remote Access",n=[{label:"Status",value:a},{label:"What",value:"Access this control panel from anywhere — your phone, another computer, or while away from home"},{label:"How",value:"Uses Tailscale to create a private, encrypted connection with a trusted HTTPS certificate (no browser warnings)"},{label:"Requires",value:"Tailscale installed on this device and on any device you want to access the control panel from, all logged into the same Tailscale account"},{label:"Internet Access",value:"Enable internet access (globe icon) to make Public Chat reachable from the web"},{label:"Cost",value:"Tailscale is free for personal use (up to 100 devices)"}],o!=null&&o.tailnetUrl){const r=o.tailnetUrl;i=c`
436
436
  ${e.remoteAccessQrDataUrl?c`<div style="text-align: center; padding: 12px 0;">
437
437
  <img src=${e.remoteAccessQrDataUrl} alt="QR code for remote access URL" style="width: 180px; height: 180px; image-rendering: pixelated; border-radius: 8px;" />
438
438
  </div>`:w}
@@ -488,7 +488,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
488
488
  </div>
489
489
  `})}
490
490
  </div>
491
- `}function Dr(e){const{licenseKey:t,licenseBusy:n,licenseValid:i,licenseMessage:s,licenseDeviceId:o,onLicenseKeyChange:a,onLicenseActivate:r}=e;return i===!0?c`
491
+ `}function Br(e){const{licenseKey:t,licenseBusy:n,licenseValid:i,licenseMessage:s,licenseDeviceId:o,onLicenseKeyChange:a,onLicenseActivate:r}=e;return i===!0?c`
492
492
  <div class="setup-container">
493
493
  <div class="setup-card setup-success">
494
494
  ${_e("license")}
@@ -689,7 +689,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
689
689
  </p>
690
690
  </div>
691
691
  </div>
692
- `}function us(e,t){const n=new Map(t.whatsappAccounts.map(i=>[i.accountId,i]));return e.whatsappAccountId?n.get(e.whatsappAccountId)??null:e.isDefault&&t.whatsappAccounts.length===1?t.whatsappAccounts[0]??null:null}function Lt(e){var n;const t=(n=e.wsProps)==null?void 0:n.selectedWorkspace;return t?e.workspaces.find(i=>i.name===t)??null:e.workspaces[0]??null}function Ag(e){const t=Lt(e),n=(t==null?void 0:t.displayName)??(t==null?void 0:t.name)??Xe().name;if(e.renamingWorkspace&&t){const i=()=>{const s=e.renameWorkspaceName.trim();s&&e.onWorkspaceRename(t.name,s)};return c`
692
+ `}function hs(e,t){const n=new Map(t.whatsappAccounts.map(i=>[i.accountId,i]));return e.whatsappAccountId?n.get(e.whatsappAccountId)??null:e.isDefault&&t.whatsappAccounts.length===1?t.whatsappAccounts[0]??null:null}function Lt(e){var n;const t=(n=e.wsProps)==null?void 0:n.selectedWorkspace;return t?e.workspaces.find(i=>i.name===t)??null:e.workspaces[0]??null}function Ag(e){const t=Lt(e),n=(t==null?void 0:t.displayName)??(t==null?void 0:t.name)??Xe().name;if(e.renamingWorkspace&&t){const i=()=>{const s=e.renameWorkspaceName.trim();s&&e.onWorkspaceRename(t.name,s)};return c`
693
693
  <div style="display: flex; align-items: center; gap: 6px; margin-bottom: 4px;">
694
694
  <input
695
695
  type="text"
@@ -807,7 +807,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
807
807
  </div>
808
808
  `:w}
809
809
  </div>
810
- `}function ka(e){var t,n;try{const i=JSON.parse(e),s=(i==null?void 0:i.error)??i,o=((n=(t=s==null?void 0:s.output)==null?void 0:t.payload)==null?void 0:n.message)??(s==null?void 0:s.message)??(i==null?void 0:i.message);if(o&&typeof o=="string")return o}catch{}return e}function _g(e){var u;const t=Lt(e);if(!t)return w;const n=us(t,e),i=(n==null?void 0:n.running)&&(n==null?void 0:n.connected),s=(n==null?void 0:n.linked)&&!i,o=!!n,a=i?"good":s?"partial":o?"bad":"unknown",r=i?"Connected":s?"Linked, not connected":o?n!=null&&n.lastError?ka(n.lastError):"Not connected":"Not paired",l=!(n!=null&&n.provider)||(n==null?void 0:n.provider)==="baileys",d=t.whatsappAccountId??(t.isDefault&&e.whatsappAccounts.length===1?(u=e.whatsappAccounts[0])==null?void 0:u.accountId:void 0),h=d!=null&&e.whatsappActiveQrAccountId===d;return c`
810
+ `}function xa(e){var t,n;try{const i=JSON.parse(e),s=(i==null?void 0:i.error)??i,o=((n=(t=s==null?void 0:s.output)==null?void 0:t.payload)==null?void 0:n.message)??(s==null?void 0:s.message)??(i==null?void 0:i.message);if(o&&typeof o=="string")return o}catch{}return e}function _g(e){var u;const t=Lt(e);if(!t)return w;const n=hs(t,e),i=(n==null?void 0:n.running)&&(n==null?void 0:n.connected),s=(n==null?void 0:n.linked)&&!i,o=!!n,a=i?"good":s?"partial":o?"bad":"unknown",r=i?"Connected":s?"Linked, not connected":o?n!=null&&n.lastError?xa(n.lastError):"Not connected":"Not paired",l=!(n!=null&&n.provider)||(n==null?void 0:n.provider)==="baileys",d=t.whatsappAccountId??(t.isDefault&&e.whatsappAccounts.length===1?(u=e.whatsappAccounts[0])==null?void 0:u.accountId:void 0),h=d!=null&&e.whatsappActiveQrAccountId===d;return c`
811
811
  <div class="setup-status-item" style="flex-wrap: wrap;">
812
812
  ${Q(a)}
813
813
  <div class="setup-status-info">
@@ -838,7 +838,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
838
838
  </div>
839
839
  `:w}
840
840
  </div>
841
- `}function Mg(e){var h,u;if(!e.whatsappSettingsOpen)return w;const t=Lt(e);if(!t)return w;const n=us(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?(h=e.whatsappAccounts[0])==null?void 0:h.accountId:void 0),a=()=>e.onWhatsAppSettingsClose(),r="display: flex; justify-content: space-between; font-size: 13px;",l="color: var(--tasker-text-grey);",d="color: var(--tasker-white); text-align: right;";return c`
841
+ `}function Mg(e){var h,u;if(!e.whatsappSettingsOpen)return w;const t=Lt(e);if(!t)return w;const n=hs(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?(h=e.whatsappAccounts[0])==null?void 0:h.accountId:void 0),a=()=>e.onWhatsAppSettingsClose(),r="display: flex; justify-content: space-between; font-size: 13px;",l="color: var(--tasker-text-grey);",d="color: var(--tasker-white); text-align: right;";return c`
842
842
  <div class="setup-info-overlay" @click=${p=>{p.target.classList.contains("setup-info-overlay")&&a()}}>
843
843
  <div class="setup-info-card" style="max-width: 360px;">
844
844
  <h3>WhatsApp</h3>
@@ -847,7 +847,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
847
847
  <div style="${r}"><span style="${l}">Phone</span><span style="${d}">${((u=n.self)==null?void 0:u.e164)||"Not paired"}</span></div>
848
848
  <div style="${r}"><span style="${l}">Connected</span><span style="${d}">${i?"Yes":"No"}</span></div>
849
849
  <div style="${r}"><span style="${l}">Linked</span><span style="${d}">${n.linked?"Yes":"No"}</span></div>
850
- ${n.lastError?c`<div style="font-size: 13px;"><div style="${l}">Error</div><div style="color: #ef4444; margin-top: 4px; line-height: 1.4;">${ka(n.lastError)}</div></div>`:w}
850
+ ${n.lastError?c`<div style="font-size: 13px;"><div style="${l}">Error</div><div style="color: #ef4444; margin-top: 4px; line-height: 1.4;">${xa(n.lastError)}</div></div>`:w}
851
851
  </div>
852
852
  ${s&&o?c`
853
853
  <div style="border-top: 1px solid rgba(255,255,255,0.08); margin: 16px 0 12px;"></div>
@@ -932,7 +932,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
932
932
  </button>
933
933
  </div>
934
934
  </div>
935
- `}function xa(e){const t=Lt(e),n=e.imessageOwnerWorkspace,i=!!(t&&n===t.name),s=!!(n&&t&&n!==t.name);return{selectedWs:t,ownerWs:n,thisWsOwns:i,anotherWsOwns:s}}function Pg(e){const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=xa(e);let s,o;return i?(s="partial",o=`Connected to ${t}`):n&&e.imessageConnected?(s="good",o="Connected"):n&&e.imessageRunning?(s="partial",o="Running, not connected"):n?(s="bad",o="Not running"):e.imessageConfigured?(s="unknown",o="Not connected"):(s="bad",o="Not configured"),c`
935
+ `}function $a(e){const t=Lt(e),n=e.imessageOwnerWorkspace,i=!!(t&&n===t.name),s=!!(n&&t&&n!==t.name);return{selectedWs:t,ownerWs:n,thisWsOwns:i,anotherWsOwns:s}}function Pg(e){const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=$a(e);let s,o;return i?(s="partial",o=`Connected to ${t}`):n&&e.imessageConnected?(s="good",o="Connected"):n&&e.imessageRunning?(s="partial",o="Running, not connected"):n?(s="bad",o="Not running"):e.imessageConfigured?(s="unknown",o="Not connected"):(s="bad",o="Not configured"),c`
936
936
  <div class="setup-status-item" style="flex-wrap: wrap;">
937
937
  ${Q(s)}
938
938
  <div class="setup-status-info">
@@ -950,7 +950,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
950
950
  </button>
951
951
  ${w}
952
952
  </div>
953
- `}function Ig(e){if(!e.imessageEnableConfirm)return w;const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=xa(e),s=()=>{e.onIMessageEnableCancel()};return n?c`
953
+ `}function Ig(e){if(!e.imessageEnableConfirm)return w;const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=$a(e),s=()=>{e.onIMessageEnableCancel()};return n?c`
954
954
  <div class="setup-info-overlay" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&s()}}>
955
955
  <div class="setup-info-card" style="text-align: center;">
956
956
  <h3>iMessage</h3>
@@ -1154,7 +1154,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1154
1154
  @click=${e.onPublicChatToggle}
1155
1155
  >${t?I.powerOff:I.power}</button>
1156
1156
  </div>
1157
- `}function Og(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"),l=Lt(e),d=l?us(l,e):null,h=!!(d!=null&&d.connected);return c`
1157
+ `}function Og(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"),l=Lt(e),d=l?hs(l,e):null,h=!!(d!=null&&d.connected);return c`
1158
1158
  <div class="setup-info-overlay" @click=${u=>{u.target.classList.contains("setup-info-overlay")&&t()}}>
1159
1159
  <div class="setup-info-card" style="max-width: 380px; max-height: 80vh; overflow-y: auto;">
1160
1160
  <h3 style="margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between;">
@@ -1693,7 +1693,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1693
1693
  >${I.powerOff}</button>
1694
1694
  ${o}
1695
1695
  </div>
1696
- `}function To(e){const t=e>=70?4:e>=50?3:e>=30?2:1;return c`
1696
+ `}function Po(e){const t=e>=70?4:e>=50?3:e>=30?2:1;return c`
1697
1697
  <span style="display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; vertical-align: middle;">
1698
1698
  ${[4,7,10,14].map((i,s)=>c`<span style="
1699
1699
  width: 3px;
@@ -1718,7 +1718,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1718
1718
  <span>NetworkManager not available</span>
1719
1719
  </div>
1720
1720
  </div>
1721
- `;const i=!!t.savedSsid&&!t.connected,s=t.connected?"good":"partial",o=t.connected?c`${t.ssid} ${t.signal!=null?c`<span style="margin-left: 4px;">${To(t.signal)}</span>`:w}`:i?c`${t.savedSsid} <span style="opacity: 0.4;">\u2014 reconnecting\u2026</span>`:"Not connected";return c`
1721
+ `;const i=!!t.savedSsid&&!t.connected,s=t.connected?"good":"partial",o=t.connected?c`${t.ssid} ${t.signal!=null?c`<span style="margin-left: 4px;">${Po(t.signal)}</span>`:w}`:i?c`${t.savedSsid} <span style="opacity: 0.4;">\u2014 reconnecting\u2026</span>`:"Not connected";return c`
1722
1722
  <div class="setup-status-item">
1723
1723
  ${Q(s)}
1724
1724
  <div class="setup-status-info">
@@ -1742,7 +1742,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1742
1742
  ${t!=null&&t.connected?c`
1743
1743
  <div style="display: flex; align-items: center; gap: 8px; margin-bottom: 12px;">
1744
1744
  <span style="color: #22c55e;">${I.wifi}</span>
1745
- <span style="font-size: 13px;">${t.ssid}${t.signal!=null?c` ${To(t.signal)}`:w}${t.ip?c` <span style="opacity: 0.5;">(${t.ip})</span>`:w}</span>
1745
+ <span style="font-size: 13px;">${t.ssid}${t.signal!=null?c` ${Po(t.signal)}`:w}${t.ip?c` <span style="opacity: 0.5;">(${t.ip})</span>`:w}</span>
1746
1746
  <button
1747
1747
  class="setup-link-btn"
1748
1748
  style="margin-left: auto; font-size: 12px;"
@@ -1800,7 +1800,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1800
1800
  </span>
1801
1801
  <span style="display: flex; align-items: center; gap: 8px;">
1802
1802
  ${o.security!=="Open"?c`<span style="opacity: 0.4; font-size: 11px;" title="${o.security}">\uD83D\uDD12</span>`:w}
1803
- <span title="Signal: ${o.signal}%">${To(o.signal)}</span>
1803
+ <span title="Signal: ${o.signal}%">${Po(o.signal)}</span>
1804
1804
  </span>
1805
1805
  </button>
1806
1806
  `})}
@@ -1947,7 +1947,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1947
1947
  ${a.status==="running"?c`<span class="setup-update-spinner"></span>`:a.status==="done"?c`<span class="setup-update-icon-ok">${I.check}</span>`:c`<span class="setup-update-icon-fail">${I.x}</span>`}
1948
1948
  </span>
1949
1949
  <span class="setup-update-step-name">${a.name}</span>
1950
- ${a.durationMs!=null?c`<span class="setup-update-step-time">${Br(a.durationMs)}</span>`:w}
1950
+ ${a.durationMs!=null?c`<span class="setup-update-step-time">${Nr(a.durationMs)}</span>`:w}
1951
1951
  </div>
1952
1952
  `)}
1953
1953
  </div>
@@ -1955,7 +1955,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1955
1955
  ${e.updateMessage?c`<p style="text-align: center; color: var(--tasker-text-grey); font-size: 13px; margin: 12px 0 0;">${e.updateMessage}</p>`:w}
1956
1956
  </div>
1957
1957
  </div>
1958
- `;if(n){const a=n.status==="ok";let r;if(a){const d=(i=n.before)==null?void 0:i.version,h=((s=n.after)==null?void 0:s.version)??n.currentVersion;r=d?`v${d} → v${h}`:`Updated to v${h}`}else r=n.reason??((o=n.failedStep)==null?void 0:o.name)??"unknown error";const l=n.durationMs!=null?Br(n.durationMs):null;return c`
1958
+ `;if(n){const a=n.status==="ok";let r;if(a){const d=(i=n.before)==null?void 0:i.version,h=((s=n.after)==null?void 0:s.version)??n.currentVersion;r=d?`v${d} → v${h}`:`Updated to v${h}`}else r=n.reason??((o=n.failedStep)==null?void 0:o.name)??"unknown error";const l=n.durationMs!=null?Nr(n.durationMs):null;return c`
1959
1959
  <div class="setup-info-overlay" @click=${d=>{d.target.classList.contains("setup-info-overlay")&&e.onUpdateDismissResult()}}>
1960
1960
  <div class="setup-info-card" style="max-width: 360px; text-align: center;">
1961
1961
  <div class="setup-update-result-icon ${a?"ok":"fail"}">${a?I.circleCheck:I.circleX}</div>
@@ -1975,7 +1975,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1975
1975
  </button>
1976
1976
  </div>
1977
1977
  </div>
1978
- `}return w}function Br(e){if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),i=t%60;return i>0?`${n}m ${i}s`:`${n}m`}function Zg(e){const t=e.accountHasPin;return c`
1978
+ `}return w}function Nr(e){if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),i=t%60;return i>0?`${n}m ${i}s`:`${n}m`}function Zg(e){const t=e.accountHasPin;return c`
1979
1979
  <div class="setup-status-item">
1980
1980
  ${Q(t?"good":"bad")}
1981
1981
  <div class="setup-status-info">
@@ -2402,7 +2402,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2402
2402
  </button>
2403
2403
  </div>
2404
2404
  </div>
2405
- `}function rm(e){const{connected:t,currentStep:n}=e;if(t&&Ki()&&wa(),e.uninstallDone||!t&&Ki())return c`
2405
+ `}function rm(e){const{connected:t,currentStep:n}=e;if(t&&qi()&&ka(),e.uninstallDone||!t&&qi())return c`
2406
2406
  <div class="setup-container">
2407
2407
  <div class="setup-card">
2408
2408
  <p style="color: var(--tasker-danger, #ef4444); font-size: 16px; font-weight: 600; margin: 0 0 12px 0;">
@@ -2425,7 +2425,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2425
2425
  <p>${o?"Restarting gateway after update…":"Connecting to gateway..."}</p>
2426
2426
  </div>
2427
2427
  </div>
2428
- `}let i;switch(n){case"license":i=Dr(e);break;case"auth":i=Sg(e);break;case"setup":i=om(e);break;default:i=Dr(e)}const s=Rt("Setup",e.wsProps);return c`${i}${$g(e)}${am(e)}${Ig(e)}${Mg(e)}${Xg(e)}${Fg(e)}${s}`}function lm(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return c`
2428
+ `}let i;switch(n){case"license":i=Br(e);break;case"auth":i=Sg(e);break;case"setup":i=om(e);break;default:i=Br(e)}const s=Rt("Setup",e.wsProps);return c`${i}${$g(e)}${am(e)}${Ig(e)}${Mg(e)}${Xg(e)}${Fg(e)}${s}`}function lm(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return c`
2429
2429
  <div class="sp-list-item">
2430
2430
  <div class="sp-list-item-main">
2431
2431
  <div class="sp-list-item-title">${e.phone}</div>
@@ -2754,11 +2754,11 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2754
2754
 
2755
2755
  ${i?um(i,e):w}
2756
2756
  ${s?pm(s,e):w}
2757
- `}const $d={CHILD:2},Sd=e=>(...t)=>({_$litDirective$:e,values:t});let Ad=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:mm}=yp,Nr=e=>e,Or=()=>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(Or(),s),r=i.insertBefore(Or(),s);n=new mm(a,r,e,e.options)}else{const a=n._$AB.nextSibling,r=n._$AM,l=r!==e;if(l){let d;(o=n._$AQ)==null||o.call(n,e),n._$AM=e,n._$AP!==void 0&&(d=e._$AU)!==r._$AU&&n._$AP(d)}if(a!==s||l){let d=n._$AA;for(;d!==a;){const h=Nr(d).nextSibling;Nr(i).insertBefore(d,s),d=h}}}return n},ft=(e,t,n=e)=>(e._$AI(t,n),e),ym={},vm=(e,t=ym)=>e._$AH=t,bm=e=>e._$AH,Ks=e=>{e._$AR(),e._$AA.remove()};const Fr=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},wm=Sd(class extends Ad{constructor(e){if(super(e),e.type!==$d.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=bm(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 d,h,u=0,p=s.length-1,v=0,$=o.length-1;for(;u<=p&&v<=$;)if(s[u]===null)u++;else if(s[p]===null)p--;else if(r[u]===a[v])l[v]=ft(s[u],o[v]),u++,v++;else if(r[p]===a[$])l[$]=ft(s[p],o[$]),p--,$--;else if(r[u]===a[$])l[$]=ft(s[u],o[$]),gn(e,l[$+1],s[u]),u++,$--;else if(r[p]===a[v])l[v]=ft(s[p],o[v]),gn(e,s[u],s[p]),p--,v++;else if(d===void 0&&(d=Fr(a,v,$),h=Fr(r,u,p)),d.has(r[u]))if(d.has(r[p])){const S=h.get(a[v]),M=S!==void 0?s[S]:null;if(M===null){const y=gn(e,s[u]);ft(y,o[v]),l[v]=y}else l[v]=ft(M,o[v]),gn(e,s[u],M),s[S]=null;v++}else Ks(s[p]),p--;else Ks(s[u]),u++;for(;v<=$;){const S=gn(e,l[$+1]);ft(S,o[v]),l[v++]=S}for(;u<=p;){const S=s[u++];S!==null&&Ks(S)}return this.ut=a,vm(e,l),rt}});class _o extends Ad{constructor(t){if(super(t),this.it=w,t.type!==$d.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===rt)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:[]}}}_o.directiveName="unsafeHTML",_o.resultType=1;const Hi=Sd(_o);const{entries:Cd,setPrototypeOf:Ur,isFrozen:km,getPrototypeOf:xm,getOwnPropertyDescriptor:$m}=Object;let{freeze:me,seal:Se,create:Mo}=Object,{apply:Po,construct:Io}=typeof Reflect<"u"&&Reflect;me||(me=function(t){return t});Se||(Se=function(t){return t});Po||(Po=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)});Io||(Io=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 hi=ye(Array.prototype.forEach),Sm=ye(Array.prototype.lastIndexOf),Wr=ye(Array.prototype.pop),mn=ye(Array.prototype.push),Am=ye(Array.prototype.splice),Ci=ye(String.prototype.toLowerCase),Hs=ye(String.prototype.toString),qs=ye(String.prototype.match),yn=ye(String.prototype.replace),Cm=ye(String.prototype.indexOf),Em=ye(String.prototype.trim),Ae=ye(Object.prototype.hasOwnProperty),fe=ye(RegExp.prototype.test),vn=Tm(TypeError);function ye(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 Po(e,t,i)}}function Tm(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Io(e,n)}}function z(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ci;Ur&&Ur(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(km(t)||(t[i]=o),s=o)}e[s]=!0}return e}function _m(e){for(let t=0;t<e.length;t++)Ae(e,t)||(e[t]=null);return e}function Ne(e){const t=Mo(null);for(const[n,i]of Cd(e))Ae(e,n)&&(Array.isArray(i)?t[n]=_m(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=Ne(i):t[n]=i);return t}function bn(e,t){for(;e!==null;){const i=$m(e,t);if(i){if(i.get)return ye(i.get);if(typeof i.value=="function")return ye(i.value)}e=xm(e)}function n(){return null}return n}const zr=me(["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"]),js=me(["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"]),Gs=me(["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"]),Mm=me(["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"]),Vs=me(["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=me(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Kr=me(["#text"]),Hr=me(["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"]),Qs=me(["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"]),qr=me(["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"]),fi=me(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Im=Se(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Rm=Se(/<%[\w\W]*|[\w\W]*%>/gm),Lm=Se(/\$\{[\w\W]*/gm),Dm=Se(/^data-[\-\w.\u00B7-\uFFFF]+$/),Bm=Se(/^aria-[\-\w]+$/),Ed=Se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Nm=Se(/^(?:\w+script|data):/i),Om=Se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Td=Se(/^html$/i),Fm=Se(/^[a-z][.\w]*(-[.\w]+)+$/i);var jr=Object.freeze({__proto__:null,ARIA_ATTR:Bm,ATTR_WHITESPACE:Om,CUSTOM_ELEMENT:Fm,DATA_ATTR:Dm,DOCTYPE_NAME:Td,ERB_EXPR:Rm,IS_ALLOWED_URI:Ed,IS_SCRIPT_OR_DATA:Nm,MUSTACHE_EXPR:Im,TMPLIT_EXPR:Lm});const wn={element:1,text:3,progressingInstruction:7,comment:8,document:9},Um=function(){return typeof window>"u"?null:window},Wm=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}},Gr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function _d(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Um();const t=N=>_d(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:d,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:u,DOMParser:p,trustedTypes:v}=e,$=l.prototype,S=bn($,"cloneNode"),M=bn($,"remove"),y=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:T,createNodeIterator:P,createDocumentFragment:D,getElementsByTagName:W}=n,{importNode:K}=i;let H=Gr();t.isSupported=typeof Cd=="function"&&typeof k=="function"&&T&&T.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ke,ERB_EXPR:Ie,TMPLIT_EXPR:Ke,DATA_ATTR:vs,ARIA_ATTR:bs,IS_SCRIPT_OR_DATA:ws,ATTR_WHITESPACE:Qn,CUSTOM_ELEMENT:ks}=jr;let{IS_ALLOWED_URI:Jn}=jr,te=null;const Yn=z({},[...zr,...js,...Gs,...Vs,...Kr]);let ne=null;const Xn=z({},[...Hr,...Qs,...qr,...fi]);let X=Object.seal(Mo(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}})),dt=null,dn=null;const et=Object.seal(Mo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Zn=!0,C=!0,R=!1,F=!0,U=!1,ee=!0,J=!1,he=!1,tt=!1,Nt=!1,ei=!1,ti=!1,Ka=!0,Ha=!1;const Uu="user-content-";let xs=!0,un=!1,Ot={},Re=null;const $s=z({},["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 qa=null;const ja=z({},["audio","video","img","source","image","track"]);let Ss=null;const Ga=z({},["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",He="http://www.w3.org/1999/xhtml";let Ft=He,As=!1,Cs=null;const Wu=z({},[ni,ii,He],Hs);let si=z({},["mi","mo","mn","ms","mtext"]),oi=z({},["annotation-xml"]);const zu=z({},["title","style","font","a","script"]);let pn=null;const Ku=["application/xhtml+xml","text/html"],Hu="text/html";let oe=null,Ut=null;const qu=n.createElement("form"),Va=function(x){return x instanceof RegExp||x instanceof Function},Es=function(){let x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ut&&Ut===x)){if((!x||typeof x!="object")&&(x={}),x=Ne(x),pn=Ku.indexOf(x.PARSER_MEDIA_TYPE)===-1?Hu:x.PARSER_MEDIA_TYPE,oe=pn==="application/xhtml+xml"?Hs:Ci,te=Ae(x,"ALLOWED_TAGS")?z({},x.ALLOWED_TAGS,oe):Yn,ne=Ae(x,"ALLOWED_ATTR")?z({},x.ALLOWED_ATTR,oe):Xn,Cs=Ae(x,"ALLOWED_NAMESPACES")?z({},x.ALLOWED_NAMESPACES,Hs):Wu,Ss=Ae(x,"ADD_URI_SAFE_ATTR")?z(Ne(Ga),x.ADD_URI_SAFE_ATTR,oe):Ga,qa=Ae(x,"ADD_DATA_URI_TAGS")?z(Ne(ja),x.ADD_DATA_URI_TAGS,oe):ja,Re=Ae(x,"FORBID_CONTENTS")?z({},x.FORBID_CONTENTS,oe):$s,dt=Ae(x,"FORBID_TAGS")?z({},x.FORBID_TAGS,oe):Ne({}),dn=Ae(x,"FORBID_ATTR")?z({},x.FORBID_ATTR,oe):Ne({}),Ot=Ae(x,"USE_PROFILES")?x.USE_PROFILES:!1,Zn=x.ALLOW_ARIA_ATTR!==!1,C=x.ALLOW_DATA_ATTR!==!1,R=x.ALLOW_UNKNOWN_PROTOCOLS||!1,F=x.ALLOW_SELF_CLOSE_IN_ATTR!==!1,U=x.SAFE_FOR_TEMPLATES||!1,ee=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,tt=x.FORCE_BODY||!1,Ka=x.SANITIZE_DOM!==!1,Ha=x.SANITIZE_NAMED_PROPS||!1,xs=x.KEEP_CONTENT!==!1,un=x.IN_PLACE||!1,Jn=x.ALLOWED_URI_REGEXP||Ed,Ft=x.NAMESPACE||He,si=x.MATHML_TEXT_INTEGRATION_POINTS||si,oi=x.HTML_INTEGRATION_POINTS||oi,X=x.CUSTOM_ELEMENT_HANDLING||{},x.CUSTOM_ELEMENT_HANDLING&&Va(x.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(X.tagNameCheck=x.CUSTOM_ELEMENT_HANDLING.tagNameCheck),x.CUSTOM_ELEMENT_HANDLING&&Va(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),U&&(C=!1),ei&&(Nt=!0),Ot&&(te=z({},Kr),ne=[],Ot.html===!0&&(z(te,zr),z(ne,Hr)),Ot.svg===!0&&(z(te,js),z(ne,Qs),z(ne,fi)),Ot.svgFilters===!0&&(z(te,Gs),z(ne,Qs),z(ne,fi)),Ot.mathMl===!0&&(z(te,Vs),z(ne,qr),z(ne,fi))),x.ADD_TAGS&&(typeof x.ADD_TAGS=="function"?et.tagCheck=x.ADD_TAGS:(te===Yn&&(te=Ne(te)),z(te,x.ADD_TAGS,oe))),x.ADD_ATTR&&(typeof x.ADD_ATTR=="function"?et.attributeCheck=x.ADD_ATTR:(ne===Xn&&(ne=Ne(ne)),z(ne,x.ADD_ATTR,oe))),x.ADD_URI_SAFE_ATTR&&z(Ss,x.ADD_URI_SAFE_ATTR,oe),x.FORBID_CONTENTS&&(Re===$s&&(Re=Ne(Re)),z(Re,x.FORBID_CONTENTS,oe)),x.ADD_FORBID_CONTENTS&&(Re===$s&&(Re=Ne(Re)),z(Re,x.ADD_FORBID_CONTENTS,oe)),xs&&(te["#text"]=!0),J&&z(te,["html","head","body"]),te.table&&(z(te,["tbody"]),delete dt.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=Wm(v,s)),A!==null&&typeof E=="string"&&(E=A.createHTML(""));me&&me(x),Ut=x}},Qa=z({},[...js,...Gs,...Mm]),Ja=z({},[...Vs,...Pm]),ju=function(x){let _=k(x);(!_||!_.tagName)&&(_={namespaceURI:Ft,tagName:"template"});const B=Ci(x.tagName),Y=Ci(_.tagName);return Cs[x.namespaceURI]?x.namespaceURI===ii?_.namespaceURI===He?B==="svg":_.namespaceURI===ni?B==="svg"&&(Y==="annotation-xml"||si[Y]):!!Qa[B]:x.namespaceURI===ni?_.namespaceURI===He?B==="math":_.namespaceURI===ii?B==="math"&&oi[Y]:!!Ja[B]:x.namespaceURI===He?_.namespaceURI===ii&&!oi[Y]||_.namespaceURI===ni&&!si[Y]?!1:!Ja[B]&&(zu[B]||!Qa[B]):!!(pn==="application/xhtml+xml"&&Cs[x.namespaceURI]):!1},Le=function(x){mn(t.removed,{element:x});try{k(x).removeChild(x)}catch{M(x)}},ut=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{Le(_)}catch{}else try{_.setAttribute(x,"")}catch{}},Ya=function(x){let _=null,B=null;if(tt)x="<remove></remove>"+x;else{const se=qs(x,/^[\r\n\t ]+/);B=se&&se[0]}pn==="application/xhtml+xml"&&Ft===He&&(x='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+x+"</body></html>");const Y=A?A.createHTML(x):x;if(Ft===He)try{_=new p().parseFromString(Y,pn)}catch{}if(!_||!_.documentElement){_=T.createDocument(Ft,"template",null);try{_.documentElement.innerHTML=As?E:Y}catch{}}const de=_.body||_.documentElement;return x&&B&&de.insertBefore(n.createTextNode(B),de.childNodes[0]||null),Ft===He?W.call(_,J?"html":"body")[0]:J?_.documentElement:de},Xa=function(x){return P.call(x.ownerDocument||x,x,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Ts=function(x){return x instanceof u&&(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")},Za=function(x){return typeof r=="function"&&x instanceof r};function qe(N,x,_){hi(N,B=>{B.call(t,x,_,Ut)})}const er=function(x){let _=null;if(qe(H.beforeSanitizeElements,x,null),Ts(x))return Le(x),!0;const B=oe(x.nodeName);if(qe(H.uponSanitizeElement,x,{tagName:B,allowedTags:te}),ee&&x.hasChildNodes()&&!Za(x.firstElementChild)&&fe(/<[/\w!]/g,x.innerHTML)&&fe(/<[/\w!]/g,x.textContent)||x.nodeType===wn.progressingInstruction||ee&&x.nodeType===wn.comment&&fe(/<[/\w]/g,x.data))return Le(x),!0;if(!(et.tagCheck instanceof Function&&et.tagCheck(B))&&(!te[B]||dt[B])){if(!dt[B]&&nr(B)&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B)))return!1;if(xs&&!Re[B]){const Y=k(x)||x.parentNode,de=b(x)||x.childNodes;if(de&&Y){const se=de.length;for(let ve=se-1;ve>=0;--ve){const je=S(de[ve],!0);je.__removalCount=(x.__removalCount||0)+1,Y.insertBefore(je,y(x))}}}return Le(x),!0}return x instanceof l&&!ju(x)||(B==="noscript"||B==="noembed"||B==="noframes")&&fe(/<\/no(script|embed|frames)/i,x.innerHTML)?(Le(x),!0):(U&&x.nodeType===wn.text&&(_=x.textContent,hi([ke,Ie,Ke],Y=>{_=yn(_,Y," ")}),x.textContent!==_&&(mn(t.removed,{element:x.cloneNode()}),x.textContent=_)),qe(H.afterSanitizeElements,x,null),!1)},tr=function(x,_,B){if(Ka&&(_==="id"||_==="name")&&(B in n||B in qu))return!1;if(!(C&&!dn[_]&&fe(vs,_))){if(!(Zn&&fe(bs,_))){if(!(et.attributeCheck instanceof Function&&et.attributeCheck(_,x))){if(!ne[_]||dn[_]){if(!(nr(x)&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,x)||X.tagNameCheck instanceof Function&&X.tagNameCheck(x))&&(X.attributeNameCheck instanceof RegExp&&fe(X.attributeNameCheck,_)||X.attributeNameCheck instanceof Function&&X.attributeNameCheck(_,x))||_==="is"&&X.allowCustomizedBuiltInElements&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B))))return!1}else if(!Ss[_]){if(!fe(Jn,yn(B,Qn,""))){if(!((_==="src"||_==="xlink:href"||_==="href")&&x!=="script"&&Cm(B,"data:")===0&&qa[x])){if(!(R&&!fe(ws,yn(B,Qn,"")))){if(B)return!1}}}}}}}return!0},nr=function(x){return x!=="annotation-xml"&&qs(x,ks)},ir=function(x){qe(H.beforeSanitizeAttributes,x,null);const{attributes:_}=x;if(!_||Ts(x))return;const B={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let Y=_.length;for(;Y--;){const de=_[Y],{name:se,namespaceURI:ve,value:je}=de,Wt=oe(se),_s=je;let le=se==="value"?_s:Em(_s);if(B.attrName=Wt,B.attrValue=le,B.keepAttr=!0,B.forceKeepAttr=void 0,qe(H.uponSanitizeAttribute,x,B),le=B.attrValue,Ha&&(Wt==="id"||Wt==="name")&&(ut(se,x),le=Uu+le),ee&&fe(/((--!?|])>)|<\/(style|title|textarea)/i,le)){ut(se,x);continue}if(Wt==="attributename"&&qs(le,"href")){ut(se,x);continue}if(B.forceKeepAttr)continue;if(!B.keepAttr){ut(se,x);continue}if(!F&&fe(/\/>/i,le)){ut(se,x);continue}U&&hi([ke,Ie,Ke],or=>{le=yn(le,or," ")});const sr=oe(x.nodeName);if(!tr(sr,Wt,le)){ut(se,x);continue}if(A&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!ve)switch(v.getAttributeType(sr,Wt)){case"TrustedHTML":{le=A.createHTML(le);break}case"TrustedScriptURL":{le=A.createScriptURL(le);break}}if(le!==_s)try{ve?x.setAttributeNS(ve,se,le):x.setAttribute(se,le),Ts(x)?Le(x):Wr(t.removed)}catch{ut(se,x)}}qe(H.afterSanitizeAttributes,x,null)},Gu=function N(x){let _=null;const B=Xa(x);for(qe(H.beforeSanitizeShadowDOM,x,null);_=B.nextNode();)qe(H.uponSanitizeShadowNode,_,null),er(_),ir(_),_.content instanceof o&&N(_.content);qe(H.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(As=!N,As&&(N="<!-->"),typeof N!="string"&&!Za(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(he||Es(x),t.removed=[],typeof N=="string"&&(un=!1),un){if(N.nodeName){const je=oe(N.nodeName);if(!te[je]||dt[je])throw vn("root node is forbidden and cannot be sanitized in-place")}}else if(N instanceof r)_=Ya("<!---->"),B=_.ownerDocument.importNode(N,!0),B.nodeType===wn.element&&B.nodeName==="BODY"||B.nodeName==="HTML"?_=B:_.appendChild(B);else{if(!Nt&&!U&&!J&&N.indexOf("<")===-1)return A&&ti?A.createHTML(N):N;if(_=Ya(N),!_)return Nt?null:ti?E:""}_&&tt&&Le(_.firstChild);const se=Xa(un?N:_);for(;Y=se.nextNode();)er(Y),ir(Y),Y.content instanceof o&&Gu(Y.content);if(un)return N;if(Nt){if(ei)for(de=D.call(_.ownerDocument);_.firstChild;)de.appendChild(_.firstChild);else de=_;return(ne.shadowroot||ne.shadowrootmode)&&(de=K.call(i,de,!0)),de}let ve=J?_.outerHTML:_.innerHTML;return J&&te["!doctype"]&&_.ownerDocument&&_.ownerDocument.doctype&&_.ownerDocument.doctype.name&&fe(Td,_.ownerDocument.doctype.name)&&(ve="<!DOCTYPE "+_.ownerDocument.doctype.name+`>
2758
- `+ve),U&&hi([ke,Ie,Ke],je=>{ve=yn(ve,je," ")}),A&&ti?A.createHTML(ve):ve},t.setConfig=function(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Es(N),he=!0},t.clearConfig=function(){Ut=null,he=!1},t.isValidAttribute=function(N,x,_){Ut||Es({});const B=oe(N),Y=oe(x);return tr(B,Y,_)},t.addHook=function(N,x){typeof x=="function"&&mn(H[N],x)},t.removeHook=function(N,x){if(x!==void 0){const _=Sm(H[N],x);return _===-1?void 0:Am(H[N],_,1)[0]}return Wr(H[N])},t.removeHooks=function(N){H[N]=[]},t.removeAllHooks=function(){H=Gr()},t}var Ro=_d();function $a(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Dt=$a();function Md(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(ge.caret,"$1"),n=n.replace(s,a),i},getRegex:()=>new RegExp(n,t)};return i}var zm=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ge={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")},Km=/^(?:[ \t]*(?:\n|$))+/,Hm=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,qm=/^ {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+|$)/,jm=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Sa=/(?:[*+-]|\d{1,9}[.)])/,Pd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Id=j(Pd).replace(/bull/g,Sa).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(),Gm=j(Pd).replace(/bull/g,Sa).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(),Aa=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Vm=/^[^\n]+/,Ca=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Qm=j(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ca).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Jm=j(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Sa).getRegex(),ps="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",Ea=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ym=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",Ea).replace("tag",ps).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Rd=j(Aa).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",ps).getRegex(),Xm=j(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Rd).getRegex(),Ta={blockquote:Xm,code:Hm,def:Qm,fences:qm,heading:jm,hr:Gn,html:Ym,lheading:Id,list:Jm,newline:Km,paragraph:Rd,table:In,text:Vm},Vr=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",ps).getRegex(),Zm={...Ta,lheading:Gm,table:Vr,paragraph:j(Aa).replace("hr",Gn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Vr).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",ps).getRegex()},ey={...Ta,html:j(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ea).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(Aa).replace("hr",Gn).replace("heading",` *#{1,6} *[^
2759
- ]`).replace("lheading",Id).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ty=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ny=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ld=/^( {2,}|\\)\n(?!\s*$)/,iy=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,hs=/[\p{P}\p{S}]/u,_a=/[\s\p{P}\p{S}]/u,Dd=/[^\s\p{P}\p{S}]/u,sy=j(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,_a).getRegex(),Bd=/(?!~)[\p{P}\p{S}]/u,oy=/(?!~)[\s\p{P}\p{S}]/u,ay=/(?:[^\s\p{P}\p{S}]|~)/u,ry=j(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",zm?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Nd=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ly=j(Nd,"u").replace(/punct/g,hs).getRegex(),cy=j(Nd,"u").replace(/punct/g,Bd).getRegex(),Od="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",dy=j(Od,"gu").replace(/notPunctSpace/g,Dd).replace(/punctSpace/g,_a).replace(/punct/g,hs).getRegex(),uy=j(Od,"gu").replace(/notPunctSpace/g,ay).replace(/punctSpace/g,oy).replace(/punct/g,Bd).getRegex(),py=j("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Dd).replace(/punctSpace/g,_a).replace(/punct/g,hs).getRegex(),hy=j(/\\(punct)/,"gu").replace(/punct/g,hs).getRegex(),fy=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(),gy=j(Ea).replace("(?:-->|$)","-->").getRegex(),my=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",gy).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),qi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,yy=j(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",qi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Fd=j(/^!?\[(label)\]\[(ref)\]/).replace("label",qi).replace("ref",Ca).getRegex(),Ud=j(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ca).getRegex(),vy=j("reflink|nolink(?!\\()","g").replace("reflink",Fd).replace("nolink",Ud).getRegex(),Qr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ma={_backpedal:In,anyPunctuation:hy,autolink:fy,blockSkip:ry,br:Ld,code:ny,del:In,emStrongLDelim:ly,emStrongRDelimAst:dy,emStrongRDelimUnd:py,escape:ty,link:yy,nolink:Ud,punctuation:sy,reflink:Fd,reflinkSearch:vy,tag:my,text:iy,url:In},by={...Ma,link:j(/^!?\[(label)\]\((.*?)\)/).replace("label",qi).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",qi).getRegex()},Lo={...Ma,emStrongRDelimAst:uy,emStrongLDelim:cy,url:j(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Qr).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",Qr).getRegex()},wy={...Lo,br:j(Ld).replace("{2,}","*").getRegex(),text:j(Lo.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},gi={normal:Ta,gfm:Zm,pedantic:ey},kn={normal:Ma,gfm:Lo,breaks:wy,pedantic:by},ky={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Jr=e=>ky[e];function Qe(e,t){if(t){if(ge.escapeTest.test(e))return e.replace(ge.escapeReplace,Jr)}else if(ge.escapeTestNoEncode.test(e))return e.replace(ge.escapeReplaceNoEncode,Jr);return e}function Yr(e){try{e=encodeURI(e).replace(ge.percentDecode,"%")}catch{return null}return e}function Xr(e,t){var o;let n=e.replace(ge.findPipe,(a,r,l)=>{let d=!1,h=r;for(;--h>=0&&l[h]==="\\";)d=!d;return d?"|":" |"}),i=n.split(ge.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(ge.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 xy(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 Zr(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 $y(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let s=i[1];return t.split(`
2757
+ `}const $d={CHILD:2},Sd=e=>(...t)=>({_$litDirective$:e,values:t});let Ad=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:mm}=yp,Or=e=>e,Fr=()=>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(Fr(),s),r=i.insertBefore(Fr(),s);n=new mm(a,r,e,e.options)}else{const a=n._$AB.nextSibling,r=n._$AM,l=r!==e;if(l){let d;(o=n._$AQ)==null||o.call(n,e),n._$AM=e,n._$AP!==void 0&&(d=e._$AU)!==r._$AU&&n._$AP(d)}if(a!==s||l){let d=n._$AA;for(;d!==a;){const h=Or(d).nextSibling;Or(i).insertBefore(d,s),d=h}}}return n},ft=(e,t,n=e)=>(e._$AI(t,n),e),ym={},vm=(e,t=ym)=>e._$AH=t,bm=e=>e._$AH,qs=e=>{e._$AR(),e._$AA.remove()};const Ur=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},wm=Sd(class extends Ad{constructor(e){if(super(e),e.type!==$d.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=bm(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 d,h,u=0,p=s.length-1,v=0,$=o.length-1;for(;u<=p&&v<=$;)if(s[u]===null)u++;else if(s[p]===null)p--;else if(r[u]===a[v])l[v]=ft(s[u],o[v]),u++,v++;else if(r[p]===a[$])l[$]=ft(s[p],o[$]),p--,$--;else if(r[u]===a[$])l[$]=ft(s[u],o[$]),gn(e,l[$+1],s[u]),u++,$--;else if(r[p]===a[v])l[v]=ft(s[p],o[v]),gn(e,s[u],s[p]),p--,v++;else if(d===void 0&&(d=Ur(a,v,$),h=Ur(r,u,p)),d.has(r[u]))if(d.has(r[p])){const S=h.get(a[v]),M=S!==void 0?s[S]:null;if(M===null){const y=gn(e,s[u]);ft(y,o[v]),l[v]=y}else l[v]=ft(M,o[v]),gn(e,s[u],M),s[S]=null;v++}else qs(s[p]),p--;else qs(s[u]),u++;for(;v<=$;){const S=gn(e,l[$+1]);ft(S,o[v]),l[v++]=S}for(;u<=p;){const S=s[u++];S!==null&&qs(S)}return this.ut=a,vm(e,l),rt}});class Io extends Ad{constructor(t){if(super(t),this.it=w,t.type!==$d.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===rt)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:[]}}}Io.directiveName="unsafeHTML",Io.resultType=1;const ji=Sd(Io);const{entries:Cd,setPrototypeOf:Wr,isFrozen:km,getPrototypeOf:xm,getOwnPropertyDescriptor:$m}=Object;let{freeze:me,seal:Se,create:Ro}=Object,{apply:Lo,construct:Do}=typeof Reflect<"u"&&Reflect;me||(me=function(t){return t});Se||(Se=function(t){return t});Lo||(Lo=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)});Do||(Do=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 hi=ye(Array.prototype.forEach),Sm=ye(Array.prototype.lastIndexOf),zr=ye(Array.prototype.pop),mn=ye(Array.prototype.push),Am=ye(Array.prototype.splice),Ci=ye(String.prototype.toLowerCase),js=ye(String.prototype.toString),Gs=ye(String.prototype.match),yn=ye(String.prototype.replace),Cm=ye(String.prototype.indexOf),Em=ye(String.prototype.trim),Ae=ye(Object.prototype.hasOwnProperty),fe=ye(RegExp.prototype.test),vn=Tm(TypeError);function ye(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 Lo(e,t,i)}}function Tm(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Do(e,n)}}function z(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ci;Wr&&Wr(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(km(t)||(t[i]=o),s=o)}e[s]=!0}return e}function _m(e){for(let t=0;t<e.length;t++)Ae(e,t)||(e[t]=null);return e}function Ne(e){const t=Ro(null);for(const[n,i]of Cd(e))Ae(e,n)&&(Array.isArray(i)?t[n]=_m(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=Ne(i):t[n]=i);return t}function bn(e,t){for(;e!==null;){const i=$m(e,t);if(i){if(i.get)return ye(i.get);if(typeof i.value=="function")return ye(i.value)}e=xm(e)}function n(){return null}return n}const Kr=me(["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"]),Vs=me(["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"]),Qs=me(["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"]),Mm=me(["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=me(["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=me(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Hr=me(["#text"]),qr=me(["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"]),Ys=me(["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"]),jr=me(["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"]),fi=me(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Im=Se(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Rm=Se(/<%[\w\W]*|[\w\W]*%>/gm),Lm=Se(/\$\{[\w\W]*/gm),Dm=Se(/^data-[\-\w.\u00B7-\uFFFF]+$/),Bm=Se(/^aria-[\-\w]+$/),Ed=Se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Nm=Se(/^(?:\w+script|data):/i),Om=Se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Td=Se(/^html$/i),Fm=Se(/^[a-z][.\w]*(-[.\w]+)+$/i);var Gr=Object.freeze({__proto__:null,ARIA_ATTR:Bm,ATTR_WHITESPACE:Om,CUSTOM_ELEMENT:Fm,DATA_ATTR:Dm,DOCTYPE_NAME:Td,ERB_EXPR:Rm,IS_ALLOWED_URI:Ed,IS_SCRIPT_OR_DATA:Nm,MUSTACHE_EXPR:Im,TMPLIT_EXPR:Lm});const wn={element:1,text:3,progressingInstruction:7,comment:8,document:9},Um=function(){return typeof window>"u"?null:window},Wm=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}},Vr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function _d(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Um();const t=N=>_d(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:d,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:u,DOMParser:p,trustedTypes:v}=e,$=l.prototype,S=bn($,"cloneNode"),M=bn($,"remove"),y=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:T,createNodeIterator:P,createDocumentFragment:D,getElementsByTagName:W}=n,{importNode:K}=i;let H=Vr();t.isSupported=typeof Cd=="function"&&typeof k=="function"&&T&&T.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ke,ERB_EXPR:Ie,TMPLIT_EXPR:Ke,DATA_ATTR:ws,ARIA_ATTR:ks,IS_SCRIPT_OR_DATA:xs,ATTR_WHITESPACE:Qn,CUSTOM_ELEMENT:$s}=Gr;let{IS_ALLOWED_URI:Jn}=Gr,te=null;const Yn=z({},[...Kr,...Vs,...Qs,...Js,...Hr]);let ne=null;const Xn=z({},[...qr,...Ys,...jr,...fi]);let X=Object.seal(Ro(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}})),dt=null,dn=null;const et=Object.seal(Ro(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Zn=!0,C=!0,R=!1,F=!0,U=!1,ee=!0,J=!1,he=!1,tt=!1,Nt=!1,ei=!1,ti=!1,Ha=!0,qa=!1;const Uu="user-content-";let Ss=!0,un=!1,Ot={},Re=null;const As=z({},["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 ja=null;const Ga=z({},["audio","video","img","source","image","track"]);let Cs=null;const Va=z({},["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",He="http://www.w3.org/1999/xhtml";let Ft=He,Es=!1,Ts=null;const Wu=z({},[ni,ii,He],js);let si=z({},["mi","mo","mn","ms","mtext"]),oi=z({},["annotation-xml"]);const zu=z({},["title","style","font","a","script"]);let pn=null;const Ku=["application/xhtml+xml","text/html"],Hu="text/html";let oe=null,Ut=null;const qu=n.createElement("form"),Qa=function(x){return x instanceof RegExp||x instanceof Function},_s=function(){let x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ut&&Ut===x)){if((!x||typeof x!="object")&&(x={}),x=Ne(x),pn=Ku.indexOf(x.PARSER_MEDIA_TYPE)===-1?Hu:x.PARSER_MEDIA_TYPE,oe=pn==="application/xhtml+xml"?js:Ci,te=Ae(x,"ALLOWED_TAGS")?z({},x.ALLOWED_TAGS,oe):Yn,ne=Ae(x,"ALLOWED_ATTR")?z({},x.ALLOWED_ATTR,oe):Xn,Ts=Ae(x,"ALLOWED_NAMESPACES")?z({},x.ALLOWED_NAMESPACES,js):Wu,Cs=Ae(x,"ADD_URI_SAFE_ATTR")?z(Ne(Va),x.ADD_URI_SAFE_ATTR,oe):Va,ja=Ae(x,"ADD_DATA_URI_TAGS")?z(Ne(Ga),x.ADD_DATA_URI_TAGS,oe):Ga,Re=Ae(x,"FORBID_CONTENTS")?z({},x.FORBID_CONTENTS,oe):As,dt=Ae(x,"FORBID_TAGS")?z({},x.FORBID_TAGS,oe):Ne({}),dn=Ae(x,"FORBID_ATTR")?z({},x.FORBID_ATTR,oe):Ne({}),Ot=Ae(x,"USE_PROFILES")?x.USE_PROFILES:!1,Zn=x.ALLOW_ARIA_ATTR!==!1,C=x.ALLOW_DATA_ATTR!==!1,R=x.ALLOW_UNKNOWN_PROTOCOLS||!1,F=x.ALLOW_SELF_CLOSE_IN_ATTR!==!1,U=x.SAFE_FOR_TEMPLATES||!1,ee=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,tt=x.FORCE_BODY||!1,Ha=x.SANITIZE_DOM!==!1,qa=x.SANITIZE_NAMED_PROPS||!1,Ss=x.KEEP_CONTENT!==!1,un=x.IN_PLACE||!1,Jn=x.ALLOWED_URI_REGEXP||Ed,Ft=x.NAMESPACE||He,si=x.MATHML_TEXT_INTEGRATION_POINTS||si,oi=x.HTML_INTEGRATION_POINTS||oi,X=x.CUSTOM_ELEMENT_HANDLING||{},x.CUSTOM_ELEMENT_HANDLING&&Qa(x.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(X.tagNameCheck=x.CUSTOM_ELEMENT_HANDLING.tagNameCheck),x.CUSTOM_ELEMENT_HANDLING&&Qa(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),U&&(C=!1),ei&&(Nt=!0),Ot&&(te=z({},Hr),ne=[],Ot.html===!0&&(z(te,Kr),z(ne,qr)),Ot.svg===!0&&(z(te,Vs),z(ne,Ys),z(ne,fi)),Ot.svgFilters===!0&&(z(te,Qs),z(ne,Ys),z(ne,fi)),Ot.mathMl===!0&&(z(te,Js),z(ne,jr),z(ne,fi))),x.ADD_TAGS&&(typeof x.ADD_TAGS=="function"?et.tagCheck=x.ADD_TAGS:(te===Yn&&(te=Ne(te)),z(te,x.ADD_TAGS,oe))),x.ADD_ATTR&&(typeof x.ADD_ATTR=="function"?et.attributeCheck=x.ADD_ATTR:(ne===Xn&&(ne=Ne(ne)),z(ne,x.ADD_ATTR,oe))),x.ADD_URI_SAFE_ATTR&&z(Cs,x.ADD_URI_SAFE_ATTR,oe),x.FORBID_CONTENTS&&(Re===As&&(Re=Ne(Re)),z(Re,x.FORBID_CONTENTS,oe)),x.ADD_FORBID_CONTENTS&&(Re===As&&(Re=Ne(Re)),z(Re,x.ADD_FORBID_CONTENTS,oe)),Ss&&(te["#text"]=!0),J&&z(te,["html","head","body"]),te.table&&(z(te,["tbody"]),delete dt.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=Wm(v,s)),A!==null&&typeof E=="string"&&(E=A.createHTML(""));me&&me(x),Ut=x}},Ja=z({},[...Vs,...Qs,...Mm]),Ya=z({},[...Js,...Pm]),ju=function(x){let _=k(x);(!_||!_.tagName)&&(_={namespaceURI:Ft,tagName:"template"});const B=Ci(x.tagName),Y=Ci(_.tagName);return Ts[x.namespaceURI]?x.namespaceURI===ii?_.namespaceURI===He?B==="svg":_.namespaceURI===ni?B==="svg"&&(Y==="annotation-xml"||si[Y]):!!Ja[B]:x.namespaceURI===ni?_.namespaceURI===He?B==="math":_.namespaceURI===ii?B==="math"&&oi[Y]:!!Ya[B]:x.namespaceURI===He?_.namespaceURI===ii&&!oi[Y]||_.namespaceURI===ni&&!si[Y]?!1:!Ya[B]&&(zu[B]||!Ja[B]):!!(pn==="application/xhtml+xml"&&Ts[x.namespaceURI]):!1},Le=function(x){mn(t.removed,{element:x});try{k(x).removeChild(x)}catch{M(x)}},ut=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{Le(_)}catch{}else try{_.setAttribute(x,"")}catch{}},Xa=function(x){let _=null,B=null;if(tt)x="<remove></remove>"+x;else{const se=Gs(x,/^[\r\n\t ]+/);B=se&&se[0]}pn==="application/xhtml+xml"&&Ft===He&&(x='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+x+"</body></html>");const Y=A?A.createHTML(x):x;if(Ft===He)try{_=new p().parseFromString(Y,pn)}catch{}if(!_||!_.documentElement){_=T.createDocument(Ft,"template",null);try{_.documentElement.innerHTML=Es?E:Y}catch{}}const de=_.body||_.documentElement;return x&&B&&de.insertBefore(n.createTextNode(B),de.childNodes[0]||null),Ft===He?W.call(_,J?"html":"body")[0]:J?_.documentElement:de},Za=function(x){return P.call(x.ownerDocument||x,x,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Ms=function(x){return x instanceof u&&(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")},er=function(x){return typeof r=="function"&&x instanceof r};function qe(N,x,_){hi(N,B=>{B.call(t,x,_,Ut)})}const tr=function(x){let _=null;if(qe(H.beforeSanitizeElements,x,null),Ms(x))return Le(x),!0;const B=oe(x.nodeName);if(qe(H.uponSanitizeElement,x,{tagName:B,allowedTags:te}),ee&&x.hasChildNodes()&&!er(x.firstElementChild)&&fe(/<[/\w!]/g,x.innerHTML)&&fe(/<[/\w!]/g,x.textContent)||x.nodeType===wn.progressingInstruction||ee&&x.nodeType===wn.comment&&fe(/<[/\w]/g,x.data))return Le(x),!0;if(!(et.tagCheck instanceof Function&&et.tagCheck(B))&&(!te[B]||dt[B])){if(!dt[B]&&ir(B)&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B)))return!1;if(Ss&&!Re[B]){const Y=k(x)||x.parentNode,de=b(x)||x.childNodes;if(de&&Y){const se=de.length;for(let ve=se-1;ve>=0;--ve){const je=S(de[ve],!0);je.__removalCount=(x.__removalCount||0)+1,Y.insertBefore(je,y(x))}}}return Le(x),!0}return x instanceof l&&!ju(x)||(B==="noscript"||B==="noembed"||B==="noframes")&&fe(/<\/no(script|embed|frames)/i,x.innerHTML)?(Le(x),!0):(U&&x.nodeType===wn.text&&(_=x.textContent,hi([ke,Ie,Ke],Y=>{_=yn(_,Y," ")}),x.textContent!==_&&(mn(t.removed,{element:x.cloneNode()}),x.textContent=_)),qe(H.afterSanitizeElements,x,null),!1)},nr=function(x,_,B){if(Ha&&(_==="id"||_==="name")&&(B in n||B in qu))return!1;if(!(C&&!dn[_]&&fe(ws,_))){if(!(Zn&&fe(ks,_))){if(!(et.attributeCheck instanceof Function&&et.attributeCheck(_,x))){if(!ne[_]||dn[_]){if(!(ir(x)&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,x)||X.tagNameCheck instanceof Function&&X.tagNameCheck(x))&&(X.attributeNameCheck instanceof RegExp&&fe(X.attributeNameCheck,_)||X.attributeNameCheck instanceof Function&&X.attributeNameCheck(_,x))||_==="is"&&X.allowCustomizedBuiltInElements&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B))))return!1}else if(!Cs[_]){if(!fe(Jn,yn(B,Qn,""))){if(!((_==="src"||_==="xlink:href"||_==="href")&&x!=="script"&&Cm(B,"data:")===0&&ja[x])){if(!(R&&!fe(xs,yn(B,Qn,"")))){if(B)return!1}}}}}}}return!0},ir=function(x){return x!=="annotation-xml"&&Gs(x,$s)},sr=function(x){qe(H.beforeSanitizeAttributes,x,null);const{attributes:_}=x;if(!_||Ms(x))return;const B={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let Y=_.length;for(;Y--;){const de=_[Y],{name:se,namespaceURI:ve,value:je}=de,Wt=oe(se),Ps=je;let le=se==="value"?Ps:Em(Ps);if(B.attrName=Wt,B.attrValue=le,B.keepAttr=!0,B.forceKeepAttr=void 0,qe(H.uponSanitizeAttribute,x,B),le=B.attrValue,qa&&(Wt==="id"||Wt==="name")&&(ut(se,x),le=Uu+le),ee&&fe(/((--!?|])>)|<\/(style|title|textarea)/i,le)){ut(se,x);continue}if(Wt==="attributename"&&Gs(le,"href")){ut(se,x);continue}if(B.forceKeepAttr)continue;if(!B.keepAttr){ut(se,x);continue}if(!F&&fe(/\/>/i,le)){ut(se,x);continue}U&&hi([ke,Ie,Ke],ar=>{le=yn(le,ar," ")});const or=oe(x.nodeName);if(!nr(or,Wt,le)){ut(se,x);continue}if(A&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!ve)switch(v.getAttributeType(or,Wt)){case"TrustedHTML":{le=A.createHTML(le);break}case"TrustedScriptURL":{le=A.createScriptURL(le);break}}if(le!==Ps)try{ve?x.setAttributeNS(ve,se,le):x.setAttribute(se,le),Ms(x)?Le(x):zr(t.removed)}catch{ut(se,x)}}qe(H.afterSanitizeAttributes,x,null)},Gu=function N(x){let _=null;const B=Za(x);for(qe(H.beforeSanitizeShadowDOM,x,null);_=B.nextNode();)qe(H.uponSanitizeShadowNode,_,null),tr(_),sr(_),_.content instanceof o&&N(_.content);qe(H.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(Es=!N,Es&&(N="<!-->"),typeof N!="string"&&!er(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(he||_s(x),t.removed=[],typeof N=="string"&&(un=!1),un){if(N.nodeName){const je=oe(N.nodeName);if(!te[je]||dt[je])throw vn("root node is forbidden and cannot be sanitized in-place")}}else if(N instanceof r)_=Xa("<!---->"),B=_.ownerDocument.importNode(N,!0),B.nodeType===wn.element&&B.nodeName==="BODY"||B.nodeName==="HTML"?_=B:_.appendChild(B);else{if(!Nt&&!U&&!J&&N.indexOf("<")===-1)return A&&ti?A.createHTML(N):N;if(_=Xa(N),!_)return Nt?null:ti?E:""}_&&tt&&Le(_.firstChild);const se=Za(un?N:_);for(;Y=se.nextNode();)tr(Y),sr(Y),Y.content instanceof o&&Gu(Y.content);if(un)return N;if(Nt){if(ei)for(de=D.call(_.ownerDocument);_.firstChild;)de.appendChild(_.firstChild);else de=_;return(ne.shadowroot||ne.shadowrootmode)&&(de=K.call(i,de,!0)),de}let ve=J?_.outerHTML:_.innerHTML;return J&&te["!doctype"]&&_.ownerDocument&&_.ownerDocument.doctype&&_.ownerDocument.doctype.name&&fe(Td,_.ownerDocument.doctype.name)&&(ve="<!DOCTYPE "+_.ownerDocument.doctype.name+`>
2758
+ `+ve),U&&hi([ke,Ie,Ke],je=>{ve=yn(ve,je," ")}),A&&ti?A.createHTML(ve):ve},t.setConfig=function(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_s(N),he=!0},t.clearConfig=function(){Ut=null,he=!1},t.isValidAttribute=function(N,x,_){Ut||_s({});const B=oe(N),Y=oe(x);return nr(B,Y,_)},t.addHook=function(N,x){typeof x=="function"&&mn(H[N],x)},t.removeHook=function(N,x){if(x!==void 0){const _=Sm(H[N],x);return _===-1?void 0:Am(H[N],_,1)[0]}return zr(H[N])},t.removeHooks=function(N){H[N]=[]},t.removeAllHooks=function(){H=Vr()},t}var Bo=_d();function Sa(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Dt=Sa();function Md(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(ge.caret,"$1"),n=n.replace(s,a),i},getRegex:()=>new RegExp(n,t)};return i}var zm=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ge={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")},Km=/^(?:[ \t]*(?:\n|$))+/,Hm=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,qm=/^ {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+|$)/,jm=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Aa=/(?:[*+-]|\d{1,9}[.)])/,Pd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Id=j(Pd).replace(/bull/g,Aa).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(),Gm=j(Pd).replace(/bull/g,Aa).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(),Ca=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Vm=/^[^\n]+/,Ea=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Qm=j(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ea).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Jm=j(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Aa).getRegex(),fs="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",Ta=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ym=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",Ta).replace("tag",fs).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Rd=j(Ca).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",fs).getRegex(),Xm=j(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Rd).getRegex(),_a={blockquote:Xm,code:Hm,def:Qm,fences:qm,heading:jm,hr:Gn,html:Ym,lheading:Id,list:Jm,newline:Km,paragraph:Rd,table:In,text:Vm},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",fs).getRegex(),Zm={..._a,lheading:Gm,table:Qr,paragraph:j(Ca).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",fs).getRegex()},ey={..._a,html:j(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ta).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(Ca).replace("hr",Gn).replace("heading",` *#{1,6} *[^
2759
+ ]`).replace("lheading",Id).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ty=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ny=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ld=/^( {2,}|\\)\n(?!\s*$)/,iy=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,gs=/[\p{P}\p{S}]/u,Ma=/[\s\p{P}\p{S}]/u,Dd=/[^\s\p{P}\p{S}]/u,sy=j(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ma).getRegex(),Bd=/(?!~)[\p{P}\p{S}]/u,oy=/(?!~)[\s\p{P}\p{S}]/u,ay=/(?:[^\s\p{P}\p{S}]|~)/u,ry=j(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",zm?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Nd=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ly=j(Nd,"u").replace(/punct/g,gs).getRegex(),cy=j(Nd,"u").replace(/punct/g,Bd).getRegex(),Od="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",dy=j(Od,"gu").replace(/notPunctSpace/g,Dd).replace(/punctSpace/g,Ma).replace(/punct/g,gs).getRegex(),uy=j(Od,"gu").replace(/notPunctSpace/g,ay).replace(/punctSpace/g,oy).replace(/punct/g,Bd).getRegex(),py=j("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Dd).replace(/punctSpace/g,Ma).replace(/punct/g,gs).getRegex(),hy=j(/\\(punct)/,"gu").replace(/punct/g,gs).getRegex(),fy=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(),gy=j(Ta).replace("(?:-->|$)","-->").getRegex(),my=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",gy).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Gi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,yy=j(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Gi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Fd=j(/^!?\[(label)\]\[(ref)\]/).replace("label",Gi).replace("ref",Ea).getRegex(),Ud=j(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ea).getRegex(),vy=j("reflink|nolink(?!\\()","g").replace("reflink",Fd).replace("nolink",Ud).getRegex(),Jr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Pa={_backpedal:In,anyPunctuation:hy,autolink:fy,blockSkip:ry,br:Ld,code:ny,del:In,emStrongLDelim:ly,emStrongRDelimAst:dy,emStrongRDelimUnd:py,escape:ty,link:yy,nolink:Ud,punctuation:sy,reflink:Fd,reflinkSearch:vy,tag:my,text:iy,url:In},by={...Pa,link:j(/^!?\[(label)\]\((.*?)\)/).replace("label",Gi).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Gi).getRegex()},No={...Pa,emStrongRDelimAst:uy,emStrongLDelim:cy,url:j(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Jr).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",Jr).getRegex()},wy={...No,br:j(Ld).replace("{2,}","*").getRegex(),text:j(No.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},gi={normal:_a,gfm:Zm,pedantic:ey},kn={normal:Pa,gfm:No,breaks:wy,pedantic:by},ky={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Yr=e=>ky[e];function Qe(e,t){if(t){if(ge.escapeTest.test(e))return e.replace(ge.escapeReplace,Yr)}else if(ge.escapeTestNoEncode.test(e))return e.replace(ge.escapeReplaceNoEncode,Yr);return e}function Xr(e){try{e=encodeURI(e).replace(ge.percentDecode,"%")}catch{return null}return e}function Zr(e,t){var o;let n=e.replace(ge.findPipe,(a,r,l)=>{let d=!1,h=r;for(;--h>=0&&l[h]==="\\";)d=!d;return d?"|":" |"}),i=n.split(ge.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(ge.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 xy(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 el(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 $y(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let s=i[1];return t.split(`
2760
2760
  `).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(`
2761
- `)}var ji=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,`
2761
+ `)}var Vi=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,`
2762
2762
  `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=$y(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],`
2763
2763
  `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=xn(t[0],`
2764
2764
  `).split(`
@@ -2778,9 +2778,9 @@ ${h}`:h;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
2778
2778
  `,1)[0],P;if($=T,this.options.pedantic?($=$.replace(this.rules.other.listReplaceNesting," "),P=$):P=$.replace(this.rules.other.tabCharGlobal," "),k.test($)||A.test($)||E.test($)||y.test($)||b.test($))break;if(P.search(this.rules.other.nonSpaceChar)>=M||!$.trim())p+=`
2779
2779
  `+P.slice(M);else{if(S||v.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||k.test(v)||A.test(v)||b.test(v))break;p+=`
2780
2780
  `+$}!S&&!$.trim()&&(S=!0),u+=T+`
2781
- `,e=e.substring(T.length+1),v=P.slice(M)}}a.loose||(l?a.loose=!0:this.rules.other.doubleBlankLine.test(u)&&(l=!0)),a.items.push({type:"list_item",raw:u,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),a.raw+=u}let d=a.items.at(-1);if(d)d.raw=d.raw.trimEnd(),d.text=d.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 u=this.rules.other.listTaskCheckbox.exec(h.raw);if(u){let p={type:"checkbox",raw:u[0]+" ",checked:u[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 u=h.tokens.filter(v=>v.type==="space"),p=u.length>0&&u.some(v=>this.rules.other.anyLine.test(v.raw));a.loose=p}}if(a.loose)for(let h of a.items){h.loose=!0;for(let u of h.tokens)u.type==="text"&&(u.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=Xr(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(`
2782
- `):[],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(Xr(r,o.header.length).map((l,d)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:o.align[d]})));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)===`
2783
- `?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=xy(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)),Zr(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 Zr(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,d=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+s);(i=d.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,u=e.slice(0,s+i.index+h+a);if(Math.min(s,a)%2){let v=u.slice(1,-1);return{type:"em",raw:u,text:v,tokens:this.lexer.inlineTokens(v)}}let p=u.slice(2,-2);return{type:"strong",raw:u,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}}}},Ee=class Do{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 ji,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:ge,block:gi.normal,inline:kn.normal};this.options.pedantic?(n.block=gi.pedantic,n.inline=kn.pedantic):this.options.gfm&&(n.block=gi.gfm,this.options.breaks?n.inline=kn.breaks:n.inline=kn.gfm),this.tokenizer.rules=n}static get rules(){return{block:gi,inline:kn}}static lex(t,n){return new Do(n).lex(t)}static lexInline(t,n){return new Do(n).inlineTokens(t)}lex(t){t=t.replace(ge.carriageReturn,`
2781
+ `,e=e.substring(T.length+1),v=P.slice(M)}}a.loose||(l?a.loose=!0:this.rules.other.doubleBlankLine.test(u)&&(l=!0)),a.items.push({type:"list_item",raw:u,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),a.raw+=u}let d=a.items.at(-1);if(d)d.raw=d.raw.trimEnd(),d.text=d.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 u=this.rules.other.listTaskCheckbox.exec(h.raw);if(u){let p={type:"checkbox",raw:u[0]+" ",checked:u[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 u=h.tokens.filter(v=>v.type==="space"),p=u.length>0&&u.some(v=>this.rules.other.anyLine.test(v.raw));a.loose=p}}if(a.loose)for(let h of a.items){h.loose=!0;for(let u of h.tokens)u.type==="text"&&(u.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=Zr(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(`
2782
+ `):[],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(Zr(r,o.header.length).map((l,d)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:o.align[d]})));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)===`
2783
+ `?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=xy(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)),el(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 el(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,d=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+s);(i=d.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,u=e.slice(0,s+i.index+h+a);if(Math.min(s,a)%2){let v=u.slice(1,-1);return{type:"em",raw:u,text:v,tokens:this.lexer.inlineTokens(v)}}let p=u.slice(2,-2);return{type:"strong",raw:u,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}}}},Ee=class Oo{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 Vi,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:ge,block:gi.normal,inline:kn.normal};this.options.pedantic?(n.block=gi.pedantic,n.inline=kn.pedantic):this.options.gfm&&(n.block=gi.gfm,this.options.breaks?n.inline=kn.breaks:n.inline=kn.gfm),this.tokenizer.rules=n}static get rules(){return{block:gi,inline:kn}}static lex(t,n){return new Oo(n).lex(t)}static lexInline(t,n){return new Oo(n).inlineTokens(t)}lex(t){t=t.replace(ge.carriageReturn,`
2784
2784
  `),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(ge.tabCharGlobal," ").replace(ge.spaceLine,""));t;){let r;if((o=(s=this.options.extensions)==null?void 0:s.block)!=null&&o.some(d=>(r=d.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 d=n.at(-1);r.raw.length===1&&d!==void 0?d.raw+=`
2785
2785
  `:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length);let d=n.at(-1);(d==null?void 0:d.type)==="paragraph"||(d==null?void 0:d.type)==="text"?(d.raw+=(d.raw.endsWith(`
2786
2786
  `)?"":`
@@ -2794,7 +2794,7 @@ ${h}`:h;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
2794
2794
  `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=d.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 d=n.at(-1);(d==null?void 0:d.type)==="text"?(d.raw+=(d.raw.endsWith(`
2795
2795
  `)?"":`
2796
2796
  `)+r.raw,d.text+=`
2797
- `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=d.text):n.push(r);continue}if(t){let d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var l,d,h,u,p;let i=t,s=null;if(this.tokens.links){let v=Object.keys(this.tokens.links);if(v.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)v.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=((d=(l=this.options.hooks)==null?void 0:l.emStrongMask)==null?void 0:d.call({lexer:this},i))??i;let a=!1,r="";for(;t;){a||(r=""),a=!1;let v;if((u=(h=this.options.extensions)==null?void 0:h.inline)!=null&&u.some(S=>(v=S.call({lexer:this},t,n))?(t=t.substring(v.raw.length),n.push(v),!0):!1))continue;if(v=this.tokenizer.escape(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.tag(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.link(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(v.raw.length);let S=n.at(-1);v.type==="text"&&(S==null?void 0:S.type)==="text"?(S.raw+=v.raw,S.text+=v.text):n.push(v);continue}if(v=this.tokenizer.emStrong(t,i,r)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.codespan(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.br(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.del(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.autolink(t)){t=t.substring(v.raw.length),n.push(v);continue}if(!this.state.inLink&&(v=this.tokenizer.url(t))){t=t.substring(v.raw.length),n.push(v);continue}let $=t;if((p=this.options.extensions)!=null&&p.startInline){let S=1/0,M=t.slice(1),y;this.options.extensions.startInline.forEach(b=>{y=b.call({lexer:this},M),typeof y=="number"&&y>=0&&(S=Math.min(S,y))}),S<1/0&&S>=0&&($=t.substring(0,S+1))}if(v=this.tokenizer.inlineText($)){t=t.substring(v.raw.length),v.raw.slice(-1)!=="_"&&(r=v.raw.slice(-1)),a=!0;let S=n.at(-1);(S==null?void 0:S.type)==="text"?(S.raw+=v.raw,S.text+=v.text):n.push(v);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}},Gi=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(ge.notSpaceStart))==null?void 0:o[0],s=e.replace(ge.endingNewline,"")+`
2797
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=d.text):n.push(r);continue}if(t){let d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var l,d,h,u,p;let i=t,s=null;if(this.tokens.links){let v=Object.keys(this.tokens.links);if(v.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)v.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=((d=(l=this.options.hooks)==null?void 0:l.emStrongMask)==null?void 0:d.call({lexer:this},i))??i;let a=!1,r="";for(;t;){a||(r=""),a=!1;let v;if((u=(h=this.options.extensions)==null?void 0:h.inline)!=null&&u.some(S=>(v=S.call({lexer:this},t,n))?(t=t.substring(v.raw.length),n.push(v),!0):!1))continue;if(v=this.tokenizer.escape(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.tag(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.link(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(v.raw.length);let S=n.at(-1);v.type==="text"&&(S==null?void 0:S.type)==="text"?(S.raw+=v.raw,S.text+=v.text):n.push(v);continue}if(v=this.tokenizer.emStrong(t,i,r)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.codespan(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.br(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.del(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.autolink(t)){t=t.substring(v.raw.length),n.push(v);continue}if(!this.state.inLink&&(v=this.tokenizer.url(t))){t=t.substring(v.raw.length),n.push(v);continue}let $=t;if((p=this.options.extensions)!=null&&p.startInline){let S=1/0,M=t.slice(1),y;this.options.extensions.startInline.forEach(b=>{y=b.call({lexer:this},M),typeof y=="number"&&y>=0&&(S=Math.min(S,y))}),S<1/0&&S>=0&&($=t.substring(0,S+1))}if(v=this.tokenizer.inlineText($)){t=t.substring(v.raw.length),v.raw.slice(-1)!=="_"&&(r=v.raw.slice(-1)),a=!0;let S=n.at(-1);(S==null?void 0:S.type)==="text"?(S.raw+=v.raw,S.text+=v.text):n.push(v);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}},Qi=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(ge.notSpaceStart))==null?void 0:o[0],s=e.replace(ge.endingNewline,"")+`
2798
2798
  `;return i?'<pre><code class="language-'+Qe(i)+'">'+(n?s:Qe(s,!0))+`</code></pre>
2799
2799
  `:"<pre><code>"+(n?s:Qe(s,!0))+`</code></pre>
2800
2800
  `}blockquote({tokens:e}){return`<blockquote>
@@ -2812,10 +2812,10 @@ ${this.parser.parse(e)}</blockquote>
2812
2812
  `}tablerow({text:e}){return`<tr>
2813
2813
  ${e}</tr>
2814
2814
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
2815
- `}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>${Qe(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=Yr(e);if(s===null)return i;e=s;let o='<a href="'+e+'"';return t&&(o+=' title="'+Qe(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=Yr(e);if(s===null)return Qe(n);e=s;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Qe(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Qe(e.text)}},Pa=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}},Te=class Bo{constructor(t){q(this,"options");q(this,"renderer");q(this,"textRenderer");this.options=t||Dt,this.options.renderer=this.options.renderer||new Gi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Pa}static parse(t,n){return new Bo(n).parse(t)}static parseInline(t,n){return new Bo(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,d=this.options.extensions.renderers[l.type].call({parser:this},l);if(d!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=d||"";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 d=this.options.extensions.renderers[r.type].call({parser:this},r);if(d!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){i+=d||"";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 d='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}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?Ee.lex:Ee.lexInline}provideParser(){return this.block?Te.parse:Te.parseInline}},q($i,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),q($i,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),$i),Sy=class{constructor(...e){q(this,"defaults",$a());q(this,"options",this.setOptions);q(this,"parse",this.parseMarkdown(!0));q(this,"parseInline",this.parseMarkdown(!1));q(this,"Parser",Te);q(this,"Renderer",Gi);q(this,"TextRenderer",Pa);q(this,"Lexer",Ee);q(this,"Tokenizer",ji);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 Gi(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]=(...d)=>{let h=r.apply(s,d);return h===!1&&(h=l.apply(s,d)),h||""}}i.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new ji(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]=(...d)=>{let h=r.apply(s,d);return h===!1&&(h=l.apply(s,d)),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]=d=>{if(this.defaults.async&&An.passThroughHooksRespectAsync.has(o))return(async()=>{let u=await r.call(s,d);return l.call(s,u)})();let h=r.call(s,d);return l.call(s,h)}:s[a]=(...d)=>{if(this.defaults.async)return(async()=>{let u=await r.apply(s,d);return u===!1&&(u=await l.apply(s,d)),u})();let h=r.apply(s,d);return h===!1&&(h=l.apply(s,d)),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 Ee.lex(e,t??this.defaults)}parser(e,t){return Te.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?Ee.lex:Ee.lexInline)(a,s),l=s.hooks?await s.hooks.processAllTokens(r):r;s.walkTokens&&await Promise.all(this.walkTokens(l,s.walkTokens));let d=await(s.hooks?await s.hooks.provideParser():e?Te.parse:Te.parseInline)(l,s);return s.hooks?await s.hooks.postprocess(d):d})().catch(o);try{s.hooks&&(t=s.hooks.preprocess(t));let a=(s.hooks?s.hooks.provideLexer():e?Ee.lex:Ee.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?Te.parse:Te.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+=`
2816
- Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Qe(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},Mt=new Sy;function V(e,t){return Mt.parse(e,t)}V.options=V.setOptions=function(e){return Mt.setOptions(e),V.defaults=Mt.defaults,Md(V.defaults),V};V.getDefaults=$a;V.defaults=Dt;V.use=function(...e){return Mt.use(...e),V.defaults=Mt.defaults,Md(V.defaults),V};V.walkTokens=function(e,t){return Mt.walkTokens(e,t)};V.parseInline=Mt.parseInline;V.Parser=Te;V.parser=Te.parse;V.Renderer=Gi;V.TextRenderer=Pa;V.Lexer=Ee;V.lexer=Ee.lex;V.Tokenizer=ji;V.Hooks=An;V.parse=V;V.options;V.setOptions;V.use;V.walkTokens;V.parseInline;Te.parse;Ee.lex;V.setOptions({gfm:!0,breaks:!0,mangle:!1});const el=["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"],tl=["class","href","rel","target","title","start"];let nl=!1;const Ay=14e4,Cy=4e4,Ey=200,Js=5e4,wt=new Map;function Ty(e){const t=wt.get(e);return t===void 0?null:(wt.delete(e),wt.set(e,t),t)}function il(e,t){if(wt.set(e,t),wt.size<=Ey)return;const n=wt.keys().next().value;n&&wt.delete(n)}function _y(){nl||(nl=!0,Ro.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function Vi(e){const t=e.trim();if(!t)return"";if(_y(),t.length<=Js){const a=Ty(t);if(a!==null)return a}const n=Xl(t,Ay),i=n.truncated?`
2815
+ `}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>${Qe(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=Xr(e);if(s===null)return i;e=s;let o='<a href="'+e+'"';return t&&(o+=' title="'+Qe(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=Xr(e);if(s===null)return Qe(n);e=s;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Qe(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Qe(e.text)}},Ia=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}},Te=class Fo{constructor(t){q(this,"options");q(this,"renderer");q(this,"textRenderer");this.options=t||Dt,this.options.renderer=this.options.renderer||new Qi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ia}static parse(t,n){return new Fo(n).parse(t)}static parseInline(t,n){return new Fo(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,d=this.options.extensions.renderers[l.type].call({parser:this},l);if(d!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=d||"";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 d=this.options.extensions.renderers[r.type].call({parser:this},r);if(d!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){i+=d||"";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 d='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}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?Ee.lex:Ee.lexInline}provideParser(){return this.block?Te.parse:Te.parseInline}},q($i,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),q($i,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),$i),Sy=class{constructor(...e){q(this,"defaults",Sa());q(this,"options",this.setOptions);q(this,"parse",this.parseMarkdown(!0));q(this,"parseInline",this.parseMarkdown(!1));q(this,"Parser",Te);q(this,"Renderer",Qi);q(this,"TextRenderer",Ia);q(this,"Lexer",Ee);q(this,"Tokenizer",Vi);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 Qi(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]=(...d)=>{let h=r.apply(s,d);return h===!1&&(h=l.apply(s,d)),h||""}}i.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new Vi(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]=(...d)=>{let h=r.apply(s,d);return h===!1&&(h=l.apply(s,d)),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]=d=>{if(this.defaults.async&&An.passThroughHooksRespectAsync.has(o))return(async()=>{let u=await r.call(s,d);return l.call(s,u)})();let h=r.call(s,d);return l.call(s,h)}:s[a]=(...d)=>{if(this.defaults.async)return(async()=>{let u=await r.apply(s,d);return u===!1&&(u=await l.apply(s,d)),u})();let h=r.apply(s,d);return h===!1&&(h=l.apply(s,d)),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 Ee.lex(e,t??this.defaults)}parser(e,t){return Te.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?Ee.lex:Ee.lexInline)(a,s),l=s.hooks?await s.hooks.processAllTokens(r):r;s.walkTokens&&await Promise.all(this.walkTokens(l,s.walkTokens));let d=await(s.hooks?await s.hooks.provideParser():e?Te.parse:Te.parseInline)(l,s);return s.hooks?await s.hooks.postprocess(d):d})().catch(o);try{s.hooks&&(t=s.hooks.preprocess(t));let a=(s.hooks?s.hooks.provideLexer():e?Ee.lex:Ee.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?Te.parse:Te.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+=`
2816
+ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Qe(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},Mt=new Sy;function V(e,t){return Mt.parse(e,t)}V.options=V.setOptions=function(e){return Mt.setOptions(e),V.defaults=Mt.defaults,Md(V.defaults),V};V.getDefaults=Sa;V.defaults=Dt;V.use=function(...e){return Mt.use(...e),V.defaults=Mt.defaults,Md(V.defaults),V};V.walkTokens=function(e,t){return Mt.walkTokens(e,t)};V.parseInline=Mt.parseInline;V.Parser=Te;V.parser=Te.parse;V.Renderer=Qi;V.TextRenderer=Ia;V.Lexer=Ee;V.lexer=Ee.lex;V.Tokenizer=Vi;V.Hooks=An;V.parse=V;V.options;V.setOptions;V.use;V.walkTokens;V.parseInline;Te.parse;Ee.lex;V.setOptions({gfm:!0,breaks:!0,mangle:!1});const tl=["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"],nl=["class","href","rel","target","title","start"];let il=!1;const Ay=14e4,Cy=4e4,Ey=200,Xs=5e4,wt=new Map;function Ty(e){const t=wt.get(e);return t===void 0?null:(wt.delete(e),wt.set(e,t),t)}function sl(e,t){if(wt.set(e,t),wt.size<=Ey)return;const n=wt.keys().next().value;n&&wt.delete(n)}function _y(){il||(il=!0,Bo.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function Ji(e){const t=e.trim();if(!t)return"";if(_y(),t.length<=Xs){const a=Ty(t);if(a!==null)return a}const n=Zl(t,Ay),i=n.truncated?`
2817
2817
 
2818
- … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>Cy){const r=`<pre class="code-block">${My(`${n.text}${i}`)}</pre>`,l=Ro.sanitize(r,{ALLOWED_TAGS:el,ALLOWED_ATTR:tl});return t.length<=Js&&il(t,l),l}const s=V.parse(`${n.text}${i}`),o=Ro.sanitize(s,{ALLOWED_TAGS:el,ALLOWED_ATTR:tl});return t.length<=Js&&il(t,o),o}function My(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const Py=1500,Iy=2e3,Wd="Copy as markdown",Ry="Copied",Ly="Copy failed";async function Dy(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 mi(e,t){e.title=t,e.setAttribute("aria-label",t)}function By(e){const t=e.label??Wd;return c`
2818
+ … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>Cy){const r=`<pre class="code-block">${My(`${n.text}${i}`)}</pre>`,l=Bo.sanitize(r,{ALLOWED_TAGS:tl,ALLOWED_ATTR:nl});return t.length<=Xs&&sl(t,l),l}const s=V.parse(`${n.text}${i}`),o=Bo.sanitize(s,{ALLOWED_TAGS:tl,ALLOWED_ATTR:nl});return t.length<=Xs&&sl(t,o),o}function My(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const Py=1500,Iy=2e3,Wd="Copy as markdown",Ry="Copied",Ly="Copy failed";async function Dy(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 mi(e,t){e.title=t,e.setAttribute("aria-label",t)}function By(e){const t=e.label??Wd;return c`
2819
2819
  <button
2820
2820
  class="chat-copy-btn"
2821
2821
  type="button"
@@ -2828,7 +2828,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2828
2828
  <span class="chat-copy-btn__icon-check">${I.check}</span>
2829
2829
  </span>
2830
2830
  </button>
2831
- `}function Ny(e){return By({text:()=>e,label:Wd})}function Oy(e){const t=e,n=Fy(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:Uy(s.arguments??s.args)})}for(const s of n){const o=String(s.type??"").toLowerCase();if(o!=="toolresult"&&o!=="tool_result")continue;const a=Wy(s),r=typeof s.name=="string"?s.name:"tool";i.push({kind:"result",name:r,text:a})}if(ic(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=Zl(e)??void 0;i.push({kind:"result",name:s,text:o})}return i}function Fy(e){return Array.isArray(e)?e.filter(Boolean):[]}function Uy(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 Wy(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}const Ys=40,Xs=new Map;async function zy(e){const t=Xs.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/Ys),l=[];for(let u=0;u<Ys;u++){let p=0;const v=u*r,$=Math.min(v+r,a.length);for(let S=v;S<$;S++){const M=Math.abs(a[S]);M>p&&(p=M)}l.push(p)}const d=Math.max(...l,.01),h=l.map(u=>Math.max(u/d,.08));return Xs.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<Ys;s++){const o=Math.abs((n*(s+1)*9301+49297)%233280/233280);i.push(.15+o*.85)}return Xs.set(e,i),i}}const Zs=[1,1.5,2],Qi=new Map;function Ky(e){let t=Qi.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:[]},Qi.set(e,t),zy(e).then(i=>{t.waveform=i,zd(e)}),t}const Rn="http://www.w3.org/2000/svg";function Hy(){const e=document.createElementNS(Rn,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor");const t=document.createElementNS(Rn,"polygon");return t.setAttribute("points","6,3 20,12 6,21"),e.appendChild(t),e}function qy(){const e=document.createElementNS(Rn,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor");const t=document.createElementNS(Rn,"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(Rn,"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 qt(e){return document.querySelector(`.vnp[data-url="${CSS.escape(e)}"]`)}function zd(e){const t=qt(e);if(!t)return;const n=Qi.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)}Ln(t,n)}}function Ln(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?Ji(t.currentTime):Ji(t.duration))}function eo(e,t){const n=e.querySelector(".vnp__play");if(!n)return;const i=n.querySelector("svg"),s=t?qy():Hy();i?n.replaceChild(s,i):n.appendChild(s)}function Ji(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 sl=new Set;function jy(e){if(sl.has(e))return;sl.add(e);const t=Qi.get(e);if(!t)return;const{audio:n}=t;n.addEventListener("loadedmetadata",()=>{t.duration=n.duration;const i=qt(e);i&&Ln(i,t)}),n.addEventListener("timeupdate",()=>{t.currentTime=n.currentTime;const i=qt(e);i&&Ln(i,t)}),n.addEventListener("ended",()=>{t.playing=!1,n.currentTime=0,t.currentTime=0;const i=qt(e);i&&(Ln(i,t),eo(i,!1))}),n.addEventListener("pause",()=>{t.playing=!1;const i=qt(e);i&&eo(i,!1)}),n.addEventListener("play",()=>{t.playing=!0;const i=qt(e);i&&eo(i,!0)})}function Gy(e,t){const n=Ky(e);jy(e);const i=r=>{r.stopPropagation(),n.playing?n.audio.pause():n.audio.play()},s=r=>{r.stopPropagation();const l=Zs.indexOf(n.speed),d=Zs[(l+1)%Zs.length];n.speed=d,n.audio.playbackRate=d;const h=r.target.closest(".vnp__speed");h&&(h.textContent=`${d}×`)},o=r=>{r.stopPropagation();const l=r.target.closest(".vnp__waveform");if(!l)return;const d=l.getBoundingClientRect(),h=Math.max(0,Math.min(1,(r.clientX-d.left)/d.width));if(n.duration>0){n.audio.currentTime=h*n.duration,n.currentTime=n.audio.currentTime;const u=l.closest(".vnp");u&&Ln(u,n)}},a=n.playing||n.currentTime>0?Ji(n.currentTime):Ji(n.duration);return queueMicrotask(()=>zd(e)),c`
2831
+ `}function Ny(e){return By({text:()=>e,label:Wd})}function Oy(e){const t=e,n=Fy(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:Uy(s.arguments??s.args)})}for(const s of n){const o=String(s.type??"").toLowerCase();if(o!=="toolresult"&&o!=="tool_result")continue;const a=Wy(s),r=typeof s.name=="string"?s.name:"tool";i.push({kind:"result",name:r,text:a})}if(sc(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=ec(e)??void 0;i.push({kind:"result",name:s,text:o})}return i}function Fy(e){return Array.isArray(e)?e.filter(Boolean):[]}function Uy(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 Wy(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}const Zs=40,eo=new Map;async function zy(e){const t=eo.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/Zs),l=[];for(let u=0;u<Zs;u++){let p=0;const v=u*r,$=Math.min(v+r,a.length);for(let S=v;S<$;S++){const M=Math.abs(a[S]);M>p&&(p=M)}l.push(p)}const d=Math.max(...l,.01),h=l.map(u=>Math.max(u/d,.08));return eo.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<Zs;s++){const o=Math.abs((n*(s+1)*9301+49297)%233280/233280);i.push(.15+o*.85)}return eo.set(e,i),i}}const to=[1,1.5,2],Yi=new Map;function Ky(e){let t=Yi.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:[]},Yi.set(e,t),zy(e).then(i=>{t.waveform=i,zd(e)}),t}const Rn="http://www.w3.org/2000/svg";function Hy(){const e=document.createElementNS(Rn,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor");const t=document.createElementNS(Rn,"polygon");return t.setAttribute("points","6,3 20,12 6,21"),e.appendChild(t),e}function qy(){const e=document.createElementNS(Rn,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor");const t=document.createElementNS(Rn,"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(Rn,"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 qt(e){return document.querySelector(`.vnp[data-url="${CSS.escape(e)}"]`)}function zd(e){const t=qt(e);if(!t)return;const n=Yi.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)}Ln(t,n)}}function Ln(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?Xi(t.currentTime):Xi(t.duration))}function no(e,t){const n=e.querySelector(".vnp__play");if(!n)return;const i=n.querySelector("svg"),s=t?qy():Hy();i?n.replaceChild(s,i):n.appendChild(s)}function Xi(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 ol=new Set;function jy(e){if(ol.has(e))return;ol.add(e);const t=Yi.get(e);if(!t)return;const{audio:n}=t;n.addEventListener("loadedmetadata",()=>{t.duration=n.duration;const i=qt(e);i&&Ln(i,t)}),n.addEventListener("timeupdate",()=>{t.currentTime=n.currentTime;const i=qt(e);i&&Ln(i,t)}),n.addEventListener("ended",()=>{t.playing=!1,n.currentTime=0,t.currentTime=0;const i=qt(e);i&&(Ln(i,t),no(i,!1))}),n.addEventListener("pause",()=>{t.playing=!1;const i=qt(e);i&&no(i,!1)}),n.addEventListener("play",()=>{t.playing=!0;const i=qt(e);i&&no(i,!0)})}function Gy(e,t){const n=Ky(e);jy(e);const i=r=>{r.stopPropagation(),n.playing?n.audio.pause():n.audio.play()},s=r=>{r.stopPropagation();const l=to.indexOf(n.speed),d=to[(l+1)%to.length];n.speed=d,n.audio.playbackRate=d;const h=r.target.closest(".vnp__speed");h&&(h.textContent=`${d}×`)},o=r=>{r.stopPropagation();const l=r.target.closest(".vnp__waveform");if(!l)return;const d=l.getBoundingClientRect(),h=Math.max(0,Math.min(1,(r.clientX-d.left)/d.width));if(n.duration>0){n.audio.currentTime=h*n.duration,n.currentTime=n.audio.currentTime;const u=l.closest(".vnp");u&&Ln(u,n)}},a=n.playing||n.currentTime>0?Xi(n.currentTime):Xi(n.duration);return queueMicrotask(()=>zd(e)),c`
2832
2832
  <div class="vnp" data-url=${e} @click=${r=>r.stopPropagation()}>
2833
2833
  <button class="vnp__play" @click=${i} aria-label=${n.playing?"Pause":"Play"}>
2834
2834
  ${n.playing?Qy():Vy()}
@@ -2858,7 +2858,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2858
2858
  <div class="chat-group assistant">
2859
2859
  <div class="chat-group-messages">
2860
2860
  <div class="chat-interim fade-in">
2861
- ${Hi(Vi(e))}
2861
+ ${ji(Ji(e))}
2862
2862
  </div>
2863
2863
  </div>
2864
2864
  </div>
@@ -2868,7 +2868,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2868
2868
  ${Kd({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!1,showReasoning:!1})}
2869
2869
  </div>
2870
2870
  </div>
2871
- `}function nv(e,t){const n=nc(e.role),i=n==="user"?"user":n==="assistant"?"assistant":"other",s=new Date(e.timestamp).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"}),o=e.messages.map((a,r)=>Kd(a.message,{isStreaming:e.isStreaming&&r===e.messages.length-1,showReasoning:t.showReasoning}));return o.every(a=>a===w)?w:c`
2871
+ `}function nv(e,t){const n=ic(e.role),i=n==="user"?"user":n==="assistant"?"assistant":"other",s=new Date(e.timestamp).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"}),o=e.messages.map((a,r)=>Kd(a.message,{isStreaming:e.isStreaming&&r===e.messages.length-1,showReasoning:t.showReasoning}));return o.every(a=>a===w)?w:c`
2872
2872
  <div class="chat-group ${i}">
2873
2873
  <div class="chat-group-messages">
2874
2874
  ${o}
@@ -2917,15 +2917,15 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2917
2917
  <span class="chat-file-card__icon">${Xy(e.mimeType)}</span>
2918
2918
  <span class="chat-file-card__name">${e.name}</span>
2919
2919
  </a>
2920
- `}function Kd(e,t,n){const i=e,s=typeof i.role=="string"?i.role:"unknown",o=ic(e)||s.toLowerCase()==="toolresult"||s.toLowerCase()==="tool_result"||typeof i.toolCallId=="string"||typeof i.tool_call_id=="string",r=Oy(e).length>0,l=Jy(e),d=l.length>0,h=Yy(e),u=h.length>0,p=Zl(e),v=t.showReasoning&&s==="assistant"?zp(e):null,$=p!=null&&p.trim()?p:null,S=v?Hp(v):null,M=$,y=(s==="assistant"||s==="user")&&!!(M!=null&&M.trim()),b=["chat-bubble",y?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!M&&(r||o)||!M&&!d&&!u?w:c`
2920
+ `}function Kd(e,t,n){const i=e,s=typeof i.role=="string"?i.role:"unknown",o=sc(e)||s.toLowerCase()==="toolresult"||s.toLowerCase()==="tool_result"||typeof i.toolCallId=="string"||typeof i.tool_call_id=="string",r=Oy(e).length>0,l=Jy(e),d=l.length>0,h=Yy(e),u=h.length>0,p=ec(e),v=t.showReasoning&&s==="assistant"?zp(e):null,$=p!=null&&p.trim()?p:null,S=v?Hp(v):null,M=$,y=(s==="assistant"||s==="user")&&!!(M!=null&&M.trim()),b=["chat-bubble",y?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!M&&(r||o)||!M&&!d&&!u?w:c`
2921
2921
  <div class="${b}">
2922
2922
  ${y?Ny(M):w}
2923
2923
  ${iv(l)}
2924
2924
  ${sv(h)}
2925
- ${S?c`<div class="chat-thinking">${Hi(Vi(S))}</div>`:w}
2926
- ${M?c`<div class="chat-text">${Hi(Vi(M))}</div>`:w}
2925
+ ${S?c`<div class="chat-thinking">${ji(Ji(S))}</div>`:w}
2926
+ ${M?c`<div class="chat-text">${ji(Ji(M))}</div>`:w}
2927
2927
  </div>
2928
- `}const O={active:!1,mode:"tap",startTime:0,elapsed:0,mediaRecorder:null,audioChunks:[],stream:null,timerId:null,startX:0,cancelled:!1};let G=null,$t=null,St=!1;function ol(e){const t=Math.floor(e/60),n=e%60;return`${t}:${n.toString().padStart(2,"0")}`}function mt(){if(O.timerId&&(clearInterval(O.timerId),O.timerId=null),O.stream){for(const e of O.stream.getTracks())e.stop();O.stream=null}$t&&(clearTimeout($t),$t=null),Yi(),O.mediaRecorder=null,O.audioChunks=[],O.active=!1,O.cancelled=!1,St=!1}async function Hd(e){var t;try{if(!((t=navigator.mediaDevices)!=null&&t.getUserMedia))return console.warn("[voice] getUserMedia unavailable (requires secure context)"),mt(),!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){mt(),G==null||G.onRequestRender();return}const o=new Blob(O.audioChunks,{type:s.mimeType});if(o.size===0){mt(),G==null||G.onRequestRender();return}const a=new FileReader;a.onload=()=>{const r=a.result,l=s.mimeType.includes("mp4")?"m4a":"webm",d={id:as(),dataUrl:r,mimeType:s.mimeType||"audio/webm",fileName:`voice-note-${Date.now()}.${l}`};mt(),G==null||G.onSend(d),G==null||G.onRequestRender()},a.onerror=()=>{mt(),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),mt(),!1}}function qd(){!O.active||!O.mediaRecorder||(O.cancelled=!1,O.mediaRecorder.state==="recording"&&O.mediaRecorder.stop())}function jd(){!O.active||!O.mediaRecorder||(O.cancelled=!0,O.mediaRecorder.state==="recording"?O.mediaRecorder.stop():(mt(),G==null||G.onRequestRender()))}function lv(){document.addEventListener("pointerup",Gd)}function Yi(){document.removeEventListener("pointerup",Gd)}function Gd(e){if(!St&&!O.active){Yi();return}if(St=!1,Yi(),$t&&(clearTimeout($t),$t=null,!O.active)){Hd("tap");return}O.active&&O.mode==="hold"&&(O.cancelled?jd():qd()),e.preventDefault()}function cv(e){O.active||(St=!0,O.startX=e.clientX,lv(),$t=setTimeout(async()=>{if(!St)return;await Hd("hold")||(St=!1,Yi())},300))}function al(e){if(!O.active||O.mode!=="hold"||!St)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 dv(){return O.active}function uv(e){G=e}function pv(e){return c`
2928
+ `}const O={active:!1,mode:"tap",startTime:0,elapsed:0,mediaRecorder:null,audioChunks:[],stream:null,timerId:null,startX:0,cancelled:!1};let G=null,$t=null,St=!1;function al(e){const t=Math.floor(e/60),n=e%60;return`${t}:${n.toString().padStart(2,"0")}`}function mt(){if(O.timerId&&(clearInterval(O.timerId),O.timerId=null),O.stream){for(const e of O.stream.getTracks())e.stop();O.stream=null}$t&&(clearTimeout($t),$t=null),Zi(),O.mediaRecorder=null,O.audioChunks=[],O.active=!1,O.cancelled=!1,St=!1}async function Hd(e){var t;try{if(!((t=navigator.mediaDevices)!=null&&t.getUserMedia))return console.warn("[voice] getUserMedia unavailable (requires secure context)"),mt(),!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){mt(),G==null||G.onRequestRender();return}const o=new Blob(O.audioChunks,{type:s.mimeType});if(o.size===0){mt(),G==null||G.onRequestRender();return}const a=new FileReader;a.onload=()=>{const r=a.result,l=s.mimeType.includes("mp4")?"m4a":"webm",d={id:ls(),dataUrl:r,mimeType:s.mimeType||"audio/webm",fileName:`voice-note-${Date.now()}.${l}`};mt(),G==null||G.onSend(d),G==null||G.onRequestRender()},a.onerror=()=>{mt(),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),mt(),!1}}function qd(){!O.active||!O.mediaRecorder||(O.cancelled=!1,O.mediaRecorder.state==="recording"&&O.mediaRecorder.stop())}function jd(){!O.active||!O.mediaRecorder||(O.cancelled=!0,O.mediaRecorder.state==="recording"?O.mediaRecorder.stop():(mt(),G==null||G.onRequestRender()))}function lv(){document.addEventListener("pointerup",Gd)}function Zi(){document.removeEventListener("pointerup",Gd)}function Gd(e){if(!St&&!O.active){Zi();return}if(St=!1,Zi(),$t&&(clearTimeout($t),$t=null,!O.active)){Hd("tap");return}O.active&&O.mode==="hold"&&(O.cancelled?jd():qd()),e.preventDefault()}function cv(e){O.active||(St=!0,O.startX=e.clientX,lv(),$t=setTimeout(async()=>{if(!St)return;await Hd("hold")||(St=!1,Zi())},300))}function rl(e){if(!O.active||O.mode!=="hold"||!St)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 dv(){return O.active}function uv(e){G=e}function pv(e){return c`
2929
2929
  <button
2930
2930
  class="btn btn--icon chat-compose__mic"
2931
2931
  ?disabled=${!e}
@@ -2936,7 +2936,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2936
2936
  ${I.mic}
2937
2937
  </button>
2938
2938
  `}function hv(){return O.active?O.mode==="tap"?c`
2939
- <div class="chat-voice-recording" @pointermove=${al}>
2939
+ <div class="chat-voice-recording" @pointermove=${rl}>
2940
2940
  <button
2941
2941
  class="btn btn--icon chat-voice-recording__trash"
2942
2942
  @click=${jd}
@@ -2947,7 +2947,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2947
2947
  </button>
2948
2948
  <div class="chat-voice-recording__indicator">
2949
2949
  <span class="chat-voice-recording__dot"></span>
2950
- <span class="chat-voice-recording__timer">${ol(O.elapsed)}</span>
2950
+ <span class="chat-voice-recording__timer">${al(O.elapsed)}</span>
2951
2951
  </div>
2952
2952
  <button
2953
2953
  class="btn btn--icon chat-voice-recording__send primary"
@@ -2959,10 +2959,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2959
2959
  </button>
2960
2960
  </div>
2961
2961
  `:c`
2962
- <div class="chat-voice-recording hold" @pointermove=${al}>
2962
+ <div class="chat-voice-recording hold" @pointermove=${rl}>
2963
2963
  <div class="chat-voice-recording__indicator">
2964
2964
  <span class="chat-voice-recording__dot"></span>
2965
- <span class="chat-voice-recording__timer">${ol(O.elapsed)}</span>
2965
+ <span class="chat-voice-recording__timer">${al(O.elapsed)}</span>
2966
2966
  <span class="chat-voice-recording__slide ${O.cancelled?"cancelled":""}">
2967
2967
  ${O.cancelled?"Release to cancel":"← Slide to cancel"}
2968
2968
  </span>
@@ -2982,10 +2982,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2982
2982
  <button @click=${e.onViewRawText} class="btn" style="margin-top: 12px;">
2983
2983
  View Raw Text
2984
2984
  </button>
2985
- `:e.content?c`<div class="sidebar-markdown">${Hi(Vi(e.content))}</div>`:c`<div class="muted">No content available</div>`}
2985
+ `:e.content?c`<div class="sidebar-markdown">${ji(Ji(e.content))}</div>`:c`<div class="muted">No content available</div>`}
2986
2986
  </div>
2987
2987
  </div>
2988
- `}var gv=Object.defineProperty,mv=Object.getOwnPropertyDescriptor,fs=(e,t,n,i)=>{for(var s=i>1?void 0:i?mv(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&&gv(t,n,s),s};let Yt=class extends Gt{constructor(){super(...arguments),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.isDragging=!1,this.startX=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startX=e.clientX,this.startRatio=this.splitRatio,this.classList.add("dragging"),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;const t=this.parentElement;if(!t)return;const n=t.getBoundingClientRect().width,s=(e.clientX-this.startX)/n;let o=this.startRatio+s;o=Math.max(this.minRatio,Math.min(this.maxRatio,o)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:o},bubbles:!0,composed:!0}))},this.handleMouseUp=()=>{this.isDragging=!1,this.classList.remove("dragging"),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}render(){return c``}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}};Yt.styles=Zu`
2988
+ `}var gv=Object.defineProperty,mv=Object.getOwnPropertyDescriptor,ms=(e,t,n,i)=>{for(var s=i>1?void 0:i?mv(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&&gv(t,n,s),s};let Yt=class extends Gt{constructor(){super(...arguments),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.isDragging=!1,this.startX=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startX=e.clientX,this.startRatio=this.splitRatio,this.classList.add("dragging"),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;const t=this.parentElement;if(!t)return;const n=t.getBoundingClientRect().width,s=(e.clientX-this.startX)/n;let o=this.startRatio+s;o=Math.max(this.minRatio,Math.min(this.maxRatio,o)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:o},bubbles:!0,composed:!0}))},this.handleMouseUp=()=>{this.isDragging=!1,this.classList.remove("dragging"),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}render(){return c``}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}};Yt.styles=Zu`
2989
2989
  :host {
2990
2990
  width: 4px;
2991
2991
  cursor: col-resize;
@@ -3011,13 +3011,13 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
3011
3011
  :host(.dragging) {
3012
3012
  background: var(--accent, #007bff);
3013
3013
  }
3014
- `;fs([ss({type:Number})],Yt.prototype,"splitRatio",2);fs([ss({type:Number})],Yt.prototype,"minRatio",2);fs([ss({type:Number})],Yt.prototype,"maxRatio",2);Yt=fs([ql("resizable-divider")],Yt);function yi(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function to(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const yv=1,vv=1,Bt="emoji",Xt="keyvalue",Ia="favorites",bv="tokens",Vd="tokens",wv="unicode",Qd="count",kv="group",xv="order",Jd="group-order",No="eTag",Xi="url",rl="skinTone",ln="readonly",Ra="readwrite",Yd="skinUnicodes",$v="skinUnicodes",Sv="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Av="en";function Cv(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 ll(e){return Cv(e,t=>t.unicode)}function Ev(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,wv,{[Vd]:[bv,!0],[Jd]:[[kv,xv]],[Yd]:[$v,!0]}),t(Ia,void 0,{[Qd]:[""]})}const Oo={},Ei={},Zi={};function Xd(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function Tv(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,yv);Oo[e]=s,s.onupgradeneeded=o=>{o.oldVersion<vv&&Ev(s.result)},Xd(n,i,s)});return t.onclose=()=>La(e),t}function _v(e){return Ei[e]||(Ei[e]=Tv(e)),Ei[e]}function Ze(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(d=>a.objectStore(d));let l;i(r,a,d=>{l=d}),a.oncomplete=()=>s(l),a.onerror=()=>o(a.error)})}function La(e){const t=Oo[e],n=t&&t.result;if(n){n.close();const i=Zi[e];if(i)for(const s of i)s()}delete Oo[e],delete Ei[e],delete Zi[e]}function Mv(e){return new Promise((t,n)=>{La(e);const i=indexedDB.deleteDatabase(e);Xd(t,n,i)})}function Pv(e,t){let n=Zi[e];n||(n=Zi[e]=[]),n.push(t)}const Iv=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 Vt(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||Iv.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const Rv=2;function Zd(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=Rv)}function Lv(e){return e.map(({annotation:n,emoticon:i,group:s,order:o,shortcodes:a,skins:r,tags:l,emoji:d,version:h})=>{const u=[...new Set(Zd([...(a||[]).map(Vt).flat(),...(l||[]).map(Vt).flat(),...Vt(n),i]))].sort(),p={annotation:n,group:s,order:o,tags:l,tokens:u,unicode:d,version:h};if(i&&(p.emoticon=i),a&&(p.shortcodes=a),r){p.skinTones=[],p.skinUnicodes=[],p.skinVersions=[];for(const{tone:v,emoji:$,version:S}of r)p.skinTones.push(v),p.skinUnicodes.push($),p.skinVersions.push(S)}return p})}function eu(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function Pt(e,t,n){eu(e,"get",t,n)}function tu(e,t,n){eu(e,"getAll",t,n)}function Da(e){e.commit&&e.commit()}function Dv(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 nu(e,t){const n=Dv(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 Bv(e){return!await Ba(e,Xt,Xi)}async function Nv(e,t,n){const[i,s]=await Promise.all([No,Xi].map(o=>Ba(e,Xt,o)));return i===n&&s===t}async function Ov(e,t){return Ze(e,Bt,ln,(i,s,o)=>{let a;const r=()=>{i.getAll(a&&IDBKeyRange.lowerBound(a,!0),50).onsuccess=l=>{const d=l.target.result;for(const h of d)if(a=h.unicode,t(h))return o(h);if(d.length<50)return o();r()}};r()})}async function iu(e,t,n,i){{const s=Lv(t);await Ze(e,[Bt,Xt],Ra,([o,a],r)=>{let l,d,h=0;function u(){++h===2&&p()}function p(){if(!(l===i&&d===n)){o.clear();for(const v of s)o.put(v);a.put(i,No),a.put(n,Xi),Da(r)}}Pt(a,No,v=>{l=v,u()}),Pt(a,Xi,v=>{d=v,u()})})}}async function Fv(e,t){return Ze(e,Bt,ln,(n,i,s)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);tu(n.index(Jd),o,s)})}async function su(e,t){const n=Zd(Vt(t));return n.length?Ze(e,Bt,ln,(i,s,o)=>{const a=[],r=()=>{a.length===n.length&&l()},l=()=>{const d=nu(a,h=>h.unicode);o(d.sort((h,u)=>h.order<u.order?-1:1))};for(let d=0;d<n.length;d++){const h=n[d],u=d===n.length-1?IDBKeyRange.bound(h,h+"￿",!1,!0):IDBKeyRange.only(h);tu(i.index(Vd),u,p=>{a.push(p),r()})}}):[]}async function Uv(e,t){const n=await su(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await Ov(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function Wv(e,t){return Ze(e,Bt,ln,(n,i,s)=>Pt(n,t,o=>{if(o)return s(o);Pt(n.index(Yd),t,a=>s(a||null))}))}function Ba(e,t,n){return Ze(e,t,ln,(i,s,o)=>Pt(i,n,o))}function zv(e,t,n,i){return Ze(e,t,Ra,(s,o)=>{s.put(i,n),Da(o)})}function Kv(e,t){return Ze(e,Ia,Ra,(n,i)=>Pt(n,t,s=>{n.put((s||0)+1,t),Da(i)}))}function Hv(e,t,n){return n===0?[]:Ze(e,[Ia,Bt],ln,([i,s],o,a)=>{const r=[];i.index(Qd).openCursor(void 0,"prev").onsuccess=l=>{const d=l.target.result;if(!d)return a(r);function h(v){if(r.push(v),r.length===n)return a(r);d.continue()}const u=d.primaryKey,p=t.byName(u);if(p)return h(p);Pt(s,u,v=>{if(v)return h(v);d.continue()})}})}const vi="";function qv(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 d=0;d<a.length;d++){const h=a.charAt(d);let u=r.get(h);u||(u=new Map,r.set(h,u)),r=u}let l=r.get(vi);l||(l=[],r.set(vi,l)),l.push(s)}}return(s,o)=>{let a=n;for(let d=0;d<s.length;d++){const h=s.charAt(d),u=a.get(h);if(u)a=u;else return[]}if(o)return a.get(vi)||[];const r=[],l=[a];for(;l.length;){const h=[...l.shift().entries()].sort((u,p)=>u[0]<p[0]?-1:1);for(const[u,p]of h)u===vi?r.push(...p):l.push(p)}return r}}const jv=["name","url"];function Gv(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||jv.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function cl(e){Gv(e);const t=(p,v)=>p.name.toLowerCase()<v.name.toLowerCase()?-1:1,n=e.sort(t),s=qv(e,p=>{const v=new Set;if(p.shortcodes)for(const $ of p.shortcodes)for(const S of Vt($))v.add(S);return v}),o=p=>s(p,!0),a=p=>s(p,!1),r=p=>{const v=Vt(p),$=v.map((S,M)=>(M<v.length-1?o:a)(S));return nu($,S=>S.name).sort(t)},l=new Map,d=new Map;for(const p of e){d.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=>d.get(p.toLowerCase())}}const Vv=typeof wrappedJSObject<"u";function $n(e){if(!e)return e;if(Vv&&(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 ou(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const Qv=["annotation","emoji","group","order","version"];function Jv(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||Qv.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function au(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function Yv(e){const t=await fetch(e,{method:"HEAD"});au(t,e);const n=t.headers.get("etag");return ou(n),n}async function Fo(e){const t=await fetch(e);au(t,e);const n=t.headers.get("etag");ou(n);const i=await t.json();return Jv(i),[n,i]}function Xv(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function Zv(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 ru(e){const t=JSON.stringify(e);let n=Zv(t);const i=await crypto.subtle.digest("SHA-1",n),s=Xv(i);return btoa(s)}async function eb(e,t){let n,i=await Yv(t);if(!i){const s=await Fo(t);i=s[0],n=s[1],i||(i=await ru(n))}await Nv(e,t,i)||(n||(n=(await Fo(t))[1]),await iu(e,n,t,i))}async function tb(e,t){let[n,i]=await Fo(t);n||(n=await ru(i)),await iu(e,i,t,n)}async function nb(e,t){try{await eb(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class ib{constructor({dataSource:t=Sv,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=cl(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await _v(this._dbName);Pv(this._dbName,this._clear);const n=this.dataSource;await Bv(t)?await tb(t,n):this._lazyUpdate=nb(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 to(t),await this.ready(),ll(await Fv(this._db,t)).map($n)}async getEmojiBySearchQuery(t){yi(t),await this.ready();const n=this._custom.search(t),i=ll(await su(this._db,t)).map($n);return[...n,...i]}async getEmojiByShortcode(t){yi(t),await this.ready();const n=this._custom.byShortcode(t);return n||$n(await Uv(this._db,t))}async getEmojiByUnicodeOrName(t){yi(t),await this.ready();const n=this._custom.byName(t);return n||$n(await Wv(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Ba(this._db,Xt,rl)||0}async setPreferredSkinTone(t){return to(t),await this.ready(),zv(this._db,Xt,rl,t)}async incrementFavoriteEmojiCount(t){return yi(t),await this.ready(),Kv(this._db,t)}async getTopFavoriteEmoji(t){return to(t),await this.ready(),(await Hv(this._db,this._custom,t)).map($n)}set customEmoji(t){this._custom=cl(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 Mv(this._dbName)}}const Uo=[[-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})),no=Uo.slice(1),sb=2,dl=6,lu=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function ul(e){return e.unicode.includes("‍")}const ob={"🫪":17,"🫩":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},ab=1e3,rb="🖐️",lb=8,cb=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],cu='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',db=(e,t)=>e<t?-1:e>t?1:0,pl=(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 ${cu}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},ub=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function pb(e){const t=pl(e,"#000"),n=pl(e,"#fff");return t&&n&&ub(t,n)}function hb(){const e=Object.entries(ob);try{for(const[t,n]of e)if(pb(t))return n}catch{}return e[0][1]}let io;const so=()=>(io||(io=new Promise(e=>lu(()=>e(hb())))),io),Wo=new Map,fb="️",gb="\uD83C",mb="‍",yb=127995,vb=57339;function bb(e,t){if(t===0)return e;const n=e.indexOf(mb);return n!==-1?e.substring(0,n)+String.fromCodePoint(yb+t-1)+e.substring(n):(e.endsWith(fb)&&(e=e.substring(0,e.length-1)),e+gb+String.fromCodePoint(vb+t-1))}function Be(e){e.preventDefault(),e.stopPropagation()}function oo(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function du(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 wb(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:d})=>({unicode:i,name:r,shortcodes:o,url:a,category:l,annotation:d,id:i||r,skins:s&&n(s)}))}const Ti=requestAnimationFrame;let kb=typeof ResizeObserver=="function";function xb(e,t,n){let i;kb?(i=new ResizeObserver(n),i.observe(e)):Ti(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function hl(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let ao;function $b(e,t,n){let i=!0,s=!1;for(const o of e){const a=n(o);if(!a)continue;const r=hl(a);r===0&&(s=!0),typeof ao>"u"&&(ao=hl(t));const l=r/1.8<ao;Wo.set(o.unicode,l),l||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
3014
+ `;ms([as({type:Number})],Yt.prototype,"splitRatio",2);ms([as({type:Number})],Yt.prototype,"minRatio",2);ms([as({type:Number})],Yt.prototype,"maxRatio",2);Yt=ms([jl("resizable-divider")],Yt);function yi(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function io(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const yv=1,vv=1,Bt="emoji",Xt="keyvalue",Ra="favorites",bv="tokens",Vd="tokens",wv="unicode",Qd="count",kv="group",xv="order",Jd="group-order",Uo="eTag",es="url",ll="skinTone",ln="readonly",La="readwrite",Yd="skinUnicodes",$v="skinUnicodes",Sv="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Av="en";function Cv(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 cl(e){return Cv(e,t=>t.unicode)}function Ev(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,wv,{[Vd]:[bv,!0],[Jd]:[[kv,xv]],[Yd]:[$v,!0]}),t(Ra,void 0,{[Qd]:[""]})}const Wo={},Ei={},ts={};function Xd(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function Tv(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,yv);Wo[e]=s,s.onupgradeneeded=o=>{o.oldVersion<vv&&Ev(s.result)},Xd(n,i,s)});return t.onclose=()=>Da(e),t}function _v(e){return Ei[e]||(Ei[e]=Tv(e)),Ei[e]}function Ze(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(d=>a.objectStore(d));let l;i(r,a,d=>{l=d}),a.oncomplete=()=>s(l),a.onerror=()=>o(a.error)})}function Da(e){const t=Wo[e],n=t&&t.result;if(n){n.close();const i=ts[e];if(i)for(const s of i)s()}delete Wo[e],delete Ei[e],delete ts[e]}function Mv(e){return new Promise((t,n)=>{Da(e);const i=indexedDB.deleteDatabase(e);Xd(t,n,i)})}function Pv(e,t){let n=ts[e];n||(n=ts[e]=[]),n.push(t)}const Iv=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 Vt(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||Iv.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const Rv=2;function Zd(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=Rv)}function Lv(e){return e.map(({annotation:n,emoticon:i,group:s,order:o,shortcodes:a,skins:r,tags:l,emoji:d,version:h})=>{const u=[...new Set(Zd([...(a||[]).map(Vt).flat(),...(l||[]).map(Vt).flat(),...Vt(n),i]))].sort(),p={annotation:n,group:s,order:o,tags:l,tokens:u,unicode:d,version:h};if(i&&(p.emoticon=i),a&&(p.shortcodes=a),r){p.skinTones=[],p.skinUnicodes=[],p.skinVersions=[];for(const{tone:v,emoji:$,version:S}of r)p.skinTones.push(v),p.skinUnicodes.push($),p.skinVersions.push(S)}return p})}function eu(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function Pt(e,t,n){eu(e,"get",t,n)}function tu(e,t,n){eu(e,"getAll",t,n)}function Ba(e){e.commit&&e.commit()}function Dv(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 nu(e,t){const n=Dv(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 Bv(e){return!await Na(e,Xt,es)}async function Nv(e,t,n){const[i,s]=await Promise.all([Uo,es].map(o=>Na(e,Xt,o)));return i===n&&s===t}async function Ov(e,t){return Ze(e,Bt,ln,(i,s,o)=>{let a;const r=()=>{i.getAll(a&&IDBKeyRange.lowerBound(a,!0),50).onsuccess=l=>{const d=l.target.result;for(const h of d)if(a=h.unicode,t(h))return o(h);if(d.length<50)return o();r()}};r()})}async function iu(e,t,n,i){{const s=Lv(t);await Ze(e,[Bt,Xt],La,([o,a],r)=>{let l,d,h=0;function u(){++h===2&&p()}function p(){if(!(l===i&&d===n)){o.clear();for(const v of s)o.put(v);a.put(i,Uo),a.put(n,es),Ba(r)}}Pt(a,Uo,v=>{l=v,u()}),Pt(a,es,v=>{d=v,u()})})}}async function Fv(e,t){return Ze(e,Bt,ln,(n,i,s)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);tu(n.index(Jd),o,s)})}async function su(e,t){const n=Zd(Vt(t));return n.length?Ze(e,Bt,ln,(i,s,o)=>{const a=[],r=()=>{a.length===n.length&&l()},l=()=>{const d=nu(a,h=>h.unicode);o(d.sort((h,u)=>h.order<u.order?-1:1))};for(let d=0;d<n.length;d++){const h=n[d],u=d===n.length-1?IDBKeyRange.bound(h,h+"￿",!1,!0):IDBKeyRange.only(h);tu(i.index(Vd),u,p=>{a.push(p),r()})}}):[]}async function Uv(e,t){const n=await su(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await Ov(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function Wv(e,t){return Ze(e,Bt,ln,(n,i,s)=>Pt(n,t,o=>{if(o)return s(o);Pt(n.index(Yd),t,a=>s(a||null))}))}function Na(e,t,n){return Ze(e,t,ln,(i,s,o)=>Pt(i,n,o))}function zv(e,t,n,i){return Ze(e,t,La,(s,o)=>{s.put(i,n),Ba(o)})}function Kv(e,t){return Ze(e,Ra,La,(n,i)=>Pt(n,t,s=>{n.put((s||0)+1,t),Ba(i)}))}function Hv(e,t,n){return n===0?[]:Ze(e,[Ra,Bt],ln,([i,s],o,a)=>{const r=[];i.index(Qd).openCursor(void 0,"prev").onsuccess=l=>{const d=l.target.result;if(!d)return a(r);function h(v){if(r.push(v),r.length===n)return a(r);d.continue()}const u=d.primaryKey,p=t.byName(u);if(p)return h(p);Pt(s,u,v=>{if(v)return h(v);d.continue()})}})}const vi="";function qv(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 d=0;d<a.length;d++){const h=a.charAt(d);let u=r.get(h);u||(u=new Map,r.set(h,u)),r=u}let l=r.get(vi);l||(l=[],r.set(vi,l)),l.push(s)}}return(s,o)=>{let a=n;for(let d=0;d<s.length;d++){const h=s.charAt(d),u=a.get(h);if(u)a=u;else return[]}if(o)return a.get(vi)||[];const r=[],l=[a];for(;l.length;){const h=[...l.shift().entries()].sort((u,p)=>u[0]<p[0]?-1:1);for(const[u,p]of h)u===vi?r.push(...p):l.push(p)}return r}}const jv=["name","url"];function Gv(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||jv.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function dl(e){Gv(e);const t=(p,v)=>p.name.toLowerCase()<v.name.toLowerCase()?-1:1,n=e.sort(t),s=qv(e,p=>{const v=new Set;if(p.shortcodes)for(const $ of p.shortcodes)for(const S of Vt($))v.add(S);return v}),o=p=>s(p,!0),a=p=>s(p,!1),r=p=>{const v=Vt(p),$=v.map((S,M)=>(M<v.length-1?o:a)(S));return nu($,S=>S.name).sort(t)},l=new Map,d=new Map;for(const p of e){d.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=>d.get(p.toLowerCase())}}const Vv=typeof wrappedJSObject<"u";function $n(e){if(!e)return e;if(Vv&&(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 ou(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const Qv=["annotation","emoji","group","order","version"];function Jv(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||Qv.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function au(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function Yv(e){const t=await fetch(e,{method:"HEAD"});au(t,e);const n=t.headers.get("etag");return ou(n),n}async function zo(e){const t=await fetch(e);au(t,e);const n=t.headers.get("etag");ou(n);const i=await t.json();return Jv(i),[n,i]}function Xv(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function Zv(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 ru(e){const t=JSON.stringify(e);let n=Zv(t);const i=await crypto.subtle.digest("SHA-1",n),s=Xv(i);return btoa(s)}async function eb(e,t){let n,i=await Yv(t);if(!i){const s=await zo(t);i=s[0],n=s[1],i||(i=await ru(n))}await Nv(e,t,i)||(n||(n=(await zo(t))[1]),await iu(e,n,t,i))}async function tb(e,t){let[n,i]=await zo(t);n||(n=await ru(i)),await iu(e,i,t,n)}async function nb(e,t){try{await eb(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class ib{constructor({dataSource:t=Sv,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=dl(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await _v(this._dbName);Pv(this._dbName,this._clear);const n=this.dataSource;await Bv(t)?await tb(t,n):this._lazyUpdate=nb(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 io(t),await this.ready(),cl(await Fv(this._db,t)).map($n)}async getEmojiBySearchQuery(t){yi(t),await this.ready();const n=this._custom.search(t),i=cl(await su(this._db,t)).map($n);return[...n,...i]}async getEmojiByShortcode(t){yi(t),await this.ready();const n=this._custom.byShortcode(t);return n||$n(await Uv(this._db,t))}async getEmojiByUnicodeOrName(t){yi(t),await this.ready();const n=this._custom.byName(t);return n||$n(await Wv(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Na(this._db,Xt,ll)||0}async setPreferredSkinTone(t){return io(t),await this.ready(),zv(this._db,Xt,ll,t)}async incrementFavoriteEmojiCount(t){return yi(t),await this.ready(),Kv(this._db,t)}async getTopFavoriteEmoji(t){return io(t),await this.ready(),(await Hv(this._db,this._custom,t)).map($n)}set customEmoji(t){this._custom=dl(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 Da(this._dbName)}async delete(){await this._shutdown(),await Mv(this._dbName)}}const Ko=[[-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})),so=Ko.slice(1),sb=2,ul=6,lu=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function pl(e){return e.unicode.includes("‍")}const ob={"🫪":17,"🫩":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},ab=1e3,rb="🖐️",lb=8,cb=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],cu='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',db=(e,t)=>e<t?-1:e>t?1:0,hl=(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 ${cu}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},ub=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function pb(e){const t=hl(e,"#000"),n=hl(e,"#fff");return t&&n&&ub(t,n)}function hb(){const e=Object.entries(ob);try{for(const[t,n]of e)if(pb(t))return n}catch{}return e[0][1]}let oo;const ao=()=>(oo||(oo=new Promise(e=>lu(()=>e(hb())))),oo),Ho=new Map,fb="️",gb="\uD83C",mb="‍",yb=127995,vb=57339;function bb(e,t){if(t===0)return e;const n=e.indexOf(mb);return n!==-1?e.substring(0,n)+String.fromCodePoint(yb+t-1)+e.substring(n):(e.endsWith(fb)&&(e=e.substring(0,e.length-1)),e+gb+String.fromCodePoint(vb+t-1))}function Be(e){e.preventDefault(),e.stopPropagation()}function ro(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function du(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 wb(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:d})=>({unicode:i,name:r,shortcodes:o,url:a,category:l,annotation:d,id:i||r,skins:s&&n(s)}))}const Ti=requestAnimationFrame;let kb=typeof ResizeObserver=="function";function xb(e,t,n){let i;kb?(i=new ResizeObserver(n),i.observe(e)):Ti(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function fl(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let lo;function $b(e,t,n){let i=!0,s=!1;for(const o of e){const a=n(o);if(!a)continue;const r=fl(a);r===0&&(s=!0),typeof lo>"u"&&(lo=fl(t));const l=r/1.8<lo;Ho.set(o.unicode,l),l||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
3015
3015
  This is likely due to using \`display:none\` which is unsupported.
3016
3016
  If this is a Jest/Vitest environment, you can ignore this warning.
3017
- For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function Sb(e){return du(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 fl(e){return""+e}function Cb(e){const t=document.createElement("template");return t.innerHTML=e,t}const Eb=new WeakMap,Tb=new WeakMap,_b=Symbol("un-keyed"),Mb="replaceChildren"in Element.prototype;function Pb(e,t){Mb?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function Ib(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 Rb(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=Ib(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&Pb(i,e)}function Lb(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:a,attributeValuePre:r,attributeValuePost:l}}=n,d=e[o];if(s!==d)if(n.currentExpression=d,a)if(d===null)i.removeAttribute(a);else{const h=r+fl(d)+l;i.setAttribute(a,h)}else{let h;Array.isArray(d)?Rb(d,n):d instanceof Element?(h=d,i.replaceWith(h)):i.nodeValue=fl(d),h&&(n.targetNode=h)}}}function Db(e){let t="",n=!1,i=!1,s=-1;const o=new Map,a=[];let r=0;for(let d=0,h=e.length;d<h;d++){const u=e[d];if(t+=u.slice(r),d===h-1)break;for(let b=0;b<u.length;b++)switch(u.charAt(b)){case"<":{u.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,M;if(i){const b=/(\S+)="?([^"=]*)$/.exec(u);$=b[1],S=b[2];const k=/^([^">]*)("?)/.exec(e[d+1]);M=k[1],t=t.slice(0,-1*b[0].length),r=k[0].length}else r=0;const y={attributeName:$,attributeValuePre:S,attributeValuePost:M,expressionIndex:d};v.push(y),!n&&!i&&(t+=" ")}return{template:Cb(t),elementsToBindings:o}}function gl(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 Bb(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))gl(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,a=-1;do{const r=t.get(++a);r&&gl(r,o,n)}while(o=s.nextNode())}return n}function Nb(e){const{template:t,elementsToBindings:n}=Dn(Eb,e,()=>Db(e)),i=t.cloneNode(!0).content.firstElementChild,s=Bb(i,n);return function(a){return Lb(a,s),i}}function Ob(e){const t=Dn(Tb,e,()=>new Map);let n=_b;function i(o,...a){const r=Dn(t,o,()=>new Map);return Dn(r,n,()=>Nb(o))(a)}function s(o,a,r){return o.map((l,d)=>{const h=n;n=r(l);try{return a(l,d)}finally{n=h}})}return{map:s,html:i}}function Fb(e,t,n,i,s,o,a,r,l){const{labelWithSkin:d,titleForEmoji:h,unicodeWithSkin:u}=n,{html:p,map:v}=Ob(t);function $(b,k,A){return v(b,(E,T)=>p`<button role="${k?"option":"menuitem"}" aria-selected="${k?T===t.activeSearchItem:null}" aria-label="${d(E,t.currentSkinTone)}" title="${h(E)}" class="${"emoji"+(k&&T===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?u(E,t.currentSkinTone):""}</button>`,E=>`${A}-${E.id}`)}const M=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}">${$(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>`,y=(b,k)=>{for(const A of e.querySelectorAll(`[${b}]`))k(A,A.getAttribute(b))};if(l){e.appendChild(M);for(const b of["click","focusout","input","keydown","keyup"])y(`data-on-${b}`,(k,A)=>{k.addEventListener(b,i[A])});y("data-ref",(b,k)=>{o[k]=b}),a.addEventListener("abort",()=>{e.removeChild(M)})}y("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 es=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function Ub(e){let t=!1,n;const i=new Map,s=new Set;let o;const a=()=>{if(t)return;const d=[...s];s.clear();try{for(const h of d)h()}finally{o=!1,s.size&&(o=!0,es(a))}},r=new Proxy({},{get(d,h){if(n){let u=i.get(h);u||(u=new Set,i.set(h,u)),u.add(n)}return d[h]},set(d,h,u){if(d[h]!==u){d[h]=u;const p=i.get(h);if(p){for(const v of p)s.add(v);o||(o=!0,es(a))}}return!0}}),l=d=>{const h=()=>{const u=n;n=h;try{return d()}finally{n=u}};return h()};return e.addEventListener("abort",()=>{t=!0}),{state:r,createEffect:l}}function ro(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 ml=new WeakMap;function Wb(e,t,n){{const i=e.closest(".tabpanel");let s=ml.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),ml.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const lo=[],{assign:bi}=Object;function zb(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:a}=Ub(s),r=new Map;bi(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),bi(o,t),bi(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:lb,isRtl:!1,currentGroupIndex:0,groups:no,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()},d=C=>e.getElementById(`emo-${C.id}`),h=(C,R)=>{n.rootElement.dispatchEvent(new CustomEvent(C,{detail:R,bubbles:!0,composed:!0}))},u=(C,R)=>C.id===R.id,p=(C,R)=>{const{category:F,emojis:U}=C,{category:ee,emojis:J}=R;return F!==ee?!1:ro(U,J,u)},v=C=>{ro(o.currentEmojis,C,u)||(o.currentEmojis=C)},$=C=>{o.searchMode!==C&&(o.searchMode=C)},S=C=>{ro(o.currentEmojisWithCategories,C,p)||(o.currentEmojisWithCategories=C)},M=(C,R)=>R&&C.skins&&C.skins[R]||C.unicode,k={labelWithSkin:(C,R)=>Sb([C.name||M(C,R),C.annotation,...C.shortcodes||lo].filter(Boolean)).join(", "),titleForEmoji:C=>C.annotation||(C.shortcodes||lo).join(", "),unicodeWithSkin:M},A={onClickSkinToneButton:X,onEmojiClick:Yn,onNavClick:Qn,onNavKeydown:ks,onSearchKeydown:ws,onSkinToneOptionsClick:Xn,onSkinToneOptionsFocusOut:et,onSkinToneOptionsKeydown:dt,onSkinToneOptionsKeyup:dn,onSearchInput:Zn},E={calculateEmojiGridStyle:D,updateOnIntersection:W};let T=!0;a(()=>{Fb(e,o,k,A,E,n,s,r,T),T=!1}),o.emojiVersion||so().then(C=>{C||(o.message=o.i18n.emojiUnsupportedMessage)}),a(()=>{async function C(){let R=!1;const F=setTimeout(()=>{R=!0,o.message=o.i18n.loadingMessage},ab);try{await o.database.ready(),o.databaseLoaded=!0}catch(U){console.error(U),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(F),R&&(R=!1,o.message="")}}o.database&&C()}),a(()=>{o.pickerStyle=`
3017
+ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function Sb(e){return du(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 gl(e){return""+e}function Cb(e){const t=document.createElement("template");return t.innerHTML=e,t}const Eb=new WeakMap,Tb=new WeakMap,_b=Symbol("un-keyed"),Mb="replaceChildren"in Element.prototype;function Pb(e,t){Mb?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function Ib(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 Rb(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=Ib(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&Pb(i,e)}function Lb(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:a,attributeValuePre:r,attributeValuePost:l}}=n,d=e[o];if(s!==d)if(n.currentExpression=d,a)if(d===null)i.removeAttribute(a);else{const h=r+gl(d)+l;i.setAttribute(a,h)}else{let h;Array.isArray(d)?Rb(d,n):d instanceof Element?(h=d,i.replaceWith(h)):i.nodeValue=gl(d),h&&(n.targetNode=h)}}}function Db(e){let t="",n=!1,i=!1,s=-1;const o=new Map,a=[];let r=0;for(let d=0,h=e.length;d<h;d++){const u=e[d];if(t+=u.slice(r),d===h-1)break;for(let b=0;b<u.length;b++)switch(u.charAt(b)){case"<":{u.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,M;if(i){const b=/(\S+)="?([^"=]*)$/.exec(u);$=b[1],S=b[2];const k=/^([^">]*)("?)/.exec(e[d+1]);M=k[1],t=t.slice(0,-1*b[0].length),r=k[0].length}else r=0;const y={attributeName:$,attributeValuePre:S,attributeValuePost:M,expressionIndex:d};v.push(y),!n&&!i&&(t+=" ")}return{template:Cb(t),elementsToBindings:o}}function ml(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 Bb(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))ml(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,a=-1;do{const r=t.get(++a);r&&ml(r,o,n)}while(o=s.nextNode())}return n}function Nb(e){const{template:t,elementsToBindings:n}=Dn(Eb,e,()=>Db(e)),i=t.cloneNode(!0).content.firstElementChild,s=Bb(i,n);return function(a){return Lb(a,s),i}}function Ob(e){const t=Dn(Tb,e,()=>new Map);let n=_b;function i(o,...a){const r=Dn(t,o,()=>new Map);return Dn(r,n,()=>Nb(o))(a)}function s(o,a,r){return o.map((l,d)=>{const h=n;n=r(l);try{return a(l,d)}finally{n=h}})}return{map:s,html:i}}function Fb(e,t,n,i,s,o,a,r,l){const{labelWithSkin:d,titleForEmoji:h,unicodeWithSkin:u}=n,{html:p,map:v}=Ob(t);function $(b,k,A){return v(b,(E,T)=>p`<button role="${k?"option":"menuitem"}" aria-selected="${k?T===t.activeSearchItem:null}" aria-label="${d(E,t.currentSkinTone)}" title="${h(E)}" class="${"emoji"+(k&&T===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?u(E,t.currentSkinTone):""}</button>`,E=>`${A}-${E.id}`)}const M=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}">${$(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>`,y=(b,k)=>{for(const A of e.querySelectorAll(`[${b}]`))k(A,A.getAttribute(b))};if(l){e.appendChild(M);for(const b of["click","focusout","input","keydown","keyup"])y(`data-on-${b}`,(k,A)=>{k.addEventListener(b,i[A])});y("data-ref",(b,k)=>{o[k]=b}),a.addEventListener("abort",()=>{e.removeChild(M)})}y("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 ns=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function Ub(e){let t=!1,n;const i=new Map,s=new Set;let o;const a=()=>{if(t)return;const d=[...s];s.clear();try{for(const h of d)h()}finally{o=!1,s.size&&(o=!0,ns(a))}},r=new Proxy({},{get(d,h){if(n){let u=i.get(h);u||(u=new Set,i.set(h,u)),u.add(n)}return d[h]},set(d,h,u){if(d[h]!==u){d[h]=u;const p=i.get(h);if(p){for(const v of p)s.add(v);o||(o=!0,ns(a))}}return!0}}),l=d=>{const h=()=>{const u=n;n=h;try{return d()}finally{n=u}};return h()};return e.addEventListener("abort",()=>{t=!0}),{state:r,createEffect:l}}function co(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 yl=new WeakMap;function Wb(e,t,n){{const i=e.closest(".tabpanel");let s=yl.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),yl.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const uo=[],{assign:bi}=Object;function zb(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:a}=Ub(s),r=new Map;bi(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),bi(o,t),bi(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:lb,isRtl:!1,currentGroupIndex:0,groups:so,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()},d=C=>e.getElementById(`emo-${C.id}`),h=(C,R)=>{n.rootElement.dispatchEvent(new CustomEvent(C,{detail:R,bubbles:!0,composed:!0}))},u=(C,R)=>C.id===R.id,p=(C,R)=>{const{category:F,emojis:U}=C,{category:ee,emojis:J}=R;return F!==ee?!1:co(U,J,u)},v=C=>{co(o.currentEmojis,C,u)||(o.currentEmojis=C)},$=C=>{o.searchMode!==C&&(o.searchMode=C)},S=C=>{co(o.currentEmojisWithCategories,C,p)||(o.currentEmojisWithCategories=C)},M=(C,R)=>R&&C.skins&&C.skins[R]||C.unicode,k={labelWithSkin:(C,R)=>Sb([C.name||M(C,R),C.annotation,...C.shortcodes||uo].filter(Boolean)).join(", "),titleForEmoji:C=>C.annotation||(C.shortcodes||uo).join(", "),unicodeWithSkin:M},A={onClickSkinToneButton:X,onEmojiClick:Yn,onNavClick:Qn,onNavKeydown:$s,onSearchKeydown:xs,onSkinToneOptionsClick:Xn,onSkinToneOptionsFocusOut:et,onSkinToneOptionsKeydown:dt,onSkinToneOptionsKeyup:dn,onSearchInput:Zn},E={calculateEmojiGridStyle:D,updateOnIntersection:W};let T=!0;a(()=>{Fb(e,o,k,A,E,n,s,r,T),T=!1}),o.emojiVersion||ao().then(C=>{C||(o.message=o.i18n.emojiUnsupportedMessage)}),a(()=>{async function C(){let R=!1;const F=setTimeout(()=>{R=!0,o.message=o.i18n.loadingMessage},ab);try{await o.database.ready(),o.databaseLoaded=!0}catch(U){console.error(U),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(F),R&&(R=!1,o.message="")}}o.database&&C()}),a(()=>{o.pickerStyle=`
3018
3018
  --num-groups: ${o.groups.length};
3019
3019
  --indicator-opacity: ${o.searchMode?0:1};
3020
- --num-skintones: ${dl};`}),a(()=>{o.customEmoji&&o.database&&P()}),a(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==Uo&&(o.groups=Uo):o.groups!==no&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=no)}),a(()=>{async function C(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}C()}),a(()=>{o.skinTones=Array(dl).fill().map((C,R)=>bb(o.skinToneEmoji,R))}),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:R}=o,F=(await Promise.all(cb.map(U=>R.getEmojiByUnicodeOrName(U)))).filter(Boolean);o.defaultFavoriteEmojis=F}o.databaseLoaded&&C()});function P(){const{customEmoji:C,database:R}=o,F=C||lo;R.customEmoji!==F&&(R.customEmoji=F)}a(()=>{async function C(){P();const{database:R,defaultFavoriteEmojis:F,numColumns:U}=o,ee=await R.getTopFavoriteEmoji(U),J=await Ke(du([...ee,...F],he=>he.unicode||he.name).slice(0,U));o.currentFavorites=J}o.databaseLoaded&&o.defaultFavoriteEmojis&&C()});function D(C){xb(C,s,()=>{{const R=getComputedStyle(n.rootElement),F=parseInt(R.getPropertyValue("--num-columns"),10),U=R.getPropertyValue("direction")==="rtl";o.numColumns=F,o.isRtl=U}})}function W(C){Wb(C,s,R=>{for(const{target:F,isIntersecting:U}of R)F.classList.toggle("onscreen",U)})}a(()=>{async function C(){const{searchText:R,currentGroup:F,databaseLoaded:U,customEmoji:ee}=o;if(!U)o.currentEmojis=[],o.searchMode=!1;else if(R.length>=sb){const J=await bs(R);o.searchText===R&&(v(J),$(!0))}else{const{id:J}=F;if(J!==-1||ee&&ee.length){const he=await vs(J);o.currentGroup.id===J&&(v(he),$(!1))}}}C()});const K=()=>{Ti(()=>Ab(n.tabpanelElement))};a(()=>{const{currentEmojis:C,emojiVersion:R}=o,F=C.filter(U=>U.unicode).filter(U=>ul(U)&&!Wo.has(U.unicode));if(!R&&F.length)v(C),Ti(()=>H(F));else{const U=R?C:C.filter(ke);v(U),K()}});function H(C){$b(C,n.baselineEmoji,d)?K():o.currentEmojis=[...o.currentEmojis]}function ke(C){return!C.unicode||!ul(C)||Wo.get(C.unicode)}async function Ie(C){const R=o.emojiVersion||await so();return C.filter(({version:F})=>!F||F<=R)}async function Ke(C){return wb(C,o.emojiVersion||await so())}async function vs(C){const R=C===-1?o.customEmoji:await o.database.getEmojiByGroup(C);return Ke(await Ie(R))}async function bs(C){return Ke(await Ie(await o.database.getEmojiBySearchQuery(C)))}a(()=>{}),a(()=>{function C(){const{searchMode:F,currentEmojis:U}=o;if(F)return[{category:"",emojis:U}];const ee=new Map;for(const J of U){const he=J.category||"";let tt=ee.get(he);tt||(tt=[],ee.set(he,tt)),tt.push(J)}return[...ee.entries()].map(([J,he])=>({category:J,emojis:he})).sort((J,he)=>o.customCategorySorting(J.category,he.category))}const R=C();S(R)}),a(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),a(()=>{const{rawSearchText:C}=o;lu(()=>{o.searchText=(C||"").trim(),o.activeSearchItem=-1})});function ws(C){if(!o.searchMode||!o.currentEmojis.length)return;const R=F=>{Be(C),o.activeSearchItem=oo(F,o.activeSearchItem,o.currentEmojis)};switch(C.key){case"ArrowDown":return R(!1);case"ArrowUp":return R(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return Be(C),te(o.currentEmojis[o.activeSearchItem].id)}}function Qn(C){const{target:R}=C,F=R.closest(".nav-button");if(!F)return;const U=parseInt(F.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(ee=>ee.id===U)}function ks(C){const{target:R,key:F}=C,U=ee=>{ee&&(Be(C),ee.focus())};switch(F){case"ArrowLeft":return U(R.previousElementSibling);case"ArrowRight":return U(R.nextElementSibling);case"Home":return U(R.parentElement.firstElementChild);case"End":return U(R.parentElement.lastElementChild)}}async function Jn(C){const R=await o.database.getEmojiByUnicodeOrName(C),F=[...o.currentEmojis,...o.currentFavorites].find(ee=>ee.id===C),U=F.unicode&&M(F,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(C),{emoji:R,skinTone:o.currentSkinTone,...U&&{unicode:U},...F.name&&{name:F.name}}}async function te(C){const R=Jn(C);h("emoji-click-sync",R),h("emoji-click",await R)}function Yn(C){const{target:R}=C;if(!R.classList.contains("emoji"))return;Be(C);const F=R.id.substring(4);te(F)}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:R}}=C,F=R&&R.match(/^skintone-(\d)/);if(!F)return;Be(C);const U=parseInt(F[1],10);ne(U)}function X(C){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(Be(C),Ti(()=>l("skintone-list")))}a(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function dt(C){if(!o.skinTonePickerExpanded)return;const R=async F=>{Be(C),o.activeSkinTone=F};switch(C.key){case"ArrowUp":return R(oo(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return R(oo(!1,o.activeSkinTone,o.skinTones));case"Home":return R(0);case"End":return R(o.skinTones.length-1);case"Enter":return Be(C),ne(o.activeSkinTone);case"Escape":return Be(C),o.skinTonePickerExpanded=!1,l("skintone-button")}}function dn(C){if(o.skinTonePickerExpanded&&C.key===" ")return Be(C),ne(o.activeSkinTone)}async function et(C){const{relatedTarget:R}=C;(!R||R.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function Zn(C){o.rawSearchText=C.target.value}return{$set(C){bi(o,C)},$destroy(){i.abort()}}}const Kb="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Hb="en";var qb={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"}},jb=':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 uu=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Gb=`:host{--emoji-font-family:${cu}}`;class Na extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=jb+Gb,this.shadowRoot.appendChild(n),this._ctx={locale:Hb,dataSource:Kb,skinToneEmoji:rb,customCategorySorting:db,customEmoji:null,i18n:qb,emojiVersion:null,...t};for(const i of uu)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){yl(this),this._cmp||(this._cmp=zb(this.shadowRoot,this._ctx))}disconnectedCallback(){yl(this),es(()=>{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 ib({locale:t,dataSource:n}))}_dbFlush(){es(()=>this._dbCreate())}}const pu={};for(const e of uu)pu[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(Na.prototype,pu);function yl(e){e instanceof Na||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Na);function Vb(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 vl(e){e.style.height="44px",e.style.overflowY="hidden"}const Qb=5e3;function Jb(e){return e?e.active?c`
3020
+ --num-skintones: ${ul};`}),a(()=>{o.customEmoji&&o.database&&P()}),a(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==Ko&&(o.groups=Ko):o.groups!==so&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=so)}),a(()=>{async function C(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}C()}),a(()=>{o.skinTones=Array(ul).fill().map((C,R)=>bb(o.skinToneEmoji,R))}),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:R}=o,F=(await Promise.all(cb.map(U=>R.getEmojiByUnicodeOrName(U)))).filter(Boolean);o.defaultFavoriteEmojis=F}o.databaseLoaded&&C()});function P(){const{customEmoji:C,database:R}=o,F=C||uo;R.customEmoji!==F&&(R.customEmoji=F)}a(()=>{async function C(){P();const{database:R,defaultFavoriteEmojis:F,numColumns:U}=o,ee=await R.getTopFavoriteEmoji(U),J=await Ke(du([...ee,...F],he=>he.unicode||he.name).slice(0,U));o.currentFavorites=J}o.databaseLoaded&&o.defaultFavoriteEmojis&&C()});function D(C){xb(C,s,()=>{{const R=getComputedStyle(n.rootElement),F=parseInt(R.getPropertyValue("--num-columns"),10),U=R.getPropertyValue("direction")==="rtl";o.numColumns=F,o.isRtl=U}})}function W(C){Wb(C,s,R=>{for(const{target:F,isIntersecting:U}of R)F.classList.toggle("onscreen",U)})}a(()=>{async function C(){const{searchText:R,currentGroup:F,databaseLoaded:U,customEmoji:ee}=o;if(!U)o.currentEmojis=[],o.searchMode=!1;else if(R.length>=sb){const J=await ks(R);o.searchText===R&&(v(J),$(!0))}else{const{id:J}=F;if(J!==-1||ee&&ee.length){const he=await ws(J);o.currentGroup.id===J&&(v(he),$(!1))}}}C()});const K=()=>{Ti(()=>Ab(n.tabpanelElement))};a(()=>{const{currentEmojis:C,emojiVersion:R}=o,F=C.filter(U=>U.unicode).filter(U=>pl(U)&&!Ho.has(U.unicode));if(!R&&F.length)v(C),Ti(()=>H(F));else{const U=R?C:C.filter(ke);v(U),K()}});function H(C){$b(C,n.baselineEmoji,d)?K():o.currentEmojis=[...o.currentEmojis]}function ke(C){return!C.unicode||!pl(C)||Ho.get(C.unicode)}async function Ie(C){const R=o.emojiVersion||await ao();return C.filter(({version:F})=>!F||F<=R)}async function Ke(C){return wb(C,o.emojiVersion||await ao())}async function ws(C){const R=C===-1?o.customEmoji:await o.database.getEmojiByGroup(C);return Ke(await Ie(R))}async function ks(C){return Ke(await Ie(await o.database.getEmojiBySearchQuery(C)))}a(()=>{}),a(()=>{function C(){const{searchMode:F,currentEmojis:U}=o;if(F)return[{category:"",emojis:U}];const ee=new Map;for(const J of U){const he=J.category||"";let tt=ee.get(he);tt||(tt=[],ee.set(he,tt)),tt.push(J)}return[...ee.entries()].map(([J,he])=>({category:J,emojis:he})).sort((J,he)=>o.customCategorySorting(J.category,he.category))}const R=C();S(R)}),a(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),a(()=>{const{rawSearchText:C}=o;lu(()=>{o.searchText=(C||"").trim(),o.activeSearchItem=-1})});function xs(C){if(!o.searchMode||!o.currentEmojis.length)return;const R=F=>{Be(C),o.activeSearchItem=ro(F,o.activeSearchItem,o.currentEmojis)};switch(C.key){case"ArrowDown":return R(!1);case"ArrowUp":return R(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return Be(C),te(o.currentEmojis[o.activeSearchItem].id)}}function Qn(C){const{target:R}=C,F=R.closest(".nav-button");if(!F)return;const U=parseInt(F.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(ee=>ee.id===U)}function $s(C){const{target:R,key:F}=C,U=ee=>{ee&&(Be(C),ee.focus())};switch(F){case"ArrowLeft":return U(R.previousElementSibling);case"ArrowRight":return U(R.nextElementSibling);case"Home":return U(R.parentElement.firstElementChild);case"End":return U(R.parentElement.lastElementChild)}}async function Jn(C){const R=await o.database.getEmojiByUnicodeOrName(C),F=[...o.currentEmojis,...o.currentFavorites].find(ee=>ee.id===C),U=F.unicode&&M(F,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(C),{emoji:R,skinTone:o.currentSkinTone,...U&&{unicode:U},...F.name&&{name:F.name}}}async function te(C){const R=Jn(C);h("emoji-click-sync",R),h("emoji-click",await R)}function Yn(C){const{target:R}=C;if(!R.classList.contains("emoji"))return;Be(C);const F=R.id.substring(4);te(F)}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:R}}=C,F=R&&R.match(/^skintone-(\d)/);if(!F)return;Be(C);const U=parseInt(F[1],10);ne(U)}function X(C){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(Be(C),Ti(()=>l("skintone-list")))}a(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function dt(C){if(!o.skinTonePickerExpanded)return;const R=async F=>{Be(C),o.activeSkinTone=F};switch(C.key){case"ArrowUp":return R(ro(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return R(ro(!1,o.activeSkinTone,o.skinTones));case"Home":return R(0);case"End":return R(o.skinTones.length-1);case"Enter":return Be(C),ne(o.activeSkinTone);case"Escape":return Be(C),o.skinTonePickerExpanded=!1,l("skintone-button")}}function dn(C){if(o.skinTonePickerExpanded&&C.key===" ")return Be(C),ne(o.activeSkinTone)}async function et(C){const{relatedTarget:R}=C;(!R||R.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function Zn(C){o.rawSearchText=C.target.value}return{$set(C){bi(o,C)},$destroy(){i.abort()}}}const Kb="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Hb="en";var qb={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"}},jb=':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 uu=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Gb=`:host{--emoji-font-family:${cu}}`;class Oa extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=jb+Gb,this.shadowRoot.appendChild(n),this._ctx={locale:Hb,dataSource:Kb,skinToneEmoji:rb,customCategorySorting:db,customEmoji:null,i18n:qb,emojiVersion:null,...t};for(const i of uu)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){vl(this),this._cmp||(this._cmp=zb(this.shadowRoot,this._ctx))}disconnectedCallback(){vl(this),ns(()=>{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 ib({locale:t,dataSource:n}))}_dbFlush(){ns(()=>this._dbCreate())}}const pu={};for(const e of uu)pu[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(Oa.prototype,pu);function vl(e){e instanceof Oa||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Oa);function Vb(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 bl(e){e.style.height="44px",e.style.overflowY="hidden"}const Qb=5e3;function Jb(e){return e?e.active?c`
3021
3021
  <div class="callout info compaction-indicator compaction-indicator--active">
3022
3022
  ${I.loader} Compacting context...
3023
3023
  </div>
@@ -3179,7 +3179,7 @@ ${e.sidebarContent}
3179
3179
  <textarea
3180
3180
  .value=${e.draft}
3181
3181
  ?disabled=${!e.connected}
3182
- @keydown=${y=>{y.key==="Enter"&&(y.isComposing||y.keyCode===229||y.shiftKey||e.connected&&(y.preventDefault(),t&&(e.onSend(),vl(y.target))))}}
3182
+ @keydown=${y=>{y.key==="Enter"&&(y.isComposing||y.keyCode===229||y.shiftKey||e.connected&&(y.preventDefault(),t&&(e.onSend(),bl(y.target))))}}
3183
3183
  @input=${y=>{const b=y.target;e.onDraftChange(b.value),Vb(b)}}
3184
3184
  @paste=${y=>nw(y,e)}
3185
3185
  placeholder=${l}
@@ -3199,7 +3199,7 @@ ${e.sidebarContent}
3199
3199
  <button
3200
3200
  class="btn btn--icon chat-compose__send primary"
3201
3201
  ?disabled=${!e.connected}
3202
- @click=${y=>{var k;e.onSend();const b=(k=y.target.closest(".chat-compose"))==null?void 0:k.querySelector("textarea");b&&vl(b)}}
3202
+ @click=${y=>{var k;e.onSend();const b=(k=y.target.closest(".chat-compose"))==null?void 0:k.querySelector("textarea");b&&bl(b)}}
3203
3203
  aria-label="${n?"Queue":"Send"}"
3204
3204
  title="${n?"Queue message":"Send (Enter)"}"
3205
3205
  >
@@ -3213,9 +3213,9 @@ ${e.sidebarContent}
3213
3213
  </div>
3214
3214
  </div>
3215
3215
  </section>
3216
- `}function aw(e){return e.map(t=>{if(t.kind!=="message")return t;const n=tc(t.message),i=nc(n.role),s=n.timestamp||Date.now();return{kind:"group",key:`group:${i}:${t.key}`,role:i,messages:[{message:t.message,key:t.key}],timestamp:s,isStreaming:!1}})}function rw(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=tc(r);if(!s&&l.role.toLowerCase()==="toolresult"){const d=r,u=(Array.isArray(d.content)?d.content:[]).filter(p=>{const v=p.type;return v==="image"||v==="file"});u.length>0&&t.push({kind:"message",key:co(r,a),message:{role:"assistant",content:u,timestamp:l.timestamp}});continue}t.push({kind:"message",key:co(r,a),message:r})}if(s)for(let a=0;a<i.length;a++)t.push({kind:"message",key:co(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(d=>d.fileName).map(d=>d.fileName))??[],l=r.length>0?a.text?`${r.join(", ")}
3216
+ `}function aw(e){return e.map(t=>{if(t.kind!=="message")return t;const n=nc(t.message),i=ic(n.role),s=n.timestamp||Date.now();return{kind:"group",key:`group:${i}:${t.key}`,role:i,messages:[{message:t.message,key:t.key}],timestamp:s,isStreaming:!1}})}function rw(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=nc(r);if(!s&&l.role.toLowerCase()==="toolresult"){const d=r,u=(Array.isArray(d.content)?d.content:[]).filter(p=>{const v=p.type;return v==="image"||v==="file"});u.length>0&&t.push({kind:"message",key:po(r,a),message:{role:"assistant",content:u,timestamp:l.timestamp}});continue}t.push({kind:"message",key:po(r,a),message:r})}if(s)for(let a=0;a<i.length;a++)t.push({kind:"message",key:po(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(d=>d.fileName).map(d=>d.fileName))??[],l=r.length>0?a.text?`${r.join(", ")}
3217
3217
 
3218
- ${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 aw(t)}function co(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}`}function lw(e){if(!e)return"";const t=new Date(e*1e3);return t.toLocaleDateString([],{year:"numeric",month:"short",day:"numeric"})+" "+t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function vu(e){return e.replace(/@s\.whatsapp\.net$/,"").replace(/@g\.us$/,"")}function cw(e){const t=e.searchQuery.toLowerCase(),n=t?e.conversations.filter(i=>i.name.toLowerCase().includes(t)||i.jid.includes(t)):e.conversations;return c`
3218
+ ${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 aw(t)}function po(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}`}function lw(e){if(!e)return"";const t=new Date(e*1e3);return t.toLocaleDateString([],{year:"numeric",month:"short",day:"numeric"})+" "+t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function vu(e){return e.replace(/@s\.whatsapp\.net$/,"").replace(/@g\.us$/,"")}function cw(e){const t=e.searchQuery.toLowerCase(),n=t?e.conversations.filter(i=>i.name.toLowerCase().includes(t)||i.jid.includes(t)):e.conversations;return c`
3219
3219
  <div class="wa-list">
3220
3220
  <div class="wa-list__header">
3221
3221
  <input
@@ -3326,7 +3326,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3326
3326
  ${t==="whatsapp"&&e.whatsappProps?fw(e.whatsappProps):yu(e)}
3327
3327
  </div>
3328
3328
  </div>
3329
- `}async function bu(e){if(!(!e.client||!e.connected)){e.loading=!0,e.lastError=null;try{const t=await e.client.request("whatsapp.conversations",{accountId:e.accountId});e.conversations=t.conversations}catch(t){e.lastError=String(t)}finally{e.loading=!1}}}async function yw(e,t){if(!(!e.client||!e.connected)){e.selectedJid=t,e.messagesLoading=!0,e.messages=[],e.groupInfo=null,e.lastError=null;try{const n=await e.client.request("whatsapp.messages",{jid:t,limit:100,accountId:e.accountId});e.messages=n.messages}catch(n){e.lastError=String(n)}if(t.endsWith("@g.us"))try{const n=await e.client.request("whatsapp.groupInfo",{jid:t,accountId:e.accountId});e.groupInfo=n}catch{}e.messagesLoading=!1}}async function vw(e,t,n){if(!(!e.client||!e.connected))try{await e.client.request("whatsapp.setActivation",{jid:t,activation:n,accountId:e.accountId}),e.groupInfo&&(e.groupInfo.activation=n);const i=e.conversations.find(s=>s.jid===t);i&&(i.activation=n)}catch(i){e.lastError=String(i)}}function bw(e){return e?`${Yl(e)} (${os(e)})`:"n/a"}function wu(e){const t=e.state??{},n=t.lastStatus??"n/a",i=t.lastRunAtMs?os(t.lastRunAtMs):"never";return`${n} · last ${i}`}function ku(e){const t=e.schedule;return t.kind==="at"?`One-time: ${Yl(t.atMs)}`:t.kind==="every"?`Every ${Xo(t.everyMs)}`:ww(t.expr,t.tz)}function ww(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," ")})`:"",d=(S,M)=>new Date(2e3,0,1,S,M).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),h=/^\d{1,2}$/.test(i)?parseInt(i,10):null,u=bl(s);if(h===null||!u)return`${e}${t?` (${t})`:""}`;const p=u.map(S=>d(S,h)),v=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 ${v}${l}`;if(r==="1-5")return`Weekdays at ${v}${l}`;if(r==="0,6"||r==="6,0")return`Weekends at ${v}${l}`;const S=bl(r);if(S)return`${S.map(y=>$[y%7]??String(y)).join(", ")} at ${v}${l}`}return`${e}${t?` (${t})`:""}`}function bl(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 kw(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 wl(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 be=null;function xw(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 $w(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 Sw(e){return e.split(",").map(n=>n.trim()).filter(Boolean).map(n=>n.toLowerCase()==="admins"?"All admins":n).join(", ")}function Aw(e){return e||"Default"}const Cw=c`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,Ew=c`<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>`,Tw=c`<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>`,gs=c`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,_w=c`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,xu=c`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`,Mw=c`<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 kl(e){const t=e.detailJobId?e.jobs.find(i=>i.id===e.detailJobId)??null:null,n=e.newEventModalOpen||!!e.editJobId;return c`
3329
+ `}async function bu(e){if(!(!e.client||!e.connected)){e.loading=!0,e.lastError=null;try{const t=await e.client.request("whatsapp.conversations",{accountId:e.accountId});e.conversations=t.conversations}catch(t){e.lastError=String(t)}finally{e.loading=!1}}}async function yw(e,t){if(!(!e.client||!e.connected)){e.selectedJid=t,e.messagesLoading=!0,e.messages=[],e.groupInfo=null,e.lastError=null;try{const n=await e.client.request("whatsapp.messages",{jid:t,limit:100,accountId:e.accountId});e.messages=n.messages}catch(n){e.lastError=String(n)}if(t.endsWith("@g.us"))try{const n=await e.client.request("whatsapp.groupInfo",{jid:t,accountId:e.accountId});e.groupInfo=n}catch{}e.messagesLoading=!1}}async function vw(e,t,n){if(!(!e.client||!e.connected))try{await e.client.request("whatsapp.setActivation",{jid:t,activation:n,accountId:e.accountId}),e.groupInfo&&(e.groupInfo.activation=n);const i=e.conversations.find(s=>s.jid===t);i&&(i.activation=n)}catch(i){e.lastError=String(i)}}function bw(e){return e?`${Xl(e)} (${rs(e)})`:"n/a"}function wu(e){const t=e.state??{},n=t.lastStatus??"n/a",i=t.lastRunAtMs?rs(t.lastRunAtMs):"never";return`${n} · last ${i}`}function ku(e){const t=e.schedule;return t.kind==="at"?`One-time: ${Xl(t.atMs)}`:t.kind==="every"?`Every ${ta(t.everyMs)}`:ww(t.expr,t.tz)}function ww(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," ")})`:"",d=(S,M)=>new Date(2e3,0,1,S,M).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),h=/^\d{1,2}$/.test(i)?parseInt(i,10):null,u=wl(s);if(h===null||!u)return`${e}${t?` (${t})`:""}`;const p=u.map(S=>d(S,h)),v=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 ${v}${l}`;if(r==="1-5")return`Weekdays at ${v}${l}`;if(r==="0,6"||r==="6,0")return`Weekends at ${v}${l}`;const S=wl(r);if(S)return`${S.map(y=>$[y%7]??String(y)).join(", ")} at ${v}${l}`}return`${e}${t?` (${t})`:""}`}function wl(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 kw(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 kl(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 be=null;function xw(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 $w(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 Sw(e){return e.split(",").map(n=>n.trim()).filter(Boolean).map(n=>n.toLowerCase()==="admins"?"All admins":n).join(", ")}function Aw(e){return e||"Default"}const Cw=c`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,Ew=c`<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>`,Tw=c`<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>`,ys=c`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,_w=c`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,xu=c`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`,Mw=c`<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 xl(e){const t=e.detailJobId?e.jobs.find(i=>i.id===e.detailJobId)??null:null,n=e.newEventModalOpen||!!e.editJobId;return c`
3330
3330
  ${Pw(e)}
3331
3331
  ${Iw(e)}
3332
3332
  ${n?Lw(e):w}
@@ -3341,7 +3341,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3341
3341
  <span>${i} event${i!==1?"s":""}</span>
3342
3342
  ${s?c`
3343
3343
  <span class="event-status-bar__sep">\u00b7</span>
3344
- <span>Next: ${os(s)}</span>
3344
+ <span>Next: ${rs(s)}</span>
3345
3345
  `:w}
3346
3346
  <button
3347
3347
  class="btn btn--sm"
@@ -3374,7 +3374,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3374
3374
  </div>
3375
3375
  <div class="event-card__schedule">${ku(e)}</div>
3376
3376
  ${e.agentId?c`<div class="event-card__agent">${Aw(e.agentId)}</div>`:w}
3377
- ${wl(e)?c`<div class="event-card__agent muted" style="font-size: 11px;">\u2192 ${wl(e)}</div>`:w}
3377
+ ${kl(e)?c`<div class="event-card__agent muted" style="font-size: 11px;">\u2192 ${kl(e)}</div>`:w}
3378
3378
  <div class="event-card__footer">
3379
3379
  <div class="event-card__status">
3380
3380
  <span class="muted" style="font-size: 11px;">${wu(e)}</span>
@@ -3415,7 +3415,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3415
3415
  <div class="event-modal__header">
3416
3416
  <div class="event-modal__title">${t?"Edit Event":"New Event"}</div>
3417
3417
  <button class="event-modal__close" @click=${i}>
3418
- ${gs}
3418
+ ${ys}
3419
3419
  </button>
3420
3420
  </div>
3421
3421
 
@@ -3598,7 +3598,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3598
3598
  title="Remove"
3599
3599
  @click=${()=>{const s=t.filter((o,a)=>a!==i);e.onFormChange({recipients:s})}}
3600
3600
  >
3601
- ${gs}
3601
+ ${ys}
3602
3602
  </button>
3603
3603
  </div>
3604
3604
  `)}
@@ -3658,7 +3658,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3658
3658
  <div class="event-modal__header">
3659
3659
  <div class="event-modal__title">${e.name||"Untitled Event"}</div>
3660
3660
  <button class="event-modal__close" @click=${t.onDetailClose}>
3661
- ${gs}
3661
+ ${ys}
3662
3662
  </button>
3663
3663
  </div>
3664
3664
 
@@ -3782,7 +3782,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3782
3782
  <div class="event-modal__header">
3783
3783
  <div class="event-modal__title">${e.runModalJobName}</div>
3784
3784
  <button class="event-modal__close" @click=${e.onRunModalClose}>
3785
- ${gs}
3785
+ ${ys}
3786
3786
  </button>
3787
3787
  </div>
3788
3788
 
@@ -3802,7 +3802,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3802
3802
  >
3803
3803
  ${i}
3804
3804
  </span>
3805
- ${t.durationMs!=null?c`<span class="muted" style="font-size: 13px;">${Xo(t.durationMs)}</span>`:w}
3805
+ ${t.durationMs!=null?c`<span class="muted" style="font-size: 13px;">${ta(t.durationMs)}</span>`:w}
3806
3806
  </div>
3807
3807
  ${t.outputText||t.summary?c`
3808
3808
  <div style="white-space: pre-wrap; font-size: 13px; line-height: 1.6; max-height: 400px; overflow-y: auto; color: var(--fg);">${t.outputText??t.summary}</div>
@@ -3827,8 +3827,8 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3827
3827
  <span class=${Fw(e.status)} style="font-size: 11px; padding: 2px 8px;">
3828
3828
  ${e.status}
3829
3829
  </span>
3830
- <span class="muted" style="font-size: 12px;">${os(e.ts)}</span>
3831
- <span class="muted" style="font-size: 12px;">${Xo(e.durationMs)}</span>
3830
+ <span class="muted" style="font-size: 12px;">${rs(e.ts)}</span>
3831
+ <span class="muted" style="font-size: 12px;">${ta(e.durationMs)}</span>
3832
3832
  </div>
3833
3833
  ${e.summary?c`<div class="muted" style="font-size: 12px;">${e.summary}</div>`:w}
3834
3834
  ${e.error?c`
@@ -4147,7 +4147,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4147
4147
  </div>
4148
4148
  `})}
4149
4149
  </div>
4150
- `}const Vw=["user","assistant","tool_call","tool_result","thinking","error"],xl={user:"User",assistant:"Assistant",tool:"Tool",tool_call:"Call",tool_result:"Result",thinking:"Thinking",error:"Error",system:"System"};function $u(e,t){return e==="tool"?"tool_call":e==="tool_result"&&typeof t=="string"&&t.startsWith("[error]")?"error":e}function Qw(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Jw(e){return e.split(":").slice(2).join(":")||e}function Yw(e,t){return t?[e.content,e.agentId,e.sessionKey,e.sessionId,e.toolName,e.toolCallId].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Xw(e,t){return`${e.sessionId}:${e.timestamp}:${t}`}const $l=300;function Zw(e,t){const n=$u(e.type,e.content);return t[n]??!0}function ek(e){const t=e.filterText.trim().toLowerCase(),n=e.entries.filter(i=>!Zw(i,e.typeFilters)||e.agents.length>0&&!(e.agentFilters[i.agentId]??!0)?!1:Yw(i,t));return c`
4150
+ `}const Vw=["user","assistant","tool_call","tool_result","thinking","error"],$l={user:"User",assistant:"Assistant",tool:"Tool",tool_call:"Call",tool_result:"Result",thinking:"Thinking",error:"Error",system:"System"};function $u(e,t){return e==="tool"?"tool_call":e==="tool_result"&&typeof t=="string"&&t.startsWith("[error]")?"error":e}function Qw(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Jw(e){return e.split(":").slice(2).join(":")||e}function Yw(e,t){return t?[e.content,e.agentId,e.sessionKey,e.sessionId,e.toolName,e.toolCallId].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Xw(e,t){return`${e.sessionId}:${e.timestamp}:${t}`}const Sl=300;function Zw(e,t){const n=$u(e.type,e.content);return t[n]??!0}function ek(e){const t=e.filterText.trim().toLowerCase(),n=e.entries.filter(i=>!Zw(i,e.typeFilters)||e.agents.length>0&&!(e.agentFilters[i.agentId]??!0)?!1:Yw(i,t));return c`
4151
4151
  <div>
4152
4152
  <button class="chips-toggle" style="margin-top: 10px;" @click=${e.onToggleChips}>
4153
4153
  <span class="chips-toggle-icon ${e.chipsExpanded?"expanded":""}">${I.chevronDown}</span>
@@ -4162,7 +4162,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4162
4162
  .checked=${e.typeFilters[i]}
4163
4163
  @change=${s=>e.onTypeToggle(i,s.target.checked)}
4164
4164
  />
4165
- <span>${xl[i]}</span>
4165
+ <span>${$l[i]}</span>
4166
4166
  </label>
4167
4167
  `)}
4168
4168
  ${e.agents.map(i=>c`
@@ -4189,11 +4189,11 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4189
4189
  ${e.error?c`<div class="callout danger" style="margin-top: 10px;">${e.error}</div>`:w}
4190
4190
 
4191
4191
  <div class="log-stream" style="margin-top: 10px;" @scroll=${e.onScroll}>
4192
- ${n.length===0?c`<div class="muted" style="padding: 12px;">No session log entries.</div>`:n.map((i,s)=>{const o=$u(i.type,i.content),a=Xw(i,s),r=e.expandedIds.has(a),l=i.content.length>$l,d=r||!l?i.content:i.content.slice(0,$l)+"…";return c`
4192
+ ${n.length===0?c`<div class="muted" style="padding: 12px;">No session log entries.</div>`:n.map((i,s)=>{const o=$u(i.type,i.content),a=Xw(i,s),r=e.expandedIds.has(a),l=i.content.length>Sl,d=r||!l?i.content:i.content.slice(0,Sl)+"…";return c`
4193
4193
  <div class="log-row session-entry ${o}">
4194
4194
  <div class="log-row-header">
4195
4195
  <span class="log-time mono">${Qw(i.timestamp)}</span>
4196
- <span class="session-log-type ${o}">${xl[o]}</span>
4196
+ <span class="session-log-type ${o}">${$l[o]}</span>
4197
4197
  <span class="log-subsystem mono">${i.agentId}</span>
4198
4198
  <span class="session-label mono">${Jw(i.sessionKey)}</span>
4199
4199
  ${i.toolName?c`<span class="session-tool mono">${i.toolName}</span>`:w}
@@ -4209,7 +4209,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4209
4209
  `})}
4210
4210
  </div>
4211
4211
  </div>
4212
- `}const zo=["trace","debug","info","warn","error","fatal"];function tk(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function Su(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function nk(e){const t=!e.isAdmin||e.logsSubTab==="session";return c`
4212
+ `}const qo=["trace","debug","info","warn","error","fatal"];function tk(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function Su(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function nk(e){const t=!e.isAdmin||e.logsSubTab==="session";return c`
4213
4213
  <section class="card">
4214
4214
  <div class="logs-toolbar">
4215
4215
  <div class="sp-tabs" style="margin: 0;">
@@ -4260,7 +4260,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4260
4260
  <button
4261
4261
  class="btn btn-sm"
4262
4262
  ?disabled=${e.entries.length===0}
4263
- @click=${()=>{const n=e.filterText.trim().toLowerCase(),i=zo.some(a=>!e.levelFilters[a]),s=e.entries.filter(a=>a.level&&!e.levelFilters[a.level]?!1:Su(a,n)),o=n||i?"filtered":"visible";e.onExport(s.map(a=>a.raw),o)}}
4263
+ @click=${()=>{const n=e.filterText.trim().toLowerCase(),i=qo.some(a=>!e.levelFilters[a]),s=e.entries.filter(a=>a.level&&!e.levelFilters[a.level]?!1:Su(a,n)),o=n||i?"filtered":"visible";e.onExport(s.map(a=>a.raw),o)}}
4264
4264
  >
4265
4265
  Export
4266
4266
  </button>
@@ -4270,7 +4270,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4270
4270
 
4271
4271
  ${t?ek(e.sessionLogsProps):ik(e)}
4272
4272
  </section>
4273
- `}function ik(e){const t=e.filterText.trim().toLowerCase();zo.some(l=>!e.levelFilters[l]);const n=e.entries.filter(l=>l.level&&!e.levelFilters[l.level]?!1:Su(l,t)),i=e.availableDates,s=e.selectedDate??(i.length>0?i[0]:null),o=s?i.indexOf(s):0,a=o>0||e.selectedDate!=null,r=o>=0&&o<i.length-1;return c`
4273
+ `}function ik(e){const t=e.filterText.trim().toLowerCase();qo.some(l=>!e.levelFilters[l]);const n=e.entries.filter(l=>l.level&&!e.levelFilters[l.level]?!1:Su(l,t)),i=e.availableDates,s=e.selectedDate??(i.length>0?i[0]:null),o=s?i.indexOf(s):0,a=o>0||e.selectedDate!=null,r=o>=0&&o<i.length-1;return c`
4274
4274
  ${i.length>1?c`
4275
4275
  <div class="logs-date-nav">
4276
4276
  <button class="btn btn-sm" ?disabled=${!r}
@@ -4292,7 +4292,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4292
4292
  </button>
4293
4293
  ${e.chipsExpanded?c`
4294
4294
  <div class="chip-row" style="margin-top: 6px; align-items: center;">
4295
- ${zo.map(l=>c`
4295
+ ${qo.map(l=>c`
4296
4296
  <label class="chip log-chip ${l}">
4297
4297
  <input
4298
4298
  type="checkbox"
@@ -4443,7 +4443,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4443
4443
  ${e.busy?"Saving…":"Save"}
4444
4444
  </button>
4445
4445
  </div>
4446
- `}const fk=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"opening-hours",label:"Opening Hours"},{id:"logs",label:"Logs"}];function gk(e){switch(e.activeTab){case"cron":return kl(e.cronProps);case"skills":return Ww(e.skillsProps);case"opening-hours":return rk(e.openingHoursProps);case"logs":return nk(e.logsProps);default:return kl(e.cronProps)}}function mk(e){return e.connected?c`
4446
+ `}const fk=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"opening-hours",label:"Opening Hours"},{id:"logs",label:"Logs"}];function gk(e){switch(e.activeTab){case"cron":return xl(e.cronProps);case"skills":return Ww(e.skillsProps);case"opening-hours":return rk(e.openingHoursProps);case"logs":return nk(e.logsProps);default:return xl(e.cronProps)}}function mk(e){return e.connected?c`
4447
4447
  <div class="setup-container">
4448
4448
  ${Rt("Advanced",e.wsProps)}
4449
4449
  <div class="setup-card sp-card-advanced" style="text-align: left;">
@@ -4467,7 +4467,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4467
4467
  <p>Connecting to gateway...</p>
4468
4468
  </div>
4469
4469
  </div>
4470
- `}function Sl(e){if(!e.show)return w;const t=Xe(),n=e.isFirstTime,i=e.changePinMode===!0&&!n,s=e.changePinBusy===!0;let o=e.accounts.length>0?e.accounts[0].id:"";const a=v=>{var S;o=v.target.value;const $=(S=v.target.closest(".login-card"))==null?void 0:S.querySelector(".login-change-pin");$&&($.style.display=o==="__master__"?"":"none")},r=v=>$=>{const S=$.target;S.value=S.value.replace(/\D/g,"").slice(0,6),v(S.value)},l=v=>{const $=v.currentTarget,S=$.closest(".login-pin-wrapper"),M=S==null?void 0:S.querySelector("input");if(!M)return;const y=M.type==="text";M.type=y?"password":"text",$.classList.toggle("active",!y)},d=!n&&e.accounts.length>1?c`
4470
+ `}function Al(e){if(!e.show)return w;const t=Xe(),n=e.isFirstTime,i=e.changePinMode===!0&&!n,s=e.changePinBusy===!0;let o=e.accounts.length>0?e.accounts[0].id:"";const a=v=>{var S;o=v.target.value;const $=(S=v.target.closest(".login-card"))==null?void 0:S.querySelector(".login-change-pin");$&&($.style.display=o==="__master__"?"":"none")},r=v=>$=>{const S=$.target;S.value=S.value.replace(/\D/g,"").slice(0,6),v(S.value)},l=v=>{const $=v.currentTarget,S=$.closest(".login-pin-wrapper"),M=S==null?void 0:S.querySelector("input");if(!M)return;const y=M.type==="text";M.type=y?"password":"text",$.classList.toggle("active",!y)},d=!n&&e.accounts.length>1?c`
4471
4471
  <select
4472
4472
  class="login-account-select"
4473
4473
  @change=${a}
@@ -4637,7 +4637,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4637
4637
  ${yu(t)}
4638
4638
  </div>
4639
4639
  </div>
4640
- `}async function vk(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 bk(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 wk(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 kk(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:bk,loadWorkspaces:Vn,removeWorkspace:wk,renameWorkspace:kk},Symbol.toStringTag,{value:"Module"})),Au={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"},Al=Au,Ko={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Au));new Set(Object.values(Ko));function xk(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 $k=4008;class Sk{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 u;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 cf();const p=(u=pf({deviceId:o.deviceId,role:t}))==null?void 0:u.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 d;if(s&&o){const p=Date.now(),v=this.connectNonce??void 0,$=xk({deviceId:o.deviceId,clientId:this.opts.clientName??Al.CONTROL_UI,clientMode:this.opts.mode??Ko.WEBCHAT,role:t,scopes:n,signedAtMs:p,token:r??null,nonce:v}),S=await df(o.privateKey,$);d={id:o.deviceId,publicKey:o.publicKey,signature:S,signedAt:p,nonce:v}}const h={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Al.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Ko.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:d,caps:[],auth:l,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",h).then(p=>{var v,$,S;(v=p==null?void 0:p.auth)!=null&&v.deviceToken&&o&&hf({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&&ff({deviceId:o.deviceId,role:t}),(p=this.ws)==null||p.close($k,"connect failed")})}handleMessage(t){var s,o,a,r,l,d;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 u=typeof h.seq=="number"?h.seq:null;u!==null&&(this.lastSeq!==null&&u>this.lastSeq+1&&((o=(s=this.opts).onGap)==null||o.call(s,{expected:this.lastSeq+1,received:u})),this.lastSeq=u);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,u=this.pending.get(h.id);if(!u)return;if(this.pending.delete(h.id),h.ok)u.resolve(h.payload);else{const p=new Error(((l=h.error)==null?void 0:l.message)??"request failed");p.payload=h.payload,p.details=(d=h.error)==null?void 0:d.details,u.reject(p)}return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=as(),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 Ho(e){return typeof e=="object"&&e!==null}function Ak(e){if(!Ho(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Ho(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 Ck(e){if(!Ho(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 Cu(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Ek(e,t){const n=Cu(e).filter(i=>i.id!==t.id);return n.push(t),n}function Cl(e,t){return Cu(e).filter(n=>n.id!==t)}class Tk{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 uo=null;function Bn(){return uo||(uo=new Tk),uo}function Oa(e){return e instanceof Error?e.message:String(e)}async function _k(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=Oa(t)}finally{e.browserLoading=!1}}async function Mk(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=Oa(t)}finally{e.browserLoading=!1}}}async function po(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 ho(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 Pk(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=Oa(t)}}function Ik(e){e.browserInputMode=!e.browserInputMode}function Rk(e){e.browserFullscreen=!e.browserFullscreen,Bn().detach()}function Lk(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,Bn().updateFrame(t.data,t.metadata)}function Dk(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function Bk(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function qo(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=bo(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 El(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function Nk(e,t){await e.request("apikeys.remove",{provider:t})}async function Ok(e,t,n){await e.request("apikeys.disable",{provider:t,disabled:n})}const ts="taskmaster_update_pending";async function Eu(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 Fk(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(ts,String(Date.now())),localStorage.removeItem(Fa)}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 Uk(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 d=e.updateProgressSteps.find(h=>h.index===r);d?(d.status="running",d.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,d=t.ok,h=t.durationMs,u=e.updateProgressSteps.find(v=>v.index===r);u?(u.status=d?"done":"failed",u.durationMs=h):e.updateProgressSteps=[...e.updateProgressSteps,{name:a,index:r,total:l,status:d?"done":"failed",durationMs:h}];const p=!d&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=d?`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 Wk(e){var n,i,s,o;if(!e.client||!e.connected)return;const t=Kk();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||Hk(a.result.ts))return;e.updateLastResult=a.result;const d=(n=a.result.after)==null?void 0:n.version;if(a.result.status==="ok"&&d&&(e.currentVersion=d),e.updateAvailable=!1,a.result.status==="ok"){const h=(i=a.result.before)==null?void 0:i.version,u=d??a.result.currentVersion;e.updateMessage=h?`Updated: v${h} → v${u}`:`Updated to v${u}`}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 Fa="taskmaster_update_dismissed";function zk(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Fa,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function Kk(){try{const e=localStorage.getItem(ts);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(ts),!1):!0:!1}catch{return!1}}function Nn(){try{localStorage.removeItem(ts)}catch{}}function Hk(e){try{const t=localStorage.getItem(Fa);return t?Number(t)>=e:!1}catch{return!1}}const Tl="notification-banner";function qk(e){const t=document.getElementById(Tl);if(!e){t==null||t.remove();return}t&&t.remove();const n=document.createElement("div");n.id=Tl,Object.assign(n.style,{background:"rgba(255, 180, 50, 0.15)",border:"1px solid rgba(255, 180, 50, 0.3)",borderRadius:"8px",padding:"12px 16px",margin:"0 0 16px 0",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"12px",color:"rgba(255, 255, 255, 0.9)",fontSize:"14px"});const i=document.createElement("span");i.textContent=e.message,n.appendChild(i);const s=document.createElement("button");s.setAttribute("aria-label","Dismiss"),s.textContent="×",Object.assign(s.style,{background:"none",border:"none",color:"rgba(255, 255, 255, 0.7)",cursor:"pointer",fontSize:"18px",padding:"0 4px"}),s.addEventListener("click",()=>n.remove()),n.appendChild(s),(document.querySelector("main")??document.body).prepend(n)}function fo(e,t){var r,l,d;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=(d=t.defaultAgentId)==null?void 0:d.trim();return n==="main"||n===s||o&&(n===`agent:${o}:main`||n===`agent:${o}:${s}`)?i:n}function jk(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=fo(e.sessionKey,t),i=fo(e.settings.sessionKey,t),s=fo(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&&at(e,a)}function Oe(e){var o;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;let t=null;const n=!!e.publicChat,i=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.contactsPage||e.advancedPage,s=n?"public-chat":i?"setup-ui":"taskmaster-control-ui";(o=e.client)==null||o.stop(),e.client=new Sk({url:e.settings.gatewayUrl,token:n?void 0:e.settings.token.trim()?e.settings.token:void 0,password:n?void 0:e.password.trim()?e.password:void 0,clientName:s,mode:"webchat",role:n?"public":void 0,scopes:n?[]:void 0,onHello:a=>{var l,d;const r=((l=a.server)==null?void 0:l.version)??null;if(t!==null&&r!==null&&r!==t){window.location.reload();return}if(t===null&&(t=r),e.connected=!0,e.lastError=null,e.hello=a,n){_l(e,a),qo(e),(((d=e.publicChatConfig)==null?void 0:d.auth)??"anonymous")==="anonymous"&&e0(e);return}Ki()&&(wa(),e.uninstallDone=!1),_l(e,a),e.handleAccessCheck(),Wk(e).then(()=>{Eu(e)}),qo(e),vk(e),(e.chatPage||e.setup)&&Qk(e),da(e,{quiet:!0}),ca(e,{quiet:!0}),Vn(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&We(e),e.setup&&(Jk(e),Yk(e),Xk(e),Zk(e)),Wi(e)},onClose:({code:a,reason:r})=>{e.connected=!1,a!==1012&&(e.lastError=`disconnected (${a}): ${r||"no reason"}`)},onEvent:a=>Gk(e,a),onGap:({expected:a,received:r})=>{console.warn(`[gateway] event gap: expected seq ${a}, got ${r}`),Wi(e)}}),e.client.start()}function Gk(e,t){try{Vk(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function Vk(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;lh(e,t.payload);return}if(t.event==="chat"){const i=t.payload;i!=null&&i.sessionKey&&cd(e,i.sessionKey);const s=ac(e,i);if((s==="final"||s==="error"||s==="aborted")&&(Zo(e),og(e)),s==="final"){const o=e,a=Math.max((((n=o.chatMessages)==null?void 0:n.length)??0)+10,nn);Jt(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&&$h(e,i),e.tab==="cron"&&e.loadCron()}if((t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&ca(e,{quiet:!0}),t.event==="exec.approval.requested"){const i=Ak(t.payload);if(i){e.execApprovalQueue=Ek(e.execApprovalQueue,i),e.execApprovalError=null;const s=Math.max(0,i.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=Cl(e.execApprovalQueue,i.id)},s)}return}if(t.event==="browser.screencast.frame"){Lk(e,t.payload);return}if(t.event==="browser.handoff"){Dk(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){Bk(e);return}if(t.event==="exec.approval.resolved"){const i=Ck(t.payload);i&&(e.execApprovalQueue=Cl(e.execApprovalQueue,i.id));return}if(t.event==="update.progress"){Uk(e,t.payload);return}if(t.event==="notification"){const i=t.payload;(i==null?void 0:i.category)==="model-fallback"&&qk(i);return}}function _l(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&&jk(e,n.sessionDefaults)}async function Qk(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 Jk(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await _i(e.client)}catch{}}async function Yk(e){if(!(!e.client||!e.connected))try{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null}catch{}}async function Xk(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 Zk(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 Ml="taskmaster_public_id";function Tu(e=30){var s;const t=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(`${Ml}=`));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=`${Ml}=${n}; path=/; expires=${i}; SameSite=Lax`,n}async function e0(e){var n,i,s;if(!e.client||!e.connected)return;const t=Tu((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=zn(r,a.sessionKey),Jt(e)}}catch(o){console.error("[public-chat] failed to resolve anonymous session:",o),e.lastError="Failed to start chat session"}}let pe=!1,ie=null,Zt="",en="",tn="",ms="",cn="phone",On="";function _u(e){return e.replace(/[\s\-()]/g,"")}function it(){pe=!1,ie=null,Zt="",en="",tn="",ms="",cn="phone",On=""}async function t0(e){if(!e.client||!e.connected)return;const t=Tu(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 Pl(e){if(!e.client||pe)return;const t=_u(Zt);if(!t){ie="Please enter your phone number",e.requestUpdate();return}pe=!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?(ms=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{pe=!1,e.requestUpdate()}}async function Il(e){if(!e.client||pe)return;const t=en.trim().toLowerCase();if(!t||!t.includes("@")){ie="Please enter a valid email address",e.requestUpdate();return}pe=!0,ie=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{identifier:t,accountId:e.accountId});n!=null&&n.ok?(ms=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{pe=!1,e.requestUpdate()}}async function Rl(e,t){if(!(!e.client||pe)){if(!t.trim()){ie="Please enter the verification code",e.requestUpdate();return}pe=!0,ie=null,e.requestUpdate();try{const n=cn==="email"?en.trim().toLowerCase():_u(Zt),i=await e.client.request("public.otp.verify",{identifier:n,code:t.trim(),accountId:e.accountId});i!=null&&i.ok&&i.sessionKey?(it(),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{pe=!1,e.requestUpdate()}}}function Ve(e){return w}function xi(e){return c`
4640
+ `}async function vk(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 bk(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 wk(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 kk(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:bk,loadWorkspaces:Vn,removeWorkspace:wk,renameWorkspace:kk},Symbol.toStringTag,{value:"Module"})),Au={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"},Cl=Au,jo={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Au));new Set(Object.values(jo));function xk(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 $k=4008;class Sk{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 u;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 cf();const p=(u=pf({deviceId:o.deviceId,role:t}))==null?void 0:u.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 d;if(s&&o){const p=Date.now(),v=this.connectNonce??void 0,$=xk({deviceId:o.deviceId,clientId:this.opts.clientName??Cl.CONTROL_UI,clientMode:this.opts.mode??jo.WEBCHAT,role:t,scopes:n,signedAtMs:p,token:r??null,nonce:v}),S=await df(o.privateKey,$);d={id:o.deviceId,publicKey:o.publicKey,signature:S,signedAt:p,nonce:v}}const h={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Cl.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??jo.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:d,caps:[],auth:l,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",h).then(p=>{var v,$,S;(v=p==null?void 0:p.auth)!=null&&v.deviceToken&&o&&hf({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&&ff({deviceId:o.deviceId,role:t}),(p=this.ws)==null||p.close($k,"connect failed")})}handleMessage(t){var s,o,a,r,l,d;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 u=typeof h.seq=="number"?h.seq:null;u!==null&&(this.lastSeq!==null&&u>this.lastSeq+1&&((o=(s=this.opts).onGap)==null||o.call(s,{expected:this.lastSeq+1,received:u})),this.lastSeq=u);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,u=this.pending.get(h.id);if(!u)return;if(this.pending.delete(h.id),h.ok)u.resolve(h.payload);else{const p=new Error(((l=h.error)==null?void 0:l.message)??"request failed");p.payload=h.payload,p.details=(d=h.error)==null?void 0:d.details,u.reject(p)}return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=ls(),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 Go(e){return typeof e=="object"&&e!==null}function Ak(e){if(!Go(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Go(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 Ck(e){if(!Go(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 Cu(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Ek(e,t){const n=Cu(e).filter(i=>i.id!==t.id);return n.push(t),n}function El(e,t){return Cu(e).filter(n=>n.id!==t)}class Tk{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 ho=null;function Bn(){return ho||(ho=new Tk),ho}function Fa(e){return e instanceof Error?e.message:String(e)}async function _k(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=Fa(t)}finally{e.browserLoading=!1}}async function Mk(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=Fa(t)}finally{e.browserLoading=!1}}}async function fo(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 go(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 Pk(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=Fa(t)}}function Ik(e){e.browserInputMode=!e.browserInputMode}function Rk(e){e.browserFullscreen=!e.browserFullscreen,Bn().detach()}function Lk(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,Bn().updateFrame(t.data,t.metadata)}function Dk(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function Bk(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function Vo(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=ko(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 Tl(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function Nk(e,t){await e.request("apikeys.remove",{provider:t})}async function Ok(e,t,n){await e.request("apikeys.disable",{provider:t,disabled:n})}const is="taskmaster_update_pending";async function Eu(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 Fk(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(is,String(Date.now())),localStorage.removeItem(Ua)}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 Uk(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 d=e.updateProgressSteps.find(h=>h.index===r);d?(d.status="running",d.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,d=t.ok,h=t.durationMs,u=e.updateProgressSteps.find(v=>v.index===r);u?(u.status=d?"done":"failed",u.durationMs=h):e.updateProgressSteps=[...e.updateProgressSteps,{name:a,index:r,total:l,status:d?"done":"failed",durationMs:h}];const p=!d&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=d?`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 Wk(e){var n,i,s,o;if(!e.client||!e.connected)return;const t=Kk();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||Hk(a.result.ts))return;e.updateLastResult=a.result;const d=(n=a.result.after)==null?void 0:n.version;if(a.result.status==="ok"&&d&&(e.currentVersion=d),e.updateAvailable=!1,a.result.status==="ok"){const h=(i=a.result.before)==null?void 0:i.version,u=d??a.result.currentVersion;e.updateMessage=h?`Updated: v${h} → v${u}`:`Updated to v${u}`}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 Ua="taskmaster_update_dismissed";function zk(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Ua,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function Kk(){try{const e=localStorage.getItem(is);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(is),!1):!0:!1}catch{return!1}}function Nn(){try{localStorage.removeItem(is)}catch{}}function Hk(e){try{const t=localStorage.getItem(Ua);return t?Number(t)>=e:!1}catch{return!1}}const _l="notification-banner";function qk(e){const t=document.getElementById(_l);if(!e){t==null||t.remove();return}t&&t.remove();const n=document.createElement("div");n.id=_l,Object.assign(n.style,{background:"rgba(255, 180, 50, 0.15)",border:"1px solid rgba(255, 180, 50, 0.3)",borderRadius:"8px",padding:"12px 16px",margin:"0 0 16px 0",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"12px",color:"rgba(255, 255, 255, 0.9)",fontSize:"14px"});const i=document.createElement("span");i.textContent=e.message,n.appendChild(i);const s=document.createElement("button");s.setAttribute("aria-label","Dismiss"),s.textContent="×",Object.assign(s.style,{background:"none",border:"none",color:"rgba(255, 255, 255, 0.7)",cursor:"pointer",fontSize:"18px",padding:"0 4px"}),s.addEventListener("click",()=>n.remove()),n.appendChild(s),(document.querySelector("main")??document.body).prepend(n)}function mo(e,t){var r,l,d;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=(d=t.defaultAgentId)==null?void 0:d.trim();return n==="main"||n===s||o&&(n===`agent:${o}:main`||n===`agent:${o}:${s}`)?i:n}function jk(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=mo(e.sessionKey,t),i=mo(e.settings.sessionKey,t),s=mo(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&&at(e,a)}function Oe(e){var o;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;let t=null;const n=!!e.publicChat,i=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.contactsPage||e.advancedPage,s=n?"public-chat":i?"setup-ui":"taskmaster-control-ui";(o=e.client)==null||o.stop(),e.client=new Sk({url:e.settings.gatewayUrl,token:n?void 0:e.settings.token.trim()?e.settings.token:void 0,password:n?void 0:e.password.trim()?e.password:void 0,clientName:s,mode:"webchat",role:n?"public":void 0,scopes:n?[]:void 0,onHello:a=>{var l,d;const r=((l=a.server)==null?void 0:l.version)??null;if(t!==null&&r!==null&&r!==t){window.location.reload();return}if(t===null&&(t=r),e.connected=!0,e.lastError=null,e.hello=a,n){Ml(e,a),Vo(e),(((d=e.publicChatConfig)==null?void 0:d.auth)??"anonymous")==="anonymous"&&e0(e);return}qi()&&(ka(),e.uninstallDone=!1),Ml(e,a),e.handleAccessCheck(),Wk(e).then(()=>{Eu(e)}),Vo(e),vk(e),(e.chatPage||e.setup)&&Qk(e),ha(e,{quiet:!0}),pa(e,{quiet:!0}),Vn(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&We(e),e.setup&&(Jk(e),Yk(e),Xk(e),Zk(e)),Ki(e)},onClose:({code:a,reason:r})=>{e.connected=!1,a!==1012&&(e.lastError=`disconnected (${a}): ${r||"no reason"}`)},onEvent:a=>Gk(e,a),onGap:({expected:a,received:r})=>{console.warn(`[gateway] event gap: expected seq ${a}, got ${r}`),Ki(e)}}),e.client.start()}function Gk(e,t){try{Vk(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function Vk(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;lh(e,t.payload);return}if(t.event==="chat"){const i=t.payload;i!=null&&i.sessionKey&&cd(e,i.sessionKey);const s=rc(e,i);if((s==="final"||s==="error"||s==="aborted")&&(na(e),og(e)),s==="final"){const o=e,a=Math.max((((n=o.chatMessages)==null?void 0:n.length)??0)+10,nn);Jt(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&&$h(e,i),e.tab==="cron"&&e.loadCron()}if((t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&pa(e,{quiet:!0}),t.event==="exec.approval.requested"){const i=Ak(t.payload);if(i){e.execApprovalQueue=Ek(e.execApprovalQueue,i),e.execApprovalError=null;const s=Math.max(0,i.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=El(e.execApprovalQueue,i.id)},s)}return}if(t.event==="browser.screencast.frame"){Lk(e,t.payload);return}if(t.event==="browser.handoff"){Dk(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){Bk(e);return}if(t.event==="exec.approval.resolved"){const i=Ck(t.payload);i&&(e.execApprovalQueue=El(e.execApprovalQueue,i.id));return}if(t.event==="update.progress"){Uk(e,t.payload);return}if(t.event==="notification"){const i=t.payload;(i==null?void 0:i.category)==="model-fallback"&&qk(i);return}}function Ml(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&&jk(e,n.sessionDefaults)}async function Qk(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 Jk(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await _i(e.client)}catch{}}async function Yk(e){if(!(!e.client||!e.connected))try{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null}catch{}}async function Xk(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 Zk(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 Pl="taskmaster_public_id";function Tu(e=30){var s;const t=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(`${Pl}=`));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=`${Pl}=${n}; path=/; expires=${i}; SameSite=Lax`,n}async function e0(e){var n,i,s;if(!e.client||!e.connected)return;const t=Tu((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=zn(r,a.sessionKey),Jt(e)}}catch(o){console.error("[public-chat] failed to resolve anonymous session:",o),e.lastError="Failed to start chat session"}}let pe=!1,ie=null,Zt="",en="",tn="",vs="",cn="phone",On="";function _u(e){return e.replace(/[\s\-()]/g,"")}function it(){pe=!1,ie=null,Zt="",en="",tn="",vs="",cn="phone",On=""}async function t0(e){if(!e.client||!e.connected)return;const t=Tu(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 Il(e){if(!e.client||pe)return;const t=_u(Zt);if(!t){ie="Please enter your phone number",e.requestUpdate();return}pe=!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?(vs=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{pe=!1,e.requestUpdate()}}async function Rl(e){if(!e.client||pe)return;const t=en.trim().toLowerCase();if(!t||!t.includes("@")){ie="Please enter a valid email address",e.requestUpdate();return}pe=!0,ie=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{identifier:t,accountId:e.accountId});n!=null&&n.ok?(vs=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{pe=!1,e.requestUpdate()}}async function Ll(e,t){if(!(!e.client||pe)){if(!t.trim()){ie="Please enter the verification code",e.requestUpdate();return}pe=!0,ie=null,e.requestUpdate();try{const n=cn==="email"?en.trim().toLowerCase():_u(Zt),i=await e.client.request("public.otp.verify",{identifier:n,code:t.trim(),accountId:e.accountId});i!=null&&i.ok&&i.sessionKey?(it(),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{pe=!1,e.requestUpdate()}}}function Ve(e){return w}function xi(e){return c`
4641
4641
  <div class="public-auth__form">
4642
4642
  <label class="field public-auth__field">
4643
4643
  <span>Your name (optional)</span>
@@ -4654,7 +4654,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4654
4654
  type="tel"
4655
4655
  .value=${Zt}
4656
4656
  @input=${t=>{Zt=t.target.value}}
4657
- @keydown=${t=>{t.key==="Enter"&&(t.preventDefault(),Pl(e))}}
4657
+ @keydown=${t=>{t.key==="Enter"&&(t.preventDefault(),Il(e))}}
4658
4658
  placeholder="+44 7123 456789"
4659
4659
  required
4660
4660
  />
@@ -4663,12 +4663,12 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4663
4663
  <button
4664
4664
  class="btn primary public-auth__btn"
4665
4665
  ?disabled=${pe}
4666
- @click=${()=>{Pl(e)}}
4666
+ @click=${()=>{Il(e)}}
4667
4667
  >
4668
4668
  ${pe?"Sending...":"Send verification code"}
4669
4669
  </button>
4670
4670
  </div>
4671
- `}function go(e){return c`
4671
+ `}function yo(e){return c`
4672
4672
  <div class="public-auth__form">
4673
4673
  <label class="field public-auth__field">
4674
4674
  <span>Your name (optional)</span>
@@ -4685,7 +4685,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4685
4685
  type="email"
4686
4686
  .value=${en}
4687
4687
  @input=${t=>{en=t.target.value}}
4688
- @keydown=${t=>{t.key==="Enter"&&(t.preventDefault(),Il(e))}}
4688
+ @keydown=${t=>{t.key==="Enter"&&(t.preventDefault(),Rl(e))}}
4689
4689
  placeholder="you@example.com"
4690
4690
  required
4691
4691
  />
@@ -4694,12 +4694,12 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4694
4694
  <button
4695
4695
  class="btn primary public-auth__btn"
4696
4696
  ?disabled=${pe}
4697
- @click=${()=>{Il(e)}}
4697
+ @click=${()=>{Rl(e)}}
4698
4698
  >
4699
4699
  ${pe?"Sending...":"Send verification code"}
4700
4700
  </button>
4701
4701
  </div>
4702
- `}function Ll(e){let t="";const n=cn==="email",i=n?"email":ms==="sms"?"SMS":"WhatsApp",s=n?en:Zt,o=n?"email":"phone";return c`
4702
+ `}function Dl(e){let t="";const n=cn==="email",i=n?"email":vs==="sms"?"SMS":"WhatsApp",s=n?en:Zt,o=n?"email":"phone";return c`
4703
4703
  <div class="public-auth__form">
4704
4704
  <p class="public-auth__hint">
4705
4705
  We sent a verification code to <strong>${s}</strong> via ${i}.
@@ -4711,7 +4711,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4711
4711
  inputmode="numeric"
4712
4712
  maxlength="6"
4713
4713
  @input=${a=>{t=a.target.value}}
4714
- @keydown=${a=>{a.key==="Enter"&&(a.preventDefault(),Rl(e,t))}}
4714
+ @keydown=${a=>{a.key==="Enter"&&(a.preventDefault(),Ll(e,t))}}
4715
4715
  placeholder="123456"
4716
4716
  required
4717
4717
  />
@@ -4720,7 +4720,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4720
4720
  <button
4721
4721
  class="btn primary public-auth__btn"
4722
4722
  ?disabled=${pe}
4723
- @click=${()=>{Rl(e,t)}}
4723
+ @click=${()=>{Ll(e,t)}}
4724
4724
  >
4725
4725
  ${pe?"Verifying...":"Verify"}
4726
4726
  </button>
@@ -4751,7 +4751,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4751
4751
  <div class="public-auth">
4752
4752
  ${Ve()}
4753
4753
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4754
- ${Ll(e)}
4754
+ ${Dl(e)}
4755
4755
  </div>
4756
4756
  </div>
4757
4757
  `:n==="email"?c`
@@ -4760,7 +4760,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4760
4760
  ${Ve()}
4761
4761
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4762
4762
  <p class="public-auth__subtitle">Verify your email address to get started.</p>
4763
- ${go(e)}
4763
+ ${yo(e)}
4764
4764
  ${u?c`
4765
4765
  <button class="btn public-auth__btn public-auth__btn--link"
4766
4766
  @click=${()=>{it(),e.onAuthStepChange("phone")}}>
@@ -4803,7 +4803,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4803
4803
  ${Ve()}
4804
4804
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4805
4805
  <p class="public-auth__subtitle">Verify your email address to get started.</p>
4806
- ${go(e)}
4806
+ ${yo(e)}
4807
4807
  </div>
4808
4808
  </div>
4809
4809
  `:c`
@@ -4821,7 +4821,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4821
4821
  ${Ve()}
4822
4822
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4823
4823
  <p class="public-auth__subtitle">${p}</p>
4824
- ${n==="otp"?Ll(e):n==="email"?go(e):xi(e)}
4824
+ ${n==="otp"?Dl(e):n==="email"?yo(e):xi(e)}
4825
4825
  ${n!=="otp"?c`
4826
4826
  <button class="btn public-auth__btn public-auth__btn--link"
4827
4827
  @click=${()=>{it(),e.onAuthStepChange("idle")}}>
@@ -4875,7 +4875,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4875
4875
  `:w}
4876
4876
  </div>
4877
4877
  </div>
4878
- `}function Ua(){return{enabled:!1,publicAgentEnabled:!0,days:{monday:{start:"09:00",end:"17:00",closed:!1},tuesday:{start:"09:00",end:"17:00",closed:!1},wednesday:{start:"09:00",end:"17:00",closed:!1},thursday:{start:"09:00",end:"17:00",closed:!1},friday:{start:"09:00",end:"17:00",closed:!1},saturday:{start:"09:00",end:"17:00",closed:!0},sunday:{start:"09:00",end:"17:00",closed:!0}},closedDates:[]}}const Mu=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];async function Wa(e){if(!(!e.client||!e.connected)&&!e.openingHoursLoading){e.openingHoursLoading=!0,e.openingHoursError=null;try{const t=await e.client.request("business.openingHours.get",{});if(t.openingHours){const n=t.openingHours,i={};for(const s of Mu){const o=n.schedule[s];o==null?i[s]={start:"09:00",end:"17:00",closed:!0}:i[s]={start:o.start,end:o.end,closed:!1}}e.openingHoursForm={enabled:n.enabled,publicAgentEnabled:t.publicAgentEnabled,days:i,closedDates:[...n.closedDates??[]].sort()}}else{const n=Ua();n.publicAgentEnabled=t.publicAgentEnabled,e.openingHoursForm=n}}catch(t){e.openingHoursError=String(t)}finally{e.openingHoursLoading=!1}}}async function Pu(e){if(!(!e.client||!e.connected||e.openingHoursBusy)){e.openingHoursBusy=!0,e.openingHoursError=null;try{const t=e.openingHoursForm,n={};for(const a of Mu){const r=t.days[a];n[a]=r!=null&&r.closed?null:{start:r.start,end:r.end}}const i=Intl.DateTimeFormat().resolvedOptions().timeZone,s={enabled:t.enabled,timezone:i,schedule:n,closedDates:t.closedDates.length>0?[...t.closedDates].sort():void 0},o=await e.client.request("config.get",{});await e.client.request("config.patch",{raw:JSON.stringify({business:{openingHours:s,publicAgentEnabled:t.publicAgentEnabled}}),baseHash:o.hash,note:"Opening hours updated"}),await Wa(e)}catch(t){e.openingHoursError=String(t)}finally{e.openingHoursBusy=!1}}}const i0=Object.freeze(Object.defineProperty({__proto__:null,defaultOpeningHoursForm:Ua,loadOpeningHours:Wa,saveOpeningHours:Pu},Symbol.toStringTag,{value:"Module"}));function s0(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 d=l.id??"";d&&i.push({phone:d,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 Iu(e,t,n="admin",i){const s=d=>d===n||d==="management",o=new Map,a=new Map;for(const d of e){if(!d||typeof d!="object"||!s(d.agentId))continue;const h=d.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&&(d.meta&&o.set(v,d.meta),h.accountId&&a.set(v,h.accountId))}const r=e.filter(d=>{if(!d||typeof d!="object"||!s(d.agentId))return!0;const h=d.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(d=>{const h=i??a.get(d.phone),u={channel:"whatsapp",peer:{kind:"dm",id:d.phone}};h&&(u.accountId=h);const p={agentId:n,match:u},v=o.get(d.phone);return v?p.meta=v:d.paired&&(p.meta={paired:!0}),p});return[...r,...l]}async function ys(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=lt(s??{}),e.adminPhones=s0(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function Ru(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=lt(e.configForm??((a=e.configSnapshot)==null?void 0:a.config)??{}),d=l.bindings??[],h=[...e.adminPhones,{phone:o}],u=Iu(d,h,s,i);cc(l,["bindings"],u);const p=(r=e.configSnapshot)==null?void 0:r.hash;if(!p){e.adminsError="Config hash missing; reload and retry.";return}const v=Ct(l);await e.client.request("config.set",{raw:v,baseHash:p}),await ys(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}async function Lu(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=lt(e.configForm??((a=e.configSnapshot)==null?void 0:a.config)??{}),d=l.bindings??[],h=e.adminPhones.filter($=>$.phone!==t),u=Iu(d,h,s,i);cc(l,["bindings"],u);const p=(r=e.configSnapshot)==null?void 0:r.hash;if(!p){e.adminsError="Config hash missing; reload and retry.";return}const v=Ct(l);await e.client.request("config.set",{raw:v,baseHash:p}),await ys(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}const o0=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:Ru,loadAdmins:ys,removeAdmin:Lu},Symbol.toStringTag,{value:"Module"}));async function It(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 Du(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 It(e,i)}catch(a){e.contactsError=String(a)}finally{e.contactsSaving=!1}}async function Bu(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 It(e,n)}catch(i){e.contactsError=String(i)}finally{e.contactsSaving=!1}}}async function jo(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 It(e,s)}catch(o){e.contactsError=String(o)}finally{e.contactsSaving=!1}}}async function Nu(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 It(e,i)}catch(s){e.contactsError=String(s)}finally{e.contactsSaving=!1}}}const a0=Object.freeze(Object.defineProperty({__proto__:null,addContact:Du,deleteContact:Bu,deleteContactField:Nu,loadContacts:It,setContactField:jo},Symbol.toStringTag,{value:"Module"}));let kt=null,Mi=null,Pi=null;const mo=[[0,"Checking Tailscale service..."],[5,"Starting login..."],[15,"Requesting authentication link..."],[40,"Setting up secure connection..."],[70,"Almost ready..."]];function Kt(){kt&&(clearInterval(kt),kt=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 r0(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 l0(e){const t=we(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 za(e){const t=we(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function c0(e){var i;const t=we(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 d0(e){return e.selectedWorkspace??void 0}function we(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const u0=/^data:/i,p0=/^https?:\/\//i;function Dl(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(d=>d.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 u0.test(a)||p0.test(a)?a:o==null?void 0:o.avatarUrl}function h0(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 f0(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 g0(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,d;return((l=r.match)==null?void 0:l.channel)==="imessage"&&((d=r.meta)==null?void 0:d.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 Ii(e){const t=Object.create(null);return Object.defineProperties(t,{client:{get:()=>e.client,set:()=>{}},connected:{get:()=>e.connected,set:()=>{}},conversations:{get:()=>e.waConversations,set:n=>{e.waConversations=n}},selectedJid:{get:()=>e.waSelectedJid,set:n=>{e.waSelectedJid=n}},messages:{get:()=>e.waMessages,set:n=>{e.waMessages=n}},groupInfo:{get:()=>e.waGroupInfo,set:n=>{e.waGroupInfo=n}},loading:{get:()=>e.waLoading,set:n=>{e.waLoading=n}},messagesLoading:{get:()=>e.waMessagesLoading,set:n=>{e.waMessagesLoading=n}},searchQuery:{get:()=>e.waSearchQuery,set:n=>{e.waSearchQuery=n}},composeDraft:{get:()=>e.waComposeDraft,set:n=>{e.waComposeDraft=n}},sending:{get:()=>e.waSending,set:n=>{e.waSending=n}},lastError:{get:()=>e.waLastError,set:n=>{e.waLastError=n}},accountId:{get:()=>za(e),set:()=>{}}}),t}function m0(){requestAnimationFrame(()=>{const e=document.querySelector(".wa-messages");e&&(e.scrollTop=e.scrollHeight)})}function y0(e){return{client:e.client,connected:e.connected,conversations:e.waConversations??[],selectedJid:e.waSelectedJid??null,messages:e.waMessages??[],groupInfo:e.waGroupInfo??null,loading:e.waLoading??!1,messagesLoading:e.waMessagesLoading??!1,searchQuery:e.waSearchQuery??"",composeDraft:e.waComposeDraft??"",sending:e.waSending??!1,lastError:e.waLastError??null,accountId:za(e),onSelectConversation:t=>{const n=Ii(e);yw(n,t).then(()=>{e.requestUpdate(),m0()})},onBack:()=>{e.waSelectedJid=null,e.waMessages=[],e.waGroupInfo=null,e.requestUpdate()},onSearchChange:t=>{e.waSearchQuery=t,e.requestUpdate()},onActivationChange:(t,n)=>{const i=Ii(e);vw(i,t,n).then(()=>e.requestUpdate())},onRefresh:()=>{const t=Ii(e);bu(t).then(()=>e.requestUpdate())},requestUpdate:()=>e.requestUpdate()}}function v0(e){var t,n,i,s,o,a,r,l,d,h;if(e.embeddingDownloading&&!e.publicChat)return c`
4878
+ `}function Wa(){return{enabled:!1,publicAgentEnabled:!0,days:{monday:{start:"09:00",end:"17:00",closed:!1},tuesday:{start:"09:00",end:"17:00",closed:!1},wednesday:{start:"09:00",end:"17:00",closed:!1},thursday:{start:"09:00",end:"17:00",closed:!1},friday:{start:"09:00",end:"17:00",closed:!1},saturday:{start:"09:00",end:"17:00",closed:!0},sunday:{start:"09:00",end:"17:00",closed:!0}},closedDates:[]}}const Mu=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];async function za(e){if(!(!e.client||!e.connected)&&!e.openingHoursLoading){e.openingHoursLoading=!0,e.openingHoursError=null;try{const t=await e.client.request("business.openingHours.get",{});if(t.openingHours){const n=t.openingHours,i={};for(const s of Mu){const o=n.schedule[s];o==null?i[s]={start:"09:00",end:"17:00",closed:!0}:i[s]={start:o.start,end:o.end,closed:!1}}e.openingHoursForm={enabled:n.enabled,publicAgentEnabled:t.publicAgentEnabled,days:i,closedDates:[...n.closedDates??[]].sort()}}else{const n=Wa();n.publicAgentEnabled=t.publicAgentEnabled,e.openingHoursForm=n}}catch(t){e.openingHoursError=String(t)}finally{e.openingHoursLoading=!1}}}async function Pu(e){if(!(!e.client||!e.connected||e.openingHoursBusy)){e.openingHoursBusy=!0,e.openingHoursError=null;try{const t=e.openingHoursForm,n={};for(const a of Mu){const r=t.days[a];n[a]=r!=null&&r.closed?null:{start:r.start,end:r.end}}const i=Intl.DateTimeFormat().resolvedOptions().timeZone,s={enabled:t.enabled,timezone:i,schedule:n,closedDates:t.closedDates.length>0?[...t.closedDates].sort():void 0},o=await e.client.request("config.get",{});await e.client.request("config.patch",{raw:JSON.stringify({business:{openingHours:s,publicAgentEnabled:t.publicAgentEnabled}}),baseHash:o.hash,note:"Opening hours updated"}),await za(e)}catch(t){e.openingHoursError=String(t)}finally{e.openingHoursBusy=!1}}}const i0=Object.freeze(Object.defineProperty({__proto__:null,defaultOpeningHoursForm:Wa,loadOpeningHours:za,saveOpeningHours:Pu},Symbol.toStringTag,{value:"Module"}));function s0(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 d=l.id??"";d&&i.push({phone:d,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 Iu(e,t,n="admin",i){const s=d=>d===n||d==="management",o=new Map,a=new Map;for(const d of e){if(!d||typeof d!="object"||!s(d.agentId))continue;const h=d.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&&(d.meta&&o.set(v,d.meta),h.accountId&&a.set(v,h.accountId))}const r=e.filter(d=>{if(!d||typeof d!="object"||!s(d.agentId))return!0;const h=d.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(d=>{const h=i??a.get(d.phone),u={channel:"whatsapp",peer:{kind:"dm",id:d.phone}};h&&(u.accountId=h);const p={agentId:n,match:u},v=o.get(d.phone);return v?p.meta=v:d.paired&&(p.meta={paired:!0}),p});return[...r,...l]}async function bs(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=lt(s??{}),e.adminPhones=s0(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function Ru(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=lt(e.configForm??((a=e.configSnapshot)==null?void 0:a.config)??{}),d=l.bindings??[],h=[...e.adminPhones,{phone:o}],u=Iu(d,h,s,i);cc(l,["bindings"],u);const p=(r=e.configSnapshot)==null?void 0:r.hash;if(!p){e.adminsError="Config hash missing; reload and retry.";return}const v=Ct(l);await e.client.request("config.set",{raw:v,baseHash:p}),await bs(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}async function Lu(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=lt(e.configForm??((a=e.configSnapshot)==null?void 0:a.config)??{}),d=l.bindings??[],h=e.adminPhones.filter($=>$.phone!==t),u=Iu(d,h,s,i);cc(l,["bindings"],u);const p=(r=e.configSnapshot)==null?void 0:r.hash;if(!p){e.adminsError="Config hash missing; reload and retry.";return}const v=Ct(l);await e.client.request("config.set",{raw:v,baseHash:p}),await bs(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}const o0=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:Ru,loadAdmins:bs,removeAdmin:Lu},Symbol.toStringTag,{value:"Module"}));async function It(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 Du(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 It(e,i)}catch(a){e.contactsError=String(a)}finally{e.contactsSaving=!1}}async function Bu(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 It(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 It(e,s)}catch(o){e.contactsError=String(o)}finally{e.contactsSaving=!1}}}async function Nu(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 It(e,i)}catch(s){e.contactsError=String(s)}finally{e.contactsSaving=!1}}}const a0=Object.freeze(Object.defineProperty({__proto__:null,addContact:Du,deleteContact:Bu,deleteContactField:Nu,loadContacts:It,setContactField:Qo},Symbol.toStringTag,{value:"Module"}));let kt=null,Mi=null,Pi=null;const vo=[[0,"Checking Tailscale service..."],[5,"Starting login..."],[15,"Requesting authentication link..."],[40,"Setting up secure connection..."],[70,"Almost ready..."]];function Kt(){kt&&(clearInterval(kt),kt=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 r0(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 l0(e){const t=we(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 Ka(e){const t=we(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function c0(e){var i;const t=we(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 d0(e){return e.selectedWorkspace??void 0}function we(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const u0=/^data:/i,p0=/^https?:\/\//i;function Bl(e){var r,l;const t=((r=e.agentsList)==null?void 0:r.agents)??[],n=Yl(e.sessionKey),i=(n==null?void 0:n.agentId)??((l=e.agentsList)==null?void 0:l.defaultId)??"main",s=t.find(d=>d.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 u0.test(a)||p0.test(a)?a:o==null?void 0:o.avatarUrl}function h0(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 f0(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 g0(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,d;return((l=r.match)==null?void 0:l.channel)==="imessage"&&((d=r.meta)==null?void 0:d.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 Ii(e){const t=Object.create(null);return Object.defineProperties(t,{client:{get:()=>e.client,set:()=>{}},connected:{get:()=>e.connected,set:()=>{}},conversations:{get:()=>e.waConversations,set:n=>{e.waConversations=n}},selectedJid:{get:()=>e.waSelectedJid,set:n=>{e.waSelectedJid=n}},messages:{get:()=>e.waMessages,set:n=>{e.waMessages=n}},groupInfo:{get:()=>e.waGroupInfo,set:n=>{e.waGroupInfo=n}},loading:{get:()=>e.waLoading,set:n=>{e.waLoading=n}},messagesLoading:{get:()=>e.waMessagesLoading,set:n=>{e.waMessagesLoading=n}},searchQuery:{get:()=>e.waSearchQuery,set:n=>{e.waSearchQuery=n}},composeDraft:{get:()=>e.waComposeDraft,set:n=>{e.waComposeDraft=n}},sending:{get:()=>e.waSending,set:n=>{e.waSending=n}},lastError:{get:()=>e.waLastError,set:n=>{e.waLastError=n}},accountId:{get:()=>Ka(e),set:()=>{}}}),t}function m0(){requestAnimationFrame(()=>{const e=document.querySelector(".wa-messages");e&&(e.scrollTop=e.scrollHeight)})}function y0(e){return{client:e.client,connected:e.connected,conversations:e.waConversations??[],selectedJid:e.waSelectedJid??null,messages:e.waMessages??[],groupInfo:e.waGroupInfo??null,loading:e.waLoading??!1,messagesLoading:e.waMessagesLoading??!1,searchQuery:e.waSearchQuery??"",composeDraft:e.waComposeDraft??"",sending:e.waSending??!1,lastError:e.waLastError??null,accountId:Ka(e),onSelectConversation:t=>{const n=Ii(e);yw(n,t).then(()=>{e.requestUpdate(),m0()})},onBack:()=>{e.waSelectedJid=null,e.waMessages=[],e.waGroupInfo=null,e.requestUpdate()},onSearchChange:t=>{e.waSearchQuery=t,e.requestUpdate()},onActivationChange:(t,n)=>{const i=Ii(e);vw(i,t,n).then(()=>e.requestUpdate())},onRefresh:()=>{const t=Ii(e);bu(t).then(()=>e.requestUpdate())},requestUpdate:()=>e.requestUpdate()}}function v0(e){var t,n,i,s,o,a,r,l,d,h;if(e.embeddingDownloading&&!e.publicChat)return c`
4879
4879
  <div class="setup-container">
4880
4880
  <div class="setup-card" style="text-align:center; max-width:420px;">
4881
4881
  <div class="setup-spinner"></div>
@@ -4896,7 +4896,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4896
4896
  <p>Connecting...</p>
4897
4897
  </div>
4898
4898
  </div>
4899
- `;if(!e.publicChatAuthenticated)return n0({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 M;e.publicChatSessionKey=$,e.sessionKey=$,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const S=((M=e.publicChatConfig)==null?void 0:M.accountId)??"";e.chatMessage=zn(S,$),ae(async()=>{const{loadChatHistory:y}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:y}},void 0,import.meta.url).then(({loadChatHistory:y})=>{y(e)})},onAuthStepChange:$=>{e.publicChatAuthStep=$},requestUpdate:()=>{e.requestUpdate()}});const u=(t=e.publicChatConfig)==null?void 0:t.greeting,p=e.chatMessages,v=!e.chatLoading&&u?[{role:"assistant",content:[{type:"text",text:u}],timestamp:0},...Array.isArray(p)?p:[]]:p;return yk({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??Dl(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(),ae(async()=>{const{loadChatHistory:$}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:$}},void 0,import.meta.url).then(({loadChatHistory:$})=>{$(e)})),onDraftChange:$=>{var M;e.chatMessage=$;const S=((M=e.publicChatConfig)==null?void 0:M.accountId)??"";wr(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:u}=e;if(u.hasPins&&!u.authenticated)return Sl({show:!0,isFirstTime:!1,accounts:u.accounts,error:u.error,busy:u.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,$)=>e.handleChangePin(p,v,$)});if(!u.hasMasterPin&&!u.authenticated&&e.setup)return Sl({show:!0,isFirstTime:!0,accounts:[],error:u.error,busy:u.busy,onSubmit:p=>e.handleSetMasterPin(p)});if(!u.hasMasterPin&&!u.authenticated&&!e.setup)return window.location.href="/setup",w}if(e.setup){const u=h0(e.channelsSnapshot),p=((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.whatsapp)??[],v=f0(e.channelsSnapshot),$=g0(e),S=async()=>{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null},M=()=>{const y=Date.now();e.tailscaleConnectProgress=0,e.tailscaleConnectMessage=mo[0][1],e.tailscaleConnectSuccess=!1,e.tailscaleError=null,Kt(),kt=setInterval(()=>{const b=(Date.now()-y)/1e3,k=Math.min(95,95*(1-Math.exp(-b/30)));e.tailscaleConnectProgress=Math.round(k);let A=mo[0][1];for(const[E,T]of mo)b>=E&&(A=T);e.tailscaleConnectMessage=A},500)};return rm({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:y=>e.handleLicenseKeyChange(y),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,authRefreshToken:e.authRefreshToken,claudeAuthModalOpen:e.claudeAuthModalOpen,authRefreshTokenInput:e.authRefreshTokenInput,authRefreshTokenBusy:e.authRefreshTokenBusy,authRefreshTokenError:e.authRefreshTokenError,onClaudeAuthModalOpen:()=>e.handleClaudeAuthModalOpen(),onClaudeAuthModalClose:()=>e.handleClaudeAuthModalClose(),onRefreshTokenInputChange:y=>{e.authRefreshTokenInput=y},onImportRefreshToken:()=>e.handleImportRefreshToken(),whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:u,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:y=>e.handleUninstallConfirmTextChange(y),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:y=>e.handleAuthSubmitCode(y),onAuthCodeChange:y=>e.handleAuthCodeChange(y),onWhatsAppRelink:async y=>{await e.handleWhatsAppStart(!0,y),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(y),await Z(e,!0),e.requestUpdate())},onWhatsAppUnlink:async y=>{await e.handleWhatsAppLogout(y)},onWhatsAppReset:async y=>{await e.handleWhatsAppLogout(y),await e.handleWhatsAppStart(!0,y),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(y),await Z(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await Z(e,!0),await e.handleGatewayHealthCheck()},onRefreshGatewayStatus:()=>e.handleGatewayHealthCheck(),onRefreshWhatsAppStatus:()=>Z(e,!0),onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),Z(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:y=>e.handleRemoveWhatsAppAccount(y),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:y=>{e.newWorkspacePin=y},onWorkspaceCreate:async(y,b)=>{const k=e.newWorkspacePin;await e.handleWorkspaceCreate(y,b),k.match(/^\d{4,6}$/)&&(await Ph(e,y,k),e.newWorkspacePin="")},onWorkspaceRemove:y=>e.handleWorkspaceRemove(y),onSetAddingWorkspace:y=>{e.addingWorkspace=y},onSetNewWorkspaceName:y=>{e.newWorkspaceName=y},onSetNewWorkspacePath:y=>{e.newWorkspacePath=y},onSetWorkspaceRemoveConfirm:y=>{e.workspaceRemoveConfirm=y},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(y,b)=>e.handleWorkspaceRename(y,b),whatsappDmPolicy:(()=>{const y=we(e),b=y==null?void 0:y.whatsappAccountId,k=b?p.find(A=>A.accountId===b):p[0];return(k==null?void 0:k.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var P;const y=we(e),b=y==null?void 0:y.whatsappAccountId,k=b?p.find(D=>D.accountId===b):p[0];if(!k)return;const E=k.dmPolicy!=null&&k.dmPolicy!=="disabled"?"disabled":"open",T=E==="open"?{dmPolicy:E,allowFrom:["*"]}:{dmPolicy:E};try{const D=await e.client.request("config.get"),W=D.config,K=(P=W==null?void 0:W.channels)==null?void 0:P.whatsapp,ke=((K==null?void 0:K.accounts)??{})[k.accountId]?{channels:{whatsapp:{accounts:{[k.accountId]:T}}}}:{channels:{whatsapp:T}};await e.client.request("config.patch",{raw:JSON.stringify(ke),baseHash:D.hash,note:`WhatsApp DM policy → ${E}`,skipRestart:!0}),await Z(e,!1)}catch(D){console.error("DM toggle failed:",D)}},whatsappGroupPolicy:(()=>{var D,W;const y=(D=e.configSnapshot)==null?void 0:D.config,b=(W=y==null?void 0:y.channels)==null?void 0:W.whatsapp,k=we(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},T=A?E[A]:void 0;return(T==null?void 0:T.groupPolicy)??(b==null?void 0:b.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var W,K;const y=(W=e.configSnapshot)==null?void 0:W.config,b=(K=y==null?void 0:y.channels)==null?void 0:K.whatsapp,k=we(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},T=A?E[A]:void 0,D=((T==null?void 0:T.groups)??(b==null?void 0:b.groups)??{})["*"];return(D==null?void 0:D.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var k;const y=we(e),b=y==null?void 0:y.whatsappAccountId;try{const A=await e.client.request("config.get"),E=A.config,T=((k=E==null?void 0:E.channels)==null?void 0:k.whatsapp)??{},P=T.accounts??{},D=b?P[b]:void 0,W=(D==null?void 0:D.groupPolicy)??T.groupPolicy??"allowlist",K=W==="disabled"||W==="allowlist",H=K?"open":"disabled",ke=K?{"*":{}}:void 0,Ie={groupPolicy:H};ke&&(Ie.groups=ke);const Ke=D?{channels:{whatsapp:{accounts:{[b]:Ie}}}}:{channels:{whatsapp:Ie}};await e.client.request("config.patch",{raw:JSON.stringify(Ke),baseHash:A.hash,note:`WhatsApp groups → ${H}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Group toggle failed:",A)}},onWhatsAppGroupMentionChange:async y=>{var A;const b=we(e),k=b==null?void 0:b.whatsappAccountId;try{const E=await e.client.request("config.get"),T=E.config,D=(((A=T==null?void 0:T.channels)==null?void 0:A.whatsapp)??{}).accounts??{},W=k?D[k]:void 0,K={"*":{requireMention:y}},H=W?{channels:{whatsapp:{accounts:{[k]:{groups:K}}}}}:{channels:{whatsapp:{groups:K}}};await e.client.request("config.patch",{raw:JSON.stringify(H),baseHash:E.hash,note:`WhatsApp group mention → ${y?"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:$,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,k=(b==null?void 0:b.bindings)??[],A=we(e),E=A==null?void 0:A.agents.find(K=>K.id.endsWith("-admin")||K.id==="admin"),T=(E==null?void 0:E.id)??"admin",P=k.filter(K=>{var H;return((H=K.match)==null?void 0:H.channel)!=="imessage"}),D=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],W=[...P,...D];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:W}),baseHash:y.hash,note:"Enable iMessage (self-chat) for "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Z(e,!0),We(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await Z(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,A=((b==null?void 0:b.bindings)??[]).filter(E=>{var T;return((T=E.match)==null?void 0:T.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:A}),baseHash:y.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Z(e,!0),We(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,k=(b==null?void 0:b.bindings)??[],A=we(e),E=A==null?void 0:A.agents.find(W=>W.id.endsWith("-admin")||W.id==="admin"),T=(E==null?void 0:E.id)??"admin",P=k.filter(W=>{var K;return((K=W.match)==null?void 0:K.channel)!=="imessage"}),D=[{agentId:T,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,...D]}),baseHash:y.hash,note:"Reassign iMessage to "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Z(e,!0),We(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:y=>{var b,k,A,E;if(e.infoModalOpen=y,y==="remote-access"){const T=((b=e.tailscaleStatus)==null?void 0:b.tailnetUrl)??((k=e.tailscaleStatus)!=null&&k.hostname?`https://${e.tailscaleStatus.hostname}`:null);T&&!e.remoteAccessQrDataUrl&&e.client.request("qr.generate",{url:T}).then(P=>{e.remoteAccessQrDataUrl=(P==null?void 0:P.dataUrl)??null}).catch(()=>{})}else if(y==="public-chat"){const T=((A=e.tailscaleStatus)==null?void 0:A.publicUrl)??((E=e.tailscaleStatus)==null?void 0:E.tailnetUrl)??null,P=e.selectedWorkspace??null;if(T&&P){const D=`${T}/public/chat/${encodeURIComponent(P)}`;e.publicChatQrDataUrl||e.client.request("qr.generate",{url:D}).then(W=>{e.publicChatQrDataUrl=(W==null?void 0:W.dataUrl)??null}).catch(()=>{})}}},onInfoModalClose:()=>{e.infoModalOpen=null},remoteAccessQrDataUrl:e.remoteAccessQrDataUrl??null,publicChatQrDataUrl:e.publicChatQrDataUrl??null,publicChatFullUrl:(()=>{var k,A;const y=((k=e.tailscaleStatus)==null?void 0:k.publicUrl)??((A=e.tailscaleStatus)==null?void 0:A.tailnetUrl)??null,b=e.selectedWorkspace??null;return!y||!b?null:`${y}/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(y,b)=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await El(e.client,y,b);const k=`${y} key saved`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}y==="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 y=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Nk(e.client,y);const b=`${y} 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(y,b)=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Ok(e.client,y,b);const k=`${y} ${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:y=>{e.authApiKeyInput=y},onAuthApiKeySubmit:async()=>{const y=e.authApiKeyInput.trim();if(y){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await El(e.client,"anthropic",y),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 y=e.selectedWorkspace??((b=e.workspaces[0])==null?void 0:b.name);return y?e.accessState.accounts.some(k=>k.id===y):!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:(y,b)=>{var A;const k=e.selectedWorkspace??((A=e.workspaces[0])==null?void 0:A.name);k&&e.handleAccountPinSave(k,y,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 y=(k=e.configSnapshot)==null?void 0:k.config,b=y==null?void 0:y.publicChat;return(b==null?void 0:b.enabled)===!0})(),publicChatAuthMode:(()=>{var T,P;const y=(T=e.configSnapshot)==null?void 0:T.config,b=y==null?void 0:y.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 y=(E=e.configSnapshot)==null?void 0:E.config,b=y==null?void 0:y.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 y=e.selectedWorkspace??"";if(y){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[y]){const P={publicChat:{greetings:{[y]:null}}};await e.client.request("config.patch",{raw:JSON.stringify(P),baseHash:k.hash,note:`Public chat greeting → disabled (${y})`,skipRestart:!0})}else{const P=await e.client.request("public.greeting.generate",{accountId:y});if(P!=null&&P.ok&&P.greeting){const D=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[y]:P.greeting}}}),baseHash:D.hash,note:`Public chat greeting → enabled (${y})`,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 y=>{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]:y}}}),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 y=e.selectedWorkspace??"";if(y){e.publicChatGreetingBusy=!0;try{const b=await e.client.request("public.greeting.generate",{accountId:y});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:{[y]:b.greeting}}}),baseHash:k.hash,note:`Public chat greeting regenerated (${y})`,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 y;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get"),k=b.config,A=((y=k==null?void 0:k.publicChat)==null?void 0:y.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 y=>{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:y}}}}),baseHash:k.hash,note:`Public chat auth → ${y}`,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 y=(k=e.configSnapshot)==null?void 0:k.config,b=(A=y==null?void 0:y.publicChat)==null?void 0:A.email;return(b==null?void 0:b.from)??""})(),publicChatEmailBusy:e.publicChatEmailBusy,publicChatVerifyMethods:(()=>{var T,P;const y=(T=e.configSnapshot)==null?void 0:T.config,b=y==null?void 0:y.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(y,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:y||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 y=e.selectedWorkspace;return y?((k=Fe()[y])==null?void 0:k.accentColor)??"":""})(),brandBackgroundColor:(()=>{var k;const y=e.selectedWorkspace;return y?((k=Fe()[y])==null?void 0:k.backgroundColor)??"":""})(),brandHasLogo:(()=>{var k;const y=e.selectedWorkspace;return y?!!((k=Fe()[y])!=null&&k.logoUrl):!1})(),agentSettingsOpen:e.agentSettingsOpen,agentSettingsAgents:(()=>{var A,E;const y=we(e);if(!y)return[];const b=(A=e.configSnapshot)==null?void 0:A.config,k=(E=b==null?void 0:b.agents)==null?void 0:E.list;return y.agents.map(T=>{var H;const P=Array.isArray(k)?k.find(ke=>ke.id===T.id):void 0,D=P==null?void 0:P.model,W=typeof D=="string"?D:(D==null?void 0:D.primary)??null,K=T.id.endsWith("-admin")||T.id==="admin";return{id:T.id,label:K?"Admin":"Public",model:(W==null?void 0:W.trim())||null,thinkingLevel:((H=P==null?void 0:P.thinkingLevel)==null?void 0:H.trim())||null}})})(),agentSettingsModelCatalog:e.chatModelCatalog??[],memoryProvider:(()=>{var k,A,E;const y=(k=e.configSnapshot)==null?void 0:k.config,b=(E=(A=y==null?void 0:y.agents)==null?void 0:A.defaults)==null?void 0:E.memorySearch;return typeof(b==null?void 0:b.provider)=="string"&&b.provider?b.provider:"local"})(),memoryFallback:(()=>{var k,A,E;const y=(k=e.configSnapshot)==null?void 0:k.config,b=(E=(A=y==null?void 0:y.agents)==null?void 0:A.defaults)==null?void 0:E.memorySearch;return typeof(b==null?void 0:b.fallback)=="string"&&b.fallback?b.fallback:"none"})(),onAgentSettingsToggle:()=>{e.agentSettingsOpen=!e.agentSettingsOpen},onAgentModelChange:async(y,b)=>{try{const k=await e.client.request("config.get"),A=k.config,E=(A==null?void 0:A.agents)??{},T=Array.isArray(E.list)?[...E.list]:[],P=T.findIndex(W=>W.id===y);if(b)P>=0?T[P]={...T[P],model:b}:T.push({id:y,model:b});else if(P>=0){const{model:W,...K}=T[P];Object.keys(K).length<=1?T.splice(P,1):T[P]=K}const D=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(D),baseHash:k.hash,note:`Agent ${y} model → ${b||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Agent model change failed:",k)}},onAgentThinkingChange:async(y,b)=>{try{const k=await e.client.request("config.get"),A=k.config,E=(A==null?void 0:A.agents)??{},T=Array.isArray(E.list)?[...E.list]:[],P=T.findIndex(K=>K.id===y),D=b==="off"?void 0:b;if(D)P>=0?T[P]={...T[P],thinkingLevel:D}:T.push({id:y,thinkingLevel:D});else if(P>=0){const{thinkingLevel:K,...H}=T[P];Object.keys(H).length<=1?T.splice(P,1):T[P]=H}const W=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(W),baseHash:k.hash,note:`Agent ${y} thinking → ${D||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Agent thinking change failed:",k)}},onMemoryProviderChange:async y=>{try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({agents:{defaults:{memorySearch:{provider:y}}}}),baseHash:b.hash,note:`Memory search provider → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Memory provider change failed:",b)}},onMemoryFallbackChange:async y=>{try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({agents:{defaults:{memorySearch:{fallback:y}}}}),baseHash:b.hash,note:`Memory search fallback → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Memory fallback change failed:",b)}},brandingBusy:e.brandingBusy,brandingExpanded:e.brandingExpanded,onBrandingToggle:()=>{e.brandingExpanded=!e.brandingExpanded},onBrandAccentColorChange:async y=>{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,T=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=T.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...T,brand:{...P,accentColor:y}}}}),baseHash:A.hash,note:`Brand accent → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const D=Fe();D[b]||(D[b]={}),D[b].accentColor=y,Tn(b)}catch(A){console.error("Brand accent change failed:",A)}finally{e.brandingBusy=!1}}},onBrandBackgroundColorChange:async y=>{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,T=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=T.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...T,brand:{...P,backgroundColor:y}}}}),baseHash:A.hash,note:`Brand background → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const D=Fe();D[b]||(D[b]={}),D[b].backgroundColor=y,Tn(b)}catch(A){console.error("Brand background change failed:",A)}finally{e.brandingBusy=!1}}},onBrandLogoUpload:async y=>{const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const k=await y.arrayBuffer(),A=new Uint8Array(k);let E="";for(let D=0;D<A.length;D++)E+=String.fromCharCode(A[D]);const T=btoa(E);await e.client.request("brand.uploadLogo",{workspace:b,data:T,mimeType:y.type});const P=Fe();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 y=e.selectedWorkspace;if(!(!y||e.brandingBusy)){e.brandingBusy=!0;try{await e.client.request("brand.removeLogo",{workspace:y});const b=Fe();b[y]&&delete b[y].logoUrl}catch(b){console.error("Brand logo remove failed:",b)}finally{e.brandingBusy=!1}}},onBrandReset:async()=>{var b;const y=e.selectedWorkspace;if(!(!y||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[y])??{},{brand:T,...P}=E;await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[y]:{...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:y})}catch{}const D=Fe();delete D[y],Tn(y)}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,M();try{const y=await e.client.request("tailscale.enable");y.authUrl?(kt&&(clearInterval(kt),kt=null),e.tailscaleConnectProgress=100,e.tailscaleConnectMessage="Waiting for authentication...",e.tailscaleAuthUrl=y.authUrl,Mi=setInterval(async()=>{try{const b=await e.client.request("tailscale.status");e.tailscaleStatus=b,e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,b.loggedIn&&(Kt(),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(()=>{Kt(),e.tailscaleBusy&&(e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)},3e5)):y.alreadyLoggedIn?(Kt(),e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1):(Kt(),e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)}catch(y){console.error("Tailscale enable failed:",y),Kt(),e.tailscaleError=y.message||"Failed to enable Remote Access",e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1}}},onTailscaleErrorDismiss:()=>{e.tailscaleError=null},onTailscaleServeEnable:async()=>{var y;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;(y=k.payload)!=null&&y.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(y){console.error("Tailscale serve disable failed:",y)}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelEnable:async()=>{var y;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;(y=k.payload)!=null&&y.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(y){console.error("Tailscale funnel disable failed:",y)}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 y;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&&((y=b.networks)!=null&&y.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 y=e.wifiSelectedSsid;e.wifiBusy=!0,e.wifiError=null;try{const k=await e.client.request("wifi.connect",{ssid:y,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 T=A.networks.find(P=>P.active)||A.networks.find(P=>P.ssid===E.ssid);T&&(E.signal=T.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 y=await e.client.request("wifi.status");e.wifiStatus=y}catch(y){console.error("WiFi disconnect failed:",y),e.wifiError=y.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 y=await e.client.request("wifi.status");e.wifiStatus=y}catch(y){console.error("WiFi forget failed:",y),e.wifiError=y.message||"Failed to forget network"}finally{e.wifiBusy=!1}}},onWifiDismiss:()=>{e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null},onWifiSelectSsid:y=>{e.wifiSelectedSsid=y,e.wifiPassword="",e.wifiError=null},onWifiPasswordChange:y=>{e.wifiPassword=y},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:y=>{e.networkPortInput=y,e.networkError=null,e.networkSuccess=null},onNetworkHostnameChange:y=>{e.networkHostnameInput=y,e.networkError=null,e.networkSuccess=null},onNetworkSave:async()=>{if(e.networkBusy)return;e.networkBusy=!0,e.networkError=null,e.networkSuccess=null;const y=e.networkPortInput.trim(),b=Number.parseInt(y,10),k=e.networkHostnameInput.trim();if(!y||!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 T={};A&&(T.gateway={port:b}),E&&(T.discovery={bonjourHostname:k});const P=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify(T),baseHash:P.hash,note:[A?`Port → ${b}`:null,E?`Hostname → ${k}`:null].filter(Boolean).join(", "),restartDelayMs:2e3}),e.networkSuccess="Saved — redirecting...";const D=window.location.protocol,W=E?`${k}.local`:window.location.hostname,K=A?b:e.networkPort,H=`${D}//${W}:${K}/setup`;setTimeout(()=>{window.location.href=H},1500)}catch(T){console.error("Network save failed:",T),e.networkError=T.message||"Failed to save network settings",e.networkBusy=!1}},wsProps:r0(e)})}if(e.filesPage){const u=c0(e);return wg({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:()=>{rn(e,u),cs(e,u)},onReindex:()=>Lf(e,u),onSelectFile:p=>{e.filesPendingDeletePath=null,Cf(e,p,u)},onToggleSelectFile:p=>Ef(e,p,u),onToggleDir:p=>Df(e,p),onUpload:(p,v)=>Mf(e,p,v,u),onNewFolder:(p,v)=>Pf(e,p,v,u),onDownload:p=>ld(e,p,u),onBulkDownload:()=>Tf(e,u),onDelete:p=>{e.filesPendingDeletePath=null,If(e,p,u)},pendingDeletePath:e.filesPendingDeletePath,onArmDelete:p=>{e.filesPendingDeletePath=p||null},onMoveToDir:(p,v)=>_f(e,p,v,u),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:p=>{const v=e.filesSearchAgentId??u;Bf(e,p,v)},onSearchAgentChange:p=>{e.filesSearchAgentId=p},onSearchClear:()=>{Nf(e)},onSearchQueryChange:p=>{e.filesSearchQuery=p}})}if(e.browserPage)return fg({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:()=>_k(e),onStop:()=>Mk(e),onToggleInput:()=>Ik(e),onToggleFullscreen:()=>Rk(e),onCompleteHandoff:()=>Pk(e),onCanvasMouseDown:u=>{const v=u.target.getBoundingClientRect(),S=Bn().translateCoordinates(u.clientX-v.left,u.clientY-v.top);po(e,"mousePressed",S.x,S.y,u.button===2?"right":u.button===1?"middle":"left")},onCanvasMouseUp:u=>{const v=u.target.getBoundingClientRect(),S=Bn().translateCoordinates(u.clientX-v.left,u.clientY-v.top);po(e,"mouseReleased",S.x,S.y)},onCanvasMouseMove:u=>{const p=Bn();if(p.shouldThrottleMouseMove())return;const $=u.target.getBoundingClientRect(),S=p.translateCoordinates(u.clientX-$.left,u.clientY-$.top);po(e,"mouseMoved",S.x,S.y)},onCanvasKeyDown:u=>{let p=0;u.altKey&&(p|=1),u.ctrlKey&&(p|=2),u.metaKey&&(p|=4),u.shiftKey&&(p|=8),ho(e,"keyDown",u.key,{code:u.code,modifiers:p||void 0}),u.key.length===1&&ho(e,"char",u.key,{text:u.key})},onCanvasKeyUp:u=>{ho(e,"keyUp",u.key,{code:u.code})}});if(e.adminsPage){const u=l0(e),p=za(e);return cm({connected:e.connected,wsProps:Sn(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>ys(e,u),onAdd:v=>{Ru(e,v,u,p).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:v=>Lu(e,v,u,p),onNewPhoneChange:v=>e.handleAdminsNewPhoneChange(v)})}if(e.contactsPage){const u=d0(e);return gm({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:()=>It(e,u),onAdd:(p,v)=>Du(e,p,v,u),onDelete:p=>Bu(e,p,u),onSetField:(p,v,$)=>jo(e,p,v,$,u),onDeleteField:(p,v)=>Nu(e,p,v,u),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:()=>It(e,u),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||(jo(e,p,v,e.contactsAddFieldValue,u),e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue="")}})}if(e.chatPage){const u=e.connected?null:"Disconnected from gateway.",p=Dl(e),v=e.chatAvatarUrl??p??null,$=(()=>{var y;const S=(y=e.configSnapshot)==null?void 0:y.config,M=S==null?void 0:S.publicChat;return(M==null?void 0:M.enabled)===!0})();return mw({connected:e.connected,wsProps:Sn(e),publicChatEnabled:$,publicChatAccountId:e.selectedWorkspace??void 0,chatPageTab:e.chatPageTab??"chat",onChatPageTabChange:S=>{if(e.chatPageTab=S,S==="whatsapp"&&!e.waLoading&&e.waConversations.length===0){const M=Ii(e);bu(M).then(()=>e.requestUpdate())}},whatsappProps:y0(e),sessionKey:e.sessionKey,onSessionKeyChange:S=>{const M=e.selectedWorkspace??"";wo(),Wn(M,e.sessionKey,e.chatMessage),e.sessionKey=S,e.chatMessage=zn(M,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(),Jt(e),Eo(e)},showThinking:e.settings.chatShowThinking??!1,verboseLevel:e.chatVerboseLevel,suggestions:e.chatSuggestions,onSuggestionClick:S=>{e.chatMessage=S,e.chatSuggestions=[],e.handleSendChat()},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:u,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>{e.resetToolStream();const S=Math.max(e.chatMessages.length+10,nn);return Promise.all([Jt(e,{limit:S}),Eo(e)])},onToggleFocusMode:()=>{},onChatScroll:S=>e.handleChatScroll(S),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:S=>{e.chatMessage=S,wr(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?mk({connected:e.connected,wsProps:Sn(e),activeTab:e.advancedTab,onTabChange:u=>{e.advancedTab=u,u==="cron"&&e.loadCron(),u==="skills"&&Pe(e,{clearMessages:!0}),u==="opening-hours"&&Wa(e),u==="logs"&&(e.logsSubTab==="session"?Pn(e,{reset:!0}):bt(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(u=>u.id):((l=e.channelsSnapshot)==null?void 0:l.channelOrder)??[],channelLabels:((d=e.channelsSnapshot)==null?void 0:d.channelLabels)??{},channelMeta:((h=e.channelsSnapshot)==null?void 0:h.channelMeta)??[],agentIds:(()=>{var p;const u=we(e);return((p=u==null?void 0:u.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:u=>{e.cronDetailJobId=u.id,xo(e,u.id)},onDetailClose:()=>{e.cronDetailJobId=null},onEdit:u=>{e.cronForm=Ah(u),e.cronEditJobId=u.id,e.cronDetailJobId=null},onEditSave:()=>{const u=e.cronEditJobId;u&&Ch(e,u).then(()=>{e.cronEditJobId=null})},onFormChange:u=>e.cronForm={...e.cronForm,...u},onRefresh:()=>e.loadCron(),onAdd:()=>{wh(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(u,p)=>kh(e,u,p),onRun:u=>xh(e,u),onRemove:u=>{e.cronPendingDeleteId=null,Sh(e,u)},pendingDeleteId:e.cronPendingDeleteId,onArmDelete:u=>{e.cronPendingDeleteId=u||null},onLoadRuns:u=>xo(e,u),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:u=>e.skillsFilter=u,onTypeFilterChange:u=>e.skillsTypeFilter=u,onRefresh:()=>Pe(e,{clearMessages:!0}),onToggle:(u,p)=>Oc(e,u,p),onEdit:(u,p)=>Nc(e,u,p),onSaveKey:u=>Fc(e,u),onInstall:(u,p,v)=>Uc(e,u,p,v),onViewDetail:u=>Wc(e,u),onDetailClose:()=>zc(e),onDetailTab:u=>Kc(e,u),onAddOpen:()=>Hc(e),onAddClose:()=>qc(e),onImportDraft:u=>jc(e,u),onInstallDraft:u=>Gc(e,u),onDeleteDraft:u=>Vc(e,u),onAddSave:()=>ua(e),onAddFormUpdate:(u,p)=>{e.skillAddForm={...e.skillAddForm,[u]:p}},onAlwaysActiveToggle:(u,p)=>Zc(e,u,p),onDelete:u=>td(e,u),onEditSkill:u=>Qc(e,u),onEditDetail:u=>Jc(e,u),onRefUpdate:(u,p)=>Yc(e,u,p),onEditTab:u=>Xc(e,u),agentFilter:e.skillsAgentFilter,onAgentFilterChange:u=>e.skillsAgentFilter=u,onAgentsChange:(u,p)=>ed(e,u,p)},logsProps:{logsSubTab:e.logsSubTab,isAdmin:e.accessState.master||!e.accessState.hasPins,onSubTabChange:u=>{e.logsSubTab=u,u==="session"?Pn(e,{reset:!0}):bt(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:u=>e.sessionLogsFilterText=u,onTypeToggle:(u,p)=>{const v=e;v.sessionLogsTypeFilters={...v.sessionLogsTypeFilters,[u]:p}},onAgentToggle:(u,p)=>{const v=e;v.sessionLogsAgentFilters={...v.sessionLogsAgentFilters,[u]:p}},onToggleAutoFollow:u=>e.sessionLogsAutoFollow=u,onToggleChips:()=>{const u=e;u.sessionLogsChipsExpanded=!u.sessionLogsChipsExpanded},onToggleExpand:u=>{const p=e,v=new Set(p.sessionLogsExpandedIds);v.has(u)?v.delete(u):v.add(u),p.sessionLogsExpandedIds=v,p.requestUpdate()},onRefresh:()=>{Pn(e,{reset:!0})},onExport:(u,p)=>e.exportSessionLogs(u,p),onScroll:u=>e.handleSessionLogsScroll(u)},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,selectedDate:e.logsDate,availableDates:e.logsAvailableDates,onDateChange:u=>{e.logsDate=u,bt(e,{reset:!0})},onFilterTextChange:u=>e.logsFilterText=u,onLevelToggle:(u,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[u]:p}},onToggleAutoFollow:u=>e.logsAutoFollow=u,onToggleChips:()=>{const u=e;u.logsChipsExpanded=!u.logsChipsExpanded},onRefresh:()=>bt(e,{reset:!0}),onExport:(u,p)=>e.exportSessionLogs(u,p),onScroll:u=>e.handleLogsScroll(u)},openingHoursProps:{loading:e.openingHoursLoading,error:e.openingHoursError,busy:e.openingHoursBusy,form:e.openingHoursForm,onFormChange:u=>{const p=e;p.openingHoursForm={...p.openingHoursForm,...u}},onDayChange:(u,p,v)=>{const $=e,S={...$.openingHoursForm.days};S[u]={...S[u],[p]:v},$.openingHoursForm={...$.openingHoursForm,days:S}},onAddClosedDate:u=>{const p=e;p.openingHoursForm.closedDates.includes(u)||(p.openingHoursForm={...p.openingHoursForm,closedDates:[...p.openingHoursForm.closedDates,u].sort()})},onRemoveClosedDate:u=>{const p=e;p.openingHoursForm={...p.openingHoursForm,closedDates:p.openingHoursForm.closedDates.filter(v=>v!==u)}},onSave:()=>{Pu(e)}}}):(window.location.replace("/chat"),c``)}function b0(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 Bl(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function w0(e,t,n){return c`
4899
+ `;if(!e.publicChatAuthenticated)return n0({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 M;e.publicChatSessionKey=$,e.sessionKey=$,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const S=((M=e.publicChatConfig)==null?void 0:M.accountId)??"";e.chatMessage=zn(S,$),ae(async()=>{const{loadChatHistory:y}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:y}},void 0,import.meta.url).then(({loadChatHistory:y})=>{y(e)})},onAuthStepChange:$=>{e.publicChatAuthStep=$},requestUpdate:()=>{e.requestUpdate()}});const u=(t=e.publicChatConfig)==null?void 0:t.greeting,p=e.chatMessages,v=!e.chatLoading&&u?[{role:"assistant",content:[{type:"text",text:u}],timestamp:0},...Array.isArray(p)?p:[]]:p;return yk({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??Bl(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(),ae(async()=>{const{loadChatHistory:$}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:$}},void 0,import.meta.url).then(({loadChatHistory:$})=>{$(e)})),onDraftChange:$=>{var M;e.chatMessage=$;const S=((M=e.publicChatConfig)==null?void 0:M.accountId)??"";kr(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:u}=e;if(u.hasPins&&!u.authenticated)return Al({show:!0,isFirstTime:!1,accounts:u.accounts,error:u.error,busy:u.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,$)=>e.handleChangePin(p,v,$)});if(!u.hasMasterPin&&!u.authenticated&&e.setup)return Al({show:!0,isFirstTime:!0,accounts:[],error:u.error,busy:u.busy,onSubmit:p=>e.handleSetMasterPin(p)});if(!u.hasMasterPin&&!u.authenticated&&!e.setup)return window.location.href="/setup",w}if(e.setup){const u=h0(e.channelsSnapshot),p=((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.whatsapp)??[],v=f0(e.channelsSnapshot),$=g0(e),S=async()=>{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null},M=()=>{const y=Date.now();e.tailscaleConnectProgress=0,e.tailscaleConnectMessage=vo[0][1],e.tailscaleConnectSuccess=!1,e.tailscaleError=null,Kt(),kt=setInterval(()=>{const b=(Date.now()-y)/1e3,k=Math.min(95,95*(1-Math.exp(-b/30)));e.tailscaleConnectProgress=Math.round(k);let A=vo[0][1];for(const[E,T]of vo)b>=E&&(A=T);e.tailscaleConnectMessage=A},500)};return rm({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:y=>e.handleLicenseKeyChange(y),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,authRefreshToken:e.authRefreshToken,claudeAuthModalOpen:e.claudeAuthModalOpen,authRefreshTokenInput:e.authRefreshTokenInput,authRefreshTokenBusy:e.authRefreshTokenBusy,authRefreshTokenError:e.authRefreshTokenError,onClaudeAuthModalOpen:()=>e.handleClaudeAuthModalOpen(),onClaudeAuthModalClose:()=>e.handleClaudeAuthModalClose(),onRefreshTokenInputChange:y=>{e.authRefreshTokenInput=y},onImportRefreshToken:()=>e.handleImportRefreshToken(),whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:u,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:y=>e.handleUninstallConfirmTextChange(y),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:y=>e.handleAuthSubmitCode(y),onAuthCodeChange:y=>e.handleAuthCodeChange(y),onWhatsAppRelink:async y=>{await e.handleWhatsAppStart(!0,y),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(y),await Z(e,!0),e.requestUpdate())},onWhatsAppUnlink:async y=>{await e.handleWhatsAppLogout(y)},onWhatsAppReset:async y=>{await e.handleWhatsAppLogout(y),await e.handleWhatsAppStart(!0,y),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(y),await Z(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await Z(e,!0),await e.handleGatewayHealthCheck()},onRefreshGatewayStatus:()=>e.handleGatewayHealthCheck(),onRefreshWhatsAppStatus:()=>Z(e,!0),onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),Z(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:y=>e.handleRemoveWhatsAppAccount(y),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:y=>{e.newWorkspacePin=y},onWorkspaceCreate:async(y,b)=>{const k=e.newWorkspacePin;await e.handleWorkspaceCreate(y,b),k.match(/^\d{4,6}$/)&&(await Ph(e,y,k),e.newWorkspacePin="")},onWorkspaceRemove:y=>e.handleWorkspaceRemove(y),onSetAddingWorkspace:y=>{e.addingWorkspace=y},onSetNewWorkspaceName:y=>{e.newWorkspaceName=y},onSetNewWorkspacePath:y=>{e.newWorkspacePath=y},onSetWorkspaceRemoveConfirm:y=>{e.workspaceRemoveConfirm=y},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(y,b)=>e.handleWorkspaceRename(y,b),whatsappDmPolicy:(()=>{const y=we(e),b=y==null?void 0:y.whatsappAccountId,k=b?p.find(A=>A.accountId===b):p[0];return(k==null?void 0:k.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var P;const y=we(e),b=y==null?void 0:y.whatsappAccountId,k=b?p.find(D=>D.accountId===b):p[0];if(!k)return;const E=k.dmPolicy!=null&&k.dmPolicy!=="disabled"?"disabled":"open",T=E==="open"?{dmPolicy:E,allowFrom:["*"]}:{dmPolicy:E};try{const D=await e.client.request("config.get"),W=D.config,K=(P=W==null?void 0:W.channels)==null?void 0:P.whatsapp,ke=((K==null?void 0:K.accounts)??{})[k.accountId]?{channels:{whatsapp:{accounts:{[k.accountId]:T}}}}:{channels:{whatsapp:T}};await e.client.request("config.patch",{raw:JSON.stringify(ke),baseHash:D.hash,note:`WhatsApp DM policy → ${E}`,skipRestart:!0}),await Z(e,!1)}catch(D){console.error("DM toggle failed:",D)}},whatsappGroupPolicy:(()=>{var D,W;const y=(D=e.configSnapshot)==null?void 0:D.config,b=(W=y==null?void 0:y.channels)==null?void 0:W.whatsapp,k=we(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},T=A?E[A]:void 0;return(T==null?void 0:T.groupPolicy)??(b==null?void 0:b.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var W,K;const y=(W=e.configSnapshot)==null?void 0:W.config,b=(K=y==null?void 0:y.channels)==null?void 0:K.whatsapp,k=we(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},T=A?E[A]:void 0,D=((T==null?void 0:T.groups)??(b==null?void 0:b.groups)??{})["*"];return(D==null?void 0:D.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var k;const y=we(e),b=y==null?void 0:y.whatsappAccountId;try{const A=await e.client.request("config.get"),E=A.config,T=((k=E==null?void 0:E.channels)==null?void 0:k.whatsapp)??{},P=T.accounts??{},D=b?P[b]:void 0,W=(D==null?void 0:D.groupPolicy)??T.groupPolicy??"allowlist",K=W==="disabled"||W==="allowlist",H=K?"open":"disabled",ke=K?{"*":{}}:void 0,Ie={groupPolicy:H};ke&&(Ie.groups=ke);const Ke=D?{channels:{whatsapp:{accounts:{[b]:Ie}}}}:{channels:{whatsapp:Ie}};await e.client.request("config.patch",{raw:JSON.stringify(Ke),baseHash:A.hash,note:`WhatsApp groups → ${H}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Group toggle failed:",A)}},onWhatsAppGroupMentionChange:async y=>{var A;const b=we(e),k=b==null?void 0:b.whatsappAccountId;try{const E=await e.client.request("config.get"),T=E.config,D=(((A=T==null?void 0:T.channels)==null?void 0:A.whatsapp)??{}).accounts??{},W=k?D[k]:void 0,K={"*":{requireMention:y}},H=W?{channels:{whatsapp:{accounts:{[k]:{groups:K}}}}}:{channels:{whatsapp:{groups:K}}};await e.client.request("config.patch",{raw:JSON.stringify(H),baseHash:E.hash,note:`WhatsApp group mention → ${y?"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:$,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,k=(b==null?void 0:b.bindings)??[],A=we(e),E=A==null?void 0:A.agents.find(K=>K.id.endsWith("-admin")||K.id==="admin"),T=(E==null?void 0:E.id)??"admin",P=k.filter(K=>{var H;return((H=K.match)==null?void 0:H.channel)!=="imessage"}),D=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],W=[...P,...D];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:W}),baseHash:y.hash,note:"Enable iMessage (self-chat) for "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Z(e,!0),We(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await Z(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,A=((b==null?void 0:b.bindings)??[]).filter(E=>{var T;return((T=E.match)==null?void 0:T.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:A}),baseHash:y.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Z(e,!0),We(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,k=(b==null?void 0:b.bindings)??[],A=we(e),E=A==null?void 0:A.agents.find(W=>W.id.endsWith("-admin")||W.id==="admin"),T=(E==null?void 0:E.id)??"admin",P=k.filter(W=>{var K;return((K=W.match)==null?void 0:K.channel)!=="imessage"}),D=[{agentId:T,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,...D]}),baseHash:y.hash,note:"Reassign iMessage to "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Z(e,!0),We(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:y=>{var b,k,A,E;if(e.infoModalOpen=y,y==="remote-access"){const T=((b=e.tailscaleStatus)==null?void 0:b.tailnetUrl)??((k=e.tailscaleStatus)!=null&&k.hostname?`https://${e.tailscaleStatus.hostname}`:null);T&&!e.remoteAccessQrDataUrl&&e.client.request("qr.generate",{url:T}).then(P=>{e.remoteAccessQrDataUrl=(P==null?void 0:P.dataUrl)??null}).catch(()=>{})}else if(y==="public-chat"){const T=((A=e.tailscaleStatus)==null?void 0:A.publicUrl)??((E=e.tailscaleStatus)==null?void 0:E.tailnetUrl)??null,P=e.selectedWorkspace??null;if(T&&P){const D=`${T}/public/chat/${encodeURIComponent(P)}`;e.publicChatQrDataUrl||e.client.request("qr.generate",{url:D}).then(W=>{e.publicChatQrDataUrl=(W==null?void 0:W.dataUrl)??null}).catch(()=>{})}}},onInfoModalClose:()=>{e.infoModalOpen=null},remoteAccessQrDataUrl:e.remoteAccessQrDataUrl??null,publicChatQrDataUrl:e.publicChatQrDataUrl??null,publicChatFullUrl:(()=>{var k,A;const y=((k=e.tailscaleStatus)==null?void 0:k.publicUrl)??((A=e.tailscaleStatus)==null?void 0:A.tailnetUrl)??null,b=e.selectedWorkspace??null;return!y||!b?null:`${y}/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(y,b)=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Tl(e.client,y,b);const k=`${y} key saved`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}y==="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 y=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Nk(e.client,y);const b=`${y} 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(y,b)=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Ok(e.client,y,b);const k=`${y} ${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:y=>{e.authApiKeyInput=y},onAuthApiKeySubmit:async()=>{const y=e.authApiKeyInput.trim();if(y){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await Tl(e.client,"anthropic",y),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 y=e.selectedWorkspace??((b=e.workspaces[0])==null?void 0:b.name);return y?e.accessState.accounts.some(k=>k.id===y):!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:(y,b)=>{var A;const k=e.selectedWorkspace??((A=e.workspaces[0])==null?void 0:A.name);k&&e.handleAccountPinSave(k,y,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 y=(k=e.configSnapshot)==null?void 0:k.config,b=y==null?void 0:y.publicChat;return(b==null?void 0:b.enabled)===!0})(),publicChatAuthMode:(()=>{var T,P;const y=(T=e.configSnapshot)==null?void 0:T.config,b=y==null?void 0:y.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 y=(E=e.configSnapshot)==null?void 0:E.config,b=y==null?void 0:y.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 y=e.selectedWorkspace??"";if(y){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[y]){const P={publicChat:{greetings:{[y]:null}}};await e.client.request("config.patch",{raw:JSON.stringify(P),baseHash:k.hash,note:`Public chat greeting → disabled (${y})`,skipRestart:!0})}else{const P=await e.client.request("public.greeting.generate",{accountId:y});if(P!=null&&P.ok&&P.greeting){const D=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[y]:P.greeting}}}),baseHash:D.hash,note:`Public chat greeting → enabled (${y})`,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 y=>{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]:y}}}),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 y=e.selectedWorkspace??"";if(y){e.publicChatGreetingBusy=!0;try{const b=await e.client.request("public.greeting.generate",{accountId:y});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:{[y]:b.greeting}}}),baseHash:k.hash,note:`Public chat greeting regenerated (${y})`,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 y;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get"),k=b.config,A=((y=k==null?void 0:k.publicChat)==null?void 0:y.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 y=>{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:y}}}}),baseHash:k.hash,note:`Public chat auth → ${y}`,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 y=(k=e.configSnapshot)==null?void 0:k.config,b=(A=y==null?void 0:y.publicChat)==null?void 0:A.email;return(b==null?void 0:b.from)??""})(),publicChatEmailBusy:e.publicChatEmailBusy,publicChatVerifyMethods:(()=>{var T,P;const y=(T=e.configSnapshot)==null?void 0:T.config,b=y==null?void 0:y.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(y,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:y||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 y=e.selectedWorkspace;return y?((k=Fe()[y])==null?void 0:k.accentColor)??"":""})(),brandBackgroundColor:(()=>{var k;const y=e.selectedWorkspace;return y?((k=Fe()[y])==null?void 0:k.backgroundColor)??"":""})(),brandHasLogo:(()=>{var k;const y=e.selectedWorkspace;return y?!!((k=Fe()[y])!=null&&k.logoUrl):!1})(),agentSettingsOpen:e.agentSettingsOpen,agentSettingsAgents:(()=>{var A,E;const y=we(e);if(!y)return[];const b=(A=e.configSnapshot)==null?void 0:A.config,k=(E=b==null?void 0:b.agents)==null?void 0:E.list;return y.agents.map(T=>{var H;const P=Array.isArray(k)?k.find(ke=>ke.id===T.id):void 0,D=P==null?void 0:P.model,W=typeof D=="string"?D:(D==null?void 0:D.primary)??null,K=T.id.endsWith("-admin")||T.id==="admin";return{id:T.id,label:K?"Admin":"Public",model:(W==null?void 0:W.trim())||null,thinkingLevel:((H=P==null?void 0:P.thinkingLevel)==null?void 0:H.trim())||null}})})(),agentSettingsModelCatalog:e.chatModelCatalog??[],memoryProvider:(()=>{var k,A,E;const y=(k=e.configSnapshot)==null?void 0:k.config,b=(E=(A=y==null?void 0:y.agents)==null?void 0:A.defaults)==null?void 0:E.memorySearch;return typeof(b==null?void 0:b.provider)=="string"&&b.provider?b.provider:"local"})(),memoryFallback:(()=>{var k,A,E;const y=(k=e.configSnapshot)==null?void 0:k.config,b=(E=(A=y==null?void 0:y.agents)==null?void 0:A.defaults)==null?void 0:E.memorySearch;return typeof(b==null?void 0:b.fallback)=="string"&&b.fallback?b.fallback:"none"})(),onAgentSettingsToggle:()=>{e.agentSettingsOpen=!e.agentSettingsOpen},onAgentModelChange:async(y,b)=>{try{const k=await e.client.request("config.get"),A=k.config,E=(A==null?void 0:A.agents)??{},T=Array.isArray(E.list)?[...E.list]:[],P=T.findIndex(W=>W.id===y);if(b)P>=0?T[P]={...T[P],model:b}:T.push({id:y,model:b});else if(P>=0){const{model:W,...K}=T[P];Object.keys(K).length<=1?T.splice(P,1):T[P]=K}const D=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(D),baseHash:k.hash,note:`Agent ${y} model → ${b||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Agent model change failed:",k)}},onAgentThinkingChange:async(y,b)=>{try{const k=await e.client.request("config.get"),A=k.config,E=(A==null?void 0:A.agents)??{},T=Array.isArray(E.list)?[...E.list]:[],P=T.findIndex(K=>K.id===y),D=b==="off"?void 0:b;if(D)P>=0?T[P]={...T[P],thinkingLevel:D}:T.push({id:y,thinkingLevel:D});else if(P>=0){const{thinkingLevel:K,...H}=T[P];Object.keys(H).length<=1?T.splice(P,1):T[P]=H}const W=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(W),baseHash:k.hash,note:`Agent ${y} thinking → ${D||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Agent thinking change failed:",k)}},onMemoryProviderChange:async y=>{try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({agents:{defaults:{memorySearch:{provider:y}}}}),baseHash:b.hash,note:`Memory search provider → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Memory provider change failed:",b)}},onMemoryFallbackChange:async y=>{try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({agents:{defaults:{memorySearch:{fallback:y}}}}),baseHash:b.hash,note:`Memory search fallback → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Memory fallback change failed:",b)}},brandingBusy:e.brandingBusy,brandingExpanded:e.brandingExpanded,onBrandingToggle:()=>{e.brandingExpanded=!e.brandingExpanded},onBrandAccentColorChange:async y=>{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,T=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=T.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...T,brand:{...P,accentColor:y}}}}),baseHash:A.hash,note:`Brand accent → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const D=Fe();D[b]||(D[b]={}),D[b].accentColor=y,Tn(b)}catch(A){console.error("Brand accent change failed:",A)}finally{e.brandingBusy=!1}}},onBrandBackgroundColorChange:async y=>{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,T=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=T.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...T,brand:{...P,backgroundColor:y}}}}),baseHash:A.hash,note:`Brand background → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const D=Fe();D[b]||(D[b]={}),D[b].backgroundColor=y,Tn(b)}catch(A){console.error("Brand background change failed:",A)}finally{e.brandingBusy=!1}}},onBrandLogoUpload:async y=>{const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const k=await y.arrayBuffer(),A=new Uint8Array(k);let E="";for(let D=0;D<A.length;D++)E+=String.fromCharCode(A[D]);const T=btoa(E);await e.client.request("brand.uploadLogo",{workspace:b,data:T,mimeType:y.type});const P=Fe();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 y=e.selectedWorkspace;if(!(!y||e.brandingBusy)){e.brandingBusy=!0;try{await e.client.request("brand.removeLogo",{workspace:y});const b=Fe();b[y]&&delete b[y].logoUrl}catch(b){console.error("Brand logo remove failed:",b)}finally{e.brandingBusy=!1}}},onBrandReset:async()=>{var b;const y=e.selectedWorkspace;if(!(!y||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[y])??{},{brand:T,...P}=E;await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[y]:{...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:y})}catch{}const D=Fe();delete D[y],Tn(y)}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,M();try{const y=await e.client.request("tailscale.enable");y.authUrl?(kt&&(clearInterval(kt),kt=null),e.tailscaleConnectProgress=100,e.tailscaleConnectMessage="Waiting for authentication...",e.tailscaleAuthUrl=y.authUrl,Mi=setInterval(async()=>{try{const b=await e.client.request("tailscale.status");e.tailscaleStatus=b,e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,b.loggedIn&&(Kt(),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(()=>{Kt(),e.tailscaleBusy&&(e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)},3e5)):y.alreadyLoggedIn?(Kt(),e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1):(Kt(),e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)}catch(y){console.error("Tailscale enable failed:",y),Kt(),e.tailscaleError=y.message||"Failed to enable Remote Access",e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1}}},onTailscaleErrorDismiss:()=>{e.tailscaleError=null},onTailscaleServeEnable:async()=>{var y;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;(y=k.payload)!=null&&y.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(y){console.error("Tailscale serve disable failed:",y)}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelEnable:async()=>{var y;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;(y=k.payload)!=null&&y.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(y){console.error("Tailscale funnel disable failed:",y)}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 y;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&&((y=b.networks)!=null&&y.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 y=e.wifiSelectedSsid;e.wifiBusy=!0,e.wifiError=null;try{const k=await e.client.request("wifi.connect",{ssid:y,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 T=A.networks.find(P=>P.active)||A.networks.find(P=>P.ssid===E.ssid);T&&(E.signal=T.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 y=await e.client.request("wifi.status");e.wifiStatus=y}catch(y){console.error("WiFi disconnect failed:",y),e.wifiError=y.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 y=await e.client.request("wifi.status");e.wifiStatus=y}catch(y){console.error("WiFi forget failed:",y),e.wifiError=y.message||"Failed to forget network"}finally{e.wifiBusy=!1}}},onWifiDismiss:()=>{e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null},onWifiSelectSsid:y=>{e.wifiSelectedSsid=y,e.wifiPassword="",e.wifiError=null},onWifiPasswordChange:y=>{e.wifiPassword=y},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:y=>{e.networkPortInput=y,e.networkError=null,e.networkSuccess=null},onNetworkHostnameChange:y=>{e.networkHostnameInput=y,e.networkError=null,e.networkSuccess=null},onNetworkSave:async()=>{if(e.networkBusy)return;e.networkBusy=!0,e.networkError=null,e.networkSuccess=null;const y=e.networkPortInput.trim(),b=Number.parseInt(y,10),k=e.networkHostnameInput.trim();if(!y||!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 T={};A&&(T.gateway={port:b}),E&&(T.discovery={bonjourHostname:k});const P=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify(T),baseHash:P.hash,note:[A?`Port → ${b}`:null,E?`Hostname → ${k}`:null].filter(Boolean).join(", "),restartDelayMs:2e3}),e.networkSuccess="Saved — redirecting...";const D=window.location.protocol,W=E?`${k}.local`:window.location.hostname,K=A?b:e.networkPort,H=`${D}//${W}:${K}/setup`;setTimeout(()=>{window.location.href=H},1500)}catch(T){console.error("Network save failed:",T),e.networkError=T.message||"Failed to save network settings",e.networkBusy=!1}},wsProps:r0(e)})}if(e.filesPage){const u=c0(e);return wg({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:()=>{rn(e,u),us(e,u)},onReindex:()=>Lf(e,u),onSelectFile:p=>{e.filesPendingDeletePath=null,Cf(e,p,u)},onToggleSelectFile:p=>Ef(e,p,u),onToggleDir:p=>Df(e,p),onUpload:(p,v)=>Mf(e,p,v,u),onNewFolder:(p,v)=>Pf(e,p,v,u),onDownload:p=>ld(e,p,u),onBulkDownload:()=>Tf(e,u),onDelete:p=>{e.filesPendingDeletePath=null,If(e,p,u)},pendingDeletePath:e.filesPendingDeletePath,onArmDelete:p=>{e.filesPendingDeletePath=p||null},onMoveToDir:(p,v)=>_f(e,p,v,u),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:p=>{const v=e.filesSearchAgentId??u;Bf(e,p,v)},onSearchAgentChange:p=>{e.filesSearchAgentId=p},onSearchClear:()=>{Nf(e)},onSearchQueryChange:p=>{e.filesSearchQuery=p}})}if(e.browserPage)return fg({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:()=>_k(e),onStop:()=>Mk(e),onToggleInput:()=>Ik(e),onToggleFullscreen:()=>Rk(e),onCompleteHandoff:()=>Pk(e),onCanvasMouseDown:u=>{const v=u.target.getBoundingClientRect(),S=Bn().translateCoordinates(u.clientX-v.left,u.clientY-v.top);fo(e,"mousePressed",S.x,S.y,u.button===2?"right":u.button===1?"middle":"left")},onCanvasMouseUp:u=>{const v=u.target.getBoundingClientRect(),S=Bn().translateCoordinates(u.clientX-v.left,u.clientY-v.top);fo(e,"mouseReleased",S.x,S.y)},onCanvasMouseMove:u=>{const p=Bn();if(p.shouldThrottleMouseMove())return;const $=u.target.getBoundingClientRect(),S=p.translateCoordinates(u.clientX-$.left,u.clientY-$.top);fo(e,"mouseMoved",S.x,S.y)},onCanvasKeyDown:u=>{let p=0;u.altKey&&(p|=1),u.ctrlKey&&(p|=2),u.metaKey&&(p|=4),u.shiftKey&&(p|=8),go(e,"keyDown",u.key,{code:u.code,modifiers:p||void 0}),u.key.length===1&&go(e,"char",u.key,{text:u.key})},onCanvasKeyUp:u=>{go(e,"keyUp",u.key,{code:u.code})}});if(e.adminsPage){const u=l0(e),p=Ka(e);return cm({connected:e.connected,wsProps:Sn(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>bs(e,u),onAdd:v=>{Ru(e,v,u,p).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:v=>Lu(e,v,u,p),onNewPhoneChange:v=>e.handleAdminsNewPhoneChange(v)})}if(e.contactsPage){const u=d0(e);return gm({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:()=>It(e,u),onAdd:(p,v)=>Du(e,p,v,u),onDelete:p=>Bu(e,p,u),onSetField:(p,v,$)=>Qo(e,p,v,$,u),onDeleteField:(p,v)=>Nu(e,p,v,u),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:()=>It(e,u),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,u),e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue="")}})}if(e.chatPage){const u=e.connected?null:"Disconnected from gateway.",p=Bl(e),v=e.chatAvatarUrl??p??null,$=(()=>{var y;const S=(y=e.configSnapshot)==null?void 0:y.config,M=S==null?void 0:S.publicChat;return(M==null?void 0:M.enabled)===!0})();return mw({connected:e.connected,wsProps:Sn(e),publicChatEnabled:$,publicChatAccountId:e.selectedWorkspace??void 0,chatPageTab:e.chatPageTab??"chat",onChatPageTabChange:S=>{if(e.chatPageTab=S,S==="whatsapp"&&!e.waLoading&&e.waConversations.length===0){const M=Ii(e);bu(M).then(()=>e.requestUpdate())}},whatsappProps:y0(e),sessionKey:e.sessionKey,onSessionKeyChange:S=>{const M=e.selectedWorkspace??"";xo(),Wn(M,e.sessionKey,e.chatMessage),e.sessionKey=S,e.chatMessage=zn(M,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(),Jt(e),Mo(e)},showThinking:e.settings.chatShowThinking??!1,verboseLevel:e.chatVerboseLevel,suggestions:e.chatSuggestions,onSuggestionClick:S=>{e.chatMessage=S,e.chatSuggestions=[],e.handleSendChat()},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:u,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>{e.resetToolStream();const S=Math.max(e.chatMessages.length+10,nn);return Promise.all([Jt(e,{limit:S}),Mo(e)])},onToggleFocusMode:()=>{},onChatScroll:S=>e.handleChatScroll(S),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:S=>{e.chatMessage=S,kr(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?mk({connected:e.connected,wsProps:Sn(e),activeTab:e.advancedTab,onTabChange:u=>{e.advancedTab=u,u==="cron"&&e.loadCron(),u==="skills"&&Pe(e,{clearMessages:!0}),u==="opening-hours"&&za(e),u==="logs"&&(e.logsSubTab==="session"?Pn(e,{reset:!0}):bt(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(u=>u.id):((l=e.channelsSnapshot)==null?void 0:l.channelOrder)??[],channelLabels:((d=e.channelsSnapshot)==null?void 0:d.channelLabels)??{},channelMeta:((h=e.channelsSnapshot)==null?void 0:h.channelMeta)??[],agentIds:(()=>{var p;const u=we(e);return((p=u==null?void 0:u.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:u=>{e.cronDetailJobId=u.id,Ao(e,u.id)},onDetailClose:()=>{e.cronDetailJobId=null},onEdit:u=>{e.cronForm=Ah(u),e.cronEditJobId=u.id,e.cronDetailJobId=null},onEditSave:()=>{const u=e.cronEditJobId;u&&Ch(e,u).then(()=>{e.cronEditJobId=null})},onFormChange:u=>e.cronForm={...e.cronForm,...u},onRefresh:()=>e.loadCron(),onAdd:()=>{wh(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(u,p)=>kh(e,u,p),onRun:u=>xh(e,u),onRemove:u=>{e.cronPendingDeleteId=null,Sh(e,u)},pendingDeleteId:e.cronPendingDeleteId,onArmDelete:u=>{e.cronPendingDeleteId=u||null},onLoadRuns:u=>Ao(e,u),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:u=>e.skillsFilter=u,onTypeFilterChange:u=>e.skillsTypeFilter=u,onRefresh:()=>Pe(e,{clearMessages:!0}),onToggle:(u,p)=>Oc(e,u,p),onEdit:(u,p)=>Nc(e,u,p),onSaveKey:u=>Fc(e,u),onInstall:(u,p,v)=>Uc(e,u,p,v),onViewDetail:u=>Wc(e,u),onDetailClose:()=>zc(e),onDetailTab:u=>Kc(e,u),onAddOpen:()=>Hc(e),onAddClose:()=>qc(e),onImportDraft:u=>jc(e,u),onInstallDraft:u=>Gc(e,u),onDeleteDraft:u=>Vc(e,u),onAddSave:()=>fa(e),onAddFormUpdate:(u,p)=>{e.skillAddForm={...e.skillAddForm,[u]:p}},onAlwaysActiveToggle:(u,p)=>Zc(e,u,p),onDelete:u=>td(e,u),onEditSkill:u=>Qc(e,u),onEditDetail:u=>Jc(e,u),onRefUpdate:(u,p)=>Yc(e,u,p),onEditTab:u=>Xc(e,u),agentFilter:e.skillsAgentFilter,onAgentFilterChange:u=>e.skillsAgentFilter=u,onAgentsChange:(u,p)=>ed(e,u,p)},logsProps:{logsSubTab:e.logsSubTab,isAdmin:e.accessState.master||!e.accessState.hasPins,onSubTabChange:u=>{e.logsSubTab=u,u==="session"?Pn(e,{reset:!0}):bt(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:u=>e.sessionLogsFilterText=u,onTypeToggle:(u,p)=>{const v=e;v.sessionLogsTypeFilters={...v.sessionLogsTypeFilters,[u]:p}},onAgentToggle:(u,p)=>{const v=e;v.sessionLogsAgentFilters={...v.sessionLogsAgentFilters,[u]:p}},onToggleAutoFollow:u=>e.sessionLogsAutoFollow=u,onToggleChips:()=>{const u=e;u.sessionLogsChipsExpanded=!u.sessionLogsChipsExpanded},onToggleExpand:u=>{const p=e,v=new Set(p.sessionLogsExpandedIds);v.has(u)?v.delete(u):v.add(u),p.sessionLogsExpandedIds=v,p.requestUpdate()},onRefresh:()=>{Pn(e,{reset:!0})},onExport:(u,p)=>e.exportSessionLogs(u,p),onScroll:u=>e.handleSessionLogsScroll(u)},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,selectedDate:e.logsDate,availableDates:e.logsAvailableDates,onDateChange:u=>{e.logsDate=u,bt(e,{reset:!0})},onFilterTextChange:u=>e.logsFilterText=u,onLevelToggle:(u,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[u]:p}},onToggleAutoFollow:u=>e.logsAutoFollow=u,onToggleChips:()=>{const u=e;u.logsChipsExpanded=!u.logsChipsExpanded},onRefresh:()=>bt(e,{reset:!0}),onExport:(u,p)=>e.exportSessionLogs(u,p),onScroll:u=>e.handleLogsScroll(u)},openingHoursProps:{loading:e.openingHoursLoading,error:e.openingHoursError,busy:e.openingHoursBusy,form:e.openingHoursForm,onFormChange:u=>{const p=e;p.openingHoursForm={...p.openingHoursForm,...u}},onDayChange:(u,p,v)=>{const $=e,S={...$.openingHoursForm.days};S[u]={...S[u],[p]:v},$.openingHoursForm={...$.openingHoursForm,days:S}},onAddClosedDate:u=>{const p=e;p.openingHoursForm.closedDates.includes(u)||(p.openingHoursForm={...p.openingHoursForm,closedDates:[...p.openingHoursForm.closedDates,u].sort()})},onRemoveClosedDate:u=>{const p=e;p.openingHoursForm={...p.openingHoursForm,closedDates:p.openingHoursForm.closedDates.filter(v=>v!==u)}},onSave:()=>{Pu(e)}}}):(window.location.replace("/chat"),c``)}function b0(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 Nl(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function w0(e,t,n){return c`
4900
4900
  <div class="audit-modal-overlay" @click=${s=>{s.target.classList.contains("audit-modal-overlay")&&n()}}>
4901
4901
  <div class="audit-modal-card">
4902
4902
  <div class="audit-modal-header">
@@ -4912,7 +4912,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4912
4912
  ${e.map(s=>c`
4913
4913
  <div class="audit-modal-entry">
4914
4914
  <div class="audit-modal-entry-path">
4915
- <span class="audit-modal-folder audit-modal-folder--${Bl(s.path)}">${Bl(s.path)}</span>
4915
+ <span class="audit-modal-folder audit-modal-folder--${Nl(s.path)}">${Nl(s.path)}</span>
4916
4916
  <a href="/files" class="audit-modal-path-link">${s.path}</a>
4917
4917
  </div>
4918
4918
  <div class="audit-modal-entry-meta">
@@ -4928,7 +4928,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4928
4928
  `}
4929
4929
  </div>
4930
4930
  </div>
4931
- `}const k0={trace:!1,debug:!1,info:!0,warn:!0,error:!0,fatal:!0},x0={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 $0(e){e.basePath=Gf();const t=Xe();Gl(t.accentColor),Vl(t.backgroundColor);const n=document.querySelector('link[rel="icon"]');if(n&&(n.href=t.iconUrl),window.scrollTo(0,0),Uf(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}`,Oe(e);return}if(e.setup){document.title=`${t.name} Setup`,Oe(e);return}if(e.filesPage){document.title=`${t.name} Files`,zf(e),Oe(e);return}if(e.browserPage){document.title=`${t.name} Browser`,Oe(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,Oe(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,Oe(e);return}if(e.chatPage){document.title=`${t.name} Chat`,Oe(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,Oe(e);return}Yf(e,!0),Vf(e),Qf(e),window.addEventListener("popstate",e.popStateHandler),Hf(e),Oe(e),Of(e),e.tab==="logs"&&(e.logsSubTab==="session"?ga(e):ha(e)),e.tab==="debug"&&ya(e)}function S0(e){mh(e)}function A0(e){var t;window.removeEventListener("popstate",e.popStateHandler),Ff(e),fa(e),ma(e),va(e),Wf(e),Kf(e),Jf(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function C0(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",s=t.has("setupStep")&&e.setupStep==="setup";(n||i||s)&&e.handleAuthStatusCheck&&e.authConnected===null&&!e.authBusy&&e.handleAuthStatusCheck(),e.setupStep==="setup"&&t.has("setupStep")&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(a=>{e.channelsSnapshot=a,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(o=>{e.channelsSnapshot=o,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;sn(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&lc(e,t.has("tab")||t.has("logsAutoFollow"))}}function E0(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 T0(e,t,n){await ea(e,t,n),await Z(e,!0)}async function _0(e,t){await hc(e,t),await Z(e,!0)}async function M0(e,t){await fc(e,t),await Z(e,!0)}async function P0(e,t){await gc(e,t)}async function I0(e,t){await mc(e,t)}async function R0(e){await bh(e),await We(e),await Z(e,!0)}async function L0(e){await We(e),await Z(e,!0)}function D0(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 Ou(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 Fu(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function B0(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=E0(n??void 0)}function N0(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function O0(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function F0(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function U0(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Ou(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(Fu(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:D0(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 Z(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function W0(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Ou(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(Fu(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 Z(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function z0(e){if(!e.client)return;const t=e.authRefreshTokenInput.trim();if(t){e.authRefreshTokenBusy=!0,e.authRefreshTokenError=null;try{const n=await e.client.request("auth.importRefreshToken",{refreshToken:t});e.authConnected=n.connected,e.authExpiresIn=n.expiresIn??null,e.authMessage=n.message??null,e.authRefreshToken=t,e.authRefreshTokenInput="",e.claudeAuthModalOpen=!1}catch(n){e.authRefreshTokenError=n instanceof Error?n.message:"Failed to import token"}finally{e.authRefreshTokenBusy=!1}}}async function K0(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,e.authRefreshToken=t.refreshToken??null}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to check auth status"}finally{e.authBusy=!1}}}async function H0(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 q0(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 j0(e,t){e.authCodeInput=t}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="setup"):(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="setup"):(e.licenseValid=null,e.licenseMessage=n,e.setupStep="license")}finally{e.licenseBusy=!1}}}async function V0(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="setup"},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 Q0(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 J0(e,t){e.licenseKey=t}async function Y0(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 X0(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 Z0=Object.defineProperty,ex=Object.getOwnPropertyDescriptor,g=(e,t,n,i)=>{for(var s=i>1?void 0:i?ex(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&&Z0(t,n,s),s};const yo=Sp();function tx(){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 nx(){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 ix(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function sx(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function ox(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function ax(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function rx(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function lx(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let f=class extends Gt{constructor(){super(...arguments),this.settings=Ls(),this.password="",this.tab="chat",this.onboarding=tx(),this.setup=nx(),this.filesPage=ix(),this.browserPage=sx(),this.adminsPage=ox(),this.contactsPage=ax(),this.chatPage=rx(),this.advancedPage=lx(),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=yc,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=yo.name,this.assistantAvatar=yo.avatar,this.assistantAgentId=yo.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.chatModelCatalog=[],this.chatVerboseLevel=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=`{
4931
+ `}const k0={trace:!1,debug:!1,info:!0,warn:!0,error:!0,fatal:!0},x0={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 $0(e){e.basePath=Gf();const t=Xe();Vl(t.accentColor),Ql(t.backgroundColor);const n=document.querySelector('link[rel="icon"]');if(n&&(n.href=t.iconUrl),window.scrollTo(0,0),Uf(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}`,Oe(e);return}if(e.setup){document.title=`${t.name} Setup`,Oe(e);return}if(e.filesPage){document.title=`${t.name} Files`,zf(e),Oe(e);return}if(e.browserPage){document.title=`${t.name} Browser`,Oe(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,Oe(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,Oe(e);return}if(e.chatPage){document.title=`${t.name} Chat`,Oe(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,Oe(e),zi(e),Wi(e);return}Yf(e,!0),Vf(e),Qf(e),window.addEventListener("popstate",e.popStateHandler),Hf(e),Oe(e),Of(e),e.tab==="logs"&&(e.logsSubTab==="session"?zi(e):Wi(e)),e.tab==="debug"&&va(e)}function S0(e){mh(e)}function A0(e){var t;window.removeEventListener("popstate",e.popStateHandler),Ff(e),ma(e),ya(e),ba(e),Wf(e),Kf(e),Jf(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function C0(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",s=t.has("setupStep")&&e.setupStep==="setup";(n||i||s)&&e.handleAuthStatusCheck&&e.authConnected===null&&!e.authBusy&&e.handleAuthStatusCheck(),e.setupStep==="setup"&&t.has("setupStep")&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(a=>{e.channelsSnapshot=a,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(o=>{e.channelsSnapshot=o,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;sn(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&So(e,t.has("tab")||t.has("logsAutoFollow")),(t.has("sessionLogsEntries")||t.has("sessionLogsAutoFollow"))&&e.sessionLogsAutoFollow&&e.logsAtBottom&&So(e,t.has("sessionLogsAutoFollow"))}}function E0(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 T0(e,t,n){await ia(e,t,n),await Z(e,!0)}async function _0(e,t){await hc(e,t),await Z(e,!0)}async function M0(e,t){await fc(e,t),await Z(e,!0)}async function P0(e,t){await gc(e,t)}async function I0(e,t){await mc(e,t)}async function R0(e){await bh(e),await We(e),await Z(e,!0)}async function L0(e){await We(e),await Z(e,!0)}function D0(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 Ou(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 Fu(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function B0(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=E0(n??void 0)}function N0(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function O0(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function F0(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function U0(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Ou(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(Fu(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:D0(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 Z(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function W0(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Ou(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(Fu(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 Z(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function z0(e){if(!e.client)return;const t=e.authRefreshTokenInput.trim();if(t){e.authRefreshTokenBusy=!0,e.authRefreshTokenError=null;try{const n=await e.client.request("auth.importRefreshToken",{refreshToken:t});e.authConnected=n.connected,e.authExpiresIn=n.expiresIn??null,e.authMessage=n.message??null,e.authRefreshToken=t,e.authRefreshTokenInput="",e.claudeAuthModalOpen=!1}catch(n){e.authRefreshTokenError=n instanceof Error?n.message:"Failed to import token"}finally{e.authRefreshTokenBusy=!1}}}async function K0(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,e.authRefreshToken=t.refreshToken??null}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to check auth status"}finally{e.authBusy=!1}}}async function H0(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 q0(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 j0(e,t){e.authCodeInput=t}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="setup"):(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="setup"):(e.licenseValid=null,e.licenseMessage=n,e.setupStep="license")}finally{e.licenseBusy=!1}}}async function V0(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="setup"},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 Q0(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 J0(e,t){e.licenseKey=t}async function Y0(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 X0(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 Z0=Object.defineProperty,ex=Object.getOwnPropertyDescriptor,g=(e,t,n,i)=>{for(var s=i>1?void 0:i?ex(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&&Z0(t,n,s),s};const bo=Sp();function tx(){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 nx(){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 ix(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function sx(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function ox(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function ax(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function rx(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function lx(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let f=class extends Gt{constructor(){super(...arguments),this.settings=Bs(),this.password="",this.tab="chat",this.onboarding=tx(),this.setup=nx(),this.filesPage=ix(),this.browserPage=sx(),this.adminsPage=ox(),this.contactsPage=ax(),this.chatPage=rx(),this.advancedPage=lx(),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=yc,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=bo.name,this.assistantAvatar=bo.avatar,this.assistantAgentId=bo.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.chatModelCatalog=[],this.chatVerboseLevel=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=`{
4932
4932
  }
4933
- `,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.agentSettingsOpen=!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.authRefreshToken=null,this.claudeAuthModalOpen=!1,this.authRefreshTokenInput="",this.authRefreshTokenBusy=!1,this.authRefreshTokenError=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={...x0},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.openingHoursLoading=!1,this.openingHoursError=null,this.openingHoursBusy=!1,this.openingHoursForm=Ua(),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.skillsAgentFilter="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.chatPageTab="chat",this.waConversations=[],this.waSelectedJid=null,this.waMessages=[],this.waGroupInfo=null,this.waLoading=!1,this.waMessagesLoading=!1,this.waSearchQuery="",this.waComposeDraft="",this.waSending=!1,this.waLastError=null,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={...k0},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.logsDate=null,this.logsAvailableDates=[],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=()=>Xf(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null,this._beforeUnloadHandler=()=>{var t;wo();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(),$0(this),window.addEventListener("beforeunload",this._beforeUnloadHandler)}firstUpdated(){S0(this)}disconnectedCallback(){window.removeEventListener("beforeunload",this._beforeUnloadHandler),this.stopEmbeddingPoll(),A0(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){C0(this,e)}connect(){Oe(this)}handleChatScroll(e){ch(this,e)}handleLogsScroll(e){uh(this,e)}handleSessionLogsScroll(e){ph(this,e)}exportLogs(e,t){fh(e,t)}exportSessionLogs(e,t){gh(e,t)}resetToolStream(){Zo(this)}resetChatScroll(){hh(this)}async loadAssistantIdentity(){await qo(this)}applySettings(e){at(this,e)}setTab(e){qf(this,e)}setTheme(e,t){jf(this,e,t)}async loadOverview(){await pd(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=this.selectedWorkspace??void 0,this.cronForm={...this.cronForm,accountId:this.selectedWorkspace??void 0},await hd(this)}async handleAbortChat(){await gd(this)}removeQueuedMessage(e){ng(this,e)}async handleSendChat(e,t){await ig(this,e,t)}async handleWhatsAppStart(e,t){await T0(this,e,t)}async handleWhatsAppWait(e){await _0(this,e)}async handleWhatsAppLogout(e){await M0(this,e)}async handleAddWhatsAppAccount(e){await P0(this,e)}async handleRemoveWhatsAppAccount(e){await I0(this,e)}async handleAccessCheck(){await Cr(this)}async handlePinSubmit(e,t){await _h(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await Mh(this,e)}async handleLogout(){await Ih(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 Cr(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 V0(this)}async handleLicenseRemove(){await Q0(this)}handleLicenseKeyChange(e){J0(this,e)}async handleAuthStatusCheck(){await K0(this)}async handleAuthStart(){await H0(this)}async handleAuthSubmitCode(e){await q0(this,e)}handleAuthCodeChange(e){j0(this,e)}handleClaudeAuthModalOpen(){this.claudeAuthModalOpen=!0}handleClaudeAuthModalClose(){this.claudeAuthModalOpen=!1,this.authUrl=null,this.authRefreshTokenInput="",this.authRefreshTokenError=null}async handleImportRefreshToken(){await z0(this)}async handleGatewayHealthCheck(){await Y0(this)}async handleGatewayRestart(){await X0(this)}async handleUpdateCheck(){await Eu(this)}async handleUpdateRun(){await Fk(this)}handleUpdateDismissResult(){zk(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 ae(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Lr);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){ae(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Lr);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await ad(this)}async clearAudit(){await Af(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,rn(this,t),cs(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();ae(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>o0);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())}ae(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this).then(()=>{sn(this,!0)})})}async handleLoadOlderChat(){if(this.chatLoadingOlder||!this.chatHistoryHasMore)return;const e=dh(this),{loadOlderChatHistory:t}=await ae(async()=>{const{loadOlderChatHistory:i}=await Promise.resolve().then(()=>Oi);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.selectedWorkspace&&this.loadCron(),this.advancedTab==="opening-hours"&&ae(async()=>{const{loadOpeningHours:n}=await Promise.resolve().then(()=>i0);return{loadOpeningHours:n}},void 0,import.meta.url).then(({loadOpeningHours:n})=>{n(this)}),this.advancedTab==="logs"&&(this.logsSubTab==="session"?ae(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>od);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):ae(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>Nh);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&ae(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>vf);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await R0(this)}async handleChannelConfigReload(){await L0(this)}handleNostrProfileEdit(e,t){B0(this,e,t)}handleNostrProfileCancel(){N0(this)}handleNostrProfileFieldChange(e,t){O0(this,e,t)}async handleNostrProfileSave(){await U0(this)}async handleNostrProfileImport(){await W0(this)}handleNostrProfileToggleAdvanced(){F0(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;ae(async()=>{const{loadContacts:t}=await Promise.resolve().then(()=>a0);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 ae(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 ae(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>ki);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await ae(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>Eh);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 ae(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 ae(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){wo(),this.selectedWorkspace&&Wn(this.selectedWorkspace,this.sessionKey,this.chatMessage),this.selectedWorkspace=e,this.publicChatQrDataUrl=null,localStorage.setItem("taskmaster-selected-workspace",e),Tn(e),br(e),this.settings=Ls(),this.chatMessage=zn(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.waConversations=[],this.waSelectedJid=null,this.waMessages=[],this.waGroupInfo=null,this.waLastError=null,this.waSearchQuery="",this.waComposeDraft="",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.chatPageTab==="whatsapp"&&!this.waLoading&&this.waConversations.length===0&&this.reloadWhatsAppConversations()):this.advancedPage&&this.handleAdvancedLoad()}async reloadWhatsAppConversations(){if(!(!this.client||!this.connected)){this.waLoading=!0,this.waLastError=null;try{const e=this.getSelectedWorkspaceInfo(),t=e==null?void 0:e.whatsappAccountId,n=await this.client.request("whatsapp.conversations",{accountId:t});this.waConversations=n.conversations}catch(e){this.waLastError=String(e)}finally{this.waLoading=!1}}}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),br(this.selectedWorkspace),this.settings=Ls(),this.chatMessage=zn(this.selectedWorkspace,this.settings.sessionKey),this.reloadCurrentPageData()}render(){return c`${v0(this)}${this.auditModalOpen?w0(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):w}`}};g([m()],f.prototype,"settings",2);g([m()],f.prototype,"password",2);g([m()],f.prototype,"tab",2);g([m()],f.prototype,"onboarding",2);g([m()],f.prototype,"setup",2);g([m()],f.prototype,"filesPage",2);g([m()],f.prototype,"browserPage",2);g([m()],f.prototype,"adminsPage",2);g([m()],f.prototype,"contactsPage",2);g([m()],f.prototype,"chatPage",2);g([m()],f.prototype,"advancedPage",2);g([m()],f.prototype,"advancedTab",2);g([m()],f.prototype,"publicChat",2);g([m()],f.prototype,"publicChatConfig",2);g([m()],f.prototype,"publicChatSessionKey",2);g([m()],f.prototype,"publicChatAuthenticated",2);g([m()],f.prototype,"publicChatAuthStep",2);g([m()],f.prototype,"connected",2);g([m()],f.prototype,"accessState",2);g([m()],f.prototype,"theme",2);g([m()],f.prototype,"themeResolved",2);g([m()],f.prototype,"hello",2);g([m()],f.prototype,"lastError",2);g([m()],f.prototype,"eventLog",2);g([m()],f.prototype,"assistantName",2);g([m()],f.prototype,"assistantAvatar",2);g([m()],f.prototype,"assistantAgentId",2);g([m()],f.prototype,"sessionKey",2);g([m()],f.prototype,"chatLoading",2);g([m()],f.prototype,"chatSending",2);g([m()],f.prototype,"chatMessage",2);g([m()],f.prototype,"chatMessages",2);g([m()],f.prototype,"chatHistoryTotal",2);g([m()],f.prototype,"chatHistoryHasMore",2);g([m()],f.prototype,"chatLoadingOlder",2);g([m()],f.prototype,"chatToolMessages",2);g([m()],f.prototype,"chatStream",2);g([m()],f.prototype,"chatInterimText",2);g([m()],f.prototype,"chatSuggestions",2);g([m()],f.prototype,"chatStreamStartedAt",2);g([m()],f.prototype,"chatRunId",2);g([m()],f.prototype,"compactionStatus",2);g([m()],f.prototype,"chatAvatarUrl",2);g([m()],f.prototype,"chatModelCatalog",2);g([m()],f.prototype,"chatVerboseLevel",2);g([m()],f.prototype,"chatQueue",2);g([m()],f.prototype,"chatAttachments",2);g([m()],f.prototype,"sidebarOpen",2);g([m()],f.prototype,"sidebarContent",2);g([m()],f.prototype,"sidebarError",2);g([m()],f.prototype,"splitRatio",2);g([m()],f.prototype,"nodesLoading",2);g([m()],f.prototype,"nodes",2);g([m()],f.prototype,"devicesLoading",2);g([m()],f.prototype,"devicesError",2);g([m()],f.prototype,"devicesList",2);g([m()],f.prototype,"execApprovalsLoading",2);g([m()],f.prototype,"execApprovalsSaving",2);g([m()],f.prototype,"execApprovalsDirty",2);g([m()],f.prototype,"execApprovalsSnapshot",2);g([m()],f.prototype,"execApprovalsForm",2);g([m()],f.prototype,"execApprovalsSelectedAgent",2);g([m()],f.prototype,"execApprovalsTarget",2);g([m()],f.prototype,"execApprovalsTargetNodeId",2);g([m()],f.prototype,"execApprovalQueue",2);g([m()],f.prototype,"execApprovalBusy",2);g([m()],f.prototype,"execApprovalError",2);g([m()],f.prototype,"configLoading",2);g([m()],f.prototype,"configRaw",2);g([m()],f.prototype,"configRawOriginal",2);g([m()],f.prototype,"configValid",2);g([m()],f.prototype,"configIssues",2);g([m()],f.prototype,"configSaving",2);g([m()],f.prototype,"configApplying",2);g([m()],f.prototype,"updateRunning",2);g([m()],f.prototype,"applySessionKey",2);g([m()],f.prototype,"configSnapshot",2);g([m()],f.prototype,"configSchema",2);g([m()],f.prototype,"configSchemaVersion",2);g([m()],f.prototype,"configSchemaLoading",2);g([m()],f.prototype,"configUiHints",2);g([m()],f.prototype,"configForm",2);g([m()],f.prototype,"configFormOriginal",2);g([m()],f.prototype,"configFormDirty",2);g([m()],f.prototype,"configFormMode",2);g([m()],f.prototype,"configSearchQuery",2);g([m()],f.prototype,"configActiveSection",2);g([m()],f.prototype,"configActiveSubsection",2);g([m()],f.prototype,"channelsLoading",2);g([m()],f.prototype,"channelsSnapshot",2);g([m()],f.prototype,"channelsError",2);g([m()],f.prototype,"channelsLastSuccess",2);g([m()],f.prototype,"whatsappLoginMessage",2);g([m()],f.prototype,"whatsappLoginQrDataUrl",2);g([m()],f.prototype,"whatsappLoginConnected",2);g([m()],f.prototype,"whatsappBusy",2);g([m()],f.prototype,"whatsappActiveQrAccountId",2);g([m()],f.prototype,"whatsappPairedPhone",2);g([m()],f.prototype,"addingWhatsAppAccount",2);g([m()],f.prototype,"newWhatsAppAccountName",2);g([m()],f.prototype,"whatsappAccountError",2);g([m()],f.prototype,"whatsappAccountSaving",2);g([m()],f.prototype,"whatsappSettingsOpen",2);g([m()],f.prototype,"publicChatToggleBusy",2);g([m()],f.prototype,"publicChatGreetingBusy",2);g([m()],f.prototype,"publicChatEmailBusy",2);g([m()],f.prototype,"publicChatSettingsOpen",2);g([m()],f.prototype,"publicChatWidgetModalOpen",2);g([m()],f.prototype,"brandingBusy",2);g([m()],f.prototype,"agentSettingsOpen",2);g([m()],f.prototype,"brandingExpanded",2);g([m()],f.prototype,"tailscaleStatus",2);g([m()],f.prototype,"tailscaleBusy",2);g([m()],f.prototype,"tailscaleAuthUrl",2);g([m()],f.prototype,"tailscaleError",2);g([m()],f.prototype,"tailscaleServeEnableUrl",2);g([m()],f.prototype,"tailscaleFunnelEnableUrl",2);g([m()],f.prototype,"tailscaleDisableConfirm",2);g([m()],f.prototype,"tailscaleConnectProgress",2);g([m()],f.prototype,"tailscaleConnectMessage",2);g([m()],f.prototype,"tailscaleConnectSuccess",2);g([m()],f.prototype,"wifiStatus",2);g([m()],f.prototype,"wifiNetworks",2);g([m()],f.prototype,"wifiBusy",2);g([m()],f.prototype,"wifiError",2);g([m()],f.prototype,"wifiPassword",2);g([m()],f.prototype,"wifiSelectedSsid",2);g([m()],f.prototype,"networkPort",2);g([m()],f.prototype,"networkHostname",2);g([m()],f.prototype,"networkPortInput",2);g([m()],f.prototype,"networkHostnameInput",2);g([m()],f.prototype,"networkModalOpen",2);g([m()],f.prototype,"networkBusy",2);g([m()],f.prototype,"networkError",2);g([m()],f.prototype,"networkSuccess",2);g([m()],f.prototype,"wifiModalOpen",2);g([m()],f.prototype,"licenseKey",2);g([m()],f.prototype,"licenseBusy",2);g([m()],f.prototype,"licenseValid",2);g([m()],f.prototype,"licenseMessage",2);g([m()],f.prototype,"licenseTier",2);g([m()],f.prototype,"licenseDeviceId",2);g([m()],f.prototype,"licenseStoredKey",2);g([m()],f.prototype,"licenseRemoveConfirm",2);g([m()],f.prototype,"authConnected",2);g([m()],f.prototype,"authBusy",2);g([m()],f.prototype,"authMessage",2);g([m()],f.prototype,"authUrl",2);g([m()],f.prototype,"authCodeInput",2);g([m()],f.prototype,"authExpiresIn",2);g([m()],f.prototype,"authRefreshToken",2);g([m()],f.prototype,"claudeAuthModalOpen",2);g([m()],f.prototype,"authRefreshTokenInput",2);g([m()],f.prototype,"authRefreshTokenBusy",2);g([m()],f.prototype,"authRefreshTokenError",2);g([m()],f.prototype,"setupStep",2);g([m()],f.prototype,"gatewayHealthy",2);g([m()],f.prototype,"gatewayHealthLoading",2);g([m()],f.prototype,"gatewayHealthMessage",2);g([m()],f.prototype,"gatewayRestartBusy",2);g([m()],f.prototype,"updateAvailable",2);g([m()],f.prototype,"currentVersion",2);g([m()],f.prototype,"latestVersion",2);g([m()],f.prototype,"updateChecking",2);g([m()],f.prototype,"updateMessage",2);g([m()],f.prototype,"updateProgressSteps",2);g([m()],f.prototype,"updateLastResult",2);g([m()],f.prototype,"uninstallConfirm",2);g([m()],f.prototype,"uninstallBusy",2);g([m()],f.prototype,"uninstallDone",2);g([m()],f.prototype,"uninstallError",2);g([m()],f.prototype,"uninstallConfirmText",2);g([m()],f.prototype,"nostrProfileFormState",2);g([m()],f.prototype,"nostrProfileAccountId",2);g([m()],f.prototype,"presenceLoading",2);g([m()],f.prototype,"presenceEntries",2);g([m()],f.prototype,"presenceError",2);g([m()],f.prototype,"presenceStatus",2);g([m()],f.prototype,"agentsLoading",2);g([m()],f.prototype,"agentsList",2);g([m()],f.prototype,"agentsError",2);g([m()],f.prototype,"sessionsLoading",2);g([m()],f.prototype,"sessionsResult",2);g([m()],f.prototype,"sessionsError",2);g([m()],f.prototype,"cronLoading",2);g([m()],f.prototype,"cronJobs",2);g([m()],f.prototype,"cronStatus",2);g([m()],f.prototype,"cronError",2);g([m()],f.prototype,"cronForm",2);g([m()],f.prototype,"cronRunsJobId",2);g([m()],f.prototype,"cronRuns",2);g([m()],f.prototype,"cronBusy",2);g([m()],f.prototype,"cronNewEventModal",2);g([m()],f.prototype,"cronDetailJobId",2);g([m()],f.prototype,"cronEditJobId",2);g([m()],f.prototype,"cronPendingDeleteId",2);g([m()],f.prototype,"cronRunModalJobId",2);g([m()],f.prototype,"cronRunModalJobName",2);g([m()],f.prototype,"cronRunResult",2);g([m()],f.prototype,"openingHoursLoading",2);g([m()],f.prototype,"openingHoursError",2);g([m()],f.prototype,"openingHoursBusy",2);g([m()],f.prototype,"openingHoursForm",2);g([m()],f.prototype,"browserScreencastActive",2);g([m()],f.prototype,"browserScreencastFrame",2);g([m()],f.prototype,"browserScreencastMetadata",2);g([m()],f.prototype,"browserHandoffPending",2);g([m()],f.prototype,"browserHandoffReason",2);g([m()],f.prototype,"browserHandoffId",2);g([m()],f.prototype,"browserInputMode",2);g([m()],f.prototype,"browserFullscreen",2);g([m()],f.prototype,"browserLoading",2);g([m()],f.prototype,"browserError",2);g([m()],f.prototype,"filesLoading",2);g([m()],f.prototype,"filesTree",2);g([m()],f.prototype,"filesRoot",2);g([m()],f.prototype,"filesError",2);g([m()],f.prototype,"filesSelectedPath",2);g([m()],f.prototype,"filesSelectedPaths",2);g([m()],f.prototype,"filesPreviewContent",2);g([m()],f.prototype,"filesPreviewLoading",2);g([m()],f.prototype,"filesPreviewBinary",2);g([m()],f.prototype,"filesPreviewSize",2);g([m()],f.prototype,"filesExpandedDirs",2);g([m()],f.prototype,"filesCurrentDir",2);g([m()],f.prototype,"filesPendingDeletePath",2);g([m()],f.prototype,"filesMessage",2);g([m()],f.prototype,"filesUploadBusy",2);g([m()],f.prototype,"filesReindexBusy",2);g([m()],f.prototype,"filesMemoryStatus",2);g([m()],f.prototype,"embeddingDownloading",2);g([m()],f.prototype,"filesSearchQuery",2);g([m()],f.prototype,"filesSearchResults",2);g([m()],f.prototype,"filesSearchLoading",2);g([m()],f.prototype,"filesSearchAgentId",2);g([m()],f.prototype,"auditEntries",2);g([m()],f.prototype,"auditLoading",2);g([m()],f.prototype,"auditModalOpen",2);g([m()],f.prototype,"skillsLoading",2);g([m()],f.prototype,"skillsReport",2);g([m()],f.prototype,"skillsError",2);g([m()],f.prototype,"skillsFilter",2);g([m()],f.prototype,"skillsTypeFilter",2);g([m()],f.prototype,"skillsAgentFilter",2);g([m()],f.prototype,"skillEdits",2);g([m()],f.prototype,"skillsBusyKey",2);g([m()],f.prototype,"skillMessages",2);g([m()],f.prototype,"skillDetail",2);g([m()],f.prototype,"skillDetailTab",2);g([m()],f.prototype,"skillAddModal",2);g([m()],f.prototype,"skillAddForm",2);g([m()],f.prototype,"skillAddFormSource",2);g([m()],f.prototype,"skillEditTab",2);g([m()],f.prototype,"skillDrafts",2);g([m()],f.prototype,"adminsLoading",2);g([m()],f.prototype,"adminPhones",2);g([m()],f.prototype,"adminsError",2);g([m()],f.prototype,"adminsSaving",2);g([m()],f.prototype,"adminsNewPhone",2);g([m()],f.prototype,"contactsLoading",2);g([m()],f.prototype,"contactsSaving",2);g([m()],f.prototype,"contactsRecords",2);g([m()],f.prototype,"contactsError",2);g([m()],f.prototype,"contactsSearchQuery",2);g([m()],f.prototype,"contactsEditingId",2);g([m()],f.prototype,"contactsShowAddForm",2);g([m()],f.prototype,"contactsNewPhone",2);g([m()],f.prototype,"contactsNewName",2);g([m()],f.prototype,"contactsDeleteConfirmId",2);g([m()],f.prototype,"contactsAddFieldForId",2);g([m()],f.prototype,"contactsAddFieldKey",2);g([m()],f.prototype,"contactsAddFieldValue",2);g([m()],f.prototype,"imessageEnableConfirm",2);g([m()],f.prototype,"imessageEnabling",2);g([m()],f.prototype,"chatPageTab",2);g([m()],f.prototype,"waConversations",2);g([m()],f.prototype,"waSelectedJid",2);g([m()],f.prototype,"waMessages",2);g([m()],f.prototype,"waGroupInfo",2);g([m()],f.prototype,"waLoading",2);g([m()],f.prototype,"waMessagesLoading",2);g([m()],f.prototype,"waSearchQuery",2);g([m()],f.prototype,"waComposeDraft",2);g([m()],f.prototype,"waSending",2);g([m()],f.prototype,"waLastError",2);g([m()],f.prototype,"infoModalOpen",2);g([m()],f.prototype,"remoteAccessQrDataUrl",2);g([m()],f.prototype,"publicChatQrDataUrl",2);g([m()],f.prototype,"workspaces",2);g([m()],f.prototype,"workspacesLoading",2);g([m()],f.prototype,"workspacesError",2);g([m()],f.prototype,"selectedWorkspace",2);g([m()],f.prototype,"addingWorkspace",2);g([m()],f.prototype,"newWorkspaceName",2);g([m()],f.prototype,"newWorkspacePath",2);g([m()],f.prototype,"newWorkspacePin",2);g([m()],f.prototype,"accountPinModalOpen",2);g([m()],f.prototype,"accountPinBusy",2);g([m()],f.prototype,"accountPinError",2);g([m()],f.prototype,"accountPinSuccess",2);g([m()],f.prototype,"apiKeyProviders",2);g([m()],f.prototype,"apiKeyModalOpen",2);g([m()],f.prototype,"apiKeyBusy",2);g([m()],f.prototype,"apiKeyError",2);g([m()],f.prototype,"apiKeySuccess",2);g([m()],f.prototype,"apiKeySavingProvider",2);g([m()],f.prototype,"authApiKeyMode",2);g([m()],f.prototype,"authApiKeyInput",2);g([m()],f.prototype,"authApiKeyBusy",2);g([m()],f.prototype,"authApiKeyError",2);g([m()],f.prototype,"pinChanging",2);g([m()],f.prototype,"pinChangeBusy",2);g([m()],f.prototype,"pinChangeError",2);g([m()],f.prototype,"loginChangePinMode",2);g([m()],f.prototype,"changePinBusy",2);g([m()],f.prototype,"changePinError",2);g([m()],f.prototype,"changePinSuccess",2);g([m()],f.prototype,"workspaceSaving",2);g([m()],f.prototype,"workspaceRemoveConfirm",2);g([m()],f.prototype,"renamingWorkspace",2);g([m()],f.prototype,"renameWorkspaceName",2);g([m()],f.prototype,"debugLoading",2);g([m()],f.prototype,"debugStatus",2);g([m()],f.prototype,"debugHealth",2);g([m()],f.prototype,"debugModels",2);g([m()],f.prototype,"debugHeartbeat",2);g([m()],f.prototype,"debugCallMethod",2);g([m()],f.prototype,"debugCallParams",2);g([m()],f.prototype,"debugCallResult",2);g([m()],f.prototype,"debugCallError",2);g([m()],f.prototype,"logsLoading",2);g([m()],f.prototype,"logsError",2);g([m()],f.prototype,"logsFile",2);g([m()],f.prototype,"logsEntries",2);g([m()],f.prototype,"logsFilterText",2);g([m()],f.prototype,"logsLevelFilters",2);g([m()],f.prototype,"logsAutoFollow",2);g([m()],f.prototype,"logsTruncated",2);g([m()],f.prototype,"logsCursor",2);g([m()],f.prototype,"logsLastFetchAt",2);g([m()],f.prototype,"logsLimit",2);g([m()],f.prototype,"logsMaxBytes",2);g([m()],f.prototype,"logsAtBottom",2);g([m()],f.prototype,"logsDate",2);g([m()],f.prototype,"logsAvailableDates",2);g([m()],f.prototype,"logsSubTab",2);g([m()],f.prototype,"logsChipsExpanded",2);g([m()],f.prototype,"sessionLogsLoading",2);g([m()],f.prototype,"sessionLogsError",2);g([m()],f.prototype,"sessionLogsEntries",2);g([m()],f.prototype,"sessionLogsFilterText",2);g([m()],f.prototype,"sessionLogsTypeFilters",2);g([m()],f.prototype,"sessionLogsAgentFilters",2);g([m()],f.prototype,"sessionLogsAgents",2);g([m()],f.prototype,"sessionLogsAutoFollow",2);g([m()],f.prototype,"sessionLogsChipsExpanded",2);g([m()],f.prototype,"sessionLogsCursors",2);g([m()],f.prototype,"sessionLogsLastFetchAt",2);g([m()],f.prototype,"sessionLogsAtBottom",2);g([m()],f.prototype,"chatUserNearBottom",2);f=g([ql("taskmaster-app")],f);
4934
- //# sourceMappingURL=index-B9ScTH-4.js.map
4933
+ `,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.agentSettingsOpen=!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.authRefreshToken=null,this.claudeAuthModalOpen=!1,this.authRefreshTokenInput="",this.authRefreshTokenBusy=!1,this.authRefreshTokenError=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={...x0},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.openingHoursLoading=!1,this.openingHoursError=null,this.openingHoursBusy=!1,this.openingHoursForm=Wa(),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.skillsAgentFilter="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.chatPageTab="chat",this.waConversations=[],this.waSelectedJid=null,this.waMessages=[],this.waGroupInfo=null,this.waLoading=!1,this.waMessagesLoading=!1,this.waSearchQuery="",this.waComposeDraft="",this.waSending=!1,this.waLastError=null,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={...k0},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.logsDate=null,this.logsAvailableDates=[],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=()=>Xf(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null,this._beforeUnloadHandler=()=>{var t;xo();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(),$0(this),window.addEventListener("beforeunload",this._beforeUnloadHandler)}firstUpdated(){S0(this)}disconnectedCallback(){window.removeEventListener("beforeunload",this._beforeUnloadHandler),this.stopEmbeddingPoll(),A0(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){C0(this,e)}connect(){Oe(this)}handleChatScroll(e){ch(this,e)}handleLogsScroll(e){uh(this,e)}handleSessionLogsScroll(e){ph(this,e)}exportLogs(e,t){fh(e,t)}exportSessionLogs(e,t){gh(e,t)}resetToolStream(){na(this)}resetChatScroll(){hh(this)}async loadAssistantIdentity(){await Vo(this)}applySettings(e){at(this,e)}setTab(e){qf(this,e)}setTheme(e,t){jf(this,e,t)}async loadOverview(){await pd(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=this.selectedWorkspace??void 0,this.cronForm={...this.cronForm,accountId:this.selectedWorkspace??void 0},await hd(this)}async handleAbortChat(){await gd(this)}removeQueuedMessage(e){ng(this,e)}async handleSendChat(e,t){await ig(this,e,t)}async handleWhatsAppStart(e,t){await T0(this,e,t)}async handleWhatsAppWait(e){await _0(this,e)}async handleWhatsAppLogout(e){await M0(this,e)}async handleAddWhatsAppAccount(e){await P0(this,e)}async handleRemoveWhatsAppAccount(e){await I0(this,e)}async handleAccessCheck(){await Er(this)}async handlePinSubmit(e,t){await _h(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await Mh(this,e)}async handleLogout(){await Ih(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 Er(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 V0(this)}async handleLicenseRemove(){await Q0(this)}handleLicenseKeyChange(e){J0(this,e)}async handleAuthStatusCheck(){await K0(this)}async handleAuthStart(){await H0(this)}async handleAuthSubmitCode(e){await q0(this,e)}handleAuthCodeChange(e){j0(this,e)}handleClaudeAuthModalOpen(){this.claudeAuthModalOpen=!0}handleClaudeAuthModalClose(){this.claudeAuthModalOpen=!1,this.authUrl=null,this.authRefreshTokenInput="",this.authRefreshTokenError=null}async handleImportRefreshToken(){await z0(this)}async handleGatewayHealthCheck(){await Y0(this)}async handleGatewayRestart(){await X0(this)}async handleUpdateCheck(){await Eu(this)}async handleUpdateRun(){await Fk(this)}handleUpdateDismissResult(){zk(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 ae(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Dr);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){ae(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Dr);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await ad(this)}async clearAudit(){await Af(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,rn(this,t),us(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();ae(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>o0);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())}ae(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this).then(()=>{sn(this,!0)})})}async handleLoadOlderChat(){if(this.chatLoadingOlder||!this.chatHistoryHasMore)return;const e=dh(this),{loadOlderChatHistory:t}=await ae(async()=>{const{loadOlderChatHistory:i}=await Promise.resolve().then(()=>Oi);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.selectedWorkspace&&this.loadCron(),this.advancedTab==="opening-hours"&&ae(async()=>{const{loadOpeningHours:n}=await Promise.resolve().then(()=>i0);return{loadOpeningHours:n}},void 0,import.meta.url).then(({loadOpeningHours:n})=>{n(this)}),this.advancedTab==="logs"&&(this.logsSubTab==="session"?ae(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>od);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):ae(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>Nh);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&ae(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>vf);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await R0(this)}async handleChannelConfigReload(){await L0(this)}handleNostrProfileEdit(e,t){B0(this,e,t)}handleNostrProfileCancel(){N0(this)}handleNostrProfileFieldChange(e,t){O0(this,e,t)}async handleNostrProfileSave(){await U0(this)}async handleNostrProfileImport(){await W0(this)}handleNostrProfileToggleAdvanced(){F0(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;ae(async()=>{const{loadContacts:t}=await Promise.resolve().then(()=>a0);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 ae(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 ae(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>ki);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await ae(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>Eh);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 ae(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 ae(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){xo(),this.selectedWorkspace&&Wn(this.selectedWorkspace,this.sessionKey,this.chatMessage),this.selectedWorkspace=e,this.publicChatQrDataUrl=null,localStorage.setItem("taskmaster-selected-workspace",e),Tn(e),wr(e),this.settings=Bs(),this.chatMessage=zn(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.waConversations=[],this.waSelectedJid=null,this.waMessages=[],this.waGroupInfo=null,this.waLastError=null,this.waSearchQuery="",this.waComposeDraft="",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.chatPageTab==="whatsapp"&&!this.waLoading&&this.waConversations.length===0&&this.reloadWhatsAppConversations()):this.advancedPage&&this.handleAdvancedLoad()}async reloadWhatsAppConversations(){if(!(!this.client||!this.connected)){this.waLoading=!0,this.waLastError=null;try{const e=this.getSelectedWorkspaceInfo(),t=e==null?void 0:e.whatsappAccountId,n=await this.client.request("whatsapp.conversations",{accountId:t});this.waConversations=n.conversations}catch(e){this.waLastError=String(e)}finally{this.waLoading=!1}}}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),wr(this.selectedWorkspace),this.settings=Bs(),this.chatMessage=zn(this.selectedWorkspace,this.settings.sessionKey),this.reloadCurrentPageData()}render(){return c`${v0(this)}${this.auditModalOpen?w0(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):w}`}};g([m()],f.prototype,"settings",2);g([m()],f.prototype,"password",2);g([m()],f.prototype,"tab",2);g([m()],f.prototype,"onboarding",2);g([m()],f.prototype,"setup",2);g([m()],f.prototype,"filesPage",2);g([m()],f.prototype,"browserPage",2);g([m()],f.prototype,"adminsPage",2);g([m()],f.prototype,"contactsPage",2);g([m()],f.prototype,"chatPage",2);g([m()],f.prototype,"advancedPage",2);g([m()],f.prototype,"advancedTab",2);g([m()],f.prototype,"publicChat",2);g([m()],f.prototype,"publicChatConfig",2);g([m()],f.prototype,"publicChatSessionKey",2);g([m()],f.prototype,"publicChatAuthenticated",2);g([m()],f.prototype,"publicChatAuthStep",2);g([m()],f.prototype,"connected",2);g([m()],f.prototype,"accessState",2);g([m()],f.prototype,"theme",2);g([m()],f.prototype,"themeResolved",2);g([m()],f.prototype,"hello",2);g([m()],f.prototype,"lastError",2);g([m()],f.prototype,"eventLog",2);g([m()],f.prototype,"assistantName",2);g([m()],f.prototype,"assistantAvatar",2);g([m()],f.prototype,"assistantAgentId",2);g([m()],f.prototype,"sessionKey",2);g([m()],f.prototype,"chatLoading",2);g([m()],f.prototype,"chatSending",2);g([m()],f.prototype,"chatMessage",2);g([m()],f.prototype,"chatMessages",2);g([m()],f.prototype,"chatHistoryTotal",2);g([m()],f.prototype,"chatHistoryHasMore",2);g([m()],f.prototype,"chatLoadingOlder",2);g([m()],f.prototype,"chatToolMessages",2);g([m()],f.prototype,"chatStream",2);g([m()],f.prototype,"chatInterimText",2);g([m()],f.prototype,"chatSuggestions",2);g([m()],f.prototype,"chatStreamStartedAt",2);g([m()],f.prototype,"chatRunId",2);g([m()],f.prototype,"compactionStatus",2);g([m()],f.prototype,"chatAvatarUrl",2);g([m()],f.prototype,"chatModelCatalog",2);g([m()],f.prototype,"chatVerboseLevel",2);g([m()],f.prototype,"chatQueue",2);g([m()],f.prototype,"chatAttachments",2);g([m()],f.prototype,"sidebarOpen",2);g([m()],f.prototype,"sidebarContent",2);g([m()],f.prototype,"sidebarError",2);g([m()],f.prototype,"splitRatio",2);g([m()],f.prototype,"nodesLoading",2);g([m()],f.prototype,"nodes",2);g([m()],f.prototype,"devicesLoading",2);g([m()],f.prototype,"devicesError",2);g([m()],f.prototype,"devicesList",2);g([m()],f.prototype,"execApprovalsLoading",2);g([m()],f.prototype,"execApprovalsSaving",2);g([m()],f.prototype,"execApprovalsDirty",2);g([m()],f.prototype,"execApprovalsSnapshot",2);g([m()],f.prototype,"execApprovalsForm",2);g([m()],f.prototype,"execApprovalsSelectedAgent",2);g([m()],f.prototype,"execApprovalsTarget",2);g([m()],f.prototype,"execApprovalsTargetNodeId",2);g([m()],f.prototype,"execApprovalQueue",2);g([m()],f.prototype,"execApprovalBusy",2);g([m()],f.prototype,"execApprovalError",2);g([m()],f.prototype,"configLoading",2);g([m()],f.prototype,"configRaw",2);g([m()],f.prototype,"configRawOriginal",2);g([m()],f.prototype,"configValid",2);g([m()],f.prototype,"configIssues",2);g([m()],f.prototype,"configSaving",2);g([m()],f.prototype,"configApplying",2);g([m()],f.prototype,"updateRunning",2);g([m()],f.prototype,"applySessionKey",2);g([m()],f.prototype,"configSnapshot",2);g([m()],f.prototype,"configSchema",2);g([m()],f.prototype,"configSchemaVersion",2);g([m()],f.prototype,"configSchemaLoading",2);g([m()],f.prototype,"configUiHints",2);g([m()],f.prototype,"configForm",2);g([m()],f.prototype,"configFormOriginal",2);g([m()],f.prototype,"configFormDirty",2);g([m()],f.prototype,"configFormMode",2);g([m()],f.prototype,"configSearchQuery",2);g([m()],f.prototype,"configActiveSection",2);g([m()],f.prototype,"configActiveSubsection",2);g([m()],f.prototype,"channelsLoading",2);g([m()],f.prototype,"channelsSnapshot",2);g([m()],f.prototype,"channelsError",2);g([m()],f.prototype,"channelsLastSuccess",2);g([m()],f.prototype,"whatsappLoginMessage",2);g([m()],f.prototype,"whatsappLoginQrDataUrl",2);g([m()],f.prototype,"whatsappLoginConnected",2);g([m()],f.prototype,"whatsappBusy",2);g([m()],f.prototype,"whatsappActiveQrAccountId",2);g([m()],f.prototype,"whatsappPairedPhone",2);g([m()],f.prototype,"addingWhatsAppAccount",2);g([m()],f.prototype,"newWhatsAppAccountName",2);g([m()],f.prototype,"whatsappAccountError",2);g([m()],f.prototype,"whatsappAccountSaving",2);g([m()],f.prototype,"whatsappSettingsOpen",2);g([m()],f.prototype,"publicChatToggleBusy",2);g([m()],f.prototype,"publicChatGreetingBusy",2);g([m()],f.prototype,"publicChatEmailBusy",2);g([m()],f.prototype,"publicChatSettingsOpen",2);g([m()],f.prototype,"publicChatWidgetModalOpen",2);g([m()],f.prototype,"brandingBusy",2);g([m()],f.prototype,"agentSettingsOpen",2);g([m()],f.prototype,"brandingExpanded",2);g([m()],f.prototype,"tailscaleStatus",2);g([m()],f.prototype,"tailscaleBusy",2);g([m()],f.prototype,"tailscaleAuthUrl",2);g([m()],f.prototype,"tailscaleError",2);g([m()],f.prototype,"tailscaleServeEnableUrl",2);g([m()],f.prototype,"tailscaleFunnelEnableUrl",2);g([m()],f.prototype,"tailscaleDisableConfirm",2);g([m()],f.prototype,"tailscaleConnectProgress",2);g([m()],f.prototype,"tailscaleConnectMessage",2);g([m()],f.prototype,"tailscaleConnectSuccess",2);g([m()],f.prototype,"wifiStatus",2);g([m()],f.prototype,"wifiNetworks",2);g([m()],f.prototype,"wifiBusy",2);g([m()],f.prototype,"wifiError",2);g([m()],f.prototype,"wifiPassword",2);g([m()],f.prototype,"wifiSelectedSsid",2);g([m()],f.prototype,"networkPort",2);g([m()],f.prototype,"networkHostname",2);g([m()],f.prototype,"networkPortInput",2);g([m()],f.prototype,"networkHostnameInput",2);g([m()],f.prototype,"networkModalOpen",2);g([m()],f.prototype,"networkBusy",2);g([m()],f.prototype,"networkError",2);g([m()],f.prototype,"networkSuccess",2);g([m()],f.prototype,"wifiModalOpen",2);g([m()],f.prototype,"licenseKey",2);g([m()],f.prototype,"licenseBusy",2);g([m()],f.prototype,"licenseValid",2);g([m()],f.prototype,"licenseMessage",2);g([m()],f.prototype,"licenseTier",2);g([m()],f.prototype,"licenseDeviceId",2);g([m()],f.prototype,"licenseStoredKey",2);g([m()],f.prototype,"licenseRemoveConfirm",2);g([m()],f.prototype,"authConnected",2);g([m()],f.prototype,"authBusy",2);g([m()],f.prototype,"authMessage",2);g([m()],f.prototype,"authUrl",2);g([m()],f.prototype,"authCodeInput",2);g([m()],f.prototype,"authExpiresIn",2);g([m()],f.prototype,"authRefreshToken",2);g([m()],f.prototype,"claudeAuthModalOpen",2);g([m()],f.prototype,"authRefreshTokenInput",2);g([m()],f.prototype,"authRefreshTokenBusy",2);g([m()],f.prototype,"authRefreshTokenError",2);g([m()],f.prototype,"setupStep",2);g([m()],f.prototype,"gatewayHealthy",2);g([m()],f.prototype,"gatewayHealthLoading",2);g([m()],f.prototype,"gatewayHealthMessage",2);g([m()],f.prototype,"gatewayRestartBusy",2);g([m()],f.prototype,"updateAvailable",2);g([m()],f.prototype,"currentVersion",2);g([m()],f.prototype,"latestVersion",2);g([m()],f.prototype,"updateChecking",2);g([m()],f.prototype,"updateMessage",2);g([m()],f.prototype,"updateProgressSteps",2);g([m()],f.prototype,"updateLastResult",2);g([m()],f.prototype,"uninstallConfirm",2);g([m()],f.prototype,"uninstallBusy",2);g([m()],f.prototype,"uninstallDone",2);g([m()],f.prototype,"uninstallError",2);g([m()],f.prototype,"uninstallConfirmText",2);g([m()],f.prototype,"nostrProfileFormState",2);g([m()],f.prototype,"nostrProfileAccountId",2);g([m()],f.prototype,"presenceLoading",2);g([m()],f.prototype,"presenceEntries",2);g([m()],f.prototype,"presenceError",2);g([m()],f.prototype,"presenceStatus",2);g([m()],f.prototype,"agentsLoading",2);g([m()],f.prototype,"agentsList",2);g([m()],f.prototype,"agentsError",2);g([m()],f.prototype,"sessionsLoading",2);g([m()],f.prototype,"sessionsResult",2);g([m()],f.prototype,"sessionsError",2);g([m()],f.prototype,"cronLoading",2);g([m()],f.prototype,"cronJobs",2);g([m()],f.prototype,"cronStatus",2);g([m()],f.prototype,"cronError",2);g([m()],f.prototype,"cronForm",2);g([m()],f.prototype,"cronRunsJobId",2);g([m()],f.prototype,"cronRuns",2);g([m()],f.prototype,"cronBusy",2);g([m()],f.prototype,"cronNewEventModal",2);g([m()],f.prototype,"cronDetailJobId",2);g([m()],f.prototype,"cronEditJobId",2);g([m()],f.prototype,"cronPendingDeleteId",2);g([m()],f.prototype,"cronRunModalJobId",2);g([m()],f.prototype,"cronRunModalJobName",2);g([m()],f.prototype,"cronRunResult",2);g([m()],f.prototype,"openingHoursLoading",2);g([m()],f.prototype,"openingHoursError",2);g([m()],f.prototype,"openingHoursBusy",2);g([m()],f.prototype,"openingHoursForm",2);g([m()],f.prototype,"browserScreencastActive",2);g([m()],f.prototype,"browserScreencastFrame",2);g([m()],f.prototype,"browserScreencastMetadata",2);g([m()],f.prototype,"browserHandoffPending",2);g([m()],f.prototype,"browserHandoffReason",2);g([m()],f.prototype,"browserHandoffId",2);g([m()],f.prototype,"browserInputMode",2);g([m()],f.prototype,"browserFullscreen",2);g([m()],f.prototype,"browserLoading",2);g([m()],f.prototype,"browserError",2);g([m()],f.prototype,"filesLoading",2);g([m()],f.prototype,"filesTree",2);g([m()],f.prototype,"filesRoot",2);g([m()],f.prototype,"filesError",2);g([m()],f.prototype,"filesSelectedPath",2);g([m()],f.prototype,"filesSelectedPaths",2);g([m()],f.prototype,"filesPreviewContent",2);g([m()],f.prototype,"filesPreviewLoading",2);g([m()],f.prototype,"filesPreviewBinary",2);g([m()],f.prototype,"filesPreviewSize",2);g([m()],f.prototype,"filesExpandedDirs",2);g([m()],f.prototype,"filesCurrentDir",2);g([m()],f.prototype,"filesPendingDeletePath",2);g([m()],f.prototype,"filesMessage",2);g([m()],f.prototype,"filesUploadBusy",2);g([m()],f.prototype,"filesReindexBusy",2);g([m()],f.prototype,"filesMemoryStatus",2);g([m()],f.prototype,"embeddingDownloading",2);g([m()],f.prototype,"filesSearchQuery",2);g([m()],f.prototype,"filesSearchResults",2);g([m()],f.prototype,"filesSearchLoading",2);g([m()],f.prototype,"filesSearchAgentId",2);g([m()],f.prototype,"auditEntries",2);g([m()],f.prototype,"auditLoading",2);g([m()],f.prototype,"auditModalOpen",2);g([m()],f.prototype,"skillsLoading",2);g([m()],f.prototype,"skillsReport",2);g([m()],f.prototype,"skillsError",2);g([m()],f.prototype,"skillsFilter",2);g([m()],f.prototype,"skillsTypeFilter",2);g([m()],f.prototype,"skillsAgentFilter",2);g([m()],f.prototype,"skillEdits",2);g([m()],f.prototype,"skillsBusyKey",2);g([m()],f.prototype,"skillMessages",2);g([m()],f.prototype,"skillDetail",2);g([m()],f.prototype,"skillDetailTab",2);g([m()],f.prototype,"skillAddModal",2);g([m()],f.prototype,"skillAddForm",2);g([m()],f.prototype,"skillAddFormSource",2);g([m()],f.prototype,"skillEditTab",2);g([m()],f.prototype,"skillDrafts",2);g([m()],f.prototype,"adminsLoading",2);g([m()],f.prototype,"adminPhones",2);g([m()],f.prototype,"adminsError",2);g([m()],f.prototype,"adminsSaving",2);g([m()],f.prototype,"adminsNewPhone",2);g([m()],f.prototype,"contactsLoading",2);g([m()],f.prototype,"contactsSaving",2);g([m()],f.prototype,"contactsRecords",2);g([m()],f.prototype,"contactsError",2);g([m()],f.prototype,"contactsSearchQuery",2);g([m()],f.prototype,"contactsEditingId",2);g([m()],f.prototype,"contactsShowAddForm",2);g([m()],f.prototype,"contactsNewPhone",2);g([m()],f.prototype,"contactsNewName",2);g([m()],f.prototype,"contactsDeleteConfirmId",2);g([m()],f.prototype,"contactsAddFieldForId",2);g([m()],f.prototype,"contactsAddFieldKey",2);g([m()],f.prototype,"contactsAddFieldValue",2);g([m()],f.prototype,"imessageEnableConfirm",2);g([m()],f.prototype,"imessageEnabling",2);g([m()],f.prototype,"chatPageTab",2);g([m()],f.prototype,"waConversations",2);g([m()],f.prototype,"waSelectedJid",2);g([m()],f.prototype,"waMessages",2);g([m()],f.prototype,"waGroupInfo",2);g([m()],f.prototype,"waLoading",2);g([m()],f.prototype,"waMessagesLoading",2);g([m()],f.prototype,"waSearchQuery",2);g([m()],f.prototype,"waComposeDraft",2);g([m()],f.prototype,"waSending",2);g([m()],f.prototype,"waLastError",2);g([m()],f.prototype,"infoModalOpen",2);g([m()],f.prototype,"remoteAccessQrDataUrl",2);g([m()],f.prototype,"publicChatQrDataUrl",2);g([m()],f.prototype,"workspaces",2);g([m()],f.prototype,"workspacesLoading",2);g([m()],f.prototype,"workspacesError",2);g([m()],f.prototype,"selectedWorkspace",2);g([m()],f.prototype,"addingWorkspace",2);g([m()],f.prototype,"newWorkspaceName",2);g([m()],f.prototype,"newWorkspacePath",2);g([m()],f.prototype,"newWorkspacePin",2);g([m()],f.prototype,"accountPinModalOpen",2);g([m()],f.prototype,"accountPinBusy",2);g([m()],f.prototype,"accountPinError",2);g([m()],f.prototype,"accountPinSuccess",2);g([m()],f.prototype,"apiKeyProviders",2);g([m()],f.prototype,"apiKeyModalOpen",2);g([m()],f.prototype,"apiKeyBusy",2);g([m()],f.prototype,"apiKeyError",2);g([m()],f.prototype,"apiKeySuccess",2);g([m()],f.prototype,"apiKeySavingProvider",2);g([m()],f.prototype,"authApiKeyMode",2);g([m()],f.prototype,"authApiKeyInput",2);g([m()],f.prototype,"authApiKeyBusy",2);g([m()],f.prototype,"authApiKeyError",2);g([m()],f.prototype,"pinChanging",2);g([m()],f.prototype,"pinChangeBusy",2);g([m()],f.prototype,"pinChangeError",2);g([m()],f.prototype,"loginChangePinMode",2);g([m()],f.prototype,"changePinBusy",2);g([m()],f.prototype,"changePinError",2);g([m()],f.prototype,"changePinSuccess",2);g([m()],f.prototype,"workspaceSaving",2);g([m()],f.prototype,"workspaceRemoveConfirm",2);g([m()],f.prototype,"renamingWorkspace",2);g([m()],f.prototype,"renameWorkspaceName",2);g([m()],f.prototype,"debugLoading",2);g([m()],f.prototype,"debugStatus",2);g([m()],f.prototype,"debugHealth",2);g([m()],f.prototype,"debugModels",2);g([m()],f.prototype,"debugHeartbeat",2);g([m()],f.prototype,"debugCallMethod",2);g([m()],f.prototype,"debugCallParams",2);g([m()],f.prototype,"debugCallResult",2);g([m()],f.prototype,"debugCallError",2);g([m()],f.prototype,"logsLoading",2);g([m()],f.prototype,"logsError",2);g([m()],f.prototype,"logsFile",2);g([m()],f.prototype,"logsEntries",2);g([m()],f.prototype,"logsFilterText",2);g([m()],f.prototype,"logsLevelFilters",2);g([m()],f.prototype,"logsAutoFollow",2);g([m()],f.prototype,"logsTruncated",2);g([m()],f.prototype,"logsCursor",2);g([m()],f.prototype,"logsLastFetchAt",2);g([m()],f.prototype,"logsLimit",2);g([m()],f.prototype,"logsMaxBytes",2);g([m()],f.prototype,"logsAtBottom",2);g([m()],f.prototype,"logsDate",2);g([m()],f.prototype,"logsAvailableDates",2);g([m()],f.prototype,"logsSubTab",2);g([m()],f.prototype,"logsChipsExpanded",2);g([m()],f.prototype,"sessionLogsLoading",2);g([m()],f.prototype,"sessionLogsError",2);g([m()],f.prototype,"sessionLogsEntries",2);g([m()],f.prototype,"sessionLogsFilterText",2);g([m()],f.prototype,"sessionLogsTypeFilters",2);g([m()],f.prototype,"sessionLogsAgentFilters",2);g([m()],f.prototype,"sessionLogsAgents",2);g([m()],f.prototype,"sessionLogsAutoFollow",2);g([m()],f.prototype,"sessionLogsChipsExpanded",2);g([m()],f.prototype,"sessionLogsCursors",2);g([m()],f.prototype,"sessionLogsLastFetchAt",2);g([m()],f.prototype,"sessionLogsAtBottom",2);g([m()],f.prototype,"chatUserNearBottom",2);f=g([jl("taskmaster-app")],f);
4934
+ //# sourceMappingURL=index-B1bLQjxV.js.map