@poolzin/pool-bot 2026.4.15 → 2026.4.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,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,tn=globalThis,Ws=tn.ShadowRoot&&(tn.ShadyCSS===void 0||tn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,qs=Symbol(),Zi=new WeakMap;class go{constructor(t,n,s){if(this._$cssResult$=!0,s!==qs)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(Ws&&t===void 0){const s=n!==void 0&&n.length===1;s&&(t=Zi.get(n)),t===void 0&&((this._styleSheet=t=new CSSStyleSheet).replaceSync(this.cssText),s&&Zi.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 go(typeof e=="string"?e:String(e),void 0,qs),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 go(n,e,qs)},hl=(e,t)=>{if(Ws)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const s=document.createElement("style"),i=tn.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)},Xi=Ws||cl?e=>e:e=>e instanceof CSSStyleSheet?fl(e):e;const{is:gl,defineProperty:ml,getOwnPropertyDescriptor:ea,getOwnPropertyNames:vl,getOwnPropertySymbols:yl,getPrototypeOf:ta}=Object,se=globalThis;let le;const na=se.trustedTypes,bl=na?na.emptyScript:"",mo=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&&mo===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}))},at=(e,t)=>e,on={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}},Gs=(e,t)=>!gl(e,t),sa={attribute:!0,type:String,converter:on,reflect:!1,useDefault:!1,hasChanged:Gs};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=sa){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}=ea(this.prototype,t)??{get(){return this[n]},set(o){this[n]=o}};if(i==null){if("value"in(ea(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 r=i?.call(this);a?.call(this,o),this.requestUpdate(t,r,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??sa}static __prepare(){if(this.hasOwnProperty(at("elementProperties")))return;const t=ta(this);t.finalize(),t._initializers!==void 0&&(this._initializers=[...t._initializers]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(at("finalized")))return;if(this.finalized=!0,this.__prepare(),this.hasOwnProperty(at("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(Xi(i))}else t!==void 0&&n.push(Xi(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 r=(i.converter?.toAttribute!==void 0?i.converter:on).toAttribute(n,i.type);this.constructor.enabledWarnings.includes("migration")&&r===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,r==null?this.removeAttribute(a):this.setAttribute(a,r),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:on;this.__reflectingProperty=i;const r=o.fromAttribute(n,a.type);this[i]=r??this.__defaultValues?.get(i)??r,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??Gs)(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 ta(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,r=this[i];o===!0&&!this._$changedProperties.has(i)&&r!==void 0&&this._$changeProperty(i,void 0,a,r)}}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[at("elementProperties")]=new Map;Se[at("finalized")]=new Map;mo?.({ReactiveElement:Se});{Se.enabledWarnings=["change-in-update","async-perform-update"];const e=function(t){t.hasOwnProperty(at("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,Et;te.litIssuedWarnings??=new Set,Et=(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(()=>{Et("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,rn=te.trustedTypes,ia=rn?rn.createPolicy("lit-html",{createHTML:e=>e}):void 0,xl=e=>e,gn=(e,t,n)=>xl,kl=e=>{if(je!==gn)throw new Error("Attempted to overwrite existing lit-html security policy. setSanitizeDOMValueFactory should be called at most once.");je=e},Sl=()=>{je=gn},bs=(e,t,n)=>je(e,t,n),vo="$lit$",ke=`lit$${Math.random().toFixed(9).slice(2)}$`,yo="?"+ke,Al=`<${yo}>`,He=document,Rt=()=>He.createComment(""),Mt=e=>e===null||typeof e!="object"&&typeof e!="function",Ys=Array.isArray,_l=e=>Ys(e)||typeof e?.[Symbol.iterator]=="function",Jn=`[
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
2
  \f\r]`,Tl=`[^
3
- \f\r"'\`<>=]`,Cl=`[^\\s"'>=/]`,mt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,aa=1,Zn=2,El=3,oa=/-->/g,ra=/>/g,De=new RegExp(`>|${Jn}(?:(${Cl}+)(${Jn}*=${Jn}*(?:${Tl}|("|')|))|$)`,"g"),Rl=0,la=1,Ml=2,ca=3,Xn=/'/g,es=/"/g,bo=/^(?:script|style|textarea|title)$/i,Il=1,ws=2,$s=3,Qs=1,ln=2,Ll=3,Pl=4,Nl=5,Js=6,Ol=7,Dl=e=>(t,...n)=>(t.some(s=>s===void 0)&&console.warn(`Some template strings are undefined.
4
- This is probably caused by illegal octal escape sequences.`),n.some(s=>s?._$litStatic$)&&Et("",`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}),c=Dl(Il),Ie=Symbol.for("lit-noChange"),g=Symbol.for("lit-nothing"),da=new WeakMap,Ke=He.createTreeWalker(He,129);let je=gn;function wo(e,t){if(!Ys(e)||!e.hasOwnProperty("raw")){let n="invalid template strings array";throw n=`
3
+ \f\r"'\`<>=]`,Cl=`[^\\s"'>=/]`,vt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,oa=1,Xn=2,El=3,ra=/-->/g,la=/>/g,De=new RegExp(`>|${Zn}(?:(${Cl}+)(${Zn}*=${Zn}*(?:${Tl}|("|')|))|$)`,"g"),Rl=0,ca=1,Ml=2,da=3,es=/'/g,ts=/"/g,wo=/^(?:script|style|textarea|title)$/i,Il=1,$s=2,xs=3,Js=1,cn=2,Ll=3,Pl=4,Nl=5,Zs=6,Ol=7,Dl=e=>(t,...n)=>(t.some(s=>s===void 0)&&console.warn(`Some template strings are undefined.
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}),l=Dl(Il),Ie=Symbol.for("lit-noChange"),g=Symbol.for("lit-nothing"),ua=new WeakMap,Ke=He.createTreeWalker(He,129);let je=mn;function $o(e,t){if(!Qs(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 ia!==void 0?ia.createHTML(t):t}const Bl=(e,t)=>{const n=e.length-1,s=[];let i=t===ws?"<svg>":t===$s?"<math>":"",a,o=mt;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===mt){if(m[aa]==="!--")o=oa;else if(m[aa]!==void 0)o=ra;else if(m[Zn]!==void 0)bo.test(m[Zn])&&(a=new RegExp(`</${m[Zn]}`,"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??mt,d=-1):m[la]===void 0?d=-2:(d=o.lastIndex-m[Ml].length,p=m[la],o=m[ca]===void 0?De:m[ca]==='"'?es:Xn):o===es||o===Xn?o=De:o===oa||o===ra?o=mt:(o=De,a=void 0);console.assert(d===-1||o===De||o===Xn||o===es,"unexpected parse state B");const v=o===De&&e[l+1].startsWith("/>")?" ":"";i+=o===mt?u+Al:d>=0?(s.push(p),u.slice(0,d)+vo+u.slice(d)+ke+v):u+ke+(d===-2?l:v)}const r=i+(e[n]||"<?>")+(t===ws?"</svg>":t===$s?"</math>":"");return[wo(e,r),s]};class It{constructor({strings:t,["_$litType$"]:n},s){this.parts=[];let i,a=0,o=0;const r=t.length-1,l=this.parts,[u,d]=Bl(t,n);if(this.el=It.createElement(u,s),Ke.currentNode=this.el.content,n===ws||n===$s){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=Ke.nextNode())!==null&&l.length<r;){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);Et("",f)}}if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(vo)){const f=d[o++],v=i.getAttribute(p).split(ke),$=/([.?@])?(.*)/.exec(f);l.push({type:Qs,index:a,name:$[2],strings:v,ctor:$[1]==="."?Ul:$[1]==="?"?Kl:$[1]==="@"?zl:vn}),i.removeAttribute(p)}else p.startsWith(ke)&&(l.push({type:Js,index:a}),i.removeAttribute(p));if(bo.test(i.tagName)){const p=i.textContent.split(ke),f=p.length-1;if(f>0){i.textContent=rn?rn.emptyScript:"";for(let m=0;m<f;m++)i.append(p[m],Rt()),Ke.nextNode(),l.push({type:ln,index:++a});i.append(p[f],Rt())}}}else if(i.nodeType===8)if(i.data===yo)l.push({type:ln,index:a});else{let f=-1;for(;(f=i.data.indexOf(ke,f+1))!==-1;)l.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 ot(e,t,n=e,s){if(t===Ie)return t;let i=s!==void 0?n.__directives?.[s]:n.__directive;const a=Mt(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=ot(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,r=0,l=s[0];for(;l!==void 0;){if(o===l.index){let u;l.type===ln?u=new mn(a,a.nextSibling,this,t):l.type===Qs?u=new l.ctor(a,l.name,l.strings,this,t):l.type===Js&&(u=new Hl(a,this,t)),this._$parts.push(u),l=s[++r]}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 mn=class $o{get _$isConnected(){return this._$parent?._$isConnected??this.__isConnected}constructor(t,n,s,i){this.type=ln,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=ot(this,t,n),Mt(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!==gn){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&&Mt(this._$committedValue)){const n=re(this._$startNode).nextSibling;this._textSanitizer===void 0&&(this._textSanitizer=bs(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=bs(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=It.createElement(wo(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=da.get(t.strings);return n===void 0&&da.set(t.strings,n=new It(t)),n}_commitIterable(t){Ys(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 $o(this._insert(Rt()),this._insert(Rt()),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 vn{get tagName(){return this.element.tagName}get _$isConnected(){return this._$parent._$isConnected}constructor(t,n,s,i,a){this.type=Qs,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=ot(this,t,n,0),o=!Mt(t)||t!==this._$committedValue&&t!==Ie,o&&(this._$committedValue=t);else{const r=t;t=a[0];let l,u;for(l=0;l<a.length-1;l++)u=ot(this,r[s+l],n,l),u===Ie&&(u=this._$committedValue[l]),o||=!Mt(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 Ul extends vn{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 vn{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 vn{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=ot(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=Js,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}),ot(this,t)}}const jl={_ChildPart:mn},Vl=te.litHtmlPolyfillSupportDevMode;Vl?.(It,mn);(te.litHtmlVersions??=[]).push("3.3.2");te.litHtmlVersions.length>1&&queueMicrotask(()=>{Et("multiple-versions","Multiple versions of Lit loaded. Loading multiple versions is not recommended.")});const nn=(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 mn(t.insertBefore(Rt(),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};nn.setSanitizer=kl,nn.createSanitizer=bs,nn._testOnlyClearSanitizerFactoryDoNotCallOrElse=Sl;const Wl=(e,t)=>e,Ee=globalThis;let xo;Ee.litIssuedWarnings??=new Set,xo=(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 ut 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=nn(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this.__childPart?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this.__childPart?.setConnected(!1)}render(){return Ie}}ut._$litElement$=!0;ut[Wl("finalized")]=!0;Ee.litElementHydrateSupport?.({LitElement:ut});const ql=Ee.litElementPolyfillSupportDevMode;ql?.({LitElement:ut});(Ee.litElementVersions??=[]).push("4.2.2");Ee.litElementVersions.length>1&&queueMicrotask(()=>{xo("multiple-versions","Multiple versions of Lit loaded. Loading multiple versions is not recommended.")});const ko=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};let So;globalThis.litIssuedWarnings??=new Set,So=(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:on,reflect:!1,hasChanged:Gs},Ql=(e=Yl,t,n)=>{const{kind:s,metadata:i}=n;i==null&&So("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(r){const l=t.get.call(this);t.set.call(this,r),this.requestUpdate(o,l,e,!0,r)},init(r){return r!==void 0&&this._$changeProperty(o,void 0,e,r),r}}}else if(s==="setter"){const{name:o}=n;return function(r){const l=this[o];t.call(this,r),this.requestUpdate(o,l,e,!0,r)}}throw new Error(`Unsupported decorator location: ${s}`)};function yn(e){return(t,n)=>typeof n=="object"?Ql(e,t,n):Gl(e,t,n)}function w(e){return yn({...e,state:!0,attribute:!1})}globalThis.litIssuedWarnings??=new Set;const Jl=50,Zl=200,Xl="Assistant";function ua(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function xs(e){const t=ua(e?.name,Jl)??Xl,n=ua(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 xs(typeof window>"u"?{}:{name:window.__CLAWDBOT_ASSISTANT_NAME__,avatar:window.__CLAWDBOT_ASSISTANT_AVATAR__})}const Ao="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(Ao);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(Ao,JSON.stringify(e))}function _o(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:"Settings",tabs:["config","debug","logs"]}],To={overview:"/overview",channels:"/channels",instances:"/instances",sessions:"/sessions",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",config:"/config",debug:"/debug",logs:"/logs"},Co=new Map(Object.entries(To).map(([e,t])=>[t,e]));function bn(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function Lt(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 wn(e,t=""){const n=bn(t),s=To[e];return n?`${n}${s}`:s}function Eo(e,t=""){const n=bn(t);let s=e||"/";n&&(s===n?s="/":s.startsWith(`${n}/`)&&(s=s.slice(n.length)));let i=Lt(s).toLowerCase();return i.endsWith("/index.html")&&(i="/"),i==="/"?"chat":Co.get(i)??null}function ic(e){let t=Lt(e);if(t.endsWith("/index.html")&&(t=Lt(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(Co.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"config":return"settings";case"debug":return"bug";case"logs":return"scrollText";default:return"folder"}}function ks(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"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"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:c`<svg viewBox="0 0 24 24"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,barChart:c`<svg viewBox="0 0 24 24"><line x1="12" x2="12" y1="20" y2="10"/><line x1="18" x2="18" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="16"/></svg>`,link:c`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,radio:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="2"/><path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"/></svg>`,fileText:c`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><line x1="16" x2="8" y1="13" y2="13"/><line x1="16" x2="8" y1="17" y2="17"/><line x1="10" x2="8" y1="9" y2="9"/></svg>`,zap:c`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:c`<svg viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>`,settings:c`<svg viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>`,bug:c`<svg viewBox="0 0 24 24"><path d="m8 2 1.88 1.88"/><path d="M14.12 3.88 16 2"/><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9"/><path d="M6.53 9C4.6 8.8 3 7.1 3 5"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="M22 13h-4"/><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"/></svg>`,scrollText:c`<svg viewBox="0 0 24 24"><path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M15 8h-5"/><path d="M15 12h-5"/></svg>`,folder:c`<svg viewBox="0 0 24 24"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>`,menu:c`<svg viewBox="0 0 24 24"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>`,x:c`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:c`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:c`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,search:c`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:c`<svg viewBox="0 0 24 24"><path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/><path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/><path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/><path d="M17.599 6.5a3 3 0 0 0 .399-1.375"/><path d="M6.003 5.125A3 3 0 0 0 6.401 6.5"/><path d="M3.477 10.896a4 4 0 0 1 .585-.396"/><path d="M19.938 10.5a4 4 0 0 1 .585.396"/><path d="M6 18a4 4 0 0 1-1.967-.516"/><path d="M19.967 17.484A4 4 0 0 1 18 18"/></svg>`,book:c`<svg viewBox="0 0 24 24"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/></svg>`,loader:c`<svg viewBox="0 0 24 24"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>`,wrench:c`<svg viewBox="0 0 24 24"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>`,fileCode:c`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><path d="m10 13-2 2 2 2"/><path d="m14 17 2-2-2-2"/></svg>`,edit:c`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,penLine:c`<svg viewBox="0 0 24 24"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>`,paperclip:c`<svg viewBox="0 0 24 24"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`,globe:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>`,eye:c`<svg viewBox="0 0 24 24"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`,eyeOff:c`<svg viewBox="0 0 24 24"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,image:c`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>`,smartphone:c`<svg viewBox="0 0 24 24"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>`,shield:c`<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:c`<svg viewBox="0 0 24 24"><path d="M12 22v-5"/><path d="M9 8V2"/><path d="M15 8V2"/><path d="M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z"/></svg>`,circle:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,puzzle:c`<svg viewBox="0 0 24 24"><path d="M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.076.874.54 1.02 1.02a2.5 2.5 0 1 0 3.237-3.237c-.48-.146-.944-.505-1.02-1.02a.98.98 0 0 1 .303-.917l1.526-1.526A2.402 2.402 0 0 1 11.998 2c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.236 3.236c-.464.18-.894.527-.967 1.02Z"/></svg>`},rc=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,qt=/<\s*\/?\s*final\b[^<>]*>/gi,pa=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^<>]*>/gi;function ha(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 fa(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(qt.test(n)){qt.lastIndex=0;const r=[],l=ha(n);for(const u of n.matchAll(qt)){const d=u.index??0;r.push({start:d,length:u[0].length,inCode:fa(d,l)})}for(let u=r.length-1;u>=0;u--){const d=r[u];d.inCode||(n=n.slice(0,d.start)+n.slice(d.start+d.length))}}else qt.lastIndex=0;const s=ha(n);pa.lastIndex=0;let i="",a=0,o=!1;for(const r of n.matchAll(pa)){const l=r.index??0,u=r[1]==="/";fa(l,s)||(o?u&&(o=!1):(i+=n.slice(a,l),u||(o=!0)),a=l+r[0].length)}return i+=n.slice(a),lc(i)}function Pt(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString()}function B(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 $n=B;function Ro(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 Ss(e){return!e||e.length===0?"none":e.filter(t=>!!(t&&t.trim())).join(", ")}function As(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 cn(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function ts(e){return cc(e)}const dc=/^\[([^\]]+)\]\s*/,uc=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],ns=new WeakMap,ss=new WeakMap;function pc(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:uc.some(t=>e.startsWith(`${t} `))}function is(e){const t=e.match(dc);if(!t)return e;const n=t[1]??"";return pc(n)?e.slice(t[0].length):e}function _s(e){const t=e,n=typeof t.role=="string"?t.role:"",s=t.content;if(typeof s=="string")return n==="assistant"?ts(s):is(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"?ts(a):is(a)}}return typeof t.text=="string"?n==="assistant"?ts(t.text):is(t.text):null}function Io(e){if(!e||typeof e!="object")return _s(e);const t=e;if(ns.has(t))return ns.get(t)??null;const n=_s(e);return ns.set(t,n),n}function ga(e){const n=e.content,s=[];if(Array.isArray(n))for(const r of n){const l=r;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=fc(e);if(!i)return null;const o=[...i.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(r=>(r[1]??"").trim()).filter(Boolean);return o.length>0?o.join(`
19
- `):null}function hc(e){if(!e||typeof e!="object")return ga(e);const t=e;if(ss.has(t))return ss.get(t)??null;const n=ga(e);return ss.set(t,n),n}function fc(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 gc(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 ma=!1;function va(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 mc(){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 vc(){ma||(ma=!0,console.warn("[uuid] crypto API missing; falling back to weak randomness"))}function Zs(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),va(t)}return vc(),va(mc())}async function rt(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 yc(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function bc(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 r=Zs();e.chatRunId=r,e.chatStream="",e.chatStreamStartedAt=a;const l=i?n.map(u=>{const d=yc(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:r,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 wc(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=_s(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 pt(e){if(!(!e.client||!e.connected)&&!e.sessionsLoading){e.sessionsLoading=!0,e.sessionsError=null;try{const t={includeGlobal:e.sessionsIncludeGlobal,includeUnknown:e.sessionsIncludeUnknown},n=cn(e.sessionsFilterActive,0),s=cn(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 xc(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 pt(e)}catch(i){e.sessionsError=String(i)}}async function kc(e,t){if(!(!e.client||!e.connected||e.sessionsLoading||!window.confirm(`Delete session "${t}"?
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 Io(e){if(!e||typeof e!="object")return Ts(e);const t=e;if(ss.has(t))return ss.get(t)??null;const n=Ts(e);return ss.set(t,n),n}function ma(e){const n=e.content,s=[];if(Array.isArray(n))for(const c of n){const r=c;if(r.type==="thinking"&&typeof r.thinking=="string"){const u=r.thinking.trim();u&&s.push(u)}}if(s.length>0)return s.join(`
18
+ `);const i=gc(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 fc(e){if(!e||typeof e!="object")return ma(e);const t=e;if(is.has(t))return is.get(t)??null;const n=ma(e);return is.set(t,n),n}function gc(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 mc(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 va=!1;function ya(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 vc(){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 yc(){va||(va=!0,console.warn("[uuid] crypto API missing; falling back to weak randomness"))}function Xs(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),ya(t)}return yc(),ya(vc())}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 bc(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function wc(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=Xs();e.chatRunId=c,e.chatStream="",e.chatStreamStartedAt=a;const r=i?n.map(u=>{const d=bc(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:r}),!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 $c(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 xc(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=Ts(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 kc(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 Sc(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 pt(e)}catch(s){e.sessionsError=String(s)}finally{e.sessionsLoading=!1}}}const ya=50,Sc=80,Ac=12e4;function _c(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 ba(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=_c(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=Mo(n,Ac);return s.truncated?`${s.text}
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 ba=50,Ac=80,_c=12e4;function Tc(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 wa(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Tc(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=Mo(n,_c);return s.truncated?`${s.text}
25
25
 
26
- … truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function Tc(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 Cc(e){if(e.toolStreamOrder.length<=ya)return;const t=e.toolStreamOrder.length-ya,n=e.toolStreamOrder.splice(0,t);for(const s of n)e.toolStreamById.delete(s)}function Ec(e){e.chatToolMessages=e.toolStreamOrder.map(t=>e.toolStreamById.get(t)?.message).filter(t=>!!t)}function Ts(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),Ec(e)}function Rc(e,t=!1){if(t){Ts(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>Ts(e),Sc))}function xn(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],Ts(e)}const Mc=5e3;function Ic(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},Mc))}function Lc(e,t){if(!t)return;if(t.stream==="compaction"){Ic(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:"",r=o==="start"?s.args:void 0,l=o==="update"?ba(s.partialResult):o==="result"?ba(s.result):void 0,u=Date.now();let d=e.toolStreamById.get(i);d?(d.name=a,r!==void 0&&(d.args=r),l!==void 0&&(d.output=l),d.updatedAt=u):(d={toolCallId:i,runId:t.runId,sessionKey:n,name:a,args:r,output:l,startedAt:typeof t.ts=="number"?t.ts:u,updatedAt:u,message:{}},e.toolStreamById.set(i,d),e.toolStreamOrder.push(i)),d.message=Tc(d),Cc(e),Rc(e,o==="result")}function kn(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 r=n();if(!r)return;const l=r.scrollHeight-r.scrollTop-r.clientHeight;(t||e.chatUserNearBottom||l<200)&&(r.scrollTop=r.scrollHeight,e.chatUserNearBottom=!0)},o)})})}function Lo(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 Pc(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=s<200}function Nc(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.logsAtBottom=s<80}function Oc(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function Dc(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
26
+ … truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function Cc(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 Ec(e){if(e.toolStreamOrder.length<=ba)return;const t=e.toolStreamOrder.length-ba,n=e.toolStreamOrder.splice(0,t);for(const s of n)e.toolStreamById.delete(s)}function Rc(e){e.chatToolMessages=e.toolStreamOrder.map(t=>e.toolStreamById.get(t)?.message).filter(t=>!!t)}function Cs(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),Rc(e)}function Mc(e,t=!1){if(t){Cs(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>Cs(e),Ac))}function kn(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],Cs(e)}const Ic=5e3;function Lc(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},Ic))}function Pc(e,t){if(!t)return;if(t.stream==="compaction"){Lc(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,r=o==="update"?wa(s.partialResult):o==="result"?wa(s.result):void 0,u=Date.now();let d=e.toolStreamById.get(i);d?(d.name=a,c!==void 0&&(d.args=c),r!==void 0&&(d.output=r),d.updatedAt=u):(d={toolCallId:i,runId:t.runId,sessionKey:n,name:a,args:c,output:r,startedAt:typeof t.ts=="number"?t.ts:u,updatedAt:u,message:{}},e.toolStreamById.set(i,d),e.toolStreamOrder.push(i)),d.message=Cc(d),Ec(e),Mc(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 r=c.scrollHeight-c.scrollTop-c.clientHeight;(t||e.chatUserNearBottom||r<200)&&(c.scrollTop=c.scrollHeight,e.chatUserNearBottom=!0)},o)})})}function Lo(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 Nc(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=s<200}function Oc(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.logsAtBottom=s<80}function Dc(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function Bc(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 Bc(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 lt(e){return`${JSON.stringify(e,null,2).trimEnd()}
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],r=t[a+1];if(typeof o=="number"){if(!Array.isArray(s))return;s[o]==null&&(s[o]=typeof r=="number"?[]:{}),s=s[o]}else{if(typeof s!="object"||s==null)return;const l=s;l[o]==null&&(l[o]=typeof r=="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 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",{});Uc(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",{});Fc(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function Fc(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function Uc(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?lt(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=lt(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 Cs(e){if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?lt(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 Kc(e){if(!(!e.client||!e.connected)){e.configApplying=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?lt(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 zc(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 Gt(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=lt(s))}function wa(e,t){const n=Ve(e.configForm??e.configSnapshot?.config??{});No(n,t),e.configForm=n,e.configFormDirty=!0,e.configFormMode==="form"&&(e.configRaw=lt(n))}async function Dt(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 Sn(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 Hc(e){if(e.scheduleKind==="at"){const n=Date.parse(e.scheduleAt);if(!Number.isFinite(n))throw new Error("Invalid run time.");return{kind:"at",atMs:n}}if(e.scheduleKind==="every"){const n=cn(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 jc(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=cn(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function Vc(e){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const t=Hc(e.cronForm),n=jc(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 Sn(e),await Dt(e)}catch(t){e.cronError=String(t)}finally{e.cronBusy=!1}}}async function Wc(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 Sn(e),await Dt(e)}catch(s){e.cronError=String(s)}finally{e.cronBusy=!1}}}async function qc(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 Gc(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 Sn(e),await Dt(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 Yc(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 Qc(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 Jc(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 An(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 Zc(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 Xc=2e3,ed=new Set(["trace","debug","info","warn","error","fatal"]);function td(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 nd(e){if(typeof e!="string")return null;const t=e.toLowerCase();return ed.has(t)?t:null}function sd(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=nd(n?.logLevelName??n?.level),a=typeof t[0]=="string"?t[0]:typeof n?.name=="string"?n?.name:null,o=td(a);let r=null;o&&(typeof o.subsystem=="string"?r=o.subsystem:typeof o.module=="string"&&(r=o.module)),!r&&a&&a.length<120&&(r=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:r,message:l??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Xs(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(r=>typeof r=="string"):[]).map(sd),o=!!(t?.reset||s.reset||e.logsCursor==null);e.logsEntries=o?a:[...e.logsEntries,...a].slice(-Xc),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:sn,Gx:$a,Gy:xa,a:as,d:os,h:id}=Bo,We=32,ei=64,ad=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},H=(e="")=>{const t=new Error(e);throw ad(t,H),t},od=e=>typeof e=="bigint",rd=e=>typeof e=="string",ld=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",Le=(e,t,n="")=>{const s=ld(e),i=e?.length,a=t!==void 0;if(!s||a&&i!==t){const o=n&&`"${n}" `,r=a?` of length ${t}`:"",l=s?`length=${i}`:`type=${typeof e}`;H(o+"expected Uint8Array"+r+", got "+l)}return e},_n=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},ka=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(!rd(e))return H(t);const n=e.length,s=n/2;if(n%2)return H(t);const i=_n(s);for(let a=0,o=0;a<s;a++,o+=2){const r=ka(e.charCodeAt(o)),l=ka(e.charCodeAt(o+1));if(r===void 0||l===void 0)return H(t);i[a]=r*16+l}return i},Ho=()=>globalThis?.crypto,cd=()=>Ho()?.subtle??H("crypto.subtle must be defined, consider polyfill"),Nt=(...e)=>{const t=_n(e.reduce((s,i)=>s+Le(i).length,0));let n=0;return e.forEach(s=>{t.set(s,n),n+=s.length}),t},dd=(e=We)=>Ho().getRandomValues(_n(e)),dn=BigInt,Ue=(e,t,n,s="bad number: out of range")=>od(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,sn),ud=(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,r=s%n,l=i-a*o;s=n,n=r,i=a,a=l}return s===1n?S(i,t):H("no inverse")},pd=e=>{const t=Go[e];return typeof t!="function"&&H("hashes."+e+" not set"),t},rs=e=>e instanceof ne?e:H("Point expected"),Es=2n**256n;class ne{static BASE;static ZERO;X;Y;Z;T;constructor(t,n,s,i){const a=Es;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=os,i=Fo(Le(t,We)),a=t[31];i[31]=a&-129;const o=Wo(i);Ue(o,0n,n?Es:q);const l=S(o*o),u=S(l-1n),d=S(s*l+1n);let{isValid:p,value:f}=fd(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=as,n=os,s=this;if(s.is0())return H("bad point: ZERO");const{X:i,Y:a,Z:o,T:r}=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*r);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:r}=rs(t),l=S(n*r),u=S(a*i),d=S(s*r),p=S(o*i);return l===u&&d===p}is0(){return this.equals(it)}negate(){return new ne(S(-this.X),this.Y,this.Z,S(-this.T))}double(){const{X:t,Y:n,Z:s}=this,i=as,a=S(t*t),o=S(n*n),r=S(2n*S(s*s)),l=S(i*a),u=t+n,d=S(S(u*u)-a-o),p=l+o,f=p-r,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:r,Z:l,T:u}=rs(t),d=as,p=os,f=S(n*o),m=S(s*r),v=S(a*p*u),$=S(i*l),k=S((n+s)*(o+r)-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(rs(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return it;if(Ue(t,1n,sn),t===1n)return this;if(this.equals(qe))return Ad(t).p;let s=it,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(it))return{x:0n,y:1n};const i=ud(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(dn(id),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(sn/2n,!1).double();return sn%2n&&(t=t.add(this)),t.is0()}}const qe=new ne($a,xa,1n,S($a*xa)),it=new ne(0n,1n,1n,0n);ne.BASE=qe;ne.ZERO=it;const Vo=e=>zo(Uo(Ue(e,0n,Es),ei)).reverse(),Wo=e=>dn("0x"+Ko(Fo(Le(e)).reverse())),fe=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=q;return n},hd=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,r=fe(o,20n)*o%q,l=fe(r,40n)*r%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}},Sa=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,fd=(e,t)=>{const n=S(t*t*t),s=S(n*n*t),i=hd(e*s).pow_p_5_8;let a=S(e*n*i);const o=S(t*a*a),r=a,l=S(a*Sa),u=o===e,d=o===S(-e),p=o===S(-e*Sa);return u&&(a=r),(d||p)&&(a=l),(S(a)&1n)===1n&&(a=S(-a)),{isValid:u||d,value:a}},Rs=e=>jo(Wo(e)),ti=(...e)=>Go.sha512Async(Nt(...e)),gd=(...e)=>pd("sha512")(Nt(...e)),qo=e=>{const t=e.slice(0,We);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(We,ei),s=Rs(t),i=qe.multiply(s),a=i.toBytes();return{head:t,prefix:n,scalar:s,point:i,pointBytes:a}},ni=e=>ti(Le(e,We)).then(qo),md=e=>qo(gd(Le(e,We))),vd=e=>ni(e).then(t=>t.pointBytes),yd=e=>ti(e.hashable).then(e.finish),bd=(e,t,n)=>{const{pointBytes:s,scalar:i}=e,a=Rs(t),o=qe.multiply(a).toBytes();return{hashable:Nt(o,s,n),finish:u=>{const d=jo(a+Rs(u)*i);return Le(Nt(o,Vo(d)),ei)}}},wd=async(e,t)=>{const n=Le(e),s=await ni(t),i=await ti(s.prefix,n);return yd(bd(s,i,n))},Go={sha512Async:async e=>{const t=cd(),n=Nt(e);return _n(await t.digest("SHA-512",n.buffer))},sha512:void 0},$d=(e=dd(We))=>e,xd={getExtendedPublicKeyAsync:ni,getExtendedPublicKey:md,randomSecretKey:$d},un=8,kd=256,Yo=Math.ceil(kd/un)+1,Ms=2**(un-1),Sd=()=>{const e=[];let t=qe,n=t;for(let s=0;s<Yo;s++){n=t,e.push(n);for(let i=1;i<Ms;i++)n=n.add(t),e.push(n);t=n.double()}return e};let Aa;const _a=(e,t)=>{const n=t.negate();return e?n:t},Ad=e=>{const t=Aa||(Aa=Sd());let n=it,s=qe;const i=2**un,a=i,o=dn(i-1),r=dn(un);for(let l=0;l<Yo;l++){let u=Number(e&o);e>>=r,u>Ms&&(u-=a,e+=1n);const d=l*Ms,p=d,f=d+Math.abs(u)-1,m=l%2!==0,v=u<0;u===0?s=s.add(_a(m,t[p])):n=n.add(_a(v,t[f]))}return e!==0n&&H("invalid wnaf"),{p:n,f:s}},ls="poolbot-device-identity-v1";function Is(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 _d(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 _d(new Uint8Array(t))}async function Td(){const e=xd.randomSecretKey(),t=await vd(e);return{deviceId:await Jo(t),publicKey:Is(t),privateKey:Is(e)}}async function si(){try{const n=localStorage.getItem(ls);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(ls,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 Td(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(ls,JSON.stringify(t)),e}async function Cd(e,t){const n=Qo(e),s=new TextEncoder().encode(t),i=await wd(s,n);return Is(i)}const Zo="poolbot.device.auth.v1";function ii(e){return e.trim()}function Ed(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 ai(){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 Rd(e){const t=ai();if(!t||t.deviceId!==e.deviceId)return null;const n=ii(e.role),s=t.tokens[n];return!s||typeof s.token!="string"?null:s}function er(e){const t=ii(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},s=ai();s&&s.deviceId===e.deviceId&&(n.tokens={...s.tokens});const i={token:e.token,role:t,scopes:Ed(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=i,Xo(n),i}function tr(e){const t=ai();if(!t||t.deviceId!==e.deviceId)return;const n=ii(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 Md(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 Id(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 Ld(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("device.token.rotate",t);if(n?.token){const s=await si(),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 Pd(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 si();t.deviceId===s.deviceId&&tr({deviceId:s.deviceId,role:t.role}),await Pe(e)}catch(s){e.devicesError=String(s)}}async function Tn(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 Nd(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 Od(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 oi(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=Nd(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const s=await e.client.request(n.method,n.params);Dd(e,s)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function Dd(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=Ve(t.file??{}))}async function Bd(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=Od(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 oi(e,t)}catch(n){e.lastError=String(n)}finally{e.execApprovalsSaving=!1}}}function Fd(e,t,n){const s=Ve(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});Po(s,t,n),e.execApprovalsForm=s,e.execApprovalsDirty=!0}function Ud(e,t){const n=Ve(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});No(n,t),e.execApprovalsForm=n,e.execApprovalsDirty=!0}async function ri(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 ct(e,t,n){if(!t.trim())return;const s={...e.skillMessages};n?s[t]=n:delete s[t],e.skillMessages=s}function Cn(e){return e instanceof Error?e.message:String(e)}async function Bt(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=Cn(n)}finally{e.skillsLoading=!1}}}function Kd(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function zd(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 Bt(e),ct(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(s){const i=Cn(s);e.skillsError=i,ct(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Hd(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 Bt(e),ct(e,t,{kind:"success",message:"API key saved"})}catch(n){const s=Cn(n);e.skillsError=s,ct(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function jd(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 Bt(e),ct(e,t,{kind:"success",message:i?.message??"Installed"})}catch(i){const a=Cn(i);e.skillsError=a,ct(e,t,{kind:"error",message:a})}finally{e.skillsBusyKey=null}}}function Vd(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function li(e){return e==="system"?Vd():e}const Yt=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,Wd=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Qt=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},qd=({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,r=Wd();if(!!o.startViewTransition&&!r){let u=.5,d=.5;if(n?.pointerClientX!==void 0&&n?.pointerClientY!==void 0&&typeof window<"u")u=Yt(n.pointerClientX/window.innerWidth),d=Yt(n.pointerClientY/window.innerHeight);else if(n?.element){const p=n.element.getBoundingClientRect();p.width>0&&p.height>0&&typeof window<"u"&&(u=Yt((p.left+p.width/2)/window.innerWidth),d=Yt((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(()=>Qt(a)):Qt(a)}catch{Qt(a),t()}return}t(),Qt(a)};function Gd(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{Tn(e,{quiet:!0})},5e3))}function Yd(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function ci(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Xs(e,{quiet:!0})},2e3))}function di(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function ui(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&An(e)},3e3))}function pi(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,En(e,li(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 Qd(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 r=new URL(window.location.href);r.search=t.toString(),window.history.replaceState({},"",r.toString())}function Jd(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?ci(e):di(e),t==="debug"?ui(e):pi(e),hi(e),ir(e,t,!1)}function Zd(e,t,n){qd({nextTheme:t,applyTheme:()=>{e.theme=t,Re(e,{...e.settings,theme:t}),En(e,li(t))},context:n,currentTheme:e.theme})}async function hi(e){e.tab==="overview"&&await ar(e),e.tab==="channels"&&await ou(e),e.tab==="instances"&&await ri(e),e.tab==="sessions"&&await pt(e),e.tab==="cron"&&await fi(e),e.tab==="skills"&&await Bt(e),e.tab==="nodes"&&(await Tn(e),await Pe(e),await Ae(e),await oi(e)),e.tab==="chat"&&(await uu(e),kn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await Oo(e),await Ae(e)),e.tab==="debug"&&(await An(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"&&(e.logsAtBottom=!0,await Xs(e,{reset:!0}),Lo(e,!0))}function Xd(){if(typeof window>"u")return"";const e=window.__CLAWDBOT_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?bn(e):ic(window.location.pathname)}function eu(e){e.theme=e.settings.theme??"system",En(e,li(e.theme))}function En(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function tu(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"&&En(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function nu(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 su(e,t){if(typeof window>"u")return;const n=Eo(window.location.pathname,e.basePath)??"chat";sr(e,n),ir(e,n,t)}function iu(e){if(typeof window>"u")return;const t=Eo(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"?ci(e):di(e),t==="debug"?ui(e):pi(e),e.connected&&hi(e)}function ir(e,t,n){if(typeof window>"u")return;const s=Lt(wn(t,e.basePath)),i=Lt(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 au(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),ri(e),pt(e),Dt(e),An(e)])}async function ou(e){await Promise.all([ue(e,!0),Oo(e),Ae(e)])}async function fi(e){await Promise.all([ue(e,!1),Dt(e),Sn(e)])}function or(e){return e.chatSending||!!e.chatRunId}function ru(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 wc(e))}function lu(e,t,n){const s=t.trim(),i=!!(n&&n.length>0);!s&&!i||(e.chatQueue=[...e.chatQueue,{id:Zs(),text:s,createdAt:Date.now(),attachments:i?n?.map(a=>({...a})):void 0}])}async function lr(e,t,n){xn(e);const s=await bc(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),kn(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 cu(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function du(e,t,n){if(!e.connected)return;const s=e.chatMessage,i=(t??e.chatMessage).trim(),a=e.chatAttachments??[],o=t==null?a:[],r=o.length>0;if(!(!i&&!r)){if(ru(i)){await rr(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),or(e)){lu(e,i,o);return}await lr(e,i,{previousDraft:t==null?s:void 0,restoreDraft:!!(t&&n?.restoreDraft),attachments:r?o:void 0,previousAttachments:t==null?a:void 0,restoreAttachments:!!(t&&n?.restoreDraft)})}}async function uu(e){await Promise.all([rt(e),pt(e),Ls(e)]),kn(e,!0)}const pu=cr;function hu(e){const t=_o(e.sessionKey);return t?.agentId?t.agentId:e.hello?.snapshot?.sessionDefaults?.defaultAgentId?.trim()||"main"}function fu(e,t){const n=bn(e),s=encodeURIComponent(t);return n?`${n}/avatar/${s}?meta=1`:`/avatar/${s}?meta=1`}async function Ls(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=hu(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=fu(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:gu}=jl,st=window.ShadyDOM?.inUse&&window.ShadyDOM?.noPatch===!0?window.ShadyDOM.wrap:e=>e,Ta=()=>document.createComment(""),vt=(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(Ta(),i),o=st(s).insertBefore(Ta(),i);n=new gu(a,o,e,e.options)}else{const a=st(n._$endNode).nextSibling,o=n._$parent,r=o!==e;if(r){n._$reparentDisconnectables?.(e),n._$parent=e;let l;n._$notifyConnectionChanged!==void 0&&(l=e._$isConnected)!==o._$isConnected&&n._$notifyConnectionChanged(l)}if(a!==i||r){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),mu={},vu=(e,t=mu)=>e._$committedValue=t,yu=e=>e._$committedValue,cs=e=>{e._$clear(),e._$startNode.remove()};const Ca=(e,t,n)=>{const s=new Map;for(let i=t;i<=n;i++)s.set(e[i],i);return s};class bu 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 r=0;for(const l of t)a[r]=i?i(l,r):r,o[r]=s(l,r),r++;return{values:o,keys:a}}render(t,n,s){return this._getValuesAndKeys(t,n,s).values}update(t,[n,s,i]){const a=yu(t),{values:o,keys:r}=this._getValuesAndKeys(n,s,i);if(!Array.isArray(a))return this._itemKeys=r,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]===r[v])u[v]=Be(a[f],o[v]),f++,v++;else if(l[m]===r[$])u[$]=Be(a[m],o[$]),m--,$--;else if(l[f]===r[$])u[$]=Be(a[f],o[$]),vt(t,u[$+1],a[f]),f++,$--;else if(l[m]===r[v])u[v]=Be(a[m],o[v]),vt(t,a[f],a[m]),m--,v++;else if(d===void 0&&(d=Ca(r,v,$),p=Ca(l,f,m)),!d.has(l[f]))cs(a[f]),f++;else if(!d.has(l[m]))cs(a[m]),m--;else{const k=p.get(r[v]),_=k!==void 0?a[k]:null;if(_===null){const M=vt(t,a[f]);Be(M,o[v]),u[v]=M}else u[v]=Be(_,o[v]),vt(t,a[f],_),a[k]=null;v++}for(;v<=$;){const k=vt(t,u[$+1]);Be(k,o[v]),u[v++]=k}for(;f<=m;){const k=a[f++];k!==null&&cs(k)}return this._itemKeys=r,vu(t,u),Ie}}const hr=ur(bu);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"}),r=typeof t.toolName=="string"||typeof t.tool_name=="string";(s||o||r)&&(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 gi(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 wu=1;class mi 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:[]}}}mi.directiveName="unsafeHTML";mi.resultType=wu;const Ps=ur(mi);const{entries:mr,setPrototypeOf:Ea,isFrozen:$u,getPrototypeOf:xu,getOwnPropertyDescriptor:ku}=Object;let{freeze:Z,seal:ae,create:Ns}=Object,{apply:Os,construct:Ds}=typeof Reflect<"u"&&Reflect;Z||(Z=function(t){return t});ae||(ae=function(t){return t});Os||(Os=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)});Ds||(Ds=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 Jt=X(Array.prototype.forEach),Su=X(Array.prototype.lastIndexOf),Ra=X(Array.prototype.pop),yt=X(Array.prototype.push),Au=X(Array.prototype.splice),an=X(String.prototype.toLowerCase),ds=X(String.prototype.toString),us=X(String.prototype.match),bt=X(String.prototype.replace),_u=X(String.prototype.indexOf),Tu=X(String.prototype.trim),oe=X(Object.prototype.hasOwnProperty),Q=X(RegExp.prototype.test),wt=Cu(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 Os(e,t,s)}}function Cu(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return Ds(e,n)}}function I(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:an;Ea&&Ea(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 Eu(e){for(let t=0;t<e.length;t++)oe(e,t)||(e[t]=null);return e}function ge(e){const t=Ns(null);for(const[n,s]of mr(e))oe(e,n)&&(Array.isArray(s)?t[n]=Eu(s):s&&typeof s=="object"&&s.constructor===Object?t[n]=ge(s):t[n]=s);return t}function $t(e,t){for(;e!==null;){const s=ku(e,t);if(s){if(s.get)return X(s.get);if(typeof s.value=="function")return X(s.value)}e=xu(e)}function n(){return null}return n}const Ma=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"]),ps=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"]),hs=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"]),Ru=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"]),fs=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"]),Mu=Z(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ia=Z(["#text"]),La=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"]),gs=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"]),Pa=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"]),Zt=Z(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Iu=ae(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Lu=ae(/<%[\w\W]*|[\w\W]*%>/gm),Pu=ae(/\$\{[\w\W]*/gm),Nu=ae(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ou=ae(/^aria-[\-\w]+$/),vr=ae(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Du=ae(/^(?:\w+script|data):/i),Bu=ae(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),yr=ae(/^html$/i),Fu=ae(/^[a-z][.\w]*(-[.\w]+)+$/i);var Na=Object.freeze({__proto__:null,ARIA_ATTR:Ou,ATTR_WHITESPACE:Bu,CUSTOM_ELEMENT:Fu,DATA_ATTR:Nu,DOCTYPE_NAME:yr,ERB_EXPR:Lu,IS_ALLOWED_URI:vr,IS_SCRIPT_OR_DATA:Du,MUSTACHE_EXPR:Iu,TMPLIT_EXPR:Pu});const xt={element:1,text:3,progressingInstruction:7,comment:8,document:9},Uu=function(){return typeof window>"u"?null:window},Ku=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}},Oa=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function br(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Uu();const t=T=>br(T);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==xt.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const s=n,i=s.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:r,Element:l,NodeFilter:u,NamedNodeMap:d=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:f,trustedTypes:m}=e,v=l.prototype,$=$t(v,"cloneNode"),k=$t(v,"remove"),_=$t(v,"nextSibling"),M=$t(v,"childNodes"),N=$t(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:Pn,getElementsByTagName:Nn}=n,{importNode:Qr}=s;let Y=Oa();t.isSupported=typeof mr=="function"&&typeof N=="function"&&E&&E.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:On,ERB_EXPR:Dn,TMPLIT_EXPR:Bn,DATA_ATTR:Jr,ARIA_ATTR:Zr,IS_SCRIPT_OR_DATA:Xr,ATTR_WHITESPACE:Ci,CUSTOM_ELEMENT:el}=Na;let{IS_ALLOWED_URI:Ei}=Na,z=null;const Ri=I({},[...Ma,...ps,...hs,...fs,...Ia]);let j=null;const Mi=I({},[...La,...gs,...Pa,...Zt]);let F=Object.seal(Ns(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}})),ht=null,Fn=null;const Qe=Object.seal(Ns(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ii=!0,Un=!0,Li=!1,Pi=!0,Je=!1,Ut=!0,Ne=!1,Kn=!1,zn=!1,Ze=!1,Kt=!1,zt=!1,Ni=!0,Oi=!1;const tl="user-content-";let Hn=!0,ft=!1,Xe={},pe=null;const jn=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 Di=null;const Bi=I({},["audio","video","img","source","image","track"]);let Vn=null;const Fi=I({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ht="http://www.w3.org/1998/Math/MathML",jt="http://www.w3.org/2000/svg",ye="http://www.w3.org/1999/xhtml";let et=ye,Wn=!1,qn=null;const nl=I({},[Ht,jt,ye],ds);let Vt=I({},["mi","mo","mn","ms","mtext"]),Wt=I({},["annotation-xml"]);const sl=I({},["title","style","font","a","script"]);let gt=null;const il=["application/xhtml+xml","text/html"],al="text/html";let K=null,tt=null;const ol=n.createElement("form"),Ui=function(h){return h instanceof RegExp||h instanceof Function},Gn=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),gt=il.indexOf(h.PARSER_MEDIA_TYPE)===-1?al:h.PARSER_MEDIA_TYPE,K=gt==="application/xhtml+xml"?ds:an,z=oe(h,"ALLOWED_TAGS")?I({},h.ALLOWED_TAGS,K):Ri,j=oe(h,"ALLOWED_ATTR")?I({},h.ALLOWED_ATTR,K):Mi,qn=oe(h,"ALLOWED_NAMESPACES")?I({},h.ALLOWED_NAMESPACES,ds):nl,Vn=oe(h,"ADD_URI_SAFE_ATTR")?I(ge(Fi),h.ADD_URI_SAFE_ATTR,K):Fi,Di=oe(h,"ADD_DATA_URI_TAGS")?I(ge(Bi),h.ADD_DATA_URI_TAGS,K):Bi,pe=oe(h,"FORBID_CONTENTS")?I({},h.FORBID_CONTENTS,K):jn,ht=oe(h,"FORBID_TAGS")?I({},h.FORBID_TAGS,K):ge({}),Fn=oe(h,"FORBID_ATTR")?I({},h.FORBID_ATTR,K):ge({}),Xe=oe(h,"USE_PROFILES")?h.USE_PROFILES:!1,Ii=h.ALLOW_ARIA_ATTR!==!1,Un=h.ALLOW_DATA_ATTR!==!1,Li=h.ALLOW_UNKNOWN_PROTOCOLS||!1,Pi=h.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Je=h.SAFE_FOR_TEMPLATES||!1,Ut=h.SAFE_FOR_XML!==!1,Ne=h.WHOLE_DOCUMENT||!1,Ze=h.RETURN_DOM||!1,Kt=h.RETURN_DOM_FRAGMENT||!1,zt=h.RETURN_TRUSTED_TYPE||!1,zn=h.FORCE_BODY||!1,Ni=h.SANITIZE_DOM!==!1,Oi=h.SANITIZE_NAMED_PROPS||!1,Hn=h.KEEP_CONTENT!==!1,ft=h.IN_PLACE||!1,Ei=h.ALLOWED_URI_REGEXP||vr,et=h.NAMESPACE||ye,Vt=h.MATHML_TEXT_INTEGRATION_POINTS||Vt,Wt=h.HTML_INTEGRATION_POINTS||Wt,F=h.CUSTOM_ELEMENT_HANDLING||{},h.CUSTOM_ELEMENT_HANDLING&&Ui(h.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(F.tagNameCheck=h.CUSTOM_ELEMENT_HANDLING.tagNameCheck),h.CUSTOM_ELEMENT_HANDLING&&Ui(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&&(Un=!1),Kt&&(Ze=!0),Xe&&(z=I({},Ia),j=[],Xe.html===!0&&(I(z,Ma),I(j,La)),Xe.svg===!0&&(I(z,ps),I(j,gs),I(j,Zt)),Xe.svgFilters===!0&&(I(z,hs),I(j,gs),I(j,Zt)),Xe.mathMl===!0&&(I(z,fs),I(j,Pa),I(j,Zt))),h.ADD_TAGS&&(typeof h.ADD_TAGS=="function"?Qe.tagCheck=h.ADD_TAGS:(z===Ri&&(z=ge(z)),I(z,h.ADD_TAGS,K))),h.ADD_ATTR&&(typeof h.ADD_ATTR=="function"?Qe.attributeCheck=h.ADD_ATTR:(j===Mi&&(j=ge(j)),I(j,h.ADD_ATTR,K))),h.ADD_URI_SAFE_ATTR&&I(Vn,h.ADD_URI_SAFE_ATTR,K),h.FORBID_CONTENTS&&(pe===jn&&(pe=ge(pe)),I(pe,h.FORBID_CONTENTS,K)),h.ADD_FORBID_CONTENTS&&(pe===jn&&(pe=ge(pe)),I(pe,h.ADD_FORBID_CONTENTS,K)),Hn&&(z["#text"]=!0),Ne&&I(z,["html","head","body"]),z.table&&(I(z,["tbody"]),delete ht.tbody),h.TRUSTED_TYPES_POLICY){if(typeof h.TRUSTED_TYPES_POLICY.createHTML!="function")throw wt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof h.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw wt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');R=h.TRUSTED_TYPES_POLICY,C=R.createHTML("")}else R===void 0&&(R=Ku(m,i)),R!==null&&typeof C=="string"&&(C=R.createHTML(""));Z&&Z(h),tt=h}},Ki=I({},[...ps,...hs,...Ru]),zi=I({},[...fs,...Mu]),rl=function(h){let x=N(h);(!x||!x.tagName)&&(x={namespaceURI:et,tagName:"template"});const A=an(h.tagName),D=an(x.tagName);return qn[h.namespaceURI]?h.namespaceURI===jt?x.namespaceURI===ye?A==="svg":x.namespaceURI===Ht?A==="svg"&&(D==="annotation-xml"||Vt[D]):!!Ki[A]:h.namespaceURI===Ht?x.namespaceURI===ye?A==="math":x.namespaceURI===jt?A==="math"&&Wt[D]:!!zi[A]:h.namespaceURI===ye?x.namespaceURI===jt&&!Wt[D]||x.namespaceURI===Ht&&!Vt[D]?!1:!zi[A]&&(sl[A]||!Ki[A]):!!(gt==="application/xhtml+xml"&&qn[h.namespaceURI]):!1},he=function(h){yt(t.removed,{element:h});try{N(h).removeChild(h)}catch{k(h)}},Oe=function(h,x){try{yt(t.removed,{attribute:x.getAttributeNode(h),from:x})}catch{yt(t.removed,{attribute:null,from:x})}if(x.removeAttribute(h),h==="is")if(Ze||Kt)try{he(x)}catch{}else try{x.setAttribute(h,"")}catch{}},Hi=function(h){let x=null,A=null;if(zn)h="<remove></remove>"+h;else{const U=us(h,/^[\r\n\t ]+/);A=U&&U[0]}gt==="application/xhtml+xml"&&et===ye&&(h='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+h+"</body></html>");const D=R?R.createHTML(h):h;if(et===ye)try{x=new f().parseFromString(D,gt)}catch{}if(!x||!x.documentElement){x=E.createDocument(et,"template",null);try{x.documentElement.innerHTML=Wn?C:D}catch{}}const W=x.body||x.documentElement;return h&&A&&W.insertBefore(n.createTextNode(A),W.childNodes[0]||null),et===ye?Nn.call(x,Ne?"html":"body")[0]:Ne?x.documentElement:W},ji=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)},Yn=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")},Vi=function(h){return typeof r=="function"&&h instanceof r};function be(T,h,x){Jt(T,A=>{A.call(t,h,x,tt)})}const Wi=function(h){let x=null;if(be(Y.beforeSanitizeElements,h,null),Yn(h))return he(h),!0;const A=K(h.nodeName);if(be(Y.uponSanitizeElement,h,{tagName:A,allowedTags:z}),Ut&&h.hasChildNodes()&&!Vi(h.firstElementChild)&&Q(/<[/\w!]/g,h.innerHTML)&&Q(/<[/\w!]/g,h.textContent)||h.nodeType===xt.progressingInstruction||Ut&&h.nodeType===xt.comment&&Q(/<[/\w]/g,h.data))return he(h),!0;if(!(Qe.tagCheck instanceof Function&&Qe.tagCheck(A))&&(!z[A]||ht[A])){if(!ht[A]&&Gi(A)&&(F.tagNameCheck instanceof RegExp&&Q(F.tagNameCheck,A)||F.tagNameCheck instanceof Function&&F.tagNameCheck(A)))return!1;if(Hn&&!pe[A]){const D=N(h)||h.parentNode,W=M(h)||h.childNodes;if(W&&D){const U=W.length;for(let ee=U-1;ee>=0;--ee){const we=$(W[ee],!0);we.__removalCount=(h.__removalCount||0)+1,D.insertBefore(we,_(h))}}}return he(h),!0}return h instanceof l&&!rl(h)||(A==="noscript"||A==="noembed"||A==="noframes")&&Q(/<\/no(script|embed|frames)/i,h.innerHTML)?(he(h),!0):(Je&&h.nodeType===xt.text&&(x=h.textContent,Jt([On,Dn,Bn],D=>{x=bt(x,D," ")}),h.textContent!==x&&(yt(t.removed,{element:h.cloneNode()}),h.textContent=x)),be(Y.afterSanitizeElements,h,null),!1)},qi=function(h,x,A){if(Ni&&(x==="id"||x==="name")&&(A in n||A in ol))return!1;if(!(Un&&!Fn[x]&&Q(Jr,x))){if(!(Ii&&Q(Zr,x))){if(!(Qe.attributeCheck instanceof Function&&Qe.attributeCheck(x,h))){if(!j[x]||Fn[x]){if(!(Gi(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(!Vn[x]){if(!Q(Ei,bt(A,Ci,""))){if(!((x==="src"||x==="xlink:href"||x==="href")&&h!=="script"&&_u(A,"data:")===0&&Di[h])){if(!(Li&&!Q(Xr,bt(A,Ci,"")))){if(A)return!1}}}}}}}return!0},Gi=function(h){return h!=="annotation-xml"&&us(h,el)},Yi=function(h){be(Y.beforeSanitizeAttributes,h,null);const{attributes:x}=h;if(!x||Yn(h))return;const A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:j,forceKeepAttr:void 0};let D=x.length;for(;D--;){const W=x[D],{name:U,namespaceURI:ee,value:we}=W,nt=K(U),Qn=we;let V=U==="value"?Qn:Tu(Qn);if(A.attrName=nt,A.attrValue=V,A.keepAttr=!0,A.forceKeepAttr=void 0,be(Y.uponSanitizeAttribute,h,A),V=A.attrValue,Oi&&(nt==="id"||nt==="name")&&(Oe(U,h),V=tl+V),Ut&&Q(/((--!?|])>)|<\/(style|title|textarea)/i,V)){Oe(U,h);continue}if(nt==="attributename"&&us(V,"href")){Oe(U,h);continue}if(A.forceKeepAttr)continue;if(!A.keepAttr){Oe(U,h);continue}if(!Pi&&Q(/\/>/i,V)){Oe(U,h);continue}Je&&Jt([On,Dn,Bn],Ji=>{V=bt(V,Ji," ")});const Qi=K(h.nodeName);if(!qi(Qi,nt,V)){Oe(U,h);continue}if(R&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!ee)switch(m.getAttributeType(Qi,nt)){case"TrustedHTML":{V=R.createHTML(V);break}case"TrustedScriptURL":{V=R.createScriptURL(V);break}}if(V!==Qn)try{ee?h.setAttributeNS(ee,U,V):h.setAttribute(U,V),Yn(h)?he(h):Ra(t.removed)}catch{Oe(U,h)}}be(Y.afterSanitizeAttributes,h,null)},ll=function T(h){let x=null;const A=ji(h);for(be(Y.beforeSanitizeShadowDOM,h,null);x=A.nextNode();)be(Y.uponSanitizeShadowNode,x,null),Wi(x),Yi(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,D=null,W=null;if(Wn=!T,Wn&&(T="<!-->"),typeof T!="string"&&!Vi(T))if(typeof T.toString=="function"){if(T=T.toString(),typeof T!="string")throw wt("dirty is not a string, aborting")}else throw wt("toString is not a function");if(!t.isSupported)return T;if(Kn||Gn(h),t.removed=[],typeof T=="string"&&(ft=!1),ft){if(T.nodeName){const we=K(T.nodeName);if(!z[we]||ht[we])throw wt("root node is forbidden and cannot be sanitized in-place")}}else if(T instanceof r)x=Hi("<!---->"),A=x.ownerDocument.importNode(T,!0),A.nodeType===xt.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?x=A:x.appendChild(A);else{if(!Ze&&!Je&&!Ne&&T.indexOf("<")===-1)return R&&zt?R.createHTML(T):T;if(x=Hi(T),!x)return Ze?null:zt?C:""}x&&zn&&he(x.firstChild);const U=ji(ft?T:x);for(;D=U.nextNode();)Wi(D),Yi(D),D.content instanceof a&&ll(D.content);if(ft)return T;if(Ze){if(Kt)for(W=Pn.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&&Jt([On,Dn,Bn],we=>{ee=bt(ee,we," ")}),R&&zt?R.createHTML(ee):ee},t.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Gn(T),Kn=!0},t.clearConfig=function(){tt=null,Kn=!1},t.isValidAttribute=function(T,h,x){tt||Gn({});const A=K(T),D=K(h);return qi(A,D,x)},t.addHook=function(T,h){typeof h=="function"&&yt(Y[T],h)},t.removeHook=function(T,h){if(h!==void 0){const x=Su(Y[T],h);return x===-1?void 0:Au(Y[T],x,1)[0]}return Ra(Y[T])},t.removeHooks=function(T){Y[T]=[]},t.removeAllHooks=function(){Y=Oa()},t}var Bs=br();function vi(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ye=vi();function wr(e){Ye=e}var Tt={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 zu=(()=>{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")},Hu=/^(?:[ \t]*(?:\n|$))+/,ju=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Vu=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ft=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Wu=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,yi=/(?:[*+-]|\d{1,9}[.)])/,$r=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,xr=P($r).replace(/bull/g,yi).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(),qu=P($r).replace(/bull/g,yi).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(),bi=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Gu=/^[^\n]+/,wi=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Yu=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",wi).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Qu=P(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,yi).getRegex(),Rn="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",$i=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ju=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",$i).replace("tag",Rn).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),kr=P(bi).replace("hr",Ft).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",Rn).getRegex(),Zu=P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",kr).getRegex(),xi={blockquote:Zu,code:ju,def:Yu,fences:Vu,heading:Wu,hr:Ft,html:Ju,lheading:xr,list:Qu,newline:Hu,paragraph:kr,table:Tt,text:Gu},Da=P("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ft).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",Rn).getRegex(),Xu={...xi,lheading:qu,table:Da,paragraph:P(bi).replace("hr",Ft).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Da).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",Rn).getRegex()},ep={...xi,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",$i).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:Tt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(bi).replace("hr",Ft).replace("heading",` *#{1,6} *[^
31
- ]`).replace("lheading",xr).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},tp=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,np=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Sr=/^( {2,}|\\)\n(?!\s*$)/,sp=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Mn=/[\p{P}\p{S}]/u,ki=/[\s\p{P}\p{S}]/u,Ar=/[^\s\p{P}\p{S}]/u,ip=P(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ki).getRegex(),_r=/(?!~)[\p{P}\p{S}]/u,ap=/(?!~)[\s\p{P}\p{S}]/u,op=/(?:[^\s\p{P}\p{S}]|~)/u,rp=P(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",zu?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Tr=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,lp=P(Tr,"u").replace(/punct/g,Mn).getRegex(),cp=P(Tr,"u").replace(/punct/g,_r).getRegex(),Cr="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",dp=P(Cr,"gu").replace(/notPunctSpace/g,Ar).replace(/punctSpace/g,ki).replace(/punct/g,Mn).getRegex(),up=P(Cr,"gu").replace(/notPunctSpace/g,op).replace(/punctSpace/g,ap).replace(/punct/g,_r).getRegex(),pp=P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ar).replace(/punctSpace/g,ki).replace(/punct/g,Mn).getRegex(),hp=P(/\\(punct)/,"gu").replace(/punct/g,Mn).getRegex(),fp=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(),gp=P($i).replace("(?:-->|$)","-->").getRegex(),mp=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",gp).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),pn=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,vp=P(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",pn).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Er=P(/^!?\[(label)\]\[(ref)\]/).replace("label",pn).replace("ref",wi).getRegex(),Rr=P(/^!?\[(ref)\](?:\[\])?/).replace("ref",wi).getRegex(),yp=P("reflink|nolink(?!\\()","g").replace("reflink",Er).replace("nolink",Rr).getRegex(),Ba=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Si={_backpedal:Tt,anyPunctuation:hp,autolink:fp,blockSkip:rp,br:Sr,code:np,del:Tt,emStrongLDelim:lp,emStrongRDelimAst:dp,emStrongRDelimUnd:pp,escape:tp,link:vp,nolink:Rr,punctuation:ip,reflink:Er,reflinkSearch:yp,tag:mp,text:sp,url:Tt},bp={...Si,link:P(/^!?\[(label)\]\((.*?)\)/).replace("label",pn).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",pn).getRegex()},Fs={...Si,emStrongRDelimAst:up,emStrongLDelim:cp,url:P(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ba).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",Ba).getRegex()},wp={...Fs,br:P(Sr).replace("{2,}","*").getRegex(),text:P(Fs.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Xt={normal:xi,gfm:Xu,pedantic:ep},kt={normal:Si,gfm:Fs,breaks:wp,pedantic:bp},$p={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Fa=e=>$p[e];function xe(e,t){if(t){if(J.escapeTest.test(e))return e.replace(J.escapeReplace,Fa)}else if(J.escapeTestNoEncode.test(e))return e.replace(J.escapeReplaceNoEncode,Fa);return e}function Ua(e){try{e=encodeURI(e).replace(J.percentDecode,"%")}catch{return null}return e}function Ka(e,t){let n=e.replace(J.findPipe,(a,o,r)=>{let l=!1,u=o;for(;--u>=0&&r[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 St(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 xp(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 za(e,t,n,s,i){let a=t.href,o=t.title||null,r=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:r,tokens:s.inlineTokens(r)};return s.state.inLink=!1,l}function kp(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let i=s[1];return t.split(`
32
- `).map(a=>{let o=a.match(n.other.beginningSpace);if(o===null)return a;let[r]=o;return r.length>=i.length?a.slice(i.length):a}).join(`
33
- `)}var hn=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:St(n,`
34
- `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=kp(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=St(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:St(t[0],`
35
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=St(t[0],`
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 Fc(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 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 Gi(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=Au(Y[T],h);return x===-1?void 0:_u(Y[T],x,1)[0]}return Ma(Y[T])},t.removeHooks=function(T){Y[T]=[]},t.removeAllHooks=function(){Y=Da()},t}var Fs=br();function yi(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ye=yi();function wr(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 Hu=(()=>{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")},ju=/^(?:[ \t]*(?:\n|$))+/,Vu=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Wu=/^ {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+|$)/,qu=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,bi=/(?:[*+-]|\d{1,9}[.)])/,$r=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,xr=P($r).replace(/bull/g,bi).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(),Gu=P($r).replace(/bull/g,bi).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(),wi=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Yu=/^[^\n]+/,$i=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Qu=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",$i).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ju=P(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,bi).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",xi=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Zu=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",xi).replace("tag",Mn).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),kr=P(wi).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(),Xu=P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",kr).getRegex(),ki={blockquote:Xu,code:Vu,def:Qu,fences:Wu,heading:qu,hr:Ut,html:Zu,lheading:xr,list:Ju,newline:ju,paragraph:kr,table:Ct,text:Yu},Ba=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(),ep={...ki,lheading:Gu,table:Ba,paragraph:P(wi).replace("hr",Ut).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ba).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()},tp={...ki,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",xi).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(wi).replace("hr",Ut).replace("heading",` *#{1,6} *[^
31
+ ]`).replace("lheading",xr).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},np=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,sp=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Sr=/^( {2,}|\\)\n(?!\s*$)/,ip=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,In=/[\p{P}\p{S}]/u,Si=/[\s\p{P}\p{S}]/u,Ar=/[^\s\p{P}\p{S}]/u,ap=P(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Si).getRegex(),_r=/(?!~)[\p{P}\p{S}]/u,op=/(?!~)[\s\p{P}\p{S}]/u,rp=/(?:[^\s\p{P}\p{S}]|~)/u,lp=P(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Hu?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Tr=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,cp=P(Tr,"u").replace(/punct/g,In).getRegex(),dp=P(Tr,"u").replace(/punct/g,_r).getRegex(),Cr="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",up=P(Cr,"gu").replace(/notPunctSpace/g,Ar).replace(/punctSpace/g,Si).replace(/punct/g,In).getRegex(),pp=P(Cr,"gu").replace(/notPunctSpace/g,rp).replace(/punctSpace/g,op).replace(/punct/g,_r).getRegex(),hp=P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ar).replace(/punctSpace/g,Si).replace(/punct/g,In).getRegex(),fp=P(/\\(punct)/,"gu").replace(/punct/g,In).getRegex(),gp=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(),mp=P(xi).replace("(?:-->|$)","-->").getRegex(),vp=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",mp).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),hn=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,yp=P(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",hn).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Er=P(/^!?\[(label)\]\[(ref)\]/).replace("label",hn).replace("ref",$i).getRegex(),Rr=P(/^!?\[(ref)\](?:\[\])?/).replace("ref",$i).getRegex(),bp=P("reflink|nolink(?!\\()","g").replace("reflink",Er).replace("nolink",Rr).getRegex(),Fa=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ai={_backpedal:Ct,anyPunctuation:fp,autolink:gp,blockSkip:lp,br:Sr,code:sp,del:Ct,emStrongLDelim:cp,emStrongRDelimAst:up,emStrongRDelimUnd:hp,escape:np,link:yp,nolink:Rr,punctuation:ap,reflink:Er,reflinkSearch:bp,tag:vp,text:ip,url:Ct},wp={...Ai,link:P(/^!?\[(label)\]\((.*?)\)/).replace("label",hn).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",hn).getRegex()},Us={...Ai,emStrongRDelimAst:pp,emStrongLDelim:dp,url:P(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Fa).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",Fa).getRegex()},$p={...Us,br:P(Sr).replace("{2,}","*").getRegex(),text:P(Us.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},en={normal:ki,gfm:ep,pedantic:tp},St={normal:Ai,gfm:Us,breaks:$p,pedantic:wp},xp={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ua=e=>xp[e];function xe(e,t){if(t){if(J.escapeTest.test(e))return e.replace(J.escapeReplace,Ua)}else if(J.escapeTestNoEncode.test(e))return e.replace(J.escapeReplaceNoEncode,Ua);return e}function Ka(e){try{e=encodeURI(e).replace(J.percentDecode,"%")}catch{return null}return e}function za(e,t){let n=e.replace(J.findPipe,(a,o,c)=>{let r=!1,u=o;for(;--u>=0&&c[u]==="\\";)r=!r;return r?"|":" |"}),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 kp(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 Ha(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 r={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:a,title:o,text:c,tokens:s.inlineTokens(c)};return s.state.inLink=!1,r}function Sp(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let i=s[1];return t.split(`
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
+ `)}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=Sp(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
+ `)}}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,r=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))r.push(n[l]),o=!0;else if(!o)r.push(n[l]);else break;n=n.slice(l);let u=r.join(`
37
+ `),s="",i="",a=[];for(;n.length>0;){let o=!1,c=[],r;for(r=0;r<n.length;r++)if(this.rules.other.blockquoteStart.test(n[r]))c.push(n[r]),o=!0;else if(!o)c.push(n[r]);else break;n=n.slice(r);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 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(`
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 r=!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),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(`
49
+ `,e=e.substring(f.length+1),r=!0),!r){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 r=i.items.at(-1);if(r)r.raw=r.raw.trimEnd(),r.text=r.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=Ka(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(Ka(o,a.header.length).map((r,l)=>({text:r,tokens:this.lexer.inline(r),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=St(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{let a=xp(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)),za(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 za(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,r=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]){r+=o;continue}else if((s[5]||s[6])&&i%3&&!((i+o)%3)){l+=o;continue}if(r-=o,r>0)continue;o=Math.min(o,o+r+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 Us{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 hn,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:Xt.normal,inline:kt.normal};this.options.pedantic?(n.block=Xt.pedantic,n.inline=kt.pedantic):this.options.gfm&&(n.block=Xt.gfm,this.options.breaks?n.inline=kt.breaks:n.inline=kt.gfm),this.tokenizer.rules=n}static get rules(){return{block:Xt,inline:kt}}static lex(t,n){return new Us(n).lex(t)}static lexInline(t,n){return new Us(n).inlineTokens(t)}lex(t){t=t.replace(J.carriageReturn,`
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 r of i.items){if(this.lexer.state.top=!1,r.tokens=this.lexer.blockTokens(r.text,[]),r.task){if(r.text=r.text.replace(this.rules.other.listReplaceTask,""),r.tokens[0]?.type==="text"||r.tokens[0]?.type==="paragraph"){r.tokens[0].raw=r.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),r.tokens[0].text=r.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(r.raw);if(u){let d={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};r.checked=d.checked,i.loose?r.tokens[0]&&["paragraph","text"].includes(r.tokens[0].type)&&"tokens"in r.tokens[0]&&r.tokens[0].tokens?(r.tokens[0].raw=d.raw+r.tokens[0].raw,r.tokens[0].text=d.raw+r.tokens[0].text,r.tokens[0].tokens.unshift(d)):r.tokens.unshift({type:"paragraph",raw:d.raw,text:d.raw,tokens:[d]}):r.tokens.unshift(d)}}if(!i.loose){let u=r.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 r of i.items){r.loose=!0;for(let u of r.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=za(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(za(o,a.header.length).map((c,r)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:a.align[r]})));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=kp(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)),Ha(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 Ha(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,r=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)){r+=o;continue}if(c-=o,c>0)continue;o=Math.min(o,o+c+r);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 Ks{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 Ks(n).lex(t)}static lexInline(t,n){return new Ks(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,20 +60,20 @@ ${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,r=t.slice(1),l;this.options.extensions.startBlock.forEach(u=>{l=u.call({lexer:this},r),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(`
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),r;this.options.extensions.startBlock.forEach(u=>{r=u.call({lexer:this},c),typeof r=="number"&&r>=0&&(o=Math.min(o,r))}),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 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,r="";for(;t;){o||(r=""),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,r)){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)!=="_"&&(r=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}},fn=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,"")+`
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 r=Object.keys(this.tokens.links);if(r.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)r.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 r;if(this.options.extensions?.inline?.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))continue;if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length);let d=n.at(-1);r.type==="text"&&d?.type==="text"?(d.raw+=r.raw,d.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,s,c)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t))){t=t.substring(r.raw.length),n.push(r);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(r=this.tokenizer.inlineText(u)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(c=r.raw.slice(-1)),o=!0;let d=n.at(-1);d?.type==="text"?(d.raw+=r.raw,d.text+=r.text):n.push(r);continue}if(t){let d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return 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>
73
73
  ${this.parser.parse(e)}</blockquote>
74
74
  `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
75
75
  `}hr(e){return`<hr>
76
- `}list(e){let t=e.ordered,n=e.start,s="";for(let o=0;o<e.items.length;o++){let r=e.items[o];s+=this.listitem(r)}let i=t?"ol":"ul",a=t&&n!==1?' start="'+n+'"':"";return"<"+i+a+`>
76
+ `}list(e){let t=e.ordered,n=e.start,s="";for(let o=0;o<e.items.length;o++){let c=e.items[o];s+=this.listitem(c)}let i=t?"ol":"ul",a=t&&n!==1?' start="'+n+'"':"";return"<"+i+a+`>
77
77
  `+s+"</"+i+`>
78
78
  `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
79
79
  `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
@@ -84,29 +84,29 @@ ${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=Ua(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=Ua(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)}},Ai=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 Ks{options;renderer;textRenderer;constructor(t){this.options=t||Ye,this.options.renderer=this.options.renderer||new fn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ai}static parse(t,n){return new Ks(n).parse(t)}static parseInline(t,n){return new Ks(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,r=this.options.extensions.renderers[o.type].call({parser:this},o);if(r!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=r||"";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 r=this.options.extensions.renderers[a.type].call({parser:this},a);if(r!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){s+=r||"";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 r='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(r),"";throw new Error(r)}}}return s}},At=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}},Sp=class{defaults=vi();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=de;Renderer=fn;TextRenderer=Ai;Lexer=ce;Tokenizer=hn;Hooks=At;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 r=i.renderer.apply(this,o);return r===!1&&(r=a.apply(this,o)),r}: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 fn(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,r=n.renderer[o],l=i[o];i[o]=(...u)=>{let d=r.apply(i,u);return d===!1&&(d=l.apply(i,u)),d||""}}s.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new hn(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,r=n.tokenizer[o],l=i[o];i[o]=(...u)=>{let d=r.apply(i,u);return d===!1&&(d=l.apply(i,u)),d}}s.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new At;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,r=n.hooks[o],l=i[o];At.passThroughHooks.has(a)?i[o]=u=>{if(this.defaults.async&&At.passThroughHooksRespectAsync.has(a))return(async()=>{let p=await r.call(i,u);return l.call(i,p)})();let d=r.call(i,u);return l.call(i,d)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let p=await r.apply(i,u);return p===!1&&(p=await l.apply(i,u)),p})();let d=r.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 r=[];return r.push(a.call(this,o)),i&&(r=r.concat(i.call(this,o))),r}}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,r=await(i.hooks?await i.hooks.provideLexer():e?ce.lex:ce.lexInline)(o,i),l=i.hooks?await i.hooks.processAllTokens(r):r;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 r=(i.hooks?i.hooks.provideParser():e?de.parse:de.parseInline)(o,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}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 Sp;function O(e,t){return Ge.parse(e,t)}O.options=O.setOptions=function(e){return Ge.setOptions(e),O.defaults=Ge.defaults,wr(O.defaults),O};O.getDefaults=vi;O.defaults=Ye;O.use=function(...e){return Ge.use(...e),O.defaults=Ge.defaults,wr(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=fn;O.TextRenderer=Ai;O.Lexer=ce;O.lexer=ce.lex;O.Tokenizer=hn;O.Hooks=At;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 Ha=["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"],ja=["class","href","rel","target","title","start"];let Va=!1;const Ap=14e4,_p=4e4,Tp=200,ms=5e4,ze=new Map;function Cp(e){const t=ze.get(e);return t===void 0?null:(ze.delete(e),ze.set(e,t),t)}function Wa(e,t){if(ze.set(e,t),ze.size<=Tp)return;const n=ze.keys().next().value;n&&ze.delete(n)}function Ep(){Va||(Va=!0,Bs.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function zs(e){const t=e.trim();if(!t)return"";if(Ep(),t.length<=ms){const o=Cp(t);if(o!==null)return o}const n=Mo(t,Ap),s=n.truncated?`
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=Ka(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=Ka(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)}},_i=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 zs{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 _i}static parse(t,n){return new zs(n).parse(t)}static parseInline(t,n){return new zs(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}},Ap=class{defaults=yi();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=de;Renderer=gn;TextRenderer=_i;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],r=i[o];i[o]=(...u)=>{let d=c.apply(i,u);return d===!1&&(d=r.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],r=i[o];i[o]=(...u)=>{let d=c.apply(i,u);return d===!1&&(d=r.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],r=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 r.call(i,p)})();let d=c.call(i,u);return r.call(i,d)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let p=await c.apply(i,u);return p===!1&&(p=await r.apply(i,u)),p})();let d=c.apply(i,u);return d===!1&&(d=r.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),r=i.hooks?await i.hooks.processAllTokens(c):c;i.walkTokens&&await Promise.all(this.walkTokens(r,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():e?de.parse:de.parseInline)(r,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 Ap;function O(e,t){return Ge.parse(e,t)}O.options=O.setOptions=function(e){return Ge.setOptions(e),O.defaults=Ge.defaults,wr(O.defaults),O};O.getDefaults=yi;O.defaults=Ye;O.use=function(...e){return Ge.use(...e),O.defaults=Ge.defaults,wr(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=_i;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 ja=["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"],Va=["class","href","rel","target","title","start"];let Wa=!1;const _p=14e4,Tp=4e4,Cp=200,vs=5e4,ze=new Map;function Ep(e){const t=ze.get(e);return t===void 0?null:(ze.delete(e),ze.set(e,t),t)}function qa(e,t){if(ze.set(e,t),ze.size<=Cp)return;const n=ze.keys().next().value;n&&ze.delete(n)}function Rp(){Wa||(Wa=!0,Fs.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function Hs(e){const t=e.trim();if(!t)return"";if(Rp(),t.length<=vs){const o=Ep(t);if(o!==null)return o}const n=Mo(t,_p),s=n.truncated?`
89
89
 
90
- … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>_p){const r=`<pre class="code-block">${Rp(`${n.text}${s}`)}</pre>`,l=Bs.sanitize(r,{ALLOWED_TAGS:Ha,ALLOWED_ATTR:ja});return t.length<=ms&&Wa(t,l),l}const i=O.parse(`${n.text}${s}`),a=Bs.sanitize(i,{ALLOWED_TAGS:Ha,ALLOWED_ATTR:ja});return t.length<=ms&&Wa(t,a),a}function Rp(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const Mp=1500,Ip=2e3,Mr="Copy as markdown",Lp="Copied",Pp="Copy failed";async function Np(e){if(!e)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function en(e,t){e.title=t,e.setAttribute("aria-label",t)}function Op(e){const t=e.label??Mr;return c`
90
+ … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>Tp){const c=`<pre class="code-block">${Mp(`${n.text}${s}`)}</pre>`,r=Fs.sanitize(c,{ALLOWED_TAGS:ja,ALLOWED_ATTR:Va});return t.length<=vs&&qa(t,r),r}const i=O.parse(`${n.text}${s}`),a=Fs.sanitize(i,{ALLOWED_TAGS:ja,ALLOWED_ATTR:Va});return t.length<=vs&&qa(t,a),a}function Mp(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const Ip=1500,Lp=2e3,Mr="Copy as markdown",Pp="Copied",Np="Copy failed";async function Op(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 Dp(e){const t=e.label??Mr;return l`
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 Np(e.text());if(s.isConnected){if(delete s.dataset.copying,s.removeAttribute("aria-busy"),s.disabled=!1,!i){s.dataset.error="1",en(s,Pp),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.error,en(s,t))},Ip);return}s.dataset.copied="1",en(s,Lp),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.copied,en(s,t))},Mp)}}}
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 Op(e.text());if(s.isConnected){if(delete s.dataset.copying,s.removeAttribute("aria-busy"),s.disabled=!1,!i){s.dataset.error="1",tn(s,Np),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.error,tn(s,t))},Lp);return}s.dataset.copied="1",tn(s,Pp),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.copied,tn(s,t))},Ip)}}}
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 Dp(e){return Op({text:()=>e,label:Mr})}const Bp={icon:"puzzle",detailKeys:["command","path","url","targetUrl","targetId","ref","element","node","nodeId","id","requestId","to","channelId","guildId","userId","name","query","pattern","messageId"]},Fp={bash:{icon:"wrench",title:"Bash",detailKeys:["command"]},process:{icon:"wrench",title:"Process",detailKeys:["sessionId"]},read:{icon:"fileText",title:"Read",detailKeys:["path"]},write:{icon:"edit",title:"Write",detailKeys:["path"]},edit:{icon:"penLine",title:"Edit",detailKeys:["path"]},attach:{icon:"paperclip",title:"Attach",detailKeys:["path","url","fileName"]},browser:{icon:"globe",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",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",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",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",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",title:"WhatsApp Login",actions:{start:{label:"start"},wait:{label:"wait"}}},discord:{icon:"messageSquare",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",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"}}}},Up={fallback:Bp,tools:Fp},Ir=Up,qa=Ir.fallback??{icon:"puzzle"},Kp=Ir.tools??{};function zp(e){return(e??"tool").trim()}function Hp(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 jp(e){const t=e?.trim();if(t)return t.replace(/_/g," ")}function Lr(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=>Lr(s)).filter(s=>!!s);if(t.length===0)return;const n=t.slice(0,3).join(", ");return t.length>3?`${n}…`:n}}}function Vp(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 Wp(e,t){for(const n of t){const s=Vp(e,n),i=Lr(s);if(i)return i}}function qp(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 Gp(e){if(!e||typeof e!="object")return;const t=e;return typeof t.path=="string"?t.path:void 0}function Yp(e,t){if(!(!e||!t))return e.actions?.[t]??void 0}function Qp(e){const t=zp(e.name),n=t.toLowerCase(),s=Kp[n],i=s?.icon??qa.icon??"puzzle",a=s?.title??Hp(t),o=s?.label??t,r=e.args&&typeof e.args=="object"?e.args.action:void 0,l=typeof r=="string"?r.trim():void 0,u=Yp(s,l),d=jp(u?.label??l);let p;n==="read"&&(p=qp(e.args)),!p&&(n==="write"||n==="edit"||n==="attach")&&(p=Gp(e.args));const f=u?.detailKeys??s?.detailKeys??qa.detailKeys??[];return!p&&f.length>0&&(p=Wp(e.args,f)),!p&&e.meta&&(p=e.meta),p&&(p=Zp(p)),{name:t,icon:i,title:a,label:o,verb:d,detail:p}}function Jp(e){const t=[];if(e.verb&&t.push(e.verb),e.detail&&t.push(e.detail),t.length!==0)return t.join(" · ")}function Zp(e){return e&&e.replace(/\/Users\/[^/]+/g,"~").replace(/\/home\/[^/]+/g,"~")}const Xp=80,eh=2,Ga=100;function th(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 nh(e){const t=e.split(`
104
- `),n=t.slice(0,eh),s=n.join(`
105
- `);return s.length>Ga?s.slice(0,Ga)+"…":n.length<t.length?s+"…":s}function sh(e){const t=e,n=ih(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:ah(i.arguments??i.args)})}for(const i of n){const a=String(i.type??"").toLowerCase();if(a!=="toolresult"&&a!=="tool_result")continue;const o=oh(i),r=typeof i.name=="string"?i.name:"tool";s.push({kind:"result",name:r,text:o})}if(gr(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=Io(e)??void 0;s.push({kind:"result",name:i,text:a})}return s}function Ya(e,t){const n=Qp({name:e.name,args:e.args}),s=Jp(n),i=!!e.text?.trim(),a=!!t,o=a?()=>{if(i){t(th(e.text));return}const p=`## ${n.label}
103
+ `}function Bp(e){return Dp({text:()=>e,label:Mr})}const Fp={icon:"puzzle",detailKeys:["command","path","url","targetUrl","targetId","ref","element","node","nodeId","id","requestId","to","channelId","guildId","userId","name","query","pattern","messageId"]},Up={bash:{icon:"wrench",title:"Bash",detailKeys:["command"]},process:{icon:"wrench",title:"Process",detailKeys:["sessionId"]},read:{icon:"fileText",title:"Read",detailKeys:["path"]},write:{icon:"edit",title:"Write",detailKeys:["path"]},edit:{icon:"penLine",title:"Edit",detailKeys:["path"]},attach:{icon:"paperclip",title:"Attach",detailKeys:["path","url","fileName"]},browser:{icon:"globe",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",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",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",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",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",title:"WhatsApp Login",actions:{start:{label:"start"},wait:{label:"wait"}}},discord:{icon:"messageSquare",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",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"}}}},Kp={fallback:Fp,tools:Up},Ir=Kp,Ga=Ir.fallback??{icon:"puzzle"},zp=Ir.tools??{};function Hp(e){return(e??"tool").trim()}function jp(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 Vp(e){const t=e?.trim();if(t)return t.replace(/_/g," ")}function Lr(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=>Lr(s)).filter(s=>!!s);if(t.length===0)return;const n=t.slice(0,3).join(", ");return t.length>3?`${n}…`:n}}}function Wp(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 qp(e,t){for(const n of t){const s=Wp(e,n),i=Lr(s);if(i)return i}}function Gp(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 Yp(e){if(!e||typeof e!="object")return;const t=e;return typeof t.path=="string"?t.path:void 0}function Qp(e,t){if(!(!e||!t))return e.actions?.[t]??void 0}function Jp(e){const t=Hp(e.name),n=t.toLowerCase(),s=zp[n],i=s?.icon??Ga.icon??"puzzle",a=s?.title??jp(t),o=s?.label??t,c=e.args&&typeof e.args=="object"?e.args.action:void 0,r=typeof c=="string"?c.trim():void 0,u=Qp(s,r),d=Vp(u?.label??r);let p;n==="read"&&(p=Gp(e.args)),!p&&(n==="write"||n==="edit"||n==="attach")&&(p=Yp(e.args));const f=u?.detailKeys??s?.detailKeys??Ga.detailKeys??[];return!p&&f.length>0&&(p=qp(e.args,f)),!p&&e.meta&&(p=e.meta),p&&(p=Xp(p)),{name:t,icon:i,title:a,label:o,verb:d,detail:p}}function Zp(e){const t=[];if(e.verb&&t.push(e.verb),e.detail&&t.push(e.detail),t.length!==0)return t.join(" · ")}function Xp(e){return e&&e.replace(/\/Users\/[^/]+/g,"~").replace(/\/home\/[^/]+/g,"~")}const eh=80,th=2,Ya=100;function nh(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 sh(e){const t=e.split(`
104
+ `),n=t.slice(0,th),s=n.join(`
105
+ `);return s.length>Ya?s.slice(0,Ya)+"…":n.length<t.length?s+"…":s}function ih(e){const t=e,n=ah(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:oh(i.arguments??i.args)})}for(const i of n){const a=String(i.type??"").toLowerCase();if(a!=="toolresult"&&a!=="tool_result")continue;const o=rh(i),c=typeof i.name=="string"?i.name:"tool";s.push({kind:"result",name:c,text:o})}if(gr(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=Io(e)??void 0;s.push({kind:"result",name:i,text:a})}return s}function Qa(e,t){const n=Jp({name:e.name,args:e.args}),s=Zp(n),i=!!e.text?.trim(),a=!!t,o=a?()=>{if(i){t(nh(e.text));return}const p=`## ${n.label}
106
106
 
107
107
  ${s?`**Command:** \`${s}\`
108
108
 
109
- `:""}*No output — tool completed successfully.*`;t(p)}:void 0,r=i&&(e.text?.length??0)<=Xp,l=i&&!r,u=i&&r,d=!i;return c`
109
+ `:""}*No output — tool completed successfully.*`;t(p)}:void 0,c=i&&(e.text?.length??0)<=eh,r=i&&!c,u=i&&c,d=!i;return l`
110
110
  <div
111
111
  class="chat-tool-card ${a?"chat-tool-card--clickable":""}"
112
112
  @click=${o}
@@ -119,17 +119,17 @@ ${s?`**Command:** \`${s}\`
119
119
  <span class="chat-tool-card__icon">${G[n.icon]}</span>
120
120
  <span>${n.label}</span>
121
121
  </div>
122
- ${a?c`<span class="chat-tool-card__action">${i?"View":""} ${G.check}</span>`:g}
123
- ${d&&!a?c`<span class="chat-tool-card__status">${G.check}</span>`:g}
122
+ ${a?l`<span class="chat-tool-card__action">${i?"View":""} ${G.check}</span>`:g}
123
+ ${d&&!a?l`<span class="chat-tool-card__status">${G.check}</span>`:g}
124
124
  </div>
125
- ${s?c`<div class="chat-tool-card__detail">${s}</div>`:g}
126
- ${d?c`<div class="chat-tool-card__status-text muted">Completed</div>`:g}
127
- ${l?c`<div class="chat-tool-card__preview mono">${nh(e.text)}</div>`:g}
128
- ${u?c`<div class="chat-tool-card__inline mono">${e.text}</div>`:g}
125
+ ${s?l`<div class="chat-tool-card__detail">${s}</div>`:g}
126
+ ${d?l`<div class="chat-tool-card__status-text muted">Completed</div>`:g}
127
+ ${r?l`<div class="chat-tool-card__preview mono">${sh(e.text)}</div>`:g}
128
+ ${u?l`<div class="chat-tool-card__inline mono">${e.text}</div>`:g}
129
129
  </div>
130
- `}function ih(e){return Array.isArray(e)?e.filter(Boolean):[]}function ah(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 oh(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function rh(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 r=o.data,l=o.media_type||"image/png",u=r.startsWith("data:")?r:`data:${l};base64,${r}`;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 lh(e){return c`
130
+ `}function ah(e){return Array.isArray(e)?e.filter(Boolean):[]}function oh(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 rh(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function lh(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,r=o.media_type||"image/png",u=c.startsWith("data:")?c:`data:${r};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 ch(e){return l`
131
131
  <div class="chat-group assistant">
132
- ${_i("assistant",e)}
132
+ ${Ti("assistant",e)}
133
133
  <div class="chat-group-messages">
134
134
  <div class="chat-bubble chat-reading-indicator" aria-hidden="true">
135
135
  <span class="chat-reading-indicator__dots">
@@ -138,9 +138,9 @@ ${s?`**Command:** \`${s}\`
138
138
  </div>
139
139
  </div>
140
140
  </div>
141
- `}function ch(e,t,n,s){const i=new Date(t).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),a=s?.name??"Assistant";return c`
141
+ `}function dh(e,t,n,s){const i=new Date(t).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),a=s?.name??"Assistant";return l`
142
142
  <div class="chat-group assistant">
143
- ${_i("assistant",s)}
143
+ ${Ti("assistant",s)}
144
144
  <div class="chat-group-messages">
145
145
  ${Pr({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!0,showReasoning:!1},n)}
146
146
  <div class="chat-group-footer">
@@ -149,24 +149,24 @@ ${s?`**Command:** \`${s}\`
149
149
  </div>
150
150
  </div>
151
151
  </div>
152
- `}function dh(e,t){const n=gi(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 c`
152
+ `}function uh(e,t){const n=mi(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 l`
153
153
  <div class="chat-group ${a}">
154
- ${_i(e.role,{name:s,avatar:t.assistantAvatar??null})}
154
+ ${Ti(e.role,{name:s,avatar:t.assistantAvatar??null})}
155
155
  <div class="chat-group-messages">
156
- ${e.messages.map((r,l)=>Pr(r.message,{isStreaming:e.isStreaming&&l===e.messages.length-1,showReasoning:t.showReasoning},t.onOpenSidebar))}
156
+ ${e.messages.map((c,r)=>Pr(c.message,{isStreaming:e.isStreaming&&r===e.messages.length-1,showReasoning:t.showReasoning},t.onOpenSidebar))}
157
157
  <div class="chat-group-footer">
158
158
  <span class="chat-sender-name">${i}</span>
159
159
  <span class="chat-group-timestamp">${o}</span>
160
160
  </div>
161
161
  </div>
162
162
  </div>
163
- `}function _i(e,t){const n=gi(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"?uh(i)?c`<img
163
+ `}function Ti(e,t){const n=mi(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"?ph(i)?l`<img
164
164
  class="chat-avatar ${o}"
165
165
  src="${i}"
166
166
  alt="${s}"
167
- />`:c`<div class="chat-avatar ${o}">${i}</div>`:c`<div class="chat-avatar ${o}">${a}</div>`}function uh(e){return/^https?:\/\//i.test(e)||/^data:image\//i.test(e)||/^\//.test(e)}function ph(e){return e.length===0?g:c`
167
+ />`:l`<div class="chat-avatar ${o}">${i}</div>`:l`<div class="chat-avatar ${o}">${a}</div>`}function ph(e){return/^https?:\/\//i.test(e)||/^data:image\//i.test(e)||/^\//.test(e)}function hh(e){return e.length===0?g:l`
168
168
  <div class="chat-message-images">
169
- ${e.map(t=>c`
169
+ ${e.map(t=>l`
170
170
  <img
171
171
  src=${t.url}
172
172
  alt=${t.alt??"Attached image"}
@@ -175,15 +175,15 @@ ${s?`**Command:** \`${s}\`
175
175
  />
176
176
  `)}
177
177
  </div>
178
- `}function Pr(e,t,n){const s=e,i=typeof s.role=="string"?s.role:"unknown",a=gr(e)||i.toLowerCase()==="toolresult"||i.toLowerCase()==="tool_result"||typeof s.toolCallId=="string"||typeof s.tool_call_id=="string",o=sh(e),r=o.length>0,l=rh(e),u=l.length>0,d=Io(e),p=t.showReasoning&&i==="assistant"?hc(e):null,f=d?.trim()?d:null,m=p?gc(p):null,v=f,$=i==="assistant"&&!!v?.trim(),k=["chat-bubble",$?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!v&&r&&a?c`${o.map(_=>Ya(_,n))}`:!v&&!r&&!u?g:c`
178
+ `}function Pr(e,t,n){const s=e,i=typeof s.role=="string"?s.role:"unknown",a=gr(e)||i.toLowerCase()==="toolresult"||i.toLowerCase()==="tool_result"||typeof s.toolCallId=="string"||typeof s.tool_call_id=="string",o=ih(e),c=o.length>0,r=lh(e),u=r.length>0,d=Io(e),p=t.showReasoning&&i==="assistant"?fc(e):null,f=d?.trim()?d:null,m=p?mc(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?l`${o.map(_=>Qa(_,n))}`:!v&&!c&&!u?g:l`
179
179
  <div class="${k}">
180
- ${$?Dp(v):g}
181
- ${ph(l)}
182
- ${m?c`<div class="chat-thinking">${Ps(zs(m))}</div>`:g}
183
- ${v?c`<div class="chat-text">${Ps(zs(v))}</div>`:g}
184
- ${o.map(_=>Ya(_,n))}
180
+ ${$?Bp(v):g}
181
+ ${hh(r)}
182
+ ${m?l`<div class="chat-thinking">${Ns(Hs(m))}</div>`:g}
183
+ ${v?l`<div class="chat-text">${Ns(Hs(v))}</div>`:g}
184
+ ${o.map(_=>Qa(_,n))}
185
185
  </div>
186
- `}function hh(e){return c`
186
+ `}function fh(e){return l`
187
187
  <div class="sidebar-panel">
188
188
  <div class="sidebar-header">
189
189
  <div class="sidebar-title">Tool Output</div>
@@ -192,15 +192,15 @@ ${s?`**Command:** \`${s}\`
192
192
  </button>
193
193
  </div>
194
194
  <div class="sidebar-content">
195
- ${e.error?c`
195
+ ${e.error?l`
196
196
  <div class="callout danger">${e.error}</div>
197
197
  <button @click=${e.onViewRawText} class="btn" style="margin-top: 12px;">
198
198
  View Raw Text
199
199
  </button>
200
- `:e.content?c`<div class="sidebar-markdown">${Ps(zs(e.content))}</div>`:c`<div class="muted">No content available</div>`}
200
+ `:e.content?l`<div class="sidebar-markdown">${Ns(Hs(e.content))}</div>`:l`<div class="muted">No content available</div>`}
201
201
  </div>
202
202
  </div>
203
- `}var fh=Object.defineProperty,gh=Object.getOwnPropertyDescriptor,In=(e,t,n,s)=>{for(var i=s>1?void 0:s?gh(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&&fh(t,n,i),i};let dt=class extends ut{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 c``}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}};dt.styles=pl`
203
+ `}var gh=Object.defineProperty,mh=Object.getOwnPropertyDescriptor,Ln=(e,t,n,s)=>{for(var i=s>1?void 0:s?mh(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&&gh(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 l``}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=pl`
204
204
  :host {
205
205
  width: 4px;
206
206
  cursor: col-resize;
@@ -226,17 +226,17 @@ ${s?`**Command:** \`${s}\`
226
226
  :host(.dragging) {
227
227
  background: var(--accent, #007bff);
228
228
  }
229
- `;In([yn({type:Number})],dt.prototype,"splitRatio",2);In([yn({type:Number})],dt.prototype,"minRatio",2);In([yn({type:Number})],dt.prototype,"maxRatio",2);dt=In([ko("resizable-divider")],dt);const mh=5e3;function vh(e){return e?e.active?c`
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([So("resizable-divider")],ut);const vh=5e3;function yh(e){return e?e.active?l`
230
230
  <div class="callout info compaction-indicator compaction-indicator--active">
231
231
  ${G.loader} Compacting context...
232
232
  </div>
233
- `:e.completedAt&&Date.now()-e.completedAt<mh?c`
233
+ `:e.completedAt&&Date.now()-e.completedAt<vh?l`
234
234
  <div class="callout success compaction-indicator compaction-indicator--complete">
235
235
  ${G.check} Context compacted
236
236
  </div>
237
- `:g:g}function yh(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function bh(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 r=o.result,l={id:yh(),dataUrl:r,mimeType:a.type},u=t.attachments??[];t.onAttachmentsChange?.([...u,l])},o.readAsDataURL(a)}}}function wh(e){const t=e.attachments??[];return t.length===0?g:c`
237
+ `:g:g}function bh(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function wh(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,r={id:bh(),dataUrl:c,mimeType:a.type},u=t.attachments??[];t.onAttachmentsChange?.([...u,r])},o.readAsDataURL(a)}}}function $h(e){const t=e.attachments??[];return t.length===0?g:l`
238
238
  <div class="chat-attachments">
239
- ${t.map(n=>c`
239
+ ${t.map(n=>l`
240
240
  <div class="chat-attachment">
241
241
  <img
242
242
  src=${n.dataUrl}
@@ -254,25 +254,25 @@ ${s?`**Command:** \`${s}\`
254
254
  </div>
255
255
  `)}
256
256
  </div>
257
- `}function $h(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",r={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=c`
257
+ `}function xh(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},r=(e.attachments?.length??0)>0,u=e.connected?r?"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=l`
258
258
  <div
259
259
  class="chat-thread"
260
260
  role="log"
261
261
  aria-live="polite"
262
262
  @scroll=${e.onChatScroll}
263
263
  >
264
- ${e.loading?c`<div class="muted">Loading chat…</div>`:g}
265
- ${hr(kh(e),m=>m.key,m=>m.kind==="reading-indicator"?lh(r):m.kind==="stream"?ch(m.text,m.startedAt,e.onOpenSidebar,r):m.kind==="group"?dh(m,{onOpenSidebar:e.onOpenSidebar,showReasoning:o,assistantName:e.assistantName,assistantAvatar:r.avatar}):g)}
264
+ ${e.loading?l`<div class="muted">Loading chat…</div>`:g}
265
+ ${hr(Sh(e),m=>m.key,m=>m.kind==="reading-indicator"?ch(c):m.kind==="stream"?dh(m.text,m.startedAt,e.onOpenSidebar,c):m.kind==="group"?uh(m,{onOpenSidebar:e.onOpenSidebar,showReasoning:o,assistantName:e.assistantName,assistantAvatar:c.avatar}):g)}
266
266
  </div>
267
- `;return c`
267
+ `;return l`
268
268
  <section class="card chat">
269
- ${e.disabledReason?c`<div class="callout">${e.disabledReason}</div>`:g}
269
+ ${e.disabledReason?l`<div class="callout">${e.disabledReason}</div>`:g}
270
270
 
271
- ${e.error?c`<div class="callout danger">${e.error}</div>`:g}
271
+ ${e.error?l`<div class="callout danger">${e.error}</div>`:g}
272
272
 
273
- ${vh(e.compactionStatus)}
273
+ ${yh(e.compactionStatus)}
274
274
 
275
- ${e.focusMode?c`
275
+ ${e.focusMode?l`
276
276
  <button
277
277
  class="chat-focus-exit"
278
278
  type="button"
@@ -294,24 +294,24 @@ ${s?`**Command:** \`${s}\`
294
294
  ${f}
295
295
  </div>
296
296
 
297
- ${p?c`
297
+ ${p?l`
298
298
  <resizable-divider
299
299
  .splitRatio=${d}
300
300
  @resize=${m=>e.onSplitRatioChange?.(m.detail.splitRatio)}
301
301
  ></resizable-divider>
302
302
  <div class="chat-sidebar">
303
- ${hh({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
303
+ ${fh({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
304
304
  ${e.sidebarContent}
305
305
  \`\`\``)}})}
306
306
  </div>
307
307
  `:g}
308
308
  </div>
309
309
 
310
- ${e.queue.length?c`
310
+ ${e.queue.length?l`
311
311
  <div class="chat-queue" role="status" aria-live="polite">
312
312
  <div class="chat-queue__title">Queued (${e.queue.length})</div>
313
313
  <div class="chat-queue__list">
314
- ${e.queue.map(m=>c`
314
+ ${e.queue.map(m=>l`
315
315
  <div class="chat-queue__item">
316
316
  <div class="chat-queue__text">
317
317
  ${m.text||(m.attachments?.length?`Image (${m.attachments.length})`:"")}
@@ -331,7 +331,7 @@ ${e.sidebarContent}
331
331
  `:g}
332
332
 
333
333
  <div class="chat-compose">
334
- ${wh(e)}
334
+ ${$h(e)}
335
335
  <div class="chat-compose__row">
336
336
  <label class="field chat-compose__field">
337
337
  <span>Message</span>
@@ -340,7 +340,7 @@ ${e.sidebarContent}
340
340
  ?disabled=${!e.connected}
341
341
  @keydown=${m=>{m.key==="Enter"&&(m.isComposing||m.keyCode===229||m.shiftKey||e.connected&&(m.preventDefault(),t&&e.onSend()))}}
342
342
  @input=${m=>e.onDraftChange(m.target.value)}
343
- @paste=${m=>bh(m,e)}
343
+ @paste=${m=>wh(m,e)}
344
344
  placeholder=${u}
345
345
  ></textarea>
346
346
  </label>
@@ -363,78 +363,78 @@ ${e.sidebarContent}
363
363
  </div>
364
364
  </div>
365
365
  </section>
366
- `}const Qa=200;function xh(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=fr(s.message),a=gi(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 kh(e){const t=[],n=Array.isArray(e.messages)?e.messages:[],s=Array.isArray(e.toolMessages)?e.toolMessages:[],i=Math.max(0,n.length-Qa);i>0&&t.push({kind:"message",key:"chat:history:notice",message:{role:"system",content:`Showing last ${Qa} messages (${i} hidden).`,timestamp:Date.now()}});for(let a=i;a<n.length;a++){const o=n[a],r=fr(o);!e.showThinking&&r.role.toLowerCase()==="toolresult"||t.push({kind:"message",key:Ja(o,a),message:o})}if(e.showThinking)for(let a=0;a<s.length;a++)t.push({kind:"message",key:Ja(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 xh(t)}function Ja(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,r=typeof n.role=="string"?n.role:"unknown";return o!=null?`msg:${r}:${o}:${t}`:`msg:${r}:${t}`}function me(e){if(e)return Array.isArray(e.type)?e.type.filter(n=>n!=="null")[0]??e.type[0]:e.type}function Nr(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 Ln(e){return e.filter(t=>typeof t=="string").join(".")}function ie(e,t){const n=Ln(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 r=a.split(".");if(r.length!==i.length)continue;let l=!0;for(let u=0;u<i.length;u+=1)if(r[u]!=="*"&&r[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 Sh(e){const t=Ln(e).toLowerCase();return t.includes("token")||t.includes("password")||t.includes("secret")||t.includes("apikey")||t.endsWith("key")}const Ah=new Set(["title","description","default","nullable"]);function _h(e){return Object.keys(e??{}).filter(n=>!Ah.has(n)).length===0}function Th(e){if(e===void 0)return"";try{return JSON.stringify(e,null,2)??""}catch{return""}}const Ot={chevronDown:c`<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:c`<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:c`<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:c`<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:c`<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:r}=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=Ln(s);if(a.has(m))return c`<div class="cfg-field cfg-field--error">
366
+ `}const Ja=200;function kh(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=fr(s.message),a=mi(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 Sh(e){const t=[],n=Array.isArray(e.messages)?e.messages:[],s=Array.isArray(e.toolMessages)?e.toolMessages:[],i=Math.max(0,n.length-Ja);i>0&&t.push({kind:"message",key:"chat:history:notice",message:{role:"system",content:`Showing last ${Ja} messages (${i} hidden).`,timestamp:Date.now()}});for(let a=i;a<n.length;a++){const o=n[a],c=fr(o);!e.showThinking&&c.role.toLowerCase()==="toolresult"||t.push({kind:"message",key:Za(o,a),message:o})}if(e.showThinking)for(let a=0;a<s.length;a++)t.push({kind:"message",key:Za(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 kh(t)}function Za(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 Nr(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 r=!0;for(let u=0;u<i.length;u+=1)if(c[u]!=="*"&&c[u]!==i[u]){r=!1;break}if(r)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 Ah(e){const t=Pn(e).toLowerCase();return t.includes("token")||t.includes("password")||t.includes("secret")||t.includes("apikey")||t.endsWith("key")}const _h=new Set(["title","description","default","nullable"]);function Th(e){return Object.keys(e??{}).filter(n=>!_h.has(n)).length===0}function Ch(e){if(e===void 0)return"";try{return JSON.stringify(e,null,2)??""}catch{return""}}const Dt={chevronDown:l`<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:l`<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:l`<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:l`<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:l`<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,r=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 l`<div class="cfg-field cfg-field--error">
367
367
  <div class="cfg-field__label">${p}</div>
368
368
  <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 c`
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 l`
370
370
  <div class="cfg-field">
371
- ${l?c`<label class="cfg-field__label">${p}</label>`:g}
372
- ${f?c`<div class="cfg-field__help">${f}</div>`:g}
371
+ ${r?l`<label class="cfg-field__label">${p}</label>`:g}
372
+ ${f?l`<div class="cfg-field__help">${f}</div>`:g}
373
373
  <div class="cfg-segmented">
374
- ${_.map((E,ve)=>c`
374
+ ${_.map((E,ve)=>l`
375
375
  <button
376
376
  type="button"
377
377
  class="cfg-segmented__btn ${E===C||String(E)===String(C)?"active":""}"
378
378
  ?disabled=${o}
379
- @click=${()=>r(s,E)}
379
+ @click=${()=>c(s,E)}
380
380
  >
381
381
  ${String(E)}
382
382
  </button>
383
383
  `)}
384
384
  </div>
385
385
  </div>
386
- `}if(M&&_.length>5)return Xa({...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 Za({...e,inputType:E&&!C?"number":"text"})}}if(t.enum){const v=t.enum;if(v.length<=5){const $=n??t.default;return c`
386
+ `}if(M&&_.length>5)return eo({...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 Xa({...e,inputType:E&&!C?"number":"text"})}}if(t.enum){const v=t.enum;if(v.length<=5){const $=n??t.default;return l`
387
387
  <div class="cfg-field">
388
- ${l?c`<label class="cfg-field__label">${p}</label>`:g}
389
- ${f?c`<div class="cfg-field__help">${f}</div>`:g}
388
+ ${r?l`<label class="cfg-field__label">${p}</label>`:g}
389
+ ${f?l`<div class="cfg-field__help">${f}</div>`:g}
390
390
  <div class="cfg-segmented">
391
- ${v.map(k=>c`
391
+ ${v.map(k=>l`
392
392
  <button
393
393
  type="button"
394
394
  class="cfg-segmented__btn ${k===$||String(k)===String($)?"active":""}"
395
395
  ?disabled=${o}
396
- @click=${()=>r(s,k)}
396
+ @click=${()=>c(s,k)}
397
397
  >
398
398
  ${String(k)}
399
399
  </button>
400
400
  `)}
401
401
  </div>
402
402
  </div>
403
- `}return Xa({...e,options:v,value:n??t.default})}if(u==="object")return Eh(e);if(u==="array")return Rh(e);if(u==="boolean"){const v=typeof n=="boolean"?n:typeof t.default=="boolean"?t.default:!1;return c`
403
+ `}return eo({...e,options:v,value:n??t.default})}if(u==="object")return Rh(e);if(u==="array")return Mh(e);if(u==="boolean"){const v=typeof n=="boolean"?n:typeof t.default=="boolean"?t.default:!1;return l`
404
404
  <label class="cfg-toggle-row ${o?"disabled":""}">
405
405
  <div class="cfg-toggle-row__content">
406
406
  <span class="cfg-toggle-row__label">${p}</span>
407
- ${f?c`<span class="cfg-toggle-row__help">${f}</span>`:g}
407
+ ${f?l`<span class="cfg-toggle-row__help">${f}</span>`:g}
408
408
  </div>
409
409
  <div class="cfg-toggle">
410
410
  <input
411
411
  type="checkbox"
412
412
  .checked=${v}
413
413
  ?disabled=${o}
414
- @change=${$=>r(s,$.target.checked)}
414
+ @change=${$=>c(s,$.target.checked)}
415
415
  />
416
416
  <span class="cfg-toggle__track"></span>
417
417
  </div>
418
418
  </label>
419
- `}return u==="number"||u==="integer"?Ch(e):u==="string"?Za({...e,inputType:"text"}):c`
419
+ `}return u==="number"||u==="integer"?Eh(e):u==="string"?Xa({...e,inputType:"text"}):l`
420
420
  <div class="cfg-field cfg-field--error">
421
421
  <div class="cfg-field__label">${p}</div>
422
422
  <div class="cfg-field__error">Unsupported type: ${u}. Use Raw mode.</div>
423
423
  </div>
424
- `}function Za(e){const{schema:t,value:n,path:s,hints:i,disabled:a,onPatch:o,inputType:r}=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??Sh(s),m=u?.placeholder??(f?"••••":t.default!==void 0?`Default: ${t.default}`:""),v=n??"";return c`
424
+ `}function Xa(e){const{schema:t,value:n,path:s,hints:i,disabled:a,onPatch:o,inputType:c}=e,r=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??Ah(s),m=u?.placeholder??(f?"••••":t.default!==void 0?`Default: ${t.default}`:""),v=n??"";return l`
425
425
  <div class="cfg-field">
426
- ${l?c`<label class="cfg-field__label">${d}</label>`:g}
427
- ${p?c`<div class="cfg-field__help">${p}</div>`:g}
426
+ ${r?l`<label class="cfg-field__label">${d}</label>`:g}
427
+ ${p?l`<div class="cfg-field__help">${p}</div>`:g}
428
428
  <div class="cfg-input-wrap">
429
429
  <input
430
- type=${f?"password":r}
430
+ type=${f?"password":c}
431
431
  class="cfg-input"
432
432
  placeholder=${m}
433
433
  .value=${v==null?"":String(v)}
434
434
  ?disabled=${a}
435
- @input=${$=>{const k=$.target.value;if(r==="number"){if(k.trim()===""){o(s,void 0);return}const _=Number(k);o(s,Number.isNaN(_)?k:_);return}o(s,k)}}
435
+ @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
436
  />
437
- ${t.default!==void 0?c`
437
+ ${t.default!==void 0?l`
438
438
  <button
439
439
  type="button"
440
440
  class="cfg-input__reset"
@@ -445,10 +445,10 @@ ${e.sidebarContent}
445
445
  `:g}
446
446
  </div>
447
447
  </div>
448
- `}function Ch(e){const{schema:t,value:n,path:s,hints:i,disabled:a,onPatch:o}=e,r=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 c`
448
+ `}function Eh(e){const{schema:t,value:n,path:s,hints:i,disabled:a,onPatch:o}=e,c=e.showLabel??!0,r=ie(s,i),u=r?.label??t.title??Te(String(s.at(-1))),d=r?.help??t.description,p=n??t.default??"",f=typeof p=="number"?p:0;return l`
449
449
  <div class="cfg-field">
450
- ${r?c`<label class="cfg-field__label">${u}</label>`:g}
451
- ${d?c`<div class="cfg-field__help">${d}</div>`:g}
450
+ ${c?l`<label class="cfg-field__label">${u}</label>`:g}
451
+ ${d?l`<div class="cfg-field__help">${d}</div>`:g}
452
452
  <div class="cfg-number">
453
453
  <button
454
454
  type="button"
@@ -471,68 +471,68 @@ ${e.sidebarContent}
471
471
  >+</button>
472
472
  </div>
473
473
  </div>
474
- `}function Xa(e){const{schema:t,value:n,path:s,hints:i,disabled:a,options:o,onPatch:r}=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 c`
474
+ `}function eo(e){const{schema:t,value:n,path:s,hints:i,disabled:a,options:o,onPatch:c}=e,r=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 l`
475
475
  <div class="cfg-field">
476
- ${l?c`<label class="cfg-field__label">${d}</label>`:g}
477
- ${p?c`<div class="cfg-field__help">${p}</div>`:g}
476
+ ${r?l`<label class="cfg-field__label">${d}</label>`:g}
477
+ ${p?l`<div class="cfg-field__help">${p}</div>`:g}
478
478
  <select
479
479
  class="cfg-select"
480
480
  ?disabled=${a}
481
481
  .value=${m>=0?String(m):v}
482
- @change=${$=>{const k=$.target.value;r(s,k===v?void 0:o[Number(k)])}}
482
+ @change=${$=>{const k=$.target.value;c(s,k===v?void 0:o[Number(k)])}}
483
483
  >
484
484
  <option value=${v}>Select...</option>
485
- ${o.map(($,k)=>c`
485
+ ${o.map(($,k)=>l`
486
486
  <option value=${String(k)}>${String($)}</option>
487
487
  `)}
488
488
  </select>
489
489
  </div>
490
- `}function Eh(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:r}=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?c`
490
+ `}function Rh(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:c}=e;e.showLabel;const r=ie(s,i),u=r?.label??t.title??Te(String(s.at(-1))),d=r?.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?l`
491
491
  <div class="cfg-fields">
492
- ${$.map(([N,R])=>_e({schema:R,value:f[N],path:[...s,N],hints:i,unsupported:a,disabled:o,onPatch:r}))}
493
- ${M?eo({schema:_,value:f,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:k,onPatch:r}):g}
492
+ ${$.map(([N,R])=>_e({schema:R,value:f[N],path:[...s,N],hints:i,unsupported:a,disabled:o,onPatch:c}))}
493
+ ${M?to({schema:_,value:f,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:k,onPatch:c}):g}
494
494
  </div>
495
- `:c`
495
+ `:l`
496
496
  <details class="cfg-object" open>
497
497
  <summary class="cfg-object__header">
498
498
  <span class="cfg-object__title">${u}</span>
499
- <span class="cfg-object__chevron">${Ot.chevronDown}</span>
499
+ <span class="cfg-object__chevron">${Dt.chevronDown}</span>
500
500
  </summary>
501
- ${d?c`<div class="cfg-object__help">${d}</div>`:g}
501
+ ${d?l`<div class="cfg-object__help">${d}</div>`:g}
502
502
  <div class="cfg-object__content">
503
- ${$.map(([N,R])=>_e({schema:R,value:f[N],path:[...s,N],hints:i,unsupported:a,disabled:o,onPatch:r}))}
504
- ${M?eo({schema:_,value:f,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:k,onPatch:r}):g}
503
+ ${$.map(([N,R])=>_e({schema:R,value:f[N],path:[...s,N],hints:i,unsupported:a,disabled:o,onPatch:c}))}
504
+ ${M?to({schema:_,value:f,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:k,onPatch:c}):g}
505
505
  </div>
506
506
  </details>
507
- `}function Rh(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:r}=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 c`
507
+ `}function Mh(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:c}=e,r=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 l`
508
508
  <div class="cfg-field cfg-field--error">
509
509
  <div class="cfg-field__label">${d}</div>
510
510
  <div class="cfg-field__error">Unsupported array schema. Use Raw mode.</div>
511
511
  </div>
512
- `;const m=Array.isArray(n)?n:Array.isArray(t.default)?t.default:[];return c`
512
+ `;const m=Array.isArray(n)?n:Array.isArray(t.default)?t.default:[];return l`
513
513
  <div class="cfg-array">
514
514
  <div class="cfg-array__header">
515
- ${l?c`<span class="cfg-array__label">${d}</span>`:g}
515
+ ${r?l`<span class="cfg-array__label">${d}</span>`:g}
516
516
  <span class="cfg-array__count">${m.length} item${m.length!==1?"s":""}</span>
517
517
  <button
518
518
  type="button"
519
519
  class="cfg-array__add"
520
520
  ?disabled=${o}
521
- @click=${()=>{const v=[...m,Nr(f)];r(s,v)}}
521
+ @click=${()=>{const v=[...m,Nr(f)];c(s,v)}}
522
522
  >
523
- <span class="cfg-array__add-icon">${Ot.plus}</span>
523
+ <span class="cfg-array__add-icon">${Dt.plus}</span>
524
524
  Add
525
525
  </button>
526
526
  </div>
527
- ${p?c`<div class="cfg-array__help">${p}</div>`:g}
527
+ ${p?l`<div class="cfg-array__help">${p}</div>`:g}
528
528
 
529
- ${m.length===0?c`
529
+ ${m.length===0?l`
530
530
  <div class="cfg-array__empty">
531
531
  No items yet. Click "Add" to create one.
532
532
  </div>
533
- `:c`
533
+ `:l`
534
534
  <div class="cfg-array__items">
535
- ${m.map((v,$)=>c`
535
+ ${m.map((v,$)=>l`
536
536
  <div class="cfg-array__item">
537
537
  <div class="cfg-array__item-header">
538
538
  <span class="cfg-array__item-index">#${$+1}</span>
@@ -541,20 +541,20 @@ ${e.sidebarContent}
541
541
  class="cfg-array__item-remove"
542
542
  title="Remove item"
543
543
  ?disabled=${o}
544
- @click=${()=>{const k=[...m];k.splice($,1),r(s,k)}}
544
+ @click=${()=>{const k=[...m];k.splice($,1),c(s,k)}}
545
545
  >
546
- ${Ot.trash}
546
+ ${Dt.trash}
547
547
  </button>
548
548
  </div>
549
549
  <div class="cfg-array__item-content">
550
- ${_e({schema:f,value:v,path:[...s,$],hints:i,unsupported:a,disabled:o,showLabel:!1,onPatch:r})}
550
+ ${_e({schema:f,value:v,path:[...s,$],hints:i,unsupported:a,disabled:o,showLabel:!1,onPatch:c})}
551
551
  </div>
552
552
  </div>
553
553
  `)}
554
554
  </div>
555
555
  `}
556
556
  </div>
557
- `}function eo(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:r,onPatch:l}=e,u=_h(t),d=Object.entries(n??{}).filter(([p])=>!r.has(p));return c`
557
+ `}function to(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:c,onPatch:r}=e,u=Th(t),d=Object.entries(n??{}).filter(([p])=>!c.has(p));return l`
558
558
  <div class="cfg-map">
559
559
  <div class="cfg-map__header">
560
560
  <span class="cfg-map__label">Custom entries</span>
@@ -562,18 +562,18 @@ ${e.sidebarContent}
562
562
  type="button"
563
563
  class="cfg-map__add"
564
564
  ?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?{}:Nr(t),l(s,p)}}
565
+ @click=${()=>{const p={...n??{}};let f=1,m=`custom-${f}`;for(;m in p;)f+=1,m=`custom-${f}`;p[m]=u?{}:Nr(t),r(s,p)}}
566
566
  >
567
- <span class="cfg-map__add-icon">${Ot.plus}</span>
567
+ <span class="cfg-map__add-icon">${Dt.plus}</span>
568
568
  Add Entry
569
569
  </button>
570
570
  </div>
571
571
 
572
- ${d.length===0?c`
572
+ ${d.length===0?l`
573
573
  <div class="cfg-map__empty">No custom entries.</div>
574
- `:c`
574
+ `:l`
575
575
  <div class="cfg-map__items">
576
- ${d.map(([p,f])=>{const m=[...s,p],v=Th(f);return c`
576
+ ${d.map(([p,f])=>{const m=[...s,p],v=Ch(f);return l`
577
577
  <div class="cfg-map__item">
578
578
  <div class="cfg-map__item-key">
579
579
  <input
@@ -582,64 +582,64 @@ ${e.sidebarContent}
582
582
  placeholder="Key"
583
583
  .value=${p}
584
584
  ?disabled=${o}
585
- @change=${$=>{const k=$.target.value.trim();if(!k||k===p)return;const _={...n??{}};k in _||(_[k]=_[p],delete _[p],l(s,_))}}
585
+ @change=${$=>{const k=$.target.value.trim();if(!k||k===p)return;const _={...n??{}};k in _||(_[k]=_[p],delete _[p],r(s,_))}}
586
586
  />
587
587
  </div>
588
588
  <div class="cfg-map__item-value">
589
- ${u?c`
589
+ ${u?l`
590
590
  <textarea
591
591
  class="cfg-textarea cfg-textarea--sm"
592
592
  placeholder="JSON value"
593
593
  rows="2"
594
594
  .value=${v}
595
595
  ?disabled=${o}
596
- @change=${$=>{const k=$.target,_=k.value.trim();if(!_){l(m,void 0);return}try{l(m,JSON.parse(_))}catch{k.value=v}}}
596
+ @change=${$=>{const k=$.target,_=k.value.trim();if(!_){r(m,void 0);return}try{r(m,JSON.parse(_))}catch{k.value=v}}}
597
597
  ></textarea>
598
- `:_e({schema:t,value:f,path:m,hints:i,unsupported:a,disabled:o,showLabel:!1,onPatch:l})}
598
+ `:_e({schema:t,value:f,path:m,hints:i,unsupported:a,disabled:o,showLabel:!1,onPatch:r})}
599
599
  </div>
600
600
  <button
601
601
  type="button"
602
602
  class="cfg-map__item-remove"
603
603
  title="Remove entry"
604
604
  ?disabled=${o}
605
- @click=${()=>{const $={...n??{}};delete $[p],l(s,$)}}
605
+ @click=${()=>{const $={...n??{}};delete $[p],r(s,$)}}
606
606
  >
607
- ${Ot.trash}
607
+ ${Dt.trash}
608
608
  </button>
609
609
  </div>
610
610
  `})}
611
611
  </div>
612
612
  `}
613
613
  </div>
614
- `}const to={env:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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>`},Ti={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 no(e){return to[e]??to.default}function Mh(e,t,n){if(!n)return!0;const s=n.toLowerCase(),i=Ti[e];return e.toLowerCase().includes(s)||i&&(i.label.toLowerCase().includes(s)||i.description.toLowerCase().includes(s))?!0:_t(t,s)}function _t(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)||_t(i,t))return!0}if(e.items){const s=Array.isArray(e.items)?e.items:[e.items];for(const i of s)if(i&&_t(i,t))return!0}if(e.additionalProperties&&typeof e.additionalProperties=="object"&&_t(e.additionalProperties,t))return!0;const n=e.anyOf??e.oneOf??e.allOf;if(n){for(const s of n)if(s&&_t(s,t))return!0}return!1}function Ih(e){if(!e.schema)return c`<div class="muted">Schema unavailable.</div>`;const t=e.schema,n=e.value??{};if(me(t)!=="object"||!t.properties)return c`<div class="callout danger">Unsupported schema. Use Raw.</div>`;const s=new Set(e.unsupportedPaths??[]),i=t.properties,a=e.searchQuery??"",o=e.activeSection,r=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&&!Mh(p,f,a)));let d=null;if(o&&r&&u.length===1){const p=u[0]?.[1];p&&me(p)==="object"&&p.properties&&p.properties[r]&&(d={sectionKey:o,subsectionKey:r,schema:p.properties[r]})}return u.length===0?c`
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`
615
615
  <div class="config-empty">
616
616
  <div class="config-empty__icon">${G.search}</div>
617
617
  <div class="config-empty__text">
618
618
  ${a?`No settings match "${a}"`:"No settings in this section"}
619
619
  </div>
620
620
  </div>
621
- `:c`
621
+ `:l`
622
622
  <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 c`
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 l`
624
624
  <section class="config-section-card" id=${N}>
625
625
  <div class="config-section-card__header">
626
- <span class="config-section-card__icon">${no(p)}</span>
626
+ <span class="config-section-card__icon">${so(p)}</span>
627
627
  <div class="config-section-card__titles">
628
628
  <h3 class="config-section-card__title">${$}</h3>
629
- ${k?c`<p class="config-section-card__desc">${k}</p>`:g}
629
+ ${k?l`<p class="config-section-card__desc">${k}</p>`:g}
630
630
  </div>
631
631
  </div>
632
632
  <div class="config-section-card__content">
633
633
  ${_e({schema:m,value:M,path:[p,f],hints:e.uiHints,unsupported:s,disabled:e.disabled??!1,showLabel:!1,onPatch:e.onPatch})}
634
634
  </div>
635
635
  </section>
636
- `})():u.map(([p,f])=>{const m=Ti[p]??{label:p.charAt(0).toUpperCase()+p.slice(1),description:f.description??""};return c`
636
+ `})():u.map(([p,f])=>{const m=Ci[p]??{label:p.charAt(0).toUpperCase()+p.slice(1),description:f.description??""};return l`
637
637
  <section class="config-section-card" id="config-section-${p}">
638
638
  <div class="config-section-card__header">
639
- <span class="config-section-card__icon">${no(p)}</span>
639
+ <span class="config-section-card__icon">${so(p)}</span>
640
640
  <div class="config-section-card__titles">
641
641
  <h3 class="config-section-card__title">${m.label}</h3>
642
- ${m.description?c`<p class="config-section-card__desc">${m.description}</p>`:g}
642
+ ${m.description?l`<p class="config-section-card__desc">${m.description}</p>`:g}
643
643
  </div>
644
644
  </div>
645
645
  <div class="config-section-card__content">
@@ -648,7 +648,7 @@ ${e.sidebarContent}
648
648
  </section>
649
649
  `})}
650
650
  </div>
651
- `}const Lh=new Set(["title","description","default","nullable"]);function Ph(e){return Object.keys(e??{}).filter(n=>!Lh.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>"]}:Ct(e,[])}function Ct(e,t){const n=new Set,s={...e},i=Ln(t)||"<root>";if(e.anyOf||e.oneOf||e.allOf){const r=Nh(e,t);return r||{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:r,nullable:l}=Or(s.enum);s.enum=r,l&&(s.nullable=!0),r.length===0&&n.add(i)}if(o==="object"){const r=e.properties??{},l={};for(const[u,d]of Object.entries(r)){const p=Ct(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"&&!Ph(e.additionalProperties)){const u=Ct(e.additionalProperties,[...t,"*"]);s.additionalProperties=u.schema??e.additionalProperties,u.unsupportedPaths.length>0&&n.add(i)}}else if(o==="array"){const r=Array.isArray(e.items)?e.items[0]:e.items;if(!r)n.add(i);else{const l=Ct(r,[...t,"*"]);s.items=l.schema??r,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 Nh(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 r of n){if(!r||typeof r!="object")return null;if(Array.isArray(r.enum)){const{enumValues:l,nullable:u}=Or(r.enum);s.push(...l),u&&(a=!0);continue}if("const"in r){if(r.const==null){a=!0;continue}s.push(r.const);continue}if(me(r)==="null"){a=!0;continue}i.push(r)}if(s.length>0&&i.length===0){const r=[];for(const l of s)r.some(u=>Object.is(u,l))||r.push(l);return{schema:{...e,enum:r,nullable:a,anyOf:void 0,oneOf:void 0,allOf:void 0},unsupportedPaths:[]}}if(i.length===1){const r=Ct(i[0],t);return r.schema&&(r.schema.nullable=a||r.schema.nullable),r}const o=["string","number","integer","boolean"];return i.length>0&&s.length===0&&i.every(r=>r.type&&o.includes(String(r.type)))?{schema:{...e,nullable:a},unsupportedPaths:[]}:null}const Hs={all:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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:c`<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>`},so=[{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"}],io="__all__";function ao(e){return Hs[e]??Hs.default}function Oh(e,t){const n=Ti[e];return n||{label:t?.title??Te(e),description:t?.description??""}}function Dh(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 r=ie([t,a],s),l=r?.label??o.title??Te(a),u=r?.help??o.description??"",d=r?.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 Bh(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 r=i,l=a,u=new Set([...Object.keys(r),...Object.keys(l)]);for(const d of u)s(r[d],l[d],o?`${o}.${d}`:d)}return s(e,t,""),n}function oo(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 Fh(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=so.filter(E=>E.key in i),o=new Set(so.map(E=>E.key)),r=Object.keys(i).filter(E=>!o.has(E)).map(E=>({key:E,label:E.charAt(0).toUpperCase()+E.slice(1)})),l=[...a,...r],u=e.activeSection&&n.schema&&me(n.schema)==="object"?n.schema.properties?.[e.activeSection]:void 0,d=e.activeSection?Oh(e.activeSection,u):null,p=e.activeSection?Dh({key:e.activeSection,schema:u,uiHints:e.uiHints}):[],f=e.formMode==="form"&&!!e.activeSection&&p.length>0,m=e.activeSubsection===io,v=e.searchQuery||m?null:e.activeSubsection??p[0]?.key??null,$=e.formMode==="form"?Bh(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 c`
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`
652
652
  <div class="config-layout">
653
653
  <!-- Sidebar -->
654
654
  <aside class="config-sidebar">
@@ -670,7 +670,7 @@ ${e.sidebarContent}
670
670
  .value=${e.searchQuery}
671
671
  @input=${E=>e.onSearchChange(E.target.value)}
672
672
  />
673
- ${e.searchQuery?c`
673
+ ${e.searchQuery?l`
674
674
  <button
675
675
  class="config-search__clear"
676
676
  @click=${()=>e.onSearchChange("")}
@@ -684,15 +684,15 @@ ${e.sidebarContent}
684
684
  class="config-nav__item ${e.activeSection===null?"active":""}"
685
685
  @click=${()=>e.onSectionChange(null)}
686
686
  >
687
- <span class="config-nav__icon">${Hs.all}</span>
687
+ <span class="config-nav__icon">${js.all}</span>
688
688
  <span class="config-nav__label">All Settings</span>
689
689
  </button>
690
- ${l.map(E=>c`
690
+ ${r.map(E=>l`
691
691
  <button
692
692
  class="config-nav__item ${e.activeSection===E.key?"active":""}"
693
693
  @click=${()=>e.onSectionChange(E.key)}
694
694
  >
695
- <span class="config-nav__icon">${ao(E.key)}</span>
695
+ <span class="config-nav__icon">${oo(E.key)}</span>
696
696
  <span class="config-nav__label">${E.label}</span>
697
697
  </button>
698
698
  `)}
@@ -723,9 +723,9 @@ ${e.sidebarContent}
723
723
  <!-- Action bar -->
724
724
  <div class="config-actions">
725
725
  <div class="config-actions__left">
726
- ${_?c`
726
+ ${_?l`
727
727
  <span class="config-changes-badge">${e.formMode==="raw"?"Unsaved changes":`${$.length} unsaved change${$.length!==1?"s":""}`}</span>
728
- `:c`
728
+ `:l`
729
729
  <span class="config-status muted">No changes</span>
730
730
  `}
731
731
  </div>
@@ -758,7 +758,7 @@ ${e.sidebarContent}
758
758
  </div>
759
759
 
760
760
  <!-- Diff panel (form mode only - raw mode doesn't have granular diff) -->
761
- ${_&&e.formMode==="form"?c`
761
+ ${_&&e.formMode==="form"?l`
762
762
  <details class="config-diff">
763
763
  <summary class="config-diff__summary">
764
764
  <span>View ${$.length} pending change${$.length!==1?"s":""}</span>
@@ -767,13 +767,13 @@ ${e.sidebarContent}
767
767
  </svg>
768
768
  </summary>
769
769
  <div class="config-diff__content">
770
- ${$.map(E=>c`
770
+ ${$.map(E=>l`
771
771
  <div class="config-diff__item">
772
772
  <div class="config-diff__path">${E.path}</div>
773
773
  <div class="config-diff__values">
774
- <span class="config-diff__from">${oo(E.from)}</span>
774
+ <span class="config-diff__from">${ro(E.from)}</span>
775
775
  <span class="config-diff__arrow">→</span>
776
- <span class="config-diff__to">${oo(E.to)}</span>
776
+ <span class="config-diff__to">${ro(E.to)}</span>
777
777
  </div>
778
778
  </div>
779
779
  `)}
@@ -781,25 +781,25 @@ ${e.sidebarContent}
781
781
  </details>
782
782
  `:g}
783
783
 
784
- ${d&&e.formMode==="form"?c`
784
+ ${d&&e.formMode==="form"?l`
785
785
  <div class="config-section-hero">
786
- <div class="config-section-hero__icon">${ao(e.activeSection??"")}</div>
786
+ <div class="config-section-hero__icon">${oo(e.activeSection??"")}</div>
787
787
  <div class="config-section-hero__text">
788
788
  <div class="config-section-hero__title">${d.label}</div>
789
- ${d.description?c`<div class="config-section-hero__desc">${d.description}</div>`:g}
789
+ ${d.description?l`<div class="config-section-hero__desc">${d.description}</div>`:g}
790
790
  </div>
791
791
  </div>
792
792
  `:g}
793
793
 
794
- ${f?c`
794
+ ${f?l`
795
795
  <div class="config-subnav">
796
796
  <button
797
797
  class="config-subnav__item ${v===null?"active":""}"
798
- @click=${()=>e.onSubsectionChange(io)}
798
+ @click=${()=>e.onSubsectionChange(ao)}
799
799
  >
800
800
  All
801
801
  </button>
802
- ${p.map(E=>c`
802
+ ${p.map(E=>l`
803
803
  <button
804
804
  class="config-subnav__item ${v===E.key?"active":""}"
805
805
  title=${E.description||E.label}
@@ -813,16 +813,16 @@ ${e.sidebarContent}
813
813
 
814
814
  <!-- Form content -->
815
815
  <div class="config-content">
816
- ${e.formMode==="form"?c`
817
- ${e.schemaLoading?c`<div class="config-loading">
816
+ ${e.formMode==="form"?l`
817
+ ${e.schemaLoading?l`<div class="config-loading">
818
818
  <div class="config-loading__spinner"></div>
819
819
  <span>Loading schema…</span>
820
- </div>`:Ih({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})}
821
- ${s?c`<div class="callout danger" style="margin-top: 12px;">
820
+ </div>`:Lh({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})}
821
+ ${s?l`<div class="callout danger" style="margin-top: 12px;">
822
822
  Form view can't safely edit some fields.
823
823
  Use Raw to avoid losing config entries.
824
824
  </div>`:g}
825
- `:c`
825
+ `:l`
826
826
  <label class="field config-raw-field">
827
827
  <span>Raw JSON5</span>
828
828
  <textarea
@@ -833,18 +833,18 @@ ${e.sidebarContent}
833
833
  `}
834
834
  </div>
835
835
 
836
- ${e.issues.length>0?c`<div class="callout danger" style="margin-top: 12px;">
836
+ ${e.issues.length>0?l`<div class="callout danger" style="margin-top: 12px;">
837
837
  <pre class="code-block">${JSON.stringify(e.issues,null,2)}</pre>
838
838
  </div>`:g}
839
839
  </main>
840
840
  </div>
841
- `}function Uh(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 Kh(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,r=typeof i?.connected=="boolean"&&i.connected,u=(n.channelAccounts?.[e]??[]).some(d=>d.configured||d.running||d.connected);return a||o||r||u}function zh(e,t){return t?.[e]?.length??0}function Br(e,t){const n=zh(e,t);return n<2?g:c`<div class="account-count">Accounts (${n})</div>`}function Hh(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 jh(e,t){const s=(e.channels??{})[t],i=e[t];return(s&&typeof s=="object"?s:null)??(i&&typeof i=="object"?i:null)??{}}function Vh(e){const t=Dr(e.schema),n=t.schema;if(!n)return c`<div class="callout danger">Schema unavailable. Use Raw.</div>`;const s=Hh(n,["channels",e.channelId]);if(!s)return c`<div class="callout danger">Channel config schema unavailable.</div>`;const i=e.configValue??{},a=jh(i,e.channelId);return c`
841
+ `}function Kh(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 zh(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 Hh(e,t){return t?.[e]?.length??0}function Br(e,t){const n=Hh(e,t);return n<2?g:l`<div class="account-count">Accounts (${n})</div>`}function jh(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 Vh(e,t){const s=(e.channels??{})[t],i=e[t];return(s&&typeof s=="object"?s:null)??(i&&typeof i=="object"?i:null)??{}}function Wh(e){const t=Dr(e.schema),n=t.schema;if(!n)return l`<div class="callout danger">Schema unavailable. Use Raw.</div>`;const s=jh(n,["channels",e.channelId]);if(!s)return l`<div class="callout danger">Channel config schema unavailable.</div>`;const i=e.configValue??{},a=Vh(i,e.channelId);return l`
842
842
  <div class="config-form">
843
843
  ${_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
844
  </div>
845
- `}function Ce(e){const{channelId:t,props:n}=e,s=n.configSaving||n.configSchemaLoading;return c`
845
+ `}function Ce(e){const{channelId:t,props:n}=e,s=n.configSaving||n.configSchemaLoading;return l`
846
846
  <div style="margin-top: 16px;">
847
- ${n.configSchemaLoading?c`<div class="muted">Loading config schema…</div>`:Vh({channelId:t,configValue:n.configForm,schema:n.configSchema,uiHints:n.configUiHints,disabled:s,onPatch:n.onConfigPatch})}
847
+ ${n.configSchemaLoading?l`<div class="muted">Loading config schema…</div>`:Wh({channelId:t,configValue:n.configForm,schema:n.configSchema,uiHints:n.configUiHints,disabled:s,onPatch:n.onConfigPatch})}
848
848
  <div class="row" style="margin-top: 12px;">
849
849
  <button
850
850
  class="btn primary"
@@ -862,7 +862,7 @@ ${e.sidebarContent}
862
862
  </button>
863
863
  </div>
864
864
  </div>
865
- `}function Wh(e){const{props:t,discord:n,accountCountLabel:s}=e;return c`
865
+ `}function qh(e){const{props:t,discord:n,accountCountLabel:s}=e;return l`
866
866
  <div class="card">
867
867
  <div class="card-title">Discord</div>
868
868
  <div class="card-sub">Bot status and channel configuration.</div>
@@ -879,19 +879,19 @@ ${e.sidebarContent}
879
879
  </div>
880
880
  <div>
881
881
  <span class="label">Last start</span>
882
- <span>${n?.lastStartAt?B(n.lastStartAt):"n/a"}</span>
882
+ <span>${n?.lastStartAt?D(n.lastStartAt):"n/a"}</span>
883
883
  </div>
884
884
  <div>
885
885
  <span class="label">Last probe</span>
886
- <span>${n?.lastProbeAt?B(n.lastProbeAt):"n/a"}</span>
886
+ <span>${n?.lastProbeAt?D(n.lastProbeAt):"n/a"}</span>
887
887
  </div>
888
888
  </div>
889
889
 
890
- ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
890
+ ${n?.lastError?l`<div class="callout danger" style="margin-top: 12px;">
891
891
  ${n.lastError}
892
892
  </div>`:g}
893
893
 
894
- ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
894
+ ${n?.probe?l`<div class="callout" style="margin-top: 12px;">
895
895
  Probe ${n.probe.ok?"ok":"failed"} ·
896
896
  ${n.probe.status??""} ${n.probe.error??""}
897
897
  </div>`:g}
@@ -904,7 +904,7 @@ ${e.sidebarContent}
904
904
  </button>
905
905
  </div>
906
906
  </div>
907
- `}function qh(e){const{props:t,googleChat:n,accountCountLabel:s}=e;return c`
907
+ `}function Gh(e){const{props:t,googleChat:n,accountCountLabel:s}=e;return l`
908
908
  <div class="card">
909
909
  <div class="card-title">Google Chat</div>
910
910
  <div class="card-sub">Chat API webhook status and channel configuration.</div>
@@ -931,19 +931,19 @@ ${e.sidebarContent}
931
931
  </div>
932
932
  <div>
933
933
  <span class="label">Last start</span>
934
- <span>${n?.lastStartAt?B(n.lastStartAt):"n/a"}</span>
934
+ <span>${n?.lastStartAt?D(n.lastStartAt):"n/a"}</span>
935
935
  </div>
936
936
  <div>
937
937
  <span class="label">Last probe</span>
938
- <span>${n?.lastProbeAt?B(n.lastProbeAt):"n/a"}</span>
938
+ <span>${n?.lastProbeAt?D(n.lastProbeAt):"n/a"}</span>
939
939
  </div>
940
940
  </div>
941
941
 
942
- ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
942
+ ${n?.lastError?l`<div class="callout danger" style="margin-top: 12px;">
943
943
  ${n.lastError}
944
944
  </div>`:g}
945
945
 
946
- ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
946
+ ${n?.probe?l`<div class="callout" style="margin-top: 12px;">
947
947
  Probe ${n.probe.ok?"ok":"failed"} ·
948
948
  ${n.probe.status??""} ${n.probe.error??""}
949
949
  </div>`:g}
@@ -956,7 +956,7 @@ ${e.sidebarContent}
956
956
  </button>
957
957
  </div>
958
958
  </div>
959
- `}function Gh(e){const{props:t,imessage:n,accountCountLabel:s}=e;return c`
959
+ `}function Yh(e){const{props:t,imessage:n,accountCountLabel:s}=e;return l`
960
960
  <div class="card">
961
961
  <div class="card-title">iMessage</div>
962
962
  <div class="card-sub">macOS bridge status and channel configuration.</div>
@@ -973,19 +973,19 @@ ${e.sidebarContent}
973
973
  </div>
974
974
  <div>
975
975
  <span class="label">Last start</span>
976
- <span>${n?.lastStartAt?B(n.lastStartAt):"n/a"}</span>
976
+ <span>${n?.lastStartAt?D(n.lastStartAt):"n/a"}</span>
977
977
  </div>
978
978
  <div>
979
979
  <span class="label">Last probe</span>
980
- <span>${n?.lastProbeAt?B(n.lastProbeAt):"n/a"}</span>
980
+ <span>${n?.lastProbeAt?D(n.lastProbeAt):"n/a"}</span>
981
981
  </div>
982
982
  </div>
983
983
 
984
- ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
984
+ ${n?.lastError?l`<div class="callout danger" style="margin-top: 12px;">
985
985
  ${n.lastError}
986
986
  </div>`:g}
987
987
 
988
- ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
988
+ ${n?.probe?l`<div class="callout" style="margin-top: 12px;">
989
989
  Probe ${n.probe.ok?"ok":"failed"} ·
990
990
  ${n.probe.error??""}
991
991
  </div>`:g}
@@ -998,10 +998,10 @@ ${e.sidebarContent}
998
998
  </button>
999
999
  </div>
1000
1000
  </div>
1001
- `}function Yh(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 Qh(e){const{state:t,callbacks:n,accountId:s}=e,i=Yh(t),a=(r,l,u={})=>{const{type:d="text",placeholder:p,maxLength:f,help:m}=u,v=t.values[r]??"",$=t.fieldErrors[r],k=`nostr-profile-${r}`;return d==="textarea"?c`
1001
+ `}function Qh(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 Jh(e){const{state:t,callbacks:n,accountId:s}=e,i=Qh(t),a=(c,r,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"?l`
1002
1002
  <div class="form-field" style="margin-bottom: 12px;">
1003
1003
  <label for="${k}" style="display: block; margin-bottom: 4px; font-weight: 500;">
1004
- ${l}
1004
+ ${r}
1005
1005
  </label>
1006
1006
  <textarea
1007
1007
  id="${k}"
@@ -1010,16 +1010,16 @@ ${e.sidebarContent}
1010
1010
  maxlength=${f??2e3}
1011
1011
  rows="3"
1012
1012
  style="width: 100%; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px; resize: vertical; font-family: inherit;"
1013
- @input=${_=>{const M=_.target;n.onFieldChange(r,M.value)}}
1013
+ @input=${_=>{const M=_.target;n.onFieldChange(c,M.value)}}
1014
1014
  ?disabled=${t.saving}
1015
1015
  ></textarea>
1016
- ${m?c`<div style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">${m}</div>`:g}
1017
- ${$?c`<div style="font-size: 12px; color: var(--danger-color); margin-top: 2px;">${$}</div>`:g}
1016
+ ${m?l`<div style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">${m}</div>`:g}
1017
+ ${$?l`<div style="font-size: 12px; color: var(--danger-color); margin-top: 2px;">${$}</div>`:g}
1018
1018
  </div>
1019
- `:c`
1019
+ `:l`
1020
1020
  <div class="form-field" style="margin-bottom: 12px;">
1021
1021
  <label for="${k}" style="display: block; margin-bottom: 4px; font-weight: 500;">
1022
- ${l}
1022
+ ${r}
1023
1023
  </label>
1024
1024
  <input
1025
1025
  id="${k}"
@@ -1028,32 +1028,32 @@ ${e.sidebarContent}
1028
1028
  placeholder=${p??""}
1029
1029
  maxlength=${f??256}
1030
1030
  style="width: 100%; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px;"
1031
- @input=${_=>{const M=_.target;n.onFieldChange(r,M.value)}}
1031
+ @input=${_=>{const M=_.target;n.onFieldChange(c,M.value)}}
1032
1032
  ?disabled=${t.saving}
1033
1033
  />
1034
- ${m?c`<div style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">${m}</div>`:g}
1035
- ${$?c`<div style="font-size: 12px; color: var(--danger-color); margin-top: 2px;">${$}</div>`:g}
1034
+ ${m?l`<div style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">${m}</div>`:g}
1035
+ ${$?l`<div style="font-size: 12px; color: var(--danger-color); margin-top: 2px;">${$}</div>`:g}
1036
1036
  </div>
1037
- `},o=()=>{const r=t.values.picture;return r?c`
1037
+ `},o=()=>{const c=t.values.picture;return c?l`
1038
1038
  <div style="margin-bottom: 12px;">
1039
1039
  <img
1040
- src=${r}
1040
+ src=${c}
1041
1041
  alt="Profile picture preview"
1042
1042
  style="max-width: 80px; max-height: 80px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-color);"
1043
- @error=${l=>{const u=l.target;u.style.display="none"}}
1044
- @load=${l=>{const u=l.target;u.style.display="block"}}
1043
+ @error=${r=>{const u=r.target;u.style.display="none"}}
1044
+ @load=${r=>{const u=r.target;u.style.display="block"}}
1045
1045
  />
1046
1046
  </div>
1047
- `:g};return c`
1047
+ `:g};return l`
1048
1048
  <div class="nostr-profile-form" style="padding: 16px; background: var(--bg-secondary); border-radius: 8px; margin-top: 12px;">
1049
1049
  <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;">
1050
1050
  <div style="font-weight: 600; font-size: 16px;">Edit Profile</div>
1051
1051
  <div style="font-size: 12px; color: var(--text-muted);">Account: ${s}</div>
1052
1052
  </div>
1053
1053
 
1054
- ${t.error?c`<div class="callout danger" style="margin-bottom: 12px;">${t.error}</div>`:g}
1054
+ ${t.error?l`<div class="callout danger" style="margin-bottom: 12px;">${t.error}</div>`:g}
1055
1055
 
1056
- ${t.success?c`<div class="callout success" style="margin-bottom: 12px;">${t.success}</div>`:g}
1056
+ ${t.success?l`<div class="callout success" style="margin-bottom: 12px;">${t.success}</div>`:g}
1057
1057
 
1058
1058
  ${o()}
1059
1059
 
@@ -1065,7 +1065,7 @@ ${e.sidebarContent}
1065
1065
 
1066
1066
  ${a("picture","Avatar URL",{type:"url",placeholder:"https://example.com/avatar.jpg",help:"HTTPS URL to your profile picture"})}
1067
1067
 
1068
- ${t.showAdvanced?c`
1068
+ ${t.showAdvanced?l`
1069
1069
  <div style="border-top: 1px solid var(--border-color); padding-top: 12px; margin-top: 12px;">
1070
1070
  <div style="font-weight: 500; margin-bottom: 12px; color: var(--text-muted);">Advanced</div>
1071
1071
 
@@ -1112,11 +1112,11 @@ ${e.sidebarContent}
1112
1112
  </button>
1113
1113
  </div>
1114
1114
 
1115
- ${i?c`<div style="font-size: 12px; color: var(--warning-color); margin-top: 8px;">
1115
+ ${i?l`<div style="font-size: 12px; color: var(--warning-color); margin-top: 8px;">
1116
1116
  You have unsaved changes
1117
1117
  </div>`:g}
1118
1118
  </div>
1119
- `}function Jh(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 ro(e){return e?e.length<=20?e:`${e.slice(0,8)}...${e.slice(-8)}`:"n/a"}function Zh(e){const{props:t,nostr:n,nostrAccounts:s,accountCountLabel:i,profileFormState:a,profileFormCallbacks:o,onEditProfile:r}=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 c`
1119
+ `}function Zh(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 lo(e){return e?e.length<=20?e:`${e.slice(0,8)}...${e.slice(-8)}`:"n/a"}function Xh(e){const{props:t,nostr:n,nostrAccounts:s,accountCountLabel:i,profileFormState:a,profileFormCallbacks:o,onEditProfile:c}=e,r=s[0],u=n?.configured??r?.configured??!1,d=n?.running??r?.running??!1,p=n?.publicKey??r?.publicKey,f=n?.lastStartAt??r?.lastStartAt??null,m=n?.lastError??r?.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 l`
1120
1120
  <div class="account-card">
1121
1121
  <div class="account-card-header">
1122
1122
  <div class="account-card-title">${C}</div>
@@ -1133,65 +1133,65 @@ ${e.sidebarContent}
1133
1133
  </div>
1134
1134
  <div>
1135
1135
  <span class="label">Public Key</span>
1136
- <span class="monospace" title="${N??""}">${ro(N)}</span>
1136
+ <span class="monospace" title="${N??""}">${lo(N)}</span>
1137
1137
  </div>
1138
1138
  <div>
1139
1139
  <span class="label">Last inbound</span>
1140
- <span>${M.lastInboundAt?B(M.lastInboundAt):"n/a"}</span>
1140
+ <span>${M.lastInboundAt?D(M.lastInboundAt):"n/a"}</span>
1141
1141
  </div>
1142
- ${M.lastError?c`
1142
+ ${M.lastError?l`
1143
1143
  <div class="account-card-error">${M.lastError}</div>
1144
1144
  `:g}
1145
1145
  </div>
1146
1146
  </div>
1147
- `},_=()=>{if($&&o)return Qh({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??{},Pn=N||R||C||E||ve;return c`
1147
+ `},_=()=>{if($&&o)return Jh({state:a,callbacks:o,accountId:s[0]?.accountId??"default"});const M=r?.profile??n?.profile,{name:N,displayName:R,about:C,picture:E,nip05:ve}=M??{},Nn=N||R||C||E||ve;return l`
1148
1148
  <div style="margin-top: 16px; padding: 12px; background: var(--bg-secondary); border-radius: 8px;">
1149
1149
  <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
1150
1150
  <div style="font-weight: 500;">Profile</div>
1151
- ${u?c`
1151
+ ${u?l`
1152
1152
  <button
1153
1153
  class="btn btn-sm"
1154
- @click=${r}
1154
+ @click=${c}
1155
1155
  style="font-size: 12px; padding: 4px 8px;"
1156
1156
  >
1157
1157
  Edit Profile
1158
1158
  </button>
1159
1159
  `:g}
1160
1160
  </div>
1161
- ${Pn?c`
1161
+ ${Nn?l`
1162
1162
  <div class="status-list">
1163
- ${E?c`
1163
+ ${E?l`
1164
1164
  <div style="margin-bottom: 8px;">
1165
1165
  <img
1166
1166
  src=${E}
1167
1167
  alt="Profile picture"
1168
1168
  style="width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-color);"
1169
- @error=${Nn=>{Nn.target.style.display="none"}}
1169
+ @error=${On=>{On.target.style.display="none"}}
1170
1170
  />
1171
1171
  </div>
1172
1172
  `:g}
1173
- ${N?c`<div><span class="label">Name</span><span>${N}</span></div>`:g}
1174
- ${R?c`<div><span class="label">Display Name</span><span>${R}</span></div>`:g}
1175
- ${C?c`<div><span class="label">About</span><span style="max-width: 300px; overflow: hidden; text-overflow: ellipsis;">${C}</span></div>`:g}
1176
- ${ve?c`<div><span class="label">NIP-05</span><span>${ve}</span></div>`:g}
1173
+ ${N?l`<div><span class="label">Name</span><span>${N}</span></div>`:g}
1174
+ ${R?l`<div><span class="label">Display Name</span><span>${R}</span></div>`:g}
1175
+ ${C?l`<div><span class="label">About</span><span style="max-width: 300px; overflow: hidden; text-overflow: ellipsis;">${C}</span></div>`:g}
1176
+ ${ve?l`<div><span class="label">NIP-05</span><span>${ve}</span></div>`:g}
1177
1177
  </div>
1178
- `:c`
1178
+ `:l`
1179
1179
  <div style="color: var(--text-muted); font-size: 13px;">
1180
1180
  No profile set. Click "Edit Profile" to add your name, bio, and avatar.
1181
1181
  </div>
1182
1182
  `}
1183
1183
  </div>
1184
- `};return c`
1184
+ `};return l`
1185
1185
  <div class="card">
1186
1186
  <div class="card-title">Nostr</div>
1187
1187
  <div class="card-sub">Decentralized DMs via Nostr relays (NIP-04).</div>
1188
1188
  ${i}
1189
1189
 
1190
- ${v?c`
1190
+ ${v?l`
1191
1191
  <div class="account-card-list">
1192
1192
  ${s.map(M=>k(M))}
1193
1193
  </div>
1194
- `:c`
1194
+ `:l`
1195
1195
  <div class="status-list" style="margin-top: 16px;">
1196
1196
  <div>
1197
1197
  <span class="label">Configured</span>
@@ -1204,17 +1204,17 @@ ${e.sidebarContent}
1204
1204
  <div>
1205
1205
  <span class="label">Public Key</span>
1206
1206
  <span class="monospace" title="${p??""}"
1207
- >${ro(p)}</span
1207
+ >${lo(p)}</span
1208
1208
  >
1209
1209
  </div>
1210
1210
  <div>
1211
1211
  <span class="label">Last start</span>
1212
- <span>${f?B(f):"n/a"}</span>
1212
+ <span>${f?D(f):"n/a"}</span>
1213
1213
  </div>
1214
1214
  </div>
1215
1215
  `}
1216
1216
 
1217
- ${m?c`<div class="callout danger" style="margin-top: 12px;">${m}</div>`:g}
1217
+ ${m?l`<div class="callout danger" style="margin-top: 12px;">${m}</div>`:g}
1218
1218
 
1219
1219
  ${_()}
1220
1220
 
@@ -1224,7 +1224,7 @@ ${e.sidebarContent}
1224
1224
  <button class="btn" @click=${()=>t.onRefresh(!1)}>Refresh</button>
1225
1225
  </div>
1226
1226
  </div>
1227
- `}function Xh(e){const{props:t,signal:n,accountCountLabel:s}=e;return c`
1227
+ `}function ef(e){const{props:t,signal:n,accountCountLabel:s}=e;return l`
1228
1228
  <div class="card">
1229
1229
  <div class="card-title">Signal</div>
1230
1230
  <div class="card-sub">signal-cli status and channel configuration.</div>
@@ -1245,19 +1245,19 @@ ${e.sidebarContent}
1245
1245
  </div>
1246
1246
  <div>
1247
1247
  <span class="label">Last start</span>
1248
- <span>${n?.lastStartAt?B(n.lastStartAt):"n/a"}</span>
1248
+ <span>${n?.lastStartAt?D(n.lastStartAt):"n/a"}</span>
1249
1249
  </div>
1250
1250
  <div>
1251
1251
  <span class="label">Last probe</span>
1252
- <span>${n?.lastProbeAt?B(n.lastProbeAt):"n/a"}</span>
1252
+ <span>${n?.lastProbeAt?D(n.lastProbeAt):"n/a"}</span>
1253
1253
  </div>
1254
1254
  </div>
1255
1255
 
1256
- ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
1256
+ ${n?.lastError?l`<div class="callout danger" style="margin-top: 12px;">
1257
1257
  ${n.lastError}
1258
1258
  </div>`:g}
1259
1259
 
1260
- ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
1260
+ ${n?.probe?l`<div class="callout" style="margin-top: 12px;">
1261
1261
  Probe ${n.probe.ok?"ok":"failed"} ·
1262
1262
  ${n.probe.status??""} ${n.probe.error??""}
1263
1263
  </div>`:g}
@@ -1270,7 +1270,7 @@ ${e.sidebarContent}
1270
1270
  </button>
1271
1271
  </div>
1272
1272
  </div>
1273
- `}function ef(e){const{props:t,slack:n,accountCountLabel:s}=e;return c`
1273
+ `}function tf(e){const{props:t,slack:n,accountCountLabel:s}=e;return l`
1274
1274
  <div class="card">
1275
1275
  <div class="card-title">Slack</div>
1276
1276
  <div class="card-sub">Socket mode status and channel configuration.</div>
@@ -1287,19 +1287,19 @@ ${e.sidebarContent}
1287
1287
  </div>
1288
1288
  <div>
1289
1289
  <span class="label">Last start</span>
1290
- <span>${n?.lastStartAt?B(n.lastStartAt):"n/a"}</span>
1290
+ <span>${n?.lastStartAt?D(n.lastStartAt):"n/a"}</span>
1291
1291
  </div>
1292
1292
  <div>
1293
1293
  <span class="label">Last probe</span>
1294
- <span>${n?.lastProbeAt?B(n.lastProbeAt):"n/a"}</span>
1294
+ <span>${n?.lastProbeAt?D(n.lastProbeAt):"n/a"}</span>
1295
1295
  </div>
1296
1296
  </div>
1297
1297
 
1298
- ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
1298
+ ${n?.lastError?l`<div class="callout danger" style="margin-top: 12px;">
1299
1299
  ${n.lastError}
1300
1300
  </div>`:g}
1301
1301
 
1302
- ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
1302
+ ${n?.probe?l`<div class="callout" style="margin-top: 12px;">
1303
1303
  Probe ${n.probe.ok?"ok":"failed"} ·
1304
1304
  ${n.probe.status??""} ${n.probe.error??""}
1305
1305
  </div>`:g}
@@ -1312,45 +1312,45 @@ ${e.sidebarContent}
1312
1312
  </button>
1313
1313
  </div>
1314
1314
  </div>
1315
- `}function tf(e){const{props:t,telegram:n,telegramAccounts:s,accountCountLabel:i}=e,a=s.length>1,o=r=>{const u=r.probe?.bot?.username,d=r.name||r.accountId;return c`
1315
+ `}function nf(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 l`
1316
1316
  <div class="account-card">
1317
1317
  <div class="account-card-header">
1318
1318
  <div class="account-card-title">
1319
1319
  ${u?`@${u}`:d}
1320
1320
  </div>
1321
- <div class="account-card-id">${r.accountId}</div>
1321
+ <div class="account-card-id">${c.accountId}</div>
1322
1322
  </div>
1323
1323
  <div class="status-list account-card-status">
1324
1324
  <div>
1325
1325
  <span class="label">Running</span>
1326
- <span>${r.running?"Yes":"No"}</span>
1326
+ <span>${c.running?"Yes":"No"}</span>
1327
1327
  </div>
1328
1328
  <div>
1329
1329
  <span class="label">Configured</span>
1330
- <span>${r.configured?"Yes":"No"}</span>
1330
+ <span>${c.configured?"Yes":"No"}</span>
1331
1331
  </div>
1332
1332
  <div>
1333
1333
  <span class="label">Last inbound</span>
1334
- <span>${r.lastInboundAt?B(r.lastInboundAt):"n/a"}</span>
1334
+ <span>${c.lastInboundAt?D(c.lastInboundAt):"n/a"}</span>
1335
1335
  </div>
1336
- ${r.lastError?c`
1336
+ ${c.lastError?l`
1337
1337
  <div class="account-card-error">
1338
- ${r.lastError}
1338
+ ${c.lastError}
1339
1339
  </div>
1340
1340
  `:g}
1341
1341
  </div>
1342
1342
  </div>
1343
- `};return c`
1343
+ `};return l`
1344
1344
  <div class="card">
1345
1345
  <div class="card-title">Telegram</div>
1346
1346
  <div class="card-sub">Bot status and channel configuration.</div>
1347
1347
  ${i}
1348
1348
 
1349
- ${a?c`
1349
+ ${a?l`
1350
1350
  <div class="account-card-list">
1351
- ${s.map(r=>o(r))}
1351
+ ${s.map(c=>o(c))}
1352
1352
  </div>
1353
- `:c`
1353
+ `:l`
1354
1354
  <div class="status-list" style="margin-top: 16px;">
1355
1355
  <div>
1356
1356
  <span class="label">Configured</span>
@@ -1366,20 +1366,20 @@ ${e.sidebarContent}
1366
1366
  </div>
1367
1367
  <div>
1368
1368
  <span class="label">Last start</span>
1369
- <span>${n?.lastStartAt?B(n.lastStartAt):"n/a"}</span>
1369
+ <span>${n?.lastStartAt?D(n.lastStartAt):"n/a"}</span>
1370
1370
  </div>
1371
1371
  <div>
1372
1372
  <span class="label">Last probe</span>
1373
- <span>${n?.lastProbeAt?B(n.lastProbeAt):"n/a"}</span>
1373
+ <span>${n?.lastProbeAt?D(n.lastProbeAt):"n/a"}</span>
1374
1374
  </div>
1375
1375
  </div>
1376
1376
  `}
1377
1377
 
1378
- ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
1378
+ ${n?.lastError?l`<div class="callout danger" style="margin-top: 12px;">
1379
1379
  ${n.lastError}
1380
1380
  </div>`:g}
1381
1381
 
1382
- ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
1382
+ ${n?.probe?l`<div class="callout" style="margin-top: 12px;">
1383
1383
  Probe ${n.probe.ok?"ok":"failed"} ·
1384
1384
  ${n.probe.status??""} ${n.probe.error??""}
1385
1385
  </div>`:g}
@@ -1392,7 +1392,7 @@ ${e.sidebarContent}
1392
1392
  </button>
1393
1393
  </div>
1394
1394
  </div>
1395
- `}function nf(e){const{props:t,whatsapp:n,accountCountLabel:s}=e;return c`
1395
+ `}function sf(e){const{props:t,whatsapp:n,accountCountLabel:s}=e;return l`
1396
1396
  <div class="card">
1397
1397
  <div class="card-title">WhatsApp</div>
1398
1398
  <div class="card-sub">Link WhatsApp Web and monitor connection health.</div>
@@ -1418,32 +1418,32 @@ ${e.sidebarContent}
1418
1418
  <div>
1419
1419
  <span class="label">Last connect</span>
1420
1420
  <span>
1421
- ${n?.lastConnectedAt?B(n.lastConnectedAt):"n/a"}
1421
+ ${n?.lastConnectedAt?D(n.lastConnectedAt):"n/a"}
1422
1422
  </span>
1423
1423
  </div>
1424
1424
  <div>
1425
1425
  <span class="label">Last message</span>
1426
1426
  <span>
1427
- ${n?.lastMessageAt?B(n.lastMessageAt):"n/a"}
1427
+ ${n?.lastMessageAt?D(n.lastMessageAt):"n/a"}
1428
1428
  </span>
1429
1429
  </div>
1430
1430
  <div>
1431
1431
  <span class="label">Auth age</span>
1432
1432
  <span>
1433
- ${n?.authAgeMs!=null?Uh(n.authAgeMs):"n/a"}
1433
+ ${n?.authAgeMs!=null?Kh(n.authAgeMs):"n/a"}
1434
1434
  </span>
1435
1435
  </div>
1436
1436
  </div>
1437
1437
 
1438
- ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
1438
+ ${n?.lastError?l`<div class="callout danger" style="margin-top: 12px;">
1439
1439
  ${n.lastError}
1440
1440
  </div>`:g}
1441
1441
 
1442
- ${t.whatsappMessage?c`<div class="callout" style="margin-top: 12px;">
1442
+ ${t.whatsappMessage?l`<div class="callout" style="margin-top: 12px;">
1443
1443
  ${t.whatsappMessage}
1444
1444
  </div>`:g}
1445
1445
 
1446
- ${t.whatsappQrDataUrl?c`<div class="qr-wrap">
1446
+ ${t.whatsappQrDataUrl?l`<div class="qr-wrap">
1447
1447
  <img src=${t.whatsappQrDataUrl} alt="WhatsApp QR" />
1448
1448
  </div>`:g}
1449
1449
 
@@ -1483,9 +1483,9 @@ ${e.sidebarContent}
1483
1483
 
1484
1484
  ${Ce({channelId:"whatsapp",props:t})}
1485
1485
  </div>
1486
- `}function sf(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,r=t?.imessage??null,l=t?.nostr??null,d=af(e.snapshot).map((p,f)=>({key:p,enabled:Kh(p,e),order:f})).sort((p,f)=>p.enabled!==f.enabled?p.enabled?-1:1:p.order-f.order);return c`
1486
+ `}function af(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,r=t?.nostr??null,d=of(e.snapshot).map((p,f)=>({key:p,enabled:zh(p,e),order:f})).sort((p,f)=>p.enabled!==f.enabled?p.enabled?-1:1:p.order-f.order);return l`
1487
1487
  <section class="grid grid-cols-2">
1488
- ${d.map(p=>of(p.key,e,{whatsapp:n,telegram:s,discord:i,slack:a,signal:o,imessage:r,nostr:l,channelAccounts:e.snapshot?.channelAccounts??null}))}
1488
+ ${d.map(p=>rf(p.key,e,{whatsapp:n,telegram:s,discord:i,slack:a,signal:o,imessage:c,nostr:r,channelAccounts:e.snapshot?.channelAccounts??null}))}
1489
1489
  </section>
1490
1490
 
1491
1491
  <section class="card" style="margin-top: 18px;">
@@ -1494,26 +1494,26 @@ ${e.sidebarContent}
1494
1494
  <div class="card-title">Channel health</div>
1495
1495
  <div class="card-sub">Channel status snapshots from the gateway.</div>
1496
1496
  </div>
1497
- <div class="muted">${e.lastSuccessAt?B(e.lastSuccessAt):"n/a"}</div>
1497
+ <div class="muted">${e.lastSuccessAt?D(e.lastSuccessAt):"n/a"}</div>
1498
1498
  </div>
1499
- ${e.lastError?c`<div class="callout danger" style="margin-top: 12px;">
1499
+ ${e.lastError?l`<div class="callout danger" style="margin-top: 12px;">
1500
1500
  ${e.lastError}
1501
1501
  </div>`:g}
1502
1502
  <pre class="code-block" style="margin-top: 12px;">
1503
1503
  ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1504
1504
  </pre>
1505
1505
  </section>
1506
- `}function af(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 of(e,t,n){const s=Br(e,n.channelAccounts);switch(e){case"whatsapp":return nf({props:t,whatsapp:n.whatsapp,accountCountLabel:s});case"telegram":return tf({props:t,telegram:n.telegram,telegramAccounts:n.channelAccounts?.telegram??[],accountCountLabel:s});case"discord":return Wh({props:t,discord:n.discord,accountCountLabel:s});case"googlechat":return qh({props:t,accountCountLabel:s});case"slack":return ef({props:t,slack:n.slack,accountCountLabel:s});case"signal":return Xh({props:t,signal:n.signal,accountCountLabel:s});case"imessage":return Gh({props:t,imessage:n.imessage,accountCountLabel:s});case"nostr":{const i=n.channelAccounts?.nostr??[],a=i[0],o=a?.accountId??"default",r=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 Zh({props:t,nostr:n.nostr,nostrAccounts:i,accountCountLabel:s,profileFormState:l,profileFormCallbacks:u,onEditProfile:()=>t.onNostrProfileEdit(o,r)})}default:return rf(e,t,n.channelAccounts??{})}}function rf(e,t,n){const s=cf(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,r=typeof i?.connected=="boolean"?i.connected:void 0,l=typeof i?.lastError=="string"?i.lastError:void 0,u=n[e]??[],d=Br(e,n);return c`
1506
+ `}function of(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 rf(e,t,n){const s=Br(e,n.channelAccounts);switch(e){case"whatsapp":return sf({props:t,whatsapp:n.whatsapp,accountCountLabel:s});case"telegram":return nf({props:t,telegram:n.telegram,telegramAccounts:n.channelAccounts?.telegram??[],accountCountLabel:s});case"discord":return qh({props:t,discord:n.discord,accountCountLabel:s});case"googlechat":return Gh({props:t,accountCountLabel:s});case"slack":return tf({props:t,slack:n.slack,accountCountLabel:s});case"signal":return ef({props:t,signal:n.signal,accountCountLabel:s});case"imessage":return Yh({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,r=t.nostrProfileAccountId===o?t.nostrProfileFormState:null,u=r?{onFieldChange:t.onNostrProfileFieldChange,onSave:t.onNostrProfileSave,onImport:t.onNostrProfileImport,onCancel:t.onNostrProfileCancel,onToggleAdvanced:t.onNostrProfileToggleAdvanced}:null;return Xh({props:t,nostr:n.nostr,nostrAccounts:i,accountCountLabel:s,profileFormState:r,profileFormCallbacks:u,onEditProfile:()=>t.onNostrProfileEdit(o,c)})}default:return lf(e,t,n.channelAccounts??{})}}function lf(e,t,n){const s=df(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,r=typeof i?.lastError=="string"?i.lastError:void 0,u=n[e]??[],d=Br(e,n);return l`
1507
1507
  <div class="card">
1508
1508
  <div class="card-title">${s}</div>
1509
1509
  <div class="card-sub">Channel status and configuration.</div>
1510
1510
  ${d}
1511
1511
 
1512
- ${u.length>0?c`
1512
+ ${u.length>0?l`
1513
1513
  <div class="account-card-list">
1514
- ${u.map(p=>hf(p))}
1514
+ ${u.map(p=>ff(p))}
1515
1515
  </div>
1516
- `:c`
1516
+ `:l`
1517
1517
  <div class="status-list" style="margin-top: 16px;">
1518
1518
  <div>
1519
1519
  <span class="label">Configured</span>
@@ -1525,18 +1525,18 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1525
1525
  </div>
1526
1526
  <div>
1527
1527
  <span class="label">Connected</span>
1528
- <span>${r==null?"n/a":r?"Yes":"No"}</span>
1528
+ <span>${c==null?"n/a":c?"Yes":"No"}</span>
1529
1529
  </div>
1530
1530
  </div>
1531
1531
  `}
1532
1532
 
1533
- ${l?c`<div class="callout danger" style="margin-top: 12px;">
1534
- ${l}
1533
+ ${r?l`<div class="callout danger" style="margin-top: 12px;">
1534
+ ${r}
1535
1535
  </div>`:g}
1536
1536
 
1537
1537
  ${Ce({channelId:e,props:t})}
1538
1538
  </div>
1539
- `}function lf(e){return e?.channelMeta?.length?Object.fromEntries(e.channelMeta.map(t=>[t.id,t])):{}}function cf(e,t){return lf(e)[t]?.label??e?.channelLabels?.[t]??t}const df=600*1e3;function Fr(e){return e.lastInboundAt?Date.now()-e.lastInboundAt<df:!1}function uf(e){return e.running?"Yes":Fr(e)?"Active":"No"}function pf(e){return e.connected===!0?"Yes":e.connected===!1?"No":Fr(e)?"Active":"n/a"}function hf(e){const t=uf(e),n=pf(e);return c`
1539
+ `}function cf(e){return e?.channelMeta?.length?Object.fromEntries(e.channelMeta.map(t=>[t.id,t])):{}}function df(e,t){return cf(e)[t]?.label??e?.channelLabels?.[t]??t}const uf=600*1e3;function Fr(e){return e.lastInboundAt?Date.now()-e.lastInboundAt<uf:!1}function pf(e){return e.running?"Yes":Fr(e)?"Active":"No"}function hf(e){return e.connected===!0?"Yes":e.connected===!1?"No":Fr(e)?"Active":"n/a"}function ff(e){const t=pf(e),n=hf(e);return l`
1540
1540
  <div class="account-card">
1541
1541
  <div class="account-card-header">
1542
1542
  <div class="account-card-title">${e.name||e.accountId}</div>
@@ -1557,16 +1557,16 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1557
1557
  </div>
1558
1558
  <div>
1559
1559
  <span class="label">Last inbound</span>
1560
- <span>${e.lastInboundAt?B(e.lastInboundAt):"n/a"}</span>
1560
+ <span>${e.lastInboundAt?D(e.lastInboundAt):"n/a"}</span>
1561
1561
  </div>
1562
- ${e.lastError?c`
1562
+ ${e.lastError?l`
1563
1563
  <div class="account-card-error">
1564
1564
  ${e.lastError}
1565
1565
  </div>
1566
1566
  `:g}
1567
1567
  </div>
1568
1568
  </div>
1569
- `}function ff(e){const t=e.host??"unknown",n=e.ip?`(${e.ip})`:"",s=e.mode??"",i=e.version??"";return`${t} ${n} ${s} ${i}`.trim()}function gf(e){const t=e.ts??null;return t?B(t):"n/a"}function Ur(e){return e?`${Pt(e)} (${B(e)})`:"n/a"}function mf(e){if(e.totalTokens==null)return"n/a";const t=e.totalTokens??0,n=e.contextTokens??0;return n?`${t} / ${n}`:String(t)}function vf(e){if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function yf(e){const t=e.schedule;return t.kind==="at"?`At ${Pt(t.atMs)}`:t.kind==="every"?`Every ${Ro(t.everyMs)}`:`Cron ${t.expr}${t.tz?` (${t.tz})`:""}`}function bf(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 wf(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 $f(e){const t=bf(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 c`
1569
+ `}function gf(e){const t=e.host??"unknown",n=e.ip?`(${e.ip})`:"",s=e.mode??"",i=e.version??"";return`${t} ${n} ${s} ${i}`.trim()}function mf(e){const t=e.ts??null;return t?D(t):"n/a"}function Ur(e){return e?`${Nt(e)} (${D(e)})`:"n/a"}function vf(e){if(e.totalTokens==null)return"n/a";const t=e.totalTokens??0,n=e.contextTokens??0;return n?`${t} / ${n}`:String(t)}function yf(e){if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function bf(e){const t=e.schedule;return t.kind==="at"?`At ${Nt(t.atMs)}`:t.kind==="every"?`Every ${dc(t.everyMs)}`:`Cron ${t.expr}${t.tz?` (${t.tz})`:""}`}function wf(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 xf(e){const t=wf(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 l`
1570
1570
  <section class="grid grid-cols-2">
1571
1571
  <div class="card">
1572
1572
  <div class="card-title">Scheduler</div>
@@ -1591,7 +1591,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1591
1591
  <button class="btn" ?disabled=${e.loading} @click=${e.onRefresh}>
1592
1592
  ${e.loading?"Refreshing…":"Refresh"}
1593
1593
  </button>
1594
- ${e.error?c`<span class="muted">${e.error}</span>`:g}
1594
+ ${e.error?l`<span class="muted">${e.error}</span>`:g}
1595
1595
  </div>
1596
1596
  </div>
1597
1597
 
@@ -1641,7 +1641,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1641
1641
  </select>
1642
1642
  </label>
1643
1643
  </div>
1644
- ${xf(e)}
1644
+ ${kf(e)}
1645
1645
  <div class="form-grid" style="margin-top: 12px;">
1646
1646
  <label class="field">
1647
1647
  <span>Session</span>
@@ -1682,7 +1682,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1682
1682
  rows="4"
1683
1683
  ></textarea>
1684
1684
  </label>
1685
- ${e.form.payloadKind==="agentTurn"?c`
1685
+ ${e.form.payloadKind==="agentTurn"?l`
1686
1686
  <div class="form-grid" style="margin-top: 12px;">
1687
1687
  <label class="field">
1688
1688
  <span>Delivery</span>
@@ -1702,15 +1702,15 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1702
1702
  @input=${a=>e.onFormChange({timeoutSeconds:a.target.value})}
1703
1703
  />
1704
1704
  </label>
1705
- ${e.form.deliveryMode==="announce"?c`
1705
+ ${e.form.deliveryMode==="announce"?l`
1706
1706
  <label class="field">
1707
1707
  <span>Channel</span>
1708
1708
  <select
1709
1709
  .value=${e.form.deliveryChannel||"last"}
1710
1710
  @change=${a=>e.onFormChange({deliveryChannel:a.target.value})}
1711
1711
  >
1712
- ${t.map(a=>c`<option value=${a}>
1713
- ${wf(e,a)}
1712
+ ${t.map(a=>l`<option value=${a}>
1713
+ ${$f(e,a)}
1714
1714
  </option>`)}
1715
1715
  </select>
1716
1716
  </label>
@@ -1736,11 +1736,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1736
1736
  <section class="card" style="margin-top: 18px;">
1737
1737
  <div class="card-title">Jobs</div>
1738
1738
  <div class="card-sub">All scheduled jobs stored in the gateway.</div>
1739
- ${e.jobs.length===0?c`
1739
+ ${e.jobs.length===0?l`
1740
1740
  <div class="muted" style="margin-top: 12px">No jobs yet.</div>
1741
- `:c`
1741
+ `:l`
1742
1742
  <div class="list" style="margin-top: 12px;">
1743
- ${e.jobs.map(a=>kf(a,e))}
1743
+ ${e.jobs.map(a=>Sf(a,e))}
1744
1744
  </div>
1745
1745
  `}
1746
1746
  </section>
@@ -1748,17 +1748,17 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1748
1748
  <section class="card" style="margin-top: 18px;">
1749
1749
  <div class="card-title">Run history</div>
1750
1750
  <div class="card-sub">Latest runs for ${s}.</div>
1751
- ${e.runsJobId==null?c`
1751
+ ${e.runsJobId==null?l`
1752
1752
  <div class="muted" style="margin-top: 12px">Select a job to inspect run history.</div>
1753
- `:i.length===0?c`
1753
+ `:i.length===0?l`
1754
1754
  <div class="muted" style="margin-top: 12px">No runs yet.</div>
1755
- `:c`
1755
+ `:l`
1756
1756
  <div class="list" style="margin-top: 12px;">
1757
- ${i.map(a=>_f(a,e.basePath))}
1757
+ ${i.map(a=>Tf(a,e.basePath))}
1758
1758
  </div>
1759
1759
  `}
1760
1760
  </section>
1761
- `}function xf(e){const t=e.form;return t.scheduleKind==="at"?c`
1761
+ `}function kf(e){const t=e.form;return t.scheduleKind==="at"?l`
1762
1762
  <label class="field" style="margin-top: 12px;">
1763
1763
  <span>Run at</span>
1764
1764
  <input
@@ -1767,7 +1767,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1767
1767
  @input=${n=>e.onFormChange({scheduleAt:n.target.value})}
1768
1768
  />
1769
1769
  </label>
1770
- `:t.scheduleKind==="every"?c`
1770
+ `:t.scheduleKind==="every"?l`
1771
1771
  <div class="form-grid" style="margin-top: 12px;">
1772
1772
  <label class="field">
1773
1773
  <span>Every</span>
@@ -1788,7 +1788,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1788
1788
  </select>
1789
1789
  </label>
1790
1790
  </div>
1791
- `:c`
1791
+ `:l`
1792
1792
  <div class="form-grid" style="margin-top: 12px;">
1793
1793
  <label class="field">
1794
1794
  <span>Expression</span>
@@ -1805,16 +1805,16 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1805
1805
  />
1806
1806
  </label>
1807
1807
  </div>
1808
- `}function kf(e,t){const s=`list-item list-item-clickable cron-job${t.runsJobId===e.id?" list-item-selected":""}`;return c`
1808
+ `}function Sf(e,t){const s=`list-item list-item-clickable cron-job${t.runsJobId===e.id?" list-item-selected":""}`;return l`
1809
1809
  <div class=${s} @click=${()=>t.onLoadRuns(e.id)}>
1810
1810
  <div class="list-main">
1811
1811
  <div class="list-title">${e.name}</div>
1812
- <div class="list-sub">${yf(e)}</div>
1813
- ${Sf(e)}
1814
- ${e.agentId?c`<div class="muted cron-job-agent">Agent: ${e.agentId}</div>`:g}
1812
+ <div class="list-sub">${bf(e)}</div>
1813
+ ${Af(e)}
1814
+ ${e.agentId?l`<div class="muted cron-job-agent">Agent: ${e.agentId}</div>`:g}
1815
1815
  </div>
1816
1816
  <div class="list-meta">
1817
- ${Af(e)}
1817
+ ${_f(e)}
1818
1818
  </div>
1819
1819
  <div class="cron-job-footer">
1820
1820
  <div class="chip-row cron-job-chips">
@@ -1856,19 +1856,19 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1856
1856
  </div>
1857
1857
  </div>
1858
1858
  </div>
1859
- `}function Sf(e){if(e.payload.kind==="systemEvent")return c`<div class="cron-job-detail">
1859
+ `}function Af(e){if(e.payload.kind==="systemEvent")return l`<div class="cron-job-detail">
1860
1860
  <span class="cron-job-detail-label">System</span>
1861
1861
  <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 c`
1862
+ </div>`;const t=e.delivery,n=t?.channel||t?.to?` (${t.channel??"last"}${t.to?` -> ${t.to}`:""})`:"";return l`
1863
1863
  <div class="cron-job-detail">
1864
1864
  <span class="cron-job-detail-label">Prompt</span>
1865
1865
  <span class="muted cron-job-detail-value">${e.payload.message}</span>
1866
1866
  </div>
1867
- ${t?c`<div class="cron-job-detail">
1867
+ ${t?l`<div class="cron-job-detail">
1868
1868
  <span class="cron-job-detail-label">Delivery</span>
1869
1869
  <span class="muted cron-job-detail-value">${t.mode}${n}</span>
1870
1870
  </div>`:g}
1871
- `}function lo(e){return typeof e!="number"||!Number.isFinite(e)?"n/a":$n(e)}function Af(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 c`
1871
+ `}function co(e){return typeof e!="number"||!Number.isFinite(e)?"n/a":xn(e)}function _f(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 l`
1872
1872
  <div class="cron-job-state">
1873
1873
  <div class="cron-job-state-row">
1874
1874
  <span class="cron-job-state-key">Status</span>
@@ -1876,31 +1876,31 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1876
1876
  </div>
1877
1877
  <div class="cron-job-state-row">
1878
1878
  <span class="cron-job-state-key">Next</span>
1879
- <span class="cron-job-state-value" title=${Pt(s)}>
1880
- ${lo(s)}
1879
+ <span class="cron-job-state-value" title=${Nt(s)}>
1880
+ ${co(s)}
1881
1881
  </span>
1882
1882
  </div>
1883
1883
  <div class="cron-job-state-row">
1884
1884
  <span class="cron-job-state-key">Last</span>
1885
- <span class="cron-job-state-value" title=${Pt(i)}>
1886
- ${lo(i)}
1885
+ <span class="cron-job-state-value" title=${Nt(i)}>
1886
+ ${co(i)}
1887
1887
  </span>
1888
1888
  </div>
1889
1889
  </div>
1890
- `}function _f(e,t){const n=typeof e.sessionKey=="string"&&e.sessionKey.trim().length>0?`${wn("chat",t)}?session=${encodeURIComponent(e.sessionKey)}`:null;return c`
1890
+ `}function Tf(e,t){const n=typeof e.sessionKey=="string"&&e.sessionKey.trim().length>0?`${$n("chat",t)}?session=${encodeURIComponent(e.sessionKey)}`:null;return l`
1891
1891
  <div class="list-item">
1892
1892
  <div class="list-main">
1893
1893
  <div class="list-title">${e.status}</div>
1894
1894
  <div class="list-sub">${e.summary??""}</div>
1895
1895
  </div>
1896
1896
  <div class="list-meta">
1897
- <div>${Pt(e.ts)}</div>
1897
+ <div>${Nt(e.ts)}</div>
1898
1898
  <div class="muted">${e.durationMs??0}ms</div>
1899
- ${n?c`<div><a class="session-link" href=${n}>Open run chat</a></div>`:g}
1900
- ${e.error?c`<div class="muted">${e.error}</div>`:g}
1899
+ ${n?l`<div><a class="session-link" href=${n}>Open run chat</a></div>`:g}
1900
+ ${e.error?l`<div class="muted">${e.error}</div>`:g}
1901
1901
  </div>
1902
1902
  </div>
1903
- `}function Tf(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",r=s>0?`${s} critical`:i>0?`${i} warnings`:"No critical issues";return c`
1903
+ `}function Cf(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 l`
1904
1904
  <section class="grid grid-cols-2">
1905
1905
  <div class="card">
1906
1906
  <div class="row" style="justify-content: space-between;">
@@ -1915,8 +1915,8 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1915
1915
  <div class="stack" style="margin-top: 12px;">
1916
1916
  <div>
1917
1917
  <div class="muted">Status</div>
1918
- ${n?c`<div class="callout ${o}" style="margin-top: 8px;">
1919
- Security audit: ${r}${a>0?` · ${a} info`:""}. Run
1918
+ ${n?l`<div class="callout ${o}" style="margin-top: 8px;">
1919
+ Security audit: ${c}${a>0?` · ${a} info`:""}. Run
1920
1920
  <span class="mono">poolbot security audit --deep</span> for details.
1921
1921
  </div>`:g}
1922
1922
  <pre class="code-block">${JSON.stringify(e.status??{},null,2)}</pre>
@@ -1940,7 +1940,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1940
1940
  <span>Method</span>
1941
1941
  <input
1942
1942
  .value=${e.callMethod}
1943
- @input=${l=>e.onCallMethodChange(l.target.value)}
1943
+ @input=${r=>e.onCallMethodChange(r.target.value)}
1944
1944
  placeholder="system-presence"
1945
1945
  />
1946
1946
  </label>
@@ -1948,7 +1948,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1948
1948
  <span>Params (JSON)</span>
1949
1949
  <textarea
1950
1950
  .value=${e.callParams}
1951
- @input=${l=>e.onCallParamsChange(l.target.value)}
1951
+ @input=${r=>e.onCallParamsChange(r.target.value)}
1952
1952
  rows="6"
1953
1953
  ></textarea>
1954
1954
  </label>
@@ -1956,10 +1956,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1956
1956
  <div class="row" style="margin-top: 12px;">
1957
1957
  <button class="btn primary" @click=${e.onCall}>Call</button>
1958
1958
  </div>
1959
- ${e.callError?c`<div class="callout danger" style="margin-top: 12px;">
1959
+ ${e.callError?l`<div class="callout danger" style="margin-top: 12px;">
1960
1960
  ${e.callError}
1961
1961
  </div>`:g}
1962
- ${e.callResult?c`<pre class="code-block" style="margin-top: 12px;">${e.callResult}</pre>`:g}
1962
+ ${e.callResult?l`<pre class="code-block" style="margin-top: 12px;">${e.callResult}</pre>`:g}
1963
1963
  </div>
1964
1964
  </section>
1965
1965
 
@@ -1972,23 +1972,23 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1972
1972
  <section class="card" style="margin-top: 18px;">
1973
1973
  <div class="card-title">Event Log</div>
1974
1974
  <div class="card-sub">Latest gateway events.</div>
1975
- ${e.eventLog.length===0?c`<div class="muted" style="margin-top: 12px;">No events yet.</div>`:c`
1975
+ ${e.eventLog.length===0?l`<div class="muted" style="margin-top: 12px;">No events yet.</div>`:l`
1976
1976
  <div class="list" style="margin-top: 12px;">
1977
- ${e.eventLog.map(l=>c`
1977
+ ${e.eventLog.map(r=>l`
1978
1978
  <div class="list-item">
1979
1979
  <div class="list-main">
1980
- <div class="list-title">${l.event}</div>
1981
- <div class="list-sub">${new Date(l.ts).toLocaleTimeString()}</div>
1980
+ <div class="list-title">${r.event}</div>
1981
+ <div class="list-sub">${new Date(r.ts).toLocaleTimeString()}</div>
1982
1982
  </div>
1983
1983
  <div class="list-meta">
1984
- <pre class="code-block">${vf(l.payload)}</pre>
1984
+ <pre class="code-block">${yf(r.payload)}</pre>
1985
1985
  </div>
1986
1986
  </div>
1987
1987
  `)}
1988
1988
  </div>
1989
1989
  `}
1990
1990
  </section>
1991
- `}function Cf(e){return c`
1991
+ `}function Ef(e){return l`
1992
1992
  <section class="card">
1993
1993
  <div class="row" style="justify-content: space-between;">
1994
1994
  <div>
@@ -1999,38 +1999,38 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1999
1999
  ${e.loading?"Loading…":"Refresh"}
2000
2000
  </button>
2001
2001
  </div>
2002
- ${e.lastError?c`<div class="callout danger" style="margin-top: 12px;">
2002
+ ${e.lastError?l`<div class="callout danger" style="margin-top: 12px;">
2003
2003
  ${e.lastError}
2004
2004
  </div>`:g}
2005
- ${e.statusMessage?c`<div class="callout" style="margin-top: 12px;">
2005
+ ${e.statusMessage?l`<div class="callout" style="margin-top: 12px;">
2006
2006
  ${e.statusMessage}
2007
2007
  </div>`:g}
2008
2008
  <div class="list" style="margin-top: 16px;">
2009
- ${e.entries.length===0?c`<div class="muted">No instances reported yet.</div>`:e.entries.map(t=>Ef(t))}
2009
+ ${e.entries.length===0?l`<div class="muted">No instances reported yet.</div>`:e.entries.map(t=>Rf(t))}
2010
2010
  </div>
2011
2011
  </section>
2012
- `}function Ef(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 c`
2012
+ `}function Rf(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 l`
2013
2013
  <div class="list-item">
2014
2014
  <div class="list-main">
2015
2015
  <div class="list-title">${e.host??"unknown host"}</div>
2016
- <div class="list-sub">${ff(e)}</div>
2016
+ <div class="list-sub">${gf(e)}</div>
2017
2017
  <div class="chip-row">
2018
2018
  <span class="chip">${n}</span>
2019
- ${s.map(o=>c`<span class="chip">${o}</span>`)}
2020
- ${a?c`<span class="chip">${a}</span>`:g}
2021
- ${e.platform?c`<span class="chip">${e.platform}</span>`:g}
2022
- ${e.deviceFamily?c`<span class="chip">${e.deviceFamily}</span>`:g}
2023
- ${e.modelIdentifier?c`<span class="chip">${e.modelIdentifier}</span>`:g}
2024
- ${e.version?c`<span class="chip">${e.version}</span>`:g}
2019
+ ${s.map(o=>l`<span class="chip">${o}</span>`)}
2020
+ ${a?l`<span class="chip">${a}</span>`:g}
2021
+ ${e.platform?l`<span class="chip">${e.platform}</span>`:g}
2022
+ ${e.deviceFamily?l`<span class="chip">${e.deviceFamily}</span>`:g}
2023
+ ${e.modelIdentifier?l`<span class="chip">${e.modelIdentifier}</span>`:g}
2024
+ ${e.version?l`<span class="chip">${e.version}</span>`:g}
2025
2025
  </div>
2026
2026
  </div>
2027
2027
  <div class="list-meta">
2028
- <div>${gf(e)}</div>
2028
+ <div>${mf(e)}</div>
2029
2029
  <div class="muted">Last input ${t}</div>
2030
2030
  <div class="muted">Reason ${e.reason??""}</div>
2031
2031
  </div>
2032
2032
  </div>
2033
- `}const co=["trace","debug","info","warn","error","fatal"];function Rf(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function Mf(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function If(e){const t=e.filterText.trim().toLowerCase(),n=co.some(a=>!e.levelFilters[a]),s=e.entries.filter(a=>a.level&&!e.levelFilters[a.level]?!1:Mf(a,t)),i=t||n?"filtered":"visible";return c`
2033
+ `}const uo=["trace","debug","info","warn","error","fatal"];function Mf(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function If(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Lf(e){const t=e.filterText.trim().toLowerCase(),n=uo.some(a=>!e.levelFilters[a]),s=e.entries.filter(a=>a.level&&!e.levelFilters[a.level]?!1:If(a,t)),i=t||n?"filtered":"visible";return l`
2034
2034
  <section class="card">
2035
2035
  <div class="row" style="justify-content: space-between;">
2036
2036
  <div>
@@ -2071,7 +2071,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2071
2071
  </div>
2072
2072
 
2073
2073
  <div class="chip-row" style="margin-top: 12px;">
2074
- ${co.map(a=>c`
2074
+ ${uo.map(a=>l`
2075
2075
  <label class="chip log-chip ${a}">
2076
2076
  <input
2077
2077
  type="checkbox"
@@ -2083,16 +2083,16 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2083
2083
  `)}
2084
2084
  </div>
2085
2085
 
2086
- ${e.file?c`<div class="muted" style="margin-top: 10px;">File: ${e.file}</div>`:g}
2087
- ${e.truncated?c`<div class="callout" style="margin-top: 10px;">
2086
+ ${e.file?l`<div class="muted" style="margin-top: 10px;">File: ${e.file}</div>`:g}
2087
+ ${e.truncated?l`<div class="callout" style="margin-top: 10px;">
2088
2088
  Log output truncated; showing latest chunk.
2089
2089
  </div>`:g}
2090
- ${e.error?c`<div class="callout danger" style="margin-top: 10px;">${e.error}</div>`:g}
2090
+ ${e.error?l`<div class="callout danger" style="margin-top: 10px;">${e.error}</div>`:g}
2091
2091
 
2092
2092
  <div class="log-stream" style="margin-top: 12px;" @scroll=${e.onScroll}>
2093
- ${s.length===0?c`<div class="muted" style="padding: 12px;">No log entries.</div>`:s.map(a=>c`
2093
+ ${s.length===0?l`<div class="muted" style="padding: 12px;">No log entries.</div>`:s.map(a=>l`
2094
2094
  <div class="log-row">
2095
- <div class="log-time mono">${Rf(a.time)}</div>
2095
+ <div class="log-time mono">${Mf(a.time)}</div>
2096
2096
  <div class="log-level ${a.level??""}">${a.level??""}</div>
2097
2097
  <div class="log-subsystem mono">${a.subsystem??""}</div>
2098
2098
  <div class="log-message mono">${a.message??a.raw}</div>
@@ -2100,7 +2100,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2100
2100
  `)}
2101
2101
  </div>
2102
2102
  </section>
2103
- `}function Kr(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,r=typeof o.id=="string"?o.id.trim():"";if(!r)return;const l=typeof o.name=="string"?o.name.trim():void 0,u=o.default===!0;s.push({id:r,name:l||void 0,isDefault:u,index:a,record:o})}),s}function zr(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 r=typeof i.nodeId=="string"?i.nodeId.trim():"";if(!r)continue;const l=typeof i.displayName=="string"&&i.displayName.trim()?i.displayName.trim():r;s.push({id:r,label:l===r?r:`${l} · ${r}`})}return s.sort((i,a)=>i.label.localeCompare(a.label)),s}const Me="__defaults__",uo=[{value:"deny",label:"Deny"},{value:"allowlist",label:"Allowlist"},{value:"full",label:"Full"}],Lf=[{value:"off",label:"Off"},{value:"on-miss",label:"On miss"},{value:"always",label:"Always"}];function po(e){return e==="allowlist"||e==="full"||e==="deny"?e:"deny"}function Pf(e){return e==="always"||e==="off"||e==="on-miss"?e:"on-miss"}function Nf(e){const t=e?.defaults??{};return{security:po(t.security),ask:Pf(t.ask),askFallback:po(t.askFallback??"deny"),autoAllowSkills:!!(t.autoAllowSkills??!1)}}function Of(e){return Kr(e).map(t=>({id:t.id,name:t.name,isDefault:t.isDefault}))}function Df(e,t){const n=Of(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,r)=>{if(o.isDefault&&!r.isDefault)return-1;if(!o.isDefault&&r.isDefault)return 1;const l=o.name?.trim()?o.name:o.id,u=r.name?.trim()?r.name:r.id;return l.localeCompare(u)}),a}function Bf(e,t){return e===Me?Me:e&&t.some(n=>n.id===e)?e:Me}function Ff(e){const t=e.execApprovalsForm??e.execApprovalsSnapshot?.file??null,n=!!t,s=Nf(t),i=Df(e.configForm,t),a=Wf(e.nodes),o=e.execApprovalsTarget;let r=o==="node"&&e.execApprovalsTargetNodeId?e.execApprovalsTargetNodeId:null;o==="node"&&r&&!a.some(p=>p.id===r)&&(r=null);const l=Bf(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:r,targetNodes:a,onSelectScope:e.onExecApprovalsSelectAgent,onSelectTarget:e.onExecApprovalsTargetChange,onPatch:e.onExecApprovalsPatch,onRemove:e.onExecApprovalsRemove,onLoad:e.onLoadExecApprovals,onSave:e.onSaveExecApprovals}}function Uf(e){const t=e.ready,n=e.target!=="node"||!!e.targetNodeId;return c`
2103
+ `}function Kr(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 r=typeof o.name=="string"?o.name.trim():void 0,u=o.default===!0;s.push({id:c,name:r||void 0,isDefault:u,index:a,record:o})}),s}function zr(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 r=typeof i.displayName=="string"&&i.displayName.trim()?i.displayName.trim():c;s.push({id:c,label:r===c?c:`${r} · ${c}`})}return s.sort((i,a)=>i.label.localeCompare(a.label)),s}const Me="__defaults__",po=[{value:"deny",label:"Deny"},{value:"allowlist",label:"Allowlist"},{value:"full",label:"Full"}],Pf=[{value:"off",label:"Off"},{value:"on-miss",label:"On miss"},{value:"always",label:"Always"}];function ho(e){return e==="allowlist"||e==="full"||e==="deny"?e:"deny"}function Nf(e){return e==="always"||e==="off"||e==="on-miss"?e:"on-miss"}function Of(e){const t=e?.defaults??{};return{security:ho(t.security),ask:Nf(t.ask),askFallback:ho(t.askFallback??"deny"),autoAllowSkills:!!(t.autoAllowSkills??!1)}}function Df(e){return Kr(e).map(t=>({id:t.id,name:t.name,isDefault:t.isDefault}))}function Bf(e,t){const n=Df(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 r=o.name?.trim()?o.name:o.id,u=c.name?.trim()?c.name:c.id;return r.localeCompare(u)}),a}function Ff(e,t){return e===Me?Me:e&&t.some(n=>n.id===e)?e:Me}function Uf(e){const t=e.execApprovalsForm??e.execApprovalsSnapshot?.file??null,n=!!t,s=Of(t),i=Bf(e.configForm,t),a=qf(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 r=Ff(e.execApprovalsSelectedAgent,i),u=r!==Me?(t?.agents??{})[r]??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:r,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 Kf(e){const t=e.ready,n=e.target!=="node"||!!e.targetNodeId;return l`
2104
2104
  <section class="card">
2105
2105
  <div class="row" style="justify-content: space-between; align-items: center;">
2106
2106
  <div>
@@ -2118,20 +2118,20 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2118
2118
  </button>
2119
2119
  </div>
2120
2120
 
2121
- ${Kf(e)}
2121
+ ${zf(e)}
2122
2122
 
2123
- ${t?c`
2124
- ${zf(e)}
2123
+ ${t?l`
2125
2124
  ${Hf(e)}
2126
- ${e.selectedScope===Me?g:jf(e)}
2127
- `:c`<div class="row" style="margin-top: 12px; gap: 12px;">
2125
+ ${jf(e)}
2126
+ ${e.selectedScope===Me?g:Vf(e)}
2127
+ `:l`<div class="row" style="margin-top: 12px; gap: 12px;">
2128
2128
  <div class="muted">Load exec approvals to edit allowlists.</div>
2129
2129
  <button class="btn" ?disabled=${e.loading||!n} @click=${e.onLoad}>
2130
2130
  ${e.loading?"Loading…":"Load approvals"}
2131
2131
  </button>
2132
2132
  </div>`}
2133
2133
  </section>
2134
- `}function Kf(e){const t=e.targetNodes.length>0,n=e.targetNodeId??"";return c`
2134
+ `}function zf(e){const t=e.targetNodes.length>0,n=e.targetNodeId??"";return l`
2135
2135
  <div class="list" style="margin-top: 12px;">
2136
2136
  <div class="list-item">
2137
2137
  <div class="list-main">
@@ -2151,7 +2151,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2151
2151
  <option value="node" ?selected=${e.target==="node"}>Node</option>
2152
2152
  </select>
2153
2153
  </label>
2154
- ${e.target==="node"?c`
2154
+ ${e.target==="node"?l`
2155
2155
  <label class="field">
2156
2156
  <span>Node</span>
2157
2157
  <select
@@ -2159,7 +2159,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2159
2159
  @change=${s=>{const a=s.target.value.trim();e.onSelectTarget("node",a||null)}}
2160
2160
  >
2161
2161
  <option value="" ?selected=${n===""}>Select node</option>
2162
- ${e.targetNodes.map(s=>c`<option
2162
+ ${e.targetNodes.map(s=>l`<option
2163
2163
  value=${s.id}
2164
2164
  ?selected=${n===s.id}
2165
2165
  >
@@ -2170,11 +2170,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2170
2170
  `:g}
2171
2171
  </div>
2172
2172
  </div>
2173
- ${e.target==="node"&&!t?c`
2173
+ ${e.target==="node"&&!t?l`
2174
2174
  <div class="muted">No nodes advertise exec approvals yet.</div>
2175
2175
  `:g}
2176
2176
  </div>
2177
- `}function zf(e){return c`
2177
+ `}function Hf(e){return l`
2178
2178
  <div class="row" style="margin-top: 12px; gap: 8px; flex-wrap: wrap;">
2179
2179
  <span class="label">Scope</span>
2180
2180
  <div class="row" style="gap: 8px; flex-wrap: wrap;">
@@ -2184,7 +2184,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2184
2184
  >
2185
2185
  Defaults
2186
2186
  </button>
2187
- ${e.agents.map(t=>{const n=t.name?.trim()?`${t.name} (${t.id})`:t.id;return c`
2187
+ ${e.agents.map(t=>{const n=t.name?.trim()?`${t.name} (${t.id})`:t.id;return l`
2188
2188
  <button
2189
2189
  class="btn btn--sm ${e.selectedScope===t.id?"active":""}"
2190
2190
  @click=${()=>e.onSelectScope(t.id)}
@@ -2194,7 +2194,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2194
2194
  `})}
2195
2195
  </div>
2196
2196
  </div>
2197
- `}function Hf(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,r=typeof s.askFallback=="string"?s.askFallback:void 0,l=t?n.security:a??"__default__",u=t?n.ask:o??"__default__",d=t?n.askFallback:r??"__default__",p=typeof s.autoAllowSkills=="boolean"?s.autoAllowSkills:void 0,f=p??n.autoAllowSkills,m=p==null;return c`
2197
+ `}function jf(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,r=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 l`
2198
2198
  <div class="list" style="margin-top: 16px;">
2199
2199
  <div class="list-item">
2200
2200
  <div class="list-main">
@@ -2210,12 +2210,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2210
2210
  ?disabled=${e.disabled}
2211
2211
  @change=${v=>{const k=v.target.value;!t&&k==="__default__"?e.onRemove([...i,"security"]):e.onPatch([...i,"security"],k)}}
2212
2212
  >
2213
- ${t?g:c`<option value="__default__" ?selected=${l==="__default__"}>
2213
+ ${t?g:l`<option value="__default__" ?selected=${r==="__default__"}>
2214
2214
  Use default (${n.security})
2215
2215
  </option>`}
2216
- ${uo.map(v=>c`<option
2216
+ ${po.map(v=>l`<option
2217
2217
  value=${v.value}
2218
- ?selected=${l===v.value}
2218
+ ?selected=${r===v.value}
2219
2219
  >
2220
2220
  ${v.label}
2221
2221
  </option>`)}
@@ -2238,10 +2238,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2238
2238
  ?disabled=${e.disabled}
2239
2239
  @change=${v=>{const k=v.target.value;!t&&k==="__default__"?e.onRemove([...i,"ask"]):e.onPatch([...i,"ask"],k)}}
2240
2240
  >
2241
- ${t?g:c`<option value="__default__" ?selected=${u==="__default__"}>
2241
+ ${t?g:l`<option value="__default__" ?selected=${u==="__default__"}>
2242
2242
  Use default (${n.ask})
2243
2243
  </option>`}
2244
- ${Lf.map(v=>c`<option
2244
+ ${Pf.map(v=>l`<option
2245
2245
  value=${v.value}
2246
2246
  ?selected=${u===v.value}
2247
2247
  >
@@ -2266,10 +2266,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2266
2266
  ?disabled=${e.disabled}
2267
2267
  @change=${v=>{const k=v.target.value;!t&&k==="__default__"?e.onRemove([...i,"askFallback"]):e.onPatch([...i,"askFallback"],k)}}
2268
2268
  >
2269
- ${t?g:c`<option value="__default__" ?selected=${d==="__default__"}>
2269
+ ${t?g:l`<option value="__default__" ?selected=${d==="__default__"}>
2270
2270
  Use default (${n.askFallback})
2271
2271
  </option>`}
2272
- ${uo.map(v=>c`<option
2272
+ ${po.map(v=>l`<option
2273
2273
  value=${v.value}
2274
2274
  ?selected=${d===v.value}
2275
2275
  >
@@ -2297,7 +2297,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2297
2297
  @change=${v=>{const $=v.target;e.onPatch([...i,"autoAllowSkills"],$.checked)}}
2298
2298
  />
2299
2299
  </label>
2300
- ${!t&&!m?c`<button
2300
+ ${!t&&!m?l`<button
2301
2301
  class="btn btn--sm"
2302
2302
  ?disabled=${e.disabled}
2303
2303
  @click=${()=>e.onRemove([...i,"autoAllowSkills"])}
@@ -2307,7 +2307,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2307
2307
  </div>
2308
2308
  </div>
2309
2309
  </div>
2310
- `}function jf(e){const t=["agents",e.selectedScope,"allowlist"],n=e.allowlist;return c`
2310
+ `}function Vf(e){const t=["agents",e.selectedScope,"allowlist"],n=e.allowlist;return l`
2311
2311
  <div class="row" style="margin-top: 18px; justify-content: space-between;">
2312
2312
  <div>
2313
2313
  <div class="card-title">Allowlist</div>
@@ -2322,17 +2322,17 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2322
2322
  </button>
2323
2323
  </div>
2324
2324
  <div class="list" style="margin-top: 12px;">
2325
- ${n.length===0?c`
2325
+ ${n.length===0?l`
2326
2326
  <div class="muted">No allowlist entries yet.</div>
2327
- `:n.map((s,i)=>Vf(e,s,i))}
2327
+ `:n.map((s,i)=>Wf(e,s,i))}
2328
2328
  </div>
2329
- `}function Vf(e,t,n){const s=t.lastUsedAt?$n(t.lastUsedAt):"never",i=t.lastUsedCommand?As(t.lastUsedCommand,120):null,a=t.lastResolvedPath?As(t.lastResolvedPath,120):null;return c`
2329
+ `}function Wf(e,t,n){const s=t.lastUsedAt?xn(t.lastUsedAt):"never",i=t.lastUsedCommand?_s(t.lastUsedCommand,120):null,a=t.lastResolvedPath?_s(t.lastResolvedPath,120):null;return l`
2330
2330
  <div class="list-item">
2331
2331
  <div class="list-main">
2332
2332
  <div class="list-title">${t.pattern?.trim()?t.pattern:"New pattern"}</div>
2333
2333
  <div class="list-sub">Last used: ${s}</div>
2334
- ${i?c`<div class="list-sub mono">${i}</div>`:g}
2335
- ${a?c`<div class="list-sub mono">${a}</div>`:g}
2334
+ ${i?l`<div class="list-sub mono">${i}</div>`:g}
2335
+ ${a?l`<div class="list-sub mono">${a}</div>`:g}
2336
2336
  </div>
2337
2337
  <div class="list-meta">
2338
2338
  <label class="field">
@@ -2341,7 +2341,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2341
2341
  type="text"
2342
2342
  .value=${t.pattern??""}
2343
2343
  ?disabled=${e.disabled}
2344
- @input=${o=>{const r=o.target;e.onPatch(["agents",e.selectedScope,"allowlist",n,"pattern"],r.value)}}
2344
+ @input=${o=>{const c=o.target;e.onPatch(["agents",e.selectedScope,"allowlist",n,"pattern"],c.value)}}
2345
2345
  />
2346
2346
  </label>
2347
2347
  <button
@@ -2353,10 +2353,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2353
2353
  </button>
2354
2354
  </div>
2355
2355
  </div>
2356
- `}function Wf(e){return zr(e,["system.execApprovals.get","system.execApprovals.set"])}function qf(e){const t=Zf(e),n=Ff(e);return c`
2357
- ${Uf(n)}
2358
- ${Xf(t)}
2359
- ${Gf(e)}
2356
+ `}function qf(e){return zr(e,["system.execApprovals.get","system.execApprovals.set"])}function Gf(e){const t=Xf(e),n=Uf(e);return l`
2357
+ ${Kf(n)}
2358
+ ${eg(t)}
2359
+ ${Yf(e)}
2360
2360
  <section class="card">
2361
2361
  <div class="row" style="justify-content: space-between;">
2362
2362
  <div>
@@ -2368,12 +2368,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2368
2368
  </button>
2369
2369
  </div>
2370
2370
  <div class="list" style="margin-top: 16px;">
2371
- ${e.nodes.length===0?c`
2371
+ ${e.nodes.length===0?l`
2372
2372
  <div class="muted">No nodes found.</div>
2373
- `:e.nodes.map(s=>sg(s))}
2373
+ `:e.nodes.map(s=>ig(s))}
2374
2374
  </div>
2375
2375
  </section>
2376
- `}function Gf(e){const t=e.devicesList??{pending:[],paired:[]},n=Array.isArray(t.pending)?t.pending:[],s=Array.isArray(t.paired)?t.paired:[];return c`
2376
+ `}function Yf(e){const t=e.devicesList??{pending:[],paired:[]},n=Array.isArray(t.pending)?t.pending:[],s=Array.isArray(t.paired)?t.paired:[];return l`
2377
2377
  <section class="card">
2378
2378
  <div class="row" style="justify-content: space-between;">
2379
2379
  <div>
@@ -2384,22 +2384,22 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2384
2384
  ${e.devicesLoading?"Loading…":"Refresh"}
2385
2385
  </button>
2386
2386
  </div>
2387
- ${e.devicesError?c`<div class="callout danger" style="margin-top: 12px;">${e.devicesError}</div>`:g}
2387
+ ${e.devicesError?l`<div class="callout danger" style="margin-top: 12px;">${e.devicesError}</div>`:g}
2388
2388
  <div class="list" style="margin-top: 16px;">
2389
- ${n.length>0?c`
2389
+ ${n.length>0?l`
2390
2390
  <div class="muted" style="margin-bottom: 8px;">Pending</div>
2391
- ${n.map(i=>Yf(i,e))}
2391
+ ${n.map(i=>Qf(i,e))}
2392
2392
  `:g}
2393
- ${s.length>0?c`
2393
+ ${s.length>0?l`
2394
2394
  <div class="muted" style="margin-top: 12px; margin-bottom: 8px;">Paired</div>
2395
- ${s.map(i=>Qf(i,e))}
2395
+ ${s.map(i=>Jf(i,e))}
2396
2396
  `:g}
2397
- ${n.length===0&&s.length===0?c`
2397
+ ${n.length===0&&s.length===0?l`
2398
2398
  <div class="muted">No paired devices.</div>
2399
2399
  `:g}
2400
2400
  </div>
2401
2401
  </section>
2402
- `}function Yf(e,t){const n=e.displayName?.trim()||e.deviceId,s=typeof e.ts=="number"?$n(e.ts):"n/a",i=e.role?.trim()?`role: ${e.role}`:"role: -",a=e.isRepair?" · repair":"",o=e.remoteIp?` · ${e.remoteIp}`:"";return c`
2402
+ `}function Qf(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 l`
2403
2403
  <div class="list-item">
2404
2404
  <div class="list-main">
2405
2405
  <div class="list-title">${n}</div>
@@ -2419,23 +2419,23 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2419
2419
  </div>
2420
2420
  </div>
2421
2421
  </div>
2422
- `}function Qf(e,t){const n=e.displayName?.trim()||e.deviceId,s=e.remoteIp?` · ${e.remoteIp}`:"",i=`roles: ${Ss(e.roles)}`,a=`scopes: ${Ss(e.scopes)}`,o=Array.isArray(e.tokens)?e.tokens:[];return c`
2422
+ `}function Jf(e,t){const n=e.displayName?.trim()||e.deviceId,s=e.remoteIp?` · ${e.remoteIp}`:"",i=`roles: ${As(e.roles)}`,a=`scopes: ${As(e.scopes)}`,o=Array.isArray(e.tokens)?e.tokens:[];return l`
2423
2423
  <div class="list-item">
2424
2424
  <div class="list-main">
2425
2425
  <div class="list-title">${n}</div>
2426
2426
  <div class="list-sub">${e.deviceId}${s}</div>
2427
2427
  <div class="muted" style="margin-top: 6px;">${i} · ${a}</div>
2428
- ${o.length===0?c`
2428
+ ${o.length===0?l`
2429
2429
  <div class="muted" style="margin-top: 6px">Tokens: none</div>
2430
- `:c`
2430
+ `:l`
2431
2431
  <div class="muted" style="margin-top: 10px;">Tokens</div>
2432
2432
  <div style="display: flex; flex-direction: column; gap: 8px; margin-top: 6px;">
2433
- ${o.map(r=>Jf(e.deviceId,r,t))}
2433
+ ${o.map(c=>Zf(e.deviceId,c,t))}
2434
2434
  </div>
2435
2435
  `}
2436
2436
  </div>
2437
2437
  </div>
2438
- `}function Jf(e,t,n){const s=t.revokedAtMs?"revoked":"active",i=`scopes: ${Ss(t.scopes)}`,a=$n(t.rotatedAtMs??t.createdAtMs??t.lastUsedAtMs??null);return c`
2438
+ `}function Zf(e,t,n){const s=t.revokedAtMs?"revoked":"active",i=`scopes: ${As(t.scopes)}`,a=xn(t.rotatedAtMs??t.createdAtMs??t.lastUsedAtMs??null);return l`
2439
2439
  <div class="row" style="justify-content: space-between; gap: 8px;">
2440
2440
  <div class="list-sub">${t.role} · ${s} · ${i} · ${a}</div>
2441
2441
  <div class="row" style="justify-content: flex-end; gap: 6px; flex-wrap: wrap;">
@@ -2445,7 +2445,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2445
2445
  >
2446
2446
  Rotate
2447
2447
  </button>
2448
- ${t.revokedAtMs?g:c`
2448
+ ${t.revokedAtMs?g:l`
2449
2449
  <button
2450
2450
  class="btn btn--sm danger"
2451
2451
  @click=${()=>n.onDeviceRevoke(e,t.role)}
@@ -2455,7 +2455,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2455
2455
  `}
2456
2456
  </div>
2457
2457
  </div>
2458
- `}function Zf(e){const t=e.configForm,n=tg(e.nodes),{defaultBinding:s,agents:i}=ng(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 Xf(e){const t=e.nodes.length>0,n=e.defaultBinding??"";return c`
2458
+ `}function Xf(e){const t=e.configForm,n=ng(e.nodes),{defaultBinding:s,agents:i}=sg(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 eg(e){const t=e.nodes.length>0,n=e.defaultBinding??"";return l`
2459
2459
  <section class="card">
2460
2460
  <div class="row" style="justify-content: space-between; align-items: center;">
2461
2461
  <div>
@@ -2473,13 +2473,13 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2473
2473
  </button>
2474
2474
  </div>
2475
2475
 
2476
- ${e.formMode==="raw"?c`
2476
+ ${e.formMode==="raw"?l`
2477
2477
  <div class="callout warn" style="margin-top: 12px">
2478
2478
  Switch the Config tab to <strong>Form</strong> mode to edit bindings here.
2479
2479
  </div>
2480
2480
  `:g}
2481
2481
 
2482
- ${e.ready?c`
2482
+ ${e.ready?l`
2483
2483
  <div class="list" style="margin-top: 16px;">
2484
2484
  <div class="list-item">
2485
2485
  <div class="list-main">
@@ -2494,7 +2494,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2494
2494
  @change=${s=>{const a=s.target.value.trim();e.onBindDefault(a||null)}}
2495
2495
  >
2496
2496
  <option value="" ?selected=${n===""}>Any node</option>
2497
- ${e.nodes.map(s=>c`<option
2497
+ ${e.nodes.map(s=>l`<option
2498
2498
  value=${s.id}
2499
2499
  ?selected=${n===s.id}
2500
2500
  >
@@ -2502,24 +2502,24 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2502
2502
  </option>`)}
2503
2503
  </select>
2504
2504
  </label>
2505
- ${t?g:c`
2505
+ ${t?g:l`
2506
2506
  <div class="muted">No nodes with system.run available.</div>
2507
2507
  `}
2508
2508
  </div>
2509
2509
  </div>
2510
2510
 
2511
- ${e.agents.length===0?c`
2511
+ ${e.agents.length===0?l`
2512
2512
  <div class="muted">No agents found.</div>
2513
- `:e.agents.map(s=>eg(s,e))}
2513
+ `:e.agents.map(s=>tg(s,e))}
2514
2514
  </div>
2515
- `:c`<div class="row" style="margin-top: 12px; gap: 12px;">
2515
+ `:l`<div class="row" style="margin-top: 12px; gap: 12px;">
2516
2516
  <div class="muted">Load config to edit bindings.</div>
2517
2517
  <button class="btn" ?disabled=${e.configLoading} @click=${e.onLoadConfig}>
2518
2518
  ${e.configLoading?"Loading…":"Load config"}
2519
2519
  </button>
2520
2520
  </div>`}
2521
2521
  </section>
2522
- `}function eg(e,t){const n=e.binding??"__default__",s=e.name?.trim()?`${e.name} (${e.id})`:e.id,i=t.nodes.length>0;return c`
2522
+ `}function tg(e,t){const n=e.binding??"__default__",s=e.name?.trim()?`${e.name} (${e.id})`:e.id,i=t.nodes.length>0;return l`
2523
2523
  <div class="list-item">
2524
2524
  <div class="list-main">
2525
2525
  <div class="list-title">${s}</div>
@@ -2533,12 +2533,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2533
2533
  <span>Binding</span>
2534
2534
  <select
2535
2535
  ?disabled=${t.disabled||!i}
2536
- @change=${a=>{const r=a.target.value.trim();t.onBindAgent(e.index,r==="__default__"?null:r)}}
2536
+ @change=${a=>{const c=a.target.value.trim();t.onBindAgent(e.index,c==="__default__"?null:c)}}
2537
2537
  >
2538
2538
  <option value="__default__" ?selected=${n==="__default__"}>
2539
2539
  Use default
2540
2540
  </option>
2541
- ${t.nodes.map(a=>c`<option
2541
+ ${t.nodes.map(a=>l`<option
2542
2542
  value=${a.id}
2543
2543
  ?selected=${n===a.id}
2544
2544
  >
@@ -2548,7 +2548,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2548
2548
  </label>
2549
2549
  </div>
2550
2550
  </div>
2551
- `}function tg(e){return zr(e,["system.run"])}function ng(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=Kr(e).map(r=>{const u=(r.record.tools??{}).exec??{},d=typeof u.node=="string"&&u.node.trim()?u.node.trim():null;return{id:r.id,name:r.name,index:r.index,isDefault:r.isDefault,binding:d}});return o.length===0&&o.push(t),{defaultBinding:i,agents:o}}function sg(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 c`
2551
+ `}function ng(e){return zr(e,["system.run"])}function sg(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=Kr(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 ig(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 l`
2552
2552
  <div class="list-item">
2553
2553
  <div class="list-main">
2554
2554
  <div class="list-title">${s}</div>
@@ -2562,84 +2562,60 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2562
2562
  <span class="chip ${t?"chip-ok":"chip-warn"}">
2563
2563
  ${t?"connected":"offline"}
2564
2564
  </span>
2565
- ${i.slice(0,12).map(o=>c`<span class="chip">${String(o)}</span>`)}
2566
- ${a.slice(0,8).map(o=>c`<span class="chip">${String(o)}</span>`)}
2565
+ ${i.slice(0,12).map(o=>l`<span class="chip">${String(o)}</span>`)}
2566
+ ${a.slice(0,8).map(o=>l`<span class="chip">${String(o)}</span>`)}
2567
2567
  </div>
2568
2568
  </div>
2569
2569
  </div>
2570
- `}function ig(e){const t=e.hello?.snapshot,n=t?.uptimeMs?Ro(t.uptimeMs):"n/a",s=t?.policy?.tickIntervalMs?`${t.policy.tickIntervalMs}ms`:"n/a",i=(()=>{if(e.connected||!e.lastError)return null;const o=e.lastError.toLowerCase();if(!(o.includes("unauthorized")||o.includes("connect failed")))return null;const l=!!e.settings.token.trim(),u=!!e.password.trim();return!l&&!u?c`
2570
+ `}function ag(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 og(e){const t=e.severity==="error"?"alert-banner--error":e.severity==="warning"?"alert-banner--warn":"alert-banner--info";return l`
2571
+ <div class="alert-banner ${t}">
2572
+ <span class="alert-banner__icon">${e.icon}</span>
2573
+ <div class="alert-banner__body">
2574
+ <div class="alert-banner__title">${e.title}</div>
2575
+ <div class="alert-banner__desc">${e.description}</div>
2576
+ </div>
2577
+ </div>
2578
+ `}function it(e,t,n,s="ok"){return l`
2579
+ <div class="health-card">
2580
+ <div class="health-card__header">
2581
+ <span class="hc-dot ${s==="ok"?"hc-dot--ok":s==="warn"?"hc-dot--warn":"hc-dot--err"}"></span>
2582
+ <span class="health-card__label">${e}</span>
2583
+ </div>
2584
+ <div class="health-card__value">${t}</div>
2585
+ <div class="health-card__hint">${n}</div>
2586
+ </div>
2587
+ `}function rg(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=ag(e),o=e.connected?"ok":e.lastError?"error":"warn",c=e.cronEnabled==null?"warn":e.cronEnabled?"ok":"warn",r=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?l`
2571
2588
  <div class="muted" style="margin-top: 8px;">
2572
2589
  This gateway requires auth. Add a token or password, then click Connect.
2573
- <div style="margin-top: 6px;">
2574
- <span class="mono">poolbot dashboard --no-open</span> → tokenized URL<br />
2575
- <span class="mono">poolbot doctor --generate-gateway-token</span> → set token
2576
- </div>
2577
- <div style="margin-top: 6px;">
2578
- <a
2579
- class="session-link"
2580
- href="https://docs.molt.bot/web/dashboard"
2581
- target="_blank"
2582
- rel="noreferrer"
2583
- title="Control UI auth docs (opens in new tab)"
2584
- >Docs: Control UI auth</a
2585
- >
2586
- </div>
2587
2590
  </div>
2588
- `:c`
2591
+ `:l`
2589
2592
  <div class="muted" style="margin-top: 8px;">
2590
- Auth failed. Re-copy a tokenized URL with
2591
- <span class="mono">poolbot dashboard --no-open</span>, or update the token,
2592
- then click Connect.
2593
- <div style="margin-top: 6px;">
2594
- <a
2595
- class="session-link"
2596
- href="https://docs.molt.bot/web/dashboard"
2597
- target="_blank"
2598
- rel="noreferrer"
2599
- title="Control UI auth docs (opens in new tab)"
2600
- >Docs: Control UI auth</a
2601
- >
2602
- </div>
2603
- </div>
2604
- `})(),a=(()=>{if(e.connected||!e.lastError||(typeof window<"u"?window.isSecureContext:!0)!==!1)return null;const r=e.lastError.toLowerCase();return!r.includes("secure context")&&!r.includes("device identity required")?null:c`
2605
- <div class="muted" style="margin-top: 8px;">
2606
- This page is HTTP, so the browser blocks device identity. Use HTTPS (Tailscale Serve) or
2607
- open <span class="mono">http://127.0.0.1:18789</span> on the gateway host.
2608
- <div style="margin-top: 6px;">
2609
- If you must stay on HTTP, set
2610
- <span class="mono">gateway.controlUi.allowInsecureAuth: true</span> (token-only).
2611
- </div>
2612
- <div style="margin-top: 6px;">
2613
- <a
2614
- class="session-link"
2615
- href="https://docs.molt.bot/gateway/tailscale"
2616
- target="_blank"
2617
- rel="noreferrer"
2618
- title="Tailscale Serve docs (opens in new tab)"
2619
- >Docs: Tailscale Serve</a
2620
- >
2621
- <span class="muted"> · </span>
2622
- <a
2623
- class="session-link"
2624
- href="https://docs.molt.bot/web/control-ui#insecure-http"
2625
- target="_blank"
2626
- rel="noreferrer"
2627
- title="Insecure HTTP docs (opens in new tab)"
2628
- >Docs: Insecure HTTP</a
2629
- >
2630
- </div>
2631
- </div>
2632
- `})();return c`
2633
- <section class="grid grid-cols-2">
2634
- <div class="card">
2593
+ Auth failed. Update the token, then click Connect.
2594
+ </div>
2595
+ `})();return l`
2596
+ ${a.length>0?l`<section class="alert-stack">
2597
+ ${a.map(og)}
2598
+ </section>`:g}
2599
+
2600
+ <section class="health-grid">
2601
+ ${it("Gateway",e.connected?"Online":"Offline",e.connected?`Uptime ${s}`:"Not connected",o)}
2602
+ ${it("Instances",String(e.presenceCount),"Presence beacons active",e.presenceCount>0?"ok":"warn")}
2603
+ ${it("Sessions",String(e.sessionsCount??"n/a"),"Tracked by gateway","ok")}
2604
+ ${it("Cron",e.cronEnabled==null?"n/a":e.cronEnabled?`${Ur(e.cronNext)}`:"Disabled",e.cronEnabled?"Next scheduled run":"Agent scheduling paused",c)}
2605
+ ${it("Channels",e.lastChannelsRefresh?D(e.lastChannelsRefresh):"n/a","Last refresh",r)}
2606
+ ${it("Tick",i,"Gateway heartbeat interval","ok")}
2607
+ </section>
2608
+
2609
+ <section class="grid grid-cols-2" style="margin-top: 18px;">
2610
+ <div class="card glass-card">
2635
2611
  <div class="card-title">Gateway Access</div>
2636
- <div class="card-sub">Where the dashboard connects and how it authenticates.</div>
2612
+ <div class="card-sub">Connection settings for the dashboard.</div>
2637
2613
  <div class="form-grid" style="margin-top: 16px;">
2638
2614
  <label class="field">
2639
2615
  <span>WebSocket URL</span>
2640
2616
  <input
2641
2617
  .value=${e.settings.gatewayUrl}
2642
- @input=${o=>{const r=o.target.value;e.onSettingsChange({...e.settings,gatewayUrl:r})}}
2618
+ @input=${d=>{const p=d.target.value;e.onSettingsChange({...e.settings,gatewayUrl:p})}}
2643
2619
  placeholder="ws://100.x.y.z:18789"
2644
2620
  />
2645
2621
  </label>
@@ -2647,110 +2623,51 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2647
2623
  <span>Gateway Token</span>
2648
2624
  <input
2649
2625
  .value=${e.settings.token}
2650
- @input=${o=>{const r=o.target.value;e.onSettingsChange({...e.settings,token:r})}}
2651
- placeholder="CLAWDBOT_GATEWAY_TOKEN"
2626
+ @input=${d=>{const p=d.target.value;e.onSettingsChange({...e.settings,token:p})}}
2627
+ placeholder="POOLBOT_GATEWAY_TOKEN"
2652
2628
  />
2653
2629
  </label>
2654
2630
  <label class="field">
2655
- <span>Password (not stored)</span>
2631
+ <span>Password</span>
2656
2632
  <input
2657
2633
  type="password"
2658
2634
  .value=${e.password}
2659
- @input=${o=>{const r=o.target.value;e.onPasswordChange(r)}}
2635
+ @input=${d=>{const p=d.target.value;e.onPasswordChange(p)}}
2660
2636
  placeholder="system or shared password"
2661
2637
  />
2662
2638
  </label>
2663
- <label class="field">
2664
- <span>Default Session Key</span>
2665
- <input
2666
- .value=${e.settings.sessionKey}
2667
- @input=${o=>{const r=o.target.value;e.onSessionKeyChange(r)}}
2668
- />
2669
- </label>
2670
2639
  </div>
2671
2640
  <div class="row" style="margin-top: 14px;">
2672
2641
  <button class="btn" @click=${()=>e.onConnect()}>Connect</button>
2673
2642
  <button class="btn" @click=${()=>e.onRefresh()}>Refresh</button>
2674
- <span class="muted">Click Connect to apply connection changes.</span>
2675
2643
  </div>
2644
+ ${e.lastError?l`<div class="callout danger" style="margin-top: 14px;">${e.lastError}${u??""}</div>`:g}
2676
2645
  </div>
2677
2646
 
2678
- <div class="card">
2679
- <div class="card-title">Snapshot</div>
2680
- <div class="card-sub">Latest gateway handshake information.</div>
2681
- <div class="stat-grid" style="margin-top: 16px;">
2682
- <div class="stat">
2683
- <div class="stat-label">Status</div>
2684
- <div class="stat-value ${e.connected?"ok":"warn"}">
2685
- ${e.connected?"Connected":"Disconnected"}
2686
- </div>
2647
+ <div class="card glass-card">
2648
+ <div class="card-title">Quick Actions</div>
2649
+ <div class="card-sub">Common operations.</div>
2650
+ <div class="qa-grid" style="margin-top: 16px;">
2651
+ <div class="qa-item">
2652
+ <div class="qa-item__label">Reset Session</div>
2653
+ <div class="muted">Use <span class="mono">/new</span> or <span class="mono">/reset</span> in chat.</div>
2687
2654
  </div>
2688
- <div class="stat">
2689
- <div class="stat-label">Uptime</div>
2690
- <div class="stat-value">${n}</div>
2655
+ <div class="qa-item">
2656
+ <div class="qa-item__label">Tailscale Serve</div>
2657
+ <div class="muted">Prefer serve mode to keep gateway on loopback with tailnet auth.</div>
2691
2658
  </div>
2692
- <div class="stat">
2693
- <div class="stat-label">Tick Interval</div>
2694
- <div class="stat-value">${s}</div>
2659
+ <div class="qa-item">
2660
+ <div class="qa-item__label">Cron Sessions</div>
2661
+ <div class="muted">Use isolated sessions for recurring agent runs.</div>
2695
2662
  </div>
2696
- <div class="stat">
2697
- <div class="stat-label">Last Channels Refresh</div>
2698
- <div class="stat-value">
2699
- ${e.lastChannelsRefresh?B(e.lastChannelsRefresh):"n/a"}
2700
- </div>
2701
- </div>
2702
- </div>
2703
- ${e.lastError?c`<div class="callout danger" style="margin-top: 14px;">
2704
- <div>${e.lastError}</div>
2705
- ${i??""}
2706
- ${a??""}
2707
- </div>`:c`<div class="callout" style="margin-top: 14px;">
2708
- Use Channels to link WhatsApp, Telegram, Discord, Signal, or iMessage.
2709
- </div>`}
2710
- </div>
2711
- </section>
2712
-
2713
- <section class="grid grid-cols-3" style="margin-top: 18px;">
2714
- <div class="card stat-card">
2715
- <div class="stat-label">Instances</div>
2716
- <div class="stat-value">${e.presenceCount}</div>
2717
- <div class="muted">Presence beacons in the last 5 minutes.</div>
2718
- </div>
2719
- <div class="card stat-card">
2720
- <div class="stat-label">Sessions</div>
2721
- <div class="stat-value">${e.sessionsCount??"n/a"}</div>
2722
- <div class="muted">Recent session keys tracked by the gateway.</div>
2723
- </div>
2724
- <div class="card stat-card">
2725
- <div class="stat-label">Cron</div>
2726
- <div class="stat-value">
2727
- ${e.cronEnabled==null?"n/a":e.cronEnabled?"Enabled":"Disabled"}
2728
- </div>
2729
- <div class="muted">Next wake ${Ur(e.cronNext)}</div>
2730
- </div>
2731
- </section>
2732
-
2733
- <section class="card" style="margin-top: 18px;">
2734
- <div class="card-title">Notes</div>
2735
- <div class="card-sub">Quick reminders for remote control setups.</div>
2736
- <div class="note-grid" style="margin-top: 14px;">
2737
- <div>
2738
- <div class="note-title">Tailscale serve</div>
2739
- <div class="muted">
2740
- Prefer serve mode to keep the gateway on loopback with tailnet auth.
2663
+ <div class="qa-item">
2664
+ <div class="qa-item__label">Doctor</div>
2665
+ <div class="muted">Run <span class="mono">poolbot doctor</span> for health checks and migrations.</div>
2741
2666
  </div>
2742
2667
  </div>
2743
- <div>
2744
- <div class="note-title">Session hygiene</div>
2745
- <div class="muted">Use /new or sessions.patch to reset context.</div>
2746
- </div>
2747
- <div>
2748
- <div class="note-title">Cron reminders</div>
2749
- <div class="muted">Use isolated sessions for recurring runs.</div>
2750
- </div>
2751
2668
  </div>
2752
2669
  </section>
2753
- `}const ag=["","off","minimal","low","medium","high"],og=["","off","on"],rg=[{value:"",label:"inherit"},{value:"off",label:"off (explicit)"},{value:"on",label:"on"}],lg=["","off","on","stream"];function cg(e){if(!e)return"";const t=e.trim().toLowerCase();return t==="z.ai"||t==="z-ai"?"zai":t}function Hr(e){return cg(e)==="zai"}function dg(e){return Hr(e)?og:ag}function ug(e,t){return!t||!e||e==="off"?e:"on"}function pg(e,t){return e?t&&e==="on"?"low":e:null}function hg(e){const t=e.result?.sessions??[];return c`
2670
+ `}const lg=["","off","minimal","low","medium","high"],cg=["","off","on"],dg=[{value:"",label:"inherit"},{value:"off",label:"off (explicit)"},{value:"on",label:"on"}],ug=["","off","on","stream"];function pg(e){if(!e)return"";const t=e.trim().toLowerCase();return t==="z.ai"||t==="z-ai"?"zai":t}function Hr(e){return pg(e)==="zai"}function hg(e){return Hr(e)?cg:lg}function fg(e,t){return!t||!e||e==="off"?e:"on"}function gg(e,t){return e?t&&e==="on"?"low":e:null}function mg(e){const t=e.result?.sessions??[];return l`
2754
2671
  <section class="card">
2755
2672
  <div class="row" style="justify-content: space-between;">
2756
2673
  <div>
@@ -2795,7 +2712,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2795
2712
  </label>
2796
2713
  </div>
2797
2714
 
2798
- ${e.error?c`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:g}
2715
+ ${e.error?l`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:g}
2799
2716
 
2800
2717
  <div class="muted" style="margin-top: 12px;">
2801
2718
  ${e.result?`Store: ${e.result.path}`:""}
@@ -2813,12 +2730,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2813
2730
  <div>Reasoning</div>
2814
2731
  <div>Actions</div>
2815
2732
  </div>
2816
- ${t.length===0?c`<div class="muted">No sessions found.</div>`:t.map(n=>fg(n,e.basePath,e.onPatch,e.onDelete,e.loading))}
2733
+ ${t.length===0?l`<div class="muted">No sessions found.</div>`:t.map(n=>vg(n,e.basePath,e.onPatch,e.onDelete,e.loading))}
2817
2734
  </div>
2818
2735
  </section>
2819
- `}function fg(e,t,n,s,i){const a=e.updatedAt?B(e.updatedAt):"n/a",o=e.thinkingLevel??"",r=Hr(e.modelProvider),l=ug(o,r),u=dg(e.modelProvider),d=e.verboseLevel??"",p=e.reasoningLevel??"",f=e.displayName??e.key,m=e.kind!=="global",v=m?`${wn("chat",t)}?session=${encodeURIComponent(e.key)}`:null;return c`
2736
+ `}function vg(e,t,n,s,i){const a=e.updatedAt?D(e.updatedAt):"n/a",o=e.thinkingLevel??"",c=Hr(e.modelProvider),r=fg(o,c),u=hg(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 l`
2820
2737
  <div class="table-row">
2821
- <div class="mono">${m?c`<a href=${v} class="session-link">${f}</a>`:f}</div>
2738
+ <div class="mono">${m?l`<a href=${v} class="session-link">${f}</a>`:f}</div>
2822
2739
  <div>
2823
2740
  <input
2824
2741
  .value=${e.label??""}
@@ -2829,14 +2746,14 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2829
2746
  </div>
2830
2747
  <div>${e.kind}</div>
2831
2748
  <div>${a}</div>
2832
- <div>${mf(e)}</div>
2749
+ <div>${vf(e)}</div>
2833
2750
  <div>
2834
2751
  <select
2835
- .value=${l}
2752
+ .value=${r}
2836
2753
  ?disabled=${i}
2837
- @change=${$=>{const k=$.target.value;n(e.key,{thinkingLevel:pg(k,r)})}}
2754
+ @change=${$=>{const k=$.target.value;n(e.key,{thinkingLevel:gg(k,c)})}}
2838
2755
  >
2839
- ${u.map($=>c`<option value=${$}>${$||"inherit"}</option>`)}
2756
+ ${u.map($=>l`<option value=${$}>${$||"inherit"}</option>`)}
2840
2757
  </select>
2841
2758
  </div>
2842
2759
  <div>
@@ -2845,7 +2762,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2845
2762
  ?disabled=${i}
2846
2763
  @change=${$=>{const k=$.target.value;n(e.key,{verboseLevel:k||null})}}
2847
2764
  >
2848
- ${rg.map($=>c`<option value=${$.value}>${$.label}</option>`)}
2765
+ ${dg.map($=>l`<option value=${$.value}>${$.label}</option>`)}
2849
2766
  </select>
2850
2767
  </div>
2851
2768
  <div>
@@ -2854,7 +2771,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2854
2771
  ?disabled=${i}
2855
2772
  @change=${$=>{const k=$.target.value;n(e.key,{reasoningLevel:k||null})}}
2856
2773
  >
2857
- ${lg.map($=>c`<option value=${$}>${$||"inherit"}</option>`)}
2774
+ ${ug.map($=>l`<option value=${$}>${$||"inherit"}</option>`)}
2858
2775
  </select>
2859
2776
  </div>
2860
2777
  <div>
@@ -2863,7 +2780,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2863
2780
  </button>
2864
2781
  </div>
2865
2782
  </div>
2866
- `}function gg(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?c`<div class="exec-approval-meta-row"><span>${e}</span><span>${t}</span></div>`:g}function mg(e){const t=e.execApprovalQueue[0];if(!t)return g;const n=t.request,s=t.expiresAtMs-Date.now(),i=s>0?`expires in ${gg(s)}`:"expired",a=e.execApprovalQueue.length;return c`
2783
+ `}function yg(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?l`<div class="exec-approval-meta-row"><span>${e}</span><span>${t}</span></div>`:g}function bg(e){const t=e.execApprovalQueue[0];if(!t)return g;const n=t.request,s=t.expiresAtMs-Date.now(),i=s>0?`expires in ${yg(s)}`:"expired",a=e.execApprovalQueue.length;return l`
2867
2784
  <div class="exec-approval-overlay" role="dialog" aria-live="polite">
2868
2785
  <div class="exec-approval-card">
2869
2786
  <div class="exec-approval-header">
@@ -2871,7 +2788,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2871
2788
  <div class="exec-approval-title">Exec approval needed</div>
2872
2789
  <div class="exec-approval-sub">${i}</div>
2873
2790
  </div>
2874
- ${a>1?c`<div class="exec-approval-queue">${a} pending</div>`:g}
2791
+ ${a>1?l`<div class="exec-approval-queue">${a} pending</div>`:g}
2875
2792
  </div>
2876
2793
  <div class="exec-approval-command mono">${n.command}</div>
2877
2794
  <div class="exec-approval-meta">
@@ -2883,7 +2800,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2883
2800
  ${Fe("Security",n.security)}
2884
2801
  ${Fe("Ask",n.ask)}
2885
2802
  </div>
2886
- ${e.execApprovalError?c`<div class="exec-approval-error">${e.execApprovalError}</div>`:g}
2803
+ ${e.execApprovalError?l`<div class="exec-approval-error">${e.execApprovalError}</div>`:g}
2887
2804
  <div class="exec-approval-actions">
2888
2805
  <button
2889
2806
  class="btn primary"
@@ -2909,7 +2826,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2909
2826
  </div>
2910
2827
  </div>
2911
2828
  </div>
2912
- `}function vg(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 c`
2829
+ `}function wg(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 l`
2913
2830
  <section class="card">
2914
2831
  <div class="row" style="justify-content: space-between;">
2915
2832
  <div>
@@ -2933,36 +2850,36 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2933
2850
  <div class="muted">${s.length} shown</div>
2934
2851
  </div>
2935
2852
 
2936
- ${e.error?c`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:g}
2853
+ ${e.error?l`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:g}
2937
2854
 
2938
- ${s.length===0?c`<div class="muted" style="margin-top: 16px;">No skills found.</div>`:c`
2855
+ ${s.length===0?l`<div class="muted" style="margin-top: 16px;">No skills found.</div>`:l`
2939
2856
  <div class="list" style="margin-top: 16px;">
2940
- ${s.map(i=>yg(i,e))}
2857
+ ${s.map(i=>$g(i,e))}
2941
2858
  </div>
2942
2859
  `}
2943
2860
  </section>
2944
- `}function yg(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}`)],r=[];return e.disabled&&r.push("disabled"),e.blockedByAllowlist&&r.push("blocked by allowlist"),c`
2861
+ `}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(r=>`bin:${r}`),...e.missing.env.map(r=>`env:${r}`),...e.missing.config.map(r=>`config:${r}`),...e.missing.os.map(r=>`os:${r}`)],c=[];return e.disabled&&c.push("disabled"),e.blockedByAllowlist&&c.push("blocked by allowlist"),l`
2945
2862
  <div class="list-item">
2946
2863
  <div class="list-main">
2947
2864
  <div class="list-title">
2948
2865
  ${e.emoji?`${e.emoji} `:""}${e.name}
2949
2866
  </div>
2950
- <div class="list-sub">${As(e.description,140)}</div>
2867
+ <div class="list-sub">${_s(e.description,140)}</div>
2951
2868
  <div class="chip-row" style="margin-top: 6px;">
2952
2869
  <span class="chip">${e.source}</span>
2953
2870
  <span class="chip ${e.eligible?"chip-ok":"chip-warn"}">
2954
2871
  ${e.eligible?"eligible":"blocked"}
2955
2872
  </span>
2956
- ${e.disabled?c`<span class="chip chip-warn">disabled</span>`:g}
2873
+ ${e.disabled?l`<span class="chip chip-warn">disabled</span>`:g}
2957
2874
  </div>
2958
- ${o.length>0?c`
2875
+ ${o.length>0?l`
2959
2876
  <div class="muted" style="margin-top: 6px;">
2960
2877
  Missing: ${o.join(", ")}
2961
2878
  </div>
2962
2879
  `:g}
2963
- ${r.length>0?c`
2880
+ ${c.length>0?l`
2964
2881
  <div class="muted" style="margin-top: 6px;">
2965
- Reason: ${r.join(", ")}
2882
+ Reason: ${c.join(", ")}
2966
2883
  </div>
2967
2884
  `:g}
2968
2885
  </div>
@@ -2975,7 +2892,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2975
2892
  >
2976
2893
  ${e.disabled?"Enable":"Disable"}
2977
2894
  </button>
2978
- ${a?c`<button
2895
+ ${a?l`<button
2979
2896
  class="btn"
2980
2897
  ?disabled=${n}
2981
2898
  @click=${()=>t.onInstall(e.skillKey,e.name,e.install[0].id)}
@@ -2983,19 +2900,19 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2983
2900
  ${n?"Installing…":e.install[0].label}
2984
2901
  </button>`:g}
2985
2902
  </div>
2986
- ${i?c`<div
2903
+ ${i?l`<div
2987
2904
  class="muted"
2988
2905
  style="margin-top: 8px; color: ${i.kind==="error"?"var(--danger-color, #d14343)":"var(--success-color, #0a7f5a)"};"
2989
2906
  >
2990
2907
  ${i.message}
2991
2908
  </div>`:g}
2992
- ${e.primaryEnv?c`
2909
+ ${e.primaryEnv?l`
2993
2910
  <div class="field" style="margin-top: 10px;">
2994
2911
  <span>API key</span>
2995
2912
  <input
2996
2913
  type="password"
2997
2914
  .value=${s}
2998
- @input=${l=>t.onEdit(e.skillKey,l.target.value)}
2915
+ @input=${r=>t.onEdit(e.skillKey,r.target.value)}
2999
2916
  />
3000
2917
  </div>
3001
2918
  <button
@@ -3009,33 +2926,33 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3009
2926
  `:g}
3010
2927
  </div>
3011
2928
  </div>
3012
- `}function bg(e,t){const n=wn(t,e.basePath);return c`
2929
+ `}function xg(e,t){const n=$n(t,e.basePath);return l`
3013
2930
  <a
3014
2931
  href=${n}
3015
2932
  class="nav-item ${e.tab===t?"active":""}"
3016
2933
  @click=${s=>{s.defaultPrevented||s.button!==0||s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||(s.preventDefault(),e.setTab(t))}}
3017
- title=${ks(t)}
2934
+ title=${Ss(t)}
3018
2935
  >
3019
2936
  <span class="nav-item__icon" aria-hidden="true">${G[ac(t)]}</span>
3020
- <span class="nav-item__text">${ks(t)}</span>
2937
+ <span class="nav-item__text">${Ss(t)}</span>
3021
2938
  </a>
3022
- `}function wg(e){const t=$g(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=c`<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>`,r=c`<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 c`
2939
+ `}function kg(e){const t=Sg(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=l`<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=l`<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 l`
3023
2940
  <div class="chat-controls">
3024
2941
  <label class="field chat-controls__session">
3025
2942
  <select
3026
2943
  .value=${e.sessionKey}
3027
2944
  ?disabled=${!e.connected}
3028
- @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(),au(e,u),rt(e)}}
2945
+ @change=${r=>{const u=r.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(),ou(e,u),lt(e)}}
3029
2946
  >
3030
- ${hr(t,l=>l.key,l=>c`<option value=${l.key}>
3031
- ${l.displayName??l.key}
2947
+ ${hr(t,r=>r.key,r=>l`<option value=${r.key}>
2948
+ ${r.displayName??r.key}
3032
2949
  </option>`)}
3033
2950
  </select>
3034
2951
  </label>
3035
2952
  <button
3036
2953
  class="btn btn--sm btn--icon"
3037
2954
  ?disabled=${e.chatLoading||!e.connected}
3038
- @click=${()=>{e.resetToolStream(),rt(e)}}
2955
+ @click=${()=>{e.resetToolStream(),lt(e)}}
3039
2956
  title="Refresh chat history"
3040
2957
  >
3041
2958
  ${o}
@@ -3057,10 +2974,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3057
2974
  aria-pressed=${a}
3058
2975
  title=${s?"Disabled during onboarding":"Toggle focus mode (hide sidebar + page header)"}
3059
2976
  >
3060
- ${r}
2977
+ ${c}
3061
2978
  </button>
3062
2979
  </div>
3063
- `}function $g(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 xg=["system","light","dark"];function kg(e){const t=Math.max(0,xg.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 c`
2980
+ `}function Sg(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 Ag=["system","light","dark"];function _g(e){const t=Math.max(0,Ag.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 l`
3064
2981
  <div class="theme-toggle" style="--theme-index: ${t};">
3065
2982
  <div class="theme-toggle__track" role="group" aria-label="Theme">
3066
2983
  <span class="theme-toggle__indicator"></span>
@@ -3071,7 +2988,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3071
2988
  aria-label="System theme"
3072
2989
  title="System"
3073
2990
  >
3074
- ${_g()}
2991
+ ${Eg()}
3075
2992
  </button>
3076
2993
  <button
3077
2994
  class="theme-toggle__button ${e.theme==="light"?"active":""}"
@@ -3080,7 +2997,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3080
2997
  aria-label="Light theme"
3081
2998
  title="Light"
3082
2999
  >
3083
- ${Sg()}
3000
+ ${Tg()}
3084
3001
  </button>
3085
3002
  <button
3086
3003
  class="theme-toggle__button ${e.theme==="dark"?"active":""}"
@@ -3089,11 +3006,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3089
3006
  aria-label="Dark theme"
3090
3007
  title="Dark"
3091
3008
  >
3092
- ${Ag()}
3009
+ ${Cg()}
3093
3010
  </button>
3094
3011
  </div>
3095
3012
  </div>
3096
- `}function Sg(){return c`
3013
+ `}function Tg(){return l`
3097
3014
  <svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
3098
3015
  <circle cx="12" cy="12" r="4"></circle>
3099
3016
  <path d="M12 2v2"></path>
@@ -3105,19 +3022,19 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3105
3022
  <path d="m6.34 17.66-1.41 1.41"></path>
3106
3023
  <path d="m19.07 4.93-1.41 1.41"></path>
3107
3024
  </svg>
3108
- `}function Ag(){return c`
3025
+ `}function Cg(){return l`
3109
3026
  <svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
3110
3027
  <path
3111
3028
  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"
3112
3029
  ></path>
3113
3030
  </svg>
3114
- `}function _g(){return c`
3031
+ `}function Eg(){return l`
3115
3032
  <svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
3116
3033
  <rect width="20" height="14" x="2" y="3" rx="2"></rect>
3117
3034
  <line x1="8" x2="16" y1="21" y2="21"></line>
3118
3035
  <line x1="12" x2="12" y1="17" y2="21"></line>
3119
3036
  </svg>
3120
- `}const Tg=/^data:/i,Cg=/^https?:\/\//i;function Eg(e){const t=e.agentsList?.agents??[],s=_o(e.sessionKey)?.agentId??e.agentsList?.defaultId??"main",a=t.find(r=>r.id===s)?.identity,o=a?.avatarUrl??a?.avatar;if(o)return Tg.test(o)||Cg.test(o)?o:a?.avatarUrl}function Rg(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),r=e.onboarding?!1:e.settings.chatShowThinking,l=Eg(e),u=e.chatAvatarUrl??l??null;return c`
3037
+ `}const Rg=/^data:/i,Mg=/^https?:\/\//i;function Ig(e){const t=e.agentsList?.agents??[],s=To(e.sessionKey)?.agentId??e.agentsList?.defaultId??"main",a=t.find(c=>c.id===s)?.identity,o=a?.avatarUrl??a?.avatar;if(o)return Rg.test(o)||Mg.test(o)?o:a?.avatarUrl}function Lg(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,r=Ig(e),u=e.chatAvatarUrl??r??null;return l`
3121
3038
  <div class="shell ${a?"shell--chat":""} ${o?"shell--chat-focus":""} ${e.settings.navCollapsed?"shell--nav-collapsed":""} ${e.onboarding?"shell--onboarding":""}">
3122
3039
  <header class="topbar">
3123
3040
  <div class="topbar-left">
@@ -3131,10 +3048,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3131
3048
  </button>
3132
3049
  <div class="brand">
3133
3050
  <div class="brand-logo">
3134
- <img src="https://mintcdn.com/clawdhub/4rYvG-uuZrMK_URE/assets/pixel-lobster.svg?fit=max&auto=format&n=4rYvG-uuZrMK_URE&q=85&s=da2032e9eac3b5d9bfe7eb96ca6a8a26" alt="Poolbot" />
3051
+ <img src="/pixel-lobster.svg" alt="Poolbot" />
3135
3052
  </div>
3136
3053
  <div class="brand-text">
3137
- <div class="brand-title">MOLTBOT</div>
3054
+ <div class="brand-title">POOLBOT</div>
3138
3055
  <div class="brand-sub">Gateway Dashboard</div>
3139
3056
  </div>
3140
3057
  </div>
@@ -3145,11 +3062,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3145
3062
  <span>Health</span>
3146
3063
  <span class="mono">${e.connected?"OK":"Offline"}</span>
3147
3064
  </div>
3148
- ${kg(e)}
3065
+ ${_g(e)}
3149
3066
  </div>
3150
3067
  </header>
3151
3068
  <aside class="nav ${e.settings.navCollapsed?"nav--collapsed":""}">
3152
- ${sc.map(d=>{const p=e.settings.navGroupsCollapsed[d.label]??!1,f=d.tabs.some(m=>m===e.tab);return c`
3069
+ ${sc.map(d=>{const p=e.settings.navGroupsCollapsed[d.label]??!1,f=d.tabs.some(m=>m===e.tab);return l`
3153
3070
  <div class="nav-group ${p&&!f?"nav-group--collapsed":""}">
3154
3071
  <button
3155
3072
  class="nav-label"
@@ -3160,7 +3077,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3160
3077
  <span class="nav-label__chevron">${p?"+":"−"}</span>
3161
3078
  </button>
3162
3079
  <div class="nav-group__items">
3163
- ${d.tabs.map(m=>bg(e,m))}
3080
+ ${d.tabs.map(m=>xg(e,m))}
3164
3081
  </div>
3165
3082
  </div>
3166
3083
  `})}
@@ -3185,40 +3102,40 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3185
3102
  <main class="content ${a?"content--chat":""}">
3186
3103
  <section class="content-header">
3187
3104
  <div>
3188
- <div class="page-title">${ks(e.tab)}</div>
3105
+ <div class="page-title">${Ss(e.tab)}</div>
3189
3106
  <div class="page-sub">${oc(e.tab)}</div>
3190
3107
  </div>
3191
3108
  <div class="page-meta">
3192
- ${e.lastError?c`<div class="pill danger">${e.lastError}</div>`:g}
3193
- ${a?wg(e):g}
3109
+ ${e.lastError?l`<div class="pill danger">${e.lastError}</div>`:g}
3110
+ ${a?kg(e):g}
3194
3111
  </div>
3195
3112
  </section>
3196
3113
 
3197
- ${e.tab==="overview"?ig({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}
3114
+ ${e.tab==="overview"?rg({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}
3198
3115
 
3199
- ${e.tab==="channels"?sf({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)=>Gt(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}
3116
+ ${e.tab==="channels"?af({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}
3200
3117
 
3201
- ${e.tab==="instances"?Cf({loading:e.presenceLoading,entries:e.presenceEntries,lastError:e.presenceError,statusMessage:e.presenceStatus,onRefresh:()=>ri(e)}):g}
3118
+ ${e.tab==="instances"?Ef({loading:e.presenceLoading,entries:e.presenceEntries,lastError:e.presenceError,statusMessage:e.presenceStatus,onRefresh:()=>li(e)}):g}
3202
3119
 
3203
- ${e.tab==="sessions"?hg({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:()=>pt(e),onPatch:(d,p)=>xc(e,d,p),onDelete:d=>kc(e,d)}):g}
3120
+ ${e.tab==="sessions"?mg({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)=>kc(e,d,p),onDelete:d=>Sc(e,d)}):g}
3204
3121
 
3205
- ${e.tab==="cron"?$f({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:()=>Vc(e),onToggle:(d,p)=>Wc(e,d,p),onRun:d=>qc(e,d),onRemove:d=>Gc(e,d),onLoadRuns:d=>Do(e,d)}):g}
3122
+ ${e.tab==="cron"?xf({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:()=>Wc(e),onToggle:(d,p)=>qc(e,d,p),onRun:d=>Gc(e,d),onRemove:d=>Yc(e,d),onLoadRuns:d=>Do(e,d)}):g}
3206
3123
 
3207
- ${e.tab==="skills"?vg({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:()=>Bt(e,{clearMessages:!0}),onToggle:(d,p)=>zd(e,d,p),onEdit:(d,p)=>Kd(e,d,p),onSaveKey:d=>Hd(e,d),onInstall:(d,p,f)=>jd(e,d,p,f)}):g}
3124
+ ${e.tab==="skills"?wg({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)=>Hd(e,d,p),onEdit:(d,p)=>zd(e,d,p),onSaveKey:d=>jd(e,d),onInstall:(d,p,f)=>Vd(e,d,p,f)}):g}
3208
3125
 
3209
- ${e.tab==="nodes"?qf({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:()=>Tn(e),onDevicesRefresh:()=>Pe(e),onDeviceApprove:d=>Md(e,d),onDeviceReject:d=>Id(e,d),onDeviceRotate:(d,p,f)=>Ld(e,{deviceId:d,role:p,scopes:f}),onDeviceRevoke:(d,p)=>Pd(e,{deviceId:d,role:p}),onLoadConfig:()=>Ae(e),onLoadExecApprovals:()=>{const d=e.execApprovalsTarget==="node"&&e.execApprovalsTargetNodeId?{kind:"node",nodeId:e.execApprovalsTargetNodeId}:{kind:"gateway"};return oi(e,d)},onBindDefault:d=>{d?Gt(e,["tools","exec","node"],d):wa(e,["tools","exec","node"])},onBindAgent:(d,p)=>{const f=["agents","list",d,"tools","exec","node"];p?Gt(e,f,p):wa(e,f)},onSaveBindings:()=>Cs(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)=>Fd(e,d,p),onExecApprovalsRemove:d=>Ud(e,d),onSaveExecApprovals:()=>{const d=e.execApprovalsTarget==="node"&&e.execApprovalsTargetNodeId?{kind:"node",nodeId:e.execApprovalsTargetNodeId}:{kind:"gateway"};return Bd(e,d)}}):g}
3126
+ ${e.tab==="nodes"?Gf({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=>Id(e,d),onDeviceReject:d=>Ld(e,d),onDeviceRotate:(d,p,f)=>Pd(e,{deviceId:d,role:p,scopes:f}),onDeviceRevoke:(d,p)=>Nd(e,{deviceId:d,role:p}),onLoadConfig:()=>Ae(e),onLoadExecApprovals:()=>{const d=e.execApprovalsTarget==="node"&&e.execApprovalsTargetNodeId?{kind:"node",nodeId:e.execApprovalsTargetNodeId}:{kind:"gateway"};return ri(e,d)},onBindDefault:d=>{d?Yt(e,["tools","exec","node"],d):$a(e,["tools","exec","node"])},onBindAgent:(d,p)=>{const f=["agents","list",d,"tools","exec","node"];p?Yt(e,f,p):$a(e,f)},onSaveBindings:()=>Es(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)=>Ud(e,d,p),onExecApprovalsRemove:d=>Kd(e,d),onSaveExecApprovals:()=>{const d=e.execApprovalsTarget==="node"&&e.execApprovalsTargetNodeId?{kind:"node",nodeId:e.execApprovalsTargetNodeId}:{kind:"gateway"};return Fd(e,d)}}):g}
3210
3127
 
3211
- ${e.tab==="chat"?$h({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(),rt(e),Ls(e)},thinkingLevel:e.chatThinkingLevel,showThinking:r,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([rt(e),Ls(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}
3128
+ ${e.tab==="chat"?xh({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),Ps(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),Ps(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}
3212
3129
 
3213
- ${e.tab==="config"?Fh({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)=>Gt(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:()=>Cs(e),onApply:()=>Kc(e),onUpdate:()=>zc(e)}):g}
3130
+ ${e.tab==="config"?Uh({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:()=>Es(e),onApply:()=>zc(e),onUpdate:()=>Hc(e)}):g}
3214
3131
 
3215
- ${e.tab==="debug"?Tf({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:()=>An(e),onCall:()=>Zc(e)}):g}
3132
+ ${e.tab==="debug"?Cf({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:()=>Xc(e)}):g}
3216
3133
 
3217
- ${e.tab==="logs"?If({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:()=>Xs(e,{reset:!0}),onExport:(d,p)=>e.exportLogs(d,p),onScroll:d=>e.handleLogsScroll(d)}):g}
3134
+ ${e.tab==="logs"?Lf({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:()=>ei(e,{reset:!0}),onExport:(d,p)=>e.exportLogs(d,p),onScroll:d=>e.handleLogsScroll(d)}):g}
3218
3135
  </main>
3219
- ${mg(e)}
3136
+ ${bg(e)}
3220
3137
  </div>
3221
- `}const Mg={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Ig={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 Lg(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"},ho=jr,js={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(jr));new Set(Object.values(js));function Pg(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 Ng=4008;class Og{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 si();const d=Rd({deviceId:i.deviceId,role:s})?.token;o=d??this.opts.token,a=!!(d&&this.opts.token)}const r=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=Pg({deviceId:i.deviceId,clientId:this.opts.clientName??ho.CONTROL_UI,clientMode:this.opts.mode??js.WEBCHAT,role:s,scopes:n,signedAtMs:d,token:o??null,nonce:p}),m=await Cd(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??ho.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??js.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:l,caps:[],auth:r,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(Ng,"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,r=o&&typeof o.nonce=="string"?o.nonce:null;r&&(this.connectNonce=r,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=Zs(),i={type:"req",id:s,method:t,params:n},a=new Promise((o,r)=>{this.pending.set(s,{resolve:l=>o(l),reject:r})});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 Vs(e){return typeof e=="object"&&e!==null}function Dg(e){if(!Vs(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Vs(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 Bg(e){if(!Vs(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 Fg(e,t){const n=Vr(e).filter(s=>s.id!==t.id);return n.push(t),n}function fo(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=xs(i);e.assistantName=a.name,e.assistantAvatar=a.avatar,e.assistantAgentId=a.agentId??null}catch{}}function vs(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 Ug(e,t){if(!t?.mainSessionKey)return;const n=vs(e.sessionKey,t),s=vs(e.settings.sessionKey,t),i=vs(e.settings.lastActiveSessionKey,t),a=n||s||e.sessionKey,o={...e.settings,sessionKey:s||a,lastActiveSessionKey:i||a},r=o.sessionKey!==e.settings.sessionKey||o.lastActiveSessionKey!==e.settings.lastActiveSessionKey;a!==e.sessionKey&&(e.sessionKey=a),r&&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 Og({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,Hg(e,t),e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,xn(e),Wr(e),Lg(e),Tn(e,{quiet:!0}),Pe(e,{quiet:!0}),hi(e)},onClose:({code:t,reason:n})=>{e.connected=!1,t!==1012&&(e.lastError=`disconnected (${t}): ${n||"no reason"}`)},onEvent:t=>Kg(e,t),onGap:({expected:t,received:n})=>{e.lastError=`event gap detected (expected seq ${t}, got ${n}); refresh recommended`}}),e.client.start()}function Kg(e,t){try{zg(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function zg(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;Lc(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n?.sessionKey&&nr(e,n.sessionKey);const s=$c(e,n);(s==="final"||s==="error"||s==="aborted")&&(xn(e),pu(e)),s==="final"&&rt(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"&&fi(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&Pe(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=Dg(t.payload);if(n){e.execApprovalQueue=Fg(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=fo(e.execApprovalQueue,n.id)},s)}return}if(t.event==="exec.approval.resolved"){const n=Bg(t.payload);n&&(e.execApprovalQueue=fo(e.execApprovalQueue,n.id))}}function Hg(e,t){const n=t.snapshot;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n?.health&&(e.debugHealth=n.health),n?.sessionDefaults&&Ug(e,n.sessionDefaults)}function jg(e){e.basePath=Xd(),su(e,!0),eu(e),tu(e),window.addEventListener("popstate",e.popStateHandler),Qd(e),qr(e),Gd(e),e.tab==="logs"&&ci(e),e.tab==="debug"&&ui(e)}function Vg(e){Bc(e)}function Wg(e){window.removeEventListener("popstate",e.popStateHandler),Yd(e),di(e),pi(e),nu(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;kn(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 Gg(e,t){await Yc(e,t),await ue(e,!0)}async function Yg(e){await Qc(e),await ue(e,!0)}async function Qg(e){await Jc(e),await ue(e,!0)}async function Jg(e){await Cs(e),await Ae(e),await ue(e,!0)}async function Zg(e){await Ae(e),await ue(e,!0)}function Xg(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 em(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Jh(n??void 0)}function tm(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function nm(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function sm(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function im(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:Xg(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 am(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 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,r=!!(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:r},i.saved&&await ue(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}var om=Object.defineProperty,rm=Object.getOwnPropertyDescriptor,b=(e,t,n,s)=>{for(var i=s>1?void 0:s?rm(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&&om(t,n,i),i};const ys=ec();function lm(){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 ut{constructor(){super(...arguments),this.settings=tc(),this.password="",this.tab="chat",this.onboarding=lm(),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=ys.name,this.assistantAvatar=ys.avatar,this.assistantAgentId=ys.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=`{
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"&&lt(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=`{
3222
3139
  }
3223
- `,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={...Ig},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={...Mg},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=()=>iu(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),jg(this)}firstUpdated(){Vg(this)}disconnectedCallback(){Wg(this),super.disconnectedCallback()}updated(e){qg(this,e)}connect(){qr(this)}handleChatScroll(e){Pc(this,e)}handleLogsScroll(e){Nc(this,e)}exportLogs(e,t){Dc(e,t)}resetToolStream(){xn(this)}resetChatScroll(){Oc(this)}async loadAssistantIdentity(){await Wr(this)}applySettings(e){Re(this,e)}setTab(e){Jd(this,e)}setTheme(e,t){Zd(this,e,t)}async loadOverview(){await ar(this)}async loadCron(){await fi(this)}async handleAbortChat(){await rr(this)}removeQueuedMessage(e){cu(this,e)}async handleSendChat(e,t){await du(this,e,t)}async handleWhatsAppStart(e){await Gg(this,e)}async handleWhatsAppWait(){await Yg(this)}async handleWhatsAppLogout(){await Qg(this)}async handleChannelConfigSave(){await Jg(this)}async handleChannelConfigReload(){await Zg(this)}handleNostrProfileEdit(e,t){em(this,e,t)}handleNostrProfileCancel(){tm(this)}handleNostrProfileFieldChange(e,t){nm(this,e,t)}async handleNostrProfileSave(){await im(this)}async handleNostrProfileImport(){await am(this)}handleNostrProfileToggleAdvanced(){sm(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 Rg(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([ko("poolbot-app")],y);
3224
- //# sourceMappingURL=index-D_2-16Kw.js.map
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={...Ng},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={...Pg},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=()=>au(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),qg(this)}firstUpdated(){Gg(this)}disconnectedCallback(){Yg(this),super.disconnectedCallback()}updated(e){Qg(this,e)}connect(){qr(this)}handleChatScroll(e){Nc(this,e)}handleLogsScroll(e){Oc(this,e)}exportLogs(e,t){Bc(e,t)}resetToolStream(){kn(this)}resetChatScroll(){Dc(this)}async loadAssistantIdentity(){await Wr(this)}applySettings(e){Re(this,e)}setTab(e){Zd(this,e)}setTheme(e,t){Xd(this,e,t)}async loadOverview(){await ar(this)}async loadCron(){await gi(this)}async handleAbortChat(){await rr(this)}removeQueuedMessage(e){du(this,e)}async handleSendChat(e,t){await uu(this,e,t)}async handleWhatsAppStart(e){await Jg(this,e)}async handleWhatsAppWait(){await Zg(this)}async handleWhatsAppLogout(){await Xg(this)}async handleChannelConfigSave(){await em(this)}async handleChannelConfigReload(){await tm(this)}handleNostrProfileEdit(e,t){sm(this,e,t)}handleNostrProfileCancel(){im(this)}handleNostrProfileFieldChange(e,t){am(this,e,t)}async handleNostrProfileSave(){await rm(this)}async handleNostrProfileImport(){await lm(this)}handleNostrProfileToggleAdvanced(){om(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 Lg(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([So("poolbot-app")],y);
3141
+ //# sourceMappingURL=index-CZyizGqu.js.map