@takibeiy/moltbot_cn 2026.1.27 → 2026.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-info.json +5 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -0
- package/dist/canvas-host/a2ui/a2ui.bundle.js +17770 -0
- package/dist/canvas-host/a2ui/index.html +307 -0
- package/dist/control-ui/assets/index-BAFzd9IE.css +1 -0
- package/dist/control-ui/assets/index-CxUFDXFX.js +3162 -0
- package/dist/control-ui/assets/index-CxUFDXFX.js.map +1 -0
- package/dist/control-ui/favicon.ico +0 -0
- package/dist/control-ui/index.html +15 -0
- package/dist/hooks/bundled/boot-md/HOOK.md +19 -0
- package/dist/hooks/bundled/command-logger/HOOK.md +122 -0
- package/dist/hooks/bundled/session-memory/HOOK.md +86 -0
- package/dist/hooks/bundled/soul-evil/HOOK.md +71 -0
- package/package.json +1 -1
|
@@ -0,0 +1,3162 @@
|
|
|
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 Wt=globalThis,Is=Wt.ShadowRoot&&(Wt.ShadyCSS===void 0||Wt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ls=Symbol(),Ui=new WeakMap;let Xa=class{constructor(t,n,s){if(this._$cssResult$=!0,s!==Ls)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=n}get styleSheet(){let t=this.o;const n=this.t;if(Is&&t===void 0){const s=n!==void 0&&n.length===1;s&&(t=Ui.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&Ui.set(n,t))}return t}toString(){return this.cssText}};const Hr=e=>new Xa(typeof e=="string"?e:e+"",void 0,Ls),zr=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((s,i,a)=>s+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[a+1],e[0]);return new Xa(n,e,Ls)},jr=(e,t)=>{if(Is)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const s=document.createElement("style"),i=Wt.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=n.cssText,e.appendChild(s)}},Ki=Is?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const s of t.cssRules)n+=s.cssText;return Hr(n)})(e):e;const{is:qr,defineProperty:Wr,getOwnPropertyDescriptor:Vr,getOwnPropertyNames:Gr,getOwnPropertySymbols:Yr,getPrototypeOf:Qr}=Object,an=globalThis,Hi=an.trustedTypes,Zr=Hi?Hi.emptyScript:"",Jr=an.reactiveElementPolyfillSupport,yt=(e,t)=>e,Yt={toAttribute(e,t){switch(t){case Boolean:e=e?Zr:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},Rs=(e,t)=>!qr(e,t),zi={attribute:!0,type:String,converter:Yt,reflect:!1,useDefault:!1,hasChanged:Rs};Symbol.metadata??=Symbol("metadata"),an.litPropertyMetadata??=new WeakMap;let Ye=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,n=zi){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(t,n),!n.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,n);i!==void 0&&Wr(this.prototype,t,i)}}static getPropertyDescriptor(t,n,s){const{get:i,set:a}=Vr(this.prototype,t)??{get(){return this[n]},set(o){this[n]=o}};return{get:i,set(o){const l=i?.call(this);a?.call(this,o),this.requestUpdate(t,l,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??zi}static _$Ei(){if(this.hasOwnProperty(yt("elementProperties")))return;const t=Qr(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(yt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(yt("properties"))){const n=this.properties,s=[...Gr(n),...Yr(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._$Eh=new Map;for(const[n,s]of this.elementProperties){const i=this._$Eu(n,s);i!==void 0&&this._$Eh.set(i,n)}this.elementStyles=this.finalizeStyles(this.styles)}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(Ki(i))}else t!==void 0&&n.push(Ki(t));return n}static _$Eu(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._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){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._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return jr(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,n,s){this._$AK(t,s)}_$ET(t,n){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const a=(s.converter?.toAttribute!==void 0?s.converter:Yt).toAttribute(n,s.type);this._$Em=t,a==null?this.removeAttribute(i):this.setAttribute(i,a),this._$Em=null}}_$AK(t,n){const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const a=s.getPropertyOptions(i),o=typeof a.converter=="function"?{fromAttribute:a.converter}:a.converter?.fromAttribute!==void 0?a.converter:Yt;this._$Em=i;const l=o.fromAttribute(n,a.type);this[i]=l??this._$Ej?.get(i)??l,this._$Em=null}}requestUpdate(t,n,s,i=!1,a){if(t!==void 0){const o=this.constructor;if(i===!1&&(a=this[t]),s??=o.getPropertyOptions(t),!((s.hasChanged??Rs)(a,n)||s.useDefault&&s.reflect&&a===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,s))))return;this.C(t,n,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,n,{useDefault:s,reflect:i,wrapped:a},o){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??n??this[t]),a!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(n=void 0),this._$AL.set(t,n)),i===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[i,a]of this._$Ep)this[i]=a;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[i,a]of s){const{wrapped:o}=a,l=this[i];o!==!0||this._$AL.has(i)||l===void 0||this.C(i,void 0,a,l)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),this._$EO?.forEach(s=>s.hostUpdate?.()),this.update(n)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(n)}willUpdate(t){}_$AE(t){this._$EO?.forEach(n=>n.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(n=>this._$ET(n,this[n])),this._$EM()}updated(t){}firstUpdated(t){}};Ye.elementStyles=[],Ye.shadowRootOptions={mode:"open"},Ye[yt("elementProperties")]=new Map,Ye[yt("finalized")]=new Map,Jr?.({ReactiveElement:Ye}),(an.reactiveElementVersions??=[]).push("2.1.2");const Ps=globalThis,ji=e=>e,Qt=Ps.trustedTypes,qi=Qt?Qt.createPolicy("lit-html",{createHTML:e=>e}):void 0,eo="$lit$",xe=`lit$${Math.random().toFixed(9).slice(2)}$`,to="?"+xe,Xr=`<${to}>`,Oe=document,xt=()=>Oe.createComment(""),At=e=>e===null||typeof e!="object"&&typeof e!="function",Ns=Array.isArray,el=e=>Ns(e)||typeof e?.[Symbol.iterator]=="function",Fn=`[
|
|
2
|
+
\f\r]`,rt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Wi=/-->/g,Vi=/>/g,Me=RegExp(`>|${Fn}(?:([^\\s"'>=/]+)(${Fn}*=${Fn}*(?:[^
|
|
3
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Gi=/'/g,Yi=/"/g,no=/^(?:script|style|textarea|title)$/i,tl=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),c=tl(1),Se=Symbol.for("lit-noChange"),f=Symbol.for("lit-nothing"),Qi=new WeakMap,Pe=Oe.createTreeWalker(Oe,129);function so(e,t){if(!Ns(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return qi!==void 0?qi.createHTML(t):t}const nl=(e,t)=>{const n=e.length-1,s=[];let i,a=t===2?"<svg>":t===3?"<math>":"",o=rt;for(let l=0;l<n;l++){const r=e[l];let p,d,u=-1,g=0;for(;g<r.length&&(o.lastIndex=g,d=o.exec(r),d!==null);)g=o.lastIndex,o===rt?d[1]==="!--"?o=Wi:d[1]!==void 0?o=Vi:d[2]!==void 0?(no.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=Me):d[3]!==void 0&&(o=Me):o===Me?d[0]===">"?(o=i??rt,u=-1):d[1]===void 0?u=-2:(u=o.lastIndex-d[2].length,p=d[1],o=d[3]===void 0?Me:d[3]==='"'?Yi:Gi):o===Yi||o===Gi?o=Me:o===Wi||o===Vi?o=rt:(o=Me,i=void 0);const v=o===Me&&e[l+1].startsWith("/>")?" ":"";a+=o===rt?r+Xr:u>=0?(s.push(p),r.slice(0,u)+eo+r.slice(u)+xe+v):r+xe+(u===-2?l:v)}return[so(e,a+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};let as=class io{constructor({strings:t,_$litType$:n},s){let i;this.parts=[];let a=0,o=0;const l=t.length-1,r=this.parts,[p,d]=nl(t,n);if(this.el=io.createElement(p,s),Pe.currentNode=this.el.content,n===2||n===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(i=Pe.nextNode())!==null&&r.length<l;){if(i.nodeType===1){if(i.hasAttributes())for(const u of i.getAttributeNames())if(u.endsWith(eo)){const g=d[o++],v=i.getAttribute(u).split(xe),m=/([.?@])?(.*)/.exec(g);r.push({type:1,index:a,name:m[2],strings:v,ctor:m[1]==="."?il:m[1]==="?"?al:m[1]==="@"?ol:rn}),i.removeAttribute(u)}else u.startsWith(xe)&&(r.push({type:6,index:a}),i.removeAttribute(u));if(no.test(i.tagName)){const u=i.textContent.split(xe),g=u.length-1;if(g>0){i.textContent=Qt?Qt.emptyScript:"";for(let v=0;v<g;v++)i.append(u[v],xt()),Pe.nextNode(),r.push({type:2,index:++a});i.append(u[g],xt())}}}else if(i.nodeType===8)if(i.data===to)r.push({type:2,index:a});else{let u=-1;for(;(u=i.data.indexOf(xe,u+1))!==-1;)r.push({type:7,index:a}),u+=xe.length-1}a++}}static createElement(t,n){const s=Oe.createElement("template");return s.innerHTML=t,s}};function Je(e,t,n=e,s){if(t===Se)return t;let i=s!==void 0?n._$Co?.[s]:n._$Cl;const a=At(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,s)),s!==void 0?(n._$Co??=[])[s]=i:n._$Cl=i),i!==void 0&&(t=Je(e,i._$AS(e,t.values),i,s)),t}class sl{constructor(t,n){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:n},parts:s}=this._$AD,i=(t?.creationScope??Oe).importNode(n,!0);Pe.currentNode=i;let a=Pe.nextNode(),o=0,l=0,r=s[0];for(;r!==void 0;){if(o===r.index){let p;r.type===2?p=new on(a,a.nextSibling,this,t):r.type===1?p=new r.ctor(a,r.name,r.strings,this,t):r.type===6&&(p=new rl(a,this,t)),this._$AV.push(p),r=s[++l]}o!==r?.index&&(a=Pe.nextNode(),o++)}return Pe.currentNode=Oe,i}p(t){let n=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,n),n+=s.strings.length-2):s._$AI(t[n])),n++}}let on=class ao{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,n,s,i){this.type=2,this._$AH=f,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&t?.nodeType===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=Je(this,t,n),At(t)?t===f||t==null||t===""?(this._$AH!==f&&this._$AR(),this._$AH=f):t!==this._$AH&&t!==Se&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):el(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==f&&At(this._$AH)?this._$AA.nextSibling.data=t:this.T(Oe.createTextNode(t)),this._$AH=t}$(t){const{values:n,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=as.createElement(so(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(n);else{const a=new sl(i,this),o=a.u(this.options);a.p(n),this.T(o),this._$AH=a}}_$AC(t){let n=Qi.get(t.strings);return n===void 0&&Qi.set(t.strings,n=new as(t)),n}k(t){Ns(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let s,i=0;for(const a of t)i===n.length?n.push(s=new ao(this.O(xt()),this.O(xt()),this,this.options)):s=n[i],s._$AI(a),i++;i<n.length&&(this._$AR(s&&s._$AB.nextSibling,i),n.length=i)}_$AR(t=this._$AA.nextSibling,n){for(this._$AP?.(!1,!0,n);t!==this._$AB;){const s=ji(t).nextSibling;ji(t).remove(),t=s}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}};class rn{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,s,i,a){this.type=1,this._$AH=f,this._$AN=void 0,this.element=t,this.name=n,this._$AM=i,this.options=a,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=f}_$AI(t,n=this,s,i){const a=this.strings;let o=!1;if(a===void 0)t=Je(this,t,n,0),o=!At(t)||t!==this._$AH&&t!==Se,o&&(this._$AH=t);else{const l=t;let r,p;for(t=a[0],r=0;r<a.length-1;r++)p=Je(this,l[s+r],n,r),p===Se&&(p=this._$AH[r]),o||=!At(p)||p!==this._$AH[r],p===f?t=f:t!==f&&(t+=(p??"")+a[r+1]),this._$AH[r]=p}o&&!i&&this.j(t)}j(t){t===f?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let il=class extends rn{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===f?void 0:t}},al=class extends rn{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==f)}},ol=class extends rn{constructor(t,n,s,i,a){super(t,n,s,i,a),this.type=5}_$AI(t,n=this){if((t=Je(this,t,n,0)??f)===Se)return;const s=this._$AH,i=t===f&&s!==f||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,a=t!==f&&(s===f||i);i&&this.element.removeEventListener(this.name,this,s),a&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},rl=class{constructor(t,n,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Je(this,t)}};const ll={I:on},cl=Ps.litHtmlPolyfillSupport;cl?.(as,on),(Ps.litHtmlVersions??=[]).push("3.3.2");const dl=(e,t,n)=>{const s=n?.renderBefore??t;let i=s._$litPart$;if(i===void 0){const a=n?.renderBefore??null;s._$litPart$=i=new on(t.insertBefore(xt(),a),a,void 0,n??{})}return i._$AI(e),i};const Os=globalThis;let Ze=class extends Ye{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=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._$Do=dl(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Se}};Ze._$litElement$=!0,Ze.finalized=!0,Os.litElementHydrateSupport?.({LitElement:Ze});const ul=Os.litElementPolyfillSupport;ul?.({LitElement:Ze});(Os.litElementVersions??=[]).push("4.2.2");const oo=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const pl={attribute:!0,type:String,converter:Yt,reflect:!1,hasChanged:Rs},hl=(e=pl,t,n)=>{const{kind:s,metadata:i}=n;let a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),s==="setter"&&((e=Object.create(e)).wrapped=!0),a.set(n.name,e),s==="accessor"){const{name:o}=n;return{set(l){const r=t.get.call(this);t.set.call(this,l),this.requestUpdate(o,r,e,!0,l)},init(l){return l!==void 0&&this.C(o,void 0,e,l),l}}}if(s==="setter"){const{name:o}=n;return function(l){const r=this[o];t.call(this,l),this.requestUpdate(o,r,e,!0,l)}}throw Error("Unsupported decorator location: "+s)};function ln(e){return(t,n)=>typeof n=="object"?hl(e,t,n):((s,i,a)=>{const o=i.hasOwnProperty(a);return i.constructor.createProperty(a,s),o?Object.getOwnPropertyDescriptor(i,a):void 0})(e,t,n)}function w(e){return ln({...e,state:!0,attribute:!1})}const fl=50,gl=200,vl="Assistant";function Zi(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function os(e){const t=Zi(e?.name,fl)??vl,n=Zi(e?.avatar??void 0,gl)??null;return{agentId:typeof e?.agentId=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function ml(){return os(typeof window>"u"?{}:{name:window.__CLAWDBOT_ASSISTANT_NAME__,avatar:window.__CLAWDBOT_ASSISTANT_AVATAR__})}const ro="moltbot.control.settings.v1";function yl(){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(ro);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 bl(e){localStorage.setItem(ro,JSON.stringify(e))}function lo(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 wl=[{label:"Chat",tabs:["chat"]},{label:"Control",tabs:["overview","channels","instances","sessions","cron"]},{label:"Agent",tabs:["skills","nodes"]},{label:"Settings",tabs:["config","debug","logs"]}],co={overview:"/overview",channels:"/channels",instances:"/instances",sessions:"/sessions",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",config:"/config",debug:"/debug",logs:"/logs"},uo=new Map(Object.entries(co).map(([e,t])=>[t,e]));function cn(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function kt(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 Ds(e,t=""){const n=cn(t),s=co[e];return n?`${n}${s}`:s}function po(e,t=""){const n=cn(t);let s=e||"/";n&&(s===n?s="/":s.startsWith(`${n}/`)&&(s=s.slice(n.length)));let i=kt(s).toLowerCase();return i.endsWith("/index.html")&&(i="/"),i==="/"?"chat":uo.get(i)??null}function $l(e){let t=kt(e);if(t.endsWith("/index.html")&&(t=kt(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(uo.has(i)){const a=n.slice(0,s);return a.length?`/${a.join("/")}`:""}}return`/${n.join("/")}`}function xl(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 rs(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 Al(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 ~/.clawdbot/moltbot.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 V={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>`,image:c`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>`,smartphone:c`<svg viewBox="0 0 24 24"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>`,plug:c`<svg viewBox="0 0 24 24"><path d="M12 22v-5"/><path d="M9 8V2"/><path d="M15 8V2"/><path d="M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z"/></svg>`,circle:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,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>`},kl=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,Bt=/<\s*\/?\s*final\b[^>]*>/gi,Ji=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Sl(e,t){return e.trimStart()}function _l(e,t){if(!e||!kl.test(e))return e;let n=e;Bt.test(n)?(Bt.lastIndex=0,n=n.replace(Bt,"")):Bt.lastIndex=0,Ji.lastIndex=0;let s="",i=0,a=!1;for(const o of n.matchAll(Ji)){const l=o.index??0,r=o[1]==="/";a?r&&(a=!1):(s+=n.slice(i,l),r||(a=!0)),i=l+o[0].length}return s+=n.slice(i),Sl(s)}function St(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString()}function O(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`}function ho(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 ls(e){return!e||e.length===0?"none":e.filter(t=>!!(t&&t.trim())).join(", ")}function cs(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function fo(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 Zt(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Un(e){return _l(e)}const Tl=/^\[([^\]]+)\]\s*/,Cl=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Kn=new WeakMap,Hn=new WeakMap;function El(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:Cl.some(t=>e.startsWith(`${t} `))}function zn(e){const t=e.match(Tl);if(!t)return e;const n=t[1]??"";return El(n)?e.slice(t[0].length):e}function ds(e){const t=e,n=typeof t.role=="string"?t.role:"",s=t.content;if(typeof s=="string")return n==="assistant"?Un(s):zn(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(`
|
|
4
|
+
`);return n==="assistant"?Un(a):zn(a)}}return typeof t.text=="string"?n==="assistant"?Un(t.text):zn(t.text):null}function go(e){if(!e||typeof e!="object")return ds(e);const t=e;if(Kn.has(t))return Kn.get(t)??null;const n=ds(e);return Kn.set(t,n),n}function Xi(e){const n=e.content,s=[];if(Array.isArray(n))for(const l of n){const r=l;if(r.type==="thinking"&&typeof r.thinking=="string"){const p=r.thinking.trim();p&&s.push(p)}}if(s.length>0)return s.join(`
|
|
5
|
+
`);const i=Il(e);if(!i)return null;const o=[...i.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(l=>(l[1]??"").trim()).filter(Boolean);return o.length>0?o.join(`
|
|
6
|
+
`):null}function Ml(e){if(!e||typeof e!="object")return Xi(e);const t=e;if(Hn.has(t))return Hn.get(t)??null;const n=Xi(e);return Hn.set(t,n),n}function Il(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(`
|
|
7
|
+
`)}return typeof t.text=="string"?t.text:null}function Ll(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(`
|
|
8
|
+
`):""}let ea=!1;function ta(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 Rl(){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 Pl(){ea||(ea=!0,console.warn("[uuid] crypto API missing; falling back to weak randomness"))}function Bs(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),ta(t)}return Pl(),ta(Rl())}async function Xe(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 Nl(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function Ol(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 p of n)o.push({type:"image",source:{type:"base64",media_type:p.mimeType,data:p.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:o,timestamp:a}],e.chatSending=!0,e.lastError=null;const l=Bs();e.chatRunId=l,e.chatStream="",e.chatStreamStartedAt=a;const r=i?n.map(p=>{const d=Nl(p.dataUrl);return d?{type:"image",mimeType:d.mimeType,content:d.content}:null}).filter(p=>p!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:s,deliver:!1,idempotencyKey:l,attachments:r}),!0}catch(p){const d=String(p);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 Dl(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 Bl(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=ds(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 st(e){if(!(!e.client||!e.connected)&&!e.sessionsLoading){e.sessionsLoading=!0,e.sessionsError=null;try{const t={includeGlobal:e.sessionsIncludeGlobal,includeUnknown:e.sessionsIncludeUnknown},n=Zt(e.sessionsFilterActive,0),s=Zt(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 Fl(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 st(e)}catch(i){e.sessionsError=String(i)}}async function Ul(e,t){if(!(!e.client||!e.connected||e.sessionsLoading||!window.confirm(`Delete session "${t}"?
|
|
9
|
+
|
|
10
|
+
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 st(e)}catch(s){e.sessionsError=String(s)}finally{e.sessionsLoading=!1}}}const na=50,Kl=80,Hl=12e4;function zl(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(`
|
|
11
|
+
`)}function sa(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=zl(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=fo(n,Hl);return s.truncated?`${s.text}
|
|
12
|
+
|
|
13
|
+
… truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function jl(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 ql(e){if(e.toolStreamOrder.length<=na)return;const t=e.toolStreamOrder.length-na,n=e.toolStreamOrder.splice(0,t);for(const s of n)e.toolStreamById.delete(s)}function Wl(e){e.chatToolMessages=e.toolStreamOrder.map(t=>e.toolStreamById.get(t)?.message).filter(t=>!!t)}function us(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),Wl(e)}function Vl(e,t=!1){if(t){us(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>us(e),Kl))}function dn(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],us(e)}const Gl=5e3;function Yl(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},Gl))}function Ql(e,t){if(!t)return;if(t.stream==="compaction"){Yl(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:"",l=o==="start"?s.args:void 0,r=o==="update"?sa(s.partialResult):o==="result"?sa(s.result):void 0,p=Date.now();let d=e.toolStreamById.get(i);d?(d.name=a,l!==void 0&&(d.args=l),r!==void 0&&(d.output=r),d.updatedAt=p):(d={toolCallId:i,runId:t.runId,sessionKey:n,name:a,args:l,output:r,startedAt:typeof t.ts=="number"?t.ts:p,updatedAt:p,message:{}},e.toolStreamById.set(i,d),e.toolStreamOrder.push(i)),d.message=jl(d),ql(e),Vl(e,o==="result")}function un(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 l=n();if(!l)return;const r=l.scrollHeight-l.scrollTop-l.clientHeight;(t||e.chatUserNearBottom||r<200)&&(l.scrollTop=l.scrollHeight,e.chatUserNearBottom=!0)},o)})})}function vo(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 Zl(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=s<200}function Jl(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.logsAtBottom=s<80}function Xl(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function ec(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
|
|
14
|
+
`)}
|
|
15
|
+
`],{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=`moltbot-logs-${t}-${a}.log`,i.click(),URL.revokeObjectURL(s)}function tc(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 De(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function et(e){return`${JSON.stringify(e,null,2).trimEnd()}
|
|
16
|
+
`}function mo(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],l=t[a+1];if(typeof o=="number"){if(!Array.isArray(s))return;s[o]==null&&(s[o]=typeof l=="number"?[]:{}),s=s[o]}else{if(typeof s!="object"||s==null)return;const r=s;r[o]==null&&(r[o]=typeof l=="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 yo(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 ye(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});sc(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function bo(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});nc(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function nc(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function sc(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?et(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=et(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=De(t.config??{}),e.configFormOriginal=De(t.config??{}),e.configRawOriginal=n)}async function ps(e){if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?et(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 ye(e)}catch(t){e.lastError=String(t)}finally{e.configSaving=!1}}}async function ic(e){if(!(!e.client||!e.connected)){e.configApplying=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?et(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 ye(e)}catch(t){e.lastError=String(t)}finally{e.configApplying=!1}}}async function ac(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 Ft(e,t,n){const s=De(e.configForm??e.configSnapshot?.config??{});mo(s,t,n),e.configForm=s,e.configFormDirty=!0,e.configFormMode==="form"&&(e.configRaw=et(s))}function ia(e,t){const n=De(e.configForm??e.configSnapshot?.config??{});yo(n,t),e.configForm=n,e.configFormDirty=!0,e.configFormMode==="form"&&(e.configRaw=et(n))}async function Ct(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 pn(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 oc(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=Zt(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 rc(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=Zt(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function lc(e){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const t=oc(e.cronForm),n=rc(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 pn(e),await Ct(e)}catch(t){e.cronError=String(t)}finally{e.cronBusy=!1}}}async function cc(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 pn(e),await Ct(e)}catch(s){e.cronError=String(s)}finally{e.cronBusy=!1}}}async function dc(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 wo(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function uc(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 pn(e),await Ct(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function wo(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 oe(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 pc(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 hc(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 fc(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 hn(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 gc(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 vc=2e3,mc=new Set(["trace","debug","info","warn","error","fatal"]);function yc(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 bc(e){if(typeof e!="string")return null;const t=e.toLowerCase();return mc.has(t)?t:null}function wc(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=bc(n?.logLevelName??n?.level),a=typeof t[0]=="string"?t[0]:typeof n?.name=="string"?n?.name:null,o=yc(a);let l=null;o&&(typeof o.subsystem=="string"?l=o.subsystem:typeof o.module=="string"&&(l=o.module)),!l&&a&&a.length<120&&(l=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:l,message:r??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Fs(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(l=>typeof l=="string"):[]).map(wc),o=!!(t?.reset||s.reset||e.logsCursor==null);e.logsEntries=o?a:[...e.logsEntries,...a].slice(-vc),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 $o={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:W,n:Vt,Gx:aa,Gy:oa,a:jn,d:qn,h:$c}=$o,Be=32,Us=64,xc=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},H=(e="")=>{const t=new Error(e);throw xc(t,H),t},Ac=e=>typeof e=="bigint",kc=e=>typeof e=="string",Sc=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",_e=(e,t,n="")=>{const s=Sc(e),i=e?.length,a=t!==void 0;if(!s||a&&i!==t){const o=n&&`"${n}" `,l=a?` of length ${t}`:"",r=s?`length=${i}`:`type=${typeof e}`;H(o+"expected Uint8Array"+l+", got "+r)}return e},fn=e=>new Uint8Array(e),xo=e=>Uint8Array.from(e),Ao=(e,t)=>e.toString(16).padStart(t,"0"),ko=e=>Array.from(_e(e)).map(t=>Ao(t,2)).join(""),ve={_0:48,_9:57,A:65,F:70,a:97,f:102},ra=e=>{if(e>=ve._0&&e<=ve._9)return e-ve._0;if(e>=ve.A&&e<=ve.F)return e-(ve.A-10);if(e>=ve.a&&e<=ve.f)return e-(ve.a-10)},So=e=>{const t="hex invalid";if(!kc(e))return H(t);const n=e.length,s=n/2;if(n%2)return H(t);const i=fn(s);for(let a=0,o=0;a<s;a++,o+=2){const l=ra(e.charCodeAt(o)),r=ra(e.charCodeAt(o+1));if(l===void 0||r===void 0)return H(t);i[a]=l*16+r}return i},_o=()=>globalThis?.crypto,_c=()=>_o()?.subtle??H("crypto.subtle must be defined, consider polyfill"),_t=(...e)=>{const t=fn(e.reduce((s,i)=>s+_e(i).length,0));let n=0;return e.forEach(s=>{t.set(s,n),n+=s.length}),t},Tc=(e=Be)=>_o().getRandomValues(fn(e)),Jt=BigInt,Re=(e,t,n,s="bad number: out of range")=>Ac(e)&&t<=e&&e<n?e:H(s),k=(e,t=W)=>{const n=e%t;return n>=0n?n:t+n},To=e=>k(e,Vt),Cc=(e,t)=>{(e===0n||t<=0n)&&H("no inverse n="+e+" mod="+t);let n=k(e,t),s=t,i=0n,a=1n;for(;n!==0n;){const o=s/n,l=s%n,r=i-a*o;s=n,n=l,i=a,a=r}return s===1n?k(i,t):H("no inverse")},Ec=e=>{const t=Io[e];return typeof t!="function"&&H("hashes."+e+" not set"),t},Wn=e=>e instanceof ee?e:H("Point expected"),hs=2n**256n;class ee{static BASE;static ZERO;X;Y;Z;T;constructor(t,n,s,i){const a=hs;this.X=Re(t,0n,a),this.Y=Re(n,0n,a),this.Z=Re(s,1n,a),this.T=Re(i,0n,a),Object.freeze(this)}static CURVE(){return $o}static fromAffine(t){return new ee(t.x,t.y,1n,k(t.x*t.y))}static fromBytes(t,n=!1){const s=qn,i=xo(_e(t,Be)),a=t[31];i[31]=a&-129;const o=Eo(i);Re(o,0n,n?hs:W);const r=k(o*o),p=k(r-1n),d=k(s*r+1n);let{isValid:u,value:g}=Ic(p,d);u||H("bad point: y not sqrt");const v=(g&1n)===1n,m=(a&128)!==0;return!n&&g===0n&&m&&H("bad point: x==0, isLastByteOdd"),m!==v&&(g=k(-g)),new ee(g,o,1n,k(g*o))}static fromHex(t,n){return ee.fromBytes(So(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=jn,n=qn,s=this;if(s.is0())return H("bad point: ZERO");const{X:i,Y:a,Z:o,T:l}=s,r=k(i*i),p=k(a*a),d=k(o*o),u=k(d*d),g=k(r*t),v=k(d*k(g+p)),m=k(u+k(n*k(r*p)));if(v!==m)return H("bad point: equation left != right (1)");const $=k(i*a),A=k(o*l);return $!==A?H("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:s,Z:i}=this,{X:a,Y:o,Z:l}=Wn(t),r=k(n*l),p=k(a*i),d=k(s*l),u=k(o*i);return r===p&&d===u}is0(){return this.equals(Qe)}negate(){return new ee(k(-this.X),this.Y,this.Z,k(-this.T))}double(){const{X:t,Y:n,Z:s}=this,i=jn,a=k(t*t),o=k(n*n),l=k(2n*k(s*s)),r=k(i*a),p=t+n,d=k(k(p*p)-a-o),u=r+o,g=u-l,v=r-o,m=k(d*g),$=k(u*v),A=k(d*v),_=k(g*u);return new ee(m,$,_,A)}add(t){const{X:n,Y:s,Z:i,T:a}=this,{X:o,Y:l,Z:r,T:p}=Wn(t),d=jn,u=qn,g=k(n*o),v=k(s*l),m=k(a*u*p),$=k(i*r),A=k((n+s)*(o+l)-g-v),_=k($-m),I=k($+m),P=k(v-d*g),M=k(A*_),C=k(I*P),E=k(A*P),pe=k(_*I);return new ee(M,C,pe,E)}subtract(t){return this.add(Wn(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return Qe;if(Re(t,1n,Vt),t===1n)return this;if(this.equals(Fe))return Hc(t).p;let s=Qe,i=Fe;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(Qe))return{x:0n,y:1n};const i=Cc(s,W);k(s*i)!==1n&&H("invalid inverse");const a=k(t*i),o=k(n*i);return{x:a,y:o}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),s=Co(n);return s[31]|=t&1n?128:0,s}toHex(){return ko(this.toBytes())}clearCofactor(){return this.multiply(Jt($c),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Vt/2n,!1).double();return Vt%2n&&(t=t.add(this)),t.is0()}}const Fe=new ee(aa,oa,1n,k(aa*oa)),Qe=new ee(0n,1n,1n,0n);ee.BASE=Fe;ee.ZERO=Qe;const Co=e=>So(Ao(Re(e,0n,hs),Us)).reverse(),Eo=e=>Jt("0x"+ko(xo(_e(e)).reverse())),ce=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=W;return n},Mc=e=>{const n=e*e%W*e%W,s=ce(n,2n)*n%W,i=ce(s,1n)*e%W,a=ce(i,5n)*i%W,o=ce(a,10n)*a%W,l=ce(o,20n)*o%W,r=ce(l,40n)*l%W,p=ce(r,80n)*r%W,d=ce(p,80n)*r%W,u=ce(d,10n)*a%W;return{pow_p_5_8:ce(u,2n)*e%W,b2:n}},la=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Ic=(e,t)=>{const n=k(t*t*t),s=k(n*n*t),i=Mc(e*s).pow_p_5_8;let a=k(e*n*i);const o=k(t*a*a),l=a,r=k(a*la),p=o===e,d=o===k(-e),u=o===k(-e*la);return p&&(a=l),(d||u)&&(a=r),(k(a)&1n)===1n&&(a=k(-a)),{isValid:p||d,value:a}},fs=e=>To(Eo(e)),Ks=(...e)=>Io.sha512Async(_t(...e)),Lc=(...e)=>Ec("sha512")(_t(...e)),Mo=e=>{const t=e.slice(0,Be);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Be,Us),s=fs(t),i=Fe.multiply(s),a=i.toBytes();return{head:t,prefix:n,scalar:s,point:i,pointBytes:a}},Hs=e=>Ks(_e(e,Be)).then(Mo),Rc=e=>Mo(Lc(_e(e,Be))),Pc=e=>Hs(e).then(t=>t.pointBytes),Nc=e=>Ks(e.hashable).then(e.finish),Oc=(e,t,n)=>{const{pointBytes:s,scalar:i}=e,a=fs(t),o=Fe.multiply(a).toBytes();return{hashable:_t(o,s,n),finish:p=>{const d=To(a+fs(p)*i);return _e(_t(o,Co(d)),Us)}}},Dc=async(e,t)=>{const n=_e(e),s=await Hs(t),i=await Ks(s.prefix,n);return Nc(Oc(s,i,n))},Io={sha512Async:async e=>{const t=_c(),n=_t(e);return fn(await t.digest("SHA-512",n.buffer))},sha512:void 0},Bc=(e=Tc(Be))=>e,Fc={getExtendedPublicKeyAsync:Hs,getExtendedPublicKey:Rc,randomSecretKey:Bc},Xt=8,Uc=256,Lo=Math.ceil(Uc/Xt)+1,gs=2**(Xt-1),Kc=()=>{const e=[];let t=Fe,n=t;for(let s=0;s<Lo;s++){n=t,e.push(n);for(let i=1;i<gs;i++)n=n.add(t),e.push(n);t=n.double()}return e};let ca;const da=(e,t)=>{const n=t.negate();return e?n:t},Hc=e=>{const t=ca||(ca=Kc());let n=Qe,s=Fe;const i=2**Xt,a=i,o=Jt(i-1),l=Jt(Xt);for(let r=0;r<Lo;r++){let p=Number(e&o);e>>=l,p>gs&&(p-=a,e+=1n);const d=r*gs,u=d,g=d+Math.abs(p)-1,v=r%2!==0,m=p<0;p===0?s=s.add(da(v,t[u])):n=n.add(da(m,t[g]))}return e!==0n&&H("invalid wnaf"),{p:n,f:s}},Vn="moltbot-device-identity-v1";function vs(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replaceAll("+","-").replaceAll("/","_").replace(/=+$/g,"")}function Ro(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 zc(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Po(e){const t=await crypto.subtle.digest("SHA-256",e);return zc(new Uint8Array(t))}async function jc(){const e=Fc.randomSecretKey(),t=await Pc(e);return{deviceId:await Po(t),publicKey:vs(t),privateKey:vs(e)}}async function zs(){try{const n=localStorage.getItem(Vn);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 Po(Ro(s.publicKey));if(i!==s.deviceId){const a={...s,deviceId:i};return localStorage.setItem(Vn,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 jc(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Vn,JSON.stringify(t)),e}async function qc(e,t){const n=Ro(e),s=new TextEncoder().encode(t),i=await Dc(s,n);return vs(i)}const No="moltbot.device.auth.v1";function js(e){return e.trim()}function Wc(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 qs(){try{const e=window.localStorage.getItem(No);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 Oo(e){try{window.localStorage.setItem(No,JSON.stringify(e))}catch{}}function Vc(e){const t=qs();if(!t||t.deviceId!==e.deviceId)return null;const n=js(e.role),s=t.tokens[n];return!s||typeof s.token!="string"?null:s}function Do(e){const t=js(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},s=qs();s&&s.deviceId===e.deviceId&&(n.tokens={...s.tokens});const i={token:e.token,role:t,scopes:Wc(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=i,Oo(n),i}function Bo(e){const t=qs();if(!t||t.deviceId!==e.deviceId)return;const n=js(e.role);if(!t.tokens[n])return;const s={...t,tokens:{...t.tokens}};delete s.tokens[n],Oo(s)}async function Te(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 Gc(e,t){if(!(!e.client||!e.connected))try{await e.client.request("device.pair.approve",{requestId:t}),await Te(e)}catch(n){e.devicesError=String(n)}}async function Yc(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 Te(e)}catch(s){e.devicesError=String(s)}}async function Qc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("device.token.rotate",t);if(n?.token){const s=await zs(),i=n.role??t.role;(n.deviceId===s.deviceId||t.deviceId===s.deviceId)&&Do({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 Te(e)}catch(n){e.devicesError=String(n)}}async function Zc(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 zs();t.deviceId===s.deviceId&&Bo({deviceId:s.deviceId,role:t.role}),await Te(e)}catch(s){e.devicesError=String(s)}}async function gn(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 Jc(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 Xc(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 Ws(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=Jc(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const s=await e.client.request(n.method,n.params);ed(e,s)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function ed(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=De(t.file??{}))}async function td(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=Xc(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 Ws(e,t)}catch(n){e.lastError=String(n)}finally{e.execApprovalsSaving=!1}}}function nd(e,t,n){const s=De(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});mo(s,t,n),e.execApprovalsForm=s,e.execApprovalsDirty=!0}function sd(e,t){const n=De(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});yo(n,t),e.execApprovalsForm=n,e.execApprovalsDirty=!0}async function Vs(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 tt(e,t,n){if(!t.trim())return;const s={...e.skillMessages};n?s[t]=n:delete s[t],e.skillMessages=s}function vn(e){return e instanceof Error?e.message:String(e)}async function Et(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=vn(n)}finally{e.skillsLoading=!1}}}function id(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function ad(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 Et(e),tt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(s){const i=vn(s);e.skillsError=i,tt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function od(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 Et(e),tt(e,t,{kind:"success",message:"API key saved"})}catch(n){const s=vn(n);e.skillsError=s,tt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function rd(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 Et(e),tt(e,t,{kind:"success",message:i?.message??"Installed"})}catch(i){const a=vn(i);e.skillsError=a,tt(e,t,{kind:"error",message:a})}finally{e.skillsBusyKey=null}}}function ld(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Gs(e){return e==="system"?ld():e}const Ut=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,cd=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Kt=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},dd=({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,l=cd();if(!!o.startViewTransition&&!l){let p=.5,d=.5;if(n?.pointerClientX!==void 0&&n?.pointerClientY!==void 0&&typeof window<"u")p=Ut(n.pointerClientX/window.innerWidth),d=Ut(n.pointerClientY/window.innerHeight);else if(n?.element){const u=n.element.getBoundingClientRect();u.width>0&&u.height>0&&typeof window<"u"&&(p=Ut((u.left+u.width/2)/window.innerWidth),d=Ut((u.top+u.height/2)/window.innerHeight))}a.style.setProperty("--theme-switch-x",`${p*100}%`),a.style.setProperty("--theme-switch-y",`${d*100}%`),a.classList.add("theme-transition");try{const u=o.startViewTransition?.(()=>{t()});u?.finished?u.finished.finally(()=>Kt(a)):Kt(a)}catch{Kt(a),t()}return}t(),Kt(a)};function ud(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{gn(e,{quiet:!0})},5e3))}function pd(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function Ys(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Fs(e,{quiet:!0})},2e3))}function Qs(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function Zs(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&hn(e)},3e3))}function Js(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Ae(e,t){const n={...t,lastActiveSessionKey:t.lastActiveSessionKey?.trim()||t.sessionKey.trim()||"main"};e.settings=n,bl(n),t.theme!==e.theme&&(e.theme=t.theme,mn(e,Gs(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function Fo(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&Ae(e,{...e.settings,lastActiveSessionKey:n})}function hd(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&&Ae(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,Ae(e,{...e.settings,sessionKey:r,lastActiveSessionKey:r}))}if(a!=null){const r=a.trim();r&&r!==e.settings.gatewayUrl&&Ae(e,{...e.settings,gatewayUrl:r}),t.delete("gatewayUrl"),o=!0}if(!o)return;const l=new URL(window.location.href);l.search=t.toString(),window.history.replaceState({},"",l.toString())}function fd(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?Ys(e):Qs(e),t==="debug"?Zs(e):Js(e),Xs(e),Ko(e,t,!1)}function gd(e,t,n){dd({nextTheme:t,applyTheme:()=>{e.theme=t,Ae(e,{...e.settings,theme:t}),mn(e,Gs(t))},context:n,currentTheme:e.theme})}async function Xs(e){e.tab==="overview"&&await Ho(e),e.tab==="channels"&&await Ad(e),e.tab==="instances"&&await Vs(e),e.tab==="sessions"&&await st(e),e.tab==="cron"&&await ei(e),e.tab==="skills"&&await Et(e),e.tab==="nodes"&&(await gn(e),await Te(e),await ye(e),await Ws(e)),e.tab==="chat"&&(await Cd(e),un(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await bo(e),await ye(e)),e.tab==="debug"&&(await hn(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"&&(e.logsAtBottom=!0,await Fs(e,{reset:!0}),vo(e,!0))}function vd(){if(typeof window>"u")return"";const e=window.__CLAWDBOT_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?cn(e):$l(window.location.pathname)}function md(e){e.theme=e.settings.theme??"system",mn(e,Gs(e.theme))}function mn(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function yd(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"&&mn(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function bd(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 wd(e,t){if(typeof window>"u")return;const n=po(window.location.pathname,e.basePath)??"chat";Uo(e,n),Ko(e,n,t)}function $d(e){if(typeof window>"u")return;const t=po(window.location.pathname,e.basePath);if(!t)return;const s=new URL(window.location.href).searchParams.get("session")?.trim();s&&(e.sessionKey=s,Ae(e,{...e.settings,sessionKey:s,lastActiveSessionKey:s})),Uo(e,t)}function Uo(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?Ys(e):Qs(e),t==="debug"?Zs(e):Js(e),e.connected&&Xs(e)}function Ko(e,t,n){if(typeof window>"u")return;const s=kt(Ds(t,e.basePath)),i=kt(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 xd(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 Ho(e){await Promise.all([oe(e,!1),Vs(e),st(e),Ct(e),hn(e)])}async function Ad(e){await Promise.all([oe(e,!0),bo(e),ye(e)])}async function ei(e){await Promise.all([oe(e,!1),Ct(e),pn(e)])}function zo(e){return e.chatSending||!!e.chatRunId}function kd(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 jo(e){e.connected&&(e.chatMessage="",await Dl(e))}function Sd(e,t,n){const s=t.trim(),i=!!(n&&n.length>0);!s&&!i||(e.chatQueue=[...e.chatQueue,{id:Bs(),text:s,createdAt:Date.now(),attachments:i?n?.map(a=>({...a})):void 0}])}async function qo(e,t,n){dn(e);const s=await Ol(e,t,n?.attachments);return!s&&n?.previousDraft!=null&&(e.chatMessage=n.previousDraft),!s&&n?.previousAttachments&&(e.chatAttachments=n.previousAttachments),s&&Fo(e,e.sessionKey),s&&n?.restoreDraft&&n.previousDraft?.trim()&&(e.chatMessage=n.previousDraft),s&&n?.restoreAttachments&&n.previousAttachments?.length&&(e.chatAttachments=n.previousAttachments),un(e),s&&!e.chatRunId&&Wo(e),s}async function Wo(e){if(!e.connected||zo(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await qo(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function _d(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function Td(e,t,n){if(!e.connected)return;const s=e.chatMessage,i=(t??e.chatMessage).trim(),a=e.chatAttachments??[],o=t==null?a:[],l=o.length>0;if(!(!i&&!l)){if(kd(i)){await jo(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),zo(e)){Sd(e,i,o);return}await qo(e,i,{previousDraft:t==null?s:void 0,restoreDraft:!!(t&&n?.restoreDraft),attachments:l?o:void 0,previousAttachments:t==null?a:void 0,restoreAttachments:!!(t&&n?.restoreDraft)})}}async function Cd(e){await Promise.all([Xe(e),st(e),ms(e)]),un(e,!0)}const Ed=Wo;function Md(e){const t=lo(e.sessionKey);return t?.agentId?t.agentId:e.hello?.snapshot?.sessionDefaults?.defaultAgentId?.trim()||"main"}function Id(e,t){const n=cn(e),s=encodeURIComponent(t);return n?`${n}/avatar/${s}?meta=1`:`/avatar/${s}?meta=1`}async function ms(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=Md(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=Id(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{I:Ld}=ll,ua=e=>e,Rd=e=>e.strings===void 0,pa=()=>document.createComment(""),lt=(e,t,n)=>{const s=e._$AA.parentNode,i=t===void 0?e._$AB:t._$AA;if(n===void 0){const a=s.insertBefore(pa(),i),o=s.insertBefore(pa(),i);n=new Ld(a,o,e,e.options)}else{const a=n._$AB.nextSibling,o=n._$AM,l=o!==e;if(l){let r;n._$AQ?.(e),n._$AM=e,n._$AP!==void 0&&(r=e._$AU)!==o._$AU&&n._$AP(r)}if(a!==i||l){let r=n._$AA;for(;r!==a;){const p=ua(r).nextSibling;ua(s).insertBefore(r,i),r=p}}}return n},Ie=(e,t,n=e)=>(e._$AI(t,n),e),Pd={},Nd=(e,t=Pd)=>e._$AH=t,Od=e=>e._$AH,Gn=e=>{e._$AR(),e._$AA.remove()};const ti={CHILD:2},ni=e=>(...t)=>({_$litDirective$:e,values:t});class si{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,s){this._$Ct=t,this._$AM=n,this._$Ci=s}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}}const bt=(e,t)=>{const n=e._$AN;if(n===void 0)return!1;for(const s of n)s._$AO?.(t,!1),bt(s,t);return!0},en=e=>{let t,n;do{if((t=e._$AM)===void 0)break;n=t._$AN,n.delete(e),e=t}while(n?.size===0)},Vo=e=>{for(let t;t=e._$AM;e=t){let n=t._$AN;if(n===void 0)t._$AN=n=new Set;else if(n.has(e))break;n.add(e),Fd(t)}};function Dd(e){this._$AN!==void 0?(en(this),this._$AM=e,Vo(this)):this._$AM=e}function Bd(e,t=!1,n=0){const s=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(t)if(Array.isArray(s))for(let a=n;a<s.length;a++)bt(s[a],!1),en(s[a]);else s!=null&&(bt(s,!1),en(s));else bt(this,e)}const Fd=e=>{e.type==ti.CHILD&&(e._$AP??=Bd,e._$AQ??=Dd)};class Ud extends si{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,n,s){super._$AT(t,n,s),Vo(this),this.isConnected=t._$AU}_$AO(t,n=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),n&&(bt(this,t),en(this))}setValue(t){if(Rd(this._$Ct))this._$Ct._$AI(t,this);else{const n=[...this._$Ct._$AH];n[this._$Ci]=t,this._$Ct._$AI(n,this,0)}}disconnected(){}reconnected(){}}const Yn=new WeakMap,Kd=ni(class extends Ud{render(e){return f}update(e,[t]){const n=t!==this.G;return n&&this.G!==void 0&&this.rt(void 0),(n||this.lt!==this.ct)&&(this.G=t,this.ht=e.options?.host,this.rt(this.ct=e.element)),f}rt(e){if(this.isConnected||(e=void 0),typeof this.G=="function"){const t=this.ht??globalThis;let n=Yn.get(t);n===void 0&&(n=new WeakMap,Yn.set(t,n)),n.get(this.G)!==void 0&&this.G.call(this.ht,void 0),n.set(this.G,e),e!==void 0&&this.G.call(this.ht,e)}else this.G.value=e}get lt(){return typeof this.G=="function"?Yn.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});const ha=(e,t,n)=>{const s=new Map;for(let i=t;i<=n;i++)s.set(e[i],i);return s},Go=ni(class extends si{constructor(e){if(super(e),e.type!==ti.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let s;n===void 0?n=t:t!==void 0&&(s=t);const i=[],a=[];let o=0;for(const l of e)i[o]=s?s(l,o):o,a[o]=n(l,o),o++;return{values:a,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,s]){const i=Od(e),{values:a,keys:o}=this.dt(t,n,s);if(!Array.isArray(i))return this.ut=o,a;const l=this.ut??=[],r=[];let p,d,u=0,g=i.length-1,v=0,m=a.length-1;for(;u<=g&&v<=m;)if(i[u]===null)u++;else if(i[g]===null)g--;else if(l[u]===o[v])r[v]=Ie(i[u],a[v]),u++,v++;else if(l[g]===o[m])r[m]=Ie(i[g],a[m]),g--,m--;else if(l[u]===o[m])r[m]=Ie(i[u],a[m]),lt(e,r[m+1],i[u]),u++,m--;else if(l[g]===o[v])r[v]=Ie(i[g],a[v]),lt(e,i[u],i[g]),g--,v++;else if(p===void 0&&(p=ha(o,v,m),d=ha(l,u,g)),p.has(l[u]))if(p.has(l[g])){const $=d.get(o[v]),A=$!==void 0?i[$]:null;if(A===null){const _=lt(e,i[u]);Ie(_,a[v]),r[v]=_}else r[v]=Ie(A,a[v]),lt(e,i[u],A),i[$]=null;v++}else Gn(i[g]),g--;else Gn(i[u]),u++;for(;v<=m;){const $=lt(e,r[m+1]);Ie($,a[v]),r[v++]=$}for(;u<=g;){const $=i[u++];$!==null&&Gn($)}return this.ut=o,Nd(e,r),Se}});function Yo(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(u=>{const v=String(u.type??"").toLowerCase();return v==="toolresult"||v==="tool_result"}),l=typeof t.toolName=="string"||typeof t.tool_name=="string";(s||o||l)&&(n="toolResult");let r=[];typeof t.content=="string"?r=[{type:"text",text:t.content}]:Array.isArray(t.content)?r=t.content.map(u=>({type:u.type||"text",text:u.text,name:u.name,args:u.args||u.arguments})):typeof t.text=="string"&&(r=[{type:"text",text:t.text}]);const p=typeof t.timestamp=="number"?t.timestamp:Date.now(),d=typeof t.id=="string"?t.id:void 0;return{role:n,content:r,timestamp:p,id:d}}function ii(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 Qo(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}class ys extends si{constructor(t){if(super(t),this.it=f,t.type!==ti.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===f||t==null)return this._t=void 0,this.it=t;if(t===Se)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const n=[t];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}}ys.directiveName="unsafeHTML",ys.resultType=1;const bs=ni(ys);const{entries:Zo,setPrototypeOf:fa,isFrozen:Hd,getPrototypeOf:zd,getOwnPropertyDescriptor:jd}=Object;let{freeze:Z,seal:ne,create:ws}=Object,{apply:$s,construct:xs}=typeof Reflect<"u"&&Reflect;Z||(Z=function(t){return t});ne||(ne=function(t){return t});$s||($s=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)});xs||(xs=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 Ht=J(Array.prototype.forEach),qd=J(Array.prototype.lastIndexOf),ga=J(Array.prototype.pop),ct=J(Array.prototype.push),Wd=J(Array.prototype.splice),Gt=J(String.prototype.toLowerCase),Qn=J(String.prototype.toString),Zn=J(String.prototype.match),dt=J(String.prototype.replace),Vd=J(String.prototype.indexOf),Gd=J(String.prototype.trim),se=J(Object.prototype.hasOwnProperty),Y=J(RegExp.prototype.test),ut=Yd(TypeError);function J(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 $s(e,t,s)}}function Yd(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return xs(e,n)}}function L(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Gt;fa&&fa(e,null);let s=t.length;for(;s--;){let i=t[s];if(typeof i=="string"){const a=n(i);a!==i&&(Hd(t)||(t[s]=a),i=a)}e[i]=!0}return e}function Qd(e){for(let t=0;t<e.length;t++)se(e,t)||(e[t]=null);return e}function de(e){const t=ws(null);for(const[n,s]of Zo(e))se(e,n)&&(Array.isArray(s)?t[n]=Qd(s):s&&typeof s=="object"&&s.constructor===Object?t[n]=de(s):t[n]=s);return t}function pt(e,t){for(;e!==null;){const s=jd(e,t);if(s){if(s.get)return J(s.get);if(typeof s.value=="function")return J(s.value)}e=zd(e)}function n(){return null}return n}const va=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"]),Jn=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"]),Xn=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"]),Zd=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"]),es=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"]),Jd=Z(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ma=Z(["#text"]),ya=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"]),ts=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"]),ba=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"]),Xd=ne(/\{\{[\w\W]*|[\w\W]*\}\}/gm),eu=ne(/<%[\w\W]*|[\w\W]*%>/gm),tu=ne(/\$\{[\w\W]*/gm),nu=ne(/^data-[\-\w.\u00B7-\uFFFF]+$/),su=ne(/^aria-[\-\w]+$/),Jo=ne(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),iu=ne(/^(?:\w+script|data):/i),au=ne(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Xo=ne(/^html$/i),ou=ne(/^[a-z][.\w]*(-[.\w]+)+$/i);var wa=Object.freeze({__proto__:null,ARIA_ATTR:su,ATTR_WHITESPACE:au,CUSTOM_ELEMENT:ou,DATA_ATTR:nu,DOCTYPE_NAME:Xo,ERB_EXPR:eu,IS_ALLOWED_URI:Jo,IS_SCRIPT_OR_DATA:iu,MUSTACHE_EXPR:Xd,TMPLIT_EXPR:tu});const ht={element:1,text:3,progressingInstruction:7,comment:8,document:9},ru=function(){return typeof window>"u"?null:window},lu=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}},$a=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function er(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ru();const t=T=>er(T);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==ht.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const s=n,i=s.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:l,Element:r,NodeFilter:p,NamedNodeMap:d=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:u,DOMParser:g,trustedTypes:v}=e,m=r.prototype,$=pt(m,"cloneNode"),A=pt(m,"remove"),_=pt(m,"nextSibling"),I=pt(m,"childNodes"),P=pt(m,"parentNode");if(typeof o=="function"){const T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let M,C="";const{implementation:E,createNodeIterator:pe,createDocumentFragment:xn,getElementsByTagName:An}=n,{importNode:Er}=s;let G=$a();t.isSupported=typeof Zo=="function"&&typeof P=="function"&&E&&E.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:kn,ERB_EXPR:Sn,TMPLIT_EXPR:_n,DATA_ATTR:Mr,ARIA_ATTR:Ir,IS_SCRIPT_OR_DATA:Lr,ATTR_WHITESPACE:vi,CUSTOM_ELEMENT:Rr}=wa;let{IS_ALLOWED_URI:mi}=wa,K=null;const yi=L({},[...va,...Jn,...Xn,...es,...ma]);let z=null;const bi=L({},[...ya,...ts,...ba,...zt]);let B=Object.seal(ws(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),it=null,Tn=null;const He=Object.seal(ws(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let wi=!0,Cn=!0,$i=!1,xi=!0,ze=!1,It=!0,Ce=!1,En=!1,Mn=!1,je=!1,Lt=!1,Rt=!1,Ai=!0,ki=!1;const Pr="user-content-";let In=!0,at=!1,qe={},re=null;const Ln=L({},["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 Si=null;const _i=L({},["audio","video","img","source","image","track"]);let Rn=null;const Ti=L({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Pt="http://www.w3.org/1998/Math/MathML",Nt="http://www.w3.org/2000/svg",he="http://www.w3.org/1999/xhtml";let We=he,Pn=!1,Nn=null;const Nr=L({},[Pt,Nt,he],Qn);let Ot=L({},["mi","mo","mn","ms","mtext"]),Dt=L({},["annotation-xml"]);const Or=L({},["title","style","font","a","script"]);let ot=null;const Dr=["application/xhtml+xml","text/html"],Br="text/html";let U=null,Ve=null;const Fr=n.createElement("form"),Ci=function(h){return h instanceof RegExp||h instanceof Function},On=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ve&&Ve===h)){if((!h||typeof h!="object")&&(h={}),h=de(h),ot=Dr.indexOf(h.PARSER_MEDIA_TYPE)===-1?Br:h.PARSER_MEDIA_TYPE,U=ot==="application/xhtml+xml"?Qn:Gt,K=se(h,"ALLOWED_TAGS")?L({},h.ALLOWED_TAGS,U):yi,z=se(h,"ALLOWED_ATTR")?L({},h.ALLOWED_ATTR,U):bi,Nn=se(h,"ALLOWED_NAMESPACES")?L({},h.ALLOWED_NAMESPACES,Qn):Nr,Rn=se(h,"ADD_URI_SAFE_ATTR")?L(de(Ti),h.ADD_URI_SAFE_ATTR,U):Ti,Si=se(h,"ADD_DATA_URI_TAGS")?L(de(_i),h.ADD_DATA_URI_TAGS,U):_i,re=se(h,"FORBID_CONTENTS")?L({},h.FORBID_CONTENTS,U):Ln,it=se(h,"FORBID_TAGS")?L({},h.FORBID_TAGS,U):de({}),Tn=se(h,"FORBID_ATTR")?L({},h.FORBID_ATTR,U):de({}),qe=se(h,"USE_PROFILES")?h.USE_PROFILES:!1,wi=h.ALLOW_ARIA_ATTR!==!1,Cn=h.ALLOW_DATA_ATTR!==!1,$i=h.ALLOW_UNKNOWN_PROTOCOLS||!1,xi=h.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ze=h.SAFE_FOR_TEMPLATES||!1,It=h.SAFE_FOR_XML!==!1,Ce=h.WHOLE_DOCUMENT||!1,je=h.RETURN_DOM||!1,Lt=h.RETURN_DOM_FRAGMENT||!1,Rt=h.RETURN_TRUSTED_TYPE||!1,Mn=h.FORCE_BODY||!1,Ai=h.SANITIZE_DOM!==!1,ki=h.SANITIZE_NAMED_PROPS||!1,In=h.KEEP_CONTENT!==!1,at=h.IN_PLACE||!1,mi=h.ALLOWED_URI_REGEXP||Jo,We=h.NAMESPACE||he,Ot=h.MATHML_TEXT_INTEGRATION_POINTS||Ot,Dt=h.HTML_INTEGRATION_POINTS||Dt,B=h.CUSTOM_ELEMENT_HANDLING||{},h.CUSTOM_ELEMENT_HANDLING&&Ci(h.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(B.tagNameCheck=h.CUSTOM_ELEMENT_HANDLING.tagNameCheck),h.CUSTOM_ELEMENT_HANDLING&&Ci(h.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(B.attributeNameCheck=h.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),h.CUSTOM_ELEMENT_HANDLING&&typeof h.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(B.allowCustomizedBuiltInElements=h.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ze&&(Cn=!1),Lt&&(je=!0),qe&&(K=L({},ma),z=[],qe.html===!0&&(L(K,va),L(z,ya)),qe.svg===!0&&(L(K,Jn),L(z,ts),L(z,zt)),qe.svgFilters===!0&&(L(K,Xn),L(z,ts),L(z,zt)),qe.mathMl===!0&&(L(K,es),L(z,ba),L(z,zt))),h.ADD_TAGS&&(typeof h.ADD_TAGS=="function"?He.tagCheck=h.ADD_TAGS:(K===yi&&(K=de(K)),L(K,h.ADD_TAGS,U))),h.ADD_ATTR&&(typeof h.ADD_ATTR=="function"?He.attributeCheck=h.ADD_ATTR:(z===bi&&(z=de(z)),L(z,h.ADD_ATTR,U))),h.ADD_URI_SAFE_ATTR&&L(Rn,h.ADD_URI_SAFE_ATTR,U),h.FORBID_CONTENTS&&(re===Ln&&(re=de(re)),L(re,h.FORBID_CONTENTS,U)),h.ADD_FORBID_CONTENTS&&(re===Ln&&(re=de(re)),L(re,h.ADD_FORBID_CONTENTS,U)),In&&(K["#text"]=!0),Ce&&L(K,["html","head","body"]),K.table&&(L(K,["tbody"]),delete it.tbody),h.TRUSTED_TYPES_POLICY){if(typeof h.TRUSTED_TYPES_POLICY.createHTML!="function")throw ut('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof h.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ut('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');M=h.TRUSTED_TYPES_POLICY,C=M.createHTML("")}else M===void 0&&(M=lu(v,i)),M!==null&&typeof C=="string"&&(C=M.createHTML(""));Z&&Z(h),Ve=h}},Ei=L({},[...Jn,...Xn,...Zd]),Mi=L({},[...es,...Jd]),Ur=function(h){let x=P(h);(!x||!x.tagName)&&(x={namespaceURI:We,tagName:"template"});const S=Gt(h.tagName),D=Gt(x.tagName);return Nn[h.namespaceURI]?h.namespaceURI===Nt?x.namespaceURI===he?S==="svg":x.namespaceURI===Pt?S==="svg"&&(D==="annotation-xml"||Ot[D]):!!Ei[S]:h.namespaceURI===Pt?x.namespaceURI===he?S==="math":x.namespaceURI===Nt?S==="math"&&Dt[D]:!!Mi[S]:h.namespaceURI===he?x.namespaceURI===Nt&&!Dt[D]||x.namespaceURI===Pt&&!Ot[D]?!1:!Mi[S]&&(Or[S]||!Ei[S]):!!(ot==="application/xhtml+xml"&&Nn[h.namespaceURI]):!1},le=function(h){ct(t.removed,{element:h});try{P(h).removeChild(h)}catch{A(h)}},Ee=function(h,x){try{ct(t.removed,{attribute:x.getAttributeNode(h),from:x})}catch{ct(t.removed,{attribute:null,from:x})}if(x.removeAttribute(h),h==="is")if(je||Lt)try{le(x)}catch{}else try{x.setAttribute(h,"")}catch{}},Ii=function(h){let x=null,S=null;if(Mn)h="<remove></remove>"+h;else{const F=Zn(h,/^[\r\n\t ]+/);S=F&&F[0]}ot==="application/xhtml+xml"&&We===he&&(h='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+h+"</body></html>");const D=M?M.createHTML(h):h;if(We===he)try{x=new g().parseFromString(D,ot)}catch{}if(!x||!x.documentElement){x=E.createDocument(We,"template",null);try{x.documentElement.innerHTML=Pn?C:D}catch{}}const q=x.body||x.documentElement;return h&&S&&q.insertBefore(n.createTextNode(S),q.childNodes[0]||null),We===he?An.call(x,Ce?"html":"body")[0]:Ce?x.documentElement:q},Li=function(h){return pe.call(h.ownerDocument||h,h,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},Dn=function(h){return h instanceof u&&(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")},Ri=function(h){return typeof l=="function"&&h instanceof l};function fe(T,h,x){Ht(T,S=>{S.call(t,h,x,Ve)})}const Pi=function(h){let x=null;if(fe(G.beforeSanitizeElements,h,null),Dn(h))return le(h),!0;const S=U(h.nodeName);if(fe(G.uponSanitizeElement,h,{tagName:S,allowedTags:K}),It&&h.hasChildNodes()&&!Ri(h.firstElementChild)&&Y(/<[/\w!]/g,h.innerHTML)&&Y(/<[/\w!]/g,h.textContent)||h.nodeType===ht.progressingInstruction||It&&h.nodeType===ht.comment&&Y(/<[/\w]/g,h.data))return le(h),!0;if(!(He.tagCheck instanceof Function&&He.tagCheck(S))&&(!K[S]||it[S])){if(!it[S]&&Oi(S)&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,S)||B.tagNameCheck instanceof Function&&B.tagNameCheck(S)))return!1;if(In&&!re[S]){const D=P(h)||h.parentNode,q=I(h)||h.childNodes;if(q&&D){const F=q.length;for(let X=F-1;X>=0;--X){const ge=$(q[X],!0);ge.__removalCount=(h.__removalCount||0)+1,D.insertBefore(ge,_(h))}}}return le(h),!0}return h instanceof r&&!Ur(h)||(S==="noscript"||S==="noembed"||S==="noframes")&&Y(/<\/no(script|embed|frames)/i,h.innerHTML)?(le(h),!0):(ze&&h.nodeType===ht.text&&(x=h.textContent,Ht([kn,Sn,_n],D=>{x=dt(x,D," ")}),h.textContent!==x&&(ct(t.removed,{element:h.cloneNode()}),h.textContent=x)),fe(G.afterSanitizeElements,h,null),!1)},Ni=function(h,x,S){if(Ai&&(x==="id"||x==="name")&&(S in n||S in Fr))return!1;if(!(Cn&&!Tn[x]&&Y(Mr,x))){if(!(wi&&Y(Ir,x))){if(!(He.attributeCheck instanceof Function&&He.attributeCheck(x,h))){if(!z[x]||Tn[x]){if(!(Oi(h)&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,h)||B.tagNameCheck instanceof Function&&B.tagNameCheck(h))&&(B.attributeNameCheck instanceof RegExp&&Y(B.attributeNameCheck,x)||B.attributeNameCheck instanceof Function&&B.attributeNameCheck(x,h))||x==="is"&&B.allowCustomizedBuiltInElements&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,S)||B.tagNameCheck instanceof Function&&B.tagNameCheck(S))))return!1}else if(!Rn[x]){if(!Y(mi,dt(S,vi,""))){if(!((x==="src"||x==="xlink:href"||x==="href")&&h!=="script"&&Vd(S,"data:")===0&&Si[h])){if(!($i&&!Y(Lr,dt(S,vi,"")))){if(S)return!1}}}}}}}return!0},Oi=function(h){return h!=="annotation-xml"&&Zn(h,Rr)},Di=function(h){fe(G.beforeSanitizeAttributes,h,null);const{attributes:x}=h;if(!x||Dn(h))return;const S={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:z,forceKeepAttr:void 0};let D=x.length;for(;D--;){const q=x[D],{name:F,namespaceURI:X,value:ge}=q,Ge=U(F),Bn=ge;let j=F==="value"?Bn:Gd(Bn);if(S.attrName=Ge,S.attrValue=j,S.keepAttr=!0,S.forceKeepAttr=void 0,fe(G.uponSanitizeAttribute,h,S),j=S.attrValue,ki&&(Ge==="id"||Ge==="name")&&(Ee(F,h),j=Pr+j),It&&Y(/((--!?|])>)|<\/(style|title|textarea)/i,j)){Ee(F,h);continue}if(Ge==="attributename"&&Zn(j,"href")){Ee(F,h);continue}if(S.forceKeepAttr)continue;if(!S.keepAttr){Ee(F,h);continue}if(!xi&&Y(/\/>/i,j)){Ee(F,h);continue}ze&&Ht([kn,Sn,_n],Fi=>{j=dt(j,Fi," ")});const Bi=U(h.nodeName);if(!Ni(Bi,Ge,j)){Ee(F,h);continue}if(M&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!X)switch(v.getAttributeType(Bi,Ge)){case"TrustedHTML":{j=M.createHTML(j);break}case"TrustedScriptURL":{j=M.createScriptURL(j);break}}if(j!==Bn)try{X?h.setAttributeNS(X,F,j):h.setAttribute(F,j),Dn(h)?le(h):ga(t.removed)}catch{Ee(F,h)}}fe(G.afterSanitizeAttributes,h,null)},Kr=function T(h){let x=null;const S=Li(h);for(fe(G.beforeSanitizeShadowDOM,h,null);x=S.nextNode();)fe(G.uponSanitizeShadowNode,x,null),Pi(x),Di(x),x.content instanceof a&&T(x.content);fe(G.afterSanitizeShadowDOM,h,null)};return t.sanitize=function(T){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,S=null,D=null,q=null;if(Pn=!T,Pn&&(T="<!-->"),typeof T!="string"&&!Ri(T))if(typeof T.toString=="function"){if(T=T.toString(),typeof T!="string")throw ut("dirty is not a string, aborting")}else throw ut("toString is not a function");if(!t.isSupported)return T;if(En||On(h),t.removed=[],typeof T=="string"&&(at=!1),at){if(T.nodeName){const ge=U(T.nodeName);if(!K[ge]||it[ge])throw ut("root node is forbidden and cannot be sanitized in-place")}}else if(T instanceof l)x=Ii("<!---->"),S=x.ownerDocument.importNode(T,!0),S.nodeType===ht.element&&S.nodeName==="BODY"||S.nodeName==="HTML"?x=S:x.appendChild(S);else{if(!je&&!ze&&!Ce&&T.indexOf("<")===-1)return M&&Rt?M.createHTML(T):T;if(x=Ii(T),!x)return je?null:Rt?C:""}x&&Mn&&le(x.firstChild);const F=Li(at?T:x);for(;D=F.nextNode();)Pi(D),Di(D),D.content instanceof a&&Kr(D.content);if(at)return T;if(je){if(Lt)for(q=xn.call(x.ownerDocument);x.firstChild;)q.appendChild(x.firstChild);else q=x;return(z.shadowroot||z.shadowrootmode)&&(q=Er.call(s,q,!0)),q}let X=Ce?x.outerHTML:x.innerHTML;return Ce&&K["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&Y(Xo,x.ownerDocument.doctype.name)&&(X="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
|
|
17
|
+
`+X),ze&&Ht([kn,Sn,_n],ge=>{X=dt(X,ge," ")}),M&&Rt?M.createHTML(X):X},t.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};On(T),En=!0},t.clearConfig=function(){Ve=null,En=!1},t.isValidAttribute=function(T,h,x){Ve||On({});const S=U(T),D=U(h);return Ni(S,D,x)},t.addHook=function(T,h){typeof h=="function"&&ct(G[T],h)},t.removeHook=function(T,h){if(h!==void 0){const x=qd(G[T],h);return x===-1?void 0:Wd(G[T],x,1)[0]}return ga(G[T])},t.removeHooks=function(T){G[T]=[]},t.removeAllHooks=function(){G=$a()},t}var As=er();function ai(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ke=ai();function tr(e){Ke=e}var wt={exec:()=>null};function R(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(Q.caret,"$1"),n=n.replace(i,o),s},getRegex:()=>new RegExp(n,t)};return s}var cu=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Q={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")},du=/^(?:[ \t]*(?:\n|$))+/,uu=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,pu=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Mt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,hu=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,oi=/(?:[*+-]|\d{1,9}[.)])/,nr=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,sr=R(nr).replace(/bull/g,oi).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(),fu=R(nr).replace(/bull/g,oi).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(),ri=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,gu=/^[^\n]+/,li=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,vu=R(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",li).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),mu=R(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,oi).getRegex(),yn="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",ci=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,yu=R("^ {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",ci).replace("tag",yn).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ir=R(ri).replace("hr",Mt).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",yn).getRegex(),bu=R(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ir).getRegex(),di={blockquote:bu,code:uu,def:vu,fences:pu,heading:hu,hr:Mt,html:yu,lheading:sr,list:mu,newline:du,paragraph:ir,table:wt,text:gu},xa=R("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Mt).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",yn).getRegex(),wu={...di,lheading:fu,table:xa,paragraph:R(ri).replace("hr",Mt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",xa).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",yn).getRegex()},$u={...di,html:R(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ci).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:wt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:R(ri).replace("hr",Mt).replace("heading",` *#{1,6} *[^
|
|
18
|
+
]`).replace("lheading",sr).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},xu=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Au=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ar=/^( {2,}|\\)\n(?!\s*$)/,ku=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,bn=/[\p{P}\p{S}]/u,ui=/[\s\p{P}\p{S}]/u,or=/[^\s\p{P}\p{S}]/u,Su=R(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ui).getRegex(),rr=/(?!~)[\p{P}\p{S}]/u,_u=/(?!~)[\s\p{P}\p{S}]/u,Tu=/(?:[^\s\p{P}\p{S}]|~)/u,Cu=R(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",cu?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),lr=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Eu=R(lr,"u").replace(/punct/g,bn).getRegex(),Mu=R(lr,"u").replace(/punct/g,rr).getRegex(),cr="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Iu=R(cr,"gu").replace(/notPunctSpace/g,or).replace(/punctSpace/g,ui).replace(/punct/g,bn).getRegex(),Lu=R(cr,"gu").replace(/notPunctSpace/g,Tu).replace(/punctSpace/g,_u).replace(/punct/g,rr).getRegex(),Ru=R("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,or).replace(/punctSpace/g,ui).replace(/punct/g,bn).getRegex(),Pu=R(/\\(punct)/,"gu").replace(/punct/g,bn).getRegex(),Nu=R(/^<(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(),Ou=R(ci).replace("(?:-->|$)","-->").getRegex(),Du=R("^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",Ou).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),tn=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Bu=R(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",tn).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),dr=R(/^!?\[(label)\]\[(ref)\]/).replace("label",tn).replace("ref",li).getRegex(),ur=R(/^!?\[(ref)\](?:\[\])?/).replace("ref",li).getRegex(),Fu=R("reflink|nolink(?!\\()","g").replace("reflink",dr).replace("nolink",ur).getRegex(),Aa=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,pi={_backpedal:wt,anyPunctuation:Pu,autolink:Nu,blockSkip:Cu,br:ar,code:Au,del:wt,emStrongLDelim:Eu,emStrongRDelimAst:Iu,emStrongRDelimUnd:Ru,escape:xu,link:Bu,nolink:ur,punctuation:Su,reflink:dr,reflinkSearch:Fu,tag:Du,text:ku,url:wt},Uu={...pi,link:R(/^!?\[(label)\]\((.*?)\)/).replace("label",tn).getRegex(),reflink:R(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",tn).getRegex()},ks={...pi,emStrongRDelimAst:Lu,emStrongLDelim:Mu,url:R(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Aa).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:R(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Aa).getRegex()},Ku={...ks,br:R(ar).replace("{2,}","*").getRegex(),text:R(ks.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},jt={normal:di,gfm:wu,pedantic:$u},ft={normal:pi,gfm:ks,breaks:Ku,pedantic:Uu},Hu={"&":"&","<":"<",">":">",'"':""","'":"'"},ka=e=>Hu[e];function me(e,t){if(t){if(Q.escapeTest.test(e))return e.replace(Q.escapeReplace,ka)}else if(Q.escapeTestNoEncode.test(e))return e.replace(Q.escapeReplaceNoEncode,ka);return e}function Sa(e){try{e=encodeURI(e).replace(Q.percentDecode,"%")}catch{return null}return e}function _a(e,t){let n=e.replace(Q.findPipe,(a,o,l)=>{let r=!1,p=o;for(;--p>=0&&l[p]==="\\";)r=!r;return r?"|":" |"}),s=n.split(Q.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(Q.slashPipe,"|");return s}function gt(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 zu(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 Ta(e,t,n,s,i){let a=t.href,o=t.title||null,l=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:l,tokens:s.inlineTokens(l)};return s.state.inLink=!1,r}function ju(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let i=s[1];return t.split(`
|
|
19
|
+
`).map(a=>{let o=a.match(n.other.beginningSpace);if(o===null)return a;let[l]=o;return l.length>=i.length?a.slice(i.length):a}).join(`
|
|
20
|
+
`)}var nn=class{options;rules;lexer;constructor(e){this.options=e||Ke}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:gt(n,`
|
|
21
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=ju(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=gt(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:gt(t[0],`
|
|
22
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=gt(t[0],`
|
|
23
|
+
`).split(`
|
|
24
|
+
`),s="",i="",a=[];for(;n.length>0;){let o=!1,l=[],r;for(r=0;r<n.length;r++)if(this.rules.other.blockquoteStart.test(n[r]))l.push(n[r]),o=!0;else if(!o)l.push(n[r]);else break;n=n.slice(r);let p=l.join(`
|
|
25
|
+
`),d=p.replace(this.rules.other.blockquoteSetextReplace,`
|
|
26
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
|
|
27
|
+
${p}`:p,i=i?`${i}
|
|
28
|
+
${d}`:d;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,a,!0),this.lexer.state.top=u,n.length===0)break;let g=a.at(-1);if(g?.type==="code")break;if(g?.type==="blockquote"){let v=g,m=v.raw+`
|
|
29
|
+
`+n.join(`
|
|
30
|
+
`),$=this.blockquote(m);a[a.length-1]=$,s=s.substring(0,s.length-v.raw.length)+$.raw,i=i.substring(0,i.length-v.text.length)+$.text;break}else if(g?.type==="list"){let v=g,m=v.raw+`
|
|
31
|
+
`+n.join(`
|
|
32
|
+
`),$=this.list(m);a[a.length-1]=$,s=s.substring(0,s.length-g.raw.length)+$.raw,i=i.substring(0,i.length-v.raw.length)+$.raw,n=m.substring(a.at(-1).raw.length).split(`
|
|
33
|
+
`);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,p="",d="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let u=t[2].split(`
|
|
34
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,$=>" ".repeat(3*$.length)),g=e.split(`
|
|
35
|
+
`,1)[0],v=!u.trim(),m=0;if(this.options.pedantic?(m=2,d=u.trimStart()):v?m=t[1].length+1:(m=t[2].search(this.rules.other.nonSpaceChar),m=m>4?1:m,d=u.slice(m),m+=t[1].length),v&&this.rules.other.blankLine.test(g)&&(p+=g+`
|
|
36
|
+
`,e=e.substring(g.length+1),r=!0),!r){let $=this.rules.other.nextBulletRegex(m),A=this.rules.other.hrRegex(m),_=this.rules.other.fencesBeginRegex(m),I=this.rules.other.headingBeginRegex(m),P=this.rules.other.htmlBeginRegex(m);for(;e;){let M=e.split(`
|
|
37
|
+
`,1)[0],C;if(g=M,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),C=g):C=g.replace(this.rules.other.tabCharGlobal," "),_.test(g)||I.test(g)||P.test(g)||$.test(g)||A.test(g))break;if(C.search(this.rules.other.nonSpaceChar)>=m||!g.trim())d+=`
|
|
38
|
+
`+C.slice(m);else{if(v||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||_.test(u)||I.test(u)||A.test(u))break;d+=`
|
|
39
|
+
`+g}!v&&!g.trim()&&(v=!0),p+=M+`
|
|
40
|
+
`,e=e.substring(M.length+1),u=C.slice(m)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(o=!0)),i.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(d),loose:!1,text:d,tokens:[]}),i.raw+=p}let l=i.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.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 p=this.rules.other.listTaskCheckbox.exec(r.raw);if(p){let d={type:"checkbox",raw:p[0]+" ",checked:p[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 p=r.tokens.filter(u=>u.type==="space"),d=p.length>0&&p.some(u=>this.rules.other.anyLine.test(u.raw));i.loose=d}}if(i.loose)for(let r of i.items){r.loose=!0;for(let p of r.tokens)p.type==="text"&&(p.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=_a(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
41
|
+
`):[],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(_a(o,a.header.length).map((l,r)=>({text:l,tokens:this.lexer.inline(l),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)===`
|
|
42
|
+
`?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=gt(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{let a=zu(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)),Ta(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 Ta(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,l=i,r=0,p=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,t=t.slice(-1*e.length+i);(s=p.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]){l+=o;continue}else if((s[5]||s[6])&&i%3&&!((i+o)%3)){r+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l+r);let d=[...s[0]][0].length,u=e.slice(0,i+s.index+d+o);if(Math.min(i,o)%2){let v=u.slice(1,-1);return{type:"em",raw:u,text:v,tokens:this.lexer.inlineTokens(v)}}let g=u.slice(2,-2);return{type:"strong",raw:u,text:g,tokens:this.lexer.inlineTokens(g)}}}}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}}}},ie=class Ss{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ke,this.options.tokenizer=this.options.tokenizer||new nn,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:Q,block:jt.normal,inline:ft.normal};this.options.pedantic?(n.block=jt.pedantic,n.inline=ft.pedantic):this.options.gfm&&(n.block=jt.gfm,this.options.breaks?n.inline=ft.breaks:n.inline=ft.gfm),this.tokenizer.rules=n}static get rules(){return{block:jt,inline:ft}}static lex(t,n){return new Ss(n).lex(t)}static lexInline(t,n){return new Ss(n).inlineTokens(t)}lex(t){t=t.replace(Q.carriageReturn,`
|
|
43
|
+
`),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(Q.tabCharGlobal," ").replace(Q.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+=`
|
|
44
|
+
`: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(`
|
|
45
|
+
`)?"":`
|
|
46
|
+
`)+i.raw,o.text+=`
|
|
47
|
+
`+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(`
|
|
48
|
+
`)?"":`
|
|
49
|
+
`)+i.raw,o.text+=`
|
|
50
|
+
`+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,l=t.slice(1),r;this.options.extensions.startBlock.forEach(p=>{r=p.call({lexer:this},l),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(`
|
|
51
|
+
`)?"":`
|
|
52
|
+
`)+i.raw,o.text+=`
|
|
53
|
+
`+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(`
|
|
54
|
+
`)?"":`
|
|
55
|
+
`)+i.raw,o.text+=`
|
|
56
|
+
`+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,l="";for(;t;){o||(l=""),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,l)){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 p=t;if(this.options.extensions?.startInline){let d=1/0,u=t.slice(1),g;this.options.extensions.startInline.forEach(v=>{g=v.call({lexer:this},u),typeof g=="number"&&g>=0&&(d=Math.min(d,g))}),d<1/0&&d>=0&&(p=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(p)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(l=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}},sn=class{options;parser;constructor(e){this.options=e||Ke}space(e){return""}code({text:e,lang:t,escaped:n}){let s=(t||"").match(Q.notSpaceStart)?.[0],i=e.replace(Q.endingNewline,"")+`
|
|
57
|
+
`;return s?'<pre><code class="language-'+me(s)+'">'+(n?i:me(i,!0))+`</code></pre>
|
|
58
|
+
`:"<pre><code>"+(n?i:me(i,!0))+`</code></pre>
|
|
59
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
60
|
+
${this.parser.parse(e)}</blockquote>
|
|
61
|
+
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
62
|
+
`}hr(e){return`<hr>
|
|
63
|
+
`}list(e){let t=e.ordered,n=e.start,s="";for(let o=0;o<e.items.length;o++){let l=e.items[o];s+=this.listitem(l)}let i=t?"ol":"ul",a=t&&n!==1?' start="'+n+'"':"";return"<"+i+a+`>
|
|
64
|
+
`+s+"</"+i+`>
|
|
65
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
66
|
+
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
67
|
+
`}table(e){let t="",n="";for(let i=0;i<e.header.length;i++)n+=this.tablecell(e.header[i]);t+=this.tablerow({text:n});let s="";for(let i=0;i<e.rows.length;i++){let a=e.rows[i];n="";for(let o=0;o<a.length;o++)n+=this.tablecell(a[o]);s+=this.tablerow({text:n})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
|
|
68
|
+
<thead>
|
|
69
|
+
`+t+`</thead>
|
|
70
|
+
`+s+`</table>
|
|
71
|
+
`}tablerow({text:e}){return`<tr>
|
|
72
|
+
${e}</tr>
|
|
73
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
74
|
+
`}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>${me(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=Sa(e);if(i===null)return s;e=i;let a='<a href="'+e+'"';return t&&(a+=' title="'+me(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=Sa(e);if(i===null)return me(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${me(t)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:me(e.text)}},hi=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}},ae=class _s{options;renderer;textRenderer;constructor(t){this.options=t||Ke,this.options.renderer=this.options.renderer||new sn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new hi}static parse(t,n){return new _s(n).parse(t)}static parseInline(t,n){return new _s(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,l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=l||"";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 l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){s+=l||"";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 l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return s}},vt=class{options;block;constructor(e){this.options=e||Ke}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?ie.lex:ie.lexInline}provideParser(){return this.block?ae.parse:ae.parseInline}},qu=class{defaults=ai();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ae;Renderer=sn;TextRenderer=hi;Lexer=ie;Tokenizer=nn;Hooks=vt;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 l=i.renderer.apply(this,o);return l===!1&&(l=a.apply(this,o)),l}: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 sn(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,l=n.renderer[o],r=i[o];i[o]=(...p)=>{let d=l.apply(i,p);return d===!1&&(d=r.apply(i,p)),d||""}}s.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new nn(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,l=n.tokenizer[o],r=i[o];i[o]=(...p)=>{let d=l.apply(i,p);return d===!1&&(d=r.apply(i,p)),d}}s.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new vt;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,l=n.hooks[o],r=i[o];vt.passThroughHooks.has(a)?i[o]=p=>{if(this.defaults.async&&vt.passThroughHooksRespectAsync.has(a))return(async()=>{let u=await l.call(i,p);return r.call(i,u)})();let d=l.call(i,p);return r.call(i,d)}:i[o]=(...p)=>{if(this.defaults.async)return(async()=>{let u=await l.apply(i,p);return u===!1&&(u=await r.apply(i,p)),u})();let d=l.apply(i,p);return d===!1&&(d=r.apply(i,p)),d}}s.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,a=n.walkTokens;s.walkTokens=function(o){let l=[];return l.push(a.call(this,o)),i&&(l=l.concat(i.call(this,o))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ie.lex(e,t??this.defaults)}parser(e,t){return ae.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,l=await(i.hooks?await i.hooks.provideLexer():e?ie.lex:ie.lexInline)(o,i),r=i.hooks?await i.hooks.processAllTokens(l):l;i.walkTokens&&await Promise.all(this.walkTokens(r,i.walkTokens));let p=await(i.hooks?await i.hooks.provideParser():e?ae.parse:ae.parseInline)(r,i);return i.hooks?await i.hooks.postprocess(p):p})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let o=(i.hooks?i.hooks.provideLexer():e?ie.lex:ie.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let l=(i.hooks?i.hooks.provideParser():e?ae.parse:ae.parseInline)(o,i);return i.hooks&&(l=i.hooks.postprocess(l)),l}catch(o){return a(o)}}}onError(e,t){return n=>{if(n.message+=`
|
|
75
|
+
Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+me(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},Ue=new qu;function N(e,t){return Ue.parse(e,t)}N.options=N.setOptions=function(e){return Ue.setOptions(e),N.defaults=Ue.defaults,tr(N.defaults),N};N.getDefaults=ai;N.defaults=Ke;N.use=function(...e){return Ue.use(...e),N.defaults=Ue.defaults,tr(N.defaults),N};N.walkTokens=function(e,t){return Ue.walkTokens(e,t)};N.parseInline=Ue.parseInline;N.Parser=ae;N.parser=ae.parse;N.Renderer=sn;N.TextRenderer=hi;N.Lexer=ie;N.lexer=ie.lex;N.Tokenizer=nn;N.Hooks=vt;N.parse=N;N.options;N.setOptions;N.use;N.walkTokens;N.parseInline;ae.parse;ie.lex;N.setOptions({gfm:!0,breaks:!0,mangle:!1});const Ca=["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"],Ea=["class","href","rel","target","title","start"];let Ma=!1;const Wu=14e4,Vu=4e4,Gu=200,ns=5e4,Ne=new Map;function Yu(e){const t=Ne.get(e);return t===void 0?null:(Ne.delete(e),Ne.set(e,t),t)}function Ia(e,t){if(Ne.set(e,t),Ne.size<=Gu)return;const n=Ne.keys().next().value;n&&Ne.delete(n)}function Qu(){Ma||(Ma=!0,As.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function Ts(e){const t=e.trim();if(!t)return"";if(Qu(),t.length<=ns){const o=Yu(t);if(o!==null)return o}const n=fo(t,Wu),s=n.truncated?`
|
|
76
|
+
|
|
77
|
+
… truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>Vu){const l=`<pre class="code-block">${Zu(`${n.text}${s}`)}</pre>`,r=As.sanitize(l,{ALLOWED_TAGS:Ca,ALLOWED_ATTR:Ea});return t.length<=ns&&Ia(t,r),r}const i=N.parse(`${n.text}${s}`),a=As.sanitize(i,{ALLOWED_TAGS:Ca,ALLOWED_ATTR:Ea});return t.length<=ns&&Ia(t,a),a}function Zu(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Ju=1500,Xu=2e3,pr="Copy as markdown",ep="Copied",tp="Copy failed";async function np(e){if(!e)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function qt(e,t){e.title=t,e.setAttribute("aria-label",t)}function sp(e){const t=e.label??pr;return c`
|
|
78
|
+
<button
|
|
79
|
+
class="chat-copy-btn"
|
|
80
|
+
type="button"
|
|
81
|
+
title=${t}
|
|
82
|
+
aria-label=${t}
|
|
83
|
+
@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",qt(s,tp),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.error,qt(s,t))},Xu);return}s.dataset.copied="1",qt(s,ep),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.copied,qt(s,t))},Ju)}}}
|
|
84
|
+
>
|
|
85
|
+
<span class="chat-copy-btn__icon" aria-hidden="true">
|
|
86
|
+
<span class="chat-copy-btn__icon-copy">${V.copy}</span>
|
|
87
|
+
<span class="chat-copy-btn__icon-check">${V.check}</span>
|
|
88
|
+
</span>
|
|
89
|
+
</button>
|
|
90
|
+
`}function ip(e){return sp({text:()=>e,label:pr})}const ap={icon:"puzzle",detailKeys:["command","path","url","targetUrl","targetId","ref","element","node","nodeId","id","requestId","to","channelId","guildId","userId","name","query","pattern","messageId"]},op={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"}}}},rp={fallback:ap,tools:op},hr=rp,La=hr.fallback??{icon:"puzzle"},lp=hr.tools??{};function cp(e){return(e??"tool").trim()}function dp(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 up(e){const t=e?.trim();if(t)return t.replace(/_/g," ")}function fr(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=>fr(s)).filter(s=>!!s);if(t.length===0)return;const n=t.slice(0,3).join(", ");return t.length>3?`${n}…`:n}}}function pp(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 hp(e,t){for(const n of t){const s=pp(e,n),i=fr(s);if(i)return i}}function fp(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 vp(e,t){if(!(!e||!t))return e.actions?.[t]??void 0}function mp(e){const t=cp(e.name),n=t.toLowerCase(),s=lp[n],i=s?.icon??La.icon??"puzzle",a=s?.title??dp(t),o=s?.label??t,l=e.args&&typeof e.args=="object"?e.args.action:void 0,r=typeof l=="string"?l.trim():void 0,p=vp(s,r),d=up(p?.label??r);let u;n==="read"&&(u=fp(e.args)),!u&&(n==="write"||n==="edit"||n==="attach")&&(u=gp(e.args));const g=p?.detailKeys??s?.detailKeys??La.detailKeys??[];return!u&&g.length>0&&(u=hp(e.args,g)),!u&&e.meta&&(u=e.meta),u&&(u=bp(u)),{name:t,icon:i,title:a,label:o,verb:d,detail:u}}function yp(e){const t=[];if(e.verb&&t.push(e.verb),e.detail&&t.push(e.detail),t.length!==0)return t.join(" · ")}function bp(e){return e&&e.replace(/\/Users\/[^/]+/g,"~").replace(/\/home\/[^/]+/g,"~")}const wp=80,$p=2,Ra=100;function xp(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 Ap(e){const t=e.split(`
|
|
91
|
+
`),n=t.slice(0,$p),s=n.join(`
|
|
92
|
+
`);return s.length>Ra?s.slice(0,Ra)+"…":n.length<t.length?s+"…":s}function kp(e){const t=e,n=Sp(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:_p(i.arguments??i.args)})}for(const i of n){const a=String(i.type??"").toLowerCase();if(a!=="toolresult"&&a!=="tool_result")continue;const o=Tp(i),l=typeof i.name=="string"?i.name:"tool";s.push({kind:"result",name:l,text:o})}if(Qo(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=go(e)??void 0;s.push({kind:"result",name:i,text:a})}return s}function Pa(e,t){const n=mp({name:e.name,args:e.args}),s=yp(n),i=!!e.text?.trim(),a=!!t,o=a?()=>{if(i){t(xp(e.text));return}const u=`## ${n.label}
|
|
93
|
+
|
|
94
|
+
${s?`**Command:** \`${s}\`
|
|
95
|
+
|
|
96
|
+
`:""}*No output — tool completed successfully.*`;t(u)}:void 0,l=i&&(e.text?.length??0)<=wp,r=i&&!l,p=i&&l,d=!i;return c`
|
|
97
|
+
<div
|
|
98
|
+
class="chat-tool-card ${a?"chat-tool-card--clickable":""}"
|
|
99
|
+
@click=${o}
|
|
100
|
+
role=${a?"button":f}
|
|
101
|
+
tabindex=${a?"0":f}
|
|
102
|
+
@keydown=${a?u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),o?.())}:f}
|
|
103
|
+
>
|
|
104
|
+
<div class="chat-tool-card__header">
|
|
105
|
+
<div class="chat-tool-card__title">
|
|
106
|
+
<span class="chat-tool-card__icon">${V[n.icon]}</span>
|
|
107
|
+
<span>${n.label}</span>
|
|
108
|
+
</div>
|
|
109
|
+
${a?c`<span class="chat-tool-card__action">${i?"View":""} ${V.check}</span>`:f}
|
|
110
|
+
${d&&!a?c`<span class="chat-tool-card__status">${V.check}</span>`:f}
|
|
111
|
+
</div>
|
|
112
|
+
${s?c`<div class="chat-tool-card__detail">${s}</div>`:f}
|
|
113
|
+
${d?c`<div class="chat-tool-card__status-text muted">Completed</div>`:f}
|
|
114
|
+
${r?c`<div class="chat-tool-card__preview mono">${Ap(e.text)}</div>`:f}
|
|
115
|
+
${p?c`<div class="chat-tool-card__inline mono">${e.text}</div>`:f}
|
|
116
|
+
</div>
|
|
117
|
+
`}function Sp(e){return Array.isArray(e)?e.filter(Boolean):[]}function _p(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 Tp(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function Cp(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 l=o.data,r=o.media_type||"image/png",p=l.startsWith("data:")?l:`data:${r};base64,${l}`;s.push({url:p})}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 Ep(e){return c`
|
|
118
|
+
<div class="chat-group assistant">
|
|
119
|
+
${fi("assistant",e)}
|
|
120
|
+
<div class="chat-group-messages">
|
|
121
|
+
<div class="chat-bubble chat-reading-indicator" aria-hidden="true">
|
|
122
|
+
<span class="chat-reading-indicator__dots">
|
|
123
|
+
<span></span><span></span><span></span>
|
|
124
|
+
</span>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
`}function Mp(e,t,n,s){const i=new Date(t).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),a=s?.name??"Assistant";return c`
|
|
129
|
+
<div class="chat-group assistant">
|
|
130
|
+
${fi("assistant",s)}
|
|
131
|
+
<div class="chat-group-messages">
|
|
132
|
+
${gr({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!0,showReasoning:!1},n)}
|
|
133
|
+
<div class="chat-group-footer">
|
|
134
|
+
<span class="chat-sender-name">${a}</span>
|
|
135
|
+
<span class="chat-group-timestamp">${i}</span>
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
`}function Ip(e,t){const n=ii(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`
|
|
140
|
+
<div class="chat-group ${a}">
|
|
141
|
+
${fi(e.role,{name:s,avatar:t.assistantAvatar??null})}
|
|
142
|
+
<div class="chat-group-messages">
|
|
143
|
+
${e.messages.map((l,r)=>gr(l.message,{isStreaming:e.isStreaming&&r===e.messages.length-1,showReasoning:t.showReasoning},t.onOpenSidebar))}
|
|
144
|
+
<div class="chat-group-footer">
|
|
145
|
+
<span class="chat-sender-name">${i}</span>
|
|
146
|
+
<span class="chat-group-timestamp">${o}</span>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
`}function fi(e,t){const n=ii(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"?Lp(i)?c`<img
|
|
151
|
+
class="chat-avatar ${o}"
|
|
152
|
+
src="${i}"
|
|
153
|
+
alt="${s}"
|
|
154
|
+
/>`:c`<div class="chat-avatar ${o}">${i}</div>`:c`<div class="chat-avatar ${o}">${a}</div>`}function Lp(e){return/^https?:\/\//i.test(e)||/^data:image\//i.test(e)||/^\//.test(e)}function Rp(e){return e.length===0?f:c`
|
|
155
|
+
<div class="chat-message-images">
|
|
156
|
+
${e.map(t=>c`
|
|
157
|
+
<img
|
|
158
|
+
src=${t.url}
|
|
159
|
+
alt=${t.alt??"Attached image"}
|
|
160
|
+
class="chat-message-image"
|
|
161
|
+
@click=${()=>window.open(t.url,"_blank")}
|
|
162
|
+
/>
|
|
163
|
+
`)}
|
|
164
|
+
</div>
|
|
165
|
+
`}function gr(e,t,n){const s=e,i=typeof s.role=="string"?s.role:"unknown",a=Qo(e)||i.toLowerCase()==="toolresult"||i.toLowerCase()==="tool_result"||typeof s.toolCallId=="string"||typeof s.tool_call_id=="string",o=kp(e),l=o.length>0,r=Cp(e),p=r.length>0,d=go(e),u=t.showReasoning&&i==="assistant"?Ml(e):null,g=d?.trim()?d:null,v=u?Ll(u):null,m=g,$=i==="assistant"&&!!m?.trim(),A=["chat-bubble",$?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!m&&l&&a?c`${o.map(_=>Pa(_,n))}`:!m&&!l&&!p?f:c`
|
|
166
|
+
<div class="${A}">
|
|
167
|
+
${$?ip(m):f}
|
|
168
|
+
${Rp(r)}
|
|
169
|
+
${v?c`<div class="chat-thinking">${bs(Ts(v))}</div>`:f}
|
|
170
|
+
${m?c`<div class="chat-text">${bs(Ts(m))}</div>`:f}
|
|
171
|
+
${o.map(_=>Pa(_,n))}
|
|
172
|
+
</div>
|
|
173
|
+
`}function Pp(e){return c`
|
|
174
|
+
<div class="sidebar-panel">
|
|
175
|
+
<div class="sidebar-header">
|
|
176
|
+
<div class="sidebar-title">Tool Output</div>
|
|
177
|
+
<button @click=${e.onClose} class="btn" title="Close sidebar">
|
|
178
|
+
${V.x}
|
|
179
|
+
</button>
|
|
180
|
+
</div>
|
|
181
|
+
<div class="sidebar-content">
|
|
182
|
+
${e.error?c`
|
|
183
|
+
<div class="callout danger">${e.error}</div>
|
|
184
|
+
<button @click=${e.onViewRawText} class="btn" style="margin-top: 12px;">
|
|
185
|
+
View Raw Text
|
|
186
|
+
</button>
|
|
187
|
+
`:e.content?c`<div class="sidebar-markdown">${bs(Ts(e.content))}</div>`:c`<div class="muted">No content available</div>`}
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
`}var Np=Object.defineProperty,Op=Object.getOwnPropertyDescriptor,wn=(e,t,n,s)=>{for(var i=s>1?void 0:s?Op(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&&Np(t,n,i),i};let nt=class extends Ze{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)}};nt.styles=zr`
|
|
191
|
+
:host {
|
|
192
|
+
width: 4px;
|
|
193
|
+
cursor: col-resize;
|
|
194
|
+
background: var(--border, #333);
|
|
195
|
+
transition: background 150ms ease-out;
|
|
196
|
+
flex-shrink: 0;
|
|
197
|
+
position: relative;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
:host::before {
|
|
201
|
+
content: "";
|
|
202
|
+
position: absolute;
|
|
203
|
+
top: 0;
|
|
204
|
+
left: -4px;
|
|
205
|
+
right: -4px;
|
|
206
|
+
bottom: 0;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
:host(:hover) {
|
|
210
|
+
background: var(--accent, #007bff);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
:host(.dragging) {
|
|
214
|
+
background: var(--accent, #007bff);
|
|
215
|
+
}
|
|
216
|
+
`;wn([ln({type:Number})],nt.prototype,"splitRatio",2);wn([ln({type:Number})],nt.prototype,"minRatio",2);wn([ln({type:Number})],nt.prototype,"maxRatio",2);nt=wn([oo("resizable-divider")],nt);const Dp=5e3;function Na(e){e.style.height="auto",e.style.height=`${e.scrollHeight}px`}function Bp(e){return e?e.active?c`
|
|
217
|
+
<div class="callout info compaction-indicator compaction-indicator--active">
|
|
218
|
+
${V.loader} Compacting context...
|
|
219
|
+
</div>
|
|
220
|
+
`:e.completedAt&&Date.now()-e.completedAt<Dp?c`
|
|
221
|
+
<div class="callout success compaction-indicator compaction-indicator--complete">
|
|
222
|
+
${V.check} Context compacted
|
|
223
|
+
</div>
|
|
224
|
+
`:f:f}function Fp(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Up(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 l=o.result,r={id:Fp(),dataUrl:l,mimeType:a.type},p=t.attachments??[];t.onAttachmentsChange?.([...p,r])},o.readAsDataURL(a)}}}function Kp(e){const t=e.attachments??[];return t.length===0?f:c`
|
|
225
|
+
<div class="chat-attachments">
|
|
226
|
+
${t.map(n=>c`
|
|
227
|
+
<div class="chat-attachment">
|
|
228
|
+
<img
|
|
229
|
+
src=${n.dataUrl}
|
|
230
|
+
alt="Attachment preview"
|
|
231
|
+
class="chat-attachment__img"
|
|
232
|
+
/>
|
|
233
|
+
<button
|
|
234
|
+
class="chat-attachment__remove"
|
|
235
|
+
type="button"
|
|
236
|
+
aria-label="Remove attachment"
|
|
237
|
+
@click=${()=>{const s=(e.attachments??[]).filter(i=>i.id!==n.id);e.onAttachmentsChange?.(s)}}
|
|
238
|
+
>
|
|
239
|
+
${V.x}
|
|
240
|
+
</button>
|
|
241
|
+
</div>
|
|
242
|
+
`)}
|
|
243
|
+
</div>
|
|
244
|
+
`}function Hp(e){const t=e.connected,n=e.sending||e.stream!==null,s=!!(e.canAbort&&e.onAbort),a=e.sessions?.sessions?.find(v=>v.key===e.sessionKey)?.reasoningLevel??"off",o=e.showThinking&&a!=="off",l={name:e.assistantName,avatar:e.assistantAvatar??e.assistantAvatarUrl??null},r=(e.attachments?.length??0)>0,p=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,u=!!(e.sidebarOpen&&e.onCloseSidebar),g=c`
|
|
245
|
+
<div
|
|
246
|
+
class="chat-thread"
|
|
247
|
+
role="log"
|
|
248
|
+
aria-live="polite"
|
|
249
|
+
@scroll=${e.onChatScroll}
|
|
250
|
+
>
|
|
251
|
+
${e.loading?c`<div class="muted">Loading chat…</div>`:f}
|
|
252
|
+
${Go(jp(e),v=>v.key,v=>v.kind==="reading-indicator"?Ep(l):v.kind==="stream"?Mp(v.text,v.startedAt,e.onOpenSidebar,l):v.kind==="group"?Ip(v,{onOpenSidebar:e.onOpenSidebar,showReasoning:o,assistantName:e.assistantName,assistantAvatar:l.avatar}):f)}
|
|
253
|
+
</div>
|
|
254
|
+
`;return c`
|
|
255
|
+
<section class="card chat">
|
|
256
|
+
${e.disabledReason?c`<div class="callout">${e.disabledReason}</div>`:f}
|
|
257
|
+
|
|
258
|
+
${e.error?c`<div class="callout danger">${e.error}</div>`:f}
|
|
259
|
+
|
|
260
|
+
${Bp(e.compactionStatus)}
|
|
261
|
+
|
|
262
|
+
${e.focusMode?c`
|
|
263
|
+
<button
|
|
264
|
+
class="chat-focus-exit"
|
|
265
|
+
type="button"
|
|
266
|
+
@click=${e.onToggleFocusMode}
|
|
267
|
+
aria-label="Exit focus mode"
|
|
268
|
+
title="Exit focus mode"
|
|
269
|
+
>
|
|
270
|
+
${V.x}
|
|
271
|
+
</button>
|
|
272
|
+
`:f}
|
|
273
|
+
|
|
274
|
+
<div
|
|
275
|
+
class="chat-split-container ${u?"chat-split-container--open":""}"
|
|
276
|
+
>
|
|
277
|
+
<div
|
|
278
|
+
class="chat-main"
|
|
279
|
+
style="flex: ${u?`0 0 ${d*100}%`:"1 1 100%"}"
|
|
280
|
+
>
|
|
281
|
+
${g}
|
|
282
|
+
</div>
|
|
283
|
+
|
|
284
|
+
${u?c`
|
|
285
|
+
<resizable-divider
|
|
286
|
+
.splitRatio=${d}
|
|
287
|
+
@resize=${v=>e.onSplitRatioChange?.(v.detail.splitRatio)}
|
|
288
|
+
></resizable-divider>
|
|
289
|
+
<div class="chat-sidebar">
|
|
290
|
+
${Pp({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
|
|
291
|
+
${e.sidebarContent}
|
|
292
|
+
\`\`\``)}})}
|
|
293
|
+
</div>
|
|
294
|
+
`:f}
|
|
295
|
+
</div>
|
|
296
|
+
|
|
297
|
+
${e.queue.length?c`
|
|
298
|
+
<div class="chat-queue" role="status" aria-live="polite">
|
|
299
|
+
<div class="chat-queue__title">Queued (${e.queue.length})</div>
|
|
300
|
+
<div class="chat-queue__list">
|
|
301
|
+
${e.queue.map(v=>c`
|
|
302
|
+
<div class="chat-queue__item">
|
|
303
|
+
<div class="chat-queue__text">
|
|
304
|
+
${v.text||(v.attachments?.length?`Image (${v.attachments.length})`:"")}
|
|
305
|
+
</div>
|
|
306
|
+
<button
|
|
307
|
+
class="btn chat-queue__remove"
|
|
308
|
+
type="button"
|
|
309
|
+
aria-label="Remove queued message"
|
|
310
|
+
@click=${()=>e.onQueueRemove(v.id)}
|
|
311
|
+
>
|
|
312
|
+
${V.x}
|
|
313
|
+
</button>
|
|
314
|
+
</div>
|
|
315
|
+
`)}
|
|
316
|
+
</div>
|
|
317
|
+
</div>
|
|
318
|
+
`:f}
|
|
319
|
+
|
|
320
|
+
<div class="chat-compose">
|
|
321
|
+
${Kp(e)}
|
|
322
|
+
<div class="chat-compose__row">
|
|
323
|
+
<label class="field chat-compose__field">
|
|
324
|
+
<span>Message</span>
|
|
325
|
+
<textarea
|
|
326
|
+
${Kd(v=>v&&Na(v))}
|
|
327
|
+
.value=${e.draft}
|
|
328
|
+
?disabled=${!e.connected}
|
|
329
|
+
@keydown=${v=>{v.key==="Enter"&&(v.isComposing||v.keyCode===229||v.shiftKey||e.connected&&(v.preventDefault(),t&&e.onSend()))}}
|
|
330
|
+
@input=${v=>{const m=v.target;Na(m),e.onDraftChange(m.value)}}
|
|
331
|
+
@paste=${v=>Up(v,e)}
|
|
332
|
+
placeholder=${p}
|
|
333
|
+
></textarea>
|
|
334
|
+
</label>
|
|
335
|
+
<div class="chat-compose__actions">
|
|
336
|
+
<button
|
|
337
|
+
class="btn"
|
|
338
|
+
?disabled=${!e.connected||!s&&e.sending}
|
|
339
|
+
@click=${s?e.onAbort:e.onNewSession}
|
|
340
|
+
>
|
|
341
|
+
${s?"Stop":"New session"}
|
|
342
|
+
</button>
|
|
343
|
+
<button
|
|
344
|
+
class="btn primary"
|
|
345
|
+
?disabled=${!e.connected}
|
|
346
|
+
@click=${e.onSend}
|
|
347
|
+
>
|
|
348
|
+
${n?"Queue":"Send"}<kbd class="btn-kbd">↵</kbd>
|
|
349
|
+
</button>
|
|
350
|
+
</div>
|
|
351
|
+
</div>
|
|
352
|
+
</div>
|
|
353
|
+
</section>
|
|
354
|
+
`}const Oa=200;function zp(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=Yo(s.message),a=ii(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 jp(e){const t=[],n=Array.isArray(e.messages)?e.messages:[],s=Array.isArray(e.toolMessages)?e.toolMessages:[],i=Math.max(0,n.length-Oa);i>0&&t.push({kind:"message",key:"chat:history:notice",message:{role:"system",content:`Showing last ${Oa} messages (${i} hidden).`,timestamp:Date.now()}});for(let a=i;a<n.length;a++){const o=n[a],l=Yo(o);!e.showThinking&&l.role.toLowerCase()==="toolresult"||t.push({kind:"message",key:Da(o,a),message:o})}if(e.showThinking)for(let a=0;a<s.length;a++)t.push({kind:"message",key:Da(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 zp(t)}function Da(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,l=typeof n.role=="string"?n.role:"unknown";return o!=null?`msg:${l}:${o}:${t}`:`msg:${l}:${t}`}function ue(e){if(e)return Array.isArray(e.type)?e.type.filter(n=>n!=="null")[0]??e.type[0]:e.type}function vr(e){if(!e)return"";if(e.default!==void 0)return e.default;switch(ue(e)){case"object":return{};case"array":return[];case"boolean":return!1;case"number":case"integer":return 0;case"string":return"";default:return""}}function $n(e){return e.filter(t=>typeof t=="string").join(".")}function te(e,t){const n=$n(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 l=a.split(".");if(l.length!==i.length)continue;let r=!0;for(let p=0;p<i.length;p+=1)if(l[p]!=="*"&&l[p]!==i[p]){r=!1;break}if(r)return o}}function we(e){return e.replace(/_/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/\s+/g," ").replace(/^./,t=>t.toUpperCase())}function qp(e){const t=$n(e).toLowerCase();return t.includes("token")||t.includes("password")||t.includes("secret")||t.includes("apikey")||t.endsWith("key")}const Wp=new Set(["title","description","default","nullable"]);function Vp(e){return Object.keys(e??{}).filter(n=>!Wp.has(n)).length===0}function Gp(e){if(e===void 0)return"";try{return JSON.stringify(e,null,2)??""}catch{return""}}const Tt={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 be(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:l}=e,r=e.showLabel??!0,p=ue(t),d=te(s,i),u=d?.label??t.title??we(String(s.at(-1))),g=d?.help??t.description,v=$n(s);if(a.has(v))return c`<div class="cfg-field cfg-field--error">
|
|
355
|
+
<div class="cfg-field__label">${u}</div>
|
|
356
|
+
<div class="cfg-field__error">Unsupported schema node. Use Raw mode.</div>
|
|
357
|
+
</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 be({...e,schema:$[0]});const A=C=>{if(C.const!==void 0)return C.const;if(C.enum&&C.enum.length===1)return C.enum[0]},_=$.map(A),I=_.every(C=>C!==void 0);if(I&&_.length>0&&_.length<=5){const C=n??t.default;return c`
|
|
358
|
+
<div class="cfg-field">
|
|
359
|
+
${r?c`<label class="cfg-field__label">${u}</label>`:f}
|
|
360
|
+
${g?c`<div class="cfg-field__help">${g}</div>`:f}
|
|
361
|
+
<div class="cfg-segmented">
|
|
362
|
+
${_.map((E,pe)=>c`
|
|
363
|
+
<button
|
|
364
|
+
type="button"
|
|
365
|
+
class="cfg-segmented__btn ${E===C||String(E)===String(C)?"active":""}"
|
|
366
|
+
?disabled=${o}
|
|
367
|
+
@click=${()=>l(s,E)}
|
|
368
|
+
>
|
|
369
|
+
${String(E)}
|
|
370
|
+
</button>
|
|
371
|
+
`)}
|
|
372
|
+
</div>
|
|
373
|
+
</div>
|
|
374
|
+
`}if(I&&_.length>5)return Fa({...e,options:_,value:n??t.default});const P=new Set($.map(C=>ue(C)).filter(Boolean)),M=new Set([...P].map(C=>C==="integer"?"number":C));if([...M].every(C=>["string","number","boolean"].includes(C))){const C=M.has("string"),E=M.has("number");if(M.has("boolean")&&M.size===1)return be({...e,schema:{...t,type:"boolean",anyOf:void 0,oneOf:void 0}});if(C||E)return Ba({...e,inputType:E&&!C?"number":"text"})}}if(t.enum){const m=t.enum;if(m.length<=5){const $=n??t.default;return c`
|
|
375
|
+
<div class="cfg-field">
|
|
376
|
+
${r?c`<label class="cfg-field__label">${u}</label>`:f}
|
|
377
|
+
${g?c`<div class="cfg-field__help">${g}</div>`:f}
|
|
378
|
+
<div class="cfg-segmented">
|
|
379
|
+
${m.map(A=>c`
|
|
380
|
+
<button
|
|
381
|
+
type="button"
|
|
382
|
+
class="cfg-segmented__btn ${A===$||String(A)===String($)?"active":""}"
|
|
383
|
+
?disabled=${o}
|
|
384
|
+
@click=${()=>l(s,A)}
|
|
385
|
+
>
|
|
386
|
+
${String(A)}
|
|
387
|
+
</button>
|
|
388
|
+
`)}
|
|
389
|
+
</div>
|
|
390
|
+
</div>
|
|
391
|
+
`}return Fa({...e,options:m,value:n??t.default})}if(p==="object")return Qp(e);if(p==="array")return Zp(e);if(p==="boolean"){const m=typeof n=="boolean"?n:typeof t.default=="boolean"?t.default:!1;return c`
|
|
392
|
+
<label class="cfg-toggle-row ${o?"disabled":""}">
|
|
393
|
+
<div class="cfg-toggle-row__content">
|
|
394
|
+
<span class="cfg-toggle-row__label">${u}</span>
|
|
395
|
+
${g?c`<span class="cfg-toggle-row__help">${g}</span>`:f}
|
|
396
|
+
</div>
|
|
397
|
+
<div class="cfg-toggle">
|
|
398
|
+
<input
|
|
399
|
+
type="checkbox"
|
|
400
|
+
.checked=${m}
|
|
401
|
+
?disabled=${o}
|
|
402
|
+
@change=${$=>l(s,$.target.checked)}
|
|
403
|
+
/>
|
|
404
|
+
<span class="cfg-toggle__track"></span>
|
|
405
|
+
</div>
|
|
406
|
+
</label>
|
|
407
|
+
`}return p==="number"||p==="integer"?Yp(e):p==="string"?Ba({...e,inputType:"text"}):c`
|
|
408
|
+
<div class="cfg-field cfg-field--error">
|
|
409
|
+
<div class="cfg-field__label">${u}</div>
|
|
410
|
+
<div class="cfg-field__error">Unsupported type: ${p}. Use Raw mode.</div>
|
|
411
|
+
</div>
|
|
412
|
+
`}function Ba(e){const{schema:t,value:n,path:s,hints:i,disabled:a,onPatch:o,inputType:l}=e,r=e.showLabel??!0,p=te(s,i),d=p?.label??t.title??we(String(s.at(-1))),u=p?.help??t.description,g=p?.sensitive??qp(s),v=p?.placeholder??(g?"••••":t.default!==void 0?`Default: ${t.default}`:""),m=n??"";return c`
|
|
413
|
+
<div class="cfg-field">
|
|
414
|
+
${r?c`<label class="cfg-field__label">${d}</label>`:f}
|
|
415
|
+
${u?c`<div class="cfg-field__help">${u}</div>`:f}
|
|
416
|
+
<div class="cfg-input-wrap">
|
|
417
|
+
<input
|
|
418
|
+
type=${g?"password":l}
|
|
419
|
+
class="cfg-input"
|
|
420
|
+
placeholder=${v}
|
|
421
|
+
.value=${m==null?"":String(m)}
|
|
422
|
+
?disabled=${a}
|
|
423
|
+
@input=${$=>{const A=$.target.value;if(l==="number"){if(A.trim()===""){o(s,void 0);return}const _=Number(A);o(s,Number.isNaN(_)?A:_);return}o(s,A)}}
|
|
424
|
+
/>
|
|
425
|
+
${t.default!==void 0?c`
|
|
426
|
+
<button
|
|
427
|
+
type="button"
|
|
428
|
+
class="cfg-input__reset"
|
|
429
|
+
title="Reset to default"
|
|
430
|
+
?disabled=${a}
|
|
431
|
+
@click=${()=>o(s,t.default)}
|
|
432
|
+
>↺</button>
|
|
433
|
+
`:f}
|
|
434
|
+
</div>
|
|
435
|
+
</div>
|
|
436
|
+
`}function Yp(e){const{schema:t,value:n,path:s,hints:i,disabled:a,onPatch:o}=e,l=e.showLabel??!0,r=te(s,i),p=r?.label??t.title??we(String(s.at(-1))),d=r?.help??t.description,u=n??t.default??"",g=typeof u=="number"?u:0;return c`
|
|
437
|
+
<div class="cfg-field">
|
|
438
|
+
${l?c`<label class="cfg-field__label">${p}</label>`:f}
|
|
439
|
+
${d?c`<div class="cfg-field__help">${d}</div>`:f}
|
|
440
|
+
<div class="cfg-number">
|
|
441
|
+
<button
|
|
442
|
+
type="button"
|
|
443
|
+
class="cfg-number__btn"
|
|
444
|
+
?disabled=${a}
|
|
445
|
+
@click=${()=>o(s,g-1)}
|
|
446
|
+
>−</button>
|
|
447
|
+
<input
|
|
448
|
+
type="number"
|
|
449
|
+
class="cfg-number__input"
|
|
450
|
+
.value=${u==null?"":String(u)}
|
|
451
|
+
?disabled=${a}
|
|
452
|
+
@input=${v=>{const m=v.target.value,$=m===""?void 0:Number(m);o(s,$)}}
|
|
453
|
+
/>
|
|
454
|
+
<button
|
|
455
|
+
type="button"
|
|
456
|
+
class="cfg-number__btn"
|
|
457
|
+
?disabled=${a}
|
|
458
|
+
@click=${()=>o(s,g+1)}
|
|
459
|
+
>+</button>
|
|
460
|
+
</div>
|
|
461
|
+
</div>
|
|
462
|
+
`}function Fa(e){const{schema:t,value:n,path:s,hints:i,disabled:a,options:o,onPatch:l}=e,r=e.showLabel??!0,p=te(s,i),d=p?.label??t.title??we(String(s.at(-1))),u=p?.help??t.description,g=n??t.default,v=o.findIndex($=>$===g||String($)===String(g)),m="__unset__";return c`
|
|
463
|
+
<div class="cfg-field">
|
|
464
|
+
${r?c`<label class="cfg-field__label">${d}</label>`:f}
|
|
465
|
+
${u?c`<div class="cfg-field__help">${u}</div>`:f}
|
|
466
|
+
<select
|
|
467
|
+
class="cfg-select"
|
|
468
|
+
?disabled=${a}
|
|
469
|
+
.value=${v>=0?String(v):m}
|
|
470
|
+
@change=${$=>{const A=$.target.value;l(s,A===m?void 0:o[Number(A)])}}
|
|
471
|
+
>
|
|
472
|
+
<option value=${m}>Select...</option>
|
|
473
|
+
${o.map(($,A)=>c`
|
|
474
|
+
<option value=${String(A)}>${String($)}</option>
|
|
475
|
+
`)}
|
|
476
|
+
</select>
|
|
477
|
+
</div>
|
|
478
|
+
`}function Qp(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:l}=e;e.showLabel;const r=te(s,i),p=r?.label??t.title??we(String(s.at(-1))),d=r?.help??t.description,u=n??t.default,g=u&&typeof u=="object"&&!Array.isArray(u)?u:{},v=t.properties??{},$=Object.entries(v).sort((P,M)=>{const C=te([...s,P[0]],i)?.order??0,E=te([...s,M[0]],i)?.order??0;return C!==E?C-E:P[0].localeCompare(M[0])}),A=new Set(Object.keys(v)),_=t.additionalProperties,I=!!_&&typeof _=="object";return s.length===1?c`
|
|
479
|
+
<div class="cfg-fields">
|
|
480
|
+
${$.map(([P,M])=>be({schema:M,value:g[P],path:[...s,P],hints:i,unsupported:a,disabled:o,onPatch:l}))}
|
|
481
|
+
${I?Ua({schema:_,value:g,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:A,onPatch:l}):f}
|
|
482
|
+
</div>
|
|
483
|
+
`:c`
|
|
484
|
+
<details class="cfg-object" open>
|
|
485
|
+
<summary class="cfg-object__header">
|
|
486
|
+
<span class="cfg-object__title">${p}</span>
|
|
487
|
+
<span class="cfg-object__chevron">${Tt.chevronDown}</span>
|
|
488
|
+
</summary>
|
|
489
|
+
${d?c`<div class="cfg-object__help">${d}</div>`:f}
|
|
490
|
+
<div class="cfg-object__content">
|
|
491
|
+
${$.map(([P,M])=>be({schema:M,value:g[P],path:[...s,P],hints:i,unsupported:a,disabled:o,onPatch:l}))}
|
|
492
|
+
${I?Ua({schema:_,value:g,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:A,onPatch:l}):f}
|
|
493
|
+
</div>
|
|
494
|
+
</details>
|
|
495
|
+
`}function Zp(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:l}=e,r=e.showLabel??!0,p=te(s,i),d=p?.label??t.title??we(String(s.at(-1))),u=p?.help??t.description,g=Array.isArray(t.items)?t.items[0]:t.items;if(!g)return c`
|
|
496
|
+
<div class="cfg-field cfg-field--error">
|
|
497
|
+
<div class="cfg-field__label">${d}</div>
|
|
498
|
+
<div class="cfg-field__error">Unsupported array schema. Use Raw mode.</div>
|
|
499
|
+
</div>
|
|
500
|
+
`;const v=Array.isArray(n)?n:Array.isArray(t.default)?t.default:[];return c`
|
|
501
|
+
<div class="cfg-array">
|
|
502
|
+
<div class="cfg-array__header">
|
|
503
|
+
${r?c`<span class="cfg-array__label">${d}</span>`:f}
|
|
504
|
+
<span class="cfg-array__count">${v.length} item${v.length!==1?"s":""}</span>
|
|
505
|
+
<button
|
|
506
|
+
type="button"
|
|
507
|
+
class="cfg-array__add"
|
|
508
|
+
?disabled=${o}
|
|
509
|
+
@click=${()=>{const m=[...v,vr(g)];l(s,m)}}
|
|
510
|
+
>
|
|
511
|
+
<span class="cfg-array__add-icon">${Tt.plus}</span>
|
|
512
|
+
Add
|
|
513
|
+
</button>
|
|
514
|
+
</div>
|
|
515
|
+
${u?c`<div class="cfg-array__help">${u}</div>`:f}
|
|
516
|
+
|
|
517
|
+
${v.length===0?c`
|
|
518
|
+
<div class="cfg-array__empty">
|
|
519
|
+
No items yet. Click "Add" to create one.
|
|
520
|
+
</div>
|
|
521
|
+
`:c`
|
|
522
|
+
<div class="cfg-array__items">
|
|
523
|
+
${v.map((m,$)=>c`
|
|
524
|
+
<div class="cfg-array__item">
|
|
525
|
+
<div class="cfg-array__item-header">
|
|
526
|
+
<span class="cfg-array__item-index">#${$+1}</span>
|
|
527
|
+
<button
|
|
528
|
+
type="button"
|
|
529
|
+
class="cfg-array__item-remove"
|
|
530
|
+
title="Remove item"
|
|
531
|
+
?disabled=${o}
|
|
532
|
+
@click=${()=>{const A=[...v];A.splice($,1),l(s,A)}}
|
|
533
|
+
>
|
|
534
|
+
${Tt.trash}
|
|
535
|
+
</button>
|
|
536
|
+
</div>
|
|
537
|
+
<div class="cfg-array__item-content">
|
|
538
|
+
${be({schema:g,value:m,path:[...s,$],hints:i,unsupported:a,disabled:o,showLabel:!1,onPatch:l})}
|
|
539
|
+
</div>
|
|
540
|
+
</div>
|
|
541
|
+
`)}
|
|
542
|
+
</div>
|
|
543
|
+
`}
|
|
544
|
+
</div>
|
|
545
|
+
`}function Ua(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:l,onPatch:r}=e,p=Vp(t),d=Object.entries(n??{}).filter(([u])=>!l.has(u));return c`
|
|
546
|
+
<div class="cfg-map">
|
|
547
|
+
<div class="cfg-map__header">
|
|
548
|
+
<span class="cfg-map__label">Custom entries</span>
|
|
549
|
+
<button
|
|
550
|
+
type="button"
|
|
551
|
+
class="cfg-map__add"
|
|
552
|
+
?disabled=${o}
|
|
553
|
+
@click=${()=>{const u={...n??{}};let g=1,v=`custom-${g}`;for(;v in u;)g+=1,v=`custom-${g}`;u[v]=p?{}:vr(t),r(s,u)}}
|
|
554
|
+
>
|
|
555
|
+
<span class="cfg-map__add-icon">${Tt.plus}</span>
|
|
556
|
+
Add Entry
|
|
557
|
+
</button>
|
|
558
|
+
</div>
|
|
559
|
+
|
|
560
|
+
${d.length===0?c`
|
|
561
|
+
<div class="cfg-map__empty">No custom entries.</div>
|
|
562
|
+
`:c`
|
|
563
|
+
<div class="cfg-map__items">
|
|
564
|
+
${d.map(([u,g])=>{const v=[...s,u],m=Gp(g);return c`
|
|
565
|
+
<div class="cfg-map__item">
|
|
566
|
+
<div class="cfg-map__item-key">
|
|
567
|
+
<input
|
|
568
|
+
type="text"
|
|
569
|
+
class="cfg-input cfg-input--sm"
|
|
570
|
+
placeholder="Key"
|
|
571
|
+
.value=${u}
|
|
572
|
+
?disabled=${o}
|
|
573
|
+
@change=${$=>{const A=$.target.value.trim();if(!A||A===u)return;const _={...n??{}};A in _||(_[A]=_[u],delete _[u],r(s,_))}}
|
|
574
|
+
/>
|
|
575
|
+
</div>
|
|
576
|
+
<div class="cfg-map__item-value">
|
|
577
|
+
${p?c`
|
|
578
|
+
<textarea
|
|
579
|
+
class="cfg-textarea cfg-textarea--sm"
|
|
580
|
+
placeholder="JSON value"
|
|
581
|
+
rows="2"
|
|
582
|
+
.value=${m}
|
|
583
|
+
?disabled=${o}
|
|
584
|
+
@change=${$=>{const A=$.target,_=A.value.trim();if(!_){r(v,void 0);return}try{r(v,JSON.parse(_))}catch{A.value=m}}}
|
|
585
|
+
></textarea>
|
|
586
|
+
`:be({schema:t,value:g,path:v,hints:i,unsupported:a,disabled:o,showLabel:!1,onPatch:r})}
|
|
587
|
+
</div>
|
|
588
|
+
<button
|
|
589
|
+
type="button"
|
|
590
|
+
class="cfg-map__item-remove"
|
|
591
|
+
title="Remove entry"
|
|
592
|
+
?disabled=${o}
|
|
593
|
+
@click=${()=>{const $={...n??{}};delete $[u],r(s,$)}}
|
|
594
|
+
>
|
|
595
|
+
${Tt.trash}
|
|
596
|
+
</button>
|
|
597
|
+
</div>
|
|
598
|
+
`})}
|
|
599
|
+
</div>
|
|
600
|
+
`}
|
|
601
|
+
</div>
|
|
602
|
+
`}const Ka={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>`},gi={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 Ha(e){return Ka[e]??Ka.default}function Jp(e,t,n){if(!n)return!0;const s=n.toLowerCase(),i=gi[e];return e.toLowerCase().includes(s)||i&&(i.label.toLowerCase().includes(s)||i.description.toLowerCase().includes(s))?!0:mt(t,s)}function mt(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)||mt(i,t))return!0}if(e.items){const s=Array.isArray(e.items)?e.items:[e.items];for(const i of s)if(i&&mt(i,t))return!0}if(e.additionalProperties&&typeof e.additionalProperties=="object"&&mt(e.additionalProperties,t))return!0;const n=e.anyOf??e.oneOf??e.allOf;if(n){for(const s of n)if(s&&mt(s,t))return!0}return!1}function Xp(e){if(!e.schema)return c`<div class="muted">Schema unavailable.</div>`;const t=e.schema,n=e.value??{};if(ue(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,l=e.activeSubsection??null,p=Object.entries(i).sort((u,g)=>{const v=te([u[0]],e.uiHints)?.order??50,m=te([g[0]],e.uiHints)?.order??50;return v!==m?v-m:u[0].localeCompare(g[0])}).filter(([u,g])=>!(o&&u!==o||a&&!Jp(u,g,a)));let d=null;if(o&&l&&p.length===1){const u=p[0]?.[1];u&&ue(u)==="object"&&u.properties&&u.properties[l]&&(d={sectionKey:o,subsectionKey:l,schema:u.properties[l]})}return p.length===0?c`
|
|
603
|
+
<div class="config-empty">
|
|
604
|
+
<div class="config-empty__icon">${V.search}</div>
|
|
605
|
+
<div class="config-empty__text">
|
|
606
|
+
${a?`No settings match "${a}"`:"No settings in this section"}
|
|
607
|
+
</div>
|
|
608
|
+
</div>
|
|
609
|
+
`:c`
|
|
610
|
+
<div class="config-form config-form--modern">
|
|
611
|
+
${d?(()=>{const{sectionKey:u,subsectionKey:g,schema:v}=d,m=te([u,g],e.uiHints),$=m?.label??v.title??we(g),A=m?.help??v.description??"",_=n[u],I=_&&typeof _=="object"?_[g]:void 0,P=`config-section-${u}-${g}`;return c`
|
|
612
|
+
<section class="config-section-card" id=${P}>
|
|
613
|
+
<div class="config-section-card__header">
|
|
614
|
+
<span class="config-section-card__icon">${Ha(u)}</span>
|
|
615
|
+
<div class="config-section-card__titles">
|
|
616
|
+
<h3 class="config-section-card__title">${$}</h3>
|
|
617
|
+
${A?c`<p class="config-section-card__desc">${A}</p>`:f}
|
|
618
|
+
</div>
|
|
619
|
+
</div>
|
|
620
|
+
<div class="config-section-card__content">
|
|
621
|
+
${be({schema:v,value:I,path:[u,g],hints:e.uiHints,unsupported:s,disabled:e.disabled??!1,showLabel:!1,onPatch:e.onPatch})}
|
|
622
|
+
</div>
|
|
623
|
+
</section>
|
|
624
|
+
`})():p.map(([u,g])=>{const v=gi[u]??{label:u.charAt(0).toUpperCase()+u.slice(1),description:g.description??""};return c`
|
|
625
|
+
<section class="config-section-card" id="config-section-${u}">
|
|
626
|
+
<div class="config-section-card__header">
|
|
627
|
+
<span class="config-section-card__icon">${Ha(u)}</span>
|
|
628
|
+
<div class="config-section-card__titles">
|
|
629
|
+
<h3 class="config-section-card__title">${v.label}</h3>
|
|
630
|
+
${v.description?c`<p class="config-section-card__desc">${v.description}</p>`:f}
|
|
631
|
+
</div>
|
|
632
|
+
</div>
|
|
633
|
+
<div class="config-section-card__content">
|
|
634
|
+
${be({schema:g,value:n[u],path:[u],hints:e.uiHints,unsupported:s,disabled:e.disabled??!1,showLabel:!1,onPatch:e.onPatch})}
|
|
635
|
+
</div>
|
|
636
|
+
</section>
|
|
637
|
+
`})}
|
|
638
|
+
</div>
|
|
639
|
+
`}const eh=new Set(["title","description","default","nullable"]);function th(e){return Object.keys(e??{}).filter(n=>!eh.has(n)).length===0}function mr(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 yr(e){return!e||typeof e!="object"?{schema:null,unsupportedPaths:["<root>"]}:$t(e,[])}function $t(e,t){const n=new Set,s={...e},i=$n(t)||"<root>";if(e.anyOf||e.oneOf||e.allOf){const l=nh(e,t);return l||{schema:e,unsupportedPaths:[i]}}const a=Array.isArray(e.type)&&e.type.includes("null"),o=ue(e)??(e.properties||e.additionalProperties?"object":void 0);if(s.type=o??e.type,s.nullable=a||e.nullable,s.enum){const{enumValues:l,nullable:r}=mr(s.enum);s.enum=l,r&&(s.nullable=!0),l.length===0&&n.add(i)}if(o==="object"){const l=e.properties??{},r={};for(const[p,d]of Object.entries(l)){const u=$t(d,[...t,p]);u.schema&&(r[p]=u.schema);for(const g of u.unsupportedPaths)n.add(g)}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"&&!th(e.additionalProperties)){const p=$t(e.additionalProperties,[...t,"*"]);s.additionalProperties=p.schema??e.additionalProperties,p.unsupportedPaths.length>0&&n.add(i)}}else if(o==="array"){const l=Array.isArray(e.items)?e.items[0]:e.items;if(!l)n.add(i);else{const r=$t(l,[...t,"*"]);s.items=r.schema??l,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 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 l of n){if(!l||typeof l!="object")return null;if(Array.isArray(l.enum)){const{enumValues:r,nullable:p}=mr(l.enum);s.push(...r),p&&(a=!0);continue}if("const"in l){if(l.const==null){a=!0;continue}s.push(l.const);continue}if(ue(l)==="null"){a=!0;continue}i.push(l)}if(s.length>0&&i.length===0){const l=[];for(const r of s)l.some(p=>Object.is(p,r))||l.push(r);return{schema:{...e,enum:l,nullable:a,anyOf:void 0,oneOf:void 0,allOf:void 0},unsupportedPaths:[]}}if(i.length===1){const l=$t(i[0],t);return l.schema&&(l.schema.nullable=a||l.schema.nullable),l}const o=["string","number","integer","boolean"];return i.length>0&&s.length===0&&i.every(l=>l.type&&o.includes(String(l.type)))?{schema:{...e,nullable:a},unsupportedPaths:[]}:null}const Cs={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>`},za=[{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"}],ja="__all__";function qa(e){return Cs[e]??Cs.default}function sh(e,t){const n=gi[e];return n||{label:t?.title??we(e),description:t?.description??""}}function ih(e){const{key:t,schema:n,uiHints:s}=e;if(!n||ue(n)!=="object"||!n.properties)return[];const i=Object.entries(n.properties).map(([a,o])=>{const l=te([t,a],s),r=l?.label??o.title??we(a),p=l?.help??o.description??"",d=l?.order??50;return{key:a,label:r,description:p,order:d}});return i.sort((a,o)=>a.order!==o.order?a.order-o.order:a.key.localeCompare(o.key)),i}function ah(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 l=i,r=a,p=new Set([...Object.keys(l),...Object.keys(r)]);for(const d of p)s(l[d],r[d],o?`${o}.${d}`:d)}return s(e,t,""),n}function Wa(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 oh(e){const t=e.valid==null?"unknown":e.valid?"valid":"invalid",n=yr(e.schema),s=n.schema?n.unsupportedPaths.length>0:!1,i=n.schema?.properties??{},a=za.filter(E=>E.key in i),o=new Set(za.map(E=>E.key)),l=Object.keys(i).filter(E=>!o.has(E)).map(E=>({key:E,label:E.charAt(0).toUpperCase()+E.slice(1)})),r=[...a,...l],p=e.activeSection&&n.schema&&ue(n.schema)==="object"?n.schema.properties?.[e.activeSection]:void 0,d=e.activeSection?sh(e.activeSection,p):null,u=e.activeSection?ih({key:e.activeSection,schema:p,uiHints:e.uiHints}):[],g=e.formMode==="form"&&!!e.activeSection&&u.length>0,v=e.activeSubsection===ja,m=e.searchQuery||v?null:e.activeSubsection??u[0]?.key??null,$=e.formMode==="form"?ah(e.originalValue,e.formValue):[],A=e.formMode==="raw"&&e.raw!==e.originalRaw,_=e.formMode==="form"?$.length>0:A,I=!!e.formValue&&!e.loading&&!!n.schema,P=e.connected&&!e.saving&&_&&(e.formMode==="raw"?!0:I),M=e.connected&&!e.applying&&!e.updating&&_&&(e.formMode==="raw"?!0:I),C=e.connected&&!e.applying&&!e.updating;return c`
|
|
640
|
+
<div class="config-layout">
|
|
641
|
+
<!-- Sidebar -->
|
|
642
|
+
<aside class="config-sidebar">
|
|
643
|
+
<div class="config-sidebar__header">
|
|
644
|
+
<div class="config-sidebar__title">Settings</div>
|
|
645
|
+
<span class="pill pill--sm ${t==="valid"?"pill--ok":t==="invalid"?"pill--danger":""}">${t}</span>
|
|
646
|
+
</div>
|
|
647
|
+
|
|
648
|
+
<!-- Search -->
|
|
649
|
+
<div class="config-search">
|
|
650
|
+
<svg class="config-search__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
651
|
+
<circle cx="11" cy="11" r="8"></circle>
|
|
652
|
+
<path d="M21 21l-4.35-4.35"></path>
|
|
653
|
+
</svg>
|
|
654
|
+
<input
|
|
655
|
+
type="text"
|
|
656
|
+
class="config-search__input"
|
|
657
|
+
placeholder="Search settings..."
|
|
658
|
+
.value=${e.searchQuery}
|
|
659
|
+
@input=${E=>e.onSearchChange(E.target.value)}
|
|
660
|
+
/>
|
|
661
|
+
${e.searchQuery?c`
|
|
662
|
+
<button
|
|
663
|
+
class="config-search__clear"
|
|
664
|
+
@click=${()=>e.onSearchChange("")}
|
|
665
|
+
>×</button>
|
|
666
|
+
`:f}
|
|
667
|
+
</div>
|
|
668
|
+
|
|
669
|
+
<!-- Section nav -->
|
|
670
|
+
<nav class="config-nav">
|
|
671
|
+
<button
|
|
672
|
+
class="config-nav__item ${e.activeSection===null?"active":""}"
|
|
673
|
+
@click=${()=>e.onSectionChange(null)}
|
|
674
|
+
>
|
|
675
|
+
<span class="config-nav__icon">${Cs.all}</span>
|
|
676
|
+
<span class="config-nav__label">All Settings</span>
|
|
677
|
+
</button>
|
|
678
|
+
${r.map(E=>c`
|
|
679
|
+
<button
|
|
680
|
+
class="config-nav__item ${e.activeSection===E.key?"active":""}"
|
|
681
|
+
@click=${()=>e.onSectionChange(E.key)}
|
|
682
|
+
>
|
|
683
|
+
<span class="config-nav__icon">${qa(E.key)}</span>
|
|
684
|
+
<span class="config-nav__label">${E.label}</span>
|
|
685
|
+
</button>
|
|
686
|
+
`)}
|
|
687
|
+
</nav>
|
|
688
|
+
|
|
689
|
+
<!-- Mode toggle at bottom -->
|
|
690
|
+
<div class="config-sidebar__footer">
|
|
691
|
+
<div class="config-mode-toggle">
|
|
692
|
+
<button
|
|
693
|
+
class="config-mode-toggle__btn ${e.formMode==="form"?"active":""}"
|
|
694
|
+
?disabled=${e.schemaLoading||!e.schema}
|
|
695
|
+
@click=${()=>e.onFormModeChange("form")}
|
|
696
|
+
>
|
|
697
|
+
Form
|
|
698
|
+
</button>
|
|
699
|
+
<button
|
|
700
|
+
class="config-mode-toggle__btn ${e.formMode==="raw"?"active":""}"
|
|
701
|
+
@click=${()=>e.onFormModeChange("raw")}
|
|
702
|
+
>
|
|
703
|
+
Raw
|
|
704
|
+
</button>
|
|
705
|
+
</div>
|
|
706
|
+
</div>
|
|
707
|
+
</aside>
|
|
708
|
+
|
|
709
|
+
<!-- Main content -->
|
|
710
|
+
<main class="config-main">
|
|
711
|
+
<!-- Action bar -->
|
|
712
|
+
<div class="config-actions">
|
|
713
|
+
<div class="config-actions__left">
|
|
714
|
+
${_?c`
|
|
715
|
+
<span class="config-changes-badge">${e.formMode==="raw"?"Unsaved changes":`${$.length} unsaved change${$.length!==1?"s":""}`}</span>
|
|
716
|
+
`:c`
|
|
717
|
+
<span class="config-status muted">No changes</span>
|
|
718
|
+
`}
|
|
719
|
+
</div>
|
|
720
|
+
<div class="config-actions__right">
|
|
721
|
+
<button class="btn btn--sm" ?disabled=${e.loading} @click=${e.onReload}>
|
|
722
|
+
${e.loading?"Loading…":"Reload"}
|
|
723
|
+
</button>
|
|
724
|
+
<button
|
|
725
|
+
class="btn btn--sm primary"
|
|
726
|
+
?disabled=${!P}
|
|
727
|
+
@click=${e.onSave}
|
|
728
|
+
>
|
|
729
|
+
${e.saving?"Saving…":"Save"}
|
|
730
|
+
</button>
|
|
731
|
+
<button
|
|
732
|
+
class="btn btn--sm"
|
|
733
|
+
?disabled=${!M}
|
|
734
|
+
@click=${e.onApply}
|
|
735
|
+
>
|
|
736
|
+
${e.applying?"Applying…":"Apply"}
|
|
737
|
+
</button>
|
|
738
|
+
<button
|
|
739
|
+
class="btn btn--sm"
|
|
740
|
+
?disabled=${!C}
|
|
741
|
+
@click=${e.onUpdate}
|
|
742
|
+
>
|
|
743
|
+
${e.updating?"Updating…":"Update"}
|
|
744
|
+
</button>
|
|
745
|
+
</div>
|
|
746
|
+
</div>
|
|
747
|
+
|
|
748
|
+
<!-- Diff panel (form mode only - raw mode doesn't have granular diff) -->
|
|
749
|
+
${_&&e.formMode==="form"?c`
|
|
750
|
+
<details class="config-diff">
|
|
751
|
+
<summary class="config-diff__summary">
|
|
752
|
+
<span>View ${$.length} pending change${$.length!==1?"s":""}</span>
|
|
753
|
+
<svg class="config-diff__chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
754
|
+
<polyline points="6 9 12 15 18 9"></polyline>
|
|
755
|
+
</svg>
|
|
756
|
+
</summary>
|
|
757
|
+
<div class="config-diff__content">
|
|
758
|
+
${$.map(E=>c`
|
|
759
|
+
<div class="config-diff__item">
|
|
760
|
+
<div class="config-diff__path">${E.path}</div>
|
|
761
|
+
<div class="config-diff__values">
|
|
762
|
+
<span class="config-diff__from">${Wa(E.from)}</span>
|
|
763
|
+
<span class="config-diff__arrow">→</span>
|
|
764
|
+
<span class="config-diff__to">${Wa(E.to)}</span>
|
|
765
|
+
</div>
|
|
766
|
+
</div>
|
|
767
|
+
`)}
|
|
768
|
+
</div>
|
|
769
|
+
</details>
|
|
770
|
+
`:f}
|
|
771
|
+
|
|
772
|
+
${d&&e.formMode==="form"?c`
|
|
773
|
+
<div class="config-section-hero">
|
|
774
|
+
<div class="config-section-hero__icon">${qa(e.activeSection??"")}</div>
|
|
775
|
+
<div class="config-section-hero__text">
|
|
776
|
+
<div class="config-section-hero__title">${d.label}</div>
|
|
777
|
+
${d.description?c`<div class="config-section-hero__desc">${d.description}</div>`:f}
|
|
778
|
+
</div>
|
|
779
|
+
</div>
|
|
780
|
+
`:f}
|
|
781
|
+
|
|
782
|
+
${g?c`
|
|
783
|
+
<div class="config-subnav">
|
|
784
|
+
<button
|
|
785
|
+
class="config-subnav__item ${m===null?"active":""}"
|
|
786
|
+
@click=${()=>e.onSubsectionChange(ja)}
|
|
787
|
+
>
|
|
788
|
+
All
|
|
789
|
+
</button>
|
|
790
|
+
${u.map(E=>c`
|
|
791
|
+
<button
|
|
792
|
+
class="config-subnav__item ${m===E.key?"active":""}"
|
|
793
|
+
title=${E.description||E.label}
|
|
794
|
+
@click=${()=>e.onSubsectionChange(E.key)}
|
|
795
|
+
>
|
|
796
|
+
${E.label}
|
|
797
|
+
</button>
|
|
798
|
+
`)}
|
|
799
|
+
</div>
|
|
800
|
+
`:f}
|
|
801
|
+
|
|
802
|
+
<!-- Form content -->
|
|
803
|
+
<div class="config-content">
|
|
804
|
+
${e.formMode==="form"?c`
|
|
805
|
+
${e.schemaLoading?c`<div class="config-loading">
|
|
806
|
+
<div class="config-loading__spinner"></div>
|
|
807
|
+
<span>Loading schema…</span>
|
|
808
|
+
</div>`:Xp({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:m})}
|
|
809
|
+
${s?c`<div class="callout danger" style="margin-top: 12px;">
|
|
810
|
+
Form view can't safely edit some fields.
|
|
811
|
+
Use Raw to avoid losing config entries.
|
|
812
|
+
</div>`:f}
|
|
813
|
+
`:c`
|
|
814
|
+
<label class="field config-raw-field">
|
|
815
|
+
<span>Raw JSON5</span>
|
|
816
|
+
<textarea
|
|
817
|
+
.value=${e.raw}
|
|
818
|
+
@input=${E=>e.onRawChange(E.target.value)}
|
|
819
|
+
></textarea>
|
|
820
|
+
</label>
|
|
821
|
+
`}
|
|
822
|
+
</div>
|
|
823
|
+
|
|
824
|
+
${e.issues.length>0?c`<div class="callout danger" style="margin-top: 12px;">
|
|
825
|
+
<pre class="code-block">${JSON.stringify(e.issues,null,2)}</pre>
|
|
826
|
+
</div>`:f}
|
|
827
|
+
</main>
|
|
828
|
+
</div>
|
|
829
|
+
`}function rh(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 lh(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,l=typeof i?.connected=="boolean"&&i.connected,p=(n.channelAccounts?.[e]??[]).some(d=>d.configured||d.running||d.connected);return a||o||l||p}function ch(e,t){return t?.[e]?.length??0}function br(e,t){const n=ch(e,t);return n<2?f:c`<div class="account-count">Accounts (${n})</div>`}function dh(e,t){let n=e;for(const s of t){if(!n)return null;const i=ue(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 uh(e,t){const s=(e.channels??{})[t],i=e[t];return(s&&typeof s=="object"?s:null)??(i&&typeof i=="object"?i:null)??{}}function ph(e){const t=yr(e.schema),n=t.schema;if(!n)return c`<div class="callout danger">Schema unavailable. Use Raw.</div>`;const s=dh(n,["channels",e.channelId]);if(!s)return c`<div class="callout danger">Channel config schema unavailable.</div>`;const i=e.configValue??{},a=uh(i,e.channelId);return c`
|
|
830
|
+
<div class="config-form">
|
|
831
|
+
${be({schema:s,value:a,path:["channels",e.channelId],hints:e.uiHints,unsupported:new Set(t.unsupportedPaths),disabled:e.disabled,showLabel:!1,onPatch:e.onPatch})}
|
|
832
|
+
</div>
|
|
833
|
+
`}function $e(e){const{channelId:t,props:n}=e,s=n.configSaving||n.configSchemaLoading;return c`
|
|
834
|
+
<div style="margin-top: 16px;">
|
|
835
|
+
${n.configSchemaLoading?c`<div class="muted">Loading config schema…</div>`:ph({channelId:t,configValue:n.configForm,schema:n.configSchema,uiHints:n.configUiHints,disabled:s,onPatch:n.onConfigPatch})}
|
|
836
|
+
<div class="row" style="margin-top: 12px;">
|
|
837
|
+
<button
|
|
838
|
+
class="btn primary"
|
|
839
|
+
?disabled=${s||!n.configFormDirty}
|
|
840
|
+
@click=${()=>n.onConfigSave()}
|
|
841
|
+
>
|
|
842
|
+
${n.configSaving?"Saving…":"Save"}
|
|
843
|
+
</button>
|
|
844
|
+
<button
|
|
845
|
+
class="btn"
|
|
846
|
+
?disabled=${s}
|
|
847
|
+
@click=${()=>n.onConfigReload()}
|
|
848
|
+
>
|
|
849
|
+
Reload
|
|
850
|
+
</button>
|
|
851
|
+
</div>
|
|
852
|
+
</div>
|
|
853
|
+
`}function hh(e){const{props:t,discord:n,accountCountLabel:s}=e;return c`
|
|
854
|
+
<div class="card">
|
|
855
|
+
<div class="card-title">Discord</div>
|
|
856
|
+
<div class="card-sub">Bot status and channel configuration.</div>
|
|
857
|
+
${s}
|
|
858
|
+
|
|
859
|
+
<div class="status-list" style="margin-top: 16px;">
|
|
860
|
+
<div>
|
|
861
|
+
<span class="label">Configured</span>
|
|
862
|
+
<span>${n?.configured?"Yes":"No"}</span>
|
|
863
|
+
</div>
|
|
864
|
+
<div>
|
|
865
|
+
<span class="label">Running</span>
|
|
866
|
+
<span>${n?.running?"Yes":"No"}</span>
|
|
867
|
+
</div>
|
|
868
|
+
<div>
|
|
869
|
+
<span class="label">Last start</span>
|
|
870
|
+
<span>${n?.lastStartAt?O(n.lastStartAt):"n/a"}</span>
|
|
871
|
+
</div>
|
|
872
|
+
<div>
|
|
873
|
+
<span class="label">Last probe</span>
|
|
874
|
+
<span>${n?.lastProbeAt?O(n.lastProbeAt):"n/a"}</span>
|
|
875
|
+
</div>
|
|
876
|
+
</div>
|
|
877
|
+
|
|
878
|
+
${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
|
|
879
|
+
${n.lastError}
|
|
880
|
+
</div>`:f}
|
|
881
|
+
|
|
882
|
+
${n?.probe?c`<div class="callout" style="margin-top: 12px;">
|
|
883
|
+
Probe ${n.probe.ok?"ok":"failed"} ·
|
|
884
|
+
${n.probe.status??""} ${n.probe.error??""}
|
|
885
|
+
</div>`:f}
|
|
886
|
+
|
|
887
|
+
${$e({channelId:"discord",props:t})}
|
|
888
|
+
|
|
889
|
+
<div class="row" style="margin-top: 12px;">
|
|
890
|
+
<button class="btn" @click=${()=>t.onRefresh(!0)}>
|
|
891
|
+
Probe
|
|
892
|
+
</button>
|
|
893
|
+
</div>
|
|
894
|
+
</div>
|
|
895
|
+
`}function fh(e){const{props:t,googleChat:n,accountCountLabel:s}=e;return c`
|
|
896
|
+
<div class="card">
|
|
897
|
+
<div class="card-title">Google Chat</div>
|
|
898
|
+
<div class="card-sub">Chat API webhook status and channel configuration.</div>
|
|
899
|
+
${s}
|
|
900
|
+
|
|
901
|
+
<div class="status-list" style="margin-top: 16px;">
|
|
902
|
+
<div>
|
|
903
|
+
<span class="label">Configured</span>
|
|
904
|
+
<span>${n?n.configured?"Yes":"No":"n/a"}</span>
|
|
905
|
+
</div>
|
|
906
|
+
<div>
|
|
907
|
+
<span class="label">Running</span>
|
|
908
|
+
<span>${n?n.running?"Yes":"No":"n/a"}</span>
|
|
909
|
+
</div>
|
|
910
|
+
<div>
|
|
911
|
+
<span class="label">Credential</span>
|
|
912
|
+
<span>${n?.credentialSource??"n/a"}</span>
|
|
913
|
+
</div>
|
|
914
|
+
<div>
|
|
915
|
+
<span class="label">Audience</span>
|
|
916
|
+
<span>
|
|
917
|
+
${n?.audienceType?`${n.audienceType}${n.audience?` · ${n.audience}`:""}`:"n/a"}
|
|
918
|
+
</span>
|
|
919
|
+
</div>
|
|
920
|
+
<div>
|
|
921
|
+
<span class="label">Last start</span>
|
|
922
|
+
<span>${n?.lastStartAt?O(n.lastStartAt):"n/a"}</span>
|
|
923
|
+
</div>
|
|
924
|
+
<div>
|
|
925
|
+
<span class="label">Last probe</span>
|
|
926
|
+
<span>${n?.lastProbeAt?O(n.lastProbeAt):"n/a"}</span>
|
|
927
|
+
</div>
|
|
928
|
+
</div>
|
|
929
|
+
|
|
930
|
+
${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
|
|
931
|
+
${n.lastError}
|
|
932
|
+
</div>`:f}
|
|
933
|
+
|
|
934
|
+
${n?.probe?c`<div class="callout" style="margin-top: 12px;">
|
|
935
|
+
Probe ${n.probe.ok?"ok":"failed"} ·
|
|
936
|
+
${n.probe.status??""} ${n.probe.error??""}
|
|
937
|
+
</div>`:f}
|
|
938
|
+
|
|
939
|
+
${$e({channelId:"googlechat",props:t})}
|
|
940
|
+
|
|
941
|
+
<div class="row" style="margin-top: 12px;">
|
|
942
|
+
<button class="btn" @click=${()=>t.onRefresh(!0)}>
|
|
943
|
+
Probe
|
|
944
|
+
</button>
|
|
945
|
+
</div>
|
|
946
|
+
</div>
|
|
947
|
+
`}function gh(e){const{props:t,imessage:n,accountCountLabel:s}=e;return c`
|
|
948
|
+
<div class="card">
|
|
949
|
+
<div class="card-title">iMessage</div>
|
|
950
|
+
<div class="card-sub">macOS bridge status and channel configuration.</div>
|
|
951
|
+
${s}
|
|
952
|
+
|
|
953
|
+
<div class="status-list" style="margin-top: 16px;">
|
|
954
|
+
<div>
|
|
955
|
+
<span class="label">Configured</span>
|
|
956
|
+
<span>${n?.configured?"Yes":"No"}</span>
|
|
957
|
+
</div>
|
|
958
|
+
<div>
|
|
959
|
+
<span class="label">Running</span>
|
|
960
|
+
<span>${n?.running?"Yes":"No"}</span>
|
|
961
|
+
</div>
|
|
962
|
+
<div>
|
|
963
|
+
<span class="label">Last start</span>
|
|
964
|
+
<span>${n?.lastStartAt?O(n.lastStartAt):"n/a"}</span>
|
|
965
|
+
</div>
|
|
966
|
+
<div>
|
|
967
|
+
<span class="label">Last probe</span>
|
|
968
|
+
<span>${n?.lastProbeAt?O(n.lastProbeAt):"n/a"}</span>
|
|
969
|
+
</div>
|
|
970
|
+
</div>
|
|
971
|
+
|
|
972
|
+
${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
|
|
973
|
+
${n.lastError}
|
|
974
|
+
</div>`:f}
|
|
975
|
+
|
|
976
|
+
${n?.probe?c`<div class="callout" style="margin-top: 12px;">
|
|
977
|
+
Probe ${n.probe.ok?"ok":"failed"} ·
|
|
978
|
+
${n.probe.error??""}
|
|
979
|
+
</div>`:f}
|
|
980
|
+
|
|
981
|
+
${$e({channelId:"imessage",props:t})}
|
|
982
|
+
|
|
983
|
+
<div class="row" style="margin-top: 12px;">
|
|
984
|
+
<button class="btn" @click=${()=>t.onRefresh(!0)}>
|
|
985
|
+
Probe
|
|
986
|
+
</button>
|
|
987
|
+
</div>
|
|
988
|
+
</div>
|
|
989
|
+
`}function vh(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 mh(e){const{state:t,callbacks:n,accountId:s}=e,i=vh(t),a=(l,r,p={})=>{const{type:d="text",placeholder:u,maxLength:g,help:v}=p,m=t.values[l]??"",$=t.fieldErrors[l],A=`nostr-profile-${l}`;return d==="textarea"?c`
|
|
990
|
+
<div class="form-field" style="margin-bottom: 12px;">
|
|
991
|
+
<label for="${A}" style="display: block; margin-bottom: 4px; font-weight: 500;">
|
|
992
|
+
${r}
|
|
993
|
+
</label>
|
|
994
|
+
<textarea
|
|
995
|
+
id="${A}"
|
|
996
|
+
.value=${m}
|
|
997
|
+
placeholder=${u??""}
|
|
998
|
+
maxlength=${g??2e3}
|
|
999
|
+
rows="3"
|
|
1000
|
+
style="width: 100%; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px; resize: vertical; font-family: inherit;"
|
|
1001
|
+
@input=${_=>{const I=_.target;n.onFieldChange(l,I.value)}}
|
|
1002
|
+
?disabled=${t.saving}
|
|
1003
|
+
></textarea>
|
|
1004
|
+
${v?c`<div style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">${v}</div>`:f}
|
|
1005
|
+
${$?c`<div style="font-size: 12px; color: var(--danger-color); margin-top: 2px;">${$}</div>`:f}
|
|
1006
|
+
</div>
|
|
1007
|
+
`:c`
|
|
1008
|
+
<div class="form-field" style="margin-bottom: 12px;">
|
|
1009
|
+
<label for="${A}" style="display: block; margin-bottom: 4px; font-weight: 500;">
|
|
1010
|
+
${r}
|
|
1011
|
+
</label>
|
|
1012
|
+
<input
|
|
1013
|
+
id="${A}"
|
|
1014
|
+
type=${d}
|
|
1015
|
+
.value=${m}
|
|
1016
|
+
placeholder=${u??""}
|
|
1017
|
+
maxlength=${g??256}
|
|
1018
|
+
style="width: 100%; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px;"
|
|
1019
|
+
@input=${_=>{const I=_.target;n.onFieldChange(l,I.value)}}
|
|
1020
|
+
?disabled=${t.saving}
|
|
1021
|
+
/>
|
|
1022
|
+
${v?c`<div style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">${v}</div>`:f}
|
|
1023
|
+
${$?c`<div style="font-size: 12px; color: var(--danger-color); margin-top: 2px;">${$}</div>`:f}
|
|
1024
|
+
</div>
|
|
1025
|
+
`},o=()=>{const l=t.values.picture;return l?c`
|
|
1026
|
+
<div style="margin-bottom: 12px;">
|
|
1027
|
+
<img
|
|
1028
|
+
src=${l}
|
|
1029
|
+
alt="Profile picture preview"
|
|
1030
|
+
style="max-width: 80px; max-height: 80px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-color);"
|
|
1031
|
+
@error=${r=>{const p=r.target;p.style.display="none"}}
|
|
1032
|
+
@load=${r=>{const p=r.target;p.style.display="block"}}
|
|
1033
|
+
/>
|
|
1034
|
+
</div>
|
|
1035
|
+
`:f};return c`
|
|
1036
|
+
<div class="nostr-profile-form" style="padding: 16px; background: var(--bg-secondary); border-radius: 8px; margin-top: 12px;">
|
|
1037
|
+
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;">
|
|
1038
|
+
<div style="font-weight: 600; font-size: 16px;">Edit Profile</div>
|
|
1039
|
+
<div style="font-size: 12px; color: var(--text-muted);">Account: ${s}</div>
|
|
1040
|
+
</div>
|
|
1041
|
+
|
|
1042
|
+
${t.error?c`<div class="callout danger" style="margin-bottom: 12px;">${t.error}</div>`:f}
|
|
1043
|
+
|
|
1044
|
+
${t.success?c`<div class="callout success" style="margin-bottom: 12px;">${t.success}</div>`:f}
|
|
1045
|
+
|
|
1046
|
+
${o()}
|
|
1047
|
+
|
|
1048
|
+
${a("name","Username",{placeholder:"satoshi",maxLength:256,help:"Short username (e.g., satoshi)"})}
|
|
1049
|
+
|
|
1050
|
+
${a("displayName","Display Name",{placeholder:"Satoshi Nakamoto",maxLength:256,help:"Your full display name"})}
|
|
1051
|
+
|
|
1052
|
+
${a("about","Bio",{type:"textarea",placeholder:"Tell people about yourself...",maxLength:2e3,help:"A brief bio or description"})}
|
|
1053
|
+
|
|
1054
|
+
${a("picture","Avatar URL",{type:"url",placeholder:"https://example.com/avatar.jpg",help:"HTTPS URL to your profile picture"})}
|
|
1055
|
+
|
|
1056
|
+
${t.showAdvanced?c`
|
|
1057
|
+
<div style="border-top: 1px solid var(--border-color); padding-top: 12px; margin-top: 12px;">
|
|
1058
|
+
<div style="font-weight: 500; margin-bottom: 12px; color: var(--text-muted);">Advanced</div>
|
|
1059
|
+
|
|
1060
|
+
${a("banner","Banner URL",{type:"url",placeholder:"https://example.com/banner.jpg",help:"HTTPS URL to a banner image"})}
|
|
1061
|
+
|
|
1062
|
+
${a("website","Website",{type:"url",placeholder:"https://example.com",help:"Your personal website"})}
|
|
1063
|
+
|
|
1064
|
+
${a("nip05","NIP-05 Identifier",{placeholder:"you@example.com",help:"Verifiable identifier (e.g., you@domain.com)"})}
|
|
1065
|
+
|
|
1066
|
+
${a("lud16","Lightning Address",{placeholder:"you@getalby.com",help:"Lightning address for tips (LUD-16)"})}
|
|
1067
|
+
</div>
|
|
1068
|
+
`:f}
|
|
1069
|
+
|
|
1070
|
+
<div style="display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap;">
|
|
1071
|
+
<button
|
|
1072
|
+
class="btn primary"
|
|
1073
|
+
@click=${n.onSave}
|
|
1074
|
+
?disabled=${t.saving||!i}
|
|
1075
|
+
>
|
|
1076
|
+
${t.saving?"Saving...":"Save & Publish"}
|
|
1077
|
+
</button>
|
|
1078
|
+
|
|
1079
|
+
<button
|
|
1080
|
+
class="btn"
|
|
1081
|
+
@click=${n.onImport}
|
|
1082
|
+
?disabled=${t.importing||t.saving}
|
|
1083
|
+
>
|
|
1084
|
+
${t.importing?"Importing...":"Import from Relays"}
|
|
1085
|
+
</button>
|
|
1086
|
+
|
|
1087
|
+
<button
|
|
1088
|
+
class="btn"
|
|
1089
|
+
@click=${n.onToggleAdvanced}
|
|
1090
|
+
>
|
|
1091
|
+
${t.showAdvanced?"Hide Advanced":"Show Advanced"}
|
|
1092
|
+
</button>
|
|
1093
|
+
|
|
1094
|
+
<button
|
|
1095
|
+
class="btn"
|
|
1096
|
+
@click=${n.onCancel}
|
|
1097
|
+
?disabled=${t.saving}
|
|
1098
|
+
>
|
|
1099
|
+
Cancel
|
|
1100
|
+
</button>
|
|
1101
|
+
</div>
|
|
1102
|
+
|
|
1103
|
+
${i?c`<div style="font-size: 12px; color: var(--warning-color); margin-top: 8px;">
|
|
1104
|
+
You have unsaved changes
|
|
1105
|
+
</div>`:f}
|
|
1106
|
+
</div>
|
|
1107
|
+
`}function yh(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 Va(e){return e?e.length<=20?e:`${e.slice(0,8)}...${e.slice(-8)}`:"n/a"}function bh(e){const{props:t,nostr:n,nostrAccounts:s,accountCountLabel:i,profileFormState:a,profileFormCallbacks:o,onEditProfile:l}=e,r=s[0],p=n?.configured??r?.configured??!1,d=n?.running??r?.running??!1,u=n?.publicKey??r?.publicKey,g=n?.lastStartAt??r?.lastStartAt??null,v=n?.lastError??r?.lastError??null,m=s.length>1,$=a!=null,A=I=>{const P=I.publicKey,M=I.profile,C=M?.displayName??M?.name??I.name??I.accountId;return c`
|
|
1108
|
+
<div class="account-card">
|
|
1109
|
+
<div class="account-card-header">
|
|
1110
|
+
<div class="account-card-title">${C}</div>
|
|
1111
|
+
<div class="account-card-id">${I.accountId}</div>
|
|
1112
|
+
</div>
|
|
1113
|
+
<div class="status-list account-card-status">
|
|
1114
|
+
<div>
|
|
1115
|
+
<span class="label">Running</span>
|
|
1116
|
+
<span>${I.running?"Yes":"No"}</span>
|
|
1117
|
+
</div>
|
|
1118
|
+
<div>
|
|
1119
|
+
<span class="label">Configured</span>
|
|
1120
|
+
<span>${I.configured?"Yes":"No"}</span>
|
|
1121
|
+
</div>
|
|
1122
|
+
<div>
|
|
1123
|
+
<span class="label">Public Key</span>
|
|
1124
|
+
<span class="monospace" title="${P??""}">${Va(P)}</span>
|
|
1125
|
+
</div>
|
|
1126
|
+
<div>
|
|
1127
|
+
<span class="label">Last inbound</span>
|
|
1128
|
+
<span>${I.lastInboundAt?O(I.lastInboundAt):"n/a"}</span>
|
|
1129
|
+
</div>
|
|
1130
|
+
${I.lastError?c`
|
|
1131
|
+
<div class="account-card-error">${I.lastError}</div>
|
|
1132
|
+
`:f}
|
|
1133
|
+
</div>
|
|
1134
|
+
</div>
|
|
1135
|
+
`},_=()=>{if($&&o)return mh({state:a,callbacks:o,accountId:s[0]?.accountId??"default"});const I=r?.profile??n?.profile,{name:P,displayName:M,about:C,picture:E,nip05:pe}=I??{},xn=P||M||C||E||pe;return c`
|
|
1136
|
+
<div style="margin-top: 16px; padding: 12px; background: var(--bg-secondary); border-radius: 8px;">
|
|
1137
|
+
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
|
|
1138
|
+
<div style="font-weight: 500;">Profile</div>
|
|
1139
|
+
${p?c`
|
|
1140
|
+
<button
|
|
1141
|
+
class="btn btn-sm"
|
|
1142
|
+
@click=${l}
|
|
1143
|
+
style="font-size: 12px; padding: 4px 8px;"
|
|
1144
|
+
>
|
|
1145
|
+
Edit Profile
|
|
1146
|
+
</button>
|
|
1147
|
+
`:f}
|
|
1148
|
+
</div>
|
|
1149
|
+
${xn?c`
|
|
1150
|
+
<div class="status-list">
|
|
1151
|
+
${E?c`
|
|
1152
|
+
<div style="margin-bottom: 8px;">
|
|
1153
|
+
<img
|
|
1154
|
+
src=${E}
|
|
1155
|
+
alt="Profile picture"
|
|
1156
|
+
style="width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-color);"
|
|
1157
|
+
@error=${An=>{An.target.style.display="none"}}
|
|
1158
|
+
/>
|
|
1159
|
+
</div>
|
|
1160
|
+
`:f}
|
|
1161
|
+
${P?c`<div><span class="label">Name</span><span>${P}</span></div>`:f}
|
|
1162
|
+
${M?c`<div><span class="label">Display Name</span><span>${M}</span></div>`:f}
|
|
1163
|
+
${C?c`<div><span class="label">About</span><span style="max-width: 300px; overflow: hidden; text-overflow: ellipsis;">${C}</span></div>`:f}
|
|
1164
|
+
${pe?c`<div><span class="label">NIP-05</span><span>${pe}</span></div>`:f}
|
|
1165
|
+
</div>
|
|
1166
|
+
`:c`
|
|
1167
|
+
<div style="color: var(--text-muted); font-size: 13px;">
|
|
1168
|
+
No profile set. Click "Edit Profile" to add your name, bio, and avatar.
|
|
1169
|
+
</div>
|
|
1170
|
+
`}
|
|
1171
|
+
</div>
|
|
1172
|
+
`};return c`
|
|
1173
|
+
<div class="card">
|
|
1174
|
+
<div class="card-title">Nostr</div>
|
|
1175
|
+
<div class="card-sub">Decentralized DMs via Nostr relays (NIP-04).</div>
|
|
1176
|
+
${i}
|
|
1177
|
+
|
|
1178
|
+
${m?c`
|
|
1179
|
+
<div class="account-card-list">
|
|
1180
|
+
${s.map(I=>A(I))}
|
|
1181
|
+
</div>
|
|
1182
|
+
`:c`
|
|
1183
|
+
<div class="status-list" style="margin-top: 16px;">
|
|
1184
|
+
<div>
|
|
1185
|
+
<span class="label">Configured</span>
|
|
1186
|
+
<span>${p?"Yes":"No"}</span>
|
|
1187
|
+
</div>
|
|
1188
|
+
<div>
|
|
1189
|
+
<span class="label">Running</span>
|
|
1190
|
+
<span>${d?"Yes":"No"}</span>
|
|
1191
|
+
</div>
|
|
1192
|
+
<div>
|
|
1193
|
+
<span class="label">Public Key</span>
|
|
1194
|
+
<span class="monospace" title="${u??""}"
|
|
1195
|
+
>${Va(u)}</span
|
|
1196
|
+
>
|
|
1197
|
+
</div>
|
|
1198
|
+
<div>
|
|
1199
|
+
<span class="label">Last start</span>
|
|
1200
|
+
<span>${g?O(g):"n/a"}</span>
|
|
1201
|
+
</div>
|
|
1202
|
+
</div>
|
|
1203
|
+
`}
|
|
1204
|
+
|
|
1205
|
+
${v?c`<div class="callout danger" style="margin-top: 12px;">${v}</div>`:f}
|
|
1206
|
+
|
|
1207
|
+
${_()}
|
|
1208
|
+
|
|
1209
|
+
${$e({channelId:"nostr",props:t})}
|
|
1210
|
+
|
|
1211
|
+
<div class="row" style="margin-top: 12px;">
|
|
1212
|
+
<button class="btn" @click=${()=>t.onRefresh(!1)}>Refresh</button>
|
|
1213
|
+
</div>
|
|
1214
|
+
</div>
|
|
1215
|
+
`}function wh(e){const{props:t,signal:n,accountCountLabel:s}=e;return c`
|
|
1216
|
+
<div class="card">
|
|
1217
|
+
<div class="card-title">Signal</div>
|
|
1218
|
+
<div class="card-sub">signal-cli status and channel configuration.</div>
|
|
1219
|
+
${s}
|
|
1220
|
+
|
|
1221
|
+
<div class="status-list" style="margin-top: 16px;">
|
|
1222
|
+
<div>
|
|
1223
|
+
<span class="label">Configured</span>
|
|
1224
|
+
<span>${n?.configured?"Yes":"No"}</span>
|
|
1225
|
+
</div>
|
|
1226
|
+
<div>
|
|
1227
|
+
<span class="label">Running</span>
|
|
1228
|
+
<span>${n?.running?"Yes":"No"}</span>
|
|
1229
|
+
</div>
|
|
1230
|
+
<div>
|
|
1231
|
+
<span class="label">Base URL</span>
|
|
1232
|
+
<span>${n?.baseUrl??"n/a"}</span>
|
|
1233
|
+
</div>
|
|
1234
|
+
<div>
|
|
1235
|
+
<span class="label">Last start</span>
|
|
1236
|
+
<span>${n?.lastStartAt?O(n.lastStartAt):"n/a"}</span>
|
|
1237
|
+
</div>
|
|
1238
|
+
<div>
|
|
1239
|
+
<span class="label">Last probe</span>
|
|
1240
|
+
<span>${n?.lastProbeAt?O(n.lastProbeAt):"n/a"}</span>
|
|
1241
|
+
</div>
|
|
1242
|
+
</div>
|
|
1243
|
+
|
|
1244
|
+
${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
|
|
1245
|
+
${n.lastError}
|
|
1246
|
+
</div>`:f}
|
|
1247
|
+
|
|
1248
|
+
${n?.probe?c`<div class="callout" style="margin-top: 12px;">
|
|
1249
|
+
Probe ${n.probe.ok?"ok":"failed"} ·
|
|
1250
|
+
${n.probe.status??""} ${n.probe.error??""}
|
|
1251
|
+
</div>`:f}
|
|
1252
|
+
|
|
1253
|
+
${$e({channelId:"signal",props:t})}
|
|
1254
|
+
|
|
1255
|
+
<div class="row" style="margin-top: 12px;">
|
|
1256
|
+
<button class="btn" @click=${()=>t.onRefresh(!0)}>
|
|
1257
|
+
Probe
|
|
1258
|
+
</button>
|
|
1259
|
+
</div>
|
|
1260
|
+
</div>
|
|
1261
|
+
`}function $h(e){const{props:t,slack:n,accountCountLabel:s}=e;return c`
|
|
1262
|
+
<div class="card">
|
|
1263
|
+
<div class="card-title">Slack</div>
|
|
1264
|
+
<div class="card-sub">Socket mode status and channel configuration.</div>
|
|
1265
|
+
${s}
|
|
1266
|
+
|
|
1267
|
+
<div class="status-list" style="margin-top: 16px;">
|
|
1268
|
+
<div>
|
|
1269
|
+
<span class="label">Configured</span>
|
|
1270
|
+
<span>${n?.configured?"Yes":"No"}</span>
|
|
1271
|
+
</div>
|
|
1272
|
+
<div>
|
|
1273
|
+
<span class="label">Running</span>
|
|
1274
|
+
<span>${n?.running?"Yes":"No"}</span>
|
|
1275
|
+
</div>
|
|
1276
|
+
<div>
|
|
1277
|
+
<span class="label">Last start</span>
|
|
1278
|
+
<span>${n?.lastStartAt?O(n.lastStartAt):"n/a"}</span>
|
|
1279
|
+
</div>
|
|
1280
|
+
<div>
|
|
1281
|
+
<span class="label">Last probe</span>
|
|
1282
|
+
<span>${n?.lastProbeAt?O(n.lastProbeAt):"n/a"}</span>
|
|
1283
|
+
</div>
|
|
1284
|
+
</div>
|
|
1285
|
+
|
|
1286
|
+
${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
|
|
1287
|
+
${n.lastError}
|
|
1288
|
+
</div>`:f}
|
|
1289
|
+
|
|
1290
|
+
${n?.probe?c`<div class="callout" style="margin-top: 12px;">
|
|
1291
|
+
Probe ${n.probe.ok?"ok":"failed"} ·
|
|
1292
|
+
${n.probe.status??""} ${n.probe.error??""}
|
|
1293
|
+
</div>`:f}
|
|
1294
|
+
|
|
1295
|
+
${$e({channelId:"slack",props:t})}
|
|
1296
|
+
|
|
1297
|
+
<div class="row" style="margin-top: 12px;">
|
|
1298
|
+
<button class="btn" @click=${()=>t.onRefresh(!0)}>
|
|
1299
|
+
Probe
|
|
1300
|
+
</button>
|
|
1301
|
+
</div>
|
|
1302
|
+
</div>
|
|
1303
|
+
`}function xh(e){const{props:t,telegram:n,telegramAccounts:s,accountCountLabel:i}=e,a=s.length>1,o=l=>{const p=l.probe?.bot?.username,d=l.name||l.accountId;return c`
|
|
1304
|
+
<div class="account-card">
|
|
1305
|
+
<div class="account-card-header">
|
|
1306
|
+
<div class="account-card-title">
|
|
1307
|
+
${p?`@${p}`:d}
|
|
1308
|
+
</div>
|
|
1309
|
+
<div class="account-card-id">${l.accountId}</div>
|
|
1310
|
+
</div>
|
|
1311
|
+
<div class="status-list account-card-status">
|
|
1312
|
+
<div>
|
|
1313
|
+
<span class="label">Running</span>
|
|
1314
|
+
<span>${l.running?"Yes":"No"}</span>
|
|
1315
|
+
</div>
|
|
1316
|
+
<div>
|
|
1317
|
+
<span class="label">Configured</span>
|
|
1318
|
+
<span>${l.configured?"Yes":"No"}</span>
|
|
1319
|
+
</div>
|
|
1320
|
+
<div>
|
|
1321
|
+
<span class="label">Last inbound</span>
|
|
1322
|
+
<span>${l.lastInboundAt?O(l.lastInboundAt):"n/a"}</span>
|
|
1323
|
+
</div>
|
|
1324
|
+
${l.lastError?c`
|
|
1325
|
+
<div class="account-card-error">
|
|
1326
|
+
${l.lastError}
|
|
1327
|
+
</div>
|
|
1328
|
+
`:f}
|
|
1329
|
+
</div>
|
|
1330
|
+
</div>
|
|
1331
|
+
`};return c`
|
|
1332
|
+
<div class="card">
|
|
1333
|
+
<div class="card-title">Telegram</div>
|
|
1334
|
+
<div class="card-sub">Bot status and channel configuration.</div>
|
|
1335
|
+
${i}
|
|
1336
|
+
|
|
1337
|
+
${a?c`
|
|
1338
|
+
<div class="account-card-list">
|
|
1339
|
+
${s.map(l=>o(l))}
|
|
1340
|
+
</div>
|
|
1341
|
+
`:c`
|
|
1342
|
+
<div class="status-list" style="margin-top: 16px;">
|
|
1343
|
+
<div>
|
|
1344
|
+
<span class="label">Configured</span>
|
|
1345
|
+
<span>${n?.configured?"Yes":"No"}</span>
|
|
1346
|
+
</div>
|
|
1347
|
+
<div>
|
|
1348
|
+
<span class="label">Running</span>
|
|
1349
|
+
<span>${n?.running?"Yes":"No"}</span>
|
|
1350
|
+
</div>
|
|
1351
|
+
<div>
|
|
1352
|
+
<span class="label">Mode</span>
|
|
1353
|
+
<span>${n?.mode??"n/a"}</span>
|
|
1354
|
+
</div>
|
|
1355
|
+
<div>
|
|
1356
|
+
<span class="label">Last start</span>
|
|
1357
|
+
<span>${n?.lastStartAt?O(n.lastStartAt):"n/a"}</span>
|
|
1358
|
+
</div>
|
|
1359
|
+
<div>
|
|
1360
|
+
<span class="label">Last probe</span>
|
|
1361
|
+
<span>${n?.lastProbeAt?O(n.lastProbeAt):"n/a"}</span>
|
|
1362
|
+
</div>
|
|
1363
|
+
</div>
|
|
1364
|
+
`}
|
|
1365
|
+
|
|
1366
|
+
${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
|
|
1367
|
+
${n.lastError}
|
|
1368
|
+
</div>`:f}
|
|
1369
|
+
|
|
1370
|
+
${n?.probe?c`<div class="callout" style="margin-top: 12px;">
|
|
1371
|
+
Probe ${n.probe.ok?"ok":"failed"} ·
|
|
1372
|
+
${n.probe.status??""} ${n.probe.error??""}
|
|
1373
|
+
</div>`:f}
|
|
1374
|
+
|
|
1375
|
+
${$e({channelId:"telegram",props:t})}
|
|
1376
|
+
|
|
1377
|
+
<div class="row" style="margin-top: 12px;">
|
|
1378
|
+
<button class="btn" @click=${()=>t.onRefresh(!0)}>
|
|
1379
|
+
Probe
|
|
1380
|
+
</button>
|
|
1381
|
+
</div>
|
|
1382
|
+
</div>
|
|
1383
|
+
`}function Ah(e){const{props:t,whatsapp:n,accountCountLabel:s}=e;return c`
|
|
1384
|
+
<div class="card">
|
|
1385
|
+
<div class="card-title">WhatsApp</div>
|
|
1386
|
+
<div class="card-sub">Link WhatsApp Web and monitor connection health.</div>
|
|
1387
|
+
${s}
|
|
1388
|
+
|
|
1389
|
+
<div class="status-list" style="margin-top: 16px;">
|
|
1390
|
+
<div>
|
|
1391
|
+
<span class="label">Configured</span>
|
|
1392
|
+
<span>${n?.configured?"Yes":"No"}</span>
|
|
1393
|
+
</div>
|
|
1394
|
+
<div>
|
|
1395
|
+
<span class="label">Linked</span>
|
|
1396
|
+
<span>${n?.linked?"Yes":"No"}</span>
|
|
1397
|
+
</div>
|
|
1398
|
+
<div>
|
|
1399
|
+
<span class="label">Running</span>
|
|
1400
|
+
<span>${n?.running?"Yes":"No"}</span>
|
|
1401
|
+
</div>
|
|
1402
|
+
<div>
|
|
1403
|
+
<span class="label">Connected</span>
|
|
1404
|
+
<span>${n?.connected?"Yes":"No"}</span>
|
|
1405
|
+
</div>
|
|
1406
|
+
<div>
|
|
1407
|
+
<span class="label">Last connect</span>
|
|
1408
|
+
<span>
|
|
1409
|
+
${n?.lastConnectedAt?O(n.lastConnectedAt):"n/a"}
|
|
1410
|
+
</span>
|
|
1411
|
+
</div>
|
|
1412
|
+
<div>
|
|
1413
|
+
<span class="label">Last message</span>
|
|
1414
|
+
<span>
|
|
1415
|
+
${n?.lastMessageAt?O(n.lastMessageAt):"n/a"}
|
|
1416
|
+
</span>
|
|
1417
|
+
</div>
|
|
1418
|
+
<div>
|
|
1419
|
+
<span class="label">Auth age</span>
|
|
1420
|
+
<span>
|
|
1421
|
+
${n?.authAgeMs!=null?rh(n.authAgeMs):"n/a"}
|
|
1422
|
+
</span>
|
|
1423
|
+
</div>
|
|
1424
|
+
</div>
|
|
1425
|
+
|
|
1426
|
+
${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
|
|
1427
|
+
${n.lastError}
|
|
1428
|
+
</div>`:f}
|
|
1429
|
+
|
|
1430
|
+
${t.whatsappMessage?c`<div class="callout" style="margin-top: 12px;">
|
|
1431
|
+
${t.whatsappMessage}
|
|
1432
|
+
</div>`:f}
|
|
1433
|
+
|
|
1434
|
+
${t.whatsappQrDataUrl?c`<div class="qr-wrap">
|
|
1435
|
+
<img src=${t.whatsappQrDataUrl} alt="WhatsApp QR" />
|
|
1436
|
+
</div>`:f}
|
|
1437
|
+
|
|
1438
|
+
<div class="row" style="margin-top: 14px; flex-wrap: wrap;">
|
|
1439
|
+
<button
|
|
1440
|
+
class="btn primary"
|
|
1441
|
+
?disabled=${t.whatsappBusy}
|
|
1442
|
+
@click=${()=>t.onWhatsAppStart(!1)}
|
|
1443
|
+
>
|
|
1444
|
+
${t.whatsappBusy?"Working…":"Show QR"}
|
|
1445
|
+
</button>
|
|
1446
|
+
<button
|
|
1447
|
+
class="btn"
|
|
1448
|
+
?disabled=${t.whatsappBusy}
|
|
1449
|
+
@click=${()=>t.onWhatsAppStart(!0)}
|
|
1450
|
+
>
|
|
1451
|
+
Relink
|
|
1452
|
+
</button>
|
|
1453
|
+
<button
|
|
1454
|
+
class="btn"
|
|
1455
|
+
?disabled=${t.whatsappBusy}
|
|
1456
|
+
@click=${()=>t.onWhatsAppWait()}
|
|
1457
|
+
>
|
|
1458
|
+
Wait for scan
|
|
1459
|
+
</button>
|
|
1460
|
+
<button
|
|
1461
|
+
class="btn danger"
|
|
1462
|
+
?disabled=${t.whatsappBusy}
|
|
1463
|
+
@click=${()=>t.onWhatsAppLogout()}
|
|
1464
|
+
>
|
|
1465
|
+
Logout
|
|
1466
|
+
</button>
|
|
1467
|
+
<button class="btn" @click=${()=>t.onRefresh(!0)}>
|
|
1468
|
+
Refresh
|
|
1469
|
+
</button>
|
|
1470
|
+
</div>
|
|
1471
|
+
|
|
1472
|
+
${$e({channelId:"whatsapp",props:t})}
|
|
1473
|
+
</div>
|
|
1474
|
+
`}function kh(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,l=t?.imessage??null,r=t?.nostr??null,d=Sh(e.snapshot).map((u,g)=>({key:u,enabled:lh(u,e),order:g})).sort((u,g)=>u.enabled!==g.enabled?u.enabled?-1:1:u.order-g.order);return c`
|
|
1475
|
+
<section class="grid grid-cols-2">
|
|
1476
|
+
${d.map(u=>_h(u.key,e,{whatsapp:n,telegram:s,discord:i,slack:a,signal:o,imessage:l,nostr:r,channelAccounts:e.snapshot?.channelAccounts??null}))}
|
|
1477
|
+
</section>
|
|
1478
|
+
|
|
1479
|
+
<section class="card" style="margin-top: 18px;">
|
|
1480
|
+
<div class="row" style="justify-content: space-between;">
|
|
1481
|
+
<div>
|
|
1482
|
+
<div class="card-title">Channel health</div>
|
|
1483
|
+
<div class="card-sub">Channel status snapshots from the gateway.</div>
|
|
1484
|
+
</div>
|
|
1485
|
+
<div class="muted">${e.lastSuccessAt?O(e.lastSuccessAt):"n/a"}</div>
|
|
1486
|
+
</div>
|
|
1487
|
+
${e.lastError?c`<div class="callout danger" style="margin-top: 12px;">
|
|
1488
|
+
${e.lastError}
|
|
1489
|
+
</div>`:f}
|
|
1490
|
+
<pre class="code-block" style="margin-top: 12px;">
|
|
1491
|
+
${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
1492
|
+
</pre>
|
|
1493
|
+
</section>
|
|
1494
|
+
`}function Sh(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 _h(e,t,n){const s=br(e,n.channelAccounts);switch(e){case"whatsapp":return Ah({props:t,whatsapp:n.whatsapp,accountCountLabel:s});case"telegram":return xh({props:t,telegram:n.telegram,telegramAccounts:n.channelAccounts?.telegram??[],accountCountLabel:s});case"discord":return hh({props:t,discord:n.discord,accountCountLabel:s});case"googlechat":return fh({props:t,accountCountLabel:s});case"slack":return $h({props:t,slack:n.slack,accountCountLabel:s});case"signal":return wh({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",l=a?.profile??null,r=t.nostrProfileAccountId===o?t.nostrProfileFormState:null,p=r?{onFieldChange:t.onNostrProfileFieldChange,onSave:t.onNostrProfileSave,onImport:t.onNostrProfileImport,onCancel:t.onNostrProfileCancel,onToggleAdvanced:t.onNostrProfileToggleAdvanced}:null;return bh({props:t,nostr:n.nostr,nostrAccounts:i,accountCountLabel:s,profileFormState:r,profileFormCallbacks:p,onEditProfile:()=>t.onNostrProfileEdit(o,l)})}default:return Th(e,t,n.channelAccounts??{})}}function Th(e,t,n){const s=Eh(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,l=typeof i?.connected=="boolean"?i.connected:void 0,r=typeof i?.lastError=="string"?i.lastError:void 0,p=n[e]??[],d=br(e,n);return c`
|
|
1495
|
+
<div class="card">
|
|
1496
|
+
<div class="card-title">${s}</div>
|
|
1497
|
+
<div class="card-sub">Channel status and configuration.</div>
|
|
1498
|
+
${d}
|
|
1499
|
+
|
|
1500
|
+
${p.length>0?c`
|
|
1501
|
+
<div class="account-card-list">
|
|
1502
|
+
${p.map(u=>Rh(u))}
|
|
1503
|
+
</div>
|
|
1504
|
+
`:c`
|
|
1505
|
+
<div class="status-list" style="margin-top: 16px;">
|
|
1506
|
+
<div>
|
|
1507
|
+
<span class="label">Configured</span>
|
|
1508
|
+
<span>${a==null?"n/a":a?"Yes":"No"}</span>
|
|
1509
|
+
</div>
|
|
1510
|
+
<div>
|
|
1511
|
+
<span class="label">Running</span>
|
|
1512
|
+
<span>${o==null?"n/a":o?"Yes":"No"}</span>
|
|
1513
|
+
</div>
|
|
1514
|
+
<div>
|
|
1515
|
+
<span class="label">Connected</span>
|
|
1516
|
+
<span>${l==null?"n/a":l?"Yes":"No"}</span>
|
|
1517
|
+
</div>
|
|
1518
|
+
</div>
|
|
1519
|
+
`}
|
|
1520
|
+
|
|
1521
|
+
${r?c`<div class="callout danger" style="margin-top: 12px;">
|
|
1522
|
+
${r}
|
|
1523
|
+
</div>`:f}
|
|
1524
|
+
|
|
1525
|
+
${$e({channelId:e,props:t})}
|
|
1526
|
+
</div>
|
|
1527
|
+
`}function Ch(e){return e?.channelMeta?.length?Object.fromEntries(e.channelMeta.map(t=>[t.id,t])):{}}function Eh(e,t){return Ch(e)[t]?.label??e?.channelLabels?.[t]??t}const Mh=600*1e3;function wr(e){return e.lastInboundAt?Date.now()-e.lastInboundAt<Mh:!1}function Ih(e){return e.running?"Yes":wr(e)?"Active":"No"}function Lh(e){return e.connected===!0?"Yes":e.connected===!1?"No":wr(e)?"Active":"n/a"}function Rh(e){const t=Ih(e),n=Lh(e);return c`
|
|
1528
|
+
<div class="account-card">
|
|
1529
|
+
<div class="account-card-header">
|
|
1530
|
+
<div class="account-card-title">${e.name||e.accountId}</div>
|
|
1531
|
+
<div class="account-card-id">${e.accountId}</div>
|
|
1532
|
+
</div>
|
|
1533
|
+
<div class="status-list account-card-status">
|
|
1534
|
+
<div>
|
|
1535
|
+
<span class="label">Running</span>
|
|
1536
|
+
<span>${t}</span>
|
|
1537
|
+
</div>
|
|
1538
|
+
<div>
|
|
1539
|
+
<span class="label">Configured</span>
|
|
1540
|
+
<span>${e.configured?"Yes":"No"}</span>
|
|
1541
|
+
</div>
|
|
1542
|
+
<div>
|
|
1543
|
+
<span class="label">Connected</span>
|
|
1544
|
+
<span>${n}</span>
|
|
1545
|
+
</div>
|
|
1546
|
+
<div>
|
|
1547
|
+
<span class="label">Last inbound</span>
|
|
1548
|
+
<span>${e.lastInboundAt?O(e.lastInboundAt):"n/a"}</span>
|
|
1549
|
+
</div>
|
|
1550
|
+
${e.lastError?c`
|
|
1551
|
+
<div class="account-card-error">
|
|
1552
|
+
${e.lastError}
|
|
1553
|
+
</div>
|
|
1554
|
+
`:f}
|
|
1555
|
+
</div>
|
|
1556
|
+
</div>
|
|
1557
|
+
`}function Ph(e){const t=e.host??"unknown",n=e.ip?`(${e.ip})`:"",s=e.mode??"",i=e.version??"";return`${t} ${n} ${s} ${i}`.trim()}function Nh(e){const t=e.ts??null;return t?O(t):"n/a"}function $r(e){return e?`${St(e)} (${O(e)})`:"n/a"}function Oh(e){if(e.totalTokens==null)return"n/a";const t=e.totalTokens??0,n=e.contextTokens??0;return n?`${t} / ${n}`:String(t)}function Dh(e){if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Bh(e){const t=e.state??{},n=t.nextRunAtMs?St(t.nextRunAtMs):"n/a",s=t.lastRunAtMs?St(t.lastRunAtMs):"n/a";return`${t.lastStatus??"n/a"} · next ${n} · last ${s}`}function Fh(e){const t=e.schedule;return t.kind==="at"?`At ${St(t.atMs)}`:t.kind==="every"?`Every ${ho(t.everyMs)}`:`Cron ${t.expr}${t.tz?` (${t.tz})`:""}`}function Uh(e){const t=e.payload;return t.kind==="systemEvent"?`System: ${t.text}`:`Agent: ${t.message}`}function Kh(e){const t=["last",...e.channels.filter(Boolean)],n=e.form.channel?.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 Hh(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 zh(e){const t=Kh(e);return c`
|
|
1558
|
+
<section class="grid grid-cols-2">
|
|
1559
|
+
<div class="card">
|
|
1560
|
+
<div class="card-title">Scheduler</div>
|
|
1561
|
+
<div class="card-sub">Gateway-owned cron scheduler status.</div>
|
|
1562
|
+
<div class="stat-grid" style="margin-top: 16px;">
|
|
1563
|
+
<div class="stat">
|
|
1564
|
+
<div class="stat-label">Enabled</div>
|
|
1565
|
+
<div class="stat-value">
|
|
1566
|
+
${e.status?e.status.enabled?"Yes":"No":"n/a"}
|
|
1567
|
+
</div>
|
|
1568
|
+
</div>
|
|
1569
|
+
<div class="stat">
|
|
1570
|
+
<div class="stat-label">Jobs</div>
|
|
1571
|
+
<div class="stat-value">${e.status?.jobs??"n/a"}</div>
|
|
1572
|
+
</div>
|
|
1573
|
+
<div class="stat">
|
|
1574
|
+
<div class="stat-label">Next wake</div>
|
|
1575
|
+
<div class="stat-value">${$r(e.status?.nextWakeAtMs??null)}</div>
|
|
1576
|
+
</div>
|
|
1577
|
+
</div>
|
|
1578
|
+
<div class="row" style="margin-top: 12px;">
|
|
1579
|
+
<button class="btn" ?disabled=${e.loading} @click=${e.onRefresh}>
|
|
1580
|
+
${e.loading?"Refreshing…":"Refresh"}
|
|
1581
|
+
</button>
|
|
1582
|
+
${e.error?c`<span class="muted">${e.error}</span>`:f}
|
|
1583
|
+
</div>
|
|
1584
|
+
</div>
|
|
1585
|
+
|
|
1586
|
+
<div class="card">
|
|
1587
|
+
<div class="card-title">New Job</div>
|
|
1588
|
+
<div class="card-sub">Create a scheduled wakeup or agent run.</div>
|
|
1589
|
+
<div class="form-grid" style="margin-top: 16px;">
|
|
1590
|
+
<label class="field">
|
|
1591
|
+
<span>Name</span>
|
|
1592
|
+
<input
|
|
1593
|
+
.value=${e.form.name}
|
|
1594
|
+
@input=${n=>e.onFormChange({name:n.target.value})}
|
|
1595
|
+
/>
|
|
1596
|
+
</label>
|
|
1597
|
+
<label class="field">
|
|
1598
|
+
<span>Description</span>
|
|
1599
|
+
<input
|
|
1600
|
+
.value=${e.form.description}
|
|
1601
|
+
@input=${n=>e.onFormChange({description:n.target.value})}
|
|
1602
|
+
/>
|
|
1603
|
+
</label>
|
|
1604
|
+
<label class="field">
|
|
1605
|
+
<span>Agent ID</span>
|
|
1606
|
+
<input
|
|
1607
|
+
.value=${e.form.agentId}
|
|
1608
|
+
@input=${n=>e.onFormChange({agentId:n.target.value})}
|
|
1609
|
+
placeholder="default"
|
|
1610
|
+
/>
|
|
1611
|
+
</label>
|
|
1612
|
+
<label class="field checkbox">
|
|
1613
|
+
<span>Enabled</span>
|
|
1614
|
+
<input
|
|
1615
|
+
type="checkbox"
|
|
1616
|
+
.checked=${e.form.enabled}
|
|
1617
|
+
@change=${n=>e.onFormChange({enabled:n.target.checked})}
|
|
1618
|
+
/>
|
|
1619
|
+
</label>
|
|
1620
|
+
<label class="field">
|
|
1621
|
+
<span>Schedule</span>
|
|
1622
|
+
<select
|
|
1623
|
+
.value=${e.form.scheduleKind}
|
|
1624
|
+
@change=${n=>e.onFormChange({scheduleKind:n.target.value})}
|
|
1625
|
+
>
|
|
1626
|
+
<option value="every">Every</option>
|
|
1627
|
+
<option value="at">At</option>
|
|
1628
|
+
<option value="cron">Cron</option>
|
|
1629
|
+
</select>
|
|
1630
|
+
</label>
|
|
1631
|
+
</div>
|
|
1632
|
+
${jh(e)}
|
|
1633
|
+
<div class="form-grid" style="margin-top: 12px;">
|
|
1634
|
+
<label class="field">
|
|
1635
|
+
<span>Session</span>
|
|
1636
|
+
<select
|
|
1637
|
+
.value=${e.form.sessionTarget}
|
|
1638
|
+
@change=${n=>e.onFormChange({sessionTarget:n.target.value})}
|
|
1639
|
+
>
|
|
1640
|
+
<option value="main">Main</option>
|
|
1641
|
+
<option value="isolated">Isolated</option>
|
|
1642
|
+
</select>
|
|
1643
|
+
</label>
|
|
1644
|
+
<label class="field">
|
|
1645
|
+
<span>Wake mode</span>
|
|
1646
|
+
<select
|
|
1647
|
+
.value=${e.form.wakeMode}
|
|
1648
|
+
@change=${n=>e.onFormChange({wakeMode:n.target.value})}
|
|
1649
|
+
>
|
|
1650
|
+
<option value="next-heartbeat">Next heartbeat</option>
|
|
1651
|
+
<option value="now">Now</option>
|
|
1652
|
+
</select>
|
|
1653
|
+
</label>
|
|
1654
|
+
<label class="field">
|
|
1655
|
+
<span>Payload</span>
|
|
1656
|
+
<select
|
|
1657
|
+
.value=${e.form.payloadKind}
|
|
1658
|
+
@change=${n=>e.onFormChange({payloadKind:n.target.value})}
|
|
1659
|
+
>
|
|
1660
|
+
<option value="systemEvent">System event</option>
|
|
1661
|
+
<option value="agentTurn">Agent turn</option>
|
|
1662
|
+
</select>
|
|
1663
|
+
</label>
|
|
1664
|
+
</div>
|
|
1665
|
+
<label class="field" style="margin-top: 12px;">
|
|
1666
|
+
<span>${e.form.payloadKind==="systemEvent"?"System text":"Agent message"}</span>
|
|
1667
|
+
<textarea
|
|
1668
|
+
.value=${e.form.payloadText}
|
|
1669
|
+
@input=${n=>e.onFormChange({payloadText:n.target.value})}
|
|
1670
|
+
rows="4"
|
|
1671
|
+
></textarea>
|
|
1672
|
+
</label>
|
|
1673
|
+
${e.form.payloadKind==="agentTurn"?c`
|
|
1674
|
+
<div class="form-grid" style="margin-top: 12px;">
|
|
1675
|
+
<label class="field checkbox">
|
|
1676
|
+
<span>Deliver</span>
|
|
1677
|
+
<input
|
|
1678
|
+
type="checkbox"
|
|
1679
|
+
.checked=${e.form.deliver}
|
|
1680
|
+
@change=${n=>e.onFormChange({deliver:n.target.checked})}
|
|
1681
|
+
/>
|
|
1682
|
+
</label>
|
|
1683
|
+
<label class="field">
|
|
1684
|
+
<span>Channel</span>
|
|
1685
|
+
<select
|
|
1686
|
+
.value=${e.form.channel||"last"}
|
|
1687
|
+
@change=${n=>e.onFormChange({channel:n.target.value})}
|
|
1688
|
+
>
|
|
1689
|
+
${t.map(n=>c`<option value=${n}>
|
|
1690
|
+
${Hh(e,n)}
|
|
1691
|
+
</option>`)}
|
|
1692
|
+
</select>
|
|
1693
|
+
</label>
|
|
1694
|
+
<label class="field">
|
|
1695
|
+
<span>To</span>
|
|
1696
|
+
<input
|
|
1697
|
+
.value=${e.form.to}
|
|
1698
|
+
@input=${n=>e.onFormChange({to:n.target.value})}
|
|
1699
|
+
placeholder="+1555… or chat id"
|
|
1700
|
+
/>
|
|
1701
|
+
</label>
|
|
1702
|
+
<label class="field">
|
|
1703
|
+
<span>Timeout (seconds)</span>
|
|
1704
|
+
<input
|
|
1705
|
+
.value=${e.form.timeoutSeconds}
|
|
1706
|
+
@input=${n=>e.onFormChange({timeoutSeconds:n.target.value})}
|
|
1707
|
+
/>
|
|
1708
|
+
</label>
|
|
1709
|
+
${e.form.sessionTarget==="isolated"?c`
|
|
1710
|
+
<label class="field">
|
|
1711
|
+
<span>Post to main prefix</span>
|
|
1712
|
+
<input
|
|
1713
|
+
.value=${e.form.postToMainPrefix}
|
|
1714
|
+
@input=${n=>e.onFormChange({postToMainPrefix:n.target.value})}
|
|
1715
|
+
/>
|
|
1716
|
+
</label>
|
|
1717
|
+
`:f}
|
|
1718
|
+
</div>
|
|
1719
|
+
`:f}
|
|
1720
|
+
<div class="row" style="margin-top: 14px;">
|
|
1721
|
+
<button class="btn primary" ?disabled=${e.busy} @click=${e.onAdd}>
|
|
1722
|
+
${e.busy?"Saving…":"Add job"}
|
|
1723
|
+
</button>
|
|
1724
|
+
</div>
|
|
1725
|
+
</div>
|
|
1726
|
+
</section>
|
|
1727
|
+
|
|
1728
|
+
<section class="card" style="margin-top: 18px;">
|
|
1729
|
+
<div class="card-title">Jobs</div>
|
|
1730
|
+
<div class="card-sub">All scheduled jobs stored in the gateway.</div>
|
|
1731
|
+
${e.jobs.length===0?c`<div class="muted" style="margin-top: 12px;">No jobs yet.</div>`:c`
|
|
1732
|
+
<div class="list" style="margin-top: 12px;">
|
|
1733
|
+
${e.jobs.map(n=>qh(n,e))}
|
|
1734
|
+
</div>
|
|
1735
|
+
`}
|
|
1736
|
+
</section>
|
|
1737
|
+
|
|
1738
|
+
<section class="card" style="margin-top: 18px;">
|
|
1739
|
+
<div class="card-title">Run history</div>
|
|
1740
|
+
<div class="card-sub">Latest runs for ${e.runsJobId??"(select a job)"}.</div>
|
|
1741
|
+
${e.runsJobId==null?c`
|
|
1742
|
+
<div class="muted" style="margin-top: 12px;">
|
|
1743
|
+
Select a job to inspect run history.
|
|
1744
|
+
</div>
|
|
1745
|
+
`:e.runs.length===0?c`<div class="muted" style="margin-top: 12px;">No runs yet.</div>`:c`
|
|
1746
|
+
<div class="list" style="margin-top: 12px;">
|
|
1747
|
+
${e.runs.map(n=>Wh(n))}
|
|
1748
|
+
</div>
|
|
1749
|
+
`}
|
|
1750
|
+
</section>
|
|
1751
|
+
`}function jh(e){const t=e.form;return t.scheduleKind==="at"?c`
|
|
1752
|
+
<label class="field" style="margin-top: 12px;">
|
|
1753
|
+
<span>Run at</span>
|
|
1754
|
+
<input
|
|
1755
|
+
type="datetime-local"
|
|
1756
|
+
.value=${t.scheduleAt}
|
|
1757
|
+
@input=${n=>e.onFormChange({scheduleAt:n.target.value})}
|
|
1758
|
+
/>
|
|
1759
|
+
</label>
|
|
1760
|
+
`:t.scheduleKind==="every"?c`
|
|
1761
|
+
<div class="form-grid" style="margin-top: 12px;">
|
|
1762
|
+
<label class="field">
|
|
1763
|
+
<span>Every</span>
|
|
1764
|
+
<input
|
|
1765
|
+
.value=${t.everyAmount}
|
|
1766
|
+
@input=${n=>e.onFormChange({everyAmount:n.target.value})}
|
|
1767
|
+
/>
|
|
1768
|
+
</label>
|
|
1769
|
+
<label class="field">
|
|
1770
|
+
<span>Unit</span>
|
|
1771
|
+
<select
|
|
1772
|
+
.value=${t.everyUnit}
|
|
1773
|
+
@change=${n=>e.onFormChange({everyUnit:n.target.value})}
|
|
1774
|
+
>
|
|
1775
|
+
<option value="minutes">Minutes</option>
|
|
1776
|
+
<option value="hours">Hours</option>
|
|
1777
|
+
<option value="days">Days</option>
|
|
1778
|
+
</select>
|
|
1779
|
+
</label>
|
|
1780
|
+
</div>
|
|
1781
|
+
`:c`
|
|
1782
|
+
<div class="form-grid" style="margin-top: 12px;">
|
|
1783
|
+
<label class="field">
|
|
1784
|
+
<span>Expression</span>
|
|
1785
|
+
<input
|
|
1786
|
+
.value=${t.cronExpr}
|
|
1787
|
+
@input=${n=>e.onFormChange({cronExpr:n.target.value})}
|
|
1788
|
+
/>
|
|
1789
|
+
</label>
|
|
1790
|
+
<label class="field">
|
|
1791
|
+
<span>Timezone (optional)</span>
|
|
1792
|
+
<input
|
|
1793
|
+
.value=${t.cronTz}
|
|
1794
|
+
@input=${n=>e.onFormChange({cronTz:n.target.value})}
|
|
1795
|
+
/>
|
|
1796
|
+
</label>
|
|
1797
|
+
</div>
|
|
1798
|
+
`}function qh(e,t){const s=`list-item list-item-clickable${t.runsJobId===e.id?" list-item-selected":""}`;return c`
|
|
1799
|
+
<div class=${s} @click=${()=>t.onLoadRuns(e.id)}>
|
|
1800
|
+
<div class="list-main">
|
|
1801
|
+
<div class="list-title">${e.name}</div>
|
|
1802
|
+
<div class="list-sub">${Fh(e)}</div>
|
|
1803
|
+
<div class="muted">${Uh(e)}</div>
|
|
1804
|
+
${e.agentId?c`<div class="muted">Agent: ${e.agentId}</div>`:f}
|
|
1805
|
+
<div class="chip-row" style="margin-top: 6px;">
|
|
1806
|
+
<span class="chip">${e.enabled?"enabled":"disabled"}</span>
|
|
1807
|
+
<span class="chip">${e.sessionTarget}</span>
|
|
1808
|
+
<span class="chip">${e.wakeMode}</span>
|
|
1809
|
+
</div>
|
|
1810
|
+
</div>
|
|
1811
|
+
<div class="list-meta">
|
|
1812
|
+
<div>${Bh(e)}</div>
|
|
1813
|
+
<div class="row" style="justify-content: flex-end; margin-top: 8px;">
|
|
1814
|
+
<button
|
|
1815
|
+
class="btn"
|
|
1816
|
+
?disabled=${t.busy}
|
|
1817
|
+
@click=${i=>{i.stopPropagation(),t.onToggle(e,!e.enabled)}}
|
|
1818
|
+
>
|
|
1819
|
+
${e.enabled?"Disable":"Enable"}
|
|
1820
|
+
</button>
|
|
1821
|
+
<button
|
|
1822
|
+
class="btn"
|
|
1823
|
+
?disabled=${t.busy}
|
|
1824
|
+
@click=${i=>{i.stopPropagation(),t.onRun(e)}}
|
|
1825
|
+
>
|
|
1826
|
+
Run
|
|
1827
|
+
</button>
|
|
1828
|
+
<button
|
|
1829
|
+
class="btn"
|
|
1830
|
+
?disabled=${t.busy}
|
|
1831
|
+
@click=${i=>{i.stopPropagation(),t.onLoadRuns(e.id)}}
|
|
1832
|
+
>
|
|
1833
|
+
Runs
|
|
1834
|
+
</button>
|
|
1835
|
+
<button
|
|
1836
|
+
class="btn danger"
|
|
1837
|
+
?disabled=${t.busy}
|
|
1838
|
+
@click=${i=>{i.stopPropagation(),t.onRemove(e)}}
|
|
1839
|
+
>
|
|
1840
|
+
Remove
|
|
1841
|
+
</button>
|
|
1842
|
+
</div>
|
|
1843
|
+
</div>
|
|
1844
|
+
</div>
|
|
1845
|
+
`}function Wh(e){return c`
|
|
1846
|
+
<div class="list-item">
|
|
1847
|
+
<div class="list-main">
|
|
1848
|
+
<div class="list-title">${e.status}</div>
|
|
1849
|
+
<div class="list-sub">${e.summary??""}</div>
|
|
1850
|
+
</div>
|
|
1851
|
+
<div class="list-meta">
|
|
1852
|
+
<div>${St(e.ts)}</div>
|
|
1853
|
+
<div class="muted">${e.durationMs??0}ms</div>
|
|
1854
|
+
${e.error?c`<div class="muted">${e.error}</div>`:f}
|
|
1855
|
+
</div>
|
|
1856
|
+
</div>
|
|
1857
|
+
`}function Vh(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",l=s>0?`${s} critical`:i>0?`${i} warnings`:"No critical issues";return c`
|
|
1858
|
+
<section class="grid grid-cols-2">
|
|
1859
|
+
<div class="card">
|
|
1860
|
+
<div class="row" style="justify-content: space-between;">
|
|
1861
|
+
<div>
|
|
1862
|
+
<div class="card-title">Snapshots</div>
|
|
1863
|
+
<div class="card-sub">Status, health, and heartbeat data.</div>
|
|
1864
|
+
</div>
|
|
1865
|
+
<button class="btn" ?disabled=${e.loading} @click=${e.onRefresh}>
|
|
1866
|
+
${e.loading?"Refreshing…":"Refresh"}
|
|
1867
|
+
</button>
|
|
1868
|
+
</div>
|
|
1869
|
+
<div class="stack" style="margin-top: 12px;">
|
|
1870
|
+
<div>
|
|
1871
|
+
<div class="muted">Status</div>
|
|
1872
|
+
${n?c`<div class="callout ${o}" style="margin-top: 8px;">
|
|
1873
|
+
Security audit: ${l}${a>0?` · ${a} info`:""}. Run
|
|
1874
|
+
<span class="mono">moltbot security audit --deep</span> for details.
|
|
1875
|
+
</div>`:f}
|
|
1876
|
+
<pre class="code-block">${JSON.stringify(e.status??{},null,2)}</pre>
|
|
1877
|
+
</div>
|
|
1878
|
+
<div>
|
|
1879
|
+
<div class="muted">Health</div>
|
|
1880
|
+
<pre class="code-block">${JSON.stringify(e.health??{},null,2)}</pre>
|
|
1881
|
+
</div>
|
|
1882
|
+
<div>
|
|
1883
|
+
<div class="muted">Last heartbeat</div>
|
|
1884
|
+
<pre class="code-block">${JSON.stringify(e.heartbeat??{},null,2)}</pre>
|
|
1885
|
+
</div>
|
|
1886
|
+
</div>
|
|
1887
|
+
</div>
|
|
1888
|
+
|
|
1889
|
+
<div class="card">
|
|
1890
|
+
<div class="card-title">Manual RPC</div>
|
|
1891
|
+
<div class="card-sub">Send a raw gateway method with JSON params.</div>
|
|
1892
|
+
<div class="form-grid" style="margin-top: 16px;">
|
|
1893
|
+
<label class="field">
|
|
1894
|
+
<span>Method</span>
|
|
1895
|
+
<input
|
|
1896
|
+
.value=${e.callMethod}
|
|
1897
|
+
@input=${r=>e.onCallMethodChange(r.target.value)}
|
|
1898
|
+
placeholder="system-presence"
|
|
1899
|
+
/>
|
|
1900
|
+
</label>
|
|
1901
|
+
<label class="field">
|
|
1902
|
+
<span>Params (JSON)</span>
|
|
1903
|
+
<textarea
|
|
1904
|
+
.value=${e.callParams}
|
|
1905
|
+
@input=${r=>e.onCallParamsChange(r.target.value)}
|
|
1906
|
+
rows="6"
|
|
1907
|
+
></textarea>
|
|
1908
|
+
</label>
|
|
1909
|
+
</div>
|
|
1910
|
+
<div class="row" style="margin-top: 12px;">
|
|
1911
|
+
<button class="btn primary" @click=${e.onCall}>Call</button>
|
|
1912
|
+
</div>
|
|
1913
|
+
${e.callError?c`<div class="callout danger" style="margin-top: 12px;">
|
|
1914
|
+
${e.callError}
|
|
1915
|
+
</div>`:f}
|
|
1916
|
+
${e.callResult?c`<pre class="code-block" style="margin-top: 12px;">${e.callResult}</pre>`:f}
|
|
1917
|
+
</div>
|
|
1918
|
+
</section>
|
|
1919
|
+
|
|
1920
|
+
<section class="card" style="margin-top: 18px;">
|
|
1921
|
+
<div class="card-title">Models</div>
|
|
1922
|
+
<div class="card-sub">Catalog from models.list.</div>
|
|
1923
|
+
<pre class="code-block" style="margin-top: 12px;">${JSON.stringify(e.models??[],null,2)}</pre>
|
|
1924
|
+
</section>
|
|
1925
|
+
|
|
1926
|
+
<section class="card" style="margin-top: 18px;">
|
|
1927
|
+
<div class="card-title">Event Log</div>
|
|
1928
|
+
<div class="card-sub">Latest gateway events.</div>
|
|
1929
|
+
${e.eventLog.length===0?c`<div class="muted" style="margin-top: 12px;">No events yet.</div>`:c`
|
|
1930
|
+
<div class="list" style="margin-top: 12px;">
|
|
1931
|
+
${e.eventLog.map(r=>c`
|
|
1932
|
+
<div class="list-item">
|
|
1933
|
+
<div class="list-main">
|
|
1934
|
+
<div class="list-title">${r.event}</div>
|
|
1935
|
+
<div class="list-sub">${new Date(r.ts).toLocaleTimeString()}</div>
|
|
1936
|
+
</div>
|
|
1937
|
+
<div class="list-meta">
|
|
1938
|
+
<pre class="code-block">${Dh(r.payload)}</pre>
|
|
1939
|
+
</div>
|
|
1940
|
+
</div>
|
|
1941
|
+
`)}
|
|
1942
|
+
</div>
|
|
1943
|
+
`}
|
|
1944
|
+
</section>
|
|
1945
|
+
`}function Gh(e){return c`
|
|
1946
|
+
<section class="card">
|
|
1947
|
+
<div class="row" style="justify-content: space-between;">
|
|
1948
|
+
<div>
|
|
1949
|
+
<div class="card-title">Connected Instances</div>
|
|
1950
|
+
<div class="card-sub">Presence beacons from the gateway and clients.</div>
|
|
1951
|
+
</div>
|
|
1952
|
+
<button class="btn" ?disabled=${e.loading} @click=${e.onRefresh}>
|
|
1953
|
+
${e.loading?"Loading…":"Refresh"}
|
|
1954
|
+
</button>
|
|
1955
|
+
</div>
|
|
1956
|
+
${e.lastError?c`<div class="callout danger" style="margin-top: 12px;">
|
|
1957
|
+
${e.lastError}
|
|
1958
|
+
</div>`:f}
|
|
1959
|
+
${e.statusMessage?c`<div class="callout" style="margin-top: 12px;">
|
|
1960
|
+
${e.statusMessage}
|
|
1961
|
+
</div>`:f}
|
|
1962
|
+
<div class="list" style="margin-top: 16px;">
|
|
1963
|
+
${e.entries.length===0?c`<div class="muted">No instances reported yet.</div>`:e.entries.map(t=>Yh(t))}
|
|
1964
|
+
</div>
|
|
1965
|
+
</section>
|
|
1966
|
+
`}function Yh(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`
|
|
1967
|
+
<div class="list-item">
|
|
1968
|
+
<div class="list-main">
|
|
1969
|
+
<div class="list-title">${e.host??"unknown host"}</div>
|
|
1970
|
+
<div class="list-sub">${Ph(e)}</div>
|
|
1971
|
+
<div class="chip-row">
|
|
1972
|
+
<span class="chip">${n}</span>
|
|
1973
|
+
${s.map(o=>c`<span class="chip">${o}</span>`)}
|
|
1974
|
+
${a?c`<span class="chip">${a}</span>`:f}
|
|
1975
|
+
${e.platform?c`<span class="chip">${e.platform}</span>`:f}
|
|
1976
|
+
${e.deviceFamily?c`<span class="chip">${e.deviceFamily}</span>`:f}
|
|
1977
|
+
${e.modelIdentifier?c`<span class="chip">${e.modelIdentifier}</span>`:f}
|
|
1978
|
+
${e.version?c`<span class="chip">${e.version}</span>`:f}
|
|
1979
|
+
</div>
|
|
1980
|
+
</div>
|
|
1981
|
+
<div class="list-meta">
|
|
1982
|
+
<div>${Nh(e)}</div>
|
|
1983
|
+
<div class="muted">Last input ${t}</div>
|
|
1984
|
+
<div class="muted">Reason ${e.reason??""}</div>
|
|
1985
|
+
</div>
|
|
1986
|
+
</div>
|
|
1987
|
+
`}const Ga=["trace","debug","info","warn","error","fatal"];function Qh(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function Zh(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Jh(e){const t=e.filterText.trim().toLowerCase(),n=Ga.some(a=>!e.levelFilters[a]),s=e.entries.filter(a=>a.level&&!e.levelFilters[a.level]?!1:Zh(a,t)),i=t||n?"filtered":"visible";return c`
|
|
1988
|
+
<section class="card">
|
|
1989
|
+
<div class="row" style="justify-content: space-between;">
|
|
1990
|
+
<div>
|
|
1991
|
+
<div class="card-title">Logs</div>
|
|
1992
|
+
<div class="card-sub">Gateway file logs (JSONL).</div>
|
|
1993
|
+
</div>
|
|
1994
|
+
<div class="row" style="gap: 8px;">
|
|
1995
|
+
<button class="btn" ?disabled=${e.loading} @click=${e.onRefresh}>
|
|
1996
|
+
${e.loading?"Loading…":"Refresh"}
|
|
1997
|
+
</button>
|
|
1998
|
+
<button
|
|
1999
|
+
class="btn"
|
|
2000
|
+
?disabled=${s.length===0}
|
|
2001
|
+
@click=${()=>e.onExport(s.map(a=>a.raw),i)}
|
|
2002
|
+
>
|
|
2003
|
+
Export ${i}
|
|
2004
|
+
</button>
|
|
2005
|
+
</div>
|
|
2006
|
+
</div>
|
|
2007
|
+
|
|
2008
|
+
<div class="filters" style="margin-top: 14px;">
|
|
2009
|
+
<label class="field" style="min-width: 220px;">
|
|
2010
|
+
<span>Filter</span>
|
|
2011
|
+
<input
|
|
2012
|
+
.value=${e.filterText}
|
|
2013
|
+
@input=${a=>e.onFilterTextChange(a.target.value)}
|
|
2014
|
+
placeholder="Search logs"
|
|
2015
|
+
/>
|
|
2016
|
+
</label>
|
|
2017
|
+
<label class="field checkbox">
|
|
2018
|
+
<span>Auto-follow</span>
|
|
2019
|
+
<input
|
|
2020
|
+
type="checkbox"
|
|
2021
|
+
.checked=${e.autoFollow}
|
|
2022
|
+
@change=${a=>e.onToggleAutoFollow(a.target.checked)}
|
|
2023
|
+
/>
|
|
2024
|
+
</label>
|
|
2025
|
+
</div>
|
|
2026
|
+
|
|
2027
|
+
<div class="chip-row" style="margin-top: 12px;">
|
|
2028
|
+
${Ga.map(a=>c`
|
|
2029
|
+
<label class="chip log-chip ${a}">
|
|
2030
|
+
<input
|
|
2031
|
+
type="checkbox"
|
|
2032
|
+
.checked=${e.levelFilters[a]}
|
|
2033
|
+
@change=${o=>e.onLevelToggle(a,o.target.checked)}
|
|
2034
|
+
/>
|
|
2035
|
+
<span>${a}</span>
|
|
2036
|
+
</label>
|
|
2037
|
+
`)}
|
|
2038
|
+
</div>
|
|
2039
|
+
|
|
2040
|
+
${e.file?c`<div class="muted" style="margin-top: 10px;">File: ${e.file}</div>`:f}
|
|
2041
|
+
${e.truncated?c`<div class="callout" style="margin-top: 10px;">
|
|
2042
|
+
Log output truncated; showing latest chunk.
|
|
2043
|
+
</div>`:f}
|
|
2044
|
+
${e.error?c`<div class="callout danger" style="margin-top: 10px;">${e.error}</div>`:f}
|
|
2045
|
+
|
|
2046
|
+
<div class="log-stream" style="margin-top: 12px;" @scroll=${e.onScroll}>
|
|
2047
|
+
${s.length===0?c`<div class="muted" style="padding: 12px;">No log entries.</div>`:s.map(a=>c`
|
|
2048
|
+
<div class="log-row">
|
|
2049
|
+
<div class="log-time mono">${Qh(a.time)}</div>
|
|
2050
|
+
<div class="log-level ${a.level??""}">${a.level??""}</div>
|
|
2051
|
+
<div class="log-subsystem mono">${a.subsystem??""}</div>
|
|
2052
|
+
<div class="log-message mono">${a.message??a.raw}</div>
|
|
2053
|
+
</div>
|
|
2054
|
+
`)}
|
|
2055
|
+
</div>
|
|
2056
|
+
</section>
|
|
2057
|
+
`}function Xh(e){const t=of(e),n=pf(e);return c`
|
|
2058
|
+
${ff(n)}
|
|
2059
|
+
${hf(t)}
|
|
2060
|
+
${ef(e)}
|
|
2061
|
+
<section class="card">
|
|
2062
|
+
<div class="row" style="justify-content: space-between;">
|
|
2063
|
+
<div>
|
|
2064
|
+
<div class="card-title">Nodes</div>
|
|
2065
|
+
<div class="card-sub">Paired devices and live links.</div>
|
|
2066
|
+
</div>
|
|
2067
|
+
<button class="btn" ?disabled=${e.loading} @click=${e.onRefresh}>
|
|
2068
|
+
${e.loading?"Loading…":"Refresh"}
|
|
2069
|
+
</button>
|
|
2070
|
+
</div>
|
|
2071
|
+
<div class="list" style="margin-top: 16px;">
|
|
2072
|
+
${e.nodes.length===0?c`<div class="muted">No nodes found.</div>`:e.nodes.map(s=>kf(s))}
|
|
2073
|
+
</div>
|
|
2074
|
+
</section>
|
|
2075
|
+
`}function ef(e){const t=e.devicesList??{pending:[],paired:[]},n=Array.isArray(t.pending)?t.pending:[],s=Array.isArray(t.paired)?t.paired:[];return c`
|
|
2076
|
+
<section class="card">
|
|
2077
|
+
<div class="row" style="justify-content: space-between;">
|
|
2078
|
+
<div>
|
|
2079
|
+
<div class="card-title">Devices</div>
|
|
2080
|
+
<div class="card-sub">Pairing requests + role tokens.</div>
|
|
2081
|
+
</div>
|
|
2082
|
+
<button class="btn" ?disabled=${e.devicesLoading} @click=${e.onDevicesRefresh}>
|
|
2083
|
+
${e.devicesLoading?"Loading…":"Refresh"}
|
|
2084
|
+
</button>
|
|
2085
|
+
</div>
|
|
2086
|
+
${e.devicesError?c`<div class="callout danger" style="margin-top: 12px;">${e.devicesError}</div>`:f}
|
|
2087
|
+
<div class="list" style="margin-top: 16px;">
|
|
2088
|
+
${n.length>0?c`
|
|
2089
|
+
<div class="muted" style="margin-bottom: 8px;">Pending</div>
|
|
2090
|
+
${n.map(i=>tf(i,e))}
|
|
2091
|
+
`:f}
|
|
2092
|
+
${s.length>0?c`
|
|
2093
|
+
<div class="muted" style="margin-top: 12px; margin-bottom: 8px;">Paired</div>
|
|
2094
|
+
${s.map(i=>nf(i,e))}
|
|
2095
|
+
`:f}
|
|
2096
|
+
${n.length===0&&s.length===0?c`<div class="muted">No paired devices.</div>`:f}
|
|
2097
|
+
</div>
|
|
2098
|
+
</section>
|
|
2099
|
+
`}function tf(e,t){const n=e.displayName?.trim()||e.deviceId,s=typeof e.ts=="number"?O(e.ts):"n/a",i=e.role?.trim()?`role: ${e.role}`:"role: -",a=e.isRepair?" · repair":"",o=e.remoteIp?` · ${e.remoteIp}`:"";return c`
|
|
2100
|
+
<div class="list-item">
|
|
2101
|
+
<div class="list-main">
|
|
2102
|
+
<div class="list-title">${n}</div>
|
|
2103
|
+
<div class="list-sub">${e.deviceId}${o}</div>
|
|
2104
|
+
<div class="muted" style="margin-top: 6px;">
|
|
2105
|
+
${i} · requested ${s}${a}
|
|
2106
|
+
</div>
|
|
2107
|
+
</div>
|
|
2108
|
+
<div class="list-meta">
|
|
2109
|
+
<div class="row" style="justify-content: flex-end; gap: 8px; flex-wrap: wrap;">
|
|
2110
|
+
<button class="btn btn--sm primary" @click=${()=>t.onDeviceApprove(e.requestId)}>
|
|
2111
|
+
Approve
|
|
2112
|
+
</button>
|
|
2113
|
+
<button class="btn btn--sm" @click=${()=>t.onDeviceReject(e.requestId)}>
|
|
2114
|
+
Reject
|
|
2115
|
+
</button>
|
|
2116
|
+
</div>
|
|
2117
|
+
</div>
|
|
2118
|
+
</div>
|
|
2119
|
+
`}function nf(e,t){const n=e.displayName?.trim()||e.deviceId,s=e.remoteIp?` · ${e.remoteIp}`:"",i=`roles: ${ls(e.roles)}`,a=`scopes: ${ls(e.scopes)}`,o=Array.isArray(e.tokens)?e.tokens:[];return c`
|
|
2120
|
+
<div class="list-item">
|
|
2121
|
+
<div class="list-main">
|
|
2122
|
+
<div class="list-title">${n}</div>
|
|
2123
|
+
<div class="list-sub">${e.deviceId}${s}</div>
|
|
2124
|
+
<div class="muted" style="margin-top: 6px;">${i} · ${a}</div>
|
|
2125
|
+
${o.length===0?c`<div class="muted" style="margin-top: 6px;">Tokens: none</div>`:c`
|
|
2126
|
+
<div class="muted" style="margin-top: 10px;">Tokens</div>
|
|
2127
|
+
<div style="display: flex; flex-direction: column; gap: 8px; margin-top: 6px;">
|
|
2128
|
+
${o.map(l=>sf(e.deviceId,l,t))}
|
|
2129
|
+
</div>
|
|
2130
|
+
`}
|
|
2131
|
+
</div>
|
|
2132
|
+
</div>
|
|
2133
|
+
`}function sf(e,t,n){const s=t.revokedAtMs?"revoked":"active",i=`scopes: ${ls(t.scopes)}`,a=O(t.rotatedAtMs??t.createdAtMs??t.lastUsedAtMs??null);return c`
|
|
2134
|
+
<div class="row" style="justify-content: space-between; gap: 8px;">
|
|
2135
|
+
<div class="list-sub">${t.role} · ${s} · ${i} · ${a}</div>
|
|
2136
|
+
<div class="row" style="justify-content: flex-end; gap: 6px; flex-wrap: wrap;">
|
|
2137
|
+
<button
|
|
2138
|
+
class="btn btn--sm"
|
|
2139
|
+
@click=${()=>n.onDeviceRotate(e,t.role,t.scopes)}
|
|
2140
|
+
>
|
|
2141
|
+
Rotate
|
|
2142
|
+
</button>
|
|
2143
|
+
${t.revokedAtMs?f:c`
|
|
2144
|
+
<button
|
|
2145
|
+
class="btn btn--sm danger"
|
|
2146
|
+
@click=${()=>n.onDeviceRevoke(e,t.role)}
|
|
2147
|
+
>
|
|
2148
|
+
Revoke
|
|
2149
|
+
</button>
|
|
2150
|
+
`}
|
|
2151
|
+
</div>
|
|
2152
|
+
</div>
|
|
2153
|
+
`}const ke="__defaults__",Ya=[{value:"deny",label:"Deny"},{value:"allowlist",label:"Allowlist"},{value:"full",label:"Full"}],af=[{value:"off",label:"Off"},{value:"on-miss",label:"On miss"},{value:"always",label:"Always"}];function of(e){const t=e.configForm,n=$f(e.nodes),{defaultBinding:s,agents:i}=Af(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 Qa(e){return e==="allowlist"||e==="full"||e==="deny"?e:"deny"}function rf(e){return e==="always"||e==="off"||e==="on-miss"?e:"on-miss"}function lf(e){const t=e?.defaults??{};return{security:Qa(t.security),ask:rf(t.ask),askFallback:Qa(t.askFallback??"deny"),autoAllowSkills:!!(t.autoAllowSkills??!1)}}function cf(e){const t=e?.agents??{},n=Array.isArray(t.list)?t.list:[],s=[];return n.forEach(i=>{if(!i||typeof i!="object")return;const a=i,o=typeof a.id=="string"?a.id.trim():"";if(!o)return;const l=typeof a.name=="string"?a.name.trim():void 0,r=a.default===!0;s.push({id:o,name:l||void 0,isDefault:r})}),s}function df(e,t){const n=cf(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,l)=>{if(o.isDefault&&!l.isDefault)return-1;if(!o.isDefault&&l.isDefault)return 1;const r=o.name?.trim()?o.name:o.id,p=l.name?.trim()?l.name:l.id;return r.localeCompare(p)}),a}function uf(e,t){return e===ke?ke:e&&t.some(n=>n.id===e)?e:ke}function pf(e){const t=e.execApprovalsForm??e.execApprovalsSnapshot?.file??null,n=!!t,s=lf(t),i=df(e.configForm,t),a=xf(e.nodes),o=e.execApprovalsTarget;let l=o==="node"&&e.execApprovalsTargetNodeId?e.execApprovalsTargetNodeId:null;o==="node"&&l&&!a.some(u=>u.id===l)&&(l=null);const r=uf(e.execApprovalsSelectedAgent,i),p=r!==ke?(t?.agents??{})[r]??null:null,d=Array.isArray(p?.allowlist)?p.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:p,agents:i,allowlist:d,target:o,targetNodeId:l,targetNodes:a,onSelectScope:e.onExecApprovalsSelectAgent,onSelectTarget:e.onExecApprovalsTargetChange,onPatch:e.onExecApprovalsPatch,onRemove:e.onExecApprovalsRemove,onLoad:e.onLoadExecApprovals,onSave:e.onSaveExecApprovals}}function hf(e){const t=e.nodes.length>0,n=e.defaultBinding??"";return c`
|
|
2154
|
+
<section class="card">
|
|
2155
|
+
<div class="row" style="justify-content: space-between; align-items: center;">
|
|
2156
|
+
<div>
|
|
2157
|
+
<div class="card-title">Exec node binding</div>
|
|
2158
|
+
<div class="card-sub">
|
|
2159
|
+
Pin agents to a specific node when using <span class="mono">exec host=node</span>.
|
|
2160
|
+
</div>
|
|
2161
|
+
</div>
|
|
2162
|
+
<button
|
|
2163
|
+
class="btn"
|
|
2164
|
+
?disabled=${e.disabled||!e.configDirty}
|
|
2165
|
+
@click=${e.onSave}
|
|
2166
|
+
>
|
|
2167
|
+
${e.configSaving?"Saving…":"Save"}
|
|
2168
|
+
</button>
|
|
2169
|
+
</div>
|
|
2170
|
+
|
|
2171
|
+
${e.formMode==="raw"?c`<div class="callout warn" style="margin-top: 12px;">
|
|
2172
|
+
Switch the Config tab to <strong>Form</strong> mode to edit bindings here.
|
|
2173
|
+
</div>`:f}
|
|
2174
|
+
|
|
2175
|
+
${e.ready?c`
|
|
2176
|
+
<div class="list" style="margin-top: 16px;">
|
|
2177
|
+
<div class="list-item">
|
|
2178
|
+
<div class="list-main">
|
|
2179
|
+
<div class="list-title">Default binding</div>
|
|
2180
|
+
<div class="list-sub">Used when agents do not override a node binding.</div>
|
|
2181
|
+
</div>
|
|
2182
|
+
<div class="list-meta">
|
|
2183
|
+
<label class="field">
|
|
2184
|
+
<span>Node</span>
|
|
2185
|
+
<select
|
|
2186
|
+
?disabled=${e.disabled||!t}
|
|
2187
|
+
@change=${s=>{const a=s.target.value.trim();e.onBindDefault(a||null)}}
|
|
2188
|
+
>
|
|
2189
|
+
<option value="" ?selected=${n===""}>Any node</option>
|
|
2190
|
+
${e.nodes.map(s=>c`<option
|
|
2191
|
+
value=${s.id}
|
|
2192
|
+
?selected=${n===s.id}
|
|
2193
|
+
>
|
|
2194
|
+
${s.label}
|
|
2195
|
+
</option>`)}
|
|
2196
|
+
</select>
|
|
2197
|
+
</label>
|
|
2198
|
+
${t?f:c`<div class="muted">No nodes with system.run available.</div>`}
|
|
2199
|
+
</div>
|
|
2200
|
+
</div>
|
|
2201
|
+
|
|
2202
|
+
${e.agents.length===0?c`<div class="muted">No agents found.</div>`:e.agents.map(s=>wf(s,e))}
|
|
2203
|
+
</div>
|
|
2204
|
+
`:c`<div class="row" style="margin-top: 12px; gap: 12px;">
|
|
2205
|
+
<div class="muted">Load config to edit bindings.</div>
|
|
2206
|
+
<button class="btn" ?disabled=${e.configLoading} @click=${e.onLoadConfig}>
|
|
2207
|
+
${e.configLoading?"Loading…":"Load config"}
|
|
2208
|
+
</button>
|
|
2209
|
+
</div>`}
|
|
2210
|
+
</section>
|
|
2211
|
+
`}function ff(e){const t=e.ready,n=e.target!=="node"||!!e.targetNodeId;return c`
|
|
2212
|
+
<section class="card">
|
|
2213
|
+
<div class="row" style="justify-content: space-between; align-items: center;">
|
|
2214
|
+
<div>
|
|
2215
|
+
<div class="card-title">Exec approvals</div>
|
|
2216
|
+
<div class="card-sub">
|
|
2217
|
+
Allowlist and approval policy for <span class="mono">exec host=gateway/node</span>.
|
|
2218
|
+
</div>
|
|
2219
|
+
</div>
|
|
2220
|
+
<button
|
|
2221
|
+
class="btn"
|
|
2222
|
+
?disabled=${e.disabled||!e.dirty||!n}
|
|
2223
|
+
@click=${e.onSave}
|
|
2224
|
+
>
|
|
2225
|
+
${e.saving?"Saving…":"Save"}
|
|
2226
|
+
</button>
|
|
2227
|
+
</div>
|
|
2228
|
+
|
|
2229
|
+
${gf(e)}
|
|
2230
|
+
|
|
2231
|
+
${t?c`
|
|
2232
|
+
${vf(e)}
|
|
2233
|
+
${mf(e)}
|
|
2234
|
+
${e.selectedScope===ke?f:yf(e)}
|
|
2235
|
+
`:c`<div class="row" style="margin-top: 12px; gap: 12px;">
|
|
2236
|
+
<div class="muted">Load exec approvals to edit allowlists.</div>
|
|
2237
|
+
<button class="btn" ?disabled=${e.loading||!n} @click=${e.onLoad}>
|
|
2238
|
+
${e.loading?"Loading…":"Load approvals"}
|
|
2239
|
+
</button>
|
|
2240
|
+
</div>`}
|
|
2241
|
+
</section>
|
|
2242
|
+
`}function gf(e){const t=e.targetNodes.length>0,n=e.targetNodeId??"";return c`
|
|
2243
|
+
<div class="list" style="margin-top: 12px;">
|
|
2244
|
+
<div class="list-item">
|
|
2245
|
+
<div class="list-main">
|
|
2246
|
+
<div class="list-title">Target</div>
|
|
2247
|
+
<div class="list-sub">
|
|
2248
|
+
Gateway edits local approvals; node edits the selected node.
|
|
2249
|
+
</div>
|
|
2250
|
+
</div>
|
|
2251
|
+
<div class="list-meta">
|
|
2252
|
+
<label class="field">
|
|
2253
|
+
<span>Host</span>
|
|
2254
|
+
<select
|
|
2255
|
+
?disabled=${e.disabled}
|
|
2256
|
+
@change=${s=>{if(s.target.value==="node"){const o=e.targetNodes[0]?.id??null;e.onSelectTarget("node",n||o)}else e.onSelectTarget("gateway",null)}}
|
|
2257
|
+
>
|
|
2258
|
+
<option value="gateway" ?selected=${e.target==="gateway"}>Gateway</option>
|
|
2259
|
+
<option value="node" ?selected=${e.target==="node"}>Node</option>
|
|
2260
|
+
</select>
|
|
2261
|
+
</label>
|
|
2262
|
+
${e.target==="node"?c`
|
|
2263
|
+
<label class="field">
|
|
2264
|
+
<span>Node</span>
|
|
2265
|
+
<select
|
|
2266
|
+
?disabled=${e.disabled||!t}
|
|
2267
|
+
@change=${s=>{const a=s.target.value.trim();e.onSelectTarget("node",a||null)}}
|
|
2268
|
+
>
|
|
2269
|
+
<option value="" ?selected=${n===""}>Select node</option>
|
|
2270
|
+
${e.targetNodes.map(s=>c`<option
|
|
2271
|
+
value=${s.id}
|
|
2272
|
+
?selected=${n===s.id}
|
|
2273
|
+
>
|
|
2274
|
+
${s.label}
|
|
2275
|
+
</option>`)}
|
|
2276
|
+
</select>
|
|
2277
|
+
</label>
|
|
2278
|
+
`:f}
|
|
2279
|
+
</div>
|
|
2280
|
+
</div>
|
|
2281
|
+
${e.target==="node"&&!t?c`<div class="muted">No nodes advertise exec approvals yet.</div>`:f}
|
|
2282
|
+
</div>
|
|
2283
|
+
`}function vf(e){return c`
|
|
2284
|
+
<div class="row" style="margin-top: 12px; gap: 8px; flex-wrap: wrap;">
|
|
2285
|
+
<span class="label">Scope</span>
|
|
2286
|
+
<div class="row" style="gap: 8px; flex-wrap: wrap;">
|
|
2287
|
+
<button
|
|
2288
|
+
class="btn btn--sm ${e.selectedScope===ke?"active":""}"
|
|
2289
|
+
@click=${()=>e.onSelectScope(ke)}
|
|
2290
|
+
>
|
|
2291
|
+
Defaults
|
|
2292
|
+
</button>
|
|
2293
|
+
${e.agents.map(t=>{const n=t.name?.trim()?`${t.name} (${t.id})`:t.id;return c`
|
|
2294
|
+
<button
|
|
2295
|
+
class="btn btn--sm ${e.selectedScope===t.id?"active":""}"
|
|
2296
|
+
@click=${()=>e.onSelectScope(t.id)}
|
|
2297
|
+
>
|
|
2298
|
+
${n}
|
|
2299
|
+
</button>
|
|
2300
|
+
`})}
|
|
2301
|
+
</div>
|
|
2302
|
+
</div>
|
|
2303
|
+
`}function mf(e){const t=e.selectedScope===ke,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,l=typeof s.askFallback=="string"?s.askFallback:void 0,r=t?n.security:a??"__default__",p=t?n.ask:o??"__default__",d=t?n.askFallback:l??"__default__",u=typeof s.autoAllowSkills=="boolean"?s.autoAllowSkills:void 0,g=u??n.autoAllowSkills,v=u==null;return c`
|
|
2304
|
+
<div class="list" style="margin-top: 16px;">
|
|
2305
|
+
<div class="list-item">
|
|
2306
|
+
<div class="list-main">
|
|
2307
|
+
<div class="list-title">Security</div>
|
|
2308
|
+
<div class="list-sub">
|
|
2309
|
+
${t?"Default security mode.":`Default: ${n.security}.`}
|
|
2310
|
+
</div>
|
|
2311
|
+
</div>
|
|
2312
|
+
<div class="list-meta">
|
|
2313
|
+
<label class="field">
|
|
2314
|
+
<span>Mode</span>
|
|
2315
|
+
<select
|
|
2316
|
+
?disabled=${e.disabled}
|
|
2317
|
+
@change=${m=>{const A=m.target.value;!t&&A==="__default__"?e.onRemove([...i,"security"]):e.onPatch([...i,"security"],A)}}
|
|
2318
|
+
>
|
|
2319
|
+
${t?f:c`<option value="__default__" ?selected=${r==="__default__"}>
|
|
2320
|
+
Use default (${n.security})
|
|
2321
|
+
</option>`}
|
|
2322
|
+
${Ya.map(m=>c`<option
|
|
2323
|
+
value=${m.value}
|
|
2324
|
+
?selected=${r===m.value}
|
|
2325
|
+
>
|
|
2326
|
+
${m.label}
|
|
2327
|
+
</option>`)}
|
|
2328
|
+
</select>
|
|
2329
|
+
</label>
|
|
2330
|
+
</div>
|
|
2331
|
+
</div>
|
|
2332
|
+
|
|
2333
|
+
<div class="list-item">
|
|
2334
|
+
<div class="list-main">
|
|
2335
|
+
<div class="list-title">Ask</div>
|
|
2336
|
+
<div class="list-sub">
|
|
2337
|
+
${t?"Default prompt policy.":`Default: ${n.ask}.`}
|
|
2338
|
+
</div>
|
|
2339
|
+
</div>
|
|
2340
|
+
<div class="list-meta">
|
|
2341
|
+
<label class="field">
|
|
2342
|
+
<span>Mode</span>
|
|
2343
|
+
<select
|
|
2344
|
+
?disabled=${e.disabled}
|
|
2345
|
+
@change=${m=>{const A=m.target.value;!t&&A==="__default__"?e.onRemove([...i,"ask"]):e.onPatch([...i,"ask"],A)}}
|
|
2346
|
+
>
|
|
2347
|
+
${t?f:c`<option value="__default__" ?selected=${p==="__default__"}>
|
|
2348
|
+
Use default (${n.ask})
|
|
2349
|
+
</option>`}
|
|
2350
|
+
${af.map(m=>c`<option
|
|
2351
|
+
value=${m.value}
|
|
2352
|
+
?selected=${p===m.value}
|
|
2353
|
+
>
|
|
2354
|
+
${m.label}
|
|
2355
|
+
</option>`)}
|
|
2356
|
+
</select>
|
|
2357
|
+
</label>
|
|
2358
|
+
</div>
|
|
2359
|
+
</div>
|
|
2360
|
+
|
|
2361
|
+
<div class="list-item">
|
|
2362
|
+
<div class="list-main">
|
|
2363
|
+
<div class="list-title">Ask fallback</div>
|
|
2364
|
+
<div class="list-sub">
|
|
2365
|
+
${t?"Applied when the UI prompt is unavailable.":`Default: ${n.askFallback}.`}
|
|
2366
|
+
</div>
|
|
2367
|
+
</div>
|
|
2368
|
+
<div class="list-meta">
|
|
2369
|
+
<label class="field">
|
|
2370
|
+
<span>Fallback</span>
|
|
2371
|
+
<select
|
|
2372
|
+
?disabled=${e.disabled}
|
|
2373
|
+
@change=${m=>{const A=m.target.value;!t&&A==="__default__"?e.onRemove([...i,"askFallback"]):e.onPatch([...i,"askFallback"],A)}}
|
|
2374
|
+
>
|
|
2375
|
+
${t?f:c`<option value="__default__" ?selected=${d==="__default__"}>
|
|
2376
|
+
Use default (${n.askFallback})
|
|
2377
|
+
</option>`}
|
|
2378
|
+
${Ya.map(m=>c`<option
|
|
2379
|
+
value=${m.value}
|
|
2380
|
+
?selected=${d===m.value}
|
|
2381
|
+
>
|
|
2382
|
+
${m.label}
|
|
2383
|
+
</option>`)}
|
|
2384
|
+
</select>
|
|
2385
|
+
</label>
|
|
2386
|
+
</div>
|
|
2387
|
+
</div>
|
|
2388
|
+
|
|
2389
|
+
<div class="list-item">
|
|
2390
|
+
<div class="list-main">
|
|
2391
|
+
<div class="list-title">Auto-allow skill CLIs</div>
|
|
2392
|
+
<div class="list-sub">
|
|
2393
|
+
${t?"Allow skill executables listed by the Gateway.":v?`Using default (${n.autoAllowSkills?"on":"off"}).`:`Override (${g?"on":"off"}).`}
|
|
2394
|
+
</div>
|
|
2395
|
+
</div>
|
|
2396
|
+
<div class="list-meta">
|
|
2397
|
+
<label class="field">
|
|
2398
|
+
<span>Enabled</span>
|
|
2399
|
+
<input
|
|
2400
|
+
type="checkbox"
|
|
2401
|
+
?disabled=${e.disabled}
|
|
2402
|
+
.checked=${g}
|
|
2403
|
+
@change=${m=>{const $=m.target;e.onPatch([...i,"autoAllowSkills"],$.checked)}}
|
|
2404
|
+
/>
|
|
2405
|
+
</label>
|
|
2406
|
+
${!t&&!v?c`<button
|
|
2407
|
+
class="btn btn--sm"
|
|
2408
|
+
?disabled=${e.disabled}
|
|
2409
|
+
@click=${()=>e.onRemove([...i,"autoAllowSkills"])}
|
|
2410
|
+
>
|
|
2411
|
+
Use default
|
|
2412
|
+
</button>`:f}
|
|
2413
|
+
</div>
|
|
2414
|
+
</div>
|
|
2415
|
+
</div>
|
|
2416
|
+
`}function yf(e){const t=["agents",e.selectedScope,"allowlist"],n=e.allowlist;return c`
|
|
2417
|
+
<div class="row" style="margin-top: 18px; justify-content: space-between;">
|
|
2418
|
+
<div>
|
|
2419
|
+
<div class="card-title">Allowlist</div>
|
|
2420
|
+
<div class="card-sub">Case-insensitive glob patterns.</div>
|
|
2421
|
+
</div>
|
|
2422
|
+
<button
|
|
2423
|
+
class="btn btn--sm"
|
|
2424
|
+
?disabled=${e.disabled}
|
|
2425
|
+
@click=${()=>{const s=[...n,{pattern:""}];e.onPatch(t,s)}}
|
|
2426
|
+
>
|
|
2427
|
+
Add pattern
|
|
2428
|
+
</button>
|
|
2429
|
+
</div>
|
|
2430
|
+
<div class="list" style="margin-top: 12px;">
|
|
2431
|
+
${n.length===0?c`<div class="muted">No allowlist entries yet.</div>`:n.map((s,i)=>bf(e,s,i))}
|
|
2432
|
+
</div>
|
|
2433
|
+
`}function bf(e,t,n){const s=t.lastUsedAt?O(t.lastUsedAt):"never",i=t.lastUsedCommand?cs(t.lastUsedCommand,120):null,a=t.lastResolvedPath?cs(t.lastResolvedPath,120):null;return c`
|
|
2434
|
+
<div class="list-item">
|
|
2435
|
+
<div class="list-main">
|
|
2436
|
+
<div class="list-title">${t.pattern?.trim()?t.pattern:"New pattern"}</div>
|
|
2437
|
+
<div class="list-sub">Last used: ${s}</div>
|
|
2438
|
+
${i?c`<div class="list-sub mono">${i}</div>`:f}
|
|
2439
|
+
${a?c`<div class="list-sub mono">${a}</div>`:f}
|
|
2440
|
+
</div>
|
|
2441
|
+
<div class="list-meta">
|
|
2442
|
+
<label class="field">
|
|
2443
|
+
<span>Pattern</span>
|
|
2444
|
+
<input
|
|
2445
|
+
type="text"
|
|
2446
|
+
.value=${t.pattern??""}
|
|
2447
|
+
?disabled=${e.disabled}
|
|
2448
|
+
@input=${o=>{const l=o.target;e.onPatch(["agents",e.selectedScope,"allowlist",n,"pattern"],l.value)}}
|
|
2449
|
+
/>
|
|
2450
|
+
</label>
|
|
2451
|
+
<button
|
|
2452
|
+
class="btn btn--sm danger"
|
|
2453
|
+
?disabled=${e.disabled}
|
|
2454
|
+
@click=${()=>{if(e.allowlist.length<=1){e.onRemove(["agents",e.selectedScope,"allowlist"]);return}e.onRemove(["agents",e.selectedScope,"allowlist",n])}}
|
|
2455
|
+
>
|
|
2456
|
+
Remove
|
|
2457
|
+
</button>
|
|
2458
|
+
</div>
|
|
2459
|
+
</div>
|
|
2460
|
+
`}function wf(e,t){const n=e.binding??"__default__",s=e.name?.trim()?`${e.name} (${e.id})`:e.id,i=t.nodes.length>0;return c`
|
|
2461
|
+
<div class="list-item">
|
|
2462
|
+
<div class="list-main">
|
|
2463
|
+
<div class="list-title">${s}</div>
|
|
2464
|
+
<div class="list-sub">
|
|
2465
|
+
${e.isDefault?"default agent":"agent"} ·
|
|
2466
|
+
${n==="__default__"?`uses default (${t.defaultBinding??"any"})`:`override: ${e.binding}`}
|
|
2467
|
+
</div>
|
|
2468
|
+
</div>
|
|
2469
|
+
<div class="list-meta">
|
|
2470
|
+
<label class="field">
|
|
2471
|
+
<span>Binding</span>
|
|
2472
|
+
<select
|
|
2473
|
+
?disabled=${t.disabled||!i}
|
|
2474
|
+
@change=${a=>{const l=a.target.value.trim();t.onBindAgent(e.index,l==="__default__"?null:l)}}
|
|
2475
|
+
>
|
|
2476
|
+
<option value="__default__" ?selected=${n==="__default__"}>
|
|
2477
|
+
Use default
|
|
2478
|
+
</option>
|
|
2479
|
+
${t.nodes.map(a=>c`<option
|
|
2480
|
+
value=${a.id}
|
|
2481
|
+
?selected=${n===a.id}
|
|
2482
|
+
>
|
|
2483
|
+
${a.label}
|
|
2484
|
+
</option>`)}
|
|
2485
|
+
</select>
|
|
2486
|
+
</label>
|
|
2487
|
+
</div>
|
|
2488
|
+
</div>
|
|
2489
|
+
`}function $f(e){const t=[];for(const n of e){if(!(Array.isArray(n.commands)?n.commands:[]).some(l=>String(l)==="system.run"))continue;const a=typeof n.nodeId=="string"?n.nodeId.trim():"";if(!a)continue;const o=typeof n.displayName=="string"&&n.displayName.trim()?n.displayName.trim():a;t.push({id:a,label:o===a?a:`${o} · ${a}`})}return t.sort((n,s)=>n.label.localeCompare(s.label)),t}function xf(e){const t=[];for(const n of e){if(!(Array.isArray(n.commands)?n.commands:[]).some(l=>String(l)==="system.execApprovals.get"||String(l)==="system.execApprovals.set"))continue;const a=typeof n.nodeId=="string"?n.nodeId.trim():"";if(!a)continue;const o=typeof n.displayName=="string"&&n.displayName.trim()?n.displayName.trim():a;t.push({id:a,label:o===a?a:`${o} · ${a}`})}return t.sort((n,s)=>n.label.localeCompare(s.label)),t}function Af(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??{},o=Array.isArray(a.list)?a.list:[];if(o.length===0)return{defaultBinding:i,agents:[t]};const l=[];return o.forEach((r,p)=>{if(!r||typeof r!="object")return;const d=r,u=typeof d.id=="string"?d.id.trim():"";if(!u)return;const g=typeof d.name=="string"?d.name.trim():void 0,v=d.default===!0,$=(d.tools??{}).exec??{},A=typeof $.node=="string"&&$.node.trim()?$.node.trim():null;l.push({id:u,name:g||void 0,index:p,isDefault:v,binding:A})}),l.length===0&&l.push(t),{defaultBinding:i,agents:l}}function kf(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`
|
|
2490
|
+
<div class="list-item">
|
|
2491
|
+
<div class="list-main">
|
|
2492
|
+
<div class="list-title">${s}</div>
|
|
2493
|
+
<div class="list-sub">
|
|
2494
|
+
${typeof e.nodeId=="string"?e.nodeId:""}
|
|
2495
|
+
${typeof e.remoteIp=="string"?` · ${e.remoteIp}`:""}
|
|
2496
|
+
${typeof e.version=="string"?` · ${e.version}`:""}
|
|
2497
|
+
</div>
|
|
2498
|
+
<div class="chip-row" style="margin-top: 6px;">
|
|
2499
|
+
<span class="chip">${n?"paired":"unpaired"}</span>
|
|
2500
|
+
<span class="chip ${t?"chip-ok":"chip-warn"}">
|
|
2501
|
+
${t?"connected":"offline"}
|
|
2502
|
+
</span>
|
|
2503
|
+
${i.slice(0,12).map(o=>c`<span class="chip">${String(o)}</span>`)}
|
|
2504
|
+
${a.slice(0,8).map(o=>c`<span class="chip">${String(o)}</span>`)}
|
|
2505
|
+
</div>
|
|
2506
|
+
</div>
|
|
2507
|
+
</div>
|
|
2508
|
+
`}function Sf(e){const t=e.hello?.snapshot,n=t?.uptimeMs?ho(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 r=!!e.settings.token.trim(),p=!!e.password.trim();return!r&&!p?c`
|
|
2509
|
+
<div class="muted" style="margin-top: 8px;">
|
|
2510
|
+
This gateway requires auth. Add a token or password, then click Connect.
|
|
2511
|
+
<div style="margin-top: 6px;">
|
|
2512
|
+
<span class="mono">moltbot dashboard --no-open</span> → tokenized URL<br />
|
|
2513
|
+
<span class="mono">moltbot doctor --generate-gateway-token</span> → set token
|
|
2514
|
+
</div>
|
|
2515
|
+
<div style="margin-top: 6px;">
|
|
2516
|
+
<a
|
|
2517
|
+
class="session-link"
|
|
2518
|
+
href="https://docs.molt.bot/web/dashboard"
|
|
2519
|
+
target="_blank"
|
|
2520
|
+
rel="noreferrer"
|
|
2521
|
+
title="Control UI auth docs (opens in new tab)"
|
|
2522
|
+
>Docs: Control UI auth</a
|
|
2523
|
+
>
|
|
2524
|
+
</div>
|
|
2525
|
+
</div>
|
|
2526
|
+
`:c`
|
|
2527
|
+
<div class="muted" style="margin-top: 8px;">
|
|
2528
|
+
Auth failed. Re-copy a tokenized URL with
|
|
2529
|
+
<span class="mono">moltbot dashboard --no-open</span>, or update the token,
|
|
2530
|
+
then click Connect.
|
|
2531
|
+
<div style="margin-top: 6px;">
|
|
2532
|
+
<a
|
|
2533
|
+
class="session-link"
|
|
2534
|
+
href="https://docs.molt.bot/web/dashboard"
|
|
2535
|
+
target="_blank"
|
|
2536
|
+
rel="noreferrer"
|
|
2537
|
+
title="Control UI auth docs (opens in new tab)"
|
|
2538
|
+
>Docs: Control UI auth</a
|
|
2539
|
+
>
|
|
2540
|
+
</div>
|
|
2541
|
+
</div>
|
|
2542
|
+
`})(),a=(()=>{if(e.connected||!e.lastError||(typeof window<"u"?window.isSecureContext:!0)!==!1)return null;const l=e.lastError.toLowerCase();return!l.includes("secure context")&&!l.includes("device identity required")?null:c`
|
|
2543
|
+
<div class="muted" style="margin-top: 8px;">
|
|
2544
|
+
This page is HTTP, so the browser blocks device identity. Use HTTPS (Tailscale Serve) or
|
|
2545
|
+
open <span class="mono">http://127.0.0.1:18789</span> on the gateway host.
|
|
2546
|
+
<div style="margin-top: 6px;">
|
|
2547
|
+
If you must stay on HTTP, set
|
|
2548
|
+
<span class="mono">gateway.controlUi.allowInsecureAuth: true</span> (token-only).
|
|
2549
|
+
</div>
|
|
2550
|
+
<div style="margin-top: 6px;">
|
|
2551
|
+
<a
|
|
2552
|
+
class="session-link"
|
|
2553
|
+
href="https://docs.molt.bot/gateway/tailscale"
|
|
2554
|
+
target="_blank"
|
|
2555
|
+
rel="noreferrer"
|
|
2556
|
+
title="Tailscale Serve docs (opens in new tab)"
|
|
2557
|
+
>Docs: Tailscale Serve</a
|
|
2558
|
+
>
|
|
2559
|
+
<span class="muted"> · </span>
|
|
2560
|
+
<a
|
|
2561
|
+
class="session-link"
|
|
2562
|
+
href="https://docs.molt.bot/web/control-ui#insecure-http"
|
|
2563
|
+
target="_blank"
|
|
2564
|
+
rel="noreferrer"
|
|
2565
|
+
title="Insecure HTTP docs (opens in new tab)"
|
|
2566
|
+
>Docs: Insecure HTTP</a
|
|
2567
|
+
>
|
|
2568
|
+
</div>
|
|
2569
|
+
</div>
|
|
2570
|
+
`})();return c`
|
|
2571
|
+
<section class="grid grid-cols-2">
|
|
2572
|
+
<div class="card">
|
|
2573
|
+
<div class="card-title">Gateway Access</div>
|
|
2574
|
+
<div class="card-sub">Where the dashboard connects and how it authenticates.</div>
|
|
2575
|
+
<div class="form-grid" style="margin-top: 16px;">
|
|
2576
|
+
<label class="field">
|
|
2577
|
+
<span>WebSocket URL</span>
|
|
2578
|
+
<input
|
|
2579
|
+
.value=${e.settings.gatewayUrl}
|
|
2580
|
+
@input=${o=>{const l=o.target.value;e.onSettingsChange({...e.settings,gatewayUrl:l})}}
|
|
2581
|
+
placeholder="ws://100.x.y.z:18789"
|
|
2582
|
+
/>
|
|
2583
|
+
</label>
|
|
2584
|
+
<label class="field">
|
|
2585
|
+
<span>Gateway Token</span>
|
|
2586
|
+
<input
|
|
2587
|
+
.value=${e.settings.token}
|
|
2588
|
+
@input=${o=>{const l=o.target.value;e.onSettingsChange({...e.settings,token:l})}}
|
|
2589
|
+
placeholder="CLAWDBOT_GATEWAY_TOKEN"
|
|
2590
|
+
/>
|
|
2591
|
+
</label>
|
|
2592
|
+
<label class="field">
|
|
2593
|
+
<span>Password (not stored)</span>
|
|
2594
|
+
<input
|
|
2595
|
+
type="password"
|
|
2596
|
+
.value=${e.password}
|
|
2597
|
+
@input=${o=>{const l=o.target.value;e.onPasswordChange(l)}}
|
|
2598
|
+
placeholder="system or shared password"
|
|
2599
|
+
/>
|
|
2600
|
+
</label>
|
|
2601
|
+
<label class="field">
|
|
2602
|
+
<span>Default Session Key</span>
|
|
2603
|
+
<input
|
|
2604
|
+
.value=${e.settings.sessionKey}
|
|
2605
|
+
@input=${o=>{const l=o.target.value;e.onSessionKeyChange(l)}}
|
|
2606
|
+
/>
|
|
2607
|
+
</label>
|
|
2608
|
+
</div>
|
|
2609
|
+
<div class="row" style="margin-top: 14px;">
|
|
2610
|
+
<button class="btn" @click=${()=>e.onConnect()}>Connect</button>
|
|
2611
|
+
<button class="btn" @click=${()=>e.onRefresh()}>Refresh</button>
|
|
2612
|
+
<span class="muted">Click Connect to apply connection changes.</span>
|
|
2613
|
+
</div>
|
|
2614
|
+
</div>
|
|
2615
|
+
|
|
2616
|
+
<div class="card">
|
|
2617
|
+
<div class="card-title">Snapshot</div>
|
|
2618
|
+
<div class="card-sub">Latest gateway handshake information.</div>
|
|
2619
|
+
<div class="stat-grid" style="margin-top: 16px;">
|
|
2620
|
+
<div class="stat">
|
|
2621
|
+
<div class="stat-label">Status</div>
|
|
2622
|
+
<div class="stat-value ${e.connected?"ok":"warn"}">
|
|
2623
|
+
${e.connected?"Connected":"Disconnected"}
|
|
2624
|
+
</div>
|
|
2625
|
+
</div>
|
|
2626
|
+
<div class="stat">
|
|
2627
|
+
<div class="stat-label">Uptime</div>
|
|
2628
|
+
<div class="stat-value">${n}</div>
|
|
2629
|
+
</div>
|
|
2630
|
+
<div class="stat">
|
|
2631
|
+
<div class="stat-label">Tick Interval</div>
|
|
2632
|
+
<div class="stat-value">${s}</div>
|
|
2633
|
+
</div>
|
|
2634
|
+
<div class="stat">
|
|
2635
|
+
<div class="stat-label">Last Channels Refresh</div>
|
|
2636
|
+
<div class="stat-value">
|
|
2637
|
+
${e.lastChannelsRefresh?O(e.lastChannelsRefresh):"n/a"}
|
|
2638
|
+
</div>
|
|
2639
|
+
</div>
|
|
2640
|
+
</div>
|
|
2641
|
+
${e.lastError?c`<div class="callout danger" style="margin-top: 14px;">
|
|
2642
|
+
<div>${e.lastError}</div>
|
|
2643
|
+
${i??""}
|
|
2644
|
+
${a??""}
|
|
2645
|
+
</div>`:c`<div class="callout" style="margin-top: 14px;">
|
|
2646
|
+
Use Channels to link WhatsApp, Telegram, Discord, Signal, or iMessage.
|
|
2647
|
+
</div>`}
|
|
2648
|
+
</div>
|
|
2649
|
+
</section>
|
|
2650
|
+
|
|
2651
|
+
<section class="grid grid-cols-3" style="margin-top: 18px;">
|
|
2652
|
+
<div class="card stat-card">
|
|
2653
|
+
<div class="stat-label">Instances</div>
|
|
2654
|
+
<div class="stat-value">${e.presenceCount}</div>
|
|
2655
|
+
<div class="muted">Presence beacons in the last 5 minutes.</div>
|
|
2656
|
+
</div>
|
|
2657
|
+
<div class="card stat-card">
|
|
2658
|
+
<div class="stat-label">Sessions</div>
|
|
2659
|
+
<div class="stat-value">${e.sessionsCount??"n/a"}</div>
|
|
2660
|
+
<div class="muted">Recent session keys tracked by the gateway.</div>
|
|
2661
|
+
</div>
|
|
2662
|
+
<div class="card stat-card">
|
|
2663
|
+
<div class="stat-label">Cron</div>
|
|
2664
|
+
<div class="stat-value">
|
|
2665
|
+
${e.cronEnabled==null?"n/a":e.cronEnabled?"Enabled":"Disabled"}
|
|
2666
|
+
</div>
|
|
2667
|
+
<div class="muted">Next wake ${$r(e.cronNext)}</div>
|
|
2668
|
+
</div>
|
|
2669
|
+
</section>
|
|
2670
|
+
|
|
2671
|
+
<section class="card" style="margin-top: 18px;">
|
|
2672
|
+
<div class="card-title">Notes</div>
|
|
2673
|
+
<div class="card-sub">Quick reminders for remote control setups.</div>
|
|
2674
|
+
<div class="note-grid" style="margin-top: 14px;">
|
|
2675
|
+
<div>
|
|
2676
|
+
<div class="note-title">Tailscale serve</div>
|
|
2677
|
+
<div class="muted">
|
|
2678
|
+
Prefer serve mode to keep the gateway on loopback with tailnet auth.
|
|
2679
|
+
</div>
|
|
2680
|
+
</div>
|
|
2681
|
+
<div>
|
|
2682
|
+
<div class="note-title">Session hygiene</div>
|
|
2683
|
+
<div class="muted">Use /new or sessions.patch to reset context.</div>
|
|
2684
|
+
</div>
|
|
2685
|
+
<div>
|
|
2686
|
+
<div class="note-title">Cron reminders</div>
|
|
2687
|
+
<div class="muted">Use isolated sessions for recurring runs.</div>
|
|
2688
|
+
</div>
|
|
2689
|
+
</div>
|
|
2690
|
+
</section>
|
|
2691
|
+
`}const _f=["","off","minimal","low","medium","high"],Tf=["","off","on"],Cf=[{value:"",label:"inherit"},{value:"off",label:"off (explicit)"},{value:"on",label:"on"}],Ef=["","off","on","stream"];function Mf(e){if(!e)return"";const t=e.trim().toLowerCase();return t==="z.ai"||t==="z-ai"?"zai":t}function xr(e){return Mf(e)==="zai"}function If(e){return xr(e)?Tf:_f}function Lf(e,t){return!t||!e||e==="off"?e:"on"}function Rf(e,t){return e?t&&e==="on"?"low":e:null}function Pf(e){const t=e.result?.sessions??[];return c`
|
|
2692
|
+
<section class="card">
|
|
2693
|
+
<div class="row" style="justify-content: space-between;">
|
|
2694
|
+
<div>
|
|
2695
|
+
<div class="card-title">Sessions</div>
|
|
2696
|
+
<div class="card-sub">Active session keys and per-session overrides.</div>
|
|
2697
|
+
</div>
|
|
2698
|
+
<button class="btn" ?disabled=${e.loading} @click=${e.onRefresh}>
|
|
2699
|
+
${e.loading?"Loading…":"Refresh"}
|
|
2700
|
+
</button>
|
|
2701
|
+
</div>
|
|
2702
|
+
|
|
2703
|
+
<div class="filters" style="margin-top: 14px;">
|
|
2704
|
+
<label class="field">
|
|
2705
|
+
<span>Active within (minutes)</span>
|
|
2706
|
+
<input
|
|
2707
|
+
.value=${e.activeMinutes}
|
|
2708
|
+
@input=${n=>e.onFiltersChange({activeMinutes:n.target.value,limit:e.limit,includeGlobal:e.includeGlobal,includeUnknown:e.includeUnknown})}
|
|
2709
|
+
/>
|
|
2710
|
+
</label>
|
|
2711
|
+
<label class="field">
|
|
2712
|
+
<span>Limit</span>
|
|
2713
|
+
<input
|
|
2714
|
+
.value=${e.limit}
|
|
2715
|
+
@input=${n=>e.onFiltersChange({activeMinutes:e.activeMinutes,limit:n.target.value,includeGlobal:e.includeGlobal,includeUnknown:e.includeUnknown})}
|
|
2716
|
+
/>
|
|
2717
|
+
</label>
|
|
2718
|
+
<label class="field checkbox">
|
|
2719
|
+
<span>Include global</span>
|
|
2720
|
+
<input
|
|
2721
|
+
type="checkbox"
|
|
2722
|
+
.checked=${e.includeGlobal}
|
|
2723
|
+
@change=${n=>e.onFiltersChange({activeMinutes:e.activeMinutes,limit:e.limit,includeGlobal:n.target.checked,includeUnknown:e.includeUnknown})}
|
|
2724
|
+
/>
|
|
2725
|
+
</label>
|
|
2726
|
+
<label class="field checkbox">
|
|
2727
|
+
<span>Include unknown</span>
|
|
2728
|
+
<input
|
|
2729
|
+
type="checkbox"
|
|
2730
|
+
.checked=${e.includeUnknown}
|
|
2731
|
+
@change=${n=>e.onFiltersChange({activeMinutes:e.activeMinutes,limit:e.limit,includeGlobal:e.includeGlobal,includeUnknown:n.target.checked})}
|
|
2732
|
+
/>
|
|
2733
|
+
</label>
|
|
2734
|
+
</div>
|
|
2735
|
+
|
|
2736
|
+
${e.error?c`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:f}
|
|
2737
|
+
|
|
2738
|
+
<div class="muted" style="margin-top: 12px;">
|
|
2739
|
+
${e.result?`Store: ${e.result.path}`:""}
|
|
2740
|
+
</div>
|
|
2741
|
+
|
|
2742
|
+
<div class="table" style="margin-top: 16px;">
|
|
2743
|
+
<div class="table-head">
|
|
2744
|
+
<div>Key</div>
|
|
2745
|
+
<div>Label</div>
|
|
2746
|
+
<div>Kind</div>
|
|
2747
|
+
<div>Updated</div>
|
|
2748
|
+
<div>Tokens</div>
|
|
2749
|
+
<div>Thinking</div>
|
|
2750
|
+
<div>Verbose</div>
|
|
2751
|
+
<div>Reasoning</div>
|
|
2752
|
+
<div>Actions</div>
|
|
2753
|
+
</div>
|
|
2754
|
+
${t.length===0?c`<div class="muted">No sessions found.</div>`:t.map(n=>Nf(n,e.basePath,e.onPatch,e.onDelete,e.loading))}
|
|
2755
|
+
</div>
|
|
2756
|
+
</section>
|
|
2757
|
+
`}function Nf(e,t,n,s,i){const a=e.updatedAt?O(e.updatedAt):"n/a",o=e.thinkingLevel??"",l=xr(e.modelProvider),r=Lf(o,l),p=If(e.modelProvider),d=e.verboseLevel??"",u=e.reasoningLevel??"",g=e.displayName??e.key,v=e.kind!=="global",m=v?`${Ds("chat",t)}?session=${encodeURIComponent(e.key)}`:null;return c`
|
|
2758
|
+
<div class="table-row">
|
|
2759
|
+
<div class="mono">${v?c`<a href=${m} class="session-link">${g}</a>`:g}</div>
|
|
2760
|
+
<div>
|
|
2761
|
+
<input
|
|
2762
|
+
.value=${e.label??""}
|
|
2763
|
+
?disabled=${i}
|
|
2764
|
+
placeholder="(optional)"
|
|
2765
|
+
@change=${$=>{const A=$.target.value.trim();n(e.key,{label:A||null})}}
|
|
2766
|
+
/>
|
|
2767
|
+
</div>
|
|
2768
|
+
<div>${e.kind}</div>
|
|
2769
|
+
<div>${a}</div>
|
|
2770
|
+
<div>${Oh(e)}</div>
|
|
2771
|
+
<div>
|
|
2772
|
+
<select
|
|
2773
|
+
.value=${r}
|
|
2774
|
+
?disabled=${i}
|
|
2775
|
+
@change=${$=>{const A=$.target.value;n(e.key,{thinkingLevel:Rf(A,l)})}}
|
|
2776
|
+
>
|
|
2777
|
+
${p.map($=>c`<option value=${$}>${$||"inherit"}</option>`)}
|
|
2778
|
+
</select>
|
|
2779
|
+
</div>
|
|
2780
|
+
<div>
|
|
2781
|
+
<select
|
|
2782
|
+
.value=${d}
|
|
2783
|
+
?disabled=${i}
|
|
2784
|
+
@change=${$=>{const A=$.target.value;n(e.key,{verboseLevel:A||null})}}
|
|
2785
|
+
>
|
|
2786
|
+
${Cf.map($=>c`<option value=${$.value}>${$.label}</option>`)}
|
|
2787
|
+
</select>
|
|
2788
|
+
</div>
|
|
2789
|
+
<div>
|
|
2790
|
+
<select
|
|
2791
|
+
.value=${u}
|
|
2792
|
+
?disabled=${i}
|
|
2793
|
+
@change=${$=>{const A=$.target.value;n(e.key,{reasoningLevel:A||null})}}
|
|
2794
|
+
>
|
|
2795
|
+
${Ef.map($=>c`<option value=${$}>${$||"inherit"}</option>`)}
|
|
2796
|
+
</select>
|
|
2797
|
+
</div>
|
|
2798
|
+
<div>
|
|
2799
|
+
<button class="btn danger" ?disabled=${i} @click=${()=>s(e.key)}>
|
|
2800
|
+
Delete
|
|
2801
|
+
</button>
|
|
2802
|
+
</div>
|
|
2803
|
+
</div>
|
|
2804
|
+
`}function Of(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 Le(e,t){return t?c`<div class="exec-approval-meta-row"><span>${e}</span><span>${t}</span></div>`:f}function Df(e){const t=e.execApprovalQueue[0];if(!t)return f;const n=t.request,s=t.expiresAtMs-Date.now(),i=s>0?`expires in ${Of(s)}`:"expired",a=e.execApprovalQueue.length;return c`
|
|
2805
|
+
<div class="exec-approval-overlay" role="dialog" aria-live="polite">
|
|
2806
|
+
<div class="exec-approval-card">
|
|
2807
|
+
<div class="exec-approval-header">
|
|
2808
|
+
<div>
|
|
2809
|
+
<div class="exec-approval-title">Exec approval needed</div>
|
|
2810
|
+
<div class="exec-approval-sub">${i}</div>
|
|
2811
|
+
</div>
|
|
2812
|
+
${a>1?c`<div class="exec-approval-queue">${a} pending</div>`:f}
|
|
2813
|
+
</div>
|
|
2814
|
+
<div class="exec-approval-command mono">${n.command}</div>
|
|
2815
|
+
<div class="exec-approval-meta">
|
|
2816
|
+
${Le("Host",n.host)}
|
|
2817
|
+
${Le("Agent",n.agentId)}
|
|
2818
|
+
${Le("Session",n.sessionKey)}
|
|
2819
|
+
${Le("CWD",n.cwd)}
|
|
2820
|
+
${Le("Resolved",n.resolvedPath)}
|
|
2821
|
+
${Le("Security",n.security)}
|
|
2822
|
+
${Le("Ask",n.ask)}
|
|
2823
|
+
</div>
|
|
2824
|
+
${e.execApprovalError?c`<div class="exec-approval-error">${e.execApprovalError}</div>`:f}
|
|
2825
|
+
<div class="exec-approval-actions">
|
|
2826
|
+
<button
|
|
2827
|
+
class="btn primary"
|
|
2828
|
+
?disabled=${e.execApprovalBusy}
|
|
2829
|
+
@click=${()=>e.handleExecApprovalDecision("allow-once")}
|
|
2830
|
+
>
|
|
2831
|
+
Allow once
|
|
2832
|
+
</button>
|
|
2833
|
+
<button
|
|
2834
|
+
class="btn"
|
|
2835
|
+
?disabled=${e.execApprovalBusy}
|
|
2836
|
+
@click=${()=>e.handleExecApprovalDecision("allow-always")}
|
|
2837
|
+
>
|
|
2838
|
+
Always allow
|
|
2839
|
+
</button>
|
|
2840
|
+
<button
|
|
2841
|
+
class="btn danger"
|
|
2842
|
+
?disabled=${e.execApprovalBusy}
|
|
2843
|
+
@click=${()=>e.handleExecApprovalDecision("deny")}
|
|
2844
|
+
>
|
|
2845
|
+
Deny
|
|
2846
|
+
</button>
|
|
2847
|
+
</div>
|
|
2848
|
+
</div>
|
|
2849
|
+
</div>
|
|
2850
|
+
`}function Bf(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`
|
|
2851
|
+
<section class="card">
|
|
2852
|
+
<div class="row" style="justify-content: space-between;">
|
|
2853
|
+
<div>
|
|
2854
|
+
<div class="card-title">Skills</div>
|
|
2855
|
+
<div class="card-sub">Bundled, managed, and workspace skills.</div>
|
|
2856
|
+
</div>
|
|
2857
|
+
<button class="btn" ?disabled=${e.loading} @click=${e.onRefresh}>
|
|
2858
|
+
${e.loading?"Loading…":"Refresh"}
|
|
2859
|
+
</button>
|
|
2860
|
+
</div>
|
|
2861
|
+
|
|
2862
|
+
<div class="filters" style="margin-top: 14px;">
|
|
2863
|
+
<label class="field" style="flex: 1;">
|
|
2864
|
+
<span>Filter</span>
|
|
2865
|
+
<input
|
|
2866
|
+
.value=${e.filter}
|
|
2867
|
+
@input=${i=>e.onFilterChange(i.target.value)}
|
|
2868
|
+
placeholder="Search skills"
|
|
2869
|
+
/>
|
|
2870
|
+
</label>
|
|
2871
|
+
<div class="muted">${s.length} shown</div>
|
|
2872
|
+
</div>
|
|
2873
|
+
|
|
2874
|
+
${e.error?c`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:f}
|
|
2875
|
+
|
|
2876
|
+
${s.length===0?c`<div class="muted" style="margin-top: 16px;">No skills found.</div>`:c`
|
|
2877
|
+
<div class="list" style="margin-top: 16px;">
|
|
2878
|
+
${s.map(i=>Ff(i,e))}
|
|
2879
|
+
</div>
|
|
2880
|
+
`}
|
|
2881
|
+
</section>
|
|
2882
|
+
`}function Ff(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}`)],l=[];return e.disabled&&l.push("disabled"),e.blockedByAllowlist&&l.push("blocked by allowlist"),c`
|
|
2883
|
+
<div class="list-item">
|
|
2884
|
+
<div class="list-main">
|
|
2885
|
+
<div class="list-title">
|
|
2886
|
+
${e.emoji?`${e.emoji} `:""}${e.name}
|
|
2887
|
+
</div>
|
|
2888
|
+
<div class="list-sub">${cs(e.description,140)}</div>
|
|
2889
|
+
<div class="chip-row" style="margin-top: 6px;">
|
|
2890
|
+
<span class="chip">${e.source}</span>
|
|
2891
|
+
<span class="chip ${e.eligible?"chip-ok":"chip-warn"}">
|
|
2892
|
+
${e.eligible?"eligible":"blocked"}
|
|
2893
|
+
</span>
|
|
2894
|
+
${e.disabled?c`<span class="chip chip-warn">disabled</span>`:f}
|
|
2895
|
+
</div>
|
|
2896
|
+
${o.length>0?c`
|
|
2897
|
+
<div class="muted" style="margin-top: 6px;">
|
|
2898
|
+
Missing: ${o.join(", ")}
|
|
2899
|
+
</div>
|
|
2900
|
+
`:f}
|
|
2901
|
+
${l.length>0?c`
|
|
2902
|
+
<div class="muted" style="margin-top: 6px;">
|
|
2903
|
+
Reason: ${l.join(", ")}
|
|
2904
|
+
</div>
|
|
2905
|
+
`:f}
|
|
2906
|
+
</div>
|
|
2907
|
+
<div class="list-meta">
|
|
2908
|
+
<div class="row" style="justify-content: flex-end; flex-wrap: wrap;">
|
|
2909
|
+
<button
|
|
2910
|
+
class="btn"
|
|
2911
|
+
?disabled=${n}
|
|
2912
|
+
@click=${()=>t.onToggle(e.skillKey,e.disabled)}
|
|
2913
|
+
>
|
|
2914
|
+
${e.disabled?"Enable":"Disable"}
|
|
2915
|
+
</button>
|
|
2916
|
+
${a?c`<button
|
|
2917
|
+
class="btn"
|
|
2918
|
+
?disabled=${n}
|
|
2919
|
+
@click=${()=>t.onInstall(e.skillKey,e.name,e.install[0].id)}
|
|
2920
|
+
>
|
|
2921
|
+
${n?"Installing…":e.install[0].label}
|
|
2922
|
+
</button>`:f}
|
|
2923
|
+
</div>
|
|
2924
|
+
${i?c`<div
|
|
2925
|
+
class="muted"
|
|
2926
|
+
style="margin-top: 8px; color: ${i.kind==="error"?"var(--danger-color, #d14343)":"var(--success-color, #0a7f5a)"};"
|
|
2927
|
+
>
|
|
2928
|
+
${i.message}
|
|
2929
|
+
</div>`:f}
|
|
2930
|
+
${e.primaryEnv?c`
|
|
2931
|
+
<div class="field" style="margin-top: 10px;">
|
|
2932
|
+
<span>API key</span>
|
|
2933
|
+
<input
|
|
2934
|
+
type="password"
|
|
2935
|
+
.value=${s}
|
|
2936
|
+
@input=${r=>t.onEdit(e.skillKey,r.target.value)}
|
|
2937
|
+
/>
|
|
2938
|
+
</div>
|
|
2939
|
+
<button
|
|
2940
|
+
class="btn primary"
|
|
2941
|
+
style="margin-top: 8px;"
|
|
2942
|
+
?disabled=${n}
|
|
2943
|
+
@click=${()=>t.onSaveKey(e.skillKey)}
|
|
2944
|
+
>
|
|
2945
|
+
Save key
|
|
2946
|
+
</button>
|
|
2947
|
+
`:f}
|
|
2948
|
+
</div>
|
|
2949
|
+
</div>
|
|
2950
|
+
`}function Uf(e,t){const n=Ds(t,e.basePath);return c`
|
|
2951
|
+
<a
|
|
2952
|
+
href=${n}
|
|
2953
|
+
class="nav-item ${e.tab===t?"active":""}"
|
|
2954
|
+
@click=${s=>{s.defaultPrevented||s.button!==0||s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||(s.preventDefault(),e.setTab(t))}}
|
|
2955
|
+
title=${rs(t)}
|
|
2956
|
+
>
|
|
2957
|
+
<span class="nav-item__icon" aria-hidden="true">${V[xl(t)]}</span>
|
|
2958
|
+
<span class="nav-item__text">${rs(t)}</span>
|
|
2959
|
+
</a>
|
|
2960
|
+
`}function Kf(e){const t=Hf(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>`,l=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`
|
|
2961
|
+
<div class="chat-controls">
|
|
2962
|
+
<label class="field chat-controls__session">
|
|
2963
|
+
<select
|
|
2964
|
+
.value=${e.sessionKey}
|
|
2965
|
+
?disabled=${!e.connected}
|
|
2966
|
+
@change=${r=>{const p=r.target.value;e.sessionKey=p,e.chatMessage="",e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:p,lastActiveSessionKey:p}),e.loadAssistantIdentity(),xd(e,p),Xe(e)}}
|
|
2967
|
+
>
|
|
2968
|
+
${Go(t,r=>r.key,r=>c`<option value=${r.key}>
|
|
2969
|
+
${r.displayName??r.key}
|
|
2970
|
+
</option>`)}
|
|
2971
|
+
</select>
|
|
2972
|
+
</label>
|
|
2973
|
+
<button
|
|
2974
|
+
class="btn btn--sm btn--icon"
|
|
2975
|
+
?disabled=${e.chatLoading||!e.connected}
|
|
2976
|
+
@click=${()=>{e.resetToolStream(),Xe(e)}}
|
|
2977
|
+
title="Refresh chat history"
|
|
2978
|
+
>
|
|
2979
|
+
${o}
|
|
2980
|
+
</button>
|
|
2981
|
+
<span class="chat-controls__separator">|</span>
|
|
2982
|
+
<button
|
|
2983
|
+
class="btn btn--sm btn--icon ${i?"active":""}"
|
|
2984
|
+
?disabled=${n}
|
|
2985
|
+
@click=${()=>{n||e.applySettings({...e.settings,chatShowThinking:!e.settings.chatShowThinking})}}
|
|
2986
|
+
aria-pressed=${i}
|
|
2987
|
+
title=${n?"Disabled during onboarding":"Toggle assistant thinking/working output"}
|
|
2988
|
+
>
|
|
2989
|
+
${V.brain}
|
|
2990
|
+
</button>
|
|
2991
|
+
<button
|
|
2992
|
+
class="btn btn--sm btn--icon ${a?"active":""}"
|
|
2993
|
+
?disabled=${s}
|
|
2994
|
+
@click=${()=>{s||e.applySettings({...e.settings,chatFocusMode:!e.settings.chatFocusMode})}}
|
|
2995
|
+
aria-pressed=${a}
|
|
2996
|
+
title=${s?"Disabled during onboarding":"Toggle focus mode (hide sidebar + page header)"}
|
|
2997
|
+
>
|
|
2998
|
+
${l}
|
|
2999
|
+
</button>
|
|
3000
|
+
</div>
|
|
3001
|
+
`}function Hf(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 zf=["system","light","dark"];function jf(e){const t=Math.max(0,zf.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`
|
|
3002
|
+
<div class="theme-toggle" style="--theme-index: ${t};">
|
|
3003
|
+
<div class="theme-toggle__track" role="group" aria-label="Theme">
|
|
3004
|
+
<span class="theme-toggle__indicator"></span>
|
|
3005
|
+
<button
|
|
3006
|
+
class="theme-toggle__button ${e.theme==="system"?"active":""}"
|
|
3007
|
+
@click=${n("system")}
|
|
3008
|
+
aria-pressed=${e.theme==="system"}
|
|
3009
|
+
aria-label="System theme"
|
|
3010
|
+
title="System"
|
|
3011
|
+
>
|
|
3012
|
+
${Vf()}
|
|
3013
|
+
</button>
|
|
3014
|
+
<button
|
|
3015
|
+
class="theme-toggle__button ${e.theme==="light"?"active":""}"
|
|
3016
|
+
@click=${n("light")}
|
|
3017
|
+
aria-pressed=${e.theme==="light"}
|
|
3018
|
+
aria-label="Light theme"
|
|
3019
|
+
title="Light"
|
|
3020
|
+
>
|
|
3021
|
+
${qf()}
|
|
3022
|
+
</button>
|
|
3023
|
+
<button
|
|
3024
|
+
class="theme-toggle__button ${e.theme==="dark"?"active":""}"
|
|
3025
|
+
@click=${n("dark")}
|
|
3026
|
+
aria-pressed=${e.theme==="dark"}
|
|
3027
|
+
aria-label="Dark theme"
|
|
3028
|
+
title="Dark"
|
|
3029
|
+
>
|
|
3030
|
+
${Wf()}
|
|
3031
|
+
</button>
|
|
3032
|
+
</div>
|
|
3033
|
+
</div>
|
|
3034
|
+
`}function qf(){return c`
|
|
3035
|
+
<svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
|
|
3036
|
+
<circle cx="12" cy="12" r="4"></circle>
|
|
3037
|
+
<path d="M12 2v2"></path>
|
|
3038
|
+
<path d="M12 20v2"></path>
|
|
3039
|
+
<path d="m4.93 4.93 1.41 1.41"></path>
|
|
3040
|
+
<path d="m17.66 17.66 1.41 1.41"></path>
|
|
3041
|
+
<path d="M2 12h2"></path>
|
|
3042
|
+
<path d="M20 12h2"></path>
|
|
3043
|
+
<path d="m6.34 17.66-1.41 1.41"></path>
|
|
3044
|
+
<path d="m19.07 4.93-1.41 1.41"></path>
|
|
3045
|
+
</svg>
|
|
3046
|
+
`}function Wf(){return c`
|
|
3047
|
+
<svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
|
|
3048
|
+
<path
|
|
3049
|
+
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"
|
|
3050
|
+
></path>
|
|
3051
|
+
</svg>
|
|
3052
|
+
`}function Vf(){return c`
|
|
3053
|
+
<svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
|
|
3054
|
+
<rect width="20" height="14" x="2" y="3" rx="2"></rect>
|
|
3055
|
+
<line x1="8" x2="16" y1="21" y2="21"></line>
|
|
3056
|
+
<line x1="12" x2="12" y1="17" y2="21"></line>
|
|
3057
|
+
</svg>
|
|
3058
|
+
`}const Gf=/^data:/i,Yf=/^https?:\/\//i;function Qf(e){const t=e.agentsList?.agents??[],s=lo(e.sessionKey)?.agentId??e.agentsList?.defaultId??"main",a=t.find(l=>l.id===s)?.identity,o=a?.avatarUrl??a?.avatar;if(o)return Gf.test(o)||Yf.test(o)?o:a?.avatarUrl}function Zf(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),l=e.onboarding?!1:e.settings.chatShowThinking,r=Qf(e),p=e.chatAvatarUrl??r??null;return c`
|
|
3059
|
+
<div class="shell ${a?"shell--chat":""} ${o?"shell--chat-focus":""} ${e.settings.navCollapsed?"shell--nav-collapsed":""} ${e.onboarding?"shell--onboarding":""}">
|
|
3060
|
+
<header class="topbar">
|
|
3061
|
+
<div class="topbar-left">
|
|
3062
|
+
<button
|
|
3063
|
+
class="nav-collapse-toggle"
|
|
3064
|
+
@click=${()=>e.applySettings({...e.settings,navCollapsed:!e.settings.navCollapsed})}
|
|
3065
|
+
title="${e.settings.navCollapsed?"Expand sidebar":"Collapse sidebar"}"
|
|
3066
|
+
aria-label="${e.settings.navCollapsed?"Expand sidebar":"Collapse sidebar"}"
|
|
3067
|
+
>
|
|
3068
|
+
<span class="nav-collapse-toggle__icon">${V.menu}</span>
|
|
3069
|
+
</button>
|
|
3070
|
+
<div class="brand">
|
|
3071
|
+
<div class="brand-logo">
|
|
3072
|
+
<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="Moltbot" />
|
|
3073
|
+
</div>
|
|
3074
|
+
<div class="brand-text">
|
|
3075
|
+
<div class="brand-title">MOLTBOT</div>
|
|
3076
|
+
<div class="brand-sub">Gateway Dashboard</div>
|
|
3077
|
+
</div>
|
|
3078
|
+
</div>
|
|
3079
|
+
</div>
|
|
3080
|
+
<div class="topbar-status">
|
|
3081
|
+
<div class="pill">
|
|
3082
|
+
<span class="statusDot ${e.connected?"ok":""}"></span>
|
|
3083
|
+
<span>Health</span>
|
|
3084
|
+
<span class="mono">${e.connected?"OK":"Offline"}</span>
|
|
3085
|
+
</div>
|
|
3086
|
+
${jf(e)}
|
|
3087
|
+
</div>
|
|
3088
|
+
</header>
|
|
3089
|
+
<aside class="nav ${e.settings.navCollapsed?"nav--collapsed":""}">
|
|
3090
|
+
${wl.map(d=>{const u=e.settings.navGroupsCollapsed[d.label]??!1,g=d.tabs.some(v=>v===e.tab);return c`
|
|
3091
|
+
<div class="nav-group ${u&&!g?"nav-group--collapsed":""}">
|
|
3092
|
+
<button
|
|
3093
|
+
class="nav-label"
|
|
3094
|
+
@click=${()=>{const v={...e.settings.navGroupsCollapsed};v[d.label]=!u,e.applySettings({...e.settings,navGroupsCollapsed:v})}}
|
|
3095
|
+
aria-expanded=${!u}
|
|
3096
|
+
>
|
|
3097
|
+
<span class="nav-label__text">${d.label}</span>
|
|
3098
|
+
<span class="nav-label__chevron">${u?"+":"−"}</span>
|
|
3099
|
+
</button>
|
|
3100
|
+
<div class="nav-group__items">
|
|
3101
|
+
${d.tabs.map(v=>Uf(e,v))}
|
|
3102
|
+
</div>
|
|
3103
|
+
</div>
|
|
3104
|
+
`})}
|
|
3105
|
+
<div class="nav-group nav-group--links">
|
|
3106
|
+
<div class="nav-label nav-label--static">
|
|
3107
|
+
<span class="nav-label__text">Resources</span>
|
|
3108
|
+
</div>
|
|
3109
|
+
<div class="nav-group__items">
|
|
3110
|
+
<a
|
|
3111
|
+
class="nav-item nav-item--external"
|
|
3112
|
+
href="https://docs.molt.bot"
|
|
3113
|
+
target="_blank"
|
|
3114
|
+
rel="noreferrer"
|
|
3115
|
+
title="Docs (opens in new tab)"
|
|
3116
|
+
>
|
|
3117
|
+
<span class="nav-item__icon" aria-hidden="true">${V.book}</span>
|
|
3118
|
+
<span class="nav-item__text">Docs</span>
|
|
3119
|
+
</a>
|
|
3120
|
+
</div>
|
|
3121
|
+
</div>
|
|
3122
|
+
</aside>
|
|
3123
|
+
<main class="content ${a?"content--chat":""}">
|
|
3124
|
+
<section class="content-header">
|
|
3125
|
+
<div>
|
|
3126
|
+
<div class="page-title">${rs(e.tab)}</div>
|
|
3127
|
+
<div class="page-sub">${Al(e.tab)}</div>
|
|
3128
|
+
</div>
|
|
3129
|
+
<div class="page-meta">
|
|
3130
|
+
${e.lastError?c`<div class="pill danger">${e.lastError}</div>`:f}
|
|
3131
|
+
${a?Kf(e):f}
|
|
3132
|
+
</div>
|
|
3133
|
+
</section>
|
|
3134
|
+
|
|
3135
|
+
${e.tab==="overview"?Sf({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()}):f}
|
|
3136
|
+
|
|
3137
|
+
${e.tab==="channels"?kh({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=>oe(e,d),onWhatsAppStart:d=>e.handleWhatsAppStart(d),onWhatsAppWait:()=>e.handleWhatsAppWait(),onWhatsAppLogout:()=>e.handleWhatsAppLogout(),onConfigPatch:(d,u)=>Ft(e,d,u),onConfigSave:()=>e.handleChannelConfigSave(),onConfigReload:()=>e.handleChannelConfigReload(),onNostrProfileEdit:(d,u)=>e.handleNostrProfileEdit(d,u),onNostrProfileCancel:()=>e.handleNostrProfileCancel(),onNostrProfileFieldChange:(d,u)=>e.handleNostrProfileFieldChange(d,u),onNostrProfileSave:()=>e.handleNostrProfileSave(),onNostrProfileImport:()=>e.handleNostrProfileImport(),onNostrProfileToggleAdvanced:()=>e.handleNostrProfileToggleAdvanced()}):f}
|
|
3138
|
+
|
|
3139
|
+
${e.tab==="instances"?Gh({loading:e.presenceLoading,entries:e.presenceEntries,lastError:e.presenceError,statusMessage:e.presenceStatus,onRefresh:()=>Vs(e)}):f}
|
|
3140
|
+
|
|
3141
|
+
${e.tab==="sessions"?Pf({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:()=>st(e),onPatch:(d,u)=>Fl(e,d,u),onDelete:d=>Ul(e,d)}):f}
|
|
3142
|
+
|
|
3143
|
+
${e.tab==="cron"?zh({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:()=>lc(e),onToggle:(d,u)=>cc(e,d,u),onRun:d=>dc(e,d),onRemove:d=>uc(e,d),onLoadRuns:d=>wo(e,d)}):f}
|
|
3144
|
+
|
|
3145
|
+
${e.tab==="skills"?Bf({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:()=>Et(e,{clearMessages:!0}),onToggle:(d,u)=>ad(e,d,u),onEdit:(d,u)=>id(e,d,u),onSaveKey:d=>od(e,d),onInstall:(d,u,g)=>rd(e,d,u,g)}):f}
|
|
3146
|
+
|
|
3147
|
+
${e.tab==="nodes"?Xh({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:()=>gn(e),onDevicesRefresh:()=>Te(e),onDeviceApprove:d=>Gc(e,d),onDeviceReject:d=>Yc(e,d),onDeviceRotate:(d,u,g)=>Qc(e,{deviceId:d,role:u,scopes:g}),onDeviceRevoke:(d,u)=>Zc(e,{deviceId:d,role:u}),onLoadConfig:()=>ye(e),onLoadExecApprovals:()=>{const d=e.execApprovalsTarget==="node"&&e.execApprovalsTargetNodeId?{kind:"node",nodeId:e.execApprovalsTargetNodeId}:{kind:"gateway"};return Ws(e,d)},onBindDefault:d=>{d?Ft(e,["tools","exec","node"],d):ia(e,["tools","exec","node"])},onBindAgent:(d,u)=>{const g=["agents","list",d,"tools","exec","node"];u?Ft(e,g,u):ia(e,g)},onSaveBindings:()=>ps(e),onExecApprovalsTargetChange:(d,u)=>{e.execApprovalsTarget=d,e.execApprovalsTargetNodeId=u,e.execApprovalsSnapshot=null,e.execApprovalsForm=null,e.execApprovalsDirty=!1,e.execApprovalsSelectedAgent=null},onExecApprovalsSelectAgent:d=>{e.execApprovalsSelectedAgent=d},onExecApprovalsPatch:(d,u)=>nd(e,d,u),onExecApprovalsRemove:d=>sd(e,d),onSaveExecApprovals:()=>{const d=e.execApprovalsTarget==="node"&&e.execApprovalsTargetNodeId?{kind:"node",nodeId:e.execApprovalsTargetNodeId}:{kind:"gateway"};return td(e,d)}}):f}
|
|
3148
|
+
|
|
3149
|
+
${e.tab==="chat"?Hp({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(),Xe(e),ms(e)},thinkingLevel:e.chatThinkingLevel,showThinking:l,loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:p,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([Xe(e),ms(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}):f}
|
|
3150
|
+
|
|
3151
|
+
${e.tab==="config"?oh({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,u)=>Ft(e,d,u),onSearchChange:d=>e.configSearchQuery=d,onSectionChange:d=>{e.configActiveSection=d,e.configActiveSubsection=null},onSubsectionChange:d=>e.configActiveSubsection=d,onReload:()=>ye(e),onSave:()=>ps(e),onApply:()=>ic(e),onUpdate:()=>ac(e)}):f}
|
|
3152
|
+
|
|
3153
|
+
${e.tab==="debug"?Vh({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:()=>hn(e),onCall:()=>gc(e)}):f}
|
|
3154
|
+
|
|
3155
|
+
${e.tab==="logs"?Jh({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,u)=>{e.logsLevelFilters={...e.logsLevelFilters,[d]:u}},onToggleAutoFollow:d=>e.logsAutoFollow=d,onRefresh:()=>Fs(e,{reset:!0}),onExport:(d,u)=>e.exportLogs(d,u),onScroll:d=>e.handleLogsScroll(d)}):f}
|
|
3156
|
+
</main>
|
|
3157
|
+
${Df(e)}
|
|
3158
|
+
</div>
|
|
3159
|
+
`}const Jf={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Xf={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 eg(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 Ar={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"moltbot-control-ui",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"moltbot-macos",IOS_APP:"moltbot-ios",ANDROID_APP:"moltbot-android",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"moltbot-probe"},Za=Ar,Es={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Ar));new Set(Object.values(Es));function tg(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 sg{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 zs();const d=Vc({deviceId:i.deviceId,role:s})?.token;o=d??this.opts.token,a=!!(d&&this.opts.token)}const l=o||this.opts.password?{token:o,password:this.opts.password}:void 0;let r;if(t&&i){const d=Date.now(),u=this.connectNonce??void 0,g=tg({deviceId:i.deviceId,clientId:this.opts.clientName??Za.CONTROL_UI,clientMode:this.opts.mode??Es.WEBCHAT,role:s,scopes:n,signedAtMs:d,token:o??null,nonce:u}),v=await qc(i.privateKey,g);r={id:i.deviceId,publicKey:i.publicKey,signature:v,signedAt:d,nonce:u}}const p={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Za.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Es.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:r,caps:[],auth:l,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",p).then(d=>{d?.auth?.deviceToken&&i&&Do({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&&Bo({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,l=o&&typeof o.nonce=="string"?o.nonce:null;l&&(this.connectNonce=l,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=Bs(),i={type:"req",id:s,method:t,params:n},a=new Promise((o,l)=>{this.pending.set(s,{resolve:r=>o(r),reject:l})});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 Ms(e){return typeof e=="object"&&e!==null}function ig(e){if(!Ms(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Ms(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 ag(e){if(!Ms(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 kr(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function og(e,t){const n=kr(e).filter(s=>s.id!==t.id);return n.push(t),n}function Ja(e,t){return kr(e).filter(n=>n.id!==t)}async function Sr(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=os(i);e.assistantName=a.name,e.assistantAvatar=a.avatar,e.assistantAgentId=a.agentId??null}catch{}}function ss(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 rg(e,t){if(!t?.mainSessionKey)return;const n=ss(e.sessionKey,t),s=ss(e.settings.sessionKey,t),i=ss(e.settings.lastActiveSessionKey,t),a=n||s||e.sessionKey,o={...e.settings,sessionKey:s||a,lastActiveSessionKey:i||a},l=o.sessionKey!==e.settings.sessionKey||o.lastActiveSessionKey!==e.settings.lastActiveSessionKey;a!==e.sessionKey&&(e.sessionKey=a),l&&Ae(e,o)}function _r(e){e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null,e.client?.stop(),e.client=new sg({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:"moltbot-control-ui",mode:"webchat",onHello:t=>{e.connected=!0,e.lastError=null,e.hello=t,dg(e,t),e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,dn(e),Sr(e),eg(e),gn(e,{quiet:!0}),Te(e,{quiet:!0}),Xs(e)},onClose:({code:t,reason:n})=>{e.connected=!1,t!==1012&&(e.lastError=`disconnected (${t}): ${n||"no reason"}`)},onEvent:t=>lg(e,t),onGap:({expected:t,received:n})=>{e.lastError=`event gap detected (expected seq ${t}, got ${n}); refresh recommended`}}),e.client.start()}function lg(e,t){try{cg(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function cg(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;Ql(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n?.sessionKey&&Fo(e,n.sessionKey);const s=Bl(e,n);(s==="final"||s==="error"||s==="aborted")&&(dn(e),Ed(e)),s==="final"&&Xe(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"&&ei(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&Te(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=ig(t.payload);if(n){e.execApprovalQueue=og(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=Ja(e.execApprovalQueue,n.id)},s)}return}if(t.event==="exec.approval.resolved"){const n=ag(t.payload);n&&(e.execApprovalQueue=Ja(e.execApprovalQueue,n.id))}}function dg(e,t){const n=t.snapshot;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n?.health&&(e.debugHealth=n.health),n?.sessionDefaults&&rg(e,n.sessionDefaults)}function ug(e){e.basePath=vd(),wd(e,!0),md(e),yd(e),window.addEventListener("popstate",e.popStateHandler),hd(e),_r(e),ud(e),e.tab==="logs"&&Ys(e),e.tab==="debug"&&Zs(e)}function pg(e){tc(e)}function hg(e){window.removeEventListener("popstate",e.popStateHandler),pd(e),Qs(e),Js(e),bd(e),e.topbarObserver?.disconnect(),e.topbarObserver=null}function fg(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;un(e,n||s||!e.chatHasAutoScrolled)}e.tab==="logs"&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&vo(e,t.has("tab")||t.has("logsAutoFollow"))}async function gg(e,t){await pc(e,t),await oe(e,!0)}async function vg(e){await hc(e),await oe(e,!0)}async function mg(e){await fc(e),await oe(e,!0)}async function yg(e){await ps(e),await ye(e),await oe(e,!0)}async function bg(e){await ye(e),await oe(e,!0)}function wg(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 Tr(e){return(e.channelsSnapshot?.channelAccounts?.nostr??[])[0]?.accountId??e.nostrProfileAccountId??"default"}function Cr(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function $g(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=yh(n??void 0)}function xg(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function Ag(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function kg(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function Sg(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Tr(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(Cr(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:wg(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 oe(e,!0)}catch(s){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(s)}`,success:null}}}async function _g(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Tr(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(Cr(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,l=!!(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:l},i.saved&&await oe(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}var Tg=Object.defineProperty,Cg=Object.getOwnPropertyDescriptor,b=(e,t,n,s)=>{for(var i=s>1?void 0:s?Cg(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&&Tg(t,n,i),i};const is=ml();function Eg(){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 Ze{constructor(){super(...arguments),this.settings=yl(),this.password="",this.tab="chat",this.onboarding=Eg(),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=is.name,this.assistantAvatar=is.avatar,this.assistantAgentId=is.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatToolMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.chatQueue=[],this.chatAttachments=[],this.sidebarOpen=!1,this.sidebarContent=null,this.sidebarError=null,this.splitRatio=this.settings.splitRatio,this.nodesLoading=!1,this.nodes=[],this.devicesLoading=!1,this.devicesError=null,this.devicesList=null,this.execApprovalsLoading=!1,this.execApprovalsSaving=!1,this.execApprovalsDirty=!1,this.execApprovalsSnapshot=null,this.execApprovalsForm=null,this.execApprovalsSelectedAgent=null,this.execApprovalsTarget="gateway",this.execApprovalsTargetNodeId=null,this.execApprovalQueue=[],this.execApprovalBusy=!1,this.execApprovalError=null,this.configLoading=!1,this.configRaw=`{
|
|
3160
|
+
}
|
|
3161
|
+
`,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={...Xf},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={...Jf},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=()=>$d(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),ug(this)}firstUpdated(){pg(this)}disconnectedCallback(){hg(this),super.disconnectedCallback()}updated(e){fg(this,e)}connect(){_r(this)}handleChatScroll(e){Zl(this,e)}handleLogsScroll(e){Jl(this,e)}exportLogs(e,t){ec(e,t)}resetToolStream(){dn(this)}resetChatScroll(){Xl(this)}async loadAssistantIdentity(){await Sr(this)}applySettings(e){Ae(this,e)}setTab(e){fd(this,e)}setTheme(e,t){gd(this,e,t)}async loadOverview(){await Ho(this)}async loadCron(){await ei(this)}async handleAbortChat(){await jo(this)}removeQueuedMessage(e){_d(this,e)}async handleSendChat(e,t){await Td(this,e,t)}async handleWhatsAppStart(e){await gg(this,e)}async handleWhatsAppWait(){await vg(this)}async handleWhatsAppLogout(){await mg(this)}async handleChannelConfigSave(){await yg(this)}async handleChannelConfigReload(){await bg(this)}handleNostrProfileEdit(e,t){$g(this,e,t)}handleNostrProfileCancel(){xg(this)}handleNostrProfileFieldChange(e,t){Ag(this,e,t)}async handleNostrProfileSave(){await Sg(this)}async handleNostrProfileImport(){await _g(this)}handleNostrProfileToggleAdvanced(){kg(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 Zf(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([oo("moltbot-app")],y);
|
|
3162
|
+
//# sourceMappingURL=index-CxUFDXFX.js.map
|