@rubytech/taskmaster 1.8.1 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-info.json +3 -3
- package/dist/control-ui/assets/{index-ySW2rUvm.js → index-zUaHKRVM.js} +180 -180
- package/dist/control-ui/assets/index-zUaHKRVM.js.map +1 -0
- package/dist/control-ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/control-ui/assets/index-ySW2rUvm.js.map +0 -1
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var Hu=Object.defineProperty;var qu=(e,t,n)=>t in e?Hu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var W=(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 r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&i(r)}).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",Vu=function(e,t){return new URL(e,t).href},Hr={},re=function(t,n,i){let s=Promise.resolve();if(n&&n.length>0){let c=function(l){return Promise.all(l.map(p=>Promise.resolve(p).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};const r=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),d=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=c(n.map(l=>{if(l=Vu(l,i),l in Hr)return;Hr[l]=!0;const p=l.endsWith(".css"),f=p?'[rel="stylesheet"]':"";if(i)for(let S=r.length-1;S>=0;S--){const h=r[S];if(h.href===l&&(!p||h.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${f}`))return;const v=document.createElement("link");if(v.rel=p?"stylesheet":ju,p||(v.as="script"),v.crossOrigin="",v.href=l,d&&v.setAttribute("nonce",d),document.head.appendChild(v),p)return new Promise((S,h)=>{v.addEventListener("load",S),v.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${l}`)))})}))}function o(r){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=r,window.dispatchEvent(a),!a.defaultPrevented)throw r}return s.then(r=>{for(const a of r||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})};const gi=globalThis,Po=gi.ShadowRoot&&(gi.ShadyCSS===void 0||gi.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Lo=Symbol(),qr=new WeakMap;let Ul=class{constructor(t,n,i){if(this._$cssResult$=!0,i!==Lo)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(Po&&t===void 0){const i=n!==void 0&&n.length===1;i&&(t=qr.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&qr.set(n,t))}return t}toString(){return this.cssText}};const Gu=e=>new Ul(typeof e=="string"?e:e+"",void 0,Lo),Qu=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((i,s,o)=>i+(r=>{if(r._$cssResult$===!0)return r.cssText;if(typeof r=="number")return r;throw Error("Value passed to 'css' function must be a 'css' function result: "+r+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[o+1],e[0]);return new Ul(n,e,Lo)},Ju=(e,t)=>{if(Po)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const i=document.createElement("style"),s=gi.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=n.cssText,e.appendChild(i)}},jr=Po?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const i of t.cssRules)n+=i.cssText;return Gu(n)})(e):e;const{is:Yu,defineProperty:Xu,getOwnPropertyDescriptor:Zu,getOwnPropertyNames:ep,getOwnPropertySymbols:tp,getPrototypeOf:np}=Object,tt=globalThis,Vr=tt.trustedTypes,ip=Vr?Vr.emptyScript:"",ms=tt.reactiveElementPolyfillSupport,bn=(e,t)=>e,ki={toAttribute(e,t){switch(t){case Boolean:e=e?ip: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}},Io=(e,t)=>!Yu(e,t),Gr={attribute:!0,type:String,converter:ki,reflect:!1,useDefault:!1,hasChanged:Io};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),tt.litPropertyMetadata??(tt.litPropertyMetadata=new WeakMap);let Ut=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=Gr){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&&Xu(this.prototype,t,s)}}static getPropertyDescriptor(t,n,i){const{get:s,set:o}=Zu(this.prototype,t)??{get(){return this[n]},set(r){this[n]=r}};return{get:s,set(r){const a=s==null?void 0:s.call(this);o==null||o.call(this,r),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Gr}static _$Ei(){if(this.hasOwnProperty(bn("elementProperties")))return;const t=np(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(bn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(bn("properties"))){const n=this.properties,i=[...ep(n),...tp(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(jr(s))}else t!==void 0&&n.push(jr(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 Ju(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 r=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:ki).toAttribute(n,i.type);this._$Em=t,r==null?this.removeAttribute(s):this.setAttribute(s,r),this._$Em=null}}_$AK(t,n){var o,r;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const a=i.getPropertyOptions(s),d=typeof a.converter=="function"?{fromAttribute:a.converter}:((o=a.converter)==null?void 0:o.fromAttribute)!==void 0?a.converter:ki;this._$Em=s;const c=d.fromAttribute(n,a.type);this[s]=c??((r=this._$Ej)==null?void 0:r.get(s))??c,this._$Em=null}}requestUpdate(t,n,i,s=!1,o){var r;if(t!==void 0){const a=this.constructor;if(s===!1&&(o=this[t]),i??(i=a.getPropertyOptions(t)),!((i.hasChanged??Io)(o,n)||i.useDefault&&i.reflect&&o===((r=this._$Ej)==null?void 0:r.get(t))&&!this.hasAttribute(a._$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},r){i&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,r??n??this[t]),o!==!0||r!==void 0)||(this._$AL.has(t)||(this.hasUpdated||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,r]of this._$Ep)this[o]=r;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,r]of s){const{wrapped:a}=r,d=this[o];a!==!0||this._$AL.has(o)||d===void 0||this.C(o,void 0,r,d)}}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){}};Ut.elementStyles=[],Ut.shadowRootOptions={mode:"open"},Ut[bn("elementProperties")]=new Map,Ut[bn("finalized")]=new Map,ms==null||ms({ReactiveElement:Ut}),(tt.reactiveElementVersions??(tt.reactiveElementVersions=[])).push("2.1.2");const wn=globalThis,Qr=e=>e,$i=wn.trustedTypes,Jr=$i?$i.createPolicy("lit-html",{createHTML:e=>e}):void 0,Wl="$lit$",et=`lit$${Math.random().toFixed(9).slice(2)}$`,Kl="?"+et,sp=`<${Kl}>`,$t=document,Pn=()=>$t.createComment(""),Ln=e=>e===null||typeof e!="object"&&typeof e!="function",Ro=Array.isArray,op=e=>Ro(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",ys=`[
|
|
2
|
-
\f\r]`,rn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,
|
|
3
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Zr=/'/g,ea=/"/g,zl=/^(?:script|style|textarea|title)$/i,rp=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),u=rp(1),it=Symbol.for("lit-noChange"),k=Symbol.for("lit-nothing"),ta=new WeakMap,mt=$t.createTreeWalker($t,129);function Hl(e,t){if(!Ro(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Jr!==void 0?Jr.createHTML(t):t}const ap=(e,t)=>{const n=e.length-1,i=[];let s,o=t===2?"<svg>":t===3?"<math>":"",r=rn;for(let a=0;a<n;a++){const d=e[a];let c,l,p=-1,f=0;for(;f<d.length&&(r.lastIndex=f,l=r.exec(d),l!==null);)f=r.lastIndex,r===rn?l[1]==="!--"?r=Yr:l[1]!==void 0?r=Xr:l[2]!==void 0?(zl.test(l[2])&&(s=RegExp("</"+l[2],"g")),r=ut):l[3]!==void 0&&(r=ut):r===ut?l[0]===">"?(r=s??rn,p=-1):l[1]===void 0?p=-2:(p=r.lastIndex-l[2].length,c=l[1],r=l[3]===void 0?ut:l[3]==='"'?ea:Zr):r===ea||r===Zr?r=ut:r===Yr||r===Xr?r=rn:(r=ut,s=void 0);const v=r===ut&&e[a+1].startsWith("/>")?" ":"";o+=r===rn?d+sp:p>=0?(i.push(c),d.slice(0,p)+Wl+d.slice(p)+et+v):d+et+(p===-2?a:v)}return[Hl(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let no=class ql{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let o=0,r=0;const a=t.length-1,d=this.parts,[c,l]=ap(t,n);if(this.el=ql.createElement(c,i),mt.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(s=mt.nextNode())!==null&&d.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const p of s.getAttributeNames())if(p.endsWith(Wl)){const f=l[r++],v=s.getAttribute(p).split(et),S=/([.?@])?(.*)/.exec(f);d.push({type:1,index:o,name:S[2],strings:v,ctor:S[1]==="."?cp:S[1]==="?"?dp:S[1]==="@"?up:ji}),s.removeAttribute(p)}else p.startsWith(et)&&(d.push({type:6,index:o}),s.removeAttribute(p));if(zl.test(s.tagName)){const p=s.textContent.split(et),f=p.length-1;if(f>0){s.textContent=$i?$i.emptyScript:"";for(let v=0;v<f;v++)s.append(p[v],Pn()),mt.nextNode(),d.push({type:2,index:++o});s.append(p[f],Pn())}}}else if(s.nodeType===8)if(s.data===Kl)d.push({type:2,index:o});else{let p=-1;for(;(p=s.data.indexOf(et,p+1))!==-1;)d.push({type:7,index:o}),p+=et.length-1}o++}}static createElement(t,n){const i=$t.createElement("template");return i.innerHTML=t,i}};function jt(e,t,n=e,i){var r,a;if(t===it)return t;let s=i!==void 0?(r=n._$Co)==null?void 0:r[i]:n._$Cl;const o=Ln(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),o===void 0?s=void 0:(s=new o(e),s._$AT(e,n,i)),i!==void 0?(n._$Co??(n._$Co=[]))[i]=s:n._$Cl=s),s!==void 0&&(t=jt(e,s._$AS(e,t.values),s,i)),t}class lp{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)??$t).importNode(n,!0);mt.currentNode=s;let o=mt.nextNode(),r=0,a=0,d=i[0];for(;d!==void 0;){if(r===d.index){let c;d.type===2?c=new qi(o,o.nextSibling,this,t):d.type===1?c=new d.ctor(o,d.name,d.strings,this,t):d.type===6&&(c=new pp(o,this,t)),this._$AV.push(c),d=i[++a]}r!==(d==null?void 0:d.index)&&(o=mt.nextNode(),r++)}return mt.currentNode=$t,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 qi=class jl{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=k,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=jt(this,t,n),Ln(t)?t===k||t==null||t===""?(this._$AH!==k&&this._$AR(),this._$AH=k):t!==this._$AH&&t!==it&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):op(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!==k&&Ln(this._$AH)?this._$AA.nextSibling.data=t:this.T($t.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=no.createElement(Hl(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(n);else{const r=new lp(s,this),a=r.u(this.options);r.p(n),this.T(a),this._$AH=r}}_$AC(t){let n=ta.get(t.strings);return n===void 0&&ta.set(t.strings,n=new no(t)),n}k(t){Ro(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 jl(this.O(Pn()),this.O(Pn()),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=Qr(t).nextSibling;Qr(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class ji{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,i,s,o){this.type=1,this._$AH=k,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=k}_$AI(t,n=this,i,s){const o=this.strings;let r=!1;if(o===void 0)t=jt(this,t,n,0),r=!Ln(t)||t!==this._$AH&&t!==it,r&&(this._$AH=t);else{const a=t;let d,c;for(t=o[0],d=0;d<o.length-1;d++)c=jt(this,a[i+d],n,d),c===it&&(c=this._$AH[d]),r||(r=!Ln(c)||c!==this._$AH[d]),c===k?t=k:t!==k&&(t+=(c??"")+o[d+1]),this._$AH[d]=c}r&&!s&&this.j(t)}j(t){t===k?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let cp=class extends ji{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===k?void 0:t}},dp=class extends ji{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==k)}},up=class extends ji{constructor(t,n,i,s,o){super(t,n,i,s,o),this.type=5}_$AI(t,n=this){if((t=jt(this,t,n,0)??k)===it)return;const i=this._$AH,s=t===k&&i!==k||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==k&&(i===k||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)}},pp=class{constructor(t,n,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){jt(this,t)}};const hp={I:qi},vs=wn.litHtmlPolyfillSupport;vs==null||vs(no,qi),(wn.litHtmlVersions??(wn.litHtmlVersions=[])).push("3.3.2");const fp=(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 qi(t.insertBefore(Pn(),o),o,void 0,n??{})}return s._$AI(e),s};const bt=globalThis;let zt=class extends Ut{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=fp(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 it}};var Ol;zt._$litElement$=!0,zt.finalized=!0,(Ol=bt.litElementHydrateSupport)==null||Ol.call(bt,{LitElement:zt});const bs=bt.litElementPolyfillSupport;bs==null||bs({LitElement:zt});(bt.litElementVersions??(bt.litElementVersions=[])).push("4.2.2");const Vl=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const gp={attribute:!0,type:String,converter:ki,reflect:!1,hasChanged:Io},mp=(e=gp,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:r}=n;return{set(a){const d=t.get.call(this);t.set.call(this,a),this.requestUpdate(r,d,e,!0,a)},init(a){return a!==void 0&&this.C(r,void 0,e,a),a}}}if(i==="setter"){const{name:r}=n;return function(a){const d=this[r];t.call(this,a),this.requestUpdate(r,d,e,!0,a)}}throw Error("Unsupported decorator location: "+i)};function Vi(e){return(t,n)=>typeof n=="object"?mp(e,t,n):((i,s,o)=>{const r=s.hasOwnProperty(o);return s.constructor.createProperty(o,i),r?Object.getOwnPropertyDescriptor(s,o):void 0})(e,t,n)}function y(e){return Vi({...e,state:!0,attribute:!1})}const yp=50,vp=200,bp="Assistant";function na(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function io(e){const t=na(e==null?void 0:e.name,yp)??bp,n=na((e==null?void 0:e.avatar)??void 0,vp)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function wp(){return io(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const kp="Taskmaster",$p="/taskmaster-icon.png",Sp="#00d4ff",xp="";let Xn=null;function Ve(){return Xn||(Xn={name:window.__TASKMASTER_BRAND_NAME__||kp,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||$p,accentColor:window.__TASKMASTER_ACCENT_COLOR__||Sp,backgroundColor:window.__TASKMASTER_BACKGROUND_COLOR__||xp},Xn)}function Re(){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 Ap(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 r=parseInt(o,16)/255;return r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)});return .2126*n+.7152*i+.0722*s}function Ql(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=Ap(e)>.4?"#111111":"#ffffff";n.style.setProperty("--accent-foreground",i),n.style.setProperty("--primary-foreground",i)}function Zn(e,t,n){const i=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e),s=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);if(!i||!s)return e;const o=(c,l)=>Math.round(parseInt(i[c],16)*(1-n)+parseInt(s[l],16)*n),r=o(1,1),a=o(2,2),d=o(3,3);return`#${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${d.toString(16).padStart(2,"0")}`}const an={"--bg":"#12141a","--bg-muted":"#262a35","--card":"#181b22","--secondary":"#1e2028"};function Jl(e){const t=document.documentElement;if(!e){for(const[i,s]of Object.entries(an))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",Zn(an["--bg"],e,.08)),t.style.setProperty("--bg-muted",Zn(an["--bg-muted"],e,.1)),t.style.setProperty("--card",Zn(an["--card"],e,.12)),t.style.setProperty("--secondary",Zn(an["--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 kn(e){const t=Ve(),n=Re(),i=e?n[e]:void 0,s=(i==null?void 0:i.accentColor)??t.accentColor;Ql(s);const o=(i==null?void 0:i.backgroundColor)??t.backgroundColor;Jl(o)}const Si="taskmaster.control.settings.v1",Yl="taskmaster.account.settings.";function $n(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const Ot={gatewayUrl:$n(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},Ze={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function Ep(){try{const e=localStorage.getItem(Si);if(!e)return{...Ot,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:Ot.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:Ot.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:Ot.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:Ot.navGroupsCollapsed}}catch{return{...Ot,gatewayUrl:$n()}}}function Cp(e){if(!e)return{...Ze};try{const t=localStorage.getItem(Yl+e);if(!t)return{...Ze};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():Ze.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||Ze.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:Ze.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:Ze.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:Ze.splitRatio}}catch{return{...Ze}}}let xi=null;function ia(e){xi=e}function ws(){return{...Ep(),...Cp(xi)}}function Tp(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(Si,JSON.stringify(t)),xi){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(Yl+xi,JSON.stringify(n))}}const _p="taskmaster.draft.";function Do(e,t){return _p+e+"."+t}function In(e,t,n){try{const i=Do(e,t);n?localStorage.setItem(i,n):localStorage.removeItem(i)}catch{}}function Rn(e,t){try{return localStorage.getItem(Do(e,t))??""}catch{return""}}function Mp(e,t){try{localStorage.removeItem(Do(e,t))}catch{}}let yt=null,$e=null;function sa(e,t,n){$e={workspace:e,sessionKey:t,text:n},yt!=null&&clearTimeout(yt),yt=setTimeout(()=>{$e&&In($e.workspace,$e.sessionKey,$e.text),$e=null,yt=null},300)}function so(){yt!=null&&clearTimeout(yt),yt=null,$e&&(In($e.workspace,$e.sessionKey,$e.text),$e=null)}(function(){try{const t=localStorage.getItem(Si);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(Si,JSON.stringify(i))}catch{}})();function Xl(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 Pp=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,ei=/<\s*\/?\s*final\b[^>]*>/gi,oa=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Lp(e,t){return e.trimStart()}function Ip(e,t){if(!e||!Pp.test(e))return e;let n=e;ei.test(n)?(ei.lastIndex=0,n=n.replace(ei,"")):ei.lastIndex=0,oa.lastIndex=0;let i="",s=0,o=!1;for(const r of n.matchAll(oa)){const a=r.index??0,d=r[1]==="/";o?d&&(o=!1):(i+=n.slice(s,a),d||(o=!0)),s=a+r[0].length}return i+=n.slice(s),Lp(i)}function Zl(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function Gi(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0){const r=-t,a=Math.round(r/1e3);if(a<60)return`in ${a}s`;const d=Math.round(a/60);if(d<60)return`in ${d}m`;const c=Math.round(d/60);return c<48?`in ${c}h`:`in ${Math.round(c/24)}d`}const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const i=Math.round(n/60);if(i<60)return`${i}m ago`;const s=Math.round(i/60);return s<48?`${s}h ago`:`${Math.round(s/24)}d ago`}function No(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 Rp(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function ec(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 Ai(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function ks(e){return Ip(e)}const Dp=/^\[([^\]]+)\]\s*/,Np=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],$s=new WeakMap,Ss=new WeakMap;function Bp(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:Np.some(t=>e.startsWith(`${t} `))}function xs(e){const t=e.match(Dp);if(!t)return e;const n=t[1]??"";return Bp(n)?e.slice(t[0].length):e}function Sn(e){const t=e,n=typeof t.role=="string"?t.role:"",i=t.content;if(typeof i=="string")return n==="assistant"?ks(i):xs(i);if(Array.isArray(i)){const s=i.map(o=>{const r=o;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(o=>typeof o=="string");if(s.length>0){const o=s.join(`
|
|
4
|
-
`);return n==="assistant"?ks(o):xs(o)}}return typeof t.text=="string"?n==="assistant"?ks(t.text):xs(t.text):null}function
|
|
1
|
+
var Hu=Object.defineProperty;var qu=(e,t,n)=>t in e?Hu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var W=(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 r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&i(r)}).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",Vu=function(e,t){return new URL(e,t).href},qr={},re=function(t,n,i){let s=Promise.resolve();if(n&&n.length>0){let c=function(l){return Promise.all(l.map(p=>Promise.resolve(p).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};const r=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),d=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=c(n.map(l=>{if(l=Vu(l,i),l in qr)return;qr[l]=!0;const p=l.endsWith(".css"),h=p?'[rel="stylesheet"]':"";if(i)for(let S=r.length-1;S>=0;S--){const f=r[S];if(f.href===l&&(!p||f.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${h}`))return;const v=document.createElement("link");if(v.rel=p?"stylesheet":ju,p||(v.as="script"),v.crossOrigin="",v.href=l,d&&v.setAttribute("nonce",d),document.head.appendChild(v),p)return new Promise((S,f)=>{v.addEventListener("load",S),v.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function o(r){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=r,window.dispatchEvent(a),!a.defaultPrevented)throw r}return s.then(r=>{for(const a of r||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})};const gi=globalThis,Lo=gi.ShadowRoot&&(gi.ShadyCSS===void 0||gi.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Io=Symbol(),jr=new WeakMap;let Wl=class{constructor(t,n,i){if(this._$cssResult$=!0,i!==Io)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(Lo&&t===void 0){const i=n!==void 0&&n.length===1;i&&(t=jr.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&jr.set(n,t))}return t}toString(){return this.cssText}};const Gu=e=>new Wl(typeof e=="string"?e:e+"",void 0,Io),Qu=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((i,s,o)=>i+(r=>{if(r._$cssResult$===!0)return r.cssText;if(typeof r=="number")return r;throw Error("Value passed to 'css' function must be a 'css' function result: "+r+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[o+1],e[0]);return new Wl(n,e,Io)},Ju=(e,t)=>{if(Lo)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const i=document.createElement("style"),s=gi.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=n.cssText,e.appendChild(i)}},Vr=Lo?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const i of t.cssRules)n+=i.cssText;return Gu(n)})(e):e;const{is:Yu,defineProperty:Xu,getOwnPropertyDescriptor:Zu,getOwnPropertyNames:ep,getOwnPropertySymbols:tp,getPrototypeOf:np}=Object,tt=globalThis,Gr=tt.trustedTypes,ip=Gr?Gr.emptyScript:"",ms=tt.reactiveElementPolyfillSupport,bn=(e,t)=>e,ki={toAttribute(e,t){switch(t){case Boolean:e=e?ip: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}},Ro=(e,t)=>!Yu(e,t),Qr={attribute:!0,type:String,converter:ki,reflect:!1,useDefault:!1,hasChanged:Ro};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),tt.litPropertyMetadata??(tt.litPropertyMetadata=new WeakMap);let Ut=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=Qr){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&&Xu(this.prototype,t,s)}}static getPropertyDescriptor(t,n,i){const{get:s,set:o}=Zu(this.prototype,t)??{get(){return this[n]},set(r){this[n]=r}};return{get:s,set(r){const a=s==null?void 0:s.call(this);o==null||o.call(this,r),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Qr}static _$Ei(){if(this.hasOwnProperty(bn("elementProperties")))return;const t=np(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(bn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(bn("properties"))){const n=this.properties,i=[...ep(n),...tp(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(Vr(s))}else t!==void 0&&n.push(Vr(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 Ju(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 r=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:ki).toAttribute(n,i.type);this._$Em=t,r==null?this.removeAttribute(s):this.setAttribute(s,r),this._$Em=null}}_$AK(t,n){var o,r;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const a=i.getPropertyOptions(s),d=typeof a.converter=="function"?{fromAttribute:a.converter}:((o=a.converter)==null?void 0:o.fromAttribute)!==void 0?a.converter:ki;this._$Em=s;const c=d.fromAttribute(n,a.type);this[s]=c??((r=this._$Ej)==null?void 0:r.get(s))??c,this._$Em=null}}requestUpdate(t,n,i,s=!1,o){var r;if(t!==void 0){const a=this.constructor;if(s===!1&&(o=this[t]),i??(i=a.getPropertyOptions(t)),!((i.hasChanged??Ro)(o,n)||i.useDefault&&i.reflect&&o===((r=this._$Ej)==null?void 0:r.get(t))&&!this.hasAttribute(a._$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},r){i&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,r??n??this[t]),o!==!0||r!==void 0)||(this._$AL.has(t)||(this.hasUpdated||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,r]of this._$Ep)this[o]=r;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,r]of s){const{wrapped:a}=r,d=this[o];a!==!0||this._$AL.has(o)||d===void 0||this.C(o,void 0,r,d)}}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){}};Ut.elementStyles=[],Ut.shadowRootOptions={mode:"open"},Ut[bn("elementProperties")]=new Map,Ut[bn("finalized")]=new Map,ms==null||ms({ReactiveElement:Ut}),(tt.reactiveElementVersions??(tt.reactiveElementVersions=[])).push("2.1.2");const wn=globalThis,Jr=e=>e,$i=wn.trustedTypes,Yr=$i?$i.createPolicy("lit-html",{createHTML:e=>e}):void 0,Kl="$lit$",et=`lit$${Math.random().toFixed(9).slice(2)}$`,zl="?"+et,sp=`<${zl}>`,$t=document,Pn=()=>$t.createComment(""),Ln=e=>e===null||typeof e!="object"&&typeof e!="function",Do=Array.isArray,op=e=>Do(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",ys=`[
|
|
2
|
+
\f\r]`,rn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Xr=/-->/g,Zr=/>/g,ut=RegExp(`>|${ys}(?:([^\\s"'>=/]+)(${ys}*=${ys}*(?:[^
|
|
3
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),ea=/'/g,ta=/"/g,Hl=/^(?:script|style|textarea|title)$/i,rp=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),u=rp(1),it=Symbol.for("lit-noChange"),k=Symbol.for("lit-nothing"),na=new WeakMap,mt=$t.createTreeWalker($t,129);function ql(e,t){if(!Do(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Yr!==void 0?Yr.createHTML(t):t}const ap=(e,t)=>{const n=e.length-1,i=[];let s,o=t===2?"<svg>":t===3?"<math>":"",r=rn;for(let a=0;a<n;a++){const d=e[a];let c,l,p=-1,h=0;for(;h<d.length&&(r.lastIndex=h,l=r.exec(d),l!==null);)h=r.lastIndex,r===rn?l[1]==="!--"?r=Xr:l[1]!==void 0?r=Zr:l[2]!==void 0?(Hl.test(l[2])&&(s=RegExp("</"+l[2],"g")),r=ut):l[3]!==void 0&&(r=ut):r===ut?l[0]===">"?(r=s??rn,p=-1):l[1]===void 0?p=-2:(p=r.lastIndex-l[2].length,c=l[1],r=l[3]===void 0?ut:l[3]==='"'?ta:ea):r===ta||r===ea?r=ut:r===Xr||r===Zr?r=rn:(r=ut,s=void 0);const v=r===ut&&e[a+1].startsWith("/>")?" ":"";o+=r===rn?d+sp:p>=0?(i.push(c),d.slice(0,p)+Kl+d.slice(p)+et+v):d+et+(p===-2?a:v)}return[ql(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let no=class jl{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let o=0,r=0;const a=t.length-1,d=this.parts,[c,l]=ap(t,n);if(this.el=jl.createElement(c,i),mt.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(s=mt.nextNode())!==null&&d.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const p of s.getAttributeNames())if(p.endsWith(Kl)){const h=l[r++],v=s.getAttribute(p).split(et),S=/([.?@])?(.*)/.exec(h);d.push({type:1,index:o,name:S[2],strings:v,ctor:S[1]==="."?cp:S[1]==="?"?dp:S[1]==="@"?up:ji}),s.removeAttribute(p)}else p.startsWith(et)&&(d.push({type:6,index:o}),s.removeAttribute(p));if(Hl.test(s.tagName)){const p=s.textContent.split(et),h=p.length-1;if(h>0){s.textContent=$i?$i.emptyScript:"";for(let v=0;v<h;v++)s.append(p[v],Pn()),mt.nextNode(),d.push({type:2,index:++o});s.append(p[h],Pn())}}}else if(s.nodeType===8)if(s.data===zl)d.push({type:2,index:o});else{let p=-1;for(;(p=s.data.indexOf(et,p+1))!==-1;)d.push({type:7,index:o}),p+=et.length-1}o++}}static createElement(t,n){const i=$t.createElement("template");return i.innerHTML=t,i}};function jt(e,t,n=e,i){var r,a;if(t===it)return t;let s=i!==void 0?(r=n._$Co)==null?void 0:r[i]:n._$Cl;const o=Ln(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),o===void 0?s=void 0:(s=new o(e),s._$AT(e,n,i)),i!==void 0?(n._$Co??(n._$Co=[]))[i]=s:n._$Cl=s),s!==void 0&&(t=jt(e,s._$AS(e,t.values),s,i)),t}class lp{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)??$t).importNode(n,!0);mt.currentNode=s;let o=mt.nextNode(),r=0,a=0,d=i[0];for(;d!==void 0;){if(r===d.index){let c;d.type===2?c=new qi(o,o.nextSibling,this,t):d.type===1?c=new d.ctor(o,d.name,d.strings,this,t):d.type===6&&(c=new pp(o,this,t)),this._$AV.push(c),d=i[++a]}r!==(d==null?void 0:d.index)&&(o=mt.nextNode(),r++)}return mt.currentNode=$t,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 qi=class Vl{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=k,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=jt(this,t,n),Ln(t)?t===k||t==null||t===""?(this._$AH!==k&&this._$AR(),this._$AH=k):t!==this._$AH&&t!==it&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):op(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!==k&&Ln(this._$AH)?this._$AA.nextSibling.data=t:this.T($t.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=no.createElement(ql(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(n);else{const r=new lp(s,this),a=r.u(this.options);r.p(n),this.T(a),this._$AH=r}}_$AC(t){let n=na.get(t.strings);return n===void 0&&na.set(t.strings,n=new no(t)),n}k(t){Do(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 Vl(this.O(Pn()),this.O(Pn()),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=Jr(t).nextSibling;Jr(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class ji{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,i,s,o){this.type=1,this._$AH=k,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=k}_$AI(t,n=this,i,s){const o=this.strings;let r=!1;if(o===void 0)t=jt(this,t,n,0),r=!Ln(t)||t!==this._$AH&&t!==it,r&&(this._$AH=t);else{const a=t;let d,c;for(t=o[0],d=0;d<o.length-1;d++)c=jt(this,a[i+d],n,d),c===it&&(c=this._$AH[d]),r||(r=!Ln(c)||c!==this._$AH[d]),c===k?t=k:t!==k&&(t+=(c??"")+o[d+1]),this._$AH[d]=c}r&&!s&&this.j(t)}j(t){t===k?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let cp=class extends ji{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===k?void 0:t}},dp=class extends ji{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==k)}},up=class extends ji{constructor(t,n,i,s,o){super(t,n,i,s,o),this.type=5}_$AI(t,n=this){if((t=jt(this,t,n,0)??k)===it)return;const i=this._$AH,s=t===k&&i!==k||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==k&&(i===k||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)}},pp=class{constructor(t,n,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){jt(this,t)}};const hp={I:qi},vs=wn.litHtmlPolyfillSupport;vs==null||vs(no,qi),(wn.litHtmlVersions??(wn.litHtmlVersions=[])).push("3.3.2");const fp=(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 qi(t.insertBefore(Pn(),o),o,void 0,n??{})}return s._$AI(e),s};const bt=globalThis;let zt=class extends Ut{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=fp(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 it}};var Ul;zt._$litElement$=!0,zt.finalized=!0,(Ul=bt.litElementHydrateSupport)==null||Ul.call(bt,{LitElement:zt});const bs=bt.litElementPolyfillSupport;bs==null||bs({LitElement:zt});(bt.litElementVersions??(bt.litElementVersions=[])).push("4.2.2");const Gl=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const gp={attribute:!0,type:String,converter:ki,reflect:!1,hasChanged:Ro},mp=(e=gp,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:r}=n;return{set(a){const d=t.get.call(this);t.set.call(this,a),this.requestUpdate(r,d,e,!0,a)},init(a){return a!==void 0&&this.C(r,void 0,e,a),a}}}if(i==="setter"){const{name:r}=n;return function(a){const d=this[r];t.call(this,a),this.requestUpdate(r,d,e,!0,a)}}throw Error("Unsupported decorator location: "+i)};function Vi(e){return(t,n)=>typeof n=="object"?mp(e,t,n):((i,s,o)=>{const r=s.hasOwnProperty(o);return s.constructor.createProperty(o,i),r?Object.getOwnPropertyDescriptor(s,o):void 0})(e,t,n)}function y(e){return Vi({...e,state:!0,attribute:!1})}const yp=50,vp=200,bp="Assistant";function ia(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function io(e){const t=ia(e==null?void 0:e.name,yp)??bp,n=ia((e==null?void 0:e.avatar)??void 0,vp)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function wp(){return io(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const kp="Taskmaster",$p="/taskmaster-icon.png",Sp="#00d4ff",xp="";let Xn=null;function Ve(){return Xn||(Xn={name:window.__TASKMASTER_BRAND_NAME__||kp,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||$p,accentColor:window.__TASKMASTER_ACCENT_COLOR__||Sp,backgroundColor:window.__TASKMASTER_BACKGROUND_COLOR__||xp},Xn)}function Re(){return window.__TASKMASTER_WORKSPACE_BRANDS__??{}}function Ql(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 Ap(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 r=parseInt(o,16)/255;return r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)});return .2126*n+.7152*i+.0722*s}function Jl(e){const t=Ql(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=Ap(e)>.4?"#111111":"#ffffff";n.style.setProperty("--accent-foreground",i),n.style.setProperty("--primary-foreground",i)}function Zn(e,t,n){const i=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e),s=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);if(!i||!s)return e;const o=(c,l)=>Math.round(parseInt(i[c],16)*(1-n)+parseInt(s[l],16)*n),r=o(1,1),a=o(2,2),d=o(3,3);return`#${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${d.toString(16).padStart(2,"0")}`}const an={"--bg":"#12141a","--bg-muted":"#262a35","--card":"#181b22","--secondary":"#1e2028"};function Yl(e){const t=document.documentElement;if(!e){for(const[i,s]of Object.entries(an))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=Ql(e);n&&(t.style.setProperty("--bg",Zn(an["--bg"],e,.08)),t.style.setProperty("--bg-muted",Zn(an["--bg-muted"],e,.1)),t.style.setProperty("--card",Zn(an["--card"],e,.12)),t.style.setProperty("--secondary",Zn(an["--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 kn(e){const t=Ve(),n=Re(),i=e?n[e]:void 0,s=(i==null?void 0:i.accentColor)??t.accentColor;Jl(s);const o=(i==null?void 0:i.backgroundColor)??t.backgroundColor;Yl(o)}const Si="taskmaster.control.settings.v1",Xl="taskmaster.account.settings.";function $n(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const Ot={gatewayUrl:$n(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},Ze={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function Ep(){try{const e=localStorage.getItem(Si);if(!e)return{...Ot,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:Ot.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:Ot.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:Ot.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:Ot.navGroupsCollapsed}}catch{return{...Ot,gatewayUrl:$n()}}}function Cp(e){if(!e)return{...Ze};try{const t=localStorage.getItem(Xl+e);if(!t)return{...Ze};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():Ze.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||Ze.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:Ze.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:Ze.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:Ze.splitRatio}}catch{return{...Ze}}}let xi=null;function sa(e){xi=e}function ws(){return{...Ep(),...Cp(xi)}}function Tp(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(Si,JSON.stringify(t)),xi){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(Xl+xi,JSON.stringify(n))}}const _p="taskmaster.draft.";function No(e,t){return _p+e+"."+t}function In(e,t,n){try{const i=No(e,t);n?localStorage.setItem(i,n):localStorage.removeItem(i)}catch{}}function Rn(e,t){try{return localStorage.getItem(No(e,t))??""}catch{return""}}function Mp(e,t){try{localStorage.removeItem(No(e,t))}catch{}}let yt=null,$e=null;function oa(e,t,n){$e={workspace:e,sessionKey:t,text:n},yt!=null&&clearTimeout(yt),yt=setTimeout(()=>{$e&&In($e.workspace,$e.sessionKey,$e.text),$e=null,yt=null},300)}function so(){yt!=null&&clearTimeout(yt),yt=null,$e&&(In($e.workspace,$e.sessionKey,$e.text),$e=null)}(function(){try{const t=localStorage.getItem(Si);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(Si,JSON.stringify(i))}catch{}})();function Zl(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 Pp=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,ei=/<\s*\/?\s*final\b[^>]*>/gi,ra=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Lp(e,t){return e.trimStart()}function Ip(e,t){if(!e||!Pp.test(e))return e;let n=e;ei.test(n)?(ei.lastIndex=0,n=n.replace(ei,"")):ei.lastIndex=0,ra.lastIndex=0;let i="",s=0,o=!1;for(const r of n.matchAll(ra)){const a=r.index??0,d=r[1]==="/";o?d&&(o=!1):(i+=n.slice(s,a),d||(o=!0)),s=a+r[0].length}return i+=n.slice(s),Lp(i)}function ec(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function Gi(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0){const r=-t,a=Math.round(r/1e3);if(a<60)return`in ${a}s`;const d=Math.round(a/60);if(d<60)return`in ${d}m`;const c=Math.round(d/60);return c<48?`in ${c}h`:`in ${Math.round(c/24)}d`}const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const i=Math.round(n/60);if(i<60)return`${i}m ago`;const s=Math.round(i/60);return s<48?`${s}h ago`:`${Math.round(s/24)}d ago`}function Bo(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 Rp(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function tc(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 Ai(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function ks(e){return Ip(e)}const Dp=/^\[([^\]]+)\]\s*/,Np=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],$s=new WeakMap,Ss=new WeakMap;function Bp(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:Np.some(t=>e.startsWith(`${t} `))}function xs(e){const t=e.match(Dp);if(!t)return e;const n=t[1]??"";return Bp(n)?e.slice(t[0].length):e}function Sn(e){const t=e,n=typeof t.role=="string"?t.role:"",i=t.content;if(typeof i=="string")return n==="assistant"?ks(i):xs(i);if(Array.isArray(i)){const s=i.map(o=>{const r=o;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(o=>typeof o=="string");if(s.length>0){const o=s.join(`
|
|
4
|
+
`);return n==="assistant"?ks(o):xs(o)}}return typeof t.text=="string"?n==="assistant"?ks(t.text):xs(t.text):null}function nc(e){if(!e||typeof e!="object")return Sn(e);const t=e;if($s.has(t))return $s.get(t)??null;const n=Sn(e);return $s.set(t,n),n}function aa(e){const n=e.content,i=[];if(Array.isArray(n))for(const a of n){const d=a;if(d.type==="thinking"&&typeof d.thinking=="string"){const c=d.thinking.trim();c&&i.push(c)}}if(i.length>0)return i.join(`
|
|
5
5
|
`);const s=Op(e);if(!s)return null;const r=[...s.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(a=>(a[1]??"").trim()).filter(Boolean);return r.length>0?r.join(`
|
|
6
|
-
`):null}function Fp(e){if(!e||typeof e!="object")return
|
|
6
|
+
`):null}function Fp(e){if(!e||typeof e!="object")return aa(e);const t=e;if(Ss.has(t))return Ss.get(t)??null;const n=aa(e);return Ss.set(t,n),n}function Op(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 Up(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 Wp=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,Kp=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,zp=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,Hp=/^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"&&Wp.test(s)||n==="assistant"&&Kp.test(s)||n==="user"&&Hp.test(s)||n==="assistant"&&zp.test(s)):!1}function
|
|
8
|
+
`):""}const Wp=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,Kp=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,zp=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,Hp=/^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"&&Wp.test(s)||n==="assistant"&&Kp.test(s)||n==="user"&&Hp.test(s)||n==="assistant"&&zp.test(s)):!1}function ic(e){return e.filter(t=>!qp(t))}function sc(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,r=Array.isArray(o)&&o.some(p=>{const v=String(p.type??"").toLowerCase();return v==="toolresult"||v==="tool_result"}),a=typeof t.toolName=="string"||typeof t.tool_name=="string";(i||r||a)&&(n="toolResult");let d=[];typeof t.content=="string"?d=[{type:"text",text:t.content}]:Array.isArray(t.content)?d=t.content.map(p=>({type:p.type||"text",text:p.text,name:p.name,args:p.args||p.arguments})):typeof t.text=="string"&&(d=[{type:"text",text:t.text}]);const c=typeof t.timestamp=="number"?t.timestamp:Date.now(),l=typeof t.id=="string"?t.id:void 0;return{role:n,content:d,timestamp:c,id:l}}function oc(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 rc(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function la(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 Qi(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),la(t)}return la(jp())}const Be=50;async function Ne(e,t){if(!e.client||!e.connected)return;e.chatLoading=!0,e.lastError=null;const n=(t==null?void 0:t.limit)??Be;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,r=ic(s);e.chatMessages=r,e.chatHistoryTotal=o,e.chatHistoryHasMore=o>s.length,e.chatThinkingLevel=i.thinkingLevel??null,e.chatModelProvider=typeof i.modelProvider=="string"?i.modelProvider:null,e.chatModel=typeof i.model=="string"?i.model:null,e.chatVerboseLevel=typeof i.verboseLevel=="string"?i.verboseLevel:null,e.chatFillerEnabled=typeof i.fillerEnabled=="boolean"?i.fillerEnabled:null}catch(i){e.lastError=String(i)}finally{e.chatLoading=!1}}async function Vp(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:Be,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=ic(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 Gp(e){const t=/^data:(.+?);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function ac(e,t,n){if(e.chatSuggestion=null,!e.client||!e.connected)return!1;const i=t.trim(),s=n&&n.length>0;if(!i&&!s)return!1;const o=Date.now(),r=(n??[]).filter(v=>!v.fileName),a=(n??[]).filter(v=>v.fileName),d=[],c=a.map(v=>v.fileName).filter(Boolean);if(c.length>0){const v=i?`${c.join(", ")}
|
|
9
9
|
|
|
10
|
-
${i}`:c.join(", ");d.push({type:"text",text:v})}else i&&d.push({type:"text",text:i});for(const v of r)d.push({type:"image",source:{type:"base64",media_type:v.mimeType,data:v.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:d,timestamp:o}],e.chatSending=!0,e.lastError=null;const l=Qi();e.chatRunId=l,e.chatStream="",e.chatStreamStartedAt=o;const p=[...r,...a],
|
|
10
|
+
${i}`:c.join(", ");d.push({type:"text",text:v})}else i&&d.push({type:"text",text:i});for(const v of r)d.push({type:"image",source:{type:"base64",media_type:v.mimeType,data:v.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:d,timestamp:o}],e.chatSending=!0,e.lastError=null;const l=Qi();e.chatRunId=l,e.chatStream="",e.chatStreamStartedAt=o;const p=[...r,...a],h=p.length>0?p.map(v=>{if(v.textContent)return{type:"document",mimeType:v.mimeType||"text/plain",fileName:v.fileName,content:btoa(unescape(encodeURIComponent(v.textContent)))};const S=Gp(v.dataUrl);return S?{type:v.fileName?"document":"image",mimeType:S.mimeType,fileName:v.fileName,content:S.content}:null}).filter(v=>v!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:i,deliver:!1,idempotencyKey:l,attachments:h}),!0}catch(v){const S=String(v);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=S,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+S}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function lc(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 cc(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=Sn(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 r=o.trim(),a=e.chatInterimText.trim();r===a||a.endsWith(r)||(r.startsWith(a)?e.chatInterimText=o:e.chatInterimText=`${e.chatInterimText}
|
|
11
11
|
|
|
12
|
-
${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(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.chatSuggestion=null;const s=Sn(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 Ei=Object.freeze(Object.defineProperty({__proto__:null,CHAT_PAGE_SIZE:Be,abortChatRun:
|
|
13
|
-
`)}function
|
|
12
|
+
${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(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.chatSuggestion=null;const s=Sn(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 Ei=Object.freeze(Object.defineProperty({__proto__:null,CHAT_PAGE_SIZE:Be,abortChatRun:lc,handleChatEvent:cc,loadChatHistory:Ne,loadOlderChatHistory:Vp,sendChatMessage:ac},Symbol.toStringTag,{value:"Module"}));async function Fo(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=Ai(e.sessionsFilterActive??"",0),i=Ai(e.sessionsFilterLimit??"",0);n>0&&(t.activeMinutes=n),i>0&&(t.limit=i);const s=await e.client.request("sessions.list",t);s&&(e.sessionsResult=s)}catch(t){e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}async function ti(e,t,n){if(!e.client||!e.connected)return;const i={key:t};"label"in n&&(i.label=n.label),"thinkingLevel"in n&&(i.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(i.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(i.reasoningLevel=n.reasoningLevel),"model"in n&&(i.model=n.model),"fillerEnabled"in n&&(i.fillerEnabled=n.fillerEnabled);try{await e.client.request("sessions.patch",i),await Fo(e)}catch(s){e.sessionsError=String(s)}}const ca=50,Qp=80,Jp=12e4;function Yp(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 da(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Yp(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=tc(n,Jp);return i.truncated?`${i.text}
|
|
14
14
|
|
|
15
|
-
… truncated (${i.total} chars, showing first ${i.text.length}).`:i.text}function Xp(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 Zp(e){if(e.toolStreamOrder.length<=
|
|
15
|
+
… truncated (${i.total} chars, showing first ${i.text.length}).`:i.text}function Xp(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 Zp(e){if(e.toolStreamOrder.length<=ca)return;const t=e.toolStreamOrder.length-ca,n=e.toolStreamOrder.splice(0,t);for(const i of n)e.toolStreamById.delete(i)}function eh(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function oo(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),eh(e)}function th(e,t=!1){if(t){oo(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>oo(e),Qp))}function Oo(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],oo(e)}const nh=5e3;function ih(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},nh))}function sh(e,t){if(!t)return;if(t.stream==="compaction"){ih(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",r=typeof i.phase=="string"?i.phase:"",a=r==="start"?i.args:void 0,d=r==="update"?da(i.partialResult):r==="result"?da(i.result):void 0,c=Date.now();let l=e.toolStreamById.get(s);l?(l.name=o,a!==void 0&&(l.args=a),d!==void 0&&(l.output=d),l.updatedAt=c):(l={toolCallId:s,runId:t.runId,sessionKey:n,name:o,args:a,output:d,startedAt:typeof t.ts=="number"?t.ts:c,updatedAt:c,message:{}},e.toolStreamById.set(s,l),e.toolStreamOrder.push(s)),l.message=Xp(l),Zp(e),th(e,r==="result")}let ni=0;function Jt(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=++ni,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===ni&&(e.chatScrollFrame=requestAnimationFrame(()=>{if(e.chatScrollFrame=null,n!==ni)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 a=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{if(e.chatScrollTimeout=null,n!==ni)return;const d=i();if(!d)return;const c=d.scrollHeight-d.scrollTop-d.clientHeight;(t||e.chatUserNearBottom||c<200)&&(d.scrollTop=d.scrollHeight,e.chatUserNearBottom=!0)},a)}))})}function dc(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 oh(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 rh(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 ah(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function lh(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function ch(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function dh(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 uh(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 ph(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 st(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function St(e){return`${JSON.stringify(e,null,2).trimEnd()}
|
|
20
|
-
`}function dc(e,t,n){if(t.length===0)return;let i=e;for(let o=0;o<t.length-1;o+=1){const r=t[o],a=t[o+1];if(typeof r=="number"){if(!Array.isArray(i))return;i[r]==null&&(i[r]=typeof a=="number"?[]:{}),i=i[r]}else{if(typeof i!="object"||i==null)return;const d=i;d[r]==null&&(d[r]=typeof a=="number"?[]:{}),i=d[r]}}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 Fe(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});fh(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function uc(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});hh(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function hh(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function fh(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?St(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=St(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=st(t.config??{}),e.configFormOriginal=st(t.config??{}),e.configRawOriginal=n)}async function gh(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?St(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 Fe(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function Yt(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 Fn(e){if(!(!e.client||!e.connected)&&!e.cronLoading){e.cronLoading=!0,e.cronError=null;try{const t={includeDisabled:!0};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(t.agentIds=e.workspaceAgentIds);const n=await e.client.request("cron.list",t);e.cronJobs=Array.isArray(n.jobs)?n.jobs:[]}catch(t){e.cronError=String(t)}finally{e.cronLoading=!1}}}function pc(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=Ai(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 hc(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 r=o.trim();r&&i.push(r)}i.length>0&&(n.to=i.join(","));const s=Ai(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function mh(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=pc(e.cronForm),i=hc(e.cronForm),s=e.cronForm.agentId.trim(),o=(t=e.cronForm.accountId)==null?void 0:t.trim(),r={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(!r.name)throw new Error("Name required.");await e.client.request("cron.add",r),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await Fn(e),await Yt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function yh(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 Fn(e),await Yt(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function vh(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 ro(e,t.id)}catch(n){e.cronError=String(n),e.cronRunResult={status:"error",error:String(n)}}finally{e.cronBusy=!1}}}function bh(e,t){e.cronRunModalJobId&&t.jobId===e.cronRunModalJobId&&t.action==="finished"&&(e.cronRunResult={status:t.status??"unknown",durationMs:t.durationMs,summary:t.summary,error:t.error})}async function wh(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 Fn(e),await Yt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}function kh(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(r=>r.trim()).filter(Boolean);t.toAdmins=o.some(r=>r.toLowerCase()==="admins"),t.recipients=o.filter(r=>r.toLowerCase()!=="admins")}}return(n=e.isolation)!=null&&n.postToMainPrefix&&(t.postToMainPrefix=e.isolation.postToMainPrefix),t}async function $h(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=pc(e.cronForm),i=hc(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 Fn(e),await Yt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function ro(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 Y(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 Oo(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 fc(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 gc(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 mc(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=st(s.config??{});(!o.channels||typeof o.channels!="object")&&(o.channels={});const r=o.channels;(!r.whatsapp||typeof r.whatsapp!="object")&&(r.whatsapp={});const a=r.whatsapp;(!a.accounts||typeof a.accounts!="object")&&(a.accounts={});const d=a.accounts;if(d[i]){e.whatsappAccountError=`Account "${i}" already exists.`;return}d[i]={name:n,provider:"baileys"};const c=s.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const l=St(o);await e.client.request("config.set",{raw:l,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await Y(e,!0),await Oo(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function yc(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=st(n.config??{}),s=i.channels,o=s==null?void 0:s.whatsapp,r=o==null?void 0:o.accounts;if(!r){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(r).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!r[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete r[t],Array.isArray(i.bindings)&&(i.bindings=i.bindings.filter(l=>{const p=l.match;return!p||p.channel!=="whatsapp"?!0:p.accountId!==t}));const d=n.hash;if(!d){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=St(i);await e.client.request("config.set",{raw:c,baseHash:d}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await Y(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const Sh=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:mc,loadChannels:Y,logoutWhatsApp:gc,removeWhatsAppAccount:yc,startWhatsAppLogin:Oo,waitWhatsAppLogin:fc},Symbol.toStringTag,{value:"Module"}));async function Uo(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 xh=2e3,Ah=new Set(["trace","debug","info","warn","error","fatal"]);function Eh(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 Ch(e){if(typeof e!="string")return null;const t=e.toLowerCase();return Ah.has(t)?t:null}function vc(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=Ch((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,r=Eh(o);let a=null;r&&(typeof r.subsystem=="string"?a=r.subsystem:typeof r.module=="string"&&(a=r.module)),!a&&o&&o.length<120&&(a=o);let d=null;return typeof t[1]=="string"?d=t[1]:!r&&typeof t[0]=="string"?d=t[0]:typeof t.message=="string"&&(d=t.message),{raw:e,time:i,level:s,subsystem:a,message:d??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Ht(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.logsLoading=!0),e.logsError=null;try{const i=await e.client.request("logs.tail",{cursor:t!=null&&t.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),o=(Array.isArray(i.lines)?i.lines.filter(a=>typeof a=="string"):[]).map(vc),r=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=r?o:[...e.logsEntries,...o].slice(-xh),typeof i.cursor=="number"&&(e.logsCursor=i.cursor),typeof i.file=="string"&&(e.logsFile=i.file),e.logsTruncated=!!i.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t!=null&&t.quiet||(e.logsLoading=!1)}}}const Th=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:Ht,parseLogLine:vc},Symbol.toStringTag,{value:"Module"}));const bc={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ce,n:mi,Gx:da,Gy:ua,a:As,d:Es,h:_h}=bc,xt=32,Wo=64,Mh=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},se=(e="")=>{const t=new Error(e);throw Mh(t,se),t},Ph=e=>typeof e=="bigint",Lh=e=>typeof e=="string",Ih=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",rt=(e,t,n="")=>{const i=Ih(e),s=e==null?void 0:e.length,o=t!==void 0;if(!i||o&&s!==t){const r=n&&`"${n}" `,a=o?` of length ${t}`:"",d=i?`length=${s}`:`type=${typeof e}`;se(r+"expected Uint8Array"+a+", got "+d)}return e},Ji=e=>new Uint8Array(e),wc=e=>Uint8Array.from(e),kc=(e,t)=>e.toString(16).padStart(t,"0"),$c=e=>Array.from(rt(e)).map(t=>kc(t,2)).join(""),ze={_0:48,_9:57,A:65,F:70,a:97,f:102},pa=e=>{if(e>=ze._0&&e<=ze._9)return e-ze._0;if(e>=ze.A&&e<=ze.F)return e-(ze.A-10);if(e>=ze.a&&e<=ze.f)return e-(ze.a-10)},Sc=e=>{const t="hex invalid";if(!Lh(e))return se(t);const n=e.length,i=n/2;if(n%2)return se(t);const s=Ji(i);for(let o=0,r=0;o<i;o++,r+=2){const a=pa(e.charCodeAt(r)),d=pa(e.charCodeAt(r+1));if(a===void 0||d===void 0)return se(t);s[o]=a*16+d}return s},xc=()=>globalThis==null?void 0:globalThis.crypto,Rh=()=>{var e;return((e=xc())==null?void 0:e.subtle)??se("crypto.subtle must be defined, consider polyfill")},Dn=(...e)=>{const t=Ji(e.reduce((i,s)=>i+rt(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},Dh=(e=xt)=>xc().getRandomValues(Ji(e)),Ci=BigInt,ft=(e,t,n,i="bad number: out of range")=>Ph(e)&&t<=e&&e<n?e:se(i),I=(e,t=ce)=>{const n=e%t;return n>=0n?n:t+n},Ac=e=>I(e,mi),Nh=(e,t)=>{(e===0n||t<=0n)&&se("no inverse n="+e+" mod="+t);let n=I(e,t),i=t,s=0n,o=1n;for(;n!==0n;){const r=i/n,a=i%n,d=s-o*r;i=n,n=a,s=o,o=d}return i===1n?I(s,t):se("no inverse")},Bh=e=>{const t=_c[e];return typeof t!="function"&&se("hashes."+e+" not set"),t},Cs=e=>e instanceof At?e:se("Point expected"),ao=2n**256n,De=class De{constructor(t,n,i,s){W(this,"X");W(this,"Y");W(this,"Z");W(this,"T");const o=ao;this.X=ft(t,0n,o),this.Y=ft(n,0n,o),this.Z=ft(i,1n,o),this.T=ft(s,0n,o),Object.freeze(this)}static CURVE(){return bc}static fromAffine(t){return new De(t.x,t.y,1n,I(t.x*t.y))}static fromBytes(t,n=!1){const i=Es,s=wc(rt(t,xt)),o=t[31];s[31]=o&-129;const r=Cc(s);ft(r,0n,n?ao:ce);const d=I(r*r),c=I(d-1n),l=I(i*d+1n);let{isValid:p,value:f}=Oh(c,l);p||se("bad point: y not sqrt");const v=(f&1n)===1n,S=(o&128)!==0;return!n&&f===0n&&S&&se("bad point: x==0, isLastByteOdd"),S!==v&&(f=I(-f)),new De(f,r,1n,I(f*r))}static fromHex(t,n){return De.fromBytes(Sc(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=As,n=Es,i=this;if(i.is0())return se("bad point: ZERO");const{X:s,Y:o,Z:r,T:a}=i,d=I(s*s),c=I(o*o),l=I(r*r),p=I(l*l),f=I(d*t),v=I(l*I(f+c)),S=I(p+I(n*I(d*c)));if(v!==S)return se("bad point: equation left != right (1)");const h=I(s*o),b=I(r*a);return h!==b?se("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:r,Z:a}=Cs(t),d=I(n*a),c=I(o*s),l=I(i*a),p=I(r*s);return d===c&&l===p}is0(){return this.equals(Kt)}negate(){return new De(I(-this.X),this.Y,this.Z,I(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=As,o=I(t*t),r=I(n*n),a=I(2n*I(i*i)),d=I(s*o),c=t+n,l=I(I(c*c)-o-r),p=d+r,f=p-a,v=d-r,S=I(l*f),h=I(p*v),b=I(l*v),w=I(f*p);return new De(S,h,w,b)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:r,Y:a,Z:d,T:c}=Cs(t),l=As,p=Es,f=I(n*r),v=I(i*a),S=I(o*p*c),h=I(s*d),b=I((n+i)*(r+a)-f-v),w=I(h-S),x=I(h+S),A=I(v-l*f),C=I(b*w),P=I(x*A),_=I(b*A),B=I(w*x);return new De(C,P,B,_)}subtract(t){return this.add(Cs(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return Kt;if(ft(t,1n,mi),t===1n)return this;if(this.equals(Et))return Jh(t).p;let i=Kt,s=Et;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(Kt))return{x:0n,y:1n};const s=Nh(i,ce);I(i*s)!==1n&&se("invalid inverse");const o=I(t*s),r=I(n*s);return{x:o,y:r}}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(Ci(_h),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(mi/2n,!1).double();return mi%2n&&(t=t.add(this)),t.is0()}};W(De,"BASE"),W(De,"ZERO");let At=De;const Et=new At(da,ua,1n,I(da*ua)),Kt=new At(0n,1n,1n,0n);At.BASE=Et;At.ZERO=Kt;const Ec=e=>Sc(kc(ft(e,0n,ao),Wo)).reverse(),Cc=e=>Ci("0x"+$c(wc(rt(e)).reverse())),Me=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=ce;return n},Fh=e=>{const n=e*e%ce*e%ce,i=Me(n,2n)*n%ce,s=Me(i,1n)*e%ce,o=Me(s,5n)*s%ce,r=Me(o,10n)*o%ce,a=Me(r,20n)*r%ce,d=Me(a,40n)*a%ce,c=Me(d,80n)*d%ce,l=Me(c,80n)*d%ce,p=Me(l,10n)*o%ce;return{pow_p_5_8:Me(p,2n)*e%ce,b2:n}},ha=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Oh=(e,t)=>{const n=I(t*t*t),i=I(n*n*t),s=Fh(e*i).pow_p_5_8;let o=I(e*n*s);const r=I(t*o*o),a=o,d=I(o*ha),c=r===e,l=r===I(-e),p=r===I(-e*ha);return c&&(o=a),(l||p)&&(o=d),(I(o)&1n)===1n&&(o=I(-o)),{isValid:c||l,value:o}},lo=e=>Ac(Cc(e)),Ko=(...e)=>_c.sha512Async(Dn(...e)),Uh=(...e)=>Bh("sha512")(Dn(...e)),Tc=e=>{const t=e.slice(0,xt);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(xt,Wo),i=lo(t),s=Et.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},zo=e=>Ko(rt(e,xt)).then(Tc),Wh=e=>Tc(Uh(rt(e,xt))),Kh=e=>zo(e).then(t=>t.pointBytes),zh=e=>Ko(e.hashable).then(e.finish),Hh=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=lo(t),r=Et.multiply(o).toBytes();return{hashable:Dn(r,i,n),finish:c=>{const l=Ac(o+lo(c)*s);return rt(Dn(r,Ec(l)),Wo)}}},qh=async(e,t)=>{const n=rt(e),i=await zo(t),s=await Ko(i.prefix,n);return zh(Hh(i,s,n))},_c={sha512Async:async e=>{const t=Rh(),n=Dn(e);return Ji(await t.digest("SHA-512",n.buffer))},sha512:void 0},jh=(e=Dh(xt))=>e,Vh={getExtendedPublicKeyAsync:zo,getExtendedPublicKey:Wh,randomSecretKey:jh},Ti=8,Gh=256,Mc=Math.ceil(Gh/Ti)+1,co=2**(Ti-1),Qh=()=>{const e=[];let t=Et,n=t;for(let i=0;i<Mc;i++){n=t,e.push(n);for(let s=1;s<co;s++)n=n.add(t),e.push(n);t=n.double()}return e};let fa;const ga=(e,t)=>{const n=t.negate();return e?n:t},Jh=e=>{const t=fa||(fa=Qh());let n=Kt,i=Et;const s=2**Ti,o=s,r=Ci(s-1),a=Ci(Ti);for(let d=0;d<Mc;d++){let c=Number(e&r);e>>=a,c>co&&(c-=o,e+=1n);const l=d*co,p=l,f=l+Math.abs(c)-1,v=d%2!==0,S=c<0;c===0?i=i.add(ga(v,t[p])):n=n.add(ga(S,t[f]))}return e!==0n&&se("invalid wnaf"),{p:n,f:i}},Ts="taskmaster-device-identity-v1";function uo(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Pc(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 Yh(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Lc(e){const t=await crypto.subtle.digest("SHA-256",e);return Yh(new Uint8Array(t))}async function Xh(){const e=Vh.randomSecretKey(),t=await Kh(e);return{deviceId:await Lc(t),publicKey:uo(t),privateKey:uo(e)}}async function Zh(){try{const n=localStorage.getItem(Ts);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 Lc(Pc(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(Ts,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 Xh(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Ts,JSON.stringify(t)),e}async function ef(e,t){const n=Pc(e),i=new TextEncoder().encode(t),s=await qh(i,n);return uo(s)}const Ic="taskmaster.device.auth.v1";function Ho(e){return e.trim()}function tf(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 qo(){try{const e=window.localStorage.getItem(Ic);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 Rc(e){try{window.localStorage.setItem(Ic,JSON.stringify(e))}catch{}}function nf(e){const t=qo();if(!t||t.deviceId!==e.deviceId)return null;const n=Ho(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function sf(e){const t=Ho(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=qo();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:tf(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,Rc(n),s}function of(e){const t=qo();if(!t||t.deviceId!==e.deviceId)return;const n=Ho(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],Rc(i)}async function jo(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 Vo(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 rf(e){return{method:"exec.approvals.get",params:{}}}async function af(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=rf(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);lf(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function lf(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=st(t.file??{}))}async function Dc(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 ot(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function Qe(e){return e instanceof Error?e.message:String(e)}function Nn(){return{name:"",skillContent:"",references:[]}}async function Ge(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=Qe(n)}finally{e.skillsLoading=!1}}}function Nc(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Bc(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 Ge(e),ot(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=Qe(i);e.skillsError=s,ot(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 Ge(e),ot(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=Qe(n);e.skillsError=i,ot(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Oc(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 Ge(e),ot(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=Qe(s);e.skillsError=o,ot(e,t,{kind:"error",message:o})}finally{e.skillsBusyKey=null}}}async function Uc(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=Qe(n)}}function Wc(e){e.skillDetail=null,e.skillDetailTab=""}function Kc(e,t){e.skillDetailTab=t}async function zc(e){if(e.skillAddModal=!0,e.skillAddForm=Nn(),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 Hc(e){e.skillAddModal=!1,e.skillAddForm=Nn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[]}function qc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n}))},e.skillAddFormSource="draft"}async function jc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n}))},e.skillAddFormSource="installed",await Go(e)}async function Go(e){if(!e.client||!e.connected)return;const t=e.skillAddForm;if(!(!t.name.trim()||!t.skillContent.trim())){e.skillsBusyKey="__add__",e.skillsError=null;try{const n=t.references.filter(s=>s.name.trim()&&s.content.trim()).map(s=>({name:s.name.trim(),content:s.content})),i=t.name.trim();e.skillAddFormSource==="installed"?(await e.client.request("skills.create",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=Nn(),e.skillAddFormSource="draft",e.skillDrafts=[],await Ge(e),ot(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=Nn(),e.skillAddFormSource="draft",e.skillDrafts=[],ot(e,i,{kind:"success",message:"Draft saved"}))}catch(n){e.skillsError=Qe(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=Qe(n)}}async function Gc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("skills.read",{name:t});if(!n)return;e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i}))},e.skillAddFormSource="installed",e.skillAddModal=!0,e.skillDrafts=[]}catch(n){e.skillsError=Qe(n)}}function Qc(e,t){const n=e.skillDetail;n&&(e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i}))},e.skillAddFormSource="installed",e.skillEditTab=t&&t!=="SKILL.md"?t:"SKILL.md",e.skillDetail=null,e.skillDetailTab="",e.skillAddModal=!0,e.skillDrafts=[])}function Jc(e,t,n){e.skillAddForm={...e.skillAddForm,references:e.skillAddForm.references.map(i=>i.name===t?{...i,content:n}:i)}}function Yc(e,t){e.skillEditTab=t}async function Xc(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.delete",{name:t}),await Ge(e)}catch(n){e.skillsError=Qe(n)}finally{e.skillsBusyKey=null}}}const cf=Object.freeze(Object.defineProperty({__proto__:null,closeAddSkillModal:Hc,closeSkillDetail:Wc,deleteDraft:Vc,deleteSkill:Xc,editDetailSkill:Qc,editSkill:Gc,emptyAddForm:Nn,importDraft:qc,installDraft:jc,installSkill:Oc,loadSkills:Ge,openAddSkillModal:zc,saveNewSkill:Go,saveSkillApiKey:Fc,setEditTab:Yc,setSkillDetailTab:Kc,updateFormReference:Jc,updateSkillEdit:Nc,updateSkillEnabled:Bc,viewSkillDetail:Uc},Symbol.toStringTag,{value:"Module"})),Zc={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},ed=new Map(Object.entries(Zc).map(([e,t])=>[t,e]));function Yi(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function Bn(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 df(e,t=""){const n=Yi(t),i=Zc[e];return n?`${n}${i}`:i}function td(e,t=""){const n=Yi(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=Bn(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":ed.get(s)??null}function uf(e){let t=Bn(e);if(t.endsWith("/index.html")&&(t=Bn(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(ed.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function pf(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Qo(e){return e==="system"?pf():e}const ii=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,hf=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,si=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},ff=({nextTheme:e,applyTheme:t,context:n,currentTheme:i})=>{var c;if(i===e)return;const s=globalThis.document??null;if(!s){t();return}const o=s.documentElement,r=s,a=hf();if(!!r.startViewTransition&&!a){let l=.5,p=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")l=ii(n.pointerClientX/window.innerWidth),p=ii(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const f=n.element.getBoundingClientRect();f.width>0&&f.height>0&&typeof window<"u"&&(l=ii((f.left+f.width/2)/window.innerWidth),p=ii((f.top+f.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${l*100}%`),o.style.setProperty("--theme-switch-y",`${p*100}%`),o.classList.add("theme-transition");try{const f=(c=r.startViewTransition)==null?void 0:c.call(r,()=>{t()});f!=null&&f.finished?f.finished.finally(()=>si(o)):si(o)}catch{si(o),t()}return}t(),si(o)},gf=2e3;async function xn(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:[],r=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=r?o:[...e.sessionLogsEntries,...o].slice(-gf),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 nd=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:xn},Symbol.toStringTag,{value:"Module"}));async function id(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 mf(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function Oe(e){return e instanceof Error?e.message:String(e)}let oi=null;function Xt(e,t){oi&&clearTimeout(oi),e.filesMessage={kind:"success",text:t},oi=setTimeout(()=>{e.filesMessage=null,oi=null},3e3)}async function Zt(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=Oe(n)}finally{e.filesLoading=!1}}}}async function yf(e,t,n){e.filesSelectedPaths=new Set([t]),await sd(e,t,n)}async function vf(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 sd(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function bf(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 od(e,o,t),i++}catch(r){s=Oe(r)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:Xt(e,`${i} file${i!==1?"s":""} downloaded`)}async function wf(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await xf(e,t,o,i)}async function sd(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=Oe(i)}finally{e.filesPreviewLoading=!1}}}async function od(e,t,n){if(!(!e.client||!e.connected))try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.download",i);if(!(s!=null&&s.base64)){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const o=Uint8Array.from(atob(s.base64),c=>c.charCodeAt(0)),r=new Blob([o]),a=URL.createObjectURL(r),d=document.createElement("a");d.href=a,d.download=s.name??t.split("/").pop()??"download",document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(a)}catch(i){e.filesMessage={kind:"error",text:Oe(i)}}}async function kf(e,t,n,i){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let s=0,o="";for(const r of n)try{const a=await r.arrayBuffer(),d=btoa(new Uint8Array(a).reduce((l,p)=>l+String.fromCharCode(p),"")),c={path:t,name:r.name,data:d};i&&(c.agentId=i),await e.client.request("files.upload",c),s++}catch(a){o=Oe(a)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:Xt(e,`${s} file${s!==1?"s":""} uploaded`),await Zt(e,i)}async function $f(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),Xt(e,`Created ${s}`),await Zt(e,i),e.filesExpandedDirs=new Set([...e.filesExpandedDirs,s]),e.filesCurrentDir=s}catch(o){e.filesMessage={kind:"error",text:Oe(o)}}}async function Sf(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),Xt(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await Zt(e,n)}catch(i){e.filesMessage={kind:"error",text:Oe(i)}}}}async function xf(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),Xt(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await Zt(e,i)}catch(s){e.filesMessage={kind:"error",text:Oe(s)}}}}async function Jo(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 Af(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;Xt(e,`Re-indexed: ${s} files, ${o} chunks`),await Jo(e,t)}catch(n){e.filesMessage={kind:"error",text:Oe(n)}}finally{e.filesReindexBusy=!1}}}function Ef(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 Cf(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:Oe(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function Tf(e){e.filesSearchQuery="",e.filesSearchResults=null}function _f(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{Vo(e,{quiet:!0})},5e3))}function Mf(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function Yo(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Ht(e,{quiet:!0})},2e3))}function Xo(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function Zo(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||xn(e,{quiet:!0})},2e3))}function er(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function tr(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&Uo(e)},3e3))}function nr(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Pf(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{id(e)},3e4))}function Lf(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function If(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{if(e.tab!=="files")return;const t=e;Jo(t,t.filesResolvedAgentId)},3e3))}function Rf(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function nt(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,Tp(n),t.theme!==e.theme&&(e.theme=t.theme,Xi(e,Qo(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function rd(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&nt(e,{...e.settings,lastActiveSessionKey:n})}function Df(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 r=!1;if(n!=null){const d=n.trim();d&&d!==e.settings.token&&nt(e,{...e.settings,token:d}),t.delete("token"),r=!0}if(i!=null){const d=i.trim();d&&(e.password=d),t.delete("password"),r=!0}if(s!=null){const d=s.trim();d&&(e.sessionKey=d,nt(e,{...e.settings,sessionKey:d,lastActiveSessionKey:d}))}if(o!=null){const d=o.trim();d&&d!==e.settings.gatewayUrl&&nt(e,{...e.settings,gatewayUrl:d}),t.delete("gatewayUrl"),r=!0}if(!r)return;const a=new URL(window.location.href);a.search=t.toString(),window.history.replaceState({},"",a.toString())}function Nf(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?Zo(e):Yo(e):(Xo(e),er(e)),t==="debug"?tr(e):nr(e),_i(e),ld(e,t,!1)}function Bf(e,t,n){ff({nextTheme:t,applyTheme:()=>{e.theme=t,nt(e,{...e.settings,theme:t}),Xi(e,Qo(t))},context:n,currentTheme:e.theme})}async function _i(e){if(e.tab==="overview"&&await cd(e),e.tab==="channels"&&await Hf(e),e.tab==="instances"&&await Dc(e),e.tab==="cron"&&await ir(e),e.tab==="skills"&&await Ge(e),e.tab==="nodes"&&(await Vo(e),await jo(e),await Fe(e),await af(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await Qf(e),Jt(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await uc(e),await Fe(e)),e.tab==="debug"&&(await Uo(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await re(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>nd);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await Ht(e,{reset:!0});cc(e,!0)}}function Ff(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?Yi(e):uf(window.location.pathname)}function Of(e){e.theme=e.settings.theme??"system",Xi(e,Qo(e.theme))}function Xi(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function Uf(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"&&Xi(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Wf(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 Kf(e,t){if(typeof window>"u")return;const n=td(window.location.pathname,e.basePath)??"chat";ad(e,n),ld(e,n,t)}function zf(e){var s;if(typeof window>"u")return;const t=td(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,nt(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),ad(e,t)}function ad(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?Zo(e):Yo(e):(Xo(e),er(e)),t==="debug"?tr(e):nr(e),e.connected&&_i(e)}function ld(e,t,n){if(typeof window>"u")return;const i=Bn(df(t,e.basePath)),s=Bn(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 cd(e){await Promise.all([Y(e,!1),Dc(e),Bo(e),Yt(e),Uo(e)])}async function Hf(e){await Promise.all([Y(e,!0),uc(e),Fe(e)])}async function ir(e){await Promise.all([Y(e,!1),Yt(e),Fn(e)])}function dd(e){return e.chatSending||!!e.chatRunId}function qf(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 ud(e){e.connected&&(e.chatMessage="",await ac(e))}function jf(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:Qi(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],Jt(e))}async function pd(e,t,n){var s,o;Fo(e);const i=await rc(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&&rd(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),Jt(e),i&&!e.chatRunId&&hd(e),i}async function hd(e){if(!e.connected||dd(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await pd(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function Vf(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function Gf(e,t,n){if(!e.connected)return;const i=e.chatMessage,s=(t??e.chatMessage).trim(),o=e.chatAttachments??[],r=t==null?o:[],a=r.length>0;if(!(!s&&!a)){if(qf(s)){await ud(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[],Mp(e.selectedWorkspace??"",e.sessionKey)),dd(e)){jf(e,s,r);return}await pd(e,s,{previousDraft:t==null?i:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:a?r:void 0,previousAttachments:t==null?o:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function Qf(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,Be);await Promise.all([Ne(t,{limit:n}),Bo(t),po(e)]),Jt(e,!0)}const Jf=hd;function Yf(e){var s,o,r;const t=Xl(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(s=e.hello)==null?void 0:s.snapshot;return((r=(o=n==null?void 0:n.sessionDefaults)==null?void 0:o.defaultAgentId)==null?void 0:r.trim())||"main"}function Xf(e,t){const n=Yi(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function po(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=Yf(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=Xf(e.basePath,t);try{const i=await fetch(n,{method:"GET"});if(!i.ok){e.chatAvatarUrl=null;return}const s=await i.json(),o=typeof s.avatarUrl=="string"?s.avatarUrl.trim():"";e.chatAvatarUrl=o||null}catch{e.chatAvatarUrl=null}}const L={messageSquare:u`<svg viewBox="0 0 24 24"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,barChart:u`<svg viewBox="0 0 24 24"><line x1="12" x2="12" y1="20" y2="10"/><line x1="18" x2="18" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="16"/></svg>`,link:u`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,unlink:u`<svg viewBox="0 0 24 24"><path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"/><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"/><line x1="8" x2="8" y1="2" y2="5"/><line x1="2" x2="5" y1="8" y2="8"/><line x1="16" x2="16" y1="19" y2="22"/><line x1="19" x2="22" y1="16" y2="16"/></svg>`,radio:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="2"/><path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"/></svg>`,fileText:u`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><line x1="16" x2="8" y1="13" y2="13"/><line x1="16" x2="8" y1="17" y2="17"/><line x1="10" x2="8" y1="9" y2="9"/></svg>`,zap:u`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:u`<svg viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>`,settings:u`<svg viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>`,bug:u`<svg viewBox="0 0 24 24"><path d="m8 2 1.88 1.88"/><path d="M14.12 3.88 16 2"/><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9"/><path d="M6.53 9C4.6 8.8 3 7.1 3 5"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="M22 13h-4"/><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"/></svg>`,scrollText:u`<svg viewBox="0 0 24 24"><path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M15 8h-5"/><path d="M15 12h-5"/></svg>`,folder:u`<svg viewBox="0 0 24 24"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>`,users:u`<svg viewBox="0 0 24 24"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>`,menu:u`<svg viewBox="0 0 24 24"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>`,x:u`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:u`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:u`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,search:u`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:u`<svg viewBox="0 0 24 24"><path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/><path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/><path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/><path d="M17.599 6.5a3 3 0 0 0 .399-1.375"/><path d="M6.003 5.125A3 3 0 0 0 6.401 6.5"/><path d="M3.477 10.896a4 4 0 0 1 .585-.396"/><path d="M19.938 10.5a4 4 0 0 1 .585.396"/><path d="M6 18a4 4 0 0 1-1.967-.516"/><path d="M19.967 17.484A4 4 0 0 1 18 18"/></svg>`,book:u`<svg viewBox="0 0 24 24"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/></svg>`,loader:u`<svg viewBox="0 0 24 24"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>`,rotateCw:u`<svg viewBox="0 0 24 24"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>`,download:u`<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,wrench:u`<svg viewBox="0 0 24 24"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>`,fileCode:u`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><path d="m10 13-2 2 2 2"/><path d="m14 17 2-2-2-2"/></svg>`,edit:u`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,penLine:u`<svg viewBox="0 0 24 24"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>`,paperclip:u`<svg viewBox="0 0 24 24"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`,globe:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>`,globeOff:u`<svg viewBox="0 0 24 24"><path d="M21.54 15H17"/><path d="M7 3.34V5a3 3 0 0 0 3 3 2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17"/><path d="M11 21.95V18a2 2 0 0 0-2-2 2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05"/><circle cx="12" cy="12" r="10"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,image:u`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>`,smartphone:u`<svg viewBox="0 0 24 24"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>`,plug:u`<svg viewBox="0 0 24 24"><path d="M12 22v-5"/><path d="M9 8V2"/><path d="M15 8V2"/><path d="M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z"/></svg>`,circle:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>`,puzzle:u`<svg viewBox="0 0 24 24"><path d="M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.076.874.54 1.02 1.02a2.5 2.5 0 1 0 3.237-3.237c-.48-.146-.944-.505-1.02-1.02a.98.98 0 0 1 .303-.917l1.526-1.526A2.402 2.402 0 0 1 11.998 2c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.236 3.236c-.464.18-.894.527-.967 1.02Z"/></svg>`,info:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>`,send:u`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`,slidersHorizontal:u`<svg viewBox="0 0 24 24"><line x1="21" x2="14" y1="4" y2="4"/><line x1="10" x2="3" y1="4" y2="4"/><line x1="21" x2="12" y1="12" y2="12"/><line x1="8" x2="3" y1="12" y2="12"/><line x1="21" x2="16" y1="20" y2="20"/><line x1="12" x2="3" y1="20" y2="20"/><line x1="14" x2="14" y1="2" y2="6"/><line x1="8" x2="8" y1="10" y2="14"/><line x1="16" x2="16" y1="18" y2="22"/></svg>`,square:u`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:u`<svg viewBox="0 0 24 24"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`,eyeOff:u`<svg viewBox="0 0 24 24"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,trash:u`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,mic:u`<svg viewBox="0 0 24 24"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" x2="12" y1="19" y2="22"/></svg>`,chevronDown:u`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:u`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/></svg>`,wifi:u`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M2 8.82a15 15 0 0 1 20 0"/><path d="M5 12.859a10 10 0 0 1 14 0"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/></svg>`,wifiOff:u`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/><path d="M5 12.859a10 10 0 0 1 5.17-2.69"/><path d="M13.41 10.28a10 10 0 0 1 5.59 2.58"/><path d="M2 8.82a15 15 0 0 1 4.17-2.65"/><path d="M10.66 5c4.01-.36 8.14.9 11.34 3.76"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,power:u`<svg viewBox="0 0 24 24"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"/><line x1="12" x2="12" y1="2" y2="12"/></svg>`,powerOff:u`<svg viewBox="0 0 24 24"><path d="M18.36 6.64A9 9 0 0 1 20.77 15"/><path d="M6.16 6.16a9 9 0 1 0 12.68 12.68"/><path d="M12 2v4"/><path d="m2 2 20 20"/></svg>`},Zf=u`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`,eg=u`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path><path d="M13.73 21a2 2 0 0 1-3.46 0"></path></svg>`;let ma=!1;function tg(){ma||(ma=!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 Mt(e,t){var l;const n=(p,f)=>p===e?u`<span class="sp-page-nav-current">${p}</span>`:u`<a href=${f}>${p}</a>`,i=u`
|
|
20
|
+
`}function uc(e,t,n){if(t.length===0)return;let i=e;for(let o=0;o<t.length-1;o+=1){const r=t[o],a=t[o+1];if(typeof r=="number"){if(!Array.isArray(i))return;i[r]==null&&(i[r]=typeof a=="number"?[]:{}),i=i[r]}else{if(typeof i!="object"||i==null)return;const d=i;d[r]==null&&(d[r]=typeof a=="number"?[]:{}),i=d[r]}}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 Fe(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});fh(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function pc(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});hh(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function hh(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function fh(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?St(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=St(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=st(t.config??{}),e.configFormOriginal=st(t.config??{}),e.configRawOriginal=n)}async function gh(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?St(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 Fe(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function Yt(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 Fn(e){if(!(!e.client||!e.connected)&&!e.cronLoading){e.cronLoading=!0,e.cronError=null;try{const t={includeDisabled:!0};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(t.agentIds=e.workspaceAgentIds);const n=await e.client.request("cron.list",t);e.cronJobs=Array.isArray(n.jobs)?n.jobs:[]}catch(t){e.cronError=String(t)}finally{e.cronLoading=!1}}}function hc(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=Ai(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 fc(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 r=o.trim();r&&i.push(r)}i.length>0&&(n.to=i.join(","));const s=Ai(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function mh(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=hc(e.cronForm),i=fc(e.cronForm),s=e.cronForm.agentId.trim(),o=(t=e.cronForm.accountId)==null?void 0:t.trim(),r={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(!r.name)throw new Error("Name required.");await e.client.request("cron.add",r),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await Fn(e),await Yt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function yh(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 Fn(e),await Yt(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function vh(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 ro(e,t.id)}catch(n){e.cronError=String(n),e.cronRunResult={status:"error",error:String(n)}}finally{e.cronBusy=!1}}}function bh(e,t){e.cronRunModalJobId&&t.jobId===e.cronRunModalJobId&&t.action==="finished"&&(e.cronRunResult={status:t.status??"unknown",durationMs:t.durationMs,summary:t.summary,error:t.error})}async function wh(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 Fn(e),await Yt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}function kh(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(r=>r.trim()).filter(Boolean);t.toAdmins=o.some(r=>r.toLowerCase()==="admins"),t.recipients=o.filter(r=>r.toLowerCase()!=="admins")}}return(n=e.isolation)!=null&&n.postToMainPrefix&&(t.postToMainPrefix=e.isolation.postToMainPrefix),t}async function $h(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=hc(e.cronForm),i=fc(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 Fn(e),await Yt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function ro(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 Y(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 Uo(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 gc(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 mc(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 yc(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=st(s.config??{});(!o.channels||typeof o.channels!="object")&&(o.channels={});const r=o.channels;(!r.whatsapp||typeof r.whatsapp!="object")&&(r.whatsapp={});const a=r.whatsapp;(!a.accounts||typeof a.accounts!="object")&&(a.accounts={});const d=a.accounts;if(d[i]){e.whatsappAccountError=`Account "${i}" already exists.`;return}d[i]={name:n,provider:"baileys"};const c=s.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const l=St(o);await e.client.request("config.set",{raw:l,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await Y(e,!0),await Uo(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function vc(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=st(n.config??{}),s=i.channels,o=s==null?void 0:s.whatsapp,r=o==null?void 0:o.accounts;if(!r){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(r).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!r[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete r[t],Array.isArray(i.bindings)&&(i.bindings=i.bindings.filter(l=>{const p=l.match;return!p||p.channel!=="whatsapp"?!0:p.accountId!==t}));const d=n.hash;if(!d){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=St(i);await e.client.request("config.set",{raw:c,baseHash:d}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await Y(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const Sh=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:yc,loadChannels:Y,logoutWhatsApp:mc,removeWhatsAppAccount:vc,startWhatsAppLogin:Uo,waitWhatsAppLogin:gc},Symbol.toStringTag,{value:"Module"}));async function Wo(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 xh=2e3,Ah=new Set(["trace","debug","info","warn","error","fatal"]);function Eh(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 Ch(e){if(typeof e!="string")return null;const t=e.toLowerCase();return Ah.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=Ch((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,r=Eh(o);let a=null;r&&(typeof r.subsystem=="string"?a=r.subsystem:typeof r.module=="string"&&(a=r.module)),!a&&o&&o.length<120&&(a=o);let d=null;return typeof t[1]=="string"?d=t[1]:!r&&typeof t[0]=="string"?d=t[0]:typeof t.message=="string"&&(d=t.message),{raw:e,time:i,level:s,subsystem:a,message:d??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Ht(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.logsLoading=!0),e.logsError=null;try{const i=await e.client.request("logs.tail",{cursor:t!=null&&t.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),o=(Array.isArray(i.lines)?i.lines.filter(a=>typeof a=="string"):[]).map(bc),r=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=r?o:[...e.logsEntries,...o].slice(-xh),typeof i.cursor=="number"&&(e.logsCursor=i.cursor),typeof i.file=="string"&&(e.logsFile=i.file),e.logsTruncated=!!i.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t!=null&&t.quiet||(e.logsLoading=!1)}}}const Th=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:Ht,parseLogLine:bc},Symbol.toStringTag,{value:"Module"}));const wc={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ce,n:mi,Gx:ua,Gy:pa,a:As,d:Es,h:_h}=wc,xt=32,Ko=64,Mh=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},se=(e="")=>{const t=new Error(e);throw Mh(t,se),t},Ph=e=>typeof e=="bigint",Lh=e=>typeof e=="string",Ih=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",rt=(e,t,n="")=>{const i=Ih(e),s=e==null?void 0:e.length,o=t!==void 0;if(!i||o&&s!==t){const r=n&&`"${n}" `,a=o?` of length ${t}`:"",d=i?`length=${s}`:`type=${typeof e}`;se(r+"expected Uint8Array"+a+", got "+d)}return e},Ji=e=>new Uint8Array(e),kc=e=>Uint8Array.from(e),$c=(e,t)=>e.toString(16).padStart(t,"0"),Sc=e=>Array.from(rt(e)).map(t=>$c(t,2)).join(""),ze={_0:48,_9:57,A:65,F:70,a:97,f:102},ha=e=>{if(e>=ze._0&&e<=ze._9)return e-ze._0;if(e>=ze.A&&e<=ze.F)return e-(ze.A-10);if(e>=ze.a&&e<=ze.f)return e-(ze.a-10)},xc=e=>{const t="hex invalid";if(!Lh(e))return se(t);const n=e.length,i=n/2;if(n%2)return se(t);const s=Ji(i);for(let o=0,r=0;o<i;o++,r+=2){const a=ha(e.charCodeAt(r)),d=ha(e.charCodeAt(r+1));if(a===void 0||d===void 0)return se(t);s[o]=a*16+d}return s},Ac=()=>globalThis==null?void 0:globalThis.crypto,Rh=()=>{var e;return((e=Ac())==null?void 0:e.subtle)??se("crypto.subtle must be defined, consider polyfill")},Dn=(...e)=>{const t=Ji(e.reduce((i,s)=>i+rt(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},Dh=(e=xt)=>Ac().getRandomValues(Ji(e)),Ci=BigInt,ft=(e,t,n,i="bad number: out of range")=>Ph(e)&&t<=e&&e<n?e:se(i),I=(e,t=ce)=>{const n=e%t;return n>=0n?n:t+n},Ec=e=>I(e,mi),Nh=(e,t)=>{(e===0n||t<=0n)&&se("no inverse n="+e+" mod="+t);let n=I(e,t),i=t,s=0n,o=1n;for(;n!==0n;){const r=i/n,a=i%n,d=s-o*r;i=n,n=a,s=o,o=d}return i===1n?I(s,t):se("no inverse")},Bh=e=>{const t=Mc[e];return typeof t!="function"&&se("hashes."+e+" not set"),t},Cs=e=>e instanceof At?e:se("Point expected"),ao=2n**256n,De=class De{constructor(t,n,i,s){W(this,"X");W(this,"Y");W(this,"Z");W(this,"T");const o=ao;this.X=ft(t,0n,o),this.Y=ft(n,0n,o),this.Z=ft(i,1n,o),this.T=ft(s,0n,o),Object.freeze(this)}static CURVE(){return wc}static fromAffine(t){return new De(t.x,t.y,1n,I(t.x*t.y))}static fromBytes(t,n=!1){const i=Es,s=kc(rt(t,xt)),o=t[31];s[31]=o&-129;const r=Tc(s);ft(r,0n,n?ao:ce);const d=I(r*r),c=I(d-1n),l=I(i*d+1n);let{isValid:p,value:h}=Oh(c,l);p||se("bad point: y not sqrt");const v=(h&1n)===1n,S=(o&128)!==0;return!n&&h===0n&&S&&se("bad point: x==0, isLastByteOdd"),S!==v&&(h=I(-h)),new De(h,r,1n,I(h*r))}static fromHex(t,n){return De.fromBytes(xc(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=As,n=Es,i=this;if(i.is0())return se("bad point: ZERO");const{X:s,Y:o,Z:r,T:a}=i,d=I(s*s),c=I(o*o),l=I(r*r),p=I(l*l),h=I(d*t),v=I(l*I(h+c)),S=I(p+I(n*I(d*c)));if(v!==S)return se("bad point: equation left != right (1)");const f=I(s*o),w=I(r*a);return f!==w?se("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:r,Z:a}=Cs(t),d=I(n*a),c=I(o*s),l=I(i*a),p=I(r*s);return d===c&&l===p}is0(){return this.equals(Kt)}negate(){return new De(I(-this.X),this.Y,this.Z,I(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=As,o=I(t*t),r=I(n*n),a=I(2n*I(i*i)),d=I(s*o),c=t+n,l=I(I(c*c)-o-r),p=d+r,h=p-a,v=d-r,S=I(l*h),f=I(p*v),w=I(l*v),b=I(h*p);return new De(S,f,b,w)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:r,Y:a,Z:d,T:c}=Cs(t),l=As,p=Es,h=I(n*r),v=I(i*a),S=I(o*p*c),f=I(s*d),w=I((n+i)*(r+a)-h-v),b=I(f-S),x=I(f+S),A=I(v-l*h),C=I(w*b),M=I(x*A),_=I(w*A),B=I(b*x);return new De(C,M,B,_)}subtract(t){return this.add(Cs(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return Kt;if(ft(t,1n,mi),t===1n)return this;if(this.equals(Et))return Jh(t).p;let i=Kt,s=Et;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(Kt))return{x:0n,y:1n};const s=Nh(i,ce);I(i*s)!==1n&&se("invalid inverse");const o=I(t*s),r=I(n*s);return{x:o,y:r}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=Cc(n);return i[31]|=t&1n?128:0,i}toHex(){return Sc(this.toBytes())}clearCofactor(){return this.multiply(Ci(_h),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(mi/2n,!1).double();return mi%2n&&(t=t.add(this)),t.is0()}};W(De,"BASE"),W(De,"ZERO");let At=De;const Et=new At(ua,pa,1n,I(ua*pa)),Kt=new At(0n,1n,1n,0n);At.BASE=Et;At.ZERO=Kt;const Cc=e=>xc($c(ft(e,0n,ao),Ko)).reverse(),Tc=e=>Ci("0x"+Sc(kc(rt(e)).reverse())),Me=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=ce;return n},Fh=e=>{const n=e*e%ce*e%ce,i=Me(n,2n)*n%ce,s=Me(i,1n)*e%ce,o=Me(s,5n)*s%ce,r=Me(o,10n)*o%ce,a=Me(r,20n)*r%ce,d=Me(a,40n)*a%ce,c=Me(d,80n)*d%ce,l=Me(c,80n)*d%ce,p=Me(l,10n)*o%ce;return{pow_p_5_8:Me(p,2n)*e%ce,b2:n}},fa=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Oh=(e,t)=>{const n=I(t*t*t),i=I(n*n*t),s=Fh(e*i).pow_p_5_8;let o=I(e*n*s);const r=I(t*o*o),a=o,d=I(o*fa),c=r===e,l=r===I(-e),p=r===I(-e*fa);return c&&(o=a),(l||p)&&(o=d),(I(o)&1n)===1n&&(o=I(-o)),{isValid:c||l,value:o}},lo=e=>Ec(Tc(e)),zo=(...e)=>Mc.sha512Async(Dn(...e)),Uh=(...e)=>Bh("sha512")(Dn(...e)),_c=e=>{const t=e.slice(0,xt);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(xt,Ko),i=lo(t),s=Et.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},Ho=e=>zo(rt(e,xt)).then(_c),Wh=e=>_c(Uh(rt(e,xt))),Kh=e=>Ho(e).then(t=>t.pointBytes),zh=e=>zo(e.hashable).then(e.finish),Hh=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=lo(t),r=Et.multiply(o).toBytes();return{hashable:Dn(r,i,n),finish:c=>{const l=Ec(o+lo(c)*s);return rt(Dn(r,Cc(l)),Ko)}}},qh=async(e,t)=>{const n=rt(e),i=await Ho(t),s=await zo(i.prefix,n);return zh(Hh(i,s,n))},Mc={sha512Async:async e=>{const t=Rh(),n=Dn(e);return Ji(await t.digest("SHA-512",n.buffer))},sha512:void 0},jh=(e=Dh(xt))=>e,Vh={getExtendedPublicKeyAsync:Ho,getExtendedPublicKey:Wh,randomSecretKey:jh},Ti=8,Gh=256,Pc=Math.ceil(Gh/Ti)+1,co=2**(Ti-1),Qh=()=>{const e=[];let t=Et,n=t;for(let i=0;i<Pc;i++){n=t,e.push(n);for(let s=1;s<co;s++)n=n.add(t),e.push(n);t=n.double()}return e};let ga;const ma=(e,t)=>{const n=t.negate();return e?n:t},Jh=e=>{const t=ga||(ga=Qh());let n=Kt,i=Et;const s=2**Ti,o=s,r=Ci(s-1),a=Ci(Ti);for(let d=0;d<Pc;d++){let c=Number(e&r);e>>=a,c>co&&(c-=o,e+=1n);const l=d*co,p=l,h=l+Math.abs(c)-1,v=d%2!==0,S=c<0;c===0?i=i.add(ma(v,t[p])):n=n.add(ma(S,t[h]))}return e!==0n&&se("invalid wnaf"),{p:n,f:i}},Ts="taskmaster-device-identity-v1";function uo(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Lc(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 Yh(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Ic(e){const t=await crypto.subtle.digest("SHA-256",e);return Yh(new Uint8Array(t))}async function Xh(){const e=Vh.randomSecretKey(),t=await Kh(e);return{deviceId:await Ic(t),publicKey:uo(t),privateKey:uo(e)}}async function Zh(){try{const n=localStorage.getItem(Ts);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 Ic(Lc(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(Ts,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 Xh(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Ts,JSON.stringify(t)),e}async function ef(e,t){const n=Lc(e),i=new TextEncoder().encode(t),s=await qh(i,n);return uo(s)}const Rc="taskmaster.device.auth.v1";function qo(e){return e.trim()}function tf(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 jo(){try{const e=window.localStorage.getItem(Rc);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(Rc,JSON.stringify(e))}catch{}}function nf(e){const t=jo();if(!t||t.deviceId!==e.deviceId)return null;const n=qo(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function sf(e){const t=qo(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=jo();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:tf(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,Dc(n),s}function of(e){const t=jo();if(!t||t.deviceId!==e.deviceId)return;const n=qo(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],Dc(i)}async function Vo(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 Go(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 rf(e){return{method:"exec.approvals.get",params:{}}}async function af(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=rf(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);lf(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function lf(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=st(t.file??{}))}async function Nc(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 ot(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function Qe(e){return e instanceof Error?e.message:String(e)}function Nn(){return{name:"",skillContent:"",references:[]}}async function Ge(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=Qe(n)}finally{e.skillsLoading=!1}}}function Bc(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Fc(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 Ge(e),ot(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=Qe(i);e.skillsError=s,ot(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Oc(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 Ge(e),ot(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=Qe(n);e.skillsError=i,ot(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 Ge(e),ot(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=Qe(s);e.skillsError=o,ot(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=Qe(n)}}function Kc(e){e.skillDetail=null,e.skillDetailTab=""}function zc(e,t){e.skillDetailTab=t}async function Hc(e){if(e.skillAddModal=!0,e.skillAddForm=Nn(),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=Nn(),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}))},e.skillAddFormSource="draft"}async function Vc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n}))},e.skillAddFormSource="installed",await Qo(e)}async function Qo(e){if(!e.client||!e.connected)return;const t=e.skillAddForm;if(!(!t.name.trim()||!t.skillContent.trim())){e.skillsBusyKey="__add__",e.skillsError=null;try{const n=t.references.filter(s=>s.name.trim()&&s.content.trim()).map(s=>({name:s.name.trim(),content:s.content})),i=t.name.trim();e.skillAddFormSource==="installed"?(await e.client.request("skills.create",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=Nn(),e.skillAddFormSource="draft",e.skillDrafts=[],await Ge(e),ot(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=Nn(),e.skillAddFormSource="draft",e.skillDrafts=[],ot(e,i,{kind:"success",message:"Draft saved"}))}catch(n){e.skillsError=Qe(n)}finally{e.skillsBusyKey=null}}}async function Gc(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=Qe(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}))},e.skillAddFormSource="installed",e.skillAddModal=!0,e.skillDrafts=[]}catch(n){e.skillsError=Qe(n)}}function Jc(e,t){const n=e.skillDetail;n&&(e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i}))},e.skillAddFormSource="installed",e.skillEditTab=t&&t!=="SKILL.md"?t:"SKILL.md",e.skillDetail=null,e.skillDetailTab="",e.skillAddModal=!0,e.skillDrafts=[])}function 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){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.delete",{name:t}),await Ge(e)}catch(n){e.skillsError=Qe(n)}finally{e.skillsBusyKey=null}}}const cf=Object.freeze(Object.defineProperty({__proto__:null,closeAddSkillModal:qc,closeSkillDetail:Kc,deleteDraft:Gc,deleteSkill:Zc,editDetailSkill:Jc,editSkill:Qc,emptyAddForm:Nn,importDraft:jc,installDraft:Vc,installSkill:Uc,loadSkills:Ge,openAddSkillModal:Hc,saveNewSkill:Qo,saveSkillApiKey:Oc,setEditTab:Xc,setSkillDetailTab:zc,updateFormReference:Yc,updateSkillEdit:Bc,updateSkillEnabled:Fc,viewSkillDetail:Wc},Symbol.toStringTag,{value:"Module"})),ed={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},td=new Map(Object.entries(ed).map(([e,t])=>[t,e]));function Yi(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function Bn(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 df(e,t=""){const n=Yi(t),i=ed[e];return n?`${n}${i}`:i}function nd(e,t=""){const n=Yi(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=Bn(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":td.get(s)??null}function uf(e){let t=Bn(e);if(t.endsWith("/index.html")&&(t=Bn(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(td.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function pf(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Jo(e){return e==="system"?pf():e}const ii=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,hf=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,si=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},ff=({nextTheme:e,applyTheme:t,context:n,currentTheme:i})=>{var c;if(i===e)return;const s=globalThis.document??null;if(!s){t();return}const o=s.documentElement,r=s,a=hf();if(!!r.startViewTransition&&!a){let l=.5,p=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")l=ii(n.pointerClientX/window.innerWidth),p=ii(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const h=n.element.getBoundingClientRect();h.width>0&&h.height>0&&typeof window<"u"&&(l=ii((h.left+h.width/2)/window.innerWidth),p=ii((h.top+h.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${l*100}%`),o.style.setProperty("--theme-switch-y",`${p*100}%`),o.classList.add("theme-transition");try{const h=(c=r.startViewTransition)==null?void 0:c.call(r,()=>{t()});h!=null&&h.finished?h.finished.finally(()=>si(o)):si(o)}catch{si(o),t()}return}t(),si(o)},gf=2e3;async function xn(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:[],r=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=r?o:[...e.sessionLogsEntries,...o].slice(-gf),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 id=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:xn},Symbol.toStringTag,{value:"Module"}));async function sd(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 mf(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function Oe(e){return e instanceof Error?e.message:String(e)}let oi=null;function Xt(e,t){oi&&clearTimeout(oi),e.filesMessage={kind:"success",text:t},oi=setTimeout(()=>{e.filesMessage=null,oi=null},3e3)}async function Zt(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=Oe(n)}finally{e.filesLoading=!1}}}}async function yf(e,t,n){e.filesSelectedPaths=new Set([t]),await od(e,t,n)}async function vf(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 od(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function bf(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 rd(e,o,t),i++}catch(r){s=Oe(r)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:Xt(e,`${i} file${i!==1?"s":""} downloaded`)}async function wf(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await xf(e,t,o,i)}async function od(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=Oe(i)}finally{e.filesPreviewLoading=!1}}}async function rd(e,t,n){if(!(!e.client||!e.connected))try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.download",i);if(!(s!=null&&s.base64)){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const o=Uint8Array.from(atob(s.base64),c=>c.charCodeAt(0)),r=new Blob([o]),a=URL.createObjectURL(r),d=document.createElement("a");d.href=a,d.download=s.name??t.split("/").pop()??"download",document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(a)}catch(i){e.filesMessage={kind:"error",text:Oe(i)}}}async function kf(e,t,n,i){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let s=0,o="";for(const r of n)try{const a=await r.arrayBuffer(),d=btoa(new Uint8Array(a).reduce((l,p)=>l+String.fromCharCode(p),"")),c={path:t,name:r.name,data:d};i&&(c.agentId=i),await e.client.request("files.upload",c),s++}catch(a){o=Oe(a)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:Xt(e,`${s} file${s!==1?"s":""} uploaded`),await Zt(e,i)}async function $f(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),Xt(e,`Created ${s}`),await Zt(e,i),e.filesExpandedDirs=new Set([...e.filesExpandedDirs,s]),e.filesCurrentDir=s}catch(o){e.filesMessage={kind:"error",text:Oe(o)}}}async function Sf(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),Xt(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await Zt(e,n)}catch(i){e.filesMessage={kind:"error",text:Oe(i)}}}}async function xf(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),Xt(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await Zt(e,i)}catch(s){e.filesMessage={kind:"error",text:Oe(s)}}}}async function Yo(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 Af(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;Xt(e,`Re-indexed: ${s} files, ${o} chunks`),await Yo(e,t)}catch(n){e.filesMessage={kind:"error",text:Oe(n)}}finally{e.filesReindexBusy=!1}}}function Ef(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 Cf(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:Oe(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function Tf(e){e.filesSearchQuery="",e.filesSearchResults=null}function _f(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{Go(e,{quiet:!0})},5e3))}function Mf(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function Xo(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Ht(e,{quiet:!0})},2e3))}function Zo(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function er(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||xn(e,{quiet:!0})},2e3))}function tr(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function nr(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&Wo(e)},3e3))}function ir(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Pf(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{sd(e)},3e4))}function Lf(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function If(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{if(e.tab!=="files")return;const t=e;Yo(t,t.filesResolvedAgentId)},3e3))}function Rf(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function nt(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,Tp(n),t.theme!==e.theme&&(e.theme=t.theme,Xi(e,Jo(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function ad(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&nt(e,{...e.settings,lastActiveSessionKey:n})}function Df(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 r=!1;if(n!=null){const d=n.trim();d&&d!==e.settings.token&&nt(e,{...e.settings,token:d}),t.delete("token"),r=!0}if(i!=null){const d=i.trim();d&&(e.password=d),t.delete("password"),r=!0}if(s!=null){const d=s.trim();d&&(e.sessionKey=d,nt(e,{...e.settings,sessionKey:d,lastActiveSessionKey:d}))}if(o!=null){const d=o.trim();d&&d!==e.settings.gatewayUrl&&nt(e,{...e.settings,gatewayUrl:d}),t.delete("gatewayUrl"),r=!0}if(!r)return;const a=new URL(window.location.href);a.search=t.toString(),window.history.replaceState({},"",a.toString())}function Nf(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?er(e):Xo(e):(Zo(e),tr(e)),t==="debug"?nr(e):ir(e),_i(e),cd(e,t,!1)}function Bf(e,t,n){ff({nextTheme:t,applyTheme:()=>{e.theme=t,nt(e,{...e.settings,theme:t}),Xi(e,Jo(t))},context:n,currentTheme:e.theme})}async function _i(e){if(e.tab==="overview"&&await dd(e),e.tab==="channels"&&await Hf(e),e.tab==="instances"&&await Nc(e),e.tab==="cron"&&await sr(e),e.tab==="skills"&&await Ge(e),e.tab==="nodes"&&(await Go(e),await Vo(e),await Fe(e),await af(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await Qf(e),Jt(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await pc(e),await Fe(e)),e.tab==="debug"&&(await Wo(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await re(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>id);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await Ht(e,{reset:!0});dc(e,!0)}}function Ff(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?Yi(e):uf(window.location.pathname)}function Of(e){e.theme=e.settings.theme??"system",Xi(e,Jo(e.theme))}function Xi(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function Uf(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"&&Xi(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Wf(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 Kf(e,t){if(typeof window>"u")return;const n=nd(window.location.pathname,e.basePath)??"chat";ld(e,n),cd(e,n,t)}function zf(e){var s;if(typeof window>"u")return;const t=nd(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,nt(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),ld(e,t)}function ld(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?er(e):Xo(e):(Zo(e),tr(e)),t==="debug"?nr(e):ir(e),e.connected&&_i(e)}function cd(e,t,n){if(typeof window>"u")return;const i=Bn(df(t,e.basePath)),s=Bn(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 dd(e){await Promise.all([Y(e,!1),Nc(e),Fo(e),Yt(e),Wo(e)])}async function Hf(e){await Promise.all([Y(e,!0),pc(e),Fe(e)])}async function sr(e){await Promise.all([Y(e,!1),Yt(e),Fn(e)])}function ud(e){return e.chatSending||!!e.chatRunId}function qf(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 pd(e){e.connected&&(e.chatMessage="",await lc(e))}function jf(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:Qi(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],Jt(e))}async function hd(e,t,n){var s,o;Oo(e);const i=await ac(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&&ad(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),Jt(e),i&&!e.chatRunId&&fd(e),i}async function fd(e){if(!e.connected||ud(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await hd(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function Vf(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function Gf(e,t,n){if(!e.connected)return;const i=e.chatMessage,s=(t??e.chatMessage).trim(),o=e.chatAttachments??[],r=t==null?o:[],a=r.length>0;if(!(!s&&!a)){if(qf(s)){await pd(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[],Mp(e.selectedWorkspace??"",e.sessionKey)),ud(e)){jf(e,s,r);return}await hd(e,s,{previousDraft:t==null?i:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:a?r:void 0,previousAttachments:t==null?o:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function Qf(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,Be);await Promise.all([Ne(t,{limit:n}),Fo(t),po(e)]),Jt(e,!0)}const Jf=fd;function Yf(e){var s,o,r;const t=Zl(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(s=e.hello)==null?void 0:s.snapshot;return((r=(o=n==null?void 0:n.sessionDefaults)==null?void 0:o.defaultAgentId)==null?void 0:r.trim())||"main"}function Xf(e,t){const n=Yi(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function po(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=Yf(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=Xf(e.basePath,t);try{const i=await fetch(n,{method:"GET"});if(!i.ok){e.chatAvatarUrl=null;return}const s=await i.json(),o=typeof s.avatarUrl=="string"?s.avatarUrl.trim():"";e.chatAvatarUrl=o||null}catch{e.chatAvatarUrl=null}}const L={messageSquare:u`<svg viewBox="0 0 24 24"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,barChart:u`<svg viewBox="0 0 24 24"><line x1="12" x2="12" y1="20" y2="10"/><line x1="18" x2="18" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="16"/></svg>`,link:u`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,unlink:u`<svg viewBox="0 0 24 24"><path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"/><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"/><line x1="8" x2="8" y1="2" y2="5"/><line x1="2" x2="5" y1="8" y2="8"/><line x1="16" x2="16" y1="19" y2="22"/><line x1="19" x2="22" y1="16" y2="16"/></svg>`,radio:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="2"/><path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"/></svg>`,fileText:u`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><line x1="16" x2="8" y1="13" y2="13"/><line x1="16" x2="8" y1="17" y2="17"/><line x1="10" x2="8" y1="9" y2="9"/></svg>`,zap:u`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:u`<svg viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>`,settings:u`<svg viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>`,bug:u`<svg viewBox="0 0 24 24"><path d="m8 2 1.88 1.88"/><path d="M14.12 3.88 16 2"/><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9"/><path d="M6.53 9C4.6 8.8 3 7.1 3 5"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="M22 13h-4"/><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"/></svg>`,scrollText:u`<svg viewBox="0 0 24 24"><path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M15 8h-5"/><path d="M15 12h-5"/></svg>`,folder:u`<svg viewBox="0 0 24 24"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>`,users:u`<svg viewBox="0 0 24 24"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>`,menu:u`<svg viewBox="0 0 24 24"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>`,x:u`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:u`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:u`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,search:u`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:u`<svg viewBox="0 0 24 24"><path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/><path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/><path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/><path d="M17.599 6.5a3 3 0 0 0 .399-1.375"/><path d="M6.003 5.125A3 3 0 0 0 6.401 6.5"/><path d="M3.477 10.896a4 4 0 0 1 .585-.396"/><path d="M19.938 10.5a4 4 0 0 1 .585.396"/><path d="M6 18a4 4 0 0 1-1.967-.516"/><path d="M19.967 17.484A4 4 0 0 1 18 18"/></svg>`,book:u`<svg viewBox="0 0 24 24"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/></svg>`,loader:u`<svg viewBox="0 0 24 24"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>`,rotateCw:u`<svg viewBox="0 0 24 24"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>`,download:u`<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,wrench:u`<svg viewBox="0 0 24 24"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>`,fileCode:u`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><path d="m10 13-2 2 2 2"/><path d="m14 17 2-2-2-2"/></svg>`,edit:u`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,penLine:u`<svg viewBox="0 0 24 24"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>`,paperclip:u`<svg viewBox="0 0 24 24"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`,globe:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>`,globeOff:u`<svg viewBox="0 0 24 24"><path d="M21.54 15H17"/><path d="M7 3.34V5a3 3 0 0 0 3 3 2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17"/><path d="M11 21.95V18a2 2 0 0 0-2-2 2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05"/><circle cx="12" cy="12" r="10"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,image:u`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>`,smartphone:u`<svg viewBox="0 0 24 24"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>`,plug:u`<svg viewBox="0 0 24 24"><path d="M12 22v-5"/><path d="M9 8V2"/><path d="M15 8V2"/><path d="M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z"/></svg>`,circle:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>`,puzzle:u`<svg viewBox="0 0 24 24"><path d="M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.076.874.54 1.02 1.02a2.5 2.5 0 1 0 3.237-3.237c-.48-.146-.944-.505-1.02-1.02a.98.98 0 0 1 .303-.917l1.526-1.526A2.402 2.402 0 0 1 11.998 2c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.236 3.236c-.464.18-.894.527-.967 1.02Z"/></svg>`,info:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>`,send:u`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`,slidersHorizontal:u`<svg viewBox="0 0 24 24"><line x1="21" x2="14" y1="4" y2="4"/><line x1="10" x2="3" y1="4" y2="4"/><line x1="21" x2="12" y1="12" y2="12"/><line x1="8" x2="3" y1="12" y2="12"/><line x1="21" x2="16" y1="20" y2="20"/><line x1="12" x2="3" y1="20" y2="20"/><line x1="14" x2="14" y1="2" y2="6"/><line x1="8" x2="8" y1="10" y2="14"/><line x1="16" x2="16" y1="18" y2="22"/></svg>`,square:u`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:u`<svg viewBox="0 0 24 24"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`,eyeOff:u`<svg viewBox="0 0 24 24"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,trash:u`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,mic:u`<svg viewBox="0 0 24 24"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" x2="12" y1="19" y2="22"/></svg>`,chevronDown:u`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:u`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/></svg>`,wifi:u`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M2 8.82a15 15 0 0 1 20 0"/><path d="M5 12.859a10 10 0 0 1 14 0"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/></svg>`,wifiOff:u`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/><path d="M5 12.859a10 10 0 0 1 5.17-2.69"/><path d="M13.41 10.28a10 10 0 0 1 5.59 2.58"/><path d="M2 8.82a15 15 0 0 1 4.17-2.65"/><path d="M10.66 5c4.01-.36 8.14.9 11.34 3.76"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,power:u`<svg viewBox="0 0 24 24"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"/><line x1="12" x2="12" y1="2" y2="12"/></svg>`,powerOff:u`<svg viewBox="0 0 24 24"><path d="M18.36 6.64A9 9 0 0 1 20.77 15"/><path d="M6.16 6.16a9 9 0 1 0 12.68 12.68"/><path d="M12 2v4"/><path d="m2 2 20 20"/></svg>`},Zf=u`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`,eg=u`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path><path d="M13.73 21a2 2 0 0 1-3.46 0"></path></svg>`;let ya=!1;function tg(){ya||(ya=!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 Mt(e,t){var l;const n=(p,h)=>p===e?u`<span class="sp-page-nav-current">${p}</span>`:u`<a href=${h}>${p}</a>`,i=u`
|
|
21
21
|
${n("Setup","/setup")}
|
|
22
22
|
${n("Chat","/chat")}
|
|
23
23
|
${n("Admins","/admins")}
|
|
@@ -196,7 +196,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
196
196
|
<p>Connecting to gateway...</p>
|
|
197
197
|
</div>
|
|
198
198
|
</div>
|
|
199
|
-
`}const Mi="application/x-taskmaster-file-path";let pt=null;function
|
|
199
|
+
`}const Mi="application/x-taskmaster-file-path";let pt=null;function gd(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function md(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function sg(e,t,n){var o,r;e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("sp-drop-target");const i=(o=e.dataTransfer)==null?void 0:o.getData(Mi);if(i){md(i)!==t&&n.onMoveToDir(i,t);return}const s=(r=e.dataTransfer)==null?void 0:r.files;if(s&&s.length>0){const a=Array.from(s).filter(d=>d.name.toLowerCase().endsWith(".md"));a.length>0&&n.onUpload(t,a)}}function yd(e,t,n){var d;const i=e.type==="directory"||e.type==="symlink"&&e.children!=null,s=t.expandedDirs.has(e.path),o=t.selectedPaths.has(e.path),r=t.currentDir===e.path,a=n*20+12;return i?u`
|
|
200
200
|
<div
|
|
201
201
|
class="sp-tree-item sp-tree-dir ${s?"expanded":""} ${r?"current":""}"
|
|
202
202
|
style="padding-left: ${a}px;"
|
|
@@ -214,7 +214,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
214
214
|
@click=${c=>{c.stopPropagation(),t.onDelete(e.path)}}
|
|
215
215
|
>×</span>`:k}
|
|
216
216
|
</div>
|
|
217
|
-
${s&&e.children?e.children.map(c=>
|
|
217
|
+
${s&&e.children?e.children.map(c=>yd(c,t,n+1)):k}
|
|
218
218
|
`:u`
|
|
219
219
|
<div
|
|
220
220
|
class="sp-tree-item sp-tree-file ${o?"selected":""}"
|
|
@@ -225,7 +225,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
225
225
|
>
|
|
226
226
|
<span class="sp-tree-icon">${L.fileText}</span>
|
|
227
227
|
<span class="sp-tree-name">${e.name}</span>
|
|
228
|
-
<span class="sp-tree-size">${
|
|
228
|
+
<span class="sp-tree-size">${gd(e.size)}</span>
|
|
229
229
|
</div>
|
|
230
230
|
`}function og(e){const t=e.selectedPaths.size;return t<2?k:u`
|
|
231
231
|
<div class="sp-bulk-actions">
|
|
@@ -248,7 +248,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
248
248
|
<div>
|
|
249
249
|
<strong>${t}</strong>
|
|
250
250
|
<div class="sp-file-preview-meta">
|
|
251
|
-
${e.selectedPath}${e.previewSize!=null?` — ${
|
|
251
|
+
${e.selectedPath}${e.previewSize!=null?` — ${gd(e.previewSize)}`:""}
|
|
252
252
|
</div>
|
|
253
253
|
</div>
|
|
254
254
|
<div class="sp-file-actions">
|
|
@@ -383,9 +383,9 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
383
383
|
${e.searchResults!==null?lg(e):u`<div
|
|
384
384
|
class="sp-file-tree"
|
|
385
385
|
@dragover=${n=>{n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(Mi)?"move":"copy")}}
|
|
386
|
-
@drop=${n=>{var o,r;n.preventDefault();const i=(o=n.dataTransfer)==null?void 0:o.getData(Mi);if(i){
|
|
386
|
+
@drop=${n=>{var o,r;n.preventDefault();const i=(o=n.dataTransfer)==null?void 0:o.getData(Mi);if(i){md(i)!=="."&&e.onMoveToDir(i,".");return}const s=(r=n.dataTransfer)==null?void 0:r.files;if(s&&s.length>0){const a=Array.from(s).filter(d=>d.name.toLowerCase().endsWith(".md"));a.length>0&&e.onUpload(t,a)}}}
|
|
387
387
|
>
|
|
388
|
-
${e.tree.length===0&&!e.loading?u`<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=>
|
|
388
|
+
${e.tree.length===0&&!e.loading?u`<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=>yd(n,e,0))}
|
|
389
389
|
</div>`}
|
|
390
390
|
|
|
391
391
|
${og(e)}
|
|
@@ -399,7 +399,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
399
399
|
<p>Connecting to gateway...</p>
|
|
400
400
|
</div>
|
|
401
401
|
</div>
|
|
402
|
-
`}const
|
|
402
|
+
`}const or="taskmaster_uninstall_done";async function dg(e){var t,n;if(!(!e.client||!e.connected)&&!e.uninstallBusy){e.uninstallBusy=!0,e.uninstallError=null,(t=e.requestUpdate)==null||t.call(e),ug();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 Pi(){try{return localStorage.getItem(or)==="1"}catch{return!1}}function rr(){try{localStorage.removeItem(or)}catch{}}function ug(){try{localStorage.setItem(or,"1")}catch{}}const va=Object.freeze(Object.defineProperty({__proto__:null,checkUninstallDone:Pi,clearUninstallDone:rr,runUninstall:dg},Symbol.toStringTag,{value:"Module"}));function j(e){return u`
|
|
403
403
|
<span
|
|
404
404
|
class="setup-status-light"
|
|
405
405
|
style="background: ${{good:"#22c55e",bad:"#ef4444",partial:"#eab308",unknown:"#6b7280"}[e]}"
|
|
@@ -412,7 +412,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
412
412
|
>
|
|
413
413
|
${L.info}
|
|
414
414
|
</button>
|
|
415
|
-
`}function pg(e){var i;if(!e.infoModalOpen)return k;let t="",n=[];switch(e.infoModalOpen){case"gateway":{const s=typeof window<"u"?window.location.host:"unknown";t="Gateway",n=[{label:"Status",value:e.gatewayHealthy===!1?"Stopped":"Running"},{label:"Address",value:s},{label:"Health",value:e.gatewayHealthMessage||"OK"}];break}case"claude":{const s=e.authExpiresIn;let o="N/A";if(s!=null&&s>0)if(s>60){const r=Math.floor(s/60),a=s%60;o=a>0?`${r}h ${a}m`:`${r}h`}else o=`${s}m`;t="Claude",n=[{label:"Connected",value:e.authConnected?"Yes":"No"},{label:"Token Expiry",value:o},{label:"Renewal",value:"Automatic (tokens refresh on expiry)"},...e.authMessage?[{label:"Message",value:e.authMessage}]:[]];break}case"license":{const s=e.licenseStoredKey?`…${e.licenseStoredKey.slice(-12)}`:"N/A";t="License",n=[{label:"Status",value:e.licenseValid?"Active":"Inactive"},{label:"Key",value:s},{label:"Tier",value:e.licenseTier||"Standard"},{label:"Device ID",value:e.licenseDeviceId||"N/A"}];break}case"whatsapp":{const s=en(e),o=s?
|
|
415
|
+
`}function pg(e){var i;if(!e.infoModalOpen)return k;let t="",n=[];switch(e.infoModalOpen){case"gateway":{const s=typeof window<"u"?window.location.host:"unknown";t="Gateway",n=[{label:"Status",value:e.gatewayHealthy===!1?"Stopped":"Running"},{label:"Address",value:s},{label:"Health",value:e.gatewayHealthMessage||"OK"}];break}case"claude":{const s=e.authExpiresIn;let o="N/A";if(s!=null&&s>0)if(s>60){const r=Math.floor(s/60),a=s%60;o=a>0?`${r}h ${a}m`:`${r}h`}else o=`${s}m`;t="Claude",n=[{label:"Connected",value:e.authConnected?"Yes":"No"},{label:"Token Expiry",value:o},{label:"Renewal",value:"Automatic (tokens refresh on expiry)"},...e.authMessage?[{label:"Message",value:e.authMessage}]:[]];break}case"license":{const s=e.licenseStoredKey?`…${e.licenseStoredKey.slice(-12)}`:"N/A";t="License",n=[{label:"Status",value:e.licenseValid?"Active":"Inactive"},{label:"Key",value:s},{label:"Tier",value:e.licenseTier||"Standard"},{label:"Device ID",value:e.licenseDeviceId||"N/A"}];break}case"whatsapp":{const s=en(e),o=s?ar(s,e):null;t="WhatsApp",n=[{label:"Account",value:(o==null?void 0:o.name)||(o==null?void 0:o.accountId)||"Default"},{label:"Phone",value:((i=o==null?void 0:o.self)==null?void 0:i.e164)||"Not paired"},{label:"Connected",value:o!=null&&o.connected?"Yes":"No"},{label:"Linked",value:o!=null&&o.linked?"Yes":"No"},...o!=null&&o.lastError?[{label:"Last Error",value:lr(o.lastError)}]:[]];break}case"imessage":{const{thisWsOwns:s}=cr(e);t="iMessage",n=[{label:"Connected",value:s&&e.imessageConnected?"Yes":"No"},{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:"Current",value:e.currentVersion?`v${e.currentVersion}`:"Unknown"},{label:"Latest",value:e.latestVersion?`v${e.latestVersion}`:"Unknown"},{label:"Status",value:e.updateAvailable===null?"Not checked":e.updateAvailable?"Update available":"Up to date"},...e.updateMessage?[{label:"Message",value:e.updateMessage}]:[]];break}case"remote-access":{const s=e.tailscaleStatus,o=s?s.installed?s.loggedIn?s.serveEnabled&&s.serveActive?"Active":s.serveEnabled&&!s.serveActive?"Enabled but not active":"Off":"Not connected":"Not installed":"Checking...";t="Remote Access",n=[{label:"Status",value:o},{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)"},...s!=null&&s.tailnetUrl?[{label:"URL",value:`${s.tailnetUrl} — bookmark this on your other devices`}]:[]];break}case"public-chat":{t="Public Chat",n=[{label:"Status",value:e.publicChatEnabled?"Enabled":"Disabled"},{label:"What",value:"A chat widget anyone can use to message your business from a web browser"},{label:"Requires",value:"Remote Access with internet access enabled — this gives your device a public URL that visitors can reach"},{label:"Access mode",value:wg[e.publicChatAuthMode]??"Open access"},{label:"Open access",value:"Anyone can chat without identifying themselves"},{label:"WhatsApp OTP",value:"Visitors verify their phone number before chatting"},{label:"Visitor chooses",value:"Visitors can chat anonymously or verify via WhatsApp"}];break}case"account-pin":{t="Account PIN",n=[{label:"Status",value:e.accountHasPin?"Set":"Not set"},{label:"What",value:"A numeric PIN that protects this account on the control panel"},{label:"When needed",value:"Required when switching to this account or after the session expires"},{label:"Format",value:"4 to 6 digits"}];break}case"branding":{const s=!!(e.brandAccentColor||e.brandBackgroundColor||e.brandHasLogo);t="Branding",n=[{label:"Status",value:s?"Customised":"Default"},{label:"What",value:"Your business logo and colour scheme, displayed on the control panel and public chat pages"},{label:"Logo",value:"Shown on public chat pages alongside your business name"},{label:"Accent colour",value:"Used for buttons, links, and interactive elements"},{label:"Background tint",value:"A subtle colour wash applied to page and card backgrounds"},{label:"Scope",value:"Each account has its own branding — switch accounts to customise each one separately"}];break}case"network":{t="Network",n=[{label:"Address",value:e.networkHostname?`${e.networkHostname}.local:${e.networkPort}`:`Port ${e.networkPort}`},{label:"What",value:"The hostname and port this device uses on your local network"},{label:"When to change",value:"If you have multiple devices on the same network, give each a unique hostname and port so they don't conflict"},{label:"After saving",value:"The gateway restarts and your browser redirects to the new address"}];break}default:return k}return u`
|
|
416
416
|
<div class="setup-info-overlay" @click=${s=>{s.target.classList.contains("setup-info-overlay")&&e.onInfoModalClose()}}>
|
|
417
417
|
<div class="setup-info-card">
|
|
418
418
|
<h3>${t}</h3>
|
|
@@ -442,7 +442,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
442
442
|
</div>
|
|
443
443
|
`})}
|
|
444
444
|
</div>
|
|
445
|
-
`}function
|
|
445
|
+
`}function ba(e){const{licenseKey:t,licenseBusy:n,licenseValid:i,licenseMessage:s,licenseDeviceId:o,onLicenseKeyChange:r,onLicenseActivate:a}=e;return i===!0?u`
|
|
446
446
|
<div class="setup-container">
|
|
447
447
|
<div class="setup-card setup-success">
|
|
448
448
|
${Ae("license")}
|
|
@@ -643,7 +643,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
643
643
|
</p>
|
|
644
644
|
</div>
|
|
645
645
|
</div>
|
|
646
|
-
`}function
|
|
646
|
+
`}function ar(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 en(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 wa(e){const t=en(e),n=(t==null?void 0:t.displayName)??(t==null?void 0:t.name)??Ve().name,i=e.whatsappBusy||e.gatewayHealthLoading;if(e.renamingWorkspace&&t){const s=()=>{const o=e.renameWorkspaceName.trim();o&&e.onWorkspaceRename(t.name,o)};return u`
|
|
647
647
|
<div style="display: flex; align-items: center; gap: 6px; margin-bottom: 4px;">
|
|
648
648
|
<input
|
|
649
649
|
type="text"
|
|
@@ -685,7 +685,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
685
685
|
${L.rotateCw}
|
|
686
686
|
</button>
|
|
687
687
|
</div>
|
|
688
|
-
`}function
|
|
688
|
+
`}function ka(e){return u`
|
|
689
689
|
<div class="setup-status-item">
|
|
690
690
|
${j(e.gatewayHealthy===!1?"bad":"good")}
|
|
691
691
|
<div class="setup-status-info">
|
|
@@ -702,7 +702,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
702
702
|
${L.rotateCw}
|
|
703
703
|
</button>
|
|
704
704
|
</div>
|
|
705
|
-
`}function
|
|
705
|
+
`}function $a(e){const t=e.authConnected===!0;return u`
|
|
706
706
|
<div class="setup-status-item">
|
|
707
707
|
${j(t?"good":"bad")}
|
|
708
708
|
<div class="setup-status-info">
|
|
@@ -731,7 +731,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
731
731
|
</button>
|
|
732
732
|
`}
|
|
733
733
|
</div>
|
|
734
|
-
`}function
|
|
734
|
+
`}function Sa(e){return u`
|
|
735
735
|
<div class="setup-status-item" style="flex-wrap: wrap;">
|
|
736
736
|
${j("good")}
|
|
737
737
|
<div class="setup-status-info">
|
|
@@ -771,7 +771,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
771
771
|
</div>
|
|
772
772
|
`:k}
|
|
773
773
|
</div>
|
|
774
|
-
`}function
|
|
774
|
+
`}function lr(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.length>80?e.slice(0,77)+"…":e}function xa(e){var p;const t=en(e);if(!t)return k;const n=ar(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,r=i?"good":s?"partial":o?"bad":"unknown",a=i?"Connected":s?"Linked, not connected":o?n!=null&&n.lastError?lr(n.lastError):"Not connected":"Not paired",d=!(n!=null&&n.provider)||(n==null?void 0:n.provider)==="baileys",c=t.whatsappAccountId??(t.isDefault&&e.whatsappAccounts.length===1?(p=e.whatsappAccounts[0])==null?void 0:p.accountId:void 0),l=c!=null&&e.whatsappActiveQrAccountId===c;return u`
|
|
775
775
|
<div class="setup-status-item" style="flex-wrap: wrap;">
|
|
776
776
|
${j(r)}
|
|
777
777
|
<div class="setup-status-info">
|
|
@@ -801,16 +801,16 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
801
801
|
</div>
|
|
802
802
|
`:k}
|
|
803
803
|
</div>
|
|
804
|
-
`}const fg=[{id:"claude-opus-4-6",shortName:"Opus"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku"}],gg="anthropic/claude-sonnet-4-5-20250929",mg=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function yg(e){var
|
|
805
|
-
<div class="setup-info-overlay" @click=${
|
|
804
|
+
`}const fg=[{id:"claude-opus-4-6",shortName:"Opus"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku"}],gg="anthropic/claude-sonnet-4-5-20250929",mg=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function yg(e){var f,w;if(!e.whatsappSettingsOpen)return k;const t=en(e);if(!t)return k;const n=ar(t,e);if(!n)return k;const i=n.running&&n.connected,s=!n.provider||n.provider==="baileys",o=t.whatsappAccountId??(t.isDefault&&e.whatsappAccounts.length===1?(f=e.whatsappAccounts[0])==null?void 0:f.accountId:void 0),r=()=>e.onWhatsAppSettingsClose(),a=e.whatsappModelCatalog??[],d=new Set(a.filter(b=>b.provider==="anthropic").map(b=>b.id)),c=fg.filter(b=>d.has(b.id)),l=e.whatsappModel??gg,p=e.whatsappThinkingLevel??"off",h="display: flex; justify-content: space-between; font-size: 13px;",v="color: var(--tasker-text-grey);",S="color: var(--tasker-white); text-align: right;";return u`
|
|
805
|
+
<div class="setup-info-overlay" @click=${b=>{b.target.classList.contains("setup-info-overlay")&&r()}}>
|
|
806
806
|
<div class="setup-info-card" style="max-width: 360px;">
|
|
807
807
|
<h3>WhatsApp</h3>
|
|
808
808
|
<div style="display: flex; flex-direction: column; gap: 8px; margin-top: 12px;">
|
|
809
|
-
<div style="${
|
|
810
|
-
<div style="${
|
|
811
|
-
<div style="${
|
|
812
|
-
<div style="${
|
|
813
|
-
${n.lastError?u`<div style="${
|
|
809
|
+
<div style="${h}"><span style="${v}">Account</span><span style="${S}">${n.name||n.accountId||"Default"}</span></div>
|
|
810
|
+
<div style="${h}"><span style="${v}">Phone</span><span style="${S}">${((w=n.self)==null?void 0:w.e164)||"Not paired"}</span></div>
|
|
811
|
+
<div style="${h}"><span style="${v}">Connected</span><span style="${S}">${i?"Yes":"No"}</span></div>
|
|
812
|
+
<div style="${h}"><span style="${v}">Linked</span><span style="${S}">${n.linked?"Yes":"No"}</span></div>
|
|
813
|
+
${n.lastError?u`<div style="${h}"><span style="${v}">Error</span><span style="${S}; color: #ef4444;">${lr(n.lastError)}</span></div>`:k}
|
|
814
814
|
</div>
|
|
815
815
|
${s&&o?u`
|
|
816
816
|
<div style="border-top: 1px solid rgba(255,255,255,0.08); margin: 16px 0 12px;"></div>
|
|
@@ -892,11 +892,11 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
892
892
|
class="setup-model-select"
|
|
893
893
|
style="flex: 1;"
|
|
894
894
|
.value=${l}
|
|
895
|
-
@change=${
|
|
895
|
+
@change=${b=>{e.onWhatsAppModelChange(b.target.value)}}
|
|
896
896
|
>
|
|
897
|
-
${c.map(
|
|
898
|
-
<option value=${"anthropic/"+
|
|
899
|
-
${
|
|
897
|
+
${c.map(b=>u`
|
|
898
|
+
<option value=${"anthropic/"+b.id} ?selected=${l==="anthropic/"+b.id}>
|
|
899
|
+
${b.shortName}
|
|
900
900
|
</option>
|
|
901
901
|
`)}
|
|
902
902
|
</select>
|
|
@@ -908,11 +908,11 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
908
908
|
class="setup-model-select"
|
|
909
909
|
style="flex: 1;"
|
|
910
910
|
.value=${p}
|
|
911
|
-
@change=${
|
|
911
|
+
@change=${b=>{e.onWhatsAppThinkingChange(b.target.value)}}
|
|
912
912
|
>
|
|
913
|
-
${mg.map(
|
|
914
|
-
<option value=${
|
|
915
|
-
${
|
|
913
|
+
${mg.map(b=>u`
|
|
914
|
+
<option value=${b.value} ?selected=${p===b.value}>
|
|
915
|
+
${b.label}
|
|
916
916
|
</option>
|
|
917
917
|
`)}
|
|
918
918
|
</select>
|
|
@@ -928,7 +928,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
928
928
|
</button>
|
|
929
929
|
</div>
|
|
930
930
|
</div>
|
|
931
|
-
`}function
|
|
931
|
+
`}function cr(e){const t=en(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 Aa(e){const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=cr(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"),u`
|
|
932
932
|
<div class="setup-status-item" style="flex-wrap: wrap;">
|
|
933
933
|
${j(s)}
|
|
934
934
|
<div class="setup-status-info">
|
|
@@ -946,7 +946,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
946
946
|
</button>
|
|
947
947
|
${k}
|
|
948
948
|
</div>
|
|
949
|
-
`}function vg(e){if(!e.imessageEnableConfirm)return k;const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=
|
|
949
|
+
`}function vg(e){if(!e.imessageEnableConfirm)return k;const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=cr(e),s=()=>{e.onIMessageEnableCancel()};return n?u`
|
|
950
950
|
<div class="setup-info-overlay" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&s()}}>
|
|
951
951
|
<div class="setup-info-card" style="text-align: center;">
|
|
952
952
|
<h3>iMessage</h3>
|
|
@@ -1022,7 +1022,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1022
1022
|
</button>
|
|
1023
1023
|
</div>
|
|
1024
1024
|
</div>
|
|
1025
|
-
`}function
|
|
1025
|
+
`}function Ea(e){if(!e.isMaster)return k;const n=e.apiKeyProviders.filter(i=>i.hasKey).length;return u`
|
|
1026
1026
|
<div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
|
|
1027
1027
|
<div class="setup-status-item">
|
|
1028
1028
|
${j(n>0?"good":"bad")}
|
|
@@ -1037,13 +1037,13 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1037
1037
|
</div>
|
|
1038
1038
|
</div>
|
|
1039
1039
|
${bg(e)}
|
|
1040
|
-
`}function bg(e){if(!e.apiKeyModalOpen)return k;const t=e.apiKeyProviders,n={};for(const c of t)c.key&&(n[c.id]=c.key);const i=(c,l)=>{const p=l==null?void 0:l.closest(".setup-apikey-input"),
|
|
1040
|
+
`}function bg(e){if(!e.apiKeyModalOpen)return k;const t=e.apiKeyProviders,n={};for(const c of t)c.key&&(n[c.id]=c.key);const i=(c,l)=>{const p=l==null?void 0:l.closest(".setup-apikey-input"),h=p==null?void 0:p.querySelector("input"),v=h==null?void 0:h.value.trim();!v||v===n[c]||e.onApiKeySave(c,v)},s=c=>{const l=c.currentTarget,p=l.closest(".setup-apikey-input"),h=p==null?void 0:p.querySelector("input");if(!h)return;const v=h.type==="text";h.type=v?"password":"text",l.classList.toggle("active",!v)},o=(c,l)=>{const p=l.target,h=p.closest(".setup-apikey-input"),v=p.value.trim(),S=v.length>0&&v!==n[c],f=h==null?void 0:h.querySelector(".setup-apikey-save");f&&(f.style.display=S?"":"none");const w=h==null?void 0:h.querySelector(".setup-apikey-eye");w&&(w.style.display=v.length>0?"":"none")},r=t.filter(c=>c.primary),a=t.filter(c=>!c.primary),d=c=>{const l=e.apiKeySavingProvider===c.id&&e.apiKeyBusy,p=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key saved`,h=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key removed`,v=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} disabled`,S=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} enabled`;return u`
|
|
1041
1041
|
<div class="setup-apikey-row ${c.disabled?"disabled":""}">
|
|
1042
1042
|
<div class="setup-apikey-info">
|
|
1043
1043
|
<strong>${c.name}</strong>
|
|
1044
1044
|
<span class="setup-apikey-category">${c.category}</span>
|
|
1045
1045
|
${p?u`<span class="setup-apikey-badge saved">Saved</span>`:k}
|
|
1046
|
-
${
|
|
1046
|
+
${h?u`<span class="setup-apikey-badge removed">Removed</span>`:k}
|
|
1047
1047
|
${v?u`<span class="setup-apikey-badge removed">Disabled</span>`:k}
|
|
1048
1048
|
${S?u`<span class="setup-apikey-badge saved">Enabled</span>`:k}
|
|
1049
1049
|
${c.disabled&&!S?u`<span class="setup-apikey-badge apikey-disabled">Off</span>`:k}
|
|
@@ -1054,8 +1054,8 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1054
1054
|
.value=${c.key??""}
|
|
1055
1055
|
placeholder="Enter key"
|
|
1056
1056
|
?disabled=${e.apiKeyBusy||c.disabled}
|
|
1057
|
-
@input=${
|
|
1058
|
-
@keydown=${
|
|
1057
|
+
@input=${f=>o(c.id,f)}
|
|
1058
|
+
@keydown=${f=>{f.key==="Enter"&&i(c.id,f.target)}}
|
|
1059
1059
|
/>
|
|
1060
1060
|
<button
|
|
1061
1061
|
class="setup-apikey-icon-btn setup-apikey-eye"
|
|
@@ -1067,7 +1067,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1067
1067
|
class="setup-apikey-save setup-button"
|
|
1068
1068
|
style="display: none;"
|
|
1069
1069
|
?disabled=${e.apiKeyBusy}
|
|
1070
|
-
@click=${
|
|
1070
|
+
@click=${f=>i(c.id,f.currentTarget)}
|
|
1071
1071
|
>Save</button>`}
|
|
1072
1072
|
${c.hasKey&&!l?u`
|
|
1073
1073
|
<button
|
|
@@ -1101,7 +1101,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1101
1101
|
</div>
|
|
1102
1102
|
</div>
|
|
1103
1103
|
</div>
|
|
1104
|
-
`}function
|
|
1104
|
+
`}function Ca(e){const t=e.updateAvailable===null?"unknown":e.updateAvailable?"partial":"good",n=e.updateAvailable&&e.latestVersion?`v${e.currentVersion} → v${e.latestVersion}`:e.currentVersion?`v${e.currentVersion}`:"Unknown",i=e.updateChecking||e.updateRunning;return u`
|
|
1105
1105
|
<div class="setup-status-item">
|
|
1106
1106
|
${j(t)}
|
|
1107
1107
|
<div class="setup-status-info">
|
|
@@ -1129,7 +1129,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1129
1129
|
</button>
|
|
1130
1130
|
`}
|
|
1131
1131
|
</div>
|
|
1132
|
-
`}const wg={anonymous:"Open access",verified:"WhatsApp OTP",choice:"Visitor chooses"};function
|
|
1132
|
+
`}const wg={anonymous:"Open access",verified:"WhatsApp OTP",choice:"Visitor chooses"};function Ta(e){const t=e.publicChatEnabled;return u`
|
|
1133
1133
|
<div class="setup-status-item">
|
|
1134
1134
|
${j(t?"good":"unknown")}
|
|
1135
1135
|
<div class="setup-status-info">
|
|
@@ -1154,7 +1154,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1154
1154
|
@click=${e.onPublicChatToggle}
|
|
1155
1155
|
>${t?L.powerOff:L.power}</button>
|
|
1156
1156
|
</div>
|
|
1157
|
-
`}function
|
|
1157
|
+
`}function _a(e){const t=!!(e.brandAccentColor||e.brandBackgroundColor||e.brandHasLogo),n=t?"good":"unknown",i=e.brandingBusy;return u`
|
|
1158
1158
|
<div class="setup-status-item">
|
|
1159
1159
|
${j(n)}
|
|
1160
1160
|
<div class="setup-status-info">
|
|
@@ -1168,7 +1168,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1168
1168
|
@click=${e.onBrandingToggle}
|
|
1169
1169
|
>${i?"...":"Edit"}</button>
|
|
1170
1170
|
</div>
|
|
1171
|
-
`}function
|
|
1171
|
+
`}function Ma(e){var s;if(!e.brandingExpanded)return k;const t=e.brandingBusy,n=(s=e.wsProps)==null?void 0:s.selectedWorkspace,i=e.brandHasLogo&&n?`/brand-logo/${encodeURIComponent(n)}`:"";return u`
|
|
1172
1172
|
<div class="setup-info-overlay" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&e.onBrandingToggle()}}>
|
|
1173
1173
|
<div class="setup-info-card" style="max-width: 400px; position: relative;">
|
|
1174
1174
|
<h3 style="margin-right: 24px;">Branding</h3>
|
|
@@ -1401,7 +1401,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1401
1401
|
>${L.powerOff}</button>
|
|
1402
1402
|
${r}
|
|
1403
1403
|
</div>
|
|
1404
|
-
`}function
|
|
1404
|
+
`}function ho(e){const t=e>=70?4:e>=50?3:e>=30?2:1;return u`
|
|
1405
1405
|
<span style="display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; vertical-align: middle;">
|
|
1406
1406
|
${[4,7,10,14].map((i,s)=>u`<span style="
|
|
1407
1407
|
width: 3px;
|
|
@@ -1410,7 +1410,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1410
1410
|
background: ${s<t?"var(--tasker-accent, #00e5ff)":"rgba(255,255,255,0.15)"};
|
|
1411
1411
|
"></span>`)}
|
|
1412
1412
|
</span>
|
|
1413
|
-
`}function
|
|
1413
|
+
`}function Pa(e){if(e.serverPlatform!=="linux")return k;const t=e.wifiStatus,n=e.wifiBusy;if(!t)return u`
|
|
1414
1414
|
<div class="setup-status-item">
|
|
1415
1415
|
${j("unknown")}
|
|
1416
1416
|
<div class="setup-status-info">
|
|
@@ -1426,7 +1426,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1426
1426
|
<span>NetworkManager not available</span>
|
|
1427
1427
|
</div>
|
|
1428
1428
|
</div>
|
|
1429
|
-
`;const i=!!t.savedSsid&&!t.connected,s=t.connected?"good":"partial",o=t.connected?u`${t.ssid} ${t.signal!=null?u`<span style="margin-left: 4px;">${
|
|
1429
|
+
`;const i=!!t.savedSsid&&!t.connected,s=t.connected?"good":"partial",o=t.connected?u`${t.ssid} ${t.signal!=null?u`<span style="margin-left: 4px;">${ho(t.signal)}</span>`:k}`:i?u`${t.savedSsid} <span style="opacity: 0.4;">\u2014 reconnecting\u2026</span>`:"Not connected";return u`
|
|
1430
1430
|
<div class="setup-status-item">
|
|
1431
1431
|
${j(s)}
|
|
1432
1432
|
<div class="setup-status-info">
|
|
@@ -1450,7 +1450,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1450
1450
|
${t!=null&&t.connected?u`
|
|
1451
1451
|
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 12px;">
|
|
1452
1452
|
<span style="color: #22c55e;">${L.wifi}</span>
|
|
1453
|
-
<span style="font-size: 13px;">${t.ssid}${t.ip?u` <span style="opacity: 0.5;">(${t.ip})</span>`:k}</span>
|
|
1453
|
+
<span style="font-size: 13px;">${t.ssid}${t.signal!=null?u` ${ho(t.signal)}`:k}${t.ip?u` <span style="opacity: 0.5;">(${t.ip})</span>`:k}</span>
|
|
1454
1454
|
<button
|
|
1455
1455
|
class="setup-link-btn"
|
|
1456
1456
|
style="margin-left: auto; font-size: 12px;"
|
|
@@ -1508,7 +1508,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1508
1508
|
</span>
|
|
1509
1509
|
<span style="display: flex; align-items: center; gap: 8px;">
|
|
1510
1510
|
${o.security!=="Open"?u`<span style="opacity: 0.4; font-size: 11px;" title="${o.security}">\uD83D\uDD12</span>`:k}
|
|
1511
|
-
<span title="Signal: ${o.signal}%">${
|
|
1511
|
+
<span title="Signal: ${o.signal}%">${ho(o.signal)}</span>
|
|
1512
1512
|
</span>
|
|
1513
1513
|
</button>
|
|
1514
1514
|
`})}
|
|
@@ -1552,7 +1552,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1552
1552
|
`:k}
|
|
1553
1553
|
</div>
|
|
1554
1554
|
</div>
|
|
1555
|
-
`}function
|
|
1555
|
+
`}function La(e){return e.isMaster?e.networkPort==null?u`
|
|
1556
1556
|
<div class="setup-status-item">
|
|
1557
1557
|
${j("unknown")}
|
|
1558
1558
|
<div class="setup-status-info">
|
|
@@ -1653,7 +1653,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1653
1653
|
${r.status==="running"?u`<span class="setup-update-spinner"></span>`:r.status==="done"?u`<span class="setup-update-icon-ok">${L.check}</span>`:u`<span class="setup-update-icon-fail">${L.x}</span>`}
|
|
1654
1654
|
</span>
|
|
1655
1655
|
<span class="setup-update-step-name">${r.name}</span>
|
|
1656
|
-
${r.durationMs!=null?u`<span class="setup-update-step-time">${
|
|
1656
|
+
${r.durationMs!=null?u`<span class="setup-update-step-time">${Ia(r.durationMs)}</span>`:k}
|
|
1657
1657
|
</div>
|
|
1658
1658
|
`)}
|
|
1659
1659
|
</div>
|
|
@@ -1661,7 +1661,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1661
1661
|
${e.updateMessage?u`<p style="text-align: center; color: var(--tasker-text-grey); font-size: 13px; margin: 12px 0 0;">${e.updateMessage}</p>`:k}
|
|
1662
1662
|
</div>
|
|
1663
1663
|
</div>
|
|
1664
|
-
`;if(n){const r=n.status==="ok";let a;if(r){const c=(i=n.before)==null?void 0:i.version,l=((s=n.after)==null?void 0:s.version)??n.currentVersion;a=c?`v${c} → v${l}`:`Updated to v${l}`}else a=n.reason??((o=n.failedStep)==null?void 0:o.name)??"unknown error";const d=n.durationMs!=null?
|
|
1664
|
+
`;if(n){const r=n.status==="ok";let a;if(r){const c=(i=n.before)==null?void 0:i.version,l=((s=n.after)==null?void 0:s.version)??n.currentVersion;a=c?`v${c} → v${l}`:`Updated to v${l}`}else a=n.reason??((o=n.failedStep)==null?void 0:o.name)??"unknown error";const d=n.durationMs!=null?Ia(n.durationMs):null;return u`
|
|
1665
1665
|
<div class="setup-info-overlay" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onUpdateDismissResult()}}>
|
|
1666
1666
|
<div class="setup-info-card" style="max-width: 360px; text-align: center;">
|
|
1667
1667
|
<div class="setup-update-result-icon ${r?"ok":"fail"}">${r?L.circleCheck:L.circleX}</div>
|
|
@@ -1681,7 +1681,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1681
1681
|
</button>
|
|
1682
1682
|
</div>
|
|
1683
1683
|
</div>
|
|
1684
|
-
`}return k}function
|
|
1684
|
+
`}return k}function Ia(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 Ra(e){const t=e.accountHasPin;return u`
|
|
1685
1685
|
<div class="setup-status-item">
|
|
1686
1686
|
${j(t?"good":"bad")}
|
|
1687
1687
|
<div class="setup-status-info">
|
|
@@ -1694,7 +1694,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1694
1694
|
@click=${()=>e.onAccountPinModalOpen()}
|
|
1695
1695
|
>${t?"Change":"Set PIN"}</button>
|
|
1696
1696
|
</div>
|
|
1697
|
-
`}function
|
|
1697
|
+
`}function Da(e){if(!e.accountPinModalOpen)return k;const t=e.accountHasPin,n=e.accountPinBusy;let i="",s="",o="";const r=c=>l=>{const p=l.target;p.value=p.value.replace(/\D/g,"").slice(0,6),c(p.value)},a=(c,l)=>{var h;let p=c.querySelector(".pin-modal-validation");p||(p=document.createElement("p"),p.className="login-error pin-modal-validation",(h=c.querySelector("button[type=submit]"))==null||h.before(p)),p.textContent=l},d=c=>{c.preventDefault();const l=c.target;if(!n){if(t&&!i){a(l,"Enter your current PIN");return}if(!s){a(l,"Enter a new PIN");return}if(!o){a(l,"Confirm your new PIN");return}if(s!==o){a(l,"PINs do not match");return}if(s.length<4){a(l,"PIN must be 4–6 digits");return}e.onAccountPinSave(t?i:null,s)}};return u`
|
|
1698
1698
|
<div class="setup-info-overlay" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onAccountPinModalClose()}}>
|
|
1699
1699
|
<div class="setup-info-card" style="max-width: 340px;">
|
|
1700
1700
|
<div class="setup-info-header">
|
|
@@ -1751,7 +1751,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1751
1751
|
</form>
|
|
1752
1752
|
</div>
|
|
1753
1753
|
</div>
|
|
1754
|
-
`}function
|
|
1754
|
+
`}function Na(e){if(!e.addingWorkspace)return k;const{workspaceSaving:t}=e;return u`
|
|
1755
1755
|
<div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
|
|
1756
1756
|
<div class="setup-add-account">
|
|
1757
1757
|
<strong>New Account</strong>
|
|
@@ -1804,7 +1804,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1804
1804
|
</div>
|
|
1805
1805
|
</div>
|
|
1806
1806
|
</div>
|
|
1807
|
-
`}function
|
|
1807
|
+
`}function Ba(e){const t=en(e);return!t||t.isDefault?k:e.workspaceRemoveConfirm===t.name?u`
|
|
1808
1808
|
<div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 12px;">
|
|
1809
1809
|
<div style="font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
|
|
1810
1810
|
<span style="color: var(--tasker-danger, #ef4444);">Remove "${t.displayName??t.name}" and its WhatsApp account?</span>
|
|
@@ -1833,7 +1833,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1833
1833
|
@click=${i=>{i.preventDefault(),e.onSetWorkspaceRemoveConfirm(t.name)}}
|
|
1834
1834
|
>Remove Account</a>
|
|
1835
1835
|
</p>
|
|
1836
|
-
`}function
|
|
1836
|
+
`}function Fa(e){if(e.uninstallDone)return u`
|
|
1837
1837
|
<div style="margin-top: 24px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
|
|
1838
1838
|
<p style="color: var(--tasker-danger, #ef4444); font-size: 13px; font-weight: 600; margin: 0 0 8px 0;">
|
|
1839
1839
|
Taskmaster has been uninstalled.
|
|
@@ -1888,7 +1888,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1888
1888
|
@click=${t=>{t.preventDefault(),e.onUninstallConfirm()}}
|
|
1889
1889
|
>Uninstall Taskmaster</a>
|
|
1890
1890
|
</p>
|
|
1891
|
-
`}function
|
|
1891
|
+
`}function Oa(){return u`
|
|
1892
1892
|
<p class="setup-hint" style="margin-top: 4px; font-size: 12px; opacity: 0.6;">
|
|
1893
1893
|
Need help? <a href="https://wa.me/447591215452" target="_blank" rel="noopener" style="color: var(--tasker-orange);">Message Tuesday on WhatsApp</a>
|
|
1894
1894
|
</p>
|
|
@@ -1929,59 +1929,59 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
1929
1929
|
`;const r=(o==null?void 0:o.running)&&(o==null?void 0:o.connected);return o?(e.whatsappAccounts.length>1?e.whatsappAccounts.every(l=>l.running&&l.connected):r)&&e.authConnected?u`
|
|
1930
1930
|
<div class="setup-container">
|
|
1931
1931
|
<div class="setup-card setup-success setup-dashboard-wide">
|
|
1932
|
-
${
|
|
1932
|
+
${wa(e)}
|
|
1933
1933
|
<div class="setup-status-dashboard">
|
|
1934
|
-
${wa(e)}
|
|
1935
1934
|
${ka(e)}
|
|
1936
1935
|
${$a(e)}
|
|
1937
1936
|
${Sa(e)}
|
|
1938
|
-
${
|
|
1939
|
-
${
|
|
1940
|
-
${
|
|
1937
|
+
${xa(e)}
|
|
1938
|
+
${e.serverPlatform==="darwin"?Aa(e):k}
|
|
1939
|
+
${Ra(e)}
|
|
1941
1940
|
${Ca(e)}
|
|
1942
1941
|
${Ta(e)}
|
|
1942
|
+
${_a(e)}
|
|
1943
1943
|
${kg(e)}
|
|
1944
|
+
${La(e)}
|
|
1944
1945
|
${Pa(e)}
|
|
1945
|
-
${Ma(e)}
|
|
1946
1946
|
</div>
|
|
1947
1947
|
|
|
1948
|
-
${
|
|
1949
|
-
${
|
|
1948
|
+
${Da(e)}
|
|
1949
|
+
${Ma(e)}
|
|
1950
1950
|
${Sg(e)}
|
|
1951
1951
|
${$g(e)}
|
|
1952
|
-
${
|
|
1953
|
-
${Da(e)}
|
|
1952
|
+
${Ea(e)}
|
|
1954
1953
|
${Na(e)}
|
|
1955
1954
|
${Ba(e)}
|
|
1956
|
-
${Fa()}
|
|
1955
|
+
${Fa(e)}
|
|
1956
|
+
${Oa()}
|
|
1957
1957
|
${e.workspacesError?u`<p class="setup-error" style="margin-top: 8px;">${e.workspacesError}</p>`:k}
|
|
1958
1958
|
</div>
|
|
1959
1959
|
</div>
|
|
1960
1960
|
`:u`
|
|
1961
1961
|
<div class="setup-container">
|
|
1962
1962
|
<div class="setup-card setup-dashboard-wide">
|
|
1963
|
-
${
|
|
1963
|
+
${wa(e)}
|
|
1964
1964
|
<div class="setup-status-dashboard">
|
|
1965
|
-
${wa(e)}
|
|
1966
1965
|
${ka(e)}
|
|
1967
1966
|
${$a(e)}
|
|
1968
1967
|
${Sa(e)}
|
|
1969
|
-
${
|
|
1970
|
-
${
|
|
1971
|
-
${
|
|
1968
|
+
${xa(e)}
|
|
1969
|
+
${e.serverPlatform==="darwin"?Aa(e):k}
|
|
1970
|
+
${Ra(e)}
|
|
1972
1971
|
${Ca(e)}
|
|
1973
1972
|
${Ta(e)}
|
|
1973
|
+
${_a(e)}
|
|
1974
|
+
${La(e)}
|
|
1974
1975
|
${Pa(e)}
|
|
1975
|
-
${Ma(e)}
|
|
1976
1976
|
</div>
|
|
1977
1977
|
|
|
1978
|
-
${Ra(e)}
|
|
1979
|
-
${_a(e)}
|
|
1980
|
-
${Aa(e)}
|
|
1981
1978
|
${Da(e)}
|
|
1979
|
+
${Ma(e)}
|
|
1980
|
+
${Ea(e)}
|
|
1982
1981
|
${Na(e)}
|
|
1983
1982
|
${Ba(e)}
|
|
1984
|
-
${Fa()}
|
|
1983
|
+
${Fa(e)}
|
|
1984
|
+
${Oa()}
|
|
1985
1985
|
${e.workspacesError?u`<p class="setup-error" style="margin-top: 8px;">${e.workspacesError}</p>`:k}
|
|
1986
1986
|
</div>
|
|
1987
1987
|
</div>
|
|
@@ -2026,7 +2026,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
2026
2026
|
</button>
|
|
2027
2027
|
</div>
|
|
2028
2028
|
</div>
|
|
2029
|
-
`}function Eg(e){const{connected:t,currentStep:n}=e;if(t&&Pi()&&
|
|
2029
|
+
`}function Eg(e){const{connected:t,currentStep:n}=e;if(t&&Pi()&&rr(),e.uninstallDone||!t&&Pi())return u`
|
|
2030
2030
|
<div class="setup-container">
|
|
2031
2031
|
<div class="setup-card">
|
|
2032
2032
|
<p style="color: var(--tasker-danger, #ef4444); font-size: 16px; font-weight: 600; margin: 0 0 12px 0;">
|
|
@@ -2049,7 +2049,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
2049
2049
|
<p>${o?"Restarting gateway after update…":"Connecting to gateway..."}</p>
|
|
2050
2050
|
</div>
|
|
2051
2051
|
</div>
|
|
2052
|
-
`}let i;switch(n){case"license":i=
|
|
2052
|
+
`}let i;switch(n){case"license":i=ba(e);break;case"auth":i=hg(e);break;case"whatsapp":case"complete":i=Ag(e);break;default:i=ba(e)}const s=Mt("Setup",e.wsProps);return u`${i}${pg(e)}${vg(e)}${yg(e)}${xg(e)}${s}`}function Cg(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return u`
|
|
2053
2053
|
<div class="sp-list-item">
|
|
2054
2054
|
<div class="sp-list-item-main">
|
|
2055
2055
|
<div class="sp-list-item-title">${e.phone}</div>
|
|
@@ -2378,9 +2378,9 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
2378
2378
|
|
|
2379
2379
|
${i?Mg(i,e):k}
|
|
2380
2380
|
${s?Pg(s,e):k}
|
|
2381
|
-
`}const bd={CHILD:2},wd=e=>(...t)=>({_$litDirective$:e,values:t});let kd=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:Dg}=hp,Oa=e=>e,Ua=()=>document.createComment(""),ln=(e,t,n)=>{var o;const i=e._$AA.parentNode,s=t===void 0?e._$AB:t._$AA;if(n===void 0){const r=i.insertBefore(Ua(),s),a=i.insertBefore(Ua(),s);n=new Dg(r,a,e,e.options)}else{const r=n._$AB.nextSibling,a=n._$AM,d=a!==e;if(d){let c;(o=n._$AQ)==null||o.call(n,e),n._$AM=e,n._$AP!==void 0&&(c=e._$AU)!==a._$AU&&n._$AP(c)}if(r!==s||d){let c=n._$AA;for(;c!==r;){const l=Oa(c).nextSibling;Oa(i).insertBefore(c,s),c=l}}}return n},ht=(e,t,n=e)=>(e._$AI(t,n),e),Ng={},Bg=(e,t=Ng)=>e._$AH=t,Fg=e=>e._$AH,_s=e=>{e._$AR(),e._$AA.remove()};const Wa=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},Og=wd(class extends kd{constructor(e){if(super(e),e.type!==bd.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 r=0;for(const a of e)s[r]=i?i(a,r):r,o[r]=n(a,r),r++;return{values:o,keys:s}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const s=Fg(e),{values:o,keys:r}=this.dt(t,n,i);if(!Array.isArray(s))return this.ut=r,o;const a=this.ut??(this.ut=[]),d=[];let c,l,p=0,f=s.length-1,v=0,S=o.length-1;for(;p<=f&&v<=S;)if(s[p]===null)p++;else if(s[f]===null)f--;else if(a[p]===r[v])d[v]=ht(s[p],o[v]),p++,v++;else if(a[f]===r[S])d[S]=ht(s[f],o[S]),f--,S--;else if(a[p]===r[S])d[S]=ht(s[p],o[S]),ln(e,d[S+1],s[p]),p++,S--;else if(a[f]===r[v])d[v]=ht(s[f],o[v]),ln(e,s[p],s[f]),f--,v++;else if(c===void 0&&(c=Wa(r,v,S),l=Wa(a,p,f)),c.has(a[p]))if(c.has(a[f])){const h=l.get(r[v]),b=h!==void 0?s[h]:null;if(b===null){const w=ln(e,s[p]);ht(w,o[v]),d[v]=w}else d[v]=ht(b,o[v]),ln(e,s[p],b),s[h]=null;v++}else _s(s[f]),f--;else _s(s[p]),p++;for(;v<=S;){const h=ln(e,d[S+1]);ht(h,o[v]),d[v++]=h}for(;p<=f;){const h=s[p++];h!==null&&_s(h)}return this.ut=r,Bg(e,d),it}});class ho extends kd{constructor(t){if(super(t),this.it=k,t.type!==bd.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===k||t==null)return this._t=void 0,this.it=t;if(t===it)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:[]}}}ho.directiveName="unsafeHTML",ho.resultType=1;const Li=wd(ho);const{entries:$d,setPrototypeOf:Ka,isFrozen:Ug,getPrototypeOf:Wg,getOwnPropertyDescriptor:Kg}=Object;let{freeze:ge,seal:we,create:fo}=Object,{apply:go,construct:mo}=typeof Reflect<"u"&&Reflect;ge||(ge=function(t){return t});we||(we=function(t){return t});go||(go=function(t,n){for(var i=arguments.length,s=new Array(i>2?i-2:0),o=2;o<i;o++)s[o-2]=arguments[o];return t.apply(n,s)});mo||(mo=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return new t(...i)});const ri=me(Array.prototype.forEach),zg=me(Array.prototype.lastIndexOf),za=me(Array.prototype.pop),cn=me(Array.prototype.push),Hg=me(Array.prototype.splice),yi=me(String.prototype.toLowerCase),Ms=me(String.prototype.toString),Ps=me(String.prototype.match),dn=me(String.prototype.replace),qg=me(String.prototype.indexOf),jg=me(String.prototype.trim),ke=me(Object.prototype.hasOwnProperty),pe=me(RegExp.prototype.test),un=Vg(TypeError);function me(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 go(e,t,i)}}function Vg(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return mo(e,n)}}function U(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:yi;Ka&&Ka(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(Ug(t)||(t[i]=o),s=o)}e[s]=!0}return e}function Gg(e){for(let t=0;t<e.length;t++)ke(e,t)||(e[t]=null);return e}function Le(e){const t=fo(null);for(const[n,i]of $d(e))ke(e,n)&&(Array.isArray(i)?t[n]=Gg(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=Le(i):t[n]=i);return t}function pn(e,t){for(;e!==null;){const i=Kg(e,t);if(i){if(i.get)return me(i.get);if(typeof i.value=="function")return me(i.value)}e=Wg(e)}function n(){return null}return n}const Ha=ge(["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"]),Ls=ge(["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"]),Is=ge(["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"]),Qg=ge(["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"]),Rs=ge(["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"]),Jg=ge(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),qa=ge(["#text"]),ja=ge(["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"]),Ds=ge(["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"]),Va=ge(["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"]),ai=ge(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Yg=we(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Xg=we(/<%[\w\W]*|[\w\W]*%>/gm),Zg=we(/\$\{[\w\W]*/gm),em=we(/^data-[\-\w.\u00B7-\uFFFF]+$/),tm=we(/^aria-[\-\w]+$/),Sd=we(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),nm=we(/^(?:\w+script|data):/i),im=we(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),xd=we(/^html$/i),sm=we(/^[a-z][.\w]*(-[.\w]+)+$/i);var Ga=Object.freeze({__proto__:null,ARIA_ATTR:tm,ATTR_WHITESPACE:im,CUSTOM_ELEMENT:sm,DATA_ATTR:em,DOCTYPE_NAME:xd,ERB_EXPR:Xg,IS_ALLOWED_URI:Sd,IS_SCRIPT_OR_DATA:nm,MUSTACHE_EXPR:Yg,TMPLIT_EXPR:Zg});const hn={element:1,text:3,progressingInstruction:7,comment:8,document:9},om=function(){return typeof window>"u"?null:window},rm=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(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Qa=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ad(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:om();const t=D=>Ad(D);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==hn.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:r,Node:a,Element:d,NodeFilter:c,NamedNodeMap:l=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:f,trustedTypes:v}=e,S=d.prototype,h=pn(S,"cloneNode"),b=pn(S,"remove"),w=pn(S,"nextSibling"),x=pn(S,"childNodes"),A=pn(S,"parentNode");if(typeof r=="function"){const D=n.createElement("template");D.content&&D.content.ownerDocument&&(n=D.content.ownerDocument)}let C,P="";const{implementation:_,createNodeIterator:B,createDocumentFragment:z,getElementsByTagName:te}=n,{importNode:be}=i;let X=Qa();t.isSupported=typeof $d=="function"&&typeof A=="function"&&_&&_.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:at,ERB_EXPR:It,TMPLIT_EXPR:lt,DATA_ATTR:ss,ARIA_ATTR:os,IS_SCRIPT_OR_DATA:rs,ATTR_WHITESPACE:Wn,CUSTOM_ELEMENT:as}=Ga;let{IS_ALLOWED_URI:Kn}=Ga,Z=null;const zn=U({},[...Ha,...Ls,...Is,...Rs,...qa]);let ee=null;const Hn=U({},[...ja,...Ds,...Va,...ai]);let Q=Object.seal(fo(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}})),ct=null,nn=null;const Ye=Object.seal(fo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let qn=!0,E=!0,M=!1,F=!0,O=!1,J=!0,V=!1,ue=!1,Xe=!1,Rt=!1,jn=!1,Vn=!1,Cr=!0,Tr=!1;const Nu="user-content-";let ls=!0,sn=!1,Dt={},Te=null;const cs=U({},["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 _r=null;const Mr=U({},["audio","video","img","source","image","track"]);let ds=null;const Pr=U({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Gn="http://www.w3.org/1998/Math/MathML",Qn="http://www.w3.org/2000/svg",Ue="http://www.w3.org/1999/xhtml";let Nt=Ue,us=!1,ps=null;const Bu=U({},[Gn,Qn,Ue],Ms);let Jn=U({},["mi","mo","mn","ms","mtext"]),Yn=U({},["annotation-xml"]);const Fu=U({},["title","style","font","a","script"]);let on=null;const Ou=["application/xhtml+xml","text/html"],Uu="text/html";let ie=null,Bt=null;const Wu=n.createElement("form"),Lr=function($){return $ instanceof RegExp||$ instanceof Function},hs=function(){let $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Bt&&Bt===$)){if((!$||typeof $!="object")&&($={}),$=Le($),on=Ou.indexOf($.PARSER_MEDIA_TYPE)===-1?Uu:$.PARSER_MEDIA_TYPE,ie=on==="application/xhtml+xml"?Ms:yi,Z=ke($,"ALLOWED_TAGS")?U({},$.ALLOWED_TAGS,ie):zn,ee=ke($,"ALLOWED_ATTR")?U({},$.ALLOWED_ATTR,ie):Hn,ps=ke($,"ALLOWED_NAMESPACES")?U({},$.ALLOWED_NAMESPACES,Ms):Bu,ds=ke($,"ADD_URI_SAFE_ATTR")?U(Le(Pr),$.ADD_URI_SAFE_ATTR,ie):Pr,_r=ke($,"ADD_DATA_URI_TAGS")?U(Le(Mr),$.ADD_DATA_URI_TAGS,ie):Mr,Te=ke($,"FORBID_CONTENTS")?U({},$.FORBID_CONTENTS,ie):cs,ct=ke($,"FORBID_TAGS")?U({},$.FORBID_TAGS,ie):Le({}),nn=ke($,"FORBID_ATTR")?U({},$.FORBID_ATTR,ie):Le({}),Dt=ke($,"USE_PROFILES")?$.USE_PROFILES:!1,qn=$.ALLOW_ARIA_ATTR!==!1,E=$.ALLOW_DATA_ATTR!==!1,M=$.ALLOW_UNKNOWN_PROTOCOLS||!1,F=$.ALLOW_SELF_CLOSE_IN_ATTR!==!1,O=$.SAFE_FOR_TEMPLATES||!1,J=$.SAFE_FOR_XML!==!1,V=$.WHOLE_DOCUMENT||!1,Rt=$.RETURN_DOM||!1,jn=$.RETURN_DOM_FRAGMENT||!1,Vn=$.RETURN_TRUSTED_TYPE||!1,Xe=$.FORCE_BODY||!1,Cr=$.SANITIZE_DOM!==!1,Tr=$.SANITIZE_NAMED_PROPS||!1,ls=$.KEEP_CONTENT!==!1,sn=$.IN_PLACE||!1,Kn=$.ALLOWED_URI_REGEXP||Sd,Nt=$.NAMESPACE||Ue,Jn=$.MATHML_TEXT_INTEGRATION_POINTS||Jn,Yn=$.HTML_INTEGRATION_POINTS||Yn,Q=$.CUSTOM_ELEMENT_HANDLING||{},$.CUSTOM_ELEMENT_HANDLING&&Lr($.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Q.tagNameCheck=$.CUSTOM_ELEMENT_HANDLING.tagNameCheck),$.CUSTOM_ELEMENT_HANDLING&&Lr($.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Q.attributeNameCheck=$.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),$.CUSTOM_ELEMENT_HANDLING&&typeof $.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Q.allowCustomizedBuiltInElements=$.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),O&&(E=!1),jn&&(Rt=!0),Dt&&(Z=U({},qa),ee=[],Dt.html===!0&&(U(Z,Ha),U(ee,ja)),Dt.svg===!0&&(U(Z,Ls),U(ee,Ds),U(ee,ai)),Dt.svgFilters===!0&&(U(Z,Is),U(ee,Ds),U(ee,ai)),Dt.mathMl===!0&&(U(Z,Rs),U(ee,Va),U(ee,ai))),$.ADD_TAGS&&(typeof $.ADD_TAGS=="function"?Ye.tagCheck=$.ADD_TAGS:(Z===zn&&(Z=Le(Z)),U(Z,$.ADD_TAGS,ie))),$.ADD_ATTR&&(typeof $.ADD_ATTR=="function"?Ye.attributeCheck=$.ADD_ATTR:(ee===Hn&&(ee=Le(ee)),U(ee,$.ADD_ATTR,ie))),$.ADD_URI_SAFE_ATTR&&U(ds,$.ADD_URI_SAFE_ATTR,ie),$.FORBID_CONTENTS&&(Te===cs&&(Te=Le(Te)),U(Te,$.FORBID_CONTENTS,ie)),$.ADD_FORBID_CONTENTS&&(Te===cs&&(Te=Le(Te)),U(Te,$.ADD_FORBID_CONTENTS,ie)),ls&&(Z["#text"]=!0),V&&U(Z,["html","head","body"]),Z.table&&(U(Z,["tbody"]),delete ct.tbody),$.TRUSTED_TYPES_POLICY){if(typeof $.TRUSTED_TYPES_POLICY.createHTML!="function")throw un('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof $.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw un('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');C=$.TRUSTED_TYPES_POLICY,P=C.createHTML("")}else C===void 0&&(C=rm(v,s)),C!==null&&typeof P=="string"&&(P=C.createHTML(""));ge&&ge($),Bt=$}},Ir=U({},[...Ls,...Is,...Qg]),Rr=U({},[...Rs,...Jg]),Ku=function($){let T=A($);(!T||!T.tagName)&&(T={namespaceURI:Nt,tagName:"template"});const R=yi($.tagName),G=yi(T.tagName);return ps[$.namespaceURI]?$.namespaceURI===Qn?T.namespaceURI===Ue?R==="svg":T.namespaceURI===Gn?R==="svg"&&(G==="annotation-xml"||Jn[G]):!!Ir[R]:$.namespaceURI===Gn?T.namespaceURI===Ue?R==="math":T.namespaceURI===Qn?R==="math"&&Yn[G]:!!Rr[R]:$.namespaceURI===Ue?T.namespaceURI===Qn&&!Yn[G]||T.namespaceURI===Gn&&!Jn[G]?!1:!Rr[R]&&(Fu[R]||!Ir[R]):!!(on==="application/xhtml+xml"&&ps[$.namespaceURI]):!1},_e=function($){cn(t.removed,{element:$});try{A($).removeChild($)}catch{b($)}},dt=function($,T){try{cn(t.removed,{attribute:T.getAttributeNode($),from:T})}catch{cn(t.removed,{attribute:null,from:T})}if(T.removeAttribute($),$==="is")if(Rt||jn)try{_e(T)}catch{}else try{T.setAttribute($,"")}catch{}},Dr=function($){let T=null,R=null;if(Xe)$="<remove></remove>"+$;else{const ne=Ps($,/^[\r\n\t ]+/);R=ne&&ne[0]}on==="application/xhtml+xml"&&Nt===Ue&&($='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+$+"</body></html>");const G=C?C.createHTML($):$;if(Nt===Ue)try{T=new f().parseFromString(G,on)}catch{}if(!T||!T.documentElement){T=_.createDocument(Nt,"template",null);try{T.documentElement.innerHTML=us?P:G}catch{}}const ae=T.body||T.documentElement;return $&&R&&ae.insertBefore(n.createTextNode(R),ae.childNodes[0]||null),Nt===Ue?te.call(T,V?"html":"body")[0]:V?T.documentElement:ae},Nr=function($){return B.call($.ownerDocument||$,$,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},fs=function($){return $ instanceof p&&(typeof $.nodeName!="string"||typeof $.textContent!="string"||typeof $.removeChild!="function"||!($.attributes instanceof l)||typeof $.removeAttribute!="function"||typeof $.setAttribute!="function"||typeof $.namespaceURI!="string"||typeof $.insertBefore!="function"||typeof $.hasChildNodes!="function")},Br=function($){return typeof a=="function"&&$ instanceof a};function We(D,$,T){ri(D,R=>{R.call(t,$,T,Bt)})}const Fr=function($){let T=null;if(We(X.beforeSanitizeElements,$,null),fs($))return _e($),!0;const R=ie($.nodeName);if(We(X.uponSanitizeElement,$,{tagName:R,allowedTags:Z}),J&&$.hasChildNodes()&&!Br($.firstElementChild)&&pe(/<[/\w!]/g,$.innerHTML)&&pe(/<[/\w!]/g,$.textContent)||$.nodeType===hn.progressingInstruction||J&&$.nodeType===hn.comment&&pe(/<[/\w]/g,$.data))return _e($),!0;if(!(Ye.tagCheck instanceof Function&&Ye.tagCheck(R))&&(!Z[R]||ct[R])){if(!ct[R]&&Ur(R)&&(Q.tagNameCheck instanceof RegExp&&pe(Q.tagNameCheck,R)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck(R)))return!1;if(ls&&!Te[R]){const G=A($)||$.parentNode,ae=x($)||$.childNodes;if(ae&&G){const ne=ae.length;for(let ye=ne-1;ye>=0;--ye){const Ke=h(ae[ye],!0);Ke.__removalCount=($.__removalCount||0)+1,G.insertBefore(Ke,w($))}}}return _e($),!0}return $ instanceof d&&!Ku($)||(R==="noscript"||R==="noembed"||R==="noframes")&&pe(/<\/no(script|embed|frames)/i,$.innerHTML)?(_e($),!0):(O&&$.nodeType===hn.text&&(T=$.textContent,ri([at,It,lt],G=>{T=dn(T,G," ")}),$.textContent!==T&&(cn(t.removed,{element:$.cloneNode()}),$.textContent=T)),We(X.afterSanitizeElements,$,null),!1)},Or=function($,T,R){if(Cr&&(T==="id"||T==="name")&&(R in n||R in Wu))return!1;if(!(E&&!nn[T]&&pe(ss,T))){if(!(qn&&pe(os,T))){if(!(Ye.attributeCheck instanceof Function&&Ye.attributeCheck(T,$))){if(!ee[T]||nn[T]){if(!(Ur($)&&(Q.tagNameCheck instanceof RegExp&&pe(Q.tagNameCheck,$)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck($))&&(Q.attributeNameCheck instanceof RegExp&&pe(Q.attributeNameCheck,T)||Q.attributeNameCheck instanceof Function&&Q.attributeNameCheck(T,$))||T==="is"&&Q.allowCustomizedBuiltInElements&&(Q.tagNameCheck instanceof RegExp&&pe(Q.tagNameCheck,R)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck(R))))return!1}else if(!ds[T]){if(!pe(Kn,dn(R,Wn,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&$!=="script"&&qg(R,"data:")===0&&_r[$])){if(!(M&&!pe(rs,dn(R,Wn,"")))){if(R)return!1}}}}}}}return!0},Ur=function($){return $!=="annotation-xml"&&Ps($,as)},Wr=function($){We(X.beforeSanitizeAttributes,$,null);const{attributes:T}=$;if(!T||fs($))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ee,forceKeepAttr:void 0};let G=T.length;for(;G--;){const ae=T[G],{name:ne,namespaceURI:ye,value:Ke}=ae,Ft=ie(ne),gs=Ke;let oe=ne==="value"?gs:jg(gs);if(R.attrName=Ft,R.attrValue=oe,R.keepAttr=!0,R.forceKeepAttr=void 0,We(X.uponSanitizeAttribute,$,R),oe=R.attrValue,Tr&&(Ft==="id"||Ft==="name")&&(dt(ne,$),oe=Nu+oe),J&&pe(/((--!?|])>)|<\/(style|title|textarea)/i,oe)){dt(ne,$);continue}if(Ft==="attributename"&&Ps(oe,"href")){dt(ne,$);continue}if(R.forceKeepAttr)continue;if(!R.keepAttr){dt(ne,$);continue}if(!F&&pe(/\/>/i,oe)){dt(ne,$);continue}O&&ri([at,It,lt],zr=>{oe=dn(oe,zr," ")});const Kr=ie($.nodeName);if(!Or(Kr,Ft,oe)){dt(ne,$);continue}if(C&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!ye)switch(v.getAttributeType(Kr,Ft)){case"TrustedHTML":{oe=C.createHTML(oe);break}case"TrustedScriptURL":{oe=C.createScriptURL(oe);break}}if(oe!==gs)try{ye?$.setAttributeNS(ye,ne,oe):$.setAttribute(ne,oe),fs($)?_e($):za(t.removed)}catch{dt(ne,$)}}We(X.afterSanitizeAttributes,$,null)},zu=function D($){let T=null;const R=Nr($);for(We(X.beforeSanitizeShadowDOM,$,null);T=R.nextNode();)We(X.uponSanitizeShadowNode,T,null),Fr(T),Wr(T),T.content instanceof o&&D(T.content);We(X.afterSanitizeShadowDOM,$,null)};return t.sanitize=function(D){let $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,R=null,G=null,ae=null;if(us=!D,us&&(D="<!-->"),typeof D!="string"&&!Br(D))if(typeof D.toString=="function"){if(D=D.toString(),typeof D!="string")throw un("dirty is not a string, aborting")}else throw un("toString is not a function");if(!t.isSupported)return D;if(ue||hs($),t.removed=[],typeof D=="string"&&(sn=!1),sn){if(D.nodeName){const Ke=ie(D.nodeName);if(!Z[Ke]||ct[Ke])throw un("root node is forbidden and cannot be sanitized in-place")}}else if(D instanceof a)T=Dr("<!---->"),R=T.ownerDocument.importNode(D,!0),R.nodeType===hn.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?T=R:T.appendChild(R);else{if(!Rt&&!O&&!V&&D.indexOf("<")===-1)return C&&Vn?C.createHTML(D):D;if(T=Dr(D),!T)return Rt?null:Vn?P:""}T&&Xe&&_e(T.firstChild);const ne=Nr(sn?D:T);for(;G=ne.nextNode();)Fr(G),Wr(G),G.content instanceof o&&zu(G.content);if(sn)return D;if(Rt){if(jn)for(ae=z.call(T.ownerDocument);T.firstChild;)ae.appendChild(T.firstChild);else ae=T;return(ee.shadowroot||ee.shadowrootmode)&&(ae=be.call(i,ae,!0)),ae}let ye=V?T.outerHTML:T.innerHTML;return V&&Z["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&pe(xd,T.ownerDocument.doctype.name)&&(ye="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
|
|
2382
|
-
`+ye),O&&ri([at,It,lt],Ke=>{ye=dn(ye,Ke," ")}),C&&Vn?C.createHTML(ye):ye},t.setConfig=function(){let D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};hs(D),ue=!0},t.clearConfig=function(){Bt=null,ue=!1},t.isValidAttribute=function(D,$,T){Bt||hs({});const R=ie(D),G=ie($);return
|
|
2383
|
-
]`).replace("lheading",Td).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},wm=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,km=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Md=/^( {2,}|\\)\n(?!\s*$)/,$m=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,es=/[\p{P}\p{S}]/u,
|
|
2381
|
+
`}const bd={CHILD:2},wd=e=>(...t)=>({_$litDirective$:e,values:t});let kd=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:Dg}=hp,Ua=e=>e,Wa=()=>document.createComment(""),ln=(e,t,n)=>{var o;const i=e._$AA.parentNode,s=t===void 0?e._$AB:t._$AA;if(n===void 0){const r=i.insertBefore(Wa(),s),a=i.insertBefore(Wa(),s);n=new Dg(r,a,e,e.options)}else{const r=n._$AB.nextSibling,a=n._$AM,d=a!==e;if(d){let c;(o=n._$AQ)==null||o.call(n,e),n._$AM=e,n._$AP!==void 0&&(c=e._$AU)!==a._$AU&&n._$AP(c)}if(r!==s||d){let c=n._$AA;for(;c!==r;){const l=Ua(c).nextSibling;Ua(i).insertBefore(c,s),c=l}}}return n},ht=(e,t,n=e)=>(e._$AI(t,n),e),Ng={},Bg=(e,t=Ng)=>e._$AH=t,Fg=e=>e._$AH,_s=e=>{e._$AR(),e._$AA.remove()};const Ka=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},Og=wd(class extends kd{constructor(e){if(super(e),e.type!==bd.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 r=0;for(const a of e)s[r]=i?i(a,r):r,o[r]=n(a,r),r++;return{values:o,keys:s}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const s=Fg(e),{values:o,keys:r}=this.dt(t,n,i);if(!Array.isArray(s))return this.ut=r,o;const a=this.ut??(this.ut=[]),d=[];let c,l,p=0,h=s.length-1,v=0,S=o.length-1;for(;p<=h&&v<=S;)if(s[p]===null)p++;else if(s[h]===null)h--;else if(a[p]===r[v])d[v]=ht(s[p],o[v]),p++,v++;else if(a[h]===r[S])d[S]=ht(s[h],o[S]),h--,S--;else if(a[p]===r[S])d[S]=ht(s[p],o[S]),ln(e,d[S+1],s[p]),p++,S--;else if(a[h]===r[v])d[v]=ht(s[h],o[v]),ln(e,s[p],s[h]),h--,v++;else if(c===void 0&&(c=Ka(r,v,S),l=Ka(a,p,h)),c.has(a[p]))if(c.has(a[h])){const f=l.get(r[v]),w=f!==void 0?s[f]:null;if(w===null){const b=ln(e,s[p]);ht(b,o[v]),d[v]=b}else d[v]=ht(w,o[v]),ln(e,s[p],w),s[f]=null;v++}else _s(s[h]),h--;else _s(s[p]),p++;for(;v<=S;){const f=ln(e,d[S+1]);ht(f,o[v]),d[v++]=f}for(;p<=h;){const f=s[p++];f!==null&&_s(f)}return this.ut=r,Bg(e,d),it}});class fo extends kd{constructor(t){if(super(t),this.it=k,t.type!==bd.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===k||t==null)return this._t=void 0,this.it=t;if(t===it)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:[]}}}fo.directiveName="unsafeHTML",fo.resultType=1;const Li=wd(fo);const{entries:$d,setPrototypeOf:za,isFrozen:Ug,getPrototypeOf:Wg,getOwnPropertyDescriptor:Kg}=Object;let{freeze:ge,seal:we,create:go}=Object,{apply:mo,construct:yo}=typeof Reflect<"u"&&Reflect;ge||(ge=function(t){return t});we||(we=function(t){return t});mo||(mo=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)});yo||(yo=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 ri=me(Array.prototype.forEach),zg=me(Array.prototype.lastIndexOf),Ha=me(Array.prototype.pop),cn=me(Array.prototype.push),Hg=me(Array.prototype.splice),yi=me(String.prototype.toLowerCase),Ms=me(String.prototype.toString),Ps=me(String.prototype.match),dn=me(String.prototype.replace),qg=me(String.prototype.indexOf),jg=me(String.prototype.trim),ke=me(Object.prototype.hasOwnProperty),pe=me(RegExp.prototype.test),un=Vg(TypeError);function me(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 mo(e,t,i)}}function Vg(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return yo(e,n)}}function U(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:yi;za&&za(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(Ug(t)||(t[i]=o),s=o)}e[s]=!0}return e}function Gg(e){for(let t=0;t<e.length;t++)ke(e,t)||(e[t]=null);return e}function Le(e){const t=go(null);for(const[n,i]of $d(e))ke(e,n)&&(Array.isArray(i)?t[n]=Gg(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=Le(i):t[n]=i);return t}function pn(e,t){for(;e!==null;){const i=Kg(e,t);if(i){if(i.get)return me(i.get);if(typeof i.value=="function")return me(i.value)}e=Wg(e)}function n(){return null}return n}const qa=ge(["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"]),Ls=ge(["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"]),Is=ge(["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"]),Qg=ge(["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"]),Rs=ge(["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"]),Jg=ge(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ja=ge(["#text"]),Va=ge(["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"]),Ds=ge(["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"]),Ga=ge(["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"]),ai=ge(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Yg=we(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Xg=we(/<%[\w\W]*|[\w\W]*%>/gm),Zg=we(/\$\{[\w\W]*/gm),em=we(/^data-[\-\w.\u00B7-\uFFFF]+$/),tm=we(/^aria-[\-\w]+$/),Sd=we(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),nm=we(/^(?:\w+script|data):/i),im=we(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),xd=we(/^html$/i),sm=we(/^[a-z][.\w]*(-[.\w]+)+$/i);var Qa=Object.freeze({__proto__:null,ARIA_ATTR:tm,ATTR_WHITESPACE:im,CUSTOM_ELEMENT:sm,DATA_ATTR:em,DOCTYPE_NAME:xd,ERB_EXPR:Xg,IS_ALLOWED_URI:Sd,IS_SCRIPT_OR_DATA:nm,MUSTACHE_EXPR:Yg,TMPLIT_EXPR:Zg});const hn={element:1,text:3,progressingInstruction:7,comment:8,document:9},om=function(){return typeof window>"u"?null:window},rm=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(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Ja=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ad(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:om();const t=D=>Ad(D);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==hn.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:r,Node:a,Element:d,NodeFilter:c,NamedNodeMap:l=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:h,trustedTypes:v}=e,S=d.prototype,f=pn(S,"cloneNode"),w=pn(S,"remove"),b=pn(S,"nextSibling"),x=pn(S,"childNodes"),A=pn(S,"parentNode");if(typeof r=="function"){const D=n.createElement("template");D.content&&D.content.ownerDocument&&(n=D.content.ownerDocument)}let C,M="";const{implementation:_,createNodeIterator:B,createDocumentFragment:z,getElementsByTagName:te}=n,{importNode:be}=i;let X=Ja();t.isSupported=typeof $d=="function"&&typeof A=="function"&&_&&_.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:at,ERB_EXPR:It,TMPLIT_EXPR:lt,DATA_ATTR:ss,ARIA_ATTR:os,IS_SCRIPT_OR_DATA:rs,ATTR_WHITESPACE:Wn,CUSTOM_ELEMENT:as}=Qa;let{IS_ALLOWED_URI:Kn}=Qa,Z=null;const zn=U({},[...qa,...Ls,...Is,...Rs,...ja]);let ee=null;const Hn=U({},[...Va,...Ds,...Ga,...ai]);let Q=Object.seal(go(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}})),ct=null,nn=null;const Ye=Object.seal(go(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let qn=!0,E=!0,P=!1,F=!0,O=!1,J=!0,V=!1,ue=!1,Xe=!1,Rt=!1,jn=!1,Vn=!1,Tr=!0,_r=!1;const Nu="user-content-";let ls=!0,sn=!1,Dt={},Te=null;const cs=U({},["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 Mr=null;const Pr=U({},["audio","video","img","source","image","track"]);let ds=null;const Lr=U({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Gn="http://www.w3.org/1998/Math/MathML",Qn="http://www.w3.org/2000/svg",Ue="http://www.w3.org/1999/xhtml";let Nt=Ue,us=!1,ps=null;const Bu=U({},[Gn,Qn,Ue],Ms);let Jn=U({},["mi","mo","mn","ms","mtext"]),Yn=U({},["annotation-xml"]);const Fu=U({},["title","style","font","a","script"]);let on=null;const Ou=["application/xhtml+xml","text/html"],Uu="text/html";let ie=null,Bt=null;const Wu=n.createElement("form"),Ir=function($){return $ instanceof RegExp||$ instanceof Function},hs=function(){let $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Bt&&Bt===$)){if((!$||typeof $!="object")&&($={}),$=Le($),on=Ou.indexOf($.PARSER_MEDIA_TYPE)===-1?Uu:$.PARSER_MEDIA_TYPE,ie=on==="application/xhtml+xml"?Ms:yi,Z=ke($,"ALLOWED_TAGS")?U({},$.ALLOWED_TAGS,ie):zn,ee=ke($,"ALLOWED_ATTR")?U({},$.ALLOWED_ATTR,ie):Hn,ps=ke($,"ALLOWED_NAMESPACES")?U({},$.ALLOWED_NAMESPACES,Ms):Bu,ds=ke($,"ADD_URI_SAFE_ATTR")?U(Le(Lr),$.ADD_URI_SAFE_ATTR,ie):Lr,Mr=ke($,"ADD_DATA_URI_TAGS")?U(Le(Pr),$.ADD_DATA_URI_TAGS,ie):Pr,Te=ke($,"FORBID_CONTENTS")?U({},$.FORBID_CONTENTS,ie):cs,ct=ke($,"FORBID_TAGS")?U({},$.FORBID_TAGS,ie):Le({}),nn=ke($,"FORBID_ATTR")?U({},$.FORBID_ATTR,ie):Le({}),Dt=ke($,"USE_PROFILES")?$.USE_PROFILES:!1,qn=$.ALLOW_ARIA_ATTR!==!1,E=$.ALLOW_DATA_ATTR!==!1,P=$.ALLOW_UNKNOWN_PROTOCOLS||!1,F=$.ALLOW_SELF_CLOSE_IN_ATTR!==!1,O=$.SAFE_FOR_TEMPLATES||!1,J=$.SAFE_FOR_XML!==!1,V=$.WHOLE_DOCUMENT||!1,Rt=$.RETURN_DOM||!1,jn=$.RETURN_DOM_FRAGMENT||!1,Vn=$.RETURN_TRUSTED_TYPE||!1,Xe=$.FORCE_BODY||!1,Tr=$.SANITIZE_DOM!==!1,_r=$.SANITIZE_NAMED_PROPS||!1,ls=$.KEEP_CONTENT!==!1,sn=$.IN_PLACE||!1,Kn=$.ALLOWED_URI_REGEXP||Sd,Nt=$.NAMESPACE||Ue,Jn=$.MATHML_TEXT_INTEGRATION_POINTS||Jn,Yn=$.HTML_INTEGRATION_POINTS||Yn,Q=$.CUSTOM_ELEMENT_HANDLING||{},$.CUSTOM_ELEMENT_HANDLING&&Ir($.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Q.tagNameCheck=$.CUSTOM_ELEMENT_HANDLING.tagNameCheck),$.CUSTOM_ELEMENT_HANDLING&&Ir($.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Q.attributeNameCheck=$.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),$.CUSTOM_ELEMENT_HANDLING&&typeof $.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Q.allowCustomizedBuiltInElements=$.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),O&&(E=!1),jn&&(Rt=!0),Dt&&(Z=U({},ja),ee=[],Dt.html===!0&&(U(Z,qa),U(ee,Va)),Dt.svg===!0&&(U(Z,Ls),U(ee,Ds),U(ee,ai)),Dt.svgFilters===!0&&(U(Z,Is),U(ee,Ds),U(ee,ai)),Dt.mathMl===!0&&(U(Z,Rs),U(ee,Ga),U(ee,ai))),$.ADD_TAGS&&(typeof $.ADD_TAGS=="function"?Ye.tagCheck=$.ADD_TAGS:(Z===zn&&(Z=Le(Z)),U(Z,$.ADD_TAGS,ie))),$.ADD_ATTR&&(typeof $.ADD_ATTR=="function"?Ye.attributeCheck=$.ADD_ATTR:(ee===Hn&&(ee=Le(ee)),U(ee,$.ADD_ATTR,ie))),$.ADD_URI_SAFE_ATTR&&U(ds,$.ADD_URI_SAFE_ATTR,ie),$.FORBID_CONTENTS&&(Te===cs&&(Te=Le(Te)),U(Te,$.FORBID_CONTENTS,ie)),$.ADD_FORBID_CONTENTS&&(Te===cs&&(Te=Le(Te)),U(Te,$.ADD_FORBID_CONTENTS,ie)),ls&&(Z["#text"]=!0),V&&U(Z,["html","head","body"]),Z.table&&(U(Z,["tbody"]),delete ct.tbody),$.TRUSTED_TYPES_POLICY){if(typeof $.TRUSTED_TYPES_POLICY.createHTML!="function")throw un('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof $.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw un('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');C=$.TRUSTED_TYPES_POLICY,M=C.createHTML("")}else C===void 0&&(C=rm(v,s)),C!==null&&typeof M=="string"&&(M=C.createHTML(""));ge&&ge($),Bt=$}},Rr=U({},[...Ls,...Is,...Qg]),Dr=U({},[...Rs,...Jg]),Ku=function($){let T=A($);(!T||!T.tagName)&&(T={namespaceURI:Nt,tagName:"template"});const R=yi($.tagName),G=yi(T.tagName);return ps[$.namespaceURI]?$.namespaceURI===Qn?T.namespaceURI===Ue?R==="svg":T.namespaceURI===Gn?R==="svg"&&(G==="annotation-xml"||Jn[G]):!!Rr[R]:$.namespaceURI===Gn?T.namespaceURI===Ue?R==="math":T.namespaceURI===Qn?R==="math"&&Yn[G]:!!Dr[R]:$.namespaceURI===Ue?T.namespaceURI===Qn&&!Yn[G]||T.namespaceURI===Gn&&!Jn[G]?!1:!Dr[R]&&(Fu[R]||!Rr[R]):!!(on==="application/xhtml+xml"&&ps[$.namespaceURI]):!1},_e=function($){cn(t.removed,{element:$});try{A($).removeChild($)}catch{w($)}},dt=function($,T){try{cn(t.removed,{attribute:T.getAttributeNode($),from:T})}catch{cn(t.removed,{attribute:null,from:T})}if(T.removeAttribute($),$==="is")if(Rt||jn)try{_e(T)}catch{}else try{T.setAttribute($,"")}catch{}},Nr=function($){let T=null,R=null;if(Xe)$="<remove></remove>"+$;else{const ne=Ps($,/^[\r\n\t ]+/);R=ne&&ne[0]}on==="application/xhtml+xml"&&Nt===Ue&&($='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+$+"</body></html>");const G=C?C.createHTML($):$;if(Nt===Ue)try{T=new h().parseFromString(G,on)}catch{}if(!T||!T.documentElement){T=_.createDocument(Nt,"template",null);try{T.documentElement.innerHTML=us?M:G}catch{}}const ae=T.body||T.documentElement;return $&&R&&ae.insertBefore(n.createTextNode(R),ae.childNodes[0]||null),Nt===Ue?te.call(T,V?"html":"body")[0]:V?T.documentElement:ae},Br=function($){return B.call($.ownerDocument||$,$,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},fs=function($){return $ instanceof p&&(typeof $.nodeName!="string"||typeof $.textContent!="string"||typeof $.removeChild!="function"||!($.attributes instanceof l)||typeof $.removeAttribute!="function"||typeof $.setAttribute!="function"||typeof $.namespaceURI!="string"||typeof $.insertBefore!="function"||typeof $.hasChildNodes!="function")},Fr=function($){return typeof a=="function"&&$ instanceof a};function We(D,$,T){ri(D,R=>{R.call(t,$,T,Bt)})}const Or=function($){let T=null;if(We(X.beforeSanitizeElements,$,null),fs($))return _e($),!0;const R=ie($.nodeName);if(We(X.uponSanitizeElement,$,{tagName:R,allowedTags:Z}),J&&$.hasChildNodes()&&!Fr($.firstElementChild)&&pe(/<[/\w!]/g,$.innerHTML)&&pe(/<[/\w!]/g,$.textContent)||$.nodeType===hn.progressingInstruction||J&&$.nodeType===hn.comment&&pe(/<[/\w]/g,$.data))return _e($),!0;if(!(Ye.tagCheck instanceof Function&&Ye.tagCheck(R))&&(!Z[R]||ct[R])){if(!ct[R]&&Wr(R)&&(Q.tagNameCheck instanceof RegExp&&pe(Q.tagNameCheck,R)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck(R)))return!1;if(ls&&!Te[R]){const G=A($)||$.parentNode,ae=x($)||$.childNodes;if(ae&&G){const ne=ae.length;for(let ye=ne-1;ye>=0;--ye){const Ke=f(ae[ye],!0);Ke.__removalCount=($.__removalCount||0)+1,G.insertBefore(Ke,b($))}}}return _e($),!0}return $ instanceof d&&!Ku($)||(R==="noscript"||R==="noembed"||R==="noframes")&&pe(/<\/no(script|embed|frames)/i,$.innerHTML)?(_e($),!0):(O&&$.nodeType===hn.text&&(T=$.textContent,ri([at,It,lt],G=>{T=dn(T,G," ")}),$.textContent!==T&&(cn(t.removed,{element:$.cloneNode()}),$.textContent=T)),We(X.afterSanitizeElements,$,null),!1)},Ur=function($,T,R){if(Tr&&(T==="id"||T==="name")&&(R in n||R in Wu))return!1;if(!(E&&!nn[T]&&pe(ss,T))){if(!(qn&&pe(os,T))){if(!(Ye.attributeCheck instanceof Function&&Ye.attributeCheck(T,$))){if(!ee[T]||nn[T]){if(!(Wr($)&&(Q.tagNameCheck instanceof RegExp&&pe(Q.tagNameCheck,$)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck($))&&(Q.attributeNameCheck instanceof RegExp&&pe(Q.attributeNameCheck,T)||Q.attributeNameCheck instanceof Function&&Q.attributeNameCheck(T,$))||T==="is"&&Q.allowCustomizedBuiltInElements&&(Q.tagNameCheck instanceof RegExp&&pe(Q.tagNameCheck,R)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck(R))))return!1}else if(!ds[T]){if(!pe(Kn,dn(R,Wn,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&$!=="script"&&qg(R,"data:")===0&&Mr[$])){if(!(P&&!pe(rs,dn(R,Wn,"")))){if(R)return!1}}}}}}}return!0},Wr=function($){return $!=="annotation-xml"&&Ps($,as)},Kr=function($){We(X.beforeSanitizeAttributes,$,null);const{attributes:T}=$;if(!T||fs($))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ee,forceKeepAttr:void 0};let G=T.length;for(;G--;){const ae=T[G],{name:ne,namespaceURI:ye,value:Ke}=ae,Ft=ie(ne),gs=Ke;let oe=ne==="value"?gs:jg(gs);if(R.attrName=Ft,R.attrValue=oe,R.keepAttr=!0,R.forceKeepAttr=void 0,We(X.uponSanitizeAttribute,$,R),oe=R.attrValue,_r&&(Ft==="id"||Ft==="name")&&(dt(ne,$),oe=Nu+oe),J&&pe(/((--!?|])>)|<\/(style|title|textarea)/i,oe)){dt(ne,$);continue}if(Ft==="attributename"&&Ps(oe,"href")){dt(ne,$);continue}if(R.forceKeepAttr)continue;if(!R.keepAttr){dt(ne,$);continue}if(!F&&pe(/\/>/i,oe)){dt(ne,$);continue}O&&ri([at,It,lt],Hr=>{oe=dn(oe,Hr," ")});const zr=ie($.nodeName);if(!Ur(zr,Ft,oe)){dt(ne,$);continue}if(C&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!ye)switch(v.getAttributeType(zr,Ft)){case"TrustedHTML":{oe=C.createHTML(oe);break}case"TrustedScriptURL":{oe=C.createScriptURL(oe);break}}if(oe!==gs)try{ye?$.setAttributeNS(ye,ne,oe):$.setAttribute(ne,oe),fs($)?_e($):Ha(t.removed)}catch{dt(ne,$)}}We(X.afterSanitizeAttributes,$,null)},zu=function D($){let T=null;const R=Br($);for(We(X.beforeSanitizeShadowDOM,$,null);T=R.nextNode();)We(X.uponSanitizeShadowNode,T,null),Or(T),Kr(T),T.content instanceof o&&D(T.content);We(X.afterSanitizeShadowDOM,$,null)};return t.sanitize=function(D){let $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,R=null,G=null,ae=null;if(us=!D,us&&(D="<!-->"),typeof D!="string"&&!Fr(D))if(typeof D.toString=="function"){if(D=D.toString(),typeof D!="string")throw un("dirty is not a string, aborting")}else throw un("toString is not a function");if(!t.isSupported)return D;if(ue||hs($),t.removed=[],typeof D=="string"&&(sn=!1),sn){if(D.nodeName){const Ke=ie(D.nodeName);if(!Z[Ke]||ct[Ke])throw un("root node is forbidden and cannot be sanitized in-place")}}else if(D instanceof a)T=Nr("<!---->"),R=T.ownerDocument.importNode(D,!0),R.nodeType===hn.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?T=R:T.appendChild(R);else{if(!Rt&&!O&&!V&&D.indexOf("<")===-1)return C&&Vn?C.createHTML(D):D;if(T=Nr(D),!T)return Rt?null:Vn?M:""}T&&Xe&&_e(T.firstChild);const ne=Br(sn?D:T);for(;G=ne.nextNode();)Or(G),Kr(G),G.content instanceof o&&zu(G.content);if(sn)return D;if(Rt){if(jn)for(ae=z.call(T.ownerDocument);T.firstChild;)ae.appendChild(T.firstChild);else ae=T;return(ee.shadowroot||ee.shadowrootmode)&&(ae=be.call(i,ae,!0)),ae}let ye=V?T.outerHTML:T.innerHTML;return V&&Z["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&pe(xd,T.ownerDocument.doctype.name)&&(ye="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
|
|
2382
|
+
`+ye),O&&ri([at,It,lt],Ke=>{ye=dn(ye,Ke," ")}),C&&Vn?C.createHTML(ye):ye},t.setConfig=function(){let D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};hs(D),ue=!0},t.clearConfig=function(){Bt=null,ue=!1},t.isValidAttribute=function(D,$,T){Bt||hs({});const R=ie(D),G=ie($);return Ur(R,G,T)},t.addHook=function(D,$){typeof $=="function"&&cn(X[D],$)},t.removeHook=function(D,$){if($!==void 0){const T=zg(X[D],$);return T===-1?void 0:Hg(X[D],T,1)[0]}return Ha(X[D])},t.removeHooks=function(D){X[D]=[]},t.removeAllHooks=function(){X=Ja()},t}var vo=Ad();function dr(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Pt=dr();function Ed(e){Pt=e}var An={exec:()=>null};function K(e,t=""){let n=typeof e=="string"?e:e.source,i={replace:(s,o)=>{let r=typeof o=="string"?o:o.source;return r=r.replace(he.caret,"$1"),n=n.replace(s,r),i},getRegex:()=>new RegExp(n,t)};return i}var am=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),he={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")},lm=/^(?:[ \t]*(?:\n|$))+/,cm=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,dm=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,On=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,um=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ur=/(?:[*+-]|\d{1,9}[.)])/,Cd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Td=K(Cd).replace(/bull/g,ur).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(),pm=K(Cd).replace(/bull/g,ur).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(),pr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,hm=/^[^\n]+/,hr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,fm=K(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",hr).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),gm=K(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ur).getRegex(),Zi="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",fr=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,mm=K("^ {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",fr).replace("tag",Zi).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),_d=K(pr).replace("hr",On).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",Zi).getRegex(),ym=K(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",_d).getRegex(),gr={blockquote:ym,code:cm,def:fm,fences:dm,heading:um,hr:On,html:mm,lheading:Td,list:gm,newline:lm,paragraph:_d,table:An,text:hm},Ya=K("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",On).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",Zi).getRegex(),vm={...gr,lheading:pm,table:Ya,paragraph:K(pr).replace("hr",On).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ya).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",Zi).getRegex()},bm={...gr,html:K(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",fr).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:An,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:K(pr).replace("hr",On).replace("heading",` *#{1,6} *[^
|
|
2383
|
+
]`).replace("lheading",Td).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},wm=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,km=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Md=/^( {2,}|\\)\n(?!\s*$)/,$m=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,es=/[\p{P}\p{S}]/u,mr=/[\s\p{P}\p{S}]/u,Pd=/[^\s\p{P}\p{S}]/u,Sm=K(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,mr).getRegex(),Ld=/(?!~)[\p{P}\p{S}]/u,xm=/(?!~)[\s\p{P}\p{S}]/u,Am=/(?:[^\s\p{P}\p{S}]|~)/u,Em=K(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",am?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Id=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Cm=K(Id,"u").replace(/punct/g,es).getRegex(),Tm=K(Id,"u").replace(/punct/g,Ld).getRegex(),Rd="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",_m=K(Rd,"gu").replace(/notPunctSpace/g,Pd).replace(/punctSpace/g,mr).replace(/punct/g,es).getRegex(),Mm=K(Rd,"gu").replace(/notPunctSpace/g,Am).replace(/punctSpace/g,xm).replace(/punct/g,Ld).getRegex(),Pm=K("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Pd).replace(/punctSpace/g,mr).replace(/punct/g,es).getRegex(),Lm=K(/\\(punct)/,"gu").replace(/punct/g,es).getRegex(),Im=K(/^<(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(),Rm=K(fr).replace("(?:-->|$)","-->").getRegex(),Dm=K("^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",Rm).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ii=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Nm=K(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Ii).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Dd=K(/^!?\[(label)\]\[(ref)\]/).replace("label",Ii).replace("ref",hr).getRegex(),Nd=K(/^!?\[(ref)\](?:\[\])?/).replace("ref",hr).getRegex(),Bm=K("reflink|nolink(?!\\()","g").replace("reflink",Dd).replace("nolink",Nd).getRegex(),Xa=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,yr={_backpedal:An,anyPunctuation:Lm,autolink:Im,blockSkip:Em,br:Md,code:km,del:An,emStrongLDelim:Cm,emStrongRDelimAst:_m,emStrongRDelimUnd:Pm,escape:wm,link:Nm,nolink:Nd,punctuation:Sm,reflink:Dd,reflinkSearch:Bm,tag:Dm,text:$m,url:An},Fm={...yr,link:K(/^!?\[(label)\]\((.*?)\)/).replace("label",Ii).getRegex(),reflink:K(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ii).getRegex()},bo={...yr,emStrongRDelimAst:Mm,emStrongLDelim:Tm,url:K(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Xa).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:K(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Xa).getRegex()},Om={...bo,br:K(Md).replace("{2,}","*").getRegex(),text:K(bo.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},li={normal:gr,gfm:vm,pedantic:bm},fn={normal:yr,gfm:bo,breaks:Om,pedantic:Fm},Um={"&":"&","<":"<",">":">",'"':""","'":"'"},Za=e=>Um[e];function He(e,t){if(t){if(he.escapeTest.test(e))return e.replace(he.escapeReplace,Za)}else if(he.escapeTestNoEncode.test(e))return e.replace(he.escapeReplaceNoEncode,Za);return e}function el(e){try{e=encodeURI(e).replace(he.percentDecode,"%")}catch{return null}return e}function tl(e,t){var o;let n=e.replace(he.findPipe,(r,a,d)=>{let c=!1,l=a;for(;--l>=0&&d[l]==="\\";)c=!c;return c?"|":" |"}),i=n.split(he.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(he.slashPipe,"|");return i}function gn(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 Wm(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 nl(e,t,n,i,s){let o=t.href,r=t.title||null,a=e[1].replace(s.other.outputLinkReplace,"$1");i.state.inLink=!0;let d={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:r,text:a,tokens:i.inlineTokens(a)};return i.state.inLink=!1,d}function Km(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let s=i[1];return t.split(`
|
|
2384
2384
|
`).map(o=>{let r=o.match(n.other.beginningSpace);if(r===null)return o;let[a]=r;return a.length>=s.length?o.slice(s.length):o}).join(`
|
|
2385
2385
|
`)}var Ri=class{constructor(e){W(this,"options");W(this,"rules");W(this,"lexer");this.options=e||Pt}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:gn(n,`
|
|
2386
2386
|
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=Km(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=gn(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:gn(t[0],`
|
|
@@ -2390,21 +2390,21 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Sn(t.
|
|
|
2390
2390
|
`),l=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
2391
2391
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
|
|
2392
2392
|
${c}`:c,s=s?`${s}
|
|
2393
|
-
${l}`:l;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,o,!0),this.lexer.state.top=p,n.length===0)break;let
|
|
2393
|
+
${l}`:l;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,o,!0),this.lexer.state.top=p,n.length===0)break;let h=o.at(-1);if((h==null?void 0:h.type)==="code")break;if((h==null?void 0:h.type)==="blockquote"){let v=h,S=v.raw+`
|
|
2394
2394
|
`+n.join(`
|
|
2395
|
-
`),
|
|
2395
|
+
`),f=this.blockquote(S);o[o.length-1]=f,i=i.substring(0,i.length-v.raw.length)+f.raw,s=s.substring(0,s.length-v.text.length)+f.text;break}else if((h==null?void 0:h.type)==="list"){let v=h,S=v.raw+`
|
|
2396
2396
|
`+n.join(`
|
|
2397
|
-
`),
|
|
2398
|
-
`);continue}}return{type:"blockquote",raw:i,tokens:o,text:s}}}list(e){var n,i;let t=this.rules.block.list.exec(e);if(t){let s=t[1].trim(),o=s.length>1,r={type:"list",raw:"",ordered:o,start:o?+s.slice(0,-1):"",loose:!1,items:[]};s=o?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=o?s:"[*+-]");let a=this.rules.other.listItemRegex(s),d=!1;for(;e;){let l=!1,p="",
|
|
2399
|
-
`,1)[0].replace(this.rules.other.listReplaceTabs,
|
|
2400
|
-
`,1)[0],
|
|
2401
|
-
`,e=e.substring(S.length+1),l=!0),!l){let
|
|
2402
|
-
`,1)[0],B;if(S=_,this.options.pedantic?(S=S.replace(this.rules.other.listReplaceNesting," "),B=S):B=S.replace(this.rules.other.tabCharGlobal," "),A.test(S)||C.test(S)||
|
|
2403
|
-
`+B.slice(
|
|
2404
|
-
`+S}!
|
|
2405
|
-
`,e=e.substring(_.length+1),v=B.slice(
|
|
2406
|
-
`):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let a of i)this.rules.other.tableAlignRight.test(a)?o.align.push("right"):this.rules.other.tableAlignCenter.test(a)?o.align.push("center"):this.rules.other.tableAlignLeft.test(a)?o.align.push("left"):o.align.push(null);for(let a=0;a<n.length;a++)o.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:o.align[a]});for(let a of s)o.rows.push(
|
|
2407
|
-
`?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=gn(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=Wm(t[2],"()");if(o===-2)return;if(o>-1){let r=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,r).trim(),t[3]=""}}let 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)),
|
|
2397
|
+
`),f=this.list(S);o[o.length-1]=f,i=i.substring(0,i.length-h.raw.length)+f.raw,s=s.substring(0,s.length-v.raw.length)+f.raw,n=S.substring(o.at(-1).raw.length).split(`
|
|
2398
|
+
`);continue}}return{type:"blockquote",raw:i,tokens:o,text:s}}}list(e){var n,i;let t=this.rules.block.list.exec(e);if(t){let s=t[1].trim(),o=s.length>1,r={type:"list",raw:"",ordered:o,start:o?+s.slice(0,-1):"",loose:!1,items:[]};s=o?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=o?s:"[*+-]");let a=this.rules.other.listItemRegex(s),d=!1;for(;e;){let l=!1,p="",h="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let v=t[2].split(`
|
|
2399
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,b=>" ".repeat(3*b.length)),S=e.split(`
|
|
2400
|
+
`,1)[0],f=!v.trim(),w=0;if(this.options.pedantic?(w=2,h=v.trimStart()):f?w=t[1].length+1:(w=t[2].search(this.rules.other.nonSpaceChar),w=w>4?1:w,h=v.slice(w),w+=t[1].length),f&&this.rules.other.blankLine.test(S)&&(p+=S+`
|
|
2401
|
+
`,e=e.substring(S.length+1),l=!0),!l){let b=this.rules.other.nextBulletRegex(w),x=this.rules.other.hrRegex(w),A=this.rules.other.fencesBeginRegex(w),C=this.rules.other.headingBeginRegex(w),M=this.rules.other.htmlBeginRegex(w);for(;e;){let _=e.split(`
|
|
2402
|
+
`,1)[0],B;if(S=_,this.options.pedantic?(S=S.replace(this.rules.other.listReplaceNesting," "),B=S):B=S.replace(this.rules.other.tabCharGlobal," "),A.test(S)||C.test(S)||M.test(S)||b.test(S)||x.test(S))break;if(B.search(this.rules.other.nonSpaceChar)>=w||!S.trim())h+=`
|
|
2403
|
+
`+B.slice(w);else{if(f||v.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||A.test(v)||C.test(v)||x.test(v))break;h+=`
|
|
2404
|
+
`+S}!f&&!S.trim()&&(f=!0),p+=_+`
|
|
2405
|
+
`,e=e.substring(_.length+1),v=B.slice(w)}}r.loose||(d?r.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(d=!0)),r.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),r.raw+=p}let c=r.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let l of r.items){if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),l.task){if(l.text=l.text.replace(this.rules.other.listReplaceTask,""),((n=l.tokens[0])==null?void 0:n.type)==="text"||((i=l.tokens[0])==null?void 0:i.type)==="paragraph"){l.tokens[0].raw=l.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),l.tokens[0].text=l.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(l.raw);if(p){let h={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};l.checked=h.checked,r.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=h.raw+l.tokens[0].raw,l.tokens[0].text=h.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(h)):l.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):l.tokens.unshift(h)}}if(!r.loose){let p=l.tokens.filter(v=>v.type==="space"),h=p.length>0&&p.some(v=>this.rules.other.anyLine.test(v.raw));r.loose=h}}if(r.loose)for(let l of r.items){l.loose=!0;for(let p of l.tokens)p.type==="text"&&(p.type="paragraph")}return r}}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 r;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=tl(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(r=t[3])!=null&&r.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
2406
|
+
`):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let a of i)this.rules.other.tableAlignRight.test(a)?o.align.push("right"):this.rules.other.tableAlignCenter.test(a)?o.align.push("center"):this.rules.other.tableAlignLeft.test(a)?o.align.push("left"):o.align.push(null);for(let a=0;a<n.length;a++)o.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:o.align[a]});for(let a of s)o.rows.push(tl(a,o.header.length).map((d,c)=>({text:d,tokens:this.lexer.inline(d),header:!1,align:o.align[c]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
|
|
2407
|
+
`?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=gn(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=Wm(t[2],"()");if(o===-2)return;if(o>-1){let r=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,r).trim(),t[3]=""}}let 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)),nl(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 nl(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,r,a=s,d=0,c=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+s);(i=c.exec(t))!=null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(r=[...o].length,i[3]||i[4]){a+=r;continue}else if((i[5]||i[6])&&s%3&&!((s+r)%3)){d+=r;continue}if(a-=r,a>0)continue;r=Math.min(r,r+a+d);let l=[...i[0]][0].length,p=e.slice(0,s+i.index+l+r);if(Math.min(s,r)%2){let v=p.slice(1,-1);return{type:"em",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}let h=p.slice(2,-2);return{type:"strong",raw:p,text:h,tokens:this.lexer.inlineTokens(h)}}}}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}}}},Se=class wo{constructor(t){W(this,"tokens");W(this,"options");W(this,"state");W(this,"inlineQueue");W(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Pt,this.options.tokenizer=this.options.tokenizer||new Ri,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:he,block:li.normal,inline:fn.normal};this.options.pedantic?(n.block=li.pedantic,n.inline=fn.pedantic):this.options.gfm&&(n.block=li.gfm,this.options.breaks?n.inline=fn.breaks:n.inline=fn.gfm),this.tokenizer.rules=n}static get rules(){return{block:li,inline:fn}}static lex(t,n){return new wo(n).lex(t)}static lexInline(t,n){return new wo(n).inlineTokens(t)}lex(t){t=t.replace(he.carriageReturn,`
|
|
2408
2408
|
`),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,r;for(this.options.pedantic&&(t=t.replace(he.tabCharGlobal," ").replace(he.spaceLine,""));t;){let a;if((o=(s=this.options.extensions)==null?void 0:s.block)!=null&&o.some(c=>(a=c.call({lexer:this},t,n))?(t=t.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.space(t)){t=t.substring(a.raw.length);let c=n.at(-1);a.raw.length===1&&c!==void 0?c.raw+=`
|
|
2409
2409
|
`:n.push(a);continue}if(a=this.tokenizer.code(t)){t=t.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
2410
2410
|
`)?"":`
|
|
@@ -2412,13 +2412,13 @@ ${l}`:l;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
2412
2412
|
`+a.text,this.inlineQueue.at(-1).src=c.text):n.push(a);continue}if(a=this.tokenizer.fences(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.heading(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.hr(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.blockquote(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.list(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.html(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.def(t)){t=t.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
2413
2413
|
`)?"":`
|
|
2414
2414
|
`)+a.raw,c.text+=`
|
|
2415
|
-
`+a.raw,this.inlineQueue.at(-1).src=c.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},n.push(a));continue}if(a=this.tokenizer.table(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.lheading(t)){t=t.substring(a.raw.length),n.push(a);continue}let d=t;if((r=this.options.extensions)!=null&&r.startBlock){let c=1/0,l=t.slice(1),p;this.options.extensions.startBlock.forEach(
|
|
2415
|
+
`+a.raw,this.inlineQueue.at(-1).src=c.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},n.push(a));continue}if(a=this.tokenizer.table(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.lheading(t)){t=t.substring(a.raw.length),n.push(a);continue}let d=t;if((r=this.options.extensions)!=null&&r.startBlock){let c=1/0,l=t.slice(1),p;this.options.extensions.startBlock.forEach(h=>{p=h.call({lexer:this},l),typeof p=="number"&&p>=0&&(c=Math.min(c,p))}),c<1/0&&c>=0&&(d=t.substring(0,c+1))}if(this.state.top&&(a=this.tokenizer.paragraph(d))){let c=n.at(-1);i&&(c==null?void 0:c.type)==="paragraph"?(c.raw+=(c.raw.endsWith(`
|
|
2416
2416
|
`)?"":`
|
|
2417
2417
|
`)+a.raw,c.text+=`
|
|
2418
2418
|
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a),i=d.length!==t.length,t=t.substring(a.raw.length);continue}if(a=this.tokenizer.text(t)){t=t.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
2419
2419
|
`)?"":`
|
|
2420
2420
|
`)+a.raw,c.text+=`
|
|
2421
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var d,c,l,p,
|
|
2421
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var d,c,l,p,h;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=((c=(d=this.options.hooks)==null?void 0:d.emStrongMask)==null?void 0:c.call({lexer:this},i))??i;let r=!1,a="";for(;t;){r||(a=""),r=!1;let v;if((p=(l=this.options.extensions)==null?void 0:l.inline)!=null&&p.some(f=>(v=f.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 f=n.at(-1);v.type==="text"&&(f==null?void 0:f.type)==="text"?(f.raw+=v.raw,f.text+=v.text):n.push(v);continue}if(v=this.tokenizer.emStrong(t,i,a)){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 S=t;if((h=this.options.extensions)!=null&&h.startInline){let f=1/0,w=t.slice(1),b;this.options.extensions.startInline.forEach(x=>{b=x.call({lexer:this},w),typeof b=="number"&&b>=0&&(f=Math.min(f,b))}),f<1/0&&f>=0&&(S=t.substring(0,f+1))}if(v=this.tokenizer.inlineText(S)){t=t.substring(v.raw.length),v.raw.slice(-1)!=="_"&&(a=v.raw.slice(-1)),r=!0;let f=n.at(-1);(f==null?void 0:f.type)==="text"?(f.raw+=v.raw,f.text+=v.text):n.push(v);continue}if(t){let f="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(f);break}else throw new Error(f)}}return n}},Di=class{constructor(e){W(this,"options");W(this,"parser");this.options=e||Pt}space(e){return""}code({text:e,lang:t,escaped:n}){var o;let i=(o=(t||"").match(he.notSpaceStart))==null?void 0:o[0],s=e.replace(he.endingNewline,"")+`
|
|
2422
2422
|
`;return i?'<pre><code class="language-'+He(i)+'">'+(n?s:He(s,!0))+`</code></pre>
|
|
2423
2423
|
`:"<pre><code>"+(n?s:He(s,!0))+`</code></pre>
|
|
2424
2424
|
`}blockquote({tokens:e}){return`<blockquote>
|
|
@@ -2436,10 +2436,10 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
2436
2436
|
`}tablerow({text:e}){return`<tr>
|
|
2437
2437
|
${e}</tr>
|
|
2438
2438
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
2439
|
-
`}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>${He(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=
|
|
2440
|
-
Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+He(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},Ct=new zm;function q(e,t){return Ct.parse(e,t)}q.options=q.setOptions=function(e){return Ct.setOptions(e),q.defaults=Ct.defaults,Ed(q.defaults),q};q.getDefaults=
|
|
2439
|
+
`}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>${He(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=el(e);if(s===null)return i;e=s;let o='<a href="'+e+'"';return t&&(o+=' title="'+He(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=el(e);if(s===null)return He(n);e=s;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${He(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:He(e.text)}},vr=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}},xe=class ko{constructor(t){W(this,"options");W(this,"renderer");W(this,"textRenderer");this.options=t||Pt,this.options.renderer=this.options.renderer||new Di,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new vr}static parse(t,n){return new ko(n).parse(t)}static parseInline(t,n){return new ko(n).parseInline(t)}parse(t){var i,s;let n="";for(let o=0;o<t.length;o++){let r=t[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[r.type]){let d=r,c=this.options.extensions.renderers[d.type].call({parser:this},d);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(d.type)){n+=c||"";continue}}let a=r;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let d='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return n}parseInline(t,n=this.renderer){var s,o;let i="";for(let r=0;r<t.length;r++){let a=t[r];if((o=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&o[a.type]){let c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){i+=c||"";continue}}let d=a;switch(d.type){case"escape":{i+=n.text(d);break}case"html":{i+=n.html(d);break}case"link":{i+=n.link(d);break}case"image":{i+=n.image(d);break}case"checkbox":{i+=n.checkbox(d);break}case"strong":{i+=n.strong(d);break}case"em":{i+=n.em(d);break}case"codespan":{i+=n.codespan(d);break}case"br":{i+=n.br(d);break}case"del":{i+=n.del(d);break}case"text":{i+=n.text(d);break}default:{let c='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return i}},fi,vn=(fi=class{constructor(e){W(this,"options");W(this,"block");this.options=e||Pt}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Se.lex:Se.lexInline}provideParser(){return this.block?xe.parse:xe.parseInline}},W(fi,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),W(fi,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),fi),zm=class{constructor(...e){W(this,"defaults",dr());W(this,"options",this.setOptions);W(this,"parse",this.parseMarkdown(!0));W(this,"parseInline",this.parseMarkdown(!1));W(this,"Parser",xe);W(this,"Renderer",Di);W(this,"TextRenderer",vr);W(this,"Lexer",Se);W(this,"Tokenizer",Ri);W(this,"Hooks",vn);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 r=o;for(let a of r.header)n=n.concat(this.walkTokens(a.tokens,t));for(let a of r.rows)for(let d of a)n=n.concat(this.walkTokens(d.tokens,t));break}case"list":{let r=o;n=n.concat(this.walkTokens(r.items,t));break}default:{let r=o;(s=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&s[r.type]?this.defaults.extensions.childTokens[r.type].forEach(a=>{let d=r[a].flat(1/0);n=n.concat(this.walkTokens(d,t))}):r.tokens&&(n=n.concat(this.walkTokens(r.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(...r){let a=s.renderer.apply(this,r);return a===!1&&(a=o.apply(this,r)),a}: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 Di(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 r=o,a=n.renderer[r],d=s[r];s[r]=(...c)=>{let l=a.apply(s,c);return l===!1&&(l=d.apply(s,c)),l||""}}i.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new Ri(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 r=o,a=n.tokenizer[r],d=s[r];s[r]=(...c)=>{let l=a.apply(s,c);return l===!1&&(l=d.apply(s,c)),l}}i.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new vn;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 r=o,a=n.hooks[r],d=s[r];vn.passThroughHooks.has(o)?s[r]=c=>{if(this.defaults.async&&vn.passThroughHooksRespectAsync.has(o))return(async()=>{let p=await a.call(s,c);return d.call(s,p)})();let l=a.call(s,c);return d.call(s,l)}:s[r]=(...c)=>{if(this.defaults.async)return(async()=>{let p=await a.apply(s,c);return p===!1&&(p=await d.apply(s,c)),p})();let l=a.apply(s,c);return l===!1&&(l=d.apply(s,c)),l}}i.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,o=n.walkTokens;i.walkTokens=function(r){let a=[];return a.push(o.call(this,r)),s&&(a=a.concat(s.call(this,r))),a}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Se.lex(e,t??this.defaults)}parser(e,t){return xe.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 r=s.hooks?await s.hooks.preprocess(t):t,a=await(s.hooks?await s.hooks.provideLexer():e?Se.lex:Se.lexInline)(r,s),d=s.hooks?await s.hooks.processAllTokens(a):a;s.walkTokens&&await Promise.all(this.walkTokens(d,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():e?xe.parse:xe.parseInline)(d,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(o);try{s.hooks&&(t=s.hooks.preprocess(t));let r=(s.hooks?s.hooks.provideLexer():e?Se.lex:Se.lexInline)(t,s);s.hooks&&(r=s.hooks.processAllTokens(r)),s.walkTokens&&this.walkTokens(r,s.walkTokens);let a=(s.hooks?s.hooks.provideParser():e?xe.parse:xe.parseInline)(r,s);return s.hooks&&(a=s.hooks.postprocess(a)),a}catch(r){return o(r)}}}onError(e,t){return n=>{if(n.message+=`
|
|
2440
|
+
Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+He(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},Ct=new zm;function q(e,t){return Ct.parse(e,t)}q.options=q.setOptions=function(e){return Ct.setOptions(e),q.defaults=Ct.defaults,Ed(q.defaults),q};q.getDefaults=dr;q.defaults=Pt;q.use=function(...e){return Ct.use(...e),q.defaults=Ct.defaults,Ed(q.defaults),q};q.walkTokens=function(e,t){return Ct.walkTokens(e,t)};q.parseInline=Ct.parseInline;q.Parser=xe;q.parser=xe.parse;q.Renderer=Di;q.TextRenderer=vr;q.Lexer=Se;q.lexer=Se.lex;q.Tokenizer=Ri;q.Hooks=vn;q.parse=q;q.options;q.setOptions;q.use;q.walkTokens;q.parseInline;xe.parse;Se.lex;q.setOptions({gfm:!0,breaks:!0,mangle:!1});const il=["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"],sl=["class","href","rel","target","title","start"];let ol=!1;const Hm=14e4,qm=4e4,jm=200,Ns=5e4,vt=new Map;function Vm(e){const t=vt.get(e);return t===void 0?null:(vt.delete(e),vt.set(e,t),t)}function rl(e,t){if(vt.set(e,t),vt.size<=jm)return;const n=vt.keys().next().value;n&&vt.delete(n)}function Gm(){ol||(ol=!0,vo.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function Ni(e){const t=e.trim();if(!t)return"";if(Gm(),t.length<=Ns){const r=Vm(t);if(r!==null)return r}const n=tc(t,Hm),i=n.truncated?`
|
|
2441
2441
|
|
|
2442
|
-
… truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>qm){const a=`<pre class="code-block">${Qm(`${n.text}${i}`)}</pre>`,d=
|
|
2442
|
+
… truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>qm){const a=`<pre class="code-block">${Qm(`${n.text}${i}`)}</pre>`,d=vo.sanitize(a,{ALLOWED_TAGS:il,ALLOWED_ATTR:sl});return t.length<=Ns&&rl(t,d),d}const s=q.parse(`${n.text}${i}`),o=vo.sanitize(s,{ALLOWED_TAGS:il,ALLOWED_ATTR:sl});return t.length<=Ns&&rl(t,o),o}function Qm(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Jm=1500,Ym=2e3,Bd="Copy as markdown",Xm="Copied",Zm="Copy failed";async function ey(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 ci(e,t){e.title=t,e.setAttribute("aria-label",t)}function ty(e){const t=e.label??Bd;return u`
|
|
2443
2443
|
<button
|
|
2444
2444
|
class="chat-copy-btn"
|
|
2445
2445
|
type="button"
|
|
@@ -2452,7 +2452,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
2452
2452
|
<span class="chat-copy-btn__icon-check">${L.check}</span>
|
|
2453
2453
|
</span>
|
|
2454
2454
|
</button>
|
|
2455
|
-
`}function ny(e){return ty({text:()=>e,label:Bd})}function iy(e){const t=e,n=sy(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:oy(s.arguments??s.args)})}for(const s of n){const o=String(s.type??"").toLowerCase();if(o!=="toolresult"&&o!=="tool_result")continue;const r=ry(s),a=typeof s.name=="string"?s.name:"tool";i.push({kind:"result",name:a,text:r})}if(
|
|
2455
|
+
`}function ny(e){return ty({text:()=>e,label:Bd})}function iy(e){const t=e,n=sy(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:oy(s.arguments??s.args)})}for(const s of n){const o=String(s.type??"").toLowerCase();if(o!=="toolresult"&&o!=="tool_result")continue;const r=ry(s),a=typeof s.name=="string"?s.name:"tool";i.push({kind:"result",name:a,text:r})}if(rc(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=nc(e)??void 0;i.push({kind:"result",name:s,text:o})}return i}function sy(e){return Array.isArray(e)?e.filter(Boolean):[]}function oy(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 ry(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}const Bs=40,Fs=new Map;async function ay(e){const t=Fs.get(e);if(t)return t;try{const n=new(window.AudioContext||window.webkitAudioContext),s=await(await fetch(e)).arrayBuffer(),r=(await n.decodeAudioData(s)).getChannelData(0),a=Math.floor(r.length/Bs),d=[];for(let p=0;p<Bs;p++){let h=0;const v=p*a,S=Math.min(v+a,r.length);for(let f=v;f<S;f++){const w=Math.abs(r[f]);w>h&&(h=w)}d.push(h)}const c=Math.max(...d,.01),l=d.map(p=>Math.max(p/c,.08));return Fs.set(e,l),n.close(),l}catch{const n=Array.from(e).reduce((s,o)=>(s<<5)-s+o.charCodeAt(0)|0,0),i=[];for(let s=0;s<Bs;s++){const o=Math.abs((n*(s+1)*9301+49297)%233280/233280);i.push(.15+o*.85)}return Fs.set(e,i),i}}const Os=[1,1.5,2],Bi=new Map;function ly(e){let t=Bi.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:[]},Bi.set(e,t),ay(e).then(i=>{t.waveform=i,Fd(e)}),t}const En="http://www.w3.org/2000/svg";function cy(){const e=document.createElementNS(En,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor");const t=document.createElementNS(En,"polygon");return t.setAttribute("points","6,3 20,12 6,21"),e.appendChild(t),e}function dy(){const e=document.createElementNS(En,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor");const t=document.createElementNS(En,"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(En,"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 Wt(e){return document.querySelector(`.vnp[data-url="${CSS.escape(e)}"]`)}function Fd(e){const t=Wt(e);if(!t)return;const n=Bi.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 r=document.createElement("span");r.className="vnp__bar",r.style.height=`${Math.round(o*100)}%`,s.appendChild(r)}i.appendChild(s)}Cn(t,n)}}function Cn(e,t){const n=t.duration>0?t.currentTime/t.duration:0,i=e.querySelectorAll(".vnp__bar"),s=i.length;i.forEach((r,a)=>{r.classList.toggle("vnp__bar--active",a/s<n)});const o=e.querySelector(".vnp__time");o&&(o.textContent=t.playing||t.currentTime>0?Fi(t.currentTime):Fi(t.duration))}function Us(e,t){const n=e.querySelector(".vnp__play");if(!n)return;const i=n.querySelector("svg"),s=t?dy():cy();i?n.replaceChild(s,i):n.appendChild(s)}function Fi(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 al=new Set;function uy(e){if(al.has(e))return;al.add(e);const t=Bi.get(e);if(!t)return;const{audio:n}=t;n.addEventListener("loadedmetadata",()=>{t.duration=n.duration;const i=Wt(e);i&&Cn(i,t)}),n.addEventListener("timeupdate",()=>{t.currentTime=n.currentTime;const i=Wt(e);i&&Cn(i,t)}),n.addEventListener("ended",()=>{t.playing=!1,n.currentTime=0,t.currentTime=0;const i=Wt(e);i&&(Cn(i,t),Us(i,!1))}),n.addEventListener("pause",()=>{t.playing=!1;const i=Wt(e);i&&Us(i,!1)}),n.addEventListener("play",()=>{t.playing=!0;const i=Wt(e);i&&Us(i,!0)})}function py(e,t){const n=ly(e);uy(e);const i=a=>{a.stopPropagation(),n.playing?n.audio.pause():n.audio.play()},s=a=>{a.stopPropagation();const d=Os.indexOf(n.speed),c=Os[(d+1)%Os.length];n.speed=c,n.audio.playbackRate=c;const l=a.target.closest(".vnp__speed");l&&(l.textContent=`${c}×`)},o=a=>{a.stopPropagation();const d=a.target.closest(".vnp__waveform");if(!d)return;const c=d.getBoundingClientRect(),l=Math.max(0,Math.min(1,(a.clientX-c.left)/c.width));if(n.duration>0){n.audio.currentTime=l*n.duration,n.currentTime=n.audio.currentTime;const p=d.closest(".vnp");p&&Cn(p,n)}},r=n.playing||n.currentTime>0?Fi(n.currentTime):Fi(n.duration);return queueMicrotask(()=>Fd(e)),u`
|
|
2456
2456
|
<div class="vnp" data-url=${e} @click=${a=>a.stopPropagation()}>
|
|
2457
2457
|
<button class="vnp__play" @click=${i} aria-label=${n.playing?"Pause":"Play"}>
|
|
2458
2458
|
${n.playing?fy():hy()}
|
|
@@ -2492,7 +2492,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
2492
2492
|
${Od({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!1,showReasoning:!1})}
|
|
2493
2493
|
</div>
|
|
2494
2494
|
</div>
|
|
2495
|
-
`}function ky(e,t){const n=
|
|
2495
|
+
`}function ky(e,t){const n=oc(e.role),i=n==="user"?"user":n==="assistant"?"assistant":"other",s=new Date(e.timestamp).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"});return u`
|
|
2496
2496
|
<div class="chat-group ${i}">
|
|
2497
2497
|
<div class="chat-group-messages">
|
|
2498
2498
|
${e.messages.map((o,r)=>Od(o.message,{isStreaming:e.isStreaming&&r===e.messages.length-1,showReasoning:t.showReasoning}))}
|
|
@@ -2516,7 +2516,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
2516
2516
|
<div class="chat-message-files">
|
|
2517
2517
|
${e.map(t=>t.mimeType==="application/pdf"?Ay(t):t.mimeType.startsWith("audio/")?py(t.url,t.name):Ey(t))}
|
|
2518
2518
|
</div>
|
|
2519
|
-
`}function xy(e,t){const n=document.createElement("div");n.className="chat-pdf-modal-overlay";const i=document.createElement("div");i.className="chat-pdf-modal";const s=document.createElement("div");s.className="chat-pdf-modal__header";const o=document.createElement("span");o.className="chat-pdf-modal__title",o.textContent=t;const r=document.createElement("a");r.className="chat-pdf-modal__open",r.href=e,r.target="_blank",r.rel="noreferrer noopener",r.textContent="Open in new tab";const a=document.createElement("button");a.className="chat-pdf-modal__close",a.setAttribute("aria-label","Close");const d=document.createElementNS("http://www.w3.org/2000/svg","svg");d.setAttribute("viewBox","0 0 24 24");const c=document.createElementNS("http://www.w3.org/2000/svg","line");c.setAttribute("x1","18"),c.setAttribute("y1","6"),c.setAttribute("x2","6"),c.setAttribute("y2","18");const l=document.createElementNS("http://www.w3.org/2000/svg","line");l.setAttribute("x1","6"),l.setAttribute("y1","6"),l.setAttribute("x2","18"),l.setAttribute("y2","18"),d.append(c,l),a.appendChild(d),s.append(o,r,a);const p=document.createElement("iframe");p.className="chat-pdf-modal__frame",p.src=e,p.title=t,i.append(s,p),n.appendChild(i),n.addEventListener("click",
|
|
2519
|
+
`}function xy(e,t){const n=document.createElement("div");n.className="chat-pdf-modal-overlay";const i=document.createElement("div");i.className="chat-pdf-modal";const s=document.createElement("div");s.className="chat-pdf-modal__header";const o=document.createElement("span");o.className="chat-pdf-modal__title",o.textContent=t;const r=document.createElement("a");r.className="chat-pdf-modal__open",r.href=e,r.target="_blank",r.rel="noreferrer noopener",r.textContent="Open in new tab";const a=document.createElement("button");a.className="chat-pdf-modal__close",a.setAttribute("aria-label","Close");const d=document.createElementNS("http://www.w3.org/2000/svg","svg");d.setAttribute("viewBox","0 0 24 24");const c=document.createElementNS("http://www.w3.org/2000/svg","line");c.setAttribute("x1","18"),c.setAttribute("y1","6"),c.setAttribute("x2","6"),c.setAttribute("y2","18");const l=document.createElementNS("http://www.w3.org/2000/svg","line");l.setAttribute("x1","6"),l.setAttribute("y1","6"),l.setAttribute("x2","18"),l.setAttribute("y2","18"),d.append(c,l),a.appendChild(d),s.append(o,r,a);const p=document.createElement("iframe");p.className="chat-pdf-modal__frame",p.src=e,p.title=t,i.append(s,p),n.appendChild(i),n.addEventListener("click",h=>{h.target===n&&n.remove()}),a.addEventListener("click",()=>n.remove()),document.body.appendChild(n)}function Ay(e){return u`
|
|
2520
2520
|
<div class="chat-pdf-preview" @click=${()=>xy(e.url,e.name)}>
|
|
2521
2521
|
<iframe
|
|
2522
2522
|
src=${e.url}
|
|
@@ -2541,15 +2541,15 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
2541
2541
|
<span class="chat-file-card__icon">${yy(e.mimeType)}</span>
|
|
2542
2542
|
<span class="chat-file-card__name">${e.name}</span>
|
|
2543
2543
|
</a>
|
|
2544
|
-
`}function Od(e,t,n){const i=e,s=typeof i.role=="string"?i.role:"unknown",o=
|
|
2544
|
+
`}function Od(e,t,n){const i=e,s=typeof i.role=="string"?i.role:"unknown",o=rc(e)||s.toLowerCase()==="toolresult"||s.toLowerCase()==="tool_result"||typeof i.toolCallId=="string"||typeof i.tool_call_id=="string",a=iy(e).length>0,d=gy(e),c=d.length>0,l=my(e),p=l.length>0,h=nc(e),v=t.showReasoning&&s==="assistant"?Fp(e):null,S=h!=null&&h.trim()?h:null,f=v?Up(v):null,w=S,b=(s==="assistant"||s==="user")&&!!(w!=null&&w.trim()),x=["chat-bubble",b?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!w&&(a||o)||!w&&!c&&!p?k:u`
|
|
2545
2545
|
<div class="${x}">
|
|
2546
|
-
${
|
|
2546
|
+
${b?ny(w):k}
|
|
2547
2547
|
${$y(d)}
|
|
2548
2548
|
${Sy(l)}
|
|
2549
|
-
${
|
|
2550
|
-
${
|
|
2549
|
+
${f?u`<div class="chat-thinking">${Li(Ni(f))}</div>`:k}
|
|
2550
|
+
${w?u`<div class="chat-text">${Li(Ni(w))}</div>`:k}
|
|
2551
2551
|
</div>
|
|
2552
|
-
`}const N={active:!1,mode:"tap",startTime:0,elapsed:0,mediaRecorder:null,audioChunks:[],stream:null,timerId:null,startX:0,cancelled:!1};let H=null,wt=null,kt=!1;function
|
|
2552
|
+
`}const N={active:!1,mode:"tap",startTime:0,elapsed:0,mediaRecorder:null,audioChunks:[],stream:null,timerId:null,startX:0,cancelled:!1};let H=null,wt=null,kt=!1;function ll(e){const t=Math.floor(e/60),n=e%60;return`${t}:${n.toString().padStart(2,"0")}`}function gt(){if(N.timerId&&(clearInterval(N.timerId),N.timerId=null),N.stream){for(const e of N.stream.getTracks())e.stop();N.stream=null}wt&&(clearTimeout(wt),wt=null),Oi(),N.mediaRecorder=null,N.audioChunks=[],N.active=!1,N.cancelled=!1,kt=!1}async function Ud(e){var t;try{if(!((t=navigator.mediaDevices)!=null&&t.getUserMedia))return console.warn("[voice] getUserMedia unavailable (requires secure context)"),gt(),!1;const n=await navigator.mediaDevices.getUserMedia({audio:!0});N.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 N.mediaRecorder=s,N.audioChunks=[],N.mode=e,N.startTime=Date.now(),N.elapsed=0,N.active=!0,N.cancelled=!1,s.ondataavailable=o=>{o.data.size>0&&N.audioChunks.push(o.data)},s.onstop=()=>{if(N.cancelled){gt(),H==null||H.onRequestRender();return}const o=new Blob(N.audioChunks,{type:s.mimeType});if(o.size===0){gt(),H==null||H.onRequestRender();return}const r=new FileReader;r.onload=()=>{const a=r.result,d=s.mimeType.includes("mp4")?"m4a":"webm",c={id:Qi(),dataUrl:a,mimeType:s.mimeType||"audio/webm",fileName:`voice-note-${Date.now()}.${d}`};gt(),H==null||H.onSend(c),H==null||H.onRequestRender()},r.onerror=()=>{gt(),H==null||H.onRequestRender()},r.readAsDataURL(o)},s.start(250),N.timerId=setInterval(()=>{N.elapsed=Math.floor((Date.now()-N.startTime)/1e3),H==null||H.onRequestRender()},1e3),H==null||H.onRequestRender(),!0}catch(n){return console.warn("[voice] startRecording failed:",n),gt(),!1}}function Wd(){!N.active||!N.mediaRecorder||(N.cancelled=!1,N.mediaRecorder.state==="recording"&&N.mediaRecorder.stop())}function Kd(){!N.active||!N.mediaRecorder||(N.cancelled=!0,N.mediaRecorder.state==="recording"?N.mediaRecorder.stop():(gt(),H==null||H.onRequestRender()))}function Cy(){document.addEventListener("pointerup",zd)}function Oi(){document.removeEventListener("pointerup",zd)}function zd(e){if(!kt&&!N.active){Oi();return}if(kt=!1,Oi(),wt&&(clearTimeout(wt),wt=null,!N.active)){Ud("tap");return}N.active&&N.mode==="hold"&&(N.cancelled?Kd():Wd()),e.preventDefault()}function Ty(e){N.active||(kt=!0,N.startX=e.clientX,Cy(),wt=setTimeout(async()=>{if(!kt)return;await Ud("hold")||(kt=!1,Oi())},300))}function cl(e){if(!N.active||N.mode!=="hold"||!kt)return;const t=N.startX-e.clientX;t>80?(N.cancelled=!0,H==null||H.onRequestRender()):N.cancelled&&t<=60&&(N.cancelled=!1,H==null||H.onRequestRender())}function _y(){return N.active}function My(e){H=e}function Py(e){return u`
|
|
2553
2553
|
<button
|
|
2554
2554
|
class="btn btn--icon chat-compose__mic"
|
|
2555
2555
|
?disabled=${!e}
|
|
@@ -2560,7 +2560,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
2560
2560
|
${L.mic}
|
|
2561
2561
|
</button>
|
|
2562
2562
|
`}function Ly(){return N.active?N.mode==="tap"?u`
|
|
2563
|
-
<div class="chat-voice-recording" @pointermove=${
|
|
2563
|
+
<div class="chat-voice-recording" @pointermove=${cl}>
|
|
2564
2564
|
<button
|
|
2565
2565
|
class="btn btn--icon chat-voice-recording__trash"
|
|
2566
2566
|
@click=${Kd}
|
|
@@ -2571,7 +2571,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
2571
2571
|
</button>
|
|
2572
2572
|
<div class="chat-voice-recording__indicator">
|
|
2573
2573
|
<span class="chat-voice-recording__dot"></span>
|
|
2574
|
-
<span class="chat-voice-recording__timer">${
|
|
2574
|
+
<span class="chat-voice-recording__timer">${ll(N.elapsed)}</span>
|
|
2575
2575
|
</div>
|
|
2576
2576
|
<button
|
|
2577
2577
|
class="btn btn--icon chat-voice-recording__send primary"
|
|
@@ -2583,10 +2583,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
2583
2583
|
</button>
|
|
2584
2584
|
</div>
|
|
2585
2585
|
`:u`
|
|
2586
|
-
<div class="chat-voice-recording hold" @pointermove=${
|
|
2586
|
+
<div class="chat-voice-recording hold" @pointermove=${cl}>
|
|
2587
2587
|
<div class="chat-voice-recording__indicator">
|
|
2588
2588
|
<span class="chat-voice-recording__dot"></span>
|
|
2589
|
-
<span class="chat-voice-recording__timer">${
|
|
2589
|
+
<span class="chat-voice-recording__timer">${ll(N.elapsed)}</span>
|
|
2590
2590
|
<span class="chat-voice-recording__slide ${N.cancelled?"cancelled":""}">
|
|
2591
2591
|
${N.cancelled?"Release to cancel":"← Slide to cancel"}
|
|
2592
2592
|
</span>
|
|
@@ -2635,13 +2635,13 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
2635
2635
|
:host(.dragging) {
|
|
2636
2636
|
background: var(--accent, #007bff);
|
|
2637
2637
|
}
|
|
2638
|
-
`;ts([Vi({type:Number})],Vt.prototype,"splitRatio",2);ts([Vi({type:Number})],Vt.prototype,"minRatio",2);ts([Vi({type:Number})],Vt.prototype,"maxRatio",2);Vt=ts([Vl("resizable-divider")],Vt);function di(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function Ws(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const Ny=1,By=1,Lt="emoji",Gt="keyvalue",vr="favorites",Fy="tokens",Hd="tokens",Oy="unicode",qd="count",Uy="group",Wy="order",jd="group-order",ko="eTag",Ui="url",cl="skinTone",tn="readonly",br="readwrite",Vd="skinUnicodes",Ky="skinUnicodes",zy="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Hy="en";function qy(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 dl(e){return qy(e,t=>t.unicode)}function jy(e){function t(n,i,s){const o=i?e.createObjectStore(n,{keyPath:i}):e.createObjectStore(n);if(s)for(const[r,[a,d]]of Object.entries(s))o.createIndex(r,a,{multiEntry:d});return o}t(Gt),t(Lt,Oy,{[Hd]:[Fy,!0],[jd]:[[Uy,Wy]],[Vd]:[Ky,!0]}),t(vr,void 0,{[qd]:[""]})}const $o={},vi={},Wi={};function Gd(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function Vy(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,Ny);$o[e]=s,s.onupgradeneeded=o=>{o.oldVersion<By&&jy(s.result)},Gd(n,i,s)});return t.onclose=()=>wr(e),t}function Gy(e){return vi[e]||(vi[e]=Vy(e)),vi[e]}function Je(e,t,n,i){return new Promise((s,o)=>{const r=e.transaction(t,n,{durability:"relaxed"}),a=typeof t=="string"?r.objectStore(t):t.map(c=>r.objectStore(c));let d;i(a,r,c=>{d=c}),r.oncomplete=()=>s(d),r.onerror=()=>o(r.error)})}function wr(e){const t=$o[e],n=t&&t.result;if(n){n.close();const i=Wi[e];if(i)for(const s of i)s()}delete $o[e],delete vi[e],delete Wi[e]}function Qy(e){return new Promise((t,n)=>{wr(e);const i=indexedDB.deleteDatabase(e);Gd(t,n,i)})}function Jy(e,t){let n=Wi[e];n||(n=Wi[e]=[]),n.push(t)}const Yy=new Set([":D","XD",":'D","O:)",":X",":P",";P","XP",":L",":Z",":j","8D","XO","8)",":B",":O",":S",":'o","Dx","X(","D:",":C",">0)",":3","</3","<3","\\M/",":E","8#"]);function qt(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||Yy.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const Xy=2;function Qd(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=Xy)}function Zy(e){return e.map(({annotation:n,emoticon:i,group:s,order:o,shortcodes:r,skins:a,tags:d,emoji:c,version:l})=>{const p=[...new Set(Qd([...(r||[]).map(qt).flat(),...(d||[]).map(qt).flat(),...qt(n),i]))].sort(),f={annotation:n,group:s,order:o,tags:d,tokens:p,unicode:c,version:l};if(i&&(f.emoticon=i),r&&(f.shortcodes=r),a){f.skinTones=[],f.skinUnicodes=[],f.skinVersions=[];for(const{tone:v,emoji:S,version:h}of a)f.skinTones.push(v),f.skinUnicodes.push(S),f.skinVersions.push(h)}return f})}function Jd(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function Tt(e,t,n){Jd(e,"get",t,n)}function Yd(e,t,n){Jd(e,"getAll",t,n)}function kr(e){e.commit&&e.commit()}function ev(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 Xd(e,t){const n=ev(e,s=>s.length),i=[];for(const s of n)e.some(o=>o.findIndex(r=>t(r)===t(s))===-1)||i.push(s);return i}async function tv(e){return!await $r(e,Gt,Ui)}async function nv(e,t,n){const[i,s]=await Promise.all([ko,Ui].map(o=>$r(e,Gt,o)));return i===n&&s===t}async function iv(e,t){return Je(e,Lt,tn,(i,s,o)=>{let r;const a=()=>{i.getAll(r&&IDBKeyRange.lowerBound(r,!0),50).onsuccess=d=>{const c=d.target.result;for(const l of c)if(r=l.unicode,t(l))return o(l);if(c.length<50)return o();a()}};a()})}async function Zd(e,t,n,i){{const s=Zy(t);await Je(e,[Lt,Gt],br,([o,r],a)=>{let d,c,l=0;function p(){++l===2&&f()}function f(){if(!(d===i&&c===n)){o.clear();for(const v of s)o.put(v);r.put(i,ko),r.put(n,Ui),kr(a)}}Tt(r,ko,v=>{d=v,p()}),Tt(r,Ui,v=>{c=v,p()})})}}async function sv(e,t){return Je(e,Lt,tn,(n,i,s)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);Yd(n.index(jd),o,s)})}async function eu(e,t){const n=Qd(qt(t));return n.length?Je(e,Lt,tn,(i,s,o)=>{const r=[],a=()=>{r.length===n.length&&d()},d=()=>{const c=Xd(r,l=>l.unicode);o(c.sort((l,p)=>l.order<p.order?-1:1))};for(let c=0;c<n.length;c++){const l=n[c],p=c===n.length-1?IDBKeyRange.bound(l,l+"",!1,!0):IDBKeyRange.only(l);Yd(i.index(Hd),p,f=>{r.push(f),a()})}}):[]}async function ov(e,t){const n=await eu(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await iv(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function rv(e,t){return Je(e,Lt,tn,(n,i,s)=>Tt(n,t,o=>{if(o)return s(o);Tt(n.index(Vd),t,r=>s(r||null))}))}function $r(e,t,n){return Je(e,t,tn,(i,s,o)=>Tt(i,n,o))}function av(e,t,n,i){return Je(e,t,br,(s,o)=>{s.put(i,n),kr(o)})}function lv(e,t){return Je(e,vr,br,(n,i)=>Tt(n,t,s=>{n.put((s||0)+1,t),kr(i)}))}function cv(e,t,n){return n===0?[]:Je(e,[vr,Lt],tn,([i,s],o,r)=>{const a=[];i.index(qd).openCursor(void 0,"prev").onsuccess=d=>{const c=d.target.result;if(!c)return r(a);function l(v){if(a.push(v),a.length===n)return r(a);c.continue()}const p=c.primaryKey,f=t.byName(p);if(f)return l(f);Tt(s,p,v=>{if(v)return l(v);c.continue()})}})}const ui="";function dv(e,t){const n=new Map;for(const s of e){const o=t(s);for(const r of o){let a=n;for(let c=0;c<r.length;c++){const l=r.charAt(c);let p=a.get(l);p||(p=new Map,a.set(l,p)),a=p}let d=a.get(ui);d||(d=[],a.set(ui,d)),d.push(s)}}return(s,o)=>{let r=n;for(let c=0;c<s.length;c++){const l=s.charAt(c),p=r.get(l);if(p)r=p;else return[]}if(o)return r.get(ui)||[];const a=[],d=[r];for(;d.length;){const l=[...d.shift().entries()].sort((p,f)=>p[0]<f[0]?-1:1);for(const[p,f]of l)p===ui?a.push(...f):d.push(f)}return a}}const uv=["name","url"];function pv(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||uv.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function ul(e){pv(e);const t=(f,v)=>f.name.toLowerCase()<v.name.toLowerCase()?-1:1,n=e.sort(t),s=dv(e,f=>{const v=new Set;if(f.shortcodes)for(const S of f.shortcodes)for(const h of qt(S))v.add(h);return v}),o=f=>s(f,!0),r=f=>s(f,!1),a=f=>{const v=qt(f),S=v.map((h,b)=>(b<v.length-1?o:r)(h));return Xd(S,h=>h.name).sort(t)},d=new Map,c=new Map;for(const f of e){c.set(f.name.toLowerCase(),f);for(const v of f.shortcodes||[])d.set(v.toLowerCase(),f)}return{all:n,search:a,byShortcode:f=>d.get(f.toLowerCase()),byName:f=>c.get(f.toLowerCase())}}const hv=typeof wrappedJSObject<"u";function mn(e){if(!e)return e;if(hv&&(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 tu(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const fv=["annotation","emoji","group","order","version"];function gv(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||fv.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function nu(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function mv(e){const t=await fetch(e,{method:"HEAD"});nu(t,e);const n=t.headers.get("etag");return tu(n),n}async function So(e){const t=await fetch(e);nu(t,e);const n=t.headers.get("etag");tu(n);const i=await t.json();return gv(i),[n,i]}function yv(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function vv(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 iu(e){const t=JSON.stringify(e);let n=vv(t);const i=await crypto.subtle.digest("SHA-1",n),s=yv(i);return btoa(s)}async function bv(e,t){let n,i=await mv(t);if(!i){const s=await So(t);i=s[0],n=s[1],i||(i=await iu(n))}await nv(e,t,i)||(n||(n=(await So(t))[1]),await Zd(e,n,t,i))}async function wv(e,t){let[n,i]=await So(t);n||(n=await iu(i)),await Zd(e,i,t,n)}async function kv(e,t){try{await bv(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class $v{constructor({dataSource:t=zy,locale:n=Hy,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=ul(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await Gy(this._dbName);Jy(this._dbName,this._clear);const n=this.dataSource;await tv(t)?await wv(t,n):this._lazyUpdate=kv(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 Ws(t),await this.ready(),dl(await sv(this._db,t)).map(mn)}async getEmojiBySearchQuery(t){di(t),await this.ready();const n=this._custom.search(t),i=dl(await eu(this._db,t)).map(mn);return[...n,...i]}async getEmojiByShortcode(t){di(t),await this.ready();const n=this._custom.byShortcode(t);return n||mn(await ov(this._db,t))}async getEmojiByUnicodeOrName(t){di(t),await this.ready();const n=this._custom.byName(t);return n||mn(await rv(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await $r(this._db,Gt,cl)||0}async setPreferredSkinTone(t){return Ws(t),await this.ready(),av(this._db,Gt,cl,t)}async incrementFavoriteEmojiCount(t){return di(t),await this.ready(),lv(this._db,t)}async getTopFavoriteEmoji(t){return Ws(t),await this.ready(),(await cv(this._db,this._custom,t)).map(mn)}set customEmoji(t){this._custom=ul(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 wr(this._dbName)}async delete(){await this._shutdown(),await Qy(this._dbName)}}const xo=[[-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})),Ks=xo.slice(1),Sv=2,pl=6,su=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function hl(e){return e.unicode.includes("")}const xv={"":17,"":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱♀️":4,"🤣":3,"👁️🗨️":2,"😀":1,"😐️":.7,"😃":.6},Av=1e3,Ev="🖐️",Cv=8,Tv=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],ou='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',_v=(e,t)=>e<t?-1:e>t?1:0,fl=(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 ${ou}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},Mv=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function Pv(e){const t=fl(e,"#000"),n=fl(e,"#fff");return t&&n&&Mv(t,n)}function Lv(){const e=Object.entries(xv);try{for(const[t,n]of e)if(Pv(t))return n}catch{}return e[0][1]}let zs;const Hs=()=>(zs||(zs=new Promise(e=>su(()=>e(Lv())))),zs),Ao=new Map,Iv="️",Rv="\uD83C",Dv="",Nv=127995,Bv=57339;function Fv(e,t){if(t===0)return e;const n=e.indexOf(Dv);return n!==-1?e.substring(0,n)+String.fromCodePoint(Nv+t-1)+e.substring(n):(e.endsWith(Iv)&&(e=e.substring(0,e.length-1)),e+Rv+String.fromCodePoint(Bv+t-1))}function Pe(e){e.preventDefault(),e.stopPropagation()}function qs(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function ru(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 Ov(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:r,name:a,category:d,annotation:c})=>({unicode:i,name:a,shortcodes:o,url:r,category:d,annotation:c,id:i||a,skins:s&&n(s)}))}const bi=requestAnimationFrame;let Uv=typeof ResizeObserver=="function";function Wv(e,t,n){let i;Uv?(i=new ResizeObserver(n),i.observe(e)):bi(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function gl(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let js;function Kv(e,t,n){let i=!0,s=!1;for(const o of e){const r=n(o);if(!r)continue;const a=gl(r);a===0&&(s=!0),typeof js>"u"&&(js=gl(t));const d=a/1.8<js;Ao.set(o.unicode,d),d||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
|
|
2638
|
+
`;ts([Vi({type:Number})],Vt.prototype,"splitRatio",2);ts([Vi({type:Number})],Vt.prototype,"minRatio",2);ts([Vi({type:Number})],Vt.prototype,"maxRatio",2);Vt=ts([Gl("resizable-divider")],Vt);function di(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function Ws(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const Ny=1,By=1,Lt="emoji",Gt="keyvalue",br="favorites",Fy="tokens",Hd="tokens",Oy="unicode",qd="count",Uy="group",Wy="order",jd="group-order",$o="eTag",Ui="url",dl="skinTone",tn="readonly",wr="readwrite",Vd="skinUnicodes",Ky="skinUnicodes",zy="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Hy="en";function qy(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 ul(e){return qy(e,t=>t.unicode)}function jy(e){function t(n,i,s){const o=i?e.createObjectStore(n,{keyPath:i}):e.createObjectStore(n);if(s)for(const[r,[a,d]]of Object.entries(s))o.createIndex(r,a,{multiEntry:d});return o}t(Gt),t(Lt,Oy,{[Hd]:[Fy,!0],[jd]:[[Uy,Wy]],[Vd]:[Ky,!0]}),t(br,void 0,{[qd]:[""]})}const So={},vi={},Wi={};function Gd(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function Vy(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,Ny);So[e]=s,s.onupgradeneeded=o=>{o.oldVersion<By&&jy(s.result)},Gd(n,i,s)});return t.onclose=()=>kr(e),t}function Gy(e){return vi[e]||(vi[e]=Vy(e)),vi[e]}function Je(e,t,n,i){return new Promise((s,o)=>{const r=e.transaction(t,n,{durability:"relaxed"}),a=typeof t=="string"?r.objectStore(t):t.map(c=>r.objectStore(c));let d;i(a,r,c=>{d=c}),r.oncomplete=()=>s(d),r.onerror=()=>o(r.error)})}function kr(e){const t=So[e],n=t&&t.result;if(n){n.close();const i=Wi[e];if(i)for(const s of i)s()}delete So[e],delete vi[e],delete Wi[e]}function Qy(e){return new Promise((t,n)=>{kr(e);const i=indexedDB.deleteDatabase(e);Gd(t,n,i)})}function Jy(e,t){let n=Wi[e];n||(n=Wi[e]=[]),n.push(t)}const Yy=new Set([":D","XD",":'D","O:)",":X",":P",";P","XP",":L",":Z",":j","8D","XO","8)",":B",":O",":S",":'o","Dx","X(","D:",":C",">0)",":3","</3","<3","\\M/",":E","8#"]);function qt(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||Yy.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const Xy=2;function Qd(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=Xy)}function Zy(e){return e.map(({annotation:n,emoticon:i,group:s,order:o,shortcodes:r,skins:a,tags:d,emoji:c,version:l})=>{const p=[...new Set(Qd([...(r||[]).map(qt).flat(),...(d||[]).map(qt).flat(),...qt(n),i]))].sort(),h={annotation:n,group:s,order:o,tags:d,tokens:p,unicode:c,version:l};if(i&&(h.emoticon=i),r&&(h.shortcodes=r),a){h.skinTones=[],h.skinUnicodes=[],h.skinVersions=[];for(const{tone:v,emoji:S,version:f}of a)h.skinTones.push(v),h.skinUnicodes.push(S),h.skinVersions.push(f)}return h})}function Jd(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function Tt(e,t,n){Jd(e,"get",t,n)}function Yd(e,t,n){Jd(e,"getAll",t,n)}function $r(e){e.commit&&e.commit()}function ev(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 Xd(e,t){const n=ev(e,s=>s.length),i=[];for(const s of n)e.some(o=>o.findIndex(r=>t(r)===t(s))===-1)||i.push(s);return i}async function tv(e){return!await Sr(e,Gt,Ui)}async function nv(e,t,n){const[i,s]=await Promise.all([$o,Ui].map(o=>Sr(e,Gt,o)));return i===n&&s===t}async function iv(e,t){return Je(e,Lt,tn,(i,s,o)=>{let r;const a=()=>{i.getAll(r&&IDBKeyRange.lowerBound(r,!0),50).onsuccess=d=>{const c=d.target.result;for(const l of c)if(r=l.unicode,t(l))return o(l);if(c.length<50)return o();a()}};a()})}async function Zd(e,t,n,i){{const s=Zy(t);await Je(e,[Lt,Gt],wr,([o,r],a)=>{let d,c,l=0;function p(){++l===2&&h()}function h(){if(!(d===i&&c===n)){o.clear();for(const v of s)o.put(v);r.put(i,$o),r.put(n,Ui),$r(a)}}Tt(r,$o,v=>{d=v,p()}),Tt(r,Ui,v=>{c=v,p()})})}}async function sv(e,t){return Je(e,Lt,tn,(n,i,s)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);Yd(n.index(jd),o,s)})}async function eu(e,t){const n=Qd(qt(t));return n.length?Je(e,Lt,tn,(i,s,o)=>{const r=[],a=()=>{r.length===n.length&&d()},d=()=>{const c=Xd(r,l=>l.unicode);o(c.sort((l,p)=>l.order<p.order?-1:1))};for(let c=0;c<n.length;c++){const l=n[c],p=c===n.length-1?IDBKeyRange.bound(l,l+"",!1,!0):IDBKeyRange.only(l);Yd(i.index(Hd),p,h=>{r.push(h),a()})}}):[]}async function ov(e,t){const n=await eu(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await iv(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function rv(e,t){return Je(e,Lt,tn,(n,i,s)=>Tt(n,t,o=>{if(o)return s(o);Tt(n.index(Vd),t,r=>s(r||null))}))}function Sr(e,t,n){return Je(e,t,tn,(i,s,o)=>Tt(i,n,o))}function av(e,t,n,i){return Je(e,t,wr,(s,o)=>{s.put(i,n),$r(o)})}function lv(e,t){return Je(e,br,wr,(n,i)=>Tt(n,t,s=>{n.put((s||0)+1,t),$r(i)}))}function cv(e,t,n){return n===0?[]:Je(e,[br,Lt],tn,([i,s],o,r)=>{const a=[];i.index(qd).openCursor(void 0,"prev").onsuccess=d=>{const c=d.target.result;if(!c)return r(a);function l(v){if(a.push(v),a.length===n)return r(a);c.continue()}const p=c.primaryKey,h=t.byName(p);if(h)return l(h);Tt(s,p,v=>{if(v)return l(v);c.continue()})}})}const ui="";function dv(e,t){const n=new Map;for(const s of e){const o=t(s);for(const r of o){let a=n;for(let c=0;c<r.length;c++){const l=r.charAt(c);let p=a.get(l);p||(p=new Map,a.set(l,p)),a=p}let d=a.get(ui);d||(d=[],a.set(ui,d)),d.push(s)}}return(s,o)=>{let r=n;for(let c=0;c<s.length;c++){const l=s.charAt(c),p=r.get(l);if(p)r=p;else return[]}if(o)return r.get(ui)||[];const a=[],d=[r];for(;d.length;){const l=[...d.shift().entries()].sort((p,h)=>p[0]<h[0]?-1:1);for(const[p,h]of l)p===ui?a.push(...h):d.push(h)}return a}}const uv=["name","url"];function pv(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||uv.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function pl(e){pv(e);const t=(h,v)=>h.name.toLowerCase()<v.name.toLowerCase()?-1:1,n=e.sort(t),s=dv(e,h=>{const v=new Set;if(h.shortcodes)for(const S of h.shortcodes)for(const f of qt(S))v.add(f);return v}),o=h=>s(h,!0),r=h=>s(h,!1),a=h=>{const v=qt(h),S=v.map((f,w)=>(w<v.length-1?o:r)(f));return Xd(S,f=>f.name).sort(t)},d=new Map,c=new Map;for(const h of e){c.set(h.name.toLowerCase(),h);for(const v of h.shortcodes||[])d.set(v.toLowerCase(),h)}return{all:n,search:a,byShortcode:h=>d.get(h.toLowerCase()),byName:h=>c.get(h.toLowerCase())}}const hv=typeof wrappedJSObject<"u";function mn(e){if(!e)return e;if(hv&&(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 tu(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const fv=["annotation","emoji","group","order","version"];function gv(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||fv.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function nu(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function mv(e){const t=await fetch(e,{method:"HEAD"});nu(t,e);const n=t.headers.get("etag");return tu(n),n}async function xo(e){const t=await fetch(e);nu(t,e);const n=t.headers.get("etag");tu(n);const i=await t.json();return gv(i),[n,i]}function yv(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function vv(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 iu(e){const t=JSON.stringify(e);let n=vv(t);const i=await crypto.subtle.digest("SHA-1",n),s=yv(i);return btoa(s)}async function bv(e,t){let n,i=await mv(t);if(!i){const s=await xo(t);i=s[0],n=s[1],i||(i=await iu(n))}await nv(e,t,i)||(n||(n=(await xo(t))[1]),await Zd(e,n,t,i))}async function wv(e,t){let[n,i]=await xo(t);n||(n=await iu(i)),await Zd(e,i,t,n)}async function kv(e,t){try{await bv(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class $v{constructor({dataSource:t=zy,locale:n=Hy,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=pl(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await Gy(this._dbName);Jy(this._dbName,this._clear);const n=this.dataSource;await tv(t)?await wv(t,n):this._lazyUpdate=kv(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 Ws(t),await this.ready(),ul(await sv(this._db,t)).map(mn)}async getEmojiBySearchQuery(t){di(t),await this.ready();const n=this._custom.search(t),i=ul(await eu(this._db,t)).map(mn);return[...n,...i]}async getEmojiByShortcode(t){di(t),await this.ready();const n=this._custom.byShortcode(t);return n||mn(await ov(this._db,t))}async getEmojiByUnicodeOrName(t){di(t),await this.ready();const n=this._custom.byName(t);return n||mn(await rv(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Sr(this._db,Gt,dl)||0}async setPreferredSkinTone(t){return Ws(t),await this.ready(),av(this._db,Gt,dl,t)}async incrementFavoriteEmojiCount(t){return di(t),await this.ready(),lv(this._db,t)}async getTopFavoriteEmoji(t){return Ws(t),await this.ready(),(await cv(this._db,this._custom,t)).map(mn)}set customEmoji(t){this._custom=pl(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 kr(this._dbName)}async delete(){await this._shutdown(),await Qy(this._dbName)}}const Ao=[[-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})),Ks=Ao.slice(1),Sv=2,hl=6,su=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function fl(e){return e.unicode.includes("")}const xv={"":17,"":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱♀️":4,"🤣":3,"👁️🗨️":2,"😀":1,"😐️":.7,"😃":.6},Av=1e3,Ev="🖐️",Cv=8,Tv=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],ou='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',_v=(e,t)=>e<t?-1:e>t?1:0,gl=(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 ${ou}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},Mv=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function Pv(e){const t=gl(e,"#000"),n=gl(e,"#fff");return t&&n&&Mv(t,n)}function Lv(){const e=Object.entries(xv);try{for(const[t,n]of e)if(Pv(t))return n}catch{}return e[0][1]}let zs;const Hs=()=>(zs||(zs=new Promise(e=>su(()=>e(Lv())))),zs),Eo=new Map,Iv="️",Rv="\uD83C",Dv="",Nv=127995,Bv=57339;function Fv(e,t){if(t===0)return e;const n=e.indexOf(Dv);return n!==-1?e.substring(0,n)+String.fromCodePoint(Nv+t-1)+e.substring(n):(e.endsWith(Iv)&&(e=e.substring(0,e.length-1)),e+Rv+String.fromCodePoint(Bv+t-1))}function Pe(e){e.preventDefault(),e.stopPropagation()}function qs(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function ru(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 Ov(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:r,name:a,category:d,annotation:c})=>({unicode:i,name:a,shortcodes:o,url:r,category:d,annotation:c,id:i||a,skins:s&&n(s)}))}const bi=requestAnimationFrame;let Uv=typeof ResizeObserver=="function";function Wv(e,t,n){let i;Uv?(i=new ResizeObserver(n),i.observe(e)):bi(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function ml(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let js;function Kv(e,t,n){let i=!0,s=!1;for(const o of e){const r=n(o);if(!r)continue;const a=ml(r);a===0&&(s=!0),typeof js>"u"&&(js=ml(t));const d=a/1.8<js;Eo.set(o.unicode,d),d||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
|
|
2639
2639
|
This is likely due to using \`display:none\` which is unsupported.
|
|
2640
2640
|
If this is a Jest/Vitest environment, you can ignore this warning.
|
|
2641
|
-
For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function zv(e){return ru(e,t=>t)}function Hv(e){e&&(e.scrollTop=0)}function Tn(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function ml(e){return""+e}function qv(e){const t=document.createElement("template");return t.innerHTML=e,t}const jv=new WeakMap,Vv=new WeakMap,Gv=Symbol("un-keyed"),Qv="replaceChildren"in Element.prototype;function Jv(e,t){Qv?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function Yv(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 Xv(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=Yv(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&Jv(i,e)}function Zv(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:r,attributeValuePre:a,attributeValuePost:d}}=n,c=e[o];if(s!==c)if(n.currentExpression=c,r)if(c===null)i.removeAttribute(r);else{const l=a+ml(c)+d;i.setAttribute(r,l)}else{let l;Array.isArray(c)?Xv(c,n):c instanceof Element?(l=c,i.replaceWith(l)):i.nodeValue=ml(c),l&&(n.targetNode=l)}}}function eb(e){let t="",n=!1,i=!1,s=-1;const o=new Map,r=[];let a=0;for(let c=0,l=e.length;c<l;c++){const p=e[c];if(t+=p.slice(a),c===l-1)break;for(let x=0;x<p.length;x++)switch(p.charAt(x)){case"<":{p.charAt(x+1)==="/"?r.pop():(n=!0,r.push(++s));break}case">":{n=!1,i=!1;break}case"=":{i=!0;break}}const f=r[r.length-1],v=Tn(o,f,()=>[]);let S,h,b;if(i){const x=/(\S+)="?([^"=]*)$/.exec(p);S=x[1],h=x[2];const A=/^([^">]*)("?)/.exec(e[c+1]);b=A[1],t=t.slice(0,-1*x[0].length),a=A[0].length}else a=0;const w={attributeName:S,attributeValuePre:h,attributeValuePost:b,expressionIndex:c};v.push(w),!n&&!i&&(t+=" ")}return{template:qv(t),elementsToBindings:o}}function yl(e,t,n){for(let i=0;i<e.length;i++){const s=e[i],o=s.attributeName?t:t.firstChild,r={binding:s,targetNode:o,targetParentNode:void 0,currentExpression:void 0};n.push(r)}}function tb(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))yl(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,r=-1;do{const a=t.get(++r);a&&yl(a,o,n)}while(o=s.nextNode())}return n}function nb(e){const{template:t,elementsToBindings:n}=Tn(jv,e,()=>eb(e)),i=t.cloneNode(!0).content.firstElementChild,s=tb(i,n);return function(r){return Zv(r,s),i}}function ib(e){const t=Tn(Vv,e,()=>new Map);let n=Gv;function i(o,...r){const a=Tn(t,o,()=>new Map);return Tn(a,n,()=>nb(o))(r)}function s(o,r,a){return o.map((d,c)=>{const l=n;n=a(d);try{return r(d,c)}finally{n=l}})}return{map:s,html:i}}function sb(e,t,n,i,s,o,r,a,d){const{labelWithSkin:c,titleForEmoji:l,unicodeWithSkin:p}=n,{html:f,map:v}=ib(t);function S(x,A,C){return v(x,(P,_)=>f`<button role="${A?"option":"menuitem"}" aria-selected="${A?_===t.activeSearchItem:null}" aria-label="${c(P,t.currentSkinTone)}" title="${l(P)}" class="${"emoji"+(A&&_===t.activeSearchItem?" active":"")+(P.unicode?"":" custom-emoji")}" id="${`${C}-${P.id}`}" style="${P.unicode?null:`--custom-emoji-background: url(${JSON.stringify(P.url)})`}">${P.unicode?p(P,t.currentSkinTone):""}</button>`,P=>`${C}-${P.id}`)}const b=f`<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,(x,A)=>f`<div id="skintone-${A}" class="emoji ${A===t.activeSkinTone?"active":""}" aria-selected="${A===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[A]}" aria-label="${t.i18n.skinTones[A]}">${x}</div>`,x=>x)}</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,x=>f`<button role="tab" class="nav-button" aria-controls="tab-${x.id}" aria-label="${t.i18n.categories[x.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===x.id}" title="${t.i18n.categories[x.name]}" data-group-id="${x.id}"><div class="nav-emoji emoji">${x.emoji}</div></button>`,x=>x.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,(x,A)=>f`<div><div id="menu-label-${A}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:x.category?x.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${A!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(x.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${A}" id="${t.searchMode?"search-results":null}">${S(x.emojis,t.searchMode,"emo")}</div></div>`,x=>x.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${S(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,w=(x,A)=>{for(const C of e.querySelectorAll(`[${x}]`))A(C,C.getAttribute(x))};if(d){e.appendChild(b);for(const x of["click","focusout","input","keydown","keyup"])w(`data-on-${x}`,(A,C)=>{A.addEventListener(x,i[C])});w("data-ref",(x,A)=>{o[A]=x}),r.addEventListener("abort",()=>{e.removeChild(b)})}w("data-action",(x,A)=>{let C=a.get(A);C||a.set(A,C=new WeakSet),C.has(x)||(C.add(x),s[A](x))})}const Ki=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function ob(e){let t=!1,n;const i=new Map,s=new Set;let o;const r=()=>{if(t)return;const c=[...s];s.clear();try{for(const l of c)l()}finally{o=!1,s.size&&(o=!0,Ki(r))}},a=new Proxy({},{get(c,l){if(n){let p=i.get(l);p||(p=new Set,i.set(l,p)),p.add(n)}return c[l]},set(c,l,p){if(c[l]!==p){c[l]=p;const f=i.get(l);if(f){for(const v of f)s.add(v);o||(o=!0,Ki(r))}}return!0}}),d=c=>{const l=()=>{const p=n;n=l;try{return c()}finally{n=p}};return l()};return e.addEventListener("abort",()=>{t=!0}),{state:a,createEffect:d}}function Vs(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 vl=new WeakMap;function rb(e,t,n){{const i=e.closest(".tabpanel");let s=vl.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),vl.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const Gs=[],{assign:pi}=Object;function ab(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:r}=ob(s),a=new Map;pi(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),pi(o,t),pi(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:Cv,isRtl:!1,currentGroupIndex:0,groups:Ks,databaseLoaded:!1,activeSearchItemId:void 0}),r(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const d=E=>{e.getElementById(E).focus()},c=E=>e.getElementById(`emo-${E.id}`),l=(E,M)=>{n.rootElement.dispatchEvent(new CustomEvent(E,{detail:M,bubbles:!0,composed:!0}))},p=(E,M)=>E.id===M.id,f=(E,M)=>{const{category:F,emojis:O}=E,{category:J,emojis:V}=M;return F!==J?!1:Vs(O,V,p)},v=E=>{Vs(o.currentEmojis,E,p)||(o.currentEmojis=E)},S=E=>{o.searchMode!==E&&(o.searchMode=E)},h=E=>{Vs(o.currentEmojisWithCategories,E,f)||(o.currentEmojisWithCategories=E)},b=(E,M)=>M&&E.skins&&E.skins[M]||E.unicode,A={labelWithSkin:(E,M)=>zv([E.name||b(E,M),E.annotation,...E.shortcodes||Gs].filter(Boolean)).join(", "),titleForEmoji:E=>E.annotation||(E.shortcodes||Gs).join(", "),unicodeWithSkin:b},C={onClickSkinToneButton:Q,onEmojiClick:zn,onNavClick:Wn,onNavKeydown:as,onSearchKeydown:rs,onSkinToneOptionsClick:Hn,onSkinToneOptionsFocusOut:Ye,onSkinToneOptionsKeydown:ct,onSkinToneOptionsKeyup:nn,onSearchInput:qn},P={calculateEmojiGridStyle:z,updateOnIntersection:te};let _=!0;r(()=>{sb(e,o,A,C,P,n,s,a,_),_=!1}),o.emojiVersion||Hs().then(E=>{E||(o.message=o.i18n.emojiUnsupportedMessage)}),r(()=>{async function E(){let M=!1;const F=setTimeout(()=>{M=!0,o.message=o.i18n.loadingMessage},Av);try{await o.database.ready(),o.databaseLoaded=!0}catch(O){console.error(O),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(F),M&&(M=!1,o.message="")}}o.database&&E()}),r(()=>{o.pickerStyle=`
|
|
2641
|
+
For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function zv(e){return ru(e,t=>t)}function Hv(e){e&&(e.scrollTop=0)}function Tn(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function yl(e){return""+e}function qv(e){const t=document.createElement("template");return t.innerHTML=e,t}const jv=new WeakMap,Vv=new WeakMap,Gv=Symbol("un-keyed"),Qv="replaceChildren"in Element.prototype;function Jv(e,t){Qv?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function Yv(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 Xv(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=Yv(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&Jv(i,e)}function Zv(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:r,attributeValuePre:a,attributeValuePost:d}}=n,c=e[o];if(s!==c)if(n.currentExpression=c,r)if(c===null)i.removeAttribute(r);else{const l=a+yl(c)+d;i.setAttribute(r,l)}else{let l;Array.isArray(c)?Xv(c,n):c instanceof Element?(l=c,i.replaceWith(l)):i.nodeValue=yl(c),l&&(n.targetNode=l)}}}function eb(e){let t="",n=!1,i=!1,s=-1;const o=new Map,r=[];let a=0;for(let c=0,l=e.length;c<l;c++){const p=e[c];if(t+=p.slice(a),c===l-1)break;for(let x=0;x<p.length;x++)switch(p.charAt(x)){case"<":{p.charAt(x+1)==="/"?r.pop():(n=!0,r.push(++s));break}case">":{n=!1,i=!1;break}case"=":{i=!0;break}}const h=r[r.length-1],v=Tn(o,h,()=>[]);let S,f,w;if(i){const x=/(\S+)="?([^"=]*)$/.exec(p);S=x[1],f=x[2];const A=/^([^">]*)("?)/.exec(e[c+1]);w=A[1],t=t.slice(0,-1*x[0].length),a=A[0].length}else a=0;const b={attributeName:S,attributeValuePre:f,attributeValuePost:w,expressionIndex:c};v.push(b),!n&&!i&&(t+=" ")}return{template:qv(t),elementsToBindings:o}}function vl(e,t,n){for(let i=0;i<e.length;i++){const s=e[i],o=s.attributeName?t:t.firstChild,r={binding:s,targetNode:o,targetParentNode:void 0,currentExpression:void 0};n.push(r)}}function tb(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))vl(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,r=-1;do{const a=t.get(++r);a&&vl(a,o,n)}while(o=s.nextNode())}return n}function nb(e){const{template:t,elementsToBindings:n}=Tn(jv,e,()=>eb(e)),i=t.cloneNode(!0).content.firstElementChild,s=tb(i,n);return function(r){return Zv(r,s),i}}function ib(e){const t=Tn(Vv,e,()=>new Map);let n=Gv;function i(o,...r){const a=Tn(t,o,()=>new Map);return Tn(a,n,()=>nb(o))(r)}function s(o,r,a){return o.map((d,c)=>{const l=n;n=a(d);try{return r(d,c)}finally{n=l}})}return{map:s,html:i}}function sb(e,t,n,i,s,o,r,a,d){const{labelWithSkin:c,titleForEmoji:l,unicodeWithSkin:p}=n,{html:h,map:v}=ib(t);function S(x,A,C){return v(x,(M,_)=>h`<button role="${A?"option":"menuitem"}" aria-selected="${A?_===t.activeSearchItem:null}" aria-label="${c(M,t.currentSkinTone)}" title="${l(M)}" class="${"emoji"+(A&&_===t.activeSearchItem?" active":"")+(M.unicode?"":" custom-emoji")}" id="${`${C}-${M.id}`}" style="${M.unicode?null:`--custom-emoji-background: url(${JSON.stringify(M.url)})`}">${M.unicode?p(M,t.currentSkinTone):""}</button>`,M=>`${C}-${M.id}`)}const w=h`<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,(x,A)=>h`<div id="skintone-${A}" class="emoji ${A===t.activeSkinTone?"active":""}" aria-selected="${A===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[A]}" aria-label="${t.i18n.skinTones[A]}">${x}</div>`,x=>x)}</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,x=>h`<button role="tab" class="nav-button" aria-controls="tab-${x.id}" aria-label="${t.i18n.categories[x.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===x.id}" title="${t.i18n.categories[x.name]}" data-group-id="${x.id}"><div class="nav-emoji emoji">${x.emoji}</div></button>`,x=>x.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,(x,A)=>h`<div><div id="menu-label-${A}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:x.category?x.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${A!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(x.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${A}" id="${t.searchMode?"search-results":null}">${S(x.emojis,t.searchMode,"emo")}</div></div>`,x=>x.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${S(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,b=(x,A)=>{for(const C of e.querySelectorAll(`[${x}]`))A(C,C.getAttribute(x))};if(d){e.appendChild(w);for(const x of["click","focusout","input","keydown","keyup"])b(`data-on-${x}`,(A,C)=>{A.addEventListener(x,i[C])});b("data-ref",(x,A)=>{o[A]=x}),r.addEventListener("abort",()=>{e.removeChild(w)})}b("data-action",(x,A)=>{let C=a.get(A);C||a.set(A,C=new WeakSet),C.has(x)||(C.add(x),s[A](x))})}const Ki=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function ob(e){let t=!1,n;const i=new Map,s=new Set;let o;const r=()=>{if(t)return;const c=[...s];s.clear();try{for(const l of c)l()}finally{o=!1,s.size&&(o=!0,Ki(r))}},a=new Proxy({},{get(c,l){if(n){let p=i.get(l);p||(p=new Set,i.set(l,p)),p.add(n)}return c[l]},set(c,l,p){if(c[l]!==p){c[l]=p;const h=i.get(l);if(h){for(const v of h)s.add(v);o||(o=!0,Ki(r))}}return!0}}),d=c=>{const l=()=>{const p=n;n=l;try{return c()}finally{n=p}};return l()};return e.addEventListener("abort",()=>{t=!0}),{state:a,createEffect:d}}function Vs(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 bl=new WeakMap;function rb(e,t,n){{const i=e.closest(".tabpanel");let s=bl.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),bl.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const Gs=[],{assign:pi}=Object;function ab(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:r}=ob(s),a=new Map;pi(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),pi(o,t),pi(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:Cv,isRtl:!1,currentGroupIndex:0,groups:Ks,databaseLoaded:!1,activeSearchItemId:void 0}),r(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const d=E=>{e.getElementById(E).focus()},c=E=>e.getElementById(`emo-${E.id}`),l=(E,P)=>{n.rootElement.dispatchEvent(new CustomEvent(E,{detail:P,bubbles:!0,composed:!0}))},p=(E,P)=>E.id===P.id,h=(E,P)=>{const{category:F,emojis:O}=E,{category:J,emojis:V}=P;return F!==J?!1:Vs(O,V,p)},v=E=>{Vs(o.currentEmojis,E,p)||(o.currentEmojis=E)},S=E=>{o.searchMode!==E&&(o.searchMode=E)},f=E=>{Vs(o.currentEmojisWithCategories,E,h)||(o.currentEmojisWithCategories=E)},w=(E,P)=>P&&E.skins&&E.skins[P]||E.unicode,A={labelWithSkin:(E,P)=>zv([E.name||w(E,P),E.annotation,...E.shortcodes||Gs].filter(Boolean)).join(", "),titleForEmoji:E=>E.annotation||(E.shortcodes||Gs).join(", "),unicodeWithSkin:w},C={onClickSkinToneButton:Q,onEmojiClick:zn,onNavClick:Wn,onNavKeydown:as,onSearchKeydown:rs,onSkinToneOptionsClick:Hn,onSkinToneOptionsFocusOut:Ye,onSkinToneOptionsKeydown:ct,onSkinToneOptionsKeyup:nn,onSearchInput:qn},M={calculateEmojiGridStyle:z,updateOnIntersection:te};let _=!0;r(()=>{sb(e,o,A,C,M,n,s,a,_),_=!1}),o.emojiVersion||Hs().then(E=>{E||(o.message=o.i18n.emojiUnsupportedMessage)}),r(()=>{async function E(){let P=!1;const F=setTimeout(()=>{P=!0,o.message=o.i18n.loadingMessage},Av);try{await o.database.ready(),o.databaseLoaded=!0}catch(O){console.error(O),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(F),P&&(P=!1,o.message="")}}o.database&&E()}),r(()=>{o.pickerStyle=`
|
|
2642
2642
|
--num-groups: ${o.groups.length};
|
|
2643
2643
|
--indicator-opacity: ${o.searchMode?0:1};
|
|
2644
|
-
--num-skintones: ${pl};`}),r(()=>{o.customEmoji&&o.database&&B()}),r(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==xo&&(o.groups=xo):o.groups!==Ks&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=Ks)}),r(()=>{async function E(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}E()}),r(()=>{o.skinTones=Array(pl).fill().map((E,M)=>Fv(o.skinToneEmoji,M))}),r(()=>{o.skinToneButtonText=o.skinTones[o.currentSkinTone]}),r(()=>{o.skinToneButtonLabel=o.i18n.skinToneLabel.replace("{skinTone}",o.i18n.skinTones[o.currentSkinTone])}),r(()=>{async function E(){const{database:M}=o,F=(await Promise.all(Tv.map(O=>M.getEmojiByUnicodeOrName(O)))).filter(Boolean);o.defaultFavoriteEmojis=F}o.databaseLoaded&&E()});function B(){const{customEmoji:E,database:M}=o,F=E||Gs;M.customEmoji!==F&&(M.customEmoji=F)}r(()=>{async function E(){B();const{database:M,defaultFavoriteEmojis:F,numColumns:O}=o,J=await M.getTopFavoriteEmoji(O),V=await lt(ru([...J,...F],ue=>ue.unicode||ue.name).slice(0,O));o.currentFavorites=V}o.databaseLoaded&&o.defaultFavoriteEmojis&&E()});function z(E){Wv(E,s,()=>{{const M=getComputedStyle(n.rootElement),F=parseInt(M.getPropertyValue("--num-columns"),10),O=M.getPropertyValue("direction")==="rtl";o.numColumns=F,o.isRtl=O}})}function te(E){rb(E,s,M=>{for(const{target:F,isIntersecting:O}of M)F.classList.toggle("onscreen",O)})}r(()=>{async function E(){const{searchText:M,currentGroup:F,databaseLoaded:O,customEmoji:J}=o;if(!O)o.currentEmojis=[],o.searchMode=!1;else if(M.length>=Sv){const V=await os(M);o.searchText===M&&(v(V),S(!0))}else{const{id:V}=F;if(V!==-1||J&&J.length){const ue=await ss(V);o.currentGroup.id===V&&(v(ue),S(!1))}}}E()});const be=()=>{bi(()=>Hv(n.tabpanelElement))};r(()=>{const{currentEmojis:E,emojiVersion:M}=o,F=E.filter(O=>O.unicode).filter(O=>hl(O)&&!Ao.has(O.unicode));if(!M&&F.length)v(E),bi(()=>X(F));else{const O=M?E:E.filter(at);v(O),be()}});function X(E){Kv(E,n.baselineEmoji,c)?be():o.currentEmojis=[...o.currentEmojis]}function at(E){return!E.unicode||!hl(E)||Ao.get(E.unicode)}async function It(E){const M=o.emojiVersion||await Hs();return E.filter(({version:F})=>!F||F<=M)}async function lt(E){return Ov(E,o.emojiVersion||await Hs())}async function ss(E){const M=E===-1?o.customEmoji:await o.database.getEmojiByGroup(E);return lt(await It(M))}async function os(E){return lt(await It(await o.database.getEmojiBySearchQuery(E)))}r(()=>{}),r(()=>{function E(){const{searchMode:F,currentEmojis:O}=o;if(F)return[{category:"",emojis:O}];const J=new Map;for(const V of O){const ue=V.category||"";let Xe=J.get(ue);Xe||(Xe=[],J.set(ue,Xe)),Xe.push(V)}return[...J.entries()].map(([V,ue])=>({category:V,emojis:ue})).sort((V,ue)=>o.customCategorySorting(V.category,ue.category))}const M=E();h(M)}),r(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),r(()=>{const{rawSearchText:E}=o;su(()=>{o.searchText=(E||"").trim(),o.activeSearchItem=-1})});function rs(E){if(!o.searchMode||!o.currentEmojis.length)return;const M=F=>{Pe(E),o.activeSearchItem=qs(F,o.activeSearchItem,o.currentEmojis)};switch(E.key){case"ArrowDown":return M(!1);case"ArrowUp":return M(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return Pe(E),Z(o.currentEmojis[o.activeSearchItem].id)}}function Wn(E){const{target:M}=E,F=M.closest(".nav-button");if(!F)return;const O=parseInt(F.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(J=>J.id===O)}function as(E){const{target:M,key:F}=E,O=J=>{J&&(Pe(E),J.focus())};switch(F){case"ArrowLeft":return O(M.previousElementSibling);case"ArrowRight":return O(M.nextElementSibling);case"Home":return O(M.parentElement.firstElementChild);case"End":return O(M.parentElement.lastElementChild)}}async function Kn(E){const M=await o.database.getEmojiByUnicodeOrName(E),F=[...o.currentEmojis,...o.currentFavorites].find(J=>J.id===E),O=F.unicode&&b(F,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(E),{emoji:M,skinTone:o.currentSkinTone,...O&&{unicode:O},...F.name&&{name:F.name}}}async function Z(E){const M=Kn(E);l("emoji-click-sync",M),l("emoji-click",await M)}function zn(E){const{target:M}=E;if(!M.classList.contains("emoji"))return;Pe(E);const F=M.id.substring(4);Z(F)}function ee(E){o.currentSkinTone=E,o.skinTonePickerExpanded=!1,d("skintone-button"),l("skin-tone-change",{skinTone:E}),o.database.setPreferredSkinTone(E)}function Hn(E){const{target:{id:M}}=E,F=M&&M.match(/^skintone-(\d)/);if(!F)return;Pe(E);const O=parseInt(F[1],10);ee(O)}function Q(E){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(Pe(E),bi(()=>d("skintone-list")))}r(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function ct(E){if(!o.skinTonePickerExpanded)return;const M=async F=>{Pe(E),o.activeSkinTone=F};switch(E.key){case"ArrowUp":return M(qs(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return M(qs(!1,o.activeSkinTone,o.skinTones));case"Home":return M(0);case"End":return M(o.skinTones.length-1);case"Enter":return Pe(E),ee(o.activeSkinTone);case"Escape":return Pe(E),o.skinTonePickerExpanded=!1,d("skintone-button")}}function nn(E){if(o.skinTonePickerExpanded&&E.key===" ")return Pe(E),ee(o.activeSkinTone)}async function Ye(E){const{relatedTarget:M}=E;(!M||M.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function qn(E){o.rawSearchText=E.target.value}return{$set(E){pi(o,E)},$destroy(){i.abort()}}}const lb="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",cb="en";var db={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"}},ub=':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 au=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],pb=`:host{--emoji-font-family:${ou}}`;class Sr extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=ub+pb,this.shadowRoot.appendChild(n),this._ctx={locale:cb,dataSource:lb,skinToneEmoji:Ev,customCategorySorting:_v,customEmoji:null,i18n:db,emojiVersion:null,...t};for(const i of au)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){bl(this),this._cmp||(this._cmp=ab(this.shadowRoot,this._ctx))}disconnectedCallback(){bl(this),Ki(()=>{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 $v({locale:t,dataSource:n}))}_dbFlush(){Ki(()=>this._dbCreate())}}const lu={};for(const e of au)lu[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(Sr.prototype,lu);function bl(e){e instanceof Sr||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Sr);function hb(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 wl(e){e.style.height="44px",e.style.overflowY="hidden"}const fb=5e3;function gb(e){return e?e.active?u`
|
|
2644
|
+
--num-skintones: ${hl};`}),r(()=>{o.customEmoji&&o.database&&B()}),r(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==Ao&&(o.groups=Ao):o.groups!==Ks&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=Ks)}),r(()=>{async function E(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}E()}),r(()=>{o.skinTones=Array(hl).fill().map((E,P)=>Fv(o.skinToneEmoji,P))}),r(()=>{o.skinToneButtonText=o.skinTones[o.currentSkinTone]}),r(()=>{o.skinToneButtonLabel=o.i18n.skinToneLabel.replace("{skinTone}",o.i18n.skinTones[o.currentSkinTone])}),r(()=>{async function E(){const{database:P}=o,F=(await Promise.all(Tv.map(O=>P.getEmojiByUnicodeOrName(O)))).filter(Boolean);o.defaultFavoriteEmojis=F}o.databaseLoaded&&E()});function B(){const{customEmoji:E,database:P}=o,F=E||Gs;P.customEmoji!==F&&(P.customEmoji=F)}r(()=>{async function E(){B();const{database:P,defaultFavoriteEmojis:F,numColumns:O}=o,J=await P.getTopFavoriteEmoji(O),V=await lt(ru([...J,...F],ue=>ue.unicode||ue.name).slice(0,O));o.currentFavorites=V}o.databaseLoaded&&o.defaultFavoriteEmojis&&E()});function z(E){Wv(E,s,()=>{{const P=getComputedStyle(n.rootElement),F=parseInt(P.getPropertyValue("--num-columns"),10),O=P.getPropertyValue("direction")==="rtl";o.numColumns=F,o.isRtl=O}})}function te(E){rb(E,s,P=>{for(const{target:F,isIntersecting:O}of P)F.classList.toggle("onscreen",O)})}r(()=>{async function E(){const{searchText:P,currentGroup:F,databaseLoaded:O,customEmoji:J}=o;if(!O)o.currentEmojis=[],o.searchMode=!1;else if(P.length>=Sv){const V=await os(P);o.searchText===P&&(v(V),S(!0))}else{const{id:V}=F;if(V!==-1||J&&J.length){const ue=await ss(V);o.currentGroup.id===V&&(v(ue),S(!1))}}}E()});const be=()=>{bi(()=>Hv(n.tabpanelElement))};r(()=>{const{currentEmojis:E,emojiVersion:P}=o,F=E.filter(O=>O.unicode).filter(O=>fl(O)&&!Eo.has(O.unicode));if(!P&&F.length)v(E),bi(()=>X(F));else{const O=P?E:E.filter(at);v(O),be()}});function X(E){Kv(E,n.baselineEmoji,c)?be():o.currentEmojis=[...o.currentEmojis]}function at(E){return!E.unicode||!fl(E)||Eo.get(E.unicode)}async function It(E){const P=o.emojiVersion||await Hs();return E.filter(({version:F})=>!F||F<=P)}async function lt(E){return Ov(E,o.emojiVersion||await Hs())}async function ss(E){const P=E===-1?o.customEmoji:await o.database.getEmojiByGroup(E);return lt(await It(P))}async function os(E){return lt(await It(await o.database.getEmojiBySearchQuery(E)))}r(()=>{}),r(()=>{function E(){const{searchMode:F,currentEmojis:O}=o;if(F)return[{category:"",emojis:O}];const J=new Map;for(const V of O){const ue=V.category||"";let Xe=J.get(ue);Xe||(Xe=[],J.set(ue,Xe)),Xe.push(V)}return[...J.entries()].map(([V,ue])=>({category:V,emojis:ue})).sort((V,ue)=>o.customCategorySorting(V.category,ue.category))}const P=E();f(P)}),r(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),r(()=>{const{rawSearchText:E}=o;su(()=>{o.searchText=(E||"").trim(),o.activeSearchItem=-1})});function rs(E){if(!o.searchMode||!o.currentEmojis.length)return;const P=F=>{Pe(E),o.activeSearchItem=qs(F,o.activeSearchItem,o.currentEmojis)};switch(E.key){case"ArrowDown":return P(!1);case"ArrowUp":return P(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return Pe(E),Z(o.currentEmojis[o.activeSearchItem].id)}}function Wn(E){const{target:P}=E,F=P.closest(".nav-button");if(!F)return;const O=parseInt(F.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(J=>J.id===O)}function as(E){const{target:P,key:F}=E,O=J=>{J&&(Pe(E),J.focus())};switch(F){case"ArrowLeft":return O(P.previousElementSibling);case"ArrowRight":return O(P.nextElementSibling);case"Home":return O(P.parentElement.firstElementChild);case"End":return O(P.parentElement.lastElementChild)}}async function Kn(E){const P=await o.database.getEmojiByUnicodeOrName(E),F=[...o.currentEmojis,...o.currentFavorites].find(J=>J.id===E),O=F.unicode&&w(F,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(E),{emoji:P,skinTone:o.currentSkinTone,...O&&{unicode:O},...F.name&&{name:F.name}}}async function Z(E){const P=Kn(E);l("emoji-click-sync",P),l("emoji-click",await P)}function zn(E){const{target:P}=E;if(!P.classList.contains("emoji"))return;Pe(E);const F=P.id.substring(4);Z(F)}function ee(E){o.currentSkinTone=E,o.skinTonePickerExpanded=!1,d("skintone-button"),l("skin-tone-change",{skinTone:E}),o.database.setPreferredSkinTone(E)}function Hn(E){const{target:{id:P}}=E,F=P&&P.match(/^skintone-(\d)/);if(!F)return;Pe(E);const O=parseInt(F[1],10);ee(O)}function Q(E){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(Pe(E),bi(()=>d("skintone-list")))}r(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function ct(E){if(!o.skinTonePickerExpanded)return;const P=async F=>{Pe(E),o.activeSkinTone=F};switch(E.key){case"ArrowUp":return P(qs(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return P(qs(!1,o.activeSkinTone,o.skinTones));case"Home":return P(0);case"End":return P(o.skinTones.length-1);case"Enter":return Pe(E),ee(o.activeSkinTone);case"Escape":return Pe(E),o.skinTonePickerExpanded=!1,d("skintone-button")}}function nn(E){if(o.skinTonePickerExpanded&&E.key===" ")return Pe(E),ee(o.activeSkinTone)}async function Ye(E){const{relatedTarget:P}=E;(!P||P.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function qn(E){o.rawSearchText=E.target.value}return{$set(E){pi(o,E)},$destroy(){i.abort()}}}const lb="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",cb="en";var db={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"}},ub=':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 au=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],pb=`:host{--emoji-font-family:${ou}}`;class xr extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=ub+pb,this.shadowRoot.appendChild(n),this._ctx={locale:cb,dataSource:lb,skinToneEmoji:Ev,customCategorySorting:_v,customEmoji:null,i18n:db,emojiVersion:null,...t};for(const i of au)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){wl(this),this._cmp||(this._cmp=ab(this.shadowRoot,this._ctx))}disconnectedCallback(){wl(this),Ki(()=>{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 $v({locale:t,dataSource:n}))}_dbFlush(){Ki(()=>this._dbCreate())}}const lu={};for(const e of au)lu[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(xr.prototype,lu);function wl(e){e instanceof xr||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",xr);function hb(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 kl(e){e.style.height="44px",e.style.overflowY="hidden"}const fb=5e3;function gb(e){return e?e.active?u`
|
|
2645
2645
|
<div class="callout info compaction-indicator compaction-indicator--active">
|
|
2646
2646
|
${L.loader} Compacting context...
|
|
2647
2647
|
</div>
|
|
@@ -2649,7 +2649,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
|
|
|
2649
2649
|
<div class="callout success compaction-indicator compaction-indicator--complete">
|
|
2650
2650
|
${L.check} Context compacted
|
|
2651
2651
|
</div>
|
|
2652
|
-
`:k:k}const qe=5*1024*1024;function je(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Ee(e,t){var i,s,o;let n=(i=e.closest(".chat"))==null?void 0:i.querySelector(".chat-attachment-error");if(!n){n=document.createElement("div"),n.className="callout danger chat-attachment-error",n.style.cssText="margin: 8px 4px; animation: fade-in 200ms ease-out;";const r=(s=e.closest(".chat"))==null?void 0:s.querySelector(".chat-compose");(o=r==null?void 0:r.parentElement)==null||o.insertBefore(n,r)}n.textContent=t,setTimeout(()=>n==null?void 0:n.remove(),4e3)}const mb=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function cu(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function du(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||mb.test(e.name)}function uu(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function pu(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function yb(e,t){if(!t.onAttachmentsChange)return;const n=document.querySelector(".chat");if(cu(e)){if(e.size>qe){n&&Ee(n,`Image too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:je(),dataUrl:i.result,mimeType:e.type};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(du(e)){if(e.size>qe){n&&Ee(n,`File too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:je(),dataUrl:"",mimeType:e.type||"text/plain",fileName:e.name,textContent:i.result};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsText(e)}else if(uu(e)){if(e.size>qe){n&&Ee(n,`PDF too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:je(),dataUrl:i.result,mimeType:"application/pdf",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(pu(e)){if(e.size>qe){n&&Ee(n,`Video too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:je(),dataUrl:i.result,mimeType:e.type||"video/mp4",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else n&&Ee(n,`Unsupported file type: ${e.name}. Use the Files page to upload to workspace.`)}function vb(e,t){var s;e.preventDefault(),e.stopPropagation();const n=e.currentTarget;n.classList.remove("chat--dragover");const i=(s=e.dataTransfer)==null?void 0:s.files;if(!(!i||i.length===0))for(let o=0;o<i.length;o++){const r=i[o];if(cu(r)){if(!t.onAttachmentsChange)continue;if(r.size>qe){Ee(n,`Image too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const d=a.result,c={id:je(),dataUrl:d,mimeType:r.type},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsDataURL(r)}else if(du(r)){if(!t.onAttachmentsChange)continue;if(r.size>qe){Ee(n,`File too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const d=a.result,c={id:je(),dataUrl:"",mimeType:r.type||"text/plain",fileName:r.name,textContent:d},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsText(r)}else if(uu(r)){if(!t.onAttachmentsChange)continue;if(r.size>qe){Ee(n,`PDF too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const d=a.result,c={id:je(),dataUrl:d,mimeType:"application/pdf",fileName:r.name},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsDataURL(r)}else if(pu(r)){if(!t.onAttachmentsChange)continue;if(r.size>qe){Ee(n,`Video too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const d=a.result,c={id:je(),dataUrl:d,mimeType:r.type||"video/mp4",fileName:r.name},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsDataURL(r)}else Ee(n,`Unsupported file type: ${r.name}. Use the Files page to upload to workspace.`)}}function bb(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function wb(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function kb(e,t){var s,o,r;const n=(s=e.clipboardData)==null?void 0:s.items;if(!n||!t.onAttachmentsChange)return;const i=[];for(let a=0;a<n.length;a++){const d=n[a];(d.type.startsWith("image/")||d.type.startsWith("video/"))&&i.push(d)}if(i.length!==0){e.preventDefault();for(const a of i){const d=a.getAsFile();if(!d)continue;const c=d.type.startsWith("video/")?"Video":"Image";if(d.size>qe){const p=((r=(o=e.target)==null?void 0:o.closest)==null?void 0:r.call(o,".chat"))??document.querySelector(".chat");p&&Ee(p,`${c} too large (${(d.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const l=new FileReader;l.onload=()=>{var
|
|
2652
|
+
`:k:k}const qe=5*1024*1024;function je(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Ee(e,t){var i,s,o;let n=(i=e.closest(".chat"))==null?void 0:i.querySelector(".chat-attachment-error");if(!n){n=document.createElement("div"),n.className="callout danger chat-attachment-error",n.style.cssText="margin: 8px 4px; animation: fade-in 200ms ease-out;";const r=(s=e.closest(".chat"))==null?void 0:s.querySelector(".chat-compose");(o=r==null?void 0:r.parentElement)==null||o.insertBefore(n,r)}n.textContent=t,setTimeout(()=>n==null?void 0:n.remove(),4e3)}const mb=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function cu(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function du(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||mb.test(e.name)}function uu(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function pu(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function yb(e,t){if(!t.onAttachmentsChange)return;const n=document.querySelector(".chat");if(cu(e)){if(e.size>qe){n&&Ee(n,`Image too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:je(),dataUrl:i.result,mimeType:e.type};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(du(e)){if(e.size>qe){n&&Ee(n,`File too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:je(),dataUrl:"",mimeType:e.type||"text/plain",fileName:e.name,textContent:i.result};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsText(e)}else if(uu(e)){if(e.size>qe){n&&Ee(n,`PDF too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:je(),dataUrl:i.result,mimeType:"application/pdf",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(pu(e)){if(e.size>qe){n&&Ee(n,`Video too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:je(),dataUrl:i.result,mimeType:e.type||"video/mp4",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else n&&Ee(n,`Unsupported file type: ${e.name}. Use the Files page to upload to workspace.`)}function vb(e,t){var s;e.preventDefault(),e.stopPropagation();const n=e.currentTarget;n.classList.remove("chat--dragover");const i=(s=e.dataTransfer)==null?void 0:s.files;if(!(!i||i.length===0))for(let o=0;o<i.length;o++){const r=i[o];if(cu(r)){if(!t.onAttachmentsChange)continue;if(r.size>qe){Ee(n,`Image too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const d=a.result,c={id:je(),dataUrl:d,mimeType:r.type},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsDataURL(r)}else if(du(r)){if(!t.onAttachmentsChange)continue;if(r.size>qe){Ee(n,`File too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const d=a.result,c={id:je(),dataUrl:"",mimeType:r.type||"text/plain",fileName:r.name,textContent:d},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsText(r)}else if(uu(r)){if(!t.onAttachmentsChange)continue;if(r.size>qe){Ee(n,`PDF too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const d=a.result,c={id:je(),dataUrl:d,mimeType:"application/pdf",fileName:r.name},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsDataURL(r)}else if(pu(r)){if(!t.onAttachmentsChange)continue;if(r.size>qe){Ee(n,`Video too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const d=a.result,c={id:je(),dataUrl:d,mimeType:r.type||"video/mp4",fileName:r.name},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsDataURL(r)}else Ee(n,`Unsupported file type: ${r.name}. Use the Files page to upload to workspace.`)}}function bb(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function wb(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function kb(e,t){var s,o,r;const n=(s=e.clipboardData)==null?void 0:s.items;if(!n||!t.onAttachmentsChange)return;const i=[];for(let a=0;a<n.length;a++){const d=n[a];(d.type.startsWith("image/")||d.type.startsWith("video/"))&&i.push(d)}if(i.length!==0){e.preventDefault();for(const a of i){const d=a.getAsFile();if(!d)continue;const c=d.type.startsWith("video/")?"Video":"Image";if(d.size>qe){const p=((r=(o=e.target)==null?void 0:o.closest)==null?void 0:r.call(o,".chat"))??document.querySelector(".chat");p&&Ee(p,`${c} too large (${(d.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const l=new FileReader;l.onload=()=>{var f;const p=l.result,h=d.type.startsWith("video/"),v={id:je(),dataUrl:p,mimeType:d.type,fileName:h?d.name||"video.mp4":void 0},S=t.attachments??[];(f=t.onAttachmentsChange)==null||f.call(t,[...S,v])},l.readAsDataURL(d)}}}function $b(e){const t=e.currentTarget,n=t.closest(".chat-compose"),i=n==null?void 0:n.querySelector(".emoji-picker-popup");if(!i)return;const s=i.classList.toggle("active");if(t.classList.toggle("active",s),s){const o=r=>{i.contains(r.target)||t.contains(r.target)||(i.classList.remove("active"),t.classList.remove("active"),document.removeEventListener("click",o,!0))};requestAnimationFrame(()=>document.addEventListener("click",o,!0))}}function Sb(e,t){const n=e.detail,i=n==null?void 0:n.unicode;if(!i)return;const s=e.currentTarget.closest(".chat-compose"),o=s==null?void 0:s.querySelector("textarea");if(!o)return;const r=o.selectionStart??t.draft.length,a=o.selectionEnd??r,d=t.draft.slice(0,r),c=t.draft.slice(a);t.onDraftChange(d+i+c);const l=s==null?void 0:s.querySelector(".emoji-picker-popup"),p=s==null?void 0:s.querySelector(".chat-compose__emoji");l==null||l.classList.remove("active"),p==null||p.classList.remove("active"),requestAnimationFrame(()=>{o.focus();const h=r+i.length;o.setSelectionRange(h,h)})}function xb(e){const t=e.attachments??[];return t.length===0?k:u`
|
|
2653
2653
|
<div class="chat-attachments">
|
|
2654
2654
|
${t.map(n=>{var i;return n.fileName?u`
|
|
2655
2655
|
<div class="chat-attachment chat-attachment--file">
|
|
@@ -2682,7 +2682,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
|
|
|
2682
2682
|
</div>
|
|
2683
2683
|
`})}
|
|
2684
2684
|
</div>
|
|
2685
|
-
`}function hu(e){var S,
|
|
2685
|
+
`}function hu(e){var S,f,w;const t=e.connected,n=e.sending||e.stream!==null,i=!!(e.canAbort&&e.onAbort),s=(f=(S=e.sessions)==null?void 0:S.sessions)==null?void 0:f.find(b=>b.key===e.sessionKey),o=(s==null?void 0:s.reasoningLevel)??"off",r=e.showThinking&&o!=="off";e.assistantName,e.assistantAvatar??e.assistantAvatarUrl;const a=(((w=e.attachments)==null?void 0:w.length)??0)>0,d=e.connected?a?"Add a message...":"Message...":"Connecting…";My({onSend:b=>{e.onAttachmentsChange&&e.onAttachmentsChange([...e.attachments??[],b]),requestAnimationFrame(()=>e.onSend())},onRequestRender:()=>{var b;(b=e.requestUpdate)==null||b.call(e)}});const c=_y(),l=!c&&!e.draft.trim()&&!a&&!n,p=e.splitRatio??.6,h=!!(e.sidebarOpen&&e.onCloseSidebar),v=u`
|
|
2686
2686
|
<div
|
|
2687
2687
|
class="chat-thread"
|
|
2688
2688
|
role="log"
|
|
@@ -2693,12 +2693,12 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
|
|
|
2693
2693
|
${e.loadingOlder?u`<span class="chat-load-more__spinner">${L.loader}</span> Loading older messages…`:u`<button class="chat-load-more__btn" type="button" @click=${e.onLoadOlder}>Load older messages</button>`}
|
|
2694
2694
|
</div>`:k}
|
|
2695
2695
|
${e.loading?u`<div class="muted">Loading chat…</div>`:k}
|
|
2696
|
-
${Og(Pb(e),
|
|
2696
|
+
${Og(Pb(e),b=>b.key,b=>b.kind==="interim"?by(b.text):b.kind==="reading-indicator"?vy():b.kind==="stream"?wy(b.text,b.startedAt,e.onOpenSidebar):b.kind==="group"?ky(b,{onOpenSidebar:e.onOpenSidebar,showReasoning:r,assistantName:e.assistantName}):k)}
|
|
2697
2697
|
</div>
|
|
2698
2698
|
`;return u`
|
|
2699
2699
|
<section
|
|
2700
2700
|
class="card chat"
|
|
2701
|
-
@drop=${
|
|
2701
|
+
@drop=${b=>vb(b,e)}
|
|
2702
2702
|
@dragover=${bb}
|
|
2703
2703
|
@dragleave=${wb}
|
|
2704
2704
|
>
|
|
@@ -2721,18 +2721,18 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
|
|
|
2721
2721
|
`:k}
|
|
2722
2722
|
|
|
2723
2723
|
<div
|
|
2724
|
-
class="chat-split-container ${
|
|
2724
|
+
class="chat-split-container ${h?"chat-split-container--open":""}"
|
|
2725
2725
|
>
|
|
2726
2726
|
<div
|
|
2727
2727
|
class="chat-main"
|
|
2728
|
-
style="flex: ${
|
|
2728
|
+
style="flex: ${h?`0 0 ${p*100}%`:"1 1 100%"}"
|
|
2729
2729
|
>
|
|
2730
2730
|
${v}
|
|
2731
2731
|
${e.nearBottom===!1?u`
|
|
2732
2732
|
<button
|
|
2733
2733
|
class="chat-scroll-bottom"
|
|
2734
2734
|
type="button"
|
|
2735
|
-
@click=${
|
|
2735
|
+
@click=${b=>{const x=b.currentTarget.closest(".chat-main"),A=x==null?void 0:x.querySelector(".chat-thread");A&&A.scrollTo({top:A.scrollHeight,behavior:"smooth"})}}
|
|
2736
2736
|
aria-label="Scroll to bottom"
|
|
2737
2737
|
title="Scroll to bottom"
|
|
2738
2738
|
>
|
|
@@ -2741,10 +2741,10 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
|
|
|
2741
2741
|
`:k}
|
|
2742
2742
|
</div>
|
|
2743
2743
|
|
|
2744
|
-
${
|
|
2744
|
+
${h?u`
|
|
2745
2745
|
<resizable-divider
|
|
2746
2746
|
.splitRatio=${p}
|
|
2747
|
-
@resize=${
|
|
2747
|
+
@resize=${b=>{var x;return(x=e.onSplitRatioChange)==null?void 0:x.call(e,b.detail.splitRatio)}}
|
|
2748
2748
|
></resizable-divider>
|
|
2749
2749
|
<div class="chat-sidebar">
|
|
2750
2750
|
${Iy({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
|
|
@@ -2759,7 +2759,7 @@ ${e.sidebarContent}
|
|
|
2759
2759
|
<button
|
|
2760
2760
|
class="chat-suggestion-chip"
|
|
2761
2761
|
type="button"
|
|
2762
|
-
@click=${()=>{var
|
|
2762
|
+
@click=${()=>{var b;return(b=e.onSuggestionClick)==null?void 0:b.call(e,e.suggestion)}}
|
|
2763
2763
|
>
|
|
2764
2764
|
${e.suggestion}
|
|
2765
2765
|
</button>
|
|
@@ -2782,7 +2782,7 @@ ${e.sidebarContent}
|
|
|
2782
2782
|
<button
|
|
2783
2783
|
class="chat-compose__attach"
|
|
2784
2784
|
type="button"
|
|
2785
|
-
@click=${
|
|
2785
|
+
@click=${b=>{var A;const x=(A=b.currentTarget.closest(".chat-compose__row"))==null?void 0:A.querySelector(".chat-compose__file-input");x==null||x.click()}}
|
|
2786
2786
|
aria-label="Attach file"
|
|
2787
2787
|
title="Attach file"
|
|
2788
2788
|
>
|
|
@@ -2794,16 +2794,16 @@ ${e.sidebarContent}
|
|
|
2794
2794
|
multiple
|
|
2795
2795
|
accept="image/*,video/*,.pdf,.md,.txt,.csv,.json,.xml,.html,.css,.js,.ts,.py,.sh,.yaml,.yml,.toml,.ini,.cfg,.log,.sql"
|
|
2796
2796
|
style="display:none"
|
|
2797
|
-
@change=${
|
|
2797
|
+
@change=${b=>{const x=b.target,A=x.files;if(!(!A||A.length===0||!e.onAttachmentsChange)){for(let C=0;C<A.length;C++)yb(A[C],e);x.value=""}}}
|
|
2798
2798
|
/>
|
|
2799
2799
|
<label class="field chat-compose__field">
|
|
2800
2800
|
<span>Message</span>
|
|
2801
2801
|
<textarea
|
|
2802
2802
|
.value=${e.draft}
|
|
2803
2803
|
?disabled=${!e.connected}
|
|
2804
|
-
@keydown=${
|
|
2805
|
-
@input=${
|
|
2806
|
-
@paste=${
|
|
2804
|
+
@keydown=${b=>{b.key==="Enter"&&(b.isComposing||b.keyCode===229||b.shiftKey||e.connected&&(b.preventDefault(),t&&(e.onSend(),kl(b.target))))}}
|
|
2805
|
+
@input=${b=>{const x=b.target;e.onDraftChange(x.value),hb(x)}}
|
|
2806
|
+
@paste=${b=>kb(b,e)}
|
|
2807
2807
|
placeholder=${d}
|
|
2808
2808
|
></textarea>
|
|
2809
2809
|
</label>
|
|
@@ -2821,7 +2821,7 @@ ${e.sidebarContent}
|
|
|
2821
2821
|
<button
|
|
2822
2822
|
class="btn btn--icon chat-compose__send primary"
|
|
2823
2823
|
?disabled=${!e.connected}
|
|
2824
|
-
@click=${
|
|
2824
|
+
@click=${b=>{var A;e.onSend();const x=(A=b.target.closest(".chat-compose"))==null?void 0:A.querySelector("textarea");x&&kl(x)}}
|
|
2825
2825
|
aria-label="${n?"Queue":"Send"}"
|
|
2826
2826
|
title="${n?"Queue message":"Send (Enter)"}"
|
|
2827
2827
|
>
|
|
@@ -2830,7 +2830,7 @@ ${e.sidebarContent}
|
|
|
2830
2830
|
</div>`}
|
|
2831
2831
|
<div class="emoji-picker-popup">
|
|
2832
2832
|
<emoji-picker
|
|
2833
|
-
@emoji-click=${
|
|
2833
|
+
@emoji-click=${b=>Sb(b,e)}
|
|
2834
2834
|
></emoji-picker>
|
|
2835
2835
|
</div>
|
|
2836
2836
|
${e.publicMode?k:_b(e)}
|
|
@@ -2894,7 +2894,7 @@ ${e.sidebarContent}
|
|
|
2894
2894
|
</label>
|
|
2895
2895
|
</div>
|
|
2896
2896
|
</div>
|
|
2897
|
-
`}function Mb(e){const t=[];let n=null;for(const i of e){if(i.kind!=="message"){n&&(t.push(n),n=null),t.push(i);continue}const s=
|
|
2897
|
+
`}function Mb(e){const t=[];let n=null;for(const i of e){if(i.kind!=="message"){n&&(t.push(n),n=null),t.push(i);continue}const s=sc(i.message),o=oc(s.role),r=s.timestamp||Date.now();!n||n.role!==o?(n&&t.push(n),n={kind:"group",key:`group:${o}:${i.key}`,role:o,messages:[{message:i.message,key:i.key}],timestamp:r,isStreaming:!1}):n.messages.push({message:i.message,key:i.key})}return n&&t.push(n),t}function Pb(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 r=0;r<n.length;r++){const a=n[r],d=sc(a);if(!s&&d.role.toLowerCase()==="toolresult"){const c=a,p=(Array.isArray(c.content)?c.content:[]).filter(h=>{const v=h.type;return v==="image"||v==="file"});p.length>0&&t.push({kind:"message",key:Qs(a,r),message:{role:"assistant",content:p,timestamp:d.timestamp}});continue}t.push({kind:"message",key:Qs(a,r),message:a})}if(s)for(let r=0;r<i.length;r++)t.push({kind:"message",key:Qs(i[r],r+n.length),message:i[r]});if(e.interimText&&t.push({kind:"interim",key:"interim:thinking",text:e.interimText}),e.stream!==null){const r=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:r,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:r})}for(const r of e.queue){const a=((o=r.attachments)==null?void 0:o.filter(c=>c.fileName).map(c=>c.fileName))??[],d=a.length>0?r.text?`${a.join(", ")}
|
|
2898
2898
|
|
|
2899
2899
|
${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,message:{role:"user",content:[{type:"text",text:d}],timestamp:r.createdAt}})}return Mb(t)}function Qs(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 r=typeof n.timestamp=="number"?n.timestamp:null,a=typeof n.role=="string"?n.role:"unknown";return r!=null?`msg:${a}:${r}:${t}`:`msg:${a}:${t}`}const Lb=u`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>`;function Ib(e){if(!e.connected)return u`
|
|
2900
2900
|
<div class="setup-container">
|
|
@@ -2917,7 +2917,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2917
2917
|
${hu(e)}
|
|
2918
2918
|
</div>
|
|
2919
2919
|
</div>
|
|
2920
|
-
`}function Rb(e){return e?`${
|
|
2920
|
+
`}function Rb(e){return e?`${ec(e)} (${Gi(e)})`:"n/a"}function fu(e){const t=e.state??{},n=t.lastStatus??"n/a",i=t.lastRunAtMs?Gi(t.lastRunAtMs):"never";return`${n} · last ${i}`}function gu(e){const t=e.schedule;return t.kind==="at"?`One-time: ${ec(t.atMs)}`:t.kind==="every"?`Every ${Bo(t.everyMs)}`:Db(t.expr,t.tz)}function Db(e,t){const n=e.trim().split(/\s+/);if(n.length!==5)return e;const[i,s,o,r,a]=n,d=t?` (${t.replace(/^.*\//,"").replace(/_/g," ")})`:"",c=(f,w)=>new Date(2e3,0,1,f,w).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),l=/^\d{1,2}$/.test(i)?parseInt(i,10):null,p=$l(s);if(l===null||!p)return`${e}${t?` (${t})`:""}`;const h=p.map(f=>c(f,l)),v=h.length<=3?h.join(" & "):`${h.slice(0,-1).join(", ")} & ${h[h.length-1]}`,S=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];if(o==="*"&&r==="*"){if(a==="*")return`Daily at ${v}${d}`;if(a==="1-5")return`Weekdays at ${v}${d}`;if(a==="0,6"||a==="6,0")return`Weekends at ${v}${d}`;const f=$l(a);if(f)return`${f.map(b=>S[b%7]??String(b)).join(", ")} at ${v}${d}`}return`${e}${t?` (${t})`:""}`}function $l(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 Nb(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 Sl(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 r=i.split(",").map(a=>a.trim()).filter(Boolean).map(a=>a.toLowerCase()==="admins"?"All admins":a);s.push(r.join(", "))}return n&&n!=="last"&&s.push(`via ${n}`),s.join(" ")||null}let ve=null;function Bb(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 Fb(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 Ob(e){return e.split(",").map(n=>n.trim()).filter(Boolean).map(n=>n.toLowerCase()==="admins"?"All admins":n).join(", ")}function Ub(e){return e||"Default"}const Wb=u`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,Kb=u`<svg viewBox="0 0 24 24"><rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/></svg>`,zb=u`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,ns=u`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,Hb=u`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,mu=u`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`,qb=u`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`;function xl(e){const t=e.detailJobId?e.jobs.find(i=>i.id===e.detailJobId)??null:null,n=e.newEventModalOpen||!!e.editJobId;return u`
|
|
2921
2921
|
${jb(e)}
|
|
2922
2922
|
${Vb(e)}
|
|
2923
2923
|
${n?Qb(e):k}
|
|
@@ -2965,7 +2965,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2965
2965
|
</div>
|
|
2966
2966
|
<div class="event-card__schedule">${gu(e)}</div>
|
|
2967
2967
|
${e.agentId?u`<div class="event-card__agent">${Ub(e.agentId)}</div>`:k}
|
|
2968
|
-
${
|
|
2968
|
+
${Sl(e)?u`<div class="event-card__agent muted" style="font-size: 11px;">\u2192 ${Sl(e)}</div>`:k}
|
|
2969
2969
|
<div class="event-card__footer">
|
|
2970
2970
|
<div class="event-card__status">
|
|
2971
2971
|
<span class="muted" style="font-size: 11px;">${fu(e)}</span>
|
|
@@ -3393,7 +3393,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3393
3393
|
>
|
|
3394
3394
|
${i}
|
|
3395
3395
|
</span>
|
|
3396
|
-
${t.durationMs!=null?u`<span class="muted" style="font-size: 13px;">${
|
|
3396
|
+
${t.durationMs!=null?u`<span class="muted" style="font-size: 13px;">${Bo(t.durationMs)}</span>`:k}
|
|
3397
3397
|
</div>
|
|
3398
3398
|
${t.summary?u`
|
|
3399
3399
|
<div style="white-space: pre-wrap; font-size: 13px; line-height: 1.6; max-height: 400px; overflow-y: auto; color: var(--fg);">
|
|
@@ -3421,7 +3421,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3421
3421
|
${e.status}
|
|
3422
3422
|
</span>
|
|
3423
3423
|
<span class="muted" style="font-size: 12px;">${Gi(e.ts)}</span>
|
|
3424
|
-
<span class="muted" style="font-size: 12px;">${
|
|
3424
|
+
<span class="muted" style="font-size: 12px;">${Bo(e.durationMs)}</span>
|
|
3425
3425
|
</div>
|
|
3426
3426
|
${e.summary?u`<div class="muted" style="font-size: 12px;">${e.summary}</div>`:k}
|
|
3427
3427
|
${e.error?u`
|
|
@@ -3694,7 +3694,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3694
3694
|
</div>
|
|
3695
3695
|
`)}
|
|
3696
3696
|
</div>
|
|
3697
|
-
`}const lw=["user","assistant","tool_call","tool_result","thinking","error"],
|
|
3697
|
+
`}const lw=["user","assistant","tool_call","tool_result","thinking","error"],Al={user:"User",assistant:"Assistant",tool:"Tool",tool_call:"Call",tool_result:"Result",thinking:"Thinking",error:"Error",system:"System"};function yu(e){return e==="tool"?"tool_call":e}function cw(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 dw(e){return e.split(":").slice(2).join(":")||e}function uw(e,t){return t?[e.content,e.agentId,e.sessionKey,e.sessionId,e.toolName,e.toolCallId].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function pw(e,t){return`${e.sessionId}:${e.timestamp}:${t}`}const El=300;function hw(e,t){const n=yu(e);return t[n]??!0}function fw(e){const t=e.filterText.trim().toLowerCase(),n=e.entries.filter(i=>!hw(i.type,e.typeFilters)||e.agents.length>0&&!(e.agentFilters[i.agentId]??!0)?!1:uw(i,t));return u`
|
|
3698
3698
|
<div>
|
|
3699
3699
|
<button class="chips-toggle" style="margin-top: 10px;" @click=${e.onToggleChips}>
|
|
3700
3700
|
<span class="chips-toggle-icon ${e.chipsExpanded?"expanded":""}">${L.chevronDown}</span>
|
|
@@ -3709,7 +3709,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3709
3709
|
.checked=${e.typeFilters[i]}
|
|
3710
3710
|
@change=${s=>e.onTypeToggle(i,s.target.checked)}
|
|
3711
3711
|
/>
|
|
3712
|
-
<span>${
|
|
3712
|
+
<span>${Al[i]}</span>
|
|
3713
3713
|
</label>
|
|
3714
3714
|
`)}
|
|
3715
3715
|
${e.agents.map(i=>u`
|
|
@@ -3736,11 +3736,11 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3736
3736
|
${e.error?u`<div class="callout danger" style="margin-top: 10px;">${e.error}</div>`:k}
|
|
3737
3737
|
|
|
3738
3738
|
<div class="log-stream" style="margin-top: 10px;" @scroll=${e.onScroll}>
|
|
3739
|
-
${n.length===0?u`<div class="muted" style="padding: 12px;">No session log entries.</div>`:n.map((i,s)=>{const o=yu(i.type),r=pw(i,s),a=e.expandedIds.has(r),d=i.content.length>
|
|
3739
|
+
${n.length===0?u`<div class="muted" style="padding: 12px;">No session log entries.</div>`:n.map((i,s)=>{const o=yu(i.type),r=pw(i,s),a=e.expandedIds.has(r),d=i.content.length>El,c=a||!d?i.content:i.content.slice(0,El)+"…";return u`
|
|
3740
3740
|
<div class="log-row session-entry ${o}">
|
|
3741
3741
|
<div class="log-row-header">
|
|
3742
3742
|
<span class="log-time mono">${cw(i.timestamp)}</span>
|
|
3743
|
-
<span class="session-log-type ${o}">${
|
|
3743
|
+
<span class="session-log-type ${o}">${Al[o]}</span>
|
|
3744
3744
|
<span class="log-subsystem mono">${i.agentId}</span>
|
|
3745
3745
|
<span class="session-label mono">${dw(i.sessionKey)}</span>
|
|
3746
3746
|
${i.toolName?u`<span class="session-tool mono">${i.toolName}</span>`:k}
|
|
@@ -3756,7 +3756,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3756
3756
|
`})}
|
|
3757
3757
|
</div>
|
|
3758
3758
|
</div>
|
|
3759
|
-
`}const
|
|
3759
|
+
`}const Co=["trace","debug","info","warn","error","fatal"];function gw(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function vu(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function mw(e){const t=e.logsSubTab==="session";return u`
|
|
3760
3760
|
<section class="card">
|
|
3761
3761
|
<div class="logs-toolbar">
|
|
3762
3762
|
<div class="sp-tabs" style="margin: 0;">
|
|
@@ -3805,7 +3805,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3805
3805
|
<button
|
|
3806
3806
|
class="btn btn-sm"
|
|
3807
3807
|
?disabled=${e.entries.length===0}
|
|
3808
|
-
@click=${()=>{const n=e.filterText.trim().toLowerCase(),i=
|
|
3808
|
+
@click=${()=>{const n=e.filterText.trim().toLowerCase(),i=Co.some(r=>!e.levelFilters[r]),s=e.entries.filter(r=>r.level&&!e.levelFilters[r.level]?!1:vu(r,n)),o=n||i?"filtered":"visible";e.onExport(s.map(r=>r.raw),o)}}
|
|
3809
3809
|
>
|
|
3810
3810
|
Export
|
|
3811
3811
|
</button>
|
|
@@ -3815,14 +3815,14 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3815
3815
|
|
|
3816
3816
|
${t?fw(e.sessionLogsProps):yw(e)}
|
|
3817
3817
|
</section>
|
|
3818
|
-
`}function yw(e){const t=e.filterText.trim().toLowerCase();
|
|
3818
|
+
`}function yw(e){const t=e.filterText.trim().toLowerCase();Co.some(i=>!e.levelFilters[i]);const n=e.entries.filter(i=>i.level&&!e.levelFilters[i.level]?!1:vu(i,t));return u`
|
|
3819
3819
|
<button class="chips-toggle" @click=${e.onToggleChips}>
|
|
3820
3820
|
<span class="chips-toggle-icon ${e.chipsExpanded?"expanded":""}">${L.chevronDown}</span>
|
|
3821
3821
|
Filters
|
|
3822
3822
|
</button>
|
|
3823
3823
|
${e.chipsExpanded?u`
|
|
3824
3824
|
<div class="chip-row" style="margin-top: 6px; align-items: center;">
|
|
3825
|
-
${
|
|
3825
|
+
${Co.map(i=>u`
|
|
3826
3826
|
<label class="chip log-chip ${i}">
|
|
3827
3827
|
<input
|
|
3828
3828
|
type="checkbox"
|
|
@@ -3861,7 +3861,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3861
3861
|
</div>
|
|
3862
3862
|
`)}
|
|
3863
3863
|
</div>
|
|
3864
|
-
`}const vw=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"logs",label:"Logs"}];function bw(e){switch(e.activeTab){case"cron":return
|
|
3864
|
+
`}const vw=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"logs",label:"Logs"}];function bw(e){switch(e.activeTab){case"cron":return xl(e.cronProps);case"skills":return nw(e.skillsProps);case"logs":return mw(e.logsProps);default:return xl(e.cronProps)}}function ww(e){return e.connected?u`
|
|
3865
3865
|
<div class="setup-container">
|
|
3866
3866
|
${Mt("Advanced",e.wsProps)}
|
|
3867
3867
|
<div class="setup-card sp-card-advanced" style="text-align: left;">
|
|
@@ -3885,7 +3885,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3885
3885
|
<p>Connecting to gateway...</p>
|
|
3886
3886
|
</div>
|
|
3887
3887
|
</div>
|
|
3888
|
-
`}function
|
|
3888
|
+
`}function Cl(e){if(!e.show)return k;const t=Ve(),n=e.isFirstTime,i=e.changePinMode===!0&&!n,s=e.changePinBusy===!0;let o=e.accounts.length>0?e.accounts[0].id:"";const r=v=>{var f;o=v.target.value;const S=(f=v.target.closest(".login-card"))==null?void 0:f.querySelector(".login-change-pin");S&&(S.style.display=o==="__master__"?"":"none")},a=v=>S=>{const f=S.target;f.value=f.value.replace(/\D/g,"").slice(0,6),v(f.value)},d=v=>{const S=v.currentTarget,f=S.closest(".login-pin-wrapper"),w=f==null?void 0:f.querySelector("input");if(!w)return;const b=w.type==="text";w.type=b?"password":"text",S.classList.toggle("active",!b)},c=!n&&e.accounts.length>1?u`
|
|
3889
3889
|
<select
|
|
3890
3890
|
class="login-account-select"
|
|
3891
3891
|
@change=${r}
|
|
@@ -3897,13 +3897,13 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3897
3897
|
</option>
|
|
3898
3898
|
`)}
|
|
3899
3899
|
</select>
|
|
3900
|
-
`:k;if(i){let v="",S="",
|
|
3900
|
+
`:k;if(i){let v="",S="",f="";const w=b=>{var x;b.preventDefault(),!s&&(!v||!S||!f||S===f&&o&&((x=e.onChangePin)==null||x.call(e,o,v,S)))};return u`
|
|
3901
3901
|
<div class="login-overlay">
|
|
3902
3902
|
<div class="login-card">
|
|
3903
3903
|
<img class="login-logo" src="${t.iconUrl}" alt="${t.name}" />
|
|
3904
3904
|
<h2 class="login-title">Change PIN</h2>
|
|
3905
3905
|
<p class="login-subtitle">Enter your current PIN, then choose a new one</p>
|
|
3906
|
-
<form class="login-form" @submit=${
|
|
3906
|
+
<form class="login-form" @submit=${w}>
|
|
3907
3907
|
${c}
|
|
3908
3908
|
<div class="login-pin-wrapper">
|
|
3909
3909
|
<input
|
|
@@ -3915,7 +3915,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3915
3915
|
maxlength="6"
|
|
3916
3916
|
placeholder="Current PIN"
|
|
3917
3917
|
?disabled=${s}
|
|
3918
|
-
@input=${a(
|
|
3918
|
+
@input=${a(b=>{v=b})}
|
|
3919
3919
|
autofocus
|
|
3920
3920
|
/>
|
|
3921
3921
|
<button class="login-pin-toggle" type="button" @click=${d}>
|
|
@@ -3933,7 +3933,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3933
3933
|
maxlength="6"
|
|
3934
3934
|
placeholder="New PIN (4-6 digits)"
|
|
3935
3935
|
?disabled=${s}
|
|
3936
|
-
@input=${a(
|
|
3936
|
+
@input=${a(b=>{S=b})}
|
|
3937
3937
|
/>
|
|
3938
3938
|
<button class="login-pin-toggle" type="button" @click=${d}>
|
|
3939
3939
|
<span class="pin-eye-show">${L.eye}</span>
|
|
@@ -3950,7 +3950,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3950
3950
|
maxlength="6"
|
|
3951
3951
|
placeholder="Confirm new PIN"
|
|
3952
3952
|
?disabled=${s}
|
|
3953
|
-
@input=${a(
|
|
3953
|
+
@input=${a(b=>{f=b})}
|
|
3954
3954
|
/>
|
|
3955
3955
|
<button class="login-pin-toggle" type="button" @click=${d}>
|
|
3956
3956
|
<span class="pin-eye-show">${L.eye}</span>
|
|
@@ -3969,12 +3969,12 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3969
3969
|
<a
|
|
3970
3970
|
class="login-link"
|
|
3971
3971
|
href="#"
|
|
3972
|
-
@click=${
|
|
3972
|
+
@click=${b=>{var x;b.preventDefault(),(x=e.onToggleChangePinMode)==null||x.call(e)}}
|
|
3973
3973
|
>Back to login</a>
|
|
3974
3974
|
</p>
|
|
3975
3975
|
</div>
|
|
3976
3976
|
</div>
|
|
3977
|
-
`}let l="",p="";const
|
|
3977
|
+
`}let l="",p="";const h=v=>{if(v.preventDefault(),!e.busy)if(n){if(!l||!p||l!==p)return;e.onSubmit(l)}else{if(!l||!o)return;e.onSubmit(o,l)}};return u`
|
|
3978
3978
|
<div class="login-overlay">
|
|
3979
3979
|
<div class="login-card">
|
|
3980
3980
|
<img class="login-logo" src="${t.iconUrl}" alt="${t.name}" />
|
|
@@ -3982,7 +3982,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3982
3982
|
<p class="login-subtitle">
|
|
3983
3983
|
${n?"Set a PIN to protect this device":"Enter your PIN to continue"}
|
|
3984
3984
|
</p>
|
|
3985
|
-
<form class="login-form" @submit=${
|
|
3985
|
+
<form class="login-form" @submit=${h}>
|
|
3986
3986
|
${c}
|
|
3987
3987
|
<div class="login-pin-wrapper">
|
|
3988
3988
|
<input
|
|
@@ -4055,7 +4055,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
4055
4055
|
${hu(t)}
|
|
4056
4056
|
</div>
|
|
4057
4057
|
</div>
|
|
4058
|
-
`}async function $w(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 Un(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 Sw(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 r=o.hash;if(!r){e.workspacesError="Config hash missing; reload and retry.";return}const a={name:n,baseHash:r,whatsappAccountName:n};(i=t.workspacePath)!=null&&i.trim()&&(a.workspaceDir=t.workspacePath.trim());const d=await e.client.request("workspaces.create",a);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await Un(e),(s=t.onCreated)==null||s.call(t,d)}catch(o){e.workspacesError=String(o)}finally{e.workspaceSaving=!1}}async function xw(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 Un(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function Aw(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 Un(e)}catch(i){e.workspacesError=String(i)}}}const hi=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:Sw,loadWorkspaces:Un,removeWorkspace:xw,renameWorkspace:Aw},Symbol.toStringTag,{value:"Module"})),bu={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=bu,Co={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(bu));new Set(Object.values(Co));function Ew(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 Cw=4008;class Tw{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 p;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,r=!1,a=this.opts.token;if(s){o=await Zh();const f=(p=nf({deviceId:o.deviceId,role:t}))==null?void 0:p.token;a=f??this.opts.token,r=!!(f&&this.opts.token)}const d=a||this.opts.password?{token:a,password:this.opts.password}:void 0;let c;if(s&&o){const f=Date.now(),v=this.connectNonce??void 0,S=Ew({deviceId:o.deviceId,clientId:this.opts.clientName??Cl.CONTROL_UI,clientMode:this.opts.mode??Co.WEBCHAT,role:t,scopes:n,signedAtMs:f,token:a??null,nonce:v}),h=await ef(o.privateKey,S);c={id:o.deviceId,publicKey:o.publicKey,signature:h,signedAt:f,nonce:v}}const l={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??Co.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:c,caps:[],auth:d,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",l).then(f=>{var v,S,h;(v=f==null?void 0:f.auth)!=null&&v.deviceToken&&o&&sf({deviceId:o.deviceId,role:f.auth.role??t,token:f.auth.deviceToken,scopes:f.auth.scopes??[]}),this.backoffMs=800,(h=(S=this.opts).onHello)==null||h.call(S,f)}).catch(()=>{var f;r&&o&&of({deviceId:o.deviceId,role:t}),(f=this.ws)==null||f.close(Cw,"connect failed")})}handleMessage(t){var s,o,r,a,d,c;let n;try{n=JSON.parse(t)}catch{return}const i=n;if(i.type==="event"){const l=n;if(l.event==="connect.challenge"){const f=l.payload,v=f&&typeof f.nonce=="string"?f.nonce:null;v&&(this.connectNonce=v,this.sendConnect());return}const p=typeof l.seq=="number"?l.seq:null;p!==null&&(this.lastSeq!==null&&p>this.lastSeq+1&&((o=(s=this.opts).onGap)==null||o.call(s,{expected:this.lastSeq+1,received:p})),this.lastSeq=p);try{(a=(r=this.opts).onEvent)==null||a.call(r,l)}catch(f){console.error("[gateway] event handler error:",f)}return}if(i.type==="res"){const l=n,p=this.pending.get(l.id);if(!p)return;if(this.pending.delete(l.id),l.ok)p.resolve(l.payload);else{const f=new Error(((d=l.error)==null?void 0:d.message)??"request failed");f.payload=l.payload,f.details=(c=l.error)==null?void 0:c.details,p.reject(f)}return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=Qi(),s={type:"req",id:i,method:t,params:n},o=new Promise((r,a)=>{this.pending.set(i,{resolve:d=>r(d),reject:a})});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 To(e){return typeof e=="object"&&e!==null}function _w(e){if(!To(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!To(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 Mw(e){if(!To(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 wu(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Pw(e,t){const n=wu(e).filter(i=>i.id!==t.id);return n.push(t),n}function Tl(e,t){return wu(e).filter(n=>n.id!==t)}class Lw{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,r=this.deviceWidth/this.canvas.width,a=this.deviceHeight/this.canvas.height;return{x:Math.round(t*s*r),y:Math.round(n*o*a)}}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 Js=null;function _n(){return Js||(Js=new Lw),Js}function xr(e){return e instanceof Error?e.message:String(e)}async function Iw(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=xr(t)}finally{e.browserLoading=!1}}async function Rw(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=xr(t)}finally{e.browserLoading=!1}}}async function Ys(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 Xs(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 Dw(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=xr(t)}}function Nw(e){e.browserInputMode=!e.browserInputMode}function Bw(e){e.browserFullscreen=!e.browserFullscreen,_n().detach()}function Fw(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,_n().updateFrame(t.data,t.metadata)}function Ow(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function Uw(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function _o(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=io(s);e.assistantName=o.name,e.assistantAvatar=o.avatar,e.assistantAgentId=o.agentId??null}catch{}}async function wi(e){return(await e.request("apikeys.list")).providers??[]}async function _l(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function Ww(e,t){await e.request("apikeys.remove",{provider:t})}async function Kw(e,t,n){await e.request("apikeys.disable",{provider:t,disabled:n})}const zi="taskmaster_update_pending";async function ku(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 zw(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(zi,String(Date.now())),localStorage.removeItem(Ar)}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")Mn(),e.updateMessage=o.result.reason||"Update skipped",e.updateRunning=!1,(i=e.requestUpdate)==null||i.call(e);else throw Mn(),new Error(o.result.reason||"Update failed")}catch(o){Mn(),e.updateMessage=`Update failed: ${String(o)}`,e.updateRunning=!1,e.updateProgressSteps=[],(s=e.requestUpdate)==null||s.call(e)}}}function Hw(e,t){var i,s,o;const n=t.phase;if(n==="step-start"){const r=t.name,a=t.index,d=t.total;e.updateMessage=`Updating: ${r} (${a+1}/${d})`;const c=e.updateProgressSteps.find(l=>l.index===a);c?(c.status="running",c.name=r):e.updateProgressSteps=[...e.updateProgressSteps,{name:r,index:a,total:d,status:"running"}],(i=e.requestUpdate)==null||i.call(e)}else if(n==="step-done"){const r=t.name,a=t.index,d=t.total,c=t.ok,l=t.durationMs,p=e.updateProgressSteps.find(v=>v.index===a);p?(p.status=c?"done":"failed",p.durationMs=l):e.updateProgressSteps=[...e.updateProgressSteps,{name:r,index:a,total:d,status:c?"done":"failed",durationMs:l}];const f=!c&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=c?`Updating: ${r} done (${a+1}/${d})`:`Update step failed: ${r}${f}`,(s=e.requestUpdate)==null||s.call(e)}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const a=t.reason;e.updateMessage=a?`Update failed: ${a}`:"Update failed",e.updateRunning=!1,Mn()}(o=e.requestUpdate)==null||o.call(e)}}async function qw(e){var n,i,s,o;if(!e.client||!e.connected)return;const t=Vw();Mn();try{const r=await e.client.request("update.lastResult",{});if(!r.ok||!r.result)return;const a=5*6e4,d=Date.now()-r.result.ts<a;if(!t&&!d||Gw(r.result.ts))return;e.updateLastResult=r.result;const c=(n=r.result.after)==null?void 0:n.version;if(r.result.status==="ok"&&c&&(e.currentVersion=c),e.updateAvailable=!1,r.result.status==="ok"){const l=(i=r.result.before)==null?void 0:i.version,p=c??r.result.currentVersion;e.updateMessage=l?`Updated: v${l} → v${p}`:`Updated to v${p}`}else{const l=r.result.reason??((s=r.result.failedStep)==null?void 0:s.name)??"unknown error";e.updateMessage=`Update failed: ${l}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(o=e.requestUpdate)==null||o.call(e)}}const Ar="taskmaster_update_dismissed";function jw(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Ar,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function Vw(){try{const e=localStorage.getItem(zi);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(zi),!1):!0:!1}catch{return!1}}function Mn(){try{localStorage.removeItem(zi)}catch{}}function Gw(e){try{const t=localStorage.getItem(Ar);return t?Number(t)>=e:!1}catch{return!1}}function Zs(e,t){var a,d,c;const n=(e??"").trim(),i=(a=t.mainSessionKey)==null?void 0:a.trim();if(!i)return n;if(!n)return i;const s=((d=t.mainKey)==null?void 0:d.trim())||"main",o=(c=t.defaultAgentId)==null?void 0:c.trim();return n==="main"||n===s||o&&(n===`agent:${o}:main`||n===`agent:${o}:${s}`)?i:n}function Qw(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=Zs(e.sessionKey,t),i=Zs(e.settings.sessionKey,t),s=Zs(e.settings.lastActiveSessionKey,t),o=n||i||e.sessionKey,r={...e.settings,sessionKey:i||o,lastActiveSessionKey:s||o},a=r.sessionKey!==e.settings.sessionKey||r.lastActiveSessionKey!==e.settings.lastActiveSessionKey;o!==e.sessionKey&&(e.sessionKey=o),a&&nt(e,r)}function Ie(e){var s;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const t=!!e.publicChat,n=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.contactsPage||e.advancedPage,i=t?"public-chat":n?"setup-ui":"taskmaster-control-ui";(s=e.client)==null||s.stop(),e.client=new Tw({url:e.settings.gatewayUrl,token:t?void 0:e.settings.token.trim()?e.settings.token:void 0,password:t?void 0:e.password.trim()?e.password:void 0,clientName:i,mode:"webchat",role:t?"public":void 0,scopes:t?[]:void 0,onHello:o=>{var r;if(e.connected=!0,e.lastError=null,e.hello=o,t){Ml(e,o),_o(e),(((r=e.publicChatConfig)==null?void 0:r.auth)??"anonymous")==="anonymous"&&ik(e);return}Pi()&&(or(),e.uninstallDone=!1),Ml(e,o),e.handleAccessCheck(),qw(e).then(()=>{ku(e)}),_o(e),$w(e),(e.chatPage||e.setup)&&Xw(e),Vo(e,{quiet:!0}),jo(e,{quiet:!0}),Un(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&Fe(e),e.setup&&(Zw(e),ek(e),tk(e),nk(e)),_i(e)},onClose:({code:o,reason:r})=>{e.connected=!1,o!==1012&&(e.lastError=`disconnected (${o}): ${r||"no reason"}`)},onEvent:o=>Jw(e,o),onGap:({expected:o,received:r})=>{console.warn(`[gateway] event gap: expected seq ${o}, got ${r}`),_i(e)}}),e.client.start()}function Jw(e,t){try{Yw(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function Yw(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;sh(e,t.payload);return}if(t.event==="chat"){const i=t.payload;i!=null&&i.sessionKey&&rd(e,i.sessionKey);const s=lc(e,i);if((s==="final"||s==="error"||s==="aborted")&&(Fo(e),Jf(e)),s==="final"){const o=e,r=Math.max((((n=o.chatMessages)==null?void 0:n.length)??0)+10,Be);Ne(o,{limit:r})}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.chatSuggestion=i.suggestions[0]);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&&bh(e,i),e.tab==="cron"&&ir(e)}if((t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&jo(e,{quiet:!0}),t.event==="exec.approval.requested"){const i=_w(t.payload);if(i){e.execApprovalQueue=Pw(e.execApprovalQueue,i),e.execApprovalError=null;const s=Math.max(0,i.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=Tl(e.execApprovalQueue,i.id)},s)}return}if(t.event==="browser.screencast.frame"){Fw(e,t.payload);return}if(t.event==="browser.handoff"){Ow(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){Uw(e);return}if(t.event==="exec.approval.resolved"){const i=Mw(t.payload);i&&(e.execApprovalQueue=Tl(e.execApprovalQueue,i.id));return}if(t.event==="update.progress"){Hw(e,t.payload);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&&Qw(e,n.sessionDefaults)}async function Xw(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 Zw(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await wi(e.client)}catch{}}async function ek(e){if(!(!e.client||!e.connected))try{e.tailscaleStatus=await e.client.request("tailscale.status")}catch{}}async function tk(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 nk(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 $u(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 ik(e){var n,i,s;if(!e.client||!e.connected)return;const t=$u((n=e.publicChatConfig)==null?void 0:n.cookieTtlDays);try{const o=(i=e.publicChatConfig)==null?void 0:i.accountId,r=await e.client.request("public.session",{cookieId:t,accountId:o});if(r!=null&&r.sessionKey){e.publicChatSessionKey=r.sessionKey,e.sessionKey=r.sessionKey,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const a=((s=e.publicChatConfig)==null?void 0:s.accountId)??"";e.chatMessage=Rn(a,r.sessionKey),Ne(e)}}catch(o){console.error("[public-chat] failed to resolve anonymous session:",o),e.lastError="Failed to start chat session"}}let Ce=!1,fe=null,Qt="",Hi="";function Su(e){return e.replace(/[\s\-()]/g,"")}function xu(){Ce=!1,fe=null,Qt="",Hi=""}async function sk(e){if(!e.client||!e.connected)return;const t=$u(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){fe=n instanceof Error?n.message:"Failed to start session",e.requestUpdate()}}async function Ll(e){if(!e.client||Ce)return;const t=Su(Qt);if(!t){fe="Please enter your phone number",e.requestUpdate();return}Ce=!0,fe=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{phone:t,name:Hi.trim()||void 0,accountId:e.accountId});n!=null&&n.ok?e.onAuthStepChange("otp"):fe=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){fe=n instanceof Error?n.message:"Failed to send verification code"}finally{Ce=!1,e.requestUpdate()}}async function Il(e,t){if(!(!e.client||Ce)){if(!t.trim()){fe="Please enter the verification code",e.requestUpdate();return}Ce=!0,fe=null,e.requestUpdate();try{const n=await e.client.request("public.otp.verify",{phone:Su(Qt),code:t.trim(),accountId:e.accountId});n!=null&&n.ok&&n.sessionKey?(xu(),e.onAuthenticated(n.sessionKey)):fe=(n==null?void 0:n.error)??"Invalid verification code"}catch(n){fe=n instanceof Error?n.message:"Verification failed"}finally{Ce=!1,e.requestUpdate()}}}function eo(e){return k}function Rl(e){return u`
|
|
4058
|
+
`}async function $w(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 Un(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 Sw(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 r=o.hash;if(!r){e.workspacesError="Config hash missing; reload and retry.";return}const a={name:n,baseHash:r,whatsappAccountName:n};(i=t.workspacePath)!=null&&i.trim()&&(a.workspaceDir=t.workspacePath.trim());const d=await e.client.request("workspaces.create",a);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await Un(e),(s=t.onCreated)==null||s.call(t,d)}catch(o){e.workspacesError=String(o)}finally{e.workspaceSaving=!1}}async function xw(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 Un(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function Aw(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 Un(e)}catch(i){e.workspacesError=String(i)}}}const hi=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:Sw,loadWorkspaces:Un,removeWorkspace:xw,renameWorkspace:Aw},Symbol.toStringTag,{value:"Module"})),bu={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"},Tl=bu,To={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(bu));new Set(Object.values(To));function Ew(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 Cw=4008;class Tw{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 p;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,r=!1,a=this.opts.token;if(s){o=await Zh();const h=(p=nf({deviceId:o.deviceId,role:t}))==null?void 0:p.token;a=h??this.opts.token,r=!!(h&&this.opts.token)}const d=a||this.opts.password?{token:a,password:this.opts.password}:void 0;let c;if(s&&o){const h=Date.now(),v=this.connectNonce??void 0,S=Ew({deviceId:o.deviceId,clientId:this.opts.clientName??Tl.CONTROL_UI,clientMode:this.opts.mode??To.WEBCHAT,role:t,scopes:n,signedAtMs:h,token:a??null,nonce:v}),f=await ef(o.privateKey,S);c={id:o.deviceId,publicKey:o.publicKey,signature:f,signedAt:h,nonce:v}}const l={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Tl.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??To.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:c,caps:[],auth:d,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",l).then(h=>{var v,S,f;(v=h==null?void 0:h.auth)!=null&&v.deviceToken&&o&&sf({deviceId:o.deviceId,role:h.auth.role??t,token:h.auth.deviceToken,scopes:h.auth.scopes??[]}),this.backoffMs=800,(f=(S=this.opts).onHello)==null||f.call(S,h)}).catch(()=>{var h;r&&o&&of({deviceId:o.deviceId,role:t}),(h=this.ws)==null||h.close(Cw,"connect failed")})}handleMessage(t){var s,o,r,a,d,c;let n;try{n=JSON.parse(t)}catch{return}const i=n;if(i.type==="event"){const l=n;if(l.event==="connect.challenge"){const h=l.payload,v=h&&typeof h.nonce=="string"?h.nonce:null;v&&(this.connectNonce=v,this.sendConnect());return}const p=typeof l.seq=="number"?l.seq:null;p!==null&&(this.lastSeq!==null&&p>this.lastSeq+1&&((o=(s=this.opts).onGap)==null||o.call(s,{expected:this.lastSeq+1,received:p})),this.lastSeq=p);try{(a=(r=this.opts).onEvent)==null||a.call(r,l)}catch(h){console.error("[gateway] event handler error:",h)}return}if(i.type==="res"){const l=n,p=this.pending.get(l.id);if(!p)return;if(this.pending.delete(l.id),l.ok)p.resolve(l.payload);else{const h=new Error(((d=l.error)==null?void 0:d.message)??"request failed");h.payload=l.payload,h.details=(c=l.error)==null?void 0:c.details,p.reject(h)}return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=Qi(),s={type:"req",id:i,method:t,params:n},o=new Promise((r,a)=>{this.pending.set(i,{resolve:d=>r(d),reject:a})});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 _o(e){return typeof e=="object"&&e!==null}function _w(e){if(!_o(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!_o(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 Mw(e){if(!_o(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 wu(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Pw(e,t){const n=wu(e).filter(i=>i.id!==t.id);return n.push(t),n}function _l(e,t){return wu(e).filter(n=>n.id!==t)}class Lw{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,r=this.deviceWidth/this.canvas.width,a=this.deviceHeight/this.canvas.height;return{x:Math.round(t*s*r),y:Math.round(n*o*a)}}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 Js=null;function _n(){return Js||(Js=new Lw),Js}function Ar(e){return e instanceof Error?e.message:String(e)}async function Iw(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=Ar(t)}finally{e.browserLoading=!1}}async function Rw(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=Ar(t)}finally{e.browserLoading=!1}}}async function Ys(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 Xs(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 Dw(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=Ar(t)}}function Nw(e){e.browserInputMode=!e.browserInputMode}function Bw(e){e.browserFullscreen=!e.browserFullscreen,_n().detach()}function Fw(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,_n().updateFrame(t.data,t.metadata)}function Ow(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function Uw(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function Mo(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=io(s);e.assistantName=o.name,e.assistantAvatar=o.avatar,e.assistantAgentId=o.agentId??null}catch{}}async function wi(e){return(await e.request("apikeys.list")).providers??[]}async function Ml(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function Ww(e,t){await e.request("apikeys.remove",{provider:t})}async function Kw(e,t,n){await e.request("apikeys.disable",{provider:t,disabled:n})}const zi="taskmaster_update_pending";async function ku(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 zw(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(zi,String(Date.now())),localStorage.removeItem(Er)}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")Mn(),e.updateMessage=o.result.reason||"Update skipped",e.updateRunning=!1,(i=e.requestUpdate)==null||i.call(e);else throw Mn(),new Error(o.result.reason||"Update failed")}catch(o){Mn(),e.updateMessage=`Update failed: ${String(o)}`,e.updateRunning=!1,e.updateProgressSteps=[],(s=e.requestUpdate)==null||s.call(e)}}}function Hw(e,t){var i,s,o;const n=t.phase;if(n==="step-start"){const r=t.name,a=t.index,d=t.total;e.updateMessage=`Updating: ${r} (${a+1}/${d})`;const c=e.updateProgressSteps.find(l=>l.index===a);c?(c.status="running",c.name=r):e.updateProgressSteps=[...e.updateProgressSteps,{name:r,index:a,total:d,status:"running"}],(i=e.requestUpdate)==null||i.call(e)}else if(n==="step-done"){const r=t.name,a=t.index,d=t.total,c=t.ok,l=t.durationMs,p=e.updateProgressSteps.find(v=>v.index===a);p?(p.status=c?"done":"failed",p.durationMs=l):e.updateProgressSteps=[...e.updateProgressSteps,{name:r,index:a,total:d,status:c?"done":"failed",durationMs:l}];const h=!c&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=c?`Updating: ${r} done (${a+1}/${d})`:`Update step failed: ${r}${h}`,(s=e.requestUpdate)==null||s.call(e)}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const a=t.reason;e.updateMessage=a?`Update failed: ${a}`:"Update failed",e.updateRunning=!1,Mn()}(o=e.requestUpdate)==null||o.call(e)}}async function qw(e){var n,i,s,o;if(!e.client||!e.connected)return;const t=Vw();Mn();try{const r=await e.client.request("update.lastResult",{});if(!r.ok||!r.result)return;const a=5*6e4,d=Date.now()-r.result.ts<a;if(!t&&!d||Gw(r.result.ts))return;e.updateLastResult=r.result;const c=(n=r.result.after)==null?void 0:n.version;if(r.result.status==="ok"&&c&&(e.currentVersion=c),e.updateAvailable=!1,r.result.status==="ok"){const l=(i=r.result.before)==null?void 0:i.version,p=c??r.result.currentVersion;e.updateMessage=l?`Updated: v${l} → v${p}`:`Updated to v${p}`}else{const l=r.result.reason??((s=r.result.failedStep)==null?void 0:s.name)??"unknown error";e.updateMessage=`Update failed: ${l}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(o=e.requestUpdate)==null||o.call(e)}}const Er="taskmaster_update_dismissed";function jw(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Er,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function Vw(){try{const e=localStorage.getItem(zi);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(zi),!1):!0:!1}catch{return!1}}function Mn(){try{localStorage.removeItem(zi)}catch{}}function Gw(e){try{const t=localStorage.getItem(Er);return t?Number(t)>=e:!1}catch{return!1}}function Zs(e,t){var a,d,c;const n=(e??"").trim(),i=(a=t.mainSessionKey)==null?void 0:a.trim();if(!i)return n;if(!n)return i;const s=((d=t.mainKey)==null?void 0:d.trim())||"main",o=(c=t.defaultAgentId)==null?void 0:c.trim();return n==="main"||n===s||o&&(n===`agent:${o}:main`||n===`agent:${o}:${s}`)?i:n}function Qw(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=Zs(e.sessionKey,t),i=Zs(e.settings.sessionKey,t),s=Zs(e.settings.lastActiveSessionKey,t),o=n||i||e.sessionKey,r={...e.settings,sessionKey:i||o,lastActiveSessionKey:s||o},a=r.sessionKey!==e.settings.sessionKey||r.lastActiveSessionKey!==e.settings.lastActiveSessionKey;o!==e.sessionKey&&(e.sessionKey=o),a&&nt(e,r)}function Ie(e){var s;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const t=!!e.publicChat,n=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.contactsPage||e.advancedPage,i=t?"public-chat":n?"setup-ui":"taskmaster-control-ui";(s=e.client)==null||s.stop(),e.client=new Tw({url:e.settings.gatewayUrl,token:t?void 0:e.settings.token.trim()?e.settings.token:void 0,password:t?void 0:e.password.trim()?e.password:void 0,clientName:i,mode:"webchat",role:t?"public":void 0,scopes:t?[]:void 0,onHello:o=>{var r;if(e.connected=!0,e.lastError=null,e.hello=o,t){Pl(e,o),Mo(e),(((r=e.publicChatConfig)==null?void 0:r.auth)??"anonymous")==="anonymous"&&ik(e);return}Pi()&&(rr(),e.uninstallDone=!1),Pl(e,o),e.handleAccessCheck(),qw(e).then(()=>{ku(e)}),Mo(e),$w(e),(e.chatPage||e.setup)&&Xw(e),Go(e,{quiet:!0}),Vo(e,{quiet:!0}),Un(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&Fe(e),e.setup&&(Zw(e),ek(e),tk(e),nk(e)),_i(e)},onClose:({code:o,reason:r})=>{e.connected=!1,o!==1012&&(e.lastError=`disconnected (${o}): ${r||"no reason"}`)},onEvent:o=>Jw(e,o),onGap:({expected:o,received:r})=>{console.warn(`[gateway] event gap: expected seq ${o}, got ${r}`),_i(e)}}),e.client.start()}function Jw(e,t){try{Yw(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function Yw(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;sh(e,t.payload);return}if(t.event==="chat"){const i=t.payload;i!=null&&i.sessionKey&&ad(e,i.sessionKey);const s=cc(e,i);if((s==="final"||s==="error"||s==="aborted")&&(Oo(e),Jf(e)),s==="final"){const o=e,r=Math.max((((n=o.chatMessages)==null?void 0:n.length)??0)+10,Be);Ne(o,{limit:r})}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.chatSuggestion=i.suggestions[0]);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&&bh(e,i),e.tab==="cron"&&sr(e)}if((t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&Vo(e,{quiet:!0}),t.event==="exec.approval.requested"){const i=_w(t.payload);if(i){e.execApprovalQueue=Pw(e.execApprovalQueue,i),e.execApprovalError=null;const s=Math.max(0,i.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=_l(e.execApprovalQueue,i.id)},s)}return}if(t.event==="browser.screencast.frame"){Fw(e,t.payload);return}if(t.event==="browser.handoff"){Ow(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){Uw(e);return}if(t.event==="exec.approval.resolved"){const i=Mw(t.payload);i&&(e.execApprovalQueue=_l(e.execApprovalQueue,i.id));return}if(t.event==="update.progress"){Hw(e,t.payload);return}}function Pl(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&&Qw(e,n.sessionDefaults)}async function Xw(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 Zw(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await wi(e.client)}catch{}}async function ek(e){if(!(!e.client||!e.connected))try{e.tailscaleStatus=await e.client.request("tailscale.status")}catch{}}async function tk(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 nk(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 Ll="taskmaster_public_id";function $u(e=30){var s;const t=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(`${Ll}=`));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=`${Ll}=${n}; path=/; expires=${i}; SameSite=Lax`,n}async function ik(e){var n,i,s;if(!e.client||!e.connected)return;const t=$u((n=e.publicChatConfig)==null?void 0:n.cookieTtlDays);try{const o=(i=e.publicChatConfig)==null?void 0:i.accountId,r=await e.client.request("public.session",{cookieId:t,accountId:o});if(r!=null&&r.sessionKey){e.publicChatSessionKey=r.sessionKey,e.sessionKey=r.sessionKey,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const a=((s=e.publicChatConfig)==null?void 0:s.accountId)??"";e.chatMessage=Rn(a,r.sessionKey),Ne(e)}}catch(o){console.error("[public-chat] failed to resolve anonymous session:",o),e.lastError="Failed to start chat session"}}let Ce=!1,fe=null,Qt="",Hi="";function Su(e){return e.replace(/[\s\-()]/g,"")}function xu(){Ce=!1,fe=null,Qt="",Hi=""}async function sk(e){if(!e.client||!e.connected)return;const t=$u(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){fe=n instanceof Error?n.message:"Failed to start session",e.requestUpdate()}}async function Il(e){if(!e.client||Ce)return;const t=Su(Qt);if(!t){fe="Please enter your phone number",e.requestUpdate();return}Ce=!0,fe=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{phone:t,name:Hi.trim()||void 0,accountId:e.accountId});n!=null&&n.ok?e.onAuthStepChange("otp"):fe=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){fe=n instanceof Error?n.message:"Failed to send verification code"}finally{Ce=!1,e.requestUpdate()}}async function Rl(e,t){if(!(!e.client||Ce)){if(!t.trim()){fe="Please enter the verification code",e.requestUpdate();return}Ce=!0,fe=null,e.requestUpdate();try{const n=await e.client.request("public.otp.verify",{phone:Su(Qt),code:t.trim(),accountId:e.accountId});n!=null&&n.ok&&n.sessionKey?(xu(),e.onAuthenticated(n.sessionKey)):fe=(n==null?void 0:n.error)??"Invalid verification code"}catch(n){fe=n instanceof Error?n.message:"Verification failed"}finally{Ce=!1,e.requestUpdate()}}}function eo(e){return k}function Dl(e){return u`
|
|
4059
4059
|
<div class="public-auth__form">
|
|
4060
4060
|
<label class="field public-auth__field">
|
|
4061
4061
|
<span>Your name (optional)</span>
|
|
@@ -4072,7 +4072,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
4072
4072
|
type="tel"
|
|
4073
4073
|
.value=${Qt}
|
|
4074
4074
|
@input=${t=>{Qt=t.target.value}}
|
|
4075
|
-
@keydown=${t=>{t.key==="Enter"&&(t.preventDefault(),
|
|
4075
|
+
@keydown=${t=>{t.key==="Enter"&&(t.preventDefault(),Il(e))}}
|
|
4076
4076
|
placeholder="+44 7123 456789"
|
|
4077
4077
|
required
|
|
4078
4078
|
/>
|
|
@@ -4081,12 +4081,12 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
4081
4081
|
<button
|
|
4082
4082
|
class="btn primary public-auth__btn"
|
|
4083
4083
|
?disabled=${Ce}
|
|
4084
|
-
@click=${()=>{
|
|
4084
|
+
@click=${()=>{Il(e)}}
|
|
4085
4085
|
>
|
|
4086
4086
|
${Ce?"Sending...":"Send verification code"}
|
|
4087
4087
|
</button>
|
|
4088
4088
|
</div>
|
|
4089
|
-
`}function
|
|
4089
|
+
`}function Nl(e){let t="";return u`
|
|
4090
4090
|
<div class="public-auth__form">
|
|
4091
4091
|
<p class="public-auth__hint">
|
|
4092
4092
|
We sent a verification code to <strong>${Qt}</strong> via WhatsApp.
|
|
@@ -4098,7 +4098,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
4098
4098
|
inputmode="numeric"
|
|
4099
4099
|
maxlength="6"
|
|
4100
4100
|
@input=${n=>{t=n.target.value}}
|
|
4101
|
-
@keydown=${n=>{n.key==="Enter"&&(n.preventDefault(),
|
|
4101
|
+
@keydown=${n=>{n.key==="Enter"&&(n.preventDefault(),Rl(e,t))}}
|
|
4102
4102
|
placeholder="123456"
|
|
4103
4103
|
required
|
|
4104
4104
|
/>
|
|
@@ -4107,7 +4107,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
4107
4107
|
<button
|
|
4108
4108
|
class="btn primary public-auth__btn"
|
|
4109
4109
|
?disabled=${Ce}
|
|
4110
|
-
@click=${()=>{
|
|
4110
|
+
@click=${()=>{Rl(e,t)}}
|
|
4111
4111
|
>
|
|
4112
4112
|
${Ce?"Verifying...":"Verify"}
|
|
4113
4113
|
</button>
|
|
@@ -4131,7 +4131,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
4131
4131
|
${eo()}
|
|
4132
4132
|
<h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
|
|
4133
4133
|
<p class="public-auth__subtitle">Verify your WhatsApp number to get started.</p>
|
|
4134
|
-
${n==="otp"?
|
|
4134
|
+
${n==="otp"?Nl(e):Dl(e)}
|
|
4135
4135
|
</div>
|
|
4136
4136
|
</div>
|
|
4137
4137
|
`:n==="phone"||n==="otp"?u`
|
|
@@ -4140,7 +4140,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
4140
4140
|
${eo()}
|
|
4141
4141
|
<h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
|
|
4142
4142
|
<p class="public-auth__subtitle">Verify your WhatsApp number to continue your conversation across devices.</p>
|
|
4143
|
-
${n==="otp"?
|
|
4143
|
+
${n==="otp"?Nl(e):Dl(e)}
|
|
4144
4144
|
</div>
|
|
4145
4145
|
</div>
|
|
4146
4146
|
`:u`
|
|
@@ -4168,7 +4168,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
4168
4168
|
</p>
|
|
4169
4169
|
</div>
|
|
4170
4170
|
</div>
|
|
4171
|
-
`}const Er="taskmaster-access-session",Au={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function Eu(){try{return localStorage.getItem(Er)}catch{return null}}function Cu(e){try{localStorage.setItem(Er,e)}catch{}}function rk(){try{localStorage.removeItem(Er)}catch{}}async function Nl(e){if(e.client)try{const t=Eu(),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 ak(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?(Cu(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 lk(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?(Cu(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 ck(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 dk(e){const t=Eu();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}rk(),e.accessState={...Au,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}function uk(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 r=o.match;if(!r||typeof r!="object"||(r.channel??"").toLowerCase()!=="whatsapp")continue;const d=r.peer;if(!d||typeof d!="object"||d.kind!=="dm")continue;const c=d.id??"";c&&i.push({phone:c,paired:((s=o.meta)==null?void 0:s.paired)===!0})}return i.sort((o,r)=>o.paired&&!r.paired?-1:!o.paired&&r.paired?1:0),i}function Tu(e,t,n="admin",i){const s=c=>c===n||c==="management",o=new Map,r=new Map;for(const c of e){if(!c||typeof c!="object"||!s(c.agentId))continue;const l=c.match;if(!l||typeof l!="object"||(l.channel??"").toLowerCase()!=="whatsapp")continue;const f=l.peer;if(!f||typeof f!="object"||f.kind!=="dm")continue;const v=f.id??"";v&&(c.meta&&o.set(v,c.meta),l.accountId&&r.set(v,l.accountId))}const a=e.filter(c=>{if(!c||typeof c!="object"||!s(c.agentId))return!0;const l=c.match;if(!l||typeof l!="object"||(l.channel??"").toLowerCase()!=="whatsapp")return!0;const f=l.peer;return!f||typeof f!="object"?!0:f.kind!=="dm"}),d=t.map(c=>{const l=i??r.get(c.phone),p={channel:"whatsapp",peer:{kind:"dm",id:c.phone}};l&&(p.accountId=l);const f={agentId:n,match:p},v=o.get(c.phone);return v?f.meta=v:c.paired&&(f.meta={paired:!0}),f});return[...a,...d]}async function is(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=st(s??{}),e.adminPhones=uk(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function _u(e,t,n,i){var r,a;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(d=>d.phone===o)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const d=st(e.configForm??((r=e.configSnapshot)==null?void 0:r.config)??{}),c=d.bindings??[],l=[...e.adminPhones,{phone:o}],p=Tu(c,l,s,i);dc(d,["bindings"],p);const f=(a=e.configSnapshot)==null?void 0:a.hash;if(!f){e.adminsError="Config hash missing; reload and retry.";return}const v=St(d);await e.client.request("config.set",{raw:v,baseHash:f}),await is(e,n)}catch(d){e.adminsError=String(d)}finally{e.adminsSaving=!1}}async function Mu(e,t,n,i){var r,a;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(d=>d.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 d=st(e.configForm??((r=e.configSnapshot)==null?void 0:r.config)??{}),c=d.bindings??[],l=e.adminPhones.filter(S=>S.phone!==t),p=Tu(c,l,s,i);dc(d,["bindings"],p);const f=(a=e.configSnapshot)==null?void 0:a.hash;if(!f){e.adminsError="Config hash missing; reload and retry.";return}const v=St(d);await e.client.request("config.set",{raw:v,baseHash:f}),await is(e,n)}catch(d){e.adminsError=String(d)}finally{e.adminsSaving=!1}}const pk=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:_u,loadAdmins:is,removeAdmin:Mu},Symbol.toStringTag,{value:"Module"}));async function _t(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 Pu(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 _t(e,i)}catch(r){e.contactsError=String(r)}finally{e.contactsSaving=!1}}async function Lu(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 _t(e,n)}catch(i){e.contactsError=String(i)}finally{e.contactsSaving=!1}}}async function Mo(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 _t(e,s)}catch(o){e.contactsError=String(o)}finally{e.contactsSaving=!1}}}async function Iu(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 _t(e,i)}catch(s){e.contactsError=String(s)}finally{e.contactsSaving=!1}}}const hk=Object.freeze(Object.defineProperty({__proto__:null,addContact:Pu,deleteContact:Lu,deleteContactField:Iu,loadContacts:_t,setContactField:Mo},Symbol.toStringTag,{value:"Module"}));function yn(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}}}function fk(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}}}function gk(e){const t=le(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 mk(e){const t=le(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function yk(e){var i;const t=le(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 vk(e){return e.selectedWorkspace??void 0}function le(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const bk=/^data:/i,wk=/^https?:\/\//i;function Bl(e){var a,d;const t=((a=e.agentsList)==null?void 0:a.agents)??[],n=Xl(e.sessionKey),i=(n==null?void 0:n.agentId)??((d=e.agentsList)==null?void 0:d.defaultId)??"main",s=t.find(c=>c.id===i),o=s==null?void 0:s.identity,r=(o==null?void 0:o.avatarUrl)??(o==null?void 0:o.avatar);if(r)return bk.test(r)||wk.test(r)?r:o==null?void 0:o.avatarUrl}function kk(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 $k(e){var r;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(r=e.channelAccounts)==null?void 0:r.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 Sk(e){var r;const t=(r=e.configSnapshot)==null?void 0:r.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const i=n.find(a=>{var d,c;return((d=a.match)==null?void 0:d.channel)==="imessage"&&((c=a.meta)==null?void 0:c.imessageOwner)});if(!i)return null;const s=i.agentId;for(const a of e.workspaces)if(a.agents.some(d=>d.id===s))return a.name;if(s==="admin"||s==="public"){const a=e.workspaces.find(d=>d.isDefault);return(a==null?void 0:a.name)??null}const o=s.replace(/-(admin|public)$/,"");if(o!==s){const a=e.workspaces.find(d=>d.name===o);return(a==null?void 0:a.name)??null}return null}function xk(e){var t,n,i,s,o,r,a,d,c;if(e.embeddingDownloading&&!e.publicChat)return u`
|
|
4171
|
+
`}const Cr="taskmaster-access-session",Au={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function Eu(){try{return localStorage.getItem(Cr)}catch{return null}}function Cu(e){try{localStorage.setItem(Cr,e)}catch{}}function rk(){try{localStorage.removeItem(Cr)}catch{}}async function Bl(e){if(e.client)try{const t=Eu(),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 ak(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?(Cu(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 lk(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?(Cu(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 ck(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 dk(e){const t=Eu();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}rk(),e.accessState={...Au,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}function uk(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 r=o.match;if(!r||typeof r!="object"||(r.channel??"").toLowerCase()!=="whatsapp")continue;const d=r.peer;if(!d||typeof d!="object"||d.kind!=="dm")continue;const c=d.id??"";c&&i.push({phone:c,paired:((s=o.meta)==null?void 0:s.paired)===!0})}return i.sort((o,r)=>o.paired&&!r.paired?-1:!o.paired&&r.paired?1:0),i}function Tu(e,t,n="admin",i){const s=c=>c===n||c==="management",o=new Map,r=new Map;for(const c of e){if(!c||typeof c!="object"||!s(c.agentId))continue;const l=c.match;if(!l||typeof l!="object"||(l.channel??"").toLowerCase()!=="whatsapp")continue;const h=l.peer;if(!h||typeof h!="object"||h.kind!=="dm")continue;const v=h.id??"";v&&(c.meta&&o.set(v,c.meta),l.accountId&&r.set(v,l.accountId))}const a=e.filter(c=>{if(!c||typeof c!="object"||!s(c.agentId))return!0;const l=c.match;if(!l||typeof l!="object"||(l.channel??"").toLowerCase()!=="whatsapp")return!0;const h=l.peer;return!h||typeof h!="object"?!0:h.kind!=="dm"}),d=t.map(c=>{const l=i??r.get(c.phone),p={channel:"whatsapp",peer:{kind:"dm",id:c.phone}};l&&(p.accountId=l);const h={agentId:n,match:p},v=o.get(c.phone);return v?h.meta=v:c.paired&&(h.meta={paired:!0}),h});return[...a,...d]}async function is(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=st(s??{}),e.adminPhones=uk(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function _u(e,t,n,i){var r,a;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(d=>d.phone===o)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const d=st(e.configForm??((r=e.configSnapshot)==null?void 0:r.config)??{}),c=d.bindings??[],l=[...e.adminPhones,{phone:o}],p=Tu(c,l,s,i);uc(d,["bindings"],p);const h=(a=e.configSnapshot)==null?void 0:a.hash;if(!h){e.adminsError="Config hash missing; reload and retry.";return}const v=St(d);await e.client.request("config.set",{raw:v,baseHash:h}),await is(e,n)}catch(d){e.adminsError=String(d)}finally{e.adminsSaving=!1}}async function Mu(e,t,n,i){var r,a;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(d=>d.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 d=st(e.configForm??((r=e.configSnapshot)==null?void 0:r.config)??{}),c=d.bindings??[],l=e.adminPhones.filter(S=>S.phone!==t),p=Tu(c,l,s,i);uc(d,["bindings"],p);const h=(a=e.configSnapshot)==null?void 0:a.hash;if(!h){e.adminsError="Config hash missing; reload and retry.";return}const v=St(d);await e.client.request("config.set",{raw:v,baseHash:h}),await is(e,n)}catch(d){e.adminsError=String(d)}finally{e.adminsSaving=!1}}const pk=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:_u,loadAdmins:is,removeAdmin:Mu},Symbol.toStringTag,{value:"Module"}));async function _t(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 Pu(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 _t(e,i)}catch(r){e.contactsError=String(r)}finally{e.contactsSaving=!1}}async function Lu(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 _t(e,n)}catch(i){e.contactsError=String(i)}finally{e.contactsSaving=!1}}}async function Po(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 _t(e,s)}catch(o){e.contactsError=String(o)}finally{e.contactsSaving=!1}}}async function Iu(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 _t(e,i)}catch(s){e.contactsError=String(s)}finally{e.contactsSaving=!1}}}const hk=Object.freeze(Object.defineProperty({__proto__:null,addContact:Pu,deleteContact:Lu,deleteContactField:Iu,loadContacts:_t,setContactField:Po},Symbol.toStringTag,{value:"Module"}));function yn(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}}}function fk(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}}}function gk(e){const t=le(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 mk(e){const t=le(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function yk(e){var i;const t=le(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 vk(e){return e.selectedWorkspace??void 0}function le(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const bk=/^data:/i,wk=/^https?:\/\//i;function Fl(e){var a,d;const t=((a=e.agentsList)==null?void 0:a.agents)??[],n=Zl(e.sessionKey),i=(n==null?void 0:n.agentId)??((d=e.agentsList)==null?void 0:d.defaultId)??"main",s=t.find(c=>c.id===i),o=s==null?void 0:s.identity,r=(o==null?void 0:o.avatarUrl)??(o==null?void 0:o.avatar);if(r)return bk.test(r)||wk.test(r)?r:o==null?void 0:o.avatarUrl}function kk(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 $k(e){var r;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(r=e.channelAccounts)==null?void 0:r.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 Sk(e){var r;const t=(r=e.configSnapshot)==null?void 0:r.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const i=n.find(a=>{var d,c;return((d=a.match)==null?void 0:d.channel)==="imessage"&&((c=a.meta)==null?void 0:c.imessageOwner)});if(!i)return null;const s=i.agentId;for(const a of e.workspaces)if(a.agents.some(d=>d.id===s))return a.name;if(s==="admin"||s==="public"){const a=e.workspaces.find(d=>d.isDefault);return(a==null?void 0:a.name)??null}const o=s.replace(/-(admin|public)$/,"");if(o!==s){const a=e.workspaces.find(d=>d.name===o);return(a==null?void 0:a.name)??null}return null}function xk(e){var t,n,i,s,o,r,a,d,c;if(e.embeddingDownloading&&!e.publicChat)return u`
|
|
4172
4172
|
<div class="setup-container">
|
|
4173
4173
|
<div class="setup-card" style="text-align:center; max-width:420px;">
|
|
4174
4174
|
<div class="setup-spinner"></div>
|
|
@@ -4182,14 +4182,14 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
4182
4182
|
</p>
|
|
4183
4183
|
</div>
|
|
4184
4184
|
</div>
|
|
4185
|
-
`;if(e.publicChat)return e.connected?e.publicChatAuthenticated?kw({connected:e.connected,sessionKey:e.sessionKey,loading:e.chatLoading,sending:e.chatSending,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,assistantAvatarUrl:e.chatAvatarUrl??
|
|
4185
|
+
`;if(e.publicChat)return e.connected?e.publicChatAuthenticated?kw({connected:e.connected,sessionKey:e.sessionKey,loading:e.chatLoading,sending:e.chatSending,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,assistantAvatarUrl:e.chatAvatarUrl??Fl(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,suggestion:e.chatSuggestion,onSuggestionClick:l=>{e.chatMessage=l,e.chatSuggestion=null,e.handleSendChat()},onRefresh:()=>(e.resetToolStream(),re(async()=>{const{loadChatHistory:l}=await Promise.resolve().then(()=>Ei);return{loadChatHistory:l}},void 0,import.meta.url).then(({loadChatHistory:l})=>{l(e)})),onDraftChange:l=>{var h;e.chatMessage=l;const p=((h=e.publicChatConfig)==null?void 0:h.accountId)??"";oa(p,e.sessionKey,l)},requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:l=>e.chatAttachments=l,onSend:()=>e.handleSendChat(),onAbort:()=>{e.handleAbortChat()},onQueueRemove:l=>e.removeQueuedMessage(l),onChatScroll:l=>e.handleChatScroll(l),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()}}):ok({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,onAuthenticated:l=>{var h;e.publicChatSessionKey=l,e.sessionKey=l,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const p=((h=e.publicChatConfig)==null?void 0:h.accountId)??"";e.chatMessage=Rn(p,l),re(async()=>{const{loadChatHistory:v}=await Promise.resolve().then(()=>Ei);return{loadChatHistory:v}},void 0,import.meta.url).then(({loadChatHistory:v})=>{v(e)})},onAuthStepChange:l=>{e.publicChatAuthStep=l},requestUpdate:()=>{e.requestUpdate()}}):u`
|
|
4186
4186
|
<div class="setup-container">
|
|
4187
4187
|
<div class="setup-card">
|
|
4188
4188
|
<div class="setup-spinner"></div>
|
|
4189
4189
|
<p>Connecting...</p>
|
|
4190
4190
|
</div>
|
|
4191
4191
|
</div>
|
|
4192
|
-
`;if(e.connected&&e.accessState.checked){const{accessState:l}=e;if(l.hasPins&&!l.authenticated)return El({show:!0,isFirstTime:!1,accounts:l.accounts,error:l.error,busy:l.busy,onSubmit:(p,f)=>{f!=null&&e.handlePinSubmit(p,f)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(p,f,v)=>e.handleChangePin(p,f,v)});if(!l.hasMasterPin&&!l.authenticated&&e.setup)return El({show:!0,isFirstTime:!0,accounts:[],error:l.error,busy:l.busy,onSubmit:p=>e.handleSetMasterPin(p)});if(!l.hasMasterPin&&!l.authenticated&&!e.setup)return window.location.href="/setup",k}if(e.setup){const l=kk(e.channelsSnapshot),p=((n=(t=e.channelsSnapshot)==null?void 0:t.channelAccounts)==null?void 0:n.whatsapp)??[],f=$k(e.channelsSnapshot),v=Sk(e),S=async()=>{e.tailscaleStatus=await e.client.request("tailscale.status")};return Eg({connected:e.connected,serverPlatform:((s=(i=e.hello)==null?void 0:i.server)==null?void 0:s.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:h=>e.handleLicenseKeyChange(h),onLicenseActivate:()=>e.handleLicenseActivate(),onLicenseRemove:async()=>{await e.handleLicenseRemove(),e.licenseRemoveConfirm=!1},licenseRemoveConfirm:e.licenseRemoveConfirm,onLicenseRemoveConfirm:()=>{e.licenseRemoveConfirm=!0},onLicenseRemoveCancel:()=>{e.licenseRemoveConfirm=!1},authConnected:e.authConnected,authBusy:e.authBusy,authMessage:e.authMessage,authUrl:e.authUrl,authCodeInput:e.authCodeInput,authExpiresIn:e.authExpiresIn,whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:l,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:h=>e.handleUninstallConfirmTextChange(h),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:h=>e.handleAuthSubmitCode(h),onAuthCodeChange:h=>e.handleAuthCodeChange(h),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async h=>{await e.handleWhatsAppStart(!0,h),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(h),await Y(e,!0),e.requestUpdate())},onWhatsAppUnlink:async h=>{await e.handleWhatsAppLogout(h)},onWhatsAppReset:async h=>{await e.handleWhatsAppLogout(h),await e.handleWhatsAppStart(!0,h),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(h),await Y(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await Y(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),Y(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:h=>e.handleRemoveWhatsAppAccount(h),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:h=>{e.newWorkspacePin=h},onWorkspaceCreate:async(h,b)=>{const w=e.newWorkspacePin;await e.handleWorkspaceCreate(h,b),w.match(/^\d{4,6}$/)&&(await ck(e,h,w),e.newWorkspacePin="")},onWorkspaceRemove:h=>e.handleWorkspaceRemove(h),onSetAddingWorkspace:h=>{e.addingWorkspace=h},onSetNewWorkspaceName:h=>{e.newWorkspaceName=h},onSetNewWorkspacePath:h=>{e.newWorkspacePath=h},onSetWorkspaceRemoveConfirm:h=>{e.workspaceRemoveConfirm=h},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(h,b)=>e.handleWorkspaceRename(h,b),whatsappDmPolicy:(()=>{const h=le(e),b=h==null?void 0:h.whatsappAccountId,w=b?p.find(x=>x.accountId===b):p[0];return(w==null?void 0:w.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var P;const h=le(e),b=h==null?void 0:h.whatsappAccountId,w=b?p.find(_=>_.accountId===b):p[0];if(!w)return;const A=w.dmPolicy!=null&&w.dmPolicy!=="disabled"?"disabled":"open",C=A==="open"?{dmPolicy:A,allowFrom:["*"]}:{dmPolicy:A};try{const _=await e.client.request("config.get"),B=_.config,z=(P=B==null?void 0:B.channels)==null?void 0:P.whatsapp,be=((z==null?void 0:z.accounts)??{})[w.accountId]?{channels:{whatsapp:{accounts:{[w.accountId]:C}}}}:{channels:{whatsapp:C}};await e.client.request("config.patch",{raw:JSON.stringify(be),baseHash:_.hash,note:`WhatsApp DM policy → ${A}`,skipRestart:!0}),await Y(e,!1)}catch(_){console.error("DM toggle failed:",_)}},whatsappModel:(()=>{var P,_;const h=le(e);if(!h)return null;const b=h.agents.find(B=>B.id.endsWith("-public")||B.id==="public");if(!b)return null;const w=(P=e.configSnapshot)==null?void 0:P.config,x=(_=w==null?void 0:w.agents)==null?void 0:_.list;if(!Array.isArray(x))return null;const A=x.find(B=>B.id===b.id);if(!(A!=null&&A.model))return null;const C=typeof A.model=="string"?A.model:A.model.primary;return(C==null?void 0:C.trim())||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async h=>{const b=le(e);if(!b)return;const w=b.agents.find(x=>x.id.endsWith("-public")||x.id==="public");if(w)try{const x=await e.client.request("config.get"),A=x.config,C=(A==null?void 0:A.agents)??{},P=Array.isArray(C.list)?[...C.list]:[],_=P.findIndex(z=>z.id===w.id);if(h)_>=0?P[_]={...P[_],model:h}:P.push({id:w.id,model:h});else if(_>=0){const{model:z,...te}=P[_];Object.keys(te).length<=1?P.splice(_,1):P[_]=te}const B=P.length>0?{agents:{list:P}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(B),baseHash:x.hash,note:`Public agent model → ${h||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(x){console.error("Model change failed:",x)}},whatsappThinkingLevel:(()=>{var C,P,_;const h=le(e);if(!h)return null;const b=h.agents.find(B=>B.id.endsWith("-public")||B.id==="public");if(!b)return null;const w=(C=e.configSnapshot)==null?void 0:C.config,x=(P=w==null?void 0:w.agents)==null?void 0:P.list;if(!Array.isArray(x))return null;const A=x.find(B=>B.id===b.id);return((_=A==null?void 0:A.thinkingLevel)==null?void 0:_.trim())||null})(),onWhatsAppThinkingChange:async h=>{const b=le(e);if(!b)return;const w=b.agents.find(x=>x.id.endsWith("-public")||x.id==="public");if(w)try{const x=await e.client.request("config.get"),A=x.config,C=(A==null?void 0:A.agents)??{},P=Array.isArray(C.list)?[...C.list]:[],_=P.findIndex(te=>te.id===w.id),B=h==="off"?void 0:h;if(B)_>=0?P[_]={...P[_],thinkingLevel:B}:P.push({id:w.id,thinkingLevel:B});else if(_>=0){const{thinkingLevel:te,...be}=P[_];Object.keys(be).length<=1?P.splice(_,1):P[_]=be}const z=P.length>0?{agents:{list:P}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(z),baseHash:x.hash,note:`Public agent thinking → ${B||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(x){console.error("Thinking change failed:",x)}},whatsappGroupPolicy:(()=>{var _,B;const h=(_=e.configSnapshot)==null?void 0:_.config,b=(B=h==null?void 0:h.channels)==null?void 0:B.whatsapp,w=le(e),x=w==null?void 0:w.whatsappAccountId,A=(b==null?void 0:b.accounts)??{},C=x?A[x]:void 0;return(C==null?void 0:C.groupPolicy)??(b==null?void 0:b.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var B,z;const h=(B=e.configSnapshot)==null?void 0:B.config,b=(z=h==null?void 0:h.channels)==null?void 0:z.whatsapp,w=le(e),x=w==null?void 0:w.whatsappAccountId,A=(b==null?void 0:b.accounts)??{},C=x?A[x]:void 0,_=((C==null?void 0:C.groups)??(b==null?void 0:b.groups)??{})["*"];return(_==null?void 0:_.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var w;const h=le(e),b=h==null?void 0:h.whatsappAccountId;try{const x=await e.client.request("config.get"),A=x.config,C=((w=A==null?void 0:A.channels)==null?void 0:w.whatsapp)??{},P=C.accounts??{},_=b?P[b]:void 0,B=(_==null?void 0:_.groupPolicy)??C.groupPolicy??"allowlist",z=B==="disabled"||B==="allowlist",te=z?"open":"disabled",be=z?{"*":{}}:void 0,X={groupPolicy:te};be&&(X.groups=be);const at=_?{channels:{whatsapp:{accounts:{[b]:X}}}}:{channels:{whatsapp:X}};await e.client.request("config.patch",{raw:JSON.stringify(at),baseHash:x.hash,note:`WhatsApp groups → ${te}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(x){console.error("Group toggle failed:",x)}},onWhatsAppGroupMentionChange:async h=>{var x;const b=le(e),w=b==null?void 0:b.whatsappAccountId;try{const A=await e.client.request("config.get"),C=A.config,_=(((x=C==null?void 0:C.channels)==null?void 0:x.whatsapp)??{}).accounts??{},B=w?_[w]:void 0,z={"*":{requireMention:h}},te=B?{channels:{whatsapp:{accounts:{[w]:{groups:z}}}}}:{channels:{whatsapp:{groups:z}}};await e.client.request("config.patch",{raw:JSON.stringify(te),baseHash:A.hash,note:`WhatsApp group mention → ${h?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Group mention change failed:",A)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:f.configured,imessageRunning:f.running,imessageConnected:f.connected,imessageLastError:f.lastError,imessageSelfChatMode:f.selfChatMode,imessageCliPath:f.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:v,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const h=await e.client.request("config.get"),b=h.config,w=(b==null?void 0:b.bindings)??[],x=le(e),A=x==null?void 0:x.agents.find(z=>z.id.endsWith("-admin")||z.id==="admin"),C=(A==null?void 0:A.id)??"admin",P=w.filter(z=>{var te;return((te=z.match)==null?void 0:te.channel)!=="imessage"}),_=[{agentId:C,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],B=[...P,..._];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:B}),baseHash:h.hash,note:"Enable iMessage (self-chat) for "+((x==null?void 0:x.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Y(e,!0),Fe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await Y(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const h=await e.client.request("config.get"),b=h.config,x=((b==null?void 0:b.bindings)??[]).filter(A=>{var C;return((C=A.match)==null?void 0:C.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:x}),baseHash:h.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Y(e,!0),Fe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const h=await e.client.request("config.get"),b=h.config,w=(b==null?void 0:b.bindings)??[],x=le(e),A=x==null?void 0:x.agents.find(B=>B.id.endsWith("-admin")||B.id==="admin"),C=(A==null?void 0:A.id)??"admin",P=w.filter(B=>{var z;return((z=B.match)==null?void 0:z.channel)!=="imessage"}),_=[{agentId:C,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,..._]}),baseHash:h.hash,note:"Reassign iMessage to "+((x==null?void 0:x.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Y(e,!0),Fe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:h=>{e.infoModalOpen=h},onInfoModalClose:()=>{e.infoModalOpen=null},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(h,b)=>{e.apiKeySavingProvider=h,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await _l(e.client,h,b);const w=`${h} key saved`;e.apiKeySuccess=w,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await wi(e.client)}catch{}h==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===w&&(e.apiKeySuccess=null)},2500)}catch(w){e.apiKeyError=w instanceof Error?w.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async h=>{e.apiKeySavingProvider=h,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Ww(e.client,h);const b=`${h} key removed`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await wi(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(h,b)=>{e.apiKeySavingProvider=h,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Kw(e.client,h,b);const w=`${h} ${b?"disabled":"enabled"}`;e.apiKeySuccess=w,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await wi(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===w&&(e.apiKeySuccess=null)},2500)}catch(w){e.apiKeyError=w instanceof Error?w.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:h=>{e.authApiKeyInput=h},onAuthApiKeySubmit:async()=>{const h=e.authApiKeyInput.trim();if(h){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await _l(e.client,"anthropic",h),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 h=e.selectedWorkspace??((b=e.workspaces[0])==null?void 0:b.name);return h?e.accessState.accounts.some(w=>w.id===h):!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:(h,b)=>{var x;const w=e.selectedWorkspace??((x=e.workspaces[0])==null?void 0:x.name);w&&e.handleAccountPinSave(w,h,b)},publicChatEnabled:(()=>{var w;const h=(w=e.configSnapshot)==null?void 0:w.config,b=h==null?void 0:h.publicChat;return(b==null?void 0:b.enabled)===!0})(),publicChatAuthMode:(()=>{var x;const h=(x=e.configSnapshot)==null?void 0:x.config,b=h==null?void 0:h.publicChat,w=b==null?void 0:b.auth;return w==="verified"||w==="choice"?w:"anonymous"})(),publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var h;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get"),w=b.config,x=((h=w==null?void 0:w.publicChat)==null?void 0:h.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!x}}),baseHash:b.hash,note:`Public chat → ${x?"disabled":"enabled"}`}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Public chat toggle failed:",b)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async h=>{if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{auth:h}}),baseHash:b.hash,note:`Public chat auth → ${h}`}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Public chat auth mode change failed:",b)}finally{e.publicChatToggleBusy=!1}}},brandAccentColor:(()=>{var w;const h=e.selectedWorkspace;return h?((w=Re()[h])==null?void 0:w.accentColor)??"":""})(),brandBackgroundColor:(()=>{var w;const h=e.selectedWorkspace;return h?((w=Re()[h])==null?void 0:w.backgroundColor)??"":""})(),brandHasLogo:(()=>{var w;const h=e.selectedWorkspace;return h?!!((w=Re()[h])!=null&&w.logoUrl):!1})(),brandingBusy:e.brandingBusy,brandingExpanded:e.brandingExpanded,onBrandingToggle:()=>{e.brandingExpanded=!e.brandingExpanded},onBrandAccentColorChange:async h=>{var w;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const x=await e.client.request("config.get"),A=x.config,C=((w=A==null?void 0:A.workspaces)==null?void 0:w[b])??{},P=C.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...C,brand:{...P,accentColor:h}}}}),baseHash:x.hash,note:`Brand accent → ${h}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const _=Re();_[b]||(_[b]={}),_[b].accentColor=h,kn(b)}catch(x){console.error("Brand accent change failed:",x)}finally{e.brandingBusy=!1}}},onBrandBackgroundColorChange:async h=>{var w;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const x=await e.client.request("config.get"),A=x.config,C=((w=A==null?void 0:A.workspaces)==null?void 0:w[b])??{},P=C.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...C,brand:{...P,backgroundColor:h}}}}),baseHash:x.hash,note:`Brand background → ${h}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const _=Re();_[b]||(_[b]={}),_[b].backgroundColor=h,kn(b)}catch(x){console.error("Brand background change failed:",x)}finally{e.brandingBusy=!1}}},onBrandLogoUpload:async h=>{const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const w=await h.arrayBuffer(),x=new Uint8Array(w);let A="";for(let _=0;_<x.length;_++)A+=String.fromCharCode(x[_]);const C=btoa(A);await e.client.request("brand.uploadLogo",{workspace:b,data:C,mimeType:h.type});const P=Re();P[b]||(P[b]={}),P[b].logoUrl=`/brand-logo/${encodeURIComponent(b)}`}catch(w){console.error("Brand logo upload failed:",w)}finally{e.brandingBusy=!1}}},onBrandLogoRemove:async()=>{const h=e.selectedWorkspace;if(!(!h||e.brandingBusy)){e.brandingBusy=!0;try{await e.client.request("brand.removeLogo",{workspace:h});const b=Re();b[h]&&delete b[h].logoUrl}catch(b){console.error("Brand logo remove failed:",b)}finally{e.brandingBusy=!1}}},onBrandReset:async()=>{var b;const h=e.selectedWorkspace;if(!(!h||e.brandingBusy)){e.brandingBusy=!0;try{const w=await e.client.request("config.get"),x=w.config,A=((b=x==null?void 0:x.workspaces)==null?void 0:b[h])??{},{brand:C,...P}=A;await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[h]:{...P,brand:null}}}),baseHash:w.hash,note:"Brand reset to defaults",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");try{await e.client.request("brand.removeLogo",{workspace:h})}catch{}const _=Re();delete _[h],kn(h)}catch(w){console.error("Brand reset failed:",w)}finally{e.brandingBusy=!1}}},tailscaleStatus:e.tailscaleStatus,tailscaleBusy:e.tailscaleBusy,tailscaleAuthUrl:e.tailscaleAuthUrl,tailscaleError:e.tailscaleError,tailscaleFunnelEnableUrl:e.tailscaleFunnelEnableUrl,tailscaleDisableConfirm:e.tailscaleDisableConfirm,onTailscaleEnable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleAuthUrl=null;try{const h=await e.client.request("tailscale.enable");if(h.authUrl){e.tailscaleAuthUrl=h.authUrl;const b=setInterval(async()=>{try{const w=await e.client.request("tailscale.status");e.tailscaleStatus=w,w.loggedIn&&(clearInterval(b),e.tailscaleAuthUrl=null,e.tailscaleBusy=!1)}catch{}},3e3);setTimeout(()=>{clearInterval(b),e.tailscaleBusy&&(e.tailscaleBusy=!1)},3e5)}else h.alreadyLoggedIn&&(e.tailscaleStatus=await e.client.request("tailscale.status")),e.tailscaleBusy=!1}catch(h){console.error("Tailscale enable failed:",h),e.tailscaleBusy=!1}}},onTailscaleServeEnable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null;try{await e.client.request("tailscale.serve.enable"),await S()}catch(h){console.error("Tailscale serve enable failed:",h),e.tailscaleError=h.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(h){console.error("Tailscale serve disable failed:",h)}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelEnable:async()=>{var h;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 w=b;(h=w.payload)!=null&&h.enableUrl&&(e.tailscaleFunnelEnableUrl=w.payload.enableUrl),e.tailscaleError=w.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(h){console.error("Tailscale funnel disable failed:",h)}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()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{const[h,b]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);e.wifiNetworks=h.networks,e.wifiStatus=b}catch(h){console.error("WiFi scan failed:",h),e.wifiError=h.message||"Failed to scan networks"}finally{e.wifiBusy=!1}}},onWifiConnect:async()=>{if(e.wifiBusy||!e.wifiSelectedSsid)return;const h=e.wifiSelectedSsid;e.wifiBusy=!0,e.wifiError=null;try{const b=await e.client.request("wifi.connect",{ssid:h,password:e.wifiPassword});e.wifiPassword="",e.wifiSelectedSsid=null,e.wifiNetworks=[],e.wifiStatus={available:!0,connected:b.connected,ssid:b.ssid,signal:null,ip:b.ip,savedSsid:b.ssid,autoconnect:!0},e.wifiBusy=!1;try{const w=await e.client.request("wifi.status");e.wifiStatus=w}catch{}}catch(b){console.error("WiFi connect failed:",b),e.wifiError=b.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 h=await e.client.request("wifi.status");e.wifiStatus=h}catch(h){console.error("WiFi disconnect failed:",h),e.wifiError=h.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 h=await e.client.request("wifi.status");e.wifiStatus=h}catch(h){console.error("WiFi forget failed:",h),e.wifiError=h.message||"Failed to forget network"}finally{e.wifiBusy=!1}}},onWifiDismiss:()=>{e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null},onWifiSelectSsid:h=>{e.wifiSelectedSsid=h,e.wifiPassword="",e.wifiError=null},onWifiPasswordChange:h=>{e.wifiPassword=h},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:h=>{e.networkPortInput=h,e.networkError=null,e.networkSuccess=null},onNetworkHostnameChange:h=>{e.networkHostnameInput=h,e.networkError=null,e.networkSuccess=null},onNetworkSave:async()=>{if(e.networkBusy)return;e.networkBusy=!0,e.networkError=null,e.networkSuccess=null;const h=e.networkPortInput.trim(),b=Number.parseInt(h,10),w=e.networkHostnameInput.trim();if(!h||!Number.isFinite(b)||b<1024||b>65535){e.networkError="Port must be a number between 1024 and 65535",e.networkBusy=!1;return}const x=b!==e.networkPort,A=w!==e.networkHostname;if(!x&&!A){e.networkBusy=!1;return}try{A&&await e.client.request("network.setHostname",{hostname:w});const C={};x&&(C.gateway={port:b}),A&&(C.discovery={bonjourHostname:w});const P=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify(C),baseHash:P.hash,note:[x?`Port → ${b}`:null,A?`Hostname → ${w}`:null].filter(Boolean).join(", "),restartDelayMs:2e3}),e.networkSuccess="Saved — redirecting...";const _=window.location.protocol,B=A?`${w}.local`:window.location.hostname,z=x?b:e.networkPort,te=`${_}//${B}:${z}/setup`;setTimeout(()=>{window.location.href=te},1500)}catch(C){console.error("Network save failed:",C),e.networkError=C.message||"Failed to save network settings",e.networkBusy=!1}},wsProps:fk(e)})}if(e.filesPage){const l=yk(e);return cg({connected:e.connected,wsProps:yn(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:()=>Zt(e,l),onReindex:()=>Af(e,l),onSelectFile:p=>{e.filesPendingDeletePath=null,yf(e,p,l)},onToggleSelectFile:p=>vf(e,p,l),onToggleDir:p=>Ef(e,p),onUpload:(p,f)=>kf(e,p,f,l),onNewFolder:(p,f)=>$f(e,p,f,l),onDownload:p=>od(e,p,l),onBulkDownload:()=>bf(e,l),onDelete:p=>{e.filesPendingDeletePath=null,Sf(e,p,l)},pendingDeletePath:e.filesPendingDeletePath,onArmDelete:p=>{e.filesPendingDeletePath=p||null},onMoveToDir:(p,f)=>wf(e,p,f,l),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:p=>{const f=e.filesSearchAgentId??l;Cf(e,p,f)},onSearchAgentChange:p=>{e.filesSearchAgentId=p},onSearchClear:()=>{Tf(e)},onSearchQueryChange:p=>{e.filesSearchQuery=p}})}if(e.browserPage)return ig({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:()=>Iw(e),onStop:()=>Rw(e),onToggleInput:()=>Nw(e),onToggleFullscreen:()=>Bw(e),onCompleteHandoff:()=>Dw(e),onCanvasMouseDown:l=>{const f=l.target.getBoundingClientRect(),S=_n().translateCoordinates(l.clientX-f.left,l.clientY-f.top);Ys(e,"mousePressed",S.x,S.y,l.button===2?"right":l.button===1?"middle":"left")},onCanvasMouseUp:l=>{const f=l.target.getBoundingClientRect(),S=_n().translateCoordinates(l.clientX-f.left,l.clientY-f.top);Ys(e,"mouseReleased",S.x,S.y)},onCanvasMouseMove:l=>{const p=_n();if(p.shouldThrottleMouseMove())return;const v=l.target.getBoundingClientRect(),S=p.translateCoordinates(l.clientX-v.left,l.clientY-v.top);Ys(e,"mouseMoved",S.x,S.y)},onCanvasKeyDown:l=>{let p=0;l.altKey&&(p|=1),l.ctrlKey&&(p|=2),l.metaKey&&(p|=4),l.shiftKey&&(p|=8),Xs(e,"keyDown",l.key,{code:l.code,modifiers:p||void 0}),l.key.length===1&&Xs(e,"char",l.key,{text:l.key})},onCanvasKeyUp:l=>{Xs(e,"keyUp",l.key,{code:l.code})}});if(e.adminsPage){const l=gk(e),p=mk(e);return Tg({connected:e.connected,wsProps:yn(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>is(e,l),onAdd:f=>{_u(e,f,l,p).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:f=>Mu(e,f,l,p),onNewPhoneChange:f=>e.handleAdminsNewPhoneChange(f)})}if(e.contactsPage){const l=vk(e);return Rg({connected:e.connected,wsProps:yn(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:()=>_t(e,l),onAdd:(p,f)=>Pu(e,p,f,l),onDelete:p=>Lu(e,p,l),onSetField:(p,f,v)=>Mo(e,p,f,v,l),onDeleteField:(p,f)=>Iu(e,p,f,l),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:()=>_t(e,l),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,f=e.contactsAddFieldKey.trim();!p||!f||(Mo(e,p,f,e.contactsAddFieldValue,l),e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue="")}})}if(e.chatPage){const l=e.connected?null:"Disconnected from gateway.",p=Bl(e),f=e.chatAvatarUrl??p??null,v=(()=>{var b;const S=(b=e.configSnapshot)==null?void 0:b.config,h=S==null?void 0:S.publicChat;return(h==null?void 0:h.enabled)===!0})();return Ib({connected:e.connected,wsProps:yn(e),publicChatEnabled:v,publicChatAccountId:e.selectedWorkspace??void 0,sessionKey:e.sessionKey,onSessionKeyChange:S=>{const h=e.selectedWorkspace??"";so(),In(h,e.sessionKey,e.chatMessage),e.sessionKey=S,e.chatMessage=Rn(h,S),e.chatAttachments=[],e.chatStream=null,e.chatInterimText=null,e.chatSuggestion=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:S,lastActiveSessionKey:S}),e.loadAssistantIdentity(),Ne(e),po(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:S=>{const h=Math.max(e.chatMessages.length+10,Be);ti(e,e.sessionKey,{model:S}).then(()=>{Ne(e,{limit:h})})},onThinkingLevelChange:S=>{const h=Math.max(e.chatMessages.length+10,Be);ti(e,e.sessionKey,{thinkingLevel:S==="off"?null:S}).then(()=>{Ne(e,{limit:h})})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,suggestion:e.chatSuggestion,onSuggestionClick:S=>{e.chatMessage=S,e.chatSuggestion=null,e.handleSendChat()},onVerboseChange:S=>{const h=Math.max(e.chatMessages.length+10,Be);ti(e,e.sessionKey,{verboseLevel:S==="off"?null:S}).then(()=>{Ne(e,{limit:h})})},onFillerChange:S=>{const h=Math.max(e.chatMessages.length+10,Be);ti(e,e.sessionKey,{fillerEnabled:S}).then(()=>{Ne(e,{limit:h})})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:f,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:l,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>{e.resetToolStream();const S=Math.max(e.chatMessages.length+10,Be);return Promise.all([Ne(e,{limit:S}),po(e)])},onToggleFocusMode:()=>{},onChatScroll:S=>e.handleChatScroll(S),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:S=>{e.chatMessage=S,sa(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?ww({connected:e.connected,wsProps:yn(e),activeTab:e.advancedTab,onTabChange:l=>{e.advancedTab=l,l==="cron"&&e.loadCron(),l==="skills"&&Ge(e,{clearMessages:!0}),l==="logs"&&(e.logsSubTab==="session"?xn(e,{reset:!0}):Ht(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(r=(o=e.channelsSnapshot)==null?void 0:o.channelMeta)!=null&&r.length?e.channelsSnapshot.channelMeta.map(l=>l.id):((a=e.channelsSnapshot)==null?void 0:a.channelOrder)??[],channelLabels:((d=e.channelsSnapshot)==null?void 0:d.channelLabels)??{},channelMeta:((c=e.channelsSnapshot)==null?void 0:c.channelMeta)??[],agentIds:(()=>{var p;const l=le(e);return((p=l==null?void 0:l.agents)==null?void 0:p.map(f=>f.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:l=>{e.cronDetailJobId=l.id,ro(e,l.id)},onDetailClose:()=>{e.cronDetailJobId=null},onEdit:l=>{e.cronForm=kh(l),e.cronEditJobId=l.id,e.cronDetailJobId=null},onEditSave:()=>{const l=e.cronEditJobId;l&&$h(e,l).then(()=>{e.cronEditJobId=null})},onFormChange:l=>e.cronForm={...e.cronForm,...l},onRefresh:()=>e.loadCron(),onAdd:()=>{mh(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(l,p)=>yh(e,l,p),onRun:l=>vh(e,l),onRemove:l=>{e.cronPendingDeleteId=null,wh(e,l)},pendingDeleteId:e.cronPendingDeleteId,onArmDelete:l=>{e.cronPendingDeleteId=l||null},onLoadRuns:l=>ro(e,l),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:l=>e.skillsFilter=l,onTypeFilterChange:l=>e.skillsTypeFilter=l,onRefresh:()=>Ge(e,{clearMessages:!0}),onToggle:(l,p)=>Bc(e,l,p),onEdit:(l,p)=>Nc(e,l,p),onSaveKey:l=>Fc(e,l),onInstall:(l,p,f)=>Oc(e,l,p,f),onViewDetail:l=>Uc(e,l),onDetailClose:()=>Wc(e),onDetailTab:l=>Kc(e,l),onAddOpen:()=>zc(e),onAddClose:()=>Hc(e),onImportDraft:l=>qc(e,l),onInstallDraft:l=>jc(e,l),onDeleteDraft:l=>Vc(e,l),onAddSave:()=>Go(e),onAddFormUpdate:(l,p)=>{e.skillAddForm={...e.skillAddForm,[l]:p}},onDelete:l=>Xc(e,l),onEditSkill:l=>Gc(e,l),onEditDetail:l=>Qc(e,l),onRefUpdate:(l,p)=>Jc(e,l,p),onEditTab:l=>Yc(e,l)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:l=>{e.logsSubTab=l,l==="session"?xn(e,{reset:!0}):Ht(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:l=>e.sessionLogsFilterText=l,onTypeToggle:(l,p)=>{const f=e;f.sessionLogsTypeFilters={...f.sessionLogsTypeFilters,[l]:p}},onAgentToggle:(l,p)=>{const f=e;f.sessionLogsAgentFilters={...f.sessionLogsAgentFilters,[l]:p}},onToggleAutoFollow:l=>e.sessionLogsAutoFollow=l,onToggleChips:()=>{const l=e;l.sessionLogsChipsExpanded=!l.sessionLogsChipsExpanded},onToggleExpand:l=>{const p=e,f=new Set(p.sessionLogsExpandedIds);f.has(l)?f.delete(l):f.add(l),p.sessionLogsExpandedIds=f,p.requestUpdate()},onRefresh:()=>{xn(e,{reset:!0})},onExport:(l,p)=>e.exportSessionLogs(l,p),onScroll:l=>e.handleSessionLogsScroll(l)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,chipsExpanded:e.logsChipsExpanded,truncated:e.logsTruncated,onFilterTextChange:l=>e.logsFilterText=l,onLevelToggle:(l,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[l]:p}},onToggleAutoFollow:l=>e.logsAutoFollow=l,onToggleChips:()=>{const l=e;l.logsChipsExpanded=!l.logsChipsExpanded},onRefresh:()=>Ht(e,{reset:!0}),onExport:(l,p)=>e.exportSessionLogs(l,p),onScroll:l=>e.handleLogsScroll(l)}}):(window.location.replace("/chat"),u``)}function Ak(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 Fl(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function Ek(e,t,n){return u`
|
|
4192
|
+
`;if(e.connected&&e.accessState.checked){const{accessState:l}=e;if(l.hasPins&&!l.authenticated)return Cl({show:!0,isFirstTime:!1,accounts:l.accounts,error:l.error,busy:l.busy,onSubmit:(p,h)=>{h!=null&&e.handlePinSubmit(p,h)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(p,h,v)=>e.handleChangePin(p,h,v)});if(!l.hasMasterPin&&!l.authenticated&&e.setup)return Cl({show:!0,isFirstTime:!0,accounts:[],error:l.error,busy:l.busy,onSubmit:p=>e.handleSetMasterPin(p)});if(!l.hasMasterPin&&!l.authenticated&&!e.setup)return window.location.href="/setup",k}if(e.setup){const l=kk(e.channelsSnapshot),p=((n=(t=e.channelsSnapshot)==null?void 0:t.channelAccounts)==null?void 0:n.whatsapp)??[],h=$k(e.channelsSnapshot),v=Sk(e),S=async()=>{e.tailscaleStatus=await e.client.request("tailscale.status")};return Eg({connected:e.connected,serverPlatform:((s=(i=e.hello)==null?void 0:i.server)==null?void 0:s.platform)??null,assistantName:e.assistantName,currentStep:e.setupStep,licenseKey:e.licenseKey,licenseBusy:e.licenseBusy,licenseValid:e.licenseValid,licenseMessage:e.licenseMessage,licenseTier:e.licenseTier,licenseDeviceId:e.licenseDeviceId,licenseStoredKey:e.licenseStoredKey,onLicenseKeyChange:f=>e.handleLicenseKeyChange(f),onLicenseActivate:()=>e.handleLicenseActivate(),onLicenseRemove:async()=>{await e.handleLicenseRemove(),e.licenseRemoveConfirm=!1},licenseRemoveConfirm:e.licenseRemoveConfirm,onLicenseRemoveConfirm:()=>{e.licenseRemoveConfirm=!0},onLicenseRemoveCancel:()=>{e.licenseRemoveConfirm=!1},authConnected:e.authConnected,authBusy:e.authBusy,authMessage:e.authMessage,authUrl:e.authUrl,authCodeInput:e.authCodeInput,authExpiresIn:e.authExpiresIn,whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:l,whatsappAccounts:p,whatsappActiveQrAccountId:e.whatsappActiveQrAccountId,whatsappAccountSaving:e.whatsappAccountSaving,gatewayHealthy:e.gatewayHealthy,gatewayHealthLoading:e.gatewayHealthLoading,gatewayHealthMessage:e.gatewayHealthMessage,gatewayRestartBusy:e.gatewayRestartBusy,updateAvailable:e.updateAvailable,currentVersion:e.currentVersion,latestVersion:e.latestVersion,updateChecking:e.updateChecking,updateRunning:e.updateRunning,updateMessage:e.updateMessage,updateProgressSteps:e.updateProgressSteps,updateLastResult:e.updateLastResult,onUpdateCheck:()=>e.handleUpdateCheck(),onUpdateRun:()=>e.handleUpdateRun(),onUpdateDismissResult:()=>e.handleUpdateDismissResult(),uninstallConfirm:e.uninstallConfirm,uninstallBusy:e.uninstallBusy,uninstallDone:e.uninstallDone,uninstallError:e.uninstallError,uninstallConfirmText:e.uninstallConfirmText,onUninstallConfirm:()=>e.handleUninstallConfirm(),onUninstallCancel:()=>e.handleUninstallCancel(),onUninstallConfirmTextChange:f=>e.handleUninstallConfirmTextChange(f),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:f=>e.handleAuthSubmitCode(f),onAuthCodeChange:f=>e.handleAuthCodeChange(f),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async f=>{await e.handleWhatsAppStart(!0,f),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(f),await Y(e,!0),e.requestUpdate())},onWhatsAppUnlink:async f=>{await e.handleWhatsAppLogout(f)},onWhatsAppReset:async f=>{await e.handleWhatsAppLogout(f),await e.handleWhatsAppStart(!0,f),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(f),await Y(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await Y(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),Y(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:f=>e.handleRemoveWhatsAppAccount(f),workspaces:e.workspaces,workspacesLoading:e.workspacesLoading,workspacesError:e.workspacesError,addingWorkspace:e.addingWorkspace,newWorkspaceName:e.newWorkspaceName,newWorkspacePath:e.newWorkspacePath,workspaceSaving:e.workspaceSaving,workspaceRemoveConfirm:e.workspaceRemoveConfirm,newWorkspacePin:e.newWorkspacePin,onSetNewWorkspacePin:f=>{e.newWorkspacePin=f},onWorkspaceCreate:async(f,w)=>{const b=e.newWorkspacePin;await e.handleWorkspaceCreate(f,w),b.match(/^\d{4,6}$/)&&(await ck(e,f,b),e.newWorkspacePin="")},onWorkspaceRemove:f=>e.handleWorkspaceRemove(f),onSetAddingWorkspace:f=>{e.addingWorkspace=f},onSetNewWorkspaceName:f=>{e.newWorkspaceName=f},onSetNewWorkspacePath:f=>{e.newWorkspacePath=f},onSetWorkspaceRemoveConfirm:f=>{e.workspaceRemoveConfirm=f},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(f,w)=>e.handleWorkspaceRename(f,w),whatsappDmPolicy:(()=>{const f=le(e),w=f==null?void 0:f.whatsappAccountId,b=w?p.find(x=>x.accountId===w):p[0];return(b==null?void 0:b.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var M;const f=le(e),w=f==null?void 0:f.whatsappAccountId,b=w?p.find(_=>_.accountId===w):p[0];if(!b)return;const A=b.dmPolicy!=null&&b.dmPolicy!=="disabled"?"disabled":"open",C=A==="open"?{dmPolicy:A,allowFrom:["*"]}:{dmPolicy:A};try{const _=await e.client.request("config.get"),B=_.config,z=(M=B==null?void 0:B.channels)==null?void 0:M.whatsapp,be=((z==null?void 0:z.accounts)??{})[b.accountId]?{channels:{whatsapp:{accounts:{[b.accountId]:C}}}}:{channels:{whatsapp:C}};await e.client.request("config.patch",{raw:JSON.stringify(be),baseHash:_.hash,note:`WhatsApp DM policy → ${A}`,skipRestart:!0}),await Y(e,!1)}catch(_){console.error("DM toggle failed:",_)}},whatsappModel:(()=>{var M,_;const f=le(e);if(!f)return null;const w=f.agents.find(B=>B.id.endsWith("-public")||B.id==="public");if(!w)return null;const b=(M=e.configSnapshot)==null?void 0:M.config,x=(_=b==null?void 0:b.agents)==null?void 0:_.list;if(!Array.isArray(x))return null;const A=x.find(B=>B.id===w.id);if(!(A!=null&&A.model))return null;const C=typeof A.model=="string"?A.model:A.model.primary;return(C==null?void 0:C.trim())||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async f=>{const w=le(e);if(!w)return;const b=w.agents.find(x=>x.id.endsWith("-public")||x.id==="public");if(b)try{const x=await e.client.request("config.get"),A=x.config,C=(A==null?void 0:A.agents)??{},M=Array.isArray(C.list)?[...C.list]:[],_=M.findIndex(z=>z.id===b.id);if(f)_>=0?M[_]={...M[_],model:f}:M.push({id:b.id,model:f});else if(_>=0){const{model:z,...te}=M[_];Object.keys(te).length<=1?M.splice(_,1):M[_]=te}const B=M.length>0?{agents:{list:M}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(B),baseHash:x.hash,note:`Public agent model → ${f||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(x){console.error("Model change failed:",x)}},whatsappThinkingLevel:(()=>{var C,M,_;const f=le(e);if(!f)return null;const w=f.agents.find(B=>B.id.endsWith("-public")||B.id==="public");if(!w)return null;const b=(C=e.configSnapshot)==null?void 0:C.config,x=(M=b==null?void 0:b.agents)==null?void 0:M.list;if(!Array.isArray(x))return null;const A=x.find(B=>B.id===w.id);return((_=A==null?void 0:A.thinkingLevel)==null?void 0:_.trim())||null})(),onWhatsAppThinkingChange:async f=>{const w=le(e);if(!w)return;const b=w.agents.find(x=>x.id.endsWith("-public")||x.id==="public");if(b)try{const x=await e.client.request("config.get"),A=x.config,C=(A==null?void 0:A.agents)??{},M=Array.isArray(C.list)?[...C.list]:[],_=M.findIndex(te=>te.id===b.id),B=f==="off"?void 0:f;if(B)_>=0?M[_]={...M[_],thinkingLevel:B}:M.push({id:b.id,thinkingLevel:B});else if(_>=0){const{thinkingLevel:te,...be}=M[_];Object.keys(be).length<=1?M.splice(_,1):M[_]=be}const z=M.length>0?{agents:{list:M}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(z),baseHash:x.hash,note:`Public agent thinking → ${B||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(x){console.error("Thinking change failed:",x)}},whatsappGroupPolicy:(()=>{var _,B;const f=(_=e.configSnapshot)==null?void 0:_.config,w=(B=f==null?void 0:f.channels)==null?void 0:B.whatsapp,b=le(e),x=b==null?void 0:b.whatsappAccountId,A=(w==null?void 0:w.accounts)??{},C=x?A[x]:void 0;return(C==null?void 0:C.groupPolicy)??(w==null?void 0:w.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var B,z;const f=(B=e.configSnapshot)==null?void 0:B.config,w=(z=f==null?void 0:f.channels)==null?void 0:z.whatsapp,b=le(e),x=b==null?void 0:b.whatsappAccountId,A=(w==null?void 0:w.accounts)??{},C=x?A[x]:void 0,_=((C==null?void 0:C.groups)??(w==null?void 0:w.groups)??{})["*"];return(_==null?void 0:_.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var b;const f=le(e),w=f==null?void 0:f.whatsappAccountId;try{const x=await e.client.request("config.get"),A=x.config,C=((b=A==null?void 0:A.channels)==null?void 0:b.whatsapp)??{},M=C.accounts??{},_=w?M[w]:void 0,B=(_==null?void 0:_.groupPolicy)??C.groupPolicy??"allowlist",z=B==="disabled"||B==="allowlist",te=z?"open":"disabled",be=z?{"*":{}}:void 0,X={groupPolicy:te};be&&(X.groups=be);const at=_?{channels:{whatsapp:{accounts:{[w]:X}}}}:{channels:{whatsapp:X}};await e.client.request("config.patch",{raw:JSON.stringify(at),baseHash:x.hash,note:`WhatsApp groups → ${te}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(x){console.error("Group toggle failed:",x)}},onWhatsAppGroupMentionChange:async f=>{var x;const w=le(e),b=w==null?void 0:w.whatsappAccountId;try{const A=await e.client.request("config.get"),C=A.config,_=(((x=C==null?void 0:C.channels)==null?void 0:x.whatsapp)??{}).accounts??{},B=b?_[b]:void 0,z={"*":{requireMention:f}},te=B?{channels:{whatsapp:{accounts:{[b]:{groups:z}}}}}:{channels:{whatsapp:{groups:z}}};await e.client.request("config.patch",{raw:JSON.stringify(te),baseHash:A.hash,note:`WhatsApp group mention → ${f?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Group mention change failed:",A)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:h.configured,imessageRunning:h.running,imessageConnected:h.connected,imessageLastError:h.lastError,imessageSelfChatMode:h.selfChatMode,imessageCliPath:h.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:v,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),w=f.config,b=(w==null?void 0:w.bindings)??[],x=le(e),A=x==null?void 0:x.agents.find(z=>z.id.endsWith("-admin")||z.id==="admin"),C=(A==null?void 0:A.id)??"admin",M=b.filter(z=>{var te;return((te=z.match)==null?void 0:te.channel)!=="imessage"}),_=[{agentId:C,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],B=[...M,..._];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:B}),baseHash:f.hash,note:"Enable iMessage (self-chat) for "+((x==null?void 0:x.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Y(e,!0),Fe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await Y(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),w=f.config,x=((w==null?void 0:w.bindings)??[]).filter(A=>{var C;return((C=A.match)==null?void 0:C.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:x}),baseHash:f.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Y(e,!0),Fe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),w=f.config,b=(w==null?void 0:w.bindings)??[],x=le(e),A=x==null?void 0:x.agents.find(B=>B.id.endsWith("-admin")||B.id==="admin"),C=(A==null?void 0:A.id)??"admin",M=b.filter(B=>{var z;return((z=B.match)==null?void 0:z.channel)!=="imessage"}),_=[{agentId:C,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:[...M,..._]}),baseHash:f.hash,note:"Reassign iMessage to "+((x==null?void 0:x.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Y(e,!0),Fe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:f=>{e.infoModalOpen=f},onInfoModalClose:()=>{e.infoModalOpen=null},isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,apiKeySavingProvider:e.apiKeySavingProvider,onApiKeyModalOpen:()=>{e.apiKeyModalOpen=!0,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeyModalClose:()=>{e.apiKeyModalOpen=!1,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeySave:async(f,w)=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Ml(e.client,f,w);const b=`${f} key saved`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await wi(e.client)}catch{}f==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async f=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Ww(e.client,f);const w=`${f} key removed`;e.apiKeySuccess=w,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await wi(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===w&&(e.apiKeySuccess=null)},2500)}catch(w){e.apiKeyError=w instanceof Error?w.message:"Failed to remove key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyDisable:async(f,w)=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Kw(e.client,f,w);const b=`${f} ${w?"disabled":"enabled"}`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await wi(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:`Failed to ${w?"disable":"enable"} key`,e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},authApiKeyMode:e.authApiKeyMode,authApiKeyInput:e.authApiKeyInput,authApiKeyBusy:e.authApiKeyBusy,authApiKeyError:e.authApiKeyError,onAuthApiKeyToggle:()=>{e.authApiKeyMode=!e.authApiKeyMode,e.authApiKeyError=null},onAuthApiKeyChange:f=>{e.authApiKeyInput=f},onAuthApiKeySubmit:async()=>{const f=e.authApiKeyInput.trim();if(f){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await Ml(e.client,"anthropic",f),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(w){e.authApiKeyError=w instanceof Error?w.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var w;const f=e.selectedWorkspace??((w=e.workspaces[0])==null?void 0:w.name);return f?e.accessState.accounts.some(b=>b.id===f):!1})(),accountPinModalOpen:e.accountPinModalOpen,accountPinBusy:e.accountPinBusy,accountPinError:e.accountPinError,accountPinSuccess:e.accountPinSuccess,onAccountPinModalOpen:()=>{e.accountPinModalOpen=!0,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinModalClose:()=>{e.accountPinModalOpen=!1,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinSave:(f,w)=>{var x;const b=e.selectedWorkspace??((x=e.workspaces[0])==null?void 0:x.name);b&&e.handleAccountPinSave(b,f,w)},publicChatEnabled:(()=>{var b;const f=(b=e.configSnapshot)==null?void 0:b.config,w=f==null?void 0:f.publicChat;return(w==null?void 0:w.enabled)===!0})(),publicChatAuthMode:(()=>{var x;const f=(x=e.configSnapshot)==null?void 0:x.config,w=f==null?void 0:f.publicChat,b=w==null?void 0:w.auth;return b==="verified"||b==="choice"?b:"anonymous"})(),publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var f;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const w=await e.client.request("config.get"),b=w.config,x=((f=b==null?void 0:b.publicChat)==null?void 0:f.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!x}}),baseHash:w.hash,note:`Public chat → ${x?"disabled":"enabled"}`}),e.configSnapshot=await e.client.request("config.get")}catch(w){console.error("Public chat toggle failed:",w)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async f=>{if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const w=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{auth:f}}),baseHash:w.hash,note:`Public chat auth → ${f}`}),e.configSnapshot=await e.client.request("config.get")}catch(w){console.error("Public chat auth mode change failed:",w)}finally{e.publicChatToggleBusy=!1}}},brandAccentColor:(()=>{var b;const f=e.selectedWorkspace;return f?((b=Re()[f])==null?void 0:b.accentColor)??"":""})(),brandBackgroundColor:(()=>{var b;const f=e.selectedWorkspace;return f?((b=Re()[f])==null?void 0:b.backgroundColor)??"":""})(),brandHasLogo:(()=>{var b;const f=e.selectedWorkspace;return f?!!((b=Re()[f])!=null&&b.logoUrl):!1})(),brandingBusy:e.brandingBusy,brandingExpanded:e.brandingExpanded,onBrandingToggle:()=>{e.brandingExpanded=!e.brandingExpanded},onBrandAccentColorChange:async f=>{var b;const w=e.selectedWorkspace;if(!(!w||e.brandingBusy)){e.brandingBusy=!0;try{const x=await e.client.request("config.get"),A=x.config,C=((b=A==null?void 0:A.workspaces)==null?void 0:b[w])??{},M=C.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[w]:{...C,brand:{...M,accentColor:f}}}}),baseHash:x.hash,note:`Brand accent → ${f}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const _=Re();_[w]||(_[w]={}),_[w].accentColor=f,kn(w)}catch(x){console.error("Brand accent change failed:",x)}finally{e.brandingBusy=!1}}},onBrandBackgroundColorChange:async f=>{var b;const w=e.selectedWorkspace;if(!(!w||e.brandingBusy)){e.brandingBusy=!0;try{const x=await e.client.request("config.get"),A=x.config,C=((b=A==null?void 0:A.workspaces)==null?void 0:b[w])??{},M=C.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[w]:{...C,brand:{...M,backgroundColor:f}}}}),baseHash:x.hash,note:`Brand background → ${f}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const _=Re();_[w]||(_[w]={}),_[w].backgroundColor=f,kn(w)}catch(x){console.error("Brand background change failed:",x)}finally{e.brandingBusy=!1}}},onBrandLogoUpload:async f=>{const w=e.selectedWorkspace;if(!(!w||e.brandingBusy)){e.brandingBusy=!0;try{const b=await f.arrayBuffer(),x=new Uint8Array(b);let A="";for(let _=0;_<x.length;_++)A+=String.fromCharCode(x[_]);const C=btoa(A);await e.client.request("brand.uploadLogo",{workspace:w,data:C,mimeType:f.type});const M=Re();M[w]||(M[w]={}),M[w].logoUrl=`/brand-logo/${encodeURIComponent(w)}`}catch(b){console.error("Brand logo upload failed:",b)}finally{e.brandingBusy=!1}}},onBrandLogoRemove:async()=>{const f=e.selectedWorkspace;if(!(!f||e.brandingBusy)){e.brandingBusy=!0;try{await e.client.request("brand.removeLogo",{workspace:f});const w=Re();w[f]&&delete w[f].logoUrl}catch(w){console.error("Brand logo remove failed:",w)}finally{e.brandingBusy=!1}}},onBrandReset:async()=>{var w;const f=e.selectedWorkspace;if(!(!f||e.brandingBusy)){e.brandingBusy=!0;try{const b=await e.client.request("config.get"),x=b.config,A=((w=x==null?void 0:x.workspaces)==null?void 0:w[f])??{},{brand:C,...M}=A;await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[f]:{...M,brand:null}}}),baseHash:b.hash,note:"Brand reset to defaults",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");try{await e.client.request("brand.removeLogo",{workspace:f})}catch{}const _=Re();delete _[f],kn(f)}catch(b){console.error("Brand reset failed:",b)}finally{e.brandingBusy=!1}}},tailscaleStatus:e.tailscaleStatus,tailscaleBusy:e.tailscaleBusy,tailscaleAuthUrl:e.tailscaleAuthUrl,tailscaleError:e.tailscaleError,tailscaleFunnelEnableUrl:e.tailscaleFunnelEnableUrl,tailscaleDisableConfirm:e.tailscaleDisableConfirm,onTailscaleEnable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleAuthUrl=null;try{const f=await e.client.request("tailscale.enable");if(f.authUrl){e.tailscaleAuthUrl=f.authUrl;const w=setInterval(async()=>{try{const b=await e.client.request("tailscale.status");e.tailscaleStatus=b,b.loggedIn&&(clearInterval(w),e.tailscaleAuthUrl=null,e.tailscaleBusy=!1)}catch{}},3e3);setTimeout(()=>{clearInterval(w),e.tailscaleBusy&&(e.tailscaleBusy=!1)},3e5)}else f.alreadyLoggedIn&&(e.tailscaleStatus=await e.client.request("tailscale.status")),e.tailscaleBusy=!1}catch(f){console.error("Tailscale enable failed:",f),e.tailscaleBusy=!1}}},onTailscaleServeEnable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null;try{await e.client.request("tailscale.serve.enable"),await S()}catch(f){console.error("Tailscale serve enable failed:",f),e.tailscaleError=f.message||"Failed to enable Remote Access"}finally{e.tailscaleBusy=!1}}},onTailscaleServeDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.serve.disable"),await S()}catch(f){console.error("Tailscale serve disable failed:",f)}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelEnable:async()=>{var f;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleFunnelEnableUrl=null;try{await e.client.request("tailscale.funnel.enable"),await S()}catch(w){console.error("Tailscale funnel enable failed:",w);const b=w;(f=b.payload)!=null&&f.enableUrl&&(e.tailscaleFunnelEnableUrl=b.payload.enableUrl),e.tailscaleError=b.message||"Failed to enable Funnel"}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.funnel.disable"),await S()}catch(f){console.error("Tailscale funnel disable failed:",f)}finally{e.tailscaleBusy=!1}}},onTailscaleDisableConfirmToggle:()=>{e.tailscaleDisableConfirm=!e.tailscaleDisableConfirm},wifiModalOpen:e.wifiModalOpen,onWifiModalToggle:()=>{e.wifiModalOpen=!e.wifiModalOpen,e.wifiModalOpen||(e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null)},wifiStatus:e.wifiStatus,wifiNetworks:e.wifiNetworks,wifiBusy:e.wifiBusy,wifiError:e.wifiError,wifiPassword:e.wifiPassword,wifiSelectedSsid:e.wifiSelectedSsid,onWifiScan:async()=>{var f;if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{const[w,b]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(e.wifiNetworks=w.networks,b.connected&&b.signal==null&&((f=w.networks)!=null&&f.length)){const x=w.networks.find(A=>A.active)||w.networks.find(A=>A.ssid===b.ssid);x&&(b.signal=x.signal)}e.wifiStatus=b}catch(w){console.error("WiFi scan failed:",w),e.wifiError=w.message||"Failed to scan networks"}finally{e.wifiBusy=!1}}},onWifiConnect:async()=>{var w;if(e.wifiBusy||!e.wifiSelectedSsid)return;const f=e.wifiSelectedSsid;e.wifiBusy=!0,e.wifiError=null;try{const b=await e.client.request("wifi.connect",{ssid:f,password:e.wifiPassword});e.wifiPassword="",e.wifiSelectedSsid=null,e.wifiNetworks=[],e.wifiStatus={available:!0,connected:b.connected,ssid:b.ssid,signal:null,ip:b.ip,savedSsid:b.ssid,autoconnect:!0},e.wifiBusy=!1;try{const[x,A]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(A.connected&&A.signal==null&&((w=x.networks)!=null&&w.length)){const C=x.networks.find(M=>M.active)||x.networks.find(M=>M.ssid===A.ssid);C&&(A.signal=C.signal)}e.wifiStatus=A}catch{}}catch(b){console.error("WiFi connect failed:",b),e.wifiError=b.message||"Failed to connect",e.wifiBusy=!1}},onWifiDisconnect:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.disconnect"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const f=await e.client.request("wifi.status");e.wifiStatus=f}catch(f){console.error("WiFi disconnect failed:",f),e.wifiError=f.message||"Failed to disconnect"}finally{e.wifiBusy=!1}}},onWifiForget:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.forget"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const f=await e.client.request("wifi.status");e.wifiStatus=f}catch(f){console.error("WiFi forget failed:",f),e.wifiError=f.message||"Failed to forget network"}finally{e.wifiBusy=!1}}},onWifiDismiss:()=>{e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null},onWifiSelectSsid:f=>{e.wifiSelectedSsid=f,e.wifiPassword="",e.wifiError=null},onWifiPasswordChange:f=>{e.wifiPassword=f},networkPort:e.networkPort,networkHostname:e.networkHostname,networkPortInput:e.networkPortInput,networkHostnameInput:e.networkHostnameInput,networkModalOpen:e.networkModalOpen,networkBusy:e.networkBusy,networkError:e.networkError,networkSuccess:e.networkSuccess,onNetworkModalToggle:()=>{e.networkModalOpen=!e.networkModalOpen,e.networkModalOpen&&(e.networkPortInput=String(e.networkPort??""),e.networkHostnameInput=e.networkHostname,e.networkError=null,e.networkSuccess=null)},onNetworkPortChange:f=>{e.networkPortInput=f,e.networkError=null,e.networkSuccess=null},onNetworkHostnameChange:f=>{e.networkHostnameInput=f,e.networkError=null,e.networkSuccess=null},onNetworkSave:async()=>{if(e.networkBusy)return;e.networkBusy=!0,e.networkError=null,e.networkSuccess=null;const f=e.networkPortInput.trim(),w=Number.parseInt(f,10),b=e.networkHostnameInput.trim();if(!f||!Number.isFinite(w)||w<1024||w>65535){e.networkError="Port must be a number between 1024 and 65535",e.networkBusy=!1;return}const x=w!==e.networkPort,A=b!==e.networkHostname;if(!x&&!A){e.networkBusy=!1;return}try{A&&await e.client.request("network.setHostname",{hostname:b});const C={};x&&(C.gateway={port:w}),A&&(C.discovery={bonjourHostname:b});const M=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify(C),baseHash:M.hash,note:[x?`Port → ${w}`:null,A?`Hostname → ${b}`:null].filter(Boolean).join(", "),restartDelayMs:2e3}),e.networkSuccess="Saved — redirecting...";const _=window.location.protocol,B=A?`${b}.local`:window.location.hostname,z=x?w:e.networkPort,te=`${_}//${B}:${z}/setup`;setTimeout(()=>{window.location.href=te},1500)}catch(C){console.error("Network save failed:",C),e.networkError=C.message||"Failed to save network settings",e.networkBusy=!1}},wsProps:fk(e)})}if(e.filesPage){const l=yk(e);return cg({connected:e.connected,wsProps:yn(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:()=>Zt(e,l),onReindex:()=>Af(e,l),onSelectFile:p=>{e.filesPendingDeletePath=null,yf(e,p,l)},onToggleSelectFile:p=>vf(e,p,l),onToggleDir:p=>Ef(e,p),onUpload:(p,h)=>kf(e,p,h,l),onNewFolder:(p,h)=>$f(e,p,h,l),onDownload:p=>rd(e,p,l),onBulkDownload:()=>bf(e,l),onDelete:p=>{e.filesPendingDeletePath=null,Sf(e,p,l)},pendingDeletePath:e.filesPendingDeletePath,onArmDelete:p=>{e.filesPendingDeletePath=p||null},onMoveToDir:(p,h)=>wf(e,p,h,l),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:p=>{const h=e.filesSearchAgentId??l;Cf(e,p,h)},onSearchAgentChange:p=>{e.filesSearchAgentId=p},onSearchClear:()=>{Tf(e)},onSearchQueryChange:p=>{e.filesSearchQuery=p}})}if(e.browserPage)return ig({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:()=>Iw(e),onStop:()=>Rw(e),onToggleInput:()=>Nw(e),onToggleFullscreen:()=>Bw(e),onCompleteHandoff:()=>Dw(e),onCanvasMouseDown:l=>{const h=l.target.getBoundingClientRect(),S=_n().translateCoordinates(l.clientX-h.left,l.clientY-h.top);Ys(e,"mousePressed",S.x,S.y,l.button===2?"right":l.button===1?"middle":"left")},onCanvasMouseUp:l=>{const h=l.target.getBoundingClientRect(),S=_n().translateCoordinates(l.clientX-h.left,l.clientY-h.top);Ys(e,"mouseReleased",S.x,S.y)},onCanvasMouseMove:l=>{const p=_n();if(p.shouldThrottleMouseMove())return;const v=l.target.getBoundingClientRect(),S=p.translateCoordinates(l.clientX-v.left,l.clientY-v.top);Ys(e,"mouseMoved",S.x,S.y)},onCanvasKeyDown:l=>{let p=0;l.altKey&&(p|=1),l.ctrlKey&&(p|=2),l.metaKey&&(p|=4),l.shiftKey&&(p|=8),Xs(e,"keyDown",l.key,{code:l.code,modifiers:p||void 0}),l.key.length===1&&Xs(e,"char",l.key,{text:l.key})},onCanvasKeyUp:l=>{Xs(e,"keyUp",l.key,{code:l.code})}});if(e.adminsPage){const l=gk(e),p=mk(e);return Tg({connected:e.connected,wsProps:yn(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>is(e,l),onAdd:h=>{_u(e,h,l,p).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:h=>Mu(e,h,l,p),onNewPhoneChange:h=>e.handleAdminsNewPhoneChange(h)})}if(e.contactsPage){const l=vk(e);return Rg({connected:e.connected,wsProps:yn(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:()=>_t(e,l),onAdd:(p,h)=>Pu(e,p,h,l),onDelete:p=>Lu(e,p,l),onSetField:(p,h,v)=>Po(e,p,h,v,l),onDeleteField:(p,h)=>Iu(e,p,h,l),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:()=>_t(e,l),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,h=e.contactsAddFieldKey.trim();!p||!h||(Po(e,p,h,e.contactsAddFieldValue,l),e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue="")}})}if(e.chatPage){const l=e.connected?null:"Disconnected from gateway.",p=Fl(e),h=e.chatAvatarUrl??p??null,v=(()=>{var w;const S=(w=e.configSnapshot)==null?void 0:w.config,f=S==null?void 0:S.publicChat;return(f==null?void 0:f.enabled)===!0})();return Ib({connected:e.connected,wsProps:yn(e),publicChatEnabled:v,publicChatAccountId:e.selectedWorkspace??void 0,sessionKey:e.sessionKey,onSessionKeyChange:S=>{const f=e.selectedWorkspace??"";so(),In(f,e.sessionKey,e.chatMessage),e.sessionKey=S,e.chatMessage=Rn(f,S),e.chatAttachments=[],e.chatStream=null,e.chatInterimText=null,e.chatSuggestion=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:S,lastActiveSessionKey:S}),e.loadAssistantIdentity(),Ne(e),po(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:S=>{const f=Math.max(e.chatMessages.length+10,Be);ti(e,e.sessionKey,{model:S}).then(()=>{Ne(e,{limit:f})})},onThinkingLevelChange:S=>{const f=Math.max(e.chatMessages.length+10,Be);ti(e,e.sessionKey,{thinkingLevel:S==="off"?null:S}).then(()=>{Ne(e,{limit:f})})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,suggestion:e.chatSuggestion,onSuggestionClick:S=>{e.chatMessage=S,e.chatSuggestion=null,e.handleSendChat()},onVerboseChange:S=>{const f=Math.max(e.chatMessages.length+10,Be);ti(e,e.sessionKey,{verboseLevel:S==="off"?null:S}).then(()=>{Ne(e,{limit:f})})},onFillerChange:S=>{const f=Math.max(e.chatMessages.length+10,Be);ti(e,e.sessionKey,{fillerEnabled:S}).then(()=>{Ne(e,{limit:f})})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:h,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:l,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>{e.resetToolStream();const S=Math.max(e.chatMessages.length+10,Be);return Promise.all([Ne(e,{limit:S}),po(e)])},onToggleFocusMode:()=>{},onChatScroll:S=>e.handleChatScroll(S),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:S=>{e.chatMessage=S,oa(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?ww({connected:e.connected,wsProps:yn(e),activeTab:e.advancedTab,onTabChange:l=>{e.advancedTab=l,l==="cron"&&e.loadCron(),l==="skills"&&Ge(e,{clearMessages:!0}),l==="logs"&&(e.logsSubTab==="session"?xn(e,{reset:!0}):Ht(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(r=(o=e.channelsSnapshot)==null?void 0:o.channelMeta)!=null&&r.length?e.channelsSnapshot.channelMeta.map(l=>l.id):((a=e.channelsSnapshot)==null?void 0:a.channelOrder)??[],channelLabels:((d=e.channelsSnapshot)==null?void 0:d.channelLabels)??{},channelMeta:((c=e.channelsSnapshot)==null?void 0:c.channelMeta)??[],agentIds:(()=>{var p;const l=le(e);return((p=l==null?void 0:l.agents)==null?void 0:p.map(h=>h.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:l=>{e.cronDetailJobId=l.id,ro(e,l.id)},onDetailClose:()=>{e.cronDetailJobId=null},onEdit:l=>{e.cronForm=kh(l),e.cronEditJobId=l.id,e.cronDetailJobId=null},onEditSave:()=>{const l=e.cronEditJobId;l&&$h(e,l).then(()=>{e.cronEditJobId=null})},onFormChange:l=>e.cronForm={...e.cronForm,...l},onRefresh:()=>e.loadCron(),onAdd:()=>{mh(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(l,p)=>yh(e,l,p),onRun:l=>vh(e,l),onRemove:l=>{e.cronPendingDeleteId=null,wh(e,l)},pendingDeleteId:e.cronPendingDeleteId,onArmDelete:l=>{e.cronPendingDeleteId=l||null},onLoadRuns:l=>ro(e,l),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:l=>e.skillsFilter=l,onTypeFilterChange:l=>e.skillsTypeFilter=l,onRefresh:()=>Ge(e,{clearMessages:!0}),onToggle:(l,p)=>Fc(e,l,p),onEdit:(l,p)=>Bc(e,l,p),onSaveKey:l=>Oc(e,l),onInstall:(l,p,h)=>Uc(e,l,p,h),onViewDetail:l=>Wc(e,l),onDetailClose:()=>Kc(e),onDetailTab:l=>zc(e,l),onAddOpen:()=>Hc(e),onAddClose:()=>qc(e),onImportDraft:l=>jc(e,l),onInstallDraft:l=>Vc(e,l),onDeleteDraft:l=>Gc(e,l),onAddSave:()=>Qo(e),onAddFormUpdate:(l,p)=>{e.skillAddForm={...e.skillAddForm,[l]:p}},onDelete:l=>Zc(e,l),onEditSkill:l=>Qc(e,l),onEditDetail:l=>Jc(e,l),onRefUpdate:(l,p)=>Yc(e,l,p),onEditTab:l=>Xc(e,l)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:l=>{e.logsSubTab=l,l==="session"?xn(e,{reset:!0}):Ht(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:l=>e.sessionLogsFilterText=l,onTypeToggle:(l,p)=>{const h=e;h.sessionLogsTypeFilters={...h.sessionLogsTypeFilters,[l]:p}},onAgentToggle:(l,p)=>{const h=e;h.sessionLogsAgentFilters={...h.sessionLogsAgentFilters,[l]:p}},onToggleAutoFollow:l=>e.sessionLogsAutoFollow=l,onToggleChips:()=>{const l=e;l.sessionLogsChipsExpanded=!l.sessionLogsChipsExpanded},onToggleExpand:l=>{const p=e,h=new Set(p.sessionLogsExpandedIds);h.has(l)?h.delete(l):h.add(l),p.sessionLogsExpandedIds=h,p.requestUpdate()},onRefresh:()=>{xn(e,{reset:!0})},onExport:(l,p)=>e.exportSessionLogs(l,p),onScroll:l=>e.handleSessionLogsScroll(l)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,chipsExpanded:e.logsChipsExpanded,truncated:e.logsTruncated,onFilterTextChange:l=>e.logsFilterText=l,onLevelToggle:(l,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[l]:p}},onToggleAutoFollow:l=>e.logsAutoFollow=l,onToggleChips:()=>{const l=e;l.logsChipsExpanded=!l.logsChipsExpanded},onRefresh:()=>Ht(e,{reset:!0}),onExport:(l,p)=>e.exportSessionLogs(l,p),onScroll:l=>e.handleLogsScroll(l)}}):(window.location.replace("/chat"),u``)}function Ak(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 Ol(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function Ek(e,t,n){return u`
|
|
4193
4193
|
<div class="audit-modal-overlay" @click=${s=>{s.target.classList.contains("audit-modal-overlay")&&n()}}>
|
|
4194
4194
|
<div class="audit-modal-card">
|
|
4195
4195
|
<div class="audit-modal-header">
|
|
@@ -4205,7 +4205,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
4205
4205
|
${e.map(s=>u`
|
|
4206
4206
|
<div class="audit-modal-entry">
|
|
4207
4207
|
<div class="audit-modal-entry-path">
|
|
4208
|
-
<span class="audit-modal-folder audit-modal-folder--${
|
|
4208
|
+
<span class="audit-modal-folder audit-modal-folder--${Ol(s.path)}">${Ol(s.path)}</span>
|
|
4209
4209
|
<a href="/files" class="audit-modal-path-link">${s.path}</a>
|
|
4210
4210
|
</div>
|
|
4211
4211
|
<div class="audit-modal-entry-meta">
|
|
@@ -4221,7 +4221,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
4221
4221
|
`}
|
|
4222
4222
|
</div>
|
|
4223
4223
|
</div>
|
|
4224
|
-
`}const Ck={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Tk={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 _k(e){e.basePath=Ff();const t=Ve();if(Ql(t.accentColor),Jl(t.backgroundColor),window.scrollTo(0,0),Pf(e),e.publicChat){const n=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__,i=(n==null?void 0:n.accountId)??"",s=i?i.charAt(0).toUpperCase()+i.slice(1):"Assistant";document.title=`Chat with ${s}`,Ie(e);return}if(e.setup){document.title=`${t.name} Setup`,Ie(e);return}if(e.filesPage){document.title=`${t.name} Files`,If(e),Ie(e);return}if(e.browserPage){document.title=`${t.name} Browser`,Ie(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,Ie(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,Ie(e);return}if(e.chatPage){document.title=`${t.name} Chat`,Ie(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,Ie(e);return}Kf(e,!0),Of(e),Uf(e),window.addEventListener("popstate",e.popStateHandler),Df(e),Ie(e),_f(e),e.tab==="logs"&&(e.logsSubTab==="session"?Zo(e):Yo(e)),e.tab==="debug"&&tr(e)}function Mk(e){ph(e)}function Pk(e){var t;window.removeEventListener("popstate",e.popStateHandler),Mf(e),Xo(e),er(e),nr(e),Lf(e),Rf(e),Wf(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function Lk(e,t){if(!e.publicChat){if(e.filesPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleFilesLoad&&e.handleFilesLoad(),e.adminsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdminsLoad&&e.handleAdminsLoad(),e.contactsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleContactsLoad&&e.handleContactsLoad(),e.chatPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleChatLoad&&e.handleChatLoad(),e.advancedPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdvancedLoad&&e.handleAdvancedLoad(),e.setup&&e.connected){const n=t.has("connected")&&t.get("connected")===!1;n&&e.handleLicenseStatusCheck&&e.licenseValid===null&&!e.licenseBusy&&e.handleLicenseStatusCheck(),n&&e.handleUpdateCheck&&e.handleUpdateCheck();const i=t.has("setupStep")&&e.setupStep==="auth";(n||i)&&e.setupStep==="auth"&&e.handleAuthStatusCheck&&e.authConnected===null&&!e.authBusy&&e.handleAuthStatusCheck(),e.setupStep==="whatsapp"&&t.has("setupStep")&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(o=>{e.channelsSnapshot=o,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1})),t.has("whatsappLoginConnected")&&e.whatsappLoginConnected===!0&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(s=>{e.channelsSnapshot=s,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1}))}if(e.tab==="chat"&&!e.advancedPage&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),i=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;Jt(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&cc(e,t.has("tab")||t.has("logsAutoFollow"))}}function Ik(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 Rk(e,t,n){await Oo(e,t,n),await Y(e,!0)}async function Dk(e,t){await fc(e,t),await Y(e,!0)}async function Nk(e,t){await gc(e,t),await Y(e,!0)}async function Bk(e,t){await mc(e,t)}async function Fk(e,t){await yc(e,t)}async function Ok(e){await gh(e),await Fe(e),await Y(e,!0)}async function Uk(e){await Fe(e),await Y(e,!0)}function Wk(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(),r=s.join(":").trim();o&&r&&(t[o]=r)}return t}function Ru(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 Du(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function Kk(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Ik(n??void 0)}function zk(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function Hk(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function qk(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function jk(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Ru(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(Du(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:Wk(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 Y(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function Vk(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Ru(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(Du(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 d=(s==null?void 0:s.error)??`Profile import failed (${i.status})`;e.nostrProfileFormState={...t,importing:!1,error:d,success:null};return}const o=s.merged??s.imported??null,r=o?{...t.values,...o}:t.values,a=!!(r.banner||r.website||r.nip05||r.lud16);e.nostrProfileFormState={...t,importing:!1,values:r,error:null,success:s.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:a},s.saved&&await Y(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function Gk(e){if(e.client){e.authBusy=!0,e.authMessage=null;try{const t=await e.client.request("auth.status",{});e.authConnected=t.connected,e.authExpiresIn=t.expiresIn??null,e.authMessage=t.message??null,t.connected&&(e.setupStep="whatsapp")}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to check auth status"}finally{e.authBusy=!1}}}async function Qk(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 Jk(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 Yk(e,t){e.authCodeInput=t}function Xk(e){e.setupStep="whatsapp"}async function Zk(e){if(e.client){e.licenseBusy=!0,e.licenseMessage=null;try{const t=await e.client.request("license.status",{});e.licenseDeviceId=t.deviceId??null,e.licenseStoredKey=t.key??null,t.licensed?(e.licenseValid=!0,e.licenseTier=t.tier??null,e.setupStep="auth"):(e.licenseValid=null,e.setupStep="license")}catch(t){const n=t instanceof Error?t.message:String(t);n.includes("unknown method")?(e.licenseValid=!0,e.setupStep="auth"):(e.licenseValid=null,e.licenseMessage=n,e.setupStep="license")}finally{e.licenseBusy=!1}}}async function e0(e){if(e.client&&e.licenseKey.trim()){e.licenseBusy=!0,e.licenseMessage=null,e.licenseValid=null;try{const t=await e.client.request("license.activate",{key:e.licenseKey.trim()});t.valid?(e.licenseValid=!0,e.licenseMessage=t.message??"License activated",e.licenseTier=t.tier??null,setTimeout(()=>{e.setupStep="auth"},1500)):(e.licenseValid=!1,e.licenseMessage=t.message??"Invalid license key")}catch(t){e.licenseValid=!1,e.licenseMessage=t instanceof Error?t.message:"Activation failed"}finally{e.licenseBusy=!1}}}async function t0(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 n0(e,t){e.licenseKey=t}async function i0(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 s0(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 o0=Object.defineProperty,r0=Object.getOwnPropertyDescriptor,m=(e,t,n,i)=>{for(var s=i>1?void 0:i?r0(t,n):t,o=e.length-1,r;o>=0;o--)(r=e[o])&&(s=(i?r(t,n,s):r(s))||s);return i&&s&&o0(t,n,s),s};const to=wp();function a0(){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 l0(){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 c0(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function d0(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function u0(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function p0(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function h0(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function f0(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let g=class extends zt{constructor(){super(...arguments),this.settings=ws(),this.password="",this.tab="chat",this.onboarding=a0(),this.setup=l0(),this.filesPage=c0(),this.browserPage=d0(),this.adminsPage=u0(),this.contactsPage=p0(),this.chatPage=h0(),this.advancedPage=f0(),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=Au,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=to.name,this.assistantAvatar=to.avatar,this.assistantAgentId=to.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.chatSuggestion=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.chatModelProvider=null,this.chatModel=null,this.chatModelCatalog=[],this.chatVerboseLevel=null,this.chatFillerEnabled=null,this.chatQueue=[],this.chatAttachments=[],this.sidebarOpen=!1,this.sidebarContent=null,this.sidebarError=null,this.splitRatio=this.settings.splitRatio,this.nodesLoading=!1,this.nodes=[],this.devicesLoading=!1,this.devicesError=null,this.devicesList=null,this.execApprovalsLoading=!1,this.execApprovalsSaving=!1,this.execApprovalsDirty=!1,this.execApprovalsSnapshot=null,this.execApprovalsForm=null,this.execApprovalsSelectedAgent=null,this.execApprovalsTarget="gateway",this.execApprovalsTargetNodeId=null,this.execApprovalQueue=[],this.execApprovalBusy=!1,this.execApprovalError=null,this.configLoading=!1,this.configRaw=`{
|
|
4224
|
+
`}const Ck={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Tk={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 _k(e){e.basePath=Ff();const t=Ve();if(Jl(t.accentColor),Yl(t.backgroundColor),window.scrollTo(0,0),Pf(e),e.publicChat){const n=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__,i=(n==null?void 0:n.accountId)??"",s=i?i.charAt(0).toUpperCase()+i.slice(1):"Assistant";document.title=`Chat with ${s}`,Ie(e);return}if(e.setup){document.title=`${t.name} Setup`,Ie(e);return}if(e.filesPage){document.title=`${t.name} Files`,If(e),Ie(e);return}if(e.browserPage){document.title=`${t.name} Browser`,Ie(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,Ie(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,Ie(e);return}if(e.chatPage){document.title=`${t.name} Chat`,Ie(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,Ie(e);return}Kf(e,!0),Of(e),Uf(e),window.addEventListener("popstate",e.popStateHandler),Df(e),Ie(e),_f(e),e.tab==="logs"&&(e.logsSubTab==="session"?er(e):Xo(e)),e.tab==="debug"&&nr(e)}function Mk(e){ph(e)}function Pk(e){var t;window.removeEventListener("popstate",e.popStateHandler),Mf(e),Zo(e),tr(e),ir(e),Lf(e),Rf(e),Wf(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function Lk(e,t){if(!e.publicChat){if(e.filesPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleFilesLoad&&e.handleFilesLoad(),e.adminsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdminsLoad&&e.handleAdminsLoad(),e.contactsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleContactsLoad&&e.handleContactsLoad(),e.chatPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleChatLoad&&e.handleChatLoad(),e.advancedPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdvancedLoad&&e.handleAdvancedLoad(),e.setup&&e.connected){const n=t.has("connected")&&t.get("connected")===!1;n&&e.handleLicenseStatusCheck&&e.licenseValid===null&&!e.licenseBusy&&e.handleLicenseStatusCheck(),n&&e.handleUpdateCheck&&e.handleUpdateCheck();const i=t.has("setupStep")&&e.setupStep==="auth";(n||i)&&e.setupStep==="auth"&&e.handleAuthStatusCheck&&e.authConnected===null&&!e.authBusy&&e.handleAuthStatusCheck(),e.setupStep==="whatsapp"&&t.has("setupStep")&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(o=>{e.channelsSnapshot=o,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1})),t.has("whatsappLoginConnected")&&e.whatsappLoginConnected===!0&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(s=>{e.channelsSnapshot=s,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1}))}if(e.tab==="chat"&&!e.advancedPage&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),i=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;Jt(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&dc(e,t.has("tab")||t.has("logsAutoFollow"))}}function Ik(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 Rk(e,t,n){await Uo(e,t,n),await Y(e,!0)}async function Dk(e,t){await gc(e,t),await Y(e,!0)}async function Nk(e,t){await mc(e,t),await Y(e,!0)}async function Bk(e,t){await yc(e,t)}async function Fk(e,t){await vc(e,t)}async function Ok(e){await gh(e),await Fe(e),await Y(e,!0)}async function Uk(e){await Fe(e),await Y(e,!0)}function Wk(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(),r=s.join(":").trim();o&&r&&(t[o]=r)}return t}function Ru(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 Du(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function Kk(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Ik(n??void 0)}function zk(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function Hk(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function qk(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function jk(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Ru(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(Du(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:Wk(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 Y(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function Vk(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Ru(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(Du(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 d=(s==null?void 0:s.error)??`Profile import failed (${i.status})`;e.nostrProfileFormState={...t,importing:!1,error:d,success:null};return}const o=s.merged??s.imported??null,r=o?{...t.values,...o}:t.values,a=!!(r.banner||r.website||r.nip05||r.lud16);e.nostrProfileFormState={...t,importing:!1,values:r,error:null,success:s.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:a},s.saved&&await Y(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function Gk(e){if(e.client){e.authBusy=!0,e.authMessage=null;try{const t=await e.client.request("auth.status",{});e.authConnected=t.connected,e.authExpiresIn=t.expiresIn??null,e.authMessage=t.message??null,t.connected&&(e.setupStep="whatsapp")}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to check auth status"}finally{e.authBusy=!1}}}async function Qk(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 Jk(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 Yk(e,t){e.authCodeInput=t}function Xk(e){e.setupStep="whatsapp"}async function Zk(e){if(e.client){e.licenseBusy=!0,e.licenseMessage=null;try{const t=await e.client.request("license.status",{});e.licenseDeviceId=t.deviceId??null,e.licenseStoredKey=t.key??null,t.licensed?(e.licenseValid=!0,e.licenseTier=t.tier??null,e.setupStep="auth"):(e.licenseValid=null,e.setupStep="license")}catch(t){const n=t instanceof Error?t.message:String(t);n.includes("unknown method")?(e.licenseValid=!0,e.setupStep="auth"):(e.licenseValid=null,e.licenseMessage=n,e.setupStep="license")}finally{e.licenseBusy=!1}}}async function e0(e){if(e.client&&e.licenseKey.trim()){e.licenseBusy=!0,e.licenseMessage=null,e.licenseValid=null;try{const t=await e.client.request("license.activate",{key:e.licenseKey.trim()});t.valid?(e.licenseValid=!0,e.licenseMessage=t.message??"License activated",e.licenseTier=t.tier??null,setTimeout(()=>{e.setupStep="auth"},1500)):(e.licenseValid=!1,e.licenseMessage=t.message??"Invalid license key")}catch(t){e.licenseValid=!1,e.licenseMessage=t instanceof Error?t.message:"Activation failed"}finally{e.licenseBusy=!1}}}async function t0(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 n0(e,t){e.licenseKey=t}async function i0(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 s0(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 o0=Object.defineProperty,r0=Object.getOwnPropertyDescriptor,m=(e,t,n,i)=>{for(var s=i>1?void 0:i?r0(t,n):t,o=e.length-1,r;o>=0;o--)(r=e[o])&&(s=(i?r(t,n,s):r(s))||s);return i&&s&&o0(t,n,s),s};const to=wp();function a0(){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 l0(){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 c0(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function d0(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function u0(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function p0(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function h0(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function f0(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let g=class extends zt{constructor(){super(...arguments),this.settings=ws(),this.password="",this.tab="chat",this.onboarding=a0(),this.setup=l0(),this.filesPage=c0(),this.browserPage=d0(),this.adminsPage=u0(),this.contactsPage=p0(),this.chatPage=h0(),this.advancedPage=f0(),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=Au,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=to.name,this.assistantAvatar=to.avatar,this.assistantAgentId=to.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.chatSuggestion=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.chatModelProvider=null,this.chatModel=null,this.chatModelCatalog=[],this.chatVerboseLevel=null,this.chatFillerEnabled=null,this.chatQueue=[],this.chatAttachments=[],this.sidebarOpen=!1,this.sidebarContent=null,this.sidebarError=null,this.splitRatio=this.settings.splitRatio,this.nodesLoading=!1,this.nodes=[],this.devicesLoading=!1,this.devicesError=null,this.devicesList=null,this.execApprovalsLoading=!1,this.execApprovalsSaving=!1,this.execApprovalsDirty=!1,this.execApprovalsSnapshot=null,this.execApprovalsForm=null,this.execApprovalsSelectedAgent=null,this.execApprovalsTarget="gateway",this.execApprovalsTargetNodeId=null,this.execApprovalQueue=[],this.execApprovalBusy=!1,this.execApprovalError=null,this.configLoading=!1,this.configRaw=`{
|
|
4225
4225
|
}
|
|
4226
|
-
`,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.brandingBusy=!1,this.brandingExpanded=!1,this.tailscaleStatus=null,this.tailscaleBusy=!1,this.tailscaleAuthUrl=null,this.tailscaleError=null,this.tailscaleFunnelEnableUrl=null,this.tailscaleDisableConfirm=!1,this.wifiStatus=null,this.wifiNetworks=[],this.wifiBusy=!1,this.wifiError=null,this.wifiPassword="",this.wifiSelectedSsid=null,this.networkPort=null,this.networkHostname="",this.networkPortInput="",this.networkHostnameInput="",this.networkModalOpen=!1,this.networkBusy=!1,this.networkError=null,this.networkSuccess=null,this.wifiModalOpen=!1,this.licenseKey="",this.licenseBusy=!1,this.licenseValid=null,this.licenseMessage=null,this.licenseTier=null,this.licenseDeviceId=null,this.licenseStoredKey=null,this.licenseRemoveConfirm=!1,this.authConnected=null,this.authBusy=!1,this.authMessage=null,this.authUrl=null,this.authCodeInput="",this.authExpiresIn=null,this.setupStep="license",this.gatewayHealthy=null,this.gatewayHealthLoading=!1,this.gatewayHealthMessage=null,this.gatewayRestartBusy=!1,this.updateAvailable=null,this.currentVersion=null,this.latestVersion=null,this.updateChecking=!1,this.updateMessage=null,this.updateProgressSteps=[],this.updateLastResult=null,this.uninstallConfirm=!1,this.uninstallBusy=!1,this.uninstallDone=!1,this.uninstallError=null,this.uninstallConfirmText="",this.nostrProfileFormState=null,this.nostrProfileAccountId=null,this.presenceLoading=!1,this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.sessionsLoading=!1,this.sessionsResult=null,this.sessionsError=null,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...Tk},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.cronEditJobId=null,this.cronPendingDeleteId=null,this.cronRunModalJobId=null,this.cronRunModalJobName="",this.cronRunResult=null,this.browserScreencastActive=!1,this.browserScreencastFrame=null,this.browserScreencastMetadata=null,this.browserHandoffPending=!1,this.browserHandoffReason=null,this.browserHandoffId=null,this.browserInputMode=!1,this.browserFullscreen=!1,this.browserLoading=!1,this.browserError=null,this.filesLoading=!1,this.filesTree=[],this.filesRoot="",this.filesError=null,this.filesSelectedPath=null,this.filesSelectedPaths=new Set,this.filesPreviewContent=null,this.filesPreviewLoading=!1,this.filesPreviewBinary=!1,this.filesPreviewSize=null,this.filesExpandedDirs=new Set,this.filesCurrentDir=".",this.filesPendingDeletePath=null,this.filesMessage=null,this.filesUploadBusy=!1,this.filesReindexBusy=!1,this.filesMemoryStatus=null,this.embeddingDownloading=!1,this.embeddingPollTimer=null,this.filesSearchQuery="",this.filesSearchResults=null,this.filesSearchLoading=!1,this.filesSearchAgentId=null,this.filesResolvedAgentId=void 0,this.auditEntries=[],this.auditLoading=!1,this.auditModalOpen=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillsTypeFilter="all",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.skillDetail=null,this.skillDetailTab="",this.skillAddModal=!1,this.skillAddForm={name:"",skillContent:"",references:[]},this.skillAddFormSource="draft",this.skillEditTab="SKILL.md",this.skillDrafts=[],this.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.contactsLoading=!1,this.contactsSaving=!1,this.contactsRecords=[],this.contactsError=null,this.contactsSearchQuery="",this.contactsEditingId=null,this.contactsShowAddForm=!1,this.contactsNewPhone="",this.contactsNewName="",this.contactsDeleteConfirmId=null,this.contactsAddFieldForId=null,this.contactsAddFieldKey="",this.contactsAddFieldValue="",this.imessageEnableConfirm=!1,this.imessageEnabling=!1,this.infoModalOpen=null,this.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={...Ck},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.logsSubTab="session",this.logsChipsExpanded=!1,this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,tool_call:!0,tool_result:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsChipsExpanded=!1,this.sessionLogsExpandedIds=new Set,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.onLoadOlder=()=>this.handleLoadOlderChat(),this.nodesPollInterval=null,this.logsPollInterval=null,this.sessionLogsPollInterval=null,this.debugPollInterval=null,this.auditPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>zf(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null,this._beforeUnloadHandler=()=>{var t;so();const e=this.selectedWorkspace??((t=this.publicChatConfig)==null?void 0:t.accountId)??"";e&&In(e,this.sessionKey,this.chatMessage)}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),_k(this),window.addEventListener("beforeunload",this._beforeUnloadHandler)}firstUpdated(){Mk(this)}disconnectedCallback(){window.removeEventListener("beforeunload",this._beforeUnloadHandler),this.stopEmbeddingPoll(),Pk(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){Lk(this,e)}connect(){Ie(this)}handleChatScroll(e){oh(this,e)}handleLogsScroll(e){ah(this,e)}handleSessionLogsScroll(e){lh(this,e)}exportLogs(e,t){dh(e,t)}exportSessionLogs(e,t){uh(e,t)}resetToolStream(){Fo(this)}resetChatScroll(){ch(this)}async loadAssistantIdentity(){await _o(this)}applySettings(e){nt(this,e)}setTab(e){Nf(this,e)}setTheme(e,t){Bf(this,e,t)}async loadOverview(){await cd(this)}async loadCron(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.cronForm={...this.cronForm,accountId:(e==null?void 0:e.whatsappAccountId)??void 0},await ir(this)}async handleAbortChat(){await ud(this)}removeQueuedMessage(e){Vf(this,e)}async handleSendChat(e,t){await Gf(this,e,t)}async handleWhatsAppStart(e,t){await Rk(this,e,t)}async handleWhatsAppWait(e){await Dk(this,e)}async handleWhatsAppLogout(e){await Nk(this,e)}async handleAddWhatsAppAccount(e){await Bk(this,e)}async handleRemoveWhatsAppAccount(e){await Fk(this,e)}async handleAccessCheck(){await Nl(this)}async handlePinSubmit(e,t){await ak(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await lk(this,e)}async handleLogout(){await dk(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 Nl(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 Zk(this)}async handleLicenseActivate(){await e0(this)}async handleLicenseRemove(){await t0(this)}handleLicenseKeyChange(e){n0(this,e)}async handleAuthStatusCheck(){await Gk(this)}async handleAuthStart(){await Qk(this)}async handleAuthSubmitCode(e){await Jk(this,e)}handleAuthCodeChange(e){Yk(this,e)}handleSkipToWhatsApp(){Xk(this)}async handleGatewayHealthCheck(){await i0(this)}async handleGatewayRestart(){await s0(this)}async handleUpdateCheck(){await ku(this)}async handleUpdateRun(){await zw(this)}handleUpdateDismissResult(){jw(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 re(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>ya);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){re(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>ya);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await id(this)}async clearAudit(){await mf(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,Zt(this,t),Jo(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();re(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>pk);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.chatSuggestion=null,this.resetChatScroll(),this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}re(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>Ei);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this).then(()=>{Jt(this,!0)})})}async handleLoadOlderChat(){if(this.chatLoadingOlder||!this.chatHistoryHasMore)return;const e=rh(this),{loadOlderChatHistory:t}=await re(async()=>{const{loadOlderChatHistory:i}=await Promise.resolve().then(()=>Ei);return{loadOlderChatHistory:i}},void 0,import.meta.url);await t(this)&&e&&(await this.updateComplete,e())}handleAdvancedLoad(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.sessionLogsEntries=[],this.sessionLogsCursors={},this.sessionLogsAgents=[],this.advancedTab==="cron"&&this.loadCron(),this.advancedTab==="logs"&&(this.logsSubTab==="session"?re(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>nd);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):re(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>Th);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&re(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>cf);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await Ok(this)}async handleChannelConfigReload(){await Uk(this)}handleNostrProfileEdit(e,t){Kk(this,e,t)}handleNostrProfileCancel(){zk(this)}handleNostrProfileFieldChange(e,t){Hk(this,e,t)}async handleNostrProfileSave(){await jk(this)}async handleNostrProfileImport(){await Vk(this)}handleNostrProfileToggleAdvanced(){qk(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;re(async()=>{const{loadContacts:t}=await Promise.resolve().then(()=>hk);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 re(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>hi);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await re(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>hi);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await re(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>Sh);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 re(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>hi);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 re(async()=>{const{renameWorkspace:i}=await Promise.resolve().then(()=>hi);return{renameWorkspace:i}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){so(),this.selectedWorkspace&&In(this.selectedWorkspace,this.sessionKey,this.chatMessage),this.selectedWorkspace=e,localStorage.setItem("taskmaster-selected-workspace",e),kn(e),ia(e),this.settings=ws(),this.chatMessage=Rn(e,this.settings.sessionKey),this.chatAttachments=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestion=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.chatQueue=[],this.lastError=null,this.reloadCurrentPageData()}getSelectedWorkspaceInfo(){return this.selectedWorkspace?this.workspaces.find(e=>e.name===this.selectedWorkspace)??null:null}reloadCurrentPageData(){this.loadAuditEntries(),this.adminsPage?this.handleAdminsLoad():this.contactsPage?this.handleContactsLoad():this.filesPage?this.handleFilesLoad():this.chatPage?this.handleChatLoad():this.advancedPage&&this.handleAdvancedLoad()}initWorkspaceSelection(){if(this.workspaces.length===0){this.reloadCurrentPageData();return}const e=localStorage.getItem("taskmaster-selected-workspace"),t=e?this.workspaces.find(n=>n.name===e):null;if(t)this.selectedWorkspace=t.name;else{const n=this.workspaces.find(i=>i.isDefault)??this.workspaces[0];this.selectedWorkspace=n.name,localStorage.setItem("taskmaster-selected-workspace",n.name)}kn(this.selectedWorkspace),ia(this.selectedWorkspace),this.settings=ws(),this.chatMessage=Rn(this.selectedWorkspace,this.settings.sessionKey),this.reloadCurrentPageData()}render(){return u`${xk(this)}${this.auditModalOpen?Ek(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):k}`}};m([y()],g.prototype,"settings",2);m([y()],g.prototype,"password",2);m([y()],g.prototype,"tab",2);m([y()],g.prototype,"onboarding",2);m([y()],g.prototype,"setup",2);m([y()],g.prototype,"filesPage",2);m([y()],g.prototype,"browserPage",2);m([y()],g.prototype,"adminsPage",2);m([y()],g.prototype,"contactsPage",2);m([y()],g.prototype,"chatPage",2);m([y()],g.prototype,"advancedPage",2);m([y()],g.prototype,"advancedTab",2);m([y()],g.prototype,"publicChat",2);m([y()],g.prototype,"publicChatConfig",2);m([y()],g.prototype,"publicChatSessionKey",2);m([y()],g.prototype,"publicChatAuthenticated",2);m([y()],g.prototype,"publicChatAuthStep",2);m([y()],g.prototype,"connected",2);m([y()],g.prototype,"accessState",2);m([y()],g.prototype,"theme",2);m([y()],g.prototype,"themeResolved",2);m([y()],g.prototype,"hello",2);m([y()],g.prototype,"lastError",2);m([y()],g.prototype,"eventLog",2);m([y()],g.prototype,"assistantName",2);m([y()],g.prototype,"assistantAvatar",2);m([y()],g.prototype,"assistantAgentId",2);m([y()],g.prototype,"sessionKey",2);m([y()],g.prototype,"chatLoading",2);m([y()],g.prototype,"chatSending",2);m([y()],g.prototype,"chatMessage",2);m([y()],g.prototype,"chatMessages",2);m([y()],g.prototype,"chatHistoryTotal",2);m([y()],g.prototype,"chatHistoryHasMore",2);m([y()],g.prototype,"chatLoadingOlder",2);m([y()],g.prototype,"chatToolMessages",2);m([y()],g.prototype,"chatStream",2);m([y()],g.prototype,"chatInterimText",2);m([y()],g.prototype,"chatSuggestion",2);m([y()],g.prototype,"chatStreamStartedAt",2);m([y()],g.prototype,"chatRunId",2);m([y()],g.prototype,"compactionStatus",2);m([y()],g.prototype,"chatAvatarUrl",2);m([y()],g.prototype,"chatThinkingLevel",2);m([y()],g.prototype,"chatModelProvider",2);m([y()],g.prototype,"chatModel",2);m([y()],g.prototype,"chatModelCatalog",2);m([y()],g.prototype,"chatVerboseLevel",2);m([y()],g.prototype,"chatFillerEnabled",2);m([y()],g.prototype,"chatQueue",2);m([y()],g.prototype,"chatAttachments",2);m([y()],g.prototype,"sidebarOpen",2);m([y()],g.prototype,"sidebarContent",2);m([y()],g.prototype,"sidebarError",2);m([y()],g.prototype,"splitRatio",2);m([y()],g.prototype,"nodesLoading",2);m([y()],g.prototype,"nodes",2);m([y()],g.prototype,"devicesLoading",2);m([y()],g.prototype,"devicesError",2);m([y()],g.prototype,"devicesList",2);m([y()],g.prototype,"execApprovalsLoading",2);m([y()],g.prototype,"execApprovalsSaving",2);m([y()],g.prototype,"execApprovalsDirty",2);m([y()],g.prototype,"execApprovalsSnapshot",2);m([y()],g.prototype,"execApprovalsForm",2);m([y()],g.prototype,"execApprovalsSelectedAgent",2);m([y()],g.prototype,"execApprovalsTarget",2);m([y()],g.prototype,"execApprovalsTargetNodeId",2);m([y()],g.prototype,"execApprovalQueue",2);m([y()],g.prototype,"execApprovalBusy",2);m([y()],g.prototype,"execApprovalError",2);m([y()],g.prototype,"configLoading",2);m([y()],g.prototype,"configRaw",2);m([y()],g.prototype,"configRawOriginal",2);m([y()],g.prototype,"configValid",2);m([y()],g.prototype,"configIssues",2);m([y()],g.prototype,"configSaving",2);m([y()],g.prototype,"configApplying",2);m([y()],g.prototype,"updateRunning",2);m([y()],g.prototype,"applySessionKey",2);m([y()],g.prototype,"configSnapshot",2);m([y()],g.prototype,"configSchema",2);m([y()],g.prototype,"configSchemaVersion",2);m([y()],g.prototype,"configSchemaLoading",2);m([y()],g.prototype,"configUiHints",2);m([y()],g.prototype,"configForm",2);m([y()],g.prototype,"configFormOriginal",2);m([y()],g.prototype,"configFormDirty",2);m([y()],g.prototype,"configFormMode",2);m([y()],g.prototype,"configSearchQuery",2);m([y()],g.prototype,"configActiveSection",2);m([y()],g.prototype,"configActiveSubsection",2);m([y()],g.prototype,"channelsLoading",2);m([y()],g.prototype,"channelsSnapshot",2);m([y()],g.prototype,"channelsError",2);m([y()],g.prototype,"channelsLastSuccess",2);m([y()],g.prototype,"whatsappLoginMessage",2);m([y()],g.prototype,"whatsappLoginQrDataUrl",2);m([y()],g.prototype,"whatsappLoginConnected",2);m([y()],g.prototype,"whatsappBusy",2);m([y()],g.prototype,"whatsappActiveQrAccountId",2);m([y()],g.prototype,"whatsappPairedPhone",2);m([y()],g.prototype,"addingWhatsAppAccount",2);m([y()],g.prototype,"newWhatsAppAccountName",2);m([y()],g.prototype,"whatsappAccountError",2);m([y()],g.prototype,"whatsappAccountSaving",2);m([y()],g.prototype,"whatsappSettingsOpen",2);m([y()],g.prototype,"publicChatToggleBusy",2);m([y()],g.prototype,"brandingBusy",2);m([y()],g.prototype,"brandingExpanded",2);m([y()],g.prototype,"tailscaleStatus",2);m([y()],g.prototype,"tailscaleBusy",2);m([y()],g.prototype,"tailscaleAuthUrl",2);m([y()],g.prototype,"tailscaleError",2);m([y()],g.prototype,"tailscaleFunnelEnableUrl",2);m([y()],g.prototype,"tailscaleDisableConfirm",2);m([y()],g.prototype,"wifiStatus",2);m([y()],g.prototype,"wifiNetworks",2);m([y()],g.prototype,"wifiBusy",2);m([y()],g.prototype,"wifiError",2);m([y()],g.prototype,"wifiPassword",2);m([y()],g.prototype,"wifiSelectedSsid",2);m([y()],g.prototype,"networkPort",2);m([y()],g.prototype,"networkHostname",2);m([y()],g.prototype,"networkPortInput",2);m([y()],g.prototype,"networkHostnameInput",2);m([y()],g.prototype,"networkModalOpen",2);m([y()],g.prototype,"networkBusy",2);m([y()],g.prototype,"networkError",2);m([y()],g.prototype,"networkSuccess",2);m([y()],g.prototype,"wifiModalOpen",2);m([y()],g.prototype,"licenseKey",2);m([y()],g.prototype,"licenseBusy",2);m([y()],g.prototype,"licenseValid",2);m([y()],g.prototype,"licenseMessage",2);m([y()],g.prototype,"licenseTier",2);m([y()],g.prototype,"licenseDeviceId",2);m([y()],g.prototype,"licenseStoredKey",2);m([y()],g.prototype,"licenseRemoveConfirm",2);m([y()],g.prototype,"authConnected",2);m([y()],g.prototype,"authBusy",2);m([y()],g.prototype,"authMessage",2);m([y()],g.prototype,"authUrl",2);m([y()],g.prototype,"authCodeInput",2);m([y()],g.prototype,"authExpiresIn",2);m([y()],g.prototype,"setupStep",2);m([y()],g.prototype,"gatewayHealthy",2);m([y()],g.prototype,"gatewayHealthLoading",2);m([y()],g.prototype,"gatewayHealthMessage",2);m([y()],g.prototype,"gatewayRestartBusy",2);m([y()],g.prototype,"updateAvailable",2);m([y()],g.prototype,"currentVersion",2);m([y()],g.prototype,"latestVersion",2);m([y()],g.prototype,"updateChecking",2);m([y()],g.prototype,"updateMessage",2);m([y()],g.prototype,"updateProgressSteps",2);m([y()],g.prototype,"updateLastResult",2);m([y()],g.prototype,"uninstallConfirm",2);m([y()],g.prototype,"uninstallBusy",2);m([y()],g.prototype,"uninstallDone",2);m([y()],g.prototype,"uninstallError",2);m([y()],g.prototype,"uninstallConfirmText",2);m([y()],g.prototype,"nostrProfileFormState",2);m([y()],g.prototype,"nostrProfileAccountId",2);m([y()],g.prototype,"presenceLoading",2);m([y()],g.prototype,"presenceEntries",2);m([y()],g.prototype,"presenceError",2);m([y()],g.prototype,"presenceStatus",2);m([y()],g.prototype,"agentsLoading",2);m([y()],g.prototype,"agentsList",2);m([y()],g.prototype,"agentsError",2);m([y()],g.prototype,"sessionsLoading",2);m([y()],g.prototype,"sessionsResult",2);m([y()],g.prototype,"sessionsError",2);m([y()],g.prototype,"cronLoading",2);m([y()],g.prototype,"cronJobs",2);m([y()],g.prototype,"cronStatus",2);m([y()],g.prototype,"cronError",2);m([y()],g.prototype,"cronForm",2);m([y()],g.prototype,"cronRunsJobId",2);m([y()],g.prototype,"cronRuns",2);m([y()],g.prototype,"cronBusy",2);m([y()],g.prototype,"cronNewEventModal",2);m([y()],g.prototype,"cronDetailJobId",2);m([y()],g.prototype,"cronEditJobId",2);m([y()],g.prototype,"cronPendingDeleteId",2);m([y()],g.prototype,"cronRunModalJobId",2);m([y()],g.prototype,"cronRunModalJobName",2);m([y()],g.prototype,"cronRunResult",2);m([y()],g.prototype,"browserScreencastActive",2);m([y()],g.prototype,"browserScreencastFrame",2);m([y()],g.prototype,"browserScreencastMetadata",2);m([y()],g.prototype,"browserHandoffPending",2);m([y()],g.prototype,"browserHandoffReason",2);m([y()],g.prototype,"browserHandoffId",2);m([y()],g.prototype,"browserInputMode",2);m([y()],g.prototype,"browserFullscreen",2);m([y()],g.prototype,"browserLoading",2);m([y()],g.prototype,"browserError",2);m([y()],g.prototype,"filesLoading",2);m([y()],g.prototype,"filesTree",2);m([y()],g.prototype,"filesRoot",2);m([y()],g.prototype,"filesError",2);m([y()],g.prototype,"filesSelectedPath",2);m([y()],g.prototype,"filesSelectedPaths",2);m([y()],g.prototype,"filesPreviewContent",2);m([y()],g.prototype,"filesPreviewLoading",2);m([y()],g.prototype,"filesPreviewBinary",2);m([y()],g.prototype,"filesPreviewSize",2);m([y()],g.prototype,"filesExpandedDirs",2);m([y()],g.prototype,"filesCurrentDir",2);m([y()],g.prototype,"filesPendingDeletePath",2);m([y()],g.prototype,"filesMessage",2);m([y()],g.prototype,"filesUploadBusy",2);m([y()],g.prototype,"filesReindexBusy",2);m([y()],g.prototype,"filesMemoryStatus",2);m([y()],g.prototype,"embeddingDownloading",2);m([y()],g.prototype,"filesSearchQuery",2);m([y()],g.prototype,"filesSearchResults",2);m([y()],g.prototype,"filesSearchLoading",2);m([y()],g.prototype,"filesSearchAgentId",2);m([y()],g.prototype,"auditEntries",2);m([y()],g.prototype,"auditLoading",2);m([y()],g.prototype,"auditModalOpen",2);m([y()],g.prototype,"skillsLoading",2);m([y()],g.prototype,"skillsReport",2);m([y()],g.prototype,"skillsError",2);m([y()],g.prototype,"skillsFilter",2);m([y()],g.prototype,"skillsTypeFilter",2);m([y()],g.prototype,"skillEdits",2);m([y()],g.prototype,"skillsBusyKey",2);m([y()],g.prototype,"skillMessages",2);m([y()],g.prototype,"skillDetail",2);m([y()],g.prototype,"skillDetailTab",2);m([y()],g.prototype,"skillAddModal",2);m([y()],g.prototype,"skillAddForm",2);m([y()],g.prototype,"skillAddFormSource",2);m([y()],g.prototype,"skillEditTab",2);m([y()],g.prototype,"skillDrafts",2);m([y()],g.prototype,"adminsLoading",2);m([y()],g.prototype,"adminPhones",2);m([y()],g.prototype,"adminsError",2);m([y()],g.prototype,"adminsSaving",2);m([y()],g.prototype,"adminsNewPhone",2);m([y()],g.prototype,"contactsLoading",2);m([y()],g.prototype,"contactsSaving",2);m([y()],g.prototype,"contactsRecords",2);m([y()],g.prototype,"contactsError",2);m([y()],g.prototype,"contactsSearchQuery",2);m([y()],g.prototype,"contactsEditingId",2);m([y()],g.prototype,"contactsShowAddForm",2);m([y()],g.prototype,"contactsNewPhone",2);m([y()],g.prototype,"contactsNewName",2);m([y()],g.prototype,"contactsDeleteConfirmId",2);m([y()],g.prototype,"contactsAddFieldForId",2);m([y()],g.prototype,"contactsAddFieldKey",2);m([y()],g.prototype,"contactsAddFieldValue",2);m([y()],g.prototype,"imessageEnableConfirm",2);m([y()],g.prototype,"imessageEnabling",2);m([y()],g.prototype,"infoModalOpen",2);m([y()],g.prototype,"workspaces",2);m([y()],g.prototype,"workspacesLoading",2);m([y()],g.prototype,"workspacesError",2);m([y()],g.prototype,"selectedWorkspace",2);m([y()],g.prototype,"addingWorkspace",2);m([y()],g.prototype,"newWorkspaceName",2);m([y()],g.prototype,"newWorkspacePath",2);m([y()],g.prototype,"newWorkspacePin",2);m([y()],g.prototype,"accountPinModalOpen",2);m([y()],g.prototype,"accountPinBusy",2);m([y()],g.prototype,"accountPinError",2);m([y()],g.prototype,"accountPinSuccess",2);m([y()],g.prototype,"apiKeyProviders",2);m([y()],g.prototype,"apiKeyModalOpen",2);m([y()],g.prototype,"apiKeyBusy",2);m([y()],g.prototype,"apiKeyError",2);m([y()],g.prototype,"apiKeySuccess",2);m([y()],g.prototype,"apiKeySavingProvider",2);m([y()],g.prototype,"authApiKeyMode",2);m([y()],g.prototype,"authApiKeyInput",2);m([y()],g.prototype,"authApiKeyBusy",2);m([y()],g.prototype,"authApiKeyError",2);m([y()],g.prototype,"pinChanging",2);m([y()],g.prototype,"pinChangeBusy",2);m([y()],g.prototype,"pinChangeError",2);m([y()],g.prototype,"loginChangePinMode",2);m([y()],g.prototype,"changePinBusy",2);m([y()],g.prototype,"changePinError",2);m([y()],g.prototype,"changePinSuccess",2);m([y()],g.prototype,"workspaceSaving",2);m([y()],g.prototype,"workspaceRemoveConfirm",2);m([y()],g.prototype,"renamingWorkspace",2);m([y()],g.prototype,"renameWorkspaceName",2);m([y()],g.prototype,"debugLoading",2);m([y()],g.prototype,"debugStatus",2);m([y()],g.prototype,"debugHealth",2);m([y()],g.prototype,"debugModels",2);m([y()],g.prototype,"debugHeartbeat",2);m([y()],g.prototype,"debugCallMethod",2);m([y()],g.prototype,"debugCallParams",2);m([y()],g.prototype,"debugCallResult",2);m([y()],g.prototype,"debugCallError",2);m([y()],g.prototype,"logsLoading",2);m([y()],g.prototype,"logsError",2);m([y()],g.prototype,"logsFile",2);m([y()],g.prototype,"logsEntries",2);m([y()],g.prototype,"logsFilterText",2);m([y()],g.prototype,"logsLevelFilters",2);m([y()],g.prototype,"logsAutoFollow",2);m([y()],g.prototype,"logsTruncated",2);m([y()],g.prototype,"logsCursor",2);m([y()],g.prototype,"logsLastFetchAt",2);m([y()],g.prototype,"logsLimit",2);m([y()],g.prototype,"logsMaxBytes",2);m([y()],g.prototype,"logsAtBottom",2);m([y()],g.prototype,"logsSubTab",2);m([y()],g.prototype,"logsChipsExpanded",2);m([y()],g.prototype,"sessionLogsLoading",2);m([y()],g.prototype,"sessionLogsError",2);m([y()],g.prototype,"sessionLogsEntries",2);m([y()],g.prototype,"sessionLogsFilterText",2);m([y()],g.prototype,"sessionLogsTypeFilters",2);m([y()],g.prototype,"sessionLogsAgentFilters",2);m([y()],g.prototype,"sessionLogsAgents",2);m([y()],g.prototype,"sessionLogsAutoFollow",2);m([y()],g.prototype,"sessionLogsChipsExpanded",2);m([y()],g.prototype,"sessionLogsCursors",2);m([y()],g.prototype,"sessionLogsLastFetchAt",2);m([y()],g.prototype,"sessionLogsAtBottom",2);m([y()],g.prototype,"chatUserNearBottom",2);g=m([Vl("taskmaster-app")],g);
|
|
4227
|
-
//# sourceMappingURL=index-
|
|
4226
|
+
`,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.brandingBusy=!1,this.brandingExpanded=!1,this.tailscaleStatus=null,this.tailscaleBusy=!1,this.tailscaleAuthUrl=null,this.tailscaleError=null,this.tailscaleFunnelEnableUrl=null,this.tailscaleDisableConfirm=!1,this.wifiStatus=null,this.wifiNetworks=[],this.wifiBusy=!1,this.wifiError=null,this.wifiPassword="",this.wifiSelectedSsid=null,this.networkPort=null,this.networkHostname="",this.networkPortInput="",this.networkHostnameInput="",this.networkModalOpen=!1,this.networkBusy=!1,this.networkError=null,this.networkSuccess=null,this.wifiModalOpen=!1,this.licenseKey="",this.licenseBusy=!1,this.licenseValid=null,this.licenseMessage=null,this.licenseTier=null,this.licenseDeviceId=null,this.licenseStoredKey=null,this.licenseRemoveConfirm=!1,this.authConnected=null,this.authBusy=!1,this.authMessage=null,this.authUrl=null,this.authCodeInput="",this.authExpiresIn=null,this.setupStep="license",this.gatewayHealthy=null,this.gatewayHealthLoading=!1,this.gatewayHealthMessage=null,this.gatewayRestartBusy=!1,this.updateAvailable=null,this.currentVersion=null,this.latestVersion=null,this.updateChecking=!1,this.updateMessage=null,this.updateProgressSteps=[],this.updateLastResult=null,this.uninstallConfirm=!1,this.uninstallBusy=!1,this.uninstallDone=!1,this.uninstallError=null,this.uninstallConfirmText="",this.nostrProfileFormState=null,this.nostrProfileAccountId=null,this.presenceLoading=!1,this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.sessionsLoading=!1,this.sessionsResult=null,this.sessionsError=null,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...Tk},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.cronEditJobId=null,this.cronPendingDeleteId=null,this.cronRunModalJobId=null,this.cronRunModalJobName="",this.cronRunResult=null,this.browserScreencastActive=!1,this.browserScreencastFrame=null,this.browserScreencastMetadata=null,this.browserHandoffPending=!1,this.browserHandoffReason=null,this.browserHandoffId=null,this.browserInputMode=!1,this.browserFullscreen=!1,this.browserLoading=!1,this.browserError=null,this.filesLoading=!1,this.filesTree=[],this.filesRoot="",this.filesError=null,this.filesSelectedPath=null,this.filesSelectedPaths=new Set,this.filesPreviewContent=null,this.filesPreviewLoading=!1,this.filesPreviewBinary=!1,this.filesPreviewSize=null,this.filesExpandedDirs=new Set,this.filesCurrentDir=".",this.filesPendingDeletePath=null,this.filesMessage=null,this.filesUploadBusy=!1,this.filesReindexBusy=!1,this.filesMemoryStatus=null,this.embeddingDownloading=!1,this.embeddingPollTimer=null,this.filesSearchQuery="",this.filesSearchResults=null,this.filesSearchLoading=!1,this.filesSearchAgentId=null,this.filesResolvedAgentId=void 0,this.auditEntries=[],this.auditLoading=!1,this.auditModalOpen=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillsTypeFilter="all",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.skillDetail=null,this.skillDetailTab="",this.skillAddModal=!1,this.skillAddForm={name:"",skillContent:"",references:[]},this.skillAddFormSource="draft",this.skillEditTab="SKILL.md",this.skillDrafts=[],this.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.contactsLoading=!1,this.contactsSaving=!1,this.contactsRecords=[],this.contactsError=null,this.contactsSearchQuery="",this.contactsEditingId=null,this.contactsShowAddForm=!1,this.contactsNewPhone="",this.contactsNewName="",this.contactsDeleteConfirmId=null,this.contactsAddFieldForId=null,this.contactsAddFieldKey="",this.contactsAddFieldValue="",this.imessageEnableConfirm=!1,this.imessageEnabling=!1,this.infoModalOpen=null,this.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={...Ck},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.logsSubTab="session",this.logsChipsExpanded=!1,this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,tool_call:!0,tool_result:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsChipsExpanded=!1,this.sessionLogsExpandedIds=new Set,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.onLoadOlder=()=>this.handleLoadOlderChat(),this.nodesPollInterval=null,this.logsPollInterval=null,this.sessionLogsPollInterval=null,this.debugPollInterval=null,this.auditPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>zf(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null,this._beforeUnloadHandler=()=>{var t;so();const e=this.selectedWorkspace??((t=this.publicChatConfig)==null?void 0:t.accountId)??"";e&&In(e,this.sessionKey,this.chatMessage)}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),_k(this),window.addEventListener("beforeunload",this._beforeUnloadHandler)}firstUpdated(){Mk(this)}disconnectedCallback(){window.removeEventListener("beforeunload",this._beforeUnloadHandler),this.stopEmbeddingPoll(),Pk(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){Lk(this,e)}connect(){Ie(this)}handleChatScroll(e){oh(this,e)}handleLogsScroll(e){ah(this,e)}handleSessionLogsScroll(e){lh(this,e)}exportLogs(e,t){dh(e,t)}exportSessionLogs(e,t){uh(e,t)}resetToolStream(){Oo(this)}resetChatScroll(){ch(this)}async loadAssistantIdentity(){await Mo(this)}applySettings(e){nt(this,e)}setTab(e){Nf(this,e)}setTheme(e,t){Bf(this,e,t)}async loadOverview(){await dd(this)}async loadCron(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.cronForm={...this.cronForm,accountId:(e==null?void 0:e.whatsappAccountId)??void 0},await sr(this)}async handleAbortChat(){await pd(this)}removeQueuedMessage(e){Vf(this,e)}async handleSendChat(e,t){await Gf(this,e,t)}async handleWhatsAppStart(e,t){await Rk(this,e,t)}async handleWhatsAppWait(e){await Dk(this,e)}async handleWhatsAppLogout(e){await Nk(this,e)}async handleAddWhatsAppAccount(e){await Bk(this,e)}async handleRemoveWhatsAppAccount(e){await Fk(this,e)}async handleAccessCheck(){await Bl(this)}async handlePinSubmit(e,t){await ak(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await lk(this,e)}async handleLogout(){await dk(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 Bl(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 Zk(this)}async handleLicenseActivate(){await e0(this)}async handleLicenseRemove(){await t0(this)}handleLicenseKeyChange(e){n0(this,e)}async handleAuthStatusCheck(){await Gk(this)}async handleAuthStart(){await Qk(this)}async handleAuthSubmitCode(e){await Jk(this,e)}handleAuthCodeChange(e){Yk(this,e)}handleSkipToWhatsApp(){Xk(this)}async handleGatewayHealthCheck(){await i0(this)}async handleGatewayRestart(){await s0(this)}async handleUpdateCheck(){await ku(this)}async handleUpdateRun(){await zw(this)}handleUpdateDismissResult(){jw(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 re(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>va);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){re(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>va);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await sd(this)}async clearAudit(){await mf(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,Zt(this,t),Yo(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();re(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>pk);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.chatSuggestion=null,this.resetChatScroll(),this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}re(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>Ei);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this).then(()=>{Jt(this,!0)})})}async handleLoadOlderChat(){if(this.chatLoadingOlder||!this.chatHistoryHasMore)return;const e=rh(this),{loadOlderChatHistory:t}=await re(async()=>{const{loadOlderChatHistory:i}=await Promise.resolve().then(()=>Ei);return{loadOlderChatHistory:i}},void 0,import.meta.url);await t(this)&&e&&(await this.updateComplete,e())}handleAdvancedLoad(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.sessionLogsEntries=[],this.sessionLogsCursors={},this.sessionLogsAgents=[],this.advancedTab==="cron"&&this.loadCron(),this.advancedTab==="logs"&&(this.logsSubTab==="session"?re(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>id);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):re(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>Th);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&re(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>cf);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await Ok(this)}async handleChannelConfigReload(){await Uk(this)}handleNostrProfileEdit(e,t){Kk(this,e,t)}handleNostrProfileCancel(){zk(this)}handleNostrProfileFieldChange(e,t){Hk(this,e,t)}async handleNostrProfileSave(){await jk(this)}async handleNostrProfileImport(){await Vk(this)}handleNostrProfileToggleAdvanced(){qk(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;re(async()=>{const{loadContacts:t}=await Promise.resolve().then(()=>hk);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 re(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>hi);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await re(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>hi);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await re(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>Sh);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 re(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>hi);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 re(async()=>{const{renameWorkspace:i}=await Promise.resolve().then(()=>hi);return{renameWorkspace:i}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){so(),this.selectedWorkspace&&In(this.selectedWorkspace,this.sessionKey,this.chatMessage),this.selectedWorkspace=e,localStorage.setItem("taskmaster-selected-workspace",e),kn(e),sa(e),this.settings=ws(),this.chatMessage=Rn(e,this.settings.sessionKey),this.chatAttachments=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestion=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.chatQueue=[],this.lastError=null,this.reloadCurrentPageData()}getSelectedWorkspaceInfo(){return this.selectedWorkspace?this.workspaces.find(e=>e.name===this.selectedWorkspace)??null:null}reloadCurrentPageData(){this.loadAuditEntries(),this.adminsPage?this.handleAdminsLoad():this.contactsPage?this.handleContactsLoad():this.filesPage?this.handleFilesLoad():this.chatPage?this.handleChatLoad():this.advancedPage&&this.handleAdvancedLoad()}initWorkspaceSelection(){if(this.workspaces.length===0){this.reloadCurrentPageData();return}const e=localStorage.getItem("taskmaster-selected-workspace"),t=e?this.workspaces.find(n=>n.name===e):null;if(t)this.selectedWorkspace=t.name;else{const n=this.workspaces.find(i=>i.isDefault)??this.workspaces[0];this.selectedWorkspace=n.name,localStorage.setItem("taskmaster-selected-workspace",n.name)}kn(this.selectedWorkspace),sa(this.selectedWorkspace),this.settings=ws(),this.chatMessage=Rn(this.selectedWorkspace,this.settings.sessionKey),this.reloadCurrentPageData()}render(){return u`${xk(this)}${this.auditModalOpen?Ek(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):k}`}};m([y()],g.prototype,"settings",2);m([y()],g.prototype,"password",2);m([y()],g.prototype,"tab",2);m([y()],g.prototype,"onboarding",2);m([y()],g.prototype,"setup",2);m([y()],g.prototype,"filesPage",2);m([y()],g.prototype,"browserPage",2);m([y()],g.prototype,"adminsPage",2);m([y()],g.prototype,"contactsPage",2);m([y()],g.prototype,"chatPage",2);m([y()],g.prototype,"advancedPage",2);m([y()],g.prototype,"advancedTab",2);m([y()],g.prototype,"publicChat",2);m([y()],g.prototype,"publicChatConfig",2);m([y()],g.prototype,"publicChatSessionKey",2);m([y()],g.prototype,"publicChatAuthenticated",2);m([y()],g.prototype,"publicChatAuthStep",2);m([y()],g.prototype,"connected",2);m([y()],g.prototype,"accessState",2);m([y()],g.prototype,"theme",2);m([y()],g.prototype,"themeResolved",2);m([y()],g.prototype,"hello",2);m([y()],g.prototype,"lastError",2);m([y()],g.prototype,"eventLog",2);m([y()],g.prototype,"assistantName",2);m([y()],g.prototype,"assistantAvatar",2);m([y()],g.prototype,"assistantAgentId",2);m([y()],g.prototype,"sessionKey",2);m([y()],g.prototype,"chatLoading",2);m([y()],g.prototype,"chatSending",2);m([y()],g.prototype,"chatMessage",2);m([y()],g.prototype,"chatMessages",2);m([y()],g.prototype,"chatHistoryTotal",2);m([y()],g.prototype,"chatHistoryHasMore",2);m([y()],g.prototype,"chatLoadingOlder",2);m([y()],g.prototype,"chatToolMessages",2);m([y()],g.prototype,"chatStream",2);m([y()],g.prototype,"chatInterimText",2);m([y()],g.prototype,"chatSuggestion",2);m([y()],g.prototype,"chatStreamStartedAt",2);m([y()],g.prototype,"chatRunId",2);m([y()],g.prototype,"compactionStatus",2);m([y()],g.prototype,"chatAvatarUrl",2);m([y()],g.prototype,"chatThinkingLevel",2);m([y()],g.prototype,"chatModelProvider",2);m([y()],g.prototype,"chatModel",2);m([y()],g.prototype,"chatModelCatalog",2);m([y()],g.prototype,"chatVerboseLevel",2);m([y()],g.prototype,"chatFillerEnabled",2);m([y()],g.prototype,"chatQueue",2);m([y()],g.prototype,"chatAttachments",2);m([y()],g.prototype,"sidebarOpen",2);m([y()],g.prototype,"sidebarContent",2);m([y()],g.prototype,"sidebarError",2);m([y()],g.prototype,"splitRatio",2);m([y()],g.prototype,"nodesLoading",2);m([y()],g.prototype,"nodes",2);m([y()],g.prototype,"devicesLoading",2);m([y()],g.prototype,"devicesError",2);m([y()],g.prototype,"devicesList",2);m([y()],g.prototype,"execApprovalsLoading",2);m([y()],g.prototype,"execApprovalsSaving",2);m([y()],g.prototype,"execApprovalsDirty",2);m([y()],g.prototype,"execApprovalsSnapshot",2);m([y()],g.prototype,"execApprovalsForm",2);m([y()],g.prototype,"execApprovalsSelectedAgent",2);m([y()],g.prototype,"execApprovalsTarget",2);m([y()],g.prototype,"execApprovalsTargetNodeId",2);m([y()],g.prototype,"execApprovalQueue",2);m([y()],g.prototype,"execApprovalBusy",2);m([y()],g.prototype,"execApprovalError",2);m([y()],g.prototype,"configLoading",2);m([y()],g.prototype,"configRaw",2);m([y()],g.prototype,"configRawOriginal",2);m([y()],g.prototype,"configValid",2);m([y()],g.prototype,"configIssues",2);m([y()],g.prototype,"configSaving",2);m([y()],g.prototype,"configApplying",2);m([y()],g.prototype,"updateRunning",2);m([y()],g.prototype,"applySessionKey",2);m([y()],g.prototype,"configSnapshot",2);m([y()],g.prototype,"configSchema",2);m([y()],g.prototype,"configSchemaVersion",2);m([y()],g.prototype,"configSchemaLoading",2);m([y()],g.prototype,"configUiHints",2);m([y()],g.prototype,"configForm",2);m([y()],g.prototype,"configFormOriginal",2);m([y()],g.prototype,"configFormDirty",2);m([y()],g.prototype,"configFormMode",2);m([y()],g.prototype,"configSearchQuery",2);m([y()],g.prototype,"configActiveSection",2);m([y()],g.prototype,"configActiveSubsection",2);m([y()],g.prototype,"channelsLoading",2);m([y()],g.prototype,"channelsSnapshot",2);m([y()],g.prototype,"channelsError",2);m([y()],g.prototype,"channelsLastSuccess",2);m([y()],g.prototype,"whatsappLoginMessage",2);m([y()],g.prototype,"whatsappLoginQrDataUrl",2);m([y()],g.prototype,"whatsappLoginConnected",2);m([y()],g.prototype,"whatsappBusy",2);m([y()],g.prototype,"whatsappActiveQrAccountId",2);m([y()],g.prototype,"whatsappPairedPhone",2);m([y()],g.prototype,"addingWhatsAppAccount",2);m([y()],g.prototype,"newWhatsAppAccountName",2);m([y()],g.prototype,"whatsappAccountError",2);m([y()],g.prototype,"whatsappAccountSaving",2);m([y()],g.prototype,"whatsappSettingsOpen",2);m([y()],g.prototype,"publicChatToggleBusy",2);m([y()],g.prototype,"brandingBusy",2);m([y()],g.prototype,"brandingExpanded",2);m([y()],g.prototype,"tailscaleStatus",2);m([y()],g.prototype,"tailscaleBusy",2);m([y()],g.prototype,"tailscaleAuthUrl",2);m([y()],g.prototype,"tailscaleError",2);m([y()],g.prototype,"tailscaleFunnelEnableUrl",2);m([y()],g.prototype,"tailscaleDisableConfirm",2);m([y()],g.prototype,"wifiStatus",2);m([y()],g.prototype,"wifiNetworks",2);m([y()],g.prototype,"wifiBusy",2);m([y()],g.prototype,"wifiError",2);m([y()],g.prototype,"wifiPassword",2);m([y()],g.prototype,"wifiSelectedSsid",2);m([y()],g.prototype,"networkPort",2);m([y()],g.prototype,"networkHostname",2);m([y()],g.prototype,"networkPortInput",2);m([y()],g.prototype,"networkHostnameInput",2);m([y()],g.prototype,"networkModalOpen",2);m([y()],g.prototype,"networkBusy",2);m([y()],g.prototype,"networkError",2);m([y()],g.prototype,"networkSuccess",2);m([y()],g.prototype,"wifiModalOpen",2);m([y()],g.prototype,"licenseKey",2);m([y()],g.prototype,"licenseBusy",2);m([y()],g.prototype,"licenseValid",2);m([y()],g.prototype,"licenseMessage",2);m([y()],g.prototype,"licenseTier",2);m([y()],g.prototype,"licenseDeviceId",2);m([y()],g.prototype,"licenseStoredKey",2);m([y()],g.prototype,"licenseRemoveConfirm",2);m([y()],g.prototype,"authConnected",2);m([y()],g.prototype,"authBusy",2);m([y()],g.prototype,"authMessage",2);m([y()],g.prototype,"authUrl",2);m([y()],g.prototype,"authCodeInput",2);m([y()],g.prototype,"authExpiresIn",2);m([y()],g.prototype,"setupStep",2);m([y()],g.prototype,"gatewayHealthy",2);m([y()],g.prototype,"gatewayHealthLoading",2);m([y()],g.prototype,"gatewayHealthMessage",2);m([y()],g.prototype,"gatewayRestartBusy",2);m([y()],g.prototype,"updateAvailable",2);m([y()],g.prototype,"currentVersion",2);m([y()],g.prototype,"latestVersion",2);m([y()],g.prototype,"updateChecking",2);m([y()],g.prototype,"updateMessage",2);m([y()],g.prototype,"updateProgressSteps",2);m([y()],g.prototype,"updateLastResult",2);m([y()],g.prototype,"uninstallConfirm",2);m([y()],g.prototype,"uninstallBusy",2);m([y()],g.prototype,"uninstallDone",2);m([y()],g.prototype,"uninstallError",2);m([y()],g.prototype,"uninstallConfirmText",2);m([y()],g.prototype,"nostrProfileFormState",2);m([y()],g.prototype,"nostrProfileAccountId",2);m([y()],g.prototype,"presenceLoading",2);m([y()],g.prototype,"presenceEntries",2);m([y()],g.prototype,"presenceError",2);m([y()],g.prototype,"presenceStatus",2);m([y()],g.prototype,"agentsLoading",2);m([y()],g.prototype,"agentsList",2);m([y()],g.prototype,"agentsError",2);m([y()],g.prototype,"sessionsLoading",2);m([y()],g.prototype,"sessionsResult",2);m([y()],g.prototype,"sessionsError",2);m([y()],g.prototype,"cronLoading",2);m([y()],g.prototype,"cronJobs",2);m([y()],g.prototype,"cronStatus",2);m([y()],g.prototype,"cronError",2);m([y()],g.prototype,"cronForm",2);m([y()],g.prototype,"cronRunsJobId",2);m([y()],g.prototype,"cronRuns",2);m([y()],g.prototype,"cronBusy",2);m([y()],g.prototype,"cronNewEventModal",2);m([y()],g.prototype,"cronDetailJobId",2);m([y()],g.prototype,"cronEditJobId",2);m([y()],g.prototype,"cronPendingDeleteId",2);m([y()],g.prototype,"cronRunModalJobId",2);m([y()],g.prototype,"cronRunModalJobName",2);m([y()],g.prototype,"cronRunResult",2);m([y()],g.prototype,"browserScreencastActive",2);m([y()],g.prototype,"browserScreencastFrame",2);m([y()],g.prototype,"browserScreencastMetadata",2);m([y()],g.prototype,"browserHandoffPending",2);m([y()],g.prototype,"browserHandoffReason",2);m([y()],g.prototype,"browserHandoffId",2);m([y()],g.prototype,"browserInputMode",2);m([y()],g.prototype,"browserFullscreen",2);m([y()],g.prototype,"browserLoading",2);m([y()],g.prototype,"browserError",2);m([y()],g.prototype,"filesLoading",2);m([y()],g.prototype,"filesTree",2);m([y()],g.prototype,"filesRoot",2);m([y()],g.prototype,"filesError",2);m([y()],g.prototype,"filesSelectedPath",2);m([y()],g.prototype,"filesSelectedPaths",2);m([y()],g.prototype,"filesPreviewContent",2);m([y()],g.prototype,"filesPreviewLoading",2);m([y()],g.prototype,"filesPreviewBinary",2);m([y()],g.prototype,"filesPreviewSize",2);m([y()],g.prototype,"filesExpandedDirs",2);m([y()],g.prototype,"filesCurrentDir",2);m([y()],g.prototype,"filesPendingDeletePath",2);m([y()],g.prototype,"filesMessage",2);m([y()],g.prototype,"filesUploadBusy",2);m([y()],g.prototype,"filesReindexBusy",2);m([y()],g.prototype,"filesMemoryStatus",2);m([y()],g.prototype,"embeddingDownloading",2);m([y()],g.prototype,"filesSearchQuery",2);m([y()],g.prototype,"filesSearchResults",2);m([y()],g.prototype,"filesSearchLoading",2);m([y()],g.prototype,"filesSearchAgentId",2);m([y()],g.prototype,"auditEntries",2);m([y()],g.prototype,"auditLoading",2);m([y()],g.prototype,"auditModalOpen",2);m([y()],g.prototype,"skillsLoading",2);m([y()],g.prototype,"skillsReport",2);m([y()],g.prototype,"skillsError",2);m([y()],g.prototype,"skillsFilter",2);m([y()],g.prototype,"skillsTypeFilter",2);m([y()],g.prototype,"skillEdits",2);m([y()],g.prototype,"skillsBusyKey",2);m([y()],g.prototype,"skillMessages",2);m([y()],g.prototype,"skillDetail",2);m([y()],g.prototype,"skillDetailTab",2);m([y()],g.prototype,"skillAddModal",2);m([y()],g.prototype,"skillAddForm",2);m([y()],g.prototype,"skillAddFormSource",2);m([y()],g.prototype,"skillEditTab",2);m([y()],g.prototype,"skillDrafts",2);m([y()],g.prototype,"adminsLoading",2);m([y()],g.prototype,"adminPhones",2);m([y()],g.prototype,"adminsError",2);m([y()],g.prototype,"adminsSaving",2);m([y()],g.prototype,"adminsNewPhone",2);m([y()],g.prototype,"contactsLoading",2);m([y()],g.prototype,"contactsSaving",2);m([y()],g.prototype,"contactsRecords",2);m([y()],g.prototype,"contactsError",2);m([y()],g.prototype,"contactsSearchQuery",2);m([y()],g.prototype,"contactsEditingId",2);m([y()],g.prototype,"contactsShowAddForm",2);m([y()],g.prototype,"contactsNewPhone",2);m([y()],g.prototype,"contactsNewName",2);m([y()],g.prototype,"contactsDeleteConfirmId",2);m([y()],g.prototype,"contactsAddFieldForId",2);m([y()],g.prototype,"contactsAddFieldKey",2);m([y()],g.prototype,"contactsAddFieldValue",2);m([y()],g.prototype,"imessageEnableConfirm",2);m([y()],g.prototype,"imessageEnabling",2);m([y()],g.prototype,"infoModalOpen",2);m([y()],g.prototype,"workspaces",2);m([y()],g.prototype,"workspacesLoading",2);m([y()],g.prototype,"workspacesError",2);m([y()],g.prototype,"selectedWorkspace",2);m([y()],g.prototype,"addingWorkspace",2);m([y()],g.prototype,"newWorkspaceName",2);m([y()],g.prototype,"newWorkspacePath",2);m([y()],g.prototype,"newWorkspacePin",2);m([y()],g.prototype,"accountPinModalOpen",2);m([y()],g.prototype,"accountPinBusy",2);m([y()],g.prototype,"accountPinError",2);m([y()],g.prototype,"accountPinSuccess",2);m([y()],g.prototype,"apiKeyProviders",2);m([y()],g.prototype,"apiKeyModalOpen",2);m([y()],g.prototype,"apiKeyBusy",2);m([y()],g.prototype,"apiKeyError",2);m([y()],g.prototype,"apiKeySuccess",2);m([y()],g.prototype,"apiKeySavingProvider",2);m([y()],g.prototype,"authApiKeyMode",2);m([y()],g.prototype,"authApiKeyInput",2);m([y()],g.prototype,"authApiKeyBusy",2);m([y()],g.prototype,"authApiKeyError",2);m([y()],g.prototype,"pinChanging",2);m([y()],g.prototype,"pinChangeBusy",2);m([y()],g.prototype,"pinChangeError",2);m([y()],g.prototype,"loginChangePinMode",2);m([y()],g.prototype,"changePinBusy",2);m([y()],g.prototype,"changePinError",2);m([y()],g.prototype,"changePinSuccess",2);m([y()],g.prototype,"workspaceSaving",2);m([y()],g.prototype,"workspaceRemoveConfirm",2);m([y()],g.prototype,"renamingWorkspace",2);m([y()],g.prototype,"renameWorkspaceName",2);m([y()],g.prototype,"debugLoading",2);m([y()],g.prototype,"debugStatus",2);m([y()],g.prototype,"debugHealth",2);m([y()],g.prototype,"debugModels",2);m([y()],g.prototype,"debugHeartbeat",2);m([y()],g.prototype,"debugCallMethod",2);m([y()],g.prototype,"debugCallParams",2);m([y()],g.prototype,"debugCallResult",2);m([y()],g.prototype,"debugCallError",2);m([y()],g.prototype,"logsLoading",2);m([y()],g.prototype,"logsError",2);m([y()],g.prototype,"logsFile",2);m([y()],g.prototype,"logsEntries",2);m([y()],g.prototype,"logsFilterText",2);m([y()],g.prototype,"logsLevelFilters",2);m([y()],g.prototype,"logsAutoFollow",2);m([y()],g.prototype,"logsTruncated",2);m([y()],g.prototype,"logsCursor",2);m([y()],g.prototype,"logsLastFetchAt",2);m([y()],g.prototype,"logsLimit",2);m([y()],g.prototype,"logsMaxBytes",2);m([y()],g.prototype,"logsAtBottom",2);m([y()],g.prototype,"logsSubTab",2);m([y()],g.prototype,"logsChipsExpanded",2);m([y()],g.prototype,"sessionLogsLoading",2);m([y()],g.prototype,"sessionLogsError",2);m([y()],g.prototype,"sessionLogsEntries",2);m([y()],g.prototype,"sessionLogsFilterText",2);m([y()],g.prototype,"sessionLogsTypeFilters",2);m([y()],g.prototype,"sessionLogsAgentFilters",2);m([y()],g.prototype,"sessionLogsAgents",2);m([y()],g.prototype,"sessionLogsAutoFollow",2);m([y()],g.prototype,"sessionLogsChipsExpanded",2);m([y()],g.prototype,"sessionLogsCursors",2);m([y()],g.prototype,"sessionLogsLastFetchAt",2);m([y()],g.prototype,"sessionLogsAtBottom",2);m([y()],g.prototype,"chatUserNearBottom",2);g=m([Gl("taskmaster-app")],g);
|
|
4227
|
+
//# sourceMappingURL=index-zUaHKRVM.js.map
|