@rubytech/taskmaster 1.0.107 → 1.0.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/system-prompt.js +2 -0
- package/dist/agents/taskmaster-tools.js +5 -0
- package/dist/agents/tool-policy.js +2 -1
- package/dist/agents/tools/authorize-admin-tool.js +1 -1
- package/dist/agents/tools/software-update-tool.js +114 -0
- package/dist/auto-reply/reply/commands-status.js +5 -9
- package/dist/auto-reply/reply/get-reply-run.js +1 -1
- package/dist/auto-reply/reply/get-reply.js +1 -1
- package/dist/auto-reply/reply/model-selection.js +1 -1
- package/dist/browser/routes/screencast.js +1 -1
- package/dist/browser/screencast.js +1 -1
- package/dist/build-info.json +3 -3
- package/dist/commands/agent.js +2 -2
- package/dist/control-ui/assets/index-B2FEGOCu.css +1 -0
- package/dist/control-ui/assets/{index-B_zHmTQU.js → index-nLVF-pVT.js} +414 -369
- package/dist/control-ui/assets/index-nLVF-pVT.js.map +1 -0
- package/dist/control-ui/index.html +2 -2
- package/dist/cron/isolated-agent/recipients.js +70 -0
- package/dist/cron/isolated-agent/run.js +43 -13
- package/dist/gateway/server-methods/access.js +3 -3
- package/dist/gateway/server-methods/browser-screencast.js +3 -3
- package/dist/gateway/server-methods/workspaces.js +7 -7
- package/dist/gateway/server.impl.js +1 -1
- package/dist/infra/heartbeat-runner.js +17 -0
- package/dist/infra/heartbeat-update-notify.js +120 -0
- package/dist/infra/tunnel.js +1 -1
- package/dist/memory/embeddings.js +0 -4
- package/dist/memory/manager.js +3 -3
- package/dist/web/inbound/media.js +1 -1
- package/dist/web/login-qr.js +0 -23
- package/dist/web/providers/cloud/receive.js +1 -1
- package/dist/web/providers/cloud/webhook.js +1 -1
- package/package.json +1 -1
- package/taskmaster-docs/USER-GUIDE.md +17 -39
- package/dist/control-ui/assets/index-2XyxmiR6.css +0 -1
- package/dist/control-ui/assets/index-B_zHmTQU.js.map +0 -1
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var nd=Object.defineProperty;var id=(e,t,n)=>t in e?nd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var U=(e,t,n)=>id(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 sd="modulepreload",od=function(e,t){return new URL(e,t).href},gr={},ie=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]"),u=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=c(n.map(l=>{if(l=od(l,i),l in gr)return;gr[l]=!0;const p=l.endsWith(".css"),f=p?'[rel="stylesheet"]':"";if(i)for(let h=r.length-1;h>=0;h--){const v=r[h];if(v.href===l&&(!p||v.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${f}`))return;const b=document.createElement("link");if(b.rel=p?"stylesheet":sd,p||(b.as="script"),b.crossOrigin="",b.href=l,u&&b.setAttribute("nonce",u),document.head.appendChild(b),p)return new Promise((h,v)=>{b.addEventListener("load",h),b.addEventListener("error",()=>v(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 Zn=globalThis,so=Zn.ShadowRoot&&(Zn.ShadyCSS===void 0||Zn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,oo=Symbol(),mr=new WeakMap;let ll=class{constructor(t,n,i){if(this._$cssResult$=!0,i!==oo)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(so&&t===void 0){const i=n!==void 0&&n.length===1;i&&(t=mr.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&mr.set(n,t))}return t}toString(){return this.cssText}};const rd=e=>new ll(typeof e=="string"?e:e+"",void 0,oo),ad=(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 ll(n,e,oo)},ld=(e,t)=>{if(so)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const i=document.createElement("style"),s=Zn.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=n.cssText,e.appendChild(i)}},yr=so?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const i of t.cssRules)n+=i.cssText;return rd(n)})(e):e;const{is:cd,defineProperty:ud,getOwnPropertyDescriptor:dd,getOwnPropertyNames:pd,getOwnPropertySymbols:hd,getPrototypeOf:fd}=Object,Xe=globalThis,vr=Xe.trustedTypes,gd=vr?vr.emptyScript:"",Qi=Xe.reactiveElementPolyfillSupport,ln=(e,t)=>e,ii={toAttribute(e,t){switch(t){case Boolean:e=e?gd: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)=>!cd(e,t),br={attribute:!0,type:String,converter:ii,reflect:!1,useDefault:!1,hasChanged:ro};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Xe.litPropertyMetadata??(Xe.litPropertyMetadata=new WeakMap);let Mt=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=br){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&&ud(this.prototype,t,s)}}static getPropertyDescriptor(t,n,i){const{get:s,set:o}=dd(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)??br}static _$Ei(){if(this.hasOwnProperty(ln("elementProperties")))return;const t=fd(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(ln("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ln("properties"))){const n=this.properties,i=[...pd(n),...hd(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(yr(s))}else t!==void 0&&n.push(yr(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 ld(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:ii).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),u=typeof a.converter=="function"?{fromAttribute:a.converter}:((o=a.converter)==null?void 0:o.fromAttribute)!==void 0?a.converter:ii;this._$Em=s;const c=u.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,u=this[o];a!==!0||this._$AL.has(o)||u===void 0||this.C(o,void 0,r,u)}}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){}};Mt.elementStyles=[],Mt.shadowRootOptions={mode:"open"},Mt[ln("elementProperties")]=new Map,Mt[ln("finalized")]=new Map,Qi==null||Qi({ReactiveElement:Mt}),(Xe.reactiveElementVersions??(Xe.reactiveElementVersions=[])).push("2.1.2");const cn=globalThis,wr=e=>e,si=cn.trustedTypes,kr=si?si.createPolicy("lit-html",{createHTML:e=>e}):void 0,cl="$lit$",Ye=`lit$${Math.random().toFixed(9).slice(2)}$`,ul="?"+Ye,md=`<${ul}>`,pt=document,vn=()=>pt.createComment(""),bn=e=>e===null||typeof e!="object"&&typeof e!="function",ao=Array.isArray,yd=e=>ao(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",Yi=`[
|
|
2
|
-
\f\r]`,
|
|
3
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),xr=/'/g,Ar=/"/g,dl=/^(?:script|style|textarea|title)$/i,vd=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),d=vd(1),Je=Symbol.for("lit-noChange"),S=Symbol.for("lit-nothing"),Er=new WeakMap,ct=pt.createTreeWalker(pt,129);function pl(e,t){if(!ao(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return kr!==void 0?kr.createHTML(t):t}const bd=(e,t)=>{const n=e.length-1,i=[];let s,o=t===2?"<svg>":t===3?"<math>":"",r=Qt;for(let a=0;a<n;a++){const u=e[a];let c,l,p=-1,f=0;for(;f<u.length&&(r.lastIndex=f,l=r.exec(u),l!==null);)f=r.lastIndex,r===Qt?l[1]==="!--"?r=Sr:l[1]!==void 0?r=$r:l[2]!==void 0?(dl.test(l[2])&&(s=RegExp("</"+l[2],"g")),r=ot):l[3]!==void 0&&(r=ot):r===ot?l[0]===">"?(r=s??Qt,p=-1):l[1]===void 0?p=-2:(p=r.lastIndex-l[2].length,c=l[1],r=l[3]===void 0?ot:l[3]==='"'?Ar:xr):r===Ar||r===xr?r=ot:r===Sr||r===$r?r=Qt:(r=ot,s=void 0);const b=r===ot&&e[a+1].startsWith("/>")?" ":"";o+=r===Qt?u+md:p>=0?(i.push(c),u.slice(0,p)+cl+u.slice(p)+Ye+b):u+Ye+(p===-2?a:b)}return[pl(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let Ps=class hl{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let o=0,r=0;const a=t.length-1,u=this.parts,[c,l]=bd(t,n);if(this.el=hl.createElement(c,i),ct.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(s=ct.nextNode())!==null&&u.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const p of s.getAttributeNames())if(p.endsWith(cl)){const f=l[r++],b=s.getAttribute(p).split(Ye),h=/([.?@])?(.*)/.exec(f);u.push({type:1,index:o,name:h[2],strings:b,ctor:h[1]==="."?kd:h[1]==="?"?Sd:h[1]==="@"?$d:Ai}),s.removeAttribute(p)}else p.startsWith(Ye)&&(u.push({type:6,index:o}),s.removeAttribute(p));if(dl.test(s.tagName)){const p=s.textContent.split(Ye),f=p.length-1;if(f>0){s.textContent=si?si.emptyScript:"";for(let b=0;b<f;b++)s.append(p[b],vn()),ct.nextNode(),u.push({type:2,index:++o});s.append(p[f],vn())}}}else if(s.nodeType===8)if(s.data===ul)u.push({type:2,index:o});else{let p=-1;for(;(p=s.data.indexOf(Ye,p+1))!==-1;)u.push({type:7,index:o}),p+=Ye.length-1}o++}}static createElement(t,n){const i=pt.createElement("template");return i.innerHTML=t,i}};function Dt(e,t,n=e,i){var r,a;if(t===Je)return t;let s=i!==void 0?(r=n._$Co)==null?void 0:r[i]:n._$Cl;const o=bn(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=Dt(e,s._$AS(e,t.values),s,i)),t}class wd{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)??pt).importNode(n,!0);ct.currentNode=s;let o=ct.nextNode(),r=0,a=0,u=i[0];for(;u!==void 0;){if(r===u.index){let c;u.type===2?c=new xi(o,o.nextSibling,this,t):u.type===1?c=new u.ctor(o,u.name,u.strings,this,t):u.type===6&&(c=new xd(o,this,t)),this._$AV.push(c),u=i[++a]}r!==(u==null?void 0:u.index)&&(o=ct.nextNode(),r++)}return ct.currentNode=pt,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 xi=class fl{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=S,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=Dt(this,t,n),bn(t)?t===S||t==null||t===""?(this._$AH!==S&&this._$AR(),this._$AH=S):t!==this._$AH&&t!==Je&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):yd(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!==S&&bn(this._$AH)?this._$AA.nextSibling.data=t:this.T(pt.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=Ps.createElement(pl(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 wd(s,this),a=r.u(this.options);r.p(n),this.T(a),this._$AH=r}}_$AC(t){let n=Er.get(t.strings);return n===void 0&&Er.set(t.strings,n=new Ps(t)),n}k(t){ao(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 fl(this.O(vn()),this.O(vn()),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=wr(t).nextSibling;wr(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class Ai{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,i,s,o){this.type=1,this._$AH=S,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=S}_$AI(t,n=this,i,s){const o=this.strings;let r=!1;if(o===void 0)t=Dt(this,t,n,0),r=!bn(t)||t!==this._$AH&&t!==Je,r&&(this._$AH=t);else{const a=t;let u,c;for(t=o[0],u=0;u<o.length-1;u++)c=Dt(this,a[i+u],n,u),c===Je&&(c=this._$AH[u]),r||(r=!bn(c)||c!==this._$AH[u]),c===S?t=S:t!==S&&(t+=(c??"")+o[u+1]),this._$AH[u]=c}r&&!s&&this.j(t)}j(t){t===S?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let kd=class extends Ai{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===S?void 0:t}},Sd=class extends Ai{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==S)}},$d=class extends Ai{constructor(t,n,i,s,o){super(t,n,i,s,o),this.type=5}_$AI(t,n=this){if((t=Dt(this,t,n,0)??S)===Je)return;const i=this._$AH,s=t===S&&i!==S||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==S&&(i===S||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)}},xd=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){Dt(this,t)}};const Ad={I:xi},Xi=cn.litHtmlPolyfillSupport;Xi==null||Xi(Ps,xi),(cn.litHtmlVersions??(cn.litHtmlVersions=[])).push("3.3.2");const Ed=(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 xi(t.insertBefore(vn(),o),o,void 0,n??{})}return s._$AI(e),s};const dt=globalThis;let Lt=class extends Mt{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=Ed(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 Je}};var al;Lt._$litElement$=!0,Lt.finalized=!0,(al=dt.litElementHydrateSupport)==null||al.call(dt,{LitElement:Lt});const Zi=dt.litElementPolyfillSupport;Zi==null||Zi({LitElement:Lt});(dt.litElementVersions??(dt.litElementVersions=[])).push("4.2.2");const gl=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const Cd={attribute:!0,type:String,converter:ii,reflect:!1,hasChanged:ro},Td=(e=Cd,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 u=t.get.call(this);t.set.call(this,a),this.requestUpdate(r,u,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 u=this[r];t.call(this,a),this.requestUpdate(r,u,e,!0,a)}}throw Error("Unsupported decorator location: "+i)};function Ei(e){return(t,n)=>typeof n=="object"?Td(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 Ei({...e,state:!0,attribute:!1})}const _d=50,Md=200,Pd="Assistant";function Cr(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function Ls(e){const t=Cr(e==null?void 0:e.name,_d)??Pd,n=Cr((e==null?void 0:e.avatar)??void 0,Md)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function Ld(){return Ls(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const Id="Taskmaster",Rd="/taskmaster-icon.png",Dd="#00d4ff",Nd="";let Nn=null;function Ke(){return Nn||(Nn={name:window.__TASKMASTER_BRAND_NAME__||Id,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||Rd,accentColor:window.__TASKMASTER_ACCENT_COLOR__||Dd,backgroundColor:window.__TASKMASTER_BACKGROUND_COLOR__||Nd},Nn)}function Oe(){return window.__TASKMASTER_WORKSPACE_BRANDS__??{}}function ml(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 yl(e){const t=ml(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)`)}function vl(e){const t=document.documentElement;if(!e){t.style.removeProperty("--brand-bg"),t.style.removeProperty("--brand-bg-subtle"),t.style.removeProperty("--brand-bg-card");return}const n=ml(e);n&&(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 un(e){const t=Ke(),n=Oe(),i=e?n[e]:void 0,s=(i==null?void 0:i.accentColor)??t.accentColor;yl(s);const o=(i==null?void 0:i.backgroundColor)??t.backgroundColor;vl(o)}const oi="taskmaster.control.settings.v1",bl="taskmaster.account.settings.";function dn(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const _t={gatewayUrl:dn(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},Qe={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function Bd(){try{const e=localStorage.getItem(oi);if(!e)return{..._t,gatewayUrl:dn()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():dn(),token:typeof t.token=="string"?t.token:_t.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:_t.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:_t.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:_t.navGroupsCollapsed}}catch{return{..._t,gatewayUrl:dn()}}}function Od(e){if(!e)return{...Qe};try{const t=localStorage.getItem(bl+e);if(!t)return{...Qe};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():Qe.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||Qe.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:Qe.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:Qe.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:Qe.splitRatio}}catch{return{...Qe}}}let ri=null;function Tr(e){ri=e}function Ji(){return{...Bd(),...Od(ri)}}function Fd(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(oi,JSON.stringify(t)),ri){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(bl+ri,JSON.stringify(n))}}(function(){try{const t=localStorage.getItem(oi);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const i={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:dn(),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(oi,JSON.stringify(i))}catch{}})();function wl(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 Ud=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,Bn=/<\s*\/?\s*final\b[^>]*>/gi,_r=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Wd(e,t){return e.trimStart()}function Kd(e,t){if(!e||!Ud.test(e))return e;let n=e;Bn.test(n)?(Bn.lastIndex=0,n=n.replace(Bn,"")):Bn.lastIndex=0,_r.lastIndex=0;let i="",s=0,o=!1;for(const r of n.matchAll(_r)){const a=r.index??0,u=r[1]==="/";o?u&&(o=!1):(i+=n.slice(s,a),u||(o=!0)),s=a+r[0].length}return i+=n.slice(s),Wd(i)}function kl(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function Ci(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 u=Math.round(a/60);if(u<60)return`in ${u}m`;const c=Math.round(u/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 Sl(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 zd(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function $l(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 es(e){return Kd(e)}const Hd=/^\[([^\]]+)\]\s*/,jd=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],ts=new WeakMap,ns=new WeakMap;function qd(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:jd.some(t=>e.startsWith(`${t} `))}function is(e){const t=e.match(Hd);if(!t)return e;const n=t[1]??"";return qd(n)?e.slice(t[0].length):e}function pn(e){const t=e,n=typeof t.role=="string"?t.role:"",i=t.content;if(typeof i=="string")return n==="assistant"?es(i):is(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"?
|
|
5
|
-
`);const s=
|
|
6
|
-
`):null}function
|
|
7
|
-
`)}return typeof t.text=="string"?t.text:null}function
|
|
8
|
-
`):""}const
|
|
1
|
+
var od=Object.defineProperty;var rd=(e,t,n)=>t in e?od(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var U=(e,t,n)=>rd(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 ad="modulepreload",ld=function(e,t){return new URL(e,t).href},yr={},ie=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]"),u=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=c(n.map(l=>{if(l=ld(l,i),l in yr)return;yr[l]=!0;const p=l.endsWith(".css"),f=p?'[rel="stylesheet"]':"";if(i)for(let h=r.length-1;h>=0;h--){const v=r[h];if(v.href===l&&(!p||v.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${f}`))return;const b=document.createElement("link");if(b.rel=p?"stylesheet":ad,p||(b.as="script"),b.crossOrigin="",b.href=l,u&&b.setAttribute("nonce",u),document.head.appendChild(b),p)return new Promise((h,v)=>{b.addEventListener("load",h),b.addEventListener("error",()=>v(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 ei=globalThis,oo=ei.ShadowRoot&&(ei.ShadyCSS===void 0||ei.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ro=Symbol(),vr=new WeakMap;let cl=class{constructor(t,n,i){if(this._$cssResult$=!0,i!==ro)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(oo&&t===void 0){const i=n!==void 0&&n.length===1;i&&(t=vr.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&vr.set(n,t))}return t}toString(){return this.cssText}};const cd=e=>new cl(typeof e=="string"?e:e+"",void 0,ro),ud=(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 cl(n,e,ro)},dd=(e,t)=>{if(oo)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const i=document.createElement("style"),s=ei.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=n.cssText,e.appendChild(i)}},br=oo?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const i of t.cssRules)n+=i.cssText;return cd(n)})(e):e;const{is:pd,defineProperty:hd,getOwnPropertyDescriptor:fd,getOwnPropertyNames:gd,getOwnPropertySymbols:md,getPrototypeOf:yd}=Object,Xe=globalThis,wr=Xe.trustedTypes,vd=wr?wr.emptyScript:"",Yi=Xe.reactiveElementPolyfillSupport,un=(e,t)=>e,oi={toAttribute(e,t){switch(t){case Boolean:e=e?vd: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}},ao=(e,t)=>!pd(e,t),kr={attribute:!0,type:String,converter:oi,reflect:!1,useDefault:!1,hasChanged:ao};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Xe.litPropertyMetadata??(Xe.litPropertyMetadata=new WeakMap);let Pt=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=kr){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&&hd(this.prototype,t,s)}}static getPropertyDescriptor(t,n,i){const{get:s,set:o}=fd(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)??kr}static _$Ei(){if(this.hasOwnProperty(un("elementProperties")))return;const t=yd(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(un("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(un("properties"))){const n=this.properties,i=[...gd(n),...md(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(br(s))}else t!==void 0&&n.push(br(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 dd(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:oi).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),u=typeof a.converter=="function"?{fromAttribute:a.converter}:((o=a.converter)==null?void 0:o.fromAttribute)!==void 0?a.converter:oi;this._$Em=s;const c=u.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??ao)(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,u=this[o];a!==!0||this._$AL.has(o)||u===void 0||this.C(o,void 0,r,u)}}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){}};Pt.elementStyles=[],Pt.shadowRootOptions={mode:"open"},Pt[un("elementProperties")]=new Map,Pt[un("finalized")]=new Map,Yi==null||Yi({ReactiveElement:Pt}),(Xe.reactiveElementVersions??(Xe.reactiveElementVersions=[])).push("2.1.2");const dn=globalThis,Sr=e=>e,ri=dn.trustedTypes,$r=ri?ri.createPolicy("lit-html",{createHTML:e=>e}):void 0,ul="$lit$",Je=`lit$${Math.random().toFixed(9).slice(2)}$`,dl="?"+Je,bd=`<${dl}>`,ht=document,wn=()=>ht.createComment(""),kn=e=>e===null||typeof e!="object"&&typeof e!="function",lo=Array.isArray,wd=e=>lo(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",Ji=`[
|
|
2
|
+
\f\r]`,Jt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,xr=/-->/g,Ar=/>/g,rt=RegExp(`>|${Ji}(?:([^\\s"'>=/]+)(${Ji}*=${Ji}*(?:[^
|
|
3
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Er=/'/g,Cr=/"/g,pl=/^(?:script|style|textarea|title)$/i,kd=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),d=kd(1),et=Symbol.for("lit-noChange"),S=Symbol.for("lit-nothing"),Tr=new WeakMap,ut=ht.createTreeWalker(ht,129);function hl(e,t){if(!lo(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return $r!==void 0?$r.createHTML(t):t}const Sd=(e,t)=>{const n=e.length-1,i=[];let s,o=t===2?"<svg>":t===3?"<math>":"",r=Jt;for(let a=0;a<n;a++){const u=e[a];let c,l,p=-1,f=0;for(;f<u.length&&(r.lastIndex=f,l=r.exec(u),l!==null);)f=r.lastIndex,r===Jt?l[1]==="!--"?r=xr:l[1]!==void 0?r=Ar:l[2]!==void 0?(pl.test(l[2])&&(s=RegExp("</"+l[2],"g")),r=rt):l[3]!==void 0&&(r=rt):r===rt?l[0]===">"?(r=s??Jt,p=-1):l[1]===void 0?p=-2:(p=r.lastIndex-l[2].length,c=l[1],r=l[3]===void 0?rt:l[3]==='"'?Cr:Er):r===Cr||r===Er?r=rt:r===xr||r===Ar?r=Jt:(r=rt,s=void 0);const b=r===rt&&e[a+1].startsWith("/>")?" ":"";o+=r===Jt?u+bd:p>=0?(i.push(c),u.slice(0,p)+ul+u.slice(p)+Je+b):u+Je+(p===-2?a:b)}return[hl(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let Ls=class fl{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let o=0,r=0;const a=t.length-1,u=this.parts,[c,l]=Sd(t,n);if(this.el=fl.createElement(c,i),ut.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(s=ut.nextNode())!==null&&u.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const p of s.getAttributeNames())if(p.endsWith(ul)){const f=l[r++],b=s.getAttribute(p).split(Je),h=/([.?@])?(.*)/.exec(f);u.push({type:1,index:o,name:h[2],strings:b,ctor:h[1]==="."?xd:h[1]==="?"?Ad:h[1]==="@"?Ed:Ci}),s.removeAttribute(p)}else p.startsWith(Je)&&(u.push({type:6,index:o}),s.removeAttribute(p));if(pl.test(s.tagName)){const p=s.textContent.split(Je),f=p.length-1;if(f>0){s.textContent=ri?ri.emptyScript:"";for(let b=0;b<f;b++)s.append(p[b],wn()),ut.nextNode(),u.push({type:2,index:++o});s.append(p[f],wn())}}}else if(s.nodeType===8)if(s.data===dl)u.push({type:2,index:o});else{let p=-1;for(;(p=s.data.indexOf(Je,p+1))!==-1;)u.push({type:7,index:o}),p+=Je.length-1}o++}}static createElement(t,n){const i=ht.createElement("template");return i.innerHTML=t,i}};function Bt(e,t,n=e,i){var r,a;if(t===et)return t;let s=i!==void 0?(r=n._$Co)==null?void 0:r[i]:n._$Cl;const o=kn(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=Bt(e,s._$AS(e,t.values),s,i)),t}class $d{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)??ht).importNode(n,!0);ut.currentNode=s;let o=ut.nextNode(),r=0,a=0,u=i[0];for(;u!==void 0;){if(r===u.index){let c;u.type===2?c=new Ei(o,o.nextSibling,this,t):u.type===1?c=new u.ctor(o,u.name,u.strings,this,t):u.type===6&&(c=new Cd(o,this,t)),this._$AV.push(c),u=i[++a]}r!==(u==null?void 0:u.index)&&(o=ut.nextNode(),r++)}return ut.currentNode=ht,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 Ei=class gl{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=S,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=Bt(this,t,n),kn(t)?t===S||t==null||t===""?(this._$AH!==S&&this._$AR(),this._$AH=S):t!==this._$AH&&t!==et&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):wd(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!==S&&kn(this._$AH)?this._$AA.nextSibling.data=t:this.T(ht.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=Ls.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 $d(s,this),a=r.u(this.options);r.p(n),this.T(a),this._$AH=r}}_$AC(t){let n=Tr.get(t.strings);return n===void 0&&Tr.set(t.strings,n=new Ls(t)),n}k(t){lo(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 gl(this.O(wn()),this.O(wn()),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=Sr(t).nextSibling;Sr(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class Ci{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,i,s,o){this.type=1,this._$AH=S,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=S}_$AI(t,n=this,i,s){const o=this.strings;let r=!1;if(o===void 0)t=Bt(this,t,n,0),r=!kn(t)||t!==this._$AH&&t!==et,r&&(this._$AH=t);else{const a=t;let u,c;for(t=o[0],u=0;u<o.length-1;u++)c=Bt(this,a[i+u],n,u),c===et&&(c=this._$AH[u]),r||(r=!kn(c)||c!==this._$AH[u]),c===S?t=S:t!==S&&(t+=(c??"")+o[u+1]),this._$AH[u]=c}r&&!s&&this.j(t)}j(t){t===S?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let xd=class extends Ci{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===S?void 0:t}},Ad=class extends Ci{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==S)}},Ed=class extends Ci{constructor(t,n,i,s,o){super(t,n,i,s,o),this.type=5}_$AI(t,n=this){if((t=Bt(this,t,n,0)??S)===et)return;const i=this._$AH,s=t===S&&i!==S||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==S&&(i===S||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)}},Cd=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){Bt(this,t)}};const Td={I:Ei},Xi=dn.litHtmlPolyfillSupport;Xi==null||Xi(Ls,Ei),(dn.litHtmlVersions??(dn.litHtmlVersions=[])).push("3.3.2");const _d=(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 Ei(t.insertBefore(wn(),o),o,void 0,n??{})}return s._$AI(e),s};const pt=globalThis;let It=class extends Pt{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=_d(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 et}};var ll;It._$litElement$=!0,It.finalized=!0,(ll=pt.litElementHydrateSupport)==null||ll.call(pt,{LitElement:It});const Zi=pt.litElementPolyfillSupport;Zi==null||Zi({LitElement:It});(pt.litElementVersions??(pt.litElementVersions=[])).push("4.2.2");const ml=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const Md={attribute:!0,type:String,converter:oi,reflect:!1,hasChanged:ao},Pd=(e=Md,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 u=t.get.call(this);t.set.call(this,a),this.requestUpdate(r,u,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 u=this[r];t.call(this,a),this.requestUpdate(r,u,e,!0,a)}}throw Error("Unsupported decorator location: "+i)};function Ti(e){return(t,n)=>typeof n=="object"?Pd(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 Ti({...e,state:!0,attribute:!1})}const Ld=50,Id=200,Rd="Assistant";function _r(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function Is(e){const t=_r(e==null?void 0:e.name,Ld)??Rd,n=_r((e==null?void 0:e.avatar)??void 0,Id)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function Dd(){return Is(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const Bd="Taskmaster",Nd="/taskmaster-icon.png",Od="#00d4ff",Fd="";let On=null;function ze(){return On||(On={name:window.__TASKMASTER_BRAND_NAME__||Bd,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||Nd,accentColor:window.__TASKMASTER_ACCENT_COLOR__||Od,backgroundColor:window.__TASKMASTER_BACKGROUND_COLOR__||Fd},On)}function Fe(){return window.__TASKMASTER_WORKSPACE_BRANDS__??{}}function yl(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 vl(e){const t=yl(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)`)}function bl(e){const t=document.documentElement;if(!e){t.style.removeProperty("--brand-bg"),t.style.removeProperty("--brand-bg-subtle"),t.style.removeProperty("--brand-bg-card");return}const n=yl(e);n&&(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 pn(e){const t=ze(),n=Fe(),i=e?n[e]:void 0,s=(i==null?void 0:i.accentColor)??t.accentColor;vl(s);const o=(i==null?void 0:i.backgroundColor)??t.backgroundColor;bl(o)}const ai="taskmaster.control.settings.v1",wl="taskmaster.account.settings.";function hn(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const Mt={gatewayUrl:hn(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},Ye={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function Ud(){try{const e=localStorage.getItem(ai);if(!e)return{...Mt,gatewayUrl:hn()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():hn(),token:typeof t.token=="string"?t.token:Mt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:Mt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:Mt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:Mt.navGroupsCollapsed}}catch{return{...Mt,gatewayUrl:hn()}}}function Wd(e){if(!e)return{...Ye};try{const t=localStorage.getItem(wl+e);if(!t)return{...Ye};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():Ye.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||Ye.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:Ye.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:Ye.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:Ye.splitRatio}}catch{return{...Ye}}}let li=null;function Mr(e){li=e}function es(){return{...Ud(),...Wd(li)}}function Kd(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(ai,JSON.stringify(t)),li){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(wl+li,JSON.stringify(n))}}(function(){try{const t=localStorage.getItem(ai);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const i={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:hn(),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(ai,JSON.stringify(i))}catch{}})();function kl(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 zd=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,Fn=/<\s*\/?\s*final\b[^>]*>/gi,Pr=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Hd(e,t){return e.trimStart()}function qd(e,t){if(!e||!zd.test(e))return e;let n=e;Fn.test(n)?(Fn.lastIndex=0,n=n.replace(Fn,"")):Fn.lastIndex=0,Pr.lastIndex=0;let i="",s=0,o=!1;for(const r of n.matchAll(Pr)){const a=r.index??0,u=r[1]==="/";o?u&&(o=!1):(i+=n.slice(s,a),u||(o=!0)),s=a+r[0].length}return i+=n.slice(s),Hd(i)}function Sl(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function _i(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 u=Math.round(a/60);if(u<60)return`in ${u}m`;const c=Math.round(u/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 $l(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 jd(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function xl(e,t){return e.length<=t?{text:e,truncated:!1,total:e.length}:{text:e.slice(0,Math.max(0,t)),truncated:!0,total:e.length}}function ci(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function ts(e){return qd(e)}const Vd=/^\[([^\]]+)\]\s*/,Gd=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],ns=new WeakMap,is=new WeakMap;function Qd(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:Gd.some(t=>e.startsWith(`${t} `))}function ss(e){const t=e.match(Vd);if(!t)return e;const n=t[1]??"";return Qd(n)?e.slice(t[0].length):e}function fn(e){const t=e,n=typeof t.role=="string"?t.role:"",i=t.content;if(typeof i=="string")return n==="assistant"?ts(i):ss(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"?ts(o):ss(o)}}return typeof t.text=="string"?n==="assistant"?ts(t.text):ss(t.text):null}function Al(e){if(!e||typeof e!="object")return fn(e);const t=e;if(ns.has(t))return ns.get(t)??null;const n=fn(e);return ns.set(t,n),n}function Lr(e){const n=e.content,i=[];if(Array.isArray(n))for(const a of n){const u=a;if(u.type==="thinking"&&typeof u.thinking=="string"){const c=u.thinking.trim();c&&i.push(c)}}if(i.length>0)return i.join(`
|
|
5
|
+
`);const s=Jd(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 Yd(e){if(!e||typeof e!="object")return Lr(e);const t=e;if(is.has(t))return is.get(t)??null;const n=Lr(e);return is.set(t,n),n}function Jd(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
|
+
`)}return typeof t.text=="string"?t.text:null}function Xd(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 Zd=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,ep=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,tp=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,np=/^A new session was started via \/new or \/reset\./;function ip(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"&&Zd.test(s)||n==="assistant"&&ep.test(s)||n==="user"&&np.test(s)||n==="assistant"&&tp.test(s)):!1}function El(e){return e.filter(t=>!ip(t))}function Cl(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 b=String(p.type??"").toLowerCase();return b==="toolresult"||b==="tool_result"}),a=typeof t.toolName=="string"||typeof t.tool_name=="string";(i||r||a)&&(n="toolResult");let u=[];typeof t.content=="string"?u=[{type:"text",text:t.content}]:Array.isArray(t.content)?u=t.content.map(p=>({type:p.type||"text",text:p.text,name:p.name,args:p.args||p.arguments})):typeof t.text=="string"&&(u=[{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:u,timestamp:c,id:l}}function Tl(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 _l(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function Ir(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 sp(){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 co(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),Ir(t)}return Ir(sp())}const Le=50;async function Pe(e,t){if(!e.client||!e.connected)return;e.chatLoading=!0,e.lastError=null;const n=(t==null?void 0:t.limit)??Le;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=El(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 op(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:Le,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=El(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 rp(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function Ml(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(b=>!b.fileName),a=(n??[]).filter(b=>b.fileName),u=[],c=a.map(b=>b.fileName).filter(Boolean);if(c.length>0){const b=i?`${c.join(", ")}
|
|
9
9
|
|
|
10
|
-
${i}`:c.join(", ");u.push({type:"text",text:b})}else i&&u.push({type:"text",text:i});for(const b of r)u.push({type:"image",source:{type:"base64",media_type:b.mimeType,data:b.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:u,timestamp:o}],e.chatSending=!0,e.lastError=null;const l=
|
|
10
|
+
${i}`:c.join(", ");u.push({type:"text",text:b})}else i&&u.push({type:"text",text:i});for(const b of r)u.push({type:"image",source:{type:"base64",media_type:b.mimeType,data:b.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:u,timestamp:o}],e.chatSending=!0,e.lastError=null;const l=co();e.chatRunId=l,e.chatStream="",e.chatStreamStartedAt=o;const p=[...r,...a],f=p.length>0?p.map(b=>{if(b.textContent)return{type:"document",mimeType:b.mimeType||"text/plain",fileName:b.fileName,content:btoa(unescape(encodeURIComponent(b.textContent)))};const h=rp(b.dataUrl);return h?{type:b.fileName?"document":"image",mimeType:h.mimeType,fileName:b.fileName,content:h.content}:null}).filter(b=>b!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:i,deliver:!1,idempotencyKey:l,attachments:f}),!0}catch(b){const h=String(b);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=h,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+h}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function Pl(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 Ll(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=fn(t.message))==null?void 0:n.trim():void 0)||((i=e.chatStream)==null?void 0:i.trim());return o&&(e.chatInterimText=e.chatInterimText?`${e.chatInterimText}
|
|
11
11
|
|
|
12
|
-
${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=
|
|
13
|
-
`)}function
|
|
12
|
+
${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=fn(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=fn(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 ui=Object.freeze(Object.defineProperty({__proto__:null,CHAT_PAGE_SIZE:Le,abortChatRun:Pl,handleChatEvent:Ll,loadChatHistory:Pe,loadOlderChatHistory:op,sendChatMessage:Ml},Symbol.toStringTag,{value:"Module"}));async function uo(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=ci(e.sessionsFilterActive??"",0),i=ci(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 Un(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 uo(e)}catch(s){e.sessionsError=String(s)}}const Rr=50,ap=80,lp=12e4;function cp(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 Dr(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=cp(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}const i=xl(n,lp);return i.truncated?`${i.text}
|
|
14
14
|
|
|
15
|
-
… truncated (${i.total} chars, showing first ${i.text.length}).`:i.text}function
|
|
15
|
+
… truncated (${i.total} chars, showing first ${i.text.length}).`:i.text}function up(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 dp(e){if(e.toolStreamOrder.length<=Rr)return;const t=e.toolStreamOrder.length-Rr,n=e.toolStreamOrder.splice(0,t);for(const i of n)e.toolStreamById.delete(i)}function pp(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function Rs(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),pp(e)}function hp(e,t=!1){if(t){Rs(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>Rs(e),ap))}function po(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],Rs(e)}const fp=5e3;function gp(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},fp))}function mp(e,t){if(!t)return;if(t.stream==="compaction"){gp(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,u=r==="update"?Dr(i.partialResult):r==="result"?Dr(i.result):void 0,c=Date.now();let l=e.toolStreamById.get(s);l?(l.name=o,a!==void 0&&(l.args=a),u!==void 0&&(l.output=u),l.updatedAt=c):(l={toolCallId:s,runId:t.runId,sessionKey:n,name:o,args:a,output:u,startedAt:typeof t.ts=="number"?t.ts:c,updatedAt:c,message:{}},e.toolStreamById.set(s,l),e.toolStreamOrder.push(s)),l.message=up(l),dp(e),hp(e,r==="result")}let Wn=0;function Wt(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=++Wn,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===Wn&&(e.chatScrollFrame=requestAnimationFrame(()=>{if(e.chatScrollFrame=null,n!==Wn)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!==Wn)return;const u=i();if(!u)return;const c=u.scrollHeight-u.scrollTop-u.clientHeight;(t||e.chatUserNearBottom||c<200)&&(u.scrollTop=u.scrollHeight,e.chatUserNearBottom=!0)},a)}))})}function Il(e,t=!1){e.logsScrollFrame&&cancelAnimationFrame(e.logsScrollFrame),e.updateComplete.then(()=>{e.logsScrollFrame=requestAnimationFrame(()=>{e.logsScrollFrame=null;const n=e.querySelector(".log-stream");!n||!(t||n.scrollTop<80)||(n.scrollTop=0)})})}function yp(e,t){const n=t.currentTarget;if(!n)return;const i=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=i<200,n.scrollTop<100&&e.onLoadOlder&&e.onLoadOlder()}function vp(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 bp(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function wp(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function kp(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function Sp(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
|
|
16
16
|
`)}
|
|
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
|
|
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 $p(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
|
|
18
18
|
`)}
|
|
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
|
|
20
|
-
`}function Il(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 u=i;u[r]==null&&(u[r]=typeof a=="number"?[]:{}),i=u[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 Le(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});$p(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function Rl(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});Sp(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function Sp(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function $p(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?ht(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=ht(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=et(t.config??{}),e.configFormOriginal=et(t.config??{}),e.configRawOriginal=n)}async function xp(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?ht(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 Le(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function Sn(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("cron.status",{});e.cronStatus=t}catch(t){e.cronError=String(t)}}async function Ti(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 Ap(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 Ep(e){if(e.payloadKind==="systemEvent"){const s=e.payloadText.trim();if(!s)throw new Error("System event text required.");return{kind:"systemEvent",text:s}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel),e.to.trim()&&(n.to=e.to.trim());const i=ai(e.timeoutSeconds,0);return i>0&&(n.timeoutSeconds=i),n}async function Cp(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=Ap(e.cronForm),i=Ep(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 Ti(e),await Sn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Tp(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 Ti(e),await Sn(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function _p(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await Rs(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Mp(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 Ti(e),await Sn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Rs(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 G(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 po(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 Dl(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 Nl(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 Bl(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=et(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 u=a.accounts;if(u[i]){e.whatsappAccountError=`Account "${i}" already exists.`;return}u[i]={name:n,provider:"baileys"};const c=s.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const l=ht(o);await e.client.request("config.set",{raw:l,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await G(e,!0),await po(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function Ol(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=et(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 u=n.hash;if(!u){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=ht(i);await e.client.request("config.set",{raw:c,baseHash:u}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await G(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const Pp=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:Bl,loadChannels:G,logoutWhatsApp:Nl,removeWhatsAppAccount:Ol,startWhatsAppLogin:po,waitWhatsAppLogin:Dl},Symbol.toStringTag,{value:"Module"}));async function ho(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 Lp=2e3,Ip=new Set(["trace","debug","info","warn","error","fatal"]);function Rp(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 Dp(e){if(typeof e!="string")return null;const t=e.toLowerCase();return Ip.has(t)?t:null}function Fl(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=Dp((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=Rp(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 u=null;return typeof t[1]=="string"?u=t[1]:!r&&typeof t[0]=="string"?u=t[0]:typeof t.message=="string"&&(u=t.message),{raw:e,time:i,level:s,subsystem:a,message:u??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function It(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(Fl),r=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=r?o:[...e.logsEntries,...o].slice(-Lp),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 Np=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:It,parseLogLine:Fl},Symbol.toStringTag,{value:"Module"}));const Ul={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:re,n:Jn,Gx:Rr,Gy:Dr,a:ss,d:os,h:Bp}=Ul,ft=32,fo=64,Op=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},te=(e="")=>{const t=new Error(e);throw Op(t,te),t},Fp=e=>typeof e=="bigint",Up=e=>typeof e=="string",Wp=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",tt=(e,t,n="")=>{const i=Wp(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}`:"",u=i?`length=${s}`:`type=${typeof e}`;te(r+"expected Uint8Array"+a+", got "+u)}return e},_i=e=>new Uint8Array(e),Wl=e=>Uint8Array.from(e),Kl=(e,t)=>e.toString(16).padStart(t,"0"),zl=e=>Array.from(tt(e)).map(t=>Kl(t,2)).join(""),Be={_0:48,_9:57,A:65,F:70,a:97,f:102},Nr=e=>{if(e>=Be._0&&e<=Be._9)return e-Be._0;if(e>=Be.A&&e<=Be.F)return e-(Be.A-10);if(e>=Be.a&&e<=Be.f)return e-(Be.a-10)},Hl=e=>{const t="hex invalid";if(!Up(e))return te(t);const n=e.length,i=n/2;if(n%2)return te(t);const s=_i(i);for(let o=0,r=0;o<i;o++,r+=2){const a=Nr(e.charCodeAt(r)),u=Nr(e.charCodeAt(r+1));if(a===void 0||u===void 0)return te(t);s[o]=a*16+u}return s},jl=()=>globalThis==null?void 0:globalThis.crypto,Kp=()=>{var e;return((e=jl())==null?void 0:e.subtle)??te("crypto.subtle must be defined, consider polyfill")},wn=(...e)=>{const t=_i(e.reduce((i,s)=>i+tt(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},zp=(e=ft)=>jl().getRandomValues(_i(e)),ci=BigInt,lt=(e,t,n,i="bad number: out of range")=>Fp(e)&&t<=e&&e<n?e:te(i),P=(e,t=re)=>{const n=e%t;return n>=0n?n:t+n},ql=e=>P(e,Jn),Hp=(e,t)=>{(e===0n||t<=0n)&&te("no inverse n="+e+" mod="+t);let n=P(e,t),i=t,s=0n,o=1n;for(;n!==0n;){const r=i/n,a=i%n,u=s-o*r;i=n,n=a,s=o,o=u}return i===1n?P(s,t):te("no inverse")},jp=e=>{const t=Yl[e];return typeof t!="function"&&te("hashes."+e+" not set"),t},rs=e=>e instanceof gt?e:te("Point expected"),Ds=2n**256n,_e=class _e{constructor(t,n,i,s){U(this,"X");U(this,"Y");U(this,"Z");U(this,"T");const o=Ds;this.X=lt(t,0n,o),this.Y=lt(n,0n,o),this.Z=lt(i,1n,o),this.T=lt(s,0n,o),Object.freeze(this)}static CURVE(){return Ul}static fromAffine(t){return new _e(t.x,t.y,1n,P(t.x*t.y))}static fromBytes(t,n=!1){const i=os,s=Wl(tt(t,ft)),o=t[31];s[31]=o&-129;const r=Gl(s);lt(r,0n,n?Ds:re);const u=P(r*r),c=P(u-1n),l=P(i*u+1n);let{isValid:p,value:f}=Vp(c,l);p||te("bad point: y not sqrt");const b=(f&1n)===1n,h=(o&128)!==0;return!n&&f===0n&&h&&te("bad point: x==0, isLastByteOdd"),h!==b&&(f=P(-f)),new _e(f,r,1n,P(f*r))}static fromHex(t,n){return _e.fromBytes(Hl(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=ss,n=os,i=this;if(i.is0())return te("bad point: ZERO");const{X:s,Y:o,Z:r,T:a}=i,u=P(s*s),c=P(o*o),l=P(r*r),p=P(l*l),f=P(u*t),b=P(l*P(f+c)),h=P(p+P(n*P(u*c)));if(b!==h)return te("bad point: equation left != right (1)");const v=P(s*o),k=P(r*a);return v!==k?te("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:r,Z:a}=rs(t),u=P(n*a),c=P(o*s),l=P(i*a),p=P(r*s);return u===c&&l===p}is0(){return this.equals(Pt)}negate(){return new _e(P(-this.X),this.Y,this.Z,P(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=ss,o=P(t*t),r=P(n*n),a=P(2n*P(i*i)),u=P(s*o),c=t+n,l=P(P(c*c)-o-r),p=u+r,f=p-a,b=u-r,h=P(l*f),v=P(p*b),k=P(l*b),$=P(f*p);return new _e(h,v,$,k)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:r,Y:a,Z:u,T:c}=rs(t),l=ss,p=os,f=P(n*r),b=P(i*a),h=P(o*p*c),v=P(s*u),k=P((n+i)*(r+a)-f-b),$=P(v-h),A=P(v+h),C=P(b-l*f),T=P(k*$),_=P(A*C),R=P(k*C),O=P($*A);return new _e(T,_,O,R)}subtract(t){return this.add(rs(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return Pt;if(lt(t,1n,Jn),t===1n)return this;if(this.equals(mt))return sh(t).p;let i=Pt,s=mt;for(let o=this;t>0n;o=o.double(),t>>=1n)t&1n?i=i.add(o):n&&(s=s.add(o));return i}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:i}=this;if(this.equals(Pt))return{x:0n,y:1n};const s=Hp(i,re);P(i*s)!==1n&&te("invalid inverse");const o=P(t*s),r=P(n*s);return{x:o,y:r}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=Vl(n);return i[31]|=t&1n?128:0,i}toHex(){return zl(this.toBytes())}clearCofactor(){return this.multiply(ci(Bp),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Jn/2n,!1).double();return Jn%2n&&(t=t.add(this)),t.is0()}};U(_e,"BASE"),U(_e,"ZERO");let gt=_e;const mt=new gt(Rr,Dr,1n,P(Rr*Dr)),Pt=new gt(0n,1n,1n,0n);gt.BASE=mt;gt.ZERO=Pt;const Vl=e=>Hl(Kl(lt(e,0n,Ds),fo)).reverse(),Gl=e=>ci("0x"+zl(Wl(tt(e)).reverse())),Ae=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=re;return n},qp=e=>{const n=e*e%re*e%re,i=Ae(n,2n)*n%re,s=Ae(i,1n)*e%re,o=Ae(s,5n)*s%re,r=Ae(o,10n)*o%re,a=Ae(r,20n)*r%re,u=Ae(a,40n)*a%re,c=Ae(u,80n)*u%re,l=Ae(c,80n)*u%re,p=Ae(l,10n)*o%re;return{pow_p_5_8:Ae(p,2n)*e%re,b2:n}},Br=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Vp=(e,t)=>{const n=P(t*t*t),i=P(n*n*t),s=qp(e*i).pow_p_5_8;let o=P(e*n*s);const r=P(t*o*o),a=o,u=P(o*Br),c=r===e,l=r===P(-e),p=r===P(-e*Br);return c&&(o=a),(l||p)&&(o=u),(P(o)&1n)===1n&&(o=P(-o)),{isValid:c||l,value:o}},Ns=e=>ql(Gl(e)),go=(...e)=>Yl.sha512Async(wn(...e)),Gp=(...e)=>jp("sha512")(wn(...e)),Ql=e=>{const t=e.slice(0,ft);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(ft,fo),i=Ns(t),s=mt.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},mo=e=>go(tt(e,ft)).then(Ql),Qp=e=>Ql(Gp(tt(e,ft))),Yp=e=>mo(e).then(t=>t.pointBytes),Xp=e=>go(e.hashable).then(e.finish),Zp=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=Ns(t),r=mt.multiply(o).toBytes();return{hashable:wn(r,i,n),finish:c=>{const l=ql(o+Ns(c)*s);return tt(wn(r,Vl(l)),fo)}}},Jp=async(e,t)=>{const n=tt(e),i=await mo(t),s=await go(i.prefix,n);return Xp(Zp(i,s,n))},Yl={sha512Async:async e=>{const t=Kp(),n=wn(e);return _i(await t.digest("SHA-512",n.buffer))},sha512:void 0},eh=(e=zp(ft))=>e,th={getExtendedPublicKeyAsync:mo,getExtendedPublicKey:Qp,randomSecretKey:eh},ui=8,nh=256,Xl=Math.ceil(nh/ui)+1,Bs=2**(ui-1),ih=()=>{const e=[];let t=mt,n=t;for(let i=0;i<Xl;i++){n=t,e.push(n);for(let s=1;s<Bs;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Or;const Fr=(e,t)=>{const n=t.negate();return e?n:t},sh=e=>{const t=Or||(Or=ih());let n=Pt,i=mt;const s=2**ui,o=s,r=ci(s-1),a=ci(ui);for(let u=0;u<Xl;u++){let c=Number(e&r);e>>=a,c>Bs&&(c-=o,e+=1n);const l=u*Bs,p=l,f=l+Math.abs(c)-1,b=u%2!==0,h=c<0;c===0?i=i.add(Fr(b,t[p])):n=n.add(Fr(h,t[f]))}return e!==0n&&te("invalid wnaf"),{p:n,f:i}},as="taskmaster-device-identity-v1";function Os(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Zl(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 oh(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Jl(e){const t=await crypto.subtle.digest("SHA-256",e);return oh(new Uint8Array(t))}async function rh(){const e=th.randomSecretKey(),t=await Yp(e);return{deviceId:await Jl(t),publicKey:Os(t),privateKey:Os(e)}}async function ah(){try{const n=localStorage.getItem(as);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 Jl(Zl(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(as,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 rh(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(as,JSON.stringify(t)),e}async function lh(e,t){const n=Zl(e),i=new TextEncoder().encode(t),s=await Jp(i,n);return Os(s)}const ec="taskmaster.device.auth.v1";function yo(e){return e.trim()}function ch(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 vo(){try{const e=window.localStorage.getItem(ec);if(!e)return null;const t=JSON.parse(e);return!t||t.version!==1||!t.deviceId||typeof t.deviceId!="string"||!t.tokens||typeof t.tokens!="object"?null:t}catch{return null}}function tc(e){try{window.localStorage.setItem(ec,JSON.stringify(e))}catch{}}function uh(e){const t=vo();if(!t||t.deviceId!==e.deviceId)return null;const n=yo(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function dh(e){const t=yo(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=vo();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:ch(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,tc(n),s}function ph(e){const t=vo();if(!t||t.deviceId!==e.deviceId)return;const n=yo(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],tc(i)}async function bo(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 wo(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 hh(e){return{method:"exec.approvals.get",params:{}}}async function fh(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=hh(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);gh(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function gh(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=et(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 Nt(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function He(e){return e instanceof Error?e.message:String(e)}function Mi(){return{name:"",skillContent:"",references:[]}}async function ze(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=He(n)}finally{e.skillsLoading=!1}}}function ic(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function sc(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 ze(e),Nt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=He(i);e.skillsError=s,Nt(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 ze(e),Nt(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=He(n);e.skillsError=i,Nt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function rc(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 ze(e),Nt(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=He(s);e.skillsError=o,Nt(e,t,{kind:"error",message:o})}finally{e.skillsBusyKey=null}}}async function ac(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=He(n)}}function lc(e){e.skillDetail=null,e.skillDetailTab=""}function cc(e,t){e.skillDetailTab=t}async function uc(e){if(e.skillAddModal=!0,e.skillAddForm=Mi(),e.skillDrafts=[],!(!e.client||!e.connected))try{const t=await e.client.request("skills.drafts",{});t&&(e.skillDrafts=t.drafts)}catch{}}function dc(e){e.skillAddModal=!1,e.skillAddForm=Mi(),e.skillDrafts=[]}function pc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n}))}}async function hc(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(i=>i.name.trim()&&i.content.trim()).map(i=>({name:i.name.trim(),content:i.content}));await e.client.request("skills.create",{name:t.name.trim(),skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=Mi(),e.skillDrafts=[],await ze(e)}catch(n){e.skillsError=He(n)}finally{e.skillsBusyKey=null}}}async function fc(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=He(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.skillAddModal=!0,e.skillDrafts=[]}catch(n){e.skillsError=He(n)}}async function mc(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.delete",{name:t}),await ze(e)}catch(n){e.skillsError=He(n)}finally{e.skillsBusyKey=null}}}const mh=Object.freeze(Object.defineProperty({__proto__:null,closeAddSkillModal:dc,closeSkillDetail:lc,deleteDraft:fc,deleteSkill:mc,editSkill:gc,emptyAddForm:Mi,importDraft:pc,installSkill:rc,loadSkills:ze,openAddSkillModal:uc,saveNewSkill:hc,saveSkillApiKey:oc,setSkillDetailTab:cc,updateSkillEdit:ic,updateSkillEnabled:sc,viewSkillDetail:ac},Symbol.toStringTag,{value:"Module"})),yc={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},vc=new Map(Object.entries(yc).map(([e,t])=>[t,e]));function Pi(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function kn(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 yh(e,t=""){const n=Pi(t),i=yc[e];return n?`${n}${i}`:i}function bc(e,t=""){const n=Pi(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=kn(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":vc.get(s)??null}function vh(e){let t=kn(e);if(t.endsWith("/index.html")&&(t=kn(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let i=0;i<n.length;i++){const s=`/${n.slice(i).join("/")}`.toLowerCase();if(vc.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function bh(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function ko(e){return e==="system"?bh():e}const Un=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,wh=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Wn=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},kh=({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=wh();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=Un(n.pointerClientX/window.innerWidth),p=Un(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=Un((f.left+f.width/2)/window.innerWidth),p=Un((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(()=>Wn(o)):Wn(o)}catch{Wn(o),t()}return}t(),Wn(o)},Sh=2e3;async function hn(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(-Sh),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 wc=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:hn},Symbol.toStringTag,{value:"Module"}));async function kc(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 $h(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function Ie(e){return e instanceof Error?e.message:String(e)}let Kn=null;function Wt(e,t){Kn&&clearTimeout(Kn),e.filesMessage={kind:"success",text:t},Kn=setTimeout(()=>{e.filesMessage=null,Kn=null},3e3)}async function Kt(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=Ie(n)}finally{e.filesLoading=!1}}}}async function xh(e,t,n){e.filesSelectedPaths=new Set([t]),await Sc(e,t,n)}async function Ah(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 Sc(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function Eh(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 $c(e,o,t),i++}catch(r){s=Ie(r)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:Wt(e,`${i} file${i!==1?"s":""} downloaded`)}async function Ch(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await Ph(e,t,o,i)}async function Sc(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=Ie(i)}finally{e.filesPreviewLoading=!1}}}async function $c(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),u=document.createElement("a");u.href=a,u.download=s.name??t.split("/").pop()??"download",document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(a)}catch(i){e.filesMessage={kind:"error",text:Ie(i)}}}async function Th(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(),u=btoa(new Uint8Array(a).reduce((l,p)=>l+String.fromCharCode(p),"")),c={path:t,name:r.name,data:u};i&&(c.agentId=i),await e.client.request("files.upload",c),s++}catch(a){o=Ie(a)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:Wt(e,`${s} file${s!==1?"s":""} uploaded`),await Kt(e,i)}async function _h(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),Wt(e,`Created ${s}`),await Kt(e,i),e.filesExpandedDirs=new Set([...e.filesExpandedDirs,s]),e.filesCurrentDir=s}catch(o){e.filesMessage={kind:"error",text:Ie(o)}}}async function Mh(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),Wt(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await Kt(e,n)}catch(i){e.filesMessage={kind:"error",text:Ie(i)}}}}async function Ph(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),Wt(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await Kt(e,i)}catch(s){e.filesMessage={kind:"error",text:Ie(s)}}}}async function So(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 Lh(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;Wt(e,`Re-indexed: ${s} files, ${o} chunks`),await So(e,t)}catch(n){e.filesMessage={kind:"error",text:Ie(n)}}finally{e.filesReindexBusy=!1}}}function Ih(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 Rh(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:Ie(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function Dh(e){e.filesSearchQuery="",e.filesSearchResults=null}function Nh(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{wo(e,{quiet:!0})},5e3))}function Bh(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function $o(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&It(e,{quiet:!0})},2e3))}function xo(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function Ao(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||hn(e,{quiet:!0})},2e3))}function Eo(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function Co(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&ho(e)},3e3))}function To(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Oh(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{kc(e)},3e4))}function Fh(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function Uh(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{if(e.tab!=="files")return;const t=e;So(t,t.filesResolvedAgentId)},3e3))}function Wh(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function Ze(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,Fd(n),t.theme!==e.theme&&(e.theme=t.theme,Li(e,ko(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function xc(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&Ze(e,{...e.settings,lastActiveSessionKey:n})}function Kh(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 u=n.trim();u&&u!==e.settings.token&&Ze(e,{...e.settings,token:u}),t.delete("token"),r=!0}if(i!=null){const u=i.trim();u&&(e.password=u),t.delete("password"),r=!0}if(s!=null){const u=s.trim();u&&(e.sessionKey=u,Ze(e,{...e.settings,sessionKey:u,lastActiveSessionKey:u}))}if(o!=null){const u=o.trim();u&&u!==e.settings.gatewayUrl&&Ze(e,{...e.settings,gatewayUrl:u}),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 zh(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?Ao(e):$o(e):(xo(e),Eo(e)),t==="debug"?Co(e):To(e),di(e),Ec(e,t,!1)}function Hh(e,t,n){kh({nextTheme:t,applyTheme:()=>{e.theme=t,Ze(e,{...e.settings,theme:t}),Li(e,ko(t))},context:n,currentTheme:e.theme})}async function di(e){if(e.tab==="overview"&&await Cc(e),e.tab==="channels"&&await Xh(e),e.tab==="instances"&&await nc(e),e.tab==="cron"&&await _o(e),e.tab==="skills"&&await ze(e),e.tab==="nodes"&&(await wo(e),await bo(e),await Le(e),await fh(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await nf(e),Ut(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await Rl(e),await Le(e)),e.tab==="debug"&&(await ho(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await ie(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>wc);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await It(e,{reset:!0});Ll(e,!0)}}function jh(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?Pi(e):vh(window.location.pathname)}function qh(e){e.theme=e.settings.theme??"system",Li(e,ko(e.theme))}function Li(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function Vh(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"&&Li(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Gh(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 Qh(e,t){if(typeof window>"u")return;const n=bc(window.location.pathname,e.basePath)??"chat";Ac(e,n),Ec(e,n,t)}function Yh(e){var s;if(typeof window>"u")return;const t=bc(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,Ze(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),Ac(e,t)}function Ac(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?Ao(e):$o(e):(xo(e),Eo(e)),t==="debug"?Co(e):To(e),e.connected&&di(e)}function Ec(e,t,n){if(typeof window>"u")return;const i=kn(yh(t,e.basePath)),s=kn(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 Cc(e){await Promise.all([G(e,!1),nc(e),co(e),Sn(e),ho(e)])}async function Xh(e){await Promise.all([G(e,!0),Rl(e),Le(e)])}async function _o(e){await Promise.all([G(e,!1),Sn(e),Ti(e)])}function Tc(e){return e.chatSending||!!e.chatRunId}function Zh(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 _c(e){e.connected&&(e.chatMessage="",await Ml(e))}function Jh(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:lo(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],Ut(e))}async function Mc(e,t,n){var s,o;uo(e);const i=await _l(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&&xc(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),Ut(e),i&&!e.chatRunId&&Pc(e),i}async function Pc(e){if(!e.connected||Tc(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await Mc(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function ef(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function tf(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(Zh(s)){await _c(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),Tc(e)){Jh(e,s,r);return}await Mc(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 nf(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,Pe);await Promise.all([Me(t,{limit:n}),co(t),Fs(e)]),Ut(e,!0)}const sf=Pc;function of(e){var s,o,r;const t=wl(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 rf(e,t){const n=Pi(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Fs(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=of(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=rf(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 D={messageSquare:d`<svg viewBox="0 0 24 24"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,barChart:d`<svg viewBox="0 0 24 24"><line x1="12" x2="12" y1="20" y2="10"/><line x1="18" x2="18" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="16"/></svg>`,link:d`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,unlink:d`<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:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="2"/><path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"/></svg>`,fileText:d`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><line x1="16" x2="8" y1="13" y2="13"/><line x1="16" x2="8" y1="17" y2="17"/><line x1="10" x2="8" y1="9" y2="9"/></svg>`,zap:d`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:d`<svg viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>`,settings:d`<svg viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>`,bug:d`<svg viewBox="0 0 24 24"><path d="m8 2 1.88 1.88"/><path d="M14.12 3.88 16 2"/><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9"/><path d="M6.53 9C4.6 8.8 3 7.1 3 5"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="M22 13h-4"/><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"/></svg>`,scrollText:d`<svg viewBox="0 0 24 24"><path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M15 8h-5"/><path d="M15 12h-5"/></svg>`,folder:d`<svg viewBox="0 0 24 24"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>`,users:d`<svg viewBox="0 0 24 24"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>`,menu:d`<svg viewBox="0 0 24 24"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>`,x:d`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:d`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:d`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,search:d`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:d`<svg viewBox="0 0 24 24"><path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/><path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/><path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/><path d="M17.599 6.5a3 3 0 0 0 .399-1.375"/><path d="M6.003 5.125A3 3 0 0 0 6.401 6.5"/><path d="M3.477 10.896a4 4 0 0 1 .585-.396"/><path d="M19.938 10.5a4 4 0 0 1 .585.396"/><path d="M6 18a4 4 0 0 1-1.967-.516"/><path d="M19.967 17.484A4 4 0 0 1 18 18"/></svg>`,book:d`<svg viewBox="0 0 24 24"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/></svg>`,loader:d`<svg viewBox="0 0 24 24"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>`,rotateCw:d`<svg viewBox="0 0 24 24"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>`,download:d`<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,wrench:d`<svg viewBox="0 0 24 24"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>`,fileCode:d`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><path d="m10 13-2 2 2 2"/><path d="m14 17 2-2-2-2"/></svg>`,edit:d`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,penLine:d`<svg viewBox="0 0 24 24"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>`,paperclip:d`<svg viewBox="0 0 24 24"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`,globe:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>`,image:d`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>`,smartphone:d`<svg viewBox="0 0 24 24"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>`,plug:d`<svg viewBox="0 0 24 24"><path d="M12 22v-5"/><path d="M9 8V2"/><path d="M15 8V2"/><path d="M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z"/></svg>`,circle:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:d`<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:d`<svg viewBox="0 0 24 24"><path d="M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.076.874.54 1.02 1.02a2.5 2.5 0 1 0 3.237-3.237c-.48-.146-.944-.505-1.02-1.02a.98.98 0 0 1 .303-.917l1.526-1.526A2.402 2.402 0 0 1 11.998 2c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.236 3.236c-.464.18-.894.527-.967 1.02Z"/></svg>`,info:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>`,send:d`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`,slidersHorizontal:d`<svg viewBox="0 0 24 24"><line x1="21" x2="14" y1="4" y2="4"/><line x1="10" x2="3" y1="4" y2="4"/><line x1="21" x2="12" y1="12" y2="12"/><line x1="8" x2="3" y1="12" y2="12"/><line x1="21" x2="16" y1="20" y2="20"/><line x1="12" x2="3" y1="20" y2="20"/><line x1="14" x2="14" y1="2" y2="6"/><line x1="8" x2="8" y1="10" y2="14"/><line x1="16" x2="16" y1="18" y2="22"/></svg>`,square:d`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:d`<svg viewBox="0 0 24 24"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`,eyeOff:d`<svg viewBox="0 0 24 24"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,trash:d`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,chevronDown:d`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:d`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/></svg>`,wifi:d`<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:d`<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>`},af=d`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`,lf=d`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><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 Ur=!1;function cf(){Ur||(Ur=!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 wt(e,t){const n=(l,p)=>l===e?d`<span class="sp-page-nav-current">${l}</span>`:d`<a href=${p}>${l}</a>`,i=d`
|
|
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 xp(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 tt(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function ft(e){return`${JSON.stringify(e,null,2).trimEnd()}
|
|
20
|
+
`}function Rl(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 u=i;u[r]==null&&(u[r]=typeof a=="number"?[]:{}),i=u[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 Ie(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});Ep(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function Dl(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});Ap(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function Ap(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function Ep(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?ft(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=ft(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=tt(t.config??{}),e.configFormOriginal=tt(t.config??{}),e.configRawOriginal=n)}async function Cp(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?ft(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 Ie(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function Kt(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 xn(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 Bl(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=ci(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 Nl(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=ci(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function Tp(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=Bl(e.cronForm),i=Nl(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 xn(e),await Kt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function _p(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 xn(e),await Kt(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function Mp(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await Ds(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Pp(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 xn(e),await Kt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}function Lp(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 Ip(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=Bl(e.cronForm),i=Nl(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 xn(e),await Kt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Ds(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 G(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 ho(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 Ol(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 Fl(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 Ul(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=tt(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 u=a.accounts;if(u[i]){e.whatsappAccountError=`Account "${i}" already exists.`;return}u[i]={name:n,provider:"baileys"};const c=s.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const l=ft(o);await e.client.request("config.set",{raw:l,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await G(e,!0),await ho(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function Wl(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=tt(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 u=n.hash;if(!u){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=ft(i);await e.client.request("config.set",{raw:c,baseHash:u}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await G(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const Rp=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:Ul,loadChannels:G,logoutWhatsApp:Fl,removeWhatsAppAccount:Wl,startWhatsAppLogin:ho,waitWhatsAppLogin:Ol},Symbol.toStringTag,{value:"Module"}));async function fo(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 Dp=2e3,Bp=new Set(["trace","debug","info","warn","error","fatal"]);function Np(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 Op(e){if(typeof e!="string")return null;const t=e.toLowerCase();return Bp.has(t)?t:null}function Kl(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=Op((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=Np(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 u=null;return typeof t[1]=="string"?u=t[1]:!r&&typeof t[0]=="string"?u=t[0]:typeof t.message=="string"&&(u=t.message),{raw:e,time:i,level:s,subsystem:a,message:u??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Rt(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(Kl),r=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=r?o:[...e.logsEntries,...o].slice(-Dp),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 Fp=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:Rt,parseLogLine:Kl},Symbol.toStringTag,{value:"Module"}));const zl={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:re,n:ti,Gx:Br,Gy:Nr,a:os,d:rs,h:Up}=zl,gt=32,go=64,Wp=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},te=(e="")=>{const t=new Error(e);throw Wp(t,te),t},Kp=e=>typeof e=="bigint",zp=e=>typeof e=="string",Hp=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",nt=(e,t,n="")=>{const i=Hp(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}`:"",u=i?`length=${s}`:`type=${typeof e}`;te(r+"expected Uint8Array"+a+", got "+u)}return e},Mi=e=>new Uint8Array(e),Hl=e=>Uint8Array.from(e),ql=(e,t)=>e.toString(16).padStart(t,"0"),jl=e=>Array.from(nt(e)).map(t=>ql(t,2)).join(""),Oe={_0:48,_9:57,A:65,F:70,a:97,f:102},Or=e=>{if(e>=Oe._0&&e<=Oe._9)return e-Oe._0;if(e>=Oe.A&&e<=Oe.F)return e-(Oe.A-10);if(e>=Oe.a&&e<=Oe.f)return e-(Oe.a-10)},Vl=e=>{const t="hex invalid";if(!zp(e))return te(t);const n=e.length,i=n/2;if(n%2)return te(t);const s=Mi(i);for(let o=0,r=0;o<i;o++,r+=2){const a=Or(e.charCodeAt(r)),u=Or(e.charCodeAt(r+1));if(a===void 0||u===void 0)return te(t);s[o]=a*16+u}return s},Gl=()=>globalThis==null?void 0:globalThis.crypto,qp=()=>{var e;return((e=Gl())==null?void 0:e.subtle)??te("crypto.subtle must be defined, consider polyfill")},Sn=(...e)=>{const t=Mi(e.reduce((i,s)=>i+nt(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},jp=(e=gt)=>Gl().getRandomValues(Mi(e)),di=BigInt,ct=(e,t,n,i="bad number: out of range")=>Kp(e)&&t<=e&&e<n?e:te(i),P=(e,t=re)=>{const n=e%t;return n>=0n?n:t+n},Ql=e=>P(e,ti),Vp=(e,t)=>{(e===0n||t<=0n)&&te("no inverse n="+e+" mod="+t);let n=P(e,t),i=t,s=0n,o=1n;for(;n!==0n;){const r=i/n,a=i%n,u=s-o*r;i=n,n=a,s=o,o=u}return i===1n?P(s,t):te("no inverse")},Gp=e=>{const t=Zl[e];return typeof t!="function"&&te("hashes."+e+" not set"),t},as=e=>e instanceof mt?e:te("Point expected"),Bs=2n**256n,Me=class Me{constructor(t,n,i,s){U(this,"X");U(this,"Y");U(this,"Z");U(this,"T");const o=Bs;this.X=ct(t,0n,o),this.Y=ct(n,0n,o),this.Z=ct(i,1n,o),this.T=ct(s,0n,o),Object.freeze(this)}static CURVE(){return zl}static fromAffine(t){return new Me(t.x,t.y,1n,P(t.x*t.y))}static fromBytes(t,n=!1){const i=rs,s=Hl(nt(t,gt)),o=t[31];s[31]=o&-129;const r=Jl(s);ct(r,0n,n?Bs:re);const u=P(r*r),c=P(u-1n),l=P(i*u+1n);let{isValid:p,value:f}=Yp(c,l);p||te("bad point: y not sqrt");const b=(f&1n)===1n,h=(o&128)!==0;return!n&&f===0n&&h&&te("bad point: x==0, isLastByteOdd"),h!==b&&(f=P(-f)),new Me(f,r,1n,P(f*r))}static fromHex(t,n){return Me.fromBytes(Vl(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=os,n=rs,i=this;if(i.is0())return te("bad point: ZERO");const{X:s,Y:o,Z:r,T:a}=i,u=P(s*s),c=P(o*o),l=P(r*r),p=P(l*l),f=P(u*t),b=P(l*P(f+c)),h=P(p+P(n*P(u*c)));if(b!==h)return te("bad point: equation left != right (1)");const v=P(s*o),k=P(r*a);return v!==k?te("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:r,Z:a}=as(t),u=P(n*a),c=P(o*s),l=P(i*a),p=P(r*s);return u===c&&l===p}is0(){return this.equals(Lt)}negate(){return new Me(P(-this.X),this.Y,this.Z,P(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=os,o=P(t*t),r=P(n*n),a=P(2n*P(i*i)),u=P(s*o),c=t+n,l=P(P(c*c)-o-r),p=u+r,f=p-a,b=u-r,h=P(l*f),v=P(p*b),k=P(l*b),$=P(f*p);return new Me(h,v,$,k)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:r,Y:a,Z:u,T:c}=as(t),l=os,p=rs,f=P(n*r),b=P(i*a),h=P(o*p*c),v=P(s*u),k=P((n+i)*(r+a)-f-b),$=P(v-h),A=P(v+h),C=P(b-l*f),T=P(k*$),_=P(A*C),R=P(k*C),O=P($*A);return new Me(T,_,O,R)}subtract(t){return this.add(as(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return Lt;if(ct(t,1n,ti),t===1n)return this;if(this.equals(yt))return ah(t).p;let i=Lt,s=yt;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(Lt))return{x:0n,y:1n};const s=Vp(i,re);P(i*s)!==1n&&te("invalid inverse");const o=P(t*s),r=P(n*s);return{x:o,y:r}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=Yl(n);return i[31]|=t&1n?128:0,i}toHex(){return jl(this.toBytes())}clearCofactor(){return this.multiply(di(Up),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(ti/2n,!1).double();return ti%2n&&(t=t.add(this)),t.is0()}};U(Me,"BASE"),U(Me,"ZERO");let mt=Me;const yt=new mt(Br,Nr,1n,P(Br*Nr)),Lt=new mt(0n,1n,1n,0n);mt.BASE=yt;mt.ZERO=Lt;const Yl=e=>Vl(ql(ct(e,0n,Bs),go)).reverse(),Jl=e=>di("0x"+jl(Hl(nt(e)).reverse())),Ee=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=re;return n},Qp=e=>{const n=e*e%re*e%re,i=Ee(n,2n)*n%re,s=Ee(i,1n)*e%re,o=Ee(s,5n)*s%re,r=Ee(o,10n)*o%re,a=Ee(r,20n)*r%re,u=Ee(a,40n)*a%re,c=Ee(u,80n)*u%re,l=Ee(c,80n)*u%re,p=Ee(l,10n)*o%re;return{pow_p_5_8:Ee(p,2n)*e%re,b2:n}},Fr=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Yp=(e,t)=>{const n=P(t*t*t),i=P(n*n*t),s=Qp(e*i).pow_p_5_8;let o=P(e*n*s);const r=P(t*o*o),a=o,u=P(o*Fr),c=r===e,l=r===P(-e),p=r===P(-e*Fr);return c&&(o=a),(l||p)&&(o=u),(P(o)&1n)===1n&&(o=P(-o)),{isValid:c||l,value:o}},Ns=e=>Ql(Jl(e)),mo=(...e)=>Zl.sha512Async(Sn(...e)),Jp=(...e)=>Gp("sha512")(Sn(...e)),Xl=e=>{const t=e.slice(0,gt);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(gt,go),i=Ns(t),s=yt.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},yo=e=>mo(nt(e,gt)).then(Xl),Xp=e=>Xl(Jp(nt(e,gt))),Zp=e=>yo(e).then(t=>t.pointBytes),eh=e=>mo(e.hashable).then(e.finish),th=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=Ns(t),r=yt.multiply(o).toBytes();return{hashable:Sn(r,i,n),finish:c=>{const l=Ql(o+Ns(c)*s);return nt(Sn(r,Yl(l)),go)}}},nh=async(e,t)=>{const n=nt(e),i=await yo(t),s=await mo(i.prefix,n);return eh(th(i,s,n))},Zl={sha512Async:async e=>{const t=qp(),n=Sn(e);return Mi(await t.digest("SHA-512",n.buffer))},sha512:void 0},ih=(e=jp(gt))=>e,sh={getExtendedPublicKeyAsync:yo,getExtendedPublicKey:Xp,randomSecretKey:ih},pi=8,oh=256,ec=Math.ceil(oh/pi)+1,Os=2**(pi-1),rh=()=>{const e=[];let t=yt,n=t;for(let i=0;i<ec;i++){n=t,e.push(n);for(let s=1;s<Os;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Ur;const Wr=(e,t)=>{const n=t.negate();return e?n:t},ah=e=>{const t=Ur||(Ur=rh());let n=Lt,i=yt;const s=2**pi,o=s,r=di(s-1),a=di(pi);for(let u=0;u<ec;u++){let c=Number(e&r);e>>=a,c>Os&&(c-=o,e+=1n);const l=u*Os,p=l,f=l+Math.abs(c)-1,b=u%2!==0,h=c<0;c===0?i=i.add(Wr(b,t[p])):n=n.add(Wr(h,t[f]))}return e!==0n&&te("invalid wnaf"),{p:n,f:i}},ls="taskmaster-device-identity-v1";function Fs(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function tc(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 lh(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function nc(e){const t=await crypto.subtle.digest("SHA-256",e);return lh(new Uint8Array(t))}async function ch(){const e=sh.randomSecretKey(),t=await Zp(e);return{deviceId:await nc(t),publicKey:Fs(t),privateKey:Fs(e)}}async function uh(){try{const n=localStorage.getItem(ls);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 nc(tc(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(ls,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 ch(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(ls,JSON.stringify(t)),e}async function dh(e,t){const n=tc(e),i=new TextEncoder().encode(t),s=await nh(i,n);return Fs(s)}const ic="taskmaster.device.auth.v1";function vo(e){return e.trim()}function ph(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 bo(){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 sc(e){try{window.localStorage.setItem(ic,JSON.stringify(e))}catch{}}function hh(e){const t=bo();if(!t||t.deviceId!==e.deviceId)return null;const n=vo(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function fh(e){const t=vo(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=bo();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:ph(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,sc(n),s}function gh(e){const t=bo();if(!t||t.deviceId!==e.deviceId)return;const n=vo(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],sc(i)}async function wo(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 ko(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 mh(e){return{method:"exec.approvals.get",params:{}}}async function yh(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=mh(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);vh(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function vh(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=tt(t.file??{}))}async function oc(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 Nt(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 Pi(){return{name:"",skillContent:"",references:[]}}async function He(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 rc(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function ac(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 He(e),Nt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=qe(i);e.skillsError=s,Nt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function lc(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 He(e),Nt(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=qe(n);e.skillsError=i,Nt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function cc(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 He(e),Nt(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=qe(s);e.skillsError=o,Nt(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 dc(e){e.skillDetail=null,e.skillDetailTab=""}function pc(e,t){e.skillDetailTab=t}async function hc(e){if(e.skillAddModal=!0,e.skillAddForm=Pi(),e.skillDrafts=[],!(!e.client||!e.connected))try{const t=await e.client.request("skills.drafts",{});t&&(e.skillDrafts=t.drafts)}catch{}}function fc(e){e.skillAddModal=!1,e.skillAddForm=Pi(),e.skillDrafts=[]}function gc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n}))}}async function mc(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(i=>i.name.trim()&&i.content.trim()).map(i=>({name:i.name.trim(),content:i.content}));await e.client.request("skills.create",{name:t.name.trim(),skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=Pi(),e.skillDrafts=[],await He(e)}catch(n){e.skillsError=qe(n)}finally{e.skillsBusyKey=null}}}async function yc(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 vc(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.skillAddModal=!0,e.skillDrafts=[]}catch(n){e.skillsError=qe(n)}}async function bc(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.delete",{name:t}),await He(e)}catch(n){e.skillsError=qe(n)}finally{e.skillsBusyKey=null}}}const bh=Object.freeze(Object.defineProperty({__proto__:null,closeAddSkillModal:fc,closeSkillDetail:dc,deleteDraft:yc,deleteSkill:bc,editSkill:vc,emptyAddForm:Pi,importDraft:gc,installSkill:cc,loadSkills:He,openAddSkillModal:hc,saveNewSkill:mc,saveSkillApiKey:lc,setSkillDetailTab:pc,updateSkillEdit:rc,updateSkillEnabled:ac,viewSkillDetail:uc},Symbol.toStringTag,{value:"Module"})),wc={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},kc=new Map(Object.entries(wc).map(([e,t])=>[t,e]));function Li(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function $n(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 wh(e,t=""){const n=Li(t),i=wc[e];return n?`${n}${i}`:i}function Sc(e,t=""){const n=Li(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=$n(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":kc.get(s)??null}function kh(e){let t=$n(e);if(t.endsWith("/index.html")&&(t=$n(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(kc.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function Sh(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function So(e){return e==="system"?Sh():e}const Kn=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,$h=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,zn=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},xh=({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=$h();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=Kn(n.pointerClientX/window.innerWidth),p=Kn(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=Kn((f.left+f.width/2)/window.innerWidth),p=Kn((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(()=>zn(o)):zn(o)}catch{zn(o),t()}return}t(),zn(o)},Ah=2e3;async function gn(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(-Ah),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 $c=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:gn},Symbol.toStringTag,{value:"Module"}));async function xc(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 Eh(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function Re(e){return e instanceof Error?e.message:String(e)}let Hn=null;function zt(e,t){Hn&&clearTimeout(Hn),e.filesMessage={kind:"success",text:t},Hn=setTimeout(()=>{e.filesMessage=null,Hn=null},3e3)}async function Ht(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=Re(n)}finally{e.filesLoading=!1}}}}async function Ch(e,t,n){e.filesSelectedPaths=new Set([t]),await Ac(e,t,n)}async function Th(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 Ac(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function _h(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 Ec(e,o,t),i++}catch(r){s=Re(r)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:zt(e,`${i} file${i!==1?"s":""} downloaded`)}async function Mh(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await Rh(e,t,o,i)}async function Ac(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=Re(i)}finally{e.filesPreviewLoading=!1}}}async function Ec(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),u=document.createElement("a");u.href=a,u.download=s.name??t.split("/").pop()??"download",document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(a)}catch(i){e.filesMessage={kind:"error",text:Re(i)}}}async function Ph(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(),u=btoa(new Uint8Array(a).reduce((l,p)=>l+String.fromCharCode(p),"")),c={path:t,name:r.name,data:u};i&&(c.agentId=i),await e.client.request("files.upload",c),s++}catch(a){o=Re(a)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:zt(e,`${s} file${s!==1?"s":""} uploaded`),await Ht(e,i)}async function Lh(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),zt(e,`Created ${s}`),await Ht(e,i),e.filesExpandedDirs=new Set([...e.filesExpandedDirs,s]),e.filesCurrentDir=s}catch(o){e.filesMessage={kind:"error",text:Re(o)}}}async function Ih(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),zt(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await Ht(e,n)}catch(i){e.filesMessage={kind:"error",text:Re(i)}}}}async function Rh(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),zt(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await Ht(e,i)}catch(s){e.filesMessage={kind:"error",text:Re(s)}}}}async function $o(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 Dh(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;zt(e,`Re-indexed: ${s} files, ${o} chunks`),await $o(e,t)}catch(n){e.filesMessage={kind:"error",text:Re(n)}}finally{e.filesReindexBusy=!1}}}function Bh(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 Nh(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:Re(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function Oh(e){e.filesSearchQuery="",e.filesSearchResults=null}function Fh(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{ko(e,{quiet:!0})},5e3))}function Uh(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function xo(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Rt(e,{quiet:!0})},2e3))}function Ao(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function Eo(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||gn(e,{quiet:!0})},2e3))}function Co(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function To(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&fo(e)},3e3))}function _o(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Wh(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{xc(e)},3e4))}function Kh(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function zh(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{if(e.tab!=="files")return;const t=e;$o(t,t.filesResolvedAgentId)},3e3))}function Hh(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function Ze(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,Kd(n),t.theme!==e.theme&&(e.theme=t.theme,Ii(e,So(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function Cc(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&Ze(e,{...e.settings,lastActiveSessionKey:n})}function qh(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 u=n.trim();u&&u!==e.settings.token&&Ze(e,{...e.settings,token:u}),t.delete("token"),r=!0}if(i!=null){const u=i.trim();u&&(e.password=u),t.delete("password"),r=!0}if(s!=null){const u=s.trim();u&&(e.sessionKey=u,Ze(e,{...e.settings,sessionKey:u,lastActiveSessionKey:u}))}if(o!=null){const u=o.trim();u&&u!==e.settings.gatewayUrl&&Ze(e,{...e.settings,gatewayUrl:u}),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 jh(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?Eo(e):xo(e):(Ao(e),Co(e)),t==="debug"?To(e):_o(e),hi(e),_c(e,t,!1)}function Vh(e,t,n){xh({nextTheme:t,applyTheme:()=>{e.theme=t,Ze(e,{...e.settings,theme:t}),Ii(e,So(t))},context:n,currentTheme:e.theme})}async function hi(e){if(e.tab==="overview"&&await Mc(e),e.tab==="channels"&&await ef(e),e.tab==="instances"&&await oc(e),e.tab==="cron"&&await Mo(e),e.tab==="skills"&&await He(e),e.tab==="nodes"&&(await ko(e),await wo(e),await Ie(e),await yh(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await rf(e),Wt(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await Dl(e),await Ie(e)),e.tab==="debug"&&(await fo(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await ie(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>$c);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await Rt(e,{reset:!0});Il(e,!0)}}function Gh(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?Li(e):kh(window.location.pathname)}function Qh(e){e.theme=e.settings.theme??"system",Ii(e,So(e.theme))}function Ii(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function Yh(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"&&Ii(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Jh(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 Xh(e,t){if(typeof window>"u")return;const n=Sc(window.location.pathname,e.basePath)??"chat";Tc(e,n),_c(e,n,t)}function Zh(e){var s;if(typeof window>"u")return;const t=Sc(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,Ze(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),Tc(e,t)}function Tc(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?Eo(e):xo(e):(Ao(e),Co(e)),t==="debug"?To(e):_o(e),e.connected&&hi(e)}function _c(e,t,n){if(typeof window>"u")return;const i=$n(wh(t,e.basePath)),s=$n(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 Mc(e){await Promise.all([G(e,!1),oc(e),uo(e),Kt(e),fo(e)])}async function ef(e){await Promise.all([G(e,!0),Dl(e),Ie(e)])}async function Mo(e){await Promise.all([G(e,!1),Kt(e),xn(e)])}function Pc(e){return e.chatSending||!!e.chatRunId}function tf(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 Lc(e){e.connected&&(e.chatMessage="",await Pl(e))}function nf(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:co(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],Wt(e))}async function Ic(e,t,n){var s,o;po(e);const i=await Ml(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&&Cc(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),Wt(e),i&&!e.chatRunId&&Rc(e),i}async function Rc(e){if(!e.connected||Pc(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await Ic(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function sf(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function of(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(tf(s)){await Lc(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),Pc(e)){nf(e,s,r);return}await Ic(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 rf(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,Le);await Promise.all([Pe(t,{limit:n}),uo(t),Us(e)]),Wt(e,!0)}const af=Rc;function lf(e){var s,o,r;const t=kl(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 cf(e,t){const n=Li(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Us(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=lf(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=cf(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 D={messageSquare:d`<svg viewBox="0 0 24 24"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,barChart:d`<svg viewBox="0 0 24 24"><line x1="12" x2="12" y1="20" y2="10"/><line x1="18" x2="18" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="16"/></svg>`,link:d`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,unlink:d`<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:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="2"/><path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"/></svg>`,fileText:d`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><line x1="16" x2="8" y1="13" y2="13"/><line x1="16" x2="8" y1="17" y2="17"/><line x1="10" x2="8" y1="9" y2="9"/></svg>`,zap:d`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:d`<svg viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>`,settings:d`<svg viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>`,bug:d`<svg viewBox="0 0 24 24"><path d="m8 2 1.88 1.88"/><path d="M14.12 3.88 16 2"/><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9"/><path d="M6.53 9C4.6 8.8 3 7.1 3 5"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="M22 13h-4"/><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"/></svg>`,scrollText:d`<svg viewBox="0 0 24 24"><path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M15 8h-5"/><path d="M15 12h-5"/></svg>`,folder:d`<svg viewBox="0 0 24 24"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>`,users:d`<svg viewBox="0 0 24 24"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>`,menu:d`<svg viewBox="0 0 24 24"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>`,x:d`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:d`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:d`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,search:d`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:d`<svg viewBox="0 0 24 24"><path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/><path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/><path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/><path d="M17.599 6.5a3 3 0 0 0 .399-1.375"/><path d="M6.003 5.125A3 3 0 0 0 6.401 6.5"/><path d="M3.477 10.896a4 4 0 0 1 .585-.396"/><path d="M19.938 10.5a4 4 0 0 1 .585.396"/><path d="M6 18a4 4 0 0 1-1.967-.516"/><path d="M19.967 17.484A4 4 0 0 1 18 18"/></svg>`,book:d`<svg viewBox="0 0 24 24"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/></svg>`,loader:d`<svg viewBox="0 0 24 24"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>`,rotateCw:d`<svg viewBox="0 0 24 24"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>`,download:d`<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,wrench:d`<svg viewBox="0 0 24 24"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>`,fileCode:d`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><path d="m10 13-2 2 2 2"/><path d="m14 17 2-2-2-2"/></svg>`,edit:d`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,penLine:d`<svg viewBox="0 0 24 24"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>`,paperclip:d`<svg viewBox="0 0 24 24"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`,globe:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>`,image:d`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>`,smartphone:d`<svg viewBox="0 0 24 24"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>`,plug:d`<svg viewBox="0 0 24 24"><path d="M12 22v-5"/><path d="M9 8V2"/><path d="M15 8V2"/><path d="M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z"/></svg>`,circle:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:d`<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:d`<svg viewBox="0 0 24 24"><path d="M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.076.874.54 1.02 1.02a2.5 2.5 0 1 0 3.237-3.237c-.48-.146-.944-.505-1.02-1.02a.98.98 0 0 1 .303-.917l1.526-1.526A2.402 2.402 0 0 1 11.998 2c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.236 3.236c-.464.18-.894.527-.967 1.02Z"/></svg>`,info:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>`,send:d`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`,slidersHorizontal:d`<svg viewBox="0 0 24 24"><line x1="21" x2="14" y1="4" y2="4"/><line x1="10" x2="3" y1="4" y2="4"/><line x1="21" x2="12" y1="12" y2="12"/><line x1="8" x2="3" y1="12" y2="12"/><line x1="21" x2="16" y1="20" y2="20"/><line x1="12" x2="3" y1="20" y2="20"/><line x1="14" x2="14" y1="2" y2="6"/><line x1="8" x2="8" y1="10" y2="14"/><line x1="16" x2="16" y1="18" y2="22"/></svg>`,square:d`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:d`<svg viewBox="0 0 24 24"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`,eyeOff:d`<svg viewBox="0 0 24 24"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,trash:d`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,chevronDown:d`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:d`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/></svg>`,wifi:d`<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:d`<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>`},uf=d`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`,df=d`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><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 Kr=!1;function pf(){Kr||(Kr=!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 kt(e,t){const n=(l,p)=>l===e?d`<span class="sp-page-nav-current">${l}</span>`:d`<a href=${p}>${l}</a>`,i=d`
|
|
21
21
|
${n("Setup","/setup")}
|
|
22
22
|
${n("Chat","/chat")}
|
|
23
23
|
${n("Admins","/admins")}
|
|
@@ -25,14 +25,14 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
25
25
|
${n("Files","/files")}
|
|
26
26
|
${n("Browser","/browser")}
|
|
27
27
|
${n("Advanced","/advanced")}
|
|
28
|
-
`,o=t&&(t.isMaster!==!1||!t.hasPins)?
|
|
29
|
-
${
|
|
28
|
+
`,o=t&&(t.isMaster!==!1||!t.hasPins)?hf(t):S,r=t!=null&&t.hasPins&&t.onLogout?d`<button class="nav-logout-btn" @click=${t.onLogout} title="Lock">${uf}</button>`:S,a=(t==null?void 0:t.auditCount)??0,u=a>0&&(t!=null&&t.onAuditClick)?d`<button class="nav-audit-btn" @click=${t.onAuditClick} title="Memory writes to review">
|
|
29
|
+
${df}
|
|
30
30
|
<span class="nav-audit-badge">${a>99?"99+":a}</span>
|
|
31
|
-
</button>`:S,c=()=>{const l=document.getElementById("nav-burger-toggle");l&&(l.checked=!1)};return
|
|
31
|
+
</button>`:S,c=()=>{const l=document.getElementById("nav-burger-toggle");l&&(l.checked=!1)};return pf(),d`
|
|
32
32
|
<div class="setup-header">
|
|
33
33
|
<input type="checkbox" id="nav-burger-toggle" class="nav-burger-checkbox" />
|
|
34
34
|
<div class="setup-header-inner">
|
|
35
|
-
<img class="setup-header-logo" src="${
|
|
35
|
+
<img class="setup-header-logo" src="${ze().iconUrl}" alt="${ze().name}" />
|
|
36
36
|
<nav class="setup-header-nav">
|
|
37
37
|
${i}
|
|
38
38
|
</nav>
|
|
@@ -50,7 +50,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
50
50
|
${i}
|
|
51
51
|
</nav>
|
|
52
52
|
</div>
|
|
53
|
-
`}function
|
|
53
|
+
`}function hf(e){const{workspaces:t,selectedWorkspace:n,onWorkspaceSelect:i}=e;return d`
|
|
54
54
|
<select
|
|
55
55
|
class="sp-workspace-selector"
|
|
56
56
|
.value=${n??""}
|
|
@@ -64,7 +64,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
64
64
|
<option disabled>───</option>
|
|
65
65
|
<option value="__add__">+ Add Account</option>
|
|
66
66
|
</select>
|
|
67
|
-
`}function
|
|
67
|
+
`}function ff(e){return e.connected?e.fullscreen&&e.active?d`
|
|
68
68
|
<div class="sp-fullscreen-overlay">
|
|
69
69
|
<div class="sp-fullscreen-toolbar">
|
|
70
70
|
<button
|
|
@@ -106,7 +106,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
106
106
|
</div>
|
|
107
107
|
`:d`
|
|
108
108
|
<div class="setup-container">
|
|
109
|
-
${
|
|
109
|
+
${kt("Browser")}
|
|
110
110
|
<div class="setup-card sp-card-wide">
|
|
111
111
|
<h1>Remote Browser</h1>
|
|
112
112
|
<p style="margin-bottom: 16px;">Live view of the headless Chrome instance.</p>
|
|
@@ -196,14 +196,14 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
196
196
|
<p>Connecting to gateway...</p>
|
|
197
197
|
</div>
|
|
198
198
|
</div>
|
|
199
|
-
`}const
|
|
199
|
+
`}const fi="application/x-taskmaster-file-path";let at=null;function Dc(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Bc(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function gf(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(fi);if(i){Bc(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(u=>u.name.toLowerCase().endsWith(".md"));a.length>0&&n.onUpload(t,a)}}function Nc(e,t,n){var u;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?d`
|
|
200
200
|
<div
|
|
201
201
|
class="sp-tree-item sp-tree-dir ${s?"expanded":""} ${r?"current":""}"
|
|
202
202
|
style="padding-left: ${a}px;"
|
|
203
203
|
@click=${()=>t.onToggleDir(e.path)}
|
|
204
204
|
@dragover=${c=>{c.preventDefault(),c.stopPropagation(),c.dataTransfer&&(c.dataTransfer.dropEffect="move"),c.currentTarget.classList.add("sp-drop-target")}}
|
|
205
205
|
@dragleave=${c=>{c.currentTarget.classList.remove("sp-drop-target")}}
|
|
206
|
-
@drop=${c=>
|
|
206
|
+
@drop=${c=>gf(c,e.path,t)}
|
|
207
207
|
>
|
|
208
208
|
<span class="sp-tree-chevron">${s?"−":"+"}</span>
|
|
209
209
|
<span class="sp-tree-icon">${D.folder}</span>
|
|
@@ -214,20 +214,20 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
214
214
|
@click=${c=>{c.stopPropagation(),t.onDelete(e.path)}}
|
|
215
215
|
>×</span>`:S}
|
|
216
216
|
</div>
|
|
217
|
-
${s&&e.children?e.children.map(c=>
|
|
217
|
+
${s&&e.children?e.children.map(c=>Nc(c,t,n+1)):S}
|
|
218
218
|
`:d`
|
|
219
219
|
<div
|
|
220
220
|
class="sp-tree-item sp-tree-file ${o?"selected":""}"
|
|
221
221
|
style="padding-left: ${a}px;"
|
|
222
222
|
draggable="true"
|
|
223
223
|
@click=${c=>{c.metaKey||c.ctrlKey?t.onToggleSelectFile(e.path):t.onSelectFile(e.path)}}
|
|
224
|
-
@dragstart=${c=>{c.dataTransfer&&(c.dataTransfer.effectAllowed="move",c.dataTransfer.setData(
|
|
224
|
+
@dragstart=${c=>{c.dataTransfer&&(c.dataTransfer.effectAllowed="move",c.dataTransfer.setData(fi,e.path),c.dataTransfer.setData("text/plain",e.name))}}
|
|
225
225
|
>
|
|
226
226
|
<span class="sp-tree-icon">${D.fileText}</span>
|
|
227
227
|
<span class="sp-tree-name">${e.name}</span>
|
|
228
|
-
<span class="sp-tree-size">${
|
|
228
|
+
<span class="sp-tree-size">${Dc(e.size)}</span>
|
|
229
229
|
</div>
|
|
230
|
-
`}function
|
|
230
|
+
`}function mf(e){const t=e.selectedPaths.size;return t<2?S:d`
|
|
231
231
|
<div class="sp-bulk-actions">
|
|
232
232
|
<span style="color: var(--tasker-muted-grey); font-size: 13px;">${t} files selected</span>
|
|
233
233
|
<button
|
|
@@ -238,7 +238,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
238
238
|
Download ${t} files
|
|
239
239
|
</button>
|
|
240
240
|
</div>
|
|
241
|
-
`}function
|
|
241
|
+
`}function yf(e){if(e.selectedPaths.size!==1||!e.selectedPath)return S;if(e.previewLoading)return d`
|
|
242
242
|
<div class="sp-file-preview">
|
|
243
243
|
<div class="setup-spinner" style="width: 32px; height: 32px; margin: 24px auto;"></div>
|
|
244
244
|
</div>
|
|
@@ -248,21 +248,21 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
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?` — ${Dc(e.previewSize)}`:""}
|
|
252
252
|
</div>
|
|
253
253
|
</div>
|
|
254
254
|
<div class="sp-file-actions">
|
|
255
255
|
<button class="setup-button secondary" style="padding: 8px 16px; font-size: 13px;" @click=${()=>e.onDownload(e.selectedPath)}>
|
|
256
256
|
Download
|
|
257
257
|
</button>
|
|
258
|
-
<button class="setup-button danger" style="padding: 8px 16px; font-size: 13px;" @click=${()=>{e.pendingDeletePath===e.selectedPath?(
|
|
258
|
+
<button class="setup-button danger" style="padding: 8px 16px; font-size: 13px;" @click=${()=>{e.pendingDeletePath===e.selectedPath?(at&&clearTimeout(at),at=null,e.onDelete(e.selectedPath)):(e.onArmDelete(e.selectedPath),at&&clearTimeout(at),at=setTimeout(()=>{e.onArmDelete(""),at=null},3e3))}}>
|
|
259
259
|
${e.pendingDeletePath===e.selectedPath?"Confirm delete?":"Delete"}
|
|
260
260
|
</button>
|
|
261
261
|
</div>
|
|
262
262
|
</div>
|
|
263
263
|
${e.previewBinary?d`<div class="sp-file-preview-body"><p style="color: var(--tasker-muted-grey);">Binary file — use Download to view.</p></div>`:e.previewContent!=null?d`<div class="sp-file-preview-body"><pre class="sp-file-code">${e.previewContent}</pre></div>`:d`<div class="sp-file-preview-body"><p style="color: var(--tasker-muted-grey);">File too large for preview — use Download.</p></div>`}
|
|
264
264
|
</div>
|
|
265
|
-
`}function
|
|
265
|
+
`}function vf(e){return d`
|
|
266
266
|
<div class="sp-search-bar">
|
|
267
267
|
<input
|
|
268
268
|
type="text"
|
|
@@ -294,7 +294,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
294
294
|
Clear
|
|
295
295
|
</button>`:S}
|
|
296
296
|
</div>
|
|
297
|
-
`}function
|
|
297
|
+
`}function bf(e){return e.searchResults?e.searchResults.length===0?d`<div class="sp-search-results">
|
|
298
298
|
<div style="padding: 24px; color: var(--tasker-muted-grey); text-align: center;">No results found.</div>
|
|
299
299
|
</div>`:d`
|
|
300
300
|
<div class="sp-search-results">
|
|
@@ -314,9 +314,9 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
314
314
|
</div>
|
|
315
315
|
`)}
|
|
316
316
|
</div>
|
|
317
|
-
`:S}function
|
|
317
|
+
`:S}function wf(e){const t=e.currentDir;return e.connected?d`
|
|
318
318
|
<div class="setup-container">
|
|
319
|
-
${
|
|
319
|
+
${kt("Files",e.wsProps)}
|
|
320
320
|
<div class="setup-card sp-card-wide">
|
|
321
321
|
<h1>Workspace Files</h1>
|
|
322
322
|
<p style="margin-bottom: 16px;">Browse, upload, and manage files in your workspace. Drag files between folders to move them.</p>
|
|
@@ -378,18 +378,18 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
378
378
|
|
|
379
379
|
${e.uploadBusy?d`<div style="margin-top: 12px; color: var(--tasker-orange); font-weight: 600; font-size: 14px;">Uploading...</div>`:S}
|
|
380
380
|
|
|
381
|
-
${
|
|
381
|
+
${vf(e)}
|
|
382
382
|
|
|
383
|
-
${e.searchResults!==null?
|
|
383
|
+
${e.searchResults!==null?bf(e):d`<div
|
|
384
384
|
class="sp-file-tree"
|
|
385
|
-
@dragover=${n=>{n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(
|
|
386
|
-
@drop=${n=>{var o,r;n.preventDefault();const i=(o=n.dataTransfer)==null?void 0:o.getData(
|
|
385
|
+
@dragover=${n=>{n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(fi)?"move":"copy")}}
|
|
386
|
+
@drop=${n=>{var o,r;n.preventDefault();const i=(o=n.dataTransfer)==null?void 0:o.getData(fi);if(i){Bc(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(u=>u.name.toLowerCase().endsWith(".md"));a.length>0&&e.onUpload(t,a)}}}
|
|
387
387
|
>
|
|
388
|
-
${e.tree.length===0&&!e.loading?d`<div style="padding: 24px; color: var(--tasker-muted-grey); text-align: center;">No files found. Drop .md files here to upload.</div>`:e.tree.map(n=>
|
|
388
|
+
${e.tree.length===0&&!e.loading?d`<div style="padding: 24px; color: var(--tasker-muted-grey); text-align: center;">No files found. Drop .md files here to upload.</div>`:e.tree.map(n=>Nc(n,e,0))}
|
|
389
389
|
</div>`}
|
|
390
390
|
|
|
391
|
-
${
|
|
392
|
-
${
|
|
391
|
+
${mf(e)}
|
|
392
|
+
${yf(e)}
|
|
393
393
|
</div>
|
|
394
394
|
</div>
|
|
395
395
|
`:d`
|
|
@@ -399,7 +399,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
399
399
|
<p>Connecting to gateway...</p>
|
|
400
400
|
</div>
|
|
401
401
|
</div>
|
|
402
|
-
`}const
|
|
402
|
+
`}const Po="taskmaster_uninstall_done";async function kf(e){var t,n;if(!(!e.client||!e.connected)&&!e.uninstallBusy){e.uninstallBusy=!0,e.uninstallError=null,(t=e.requestUpdate)==null||t.call(e),Sf();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 gi(){try{return localStorage.getItem(Po)==="1"}catch{return!1}}function Lo(){try{localStorage.removeItem(Po)}catch{}}function Sf(){try{localStorage.setItem(Po,"1")}catch{}}const zr=Object.freeze(Object.defineProperty({__proto__:null,checkUninstallDone:gi,clearUninstallDone:Lo,runUninstall:kf},Symbol.toStringTag,{value:"Module"}));function q(e){return d`
|
|
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}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
412
412
|
>
|
|
413
413
|
${D.info}
|
|
414
414
|
</button>
|
|
415
|
-
`}function
|
|
415
|
+
`}function $f(e){var i;if(!e.infoModalOpen)return S;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=qt(e),o=s?Io(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:Oc(o.lastError)}]:[]];break}case"imessage":{const{thisWsOwns:s}=Ro(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"internet":{const s=e.tailscaleStatus,o=s?s.installed?s.loggedIn?s.funnelEnabled&&s.funnelActive?"Active":s.funnelEnabled&&!s.funnelActive?"Enabled but not active":"Connected (not public)":"Not connected":"Not installed":"Checking...";t="Internet Access",n=[{label:"Status",value:o},{label:"What",value:"Makes your public chat and API reachable from the internet, not just your local network"},{label:"How",value:"Uses Tailscale Funnel — a free, secure tunnel that gives your device a public HTTPS address"},{label:"Security",value:"Only the /public/* paths are exposed. The control panel stays LAN-only."},...s!=null&&s.publicUrl?[{label:"Public URL",value:s.publicUrl}]:[],...s!=null&&s.hostname?[{label:"Hostname",value:s.hostname}]:[]];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:"Access mode",value:Pf[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}default:return S}return d`
|
|
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>
|
|
@@ -431,7 +431,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
431
431
|
</button>
|
|
432
432
|
</div>
|
|
433
433
|
</div>
|
|
434
|
-
`}function
|
|
434
|
+
`}function ke(e){const t=[{id:"license",label:"1. Activate License"},{id:"auth",label:"2. Connect Claude"},{id:"whatsapp",label:"3. Link WhatsApp"}],n=["license","auth","whatsapp","complete"],i=n.indexOf(e);return d`
|
|
435
435
|
<div class="setup-steps">
|
|
436
436
|
${t.map(s=>{const o=n.indexOf(s.id),r=e===s.id,a=i>o;return d`
|
|
437
437
|
<div
|
|
@@ -442,12 +442,12 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
442
442
|
</div>
|
|
443
443
|
`})}
|
|
444
444
|
</div>
|
|
445
|
-
`}function
|
|
445
|
+
`}function Hr(e){const{licenseKey:t,licenseBusy:n,licenseValid:i,licenseMessage:s,licenseDeviceId:o,onLicenseKeyChange:r,onLicenseActivate:a}=e;return i===!0?d`
|
|
446
446
|
<div class="setup-container">
|
|
447
447
|
<div class="setup-card setup-success">
|
|
448
|
-
${
|
|
448
|
+
${ke("license")}
|
|
449
449
|
<div class="setup-status-row">
|
|
450
|
-
${
|
|
450
|
+
${q("good")}
|
|
451
451
|
<span>License Activated</span>
|
|
452
452
|
</div>
|
|
453
453
|
<p>${s??"Your license is active."}</p>
|
|
@@ -456,7 +456,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
456
456
|
`:n&&!t?d`
|
|
457
457
|
<div class="setup-container">
|
|
458
458
|
<div class="setup-card">
|
|
459
|
-
${
|
|
459
|
+
${ke("license")}
|
|
460
460
|
<div class="setup-spinner"></div>
|
|
461
461
|
<p>Checking license...</p>
|
|
462
462
|
</div>
|
|
@@ -464,7 +464,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
464
464
|
`:d`
|
|
465
465
|
<div class="setup-container">
|
|
466
466
|
<div class="setup-card">
|
|
467
|
-
${
|
|
467
|
+
${ke("license")}
|
|
468
468
|
<h1>Activate License</h1>
|
|
469
469
|
<p>Enter your license key to get started.</p>
|
|
470
470
|
${o?d`
|
|
@@ -499,7 +499,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
499
499
|
</div>
|
|
500
500
|
${i===!1&&s?d`
|
|
501
501
|
<div class="setup-status-row" style="margin-top: 12px;">
|
|
502
|
-
${
|
|
502
|
+
${q("bad")}
|
|
503
503
|
<span class="setup-error">${s}</span>
|
|
504
504
|
</div>
|
|
505
505
|
`:S}
|
|
@@ -511,12 +511,12 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
511
511
|
</p>
|
|
512
512
|
</div>
|
|
513
513
|
</div>
|
|
514
|
-
`}function
|
|
514
|
+
`}function xf(e){const{authConnected:t,authBusy:n,authMessage:i,authUrl:s,authCodeInput:o,authExpiresIn:r,onStartAuth:a,onSubmitAuthCode:u,onAuthCodeChange:c,onSkipToWhatsApp:l}=e;return t===!0?d`
|
|
515
515
|
<div class="setup-container">
|
|
516
516
|
<div class="setup-card setup-success">
|
|
517
|
-
${
|
|
517
|
+
${ke("auth")}
|
|
518
518
|
<div class="setup-status-row">
|
|
519
|
-
${
|
|
519
|
+
${q("good")}
|
|
520
520
|
<span>Claude Connected</span>
|
|
521
521
|
</div>
|
|
522
522
|
<p>
|
|
@@ -536,7 +536,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
536
536
|
`:n&&!s?d`
|
|
537
537
|
<div class="setup-container">
|
|
538
538
|
<div class="setup-card">
|
|
539
|
-
${
|
|
539
|
+
${ke("auth")}
|
|
540
540
|
<div class="setup-spinner"></div>
|
|
541
541
|
<p>Starting Claude connection...</p>
|
|
542
542
|
</div>
|
|
@@ -544,7 +544,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
544
544
|
`:s?d`
|
|
545
545
|
<div class="setup-container">
|
|
546
546
|
<div class="setup-card">
|
|
547
|
-
${
|
|
547
|
+
${ke("auth")}
|
|
548
548
|
<h1>Connect to Claude</h1>
|
|
549
549
|
<p>Click the button below to sign in with your Claude Pro account.</p>
|
|
550
550
|
<a
|
|
@@ -585,7 +585,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
585
585
|
`:e.authApiKeyMode?d`
|
|
586
586
|
<div class="setup-container">
|
|
587
587
|
<div class="setup-card">
|
|
588
|
-
${
|
|
588
|
+
${ke("auth")}
|
|
589
589
|
<h1>Enter API Key</h1>
|
|
590
590
|
<p>Paste your Anthropic API key below.</p>
|
|
591
591
|
<div class="setup-code-input">
|
|
@@ -621,7 +621,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
621
621
|
`:d`
|
|
622
622
|
<div class="setup-container">
|
|
623
623
|
<div class="setup-card">
|
|
624
|
-
${
|
|
624
|
+
${ke("auth")}
|
|
625
625
|
<h1>Connect to Claude</h1>
|
|
626
626
|
${t===!1&&i?d`<p class="setup-error">${i}</p>`:d`<p>
|
|
627
627
|
First, let's connect your Claude Pro subscription.<br />
|
|
@@ -643,7 +643,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
643
643
|
</p>
|
|
644
644
|
</div>
|
|
645
645
|
</div>
|
|
646
|
-
`}function
|
|
646
|
+
`}function Io(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 qt(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 qr(e){const t=qt(e),n=(t==null?void 0:t.displayName)??(t==null?void 0:t.name)??ze().name,i=e.whatsappBusy||e.gatewayHealthLoading;if(e.renamingWorkspace&&t){const s=()=>{const o=e.renameWorkspaceName.trim();o&&e.onWorkspaceRename(t.name,o)};return d`
|
|
647
647
|
<div style="display: flex; align-items: center; gap: 6px; margin-bottom: 4px;">
|
|
648
648
|
<input
|
|
649
649
|
type="text"
|
|
@@ -685,9 +685,9 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
685
685
|
${D.rotateCw}
|
|
686
686
|
</button>
|
|
687
687
|
</div>
|
|
688
|
-
`}function
|
|
688
|
+
`}function jr(e){return d`
|
|
689
689
|
<div class="setup-status-item">
|
|
690
|
-
${
|
|
690
|
+
${q(e.gatewayHealthy===!1?"bad":"good")}
|
|
691
691
|
<div class="setup-status-info">
|
|
692
692
|
<strong>Gateway</strong>
|
|
693
693
|
<span>${e.gatewayHealthMessage||"Running"}</span>
|
|
@@ -702,9 +702,9 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
702
702
|
${D.rotateCw}
|
|
703
703
|
</button>
|
|
704
704
|
</div>
|
|
705
|
-
`}function
|
|
705
|
+
`}function Vr(e){const t=e.authConnected===!0;return d`
|
|
706
706
|
<div class="setup-status-item">
|
|
707
|
-
${
|
|
707
|
+
${q(t?"good":"bad")}
|
|
708
708
|
<div class="setup-status-info">
|
|
709
709
|
<strong>Claude</strong>
|
|
710
710
|
<span>
|
|
@@ -731,9 +731,9 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
731
731
|
</button>
|
|
732
732
|
`}
|
|
733
733
|
</div>
|
|
734
|
-
`}function
|
|
734
|
+
`}function Gr(e){return d`
|
|
735
735
|
<div class="setup-status-item" style="flex-wrap: wrap;">
|
|
736
|
-
${
|
|
736
|
+
${q("good")}
|
|
737
737
|
<div class="setup-status-info">
|
|
738
738
|
<strong>License</strong>
|
|
739
739
|
<span>Active</span>
|
|
@@ -749,7 +749,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
749
749
|
${e.licenseRemoveConfirm?d`
|
|
750
750
|
<div style="width: 100%; margin-top: 8px; margin-left: 30px;">
|
|
751
751
|
<p style="color: var(--tasker-text-grey); font-size: 13px; margin: 0 0 8px;">
|
|
752
|
-
Removing your license will disable ${
|
|
752
|
+
Removing your license will disable ${ze().name} until you enter a new key.
|
|
753
753
|
</p>
|
|
754
754
|
<div style="display: flex; gap: 8px;">
|
|
755
755
|
<button
|
|
@@ -771,9 +771,9 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
771
771
|
</div>
|
|
772
772
|
`:S}
|
|
773
773
|
</div>
|
|
774
|
-
`}function
|
|
774
|
+
`}function Oc(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 Qr(e){var p;const t=qt(e);if(!t)return S;const n=Io(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?Oc(n.lastError):"Not connected":"Not paired",u=!(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 d`
|
|
775
775
|
<div class="setup-status-item" style="flex-wrap: wrap;">
|
|
776
|
-
${
|
|
776
|
+
${q(r)}
|
|
777
777
|
<div class="setup-status-info">
|
|
778
778
|
<div style="display: flex; align-items: center; gap: 4px;">
|
|
779
779
|
<strong>WhatsApp</strong>
|
|
@@ -832,7 +832,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
832
832
|
</div>
|
|
833
833
|
`:S}
|
|
834
834
|
</div>
|
|
835
|
-
`}const
|
|
835
|
+
`}const Af=[{id:"claude-opus-4-6",shortName:"Opus"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku"}],Ef="anthropic/claude-sonnet-4-5-20250929",Cf=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function Tf(e){if(!e.whatsappSettingsOpen)return S;const t=qt(e);if(!t)return S;const n=Io(t,e),i=(n==null?void 0:n.running)&&(n==null?void 0:n.connected);if(!n||!i)return S;const s=()=>e.onWhatsAppSettingsClose(),o=e.whatsappModelCatalog??[],r=new Set(o.filter(l=>l.provider==="anthropic").map(l=>l.id)),a=Af.filter(l=>r.has(l.id)),u=e.whatsappModel??Ef,c=e.whatsappThinkingLevel??"off";return d`
|
|
836
836
|
<div class="setup-info-overlay" @click=${l=>{l.target.classList.contains("setup-info-overlay")&&s()}}>
|
|
837
837
|
<div class="setup-info-card" style="max-width: 360px;">
|
|
838
838
|
<h3>Public Agent Settings</h3>
|
|
@@ -918,7 +918,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
918
918
|
.value=${c}
|
|
919
919
|
@change=${l=>{e.onWhatsAppThinkingChange(l.target.value)}}
|
|
920
920
|
>
|
|
921
|
-
${
|
|
921
|
+
${Cf.map(l=>d`
|
|
922
922
|
<option value=${l.value} ?selected=${c===l.value}>
|
|
923
923
|
${l.label}
|
|
924
924
|
</option>
|
|
@@ -935,9 +935,9 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
935
935
|
</button>
|
|
936
936
|
</div>
|
|
937
937
|
</div>
|
|
938
|
-
`}function
|
|
938
|
+
`}function Ro(e){const t=qt(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 Yr(e){const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=Ro(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"),d`
|
|
939
939
|
<div class="setup-status-item" style="flex-wrap: wrap;">
|
|
940
|
-
${
|
|
940
|
+
${q(s)}
|
|
941
941
|
<div class="setup-status-info">
|
|
942
942
|
<strong>iMessage</strong>
|
|
943
943
|
<span>${o}</span>
|
|
@@ -953,7 +953,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
953
953
|
</button>
|
|
954
954
|
${S}
|
|
955
955
|
</div>
|
|
956
|
-
`}function
|
|
956
|
+
`}function _f(e){if(!e.imessageEnableConfirm)return S;const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=Ro(e),s=()=>{e.onIMessageEnableCancel()};return n?d`
|
|
957
957
|
<div class="setup-info-overlay" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&s()}}>
|
|
958
958
|
<div class="setup-info-card" style="text-align: center;">
|
|
959
959
|
<h3>iMessage</h3>
|
|
@@ -1010,7 +1010,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1010
1010
|
<div class="setup-info-card" style="text-align: center;">
|
|
1011
1011
|
<h3>Enable iMessage</h3>
|
|
1012
1012
|
<p style="color: var(--tasker-text-grey); font-size: 13px; margin: 8px 0 16px;">
|
|
1013
|
-
${
|
|
1013
|
+
${ze().name} will respond to messages in Messages.app for this business.
|
|
1014
1014
|
</p>
|
|
1015
1015
|
<button
|
|
1016
1016
|
class="setup-button primary"
|
|
@@ -1029,10 +1029,10 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1029
1029
|
</button>
|
|
1030
1030
|
</div>
|
|
1031
1031
|
</div>
|
|
1032
|
-
`}function
|
|
1032
|
+
`}function Jr(e){if(!e.isMaster)return S;const n=e.apiKeyProviders.filter(i=>i.hasKey).length;return d`
|
|
1033
1033
|
<div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
|
|
1034
1034
|
<div class="setup-status-item">
|
|
1035
|
-
${
|
|
1035
|
+
${q(n>0?"good":"bad")}
|
|
1036
1036
|
<div class="setup-status-info">
|
|
1037
1037
|
<strong>API Keys</strong>
|
|
1038
1038
|
<span>${n} configured</span>
|
|
@@ -1043,8 +1043,8 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1043
1043
|
>Manage</button>
|
|
1044
1044
|
</div>
|
|
1045
1045
|
</div>
|
|
1046
|
-
${
|
|
1047
|
-
`}function
|
|
1046
|
+
${Mf(e)}
|
|
1047
|
+
`}function Mf(e){if(!e.apiKeyModalOpen)return S;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"),f=p==null?void 0:p.querySelector("input"),b=f==null?void 0:f.value.trim();!b||b===n[c]||e.onApiKeySave(c,b)},s=c=>{const l=c.currentTarget,p=l.closest(".setup-apikey-input"),f=p==null?void 0:p.querySelector("input");if(!f)return;const b=f.type==="text";f.type=b?"password":"text",l.classList.toggle("active",!b)},o=(c,l)=>{const p=l.target,f=p.closest(".setup-apikey-input"),b=p.value.trim(),h=b.length>0&&b!==n[c],v=f==null?void 0:f.querySelector(".setup-apikey-save");v&&(v.style.display=h?"":"none");const k=f==null?void 0:f.querySelector(".setup-apikey-eye");k&&(k.style.display=b.length>0?"":"none")},r=t.filter(c=>c.primary),a=t.filter(c=>!c.primary),u=c=>{const l=e.apiKeySavingProvider===c.id&&e.apiKeyBusy,p=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key saved`,f=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key removed`;return d`
|
|
1048
1048
|
<div class="setup-apikey-row">
|
|
1049
1049
|
<div class="setup-apikey-info">
|
|
1050
1050
|
<strong>${c.name}</strong>
|
|
@@ -1099,9 +1099,9 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1099
1099
|
</div>
|
|
1100
1100
|
</div>
|
|
1101
1101
|
</div>
|
|
1102
|
-
`}function
|
|
1102
|
+
`}function Xr(e){const t=e.updateAvailable===null?"unknown":e.updateAvailable?"partial":"good",n=e.updateAvailable&&e.latestVersion?`v${e.currentVersion} → v${e.latestVersion}`:e.currentVersion?`v${e.currentVersion}`:"Unknown",i=e.updateChecking||e.updateRunning;return d`
|
|
1103
1103
|
<div class="setup-status-item">
|
|
1104
|
-
${
|
|
1104
|
+
${q(t)}
|
|
1105
1105
|
<div class="setup-status-info">
|
|
1106
1106
|
<strong>Software</strong>
|
|
1107
1107
|
<span>${n}</span>
|
|
@@ -1114,7 +1114,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1114
1114
|
@click=${e.onUpdateRun}
|
|
1115
1115
|
title="Update Now"
|
|
1116
1116
|
>
|
|
1117
|
-
${D.download}
|
|
1117
|
+
${e.updateRunning?D.loader:D.download}
|
|
1118
1118
|
</button>
|
|
1119
1119
|
`:d`
|
|
1120
1120
|
<button
|
|
@@ -1127,9 +1127,9 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1127
1127
|
</button>
|
|
1128
1128
|
`}
|
|
1129
1129
|
</div>
|
|
1130
|
-
`}const
|
|
1130
|
+
`}const Pf={anonymous:"Open access",verified:"WhatsApp OTP",choice:"Visitor chooses"};function Zr(e){const t=e.publicChatEnabled;return d`
|
|
1131
1131
|
<div class="setup-status-item">
|
|
1132
|
-
${
|
|
1132
|
+
${q(t?"good":"unknown")}
|
|
1133
1133
|
<div class="setup-status-info">
|
|
1134
1134
|
<strong>Public Chat</strong>
|
|
1135
1135
|
${t?d`
|
|
@@ -1151,9 +1151,9 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1151
1151
|
@click=${e.onPublicChatToggle}
|
|
1152
1152
|
>${e.publicChatBusy?"...":t?"Disable":"Enable"}</button>
|
|
1153
1153
|
</div>
|
|
1154
|
-
`}function
|
|
1154
|
+
`}function ea(e){const t=!!(e.brandAccentColor||e.brandBackgroundColor||e.brandHasLogo),n=t?"good":"unknown",i=e.brandingBusy;return d`
|
|
1155
1155
|
<div class="setup-status-item">
|
|
1156
|
-
${
|
|
1156
|
+
${q(n)}
|
|
1157
1157
|
<div class="setup-status-info">
|
|
1158
1158
|
<strong>Branding</strong>
|
|
1159
1159
|
<span>${t?"Customised":"Default"}</span>
|
|
@@ -1165,7 +1165,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1165
1165
|
@click=${e.onBrandingToggle}
|
|
1166
1166
|
>${i?"...":"Edit"}</button>
|
|
1167
1167
|
</div>
|
|
1168
|
-
`}function
|
|
1168
|
+
`}function ta(e){var s;if(!e.brandingExpanded)return S;const t=e.brandingBusy,n=(s=e.wsProps)==null?void 0:s.selectedWorkspace,i=e.brandHasLogo&&n?`/brand-logo/${encodeURIComponent(n)}`:"";return d`
|
|
1169
1169
|
<div class="setup-info-overlay" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&e.onBrandingToggle()}}>
|
|
1170
1170
|
<div class="setup-info-card" style="max-width: 400px;">
|
|
1171
1171
|
<h3>Branding</h3>
|
|
@@ -1234,9 +1234,9 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1234
1234
|
</button>
|
|
1235
1235
|
</div>
|
|
1236
1236
|
</div>
|
|
1237
|
-
`}function
|
|
1237
|
+
`}function Lf(e){if(!e.isMaster)return S;const t=e.tailscaleStatus,n=e.tailscaleBusy,i=e.tailscaleAuthUrl;if(!t)return d`
|
|
1238
1238
|
<div class="setup-status-item">
|
|
1239
|
-
${
|
|
1239
|
+
${q("unknown")}
|
|
1240
1240
|
<div class="setup-status-info">
|
|
1241
1241
|
<strong>Internet Access</strong>
|
|
1242
1242
|
<span>Checking...</span>
|
|
@@ -1245,7 +1245,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1245
1245
|
</div>
|
|
1246
1246
|
`;if(!t.installed)return d`
|
|
1247
1247
|
<div class="setup-status-item">
|
|
1248
|
-
${
|
|
1248
|
+
${q("unknown")}
|
|
1249
1249
|
<div class="setup-status-info">
|
|
1250
1250
|
<strong>Internet Access</strong>
|
|
1251
1251
|
<span>Tailscale not installed</span>
|
|
@@ -1255,7 +1255,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1255
1255
|
`;if(i)return d`
|
|
1256
1256
|
<div>
|
|
1257
1257
|
<div class="setup-status-item">
|
|
1258
|
-
${
|
|
1258
|
+
${q("partial")}
|
|
1259
1259
|
<div class="setup-status-info">
|
|
1260
1260
|
<strong>Internet Access</strong>
|
|
1261
1261
|
<span>Waiting for authentication...</span>
|
|
@@ -1285,7 +1285,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1285
1285
|
</div>
|
|
1286
1286
|
`;if(!t.loggedIn)return d`
|
|
1287
1287
|
<div class="setup-status-item">
|
|
1288
|
-
${
|
|
1288
|
+
${q("partial")}
|
|
1289
1289
|
<div class="setup-status-info">
|
|
1290
1290
|
<strong>Internet Access</strong>
|
|
1291
1291
|
<span>Not connected</span>
|
|
@@ -1300,7 +1300,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1300
1300
|
`;if(!t.funnelEnabled){const o=e.tailscaleFunnelEnableUrl;return d`
|
|
1301
1301
|
<div>
|
|
1302
1302
|
<div class="setup-status-item">
|
|
1303
|
-
${
|
|
1303
|
+
${q("partial")}
|
|
1304
1304
|
<div class="setup-status-info">
|
|
1305
1305
|
<strong>Internet Access</strong>
|
|
1306
1306
|
<span>Connected (LAN only)</span>
|
|
@@ -1332,7 +1332,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1332
1332
|
`}if(!t.funnelActive)return d`
|
|
1333
1333
|
<div>
|
|
1334
1334
|
<div class="setup-status-item">
|
|
1335
|
-
${
|
|
1335
|
+
${q("error")}
|
|
1336
1336
|
<div class="setup-status-info">
|
|
1337
1337
|
<strong>Internet Access</strong>
|
|
1338
1338
|
<span>Enabled but not active</span>
|
|
@@ -1359,7 +1359,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1359
1359
|
</div>
|
|
1360
1360
|
`;const s=t.publicUrl??`https://${t.hostname}`;return d`
|
|
1361
1361
|
<div class="setup-status-item">
|
|
1362
|
-
${
|
|
1362
|
+
${q("good")}
|
|
1363
1363
|
<div class="setup-status-info">
|
|
1364
1364
|
<strong>Internet Access</strong>
|
|
1365
1365
|
<a
|
|
@@ -1381,7 +1381,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1381
1381
|
@click=${e.onTailscaleFunnelDisable}
|
|
1382
1382
|
>${n?"...":"Disable"}</button>
|
|
1383
1383
|
</div>
|
|
1384
|
-
`}function
|
|
1384
|
+
`}function na(e){const t=e>=70?4:e>=50?3:e>=30?2:1;return d`
|
|
1385
1385
|
<span style="display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; vertical-align: middle;">
|
|
1386
1386
|
${[4,7,10,14].map((i,s)=>d`<span style="
|
|
1387
1387
|
width: 3px;
|
|
@@ -1390,9 +1390,9 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1390
1390
|
background: ${s<t?"var(--tasker-accent, #00e5ff)":"rgba(255,255,255,0.15)"};
|
|
1391
1391
|
"></span>`)}
|
|
1392
1392
|
</span>
|
|
1393
|
-
`}function
|
|
1393
|
+
`}function ia(e){if(e.serverPlatform!=="linux")return S;const t=e.wifiStatus,n=e.wifiBusy;if(!t)return d`
|
|
1394
1394
|
<div class="setup-status-item">
|
|
1395
|
-
${
|
|
1395
|
+
${q("unknown")}
|
|
1396
1396
|
<div class="setup-status-info">
|
|
1397
1397
|
<strong>WiFi</strong>
|
|
1398
1398
|
<span>Checking...</span>
|
|
@@ -1400,16 +1400,16 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1400
1400
|
</div>
|
|
1401
1401
|
`;if(!t.available)return d`
|
|
1402
1402
|
<div class="setup-status-item">
|
|
1403
|
-
${
|
|
1403
|
+
${q("unknown")}
|
|
1404
1404
|
<div class="setup-status-info">
|
|
1405
1405
|
<strong>WiFi</strong>
|
|
1406
1406
|
<span>NetworkManager not available</span>
|
|
1407
1407
|
</div>
|
|
1408
1408
|
</div>
|
|
1409
|
-
`;const i=e.wifiNetworks,s=e.wifiSelectedSsid,o=i.length>0,r=!!t.savedSsid&&!t.connected,a=t.connected?"good":"partial",u=t.connected?d`${t.ssid} ${t.signal!=null?d`<span style="margin-left: 4px;">${
|
|
1409
|
+
`;const i=e.wifiNetworks,s=e.wifiSelectedSsid,o=i.length>0,r=!!t.savedSsid&&!t.connected,a=t.connected?"good":"partial",u=t.connected?d`${t.ssid} ${t.signal!=null?d`<span style="margin-left: 4px;">${na(t.signal)}</span>`:S}`:r?d`${t.savedSsid} <span style="opacity: 0.4;">\u2014 reconnecting\u2026</span>`:"Not connected";return d`
|
|
1410
1410
|
<div>
|
|
1411
1411
|
<div class="setup-status-item">
|
|
1412
|
-
${
|
|
1412
|
+
${q(a)}
|
|
1413
1413
|
<div class="setup-status-info">
|
|
1414
1414
|
<strong>WiFi</strong>
|
|
1415
1415
|
<span>${u}</span>
|
|
@@ -1466,7 +1466,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1466
1466
|
</span>
|
|
1467
1467
|
<span style="display: flex; align-items: center; gap: 8px;">
|
|
1468
1468
|
${c.security!=="Open"?d`<span style="opacity: 0.4; font-size: 11px;" title="${c.security}">\uD83D\uDD12</span>`:S}
|
|
1469
|
-
<span title="Signal: ${c.signal}%">${
|
|
1469
|
+
<span title="Signal: ${c.signal}%">${na(c.signal)}</span>
|
|
1470
1470
|
</span>
|
|
1471
1471
|
</button>
|
|
1472
1472
|
`})}
|
|
@@ -1510,7 +1510,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1510
1510
|
</div>
|
|
1511
1511
|
`:S}
|
|
1512
1512
|
</div>
|
|
1513
|
-
`}function
|
|
1513
|
+
`}function If(e){var i,s,o;const t=e.updateRunning,n=e.updateLastResult;if(!t&&!n)return S;if(t)return d`
|
|
1514
1514
|
<div class="setup-info-overlay">
|
|
1515
1515
|
<div class="setup-info-card" style="max-width: 400px;">
|
|
1516
1516
|
<h3>Software Update</h3>
|
|
@@ -1522,7 +1522,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1522
1522
|
${r.status==="running"?d`<span class="setup-update-spinner"></span>`:r.status==="done"?d`<span class="setup-update-icon-ok">${D.check}</span>`:d`<span class="setup-update-icon-fail">${D.x}</span>`}
|
|
1523
1523
|
</span>
|
|
1524
1524
|
<span class="setup-update-step-name">${r.name}</span>
|
|
1525
|
-
${r.durationMs!=null?d`<span class="setup-update-step-time">${
|
|
1525
|
+
${r.durationMs!=null?d`<span class="setup-update-step-time">${sa(r.durationMs)}</span>`:S}
|
|
1526
1526
|
</div>
|
|
1527
1527
|
`)}
|
|
1528
1528
|
</div>
|
|
@@ -1530,7 +1530,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1530
1530
|
${e.updateMessage?d`<p style="text-align: center; color: var(--tasker-text-grey); font-size: 13px; margin: 12px 0 0;">${e.updateMessage}</p>`:S}
|
|
1531
1531
|
</div>
|
|
1532
1532
|
</div>
|
|
1533
|
-
`;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 u=n.durationMs!=null?
|
|
1533
|
+
`;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 u=n.durationMs!=null?sa(n.durationMs):null;return d`
|
|
1534
1534
|
<div class="setup-info-overlay" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onUpdateDismissResult()}}>
|
|
1535
1535
|
<div class="setup-info-card" style="max-width: 360px; text-align: center;">
|
|
1536
1536
|
<div class="setup-update-result-icon ${r?"ok":"fail"}">${r?D.circleCheck:D.circleX}</div>
|
|
@@ -1550,9 +1550,9 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1550
1550
|
</button>
|
|
1551
1551
|
</div>
|
|
1552
1552
|
</div>
|
|
1553
|
-
`}return S}function
|
|
1553
|
+
`}return S}function sa(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 oa(e){const t=e.accountHasPin;return d`
|
|
1554
1554
|
<div class="setup-status-item">
|
|
1555
|
-
${
|
|
1555
|
+
${q(t?"good":"bad")}
|
|
1556
1556
|
<div class="setup-status-info">
|
|
1557
1557
|
<strong>Account PIN</strong>
|
|
1558
1558
|
<span>${t?"Set":"Not set"}</span>
|
|
@@ -1563,7 +1563,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1563
1563
|
@click=${()=>e.onAccountPinModalOpen()}
|
|
1564
1564
|
>${t?"Change":"Set PIN"}</button>
|
|
1565
1565
|
</div>
|
|
1566
|
-
`}function
|
|
1566
|
+
`}function ra(e){if(!e.accountPinModalOpen)return S;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 f;let p=c.querySelector(".pin-modal-validation");p||(p=document.createElement("p"),p.className="login-error pin-modal-validation",(f=c.querySelector("button[type=submit]"))==null||f.before(p)),p.textContent=l},u=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 d`
|
|
1567
1567
|
<div class="setup-info-overlay" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onAccountPinModalClose()}}>
|
|
1568
1568
|
<div class="setup-info-card" style="max-width: 340px;">
|
|
1569
1569
|
<div class="setup-info-header">
|
|
@@ -1620,7 +1620,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1620
1620
|
</form>
|
|
1621
1621
|
</div>
|
|
1622
1622
|
</div>
|
|
1623
|
-
`}function
|
|
1623
|
+
`}function aa(e){if(!e.addingWorkspace)return S;const{workspaceSaving:t}=e;return d`
|
|
1624
1624
|
<div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
|
|
1625
1625
|
<div class="setup-add-account">
|
|
1626
1626
|
<strong>New Account</strong>
|
|
@@ -1673,7 +1673,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1673
1673
|
</div>
|
|
1674
1674
|
</div>
|
|
1675
1675
|
</div>
|
|
1676
|
-
`}function
|
|
1676
|
+
`}function la(e){const t=qt(e);return!t||t.isDefault?S:e.workspaceRemoveConfirm===t.name?d`
|
|
1677
1677
|
<div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 12px;">
|
|
1678
1678
|
<div style="font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
|
|
1679
1679
|
<span style="color: var(--tasker-danger, #ef4444);">Remove "${t.displayName??t.name}" and its WhatsApp account?</span>
|
|
@@ -1702,7 +1702,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1702
1702
|
@click=${i=>{i.preventDefault(),e.onSetWorkspaceRemoveConfirm(t.name)}}
|
|
1703
1703
|
>Remove Account</a>
|
|
1704
1704
|
</p>
|
|
1705
|
-
`}function
|
|
1705
|
+
`}function ca(e){if(e.uninstallDone)return d`
|
|
1706
1706
|
<div style="margin-top: 24px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
|
|
1707
1707
|
<p style="color: var(--tasker-danger, #ef4444); font-size: 13px; font-weight: 600; margin: 0 0 8px 0;">
|
|
1708
1708
|
Taskmaster has been uninstalled.
|
|
@@ -1757,11 +1757,11 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1757
1757
|
@click=${t=>{t.preventDefault(),e.onUninstallConfirm()}}
|
|
1758
1758
|
>Uninstall Taskmaster</a>
|
|
1759
1759
|
</p>
|
|
1760
|
-
`}function
|
|
1760
|
+
`}function ua(){return d`
|
|
1761
1761
|
<p class="setup-hint" style="margin-top: 4px; font-size: 12px; opacity: 0.6;">
|
|
1762
1762
|
Need help? <a href="https://wa.me/447591215452" target="_blank" rel="noopener" style="color: var(--tasker-orange);">Message Dave on WhatsApp</a>
|
|
1763
1763
|
</p>
|
|
1764
|
-
`}function
|
|
1764
|
+
`}function Rf(e){const{whatsappBusy:t,whatsappLoginMessage:n,whatsappLoginQrDataUrl:i,whatsappLoginConnected:s,whatsappChannelStatus:o}=e;if(i)return d`
|
|
1765
1765
|
<div class="setup-container">
|
|
1766
1766
|
<div class="setup-card">
|
|
1767
1767
|
<h1>Scan with WhatsApp</h1>
|
|
@@ -1775,7 +1775,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1775
1775
|
Scan the code above with your phone
|
|
1776
1776
|
</p>`}
|
|
1777
1777
|
<p class="setup-hint" style="margin-top: 16px;">
|
|
1778
|
-
<strong>Important:</strong> If you see "${
|
|
1778
|
+
<strong>Important:</strong> If you see "${ze().name}" in your Linked
|
|
1779
1779
|
Devices, remove it first before scanning.
|
|
1780
1780
|
</p>
|
|
1781
1781
|
<div class="setup-actions" style="margin-top: 24px;">
|
|
@@ -1798,64 +1798,64 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1798
1798
|
`;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?d`
|
|
1799
1799
|
<div class="setup-container">
|
|
1800
1800
|
<div class="setup-card setup-success setup-dashboard-wide">
|
|
1801
|
-
${
|
|
1801
|
+
${qr(e)}
|
|
1802
1802
|
<div class="setup-status-dashboard">
|
|
1803
|
-
${Hr(e)}
|
|
1804
1803
|
${jr(e)}
|
|
1805
|
-
${qr(e)}
|
|
1806
1804
|
${Vr(e)}
|
|
1807
|
-
${
|
|
1808
|
-
${
|
|
1809
|
-
${Yr(e)}
|
|
1805
|
+
${Gr(e)}
|
|
1806
|
+
${Qr(e)}
|
|
1807
|
+
${e.serverPlatform==="darwin"?Yr(e):S}
|
|
1808
|
+
${oa(e)}
|
|
1810
1809
|
${Xr(e)}
|
|
1811
1810
|
${Zr(e)}
|
|
1812
|
-
${
|
|
1813
|
-
${
|
|
1811
|
+
${ea(e)}
|
|
1812
|
+
${Lf(e)}
|
|
1813
|
+
${ia(e)}
|
|
1814
1814
|
</div>
|
|
1815
1815
|
|
|
1816
|
-
${sa(e)}
|
|
1817
|
-
${Jr(e)}
|
|
1818
|
-
${Qr(e)}
|
|
1819
|
-
${oa(e)}
|
|
1820
1816
|
${ra(e)}
|
|
1817
|
+
${ta(e)}
|
|
1818
|
+
${Jr(e)}
|
|
1821
1819
|
${aa(e)}
|
|
1822
|
-
${la()}
|
|
1820
|
+
${la(e)}
|
|
1821
|
+
${ca(e)}
|
|
1822
|
+
${ua()}
|
|
1823
1823
|
${e.workspacesError?d`<p class="setup-error" style="margin-top: 8px;">${e.workspacesError}</p>`:S}
|
|
1824
1824
|
</div>
|
|
1825
1825
|
</div>
|
|
1826
1826
|
`:d`
|
|
1827
1827
|
<div class="setup-container">
|
|
1828
1828
|
<div class="setup-card setup-dashboard-wide">
|
|
1829
|
-
${
|
|
1829
|
+
${qr(e)}
|
|
1830
1830
|
<div class="setup-status-dashboard">
|
|
1831
|
-
${Hr(e)}
|
|
1832
1831
|
${jr(e)}
|
|
1833
|
-
${qr(e)}
|
|
1834
1832
|
${Vr(e)}
|
|
1835
|
-
${
|
|
1836
|
-
${
|
|
1837
|
-
${Yr(e)}
|
|
1833
|
+
${Gr(e)}
|
|
1834
|
+
${Qr(e)}
|
|
1835
|
+
${e.serverPlatform==="darwin"?Yr(e):S}
|
|
1836
|
+
${oa(e)}
|
|
1838
1837
|
${Xr(e)}
|
|
1839
1838
|
${Zr(e)}
|
|
1840
|
-
${
|
|
1839
|
+
${ea(e)}
|
|
1840
|
+
${ia(e)}
|
|
1841
1841
|
</div>
|
|
1842
1842
|
|
|
1843
|
-
${sa(e)}
|
|
1844
|
-
${Jr(e)}
|
|
1845
|
-
${Qr(e)}
|
|
1846
|
-
${oa(e)}
|
|
1847
1843
|
${ra(e)}
|
|
1844
|
+
${ta(e)}
|
|
1845
|
+
${Jr(e)}
|
|
1848
1846
|
${aa(e)}
|
|
1849
|
-
${la()}
|
|
1847
|
+
${la(e)}
|
|
1848
|
+
${ca(e)}
|
|
1849
|
+
${ua()}
|
|
1850
1850
|
${e.workspacesError?d`<p class="setup-error" style="margin-top: 8px;">${e.workspacesError}</p>`:S}
|
|
1851
1851
|
</div>
|
|
1852
1852
|
</div>
|
|
1853
1853
|
`:o?s===!1&&n&&!t?d`
|
|
1854
1854
|
<div class="setup-container">
|
|
1855
1855
|
<div class="setup-card">
|
|
1856
|
-
${
|
|
1856
|
+
${ke("whatsapp")}
|
|
1857
1857
|
<div class="setup-status-row">
|
|
1858
|
-
${
|
|
1858
|
+
${q("bad")}
|
|
1859
1859
|
<span>Connection Failed</span>
|
|
1860
1860
|
</div>
|
|
1861
1861
|
<p class="setup-error">${n}</p>
|
|
@@ -1871,7 +1871,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1871
1871
|
`:d`
|
|
1872
1872
|
<div class="setup-container">
|
|
1873
1873
|
<div class="setup-card">
|
|
1874
|
-
${
|
|
1874
|
+
${ke("whatsapp")}
|
|
1875
1875
|
${n?d`<p class="setup-error">${n}</p>`:d`<div class="setup-spinner"></div>
|
|
1876
1876
|
<p>Preparing...</p>`}
|
|
1877
1877
|
</div>
|
|
@@ -1879,7 +1879,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1879
1879
|
`:d`
|
|
1880
1880
|
<div class="setup-container">
|
|
1881
1881
|
<div class="setup-card">
|
|
1882
|
-
${
|
|
1882
|
+
${ke("whatsapp")}
|
|
1883
1883
|
<div class="setup-spinner"></div>
|
|
1884
1884
|
<p>Checking connection status...</p>
|
|
1885
1885
|
<button
|
|
@@ -1891,7 +1891,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1891
1891
|
</button>
|
|
1892
1892
|
</div>
|
|
1893
1893
|
</div>
|
|
1894
|
-
`}function
|
|
1894
|
+
`}function Df(e){const{connected:t,currentStep:n}=e;if(t&&gi()&&Lo(),e.uninstallDone||!t&&gi())return d`
|
|
1895
1895
|
<div class="setup-container">
|
|
1896
1896
|
<div class="setup-card">
|
|
1897
1897
|
<p style="color: var(--tasker-danger, #ef4444); font-size: 16px; font-weight: 600; margin: 0 0 12px 0;">
|
|
@@ -1914,7 +1914,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1914
1914
|
<p>${o?"Restarting gateway after update…":"Connecting to gateway..."}</p>
|
|
1915
1915
|
</div>
|
|
1916
1916
|
</div>
|
|
1917
|
-
`}let i;switch(n){case"license":i=
|
|
1917
|
+
`}let i;switch(n){case"license":i=Hr(e);break;case"auth":i=xf(e);break;case"whatsapp":case"complete":i=Rf(e);break;default:i=Hr(e)}const s=kt("Setup",e.wsProps);return d`${i}${$f(e)}${_f(e)}${Tf(e)}${If(e)}${s}`}function Bf(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return d`
|
|
1918
1918
|
<div class="sp-list-item">
|
|
1919
1919
|
<div class="sp-list-item-main">
|
|
1920
1920
|
<div class="sp-list-item-title">${e.phone}</div>
|
|
@@ -1929,7 +1929,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1929
1929
|
Remove
|
|
1930
1930
|
</button>`}
|
|
1931
1931
|
</div>
|
|
1932
|
-
`}function
|
|
1932
|
+
`}function Nf(e){if(!e.connected)return d`
|
|
1933
1933
|
<div class="setup-container">
|
|
1934
1934
|
<div class="setup-card">
|
|
1935
1935
|
<div class="setup-spinner"></div>
|
|
@@ -1938,7 +1938,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1938
1938
|
</div>
|
|
1939
1939
|
`;const t=n=>{n.preventDefault(),e.newPhone.trim()&&e.onAdd(e.newPhone)};return d`
|
|
1940
1940
|
<div class="setup-container">
|
|
1941
|
-
${
|
|
1941
|
+
${kt("Admins",e.wsProps)}
|
|
1942
1942
|
<div class="setup-card" style="max-width: 520px;">
|
|
1943
1943
|
<h1>Admin Phones</h1>
|
|
1944
1944
|
<p style="margin-bottom: 16px;">
|
|
@@ -1978,7 +1978,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1978
1978
|
</form>
|
|
1979
1979
|
|
|
1980
1980
|
<div class="sp-list" style="margin-top: 20px;">
|
|
1981
|
-
${e.phones.length===0?d`<div class="sp-list-empty">No admin phones configured yet.</div>`:e.phones.map(n=>
|
|
1981
|
+
${e.phones.length===0?d`<div class="sp-list-empty">No admin phones configured yet.</div>`:e.phones.map(n=>Bf(n,e))}
|
|
1982
1982
|
</div>
|
|
1983
1983
|
|
|
1984
1984
|
<div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
|
|
@@ -1989,7 +1989,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
1989
1989
|
|
|
1990
1990
|
</div>
|
|
1991
1991
|
</div>
|
|
1992
|
-
`}function
|
|
1992
|
+
`}function Of(e){return Object.keys(e.fields).length}function Ff(e,t){const n=Object.entries(e.fields);return d`
|
|
1993
1993
|
<div class="contacts-record-fields">
|
|
1994
1994
|
${n.length===0?d`<div style="color: rgba(255,255,255,0.4); font-size: 13px; margin-top: 12px;">No fields yet. Add one below.</div>`:n.map(([i,s])=>d`
|
|
1995
1995
|
<div class="contacts-field-row">
|
|
@@ -2036,7 +2036,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
2036
2036
|
</button>
|
|
2037
2037
|
</div>
|
|
2038
2038
|
</div>
|
|
2039
|
-
`}function
|
|
2039
|
+
`}function Uf(e,t){const n=t.editingId===e.id,i=Of(e),s=i===0?"No fields":`${i} field${i>1?"s":""}`;return d`
|
|
2040
2040
|
<div class="contacts-record">
|
|
2041
2041
|
<div
|
|
2042
2042
|
class="contacts-record-header"
|
|
@@ -2048,9 +2048,9 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
2048
2048
|
</div>
|
|
2049
2049
|
<span class="contacts-record-meta">${s}</span>
|
|
2050
2050
|
</div>
|
|
2051
|
-
${n?
|
|
2051
|
+
${n?Ff(e,t):S}
|
|
2052
2052
|
</div>
|
|
2053
|
-
`}function
|
|
2053
|
+
`}function Wf(e){if(!e.connected)return d`
|
|
2054
2054
|
<div class="setup-container">
|
|
2055
2055
|
<div class="setup-card">
|
|
2056
2056
|
<div class="setup-spinner"></div>
|
|
@@ -2059,7 +2059,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
2059
2059
|
</div>
|
|
2060
2060
|
`;const t=i=>{i.preventDefault(),e.onSearchSubmit()},n=i=>{i.preventDefault(),e.newRecordPhone.trim()&&e.newRecordName.trim()&&e.onAdd(e.newRecordPhone,e.newRecordName)};return d`
|
|
2061
2061
|
<div class="setup-container">
|
|
2062
|
-
${
|
|
2062
|
+
${kt("Contacts",e.wsProps)}
|
|
2063
2063
|
<div class="setup-card" style="max-width: 620px;">
|
|
2064
2064
|
<h1>Contact Records</h1>
|
|
2065
2065
|
<p style="margin-bottom: 16px;">
|
|
@@ -2146,7 +2146,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
2146
2146
|
<div style="margin-top: 16px;">
|
|
2147
2147
|
${e.records.length===0?d`<div class="contacts-empty">
|
|
2148
2148
|
${e.searchQuery.trim()?`No records matching "${e.searchQuery}".`:"No contact records yet. Add one to get started."}
|
|
2149
|
-
</div>`:e.records.map(i=>
|
|
2149
|
+
</div>`:e.records.map(i=>Uf(i,e))}
|
|
2150
2150
|
</div>
|
|
2151
2151
|
|
|
2152
2152
|
<div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
|
|
@@ -2157,13 +2157,13 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=pn(t.messa
|
|
|
2157
2157
|
</div>
|
|
2158
2158
|
</div>
|
|
2159
2159
|
</div>
|
|
2160
|
-
`}const Nc={CHILD:2},Bc=e=>(...t)=>({_$litDirective$:e,values:t});let Oc=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:Ff}=Ad,ca=e=>e,ua=()=>document.createComment(""),Yt=(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 Ff(r,a,e,e.options)}else{const r=n._$AB.nextSibling,a=n._$AM,u=a!==e;if(u){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||u){let c=n._$AA;for(;c!==r;){const l=ca(c).nextSibling;ca(i).insertBefore(c,s),c=l}}}return n},at=(e,t,n=e)=>(e._$AI(t,n),e),Uf={},Wf=(e,t=Uf)=>e._$AH=t,Kf=e=>e._$AH,ls=e=>{e._$AR(),e._$AA.remove()};const da=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},zf=Bc(class extends Oc{constructor(e){if(super(e),e.type!==Nc.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=Kf(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=[]),u=[];let c,l,p=0,f=s.length-1,b=0,h=o.length-1;for(;p<=f&&b<=h;)if(s[p]===null)p++;else if(s[f]===null)f--;else if(a[p]===r[b])u[b]=at(s[p],o[b]),p++,b++;else if(a[f]===r[h])u[h]=at(s[f],o[h]),f--,h--;else if(a[p]===r[h])u[h]=at(s[p],o[h]),Yt(e,u[h+1],s[p]),p++,h--;else if(a[f]===r[b])u[b]=at(s[f],o[b]),Yt(e,s[p],s[f]),f--,b++;else if(c===void 0&&(c=da(r,b,h),l=da(a,p,f)),c.has(a[p]))if(c.has(a[f])){const v=l.get(r[b]),k=v!==void 0?s[v]:null;if(k===null){const $=Yt(e,s[p]);at($,o[b]),u[b]=$}else u[b]=at(k,o[b]),Yt(e,s[p],k),s[v]=null;b++}else ls(s[f]),f--;else ls(s[p]),p++;for(;b<=h;){const v=Yt(e,u[h+1]);at(v,o[b]),u[b++]=v}for(;p<=f;){const v=s[p++];v!==null&&ls(v)}return this.ut=r,Wf(e,u),Je}});class Us extends Oc{constructor(t){if(super(t),this.it=S,t.type!==Nc.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===S||t==null)return this._t=void 0,this.it=t;if(t===Je)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:[]}}}Us.directiveName="unsafeHTML",Us.resultType=1;const fi=Bc(Us);const{entries:Fc,setPrototypeOf:pa,isFrozen:Hf,getPrototypeOf:jf,getOwnPropertyDescriptor:qf}=Object;let{freeze:pe,seal:ge,create:Ws}=Object,{apply:Ks,construct:zs}=typeof Reflect<"u"&&Reflect;pe||(pe=function(t){return t});ge||(ge=function(t){return t});Ks||(Ks=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)});zs||(zs=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 zn=he(Array.prototype.forEach),Vf=he(Array.prototype.lastIndexOf),ha=he(Array.prototype.pop),Xt=he(Array.prototype.push),Gf=he(Array.prototype.splice),ei=he(String.prototype.toLowerCase),cs=he(String.prototype.toString),us=he(String.prototype.match),Zt=he(String.prototype.replace),Qf=he(String.prototype.indexOf),Yf=he(String.prototype.trim),ye=he(Object.prototype.hasOwnProperty),ce=he(RegExp.prototype.test),Jt=Xf(TypeError);function he(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 Ks(e,t,i)}}function Xf(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return zs(e,n)}}function F(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ei;pa&&pa(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(Hf(t)||(t[i]=o),s=o)}e[s]=!0}return e}function Zf(e){for(let t=0;t<e.length;t++)ye(e,t)||(e[t]=null);return e}function Ce(e){const t=Ws(null);for(const[n,i]of Fc(e))ye(e,n)&&(Array.isArray(i)?t[n]=Zf(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=Ce(i):t[n]=i);return t}function en(e,t){for(;e!==null;){const i=qf(e,t);if(i){if(i.get)return he(i.get);if(typeof i.value=="function")return he(i.value)}e=jf(e)}function n(){return null}return n}const fa=pe(["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"]),ds=pe(["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"]),ps=pe(["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"]),Jf=pe(["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"]),hs=pe(["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"]),eg=pe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ga=pe(["#text"]),ma=pe(["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"]),fs=pe(["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"]),ya=pe(["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"]),Hn=pe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),tg=ge(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ng=ge(/<%[\w\W]*|[\w\W]*%>/gm),ig=ge(/\$\{[\w\W]*/gm),sg=ge(/^data-[\-\w.\u00B7-\uFFFF]+$/),og=ge(/^aria-[\-\w]+$/),Uc=ge(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),rg=ge(/^(?:\w+script|data):/i),ag=ge(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Wc=ge(/^html$/i),lg=ge(/^[a-z][.\w]*(-[.\w]+)+$/i);var va=Object.freeze({__proto__:null,ARIA_ATTR:og,ATTR_WHITESPACE:ag,CUSTOM_ELEMENT:lg,DATA_ATTR:sg,DOCTYPE_NAME:Wc,ERB_EXPR:ng,IS_ALLOWED_URI:Uc,IS_SCRIPT_OR_DATA:rg,MUSTACHE_EXPR:tg,TMPLIT_EXPR:ig});const tn={element:1,text:3,progressingInstruction:7,comment:8,document:9},cg=function(){return typeof window>"u"?null:window},ug=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}},ba=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Kc(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:cg();const t=I=>Kc(I);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==tn.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:u,NodeFilter:c,NamedNodeMap:l=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:f,trustedTypes:b}=e,h=u.prototype,v=en(h,"cloneNode"),k=en(h,"remove"),$=en(h,"nextSibling"),A=en(h,"childNodes"),C=en(h,"parentNode");if(typeof r=="function"){const I=n.createElement("template");I.content&&I.content.ownerDocument&&(n=I.content.ownerDocument)}let T,_="";const{implementation:R,createNodeIterator:O,createDocumentFragment:ee,getElementsByTagName:me}=n,{importNode:qe}=i;let Z=ba();t.isSupported=typeof Fc=="function"&&typeof C=="function"&&R&&R.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:jt,ERB_EXPR:$t,TMPLIT_EXPR:nt,DATA_ATTR:Bi,ARIA_ATTR:Oi,IS_SCRIPT_OR_DATA:Fi,ATTR_WHITESPACE:An,CUSTOM_ELEMENT:Ui}=va;let{IS_ALLOWED_URI:En}=va,Q=null;const Cn=F({},[...fa,...ds,...ps,...hs,...ga]);let Y=null;const Tn=F({},[...ma,...fs,...ya,...Hn]);let q=Object.seal(Ws(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}})),it=null,qt=null;const Ve=Object.seal(Ws(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let _n=!0,x=!0,M=!1,N=!0,B=!1,V=!0,z=!1,le=!1,Ge=!1,xt=!1,Mn=!1,Pn=!1,Zo=!0,Jo=!1;const Gu="user-content-";let Wi=!0,Vt=!1,At={},$e=null;const Ki=F({},["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 er=null;const tr=F({},["audio","video","img","source","image","track"]);let zi=null;const nr=F({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ln="http://www.w3.org/1998/Math/MathML",In="http://www.w3.org/2000/svg",Re="http://www.w3.org/1999/xhtml";let Et=Re,Hi=!1,ji=null;const Qu=F({},[Ln,In,Re],cs);let Rn=F({},["mi","mo","mn","ms","mtext"]),Dn=F({},["annotation-xml"]);const Yu=F({},["title","style","font","a","script"]);let Gt=null;const Xu=["application/xhtml+xml","text/html"],Zu="text/html";let J=null,Ct=null;const Ju=n.createElement("form"),ir=function(w){return w instanceof RegExp||w instanceof Function},qi=function(){let w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ct&&Ct===w)){if((!w||typeof w!="object")&&(w={}),w=Ce(w),Gt=Xu.indexOf(w.PARSER_MEDIA_TYPE)===-1?Zu:w.PARSER_MEDIA_TYPE,J=Gt==="application/xhtml+xml"?cs:ei,Q=ye(w,"ALLOWED_TAGS")?F({},w.ALLOWED_TAGS,J):Cn,Y=ye(w,"ALLOWED_ATTR")?F({},w.ALLOWED_ATTR,J):Tn,ji=ye(w,"ALLOWED_NAMESPACES")?F({},w.ALLOWED_NAMESPACES,cs):Qu,zi=ye(w,"ADD_URI_SAFE_ATTR")?F(Ce(nr),w.ADD_URI_SAFE_ATTR,J):nr,er=ye(w,"ADD_DATA_URI_TAGS")?F(Ce(tr),w.ADD_DATA_URI_TAGS,J):tr,$e=ye(w,"FORBID_CONTENTS")?F({},w.FORBID_CONTENTS,J):Ki,it=ye(w,"FORBID_TAGS")?F({},w.FORBID_TAGS,J):Ce({}),qt=ye(w,"FORBID_ATTR")?F({},w.FORBID_ATTR,J):Ce({}),At=ye(w,"USE_PROFILES")?w.USE_PROFILES:!1,_n=w.ALLOW_ARIA_ATTR!==!1,x=w.ALLOW_DATA_ATTR!==!1,M=w.ALLOW_UNKNOWN_PROTOCOLS||!1,N=w.ALLOW_SELF_CLOSE_IN_ATTR!==!1,B=w.SAFE_FOR_TEMPLATES||!1,V=w.SAFE_FOR_XML!==!1,z=w.WHOLE_DOCUMENT||!1,xt=w.RETURN_DOM||!1,Mn=w.RETURN_DOM_FRAGMENT||!1,Pn=w.RETURN_TRUSTED_TYPE||!1,Ge=w.FORCE_BODY||!1,Zo=w.SANITIZE_DOM!==!1,Jo=w.SANITIZE_NAMED_PROPS||!1,Wi=w.KEEP_CONTENT!==!1,Vt=w.IN_PLACE||!1,En=w.ALLOWED_URI_REGEXP||Uc,Et=w.NAMESPACE||Re,Rn=w.MATHML_TEXT_INTEGRATION_POINTS||Rn,Dn=w.HTML_INTEGRATION_POINTS||Dn,q=w.CUSTOM_ELEMENT_HANDLING||{},w.CUSTOM_ELEMENT_HANDLING&&ir(w.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(q.tagNameCheck=w.CUSTOM_ELEMENT_HANDLING.tagNameCheck),w.CUSTOM_ELEMENT_HANDLING&&ir(w.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(q.attributeNameCheck=w.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),w.CUSTOM_ELEMENT_HANDLING&&typeof w.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(q.allowCustomizedBuiltInElements=w.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),B&&(x=!1),Mn&&(xt=!0),At&&(Q=F({},ga),Y=[],At.html===!0&&(F(Q,fa),F(Y,ma)),At.svg===!0&&(F(Q,ds),F(Y,fs),F(Y,Hn)),At.svgFilters===!0&&(F(Q,ps),F(Y,fs),F(Y,Hn)),At.mathMl===!0&&(F(Q,hs),F(Y,ya),F(Y,Hn))),w.ADD_TAGS&&(typeof w.ADD_TAGS=="function"?Ve.tagCheck=w.ADD_TAGS:(Q===Cn&&(Q=Ce(Q)),F(Q,w.ADD_TAGS,J))),w.ADD_ATTR&&(typeof w.ADD_ATTR=="function"?Ve.attributeCheck=w.ADD_ATTR:(Y===Tn&&(Y=Ce(Y)),F(Y,w.ADD_ATTR,J))),w.ADD_URI_SAFE_ATTR&&F(zi,w.ADD_URI_SAFE_ATTR,J),w.FORBID_CONTENTS&&($e===Ki&&($e=Ce($e)),F($e,w.FORBID_CONTENTS,J)),w.ADD_FORBID_CONTENTS&&($e===Ki&&($e=Ce($e)),F($e,w.ADD_FORBID_CONTENTS,J)),Wi&&(Q["#text"]=!0),z&&F(Q,["html","head","body"]),Q.table&&(F(Q,["tbody"]),delete it.tbody),w.TRUSTED_TYPES_POLICY){if(typeof w.TRUSTED_TYPES_POLICY.createHTML!="function")throw Jt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof w.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Jt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');T=w.TRUSTED_TYPES_POLICY,_=T.createHTML("")}else T===void 0&&(T=ug(b,s)),T!==null&&typeof _=="string"&&(_=T.createHTML(""));pe&&pe(w),Ct=w}},sr=F({},[...ds,...ps,...Jf]),or=F({},[...hs,...eg]),ed=function(w){let E=C(w);(!E||!E.tagName)&&(E={namespaceURI:Et,tagName:"template"});const L=ei(w.tagName),H=ei(E.tagName);return ji[w.namespaceURI]?w.namespaceURI===In?E.namespaceURI===Re?L==="svg":E.namespaceURI===Ln?L==="svg"&&(H==="annotation-xml"||Rn[H]):!!sr[L]:w.namespaceURI===Ln?E.namespaceURI===Re?L==="math":E.namespaceURI===In?L==="math"&&Dn[H]:!!or[L]:w.namespaceURI===Re?E.namespaceURI===In&&!Dn[H]||E.namespaceURI===Ln&&!Rn[H]?!1:!or[L]&&(Yu[L]||!sr[L]):!!(Gt==="application/xhtml+xml"&&ji[w.namespaceURI]):!1},xe=function(w){Xt(t.removed,{element:w});try{C(w).removeChild(w)}catch{k(w)}},st=function(w,E){try{Xt(t.removed,{attribute:E.getAttributeNode(w),from:E})}catch{Xt(t.removed,{attribute:null,from:E})}if(E.removeAttribute(w),w==="is")if(xt||Mn)try{xe(E)}catch{}else try{E.setAttribute(w,"")}catch{}},rr=function(w){let E=null,L=null;if(Ge)w="<remove></remove>"+w;else{const X=us(w,/^[\r\n\t ]+/);L=X&&X[0]}Gt==="application/xhtml+xml"&&Et===Re&&(w='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+w+"</body></html>");const H=T?T.createHTML(w):w;if(Et===Re)try{E=new f().parseFromString(H,Gt)}catch{}if(!E||!E.documentElement){E=R.createDocument(Et,"template",null);try{E.documentElement.innerHTML=Hi?_:H}catch{}}const se=E.body||E.documentElement;return w&&L&&se.insertBefore(n.createTextNode(L),se.childNodes[0]||null),Et===Re?me.call(E,z?"html":"body")[0]:z?E.documentElement:se},ar=function(w){return O.call(w.ownerDocument||w,w,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Vi=function(w){return w instanceof p&&(typeof w.nodeName!="string"||typeof w.textContent!="string"||typeof w.removeChild!="function"||!(w.attributes instanceof l)||typeof w.removeAttribute!="function"||typeof w.setAttribute!="function"||typeof w.namespaceURI!="string"||typeof w.insertBefore!="function"||typeof w.hasChildNodes!="function")},lr=function(w){return typeof a=="function"&&w instanceof a};function De(I,w,E){zn(I,L=>{L.call(t,w,E,Ct)})}const cr=function(w){let E=null;if(De(Z.beforeSanitizeElements,w,null),Vi(w))return xe(w),!0;const L=J(w.nodeName);if(De(Z.uponSanitizeElement,w,{tagName:L,allowedTags:Q}),V&&w.hasChildNodes()&&!lr(w.firstElementChild)&&ce(/<[/\w!]/g,w.innerHTML)&&ce(/<[/\w!]/g,w.textContent)||w.nodeType===tn.progressingInstruction||V&&w.nodeType===tn.comment&&ce(/<[/\w]/g,w.data))return xe(w),!0;if(!(Ve.tagCheck instanceof Function&&Ve.tagCheck(L))&&(!Q[L]||it[L])){if(!it[L]&&dr(L)&&(q.tagNameCheck instanceof RegExp&&ce(q.tagNameCheck,L)||q.tagNameCheck instanceof Function&&q.tagNameCheck(L)))return!1;if(Wi&&!$e[L]){const H=C(w)||w.parentNode,se=A(w)||w.childNodes;if(se&&H){const X=se.length;for(let fe=X-1;fe>=0;--fe){const Ne=v(se[fe],!0);Ne.__removalCount=(w.__removalCount||0)+1,H.insertBefore(Ne,$(w))}}}return xe(w),!0}return w instanceof u&&!ed(w)||(L==="noscript"||L==="noembed"||L==="noframes")&&ce(/<\/no(script|embed|frames)/i,w.innerHTML)?(xe(w),!0):(B&&w.nodeType===tn.text&&(E=w.textContent,zn([jt,$t,nt],H=>{E=Zt(E,H," ")}),w.textContent!==E&&(Xt(t.removed,{element:w.cloneNode()}),w.textContent=E)),De(Z.afterSanitizeElements,w,null),!1)},ur=function(w,E,L){if(Zo&&(E==="id"||E==="name")&&(L in n||L in Ju))return!1;if(!(x&&!qt[E]&&ce(Bi,E))){if(!(_n&&ce(Oi,E))){if(!(Ve.attributeCheck instanceof Function&&Ve.attributeCheck(E,w))){if(!Y[E]||qt[E]){if(!(dr(w)&&(q.tagNameCheck instanceof RegExp&&ce(q.tagNameCheck,w)||q.tagNameCheck instanceof Function&&q.tagNameCheck(w))&&(q.attributeNameCheck instanceof RegExp&&ce(q.attributeNameCheck,E)||q.attributeNameCheck instanceof Function&&q.attributeNameCheck(E,w))||E==="is"&&q.allowCustomizedBuiltInElements&&(q.tagNameCheck instanceof RegExp&&ce(q.tagNameCheck,L)||q.tagNameCheck instanceof Function&&q.tagNameCheck(L))))return!1}else if(!zi[E]){if(!ce(En,Zt(L,An,""))){if(!((E==="src"||E==="xlink:href"||E==="href")&&w!=="script"&&Qf(L,"data:")===0&&er[w])){if(!(M&&!ce(Fi,Zt(L,An,"")))){if(L)return!1}}}}}}}return!0},dr=function(w){return w!=="annotation-xml"&&us(w,Ui)},pr=function(w){De(Z.beforeSanitizeAttributes,w,null);const{attributes:E}=w;if(!E||Vi(w))return;const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Y,forceKeepAttr:void 0};let H=E.length;for(;H--;){const se=E[H],{name:X,namespaceURI:fe,value:Ne}=se,Tt=J(X),Gi=Ne;let ne=X==="value"?Gi:Yf(Gi);if(L.attrName=Tt,L.attrValue=ne,L.keepAttr=!0,L.forceKeepAttr=void 0,De(Z.uponSanitizeAttribute,w,L),ne=L.attrValue,Jo&&(Tt==="id"||Tt==="name")&&(st(X,w),ne=Gu+ne),V&&ce(/((--!?|])>)|<\/(style|title|textarea)/i,ne)){st(X,w);continue}if(Tt==="attributename"&&us(ne,"href")){st(X,w);continue}if(L.forceKeepAttr)continue;if(!L.keepAttr){st(X,w);continue}if(!N&&ce(/\/>/i,ne)){st(X,w);continue}B&&zn([jt,$t,nt],fr=>{ne=Zt(ne,fr," ")});const hr=J(w.nodeName);if(!ur(hr,Tt,ne)){st(X,w);continue}if(T&&typeof b=="object"&&typeof b.getAttributeType=="function"&&!fe)switch(b.getAttributeType(hr,Tt)){case"TrustedHTML":{ne=T.createHTML(ne);break}case"TrustedScriptURL":{ne=T.createScriptURL(ne);break}}if(ne!==Gi)try{fe?w.setAttributeNS(fe,X,ne):w.setAttribute(X,ne),Vi(w)?xe(w):ha(t.removed)}catch{st(X,w)}}De(Z.afterSanitizeAttributes,w,null)},td=function I(w){let E=null;const L=ar(w);for(De(Z.beforeSanitizeShadowDOM,w,null);E=L.nextNode();)De(Z.uponSanitizeShadowNode,E,null),cr(E),pr(E),E.content instanceof o&&I(E.content);De(Z.afterSanitizeShadowDOM,w,null)};return t.sanitize=function(I){let w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=null,L=null,H=null,se=null;if(Hi=!I,Hi&&(I="<!-->"),typeof I!="string"&&!lr(I))if(typeof I.toString=="function"){if(I=I.toString(),typeof I!="string")throw Jt("dirty is not a string, aborting")}else throw Jt("toString is not a function");if(!t.isSupported)return I;if(le||qi(w),t.removed=[],typeof I=="string"&&(Vt=!1),Vt){if(I.nodeName){const Ne=J(I.nodeName);if(!Q[Ne]||it[Ne])throw Jt("root node is forbidden and cannot be sanitized in-place")}}else if(I instanceof a)E=rr("<!---->"),L=E.ownerDocument.importNode(I,!0),L.nodeType===tn.element&&L.nodeName==="BODY"||L.nodeName==="HTML"?E=L:E.appendChild(L);else{if(!xt&&!B&&!z&&I.indexOf("<")===-1)return T&&Pn?T.createHTML(I):I;if(E=rr(I),!E)return xt?null:Pn?_:""}E&&Ge&&xe(E.firstChild);const X=ar(Vt?I:E);for(;H=X.nextNode();)cr(H),pr(H),H.content instanceof o&&td(H.content);if(Vt)return I;if(xt){if(Mn)for(se=ee.call(E.ownerDocument);E.firstChild;)se.appendChild(E.firstChild);else se=E;return(Y.shadowroot||Y.shadowrootmode)&&(se=qe.call(i,se,!0)),se}let fe=z?E.outerHTML:E.innerHTML;return z&&Q["!doctype"]&&E.ownerDocument&&E.ownerDocument.doctype&&E.ownerDocument.doctype.name&&ce(Wc,E.ownerDocument.doctype.name)&&(fe="<!DOCTYPE "+E.ownerDocument.doctype.name+`>
|
|
2161
|
-
`+fe),
|
|
2162
|
-
]`).replace("lheading",
|
|
2160
|
+
`}const Fc={CHILD:2},Uc=e=>(...t)=>({_$litDirective$:e,values:t});let Wc=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:Kf}=Td,da=e=>e,pa=()=>document.createComment(""),Xt=(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(pa(),s),a=i.insertBefore(pa(),s);n=new Kf(r,a,e,e.options)}else{const r=n._$AB.nextSibling,a=n._$AM,u=a!==e;if(u){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||u){let c=n._$AA;for(;c!==r;){const l=da(c).nextSibling;da(i).insertBefore(c,s),c=l}}}return n},lt=(e,t,n=e)=>(e._$AI(t,n),e),zf={},Hf=(e,t=zf)=>e._$AH=t,qf=e=>e._$AH,cs=e=>{e._$AR(),e._$AA.remove()};const ha=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},jf=Uc(class extends Wc{constructor(e){if(super(e),e.type!==Fc.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=qf(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=[]),u=[];let c,l,p=0,f=s.length-1,b=0,h=o.length-1;for(;p<=f&&b<=h;)if(s[p]===null)p++;else if(s[f]===null)f--;else if(a[p]===r[b])u[b]=lt(s[p],o[b]),p++,b++;else if(a[f]===r[h])u[h]=lt(s[f],o[h]),f--,h--;else if(a[p]===r[h])u[h]=lt(s[p],o[h]),Xt(e,u[h+1],s[p]),p++,h--;else if(a[f]===r[b])u[b]=lt(s[f],o[b]),Xt(e,s[p],s[f]),f--,b++;else if(c===void 0&&(c=ha(r,b,h),l=ha(a,p,f)),c.has(a[p]))if(c.has(a[f])){const v=l.get(r[b]),k=v!==void 0?s[v]:null;if(k===null){const $=Xt(e,s[p]);lt($,o[b]),u[b]=$}else u[b]=lt(k,o[b]),Xt(e,s[p],k),s[v]=null;b++}else cs(s[f]),f--;else cs(s[p]),p++;for(;b<=h;){const v=Xt(e,u[h+1]);lt(v,o[b]),u[b++]=v}for(;p<=f;){const v=s[p++];v!==null&&cs(v)}return this.ut=r,Hf(e,u),et}});class Ws extends Wc{constructor(t){if(super(t),this.it=S,t.type!==Fc.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===S||t==null)return this._t=void 0,this.it=t;if(t===et)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:[]}}}Ws.directiveName="unsafeHTML",Ws.resultType=1;const mi=Uc(Ws);const{entries:Kc,setPrototypeOf:fa,isFrozen:Vf,getPrototypeOf:Gf,getOwnPropertyDescriptor:Qf}=Object;let{freeze:pe,seal:me,create:Ks}=Object,{apply:zs,construct:Hs}=typeof Reflect<"u"&&Reflect;pe||(pe=function(t){return t});me||(me=function(t){return t});zs||(zs=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)});Hs||(Hs=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 qn=he(Array.prototype.forEach),Yf=he(Array.prototype.lastIndexOf),ga=he(Array.prototype.pop),Zt=he(Array.prototype.push),Jf=he(Array.prototype.splice),ni=he(String.prototype.toLowerCase),us=he(String.prototype.toString),ds=he(String.prototype.match),en=he(String.prototype.replace),Xf=he(String.prototype.indexOf),Zf=he(String.prototype.trim),ve=he(Object.prototype.hasOwnProperty),ce=he(RegExp.prototype.test),tn=eg(TypeError);function he(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 zs(e,t,i)}}function eg(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Hs(e,n)}}function F(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ni;fa&&fa(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(Vf(t)||(t[i]=o),s=o)}e[s]=!0}return e}function tg(e){for(let t=0;t<e.length;t++)ve(e,t)||(e[t]=null);return e}function Te(e){const t=Ks(null);for(const[n,i]of Kc(e))ve(e,n)&&(Array.isArray(i)?t[n]=tg(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=Te(i):t[n]=i);return t}function nn(e,t){for(;e!==null;){const i=Qf(e,t);if(i){if(i.get)return he(i.get);if(typeof i.value=="function")return he(i.value)}e=Gf(e)}function n(){return null}return n}const ma=pe(["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"]),ps=pe(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),hs=pe(["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"]),ng=pe(["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"]),fs=pe(["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"]),ig=pe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ya=pe(["#text"]),va=pe(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),gs=pe(["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"]),ba=pe(["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"]),jn=pe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),sg=me(/\{\{[\w\W]*|[\w\W]*\}\}/gm),og=me(/<%[\w\W]*|[\w\W]*%>/gm),rg=me(/\$\{[\w\W]*/gm),ag=me(/^data-[\-\w.\u00B7-\uFFFF]+$/),lg=me(/^aria-[\-\w]+$/),zc=me(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),cg=me(/^(?:\w+script|data):/i),ug=me(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Hc=me(/^html$/i),dg=me(/^[a-z][.\w]*(-[.\w]+)+$/i);var wa=Object.freeze({__proto__:null,ARIA_ATTR:lg,ATTR_WHITESPACE:ug,CUSTOM_ELEMENT:dg,DATA_ATTR:ag,DOCTYPE_NAME:Hc,ERB_EXPR:og,IS_ALLOWED_URI:zc,IS_SCRIPT_OR_DATA:cg,MUSTACHE_EXPR:sg,TMPLIT_EXPR:rg});const sn={element:1,text:3,progressingInstruction:7,comment:8,document:9},pg=function(){return typeof window>"u"?null:window},hg=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}},ka=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function qc(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:pg();const t=I=>qc(I);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==sn.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:u,NodeFilter:c,NamedNodeMap:l=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:f,trustedTypes:b}=e,h=u.prototype,v=nn(h,"cloneNode"),k=nn(h,"remove"),$=nn(h,"nextSibling"),A=nn(h,"childNodes"),C=nn(h,"parentNode");if(typeof r=="function"){const I=n.createElement("template");I.content&&I.content.ownerDocument&&(n=I.content.ownerDocument)}let T,_="";const{implementation:R,createNodeIterator:O,createDocumentFragment:ee,getElementsByTagName:ye}=n,{importNode:Ve}=i;let X=ka();t.isSupported=typeof Kc=="function"&&typeof C=="function"&&R&&R.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Vt,ERB_EXPR:xt,TMPLIT_EXPR:it,DATA_ATTR:Oi,ARIA_ATTR:Fi,IS_SCRIPT_OR_DATA:Ui,ATTR_WHITESPACE:Cn,CUSTOM_ELEMENT:Wi}=wa;let{IS_ALLOWED_URI:Tn}=wa,Q=null;const _n=F({},[...ma,...ps,...hs,...fs,...ya]);let Y=null;const Mn=F({},[...va,...gs,...ba,...jn]);let j=Object.seal(Ks(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}})),st=null,Gt=null;const Ge=Object.seal(Ks(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Pn=!0,x=!0,M=!1,B=!0,N=!1,V=!0,z=!1,le=!1,Qe=!1,At=!1,Ln=!1,In=!1,er=!0,tr=!1;const Ju="user-content-";let Ki=!0,Qt=!1,Et={},xe=null;const zi=F({},["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 nr=null;const ir=F({},["audio","video","img","source","image","track"]);let Hi=null;const sr=F({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Rn="http://www.w3.org/1998/Math/MathML",Dn="http://www.w3.org/2000/svg",De="http://www.w3.org/1999/xhtml";let Ct=De,qi=!1,ji=null;const Xu=F({},[Rn,Dn,De],us);let Bn=F({},["mi","mo","mn","ms","mtext"]),Nn=F({},["annotation-xml"]);const Zu=F({},["title","style","font","a","script"]);let Yt=null;const ed=["application/xhtml+xml","text/html"],td="text/html";let Z=null,Tt=null;const nd=n.createElement("form"),or=function(w){return w instanceof RegExp||w instanceof Function},Vi=function(){let w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Tt&&Tt===w)){if((!w||typeof w!="object")&&(w={}),w=Te(w),Yt=ed.indexOf(w.PARSER_MEDIA_TYPE)===-1?td:w.PARSER_MEDIA_TYPE,Z=Yt==="application/xhtml+xml"?us:ni,Q=ve(w,"ALLOWED_TAGS")?F({},w.ALLOWED_TAGS,Z):_n,Y=ve(w,"ALLOWED_ATTR")?F({},w.ALLOWED_ATTR,Z):Mn,ji=ve(w,"ALLOWED_NAMESPACES")?F({},w.ALLOWED_NAMESPACES,us):Xu,Hi=ve(w,"ADD_URI_SAFE_ATTR")?F(Te(sr),w.ADD_URI_SAFE_ATTR,Z):sr,nr=ve(w,"ADD_DATA_URI_TAGS")?F(Te(ir),w.ADD_DATA_URI_TAGS,Z):ir,xe=ve(w,"FORBID_CONTENTS")?F({},w.FORBID_CONTENTS,Z):zi,st=ve(w,"FORBID_TAGS")?F({},w.FORBID_TAGS,Z):Te({}),Gt=ve(w,"FORBID_ATTR")?F({},w.FORBID_ATTR,Z):Te({}),Et=ve(w,"USE_PROFILES")?w.USE_PROFILES:!1,Pn=w.ALLOW_ARIA_ATTR!==!1,x=w.ALLOW_DATA_ATTR!==!1,M=w.ALLOW_UNKNOWN_PROTOCOLS||!1,B=w.ALLOW_SELF_CLOSE_IN_ATTR!==!1,N=w.SAFE_FOR_TEMPLATES||!1,V=w.SAFE_FOR_XML!==!1,z=w.WHOLE_DOCUMENT||!1,At=w.RETURN_DOM||!1,Ln=w.RETURN_DOM_FRAGMENT||!1,In=w.RETURN_TRUSTED_TYPE||!1,Qe=w.FORCE_BODY||!1,er=w.SANITIZE_DOM!==!1,tr=w.SANITIZE_NAMED_PROPS||!1,Ki=w.KEEP_CONTENT!==!1,Qt=w.IN_PLACE||!1,Tn=w.ALLOWED_URI_REGEXP||zc,Ct=w.NAMESPACE||De,Bn=w.MATHML_TEXT_INTEGRATION_POINTS||Bn,Nn=w.HTML_INTEGRATION_POINTS||Nn,j=w.CUSTOM_ELEMENT_HANDLING||{},w.CUSTOM_ELEMENT_HANDLING&&or(w.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(j.tagNameCheck=w.CUSTOM_ELEMENT_HANDLING.tagNameCheck),w.CUSTOM_ELEMENT_HANDLING&&or(w.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(j.attributeNameCheck=w.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),w.CUSTOM_ELEMENT_HANDLING&&typeof w.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(j.allowCustomizedBuiltInElements=w.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),N&&(x=!1),Ln&&(At=!0),Et&&(Q=F({},ya),Y=[],Et.html===!0&&(F(Q,ma),F(Y,va)),Et.svg===!0&&(F(Q,ps),F(Y,gs),F(Y,jn)),Et.svgFilters===!0&&(F(Q,hs),F(Y,gs),F(Y,jn)),Et.mathMl===!0&&(F(Q,fs),F(Y,ba),F(Y,jn))),w.ADD_TAGS&&(typeof w.ADD_TAGS=="function"?Ge.tagCheck=w.ADD_TAGS:(Q===_n&&(Q=Te(Q)),F(Q,w.ADD_TAGS,Z))),w.ADD_ATTR&&(typeof w.ADD_ATTR=="function"?Ge.attributeCheck=w.ADD_ATTR:(Y===Mn&&(Y=Te(Y)),F(Y,w.ADD_ATTR,Z))),w.ADD_URI_SAFE_ATTR&&F(Hi,w.ADD_URI_SAFE_ATTR,Z),w.FORBID_CONTENTS&&(xe===zi&&(xe=Te(xe)),F(xe,w.FORBID_CONTENTS,Z)),w.ADD_FORBID_CONTENTS&&(xe===zi&&(xe=Te(xe)),F(xe,w.ADD_FORBID_CONTENTS,Z)),Ki&&(Q["#text"]=!0),z&&F(Q,["html","head","body"]),Q.table&&(F(Q,["tbody"]),delete st.tbody),w.TRUSTED_TYPES_POLICY){if(typeof w.TRUSTED_TYPES_POLICY.createHTML!="function")throw tn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof w.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw tn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');T=w.TRUSTED_TYPES_POLICY,_=T.createHTML("")}else T===void 0&&(T=hg(b,s)),T!==null&&typeof _=="string"&&(_=T.createHTML(""));pe&&pe(w),Tt=w}},rr=F({},[...ps,...hs,...ng]),ar=F({},[...fs,...ig]),id=function(w){let E=C(w);(!E||!E.tagName)&&(E={namespaceURI:Ct,tagName:"template"});const L=ni(w.tagName),H=ni(E.tagName);return ji[w.namespaceURI]?w.namespaceURI===Dn?E.namespaceURI===De?L==="svg":E.namespaceURI===Rn?L==="svg"&&(H==="annotation-xml"||Bn[H]):!!rr[L]:w.namespaceURI===Rn?E.namespaceURI===De?L==="math":E.namespaceURI===Dn?L==="math"&&Nn[H]:!!ar[L]:w.namespaceURI===De?E.namespaceURI===Dn&&!Nn[H]||E.namespaceURI===Rn&&!Bn[H]?!1:!ar[L]&&(Zu[L]||!rr[L]):!!(Yt==="application/xhtml+xml"&&ji[w.namespaceURI]):!1},Ae=function(w){Zt(t.removed,{element:w});try{C(w).removeChild(w)}catch{k(w)}},ot=function(w,E){try{Zt(t.removed,{attribute:E.getAttributeNode(w),from:E})}catch{Zt(t.removed,{attribute:null,from:E})}if(E.removeAttribute(w),w==="is")if(At||Ln)try{Ae(E)}catch{}else try{E.setAttribute(w,"")}catch{}},lr=function(w){let E=null,L=null;if(Qe)w="<remove></remove>"+w;else{const J=ds(w,/^[\r\n\t ]+/);L=J&&J[0]}Yt==="application/xhtml+xml"&&Ct===De&&(w='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+w+"</body></html>");const H=T?T.createHTML(w):w;if(Ct===De)try{E=new f().parseFromString(H,Yt)}catch{}if(!E||!E.documentElement){E=R.createDocument(Ct,"template",null);try{E.documentElement.innerHTML=qi?_:H}catch{}}const se=E.body||E.documentElement;return w&&L&&se.insertBefore(n.createTextNode(L),se.childNodes[0]||null),Ct===De?ye.call(E,z?"html":"body")[0]:z?E.documentElement:se},cr=function(w){return O.call(w.ownerDocument||w,w,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Gi=function(w){return w instanceof p&&(typeof w.nodeName!="string"||typeof w.textContent!="string"||typeof w.removeChild!="function"||!(w.attributes instanceof l)||typeof w.removeAttribute!="function"||typeof w.setAttribute!="function"||typeof w.namespaceURI!="string"||typeof w.insertBefore!="function"||typeof w.hasChildNodes!="function")},ur=function(w){return typeof a=="function"&&w instanceof a};function Be(I,w,E){qn(I,L=>{L.call(t,w,E,Tt)})}const dr=function(w){let E=null;if(Be(X.beforeSanitizeElements,w,null),Gi(w))return Ae(w),!0;const L=Z(w.nodeName);if(Be(X.uponSanitizeElement,w,{tagName:L,allowedTags:Q}),V&&w.hasChildNodes()&&!ur(w.firstElementChild)&&ce(/<[/\w!]/g,w.innerHTML)&&ce(/<[/\w!]/g,w.textContent)||w.nodeType===sn.progressingInstruction||V&&w.nodeType===sn.comment&&ce(/<[/\w]/g,w.data))return Ae(w),!0;if(!(Ge.tagCheck instanceof Function&&Ge.tagCheck(L))&&(!Q[L]||st[L])){if(!st[L]&&hr(L)&&(j.tagNameCheck instanceof RegExp&&ce(j.tagNameCheck,L)||j.tagNameCheck instanceof Function&&j.tagNameCheck(L)))return!1;if(Ki&&!xe[L]){const H=C(w)||w.parentNode,se=A(w)||w.childNodes;if(se&&H){const J=se.length;for(let fe=J-1;fe>=0;--fe){const Ne=v(se[fe],!0);Ne.__removalCount=(w.__removalCount||0)+1,H.insertBefore(Ne,$(w))}}}return Ae(w),!0}return w instanceof u&&!id(w)||(L==="noscript"||L==="noembed"||L==="noframes")&&ce(/<\/no(script|embed|frames)/i,w.innerHTML)?(Ae(w),!0):(N&&w.nodeType===sn.text&&(E=w.textContent,qn([Vt,xt,it],H=>{E=en(E,H," ")}),w.textContent!==E&&(Zt(t.removed,{element:w.cloneNode()}),w.textContent=E)),Be(X.afterSanitizeElements,w,null),!1)},pr=function(w,E,L){if(er&&(E==="id"||E==="name")&&(L in n||L in nd))return!1;if(!(x&&!Gt[E]&&ce(Oi,E))){if(!(Pn&&ce(Fi,E))){if(!(Ge.attributeCheck instanceof Function&&Ge.attributeCheck(E,w))){if(!Y[E]||Gt[E]){if(!(hr(w)&&(j.tagNameCheck instanceof RegExp&&ce(j.tagNameCheck,w)||j.tagNameCheck instanceof Function&&j.tagNameCheck(w))&&(j.attributeNameCheck instanceof RegExp&&ce(j.attributeNameCheck,E)||j.attributeNameCheck instanceof Function&&j.attributeNameCheck(E,w))||E==="is"&&j.allowCustomizedBuiltInElements&&(j.tagNameCheck instanceof RegExp&&ce(j.tagNameCheck,L)||j.tagNameCheck instanceof Function&&j.tagNameCheck(L))))return!1}else if(!Hi[E]){if(!ce(Tn,en(L,Cn,""))){if(!((E==="src"||E==="xlink:href"||E==="href")&&w!=="script"&&Xf(L,"data:")===0&&nr[w])){if(!(M&&!ce(Ui,en(L,Cn,"")))){if(L)return!1}}}}}}}return!0},hr=function(w){return w!=="annotation-xml"&&ds(w,Wi)},fr=function(w){Be(X.beforeSanitizeAttributes,w,null);const{attributes:E}=w;if(!E||Gi(w))return;const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Y,forceKeepAttr:void 0};let H=E.length;for(;H--;){const se=E[H],{name:J,namespaceURI:fe,value:Ne}=se,_t=Z(J),Qi=Ne;let ne=J==="value"?Qi:Zf(Qi);if(L.attrName=_t,L.attrValue=ne,L.keepAttr=!0,L.forceKeepAttr=void 0,Be(X.uponSanitizeAttribute,w,L),ne=L.attrValue,tr&&(_t==="id"||_t==="name")&&(ot(J,w),ne=Ju+ne),V&&ce(/((--!?|])>)|<\/(style|title|textarea)/i,ne)){ot(J,w);continue}if(_t==="attributename"&&ds(ne,"href")){ot(J,w);continue}if(L.forceKeepAttr)continue;if(!L.keepAttr){ot(J,w);continue}if(!B&&ce(/\/>/i,ne)){ot(J,w);continue}N&&qn([Vt,xt,it],mr=>{ne=en(ne,mr," ")});const gr=Z(w.nodeName);if(!pr(gr,_t,ne)){ot(J,w);continue}if(T&&typeof b=="object"&&typeof b.getAttributeType=="function"&&!fe)switch(b.getAttributeType(gr,_t)){case"TrustedHTML":{ne=T.createHTML(ne);break}case"TrustedScriptURL":{ne=T.createScriptURL(ne);break}}if(ne!==Qi)try{fe?w.setAttributeNS(fe,J,ne):w.setAttribute(J,ne),Gi(w)?Ae(w):ga(t.removed)}catch{ot(J,w)}}Be(X.afterSanitizeAttributes,w,null)},sd=function I(w){let E=null;const L=cr(w);for(Be(X.beforeSanitizeShadowDOM,w,null);E=L.nextNode();)Be(X.uponSanitizeShadowNode,E,null),dr(E),fr(E),E.content instanceof o&&I(E.content);Be(X.afterSanitizeShadowDOM,w,null)};return t.sanitize=function(I){let w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=null,L=null,H=null,se=null;if(qi=!I,qi&&(I="<!-->"),typeof I!="string"&&!ur(I))if(typeof I.toString=="function"){if(I=I.toString(),typeof I!="string")throw tn("dirty is not a string, aborting")}else throw tn("toString is not a function");if(!t.isSupported)return I;if(le||Vi(w),t.removed=[],typeof I=="string"&&(Qt=!1),Qt){if(I.nodeName){const Ne=Z(I.nodeName);if(!Q[Ne]||st[Ne])throw tn("root node is forbidden and cannot be sanitized in-place")}}else if(I instanceof a)E=lr("<!---->"),L=E.ownerDocument.importNode(I,!0),L.nodeType===sn.element&&L.nodeName==="BODY"||L.nodeName==="HTML"?E=L:E.appendChild(L);else{if(!At&&!N&&!z&&I.indexOf("<")===-1)return T&&In?T.createHTML(I):I;if(E=lr(I),!E)return At?null:In?_:""}E&&Qe&&Ae(E.firstChild);const J=cr(Qt?I:E);for(;H=J.nextNode();)dr(H),fr(H),H.content instanceof o&&sd(H.content);if(Qt)return I;if(At){if(Ln)for(se=ee.call(E.ownerDocument);E.firstChild;)se.appendChild(E.firstChild);else se=E;return(Y.shadowroot||Y.shadowrootmode)&&(se=Ve.call(i,se,!0)),se}let fe=z?E.outerHTML:E.innerHTML;return z&&Q["!doctype"]&&E.ownerDocument&&E.ownerDocument.doctype&&E.ownerDocument.doctype.name&&ce(Hc,E.ownerDocument.doctype.name)&&(fe="<!DOCTYPE "+E.ownerDocument.doctype.name+`>
|
|
2161
|
+
`+fe),N&&qn([Vt,xt,it],Ne=>{fe=en(fe,Ne," ")}),T&&In?T.createHTML(fe):fe},t.setConfig=function(){let I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Vi(I),le=!0},t.clearConfig=function(){Tt=null,le=!1},t.isValidAttribute=function(I,w,E){Tt||Vi({});const L=Z(I),H=Z(w);return pr(L,H,E)},t.addHook=function(I,w){typeof w=="function"&&Zt(X[I],w)},t.removeHook=function(I,w){if(w!==void 0){const E=Yf(X[I],w);return E===-1?void 0:Jf(X[I],E,1)[0]}return ga(X[I])},t.removeHooks=function(I){X[I]=[]},t.removeAllHooks=function(){X=ka()},t}var qs=qc();function Do(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var St=Do();function jc(e){St=e}var mn={exec:()=>null};function W(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(ue.caret,"$1"),n=n.replace(s,r),i},getRegex:()=>new RegExp(n,t)};return i}var fg=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ue={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")},gg=/^(?:[ \t]*(?:\n|$))+/,mg=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,yg=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,An=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,vg=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Bo=/(?:[*+-]|\d{1,9}[.)])/,Vc=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Gc=W(Vc).replace(/bull/g,Bo).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(),bg=W(Vc).replace(/bull/g,Bo).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(),No=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,wg=/^[^\n]+/,Oo=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,kg=W(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Oo).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Sg=W(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Bo).getRegex(),Ri="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Fo=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,$g=W("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Fo).replace("tag",Ri).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Qc=W(No).replace("hr",An).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",Ri).getRegex(),xg=W(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Qc).getRegex(),Uo={blockquote:xg,code:mg,def:kg,fences:yg,heading:vg,hr:An,html:$g,lheading:Gc,list:Sg,newline:gg,paragraph:Qc,table:mn,text:wg},Sa=W("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",An).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",Ri).getRegex(),Ag={...Uo,lheading:bg,table:Sa,paragraph:W(No).replace("hr",An).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Sa).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",Ri).getRegex()},Eg={...Uo,html:W(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Fo).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:mn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:W(No).replace("hr",An).replace("heading",` *#{1,6} *[^
|
|
2162
|
+
]`).replace("lheading",Gc).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Cg=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Tg=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Yc=/^( {2,}|\\)\n(?!\s*$)/,_g=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Di=/[\p{P}\p{S}]/u,Wo=/[\s\p{P}\p{S}]/u,Jc=/[^\s\p{P}\p{S}]/u,Mg=W(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Wo).getRegex(),Xc=/(?!~)[\p{P}\p{S}]/u,Pg=/(?!~)[\s\p{P}\p{S}]/u,Lg=/(?:[^\s\p{P}\p{S}]|~)/u,Ig=W(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",fg?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Zc=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Rg=W(Zc,"u").replace(/punct/g,Di).getRegex(),Dg=W(Zc,"u").replace(/punct/g,Xc).getRegex(),eu="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Bg=W(eu,"gu").replace(/notPunctSpace/g,Jc).replace(/punctSpace/g,Wo).replace(/punct/g,Di).getRegex(),Ng=W(eu,"gu").replace(/notPunctSpace/g,Lg).replace(/punctSpace/g,Pg).replace(/punct/g,Xc).getRegex(),Og=W("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Jc).replace(/punctSpace/g,Wo).replace(/punct/g,Di).getRegex(),Fg=W(/\\(punct)/,"gu").replace(/punct/g,Di).getRegex(),Ug=W(/^<(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(),Wg=W(Fo).replace("(?:-->|$)","-->").getRegex(),Kg=W("^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",Wg).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),yi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,zg=W(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",yi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),tu=W(/^!?\[(label)\]\[(ref)\]/).replace("label",yi).replace("ref",Oo).getRegex(),nu=W(/^!?\[(ref)\](?:\[\])?/).replace("ref",Oo).getRegex(),Hg=W("reflink|nolink(?!\\()","g").replace("reflink",tu).replace("nolink",nu).getRegex(),$a=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ko={_backpedal:mn,anyPunctuation:Fg,autolink:Ug,blockSkip:Ig,br:Yc,code:Tg,del:mn,emStrongLDelim:Rg,emStrongRDelimAst:Bg,emStrongRDelimUnd:Og,escape:Cg,link:zg,nolink:nu,punctuation:Mg,reflink:tu,reflinkSearch:Hg,tag:Kg,text:_g,url:mn},qg={...Ko,link:W(/^!?\[(label)\]\((.*?)\)/).replace("label",yi).getRegex(),reflink:W(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",yi).getRegex()},js={...Ko,emStrongRDelimAst:Ng,emStrongLDelim:Dg,url:W(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",$a).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:W(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",$a).getRegex()},jg={...js,br:W(Yc).replace("{2,}","*").getRegex(),text:W(js.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Vn={normal:Uo,gfm:Ag,pedantic:Eg},on={normal:Ko,gfm:js,breaks:jg,pedantic:qg},Vg={"&":"&","<":"<",">":">",'"':""","'":"'"},xa=e=>Vg[e];function Ue(e,t){if(t){if(ue.escapeTest.test(e))return e.replace(ue.escapeReplace,xa)}else if(ue.escapeTestNoEncode.test(e))return e.replace(ue.escapeReplaceNoEncode,xa);return e}function Aa(e){try{e=encodeURI(e).replace(ue.percentDecode,"%")}catch{return null}return e}function Ea(e,t){var o;let n=e.replace(ue.findPipe,(r,a,u)=>{let c=!1,l=a;for(;--l>=0&&u[l]==="\\";)c=!c;return c?"|":" |"}),i=n.split(ue.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(ue.slashPipe,"|");return i}function rn(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 Gg(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 Ca(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 u={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:r,text:a,tokens:i.inlineTokens(a)};return i.state.inLink=!1,u}function Qg(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let s=i[1];return t.split(`
|
|
2163
2163
|
`).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(`
|
|
2164
|
-
`)}var
|
|
2165
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=
|
|
2166
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=
|
|
2164
|
+
`)}var vi=class{constructor(e){U(this,"options");U(this,"rules");U(this,"lexer");this.options=e||St}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:rn(n,`
|
|
2165
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=Qg(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=rn(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:rn(t[0],`
|
|
2166
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=rn(t[0],`
|
|
2167
2167
|
`).split(`
|
|
2168
2168
|
`),i="",s="",o=[];for(;n.length>0;){let r=!1,a=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))a.push(n[u]),r=!0;else if(!r)a.push(n[u]);else break;n=n.slice(u);let c=a.join(`
|
|
2169
2169
|
`),l=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
@@ -2181,9 +2181,9 @@ ${l}`:l;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
2181
2181
|
`,1)[0],O;if(h=R,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),O=h):O=h.replace(this.rules.other.tabCharGlobal," "),C.test(h)||T.test(h)||_.test(h)||$.test(h)||A.test(h))break;if(O.search(this.rules.other.nonSpaceChar)>=k||!h.trim())f+=`
|
|
2182
2182
|
`+O.slice(k);else{if(v||b.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||C.test(b)||T.test(b)||A.test(b))break;f+=`
|
|
2183
2183
|
`+h}!v&&!h.trim()&&(v=!0),p+=R+`
|
|
2184
|
-
`,e=e.substring(R.length+1),b=O.slice(k)}}r.loose||(u?r.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(u=!0)),r.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(f),loose:!1,text:f,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 f=this.lexer.inlineQueue.length-1;f>=0;f--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[f].src)){this.lexer.inlineQueue[f].src=this.lexer.inlineQueue[f].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(l.raw);if(p){let f={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};l.checked=f.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=f.raw+l.tokens[0].raw,l.tokens[0].text=f.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(f)):l.tokens.unshift({type:"paragraph",raw:f.raw,text:f.raw,tokens:[f]}):l.tokens.unshift(f)}}if(!r.loose){let p=l.tokens.filter(b=>b.type==="space"),f=p.length>0&&p.some(b=>this.rules.other.anyLine.test(b.raw));r.loose=f}}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=
|
|
2185
|
-
`):[],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(
|
|
2186
|
-
`?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=
|
|
2184
|
+
`,e=e.substring(R.length+1),b=O.slice(k)}}r.loose||(u?r.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(u=!0)),r.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(f),loose:!1,text:f,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 f=this.lexer.inlineQueue.length-1;f>=0;f--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[f].src)){this.lexer.inlineQueue[f].src=this.lexer.inlineQueue[f].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(l.raw);if(p){let f={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};l.checked=f.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=f.raw+l.tokens[0].raw,l.tokens[0].text=f.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(f)):l.tokens.unshift({type:"paragraph",raw:f.raw,text:f.raw,tokens:[f]}):l.tokens.unshift(f)}}if(!r.loose){let p=l.tokens.filter(b=>b.type==="space"),f=p.length>0&&p.some(b=>this.rules.other.anyLine.test(b.raw));r.loose=f}}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=Ea(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(`
|
|
2185
|
+
`):[],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(Ea(a,o.header.length).map((u,c)=>({text:u,tokens:this.lexer.inline(u),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)===`
|
|
2186
|
+
`?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=rn(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=Gg(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)),Ca(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 Ca(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,u=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)){u+=r;continue}if(a-=r,a>0)continue;r=Math.min(r,r+a+u);let l=[...i[0]][0].length,p=e.slice(0,s+i.index+l+r);if(Math.min(s,r)%2){let b=p.slice(1,-1);return{type:"em",raw:p,text:b,tokens:this.lexer.inlineTokens(b)}}let f=p.slice(2,-2);return{type:"strong",raw:p,text:f,tokens:this.lexer.inlineTokens(f)}}}}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}}}},be=class Vs{constructor(t){U(this,"tokens");U(this,"options");U(this,"state");U(this,"inlineQueue");U(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||St,this.options.tokenizer=this.options.tokenizer||new vi,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:ue,block:Vn.normal,inline:on.normal};this.options.pedantic?(n.block=Vn.pedantic,n.inline=on.pedantic):this.options.gfm&&(n.block=Vn.gfm,this.options.breaks?n.inline=on.breaks:n.inline=on.gfm),this.tokenizer.rules=n}static get rules(){return{block:Vn,inline:on}}static lex(t,n){return new Vs(n).lex(t)}static lexInline(t,n){return new Vs(n).inlineTokens(t)}lex(t){t=t.replace(ue.carriageReturn,`
|
|
2187
2187
|
`),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(ue.tabCharGlobal," ").replace(ue.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+=`
|
|
2188
2188
|
`: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(`
|
|
2189
2189
|
`)?"":`
|
|
@@ -2197,9 +2197,9 @@ ${l}`:l;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
2197
2197
|
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a),i=u.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(`
|
|
2198
2198
|
`)?"":`
|
|
2199
2199
|
`)+a.raw,c.text+=`
|
|
2200
|
-
`+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 u,c,l,p,f;let i=t,s=null;if(this.tokens.links){let b=Object.keys(this.tokens.links);if(b.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)b.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=(u=this.options.hooks)==null?void 0:u.emStrongMask)==null?void 0:c.call({lexer:this},i))??i;let r=!1,a="";for(;t;){r||(a=""),r=!1;let b;if((p=(l=this.options.extensions)==null?void 0:l.inline)!=null&&p.some(v=>(b=v.call({lexer:this},t,n))?(t=t.substring(b.raw.length),n.push(b),!0):!1))continue;if(b=this.tokenizer.escape(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.tag(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.link(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(b.raw.length);let v=n.at(-1);b.type==="text"&&(v==null?void 0:v.type)==="text"?(v.raw+=b.raw,v.text+=b.text):n.push(b);continue}if(b=this.tokenizer.emStrong(t,i,a)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.codespan(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.br(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.del(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.autolink(t)){t=t.substring(b.raw.length),n.push(b);continue}if(!this.state.inLink&&(b=this.tokenizer.url(t))){t=t.substring(b.raw.length),n.push(b);continue}let h=t;if((f=this.options.extensions)!=null&&f.startInline){let v=1/0,k=t.slice(1),$;this.options.extensions.startInline.forEach(A=>{$=A.call({lexer:this},k),typeof $=="number"&&$>=0&&(v=Math.min(v,$))}),v<1/0&&v>=0&&(h=t.substring(0,v+1))}if(b=this.tokenizer.inlineText(h)){t=t.substring(b.raw.length),b.raw.slice(-1)!=="_"&&(a=b.raw.slice(-1)),r=!0;let v=n.at(-1);(v==null?void 0:v.type)==="text"?(v.raw+=b.raw,v.text+=b.text):n.push(b);continue}if(t){let v="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(v);break}else throw new Error(v)}}return n}},
|
|
2201
|
-
`;return i?'<pre><code class="language-'+
|
|
2202
|
-
`:"<pre><code>"+(n?s:
|
|
2200
|
+
`+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 u,c,l,p,f;let i=t,s=null;if(this.tokens.links){let b=Object.keys(this.tokens.links);if(b.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)b.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=(u=this.options.hooks)==null?void 0:u.emStrongMask)==null?void 0:c.call({lexer:this},i))??i;let r=!1,a="";for(;t;){r||(a=""),r=!1;let b;if((p=(l=this.options.extensions)==null?void 0:l.inline)!=null&&p.some(v=>(b=v.call({lexer:this},t,n))?(t=t.substring(b.raw.length),n.push(b),!0):!1))continue;if(b=this.tokenizer.escape(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.tag(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.link(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(b.raw.length);let v=n.at(-1);b.type==="text"&&(v==null?void 0:v.type)==="text"?(v.raw+=b.raw,v.text+=b.text):n.push(b);continue}if(b=this.tokenizer.emStrong(t,i,a)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.codespan(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.br(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.del(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.autolink(t)){t=t.substring(b.raw.length),n.push(b);continue}if(!this.state.inLink&&(b=this.tokenizer.url(t))){t=t.substring(b.raw.length),n.push(b);continue}let h=t;if((f=this.options.extensions)!=null&&f.startInline){let v=1/0,k=t.slice(1),$;this.options.extensions.startInline.forEach(A=>{$=A.call({lexer:this},k),typeof $=="number"&&$>=0&&(v=Math.min(v,$))}),v<1/0&&v>=0&&(h=t.substring(0,v+1))}if(b=this.tokenizer.inlineText(h)){t=t.substring(b.raw.length),b.raw.slice(-1)!=="_"&&(a=b.raw.slice(-1)),r=!0;let v=n.at(-1);(v==null?void 0:v.type)==="text"?(v.raw+=b.raw,v.text+=b.text):n.push(b);continue}if(t){let v="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(v);break}else throw new Error(v)}}return n}},bi=class{constructor(e){U(this,"options");U(this,"parser");this.options=e||St}space(e){return""}code({text:e,lang:t,escaped:n}){var o;let i=(o=(t||"").match(ue.notSpaceStart))==null?void 0:o[0],s=e.replace(ue.endingNewline,"")+`
|
|
2201
|
+
`;return i?'<pre><code class="language-'+Ue(i)+'">'+(n?s:Ue(s,!0))+`</code></pre>
|
|
2202
|
+
`:"<pre><code>"+(n?s:Ue(s,!0))+`</code></pre>
|
|
2203
2203
|
`}blockquote({tokens:e}){return`<blockquote>
|
|
2204
2204
|
${this.parser.parse(e)}</blockquote>
|
|
2205
2205
|
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
@@ -2215,23 +2215,23 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
2215
2215
|
`}tablerow({text:e}){return`<tr>
|
|
2216
2216
|
${e}</tr>
|
|
2217
2217
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
2218
|
-
`}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>${
|
|
2219
|
-
Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+
|
|
2218
|
+
`}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>${Ue(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=Aa(e);if(s===null)return i;e=s;let o='<a href="'+e+'"';return t&&(o+=' title="'+Ue(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=Aa(e);if(s===null)return Ue(n);e=s;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Ue(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ue(e.text)}},zo=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}},we=class Gs{constructor(t){U(this,"options");U(this,"renderer");U(this,"textRenderer");this.options=t||St,this.options.renderer=this.options.renderer||new bi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new zo}static parse(t,n){return new Gs(n).parse(t)}static parseInline(t,n){return new Gs(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 u=r,c=this.options.extensions.renderers[u.type].call({parser:this},u);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(u.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 u='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}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 u=a;switch(u.type){case"escape":{i+=n.text(u);break}case"html":{i+=n.html(u);break}case"link":{i+=n.link(u);break}case"image":{i+=n.image(u);break}case"checkbox":{i+=n.checkbox(u);break}case"strong":{i+=n.strong(u);break}case"em":{i+=n.em(u);break}case"codespan":{i+=n.codespan(u);break}case"br":{i+=n.br(u);break}case"del":{i+=n.del(u);break}case"text":{i+=n.text(u);break}default:{let c='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return i}},Zn,cn=(Zn=class{constructor(e){U(this,"options");U(this,"block");this.options=e||St}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?be.lex:be.lexInline}provideParser(){return this.block?we.parse:we.parseInline}},U(Zn,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),U(Zn,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Zn),Yg=class{constructor(...e){U(this,"defaults",Do());U(this,"options",this.setOptions);U(this,"parse",this.parseMarkdown(!0));U(this,"parseInline",this.parseMarkdown(!1));U(this,"Parser",we);U(this,"Renderer",bi);U(this,"TextRenderer",zo);U(this,"Lexer",be);U(this,"Tokenizer",vi);U(this,"Hooks",cn);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 u of a)n=n.concat(this.walkTokens(u.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 u=r[a].flat(1/0);n=n.concat(this.walkTokens(u,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 bi(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],u=s[r];s[r]=(...c)=>{let l=a.apply(s,c);return l===!1&&(l=u.apply(s,c)),l||""}}i.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new vi(this.defaults);for(let o in n.tokenizer){if(!(o in s))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let r=o,a=n.tokenizer[r],u=s[r];s[r]=(...c)=>{let l=a.apply(s,c);return l===!1&&(l=u.apply(s,c)),l}}i.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new cn;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],u=s[r];cn.passThroughHooks.has(o)?s[r]=c=>{if(this.defaults.async&&cn.passThroughHooksRespectAsync.has(o))return(async()=>{let p=await a.call(s,c);return u.call(s,p)})();let l=a.call(s,c);return u.call(s,l)}:s[r]=(...c)=>{if(this.defaults.async)return(async()=>{let p=await a.apply(s,c);return p===!1&&(p=await u.apply(s,c)),p})();let l=a.apply(s,c);return l===!1&&(l=u.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 be.lex(e,t??this.defaults)}parser(e,t){return we.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?be.lex:be.lexInline)(r,s),u=s.hooks?await s.hooks.processAllTokens(a):a;s.walkTokens&&await Promise.all(this.walkTokens(u,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():e?we.parse:we.parseInline)(u,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?be.lex:be.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?we.parse:we.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+=`
|
|
2219
|
+
Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Ue(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},vt=new Yg;function K(e,t){return vt.parse(e,t)}K.options=K.setOptions=function(e){return vt.setOptions(e),K.defaults=vt.defaults,jc(K.defaults),K};K.getDefaults=Do;K.defaults=St;K.use=function(...e){return vt.use(...e),K.defaults=vt.defaults,jc(K.defaults),K};K.walkTokens=function(e,t){return vt.walkTokens(e,t)};K.parseInline=vt.parseInline;K.Parser=we;K.parser=we.parse;K.Renderer=bi;K.TextRenderer=zo;K.Lexer=be;K.lexer=be.lex;K.Tokenizer=vi;K.Hooks=cn;K.parse=K;K.options;K.setOptions;K.use;K.walkTokens;K.parseInline;we.parse;be.lex;K.setOptions({gfm:!0,breaks:!0,mangle:!1});const Ta=["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"],_a=["class","href","rel","target","title","start"];let Ma=!1;const Jg=14e4,Xg=4e4,Zg=200,ms=5e4,dt=new Map;function em(e){const t=dt.get(e);return t===void 0?null:(dt.delete(e),dt.set(e,t),t)}function Pa(e,t){if(dt.set(e,t),dt.size<=Zg)return;const n=dt.keys().next().value;n&&dt.delete(n)}function tm(){Ma||(Ma=!0,qs.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function wi(e){const t=e.trim();if(!t)return"";if(tm(),t.length<=ms){const r=em(t);if(r!==null)return r}const n=xl(t,Jg),i=n.truncated?`
|
|
2220
2220
|
|
|
2221
|
-
… truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>
|
|
2221
|
+
… truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>Xg){const a=`<pre class="code-block">${nm(`${n.text}${i}`)}</pre>`,u=qs.sanitize(a,{ALLOWED_TAGS:Ta,ALLOWED_ATTR:_a});return t.length<=ms&&Pa(t,u),u}const s=K.parse(`${n.text}${i}`),o=qs.sanitize(s,{ALLOWED_TAGS:Ta,ALLOWED_ATTR:_a});return t.length<=ms&&Pa(t,o),o}function nm(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const im=1500,sm=2e3,iu="Copy as markdown",om="Copied",rm="Copy failed";async function am(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 Gn(e,t){e.title=t,e.setAttribute("aria-label",t)}function lm(e){const t=e.label??iu;return d`
|
|
2222
2222
|
<button
|
|
2223
2223
|
class="chat-copy-btn"
|
|
2224
2224
|
type="button"
|
|
2225
2225
|
title=${t}
|
|
2226
2226
|
aria-label=${t}
|
|
2227
|
-
@click=${async n=>{const i=n.currentTarget;if(i==null||i.querySelector(".chat-copy-btn__icon"),!i||i.dataset.copying==="1")return;i.dataset.copying="1",i.setAttribute("aria-busy","true"),i.disabled=!0;const s=await
|
|
2227
|
+
@click=${async n=>{const i=n.currentTarget;if(i==null||i.querySelector(".chat-copy-btn__icon"),!i||i.dataset.copying==="1")return;i.dataset.copying="1",i.setAttribute("aria-busy","true"),i.disabled=!0;const s=await am(e.text());if(i.isConnected){if(delete i.dataset.copying,i.removeAttribute("aria-busy"),i.disabled=!1,!s){i.dataset.error="1",Gn(i,rm),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.error,Gn(i,t))},sm);return}i.dataset.copied="1",Gn(i,om),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.copied,Gn(i,t))},im)}}}
|
|
2228
2228
|
>
|
|
2229
2229
|
<span class="chat-copy-btn__icon" aria-hidden="true">
|
|
2230
2230
|
<span class="chat-copy-btn__icon-copy">${D.copy}</span>
|
|
2231
2231
|
<span class="chat-copy-btn__icon-check">${D.check}</span>
|
|
2232
2232
|
</span>
|
|
2233
2233
|
</button>
|
|
2234
|
-
`}function
|
|
2234
|
+
`}function cm(e){return lm({text:()=>e,label:iu})}function um(e){const t=e,n=dm(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:pm(s.arguments??s.args)})}for(const s of n){const o=String(s.type??"").toLowerCase();if(o!=="toolresult"&&o!=="tool_result")continue;const r=hm(s),a=typeof s.name=="string"?s.name:"tool";i.push({kind:"result",name:a,text:r})}if(_l(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=Al(e)??void 0;i.push({kind:"result",name:s,text:o})}return i}function dm(e){return Array.isArray(e)?e.filter(Boolean):[]}function pm(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 hm(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function fm(e){var s;const n=e.content,i=[];if(Array.isArray(n))for(const o of n){if(typeof o!="object"||o===null)continue;const r=o;if(r.type==="image")if(((s=r.source)==null?void 0:s.type)==="base64"){const a=r.source,u=a.data,c=a.media_type||"image/png",l=u.startsWith("data:")?u:`data:${c};base64,${u}`;i.push({url:l})}else if(typeof r.data=="string"&&r.data){const a=r.data,u=r.mimeType||r.media_type||"image/png",c=a.startsWith("data:")?a:`data:${u};base64,${a}`;i.push({url:c})}else typeof r.url=="string"&&i.push({url:r.url});else if(r.type==="image_url"){const a=r.image_url;typeof(a==null?void 0:a.url)=="string"&&i.push({url:a.url})}}return i}function gm(e){return d`
|
|
2235
2235
|
<div class="chat-group assistant">
|
|
2236
2236
|
<div class="chat-group-messages">
|
|
2237
2237
|
<div class="chat-bubble chat-reading-indicator" aria-hidden="true">
|
|
@@ -2241,30 +2241,30 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
2241
2241
|
</div>
|
|
2242
2242
|
</div>
|
|
2243
2243
|
</div>
|
|
2244
|
-
`}function
|
|
2244
|
+
`}function mm(e){return d`
|
|
2245
2245
|
<div class="chat-group assistant">
|
|
2246
2246
|
<div class="chat-group-messages">
|
|
2247
2247
|
<div class="chat-interim fade-in">
|
|
2248
|
-
${
|
|
2248
|
+
${mi(wi(e))}
|
|
2249
2249
|
</div>
|
|
2250
2250
|
</div>
|
|
2251
2251
|
</div>
|
|
2252
|
-
`}function
|
|
2252
|
+
`}function ym(e,t,n,i){return d`
|
|
2253
2253
|
<div class="chat-group assistant">
|
|
2254
2254
|
<div class="chat-group-messages">
|
|
2255
|
-
${
|
|
2255
|
+
${su({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!1,showReasoning:!1})}
|
|
2256
2256
|
</div>
|
|
2257
2257
|
</div>
|
|
2258
|
-
`}function
|
|
2258
|
+
`}function vm(e,t){const n=Tl(e.role),i=n==="user"?"user":n==="assistant"?"assistant":"other",s=new Date(e.timestamp).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"});return d`
|
|
2259
2259
|
<div class="chat-group ${i}">
|
|
2260
2260
|
<div class="chat-group-messages">
|
|
2261
|
-
${e.messages.map((o,r)=>
|
|
2261
|
+
${e.messages.map((o,r)=>su(o.message,{isStreaming:e.isStreaming&&r===e.messages.length-1,showReasoning:t.showReasoning}))}
|
|
2262
2262
|
<div class="chat-group-footer">
|
|
2263
2263
|
<span class="chat-group-timestamp">${s}</span>
|
|
2264
2264
|
</div>
|
|
2265
2265
|
</div>
|
|
2266
2266
|
</div>
|
|
2267
|
-
`}function
|
|
2267
|
+
`}function bm(e){return e.length===0?S:d`
|
|
2268
2268
|
<div class="chat-message-images">
|
|
2269
2269
|
${e.map(t=>d`
|
|
2270
2270
|
<img
|
|
@@ -2275,14 +2275,14 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
2275
2275
|
/>
|
|
2276
2276
|
`)}
|
|
2277
2277
|
</div>
|
|
2278
|
-
`}function
|
|
2278
|
+
`}function su(e,t,n){const i=e,s=typeof i.role=="string"?i.role:"unknown",o=_l(e)||s.toLowerCase()==="toolresult"||s.toLowerCase()==="tool_result"||typeof i.toolCallId=="string"||typeof i.tool_call_id=="string",a=um(e).length>0,u=fm(e),c=u.length>0,l=Al(e),p=t.showReasoning&&s==="assistant"?Yd(e):null,f=l!=null&&l.trim()?l:null,b=p?Xd(p):null,h=f,v=(s==="assistant"||s==="user")&&!!(h!=null&&h.trim()),k=["chat-bubble",v?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!h&&(a||o)||!h&&!c?S:d`
|
|
2279
2279
|
<div class="${k}">
|
|
2280
|
-
${v?
|
|
2281
|
-
${
|
|
2282
|
-
${b?d`<div class="chat-thinking">${
|
|
2283
|
-
${h?d`<div class="chat-text">${
|
|
2280
|
+
${v?cm(h):S}
|
|
2281
|
+
${bm(u)}
|
|
2282
|
+
${b?d`<div class="chat-thinking">${mi(wi(b))}</div>`:S}
|
|
2283
|
+
${h?d`<div class="chat-text">${mi(wi(h))}</div>`:S}
|
|
2284
2284
|
</div>
|
|
2285
|
-
`}function
|
|
2285
|
+
`}function wm(e){return d`
|
|
2286
2286
|
<div class="sidebar-panel">
|
|
2287
2287
|
<div class="sidebar-header">
|
|
2288
2288
|
<div class="sidebar-title">Tool Output</div>
|
|
@@ -2296,10 +2296,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
2296
2296
|
<button @click=${e.onViewRawText} class="btn" style="margin-top: 12px;">
|
|
2297
2297
|
View Raw Text
|
|
2298
2298
|
</button>
|
|
2299
|
-
`:e.content?d`<div class="sidebar-markdown">${
|
|
2299
|
+
`:e.content?d`<div class="sidebar-markdown">${mi(wi(e.content))}</div>`:d`<div class="muted">No content available</div>`}
|
|
2300
2300
|
</div>
|
|
2301
2301
|
</div>
|
|
2302
|
-
`}var
|
|
2302
|
+
`}var km=Object.defineProperty,Sm=Object.getOwnPropertyDescriptor,Bi=(e,t,n,i)=>{for(var s=i>1?void 0:i?Sm(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&&km(t,n,s),s};let Ot=class extends It{constructor(){super(...arguments),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.isDragging=!1,this.startX=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startX=e.clientX,this.startRatio=this.splitRatio,this.classList.add("dragging"),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;const t=this.parentElement;if(!t)return;const n=t.getBoundingClientRect().width,s=(e.clientX-this.startX)/n;let o=this.startRatio+s;o=Math.max(this.minRatio,Math.min(this.maxRatio,o)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:o},bubbles:!0,composed:!0}))},this.handleMouseUp=()=>{this.isDragging=!1,this.classList.remove("dragging"),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}render(){return d``}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}};Ot.styles=ud`
|
|
2303
2303
|
:host {
|
|
2304
2304
|
width: 4px;
|
|
2305
2305
|
cursor: col-resize;
|
|
@@ -2325,21 +2325,21 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
2325
2325
|
:host(.dragging) {
|
|
2326
2326
|
background: var(--accent, #007bff);
|
|
2327
2327
|
}
|
|
2328
|
-
`;Di([Ei({type:Number})],Bt.prototype,"splitRatio",2);Di([Ei({type:Number})],Bt.prototype,"minRatio",2);Di([Ei({type:Number})],Bt.prototype,"maxRatio",2);Bt=Di([gl("resizable-divider")],Bt);function Vn(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function ms(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const wm=1,km=1,St="emoji",Ot="keyvalue",zo="favorites",Sm="tokens",nu="tokens",$m="unicode",iu="count",xm="group",Am="order",su="group-order",Gs="eTag",bi="url",Ma="skinTone",Ht="readonly",Ho="readwrite",ou="skinUnicodes",Em="skinUnicodes",Cm="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Tm="en";function _m(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 Pa(e){return _m(e,t=>t.unicode)}function Mm(e){function t(n,i,s){const o=i?e.createObjectStore(n,{keyPath:i}):e.createObjectStore(n);if(s)for(const[r,[a,u]]of Object.entries(s))o.createIndex(r,a,{multiEntry:u});return o}t(Ot),t(St,$m,{[nu]:[Sm,!0],[su]:[[xm,Am]],[ou]:[Em,!0]}),t(zo,void 0,{[iu]:[""]})}const Qs={},ti={},wi={};function ru(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function Pm(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,wm);Qs[e]=s,s.onupgradeneeded=o=>{o.oldVersion<km&&Mm(s.result)},ru(n,i,s)});return t.onclose=()=>jo(e),t}function Lm(e){return ti[e]||(ti[e]=Pm(e)),ti[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 u;i(a,r,c=>{u=c}),r.oncomplete=()=>s(u),r.onerror=()=>o(r.error)})}function jo(e){const t=Qs[e],n=t&&t.result;if(n){n.close();const i=wi[e];if(i)for(const s of i)s()}delete Qs[e],delete ti[e],delete wi[e]}function Im(e){return new Promise((t,n)=>{jo(e);const i=indexedDB.deleteDatabase(e);ru(t,n,i)})}function Rm(e,t){let n=wi[e];n||(n=wi[e]=[]),n.push(t)}const Dm=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 Rt(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||Dm.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const Nm=2;function au(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=Nm)}function Bm(e){return e.map(({annotation:n,emoticon:i,group:s,order:o,shortcodes:r,skins:a,tags:u,emoji:c,version:l})=>{const p=[...new Set(au([...(r||[]).map(Rt).flat(),...(u||[]).map(Rt).flat(),...Rt(n),i]))].sort(),f={annotation:n,group:s,order:o,tags:u,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:b,emoji:h,version:v}of a)f.skinTones.push(b),f.skinUnicodes.push(h),f.skinVersions.push(v)}return f})}function lu(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function vt(e,t,n){lu(e,"get",t,n)}function cu(e,t,n){lu(e,"getAll",t,n)}function qo(e){e.commit&&e.commit()}function Om(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 uu(e,t){const n=Om(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 Fm(e){return!await Vo(e,Ot,bi)}async function Um(e,t,n){const[i,s]=await Promise.all([Gs,bi].map(o=>Vo(e,Ot,o)));return i===n&&s===t}async function Wm(e,t){return je(e,St,Ht,(i,s,o)=>{let r;const a=()=>{i.getAll(r&&IDBKeyRange.lowerBound(r,!0),50).onsuccess=u=>{const c=u.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 du(e,t,n,i){{const s=Bm(t);await je(e,[St,Ot],Ho,([o,r],a)=>{let u,c,l=0;function p(){++l===2&&f()}function f(){if(!(u===i&&c===n)){o.clear();for(const b of s)o.put(b);r.put(i,Gs),r.put(n,bi),qo(a)}}vt(r,Gs,b=>{u=b,p()}),vt(r,bi,b=>{c=b,p()})})}}async function Km(e,t){return je(e,St,Ht,(n,i,s)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);cu(n.index(su),o,s)})}async function pu(e,t){const n=au(Rt(t));return n.length?je(e,St,Ht,(i,s,o)=>{const r=[],a=()=>{r.length===n.length&&u()},u=()=>{const c=uu(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);cu(i.index(nu),p,f=>{r.push(f),a()})}}):[]}async function zm(e,t){const n=await pu(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await Wm(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function Hm(e,t){return je(e,St,Ht,(n,i,s)=>vt(n,t,o=>{if(o)return s(o);vt(n.index(ou),t,r=>s(r||null))}))}function Vo(e,t,n){return je(e,t,Ht,(i,s,o)=>vt(i,n,o))}function jm(e,t,n,i){return je(e,t,Ho,(s,o)=>{s.put(i,n),qo(o)})}function qm(e,t){return je(e,zo,Ho,(n,i)=>vt(n,t,s=>{n.put((s||0)+1,t),qo(i)}))}function Vm(e,t,n){return n===0?[]:je(e,[zo,St],Ht,([i,s],o,r)=>{const a=[];i.index(iu).openCursor(void 0,"prev").onsuccess=u=>{const c=u.target.result;if(!c)return r(a);function l(b){if(a.push(b),a.length===n)return r(a);c.continue()}const p=c.primaryKey,f=t.byName(p);if(f)return l(f);vt(s,p,b=>{if(b)return l(b);c.continue()})}})}const Gn="";function Gm(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 u=a.get(Gn);u||(u=[],a.set(Gn,u)),u.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(Gn)||[];const a=[],u=[r];for(;u.length;){const l=[...u.shift().entries()].sort((p,f)=>p[0]<f[0]?-1:1);for(const[p,f]of l)p===Gn?a.push(...f):u.push(f)}return a}}const Qm=["name","url"];function Ym(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||Qm.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function La(e){Ym(e);const t=(f,b)=>f.name.toLowerCase()<b.name.toLowerCase()?-1:1,n=e.sort(t),s=Gm(e,f=>{const b=new Set;if(f.shortcodes)for(const h of f.shortcodes)for(const v of Rt(h))b.add(v);return b}),o=f=>s(f,!0),r=f=>s(f,!1),a=f=>{const b=Rt(f),h=b.map((v,k)=>(k<b.length-1?o:r)(v));return uu(h,v=>v.name).sort(t)},u=new Map,c=new Map;for(const f of e){c.set(f.name.toLowerCase(),f);for(const b of f.shortcodes||[])u.set(b.toLowerCase(),f)}return{all:n,search:a,byShortcode:f=>u.get(f.toLowerCase()),byName:f=>c.get(f.toLowerCase())}}const Xm=typeof wrappedJSObject<"u";function on(e){if(!e)return e;if(Xm&&(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 hu(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const Zm=["annotation","emoji","group","order","version"];function Jm(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||Zm.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function fu(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function ey(e){const t=await fetch(e,{method:"HEAD"});fu(t,e);const n=t.headers.get("etag");return hu(n),n}async function Ys(e){const t=await fetch(e);fu(t,e);const n=t.headers.get("etag");hu(n);const i=await t.json();return Jm(i),[n,i]}function ty(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function ny(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 gu(e){const t=JSON.stringify(e);let n=ny(t);const i=await crypto.subtle.digest("SHA-1",n),s=ty(i);return btoa(s)}async function iy(e,t){let n,i=await ey(t);if(!i){const s=await Ys(t);i=s[0],n=s[1],i||(i=await gu(n))}await Um(e,t,i)||(n||(n=(await Ys(t))[1]),await du(e,n,t,i))}async function sy(e,t){let[n,i]=await Ys(t);n||(n=await gu(i)),await du(e,i,t,n)}async function oy(e,t){try{await iy(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class ry{constructor({dataSource:t=Cm,locale:n=Tm,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=La(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await Lm(this._dbName);Rm(this._dbName,this._clear);const n=this.dataSource;await Fm(t)?await sy(t,n):this._lazyUpdate=oy(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 ms(t),await this.ready(),Pa(await Km(this._db,t)).map(on)}async getEmojiBySearchQuery(t){Vn(t),await this.ready();const n=this._custom.search(t),i=Pa(await pu(this._db,t)).map(on);return[...n,...i]}async getEmojiByShortcode(t){Vn(t),await this.ready();const n=this._custom.byShortcode(t);return n||on(await zm(this._db,t))}async getEmojiByUnicodeOrName(t){Vn(t),await this.ready();const n=this._custom.byName(t);return n||on(await Hm(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Vo(this._db,Ot,Ma)||0}async setPreferredSkinTone(t){return ms(t),await this.ready(),jm(this._db,Ot,Ma,t)}async incrementFavoriteEmojiCount(t){return Vn(t),await this.ready(),qm(this._db,t)}async getTopFavoriteEmoji(t){return ms(t),await this.ready(),(await Vm(this._db,this._custom,t)).map(on)}set customEmoji(t){this._custom=La(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 jo(this._dbName)}async delete(){await this._shutdown(),await Im(this._dbName)}}const Xs=[[-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})),ys=Xs.slice(1),ay=2,Ia=6,mu=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function Ra(e){return e.unicode.includes("")}const ly={"":17,"":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱♀️":4,"🤣":3,"👁️🗨️":2,"😀":1,"😐️":.7,"😃":.6},cy=1e3,uy="🖐️",dy=8,py=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],yu='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',hy=(e,t)=>e<t?-1:e>t?1:0,Da=(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 ${yu}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},fy=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function gy(e){const t=Da(e,"#000"),n=Da(e,"#fff");return t&&n&&fy(t,n)}function my(){const e=Object.entries(ly);try{for(const[t,n]of e)if(gy(t))return n}catch{}return e[0][1]}let vs;const bs=()=>(vs||(vs=new Promise(e=>mu(()=>e(my())))),vs),Zs=new Map,yy="️",vy="\uD83C",by="",wy=127995,ky=57339;function Sy(e,t){if(t===0)return e;const n=e.indexOf(by);return n!==-1?e.substring(0,n)+String.fromCodePoint(wy+t-1)+e.substring(n):(e.endsWith(yy)&&(e=e.substring(0,e.length-1)),e+vy+String.fromCodePoint(ky+t-1))}function Ee(e){e.preventDefault(),e.stopPropagation()}function ws(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function vu(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 $y(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:u,annotation:c})=>({unicode:i,name:a,shortcodes:o,url:r,category:u,annotation:c,id:i||a,skins:s&&n(s)}))}const ni=requestAnimationFrame;let xy=typeof ResizeObserver=="function";function Ay(e,t,n){let i;xy?(i=new ResizeObserver(n),i.observe(e)):ni(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function Na(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let ks;function Ey(e,t,n){let i=!0,s=!1;for(const o of e){const r=n(o);if(!r)continue;const a=Na(r);a===0&&(s=!0),typeof ks>"u"&&(ks=Na(t));const u=a/1.8<ks;Zs.set(o.unicode,u),u||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
|
|
2328
|
+
`;Bi([Ti({type:Number})],Ot.prototype,"splitRatio",2);Bi([Ti({type:Number})],Ot.prototype,"minRatio",2);Bi([Ti({type:Number})],Ot.prototype,"maxRatio",2);Ot=Bi([ml("resizable-divider")],Ot);function Qn(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function ys(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const $m=1,xm=1,$t="emoji",Ft="keyvalue",Ho="favorites",Am="tokens",ou="tokens",Em="unicode",ru="count",Cm="group",Tm="order",au="group-order",Qs="eTag",ki="url",La="skinTone",jt="readonly",qo="readwrite",lu="skinUnicodes",_m="skinUnicodes",Mm="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Pm="en";function Lm(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 Ia(e){return Lm(e,t=>t.unicode)}function Im(e){function t(n,i,s){const o=i?e.createObjectStore(n,{keyPath:i}):e.createObjectStore(n);if(s)for(const[r,[a,u]]of Object.entries(s))o.createIndex(r,a,{multiEntry:u});return o}t(Ft),t($t,Em,{[ou]:[Am,!0],[au]:[[Cm,Tm]],[lu]:[_m,!0]}),t(Ho,void 0,{[ru]:[""]})}const Ys={},ii={},Si={};function cu(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function Rm(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,$m);Ys[e]=s,s.onupgradeneeded=o=>{o.oldVersion<xm&&Im(s.result)},cu(n,i,s)});return t.onclose=()=>jo(e),t}function Dm(e){return ii[e]||(ii[e]=Rm(e)),ii[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 u;i(a,r,c=>{u=c}),r.oncomplete=()=>s(u),r.onerror=()=>o(r.error)})}function jo(e){const t=Ys[e],n=t&&t.result;if(n){n.close();const i=Si[e];if(i)for(const s of i)s()}delete Ys[e],delete ii[e],delete Si[e]}function Bm(e){return new Promise((t,n)=>{jo(e);const i=indexedDB.deleteDatabase(e);cu(t,n,i)})}function Nm(e,t){let n=Si[e];n||(n=Si[e]=[]),n.push(t)}const Om=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 Dt(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||Om.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const Fm=2;function uu(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=Fm)}function Um(e){return e.map(({annotation:n,emoticon:i,group:s,order:o,shortcodes:r,skins:a,tags:u,emoji:c,version:l})=>{const p=[...new Set(uu([...(r||[]).map(Dt).flat(),...(u||[]).map(Dt).flat(),...Dt(n),i]))].sort(),f={annotation:n,group:s,order:o,tags:u,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:b,emoji:h,version:v}of a)f.skinTones.push(b),f.skinUnicodes.push(h),f.skinVersions.push(v)}return f})}function du(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function bt(e,t,n){du(e,"get",t,n)}function pu(e,t,n){du(e,"getAll",t,n)}function Vo(e){e.commit&&e.commit()}function Wm(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 hu(e,t){const n=Wm(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 Km(e){return!await Go(e,Ft,ki)}async function zm(e,t,n){const[i,s]=await Promise.all([Qs,ki].map(o=>Go(e,Ft,o)));return i===n&&s===t}async function Hm(e,t){return je(e,$t,jt,(i,s,o)=>{let r;const a=()=>{i.getAll(r&&IDBKeyRange.lowerBound(r,!0),50).onsuccess=u=>{const c=u.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 fu(e,t,n,i){{const s=Um(t);await je(e,[$t,Ft],qo,([o,r],a)=>{let u,c,l=0;function p(){++l===2&&f()}function f(){if(!(u===i&&c===n)){o.clear();for(const b of s)o.put(b);r.put(i,Qs),r.put(n,ki),Vo(a)}}bt(r,Qs,b=>{u=b,p()}),bt(r,ki,b=>{c=b,p()})})}}async function qm(e,t){return je(e,$t,jt,(n,i,s)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);pu(n.index(au),o,s)})}async function gu(e,t){const n=uu(Dt(t));return n.length?je(e,$t,jt,(i,s,o)=>{const r=[],a=()=>{r.length===n.length&&u()},u=()=>{const c=hu(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);pu(i.index(ou),p,f=>{r.push(f),a()})}}):[]}async function jm(e,t){const n=await gu(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await Hm(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function Vm(e,t){return je(e,$t,jt,(n,i,s)=>bt(n,t,o=>{if(o)return s(o);bt(n.index(lu),t,r=>s(r||null))}))}function Go(e,t,n){return je(e,t,jt,(i,s,o)=>bt(i,n,o))}function Gm(e,t,n,i){return je(e,t,qo,(s,o)=>{s.put(i,n),Vo(o)})}function Qm(e,t){return je(e,Ho,qo,(n,i)=>bt(n,t,s=>{n.put((s||0)+1,t),Vo(i)}))}function Ym(e,t,n){return n===0?[]:je(e,[Ho,$t],jt,([i,s],o,r)=>{const a=[];i.index(ru).openCursor(void 0,"prev").onsuccess=u=>{const c=u.target.result;if(!c)return r(a);function l(b){if(a.push(b),a.length===n)return r(a);c.continue()}const p=c.primaryKey,f=t.byName(p);if(f)return l(f);bt(s,p,b=>{if(b)return l(b);c.continue()})}})}const Yn="";function Jm(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 u=a.get(Yn);u||(u=[],a.set(Yn,u)),u.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(Yn)||[];const a=[],u=[r];for(;u.length;){const l=[...u.shift().entries()].sort((p,f)=>p[0]<f[0]?-1:1);for(const[p,f]of l)p===Yn?a.push(...f):u.push(f)}return a}}const Xm=["name","url"];function Zm(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||Xm.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function Ra(e){Zm(e);const t=(f,b)=>f.name.toLowerCase()<b.name.toLowerCase()?-1:1,n=e.sort(t),s=Jm(e,f=>{const b=new Set;if(f.shortcodes)for(const h of f.shortcodes)for(const v of Dt(h))b.add(v);return b}),o=f=>s(f,!0),r=f=>s(f,!1),a=f=>{const b=Dt(f),h=b.map((v,k)=>(k<b.length-1?o:r)(v));return hu(h,v=>v.name).sort(t)},u=new Map,c=new Map;for(const f of e){c.set(f.name.toLowerCase(),f);for(const b of f.shortcodes||[])u.set(b.toLowerCase(),f)}return{all:n,search:a,byShortcode:f=>u.get(f.toLowerCase()),byName:f=>c.get(f.toLowerCase())}}const ey=typeof wrappedJSObject<"u";function an(e){if(!e)return e;if(ey&&(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 mu(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const ty=["annotation","emoji","group","order","version"];function ny(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||ty.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function yu(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function iy(e){const t=await fetch(e,{method:"HEAD"});yu(t,e);const n=t.headers.get("etag");return mu(n),n}async function Js(e){const t=await fetch(e);yu(t,e);const n=t.headers.get("etag");mu(n);const i=await t.json();return ny(i),[n,i]}function sy(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function oy(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 vu(e){const t=JSON.stringify(e);let n=oy(t);const i=await crypto.subtle.digest("SHA-1",n),s=sy(i);return btoa(s)}async function ry(e,t){let n,i=await iy(t);if(!i){const s=await Js(t);i=s[0],n=s[1],i||(i=await vu(n))}await zm(e,t,i)||(n||(n=(await Js(t))[1]),await fu(e,n,t,i))}async function ay(e,t){let[n,i]=await Js(t);n||(n=await vu(i)),await fu(e,i,t,n)}async function ly(e,t){try{await ry(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class cy{constructor({dataSource:t=Mm,locale:n=Pm,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=Ra(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await Dm(this._dbName);Nm(this._dbName,this._clear);const n=this.dataSource;await Km(t)?await ay(t,n):this._lazyUpdate=ly(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 ys(t),await this.ready(),Ia(await qm(this._db,t)).map(an)}async getEmojiBySearchQuery(t){Qn(t),await this.ready();const n=this._custom.search(t),i=Ia(await gu(this._db,t)).map(an);return[...n,...i]}async getEmojiByShortcode(t){Qn(t),await this.ready();const n=this._custom.byShortcode(t);return n||an(await jm(this._db,t))}async getEmojiByUnicodeOrName(t){Qn(t),await this.ready();const n=this._custom.byName(t);return n||an(await Vm(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Go(this._db,Ft,La)||0}async setPreferredSkinTone(t){return ys(t),await this.ready(),Gm(this._db,Ft,La,t)}async incrementFavoriteEmojiCount(t){return Qn(t),await this.ready(),Qm(this._db,t)}async getTopFavoriteEmoji(t){return ys(t),await this.ready(),(await Ym(this._db,this._custom,t)).map(an)}set customEmoji(t){this._custom=Ra(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 jo(this._dbName)}async delete(){await this._shutdown(),await Bm(this._dbName)}}const Xs=[[-1,"✨","custom"],[0,"😀","smileys-emotion"],[1,"👋","people-body"],[3,"🐱","animals-nature"],[4,"🍎","food-drink"],[5,"🏠️","travel-places"],[6,"⚽","activities"],[7,"📝","objects"],[8,"⛔️","symbols"],[9,"🏁","flags"]].map(([e,t,n])=>({id:e,emoji:t,name:n})),vs=Xs.slice(1),uy=2,Da=6,bu=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function Ba(e){return e.unicode.includes("")}const dy={"":17,"":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱♀️":4,"🤣":3,"👁️🗨️":2,"😀":1,"😐️":.7,"😃":.6},py=1e3,hy="🖐️",fy=8,gy=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],wu='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',my=(e,t)=>e<t?-1:e>t?1:0,Na=(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 ${wu}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},yy=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function vy(e){const t=Na(e,"#000"),n=Na(e,"#fff");return t&&n&&yy(t,n)}function by(){const e=Object.entries(dy);try{for(const[t,n]of e)if(vy(t))return n}catch{}return e[0][1]}let bs;const ws=()=>(bs||(bs=new Promise(e=>bu(()=>e(by())))),bs),Zs=new Map,wy="️",ky="\uD83C",Sy="",$y=127995,xy=57339;function Ay(e,t){if(t===0)return e;const n=e.indexOf(Sy);return n!==-1?e.substring(0,n)+String.fromCodePoint($y+t-1)+e.substring(n):(e.endsWith(wy)&&(e=e.substring(0,e.length-1)),e+ky+String.fromCodePoint(xy+t-1))}function Ce(e){e.preventDefault(),e.stopPropagation()}function ks(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function ku(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 Ey(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:u,annotation:c})=>({unicode:i,name:a,shortcodes:o,url:r,category:u,annotation:c,id:i||a,skins:s&&n(s)}))}const si=requestAnimationFrame;let Cy=typeof ResizeObserver=="function";function Ty(e,t,n){let i;Cy?(i=new ResizeObserver(n),i.observe(e)):si(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function Oa(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let Ss;function _y(e,t,n){let i=!0,s=!1;for(const o of e){const r=n(o);if(!r)continue;const a=Oa(r);a===0&&(s=!0),typeof Ss>"u"&&(Ss=Oa(t));const u=a/1.8<Ss;Zs.set(o.unicode,u),u||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
|
|
2329
2329
|
This is likely due to using \`display:none\` which is unsupported.
|
|
2330
2330
|
If this is a Jest/Vitest environment, you can ignore this warning.
|
|
2331
|
-
For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function Cy(e){return vu(e,t=>t)}function Ty(e){e&&(e.scrollTop=0)}function gn(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function Ba(e){return""+e}function _y(e){const t=document.createElement("template");return t.innerHTML=e,t}const My=new WeakMap,Py=new WeakMap,Ly=Symbol("un-keyed"),Iy="replaceChildren"in Element.prototype;function Ry(e,t){Iy?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function Dy(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 Ny(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=Dy(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&Ry(i,e)}function By(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:r,attributeValuePre:a,attributeValuePost:u}}=n,c=e[o];if(s!==c)if(n.currentExpression=c,r)if(c===null)i.removeAttribute(r);else{const l=a+Ba(c)+u;i.setAttribute(r,l)}else{let l;Array.isArray(c)?Ny(c,n):c instanceof Element?(l=c,i.replaceWith(l)):i.nodeValue=Ba(c),l&&(n.targetNode=l)}}}function Oy(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 A=0;A<p.length;A++)switch(p.charAt(A)){case"<":{p.charAt(A+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],b=gn(o,f,()=>[]);let h,v,k;if(i){const A=/(\S+)="?([^"=]*)$/.exec(p);h=A[1],v=A[2];const C=/^([^">]*)("?)/.exec(e[c+1]);k=C[1],t=t.slice(0,-1*A[0].length),a=C[0].length}else a=0;const $={attributeName:h,attributeValuePre:v,attributeValuePost:k,expressionIndex:c};b.push($),!n&&!i&&(t+=" ")}return{template:_y(t),elementsToBindings:o}}function Oa(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 Fy(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))Oa(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,r=-1;do{const a=t.get(++r);a&&Oa(a,o,n)}while(o=s.nextNode())}return n}function Uy(e){const{template:t,elementsToBindings:n}=gn(My,e,()=>Oy(e)),i=t.cloneNode(!0).content.firstElementChild,s=Fy(i,n);return function(r){return By(r,s),i}}function Wy(e){const t=gn(Py,e,()=>new Map);let n=Ly;function i(o,...r){const a=gn(t,o,()=>new Map);return gn(a,n,()=>Uy(o))(r)}function s(o,r,a){return o.map((u,c)=>{const l=n;n=a(u);try{return r(u,c)}finally{n=l}})}return{map:s,html:i}}function Ky(e,t,n,i,s,o,r,a,u){const{labelWithSkin:c,titleForEmoji:l,unicodeWithSkin:p}=n,{html:f,map:b}=Wy(t);function h(A,C,T){return b(A,(_,R)=>f`<button role="${C?"option":"menuitem"}" aria-selected="${C?R===t.activeSearchItem:null}" aria-label="${c(_,t.currentSkinTone)}" title="${l(_)}" class="${"emoji"+(C&&R===t.activeSearchItem?" active":"")+(_.unicode?"":" custom-emoji")}" id="${`${T}-${_.id}`}" style="${_.unicode?null:`--custom-emoji-background: url(${JSON.stringify(_.url)})`}">${_.unicode?p(_,t.currentSkinTone):""}</button>`,_=>`${T}-${_.id}`)}const k=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">${b(t.skinTones,(A,C)=>f`<div id="skintone-${C}" class="emoji ${C===t.activeSkinTone?"active":""}" aria-selected="${C===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[C]}" aria-label="${t.i18n.skinTones[C]}">${A}</div>`,A=>A)}</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">${b(t.groups,A=>f`<button role="tab" class="nav-button" aria-controls="tab-${A.id}" aria-label="${t.i18n.categories[A.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===A.id}" title="${t.i18n.categories[A.name]}" data-group-id="${A.id}"><div class="nav-emoji emoji">${A.emoji}</div></button>`,A=>A.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">${b(t.currentEmojisWithCategories,(A,C)=>f`<div><div id="menu-label-${C}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:A.category?A.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${C!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(A.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${C}" id="${t.searchMode?"search-results":null}">${h(A.emojis,t.searchMode,"emo")}</div></div>`,A=>A.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${h(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,$=(A,C)=>{for(const T of e.querySelectorAll(`[${A}]`))C(T,T.getAttribute(A))};if(u){e.appendChild(k);for(const A of["click","focusout","input","keydown","keyup"])$(`data-on-${A}`,(C,T)=>{C.addEventListener(A,i[T])});$("data-ref",(A,C)=>{o[C]=A}),r.addEventListener("abort",()=>{e.removeChild(k)})}$("data-action",(A,C)=>{let T=a.get(C);T||a.set(C,T=new WeakSet),T.has(A)||(T.add(A),s[C](A))})}const ki=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function zy(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 b of f)s.add(b);o||(o=!0,ki(r))}}return!0}}),u=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:u}}function Ss(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 Fa=new WeakMap;function Hy(e,t,n){{const i=e.closest(".tabpanel");let s=Fa.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),Fa.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const $s=[],{assign:Qn}=Object;function jy(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:r}=zy(s),a=new Map;Qn(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),Qn(o,t),Qn(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:dy,isRtl:!1,currentGroupIndex:0,groups:ys,databaseLoaded:!1,activeSearchItemId:void 0}),r(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const u=x=>{e.getElementById(x).focus()},c=x=>e.getElementById(`emo-${x.id}`),l=(x,M)=>{n.rootElement.dispatchEvent(new CustomEvent(x,{detail:M,bubbles:!0,composed:!0}))},p=(x,M)=>x.id===M.id,f=(x,M)=>{const{category:N,emojis:B}=x,{category:V,emojis:z}=M;return N!==V?!1:Ss(B,z,p)},b=x=>{Ss(o.currentEmojis,x,p)||(o.currentEmojis=x)},h=x=>{o.searchMode!==x&&(o.searchMode=x)},v=x=>{Ss(o.currentEmojisWithCategories,x,f)||(o.currentEmojisWithCategories=x)},k=(x,M)=>M&&x.skins&&x.skins[M]||x.unicode,C={labelWithSkin:(x,M)=>Cy([x.name||k(x,M),x.annotation,...x.shortcodes||$s].filter(Boolean)).join(", "),titleForEmoji:x=>x.annotation||(x.shortcodes||$s).join(", "),unicodeWithSkin:k},T={onClickSkinToneButton:q,onEmojiClick:Cn,onNavClick:An,onNavKeydown:Ui,onSearchKeydown:Fi,onSkinToneOptionsClick:Tn,onSkinToneOptionsFocusOut:Ve,onSkinToneOptionsKeydown:it,onSkinToneOptionsKeyup:qt,onSearchInput:_n},_={calculateEmojiGridStyle:ee,updateOnIntersection:me};let R=!0;r(()=>{Ky(e,o,C,T,_,n,s,a,R),R=!1}),o.emojiVersion||bs().then(x=>{x||(o.message=o.i18n.emojiUnsupportedMessage)}),r(()=>{async function x(){let M=!1;const N=setTimeout(()=>{M=!0,o.message=o.i18n.loadingMessage},cy);try{await o.database.ready(),o.databaseLoaded=!0}catch(B){console.error(B),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(N),M&&(M=!1,o.message="")}}o.database&&x()}),r(()=>{o.pickerStyle=`
|
|
2331
|
+
For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function My(e){return ku(e,t=>t)}function Py(e){e&&(e.scrollTop=0)}function yn(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function Fa(e){return""+e}function Ly(e){const t=document.createElement("template");return t.innerHTML=e,t}const Iy=new WeakMap,Ry=new WeakMap,Dy=Symbol("un-keyed"),By="replaceChildren"in Element.prototype;function Ny(e,t){By?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function Oy(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 Fy(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=Oy(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&Ny(i,e)}function Uy(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:r,attributeValuePre:a,attributeValuePost:u}}=n,c=e[o];if(s!==c)if(n.currentExpression=c,r)if(c===null)i.removeAttribute(r);else{const l=a+Fa(c)+u;i.setAttribute(r,l)}else{let l;Array.isArray(c)?Fy(c,n):c instanceof Element?(l=c,i.replaceWith(l)):i.nodeValue=Fa(c),l&&(n.targetNode=l)}}}function Wy(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 A=0;A<p.length;A++)switch(p.charAt(A)){case"<":{p.charAt(A+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],b=yn(o,f,()=>[]);let h,v,k;if(i){const A=/(\S+)="?([^"=]*)$/.exec(p);h=A[1],v=A[2];const C=/^([^">]*)("?)/.exec(e[c+1]);k=C[1],t=t.slice(0,-1*A[0].length),a=C[0].length}else a=0;const $={attributeName:h,attributeValuePre:v,attributeValuePost:k,expressionIndex:c};b.push($),!n&&!i&&(t+=" ")}return{template:Ly(t),elementsToBindings:o}}function Ua(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 Ky(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))Ua(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,r=-1;do{const a=t.get(++r);a&&Ua(a,o,n)}while(o=s.nextNode())}return n}function zy(e){const{template:t,elementsToBindings:n}=yn(Iy,e,()=>Wy(e)),i=t.cloneNode(!0).content.firstElementChild,s=Ky(i,n);return function(r){return Uy(r,s),i}}function Hy(e){const t=yn(Ry,e,()=>new Map);let n=Dy;function i(o,...r){const a=yn(t,o,()=>new Map);return yn(a,n,()=>zy(o))(r)}function s(o,r,a){return o.map((u,c)=>{const l=n;n=a(u);try{return r(u,c)}finally{n=l}})}return{map:s,html:i}}function qy(e,t,n,i,s,o,r,a,u){const{labelWithSkin:c,titleForEmoji:l,unicodeWithSkin:p}=n,{html:f,map:b}=Hy(t);function h(A,C,T){return b(A,(_,R)=>f`<button role="${C?"option":"menuitem"}" aria-selected="${C?R===t.activeSearchItem:null}" aria-label="${c(_,t.currentSkinTone)}" title="${l(_)}" class="${"emoji"+(C&&R===t.activeSearchItem?" active":"")+(_.unicode?"":" custom-emoji")}" id="${`${T}-${_.id}`}" style="${_.unicode?null:`--custom-emoji-background: url(${JSON.stringify(_.url)})`}">${_.unicode?p(_,t.currentSkinTone):""}</button>`,_=>`${T}-${_.id}`)}const k=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">${b(t.skinTones,(A,C)=>f`<div id="skintone-${C}" class="emoji ${C===t.activeSkinTone?"active":""}" aria-selected="${C===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[C]}" aria-label="${t.i18n.skinTones[C]}">${A}</div>`,A=>A)}</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">${b(t.groups,A=>f`<button role="tab" class="nav-button" aria-controls="tab-${A.id}" aria-label="${t.i18n.categories[A.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===A.id}" title="${t.i18n.categories[A.name]}" data-group-id="${A.id}"><div class="nav-emoji emoji">${A.emoji}</div></button>`,A=>A.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">${b(t.currentEmojisWithCategories,(A,C)=>f`<div><div id="menu-label-${C}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:A.category?A.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${C!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(A.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${C}" id="${t.searchMode?"search-results":null}">${h(A.emojis,t.searchMode,"emo")}</div></div>`,A=>A.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${h(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,$=(A,C)=>{for(const T of e.querySelectorAll(`[${A}]`))C(T,T.getAttribute(A))};if(u){e.appendChild(k);for(const A of["click","focusout","input","keydown","keyup"])$(`data-on-${A}`,(C,T)=>{C.addEventListener(A,i[T])});$("data-ref",(A,C)=>{o[C]=A}),r.addEventListener("abort",()=>{e.removeChild(k)})}$("data-action",(A,C)=>{let T=a.get(C);T||a.set(C,T=new WeakSet),T.has(A)||(T.add(A),s[C](A))})}const $i=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function jy(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,$i(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 b of f)s.add(b);o||(o=!0,$i(r))}}return!0}}),u=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:u}}function $s(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 Wa=new WeakMap;function Vy(e,t,n){{const i=e.closest(".tabpanel");let s=Wa.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),Wa.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const xs=[],{assign:Jn}=Object;function Gy(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:r}=jy(s),a=new Map;Jn(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),Jn(o,t),Jn(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:fy,isRtl:!1,currentGroupIndex:0,groups:vs,databaseLoaded:!1,activeSearchItemId:void 0}),r(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const u=x=>{e.getElementById(x).focus()},c=x=>e.getElementById(`emo-${x.id}`),l=(x,M)=>{n.rootElement.dispatchEvent(new CustomEvent(x,{detail:M,bubbles:!0,composed:!0}))},p=(x,M)=>x.id===M.id,f=(x,M)=>{const{category:B,emojis:N}=x,{category:V,emojis:z}=M;return B!==V?!1:$s(N,z,p)},b=x=>{$s(o.currentEmojis,x,p)||(o.currentEmojis=x)},h=x=>{o.searchMode!==x&&(o.searchMode=x)},v=x=>{$s(o.currentEmojisWithCategories,x,f)||(o.currentEmojisWithCategories=x)},k=(x,M)=>M&&x.skins&&x.skins[M]||x.unicode,C={labelWithSkin:(x,M)=>My([x.name||k(x,M),x.annotation,...x.shortcodes||xs].filter(Boolean)).join(", "),titleForEmoji:x=>x.annotation||(x.shortcodes||xs).join(", "),unicodeWithSkin:k},T={onClickSkinToneButton:j,onEmojiClick:_n,onNavClick:Cn,onNavKeydown:Wi,onSearchKeydown:Ui,onSkinToneOptionsClick:Mn,onSkinToneOptionsFocusOut:Ge,onSkinToneOptionsKeydown:st,onSkinToneOptionsKeyup:Gt,onSearchInput:Pn},_={calculateEmojiGridStyle:ee,updateOnIntersection:ye};let R=!0;r(()=>{qy(e,o,C,T,_,n,s,a,R),R=!1}),o.emojiVersion||ws().then(x=>{x||(o.message=o.i18n.emojiUnsupportedMessage)}),r(()=>{async function x(){let M=!1;const B=setTimeout(()=>{M=!0,o.message=o.i18n.loadingMessage},py);try{await o.database.ready(),o.databaseLoaded=!0}catch(N){console.error(N),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(B),M&&(M=!1,o.message="")}}o.database&&x()}),r(()=>{o.pickerStyle=`
|
|
2332
2332
|
--num-groups: ${o.groups.length};
|
|
2333
2333
|
--indicator-opacity: ${o.searchMode?0:1};
|
|
2334
|
-
--num-skintones: ${Ia};`}),r(()=>{o.customEmoji&&o.database&&O()}),r(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==Xs&&(o.groups=Xs):o.groups!==ys&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=ys)}),r(()=>{async function x(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}x()}),r(()=>{o.skinTones=Array(Ia).fill().map((x,M)=>Sy(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 x(){const{database:M}=o,N=(await Promise.all(py.map(B=>M.getEmojiByUnicodeOrName(B)))).filter(Boolean);o.defaultFavoriteEmojis=N}o.databaseLoaded&&x()});function O(){const{customEmoji:x,database:M}=o,N=x||$s;M.customEmoji!==N&&(M.customEmoji=N)}r(()=>{async function x(){O();const{database:M,defaultFavoriteEmojis:N,numColumns:B}=o,V=await M.getTopFavoriteEmoji(B),z=await nt(vu([...V,...N],le=>le.unicode||le.name).slice(0,B));o.currentFavorites=z}o.databaseLoaded&&o.defaultFavoriteEmojis&&x()});function ee(x){Ay(x,s,()=>{{const M=getComputedStyle(n.rootElement),N=parseInt(M.getPropertyValue("--num-columns"),10),B=M.getPropertyValue("direction")==="rtl";o.numColumns=N,o.isRtl=B}})}function me(x){Hy(x,s,M=>{for(const{target:N,isIntersecting:B}of M)N.classList.toggle("onscreen",B)})}r(()=>{async function x(){const{searchText:M,currentGroup:N,databaseLoaded:B,customEmoji:V}=o;if(!B)o.currentEmojis=[],o.searchMode=!1;else if(M.length>=ay){const z=await Oi(M);o.searchText===M&&(b(z),h(!0))}else{const{id:z}=N;if(z!==-1||V&&V.length){const le=await Bi(z);o.currentGroup.id===z&&(b(le),h(!1))}}}x()});const qe=()=>{ni(()=>Ty(n.tabpanelElement))};r(()=>{const{currentEmojis:x,emojiVersion:M}=o,N=x.filter(B=>B.unicode).filter(B=>Ra(B)&&!Zs.has(B.unicode));if(!M&&N.length)b(x),ni(()=>Z(N));else{const B=M?x:x.filter(jt);b(B),qe()}});function Z(x){Ey(x,n.baselineEmoji,c)?qe():o.currentEmojis=[...o.currentEmojis]}function jt(x){return!x.unicode||!Ra(x)||Zs.get(x.unicode)}async function $t(x){const M=o.emojiVersion||await bs();return x.filter(({version:N})=>!N||N<=M)}async function nt(x){return $y(x,o.emojiVersion||await bs())}async function Bi(x){const M=x===-1?o.customEmoji:await o.database.getEmojiByGroup(x);return nt(await $t(M))}async function Oi(x){return nt(await $t(await o.database.getEmojiBySearchQuery(x)))}r(()=>{}),r(()=>{function x(){const{searchMode:N,currentEmojis:B}=o;if(N)return[{category:"",emojis:B}];const V=new Map;for(const z of B){const le=z.category||"";let Ge=V.get(le);Ge||(Ge=[],V.set(le,Ge)),Ge.push(z)}return[...V.entries()].map(([z,le])=>({category:z,emojis:le})).sort((z,le)=>o.customCategorySorting(z.category,le.category))}const M=x();v(M)}),r(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),r(()=>{const{rawSearchText:x}=o;mu(()=>{o.searchText=(x||"").trim(),o.activeSearchItem=-1})});function Fi(x){if(!o.searchMode||!o.currentEmojis.length)return;const M=N=>{Ee(x),o.activeSearchItem=ws(N,o.activeSearchItem,o.currentEmojis)};switch(x.key){case"ArrowDown":return M(!1);case"ArrowUp":return M(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return Ee(x),Q(o.currentEmojis[o.activeSearchItem].id)}}function An(x){const{target:M}=x,N=M.closest(".nav-button");if(!N)return;const B=parseInt(N.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(V=>V.id===B)}function Ui(x){const{target:M,key:N}=x,B=V=>{V&&(Ee(x),V.focus())};switch(N){case"ArrowLeft":return B(M.previousElementSibling);case"ArrowRight":return B(M.nextElementSibling);case"Home":return B(M.parentElement.firstElementChild);case"End":return B(M.parentElement.lastElementChild)}}async function En(x){const M=await o.database.getEmojiByUnicodeOrName(x),N=[...o.currentEmojis,...o.currentFavorites].find(V=>V.id===x),B=N.unicode&&k(N,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(x),{emoji:M,skinTone:o.currentSkinTone,...B&&{unicode:B},...N.name&&{name:N.name}}}async function Q(x){const M=En(x);l("emoji-click-sync",M),l("emoji-click",await M)}function Cn(x){const{target:M}=x;if(!M.classList.contains("emoji"))return;Ee(x);const N=M.id.substring(4);Q(N)}function Y(x){o.currentSkinTone=x,o.skinTonePickerExpanded=!1,u("skintone-button"),l("skin-tone-change",{skinTone:x}),o.database.setPreferredSkinTone(x)}function Tn(x){const{target:{id:M}}=x,N=M&&M.match(/^skintone-(\d)/);if(!N)return;Ee(x);const B=parseInt(N[1],10);Y(B)}function q(x){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(Ee(x),ni(()=>u("skintone-list")))}r(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function it(x){if(!o.skinTonePickerExpanded)return;const M=async N=>{Ee(x),o.activeSkinTone=N};switch(x.key){case"ArrowUp":return M(ws(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return M(ws(!1,o.activeSkinTone,o.skinTones));case"Home":return M(0);case"End":return M(o.skinTones.length-1);case"Enter":return Ee(x),Y(o.activeSkinTone);case"Escape":return Ee(x),o.skinTonePickerExpanded=!1,u("skintone-button")}}function qt(x){if(o.skinTonePickerExpanded&&x.key===" ")return Ee(x),Y(o.activeSkinTone)}async function Ve(x){const{relatedTarget:M}=x;(!M||M.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function _n(x){o.rawSearchText=x.target.value}return{$set(x){Qn(o,x)},$destroy(){i.abort()}}}const qy="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Vy="en";var Gy={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"}},Qy=':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 bu=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Yy=`:host{--emoji-font-family:${yu}}`;class Go extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=Qy+Yy,this.shadowRoot.appendChild(n),this._ctx={locale:Vy,dataSource:qy,skinToneEmoji:uy,customCategorySorting:hy,customEmoji:null,i18n:Gy,emojiVersion:null,...t};for(const i of bu)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){Ua(this),this._cmp||(this._cmp=jy(this.shadowRoot,this._ctx))}disconnectedCallback(){Ua(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 ry({locale:t,dataSource:n}))}_dbFlush(){ki(()=>this._dbCreate())}}const wu={};for(const e of bu)wu[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(Go.prototype,wu);function Ua(e){e instanceof Go||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Go);function Xy(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 Wa(e){e.style.height="44px",e.style.overflowY="hidden"}const Zy=5e3;function Jy(e){return e?e.active?d`
|
|
2334
|
+
--num-skintones: ${Da};`}),r(()=>{o.customEmoji&&o.database&&O()}),r(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==Xs&&(o.groups=Xs):o.groups!==vs&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=vs)}),r(()=>{async function x(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}x()}),r(()=>{o.skinTones=Array(Da).fill().map((x,M)=>Ay(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 x(){const{database:M}=o,B=(await Promise.all(gy.map(N=>M.getEmojiByUnicodeOrName(N)))).filter(Boolean);o.defaultFavoriteEmojis=B}o.databaseLoaded&&x()});function O(){const{customEmoji:x,database:M}=o,B=x||xs;M.customEmoji!==B&&(M.customEmoji=B)}r(()=>{async function x(){O();const{database:M,defaultFavoriteEmojis:B,numColumns:N}=o,V=await M.getTopFavoriteEmoji(N),z=await it(ku([...V,...B],le=>le.unicode||le.name).slice(0,N));o.currentFavorites=z}o.databaseLoaded&&o.defaultFavoriteEmojis&&x()});function ee(x){Ty(x,s,()=>{{const M=getComputedStyle(n.rootElement),B=parseInt(M.getPropertyValue("--num-columns"),10),N=M.getPropertyValue("direction")==="rtl";o.numColumns=B,o.isRtl=N}})}function ye(x){Vy(x,s,M=>{for(const{target:B,isIntersecting:N}of M)B.classList.toggle("onscreen",N)})}r(()=>{async function x(){const{searchText:M,currentGroup:B,databaseLoaded:N,customEmoji:V}=o;if(!N)o.currentEmojis=[],o.searchMode=!1;else if(M.length>=uy){const z=await Fi(M);o.searchText===M&&(b(z),h(!0))}else{const{id:z}=B;if(z!==-1||V&&V.length){const le=await Oi(z);o.currentGroup.id===z&&(b(le),h(!1))}}}x()});const Ve=()=>{si(()=>Py(n.tabpanelElement))};r(()=>{const{currentEmojis:x,emojiVersion:M}=o,B=x.filter(N=>N.unicode).filter(N=>Ba(N)&&!Zs.has(N.unicode));if(!M&&B.length)b(x),si(()=>X(B));else{const N=M?x:x.filter(Vt);b(N),Ve()}});function X(x){_y(x,n.baselineEmoji,c)?Ve():o.currentEmojis=[...o.currentEmojis]}function Vt(x){return!x.unicode||!Ba(x)||Zs.get(x.unicode)}async function xt(x){const M=o.emojiVersion||await ws();return x.filter(({version:B})=>!B||B<=M)}async function it(x){return Ey(x,o.emojiVersion||await ws())}async function Oi(x){const M=x===-1?o.customEmoji:await o.database.getEmojiByGroup(x);return it(await xt(M))}async function Fi(x){return it(await xt(await o.database.getEmojiBySearchQuery(x)))}r(()=>{}),r(()=>{function x(){const{searchMode:B,currentEmojis:N}=o;if(B)return[{category:"",emojis:N}];const V=new Map;for(const z of N){const le=z.category||"";let Qe=V.get(le);Qe||(Qe=[],V.set(le,Qe)),Qe.push(z)}return[...V.entries()].map(([z,le])=>({category:z,emojis:le})).sort((z,le)=>o.customCategorySorting(z.category,le.category))}const M=x();v(M)}),r(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),r(()=>{const{rawSearchText:x}=o;bu(()=>{o.searchText=(x||"").trim(),o.activeSearchItem=-1})});function Ui(x){if(!o.searchMode||!o.currentEmojis.length)return;const M=B=>{Ce(x),o.activeSearchItem=ks(B,o.activeSearchItem,o.currentEmojis)};switch(x.key){case"ArrowDown":return M(!1);case"ArrowUp":return M(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return Ce(x),Q(o.currentEmojis[o.activeSearchItem].id)}}function Cn(x){const{target:M}=x,B=M.closest(".nav-button");if(!B)return;const N=parseInt(B.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(V=>V.id===N)}function Wi(x){const{target:M,key:B}=x,N=V=>{V&&(Ce(x),V.focus())};switch(B){case"ArrowLeft":return N(M.previousElementSibling);case"ArrowRight":return N(M.nextElementSibling);case"Home":return N(M.parentElement.firstElementChild);case"End":return N(M.parentElement.lastElementChild)}}async function Tn(x){const M=await o.database.getEmojiByUnicodeOrName(x),B=[...o.currentEmojis,...o.currentFavorites].find(V=>V.id===x),N=B.unicode&&k(B,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(x),{emoji:M,skinTone:o.currentSkinTone,...N&&{unicode:N},...B.name&&{name:B.name}}}async function Q(x){const M=Tn(x);l("emoji-click-sync",M),l("emoji-click",await M)}function _n(x){const{target:M}=x;if(!M.classList.contains("emoji"))return;Ce(x);const B=M.id.substring(4);Q(B)}function Y(x){o.currentSkinTone=x,o.skinTonePickerExpanded=!1,u("skintone-button"),l("skin-tone-change",{skinTone:x}),o.database.setPreferredSkinTone(x)}function Mn(x){const{target:{id:M}}=x,B=M&&M.match(/^skintone-(\d)/);if(!B)return;Ce(x);const N=parseInt(B[1],10);Y(N)}function j(x){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(Ce(x),si(()=>u("skintone-list")))}r(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function st(x){if(!o.skinTonePickerExpanded)return;const M=async B=>{Ce(x),o.activeSkinTone=B};switch(x.key){case"ArrowUp":return M(ks(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return M(ks(!1,o.activeSkinTone,o.skinTones));case"Home":return M(0);case"End":return M(o.skinTones.length-1);case"Enter":return Ce(x),Y(o.activeSkinTone);case"Escape":return Ce(x),o.skinTonePickerExpanded=!1,u("skintone-button")}}function Gt(x){if(o.skinTonePickerExpanded&&x.key===" ")return Ce(x),Y(o.activeSkinTone)}async function Ge(x){const{relatedTarget:M}=x;(!M||M.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function Pn(x){o.rawSearchText=x.target.value}return{$set(x){Jn(o,x)},$destroy(){i.abort()}}}const Qy="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Yy="en";var Jy={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"}},Xy=':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 Su=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Zy=`:host{--emoji-font-family:${wu}}`;class Qo extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=Xy+Zy,this.shadowRoot.appendChild(n),this._ctx={locale:Yy,dataSource:Qy,skinToneEmoji:hy,customCategorySorting:my,customEmoji:null,i18n:Jy,emojiVersion:null,...t};for(const i of Su)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){Ka(this),this._cmp||(this._cmp=Gy(this.shadowRoot,this._ctx))}disconnectedCallback(){Ka(this),$i(()=>{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 cy({locale:t,dataSource:n}))}_dbFlush(){$i(()=>this._dbCreate())}}const $u={};for(const e of Su)$u[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(Qo.prototype,$u);function Ka(e){e instanceof Qo||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Qo);function ev(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 za(e){e.style.height="44px",e.style.overflowY="hidden"}const tv=5e3;function nv(e){return e?e.active?d`
|
|
2335
2335
|
<div class="callout info compaction-indicator compaction-indicator--active">
|
|
2336
2336
|
${D.loader} Compacting context...
|
|
2337
2337
|
</div>
|
|
2338
|
-
`:e.completedAt&&Date.now()-e.completedAt<
|
|
2338
|
+
`:e.completedAt&&Date.now()-e.completedAt<tv?d`
|
|
2339
2339
|
<div class="callout success compaction-indicator compaction-indicator--complete">
|
|
2340
2340
|
${D.check} Context compacted
|
|
2341
2341
|
</div>
|
|
2342
|
-
`:S:S}const
|
|
2342
|
+
`:S:S}const We=5*1024*1024;function Ke(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Se(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 iv=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function xu(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function Au(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||iv.test(e.name)}function Eu(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function Cu(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function sv(e,t){if(!t.onAttachmentsChange)return;const n=document.querySelector(".chat");if(xu(e)){if(e.size>We){n&&Se(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:Ke(),dataUrl:i.result,mimeType:e.type};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(Au(e)){if(e.size>We){n&&Se(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:Ke(),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(Eu(e)){if(e.size>We){n&&Se(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:Ke(),dataUrl:i.result,mimeType:"application/pdf",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(Cu(e)){if(e.size>We){n&&Se(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:Ke(),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&&Se(n,`Unsupported file type: ${e.name}. Use the Files page to upload to workspace.`)}function ov(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(xu(r)){if(!t.onAttachmentsChange)continue;if(r.size>We){Se(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 u=a.result,c={id:Ke(),dataUrl:u,mimeType:r.type},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsDataURL(r)}else if(Au(r)){if(!t.onAttachmentsChange)continue;if(r.size>We){Se(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 u=a.result,c={id:Ke(),dataUrl:"",mimeType:r.type||"text/plain",fileName:r.name,textContent:u},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsText(r)}else if(Eu(r)){if(!t.onAttachmentsChange)continue;if(r.size>We){Se(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 u=a.result,c={id:Ke(),dataUrl:u,mimeType:"application/pdf",fileName:r.name},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsDataURL(r)}else if(Cu(r)){if(!t.onAttachmentsChange)continue;if(r.size>We){Se(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 u=a.result,c={id:Ke(),dataUrl:u,mimeType:r.type||"video/mp4",fileName:r.name},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsDataURL(r)}else Se(n,`Unsupported file type: ${r.name}. Use the Files page to upload to workspace.`)}}function rv(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function av(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function lv(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 u=n[a];(u.type.startsWith("image/")||u.type.startsWith("video/"))&&i.push(u)}if(i.length!==0){e.preventDefault();for(const a of i){const u=a.getAsFile();if(!u)continue;const c=u.type.startsWith("video/")?"Video":"Image";if(u.size>We){const p=((r=(o=e.target)==null?void 0:o.closest)==null?void 0:r.call(o,".chat"))??document.querySelector(".chat");p&&Se(p,`${c} too large (${(u.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const l=new FileReader;l.onload=()=>{var v;const p=l.result,f=u.type.startsWith("video/"),b={id:Ke(),dataUrl:p,mimeType:u.type,fileName:f?u.name||"video.mp4":void 0},h=t.attachments??[];(v=t.onAttachmentsChange)==null||v.call(t,[...h,b])},l.readAsDataURL(u)}}}function cv(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 uv(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,u=t.draft.slice(0,r),c=t.draft.slice(a);t.onDraftChange(u+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 f=r+i.length;o.setSelectionRange(f,f)})}function dv(e){const t=e.attachments??[];return t.length===0?S:d`
|
|
2343
2343
|
<div class="chat-attachments">
|
|
2344
2344
|
${t.map(n=>{var i;return n.fileName?d`
|
|
2345
2345
|
<div class="chat-attachment chat-attachment--file">
|
|
@@ -2372,7 +2372,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
|
|
|
2372
2372
|
</div>
|
|
2373
2373
|
`})}
|
|
2374
2374
|
</div>
|
|
2375
|
-
`}function
|
|
2375
|
+
`}function Tu(e){var f,b,h;const t=e.connected,n=e.sending||e.stream!==null,i=!!(e.canAbort&&e.onAbort),s=(b=(f=e.sessions)==null?void 0:f.sessions)==null?void 0:b.find(v=>v.key===e.sessionKey),o=(s==null?void 0:s.reasoningLevel)??"off",r=e.showThinking&&o!=="off";e.assistantName,e.assistantAvatar??e.assistantAvatarUrl;const a=(((h=e.attachments)==null?void 0:h.length)??0)>0,u=e.connected?a?"Add a message...":"Message...":"Connecting…",c=e.splitRatio??.6,l=!!(e.sidebarOpen&&e.onCloseSidebar),p=d`
|
|
2376
2376
|
<div
|
|
2377
2377
|
class="chat-thread"
|
|
2378
2378
|
role="log"
|
|
@@ -2383,20 +2383,20 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
|
|
|
2383
2383
|
${e.loadingOlder?d`<span class="chat-load-more__spinner">${D.loader}</span> Loading older messages…`:d`<button class="chat-load-more__btn" type="button" @click=${e.onLoadOlder}>Load older messages</button>`}
|
|
2384
2384
|
</div>`:S}
|
|
2385
2385
|
${e.loading?d`<div class="muted">Loading chat…</div>`:S}
|
|
2386
|
-
${
|
|
2386
|
+
${jf(vv(e),v=>v.key,v=>v.kind==="interim"?mm(v.text):v.kind==="reading-indicator"?gm():v.kind==="stream"?ym(v.text,v.startedAt,e.onOpenSidebar):v.kind==="group"?vm(v,{onOpenSidebar:e.onOpenSidebar,showReasoning:r,assistantName:e.assistantName}):S)}
|
|
2387
2387
|
</div>
|
|
2388
2388
|
`;return d`
|
|
2389
2389
|
<section
|
|
2390
2390
|
class="card chat"
|
|
2391
|
-
@drop=${v=>
|
|
2392
|
-
@dragover=${
|
|
2393
|
-
@dragleave=${
|
|
2391
|
+
@drop=${v=>ov(v,e)}
|
|
2392
|
+
@dragover=${rv}
|
|
2393
|
+
@dragleave=${av}
|
|
2394
2394
|
>
|
|
2395
2395
|
${e.disabledReason?d`<div class="callout">${e.disabledReason}</div>`:S}
|
|
2396
2396
|
|
|
2397
2397
|
${e.error?d`<div class="callout danger">${e.error}</div>`:S}
|
|
2398
2398
|
|
|
2399
|
-
${
|
|
2399
|
+
${nv(e.compactionStatus)}
|
|
2400
2400
|
|
|
2401
2401
|
${e.focusMode?d`
|
|
2402
2402
|
<button
|
|
@@ -2437,7 +2437,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
|
|
|
2437
2437
|
@resize=${v=>{var k;return(k=e.onSplitRatioChange)==null?void 0:k.call(e,v.detail.splitRatio)}}
|
|
2438
2438
|
></resizable-divider>
|
|
2439
2439
|
<div class="chat-sidebar">
|
|
2440
|
-
${
|
|
2440
|
+
${wm({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
|
|
2441
2441
|
${e.sidebarContent}
|
|
2442
2442
|
\`\`\``)}})}
|
|
2443
2443
|
</div>
|
|
@@ -2457,12 +2457,12 @@ ${e.sidebarContent}
|
|
|
2457
2457
|
`:S}
|
|
2458
2458
|
|
|
2459
2459
|
<div class="chat-compose">
|
|
2460
|
-
${
|
|
2460
|
+
${dv(e)}
|
|
2461
2461
|
<div class="chat-compose__row">
|
|
2462
2462
|
<button
|
|
2463
2463
|
class="chat-compose__emoji"
|
|
2464
2464
|
type="button"
|
|
2465
|
-
@click=${
|
|
2465
|
+
@click=${cv}
|
|
2466
2466
|
aria-label="Emoji"
|
|
2467
2467
|
title="Emoji"
|
|
2468
2468
|
>
|
|
@@ -2483,16 +2483,16 @@ ${e.sidebarContent}
|
|
|
2483
2483
|
multiple
|
|
2484
2484
|
accept="image/*,video/*,.pdf,.md,.txt,.csv,.json,.xml,.html,.css,.js,.ts,.py,.sh,.yaml,.yml,.toml,.ini,.cfg,.log,.sql"
|
|
2485
2485
|
style="display:none"
|
|
2486
|
-
@change=${v=>{const k=v.target,$=k.files;if(!(!$||$.length===0||!e.onAttachmentsChange)){for(let A=0;A<$.length;A++)
|
|
2486
|
+
@change=${v=>{const k=v.target,$=k.files;if(!(!$||$.length===0||!e.onAttachmentsChange)){for(let A=0;A<$.length;A++)sv($[A],e);k.value=""}}}
|
|
2487
2487
|
/>
|
|
2488
2488
|
<label class="field chat-compose__field">
|
|
2489
2489
|
<span>Message</span>
|
|
2490
2490
|
<textarea
|
|
2491
2491
|
.value=${e.draft}
|
|
2492
2492
|
?disabled=${!e.connected}
|
|
2493
|
-
@keydown=${v=>{v.key==="Enter"&&(v.isComposing||v.keyCode===229||v.shiftKey||e.connected&&(v.preventDefault(),t&&(e.onSend(),
|
|
2494
|
-
@input=${v=>{const k=v.target;e.onDraftChange(k.value),
|
|
2495
|
-
@paste=${v=>
|
|
2493
|
+
@keydown=${v=>{v.key==="Enter"&&(v.isComposing||v.keyCode===229||v.shiftKey||e.connected&&(v.preventDefault(),t&&(e.onSend(),za(v.target))))}}
|
|
2494
|
+
@input=${v=>{const k=v.target;e.onDraftChange(k.value),ev(k)}}
|
|
2495
|
+
@paste=${v=>lv(v,e)}
|
|
2496
2496
|
placeholder=${u}
|
|
2497
2497
|
></textarea>
|
|
2498
2498
|
</label>
|
|
@@ -2509,7 +2509,7 @@ ${e.sidebarContent}
|
|
|
2509
2509
|
<button
|
|
2510
2510
|
class="btn btn--icon chat-compose__send primary"
|
|
2511
2511
|
?disabled=${!e.connected}
|
|
2512
|
-
@click=${v=>{var $;e.onSend();const k=($=v.target.closest(".chat-compose"))==null?void 0:$.querySelector("textarea");k&&
|
|
2512
|
+
@click=${v=>{var $;e.onSend();const k=($=v.target.closest(".chat-compose"))==null?void 0:$.querySelector("textarea");k&&za(k)}}
|
|
2513
2513
|
aria-label="${n?"Queue":"Send"}"
|
|
2514
2514
|
title="${n?"Queue message":"Send (Enter)"}"
|
|
2515
2515
|
>
|
|
@@ -2518,13 +2518,13 @@ ${e.sidebarContent}
|
|
|
2518
2518
|
</div>
|
|
2519
2519
|
<div class="emoji-picker-popup">
|
|
2520
2520
|
<emoji-picker
|
|
2521
|
-
@emoji-click=${v=>
|
|
2521
|
+
@emoji-click=${v=>uv(v,e)}
|
|
2522
2522
|
></emoji-picker>
|
|
2523
2523
|
</div>
|
|
2524
|
-
${e.publicMode?S:
|
|
2524
|
+
${e.publicMode?S:mv(e)}
|
|
2525
2525
|
</div>
|
|
2526
2526
|
</section>
|
|
2527
|
-
`}const
|
|
2527
|
+
`}const pv=[{id:"claude-opus-4-6",shortName:"Opus",description:"Most capable"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet",description:"Fast & capable"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku",description:"Fastest"}];function hv(e){const t=new Set(e.filter(n=>n.provider==="anthropic").map(n=>n.id));return pv.filter(n=>t.has(n.id)).map(n=>({key:`anthropic/${n.id}`,...n}))}const fv=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function gv(e){var s;const t=e.currentTarget,n=(s=t.closest(".chat-model-bar"))==null?void 0:s.querySelector(".chat-settings-menu");if(!n)return;const i=n.classList.contains("active");if(document.querySelectorAll(".chat-settings-menu.active").forEach(o=>o.classList.remove("active")),!i){n.classList.add("active");const o=r=>{!n.contains(r.target)&&r.target!==t&&!t.contains(r.target)&&(n.classList.remove("active"),document.removeEventListener("click",o))};requestAnimationFrame(()=>document.addEventListener("click",o))}}function mv(e){if(!e.connected)return S;const t=e.modelCatalog??[],n=hv(t);if(n.length===0)return S;const i=e.modelProvider&&e.model?`${e.modelProvider}/${e.model}`:null,s=e.thinkingLevel??"off",o=e.verboseLevel==="on"||e.verboseLevel==="full",r=e.fillerEnabled===!0;return d`
|
|
2528
2528
|
<div class="chat-model-bar">
|
|
2529
2529
|
<div class="chat-model-bar__select">
|
|
2530
2530
|
<select
|
|
@@ -2545,7 +2545,7 @@ ${e.sidebarContent}
|
|
|
2545
2545
|
.value=${s}
|
|
2546
2546
|
@change=${a=>{const u=a.target.value;e.onThinkingLevelChange&&e.onThinkingLevelChange(u)}}
|
|
2547
2547
|
>
|
|
2548
|
-
${
|
|
2548
|
+
${fv.map(a=>d`
|
|
2549
2549
|
<option value=${a.value} ?selected=${a.value===s}>
|
|
2550
2550
|
Thinking: ${a.label}
|
|
2551
2551
|
</option>
|
|
@@ -2555,7 +2555,7 @@ ${e.sidebarContent}
|
|
|
2555
2555
|
<button
|
|
2556
2556
|
class="chat-model-bar__settings-btn"
|
|
2557
2557
|
type="button"
|
|
2558
|
-
@click=${
|
|
2558
|
+
@click=${gv}
|
|
2559
2559
|
aria-label="Message settings"
|
|
2560
2560
|
title="Message settings"
|
|
2561
2561
|
>
|
|
@@ -2582,9 +2582,9 @@ ${e.sidebarContent}
|
|
|
2582
2582
|
</label>
|
|
2583
2583
|
</div>
|
|
2584
2584
|
</div>
|
|
2585
|
-
`}function
|
|
2585
|
+
`}function yv(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=Cl(i.message),o=Tl(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 vv(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],u=Cl(a);if(!s&&u.role.toLowerCase()==="toolresult"){const c=a,p=(Array.isArray(c.content)?c.content:[]).filter(f=>f.type==="image");p.length>0&&t.push({kind:"message",key:As(a,r),message:{role:"assistant",content:p,timestamp:u.timestamp}});continue}t.push({kind:"message",key:As(a,r),message:a})}if(s)for(let r=0;r<i.length;r++)t.push({kind:"message",key:As(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))??[],u=a.length>0?r.text?`${a.join(", ")}
|
|
2586
2586
|
|
|
2587
|
-
${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,message:{role:"user",content:[{type:"text",text:u}],timestamp:r.createdAt}})}return
|
|
2587
|
+
${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,message:{role:"user",content:[{type:"text",text:u}],timestamp:r.createdAt}})}return yv(t)}function As(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 bv=d`<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 wv(e){if(!e.connected)return d`
|
|
2588
2588
|
<div class="setup-container">
|
|
2589
2589
|
<div class="setup-card">
|
|
2590
2590
|
<div class="setup-spinner"></div>
|
|
@@ -2597,20 +2597,20 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2597
2597
|
target="_blank"
|
|
2598
2598
|
rel="noopener"
|
|
2599
2599
|
title="Open public chat in new tab"
|
|
2600
|
-
>Public ${
|
|
2600
|
+
>Public ${bv}</a>`:S;return d`
|
|
2601
2601
|
<div class="setup-container setup-container--full chat-page">
|
|
2602
|
-
${
|
|
2602
|
+
${kt("Chat",e.wsProps)}
|
|
2603
2603
|
${t}
|
|
2604
2604
|
<div class="chat-viewport">
|
|
2605
|
-
${
|
|
2605
|
+
${Tu(e)}
|
|
2606
2606
|
</div>
|
|
2607
2607
|
</div>
|
|
2608
|
-
`}function
|
|
2609
|
-
${
|
|
2610
|
-
${
|
|
2611
|
-
${
|
|
2612
|
-
${t?
|
|
2613
|
-
`}function
|
|
2608
|
+
`}function kv(e){return e?`${Sl(e)} (${_i(e)})`:"n/a"}function _u(e){const t=e.state??{},n=t.lastStatus??"n/a",i=t.lastRunAtMs?_i(t.lastRunAtMs):"never";return`${n} · last ${i}`}function Mu(e){const t=e.schedule;return t.kind==="at"?`One-time: ${Sl(t.atMs)}`:t.kind==="every"?`Every ${$l(t.everyMs)}`:Sv(t.expr,t.tz)}function Sv(e,t){const n=e.trim().split(/\s+/);if(n.length!==5)return e;const[i,s,o,r,a]=n,u=t?` (${t.replace(/^.*\//,"").replace(/_/g," ")})`:"",c=(v,k)=>new Date(2e3,0,1,v,k).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),l=/^\d{1,2}$/.test(i)?parseInt(i,10):null,p=Ha(s);if(l===null||!p)return`${e}${t?` (${t})`:""}`;const f=p.map(v=>c(v,l)),b=f.length<=3?f.join(" & "):`${f.slice(0,-1).join(", ")} & ${f[f.length-1]}`,h=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];if(o==="*"&&r==="*"){if(a==="*")return`Daily at ${b}${u}`;if(a==="1-5")return`Weekdays at ${b}${u}`;if(a==="0,6"||a==="6,0")return`Weekends at ${b}${u}`;const v=Ha(a);if(v)return`${v.map($=>h[$%7]??String($)).join(", ")} at ${b}${u}`}return`${e}${t?` (${t})`:""}`}function Ha(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 $v(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 qa(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 ge=null;function xv(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 Av(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 Ev(e){return e.split(",").map(n=>n.trim()).filter(Boolean).map(n=>n.toLowerCase()==="admins"?"All admins":n).join(", ")}function Cv(e){return e||"Default"}const Tv=d`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,_v=d`<svg viewBox="0 0 24 24"><rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/></svg>`,Mv=d`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,Yo=d`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,Pv=d`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,Pu=d`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`,Lv=d`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`;function ja(e){const t=e.detailJobId?e.jobs.find(i=>i.id===e.detailJobId)??null:null,n=e.newEventModalOpen||!!e.editJobId;return d`
|
|
2609
|
+
${Iv(e)}
|
|
2610
|
+
${Rv(e)}
|
|
2611
|
+
${n?Bv(e):S}
|
|
2612
|
+
${t?Fv(t,e):S}
|
|
2613
|
+
`}function Iv(e){const t=e.status,n=(t==null?void 0:t.enabled)??!1,i=(t==null?void 0:t.jobs)??0,s=t==null?void 0:t.nextWakeAtMs;return d`
|
|
2614
2614
|
<div class="event-status-bar">
|
|
2615
2615
|
<div class="event-status-bar__info">
|
|
2616
2616
|
<span class="statusDot ${n?"ok":""}"></span>
|
|
@@ -2619,7 +2619,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2619
2619
|
<span>${i} event${i!==1?"s":""}</span>
|
|
2620
2620
|
${s?d`
|
|
2621
2621
|
<span class="event-status-bar__sep">\u00b7</span>
|
|
2622
|
-
<span>Next: ${
|
|
2622
|
+
<span>Next: ${_i(s)}</span>
|
|
2623
2623
|
`:S}
|
|
2624
2624
|
<button
|
|
2625
2625
|
class="btn btn--sm"
|
|
@@ -2632,14 +2632,14 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2632
2632
|
${e.error?d`<span class="muted">${e.error}</span>`:S}
|
|
2633
2633
|
</div>
|
|
2634
2634
|
<button class="btn primary btn--sm" @click=${e.onNewEventModalOpen}>
|
|
2635
|
-
${
|
|
2635
|
+
${Pu} New Event
|
|
2636
2636
|
</button>
|
|
2637
2637
|
</div>
|
|
2638
|
-
`}function
|
|
2638
|
+
`}function Rv(e){return e.jobs.length===0?d`<div class="muted" style="padding: 20px 0;">No events yet. Create one to get started.</div>`:d`
|
|
2639
2639
|
<div class="event-grid">
|
|
2640
|
-
${e.jobs.map(t=>
|
|
2640
|
+
${e.jobs.map(t=>Dv(t,e))}
|
|
2641
2641
|
</div>
|
|
2642
|
-
`}function
|
|
2642
|
+
`}function Dv(e,t){return d`
|
|
2643
2643
|
<div
|
|
2644
2644
|
class="event-card ${e.enabled?"":"disabled"}"
|
|
2645
2645
|
@click=${()=>t.onDetailOpen(e)}
|
|
@@ -2650,12 +2650,12 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2650
2650
|
${e.enabled?"On":"Off"}
|
|
2651
2651
|
</span>
|
|
2652
2652
|
</div>
|
|
2653
|
-
<div class="event-card__schedule">${
|
|
2654
|
-
${e.agentId?d`<div class="event-card__agent">${
|
|
2655
|
-
${
|
|
2653
|
+
<div class="event-card__schedule">${Mu(e)}</div>
|
|
2654
|
+
${e.agentId?d`<div class="event-card__agent">${Cv(e.agentId)}</div>`:S}
|
|
2655
|
+
${qa(e)?d`<div class="event-card__agent muted" style="font-size: 11px;">\u2192 ${qa(e)}</div>`:S}
|
|
2656
2656
|
<div class="event-card__footer">
|
|
2657
2657
|
<div class="event-card__status">
|
|
2658
|
-
<span class="muted" style="font-size: 11px;">${
|
|
2658
|
+
<span class="muted" style="font-size: 11px;">${_u(e)}</span>
|
|
2659
2659
|
</div>
|
|
2660
2660
|
<div class="event-card__actions" @click=${n=>n.stopPropagation()}>
|
|
2661
2661
|
<button
|
|
@@ -2664,7 +2664,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2664
2664
|
?disabled=${t.busy}
|
|
2665
2665
|
@click=${()=>t.onToggle(e,!e.enabled)}
|
|
2666
2666
|
>
|
|
2667
|
-
${e.enabled?
|
|
2667
|
+
${e.enabled?_v:Tv}
|
|
2668
2668
|
</button>
|
|
2669
2669
|
<button
|
|
2670
2670
|
class="btn-icon"
|
|
@@ -2672,26 +2672,28 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2672
2672
|
?disabled=${t.busy}
|
|
2673
2673
|
@click=${()=>t.onRun(e)}
|
|
2674
2674
|
>
|
|
2675
|
-
${
|
|
2675
|
+
${Pv}
|
|
2676
2676
|
</button>
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2677
|
+
${t.pendingDeleteId===e.id?d`<button
|
|
2678
|
+
class="btn danger btn--sm"
|
|
2679
|
+
?disabled=${t.busy}
|
|
2680
|
+
@click=${()=>{ge&&clearTimeout(ge),ge=null,t.onRemove(e)}}
|
|
2681
|
+
>Confirm delete?</button>`:d`<button
|
|
2682
|
+
class="btn-icon danger"
|
|
2683
|
+
title="Delete"
|
|
2684
|
+
?disabled=${t.busy}
|
|
2685
|
+
@click=${()=>{t.onArmDelete(e.id),ge&&clearTimeout(ge),ge=setTimeout(()=>{t.onArmDelete(""),ge=null},3e3)}}
|
|
2686
|
+
>${Mv}</button>`}
|
|
2687
|
+
</div>
|
|
2688
|
+
</div>
|
|
2689
|
+
</div>
|
|
2690
|
+
`}function Bv(e){const t=!!e.editJobId,n=xv(e),i=()=>{e.onNewEventModalClose()};return d`
|
|
2691
|
+
<div class="event-modal-overlay" @click=${i}>
|
|
2692
|
+
<div class="event-modal" @click=${s=>s.stopPropagation()}>
|
|
2691
2693
|
<div class="event-modal__header">
|
|
2692
|
-
<div class="event-modal__title"
|
|
2693
|
-
<button class="event-modal__close" @click=${
|
|
2694
|
-
${
|
|
2694
|
+
<div class="event-modal__title">${t?"Edit Event":"New Event"}</div>
|
|
2695
|
+
<button class="event-modal__close" @click=${i}>
|
|
2696
|
+
${Yo}
|
|
2695
2697
|
</button>
|
|
2696
2698
|
</div>
|
|
2697
2699
|
|
|
@@ -2700,7 +2702,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2700
2702
|
<span>Name</span>
|
|
2701
2703
|
<input
|
|
2702
2704
|
.value=${e.form.name}
|
|
2703
|
-
@input=${
|
|
2705
|
+
@input=${s=>e.onFormChange({name:s.target.value})}
|
|
2704
2706
|
placeholder="e.g. Morning briefing"
|
|
2705
2707
|
/>
|
|
2706
2708
|
</label>
|
|
@@ -2708,7 +2710,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2708
2710
|
<span>Description</span>
|
|
2709
2711
|
<input
|
|
2710
2712
|
.value=${e.form.description}
|
|
2711
|
-
@input=${
|
|
2713
|
+
@input=${s=>e.onFormChange({description:s.target.value})}
|
|
2712
2714
|
placeholder="What does this event do?"
|
|
2713
2715
|
/>
|
|
2714
2716
|
</label>
|
|
@@ -2716,10 +2718,10 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2716
2718
|
<span>Agent</span>
|
|
2717
2719
|
<select
|
|
2718
2720
|
.value=${e.form.agentId}
|
|
2719
|
-
@change=${
|
|
2721
|
+
@change=${s=>e.onFormChange({agentId:s.target.value})}
|
|
2720
2722
|
>
|
|
2721
2723
|
<option value="">Default</option>
|
|
2722
|
-
${e.agentIds.map(
|
|
2724
|
+
${e.agentIds.map(s=>d`<option value=${s}>${s}</option>`)}
|
|
2723
2725
|
</select>
|
|
2724
2726
|
</label>
|
|
2725
2727
|
<label class="field checkbox">
|
|
@@ -2727,14 +2729,14 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2727
2729
|
<input
|
|
2728
2730
|
type="checkbox"
|
|
2729
2731
|
.checked=${e.form.enabled}
|
|
2730
|
-
@change=${
|
|
2732
|
+
@change=${s=>e.onFormChange({enabled:s.target.checked})}
|
|
2731
2733
|
/>
|
|
2732
2734
|
</label>
|
|
2733
2735
|
<label class="field">
|
|
2734
2736
|
<span>Timing</span>
|
|
2735
2737
|
<select
|
|
2736
2738
|
.value=${e.form.scheduleKind}
|
|
2737
|
-
@change=${
|
|
2739
|
+
@change=${s=>e.onFormChange({scheduleKind:s.target.value})}
|
|
2738
2740
|
>
|
|
2739
2741
|
<option value="every">Repeating</option>
|
|
2740
2742
|
<option value="at">One-time</option>
|
|
@@ -2743,14 +2745,14 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2743
2745
|
</label>
|
|
2744
2746
|
</div>
|
|
2745
2747
|
|
|
2746
|
-
${
|
|
2748
|
+
${Ov(e)}
|
|
2747
2749
|
|
|
2748
2750
|
<div class="form-grid" style="margin-top: 12px;">
|
|
2749
2751
|
<label class="field">
|
|
2750
2752
|
<span>Session type</span>
|
|
2751
2753
|
<select
|
|
2752
2754
|
.value=${e.form.sessionTarget}
|
|
2753
|
-
@change=${
|
|
2755
|
+
@change=${s=>{const o=s.target.value;e.onFormChange({sessionTarget:o,payloadKind:o==="isolated"?"agentTurn":"systemEvent"})}}
|
|
2754
2756
|
>
|
|
2755
2757
|
<option value="main">Shared session</option>
|
|
2756
2758
|
<option value="isolated">Separate session</option>
|
|
@@ -2760,7 +2762,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2760
2762
|
<span>When to run</span>
|
|
2761
2763
|
<select
|
|
2762
2764
|
.value=${e.form.wakeMode}
|
|
2763
|
-
@change=${
|
|
2765
|
+
@change=${s=>e.onFormChange({wakeMode:s.target.value})}
|
|
2764
2766
|
>
|
|
2765
2767
|
<option value="next-heartbeat">Next available time</option>
|
|
2766
2768
|
<option value="now">Right away</option>
|
|
@@ -2770,7 +2772,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2770
2772
|
<span>Action type</span>
|
|
2771
2773
|
<select
|
|
2772
2774
|
.value=${e.form.payloadKind}
|
|
2773
|
-
@change=${
|
|
2775
|
+
@change=${s=>{const o=s.target.value;e.onFormChange({payloadKind:o,sessionTarget:o==="agentTurn"?"isolated":"main"})}}
|
|
2774
2776
|
>
|
|
2775
2777
|
<option value="systemEvent">Background task</option>
|
|
2776
2778
|
<option value="agentTurn">Send a message</option>
|
|
@@ -2782,7 +2784,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2782
2784
|
<span>${e.form.payloadKind==="systemEvent"?"Task description":"Message to send"}</span>
|
|
2783
2785
|
<textarea
|
|
2784
2786
|
.value=${e.form.payloadText}
|
|
2785
|
-
@input=${
|
|
2787
|
+
@input=${s=>e.onFormChange({payloadText:s.target.value})}
|
|
2786
2788
|
rows="4"
|
|
2787
2789
|
placeholder="${e.form.payloadKind==="systemEvent"?"Describe what the assistant should do…":"Type the message to send…"}"
|
|
2788
2790
|
></textarea>
|
|
@@ -2795,33 +2797,36 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2795
2797
|
<input
|
|
2796
2798
|
type="checkbox"
|
|
2797
2799
|
.checked=${e.form.deliver}
|
|
2798
|
-
@change=${
|
|
2800
|
+
@change=${s=>e.onFormChange({deliver:s.target.checked})}
|
|
2799
2801
|
/>
|
|
2800
2802
|
</label>
|
|
2801
2803
|
<label class="field">
|
|
2802
2804
|
<span>Channel</span>
|
|
2803
2805
|
<select
|
|
2804
2806
|
.value=${e.form.channel||"last"}
|
|
2805
|
-
@change=${
|
|
2807
|
+
@change=${s=>e.onFormChange({channel:s.target.value})}
|
|
2806
2808
|
>
|
|
2807
|
-
${
|
|
2808
|
-
${
|
|
2809
|
+
${n.map(s=>d`<option value=${s}>
|
|
2810
|
+
${Av(e,s)}
|
|
2809
2811
|
</option>`)}
|
|
2810
2812
|
</select>
|
|
2811
2813
|
</label>
|
|
2812
|
-
<label class="field">
|
|
2813
|
-
<span>
|
|
2814
|
+
<label class="field checkbox">
|
|
2815
|
+
<span>All admins</span>
|
|
2814
2816
|
<input
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2817
|
+
type="checkbox"
|
|
2818
|
+
.checked=${e.form.toAdmins}
|
|
2819
|
+
@change=${s=>e.onFormChange({toAdmins:s.target.checked})}
|
|
2818
2820
|
/>
|
|
2819
2821
|
</label>
|
|
2822
|
+
</div>
|
|
2823
|
+
${Nv(e)}
|
|
2824
|
+
<div class="form-grid" style="margin-top: 12px;">
|
|
2820
2825
|
<label class="field">
|
|
2821
2826
|
<span>Timeout (seconds)</span>
|
|
2822
2827
|
<input
|
|
2823
2828
|
.value=${e.form.timeoutSeconds}
|
|
2824
|
-
@input=${
|
|
2829
|
+
@input=${s=>e.onFormChange({timeoutSeconds:s.target.value})}
|
|
2825
2830
|
/>
|
|
2826
2831
|
</label>
|
|
2827
2832
|
${e.form.sessionTarget==="isolated"?d`
|
|
@@ -2829,7 +2834,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2829
2834
|
<span>Summary prefix</span>
|
|
2830
2835
|
<input
|
|
2831
2836
|
.value=${e.form.postToMainPrefix}
|
|
2832
|
-
@input=${
|
|
2837
|
+
@input=${s=>e.onFormChange({postToMainPrefix:s.target.value})}
|
|
2833
2838
|
/>
|
|
2834
2839
|
</label>
|
|
2835
2840
|
`:S}
|
|
@@ -2837,14 +2842,46 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2837
2842
|
`:S}
|
|
2838
2843
|
|
|
2839
2844
|
<div class="row" style="margin-top: 16px; justify-content: flex-end;">
|
|
2840
|
-
<button class="btn" @click=${
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2845
|
+
<button class="btn" @click=${i}>Cancel</button>
|
|
2846
|
+
${t?d`<button class="btn primary" ?disabled=${e.busy} @click=${e.onEditSave}>
|
|
2847
|
+
${e.busy?"Saving…":"Save Changes"}
|
|
2848
|
+
</button>`:d`<button class="btn primary" ?disabled=${e.busy} @click=${e.onAdd}>
|
|
2849
|
+
${e.busy?"Creating…":"Create Event"}
|
|
2850
|
+
</button>`}
|
|
2844
2851
|
</div>
|
|
2845
2852
|
</div>
|
|
2846
2853
|
</div>
|
|
2847
|
-
`}function
|
|
2854
|
+
`}function Nv(e){const t=e.form.recipients;return d`
|
|
2855
|
+
<div style="margin-top: 8px;">
|
|
2856
|
+
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;">
|
|
2857
|
+
<span style="font-size: 13px; color: var(--muted);">Recipients</span>
|
|
2858
|
+
<button
|
|
2859
|
+
class="btn btn--sm"
|
|
2860
|
+
@click=${()=>{e.onFormChange({recipients:[...t,""]})}}
|
|
2861
|
+
>
|
|
2862
|
+
${Pu} Add
|
|
2863
|
+
</button>
|
|
2864
|
+
</div>
|
|
2865
|
+
${t.length===0&&!e.form.toAdmins?d`<div class="muted" style="font-size: 12px; padding: 4px 0;">No recipients. Add a phone number or enable "All admins".</div>`:S}
|
|
2866
|
+
${t.map((n,i)=>d`
|
|
2867
|
+
<div style="display: flex; align-items: center; gap: 6px; margin-bottom: 6px;">
|
|
2868
|
+
<input
|
|
2869
|
+
style="flex: 1;"
|
|
2870
|
+
.value=${n}
|
|
2871
|
+
@input=${s=>{const o=[...t];o[i]=s.target.value,e.onFormChange({recipients:o})}}
|
|
2872
|
+
placeholder="+1555\u2026 or chat id"
|
|
2873
|
+
/>
|
|
2874
|
+
<button
|
|
2875
|
+
class="btn-icon danger"
|
|
2876
|
+
title="Remove"
|
|
2877
|
+
@click=${()=>{const s=t.filter((o,r)=>r!==i);e.onFormChange({recipients:s})}}
|
|
2878
|
+
>
|
|
2879
|
+
${Yo}
|
|
2880
|
+
</button>
|
|
2881
|
+
</div>
|
|
2882
|
+
`)}
|
|
2883
|
+
</div>
|
|
2884
|
+
`}function Ov(e){const t=e.form;return t.scheduleKind==="at"?d`
|
|
2848
2885
|
<label class="field" style="margin-top: 12px;">
|
|
2849
2886
|
<span>Run at</span>
|
|
2850
2887
|
<input
|
|
@@ -2893,18 +2930,49 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2893
2930
|
/>
|
|
2894
2931
|
</label>
|
|
2895
2932
|
</div>
|
|
2896
|
-
`}function
|
|
2933
|
+
`}function Fv(e,t){var n;return d`
|
|
2897
2934
|
<div class="event-modal-overlay" @click=${t.onDetailClose}>
|
|
2898
2935
|
<div class="event-modal" @click=${i=>i.stopPropagation()}>
|
|
2899
2936
|
<div class="event-modal__header">
|
|
2900
2937
|
<div class="event-modal__title">${e.name||"Untitled Event"}</div>
|
|
2901
2938
|
<button class="event-modal__close" @click=${t.onDetailClose}>
|
|
2902
|
-
${
|
|
2939
|
+
${Yo}
|
|
2903
2940
|
</button>
|
|
2904
2941
|
</div>
|
|
2905
2942
|
|
|
2906
2943
|
${e.description?d`<div style="color: var(--muted); font-size: 13px; margin-bottom: 16px;">${e.description}</div>`:S}
|
|
2907
2944
|
|
|
2945
|
+
<div class="row" style="margin-bottom: 16px; gap: 8px; justify-content: flex-start;">
|
|
2946
|
+
<button
|
|
2947
|
+
class="btn"
|
|
2948
|
+
?disabled=${t.busy}
|
|
2949
|
+
@click=${()=>t.onEdit(e)}
|
|
2950
|
+
>
|
|
2951
|
+
${Lv} Edit
|
|
2952
|
+
</button>
|
|
2953
|
+
<button
|
|
2954
|
+
class="btn"
|
|
2955
|
+
?disabled=${t.busy}
|
|
2956
|
+
@click=${()=>t.onToggle(e,!e.enabled)}
|
|
2957
|
+
>
|
|
2958
|
+
${e.enabled?"Disable":"Enable"}
|
|
2959
|
+
</button>
|
|
2960
|
+
<button
|
|
2961
|
+
class="btn primary"
|
|
2962
|
+
?disabled=${t.busy}
|
|
2963
|
+
@click=${()=>t.onRun(e)}
|
|
2964
|
+
>
|
|
2965
|
+
Run Now
|
|
2966
|
+
</button>
|
|
2967
|
+
<button
|
|
2968
|
+
class="btn danger"
|
|
2969
|
+
?disabled=${t.busy}
|
|
2970
|
+
@click=${()=>{t.pendingDeleteId===e.id?(ge&&clearTimeout(ge),ge=null,t.onRemove(e),t.onDetailClose()):(t.onArmDelete(e.id),ge&&clearTimeout(ge),ge=setTimeout(()=>{t.onArmDelete(""),ge=null},3e3))}}
|
|
2971
|
+
>
|
|
2972
|
+
${t.pendingDeleteId===e.id?"Confirm delete?":"Delete"}
|
|
2973
|
+
</button>
|
|
2974
|
+
</div>
|
|
2975
|
+
|
|
2908
2976
|
<div class="event-detail-section">
|
|
2909
2977
|
<div class="event-detail-row">
|
|
2910
2978
|
<span class="event-detail-label">Status</span>
|
|
@@ -2916,7 +2984,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2916
2984
|
</div>
|
|
2917
2985
|
<div class="event-detail-row">
|
|
2918
2986
|
<span class="event-detail-label">Schedule</span>
|
|
2919
|
-
<span class="event-detail-value">${
|
|
2987
|
+
<span class="event-detail-value">${Mu(e)}</span>
|
|
2920
2988
|
</div>
|
|
2921
2989
|
${e.agentId?d`
|
|
2922
2990
|
<div class="event-detail-row">
|
|
@@ -2938,12 +3006,12 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2938
3006
|
</div>
|
|
2939
3007
|
<div class="event-detail-row" style="flex-direction: column; align-items: stretch; gap: 4px;">
|
|
2940
3008
|
<span class="event-detail-label">Action</span>
|
|
2941
|
-
<span class="event-detail-value" style="text-align: left; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.5;">${
|
|
3009
|
+
<span class="event-detail-value" style="text-align: left; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.5;">${$v(e,!1)}</span>
|
|
2942
3010
|
</div>
|
|
2943
3011
|
${e.payload.kind==="agentTurn"&&e.payload.to?d`
|
|
2944
3012
|
<div class="event-detail-row">
|
|
2945
3013
|
<span class="event-detail-label">Send to</span>
|
|
2946
|
-
<span class="event-detail-value mono">${e.payload.to}</span>
|
|
3014
|
+
<span class="event-detail-value mono">${Ev(e.payload.to)}</span>
|
|
2947
3015
|
</div>
|
|
2948
3016
|
`:S}
|
|
2949
3017
|
${e.payload.kind==="agentTurn"&&(e.payload.channel??e.payload.provider)?d`
|
|
@@ -2963,12 +3031,12 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2963
3031
|
<div class="event-detail-section">
|
|
2964
3032
|
<div class="event-detail-row">
|
|
2965
3033
|
<span class="event-detail-label">Last run</span>
|
|
2966
|
-
<span class="event-detail-value">${
|
|
3034
|
+
<span class="event-detail-value">${_u(e)}</span>
|
|
2967
3035
|
</div>
|
|
2968
3036
|
${(n=e.state)!=null&&n.nextRunAtMs?d`
|
|
2969
3037
|
<div class="event-detail-row">
|
|
2970
3038
|
<span class="event-detail-label">Next run</span>
|
|
2971
|
-
<span class="event-detail-value">${
|
|
3039
|
+
<span class="event-detail-value">${kv(e.state.nextRunAtMs)}</span>
|
|
2972
3040
|
</div>
|
|
2973
3041
|
`:S}
|
|
2974
3042
|
</div>
|
|
@@ -2979,44 +3047,21 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
2979
3047
|
</div>
|
|
2980
3048
|
${t.runs.length===0?d`<div class="muted" style="font-size: 13px;">No runs recorded yet.</div>`:d`
|
|
2981
3049
|
<div class="list">
|
|
2982
|
-
${[...t.runs].sort((i,s)=>s.ts-i.ts).map(i=>
|
|
3050
|
+
${[...t.runs].sort((i,s)=>s.ts-i.ts).map(i=>Wv(i))}
|
|
2983
3051
|
</div>
|
|
2984
3052
|
`}
|
|
2985
3053
|
</div>
|
|
2986
3054
|
|
|
2987
|
-
<div class="row" style="margin-top: 16px; gap: 8px; justify-content: flex-end;">
|
|
2988
|
-
<button
|
|
2989
|
-
class="btn"
|
|
2990
|
-
?disabled=${t.busy}
|
|
2991
|
-
@click=${()=>t.onToggle(e,!e.enabled)}
|
|
2992
|
-
>
|
|
2993
|
-
${e.enabled?"Disable":"Enable"}
|
|
2994
|
-
</button>
|
|
2995
|
-
<button
|
|
2996
|
-
class="btn primary"
|
|
2997
|
-
?disabled=${t.busy}
|
|
2998
|
-
@click=${()=>t.onRun(e)}
|
|
2999
|
-
>
|
|
3000
|
-
Run Now
|
|
3001
|
-
</button>
|
|
3002
|
-
<button
|
|
3003
|
-
class="btn danger"
|
|
3004
|
-
?disabled=${t.busy}
|
|
3005
|
-
@click=${()=>{t.onRemove(e),t.onDetailClose()}}
|
|
3006
|
-
>
|
|
3007
|
-
Delete
|
|
3008
|
-
</button>
|
|
3009
|
-
</div>
|
|
3010
3055
|
</div>
|
|
3011
3056
|
</div>
|
|
3012
|
-
`}function
|
|
3057
|
+
`}function Uv(e){const t=e.toLowerCase();return t==="ok"||t==="success"?"chip chip-ok":t==="error"||t==="fail"||t==="failed"?"chip chip-warn":"chip"}function Wv(e){return d`
|
|
3013
3058
|
<div class="list-item" style="grid-template-columns: 1fr; gap: 6px;">
|
|
3014
3059
|
<div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
|
|
3015
|
-
<span class=${
|
|
3060
|
+
<span class=${Uv(e.status)} style="font-size: 11px; padding: 2px 8px;">
|
|
3016
3061
|
${e.status}
|
|
3017
3062
|
</span>
|
|
3018
|
-
<span class="muted" style="font-size: 12px;">${
|
|
3019
|
-
<span class="muted" style="font-size: 12px;">${
|
|
3063
|
+
<span class="muted" style="font-size: 12px;">${_i(e.ts)}</span>
|
|
3064
|
+
<span class="muted" style="font-size: 12px;">${$l(e.durationMs)}</span>
|
|
3020
3065
|
</div>
|
|
3021
3066
|
${e.summary?d`<div class="muted" style="font-size: 12px;">${e.summary}</div>`:S}
|
|
3022
3067
|
${e.error?d`
|
|
@@ -3026,7 +3071,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3026
3071
|
</details>
|
|
3027
3072
|
`:S}
|
|
3028
3073
|
</div>
|
|
3029
|
-
`}function
|
|
3074
|
+
`}function Kv(e){var s;const t=((s=e.report)==null?void 0:s.skills)??[],n=e.filter.trim().toLowerCase(),i=n?t.filter(o=>[o.name,o.description,o.preloaded?"preloaded":"user"].join(" ").toLowerCase().includes(n)):t;return d`
|
|
3030
3075
|
<section class="card">
|
|
3031
3076
|
<div class="row" style="justify-content: space-between;">
|
|
3032
3077
|
<div>
|
|
@@ -3057,20 +3102,20 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3057
3102
|
|
|
3058
3103
|
${i.length===0?d`<div class="muted" style="margin-top: 16px;">No skills found.</div>`:d`
|
|
3059
3104
|
<div class="list" style="margin-top: 16px;">
|
|
3060
|
-
${i.map(o=>
|
|
3105
|
+
${i.map(o=>zv(o,e))}
|
|
3061
3106
|
</div>
|
|
3062
3107
|
`}
|
|
3063
3108
|
</section>
|
|
3064
3109
|
|
|
3065
|
-
${e.detail?
|
|
3066
|
-
${e.addModal?
|
|
3067
|
-
`}function
|
|
3110
|
+
${e.detail?Hv(e):S}
|
|
3111
|
+
${e.addModal?qv(e):S}
|
|
3112
|
+
`}function zv(e,t){const n=t.busyKey===e.skillKey,i=t.edits[e.skillKey]??"",s=t.messages[e.skillKey]??null,o=e.install.length>0&&e.missing.bins.length>0,r=[...e.missing.bins.map(u=>`bin:${u}`),...e.missing.env.map(u=>`env:${u}`),...e.missing.config.map(u=>`config:${u}`),...e.missing.os.map(u=>`os:${u}`)],a=[];return e.disabled&&a.push("disabled"),e.blockedByAllowlist&&a.push("blocked by allowlist"),d`
|
|
3068
3113
|
<div class="list-item" style="cursor: pointer;" @click=${()=>t.onViewDetail(e.name)}>
|
|
3069
3114
|
<div class="list-main">
|
|
3070
3115
|
<div class="list-title">
|
|
3071
3116
|
${e.emoji?`${e.emoji} `:""}${e.name}
|
|
3072
3117
|
</div>
|
|
3073
|
-
<div class="list-sub">${
|
|
3118
|
+
<div class="list-sub">${jd(e.description,140)}</div>
|
|
3074
3119
|
<div class="chip-row" style="margin-top: 6px;">
|
|
3075
3120
|
<span class="chip ${e.preloaded?"chip-ok":""}">
|
|
3076
3121
|
${e.preloaded?"Preloaded":"User"}
|
|
@@ -3145,7 +3190,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3145
3190
|
`:S}
|
|
3146
3191
|
</div>
|
|
3147
3192
|
</div>
|
|
3148
|
-
`}function
|
|
3193
|
+
`}function Hv(e){var r;const t=e.detail,n=["SKILL.md",...t.references.map(a=>a.name)],i=e.detailTab||"SKILL.md",s=i==="SKILL.md"?t.content:((r=t.references.find(a=>a.name===i))==null?void 0:r.content)??"";return d`
|
|
3149
3194
|
<div class="event-modal-overlay" @click=${a=>{a.target.classList.contains("event-modal-overlay")&&e.onDetailClose()}}>
|
|
3150
3195
|
<div class="event-modal" style="width: min(720px, 100%);" @click=${a=>a.stopPropagation()}>
|
|
3151
3196
|
<div class="event-modal__header">
|
|
@@ -3168,7 +3213,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3168
3213
|
<pre style="white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 1.5; max-height: 60vh; overflow-y: auto; background: var(--bg, #111); padding: 16px; border-radius: 8px; border: 1px solid var(--border);">${s}</pre>
|
|
3169
3214
|
</div>
|
|
3170
3215
|
</div>
|
|
3171
|
-
`}function
|
|
3216
|
+
`}function qv(e){const t=e.drafts.length>0,n=e.busyKey==="__add__";return d`
|
|
3172
3217
|
<div class="event-modal-overlay" @click=${s=>{s.target.classList.contains("event-modal-overlay")&&e.onAddClose()}}>
|
|
3173
3218
|
<div class="event-modal" style="width: min(520px, 100%);" @click=${s=>s.stopPropagation()}>
|
|
3174
3219
|
<div class="event-modal__header">
|
|
@@ -3217,7 +3262,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3217
3262
|
`}
|
|
3218
3263
|
</div>
|
|
3219
3264
|
</div>
|
|
3220
|
-
`}const
|
|
3265
|
+
`}const Va=["user","assistant","tool","thinking","error"],Ga={user:"User",assistant:"Assistant",tool:"Tool",thinking:"Thinking",error:"Error",system:"System"};function jv(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 Vv(e){return e.split(":").slice(2).join(":")||e}function Gv(e,t){return t?[e.content,e.agentId,e.sessionKey,e.sessionId,e.toolName].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Qv(e,t=500){return e.length<=t?e:e.slice(0,t)+"..."}function Yv(e){const t=e.filterText.trim().toLowerCase();Va.some(i=>!e.typeFilters[i]),e.agents.some(i=>!e.agentFilters[i]);const n=e.entries.filter(i=>!e.typeFilters[i.type]||e.agents.length>0&&!(e.agentFilters[i.agentId]??!0)?!1:Gv(i,t));return d`
|
|
3221
3266
|
<div>
|
|
3222
3267
|
<div class="filters" style="margin-top: 14px;">
|
|
3223
3268
|
<label class="field" style="min-width: 220px;">
|
|
@@ -3231,14 +3276,14 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3231
3276
|
</div>
|
|
3232
3277
|
|
|
3233
3278
|
<div class="chip-row" style="margin-top: 12px;">
|
|
3234
|
-
${
|
|
3279
|
+
${Va.map(i=>d`
|
|
3235
3280
|
<label class="chip session-log-chip ${i}">
|
|
3236
3281
|
<input
|
|
3237
3282
|
type="checkbox"
|
|
3238
3283
|
.checked=${e.typeFilters[i]}
|
|
3239
3284
|
@change=${s=>e.onTypeToggle(i,s.target.checked)}
|
|
3240
3285
|
/>
|
|
3241
|
-
<span>${
|
|
3286
|
+
<span>${Ga[i]}</span>
|
|
3242
3287
|
</label>
|
|
3243
3288
|
`)}
|
|
3244
3289
|
</div>
|
|
@@ -3270,19 +3315,19 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3270
3315
|
${n.length===0?d`<div class="muted" style="padding: 12px;">No session log entries.</div>`:n.map(i=>d`
|
|
3271
3316
|
<div class="log-row session-entry ${i.type}">
|
|
3272
3317
|
<div class="log-row-header">
|
|
3273
|
-
<span class="log-time mono">${
|
|
3274
|
-
<span class="session-log-type ${i.type}">${
|
|
3318
|
+
<span class="log-time mono">${jv(i.timestamp)}</span>
|
|
3319
|
+
<span class="session-log-type ${i.type}">${Ga[i.type]}</span>
|
|
3275
3320
|
<span class="log-subsystem mono">${i.agentId}</span>
|
|
3276
|
-
<span class="session-label mono">${
|
|
3321
|
+
<span class="session-label mono">${Vv(i.sessionKey)}</span>
|
|
3277
3322
|
${i.toolName?d`<span class="session-tool mono">${i.toolName}</span>`:S}
|
|
3278
3323
|
${i.model?d`<span class="session-model mono">${i.model}</span>`:S}
|
|
3279
3324
|
</div>
|
|
3280
|
-
<div class="log-message mono">${
|
|
3325
|
+
<div class="log-message mono">${Qv(i.content)}</div>
|
|
3281
3326
|
</div>
|
|
3282
3327
|
`)}
|
|
3283
3328
|
</div>
|
|
3284
3329
|
</div>
|
|
3285
|
-
`}const
|
|
3330
|
+
`}const eo=["trace","debug","info","warn","error","fatal"];function Jv(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function Lu(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Xv(e){return d`
|
|
3286
3331
|
<section class="card">
|
|
3287
3332
|
<div class="row" style="justify-content: space-between;">
|
|
3288
3333
|
<div>
|
|
@@ -3297,7 +3342,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3297
3342
|
<button
|
|
3298
3343
|
class="btn"
|
|
3299
3344
|
?disabled=${e.entries.length===0}
|
|
3300
|
-
@click=${()=>{const t=e.filterText.trim().toLowerCase(),n=
|
|
3345
|
+
@click=${()=>{const t=e.filterText.trim().toLowerCase(),n=eo.some(o=>!e.levelFilters[o]),i=e.entries.filter(o=>o.level&&!e.levelFilters[o.level]?!1:Lu(o,t)),s=t||n?"filtered":"visible";e.onExport(i.map(o=>o.raw),s)}}
|
|
3301
3346
|
>
|
|
3302
3347
|
Export
|
|
3303
3348
|
</button>
|
|
@@ -3327,9 +3372,9 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3327
3372
|
</button>
|
|
3328
3373
|
</div>
|
|
3329
3374
|
|
|
3330
|
-
${e.logsSubTab==="session"?
|
|
3375
|
+
${e.logsSubTab==="session"?Yv(e.sessionLogsProps):Zv(e)}
|
|
3331
3376
|
</section>
|
|
3332
|
-
`}function
|
|
3377
|
+
`}function Zv(e){const t=e.filterText.trim().toLowerCase();eo.some(i=>!e.levelFilters[i]);const n=e.entries.filter(i=>i.level&&!e.levelFilters[i.level]?!1:Lu(i,t));return d`
|
|
3333
3378
|
<div class="filters" style="margin-top: 14px;">
|
|
3334
3379
|
<label class="field" style="min-width: 220px;">
|
|
3335
3380
|
<span>Filter</span>
|
|
@@ -3350,7 +3395,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3350
3395
|
</div>
|
|
3351
3396
|
|
|
3352
3397
|
<div class="chip-row" style="margin-top: 12px;">
|
|
3353
|
-
${
|
|
3398
|
+
${eo.map(i=>d`
|
|
3354
3399
|
<label class="chip log-chip ${i}">
|
|
3355
3400
|
<input
|
|
3356
3401
|
type="checkbox"
|
|
@@ -3372,7 +3417,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3372
3417
|
${n.length===0?d`<div class="muted" style="padding: 12px;">No log entries.</div>`:[...n].reverse().map(i=>d`
|
|
3373
3418
|
<div class="log-row">
|
|
3374
3419
|
<div class="log-row-header">
|
|
3375
|
-
<span class="log-time mono">${
|
|
3420
|
+
<span class="log-time mono">${Jv(i.time)}</span>
|
|
3376
3421
|
<span class="log-level ${i.level??""}">${i.level??""}</span>
|
|
3377
3422
|
<span class="log-subsystem mono">${i.subsystem??""}</span>
|
|
3378
3423
|
</div>
|
|
@@ -3380,13 +3425,13 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3380
3425
|
</div>
|
|
3381
3426
|
`)}
|
|
3382
3427
|
</div>
|
|
3383
|
-
`}const
|
|
3428
|
+
`}const eb=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"logs",label:"Logs"}];function tb(e){switch(e.activeTab){case"cron":return ja(e.cronProps);case"skills":return Kv(e.skillsProps);case"logs":return Xv(e.logsProps);default:return ja(e.cronProps)}}function nb(e){return e.connected?d`
|
|
3384
3429
|
<div class="setup-container">
|
|
3385
|
-
${
|
|
3430
|
+
${kt("Advanced",e.wsProps)}
|
|
3386
3431
|
<div class="setup-card sp-card-advanced" style="text-align: left;">
|
|
3387
3432
|
<h1>Advanced</h1>
|
|
3388
3433
|
<div class="sp-tabs">
|
|
3389
|
-
${
|
|
3434
|
+
${eb.map(t=>d`
|
|
3390
3435
|
<button
|
|
3391
3436
|
class="sp-tab ${e.activeTab===t.id?"active":""}"
|
|
3392
3437
|
@click=${()=>e.onTabChange(t.id)}
|
|
@@ -3395,7 +3440,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3395
3440
|
</button>
|
|
3396
3441
|
`)}
|
|
3397
3442
|
</div>
|
|
3398
|
-
${
|
|
3443
|
+
${tb(e)}
|
|
3399
3444
|
</div>
|
|
3400
3445
|
</div>
|
|
3401
3446
|
`:d`
|
|
@@ -3405,7 +3450,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3405
3450
|
<p>Connecting to gateway...</p>
|
|
3406
3451
|
</div>
|
|
3407
3452
|
</div>
|
|
3408
|
-
`}function
|
|
3453
|
+
`}function Qa(e){if(!e.show)return S;const t=ze(),n=e.isFirstTime,i=e.changePinMode===!0&&!n,s=e.changePinBusy===!0;let o=e.accounts.length>0?e.accounts[0].id:"";const r=f=>{var h;o=f.target.value;const b=(h=f.target.closest(".login-card"))==null?void 0:h.querySelector(".login-change-pin");b&&(b.style.display=o==="__master__"?"":"none")},a=f=>b=>{const h=b.target;h.value=h.value.replace(/\D/g,"").slice(0,6),f(h.value)},u=!n&&e.accounts.length>1?d`
|
|
3409
3454
|
<select
|
|
3410
3455
|
class="login-account-select"
|
|
3411
3456
|
@change=${r}
|
|
@@ -3529,7 +3574,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3529
3574
|
</p>`:S}
|
|
3530
3575
|
</div>
|
|
3531
3576
|
</div>
|
|
3532
|
-
`}function
|
|
3577
|
+
`}function ib(e){if(!e.connected)return d`
|
|
3533
3578
|
<div class="setup-container">
|
|
3534
3579
|
<div class="setup-card">
|
|
3535
3580
|
<div class="setup-spinner"></div>
|
|
@@ -3542,17 +3587,17 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3542
3587
|
<span class="public-chat-header__name">${n}</span>
|
|
3543
3588
|
</div>
|
|
3544
3589
|
<div class="chat-viewport">
|
|
3545
|
-
${
|
|
3590
|
+
${Tu(t)}
|
|
3546
3591
|
</div>
|
|
3547
3592
|
</div>
|
|
3548
|
-
`}async function Xv(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 xn(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 Zv(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 u=await e.client.request("workspaces.create",a);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await xn(e),(s=t.onCreated)==null||s.call(t,u)}catch(o){e.workspacesError=String(o)}finally{e.workspaceSaving=!1}}async function Jv(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 xn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function eb(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 xn(e)}catch(i){e.workspacesError=String(i)}}}const Yn=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:Zv,loadWorkspaces:xn,removeWorkspace:Jv,renameWorkspace:eb},Symbol.toStringTag,{value:"Module"})),Mu={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"},Qa=Mu,eo={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Mu));new Set(Object.values(eo));function tb(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 nb=4008;class ib{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 ah();const f=(p=uh({deviceId:o.deviceId,role:t}))==null?void 0:p.token;a=f??this.opts.token,r=!!(f&&this.opts.token)}const u=a||this.opts.password?{token:a,password:this.opts.password}:void 0;let c;if(s&&o){const f=Date.now(),b=this.connectNonce??void 0,h=tb({deviceId:o.deviceId,clientId:this.opts.clientName??Qa.CONTROL_UI,clientMode:this.opts.mode??eo.WEBCHAT,role:t,scopes:n,signedAtMs:f,token:a??null,nonce:b}),v=await lh(o.privateKey,h);c={id:o.deviceId,publicKey:o.publicKey,signature:v,signedAt:f,nonce:b}}const l={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Qa.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??eo.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:c,caps:[],auth:u,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",l).then(f=>{var b,h,v;(b=f==null?void 0:f.auth)!=null&&b.deviceToken&&o&&dh({deviceId:o.deviceId,role:f.auth.role??t,token:f.auth.deviceToken,scopes:f.auth.scopes??[]}),this.backoffMs=800,(v=(h=this.opts).onHello)==null||v.call(h,f)}).catch(()=>{var f;r&&o&&ph({deviceId:o.deviceId,role:t}),(f=this.ws)==null||f.close(nb,"connect failed")})}handleMessage(t){var s,o,r,a,u,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,b=f&&typeof f.nonce=="string"?f.nonce:null;b&&(this.connectNonce=b,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(((u=l.error)==null?void 0:u.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=lo(),s={type:"req",id:i,method:t,params:n},o=new Promise((r,a)=>{this.pending.set(i,{resolve:u=>r(u),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 sb(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 ob(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 Pu(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function rb(e,t){const n=Pu(e).filter(i=>i.id!==t.id);return n.push(t),n}function Ya(e,t){return Pu(e).filter(n=>n.id!==t)}class ab{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 As=null;function mn(){return As||(As=new ab),As}function Qo(e){return e instanceof Error?e.message:String(e)}async function lb(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=Qo(t)}finally{e.browserLoading=!1}}async function cb(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=Qo(t)}finally{e.browserLoading=!1}}}async function Es(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 Cs(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 ub(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=Qo(t)}}function db(e){e.browserInputMode=!e.browserInputMode}function pb(e){e.browserFullscreen=!e.browserFullscreen,mn().detach()}function hb(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,mn().updateFrame(t.data,t.metadata)}function fb(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function gb(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function no(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=Ls(s);e.assistantName=o.name,e.assistantAvatar=o.avatar,e.assistantAgentId=o.agentId??null}catch{}}async function io(e){return(await e.request("apikeys.list")).providers??[]}async function Xa(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function mb(e,t){await e.request("apikeys.remove",{provider:t})}const Si="taskmaster_update_pending";async function Lu(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 yb(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(Si,String(Date.now())),localStorage.removeItem(Yo)}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")yn(),e.updateMessage=o.result.reason||"Update skipped",e.updateRunning=!1,(i=e.requestUpdate)==null||i.call(e);else throw yn(),new Error(o.result.reason||"Update failed")}catch(o){yn(),e.updateMessage=`Update failed: ${String(o)}`,e.updateRunning=!1,e.updateProgressSteps=[],(s=e.requestUpdate)==null||s.call(e)}}}function vb(e,t){var i,s,o;const n=t.phase;if(n==="step-start"){const r=t.name,a=t.index,u=t.total;e.updateMessage=`Updating: ${r} (${a+1}/${u})`;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:u,status:"running"}],(i=e.requestUpdate)==null||i.call(e)}else if(n==="step-done"){const r=t.name,a=t.index,u=t.total,c=t.ok,l=t.durationMs,p=e.updateProgressSteps.find(b=>b.index===a);p?(p.status=c?"done":"failed",p.durationMs=l):e.updateProgressSteps=[...e.updateProgressSteps,{name:r,index:a,total:u,status:c?"done":"failed",durationMs:l}];const f=!c&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=c?`Updating: ${r} done (${a+1}/${u})`:`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,yn()}(o=e.requestUpdate)==null||o.call(e)}}async function bb(e){var n,i,s,o;if(!e.client||!e.connected)return;const t=kb();yn();try{const r=await e.client.request("update.lastResult",{});if(!r.ok||!r.result)return;const a=5*6e4,u=Date.now()-r.result.ts<a;if(!t&&!u||Sb(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 Yo="taskmaster_update_dismissed";function wb(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Yo,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function kb(){try{const e=localStorage.getItem(Si);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(Si),!1):!0:!1}catch{return!1}}function yn(){try{localStorage.removeItem(Si)}catch{}}function Sb(e){try{const t=localStorage.getItem(Yo);return t?Number(t)>=e:!1}catch{return!1}}function Ts(e,t){var a,u,c;const n=(e??"").trim(),i=(a=t.mainSessionKey)==null?void 0:a.trim();if(!i)return n;if(!n)return i;const s=((u=t.mainKey)==null?void 0:u.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 $b(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=Ts(e.sessionKey,t),i=Ts(e.settings.sessionKey,t),s=Ts(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&&Ze(e,r)}function Te(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 ib({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){Za(e,o),no(e),(((r=e.publicChatConfig)==null?void 0:r.auth)??"anonymous")==="anonymous"&&Mb(e);return}hi()&&(Po(),e.uninstallDone=!1),Za(e,o),e.handleAccessCheck(),bb(e).then(()=>{Lu(e)}),no(e),Xv(e),(e.chatPage||e.setup)&&Eb(e),wo(e,{quiet:!0}),bo(e,{quiet:!0}),xn(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&Le(e),e.setup&&(Cb(e),Tb(e),_b(e)),di(e)},onClose:({code:o,reason:r})=>{e.connected=!1,o!==1012&&(e.lastError=`disconnected (${o}): ${r||"no reason"}`)},onEvent:o=>xb(e,o),onGap:({expected:o,received:r})=>{console.warn(`[gateway] event gap: expected seq ${o}, got ${r}`),di(e)}}),e.client.start()}function xb(e,t){try{Ab(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function Ab(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;hp(e,t.payload);return}if(t.event==="chat"){const i=t.payload;i!=null&&i.sessionKey&&xc(e,i.sessionKey);const s=Pl(e,i);if((s==="final"||s==="error"||s==="aborted")&&(uo(e),sf(e)),s==="final"){const o=e,r=Math.max((((n=o.chatMessages)==null?void 0:n.length)??0)+10,Pe);Me(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"&&e.tab==="cron"&&_o(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&bo(e,{quiet:!0}),t.event==="exec.approval.requested"){const i=sb(t.payload);if(i){e.execApprovalQueue=rb(e.execApprovalQueue,i),e.execApprovalError=null;const s=Math.max(0,i.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=Ya(e.execApprovalQueue,i.id)},s)}return}if(t.event==="browser.screencast.frame"){hb(e,t.payload);return}if(t.event==="browser.handoff"){fb(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){gb(e);return}if(t.event==="exec.approval.resolved"){const i=ob(t.payload);i&&(e.execApprovalQueue=Ya(e.execApprovalQueue,i.id));return}if(t.event==="update.progress"){vb(e,t.payload);return}}function Za(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&&$b(e,n.sessionDefaults)}async function Eb(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 Cb(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await io(e.client)}catch{}}async function Tb(e){if(!(!e.client||!e.connected))try{e.tailscaleStatus=await e.client.request("tailscale.status")}catch{}}async function _b(e){if(!(!e.client||!e.connected))try{e.wifiStatus=await e.client.request("wifi.status")}catch{}}const Ja="taskmaster_public_id";function Iu(e=30){var s;const t=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(`${Ja}=`));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=`${Ja}=${n}; path=/; expires=${i}; SameSite=Lax`,n}async function Mb(e){var n,i;if(!e.client||!e.connected)return;const t=Iu((n=e.publicChatConfig)==null?void 0:n.cookieTtlDays);try{const s=(i=e.publicChatConfig)==null?void 0:i.accountId,o=await e.client.request("public.session",{cookieId:t,accountId:s});o!=null&&o.sessionKey&&(e.publicChatSessionKey=o.sessionKey,e.sessionKey=o.sessionKey,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready",Me(e))}catch(s){console.error("[public-chat] failed to resolve anonymous session:",s),e.lastError="Failed to start chat session"}}let Se=!1,de=null,Ft="",$i="";function Ru(e){return e.replace(/[\s\-()]/g,"")}function Du(){Se=!1,de=null,Ft="",$i=""}async function Pb(e){if(!e.client||!e.connected)return;const t=Iu(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){de=n instanceof Error?n.message:"Failed to start session",e.requestUpdate()}}async function el(e){if(!e.client||Se)return;const t=Ru(Ft);if(!t){de="Please enter your phone number",e.requestUpdate();return}Se=!0,de=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{phone:t,name:$i.trim()||void 0});n!=null&&n.ok?e.onAuthStepChange("otp"):de=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){de=n instanceof Error?n.message:"Failed to send verification code"}finally{Se=!1,e.requestUpdate()}}async function tl(e,t){if(!(!e.client||Se)){if(!t.trim()){de="Please enter the verification code",e.requestUpdate();return}Se=!0,de=null,e.requestUpdate();try{const n=await e.client.request("public.otp.verify",{phone:Ru(Ft),code:t.trim(),accountId:e.accountId});n!=null&&n.ok&&n.sessionKey?(Du(),e.onAuthenticated(n.sessionKey)):de=(n==null?void 0:n.error)??"Invalid verification code"}catch(n){de=n instanceof Error?n.message:"Verification failed"}finally{Se=!1,e.requestUpdate()}}}function _s(e){return S}function nl(e){return d`
|
|
3593
|
+
`}async function sb(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 En(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 ob(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 u=await e.client.request("workspaces.create",a);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await En(e),(s=t.onCreated)==null||s.call(t,u)}catch(o){e.workspacesError=String(o)}finally{e.workspaceSaving=!1}}async function rb(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 En(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function ab(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 En(e)}catch(i){e.workspacesError=String(i)}}}const Xn=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:ob,loadWorkspaces:En,removeWorkspace:rb,renameWorkspace:ab},Symbol.toStringTag,{value:"Module"})),Iu={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"},Ya=Iu,to={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Iu));new Set(Object.values(to));function lb(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 cb=4008;class ub{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 uh();const f=(p=hh({deviceId:o.deviceId,role:t}))==null?void 0:p.token;a=f??this.opts.token,r=!!(f&&this.opts.token)}const u=a||this.opts.password?{token:a,password:this.opts.password}:void 0;let c;if(s&&o){const f=Date.now(),b=this.connectNonce??void 0,h=lb({deviceId:o.deviceId,clientId:this.opts.clientName??Ya.CONTROL_UI,clientMode:this.opts.mode??to.WEBCHAT,role:t,scopes:n,signedAtMs:f,token:a??null,nonce:b}),v=await dh(o.privateKey,h);c={id:o.deviceId,publicKey:o.publicKey,signature:v,signedAt:f,nonce:b}}const l={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Ya.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??to.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:c,caps:[],auth:u,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",l).then(f=>{var b,h,v;(b=f==null?void 0:f.auth)!=null&&b.deviceToken&&o&&fh({deviceId:o.deviceId,role:f.auth.role??t,token:f.auth.deviceToken,scopes:f.auth.scopes??[]}),this.backoffMs=800,(v=(h=this.opts).onHello)==null||v.call(h,f)}).catch(()=>{var f;r&&o&&gh({deviceId:o.deviceId,role:t}),(f=this.ws)==null||f.close(cb,"connect failed")})}handleMessage(t){var s,o,r,a,u,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,b=f&&typeof f.nonce=="string"?f.nonce:null;b&&(this.connectNonce=b,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(((u=l.error)==null?void 0:u.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=co(),s={type:"req",id:i,method:t,params:n},o=new Promise((r,a)=>{this.pending.set(i,{resolve:u=>r(u),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 no(e){return typeof e=="object"&&e!==null}function db(e){if(!no(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!no(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 pb(e){if(!no(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 Ru(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function hb(e,t){const n=Ru(e).filter(i=>i.id!==t.id);return n.push(t),n}function Ja(e,t){return Ru(e).filter(n=>n.id!==t)}class fb{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 Es=null;function vn(){return Es||(Es=new fb),Es}function Jo(e){return e instanceof Error?e.message:String(e)}async function gb(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=Jo(t)}finally{e.browserLoading=!1}}async function mb(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=Jo(t)}finally{e.browserLoading=!1}}}async function Cs(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 Ts(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 yb(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=Jo(t)}}function vb(e){e.browserInputMode=!e.browserInputMode}function bb(e){e.browserFullscreen=!e.browserFullscreen,vn().detach()}function wb(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,vn().updateFrame(t.data,t.metadata)}function kb(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function Sb(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function io(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=Is(s);e.assistantName=o.name,e.assistantAvatar=o.avatar,e.assistantAgentId=o.agentId??null}catch{}}async function so(e){return(await e.request("apikeys.list")).providers??[]}async function Xa(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function $b(e,t){await e.request("apikeys.remove",{provider:t})}const xi="taskmaster_update_pending";async function Du(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 xb(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(xi,String(Date.now())),localStorage.removeItem(Xo)}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")bn(),e.updateMessage=o.result.reason||"Update skipped",e.updateRunning=!1,(i=e.requestUpdate)==null||i.call(e);else throw bn(),new Error(o.result.reason||"Update failed")}catch(o){bn(),e.updateMessage=`Update failed: ${String(o)}`,e.updateRunning=!1,e.updateProgressSteps=[],(s=e.requestUpdate)==null||s.call(e)}}}function Ab(e,t){var i,s,o;const n=t.phase;if(n==="step-start"){const r=t.name,a=t.index,u=t.total;e.updateMessage=`Updating: ${r} (${a+1}/${u})`;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:u,status:"running"}],(i=e.requestUpdate)==null||i.call(e)}else if(n==="step-done"){const r=t.name,a=t.index,u=t.total,c=t.ok,l=t.durationMs,p=e.updateProgressSteps.find(b=>b.index===a);p?(p.status=c?"done":"failed",p.durationMs=l):e.updateProgressSteps=[...e.updateProgressSteps,{name:r,index:a,total:u,status:c?"done":"failed",durationMs:l}];const f=!c&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=c?`Updating: ${r} done (${a+1}/${u})`:`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,bn()}(o=e.requestUpdate)==null||o.call(e)}}async function Eb(e){var n,i,s,o;if(!e.client||!e.connected)return;const t=Tb();bn();try{const r=await e.client.request("update.lastResult",{});if(!r.ok||!r.result)return;const a=5*6e4,u=Date.now()-r.result.ts<a;if(!t&&!u||_b(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 Xo="taskmaster_update_dismissed";function Cb(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Xo,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function Tb(){try{const e=localStorage.getItem(xi);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(xi),!1):!0:!1}catch{return!1}}function bn(){try{localStorage.removeItem(xi)}catch{}}function _b(e){try{const t=localStorage.getItem(Xo);return t?Number(t)>=e:!1}catch{return!1}}function _s(e,t){var a,u,c;const n=(e??"").trim(),i=(a=t.mainSessionKey)==null?void 0:a.trim();if(!i)return n;if(!n)return i;const s=((u=t.mainKey)==null?void 0:u.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 Mb(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=_s(e.sessionKey,t),i=_s(e.settings.sessionKey,t),s=_s(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&&Ze(e,r)}function _e(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 ub({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){Za(e,o),io(e),(((r=e.publicChatConfig)==null?void 0:r.auth)??"anonymous")==="anonymous"&&Nb(e);return}gi()&&(Lo(),e.uninstallDone=!1),Za(e,o),e.handleAccessCheck(),Eb(e).then(()=>{Du(e)}),io(e),sb(e),(e.chatPage||e.setup)&&Ib(e),ko(e,{quiet:!0}),wo(e,{quiet:!0}),En(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&Ie(e),e.setup&&(Rb(e),Db(e),Bb(e)),hi(e)},onClose:({code:o,reason:r})=>{e.connected=!1,o!==1012&&(e.lastError=`disconnected (${o}): ${r||"no reason"}`)},onEvent:o=>Pb(e,o),onGap:({expected:o,received:r})=>{console.warn(`[gateway] event gap: expected seq ${o}, got ${r}`),hi(e)}}),e.client.start()}function Pb(e,t){try{Lb(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function Lb(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;mp(e,t.payload);return}if(t.event==="chat"){const i=t.payload;i!=null&&i.sessionKey&&Cc(e,i.sessionKey);const s=Ll(e,i);if((s==="final"||s==="error"||s==="aborted")&&(po(e),af(e)),s==="final"){const o=e,r=Math.max((((n=o.chatMessages)==null?void 0:n.length)??0)+10,Le);Pe(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"&&e.tab==="cron"&&Mo(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&wo(e,{quiet:!0}),t.event==="exec.approval.requested"){const i=db(t.payload);if(i){e.execApprovalQueue=hb(e.execApprovalQueue,i),e.execApprovalError=null;const s=Math.max(0,i.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=Ja(e.execApprovalQueue,i.id)},s)}return}if(t.event==="browser.screencast.frame"){wb(e,t.payload);return}if(t.event==="browser.handoff"){kb(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){Sb(e);return}if(t.event==="exec.approval.resolved"){const i=pb(t.payload);i&&(e.execApprovalQueue=Ja(e.execApprovalQueue,i.id));return}if(t.event==="update.progress"){Ab(e,t.payload);return}}function Za(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&&Mb(e,n.sessionDefaults)}async function Ib(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 Rb(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await so(e.client)}catch{}}async function Db(e){if(!(!e.client||!e.connected))try{e.tailscaleStatus=await e.client.request("tailscale.status")}catch{}}async function Bb(e){if(!(!e.client||!e.connected))try{e.wifiStatus=await e.client.request("wifi.status")}catch{}}const el="taskmaster_public_id";function Bu(e=30){var s;const t=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(`${el}=`));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=`${el}=${n}; path=/; expires=${i}; SameSite=Lax`,n}async function Nb(e){var n,i;if(!e.client||!e.connected)return;const t=Bu((n=e.publicChatConfig)==null?void 0:n.cookieTtlDays);try{const s=(i=e.publicChatConfig)==null?void 0:i.accountId,o=await e.client.request("public.session",{cookieId:t,accountId:s});o!=null&&o.sessionKey&&(e.publicChatSessionKey=o.sessionKey,e.sessionKey=o.sessionKey,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready",Pe(e))}catch(s){console.error("[public-chat] failed to resolve anonymous session:",s),e.lastError="Failed to start chat session"}}let $e=!1,de=null,Ut="",Ai="";function Nu(e){return e.replace(/[\s\-()]/g,"")}function Ou(){$e=!1,de=null,Ut="",Ai=""}async function Ob(e){if(!e.client||!e.connected)return;const t=Bu(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){de=n instanceof Error?n.message:"Failed to start session",e.requestUpdate()}}async function tl(e){if(!e.client||$e)return;const t=Nu(Ut);if(!t){de="Please enter your phone number",e.requestUpdate();return}$e=!0,de=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{phone:t,name:Ai.trim()||void 0});n!=null&&n.ok?e.onAuthStepChange("otp"):de=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){de=n instanceof Error?n.message:"Failed to send verification code"}finally{$e=!1,e.requestUpdate()}}async function nl(e,t){if(!(!e.client||$e)){if(!t.trim()){de="Please enter the verification code",e.requestUpdate();return}$e=!0,de=null,e.requestUpdate();try{const n=await e.client.request("public.otp.verify",{phone:Nu(Ut),code:t.trim(),accountId:e.accountId});n!=null&&n.ok&&n.sessionKey?(Ou(),e.onAuthenticated(n.sessionKey)):de=(n==null?void 0:n.error)??"Invalid verification code"}catch(n){de=n instanceof Error?n.message:"Verification failed"}finally{$e=!1,e.requestUpdate()}}}function Ms(e){return S}function il(e){return d`
|
|
3549
3594
|
<div class="public-auth__form">
|
|
3550
3595
|
<label class="field public-auth__field">
|
|
3551
3596
|
<span>Your name (optional)</span>
|
|
3552
3597
|
<input
|
|
3553
3598
|
type="text"
|
|
3554
|
-
.value=${
|
|
3555
|
-
@input=${t=>{
|
|
3599
|
+
.value=${Ai}
|
|
3600
|
+
@input=${t=>{Ai=t.target.value}}
|
|
3556
3601
|
placeholder="Name"
|
|
3557
3602
|
/>
|
|
3558
3603
|
</label>
|
|
@@ -3560,9 +3605,9 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3560
3605
|
<span>WhatsApp number</span>
|
|
3561
3606
|
<input
|
|
3562
3607
|
type="tel"
|
|
3563
|
-
.value=${
|
|
3564
|
-
@input=${t=>{
|
|
3565
|
-
@keydown=${t=>{t.key==="Enter"&&(t.preventDefault(),
|
|
3608
|
+
.value=${Ut}
|
|
3609
|
+
@input=${t=>{Ut=t.target.value}}
|
|
3610
|
+
@keydown=${t=>{t.key==="Enter"&&(t.preventDefault(),tl(e))}}
|
|
3566
3611
|
placeholder="+44 7123 456789"
|
|
3567
3612
|
required
|
|
3568
3613
|
/>
|
|
@@ -3570,16 +3615,16 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3570
3615
|
${de?d`<div class="public-auth__error">${de}</div>`:S}
|
|
3571
3616
|
<button
|
|
3572
3617
|
class="btn primary public-auth__btn"
|
|
3573
|
-
?disabled=${
|
|
3574
|
-
@click=${()=>{
|
|
3618
|
+
?disabled=${$e}
|
|
3619
|
+
@click=${()=>{tl(e)}}
|
|
3575
3620
|
>
|
|
3576
|
-
${
|
|
3621
|
+
${$e?"Sending...":"Send verification code"}
|
|
3577
3622
|
</button>
|
|
3578
3623
|
</div>
|
|
3579
|
-
`}function
|
|
3624
|
+
`}function sl(e){let t="";return d`
|
|
3580
3625
|
<div class="public-auth__form">
|
|
3581
3626
|
<p class="public-auth__hint">
|
|
3582
|
-
We sent a verification code to <strong>${
|
|
3627
|
+
We sent a verification code to <strong>${Ut}</strong> via WhatsApp.
|
|
3583
3628
|
</p>
|
|
3584
3629
|
<label class="field public-auth__field">
|
|
3585
3630
|
<span>Verification code</span>
|
|
@@ -3588,7 +3633,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3588
3633
|
inputmode="numeric"
|
|
3589
3634
|
maxlength="6"
|
|
3590
3635
|
@input=${n=>{t=n.target.value}}
|
|
3591
|
-
@keydown=${n=>{n.key==="Enter"&&(n.preventDefault(),
|
|
3636
|
+
@keydown=${n=>{n.key==="Enter"&&(n.preventDefault(),nl(e,t))}}
|
|
3592
3637
|
placeholder="123456"
|
|
3593
3638
|
required
|
|
3594
3639
|
/>
|
|
@@ -3596,10 +3641,10 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3596
3641
|
${de?d`<div class="public-auth__error">${de}</div>`:S}
|
|
3597
3642
|
<button
|
|
3598
3643
|
class="btn primary public-auth__btn"
|
|
3599
|
-
?disabled=${
|
|
3600
|
-
@click=${()=>{
|
|
3644
|
+
?disabled=${$e}
|
|
3645
|
+
@click=${()=>{nl(e,t)}}
|
|
3601
3646
|
>
|
|
3602
|
-
${
|
|
3647
|
+
${$e?"Verifying...":"Verify"}
|
|
3603
3648
|
</button>
|
|
3604
3649
|
<button
|
|
3605
3650
|
class="btn public-auth__btn public-auth__btn--link"
|
|
@@ -3608,7 +3653,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3608
3653
|
Use a different number
|
|
3609
3654
|
</button>
|
|
3610
3655
|
</div>
|
|
3611
|
-
`}function
|
|
3656
|
+
`}function Fb(e){const{authMode:t,authStep:n}=e;return t==="anonymous"?d`
|
|
3612
3657
|
<div class="setup-container">
|
|
3613
3658
|
<div class="setup-card">
|
|
3614
3659
|
<div class="setup-spinner"></div>
|
|
@@ -3618,37 +3663,37 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3618
3663
|
`:t==="verified"?d`
|
|
3619
3664
|
<div class="setup-container">
|
|
3620
3665
|
<div class="public-auth">
|
|
3621
|
-
${
|
|
3666
|
+
${Ms()}
|
|
3622
3667
|
<h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
|
|
3623
3668
|
<p class="public-auth__subtitle">Verify your WhatsApp number to get started.</p>
|
|
3624
|
-
${n==="otp"?
|
|
3669
|
+
${n==="otp"?sl(e):il(e)}
|
|
3625
3670
|
</div>
|
|
3626
3671
|
</div>
|
|
3627
3672
|
`:n==="phone"||n==="otp"?d`
|
|
3628
3673
|
<div class="setup-container">
|
|
3629
3674
|
<div class="public-auth">
|
|
3630
|
-
${
|
|
3675
|
+
${Ms()}
|
|
3631
3676
|
<h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
|
|
3632
3677
|
<p class="public-auth__subtitle">Verify your WhatsApp number to continue your conversation across devices.</p>
|
|
3633
|
-
${n==="otp"?
|
|
3678
|
+
${n==="otp"?sl(e):il(e)}
|
|
3634
3679
|
</div>
|
|
3635
3680
|
</div>
|
|
3636
3681
|
`:d`
|
|
3637
3682
|
<div class="setup-container">
|
|
3638
3683
|
<div class="public-auth">
|
|
3639
|
-
${
|
|
3684
|
+
${Ms()}
|
|
3640
3685
|
<h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
|
|
3641
3686
|
<p class="public-auth__subtitle">How would you like to get started?</p>
|
|
3642
3687
|
<div class="public-auth__choices">
|
|
3643
3688
|
<button
|
|
3644
3689
|
class="btn primary public-auth__btn"
|
|
3645
|
-
@click=${()=>{
|
|
3690
|
+
@click=${()=>{Ob(e)}}
|
|
3646
3691
|
>
|
|
3647
3692
|
Chat now
|
|
3648
3693
|
</button>
|
|
3649
3694
|
<button
|
|
3650
3695
|
class="btn public-auth__btn"
|
|
3651
|
-
@click=${()=>{
|
|
3696
|
+
@click=${()=>{Ou(),e.onAuthStepChange("phone")}}
|
|
3652
3697
|
>
|
|
3653
3698
|
Verify with WhatsApp
|
|
3654
3699
|
</button>
|
|
@@ -3658,7 +3703,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3658
3703
|
</p>
|
|
3659
3704
|
</div>
|
|
3660
3705
|
</div>
|
|
3661
|
-
`}const Xo="taskmaster-access-session",Nu={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function Bu(){try{return localStorage.getItem(Xo)}catch{return null}}function Ou(e){try{localStorage.setItem(Xo,e)}catch{}}function Ib(){try{localStorage.removeItem(Xo)}catch{}}async function sl(e){if(e.client)try{const t=Bu(),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 Rb(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?(Ou(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 Db(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?(Ou(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 Nb(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 Bb(e){const t=Bu();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}Ib(),e.accessState={...Nu,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}function Ob(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 u=r.peer;if(!u||typeof u!="object"||u.kind!=="dm")continue;const c=u.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 Fu(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 b=f.id??"";b&&(c.meta&&o.set(b,c.meta),l.accountId&&r.set(b,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"}),u=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},b=o.get(c.phone);return b?f.meta=b:c.paired&&(f.meta={paired:!0}),f});return[...a,...u]}async function Ni(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=et(s??{}),e.adminPhones=Ob(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function Uu(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(u=>u.phone===o)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const u=et(e.configForm??((r=e.configSnapshot)==null?void 0:r.config)??{}),c=u.bindings??[],l=[...e.adminPhones,{phone:o}],p=Fu(c,l,s,i);Il(u,["bindings"],p);const f=(a=e.configSnapshot)==null?void 0:a.hash;if(!f){e.adminsError="Config hash missing; reload and retry.";return}const b=ht(u);await e.client.request("config.set",{raw:b,baseHash:f}),await Ni(e,n)}catch(u){e.adminsError=String(u)}finally{e.adminsSaving=!1}}async function Wu(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(u=>u.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 u=et(e.configForm??((r=e.configSnapshot)==null?void 0:r.config)??{}),c=u.bindings??[],l=e.adminPhones.filter(h=>h.phone!==t),p=Fu(c,l,s,i);Il(u,["bindings"],p);const f=(a=e.configSnapshot)==null?void 0:a.hash;if(!f){e.adminsError="Config hash missing; reload and retry.";return}const b=ht(u);await e.client.request("config.set",{raw:b,baseHash:f}),await Ni(e,n)}catch(u){e.adminsError=String(u)}finally{e.adminsSaving=!1}}const Fb=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:Uu,loadAdmins:Ni,removeAdmin:Wu},Symbol.toStringTag,{value:"Module"}));async function bt(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 Ku(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 bt(e,i)}catch(r){e.contactsError=String(r)}finally{e.contactsSaving=!1}}async function zu(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 bt(e,n)}catch(i){e.contactsError=String(i)}finally{e.contactsSaving=!1}}}async function Hu(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 bt(e,s)}catch(o){e.contactsError=String(o)}finally{e.contactsSaving=!1}}}async function ju(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 bt(e,i)}catch(s){e.contactsError=String(s)}finally{e.contactsSaving=!1}}}const Ub=Object.freeze(Object.defineProperty({__proto__:null,addContact:Ku,deleteContact:zu,deleteContactField:ju,loadContacts:bt,setContactField:Hu},Symbol.toStringTag,{value:"Module"}));function rn(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 Wb(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 Kb(e){const t=oe(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 zb(e){const t=oe(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function Hb(e){var i;const t=oe(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 jb(e){return e.selectedWorkspace??void 0}function oe(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const qb=/^data:/i,Vb=/^https?:\/\//i;function ol(e){var a,u;const t=((a=e.agentsList)==null?void 0:a.agents)??[],n=wl(e.sessionKey),i=(n==null?void 0:n.agentId)??((u=e.agentsList)==null?void 0:u.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 qb.test(r)||Vb.test(r)?r:o==null?void 0:o.avatarUrl}function Gb(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 Qb(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 Yb(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 u,c;return((u=a.match)==null?void 0:u.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(u=>u.id===s))return a.name;if(s==="admin"||s==="public"){const a=e.workspaces.find(u=>u.isDefault);return(a==null?void 0:a.name)??null}const o=s.replace(/-(admin|public)$/,"");if(o!==s){const a=e.workspaces.find(u=>u.name===o);return(a==null?void 0:a.name)??null}return null}function Xb(e){var t,n,i,s,o,r,a,u,c;if(e.embeddingDownloading&&!e.publicChat)return d`
|
|
3706
|
+
`}const Zo="taskmaster-access-session",Fu={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function Uu(){try{return localStorage.getItem(Zo)}catch{return null}}function Wu(e){try{localStorage.setItem(Zo,e)}catch{}}function Ub(){try{localStorage.removeItem(Zo)}catch{}}async function ol(e){if(e.client)try{const t=Uu(),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 Wb(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?(Wu(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 Kb(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?(Wu(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 zb(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 Hb(e){const t=Uu();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}Ub(),e.accessState={...Fu,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}function qb(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 u=r.peer;if(!u||typeof u!="object"||u.kind!=="dm")continue;const c=u.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 Ku(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 b=f.id??"";b&&(c.meta&&o.set(b,c.meta),l.accountId&&r.set(b,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"}),u=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},b=o.get(c.phone);return b?f.meta=b:c.paired&&(f.meta={paired:!0}),f});return[...a,...u]}async function Ni(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=tt(s??{}),e.adminPhones=qb(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function zu(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(u=>u.phone===o)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const u=tt(e.configForm??((r=e.configSnapshot)==null?void 0:r.config)??{}),c=u.bindings??[],l=[...e.adminPhones,{phone:o}],p=Ku(c,l,s,i);Rl(u,["bindings"],p);const f=(a=e.configSnapshot)==null?void 0:a.hash;if(!f){e.adminsError="Config hash missing; reload and retry.";return}const b=ft(u);await e.client.request("config.set",{raw:b,baseHash:f}),await Ni(e,n)}catch(u){e.adminsError=String(u)}finally{e.adminsSaving=!1}}async function Hu(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(u=>u.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 u=tt(e.configForm??((r=e.configSnapshot)==null?void 0:r.config)??{}),c=u.bindings??[],l=e.adminPhones.filter(h=>h.phone!==t),p=Ku(c,l,s,i);Rl(u,["bindings"],p);const f=(a=e.configSnapshot)==null?void 0:a.hash;if(!f){e.adminsError="Config hash missing; reload and retry.";return}const b=ft(u);await e.client.request("config.set",{raw:b,baseHash:f}),await Ni(e,n)}catch(u){e.adminsError=String(u)}finally{e.adminsSaving=!1}}const jb=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:zu,loadAdmins:Ni,removeAdmin:Hu},Symbol.toStringTag,{value:"Module"}));async function wt(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 qu(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 wt(e,i)}catch(r){e.contactsError=String(r)}finally{e.contactsSaving=!1}}async function ju(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 wt(e,n)}catch(i){e.contactsError=String(i)}finally{e.contactsSaving=!1}}}async function Vu(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 wt(e,s)}catch(o){e.contactsError=String(o)}finally{e.contactsSaving=!1}}}async function Gu(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 wt(e,i)}catch(s){e.contactsError=String(s)}finally{e.contactsSaving=!1}}}const Vb=Object.freeze(Object.defineProperty({__proto__:null,addContact:qu,deleteContact:ju,deleteContactField:Gu,loadContacts:wt,setContactField:Vu},Symbol.toStringTag,{value:"Module"}));function ln(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 Gb(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 Qb(e){const t=oe(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 Yb(e){const t=oe(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function Jb(e){var i;const t=oe(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 Xb(e){return e.selectedWorkspace??void 0}function oe(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const Zb=/^data:/i,ew=/^https?:\/\//i;function rl(e){var a,u;const t=((a=e.agentsList)==null?void 0:a.agents)??[],n=kl(e.sessionKey),i=(n==null?void 0:n.agentId)??((u=e.agentsList)==null?void 0:u.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 Zb.test(r)||ew.test(r)?r:o==null?void 0:o.avatarUrl}function tw(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 nw(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 iw(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 u,c;return((u=a.match)==null?void 0:u.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(u=>u.id===s))return a.name;if(s==="admin"||s==="public"){const a=e.workspaces.find(u=>u.isDefault);return(a==null?void 0:a.name)??null}const o=s.replace(/-(admin|public)$/,"");if(o!==s){const a=e.workspaces.find(u=>u.name===o);return(a==null?void 0:a.name)??null}return null}function sw(e){var t,n,i,s,o,r,a,u,c;if(e.embeddingDownloading&&!e.publicChat)return d`
|
|
3662
3707
|
<div class="setup-container">
|
|
3663
3708
|
<div class="setup-card" style="text-align:center; max-width:420px;">
|
|
3664
3709
|
<div class="setup-spinner"></div>
|
|
@@ -3672,14 +3717,14 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3672
3717
|
</p>
|
|
3673
3718
|
</div>
|
|
3674
3719
|
</div>
|
|
3675
|
-
`;if(e.publicChat)return e.connected?e.publicChatAuthenticated?
|
|
3720
|
+
`;if(e.publicChat)return e.connected?e.publicChatAuthenticated?ib({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??rl(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(),ie(async()=>{const{loadChatHistory:l}=await Promise.resolve().then(()=>ui);return{loadChatHistory:l}},void 0,import.meta.url).then(({loadChatHistory:l})=>{l(e)})),onDraftChange:l=>e.chatMessage=l,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()}}):Fb({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=>{e.publicChatSessionKey=l,e.sessionKey=l,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready",ie(async()=>{const{loadChatHistory:p}=await Promise.resolve().then(()=>ui);return{loadChatHistory:p}},void 0,import.meta.url).then(({loadChatHistory:p})=>{p(e)})},onAuthStepChange:l=>{e.publicChatAuthStep=l},requestUpdate:()=>{e.requestUpdate()}}):d`
|
|
3676
3721
|
<div class="setup-container">
|
|
3677
3722
|
<div class="setup-card">
|
|
3678
3723
|
<div class="setup-spinner"></div>
|
|
3679
3724
|
<p>Connecting...</p>
|
|
3680
3725
|
</div>
|
|
3681
3726
|
</div>
|
|
3682
|
-
`;if(e.connected&&e.accessState.checked){const{accessState:l}=e;if(l.hasPins&&!l.authenticated)return Ga({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,b)=>e.handleChangePin(p,f,b)});if(!l.hasMasterPin&&!l.authenticated&&e.setup)return Ga({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",S}if(e.setup){const l=Gb(e.channelsSnapshot),p=((n=(t=e.channelsSnapshot)==null?void 0:t.channelAccounts)==null?void 0:n.whatsapp)??[],f=Qb(e.channelsSnapshot),b=Yb(e);return Lf({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 G(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 G(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await G(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),G(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,v)=>{const k=e.newWorkspacePin;await e.handleWorkspaceCreate(h,v),k.match(/^\d{4,6}$/)&&(await Nb(e,h,k),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,v)=>e.handleWorkspaceRename(h,v),whatsappDmPolicy:(()=>{const h=oe(e),v=h==null?void 0:h.whatsappAccountId,k=v?p.find($=>$.accountId===v):p[0];return(k==null?void 0:k.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var T;const h=oe(e),v=h==null?void 0:h.whatsappAccountId,k=v?p.find(_=>_.accountId===v):p[0];if(!k)return;const A=k.dmPolicy!=null&&k.dmPolicy!=="disabled"?"disabled":"open",C=A==="open"?{dmPolicy:A,allowFrom:["*"]}:{dmPolicy:A};try{const _=await e.client.request("config.get"),R=_.config,O=(T=R==null?void 0:R.channels)==null?void 0:T.whatsapp,me=((O==null?void 0:O.accounts)??{})[k.accountId]?{channels:{whatsapp:{accounts:{[k.accountId]:C}}}}:{channels:{whatsapp:C}};await e.client.request("config.patch",{raw:JSON.stringify(me),baseHash:_.hash,note:`WhatsApp DM policy → ${A}`,skipRestart:!0}),await G(e,!1)}catch(_){console.error("DM toggle failed:",_)}},whatsappModel:(()=>{var T,_;const h=oe(e);if(!h)return null;const v=h.agents.find(R=>R.id.endsWith("-public")||R.id==="public");if(!v)return null;const k=(T=e.configSnapshot)==null?void 0:T.config,$=(_=k==null?void 0:k.agents)==null?void 0:_.list;if(!Array.isArray($))return null;const A=$.find(R=>R.id===v.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 v=oe(e);if(!v)return;const k=v.agents.find($=>$.id.endsWith("-public")||$.id==="public");if(k)try{const $=await e.client.request("config.get"),A=$.config,C=(A==null?void 0:A.agents)??{},T=Array.isArray(C.list)?[...C.list]:[],_=T.findIndex(O=>O.id===k.id);if(h)_>=0?T[_]={...T[_],model:h}:T.push({id:k.id,model:h});else if(_>=0){const{model:O,...ee}=T[_];Object.keys(ee).length<=1?T.splice(_,1):T[_]=ee}const R=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(R),baseHash:$.hash,note:`Public agent model → ${h||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Model change failed:",$)}},whatsappThinkingLevel:(()=>{var C,T,_;const h=oe(e);if(!h)return null;const v=h.agents.find(R=>R.id.endsWith("-public")||R.id==="public");if(!v)return null;const k=(C=e.configSnapshot)==null?void 0:C.config,$=(T=k==null?void 0:k.agents)==null?void 0:T.list;if(!Array.isArray($))return null;const A=$.find(R=>R.id===v.id);return((_=A==null?void 0:A.thinkingLevel)==null?void 0:_.trim())||null})(),onWhatsAppThinkingChange:async h=>{const v=oe(e);if(!v)return;const k=v.agents.find($=>$.id.endsWith("-public")||$.id==="public");if(k)try{const $=await e.client.request("config.get"),A=$.config,C=(A==null?void 0:A.agents)??{},T=Array.isArray(C.list)?[...C.list]:[],_=T.findIndex(ee=>ee.id===k.id),R=h==="off"?void 0:h;if(R)_>=0?T[_]={...T[_],thinkingLevel:R}:T.push({id:k.id,thinkingLevel:R});else if(_>=0){const{thinkingLevel:ee,...me}=T[_];Object.keys(me).length<=1?T.splice(_,1):T[_]=me}const O=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(O),baseHash:$.hash,note:`Public agent thinking → ${R||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Thinking change failed:",$)}},whatsappGroupPolicy:(()=>{var _,R;const h=(_=e.configSnapshot)==null?void 0:_.config,v=(R=h==null?void 0:h.channels)==null?void 0:R.whatsapp,k=oe(e),$=k==null?void 0:k.whatsappAccountId,A=(v==null?void 0:v.accounts)??{},C=$?A[$]:void 0;return(C==null?void 0:C.groupPolicy)??(v==null?void 0:v.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var R,O;const h=(R=e.configSnapshot)==null?void 0:R.config,v=(O=h==null?void 0:h.channels)==null?void 0:O.whatsapp,k=oe(e),$=k==null?void 0:k.whatsappAccountId,A=(v==null?void 0:v.accounts)??{},C=$?A[$]:void 0,_=((C==null?void 0:C.groups)??(v==null?void 0:v.groups)??{})["*"];return(_==null?void 0:_.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var k;const h=oe(e),v=h==null?void 0:h.whatsappAccountId;try{const $=await e.client.request("config.get"),A=$.config,C=((k=A==null?void 0:A.channels)==null?void 0:k.whatsapp)??{},T=C.accounts??{},_=v?T[v]:void 0,R=(_==null?void 0:_.groupPolicy)??C.groupPolicy??"allowlist",O=R==="disabled"||R==="allowlist",ee=O?"open":"disabled",me=O?{"*":{}}:void 0,qe={groupPolicy:ee};me&&(qe.groups=me);const Z=_?{channels:{whatsapp:{accounts:{[v]:qe}}}}:{channels:{whatsapp:qe}};await e.client.request("config.patch",{raw:JSON.stringify(Z),baseHash:$.hash,note:`WhatsApp groups → ${ee}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Group toggle failed:",$)}},onWhatsAppGroupMentionChange:async h=>{var $;const v=oe(e),k=v==null?void 0:v.whatsappAccountId;try{const A=await e.client.request("config.get"),C=A.config,_=((($=C==null?void 0:C.channels)==null?void 0:$.whatsapp)??{}).accounts??{},R=k?_[k]:void 0,O={"*":{requireMention:h}},ee=R?{channels:{whatsapp:{accounts:{[k]:{groups:O}}}}}:{channels:{whatsapp:{groups:O}}};await e.client.request("config.patch",{raw:JSON.stringify(ee),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:b,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const h=await e.client.request("config.get"),v=h.config,k=(v==null?void 0:v.bindings)??[],$=oe(e),A=$==null?void 0:$.agents.find(O=>O.id.endsWith("-admin")||O.id==="admin"),C=(A==null?void 0:A.id)??"admin",T=k.filter(O=>{var ee;return((ee=O.match)==null?void 0:ee.channel)!=="imessage"}),_=[{agentId:C,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],R=[...T,..._];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:R}),baseHash:h.hash,note:"Enable iMessage (self-chat) for "+(($==null?void 0:$.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([G(e,!0),Le(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await G(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const h=await e.client.request("config.get"),v=h.config,$=((v==null?void 0:v.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:$}),baseHash:h.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([G(e,!0),Le(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const h=await e.client.request("config.get"),v=h.config,k=(v==null?void 0:v.bindings)??[],$=oe(e),A=$==null?void 0:$.agents.find(R=>R.id.endsWith("-admin")||R.id==="admin"),C=(A==null?void 0:A.id)??"admin",T=k.filter(R=>{var O;return((O=R.match)==null?void 0:O.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:[...T,..._]}),baseHash:h.hash,note:"Reassign iMessage to "+(($==null?void 0:$.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([G(e,!0),Le(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,v)=>{e.apiKeySavingProvider=h,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Xa(e.client,h,v);const k=`${h} key saved`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await io(e.client)}catch{}h==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async h=>{e.apiKeySavingProvider=h,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await mb(e.client,h);const v=`${h} key removed`;e.apiKeySuccess=v,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await io(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===v&&(e.apiKeySuccess=null)},2500)}catch(v){e.apiKeyError=v instanceof Error?v.message:"Failed to remove 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 Xa(e.client,"anthropic",h),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(v){e.authApiKeyError=v instanceof Error?v.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var v;const h=e.selectedWorkspace??((v=e.workspaces[0])==null?void 0:v.name);return h?e.accessState.accounts.some(k=>k.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,v)=>{var $;const k=e.selectedWorkspace??(($=e.workspaces[0])==null?void 0:$.name);k&&e.handleAccountPinSave(k,h,v)},publicChatEnabled:(()=>{var k;const h=(k=e.configSnapshot)==null?void 0:k.config,v=h==null?void 0:h.publicChat;return(v==null?void 0:v.enabled)===!0})(),publicChatAuthMode:(()=>{var $;const h=($=e.configSnapshot)==null?void 0:$.config,v=h==null?void 0:h.publicChat,k=v==null?void 0:v.auth;return k==="verified"||k==="choice"?k:"anonymous"})(),publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var h;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const v=await e.client.request("config.get"),k=v.config,$=((h=k==null?void 0:k.publicChat)==null?void 0:h.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!$}}),baseHash:v.hash,note:`Public chat → ${$?"disabled":"enabled"}`}),e.configSnapshot=await e.client.request("config.get")}catch(v){console.error("Public chat toggle failed:",v)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async h=>{if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const v=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{auth:h}}),baseHash:v.hash,note:`Public chat auth → ${h}`}),e.configSnapshot=await e.client.request("config.get")}catch(v){console.error("Public chat auth mode change failed:",v)}finally{e.publicChatToggleBusy=!1}}},brandAccentColor:(()=>{var k;const h=e.selectedWorkspace;return h?((k=Oe()[h])==null?void 0:k.accentColor)??"":""})(),brandBackgroundColor:(()=>{var k;const h=e.selectedWorkspace;return h?((k=Oe()[h])==null?void 0:k.backgroundColor)??"":""})(),brandHasLogo:(()=>{var k;const h=e.selectedWorkspace;return h?!!((k=Oe()[h])!=null&&k.logoUrl):!1})(),brandingBusy:e.brandingBusy,brandingExpanded:e.brandingExpanded,onBrandingToggle:()=>{e.brandingExpanded=!e.brandingExpanded},onBrandAccentColorChange:async h=>{var k;const v=e.selectedWorkspace;if(!(!v||e.brandingBusy)){e.brandingBusy=!0;try{const $=await e.client.request("config.get"),A=$.config,C=((k=A==null?void 0:A.workspaces)==null?void 0:k[v])??{},T=C.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[v]:{...C,brand:{...T,accentColor:h}}}}),baseHash:$.hash,note:`Brand accent → ${h}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const _=Oe();_[v]||(_[v]={}),_[v].accentColor=h,un(v)}catch($){console.error("Brand accent change failed:",$)}finally{e.brandingBusy=!1}}},onBrandBackgroundColorChange:async h=>{var k;const v=e.selectedWorkspace;if(!(!v||e.brandingBusy)){e.brandingBusy=!0;try{const $=await e.client.request("config.get"),A=$.config,C=((k=A==null?void 0:A.workspaces)==null?void 0:k[v])??{},T=C.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[v]:{...C,brand:{...T,backgroundColor:h}}}}),baseHash:$.hash,note:`Brand background → ${h}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const _=Oe();_[v]||(_[v]={}),_[v].backgroundColor=h,un(v)}catch($){console.error("Brand background change failed:",$)}finally{e.brandingBusy=!1}}},onBrandLogoUpload:async h=>{const v=e.selectedWorkspace;if(!(!v||e.brandingBusy)){e.brandingBusy=!0;try{const k=await h.arrayBuffer(),$=new Uint8Array(k);let A="";for(let _=0;_<$.length;_++)A+=String.fromCharCode($[_]);const C=btoa(A);await e.client.request("brand.uploadLogo",{workspace:v,data:C,mimeType:h.type});const T=Oe();T[v]||(T[v]={}),T[v].logoUrl=`/brand-logo/${encodeURIComponent(v)}`}catch(k){console.error("Brand logo upload failed:",k)}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 v=Oe();v[h]&&delete v[h].logoUrl}catch(v){console.error("Brand logo remove failed:",v)}finally{e.brandingBusy=!1}}},onBrandReset:async()=>{var v;const h=e.selectedWorkspace;if(!(!h||e.brandingBusy)){e.brandingBusy=!0;try{const k=await e.client.request("config.get"),$=k.config,A=((v=$==null?void 0:$.workspaces)==null?void 0:v[h])??{},{brand:C,...T}=A;await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[h]:{...T,brand:null}}}),baseHash:k.hash,note:"Brand reset to defaults",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");try{await e.client.request("brand.removeLogo",{workspace:h})}catch{}const _=Oe();delete _[h],un(h)}catch(k){console.error("Brand reset failed:",k)}finally{e.brandingBusy=!1}}},tailscaleStatus:e.tailscaleStatus,tailscaleBusy:e.tailscaleBusy,tailscaleAuthUrl:e.tailscaleAuthUrl,tailscaleError:e.tailscaleError,tailscaleFunnelEnableUrl:e.tailscaleFunnelEnableUrl,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 v=setInterval(async()=>{try{const k=await e.client.request("tailscale.status");e.tailscaleStatus=k,k.loggedIn&&(clearInterval(v),e.tailscaleAuthUrl=null,e.tailscaleBusy=!1)}catch{}},3e3);setTimeout(()=>{clearInterval(v),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}}},onTailscaleFunnelEnable:async()=>{var h;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleFunnelEnableUrl=null;try{await e.client.request("tailscale.funnel.enable")}catch(v){console.error("Tailscale funnel enable failed:",v);const k=v;(h=k.payload)!=null&&h.enableUrl&&(e.tailscaleFunnelEnableUrl=k.payload.enableUrl),e.tailscaleError=k.message||"Failed to enable Funnel",e.tailscaleBusy=!1}}},onTailscaleFunnelDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.funnel.disable")}catch(h){console.error("Tailscale funnel disable failed:",h),e.tailscaleBusy=!1}}},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,v]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);e.wifiNetworks=h.networks,e.wifiStatus=v}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 v=await e.client.request("wifi.connect",{ssid:h,password:e.wifiPassword});e.wifiPassword="",e.wifiSelectedSsid=null,e.wifiNetworks=[],e.wifiStatus={available:!0,connected:v.connected,ssid:v.ssid,signal:null,ip:v.ip,savedSsid:v.ssid,autoconnect:!0},e.wifiBusy=!1;try{const k=await e.client.request("wifi.status");e.wifiStatus=k}catch{}}catch(v){console.error("WiFi connect failed:",v),e.wifiError=v.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},wsProps:Wb(e)})}if(e.filesPage){const l=Hb(e);return yf({connected:e.connected,wsProps:rn(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:()=>Kt(e,l),onReindex:()=>Lh(e,l),onSelectFile:p=>{e.filesPendingDeletePath=null,xh(e,p,l)},onToggleSelectFile:p=>Ah(e,p,l),onToggleDir:p=>Ih(e,p),onUpload:(p,f)=>Th(e,p,f,l),onNewFolder:(p,f)=>_h(e,p,f,l),onDownload:p=>$c(e,p,l),onBulkDownload:()=>Eh(e,l),onDelete:p=>{e.filesPendingDeletePath=null,Mh(e,p,l)},pendingDeletePath:e.filesPendingDeletePath,onArmDelete:p=>{e.filesPendingDeletePath=p||null},onMoveToDir:(p,f)=>Ch(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;Rh(e,p,f)},onSearchAgentChange:p=>{e.filesSearchAgentId=p},onSearchClear:()=>{Dh(e)},onSearchQueryChange:p=>{e.filesSearchQuery=p}})}if(e.browserPage)return df({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:()=>lb(e),onStop:()=>cb(e),onToggleInput:()=>db(e),onToggleFullscreen:()=>pb(e),onCompleteHandoff:()=>ub(e),onCanvasMouseDown:l=>{const f=l.target.getBoundingClientRect(),h=mn().translateCoordinates(l.clientX-f.left,l.clientY-f.top);Es(e,"mousePressed",h.x,h.y,l.button===2?"right":l.button===1?"middle":"left")},onCanvasMouseUp:l=>{const f=l.target.getBoundingClientRect(),h=mn().translateCoordinates(l.clientX-f.left,l.clientY-f.top);Es(e,"mouseReleased",h.x,h.y)},onCanvasMouseMove:l=>{const p=mn();if(p.shouldThrottleMouseMove())return;const b=l.target.getBoundingClientRect(),h=p.translateCoordinates(l.clientX-b.left,l.clientY-b.top);Es(e,"mouseMoved",h.x,h.y)},onCanvasKeyDown:l=>{let p=0;l.altKey&&(p|=1),l.ctrlKey&&(p|=2),l.metaKey&&(p|=4),l.shiftKey&&(p|=8),Cs(e,"keyDown",l.key,{code:l.code,modifiers:p||void 0}),l.key.length===1&&Cs(e,"char",l.key,{text:l.key})},onCanvasKeyUp:l=>{Cs(e,"keyUp",l.key,{code:l.code})}});if(e.adminsPage){const l=Kb(e),p=zb(e);return Rf({connected:e.connected,wsProps:rn(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>Ni(e,l),onAdd:f=>{Uu(e,f,l,p).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:f=>Wu(e,f,l,p),onNewPhoneChange:f=>e.handleAdminsNewPhoneChange(f)})}if(e.contactsPage){const l=jb(e);return Of({connected:e.connected,wsProps:rn(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,onSearch:p=>e.contactsSearchQuery=p,onSearchSubmit:()=>bt(e,l),onAdd:(p,f)=>Ku(e,p,f,l),onDelete:p=>zu(e,p,l),onSetField:(p,f,b)=>Hu(e,p,f,b,l),onDeleteField:(p,f)=>ju(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:()=>bt(e,l)})}if(e.chatPage){const l=e.connected?null:"Disconnected from gateway.",p=ol(e),f=e.chatAvatarUrl??p??null,b=(()=>{var k;const h=(k=e.configSnapshot)==null?void 0:k.config,v=h==null?void 0:h.publicChat;return(v==null?void 0:v.enabled)===!0})();return yv({connected:e.connected,wsProps:rn(e),publicChatEnabled:b,publicChatAccountId:e.selectedWorkspace??void 0,sessionKey:e.sessionKey,onSessionKeyChange:h=>{e.sessionKey=h,e.chatMessage="",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:h,lastActiveSessionKey:h}),e.loadAssistantIdentity(),Me(e),Fs(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:h=>{const v=Math.max(e.chatMessages.length+10,Pe);On(e,e.sessionKey,{model:h}).then(()=>{Me(e,{limit:v})})},onThinkingLevelChange:h=>{const v=Math.max(e.chatMessages.length+10,Pe);On(e,e.sessionKey,{thinkingLevel:h==="off"?null:h}).then(()=>{Me(e,{limit:v})})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,suggestion:e.chatSuggestion,onSuggestionClick:h=>{e.chatMessage=h,e.chatSuggestion=null,e.handleSendChat()},onVerboseChange:h=>{const v=Math.max(e.chatMessages.length+10,Pe);On(e,e.sessionKey,{verboseLevel:h==="off"?null:h}).then(()=>{Me(e,{limit:v})})},onFillerChange:h=>{const v=Math.max(e.chatMessages.length+10,Pe);On(e,e.sessionKey,{fillerEnabled:h}).then(()=>{Me(e,{limit:v})})},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 h=Math.max(e.chatMessages.length+10,Pe);return Promise.all([Me(e,{limit:h}),Fs(e)])},onToggleFocusMode:()=>{},onChatScroll:h=>e.handleChatScroll(h),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:h=>e.chatMessage=h,attachments:e.chatAttachments,onAttachmentsChange:h=>e.chatAttachments=h,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:h=>e.removeQueuedMessage(h),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:h=>e.handleOpenSidebar(h),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:h=>e.handleSplitRatioChange(h),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?Qv({connected:e.connected,wsProps:rn(e),activeTab:e.advancedTab,onTabChange:l=>{e.advancedTab=l,l==="cron"&&e.loadCron(),l==="skills"&&ze(e,{clearMessages:!0}),l==="logs"&&(e.logsSubTab==="session"?hn(e,{reset:!0}):It(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:((u=e.channelsSnapshot)==null?void 0:u.channelLabels)??{},channelMeta:((c=e.channelsSnapshot)==null?void 0:c.channelMeta)??[],agentIds:(()=>{var p;const l=oe(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},detailJobId:e.cronDetailJobId,onDetailOpen:l=>{e.cronDetailJobId=l.id,Rs(e,l.id)},onDetailClose:()=>{e.cronDetailJobId=null},onFormChange:l=>e.cronForm={...e.cronForm,...l},onRefresh:()=>e.loadCron(),onAdd:()=>{Cp(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(l,p)=>Tp(e,l,p),onRun:l=>_p(e,l),onRemove:l=>Mp(e,l),onLoadRuns:l=>Rs(e,l)},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,detail:e.skillDetail,detailTab:e.skillDetailTab,addModal:e.skillAddModal,drafts:e.skillDrafts,onFilterChange:l=>e.skillsFilter=l,onRefresh:()=>ze(e,{clearMessages:!0}),onToggle:(l,p)=>sc(e,l,p),onEdit:(l,p)=>ic(e,l,p),onSaveKey:l=>oc(e,l),onInstall:(l,p,f)=>rc(e,l,p,f),onViewDetail:l=>ac(e,l),onDetailClose:()=>lc(e),onDetailTab:l=>cc(e,l),onAddOpen:()=>uc(e),onAddClose:()=>dc(e),onImportDraft:l=>pc(e,l),onDeleteDraft:l=>fc(e,l),onAddSave:()=>hc(e),onDelete:l=>mc(e,l),onEditSkill:l=>gc(e,l)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:l=>{e.logsSubTab=l,l==="session"?hn(e,{reset:!0}):It(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,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,onRefresh:()=>{hn(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,truncated:e.logsTruncated,onFilterTextChange:l=>e.logsFilterText=l,onLevelToggle:(l,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[l]:p}},onToggleAutoFollow:l=>e.logsAutoFollow=l,onRefresh:()=>It(e,{reset:!0}),onExport:(l,p)=>e.exportSessionLogs(l,p),onScroll:l=>e.handleLogsScroll(l)}}):(window.location.replace("/chat"),d``)}function Zb(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 rl(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function Jb(e,t,n){return d`
|
|
3727
|
+
`;if(e.connected&&e.accessState.checked){const{accessState:l}=e;if(l.hasPins&&!l.authenticated)return Qa({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,b)=>e.handleChangePin(p,f,b)});if(!l.hasMasterPin&&!l.authenticated&&e.setup)return Qa({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",S}if(e.setup){const l=tw(e.channelsSnapshot),p=((n=(t=e.channelsSnapshot)==null?void 0:t.channelAccounts)==null?void 0:n.whatsapp)??[],f=nw(e.channelsSnapshot),b=iw(e);return Df({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 G(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 G(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await G(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),G(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,v)=>{const k=e.newWorkspacePin;await e.handleWorkspaceCreate(h,v),k.match(/^\d{4,6}$/)&&(await zb(e,h,k),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,v)=>e.handleWorkspaceRename(h,v),whatsappDmPolicy:(()=>{const h=oe(e),v=h==null?void 0:h.whatsappAccountId,k=v?p.find($=>$.accountId===v):p[0];return(k==null?void 0:k.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var T;const h=oe(e),v=h==null?void 0:h.whatsappAccountId,k=v?p.find(_=>_.accountId===v):p[0];if(!k)return;const A=k.dmPolicy!=null&&k.dmPolicy!=="disabled"?"disabled":"open",C=A==="open"?{dmPolicy:A,allowFrom:["*"]}:{dmPolicy:A};try{const _=await e.client.request("config.get"),R=_.config,O=(T=R==null?void 0:R.channels)==null?void 0:T.whatsapp,ye=((O==null?void 0:O.accounts)??{})[k.accountId]?{channels:{whatsapp:{accounts:{[k.accountId]:C}}}}:{channels:{whatsapp:C}};await e.client.request("config.patch",{raw:JSON.stringify(ye),baseHash:_.hash,note:`WhatsApp DM policy → ${A}`,skipRestart:!0}),await G(e,!1)}catch(_){console.error("DM toggle failed:",_)}},whatsappModel:(()=>{var T,_;const h=oe(e);if(!h)return null;const v=h.agents.find(R=>R.id.endsWith("-public")||R.id==="public");if(!v)return null;const k=(T=e.configSnapshot)==null?void 0:T.config,$=(_=k==null?void 0:k.agents)==null?void 0:_.list;if(!Array.isArray($))return null;const A=$.find(R=>R.id===v.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 v=oe(e);if(!v)return;const k=v.agents.find($=>$.id.endsWith("-public")||$.id==="public");if(k)try{const $=await e.client.request("config.get"),A=$.config,C=(A==null?void 0:A.agents)??{},T=Array.isArray(C.list)?[...C.list]:[],_=T.findIndex(O=>O.id===k.id);if(h)_>=0?T[_]={...T[_],model:h}:T.push({id:k.id,model:h});else if(_>=0){const{model:O,...ee}=T[_];Object.keys(ee).length<=1?T.splice(_,1):T[_]=ee}const R=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(R),baseHash:$.hash,note:`Public agent model → ${h||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Model change failed:",$)}},whatsappThinkingLevel:(()=>{var C,T,_;const h=oe(e);if(!h)return null;const v=h.agents.find(R=>R.id.endsWith("-public")||R.id==="public");if(!v)return null;const k=(C=e.configSnapshot)==null?void 0:C.config,$=(T=k==null?void 0:k.agents)==null?void 0:T.list;if(!Array.isArray($))return null;const A=$.find(R=>R.id===v.id);return((_=A==null?void 0:A.thinkingLevel)==null?void 0:_.trim())||null})(),onWhatsAppThinkingChange:async h=>{const v=oe(e);if(!v)return;const k=v.agents.find($=>$.id.endsWith("-public")||$.id==="public");if(k)try{const $=await e.client.request("config.get"),A=$.config,C=(A==null?void 0:A.agents)??{},T=Array.isArray(C.list)?[...C.list]:[],_=T.findIndex(ee=>ee.id===k.id),R=h==="off"?void 0:h;if(R)_>=0?T[_]={...T[_],thinkingLevel:R}:T.push({id:k.id,thinkingLevel:R});else if(_>=0){const{thinkingLevel:ee,...ye}=T[_];Object.keys(ye).length<=1?T.splice(_,1):T[_]=ye}const O=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(O),baseHash:$.hash,note:`Public agent thinking → ${R||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Thinking change failed:",$)}},whatsappGroupPolicy:(()=>{var _,R;const h=(_=e.configSnapshot)==null?void 0:_.config,v=(R=h==null?void 0:h.channels)==null?void 0:R.whatsapp,k=oe(e),$=k==null?void 0:k.whatsappAccountId,A=(v==null?void 0:v.accounts)??{},C=$?A[$]:void 0;return(C==null?void 0:C.groupPolicy)??(v==null?void 0:v.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var R,O;const h=(R=e.configSnapshot)==null?void 0:R.config,v=(O=h==null?void 0:h.channels)==null?void 0:O.whatsapp,k=oe(e),$=k==null?void 0:k.whatsappAccountId,A=(v==null?void 0:v.accounts)??{},C=$?A[$]:void 0,_=((C==null?void 0:C.groups)??(v==null?void 0:v.groups)??{})["*"];return(_==null?void 0:_.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var k;const h=oe(e),v=h==null?void 0:h.whatsappAccountId;try{const $=await e.client.request("config.get"),A=$.config,C=((k=A==null?void 0:A.channels)==null?void 0:k.whatsapp)??{},T=C.accounts??{},_=v?T[v]:void 0,R=(_==null?void 0:_.groupPolicy)??C.groupPolicy??"allowlist",O=R==="disabled"||R==="allowlist",ee=O?"open":"disabled",ye=O?{"*":{}}:void 0,Ve={groupPolicy:ee};ye&&(Ve.groups=ye);const X=_?{channels:{whatsapp:{accounts:{[v]:Ve}}}}:{channels:{whatsapp:Ve}};await e.client.request("config.patch",{raw:JSON.stringify(X),baseHash:$.hash,note:`WhatsApp groups → ${ee}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Group toggle failed:",$)}},onWhatsAppGroupMentionChange:async h=>{var $;const v=oe(e),k=v==null?void 0:v.whatsappAccountId;try{const A=await e.client.request("config.get"),C=A.config,_=((($=C==null?void 0:C.channels)==null?void 0:$.whatsapp)??{}).accounts??{},R=k?_[k]:void 0,O={"*":{requireMention:h}},ee=R?{channels:{whatsapp:{accounts:{[k]:{groups:O}}}}}:{channels:{whatsapp:{groups:O}}};await e.client.request("config.patch",{raw:JSON.stringify(ee),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:b,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const h=await e.client.request("config.get"),v=h.config,k=(v==null?void 0:v.bindings)??[],$=oe(e),A=$==null?void 0:$.agents.find(O=>O.id.endsWith("-admin")||O.id==="admin"),C=(A==null?void 0:A.id)??"admin",T=k.filter(O=>{var ee;return((ee=O.match)==null?void 0:ee.channel)!=="imessage"}),_=[{agentId:C,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],R=[...T,..._];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:R}),baseHash:h.hash,note:"Enable iMessage (self-chat) for "+(($==null?void 0:$.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([G(e,!0),Ie(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await G(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const h=await e.client.request("config.get"),v=h.config,$=((v==null?void 0:v.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:$}),baseHash:h.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([G(e,!0),Ie(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const h=await e.client.request("config.get"),v=h.config,k=(v==null?void 0:v.bindings)??[],$=oe(e),A=$==null?void 0:$.agents.find(R=>R.id.endsWith("-admin")||R.id==="admin"),C=(A==null?void 0:A.id)??"admin",T=k.filter(R=>{var O;return((O=R.match)==null?void 0:O.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:[...T,..._]}),baseHash:h.hash,note:"Reassign iMessage to "+(($==null?void 0:$.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([G(e,!0),Ie(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,v)=>{e.apiKeySavingProvider=h,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Xa(e.client,h,v);const k=`${h} key saved`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await so(e.client)}catch{}h==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async h=>{e.apiKeySavingProvider=h,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await $b(e.client,h);const v=`${h} key removed`;e.apiKeySuccess=v,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await so(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===v&&(e.apiKeySuccess=null)},2500)}catch(v){e.apiKeyError=v instanceof Error?v.message:"Failed to remove 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 Xa(e.client,"anthropic",h),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(v){e.authApiKeyError=v instanceof Error?v.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var v;const h=e.selectedWorkspace??((v=e.workspaces[0])==null?void 0:v.name);return h?e.accessState.accounts.some(k=>k.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,v)=>{var $;const k=e.selectedWorkspace??(($=e.workspaces[0])==null?void 0:$.name);k&&e.handleAccountPinSave(k,h,v)},publicChatEnabled:(()=>{var k;const h=(k=e.configSnapshot)==null?void 0:k.config,v=h==null?void 0:h.publicChat;return(v==null?void 0:v.enabled)===!0})(),publicChatAuthMode:(()=>{var $;const h=($=e.configSnapshot)==null?void 0:$.config,v=h==null?void 0:h.publicChat,k=v==null?void 0:v.auth;return k==="verified"||k==="choice"?k:"anonymous"})(),publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var h;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const v=await e.client.request("config.get"),k=v.config,$=((h=k==null?void 0:k.publicChat)==null?void 0:h.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!$}}),baseHash:v.hash,note:`Public chat → ${$?"disabled":"enabled"}`}),e.configSnapshot=await e.client.request("config.get")}catch(v){console.error("Public chat toggle failed:",v)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async h=>{if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const v=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{auth:h}}),baseHash:v.hash,note:`Public chat auth → ${h}`}),e.configSnapshot=await e.client.request("config.get")}catch(v){console.error("Public chat auth mode change failed:",v)}finally{e.publicChatToggleBusy=!1}}},brandAccentColor:(()=>{var k;const h=e.selectedWorkspace;return h?((k=Fe()[h])==null?void 0:k.accentColor)??"":""})(),brandBackgroundColor:(()=>{var k;const h=e.selectedWorkspace;return h?((k=Fe()[h])==null?void 0:k.backgroundColor)??"":""})(),brandHasLogo:(()=>{var k;const h=e.selectedWorkspace;return h?!!((k=Fe()[h])!=null&&k.logoUrl):!1})(),brandingBusy:e.brandingBusy,brandingExpanded:e.brandingExpanded,onBrandingToggle:()=>{e.brandingExpanded=!e.brandingExpanded},onBrandAccentColorChange:async h=>{var k;const v=e.selectedWorkspace;if(!(!v||e.brandingBusy)){e.brandingBusy=!0;try{const $=await e.client.request("config.get"),A=$.config,C=((k=A==null?void 0:A.workspaces)==null?void 0:k[v])??{},T=C.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[v]:{...C,brand:{...T,accentColor:h}}}}),baseHash:$.hash,note:`Brand accent → ${h}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const _=Fe();_[v]||(_[v]={}),_[v].accentColor=h,pn(v)}catch($){console.error("Brand accent change failed:",$)}finally{e.brandingBusy=!1}}},onBrandBackgroundColorChange:async h=>{var k;const v=e.selectedWorkspace;if(!(!v||e.brandingBusy)){e.brandingBusy=!0;try{const $=await e.client.request("config.get"),A=$.config,C=((k=A==null?void 0:A.workspaces)==null?void 0:k[v])??{},T=C.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[v]:{...C,brand:{...T,backgroundColor:h}}}}),baseHash:$.hash,note:`Brand background → ${h}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const _=Fe();_[v]||(_[v]={}),_[v].backgroundColor=h,pn(v)}catch($){console.error("Brand background change failed:",$)}finally{e.brandingBusy=!1}}},onBrandLogoUpload:async h=>{const v=e.selectedWorkspace;if(!(!v||e.brandingBusy)){e.brandingBusy=!0;try{const k=await h.arrayBuffer(),$=new Uint8Array(k);let A="";for(let _=0;_<$.length;_++)A+=String.fromCharCode($[_]);const C=btoa(A);await e.client.request("brand.uploadLogo",{workspace:v,data:C,mimeType:h.type});const T=Fe();T[v]||(T[v]={}),T[v].logoUrl=`/brand-logo/${encodeURIComponent(v)}`}catch(k){console.error("Brand logo upload failed:",k)}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 v=Fe();v[h]&&delete v[h].logoUrl}catch(v){console.error("Brand logo remove failed:",v)}finally{e.brandingBusy=!1}}},onBrandReset:async()=>{var v;const h=e.selectedWorkspace;if(!(!h||e.brandingBusy)){e.brandingBusy=!0;try{const k=await e.client.request("config.get"),$=k.config,A=((v=$==null?void 0:$.workspaces)==null?void 0:v[h])??{},{brand:C,...T}=A;await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[h]:{...T,brand:null}}}),baseHash:k.hash,note:"Brand reset to defaults",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");try{await e.client.request("brand.removeLogo",{workspace:h})}catch{}const _=Fe();delete _[h],pn(h)}catch(k){console.error("Brand reset failed:",k)}finally{e.brandingBusy=!1}}},tailscaleStatus:e.tailscaleStatus,tailscaleBusy:e.tailscaleBusy,tailscaleAuthUrl:e.tailscaleAuthUrl,tailscaleError:e.tailscaleError,tailscaleFunnelEnableUrl:e.tailscaleFunnelEnableUrl,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 v=setInterval(async()=>{try{const k=await e.client.request("tailscale.status");e.tailscaleStatus=k,k.loggedIn&&(clearInterval(v),e.tailscaleAuthUrl=null,e.tailscaleBusy=!1)}catch{}},3e3);setTimeout(()=>{clearInterval(v),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}}},onTailscaleFunnelEnable:async()=>{var h;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleFunnelEnableUrl=null;try{await e.client.request("tailscale.funnel.enable")}catch(v){console.error("Tailscale funnel enable failed:",v);const k=v;(h=k.payload)!=null&&h.enableUrl&&(e.tailscaleFunnelEnableUrl=k.payload.enableUrl),e.tailscaleError=k.message||"Failed to enable Funnel",e.tailscaleBusy=!1}}},onTailscaleFunnelDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.funnel.disable")}catch(h){console.error("Tailscale funnel disable failed:",h),e.tailscaleBusy=!1}}},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,v]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);e.wifiNetworks=h.networks,e.wifiStatus=v}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 v=await e.client.request("wifi.connect",{ssid:h,password:e.wifiPassword});e.wifiPassword="",e.wifiSelectedSsid=null,e.wifiNetworks=[],e.wifiStatus={available:!0,connected:v.connected,ssid:v.ssid,signal:null,ip:v.ip,savedSsid:v.ssid,autoconnect:!0},e.wifiBusy=!1;try{const k=await e.client.request("wifi.status");e.wifiStatus=k}catch{}}catch(v){console.error("WiFi connect failed:",v),e.wifiError=v.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},wsProps:Gb(e)})}if(e.filesPage){const l=Jb(e);return wf({connected:e.connected,wsProps:ln(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:()=>Ht(e,l),onReindex:()=>Dh(e,l),onSelectFile:p=>{e.filesPendingDeletePath=null,Ch(e,p,l)},onToggleSelectFile:p=>Th(e,p,l),onToggleDir:p=>Bh(e,p),onUpload:(p,f)=>Ph(e,p,f,l),onNewFolder:(p,f)=>Lh(e,p,f,l),onDownload:p=>Ec(e,p,l),onBulkDownload:()=>_h(e,l),onDelete:p=>{e.filesPendingDeletePath=null,Ih(e,p,l)},pendingDeletePath:e.filesPendingDeletePath,onArmDelete:p=>{e.filesPendingDeletePath=p||null},onMoveToDir:(p,f)=>Mh(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;Nh(e,p,f)},onSearchAgentChange:p=>{e.filesSearchAgentId=p},onSearchClear:()=>{Oh(e)},onSearchQueryChange:p=>{e.filesSearchQuery=p}})}if(e.browserPage)return ff({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:()=>gb(e),onStop:()=>mb(e),onToggleInput:()=>vb(e),onToggleFullscreen:()=>bb(e),onCompleteHandoff:()=>yb(e),onCanvasMouseDown:l=>{const f=l.target.getBoundingClientRect(),h=vn().translateCoordinates(l.clientX-f.left,l.clientY-f.top);Cs(e,"mousePressed",h.x,h.y,l.button===2?"right":l.button===1?"middle":"left")},onCanvasMouseUp:l=>{const f=l.target.getBoundingClientRect(),h=vn().translateCoordinates(l.clientX-f.left,l.clientY-f.top);Cs(e,"mouseReleased",h.x,h.y)},onCanvasMouseMove:l=>{const p=vn();if(p.shouldThrottleMouseMove())return;const b=l.target.getBoundingClientRect(),h=p.translateCoordinates(l.clientX-b.left,l.clientY-b.top);Cs(e,"mouseMoved",h.x,h.y)},onCanvasKeyDown:l=>{let p=0;l.altKey&&(p|=1),l.ctrlKey&&(p|=2),l.metaKey&&(p|=4),l.shiftKey&&(p|=8),Ts(e,"keyDown",l.key,{code:l.code,modifiers:p||void 0}),l.key.length===1&&Ts(e,"char",l.key,{text:l.key})},onCanvasKeyUp:l=>{Ts(e,"keyUp",l.key,{code:l.code})}});if(e.adminsPage){const l=Qb(e),p=Yb(e);return Nf({connected:e.connected,wsProps:ln(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>Ni(e,l),onAdd:f=>{zu(e,f,l,p).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:f=>Hu(e,f,l,p),onNewPhoneChange:f=>e.handleAdminsNewPhoneChange(f)})}if(e.contactsPage){const l=Xb(e);return Wf({connected:e.connected,wsProps:ln(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,onSearch:p=>e.contactsSearchQuery=p,onSearchSubmit:()=>wt(e,l),onAdd:(p,f)=>qu(e,p,f,l),onDelete:p=>ju(e,p,l),onSetField:(p,f,b)=>Vu(e,p,f,b,l),onDeleteField:(p,f)=>Gu(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:()=>wt(e,l)})}if(e.chatPage){const l=e.connected?null:"Disconnected from gateway.",p=rl(e),f=e.chatAvatarUrl??p??null,b=(()=>{var k;const h=(k=e.configSnapshot)==null?void 0:k.config,v=h==null?void 0:h.publicChat;return(v==null?void 0:v.enabled)===!0})();return wv({connected:e.connected,wsProps:ln(e),publicChatEnabled:b,publicChatAccountId:e.selectedWorkspace??void 0,sessionKey:e.sessionKey,onSessionKeyChange:h=>{e.sessionKey=h,e.chatMessage="",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:h,lastActiveSessionKey:h}),e.loadAssistantIdentity(),Pe(e),Us(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:h=>{const v=Math.max(e.chatMessages.length+10,Le);Un(e,e.sessionKey,{model:h}).then(()=>{Pe(e,{limit:v})})},onThinkingLevelChange:h=>{const v=Math.max(e.chatMessages.length+10,Le);Un(e,e.sessionKey,{thinkingLevel:h==="off"?null:h}).then(()=>{Pe(e,{limit:v})})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,suggestion:e.chatSuggestion,onSuggestionClick:h=>{e.chatMessage=h,e.chatSuggestion=null,e.handleSendChat()},onVerboseChange:h=>{const v=Math.max(e.chatMessages.length+10,Le);Un(e,e.sessionKey,{verboseLevel:h==="off"?null:h}).then(()=>{Pe(e,{limit:v})})},onFillerChange:h=>{const v=Math.max(e.chatMessages.length+10,Le);Un(e,e.sessionKey,{fillerEnabled:h}).then(()=>{Pe(e,{limit:v})})},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 h=Math.max(e.chatMessages.length+10,Le);return Promise.all([Pe(e,{limit:h}),Us(e)])},onToggleFocusMode:()=>{},onChatScroll:h=>e.handleChatScroll(h),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:h=>e.chatMessage=h,attachments:e.chatAttachments,onAttachmentsChange:h=>e.chatAttachments=h,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:h=>e.removeQueuedMessage(h),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:h=>e.handleOpenSidebar(h),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:h=>e.handleSplitRatioChange(h),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?nb({connected:e.connected,wsProps:ln(e),activeTab:e.advancedTab,onTabChange:l=>{e.advancedTab=l,l==="cron"&&e.loadCron(),l==="skills"&&He(e,{clearMessages:!0}),l==="logs"&&(e.logsSubTab==="session"?gn(e,{reset:!0}):Rt(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:((u=e.channelsSnapshot)==null?void 0:u.channelLabels)??{},channelMeta:((c=e.channelsSnapshot)==null?void 0:c.channelMeta)??[],agentIds:(()=>{var p;const l=oe(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,Ds(e,l.id)},onDetailClose:()=>{e.cronDetailJobId=null},onEdit:l=>{e.cronForm=Lp(l),e.cronEditJobId=l.id,e.cronDetailJobId=null},onEditSave:()=>{const l=e.cronEditJobId;l&&Ip(e,l).then(()=>{e.cronEditJobId=null})},onFormChange:l=>e.cronForm={...e.cronForm,...l},onRefresh:()=>e.loadCron(),onAdd:()=>{Tp(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(l,p)=>_p(e,l,p),onRun:l=>Mp(e,l),onRemove:l=>{e.cronPendingDeleteId=null,Pp(e,l)},pendingDeleteId:e.cronPendingDeleteId,onArmDelete:l=>{e.cronPendingDeleteId=l||null},onLoadRuns:l=>Ds(e,l)},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,detail:e.skillDetail,detailTab:e.skillDetailTab,addModal:e.skillAddModal,drafts:e.skillDrafts,onFilterChange:l=>e.skillsFilter=l,onRefresh:()=>He(e,{clearMessages:!0}),onToggle:(l,p)=>ac(e,l,p),onEdit:(l,p)=>rc(e,l,p),onSaveKey:l=>lc(e,l),onInstall:(l,p,f)=>cc(e,l,p,f),onViewDetail:l=>uc(e,l),onDetailClose:()=>dc(e),onDetailTab:l=>pc(e,l),onAddOpen:()=>hc(e),onAddClose:()=>fc(e),onImportDraft:l=>gc(e,l),onDeleteDraft:l=>yc(e,l),onAddSave:()=>mc(e),onDelete:l=>bc(e,l),onEditSkill:l=>vc(e,l)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:l=>{e.logsSubTab=l,l==="session"?gn(e,{reset:!0}):Rt(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,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,onRefresh:()=>{gn(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,truncated:e.logsTruncated,onFilterTextChange:l=>e.logsFilterText=l,onLevelToggle:(l,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[l]:p}},onToggleAutoFollow:l=>e.logsAutoFollow=l,onRefresh:()=>Rt(e,{reset:!0}),onExport:(l,p)=>e.exportSessionLogs(l,p),onScroll:l=>e.handleLogsScroll(l)}}):(window.location.replace("/chat"),d``)}function ow(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 al(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function rw(e,t,n){return d`
|
|
3683
3728
|
<div class="audit-modal-overlay" @click=${s=>{s.target.classList.contains("audit-modal-overlay")&&n()}}>
|
|
3684
3729
|
<div class="audit-modal-card">
|
|
3685
3730
|
<div class="audit-modal-header">
|
|
@@ -3695,11 +3740,11 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3695
3740
|
${e.map(s=>d`
|
|
3696
3741
|
<div class="audit-modal-entry">
|
|
3697
3742
|
<div class="audit-modal-entry-path">
|
|
3698
|
-
<span class="audit-modal-folder audit-modal-folder--${
|
|
3743
|
+
<span class="audit-modal-folder audit-modal-folder--${al(s.path)}">${al(s.path)}</span>
|
|
3699
3744
|
<a href="/files" class="audit-modal-path-link">${s.path}</a>
|
|
3700
3745
|
</div>
|
|
3701
3746
|
<div class="audit-modal-entry-meta">
|
|
3702
|
-
${
|
|
3747
|
+
${ow(s.timestamp)}
|
|
3703
3748
|
<span class="audit-modal-agent">${s.agentId}</span>
|
|
3704
3749
|
</div>
|
|
3705
3750
|
</div>
|
|
@@ -3711,7 +3756,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
|
|
|
3711
3756
|
`}
|
|
3712
3757
|
</div>
|
|
3713
3758
|
</div>
|
|
3714
|
-
`}const ew={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},tw={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",to:"",timeoutSeconds:"",postToMainPrefix:""};function nw(e){e.basePath=jh();const t=Ke();if(yl(t.accentColor),vl(t.backgroundColor),window.scrollTo(0,0),Oh(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}`,Te(e);return}if(e.setup){document.title=`${t.name} Setup`,Te(e);return}if(e.filesPage){document.title=`${t.name} Files`,Uh(e),Te(e);return}if(e.browserPage){document.title=`${t.name} Browser`,Te(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,Te(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,Te(e);return}if(e.chatPage){document.title=`${t.name} Chat`,Te(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,Te(e);return}Qh(e,!0),qh(e),Vh(e),window.addEventListener("popstate",e.popStateHandler),Kh(e),Te(e),Nh(e),e.tab==="logs"&&(e.logsSubTab==="session"?Ao(e):$o(e)),e.tab==="debug"&&Co(e)}function iw(e){kp(e)}function sw(e){var t;window.removeEventListener("popstate",e.popStateHandler),Bh(e),xo(e),Eo(e),To(e),Fh(e),Wh(e),Gh(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function ow(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;Ut(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&Ll(e,t.has("tab")||t.has("logsAutoFollow"))}}function rw(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 aw(e,t,n){await po(e,t,n),await G(e,!0)}async function lw(e,t){await Dl(e,t),await G(e,!0)}async function cw(e,t){await Nl(e,t),await G(e,!0)}async function uw(e,t){await Bl(e,t)}async function dw(e,t){await Ol(e,t)}async function pw(e){await xp(e),await Le(e),await G(e,!0)}async function hw(e){await Le(e),await G(e,!0)}function fw(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 qu(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 Vu(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function gw(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=rw(n??void 0)}function mw(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function yw(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function vw(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function bw(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=qu(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(Vu(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:fw(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 G(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function ww(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=qu(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(Vu(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 u=(s==null?void 0:s.error)??`Profile import failed (${i.status})`;e.nostrProfileFormState={...t,importing:!1,error:u,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 G(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function kw(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 Sw(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 $w(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 xw(e,t){e.authCodeInput=t}function Aw(e){e.setupStep="whatsapp"}async function Ew(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 Cw(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 Tw(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 _w(e,t){e.licenseKey=t}async function Mw(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 Pw(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 Lw=Object.defineProperty,Iw=Object.getOwnPropertyDescriptor,m=(e,t,n,i)=>{for(var s=i>1?void 0:i?Iw(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&&Lw(t,n,s),s};const Ms=Ld();function Rw(){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 Dw(){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 Nw(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function Bw(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function Ow(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function Fw(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function Uw(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function Ww(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let g=class extends Lt{constructor(){super(...arguments),this.settings=Ji(),this.password="",this.tab="chat",this.onboarding=Rw(),this.setup=Dw(),this.filesPage=Nw(),this.browserPage=Bw(),this.adminsPage=Ow(),this.contactsPage=Fw(),this.chatPage=Uw(),this.advancedPage=Ww(),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=Nu,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=Ms.name,this.assistantAvatar=Ms.avatar,this.assistantAgentId=Ms.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=`{
|
|
3759
|
+
`}const aw={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},lw={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 cw(e){e.basePath=Gh();const t=ze();if(vl(t.accentColor),bl(t.backgroundColor),window.scrollTo(0,0),Wh(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}`,_e(e);return}if(e.setup){document.title=`${t.name} Setup`,_e(e);return}if(e.filesPage){document.title=`${t.name} Files`,zh(e),_e(e);return}if(e.browserPage){document.title=`${t.name} Browser`,_e(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,_e(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,_e(e);return}if(e.chatPage){document.title=`${t.name} Chat`,_e(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,_e(e);return}Xh(e,!0),Qh(e),Yh(e),window.addEventListener("popstate",e.popStateHandler),qh(e),_e(e),Fh(e),e.tab==="logs"&&(e.logsSubTab==="session"?Eo(e):xo(e)),e.tab==="debug"&&To(e)}function uw(e){xp(e)}function dw(e){var t;window.removeEventListener("popstate",e.popStateHandler),Uh(e),Ao(e),Co(e),_o(e),Kh(e),Hh(e),Jh(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function pw(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;Wt(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&Il(e,t.has("tab")||t.has("logsAutoFollow"))}}function hw(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 fw(e,t,n){await ho(e,t,n),await G(e,!0)}async function gw(e,t){await Ol(e,t),await G(e,!0)}async function mw(e,t){await Fl(e,t),await G(e,!0)}async function yw(e,t){await Ul(e,t)}async function vw(e,t){await Wl(e,t)}async function bw(e){await Cp(e),await Ie(e),await G(e,!0)}async function ww(e){await Ie(e),await G(e,!0)}function kw(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 Qu(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 Yu(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function Sw(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=hw(n??void 0)}function $w(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function xw(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function Aw(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function Ew(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Qu(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(Yu(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:kw(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 G(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function Cw(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Qu(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(Yu(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 u=(s==null?void 0:s.error)??`Profile import failed (${i.status})`;e.nostrProfileFormState={...t,importing:!1,error:u,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 G(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function Tw(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 _w(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 Mw(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 Pw(e,t){e.authCodeInput=t}function Lw(e){e.setupStep="whatsapp"}async function Iw(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 Rw(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 Dw(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 Bw(e,t){e.licenseKey=t}async function Nw(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 Ow(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 Fw=Object.defineProperty,Uw=Object.getOwnPropertyDescriptor,m=(e,t,n,i)=>{for(var s=i>1?void 0:i?Uw(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&&Fw(t,n,s),s};const Ps=Dd();function Ww(){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 Kw(){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 zw(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function Hw(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function qw(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function jw(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function Vw(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function Gw(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let g=class extends It{constructor(){super(...arguments),this.settings=es(),this.password="",this.tab="chat",this.onboarding=Ww(),this.setup=Kw(),this.filesPage=zw(),this.browserPage=Hw(),this.adminsPage=qw(),this.contactsPage=jw(),this.chatPage=Vw(),this.advancedPage=Gw(),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=Fu,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=Ps.name,this.assistantAvatar=Ps.avatar,this.assistantAgentId=Ps.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=`{
|
|
3715
3760
|
}
|
|
3716
|
-
`,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.wifiStatus=null,this.wifiNetworks=[],this.wifiBusy=!1,this.wifiError=null,this.wifiPassword="",this.wifiSelectedSsid=null,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={...tw},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.browserScreencastActive=!1,this.browserScreencastFrame=null,this.browserScreencastMetadata=null,this.browserHandoffPending=!1,this.browserHandoffReason=null,this.browserHandoffId=null,this.browserInputMode=!1,this.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.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.skillDetail=null,this.skillDetailTab="",this.skillAddModal=!1,this.skillAddForm={name:"",skillContent:"",references:[]},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.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={...ew},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.logsSubTab="session",this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.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=()=>Yh(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),nw(this)}firstUpdated(){iw(this)}disconnectedCallback(){this.stopEmbeddingPoll(),sw(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){ow(this,e)}connect(){Te(this)}handleChatScroll(e){fp(this,e)}handleLogsScroll(e){mp(this,e)}handleSessionLogsScroll(e){yp(this,e)}exportLogs(e,t){bp(e,t)}exportSessionLogs(e,t){wp(e,t)}resetToolStream(){uo(this)}resetChatScroll(){vp(this)}async loadAssistantIdentity(){await no(this)}applySettings(e){Ze(this,e)}setTab(e){zh(this,e)}setTheme(e,t){Hh(this,e,t)}async loadOverview(){await Cc(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 _o(this)}async handleAbortChat(){await _c(this)}removeQueuedMessage(e){ef(this,e)}async handleSendChat(e,t){await tf(this,e,t)}async handleWhatsAppStart(e,t){await aw(this,e,t)}async handleWhatsAppWait(e){await lw(this,e)}async handleWhatsAppLogout(e){await cw(this,e)}async handleAddWhatsAppAccount(e){await uw(this,e)}async handleRemoveWhatsAppAccount(e){await dw(this,e)}async handleAccessCheck(){await sl(this)}async handlePinSubmit(e,t){await Rb(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await Db(this,e)}async handleLogout(){await Bb(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 sl(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 Ew(this)}async handleLicenseActivate(){await Cw(this)}async handleLicenseRemove(){await Tw(this)}handleLicenseKeyChange(e){_w(this,e)}async handleAuthStatusCheck(){await kw(this)}async handleAuthStart(){await Sw(this)}async handleAuthSubmitCode(e){await $w(this,e)}handleAuthCodeChange(e){xw(this,e)}handleSkipToWhatsApp(){Aw(this)}async handleGatewayHealthCheck(){await Mw(this)}async handleGatewayRestart(){await Pw(this)}async handleUpdateCheck(){await Lu(this)}async handleUpdateRun(){await yb(this)}handleUpdateDismissResult(){wb(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 ie(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Wr);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){ie(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Wr);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await kc(this)}async clearAudit(){await $h(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,Kt(this,t),So(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();ie(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>Fb);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())}ie(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>li);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this).then(()=>{Ut(this,!0)})})}async handleLoadOlderChat(){if(this.chatLoadingOlder||!this.chatHistoryHasMore)return;const e=gp(this),{loadOlderChatHistory:t}=await ie(async()=>{const{loadOlderChatHistory:i}=await Promise.resolve().then(()=>li);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"?ie(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>wc);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):ie(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>Np);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&ie(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>mh);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await pw(this)}async handleChannelConfigReload(){await hw(this)}handleNostrProfileEdit(e,t){gw(this,e,t)}handleNostrProfileCancel(){mw(this)}handleNostrProfileFieldChange(e,t){yw(this,e,t)}async handleNostrProfileSave(){await bw(this)}async handleNostrProfileImport(){await ww(this)}handleNostrProfileToggleAdvanced(){vw(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;ie(async()=>{const{loadContacts:t}=await Promise.resolve().then(()=>Ub);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 ie(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>Yn);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await ie(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>Yn);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await ie(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>Pp);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 ie(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>Yn);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 ie(async()=>{const{renameWorkspace:i}=await Promise.resolve().then(()=>Yn);return{renameWorkspace:i}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){this.selectedWorkspace=e,localStorage.setItem("taskmaster-selected-workspace",e),un(e),Tr(e),this.settings=Ji(),this.chatMessage="",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)}un(this.selectedWorkspace),Tr(this.selectedWorkspace),this.settings=Ji(),this.reloadCurrentPageData()}render(){return d`${Xb(this)}${this.auditModalOpen?Jb(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):S}`}};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,"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,"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,"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,"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,"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,"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,"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,"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);
|
|
3717
|
-
//# sourceMappingURL=index-
|
|
3761
|
+
`,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.wifiStatus=null,this.wifiNetworks=[],this.wifiBusy=!1,this.wifiError=null,this.wifiPassword="",this.wifiSelectedSsid=null,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={...lw},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.cronEditJobId=null,this.cronPendingDeleteId=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.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.skillDetail=null,this.skillDetailTab="",this.skillAddModal=!1,this.skillAddForm={name:"",skillContent:"",references:[]},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.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={...aw},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.logsSubTab="session",this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.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=()=>Zh(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),cw(this)}firstUpdated(){uw(this)}disconnectedCallback(){this.stopEmbeddingPoll(),dw(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){pw(this,e)}connect(){_e(this)}handleChatScroll(e){yp(this,e)}handleLogsScroll(e){bp(this,e)}handleSessionLogsScroll(e){wp(this,e)}exportLogs(e,t){Sp(e,t)}exportSessionLogs(e,t){$p(e,t)}resetToolStream(){po(this)}resetChatScroll(){kp(this)}async loadAssistantIdentity(){await io(this)}applySettings(e){Ze(this,e)}setTab(e){jh(this,e)}setTheme(e,t){Vh(this,e,t)}async loadOverview(){await Mc(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 Mo(this)}async handleAbortChat(){await Lc(this)}removeQueuedMessage(e){sf(this,e)}async handleSendChat(e,t){await of(this,e,t)}async handleWhatsAppStart(e,t){await fw(this,e,t)}async handleWhatsAppWait(e){await gw(this,e)}async handleWhatsAppLogout(e){await mw(this,e)}async handleAddWhatsAppAccount(e){await yw(this,e)}async handleRemoveWhatsAppAccount(e){await vw(this,e)}async handleAccessCheck(){await ol(this)}async handlePinSubmit(e,t){await Wb(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await Kb(this,e)}async handleLogout(){await Hb(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 ol(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 Iw(this)}async handleLicenseActivate(){await Rw(this)}async handleLicenseRemove(){await Dw(this)}handleLicenseKeyChange(e){Bw(this,e)}async handleAuthStatusCheck(){await Tw(this)}async handleAuthStart(){await _w(this)}async handleAuthSubmitCode(e){await Mw(this,e)}handleAuthCodeChange(e){Pw(this,e)}handleSkipToWhatsApp(){Lw(this)}async handleGatewayHealthCheck(){await Nw(this)}async handleGatewayRestart(){await Ow(this)}async handleUpdateCheck(){await Du(this)}async handleUpdateRun(){await xb(this)}handleUpdateDismissResult(){Cb(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 ie(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>zr);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){ie(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>zr);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await xc(this)}async clearAudit(){await Eh(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,Ht(this,t),$o(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();ie(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>jb);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())}ie(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>ui);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this).then(()=>{Wt(this,!0)})})}async handleLoadOlderChat(){if(this.chatLoadingOlder||!this.chatHistoryHasMore)return;const e=vp(this),{loadOlderChatHistory:t}=await ie(async()=>{const{loadOlderChatHistory:i}=await Promise.resolve().then(()=>ui);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"?ie(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>$c);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):ie(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>Fp);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&ie(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>bh);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await bw(this)}async handleChannelConfigReload(){await ww(this)}handleNostrProfileEdit(e,t){Sw(this,e,t)}handleNostrProfileCancel(){$w(this)}handleNostrProfileFieldChange(e,t){xw(this,e,t)}async handleNostrProfileSave(){await Ew(this)}async handleNostrProfileImport(){await Cw(this)}handleNostrProfileToggleAdvanced(){Aw(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;ie(async()=>{const{loadContacts:t}=await Promise.resolve().then(()=>Vb);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 ie(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>Xn);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await ie(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>Xn);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await ie(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>Rp);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 ie(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>Xn);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 ie(async()=>{const{renameWorkspace:i}=await Promise.resolve().then(()=>Xn);return{renameWorkspace:i}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){this.selectedWorkspace=e,localStorage.setItem("taskmaster-selected-workspace",e),pn(e),Mr(e),this.settings=es(),this.chatMessage="",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)}pn(this.selectedWorkspace),Mr(this.selectedWorkspace),this.settings=es(),this.reloadCurrentPageData()}render(){return d`${sw(this)}${this.auditModalOpen?rw(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):S}`}};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,"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,"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,"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,"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,"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,"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,"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,"sessionLogsCursors",2);m([y()],g.prototype,"sessionLogsLastFetchAt",2);m([y()],g.prototype,"sessionLogsAtBottom",2);m([y()],g.prototype,"chatUserNearBottom",2);g=m([ml("taskmaster-app")],g);
|
|
3762
|
+
//# sourceMappingURL=index-nLVF-pVT.js.map
|