@poolzin/pool-bot 2026.4.25 → 2026.4.27
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.d.ts.map +1 -1
- package/dist/agents/system-prompt.js +14 -3
- package/dist/build-info.json +3 -3
- package/dist/control-ui/assets/{index-D0f1KDTY.js → index-1DWuMa4l.js} +451 -429
- package/dist/control-ui/assets/index-1DWuMa4l.js.map +1 -0
- package/dist/control-ui/assets/{index-Dy7DUJt9.css → index-Cm16MN6l.css} +1 -1
- package/dist/control-ui/index.html +2 -2
- package/package.json +5 -2
- package/patches/@mariozechner__pi-ai.patch +13 -0
- package/dist/control-ui/assets/index-D0f1KDTY.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();const cl=!1,nn=globalThis,qs=nn.ShadowRoot&&(nn.ShadyCSS===void 0||nn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Gs=Symbol(),Xi=new WeakMap;class mo{constructor(t,n,s){if(this._$cssResult$=!0,s!==Gs)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this._strings=n}get styleSheet(){let t=this._styleSheet;const n=this._strings;if(qs&&t===void 0){const s=n!==void 0&&n.length===1;s&&(t=Xi.get(n)),t===void 0&&((this._styleSheet=t=new CSSStyleSheet).replaceSync(this.cssText),s&&Xi.set(n,t))}return t}toString(){return this.cssText}}const dl=e=>{if(e._$cssResult$===!0)return e.cssText;if(typeof e=="number")return e;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${e}. Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.`)},ul=e=>new mo(typeof e=="string"?e:String(e),void 0,Gs),pl=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((s,i,a)=>s+dl(i)+e[a+1],e[0]);return new mo(n,e,Gs)},hl=(e,t)=>{if(qs)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const s=document.createElement("style"),i=nn.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=n.cssText,e.appendChild(s)}},fl=e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return ul(t)},ea=qs||cl?e=>e:e=>e instanceof CSSStyleSheet?fl(e):e;const{is:gl,defineProperty:ml,getOwnPropertyDescriptor:ta,getOwnPropertyNames:vl,getOwnPropertySymbols:yl,getPrototypeOf:na}=Object,se=globalThis;let le;const sa=se.trustedTypes,bl=sa?sa.emptyScript:"",vo=se.reactiveElementPolyfillSupportDevMode;se.litIssuedWarnings??=new Set,le=(e,t)=>{t+=` See https://lit.dev/msg/${e} for more information.`,!se.litIssuedWarnings.has(t)&&!se.litIssuedWarnings.has(e)&&(console.warn(t),se.litIssuedWarnings.add(t))},queueMicrotask(()=>{le("dev-mode","Lit is in dev mode. Not recommended for production!"),se.ShadyDOM?.inUse&&vo===void 0&&le("polyfill-support-missing","Shadow DOM is being polyfilled via `ShadyDOM` but the `polyfill-support` module has not been loaded.")});const wl=e=>{se.emitLitDebugLogEvents&&se.dispatchEvent(new CustomEvent("lit-debug",{detail:e}))},ot=(e,t)=>e,rn={toAttribute(e,t){switch(t){case Boolean:e=e?bl:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e);break}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}break}return n}},Ys=(e,t)=>!gl(e,t),ia={attribute:!0,type:String,converter:rn,reflect:!1,useDefault:!1,hasChanged:Ys};Symbol.metadata??=Symbol("metadata");se.litPropertyMetadata??=new WeakMap;class Se extends HTMLElement{static addInitializer(t){this.__prepare(),(this._initializers??=[]).push(t)}static get observedAttributes(){return this.finalize(),this.__attributeToPropertyMap&&[...this.__attributeToPropertyMap.keys()]}static createProperty(t,n=ia){if(n.state&&(n.attribute=!1),this.__prepare(),this.prototype.hasOwnProperty(t)&&(n=Object.create(n),n.wrapped=!0),this.elementProperties.set(t,n),!n.noAccessor){const s=Symbol.for(`${String(t)} (@property() cache)`),i=this.getPropertyDescriptor(t,s,n);i!==void 0&&ml(this.prototype,t,i)}}static getPropertyDescriptor(t,n,s){const{get:i,set:a}=ta(this.prototype,t)??{get(){return this[n]},set(o){this[n]=o}};if(i==null){if("value"in(ta(this.prototype,t)??{}))throw new Error(`Field ${JSON.stringify(String(t))} on ${this.name} was declared as a reactive property but it's actually declared as a value on the prototype. Usually this is due to using @property or @state on a method.`);le("reactive-property-without-getter",`Field ${JSON.stringify(String(t))} on ${this.name} was declared as a reactive property but it does not have a getter. This will be an error in a future version of Lit.`)}return{get:i,set(o){const c=i?.call(this);a?.call(this,o),this.requestUpdate(t,c,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??ia}static __prepare(){if(this.hasOwnProperty(ot("elementProperties")))return;const t=na(this);t.finalize(),t._initializers!==void 0&&(this._initializers=[...t._initializers]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(ot("finalized")))return;if(this.finalized=!0,this.__prepare(),this.hasOwnProperty(ot("properties"))){const n=this.properties,s=[...vl(n),...yl(n)];for(const i of s)this.createProperty(i,n[i])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[s,i]of n)this.elementProperties.set(s,i)}this.__attributeToPropertyMap=new Map;for(const[n,s]of this.elementProperties){const i=this.__attributeNameForProperty(n,s);i!==void 0&&this.__attributeToPropertyMap.set(i,n)}this.elementStyles=this.finalizeStyles(this.styles),this.hasOwnProperty("createProperty")&&le("no-override-create-property","Overriding ReactiveElement.createProperty() is deprecated. The override will not be called with standard decorators"),this.hasOwnProperty("getPropertyDescriptor")&&le("no-override-get-property-descriptor","Overriding ReactiveElement.getPropertyDescriptor() is deprecated. The override will not be called with standard decorators")}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)n.unshift(ea(i))}else t!==void 0&&n.push(ea(t));return n}static __attributeNameForProperty(t,n){const s=n.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this.__instanceProperties=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this.__reflectingProperty=null,this.__initialize()}__initialize(){this.__updatePromise=new Promise(t=>this.enableUpdating=t),this._$changedProperties=new Map,this.__saveInstanceProperties(),this.requestUpdate(),this.constructor._initializers?.forEach(t=>t(this))}addController(t){(this.__controllers??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this.__controllers?.delete(t)}__saveInstanceProperties(){const t=new Map,n=this.constructor.elementProperties;for(const s of n.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this.__instanceProperties=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return hl(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this.__controllers?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this.__controllers?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,n,s){this._$attributeToProperty(t,s)}__propertyToAttribute(t,n){const i=this.constructor.elementProperties.get(t),a=this.constructor.__attributeNameForProperty(t,i);if(a!==void 0&&i.reflect===!0){const c=(i.converter?.toAttribute!==void 0?i.converter:rn).toAttribute(n,i.type);this.constructor.enabledWarnings.includes("migration")&&c===void 0&&le("undefined-attribute-value",`The attribute value for the ${t} property is undefined on element ${this.localName}. The attribute will be removed, but in the previous version of \`ReactiveElement\`, the attribute would not have changed.`),this.__reflectingProperty=t,c==null?this.removeAttribute(a):this.setAttribute(a,c),this.__reflectingProperty=null}}_$attributeToProperty(t,n){const s=this.constructor,i=s.__attributeToPropertyMap.get(t);if(i!==void 0&&this.__reflectingProperty!==i){const a=s.getPropertyOptions(i),o=typeof a.converter=="function"?{fromAttribute:a.converter}:a.converter?.fromAttribute!==void 0?a.converter:rn;this.__reflectingProperty=i;const c=o.fromAttribute(n,a.type);this[i]=c??this.__defaultValues?.get(i)??c,this.__reflectingProperty=null}}requestUpdate(t,n,s,i=!1,a){if(t!==void 0){t instanceof Event&&le("","The requestUpdate() method was called with an Event as the property name. This is probably a mistake caused by binding this.requestUpdate as an event listener. Instead bind a function that will call it with no arguments: () => this.requestUpdate()");const o=this.constructor;if(i===!1&&(a=this[t]),s??=o.getPropertyOptions(t),(s.hasChanged??Ys)(a,n)||s.useDefault&&s.reflect&&a===this.__defaultValues?.get(t)&&!this.hasAttribute(o.__attributeNameForProperty(t,s)))this._$changeProperty(t,n,s);else return}this.isUpdatePending===!1&&(this.__updatePromise=this.__enqueueUpdate())}_$changeProperty(t,n,{useDefault:s,reflect:i,wrapped:a},o){s&&!(this.__defaultValues??=new Map).has(t)&&(this.__defaultValues.set(t,o??n??this[t]),a!==!0||o!==void 0)||(this._$changedProperties.has(t)||(!this.hasUpdated&&!s&&(n=void 0),this._$changedProperties.set(t,n)),i===!0&&this.__reflectingProperty!==t&&(this.__reflectingProperties??=new Set).add(t))}async __enqueueUpdate(){this.isUpdatePending=!0;try{await this.__updatePromise}catch(n){Promise.reject(n)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){const t=this.performUpdate();return this.constructor.enabledWarnings.includes("async-perform-update")&&typeof t?.then=="function"&&le("async-perform-update",`Element ${this.localName} returned a Promise from performUpdate(). This behavior is deprecated and will be removed in a future version of ReactiveElement.`),t}performUpdate(){if(!this.isUpdatePending)return;if(wl?.({kind:"update"}),!this.hasUpdated){this.renderRoot??=this.createRenderRoot();{const a=[...this.constructor.elementProperties.keys()].filter(o=>this.hasOwnProperty(o)&&o in na(this));if(a.length)throw new Error(`The following properties on element ${this.localName} will not trigger updates as expected because they are set using class fields: ${a.join(", ")}. Native class fields and some compiled output will overwrite accessors used for detecting changes. See https://lit.dev/msg/class-field-shadowing for more information.`)}if(this.__instanceProperties){for(const[i,a]of this.__instanceProperties)this[i]=a;this.__instanceProperties=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[i,a]of s){const{wrapped:o}=a,c=this[i];o===!0&&!this._$changedProperties.has(i)&&c!==void 0&&this._$changeProperty(i,void 0,a,c)}}let t=!1;const n=this._$changedProperties;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),this.__controllers?.forEach(s=>s.hostUpdate?.()),this.update(n)):this.__markUpdated()}catch(s){throw t=!1,this.__markUpdated(),s}t&&this._$didUpdate(n)}willUpdate(t){}_$didUpdate(t){this.__controllers?.forEach(n=>n.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t),this.isUpdatePending&&this.constructor.enabledWarnings.includes("change-in-update")&&le("change-in-update",`Element ${this.localName} scheduled an update (generally because a property was set) after an update completed, causing a new update to be scheduled. This is inefficient and should be avoided unless the next update can only be scheduled as a side effect of the previous update.`)}__markUpdated(){this._$changedProperties=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this.__updatePromise}shouldUpdate(t){return!0}update(t){this.__reflectingProperties&&=this.__reflectingProperties.forEach(n=>this.__propertyToAttribute(n,this[n])),this.__markUpdated()}updated(t){}firstUpdated(t){}}Se.elementStyles=[];Se.shadowRootOptions={mode:"open"};Se[ot("elementProperties")]=new Map;Se[ot("finalized")]=new Map;vo?.({ReactiveElement:Se});{Se.enabledWarnings=["change-in-update","async-perform-update"];const e=function(t){t.hasOwnProperty(ot("enabledWarnings"))||(t.enabledWarnings=t.enabledWarnings.slice())};Se.enableWarning=function(t){e(this),this.enabledWarnings.includes(t)||this.enabledWarnings.push(t)},Se.disableWarning=function(t){e(this);const n=this.enabledWarnings.indexOf(t);n>=0&&this.enabledWarnings.splice(n,1)}}(se.reactiveElementVersions??=[]).push("2.1.2");se.reactiveElementVersions.length>1&&queueMicrotask(()=>{le("multiple-versions","Multiple versions of Lit loaded. Loading multiple versions is not recommended.")});const te=globalThis,L=e=>{te.emitLitDebugLogEvents&&te.dispatchEvent(new CustomEvent("lit-debug",{detail:e}))};let $l=0,Rt;te.litIssuedWarnings??=new Set,Rt=(e,t)=>{t+=e?` See https://lit.dev/msg/${e} for more information.`:"",!te.litIssuedWarnings.has(t)&&!te.litIssuedWarnings.has(e)&&(console.warn(t),te.litIssuedWarnings.add(t))},queueMicrotask(()=>{Rt("dev-mode","Lit is in dev mode. Not recommended for production!")});const re=te.ShadyDOM?.inUse&&te.ShadyDOM?.noPatch===!0?te.ShadyDOM.wrap:e=>e,ln=te.trustedTypes,aa=ln?ln.createPolicy("lit-html",{createHTML:e=>e}):void 0,xl=e=>e,mn=(e,t,n)=>xl,kl=e=>{if(je!==mn)throw new Error("Attempted to overwrite existing lit-html security policy. setSanitizeDOMValueFactory should be called at most once.");je=e},Sl=()=>{je=mn},ws=(e,t,n)=>je(e,t,n),yo="$lit$",ke=`lit$${Math.random().toFixed(9).slice(2)}$`,bo="?"+ke,Al=`<${bo}>`,He=document,Mt=()=>He.createComment(""),It=e=>e===null||typeof e!="object"&&typeof e!="function",Qs=Array.isArray,_l=e=>Qs(e)||typeof e?.[Symbol.iterator]=="function",Zn=`[
|
|
2
|
-
\f\r]`,
|
|
3
|
-
\f\r"'\`<>=]`,
|
|
1
|
+
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();const hl=!1,nn=globalThis,Gs=nn.ShadowRoot&&(nn.ShadyCSS===void 0||nn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ys=Symbol(),ea=new WeakMap;class yo{constructor(t,n,s){if(this._$cssResult$=!0,s!==Ys)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this._strings=n}get styleSheet(){let t=this._styleSheet;const n=this._strings;if(Gs&&t===void 0){const s=n!==void 0&&n.length===1;s&&(t=ea.get(n)),t===void 0&&((this._styleSheet=t=new CSSStyleSheet).replaceSync(this.cssText),s&&ea.set(n,t))}return t}toString(){return this.cssText}}const fl=e=>{if(e._$cssResult$===!0)return e.cssText;if(typeof e=="number")return e;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${e}. Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.`)},gl=e=>new yo(typeof e=="string"?e:String(e),void 0,Ys),ml=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((s,i,a)=>s+fl(i)+e[a+1],e[0]);return new yo(n,e,Ys)},vl=(e,t)=>{if(Gs)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const s=document.createElement("style"),i=nn.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=n.cssText,e.appendChild(s)}},yl=e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return gl(t)},ta=Gs||hl?e=>e:e=>e instanceof CSSStyleSheet?yl(e):e;const{is:bl,defineProperty:wl,getOwnPropertyDescriptor:na,getOwnPropertyNames:$l,getOwnPropertySymbols:xl,getPrototypeOf:sa}=Object,se=globalThis;let le;const ia=se.trustedTypes,kl=ia?ia.emptyScript:"",bo=se.reactiveElementPolyfillSupportDevMode;se.litIssuedWarnings??=new Set,le=(e,t)=>{t+=` See https://lit.dev/msg/${e} for more information.`,!se.litIssuedWarnings.has(t)&&!se.litIssuedWarnings.has(e)&&(console.warn(t),se.litIssuedWarnings.add(t))},queueMicrotask(()=>{le("dev-mode","Lit is in dev mode. Not recommended for production!"),se.ShadyDOM?.inUse&&bo===void 0&&le("polyfill-support-missing","Shadow DOM is being polyfilled via `ShadyDOM` but the `polyfill-support` module has not been loaded.")});const Sl=e=>{se.emitLitDebugLogEvents&&se.dispatchEvent(new CustomEvent("lit-debug",{detail:e}))},ot=(e,t)=>e,rn={toAttribute(e,t){switch(t){case Boolean:e=e?kl:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e);break}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}break}return n}},Qs=(e,t)=>!bl(e,t),aa={attribute:!0,type:String,converter:rn,reflect:!1,useDefault:!1,hasChanged:Qs};Symbol.metadata??=Symbol("metadata");se.litPropertyMetadata??=new WeakMap;class Se extends HTMLElement{static addInitializer(t){this.__prepare(),(this._initializers??=[]).push(t)}static get observedAttributes(){return this.finalize(),this.__attributeToPropertyMap&&[...this.__attributeToPropertyMap.keys()]}static createProperty(t,n=aa){if(n.state&&(n.attribute=!1),this.__prepare(),this.prototype.hasOwnProperty(t)&&(n=Object.create(n),n.wrapped=!0),this.elementProperties.set(t,n),!n.noAccessor){const s=Symbol.for(`${String(t)} (@property() cache)`),i=this.getPropertyDescriptor(t,s,n);i!==void 0&&wl(this.prototype,t,i)}}static getPropertyDescriptor(t,n,s){const{get:i,set:a}=na(this.prototype,t)??{get(){return this[n]},set(o){this[n]=o}};if(i==null){if("value"in(na(this.prototype,t)??{}))throw new Error(`Field ${JSON.stringify(String(t))} on ${this.name} was declared as a reactive property but it's actually declared as a value on the prototype. Usually this is due to using @property or @state on a method.`);le("reactive-property-without-getter",`Field ${JSON.stringify(String(t))} on ${this.name} was declared as a reactive property but it does not have a getter. This will be an error in a future version of Lit.`)}return{get:i,set(o){const c=i?.call(this);a?.call(this,o),this.requestUpdate(t,c,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??aa}static __prepare(){if(this.hasOwnProperty(ot("elementProperties")))return;const t=sa(this);t.finalize(),t._initializers!==void 0&&(this._initializers=[...t._initializers]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(ot("finalized")))return;if(this.finalized=!0,this.__prepare(),this.hasOwnProperty(ot("properties"))){const n=this.properties,s=[...$l(n),...xl(n)];for(const i of s)this.createProperty(i,n[i])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[s,i]of n)this.elementProperties.set(s,i)}this.__attributeToPropertyMap=new Map;for(const[n,s]of this.elementProperties){const i=this.__attributeNameForProperty(n,s);i!==void 0&&this.__attributeToPropertyMap.set(i,n)}this.elementStyles=this.finalizeStyles(this.styles),this.hasOwnProperty("createProperty")&&le("no-override-create-property","Overriding ReactiveElement.createProperty() is deprecated. The override will not be called with standard decorators"),this.hasOwnProperty("getPropertyDescriptor")&&le("no-override-get-property-descriptor","Overriding ReactiveElement.getPropertyDescriptor() is deprecated. The override will not be called with standard decorators")}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)n.unshift(ta(i))}else t!==void 0&&n.push(ta(t));return n}static __attributeNameForProperty(t,n){const s=n.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this.__instanceProperties=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this.__reflectingProperty=null,this.__initialize()}__initialize(){this.__updatePromise=new Promise(t=>this.enableUpdating=t),this._$changedProperties=new Map,this.__saveInstanceProperties(),this.requestUpdate(),this.constructor._initializers?.forEach(t=>t(this))}addController(t){(this.__controllers??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this.__controllers?.delete(t)}__saveInstanceProperties(){const t=new Map,n=this.constructor.elementProperties;for(const s of n.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this.__instanceProperties=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return vl(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this.__controllers?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this.__controllers?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,n,s){this._$attributeToProperty(t,s)}__propertyToAttribute(t,n){const i=this.constructor.elementProperties.get(t),a=this.constructor.__attributeNameForProperty(t,i);if(a!==void 0&&i.reflect===!0){const c=(i.converter?.toAttribute!==void 0?i.converter:rn).toAttribute(n,i.type);this.constructor.enabledWarnings.includes("migration")&&c===void 0&&le("undefined-attribute-value",`The attribute value for the ${t} property is undefined on element ${this.localName}. The attribute will be removed, but in the previous version of \`ReactiveElement\`, the attribute would not have changed.`),this.__reflectingProperty=t,c==null?this.removeAttribute(a):this.setAttribute(a,c),this.__reflectingProperty=null}}_$attributeToProperty(t,n){const s=this.constructor,i=s.__attributeToPropertyMap.get(t);if(i!==void 0&&this.__reflectingProperty!==i){const a=s.getPropertyOptions(i),o=typeof a.converter=="function"?{fromAttribute:a.converter}:a.converter?.fromAttribute!==void 0?a.converter:rn;this.__reflectingProperty=i;const c=o.fromAttribute(n,a.type);this[i]=c??this.__defaultValues?.get(i)??c,this.__reflectingProperty=null}}requestUpdate(t,n,s,i=!1,a){if(t!==void 0){t instanceof Event&&le("","The requestUpdate() method was called with an Event as the property name. This is probably a mistake caused by binding this.requestUpdate as an event listener. Instead bind a function that will call it with no arguments: () => this.requestUpdate()");const o=this.constructor;if(i===!1&&(a=this[t]),s??=o.getPropertyOptions(t),(s.hasChanged??Qs)(a,n)||s.useDefault&&s.reflect&&a===this.__defaultValues?.get(t)&&!this.hasAttribute(o.__attributeNameForProperty(t,s)))this._$changeProperty(t,n,s);else return}this.isUpdatePending===!1&&(this.__updatePromise=this.__enqueueUpdate())}_$changeProperty(t,n,{useDefault:s,reflect:i,wrapped:a},o){s&&!(this.__defaultValues??=new Map).has(t)&&(this.__defaultValues.set(t,o??n??this[t]),a!==!0||o!==void 0)||(this._$changedProperties.has(t)||(!this.hasUpdated&&!s&&(n=void 0),this._$changedProperties.set(t,n)),i===!0&&this.__reflectingProperty!==t&&(this.__reflectingProperties??=new Set).add(t))}async __enqueueUpdate(){this.isUpdatePending=!0;try{await this.__updatePromise}catch(n){Promise.reject(n)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){const t=this.performUpdate();return this.constructor.enabledWarnings.includes("async-perform-update")&&typeof t?.then=="function"&&le("async-perform-update",`Element ${this.localName} returned a Promise from performUpdate(). This behavior is deprecated and will be removed in a future version of ReactiveElement.`),t}performUpdate(){if(!this.isUpdatePending)return;if(Sl?.({kind:"update"}),!this.hasUpdated){this.renderRoot??=this.createRenderRoot();{const a=[...this.constructor.elementProperties.keys()].filter(o=>this.hasOwnProperty(o)&&o in sa(this));if(a.length)throw new Error(`The following properties on element ${this.localName} will not trigger updates as expected because they are set using class fields: ${a.join(", ")}. Native class fields and some compiled output will overwrite accessors used for detecting changes. See https://lit.dev/msg/class-field-shadowing for more information.`)}if(this.__instanceProperties){for(const[i,a]of this.__instanceProperties)this[i]=a;this.__instanceProperties=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[i,a]of s){const{wrapped:o}=a,c=this[i];o===!0&&!this._$changedProperties.has(i)&&c!==void 0&&this._$changeProperty(i,void 0,a,c)}}let t=!1;const n=this._$changedProperties;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),this.__controllers?.forEach(s=>s.hostUpdate?.()),this.update(n)):this.__markUpdated()}catch(s){throw t=!1,this.__markUpdated(),s}t&&this._$didUpdate(n)}willUpdate(t){}_$didUpdate(t){this.__controllers?.forEach(n=>n.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t),this.isUpdatePending&&this.constructor.enabledWarnings.includes("change-in-update")&&le("change-in-update",`Element ${this.localName} scheduled an update (generally because a property was set) after an update completed, causing a new update to be scheduled. This is inefficient and should be avoided unless the next update can only be scheduled as a side effect of the previous update.`)}__markUpdated(){this._$changedProperties=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this.__updatePromise}shouldUpdate(t){return!0}update(t){this.__reflectingProperties&&=this.__reflectingProperties.forEach(n=>this.__propertyToAttribute(n,this[n])),this.__markUpdated()}updated(t){}firstUpdated(t){}}Se.elementStyles=[];Se.shadowRootOptions={mode:"open"};Se[ot("elementProperties")]=new Map;Se[ot("finalized")]=new Map;bo?.({ReactiveElement:Se});{Se.enabledWarnings=["change-in-update","async-perform-update"];const e=function(t){t.hasOwnProperty(ot("enabledWarnings"))||(t.enabledWarnings=t.enabledWarnings.slice())};Se.enableWarning=function(t){e(this),this.enabledWarnings.includes(t)||this.enabledWarnings.push(t)},Se.disableWarning=function(t){e(this);const n=this.enabledWarnings.indexOf(t);n>=0&&this.enabledWarnings.splice(n,1)}}(se.reactiveElementVersions??=[]).push("2.1.2");se.reactiveElementVersions.length>1&&queueMicrotask(()=>{le("multiple-versions","Multiple versions of Lit loaded. Loading multiple versions is not recommended.")});const te=globalThis,L=e=>{te.emitLitDebugLogEvents&&te.dispatchEvent(new CustomEvent("lit-debug",{detail:e}))};let Al=0,Rt;te.litIssuedWarnings??=new Set,Rt=(e,t)=>{t+=e?` See https://lit.dev/msg/${e} for more information.`:"",!te.litIssuedWarnings.has(t)&&!te.litIssuedWarnings.has(e)&&(console.warn(t),te.litIssuedWarnings.add(t))},queueMicrotask(()=>{Rt("dev-mode","Lit is in dev mode. Not recommended for production!")});const re=te.ShadyDOM?.inUse&&te.ShadyDOM?.noPatch===!0?te.ShadyDOM.wrap:e=>e,ln=te.trustedTypes,oa=ln?ln.createPolicy("lit-html",{createHTML:e=>e}):void 0,_l=e=>e,mn=(e,t,n)=>_l,Tl=e=>{if(je!==mn)throw new Error("Attempted to overwrite existing lit-html security policy. setSanitizeDOMValueFactory should be called at most once.");je=e},Cl=()=>{je=mn},$s=(e,t,n)=>je(e,t,n),wo="$lit$",ke=`lit$${Math.random().toFixed(9).slice(2)}$`,$o="?"+ke,El=`<${$o}>`,He=document,Mt=()=>He.createComment(""),It=e=>e===null||typeof e!="object"&&typeof e!="function",Js=Array.isArray,Rl=e=>Js(e)||typeof e?.[Symbol.iterator]=="function",Zn=`[
|
|
2
|
+
\f\r]`,Ml=`[^
|
|
3
|
+
\f\r"'\`<>=]`,Il=`[^\\s"'>=/]`,vt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ra=1,Xn=2,Ll=3,la=/-->/g,ca=/>/g,De=new RegExp(`>|${Zn}(?:(${Il}+)(${Zn}*=${Zn}*(?:${Ml}|("|')|))|$)`,"g"),Pl=0,da=1,Nl=2,ua=3,es=/'/g,ts=/"/g,xo=/^(?:script|style|textarea|title)$/i,Ol=1,xs=2,ks=3,Zs=1,cn=2,Dl=3,Bl=4,Fl=5,Xs=6,Ul=7,Kl=e=>(t,...n)=>(t.some(s=>s===void 0)&&console.warn(`Some template strings are undefined.
|
|
4
4
|
This is probably caused by illegal octal escape sequences.`),n.some(s=>s?._$litStatic$)&&Rt("",`Static values 'literal' or 'unsafeStatic' cannot be used as values to non-static templates.
|
|
5
|
-
Please use the static 'html' tag function. See https://lit.dev/docs/templates/expressions/#static-expressions`),{_$litType$:e,strings:t,values:n}),
|
|
5
|
+
Please use the static 'html' tag function. See https://lit.dev/docs/templates/expressions/#static-expressions`),{_$litType$:e,strings:t,values:n}),r=Kl(Ol),Ie=Symbol.for("lit-noChange"),g=Symbol.for("lit-nothing"),pa=new WeakMap,Ke=He.createTreeWalker(He,129);let je=mn;function ko(e,t){if(!Js(e)||!e.hasOwnProperty("raw")){let n="invalid template strings array";throw n=`
|
|
6
6
|
Internal Error: expected template strings to be an array
|
|
7
7
|
with a 'raw' field. Faking a template strings array by
|
|
8
8
|
calling html or svg like an ordinary function is effectively
|
|
@@ -13,28 +13,28 @@ Please use the static 'html' tag function. See https://lit.dev/docs/templates/ex
|
|
|
13
13
|
https://github.com/lit/lit/issues/new?template=bug_report.md
|
|
14
14
|
and include information about your build tooling, if any.
|
|
15
15
|
`.trim().replace(/\n */g,`
|
|
16
|
-
`),new Error(n)}return aa!==void 0?aa.createHTML(t):t}const Bl=(e,t)=>{const n=e.length-1,s=[];let i=t===$s?"<svg>":t===xs?"<math>":"",a,o=vt;for(let r=0;r<n;r++){const u=e[r];let d=-1,p,f=0,m;for(;f<u.length&&(o.lastIndex=f,m=o.exec(u),m!==null);)if(f=o.lastIndex,o===vt){if(m[oa]==="!--")o=ra;else if(m[oa]!==void 0)o=la;else if(m[Xn]!==void 0)wo.test(m[Xn])&&(a=new RegExp(`</${m[Xn]}`,"g")),o=De;else if(m[El]!==void 0)throw new Error("Bindings in tag names are not supported. Please use static templates instead. See https://lit.dev/docs/templates/expressions/#static-expressions")}else o===De?m[Rl]===">"?(o=a??vt,d=-1):m[ca]===void 0?d=-2:(d=o.lastIndex-m[Ml].length,p=m[ca],o=m[da]===void 0?De:m[da]==='"'?ts:es):o===ts||o===es?o=De:o===ra||o===la?o=vt:(o=De,a=void 0);console.assert(d===-1||o===De||o===es||o===ts,"unexpected parse state B");const v=o===De&&e[r+1].startsWith("/>")?" ":"";i+=o===vt?u+Al:d>=0?(s.push(p),u.slice(0,d)+yo+u.slice(d)+ke+v):u+ke+(d===-2?r:v)}const c=i+(e[n]||"<?>")+(t===$s?"</svg>":t===xs?"</math>":"");return[$o(e,c),s]};class Lt{constructor({strings:t,["_$litType$"]:n},s){this.parts=[];let i,a=0,o=0;const c=t.length-1,r=this.parts,[u,d]=Bl(t,n);if(this.el=Lt.createElement(u,s),Ke.currentNode=this.el.content,n===$s||n===xs){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=Ke.nextNode())!==null&&r.length<c;){if(i.nodeType===1){{const p=i.localName;if(/^(?:textarea|template)$/i.test(p)&&i.innerHTML.includes(ke)){const f=`Expressions are not supported inside \`${p}\` elements. See https://lit.dev/msg/expression-in-${p} for more information.`;if(p==="template")throw new Error(f);Rt("",f)}}if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(yo)){const f=d[o++],v=i.getAttribute(p).split(ke),$=/([.?@])?(.*)/.exec(f);r.push({type:Js,index:a,name:$[2],strings:v,ctor:$[1]==="."?Ul:$[1]==="?"?Kl:$[1]==="@"?zl:yn}),i.removeAttribute(p)}else p.startsWith(ke)&&(r.push({type:Zs,index:a}),i.removeAttribute(p));if(wo.test(i.tagName)){const p=i.textContent.split(ke),f=p.length-1;if(f>0){i.textContent=ln?ln.emptyScript:"";for(let m=0;m<f;m++)i.append(p[m],Mt()),Ke.nextNode(),r.push({type:cn,index:++a});i.append(p[f],Mt())}}}else if(i.nodeType===8)if(i.data===bo)r.push({type:cn,index:a});else{let f=-1;for(;(f=i.data.indexOf(ke,f+1))!==-1;)r.push({type:Ol,index:a}),f+=ke.length-1}a++}if(d.length!==o)throw new Error('Detected duplicate attribute bindings. This occurs if your template has duplicate attributes on an element tag. For example "<input ?disabled=${true} ?disabled=${false}>" contains a duplicate "disabled" attribute. The error was detected in the following template: \n`'+t.join("${...}")+"`");L&&L({kind:"template prep",template:this,clonableTemplate:this.el,parts:this.parts,strings:t})}static createElement(t,n){const s=He.createElement("template");return s.innerHTML=t,s}}function rt(e,t,n=e,s){if(t===Ie)return t;let i=s!==void 0?n.__directives?.[s]:n.__directive;const a=It(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$notifyDirectiveConnectionChanged?.(!1),a===void 0?i=void 0:(i=new a(e),i._$initialize(e,n,s)),s!==void 0?(n.__directives??=[])[s]=i:n.__directive=i),i!==void 0&&(t=rt(e,i._$resolve(e,t.values),i,s)),t}class Fl{constructor(t,n){this._$parts=[],this._$disconnectableChildren=void 0,this._$template=t,this._$parent=n}get parentNode(){return this._$parent.parentNode}get _$isConnected(){return this._$parent._$isConnected}_clone(t){const{el:{content:n},parts:s}=this._$template,i=(t?.creationScope??He).importNode(n,!0);Ke.currentNode=i;let a=Ke.nextNode(),o=0,c=0,r=s[0];for(;r!==void 0;){if(o===r.index){let u;r.type===cn?u=new vn(a,a.nextSibling,this,t):r.type===Js?u=new r.ctor(a,r.name,r.strings,this,t):r.type===Zs&&(u=new Hl(a,this,t)),this._$parts.push(u),r=s[++c]}o!==r?.index&&(a=Ke.nextNode(),o++)}return Ke.currentNode=He,i}_update(t){let n=0;for(const s of this._$parts)s!==void 0&&(L&&L({kind:"set part",part:s,value:t[n],valueIndex:n,values:t,templateInstance:this}),s.strings!==void 0?(s._$setValue(t,s,n),n+=s.strings.length-2):s._$setValue(t[n])),n++}}let vn=class xo{get _$isConnected(){return this._$parent?._$isConnected??this.__isConnected}constructor(t,n,s,i){this.type=cn,this._$committedValue=g,this._$disconnectableChildren=void 0,this._$startNode=t,this._$endNode=n,this._$parent=s,this.options=i,this.__isConnected=i?.isConnected??!0,this._textSanitizer=void 0}get parentNode(){let t=re(this._$startNode).parentNode;const n=this._$parent;return n!==void 0&&t?.nodeType===11&&(t=n.parentNode),t}get startNode(){return this._$startNode}get endNode(){return this._$endNode}_$setValue(t,n=this){if(this.parentNode===null)throw new Error("This `ChildPart` has no `parentNode` and therefore cannot accept a value. This likely means the element containing the part was manipulated in an unsupported way outside of Lit's control such that the part's marker nodes were ejected from DOM. For example, setting the element's `innerHTML` or `textContent` can do this.");if(t=rt(this,t,n),It(t))t===g||t==null||t===""?(this._$committedValue!==g&&(L&&L({kind:"commit nothing to child",start:this._$startNode,end:this._$endNode,parent:this._$parent,options:this.options}),this._$clear()),this._$committedValue=g):t!==this._$committedValue&&t!==Ie&&this._commitText(t);else if(t._$litType$!==void 0)this._commitTemplateResult(t);else if(t.nodeType!==void 0){if(this.options?.host===t){this._commitText("[probable mistake: rendered a template's host in itself (commonly caused by writing ${this} in a template]"),console.warn("Attempted to render the template host",t,"inside itself. This is almost always a mistake, and in dev mode ","we render some warning text. In production however, we'll ","render it, which will usually result in an error, and sometimes ","in the element disappearing from the DOM.");return}this._commitNode(t)}else _l(t)?this._commitIterable(t):this._commitText(t)}_insert(t){return re(re(this._$startNode).parentNode).insertBefore(t,this._$endNode)}_commitNode(t){if(this._$committedValue!==t){if(this._$clear(),je!==mn){const n=this._$startNode.parentNode?.nodeName;if(n==="STYLE"||n==="SCRIPT"){let s="Forbidden";throw n==="STYLE"?s="Lit does not support binding inside style nodes. This is a security risk, as style injection attacks can exfiltrate data and spoof UIs. Consider instead using css`...` literals to compose styles, and do dynamic styling with css custom properties, ::parts, <slot>s, and by mutating the DOM rather than stylesheets.":s="Lit does not support binding inside script nodes. This is a security risk, as it could allow arbitrary code execution.",new Error(s)}}L&&L({kind:"commit node",start:this._$startNode,parent:this._$parent,value:t,options:this.options}),this._$committedValue=this._insert(t)}}_commitText(t){if(this._$committedValue!==g&&It(this._$committedValue)){const n=re(this._$startNode).nextSibling;this._textSanitizer===void 0&&(this._textSanitizer=ws(n,"data","property")),t=this._textSanitizer(t),L&&L({kind:"commit text",node:n,value:t,options:this.options}),n.data=t}else{const n=He.createTextNode("");this._commitNode(n),this._textSanitizer===void 0&&(this._textSanitizer=ws(n,"data","property")),t=this._textSanitizer(t),L&&L({kind:"commit text",node:n,value:t,options:this.options}),n.data=t}this._$committedValue=t}_commitTemplateResult(t){const{values:n,["_$litType$"]:s}=t,i=typeof s=="number"?this._$getTemplate(t):(s.el===void 0&&(s.el=Lt.createElement($o(s.h,s.h[0]),this.options)),s);if(this._$committedValue?._$template===i)L&&L({kind:"template updating",template:i,instance:this._$committedValue,parts:this._$committedValue._$parts,options:this.options,values:n}),this._$committedValue._update(n);else{const a=new Fl(i,this),o=a._clone(this.options);L&&L({kind:"template instantiated",template:i,instance:a,parts:a._$parts,options:this.options,fragment:o,values:n}),a._update(n),L&&L({kind:"template instantiated and updated",template:i,instance:a,parts:a._$parts,options:this.options,fragment:o,values:n}),this._commitNode(o),this._$committedValue=a}}_$getTemplate(t){let n=ua.get(t.strings);return n===void 0&&ua.set(t.strings,n=new Lt(t)),n}_commitIterable(t){Qs(this._$committedValue)||(this._$committedValue=[],this._$clear());const n=this._$committedValue;let s=0,i;for(const a of t)s===n.length?n.push(i=new xo(this._insert(Mt()),this._insert(Mt()),this,this.options)):i=n[s],i._$setValue(a),s++;s<n.length&&(this._$clear(i&&re(i._$endNode).nextSibling,s),n.length=s)}_$clear(t=re(this._$startNode).nextSibling,n){for(this._$notifyConnectionChanged?.(!1,!0,n);t!==this._$endNode;){const s=re(t).nextSibling;re(t).remove(),t=s}}setConnected(t){if(this._$parent===void 0)this.__isConnected=t,this._$notifyConnectionChanged?.(t);else throw new Error("part.setConnected() may only be called on a RootPart returned from render().")}};class yn{get tagName(){return this.element.tagName}get _$isConnected(){return this._$parent._$isConnected}constructor(t,n,s,i,a){this.type=Js,this._$committedValue=g,this._$disconnectableChildren=void 0,this.element=t,this.name=n,this._$parent=i,this.options=a,s.length>2||s[0]!==""||s[1]!==""?(this._$committedValue=new Array(s.length-1).fill(new String),this.strings=s):this._$committedValue=g,this._sanitizer=void 0}_$setValue(t,n=this,s,i){const a=this.strings;let o=!1;if(a===void 0)t=rt(this,t,n,0),o=!It(t)||t!==this._$committedValue&&t!==Ie,o&&(this._$committedValue=t);else{const c=t;t=a[0];let r,u;for(r=0;r<a.length-1;r++)u=rt(this,c[s+r],n,r),u===Ie&&(u=this._$committedValue[r]),o||=!It(u)||u!==this._$committedValue[r],u===g?t=g:t!==g&&(t+=(u??"")+a[r+1]),this._$committedValue[r]=u}o&&!i&&this._commitValue(t)}_commitValue(t){t===g?re(this.element).removeAttribute(this.name):(this._sanitizer===void 0&&(this._sanitizer=je(this.element,this.name,"attribute")),t=this._sanitizer(t??""),L&&L({kind:"commit attribute",element:this.element,name:this.name,value:t,options:this.options}),re(this.element).setAttribute(this.name,t??""))}}class Ul extends yn{constructor(){super(...arguments),this.type=Ll}_commitValue(t){this._sanitizer===void 0&&(this._sanitizer=je(this.element,this.name,"property")),t=this._sanitizer(t),L&&L({kind:"commit property",element:this.element,name:this.name,value:t,options:this.options}),this.element[this.name]=t===g?void 0:t}}class Kl extends yn{constructor(){super(...arguments),this.type=Pl}_commitValue(t){L&&L({kind:"commit boolean attribute",element:this.element,name:this.name,value:!!(t&&t!==g),options:this.options}),re(this.element).toggleAttribute(this.name,!!t&&t!==g)}}class zl extends yn{constructor(t,n,s,i,a){if(super(t,n,s,i,a),this.type=Nl,this.strings!==void 0)throw new Error(`A \`<${t.localName}>\` has a \`@${n}=...\` listener with invalid content. Event listeners in templates must have exactly one expression and no surrounding text.`)}_$setValue(t,n=this){if(t=rt(this,t,n,0)??g,t===Ie)return;const s=this._$committedValue,i=t===g&&s!==g||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,a=t!==g&&(s===g||i);L&&L({kind:"commit event listener",element:this.element,name:this.name,value:t,options:this.options,removeListener:i,addListener:a,oldListener:s}),i&&this.element.removeEventListener(this.name,this,s),a&&this.element.addEventListener(this.name,this,t),this._$committedValue=t}handleEvent(t){typeof this._$committedValue=="function"?this._$committedValue.call(this.options?.host??this.element,t):this._$committedValue.handleEvent(t)}}class Hl{constructor(t,n,s){this.element=t,this.type=Zs,this._$disconnectableChildren=void 0,this._$parent=n,this.options=s}get _$isConnected(){return this._$parent._$isConnected}_$setValue(t){L&&L({kind:"commit to element binding",element:this.element,value:t,options:this.options}),rt(this,t)}}const jl={_ChildPart:vn},Vl=te.litHtmlPolyfillSupportDevMode;Vl?.(Lt,vn);(te.litHtmlVersions??=[]).push("3.3.2");te.litHtmlVersions.length>1&&queueMicrotask(()=>{Rt("multiple-versions","Multiple versions of Lit loaded. Loading multiple versions is not recommended.")});const sn=(e,t,n)=>{if(t==null)throw new TypeError(`The container to render into may not be ${t}`);const s=$l++,i=n?.renderBefore??t;let a=i._$litPart$;if(L&&L({kind:"begin render",id:s,value:e,container:t,options:n,part:a}),a===void 0){const o=n?.renderBefore??null;i._$litPart$=a=new vn(t.insertBefore(Mt(),o),o,void 0,n??{})}return a._$setValue(e),L&&L({kind:"end render",id:s,value:e,container:t,options:n,part:a}),a};sn.setSanitizer=kl,sn.createSanitizer=ws,sn._testOnlyClearSanitizerFactoryDoNotCallOrElse=Sl;const Wl=(e,t)=>e,Ee=globalThis;let ko;Ee.litIssuedWarnings??=new Set,ko=(e,t)=>{t+=` See https://lit.dev/msg/${e} for more information.`,!Ee.litIssuedWarnings.has(t)&&!Ee.litIssuedWarnings.has(e)&&(console.warn(t),Ee.litIssuedWarnings.add(t))};class pt extends Se{constructor(){super(...arguments),this.renderOptions={host:this},this.__childPart=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this.__childPart=sn(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this.__childPart?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this.__childPart?.setConnected(!1)}render(){return Ie}}pt._$litElement$=!0;pt[Wl("finalized")]=!0;Ee.litElementHydrateSupport?.({LitElement:pt});const ql=Ee.litElementPolyfillSupportDevMode;ql?.({LitElement:pt});(Ee.litElementVersions??=[]).push("4.2.2");Ee.litElementVersions.length>1&&queueMicrotask(()=>{ko("multiple-versions","Multiple versions of Lit loaded. Loading multiple versions is not recommended.")});const So=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};let Ao;globalThis.litIssuedWarnings??=new Set,Ao=(e,t)=>{t+=` See https://lit.dev/msg/${e} for more information.`,!globalThis.litIssuedWarnings.has(t)&&!globalThis.litIssuedWarnings.has(e)&&(console.warn(t),globalThis.litIssuedWarnings.add(t))};const Gl=(e,t,n)=>{const s=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),s?Object.getOwnPropertyDescriptor(t,n):void 0},Yl={attribute:!0,type:String,converter:rn,reflect:!1,hasChanged:Ys},Ql=(e=Yl,t,n)=>{const{kind:s,metadata:i}=n;i==null&&Ao("missing-class-metadata",`The class ${t} is missing decorator metadata. This could mean that you're using a compiler that supports decorators but doesn't support decorator metadata, such as TypeScript 5.1. Please update your compiler.`);let a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),s==="setter"&&(e=Object.create(e),e.wrapped=!0),a.set(n.name,e),s==="accessor"){const{name:o}=n;return{set(c){const r=t.get.call(this);t.set.call(this,c),this.requestUpdate(o,r,e,!0,c)},init(c){return c!==void 0&&this._$changeProperty(o,void 0,e,c),c}}}else if(s==="setter"){const{name:o}=n;return function(c){const r=this[o];t.call(this,c),this.requestUpdate(o,r,e,!0,c)}}throw new Error(`Unsupported decorator location: ${s}`)};function bn(e){return(t,n)=>typeof n=="object"?Ql(e,t,n):Gl(e,t,n)}function w(e){return bn({...e,state:!0,attribute:!1})}globalThis.litIssuedWarnings??=new Set;const Jl=50,Zl=200,Xl="Assistant";function pa(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function ks(e){const t=pa(e?.name,Jl)??Xl,n=pa(e?.avatar??void 0,Zl)??null;return{agentId:typeof e?.agentId=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function ec(){return ks(typeof window>"u"?{}:{name:window.__CLAWDBOT_ASSISTANT_NAME__,avatar:window.__CLAWDBOT_ASSISTANT_AVATAR__})}const _o="poolbot.control.settings.v1";function tc(){const t={gatewayUrl:`${location.protocol==="https:"?"wss":"ws"}://${location.host}`,token:"",sessionKey:"main",lastActiveSessionKey:"main",theme:"system",chatFocusMode:!1,chatShowThinking:!0,splitRatio:.6,navCollapsed:!1,navGroupsCollapsed:{}};try{const n=localStorage.getItem(_o);if(!n)return t;const s=JSON.parse(n);return{gatewayUrl:typeof s.gatewayUrl=="string"&&s.gatewayUrl.trim()?s.gatewayUrl.trim():t.gatewayUrl,token:typeof s.token=="string"?s.token:t.token,sessionKey:typeof s.sessionKey=="string"&&s.sessionKey.trim()?s.sessionKey.trim():t.sessionKey,lastActiveSessionKey:typeof s.lastActiveSessionKey=="string"&&s.lastActiveSessionKey.trim()?s.lastActiveSessionKey.trim():typeof s.sessionKey=="string"&&s.sessionKey.trim()||t.lastActiveSessionKey,theme:s.theme==="light"||s.theme==="dark"||s.theme==="system"?s.theme:t.theme,chatFocusMode:typeof s.chatFocusMode=="boolean"?s.chatFocusMode:t.chatFocusMode,chatShowThinking:typeof s.chatShowThinking=="boolean"?s.chatShowThinking:t.chatShowThinking,splitRatio:typeof s.splitRatio=="number"&&s.splitRatio>=.4&&s.splitRatio<=.7?s.splitRatio:t.splitRatio,navCollapsed:typeof s.navCollapsed=="boolean"?s.navCollapsed:t.navCollapsed,navGroupsCollapsed:typeof s.navGroupsCollapsed=="object"&&s.navGroupsCollapsed!==null?s.navGroupsCollapsed:t.navGroupsCollapsed}}catch{return t}}function nc(e){localStorage.setItem(_o,JSON.stringify(e))}function To(e){const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const s=n[1]?.trim(),i=n.slice(2).join(":");return!s||!i?null:{agentId:s,rest:i}}const sc=[{label:"Chat",tabs:["chat"]},{label:"Control",tabs:["overview","channels","instances","sessions","cron"]},{label:"Agent",tabs:["skills","nodes"]},{label:"Insights",tabs:["usage"]},{label:"Settings",tabs:["config","debug","logs"]}],Co={overview:"/overview",channels:"/channels",instances:"/instances",sessions:"/sessions",cron:"/cron",skills:"/skills",nodes:"/nodes",usage:"/usage",chat:"/chat",config:"/config",debug:"/debug",logs:"/logs"},Eo=new Map(Object.entries(Co).map(([e,t])=>[t,e]));function wn(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function Pt(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 $n(e,t=""){const n=wn(t),s=Co[e];return n?`${n}${s}`:s}function Ro(e,t=""){const n=wn(t);let s=e||"/";n&&(s===n?s="/":s.startsWith(`${n}/`)&&(s=s.slice(n.length)));let i=Pt(s).toLowerCase();return i.endsWith("/index.html")&&(i="/"),i==="/"?"chat":Eo.get(i)??null}function ic(e){let t=Pt(e);if(t.endsWith("/index.html")&&(t=Pt(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let s=0;s<n.length;s++){const i=`/${n.slice(s).join("/")}`.toLowerCase();if(Eo.has(i)){const a=n.slice(0,s);return a.length?`/${a.join("/")}`:""}}return`/${n.join("/")}`}function ac(e){switch(e){case"chat":return"messageSquare";case"overview":return"barChart";case"channels":return"link";case"instances":return"radio";case"sessions":return"fileText";case"cron":return"loader";case"skills":return"zap";case"nodes":return"monitor";case"usage":return"barChart";case"config":return"settings";case"debug":return"bug";case"logs":return"scrollText";default:return"folder"}}function Ss(e){switch(e){case"overview":return"Overview";case"channels":return"Channels";case"instances":return"Instances";case"sessions":return"Sessions";case"cron":return"Cron Jobs";case"skills":return"Skills";case"nodes":return"Nodes";case"usage":return"Usage & Costs";case"chat":return"Chat";case"config":return"Config";case"debug":return"Debug";case"logs":return"Logs";default:return"Control"}}function oc(e){switch(e){case"overview":return"Gateway status, entry points, and a fast health read.";case"channels":return"Manage channels and settings.";case"instances":return"Presence beacons from connected clients and nodes.";case"sessions":return"Inspect active sessions and adjust per-session defaults.";case"cron":return"Schedule wakeups and recurring agent runs.";case"skills":return"Manage skill availability and API key injection.";case"nodes":return"Paired devices, capabilities, and command exposure.";case"usage":return"Token usage, cost breakdown, and session analytics.";case"chat":return"Direct gateway chat session for quick interventions.";case"config":return"Edit ~/.poolbot/poolbot.json safely.";case"debug":return"Gateway snapshots, events, and manual RPC calls.";case"logs":return"Live tail of the gateway file logs.";default:return""}}const G={messageSquare:l`<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:l`<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:l`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,radio:l`<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:l`<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:l`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:l`<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:l`<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:l`<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:l`<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:l`<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>`,menu:l`<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:l`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:l`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:l`<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:l`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:l`<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:l`<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:l`<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>`,wrench:l`<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:l`<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:l`<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:l`<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:l`<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:l`<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>`,eye:l`<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:l`<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>`,image:l`<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:l`<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>`,shield:l`<svg viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/><path d="m9 12 2 2 4-4"/></svg>`,plug:l`<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:l`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,puzzle:l`<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>`},rc=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,Gt=/<\s*\/?\s*final\b[^<>]*>/gi,ha=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^<>]*>/gi;function fa(e){const t=[],n=/(^|\n)(```|~~~)[^\n]*\n[\s\S]*?(?:\n\2(?:\n|$)|$)/g;for(const i of e.matchAll(n)){const a=(i.index??0)+i[1].length;t.push({start:a,end:a+i[0].length-i[1].length})}const s=/`+[^`]+`+/g;for(const i of e.matchAll(s)){const a=i.index??0,o=a+i[0].length;t.some(r=>a>=r.start&&o<=r.end)||t.push({start:a,end:o})}return t.sort((i,a)=>i.start-a.start),t}function ga(e,t){return t.some(n=>e>=n.start&&e<n.end)}function lc(e,t){return e.trimStart()}function cc(e,t){if(!e||!rc.test(e))return e;let n=e;if(Gt.test(n)){Gt.lastIndex=0;const c=[],r=fa(n);for(const u of n.matchAll(Gt)){const d=u.index??0;c.push({start:d,length:u[0].length,inCode:ga(d,r)})}for(let u=c.length-1;u>=0;u--){const d=c[u];d.inCode||(n=n.slice(0,d.start)+n.slice(d.start+d.length))}}else Gt.lastIndex=0;const s=fa(n);ha.lastIndex=0;let i="",a=0,o=!1;for(const c of n.matchAll(ha)){const r=c.index??0,u=c[1]==="/";ga(r,s)||(o?u&&(o=!1):(i+=n.slice(a,r),u||(o=!0)),a=r+c[0].length)}return i+=n.slice(a),lc(i)}function Nt(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString()}function D(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0)return"just now";const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const s=Math.round(n/60);if(s<60)return`${s}m ago`;const i=Math.round(s/60);return i<48?`${i}h ago`:`${Math.round(i/24)}d ago`}const xn=D;function dc(e){if(!e&&e!==0)return"n/a";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const s=Math.round(n/60);return s<48?`${s}h`:`${Math.round(s/24)}d`}function As(e){return!e||e.length===0?"none":e.filter(t=>!!(t&&t.trim())).join(", ")}function _s(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Mo(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 dn(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function ns(e){return cc(e)}const uc=/^\[([^\]]+)\]\s*/,pc=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],ss=new WeakMap,is=new WeakMap;function hc(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:pc.some(t=>e.startsWith(`${t} `))}function as(e){const t=e.match(uc);if(!t)return e;const n=t[1]??"";return hc(n)?e.slice(t[0].length):e}function Ts(e){const t=e,n=typeof t.role=="string"?t.role:"",s=t.content;if(typeof s=="string")return n==="assistant"?ns(s):as(s);if(Array.isArray(s)){const i=s.map(a=>{const o=a;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(a=>typeof a=="string");if(i.length>0){const a=i.join(`
|
|
17
|
-
`);return n==="assistant"?ns(a):as(a)}}return typeof t.text=="string"?n==="assistant"?ns(t.text):as(t.text):null}function
|
|
18
|
-
`);const i=
|
|
19
|
-
`):null}function
|
|
20
|
-
`)}return typeof t.text=="string"?t.text:null}function
|
|
21
|
-
`):""}let
|
|
16
|
+
`),new Error(n)}return oa!==void 0?oa.createHTML(t):t}const zl=(e,t)=>{const n=e.length-1,s=[];let i=t===xs?"<svg>":t===ks?"<math>":"",a,o=vt;for(let l=0;l<n;l++){const u=e[l];let d=-1,p,f=0,m;for(;f<u.length&&(o.lastIndex=f,m=o.exec(u),m!==null);)if(f=o.lastIndex,o===vt){if(m[ra]==="!--")o=la;else if(m[ra]!==void 0)o=ca;else if(m[Xn]!==void 0)xo.test(m[Xn])&&(a=new RegExp(`</${m[Xn]}`,"g")),o=De;else if(m[Ll]!==void 0)throw new Error("Bindings in tag names are not supported. Please use static templates instead. See https://lit.dev/docs/templates/expressions/#static-expressions")}else o===De?m[Pl]===">"?(o=a??vt,d=-1):m[da]===void 0?d=-2:(d=o.lastIndex-m[Nl].length,p=m[da],o=m[ua]===void 0?De:m[ua]==='"'?ts:es):o===ts||o===es?o=De:o===la||o===ca?o=vt:(o=De,a=void 0);console.assert(d===-1||o===De||o===es||o===ts,"unexpected parse state B");const v=o===De&&e[l+1].startsWith("/>")?" ":"";i+=o===vt?u+El:d>=0?(s.push(p),u.slice(0,d)+wo+u.slice(d)+ke+v):u+ke+(d===-2?l:v)}const c=i+(e[n]||"<?>")+(t===xs?"</svg>":t===ks?"</math>":"");return[ko(e,c),s]};class Lt{constructor({strings:t,["_$litType$"]:n},s){this.parts=[];let i,a=0,o=0;const c=t.length-1,l=this.parts,[u,d]=zl(t,n);if(this.el=Lt.createElement(u,s),Ke.currentNode=this.el.content,n===xs||n===ks){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=Ke.nextNode())!==null&&l.length<c;){if(i.nodeType===1){{const p=i.localName;if(/^(?:textarea|template)$/i.test(p)&&i.innerHTML.includes(ke)){const f=`Expressions are not supported inside \`${p}\` elements. See https://lit.dev/msg/expression-in-${p} for more information.`;if(p==="template")throw new Error(f);Rt("",f)}}if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(wo)){const f=d[o++],v=i.getAttribute(p).split(ke),$=/([.?@])?(.*)/.exec(f);l.push({type:Zs,index:a,name:$[2],strings:v,ctor:$[1]==="."?jl:$[1]==="?"?Vl:$[1]==="@"?Wl:yn}),i.removeAttribute(p)}else p.startsWith(ke)&&(l.push({type:Xs,index:a}),i.removeAttribute(p));if(xo.test(i.tagName)){const p=i.textContent.split(ke),f=p.length-1;if(f>0){i.textContent=ln?ln.emptyScript:"";for(let m=0;m<f;m++)i.append(p[m],Mt()),Ke.nextNode(),l.push({type:cn,index:++a});i.append(p[f],Mt())}}}else if(i.nodeType===8)if(i.data===$o)l.push({type:cn,index:a});else{let f=-1;for(;(f=i.data.indexOf(ke,f+1))!==-1;)l.push({type:Ul,index:a}),f+=ke.length-1}a++}if(d.length!==o)throw new Error('Detected duplicate attribute bindings. This occurs if your template has duplicate attributes on an element tag. For example "<input ?disabled=${true} ?disabled=${false}>" contains a duplicate "disabled" attribute. The error was detected in the following template: \n`'+t.join("${...}")+"`");L&&L({kind:"template prep",template:this,clonableTemplate:this.el,parts:this.parts,strings:t})}static createElement(t,n){const s=He.createElement("template");return s.innerHTML=t,s}}function rt(e,t,n=e,s){if(t===Ie)return t;let i=s!==void 0?n.__directives?.[s]:n.__directive;const a=It(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$notifyDirectiveConnectionChanged?.(!1),a===void 0?i=void 0:(i=new a(e),i._$initialize(e,n,s)),s!==void 0?(n.__directives??=[])[s]=i:n.__directive=i),i!==void 0&&(t=rt(e,i._$resolve(e,t.values),i,s)),t}class Hl{constructor(t,n){this._$parts=[],this._$disconnectableChildren=void 0,this._$template=t,this._$parent=n}get parentNode(){return this._$parent.parentNode}get _$isConnected(){return this._$parent._$isConnected}_clone(t){const{el:{content:n},parts:s}=this._$template,i=(t?.creationScope??He).importNode(n,!0);Ke.currentNode=i;let a=Ke.nextNode(),o=0,c=0,l=s[0];for(;l!==void 0;){if(o===l.index){let u;l.type===cn?u=new vn(a,a.nextSibling,this,t):l.type===Zs?u=new l.ctor(a,l.name,l.strings,this,t):l.type===Xs&&(u=new ql(a,this,t)),this._$parts.push(u),l=s[++c]}o!==l?.index&&(a=Ke.nextNode(),o++)}return Ke.currentNode=He,i}_update(t){let n=0;for(const s of this._$parts)s!==void 0&&(L&&L({kind:"set part",part:s,value:t[n],valueIndex:n,values:t,templateInstance:this}),s.strings!==void 0?(s._$setValue(t,s,n),n+=s.strings.length-2):s._$setValue(t[n])),n++}}let vn=class So{get _$isConnected(){return this._$parent?._$isConnected??this.__isConnected}constructor(t,n,s,i){this.type=cn,this._$committedValue=g,this._$disconnectableChildren=void 0,this._$startNode=t,this._$endNode=n,this._$parent=s,this.options=i,this.__isConnected=i?.isConnected??!0,this._textSanitizer=void 0}get parentNode(){let t=re(this._$startNode).parentNode;const n=this._$parent;return n!==void 0&&t?.nodeType===11&&(t=n.parentNode),t}get startNode(){return this._$startNode}get endNode(){return this._$endNode}_$setValue(t,n=this){if(this.parentNode===null)throw new Error("This `ChildPart` has no `parentNode` and therefore cannot accept a value. This likely means the element containing the part was manipulated in an unsupported way outside of Lit's control such that the part's marker nodes were ejected from DOM. For example, setting the element's `innerHTML` or `textContent` can do this.");if(t=rt(this,t,n),It(t))t===g||t==null||t===""?(this._$committedValue!==g&&(L&&L({kind:"commit nothing to child",start:this._$startNode,end:this._$endNode,parent:this._$parent,options:this.options}),this._$clear()),this._$committedValue=g):t!==this._$committedValue&&t!==Ie&&this._commitText(t);else if(t._$litType$!==void 0)this._commitTemplateResult(t);else if(t.nodeType!==void 0){if(this.options?.host===t){this._commitText("[probable mistake: rendered a template's host in itself (commonly caused by writing ${this} in a template]"),console.warn("Attempted to render the template host",t,"inside itself. This is almost always a mistake, and in dev mode ","we render some warning text. In production however, we'll ","render it, which will usually result in an error, and sometimes ","in the element disappearing from the DOM.");return}this._commitNode(t)}else Rl(t)?this._commitIterable(t):this._commitText(t)}_insert(t){return re(re(this._$startNode).parentNode).insertBefore(t,this._$endNode)}_commitNode(t){if(this._$committedValue!==t){if(this._$clear(),je!==mn){const n=this._$startNode.parentNode?.nodeName;if(n==="STYLE"||n==="SCRIPT"){let s="Forbidden";throw n==="STYLE"?s="Lit does not support binding inside style nodes. This is a security risk, as style injection attacks can exfiltrate data and spoof UIs. Consider instead using css`...` literals to compose styles, and do dynamic styling with css custom properties, ::parts, <slot>s, and by mutating the DOM rather than stylesheets.":s="Lit does not support binding inside script nodes. This is a security risk, as it could allow arbitrary code execution.",new Error(s)}}L&&L({kind:"commit node",start:this._$startNode,parent:this._$parent,value:t,options:this.options}),this._$committedValue=this._insert(t)}}_commitText(t){if(this._$committedValue!==g&&It(this._$committedValue)){const n=re(this._$startNode).nextSibling;this._textSanitizer===void 0&&(this._textSanitizer=$s(n,"data","property")),t=this._textSanitizer(t),L&&L({kind:"commit text",node:n,value:t,options:this.options}),n.data=t}else{const n=He.createTextNode("");this._commitNode(n),this._textSanitizer===void 0&&(this._textSanitizer=$s(n,"data","property")),t=this._textSanitizer(t),L&&L({kind:"commit text",node:n,value:t,options:this.options}),n.data=t}this._$committedValue=t}_commitTemplateResult(t){const{values:n,["_$litType$"]:s}=t,i=typeof s=="number"?this._$getTemplate(t):(s.el===void 0&&(s.el=Lt.createElement(ko(s.h,s.h[0]),this.options)),s);if(this._$committedValue?._$template===i)L&&L({kind:"template updating",template:i,instance:this._$committedValue,parts:this._$committedValue._$parts,options:this.options,values:n}),this._$committedValue._update(n);else{const a=new Hl(i,this),o=a._clone(this.options);L&&L({kind:"template instantiated",template:i,instance:a,parts:a._$parts,options:this.options,fragment:o,values:n}),a._update(n),L&&L({kind:"template instantiated and updated",template:i,instance:a,parts:a._$parts,options:this.options,fragment:o,values:n}),this._commitNode(o),this._$committedValue=a}}_$getTemplate(t){let n=pa.get(t.strings);return n===void 0&&pa.set(t.strings,n=new Lt(t)),n}_commitIterable(t){Js(this._$committedValue)||(this._$committedValue=[],this._$clear());const n=this._$committedValue;let s=0,i;for(const a of t)s===n.length?n.push(i=new So(this._insert(Mt()),this._insert(Mt()),this,this.options)):i=n[s],i._$setValue(a),s++;s<n.length&&(this._$clear(i&&re(i._$endNode).nextSibling,s),n.length=s)}_$clear(t=re(this._$startNode).nextSibling,n){for(this._$notifyConnectionChanged?.(!1,!0,n);t!==this._$endNode;){const s=re(t).nextSibling;re(t).remove(),t=s}}setConnected(t){if(this._$parent===void 0)this.__isConnected=t,this._$notifyConnectionChanged?.(t);else throw new Error("part.setConnected() may only be called on a RootPart returned from render().")}};class yn{get tagName(){return this.element.tagName}get _$isConnected(){return this._$parent._$isConnected}constructor(t,n,s,i,a){this.type=Zs,this._$committedValue=g,this._$disconnectableChildren=void 0,this.element=t,this.name=n,this._$parent=i,this.options=a,s.length>2||s[0]!==""||s[1]!==""?(this._$committedValue=new Array(s.length-1).fill(new String),this.strings=s):this._$committedValue=g,this._sanitizer=void 0}_$setValue(t,n=this,s,i){const a=this.strings;let o=!1;if(a===void 0)t=rt(this,t,n,0),o=!It(t)||t!==this._$committedValue&&t!==Ie,o&&(this._$committedValue=t);else{const c=t;t=a[0];let l,u;for(l=0;l<a.length-1;l++)u=rt(this,c[s+l],n,l),u===Ie&&(u=this._$committedValue[l]),o||=!It(u)||u!==this._$committedValue[l],u===g?t=g:t!==g&&(t+=(u??"")+a[l+1]),this._$committedValue[l]=u}o&&!i&&this._commitValue(t)}_commitValue(t){t===g?re(this.element).removeAttribute(this.name):(this._sanitizer===void 0&&(this._sanitizer=je(this.element,this.name,"attribute")),t=this._sanitizer(t??""),L&&L({kind:"commit attribute",element:this.element,name:this.name,value:t,options:this.options}),re(this.element).setAttribute(this.name,t??""))}}class jl extends yn{constructor(){super(...arguments),this.type=Dl}_commitValue(t){this._sanitizer===void 0&&(this._sanitizer=je(this.element,this.name,"property")),t=this._sanitizer(t),L&&L({kind:"commit property",element:this.element,name:this.name,value:t,options:this.options}),this.element[this.name]=t===g?void 0:t}}class Vl extends yn{constructor(){super(...arguments),this.type=Bl}_commitValue(t){L&&L({kind:"commit boolean attribute",element:this.element,name:this.name,value:!!(t&&t!==g),options:this.options}),re(this.element).toggleAttribute(this.name,!!t&&t!==g)}}class Wl extends yn{constructor(t,n,s,i,a){if(super(t,n,s,i,a),this.type=Fl,this.strings!==void 0)throw new Error(`A \`<${t.localName}>\` has a \`@${n}=...\` listener with invalid content. Event listeners in templates must have exactly one expression and no surrounding text.`)}_$setValue(t,n=this){if(t=rt(this,t,n,0)??g,t===Ie)return;const s=this._$committedValue,i=t===g&&s!==g||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,a=t!==g&&(s===g||i);L&&L({kind:"commit event listener",element:this.element,name:this.name,value:t,options:this.options,removeListener:i,addListener:a,oldListener:s}),i&&this.element.removeEventListener(this.name,this,s),a&&this.element.addEventListener(this.name,this,t),this._$committedValue=t}handleEvent(t){typeof this._$committedValue=="function"?this._$committedValue.call(this.options?.host??this.element,t):this._$committedValue.handleEvent(t)}}class ql{constructor(t,n,s){this.element=t,this.type=Xs,this._$disconnectableChildren=void 0,this._$parent=n,this.options=s}get _$isConnected(){return this._$parent._$isConnected}_$setValue(t){L&&L({kind:"commit to element binding",element:this.element,value:t,options:this.options}),rt(this,t)}}const Gl={_ChildPart:vn},Yl=te.litHtmlPolyfillSupportDevMode;Yl?.(Lt,vn);(te.litHtmlVersions??=[]).push("3.3.2");te.litHtmlVersions.length>1&&queueMicrotask(()=>{Rt("multiple-versions","Multiple versions of Lit loaded. Loading multiple versions is not recommended.")});const sn=(e,t,n)=>{if(t==null)throw new TypeError(`The container to render into may not be ${t}`);const s=Al++,i=n?.renderBefore??t;let a=i._$litPart$;if(L&&L({kind:"begin render",id:s,value:e,container:t,options:n,part:a}),a===void 0){const o=n?.renderBefore??null;i._$litPart$=a=new vn(t.insertBefore(Mt(),o),o,void 0,n??{})}return a._$setValue(e),L&&L({kind:"end render",id:s,value:e,container:t,options:n,part:a}),a};sn.setSanitizer=Tl,sn.createSanitizer=$s,sn._testOnlyClearSanitizerFactoryDoNotCallOrElse=Cl;const Ql=(e,t)=>e,Ee=globalThis;let Ao;Ee.litIssuedWarnings??=new Set,Ao=(e,t)=>{t+=` See https://lit.dev/msg/${e} for more information.`,!Ee.litIssuedWarnings.has(t)&&!Ee.litIssuedWarnings.has(e)&&(console.warn(t),Ee.litIssuedWarnings.add(t))};class pt extends Se{constructor(){super(...arguments),this.renderOptions={host:this},this.__childPart=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this.__childPart=sn(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this.__childPart?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this.__childPart?.setConnected(!1)}render(){return Ie}}pt._$litElement$=!0;pt[Ql("finalized")]=!0;Ee.litElementHydrateSupport?.({LitElement:pt});const Jl=Ee.litElementPolyfillSupportDevMode;Jl?.({LitElement:pt});(Ee.litElementVersions??=[]).push("4.2.2");Ee.litElementVersions.length>1&&queueMicrotask(()=>{Ao("multiple-versions","Multiple versions of Lit loaded. Loading multiple versions is not recommended.")});const _o=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};let To;globalThis.litIssuedWarnings??=new Set,To=(e,t)=>{t+=` See https://lit.dev/msg/${e} for more information.`,!globalThis.litIssuedWarnings.has(t)&&!globalThis.litIssuedWarnings.has(e)&&(console.warn(t),globalThis.litIssuedWarnings.add(t))};const Zl=(e,t,n)=>{const s=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),s?Object.getOwnPropertyDescriptor(t,n):void 0},Xl={attribute:!0,type:String,converter:rn,reflect:!1,hasChanged:Qs},ec=(e=Xl,t,n)=>{const{kind:s,metadata:i}=n;i==null&&To("missing-class-metadata",`The class ${t} is missing decorator metadata. This could mean that you're using a compiler that supports decorators but doesn't support decorator metadata, such as TypeScript 5.1. Please update your compiler.`);let a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),s==="setter"&&(e=Object.create(e),e.wrapped=!0),a.set(n.name,e),s==="accessor"){const{name:o}=n;return{set(c){const l=t.get.call(this);t.set.call(this,c),this.requestUpdate(o,l,e,!0,c)},init(c){return c!==void 0&&this._$changeProperty(o,void 0,e,c),c}}}else if(s==="setter"){const{name:o}=n;return function(c){const l=this[o];t.call(this,c),this.requestUpdate(o,l,e,!0,c)}}throw new Error(`Unsupported decorator location: ${s}`)};function bn(e){return(t,n)=>typeof n=="object"?ec(e,t,n):Zl(e,t,n)}function w(e){return bn({...e,state:!0,attribute:!1})}globalThis.litIssuedWarnings??=new Set;const tc=50,nc=200,sc="Assistant";function ha(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function Ss(e){const t=ha(e?.name,tc)??sc,n=ha(e?.avatar??void 0,nc)??null;return{agentId:typeof e?.agentId=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function ic(){return Ss(typeof window>"u"?{}:{name:window.__CLAWDBOT_ASSISTANT_NAME__,avatar:window.__CLAWDBOT_ASSISTANT_AVATAR__})}const Co="poolbot.control.settings.v1";function ac(){const t={gatewayUrl:`${location.protocol==="https:"?"wss":"ws"}://${location.host}`,token:"",sessionKey:"main",lastActiveSessionKey:"main",theme:"system",chatFocusMode:!1,chatShowThinking:!0,splitRatio:.6,navCollapsed:!1,navGroupsCollapsed:{},personality:"default",skin:"default"};try{const n=localStorage.getItem(Co);if(!n)return t;const s=JSON.parse(n);return{gatewayUrl:typeof s.gatewayUrl=="string"&&s.gatewayUrl.trim()?s.gatewayUrl.trim():t.gatewayUrl,token:typeof s.token=="string"?s.token:t.token,sessionKey:typeof s.sessionKey=="string"&&s.sessionKey.trim()?s.sessionKey.trim():t.sessionKey,lastActiveSessionKey:typeof s.lastActiveSessionKey=="string"&&s.lastActiveSessionKey.trim()?s.lastActiveSessionKey.trim():typeof s.sessionKey=="string"&&s.sessionKey.trim()||t.lastActiveSessionKey,theme:s.theme==="light"||s.theme==="dark"||s.theme==="system"?s.theme:t.theme,chatFocusMode:typeof s.chatFocusMode=="boolean"?s.chatFocusMode:t.chatFocusMode,chatShowThinking:typeof s.chatShowThinking=="boolean"?s.chatShowThinking:t.chatShowThinking,splitRatio:typeof s.splitRatio=="number"&&s.splitRatio>=.4&&s.splitRatio<=.7?s.splitRatio:t.splitRatio,navCollapsed:typeof s.navCollapsed=="boolean"?s.navCollapsed:t.navCollapsed,navGroupsCollapsed:typeof s.navGroupsCollapsed=="object"&&s.navGroupsCollapsed!==null?s.navGroupsCollapsed:t.navGroupsCollapsed,personality:typeof s.personality=="string"&&s.personality.trim()?s.personality.trim():t.personality,skin:typeof s.skin=="string"&&s.skin.trim()?s.skin.trim():t.skin}}catch{return t}}function oc(e){localStorage.setItem(Co,JSON.stringify(e))}function Eo(e){const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const s=n[1]?.trim(),i=n.slice(2).join(":");return!s||!i?null:{agentId:s,rest:i}}const rc=[{label:"Chat",tabs:["chat"]},{label:"Control",tabs:["overview","channels","instances","sessions","cron"]},{label:"Agent",tabs:["skills","nodes"]},{label:"Insights",tabs:["usage"]},{label:"Settings",tabs:["config","debug","logs"]}],Ro={overview:"/overview",channels:"/channels",instances:"/instances",sessions:"/sessions",cron:"/cron",skills:"/skills",nodes:"/nodes",usage:"/usage",chat:"/chat",config:"/config",debug:"/debug",logs:"/logs"},Mo=new Map(Object.entries(Ro).map(([e,t])=>[t,e]));function wn(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function Pt(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 $n(e,t=""){const n=wn(t),s=Ro[e];return n?`${n}${s}`:s}function Io(e,t=""){const n=wn(t);let s=e||"/";n&&(s===n?s="/":s.startsWith(`${n}/`)&&(s=s.slice(n.length)));let i=Pt(s).toLowerCase();return i.endsWith("/index.html")&&(i="/"),i==="/"?"chat":Mo.get(i)??null}function lc(e){let t=Pt(e);if(t.endsWith("/index.html")&&(t=Pt(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let s=0;s<n.length;s++){const i=`/${n.slice(s).join("/")}`.toLowerCase();if(Mo.has(i)){const a=n.slice(0,s);return a.length?`/${a.join("/")}`:""}}return`/${n.join("/")}`}function cc(e){switch(e){case"chat":return"messageSquare";case"overview":return"barChart";case"channels":return"link";case"instances":return"radio";case"sessions":return"fileText";case"cron":return"loader";case"skills":return"zap";case"nodes":return"monitor";case"usage":return"barChart";case"config":return"settings";case"debug":return"bug";case"logs":return"scrollText";default:return"folder"}}function As(e){switch(e){case"overview":return"Overview";case"channels":return"Channels";case"instances":return"Instances";case"sessions":return"Sessions";case"cron":return"Cron Jobs";case"skills":return"Skills";case"nodes":return"Nodes";case"usage":return"Usage & Costs";case"chat":return"Chat";case"config":return"Config";case"debug":return"Debug";case"logs":return"Logs";default:return"Control"}}function dc(e){switch(e){case"overview":return"Gateway status, entry points, and a fast health read.";case"channels":return"Manage channels and settings.";case"instances":return"Presence beacons from connected clients and nodes.";case"sessions":return"Inspect active sessions and adjust per-session defaults.";case"cron":return"Schedule wakeups and recurring agent runs.";case"skills":return"Manage skill availability and API key injection.";case"nodes":return"Paired devices, capabilities, and command exposure.";case"usage":return"Token usage, cost breakdown, and session analytics.";case"chat":return"Direct gateway chat session for quick interventions.";case"config":return"Edit ~/.poolbot/poolbot.json safely.";case"debug":return"Gateway snapshots, events, and manual RPC calls.";case"logs":return"Live tail of the gateway file logs.";default:return""}}const G={messageSquare:r`<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:r`<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:r`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,radio:r`<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:r`<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:r`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:r`<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:r`<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:r`<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:r`<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:r`<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>`,menu:r`<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:r`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:r`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:r`<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:r`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:r`<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:r`<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:r`<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>`,wrench:r`<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:r`<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:r`<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:r`<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:r`<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:r`<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>`,eye:r`<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:r`<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>`,image:r`<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:r`<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>`,shield:r`<svg viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/><path d="m9 12 2 2 4-4"/></svg>`,plug:r`<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:r`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,puzzle:r`<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>`},uc=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,Gt=/<\s*\/?\s*final\b[^<>]*>/gi,fa=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^<>]*>/gi;function ga(e){const t=[],n=/(^|\n)(```|~~~)[^\n]*\n[\s\S]*?(?:\n\2(?:\n|$)|$)/g;for(const i of e.matchAll(n)){const a=(i.index??0)+i[1].length;t.push({start:a,end:a+i[0].length-i[1].length})}const s=/`+[^`]+`+/g;for(const i of e.matchAll(s)){const a=i.index??0,o=a+i[0].length;t.some(l=>a>=l.start&&o<=l.end)||t.push({start:a,end:o})}return t.sort((i,a)=>i.start-a.start),t}function ma(e,t){return t.some(n=>e>=n.start&&e<n.end)}function pc(e,t){return e.trimStart()}function hc(e,t){if(!e||!uc.test(e))return e;let n=e;if(Gt.test(n)){Gt.lastIndex=0;const c=[],l=ga(n);for(const u of n.matchAll(Gt)){const d=u.index??0;c.push({start:d,length:u[0].length,inCode:ma(d,l)})}for(let u=c.length-1;u>=0;u--){const d=c[u];d.inCode||(n=n.slice(0,d.start)+n.slice(d.start+d.length))}}else Gt.lastIndex=0;const s=ga(n);fa.lastIndex=0;let i="",a=0,o=!1;for(const c of n.matchAll(fa)){const l=c.index??0,u=c[1]==="/";ma(l,s)||(o?u&&(o=!1):(i+=n.slice(a,l),u||(o=!0)),a=l+c[0].length)}return i+=n.slice(a),pc(i)}function Nt(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString()}function D(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0)return"just now";const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const s=Math.round(n/60);if(s<60)return`${s}m ago`;const i=Math.round(s/60);return i<48?`${i}h ago`:`${Math.round(i/24)}d ago`}const xn=D;function fc(e){if(!e&&e!==0)return"n/a";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const s=Math.round(n/60);return s<48?`${s}h`:`${Math.round(s/24)}d`}function _s(e){return!e||e.length===0?"none":e.filter(t=>!!(t&&t.trim())).join(", ")}function Ts(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Lo(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 dn(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function ns(e){return hc(e)}const gc=/^\[([^\]]+)\]\s*/,mc=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],ss=new WeakMap,is=new WeakMap;function vc(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:mc.some(t=>e.startsWith(`${t} `))}function as(e){const t=e.match(gc);if(!t)return e;const n=t[1]??"";return vc(n)?e.slice(t[0].length):e}function Cs(e){const t=e,n=typeof t.role=="string"?t.role:"",s=t.content;if(typeof s=="string")return n==="assistant"?ns(s):as(s);if(Array.isArray(s)){const i=s.map(a=>{const o=a;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(a=>typeof a=="string");if(i.length>0){const a=i.join(`
|
|
17
|
+
`);return n==="assistant"?ns(a):as(a)}}return typeof t.text=="string"?n==="assistant"?ns(t.text):as(t.text):null}function Po(e){if(!e||typeof e!="object")return Cs(e);const t=e;if(ss.has(t))return ss.get(t)??null;const n=Cs(e);return ss.set(t,n),n}function va(e){const n=e.content,s=[];if(Array.isArray(n))for(const c of n){const l=c;if(l.type==="thinking"&&typeof l.thinking=="string"){const u=l.thinking.trim();u&&s.push(u)}}if(s.length>0)return s.join(`
|
|
18
|
+
`);const i=bc(e);if(!i)return null;const o=[...i.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(c=>(c[1]??"").trim()).filter(Boolean);return o.length>0?o.join(`
|
|
19
|
+
`):null}function yc(e){if(!e||typeof e!="object")return va(e);const t=e;if(is.has(t))return is.get(t)??null;const n=va(e);return is.set(t,n),n}function bc(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const s=n.map(i=>{const a=i;return a.type==="text"&&typeof a.text=="string"?a.text:null}).filter(i=>typeof i=="string");if(s.length>0)return s.join(`
|
|
20
|
+
`)}return typeof t.text=="string"?t.text:null}function wc(e){const t=e.trim();if(!t)return"";const n=t.split(/\r?\n/).map(s=>s.trim()).filter(Boolean).map(s=>`_${s}_`);return n.length?["_Reasoning:_",...n].join(`
|
|
21
|
+
`):""}let ya=!1;function ba(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 $c(){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 xc(){ya||(ya=!0,console.warn("[uuid] crypto API missing; falling back to weak randomness"))}function ei(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),ba(t)}return xc(),ba($c())}async function lt(e){if(!(!e.client||!e.connected)){e.chatLoading=!0,e.lastError=null;try{const t=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:200});e.chatMessages=Array.isArray(t.messages)?t.messages:[],e.chatThinkingLevel=t.thinkingLevel??null}catch(t){e.lastError=String(t)}finally{e.chatLoading=!1}}}function kc(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function Sc(e,t,n){if(!e.client||!e.connected)return!1;const s=t.trim(),i=n&&n.length>0;if(!s&&!i)return!1;const a=Date.now(),o=[];if(s&&o.push({type:"text",text:s}),i)for(const u of n)o.push({type:"image",source:{type:"base64",media_type:u.mimeType,data:u.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:o,timestamp:a}],e.chatSending=!0,e.lastError=null;const c=ei();e.chatRunId=c,e.chatStream="",e.chatStreamStartedAt=a;const l=i?n.map(u=>{const d=kc(u.dataUrl);return d?{type:"image",mimeType:d.mimeType,content:d.content}:null}).filter(u=>u!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:s,deliver:!1,idempotencyKey:c,attachments:l}),!0}catch(u){const d=String(u);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=d,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+d}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function Ac(e){if(!e.client||!e.connected)return!1;const t=e.chatRunId;try{return await e.client.request("chat.abort",t?{sessionKey:e.sessionKey,runId:t}:{sessionKey:e.sessionKey}),!0}catch(n){return e.lastError=String(n),!1}}function _c(e,t){if(!t||t.sessionKey!==e.sessionKey)return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId)return t.state==="final"?"final":null;if(t.state==="delta"){const n=Cs(t.message);if(typeof n=="string"){const s=e.chatStream??"";(!s||n.length>=s.length)&&(e.chatStream=n)}}else t.state==="final"||t.state==="aborted"?(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null):t.state==="error"&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.lastError=t.errorMessage??"chat error");return t.state}async function ht(e){if(!(!e.client||!e.connected)&&!e.sessionsLoading){e.sessionsLoading=!0,e.sessionsError=null;try{const t={includeGlobal:e.sessionsIncludeGlobal,includeUnknown:e.sessionsIncludeUnknown},n=dn(e.sessionsFilterActive,0),s=dn(e.sessionsFilterLimit,0);n>0&&(t.activeMinutes=n),s>0&&(t.limit=s);const i=await e.client.request("sessions.list",t);i&&(e.sessionsResult=i)}catch(t){e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}async function Tc(e,t,n){if(!e.client||!e.connected)return;const s={key:t};"label"in n&&(s.label=n.label),"thinkingLevel"in n&&(s.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(s.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(s.reasoningLevel=n.reasoningLevel);try{await e.client.request("sessions.patch",s),await ht(e)}catch(i){e.sessionsError=String(i)}}async function Cc(e,t){if(!(!e.client||!e.connected||e.sessionsLoading||!window.confirm(`Delete session "${t}"?
|
|
22
22
|
|
|
23
|
-
Deletes the session entry and archives its transcript.`))){e.sessionsLoading=!0,e.sessionsError=null;try{await e.client.request("sessions.delete",{key:t,deleteTranscript:!0}),await ht(e)}catch(s){e.sessionsError=String(s)}finally{e.sessionsLoading=!1}}}const
|
|
24
|
-
`)}function
|
|
23
|
+
Deletes the session entry and archives its transcript.`))){e.sessionsLoading=!0,e.sessionsError=null;try{await e.client.request("sessions.delete",{key:t,deleteTranscript:!0}),await ht(e)}catch(s){e.sessionsError=String(s)}finally{e.sessionsLoading=!1}}}const wa=50,Ec=80,Rc=12e4;function Mc(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.text=="string")return t.text;const n=t.content;if(!Array.isArray(n))return null;const s=n.map(i=>{if(!i||typeof i!="object")return null;const a=i;return a.type==="text"&&typeof a.text=="string"?a.text:null}).filter(i=>!!i);return s.length===0?null:s.join(`
|
|
24
|
+
`)}function $a(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Mc(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}const s=Lo(n,Rc);return s.truncated?`${s.text}
|
|
25
25
|
|
|
26
|
-
… truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function
|
|
26
|
+
… truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function Ic(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 Lc(e){if(e.toolStreamOrder.length<=wa)return;const t=e.toolStreamOrder.length-wa,n=e.toolStreamOrder.splice(0,t);for(const s of n)e.toolStreamById.delete(s)}function Pc(e){e.chatToolMessages=e.toolStreamOrder.map(t=>e.toolStreamById.get(t)?.message).filter(t=>!!t)}function Es(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),Pc(e)}function Nc(e,t=!1){if(t){Es(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>Es(e),Ec))}function kn(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],Es(e)}const Oc=5e3;function Dc(e,t){const n=t.data??{},s=typeof n.phase=="string"?n.phase:"";e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),s==="start"?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:s==="end"&&(e.compactionStatus={active:!1,startedAt:e.compactionStatus?.startedAt??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},Oc))}function Bc(e,t){if(!t)return;if(t.stream==="compaction"){Dc(e,t);return}if(t.stream!=="tool")return;const n=typeof t.sessionKey=="string"?t.sessionKey:void 0;if(n&&n!==e.sessionKey||!n&&e.chatRunId&&t.runId!==e.chatRunId||e.chatRunId&&t.runId!==e.chatRunId||!e.chatRunId)return;const s=t.data??{},i=typeof s.toolCallId=="string"?s.toolCallId:"";if(!i)return;const a=typeof s.name=="string"?s.name:"tool",o=typeof s.phase=="string"?s.phase:"",c=o==="start"?s.args:void 0,l=o==="update"?$a(s.partialResult):o==="result"?$a(s.result):void 0,u=Date.now();let d=e.toolStreamById.get(i);d?(d.name=a,c!==void 0&&(d.args=c),l!==void 0&&(d.output=l),d.updatedAt=u):(d={toolCallId:i,runId:t.runId,sessionKey:n,name:a,args:c,output:l,startedAt:typeof t.ts=="number"?t.ts:u,updatedAt:u,message:{}},e.toolStreamById.set(i,d),e.toolStreamOrder.push(i)),d.message=Ic(d),Lc(e),Nc(e,o==="result")}function Sn(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=()=>{const s=e.querySelector(".chat-thread");if(s){const i=getComputedStyle(s).overflowY;if(i==="auto"||i==="scroll"||s.scrollHeight-s.clientHeight>1)return s}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{e.chatScrollFrame=requestAnimationFrame(()=>{e.chatScrollFrame=null;const s=n();if(!s)return;const i=s.scrollHeight-s.scrollTop-s.clientHeight;if(!(t||e.chatUserNearBottom||i<200))return;t&&(e.chatHasAutoScrolled=!0),s.scrollTop=s.scrollHeight,e.chatUserNearBottom=!0;const o=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{e.chatScrollTimeout=null;const c=n();if(!c)return;const l=c.scrollHeight-c.scrollTop-c.clientHeight;(t||e.chatUserNearBottom||l<200)&&(c.scrollTop=c.scrollHeight,e.chatUserNearBottom=!0)},o)})})}function No(e,t=!1){e.logsScrollFrame&&cancelAnimationFrame(e.logsScrollFrame),e.updateComplete.then(()=>{e.logsScrollFrame=requestAnimationFrame(()=>{e.logsScrollFrame=null;const n=e.querySelector(".log-stream");if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;(t||s<80)&&(n.scrollTop=n.scrollHeight)})})}function Fc(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=s<200}function Uc(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.logsAtBottom=s<80}function Kc(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function zc(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
|
|
27
27
|
`)}
|
|
28
|
-
`],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),a=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`poolbot-logs-${t}-${a}.log`,i.click(),URL.revokeObjectURL(s)}function
|
|
29
|
-
`}function Po(e,t,n){if(t.length===0)return;let s=e;for(let a=0;a<t.length-1;a+=1){const o=t[a],c=t[a+1];if(typeof o=="number"){if(!Array.isArray(s))return;s[o]==null&&(s[o]=typeof c=="number"?[]:{}),s=s[o]}else{if(typeof s!="object"||s==null)return;const r=s;r[o]==null&&(r[o]=typeof c=="number"?[]:{}),s=r[o]}}const i=t[t.length-1];if(typeof i=="number"){Array.isArray(s)&&(s[i]=n);return}typeof s=="object"&&s!=null&&(s[i]=n)}function No(e,t){if(t.length===0)return;let n=e;for(let i=0;i<t.length-1;i+=1){const a=t[i];if(typeof a=="number"){if(!Array.isArray(n))return;n=n[a]}else{if(typeof n!="object"||n==null)return;n=n[a]}if(n==null)return}const s=t[t.length-1];if(typeof s=="number"){Array.isArray(n)&&n.splice(s,1);return}typeof n=="object"&&n!=null&&delete n[s]}async function Ae(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});Kc(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function Oo(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});Uc(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function Uc(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function Kc(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?ct(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=ct(e.configForm):e.configRaw=n,e.configValid=typeof t.valid=="boolean"?t.valid:null,e.configIssues=Array.isArray(t.issues)?t.issues:[],e.configFormDirty||(e.configForm=Ve(t.config??{}),e.configFormOriginal=Ve(t.config??{}),e.configRawOriginal=n)}async function Es(e){if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?ct(e.configForm):e.configRaw,n=e.configSnapshot?.hash;if(!n){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:t,baseHash:n}),e.configFormDirty=!1,await Ae(e)}catch(t){e.lastError=String(t)}finally{e.configSaving=!1}}}async function zc(e){if(!(!e.client||!e.connected)){e.configApplying=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?ct(e.configForm):e.configRaw,n=e.configSnapshot?.hash;if(!n){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.apply",{raw:t,baseHash:n,sessionKey:e.applySessionKey}),e.configFormDirty=!1,await Ae(e)}catch(t){e.lastError=String(t)}finally{e.configApplying=!1}}}async function Hc(e){if(!(!e.client||!e.connected)){e.updateRunning=!0,e.lastError=null;try{await e.client.request("update.run",{sessionKey:e.applySessionKey})}catch(t){e.lastError=String(t)}finally{e.updateRunning=!1}}}function Yt(e,t,n){const s=Ve(e.configForm??e.configSnapshot?.config??{});Po(s,t,n),e.configForm=s,e.configFormDirty=!0,e.configFormMode==="form"&&(e.configRaw=ct(s))}function $a(e,t){const n=Ve(e.configForm??e.configSnapshot?.config??{});No(n,t),e.configForm=n,e.configFormDirty=!0,e.configFormMode==="form"&&(e.configRaw=ct(n))}async function Bt(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 An(e){if(!(!e.client||!e.connected)&&!e.cronLoading){e.cronLoading=!0,e.cronError=null;try{const t=await e.client.request("cron.list",{includeDisabled:!0});e.cronJobs=Array.isArray(t.jobs)?t.jobs:[]}catch(t){e.cronError=String(t)}finally{e.cronLoading=!1}}}function jc(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=dn(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const s=e.everyUnit;return{kind:"every",everyMs:n*(s==="minutes"?6e4:s==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function Vc(e){if(e.payloadKind==="systemEvent"){const i=e.payloadText.trim();if(!i)throw new Error("System event text required.");return{kind:"systemEvent",text:i}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel),e.to.trim()&&(n.to=e.to.trim());const s=dn(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function Wc(e){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const t=jc(e.cronForm),n=Vc(e.cronForm),s=e.cronForm.agentId.trim(),i={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,enabled:e.cronForm.enabled,schedule:t,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:n,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!i.name)throw new Error("Name required.");await e.client.request("cron.add",i),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await An(e),await Bt(e)}catch(t){e.cronError=String(t)}finally{e.cronBusy=!1}}}async function qc(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 An(e),await Bt(e)}catch(s){e.cronError=String(s)}finally{e.cronBusy=!1}}}async function Gc(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 Do(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Yc(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 An(e),await Bt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Do(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 ue(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 Qc(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const n=await e.client.request("web.login.start",{force:t,timeoutMs:3e4});e.whatsappLoginMessage=n.message??null,e.whatsappLoginQrDataUrl=n.qrDataUrl??null,e.whatsappLoginConnected=null}catch(n){e.whatsappLoginMessage=String(n),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function Jc(e){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const t=await e.client.request("web.login.wait",{timeoutMs:12e4});e.whatsappLoginMessage=t.message??null,e.whatsappLoginConnected=t.connected??null,t.connected&&(e.whatsappLoginQrDataUrl=null)}catch(t){e.whatsappLoginMessage=String(t),e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function Zc(e){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{await e.client.request("channels.logout",{channel:"whatsapp"}),e.whatsappLoginMessage="Logged out.",e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}catch(t){e.whatsappLoginMessage=String(t)}finally{e.whatsappBusy=!1}}}async function _n(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,s,i]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const a=s;e.debugModels=Array.isArray(a?.models)?a?.models:[],e.debugHeartbeat=i}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}async function Xc(e){if(!(!e.client||!e.connected)){e.debugCallError=null,e.debugCallResult=null;try{const t=e.debugCallParams.trim()?JSON.parse(e.debugCallParams):{},n=await e.client.request(e.debugCallMethod.trim(),t);e.debugCallResult=JSON.stringify(n,null,2)}catch(t){e.debugCallError=String(t)}}}const ed=2e3,td=new Set(["trace","debug","info","warn","error","fatal"]);function nd(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 sd(e){if(typeof e!="string")return null;const t=e.toLowerCase();return td.has(t)?t:null}function id(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,s=typeof t.time=="string"?t.time:typeof n?.date=="string"?n?.date:null,i=sd(n?.logLevelName??n?.level),a=typeof t[0]=="string"?t[0]:typeof n?.name=="string"?n?.name:null,o=nd(a);let c=null;o&&(typeof o.subsystem=="string"?c=o.subsystem:typeof o.module=="string"&&(c=o.module)),!c&&a&&a.length<120&&(c=a);let r=null;return typeof t[1]=="string"?r=t[1]:!o&&typeof t[0]=="string"?r=t[0]:typeof t.message=="string"&&(r=t.message),{raw:e,time:s,level:i,subsystem:c,message:r??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function ei(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!t?.quiet)){t?.quiet||(e.logsLoading=!0),e.logsError=null;try{const s=await e.client.request("logs.tail",{cursor:t?.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),a=(Array.isArray(s.lines)?s.lines.filter(c=>typeof c=="string"):[]).map(id),o=!!(t?.reset||s.reset||e.logsCursor==null);e.logsEntries=o?a:[...e.logsEntries,...a].slice(-ed),typeof s.cursor=="number"&&(e.logsCursor=s.cursor),typeof s.file=="string"&&(e.logsFile=s.file),e.logsTruncated=!!s.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t?.quiet||(e.logsLoading=!1)}}}const Bo={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:q,n:an,Gx:xa,Gy:ka,a:os,d:rs,h:ad}=Bo,We=32,ti=64,od=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},H=(e="")=>{const t=new Error(e);throw od(t,H),t},rd=e=>typeof e=="bigint",ld=e=>typeof e=="string",cd=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",Le=(e,t,n="")=>{const s=cd(e),i=e?.length,a=t!==void 0;if(!s||a&&i!==t){const o=n&&`"${n}" `,c=a?` of length ${t}`:"",r=s?`length=${i}`:`type=${typeof e}`;H(o+"expected Uint8Array"+c+", got "+r)}return e},Tn=e=>new Uint8Array(e),Fo=e=>Uint8Array.from(e),Uo=(e,t)=>e.toString(16).padStart(t,"0"),Ko=e=>Array.from(Le(e)).map(t=>Uo(t,2)).join(""),$e={_0:48,_9:57,A:65,F:70,a:97,f:102},Sa=e=>{if(e>=$e._0&&e<=$e._9)return e-$e._0;if(e>=$e.A&&e<=$e.F)return e-($e.A-10);if(e>=$e.a&&e<=$e.f)return e-($e.a-10)},zo=e=>{const t="hex invalid";if(!ld(e))return H(t);const n=e.length,s=n/2;if(n%2)return H(t);const i=Tn(s);for(let a=0,o=0;a<s;a++,o+=2){const c=Sa(e.charCodeAt(o)),r=Sa(e.charCodeAt(o+1));if(c===void 0||r===void 0)return H(t);i[a]=c*16+r}return i},Ho=()=>globalThis?.crypto,dd=()=>Ho()?.subtle??H("crypto.subtle must be defined, consider polyfill"),Ot=(...e)=>{const t=Tn(e.reduce((s,i)=>s+Le(i).length,0));let n=0;return e.forEach(s=>{t.set(s,n),n+=s.length}),t},ud=(e=We)=>Ho().getRandomValues(Tn(e)),un=BigInt,Ue=(e,t,n,s="bad number: out of range")=>rd(e)&&t<=e&&e<n?e:H(s),S=(e,t=q)=>{const n=e%t;return n>=0n?n:t+n},jo=e=>S(e,an),pd=(e,t)=>{(e===0n||t<=0n)&&H("no inverse n="+e+" mod="+t);let n=S(e,t),s=t,i=0n,a=1n;for(;n!==0n;){const o=s/n,c=s%n,r=i-a*o;s=n,n=c,i=a,a=r}return s===1n?S(i,t):H("no inverse")},hd=e=>{const t=Go[e];return typeof t!="function"&&H("hashes."+e+" not set"),t},ls=e=>e instanceof ne?e:H("Point expected"),Rs=2n**256n;class ne{static BASE;static ZERO;X;Y;Z;T;constructor(t,n,s,i){const a=Rs;this.X=Ue(t,0n,a),this.Y=Ue(n,0n,a),this.Z=Ue(s,1n,a),this.T=Ue(i,0n,a),Object.freeze(this)}static CURVE(){return Bo}static fromAffine(t){return new ne(t.x,t.y,1n,S(t.x*t.y))}static fromBytes(t,n=!1){const s=rs,i=Fo(Le(t,We)),a=t[31];i[31]=a&-129;const o=Wo(i);Ue(o,0n,n?Rs:q);const r=S(o*o),u=S(r-1n),d=S(s*r+1n);let{isValid:p,value:f}=gd(u,d);p||H("bad point: y not sqrt");const m=(f&1n)===1n,v=(a&128)!==0;return!n&&f===0n&&v&&H("bad point: x==0, isLastByteOdd"),v!==m&&(f=S(-f)),new ne(f,o,1n,S(f*o))}static fromHex(t,n){return ne.fromBytes(zo(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=os,n=rs,s=this;if(s.is0())return H("bad point: ZERO");const{X:i,Y:a,Z:o,T:c}=s,r=S(i*i),u=S(a*a),d=S(o*o),p=S(d*d),f=S(r*t),m=S(d*S(f+u)),v=S(p+S(n*S(r*u)));if(m!==v)return H("bad point: equation left != right (1)");const $=S(i*a),k=S(o*c);return $!==k?H("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:s,Z:i}=this,{X:a,Y:o,Z:c}=ls(t),r=S(n*c),u=S(a*i),d=S(s*c),p=S(o*i);return r===u&&d===p}is0(){return this.equals(at)}negate(){return new ne(S(-this.X),this.Y,this.Z,S(-this.T))}double(){const{X:t,Y:n,Z:s}=this,i=os,a=S(t*t),o=S(n*n),c=S(2n*S(s*s)),r=S(i*a),u=t+n,d=S(S(u*u)-a-o),p=r+o,f=p-c,m=r-o,v=S(d*f),$=S(p*m),k=S(d*m),_=S(f*p);return new ne(v,$,_,k)}add(t){const{X:n,Y:s,Z:i,T:a}=this,{X:o,Y:c,Z:r,T:u}=ls(t),d=os,p=rs,f=S(n*o),m=S(s*c),v=S(a*p*u),$=S(i*r),k=S((n+s)*(o+c)-f-m),_=S($-v),M=S($+v),N=S(m-d*f),R=S(k*_),C=S(M*N),E=S(k*N),ve=S(_*M);return new ne(R,C,ve,E)}subtract(t){return this.add(ls(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return at;if(Ue(t,1n,an),t===1n)return this;if(this.equals(qe))return _d(t).p;let s=at,i=qe;for(let a=this;t>0n;a=a.double(),t>>=1n)t&1n?s=s.add(a):n&&(i=i.add(a));return s}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:s}=this;if(this.equals(at))return{x:0n,y:1n};const i=pd(s,q);S(s*i)!==1n&&H("invalid inverse");const a=S(t*i),o=S(n*i);return{x:a,y:o}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),s=Vo(n);return s[31]|=t&1n?128:0,s}toHex(){return Ko(this.toBytes())}clearCofactor(){return this.multiply(un(ad),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(an/2n,!1).double();return an%2n&&(t=t.add(this)),t.is0()}}const qe=new ne(xa,ka,1n,S(xa*ka)),at=new ne(0n,1n,1n,0n);ne.BASE=qe;ne.ZERO=at;const Vo=e=>zo(Uo(Ue(e,0n,Rs),ti)).reverse(),Wo=e=>un("0x"+Ko(Fo(Le(e)).reverse())),fe=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=q;return n},fd=e=>{const n=e*e%q*e%q,s=fe(n,2n)*n%q,i=fe(s,1n)*e%q,a=fe(i,5n)*i%q,o=fe(a,10n)*a%q,c=fe(o,20n)*o%q,r=fe(c,40n)*c%q,u=fe(r,80n)*r%q,d=fe(u,80n)*r%q,p=fe(d,10n)*a%q;return{pow_p_5_8:fe(p,2n)*e%q,b2:n}},Aa=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,gd=(e,t)=>{const n=S(t*t*t),s=S(n*n*t),i=fd(e*s).pow_p_5_8;let a=S(e*n*i);const o=S(t*a*a),c=a,r=S(a*Aa),u=o===e,d=o===S(-e),p=o===S(-e*Aa);return u&&(a=c),(d||p)&&(a=r),(S(a)&1n)===1n&&(a=S(-a)),{isValid:u||d,value:a}},Ms=e=>jo(Wo(e)),ni=(...e)=>Go.sha512Async(Ot(...e)),md=(...e)=>hd("sha512")(Ot(...e)),qo=e=>{const t=e.slice(0,We);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(We,ti),s=Ms(t),i=qe.multiply(s),a=i.toBytes();return{head:t,prefix:n,scalar:s,point:i,pointBytes:a}},si=e=>ni(Le(e,We)).then(qo),vd=e=>qo(md(Le(e,We))),yd=e=>si(e).then(t=>t.pointBytes),bd=e=>ni(e.hashable).then(e.finish),wd=(e,t,n)=>{const{pointBytes:s,scalar:i}=e,a=Ms(t),o=qe.multiply(a).toBytes();return{hashable:Ot(o,s,n),finish:u=>{const d=jo(a+Ms(u)*i);return Le(Ot(o,Vo(d)),ti)}}},$d=async(e,t)=>{const n=Le(e),s=await si(t),i=await ni(s.prefix,n);return bd(wd(s,i,n))},Go={sha512Async:async e=>{const t=dd(),n=Ot(e);return Tn(await t.digest("SHA-512",n.buffer))},sha512:void 0},xd=(e=ud(We))=>e,kd={getExtendedPublicKeyAsync:si,getExtendedPublicKey:vd,randomSecretKey:xd},pn=8,Sd=256,Yo=Math.ceil(Sd/pn)+1,Is=2**(pn-1),Ad=()=>{const e=[];let t=qe,n=t;for(let s=0;s<Yo;s++){n=t,e.push(n);for(let i=1;i<Is;i++)n=n.add(t),e.push(n);t=n.double()}return e};let _a;const Ta=(e,t)=>{const n=t.negate();return e?n:t},_d=e=>{const t=_a||(_a=Ad());let n=at,s=qe;const i=2**pn,a=i,o=un(i-1),c=un(pn);for(let r=0;r<Yo;r++){let u=Number(e&o);e>>=c,u>Is&&(u-=a,e+=1n);const d=r*Is,p=d,f=d+Math.abs(u)-1,m=r%2!==0,v=u<0;u===0?s=s.add(Ta(m,t[p])):n=n.add(Ta(v,t[f]))}return e!==0n&&H("invalid wnaf"),{p:n,f:s}},cs="poolbot-device-identity-v1";function Ls(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replaceAll("+","-").replaceAll("/","_").replace(/=+$/g,"")}function Qo(e){const t=e.replaceAll("-","+").replaceAll("_","/"),n=t+"=".repeat((4-t.length%4)%4),s=atob(n),i=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)i[a]=s.charCodeAt(a);return i}function Td(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Jo(e){const t=await crypto.subtle.digest("SHA-256",e);return Td(new Uint8Array(t))}async function Cd(){const e=kd.randomSecretKey(),t=await yd(e);return{deviceId:await Jo(t),publicKey:Ls(t),privateKey:Ls(e)}}async function ii(){try{const n=localStorage.getItem(cs);if(n){const s=JSON.parse(n);if(s?.version===1&&typeof s.deviceId=="string"&&typeof s.publicKey=="string"&&typeof s.privateKey=="string"){const i=await Jo(Qo(s.publicKey));if(i!==s.deviceId){const a={...s,deviceId:i};return localStorage.setItem(cs,JSON.stringify(a)),{deviceId:i,publicKey:s.publicKey,privateKey:s.privateKey}}return{deviceId:s.deviceId,publicKey:s.publicKey,privateKey:s.privateKey}}}}catch{}const e=await Cd(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(cs,JSON.stringify(t)),e}async function Ed(e,t){const n=Qo(e),s=new TextEncoder().encode(t),i=await $d(s,n);return Ls(i)}const Zo="poolbot.device.auth.v1";function ai(e){return e.trim()}function Rd(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const s=n.trim();s&&t.add(s)}return[...t].sort()}function oi(){try{const e=window.localStorage.getItem(Zo);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 Xo(e){try{window.localStorage.setItem(Zo,JSON.stringify(e))}catch{}}function Md(e){const t=oi();if(!t||t.deviceId!==e.deviceId)return null;const n=ai(e.role),s=t.tokens[n];return!s||typeof s.token!="string"?null:s}function er(e){const t=ai(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},s=oi();s&&s.deviceId===e.deviceId&&(n.tokens={...s.tokens});const i={token:e.token,role:t,scopes:Rd(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=i,Xo(n),i}function tr(e){const t=oi();if(!t||t.deviceId!==e.deviceId)return;const n=ai(e.role);if(!t.tokens[n])return;const s={...t,tokens:{...t.tokens}};delete s.tokens[n],Xo(s)}async function Pe(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t?.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n?.pending)?n.pending:[],paired:Array.isArray(n?.paired)?n.paired:[]}}catch(n){t?.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function Id(e,t){if(!(!e.client||!e.connected))try{await e.client.request("device.pair.approve",{requestId:t}),await Pe(e)}catch(n){e.devicesError=String(n)}}async function Ld(e,t){if(!(!e.client||!e.connected||!window.confirm("Reject this device pairing request?")))try{await e.client.request("device.pair.reject",{requestId:t}),await Pe(e)}catch(s){e.devicesError=String(s)}}async function Pd(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("device.token.rotate",t);if(n?.token){const s=await ii(),i=n.role??t.role;(n.deviceId===s.deviceId||t.deviceId===s.deviceId)&&er({deviceId:s.deviceId,role:i,token:n.token,scopes:n.scopes??t.scopes??[]}),window.prompt("New device token (copy and store securely):",n.token)}await Pe(e)}catch(n){e.devicesError=String(n)}}async function Nd(e,t){if(!(!e.client||!e.connected||!window.confirm(`Revoke token for ${t.deviceId} (${t.role})?`)))try{await e.client.request("device.token.revoke",t);const s=await ii();t.deviceId===s.deviceId&&tr({deviceId:s.deviceId,role:t.role}),await Pe(e)}catch(s){e.devicesError=String(s)}}async function Cn(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,t?.quiet||(e.lastError=null);try{const n=await e.client.request("node.list",{});e.nodes=Array.isArray(n.nodes)?n.nodes:[]}catch(n){t?.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function Od(e){if(!e||e.kind==="gateway")return{method:"exec.approvals.get",params:{}};const t=e.nodeId.trim();return t?{method:"exec.approvals.node.get",params:{nodeId:t}}:null}function Dd(e,t){if(!e||e.kind==="gateway")return{method:"exec.approvals.set",params:t};const n=e.nodeId.trim();return n?{method:"exec.approvals.node.set",params:{...t,nodeId:n}}:null}async function ri(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=Od(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const s=await e.client.request(n.method,n.params);Bd(e,s)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function Bd(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=Ve(t.file??{}))}async function Fd(e,t){if(!(!e.client||!e.connected)){e.execApprovalsSaving=!0,e.lastError=null;try{const n=e.execApprovalsSnapshot?.hash;if(!n){e.lastError="Exec approvals hash missing; reload and retry.";return}const s=e.execApprovalsForm??e.execApprovalsSnapshot?.file??{},i=Dd(t,{file:s,baseHash:n});if(!i){e.lastError="Select a node before saving exec approvals.";return}await e.client.request(i.method,i.params),e.execApprovalsDirty=!1,await ri(e,t)}catch(n){e.lastError=String(n)}finally{e.execApprovalsSaving=!1}}}function Ud(e,t,n){const s=Ve(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});Po(s,t,n),e.execApprovalsForm=s,e.execApprovalsDirty=!0}function Kd(e,t){const n=Ve(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});No(n,t),e.execApprovalsForm=n,e.execApprovalsDirty=!0}async function li(e){if(!(!e.client||!e.connected)&&!e.presenceLoading){e.presenceLoading=!0,e.presenceError=null,e.presenceStatus=null;try{const t=await e.client.request("system-presence",{});Array.isArray(t)?(e.presenceEntries=t,e.presenceStatus=t.length===0?"No instances yet.":null):(e.presenceEntries=[],e.presenceStatus="No presence payload.")}catch(t){e.presenceError=String(t)}finally{e.presenceLoading=!1}}}function dt(e,t,n){if(!t.trim())return;const s={...e.skillMessages};n?s[t]=n:delete s[t],e.skillMessages=s}function En(e){return e instanceof Error?e.message:String(e)}async function Ft(e,t){if(t?.clearMessages&&Object.keys(e.skillMessages).length>0&&(e.skillMessages={}),!(!e.client||!e.connected)&&!e.skillsLoading){e.skillsLoading=!0,e.skillsError=null;try{const n=await e.client.request("skills.status",{});n&&(e.skillsReport=n)}catch(n){e.skillsError=En(n)}finally{e.skillsLoading=!1}}}function zd(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Hd(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 Ft(e),dt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(s){const i=En(s);e.skillsError=i,dt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function jd(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const n=e.skillEdits[t]??"";await e.client.request("skills.update",{skillKey:t,apiKey:n}),await Ft(e),dt(e,t,{kind:"success",message:"API key saved"})}catch(n){const s=En(n);e.skillsError=s,dt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Vd(e,t,n,s){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const i=await e.client.request("skills.install",{name:n,installId:s,timeoutMs:12e4});await Ft(e),dt(e,t,{kind:"success",message:i?.message??"Installed"})}catch(i){const a=En(i);e.skillsError=a,dt(e,t,{kind:"error",message:a})}finally{e.skillsBusyKey=null}}}function Wd(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function ci(e){return e==="system"?Wd():e}const Qt=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,qd=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Jt=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},Gd=({nextTheme:e,applyTheme:t,context:n,currentTheme:s})=>{if(s===e)return;const i=globalThis.document??null;if(!i){t();return}const a=i.documentElement,o=i,c=qd();if(!!o.startViewTransition&&!c){let u=.5,d=.5;if(n?.pointerClientX!==void 0&&n?.pointerClientY!==void 0&&typeof window<"u")u=Qt(n.pointerClientX/window.innerWidth),d=Qt(n.pointerClientY/window.innerHeight);else if(n?.element){const p=n.element.getBoundingClientRect();p.width>0&&p.height>0&&typeof window<"u"&&(u=Qt((p.left+p.width/2)/window.innerWidth),d=Qt((p.top+p.height/2)/window.innerHeight))}a.style.setProperty("--theme-switch-x",`${u*100}%`),a.style.setProperty("--theme-switch-y",`${d*100}%`),a.classList.add("theme-transition");try{const p=o.startViewTransition?.(()=>{t()});p?.finished?p.finished.finally(()=>Jt(a)):Jt(a)}catch{Jt(a),t()}return}t(),Jt(a)};function Yd(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{Cn(e,{quiet:!0})},5e3))}function Qd(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function di(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&ei(e,{quiet:!0})},2e3))}function ui(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function pi(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&_n(e)},3e3))}function hi(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Re(e,t){const n={...t,lastActiveSessionKey:t.lastActiveSessionKey?.trim()||t.sessionKey.trim()||"main"};e.settings=n,nc(n),t.theme!==e.theme&&(e.theme=t.theme,Rn(e,ci(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function nr(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&Re(e,{...e.settings,lastActiveSessionKey:n})}function Jd(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),s=t.get("password"),i=t.get("session"),a=t.get("gatewayUrl");let o=!1;if(n!=null){const r=n.trim();r&&r!==e.settings.token&&Re(e,{...e.settings,token:r}),t.delete("token"),o=!0}if(s!=null){const r=s.trim();r&&(e.password=r),t.delete("password"),o=!0}if(i!=null){const r=i.trim();r&&(e.sessionKey=r,Re(e,{...e.settings,sessionKey:r,lastActiveSessionKey:r}))}if(a!=null){const r=a.trim();r&&r!==e.settings.gatewayUrl&&Re(e,{...e.settings,gatewayUrl:r}),t.delete("gatewayUrl"),o=!0}if(!o)return;const c=new URL(window.location.href);c.search=t.toString(),window.history.replaceState({},"",c.toString())}function Zd(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?di(e):ui(e),t==="debug"?pi(e):hi(e),fi(e),ir(e,t,!1)}function Xd(e,t,n){Gd({nextTheme:t,applyTheme:()=>{e.theme=t,Re(e,{...e.settings,theme:t}),Rn(e,ci(t))},context:n,currentTheme:e.theme})}async function fi(e){e.tab==="overview"&&await ar(e),e.tab==="channels"&&await ru(e),e.tab==="instances"&&await li(e),e.tab==="sessions"&&await ht(e),e.tab==="cron"&&await gi(e),e.tab==="skills"&&await Ft(e),e.tab==="nodes"&&(await Cn(e),await Pe(e),await Ae(e),await ri(e)),e.tab==="chat"&&(await pu(e),Sn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await Oo(e),await Ae(e)),e.tab==="debug"&&(await _n(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"&&(e.logsAtBottom=!0,await ei(e,{reset:!0}),Lo(e,!0))}function eu(){if(typeof window>"u")return"";const e=window.__CLAWDBOT_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?wn(e):ic(window.location.pathname)}function tu(e){e.theme=e.settings.theme??"system",Rn(e,ci(e.theme))}function Rn(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function nu(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"&&Rn(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function su(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 iu(e,t){if(typeof window>"u")return;const n=Ro(window.location.pathname,e.basePath)??"chat";sr(e,n),ir(e,n,t)}function au(e){if(typeof window>"u")return;const t=Ro(window.location.pathname,e.basePath);if(!t)return;const s=new URL(window.location.href).searchParams.get("session")?.trim();s&&(e.sessionKey=s,Re(e,{...e.settings,sessionKey:s,lastActiveSessionKey:s})),sr(e,t)}function sr(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?di(e):ui(e),t==="debug"?pi(e):hi(e),e.connected&&fi(e)}function ir(e,t,n){if(typeof window>"u")return;const s=Pt($n(t,e.basePath)),i=Pt(window.location.pathname),a=new URL(window.location.href);t==="chat"&&e.sessionKey?a.searchParams.set("session",e.sessionKey):a.searchParams.delete("session"),i!==s&&(a.pathname=s),n?window.history.replaceState({},"",a.toString()):window.history.pushState({},"",a.toString())}function ou(e,t,n){if(typeof window>"u")return;const s=new URL(window.location.href);s.searchParams.set("session",t),window.history.replaceState({},"",s.toString())}async function ar(e){await Promise.all([ue(e,!1),li(e),ht(e),Bt(e),_n(e)])}async function ru(e){await Promise.all([ue(e,!0),Oo(e),Ae(e)])}async function gi(e){await Promise.all([ue(e,!1),Bt(e),An(e)])}function or(e){return e.chatSending||!!e.chatRunId}function lu(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 rr(e){e.connected&&(e.chatMessage="",await $c(e))}function cu(e,t,n){const s=t.trim(),i=!!(n&&n.length>0);!s&&!i||(e.chatQueue=[...e.chatQueue,{id:Xs(),text:s,createdAt:Date.now(),attachments:i?n?.map(a=>({...a})):void 0}])}async function lr(e,t,n){kn(e);const s=await wc(e,t,n?.attachments);return!s&&n?.previousDraft!=null&&(e.chatMessage=n.previousDraft),!s&&n?.previousAttachments&&(e.chatAttachments=n.previousAttachments),s&&nr(e,e.sessionKey),s&&n?.restoreDraft&&n.previousDraft?.trim()&&(e.chatMessage=n.previousDraft),s&&n?.restoreAttachments&&n.previousAttachments?.length&&(e.chatAttachments=n.previousAttachments),Sn(e),s&&!e.chatRunId&&cr(e),s}async function cr(e){if(!e.connected||or(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await lr(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function du(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function uu(e,t,n){if(!e.connected)return;const s=e.chatMessage,i=(t??e.chatMessage).trim(),a=e.chatAttachments??[],o=t==null?a:[],c=o.length>0;if(!(!i&&!c)){if(lu(i)){await rr(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),or(e)){cu(e,i,o);return}await lr(e,i,{previousDraft:t==null?s:void 0,restoreDraft:!!(t&&n?.restoreDraft),attachments:c?o:void 0,previousAttachments:t==null?a:void 0,restoreAttachments:!!(t&&n?.restoreDraft)})}}async function pu(e){await Promise.all([lt(e),ht(e),Ps(e)]),Sn(e,!0)}const hu=cr;function fu(e){const t=To(e.sessionKey);return t?.agentId?t.agentId:e.hello?.snapshot?.sessionDefaults?.defaultAgentId?.trim()||"main"}function gu(e,t){const n=wn(e),s=encodeURIComponent(t);return n?`${n}/avatar/${s}?meta=1`:`/avatar/${s}?meta=1`}async function Ps(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=fu(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=gu(e.basePath,t);try{const s=await fetch(n,{method:"GET"});if(!s.ok){e.chatAvatarUrl=null;return}const i=await s.json(),a=typeof i.avatarUrl=="string"?i.avatarUrl.trim():"";e.chatAvatarUrl=a||null}catch{e.chatAvatarUrl=null}}const dr={CHILD:2},ur=e=>(...t)=>({_$litDirective$:e,values:t});class pr{constructor(t){}get _$isConnected(){return this._$parent._$isConnected}_$initialize(t,n,s){this.__part=t,this._$parent=n,this.__attributeIndex=s}_$resolve(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}}const{_ChildPart:mu}=jl,st=window.ShadyDOM?.inUse&&window.ShadyDOM?.noPatch===!0?window.ShadyDOM.wrap:e=>e,Ca=()=>document.createComment(""),yt=(e,t,n)=>{const s=st(e._$startNode).parentNode,i=t===void 0?e._$endNode:t._$startNode;if(n===void 0){const a=st(s).insertBefore(Ca(),i),o=st(s).insertBefore(Ca(),i);n=new mu(a,o,e,e.options)}else{const a=st(n._$endNode).nextSibling,o=n._$parent,c=o!==e;if(c){n._$reparentDisconnectables?.(e),n._$parent=e;let r;n._$notifyConnectionChanged!==void 0&&(r=e._$isConnected)!==o._$isConnected&&n._$notifyConnectionChanged(r)}if(a!==i||c){let r=n._$startNode;for(;r!==a;){const u=st(r).nextSibling;st(s).insertBefore(r,i),r=u}}}return n},Be=(e,t,n=e)=>(e._$setValue(t,n),e),vu={},yu=(e,t=vu)=>e._$committedValue=t,bu=e=>e._$committedValue,ds=e=>{e._$clear(),e._$startNode.remove()};const Ea=(e,t,n)=>{const s=new Map;for(let i=t;i<=n;i++)s.set(e[i],i);return s};class wu extends pr{constructor(t){if(super(t),t.type!==dr.CHILD)throw new Error("repeat() can only be used in text expressions")}_getValuesAndKeys(t,n,s){let i;s===void 0?s=n:n!==void 0&&(i=n);const a=[],o=[];let c=0;for(const r of t)a[c]=i?i(r,c):c,o[c]=s(r,c),c++;return{values:o,keys:a}}render(t,n,s){return this._getValuesAndKeys(t,n,s).values}update(t,[n,s,i]){const a=bu(t),{values:o,keys:c}=this._getValuesAndKeys(n,s,i);if(!Array.isArray(a))return this._itemKeys=c,o;const r=this._itemKeys??=[],u=[];let d,p,f=0,m=a.length-1,v=0,$=o.length-1;for(;f<=m&&v<=$;)if(a[f]===null)f++;else if(a[m]===null)m--;else if(r[f]===c[v])u[v]=Be(a[f],o[v]),f++,v++;else if(r[m]===c[$])u[$]=Be(a[m],o[$]),m--,$--;else if(r[f]===c[$])u[$]=Be(a[f],o[$]),yt(t,u[$+1],a[f]),f++,$--;else if(r[m]===c[v])u[v]=Be(a[m],o[v]),yt(t,a[f],a[m]),m--,v++;else if(d===void 0&&(d=Ea(c,v,$),p=Ea(r,f,m)),!d.has(r[f]))ds(a[f]),f++;else if(!d.has(r[m]))ds(a[m]),m--;else{const k=p.get(c[v]),_=k!==void 0?a[k]:null;if(_===null){const M=yt(t,a[f]);Be(M,o[v]),u[v]=M}else u[v]=Be(_,o[v]),yt(t,a[f],_),a[k]=null;v++}for(;v<=$;){const k=yt(t,u[$+1]);Be(k,o[v]),u[v++]=k}for(;f<=m;){const k=a[f++];k!==null&&ds(k)}return this._itemKeys=c,yu(t,u),Ie}}const hr=ur(wu);function fr(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const s=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",i=t.content,a=Array.isArray(i)?i:null,o=Array.isArray(a)&&a.some(p=>{const m=String(p.type??"").toLowerCase();return m==="toolresult"||m==="tool_result"}),c=typeof t.toolName=="string"||typeof t.tool_name=="string";(s||o||c)&&(n="toolResult");let r=[];typeof t.content=="string"?r=[{type:"text",text:t.content}]:Array.isArray(t.content)?r=t.content.map(p=>({type:p.type||"text",text:p.text,name:p.name,args:p.args||p.arguments})):typeof t.text=="string"&&(r=[{type:"text",text:t.text}]);const u=typeof t.timestamp=="number"?t.timestamp:Date.now(),d=typeof t.id=="string"?t.id:void 0;return{role:n,content:r,timestamp:u,id:d}}function mi(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 gr(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}const $u=1;class vi extends pr{constructor(t){if(super(t),this._value=g,t.type!==dr.CHILD)throw new Error(`${this.constructor.directiveName}() can only be used in child bindings`)}render(t){if(t===g||t==null)return this._templateResult=void 0,this._value=t;if(t===Ie)return t;if(typeof t!="string")throw new Error(`${this.constructor.directiveName}() called with a non-string value`);if(t===this._value)return this._templateResult;this._value=t;const n=[t];return n.raw=n,this._templateResult={_$litType$:this.constructor.resultType,strings:n,values:[]}}}vi.directiveName="unsafeHTML";vi.resultType=$u;const Ns=ur(vi);const{entries:mr,setPrototypeOf:Ra,isFrozen:xu,getPrototypeOf:ku,getOwnPropertyDescriptor:Su}=Object;let{freeze:Z,seal:ae,create:Os}=Object,{apply:Ds,construct:Bs}=typeof Reflect<"u"&&Reflect;Z||(Z=function(t){return t});ae||(ae=function(t){return t});Ds||(Ds=function(t,n){for(var s=arguments.length,i=new Array(s>2?s-2:0),a=2;a<s;a++)i[a-2]=arguments[a];return t.apply(n,i)});Bs||(Bs=function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return new t(...s)});const Zt=X(Array.prototype.forEach),Au=X(Array.prototype.lastIndexOf),Ma=X(Array.prototype.pop),bt=X(Array.prototype.push),_u=X(Array.prototype.splice),on=X(String.prototype.toLowerCase),us=X(String.prototype.toString),ps=X(String.prototype.match),wt=X(String.prototype.replace),Tu=X(String.prototype.indexOf),Cu=X(String.prototype.trim),oe=X(Object.prototype.hasOwnProperty),Q=X(RegExp.prototype.test),$t=Eu(TypeError);function X(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return Ds(e,t,s)}}function Eu(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return Bs(e,n)}}function I(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:on;Ra&&Ra(e,null);let s=t.length;for(;s--;){let i=t[s];if(typeof i=="string"){const a=n(i);a!==i&&(xu(t)||(t[s]=a),i=a)}e[i]=!0}return e}function Ru(e){for(let t=0;t<e.length;t++)oe(e,t)||(e[t]=null);return e}function ge(e){const t=Os(null);for(const[n,s]of mr(e))oe(e,n)&&(Array.isArray(s)?t[n]=Ru(s):s&&typeof s=="object"&&s.constructor===Object?t[n]=ge(s):t[n]=s);return t}function xt(e,t){for(;e!==null;){const s=Su(e,t);if(s){if(s.get)return X(s.get);if(typeof s.value=="function")return X(s.value)}e=ku(e)}function n(){return null}return n}const Ia=Z(["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"]),hs=Z(["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"]),fs=Z(["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"]),Mu=Z(["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"]),gs=Z(["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"]),Iu=Z(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),La=Z(["#text"]),Pa=Z(["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"]),ms=Z(["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"]),Na=Z(["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"]),Xt=Z(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Lu=ae(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Pu=ae(/<%[\w\W]*|[\w\W]*%>/gm),Nu=ae(/\$\{[\w\W]*/gm),Ou=ae(/^data-[\-\w.\u00B7-\uFFFF]+$/),Du=ae(/^aria-[\-\w]+$/),vr=ae(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Bu=ae(/^(?:\w+script|data):/i),Fu=ae(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),yr=ae(/^html$/i),Uu=ae(/^[a-z][.\w]*(-[.\w]+)+$/i);var Oa=Object.freeze({__proto__:null,ARIA_ATTR:Du,ATTR_WHITESPACE:Fu,CUSTOM_ELEMENT:Uu,DATA_ATTR:Ou,DOCTYPE_NAME:yr,ERB_EXPR:Pu,IS_ALLOWED_URI:vr,IS_SCRIPT_OR_DATA:Bu,MUSTACHE_EXPR:Lu,TMPLIT_EXPR:Nu});const kt={element:1,text:3,progressingInstruction:7,comment:8,document:9},Ku=function(){return typeof window>"u"?null:window},zu=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let s=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(s=n.getAttribute(i));const a="dompurify"+(s?"#"+s:"");try{return t.createPolicy(a,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Da=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function br(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ku();const t=T=>br(T);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==kt.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const s=n,i=s.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:c,Element:r,NodeFilter:u,NamedNodeMap:d=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:f,trustedTypes:m}=e,v=r.prototype,$=xt(v,"cloneNode"),k=xt(v,"remove"),_=xt(v,"nextSibling"),M=xt(v,"childNodes"),N=xt(v,"parentNode");if(typeof o=="function"){const T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let R,C="";const{implementation:E,createNodeIterator:ve,createDocumentFragment:Nn,getElementsByTagName:On}=n,{importNode:Qr}=s;let Y=Da();t.isSupported=typeof mr=="function"&&typeof N=="function"&&E&&E.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Dn,ERB_EXPR:Bn,TMPLIT_EXPR:Fn,DATA_ATTR:Jr,ARIA_ATTR:Zr,IS_SCRIPT_OR_DATA:Xr,ATTR_WHITESPACE:Ei,CUSTOM_ELEMENT:el}=Oa;let{IS_ALLOWED_URI:Ri}=Oa,z=null;const Mi=I({},[...Ia,...hs,...fs,...gs,...La]);let j=null;const Ii=I({},[...Pa,...ms,...Na,...Xt]);let F=Object.seal(Os(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}})),ft=null,Un=null;const Qe=Object.seal(Os(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Li=!0,Kn=!0,Pi=!1,Ni=!0,Je=!1,Kt=!0,Ne=!1,zn=!1,Hn=!1,Ze=!1,zt=!1,Ht=!1,Oi=!0,Di=!1;const tl="user-content-";let jn=!0,gt=!1,Xe={},pe=null;const Vn=I({},["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 Bi=null;const Fi=I({},["audio","video","img","source","image","track"]);let Wn=null;const Ui=I({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),jt="http://www.w3.org/1998/Math/MathML",Vt="http://www.w3.org/2000/svg",ye="http://www.w3.org/1999/xhtml";let et=ye,qn=!1,Gn=null;const nl=I({},[jt,Vt,ye],us);let Wt=I({},["mi","mo","mn","ms","mtext"]),qt=I({},["annotation-xml"]);const sl=I({},["title","style","font","a","script"]);let mt=null;const il=["application/xhtml+xml","text/html"],al="text/html";let K=null,tt=null;const ol=n.createElement("form"),Ki=function(h){return h instanceof RegExp||h instanceof Function},Yn=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(tt&&tt===h)){if((!h||typeof h!="object")&&(h={}),h=ge(h),mt=il.indexOf(h.PARSER_MEDIA_TYPE)===-1?al:h.PARSER_MEDIA_TYPE,K=mt==="application/xhtml+xml"?us:on,z=oe(h,"ALLOWED_TAGS")?I({},h.ALLOWED_TAGS,K):Mi,j=oe(h,"ALLOWED_ATTR")?I({},h.ALLOWED_ATTR,K):Ii,Gn=oe(h,"ALLOWED_NAMESPACES")?I({},h.ALLOWED_NAMESPACES,us):nl,Wn=oe(h,"ADD_URI_SAFE_ATTR")?I(ge(Ui),h.ADD_URI_SAFE_ATTR,K):Ui,Bi=oe(h,"ADD_DATA_URI_TAGS")?I(ge(Fi),h.ADD_DATA_URI_TAGS,K):Fi,pe=oe(h,"FORBID_CONTENTS")?I({},h.FORBID_CONTENTS,K):Vn,ft=oe(h,"FORBID_TAGS")?I({},h.FORBID_TAGS,K):ge({}),Un=oe(h,"FORBID_ATTR")?I({},h.FORBID_ATTR,K):ge({}),Xe=oe(h,"USE_PROFILES")?h.USE_PROFILES:!1,Li=h.ALLOW_ARIA_ATTR!==!1,Kn=h.ALLOW_DATA_ATTR!==!1,Pi=h.ALLOW_UNKNOWN_PROTOCOLS||!1,Ni=h.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Je=h.SAFE_FOR_TEMPLATES||!1,Kt=h.SAFE_FOR_XML!==!1,Ne=h.WHOLE_DOCUMENT||!1,Ze=h.RETURN_DOM||!1,zt=h.RETURN_DOM_FRAGMENT||!1,Ht=h.RETURN_TRUSTED_TYPE||!1,Hn=h.FORCE_BODY||!1,Oi=h.SANITIZE_DOM!==!1,Di=h.SANITIZE_NAMED_PROPS||!1,jn=h.KEEP_CONTENT!==!1,gt=h.IN_PLACE||!1,Ri=h.ALLOWED_URI_REGEXP||vr,et=h.NAMESPACE||ye,Wt=h.MATHML_TEXT_INTEGRATION_POINTS||Wt,qt=h.HTML_INTEGRATION_POINTS||qt,F=h.CUSTOM_ELEMENT_HANDLING||{},h.CUSTOM_ELEMENT_HANDLING&&Ki(h.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(F.tagNameCheck=h.CUSTOM_ELEMENT_HANDLING.tagNameCheck),h.CUSTOM_ELEMENT_HANDLING&&Ki(h.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(F.attributeNameCheck=h.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),h.CUSTOM_ELEMENT_HANDLING&&typeof h.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(F.allowCustomizedBuiltInElements=h.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Je&&(Kn=!1),zt&&(Ze=!0),Xe&&(z=I({},La),j=[],Xe.html===!0&&(I(z,Ia),I(j,Pa)),Xe.svg===!0&&(I(z,hs),I(j,ms),I(j,Xt)),Xe.svgFilters===!0&&(I(z,fs),I(j,ms),I(j,Xt)),Xe.mathMl===!0&&(I(z,gs),I(j,Na),I(j,Xt))),h.ADD_TAGS&&(typeof h.ADD_TAGS=="function"?Qe.tagCheck=h.ADD_TAGS:(z===Mi&&(z=ge(z)),I(z,h.ADD_TAGS,K))),h.ADD_ATTR&&(typeof h.ADD_ATTR=="function"?Qe.attributeCheck=h.ADD_ATTR:(j===Ii&&(j=ge(j)),I(j,h.ADD_ATTR,K))),h.ADD_URI_SAFE_ATTR&&I(Wn,h.ADD_URI_SAFE_ATTR,K),h.FORBID_CONTENTS&&(pe===Vn&&(pe=ge(pe)),I(pe,h.FORBID_CONTENTS,K)),h.ADD_FORBID_CONTENTS&&(pe===Vn&&(pe=ge(pe)),I(pe,h.ADD_FORBID_CONTENTS,K)),jn&&(z["#text"]=!0),Ne&&I(z,["html","head","body"]),z.table&&(I(z,["tbody"]),delete ft.tbody),h.TRUSTED_TYPES_POLICY){if(typeof h.TRUSTED_TYPES_POLICY.createHTML!="function")throw $t('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof h.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw $t('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');R=h.TRUSTED_TYPES_POLICY,C=R.createHTML("")}else R===void 0&&(R=zu(m,i)),R!==null&&typeof C=="string"&&(C=R.createHTML(""));Z&&Z(h),tt=h}},zi=I({},[...hs,...fs,...Mu]),Hi=I({},[...gs,...Iu]),rl=function(h){let x=N(h);(!x||!x.tagName)&&(x={namespaceURI:et,tagName:"template"});const A=on(h.tagName),B=on(x.tagName);return Gn[h.namespaceURI]?h.namespaceURI===Vt?x.namespaceURI===ye?A==="svg":x.namespaceURI===jt?A==="svg"&&(B==="annotation-xml"||Wt[B]):!!zi[A]:h.namespaceURI===jt?x.namespaceURI===ye?A==="math":x.namespaceURI===Vt?A==="math"&&qt[B]:!!Hi[A]:h.namespaceURI===ye?x.namespaceURI===Vt&&!qt[B]||x.namespaceURI===jt&&!Wt[B]?!1:!Hi[A]&&(sl[A]||!zi[A]):!!(mt==="application/xhtml+xml"&&Gn[h.namespaceURI]):!1},he=function(h){bt(t.removed,{element:h});try{N(h).removeChild(h)}catch{k(h)}},Oe=function(h,x){try{bt(t.removed,{attribute:x.getAttributeNode(h),from:x})}catch{bt(t.removed,{attribute:null,from:x})}if(x.removeAttribute(h),h==="is")if(Ze||zt)try{he(x)}catch{}else try{x.setAttribute(h,"")}catch{}},ji=function(h){let x=null,A=null;if(Hn)h="<remove></remove>"+h;else{const U=ps(h,/^[\r\n\t ]+/);A=U&&U[0]}mt==="application/xhtml+xml"&&et===ye&&(h='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+h+"</body></html>");const B=R?R.createHTML(h):h;if(et===ye)try{x=new f().parseFromString(B,mt)}catch{}if(!x||!x.documentElement){x=E.createDocument(et,"template",null);try{x.documentElement.innerHTML=qn?C:B}catch{}}const W=x.body||x.documentElement;return h&&A&&W.insertBefore(n.createTextNode(A),W.childNodes[0]||null),et===ye?On.call(x,Ne?"html":"body")[0]:Ne?x.documentElement:W},Vi=function(h){return ve.call(h.ownerDocument||h,h,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Qn=function(h){return h instanceof p&&(typeof h.nodeName!="string"||typeof h.textContent!="string"||typeof h.removeChild!="function"||!(h.attributes instanceof d)||typeof h.removeAttribute!="function"||typeof h.setAttribute!="function"||typeof h.namespaceURI!="string"||typeof h.insertBefore!="function"||typeof h.hasChildNodes!="function")},Wi=function(h){return typeof c=="function"&&h instanceof c};function be(T,h,x){Zt(T,A=>{A.call(t,h,x,tt)})}const qi=function(h){let x=null;if(be(Y.beforeSanitizeElements,h,null),Qn(h))return he(h),!0;const A=K(h.nodeName);if(be(Y.uponSanitizeElement,h,{tagName:A,allowedTags:z}),Kt&&h.hasChildNodes()&&!Wi(h.firstElementChild)&&Q(/<[/\w!]/g,h.innerHTML)&&Q(/<[/\w!]/g,h.textContent)||h.nodeType===kt.progressingInstruction||Kt&&h.nodeType===kt.comment&&Q(/<[/\w]/g,h.data))return he(h),!0;if(!(Qe.tagCheck instanceof Function&&Qe.tagCheck(A))&&(!z[A]||ft[A])){if(!ft[A]&&Yi(A)&&(F.tagNameCheck instanceof RegExp&&Q(F.tagNameCheck,A)||F.tagNameCheck instanceof Function&&F.tagNameCheck(A)))return!1;if(jn&&!pe[A]){const B=N(h)||h.parentNode,W=M(h)||h.childNodes;if(W&&B){const U=W.length;for(let ee=U-1;ee>=0;--ee){const we=$(W[ee],!0);we.__removalCount=(h.__removalCount||0)+1,B.insertBefore(we,_(h))}}}return he(h),!0}return h instanceof r&&!rl(h)||(A==="noscript"||A==="noembed"||A==="noframes")&&Q(/<\/no(script|embed|frames)/i,h.innerHTML)?(he(h),!0):(Je&&h.nodeType===kt.text&&(x=h.textContent,Zt([Dn,Bn,Fn],B=>{x=wt(x,B," ")}),h.textContent!==x&&(bt(t.removed,{element:h.cloneNode()}),h.textContent=x)),be(Y.afterSanitizeElements,h,null),!1)},Gi=function(h,x,A){if(Oi&&(x==="id"||x==="name")&&(A in n||A in ol))return!1;if(!(Kn&&!Un[x]&&Q(Jr,x))){if(!(Li&&Q(Zr,x))){if(!(Qe.attributeCheck instanceof Function&&Qe.attributeCheck(x,h))){if(!j[x]||Un[x]){if(!(Yi(h)&&(F.tagNameCheck instanceof RegExp&&Q(F.tagNameCheck,h)||F.tagNameCheck instanceof Function&&F.tagNameCheck(h))&&(F.attributeNameCheck instanceof RegExp&&Q(F.attributeNameCheck,x)||F.attributeNameCheck instanceof Function&&F.attributeNameCheck(x,h))||x==="is"&&F.allowCustomizedBuiltInElements&&(F.tagNameCheck instanceof RegExp&&Q(F.tagNameCheck,A)||F.tagNameCheck instanceof Function&&F.tagNameCheck(A))))return!1}else if(!Wn[x]){if(!Q(Ri,wt(A,Ei,""))){if(!((x==="src"||x==="xlink:href"||x==="href")&&h!=="script"&&Tu(A,"data:")===0&&Bi[h])){if(!(Pi&&!Q(Xr,wt(A,Ei,"")))){if(A)return!1}}}}}}}return!0},Yi=function(h){return h!=="annotation-xml"&&ps(h,el)},Qi=function(h){be(Y.beforeSanitizeAttributes,h,null);const{attributes:x}=h;if(!x||Qn(h))return;const A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:j,forceKeepAttr:void 0};let B=x.length;for(;B--;){const W=x[B],{name:U,namespaceURI:ee,value:we}=W,nt=K(U),Jn=we;let V=U==="value"?Jn:Cu(Jn);if(A.attrName=nt,A.attrValue=V,A.keepAttr=!0,A.forceKeepAttr=void 0,be(Y.uponSanitizeAttribute,h,A),V=A.attrValue,Di&&(nt==="id"||nt==="name")&&(Oe(U,h),V=tl+V),Kt&&Q(/((--!?|])>)|<\/(style|title|textarea)/i,V)){Oe(U,h);continue}if(nt==="attributename"&&ps(V,"href")){Oe(U,h);continue}if(A.forceKeepAttr)continue;if(!A.keepAttr){Oe(U,h);continue}if(!Ni&&Q(/\/>/i,V)){Oe(U,h);continue}Je&&Zt([Dn,Bn,Fn],Zi=>{V=wt(V,Zi," ")});const Ji=K(h.nodeName);if(!Gi(Ji,nt,V)){Oe(U,h);continue}if(R&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!ee)switch(m.getAttributeType(Ji,nt)){case"TrustedHTML":{V=R.createHTML(V);break}case"TrustedScriptURL":{V=R.createScriptURL(V);break}}if(V!==Jn)try{ee?h.setAttributeNS(ee,U,V):h.setAttribute(U,V),Qn(h)?he(h):Ma(t.removed)}catch{Oe(U,h)}}be(Y.afterSanitizeAttributes,h,null)},ll=function T(h){let x=null;const A=Vi(h);for(be(Y.beforeSanitizeShadowDOM,h,null);x=A.nextNode();)be(Y.uponSanitizeShadowNode,x,null),qi(x),Qi(x),x.content instanceof a&&T(x.content);be(Y.afterSanitizeShadowDOM,h,null)};return t.sanitize=function(T){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,A=null,B=null,W=null;if(qn=!T,qn&&(T="<!-->"),typeof T!="string"&&!Wi(T))if(typeof T.toString=="function"){if(T=T.toString(),typeof T!="string")throw $t("dirty is not a string, aborting")}else throw $t("toString is not a function");if(!t.isSupported)return T;if(zn||Yn(h),t.removed=[],typeof T=="string"&&(gt=!1),gt){if(T.nodeName){const we=K(T.nodeName);if(!z[we]||ft[we])throw $t("root node is forbidden and cannot be sanitized in-place")}}else if(T instanceof c)x=ji("<!---->"),A=x.ownerDocument.importNode(T,!0),A.nodeType===kt.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?x=A:x.appendChild(A);else{if(!Ze&&!Je&&!Ne&&T.indexOf("<")===-1)return R&&Ht?R.createHTML(T):T;if(x=ji(T),!x)return Ze?null:Ht?C:""}x&&Hn&&he(x.firstChild);const U=Vi(gt?T:x);for(;B=U.nextNode();)qi(B),Qi(B),B.content instanceof a&&ll(B.content);if(gt)return T;if(Ze){if(zt)for(W=Nn.call(x.ownerDocument);x.firstChild;)W.appendChild(x.firstChild);else W=x;return(j.shadowroot||j.shadowrootmode)&&(W=Qr.call(s,W,!0)),W}let ee=Ne?x.outerHTML:x.innerHTML;return Ne&&z["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&Q(yr,x.ownerDocument.doctype.name)&&(ee="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
|
|
30
|
-
`+ee),Je&&Zt([Dn,Bn,Fn],we=>{ee=wt(ee,we," ")}),R&&Ht?R.createHTML(ee):ee},t.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Yn(T),zn=!0},t.clearConfig=function(){tt=null,zn=!1},t.isValidAttribute=function(T,h,x){tt||Yn({});const A=K(T),B=K(h);return
|
|
31
|
-
]`).replace("lheading",
|
|
28
|
+
`],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),a=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`poolbot-logs-${t}-${a}.log`,i.click(),URL.revokeObjectURL(s)}function Hc(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:s}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${s}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}function Ve(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function ct(e){return`${JSON.stringify(e,null,2).trimEnd()}
|
|
29
|
+
`}function Oo(e,t,n){if(t.length===0)return;let s=e;for(let a=0;a<t.length-1;a+=1){const o=t[a],c=t[a+1];if(typeof o=="number"){if(!Array.isArray(s))return;s[o]==null&&(s[o]=typeof c=="number"?[]:{}),s=s[o]}else{if(typeof s!="object"||s==null)return;const l=s;l[o]==null&&(l[o]=typeof c=="number"?[]:{}),s=l[o]}}const i=t[t.length-1];if(typeof i=="number"){Array.isArray(s)&&(s[i]=n);return}typeof s=="object"&&s!=null&&(s[i]=n)}function Do(e,t){if(t.length===0)return;let n=e;for(let i=0;i<t.length-1;i+=1){const a=t[i];if(typeof a=="number"){if(!Array.isArray(n))return;n=n[a]}else{if(typeof n!="object"||n==null)return;n=n[a]}if(n==null)return}const s=t[t.length-1];if(typeof s=="number"){Array.isArray(n)&&n.splice(s,1);return}typeof n=="object"&&n!=null&&delete n[s]}async function Ae(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});Vc(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function Bo(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});jc(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function jc(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function Vc(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?ct(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=ct(e.configForm):e.configRaw=n,e.configValid=typeof t.valid=="boolean"?t.valid:null,e.configIssues=Array.isArray(t.issues)?t.issues:[],e.configFormDirty||(e.configForm=Ve(t.config??{}),e.configFormOriginal=Ve(t.config??{}),e.configRawOriginal=n)}async function Rs(e){if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?ct(e.configForm):e.configRaw,n=e.configSnapshot?.hash;if(!n){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:t,baseHash:n}),e.configFormDirty=!1,await Ae(e)}catch(t){e.lastError=String(t)}finally{e.configSaving=!1}}}async function Wc(e){if(!(!e.client||!e.connected)){e.configApplying=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?ct(e.configForm):e.configRaw,n=e.configSnapshot?.hash;if(!n){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.apply",{raw:t,baseHash:n,sessionKey:e.applySessionKey}),e.configFormDirty=!1,await Ae(e)}catch(t){e.lastError=String(t)}finally{e.configApplying=!1}}}async function qc(e){if(!(!e.client||!e.connected)){e.updateRunning=!0,e.lastError=null;try{await e.client.request("update.run",{sessionKey:e.applySessionKey})}catch(t){e.lastError=String(t)}finally{e.updateRunning=!1}}}function Yt(e,t,n){const s=Ve(e.configForm??e.configSnapshot?.config??{});Oo(s,t,n),e.configForm=s,e.configFormDirty=!0,e.configFormMode==="form"&&(e.configRaw=ct(s))}function xa(e,t){const n=Ve(e.configForm??e.configSnapshot?.config??{});Do(n,t),e.configForm=n,e.configFormDirty=!0,e.configFormMode==="form"&&(e.configRaw=ct(n))}async function Bt(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 An(e){if(!(!e.client||!e.connected)&&!e.cronLoading){e.cronLoading=!0,e.cronError=null;try{const t=await e.client.request("cron.list",{includeDisabled:!0});e.cronJobs=Array.isArray(t.jobs)?t.jobs:[]}catch(t){e.cronError=String(t)}finally{e.cronLoading=!1}}}function Gc(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=dn(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const s=e.everyUnit;return{kind:"every",everyMs:n*(s==="minutes"?6e4:s==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function Yc(e){if(e.payloadKind==="systemEvent"){const i=e.payloadText.trim();if(!i)throw new Error("System event text required.");return{kind:"systemEvent",text:i}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel),e.to.trim()&&(n.to=e.to.trim());const s=dn(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function Qc(e){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const t=Gc(e.cronForm),n=Yc(e.cronForm),s=e.cronForm.agentId.trim(),i={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,enabled:e.cronForm.enabled,schedule:t,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:n,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!i.name)throw new Error("Name required.");await e.client.request("cron.add",i),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await An(e),await Bt(e)}catch(t){e.cronError=String(t)}finally{e.cronBusy=!1}}}async function Jc(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 An(e),await Bt(e)}catch(s){e.cronError=String(s)}finally{e.cronBusy=!1}}}async function Zc(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 Fo(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Xc(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 An(e),await Bt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Fo(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 ue(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 ed(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const n=await e.client.request("web.login.start",{force:t,timeoutMs:3e4});e.whatsappLoginMessage=n.message??null,e.whatsappLoginQrDataUrl=n.qrDataUrl??null,e.whatsappLoginConnected=null}catch(n){e.whatsappLoginMessage=String(n),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function td(e){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const t=await e.client.request("web.login.wait",{timeoutMs:12e4});e.whatsappLoginMessage=t.message??null,e.whatsappLoginConnected=t.connected??null,t.connected&&(e.whatsappLoginQrDataUrl=null)}catch(t){e.whatsappLoginMessage=String(t),e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function nd(e){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{await e.client.request("channels.logout",{channel:"whatsapp"}),e.whatsappLoginMessage="Logged out.",e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}catch(t){e.whatsappLoginMessage=String(t)}finally{e.whatsappBusy=!1}}}async function _n(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,s,i]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const a=s;e.debugModels=Array.isArray(a?.models)?a?.models:[],e.debugHeartbeat=i}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}async function sd(e){if(!(!e.client||!e.connected)){e.debugCallError=null,e.debugCallResult=null;try{const t=e.debugCallParams.trim()?JSON.parse(e.debugCallParams):{},n=await e.client.request(e.debugCallMethod.trim(),t);e.debugCallResult=JSON.stringify(n,null,2)}catch(t){e.debugCallError=String(t)}}}const id=2e3,ad=new Set(["trace","debug","info","warn","error","fatal"]);function od(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 rd(e){if(typeof e!="string")return null;const t=e.toLowerCase();return ad.has(t)?t:null}function ld(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,s=typeof t.time=="string"?t.time:typeof n?.date=="string"?n?.date:null,i=rd(n?.logLevelName??n?.level),a=typeof t[0]=="string"?t[0]:typeof n?.name=="string"?n?.name:null,o=od(a);let c=null;o&&(typeof o.subsystem=="string"?c=o.subsystem:typeof o.module=="string"&&(c=o.module)),!c&&a&&a.length<120&&(c=a);let l=null;return typeof t[1]=="string"?l=t[1]:!o&&typeof t[0]=="string"?l=t[0]:typeof t.message=="string"&&(l=t.message),{raw:e,time:s,level:i,subsystem:c,message:l??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function ti(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!t?.quiet)){t?.quiet||(e.logsLoading=!0),e.logsError=null;try{const s=await e.client.request("logs.tail",{cursor:t?.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),a=(Array.isArray(s.lines)?s.lines.filter(c=>typeof c=="string"):[]).map(ld),o=!!(t?.reset||s.reset||e.logsCursor==null);e.logsEntries=o?a:[...e.logsEntries,...a].slice(-id),typeof s.cursor=="number"&&(e.logsCursor=s.cursor),typeof s.file=="string"&&(e.logsFile=s.file),e.logsTruncated=!!s.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t?.quiet||(e.logsLoading=!1)}}}const Uo={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:q,n:an,Gx:ka,Gy:Sa,a:os,d:rs,h:cd}=Uo,We=32,ni=64,dd=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},H=(e="")=>{const t=new Error(e);throw dd(t,H),t},ud=e=>typeof e=="bigint",pd=e=>typeof e=="string",hd=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",Le=(e,t,n="")=>{const s=hd(e),i=e?.length,a=t!==void 0;if(!s||a&&i!==t){const o=n&&`"${n}" `,c=a?` of length ${t}`:"",l=s?`length=${i}`:`type=${typeof e}`;H(o+"expected Uint8Array"+c+", got "+l)}return e},Tn=e=>new Uint8Array(e),Ko=e=>Uint8Array.from(e),zo=(e,t)=>e.toString(16).padStart(t,"0"),Ho=e=>Array.from(Le(e)).map(t=>zo(t,2)).join(""),$e={_0:48,_9:57,A:65,F:70,a:97,f:102},Aa=e=>{if(e>=$e._0&&e<=$e._9)return e-$e._0;if(e>=$e.A&&e<=$e.F)return e-($e.A-10);if(e>=$e.a&&e<=$e.f)return e-($e.a-10)},jo=e=>{const t="hex invalid";if(!pd(e))return H(t);const n=e.length,s=n/2;if(n%2)return H(t);const i=Tn(s);for(let a=0,o=0;a<s;a++,o+=2){const c=Aa(e.charCodeAt(o)),l=Aa(e.charCodeAt(o+1));if(c===void 0||l===void 0)return H(t);i[a]=c*16+l}return i},Vo=()=>globalThis?.crypto,fd=()=>Vo()?.subtle??H("crypto.subtle must be defined, consider polyfill"),Ot=(...e)=>{const t=Tn(e.reduce((s,i)=>s+Le(i).length,0));let n=0;return e.forEach(s=>{t.set(s,n),n+=s.length}),t},gd=(e=We)=>Vo().getRandomValues(Tn(e)),un=BigInt,Ue=(e,t,n,s="bad number: out of range")=>ud(e)&&t<=e&&e<n?e:H(s),S=(e,t=q)=>{const n=e%t;return n>=0n?n:t+n},Wo=e=>S(e,an),md=(e,t)=>{(e===0n||t<=0n)&&H("no inverse n="+e+" mod="+t);let n=S(e,t),s=t,i=0n,a=1n;for(;n!==0n;){const o=s/n,c=s%n,l=i-a*o;s=n,n=c,i=a,a=l}return s===1n?S(i,t):H("no inverse")},vd=e=>{const t=Qo[e];return typeof t!="function"&&H("hashes."+e+" not set"),t},ls=e=>e instanceof ne?e:H("Point expected"),Ms=2n**256n;class ne{static BASE;static ZERO;X;Y;Z;T;constructor(t,n,s,i){const a=Ms;this.X=Ue(t,0n,a),this.Y=Ue(n,0n,a),this.Z=Ue(s,1n,a),this.T=Ue(i,0n,a),Object.freeze(this)}static CURVE(){return Uo}static fromAffine(t){return new ne(t.x,t.y,1n,S(t.x*t.y))}static fromBytes(t,n=!1){const s=rs,i=Ko(Le(t,We)),a=t[31];i[31]=a&-129;const o=Go(i);Ue(o,0n,n?Ms:q);const l=S(o*o),u=S(l-1n),d=S(s*l+1n);let{isValid:p,value:f}=bd(u,d);p||H("bad point: y not sqrt");const m=(f&1n)===1n,v=(a&128)!==0;return!n&&f===0n&&v&&H("bad point: x==0, isLastByteOdd"),v!==m&&(f=S(-f)),new ne(f,o,1n,S(f*o))}static fromHex(t,n){return ne.fromBytes(jo(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=os,n=rs,s=this;if(s.is0())return H("bad point: ZERO");const{X:i,Y:a,Z:o,T:c}=s,l=S(i*i),u=S(a*a),d=S(o*o),p=S(d*d),f=S(l*t),m=S(d*S(f+u)),v=S(p+S(n*S(l*u)));if(m!==v)return H("bad point: equation left != right (1)");const $=S(i*a),k=S(o*c);return $!==k?H("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:s,Z:i}=this,{X:a,Y:o,Z:c}=ls(t),l=S(n*c),u=S(a*i),d=S(s*c),p=S(o*i);return l===u&&d===p}is0(){return this.equals(at)}negate(){return new ne(S(-this.X),this.Y,this.Z,S(-this.T))}double(){const{X:t,Y:n,Z:s}=this,i=os,a=S(t*t),o=S(n*n),c=S(2n*S(s*s)),l=S(i*a),u=t+n,d=S(S(u*u)-a-o),p=l+o,f=p-c,m=l-o,v=S(d*f),$=S(p*m),k=S(d*m),_=S(f*p);return new ne(v,$,_,k)}add(t){const{X:n,Y:s,Z:i,T:a}=this,{X:o,Y:c,Z:l,T:u}=ls(t),d=os,p=rs,f=S(n*o),m=S(s*c),v=S(a*p*u),$=S(i*l),k=S((n+s)*(o+c)-f-m),_=S($-v),M=S($+v),N=S(m-d*f),R=S(k*_),C=S(M*N),E=S(k*N),ve=S(_*M);return new ne(R,C,ve,E)}subtract(t){return this.add(ls(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return at;if(Ue(t,1n,an),t===1n)return this;if(this.equals(qe))return Rd(t).p;let s=at,i=qe;for(let a=this;t>0n;a=a.double(),t>>=1n)t&1n?s=s.add(a):n&&(i=i.add(a));return s}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:s}=this;if(this.equals(at))return{x:0n,y:1n};const i=md(s,q);S(s*i)!==1n&&H("invalid inverse");const a=S(t*i),o=S(n*i);return{x:a,y:o}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),s=qo(n);return s[31]|=t&1n?128:0,s}toHex(){return Ho(this.toBytes())}clearCofactor(){return this.multiply(un(cd),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(an/2n,!1).double();return an%2n&&(t=t.add(this)),t.is0()}}const qe=new ne(ka,Sa,1n,S(ka*Sa)),at=new ne(0n,1n,1n,0n);ne.BASE=qe;ne.ZERO=at;const qo=e=>jo(zo(Ue(e,0n,Ms),ni)).reverse(),Go=e=>un("0x"+Ho(Ko(Le(e)).reverse())),fe=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=q;return n},yd=e=>{const n=e*e%q*e%q,s=fe(n,2n)*n%q,i=fe(s,1n)*e%q,a=fe(i,5n)*i%q,o=fe(a,10n)*a%q,c=fe(o,20n)*o%q,l=fe(c,40n)*c%q,u=fe(l,80n)*l%q,d=fe(u,80n)*l%q,p=fe(d,10n)*a%q;return{pow_p_5_8:fe(p,2n)*e%q,b2:n}},_a=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,bd=(e,t)=>{const n=S(t*t*t),s=S(n*n*t),i=yd(e*s).pow_p_5_8;let a=S(e*n*i);const o=S(t*a*a),c=a,l=S(a*_a),u=o===e,d=o===S(-e),p=o===S(-e*_a);return u&&(a=c),(d||p)&&(a=l),(S(a)&1n)===1n&&(a=S(-a)),{isValid:u||d,value:a}},Is=e=>Wo(Go(e)),si=(...e)=>Qo.sha512Async(Ot(...e)),wd=(...e)=>vd("sha512")(Ot(...e)),Yo=e=>{const t=e.slice(0,We);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(We,ni),s=Is(t),i=qe.multiply(s),a=i.toBytes();return{head:t,prefix:n,scalar:s,point:i,pointBytes:a}},ii=e=>si(Le(e,We)).then(Yo),$d=e=>Yo(wd(Le(e,We))),xd=e=>ii(e).then(t=>t.pointBytes),kd=e=>si(e.hashable).then(e.finish),Sd=(e,t,n)=>{const{pointBytes:s,scalar:i}=e,a=Is(t),o=qe.multiply(a).toBytes();return{hashable:Ot(o,s,n),finish:u=>{const d=Wo(a+Is(u)*i);return Le(Ot(o,qo(d)),ni)}}},Ad=async(e,t)=>{const n=Le(e),s=await ii(t),i=await si(s.prefix,n);return kd(Sd(s,i,n))},Qo={sha512Async:async e=>{const t=fd(),n=Ot(e);return Tn(await t.digest("SHA-512",n.buffer))},sha512:void 0},_d=(e=gd(We))=>e,Td={getExtendedPublicKeyAsync:ii,getExtendedPublicKey:$d,randomSecretKey:_d},pn=8,Cd=256,Jo=Math.ceil(Cd/pn)+1,Ls=2**(pn-1),Ed=()=>{const e=[];let t=qe,n=t;for(let s=0;s<Jo;s++){n=t,e.push(n);for(let i=1;i<Ls;i++)n=n.add(t),e.push(n);t=n.double()}return e};let Ta;const Ca=(e,t)=>{const n=t.negate();return e?n:t},Rd=e=>{const t=Ta||(Ta=Ed());let n=at,s=qe;const i=2**pn,a=i,o=un(i-1),c=un(pn);for(let l=0;l<Jo;l++){let u=Number(e&o);e>>=c,u>Ls&&(u-=a,e+=1n);const d=l*Ls,p=d,f=d+Math.abs(u)-1,m=l%2!==0,v=u<0;u===0?s=s.add(Ca(m,t[p])):n=n.add(Ca(v,t[f]))}return e!==0n&&H("invalid wnaf"),{p:n,f:s}},cs="poolbot-device-identity-v1";function Ps(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replaceAll("+","-").replaceAll("/","_").replace(/=+$/g,"")}function Zo(e){const t=e.replaceAll("-","+").replaceAll("_","/"),n=t+"=".repeat((4-t.length%4)%4),s=atob(n),i=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)i[a]=s.charCodeAt(a);return i}function Md(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Xo(e){const t=await crypto.subtle.digest("SHA-256",e);return Md(new Uint8Array(t))}async function Id(){const e=Td.randomSecretKey(),t=await xd(e);return{deviceId:await Xo(t),publicKey:Ps(t),privateKey:Ps(e)}}async function ai(){try{const n=localStorage.getItem(cs);if(n){const s=JSON.parse(n);if(s?.version===1&&typeof s.deviceId=="string"&&typeof s.publicKey=="string"&&typeof s.privateKey=="string"){const i=await Xo(Zo(s.publicKey));if(i!==s.deviceId){const a={...s,deviceId:i};return localStorage.setItem(cs,JSON.stringify(a)),{deviceId:i,publicKey:s.publicKey,privateKey:s.privateKey}}return{deviceId:s.deviceId,publicKey:s.publicKey,privateKey:s.privateKey}}}}catch{}const e=await Id(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(cs,JSON.stringify(t)),e}async function Ld(e,t){const n=Zo(e),s=new TextEncoder().encode(t),i=await Ad(s,n);return Ps(i)}const er="poolbot.device.auth.v1";function oi(e){return e.trim()}function Pd(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const s=n.trim();s&&t.add(s)}return[...t].sort()}function ri(){try{const e=window.localStorage.getItem(er);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 tr(e){try{window.localStorage.setItem(er,JSON.stringify(e))}catch{}}function Nd(e){const t=ri();if(!t||t.deviceId!==e.deviceId)return null;const n=oi(e.role),s=t.tokens[n];return!s||typeof s.token!="string"?null:s}function nr(e){const t=oi(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},s=ri();s&&s.deviceId===e.deviceId&&(n.tokens={...s.tokens});const i={token:e.token,role:t,scopes:Pd(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=i,tr(n),i}function sr(e){const t=ri();if(!t||t.deviceId!==e.deviceId)return;const n=oi(e.role);if(!t.tokens[n])return;const s={...t,tokens:{...t.tokens}};delete s.tokens[n],tr(s)}async function Pe(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t?.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n?.pending)?n.pending:[],paired:Array.isArray(n?.paired)?n.paired:[]}}catch(n){t?.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function Od(e,t){if(!(!e.client||!e.connected))try{await e.client.request("device.pair.approve",{requestId:t}),await Pe(e)}catch(n){e.devicesError=String(n)}}async function Dd(e,t){if(!(!e.client||!e.connected||!window.confirm("Reject this device pairing request?")))try{await e.client.request("device.pair.reject",{requestId:t}),await Pe(e)}catch(s){e.devicesError=String(s)}}async function Bd(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("device.token.rotate",t);if(n?.token){const s=await ai(),i=n.role??t.role;(n.deviceId===s.deviceId||t.deviceId===s.deviceId)&&nr({deviceId:s.deviceId,role:i,token:n.token,scopes:n.scopes??t.scopes??[]}),window.prompt("New device token (copy and store securely):",n.token)}await Pe(e)}catch(n){e.devicesError=String(n)}}async function Fd(e,t){if(!(!e.client||!e.connected||!window.confirm(`Revoke token for ${t.deviceId} (${t.role})?`)))try{await e.client.request("device.token.revoke",t);const s=await ai();t.deviceId===s.deviceId&&sr({deviceId:s.deviceId,role:t.role}),await Pe(e)}catch(s){e.devicesError=String(s)}}async function Cn(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,t?.quiet||(e.lastError=null);try{const n=await e.client.request("node.list",{});e.nodes=Array.isArray(n.nodes)?n.nodes:[]}catch(n){t?.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function Ud(e){if(!e||e.kind==="gateway")return{method:"exec.approvals.get",params:{}};const t=e.nodeId.trim();return t?{method:"exec.approvals.node.get",params:{nodeId:t}}:null}function Kd(e,t){if(!e||e.kind==="gateway")return{method:"exec.approvals.set",params:t};const n=e.nodeId.trim();return n?{method:"exec.approvals.node.set",params:{...t,nodeId:n}}:null}async function li(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=Ud(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const s=await e.client.request(n.method,n.params);zd(e,s)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function zd(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=Ve(t.file??{}))}async function Hd(e,t){if(!(!e.client||!e.connected)){e.execApprovalsSaving=!0,e.lastError=null;try{const n=e.execApprovalsSnapshot?.hash;if(!n){e.lastError="Exec approvals hash missing; reload and retry.";return}const s=e.execApprovalsForm??e.execApprovalsSnapshot?.file??{},i=Kd(t,{file:s,baseHash:n});if(!i){e.lastError="Select a node before saving exec approvals.";return}await e.client.request(i.method,i.params),e.execApprovalsDirty=!1,await li(e,t)}catch(n){e.lastError=String(n)}finally{e.execApprovalsSaving=!1}}}function jd(e,t,n){const s=Ve(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});Oo(s,t,n),e.execApprovalsForm=s,e.execApprovalsDirty=!0}function Vd(e,t){const n=Ve(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});Do(n,t),e.execApprovalsForm=n,e.execApprovalsDirty=!0}async function ci(e){if(!(!e.client||!e.connected)&&!e.presenceLoading){e.presenceLoading=!0,e.presenceError=null,e.presenceStatus=null;try{const t=await e.client.request("system-presence",{});Array.isArray(t)?(e.presenceEntries=t,e.presenceStatus=t.length===0?"No instances yet.":null):(e.presenceEntries=[],e.presenceStatus="No presence payload.")}catch(t){e.presenceError=String(t)}finally{e.presenceLoading=!1}}}function dt(e,t,n){if(!t.trim())return;const s={...e.skillMessages};n?s[t]=n:delete s[t],e.skillMessages=s}function En(e){return e instanceof Error?e.message:String(e)}async function Ft(e,t){if(t?.clearMessages&&Object.keys(e.skillMessages).length>0&&(e.skillMessages={}),!(!e.client||!e.connected)&&!e.skillsLoading){e.skillsLoading=!0,e.skillsError=null;try{const n=await e.client.request("skills.status",{});n&&(e.skillsReport=n)}catch(n){e.skillsError=En(n)}finally{e.skillsLoading=!1}}}function Wd(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function qd(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 Ft(e),dt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(s){const i=En(s);e.skillsError=i,dt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Gd(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 Ft(e),dt(e,t,{kind:"success",message:"API key saved"})}catch(n){const s=En(n);e.skillsError=s,dt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Yd(e,t,n,s){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const i=await e.client.request("skills.install",{name:n,installId:s,timeoutMs:12e4});await Ft(e),dt(e,t,{kind:"success",message:i?.message??"Installed"})}catch(i){const a=En(i);e.skillsError=a,dt(e,t,{kind:"error",message:a})}finally{e.skillsBusyKey=null}}}function Qd(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function di(e){return e==="system"?Qd():e}const Qt=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,Jd=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Jt=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},Zd=({nextTheme:e,applyTheme:t,context:n,currentTheme:s})=>{if(s===e)return;const i=globalThis.document??null;if(!i){t();return}const a=i.documentElement,o=i,c=Jd();if(!!o.startViewTransition&&!c){let u=.5,d=.5;if(n?.pointerClientX!==void 0&&n?.pointerClientY!==void 0&&typeof window<"u")u=Qt(n.pointerClientX/window.innerWidth),d=Qt(n.pointerClientY/window.innerHeight);else if(n?.element){const p=n.element.getBoundingClientRect();p.width>0&&p.height>0&&typeof window<"u"&&(u=Qt((p.left+p.width/2)/window.innerWidth),d=Qt((p.top+p.height/2)/window.innerHeight))}a.style.setProperty("--theme-switch-x",`${u*100}%`),a.style.setProperty("--theme-switch-y",`${d*100}%`),a.classList.add("theme-transition");try{const p=o.startViewTransition?.(()=>{t()});p?.finished?p.finished.finally(()=>Jt(a)):Jt(a)}catch{Jt(a),t()}return}t(),Jt(a)};function Xd(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{Cn(e,{quiet:!0})},5e3))}function eu(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function ui(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&ti(e,{quiet:!0})},2e3))}function pi(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function hi(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&_n(e)},3e3))}function fi(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Re(e,t){const n={...t,lastActiveSessionKey:t.lastActiveSessionKey?.trim()||t.sessionKey.trim()||"main"};e.settings=n,oc(n),t.theme!==e.theme&&(e.theme=t.theme,Rn(e,di(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function ir(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&Re(e,{...e.settings,lastActiveSessionKey:n})}function tu(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),s=t.get("password"),i=t.get("session"),a=t.get("gatewayUrl");let o=!1;if(n!=null){const l=n.trim();l&&l!==e.settings.token&&Re(e,{...e.settings,token:l}),t.delete("token"),o=!0}if(s!=null){const l=s.trim();l&&(e.password=l),t.delete("password"),o=!0}if(i!=null){const l=i.trim();l&&(e.sessionKey=l,Re(e,{...e.settings,sessionKey:l,lastActiveSessionKey:l}))}if(a!=null){const l=a.trim();l&&l!==e.settings.gatewayUrl&&Re(e,{...e.settings,gatewayUrl:l}),t.delete("gatewayUrl"),o=!0}if(!o)return;const c=new URL(window.location.href);c.search=t.toString(),window.history.replaceState({},"",c.toString())}function nu(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?ui(e):pi(e),t==="debug"?hi(e):fi(e),gi(e),or(e,t,!1)}function su(e,t,n){Zd({nextTheme:t,applyTheme:()=>{e.theme=t,Re(e,{...e.settings,theme:t}),Rn(e,di(t))},context:n,currentTheme:e.theme})}async function gi(e){e.tab==="overview"&&await rr(e),e.tab==="channels"&&await uu(e),e.tab==="instances"&&await ci(e),e.tab==="sessions"&&await ht(e),e.tab==="cron"&&await mi(e),e.tab==="skills"&&await Ft(e),e.tab==="nodes"&&(await Cn(e),await Pe(e),await Ae(e),await li(e)),e.tab==="chat"&&(await mu(e),Sn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await Bo(e),await Ae(e)),e.tab==="debug"&&(await _n(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"&&(e.logsAtBottom=!0,await ti(e,{reset:!0}),No(e,!0))}function iu(){if(typeof window>"u")return"";const e=window.__CLAWDBOT_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?wn(e):lc(window.location.pathname)}function au(e){e.theme=e.settings.theme??"system",Rn(e,di(e.theme))}function Rn(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function ou(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"&&Rn(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function ru(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 lu(e,t){if(typeof window>"u")return;const n=Io(window.location.pathname,e.basePath)??"chat";ar(e,n),or(e,n,t)}function cu(e){if(typeof window>"u")return;const t=Io(window.location.pathname,e.basePath);if(!t)return;const s=new URL(window.location.href).searchParams.get("session")?.trim();s&&(e.sessionKey=s,Re(e,{...e.settings,sessionKey:s,lastActiveSessionKey:s})),ar(e,t)}function ar(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?ui(e):pi(e),t==="debug"?hi(e):fi(e),e.connected&&gi(e)}function or(e,t,n){if(typeof window>"u")return;const s=Pt($n(t,e.basePath)),i=Pt(window.location.pathname),a=new URL(window.location.href);t==="chat"&&e.sessionKey?a.searchParams.set("session",e.sessionKey):a.searchParams.delete("session"),i!==s&&(a.pathname=s),n?window.history.replaceState({},"",a.toString()):window.history.pushState({},"",a.toString())}function du(e,t,n){if(typeof window>"u")return;const s=new URL(window.location.href);s.searchParams.set("session",t),window.history.replaceState({},"",s.toString())}async function rr(e){await Promise.all([ue(e,!1),ci(e),ht(e),Bt(e),_n(e)])}async function uu(e){await Promise.all([ue(e,!0),Bo(e),Ae(e)])}async function mi(e){await Promise.all([ue(e,!1),Bt(e),An(e)])}function lr(e){return e.chatSending||!!e.chatRunId}function pu(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 cr(e){e.connected&&(e.chatMessage="",await Ac(e))}function hu(e,t,n){const s=t.trim(),i=!!(n&&n.length>0);!s&&!i||(e.chatQueue=[...e.chatQueue,{id:ei(),text:s,createdAt:Date.now(),attachments:i?n?.map(a=>({...a})):void 0}])}async function dr(e,t,n){kn(e);const s=await Sc(e,t,n?.attachments);return!s&&n?.previousDraft!=null&&(e.chatMessage=n.previousDraft),!s&&n?.previousAttachments&&(e.chatAttachments=n.previousAttachments),s&&ir(e,e.sessionKey),s&&n?.restoreDraft&&n.previousDraft?.trim()&&(e.chatMessage=n.previousDraft),s&&n?.restoreAttachments&&n.previousAttachments?.length&&(e.chatAttachments=n.previousAttachments),Sn(e),s&&!e.chatRunId&&ur(e),s}async function ur(e){if(!e.connected||lr(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await dr(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function fu(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function gu(e,t,n){if(!e.connected)return;const s=e.chatMessage,i=(t??e.chatMessage).trim(),a=e.chatAttachments??[],o=t==null?a:[],c=o.length>0;if(!(!i&&!c)){if(pu(i)){await cr(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),lr(e)){hu(e,i,o);return}await dr(e,i,{previousDraft:t==null?s:void 0,restoreDraft:!!(t&&n?.restoreDraft),attachments:c?o:void 0,previousAttachments:t==null?a:void 0,restoreAttachments:!!(t&&n?.restoreDraft)})}}async function mu(e){await Promise.all([lt(e),ht(e),Ns(e)]),Sn(e,!0)}const vu=ur;function yu(e){const t=Eo(e.sessionKey);return t?.agentId?t.agentId:e.hello?.snapshot?.sessionDefaults?.defaultAgentId?.trim()||"main"}function bu(e,t){const n=wn(e),s=encodeURIComponent(t);return n?`${n}/avatar/${s}?meta=1`:`/avatar/${s}?meta=1`}async function Ns(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=yu(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=bu(e.basePath,t);try{const s=await fetch(n,{method:"GET"});if(!s.ok){e.chatAvatarUrl=null;return}const i=await s.json(),a=typeof i.avatarUrl=="string"?i.avatarUrl.trim():"";e.chatAvatarUrl=a||null}catch{e.chatAvatarUrl=null}}const pr={CHILD:2},hr=e=>(...t)=>({_$litDirective$:e,values:t});class fr{constructor(t){}get _$isConnected(){return this._$parent._$isConnected}_$initialize(t,n,s){this.__part=t,this._$parent=n,this.__attributeIndex=s}_$resolve(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}}const{_ChildPart:wu}=Gl,st=window.ShadyDOM?.inUse&&window.ShadyDOM?.noPatch===!0?window.ShadyDOM.wrap:e=>e,Ea=()=>document.createComment(""),yt=(e,t,n)=>{const s=st(e._$startNode).parentNode,i=t===void 0?e._$endNode:t._$startNode;if(n===void 0){const a=st(s).insertBefore(Ea(),i),o=st(s).insertBefore(Ea(),i);n=new wu(a,o,e,e.options)}else{const a=st(n._$endNode).nextSibling,o=n._$parent,c=o!==e;if(c){n._$reparentDisconnectables?.(e),n._$parent=e;let l;n._$notifyConnectionChanged!==void 0&&(l=e._$isConnected)!==o._$isConnected&&n._$notifyConnectionChanged(l)}if(a!==i||c){let l=n._$startNode;for(;l!==a;){const u=st(l).nextSibling;st(s).insertBefore(l,i),l=u}}}return n},Be=(e,t,n=e)=>(e._$setValue(t,n),e),$u={},xu=(e,t=$u)=>e._$committedValue=t,ku=e=>e._$committedValue,ds=e=>{e._$clear(),e._$startNode.remove()};const Ra=(e,t,n)=>{const s=new Map;for(let i=t;i<=n;i++)s.set(e[i],i);return s};class Su extends fr{constructor(t){if(super(t),t.type!==pr.CHILD)throw new Error("repeat() can only be used in text expressions")}_getValuesAndKeys(t,n,s){let i;s===void 0?s=n:n!==void 0&&(i=n);const a=[],o=[];let c=0;for(const l of t)a[c]=i?i(l,c):c,o[c]=s(l,c),c++;return{values:o,keys:a}}render(t,n,s){return this._getValuesAndKeys(t,n,s).values}update(t,[n,s,i]){const a=ku(t),{values:o,keys:c}=this._getValuesAndKeys(n,s,i);if(!Array.isArray(a))return this._itemKeys=c,o;const l=this._itemKeys??=[],u=[];let d,p,f=0,m=a.length-1,v=0,$=o.length-1;for(;f<=m&&v<=$;)if(a[f]===null)f++;else if(a[m]===null)m--;else if(l[f]===c[v])u[v]=Be(a[f],o[v]),f++,v++;else if(l[m]===c[$])u[$]=Be(a[m],o[$]),m--,$--;else if(l[f]===c[$])u[$]=Be(a[f],o[$]),yt(t,u[$+1],a[f]),f++,$--;else if(l[m]===c[v])u[v]=Be(a[m],o[v]),yt(t,a[f],a[m]),m--,v++;else if(d===void 0&&(d=Ra(c,v,$),p=Ra(l,f,m)),!d.has(l[f]))ds(a[f]),f++;else if(!d.has(l[m]))ds(a[m]),m--;else{const k=p.get(c[v]),_=k!==void 0?a[k]:null;if(_===null){const M=yt(t,a[f]);Be(M,o[v]),u[v]=M}else u[v]=Be(_,o[v]),yt(t,a[f],_),a[k]=null;v++}for(;v<=$;){const k=yt(t,u[$+1]);Be(k,o[v]),u[v++]=k}for(;f<=m;){const k=a[f++];k!==null&&ds(k)}return this._itemKeys=c,xu(t,u),Ie}}const gr=hr(Su);function mr(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const s=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",i=t.content,a=Array.isArray(i)?i:null,o=Array.isArray(a)&&a.some(p=>{const m=String(p.type??"").toLowerCase();return m==="toolresult"||m==="tool_result"}),c=typeof t.toolName=="string"||typeof t.tool_name=="string";(s||o||c)&&(n="toolResult");let l=[];typeof t.content=="string"?l=[{type:"text",text:t.content}]:Array.isArray(t.content)?l=t.content.map(p=>({type:p.type||"text",text:p.text,name:p.name,args:p.args||p.arguments})):typeof t.text=="string"&&(l=[{type:"text",text:t.text}]);const u=typeof t.timestamp=="number"?t.timestamp:Date.now(),d=typeof t.id=="string"?t.id:void 0;return{role:n,content:l,timestamp:u,id:d}}function vi(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 vr(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}const Au=1;class yi extends fr{constructor(t){if(super(t),this._value=g,t.type!==pr.CHILD)throw new Error(`${this.constructor.directiveName}() can only be used in child bindings`)}render(t){if(t===g||t==null)return this._templateResult=void 0,this._value=t;if(t===Ie)return t;if(typeof t!="string")throw new Error(`${this.constructor.directiveName}() called with a non-string value`);if(t===this._value)return this._templateResult;this._value=t;const n=[t];return n.raw=n,this._templateResult={_$litType$:this.constructor.resultType,strings:n,values:[]}}}yi.directiveName="unsafeHTML";yi.resultType=Au;const Os=hr(yi);const{entries:yr,setPrototypeOf:Ma,isFrozen:_u,getPrototypeOf:Tu,getOwnPropertyDescriptor:Cu}=Object;let{freeze:Z,seal:ae,create:Ds}=Object,{apply:Bs,construct:Fs}=typeof Reflect<"u"&&Reflect;Z||(Z=function(t){return t});ae||(ae=function(t){return t});Bs||(Bs=function(t,n){for(var s=arguments.length,i=new Array(s>2?s-2:0),a=2;a<s;a++)i[a-2]=arguments[a];return t.apply(n,i)});Fs||(Fs=function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return new t(...s)});const Zt=X(Array.prototype.forEach),Eu=X(Array.prototype.lastIndexOf),Ia=X(Array.prototype.pop),bt=X(Array.prototype.push),Ru=X(Array.prototype.splice),on=X(String.prototype.toLowerCase),us=X(String.prototype.toString),ps=X(String.prototype.match),wt=X(String.prototype.replace),Mu=X(String.prototype.indexOf),Iu=X(String.prototype.trim),oe=X(Object.prototype.hasOwnProperty),Q=X(RegExp.prototype.test),$t=Lu(TypeError);function X(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return Bs(e,t,s)}}function Lu(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return Fs(e,n)}}function I(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:on;Ma&&Ma(e,null);let s=t.length;for(;s--;){let i=t[s];if(typeof i=="string"){const a=n(i);a!==i&&(_u(t)||(t[s]=a),i=a)}e[i]=!0}return e}function Pu(e){for(let t=0;t<e.length;t++)oe(e,t)||(e[t]=null);return e}function ge(e){const t=Ds(null);for(const[n,s]of yr(e))oe(e,n)&&(Array.isArray(s)?t[n]=Pu(s):s&&typeof s=="object"&&s.constructor===Object?t[n]=ge(s):t[n]=s);return t}function xt(e,t){for(;e!==null;){const s=Cu(e,t);if(s){if(s.get)return X(s.get);if(typeof s.value=="function")return X(s.value)}e=Tu(e)}function n(){return null}return n}const La=Z(["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"]),hs=Z(["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"]),fs=Z(["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"]),Nu=Z(["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"]),gs=Z(["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"]),Ou=Z(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Pa=Z(["#text"]),Na=Z(["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"]),ms=Z(["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"]),Oa=Z(["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"]),Xt=Z(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Du=ae(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Bu=ae(/<%[\w\W]*|[\w\W]*%>/gm),Fu=ae(/\$\{[\w\W]*/gm),Uu=ae(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ku=ae(/^aria-[\-\w]+$/),br=ae(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),zu=ae(/^(?:\w+script|data):/i),Hu=ae(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),wr=ae(/^html$/i),ju=ae(/^[a-z][.\w]*(-[.\w]+)+$/i);var Da=Object.freeze({__proto__:null,ARIA_ATTR:Ku,ATTR_WHITESPACE:Hu,CUSTOM_ELEMENT:ju,DATA_ATTR:Uu,DOCTYPE_NAME:wr,ERB_EXPR:Bu,IS_ALLOWED_URI:br,IS_SCRIPT_OR_DATA:zu,MUSTACHE_EXPR:Du,TMPLIT_EXPR:Fu});const kt={element:1,text:3,progressingInstruction:7,comment:8,document:9},Vu=function(){return typeof window>"u"?null:window},Wu=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let s=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(s=n.getAttribute(i));const a="dompurify"+(s?"#"+s:"");try{return t.createPolicy(a,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Ba=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function $r(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Vu();const t=T=>$r(T);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==kt.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const s=n,i=s.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:c,Element:l,NodeFilter:u,NamedNodeMap:d=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:f,trustedTypes:m}=e,v=l.prototype,$=xt(v,"cloneNode"),k=xt(v,"remove"),_=xt(v,"nextSibling"),M=xt(v,"childNodes"),N=xt(v,"parentNode");if(typeof o=="function"){const T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let R,C="";const{implementation:E,createNodeIterator:ve,createDocumentFragment:Nn,getElementsByTagName:On}=n,{importNode:el}=s;let Y=Ba();t.isSupported=typeof yr=="function"&&typeof N=="function"&&E&&E.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Dn,ERB_EXPR:Bn,TMPLIT_EXPR:Fn,DATA_ATTR:tl,ARIA_ATTR:nl,IS_SCRIPT_OR_DATA:sl,ATTR_WHITESPACE:Ri,CUSTOM_ELEMENT:il}=Da;let{IS_ALLOWED_URI:Mi}=Da,z=null;const Ii=I({},[...La,...hs,...fs,...gs,...Pa]);let j=null;const Li=I({},[...Na,...ms,...Oa,...Xt]);let F=Object.seal(Ds(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}})),ft=null,Un=null;const Qe=Object.seal(Ds(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Pi=!0,Kn=!0,Ni=!1,Oi=!0,Je=!1,Kt=!0,Ne=!1,zn=!1,Hn=!1,Ze=!1,zt=!1,Ht=!1,Di=!0,Bi=!1;const al="user-content-";let jn=!0,gt=!1,Xe={},pe=null;const Vn=I({},["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 Fi=null;const Ui=I({},["audio","video","img","source","image","track"]);let Wn=null;const Ki=I({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),jt="http://www.w3.org/1998/Math/MathML",Vt="http://www.w3.org/2000/svg",ye="http://www.w3.org/1999/xhtml";let et=ye,qn=!1,Gn=null;const ol=I({},[jt,Vt,ye],us);let Wt=I({},["mi","mo","mn","ms","mtext"]),qt=I({},["annotation-xml"]);const rl=I({},["title","style","font","a","script"]);let mt=null;const ll=["application/xhtml+xml","text/html"],cl="text/html";let K=null,tt=null;const dl=n.createElement("form"),zi=function(h){return h instanceof RegExp||h instanceof Function},Yn=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(tt&&tt===h)){if((!h||typeof h!="object")&&(h={}),h=ge(h),mt=ll.indexOf(h.PARSER_MEDIA_TYPE)===-1?cl:h.PARSER_MEDIA_TYPE,K=mt==="application/xhtml+xml"?us:on,z=oe(h,"ALLOWED_TAGS")?I({},h.ALLOWED_TAGS,K):Ii,j=oe(h,"ALLOWED_ATTR")?I({},h.ALLOWED_ATTR,K):Li,Gn=oe(h,"ALLOWED_NAMESPACES")?I({},h.ALLOWED_NAMESPACES,us):ol,Wn=oe(h,"ADD_URI_SAFE_ATTR")?I(ge(Ki),h.ADD_URI_SAFE_ATTR,K):Ki,Fi=oe(h,"ADD_DATA_URI_TAGS")?I(ge(Ui),h.ADD_DATA_URI_TAGS,K):Ui,pe=oe(h,"FORBID_CONTENTS")?I({},h.FORBID_CONTENTS,K):Vn,ft=oe(h,"FORBID_TAGS")?I({},h.FORBID_TAGS,K):ge({}),Un=oe(h,"FORBID_ATTR")?I({},h.FORBID_ATTR,K):ge({}),Xe=oe(h,"USE_PROFILES")?h.USE_PROFILES:!1,Pi=h.ALLOW_ARIA_ATTR!==!1,Kn=h.ALLOW_DATA_ATTR!==!1,Ni=h.ALLOW_UNKNOWN_PROTOCOLS||!1,Oi=h.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Je=h.SAFE_FOR_TEMPLATES||!1,Kt=h.SAFE_FOR_XML!==!1,Ne=h.WHOLE_DOCUMENT||!1,Ze=h.RETURN_DOM||!1,zt=h.RETURN_DOM_FRAGMENT||!1,Ht=h.RETURN_TRUSTED_TYPE||!1,Hn=h.FORCE_BODY||!1,Di=h.SANITIZE_DOM!==!1,Bi=h.SANITIZE_NAMED_PROPS||!1,jn=h.KEEP_CONTENT!==!1,gt=h.IN_PLACE||!1,Mi=h.ALLOWED_URI_REGEXP||br,et=h.NAMESPACE||ye,Wt=h.MATHML_TEXT_INTEGRATION_POINTS||Wt,qt=h.HTML_INTEGRATION_POINTS||qt,F=h.CUSTOM_ELEMENT_HANDLING||{},h.CUSTOM_ELEMENT_HANDLING&&zi(h.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(F.tagNameCheck=h.CUSTOM_ELEMENT_HANDLING.tagNameCheck),h.CUSTOM_ELEMENT_HANDLING&&zi(h.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(F.attributeNameCheck=h.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),h.CUSTOM_ELEMENT_HANDLING&&typeof h.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(F.allowCustomizedBuiltInElements=h.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Je&&(Kn=!1),zt&&(Ze=!0),Xe&&(z=I({},Pa),j=[],Xe.html===!0&&(I(z,La),I(j,Na)),Xe.svg===!0&&(I(z,hs),I(j,ms),I(j,Xt)),Xe.svgFilters===!0&&(I(z,fs),I(j,ms),I(j,Xt)),Xe.mathMl===!0&&(I(z,gs),I(j,Oa),I(j,Xt))),h.ADD_TAGS&&(typeof h.ADD_TAGS=="function"?Qe.tagCheck=h.ADD_TAGS:(z===Ii&&(z=ge(z)),I(z,h.ADD_TAGS,K))),h.ADD_ATTR&&(typeof h.ADD_ATTR=="function"?Qe.attributeCheck=h.ADD_ATTR:(j===Li&&(j=ge(j)),I(j,h.ADD_ATTR,K))),h.ADD_URI_SAFE_ATTR&&I(Wn,h.ADD_URI_SAFE_ATTR,K),h.FORBID_CONTENTS&&(pe===Vn&&(pe=ge(pe)),I(pe,h.FORBID_CONTENTS,K)),h.ADD_FORBID_CONTENTS&&(pe===Vn&&(pe=ge(pe)),I(pe,h.ADD_FORBID_CONTENTS,K)),jn&&(z["#text"]=!0),Ne&&I(z,["html","head","body"]),z.table&&(I(z,["tbody"]),delete ft.tbody),h.TRUSTED_TYPES_POLICY){if(typeof h.TRUSTED_TYPES_POLICY.createHTML!="function")throw $t('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof h.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw $t('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');R=h.TRUSTED_TYPES_POLICY,C=R.createHTML("")}else R===void 0&&(R=Wu(m,i)),R!==null&&typeof C=="string"&&(C=R.createHTML(""));Z&&Z(h),tt=h}},Hi=I({},[...hs,...fs,...Nu]),ji=I({},[...gs,...Ou]),ul=function(h){let x=N(h);(!x||!x.tagName)&&(x={namespaceURI:et,tagName:"template"});const A=on(h.tagName),B=on(x.tagName);return Gn[h.namespaceURI]?h.namespaceURI===Vt?x.namespaceURI===ye?A==="svg":x.namespaceURI===jt?A==="svg"&&(B==="annotation-xml"||Wt[B]):!!Hi[A]:h.namespaceURI===jt?x.namespaceURI===ye?A==="math":x.namespaceURI===Vt?A==="math"&&qt[B]:!!ji[A]:h.namespaceURI===ye?x.namespaceURI===Vt&&!qt[B]||x.namespaceURI===jt&&!Wt[B]?!1:!ji[A]&&(rl[A]||!Hi[A]):!!(mt==="application/xhtml+xml"&&Gn[h.namespaceURI]):!1},he=function(h){bt(t.removed,{element:h});try{N(h).removeChild(h)}catch{k(h)}},Oe=function(h,x){try{bt(t.removed,{attribute:x.getAttributeNode(h),from:x})}catch{bt(t.removed,{attribute:null,from:x})}if(x.removeAttribute(h),h==="is")if(Ze||zt)try{he(x)}catch{}else try{x.setAttribute(h,"")}catch{}},Vi=function(h){let x=null,A=null;if(Hn)h="<remove></remove>"+h;else{const U=ps(h,/^[\r\n\t ]+/);A=U&&U[0]}mt==="application/xhtml+xml"&&et===ye&&(h='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+h+"</body></html>");const B=R?R.createHTML(h):h;if(et===ye)try{x=new f().parseFromString(B,mt)}catch{}if(!x||!x.documentElement){x=E.createDocument(et,"template",null);try{x.documentElement.innerHTML=qn?C:B}catch{}}const W=x.body||x.documentElement;return h&&A&&W.insertBefore(n.createTextNode(A),W.childNodes[0]||null),et===ye?On.call(x,Ne?"html":"body")[0]:Ne?x.documentElement:W},Wi=function(h){return ve.call(h.ownerDocument||h,h,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Qn=function(h){return h instanceof p&&(typeof h.nodeName!="string"||typeof h.textContent!="string"||typeof h.removeChild!="function"||!(h.attributes instanceof d)||typeof h.removeAttribute!="function"||typeof h.setAttribute!="function"||typeof h.namespaceURI!="string"||typeof h.insertBefore!="function"||typeof h.hasChildNodes!="function")},qi=function(h){return typeof c=="function"&&h instanceof c};function be(T,h,x){Zt(T,A=>{A.call(t,h,x,tt)})}const Gi=function(h){let x=null;if(be(Y.beforeSanitizeElements,h,null),Qn(h))return he(h),!0;const A=K(h.nodeName);if(be(Y.uponSanitizeElement,h,{tagName:A,allowedTags:z}),Kt&&h.hasChildNodes()&&!qi(h.firstElementChild)&&Q(/<[/\w!]/g,h.innerHTML)&&Q(/<[/\w!]/g,h.textContent)||h.nodeType===kt.progressingInstruction||Kt&&h.nodeType===kt.comment&&Q(/<[/\w]/g,h.data))return he(h),!0;if(!(Qe.tagCheck instanceof Function&&Qe.tagCheck(A))&&(!z[A]||ft[A])){if(!ft[A]&&Qi(A)&&(F.tagNameCheck instanceof RegExp&&Q(F.tagNameCheck,A)||F.tagNameCheck instanceof Function&&F.tagNameCheck(A)))return!1;if(jn&&!pe[A]){const B=N(h)||h.parentNode,W=M(h)||h.childNodes;if(W&&B){const U=W.length;for(let ee=U-1;ee>=0;--ee){const we=$(W[ee],!0);we.__removalCount=(h.__removalCount||0)+1,B.insertBefore(we,_(h))}}}return he(h),!0}return h instanceof l&&!ul(h)||(A==="noscript"||A==="noembed"||A==="noframes")&&Q(/<\/no(script|embed|frames)/i,h.innerHTML)?(he(h),!0):(Je&&h.nodeType===kt.text&&(x=h.textContent,Zt([Dn,Bn,Fn],B=>{x=wt(x,B," ")}),h.textContent!==x&&(bt(t.removed,{element:h.cloneNode()}),h.textContent=x)),be(Y.afterSanitizeElements,h,null),!1)},Yi=function(h,x,A){if(Di&&(x==="id"||x==="name")&&(A in n||A in dl))return!1;if(!(Kn&&!Un[x]&&Q(tl,x))){if(!(Pi&&Q(nl,x))){if(!(Qe.attributeCheck instanceof Function&&Qe.attributeCheck(x,h))){if(!j[x]||Un[x]){if(!(Qi(h)&&(F.tagNameCheck instanceof RegExp&&Q(F.tagNameCheck,h)||F.tagNameCheck instanceof Function&&F.tagNameCheck(h))&&(F.attributeNameCheck instanceof RegExp&&Q(F.attributeNameCheck,x)||F.attributeNameCheck instanceof Function&&F.attributeNameCheck(x,h))||x==="is"&&F.allowCustomizedBuiltInElements&&(F.tagNameCheck instanceof RegExp&&Q(F.tagNameCheck,A)||F.tagNameCheck instanceof Function&&F.tagNameCheck(A))))return!1}else if(!Wn[x]){if(!Q(Mi,wt(A,Ri,""))){if(!((x==="src"||x==="xlink:href"||x==="href")&&h!=="script"&&Mu(A,"data:")===0&&Fi[h])){if(!(Ni&&!Q(sl,wt(A,Ri,"")))){if(A)return!1}}}}}}}return!0},Qi=function(h){return h!=="annotation-xml"&&ps(h,il)},Ji=function(h){be(Y.beforeSanitizeAttributes,h,null);const{attributes:x}=h;if(!x||Qn(h))return;const A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:j,forceKeepAttr:void 0};let B=x.length;for(;B--;){const W=x[B],{name:U,namespaceURI:ee,value:we}=W,nt=K(U),Jn=we;let V=U==="value"?Jn:Iu(Jn);if(A.attrName=nt,A.attrValue=V,A.keepAttr=!0,A.forceKeepAttr=void 0,be(Y.uponSanitizeAttribute,h,A),V=A.attrValue,Bi&&(nt==="id"||nt==="name")&&(Oe(U,h),V=al+V),Kt&&Q(/((--!?|])>)|<\/(style|title|textarea)/i,V)){Oe(U,h);continue}if(nt==="attributename"&&ps(V,"href")){Oe(U,h);continue}if(A.forceKeepAttr)continue;if(!A.keepAttr){Oe(U,h);continue}if(!Oi&&Q(/\/>/i,V)){Oe(U,h);continue}Je&&Zt([Dn,Bn,Fn],Xi=>{V=wt(V,Xi," ")});const Zi=K(h.nodeName);if(!Yi(Zi,nt,V)){Oe(U,h);continue}if(R&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!ee)switch(m.getAttributeType(Zi,nt)){case"TrustedHTML":{V=R.createHTML(V);break}case"TrustedScriptURL":{V=R.createScriptURL(V);break}}if(V!==Jn)try{ee?h.setAttributeNS(ee,U,V):h.setAttribute(U,V),Qn(h)?he(h):Ia(t.removed)}catch{Oe(U,h)}}be(Y.afterSanitizeAttributes,h,null)},pl=function T(h){let x=null;const A=Wi(h);for(be(Y.beforeSanitizeShadowDOM,h,null);x=A.nextNode();)be(Y.uponSanitizeShadowNode,x,null),Gi(x),Ji(x),x.content instanceof a&&T(x.content);be(Y.afterSanitizeShadowDOM,h,null)};return t.sanitize=function(T){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,A=null,B=null,W=null;if(qn=!T,qn&&(T="<!-->"),typeof T!="string"&&!qi(T))if(typeof T.toString=="function"){if(T=T.toString(),typeof T!="string")throw $t("dirty is not a string, aborting")}else throw $t("toString is not a function");if(!t.isSupported)return T;if(zn||Yn(h),t.removed=[],typeof T=="string"&&(gt=!1),gt){if(T.nodeName){const we=K(T.nodeName);if(!z[we]||ft[we])throw $t("root node is forbidden and cannot be sanitized in-place")}}else if(T instanceof c)x=Vi("<!---->"),A=x.ownerDocument.importNode(T,!0),A.nodeType===kt.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?x=A:x.appendChild(A);else{if(!Ze&&!Je&&!Ne&&T.indexOf("<")===-1)return R&&Ht?R.createHTML(T):T;if(x=Vi(T),!x)return Ze?null:Ht?C:""}x&&Hn&&he(x.firstChild);const U=Wi(gt?T:x);for(;B=U.nextNode();)Gi(B),Ji(B),B.content instanceof a&&pl(B.content);if(gt)return T;if(Ze){if(zt)for(W=Nn.call(x.ownerDocument);x.firstChild;)W.appendChild(x.firstChild);else W=x;return(j.shadowroot||j.shadowrootmode)&&(W=el.call(s,W,!0)),W}let ee=Ne?x.outerHTML:x.innerHTML;return Ne&&z["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&Q(wr,x.ownerDocument.doctype.name)&&(ee="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
|
|
30
|
+
`+ee),Je&&Zt([Dn,Bn,Fn],we=>{ee=wt(ee,we," ")}),R&&Ht?R.createHTML(ee):ee},t.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Yn(T),zn=!0},t.clearConfig=function(){tt=null,zn=!1},t.isValidAttribute=function(T,h,x){tt||Yn({});const A=K(T),B=K(h);return Yi(A,B,x)},t.addHook=function(T,h){typeof h=="function"&&bt(Y[T],h)},t.removeHook=function(T,h){if(h!==void 0){const x=Eu(Y[T],h);return x===-1?void 0:Ru(Y[T],x,1)[0]}return Ia(Y[T])},t.removeHooks=function(T){Y[T]=[]},t.removeAllHooks=function(){Y=Ba()},t}var Us=$r();function bi(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ye=bi();function xr(e){Ye=e}var Ct={exec:()=>null};function P(e,t=""){let n=typeof e=="string"?e:e.source,s={replace:(i,a)=>{let o=typeof a=="string"?a:a.source;return o=o.replace(J.caret,"$1"),n=n.replace(i,o),s},getRegex:()=>new RegExp(n,t)};return s}var qu=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),J={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")},Gu=/^(?:[ \t]*(?:\n|$))+/,Yu=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Qu=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ut=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ju=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,wi=/(?:[*+-]|\d{1,9}[.)])/,kr=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Sr=P(kr).replace(/bull/g,wi).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(),Zu=P(kr).replace(/bull/g,wi).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(),$i=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Xu=/^[^\n]+/,xi=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ep=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",xi).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),tp=P(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,wi).getRegex(),Mn="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",ki=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,np=P("^ {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",ki).replace("tag",Mn).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ar=P($i).replace("hr",Ut).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",Mn).getRegex(),sp=P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ar).getRegex(),Si={blockquote:sp,code:Yu,def:ep,fences:Qu,heading:Ju,hr:Ut,html:np,lheading:Sr,list:tp,newline:Gu,paragraph:Ar,table:Ct,text:Xu},Fa=P("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ut).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",Mn).getRegex(),ip={...Si,lheading:Zu,table:Fa,paragraph:P($i).replace("hr",Ut).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Fa).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",Mn).getRegex()},ap={...Si,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ki).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:Ct,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P($i).replace("hr",Ut).replace("heading",` *#{1,6} *[^
|
|
31
|
+
]`).replace("lheading",Sr).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},op=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,rp=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,_r=/^( {2,}|\\)\n(?!\s*$)/,lp=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,In=/[\p{P}\p{S}]/u,Ai=/[\s\p{P}\p{S}]/u,Tr=/[^\s\p{P}\p{S}]/u,cp=P(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ai).getRegex(),Cr=/(?!~)[\p{P}\p{S}]/u,dp=/(?!~)[\s\p{P}\p{S}]/u,up=/(?:[^\s\p{P}\p{S}]|~)/u,pp=P(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",qu?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Er=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,hp=P(Er,"u").replace(/punct/g,In).getRegex(),fp=P(Er,"u").replace(/punct/g,Cr).getRegex(),Rr="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",gp=P(Rr,"gu").replace(/notPunctSpace/g,Tr).replace(/punctSpace/g,Ai).replace(/punct/g,In).getRegex(),mp=P(Rr,"gu").replace(/notPunctSpace/g,up).replace(/punctSpace/g,dp).replace(/punct/g,Cr).getRegex(),vp=P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Tr).replace(/punctSpace/g,Ai).replace(/punct/g,In).getRegex(),yp=P(/\\(punct)/,"gu").replace(/punct/g,In).getRegex(),bp=P(/^<(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(),wp=P(ki).replace("(?:-->|$)","-->").getRegex(),$p=P("^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",wp).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),hn=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,xp=P(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",hn).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Mr=P(/^!?\[(label)\]\[(ref)\]/).replace("label",hn).replace("ref",xi).getRegex(),Ir=P(/^!?\[(ref)\](?:\[\])?/).replace("ref",xi).getRegex(),kp=P("reflink|nolink(?!\\()","g").replace("reflink",Mr).replace("nolink",Ir).getRegex(),Ua=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,_i={_backpedal:Ct,anyPunctuation:yp,autolink:bp,blockSkip:pp,br:_r,code:rp,del:Ct,emStrongLDelim:hp,emStrongRDelimAst:gp,emStrongRDelimUnd:vp,escape:op,link:xp,nolink:Ir,punctuation:cp,reflink:Mr,reflinkSearch:kp,tag:$p,text:lp,url:Ct},Sp={..._i,link:P(/^!?\[(label)\]\((.*?)\)/).replace("label",hn).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",hn).getRegex()},Ks={..._i,emStrongRDelimAst:mp,emStrongLDelim:fp,url:P(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ua).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:P(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Ua).getRegex()},Ap={...Ks,br:P(_r).replace("{2,}","*").getRegex(),text:P(Ks.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},en={normal:Si,gfm:ip,pedantic:ap},St={normal:_i,gfm:Ks,breaks:Ap,pedantic:Sp},_p={"&":"&","<":"<",">":">",'"':""","'":"'"},Ka=e=>_p[e];function xe(e,t){if(t){if(J.escapeTest.test(e))return e.replace(J.escapeReplace,Ka)}else if(J.escapeTestNoEncode.test(e))return e.replace(J.escapeReplaceNoEncode,Ka);return e}function za(e){try{e=encodeURI(e).replace(J.percentDecode,"%")}catch{return null}return e}function Ha(e,t){let n=e.replace(J.findPipe,(a,o,c)=>{let l=!1,u=o;for(;--u>=0&&c[u]==="\\";)l=!l;return l?"|":" |"}),s=n.split(J.splitPipe),i=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;i<s.length;i++)s[i]=s[i].trim().replace(J.slashPipe,"|");return s}function At(e,t,n){let s=e.length;if(s===0)return"";let i=0;for(;i<s&&e.charAt(s-i-1)===t;)i++;return e.slice(0,s-i)}function Tp(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let s=0;s<e.length;s++)if(e[s]==="\\")s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return n>0?-2:-1}function ja(e,t,n,s,i){let a=t.href,o=t.title||null,c=e[1].replace(i.other.outputLinkReplace,"$1");s.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:a,title:o,text:c,tokens:s.inlineTokens(c)};return s.state.inLink=!1,l}function Cp(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let i=s[1];return t.split(`
|
|
32
32
|
`).map(a=>{let o=a.match(n.other.beginningSpace);if(o===null)return a;let[c]=o;return c.length>=i.length?a.slice(i.length):a}).join(`
|
|
33
33
|
`)}var fn=class{options;rules;lexer;constructor(e){this.options=e||Ye}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:At(n,`
|
|
34
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=
|
|
34
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=Cp(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=At(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:At(t[0],`
|
|
35
35
|
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=At(t[0],`
|
|
36
36
|
`).split(`
|
|
37
|
-
`),s="",i="",a=[];for(;n.length>0;){let o=!1,c=[],
|
|
37
|
+
`),s="",i="",a=[];for(;n.length>0;){let o=!1,c=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))c.push(n[l]),o=!0;else if(!o)c.push(n[l]);else break;n=n.slice(l);let u=c.join(`
|
|
38
38
|
`),d=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
39
39
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
|
|
40
40
|
${u}`:u,i=i?`${i}
|
|
@@ -43,16 +43,16 @@ ${d}`:d;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
43
43
|
`),$=this.blockquote(v);a[a.length-1]=$,s=s.substring(0,s.length-m.raw.length)+$.raw,i=i.substring(0,i.length-m.text.length)+$.text;break}else if(f?.type==="list"){let m=f,v=m.raw+`
|
|
44
44
|
`+n.join(`
|
|
45
45
|
`),$=this.list(v);a[a.length-1]=$,s=s.substring(0,s.length-f.raw.length)+$.raw,i=i.substring(0,i.length-m.raw.length)+$.raw,n=v.substring(a.at(-1).raw.length).split(`
|
|
46
|
-
`);continue}}return{type:"blockquote",raw:s,tokens:a,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),s=n.length>1,i={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let
|
|
46
|
+
`);continue}}return{type:"blockquote",raw:s,tokens:a,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),s=n.length>1,i={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let l=!1,u="",d="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;u=t[0],e=e.substring(u.length);let p=t[2].split(`
|
|
47
47
|
`,1)[0].replace(this.rules.other.listReplaceTabs,$=>" ".repeat(3*$.length)),f=e.split(`
|
|
48
48
|
`,1)[0],m=!p.trim(),v=0;if(this.options.pedantic?(v=2,d=p.trimStart()):m?v=t[1].length+1:(v=t[2].search(this.rules.other.nonSpaceChar),v=v>4?1:v,d=p.slice(v),v+=t[1].length),m&&this.rules.other.blankLine.test(f)&&(u+=f+`
|
|
49
|
-
`,e=e.substring(f.length+1),
|
|
49
|
+
`,e=e.substring(f.length+1),l=!0),!l){let $=this.rules.other.nextBulletRegex(v),k=this.rules.other.hrRegex(v),_=this.rules.other.fencesBeginRegex(v),M=this.rules.other.headingBeginRegex(v),N=this.rules.other.htmlBeginRegex(v);for(;e;){let R=e.split(`
|
|
50
50
|
`,1)[0],C;if(f=R,this.options.pedantic?(f=f.replace(this.rules.other.listReplaceNesting," "),C=f):C=f.replace(this.rules.other.tabCharGlobal," "),_.test(f)||M.test(f)||N.test(f)||$.test(f)||k.test(f))break;if(C.search(this.rules.other.nonSpaceChar)>=v||!f.trim())d+=`
|
|
51
51
|
`+C.slice(v);else{if(m||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||_.test(p)||M.test(p)||k.test(p))break;d+=`
|
|
52
52
|
`+f}!m&&!f.trim()&&(m=!0),u+=R+`
|
|
53
|
-
`,e=e.substring(R.length+1),p=C.slice(v)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(u)&&(o=!0)),i.items.push({type:"list_item",raw:u,task:!!this.options.gfm&&this.rules.other.listIsTask.test(d),loose:!1,text:d,tokens:[]}),i.raw+=u}let c=i.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let
|
|
54
|
-
`):[],a={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let o of s)this.rules.other.tableAlignRight.test(o)?a.align.push("right"):this.rules.other.tableAlignCenter.test(o)?a.align.push("center"):this.rules.other.tableAlignLeft.test(o)?a.align.push("left"):a.align.push(null);for(let o=0;o<n.length;o++)a.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:a.align[o]});for(let o of i)a.rows.push(
|
|
55
|
-
`?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 a=At(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{let a=
|
|
53
|
+
`,e=e.substring(R.length+1),p=C.slice(v)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(u)&&(o=!0)),i.items.push({type:"list_item",raw:u,task:!!this.options.gfm&&this.rules.other.listIsTask.test(d),loose:!1,text:d,tokens:[]}),i.raw+=u}let c=i.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let l of i.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,""),l.tokens[0]?.type==="text"||l.tokens[0]?.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 d=this.lexer.inlineQueue.length-1;d>=0;d--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[d].src)){this.lexer.inlineQueue[d].src=this.lexer.inlineQueue[d].src.replace(this.rules.other.listReplaceTask,"");break}}let u=this.rules.other.listTaskCheckbox.exec(l.raw);if(u){let d={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};l.checked=d.checked,i.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=d.raw+l.tokens[0].raw,l.tokens[0].text=d.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(d)):l.tokens.unshift({type:"paragraph",raw:d.raw,text:d.raw,tokens:[d]}):l.tokens.unshift(d)}}if(!i.loose){let u=l.tokens.filter(p=>p.type==="space"),d=u.length>0&&u.some(p=>this.rules.other.anyLine.test(p.raw));i.loose=d}}if(i.loose)for(let l of i.items){l.loose=!0;for(let u of l.tokens)u.type==="text"&&(u.type="paragraph")}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:s,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Ha(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
54
|
+
`):[],a={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let o of s)this.rules.other.tableAlignRight.test(o)?a.align.push("right"):this.rules.other.tableAlignCenter.test(o)?a.align.push("center"):this.rules.other.tableAlignLeft.test(o)?a.align.push("left"):a.align.push(null);for(let o=0;o<n.length;o++)a.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:a.align[o]});for(let o of i)a.rows.push(Ha(o,a.header.length).map((c,l)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:a.align[l]})));return a}}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)===`
|
|
55
|
+
`?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 a=At(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{let a=Tp(t[2],"()");if(a===-2)return;if(a>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+a;t[2]=t[2].substring(0,a),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let s=t[2],i="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(s);a&&(s=a[1],i=a[3])}else i=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),ja(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[s.toLowerCase()];if(!i){let a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return ja(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!(!s||s[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[2])||!n||this.rules.inline.punctuation.exec(n))){let i=[...s[0]].length-1,a,o,c=i,l=0,u=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,t=t.slice(-1*e.length+i);(s=u.exec(t))!=null;){if(a=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!a)continue;if(o=[...a].length,s[3]||s[4]){c+=o;continue}else if((s[5]||s[6])&&i%3&&!((i+o)%3)){l+=o;continue}if(c-=o,c>0)continue;o=Math.min(o,o+c+l);let d=[...s[0]][0].length,p=e.slice(0,i+s.index+d+o);if(Math.min(i,o)%2){let m=p.slice(1,-1);return{type:"em",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}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," "),s=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,s;if(t[2]==="@")n=t[0],s="mailto:"+n;else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},ce=class zs{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ye,this.options.tokenizer=this.options.tokenizer||new fn,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:J,block:en.normal,inline:St.normal};this.options.pedantic?(n.block=en.pedantic,n.inline=St.pedantic):this.options.gfm&&(n.block=en.gfm,this.options.breaks?n.inline=St.breaks:n.inline=St.gfm),this.tokenizer.rules=n}static get rules(){return{block:en,inline:St}}static lex(t,n){return new zs(n).lex(t)}static lexInline(t,n){return new zs(n).inlineTokens(t)}lex(t){t=t.replace(J.carriageReturn,`
|
|
56
56
|
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],s=!1){for(this.options.pedantic&&(t=t.replace(J.tabCharGlobal," ").replace(J.spaceLine,""));t;){let i;if(this.options.extensions?.block?.some(o=>(i=o.call({lexer:this},t,n))?(t=t.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(t)){t=t.substring(i.raw.length);let o=n.at(-1);i.raw.length===1&&o!==void 0?o.raw+=`
|
|
57
57
|
`:n.push(i);continue}if(i=this.tokenizer.code(t)){t=t.substring(i.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
58
58
|
`)?"":`
|
|
@@ -60,13 +60,13 @@ ${d}`:d;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
60
60
|
`+i.text,this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(i=this.tokenizer.fences(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.heading(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.hr(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.blockquote(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.list(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.html(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.def(t)){t=t.substring(i.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
61
61
|
`)?"":`
|
|
62
62
|
`)+i.raw,o.text+=`
|
|
63
|
-
`+i.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},n.push(i));continue}if(i=this.tokenizer.table(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(t)){t=t.substring(i.raw.length),n.push(i);continue}let a=t;if(this.options.extensions?.startBlock){let o=1/0,c=t.slice(1),
|
|
63
|
+
`+i.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},n.push(i));continue}if(i=this.tokenizer.table(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(t)){t=t.substring(i.raw.length),n.push(i);continue}let a=t;if(this.options.extensions?.startBlock){let o=1/0,c=t.slice(1),l;this.options.extensions.startBlock.forEach(u=>{l=u.call({lexer:this},c),typeof l=="number"&&l>=0&&(o=Math.min(o,l))}),o<1/0&&o>=0&&(a=t.substring(0,o+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let o=n.at(-1);s&&o?.type==="paragraph"?(o.raw+=(o.raw.endsWith(`
|
|
64
64
|
`)?"":`
|
|
65
65
|
`)+i.raw,o.text+=`
|
|
66
66
|
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i),s=a.length!==t.length,t=t.substring(i.raw.length);continue}if(i=this.tokenizer.text(t)){t=t.substring(i.raw.length);let o=n.at(-1);o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
67
67
|
`)?"":`
|
|
68
68
|
`)+i.raw,o.text+=`
|
|
69
|
-
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(t){let o="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let s=t,i=null;if(this.tokens.links){let
|
|
69
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(t){let o="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let s=t,i=null;if(this.tokens.links){let l=Object.keys(this.tokens.links);if(l.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)l.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,i.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let a;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)a=i[2]?i[2].length:0,s=s.slice(0,i.index+a)+"["+"a".repeat(i[0].length-a-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let o=!1,c="";for(;t;){o||(c=""),o=!1;let l;if(this.options.extensions?.inline?.some(d=>(l=d.call({lexer:this},t,n))?(t=t.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.escape(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.tag(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.link(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(l.raw.length);let d=n.at(-1);l.type==="text"&&d?.type==="text"?(d.raw+=l.raw,d.text+=l.text):n.push(l);continue}if(l=this.tokenizer.emStrong(t,s,c)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.codespan(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.br(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.del(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.autolink(t)){t=t.substring(l.raw.length),n.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(t))){t=t.substring(l.raw.length),n.push(l);continue}let u=t;if(this.options.extensions?.startInline){let d=1/0,p=t.slice(1),f;this.options.extensions.startInline.forEach(m=>{f=m.call({lexer:this},p),typeof f=="number"&&f>=0&&(d=Math.min(d,f))}),d<1/0&&d>=0&&(u=t.substring(0,d+1))}if(l=this.tokenizer.inlineText(u)){t=t.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(c=l.raw.slice(-1)),o=!0;let d=n.at(-1);d?.type==="text"?(d.raw+=l.raw,d.text+=l.text):n.push(l);continue}if(t){let d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}},gn=class{options;parser;constructor(e){this.options=e||Ye}space(e){return""}code({text:e,lang:t,escaped:n}){let s=(t||"").match(J.notSpaceStart)?.[0],i=e.replace(J.endingNewline,"")+`
|
|
70
70
|
`;return s?'<pre><code class="language-'+xe(s)+'">'+(n?i:xe(i,!0))+`</code></pre>
|
|
71
71
|
`:"<pre><code>"+(n?i:xe(i,!0))+`</code></pre>
|
|
72
72
|
`}blockquote({tokens:e}){return`<blockquote>
|
|
@@ -84,29 +84,50 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
84
84
|
`}tablerow({text:e}){return`<tr>
|
|
85
85
|
${e}</tr>
|
|
86
86
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
87
|
-
`}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>${xe(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),i=
|
|
88
|
-
Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+xe(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},Ge=new
|
|
87
|
+
`}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>${xe(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),i=za(e);if(i===null)return s;e=i;let a='<a href="'+e+'"';return t&&(a+=' title="'+xe(t)+'"'),a+=">"+s+"</a>",a}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let i=za(e);if(i===null)return xe(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${xe(t)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:xe(e.text)}},Ti=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}},de=class Hs{options;renderer;textRenderer;constructor(t){this.options=t||Ye,this.options.renderer=this.options.renderer||new gn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ti}static parse(t,n){return new Hs(n).parse(t)}static parseInline(t,n){return new Hs(n).parseInline(t)}parse(t){let n="";for(let s=0;s<t.length;s++){let i=t[s];if(this.options.extensions?.renderers?.[i.type]){let o=i,c=this.options.extensions.renderers[o.type].call({parser:this},o);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=c||"";continue}}let a=i;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 o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(t,n=this.renderer){let s="";for(let i=0;i<t.length;i++){let a=t[i];if(this.options.extensions?.renderers?.[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)){s+=c||"";continue}}let o=a;switch(o.type){case"escape":{s+=n.text(o);break}case"html":{s+=n.html(o);break}case"link":{s+=n.link(o);break}case"image":{s+=n.image(o);break}case"checkbox":{s+=n.checkbox(o);break}case"strong":{s+=n.strong(o);break}case"em":{s+=n.em(o);break}case"codespan":{s+=n.codespan(o);break}case"br":{s+=n.br(o);break}case"del":{s+=n.del(o);break}case"text":{s+=n.text(o);break}default:{let c='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}},_t=class{options;block;constructor(e){this.options=e||Ye}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?ce.lex:ce.lexInline}provideParser(){return this.block?de.parse:de.parseInline}},Ep=class{defaults=bi();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=de;Renderer=gn;TextRenderer=Ti;Lexer=ce;Tokenizer=fn;Hooks=_t;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{let i=s;for(let a of i.header)n=n.concat(this.walkTokens(a.tokens,t));for(let a of i.rows)for(let o of a)n=n.concat(this.walkTokens(o.tokens,t));break}case"list":{let i=s;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=s;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(a=>{let o=i[a].flat(1/0);n=n.concat(this.walkTokens(o,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let a=t.renderers[i.name];a?t.renderers[i.name]=function(...o){let c=i.renderer.apply(this,o);return c===!1&&(c=a.apply(this,o)),c}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=t[i.level];a?a.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),s.extensions=t),n.renderer){let i=this.defaults.renderer||new gn(this.defaults);for(let a in n.renderer){if(!(a in i))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,c=n.renderer[o],l=i[o];i[o]=(...u)=>{let d=c.apply(i,u);return d===!1&&(d=l.apply(i,u)),d||""}}s.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new fn(this.defaults);for(let a in n.tokenizer){if(!(a in i))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,c=n.tokenizer[o],l=i[o];i[o]=(...u)=>{let d=c.apply(i,u);return d===!1&&(d=l.apply(i,u)),d}}s.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new _t;for(let a in n.hooks){if(!(a in i))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,c=n.hooks[o],l=i[o];_t.passThroughHooks.has(a)?i[o]=u=>{if(this.defaults.async&&_t.passThroughHooksRespectAsync.has(a))return(async()=>{let p=await c.call(i,u);return l.call(i,p)})();let d=c.call(i,u);return l.call(i,d)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let p=await c.apply(i,u);return p===!1&&(p=await l.apply(i,u)),p})();let d=c.apply(i,u);return d===!1&&(d=l.apply(i,u)),d}}s.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,a=n.walkTokens;s.walkTokens=function(o){let c=[];return c.push(a.call(this,o)),i&&(c=c.concat(i.call(this,o))),c}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ce.lex(e,t??this.defaults)}parser(e,t){return de.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let s={...n},i={...this.defaults,...s},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&s.async===!1)return a(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 a(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,c=await(i.hooks?await i.hooks.provideLexer():e?ce.lex:ce.lexInline)(o,i),l=i.hooks?await i.hooks.processAllTokens(c):c;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():e?de.parse:de.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let o=(i.hooks?i.hooks.provideLexer():e?ce.lex:ce.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let c=(i.hooks?i.hooks.provideParser():e?de.parse:de.parseInline)(o,i);return i.hooks&&(c=i.hooks.postprocess(c)),c}catch(o){return a(o)}}}onError(e,t){return n=>{if(n.message+=`
|
|
88
|
+
Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+xe(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},Ge=new Ep;function O(e,t){return Ge.parse(e,t)}O.options=O.setOptions=function(e){return Ge.setOptions(e),O.defaults=Ge.defaults,xr(O.defaults),O};O.getDefaults=bi;O.defaults=Ye;O.use=function(...e){return Ge.use(...e),O.defaults=Ge.defaults,xr(O.defaults),O};O.walkTokens=function(e,t){return Ge.walkTokens(e,t)};O.parseInline=Ge.parseInline;O.Parser=de;O.parser=de.parse;O.Renderer=gn;O.TextRenderer=Ti;O.Lexer=ce;O.lexer=ce.lex;O.Tokenizer=fn;O.Hooks=_t;O.parse=O;O.options;O.setOptions;O.use;O.walkTokens;O.parseInline;de.parse;ce.lex;O.setOptions({gfm:!0,breaks:!0,mangle:!1});const Va=["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"],Wa=["class","href","rel","target","title","start"];let qa=!1;const Rp=14e4,Mp=4e4,Ip=200,vs=5e4,ze=new Map;function Lp(e){const t=ze.get(e);return t===void 0?null:(ze.delete(e),ze.set(e,t),t)}function Ga(e,t){if(ze.set(e,t),ze.size<=Ip)return;const n=ze.keys().next().value;n&&ze.delete(n)}function Pp(){qa||(qa=!0,Us.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function js(e){const t=e.trim();if(!t)return"";if(Pp(),t.length<=vs){const o=Lp(t);if(o!==null)return o}const n=Lo(t,Rp),s=n.truncated?`
|
|
89
89
|
|
|
90
|
-
… truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>
|
|
90
|
+
… truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>Mp){const c=`<pre class="code-block">${Np(`${n.text}${s}`)}</pre>`,l=Us.sanitize(c,{ALLOWED_TAGS:Va,ALLOWED_ATTR:Wa});return t.length<=vs&&Ga(t,l),l}const i=O.parse(`${n.text}${s}`),a=Us.sanitize(i,{ALLOWED_TAGS:Va,ALLOWED_ATTR:Wa});return t.length<=vs&&Ga(t,a),a}function Np(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Op=1500,Dp=2e3,Lr="Copy as markdown",Bp="Copied",Fp="Copy failed";async function Up(e){if(!e)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function tn(e,t){e.title=t,e.setAttribute("aria-label",t)}function Kp(e){const t=e.label??Lr;return r`
|
|
91
91
|
<button
|
|
92
92
|
class="chat-copy-btn"
|
|
93
93
|
type="button"
|
|
94
94
|
title=${t}
|
|
95
95
|
aria-label=${t}
|
|
96
|
-
@click=${async n=>{const s=n.currentTarget;if(s?.querySelector(".chat-copy-btn__icon"),!s||s.dataset.copying==="1")return;s.dataset.copying="1",s.setAttribute("aria-busy","true"),s.disabled=!0;const i=await
|
|
96
|
+
@click=${async n=>{const s=n.currentTarget;if(s?.querySelector(".chat-copy-btn__icon"),!s||s.dataset.copying==="1")return;s.dataset.copying="1",s.setAttribute("aria-busy","true"),s.disabled=!0;const i=await Up(e.text());if(s.isConnected){if(delete s.dataset.copying,s.removeAttribute("aria-busy"),s.disabled=!1,!i){s.dataset.error="1",tn(s,Fp),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.error,tn(s,t))},Dp);return}s.dataset.copied="1",tn(s,Bp),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.copied,tn(s,t))},Op)}}}
|
|
97
97
|
>
|
|
98
98
|
<span class="chat-copy-btn__icon" aria-hidden="true">
|
|
99
99
|
<span class="chat-copy-btn__icon-copy">${G.copy}</span>
|
|
100
100
|
<span class="chat-copy-btn__icon-check">${G.check}</span>
|
|
101
101
|
</span>
|
|
102
102
|
</button>
|
|
103
|
-
`}function
|
|
104
|
-
`),n=t.slice(0,
|
|
105
|
-
`);return s.length>Ya?s.slice(0,Ya)+"…":n.length<t.length?s+"…":s}function
|
|
103
|
+
`}function zp(e){return Kp({text:()=>e,label:Lr})}const Hp={icon:"puzzle",emoji:"⚡",detailKeys:["command","path","url","targetUrl","targetId","ref","element","node","nodeId","id","requestId","to","channelId","guildId","userId","name","query","pattern","messageId"]},jp={bash:{icon:"wrench",emoji:"💻",title:"Bash",detailKeys:["command"]},process:{icon:"wrench",emoji:"⚙️",title:"Process",detailKeys:["sessionId"]},read:{icon:"fileText",emoji:"📖",title:"Read",detailKeys:["path"]},write:{icon:"edit",emoji:"✍️",title:"Write",detailKeys:["path"]},edit:{icon:"penLine",emoji:"✏️",title:"Edit",detailKeys:["path"]},attach:{icon:"paperclip",emoji:"📎",title:"Attach",detailKeys:["path","url","fileName"]},browser:{icon:"globe",emoji:"🌐",title:"Browser",actions:{status:{label:"status"},start:{label:"start"},stop:{label:"stop"},tabs:{label:"tabs"},open:{label:"open",detailKeys:["targetUrl"]},focus:{label:"focus",detailKeys:["targetId"]},close:{label:"close",detailKeys:["targetId"]},snapshot:{label:"snapshot",detailKeys:["targetUrl","targetId","ref","element","format"]},screenshot:{label:"screenshot",detailKeys:["targetUrl","targetId","ref","element"]},navigate:{label:"navigate",detailKeys:["targetUrl","targetId"]},console:{label:"console",detailKeys:["level","targetId"]},pdf:{label:"pdf",detailKeys:["targetId"]},upload:{label:"upload",detailKeys:["paths","ref","inputRef","element","targetId"]},dialog:{label:"dialog",detailKeys:["accept","promptText","targetId"]},act:{label:"act",detailKeys:["request.kind","request.ref","request.selector","request.text","request.value"]}}},canvas:{icon:"image",emoji:"🎨",title:"Canvas",actions:{present:{label:"present",detailKeys:["target","node","nodeId"]},hide:{label:"hide",detailKeys:["node","nodeId"]},navigate:{label:"navigate",detailKeys:["url","node","nodeId"]},eval:{label:"eval",detailKeys:["javaScript","node","nodeId"]},snapshot:{label:"snapshot",detailKeys:["format","node","nodeId"]},a2ui_push:{label:"A2UI push",detailKeys:["jsonlPath","node","nodeId"]},a2ui_reset:{label:"A2UI reset",detailKeys:["node","nodeId"]}}},nodes:{icon:"smartphone",emoji:"📱",title:"Nodes",actions:{status:{label:"status"},describe:{label:"describe",detailKeys:["node","nodeId"]},pending:{label:"pending"},approve:{label:"approve",detailKeys:["requestId"]},reject:{label:"reject",detailKeys:["requestId"]},notify:{label:"notify",detailKeys:["node","nodeId","title","body"]},camera_snap:{label:"camera snap",detailKeys:["node","nodeId","facing","deviceId"]},camera_list:{label:"camera list",detailKeys:["node","nodeId"]},camera_clip:{label:"camera clip",detailKeys:["node","nodeId","facing","duration","durationMs"]},screen_record:{label:"screen record",detailKeys:["node","nodeId","duration","durationMs","fps","screenIndex"]}}},cron:{icon:"loader",emoji:"⏰",title:"Cron",actions:{status:{label:"status"},list:{label:"list"},add:{label:"add",detailKeys:["job.name","job.id","job.schedule","job.cron"]},update:{label:"update",detailKeys:["id"]},remove:{label:"remove",detailKeys:["id"]},run:{label:"run",detailKeys:["id"]},runs:{label:"runs",detailKeys:["id"]},wake:{label:"wake",detailKeys:["text","mode"]}}},gateway:{icon:"plug",emoji:"🔌",title:"Gateway",actions:{restart:{label:"restart",detailKeys:["reason","delayMs"]},"config.get":{label:"config get"},"config.schema":{label:"config schema"},"config.apply":{label:"config apply",detailKeys:["restartDelayMs"]},"update.run":{label:"update run",detailKeys:["restartDelayMs"]}}},whatsapp_login:{icon:"circle",emoji:"💬",title:"WhatsApp Login",actions:{start:{label:"start"},wait:{label:"wait"}}},discord:{icon:"messageSquare",emoji:"💜",title:"Discord",actions:{react:{label:"react",detailKeys:["channelId","messageId","emoji"]},reactions:{label:"reactions",detailKeys:["channelId","messageId"]},sticker:{label:"sticker",detailKeys:["to","stickerIds"]},poll:{label:"poll",detailKeys:["question","to"]},permissions:{label:"permissions",detailKeys:["channelId"]},readMessages:{label:"read messages",detailKeys:["channelId","limit"]},sendMessage:{label:"send",detailKeys:["to","content"]},editMessage:{label:"edit",detailKeys:["channelId","messageId"]},deleteMessage:{label:"delete",detailKeys:["channelId","messageId"]},threadCreate:{label:"thread create",detailKeys:["channelId","name"]},threadList:{label:"thread list",detailKeys:["guildId","channelId"]},threadReply:{label:"thread reply",detailKeys:["channelId","content"]},pinMessage:{label:"pin",detailKeys:["channelId","messageId"]},unpinMessage:{label:"unpin",detailKeys:["channelId","messageId"]},listPins:{label:"list pins",detailKeys:["channelId"]},searchMessages:{label:"search",detailKeys:["guildId","content"]},memberInfo:{label:"member",detailKeys:["guildId","userId"]},roleInfo:{label:"roles",detailKeys:["guildId"]},emojiList:{label:"emoji list",detailKeys:["guildId"]},roleAdd:{label:"role add",detailKeys:["guildId","userId","roleId"]},roleRemove:{label:"role remove",detailKeys:["guildId","userId","roleId"]},channelInfo:{label:"channel",detailKeys:["channelId"]},channelList:{label:"channels",detailKeys:["guildId"]},voiceStatus:{label:"voice",detailKeys:["guildId","userId"]},eventList:{label:"events",detailKeys:["guildId"]},eventCreate:{label:"event create",detailKeys:["guildId","name"]},timeout:{label:"timeout",detailKeys:["guildId","userId"]},kick:{label:"kick",detailKeys:["guildId","userId"]},ban:{label:"ban",detailKeys:["guildId","userId"]}}},slack:{icon:"messageSquare",emoji:"🟣",title:"Slack",actions:{react:{label:"react",detailKeys:["channelId","messageId","emoji"]},reactions:{label:"reactions",detailKeys:["channelId","messageId"]},sendMessage:{label:"send",detailKeys:["to","content"]},editMessage:{label:"edit",detailKeys:["channelId","messageId"]},deleteMessage:{label:"delete",detailKeys:["channelId","messageId"]},readMessages:{label:"read messages",detailKeys:["channelId","limit"]},pinMessage:{label:"pin",detailKeys:["channelId","messageId"]},unpinMessage:{label:"unpin",detailKeys:["channelId","messageId"]},listPins:{label:"list pins",detailKeys:["channelId"]},memberInfo:{label:"member",detailKeys:["userId"]},emojiList:{label:"emoji list"}}}},Vp={fallback:Hp,tools:jp},Pr=Vp,ys=Pr.fallback??{icon:"puzzle"},Wp=Pr.tools??{};function qp(e){return(e??"tool").trim()}function Gp(e){const t=e.replace(/_/g," ").trim();return t?t.split(/\s+/).map(n=>n.length<=2&&n.toUpperCase()===n?n:`${n.at(0)?.toUpperCase()??""}${n.slice(1)}`).join(" "):"Tool"}function Yp(e){const t=e?.trim();if(t)return t.replace(/_/g," ")}function Nr(e){if(e!=null){if(typeof e=="string"){const t=e.trim();if(!t)return;const n=t.split(/\r?\n/)[0]?.trim()??"";return n?n.length>160?`${n.slice(0,157)}…`:n:void 0}if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e)){const t=e.map(s=>Nr(s)).filter(s=>!!s);if(t.length===0)return;const n=t.slice(0,3).join(", ");return t.length>3?`${n}…`:n}}}function Qp(e,t){if(!e||typeof e!="object")return;let n=e;for(const s of t.split(".")){if(!s||!n||typeof n!="object")return;n=n[s]}return n}function Jp(e,t){for(const n of t){const s=Qp(e,n),i=Nr(s);if(i)return i}}function Zp(e){if(!e||typeof e!="object")return;const t=e,n=typeof t.path=="string"?t.path:void 0;if(!n)return;const s=typeof t.offset=="number"?t.offset:void 0,i=typeof t.limit=="number"?t.limit:void 0;return s!==void 0&&i!==void 0?`${n}:${s}-${s+i}`:n}function Xp(e){if(!e||typeof e!="object")return;const t=e;return typeof t.path=="string"?t.path:void 0}function eh(e,t){if(!(!e||!t))return e.actions?.[t]??void 0}function Or(e){const t=qp(e.name),n=t.toLowerCase(),s=Wp[n],i=s?.icon??ys.icon??"puzzle",a=s?.emoji??ys.emoji??"⚡",o=s?.title??Gp(t),c=s?.label??t,l=e.args&&typeof e.args=="object"?e.args.action:void 0,u=typeof l=="string"?l.trim():void 0,d=eh(s,u),p=Yp(d?.label??u);let f;n==="read"&&(f=Zp(e.args)),!f&&(n==="write"||n==="edit"||n==="attach")&&(f=Xp(e.args));const m=d?.detailKeys??s?.detailKeys??ys.detailKeys??[];return!f&&m.length>0&&(f=Jp(e.args,m)),!f&&e.meta&&(f=e.meta),f&&(f=th(f)),{name:t,icon:i,emoji:a,title:o,label:c,verb:p,detail:f}}function Dr(e){const t=[];if(e.verb&&t.push(e.verb),e.detail&&t.push(e.detail),t.length!==0)return t.join(" · ")}function th(e){return e&&e.replace(/\/Users\/[^/]+/g,"~").replace(/\/home\/[^/]+/g,"~")}const nh=80,sh=2,Ya=100;function ih(e){const t=e.trim();if(t.startsWith("{")||t.startsWith("["))try{const n=JSON.parse(t);return"```json\n"+JSON.stringify(n,null,2)+"\n```"}catch{}return e}function ah(e){const t=e.split(`
|
|
104
|
+
`),n=t.slice(0,sh),s=n.join(`
|
|
105
|
+
`);return s.length>Ya?s.slice(0,Ya)+"…":n.length<t.length?s+"…":s}function oh(e,t){const n=Or({name:e.name,args:e.args}),s=n.emoji??"⚡",i=Dr(n),a=t?.status?`chat-activity-item--${t.status}`:"",o=t?.duration!=null?`${(t.duration/1e3).toFixed(1)}s`:"",c=t?.status==="running"?"◌":t?.status==="error"?"✕":"┊";return r`
|
|
106
|
+
<div class="chat-activity-item ${a}">
|
|
107
|
+
<span class="chat-activity-prefix">${c}</span>
|
|
108
|
+
<span class="chat-activity-emoji">${s}</span>
|
|
109
|
+
<span class="chat-activity-name">${n.label}</span>
|
|
110
|
+
${i?r`<span class="chat-activity-detail">${i}</span>`:g}
|
|
111
|
+
${o?r`<span class="chat-activity-duration">${o}</span>`:g}
|
|
112
|
+
${t?.status==="success"?r`<span class="chat-activity-check">✓</span>`:g}
|
|
113
|
+
</div>
|
|
114
|
+
`}function rh(e,t){if(e.length===0)return g;const n=3,s=e.length>n+2;return r`
|
|
115
|
+
<div class="${s?"chat-activity-feed chat-activity-feed--collapsed":"chat-activity-feed"}">
|
|
116
|
+
${e.map(a=>oh(a,{status:"success"}))}
|
|
117
|
+
${s?r`
|
|
118
|
+
<button
|
|
119
|
+
class="chat-activity-expand"
|
|
120
|
+
@click=${a=>{const o=a.target.closest(".chat-activity-feed");o?.classList.toggle("chat-activity-feed--collapsed");const c=a.target;c.textContent=o?.classList.contains("chat-activity-feed--collapsed")?`┊ +${e.length-n} more`:"┊ collapse"}}
|
|
121
|
+
>
|
|
122
|
+
┊ +${e.length-n} more
|
|
123
|
+
</button>
|
|
124
|
+
`:g}
|
|
125
|
+
</div>
|
|
126
|
+
`}function lh(e){const t=e,n=ch(t.content),s=[];for(const i of n){const a=String(i.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(a)||typeof i.name=="string"&&i.arguments!=null)&&s.push({kind:"call",name:i.name??"tool",args:dh(i.arguments??i.args)})}for(const i of n){const a=String(i.type??"").toLowerCase();if(a!=="toolresult"&&a!=="tool_result")continue;const o=uh(i),c=typeof i.name=="string"?i.name:"tool";s.push({kind:"result",name:c,text:o})}if(vr(e)&&!s.some(i=>i.kind==="result")){const i=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",a=Po(e)??void 0;s.push({kind:"result",name:i,text:a})}return s}function Qa(e,t){const n=Or({name:e.name,args:e.args}),s=Dr(n),i=!!e.text?.trim(),a=!!t,o=a?()=>{if(i){t(ih(e.text));return}const p=`## ${n.label}
|
|
106
127
|
|
|
107
128
|
${s?`**Command:** \`${s}\`
|
|
108
129
|
|
|
109
|
-
`:""}*No output — tool completed successfully.*`;t(p)}:void 0,c=i&&(e.text?.length??0)<=
|
|
130
|
+
`:""}*No output — tool completed successfully.*`;t(p)}:void 0,c=i&&(e.text?.length??0)<=nh,l=i&&!c,u=i&&c,d=!i;return r`
|
|
110
131
|
<div
|
|
111
132
|
class="chat-tool-card ${a?"chat-tool-card--clickable":""}"
|
|
112
133
|
@click=${o}
|
|
@@ -119,54 +140,55 @@ ${s?`**Command:** \`${s}\`
|
|
|
119
140
|
<span class="chat-tool-card__icon">${G[n.icon]}</span>
|
|
120
141
|
<span>${n.label}</span>
|
|
121
142
|
</div>
|
|
122
|
-
${a?
|
|
123
|
-
${d&&!a?
|
|
143
|
+
${a?r`<span class="chat-tool-card__action">${i?"View":""} ${G.check}</span>`:g}
|
|
144
|
+
${d&&!a?r`<span class="chat-tool-card__status">${G.check}</span>`:g}
|
|
124
145
|
</div>
|
|
125
|
-
${s?
|
|
126
|
-
${d?
|
|
127
|
-
${r
|
|
128
|
-
${u?
|
|
146
|
+
${s?r`<div class="chat-tool-card__detail">${s}</div>`:g}
|
|
147
|
+
${d?r`<div class="chat-tool-card__status-text muted">Completed</div>`:g}
|
|
148
|
+
${l?r`<div class="chat-tool-card__preview mono">${ah(e.text)}</div>`:g}
|
|
149
|
+
${u?r`<div class="chat-tool-card__inline mono">${e.text}</div>`:g}
|
|
129
150
|
</div>
|
|
130
|
-
`}function
|
|
151
|
+
`}function ch(e){return Array.isArray(e)?e.filter(Boolean):[]}function dh(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 uh(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}const Ja=["thinking","analyzing","processing","pondering","musing","considering","reasoning","reflecting","examining","investigating","exploring","deliberating"];let Za=0;function ph(){const e=Ja[Za%Ja.length];return Za++,e}function hh(e){const n=e.content,s=[];if(Array.isArray(n))for(const i of n){if(typeof i!="object"||i===null)continue;const a=i;if(a.type==="image"){const o=a.source;if(o?.type==="base64"&&typeof o.data=="string"){const c=o.data,l=o.media_type||"image/png",u=c.startsWith("data:")?c:`data:${l};base64,${c}`;s.push({url:u})}else typeof a.url=="string"&&s.push({url:a.url})}else if(a.type==="image_url"){const o=a.image_url;typeof o?.url=="string"&&s.push({url:o.url})}}return s}function fh(e){const t=ph();return r`
|
|
131
152
|
<div class="chat-group assistant">
|
|
132
|
-
${
|
|
153
|
+
${Ci("assistant",e)}
|
|
133
154
|
<div class="chat-group-messages">
|
|
134
155
|
<div class="chat-bubble chat-reading-indicator" aria-hidden="true">
|
|
135
156
|
<span class="chat-reading-indicator__dots">
|
|
136
157
|
<span></span><span></span><span></span>
|
|
137
158
|
</span>
|
|
159
|
+
<span class="chat-reading-indicator__verb">${t}</span>
|
|
138
160
|
</div>
|
|
139
161
|
</div>
|
|
140
162
|
</div>
|
|
141
|
-
`}function
|
|
163
|
+
`}function gh(e,t,n,s){const i=new Date(t).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),a=s?.name??"Assistant";return r`
|
|
142
164
|
<div class="chat-group assistant">
|
|
143
|
-
${
|
|
165
|
+
${Ci("assistant",s)}
|
|
144
166
|
<div class="chat-group-messages">
|
|
145
|
-
${
|
|
167
|
+
${Br({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!0,showReasoning:!1},n)}
|
|
146
168
|
<div class="chat-group-footer">
|
|
147
169
|
<span class="chat-sender-name">${a}</span>
|
|
148
170
|
<span class="chat-group-timestamp">${i}</span>
|
|
149
171
|
</div>
|
|
150
172
|
</div>
|
|
151
173
|
</div>
|
|
152
|
-
`}function
|
|
174
|
+
`}function mh(e,t){const n=vi(e.role),s=t.assistantName??"Assistant",i=n==="user"?"You":n==="assistant"?s:n,a=n==="user"?"user":n==="assistant"?"assistant":"other",o=new Date(e.timestamp).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return r`
|
|
153
175
|
<div class="chat-group ${a}">
|
|
154
|
-
${
|
|
176
|
+
${Ci(e.role,{name:s,avatar:t.assistantAvatar??null})}
|
|
155
177
|
<div class="chat-group-messages">
|
|
156
|
-
${e.messages.map((c,
|
|
178
|
+
${e.messages.map((c,l)=>Br(c.message,{isStreaming:e.isStreaming&&l===e.messages.length-1,showReasoning:t.showReasoning},t.onOpenSidebar))}
|
|
157
179
|
<div class="chat-group-footer">
|
|
158
180
|
<span class="chat-sender-name">${i}</span>
|
|
159
181
|
<span class="chat-group-timestamp">${o}</span>
|
|
160
182
|
</div>
|
|
161
183
|
</div>
|
|
162
184
|
</div>
|
|
163
|
-
`}function
|
|
185
|
+
`}function Ci(e,t){const n=vi(e),s=t?.name?.trim()||"Assistant",i=t?.avatar?.trim()||"",a=n==="user"?"U":n==="assistant"?s.charAt(0).toUpperCase()||"A":n==="tool"?"⚙":"?",o=n==="user"?"user":n==="assistant"?"assistant":n==="tool"?"tool":"other";return i&&n==="assistant"?vh(i)?r`<img
|
|
164
186
|
class="chat-avatar ${o}"
|
|
165
187
|
src="${i}"
|
|
166
188
|
alt="${s}"
|
|
167
|
-
/>`:
|
|
189
|
+
/>`:r`<div class="chat-avatar ${o}">${i}</div>`:r`<div class="chat-avatar ${o}">${a}</div>`}function vh(e){return/^https?:\/\//i.test(e)||/^data:image\//i.test(e)||e.startsWith("/")}function yh(e){return e.length===0?g:r`
|
|
168
190
|
<div class="chat-message-images">
|
|
169
|
-
${e.map(t=>
|
|
191
|
+
${e.map(t=>r`
|
|
170
192
|
<img
|
|
171
193
|
src=${t.url}
|
|
172
194
|
alt=${t.alt??"Attached image"}
|
|
@@ -175,15 +197,15 @@ ${s?`**Command:** \`${s}\`
|
|
|
175
197
|
/>
|
|
176
198
|
`)}
|
|
177
199
|
</div>
|
|
178
|
-
`}function
|
|
200
|
+
`}function Br(e,t,n){const s=e,i=typeof s.role=="string"?s.role:"unknown",a=vr(e)||i.toLowerCase()==="toolresult"||i.toLowerCase()==="tool_result"||typeof s.toolCallId=="string"||typeof s.tool_call_id=="string",o=lh(e),c=o.length>0,l=hh(e),u=l.length>0,d=Po(e),p=t.showReasoning&&i==="assistant"?yc(e):null,f=d?.trim()?d:null,m=p?wc(p):null,v=f,$=i==="assistant"&&!!v?.trim(),k=["chat-bubble",$?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!v&&c&&a?r`${o.map(_=>Qa(_,n))}`:!v&&!c&&!u?g:r`
|
|
179
201
|
<div class="${k}">
|
|
180
|
-
${$?
|
|
181
|
-
${
|
|
182
|
-
${m?
|
|
183
|
-
${v?
|
|
184
|
-
${o.map(_=>Qa(_,n))}
|
|
202
|
+
${$?zp(v):g}
|
|
203
|
+
${yh(l)}
|
|
204
|
+
${m?r`<div class="chat-thinking">${Os(js(m))}</div>`:g}
|
|
205
|
+
${v?r`<div class="chat-text">${Os(js(v))}</div>`:g}
|
|
206
|
+
${o.length>1?rh(o):o.map(_=>Qa(_,n))}
|
|
185
207
|
</div>
|
|
186
|
-
`}function
|
|
208
|
+
`}function bh(e){return r`
|
|
187
209
|
<div class="sidebar-panel">
|
|
188
210
|
<div class="sidebar-header">
|
|
189
211
|
<div class="sidebar-title">Tool Output</div>
|
|
@@ -192,15 +214,15 @@ ${s?`**Command:** \`${s}\`
|
|
|
192
214
|
</button>
|
|
193
215
|
</div>
|
|
194
216
|
<div class="sidebar-content">
|
|
195
|
-
${e.error?
|
|
217
|
+
${e.error?r`
|
|
196
218
|
<div class="callout danger">${e.error}</div>
|
|
197
219
|
<button @click=${e.onViewRawText} class="btn" style="margin-top: 12px;">
|
|
198
220
|
View Raw Text
|
|
199
221
|
</button>
|
|
200
|
-
`:e.content?
|
|
222
|
+
`:e.content?r`<div class="sidebar-markdown">${Os(js(e.content))}</div>`:r`<div class="muted">No content available</div>`}
|
|
201
223
|
</div>
|
|
202
224
|
</div>
|
|
203
|
-
`}var
|
|
225
|
+
`}var wh=Object.defineProperty,$h=Object.getOwnPropertyDescriptor,Ln=(e,t,n,s)=>{for(var i=s>1?void 0:s?$h(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&wh(t,n,i),i};let ut=class extends pt{constructor(){super(...arguments),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.isDragging=!1,this.startX=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startX=e.clientX,this.startRatio=this.splitRatio,this.classList.add("dragging"),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;const t=this.parentElement;if(!t)return;const n=t.getBoundingClientRect().width,i=(e.clientX-this.startX)/n;let a=this.startRatio+i;a=Math.max(this.minRatio,Math.min(this.maxRatio,a)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:a},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 r``}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)}};ut.styles=ml`
|
|
204
226
|
:host {
|
|
205
227
|
width: 4px;
|
|
206
228
|
cursor: col-resize;
|
|
@@ -226,17 +248,17 @@ ${s?`**Command:** \`${s}\`
|
|
|
226
248
|
:host(.dragging) {
|
|
227
249
|
background: var(--accent, #007bff);
|
|
228
250
|
}
|
|
229
|
-
`;Ln([bn({type:Number})],ut.prototype,"splitRatio",2);Ln([bn({type:Number})],ut.prototype,"minRatio",2);Ln([bn({type:Number})],ut.prototype,"maxRatio",2);ut=Ln([
|
|
251
|
+
`;Ln([bn({type:Number})],ut.prototype,"splitRatio",2);Ln([bn({type:Number})],ut.prototype,"minRatio",2);Ln([bn({type:Number})],ut.prototype,"maxRatio",2);ut=Ln([_o("resizable-divider")],ut);const xh=5e3;function kh(e){return e?e.active?r`
|
|
230
252
|
<div class="callout info compaction-indicator compaction-indicator--active">
|
|
231
253
|
${G.loader} Compacting context...
|
|
232
254
|
</div>
|
|
233
|
-
`:e.completedAt&&Date.now()-e.completedAt<
|
|
255
|
+
`:e.completedAt&&Date.now()-e.completedAt<xh?r`
|
|
234
256
|
<div class="callout success compaction-indicator compaction-indicator--complete">
|
|
235
257
|
${G.check} Context compacted
|
|
236
258
|
</div>
|
|
237
|
-
`:g:g}function
|
|
259
|
+
`:g:g}function Sh(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Ah(e,t){const n=e.clipboardData?.items;if(!n||!t.onAttachmentsChange)return;const s=[];for(let i=0;i<n.length;i++){const a=n[i];a.type.startsWith("image/")&&s.push(a)}if(s.length!==0){e.preventDefault();for(const i of s){const a=i.getAsFile();if(!a)continue;const o=new FileReader;o.onload=()=>{const c=o.result,l={id:Sh(),dataUrl:c,mimeType:a.type},u=t.attachments??[];t.onAttachmentsChange?.([...u,l])},o.readAsDataURL(a)}}}function _h(e){const t=e.attachments??[];return t.length===0?g:r`
|
|
238
260
|
<div class="chat-attachments">
|
|
239
|
-
${t.map(n=>
|
|
261
|
+
${t.map(n=>r`
|
|
240
262
|
<div class="chat-attachment">
|
|
241
263
|
<img
|
|
242
264
|
src=${n.dataUrl}
|
|
@@ -254,25 +276,25 @@ ${s?`**Command:** \`${s}\`
|
|
|
254
276
|
</div>
|
|
255
277
|
`)}
|
|
256
278
|
</div>
|
|
257
|
-
`}function
|
|
279
|
+
`}function Th(e){const t=e.connected,n=e.sending||e.stream!==null,s=!!(e.canAbort&&e.onAbort),a=e.sessions?.sessions?.find(m=>m.key===e.sessionKey)?.reasoningLevel??"off",o=e.showThinking&&a!=="off",c={name:e.assistantName,avatar:e.assistantAvatar??e.assistantAvatarUrl??null},l=(e.attachments?.length??0)>0,u=e.connected?l?"Add a message or paste more images...":"Message (↩ to send, Shift+↩ for line breaks, paste images)":"Connect to the gateway to start chatting…",d=e.splitRatio??.6,p=!!(e.sidebarOpen&&e.onCloseSidebar),f=r`
|
|
258
280
|
<div
|
|
259
281
|
class="chat-thread"
|
|
260
282
|
role="log"
|
|
261
283
|
aria-live="polite"
|
|
262
284
|
@scroll=${e.onChatScroll}
|
|
263
285
|
>
|
|
264
|
-
${e.loading?
|
|
265
|
-
${
|
|
286
|
+
${e.loading?r`<div class="muted">Loading chat…</div>`:g}
|
|
287
|
+
${gr(Eh(e),m=>m.key,m=>m.kind==="reading-indicator"?fh(c):m.kind==="stream"?gh(m.text,m.startedAt,e.onOpenSidebar,c):m.kind==="group"?mh(m,{onOpenSidebar:e.onOpenSidebar,showReasoning:o,assistantName:e.assistantName,assistantAvatar:c.avatar}):g)}
|
|
266
288
|
</div>
|
|
267
|
-
`;return
|
|
289
|
+
`;return r`
|
|
268
290
|
<section class="card chat">
|
|
269
|
-
${e.disabledReason?
|
|
291
|
+
${e.disabledReason?r`<div class="callout">${e.disabledReason}</div>`:g}
|
|
270
292
|
|
|
271
|
-
${e.error?
|
|
293
|
+
${e.error?r`<div class="callout danger">${e.error}</div>`:g}
|
|
272
294
|
|
|
273
|
-
${
|
|
295
|
+
${kh(e.compactionStatus)}
|
|
274
296
|
|
|
275
|
-
${e.focusMode?
|
|
297
|
+
${e.focusMode?r`
|
|
276
298
|
<button
|
|
277
299
|
class="chat-focus-exit"
|
|
278
300
|
type="button"
|
|
@@ -294,24 +316,24 @@ ${s?`**Command:** \`${s}\`
|
|
|
294
316
|
${f}
|
|
295
317
|
</div>
|
|
296
318
|
|
|
297
|
-
${p?
|
|
319
|
+
${p?r`
|
|
298
320
|
<resizable-divider
|
|
299
321
|
.splitRatio=${d}
|
|
300
322
|
@resize=${m=>e.onSplitRatioChange?.(m.detail.splitRatio)}
|
|
301
323
|
></resizable-divider>
|
|
302
324
|
<div class="chat-sidebar">
|
|
303
|
-
${
|
|
325
|
+
${bh({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
|
|
304
326
|
${e.sidebarContent}
|
|
305
327
|
\`\`\``)}})}
|
|
306
328
|
</div>
|
|
307
329
|
`:g}
|
|
308
330
|
</div>
|
|
309
331
|
|
|
310
|
-
${e.queue.length?
|
|
332
|
+
${e.queue.length?r`
|
|
311
333
|
<div class="chat-queue" role="status" aria-live="polite">
|
|
312
334
|
<div class="chat-queue__title">Queued (${e.queue.length})</div>
|
|
313
335
|
<div class="chat-queue__list">
|
|
314
|
-
${e.queue.map(m=>
|
|
336
|
+
${e.queue.map(m=>r`
|
|
315
337
|
<div class="chat-queue__item">
|
|
316
338
|
<div class="chat-queue__text">
|
|
317
339
|
${m.text||(m.attachments?.length?`Image (${m.attachments.length})`:"")}
|
|
@@ -331,7 +353,7 @@ ${e.sidebarContent}
|
|
|
331
353
|
`:g}
|
|
332
354
|
|
|
333
355
|
<div class="chat-compose">
|
|
334
|
-
${
|
|
356
|
+
${_h(e)}
|
|
335
357
|
<div class="chat-compose__row">
|
|
336
358
|
<label class="field chat-compose__field">
|
|
337
359
|
<span>Message</span>
|
|
@@ -340,7 +362,7 @@ ${e.sidebarContent}
|
|
|
340
362
|
?disabled=${!e.connected}
|
|
341
363
|
@keydown=${m=>{m.key==="Enter"&&(m.isComposing||m.keyCode===229||m.shiftKey||e.connected&&(m.preventDefault(),t&&e.onSend()))}}
|
|
342
364
|
@input=${m=>e.onDraftChange(m.target.value)}
|
|
343
|
-
@paste=${m=>
|
|
365
|
+
@paste=${m=>Ah(m,e)}
|
|
344
366
|
placeholder=${u}
|
|
345
367
|
></textarea>
|
|
346
368
|
</label>
|
|
@@ -363,15 +385,15 @@ ${e.sidebarContent}
|
|
|
363
385
|
</div>
|
|
364
386
|
</div>
|
|
365
387
|
</section>
|
|
366
|
-
`}const
|
|
388
|
+
`}const Xa=200;function Ch(e){const t=[];let n=null;for(const s of e){if(s.kind!=="message"){n&&(t.push(n),n=null),t.push(s);continue}const i=mr(s.message),a=vi(i.role),o=i.timestamp||Date.now();!n||n.role!==a?(n&&t.push(n),n={kind:"group",key:`group:${a}:${s.key}`,role:a,messages:[{message:s.message,key:s.key}],timestamp:o,isStreaming:!1}):n.messages.push({message:s.message,key:s.key})}return n&&t.push(n),t}function Eh(e){const t=[],n=Array.isArray(e.messages)?e.messages:[],s=Array.isArray(e.toolMessages)?e.toolMessages:[],i=Math.max(0,n.length-Xa);i>0&&t.push({kind:"message",key:"chat:history:notice",message:{role:"system",content:`Showing last ${Xa} messages (${i} hidden).`,timestamp:Date.now()}});for(let a=i;a<n.length;a++){const o=n[a],c=mr(o);!e.showThinking&&c.role.toLowerCase()==="toolresult"||t.push({kind:"message",key:eo(o,a),message:o})}if(e.showThinking)for(let a=0;a<s.length;a++)t.push({kind:"message",key:eo(s[a],a+n.length),message:s[a]});if(e.stream!==null){const a=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:a,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:a})}return Ch(t)}function eo(e,t){const n=e,s=typeof n.toolCallId=="string"?n.toolCallId:"";if(s)return`tool:${s}`;const i=typeof n.id=="string"?n.id:"";if(i)return`msg:${i}`;const a=typeof n.messageId=="string"?n.messageId:"";if(a)return`msg:${a}`;const o=typeof n.timestamp=="number"?n.timestamp:null,c=typeof n.role=="string"?n.role:"unknown";return o!=null?`msg:${c}:${o}:${t}`:`msg:${c}:${t}`}function me(e){if(e)return Array.isArray(e.type)?e.type.filter(n=>n!=="null")[0]??e.type[0]:e.type}function Fr(e){if(!e)return"";if(e.default!==void 0)return e.default;switch(me(e)){case"object":return{};case"array":return[];case"boolean":return!1;case"number":case"integer":return 0;case"string":return"";default:return""}}function Pn(e){return e.filter(t=>typeof t=="string").join(".")}function ie(e,t){const n=Pn(e),s=t[n];if(s)return s;const i=n.split(".");for(const[a,o]of Object.entries(t)){if(!a.includes("*"))continue;const c=a.split(".");if(c.length!==i.length)continue;let l=!0;for(let u=0;u<i.length;u+=1)if(c[u]!=="*"&&c[u]!==i[u]){l=!1;break}if(l)return o}}function Te(e){return e.replace(/_/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/\s+/g," ").replace(/^./,t=>t.toUpperCase())}function Rh(e){const t=Pn(e).toLowerCase();return t.includes("token")||t.includes("password")||t.includes("secret")||t.includes("apikey")||t.endsWith("key")}const Mh=new Set(["title","description","default","nullable"]);function Ih(e){return Object.keys(e??{}).filter(n=>!Mh.has(n)).length===0}function Lh(e){if(e===void 0)return"";try{return JSON.stringify(e,null,2)??""}catch{return""}}const Dt={chevronDown:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>`,plus:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>`,minus:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line></svg>`,trash:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>`,edit:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path></svg>`};function _e(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:c}=e,l=e.showLabel??!0,u=me(t),d=ie(s,i),p=d?.label??t.title??Te(String(s.at(-1))),f=d?.help??t.description,m=Pn(s);if(a.has(m))return r`<div class="cfg-field cfg-field--error">
|
|
367
389
|
<div class="cfg-field__label">${p}</div>
|
|
368
390
|
<div class="cfg-field__error">Unsupported schema node. Use Raw mode.</div>
|
|
369
|
-
</div>`;if(t.anyOf||t.oneOf){const $=(t.anyOf??t.oneOf??[]).filter(C=>!(C.type==="null"||Array.isArray(C.type)&&C.type.includes("null")));if($.length===1)return _e({...e,schema:$[0]});const k=C=>{if(C.const!==void 0)return C.const;if(C.enum&&C.enum.length===1)return C.enum[0]},_=$.map(k),M=_.every(C=>C!==void 0);if(M&&_.length>0&&_.length<=5){const C=n??t.default;return
|
|
391
|
+
</div>`;if(t.anyOf||t.oneOf){const $=(t.anyOf??t.oneOf??[]).filter(C=>!(C.type==="null"||Array.isArray(C.type)&&C.type.includes("null")));if($.length===1)return _e({...e,schema:$[0]});const k=C=>{if(C.const!==void 0)return C.const;if(C.enum&&C.enum.length===1)return C.enum[0]},_=$.map(k),M=_.every(C=>C!==void 0);if(M&&_.length>0&&_.length<=5){const C=n??t.default;return r`
|
|
370
392
|
<div class="cfg-field">
|
|
371
|
-
${r
|
|
372
|
-
${f?
|
|
393
|
+
${l?r`<label class="cfg-field__label">${p}</label>`:g}
|
|
394
|
+
${f?r`<div class="cfg-field__help">${f}</div>`:g}
|
|
373
395
|
<div class="cfg-segmented">
|
|
374
|
-
${_.map((E,ve)=>
|
|
396
|
+
${_.map((E,ve)=>r`
|
|
375
397
|
<button
|
|
376
398
|
type="button"
|
|
377
399
|
class="cfg-segmented__btn ${E===C||String(E)===String(C)?"active":""}"
|
|
@@ -383,12 +405,12 @@ ${e.sidebarContent}
|
|
|
383
405
|
`)}
|
|
384
406
|
</div>
|
|
385
407
|
</div>
|
|
386
|
-
`}if(M&&_.length>5)return
|
|
408
|
+
`}if(M&&_.length>5)return no({...e,options:_,value:n??t.default});const N=new Set($.map(C=>me(C)).filter(Boolean)),R=new Set([...N].map(C=>C==="integer"?"number":C));if([...R].every(C=>["string","number","boolean"].includes(C))){const C=R.has("string"),E=R.has("number");if(R.has("boolean")&&R.size===1)return _e({...e,schema:{...t,type:"boolean",anyOf:void 0,oneOf:void 0}});if(C||E)return to({...e,inputType:E&&!C?"number":"text"})}}if(t.enum){const v=t.enum;if(v.length<=5){const $=n??t.default;return r`
|
|
387
409
|
<div class="cfg-field">
|
|
388
|
-
${r
|
|
389
|
-
${f?
|
|
410
|
+
${l?r`<label class="cfg-field__label">${p}</label>`:g}
|
|
411
|
+
${f?r`<div class="cfg-field__help">${f}</div>`:g}
|
|
390
412
|
<div class="cfg-segmented">
|
|
391
|
-
${v.map(k=>
|
|
413
|
+
${v.map(k=>r`
|
|
392
414
|
<button
|
|
393
415
|
type="button"
|
|
394
416
|
class="cfg-segmented__btn ${k===$||String(k)===String($)?"active":""}"
|
|
@@ -400,11 +422,11 @@ ${e.sidebarContent}
|
|
|
400
422
|
`)}
|
|
401
423
|
</div>
|
|
402
424
|
</div>
|
|
403
|
-
`}return
|
|
425
|
+
`}return no({...e,options:v,value:n??t.default})}if(u==="object")return Nh(e);if(u==="array")return Oh(e);if(u==="boolean"){const v=typeof n=="boolean"?n:typeof t.default=="boolean"?t.default:!1;return r`
|
|
404
426
|
<label class="cfg-toggle-row ${o?"disabled":""}">
|
|
405
427
|
<div class="cfg-toggle-row__content">
|
|
406
428
|
<span class="cfg-toggle-row__label">${p}</span>
|
|
407
|
-
${f?
|
|
429
|
+
${f?r`<span class="cfg-toggle-row__help">${f}</span>`:g}
|
|
408
430
|
</div>
|
|
409
431
|
<div class="cfg-toggle">
|
|
410
432
|
<input
|
|
@@ -416,15 +438,15 @@ ${e.sidebarContent}
|
|
|
416
438
|
<span class="cfg-toggle__track"></span>
|
|
417
439
|
</div>
|
|
418
440
|
</label>
|
|
419
|
-
`}return u==="number"||u==="integer"?
|
|
441
|
+
`}return u==="number"||u==="integer"?Ph(e):u==="string"?to({...e,inputType:"text"}):r`
|
|
420
442
|
<div class="cfg-field cfg-field--error">
|
|
421
443
|
<div class="cfg-field__label">${p}</div>
|
|
422
444
|
<div class="cfg-field__error">Unsupported type: ${u}. Use Raw mode.</div>
|
|
423
445
|
</div>
|
|
424
|
-
`}function
|
|
446
|
+
`}function to(e){const{schema:t,value:n,path:s,hints:i,disabled:a,onPatch:o,inputType:c}=e,l=e.showLabel??!0,u=ie(s,i),d=u?.label??t.title??Te(String(s.at(-1))),p=u?.help??t.description,f=u?.sensitive??Rh(s),m=u?.placeholder??(f?"••••":t.default!==void 0?`Default: ${t.default}`:""),v=n??"";return r`
|
|
425
447
|
<div class="cfg-field">
|
|
426
|
-
${r
|
|
427
|
-
${p?
|
|
448
|
+
${l?r`<label class="cfg-field__label">${d}</label>`:g}
|
|
449
|
+
${p?r`<div class="cfg-field__help">${p}</div>`:g}
|
|
428
450
|
<div class="cfg-input-wrap">
|
|
429
451
|
<input
|
|
430
452
|
type=${f?"password":c}
|
|
@@ -434,7 +456,7 @@ ${e.sidebarContent}
|
|
|
434
456
|
?disabled=${a}
|
|
435
457
|
@input=${$=>{const k=$.target.value;if(c==="number"){if(k.trim()===""){o(s,void 0);return}const _=Number(k);o(s,Number.isNaN(_)?k:_);return}o(s,k)}}
|
|
436
458
|
/>
|
|
437
|
-
${t.default!==void 0?
|
|
459
|
+
${t.default!==void 0?r`
|
|
438
460
|
<button
|
|
439
461
|
type="button"
|
|
440
462
|
class="cfg-input__reset"
|
|
@@ -445,10 +467,10 @@ ${e.sidebarContent}
|
|
|
445
467
|
`:g}
|
|
446
468
|
</div>
|
|
447
469
|
</div>
|
|
448
|
-
`}function
|
|
470
|
+
`}function Ph(e){const{schema:t,value:n,path:s,hints:i,disabled:a,onPatch:o}=e,c=e.showLabel??!0,l=ie(s,i),u=l?.label??t.title??Te(String(s.at(-1))),d=l?.help??t.description,p=n??t.default??"",f=typeof p=="number"?p:0;return r`
|
|
449
471
|
<div class="cfg-field">
|
|
450
|
-
${c?
|
|
451
|
-
${d?
|
|
472
|
+
${c?r`<label class="cfg-field__label">${u}</label>`:g}
|
|
473
|
+
${d?r`<div class="cfg-field__help">${d}</div>`:g}
|
|
452
474
|
<div class="cfg-number">
|
|
453
475
|
<button
|
|
454
476
|
type="button"
|
|
@@ -471,10 +493,10 @@ ${e.sidebarContent}
|
|
|
471
493
|
>+</button>
|
|
472
494
|
</div>
|
|
473
495
|
</div>
|
|
474
|
-
`}function
|
|
496
|
+
`}function no(e){const{schema:t,value:n,path:s,hints:i,disabled:a,options:o,onPatch:c}=e,l=e.showLabel??!0,u=ie(s,i),d=u?.label??t.title??Te(String(s.at(-1))),p=u?.help??t.description,f=n??t.default,m=o.findIndex($=>$===f||String($)===String(f)),v="__unset__";return r`
|
|
475
497
|
<div class="cfg-field">
|
|
476
|
-
${r
|
|
477
|
-
${p?
|
|
498
|
+
${l?r`<label class="cfg-field__label">${d}</label>`:g}
|
|
499
|
+
${p?r`<div class="cfg-field__help">${p}</div>`:g}
|
|
478
500
|
<select
|
|
479
501
|
class="cfg-select"
|
|
480
502
|
?disabled=${a}
|
|
@@ -482,57 +504,57 @@ ${e.sidebarContent}
|
|
|
482
504
|
@change=${$=>{const k=$.target.value;c(s,k===v?void 0:o[Number(k)])}}
|
|
483
505
|
>
|
|
484
506
|
<option value=${v}>Select...</option>
|
|
485
|
-
${o.map(($,k)=>
|
|
507
|
+
${o.map(($,k)=>r`
|
|
486
508
|
<option value=${String(k)}>${String($)}</option>
|
|
487
509
|
`)}
|
|
488
510
|
</select>
|
|
489
511
|
</div>
|
|
490
|
-
`}function
|
|
512
|
+
`}function Nh(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:c}=e;e.showLabel;const l=ie(s,i),u=l?.label??t.title??Te(String(s.at(-1))),d=l?.help??t.description,p=n??t.default,f=p&&typeof p=="object"&&!Array.isArray(p)?p:{},m=t.properties??{},$=Object.entries(m).sort((N,R)=>{const C=ie([...s,N[0]],i)?.order??0,E=ie([...s,R[0]],i)?.order??0;return C!==E?C-E:N[0].localeCompare(R[0])}),k=new Set(Object.keys(m)),_=t.additionalProperties,M=!!_&&typeof _=="object";return s.length===1?r`
|
|
491
513
|
<div class="cfg-fields">
|
|
492
514
|
${$.map(([N,R])=>_e({schema:R,value:f[N],path:[...s,N],hints:i,unsupported:a,disabled:o,onPatch:c}))}
|
|
493
|
-
${M?
|
|
515
|
+
${M?so({schema:_,value:f,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:k,onPatch:c}):g}
|
|
494
516
|
</div>
|
|
495
|
-
`:
|
|
517
|
+
`:r`
|
|
496
518
|
<details class="cfg-object" open>
|
|
497
519
|
<summary class="cfg-object__header">
|
|
498
520
|
<span class="cfg-object__title">${u}</span>
|
|
499
521
|
<span class="cfg-object__chevron">${Dt.chevronDown}</span>
|
|
500
522
|
</summary>
|
|
501
|
-
${d?
|
|
523
|
+
${d?r`<div class="cfg-object__help">${d}</div>`:g}
|
|
502
524
|
<div class="cfg-object__content">
|
|
503
525
|
${$.map(([N,R])=>_e({schema:R,value:f[N],path:[...s,N],hints:i,unsupported:a,disabled:o,onPatch:c}))}
|
|
504
|
-
${M?
|
|
526
|
+
${M?so({schema:_,value:f,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:k,onPatch:c}):g}
|
|
505
527
|
</div>
|
|
506
528
|
</details>
|
|
507
|
-
`}function
|
|
529
|
+
`}function Oh(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:c}=e,l=e.showLabel??!0,u=ie(s,i),d=u?.label??t.title??Te(String(s.at(-1))),p=u?.help??t.description,f=Array.isArray(t.items)?t.items[0]:t.items;if(!f)return r`
|
|
508
530
|
<div class="cfg-field cfg-field--error">
|
|
509
531
|
<div class="cfg-field__label">${d}</div>
|
|
510
532
|
<div class="cfg-field__error">Unsupported array schema. Use Raw mode.</div>
|
|
511
533
|
</div>
|
|
512
|
-
`;const m=Array.isArray(n)?n:Array.isArray(t.default)?t.default:[];return
|
|
534
|
+
`;const m=Array.isArray(n)?n:Array.isArray(t.default)?t.default:[];return r`
|
|
513
535
|
<div class="cfg-array">
|
|
514
536
|
<div class="cfg-array__header">
|
|
515
|
-
${r
|
|
537
|
+
${l?r`<span class="cfg-array__label">${d}</span>`:g}
|
|
516
538
|
<span class="cfg-array__count">${m.length} item${m.length!==1?"s":""}</span>
|
|
517
539
|
<button
|
|
518
540
|
type="button"
|
|
519
541
|
class="cfg-array__add"
|
|
520
542
|
?disabled=${o}
|
|
521
|
-
@click=${()=>{const v=[...m,
|
|
543
|
+
@click=${()=>{const v=[...m,Fr(f)];c(s,v)}}
|
|
522
544
|
>
|
|
523
545
|
<span class="cfg-array__add-icon">${Dt.plus}</span>
|
|
524
546
|
Add
|
|
525
547
|
</button>
|
|
526
548
|
</div>
|
|
527
|
-
${p?
|
|
549
|
+
${p?r`<div class="cfg-array__help">${p}</div>`:g}
|
|
528
550
|
|
|
529
|
-
${m.length===0?
|
|
551
|
+
${m.length===0?r`
|
|
530
552
|
<div class="cfg-array__empty">
|
|
531
553
|
No items yet. Click "Add" to create one.
|
|
532
554
|
</div>
|
|
533
|
-
`:
|
|
555
|
+
`:r`
|
|
534
556
|
<div class="cfg-array__items">
|
|
535
|
-
${m.map((v,$)=>
|
|
557
|
+
${m.map((v,$)=>r`
|
|
536
558
|
<div class="cfg-array__item">
|
|
537
559
|
<div class="cfg-array__item-header">
|
|
538
560
|
<span class="cfg-array__item-index">#${$+1}</span>
|
|
@@ -554,7 +576,7 @@ ${e.sidebarContent}
|
|
|
554
576
|
</div>
|
|
555
577
|
`}
|
|
556
578
|
</div>
|
|
557
|
-
`}function
|
|
579
|
+
`}function so(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:c,onPatch:l}=e,u=Ih(t),d=Object.entries(n??{}).filter(([p])=>!c.has(p));return r`
|
|
558
580
|
<div class="cfg-map">
|
|
559
581
|
<div class="cfg-map__header">
|
|
560
582
|
<span class="cfg-map__label">Custom entries</span>
|
|
@@ -562,18 +584,18 @@ ${e.sidebarContent}
|
|
|
562
584
|
type="button"
|
|
563
585
|
class="cfg-map__add"
|
|
564
586
|
?disabled=${o}
|
|
565
|
-
@click=${()=>{const p={...n??{}};let f=1,m=`custom-${f}`;for(;m in p;)f+=1,m=`custom-${f}`;p[m]=u?{}:
|
|
587
|
+
@click=${()=>{const p={...n??{}};let f=1,m=`custom-${f}`;for(;m in p;)f+=1,m=`custom-${f}`;p[m]=u?{}:Fr(t),l(s,p)}}
|
|
566
588
|
>
|
|
567
589
|
<span class="cfg-map__add-icon">${Dt.plus}</span>
|
|
568
590
|
Add Entry
|
|
569
591
|
</button>
|
|
570
592
|
</div>
|
|
571
593
|
|
|
572
|
-
${d.length===0?
|
|
594
|
+
${d.length===0?r`
|
|
573
595
|
<div class="cfg-map__empty">No custom entries.</div>
|
|
574
|
-
`:
|
|
596
|
+
`:r`
|
|
575
597
|
<div class="cfg-map__items">
|
|
576
|
-
${d.map(([p,f])=>{const m=[...s,p],v=
|
|
598
|
+
${d.map(([p,f])=>{const m=[...s,p],v=Lh(f);return r`
|
|
577
599
|
<div class="cfg-map__item">
|
|
578
600
|
<div class="cfg-map__item-key">
|
|
579
601
|
<input
|
|
@@ -582,27 +604,27 @@ ${e.sidebarContent}
|
|
|
582
604
|
placeholder="Key"
|
|
583
605
|
.value=${p}
|
|
584
606
|
?disabled=${o}
|
|
585
|
-
@change=${$=>{const k=$.target.value.trim();if(!k||k===p)return;const _={...n??{}};k in _||(_[k]=_[p],delete _[p],
|
|
607
|
+
@change=${$=>{const k=$.target.value.trim();if(!k||k===p)return;const _={...n??{}};k in _||(_[k]=_[p],delete _[p],l(s,_))}}
|
|
586
608
|
/>
|
|
587
609
|
</div>
|
|
588
610
|
<div class="cfg-map__item-value">
|
|
589
|
-
${u?
|
|
611
|
+
${u?r`
|
|
590
612
|
<textarea
|
|
591
613
|
class="cfg-textarea cfg-textarea--sm"
|
|
592
614
|
placeholder="JSON value"
|
|
593
615
|
rows="2"
|
|
594
616
|
.value=${v}
|
|
595
617
|
?disabled=${o}
|
|
596
|
-
@change=${$=>{const k=$.target,_=k.value.trim();if(!_){
|
|
618
|
+
@change=${$=>{const k=$.target,_=k.value.trim();if(!_){l(m,void 0);return}try{l(m,JSON.parse(_))}catch{k.value=v}}}
|
|
597
619
|
></textarea>
|
|
598
|
-
`:_e({schema:t,value:f,path:m,hints:i,unsupported:a,disabled:o,showLabel:!1,onPatch:
|
|
620
|
+
`:_e({schema:t,value:f,path:m,hints:i,unsupported:a,disabled:o,showLabel:!1,onPatch:l})}
|
|
599
621
|
</div>
|
|
600
622
|
<button
|
|
601
623
|
type="button"
|
|
602
624
|
class="cfg-map__item-remove"
|
|
603
625
|
title="Remove entry"
|
|
604
626
|
?disabled=${o}
|
|
605
|
-
@click=${()=>{const $={...n??{}};delete $[p],
|
|
627
|
+
@click=${()=>{const $={...n??{}};delete $[p],l(s,$)}}
|
|
606
628
|
>
|
|
607
629
|
${Dt.trash}
|
|
608
630
|
</button>
|
|
@@ -611,35 +633,35 @@ ${e.sidebarContent}
|
|
|
611
633
|
</div>
|
|
612
634
|
`}
|
|
613
635
|
</div>
|
|
614
|
-
`}const no={env:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>`,update:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>`,agents:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2z"></path><circle cx="8" cy="14" r="1"></circle><circle cx="16" cy="14" r="1"></circle></svg>`,auth:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><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>`,channels:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>`,messages:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>`,commands:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><polyline points="4 17 10 11 4 5"></polyline><line x1="12" y1="19" x2="20" y2="19"></line></svg>`,hooks:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><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><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>`,skills:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>`,tools:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><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"></path></svg>`,gateway:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,wizard:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M15 4V2"></path><path d="M15 16v-2"></path><path d="M8 9h2"></path><path d="M20 9h2"></path><path d="M17.8 11.8 19 13"></path><path d="M15 9h0"></path><path d="M17.8 6.2 19 5"></path><path d="m3 21 9-9"></path><path d="M12.2 6.2 11 5"></path></svg>`,meta:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 20h9"></path><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"></path></svg>`,logging:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>`,browser:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><circle cx="12" cy="12" r="4"></circle><line x1="21.17" y1="8" x2="12" y2="8"></line><line x1="3.95" y1="6.06" x2="8.54" y2="14"></line><line x1="10.88" y1="21.94" x2="15.46" y2="14"></line></svg>`,ui:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="3" y1="9" x2="21" y2="9"></line><line x1="9" y1="21" x2="9" y2="9"></line></svg>`,models:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg>`,bindings:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6.01" y2="6"></line><line x1="6" y1="18" x2="6.01" y2="18"></line></svg>`,broadcast:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"></path><path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5"></path><circle cx="12" cy="12" r="2"></circle><path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5"></path><path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"></path></svg>`,audio:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg>`,session:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>`,cron:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>`,web:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,discovery:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>`,canvasHost:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>`,talk:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>`,plugins:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 2v6"></path><path d="m4.93 10.93 4.24 4.24"></path><path d="M2 12h6"></path><path d="m4.93 13.07 4.24-4.24"></path><path d="M12 22v-6"></path><path d="m19.07 13.07-4.24-4.24"></path><path d="M22 12h-6"></path><path d="m19.07 10.93-4.24 4.24"></path></svg>`,default:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>`},Ci={env:{label:"Environment Variables",description:"Environment variables passed to the gateway process"},update:{label:"Updates",description:"Auto-update settings and release channel"},agents:{label:"Agents",description:"Agent configurations, models, and identities"},auth:{label:"Authentication",description:"API keys and authentication profiles"},channels:{label:"Channels",description:"Messaging channels (Telegram, Discord, Slack, etc.)"},messages:{label:"Messages",description:"Message handling and routing settings"},commands:{label:"Commands",description:"Custom slash commands"},hooks:{label:"Hooks",description:"Webhooks and event hooks"},skills:{label:"Skills",description:"Skill packs and capabilities"},tools:{label:"Tools",description:"Tool configurations (browser, search, etc.)"},gateway:{label:"Gateway",description:"Gateway server settings (port, auth, binding)"},wizard:{label:"Setup Wizard",description:"Setup wizard state and history"},meta:{label:"Metadata",description:"Gateway metadata and version information"},logging:{label:"Logging",description:"Log levels and output configuration"},browser:{label:"Browser",description:"Browser automation settings"},ui:{label:"UI",description:"User interface preferences"},models:{label:"Models",description:"AI model configurations and providers"},bindings:{label:"Bindings",description:"Key bindings and shortcuts"},broadcast:{label:"Broadcast",description:"Broadcast and notification settings"},audio:{label:"Audio",description:"Audio input/output settings"},session:{label:"Session",description:"Session management and persistence"},cron:{label:"Cron",description:"Scheduled tasks and automation"},web:{label:"Web",description:"Web server and API settings"},discovery:{label:"Discovery",description:"Service discovery and networking"},canvasHost:{label:"Canvas Host",description:"Canvas rendering and display"},talk:{label:"Talk",description:"Voice and speech settings"},plugins:{label:"Plugins",description:"Plugin management and extensions"}};function so(e){return no[e]??no.default}function Ih(e,t,n){if(!n)return!0;const s=n.toLowerCase(),i=Ci[e];return e.toLowerCase().includes(s)||i&&(i.label.toLowerCase().includes(s)||i.description.toLowerCase().includes(s))?!0:Tt(t,s)}function Tt(e,t){if(e.title?.toLowerCase().includes(t)||e.description?.toLowerCase().includes(t)||e.enum?.some(s=>String(s).toLowerCase().includes(t)))return!0;if(e.properties){for(const[s,i]of Object.entries(e.properties))if(s.toLowerCase().includes(t)||Tt(i,t))return!0}if(e.items){const s=Array.isArray(e.items)?e.items:[e.items];for(const i of s)if(i&&Tt(i,t))return!0}if(e.additionalProperties&&typeof e.additionalProperties=="object"&&Tt(e.additionalProperties,t))return!0;const n=e.anyOf??e.oneOf??e.allOf;if(n){for(const s of n)if(s&&Tt(s,t))return!0}return!1}function Lh(e){if(!e.schema)return l`<div class="muted">Schema unavailable.</div>`;const t=e.schema,n=e.value??{};if(me(t)!=="object"||!t.properties)return l`<div class="callout danger">Unsupported schema. Use Raw.</div>`;const s=new Set(e.unsupportedPaths??[]),i=t.properties,a=e.searchQuery??"",o=e.activeSection,c=e.activeSubsection??null,u=Object.entries(i).sort((p,f)=>{const m=ie([p[0]],e.uiHints)?.order??50,v=ie([f[0]],e.uiHints)?.order??50;return m!==v?m-v:p[0].localeCompare(f[0])}).filter(([p,f])=>!(o&&p!==o||a&&!Ih(p,f,a)));let d=null;if(o&&c&&u.length===1){const p=u[0]?.[1];p&&me(p)==="object"&&p.properties&&p.properties[c]&&(d={sectionKey:o,subsectionKey:c,schema:p.properties[c]})}return u.length===0?l`
|
|
636
|
+
`}const io={env:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>`,update:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>`,agents:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2z"></path><circle cx="8" cy="14" r="1"></circle><circle cx="16" cy="14" r="1"></circle></svg>`,auth:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><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>`,channels:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>`,messages:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>`,commands:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><polyline points="4 17 10 11 4 5"></polyline><line x1="12" y1="19" x2="20" y2="19"></line></svg>`,hooks:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><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><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>`,skills:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>`,tools:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><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"></path></svg>`,gateway:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,wizard:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M15 4V2"></path><path d="M15 16v-2"></path><path d="M8 9h2"></path><path d="M20 9h2"></path><path d="M17.8 11.8 19 13"></path><path d="M15 9h0"></path><path d="M17.8 6.2 19 5"></path><path d="m3 21 9-9"></path><path d="M12.2 6.2 11 5"></path></svg>`,meta:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 20h9"></path><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"></path></svg>`,logging:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>`,browser:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><circle cx="12" cy="12" r="4"></circle><line x1="21.17" y1="8" x2="12" y2="8"></line><line x1="3.95" y1="6.06" x2="8.54" y2="14"></line><line x1="10.88" y1="21.94" x2="15.46" y2="14"></line></svg>`,ui:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="3" y1="9" x2="21" y2="9"></line><line x1="9" y1="21" x2="9" y2="9"></line></svg>`,models:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg>`,bindings:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6.01" y2="6"></line><line x1="6" y1="18" x2="6.01" y2="18"></line></svg>`,broadcast:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"></path><path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5"></path><circle cx="12" cy="12" r="2"></circle><path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5"></path><path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"></path></svg>`,audio:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg>`,session:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>`,cron:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>`,web:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,discovery:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>`,canvasHost:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>`,talk:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>`,plugins:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 2v6"></path><path d="m4.93 10.93 4.24 4.24"></path><path d="M2 12h6"></path><path d="m4.93 13.07 4.24-4.24"></path><path d="M12 22v-6"></path><path d="m19.07 13.07-4.24-4.24"></path><path d="M22 12h-6"></path><path d="m19.07 10.93-4.24 4.24"></path></svg>`,default:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>`},Ei={env:{label:"Environment Variables",description:"Environment variables passed to the gateway process"},update:{label:"Updates",description:"Auto-update settings and release channel"},agents:{label:"Agents",description:"Agent configurations, models, and identities"},auth:{label:"Authentication",description:"API keys and authentication profiles"},channels:{label:"Channels",description:"Messaging channels (Telegram, Discord, Slack, etc.)"},messages:{label:"Messages",description:"Message handling and routing settings"},commands:{label:"Commands",description:"Custom slash commands"},hooks:{label:"Hooks",description:"Webhooks and event hooks"},skills:{label:"Skills",description:"Skill packs and capabilities"},tools:{label:"Tools",description:"Tool configurations (browser, search, etc.)"},gateway:{label:"Gateway",description:"Gateway server settings (port, auth, binding)"},wizard:{label:"Setup Wizard",description:"Setup wizard state and history"},meta:{label:"Metadata",description:"Gateway metadata and version information"},logging:{label:"Logging",description:"Log levels and output configuration"},browser:{label:"Browser",description:"Browser automation settings"},ui:{label:"UI",description:"User interface preferences"},models:{label:"Models",description:"AI model configurations and providers"},bindings:{label:"Bindings",description:"Key bindings and shortcuts"},broadcast:{label:"Broadcast",description:"Broadcast and notification settings"},audio:{label:"Audio",description:"Audio input/output settings"},session:{label:"Session",description:"Session management and persistence"},cron:{label:"Cron",description:"Scheduled tasks and automation"},web:{label:"Web",description:"Web server and API settings"},discovery:{label:"Discovery",description:"Service discovery and networking"},canvasHost:{label:"Canvas Host",description:"Canvas rendering and display"},talk:{label:"Talk",description:"Voice and speech settings"},plugins:{label:"Plugins",description:"Plugin management and extensions"}};function ao(e){return io[e]??io.default}function Dh(e,t,n){if(!n)return!0;const s=n.toLowerCase(),i=Ei[e];return e.toLowerCase().includes(s)||i&&(i.label.toLowerCase().includes(s)||i.description.toLowerCase().includes(s))?!0:Tt(t,s)}function Tt(e,t){if(e.title?.toLowerCase().includes(t)||e.description?.toLowerCase().includes(t)||e.enum?.some(s=>String(s).toLowerCase().includes(t)))return!0;if(e.properties){for(const[s,i]of Object.entries(e.properties))if(s.toLowerCase().includes(t)||Tt(i,t))return!0}if(e.items){const s=Array.isArray(e.items)?e.items:[e.items];for(const i of s)if(i&&Tt(i,t))return!0}if(e.additionalProperties&&typeof e.additionalProperties=="object"&&Tt(e.additionalProperties,t))return!0;const n=e.anyOf??e.oneOf??e.allOf;if(n){for(const s of n)if(s&&Tt(s,t))return!0}return!1}function Bh(e){if(!e.schema)return r`<div class="muted">Schema unavailable.</div>`;const t=e.schema,n=e.value??{};if(me(t)!=="object"||!t.properties)return r`<div class="callout danger">Unsupported schema. Use Raw.</div>`;const s=new Set(e.unsupportedPaths??[]),i=t.properties,a=e.searchQuery??"",o=e.activeSection,c=e.activeSubsection??null,u=Object.entries(i).sort((p,f)=>{const m=ie([p[0]],e.uiHints)?.order??50,v=ie([f[0]],e.uiHints)?.order??50;return m!==v?m-v:p[0].localeCompare(f[0])}).filter(([p,f])=>!(o&&p!==o||a&&!Dh(p,f,a)));let d=null;if(o&&c&&u.length===1){const p=u[0]?.[1];p&&me(p)==="object"&&p.properties&&p.properties[c]&&(d={sectionKey:o,subsectionKey:c,schema:p.properties[c]})}return u.length===0?r`
|
|
615
637
|
<div class="config-empty">
|
|
616
638
|
<div class="config-empty__icon">${G.search}</div>
|
|
617
639
|
<div class="config-empty__text">
|
|
618
640
|
${a?`No settings match "${a}"`:"No settings in this section"}
|
|
619
641
|
</div>
|
|
620
642
|
</div>
|
|
621
|
-
`:
|
|
643
|
+
`:r`
|
|
622
644
|
<div class="config-form config-form--modern">
|
|
623
|
-
${d?(()=>{const{sectionKey:p,subsectionKey:f,schema:m}=d,v=ie([p,f],e.uiHints),$=v?.label??m.title??Te(f),k=v?.help??m.description??"",_=n[p],M=_&&typeof _=="object"?_[f]:void 0,N=`config-section-${p}-${f}`;return
|
|
645
|
+
${d?(()=>{const{sectionKey:p,subsectionKey:f,schema:m}=d,v=ie([p,f],e.uiHints),$=v?.label??m.title??Te(f),k=v?.help??m.description??"",_=n[p],M=_&&typeof _=="object"?_[f]:void 0,N=`config-section-${p}-${f}`;return r`
|
|
624
646
|
<section class="config-section-card" id=${N}>
|
|
625
647
|
<div class="config-section-card__header">
|
|
626
|
-
<span class="config-section-card__icon">${
|
|
648
|
+
<span class="config-section-card__icon">${ao(p)}</span>
|
|
627
649
|
<div class="config-section-card__titles">
|
|
628
650
|
<h3 class="config-section-card__title">${$}</h3>
|
|
629
|
-
${k?
|
|
651
|
+
${k?r`<p class="config-section-card__desc">${k}</p>`:g}
|
|
630
652
|
</div>
|
|
631
653
|
</div>
|
|
632
654
|
<div class="config-section-card__content">
|
|
633
655
|
${_e({schema:m,value:M,path:[p,f],hints:e.uiHints,unsupported:s,disabled:e.disabled??!1,showLabel:!1,onPatch:e.onPatch})}
|
|
634
656
|
</div>
|
|
635
657
|
</section>
|
|
636
|
-
`})():u.map(([p,f])=>{const m=
|
|
658
|
+
`})():u.map(([p,f])=>{const m=Ei[p]??{label:p.charAt(0).toUpperCase()+p.slice(1),description:f.description??""};return r`
|
|
637
659
|
<section class="config-section-card" id="config-section-${p}">
|
|
638
660
|
<div class="config-section-card__header">
|
|
639
|
-
<span class="config-section-card__icon">${
|
|
661
|
+
<span class="config-section-card__icon">${ao(p)}</span>
|
|
640
662
|
<div class="config-section-card__titles">
|
|
641
663
|
<h3 class="config-section-card__title">${m.label}</h3>
|
|
642
|
-
${m.description?
|
|
664
|
+
${m.description?r`<p class="config-section-card__desc">${m.description}</p>`:g}
|
|
643
665
|
</div>
|
|
644
666
|
</div>
|
|
645
667
|
<div class="config-section-card__content">
|
|
@@ -648,7 +670,7 @@ ${e.sidebarContent}
|
|
|
648
670
|
</section>
|
|
649
671
|
`})}
|
|
650
672
|
</div>
|
|
651
|
-
`}const Ph=new Set(["title","description","default","nullable"]);function Nh(e){return Object.keys(e??{}).filter(n=>!Ph.has(n)).length===0}function Or(e){const t=e.filter(i=>i!=null),n=t.length!==e.length,s=[];for(const i of t)s.some(a=>Object.is(a,i))||s.push(i);return{enumValues:s,nullable:n}}function Dr(e){return!e||typeof e!="object"?{schema:null,unsupportedPaths:["<root>"]}:Et(e,[])}function Et(e,t){const n=new Set,s={...e},i=Pn(t)||"<root>";if(e.anyOf||e.oneOf||e.allOf){const c=Oh(e,t);return c||{schema:e,unsupportedPaths:[i]}}const a=Array.isArray(e.type)&&e.type.includes("null"),o=me(e)??(e.properties||e.additionalProperties?"object":void 0);if(s.type=o??e.type,s.nullable=a||e.nullable,s.enum){const{enumValues:c,nullable:r}=Or(s.enum);s.enum=c,r&&(s.nullable=!0),c.length===0&&n.add(i)}if(o==="object"){const c=e.properties??{},r={};for(const[u,d]of Object.entries(c)){const p=Et(d,[...t,u]);p.schema&&(r[u]=p.schema);for(const f of p.unsupportedPaths)n.add(f)}if(s.properties=r,e.additionalProperties===!0)n.add(i);else if(e.additionalProperties===!1)s.additionalProperties=!1;else if(e.additionalProperties&&typeof e.additionalProperties=="object"&&!Nh(e.additionalProperties)){const u=Et(e.additionalProperties,[...t,"*"]);s.additionalProperties=u.schema??e.additionalProperties,u.unsupportedPaths.length>0&&n.add(i)}}else if(o==="array"){const c=Array.isArray(e.items)?e.items[0]:e.items;if(!c)n.add(i);else{const r=Et(c,[...t,"*"]);s.items=r.schema??c,r.unsupportedPaths.length>0&&n.add(i)}}else o!=="string"&&o!=="number"&&o!=="integer"&&o!=="boolean"&&!s.enum&&n.add(i);return{schema:s,unsupportedPaths:Array.from(n)}}function Oh(e,t){if(e.allOf)return null;const n=e.anyOf??e.oneOf;if(!n)return null;const s=[],i=[];let a=!1;for(const c of n){if(!c||typeof c!="object")return null;if(Array.isArray(c.enum)){const{enumValues:r,nullable:u}=Or(c.enum);s.push(...r),u&&(a=!0);continue}if("const"in c){if(c.const==null){a=!0;continue}s.push(c.const);continue}if(me(c)==="null"){a=!0;continue}i.push(c)}if(s.length>0&&i.length===0){const c=[];for(const r of s)c.some(u=>Object.is(u,r))||c.push(r);return{schema:{...e,enum:c,nullable:a,anyOf:void 0,oneOf:void 0,allOf:void 0},unsupportedPaths:[]}}if(i.length===1){const c=Et(i[0],t);return c.schema&&(c.schema.nullable=a||c.schema.nullable),c}const o=["string","number","integer","boolean"];return i.length>0&&s.length===0&&i.every(c=>c.type&&o.includes(String(c.type)))?{schema:{...e,nullable:a},unsupportedPaths:[]}:null}const js={all:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>`,env:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>`,update:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>`,agents:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2z"></path><circle cx="8" cy="14" r="1"></circle><circle cx="16" cy="14" r="1"></circle></svg>`,auth:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><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>`,channels:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>`,messages:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>`,commands:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="4 17 10 11 4 5"></polyline><line x1="12" y1="19" x2="20" y2="19"></line></svg>`,hooks:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><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><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>`,skills:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>`,tools:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><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"></path></svg>`,gateway:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,wizard:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 4V2"></path><path d="M15 16v-2"></path><path d="M8 9h2"></path><path d="M20 9h2"></path><path d="M17.8 11.8 19 13"></path><path d="M15 9h0"></path><path d="M17.8 6.2 19 5"></path><path d="m3 21 9-9"></path><path d="M12.2 6.2 11 5"></path></svg>`,meta:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 20h9"></path><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"></path></svg>`,logging:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>`,browser:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><circle cx="12" cy="12" r="4"></circle><line x1="21.17" y1="8" x2="12" y2="8"></line><line x1="3.95" y1="6.06" x2="8.54" y2="14"></line><line x1="10.88" y1="21.94" x2="15.46" y2="14"></line></svg>`,ui:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="3" y1="9" x2="21" y2="9"></line><line x1="9" y1="21" x2="9" y2="9"></line></svg>`,models:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg>`,bindings:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6.01" y2="6"></line><line x1="6" y1="18" x2="6.01" y2="18"></line></svg>`,broadcast:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"></path><path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5"></path><circle cx="12" cy="12" r="2"></circle><path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5"></path><path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"></path></svg>`,audio:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg>`,session:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>`,cron:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>`,web:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,discovery:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>`,canvasHost:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>`,talk:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>`,plugins:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2v6"></path><path d="m4.93 10.93 4.24 4.24"></path><path d="M2 12h6"></path><path d="m4.93 13.07 4.24-4.24"></path><path d="M12 22v-6"></path><path d="m19.07 13.07-4.24-4.24"></path><path d="M22 12h-6"></path><path d="m19.07 10.93-4.24 4.24"></path></svg>`,default:l`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>`},io=[{key:"env",label:"Environment"},{key:"update",label:"Updates"},{key:"agents",label:"Agents"},{key:"auth",label:"Authentication"},{key:"channels",label:"Channels"},{key:"messages",label:"Messages"},{key:"commands",label:"Commands"},{key:"hooks",label:"Hooks"},{key:"skills",label:"Skills"},{key:"tools",label:"Tools"},{key:"gateway",label:"Gateway"},{key:"wizard",label:"Setup Wizard"}],ao="__all__";function oo(e){return js[e]??js.default}function Dh(e,t){const n=Ci[e];return n||{label:t?.title??Te(e),description:t?.description??""}}function Bh(e){const{key:t,schema:n,uiHints:s}=e;if(!n||me(n)!=="object"||!n.properties)return[];const i=Object.entries(n.properties).map(([a,o])=>{const c=ie([t,a],s),r=c?.label??o.title??Te(a),u=c?.help??o.description??"",d=c?.order??50;return{key:a,label:r,description:u,order:d}});return i.sort((a,o)=>a.order!==o.order?a.order-o.order:a.key.localeCompare(o.key)),i}function Fh(e,t){if(!e||!t)return[];const n=[];function s(i,a,o){if(i===a)return;if(typeof i!=typeof a){n.push({path:o,from:i,to:a});return}if(typeof i!="object"||i===null||a===null){i!==a&&n.push({path:o,from:i,to:a});return}if(Array.isArray(i)&&Array.isArray(a)){JSON.stringify(i)!==JSON.stringify(a)&&n.push({path:o,from:i,to:a});return}const c=i,r=a,u=new Set([...Object.keys(c),...Object.keys(r)]);for(const d of u)s(c[d],r[d],o?`${o}.${d}`:d)}return s(e,t,""),n}function ro(e,t=40){let n;try{n=JSON.stringify(e)??String(e)}catch{n=String(e)}return n.length<=t?n:n.slice(0,t-3)+"..."}function Uh(e){const t=e.valid==null?"unknown":e.valid?"valid":"invalid",n=Dr(e.schema),s=n.schema?n.unsupportedPaths.length>0:!1,i=n.schema?.properties??{},a=io.filter(E=>E.key in i),o=new Set(io.map(E=>E.key)),c=Object.keys(i).filter(E=>!o.has(E)).map(E=>({key:E,label:E.charAt(0).toUpperCase()+E.slice(1)})),r=[...a,...c],u=e.activeSection&&n.schema&&me(n.schema)==="object"?n.schema.properties?.[e.activeSection]:void 0,d=e.activeSection?Dh(e.activeSection,u):null,p=e.activeSection?Bh({key:e.activeSection,schema:u,uiHints:e.uiHints}):[],f=e.formMode==="form"&&!!e.activeSection&&p.length>0,m=e.activeSubsection===ao,v=e.searchQuery||m?null:e.activeSubsection??p[0]?.key??null,$=e.formMode==="form"?Fh(e.originalValue,e.formValue):[],k=e.formMode==="raw"&&e.raw!==e.originalRaw,_=e.formMode==="form"?$.length>0:k,M=!!e.formValue&&!e.loading&&!!n.schema,N=e.connected&&!e.saving&&_&&(e.formMode==="raw"?!0:M),R=e.connected&&!e.applying&&!e.updating&&_&&(e.formMode==="raw"?!0:M),C=e.connected&&!e.applying&&!e.updating;return l`
|
|
673
|
+
`}const Fh=new Set(["title","description","default","nullable"]);function Uh(e){return Object.keys(e??{}).filter(n=>!Fh.has(n)).length===0}function Ur(e){const t=e.filter(i=>i!=null),n=t.length!==e.length,s=[];for(const i of t)s.some(a=>Object.is(a,i))||s.push(i);return{enumValues:s,nullable:n}}function Kr(e){return!e||typeof e!="object"?{schema:null,unsupportedPaths:["<root>"]}:Et(e,[])}function Et(e,t){const n=new Set,s={...e},i=Pn(t)||"<root>";if(e.anyOf||e.oneOf||e.allOf){const c=Kh(e,t);return c||{schema:e,unsupportedPaths:[i]}}const a=Array.isArray(e.type)&&e.type.includes("null"),o=me(e)??(e.properties||e.additionalProperties?"object":void 0);if(s.type=o??e.type,s.nullable=a||e.nullable,s.enum){const{enumValues:c,nullable:l}=Ur(s.enum);s.enum=c,l&&(s.nullable=!0),c.length===0&&n.add(i)}if(o==="object"){const c=e.properties??{},l={};for(const[u,d]of Object.entries(c)){const p=Et(d,[...t,u]);p.schema&&(l[u]=p.schema);for(const f of p.unsupportedPaths)n.add(f)}if(s.properties=l,e.additionalProperties===!0)n.add(i);else if(e.additionalProperties===!1)s.additionalProperties=!1;else if(e.additionalProperties&&typeof e.additionalProperties=="object"&&!Uh(e.additionalProperties)){const u=Et(e.additionalProperties,[...t,"*"]);s.additionalProperties=u.schema??e.additionalProperties,u.unsupportedPaths.length>0&&n.add(i)}}else if(o==="array"){const c=Array.isArray(e.items)?e.items[0]:e.items;if(!c)n.add(i);else{const l=Et(c,[...t,"*"]);s.items=l.schema??c,l.unsupportedPaths.length>0&&n.add(i)}}else o!=="string"&&o!=="number"&&o!=="integer"&&o!=="boolean"&&!s.enum&&n.add(i);return{schema:s,unsupportedPaths:Array.from(n)}}function Kh(e,t){if(e.allOf)return null;const n=e.anyOf??e.oneOf;if(!n)return null;const s=[],i=[];let a=!1;for(const c of n){if(!c||typeof c!="object")return null;if(Array.isArray(c.enum)){const{enumValues:l,nullable:u}=Ur(c.enum);s.push(...l),u&&(a=!0);continue}if("const"in c){if(c.const==null){a=!0;continue}s.push(c.const);continue}if(me(c)==="null"){a=!0;continue}i.push(c)}if(s.length>0&&i.length===0){const c=[];for(const l of s)c.some(u=>Object.is(u,l))||c.push(l);return{schema:{...e,enum:c,nullable:a,anyOf:void 0,oneOf:void 0,allOf:void 0},unsupportedPaths:[]}}if(i.length===1){const c=Et(i[0],t);return c.schema&&(c.schema.nullable=a||c.schema.nullable),c}const o=["string","number","integer","boolean"];return i.length>0&&s.length===0&&i.every(c=>c.type&&o.includes(String(c.type)))?{schema:{...e,nullable:a},unsupportedPaths:[]}:null}const Vs={all:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>`,env:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>`,update:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>`,agents:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2z"></path><circle cx="8" cy="14" r="1"></circle><circle cx="16" cy="14" r="1"></circle></svg>`,auth:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><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>`,channels:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>`,messages:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>`,commands:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="4 17 10 11 4 5"></polyline><line x1="12" y1="19" x2="20" y2="19"></line></svg>`,hooks:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><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><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>`,skills:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>`,tools:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><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"></path></svg>`,gateway:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,wizard:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 4V2"></path><path d="M15 16v-2"></path><path d="M8 9h2"></path><path d="M20 9h2"></path><path d="M17.8 11.8 19 13"></path><path d="M15 9h0"></path><path d="M17.8 6.2 19 5"></path><path d="m3 21 9-9"></path><path d="M12.2 6.2 11 5"></path></svg>`,meta:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 20h9"></path><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"></path></svg>`,logging:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>`,browser:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><circle cx="12" cy="12" r="4"></circle><line x1="21.17" y1="8" x2="12" y2="8"></line><line x1="3.95" y1="6.06" x2="8.54" y2="14"></line><line x1="10.88" y1="21.94" x2="15.46" y2="14"></line></svg>`,ui:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="3" y1="9" x2="21" y2="9"></line><line x1="9" y1="21" x2="9" y2="9"></line></svg>`,models:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg>`,bindings:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6.01" y2="6"></line><line x1="6" y1="18" x2="6.01" y2="18"></line></svg>`,broadcast:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"></path><path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5"></path><circle cx="12" cy="12" r="2"></circle><path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5"></path><path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"></path></svg>`,audio:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg>`,session:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>`,cron:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>`,web:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,discovery:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>`,canvasHost:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>`,talk:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>`,plugins:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2v6"></path><path d="m4.93 10.93 4.24 4.24"></path><path d="M2 12h6"></path><path d="m4.93 13.07 4.24-4.24"></path><path d="M12 22v-6"></path><path d="m19.07 13.07-4.24-4.24"></path><path d="M22 12h-6"></path><path d="m19.07 10.93-4.24 4.24"></path></svg>`,default:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>`},oo=[{key:"env",label:"Environment"},{key:"update",label:"Updates"},{key:"agents",label:"Agents"},{key:"auth",label:"Authentication"},{key:"channels",label:"Channels"},{key:"messages",label:"Messages"},{key:"commands",label:"Commands"},{key:"hooks",label:"Hooks"},{key:"skills",label:"Skills"},{key:"tools",label:"Tools"},{key:"gateway",label:"Gateway"},{key:"wizard",label:"Setup Wizard"}],ro="__all__";function lo(e){return Vs[e]??Vs.default}function zh(e,t){const n=Ei[e];return n||{label:t?.title??Te(e),description:t?.description??""}}function Hh(e){const{key:t,schema:n,uiHints:s}=e;if(!n||me(n)!=="object"||!n.properties)return[];const i=Object.entries(n.properties).map(([a,o])=>{const c=ie([t,a],s),l=c?.label??o.title??Te(a),u=c?.help??o.description??"",d=c?.order??50;return{key:a,label:l,description:u,order:d}});return i.sort((a,o)=>a.order!==o.order?a.order-o.order:a.key.localeCompare(o.key)),i}function jh(e,t){if(!e||!t)return[];const n=[];function s(i,a,o){if(i===a)return;if(typeof i!=typeof a){n.push({path:o,from:i,to:a});return}if(typeof i!="object"||i===null||a===null){i!==a&&n.push({path:o,from:i,to:a});return}if(Array.isArray(i)&&Array.isArray(a)){JSON.stringify(i)!==JSON.stringify(a)&&n.push({path:o,from:i,to:a});return}const c=i,l=a,u=new Set([...Object.keys(c),...Object.keys(l)]);for(const d of u)s(c[d],l[d],o?`${o}.${d}`:d)}return s(e,t,""),n}function co(e,t=40){let n;try{n=JSON.stringify(e)??String(e)}catch{n=String(e)}return n.length<=t?n:n.slice(0,t-3)+"..."}function Vh(e){const t=e.valid==null?"unknown":e.valid?"valid":"invalid",n=Kr(e.schema),s=n.schema?n.unsupportedPaths.length>0:!1,i=n.schema?.properties??{},a=oo.filter(E=>E.key in i),o=new Set(oo.map(E=>E.key)),c=Object.keys(i).filter(E=>!o.has(E)).map(E=>({key:E,label:E.charAt(0).toUpperCase()+E.slice(1)})),l=[...a,...c],u=e.activeSection&&n.schema&&me(n.schema)==="object"?n.schema.properties?.[e.activeSection]:void 0,d=e.activeSection?zh(e.activeSection,u):null,p=e.activeSection?Hh({key:e.activeSection,schema:u,uiHints:e.uiHints}):[],f=e.formMode==="form"&&!!e.activeSection&&p.length>0,m=e.activeSubsection===ro,v=e.searchQuery||m?null:e.activeSubsection??p[0]?.key??null,$=e.formMode==="form"?jh(e.originalValue,e.formValue):[],k=e.formMode==="raw"&&e.raw!==e.originalRaw,_=e.formMode==="form"?$.length>0:k,M=!!e.formValue&&!e.loading&&!!n.schema,N=e.connected&&!e.saving&&_&&(e.formMode==="raw"?!0:M),R=e.connected&&!e.applying&&!e.updating&&_&&(e.formMode==="raw"?!0:M),C=e.connected&&!e.applying&&!e.updating;return r`
|
|
652
674
|
<div class="config-layout">
|
|
653
675
|
<!-- Sidebar -->
|
|
654
676
|
<aside class="config-sidebar">
|
|
@@ -670,7 +692,7 @@ ${e.sidebarContent}
|
|
|
670
692
|
.value=${e.searchQuery}
|
|
671
693
|
@input=${E=>e.onSearchChange(E.target.value)}
|
|
672
694
|
/>
|
|
673
|
-
${e.searchQuery?
|
|
695
|
+
${e.searchQuery?r`
|
|
674
696
|
<button
|
|
675
697
|
class="config-search__clear"
|
|
676
698
|
@click=${()=>e.onSearchChange("")}
|
|
@@ -684,15 +706,15 @@ ${e.sidebarContent}
|
|
|
684
706
|
class="config-nav__item ${e.activeSection===null?"active":""}"
|
|
685
707
|
@click=${()=>e.onSectionChange(null)}
|
|
686
708
|
>
|
|
687
|
-
<span class="config-nav__icon">${
|
|
709
|
+
<span class="config-nav__icon">${Vs.all}</span>
|
|
688
710
|
<span class="config-nav__label">All Settings</span>
|
|
689
711
|
</button>
|
|
690
|
-
${
|
|
712
|
+
${l.map(E=>r`
|
|
691
713
|
<button
|
|
692
714
|
class="config-nav__item ${e.activeSection===E.key?"active":""}"
|
|
693
715
|
@click=${()=>e.onSectionChange(E.key)}
|
|
694
716
|
>
|
|
695
|
-
<span class="config-nav__icon">${
|
|
717
|
+
<span class="config-nav__icon">${lo(E.key)}</span>
|
|
696
718
|
<span class="config-nav__label">${E.label}</span>
|
|
697
719
|
</button>
|
|
698
720
|
`)}
|
|
@@ -723,9 +745,9 @@ ${e.sidebarContent}
|
|
|
723
745
|
<!-- Action bar -->
|
|
724
746
|
<div class="config-actions">
|
|
725
747
|
<div class="config-actions__left">
|
|
726
|
-
${_?
|
|
748
|
+
${_?r`
|
|
727
749
|
<span class="config-changes-badge">${e.formMode==="raw"?"Unsaved changes":`${$.length} unsaved change${$.length!==1?"s":""}`}</span>
|
|
728
|
-
`:
|
|
750
|
+
`:r`
|
|
729
751
|
<span class="config-status muted">No changes</span>
|
|
730
752
|
`}
|
|
731
753
|
</div>
|
|
@@ -758,7 +780,7 @@ ${e.sidebarContent}
|
|
|
758
780
|
</div>
|
|
759
781
|
|
|
760
782
|
<!-- Diff panel (form mode only - raw mode doesn't have granular diff) -->
|
|
761
|
-
${_&&e.formMode==="form"?
|
|
783
|
+
${_&&e.formMode==="form"?r`
|
|
762
784
|
<details class="config-diff">
|
|
763
785
|
<summary class="config-diff__summary">
|
|
764
786
|
<span>View ${$.length} pending change${$.length!==1?"s":""}</span>
|
|
@@ -767,13 +789,13 @@ ${e.sidebarContent}
|
|
|
767
789
|
</svg>
|
|
768
790
|
</summary>
|
|
769
791
|
<div class="config-diff__content">
|
|
770
|
-
${$.map(E=>
|
|
792
|
+
${$.map(E=>r`
|
|
771
793
|
<div class="config-diff__item">
|
|
772
794
|
<div class="config-diff__path">${E.path}</div>
|
|
773
795
|
<div class="config-diff__values">
|
|
774
|
-
<span class="config-diff__from">${
|
|
796
|
+
<span class="config-diff__from">${co(E.from)}</span>
|
|
775
797
|
<span class="config-diff__arrow">→</span>
|
|
776
|
-
<span class="config-diff__to">${
|
|
798
|
+
<span class="config-diff__to">${co(E.to)}</span>
|
|
777
799
|
</div>
|
|
778
800
|
</div>
|
|
779
801
|
`)}
|
|
@@ -781,25 +803,25 @@ ${e.sidebarContent}
|
|
|
781
803
|
</details>
|
|
782
804
|
`:g}
|
|
783
805
|
|
|
784
|
-
${d&&e.formMode==="form"?
|
|
806
|
+
${d&&e.formMode==="form"?r`
|
|
785
807
|
<div class="config-section-hero">
|
|
786
|
-
<div class="config-section-hero__icon">${
|
|
808
|
+
<div class="config-section-hero__icon">${lo(e.activeSection??"")}</div>
|
|
787
809
|
<div class="config-section-hero__text">
|
|
788
810
|
<div class="config-section-hero__title">${d.label}</div>
|
|
789
|
-
${d.description?
|
|
811
|
+
${d.description?r`<div class="config-section-hero__desc">${d.description}</div>`:g}
|
|
790
812
|
</div>
|
|
791
813
|
</div>
|
|
792
814
|
`:g}
|
|
793
815
|
|
|
794
|
-
${f?
|
|
816
|
+
${f?r`
|
|
795
817
|
<div class="config-subnav">
|
|
796
818
|
<button
|
|
797
819
|
class="config-subnav__item ${v===null?"active":""}"
|
|
798
|
-
@click=${()=>e.onSubsectionChange(
|
|
820
|
+
@click=${()=>e.onSubsectionChange(ro)}
|
|
799
821
|
>
|
|
800
822
|
All
|
|
801
823
|
</button>
|
|
802
|
-
${p.map(E=>
|
|
824
|
+
${p.map(E=>r`
|
|
803
825
|
<button
|
|
804
826
|
class="config-subnav__item ${v===E.key?"active":""}"
|
|
805
827
|
title=${E.description||E.label}
|
|
@@ -813,16 +835,16 @@ ${e.sidebarContent}
|
|
|
813
835
|
|
|
814
836
|
<!-- Form content -->
|
|
815
837
|
<div class="config-content">
|
|
816
|
-
${e.formMode==="form"?
|
|
817
|
-
${e.schemaLoading?
|
|
838
|
+
${e.formMode==="form"?r`
|
|
839
|
+
${e.schemaLoading?r`<div class="config-loading">
|
|
818
840
|
<div class="config-loading__spinner"></div>
|
|
819
841
|
<span>Loading schema…</span>
|
|
820
|
-
</div>`:
|
|
821
|
-
${s?
|
|
842
|
+
</div>`:Bh({schema:n.schema,uiHints:e.uiHints,value:e.formValue,disabled:e.loading||!e.formValue,unsupportedPaths:n.unsupportedPaths,onPatch:e.onFormPatch,searchQuery:e.searchQuery,activeSection:e.activeSection,activeSubsection:v})}
|
|
843
|
+
${s?r`<div class="callout danger" style="margin-top: 12px;">
|
|
822
844
|
Form view can't safely edit some fields.
|
|
823
845
|
Use Raw to avoid losing config entries.
|
|
824
846
|
</div>`:g}
|
|
825
|
-
`:
|
|
847
|
+
`:r`
|
|
826
848
|
<label class="field config-raw-field">
|
|
827
849
|
<span>Raw JSON5</span>
|
|
828
850
|
<textarea
|
|
@@ -833,18 +855,18 @@ ${e.sidebarContent}
|
|
|
833
855
|
`}
|
|
834
856
|
</div>
|
|
835
857
|
|
|
836
|
-
${e.issues.length>0?
|
|
858
|
+
${e.issues.length>0?r`<div class="callout danger" style="margin-top: 12px;">
|
|
837
859
|
<pre class="code-block">${JSON.stringify(e.issues,null,2)}</pre>
|
|
838
860
|
</div>`:g}
|
|
839
861
|
</main>
|
|
840
862
|
</div>
|
|
841
|
-
`}function
|
|
863
|
+
`}function Wh(e){if(!e&&e!==0)return"n/a";const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);return n<60?`${n}m`:`${Math.round(n/60)}h`}function qh(e,t){const n=t.snapshot,s=n?.channels;if(!n||!s)return!1;const i=s[e],a=typeof i?.configured=="boolean"&&i.configured,o=typeof i?.running=="boolean"&&i.running,c=typeof i?.connected=="boolean"&&i.connected,u=(n.channelAccounts?.[e]??[]).some(d=>d.configured||d.running||d.connected);return a||o||c||u}function Gh(e,t){return t?.[e]?.length??0}function zr(e,t){const n=Gh(e,t);return n<2?g:r`<div class="account-count">Accounts (${n})</div>`}function Yh(e,t){let n=e;for(const s of t){if(!n)return null;const i=me(n);if(i==="object"){const a=n.properties??{};if(typeof s=="string"&&a[s]){n=a[s];continue}const o=n.additionalProperties;if(typeof s=="string"&&o&&typeof o=="object"){n=o;continue}return null}if(i==="array"){if(typeof s!="number")return null;n=(Array.isArray(n.items)?n.items[0]:n.items)??null;continue}return null}return n}function Qh(e,t){const s=(e.channels??{})[t],i=e[t];return(s&&typeof s=="object"?s:null)??(i&&typeof i=="object"?i:null)??{}}function Jh(e){const t=Kr(e.schema),n=t.schema;if(!n)return r`<div class="callout danger">Schema unavailable. Use Raw.</div>`;const s=Yh(n,["channels",e.channelId]);if(!s)return r`<div class="callout danger">Channel config schema unavailable.</div>`;const i=e.configValue??{},a=Qh(i,e.channelId);return r`
|
|
842
864
|
<div class="config-form">
|
|
843
865
|
${_e({schema:s,value:a,path:["channels",e.channelId],hints:e.uiHints,unsupported:new Set(t.unsupportedPaths),disabled:e.disabled,showLabel:!1,onPatch:e.onPatch})}
|
|
844
866
|
</div>
|
|
845
|
-
`}function Ce(e){const{channelId:t,props:n}=e,s=n.configSaving||n.configSchemaLoading;return
|
|
867
|
+
`}function Ce(e){const{channelId:t,props:n}=e,s=n.configSaving||n.configSchemaLoading;return r`
|
|
846
868
|
<div style="margin-top: 16px;">
|
|
847
|
-
${n.configSchemaLoading?
|
|
869
|
+
${n.configSchemaLoading?r`<div class="muted">Loading config schema…</div>`:Jh({channelId:t,configValue:n.configForm,schema:n.configSchema,uiHints:n.configUiHints,disabled:s,onPatch:n.onConfigPatch})}
|
|
848
870
|
<div class="row" style="margin-top: 12px;">
|
|
849
871
|
<button
|
|
850
872
|
class="btn primary"
|
|
@@ -862,7 +884,7 @@ ${e.sidebarContent}
|
|
|
862
884
|
</button>
|
|
863
885
|
</div>
|
|
864
886
|
</div>
|
|
865
|
-
`}function
|
|
887
|
+
`}function Zh(e){const{props:t,discord:n,accountCountLabel:s}=e;return r`
|
|
866
888
|
<div class="card">
|
|
867
889
|
<div class="card-title">Discord</div>
|
|
868
890
|
<div class="card-sub">Bot status and channel configuration.</div>
|
|
@@ -887,11 +909,11 @@ ${e.sidebarContent}
|
|
|
887
909
|
</div>
|
|
888
910
|
</div>
|
|
889
911
|
|
|
890
|
-
${n?.lastError?
|
|
912
|
+
${n?.lastError?r`<div class="callout danger" style="margin-top: 12px;">
|
|
891
913
|
${n.lastError}
|
|
892
914
|
</div>`:g}
|
|
893
915
|
|
|
894
|
-
${n?.probe?
|
|
916
|
+
${n?.probe?r`<div class="callout" style="margin-top: 12px;">
|
|
895
917
|
Probe ${n.probe.ok?"ok":"failed"} ·
|
|
896
918
|
${n.probe.status??""} ${n.probe.error??""}
|
|
897
919
|
</div>`:g}
|
|
@@ -904,7 +926,7 @@ ${e.sidebarContent}
|
|
|
904
926
|
</button>
|
|
905
927
|
</div>
|
|
906
928
|
</div>
|
|
907
|
-
`}function
|
|
929
|
+
`}function Xh(e){const{props:t,googleChat:n,accountCountLabel:s}=e;return r`
|
|
908
930
|
<div class="card">
|
|
909
931
|
<div class="card-title">Google Chat</div>
|
|
910
932
|
<div class="card-sub">Chat API webhook status and channel configuration.</div>
|
|
@@ -939,11 +961,11 @@ ${e.sidebarContent}
|
|
|
939
961
|
</div>
|
|
940
962
|
</div>
|
|
941
963
|
|
|
942
|
-
${n?.lastError?
|
|
964
|
+
${n?.lastError?r`<div class="callout danger" style="margin-top: 12px;">
|
|
943
965
|
${n.lastError}
|
|
944
966
|
</div>`:g}
|
|
945
967
|
|
|
946
|
-
${n?.probe?
|
|
968
|
+
${n?.probe?r`<div class="callout" style="margin-top: 12px;">
|
|
947
969
|
Probe ${n.probe.ok?"ok":"failed"} ·
|
|
948
970
|
${n.probe.status??""} ${n.probe.error??""}
|
|
949
971
|
</div>`:g}
|
|
@@ -956,7 +978,7 @@ ${e.sidebarContent}
|
|
|
956
978
|
</button>
|
|
957
979
|
</div>
|
|
958
980
|
</div>
|
|
959
|
-
`}function
|
|
981
|
+
`}function ef(e){const{props:t,imessage:n,accountCountLabel:s}=e;return r`
|
|
960
982
|
<div class="card">
|
|
961
983
|
<div class="card-title">iMessage</div>
|
|
962
984
|
<div class="card-sub">macOS bridge status and channel configuration.</div>
|
|
@@ -981,11 +1003,11 @@ ${e.sidebarContent}
|
|
|
981
1003
|
</div>
|
|
982
1004
|
</div>
|
|
983
1005
|
|
|
984
|
-
${n?.lastError?
|
|
1006
|
+
${n?.lastError?r`<div class="callout danger" style="margin-top: 12px;">
|
|
985
1007
|
${n.lastError}
|
|
986
1008
|
</div>`:g}
|
|
987
1009
|
|
|
988
|
-
${n?.probe?
|
|
1010
|
+
${n?.probe?r`<div class="callout" style="margin-top: 12px;">
|
|
989
1011
|
Probe ${n.probe.ok?"ok":"failed"} ·
|
|
990
1012
|
${n.probe.error??""}
|
|
991
1013
|
</div>`:g}
|
|
@@ -998,10 +1020,10 @@ ${e.sidebarContent}
|
|
|
998
1020
|
</button>
|
|
999
1021
|
</div>
|
|
1000
1022
|
</div>
|
|
1001
|
-
`}function
|
|
1023
|
+
`}function tf(e){const{values:t,original:n}=e;return t.name!==n.name||t.displayName!==n.displayName||t.about!==n.about||t.picture!==n.picture||t.banner!==n.banner||t.website!==n.website||t.nip05!==n.nip05||t.lud16!==n.lud16}function nf(e){const{state:t,callbacks:n,accountId:s}=e,i=tf(t),a=(c,l,u={})=>{const{type:d="text",placeholder:p,maxLength:f,help:m}=u,v=t.values[c]??"",$=t.fieldErrors[c],k=`nostr-profile-${c}`;return d==="textarea"?r`
|
|
1002
1024
|
<div class="form-field" style="margin-bottom: 12px;">
|
|
1003
1025
|
<label for="${k}" style="display: block; margin-bottom: 4px; font-weight: 500;">
|
|
1004
|
-
${
|
|
1026
|
+
${l}
|
|
1005
1027
|
</label>
|
|
1006
1028
|
<textarea
|
|
1007
1029
|
id="${k}"
|
|
@@ -1013,13 +1035,13 @@ ${e.sidebarContent}
|
|
|
1013
1035
|
@input=${_=>{const M=_.target;n.onFieldChange(c,M.value)}}
|
|
1014
1036
|
?disabled=${t.saving}
|
|
1015
1037
|
></textarea>
|
|
1016
|
-
${m?
|
|
1017
|
-
${$?
|
|
1038
|
+
${m?r`<div style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">${m}</div>`:g}
|
|
1039
|
+
${$?r`<div style="font-size: 12px; color: var(--danger-color); margin-top: 2px;">${$}</div>`:g}
|
|
1018
1040
|
</div>
|
|
1019
|
-
`:
|
|
1041
|
+
`:r`
|
|
1020
1042
|
<div class="form-field" style="margin-bottom: 12px;">
|
|
1021
1043
|
<label for="${k}" style="display: block; margin-bottom: 4px; font-weight: 500;">
|
|
1022
|
-
${
|
|
1044
|
+
${l}
|
|
1023
1045
|
</label>
|
|
1024
1046
|
<input
|
|
1025
1047
|
id="${k}"
|
|
@@ -1031,29 +1053,29 @@ ${e.sidebarContent}
|
|
|
1031
1053
|
@input=${_=>{const M=_.target;n.onFieldChange(c,M.value)}}
|
|
1032
1054
|
?disabled=${t.saving}
|
|
1033
1055
|
/>
|
|
1034
|
-
${m?
|
|
1035
|
-
${$?
|
|
1056
|
+
${m?r`<div style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">${m}</div>`:g}
|
|
1057
|
+
${$?r`<div style="font-size: 12px; color: var(--danger-color); margin-top: 2px;">${$}</div>`:g}
|
|
1036
1058
|
</div>
|
|
1037
|
-
`},o=()=>{const c=t.values.picture;return c?
|
|
1059
|
+
`},o=()=>{const c=t.values.picture;return c?r`
|
|
1038
1060
|
<div style="margin-bottom: 12px;">
|
|
1039
1061
|
<img
|
|
1040
1062
|
src=${c}
|
|
1041
1063
|
alt="Profile picture preview"
|
|
1042
1064
|
style="max-width: 80px; max-height: 80px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-color);"
|
|
1043
|
-
@error=${
|
|
1044
|
-
@load=${
|
|
1065
|
+
@error=${l=>{const u=l.target;u.style.display="none"}}
|
|
1066
|
+
@load=${l=>{const u=l.target;u.style.display="block"}}
|
|
1045
1067
|
/>
|
|
1046
1068
|
</div>
|
|
1047
|
-
`:g};return
|
|
1069
|
+
`:g};return r`
|
|
1048
1070
|
<div class="nostr-profile-form" style="padding: 16px; background: var(--bg-secondary); border-radius: 8px; margin-top: 12px;">
|
|
1049
1071
|
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;">
|
|
1050
1072
|
<div style="font-weight: 600; font-size: 16px;">Edit Profile</div>
|
|
1051
1073
|
<div style="font-size: 12px; color: var(--text-muted);">Account: ${s}</div>
|
|
1052
1074
|
</div>
|
|
1053
1075
|
|
|
1054
|
-
${t.error?
|
|
1076
|
+
${t.error?r`<div class="callout danger" style="margin-bottom: 12px;">${t.error}</div>`:g}
|
|
1055
1077
|
|
|
1056
|
-
${t.success?
|
|
1078
|
+
${t.success?r`<div class="callout success" style="margin-bottom: 12px;">${t.success}</div>`:g}
|
|
1057
1079
|
|
|
1058
1080
|
${o()}
|
|
1059
1081
|
|
|
@@ -1065,7 +1087,7 @@ ${e.sidebarContent}
|
|
|
1065
1087
|
|
|
1066
1088
|
${a("picture","Avatar URL",{type:"url",placeholder:"https://example.com/avatar.jpg",help:"HTTPS URL to your profile picture"})}
|
|
1067
1089
|
|
|
1068
|
-
${t.showAdvanced?
|
|
1090
|
+
${t.showAdvanced?r`
|
|
1069
1091
|
<div style="border-top: 1px solid var(--border-color); padding-top: 12px; margin-top: 12px;">
|
|
1070
1092
|
<div style="font-weight: 500; margin-bottom: 12px; color: var(--text-muted);">Advanced</div>
|
|
1071
1093
|
|
|
@@ -1112,11 +1134,11 @@ ${e.sidebarContent}
|
|
|
1112
1134
|
</button>
|
|
1113
1135
|
</div>
|
|
1114
1136
|
|
|
1115
|
-
${i?
|
|
1137
|
+
${i?r`<div style="font-size: 12px; color: var(--warning-color); margin-top: 8px;">
|
|
1116
1138
|
You have unsaved changes
|
|
1117
1139
|
</div>`:g}
|
|
1118
1140
|
</div>
|
|
1119
|
-
`}function
|
|
1141
|
+
`}function sf(e){const t={name:e?.name??"",displayName:e?.displayName??"",about:e?.about??"",picture:e?.picture??"",banner:e?.banner??"",website:e?.website??"",nip05:e?.nip05??"",lud16:e?.lud16??""};return{values:t,original:{...t},saving:!1,importing:!1,error:null,success:null,fieldErrors:{},showAdvanced:!!(e?.banner||e?.website||e?.nip05||e?.lud16)}}function uo(e){return e?e.length<=20?e:`${e.slice(0,8)}...${e.slice(-8)}`:"n/a"}function af(e){const{props:t,nostr:n,nostrAccounts:s,accountCountLabel:i,profileFormState:a,profileFormCallbacks:o,onEditProfile:c}=e,l=s[0],u=n?.configured??l?.configured??!1,d=n?.running??l?.running??!1,p=n?.publicKey??l?.publicKey,f=n?.lastStartAt??l?.lastStartAt??null,m=n?.lastError??l?.lastError??null,v=s.length>1,$=a!=null,k=M=>{const N=M.publicKey,R=M.profile,C=R?.displayName??R?.name??M.name??M.accountId;return r`
|
|
1120
1142
|
<div class="account-card">
|
|
1121
1143
|
<div class="account-card-header">
|
|
1122
1144
|
<div class="account-card-title">${C}</div>
|
|
@@ -1133,22 +1155,22 @@ ${e.sidebarContent}
|
|
|
1133
1155
|
</div>
|
|
1134
1156
|
<div>
|
|
1135
1157
|
<span class="label">Public Key</span>
|
|
1136
|
-
<span class="monospace" title="${N??""}">${
|
|
1158
|
+
<span class="monospace" title="${N??""}">${uo(N)}</span>
|
|
1137
1159
|
</div>
|
|
1138
1160
|
<div>
|
|
1139
1161
|
<span class="label">Last inbound</span>
|
|
1140
1162
|
<span>${M.lastInboundAt?D(M.lastInboundAt):"n/a"}</span>
|
|
1141
1163
|
</div>
|
|
1142
|
-
${M.lastError?
|
|
1164
|
+
${M.lastError?r`
|
|
1143
1165
|
<div class="account-card-error">${M.lastError}</div>
|
|
1144
1166
|
`:g}
|
|
1145
1167
|
</div>
|
|
1146
1168
|
</div>
|
|
1147
|
-
`},_=()=>{if($&&o)return
|
|
1169
|
+
`},_=()=>{if($&&o)return nf({state:a,callbacks:o,accountId:s[0]?.accountId??"default"});const M=l?.profile??n?.profile,{name:N,displayName:R,about:C,picture:E,nip05:ve}=M??{},Nn=N||R||C||E||ve;return r`
|
|
1148
1170
|
<div style="margin-top: 16px; padding: 12px; background: var(--bg-secondary); border-radius: 8px;">
|
|
1149
1171
|
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
|
|
1150
1172
|
<div style="font-weight: 500;">Profile</div>
|
|
1151
|
-
${u?
|
|
1173
|
+
${u?r`
|
|
1152
1174
|
<button
|
|
1153
1175
|
class="btn btn-sm"
|
|
1154
1176
|
@click=${c}
|
|
@@ -1158,9 +1180,9 @@ ${e.sidebarContent}
|
|
|
1158
1180
|
</button>
|
|
1159
1181
|
`:g}
|
|
1160
1182
|
</div>
|
|
1161
|
-
${Nn?
|
|
1183
|
+
${Nn?r`
|
|
1162
1184
|
<div class="status-list">
|
|
1163
|
-
${E?
|
|
1185
|
+
${E?r`
|
|
1164
1186
|
<div style="margin-bottom: 8px;">
|
|
1165
1187
|
<img
|
|
1166
1188
|
src=${E}
|
|
@@ -1170,28 +1192,28 @@ ${e.sidebarContent}
|
|
|
1170
1192
|
/>
|
|
1171
1193
|
</div>
|
|
1172
1194
|
`:g}
|
|
1173
|
-
${N?
|
|
1174
|
-
${R?
|
|
1175
|
-
${C?
|
|
1176
|
-
${ve?
|
|
1195
|
+
${N?r`<div><span class="label">Name</span><span>${N}</span></div>`:g}
|
|
1196
|
+
${R?r`<div><span class="label">Display Name</span><span>${R}</span></div>`:g}
|
|
1197
|
+
${C?r`<div><span class="label">About</span><span style="max-width: 300px; overflow: hidden; text-overflow: ellipsis;">${C}</span></div>`:g}
|
|
1198
|
+
${ve?r`<div><span class="label">NIP-05</span><span>${ve}</span></div>`:g}
|
|
1177
1199
|
</div>
|
|
1178
|
-
`:
|
|
1200
|
+
`:r`
|
|
1179
1201
|
<div style="color: var(--text-muted); font-size: 13px;">
|
|
1180
1202
|
No profile set. Click "Edit Profile" to add your name, bio, and avatar.
|
|
1181
1203
|
</div>
|
|
1182
1204
|
`}
|
|
1183
1205
|
</div>
|
|
1184
|
-
`};return
|
|
1206
|
+
`};return r`
|
|
1185
1207
|
<div class="card">
|
|
1186
1208
|
<div class="card-title">Nostr</div>
|
|
1187
1209
|
<div class="card-sub">Decentralized DMs via Nostr relays (NIP-04).</div>
|
|
1188
1210
|
${i}
|
|
1189
1211
|
|
|
1190
|
-
${v?
|
|
1212
|
+
${v?r`
|
|
1191
1213
|
<div class="account-card-list">
|
|
1192
1214
|
${s.map(M=>k(M))}
|
|
1193
1215
|
</div>
|
|
1194
|
-
`:
|
|
1216
|
+
`:r`
|
|
1195
1217
|
<div class="status-list" style="margin-top: 16px;">
|
|
1196
1218
|
<div>
|
|
1197
1219
|
<span class="label">Configured</span>
|
|
@@ -1204,7 +1226,7 @@ ${e.sidebarContent}
|
|
|
1204
1226
|
<div>
|
|
1205
1227
|
<span class="label">Public Key</span>
|
|
1206
1228
|
<span class="monospace" title="${p??""}"
|
|
1207
|
-
>${
|
|
1229
|
+
>${uo(p)}</span
|
|
1208
1230
|
>
|
|
1209
1231
|
</div>
|
|
1210
1232
|
<div>
|
|
@@ -1214,7 +1236,7 @@ ${e.sidebarContent}
|
|
|
1214
1236
|
</div>
|
|
1215
1237
|
`}
|
|
1216
1238
|
|
|
1217
|
-
${m?
|
|
1239
|
+
${m?r`<div class="callout danger" style="margin-top: 12px;">${m}</div>`:g}
|
|
1218
1240
|
|
|
1219
1241
|
${_()}
|
|
1220
1242
|
|
|
@@ -1224,7 +1246,7 @@ ${e.sidebarContent}
|
|
|
1224
1246
|
<button class="btn" @click=${()=>t.onRefresh(!1)}>Refresh</button>
|
|
1225
1247
|
</div>
|
|
1226
1248
|
</div>
|
|
1227
|
-
`}function
|
|
1249
|
+
`}function of(e){const{props:t,signal:n,accountCountLabel:s}=e;return r`
|
|
1228
1250
|
<div class="card">
|
|
1229
1251
|
<div class="card-title">Signal</div>
|
|
1230
1252
|
<div class="card-sub">signal-cli status and channel configuration.</div>
|
|
@@ -1253,11 +1275,11 @@ ${e.sidebarContent}
|
|
|
1253
1275
|
</div>
|
|
1254
1276
|
</div>
|
|
1255
1277
|
|
|
1256
|
-
${n?.lastError?
|
|
1278
|
+
${n?.lastError?r`<div class="callout danger" style="margin-top: 12px;">
|
|
1257
1279
|
${n.lastError}
|
|
1258
1280
|
</div>`:g}
|
|
1259
1281
|
|
|
1260
|
-
${n?.probe?
|
|
1282
|
+
${n?.probe?r`<div class="callout" style="margin-top: 12px;">
|
|
1261
1283
|
Probe ${n.probe.ok?"ok":"failed"} ·
|
|
1262
1284
|
${n.probe.status??""} ${n.probe.error??""}
|
|
1263
1285
|
</div>`:g}
|
|
@@ -1270,7 +1292,7 @@ ${e.sidebarContent}
|
|
|
1270
1292
|
</button>
|
|
1271
1293
|
</div>
|
|
1272
1294
|
</div>
|
|
1273
|
-
`}function
|
|
1295
|
+
`}function rf(e){const{props:t,slack:n,accountCountLabel:s}=e;return r`
|
|
1274
1296
|
<div class="card">
|
|
1275
1297
|
<div class="card-title">Slack</div>
|
|
1276
1298
|
<div class="card-sub">Socket mode status and channel configuration.</div>
|
|
@@ -1295,11 +1317,11 @@ ${e.sidebarContent}
|
|
|
1295
1317
|
</div>
|
|
1296
1318
|
</div>
|
|
1297
1319
|
|
|
1298
|
-
${n?.lastError?
|
|
1320
|
+
${n?.lastError?r`<div class="callout danger" style="margin-top: 12px;">
|
|
1299
1321
|
${n.lastError}
|
|
1300
1322
|
</div>`:g}
|
|
1301
1323
|
|
|
1302
|
-
${n?.probe?
|
|
1324
|
+
${n?.probe?r`<div class="callout" style="margin-top: 12px;">
|
|
1303
1325
|
Probe ${n.probe.ok?"ok":"failed"} ·
|
|
1304
1326
|
${n.probe.status??""} ${n.probe.error??""}
|
|
1305
1327
|
</div>`:g}
|
|
@@ -1312,7 +1334,7 @@ ${e.sidebarContent}
|
|
|
1312
1334
|
</button>
|
|
1313
1335
|
</div>
|
|
1314
1336
|
</div>
|
|
1315
|
-
`}function
|
|
1337
|
+
`}function lf(e){const{props:t,telegram:n,telegramAccounts:s,accountCountLabel:i}=e,a=s.length>1,o=c=>{const u=c.probe?.bot?.username,d=c.name||c.accountId;return r`
|
|
1316
1338
|
<div class="account-card">
|
|
1317
1339
|
<div class="account-card-header">
|
|
1318
1340
|
<div class="account-card-title">
|
|
@@ -1333,24 +1355,24 @@ ${e.sidebarContent}
|
|
|
1333
1355
|
<span class="label">Last inbound</span>
|
|
1334
1356
|
<span>${c.lastInboundAt?D(c.lastInboundAt):"n/a"}</span>
|
|
1335
1357
|
</div>
|
|
1336
|
-
${c.lastError?
|
|
1358
|
+
${c.lastError?r`
|
|
1337
1359
|
<div class="account-card-error">
|
|
1338
1360
|
${c.lastError}
|
|
1339
1361
|
</div>
|
|
1340
1362
|
`:g}
|
|
1341
1363
|
</div>
|
|
1342
1364
|
</div>
|
|
1343
|
-
`};return
|
|
1365
|
+
`};return r`
|
|
1344
1366
|
<div class="card">
|
|
1345
1367
|
<div class="card-title">Telegram</div>
|
|
1346
1368
|
<div class="card-sub">Bot status and channel configuration.</div>
|
|
1347
1369
|
${i}
|
|
1348
1370
|
|
|
1349
|
-
${a?
|
|
1371
|
+
${a?r`
|
|
1350
1372
|
<div class="account-card-list">
|
|
1351
1373
|
${s.map(c=>o(c))}
|
|
1352
1374
|
</div>
|
|
1353
|
-
`:
|
|
1375
|
+
`:r`
|
|
1354
1376
|
<div class="status-list" style="margin-top: 16px;">
|
|
1355
1377
|
<div>
|
|
1356
1378
|
<span class="label">Configured</span>
|
|
@@ -1375,11 +1397,11 @@ ${e.sidebarContent}
|
|
|
1375
1397
|
</div>
|
|
1376
1398
|
`}
|
|
1377
1399
|
|
|
1378
|
-
${n?.lastError?
|
|
1400
|
+
${n?.lastError?r`<div class="callout danger" style="margin-top: 12px;">
|
|
1379
1401
|
${n.lastError}
|
|
1380
1402
|
</div>`:g}
|
|
1381
1403
|
|
|
1382
|
-
${n?.probe?
|
|
1404
|
+
${n?.probe?r`<div class="callout" style="margin-top: 12px;">
|
|
1383
1405
|
Probe ${n.probe.ok?"ok":"failed"} ·
|
|
1384
1406
|
${n.probe.status??""} ${n.probe.error??""}
|
|
1385
1407
|
</div>`:g}
|
|
@@ -1392,7 +1414,7 @@ ${e.sidebarContent}
|
|
|
1392
1414
|
</button>
|
|
1393
1415
|
</div>
|
|
1394
1416
|
</div>
|
|
1395
|
-
`}function
|
|
1417
|
+
`}function cf(e){const{props:t,whatsapp:n,accountCountLabel:s}=e;return r`
|
|
1396
1418
|
<div class="card">
|
|
1397
1419
|
<div class="card-title">WhatsApp</div>
|
|
1398
1420
|
<div class="card-sub">Link WhatsApp Web and monitor connection health.</div>
|
|
@@ -1430,20 +1452,20 @@ ${e.sidebarContent}
|
|
|
1430
1452
|
<div>
|
|
1431
1453
|
<span class="label">Auth age</span>
|
|
1432
1454
|
<span>
|
|
1433
|
-
${n?.authAgeMs!=null?
|
|
1455
|
+
${n?.authAgeMs!=null?Wh(n.authAgeMs):"n/a"}
|
|
1434
1456
|
</span>
|
|
1435
1457
|
</div>
|
|
1436
1458
|
</div>
|
|
1437
1459
|
|
|
1438
|
-
${n?.lastError?
|
|
1460
|
+
${n?.lastError?r`<div class="callout danger" style="margin-top: 12px;">
|
|
1439
1461
|
${n.lastError}
|
|
1440
1462
|
</div>`:g}
|
|
1441
1463
|
|
|
1442
|
-
${t.whatsappMessage?
|
|
1464
|
+
${t.whatsappMessage?r`<div class="callout" style="margin-top: 12px;">
|
|
1443
1465
|
${t.whatsappMessage}
|
|
1444
1466
|
</div>`:g}
|
|
1445
1467
|
|
|
1446
|
-
${t.whatsappQrDataUrl?
|
|
1468
|
+
${t.whatsappQrDataUrl?r`<div class="qr-wrap">
|
|
1447
1469
|
<img src=${t.whatsappQrDataUrl} alt="WhatsApp QR" />
|
|
1448
1470
|
</div>`:g}
|
|
1449
1471
|
|
|
@@ -1483,9 +1505,9 @@ ${e.sidebarContent}
|
|
|
1483
1505
|
|
|
1484
1506
|
${Ce({channelId:"whatsapp",props:t})}
|
|
1485
1507
|
</div>
|
|
1486
|
-
`}function
|
|
1508
|
+
`}function df(e){const t=e.snapshot?.channels,n=t?.whatsapp??void 0,s=t?.telegram??void 0,i=t?.discord??null;t?.googlechat;const a=t?.slack??null,o=t?.signal??null,c=t?.imessage??null,l=t?.nostr??null,d=uf(e.snapshot).map((p,f)=>({key:p,enabled:qh(p,e),order:f})).sort((p,f)=>p.enabled!==f.enabled?p.enabled?-1:1:p.order-f.order);return r`
|
|
1487
1509
|
<section class="grid grid-cols-2">
|
|
1488
|
-
${d.map(p=>
|
|
1510
|
+
${d.map(p=>pf(p.key,e,{whatsapp:n,telegram:s,discord:i,slack:a,signal:o,imessage:c,nostr:l,channelAccounts:e.snapshot?.channelAccounts??null}))}
|
|
1489
1511
|
</section>
|
|
1490
1512
|
|
|
1491
1513
|
<section class="card" style="margin-top: 18px;">
|
|
@@ -1496,24 +1518,24 @@ ${e.sidebarContent}
|
|
|
1496
1518
|
</div>
|
|
1497
1519
|
<div class="muted">${e.lastSuccessAt?D(e.lastSuccessAt):"n/a"}</div>
|
|
1498
1520
|
</div>
|
|
1499
|
-
${e.lastError?
|
|
1521
|
+
${e.lastError?r`<div class="callout danger" style="margin-top: 12px;">
|
|
1500
1522
|
${e.lastError}
|
|
1501
1523
|
</div>`:g}
|
|
1502
1524
|
<pre class="code-block" style="margin-top: 12px;">
|
|
1503
1525
|
${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
1504
1526
|
</pre>
|
|
1505
1527
|
</section>
|
|
1506
|
-
`}function
|
|
1528
|
+
`}function uf(e){return e?.channelMeta?.length?e.channelMeta.map(t=>t.id):e?.channelOrder?.length?e.channelOrder:["whatsapp","telegram","discord","googlechat","slack","signal","imessage","nostr"]}function pf(e,t,n){const s=zr(e,n.channelAccounts);switch(e){case"whatsapp":return cf({props:t,whatsapp:n.whatsapp,accountCountLabel:s});case"telegram":return lf({props:t,telegram:n.telegram,telegramAccounts:n.channelAccounts?.telegram??[],accountCountLabel:s});case"discord":return Zh({props:t,discord:n.discord,accountCountLabel:s});case"googlechat":return Xh({props:t,accountCountLabel:s});case"slack":return rf({props:t,slack:n.slack,accountCountLabel:s});case"signal":return of({props:t,signal:n.signal,accountCountLabel:s});case"imessage":return ef({props:t,imessage:n.imessage,accountCountLabel:s});case"nostr":{const i=n.channelAccounts?.nostr??[],a=i[0],o=a?.accountId??"default",c=a?.profile??null,l=t.nostrProfileAccountId===o?t.nostrProfileFormState:null,u=l?{onFieldChange:t.onNostrProfileFieldChange,onSave:t.onNostrProfileSave,onImport:t.onNostrProfileImport,onCancel:t.onNostrProfileCancel,onToggleAdvanced:t.onNostrProfileToggleAdvanced}:null;return af({props:t,nostr:n.nostr,nostrAccounts:i,accountCountLabel:s,profileFormState:l,profileFormCallbacks:u,onEditProfile:()=>t.onNostrProfileEdit(o,c)})}default:return hf(e,t,n.channelAccounts??{})}}function hf(e,t,n){const s=gf(t.snapshot,e),i=t.snapshot?.channels?.[e],a=typeof i?.configured=="boolean"?i.configured:void 0,o=typeof i?.running=="boolean"?i.running:void 0,c=typeof i?.connected=="boolean"?i.connected:void 0,l=typeof i?.lastError=="string"?i.lastError:void 0,u=n[e]??[],d=zr(e,n);return r`
|
|
1507
1529
|
<div class="card">
|
|
1508
1530
|
<div class="card-title">${s}</div>
|
|
1509
1531
|
<div class="card-sub">Channel status and configuration.</div>
|
|
1510
1532
|
${d}
|
|
1511
1533
|
|
|
1512
|
-
${u.length>0?
|
|
1534
|
+
${u.length>0?r`
|
|
1513
1535
|
<div class="account-card-list">
|
|
1514
|
-
${u.map(p=>
|
|
1536
|
+
${u.map(p=>bf(p))}
|
|
1515
1537
|
</div>
|
|
1516
|
-
`:
|
|
1538
|
+
`:r`
|
|
1517
1539
|
<div class="status-list" style="margin-top: 16px;">
|
|
1518
1540
|
<div>
|
|
1519
1541
|
<span class="label">Configured</span>
|
|
@@ -1530,13 +1552,13 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1530
1552
|
</div>
|
|
1531
1553
|
`}
|
|
1532
1554
|
|
|
1533
|
-
${r
|
|
1534
|
-
${
|
|
1555
|
+
${l?r`<div class="callout danger" style="margin-top: 12px;">
|
|
1556
|
+
${l}
|
|
1535
1557
|
</div>`:g}
|
|
1536
1558
|
|
|
1537
1559
|
${Ce({channelId:e,props:t})}
|
|
1538
1560
|
</div>
|
|
1539
|
-
`}function
|
|
1561
|
+
`}function ff(e){return e?.channelMeta?.length?Object.fromEntries(e.channelMeta.map(t=>[t.id,t])):{}}function gf(e,t){return ff(e)[t]?.label??e?.channelLabels?.[t]??t}const mf=600*1e3;function Hr(e){return e.lastInboundAt?Date.now()-e.lastInboundAt<mf:!1}function vf(e){return e.running?"Yes":Hr(e)?"Active":"No"}function yf(e){return e.connected===!0?"Yes":e.connected===!1?"No":Hr(e)?"Active":"n/a"}function bf(e){const t=vf(e),n=yf(e);return r`
|
|
1540
1562
|
<div class="account-card">
|
|
1541
1563
|
<div class="account-card-header">
|
|
1542
1564
|
<div class="account-card-title">${e.name||e.accountId}</div>
|
|
@@ -1559,14 +1581,14 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1559
1581
|
<span class="label">Last inbound</span>
|
|
1560
1582
|
<span>${e.lastInboundAt?D(e.lastInboundAt):"n/a"}</span>
|
|
1561
1583
|
</div>
|
|
1562
|
-
${e.lastError?
|
|
1584
|
+
${e.lastError?r`
|
|
1563
1585
|
<div class="account-card-error">
|
|
1564
1586
|
${e.lastError}
|
|
1565
1587
|
</div>
|
|
1566
1588
|
`:g}
|
|
1567
1589
|
</div>
|
|
1568
1590
|
</div>
|
|
1569
|
-
`}function
|
|
1591
|
+
`}function wf(e){const t=e.host??"unknown",n=e.ip?`(${e.ip})`:"",s=e.mode??"",i=e.version??"";return`${t} ${n} ${s} ${i}`.trim()}function $f(e){const t=e.ts??null;return t?D(t):"n/a"}function jr(e){return e?`${Nt(e)} (${D(e)})`:"n/a"}function xf(e){if(e.totalTokens==null)return"n/a";const t=e.totalTokens??0,n=e.contextTokens??0;return n?`${t} / ${n}`:String(t)}function kf(e){if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Sf(e){const t=e.schedule;return t.kind==="at"?`At ${Nt(t.atMs)}`:t.kind==="every"?`Every ${fc(t.everyMs)}`:`Cron ${t.expr}${t.tz?` (${t.tz})`:""}`}function Af(e){const t=["last",...e.channels.filter(Boolean)],n=e.form.deliveryChannel?.trim();n&&!t.includes(n)&&t.push(n);const s=new Set;return t.filter(i=>s.has(i)?!1:(s.add(i),!0))}function _f(e,t){if(t==="last")return"last";const n=e.channelMeta?.find(s=>s.id===t);return n?.label?n.label:e.channelLabels?.[t]??t}function Tf(e){const t=Af(e),s=(e.runsJobId==null?void 0:e.jobs.find(a=>a.id===e.runsJobId))?.name??e.runsJobId??"(select a job)",i=e.runs.toSorted((a,o)=>o.ts-a.ts);return r`
|
|
1570
1592
|
<section class="grid grid-cols-2">
|
|
1571
1593
|
<div class="card">
|
|
1572
1594
|
<div class="card-title">Scheduler</div>
|
|
@@ -1584,14 +1606,14 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1584
1606
|
</div>
|
|
1585
1607
|
<div class="stat">
|
|
1586
1608
|
<div class="stat-label">Next wake</div>
|
|
1587
|
-
<div class="stat-value">${
|
|
1609
|
+
<div class="stat-value">${jr(e.status?.nextWakeAtMs??null)}</div>
|
|
1588
1610
|
</div>
|
|
1589
1611
|
</div>
|
|
1590
1612
|
<div class="row" style="margin-top: 12px;">
|
|
1591
1613
|
<button class="btn" ?disabled=${e.loading} @click=${e.onRefresh}>
|
|
1592
1614
|
${e.loading?"Refreshing…":"Refresh"}
|
|
1593
1615
|
</button>
|
|
1594
|
-
${e.error?
|
|
1616
|
+
${e.error?r`<span class="muted">${e.error}</span>`:g}
|
|
1595
1617
|
</div>
|
|
1596
1618
|
</div>
|
|
1597
1619
|
|
|
@@ -1641,7 +1663,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1641
1663
|
</select>
|
|
1642
1664
|
</label>
|
|
1643
1665
|
</div>
|
|
1644
|
-
${
|
|
1666
|
+
${Cf(e)}
|
|
1645
1667
|
<div class="form-grid" style="margin-top: 12px;">
|
|
1646
1668
|
<label class="field">
|
|
1647
1669
|
<span>Session</span>
|
|
@@ -1682,7 +1704,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1682
1704
|
rows="4"
|
|
1683
1705
|
></textarea>
|
|
1684
1706
|
</label>
|
|
1685
|
-
${e.form.payloadKind==="agentTurn"?
|
|
1707
|
+
${e.form.payloadKind==="agentTurn"?r`
|
|
1686
1708
|
<div class="form-grid" style="margin-top: 12px;">
|
|
1687
1709
|
<label class="field">
|
|
1688
1710
|
<span>Delivery</span>
|
|
@@ -1702,15 +1724,15 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1702
1724
|
@input=${a=>e.onFormChange({timeoutSeconds:a.target.value})}
|
|
1703
1725
|
/>
|
|
1704
1726
|
</label>
|
|
1705
|
-
${e.form.deliveryMode==="announce"?
|
|
1727
|
+
${e.form.deliveryMode==="announce"?r`
|
|
1706
1728
|
<label class="field">
|
|
1707
1729
|
<span>Channel</span>
|
|
1708
1730
|
<select
|
|
1709
1731
|
.value=${e.form.deliveryChannel||"last"}
|
|
1710
1732
|
@change=${a=>e.onFormChange({deliveryChannel:a.target.value})}
|
|
1711
1733
|
>
|
|
1712
|
-
${t.map(a=>
|
|
1713
|
-
${
|
|
1734
|
+
${t.map(a=>r`<option value=${a}>
|
|
1735
|
+
${_f(e,a)}
|
|
1714
1736
|
</option>`)}
|
|
1715
1737
|
</select>
|
|
1716
1738
|
</label>
|
|
@@ -1736,11 +1758,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1736
1758
|
<section class="card" style="margin-top: 18px;">
|
|
1737
1759
|
<div class="card-title">Jobs</div>
|
|
1738
1760
|
<div class="card-sub">All scheduled jobs stored in the gateway.</div>
|
|
1739
|
-
${e.jobs.length===0?
|
|
1761
|
+
${e.jobs.length===0?r`
|
|
1740
1762
|
<div class="muted" style="margin-top: 12px">No jobs yet.</div>
|
|
1741
|
-
`:
|
|
1763
|
+
`:r`
|
|
1742
1764
|
<div class="list" style="margin-top: 12px;">
|
|
1743
|
-
${e.jobs.map(a=>
|
|
1765
|
+
${e.jobs.map(a=>Ef(a,e))}
|
|
1744
1766
|
</div>
|
|
1745
1767
|
`}
|
|
1746
1768
|
</section>
|
|
@@ -1748,17 +1770,17 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1748
1770
|
<section class="card" style="margin-top: 18px;">
|
|
1749
1771
|
<div class="card-title">Run history</div>
|
|
1750
1772
|
<div class="card-sub">Latest runs for ${s}.</div>
|
|
1751
|
-
${e.runsJobId==null?
|
|
1773
|
+
${e.runsJobId==null?r`
|
|
1752
1774
|
<div class="muted" style="margin-top: 12px">Select a job to inspect run history.</div>
|
|
1753
|
-
`:i.length===0?
|
|
1775
|
+
`:i.length===0?r`
|
|
1754
1776
|
<div class="muted" style="margin-top: 12px">No runs yet.</div>
|
|
1755
|
-
`:
|
|
1777
|
+
`:r`
|
|
1756
1778
|
<div class="list" style="margin-top: 12px;">
|
|
1757
|
-
${i.map(a=>
|
|
1779
|
+
${i.map(a=>If(a,e.basePath))}
|
|
1758
1780
|
</div>
|
|
1759
1781
|
`}
|
|
1760
1782
|
</section>
|
|
1761
|
-
`}function
|
|
1783
|
+
`}function Cf(e){const t=e.form;return t.scheduleKind==="at"?r`
|
|
1762
1784
|
<label class="field" style="margin-top: 12px;">
|
|
1763
1785
|
<span>Run at</span>
|
|
1764
1786
|
<input
|
|
@@ -1767,7 +1789,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1767
1789
|
@input=${n=>e.onFormChange({scheduleAt:n.target.value})}
|
|
1768
1790
|
/>
|
|
1769
1791
|
</label>
|
|
1770
|
-
`:t.scheduleKind==="every"?
|
|
1792
|
+
`:t.scheduleKind==="every"?r`
|
|
1771
1793
|
<div class="form-grid" style="margin-top: 12px;">
|
|
1772
1794
|
<label class="field">
|
|
1773
1795
|
<span>Every</span>
|
|
@@ -1788,7 +1810,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1788
1810
|
</select>
|
|
1789
1811
|
</label>
|
|
1790
1812
|
</div>
|
|
1791
|
-
`:
|
|
1813
|
+
`:r`
|
|
1792
1814
|
<div class="form-grid" style="margin-top: 12px;">
|
|
1793
1815
|
<label class="field">
|
|
1794
1816
|
<span>Expression</span>
|
|
@@ -1805,16 +1827,16 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1805
1827
|
/>
|
|
1806
1828
|
</label>
|
|
1807
1829
|
</div>
|
|
1808
|
-
`}function
|
|
1830
|
+
`}function Ef(e,t){const s=`list-item list-item-clickable cron-job${t.runsJobId===e.id?" list-item-selected":""}`;return r`
|
|
1809
1831
|
<div class=${s} @click=${()=>t.onLoadRuns(e.id)}>
|
|
1810
1832
|
<div class="list-main">
|
|
1811
1833
|
<div class="list-title">${e.name}</div>
|
|
1812
|
-
<div class="list-sub">${
|
|
1813
|
-
${
|
|
1814
|
-
${e.agentId?
|
|
1834
|
+
<div class="list-sub">${Sf(e)}</div>
|
|
1835
|
+
${Rf(e)}
|
|
1836
|
+
${e.agentId?r`<div class="muted cron-job-agent">Agent: ${e.agentId}</div>`:g}
|
|
1815
1837
|
</div>
|
|
1816
1838
|
<div class="list-meta">
|
|
1817
|
-
${
|
|
1839
|
+
${Mf(e)}
|
|
1818
1840
|
</div>
|
|
1819
1841
|
<div class="cron-job-footer">
|
|
1820
1842
|
<div class="chip-row cron-job-chips">
|
|
@@ -1856,19 +1878,19 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1856
1878
|
</div>
|
|
1857
1879
|
</div>
|
|
1858
1880
|
</div>
|
|
1859
|
-
`}function
|
|
1881
|
+
`}function Rf(e){if(e.payload.kind==="systemEvent")return r`<div class="cron-job-detail">
|
|
1860
1882
|
<span class="cron-job-detail-label">System</span>
|
|
1861
1883
|
<span class="muted cron-job-detail-value">${e.payload.text}</span>
|
|
1862
|
-
</div>`;const t=e.delivery,n=t?.channel||t?.to?` (${t.channel??"last"}${t.to?` -> ${t.to}`:""})`:"";return
|
|
1884
|
+
</div>`;const t=e.delivery,n=t?.channel||t?.to?` (${t.channel??"last"}${t.to?` -> ${t.to}`:""})`:"";return r`
|
|
1863
1885
|
<div class="cron-job-detail">
|
|
1864
1886
|
<span class="cron-job-detail-label">Prompt</span>
|
|
1865
1887
|
<span class="muted cron-job-detail-value">${e.payload.message}</span>
|
|
1866
1888
|
</div>
|
|
1867
|
-
${t?
|
|
1889
|
+
${t?r`<div class="cron-job-detail">
|
|
1868
1890
|
<span class="cron-job-detail-label">Delivery</span>
|
|
1869
1891
|
<span class="muted cron-job-detail-value">${t.mode}${n}</span>
|
|
1870
1892
|
</div>`:g}
|
|
1871
|
-
`}function
|
|
1893
|
+
`}function po(e){return typeof e!="number"||!Number.isFinite(e)?"n/a":xn(e)}function Mf(e){const t=e.state?.lastStatus??"n/a",n=t==="ok"?"cron-job-status-ok":t==="error"?"cron-job-status-error":t==="skipped"?"cron-job-status-skipped":"cron-job-status-na",s=e.state?.nextRunAtMs,i=e.state?.lastRunAtMs;return r`
|
|
1872
1894
|
<div class="cron-job-state">
|
|
1873
1895
|
<div class="cron-job-state-row">
|
|
1874
1896
|
<span class="cron-job-state-key">Status</span>
|
|
@@ -1877,17 +1899,17 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1877
1899
|
<div class="cron-job-state-row">
|
|
1878
1900
|
<span class="cron-job-state-key">Next</span>
|
|
1879
1901
|
<span class="cron-job-state-value" title=${Nt(s)}>
|
|
1880
|
-
${
|
|
1902
|
+
${po(s)}
|
|
1881
1903
|
</span>
|
|
1882
1904
|
</div>
|
|
1883
1905
|
<div class="cron-job-state-row">
|
|
1884
1906
|
<span class="cron-job-state-key">Last</span>
|
|
1885
1907
|
<span class="cron-job-state-value" title=${Nt(i)}>
|
|
1886
|
-
${
|
|
1908
|
+
${po(i)}
|
|
1887
1909
|
</span>
|
|
1888
1910
|
</div>
|
|
1889
1911
|
</div>
|
|
1890
|
-
`}function
|
|
1912
|
+
`}function If(e,t){const n=typeof e.sessionKey=="string"&&e.sessionKey.trim().length>0?`${$n("chat",t)}?session=${encodeURIComponent(e.sessionKey)}`:null;return r`
|
|
1891
1913
|
<div class="list-item">
|
|
1892
1914
|
<div class="list-main">
|
|
1893
1915
|
<div class="list-title">${e.status}</div>
|
|
@@ -1896,11 +1918,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1896
1918
|
<div class="list-meta">
|
|
1897
1919
|
<div>${Nt(e.ts)}</div>
|
|
1898
1920
|
<div class="muted">${e.durationMs??0}ms</div>
|
|
1899
|
-
${n?
|
|
1900
|
-
${e.error?
|
|
1921
|
+
${n?r`<div><a class="session-link" href=${n}>Open run chat</a></div>`:g}
|
|
1922
|
+
${e.error?r`<div class="muted">${e.error}</div>`:g}
|
|
1901
1923
|
</div>
|
|
1902
1924
|
</div>
|
|
1903
|
-
`}function
|
|
1925
|
+
`}function Lf(e){const n=(e.status&&typeof e.status=="object"?e.status.securityAudit:null)?.summary??null,s=n?.critical??0,i=n?.warn??0,a=n?.info??0,o=s>0?"danger":i>0?"warn":"success",c=s>0?`${s} critical`:i>0?`${i} warnings`:"No critical issues";return r`
|
|
1904
1926
|
<section class="grid grid-cols-2">
|
|
1905
1927
|
<div class="card">
|
|
1906
1928
|
<div class="row" style="justify-content: space-between;">
|
|
@@ -1915,7 +1937,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1915
1937
|
<div class="stack" style="margin-top: 12px;">
|
|
1916
1938
|
<div>
|
|
1917
1939
|
<div class="muted">Status</div>
|
|
1918
|
-
${n?
|
|
1940
|
+
${n?r`<div class="callout ${o}" style="margin-top: 8px;">
|
|
1919
1941
|
Security audit: ${c}${a>0?` · ${a} info`:""}. Run
|
|
1920
1942
|
<span class="mono">poolbot security audit --deep</span> for details.
|
|
1921
1943
|
</div>`:g}
|
|
@@ -1940,7 +1962,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1940
1962
|
<span>Method</span>
|
|
1941
1963
|
<input
|
|
1942
1964
|
.value=${e.callMethod}
|
|
1943
|
-
@input=${
|
|
1965
|
+
@input=${l=>e.onCallMethodChange(l.target.value)}
|
|
1944
1966
|
placeholder="system-presence"
|
|
1945
1967
|
/>
|
|
1946
1968
|
</label>
|
|
@@ -1948,7 +1970,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1948
1970
|
<span>Params (JSON)</span>
|
|
1949
1971
|
<textarea
|
|
1950
1972
|
.value=${e.callParams}
|
|
1951
|
-
@input=${
|
|
1973
|
+
@input=${l=>e.onCallParamsChange(l.target.value)}
|
|
1952
1974
|
rows="6"
|
|
1953
1975
|
></textarea>
|
|
1954
1976
|
</label>
|
|
@@ -1956,10 +1978,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1956
1978
|
<div class="row" style="margin-top: 12px;">
|
|
1957
1979
|
<button class="btn primary" @click=${e.onCall}>Call</button>
|
|
1958
1980
|
</div>
|
|
1959
|
-
${e.callError?
|
|
1981
|
+
${e.callError?r`<div class="callout danger" style="margin-top: 12px;">
|
|
1960
1982
|
${e.callError}
|
|
1961
1983
|
</div>`:g}
|
|
1962
|
-
${e.callResult?
|
|
1984
|
+
${e.callResult?r`<pre class="code-block" style="margin-top: 12px;">${e.callResult}</pre>`:g}
|
|
1963
1985
|
</div>
|
|
1964
1986
|
</section>
|
|
1965
1987
|
|
|
@@ -1972,23 +1994,23 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1972
1994
|
<section class="card" style="margin-top: 18px;">
|
|
1973
1995
|
<div class="card-title">Event Log</div>
|
|
1974
1996
|
<div class="card-sub">Latest gateway events.</div>
|
|
1975
|
-
${e.eventLog.length===0?
|
|
1997
|
+
${e.eventLog.length===0?r`<div class="muted" style="margin-top: 12px;">No events yet.</div>`:r`
|
|
1976
1998
|
<div class="list" style="margin-top: 12px;">
|
|
1977
|
-
${e.eventLog.map(r
|
|
1999
|
+
${e.eventLog.map(l=>r`
|
|
1978
2000
|
<div class="list-item">
|
|
1979
2001
|
<div class="list-main">
|
|
1980
|
-
<div class="list-title">${
|
|
1981
|
-
<div class="list-sub">${new Date(
|
|
2002
|
+
<div class="list-title">${l.event}</div>
|
|
2003
|
+
<div class="list-sub">${new Date(l.ts).toLocaleTimeString()}</div>
|
|
1982
2004
|
</div>
|
|
1983
2005
|
<div class="list-meta">
|
|
1984
|
-
<pre class="code-block">${
|
|
2006
|
+
<pre class="code-block">${kf(l.payload)}</pre>
|
|
1985
2007
|
</div>
|
|
1986
2008
|
</div>
|
|
1987
2009
|
`)}
|
|
1988
2010
|
</div>
|
|
1989
2011
|
`}
|
|
1990
2012
|
</section>
|
|
1991
|
-
`}function
|
|
2013
|
+
`}function Pf(e){return r`
|
|
1992
2014
|
<section class="card">
|
|
1993
2015
|
<div class="row" style="justify-content: space-between;">
|
|
1994
2016
|
<div>
|
|
@@ -1999,38 +2021,38 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1999
2021
|
${e.loading?"Loading…":"Refresh"}
|
|
2000
2022
|
</button>
|
|
2001
2023
|
</div>
|
|
2002
|
-
${e.lastError?
|
|
2024
|
+
${e.lastError?r`<div class="callout danger" style="margin-top: 12px;">
|
|
2003
2025
|
${e.lastError}
|
|
2004
2026
|
</div>`:g}
|
|
2005
|
-
${e.statusMessage?
|
|
2027
|
+
${e.statusMessage?r`<div class="callout" style="margin-top: 12px;">
|
|
2006
2028
|
${e.statusMessage}
|
|
2007
2029
|
</div>`:g}
|
|
2008
2030
|
<div class="list" style="margin-top: 16px;">
|
|
2009
|
-
${e.entries.length===0?
|
|
2031
|
+
${e.entries.length===0?r`<div class="muted">No instances reported yet.</div>`:e.entries.map(t=>Nf(t))}
|
|
2010
2032
|
</div>
|
|
2011
2033
|
</section>
|
|
2012
|
-
`}function
|
|
2034
|
+
`}function Nf(e){const t=e.lastInputSeconds!=null?`${e.lastInputSeconds}s ago`:"n/a",n=e.mode??"unknown",s=Array.isArray(e.roles)?e.roles.filter(Boolean):[],i=Array.isArray(e.scopes)?e.scopes.filter(Boolean):[],a=i.length>0?i.length>3?`${i.length} scopes`:`scopes: ${i.join(", ")}`:null;return r`
|
|
2013
2035
|
<div class="list-item">
|
|
2014
2036
|
<div class="list-main">
|
|
2015
2037
|
<div class="list-title">${e.host??"unknown host"}</div>
|
|
2016
|
-
<div class="list-sub">${
|
|
2038
|
+
<div class="list-sub">${wf(e)}</div>
|
|
2017
2039
|
<div class="chip-row">
|
|
2018
2040
|
<span class="chip">${n}</span>
|
|
2019
|
-
${s.map(o=>
|
|
2020
|
-
${a?
|
|
2021
|
-
${e.platform?
|
|
2022
|
-
${e.deviceFamily?
|
|
2023
|
-
${e.modelIdentifier?
|
|
2024
|
-
${e.version?
|
|
2041
|
+
${s.map(o=>r`<span class="chip">${o}</span>`)}
|
|
2042
|
+
${a?r`<span class="chip">${a}</span>`:g}
|
|
2043
|
+
${e.platform?r`<span class="chip">${e.platform}</span>`:g}
|
|
2044
|
+
${e.deviceFamily?r`<span class="chip">${e.deviceFamily}</span>`:g}
|
|
2045
|
+
${e.modelIdentifier?r`<span class="chip">${e.modelIdentifier}</span>`:g}
|
|
2046
|
+
${e.version?r`<span class="chip">${e.version}</span>`:g}
|
|
2025
2047
|
</div>
|
|
2026
2048
|
</div>
|
|
2027
2049
|
<div class="list-meta">
|
|
2028
|
-
<div>${
|
|
2050
|
+
<div>${$f(e)}</div>
|
|
2029
2051
|
<div class="muted">Last input ${t}</div>
|
|
2030
2052
|
<div class="muted">Reason ${e.reason??""}</div>
|
|
2031
2053
|
</div>
|
|
2032
2054
|
</div>
|
|
2033
|
-
`}const
|
|
2055
|
+
`}const ho=["trace","debug","info","warn","error","fatal"];function Of(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function Df(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Bf(e){const t=e.filterText.trim().toLowerCase(),n=ho.some(a=>!e.levelFilters[a]),s=e.entries.filter(a=>a.level&&!e.levelFilters[a.level]?!1:Df(a,t)),i=t||n?"filtered":"visible";return r`
|
|
2034
2056
|
<section class="card">
|
|
2035
2057
|
<div class="row" style="justify-content: space-between;">
|
|
2036
2058
|
<div>
|
|
@@ -2071,7 +2093,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2071
2093
|
</div>
|
|
2072
2094
|
|
|
2073
2095
|
<div class="chip-row" style="margin-top: 12px;">
|
|
2074
|
-
${
|
|
2096
|
+
${ho.map(a=>r`
|
|
2075
2097
|
<label class="chip log-chip ${a}">
|
|
2076
2098
|
<input
|
|
2077
2099
|
type="checkbox"
|
|
@@ -2083,16 +2105,16 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2083
2105
|
`)}
|
|
2084
2106
|
</div>
|
|
2085
2107
|
|
|
2086
|
-
${e.file?
|
|
2087
|
-
${e.truncated?
|
|
2108
|
+
${e.file?r`<div class="muted" style="margin-top: 10px;">File: ${e.file}</div>`:g}
|
|
2109
|
+
${e.truncated?r`<div class="callout" style="margin-top: 10px;">
|
|
2088
2110
|
Log output truncated; showing latest chunk.
|
|
2089
2111
|
</div>`:g}
|
|
2090
|
-
${e.error?
|
|
2112
|
+
${e.error?r`<div class="callout danger" style="margin-top: 10px;">${e.error}</div>`:g}
|
|
2091
2113
|
|
|
2092
2114
|
<div class="log-stream" style="margin-top: 12px;" @scroll=${e.onScroll}>
|
|
2093
|
-
${s.length===0?
|
|
2115
|
+
${s.length===0?r`<div class="muted" style="padding: 12px;">No log entries.</div>`:s.map(a=>r`
|
|
2094
2116
|
<div class="log-row">
|
|
2095
|
-
<div class="log-time mono">${
|
|
2117
|
+
<div class="log-time mono">${Of(a.time)}</div>
|
|
2096
2118
|
<div class="log-level ${a.level??""}">${a.level??""}</div>
|
|
2097
2119
|
<div class="log-subsystem mono">${a.subsystem??""}</div>
|
|
2098
2120
|
<div class="log-message mono">${a.message??a.raw}</div>
|
|
@@ -2100,7 +2122,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2100
2122
|
`)}
|
|
2101
2123
|
</div>
|
|
2102
2124
|
</section>
|
|
2103
|
-
`}function
|
|
2125
|
+
`}function Vr(e){const t=e?.agents??{},n=Array.isArray(t.list)?t.list:[],s=[];return n.forEach((i,a)=>{if(!i||typeof i!="object")return;const o=i,c=typeof o.id=="string"?o.id.trim():"";if(!c)return;const l=typeof o.name=="string"?o.name.trim():void 0,u=o.default===!0;s.push({id:c,name:l||void 0,isDefault:u,index:a,record:o})}),s}function Wr(e,t){const n=new Set(t),s=[];for(const i of e){if(!(Array.isArray(i.commands)?i.commands:[]).some(u=>n.has(String(u))))continue;const c=typeof i.nodeId=="string"?i.nodeId.trim():"";if(!c)continue;const l=typeof i.displayName=="string"&&i.displayName.trim()?i.displayName.trim():c;s.push({id:c,label:l===c?c:`${l} · ${c}`})}return s.sort((i,a)=>i.label.localeCompare(a.label)),s}const Me="__defaults__",fo=[{value:"deny",label:"Deny"},{value:"allowlist",label:"Allowlist"},{value:"full",label:"Full"}],Ff=[{value:"off",label:"Off"},{value:"on-miss",label:"On miss"},{value:"always",label:"Always"}];function go(e){return e==="allowlist"||e==="full"||e==="deny"?e:"deny"}function Uf(e){return e==="always"||e==="off"||e==="on-miss"?e:"on-miss"}function Kf(e){const t=e?.defaults??{};return{security:go(t.security),ask:Uf(t.ask),askFallback:go(t.askFallback??"deny"),autoAllowSkills:!!(t.autoAllowSkills??!1)}}function zf(e){return Vr(e).map(t=>({id:t.id,name:t.name,isDefault:t.isDefault}))}function Hf(e,t){const n=zf(e),s=Object.keys(t?.agents??{}),i=new Map;n.forEach(o=>i.set(o.id,o)),s.forEach(o=>{i.has(o)||i.set(o,{id:o})});const a=Array.from(i.values());return a.length===0&&a.push({id:"main",isDefault:!0}),a.sort((o,c)=>{if(o.isDefault&&!c.isDefault)return-1;if(!o.isDefault&&c.isDefault)return 1;const l=o.name?.trim()?o.name:o.id,u=c.name?.trim()?c.name:c.id;return l.localeCompare(u)}),a}function jf(e,t){return e===Me?Me:e&&t.some(n=>n.id===e)?e:Me}function Vf(e){const t=e.execApprovalsForm??e.execApprovalsSnapshot?.file??null,n=!!t,s=Kf(t),i=Hf(e.configForm,t),a=Zf(e.nodes),o=e.execApprovalsTarget;let c=o==="node"&&e.execApprovalsTargetNodeId?e.execApprovalsTargetNodeId:null;o==="node"&&c&&!a.some(p=>p.id===c)&&(c=null);const l=jf(e.execApprovalsSelectedAgent,i),u=l!==Me?(t?.agents??{})[l]??null:null,d=Array.isArray(u?.allowlist)?u.allowlist??[]:[];return{ready:n,disabled:e.execApprovalsSaving||e.execApprovalsLoading,dirty:e.execApprovalsDirty,loading:e.execApprovalsLoading,saving:e.execApprovalsSaving,form:t,defaults:s,selectedScope:l,selectedAgent:u,agents:i,allowlist:d,target:o,targetNodeId:c,targetNodes:a,onSelectScope:e.onExecApprovalsSelectAgent,onSelectTarget:e.onExecApprovalsTargetChange,onPatch:e.onExecApprovalsPatch,onRemove:e.onExecApprovalsRemove,onLoad:e.onLoadExecApprovals,onSave:e.onSaveExecApprovals}}function Wf(e){const t=e.ready,n=e.target!=="node"||!!e.targetNodeId;return r`
|
|
2104
2126
|
<section class="card">
|
|
2105
2127
|
<div class="row" style="justify-content: space-between; align-items: center;">
|
|
2106
2128
|
<div>
|
|
@@ -2118,20 +2140,20 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2118
2140
|
</button>
|
|
2119
2141
|
</div>
|
|
2120
2142
|
|
|
2121
|
-
${
|
|
2143
|
+
${qf(e)}
|
|
2122
2144
|
|
|
2123
|
-
${t?
|
|
2124
|
-
${
|
|
2125
|
-
${
|
|
2126
|
-
${e.selectedScope===Me?g:
|
|
2127
|
-
`:
|
|
2145
|
+
${t?r`
|
|
2146
|
+
${Gf(e)}
|
|
2147
|
+
${Yf(e)}
|
|
2148
|
+
${e.selectedScope===Me?g:Qf(e)}
|
|
2149
|
+
`:r`<div class="row" style="margin-top: 12px; gap: 12px;">
|
|
2128
2150
|
<div class="muted">Load exec approvals to edit allowlists.</div>
|
|
2129
2151
|
<button class="btn" ?disabled=${e.loading||!n} @click=${e.onLoad}>
|
|
2130
2152
|
${e.loading?"Loading…":"Load approvals"}
|
|
2131
2153
|
</button>
|
|
2132
2154
|
</div>`}
|
|
2133
2155
|
</section>
|
|
2134
|
-
`}function
|
|
2156
|
+
`}function qf(e){const t=e.targetNodes.length>0,n=e.targetNodeId??"";return r`
|
|
2135
2157
|
<div class="list" style="margin-top: 12px;">
|
|
2136
2158
|
<div class="list-item">
|
|
2137
2159
|
<div class="list-main">
|
|
@@ -2151,7 +2173,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2151
2173
|
<option value="node" ?selected=${e.target==="node"}>Node</option>
|
|
2152
2174
|
</select>
|
|
2153
2175
|
</label>
|
|
2154
|
-
${e.target==="node"?
|
|
2176
|
+
${e.target==="node"?r`
|
|
2155
2177
|
<label class="field">
|
|
2156
2178
|
<span>Node</span>
|
|
2157
2179
|
<select
|
|
@@ -2159,7 +2181,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2159
2181
|
@change=${s=>{const a=s.target.value.trim();e.onSelectTarget("node",a||null)}}
|
|
2160
2182
|
>
|
|
2161
2183
|
<option value="" ?selected=${n===""}>Select node</option>
|
|
2162
|
-
${e.targetNodes.map(s=>
|
|
2184
|
+
${e.targetNodes.map(s=>r`<option
|
|
2163
2185
|
value=${s.id}
|
|
2164
2186
|
?selected=${n===s.id}
|
|
2165
2187
|
>
|
|
@@ -2170,11 +2192,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2170
2192
|
`:g}
|
|
2171
2193
|
</div>
|
|
2172
2194
|
</div>
|
|
2173
|
-
${e.target==="node"&&!t?
|
|
2195
|
+
${e.target==="node"&&!t?r`
|
|
2174
2196
|
<div class="muted">No nodes advertise exec approvals yet.</div>
|
|
2175
2197
|
`:g}
|
|
2176
2198
|
</div>
|
|
2177
|
-
`}function
|
|
2199
|
+
`}function Gf(e){return r`
|
|
2178
2200
|
<div class="row" style="margin-top: 12px; gap: 8px; flex-wrap: wrap;">
|
|
2179
2201
|
<span class="label">Scope</span>
|
|
2180
2202
|
<div class="row" style="gap: 8px; flex-wrap: wrap;">
|
|
@@ -2184,7 +2206,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2184
2206
|
>
|
|
2185
2207
|
Defaults
|
|
2186
2208
|
</button>
|
|
2187
|
-
${e.agents.map(t=>{const n=t.name?.trim()?`${t.name} (${t.id})`:t.id;return
|
|
2209
|
+
${e.agents.map(t=>{const n=t.name?.trim()?`${t.name} (${t.id})`:t.id;return r`
|
|
2188
2210
|
<button
|
|
2189
2211
|
class="btn btn--sm ${e.selectedScope===t.id?"active":""}"
|
|
2190
2212
|
@click=${()=>e.onSelectScope(t.id)}
|
|
@@ -2194,7 +2216,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2194
2216
|
`})}
|
|
2195
2217
|
</div>
|
|
2196
2218
|
</div>
|
|
2197
|
-
`}function
|
|
2219
|
+
`}function Yf(e){const t=e.selectedScope===Me,n=e.defaults,s=e.selectedAgent??{},i=t?["defaults"]:["agents",e.selectedScope],a=typeof s.security=="string"?s.security:void 0,o=typeof s.ask=="string"?s.ask:void 0,c=typeof s.askFallback=="string"?s.askFallback:void 0,l=t?n.security:a??"__default__",u=t?n.ask:o??"__default__",d=t?n.askFallback:c??"__default__",p=typeof s.autoAllowSkills=="boolean"?s.autoAllowSkills:void 0,f=p??n.autoAllowSkills,m=p==null;return r`
|
|
2198
2220
|
<div class="list" style="margin-top: 16px;">
|
|
2199
2221
|
<div class="list-item">
|
|
2200
2222
|
<div class="list-main">
|
|
@@ -2210,12 +2232,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2210
2232
|
?disabled=${e.disabled}
|
|
2211
2233
|
@change=${v=>{const k=v.target.value;!t&&k==="__default__"?e.onRemove([...i,"security"]):e.onPatch([...i,"security"],k)}}
|
|
2212
2234
|
>
|
|
2213
|
-
${t?g:
|
|
2235
|
+
${t?g:r`<option value="__default__" ?selected=${l==="__default__"}>
|
|
2214
2236
|
Use default (${n.security})
|
|
2215
2237
|
</option>`}
|
|
2216
|
-
${
|
|
2238
|
+
${fo.map(v=>r`<option
|
|
2217
2239
|
value=${v.value}
|
|
2218
|
-
?selected=${
|
|
2240
|
+
?selected=${l===v.value}
|
|
2219
2241
|
>
|
|
2220
2242
|
${v.label}
|
|
2221
2243
|
</option>`)}
|
|
@@ -2238,10 +2260,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2238
2260
|
?disabled=${e.disabled}
|
|
2239
2261
|
@change=${v=>{const k=v.target.value;!t&&k==="__default__"?e.onRemove([...i,"ask"]):e.onPatch([...i,"ask"],k)}}
|
|
2240
2262
|
>
|
|
2241
|
-
${t?g:
|
|
2263
|
+
${t?g:r`<option value="__default__" ?selected=${u==="__default__"}>
|
|
2242
2264
|
Use default (${n.ask})
|
|
2243
2265
|
</option>`}
|
|
2244
|
-
${
|
|
2266
|
+
${Ff.map(v=>r`<option
|
|
2245
2267
|
value=${v.value}
|
|
2246
2268
|
?selected=${u===v.value}
|
|
2247
2269
|
>
|
|
@@ -2266,10 +2288,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2266
2288
|
?disabled=${e.disabled}
|
|
2267
2289
|
@change=${v=>{const k=v.target.value;!t&&k==="__default__"?e.onRemove([...i,"askFallback"]):e.onPatch([...i,"askFallback"],k)}}
|
|
2268
2290
|
>
|
|
2269
|
-
${t?g:
|
|
2291
|
+
${t?g:r`<option value="__default__" ?selected=${d==="__default__"}>
|
|
2270
2292
|
Use default (${n.askFallback})
|
|
2271
2293
|
</option>`}
|
|
2272
|
-
${
|
|
2294
|
+
${fo.map(v=>r`<option
|
|
2273
2295
|
value=${v.value}
|
|
2274
2296
|
?selected=${d===v.value}
|
|
2275
2297
|
>
|
|
@@ -2297,7 +2319,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2297
2319
|
@change=${v=>{const $=v.target;e.onPatch([...i,"autoAllowSkills"],$.checked)}}
|
|
2298
2320
|
/>
|
|
2299
2321
|
</label>
|
|
2300
|
-
${!t&&!m?
|
|
2322
|
+
${!t&&!m?r`<button
|
|
2301
2323
|
class="btn btn--sm"
|
|
2302
2324
|
?disabled=${e.disabled}
|
|
2303
2325
|
@click=${()=>e.onRemove([...i,"autoAllowSkills"])}
|
|
@@ -2307,7 +2329,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2307
2329
|
</div>
|
|
2308
2330
|
</div>
|
|
2309
2331
|
</div>
|
|
2310
|
-
`}function
|
|
2332
|
+
`}function Qf(e){const t=["agents",e.selectedScope,"allowlist"],n=e.allowlist;return r`
|
|
2311
2333
|
<div class="row" style="margin-top: 18px; justify-content: space-between;">
|
|
2312
2334
|
<div>
|
|
2313
2335
|
<div class="card-title">Allowlist</div>
|
|
@@ -2322,17 +2344,17 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2322
2344
|
</button>
|
|
2323
2345
|
</div>
|
|
2324
2346
|
<div class="list" style="margin-top: 12px;">
|
|
2325
|
-
${n.length===0?
|
|
2347
|
+
${n.length===0?r`
|
|
2326
2348
|
<div class="muted">No allowlist entries yet.</div>
|
|
2327
|
-
`:n.map((s,i)=>
|
|
2349
|
+
`:n.map((s,i)=>Jf(e,s,i))}
|
|
2328
2350
|
</div>
|
|
2329
|
-
`}function
|
|
2351
|
+
`}function Jf(e,t,n){const s=t.lastUsedAt?xn(t.lastUsedAt):"never",i=t.lastUsedCommand?Ts(t.lastUsedCommand,120):null,a=t.lastResolvedPath?Ts(t.lastResolvedPath,120):null;return r`
|
|
2330
2352
|
<div class="list-item">
|
|
2331
2353
|
<div class="list-main">
|
|
2332
2354
|
<div class="list-title">${t.pattern?.trim()?t.pattern:"New pattern"}</div>
|
|
2333
2355
|
<div class="list-sub">Last used: ${s}</div>
|
|
2334
|
-
${i?
|
|
2335
|
-
${a?
|
|
2356
|
+
${i?r`<div class="list-sub mono">${i}</div>`:g}
|
|
2357
|
+
${a?r`<div class="list-sub mono">${a}</div>`:g}
|
|
2336
2358
|
</div>
|
|
2337
2359
|
<div class="list-meta">
|
|
2338
2360
|
<label class="field">
|
|
@@ -2353,10 +2375,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2353
2375
|
</button>
|
|
2354
2376
|
</div>
|
|
2355
2377
|
</div>
|
|
2356
|
-
`}function
|
|
2357
|
-
${
|
|
2358
|
-
${
|
|
2359
|
-
${
|
|
2378
|
+
`}function Zf(e){return Wr(e,["system.execApprovals.get","system.execApprovals.set"])}function Xf(e){const t=ig(e),n=Vf(e);return r`
|
|
2379
|
+
${Wf(n)}
|
|
2380
|
+
${ag(t)}
|
|
2381
|
+
${eg(e)}
|
|
2360
2382
|
<section class="card">
|
|
2361
2383
|
<div class="row" style="justify-content: space-between;">
|
|
2362
2384
|
<div>
|
|
@@ -2368,12 +2390,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2368
2390
|
</button>
|
|
2369
2391
|
</div>
|
|
2370
2392
|
<div class="list" style="margin-top: 16px;">
|
|
2371
|
-
${e.nodes.length===0?
|
|
2393
|
+
${e.nodes.length===0?r`
|
|
2372
2394
|
<div class="muted">No nodes found.</div>
|
|
2373
|
-
`:e.nodes.map(s=>
|
|
2395
|
+
`:e.nodes.map(s=>cg(s))}
|
|
2374
2396
|
</div>
|
|
2375
2397
|
</section>
|
|
2376
|
-
`}function
|
|
2398
|
+
`}function eg(e){const t=e.devicesList??{pending:[],paired:[]},n=Array.isArray(t.pending)?t.pending:[],s=Array.isArray(t.paired)?t.paired:[];return r`
|
|
2377
2399
|
<section class="card">
|
|
2378
2400
|
<div class="row" style="justify-content: space-between;">
|
|
2379
2401
|
<div>
|
|
@@ -2384,22 +2406,22 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2384
2406
|
${e.devicesLoading?"Loading…":"Refresh"}
|
|
2385
2407
|
</button>
|
|
2386
2408
|
</div>
|
|
2387
|
-
${e.devicesError?
|
|
2409
|
+
${e.devicesError?r`<div class="callout danger" style="margin-top: 12px;">${e.devicesError}</div>`:g}
|
|
2388
2410
|
<div class="list" style="margin-top: 16px;">
|
|
2389
|
-
${n.length>0?
|
|
2411
|
+
${n.length>0?r`
|
|
2390
2412
|
<div class="muted" style="margin-bottom: 8px;">Pending</div>
|
|
2391
|
-
${n.map(i=>
|
|
2413
|
+
${n.map(i=>tg(i,e))}
|
|
2392
2414
|
`:g}
|
|
2393
|
-
${s.length>0?
|
|
2415
|
+
${s.length>0?r`
|
|
2394
2416
|
<div class="muted" style="margin-top: 12px; margin-bottom: 8px;">Paired</div>
|
|
2395
|
-
${s.map(i=>
|
|
2417
|
+
${s.map(i=>ng(i,e))}
|
|
2396
2418
|
`:g}
|
|
2397
|
-
${n.length===0&&s.length===0?
|
|
2419
|
+
${n.length===0&&s.length===0?r`
|
|
2398
2420
|
<div class="muted">No paired devices.</div>
|
|
2399
2421
|
`:g}
|
|
2400
2422
|
</div>
|
|
2401
2423
|
</section>
|
|
2402
|
-
`}function
|
|
2424
|
+
`}function tg(e,t){const n=e.displayName?.trim()||e.deviceId,s=typeof e.ts=="number"?xn(e.ts):"n/a",i=e.role?.trim()?`role: ${e.role}`:"role: -",a=e.isRepair?" · repair":"",o=e.remoteIp?` · ${e.remoteIp}`:"";return r`
|
|
2403
2425
|
<div class="list-item">
|
|
2404
2426
|
<div class="list-main">
|
|
2405
2427
|
<div class="list-title">${n}</div>
|
|
@@ -2419,23 +2441,23 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2419
2441
|
</div>
|
|
2420
2442
|
</div>
|
|
2421
2443
|
</div>
|
|
2422
|
-
`}function
|
|
2444
|
+
`}function ng(e,t){const n=e.displayName?.trim()||e.deviceId,s=e.remoteIp?` · ${e.remoteIp}`:"",i=`roles: ${_s(e.roles)}`,a=`scopes: ${_s(e.scopes)}`,o=Array.isArray(e.tokens)?e.tokens:[];return r`
|
|
2423
2445
|
<div class="list-item">
|
|
2424
2446
|
<div class="list-main">
|
|
2425
2447
|
<div class="list-title">${n}</div>
|
|
2426
2448
|
<div class="list-sub">${e.deviceId}${s}</div>
|
|
2427
2449
|
<div class="muted" style="margin-top: 6px;">${i} · ${a}</div>
|
|
2428
|
-
${o.length===0?
|
|
2450
|
+
${o.length===0?r`
|
|
2429
2451
|
<div class="muted" style="margin-top: 6px">Tokens: none</div>
|
|
2430
|
-
`:
|
|
2452
|
+
`:r`
|
|
2431
2453
|
<div class="muted" style="margin-top: 10px;">Tokens</div>
|
|
2432
2454
|
<div style="display: flex; flex-direction: column; gap: 8px; margin-top: 6px;">
|
|
2433
|
-
${o.map(c=>
|
|
2455
|
+
${o.map(c=>sg(e.deviceId,c,t))}
|
|
2434
2456
|
</div>
|
|
2435
2457
|
`}
|
|
2436
2458
|
</div>
|
|
2437
2459
|
</div>
|
|
2438
|
-
`}function
|
|
2460
|
+
`}function sg(e,t,n){const s=t.revokedAtMs?"revoked":"active",i=`scopes: ${_s(t.scopes)}`,a=xn(t.rotatedAtMs??t.createdAtMs??t.lastUsedAtMs??null);return r`
|
|
2439
2461
|
<div class="row" style="justify-content: space-between; gap: 8px;">
|
|
2440
2462
|
<div class="list-sub">${t.role} · ${s} · ${i} · ${a}</div>
|
|
2441
2463
|
<div class="row" style="justify-content: flex-end; gap: 6px; flex-wrap: wrap;">
|
|
@@ -2445,7 +2467,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2445
2467
|
>
|
|
2446
2468
|
Rotate
|
|
2447
2469
|
</button>
|
|
2448
|
-
${t.revokedAtMs?g:
|
|
2470
|
+
${t.revokedAtMs?g:r`
|
|
2449
2471
|
<button
|
|
2450
2472
|
class="btn btn--sm danger"
|
|
2451
2473
|
@click=${()=>n.onDeviceRevoke(e,t.role)}
|
|
@@ -2455,7 +2477,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2455
2477
|
`}
|
|
2456
2478
|
</div>
|
|
2457
2479
|
</div>
|
|
2458
|
-
`}function
|
|
2480
|
+
`}function ig(e){const t=e.configForm,n=rg(e.nodes),{defaultBinding:s,agents:i}=lg(t),a=!!t,o=e.configSaving||e.configFormMode==="raw";return{ready:a,disabled:o,configDirty:e.configDirty,configLoading:e.configLoading,configSaving:e.configSaving,defaultBinding:s,agents:i,nodes:n,onBindDefault:e.onBindDefault,onBindAgent:e.onBindAgent,onSave:e.onSaveBindings,onLoadConfig:e.onLoadConfig,formMode:e.configFormMode}}function ag(e){const t=e.nodes.length>0,n=e.defaultBinding??"";return r`
|
|
2459
2481
|
<section class="card">
|
|
2460
2482
|
<div class="row" style="justify-content: space-between; align-items: center;">
|
|
2461
2483
|
<div>
|
|
@@ -2473,13 +2495,13 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2473
2495
|
</button>
|
|
2474
2496
|
</div>
|
|
2475
2497
|
|
|
2476
|
-
${e.formMode==="raw"?
|
|
2498
|
+
${e.formMode==="raw"?r`
|
|
2477
2499
|
<div class="callout warn" style="margin-top: 12px">
|
|
2478
2500
|
Switch the Config tab to <strong>Form</strong> mode to edit bindings here.
|
|
2479
2501
|
</div>
|
|
2480
2502
|
`:g}
|
|
2481
2503
|
|
|
2482
|
-
${e.ready?
|
|
2504
|
+
${e.ready?r`
|
|
2483
2505
|
<div class="list" style="margin-top: 16px;">
|
|
2484
2506
|
<div class="list-item">
|
|
2485
2507
|
<div class="list-main">
|
|
@@ -2494,7 +2516,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2494
2516
|
@change=${s=>{const a=s.target.value.trim();e.onBindDefault(a||null)}}
|
|
2495
2517
|
>
|
|
2496
2518
|
<option value="" ?selected=${n===""}>Any node</option>
|
|
2497
|
-
${e.nodes.map(s=>
|
|
2519
|
+
${e.nodes.map(s=>r`<option
|
|
2498
2520
|
value=${s.id}
|
|
2499
2521
|
?selected=${n===s.id}
|
|
2500
2522
|
>
|
|
@@ -2502,24 +2524,24 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2502
2524
|
</option>`)}
|
|
2503
2525
|
</select>
|
|
2504
2526
|
</label>
|
|
2505
|
-
${t?g:
|
|
2527
|
+
${t?g:r`
|
|
2506
2528
|
<div class="muted">No nodes with system.run available.</div>
|
|
2507
2529
|
`}
|
|
2508
2530
|
</div>
|
|
2509
2531
|
</div>
|
|
2510
2532
|
|
|
2511
|
-
${e.agents.length===0?
|
|
2533
|
+
${e.agents.length===0?r`
|
|
2512
2534
|
<div class="muted">No agents found.</div>
|
|
2513
|
-
`:e.agents.map(s=>
|
|
2535
|
+
`:e.agents.map(s=>og(s,e))}
|
|
2514
2536
|
</div>
|
|
2515
|
-
`:
|
|
2537
|
+
`:r`<div class="row" style="margin-top: 12px; gap: 12px;">
|
|
2516
2538
|
<div class="muted">Load config to edit bindings.</div>
|
|
2517
2539
|
<button class="btn" ?disabled=${e.configLoading} @click=${e.onLoadConfig}>
|
|
2518
2540
|
${e.configLoading?"Loading…":"Load config"}
|
|
2519
2541
|
</button>
|
|
2520
2542
|
</div>`}
|
|
2521
2543
|
</section>
|
|
2522
|
-
`}function
|
|
2544
|
+
`}function og(e,t){const n=e.binding??"__default__",s=e.name?.trim()?`${e.name} (${e.id})`:e.id,i=t.nodes.length>0;return r`
|
|
2523
2545
|
<div class="list-item">
|
|
2524
2546
|
<div class="list-main">
|
|
2525
2547
|
<div class="list-title">${s}</div>
|
|
@@ -2538,7 +2560,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2538
2560
|
<option value="__default__" ?selected=${n==="__default__"}>
|
|
2539
2561
|
Use default
|
|
2540
2562
|
</option>
|
|
2541
|
-
${t.nodes.map(a=>
|
|
2563
|
+
${t.nodes.map(a=>r`<option
|
|
2542
2564
|
value=${a.id}
|
|
2543
2565
|
?selected=${n===a.id}
|
|
2544
2566
|
>
|
|
@@ -2548,7 +2570,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2548
2570
|
</label>
|
|
2549
2571
|
</div>
|
|
2550
2572
|
</div>
|
|
2551
|
-
`}function
|
|
2573
|
+
`}function rg(e){return Wr(e,["system.run"])}function lg(e){const t={id:"main",name:void 0,index:0,isDefault:!0,binding:null};if(!e||typeof e!="object")return{defaultBinding:null,agents:[t]};const s=(e.tools??{}).exec??{},i=typeof s.node=="string"&&s.node.trim()?s.node.trim():null,a=e.agents??{};if(!Array.isArray(a.list)||a.list.length===0)return{defaultBinding:i,agents:[t]};const o=Vr(e).map(c=>{const u=(c.record.tools??{}).exec??{},d=typeof u.node=="string"&&u.node.trim()?u.node.trim():null;return{id:c.id,name:c.name,index:c.index,isDefault:c.isDefault,binding:d}});return o.length===0&&o.push(t),{defaultBinding:i,agents:o}}function cg(e){const t=!!e.connected,n=!!e.paired,s=typeof e.displayName=="string"&&e.displayName.trim()||(typeof e.nodeId=="string"?e.nodeId:"unknown"),i=Array.isArray(e.caps)?e.caps:[],a=Array.isArray(e.commands)?e.commands:[];return r`
|
|
2552
2574
|
<div class="list-item">
|
|
2553
2575
|
<div class="list-main">
|
|
2554
2576
|
<div class="list-title">${s}</div>
|
|
@@ -2562,12 +2584,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2562
2584
|
<span class="chip ${t?"chip-ok":"chip-warn"}">
|
|
2563
2585
|
${t?"connected":"offline"}
|
|
2564
2586
|
</span>
|
|
2565
|
-
${i.slice(0,12).map(o=>
|
|
2566
|
-
${a.slice(0,8).map(o=>
|
|
2587
|
+
${i.slice(0,12).map(o=>r`<span class="chip">${String(o)}</span>`)}
|
|
2588
|
+
${a.slice(0,8).map(o=>r`<span class="chip">${String(o)}</span>`)}
|
|
2567
2589
|
</div>
|
|
2568
2590
|
</div>
|
|
2569
2591
|
</div>
|
|
2570
|
-
`}function
|
|
2592
|
+
`}function dg(e){const t=[];if(e.connected||t.push({severity:"error",icon:"⚠️",title:"Gateway Offline",description:"Cannot reach the gateway. Check the WebSocket URL and token."}),e.lastError){const n=e.lastError.toLowerCase();!n.includes("unauthorized")&&!n.includes("connect failed")&&t.push({severity:"error",icon:"❌",title:"Gateway Error",description:e.lastError})}return e.cronEnabled===!1&&t.push({severity:"warning",icon:"⏰",title:"Cron Disabled",description:"Scheduled agent runs are paused."}),e.lastChannelsRefresh&&Date.now()-e.lastChannelsRefresh>3e5&&t.push({severity:"warning",icon:"🔗",title:"Stale Channels",description:`Last channel refresh was ${D(e.lastChannelsRefresh)}.`}),t}function ug(e){const t=e.severity==="error"?"alert-banner--error":e.severity==="warning"?"alert-banner--warn":"alert-banner--info";return r`
|
|
2571
2593
|
<div class="alert-banner ${t}">
|
|
2572
2594
|
<span class="alert-banner__icon">${e.icon}</span>
|
|
2573
2595
|
<div class="alert-banner__body">
|
|
@@ -2575,7 +2597,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2575
2597
|
<div class="alert-banner__desc">${e.description}</div>
|
|
2576
2598
|
</div>
|
|
2577
2599
|
</div>
|
|
2578
|
-
`}function it(e,t,n,s="ok"){return
|
|
2600
|
+
`}function it(e,t,n,s="ok"){return r`
|
|
2579
2601
|
<div class="health-card">
|
|
2580
2602
|
<div class="health-card__header">
|
|
2581
2603
|
<span class="hc-dot ${s==="ok"?"hc-dot--ok":s==="warn"?"hc-dot--warn":"hc-dot--err"}"></span>
|
|
@@ -2584,25 +2606,25 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2584
2606
|
<div class="health-card__value">${t}</div>
|
|
2585
2607
|
<div class="health-card__hint">${n}</div>
|
|
2586
2608
|
</div>
|
|
2587
|
-
`}function
|
|
2609
|
+
`}function pg(e){const t=e.hello?.snapshot,n=t?.uptimeMs??0,s=n?D(Date.now()-n):"n/a",i=t?.policy?.tickIntervalMs?`${(t.policy.tickIntervalMs/1e3).toFixed(t.policy.tickIntervalMs%1e3===0?0:1)}s`:"n/a",a=dg(e),o=e.connected?"ok":e.lastError?"error":"warn",c=e.cronEnabled==null?"warn":e.cronEnabled?"ok":"warn",l=e.lastChannelsRefresh==null||Date.now()-e.lastChannelsRefresh>3e5?"warn":"ok",u=(()=>{if(e.connected||!e.lastError)return null;const d=e.lastError.toLowerCase();if(!d.includes("unauthorized")&&!d.includes("connect failed"))return null;const p=!!e.settings.token.trim(),f=!!e.password.trim();return!p&&!f?r`
|
|
2588
2610
|
<div class="muted" style="margin-top: 8px;">
|
|
2589
2611
|
This gateway requires auth. Add a token or password, then click Connect.
|
|
2590
2612
|
</div>
|
|
2591
|
-
`:
|
|
2613
|
+
`:r`
|
|
2592
2614
|
<div class="muted" style="margin-top: 8px;">
|
|
2593
2615
|
Auth failed. Update the token, then click Connect.
|
|
2594
2616
|
</div>
|
|
2595
|
-
`})();return
|
|
2596
|
-
${a.length>0?
|
|
2597
|
-
${a.map(
|
|
2617
|
+
`})();return r`
|
|
2618
|
+
${a.length>0?r`<section class="alert-stack">
|
|
2619
|
+
${a.map(ug)}
|
|
2598
2620
|
</section>`:g}
|
|
2599
2621
|
|
|
2600
2622
|
<section class="health-grid">
|
|
2601
2623
|
${it("Gateway",e.connected?"Online":"Offline",e.connected?`Uptime ${s}`:"Not connected",o)}
|
|
2602
2624
|
${it("Instances",String(e.presenceCount),"Presence beacons active",e.presenceCount>0?"ok":"warn")}
|
|
2603
2625
|
${it("Sessions",String(e.sessionsCount??"n/a"),"Tracked by gateway","ok")}
|
|
2604
|
-
${it("Cron",e.cronEnabled==null?"n/a":e.cronEnabled?`${
|
|
2605
|
-
${it("Channels",e.lastChannelsRefresh?D(e.lastChannelsRefresh):"n/a","Last refresh",
|
|
2626
|
+
${it("Cron",e.cronEnabled==null?"n/a":e.cronEnabled?`${jr(e.cronNext)}`:"Disabled",e.cronEnabled?"Next scheduled run":"Agent scheduling paused",c)}
|
|
2627
|
+
${it("Channels",e.lastChannelsRefresh?D(e.lastChannelsRefresh):"n/a","Last refresh",l)}
|
|
2606
2628
|
${it("Tick",i,"Gateway heartbeat interval","ok")}
|
|
2607
2629
|
</section>
|
|
2608
2630
|
|
|
@@ -2641,7 +2663,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2641
2663
|
<button class="btn" @click=${()=>e.onConnect()}>Connect</button>
|
|
2642
2664
|
<button class="btn" @click=${()=>e.onRefresh()}>Refresh</button>
|
|
2643
2665
|
</div>
|
|
2644
|
-
${e.lastError?
|
|
2666
|
+
${e.lastError?r`<div class="callout danger" style="margin-top: 14px;">${e.lastError}${u??""}</div>`:g}
|
|
2645
2667
|
</div>
|
|
2646
2668
|
|
|
2647
2669
|
<div class="card glass-card">
|
|
@@ -2667,7 +2689,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2667
2689
|
</div>
|
|
2668
2690
|
</div>
|
|
2669
2691
|
</section>
|
|
2670
|
-
`}const
|
|
2692
|
+
`}const hg=["","off","minimal","low","medium","high"],fg=["","off","on"],gg=[{value:"",label:"inherit"},{value:"off",label:"off (explicit)"},{value:"on",label:"on"}],mg=["","off","on","stream"];function vg(e){if(!e)return"";const t=e.trim().toLowerCase();return t==="z.ai"||t==="z-ai"?"zai":t}function qr(e){return vg(e)==="zai"}function yg(e){return qr(e)?fg:hg}function bg(e,t){return!t||!e||e==="off"?e:"on"}function wg(e,t){return e?t&&e==="on"?"low":e:null}function $g(e){const t=e.result?.sessions??[];return r`
|
|
2671
2693
|
<section class="card">
|
|
2672
2694
|
<div class="row" style="justify-content: space-between;">
|
|
2673
2695
|
<div>
|
|
@@ -2712,7 +2734,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2712
2734
|
</label>
|
|
2713
2735
|
</div>
|
|
2714
2736
|
|
|
2715
|
-
${e.error?
|
|
2737
|
+
${e.error?r`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:g}
|
|
2716
2738
|
|
|
2717
2739
|
<div class="muted" style="margin-top: 12px;">
|
|
2718
2740
|
${e.result?`Store: ${e.result.path}`:""}
|
|
@@ -2730,12 +2752,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2730
2752
|
<div>Reasoning</div>
|
|
2731
2753
|
<div>Actions</div>
|
|
2732
2754
|
</div>
|
|
2733
|
-
${t.length===0?
|
|
2755
|
+
${t.length===0?r`<div class="muted">No sessions found.</div>`:t.map(n=>xg(n,e.basePath,e.onPatch,e.onDelete,e.loading))}
|
|
2734
2756
|
</div>
|
|
2735
2757
|
</section>
|
|
2736
|
-
`}function
|
|
2758
|
+
`}function xg(e,t,n,s,i){const a=e.updatedAt?D(e.updatedAt):"n/a",o=e.thinkingLevel??"",c=qr(e.modelProvider),l=bg(o,c),u=yg(e.modelProvider),d=e.verboseLevel??"",p=e.reasoningLevel??"",f=e.displayName??e.key,m=e.kind!=="global",v=m?`${$n("chat",t)}?session=${encodeURIComponent(e.key)}`:null;return r`
|
|
2737
2759
|
<div class="table-row">
|
|
2738
|
-
<div class="mono">${m?
|
|
2760
|
+
<div class="mono">${m?r`<a href=${v} class="session-link">${f}</a>`:f}</div>
|
|
2739
2761
|
<div>
|
|
2740
2762
|
<input
|
|
2741
2763
|
.value=${e.label??""}
|
|
@@ -2746,14 +2768,14 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2746
2768
|
</div>
|
|
2747
2769
|
<div>${e.kind}</div>
|
|
2748
2770
|
<div>${a}</div>
|
|
2749
|
-
<div>${
|
|
2771
|
+
<div>${xf(e)}</div>
|
|
2750
2772
|
<div>
|
|
2751
2773
|
<select
|
|
2752
|
-
.value=${
|
|
2774
|
+
.value=${l}
|
|
2753
2775
|
?disabled=${i}
|
|
2754
|
-
@change=${$=>{const k=$.target.value;n(e.key,{thinkingLevel:
|
|
2776
|
+
@change=${$=>{const k=$.target.value;n(e.key,{thinkingLevel:wg(k,c)})}}
|
|
2755
2777
|
>
|
|
2756
|
-
${u.map($=>
|
|
2778
|
+
${u.map($=>r`<option value=${$}>${$||"inherit"}</option>`)}
|
|
2757
2779
|
</select>
|
|
2758
2780
|
</div>
|
|
2759
2781
|
<div>
|
|
@@ -2762,7 +2784,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2762
2784
|
?disabled=${i}
|
|
2763
2785
|
@change=${$=>{const k=$.target.value;n(e.key,{verboseLevel:k||null})}}
|
|
2764
2786
|
>
|
|
2765
|
-
${
|
|
2787
|
+
${gg.map($=>r`<option value=${$.value}>${$.label}</option>`)}
|
|
2766
2788
|
</select>
|
|
2767
2789
|
</div>
|
|
2768
2790
|
<div>
|
|
@@ -2771,7 +2793,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2771
2793
|
?disabled=${i}
|
|
2772
2794
|
@change=${$=>{const k=$.target.value;n(e.key,{reasoningLevel:k||null})}}
|
|
2773
2795
|
>
|
|
2774
|
-
${
|
|
2796
|
+
${mg.map($=>r`<option value=${$}>${$||"inherit"}</option>`)}
|
|
2775
2797
|
</select>
|
|
2776
2798
|
</div>
|
|
2777
2799
|
<div>
|
|
@@ -2780,7 +2802,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2780
2802
|
</button>
|
|
2781
2803
|
</div>
|
|
2782
2804
|
</div>
|
|
2783
|
-
`}function
|
|
2805
|
+
`}function kg(e){const t=Math.max(0,e),n=Math.floor(t/1e3);if(n<60)return`${n}s`;const s=Math.floor(n/60);return s<60?`${s}m`:`${Math.floor(s/60)}h`}function Fe(e,t){return t?r`<div class="exec-approval-meta-row"><span>${e}</span><span>${t}</span></div>`:g}function Sg(e){const t=e.execApprovalQueue[0];if(!t)return g;const n=t.request,s=t.expiresAtMs-Date.now(),i=s>0?`expires in ${kg(s)}`:"expired",a=e.execApprovalQueue.length;return r`
|
|
2784
2806
|
<div class="exec-approval-overlay" role="dialog" aria-live="polite">
|
|
2785
2807
|
<div class="exec-approval-card">
|
|
2786
2808
|
<div class="exec-approval-header">
|
|
@@ -2788,7 +2810,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2788
2810
|
<div class="exec-approval-title">Exec approval needed</div>
|
|
2789
2811
|
<div class="exec-approval-sub">${i}</div>
|
|
2790
2812
|
</div>
|
|
2791
|
-
${a>1?
|
|
2813
|
+
${a>1?r`<div class="exec-approval-queue">${a} pending</div>`:g}
|
|
2792
2814
|
</div>
|
|
2793
2815
|
<div class="exec-approval-command mono">${n.command}</div>
|
|
2794
2816
|
<div class="exec-approval-meta">
|
|
@@ -2800,7 +2822,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2800
2822
|
${Fe("Security",n.security)}
|
|
2801
2823
|
${Fe("Ask",n.ask)}
|
|
2802
2824
|
</div>
|
|
2803
|
-
${e.execApprovalError?
|
|
2825
|
+
${e.execApprovalError?r`<div class="exec-approval-error">${e.execApprovalError}</div>`:g}
|
|
2804
2826
|
<div class="exec-approval-actions">
|
|
2805
2827
|
<button
|
|
2806
2828
|
class="btn primary"
|
|
@@ -2826,7 +2848,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2826
2848
|
</div>
|
|
2827
2849
|
</div>
|
|
2828
2850
|
</div>
|
|
2829
|
-
`}function
|
|
2851
|
+
`}function Ag(e){const t=e.report?.skills??[],n=e.filter.trim().toLowerCase(),s=n?t.filter(i=>[i.name,i.description,i.source].join(" ").toLowerCase().includes(n)):t;return r`
|
|
2830
2852
|
<section class="card">
|
|
2831
2853
|
<div class="row" style="justify-content: space-between;">
|
|
2832
2854
|
<div>
|
|
@@ -2850,34 +2872,34 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2850
2872
|
<div class="muted">${s.length} shown</div>
|
|
2851
2873
|
</div>
|
|
2852
2874
|
|
|
2853
|
-
${e.error?
|
|
2875
|
+
${e.error?r`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:g}
|
|
2854
2876
|
|
|
2855
|
-
${s.length===0?
|
|
2877
|
+
${s.length===0?r`<div class="muted" style="margin-top: 16px;">No skills found.</div>`:r`
|
|
2856
2878
|
<div class="list" style="margin-top: 16px;">
|
|
2857
|
-
${s.map(i
|
|
2879
|
+
${s.map(i=>_g(i,e))}
|
|
2858
2880
|
</div>
|
|
2859
2881
|
`}
|
|
2860
2882
|
</section>
|
|
2861
|
-
`}function
|
|
2883
|
+
`}function _g(e,t){const n=t.busyKey===e.skillKey,s=t.edits[e.skillKey]??"",i=t.messages[e.skillKey]??null,a=e.install.length>0&&e.missing.bins.length>0,o=[...e.missing.bins.map(l=>`bin:${l}`),...e.missing.env.map(l=>`env:${l}`),...e.missing.config.map(l=>`config:${l}`),...e.missing.os.map(l=>`os:${l}`)],c=[];return e.disabled&&c.push("disabled"),e.blockedByAllowlist&&c.push("blocked by allowlist"),r`
|
|
2862
2884
|
<div class="list-item">
|
|
2863
2885
|
<div class="list-main">
|
|
2864
2886
|
<div class="list-title">
|
|
2865
2887
|
${e.emoji?`${e.emoji} `:""}${e.name}
|
|
2866
2888
|
</div>
|
|
2867
|
-
<div class="list-sub">${
|
|
2889
|
+
<div class="list-sub">${Ts(e.description,140)}</div>
|
|
2868
2890
|
<div class="chip-row" style="margin-top: 6px;">
|
|
2869
2891
|
<span class="chip">${e.source}</span>
|
|
2870
2892
|
<span class="chip ${e.eligible?"chip-ok":"chip-warn"}">
|
|
2871
2893
|
${e.eligible?"eligible":"blocked"}
|
|
2872
2894
|
</span>
|
|
2873
|
-
${e.disabled?
|
|
2895
|
+
${e.disabled?r`<span class="chip chip-warn">disabled</span>`:g}
|
|
2874
2896
|
</div>
|
|
2875
|
-
${o.length>0?
|
|
2897
|
+
${o.length>0?r`
|
|
2876
2898
|
<div class="muted" style="margin-top: 6px;">
|
|
2877
2899
|
Missing: ${o.join(", ")}
|
|
2878
2900
|
</div>
|
|
2879
2901
|
`:g}
|
|
2880
|
-
${c.length>0?
|
|
2902
|
+
${c.length>0?r`
|
|
2881
2903
|
<div class="muted" style="margin-top: 6px;">
|
|
2882
2904
|
Reason: ${c.join(", ")}
|
|
2883
2905
|
</div>
|
|
@@ -2892,7 +2914,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2892
2914
|
>
|
|
2893
2915
|
${e.disabled?"Enable":"Disable"}
|
|
2894
2916
|
</button>
|
|
2895
|
-
${a?
|
|
2917
|
+
${a?r`<button
|
|
2896
2918
|
class="btn"
|
|
2897
2919
|
?disabled=${n}
|
|
2898
2920
|
@click=${()=>t.onInstall(e.skillKey,e.name,e.install[0].id)}
|
|
@@ -2900,19 +2922,19 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2900
2922
|
${n?"Installing…":e.install[0].label}
|
|
2901
2923
|
</button>`:g}
|
|
2902
2924
|
</div>
|
|
2903
|
-
${i?
|
|
2925
|
+
${i?r`<div
|
|
2904
2926
|
class="muted"
|
|
2905
2927
|
style="margin-top: 8px; color: ${i.kind==="error"?"var(--danger-color, #d14343)":"var(--success-color, #0a7f5a)"};"
|
|
2906
2928
|
>
|
|
2907
2929
|
${i.message}
|
|
2908
2930
|
</div>`:g}
|
|
2909
|
-
${e.primaryEnv?
|
|
2931
|
+
${e.primaryEnv?r`
|
|
2910
2932
|
<div class="field" style="margin-top: 10px;">
|
|
2911
2933
|
<span>API key</span>
|
|
2912
2934
|
<input
|
|
2913
2935
|
type="password"
|
|
2914
2936
|
.value=${s}
|
|
2915
|
-
@input=${
|
|
2937
|
+
@input=${l=>t.onEdit(e.skillKey,l.target.value)}
|
|
2916
2938
|
/>
|
|
2917
2939
|
</div>
|
|
2918
2940
|
<button
|
|
@@ -2926,26 +2948,26 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2926
2948
|
`:g}
|
|
2927
2949
|
</div>
|
|
2928
2950
|
</div>
|
|
2929
|
-
`}function
|
|
2951
|
+
`}function Tg(e,t){const n=$n(t,e.basePath);return r`
|
|
2930
2952
|
<a
|
|
2931
2953
|
href=${n}
|
|
2932
2954
|
class="nav-item ${e.tab===t?"active":""}"
|
|
2933
2955
|
@click=${s=>{s.defaultPrevented||s.button!==0||s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||(s.preventDefault(),e.setTab(t))}}
|
|
2934
|
-
title=${
|
|
2956
|
+
title=${As(t)}
|
|
2935
2957
|
>
|
|
2936
|
-
<span class="nav-item__icon" aria-hidden="true">${G[
|
|
2937
|
-
<span class="nav-item__text">${
|
|
2958
|
+
<span class="nav-item__icon" aria-hidden="true">${G[cc(t)]}</span>
|
|
2959
|
+
<span class="nav-item__text">${As(t)}</span>
|
|
2938
2960
|
</a>
|
|
2939
|
-
`}function
|
|
2961
|
+
`}function Cg(e){const t=Eg(e.sessionKey,e.sessionsResult),n=e.onboarding,s=e.onboarding,i=e.onboarding?!1:e.settings.chatShowThinking,a=e.onboarding?!0:e.settings.chatFocusMode,o=r`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"></path><path d="M21 3v5h-5"></path></svg>`,c=r`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7V4h3"></path><path d="M20 7V4h-3"></path><path d="M4 17v3h3"></path><path d="M20 17v3h-3"></path><circle cx="12" cy="12" r="3"></circle></svg>`;return r`
|
|
2940
2962
|
<div class="chat-controls">
|
|
2941
2963
|
<label class="field chat-controls__session">
|
|
2942
2964
|
<select
|
|
2943
2965
|
.value=${e.sessionKey}
|
|
2944
2966
|
?disabled=${!e.connected}
|
|
2945
|
-
@change=${
|
|
2967
|
+
@change=${l=>{const u=l.target.value;e.sessionKey=u,e.chatMessage="",e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:u,lastActiveSessionKey:u}),e.loadAssistantIdentity(),du(e,u),lt(e)}}
|
|
2946
2968
|
>
|
|
2947
|
-
${
|
|
2948
|
-
${
|
|
2969
|
+
${gr(t,l=>l.key,l=>r`<option value=${l.key}>
|
|
2970
|
+
${l.displayName??l.key}
|
|
2949
2971
|
</option>`)}
|
|
2950
2972
|
</select>
|
|
2951
2973
|
</label>
|
|
@@ -2977,7 +2999,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2977
2999
|
${c}
|
|
2978
3000
|
</button>
|
|
2979
3001
|
</div>
|
|
2980
|
-
`}function
|
|
3002
|
+
`}function Eg(e,t){const n=new Set,s=[],i=t?.sessions?.find(a=>a.key===e);if(n.add(e),s.push({key:e,displayName:i?.displayName}),t?.sessions)for(const a of t.sessions)n.has(a.key)||(n.add(a.key),s.push({key:a.key,displayName:a.displayName}));return s}const Rg=["system","light","dark"];function Mg(e){const t=Math.max(0,Rg.indexOf(e.theme)),n=s=>i=>{const o={element:i.currentTarget};(i.clientX||i.clientY)&&(o.pointerClientX=i.clientX,o.pointerClientY=i.clientY),e.setTheme(s,o)};return r`
|
|
2981
3003
|
<div class="theme-toggle" style="--theme-index: ${t};">
|
|
2982
3004
|
<div class="theme-toggle__track" role="group" aria-label="Theme">
|
|
2983
3005
|
<span class="theme-toggle__indicator"></span>
|
|
@@ -2988,7 +3010,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2988
3010
|
aria-label="System theme"
|
|
2989
3011
|
title="System"
|
|
2990
3012
|
>
|
|
2991
|
-
${
|
|
3013
|
+
${Pg()}
|
|
2992
3014
|
</button>
|
|
2993
3015
|
<button
|
|
2994
3016
|
class="theme-toggle__button ${e.theme==="light"?"active":""}"
|
|
@@ -2997,7 +3019,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2997
3019
|
aria-label="Light theme"
|
|
2998
3020
|
title="Light"
|
|
2999
3021
|
>
|
|
3000
|
-
${
|
|
3022
|
+
${Ig()}
|
|
3001
3023
|
</button>
|
|
3002
3024
|
<button
|
|
3003
3025
|
class="theme-toggle__button ${e.theme==="dark"?"active":""}"
|
|
@@ -3006,11 +3028,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
3006
3028
|
aria-label="Dark theme"
|
|
3007
3029
|
title="Dark"
|
|
3008
3030
|
>
|
|
3009
|
-
${
|
|
3031
|
+
${Lg()}
|
|
3010
3032
|
</button>
|
|
3011
3033
|
</div>
|
|
3012
3034
|
</div>
|
|
3013
|
-
`}function
|
|
3035
|
+
`}function Ig(){return r`
|
|
3014
3036
|
<svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
|
|
3015
3037
|
<circle cx="12" cy="12" r="4"></circle>
|
|
3016
3038
|
<path d="M12 2v2"></path>
|
|
@@ -3022,19 +3044,19 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
3022
3044
|
<path d="m6.34 17.66-1.41 1.41"></path>
|
|
3023
3045
|
<path d="m19.07 4.93-1.41 1.41"></path>
|
|
3024
3046
|
</svg>
|
|
3025
|
-
`}function
|
|
3047
|
+
`}function Lg(){return r`
|
|
3026
3048
|
<svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
|
|
3027
3049
|
<path
|
|
3028
3050
|
d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"
|
|
3029
3051
|
></path>
|
|
3030
3052
|
</svg>
|
|
3031
|
-
`}function
|
|
3053
|
+
`}function Pg(){return r`
|
|
3032
3054
|
<svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
|
|
3033
3055
|
<rect width="20" height="14" x="2" y="3" rx="2"></rect>
|
|
3034
3056
|
<line x1="8" x2="16" y1="21" y2="21"></line>
|
|
3035
3057
|
<line x1="12" x2="12" y1="17" y2="21"></line>
|
|
3036
3058
|
</svg>
|
|
3037
|
-
`}const
|
|
3059
|
+
`}const Ng=/^data:/i,Og=/^https?:\/\//i;function Dg(e){const t=e.agentsList?.agents??[],s=Eo(e.sessionKey)?.agentId??e.agentsList?.defaultId??"main",a=t.find(c=>c.id===s)?.identity,o=a?.avatarUrl??a?.avatar;if(o)return Ng.test(o)||Og.test(o)?o:a?.avatarUrl}function Bg(e){const t=e.presenceEntries.length,n=e.sessionsResult?.count??null,s=e.cronStatus?.nextWakeAtMs??null,i=e.connected?null:"Disconnected from gateway.",a=e.tab==="chat",o=a&&(e.settings.chatFocusMode||e.onboarding),c=e.onboarding?!1:e.settings.chatShowThinking,l=Dg(e),u=e.chatAvatarUrl??l??null;return r`
|
|
3038
3060
|
<div class="shell ${a?"shell--chat":""} ${o?"shell--chat-focus":""} ${e.settings.navCollapsed?"shell--nav-collapsed":""} ${e.onboarding?"shell--onboarding":""}">
|
|
3039
3061
|
<header class="topbar">
|
|
3040
3062
|
<div class="topbar-left">
|
|
@@ -3062,11 +3084,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
3062
3084
|
<span>Health</span>
|
|
3063
3085
|
<span class="mono">${e.connected?"OK":"Offline"}</span>
|
|
3064
3086
|
</div>
|
|
3065
|
-
${
|
|
3087
|
+
${Mg(e)}
|
|
3066
3088
|
</div>
|
|
3067
3089
|
</header>
|
|
3068
3090
|
<aside class="nav ${e.settings.navCollapsed?"nav--collapsed":""}">
|
|
3069
|
-
${
|
|
3091
|
+
${rc.map(d=>{const p=e.settings.navGroupsCollapsed[d.label]??!1,f=d.tabs.some(m=>m===e.tab);return r`
|
|
3070
3092
|
<div class="nav-group ${p&&!f?"nav-group--collapsed":""}">
|
|
3071
3093
|
<button
|
|
3072
3094
|
class="nav-label"
|
|
@@ -3077,7 +3099,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
3077
3099
|
<span class="nav-label__chevron">${p?"+":"−"}</span>
|
|
3078
3100
|
</button>
|
|
3079
3101
|
<div class="nav-group__items">
|
|
3080
|
-
${d.tabs.map(m=>
|
|
3102
|
+
${d.tabs.map(m=>Tg(e,m))}
|
|
3081
3103
|
</div>
|
|
3082
3104
|
</div>
|
|
3083
3105
|
`})}
|
|
@@ -3102,40 +3124,40 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
3102
3124
|
<main class="content ${a?"content--chat":""}">
|
|
3103
3125
|
<section class="content-header">
|
|
3104
3126
|
<div>
|
|
3105
|
-
<div class="page-title">${
|
|
3106
|
-
<div class="page-sub">${
|
|
3127
|
+
<div class="page-title">${As(e.tab)}</div>
|
|
3128
|
+
<div class="page-sub">${dc(e.tab)}</div>
|
|
3107
3129
|
</div>
|
|
3108
3130
|
<div class="page-meta">
|
|
3109
|
-
${e.lastError?
|
|
3110
|
-
${a?
|
|
3131
|
+
${e.lastError?r`<div class="pill danger">${e.lastError}</div>`:g}
|
|
3132
|
+
${a?Cg(e):g}
|
|
3111
3133
|
</div>
|
|
3112
3134
|
</section>
|
|
3113
3135
|
|
|
3114
|
-
${e.tab==="overview"?
|
|
3136
|
+
${e.tab==="overview"?pg({connected:e.connected,hello:e.hello,settings:e.settings,password:e.password,lastError:e.lastError,presenceCount:t,sessionsCount:n,cronEnabled:e.cronStatus?.enabled??null,cronNext:s,lastChannelsRefresh:e.channelsLastSuccess,onSettingsChange:d=>e.applySettings(d),onPasswordChange:d=>e.password=d,onSessionKeyChange:d=>{e.sessionKey=d,e.chatMessage="",e.resetToolStream(),e.applySettings({...e.settings,sessionKey:d,lastActiveSessionKey:d}),e.loadAssistantIdentity()},onConnect:()=>e.connect(),onRefresh:()=>e.loadOverview()}):g}
|
|
3115
3137
|
|
|
3116
|
-
${e.tab==="channels"?
|
|
3138
|
+
${e.tab==="channels"?df({connected:e.connected,loading:e.channelsLoading,snapshot:e.channelsSnapshot,lastError:e.channelsError,lastSuccessAt:e.channelsLastSuccess,whatsappMessage:e.whatsappLoginMessage,whatsappQrDataUrl:e.whatsappLoginQrDataUrl,whatsappConnected:e.whatsappLoginConnected,whatsappBusy:e.whatsappBusy,configSchema:e.configSchema,configSchemaLoading:e.configSchemaLoading,configForm:e.configForm,configUiHints:e.configUiHints,configSaving:e.configSaving,configFormDirty:e.configFormDirty,nostrProfileFormState:e.nostrProfileFormState,nostrProfileAccountId:e.nostrProfileAccountId,onRefresh:d=>ue(e,d),onWhatsAppStart:d=>e.handleWhatsAppStart(d),onWhatsAppWait:()=>e.handleWhatsAppWait(),onWhatsAppLogout:()=>e.handleWhatsAppLogout(),onConfigPatch:(d,p)=>Yt(e,d,p),onConfigSave:()=>e.handleChannelConfigSave(),onConfigReload:()=>e.handleChannelConfigReload(),onNostrProfileEdit:(d,p)=>e.handleNostrProfileEdit(d,p),onNostrProfileCancel:()=>e.handleNostrProfileCancel(),onNostrProfileFieldChange:(d,p)=>e.handleNostrProfileFieldChange(d,p),onNostrProfileSave:()=>e.handleNostrProfileSave(),onNostrProfileImport:()=>e.handleNostrProfileImport(),onNostrProfileToggleAdvanced:()=>e.handleNostrProfileToggleAdvanced()}):g}
|
|
3117
3139
|
|
|
3118
|
-
${e.tab==="instances"?
|
|
3140
|
+
${e.tab==="instances"?Pf({loading:e.presenceLoading,entries:e.presenceEntries,lastError:e.presenceError,statusMessage:e.presenceStatus,onRefresh:()=>ci(e)}):g}
|
|
3119
3141
|
|
|
3120
|
-
${e.tab==="sessions"
|
|
3142
|
+
${e.tab==="sessions"?$g({loading:e.sessionsLoading,result:e.sessionsResult,error:e.sessionsError,activeMinutes:e.sessionsFilterActive,limit:e.sessionsFilterLimit,includeGlobal:e.sessionsIncludeGlobal,includeUnknown:e.sessionsIncludeUnknown,basePath:e.basePath,onFiltersChange:d=>{e.sessionsFilterActive=d.activeMinutes,e.sessionsFilterLimit=d.limit,e.sessionsIncludeGlobal=d.includeGlobal,e.sessionsIncludeUnknown=d.includeUnknown},onRefresh:()=>ht(e),onPatch:(d,p)=>Tc(e,d,p),onDelete:d=>Cc(e,d)}):g}
|
|
3121
3143
|
|
|
3122
|
-
${e.tab==="cron"?
|
|
3144
|
+
${e.tab==="cron"?Tf({loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:e.channelsSnapshot?.channelMeta?.length?e.channelsSnapshot.channelMeta.map(d=>d.id):e.channelsSnapshot?.channelOrder??[],channelLabels:e.channelsSnapshot?.channelLabels??{},channelMeta:e.channelsSnapshot?.channelMeta??[],runsJobId:e.cronRunsJobId,runs:e.cronRuns,onFormChange:d=>e.cronForm={...e.cronForm,...d},onRefresh:()=>e.loadCron(),onAdd:()=>Qc(e),onToggle:(d,p)=>Jc(e,d,p),onRun:d=>Zc(e,d),onRemove:d=>Xc(e,d),onLoadRuns:d=>Fo(e,d)}):g}
|
|
3123
3145
|
|
|
3124
|
-
${e.tab==="skills"?
|
|
3146
|
+
${e.tab==="skills"?Ag({loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,onFilterChange:d=>e.skillsFilter=d,onRefresh:()=>Ft(e,{clearMessages:!0}),onToggle:(d,p)=>qd(e,d,p),onEdit:(d,p)=>Wd(e,d,p),onSaveKey:d=>Gd(e,d),onInstall:(d,p,f)=>Yd(e,d,p,f)}):g}
|
|
3125
3147
|
|
|
3126
|
-
${e.tab==="nodes"?
|
|
3148
|
+
${e.tab==="nodes"?Xf({loading:e.nodesLoading,nodes:e.nodes,devicesLoading:e.devicesLoading,devicesError:e.devicesError,devicesList:e.devicesList,configForm:e.configForm??e.configSnapshot?.config,configLoading:e.configLoading,configSaving:e.configSaving,configDirty:e.configFormDirty,configFormMode:e.configFormMode,execApprovalsLoading:e.execApprovalsLoading,execApprovalsSaving:e.execApprovalsSaving,execApprovalsDirty:e.execApprovalsDirty,execApprovalsSnapshot:e.execApprovalsSnapshot,execApprovalsForm:e.execApprovalsForm,execApprovalsSelectedAgent:e.execApprovalsSelectedAgent,execApprovalsTarget:e.execApprovalsTarget,execApprovalsTargetNodeId:e.execApprovalsTargetNodeId,onRefresh:()=>Cn(e),onDevicesRefresh:()=>Pe(e),onDeviceApprove:d=>Od(e,d),onDeviceReject:d=>Dd(e,d),onDeviceRotate:(d,p,f)=>Bd(e,{deviceId:d,role:p,scopes:f}),onDeviceRevoke:(d,p)=>Fd(e,{deviceId:d,role:p}),onLoadConfig:()=>Ae(e),onLoadExecApprovals:()=>{const d=e.execApprovalsTarget==="node"&&e.execApprovalsTargetNodeId?{kind:"node",nodeId:e.execApprovalsTargetNodeId}:{kind:"gateway"};return li(e,d)},onBindDefault:d=>{d?Yt(e,["tools","exec","node"],d):xa(e,["tools","exec","node"])},onBindAgent:(d,p)=>{const f=["agents","list",d,"tools","exec","node"];p?Yt(e,f,p):xa(e,f)},onSaveBindings:()=>Rs(e),onExecApprovalsTargetChange:(d,p)=>{e.execApprovalsTarget=d,e.execApprovalsTargetNodeId=p,e.execApprovalsSnapshot=null,e.execApprovalsForm=null,e.execApprovalsDirty=!1,e.execApprovalsSelectedAgent=null},onExecApprovalsSelectAgent:d=>{e.execApprovalsSelectedAgent=d},onExecApprovalsPatch:(d,p)=>jd(e,d,p),onExecApprovalsRemove:d=>Vd(e,d),onSaveExecApprovals:()=>{const d=e.execApprovalsTarget==="node"&&e.execApprovalsTargetNodeId?{kind:"node",nodeId:e.execApprovalsTargetNodeId}:{kind:"gateway"};return Hd(e,d)}}):g}
|
|
3127
3149
|
|
|
3128
|
-
${e.tab==="chat"?
|
|
3150
|
+
${e.tab==="chat"?Th({sessionKey:e.sessionKey,onSessionKeyChange:d=>{e.sessionKey=d,e.chatMessage="",e.chatAttachments=[],e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:d,lastActiveSessionKey:d}),e.loadAssistantIdentity(),lt(e),Ns(e)},thinkingLevel:e.chatThinkingLevel,showThinking:c,loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:u,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,draft:e.chatMessage,queue:e.chatQueue,connected:e.connected,canSend:e.connected,disabledReason:i,error:e.lastError,sessions:e.sessionsResult,focusMode:o,onRefresh:()=>(e.resetToolStream(),Promise.all([lt(e),Ns(e)])),onToggleFocusMode:()=>{e.onboarding||e.applySettings({...e.settings,chatFocusMode:!e.settings.chatFocusMode})},onChatScroll:d=>e.handleChatScroll(d),onDraftChange:d=>e.chatMessage=d,attachments:e.chatAttachments,onAttachmentsChange:d=>e.chatAttachments=d,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:d=>e.removeQueuedMessage(d),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:d=>e.handleOpenSidebar(d),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:d=>e.handleSplitRatioChange(d),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar}):g}
|
|
3129
3151
|
|
|
3130
|
-
${e.tab==="config"?
|
|
3152
|
+
${e.tab==="config"?Vh({raw:e.configRaw,originalRaw:e.configRawOriginal,valid:e.configValid,issues:e.configIssues,loading:e.configLoading,saving:e.configSaving,applying:e.configApplying,updating:e.updateRunning,connected:e.connected,schema:e.configSchema,schemaLoading:e.configSchemaLoading,uiHints:e.configUiHints,formMode:e.configFormMode,formValue:e.configForm,originalValue:e.configFormOriginal,searchQuery:e.configSearchQuery,activeSection:e.configActiveSection,activeSubsection:e.configActiveSubsection,onRawChange:d=>{e.configRaw=d},onFormModeChange:d=>e.configFormMode=d,onFormPatch:(d,p)=>Yt(e,d,p),onSearchChange:d=>e.configSearchQuery=d,onSectionChange:d=>{e.configActiveSection=d,e.configActiveSubsection=null},onSubsectionChange:d=>e.configActiveSubsection=d,onReload:()=>Ae(e),onSave:()=>Rs(e),onApply:()=>Wc(e),onUpdate:()=>qc(e)}):g}
|
|
3131
3153
|
|
|
3132
|
-
${e.tab==="debug"?
|
|
3154
|
+
${e.tab==="debug"?Lf({loading:e.debugLoading,status:e.debugStatus,health:e.debugHealth,models:e.debugModels,heartbeat:e.debugHeartbeat,eventLog:e.eventLog,callMethod:e.debugCallMethod,callParams:e.debugCallParams,callResult:e.debugCallResult,callError:e.debugCallError,onCallMethodChange:d=>e.debugCallMethod=d,onCallParamsChange:d=>e.debugCallParams=d,onRefresh:()=>_n(e),onCall:()=>sd(e)}):g}
|
|
3133
3155
|
|
|
3134
|
-
${e.tab==="logs"?
|
|
3156
|
+
${e.tab==="logs"?Bf({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:d=>e.logsFilterText=d,onLevelToggle:(d,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[d]:p}},onToggleAutoFollow:d=>e.logsAutoFollow=d,onRefresh:()=>ti(e,{reset:!0}),onExport:(d,p)=>e.exportLogs(d,p),onScroll:d=>e.handleLogsScroll(d)}):g}
|
|
3135
3157
|
</main>
|
|
3136
|
-
${
|
|
3158
|
+
${Sg(e)}
|
|
3137
3159
|
</div>
|
|
3138
|
-
`}const Pg={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Ng={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",to:"",timeoutSeconds:"",postToMainPrefix:""};async function Og(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}}}const jr={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"poolbot-control-ui",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"poolbot-macos",IOS_APP:"poolbot-ios",ANDROID_APP:"poolbot-android",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"poolbot-probe"},fo=jr,Vs={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(jr));new Set(Object.values(Vs));function Dg(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),s=e.token??"",i=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),s];return t==="v2"&&i.push(e.nonce??""),i.join("|")}const Bg=4008;class Fg{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){this.closed=!0,this.ws?.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){return this.ws?.readyState===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.onopen=()=>this.queueConnect(),this.ws.onmessage=t=>this.handleMessage(String(t.data??"")),this.ws.onclose=t=>{const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),this.opts.onClose?.({code:t.code,reason:n}),this.scheduleReconnect()},this.ws.onerror=()=>{})}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=typeof crypto<"u"&&!!crypto.subtle,n=["operator.admin","operator.approvals","operator.pairing"],s="operator";let i=null,a=!1,o=this.opts.token;if(t){i=await ii();const d=Md({deviceId:i.deviceId,role:s})?.token;o=d??this.opts.token,a=!!(d&&this.opts.token)}const c=o||this.opts.password?{token:o,password:this.opts.password}:void 0;let r;if(t&&i){const d=Date.now(),p=this.connectNonce??void 0,f=Dg({deviceId:i.deviceId,clientId:this.opts.clientName??fo.CONTROL_UI,clientMode:this.opts.mode??Vs.WEBCHAT,role:s,scopes:n,signedAtMs:d,token:o??null,nonce:p}),m=await Ed(i.privateKey,f);r={id:i.deviceId,publicKey:i.publicKey,signature:m,signedAt:d,nonce:p}}const u={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??fo.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Vs.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:r,caps:[],auth:c,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",u).then(d=>{d?.auth?.deviceToken&&i&&er({deviceId:i.deviceId,role:d.auth.role??s,token:d.auth.deviceToken,scopes:d.auth.scopes??[]}),this.backoffMs=800,this.opts.onHello?.(d)}).catch(()=>{a&&i&&tr({deviceId:i.deviceId,role:s}),this.ws?.close(Bg,"connect failed")})}handleMessage(t){let n;try{n=JSON.parse(t)}catch{return}const s=n;if(s.type==="event"){const i=n;if(i.event==="connect.challenge"){const o=i.payload,c=o&&typeof o.nonce=="string"?o.nonce:null;c&&(this.connectNonce=c,this.sendConnect());return}const a=typeof i.seq=="number"?i.seq:null;a!==null&&(this.lastSeq!==null&&a>this.lastSeq+1&&this.opts.onGap?.({expected:this.lastSeq+1,received:a}),this.lastSeq=a);try{this.opts.onEvent?.(i)}catch(o){console.error("[gateway] event handler error:",o)}return}if(s.type==="res"){const i=n,a=this.pending.get(i.id);if(!a)return;this.pending.delete(i.id),i.ok?a.resolve(i.payload):a.reject(new Error(i.error?.message??"request failed"));return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const s=Xs(),i={type:"req",id:s,method:t,params:n},a=new Promise((o,c)=>{this.pending.set(s,{resolve:r=>o(r),reject:c})});return this.ws.send(JSON.stringify(i)),a}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Ws(e){return typeof e=="object"&&e!==null}function Ug(e){if(!Ws(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Ws(n))return null;const s=typeof n.command=="string"?n.command.trim():"";if(!s)return null;const i=typeof e.createdAtMs=="number"?e.createdAtMs:0,a=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!i||!a?null:{id:t,request:{command:s,cwd:typeof n.cwd=="string"?n.cwd:null,host:typeof n.host=="string"?n.host:null,security:typeof n.security=="string"?n.security:null,ask:typeof n.ask=="string"?n.ask:null,agentId:typeof n.agentId=="string"?n.agentId:null,resolvedPath:typeof n.resolvedPath=="string"?n.resolvedPath:null,sessionKey:typeof n.sessionKey=="string"?n.sessionKey:null},createdAtMs:i,expiresAtMs:a}}function Kg(e){if(!Ws(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 Vr(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function zg(e,t){const n=Vr(e).filter(s=>s.id!==t.id);return n.push(t),n}function go(e,t){return Vr(e).filter(n=>n.id!==t)}async function Wr(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),s=n?{sessionKey:n}:{};try{const i=await e.client.request("agent.identity.get",s);if(!i)return;const a=ks(i);e.assistantName=a.name,e.assistantAvatar=a.avatar,e.assistantAgentId=a.agentId??null}catch{}}function ys(e,t){const n=(e??"").trim(),s=t.mainSessionKey?.trim();if(!s)return n;if(!n)return s;const i=t.mainKey?.trim()||"main",a=t.defaultAgentId?.trim();return n==="main"||n===i||a&&(n===`agent:${a}:main`||n===`agent:${a}:${i}`)?s:n}function Hg(e,t){if(!t?.mainSessionKey)return;const n=ys(e.sessionKey,t),s=ys(e.settings.sessionKey,t),i=ys(e.settings.lastActiveSessionKey,t),a=n||s||e.sessionKey,o={...e.settings,sessionKey:s||a,lastActiveSessionKey:i||a},c=o.sessionKey!==e.settings.sessionKey||o.lastActiveSessionKey!==e.settings.lastActiveSessionKey;a!==e.sessionKey&&(e.sessionKey=a),c&&Re(e,o)}function qr(e){e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null,e.client?.stop(),e.client=new Fg({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:"poolbot-control-ui",mode:"webchat",onHello:t=>{e.connected=!0,e.lastError=null,e.hello=t,Wg(e,t),e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,kn(e),Wr(e),Og(e),Cn(e,{quiet:!0}),Pe(e,{quiet:!0}),fi(e)},onClose:({code:t,reason:n})=>{e.connected=!1,t!==1012&&(e.lastError=`disconnected (${t}): ${n||"no reason"}`)},onEvent:t=>jg(e,t),onGap:({expected:t,received:n})=>{e.lastError=`event gap detected (expected seq ${t}, got ${n}); refresh recommended`}}),e.client.start()}function jg(e,t){try{Vg(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function Vg(e,t){if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),e.tab==="debug"&&(e.eventLog=e.eventLogBuffer),t.event==="agent"){if(e.onboarding)return;Pc(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n?.sessionKey&&nr(e,n.sessionKey);const s=xc(e,n);(s==="final"||s==="error"||s==="aborted")&&(kn(e),hu(e)),s==="final"&<(e);return}if(t.event==="presence"){const n=t.payload;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&gi(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&Pe(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=Ug(t.payload);if(n){e.execApprovalQueue=zg(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=go(e.execApprovalQueue,n.id)},s)}return}if(t.event==="exec.approval.resolved"){const n=Kg(t.payload);n&&(e.execApprovalQueue=go(e.execApprovalQueue,n.id))}}function Wg(e,t){const n=t.snapshot;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n?.health&&(e.debugHealth=n.health),n?.sessionDefaults&&Hg(e,n.sessionDefaults)}function qg(e){e.basePath=eu(),iu(e,!0),tu(e),nu(e),window.addEventListener("popstate",e.popStateHandler),Jd(e),qr(e),Yd(e),e.tab==="logs"&&di(e),e.tab==="debug"&&pi(e)}function Gg(e){Fc(e)}function Yg(e){window.removeEventListener("popstate",e.popStateHandler),Qd(e),ui(e),hi(e),su(e),e.topbarObserver?.disconnect(),e.topbarObserver=null}function Qg(e,t){if(e.tab==="chat"&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),s=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;Sn(e,n||s||!e.chatHasAutoScrolled)}e.tab==="logs"&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&Lo(e,t.has("tab")||t.has("logsAutoFollow"))}async function Jg(e,t){await Qc(e,t),await ue(e,!0)}async function Zg(e){await Jc(e),await ue(e,!0)}async function Xg(e){await Zc(e),await ue(e,!0)}async function em(e){await Es(e),await Ae(e),await ue(e,!0)}async function tm(e){await Ae(e),await ue(e,!0)}function nm(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[s,...i]=n.split(":");if(!s||i.length===0)continue;const a=s.trim(),o=i.join(":").trim();a&&o&&(t[a]=o)}return t}function Gr(e){return(e.channelsSnapshot?.channelAccounts?.nostr??[])[0]?.accountId??e.nostrProfileAccountId??"default"}function Yr(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function sm(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Zh(n??void 0)}function im(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function am(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function om(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function rm(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Gr(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(Yr(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const a=i?.error??`Profile update failed (${s.status})`;e.nostrProfileFormState={...t,saving:!1,error:a,success:null,fieldErrors:nm(i?.details)};return}if(!i.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await ue(e,!0)}catch(s){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(s)}`,success:null}}}async function lm(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Gr(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(Yr(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const r=i?.error??`Profile import failed (${s.status})`;e.nostrProfileFormState={...t,importing:!1,error:r,success:null};return}const a=i.merged??i.imported??null,o=a?{...t.values,...a}:t.values,c=!!(o.banner||o.website||o.nip05||o.lud16);e.nostrProfileFormState={...t,importing:!1,values:o,error:null,success:i.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:c},i.saved&&await ue(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}var cm=Object.defineProperty,dm=Object.getOwnPropertyDescriptor,b=(e,t,n,s)=>{for(var i=s>1?void 0:s?dm(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&cm(t,n,i),i};const bs=ec();function um(){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"}let y=class extends pt{constructor(){super(...arguments),this.settings=tc(),this.password="",this.tab="chat",this.onboarding=um(),this.connected=!1,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=bs.name,this.assistantAvatar=bs.avatar,this.assistantAgentId=bs.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatToolMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.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=`{
|
|
3160
|
+
`}const Fg={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Ug={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",to:"",timeoutSeconds:"",postToMainPrefix:""};async function Kg(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}}}const Gr={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"poolbot-control-ui",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"poolbot-macos",IOS_APP:"poolbot-ios",ANDROID_APP:"poolbot-android",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"poolbot-probe"},mo=Gr,Ws={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Gr));new Set(Object.values(Ws));function zg(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),s=e.token??"",i=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),s];return t==="v2"&&i.push(e.nonce??""),i.join("|")}const Hg=4008;class jg{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){this.closed=!0,this.ws?.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){return this.ws?.readyState===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.onopen=()=>this.queueConnect(),this.ws.onmessage=t=>this.handleMessage(String(t.data??"")),this.ws.onclose=t=>{const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),this.opts.onClose?.({code:t.code,reason:n}),this.scheduleReconnect()},this.ws.onerror=()=>{})}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=typeof crypto<"u"&&!!crypto.subtle,n=["operator.admin","operator.approvals","operator.pairing"],s="operator";let i=null,a=!1,o=this.opts.token;if(t){i=await ai();const d=Nd({deviceId:i.deviceId,role:s})?.token;o=d??this.opts.token,a=!!(d&&this.opts.token)}const c=o||this.opts.password?{token:o,password:this.opts.password}:void 0;let l;if(t&&i){const d=Date.now(),p=this.connectNonce??void 0,f=zg({deviceId:i.deviceId,clientId:this.opts.clientName??mo.CONTROL_UI,clientMode:this.opts.mode??Ws.WEBCHAT,role:s,scopes:n,signedAtMs:d,token:o??null,nonce:p}),m=await Ld(i.privateKey,f);l={id:i.deviceId,publicKey:i.publicKey,signature:m,signedAt:d,nonce:p}}const u={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??mo.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Ws.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:l,caps:[],auth:c,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",u).then(d=>{d?.auth?.deviceToken&&i&&nr({deviceId:i.deviceId,role:d.auth.role??s,token:d.auth.deviceToken,scopes:d.auth.scopes??[]}),this.backoffMs=800,this.opts.onHello?.(d)}).catch(()=>{a&&i&&sr({deviceId:i.deviceId,role:s}),this.ws?.close(Hg,"connect failed")})}handleMessage(t){let n;try{n=JSON.parse(t)}catch{return}const s=n;if(s.type==="event"){const i=n;if(i.event==="connect.challenge"){const o=i.payload,c=o&&typeof o.nonce=="string"?o.nonce:null;c&&(this.connectNonce=c,this.sendConnect());return}const a=typeof i.seq=="number"?i.seq:null;a!==null&&(this.lastSeq!==null&&a>this.lastSeq+1&&this.opts.onGap?.({expected:this.lastSeq+1,received:a}),this.lastSeq=a);try{this.opts.onEvent?.(i)}catch(o){console.error("[gateway] event handler error:",o)}return}if(s.type==="res"){const i=n,a=this.pending.get(i.id);if(!a)return;this.pending.delete(i.id),i.ok?a.resolve(i.payload):a.reject(new Error(i.error?.message??"request failed"));return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const s=ei(),i={type:"req",id:s,method:t,params:n},a=new Promise((o,c)=>{this.pending.set(s,{resolve:l=>o(l),reject:c})});return this.ws.send(JSON.stringify(i)),a}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function qs(e){return typeof e=="object"&&e!==null}function Vg(e){if(!qs(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!qs(n))return null;const s=typeof n.command=="string"?n.command.trim():"";if(!s)return null;const i=typeof e.createdAtMs=="number"?e.createdAtMs:0,a=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!i||!a?null:{id:t,request:{command:s,cwd:typeof n.cwd=="string"?n.cwd:null,host:typeof n.host=="string"?n.host:null,security:typeof n.security=="string"?n.security:null,ask:typeof n.ask=="string"?n.ask:null,agentId:typeof n.agentId=="string"?n.agentId:null,resolvedPath:typeof n.resolvedPath=="string"?n.resolvedPath:null,sessionKey:typeof n.sessionKey=="string"?n.sessionKey:null},createdAtMs:i,expiresAtMs:a}}function Wg(e){if(!qs(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 Yr(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function qg(e,t){const n=Yr(e).filter(s=>s.id!==t.id);return n.push(t),n}function vo(e,t){return Yr(e).filter(n=>n.id!==t)}async function Qr(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),s=n?{sessionKey:n}:{};try{const i=await e.client.request("agent.identity.get",s);if(!i)return;const a=Ss(i);e.assistantName=a.name,e.assistantAvatar=a.avatar,e.assistantAgentId=a.agentId??null}catch{}}function bs(e,t){const n=(e??"").trim(),s=t.mainSessionKey?.trim();if(!s)return n;if(!n)return s;const i=t.mainKey?.trim()||"main",a=t.defaultAgentId?.trim();return n==="main"||n===i||a&&(n===`agent:${a}:main`||n===`agent:${a}:${i}`)?s:n}function Gg(e,t){if(!t?.mainSessionKey)return;const n=bs(e.sessionKey,t),s=bs(e.settings.sessionKey,t),i=bs(e.settings.lastActiveSessionKey,t),a=n||s||e.sessionKey,o={...e.settings,sessionKey:s||a,lastActiveSessionKey:i||a},c=o.sessionKey!==e.settings.sessionKey||o.lastActiveSessionKey!==e.settings.lastActiveSessionKey;a!==e.sessionKey&&(e.sessionKey=a),c&&Re(e,o)}function Jr(e){e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null,e.client?.stop(),e.client=new jg({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:"poolbot-control-ui",mode:"webchat",onHello:t=>{e.connected=!0,e.lastError=null,e.hello=t,Jg(e,t),e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,kn(e),Qr(e),Kg(e),Cn(e,{quiet:!0}),Pe(e,{quiet:!0}),gi(e)},onClose:({code:t,reason:n})=>{e.connected=!1,t!==1012&&(e.lastError=`disconnected (${t}): ${n||"no reason"}`)},onEvent:t=>Yg(e,t),onGap:({expected:t,received:n})=>{e.lastError=`event gap detected (expected seq ${t}, got ${n}); refresh recommended`}}),e.client.start()}function Yg(e,t){try{Qg(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function Qg(e,t){if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),e.tab==="debug"&&(e.eventLog=e.eventLogBuffer),t.event==="agent"){if(e.onboarding)return;Bc(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n?.sessionKey&&ir(e,n.sessionKey);const s=_c(e,n);(s==="final"||s==="error"||s==="aborted")&&(kn(e),vu(e)),s==="final"&<(e);return}if(t.event==="presence"){const n=t.payload;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&mi(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&Pe(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=Vg(t.payload);if(n){e.execApprovalQueue=qg(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=vo(e.execApprovalQueue,n.id)},s)}return}if(t.event==="exec.approval.resolved"){const n=Wg(t.payload);n&&(e.execApprovalQueue=vo(e.execApprovalQueue,n.id))}}function Jg(e,t){const n=t.snapshot;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n?.health&&(e.debugHealth=n.health),n?.sessionDefaults&&Gg(e,n.sessionDefaults)}function Zg(e){e.basePath=iu(),lu(e,!0),au(e),ou(e),window.addEventListener("popstate",e.popStateHandler),tu(e),Jr(e),Xd(e),e.tab==="logs"&&ui(e),e.tab==="debug"&&hi(e)}function Xg(e){Hc(e)}function em(e){window.removeEventListener("popstate",e.popStateHandler),eu(e),pi(e),fi(e),ru(e),e.topbarObserver?.disconnect(),e.topbarObserver=null}function tm(e,t){if(e.tab==="chat"&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),s=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;Sn(e,n||s||!e.chatHasAutoScrolled)}e.tab==="logs"&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&No(e,t.has("tab")||t.has("logsAutoFollow"))}async function nm(e,t){await ed(e,t),await ue(e,!0)}async function sm(e){await td(e),await ue(e,!0)}async function im(e){await nd(e),await ue(e,!0)}async function am(e){await Rs(e),await Ae(e),await ue(e,!0)}async function om(e){await Ae(e),await ue(e,!0)}function rm(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[s,...i]=n.split(":");if(!s||i.length===0)continue;const a=s.trim(),o=i.join(":").trim();a&&o&&(t[a]=o)}return t}function Zr(e){return(e.channelsSnapshot?.channelAccounts?.nostr??[])[0]?.accountId??e.nostrProfileAccountId??"default"}function Xr(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function lm(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=sf(n??void 0)}function cm(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function dm(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function um(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function pm(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Zr(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(Xr(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const a=i?.error??`Profile update failed (${s.status})`;e.nostrProfileFormState={...t,saving:!1,error:a,success:null,fieldErrors:rm(i?.details)};return}if(!i.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await ue(e,!0)}catch(s){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(s)}`,success:null}}}async function hm(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Zr(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(Xr(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const l=i?.error??`Profile import failed (${s.status})`;e.nostrProfileFormState={...t,importing:!1,error:l,success:null};return}const a=i.merged??i.imported??null,o=a?{...t.values,...a}:t.values,c=!!(o.banner||o.website||o.nip05||o.lud16);e.nostrProfileFormState={...t,importing:!1,values:o,error:null,success:i.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:c},i.saved&&await ue(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}var fm=Object.defineProperty,gm=Object.getOwnPropertyDescriptor,b=(e,t,n,s)=>{for(var i=s>1?void 0:s?gm(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&fm(t,n,i),i};const ws=ic();function mm(){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"}let y=class extends pt{constructor(){super(...arguments),this.settings=ac(),this.password="",this.tab="chat",this.onboarding=mm(),this.connected=!1,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=ws.name,this.assistantAvatar=ws.avatar,this.assistantAgentId=ws.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatToolMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.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=`{
|
|
3139
3161
|
}
|
|
3140
|
-
`,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.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.sessionsFilterActive="",this.sessionsFilterLimit="120",this.sessionsIncludeGlobal=!0,this.sessionsIncludeUnknown=!1,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...
|
|
3141
|
-
//# sourceMappingURL=index-
|
|
3162
|
+
`,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.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.sessionsFilterActive="",this.sessionsFilterLimit="120",this.sessionsIncludeGlobal=!0,this.sessionsIncludeUnknown=!1,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...Ug},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},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={...Fg},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.nodesPollInterval=null,this.logsPollInterval=null,this.debugPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>cu(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),Zg(this)}firstUpdated(){Xg(this)}disconnectedCallback(){em(this),super.disconnectedCallback()}updated(e){tm(this,e)}connect(){Jr(this)}handleChatScroll(e){Fc(this,e)}handleLogsScroll(e){Uc(this,e)}exportLogs(e,t){zc(e,t)}resetToolStream(){kn(this)}resetChatScroll(){Kc(this)}async loadAssistantIdentity(){await Qr(this)}applySettings(e){Re(this,e)}setTab(e){nu(this,e)}setTheme(e,t){su(this,e,t)}async loadOverview(){await rr(this)}async loadCron(){await mi(this)}async handleAbortChat(){await cr(this)}removeQueuedMessage(e){fu(this,e)}async handleSendChat(e,t){await gu(this,e,t)}async handleWhatsAppStart(e){await nm(this,e)}async handleWhatsAppWait(){await sm(this)}async handleWhatsAppLogout(){await im(this)}async handleChannelConfigSave(){await am(this)}async handleChannelConfigReload(){await om(this)}handleNostrProfileEdit(e,t){lm(this,e,t)}handleNostrProfileCancel(){cm(this)}handleNostrProfileFieldChange(e,t){dm(this,e,t)}async handleNostrProfileSave(){await pm(this)}async handleNostrProfileImport(){await hm(this)}handleNostrProfileToggleAdvanced(){um(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})}render(){return Bg(this)}};b([w()],y.prototype,"settings",2);b([w()],y.prototype,"password",2);b([w()],y.prototype,"tab",2);b([w()],y.prototype,"onboarding",2);b([w()],y.prototype,"connected",2);b([w()],y.prototype,"theme",2);b([w()],y.prototype,"themeResolved",2);b([w()],y.prototype,"hello",2);b([w()],y.prototype,"lastError",2);b([w()],y.prototype,"eventLog",2);b([w()],y.prototype,"assistantName",2);b([w()],y.prototype,"assistantAvatar",2);b([w()],y.prototype,"assistantAgentId",2);b([w()],y.prototype,"sessionKey",2);b([w()],y.prototype,"chatLoading",2);b([w()],y.prototype,"chatSending",2);b([w()],y.prototype,"chatMessage",2);b([w()],y.prototype,"chatMessages",2);b([w()],y.prototype,"chatToolMessages",2);b([w()],y.prototype,"chatStream",2);b([w()],y.prototype,"chatStreamStartedAt",2);b([w()],y.prototype,"chatRunId",2);b([w()],y.prototype,"compactionStatus",2);b([w()],y.prototype,"chatAvatarUrl",2);b([w()],y.prototype,"chatThinkingLevel",2);b([w()],y.prototype,"chatQueue",2);b([w()],y.prototype,"chatAttachments",2);b([w()],y.prototype,"sidebarOpen",2);b([w()],y.prototype,"sidebarContent",2);b([w()],y.prototype,"sidebarError",2);b([w()],y.prototype,"splitRatio",2);b([w()],y.prototype,"nodesLoading",2);b([w()],y.prototype,"nodes",2);b([w()],y.prototype,"devicesLoading",2);b([w()],y.prototype,"devicesError",2);b([w()],y.prototype,"devicesList",2);b([w()],y.prototype,"execApprovalsLoading",2);b([w()],y.prototype,"execApprovalsSaving",2);b([w()],y.prototype,"execApprovalsDirty",2);b([w()],y.prototype,"execApprovalsSnapshot",2);b([w()],y.prototype,"execApprovalsForm",2);b([w()],y.prototype,"execApprovalsSelectedAgent",2);b([w()],y.prototype,"execApprovalsTarget",2);b([w()],y.prototype,"execApprovalsTargetNodeId",2);b([w()],y.prototype,"execApprovalQueue",2);b([w()],y.prototype,"execApprovalBusy",2);b([w()],y.prototype,"execApprovalError",2);b([w()],y.prototype,"configLoading",2);b([w()],y.prototype,"configRaw",2);b([w()],y.prototype,"configRawOriginal",2);b([w()],y.prototype,"configValid",2);b([w()],y.prototype,"configIssues",2);b([w()],y.prototype,"configSaving",2);b([w()],y.prototype,"configApplying",2);b([w()],y.prototype,"updateRunning",2);b([w()],y.prototype,"applySessionKey",2);b([w()],y.prototype,"configSnapshot",2);b([w()],y.prototype,"configSchema",2);b([w()],y.prototype,"configSchemaVersion",2);b([w()],y.prototype,"configSchemaLoading",2);b([w()],y.prototype,"configUiHints",2);b([w()],y.prototype,"configForm",2);b([w()],y.prototype,"configFormOriginal",2);b([w()],y.prototype,"configFormDirty",2);b([w()],y.prototype,"configFormMode",2);b([w()],y.prototype,"configSearchQuery",2);b([w()],y.prototype,"configActiveSection",2);b([w()],y.prototype,"configActiveSubsection",2);b([w()],y.prototype,"channelsLoading",2);b([w()],y.prototype,"channelsSnapshot",2);b([w()],y.prototype,"channelsError",2);b([w()],y.prototype,"channelsLastSuccess",2);b([w()],y.prototype,"whatsappLoginMessage",2);b([w()],y.prototype,"whatsappLoginQrDataUrl",2);b([w()],y.prototype,"whatsappLoginConnected",2);b([w()],y.prototype,"whatsappBusy",2);b([w()],y.prototype,"nostrProfileFormState",2);b([w()],y.prototype,"nostrProfileAccountId",2);b([w()],y.prototype,"presenceLoading",2);b([w()],y.prototype,"presenceEntries",2);b([w()],y.prototype,"presenceError",2);b([w()],y.prototype,"presenceStatus",2);b([w()],y.prototype,"agentsLoading",2);b([w()],y.prototype,"agentsList",2);b([w()],y.prototype,"agentsError",2);b([w()],y.prototype,"sessionsLoading",2);b([w()],y.prototype,"sessionsResult",2);b([w()],y.prototype,"sessionsError",2);b([w()],y.prototype,"sessionsFilterActive",2);b([w()],y.prototype,"sessionsFilterLimit",2);b([w()],y.prototype,"sessionsIncludeGlobal",2);b([w()],y.prototype,"sessionsIncludeUnknown",2);b([w()],y.prototype,"cronLoading",2);b([w()],y.prototype,"cronJobs",2);b([w()],y.prototype,"cronStatus",2);b([w()],y.prototype,"cronError",2);b([w()],y.prototype,"cronForm",2);b([w()],y.prototype,"cronRunsJobId",2);b([w()],y.prototype,"cronRuns",2);b([w()],y.prototype,"cronBusy",2);b([w()],y.prototype,"skillsLoading",2);b([w()],y.prototype,"skillsReport",2);b([w()],y.prototype,"skillsError",2);b([w()],y.prototype,"skillsFilter",2);b([w()],y.prototype,"skillEdits",2);b([w()],y.prototype,"skillsBusyKey",2);b([w()],y.prototype,"skillMessages",2);b([w()],y.prototype,"debugLoading",2);b([w()],y.prototype,"debugStatus",2);b([w()],y.prototype,"debugHealth",2);b([w()],y.prototype,"debugModels",2);b([w()],y.prototype,"debugHeartbeat",2);b([w()],y.prototype,"debugCallMethod",2);b([w()],y.prototype,"debugCallParams",2);b([w()],y.prototype,"debugCallResult",2);b([w()],y.prototype,"debugCallError",2);b([w()],y.prototype,"logsLoading",2);b([w()],y.prototype,"logsError",2);b([w()],y.prototype,"logsFile",2);b([w()],y.prototype,"logsEntries",2);b([w()],y.prototype,"logsFilterText",2);b([w()],y.prototype,"logsLevelFilters",2);b([w()],y.prototype,"logsAutoFollow",2);b([w()],y.prototype,"logsTruncated",2);b([w()],y.prototype,"logsCursor",2);b([w()],y.prototype,"logsLastFetchAt",2);b([w()],y.prototype,"logsLimit",2);b([w()],y.prototype,"logsMaxBytes",2);b([w()],y.prototype,"logsAtBottom",2);y=b([_o("poolbot-app")],y);
|
|
3163
|
+
//# sourceMappingURL=index-1DWuMa4l.js.map
|