@rubytech/taskmaster 1.23.0 → 1.23.1
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.
|
@@ -17,7 +17,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
17
17
|
`],{type:"text/plain"}),i=URL.createObjectURL(n),s=document.createElement("a"),o=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-logs-${t}-${o}.log`,s.click(),URL.revokeObjectURL(i)}function gh(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
|
|
18
18
|
`)}
|
|
19
19
|
`],{type:"text/plain"}),i=URL.createObjectURL(n),s=document.createElement("a"),o=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-session-logs-${t}-${o}.log`,s.click(),URL.revokeObjectURL(i)}function mh(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:i}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${i}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}function lt(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Ct(e){return`${JSON.stringify(e,null,2).trimEnd()}
|
|
20
|
-
`}function cc(e,t,n){if(t.length===0)return;let i=e;for(let o=0;o<t.length-1;o+=1){const a=t[o],r=t[o+1];if(typeof a=="number"){if(!Array.isArray(i))return;i[a]==null&&(i[a]=typeof r=="number"?[]:{}),i=i[a]}else{if(typeof i!="object"||i==null)return;const l=i;l[a]==null&&(l[a]=typeof r=="number"?[]:{}),i=l[a]}}const s=t[t.length-1];if(typeof s=="number"){Array.isArray(i)&&(i[s]=n);return}typeof i=="object"&&i!=null&&(i[s]=n)}async function We(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});vh(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function dc(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});yh(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function yh(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function vh(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?Ct(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=Ct(e.configForm):e.configRaw=n,e.configValid=typeof t.valid=="boolean"?t.valid:null,e.configIssues=Array.isArray(t.issues)?t.issues:[],e.configFormDirty||(e.configForm=lt(t.config??{}),e.configFormOriginal=lt(t.config??{}),e.configRawOriginal=n)}async function bh(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?Ct(e.configForm):e.configRaw,i=(t=e.configSnapshot)==null?void 0:t.hash;if(!i){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:n,baseHash:i}),e.configFormDirty=!1,await We(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function on(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 jn(e){if(!(!e.client||!e.connected)&&!e.cronLoading){e.cronLoading=!0,e.cronError=null;try{const t={includeDisabled:!0};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(t.agentIds=e.workspaceAgentIds),e.accountId&&(t.accountId=e.accountId);const n=await e.client.request("cron.list",t);e.cronJobs=Array.isArray(n.jobs)?n.jobs:[]}catch(t){e.cronError=String(t)}finally{e.cronLoading=!1}}}function uc(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=Ni(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const i=e.everyUnit;return{kind:"every",everyMs:n*(i==="minutes"?6e4:i==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function pc(e){if(e.payloadKind==="systemEvent"){const o=e.payloadText.trim();if(!o)throw new Error("System event text required.");return{kind:"systemEvent",text:o}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel);const i=[];e.toAdmins&&i.push("admins");for(const o of e.recipients){const a=o.trim();a&&i.push(a)}i.length>0&&(n.to=i.join(","));const s=Ni(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function wh(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=uc(e.cronForm),i=pc(e.cronForm),s=e.cronForm.agentId.trim(),o=(t=e.cronForm.accountId)==null?void 0:t.trim(),a={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,accountId:o||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!a.name)throw new Error("Name required.");await e.client.request("cron.add",a),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await jn(e),await on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function kh(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 jn(e),await on(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function xh(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null,e.cronRunModalJobId=t.id,e.cronRunModalJobName=t.name||"Untitled",e.cronRunResult=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await xo(e,t.id)}catch(n){e.cronError=String(n),e.cronRunResult={status:"error",error:String(n)}}finally{e.cronBusy=!1}}}function $h(e,t){e.cronRunModalJobId&&t.jobId===e.cronRunModalJobId&&t.action==="finished"&&(e.cronRunResult={status:t.status??"unknown",durationMs:t.durationMs,summary:t.summary,outputText:t.outputText,error:t.error})}async function Sh(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 jn(e),await on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}function Ah(e){var n;const t={name:e.name||"",description:e.description||"",agentId:e.agentId||"",enabled:e.enabled,scheduleKind:e.schedule.kind,scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"",cronTz:"",sessionTarget:e.sessionTarget||"main",wakeMode:e.wakeMode||"next-heartbeat",payloadKind:e.payload.kind,payloadText:"",deliver:!1,channel:"last",recipients:[],toAdmins:!1,timeoutSeconds:"",postToMainPrefix:""};if(e.schedule.kind==="at"){const i=new Date(e.schedule.atMs),s=o=>String(o).padStart(2,"0");t.scheduleAt=`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}T${s(i.getHours())}:${s(i.getMinutes())}`}else if(e.schedule.kind==="every"){const i=e.schedule.everyMs;i%864e5===0?(t.everyAmount=String(i/864e5),t.everyUnit="days"):i%36e5===0?(t.everyAmount=String(i/36e5),t.everyUnit="hours"):(t.everyAmount=String(i/6e4),t.everyUnit="minutes")}else e.schedule.kind==="cron"&&(t.cronExpr=e.schedule.expr,t.cronTz=e.schedule.tz||"");if(e.payload.kind==="systemEvent")t.payloadText=e.payload.text;else if(e.payload.kind==="agentTurn"){t.payloadText=e.payload.message,t.deliver=e.payload.deliver??!1,t.timeoutSeconds=e.payload.timeoutSeconds?String(e.payload.timeoutSeconds):"";const i=e.payload.channel??e.payload.provider;t.channel=i||"last";const s=e.payload.to||"";if(s){const o=s.split(",").map(a=>a.trim()).filter(Boolean);t.toAdmins=o.some(a=>a.toLowerCase()==="admins"),t.recipients=o.filter(a=>a.toLowerCase()!=="admins")}}return(n=e.isolation)!=null&&n.postToMainPrefix&&(t.postToMainPrefix=e.isolation.postToMainPrefix),t}async function Ch(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=uc(e.cronForm),i=pc(e.cronForm),s={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:e.cronForm.agentId.trim()||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i};if(e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?s.isolation={postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:s.isolation=void 0,!s.name)throw new Error("Name required.");await e.client.request("cron.update",{id:t,patch:s}),await jn(e),await on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function xo(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 ee(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 ea(e,t,n){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0,e.whatsappActiveQrAccountId=n??null;try{const i=await e.client.request("web.login.start",{force:t,timeoutMs:3e4,accountId:n});e.whatsappLoginMessage=i.message??null,e.whatsappLoginQrDataUrl=i.qrDataUrl??null,e.whatsappLoginConnected=null}catch(i){e.whatsappLoginMessage=String(i),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function hc(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const n=await e.client.request("web.login.wait",{timeoutMs:12e4,accountId:t});e.whatsappLoginMessage=n.message??null,e.whatsappLoginConnected=n.connected??null,n.connected&&(e.whatsappLoginQrDataUrl=null,e.whatsappActiveQrAccountId=null,e.whatsappPairedPhone=n.selfPhone??null)}catch(n){e.whatsappLoginMessage=String(n),e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function fc(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t}),e.whatsappLoginMessage="Logged out.",e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null}catch(n){e.whatsappLoginMessage=String(n)}finally{e.whatsappBusy=!1}}}async function gc(e,t){if(!e.client||!e.connected||e.whatsappAccountSaving)return;const n=t.trim();if(!n){e.whatsappAccountError="Account name is required.";return}const i=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");if(!i){e.whatsappAccountError="Invalid account name.";return}e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const o=lt(s.config??{});(!o.channels||typeof o.channels!="object")&&(o.channels={});const a=o.channels;(!a.whatsapp||typeof a.whatsapp!="object")&&(a.whatsapp={});const r=a.whatsapp;(!r.accounts||typeof r.accounts!="object")&&(r.accounts={});const l=r.accounts;if(l[i]){e.whatsappAccountError=`Account "${i}" already exists.`;return}l[i]={name:n,provider:"baileys"};const d=s.hash;if(!d){e.whatsappAccountError="Config hash missing; reload and retry.";return}const h=Ct(o);await e.client.request("config.set",{raw:h,baseHash:d}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await ee(e,!0),await ea(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function mc(e,t){if(!(!e.client||!e.connected)&&!e.whatsappAccountSaving){e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const i=lt(n.config??{}),s=i.channels,o=s==null?void 0:s.whatsapp,a=o==null?void 0:o.accounts;if(!a){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(a).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!a[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete a[t],Array.isArray(i.bindings)&&(i.bindings=i.bindings.filter(h=>{const u=h.match;return!u||u.channel!=="whatsapp"?!0:u.accountId!==t}));const l=n.hash;if(!l){e.whatsappAccountError="Config hash missing; reload and retry.";return}const d=Ct(i);await e.client.request("config.set",{raw:d,baseHash:l}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await ee(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const Eh=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:gc,loadChannels:ee,logoutWhatsApp:fc,removeWhatsAppAccount:mc,startWhatsAppLogin:ea,waitWhatsAppLogin:hc},Symbol.toStringTag,{value:"Module"}));async function ta(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,i,s]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const o=i;e.debugModels=Array.isArray(o==null?void 0:o.models)?o==null?void 0:o.models:[],e.debugHeartbeat=s}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}const na="taskmaster-access-session",yc={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function ia(){try{return localStorage.getItem(na)}catch{return null}}function vc(e){try{localStorage.setItem(na,e)}catch{}}function Th(){try{localStorage.removeItem(na)}catch{}}async function Cr(e){if(e.client)try{const t=ia(),n=await e.client.request("access.status",{token:t});e.accessState={...e.accessState,checked:!0,hasPins:n.hasPins,hasMasterPin:n.hasMasterPin,accounts:n.accounts??[],authenticated:n.authenticated,workspace:n.workspace,master:n.master,error:null}}catch{e.accessState={...e.accessState,checked:!0,hasPins:!1,hasMasterPin:!1,accounts:[],authenticated:!0,error:null}}}async function _h(e,t,n){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const i=await e.client.request("access.verify",{account:t,pin:n});i.ok&&i.token?(vc(i.token),e.accessState={...e.accessState,authenticated:!0,workspace:i.workspace??null,master:i.master??!1,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:i.message??"Incorrect PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to verify PIN"}}}}async function Mh(e,t){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const n=await e.client.request("access.setMasterPin",{pin:t});n.ok&&n.token?(vc(n.token),e.accessState={...e.accessState,checked:!0,hasPins:!0,hasMasterPin:!0,authenticated:!0,workspace:null,master:!0,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:"Failed to set PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to set PIN"}}}}async function Ph(e,t,n){if(!e.client)return!1;try{return(await e.client.request("access.setAccountPin",{workspace:t,pin:n})).ok}catch{return!1}}async function Ih(e){const t=ia();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}Th(),e.accessState={...yc,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}const Rh=2e3,Lh=new Set(["trace","debug","info","warn","error","fatal"]);function Dh(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 Bh(e){if(typeof e!="string")return null;const t=e.toLowerCase();return Lh.has(t)?t:null}function bc(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,i=typeof t.time=="string"?t.time:typeof(n==null?void 0:n.date)=="string"?n==null?void 0:n.date:null,s=Bh((n==null?void 0:n.logLevelName)??(n==null?void 0:n.level)),o=typeof t[0]=="string"?t[0]:typeof(n==null?void 0:n.name)=="string"?n==null?void 0:n.name:null,a=Dh(o);let r=null;a&&(typeof a.subsystem=="string"?r=a.subsystem:typeof a.module=="string"&&(r=a.module)),!r&&o&&o.length<120&&(r=o);let l=null;return typeof t[1]=="string"?l=t[1]:!a&&typeof t[0]=="string"?l=t[0]:typeof t.message=="string"&&(l=t.message),{raw:e,time:i,level:s,subsystem:r,message:l??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function bt(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.logsLoading=!0),e.logsError=null;try{const i=await e.client.request("logs.tail",{cursor:t!=null&&t.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes,date:e.logsDate??void 0,accessToken:ia()??void 0}),o=(Array.isArray(i.lines)?i.lines.filter(r=>typeof r=="string"):[]).map(bc),a=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=a?o:[...e.logsEntries,...o].slice(-Rh),typeof i.cursor=="number"&&(e.logsCursor=i.cursor),typeof i.file=="string"&&(e.logsFile=i.file),Array.isArray(i.availableDates)&&(e.logsAvailableDates=i.availableDates.filter(r=>typeof r=="string")),e.logsTruncated=!!i.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t!=null&&t.quiet||(e.logsLoading=!1)}}}const Nh=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:bt,parseLogLine:bc},Symbol.toStringTag,{value:"Module"}));const wc={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ue,n:Ai,Gx:Er,Gy:Tr,a:Fs,d:Us,h:Oh}=wc,Et=32,sa=64,Fh=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},re=(e="")=>{const t=new Error(e);throw Fh(t,re),t},Uh=e=>typeof e=="bigint",Wh=e=>typeof e=="string",zh=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",ct=(e,t,n="")=>{const i=zh(e),s=e==null?void 0:e.length,o=t!==void 0;if(!i||o&&s!==t){const a=n&&`"${n}" `,r=o?` of length ${t}`:"",l=i?`length=${s}`:`type=${typeof e}`;re(a+"expected Uint8Array"+r+", got "+l)}return e},rs=e=>new Uint8Array(e),kc=e=>Uint8Array.from(e),xc=(e,t)=>e.toString(16).padStart(t,"0"),$c=e=>Array.from(ct(e)).map(t=>xc(t,2)).join(""),Ge={_0:48,_9:57,A:65,F:70,a:97,f:102},_r=e=>{if(e>=Ge._0&&e<=Ge._9)return e-Ge._0;if(e>=Ge.A&&e<=Ge.F)return e-(Ge.A-10);if(e>=Ge.a&&e<=Ge.f)return e-(Ge.a-10)},Sc=e=>{const t="hex invalid";if(!Wh(e))return re(t);const n=e.length,i=n/2;if(n%2)return re(t);const s=rs(i);for(let o=0,a=0;o<i;o++,a+=2){const r=_r(e.charCodeAt(a)),l=_r(e.charCodeAt(a+1));if(r===void 0||l===void 0)return re(t);s[o]=r*16+l}return s},Ac=()=>globalThis==null?void 0:globalThis.crypto,Kh=()=>{var e;return((e=Ac())==null?void 0:e.subtle)??re("crypto.subtle must be defined, consider polyfill")},Kn=(...e)=>{const t=rs(e.reduce((i,s)=>i+ct(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},Hh=(e=Et)=>Ac().getRandomValues(rs(e)),Fi=BigInt,gt=(e,t,n,i="bad number: out of range")=>Uh(e)&&t<=e&&e<n?e:re(i),L=(e,t=ue)=>{const n=e%t;return n>=0n?n:t+n},Cc=e=>L(e,Ai),qh=(e,t)=>{(e===0n||t<=0n)&&re("no inverse n="+e+" mod="+t);let n=L(e,t),i=t,s=0n,o=1n;for(;n!==0n;){const a=i/n,r=i%n,l=s-o*a;i=n,n=r,s=o,o=l}return i===1n?L(s,t):re("no inverse")},jh=e=>{const t=Mc[e];return typeof t!="function"&&re("hashes."+e+" not set"),t},Ws=e=>e instanceof Tt?e:re("Point expected"),$o=2n**256n,Ue=class Ue{constructor(t,n,i,s){q(this,"X");q(this,"Y");q(this,"Z");q(this,"T");const o=$o;this.X=gt(t,0n,o),this.Y=gt(n,0n,o),this.Z=gt(i,1n,o),this.T=gt(s,0n,o),Object.freeze(this)}static CURVE(){return wc}static fromAffine(t){return new Ue(t.x,t.y,1n,L(t.x*t.y))}static fromBytes(t,n=!1){const i=Us,s=kc(ct(t,Et)),o=t[31];s[31]=o&-129;const a=Tc(s);gt(a,0n,n?$o:ue);const l=L(a*a),d=L(l-1n),h=L(i*l+1n);let{isValid:u,value:p}=Vh(d,h);u||re("bad point: y not sqrt");const v=(p&1n)===1n,$=(o&128)!==0;return!n&&p===0n&&$&&re("bad point: x==0, isLastByteOdd"),$!==v&&(p=L(-p)),new Ue(p,a,1n,L(p*a))}static fromHex(t,n){return Ue.fromBytes(Sc(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Fs,n=Us,i=this;if(i.is0())return re("bad point: ZERO");const{X:s,Y:o,Z:a,T:r}=i,l=L(s*s),d=L(o*o),h=L(a*a),u=L(h*h),p=L(l*t),v=L(h*L(p+d)),$=L(u+L(n*L(l*d)));if(v!==$)return re("bad point: equation left != right (1)");const S=L(s*o),M=L(a*r);return S!==M?re("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:a,Z:r}=Ws(t),l=L(n*r),d=L(o*s),h=L(i*r),u=L(a*s);return l===d&&h===u}is0(){return this.equals(jt)}negate(){return new Ue(L(-this.X),this.Y,this.Z,L(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=Fs,o=L(t*t),a=L(n*n),r=L(2n*L(i*i)),l=L(s*o),d=t+n,h=L(L(d*d)-o-a),u=l+a,p=u-r,v=l-a,$=L(h*p),S=L(u*v),M=L(h*v),y=L(p*u);return new Ue($,S,y,M)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:a,Y:r,Z:l,T:d}=Ws(t),h=Fs,u=Us,p=L(n*a),v=L(i*r),$=L(o*u*d),S=L(s*l),M=L((n+i)*(a+r)-p-v),y=L(S-$),b=L(S+$),k=L(v-h*p),A=L(M*y),E=L(b*k),T=L(M*k),P=L(y*b);return new Ue(A,E,P,T)}subtract(t){return this.add(Ws(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return jt;if(gt(t,1n,Ai),t===1n)return this;if(this.equals(_t))return af(t).p;let i=jt,s=_t;for(let o=this;t>0n;o=o.double(),t>>=1n)t&1n?i=i.add(o):n&&(s=s.add(o));return i}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:i}=this;if(this.equals(jt))return{x:0n,y:1n};const s=qh(i,ue);L(i*s)!==1n&&re("invalid inverse");const o=L(t*s),a=L(n*s);return{x:o,y:a}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=Ec(n);return i[31]|=t&1n?128:0,i}toHex(){return $c(this.toBytes())}clearCofactor(){return this.multiply(Fi(Oh),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Ai/2n,!1).double();return Ai%2n&&(t=t.add(this)),t.is0()}};q(Ue,"BASE"),q(Ue,"ZERO");let Tt=Ue;const _t=new Tt(Er,Tr,1n,L(Er*Tr)),jt=new Tt(0n,1n,1n,0n);Tt.BASE=_t;Tt.ZERO=jt;const Ec=e=>Sc(xc(gt(e,0n,$o),sa)).reverse(),Tc=e=>Fi("0x"+$c(kc(ct(e)).reverse())),De=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=ue;return n},Gh=e=>{const n=e*e%ue*e%ue,i=De(n,2n)*n%ue,s=De(i,1n)*e%ue,o=De(s,5n)*s%ue,a=De(o,10n)*o%ue,r=De(a,20n)*a%ue,l=De(r,40n)*r%ue,d=De(l,80n)*l%ue,h=De(d,80n)*l%ue,u=De(h,10n)*o%ue;return{pow_p_5_8:De(u,2n)*e%ue,b2:n}},Mr=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Vh=(e,t)=>{const n=L(t*t*t),i=L(n*n*t),s=Gh(e*i).pow_p_5_8;let o=L(e*n*s);const a=L(t*o*o),r=o,l=L(o*Mr),d=a===e,h=a===L(-e),u=a===L(-e*Mr);return d&&(o=r),(h||u)&&(o=l),(L(o)&1n)===1n&&(o=L(-o)),{isValid:d||h,value:o}},So=e=>Cc(Tc(e)),oa=(...e)=>Mc.sha512Async(Kn(...e)),Qh=(...e)=>jh("sha512")(Kn(...e)),_c=e=>{const t=e.slice(0,Et);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Et,sa),i=So(t),s=_t.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},aa=e=>oa(ct(e,Et)).then(_c),Jh=e=>_c(Qh(ct(e,Et))),Yh=e=>aa(e).then(t=>t.pointBytes),Xh=e=>oa(e.hashable).then(e.finish),Zh=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=So(t),a=_t.multiply(o).toBytes();return{hashable:Kn(a,i,n),finish:d=>{const h=Cc(o+So(d)*s);return ct(Kn(a,Ec(h)),sa)}}},ef=async(e,t)=>{const n=ct(e),i=await aa(t),s=await oa(i.prefix,n);return Xh(Zh(i,s,n))},Mc={sha512Async:async e=>{const t=Kh(),n=Kn(e);return rs(await t.digest("SHA-512",n.buffer))},sha512:void 0},tf=(e=Hh(Et))=>e,nf={getExtendedPublicKeyAsync:aa,getExtendedPublicKey:Jh,randomSecretKey:tf},Ui=8,sf=256,Pc=Math.ceil(sf/Ui)+1,Ao=2**(Ui-1),of=()=>{const e=[];let t=_t,n=t;for(let i=0;i<Pc;i++){n=t,e.push(n);for(let s=1;s<Ao;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Pr;const Ir=(e,t)=>{const n=t.negate();return e?n:t},af=e=>{const t=Pr||(Pr=of());let n=jt,i=_t;const s=2**Ui,o=s,a=Fi(s-1),r=Fi(Ui);for(let l=0;l<Pc;l++){let d=Number(e&a);e>>=r,d>Ao&&(d-=o,e+=1n);const h=l*Ao,u=h,p=h+Math.abs(d)-1,v=l%2!==0,$=d<0;d===0?i=i.add(Ir(v,t[u])):n=n.add(Ir($,t[p]))}return e!==0n&&re("invalid wnaf"),{p:n,f:i}},zs="taskmaster-device-identity-v1";function Co(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Ic(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),i=atob(n),s=new Uint8Array(i.length);for(let o=0;o<i.length;o+=1)s[o]=i.charCodeAt(o);return s}function rf(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Rc(e){const t=await crypto.subtle.digest("SHA-256",e);return rf(new Uint8Array(t))}async function lf(){const e=nf.randomSecretKey(),t=await Yh(e);return{deviceId:await Rc(t),publicKey:Co(t),privateKey:Co(e)}}async function cf(){try{const n=localStorage.getItem(zs);if(n){const i=JSON.parse(n);if((i==null?void 0:i.version)===1&&typeof i.deviceId=="string"&&typeof i.publicKey=="string"&&typeof i.privateKey=="string"){const s=await Rc(Ic(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(zs,JSON.stringify(o)),{deviceId:s,publicKey:i.publicKey,privateKey:i.privateKey}}return{deviceId:i.deviceId,publicKey:i.publicKey,privateKey:i.privateKey}}}}catch{}const e=await lf(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(zs,JSON.stringify(t)),e}async function df(e,t){const n=Ic(e),i=new TextEncoder().encode(t),s=await ef(i,n);return Co(s)}const Lc="taskmaster.device.auth.v1";function ra(e){return e.trim()}function uf(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const i=n.trim();i&&t.add(i)}return[...t].sort()}function la(){try{const e=window.localStorage.getItem(Lc);if(!e)return null;const t=JSON.parse(e);return!t||t.version!==1||!t.deviceId||typeof t.deviceId!="string"||!t.tokens||typeof t.tokens!="object"?null:t}catch{return null}}function Dc(e){try{window.localStorage.setItem(Lc,JSON.stringify(e))}catch{}}function pf(e){const t=la();if(!t||t.deviceId!==e.deviceId)return null;const n=ra(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function hf(e){const t=ra(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=la();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:uf(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,Dc(n),s}function ff(e){const t=la();if(!t||t.deviceId!==e.deviceId)return;const n=ra(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],Dc(i)}async function ca(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t!=null&&t.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n==null?void 0:n.pending)?n.pending:[],paired:Array.isArray(n==null?void 0:n.paired)?n.paired:[]}}catch(n){t!=null&&t.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function da(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,t!=null&&t.quiet||(e.lastError=null);try{const n=await e.client.request("node.list",{});e.nodes=Array.isArray(n.nodes)?n.nodes:[]}catch(n){t!=null&&t.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function gf(e){return{method:"exec.approvals.get",params:{}}}async function mf(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=gf(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);yf(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function yf(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=lt(t.file??{}))}async function Bc(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 xe(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function $e(e){return e instanceof Error?e.message:String(e)}function Hn(){return{name:"",skillContent:"",references:[],alwaysActive:!1}}async function Pe(e,t){if(t!=null&&t.clearMessages&&Object.keys(e.skillMessages).length>0&&(e.skillMessages={}),!(!e.client||!e.connected)&&!e.skillsLoading){e.skillsLoading=!0,e.skillsError=null;try{const n=await e.client.request("skills.status",{});n&&(e.skillsReport=n)}catch(n){e.skillsError=$e(n)}finally{e.skillsLoading=!1}}}function Nc(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Oc(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 Pe(e),xe(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=$e(i);e.skillsError=s,xe(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Fc(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const n=e.skillEdits[t]??"";await e.client.request("skills.update",{skillKey:t,apiKey:n}),await Pe(e),xe(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=$e(n);e.skillsError=i,xe(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Uc(e,t,n,i){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const s=await e.client.request("skills.install",{name:n,installId:i,timeoutMs:12e4});await Pe(e),xe(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=$e(s);e.skillsError=o,xe(e,t,{kind:"error",message:o})}finally{e.skillsBusyKey=null}}}async function Wc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("skills.read",{name:t});n&&(e.skillDetail=n,e.skillDetailTab="SKILL.md")}catch(n){e.skillsError=$e(n)}}function zc(e){e.skillDetail=null,e.skillDetailTab=""}function Kc(e,t){e.skillDetailTab=t}async function Hc(e){if(e.skillAddModal=!0,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[],!(!e.client||!e.connected))try{const t=await e.client.request("skills.drafts",{});t&&(e.skillDrafts=t.drafts)}catch{}}function qc(e){e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[]}function jc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n})),alwaysActive:!1},e.skillAddFormSource="draft"}async function Gc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n})),alwaysActive:!1},e.skillAddFormSource="installed",await ua(e)}async function ua(e){if(!e.client||!e.connected)return;const t=e.skillAddForm;if(!(!t.name.trim()||!t.skillContent.trim())){e.skillsBusyKey="__add__",e.skillsError=null;try{const n=t.references.filter(s=>s.name.trim()&&s.content.trim()).map(s=>({name:s.name.trim(),content:s.content})),i=t.name.trim();e.skillAddFormSource==="installed"?(await e.client.request("skills.create",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0,alwaysActive:t.alwaysActive}),e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillDrafts=[],await Pe(e),xe(e,i,{kind:"success",message:"Skill saved — active on next message"})):(await e.client.request("skills.saveDraft",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillDrafts=[],xe(e,i,{kind:"success",message:"Draft saved"}))}catch(n){e.skillsError=$e(n)}finally{e.skillsBusyKey=null}}}async function Vc(e,t){if(!(!e.client||!e.connected))try{await e.client.request("skills.deleteDraft",{name:t}),e.skillDrafts=e.skillDrafts.filter(n=>n.name!==t)}catch(n){e.skillsError=$e(n)}}async function Qc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("skills.read",{name:t});if(!n)return;e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i})),alwaysActive:n.alwaysActive??!1},e.skillAddFormSource="installed",e.skillAddModal=!0,e.skillDrafts=[]}catch(n){e.skillsError=$e(n)}}function Jc(e,t){const n=e.skillDetail;n&&(e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i})),alwaysActive:n.alwaysActive??!1},e.skillAddFormSource="installed",e.skillEditTab=t&&t!=="SKILL.md"?t:"SKILL.md",e.skillDetail=null,e.skillDetailTab="",e.skillAddModal=!0,e.skillDrafts=[])}function Yc(e,t,n){e.skillAddForm={...e.skillAddForm,references:e.skillAddForm.references.map(i=>i.name===t?{...i,content:n}:i)}}function Xc(e,t){e.skillEditTab=t}async function Zc(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const i=await e.client.request("skills.read",{name:t});if(!i)return;const s=i.references.filter(o=>o.name.trim()&&o.content.trim()).map(o=>({name:o.name.trim(),content:o.content}));await e.client.request("skills.create",{name:t,skillContent:i.content,references:s.length>0?s:void 0,alwaysActive:n}),await Pe(e),xe(e,t,{kind:"success",message:n?"Skill is now always active":"Skill loads on demand"})}catch(i){e.skillsError=$e(i),xe(e,t,{kind:"error",message:$e(i)})}finally{e.skillsBusyKey=null}}}async function ed(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.update",{skillKey:t,agents:n}),await Pe(e),xe(e,t,{kind:"success",message:"Agent access updated"})}catch(i){const s=$e(i);e.skillsError=s,xe(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function td(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.delete",{name:t}),await Pe(e)}catch(n){e.skillsError=$e(n)}finally{e.skillsBusyKey=null}}}const vf=Object.freeze(Object.defineProperty({__proto__:null,closeAddSkillModal:qc,closeSkillDetail:zc,deleteDraft:Vc,deleteSkill:td,editDetailSkill:Jc,editSkill:Qc,emptyAddForm:Hn,importDraft:jc,installDraft:Gc,installSkill:Uc,loadSkills:Pe,openAddSkillModal:Hc,saveNewSkill:ua,saveSkillApiKey:Fc,setEditTab:Xc,setSkillDetailTab:Kc,toggleAlwaysActive:Zc,updateFormReference:Yc,updateSkillAgents:ed,updateSkillEdit:Nc,updateSkillEnabled:Oc,viewSkillDetail:Wc},Symbol.toStringTag,{value:"Module"})),nd={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},id=new Map(Object.entries(nd).map(([e,t])=>[t,e]));function ls(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function qn(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 bf(e,t=""){const n=ls(t),i=nd[e];return n?`${n}${i}`:i}function sd(e,t=""){const n=ls(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=qn(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":id.get(s)??null}function wf(e){let t=qn(e);if(t.endsWith("/index.html")&&(t=qn(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let i=0;i<n.length;i++){const s=`/${n.slice(i).join("/")}`.toLowerCase();if(id.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function kf(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function pa(e){return e==="system"?kf():e}const di=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,xf=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,ui=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},$f=({nextTheme:e,applyTheme:t,context:n,currentTheme:i})=>{var d;if(i===e)return;const s=globalThis.document??null;if(!s){t();return}const o=s.documentElement,a=s,r=xf();if(!!a.startViewTransition&&!r){let h=.5,u=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")h=di(n.pointerClientX/window.innerWidth),u=di(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const p=n.element.getBoundingClientRect();p.width>0&&p.height>0&&typeof window<"u"&&(h=di((p.left+p.width/2)/window.innerWidth),u=di((p.top+p.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${h*100}%`),o.style.setProperty("--theme-switch-y",`${u*100}%`),o.classList.add("theme-transition");try{const p=(d=a.startViewTransition)==null?void 0:d.call(a,()=>{t()});p!=null&&p.finished?p.finished.finally(()=>ui(o)):ui(o)}catch{ui(o),t()}return}t(),ui(o)},Sf=2e3;async function Pn(e,t){if(!(!e.client||!e.connected)&&!(e.sessionLogsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.sessionLogsLoading=!0),e.sessionLogsError=null;try{const n={cursors:t!=null&&t.reset?void 0:e.sessionLogsCursors,limit:500};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(n.agents=e.workspaceAgentIds);const s=await e.client.request("sessions.transcript",n),o=Array.isArray(s.entries)?s.entries:[],a=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=a?o:[...e.sessionLogsEntries,...o].slice(-Sf),s.cursors&&(e.sessionLogsCursors=s.cursors),Array.isArray(s.agents)&&(e.sessionLogsAgents=s.agents),e.sessionLogsLastFetchAt=Date.now()}catch(n){e.sessionLogsError=String(n)}finally{t!=null&&t.quiet||(e.sessionLogsLoading=!1)}}}const od=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:Pn},Symbol.toStringTag,{value:"Module"}));async function ad(e,t){if(!(!e.client||!e.connected))try{const n={},i=await e.client.request("memory.audit",n);i!=null&&i.ok&&(e.auditEntries=i.entries??[])}catch{}}async function Af(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function ze(e){return e instanceof Error?e.message:String(e)}let pi=null;function an(e,t){pi&&clearTimeout(pi),e.filesMessage={kind:"success",text:t},pi=setTimeout(()=>{e.filesMessage=null,pi=null},3e3)}async function rn(e,t){if(!(!e.client||!e.connected)){if(!t){e.filesTree=[],e.filesRoot="";return}if(!e.filesLoading){e.filesLoading=!0,e.filesError=null;try{const n={};t&&(n.agentId=t);const i=await e.client.request("files.tree",n);i!=null&&i.tree&&(e.filesTree=i.tree,e.filesRoot=i.root??"")}catch(n){e.filesError=ze(n)}finally{e.filesLoading=!1}}}}async function Cf(e,t,n){e.filesSelectedPaths=new Set([t]),await rd(e,t,n)}async function Ef(e,t,n){const i=new Set(e.filesSelectedPaths);if(i.has(t)?i.delete(t):i.add(t),e.filesSelectedPaths=i,i.size===1){const s=[...i][0];await rd(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function Tf(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let i=0,s="";for(const o of n)try{await ld(e,o,t),i++}catch(a){s=ze(a)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:an(e,`${i} file${i!==1?"s":""} downloaded`)}async function _f(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await Rf(e,t,o,i)}async function rd(e,t,n){if(!(!e.client||!e.connected)){e.filesSelectedPath=t,e.filesPreviewLoading=!0,e.filesPreviewContent=null,e.filesPreviewBinary=!1,e.filesPreviewSize=null;try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.read",i);e.filesPreviewContent=(s==null?void 0:s.content)??null,e.filesPreviewBinary=(s==null?void 0:s.binary)??!1,e.filesPreviewSize=(s==null?void 0:s.size)??null}catch(i){e.filesError=ze(i)}finally{e.filesPreviewLoading=!1}}}async function ld(e,t,n){if(!(!e.client||!e.connected))try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.download",i);if(!(s!=null&&s.base64)){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const o=Uint8Array.from(atob(s.base64),d=>d.charCodeAt(0)),a=new Blob([o]),r=URL.createObjectURL(a),l=document.createElement("a");l.href=r,l.download=s.name??t.split("/").pop()??"download",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(r)}catch(i){e.filesMessage={kind:"error",text:ze(i)}}}async function Mf(e,t,n,i){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let s=0,o="";for(const a of n)try{const r=await a.arrayBuffer(),l=btoa(new Uint8Array(r).reduce((h,u)=>h+String.fromCharCode(u),"")),d={path:t,name:a.name,data:l};i&&(d.agentId=i),await e.client.request("files.upload",d),s++}catch(r){o=ze(r)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:an(e,`${s} file${s!==1?"s":""} uploaded`),await rn(e,i)}async function Pf(e,t,n,i){if(!e.client||!e.connected)return;e.filesMessage=null;const s=t==="."?n:`${t}/${n}`;try{const o={path:s};i&&(o.agentId=i),await e.client.request("files.mkdir",o),an(e,`Created ${s}`),await rn(e,i),e.filesExpandedDirs=new Set([...e.filesExpandedDirs,s]),e.filesCurrentDir=s}catch(o){e.filesMessage={kind:"error",text:ze(o)}}}async function If(e,t,n){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const i={path:t};n&&(i.agentId=n),await e.client.request("files.delete",i),an(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await rn(e,n)}catch(i){e.filesMessage={kind:"error",text:ze(i)}}}}async function Rf(e,t,n,i){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const s={from:t,to:n};i&&(s.agentId=i),await e.client.request("files.move",s),an(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await rn(e,i)}catch(s){e.filesMessage={kind:"error",text:ze(s)}}}}async function cs(e,t){if(!(!e.client||!e.connected))try{const n={};t&&(n.agentId=t);const i=await e.client.request("memory.status",n);i!=null&&i.ok&&(e.filesMemoryStatus={dirty:i.dirty??!1,syncing:i.syncing,syncProgress:i.syncProgress,files:i.files??0,chunks:i.chunks??0,model:i.model,embeddingState:i.embeddingState})}catch{}}async function Lf(e,t){if(!(!e.client||!e.connected)&&!e.filesReindexBusy){e.filesReindexBusy=!0,e.filesMessage=null;try{const n={force:!0};t&&(n.agentId=t);const i=await e.client.request("memory.reindex",n),s=(i==null?void 0:i.files)??0,o=(i==null?void 0:i.chunks)??0;an(e,`Re-indexed: ${s} files, ${o} chunks`),await cs(e,t)}catch(n){e.filesMessage={kind:"error",text:ze(n)}}finally{e.filesReindexBusy=!1}}}function Df(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n,e.filesCurrentDir=t}async function Bf(e,t,n){if(!(!e.client||!e.connected)){if(!t.trim()){e.filesSearchResults=null;return}e.filesSearchLoading=!0,e.filesSearchResults=null;try{const i={query:t.trim(),maxResults:20};n&&(i.agentId=n);const s=await e.client.request("memory.search",i);e.filesSearchResults=(s==null?void 0:s.results)??[]}catch(i){e.filesMessage={kind:"error",text:ze(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function Nf(e){e.filesSearchQuery="",e.filesSearchResults=null}function Of(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{da(e,{quiet:!0})},5e3))}function Ff(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function ha(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&e.logsDate==null&&bt(e,{quiet:!0})},2e3))}function fa(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function ga(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||Pn(e,{quiet:!0})},2e3))}function ma(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function ya(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&ta(e)},3e3))}function va(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Uf(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{ad(e)},3e4))}function Wf(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function zf(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{const t=e;t.filesPage&&cs(t,t.filesResolvedAgentId)},3e3))}function Kf(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function at(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,Ip(n),t.theme!==e.theme&&(e.theme=t.theme,ds(e,pa(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function cd(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&at(e,{...e.settings,lastActiveSessionKey:n})}function Hf(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),i=t.get("password"),s=t.get("session"),o=t.get("gatewayUrl");let a=!1;if(n!=null){const l=n.trim();l&&l!==e.settings.token&&at(e,{...e.settings,token:l}),t.delete("token"),a=!0}if(i!=null){const l=i.trim();l&&(e.password=l),t.delete("password"),a=!0}if(s!=null){const l=s.trim();l&&(e.sessionKey=l,at(e,{...e.settings,sessionKey:l,lastActiveSessionKey:l}))}if(o!=null){const l=o.trim();l&&l!==e.settings.gatewayUrl&&at(e,{...e.settings,gatewayUrl:l}),t.delete("gatewayUrl"),a=!0}if(!a)return;const r=new URL(window.location.href);r.search=t.toString(),window.history.replaceState({},"",r.toString())}function qf(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?ga(e):ha(e):(fa(e),ma(e)),t==="debug"?ya(e):va(e),Wi(e),ud(e,t,!1)}function jf(e,t,n){$f({nextTheme:t,applyTheme:()=>{e.theme=t,at(e,{...e.settings,theme:t}),ds(e,pa(t))},context:n,currentTheme:e.theme})}async function Wi(e){if(e.tab==="overview"&&await pd(e),e.tab==="channels"&&await Zf(e),e.tab==="instances"&&await Bc(e),e.tab==="cron"&&await hd(e),e.tab==="skills"&&await Pe(e),e.tab==="nodes"&&(await da(e),await ca(e),await We(e),await mf(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await sg(e),sn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await dc(e),await We(e)),e.tab==="debug"&&(await ta(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await ae(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>od);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await bt(e,{reset:!0});lc(e,!0)}}function Gf(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?ls(e):wf(window.location.pathname)}function Vf(e){e.theme=e.settings.theme??"system",ds(e,pa(e.theme))}function ds(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function Qf(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"&&ds(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Jf(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 Yf(e,t){if(typeof window>"u")return;const n=sd(window.location.pathname,e.basePath)??"chat";dd(e,n),ud(e,n,t)}function Xf(e){var s;if(typeof window>"u")return;const t=sd(window.location.pathname,e.basePath);if(!t)return;const i=(s=new URL(window.location.href).searchParams.get("session"))==null?void 0:s.trim();i&&(e.sessionKey=i,at(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),dd(e,t)}function dd(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?ga(e):ha(e):(fa(e),ma(e)),t==="debug"?ya(e):va(e),e.connected&&Wi(e)}function ud(e,t,n){if(typeof window>"u")return;const i=qn(bf(t,e.basePath)),s=qn(window.location.pathname),o=new URL(window.location.href);t==="chat"&&e.sessionKey?o.searchParams.set("session",e.sessionKey):o.searchParams.delete("session"),s!==i&&(o.pathname=i),n?window.history.replaceState({},"",o.toString()):window.history.pushState({},"",o.toString())}async function pd(e){await Promise.all([ee(e,!1),Bc(e),rc(e),on(e),ta(e)])}async function Zf(e){await Promise.all([ee(e,!0),dc(e),We(e)])}async function hd(e){await Promise.all([ee(e,!1),on(e),jn(e)])}function fd(e){return e.chatSending||!!e.chatRunId}function eg(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 gd(e){e.connected&&(e.chatMessage="",await oc(e))}function tg(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:as(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],sn(e))}async function md(e,t,n){var s,o;Zo(e);const i=await sc(e,t,n==null?void 0:n.attachments);return!i&&(n==null?void 0:n.previousDraft)!=null&&(e.chatMessage=n.previousDraft),!i&&(n!=null&&n.previousAttachments)&&(e.chatAttachments=n.previousAttachments),i&&cd(e,e.sessionKey),i&&(n!=null&&n.restoreDraft)&&((s=n.previousDraft)!=null&&s.trim())&&(e.chatMessage=n.previousDraft),i&&(n!=null&&n.restoreAttachments)&&((o=n.previousAttachments)!=null&&o.length)&&(e.chatAttachments=n.previousAttachments),sn(e),i&&!e.chatRunId&&yd(e),i}async function yd(e){if(!e.connected||fd(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await md(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function ng(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function ig(e,t,n){if(!e.connected)return;const i=e.chatMessage,s=(t??e.chatMessage).trim(),o=e.chatAttachments??[],a=t==null?o:[],r=a.length>0;if(!(!s&&!r)){if(eg(s)){await gd(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[],Lp(e.selectedWorkspace??"",e.sessionKey)),fd(e)){tg(e,s,a);return}await md(e,s,{previousDraft:t==null?i:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:r?a:void 0,previousAttachments:t==null?o:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function sg(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,nn);await Promise.all([Jt(t,{limit:n}),rc(t),Eo(e)]),sn(e,!0)}const og=yd;function ag(e){var s,o,a;const t=Jl(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(s=e.hello)==null?void 0:s.snapshot;return((a=(o=n==null?void 0:n.sessionDefaults)==null?void 0:o.defaultAgentId)==null?void 0:a.trim())||"main"}function rg(e,t){const n=ls(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Eo(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=ag(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=rg(e.basePath,t);try{const i=await fetch(n,{method:"GET"});if(!i.ok){e.chatAvatarUrl=null;return}const s=await i.json(),o=typeof s.avatarUrl=="string"?s.avatarUrl.trim():"";e.chatAvatarUrl=o||null}catch{e.chatAvatarUrl=null}}const I={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>`,unlink:c`<svg viewBox="0 0 24 24"><path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"/><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"/><line x1="8" x2="8" y1="2" y2="5"/><line x1="2" x2="5" y1="8" y2="8"/><line x1="16" x2="16" y1="19" y2="22"/><line x1="19" x2="22" y1="16" y2="16"/></svg>`,radio: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>`,users:c`<svg viewBox="0 0 24 24"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>`,user:c`<svg viewBox="0 0 24 24"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></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>`,rotateCw:c`<svg viewBox="0 0 24 24"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>`,download:c`<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,wrench: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>`,globeOff:c`<svg viewBox="0 0 24 24"><path d="M21.54 15H17"/><path d="M7 3.34V5a3 3 0 0 0 3 3 2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17"/><path d="M11 21.95V18a2 2 0 0 0-2-2 2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05"/><circle cx="12" cy="12" r="10"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,image: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>`,circleCheck:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>`,puzzle: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>`,info:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>`,send:c`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`,slidersHorizontal:c`<svg viewBox="0 0 24 24"><line x1="21" x2="14" y1="4" y2="4"/><line x1="10" x2="3" y1="4" y2="4"/><line x1="21" x2="12" y1="12" y2="12"/><line x1="8" x2="3" y1="12" y2="12"/><line x1="21" x2="16" y1="20" y2="20"/><line x1="12" x2="3" y1="20" y2="20"/><line x1="14" x2="14" y1="2" y2="6"/><line x1="8" x2="8" y1="10" y2="14"/><line x1="16" x2="16" y1="18" y2="22"/></svg>`,square:c`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:c`<svg viewBox="0 0 24 24"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`,eyeOff:c`<svg viewBox="0 0 24 24"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,trash:c`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,mic:c`<svg viewBox="0 0 24 24"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" x2="12" y1="19" y2="22"/></svg>`,chevronDown:c`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,chevronLeft:c`<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>`,chevronRight:c`<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>`,film:c`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/></svg>`,wifi:c`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M2 8.82a15 15 0 0 1 20 0"/><path d="M5 12.859a10 10 0 0 1 14 0"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/></svg>`,wifiOff:c`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/><path d="M5 12.859a10 10 0 0 1 5.17-2.69"/><path d="M13.41 10.28a10 10 0 0 1 5.59 2.58"/><path d="M2 8.82a15 15 0 0 1 4.17-2.65"/><path d="M10.66 5c4.01-.36 8.14.9 11.34 3.76"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,power:c`<svg viewBox="0 0 24 24"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"/><line x1="12" x2="12" y1="2" y2="12"/></svg>`,powerOff:c`<svg viewBox="0 0 24 24"><path d="M18.36 6.64A9 9 0 0 1 20.77 15"/><path d="M6.16 6.16a9 9 0 1 0 12.68 12.68"/><path d="M12 2v4"/><path d="m2 2 20 20"/></svg>`},lg=c`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`,cg=c`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path><path d="M13.73 21a2 2 0 0 1-3.46 0"></path></svg>`,dg=c`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"></path><line x1="12" y1="2" x2="12" y2="12"></line></svg>`;let Rr=!1;function ug(){Rr||(Rr=!0,document.addEventListener("click",e=>{const t=document.getElementById("nav-burger-toggle");if(!(t!=null&&t.checked))return;const n=t.closest(".setup-header");n!=null&&n.contains(e.target)||(t.checked=!1)}))}function Rt(e,t){var u;const n=(p,v)=>p===e?c`<span class="sp-page-nav-current">${p}</span>`:c`<a href=${v}>${p}</a>`,i=c`
|
|
20
|
+
`}function cc(e,t,n){if(t.length===0)return;let i=e;for(let o=0;o<t.length-1;o+=1){const a=t[o],r=t[o+1];if(typeof a=="number"){if(!Array.isArray(i))return;i[a]==null&&(i[a]=typeof r=="number"?[]:{}),i=i[a]}else{if(typeof i!="object"||i==null)return;const l=i;l[a]==null&&(l[a]=typeof r=="number"?[]:{}),i=l[a]}}const s=t[t.length-1];if(typeof s=="number"){Array.isArray(i)&&(i[s]=n);return}typeof i=="object"&&i!=null&&(i[s]=n)}async function We(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});vh(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function dc(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});yh(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function yh(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function vh(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?Ct(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=Ct(e.configForm):e.configRaw=n,e.configValid=typeof t.valid=="boolean"?t.valid:null,e.configIssues=Array.isArray(t.issues)?t.issues:[],e.configFormDirty||(e.configForm=lt(t.config??{}),e.configFormOriginal=lt(t.config??{}),e.configRawOriginal=n)}async function bh(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?Ct(e.configForm):e.configRaw,i=(t=e.configSnapshot)==null?void 0:t.hash;if(!i){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:n,baseHash:i}),e.configFormDirty=!1,await We(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function on(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 jn(e){if(!(!e.client||!e.connected)&&!e.cronLoading){e.cronLoading=!0,e.cronError=null;try{const t={includeDisabled:!0};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(t.agentIds=e.workspaceAgentIds),e.accountId&&(t.accountId=e.accountId);const n=await e.client.request("cron.list",t);e.cronJobs=Array.isArray(n.jobs)?n.jobs:[]}catch(t){e.cronError=String(t)}finally{e.cronLoading=!1}}}function uc(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=Ni(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const i=e.everyUnit;return{kind:"every",everyMs:n*(i==="minutes"?6e4:i==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function pc(e){if(e.payloadKind==="systemEvent"){const o=e.payloadText.trim();if(!o)throw new Error("System event text required.");return{kind:"systemEvent",text:o}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel);const i=[];e.toAdmins&&i.push("admins");for(const o of e.recipients){const a=o.trim();a&&i.push(a)}i.length>0&&(n.to=i.join(","));const s=Ni(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function wh(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=uc(e.cronForm),i=pc(e.cronForm),s=e.cronForm.agentId.trim(),o=(t=e.cronForm.accountId)==null?void 0:t.trim(),a={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,accountId:o||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!a.name)throw new Error("Name required.");await e.client.request("cron.add",a),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await jn(e),await on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function kh(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 jn(e),await on(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function xh(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null,e.cronRunModalJobId=t.id,e.cronRunModalJobName=t.name||"Untitled",e.cronRunResult=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await xo(e,t.id)}catch(n){e.cronError=String(n),e.cronRunResult={status:"error",error:String(n)}}finally{e.cronBusy=!1}}}function $h(e,t){e.cronRunModalJobId&&t.jobId===e.cronRunModalJobId&&t.action==="finished"&&(e.cronRunResult={status:t.status??"unknown",durationMs:t.durationMs,summary:t.summary,outputText:t.outputText,error:t.error})}async function Sh(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 jn(e),await on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}function Ah(e){var n;const t={name:e.name||"",description:e.description||"",agentId:e.agentId||"",enabled:e.enabled,scheduleKind:e.schedule.kind,scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"",cronTz:"",sessionTarget:e.sessionTarget||"main",wakeMode:e.wakeMode||"next-heartbeat",payloadKind:e.payload.kind,payloadText:"",deliver:!1,channel:"last",recipients:[],toAdmins:!1,timeoutSeconds:"",postToMainPrefix:""};if(e.schedule.kind==="at"){const i=new Date(e.schedule.atMs),s=o=>String(o).padStart(2,"0");t.scheduleAt=`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}T${s(i.getHours())}:${s(i.getMinutes())}`}else if(e.schedule.kind==="every"){const i=e.schedule.everyMs;i%864e5===0?(t.everyAmount=String(i/864e5),t.everyUnit="days"):i%36e5===0?(t.everyAmount=String(i/36e5),t.everyUnit="hours"):(t.everyAmount=String(i/6e4),t.everyUnit="minutes")}else e.schedule.kind==="cron"&&(t.cronExpr=e.schedule.expr,t.cronTz=e.schedule.tz||"");if(e.payload.kind==="systemEvent")t.payloadText=e.payload.text;else if(e.payload.kind==="agentTurn"){t.payloadText=e.payload.message,t.deliver=e.payload.deliver??!1,t.timeoutSeconds=e.payload.timeoutSeconds?String(e.payload.timeoutSeconds):"";const i=e.payload.channel??e.payload.provider;t.channel=i||"last";const s=e.payload.to||"";if(s){const o=s.split(",").map(a=>a.trim()).filter(Boolean);t.toAdmins=o.some(a=>a.toLowerCase()==="admins"),t.recipients=o.filter(a=>a.toLowerCase()!=="admins")}}return(n=e.isolation)!=null&&n.postToMainPrefix&&(t.postToMainPrefix=e.isolation.postToMainPrefix),t}async function Ch(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=uc(e.cronForm),i=pc(e.cronForm),s={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:e.cronForm.agentId.trim()||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i};if(e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?s.isolation={postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:s.isolation=void 0,!s.name)throw new Error("Name required.");await e.client.request("cron.update",{id:t,patch:s}),await jn(e),await on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function xo(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 Z(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 ea(e,t,n){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0,e.whatsappActiveQrAccountId=n??null;try{const i=await e.client.request("web.login.start",{force:t,timeoutMs:3e4,accountId:n});e.whatsappLoginMessage=i.message??null,e.whatsappLoginQrDataUrl=i.qrDataUrl??null,e.whatsappLoginConnected=null}catch(i){e.whatsappLoginMessage=String(i),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function hc(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const n=await e.client.request("web.login.wait",{timeoutMs:12e4,accountId:t});e.whatsappLoginMessage=n.message??null,e.whatsappLoginConnected=n.connected??null,n.connected&&(e.whatsappLoginQrDataUrl=null,e.whatsappActiveQrAccountId=null,e.whatsappPairedPhone=n.selfPhone??null)}catch(n){e.whatsappLoginMessage=String(n),e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function fc(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t}),e.whatsappLoginMessage="Logged out.",e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null}catch(n){e.whatsappLoginMessage=String(n)}finally{e.whatsappBusy=!1}}}async function gc(e,t){if(!e.client||!e.connected||e.whatsappAccountSaving)return;const n=t.trim();if(!n){e.whatsappAccountError="Account name is required.";return}const i=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");if(!i){e.whatsappAccountError="Invalid account name.";return}e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const o=lt(s.config??{});(!o.channels||typeof o.channels!="object")&&(o.channels={});const a=o.channels;(!a.whatsapp||typeof a.whatsapp!="object")&&(a.whatsapp={});const r=a.whatsapp;(!r.accounts||typeof r.accounts!="object")&&(r.accounts={});const l=r.accounts;if(l[i]){e.whatsappAccountError=`Account "${i}" already exists.`;return}l[i]={name:n,provider:"baileys"};const d=s.hash;if(!d){e.whatsappAccountError="Config hash missing; reload and retry.";return}const h=Ct(o);await e.client.request("config.set",{raw:h,baseHash:d}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await Z(e,!0),await ea(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function mc(e,t){if(!(!e.client||!e.connected)&&!e.whatsappAccountSaving){e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const i=lt(n.config??{}),s=i.channels,o=s==null?void 0:s.whatsapp,a=o==null?void 0:o.accounts;if(!a){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(a).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!a[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete a[t],Array.isArray(i.bindings)&&(i.bindings=i.bindings.filter(h=>{const u=h.match;return!u||u.channel!=="whatsapp"?!0:u.accountId!==t}));const l=n.hash;if(!l){e.whatsappAccountError="Config hash missing; reload and retry.";return}const d=Ct(i);await e.client.request("config.set",{raw:d,baseHash:l}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await Z(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const Eh=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:gc,loadChannels:Z,logoutWhatsApp:fc,removeWhatsAppAccount:mc,startWhatsAppLogin:ea,waitWhatsAppLogin:hc},Symbol.toStringTag,{value:"Module"}));async function ta(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,i,s]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const o=i;e.debugModels=Array.isArray(o==null?void 0:o.models)?o==null?void 0:o.models:[],e.debugHeartbeat=s}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}const na="taskmaster-access-session",yc={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function ia(){try{return localStorage.getItem(na)}catch{return null}}function vc(e){try{localStorage.setItem(na,e)}catch{}}function Th(){try{localStorage.removeItem(na)}catch{}}async function Cr(e){if(e.client)try{const t=ia(),n=await e.client.request("access.status",{token:t});e.accessState={...e.accessState,checked:!0,hasPins:n.hasPins,hasMasterPin:n.hasMasterPin,accounts:n.accounts??[],authenticated:n.authenticated,workspace:n.workspace,master:n.master,error:null}}catch{e.accessState={...e.accessState,checked:!0,hasPins:!1,hasMasterPin:!1,accounts:[],authenticated:!0,error:null}}}async function _h(e,t,n){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const i=await e.client.request("access.verify",{account:t,pin:n});i.ok&&i.token?(vc(i.token),e.accessState={...e.accessState,authenticated:!0,workspace:i.workspace??null,master:i.master??!1,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:i.message??"Incorrect PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to verify PIN"}}}}async function Mh(e,t){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const n=await e.client.request("access.setMasterPin",{pin:t});n.ok&&n.token?(vc(n.token),e.accessState={...e.accessState,checked:!0,hasPins:!0,hasMasterPin:!0,authenticated:!0,workspace:null,master:!0,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:"Failed to set PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to set PIN"}}}}async function Ph(e,t,n){if(!e.client)return!1;try{return(await e.client.request("access.setAccountPin",{workspace:t,pin:n})).ok}catch{return!1}}async function Ih(e){const t=ia();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}Th(),e.accessState={...yc,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}const Rh=2e3,Lh=new Set(["trace","debug","info","warn","error","fatal"]);function Dh(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 Bh(e){if(typeof e!="string")return null;const t=e.toLowerCase();return Lh.has(t)?t:null}function bc(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,i=typeof t.time=="string"?t.time:typeof(n==null?void 0:n.date)=="string"?n==null?void 0:n.date:null,s=Bh((n==null?void 0:n.logLevelName)??(n==null?void 0:n.level)),o=typeof t[0]=="string"?t[0]:typeof(n==null?void 0:n.name)=="string"?n==null?void 0:n.name:null,a=Dh(o);let r=null;a&&(typeof a.subsystem=="string"?r=a.subsystem:typeof a.module=="string"&&(r=a.module)),!r&&o&&o.length<120&&(r=o);let l=null;return typeof t[1]=="string"?l=t[1]:!a&&typeof t[0]=="string"?l=t[0]:typeof t.message=="string"&&(l=t.message),{raw:e,time:i,level:s,subsystem:r,message:l??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function bt(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.logsLoading=!0),e.logsError=null;try{const i=await e.client.request("logs.tail",{cursor:t!=null&&t.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes,date:e.logsDate??void 0,accessToken:ia()??void 0}),o=(Array.isArray(i.lines)?i.lines.filter(r=>typeof r=="string"):[]).map(bc),a=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=a?o:[...e.logsEntries,...o].slice(-Rh),typeof i.cursor=="number"&&(e.logsCursor=i.cursor),typeof i.file=="string"&&(e.logsFile=i.file),Array.isArray(i.availableDates)&&(e.logsAvailableDates=i.availableDates.filter(r=>typeof r=="string")),e.logsTruncated=!!i.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t!=null&&t.quiet||(e.logsLoading=!1)}}}const Nh=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:bt,parseLogLine:bc},Symbol.toStringTag,{value:"Module"}));const wc={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ue,n:Ai,Gx:Er,Gy:Tr,a:Fs,d:Us,h:Oh}=wc,Et=32,sa=64,Fh=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},re=(e="")=>{const t=new Error(e);throw Fh(t,re),t},Uh=e=>typeof e=="bigint",Wh=e=>typeof e=="string",zh=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",ct=(e,t,n="")=>{const i=zh(e),s=e==null?void 0:e.length,o=t!==void 0;if(!i||o&&s!==t){const a=n&&`"${n}" `,r=o?` of length ${t}`:"",l=i?`length=${s}`:`type=${typeof e}`;re(a+"expected Uint8Array"+r+", got "+l)}return e},rs=e=>new Uint8Array(e),kc=e=>Uint8Array.from(e),xc=(e,t)=>e.toString(16).padStart(t,"0"),$c=e=>Array.from(ct(e)).map(t=>xc(t,2)).join(""),Ge={_0:48,_9:57,A:65,F:70,a:97,f:102},_r=e=>{if(e>=Ge._0&&e<=Ge._9)return e-Ge._0;if(e>=Ge.A&&e<=Ge.F)return e-(Ge.A-10);if(e>=Ge.a&&e<=Ge.f)return e-(Ge.a-10)},Sc=e=>{const t="hex invalid";if(!Wh(e))return re(t);const n=e.length,i=n/2;if(n%2)return re(t);const s=rs(i);for(let o=0,a=0;o<i;o++,a+=2){const r=_r(e.charCodeAt(a)),l=_r(e.charCodeAt(a+1));if(r===void 0||l===void 0)return re(t);s[o]=r*16+l}return s},Ac=()=>globalThis==null?void 0:globalThis.crypto,Kh=()=>{var e;return((e=Ac())==null?void 0:e.subtle)??re("crypto.subtle must be defined, consider polyfill")},Kn=(...e)=>{const t=rs(e.reduce((i,s)=>i+ct(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},Hh=(e=Et)=>Ac().getRandomValues(rs(e)),Fi=BigInt,gt=(e,t,n,i="bad number: out of range")=>Uh(e)&&t<=e&&e<n?e:re(i),L=(e,t=ue)=>{const n=e%t;return n>=0n?n:t+n},Cc=e=>L(e,Ai),qh=(e,t)=>{(e===0n||t<=0n)&&re("no inverse n="+e+" mod="+t);let n=L(e,t),i=t,s=0n,o=1n;for(;n!==0n;){const a=i/n,r=i%n,l=s-o*a;i=n,n=r,s=o,o=l}return i===1n?L(s,t):re("no inverse")},jh=e=>{const t=Mc[e];return typeof t!="function"&&re("hashes."+e+" not set"),t},Ws=e=>e instanceof Tt?e:re("Point expected"),$o=2n**256n,Ue=class Ue{constructor(t,n,i,s){q(this,"X");q(this,"Y");q(this,"Z");q(this,"T");const o=$o;this.X=gt(t,0n,o),this.Y=gt(n,0n,o),this.Z=gt(i,1n,o),this.T=gt(s,0n,o),Object.freeze(this)}static CURVE(){return wc}static fromAffine(t){return new Ue(t.x,t.y,1n,L(t.x*t.y))}static fromBytes(t,n=!1){const i=Us,s=kc(ct(t,Et)),o=t[31];s[31]=o&-129;const a=Tc(s);gt(a,0n,n?$o:ue);const l=L(a*a),d=L(l-1n),h=L(i*l+1n);let{isValid:u,value:p}=Vh(d,h);u||re("bad point: y not sqrt");const v=(p&1n)===1n,$=(o&128)!==0;return!n&&p===0n&&$&&re("bad point: x==0, isLastByteOdd"),$!==v&&(p=L(-p)),new Ue(p,a,1n,L(p*a))}static fromHex(t,n){return Ue.fromBytes(Sc(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Fs,n=Us,i=this;if(i.is0())return re("bad point: ZERO");const{X:s,Y:o,Z:a,T:r}=i,l=L(s*s),d=L(o*o),h=L(a*a),u=L(h*h),p=L(l*t),v=L(h*L(p+d)),$=L(u+L(n*L(l*d)));if(v!==$)return re("bad point: equation left != right (1)");const S=L(s*o),M=L(a*r);return S!==M?re("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:a,Z:r}=Ws(t),l=L(n*r),d=L(o*s),h=L(i*r),u=L(a*s);return l===d&&h===u}is0(){return this.equals(jt)}negate(){return new Ue(L(-this.X),this.Y,this.Z,L(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=Fs,o=L(t*t),a=L(n*n),r=L(2n*L(i*i)),l=L(s*o),d=t+n,h=L(L(d*d)-o-a),u=l+a,p=u-r,v=l-a,$=L(h*p),S=L(u*v),M=L(h*v),y=L(p*u);return new Ue($,S,y,M)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:a,Y:r,Z:l,T:d}=Ws(t),h=Fs,u=Us,p=L(n*a),v=L(i*r),$=L(o*u*d),S=L(s*l),M=L((n+i)*(a+r)-p-v),y=L(S-$),b=L(S+$),k=L(v-h*p),A=L(M*y),E=L(b*k),T=L(M*k),P=L(y*b);return new Ue(A,E,P,T)}subtract(t){return this.add(Ws(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return jt;if(gt(t,1n,Ai),t===1n)return this;if(this.equals(_t))return af(t).p;let i=jt,s=_t;for(let o=this;t>0n;o=o.double(),t>>=1n)t&1n?i=i.add(o):n&&(s=s.add(o));return i}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:i}=this;if(this.equals(jt))return{x:0n,y:1n};const s=qh(i,ue);L(i*s)!==1n&&re("invalid inverse");const o=L(t*s),a=L(n*s);return{x:o,y:a}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=Ec(n);return i[31]|=t&1n?128:0,i}toHex(){return $c(this.toBytes())}clearCofactor(){return this.multiply(Fi(Oh),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Ai/2n,!1).double();return Ai%2n&&(t=t.add(this)),t.is0()}};q(Ue,"BASE"),q(Ue,"ZERO");let Tt=Ue;const _t=new Tt(Er,Tr,1n,L(Er*Tr)),jt=new Tt(0n,1n,1n,0n);Tt.BASE=_t;Tt.ZERO=jt;const Ec=e=>Sc(xc(gt(e,0n,$o),sa)).reverse(),Tc=e=>Fi("0x"+$c(kc(ct(e)).reverse())),De=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=ue;return n},Gh=e=>{const n=e*e%ue*e%ue,i=De(n,2n)*n%ue,s=De(i,1n)*e%ue,o=De(s,5n)*s%ue,a=De(o,10n)*o%ue,r=De(a,20n)*a%ue,l=De(r,40n)*r%ue,d=De(l,80n)*l%ue,h=De(d,80n)*l%ue,u=De(h,10n)*o%ue;return{pow_p_5_8:De(u,2n)*e%ue,b2:n}},Mr=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Vh=(e,t)=>{const n=L(t*t*t),i=L(n*n*t),s=Gh(e*i).pow_p_5_8;let o=L(e*n*s);const a=L(t*o*o),r=o,l=L(o*Mr),d=a===e,h=a===L(-e),u=a===L(-e*Mr);return d&&(o=r),(h||u)&&(o=l),(L(o)&1n)===1n&&(o=L(-o)),{isValid:d||h,value:o}},So=e=>Cc(Tc(e)),oa=(...e)=>Mc.sha512Async(Kn(...e)),Qh=(...e)=>jh("sha512")(Kn(...e)),_c=e=>{const t=e.slice(0,Et);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Et,sa),i=So(t),s=_t.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},aa=e=>oa(ct(e,Et)).then(_c),Jh=e=>_c(Qh(ct(e,Et))),Yh=e=>aa(e).then(t=>t.pointBytes),Xh=e=>oa(e.hashable).then(e.finish),Zh=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=So(t),a=_t.multiply(o).toBytes();return{hashable:Kn(a,i,n),finish:d=>{const h=Cc(o+So(d)*s);return ct(Kn(a,Ec(h)),sa)}}},ef=async(e,t)=>{const n=ct(e),i=await aa(t),s=await oa(i.prefix,n);return Xh(Zh(i,s,n))},Mc={sha512Async:async e=>{const t=Kh(),n=Kn(e);return rs(await t.digest("SHA-512",n.buffer))},sha512:void 0},tf=(e=Hh(Et))=>e,nf={getExtendedPublicKeyAsync:aa,getExtendedPublicKey:Jh,randomSecretKey:tf},Ui=8,sf=256,Pc=Math.ceil(sf/Ui)+1,Ao=2**(Ui-1),of=()=>{const e=[];let t=_t,n=t;for(let i=0;i<Pc;i++){n=t,e.push(n);for(let s=1;s<Ao;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Pr;const Ir=(e,t)=>{const n=t.negate();return e?n:t},af=e=>{const t=Pr||(Pr=of());let n=jt,i=_t;const s=2**Ui,o=s,a=Fi(s-1),r=Fi(Ui);for(let l=0;l<Pc;l++){let d=Number(e&a);e>>=r,d>Ao&&(d-=o,e+=1n);const h=l*Ao,u=h,p=h+Math.abs(d)-1,v=l%2!==0,$=d<0;d===0?i=i.add(Ir(v,t[u])):n=n.add(Ir($,t[p]))}return e!==0n&&re("invalid wnaf"),{p:n,f:i}},zs="taskmaster-device-identity-v1";function Co(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Ic(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),i=atob(n),s=new Uint8Array(i.length);for(let o=0;o<i.length;o+=1)s[o]=i.charCodeAt(o);return s}function rf(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Rc(e){const t=await crypto.subtle.digest("SHA-256",e);return rf(new Uint8Array(t))}async function lf(){const e=nf.randomSecretKey(),t=await Yh(e);return{deviceId:await Rc(t),publicKey:Co(t),privateKey:Co(e)}}async function cf(){try{const n=localStorage.getItem(zs);if(n){const i=JSON.parse(n);if((i==null?void 0:i.version)===1&&typeof i.deviceId=="string"&&typeof i.publicKey=="string"&&typeof i.privateKey=="string"){const s=await Rc(Ic(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(zs,JSON.stringify(o)),{deviceId:s,publicKey:i.publicKey,privateKey:i.privateKey}}return{deviceId:i.deviceId,publicKey:i.publicKey,privateKey:i.privateKey}}}}catch{}const e=await lf(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(zs,JSON.stringify(t)),e}async function df(e,t){const n=Ic(e),i=new TextEncoder().encode(t),s=await ef(i,n);return Co(s)}const Lc="taskmaster.device.auth.v1";function ra(e){return e.trim()}function uf(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const i=n.trim();i&&t.add(i)}return[...t].sort()}function la(){try{const e=window.localStorage.getItem(Lc);if(!e)return null;const t=JSON.parse(e);return!t||t.version!==1||!t.deviceId||typeof t.deviceId!="string"||!t.tokens||typeof t.tokens!="object"?null:t}catch{return null}}function Dc(e){try{window.localStorage.setItem(Lc,JSON.stringify(e))}catch{}}function pf(e){const t=la();if(!t||t.deviceId!==e.deviceId)return null;const n=ra(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function hf(e){const t=ra(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=la();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:uf(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,Dc(n),s}function ff(e){const t=la();if(!t||t.deviceId!==e.deviceId)return;const n=ra(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],Dc(i)}async function ca(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t!=null&&t.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n==null?void 0:n.pending)?n.pending:[],paired:Array.isArray(n==null?void 0:n.paired)?n.paired:[]}}catch(n){t!=null&&t.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function da(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,t!=null&&t.quiet||(e.lastError=null);try{const n=await e.client.request("node.list",{});e.nodes=Array.isArray(n.nodes)?n.nodes:[]}catch(n){t!=null&&t.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function gf(e){return{method:"exec.approvals.get",params:{}}}async function mf(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=gf(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);yf(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function yf(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=lt(t.file??{}))}async function Bc(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 xe(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function $e(e){return e instanceof Error?e.message:String(e)}function Hn(){return{name:"",skillContent:"",references:[],alwaysActive:!1}}async function Pe(e,t){if(t!=null&&t.clearMessages&&Object.keys(e.skillMessages).length>0&&(e.skillMessages={}),!(!e.client||!e.connected)&&!e.skillsLoading){e.skillsLoading=!0,e.skillsError=null;try{const n=await e.client.request("skills.status",{});n&&(e.skillsReport=n)}catch(n){e.skillsError=$e(n)}finally{e.skillsLoading=!1}}}function Nc(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Oc(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 Pe(e),xe(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=$e(i);e.skillsError=s,xe(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Fc(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const n=e.skillEdits[t]??"";await e.client.request("skills.update",{skillKey:t,apiKey:n}),await Pe(e),xe(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=$e(n);e.skillsError=i,xe(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Uc(e,t,n,i){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const s=await e.client.request("skills.install",{name:n,installId:i,timeoutMs:12e4});await Pe(e),xe(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=$e(s);e.skillsError=o,xe(e,t,{kind:"error",message:o})}finally{e.skillsBusyKey=null}}}async function Wc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("skills.read",{name:t});n&&(e.skillDetail=n,e.skillDetailTab="SKILL.md")}catch(n){e.skillsError=$e(n)}}function zc(e){e.skillDetail=null,e.skillDetailTab=""}function Kc(e,t){e.skillDetailTab=t}async function Hc(e){if(e.skillAddModal=!0,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[],!(!e.client||!e.connected))try{const t=await e.client.request("skills.drafts",{});t&&(e.skillDrafts=t.drafts)}catch{}}function qc(e){e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[]}function jc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n})),alwaysActive:!1},e.skillAddFormSource="draft"}async function Gc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n})),alwaysActive:!1},e.skillAddFormSource="installed",await ua(e)}async function ua(e){if(!e.client||!e.connected)return;const t=e.skillAddForm;if(!(!t.name.trim()||!t.skillContent.trim())){e.skillsBusyKey="__add__",e.skillsError=null;try{const n=t.references.filter(s=>s.name.trim()&&s.content.trim()).map(s=>({name:s.name.trim(),content:s.content})),i=t.name.trim();e.skillAddFormSource==="installed"?(await e.client.request("skills.create",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0,alwaysActive:t.alwaysActive}),e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillDrafts=[],await Pe(e),xe(e,i,{kind:"success",message:"Skill saved — active on next message"})):(await e.client.request("skills.saveDraft",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillDrafts=[],xe(e,i,{kind:"success",message:"Draft saved"}))}catch(n){e.skillsError=$e(n)}finally{e.skillsBusyKey=null}}}async function Vc(e,t){if(!(!e.client||!e.connected))try{await e.client.request("skills.deleteDraft",{name:t}),e.skillDrafts=e.skillDrafts.filter(n=>n.name!==t)}catch(n){e.skillsError=$e(n)}}async function Qc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("skills.read",{name:t});if(!n)return;e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i})),alwaysActive:n.alwaysActive??!1},e.skillAddFormSource="installed",e.skillAddModal=!0,e.skillDrafts=[]}catch(n){e.skillsError=$e(n)}}function Jc(e,t){const n=e.skillDetail;n&&(e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i})),alwaysActive:n.alwaysActive??!1},e.skillAddFormSource="installed",e.skillEditTab=t&&t!=="SKILL.md"?t:"SKILL.md",e.skillDetail=null,e.skillDetailTab="",e.skillAddModal=!0,e.skillDrafts=[])}function Yc(e,t,n){e.skillAddForm={...e.skillAddForm,references:e.skillAddForm.references.map(i=>i.name===t?{...i,content:n}:i)}}function Xc(e,t){e.skillEditTab=t}async function Zc(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const i=await e.client.request("skills.read",{name:t});if(!i)return;const s=i.references.filter(o=>o.name.trim()&&o.content.trim()).map(o=>({name:o.name.trim(),content:o.content}));await e.client.request("skills.create",{name:t,skillContent:i.content,references:s.length>0?s:void 0,alwaysActive:n}),await Pe(e),xe(e,t,{kind:"success",message:n?"Skill is now always active":"Skill loads on demand"})}catch(i){e.skillsError=$e(i),xe(e,t,{kind:"error",message:$e(i)})}finally{e.skillsBusyKey=null}}}async function ed(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.update",{skillKey:t,agents:n}),await Pe(e),xe(e,t,{kind:"success",message:"Agent access updated"})}catch(i){const s=$e(i);e.skillsError=s,xe(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function td(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.delete",{name:t}),await Pe(e)}catch(n){e.skillsError=$e(n)}finally{e.skillsBusyKey=null}}}const vf=Object.freeze(Object.defineProperty({__proto__:null,closeAddSkillModal:qc,closeSkillDetail:zc,deleteDraft:Vc,deleteSkill:td,editDetailSkill:Jc,editSkill:Qc,emptyAddForm:Hn,importDraft:jc,installDraft:Gc,installSkill:Uc,loadSkills:Pe,openAddSkillModal:Hc,saveNewSkill:ua,saveSkillApiKey:Fc,setEditTab:Xc,setSkillDetailTab:Kc,toggleAlwaysActive:Zc,updateFormReference:Yc,updateSkillAgents:ed,updateSkillEdit:Nc,updateSkillEnabled:Oc,viewSkillDetail:Wc},Symbol.toStringTag,{value:"Module"})),nd={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},id=new Map(Object.entries(nd).map(([e,t])=>[t,e]));function ls(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function qn(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 bf(e,t=""){const n=ls(t),i=nd[e];return n?`${n}${i}`:i}function sd(e,t=""){const n=ls(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=qn(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":id.get(s)??null}function wf(e){let t=qn(e);if(t.endsWith("/index.html")&&(t=qn(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let i=0;i<n.length;i++){const s=`/${n.slice(i).join("/")}`.toLowerCase();if(id.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function kf(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function pa(e){return e==="system"?kf():e}const di=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,xf=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,ui=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},$f=({nextTheme:e,applyTheme:t,context:n,currentTheme:i})=>{var d;if(i===e)return;const s=globalThis.document??null;if(!s){t();return}const o=s.documentElement,a=s,r=xf();if(!!a.startViewTransition&&!r){let h=.5,u=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")h=di(n.pointerClientX/window.innerWidth),u=di(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const p=n.element.getBoundingClientRect();p.width>0&&p.height>0&&typeof window<"u"&&(h=di((p.left+p.width/2)/window.innerWidth),u=di((p.top+p.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${h*100}%`),o.style.setProperty("--theme-switch-y",`${u*100}%`),o.classList.add("theme-transition");try{const p=(d=a.startViewTransition)==null?void 0:d.call(a,()=>{t()});p!=null&&p.finished?p.finished.finally(()=>ui(o)):ui(o)}catch{ui(o),t()}return}t(),ui(o)},Sf=2e3;async function Pn(e,t){if(!(!e.client||!e.connected)&&!(e.sessionLogsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.sessionLogsLoading=!0),e.sessionLogsError=null;try{const n={cursors:t!=null&&t.reset?void 0:e.sessionLogsCursors,limit:500};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(n.agents=e.workspaceAgentIds);const s=await e.client.request("sessions.transcript",n),o=Array.isArray(s.entries)?s.entries:[],a=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=a?o:[...e.sessionLogsEntries,...o].slice(-Sf),s.cursors&&(e.sessionLogsCursors=s.cursors),Array.isArray(s.agents)&&(e.sessionLogsAgents=s.agents),e.sessionLogsLastFetchAt=Date.now()}catch(n){e.sessionLogsError=String(n)}finally{t!=null&&t.quiet||(e.sessionLogsLoading=!1)}}}const od=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:Pn},Symbol.toStringTag,{value:"Module"}));async function ad(e,t){if(!(!e.client||!e.connected))try{const n={},i=await e.client.request("memory.audit",n);i!=null&&i.ok&&(e.auditEntries=i.entries??[])}catch{}}async function Af(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function ze(e){return e instanceof Error?e.message:String(e)}let pi=null;function an(e,t){pi&&clearTimeout(pi),e.filesMessage={kind:"success",text:t},pi=setTimeout(()=>{e.filesMessage=null,pi=null},3e3)}async function rn(e,t){if(!(!e.client||!e.connected)){if(!t){e.filesTree=[],e.filesRoot="";return}if(!e.filesLoading){e.filesLoading=!0,e.filesError=null;try{const n={};t&&(n.agentId=t);const i=await e.client.request("files.tree",n);i!=null&&i.tree&&(e.filesTree=i.tree,e.filesRoot=i.root??"")}catch(n){e.filesError=ze(n)}finally{e.filesLoading=!1}}}}async function Cf(e,t,n){e.filesSelectedPaths=new Set([t]),await rd(e,t,n)}async function Ef(e,t,n){const i=new Set(e.filesSelectedPaths);if(i.has(t)?i.delete(t):i.add(t),e.filesSelectedPaths=i,i.size===1){const s=[...i][0];await rd(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function Tf(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let i=0,s="";for(const o of n)try{await ld(e,o,t),i++}catch(a){s=ze(a)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:an(e,`${i} file${i!==1?"s":""} downloaded`)}async function _f(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await Rf(e,t,o,i)}async function rd(e,t,n){if(!(!e.client||!e.connected)){e.filesSelectedPath=t,e.filesPreviewLoading=!0,e.filesPreviewContent=null,e.filesPreviewBinary=!1,e.filesPreviewSize=null;try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.read",i);e.filesPreviewContent=(s==null?void 0:s.content)??null,e.filesPreviewBinary=(s==null?void 0:s.binary)??!1,e.filesPreviewSize=(s==null?void 0:s.size)??null}catch(i){e.filesError=ze(i)}finally{e.filesPreviewLoading=!1}}}async function ld(e,t,n){if(!(!e.client||!e.connected))try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.download",i);if(!(s!=null&&s.base64)){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const o=Uint8Array.from(atob(s.base64),d=>d.charCodeAt(0)),a=new Blob([o]),r=URL.createObjectURL(a),l=document.createElement("a");l.href=r,l.download=s.name??t.split("/").pop()??"download",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(r)}catch(i){e.filesMessage={kind:"error",text:ze(i)}}}async function Mf(e,t,n,i){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let s=0,o="";for(const a of n)try{const r=await a.arrayBuffer(),l=btoa(new Uint8Array(r).reduce((h,u)=>h+String.fromCharCode(u),"")),d={path:t,name:a.name,data:l};i&&(d.agentId=i),await e.client.request("files.upload",d),s++}catch(r){o=ze(r)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:an(e,`${s} file${s!==1?"s":""} uploaded`),await rn(e,i)}async function Pf(e,t,n,i){if(!e.client||!e.connected)return;e.filesMessage=null;const s=t==="."?n:`${t}/${n}`;try{const o={path:s};i&&(o.agentId=i),await e.client.request("files.mkdir",o),an(e,`Created ${s}`),await rn(e,i),e.filesExpandedDirs=new Set([...e.filesExpandedDirs,s]),e.filesCurrentDir=s}catch(o){e.filesMessage={kind:"error",text:ze(o)}}}async function If(e,t,n){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const i={path:t};n&&(i.agentId=n),await e.client.request("files.delete",i),an(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await rn(e,n)}catch(i){e.filesMessage={kind:"error",text:ze(i)}}}}async function Rf(e,t,n,i){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const s={from:t,to:n};i&&(s.agentId=i),await e.client.request("files.move",s),an(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await rn(e,i)}catch(s){e.filesMessage={kind:"error",text:ze(s)}}}}async function cs(e,t){if(!(!e.client||!e.connected))try{const n={};t&&(n.agentId=t);const i=await e.client.request("memory.status",n);i!=null&&i.ok&&(e.filesMemoryStatus={dirty:i.dirty??!1,syncing:i.syncing,syncProgress:i.syncProgress,files:i.files??0,chunks:i.chunks??0,model:i.model,embeddingState:i.embeddingState})}catch{}}async function Lf(e,t){if(!(!e.client||!e.connected)&&!e.filesReindexBusy){e.filesReindexBusy=!0,e.filesMessage=null;try{const n={force:!0};t&&(n.agentId=t);const i=await e.client.request("memory.reindex",n),s=(i==null?void 0:i.files)??0,o=(i==null?void 0:i.chunks)??0;an(e,`Re-indexed: ${s} files, ${o} chunks`),await cs(e,t)}catch(n){e.filesMessage={kind:"error",text:ze(n)}}finally{e.filesReindexBusy=!1}}}function Df(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n,e.filesCurrentDir=t}async function Bf(e,t,n){if(!(!e.client||!e.connected)){if(!t.trim()){e.filesSearchResults=null;return}e.filesSearchLoading=!0,e.filesSearchResults=null;try{const i={query:t.trim(),maxResults:20};n&&(i.agentId=n);const s=await e.client.request("memory.search",i);e.filesSearchResults=(s==null?void 0:s.results)??[]}catch(i){e.filesMessage={kind:"error",text:ze(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function Nf(e){e.filesSearchQuery="",e.filesSearchResults=null}function Of(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{da(e,{quiet:!0})},5e3))}function Ff(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function ha(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&e.logsDate==null&&bt(e,{quiet:!0})},2e3))}function fa(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function ga(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||Pn(e,{quiet:!0})},2e3))}function ma(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function ya(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&ta(e)},3e3))}function va(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Uf(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{ad(e)},3e4))}function Wf(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function zf(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{const t=e;t.filesPage&&cs(t,t.filesResolvedAgentId)},3e3))}function Kf(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function at(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,Ip(n),t.theme!==e.theme&&(e.theme=t.theme,ds(e,pa(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function cd(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&at(e,{...e.settings,lastActiveSessionKey:n})}function Hf(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),i=t.get("password"),s=t.get("session"),o=t.get("gatewayUrl");let a=!1;if(n!=null){const l=n.trim();l&&l!==e.settings.token&&at(e,{...e.settings,token:l}),t.delete("token"),a=!0}if(i!=null){const l=i.trim();l&&(e.password=l),t.delete("password"),a=!0}if(s!=null){const l=s.trim();l&&(e.sessionKey=l,at(e,{...e.settings,sessionKey:l,lastActiveSessionKey:l}))}if(o!=null){const l=o.trim();l&&l!==e.settings.gatewayUrl&&at(e,{...e.settings,gatewayUrl:l}),t.delete("gatewayUrl"),a=!0}if(!a)return;const r=new URL(window.location.href);r.search=t.toString(),window.history.replaceState({},"",r.toString())}function qf(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?ga(e):ha(e):(fa(e),ma(e)),t==="debug"?ya(e):va(e),Wi(e),ud(e,t,!1)}function jf(e,t,n){$f({nextTheme:t,applyTheme:()=>{e.theme=t,at(e,{...e.settings,theme:t}),ds(e,pa(t))},context:n,currentTheme:e.theme})}async function Wi(e){if(e.tab==="overview"&&await pd(e),e.tab==="channels"&&await Zf(e),e.tab==="instances"&&await Bc(e),e.tab==="cron"&&await hd(e),e.tab==="skills"&&await Pe(e),e.tab==="nodes"&&(await da(e),await ca(e),await We(e),await mf(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await sg(e),sn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await dc(e),await We(e)),e.tab==="debug"&&(await ta(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await ae(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>od);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await bt(e,{reset:!0});lc(e,!0)}}function Gf(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?ls(e):wf(window.location.pathname)}function Vf(e){e.theme=e.settings.theme??"system",ds(e,pa(e.theme))}function ds(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function Qf(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"&&ds(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Jf(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 Yf(e,t){if(typeof window>"u")return;const n=sd(window.location.pathname,e.basePath)??"chat";dd(e,n),ud(e,n,t)}function Xf(e){var s;if(typeof window>"u")return;const t=sd(window.location.pathname,e.basePath);if(!t)return;const i=(s=new URL(window.location.href).searchParams.get("session"))==null?void 0:s.trim();i&&(e.sessionKey=i,at(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),dd(e,t)}function dd(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?ga(e):ha(e):(fa(e),ma(e)),t==="debug"?ya(e):va(e),e.connected&&Wi(e)}function ud(e,t,n){if(typeof window>"u")return;const i=qn(bf(t,e.basePath)),s=qn(window.location.pathname),o=new URL(window.location.href);t==="chat"&&e.sessionKey?o.searchParams.set("session",e.sessionKey):o.searchParams.delete("session"),s!==i&&(o.pathname=i),n?window.history.replaceState({},"",o.toString()):window.history.pushState({},"",o.toString())}async function pd(e){await Promise.all([Z(e,!1),Bc(e),rc(e),on(e),ta(e)])}async function Zf(e){await Promise.all([Z(e,!0),dc(e),We(e)])}async function hd(e){await Promise.all([Z(e,!1),on(e),jn(e)])}function fd(e){return e.chatSending||!!e.chatRunId}function eg(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 gd(e){e.connected&&(e.chatMessage="",await oc(e))}function tg(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:as(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],sn(e))}async function md(e,t,n){var s,o;Zo(e);const i=await sc(e,t,n==null?void 0:n.attachments);return!i&&(n==null?void 0:n.previousDraft)!=null&&(e.chatMessage=n.previousDraft),!i&&(n!=null&&n.previousAttachments)&&(e.chatAttachments=n.previousAttachments),i&&cd(e,e.sessionKey),i&&(n!=null&&n.restoreDraft)&&((s=n.previousDraft)!=null&&s.trim())&&(e.chatMessage=n.previousDraft),i&&(n!=null&&n.restoreAttachments)&&((o=n.previousAttachments)!=null&&o.length)&&(e.chatAttachments=n.previousAttachments),sn(e),i&&!e.chatRunId&&yd(e),i}async function yd(e){if(!e.connected||fd(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await md(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function ng(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function ig(e,t,n){if(!e.connected)return;const i=e.chatMessage,s=(t??e.chatMessage).trim(),o=e.chatAttachments??[],a=t==null?o:[],r=a.length>0;if(!(!s&&!r)){if(eg(s)){await gd(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[],Lp(e.selectedWorkspace??"",e.sessionKey)),fd(e)){tg(e,s,a);return}await md(e,s,{previousDraft:t==null?i:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:r?a:void 0,previousAttachments:t==null?o:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function sg(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,nn);await Promise.all([Jt(t,{limit:n}),rc(t),Eo(e)]),sn(e,!0)}const og=yd;function ag(e){var s,o,a;const t=Jl(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(s=e.hello)==null?void 0:s.snapshot;return((a=(o=n==null?void 0:n.sessionDefaults)==null?void 0:o.defaultAgentId)==null?void 0:a.trim())||"main"}function rg(e,t){const n=ls(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Eo(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=ag(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=rg(e.basePath,t);try{const i=await fetch(n,{method:"GET"});if(!i.ok){e.chatAvatarUrl=null;return}const s=await i.json(),o=typeof s.avatarUrl=="string"?s.avatarUrl.trim():"";e.chatAvatarUrl=o||null}catch{e.chatAvatarUrl=null}}const I={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>`,unlink:c`<svg viewBox="0 0 24 24"><path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"/><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"/><line x1="8" x2="8" y1="2" y2="5"/><line x1="2" x2="5" y1="8" y2="8"/><line x1="16" x2="16" y1="19" y2="22"/><line x1="19" x2="22" y1="16" y2="16"/></svg>`,radio: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>`,users:c`<svg viewBox="0 0 24 24"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>`,user:c`<svg viewBox="0 0 24 24"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></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>`,rotateCw:c`<svg viewBox="0 0 24 24"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>`,refreshCw:c`<svg viewBox="0 0 24 24"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/></svg>`,download:c`<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,wrench: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>`,globeOff:c`<svg viewBox="0 0 24 24"><path d="M21.54 15H17"/><path d="M7 3.34V5a3 3 0 0 0 3 3 2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17"/><path d="M11 21.95V18a2 2 0 0 0-2-2 2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05"/><circle cx="12" cy="12" r="10"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,image: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>`,circleCheck:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>`,puzzle: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>`,info:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>`,send:c`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`,slidersHorizontal:c`<svg viewBox="0 0 24 24"><line x1="21" x2="14" y1="4" y2="4"/><line x1="10" x2="3" y1="4" y2="4"/><line x1="21" x2="12" y1="12" y2="12"/><line x1="8" x2="3" y1="12" y2="12"/><line x1="21" x2="16" y1="20" y2="20"/><line x1="12" x2="3" y1="20" y2="20"/><line x1="14" x2="14" y1="2" y2="6"/><line x1="8" x2="8" y1="10" y2="14"/><line x1="16" x2="16" y1="18" y2="22"/></svg>`,square:c`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:c`<svg viewBox="0 0 24 24"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`,eyeOff:c`<svg viewBox="0 0 24 24"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,trash:c`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,mic:c`<svg viewBox="0 0 24 24"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" x2="12" y1="19" y2="22"/></svg>`,chevronDown:c`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,chevronLeft:c`<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>`,chevronRight:c`<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>`,film:c`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/></svg>`,wifi:c`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M2 8.82a15 15 0 0 1 20 0"/><path d="M5 12.859a10 10 0 0 1 14 0"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/></svg>`,wifiOff:c`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/><path d="M5 12.859a10 10 0 0 1 5.17-2.69"/><path d="M13.41 10.28a10 10 0 0 1 5.59 2.58"/><path d="M2 8.82a15 15 0 0 1 4.17-2.65"/><path d="M10.66 5c4.01-.36 8.14.9 11.34 3.76"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,power:c`<svg viewBox="0 0 24 24"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"/><line x1="12" x2="12" y1="2" y2="12"/></svg>`,powerOff:c`<svg viewBox="0 0 24 24"><path d="M18.36 6.64A9 9 0 0 1 20.77 15"/><path d="M6.16 6.16a9 9 0 1 0 12.68 12.68"/><path d="M12 2v4"/><path d="m2 2 20 20"/></svg>`},lg=c`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`,cg=c`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path><path d="M13.73 21a2 2 0 0 1-3.46 0"></path></svg>`,dg=c`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"></path><line x1="12" y1="2" x2="12" y2="12"></line></svg>`;let Rr=!1;function ug(){Rr||(Rr=!0,document.addEventListener("click",e=>{const t=document.getElementById("nav-burger-toggle");if(!(t!=null&&t.checked))return;const n=t.closest(".setup-header");n!=null&&n.contains(e.target)||(t.checked=!1)}))}function Rt(e,t){var u;const n=(p,v)=>p===e?c`<span class="sp-page-nav-current">${p}</span>`:c`<a href=${v}>${p}</a>`,i=c`
|
|
21
21
|
${n("Setup","/setup")}
|
|
22
22
|
${n("Chat","/chat")}
|
|
23
23
|
${n("Admins","/admins")}
|
|
@@ -689,19 +689,19 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
689
689
|
</p>
|
|
690
690
|
</div>
|
|
691
691
|
</div>
|
|
692
|
-
`}function us(e,t){const n=new Map(t.whatsappAccounts.map(i=>[i.accountId,i]));return e.whatsappAccountId?n.get(e.whatsappAccountId)??null:e.isDefault&&t.whatsappAccounts.length===1?t.whatsappAccounts[0]??null:null}function Lt(e){var n;const t=(n=e.wsProps)==null?void 0:n.selectedWorkspace;return t?e.workspaces.find(i=>i.name===t)??null:e.workspaces[0]??null}function Ag(e){const t=Lt(e),n=(t==null?void 0:t.displayName)??(t==null?void 0:t.name)??Xe().name
|
|
692
|
+
`}function us(e,t){const n=new Map(t.whatsappAccounts.map(i=>[i.accountId,i]));return e.whatsappAccountId?n.get(e.whatsappAccountId)??null:e.isDefault&&t.whatsappAccounts.length===1?t.whatsappAccounts[0]??null:null}function Lt(e){var n;const t=(n=e.wsProps)==null?void 0:n.selectedWorkspace;return t?e.workspaces.find(i=>i.name===t)??null:e.workspaces[0]??null}function Ag(e){const t=Lt(e),n=(t==null?void 0:t.displayName)??(t==null?void 0:t.name)??Xe().name;if(e.renamingWorkspace&&t){const i=()=>{const s=e.renameWorkspaceName.trim();s&&e.onWorkspaceRename(t.name,s)};return c`
|
|
693
693
|
<div style="display: flex; align-items: center; gap: 6px; margin-bottom: 4px;">
|
|
694
694
|
<input
|
|
695
695
|
type="text"
|
|
696
696
|
.value=${e.renameWorkspaceName}
|
|
697
|
-
@input=${
|
|
698
|
-
@keydown=${
|
|
697
|
+
@input=${s=>{e.renameWorkspaceName=s.target.value}}
|
|
698
|
+
@keydown=${s=>{s.key==="Enter"&&i(),s.key==="Escape"&&e.onWorkspaceRenameCancel()}}
|
|
699
699
|
style="flex: 1; font-size: 18px; font-weight: 600; background: var(--tasker-bg-input, rgba(255,255,255,0.08)); border: 1px solid var(--tasker-border, rgba(255,255,255,0.15)); border-radius: 6px; color: var(--tasker-white); padding: 4px 8px; outline: none;"
|
|
700
700
|
autofocus
|
|
701
701
|
/>
|
|
702
702
|
<button
|
|
703
703
|
class="setup-status-action"
|
|
704
|
-
@click=${
|
|
704
|
+
@click=${i}
|
|
705
705
|
title="Save"
|
|
706
706
|
style="color: #22c55e;"
|
|
707
707
|
>${I.check}</button>
|
|
@@ -712,24 +712,14 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
712
712
|
>${I.x}</button>
|
|
713
713
|
</div>
|
|
714
714
|
`}return c`
|
|
715
|
-
<div style="display: flex; align-items: center;
|
|
716
|
-
<
|
|
717
|
-
<h2 style="margin: 0; font-size: 20px; font-weight: 600; color: var(--tasker-white);">${n}</h2>
|
|
718
|
-
<button
|
|
719
|
-
class="setup-status-action"
|
|
720
|
-
@click=${e.onWorkspaceRenameStart}
|
|
721
|
-
title="Rename"
|
|
722
|
-
style="opacity: 0.5; transform: scale(0.8);"
|
|
723
|
-
>${I.edit}</button>
|
|
724
|
-
</div>
|
|
715
|
+
<div style="display: flex; align-items: center; gap: 6px; margin-bottom: 4px;">
|
|
716
|
+
<h2 style="margin: 0; font-size: 20px; font-weight: 600; color: var(--tasker-white);">${n}</h2>
|
|
725
717
|
<button
|
|
726
|
-
class="setup-status-action
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
>
|
|
731
|
-
${I.rotateCw}
|
|
732
|
-
</button>
|
|
718
|
+
class="setup-status-action"
|
|
719
|
+
@click=${e.onWorkspaceRenameStart}
|
|
720
|
+
title="Rename"
|
|
721
|
+
style="opacity: 0.5; transform: scale(0.8);"
|
|
722
|
+
>${I.edit}</button>
|
|
733
723
|
</div>
|
|
734
724
|
`}function Cg(e){return c`
|
|
735
725
|
<div class="setup-status-item">
|
|
@@ -740,10 +730,10 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
740
730
|
</div>
|
|
741
731
|
${ce("gateway",e)}
|
|
742
732
|
<button
|
|
743
|
-
class="setup-status-action ${e.
|
|
744
|
-
?disabled=${e.
|
|
745
|
-
@click=${e.
|
|
746
|
-
title="
|
|
733
|
+
class="setup-status-action ${e.gatewayHealthLoading?"spinning":""}"
|
|
734
|
+
?disabled=${e.gatewayHealthLoading}
|
|
735
|
+
@click=${e.onRefreshGatewayStatus}
|
|
736
|
+
title="Refresh status"
|
|
747
737
|
>
|
|
748
738
|
${I.rotateCw}
|
|
749
739
|
</button>
|
|
@@ -765,7 +755,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
765
755
|
@click=${e.onClaudeAuthModalOpen}
|
|
766
756
|
title="Manage Connection"
|
|
767
757
|
>
|
|
768
|
-
${I.
|
|
758
|
+
${I.refreshCw}
|
|
769
759
|
</button>
|
|
770
760
|
`:c`
|
|
771
761
|
<button
|
|
@@ -773,7 +763,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
773
763
|
@click=${e.onClaudeAuthModalOpen}
|
|
774
764
|
title="Connect Claude"
|
|
775
765
|
>
|
|
776
|
-
${I.
|
|
766
|
+
${I.refreshCw}
|
|
777
767
|
</button>
|
|
778
768
|
`}
|
|
779
769
|
</div>
|
|
@@ -790,7 +780,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
790
780
|
@click=${()=>{e.licenseRemoveConfirm?e.onLicenseRemoveCancel():e.onLicenseRemoveConfirm()}}
|
|
791
781
|
title="Manage License"
|
|
792
782
|
>
|
|
793
|
-
${I.
|
|
783
|
+
${I.refreshCw}
|
|
794
784
|
</button>
|
|
795
785
|
${e.licenseRemoveConfirm?c`
|
|
796
786
|
<div style="width: 100%; margin-top: 8px; margin-left: 30px;">
|
|
@@ -832,7 +822,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
832
822
|
>${I.settings}</button>`:w}
|
|
833
823
|
${l&&d?c`<button
|
|
834
824
|
class="setup-status-action"
|
|
835
|
-
@click=${e.
|
|
825
|
+
@click=${e.onRefreshWhatsAppStatus}
|
|
836
826
|
title="Refresh status"
|
|
837
827
|
>${I.rotateCw}</button>`:w}
|
|
838
828
|
${h&&e.whatsappLoginQrDataUrl?c`
|
|
@@ -956,7 +946,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
956
946
|
@click=${e.onIMessageEnable}
|
|
957
947
|
title="${n?"Manage iMessage":"Connect iMessage"}"
|
|
958
948
|
>
|
|
959
|
-
${I.
|
|
949
|
+
${I.refreshCw}
|
|
960
950
|
</button>
|
|
961
951
|
${w}
|
|
962
952
|
</div>
|
|
@@ -1212,7 +1202,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
1212
1202
|
title="Regenerate greeting"
|
|
1213
1203
|
?disabled=${e.publicChatGreetingBusy}
|
|
1214
1204
|
@click=${e.onPublicChatGreetingRegenerate}
|
|
1215
|
-
>${e.publicChatGreetingBusy?I.loader:I.
|
|
1205
|
+
>${e.publicChatGreetingBusy?I.loader:I.refreshCw}</button>`:w}
|
|
1216
1206
|
</div>
|
|
1217
1207
|
${n||e.publicChatGreetingBusy?c`
|
|
1218
1208
|
<textarea
|
|
@@ -2764,7 +2754,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
2764
2754
|
|
|
2765
2755
|
${i?um(i,e):w}
|
|
2766
2756
|
${s?pm(s,e):w}
|
|
2767
|
-
`}const $d={CHILD:2},Sd=e=>(...t)=>({_$litDirective$:e,values:t});let Ad=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,i){this._$Ct=t,this._$AM=n,this._$Ci=i}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}};const{I:mm}=yp,Nr=e=>e,Or=()=>document.createComment(""),gn=(e,t,n)=>{var o;const i=e._$AA.parentNode,s=t===void 0?e._$AB:t._$AA;if(n===void 0){const a=i.insertBefore(Or(),s),r=i.insertBefore(Or(),s);n=new mm(a,r,e,e.options)}else{const a=n._$AB.nextSibling,r=n._$AM,l=r!==e;if(l){let d;(o=n._$AQ)==null||o.call(n,e),n._$AM=e,n._$AP!==void 0&&(d=e._$AU)!==r._$AU&&n._$AP(d)}if(a!==s||l){let d=n._$AA;for(;d!==a;){const h=Nr(d).nextSibling;Nr(i).insertBefore(d,s),d=h}}}return n},ft=(e,t,n=e)=>(e._$AI(t,n),e),ym={},vm=(e,t=ym)=>e._$AH=t,bm=e=>e._$AH,Ks=e=>{e._$AR(),e._$AA.remove()};const Fr=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},wm=Sd(class extends Ad{constructor(e){if(super(e),e.type!==$d.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let i;n===void 0?n=t:t!==void 0&&(i=t);const s=[],o=[];let a=0;for(const r of e)s[a]=i?i(r,a):a,o[a]=n(r,a),a++;return{values:o,keys:s}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const s=bm(e),{values:o,keys:a}=this.dt(t,n,i);if(!Array.isArray(s))return this.ut=a,o;const r=this.ut??(this.ut=[]),l=[];let d,h,u=0,p=s.length-1,v=0,$=o.length-1;for(;u<=p&&v<=$;)if(s[u]===null)u++;else if(s[p]===null)p--;else if(r[u]===a[v])l[v]=ft(s[u],o[v]),u++,v++;else if(r[p]===a[$])l[$]=ft(s[p],o[$]),p--,$--;else if(r[u]===a[$])l[$]=ft(s[u],o[$]),gn(e,l[$+1],s[u]),u++,$--;else if(r[p]===a[v])l[v]=ft(s[p],o[v]),gn(e,s[u],s[p]),p--,v++;else if(d===void 0&&(d=Fr(a,v,$),h=Fr(r,u,p)),d.has(r[u]))if(d.has(r[p])){const S=h.get(a[v]),M=S!==void 0?s[S]:null;if(M===null){const y=gn(e,s[u]);ft(y,o[v]),l[v]=y}else l[v]=ft(M,o[v]),gn(e,s[u],M),s[S]=null;v++}else Ks(s[p]),p--;else Ks(s[u]),u++;for(;v<=$;){const S=gn(e,l[$+1]);ft(S,o[v]),l[v++]=S}for(;u<=p;){const S=s[u++];S!==null&&Ks(S)}return this.ut=a,vm(e,l),rt}});class _o extends Ad{constructor(t){if(super(t),this.it=w,t.type!==$d.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===w||t==null)return this._t=void 0,this.it=t;if(t===rt)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:[]}}}_o.directiveName="unsafeHTML",_o.resultType=1;const Hi=Sd(_o);const{entries:Cd,setPrototypeOf:Ur,isFrozen:km,getPrototypeOf:xm,getOwnPropertyDescriptor:$m}=Object;let{freeze:me,seal:Se,create:Mo}=Object,{apply:Po,construct:Io}=typeof Reflect<"u"&&Reflect;me||(me=function(t){return t});Se||(Se=function(t){return t});Po||(Po=function(t,n){for(var i=arguments.length,s=new Array(i>2?i-2:0),o=2;o<i;o++)s[o-2]=arguments[o];return t.apply(n,s)});Io||(Io=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return new t(...i)});const hi=ye(Array.prototype.forEach),Sm=ye(Array.prototype.lastIndexOf),Wr=ye(Array.prototype.pop),mn=ye(Array.prototype.push),Am=ye(Array.prototype.splice),Ci=ye(String.prototype.toLowerCase),Hs=ye(String.prototype.toString),qs=ye(String.prototype.match),yn=ye(String.prototype.replace),Cm=ye(String.prototype.indexOf),Em=ye(String.prototype.trim),Ae=ye(Object.prototype.hasOwnProperty),fe=ye(RegExp.prototype.test),vn=Tm(TypeError);function ye(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return Po(e,t,i)}}function Tm(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Io(e,n)}}function z(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ci;Ur&&Ur(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(km(t)||(t[i]=o),s=o)}e[s]=!0}return e}function _m(e){for(let t=0;t<e.length;t++)Ae(e,t)||(e[t]=null);return e}function Ne(e){const t=Mo(null);for(const[n,i]of Cd(e))Ae(e,n)&&(Array.isArray(i)?t[n]=_m(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=Ne(i):t[n]=i);return t}function bn(e,t){for(;e!==null;){const i=$m(e,t);if(i){if(i.get)return ye(i.get);if(typeof i.value=="function")return ye(i.value)}e=xm(e)}function n(){return null}return n}const zr=me(["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"]),js=me(["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"]),Gs=me(["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"]),Mm=me(["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"]),Vs=me(["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"]),Pm=me(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Kr=me(["#text"]),Hr=me(["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"]),Qs=me(["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"]),qr=me(["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"]),fi=me(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Im=Se(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Rm=Se(/<%[\w\W]*|[\w\W]*%>/gm),Lm=Se(/\$\{[\w\W]*/gm),Dm=Se(/^data-[\-\w.\u00B7-\uFFFF]+$/),Bm=Se(/^aria-[\-\w]+$/),Ed=Se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Nm=Se(/^(?:\w+script|data):/i),Om=Se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Td=Se(/^html$/i),Fm=Se(/^[a-z][.\w]*(-[.\w]+)+$/i);var jr=Object.freeze({__proto__:null,ARIA_ATTR:Bm,ATTR_WHITESPACE:Om,CUSTOM_ELEMENT:Fm,DATA_ATTR:Dm,DOCTYPE_NAME:Td,ERB_EXPR:Rm,IS_ALLOWED_URI:Ed,IS_SCRIPT_OR_DATA:Nm,MUSTACHE_EXPR:Im,TMPLIT_EXPR:Lm});const wn={element:1,text:3,progressingInstruction:7,comment:8,document:9},Um=function(){return typeof window>"u"?null:window},Wm=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(i=n.getAttribute(s));const o="dompurify"+(i?"#"+i:"");try{return t.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Gr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function _d(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Um();const t=N=>_d(N);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==wn.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:r,Element:l,NodeFilter:d,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:u,DOMParser:p,trustedTypes:v}=e,$=l.prototype,S=bn($,"cloneNode"),M=bn($,"remove"),y=bn($,"nextSibling"),b=bn($,"childNodes"),k=bn($,"parentNode");if(typeof a=="function"){const N=n.createElement("template");N.content&&N.content.ownerDocument&&(n=N.content.ownerDocument)}let A,E="";const{implementation:T,createNodeIterator:P,createDocumentFragment:D,getElementsByTagName:W}=n,{importNode:K}=i;let H=Gr();t.isSupported=typeof Cd=="function"&&typeof k=="function"&&T&&T.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ke,ERB_EXPR:Ie,TMPLIT_EXPR:Ke,DATA_ATTR:vs,ARIA_ATTR:bs,IS_SCRIPT_OR_DATA:ws,ATTR_WHITESPACE:Qn,CUSTOM_ELEMENT:ks}=jr;let{IS_ALLOWED_URI:Jn}=jr,te=null;const Yn=z({},[...zr,...js,...Gs,...Vs,...Kr]);let ne=null;const Xn=z({},[...Hr,...Qs,...qr,...fi]);let X=Object.seal(Mo(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}})),dt=null,dn=null;const et=Object.seal(Mo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Zn=!0,C=!0,R=!1,F=!0,U=!1,Z=!0,J=!1,he=!1,tt=!1,Nt=!1,ei=!1,ti=!1,Ka=!0,Ha=!1;const Uu="user-content-";let xs=!0,un=!1,Ot={},Re=null;const $s=z({},["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 qa=null;const ja=z({},["audio","video","img","source","image","track"]);let Ss=null;const Ga=z({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ni="http://www.w3.org/1998/Math/MathML",ii="http://www.w3.org/2000/svg",He="http://www.w3.org/1999/xhtml";let Ft=He,As=!1,Cs=null;const Wu=z({},[ni,ii,He],Hs);let si=z({},["mi","mo","mn","ms","mtext"]),oi=z({},["annotation-xml"]);const zu=z({},["title","style","font","a","script"]);let pn=null;const Ku=["application/xhtml+xml","text/html"],Hu="text/html";let oe=null,Ut=null;const qu=n.createElement("form"),Va=function(x){return x instanceof RegExp||x instanceof Function},Es=function(){let x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ut&&Ut===x)){if((!x||typeof x!="object")&&(x={}),x=Ne(x),pn=Ku.indexOf(x.PARSER_MEDIA_TYPE)===-1?Hu:x.PARSER_MEDIA_TYPE,oe=pn==="application/xhtml+xml"?Hs:Ci,te=Ae(x,"ALLOWED_TAGS")?z({},x.ALLOWED_TAGS,oe):Yn,ne=Ae(x,"ALLOWED_ATTR")?z({},x.ALLOWED_ATTR,oe):Xn,Cs=Ae(x,"ALLOWED_NAMESPACES")?z({},x.ALLOWED_NAMESPACES,Hs):Wu,Ss=Ae(x,"ADD_URI_SAFE_ATTR")?z(Ne(Ga),x.ADD_URI_SAFE_ATTR,oe):Ga,qa=Ae(x,"ADD_DATA_URI_TAGS")?z(Ne(ja),x.ADD_DATA_URI_TAGS,oe):ja,Re=Ae(x,"FORBID_CONTENTS")?z({},x.FORBID_CONTENTS,oe):$s,dt=Ae(x,"FORBID_TAGS")?z({},x.FORBID_TAGS,oe):Ne({}),dn=Ae(x,"FORBID_ATTR")?z({},x.FORBID_ATTR,oe):Ne({}),Ot=Ae(x,"USE_PROFILES")?x.USE_PROFILES:!1,Zn=x.ALLOW_ARIA_ATTR!==!1,C=x.ALLOW_DATA_ATTR!==!1,R=x.ALLOW_UNKNOWN_PROTOCOLS||!1,F=x.ALLOW_SELF_CLOSE_IN_ATTR!==!1,U=x.SAFE_FOR_TEMPLATES||!1,Z=x.SAFE_FOR_XML!==!1,J=x.WHOLE_DOCUMENT||!1,Nt=x.RETURN_DOM||!1,ei=x.RETURN_DOM_FRAGMENT||!1,ti=x.RETURN_TRUSTED_TYPE||!1,tt=x.FORCE_BODY||!1,Ka=x.SANITIZE_DOM!==!1,Ha=x.SANITIZE_NAMED_PROPS||!1,xs=x.KEEP_CONTENT!==!1,un=x.IN_PLACE||!1,Jn=x.ALLOWED_URI_REGEXP||Ed,Ft=x.NAMESPACE||He,si=x.MATHML_TEXT_INTEGRATION_POINTS||si,oi=x.HTML_INTEGRATION_POINTS||oi,X=x.CUSTOM_ELEMENT_HANDLING||{},x.CUSTOM_ELEMENT_HANDLING&&Va(x.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(X.tagNameCheck=x.CUSTOM_ELEMENT_HANDLING.tagNameCheck),x.CUSTOM_ELEMENT_HANDLING&&Va(x.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(X.attributeNameCheck=x.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),x.CUSTOM_ELEMENT_HANDLING&&typeof x.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(X.allowCustomizedBuiltInElements=x.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),U&&(C=!1),ei&&(Nt=!0),Ot&&(te=z({},Kr),ne=[],Ot.html===!0&&(z(te,zr),z(ne,Hr)),Ot.svg===!0&&(z(te,js),z(ne,Qs),z(ne,fi)),Ot.svgFilters===!0&&(z(te,Gs),z(ne,Qs),z(ne,fi)),Ot.mathMl===!0&&(z(te,Vs),z(ne,qr),z(ne,fi))),x.ADD_TAGS&&(typeof x.ADD_TAGS=="function"?et.tagCheck=x.ADD_TAGS:(te===Yn&&(te=Ne(te)),z(te,x.ADD_TAGS,oe))),x.ADD_ATTR&&(typeof x.ADD_ATTR=="function"?et.attributeCheck=x.ADD_ATTR:(ne===Xn&&(ne=Ne(ne)),z(ne,x.ADD_ATTR,oe))),x.ADD_URI_SAFE_ATTR&&z(Ss,x.ADD_URI_SAFE_ATTR,oe),x.FORBID_CONTENTS&&(Re===$s&&(Re=Ne(Re)),z(Re,x.FORBID_CONTENTS,oe)),x.ADD_FORBID_CONTENTS&&(Re===$s&&(Re=Ne(Re)),z(Re,x.ADD_FORBID_CONTENTS,oe)),xs&&(te["#text"]=!0),J&&z(te,["html","head","body"]),te.table&&(z(te,["tbody"]),delete dt.tbody),x.TRUSTED_TYPES_POLICY){if(typeof x.TRUSTED_TYPES_POLICY.createHTML!="function")throw vn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof x.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw vn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');A=x.TRUSTED_TYPES_POLICY,E=A.createHTML("")}else A===void 0&&(A=Wm(v,s)),A!==null&&typeof E=="string"&&(E=A.createHTML(""));me&&me(x),Ut=x}},Qa=z({},[...js,...Gs,...Mm]),Ja=z({},[...Vs,...Pm]),ju=function(x){let _=k(x);(!_||!_.tagName)&&(_={namespaceURI:Ft,tagName:"template"});const B=Ci(x.tagName),Y=Ci(_.tagName);return Cs[x.namespaceURI]?x.namespaceURI===ii?_.namespaceURI===He?B==="svg":_.namespaceURI===ni?B==="svg"&&(Y==="annotation-xml"||si[Y]):!!Qa[B]:x.namespaceURI===ni?_.namespaceURI===He?B==="math":_.namespaceURI===ii?B==="math"&&oi[Y]:!!Ja[B]:x.namespaceURI===He?_.namespaceURI===ii&&!oi[Y]||_.namespaceURI===ni&&!si[Y]?!1:!Ja[B]&&(zu[B]||!Qa[B]):!!(pn==="application/xhtml+xml"&&Cs[x.namespaceURI]):!1},Le=function(x){mn(t.removed,{element:x});try{k(x).removeChild(x)}catch{M(x)}},ut=function(x,_){try{mn(t.removed,{attribute:_.getAttributeNode(x),from:_})}catch{mn(t.removed,{attribute:null,from:_})}if(_.removeAttribute(x),x==="is")if(Nt||ei)try{Le(_)}catch{}else try{_.setAttribute(x,"")}catch{}},Ya=function(x){let _=null,B=null;if(tt)x="<remove></remove>"+x;else{const se=qs(x,/^[\r\n\t ]+/);B=se&&se[0]}pn==="application/xhtml+xml"&&Ft===He&&(x='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+x+"</body></html>");const Y=A?A.createHTML(x):x;if(Ft===He)try{_=new p().parseFromString(Y,pn)}catch{}if(!_||!_.documentElement){_=T.createDocument(Ft,"template",null);try{_.documentElement.innerHTML=As?E:Y}catch{}}const de=_.body||_.documentElement;return x&&B&&de.insertBefore(n.createTextNode(B),de.childNodes[0]||null),Ft===He?W.call(_,J?"html":"body")[0]:J?_.documentElement:de},Xa=function(x){return P.call(x.ownerDocument||x,x,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Ts=function(x){return x instanceof u&&(typeof x.nodeName!="string"||typeof x.textContent!="string"||typeof x.removeChild!="function"||!(x.attributes instanceof h)||typeof x.removeAttribute!="function"||typeof x.setAttribute!="function"||typeof x.namespaceURI!="string"||typeof x.insertBefore!="function"||typeof x.hasChildNodes!="function")},Za=function(x){return typeof r=="function"&&x instanceof r};function qe(N,x,_){hi(N,B=>{B.call(t,x,_,Ut)})}const er=function(x){let _=null;if(qe(H.beforeSanitizeElements,x,null),Ts(x))return Le(x),!0;const B=oe(x.nodeName);if(qe(H.uponSanitizeElement,x,{tagName:B,allowedTags:te}),Z&&x.hasChildNodes()&&!Za(x.firstElementChild)&&fe(/<[/\w!]/g,x.innerHTML)&&fe(/<[/\w!]/g,x.textContent)||x.nodeType===wn.progressingInstruction||Z&&x.nodeType===wn.comment&&fe(/<[/\w]/g,x.data))return Le(x),!0;if(!(et.tagCheck instanceof Function&&et.tagCheck(B))&&(!te[B]||dt[B])){if(!dt[B]&&nr(B)&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B)))return!1;if(xs&&!Re[B]){const Y=k(x)||x.parentNode,de=b(x)||x.childNodes;if(de&&Y){const se=de.length;for(let ve=se-1;ve>=0;--ve){const je=S(de[ve],!0);je.__removalCount=(x.__removalCount||0)+1,Y.insertBefore(je,y(x))}}}return Le(x),!0}return x instanceof l&&!ju(x)||(B==="noscript"||B==="noembed"||B==="noframes")&&fe(/<\/no(script|embed|frames)/i,x.innerHTML)?(Le(x),!0):(U&&x.nodeType===wn.text&&(_=x.textContent,hi([ke,Ie,Ke],Y=>{_=yn(_,Y," ")}),x.textContent!==_&&(mn(t.removed,{element:x.cloneNode()}),x.textContent=_)),qe(H.afterSanitizeElements,x,null),!1)},tr=function(x,_,B){if(Ka&&(_==="id"||_==="name")&&(B in n||B in qu))return!1;if(!(C&&!dn[_]&&fe(vs,_))){if(!(Zn&&fe(bs,_))){if(!(et.attributeCheck instanceof Function&&et.attributeCheck(_,x))){if(!ne[_]||dn[_]){if(!(nr(x)&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,x)||X.tagNameCheck instanceof Function&&X.tagNameCheck(x))&&(X.attributeNameCheck instanceof RegExp&&fe(X.attributeNameCheck,_)||X.attributeNameCheck instanceof Function&&X.attributeNameCheck(_,x))||_==="is"&&X.allowCustomizedBuiltInElements&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B))))return!1}else if(!Ss[_]){if(!fe(Jn,yn(B,Qn,""))){if(!((_==="src"||_==="xlink:href"||_==="href")&&x!=="script"&&Cm(B,"data:")===0&&qa[x])){if(!(R&&!fe(ws,yn(B,Qn,"")))){if(B)return!1}}}}}}}return!0},nr=function(x){return x!=="annotation-xml"&&qs(x,ks)},ir=function(x){qe(H.beforeSanitizeAttributes,x,null);const{attributes:_}=x;if(!_||Ts(x))return;const B={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let Y=_.length;for(;Y--;){const de=_[Y],{name:se,namespaceURI:ve,value:je}=de,Wt=oe(se),_s=je;let le=se==="value"?_s:Em(_s);if(B.attrName=Wt,B.attrValue=le,B.keepAttr=!0,B.forceKeepAttr=void 0,qe(H.uponSanitizeAttribute,x,B),le=B.attrValue,Ha&&(Wt==="id"||Wt==="name")&&(ut(se,x),le=Uu+le),Z&&fe(/((--!?|])>)|<\/(style|title|textarea)/i,le)){ut(se,x);continue}if(Wt==="attributename"&&qs(le,"href")){ut(se,x);continue}if(B.forceKeepAttr)continue;if(!B.keepAttr){ut(se,x);continue}if(!F&&fe(/\/>/i,le)){ut(se,x);continue}U&&hi([ke,Ie,Ke],or=>{le=yn(le,or," ")});const sr=oe(x.nodeName);if(!tr(sr,Wt,le)){ut(se,x);continue}if(A&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!ve)switch(v.getAttributeType(sr,Wt)){case"TrustedHTML":{le=A.createHTML(le);break}case"TrustedScriptURL":{le=A.createScriptURL(le);break}}if(le!==_s)try{ve?x.setAttributeNS(ve,se,le):x.setAttribute(se,le),Ts(x)?Le(x):Wr(t.removed)}catch{ut(se,x)}}qe(H.afterSanitizeAttributes,x,null)},Gu=function N(x){let _=null;const B=Xa(x);for(qe(H.beforeSanitizeShadowDOM,x,null);_=B.nextNode();)qe(H.uponSanitizeShadowNode,_,null),er(_),ir(_),_.content instanceof o&&N(_.content);qe(H.afterSanitizeShadowDOM,x,null)};return t.sanitize=function(N){let x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_=null,B=null,Y=null,de=null;if(As=!N,As&&(N="<!-->"),typeof N!="string"&&!Za(N))if(typeof N.toString=="function"){if(N=N.toString(),typeof N!="string")throw vn("dirty is not a string, aborting")}else throw vn("toString is not a function");if(!t.isSupported)return N;if(he||Es(x),t.removed=[],typeof N=="string"&&(un=!1),un){if(N.nodeName){const je=oe(N.nodeName);if(!te[je]||dt[je])throw vn("root node is forbidden and cannot be sanitized in-place")}}else if(N instanceof r)_=Ya("<!---->"),B=_.ownerDocument.importNode(N,!0),B.nodeType===wn.element&&B.nodeName==="BODY"||B.nodeName==="HTML"?_=B:_.appendChild(B);else{if(!Nt&&!U&&!J&&N.indexOf("<")===-1)return A&&ti?A.createHTML(N):N;if(_=Ya(N),!_)return Nt?null:ti?E:""}_&&tt&&Le(_.firstChild);const se=Xa(un?N:_);for(;Y=se.nextNode();)er(Y),ir(Y),Y.content instanceof o&&Gu(Y.content);if(un)return N;if(Nt){if(ei)for(de=D.call(_.ownerDocument);_.firstChild;)de.appendChild(_.firstChild);else de=_;return(ne.shadowroot||ne.shadowrootmode)&&(de=K.call(i,de,!0)),de}let ve=J?_.outerHTML:_.innerHTML;return J&&te["!doctype"]&&_.ownerDocument&&_.ownerDocument.doctype&&_.ownerDocument.doctype.name&&fe(Td,_.ownerDocument.doctype.name)&&(ve="<!DOCTYPE "+_.ownerDocument.doctype.name+`>
|
|
2757
|
+
`}const $d={CHILD:2},Sd=e=>(...t)=>({_$litDirective$:e,values:t});let Ad=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,i){this._$Ct=t,this._$AM=n,this._$Ci=i}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}};const{I:mm}=yp,Nr=e=>e,Or=()=>document.createComment(""),gn=(e,t,n)=>{var o;const i=e._$AA.parentNode,s=t===void 0?e._$AB:t._$AA;if(n===void 0){const a=i.insertBefore(Or(),s),r=i.insertBefore(Or(),s);n=new mm(a,r,e,e.options)}else{const a=n._$AB.nextSibling,r=n._$AM,l=r!==e;if(l){let d;(o=n._$AQ)==null||o.call(n,e),n._$AM=e,n._$AP!==void 0&&(d=e._$AU)!==r._$AU&&n._$AP(d)}if(a!==s||l){let d=n._$AA;for(;d!==a;){const h=Nr(d).nextSibling;Nr(i).insertBefore(d,s),d=h}}}return n},ft=(e,t,n=e)=>(e._$AI(t,n),e),ym={},vm=(e,t=ym)=>e._$AH=t,bm=e=>e._$AH,Ks=e=>{e._$AR(),e._$AA.remove()};const Fr=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},wm=Sd(class extends Ad{constructor(e){if(super(e),e.type!==$d.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let i;n===void 0?n=t:t!==void 0&&(i=t);const s=[],o=[];let a=0;for(const r of e)s[a]=i?i(r,a):a,o[a]=n(r,a),a++;return{values:o,keys:s}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const s=bm(e),{values:o,keys:a}=this.dt(t,n,i);if(!Array.isArray(s))return this.ut=a,o;const r=this.ut??(this.ut=[]),l=[];let d,h,u=0,p=s.length-1,v=0,$=o.length-1;for(;u<=p&&v<=$;)if(s[u]===null)u++;else if(s[p]===null)p--;else if(r[u]===a[v])l[v]=ft(s[u],o[v]),u++,v++;else if(r[p]===a[$])l[$]=ft(s[p],o[$]),p--,$--;else if(r[u]===a[$])l[$]=ft(s[u],o[$]),gn(e,l[$+1],s[u]),u++,$--;else if(r[p]===a[v])l[v]=ft(s[p],o[v]),gn(e,s[u],s[p]),p--,v++;else if(d===void 0&&(d=Fr(a,v,$),h=Fr(r,u,p)),d.has(r[u]))if(d.has(r[p])){const S=h.get(a[v]),M=S!==void 0?s[S]:null;if(M===null){const y=gn(e,s[u]);ft(y,o[v]),l[v]=y}else l[v]=ft(M,o[v]),gn(e,s[u],M),s[S]=null;v++}else Ks(s[p]),p--;else Ks(s[u]),u++;for(;v<=$;){const S=gn(e,l[$+1]);ft(S,o[v]),l[v++]=S}for(;u<=p;){const S=s[u++];S!==null&&Ks(S)}return this.ut=a,vm(e,l),rt}});class _o extends Ad{constructor(t){if(super(t),this.it=w,t.type!==$d.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===w||t==null)return this._t=void 0,this.it=t;if(t===rt)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:[]}}}_o.directiveName="unsafeHTML",_o.resultType=1;const Hi=Sd(_o);const{entries:Cd,setPrototypeOf:Ur,isFrozen:km,getPrototypeOf:xm,getOwnPropertyDescriptor:$m}=Object;let{freeze:me,seal:Se,create:Mo}=Object,{apply:Po,construct:Io}=typeof Reflect<"u"&&Reflect;me||(me=function(t){return t});Se||(Se=function(t){return t});Po||(Po=function(t,n){for(var i=arguments.length,s=new Array(i>2?i-2:0),o=2;o<i;o++)s[o-2]=arguments[o];return t.apply(n,s)});Io||(Io=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return new t(...i)});const hi=ye(Array.prototype.forEach),Sm=ye(Array.prototype.lastIndexOf),Wr=ye(Array.prototype.pop),mn=ye(Array.prototype.push),Am=ye(Array.prototype.splice),Ci=ye(String.prototype.toLowerCase),Hs=ye(String.prototype.toString),qs=ye(String.prototype.match),yn=ye(String.prototype.replace),Cm=ye(String.prototype.indexOf),Em=ye(String.prototype.trim),Ae=ye(Object.prototype.hasOwnProperty),fe=ye(RegExp.prototype.test),vn=Tm(TypeError);function ye(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return Po(e,t,i)}}function Tm(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Io(e,n)}}function z(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ci;Ur&&Ur(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(km(t)||(t[i]=o),s=o)}e[s]=!0}return e}function _m(e){for(let t=0;t<e.length;t++)Ae(e,t)||(e[t]=null);return e}function Ne(e){const t=Mo(null);for(const[n,i]of Cd(e))Ae(e,n)&&(Array.isArray(i)?t[n]=_m(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=Ne(i):t[n]=i);return t}function bn(e,t){for(;e!==null;){const i=$m(e,t);if(i){if(i.get)return ye(i.get);if(typeof i.value=="function")return ye(i.value)}e=xm(e)}function n(){return null}return n}const zr=me(["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"]),js=me(["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"]),Gs=me(["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"]),Mm=me(["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"]),Vs=me(["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"]),Pm=me(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Kr=me(["#text"]),Hr=me(["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"]),Qs=me(["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"]),qr=me(["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"]),fi=me(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Im=Se(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Rm=Se(/<%[\w\W]*|[\w\W]*%>/gm),Lm=Se(/\$\{[\w\W]*/gm),Dm=Se(/^data-[\-\w.\u00B7-\uFFFF]+$/),Bm=Se(/^aria-[\-\w]+$/),Ed=Se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Nm=Se(/^(?:\w+script|data):/i),Om=Se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Td=Se(/^html$/i),Fm=Se(/^[a-z][.\w]*(-[.\w]+)+$/i);var jr=Object.freeze({__proto__:null,ARIA_ATTR:Bm,ATTR_WHITESPACE:Om,CUSTOM_ELEMENT:Fm,DATA_ATTR:Dm,DOCTYPE_NAME:Td,ERB_EXPR:Rm,IS_ALLOWED_URI:Ed,IS_SCRIPT_OR_DATA:Nm,MUSTACHE_EXPR:Im,TMPLIT_EXPR:Lm});const wn={element:1,text:3,progressingInstruction:7,comment:8,document:9},Um=function(){return typeof window>"u"?null:window},Wm=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(i=n.getAttribute(s));const o="dompurify"+(i?"#"+i:"");try{return t.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Gr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function _d(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Um();const t=N=>_d(N);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==wn.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:r,Element:l,NodeFilter:d,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:u,DOMParser:p,trustedTypes:v}=e,$=l.prototype,S=bn($,"cloneNode"),M=bn($,"remove"),y=bn($,"nextSibling"),b=bn($,"childNodes"),k=bn($,"parentNode");if(typeof a=="function"){const N=n.createElement("template");N.content&&N.content.ownerDocument&&(n=N.content.ownerDocument)}let A,E="";const{implementation:T,createNodeIterator:P,createDocumentFragment:D,getElementsByTagName:W}=n,{importNode:K}=i;let H=Gr();t.isSupported=typeof Cd=="function"&&typeof k=="function"&&T&&T.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ke,ERB_EXPR:Ie,TMPLIT_EXPR:Ke,DATA_ATTR:vs,ARIA_ATTR:bs,IS_SCRIPT_OR_DATA:ws,ATTR_WHITESPACE:Qn,CUSTOM_ELEMENT:ks}=jr;let{IS_ALLOWED_URI:Jn}=jr,te=null;const Yn=z({},[...zr,...js,...Gs,...Vs,...Kr]);let ne=null;const Xn=z({},[...Hr,...Qs,...qr,...fi]);let X=Object.seal(Mo(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}})),dt=null,dn=null;const et=Object.seal(Mo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Zn=!0,C=!0,R=!1,F=!0,U=!1,ee=!0,J=!1,he=!1,tt=!1,Nt=!1,ei=!1,ti=!1,Ka=!0,Ha=!1;const Uu="user-content-";let xs=!0,un=!1,Ot={},Re=null;const $s=z({},["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 qa=null;const ja=z({},["audio","video","img","source","image","track"]);let Ss=null;const Ga=z({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ni="http://www.w3.org/1998/Math/MathML",ii="http://www.w3.org/2000/svg",He="http://www.w3.org/1999/xhtml";let Ft=He,As=!1,Cs=null;const Wu=z({},[ni,ii,He],Hs);let si=z({},["mi","mo","mn","ms","mtext"]),oi=z({},["annotation-xml"]);const zu=z({},["title","style","font","a","script"]);let pn=null;const Ku=["application/xhtml+xml","text/html"],Hu="text/html";let oe=null,Ut=null;const qu=n.createElement("form"),Va=function(x){return x instanceof RegExp||x instanceof Function},Es=function(){let x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ut&&Ut===x)){if((!x||typeof x!="object")&&(x={}),x=Ne(x),pn=Ku.indexOf(x.PARSER_MEDIA_TYPE)===-1?Hu:x.PARSER_MEDIA_TYPE,oe=pn==="application/xhtml+xml"?Hs:Ci,te=Ae(x,"ALLOWED_TAGS")?z({},x.ALLOWED_TAGS,oe):Yn,ne=Ae(x,"ALLOWED_ATTR")?z({},x.ALLOWED_ATTR,oe):Xn,Cs=Ae(x,"ALLOWED_NAMESPACES")?z({},x.ALLOWED_NAMESPACES,Hs):Wu,Ss=Ae(x,"ADD_URI_SAFE_ATTR")?z(Ne(Ga),x.ADD_URI_SAFE_ATTR,oe):Ga,qa=Ae(x,"ADD_DATA_URI_TAGS")?z(Ne(ja),x.ADD_DATA_URI_TAGS,oe):ja,Re=Ae(x,"FORBID_CONTENTS")?z({},x.FORBID_CONTENTS,oe):$s,dt=Ae(x,"FORBID_TAGS")?z({},x.FORBID_TAGS,oe):Ne({}),dn=Ae(x,"FORBID_ATTR")?z({},x.FORBID_ATTR,oe):Ne({}),Ot=Ae(x,"USE_PROFILES")?x.USE_PROFILES:!1,Zn=x.ALLOW_ARIA_ATTR!==!1,C=x.ALLOW_DATA_ATTR!==!1,R=x.ALLOW_UNKNOWN_PROTOCOLS||!1,F=x.ALLOW_SELF_CLOSE_IN_ATTR!==!1,U=x.SAFE_FOR_TEMPLATES||!1,ee=x.SAFE_FOR_XML!==!1,J=x.WHOLE_DOCUMENT||!1,Nt=x.RETURN_DOM||!1,ei=x.RETURN_DOM_FRAGMENT||!1,ti=x.RETURN_TRUSTED_TYPE||!1,tt=x.FORCE_BODY||!1,Ka=x.SANITIZE_DOM!==!1,Ha=x.SANITIZE_NAMED_PROPS||!1,xs=x.KEEP_CONTENT!==!1,un=x.IN_PLACE||!1,Jn=x.ALLOWED_URI_REGEXP||Ed,Ft=x.NAMESPACE||He,si=x.MATHML_TEXT_INTEGRATION_POINTS||si,oi=x.HTML_INTEGRATION_POINTS||oi,X=x.CUSTOM_ELEMENT_HANDLING||{},x.CUSTOM_ELEMENT_HANDLING&&Va(x.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(X.tagNameCheck=x.CUSTOM_ELEMENT_HANDLING.tagNameCheck),x.CUSTOM_ELEMENT_HANDLING&&Va(x.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(X.attributeNameCheck=x.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),x.CUSTOM_ELEMENT_HANDLING&&typeof x.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(X.allowCustomizedBuiltInElements=x.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),U&&(C=!1),ei&&(Nt=!0),Ot&&(te=z({},Kr),ne=[],Ot.html===!0&&(z(te,zr),z(ne,Hr)),Ot.svg===!0&&(z(te,js),z(ne,Qs),z(ne,fi)),Ot.svgFilters===!0&&(z(te,Gs),z(ne,Qs),z(ne,fi)),Ot.mathMl===!0&&(z(te,Vs),z(ne,qr),z(ne,fi))),x.ADD_TAGS&&(typeof x.ADD_TAGS=="function"?et.tagCheck=x.ADD_TAGS:(te===Yn&&(te=Ne(te)),z(te,x.ADD_TAGS,oe))),x.ADD_ATTR&&(typeof x.ADD_ATTR=="function"?et.attributeCheck=x.ADD_ATTR:(ne===Xn&&(ne=Ne(ne)),z(ne,x.ADD_ATTR,oe))),x.ADD_URI_SAFE_ATTR&&z(Ss,x.ADD_URI_SAFE_ATTR,oe),x.FORBID_CONTENTS&&(Re===$s&&(Re=Ne(Re)),z(Re,x.FORBID_CONTENTS,oe)),x.ADD_FORBID_CONTENTS&&(Re===$s&&(Re=Ne(Re)),z(Re,x.ADD_FORBID_CONTENTS,oe)),xs&&(te["#text"]=!0),J&&z(te,["html","head","body"]),te.table&&(z(te,["tbody"]),delete dt.tbody),x.TRUSTED_TYPES_POLICY){if(typeof x.TRUSTED_TYPES_POLICY.createHTML!="function")throw vn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof x.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw vn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');A=x.TRUSTED_TYPES_POLICY,E=A.createHTML("")}else A===void 0&&(A=Wm(v,s)),A!==null&&typeof E=="string"&&(E=A.createHTML(""));me&&me(x),Ut=x}},Qa=z({},[...js,...Gs,...Mm]),Ja=z({},[...Vs,...Pm]),ju=function(x){let _=k(x);(!_||!_.tagName)&&(_={namespaceURI:Ft,tagName:"template"});const B=Ci(x.tagName),Y=Ci(_.tagName);return Cs[x.namespaceURI]?x.namespaceURI===ii?_.namespaceURI===He?B==="svg":_.namespaceURI===ni?B==="svg"&&(Y==="annotation-xml"||si[Y]):!!Qa[B]:x.namespaceURI===ni?_.namespaceURI===He?B==="math":_.namespaceURI===ii?B==="math"&&oi[Y]:!!Ja[B]:x.namespaceURI===He?_.namespaceURI===ii&&!oi[Y]||_.namespaceURI===ni&&!si[Y]?!1:!Ja[B]&&(zu[B]||!Qa[B]):!!(pn==="application/xhtml+xml"&&Cs[x.namespaceURI]):!1},Le=function(x){mn(t.removed,{element:x});try{k(x).removeChild(x)}catch{M(x)}},ut=function(x,_){try{mn(t.removed,{attribute:_.getAttributeNode(x),from:_})}catch{mn(t.removed,{attribute:null,from:_})}if(_.removeAttribute(x),x==="is")if(Nt||ei)try{Le(_)}catch{}else try{_.setAttribute(x,"")}catch{}},Ya=function(x){let _=null,B=null;if(tt)x="<remove></remove>"+x;else{const se=qs(x,/^[\r\n\t ]+/);B=se&&se[0]}pn==="application/xhtml+xml"&&Ft===He&&(x='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+x+"</body></html>");const Y=A?A.createHTML(x):x;if(Ft===He)try{_=new p().parseFromString(Y,pn)}catch{}if(!_||!_.documentElement){_=T.createDocument(Ft,"template",null);try{_.documentElement.innerHTML=As?E:Y}catch{}}const de=_.body||_.documentElement;return x&&B&&de.insertBefore(n.createTextNode(B),de.childNodes[0]||null),Ft===He?W.call(_,J?"html":"body")[0]:J?_.documentElement:de},Xa=function(x){return P.call(x.ownerDocument||x,x,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Ts=function(x){return x instanceof u&&(typeof x.nodeName!="string"||typeof x.textContent!="string"||typeof x.removeChild!="function"||!(x.attributes instanceof h)||typeof x.removeAttribute!="function"||typeof x.setAttribute!="function"||typeof x.namespaceURI!="string"||typeof x.insertBefore!="function"||typeof x.hasChildNodes!="function")},Za=function(x){return typeof r=="function"&&x instanceof r};function qe(N,x,_){hi(N,B=>{B.call(t,x,_,Ut)})}const er=function(x){let _=null;if(qe(H.beforeSanitizeElements,x,null),Ts(x))return Le(x),!0;const B=oe(x.nodeName);if(qe(H.uponSanitizeElement,x,{tagName:B,allowedTags:te}),ee&&x.hasChildNodes()&&!Za(x.firstElementChild)&&fe(/<[/\w!]/g,x.innerHTML)&&fe(/<[/\w!]/g,x.textContent)||x.nodeType===wn.progressingInstruction||ee&&x.nodeType===wn.comment&&fe(/<[/\w]/g,x.data))return Le(x),!0;if(!(et.tagCheck instanceof Function&&et.tagCheck(B))&&(!te[B]||dt[B])){if(!dt[B]&&nr(B)&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B)))return!1;if(xs&&!Re[B]){const Y=k(x)||x.parentNode,de=b(x)||x.childNodes;if(de&&Y){const se=de.length;for(let ve=se-1;ve>=0;--ve){const je=S(de[ve],!0);je.__removalCount=(x.__removalCount||0)+1,Y.insertBefore(je,y(x))}}}return Le(x),!0}return x instanceof l&&!ju(x)||(B==="noscript"||B==="noembed"||B==="noframes")&&fe(/<\/no(script|embed|frames)/i,x.innerHTML)?(Le(x),!0):(U&&x.nodeType===wn.text&&(_=x.textContent,hi([ke,Ie,Ke],Y=>{_=yn(_,Y," ")}),x.textContent!==_&&(mn(t.removed,{element:x.cloneNode()}),x.textContent=_)),qe(H.afterSanitizeElements,x,null),!1)},tr=function(x,_,B){if(Ka&&(_==="id"||_==="name")&&(B in n||B in qu))return!1;if(!(C&&!dn[_]&&fe(vs,_))){if(!(Zn&&fe(bs,_))){if(!(et.attributeCheck instanceof Function&&et.attributeCheck(_,x))){if(!ne[_]||dn[_]){if(!(nr(x)&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,x)||X.tagNameCheck instanceof Function&&X.tagNameCheck(x))&&(X.attributeNameCheck instanceof RegExp&&fe(X.attributeNameCheck,_)||X.attributeNameCheck instanceof Function&&X.attributeNameCheck(_,x))||_==="is"&&X.allowCustomizedBuiltInElements&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B))))return!1}else if(!Ss[_]){if(!fe(Jn,yn(B,Qn,""))){if(!((_==="src"||_==="xlink:href"||_==="href")&&x!=="script"&&Cm(B,"data:")===0&&qa[x])){if(!(R&&!fe(ws,yn(B,Qn,"")))){if(B)return!1}}}}}}}return!0},nr=function(x){return x!=="annotation-xml"&&qs(x,ks)},ir=function(x){qe(H.beforeSanitizeAttributes,x,null);const{attributes:_}=x;if(!_||Ts(x))return;const B={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let Y=_.length;for(;Y--;){const de=_[Y],{name:se,namespaceURI:ve,value:je}=de,Wt=oe(se),_s=je;let le=se==="value"?_s:Em(_s);if(B.attrName=Wt,B.attrValue=le,B.keepAttr=!0,B.forceKeepAttr=void 0,qe(H.uponSanitizeAttribute,x,B),le=B.attrValue,Ha&&(Wt==="id"||Wt==="name")&&(ut(se,x),le=Uu+le),ee&&fe(/((--!?|])>)|<\/(style|title|textarea)/i,le)){ut(se,x);continue}if(Wt==="attributename"&&qs(le,"href")){ut(se,x);continue}if(B.forceKeepAttr)continue;if(!B.keepAttr){ut(se,x);continue}if(!F&&fe(/\/>/i,le)){ut(se,x);continue}U&&hi([ke,Ie,Ke],or=>{le=yn(le,or," ")});const sr=oe(x.nodeName);if(!tr(sr,Wt,le)){ut(se,x);continue}if(A&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!ve)switch(v.getAttributeType(sr,Wt)){case"TrustedHTML":{le=A.createHTML(le);break}case"TrustedScriptURL":{le=A.createScriptURL(le);break}}if(le!==_s)try{ve?x.setAttributeNS(ve,se,le):x.setAttribute(se,le),Ts(x)?Le(x):Wr(t.removed)}catch{ut(se,x)}}qe(H.afterSanitizeAttributes,x,null)},Gu=function N(x){let _=null;const B=Xa(x);for(qe(H.beforeSanitizeShadowDOM,x,null);_=B.nextNode();)qe(H.uponSanitizeShadowNode,_,null),er(_),ir(_),_.content instanceof o&&N(_.content);qe(H.afterSanitizeShadowDOM,x,null)};return t.sanitize=function(N){let x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_=null,B=null,Y=null,de=null;if(As=!N,As&&(N="<!-->"),typeof N!="string"&&!Za(N))if(typeof N.toString=="function"){if(N=N.toString(),typeof N!="string")throw vn("dirty is not a string, aborting")}else throw vn("toString is not a function");if(!t.isSupported)return N;if(he||Es(x),t.removed=[],typeof N=="string"&&(un=!1),un){if(N.nodeName){const je=oe(N.nodeName);if(!te[je]||dt[je])throw vn("root node is forbidden and cannot be sanitized in-place")}}else if(N instanceof r)_=Ya("<!---->"),B=_.ownerDocument.importNode(N,!0),B.nodeType===wn.element&&B.nodeName==="BODY"||B.nodeName==="HTML"?_=B:_.appendChild(B);else{if(!Nt&&!U&&!J&&N.indexOf("<")===-1)return A&&ti?A.createHTML(N):N;if(_=Ya(N),!_)return Nt?null:ti?E:""}_&&tt&&Le(_.firstChild);const se=Xa(un?N:_);for(;Y=se.nextNode();)er(Y),ir(Y),Y.content instanceof o&&Gu(Y.content);if(un)return N;if(Nt){if(ei)for(de=D.call(_.ownerDocument);_.firstChild;)de.appendChild(_.firstChild);else de=_;return(ne.shadowroot||ne.shadowrootmode)&&(de=K.call(i,de,!0)),de}let ve=J?_.outerHTML:_.innerHTML;return J&&te["!doctype"]&&_.ownerDocument&&_.ownerDocument.doctype&&_.ownerDocument.doctype.name&&fe(Td,_.ownerDocument.doctype.name)&&(ve="<!DOCTYPE "+_.ownerDocument.doctype.name+`>
|
|
2768
2758
|
`+ve),U&&hi([ke,Ie,Ke],je=>{ve=yn(ve,je," ")}),A&&ti?A.createHTML(ve):ve},t.setConfig=function(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Es(N),he=!0},t.clearConfig=function(){Ut=null,he=!1},t.isValidAttribute=function(N,x,_){Ut||Es({});const B=oe(N),Y=oe(x);return tr(B,Y,_)},t.addHook=function(N,x){typeof x=="function"&&mn(H[N],x)},t.removeHook=function(N,x){if(x!==void 0){const _=Sm(H[N],x);return _===-1?void 0:Am(H[N],_,1)[0]}return Wr(H[N])},t.removeHooks=function(N){H[N]=[]},t.removeAllHooks=function(){H=Gr()},t}var Ro=_d();function $a(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Dt=$a();function Md(e){Dt=e}var In={exec:()=>null};function j(e,t=""){let n=typeof e=="string"?e:e.source,i={replace:(s,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(ge.caret,"$1"),n=n.replace(s,a),i},getRegex:()=>new RegExp(n,t)};return i}var zm=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ge={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")},Km=/^(?:[ \t]*(?:\n|$))+/,Hm=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,qm=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Gn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,jm=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Sa=/(?:[*+-]|\d{1,9}[.)])/,Pd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Id=j(Pd).replace(/bull/g,Sa).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(),Gm=j(Pd).replace(/bull/g,Sa).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(),Aa=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Vm=/^[^\n]+/,Ca=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Qm=j(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ca).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Jm=j(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Sa).getRegex(),ps="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",Ea=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ym=j("^ {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",Ea).replace("tag",ps).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Rd=j(Aa).replace("hr",Gn).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",ps).getRegex(),Xm=j(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Rd).getRegex(),Ta={blockquote:Xm,code:Hm,def:Qm,fences:qm,heading:jm,hr:Gn,html:Ym,lheading:Id,list:Jm,newline:Km,paragraph:Rd,table:In,text:Vm},Vr=j("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Gn).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",ps).getRegex(),Zm={...Ta,lheading:Gm,table:Vr,paragraph:j(Aa).replace("hr",Gn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Vr).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",ps).getRegex()},ey={...Ta,html:j(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ea).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:In,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:j(Aa).replace("hr",Gn).replace("heading",` *#{1,6} *[^
|
|
2769
2759
|
]`).replace("lheading",Id).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ty=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ny=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ld=/^( {2,}|\\)\n(?!\s*$)/,iy=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,hs=/[\p{P}\p{S}]/u,_a=/[\s\p{P}\p{S}]/u,Dd=/[^\s\p{P}\p{S}]/u,sy=j(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,_a).getRegex(),Bd=/(?!~)[\p{P}\p{S}]/u,oy=/(?!~)[\s\p{P}\p{S}]/u,ay=/(?:[^\s\p{P}\p{S}]|~)/u,ry=j(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",zm?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Nd=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ly=j(Nd,"u").replace(/punct/g,hs).getRegex(),cy=j(Nd,"u").replace(/punct/g,Bd).getRegex(),Od="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",dy=j(Od,"gu").replace(/notPunctSpace/g,Dd).replace(/punctSpace/g,_a).replace(/punct/g,hs).getRegex(),uy=j(Od,"gu").replace(/notPunctSpace/g,ay).replace(/punctSpace/g,oy).replace(/punct/g,Bd).getRegex(),py=j("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Dd).replace(/punctSpace/g,_a).replace(/punct/g,hs).getRegex(),hy=j(/\\(punct)/,"gu").replace(/punct/g,hs).getRegex(),fy=j(/^<(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(),gy=j(Ea).replace("(?:-->|$)","-->").getRegex(),my=j("^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",gy).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),qi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,yy=j(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",qi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Fd=j(/^!?\[(label)\]\[(ref)\]/).replace("label",qi).replace("ref",Ca).getRegex(),Ud=j(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ca).getRegex(),vy=j("reflink|nolink(?!\\()","g").replace("reflink",Fd).replace("nolink",Ud).getRegex(),Qr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ma={_backpedal:In,anyPunctuation:hy,autolink:fy,blockSkip:ry,br:Ld,code:ny,del:In,emStrongLDelim:ly,emStrongRDelimAst:dy,emStrongRDelimUnd:py,escape:ty,link:yy,nolink:Ud,punctuation:sy,reflink:Fd,reflinkSearch:vy,tag:my,text:iy,url:In},by={...Ma,link:j(/^!?\[(label)\]\((.*?)\)/).replace("label",qi).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",qi).getRegex()},Lo={...Ma,emStrongRDelimAst:uy,emStrongLDelim:cy,url:j(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Qr).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:j(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Qr).getRegex()},wy={...Lo,br:j(Ld).replace("{2,}","*").getRegex(),text:j(Lo.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},gi={normal:Ta,gfm:Zm,pedantic:ey},kn={normal:Ma,gfm:Lo,breaks:wy,pedantic:by},ky={"&":"&","<":"<",">":">",'"':""","'":"'"},Jr=e=>ky[e];function Qe(e,t){if(t){if(ge.escapeTest.test(e))return e.replace(ge.escapeReplace,Jr)}else if(ge.escapeTestNoEncode.test(e))return e.replace(ge.escapeReplaceNoEncode,Jr);return e}function Yr(e){try{e=encodeURI(e).replace(ge.percentDecode,"%")}catch{return null}return e}function Xr(e,t){var o;let n=e.replace(ge.findPipe,(a,r,l)=>{let d=!1,h=r;for(;--h>=0&&l[h]==="\\";)d=!d;return d?"|":" |"}),i=n.split(ge.splitPipe),s=0;if(i[0].trim()||i.shift(),i.length>0&&!((o=i.at(-1))!=null&&o.trim())&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;s<i.length;s++)i[s]=i[s].trim().replace(ge.slashPipe,"|");return i}function xn(e,t,n){let i=e.length;if(i===0)return"";let s=0;for(;s<i&&e.charAt(i-s-1)===t;)s++;return e.slice(0,i-s)}function xy(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}function Zr(e,t,n,i,s){let o=t.href,a=t.title||null,r=e[1].replace(s.other.outputLinkReplace,"$1");i.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:a,text:r,tokens:i.inlineTokens(r)};return i.state.inLink=!1,l}function $y(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let s=i[1];return t.split(`
|
|
2770
2760
|
`).map(o=>{let a=o.match(n.other.beginningSpace);if(a===null)return o;let[r]=a;return r.length>=s.length?o.slice(s.length):o}).join(`
|
|
@@ -3024,10 +3014,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
3024
3014
|
`;fs([ss({type:Number})],Yt.prototype,"splitRatio",2);fs([ss({type:Number})],Yt.prototype,"minRatio",2);fs([ss({type:Number})],Yt.prototype,"maxRatio",2);Yt=fs([ql("resizable-divider")],Yt);function yi(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function to(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const yv=1,vv=1,Bt="emoji",Xt="keyvalue",Ia="favorites",bv="tokens",Vd="tokens",wv="unicode",Qd="count",kv="group",xv="order",Jd="group-order",No="eTag",Xi="url",rl="skinTone",ln="readonly",Ra="readwrite",Yd="skinUnicodes",$v="skinUnicodes",Sv="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Av="en";function Cv(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function ll(e){return Cv(e,t=>t.unicode)}function Ev(e){function t(n,i,s){const o=i?e.createObjectStore(n,{keyPath:i}):e.createObjectStore(n);if(s)for(const[a,[r,l]]of Object.entries(s))o.createIndex(a,r,{multiEntry:l});return o}t(Xt),t(Bt,wv,{[Vd]:[bv,!0],[Jd]:[[kv,xv]],[Yd]:[$v,!0]}),t(Ia,void 0,{[Qd]:[""]})}const Oo={},Ei={},Zi={};function Xd(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function Tv(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,yv);Oo[e]=s,s.onupgradeneeded=o=>{o.oldVersion<vv&&Ev(s.result)},Xd(n,i,s)});return t.onclose=()=>La(e),t}function _v(e){return Ei[e]||(Ei[e]=Tv(e)),Ei[e]}function Ze(e,t,n,i){return new Promise((s,o)=>{const a=e.transaction(t,n,{durability:"relaxed"}),r=typeof t=="string"?a.objectStore(t):t.map(d=>a.objectStore(d));let l;i(r,a,d=>{l=d}),a.oncomplete=()=>s(l),a.onerror=()=>o(a.error)})}function La(e){const t=Oo[e],n=t&&t.result;if(n){n.close();const i=Zi[e];if(i)for(const s of i)s()}delete Oo[e],delete Ei[e],delete Zi[e]}function Mv(e){return new Promise((t,n)=>{La(e);const i=indexedDB.deleteDatabase(e);Xd(t,n,i)})}function Pv(e,t){let n=Zi[e];n||(n=Zi[e]=[]),n.push(t)}const Iv=new Set([":D","XD",":'D","O:)",":X",":P",";P","XP",":L",":Z",":j","8D","XO","8)",":B",":O",":S",":'o","Dx","X(","D:",":C",">0)",":3","</3","<3","\\M/",":E","8#"]);function Vt(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||Iv.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const Rv=2;function Zd(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=Rv)}function Lv(e){return e.map(({annotation:n,emoticon:i,group:s,order:o,shortcodes:a,skins:r,tags:l,emoji:d,version:h})=>{const u=[...new Set(Zd([...(a||[]).map(Vt).flat(),...(l||[]).map(Vt).flat(),...Vt(n),i]))].sort(),p={annotation:n,group:s,order:o,tags:l,tokens:u,unicode:d,version:h};if(i&&(p.emoticon=i),a&&(p.shortcodes=a),r){p.skinTones=[],p.skinUnicodes=[],p.skinVersions=[];for(const{tone:v,emoji:$,version:S}of r)p.skinTones.push(v),p.skinUnicodes.push($),p.skinVersions.push(S)}return p})}function eu(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function Pt(e,t,n){eu(e,"get",t,n)}function tu(e,t,n){eu(e,"getAll",t,n)}function Da(e){e.commit&&e.commit()}function Dv(e,t){let n=e[0];for(let i=1;i<e.length;i++){const s=e[i];t(n)>t(s)&&(n=s)}return n}function nu(e,t){const n=Dv(e,s=>s.length),i=[];for(const s of n)e.some(o=>o.findIndex(a=>t(a)===t(s))===-1)||i.push(s);return i}async function Bv(e){return!await Ba(e,Xt,Xi)}async function Nv(e,t,n){const[i,s]=await Promise.all([No,Xi].map(o=>Ba(e,Xt,o)));return i===n&&s===t}async function Ov(e,t){return Ze(e,Bt,ln,(i,s,o)=>{let a;const r=()=>{i.getAll(a&&IDBKeyRange.lowerBound(a,!0),50).onsuccess=l=>{const d=l.target.result;for(const h of d)if(a=h.unicode,t(h))return o(h);if(d.length<50)return o();r()}};r()})}async function iu(e,t,n,i){{const s=Lv(t);await Ze(e,[Bt,Xt],Ra,([o,a],r)=>{let l,d,h=0;function u(){++h===2&&p()}function p(){if(!(l===i&&d===n)){o.clear();for(const v of s)o.put(v);a.put(i,No),a.put(n,Xi),Da(r)}}Pt(a,No,v=>{l=v,u()}),Pt(a,Xi,v=>{d=v,u()})})}}async function Fv(e,t){return Ze(e,Bt,ln,(n,i,s)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);tu(n.index(Jd),o,s)})}async function su(e,t){const n=Zd(Vt(t));return n.length?Ze(e,Bt,ln,(i,s,o)=>{const a=[],r=()=>{a.length===n.length&&l()},l=()=>{const d=nu(a,h=>h.unicode);o(d.sort((h,u)=>h.order<u.order?-1:1))};for(let d=0;d<n.length;d++){const h=n[d],u=d===n.length-1?IDBKeyRange.bound(h,h+"",!1,!0):IDBKeyRange.only(h);tu(i.index(Vd),u,p=>{a.push(p),r()})}}):[]}async function Uv(e,t){const n=await su(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await Ov(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function Wv(e,t){return Ze(e,Bt,ln,(n,i,s)=>Pt(n,t,o=>{if(o)return s(o);Pt(n.index(Yd),t,a=>s(a||null))}))}function Ba(e,t,n){return Ze(e,t,ln,(i,s,o)=>Pt(i,n,o))}function zv(e,t,n,i){return Ze(e,t,Ra,(s,o)=>{s.put(i,n),Da(o)})}function Kv(e,t){return Ze(e,Ia,Ra,(n,i)=>Pt(n,t,s=>{n.put((s||0)+1,t),Da(i)}))}function Hv(e,t,n){return n===0?[]:Ze(e,[Ia,Bt],ln,([i,s],o,a)=>{const r=[];i.index(Qd).openCursor(void 0,"prev").onsuccess=l=>{const d=l.target.result;if(!d)return a(r);function h(v){if(r.push(v),r.length===n)return a(r);d.continue()}const u=d.primaryKey,p=t.byName(u);if(p)return h(p);Pt(s,u,v=>{if(v)return h(v);d.continue()})}})}const vi="";function qv(e,t){const n=new Map;for(const s of e){const o=t(s);for(const a of o){let r=n;for(let d=0;d<a.length;d++){const h=a.charAt(d);let u=r.get(h);u||(u=new Map,r.set(h,u)),r=u}let l=r.get(vi);l||(l=[],r.set(vi,l)),l.push(s)}}return(s,o)=>{let a=n;for(let d=0;d<s.length;d++){const h=s.charAt(d),u=a.get(h);if(u)a=u;else return[]}if(o)return a.get(vi)||[];const r=[],l=[a];for(;l.length;){const h=[...l.shift().entries()].sort((u,p)=>u[0]<p[0]?-1:1);for(const[u,p]of h)u===vi?r.push(...p):l.push(p)}return r}}const jv=["name","url"];function Gv(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||jv.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function cl(e){Gv(e);const t=(p,v)=>p.name.toLowerCase()<v.name.toLowerCase()?-1:1,n=e.sort(t),s=qv(e,p=>{const v=new Set;if(p.shortcodes)for(const $ of p.shortcodes)for(const S of Vt($))v.add(S);return v}),o=p=>s(p,!0),a=p=>s(p,!1),r=p=>{const v=Vt(p),$=v.map((S,M)=>(M<v.length-1?o:a)(S));return nu($,S=>S.name).sort(t)},l=new Map,d=new Map;for(const p of e){d.set(p.name.toLowerCase(),p);for(const v of p.shortcodes||[])l.set(v.toLowerCase(),p)}return{all:n,search:r,byShortcode:p=>l.get(p.toLowerCase()),byName:p=>d.get(p.toLowerCase())}}const Vv=typeof wrappedJSObject<"u";function $n(e){if(!e)return e;if(Vv&&(e=structuredClone(e)),delete e.tokens,e.skinTones){const t=e.skinTones.length;e.skins=Array(t);for(let n=0;n<t;n++)e.skins[n]={tone:e.skinTones[n],unicode:e.skinUnicodes[n],version:e.skinVersions[n]};delete e.skinTones,delete e.skinUnicodes,delete e.skinVersions}return e}function ou(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const Qv=["annotation","emoji","group","order","version"];function Jv(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||Qv.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function au(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function Yv(e){const t=await fetch(e,{method:"HEAD"});au(t,e);const n=t.headers.get("etag");return ou(n),n}async function Fo(e){const t=await fetch(e);au(t,e);const n=t.headers.get("etag");ou(n);const i=await t.json();return Jv(i),[n,i]}function Xv(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function Zv(e){for(var t=e.length,n=new ArrayBuffer(t),i=new Uint8Array(n),s=-1;++s<t;)i[s]=e.charCodeAt(s);return n}async function ru(e){const t=JSON.stringify(e);let n=Zv(t);const i=await crypto.subtle.digest("SHA-1",n),s=Xv(i);return btoa(s)}async function eb(e,t){let n,i=await Yv(t);if(!i){const s=await Fo(t);i=s[0],n=s[1],i||(i=await ru(n))}await Nv(e,t,i)||(n||(n=(await Fo(t))[1]),await iu(e,n,t,i))}async function tb(e,t){let[n,i]=await Fo(t);n||(n=await ru(i)),await iu(e,i,t,n)}async function nb(e,t){try{await eb(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class ib{constructor({dataSource:t=Sv,locale:n=Av,customEmoji:i=[]}={}){this.dataSource=t,this.locale=n,this._dbName=`emoji-picker-element-${this.locale}`,this._db=void 0,this._lazyUpdate=void 0,this._custom=cl(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await _v(this._dbName);Pv(this._dbName,this._clear);const n=this.dataSource;await Bv(t)?await tb(t,n):this._lazyUpdate=nb(t,n)}async ready(){const t=async()=>(this._ready||(this._ready=this._init()),this._ready);await t(),this._db||await t()}async getEmojiByGroup(t){return to(t),await this.ready(),ll(await Fv(this._db,t)).map($n)}async getEmojiBySearchQuery(t){yi(t),await this.ready();const n=this._custom.search(t),i=ll(await su(this._db,t)).map($n);return[...n,...i]}async getEmojiByShortcode(t){yi(t),await this.ready();const n=this._custom.byShortcode(t);return n||$n(await Uv(this._db,t))}async getEmojiByUnicodeOrName(t){yi(t),await this.ready();const n=this._custom.byName(t);return n||$n(await Wv(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Ba(this._db,Xt,rl)||0}async setPreferredSkinTone(t){return to(t),await this.ready(),zv(this._db,Xt,rl,t)}async incrementFavoriteEmojiCount(t){return yi(t),await this.ready(),Kv(this._db,t)}async getTopFavoriteEmoji(t){return to(t),await this.ready(),(await Hv(this._db,this._custom,t)).map($n)}set customEmoji(t){this._custom=cl(t)}get customEmoji(){return this._custom.all}async _shutdown(){await this.ready();try{await this._lazyUpdate}catch{}}_clear(){this._db=this._ready=this._lazyUpdate=void 0}async close(){await this._shutdown(),await La(this._dbName)}async delete(){await this._shutdown(),await Mv(this._dbName)}}const Uo=[[-1,"✨","custom"],[0,"😀","smileys-emotion"],[1,"👋","people-body"],[3,"🐱","animals-nature"],[4,"🍎","food-drink"],[5,"🏠️","travel-places"],[6,"⚽","activities"],[7,"📝","objects"],[8,"⛔️","symbols"],[9,"🏁","flags"]].map(([e,t,n])=>({id:e,emoji:t,name:n})),no=Uo.slice(1),sb=2,dl=6,lu=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function ul(e){return e.unicode.includes("")}const ob={"":17,"":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱♀️":4,"🤣":3,"👁️🗨️":2,"😀":1,"😐️":.7,"😃":.6},ab=1e3,rb="🖐️",lb=8,cb=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],cu='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',db=(e,t)=>e<t?-1:e>t?1:0,pl=(e,t)=>{const n=document.createElement("canvas");n.width=n.height=1;const i=n.getContext("2d",{willReadFrequently:!0});return i.textBaseline="top",i.font=`100px ${cu}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},ub=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function pb(e){const t=pl(e,"#000"),n=pl(e,"#fff");return t&&n&&ub(t,n)}function hb(){const e=Object.entries(ob);try{for(const[t,n]of e)if(pb(t))return n}catch{}return e[0][1]}let io;const so=()=>(io||(io=new Promise(e=>lu(()=>e(hb())))),io),Wo=new Map,fb="️",gb="\uD83C",mb="",yb=127995,vb=57339;function bb(e,t){if(t===0)return e;const n=e.indexOf(mb);return n!==-1?e.substring(0,n)+String.fromCodePoint(yb+t-1)+e.substring(n):(e.endsWith(fb)&&(e=e.substring(0,e.length-1)),e+gb+String.fromCodePoint(vb+t-1))}function Be(e){e.preventDefault(),e.stopPropagation()}function oo(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function du(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function wb(e,t){const n=i=>{const s={};for(const o of i)typeof o.tone=="number"&&o.version<=t&&(s[o.tone]=o.unicode);return s};return e.map(({unicode:i,skins:s,shortcodes:o,url:a,name:r,category:l,annotation:d})=>({unicode:i,name:r,shortcodes:o,url:a,category:l,annotation:d,id:i||r,skins:s&&n(s)}))}const Ti=requestAnimationFrame;let kb=typeof ResizeObserver=="function";function xb(e,t,n){let i;kb?(i=new ResizeObserver(n),i.observe(e)):Ti(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function hl(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let ao;function $b(e,t,n){let i=!0,s=!1;for(const o of e){const a=n(o);if(!a)continue;const r=hl(a);r===0&&(s=!0),typeof ao>"u"&&(ao=hl(t));const l=r/1.8<ao;Wo.set(o.unicode,l),l||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
|
|
3025
3015
|
This is likely due to using \`display:none\` which is unsupported.
|
|
3026
3016
|
If this is a Jest/Vitest environment, you can ignore this warning.
|
|
3027
|
-
For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function Sb(e){return du(e,t=>t)}function Ab(e){e&&(e.scrollTop=0)}function Dn(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function fl(e){return""+e}function Cb(e){const t=document.createElement("template");return t.innerHTML=e,t}const Eb=new WeakMap,Tb=new WeakMap,_b=Symbol("un-keyed"),Mb="replaceChildren"in Element.prototype;function Pb(e,t){Mb?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function Ib(e,t){let n=e.firstChild,i=0;for(;n;){if(t[i]!==n)return!0;n=n.nextSibling,i++}return i!==t.length}function Rb(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=Ib(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&Pb(i,e)}function Lb(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:a,attributeValuePre:r,attributeValuePost:l}}=n,d=e[o];if(s!==d)if(n.currentExpression=d,a)if(d===null)i.removeAttribute(a);else{const h=r+fl(d)+l;i.setAttribute(a,h)}else{let h;Array.isArray(d)?Rb(d,n):d instanceof Element?(h=d,i.replaceWith(h)):i.nodeValue=fl(d),h&&(n.targetNode=h)}}}function Db(e){let t="",n=!1,i=!1,s=-1;const o=new Map,a=[];let r=0;for(let d=0,h=e.length;d<h;d++){const u=e[d];if(t+=u.slice(r),d===h-1)break;for(let b=0;b<u.length;b++)switch(u.charAt(b)){case"<":{u.charAt(b+1)==="/"?a.pop():(n=!0,a.push(++s));break}case">":{n=!1,i=!1;break}case"=":{i=!0;break}}const p=a[a.length-1],v=Dn(o,p,()=>[]);let $,S,M;if(i){const b=/(\S+)="?([^"=]*)$/.exec(u);$=b[1],S=b[2];const k=/^([^">]*)("?)/.exec(e[d+1]);M=k[1],t=t.slice(0,-1*b[0].length),r=k[0].length}else r=0;const y={attributeName:$,attributeValuePre:S,attributeValuePost:M,expressionIndex:d};v.push(y),!n&&!i&&(t+=" ")}return{template:Cb(t),elementsToBindings:o}}function gl(e,t,n){for(let i=0;i<e.length;i++){const s=e[i],o=s.attributeName?t:t.firstChild,a={binding:s,targetNode:o,targetParentNode:void 0,currentExpression:void 0};n.push(a)}}function Bb(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))gl(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,a=-1;do{const r=t.get(++a);r&&gl(r,o,n)}while(o=s.nextNode())}return n}function Nb(e){const{template:t,elementsToBindings:n}=Dn(Eb,e,()=>Db(e)),i=t.cloneNode(!0).content.firstElementChild,s=Bb(i,n);return function(a){return Lb(a,s),i}}function Ob(e){const t=Dn(Tb,e,()=>new Map);let n=_b;function i(o,...a){const r=Dn(t,o,()=>new Map);return Dn(r,n,()=>Nb(o))(a)}function s(o,a,r){return o.map((l,d)=>{const h=n;n=r(l);try{return a(l,d)}finally{n=h}})}return{map:s,html:i}}function Fb(e,t,n,i,s,o,a,r,l){const{labelWithSkin:d,titleForEmoji:h,unicodeWithSkin:u}=n,{html:p,map:v}=Ob(t);function $(b,k,A){return v(b,(E,T)=>p`<button role="${k?"option":"menuitem"}" aria-selected="${k?T===t.activeSearchItem:null}" aria-label="${d(E,t.currentSkinTone)}" title="${h(E)}" class="${"emoji"+(k&&T===t.activeSearchItem?" active":"")+(E.unicode?"":" custom-emoji")}" id="${`${A}-${E.id}`}" style="${E.unicode?null:`--custom-emoji-background: url(${JSON.stringify(E.url)})`}">${E.unicode?u(E,t.currentSkinTone):""}</button>`,E=>`${A}-${E.id}`)}const M=p`<section data-ref="rootElement" class="picker" aria-label="${t.i18n.regionLabel}" style="${t.pickerStyle||""}"><div class="pad-top"></div><div class="search-row"><div class="search-wrapper"><input id="search" class="search" type="search" role="combobox" enterkeyhint="search" placeholder="${t.i18n.searchLabel}" autocapitalize="none" autocomplete="off" spellcheck="true" aria-expanded="${!!(t.searchMode&&t.currentEmojis.length)}" aria-controls="search-results" aria-describedby="search-description" aria-autocomplete="list" aria-activedescendant="${t.activeSearchItemId?`emo-${t.activeSearchItemId}`:null}" data-ref="searchElement" data-on-input="onSearchInput" data-on-keydown="onSearchKeydown"><label class="sr-only" for="search">${t.i18n.searchLabel}</label> <span id="search-description" class="sr-only">${t.i18n.searchDescription}</span></div><div class="skintone-button-wrapper ${t.skinTonePickerExpandedAfterAnimation?"expanded":""}"><button id="skintone-button" class="emoji ${t.skinTonePickerExpanded?"hide-focus":""}" aria-label="${t.skinToneButtonLabel}" title="${t.skinToneButtonLabel}" aria-describedby="skintone-description" aria-haspopup="listbox" aria-expanded="${t.skinTonePickerExpanded}" aria-controls="skintone-list" data-on-click="onClickSkinToneButton">${t.skinToneButtonText||""}</button></div><span id="skintone-description" class="sr-only">${t.i18n.skinToneDescription}</span><div data-ref="skinToneDropdown" id="skintone-list" class="skintone-list hide-focus ${t.skinTonePickerExpanded?"":"hidden no-animate"}" style="transform:translateY(${t.skinTonePickerExpanded?0:"calc(-1 * var(--num-skintones) * var(--total-emoji-size))"})" role="listbox" aria-label="${t.i18n.skinTonesLabel}" aria-activedescendant="skintone-${t.activeSkinTone}" aria-hidden="${!t.skinTonePickerExpanded}" tabIndex="-1" data-on-focusout="onSkinToneOptionsFocusOut" data-on-click="onSkinToneOptionsClick" data-on-keydown="onSkinToneOptionsKeydown" data-on-keyup="onSkinToneOptionsKeyup">${v(t.skinTones,(b,k)=>p`<div id="skintone-${k}" class="emoji ${k===t.activeSkinTone?"active":""}" aria-selected="${k===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[k]}" aria-label="${t.i18n.skinTones[k]}">${b}</div>`,b=>b)}</div></div><div class="nav" role="tablist" style="grid-template-columns:repeat(${t.groups.length},1fr)" aria-label="${t.i18n.categoriesLabel}" data-on-keydown="onNavKeydown" data-on-click="onNavClick">${v(t.groups,b=>p`<button role="tab" class="nav-button" aria-controls="tab-${b.id}" aria-label="${t.i18n.categories[b.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===b.id}" title="${t.i18n.categories[b.name]}" data-group-id="${b.id}"><div class="nav-emoji emoji">${b.emoji}</div></button>`,b=>b.id)}</div><div class="indicator-wrapper"><div class="indicator" style="transform:translateX(${(t.isRtl?-1:1)*t.currentGroupIndex*100}%)"></div></div><div class="message ${t.message?"":"gone"}" role="alert" aria-live="polite">${t.message||""}</div><div data-ref="tabpanelElement" class="tabpanel ${!t.databaseLoaded||t.message?"gone":""}" role="${t.searchMode?"region":"tabpanel"}" aria-label="${t.searchMode?t.i18n.searchResultsLabel:t.i18n.categories[t.currentGroup.name]}" id="${t.searchMode?null:`tab-${t.currentGroup.id}`}" tabIndex="0" data-on-click="onEmojiClick"><div data-action="calculateEmojiGridStyle">${v(t.currentEmojisWithCategories,(b,k)=>p`<div><div id="menu-label-${k}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:b.category?b.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${k!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(b.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${k}" id="${t.searchMode?"search-results":null}">${$(b.emojis,t.searchMode,"emo")}</div></div>`,b=>b.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${$(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,y=(b,k)=>{for(const A of e.querySelectorAll(`[${b}]`))k(A,A.getAttribute(b))};if(l){e.appendChild(M);for(const b of["click","focusout","input","keydown","keyup"])y(`data-on-${b}`,(k,A)=>{k.addEventListener(b,i[A])});y("data-ref",(b,k)=>{o[k]=b}),a.addEventListener("abort",()=>{e.removeChild(M)})}y("data-action",(b,k)=>{let A=r.get(k);A||r.set(k,A=new WeakSet),A.has(b)||(A.add(b),s[k](b))})}const es=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function Ub(e){let t=!1,n;const i=new Map,s=new Set;let o;const a=()=>{if(t)return;const d=[...s];s.clear();try{for(const h of d)h()}finally{o=!1,s.size&&(o=!0,es(a))}},r=new Proxy({},{get(d,h){if(n){let u=i.get(h);u||(u=new Set,i.set(h,u)),u.add(n)}return d[h]},set(d,h,u){if(d[h]!==u){d[h]=u;const p=i.get(h);if(p){for(const v of p)s.add(v);o||(o=!0,es(a))}}return!0}}),l=d=>{const h=()=>{const u=n;n=h;try{return d()}finally{n=u}};return h()};return e.addEventListener("abort",()=>{t=!0}),{state:r,createEffect:l}}function ro(e,t,n){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}const ml=new WeakMap;function Wb(e,t,n){{const i=e.closest(".tabpanel");let s=ml.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),ml.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const lo=[],{assign:bi}=Object;function zb(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:a}=Ub(s),r=new Map;bi(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),bi(o,t),bi(o,{initialLoad:!0,currentEmojis:[],currentEmojisWithCategories:[],rawSearchText:"",searchText:"",searchMode:!1,activeSearchItem:-1,message:void 0,skinTonePickerExpanded:!1,skinTonePickerExpandedAfterAnimation:!1,currentSkinTone:0,activeSkinTone:0,skinToneButtonText:void 0,pickerStyle:void 0,skinToneButtonLabel:"",skinTones:[],currentFavorites:[],defaultFavoriteEmojis:void 0,numColumns:lb,isRtl:!1,currentGroupIndex:0,groups:no,databaseLoaded:!1,activeSearchItemId:void 0}),a(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const l=C=>{e.getElementById(C).focus()},d=C=>e.getElementById(`emo-${C.id}`),h=(C,R)=>{n.rootElement.dispatchEvent(new CustomEvent(C,{detail:R,bubbles:!0,composed:!0}))},u=(C,R)=>C.id===R.id,p=(C,R)=>{const{category:F,emojis:U}=C,{category:Z,emojis:J}=R;return F!==Z?!1:ro(U,J,u)},v=C=>{ro(o.currentEmojis,C,u)||(o.currentEmojis=C)},$=C=>{o.searchMode!==C&&(o.searchMode=C)},S=C=>{ro(o.currentEmojisWithCategories,C,p)||(o.currentEmojisWithCategories=C)},M=(C,R)=>R&&C.skins&&C.skins[R]||C.unicode,k={labelWithSkin:(C,R)=>Sb([C.name||M(C,R),C.annotation,...C.shortcodes||lo].filter(Boolean)).join(", "),titleForEmoji:C=>C.annotation||(C.shortcodes||lo).join(", "),unicodeWithSkin:M},A={onClickSkinToneButton:X,onEmojiClick:Yn,onNavClick:Qn,onNavKeydown:ks,onSearchKeydown:ws,onSkinToneOptionsClick:Xn,onSkinToneOptionsFocusOut:et,onSkinToneOptionsKeydown:dt,onSkinToneOptionsKeyup:dn,onSearchInput:Zn},E={calculateEmojiGridStyle:D,updateOnIntersection:W};let T=!0;a(()=>{Fb(e,o,k,A,E,n,s,r,T),T=!1}),o.emojiVersion||so().then(C=>{C||(o.message=o.i18n.emojiUnsupportedMessage)}),a(()=>{async function C(){let R=!1;const F=setTimeout(()=>{R=!0,o.message=o.i18n.loadingMessage},ab);try{await o.database.ready(),o.databaseLoaded=!0}catch(U){console.error(U),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(F),R&&(R=!1,o.message="")}}o.database&&C()}),a(()=>{o.pickerStyle=`
|
|
3017
|
+
For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function Sb(e){return du(e,t=>t)}function Ab(e){e&&(e.scrollTop=0)}function Dn(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function fl(e){return""+e}function Cb(e){const t=document.createElement("template");return t.innerHTML=e,t}const Eb=new WeakMap,Tb=new WeakMap,_b=Symbol("un-keyed"),Mb="replaceChildren"in Element.prototype;function Pb(e,t){Mb?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function Ib(e,t){let n=e.firstChild,i=0;for(;n;){if(t[i]!==n)return!0;n=n.nextSibling,i++}return i!==t.length}function Rb(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=Ib(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&Pb(i,e)}function Lb(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:a,attributeValuePre:r,attributeValuePost:l}}=n,d=e[o];if(s!==d)if(n.currentExpression=d,a)if(d===null)i.removeAttribute(a);else{const h=r+fl(d)+l;i.setAttribute(a,h)}else{let h;Array.isArray(d)?Rb(d,n):d instanceof Element?(h=d,i.replaceWith(h)):i.nodeValue=fl(d),h&&(n.targetNode=h)}}}function Db(e){let t="",n=!1,i=!1,s=-1;const o=new Map,a=[];let r=0;for(let d=0,h=e.length;d<h;d++){const u=e[d];if(t+=u.slice(r),d===h-1)break;for(let b=0;b<u.length;b++)switch(u.charAt(b)){case"<":{u.charAt(b+1)==="/"?a.pop():(n=!0,a.push(++s));break}case">":{n=!1,i=!1;break}case"=":{i=!0;break}}const p=a[a.length-1],v=Dn(o,p,()=>[]);let $,S,M;if(i){const b=/(\S+)="?([^"=]*)$/.exec(u);$=b[1],S=b[2];const k=/^([^">]*)("?)/.exec(e[d+1]);M=k[1],t=t.slice(0,-1*b[0].length),r=k[0].length}else r=0;const y={attributeName:$,attributeValuePre:S,attributeValuePost:M,expressionIndex:d};v.push(y),!n&&!i&&(t+=" ")}return{template:Cb(t),elementsToBindings:o}}function gl(e,t,n){for(let i=0;i<e.length;i++){const s=e[i],o=s.attributeName?t:t.firstChild,a={binding:s,targetNode:o,targetParentNode:void 0,currentExpression:void 0};n.push(a)}}function Bb(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))gl(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,a=-1;do{const r=t.get(++a);r&&gl(r,o,n)}while(o=s.nextNode())}return n}function Nb(e){const{template:t,elementsToBindings:n}=Dn(Eb,e,()=>Db(e)),i=t.cloneNode(!0).content.firstElementChild,s=Bb(i,n);return function(a){return Lb(a,s),i}}function Ob(e){const t=Dn(Tb,e,()=>new Map);let n=_b;function i(o,...a){const r=Dn(t,o,()=>new Map);return Dn(r,n,()=>Nb(o))(a)}function s(o,a,r){return o.map((l,d)=>{const h=n;n=r(l);try{return a(l,d)}finally{n=h}})}return{map:s,html:i}}function Fb(e,t,n,i,s,o,a,r,l){const{labelWithSkin:d,titleForEmoji:h,unicodeWithSkin:u}=n,{html:p,map:v}=Ob(t);function $(b,k,A){return v(b,(E,T)=>p`<button role="${k?"option":"menuitem"}" aria-selected="${k?T===t.activeSearchItem:null}" aria-label="${d(E,t.currentSkinTone)}" title="${h(E)}" class="${"emoji"+(k&&T===t.activeSearchItem?" active":"")+(E.unicode?"":" custom-emoji")}" id="${`${A}-${E.id}`}" style="${E.unicode?null:`--custom-emoji-background: url(${JSON.stringify(E.url)})`}">${E.unicode?u(E,t.currentSkinTone):""}</button>`,E=>`${A}-${E.id}`)}const M=p`<section data-ref="rootElement" class="picker" aria-label="${t.i18n.regionLabel}" style="${t.pickerStyle||""}"><div class="pad-top"></div><div class="search-row"><div class="search-wrapper"><input id="search" class="search" type="search" role="combobox" enterkeyhint="search" placeholder="${t.i18n.searchLabel}" autocapitalize="none" autocomplete="off" spellcheck="true" aria-expanded="${!!(t.searchMode&&t.currentEmojis.length)}" aria-controls="search-results" aria-describedby="search-description" aria-autocomplete="list" aria-activedescendant="${t.activeSearchItemId?`emo-${t.activeSearchItemId}`:null}" data-ref="searchElement" data-on-input="onSearchInput" data-on-keydown="onSearchKeydown"><label class="sr-only" for="search">${t.i18n.searchLabel}</label> <span id="search-description" class="sr-only">${t.i18n.searchDescription}</span></div><div class="skintone-button-wrapper ${t.skinTonePickerExpandedAfterAnimation?"expanded":""}"><button id="skintone-button" class="emoji ${t.skinTonePickerExpanded?"hide-focus":""}" aria-label="${t.skinToneButtonLabel}" title="${t.skinToneButtonLabel}" aria-describedby="skintone-description" aria-haspopup="listbox" aria-expanded="${t.skinTonePickerExpanded}" aria-controls="skintone-list" data-on-click="onClickSkinToneButton">${t.skinToneButtonText||""}</button></div><span id="skintone-description" class="sr-only">${t.i18n.skinToneDescription}</span><div data-ref="skinToneDropdown" id="skintone-list" class="skintone-list hide-focus ${t.skinTonePickerExpanded?"":"hidden no-animate"}" style="transform:translateY(${t.skinTonePickerExpanded?0:"calc(-1 * var(--num-skintones) * var(--total-emoji-size))"})" role="listbox" aria-label="${t.i18n.skinTonesLabel}" aria-activedescendant="skintone-${t.activeSkinTone}" aria-hidden="${!t.skinTonePickerExpanded}" tabIndex="-1" data-on-focusout="onSkinToneOptionsFocusOut" data-on-click="onSkinToneOptionsClick" data-on-keydown="onSkinToneOptionsKeydown" data-on-keyup="onSkinToneOptionsKeyup">${v(t.skinTones,(b,k)=>p`<div id="skintone-${k}" class="emoji ${k===t.activeSkinTone?"active":""}" aria-selected="${k===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[k]}" aria-label="${t.i18n.skinTones[k]}">${b}</div>`,b=>b)}</div></div><div class="nav" role="tablist" style="grid-template-columns:repeat(${t.groups.length},1fr)" aria-label="${t.i18n.categoriesLabel}" data-on-keydown="onNavKeydown" data-on-click="onNavClick">${v(t.groups,b=>p`<button role="tab" class="nav-button" aria-controls="tab-${b.id}" aria-label="${t.i18n.categories[b.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===b.id}" title="${t.i18n.categories[b.name]}" data-group-id="${b.id}"><div class="nav-emoji emoji">${b.emoji}</div></button>`,b=>b.id)}</div><div class="indicator-wrapper"><div class="indicator" style="transform:translateX(${(t.isRtl?-1:1)*t.currentGroupIndex*100}%)"></div></div><div class="message ${t.message?"":"gone"}" role="alert" aria-live="polite">${t.message||""}</div><div data-ref="tabpanelElement" class="tabpanel ${!t.databaseLoaded||t.message?"gone":""}" role="${t.searchMode?"region":"tabpanel"}" aria-label="${t.searchMode?t.i18n.searchResultsLabel:t.i18n.categories[t.currentGroup.name]}" id="${t.searchMode?null:`tab-${t.currentGroup.id}`}" tabIndex="0" data-on-click="onEmojiClick"><div data-action="calculateEmojiGridStyle">${v(t.currentEmojisWithCategories,(b,k)=>p`<div><div id="menu-label-${k}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:b.category?b.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${k!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(b.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${k}" id="${t.searchMode?"search-results":null}">${$(b.emojis,t.searchMode,"emo")}</div></div>`,b=>b.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${$(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,y=(b,k)=>{for(const A of e.querySelectorAll(`[${b}]`))k(A,A.getAttribute(b))};if(l){e.appendChild(M);for(const b of["click","focusout","input","keydown","keyup"])y(`data-on-${b}`,(k,A)=>{k.addEventListener(b,i[A])});y("data-ref",(b,k)=>{o[k]=b}),a.addEventListener("abort",()=>{e.removeChild(M)})}y("data-action",(b,k)=>{let A=r.get(k);A||r.set(k,A=new WeakSet),A.has(b)||(A.add(b),s[k](b))})}const es=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function Ub(e){let t=!1,n;const i=new Map,s=new Set;let o;const a=()=>{if(t)return;const d=[...s];s.clear();try{for(const h of d)h()}finally{o=!1,s.size&&(o=!0,es(a))}},r=new Proxy({},{get(d,h){if(n){let u=i.get(h);u||(u=new Set,i.set(h,u)),u.add(n)}return d[h]},set(d,h,u){if(d[h]!==u){d[h]=u;const p=i.get(h);if(p){for(const v of p)s.add(v);o||(o=!0,es(a))}}return!0}}),l=d=>{const h=()=>{const u=n;n=h;try{return d()}finally{n=u}};return h()};return e.addEventListener("abort",()=>{t=!0}),{state:r,createEffect:l}}function ro(e,t,n){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}const ml=new WeakMap;function Wb(e,t,n){{const i=e.closest(".tabpanel");let s=ml.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),ml.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const lo=[],{assign:bi}=Object;function zb(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:a}=Ub(s),r=new Map;bi(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),bi(o,t),bi(o,{initialLoad:!0,currentEmojis:[],currentEmojisWithCategories:[],rawSearchText:"",searchText:"",searchMode:!1,activeSearchItem:-1,message:void 0,skinTonePickerExpanded:!1,skinTonePickerExpandedAfterAnimation:!1,currentSkinTone:0,activeSkinTone:0,skinToneButtonText:void 0,pickerStyle:void 0,skinToneButtonLabel:"",skinTones:[],currentFavorites:[],defaultFavoriteEmojis:void 0,numColumns:lb,isRtl:!1,currentGroupIndex:0,groups:no,databaseLoaded:!1,activeSearchItemId:void 0}),a(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const l=C=>{e.getElementById(C).focus()},d=C=>e.getElementById(`emo-${C.id}`),h=(C,R)=>{n.rootElement.dispatchEvent(new CustomEvent(C,{detail:R,bubbles:!0,composed:!0}))},u=(C,R)=>C.id===R.id,p=(C,R)=>{const{category:F,emojis:U}=C,{category:ee,emojis:J}=R;return F!==ee?!1:ro(U,J,u)},v=C=>{ro(o.currentEmojis,C,u)||(o.currentEmojis=C)},$=C=>{o.searchMode!==C&&(o.searchMode=C)},S=C=>{ro(o.currentEmojisWithCategories,C,p)||(o.currentEmojisWithCategories=C)},M=(C,R)=>R&&C.skins&&C.skins[R]||C.unicode,k={labelWithSkin:(C,R)=>Sb([C.name||M(C,R),C.annotation,...C.shortcodes||lo].filter(Boolean)).join(", "),titleForEmoji:C=>C.annotation||(C.shortcodes||lo).join(", "),unicodeWithSkin:M},A={onClickSkinToneButton:X,onEmojiClick:Yn,onNavClick:Qn,onNavKeydown:ks,onSearchKeydown:ws,onSkinToneOptionsClick:Xn,onSkinToneOptionsFocusOut:et,onSkinToneOptionsKeydown:dt,onSkinToneOptionsKeyup:dn,onSearchInput:Zn},E={calculateEmojiGridStyle:D,updateOnIntersection:W};let T=!0;a(()=>{Fb(e,o,k,A,E,n,s,r,T),T=!1}),o.emojiVersion||so().then(C=>{C||(o.message=o.i18n.emojiUnsupportedMessage)}),a(()=>{async function C(){let R=!1;const F=setTimeout(()=>{R=!0,o.message=o.i18n.loadingMessage},ab);try{await o.database.ready(),o.databaseLoaded=!0}catch(U){console.error(U),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(F),R&&(R=!1,o.message="")}}o.database&&C()}),a(()=>{o.pickerStyle=`
|
|
3028
3018
|
--num-groups: ${o.groups.length};
|
|
3029
3019
|
--indicator-opacity: ${o.searchMode?0:1};
|
|
3030
|
-
--num-skintones: ${dl};`}),a(()=>{o.customEmoji&&o.database&&P()}),a(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==Uo&&(o.groups=Uo):o.groups!==no&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=no)}),a(()=>{async function C(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}C()}),a(()=>{o.skinTones=Array(dl).fill().map((C,R)=>bb(o.skinToneEmoji,R))}),a(()=>{o.skinToneButtonText=o.skinTones[o.currentSkinTone]}),a(()=>{o.skinToneButtonLabel=o.i18n.skinToneLabel.replace("{skinTone}",o.i18n.skinTones[o.currentSkinTone])}),a(()=>{async function C(){const{database:R}=o,F=(await Promise.all(cb.map(U=>R.getEmojiByUnicodeOrName(U)))).filter(Boolean);o.defaultFavoriteEmojis=F}o.databaseLoaded&&C()});function P(){const{customEmoji:C,database:R}=o,F=C||lo;R.customEmoji!==F&&(R.customEmoji=F)}a(()=>{async function C(){P();const{database:R,defaultFavoriteEmojis:F,numColumns:U}=o,Z=await R.getTopFavoriteEmoji(U),J=await Ke(du([...Z,...F],he=>he.unicode||he.name).slice(0,U));o.currentFavorites=J}o.databaseLoaded&&o.defaultFavoriteEmojis&&C()});function D(C){xb(C,s,()=>{{const R=getComputedStyle(n.rootElement),F=parseInt(R.getPropertyValue("--num-columns"),10),U=R.getPropertyValue("direction")==="rtl";o.numColumns=F,o.isRtl=U}})}function W(C){Wb(C,s,R=>{for(const{target:F,isIntersecting:U}of R)F.classList.toggle("onscreen",U)})}a(()=>{async function C(){const{searchText:R,currentGroup:F,databaseLoaded:U,customEmoji:Z}=o;if(!U)o.currentEmojis=[],o.searchMode=!1;else if(R.length>=sb){const J=await bs(R);o.searchText===R&&(v(J),$(!0))}else{const{id:J}=F;if(J!==-1||Z&&Z.length){const he=await vs(J);o.currentGroup.id===J&&(v(he),$(!1))}}}C()});const K=()=>{Ti(()=>Ab(n.tabpanelElement))};a(()=>{const{currentEmojis:C,emojiVersion:R}=o,F=C.filter(U=>U.unicode).filter(U=>ul(U)&&!Wo.has(U.unicode));if(!R&&F.length)v(C),Ti(()=>H(F));else{const U=R?C:C.filter(ke);v(U),K()}});function H(C){$b(C,n.baselineEmoji,d)?K():o.currentEmojis=[...o.currentEmojis]}function ke(C){return!C.unicode||!ul(C)||Wo.get(C.unicode)}async function Ie(C){const R=o.emojiVersion||await so();return C.filter(({version:F})=>!F||F<=R)}async function Ke(C){return wb(C,o.emojiVersion||await so())}async function vs(C){const R=C===-1?o.customEmoji:await o.database.getEmojiByGroup(C);return Ke(await Ie(R))}async function bs(C){return Ke(await Ie(await o.database.getEmojiBySearchQuery(C)))}a(()=>{}),a(()=>{function C(){const{searchMode:F,currentEmojis:U}=o;if(F)return[{category:"",emojis:U}];const Z=new Map;for(const J of U){const he=J.category||"";let tt=Z.get(he);tt||(tt=[],Z.set(he,tt)),tt.push(J)}return[...Z.entries()].map(([J,he])=>({category:J,emojis:he})).sort((J,he)=>o.customCategorySorting(J.category,he.category))}const R=C();S(R)}),a(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),a(()=>{const{rawSearchText:C}=o;lu(()=>{o.searchText=(C||"").trim(),o.activeSearchItem=-1})});function ws(C){if(!o.searchMode||!o.currentEmojis.length)return;const R=F=>{Be(C),o.activeSearchItem=oo(F,o.activeSearchItem,o.currentEmojis)};switch(C.key){case"ArrowDown":return R(!1);case"ArrowUp":return R(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return Be(C),te(o.currentEmojis[o.activeSearchItem].id)}}function Qn(C){const{target:R}=C,F=R.closest(".nav-button");if(!F)return;const U=parseInt(F.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(Z=>Z.id===U)}function ks(C){const{target:R,key:F}=C,U=Z=>{Z&&(Be(C),Z.focus())};switch(F){case"ArrowLeft":return U(R.previousElementSibling);case"ArrowRight":return U(R.nextElementSibling);case"Home":return U(R.parentElement.firstElementChild);case"End":return U(R.parentElement.lastElementChild)}}async function Jn(C){const R=await o.database.getEmojiByUnicodeOrName(C),F=[...o.currentEmojis,...o.currentFavorites].find(Z=>Z.id===C),U=F.unicode&&M(F,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(C),{emoji:R,skinTone:o.currentSkinTone,...U&&{unicode:U},...F.name&&{name:F.name}}}async function te(C){const R=Jn(C);h("emoji-click-sync",R),h("emoji-click",await R)}function Yn(C){const{target:R}=C;if(!R.classList.contains("emoji"))return;Be(C);const F=R.id.substring(4);te(F)}function ne(C){o.currentSkinTone=C,o.skinTonePickerExpanded=!1,l("skintone-button"),h("skin-tone-change",{skinTone:C}),o.database.setPreferredSkinTone(C)}function Xn(C){const{target:{id:R}}=C,F=R&&R.match(/^skintone-(\d)/);if(!F)return;Be(C);const U=parseInt(F[1],10);ne(U)}function X(C){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(Be(C),Ti(()=>l("skintone-list")))}a(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function dt(C){if(!o.skinTonePickerExpanded)return;const R=async F=>{Be(C),o.activeSkinTone=F};switch(C.key){case"ArrowUp":return R(oo(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return R(oo(!1,o.activeSkinTone,o.skinTones));case"Home":return R(0);case"End":return R(o.skinTones.length-1);case"Enter":return Be(C),ne(o.activeSkinTone);case"Escape":return Be(C),o.skinTonePickerExpanded=!1,l("skintone-button")}}function dn(C){if(o.skinTonePickerExpanded&&C.key===" ")return Be(C),ne(o.activeSkinTone)}async function et(C){const{relatedTarget:R}=C;(!R||R.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function Zn(C){o.rawSearchText=C.target.value}return{$set(C){bi(o,C)},$destroy(){i.abort()}}}const Kb="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Hb="en";var qb={categoriesLabel:"Categories",emojiUnsupportedMessage:"Your browser does not support color emoji.",favoritesLabel:"Favorites",loadingMessage:"Loading…",networkErrorMessage:"Could not load emoji.",regionLabel:"Emoji picker",searchDescription:"When search results are available, press up or down to select and enter to choose.",searchLabel:"Search",searchResultsLabel:"Search results",skinToneDescription:"When expanded, press up or down to select and enter to choose.",skinToneLabel:"Choose a skin tone (currently {skinTone})",skinTonesLabel:"Skin tones",skinTones:["Default","Light","Medium-Light","Medium","Medium-Dark","Dark"],categories:{custom:"Custom","smileys-emotion":"Smileys and emoticons","people-body":"People and body","animals-nature":"Animals and nature","food-drink":"Food and drink","travel-places":"Travel and places",activities:"Activities",objects:"Objects",symbols:"Symbols",flags:"Flags"}},jb=':host{--emoji-size:1.375rem;--emoji-padding:0.5rem;--category-emoji-size:var(--emoji-size);--category-emoji-padding:var(--emoji-padding);--indicator-height:3px;--input-border-radius:0.5rem;--input-border-size:1px;--input-font-size:1rem;--input-line-height:1.5;--input-padding:0.25rem;--num-columns:8;--outline-size:2px;--border-size:1px;--border-radius:0;--skintone-border-radius:1rem;--category-font-size:1rem;display:flex;width:min-content;height:400px}:host,:host(.light){color-scheme:light;--background:#fff;--border-color:#e0e0e0;--indicator-color:#385ac1;--input-border-color:#999;--input-font-color:#111;--input-placeholder-color:#999;--outline-color:#999;--category-font-color:#111;--button-active-background:#e6e6e6;--button-hover-background:#d9d9d9}:host(.dark){color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}@media (prefers-color-scheme:dark){:host{color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}}:host([hidden]){display:none}button{margin:0;padding:0;border:0;background:0 0;box-shadow:none;-webkit-tap-highlight-color:transparent}button::-moz-focus-inner{border:0}input{padding:0;margin:0;line-height:1.15;font-family:inherit}input[type=search]{-webkit-appearance:none}:focus{outline:var(--outline-color) solid var(--outline-size);outline-offset:calc(-1*var(--outline-size))}:host([data-js-focus-visible]) :focus:not([data-focus-visible-added]){outline:0}:focus:not(:focus-visible){outline:0}.hide-focus{outline:0}*{box-sizing:border-box}.picker{contain:content;display:flex;flex-direction:column;background:var(--background);border:var(--border-size) solid var(--border-color);border-radius:var(--border-radius);width:100%;height:100%;overflow:hidden;--total-emoji-size:calc(var(--emoji-size) + (2 * var(--emoji-padding)));--total-category-emoji-size:calc(var(--category-emoji-size) + (2 * var(--category-emoji-padding)))}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.hidden{opacity:0;pointer-events:none}.abs-pos{position:absolute;left:0;top:0}.gone{display:none!important}.skintone-button-wrapper,.skintone-list{background:var(--background);z-index:3}.skintone-button-wrapper.expanded{z-index:1}.skintone-list{position:absolute;inset-inline-end:0;top:0;z-index:2;overflow:visible;border-bottom:var(--border-size) solid var(--border-color);border-radius:0 0 var(--skintone-border-radius) var(--skintone-border-radius);will-change:transform;transition:transform .2s ease-in-out;transform-origin:center 0}@media (prefers-reduced-motion:reduce){.skintone-list{transition-duration:.001s}}@supports not (inset-inline-end:0){.skintone-list{right:0}}.skintone-list.no-animate{transition:none}.tabpanel{overflow-y:auto;scrollbar-gutter:stable;-webkit-overflow-scrolling:touch;will-change:transform;min-height:0;flex:1;contain:content}.emoji-menu{display:grid;grid-template-columns:repeat(var(--num-columns),var(--total-emoji-size));justify-content:space-around;align-items:flex-start;width:100%}.emoji-menu.visibility-auto{content-visibility:auto;contain-intrinsic-size:calc(var(--num-columns)*var(--total-emoji-size)) calc(var(--num-rows)*var(--total-emoji-size))}.category{padding:var(--emoji-padding);font-size:var(--category-font-size);color:var(--category-font-color)}.emoji,button.emoji{font-size:var(--emoji-size);display:flex;align-items:center;justify-content:center;border-radius:100%;height:var(--total-emoji-size);width:var(--total-emoji-size);line-height:1;overflow:hidden;font-family:var(--emoji-font-family);cursor:pointer}@media (hover:hover) and (pointer:fine){.emoji:hover,button.emoji:hover{background:var(--button-hover-background)}}.emoji.active,.emoji:active,button.emoji.active,button.emoji:active{background:var(--button-active-background)}.onscreen .custom-emoji::after{content:"";width:var(--emoji-size);height:var(--emoji-size);background-repeat:no-repeat;background-position:center center;background-size:contain;background-image:var(--custom-emoji-background)}.nav,.nav-button{align-items:center}.nav{display:grid;justify-content:space-between;contain:content}.nav-button{display:flex;justify-content:center}.nav-emoji{font-size:var(--category-emoji-size);width:var(--total-category-emoji-size);height:var(--total-category-emoji-size)}.indicator-wrapper{display:flex;border-bottom:1px solid var(--border-color)}.indicator{width:calc(100%/var(--num-groups));height:var(--indicator-height);opacity:var(--indicator-opacity);background-color:var(--indicator-color);will-change:transform,opacity;transition:opacity .1s linear,transform .25s ease-in-out}@media (prefers-reduced-motion:reduce){.indicator{will-change:opacity;transition:opacity .1s linear}}.pad-top,input.search{background:var(--background);width:100%}.pad-top{height:var(--emoji-padding);z-index:3}.search-row{display:flex;align-items:center;position:relative;padding-inline-start:var(--emoji-padding);padding-bottom:var(--emoji-padding)}.search-wrapper{flex:1;min-width:0}input.search{padding:var(--input-padding);border-radius:var(--input-border-radius);border:var(--input-border-size) solid var(--input-border-color);color:var(--input-font-color);font-size:var(--input-font-size);line-height:var(--input-line-height)}input.search::placeholder{color:var(--input-placeholder-color)}.favorites{overflow-y:auto;scrollbar-gutter:stable;display:flex;flex-direction:row;border-top:var(--border-size) solid var(--border-color);contain:content}.message{padding:var(--emoji-padding)}';const uu=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Gb=`:host{--emoji-font-family:${cu}}`;class Na extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=jb+Gb,this.shadowRoot.appendChild(n),this._ctx={locale:Hb,dataSource:Kb,skinToneEmoji:rb,customCategorySorting:db,customEmoji:null,i18n:qb,emojiVersion:null,...t};for(const i of uu)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){yl(this),this._cmp||(this._cmp=zb(this.shadowRoot,this._ctx))}disconnectedCallback(){yl(this),es(()=>{if(!this.isConnected&&this._cmp){this._cmp.$destroy(),this._cmp=void 0;const{database:t}=this._ctx;t.close().catch(n=>console.error(n))}})}static get observedAttributes(){return["locale","data-source","skin-tone-emoji","emoji-version"]}attributeChangedCallback(t,n,i){this._set(t.replace(/-([a-z])/g,(s,o)=>o.toUpperCase()),t==="emoji-version"?parseFloat(i):i)}_set(t,n){this._ctx[t]=n,this._cmp&&this._cmp.$set({[t]:n}),["locale","dataSource"].includes(t)&&this._dbFlush()}_dbCreate(){const{locale:t,dataSource:n,database:i}=this._ctx;(!i||i.locale!==t||i.dataSource!==n)&&this._set("database",new ib({locale:t,dataSource:n}))}_dbFlush(){es(()=>this._dbCreate())}}const pu={};for(const e of uu)pu[e]={get(){return e==="database"&&this._dbCreate(),this._ctx[e]},set(t){if(e==="database")throw new Error("database is read-only");this._set(e,t)}};Object.defineProperties(Na.prototype,pu);function yl(e){e instanceof Na||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Na);function Vb(e){e.style.height="0";const t=Math.max(e.scrollHeight,44);e.style.height=`${t}px`,e.style.overflowY=e.scrollHeight>e.offsetHeight?"auto":"hidden"}function vl(e){e.style.height="44px",e.style.overflowY="hidden"}const Qb=5e3;function Jb(e){return e?e.active?c`
|
|
3020
|
+
--num-skintones: ${dl};`}),a(()=>{o.customEmoji&&o.database&&P()}),a(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==Uo&&(o.groups=Uo):o.groups!==no&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=no)}),a(()=>{async function C(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}C()}),a(()=>{o.skinTones=Array(dl).fill().map((C,R)=>bb(o.skinToneEmoji,R))}),a(()=>{o.skinToneButtonText=o.skinTones[o.currentSkinTone]}),a(()=>{o.skinToneButtonLabel=o.i18n.skinToneLabel.replace("{skinTone}",o.i18n.skinTones[o.currentSkinTone])}),a(()=>{async function C(){const{database:R}=o,F=(await Promise.all(cb.map(U=>R.getEmojiByUnicodeOrName(U)))).filter(Boolean);o.defaultFavoriteEmojis=F}o.databaseLoaded&&C()});function P(){const{customEmoji:C,database:R}=o,F=C||lo;R.customEmoji!==F&&(R.customEmoji=F)}a(()=>{async function C(){P();const{database:R,defaultFavoriteEmojis:F,numColumns:U}=o,ee=await R.getTopFavoriteEmoji(U),J=await Ke(du([...ee,...F],he=>he.unicode||he.name).slice(0,U));o.currentFavorites=J}o.databaseLoaded&&o.defaultFavoriteEmojis&&C()});function D(C){xb(C,s,()=>{{const R=getComputedStyle(n.rootElement),F=parseInt(R.getPropertyValue("--num-columns"),10),U=R.getPropertyValue("direction")==="rtl";o.numColumns=F,o.isRtl=U}})}function W(C){Wb(C,s,R=>{for(const{target:F,isIntersecting:U}of R)F.classList.toggle("onscreen",U)})}a(()=>{async function C(){const{searchText:R,currentGroup:F,databaseLoaded:U,customEmoji:ee}=o;if(!U)o.currentEmojis=[],o.searchMode=!1;else if(R.length>=sb){const J=await bs(R);o.searchText===R&&(v(J),$(!0))}else{const{id:J}=F;if(J!==-1||ee&&ee.length){const he=await vs(J);o.currentGroup.id===J&&(v(he),$(!1))}}}C()});const K=()=>{Ti(()=>Ab(n.tabpanelElement))};a(()=>{const{currentEmojis:C,emojiVersion:R}=o,F=C.filter(U=>U.unicode).filter(U=>ul(U)&&!Wo.has(U.unicode));if(!R&&F.length)v(C),Ti(()=>H(F));else{const U=R?C:C.filter(ke);v(U),K()}});function H(C){$b(C,n.baselineEmoji,d)?K():o.currentEmojis=[...o.currentEmojis]}function ke(C){return!C.unicode||!ul(C)||Wo.get(C.unicode)}async function Ie(C){const R=o.emojiVersion||await so();return C.filter(({version:F})=>!F||F<=R)}async function Ke(C){return wb(C,o.emojiVersion||await so())}async function vs(C){const R=C===-1?o.customEmoji:await o.database.getEmojiByGroup(C);return Ke(await Ie(R))}async function bs(C){return Ke(await Ie(await o.database.getEmojiBySearchQuery(C)))}a(()=>{}),a(()=>{function C(){const{searchMode:F,currentEmojis:U}=o;if(F)return[{category:"",emojis:U}];const ee=new Map;for(const J of U){const he=J.category||"";let tt=ee.get(he);tt||(tt=[],ee.set(he,tt)),tt.push(J)}return[...ee.entries()].map(([J,he])=>({category:J,emojis:he})).sort((J,he)=>o.customCategorySorting(J.category,he.category))}const R=C();S(R)}),a(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),a(()=>{const{rawSearchText:C}=o;lu(()=>{o.searchText=(C||"").trim(),o.activeSearchItem=-1})});function ws(C){if(!o.searchMode||!o.currentEmojis.length)return;const R=F=>{Be(C),o.activeSearchItem=oo(F,o.activeSearchItem,o.currentEmojis)};switch(C.key){case"ArrowDown":return R(!1);case"ArrowUp":return R(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return Be(C),te(o.currentEmojis[o.activeSearchItem].id)}}function Qn(C){const{target:R}=C,F=R.closest(".nav-button");if(!F)return;const U=parseInt(F.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(ee=>ee.id===U)}function ks(C){const{target:R,key:F}=C,U=ee=>{ee&&(Be(C),ee.focus())};switch(F){case"ArrowLeft":return U(R.previousElementSibling);case"ArrowRight":return U(R.nextElementSibling);case"Home":return U(R.parentElement.firstElementChild);case"End":return U(R.parentElement.lastElementChild)}}async function Jn(C){const R=await o.database.getEmojiByUnicodeOrName(C),F=[...o.currentEmojis,...o.currentFavorites].find(ee=>ee.id===C),U=F.unicode&&M(F,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(C),{emoji:R,skinTone:o.currentSkinTone,...U&&{unicode:U},...F.name&&{name:F.name}}}async function te(C){const R=Jn(C);h("emoji-click-sync",R),h("emoji-click",await R)}function Yn(C){const{target:R}=C;if(!R.classList.contains("emoji"))return;Be(C);const F=R.id.substring(4);te(F)}function ne(C){o.currentSkinTone=C,o.skinTonePickerExpanded=!1,l("skintone-button"),h("skin-tone-change",{skinTone:C}),o.database.setPreferredSkinTone(C)}function Xn(C){const{target:{id:R}}=C,F=R&&R.match(/^skintone-(\d)/);if(!F)return;Be(C);const U=parseInt(F[1],10);ne(U)}function X(C){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(Be(C),Ti(()=>l("skintone-list")))}a(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function dt(C){if(!o.skinTonePickerExpanded)return;const R=async F=>{Be(C),o.activeSkinTone=F};switch(C.key){case"ArrowUp":return R(oo(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return R(oo(!1,o.activeSkinTone,o.skinTones));case"Home":return R(0);case"End":return R(o.skinTones.length-1);case"Enter":return Be(C),ne(o.activeSkinTone);case"Escape":return Be(C),o.skinTonePickerExpanded=!1,l("skintone-button")}}function dn(C){if(o.skinTonePickerExpanded&&C.key===" ")return Be(C),ne(o.activeSkinTone)}async function et(C){const{relatedTarget:R}=C;(!R||R.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function Zn(C){o.rawSearchText=C.target.value}return{$set(C){bi(o,C)},$destroy(){i.abort()}}}const Kb="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Hb="en";var qb={categoriesLabel:"Categories",emojiUnsupportedMessage:"Your browser does not support color emoji.",favoritesLabel:"Favorites",loadingMessage:"Loading…",networkErrorMessage:"Could not load emoji.",regionLabel:"Emoji picker",searchDescription:"When search results are available, press up or down to select and enter to choose.",searchLabel:"Search",searchResultsLabel:"Search results",skinToneDescription:"When expanded, press up or down to select and enter to choose.",skinToneLabel:"Choose a skin tone (currently {skinTone})",skinTonesLabel:"Skin tones",skinTones:["Default","Light","Medium-Light","Medium","Medium-Dark","Dark"],categories:{custom:"Custom","smileys-emotion":"Smileys and emoticons","people-body":"People and body","animals-nature":"Animals and nature","food-drink":"Food and drink","travel-places":"Travel and places",activities:"Activities",objects:"Objects",symbols:"Symbols",flags:"Flags"}},jb=':host{--emoji-size:1.375rem;--emoji-padding:0.5rem;--category-emoji-size:var(--emoji-size);--category-emoji-padding:var(--emoji-padding);--indicator-height:3px;--input-border-radius:0.5rem;--input-border-size:1px;--input-font-size:1rem;--input-line-height:1.5;--input-padding:0.25rem;--num-columns:8;--outline-size:2px;--border-size:1px;--border-radius:0;--skintone-border-radius:1rem;--category-font-size:1rem;display:flex;width:min-content;height:400px}:host,:host(.light){color-scheme:light;--background:#fff;--border-color:#e0e0e0;--indicator-color:#385ac1;--input-border-color:#999;--input-font-color:#111;--input-placeholder-color:#999;--outline-color:#999;--category-font-color:#111;--button-active-background:#e6e6e6;--button-hover-background:#d9d9d9}:host(.dark){color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}@media (prefers-color-scheme:dark){:host{color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}}:host([hidden]){display:none}button{margin:0;padding:0;border:0;background:0 0;box-shadow:none;-webkit-tap-highlight-color:transparent}button::-moz-focus-inner{border:0}input{padding:0;margin:0;line-height:1.15;font-family:inherit}input[type=search]{-webkit-appearance:none}:focus{outline:var(--outline-color) solid var(--outline-size);outline-offset:calc(-1*var(--outline-size))}:host([data-js-focus-visible]) :focus:not([data-focus-visible-added]){outline:0}:focus:not(:focus-visible){outline:0}.hide-focus{outline:0}*{box-sizing:border-box}.picker{contain:content;display:flex;flex-direction:column;background:var(--background);border:var(--border-size) solid var(--border-color);border-radius:var(--border-radius);width:100%;height:100%;overflow:hidden;--total-emoji-size:calc(var(--emoji-size) + (2 * var(--emoji-padding)));--total-category-emoji-size:calc(var(--category-emoji-size) + (2 * var(--category-emoji-padding)))}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.hidden{opacity:0;pointer-events:none}.abs-pos{position:absolute;left:0;top:0}.gone{display:none!important}.skintone-button-wrapper,.skintone-list{background:var(--background);z-index:3}.skintone-button-wrapper.expanded{z-index:1}.skintone-list{position:absolute;inset-inline-end:0;top:0;z-index:2;overflow:visible;border-bottom:var(--border-size) solid var(--border-color);border-radius:0 0 var(--skintone-border-radius) var(--skintone-border-radius);will-change:transform;transition:transform .2s ease-in-out;transform-origin:center 0}@media (prefers-reduced-motion:reduce){.skintone-list{transition-duration:.001s}}@supports not (inset-inline-end:0){.skintone-list{right:0}}.skintone-list.no-animate{transition:none}.tabpanel{overflow-y:auto;scrollbar-gutter:stable;-webkit-overflow-scrolling:touch;will-change:transform;min-height:0;flex:1;contain:content}.emoji-menu{display:grid;grid-template-columns:repeat(var(--num-columns),var(--total-emoji-size));justify-content:space-around;align-items:flex-start;width:100%}.emoji-menu.visibility-auto{content-visibility:auto;contain-intrinsic-size:calc(var(--num-columns)*var(--total-emoji-size)) calc(var(--num-rows)*var(--total-emoji-size))}.category{padding:var(--emoji-padding);font-size:var(--category-font-size);color:var(--category-font-color)}.emoji,button.emoji{font-size:var(--emoji-size);display:flex;align-items:center;justify-content:center;border-radius:100%;height:var(--total-emoji-size);width:var(--total-emoji-size);line-height:1;overflow:hidden;font-family:var(--emoji-font-family);cursor:pointer}@media (hover:hover) and (pointer:fine){.emoji:hover,button.emoji:hover{background:var(--button-hover-background)}}.emoji.active,.emoji:active,button.emoji.active,button.emoji:active{background:var(--button-active-background)}.onscreen .custom-emoji::after{content:"";width:var(--emoji-size);height:var(--emoji-size);background-repeat:no-repeat;background-position:center center;background-size:contain;background-image:var(--custom-emoji-background)}.nav,.nav-button{align-items:center}.nav{display:grid;justify-content:space-between;contain:content}.nav-button{display:flex;justify-content:center}.nav-emoji{font-size:var(--category-emoji-size);width:var(--total-category-emoji-size);height:var(--total-category-emoji-size)}.indicator-wrapper{display:flex;border-bottom:1px solid var(--border-color)}.indicator{width:calc(100%/var(--num-groups));height:var(--indicator-height);opacity:var(--indicator-opacity);background-color:var(--indicator-color);will-change:transform,opacity;transition:opacity .1s linear,transform .25s ease-in-out}@media (prefers-reduced-motion:reduce){.indicator{will-change:opacity;transition:opacity .1s linear}}.pad-top,input.search{background:var(--background);width:100%}.pad-top{height:var(--emoji-padding);z-index:3}.search-row{display:flex;align-items:center;position:relative;padding-inline-start:var(--emoji-padding);padding-bottom:var(--emoji-padding)}.search-wrapper{flex:1;min-width:0}input.search{padding:var(--input-padding);border-radius:var(--input-border-radius);border:var(--input-border-size) solid var(--input-border-color);color:var(--input-font-color);font-size:var(--input-font-size);line-height:var(--input-line-height)}input.search::placeholder{color:var(--input-placeholder-color)}.favorites{overflow-y:auto;scrollbar-gutter:stable;display:flex;flex-direction:row;border-top:var(--border-size) solid var(--border-color);contain:content}.message{padding:var(--emoji-padding)}';const uu=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Gb=`:host{--emoji-font-family:${cu}}`;class Na extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=jb+Gb,this.shadowRoot.appendChild(n),this._ctx={locale:Hb,dataSource:Kb,skinToneEmoji:rb,customCategorySorting:db,customEmoji:null,i18n:qb,emojiVersion:null,...t};for(const i of uu)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){yl(this),this._cmp||(this._cmp=zb(this.shadowRoot,this._ctx))}disconnectedCallback(){yl(this),es(()=>{if(!this.isConnected&&this._cmp){this._cmp.$destroy(),this._cmp=void 0;const{database:t}=this._ctx;t.close().catch(n=>console.error(n))}})}static get observedAttributes(){return["locale","data-source","skin-tone-emoji","emoji-version"]}attributeChangedCallback(t,n,i){this._set(t.replace(/-([a-z])/g,(s,o)=>o.toUpperCase()),t==="emoji-version"?parseFloat(i):i)}_set(t,n){this._ctx[t]=n,this._cmp&&this._cmp.$set({[t]:n}),["locale","dataSource"].includes(t)&&this._dbFlush()}_dbCreate(){const{locale:t,dataSource:n,database:i}=this._ctx;(!i||i.locale!==t||i.dataSource!==n)&&this._set("database",new ib({locale:t,dataSource:n}))}_dbFlush(){es(()=>this._dbCreate())}}const pu={};for(const e of uu)pu[e]={get(){return e==="database"&&this._dbCreate(),this._ctx[e]},set(t){if(e==="database")throw new Error("database is read-only");this._set(e,t)}};Object.defineProperties(Na.prototype,pu);function yl(e){e instanceof Na||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Na);function Vb(e){e.style.height="0";const t=Math.max(e.scrollHeight,44);e.style.height=`${t}px`,e.style.overflowY=e.scrollHeight>e.offsetHeight?"auto":"hidden"}function vl(e){e.style.height="44px",e.style.overflowY="hidden"}const Qb=5e3;function Jb(e){return e?e.active?c`
|
|
3031
3021
|
<div class="callout info compaction-indicator compaction-indicator--active">
|
|
3032
3022
|
${I.loader} Compacting context...
|
|
3033
3023
|
</div>
|
|
@@ -4906,7 +4896,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
4906
4896
|
<p>Connecting...</p>
|
|
4907
4897
|
</div>
|
|
4908
4898
|
</div>
|
|
4909
|
-
`;if(!e.publicChatAuthenticated)return n0({authMode:e.publicChatConfig.auth??"anonymous",authStep:e.publicChatAuthStep,connected:e.connected,client:e.client,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,accountId:e.publicChatConfig.accountId,cookieTtlDays:e.publicChatConfig.cookieTtlDays,otpChannels:e.publicChatConfig.otpChannels,verifyMethods:e.publicChatConfig.verifyMethods,onAuthenticated:$=>{var M;e.publicChatSessionKey=$,e.sessionKey=$,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const S=((M=e.publicChatConfig)==null?void 0:M.accountId)??"";e.chatMessage=zn(S,$),ae(async()=>{const{loadChatHistory:y}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:y}},void 0,import.meta.url).then(({loadChatHistory:y})=>{y(e)})},onAuthStepChange:$=>{e.publicChatAuthStep=$},requestUpdate:()=>{e.requestUpdate()}});const u=(t=e.publicChatConfig)==null?void 0:t.greeting,p=e.chatMessages,v=!e.chatLoading&&u?[{role:"assistant",content:[{type:"text",text:u}],timestamp:0},...Array.isArray(p)?p:[]]:p;return yk({connected:e.connected,sessionKey:e.sessionKey,loading:e.chatLoading,sending:e.chatSending,messages:v,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,assistantAvatarUrl:e.chatAvatarUrl??Dl(e)??null,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,canAbort:!!e.chatRunId,disabledReason:e.connected?null:"Disconnected.",error:e.lastError,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,suggestions:e.chatSuggestions,onSuggestionClick:$=>{e.chatMessage=$,e.chatSuggestions=[],e.handleSendChat()},onRefresh:()=>(e.resetToolStream(),ae(async()=>{const{loadChatHistory:$}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:$}},void 0,import.meta.url).then(({loadChatHistory:$})=>{$(e)})),onDraftChange:$=>{var M;e.chatMessage=$;const S=((M=e.publicChatConfig)==null?void 0:M.accountId)??"";wr(S,e.sessionKey,$)},requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:$=>e.chatAttachments=$,onSend:()=>e.handleSendChat(),onAbort:()=>{e.handleAbortChat()},onQueueRemove:$=>e.removeQueuedMessage($),onChatScroll:$=>e.handleChatScroll($),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()}})}if(e.connected&&e.accessState.checked){const{accessState:u}=e;if(u.hasPins&&!u.authenticated)return Sl({show:!0,isFirstTime:!1,accounts:u.accounts,error:u.error,busy:u.busy,onSubmit:(p,v)=>{v!=null&&e.handlePinSubmit(p,v)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(p,v,$)=>e.handleChangePin(p,v,$)});if(!u.hasMasterPin&&!u.authenticated&&e.setup)return Sl({show:!0,isFirstTime:!0,accounts:[],error:u.error,busy:u.busy,onSubmit:p=>e.handleSetMasterPin(p)});if(!u.hasMasterPin&&!u.authenticated&&!e.setup)return window.location.href="/setup",w}if(e.setup){const u=h0(e.channelsSnapshot),p=((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.whatsapp)??[],v=f0(e.channelsSnapshot),$=g0(e),S=async()=>{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null},M=()=>{const y=Date.now();e.tailscaleConnectProgress=0,e.tailscaleConnectMessage=mo[0][1],e.tailscaleConnectSuccess=!1,e.tailscaleError=null,Kt(),kt=setInterval(()=>{const b=(Date.now()-y)/1e3,k=Math.min(95,95*(1-Math.exp(-b/30)));e.tailscaleConnectProgress=Math.round(k);let A=mo[0][1];for(const[E,T]of mo)b>=E&&(A=T);e.tailscaleConnectMessage=A},500)};return rm({connected:e.connected,serverPlatform:((o=(s=e.hello)==null?void 0:s.server)==null?void 0:o.platform)??null,assistantName:e.assistantName,currentStep:e.setupStep,licenseKey:e.licenseKey,licenseBusy:e.licenseBusy,licenseValid:e.licenseValid,licenseMessage:e.licenseMessage,licenseTier:e.licenseTier,licenseDeviceId:e.licenseDeviceId,licenseStoredKey:e.licenseStoredKey,onLicenseKeyChange:y=>e.handleLicenseKeyChange(y),onLicenseActivate:()=>e.handleLicenseActivate(),onLicenseRemove:async()=>{await e.handleLicenseRemove(),e.licenseRemoveConfirm=!1},licenseRemoveConfirm:e.licenseRemoveConfirm,onLicenseRemoveConfirm:()=>{e.licenseRemoveConfirm=!0},onLicenseRemoveCancel:()=>{e.licenseRemoveConfirm=!1},authConnected:e.authConnected,authBusy:e.authBusy,authMessage:e.authMessage,authUrl:e.authUrl,authCodeInput:e.authCodeInput,authExpiresIn:e.authExpiresIn,authRefreshToken:e.authRefreshToken,claudeAuthModalOpen:e.claudeAuthModalOpen,authRefreshTokenInput:e.authRefreshTokenInput,authRefreshTokenBusy:e.authRefreshTokenBusy,authRefreshTokenError:e.authRefreshTokenError,onClaudeAuthModalOpen:()=>e.handleClaudeAuthModalOpen(),onClaudeAuthModalClose:()=>e.handleClaudeAuthModalClose(),onRefreshTokenInputChange:y=>{e.authRefreshTokenInput=y},onImportRefreshToken:()=>e.handleImportRefreshToken(),whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:u,whatsappAccounts:p,whatsappActiveQrAccountId:e.whatsappActiveQrAccountId,whatsappAccountSaving:e.whatsappAccountSaving,gatewayHealthy:e.gatewayHealthy,gatewayHealthLoading:e.gatewayHealthLoading,gatewayHealthMessage:e.gatewayHealthMessage,gatewayRestartBusy:e.gatewayRestartBusy,updateAvailable:e.updateAvailable,currentVersion:e.currentVersion,latestVersion:e.latestVersion,updateChecking:e.updateChecking,updateRunning:e.updateRunning,updateMessage:e.updateMessage,updateProgressSteps:e.updateProgressSteps,updateLastResult:e.updateLastResult,onUpdateCheck:()=>e.handleUpdateCheck(),onUpdateRun:()=>e.handleUpdateRun(),onUpdateDismissResult:()=>e.handleUpdateDismissResult(),uninstallConfirm:e.uninstallConfirm,uninstallBusy:e.uninstallBusy,uninstallDone:e.uninstallDone,uninstallError:e.uninstallError,uninstallConfirmText:e.uninstallConfirmText,onUninstallConfirm:()=>e.handleUninstallConfirm(),onUninstallCancel:()=>e.handleUninstallCancel(),onUninstallConfirmTextChange:y=>e.handleUninstallConfirmTextChange(y),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:y=>e.handleAuthSubmitCode(y),onAuthCodeChange:y=>e.handleAuthCodeChange(y),onWhatsAppRelink:async y=>{await e.handleWhatsAppStart(!0,y),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(y),await ee(e,!0),e.requestUpdate())},onWhatsAppUnlink:async y=>{await e.handleWhatsAppLogout(y)},onWhatsAppReset:async y=>{await e.handleWhatsAppLogout(y),await e.handleWhatsAppStart(!0,y),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(y),await ee(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await ee(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),ee(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:y=>e.handleRemoveWhatsAppAccount(y),workspaces:e.workspaces,workspacesLoading:e.workspacesLoading,workspacesError:e.workspacesError,addingWorkspace:e.addingWorkspace,newWorkspaceName:e.newWorkspaceName,newWorkspacePath:e.newWorkspacePath,workspaceSaving:e.workspaceSaving,workspaceRemoveConfirm:e.workspaceRemoveConfirm,newWorkspacePin:e.newWorkspacePin,onSetNewWorkspacePin:y=>{e.newWorkspacePin=y},onWorkspaceCreate:async(y,b)=>{const k=e.newWorkspacePin;await e.handleWorkspaceCreate(y,b),k.match(/^\d{4,6}$/)&&(await Ph(e,y,k),e.newWorkspacePin="")},onWorkspaceRemove:y=>e.handleWorkspaceRemove(y),onSetAddingWorkspace:y=>{e.addingWorkspace=y},onSetNewWorkspaceName:y=>{e.newWorkspaceName=y},onSetNewWorkspacePath:y=>{e.newWorkspacePath=y},onSetWorkspaceRemoveConfirm:y=>{e.workspaceRemoveConfirm=y},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(y,b)=>e.handleWorkspaceRename(y,b),whatsappDmPolicy:(()=>{const y=we(e),b=y==null?void 0:y.whatsappAccountId,k=b?p.find(A=>A.accountId===b):p[0];return(k==null?void 0:k.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var P;const y=we(e),b=y==null?void 0:y.whatsappAccountId,k=b?p.find(D=>D.accountId===b):p[0];if(!k)return;const E=k.dmPolicy!=null&&k.dmPolicy!=="disabled"?"disabled":"open",T=E==="open"?{dmPolicy:E,allowFrom:["*"]}:{dmPolicy:E};try{const D=await e.client.request("config.get"),W=D.config,K=(P=W==null?void 0:W.channels)==null?void 0:P.whatsapp,ke=((K==null?void 0:K.accounts)??{})[k.accountId]?{channels:{whatsapp:{accounts:{[k.accountId]:T}}}}:{channels:{whatsapp:T}};await e.client.request("config.patch",{raw:JSON.stringify(ke),baseHash:D.hash,note:`WhatsApp DM policy → ${E}`,skipRestart:!0}),await ee(e,!1)}catch(D){console.error("DM toggle failed:",D)}},whatsappGroupPolicy:(()=>{var D,W;const y=(D=e.configSnapshot)==null?void 0:D.config,b=(W=y==null?void 0:y.channels)==null?void 0:W.whatsapp,k=we(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},T=A?E[A]:void 0;return(T==null?void 0:T.groupPolicy)??(b==null?void 0:b.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var W,K;const y=(W=e.configSnapshot)==null?void 0:W.config,b=(K=y==null?void 0:y.channels)==null?void 0:K.whatsapp,k=we(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},T=A?E[A]:void 0,D=((T==null?void 0:T.groups)??(b==null?void 0:b.groups)??{})["*"];return(D==null?void 0:D.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var k;const y=we(e),b=y==null?void 0:y.whatsappAccountId;try{const A=await e.client.request("config.get"),E=A.config,T=((k=E==null?void 0:E.channels)==null?void 0:k.whatsapp)??{},P=T.accounts??{},D=b?P[b]:void 0,W=(D==null?void 0:D.groupPolicy)??T.groupPolicy??"allowlist",K=W==="disabled"||W==="allowlist",H=K?"open":"disabled",ke=K?{"*":{}}:void 0,Ie={groupPolicy:H};ke&&(Ie.groups=ke);const Ke=D?{channels:{whatsapp:{accounts:{[b]:Ie}}}}:{channels:{whatsapp:Ie}};await e.client.request("config.patch",{raw:JSON.stringify(Ke),baseHash:A.hash,note:`WhatsApp groups → ${H}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Group toggle failed:",A)}},onWhatsAppGroupMentionChange:async y=>{var A;const b=we(e),k=b==null?void 0:b.whatsappAccountId;try{const E=await e.client.request("config.get"),T=E.config,D=(((A=T==null?void 0:T.channels)==null?void 0:A.whatsapp)??{}).accounts??{},W=k?D[k]:void 0,K={"*":{requireMention:y}},H=W?{channels:{whatsapp:{accounts:{[k]:{groups:K}}}}}:{channels:{whatsapp:{groups:K}}};await e.client.request("config.patch",{raw:JSON.stringify(H),baseHash:E.hash,note:`WhatsApp group mention → ${y?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(E){console.error("Group mention change failed:",E)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:v.configured,imessageRunning:v.running,imessageConnected:v.connected,imessageLastError:v.lastError,imessageSelfChatMode:v.selfChatMode,imessageCliPath:v.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:$,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,k=(b==null?void 0:b.bindings)??[],A=we(e),E=A==null?void 0:A.agents.find(K=>K.id.endsWith("-admin")||K.id==="admin"),T=(E==null?void 0:E.id)??"admin",P=k.filter(K=>{var H;return((H=K.match)==null?void 0:H.channel)!=="imessage"}),D=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],W=[...P,...D];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:W}),baseHash:y.hash,note:"Enable iMessage (self-chat) for "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),We(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await ee(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,A=((b==null?void 0:b.bindings)??[]).filter(E=>{var T;return((T=E.match)==null?void 0:T.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:A}),baseHash:y.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),We(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,k=(b==null?void 0:b.bindings)??[],A=we(e),E=A==null?void 0:A.agents.find(W=>W.id.endsWith("-admin")||W.id==="admin"),T=(E==null?void 0:E.id)??"admin",P=k.filter(W=>{var K;return((K=W.match)==null?void 0:K.channel)!=="imessage"}),D=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:[...P,...D]}),baseHash:y.hash,note:"Reassign iMessage to "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),We(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:y=>{var b,k,A,E;if(e.infoModalOpen=y,y==="remote-access"){const T=((b=e.tailscaleStatus)==null?void 0:b.tailnetUrl)??((k=e.tailscaleStatus)!=null&&k.hostname?`https://${e.tailscaleStatus.hostname}`:null);T&&!e.remoteAccessQrDataUrl&&e.client.request("qr.generate",{url:T}).then(P=>{e.remoteAccessQrDataUrl=(P==null?void 0:P.dataUrl)??null}).catch(()=>{})}else if(y==="public-chat"){const T=((A=e.tailscaleStatus)==null?void 0:A.publicUrl)??((E=e.tailscaleStatus)==null?void 0:E.tailnetUrl)??null,P=e.selectedWorkspace??null;if(T&&P){const D=`${T}/public/chat/${encodeURIComponent(P)}`;e.publicChatQrDataUrl||e.client.request("qr.generate",{url:D}).then(W=>{e.publicChatQrDataUrl=(W==null?void 0:W.dataUrl)??null}).catch(()=>{})}}},onInfoModalClose:()=>{e.infoModalOpen=null},remoteAccessQrDataUrl:e.remoteAccessQrDataUrl??null,publicChatQrDataUrl:e.publicChatQrDataUrl??null,publicChatFullUrl:(()=>{var k,A;const y=((k=e.tailscaleStatus)==null?void 0:k.publicUrl)??((A=e.tailscaleStatus)==null?void 0:A.tailnetUrl)??null,b=e.selectedWorkspace??null;return!y||!b?null:`${y}/public/chat/${encodeURIComponent(b)}`})(),isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,apiKeySavingProvider:e.apiKeySavingProvider,onApiKeyModalOpen:()=>{e.apiKeyModalOpen=!0,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeyModalClose:()=>{e.apiKeyModalOpen=!1,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeySave:async(y,b)=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await El(e.client,y,b);const k=`${y} key saved`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}y==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async y=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Nk(e.client,y);const b=`${y} key removed`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to remove key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyDisable:async(y,b)=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Ok(e.client,y,b);const k=`${y} ${b?"disabled":"enabled"}`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:`Failed to ${b?"disable":"enable"} key`,e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},authApiKeyMode:e.authApiKeyMode,authApiKeyInput:e.authApiKeyInput,authApiKeyBusy:e.authApiKeyBusy,authApiKeyError:e.authApiKeyError,onAuthApiKeyToggle:()=>{e.authApiKeyMode=!e.authApiKeyMode,e.authApiKeyError=null},onAuthApiKeyChange:y=>{e.authApiKeyInput=y},onAuthApiKeySubmit:async()=>{const y=e.authApiKeyInput.trim();if(y){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await El(e.client,"anthropic",y),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(b){e.authApiKeyError=b instanceof Error?b.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var b;const y=e.selectedWorkspace??((b=e.workspaces[0])==null?void 0:b.name);return y?e.accessState.accounts.some(k=>k.id===y):!1})(),accountPinModalOpen:e.accountPinModalOpen,accountPinBusy:e.accountPinBusy,accountPinError:e.accountPinError,accountPinSuccess:e.accountPinSuccess,onAccountPinModalOpen:()=>{e.accountPinModalOpen=!0,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinModalClose:()=>{e.accountPinModalOpen=!1,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinSave:(y,b)=>{var A;const k=e.selectedWorkspace??((A=e.workspaces[0])==null?void 0:A.name);k&&e.handleAccountPinSave(k,y,b)},publicChatAccountId:e.selectedWorkspace??null,publicChatSettingsOpen:e.publicChatSettingsOpen,onPublicChatSettingsOpen:()=>{e.publicChatSettingsOpen=!0},onPublicChatSettingsClose:()=>{e.publicChatSettingsOpen=!1},publicChatWidgetModalOpen:e.publicChatWidgetModalOpen,onPublicChatWidgetModalOpen:()=>{e.publicChatWidgetModalOpen=!0},onPublicChatWidgetModalClose:()=>{e.publicChatWidgetModalOpen=!1},publicChatEnabled:(()=>{var k;const y=(k=e.configSnapshot)==null?void 0:k.config,b=y==null?void 0:y.publicChat;return(b==null?void 0:b.enabled)===!0})(),publicChatAuthMode:(()=>{var T,P;const y=(T=e.configSnapshot)==null?void 0:T.config,b=y==null?void 0:y.publicChat,k=e.selectedWorkspace??"",A=b==null?void 0:b.accountSettings,E=((P=A==null?void 0:A[k])==null?void 0:P.auth)??(b==null?void 0:b.auth);return E==="verified"||E==="choice"?E:"anonymous"})(),publicChatGreeting:(()=>{var E;const y=(E=e.configSnapshot)==null?void 0:E.config,b=y==null?void 0:y.publicChat,k=b==null?void 0:b.greetings,A=e.selectedWorkspace??"";return(A&&(k==null?void 0:k[A]))??""})(),publicChatGreetingBusy:e.publicChatGreetingBusy,onPublicChatGreetingToggle:async()=>{var b;if(e.publicChatGreetingBusy)return;const y=e.selectedWorkspace??"";if(y){e.publicChatGreetingBusy=!0;try{const k=await e.client.request("config.get"),A=k.config,E=(b=A==null?void 0:A.publicChat)==null?void 0:b.greetings;if(E==null?void 0:E[y]){const P={publicChat:{greetings:{[y]:null}}};await e.client.request("config.patch",{raw:JSON.stringify(P),baseHash:k.hash,note:`Public chat greeting → disabled (${y})`,skipRestart:!0})}else{const P=await e.client.request("public.greeting.generate",{accountId:y});if(P!=null&&P.ok&&P.greeting){const D=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[y]:P.greeting}}}),baseHash:D.hash,note:`Public chat greeting → enabled (${y})`,skipRestart:!0})}}e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat greeting toggle failed:",k)}finally{e.publicChatGreetingBusy=!1}}},onPublicChatGreetingSave:async y=>{const b=e.selectedWorkspace??"";if(b)try{const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[b]:y}}}),baseHash:k.hash,note:`Public chat greeting text updated (${b})`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat greeting save failed:",k)}},onPublicChatGreetingRegenerate:async()=>{if(e.publicChatGreetingBusy)return;const y=e.selectedWorkspace??"";if(y){e.publicChatGreetingBusy=!0;try{const b=await e.client.request("public.greeting.generate",{accountId:y});if(b!=null&&b.ok&&b.greeting){const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[y]:b.greeting}}}),baseHash:k.hash,note:`Public chat greeting regenerated (${y})`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}}catch(b){console.error("Public chat greeting regeneration failed:",b)}finally{e.publicChatGreetingBusy=!1}}},publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var y;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get"),k=b.config,A=((y=k==null?void 0:k.publicChat)==null?void 0:y.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!A}}),baseHash:b.hash,note:`Public chat → ${A?"disabled":"enabled"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get"),e.publicChatQrDataUrl=null}catch(b){console.error("Public chat toggle failed:",b)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async y=>{if(e.publicChatToggleBusy)return;const b=e.selectedWorkspace??"";if(b){e.publicChatToggleBusy=!0;try{const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{accountSettings:{[b]:{auth:y}}}}),baseHash:k.hash,note:`Public chat auth → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat auth mode change failed:",k)}finally{e.publicChatToggleBusy=!1}}},publicChatEmailFrom:(()=>{var k,A;const y=(k=e.configSnapshot)==null?void 0:k.config,b=(A=y==null?void 0:y.publicChat)==null?void 0:A.email;return(b==null?void 0:b.from)??""})(),publicChatEmailBusy:e.publicChatEmailBusy,publicChatVerifyMethods:(()=>{var T,P;const y=(T=e.configSnapshot)==null?void 0:T.config,b=y==null?void 0:y.publicChat,k=e.selectedWorkspace??"",A=b==null?void 0:b.accountSettings,E=((P=A==null?void 0:A[k])==null?void 0:P.verifyMethods)??(b==null?void 0:b.verifyMethods);return Array.isArray(E)?E:["whatsapp","sms"]})(),onPublicChatEmailSave:async(y,b)=>{if(e.publicChatEmailBusy)return;const k=e.selectedWorkspace??"";if(k){e.publicChatEmailBusy=!0;try{const A=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{email:{from:y||void 0},accountSettings:{[k]:{verifyMethods:b}}}}),baseHash:A.hash,note:"Update email verification settings for public chat",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Email verification save failed:",A)}finally{e.publicChatEmailBusy=!1}}},brandAccentColor:(()=>{var k;const y=e.selectedWorkspace;return y?((k=Fe()[y])==null?void 0:k.accentColor)??"":""})(),brandBackgroundColor:(()=>{var k;const y=e.selectedWorkspace;return y?((k=Fe()[y])==null?void 0:k.backgroundColor)??"":""})(),brandHasLogo:(()=>{var k;const y=e.selectedWorkspace;return y?!!((k=Fe()[y])!=null&&k.logoUrl):!1})(),agentSettingsOpen:e.agentSettingsOpen,agentSettingsAgents:(()=>{var A,E;const y=we(e);if(!y)return[];const b=(A=e.configSnapshot)==null?void 0:A.config,k=(E=b==null?void 0:b.agents)==null?void 0:E.list;return y.agents.map(T=>{var H;const P=Array.isArray(k)?k.find(ke=>ke.id===T.id):void 0,D=P==null?void 0:P.model,W=typeof D=="string"?D:(D==null?void 0:D.primary)??null,K=T.id.endsWith("-admin")||T.id==="admin";return{id:T.id,label:K?"Admin":"Public",model:(W==null?void 0:W.trim())||null,thinkingLevel:((H=P==null?void 0:P.thinkingLevel)==null?void 0:H.trim())||null}})})(),agentSettingsModelCatalog:e.chatModelCatalog??[],memoryProvider:(()=>{var k,A,E;const y=(k=e.configSnapshot)==null?void 0:k.config,b=(E=(A=y==null?void 0:y.agents)==null?void 0:A.defaults)==null?void 0:E.memorySearch;return typeof(b==null?void 0:b.provider)=="string"&&b.provider?b.provider:"local"})(),memoryFallback:(()=>{var k,A,E;const y=(k=e.configSnapshot)==null?void 0:k.config,b=(E=(A=y==null?void 0:y.agents)==null?void 0:A.defaults)==null?void 0:E.memorySearch;return typeof(b==null?void 0:b.fallback)=="string"&&b.fallback?b.fallback:"none"})(),onAgentSettingsToggle:()=>{e.agentSettingsOpen=!e.agentSettingsOpen},onAgentModelChange:async(y,b)=>{try{const k=await e.client.request("config.get"),A=k.config,E=(A==null?void 0:A.agents)??{},T=Array.isArray(E.list)?[...E.list]:[],P=T.findIndex(W=>W.id===y);if(b)P>=0?T[P]={...T[P],model:b}:T.push({id:y,model:b});else if(P>=0){const{model:W,...K}=T[P];Object.keys(K).length<=1?T.splice(P,1):T[P]=K}const D=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(D),baseHash:k.hash,note:`Agent ${y} model → ${b||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Agent model change failed:",k)}},onAgentThinkingChange:async(y,b)=>{try{const k=await e.client.request("config.get"),A=k.config,E=(A==null?void 0:A.agents)??{},T=Array.isArray(E.list)?[...E.list]:[],P=T.findIndex(K=>K.id===y),D=b==="off"?void 0:b;if(D)P>=0?T[P]={...T[P],thinkingLevel:D}:T.push({id:y,thinkingLevel:D});else if(P>=0){const{thinkingLevel:K,...H}=T[P];Object.keys(H).length<=1?T.splice(P,1):T[P]=H}const W=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(W),baseHash:k.hash,note:`Agent ${y} thinking → ${D||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Agent thinking change failed:",k)}},onMemoryProviderChange:async y=>{try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({agents:{defaults:{memorySearch:{provider:y}}}}),baseHash:b.hash,note:`Memory search provider → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Memory provider change failed:",b)}},onMemoryFallbackChange:async y=>{try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({agents:{defaults:{memorySearch:{fallback:y}}}}),baseHash:b.hash,note:`Memory search fallback → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Memory fallback change failed:",b)}},brandingBusy:e.brandingBusy,brandingExpanded:e.brandingExpanded,onBrandingToggle:()=>{e.brandingExpanded=!e.brandingExpanded},onBrandAccentColorChange:async y=>{var k;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const A=await e.client.request("config.get"),E=A.config,T=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=T.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...T,brand:{...P,accentColor:y}}}}),baseHash:A.hash,note:`Brand accent → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const D=Fe();D[b]||(D[b]={}),D[b].accentColor=y,Tn(b)}catch(A){console.error("Brand accent change failed:",A)}finally{e.brandingBusy=!1}}},onBrandBackgroundColorChange:async y=>{var k;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const A=await e.client.request("config.get"),E=A.config,T=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=T.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...T,brand:{...P,backgroundColor:y}}}}),baseHash:A.hash,note:`Brand background → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const D=Fe();D[b]||(D[b]={}),D[b].backgroundColor=y,Tn(b)}catch(A){console.error("Brand background change failed:",A)}finally{e.brandingBusy=!1}}},onBrandLogoUpload:async y=>{const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const k=await y.arrayBuffer(),A=new Uint8Array(k);let E="";for(let D=0;D<A.length;D++)E+=String.fromCharCode(A[D]);const T=btoa(E);await e.client.request("brand.uploadLogo",{workspace:b,data:T,mimeType:y.type});const P=Fe();P[b]||(P[b]={}),P[b].logoUrl=`/brand-logo/${encodeURIComponent(b)}`}catch(k){console.error("Brand logo upload failed:",k)}finally{e.brandingBusy=!1}}},onBrandLogoRemove:async()=>{const y=e.selectedWorkspace;if(!(!y||e.brandingBusy)){e.brandingBusy=!0;try{await e.client.request("brand.removeLogo",{workspace:y});const b=Fe();b[y]&&delete b[y].logoUrl}catch(b){console.error("Brand logo remove failed:",b)}finally{e.brandingBusy=!1}}},onBrandReset:async()=>{var b;const y=e.selectedWorkspace;if(!(!y||e.brandingBusy)){e.brandingBusy=!0;try{const k=await e.client.request("config.get"),A=k.config,E=((b=A==null?void 0:A.workspaces)==null?void 0:b[y])??{},{brand:T,...P}=E;await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[y]:{...P,brand:null}}}),baseHash:k.hash,note:"Brand reset to defaults",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");try{await e.client.request("brand.removeLogo",{workspace:y})}catch{}const D=Fe();delete D[y],Tn(y)}catch(k){console.error("Brand reset failed:",k)}finally{e.brandingBusy=!1}}},tailscaleStatus:e.tailscaleStatus,tailscaleBusy:e.tailscaleBusy,tailscaleAuthUrl:e.tailscaleAuthUrl,tailscaleError:e.tailscaleError,tailscaleServeEnableUrl:e.tailscaleServeEnableUrl,tailscaleFunnelEnableUrl:e.tailscaleFunnelEnableUrl,tailscaleDisableConfirm:e.tailscaleDisableConfirm,tailscaleConnectProgress:e.tailscaleConnectProgress,tailscaleConnectMessage:e.tailscaleConnectMessage,tailscaleConnectSuccess:e.tailscaleConnectSuccess,onTailscaleEnable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleAuthUrl=null,M();try{const y=await e.client.request("tailscale.enable");y.authUrl?(kt&&(clearInterval(kt),kt=null),e.tailscaleConnectProgress=100,e.tailscaleConnectMessage="Waiting for authentication...",e.tailscaleAuthUrl=y.authUrl,Mi=setInterval(async()=>{try{const b=await e.client.request("tailscale.status");e.tailscaleStatus=b,e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,b.loggedIn&&(Kt(),e.tailscaleAuthUrl=null,e.tailscaleConnectSuccess=!0,e.tailscaleConnectMessage="Connected!",setTimeout(()=>{e.tailscaleConnectSuccess=!1,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1},1500))}catch{}},3e3),Pi=setTimeout(()=>{Kt(),e.tailscaleBusy&&(e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)},3e5)):y.alreadyLoggedIn?(Kt(),e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1):(Kt(),e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)}catch(y){console.error("Tailscale enable failed:",y),Kt(),e.tailscaleError=y.message||"Failed to enable Remote Access",e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1}}},onTailscaleErrorDismiss:()=>{e.tailscaleError=null},onTailscaleServeEnable:async()=>{var y;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleServeEnableUrl=null;try{await e.client.request("tailscale.serve.enable"),await S()}catch(b){console.error("Tailscale serve enable failed:",b);const k=b;(y=k.payload)!=null&&y.enableUrl&&(e.tailscaleServeEnableUrl=k.payload.enableUrl),e.tailscaleError=k.message||"Failed to enable Remote Access"}finally{e.tailscaleBusy=!1}}},onTailscaleServeDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.serve.disable"),await S()}catch(y){console.error("Tailscale serve disable failed:",y)}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelEnable:async()=>{var y;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleFunnelEnableUrl=null;try{await e.client.request("tailscale.funnel.enable"),await S()}catch(b){console.error("Tailscale funnel enable failed:",b);const k=b;(y=k.payload)!=null&&y.enableUrl&&(e.tailscaleFunnelEnableUrl=k.payload.enableUrl),e.tailscaleError=k.message||"Failed to enable Funnel"}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.funnel.disable"),await S()}catch(y){console.error("Tailscale funnel disable failed:",y)}finally{e.tailscaleBusy=!1}}},onTailscaleDisableConfirmToggle:()=>{e.tailscaleDisableConfirm=!e.tailscaleDisableConfirm},wifiModalOpen:e.wifiModalOpen,onWifiModalToggle:()=>{e.wifiModalOpen=!e.wifiModalOpen,e.wifiModalOpen||(e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null)},wifiStatus:e.wifiStatus,wifiNetworks:e.wifiNetworks,wifiBusy:e.wifiBusy,wifiError:e.wifiError,wifiPassword:e.wifiPassword,wifiSelectedSsid:e.wifiSelectedSsid,onWifiScan:async()=>{var y;if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{const[b,k]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(e.wifiNetworks=b.networks,k.connected&&k.signal==null&&((y=b.networks)!=null&&y.length)){const A=b.networks.find(E=>E.active)||b.networks.find(E=>E.ssid===k.ssid);A&&(k.signal=A.signal)}e.wifiStatus=k}catch(b){console.error("WiFi scan failed:",b),e.wifiError=b.message||"Failed to scan networks"}finally{e.wifiBusy=!1}}},onWifiConnect:async()=>{var b;if(e.wifiBusy||!e.wifiSelectedSsid)return;const y=e.wifiSelectedSsid;e.wifiBusy=!0,e.wifiError=null;try{const k=await e.client.request("wifi.connect",{ssid:y,password:e.wifiPassword});e.wifiPassword="",e.wifiSelectedSsid=null,e.wifiNetworks=[],e.wifiStatus={available:!0,connected:k.connected,ssid:k.ssid,signal:null,ip:k.ip,savedSsid:k.ssid,autoconnect:!0},e.wifiBusy=!1;try{const[A,E]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(E.connected&&E.signal==null&&((b=A.networks)!=null&&b.length)){const T=A.networks.find(P=>P.active)||A.networks.find(P=>P.ssid===E.ssid);T&&(E.signal=T.signal)}e.wifiStatus=E}catch{}}catch(k){console.error("WiFi connect failed:",k),e.wifiError=k.message||"Failed to connect",e.wifiBusy=!1}},onWifiDisconnect:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.disconnect"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const y=await e.client.request("wifi.status");e.wifiStatus=y}catch(y){console.error("WiFi disconnect failed:",y),e.wifiError=y.message||"Failed to disconnect"}finally{e.wifiBusy=!1}}},onWifiForget:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.forget"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const y=await e.client.request("wifi.status");e.wifiStatus=y}catch(y){console.error("WiFi forget failed:",y),e.wifiError=y.message||"Failed to forget network"}finally{e.wifiBusy=!1}}},onWifiDismiss:()=>{e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null},onWifiSelectSsid:y=>{e.wifiSelectedSsid=y,e.wifiPassword="",e.wifiError=null},onWifiPasswordChange:y=>{e.wifiPassword=y},networkPort:e.networkPort,networkHostname:e.networkHostname,networkPortInput:e.networkPortInput,networkHostnameInput:e.networkHostnameInput,networkModalOpen:e.networkModalOpen,networkBusy:e.networkBusy,networkError:e.networkError,networkSuccess:e.networkSuccess,onNetworkModalToggle:()=>{e.networkModalOpen=!e.networkModalOpen,e.networkModalOpen&&(e.networkPortInput=String(e.networkPort??""),e.networkHostnameInput=e.networkHostname,e.networkError=null,e.networkSuccess=null)},onNetworkPortChange:y=>{e.networkPortInput=y,e.networkError=null,e.networkSuccess=null},onNetworkHostnameChange:y=>{e.networkHostnameInput=y,e.networkError=null,e.networkSuccess=null},onNetworkSave:async()=>{if(e.networkBusy)return;e.networkBusy=!0,e.networkError=null,e.networkSuccess=null;const y=e.networkPortInput.trim(),b=Number.parseInt(y,10),k=e.networkHostnameInput.trim();if(!y||!Number.isFinite(b)||b<1024||b>65535){e.networkError="Port must be a number between 1024 and 65535",e.networkBusy=!1;return}const A=b!==e.networkPort,E=k!==e.networkHostname;if(!A&&!E){e.networkBusy=!1;return}try{E&&await e.client.request("network.setHostname",{hostname:k});const T={};A&&(T.gateway={port:b}),E&&(T.discovery={bonjourHostname:k});const P=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify(T),baseHash:P.hash,note:[A?`Port → ${b}`:null,E?`Hostname → ${k}`:null].filter(Boolean).join(", "),restartDelayMs:2e3}),e.networkSuccess="Saved — redirecting...";const D=window.location.protocol,W=E?`${k}.local`:window.location.hostname,K=A?b:e.networkPort,H=`${D}//${W}:${K}/setup`;setTimeout(()=>{window.location.href=H},1500)}catch(T){console.error("Network save failed:",T),e.networkError=T.message||"Failed to save network settings",e.networkBusy=!1}},wsProps:r0(e)})}if(e.filesPage){const u=c0(e);return wg({connected:e.connected,wsProps:Sn(e),loading:e.filesLoading,tree:e.filesTree,root:e.filesRoot,error:e.filesError,selectedPath:e.filesSelectedPath,selectedPaths:e.filesSelectedPaths,previewContent:e.filesPreviewContent,previewLoading:e.filesPreviewLoading,previewBinary:e.filesPreviewBinary,previewSize:e.filesPreviewSize,expandedDirs:e.filesExpandedDirs,currentDir:e.filesCurrentDir,message:e.filesMessage,uploadBusy:e.filesUploadBusy,reindexBusy:e.filesReindexBusy,memoryStatus:e.filesMemoryStatus,onRefresh:()=>{rn(e,u),cs(e,u)},onReindex:()=>Lf(e,u),onSelectFile:p=>{e.filesPendingDeletePath=null,Cf(e,p,u)},onToggleSelectFile:p=>Ef(e,p,u),onToggleDir:p=>Df(e,p),onUpload:(p,v)=>Mf(e,p,v,u),onNewFolder:(p,v)=>Pf(e,p,v,u),onDownload:p=>ld(e,p,u),onBulkDownload:()=>Tf(e,u),onDelete:p=>{e.filesPendingDeletePath=null,If(e,p,u)},pendingDeletePath:e.filesPendingDeletePath,onArmDelete:p=>{e.filesPendingDeletePath=p||null},onMoveToDir:(p,v)=>_f(e,p,v,u),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:p=>{const v=e.filesSearchAgentId??u;Bf(e,p,v)},onSearchAgentChange:p=>{e.filesSearchAgentId=p},onSearchClear:()=>{Nf(e)},onSearchQueryChange:p=>{e.filesSearchQuery=p}})}if(e.browserPage)return fg({connected:e.connected,active:e.browserScreencastActive,loading:e.browserLoading,error:e.browserError,inputMode:e.browserInputMode,fullscreen:e.browserFullscreen,handoffPending:e.browserHandoffPending,handoffReason:e.browserHandoffReason,onStart:()=>_k(e),onStop:()=>Mk(e),onToggleInput:()=>Ik(e),onToggleFullscreen:()=>Rk(e),onCompleteHandoff:()=>Pk(e),onCanvasMouseDown:u=>{const v=u.target.getBoundingClientRect(),S=Bn().translateCoordinates(u.clientX-v.left,u.clientY-v.top);po(e,"mousePressed",S.x,S.y,u.button===2?"right":u.button===1?"middle":"left")},onCanvasMouseUp:u=>{const v=u.target.getBoundingClientRect(),S=Bn().translateCoordinates(u.clientX-v.left,u.clientY-v.top);po(e,"mouseReleased",S.x,S.y)},onCanvasMouseMove:u=>{const p=Bn();if(p.shouldThrottleMouseMove())return;const $=u.target.getBoundingClientRect(),S=p.translateCoordinates(u.clientX-$.left,u.clientY-$.top);po(e,"mouseMoved",S.x,S.y)},onCanvasKeyDown:u=>{let p=0;u.altKey&&(p|=1),u.ctrlKey&&(p|=2),u.metaKey&&(p|=4),u.shiftKey&&(p|=8),ho(e,"keyDown",u.key,{code:u.code,modifiers:p||void 0}),u.key.length===1&&ho(e,"char",u.key,{text:u.key})},onCanvasKeyUp:u=>{ho(e,"keyUp",u.key,{code:u.code})}});if(e.adminsPage){const u=l0(e),p=za(e);return cm({connected:e.connected,wsProps:Sn(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>ys(e,u),onAdd:v=>{Ru(e,v,u,p).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:v=>Lu(e,v,u,p),onNewPhoneChange:v=>e.handleAdminsNewPhoneChange(v)})}if(e.contactsPage){const u=d0(e);return gm({connected:e.connected,wsProps:Sn(e),loading:e.contactsLoading,saving:e.contactsSaving,records:e.contactsRecords,error:e.contactsError,searchQuery:e.contactsSearchQuery,editingId:e.contactsEditingId,showAddForm:e.contactsShowAddForm,newRecordPhone:e.contactsNewPhone,newRecordName:e.contactsNewName,deleteConfirmId:e.contactsDeleteConfirmId,addFieldForId:e.contactsAddFieldForId,addFieldKey:e.contactsAddFieldKey,addFieldValue:e.contactsAddFieldValue,onSearch:p=>e.contactsSearchQuery=p,onSearchSubmit:()=>It(e,u),onAdd:(p,v)=>Du(e,p,v,u),onDelete:p=>Bu(e,p,u),onSetField:(p,v,$)=>jo(e,p,v,$,u),onDeleteField:(p,v)=>Nu(e,p,v,u),onToggleExpand:p=>{e.contactsEditingId=e.contactsEditingId===p?null:p},onShowAddForm:()=>e.contactsShowAddForm=!0,onCancelAddForm:()=>{e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName=""},onNewRecordPhoneChange:p=>e.handleContactsNewPhoneChange(p),onNewRecordNameChange:p=>e.handleContactsNewNameChange(p),onRefresh:()=>It(e,u),onDeleteConfirmOpen:p=>e.contactsDeleteConfirmId=p,onDeleteConfirmClose:()=>e.contactsDeleteConfirmId=null,onAddFieldOpen:p=>{e.contactsAddFieldForId=p,e.contactsAddFieldKey="",e.contactsAddFieldValue=""},onAddFieldClose:()=>{e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue=""},onAddFieldKeyChange:p=>e.contactsAddFieldKey=p,onAddFieldValueChange:p=>e.contactsAddFieldValue=p,onAddFieldSubmit:()=>{const p=e.contactsAddFieldForId,v=e.contactsAddFieldKey.trim();!p||!v||(jo(e,p,v,e.contactsAddFieldValue,u),e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue="")}})}if(e.chatPage){const u=e.connected?null:"Disconnected from gateway.",p=Dl(e),v=e.chatAvatarUrl??p??null,$=(()=>{var y;const S=(y=e.configSnapshot)==null?void 0:y.config,M=S==null?void 0:S.publicChat;return(M==null?void 0:M.enabled)===!0})();return mw({connected:e.connected,wsProps:Sn(e),publicChatEnabled:$,publicChatAccountId:e.selectedWorkspace??void 0,chatPageTab:e.chatPageTab??"chat",onChatPageTabChange:S=>{if(e.chatPageTab=S,S==="whatsapp"&&!e.waLoading&&e.waConversations.length===0){const M=Ii(e);bu(M).then(()=>e.requestUpdate())}},whatsappProps:y0(e),sessionKey:e.sessionKey,onSessionKeyChange:S=>{const M=e.selectedWorkspace??"";wo(),Wn(M,e.sessionKey,e.chatMessage),e.sessionKey=S,e.chatMessage=zn(M,S),e.chatAttachments=[],e.chatStream=null,e.chatInterimText=null,e.chatSuggestions=[],e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:S,lastActiveSessionKey:S}),e.loadAssistantIdentity(),Jt(e),Eo(e)},showThinking:e.settings.chatShowThinking??!1,verboseLevel:e.chatVerboseLevel,suggestions:e.chatSuggestions,onSuggestionClick:S=>{e.chatMessage=S,e.chatSuggestions=[],e.handleSendChat()},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:v,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:u,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>{e.resetToolStream();const S=Math.max(e.chatMessages.length+10,nn);return Promise.all([Jt(e,{limit:S}),Eo(e)])},onToggleFocusMode:()=>{},onChatScroll:S=>e.handleChatScroll(S),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:S=>{e.chatMessage=S,wr(e.selectedWorkspace??"",e.sessionKey,S)},requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:S=>e.chatAttachments=S,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:S=>e.removeQueuedMessage(S),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:S=>e.handleOpenSidebar(S),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:S=>e.handleSplitRatioChange(S),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?mk({connected:e.connected,wsProps:Sn(e),activeTab:e.advancedTab,onTabChange:u=>{e.advancedTab=u,u==="cron"&&e.loadCron(),u==="skills"&&Pe(e,{clearMessages:!0}),u==="opening-hours"&&Wa(e),u==="logs"&&(e.logsSubTab==="session"?Pn(e,{reset:!0}):bt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(r=(a=e.channelsSnapshot)==null?void 0:a.channelMeta)!=null&&r.length?e.channelsSnapshot.channelMeta.map(u=>u.id):((l=e.channelsSnapshot)==null?void 0:l.channelOrder)??[],channelLabels:((d=e.channelsSnapshot)==null?void 0:d.channelLabels)??{},channelMeta:((h=e.channelsSnapshot)==null?void 0:h.channelMeta)??[],agentIds:(()=>{var p;const u=we(e);return((p=u==null?void 0:u.agents)==null?void 0:p.map(v=>v.id))??[]})(),runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1,e.cronEditJobId=null},detailJobId:e.cronDetailJobId,editJobId:e.cronEditJobId,onDetailOpen:u=>{e.cronDetailJobId=u.id,xo(e,u.id)},onDetailClose:()=>{e.cronDetailJobId=null},onEdit:u=>{e.cronForm=Ah(u),e.cronEditJobId=u.id,e.cronDetailJobId=null},onEditSave:()=>{const u=e.cronEditJobId;u&&Ch(e,u).then(()=>{e.cronEditJobId=null})},onFormChange:u=>e.cronForm={...e.cronForm,...u},onRefresh:()=>e.loadCron(),onAdd:()=>{wh(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(u,p)=>kh(e,u,p),onRun:u=>xh(e,u),onRemove:u=>{e.cronPendingDeleteId=null,Sh(e,u)},pendingDeleteId:e.cronPendingDeleteId,onArmDelete:u=>{e.cronPendingDeleteId=u||null},onLoadRuns:u=>xo(e,u),runModalJobId:e.cronRunModalJobId,runModalJobName:e.cronRunModalJobName,runResult:e.cronRunResult,onRunModalClose:()=>{e.cronRunModalJobId=null,e.cronRunModalJobName="",e.cronRunResult=null}},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,typeFilter:e.skillsTypeFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,detail:e.skillDetail,detailTab:e.skillDetailTab,addModal:e.skillAddModal,addForm:e.skillAddForm,formSource:e.skillAddFormSource,editTab:e.skillEditTab,drafts:e.skillDrafts,onFilterChange:u=>e.skillsFilter=u,onTypeFilterChange:u=>e.skillsTypeFilter=u,onRefresh:()=>Pe(e,{clearMessages:!0}),onToggle:(u,p)=>Oc(e,u,p),onEdit:(u,p)=>Nc(e,u,p),onSaveKey:u=>Fc(e,u),onInstall:(u,p,v)=>Uc(e,u,p,v),onViewDetail:u=>Wc(e,u),onDetailClose:()=>zc(e),onDetailTab:u=>Kc(e,u),onAddOpen:()=>Hc(e),onAddClose:()=>qc(e),onImportDraft:u=>jc(e,u),onInstallDraft:u=>Gc(e,u),onDeleteDraft:u=>Vc(e,u),onAddSave:()=>ua(e),onAddFormUpdate:(u,p)=>{e.skillAddForm={...e.skillAddForm,[u]:p}},onAlwaysActiveToggle:(u,p)=>Zc(e,u,p),onDelete:u=>td(e,u),onEditSkill:u=>Qc(e,u),onEditDetail:u=>Jc(e,u),onRefUpdate:(u,p)=>Yc(e,u,p),onEditTab:u=>Xc(e,u),agentFilter:e.skillsAgentFilter,onAgentFilterChange:u=>e.skillsAgentFilter=u,onAgentsChange:(u,p)=>ed(e,u,p)},logsProps:{logsSubTab:e.logsSubTab,isAdmin:e.accessState.master||!e.accessState.hasPins,onSubTabChange:u=>{e.logsSubTab=u,u==="session"?Pn(e,{reset:!0}):bt(e,{reset:!0})},sessionLogsProps:{loading:e.sessionLogsLoading,error:e.sessionLogsError,entries:e.sessionLogsEntries,agents:e.sessionLogsAgents,filterText:e.sessionLogsFilterText,typeFilters:e.sessionLogsTypeFilters,agentFilters:e.sessionLogsAgentFilters,autoFollow:e.sessionLogsAutoFollow,chipsExpanded:e.sessionLogsChipsExpanded,expandedIds:e.sessionLogsExpandedIds,onFilterTextChange:u=>e.sessionLogsFilterText=u,onTypeToggle:(u,p)=>{const v=e;v.sessionLogsTypeFilters={...v.sessionLogsTypeFilters,[u]:p}},onAgentToggle:(u,p)=>{const v=e;v.sessionLogsAgentFilters={...v.sessionLogsAgentFilters,[u]:p}},onToggleAutoFollow:u=>e.sessionLogsAutoFollow=u,onToggleChips:()=>{const u=e;u.sessionLogsChipsExpanded=!u.sessionLogsChipsExpanded},onToggleExpand:u=>{const p=e,v=new Set(p.sessionLogsExpandedIds);v.has(u)?v.delete(u):v.add(u),p.sessionLogsExpandedIds=v,p.requestUpdate()},onRefresh:()=>{Pn(e,{reset:!0})},onExport:(u,p)=>e.exportSessionLogs(u,p),onScroll:u=>e.handleSessionLogsScroll(u)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,chipsExpanded:e.logsChipsExpanded,truncated:e.logsTruncated,selectedDate:e.logsDate,availableDates:e.logsAvailableDates,onDateChange:u=>{e.logsDate=u,bt(e,{reset:!0})},onFilterTextChange:u=>e.logsFilterText=u,onLevelToggle:(u,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[u]:p}},onToggleAutoFollow:u=>e.logsAutoFollow=u,onToggleChips:()=>{const u=e;u.logsChipsExpanded=!u.logsChipsExpanded},onRefresh:()=>bt(e,{reset:!0}),onExport:(u,p)=>e.exportSessionLogs(u,p),onScroll:u=>e.handleLogsScroll(u)},openingHoursProps:{loading:e.openingHoursLoading,error:e.openingHoursError,busy:e.openingHoursBusy,form:e.openingHoursForm,onFormChange:u=>{const p=e;p.openingHoursForm={...p.openingHoursForm,...u}},onDayChange:(u,p,v)=>{const $=e,S={...$.openingHoursForm.days};S[u]={...S[u],[p]:v},$.openingHoursForm={...$.openingHoursForm,days:S}},onAddClosedDate:u=>{const p=e;p.openingHoursForm.closedDates.includes(u)||(p.openingHoursForm={...p.openingHoursForm,closedDates:[...p.openingHoursForm.closedDates,u].sort()})},onRemoveClosedDate:u=>{const p=e;p.openingHoursForm={...p.openingHoursForm,closedDates:p.openingHoursForm.closedDates.filter(v=>v!==u)}},onSave:()=>{Pu(e)}}}):(window.location.replace("/chat"),c``)}function b0(e){const t=new Date(e),n=t.toLocaleDateString("en-GB",{day:"2-digit",month:"short"}),i=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} ${i}`}function Bl(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function w0(e,t,n){return c`
|
|
4899
|
+
`;if(!e.publicChatAuthenticated)return n0({authMode:e.publicChatConfig.auth??"anonymous",authStep:e.publicChatAuthStep,connected:e.connected,client:e.client,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,accountId:e.publicChatConfig.accountId,cookieTtlDays:e.publicChatConfig.cookieTtlDays,otpChannels:e.publicChatConfig.otpChannels,verifyMethods:e.publicChatConfig.verifyMethods,onAuthenticated:$=>{var M;e.publicChatSessionKey=$,e.sessionKey=$,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const S=((M=e.publicChatConfig)==null?void 0:M.accountId)??"";e.chatMessage=zn(S,$),ae(async()=>{const{loadChatHistory:y}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:y}},void 0,import.meta.url).then(({loadChatHistory:y})=>{y(e)})},onAuthStepChange:$=>{e.publicChatAuthStep=$},requestUpdate:()=>{e.requestUpdate()}});const u=(t=e.publicChatConfig)==null?void 0:t.greeting,p=e.chatMessages,v=!e.chatLoading&&u?[{role:"assistant",content:[{type:"text",text:u}],timestamp:0},...Array.isArray(p)?p:[]]:p;return yk({connected:e.connected,sessionKey:e.sessionKey,loading:e.chatLoading,sending:e.chatSending,messages:v,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,assistantAvatarUrl:e.chatAvatarUrl??Dl(e)??null,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,canAbort:!!e.chatRunId,disabledReason:e.connected?null:"Disconnected.",error:e.lastError,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,suggestions:e.chatSuggestions,onSuggestionClick:$=>{e.chatMessage=$,e.chatSuggestions=[],e.handleSendChat()},onRefresh:()=>(e.resetToolStream(),ae(async()=>{const{loadChatHistory:$}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:$}},void 0,import.meta.url).then(({loadChatHistory:$})=>{$(e)})),onDraftChange:$=>{var M;e.chatMessage=$;const S=((M=e.publicChatConfig)==null?void 0:M.accountId)??"";wr(S,e.sessionKey,$)},requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:$=>e.chatAttachments=$,onSend:()=>e.handleSendChat(),onAbort:()=>{e.handleAbortChat()},onQueueRemove:$=>e.removeQueuedMessage($),onChatScroll:$=>e.handleChatScroll($),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()}})}if(e.connected&&e.accessState.checked){const{accessState:u}=e;if(u.hasPins&&!u.authenticated)return Sl({show:!0,isFirstTime:!1,accounts:u.accounts,error:u.error,busy:u.busy,onSubmit:(p,v)=>{v!=null&&e.handlePinSubmit(p,v)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(p,v,$)=>e.handleChangePin(p,v,$)});if(!u.hasMasterPin&&!u.authenticated&&e.setup)return Sl({show:!0,isFirstTime:!0,accounts:[],error:u.error,busy:u.busy,onSubmit:p=>e.handleSetMasterPin(p)});if(!u.hasMasterPin&&!u.authenticated&&!e.setup)return window.location.href="/setup",w}if(e.setup){const u=h0(e.channelsSnapshot),p=((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.whatsapp)??[],v=f0(e.channelsSnapshot),$=g0(e),S=async()=>{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null},M=()=>{const y=Date.now();e.tailscaleConnectProgress=0,e.tailscaleConnectMessage=mo[0][1],e.tailscaleConnectSuccess=!1,e.tailscaleError=null,Kt(),kt=setInterval(()=>{const b=(Date.now()-y)/1e3,k=Math.min(95,95*(1-Math.exp(-b/30)));e.tailscaleConnectProgress=Math.round(k);let A=mo[0][1];for(const[E,T]of mo)b>=E&&(A=T);e.tailscaleConnectMessage=A},500)};return rm({connected:e.connected,serverPlatform:((o=(s=e.hello)==null?void 0:s.server)==null?void 0:o.platform)??null,assistantName:e.assistantName,currentStep:e.setupStep,licenseKey:e.licenseKey,licenseBusy:e.licenseBusy,licenseValid:e.licenseValid,licenseMessage:e.licenseMessage,licenseTier:e.licenseTier,licenseDeviceId:e.licenseDeviceId,licenseStoredKey:e.licenseStoredKey,onLicenseKeyChange:y=>e.handleLicenseKeyChange(y),onLicenseActivate:()=>e.handleLicenseActivate(),onLicenseRemove:async()=>{await e.handleLicenseRemove(),e.licenseRemoveConfirm=!1},licenseRemoveConfirm:e.licenseRemoveConfirm,onLicenseRemoveConfirm:()=>{e.licenseRemoveConfirm=!0},onLicenseRemoveCancel:()=>{e.licenseRemoveConfirm=!1},authConnected:e.authConnected,authBusy:e.authBusy,authMessage:e.authMessage,authUrl:e.authUrl,authCodeInput:e.authCodeInput,authExpiresIn:e.authExpiresIn,authRefreshToken:e.authRefreshToken,claudeAuthModalOpen:e.claudeAuthModalOpen,authRefreshTokenInput:e.authRefreshTokenInput,authRefreshTokenBusy:e.authRefreshTokenBusy,authRefreshTokenError:e.authRefreshTokenError,onClaudeAuthModalOpen:()=>e.handleClaudeAuthModalOpen(),onClaudeAuthModalClose:()=>e.handleClaudeAuthModalClose(),onRefreshTokenInputChange:y=>{e.authRefreshTokenInput=y},onImportRefreshToken:()=>e.handleImportRefreshToken(),whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:u,whatsappAccounts:p,whatsappActiveQrAccountId:e.whatsappActiveQrAccountId,whatsappAccountSaving:e.whatsappAccountSaving,gatewayHealthy:e.gatewayHealthy,gatewayHealthLoading:e.gatewayHealthLoading,gatewayHealthMessage:e.gatewayHealthMessage,gatewayRestartBusy:e.gatewayRestartBusy,updateAvailable:e.updateAvailable,currentVersion:e.currentVersion,latestVersion:e.latestVersion,updateChecking:e.updateChecking,updateRunning:e.updateRunning,updateMessage:e.updateMessage,updateProgressSteps:e.updateProgressSteps,updateLastResult:e.updateLastResult,onUpdateCheck:()=>e.handleUpdateCheck(),onUpdateRun:()=>e.handleUpdateRun(),onUpdateDismissResult:()=>e.handleUpdateDismissResult(),uninstallConfirm:e.uninstallConfirm,uninstallBusy:e.uninstallBusy,uninstallDone:e.uninstallDone,uninstallError:e.uninstallError,uninstallConfirmText:e.uninstallConfirmText,onUninstallConfirm:()=>e.handleUninstallConfirm(),onUninstallCancel:()=>e.handleUninstallCancel(),onUninstallConfirmTextChange:y=>e.handleUninstallConfirmTextChange(y),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:y=>e.handleAuthSubmitCode(y),onAuthCodeChange:y=>e.handleAuthCodeChange(y),onWhatsAppRelink:async y=>{await e.handleWhatsAppStart(!0,y),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(y),await Z(e,!0),e.requestUpdate())},onWhatsAppUnlink:async y=>{await e.handleWhatsAppLogout(y)},onWhatsAppReset:async y=>{await e.handleWhatsAppLogout(y),await e.handleWhatsAppStart(!0,y),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(y),await Z(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await Z(e,!0),await e.handleGatewayHealthCheck()},onRefreshGatewayStatus:()=>e.handleGatewayHealthCheck(),onRefreshWhatsAppStatus:()=>Z(e,!0),onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),Z(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:y=>e.handleRemoveWhatsAppAccount(y),workspaces:e.workspaces,workspacesLoading:e.workspacesLoading,workspacesError:e.workspacesError,addingWorkspace:e.addingWorkspace,newWorkspaceName:e.newWorkspaceName,newWorkspacePath:e.newWorkspacePath,workspaceSaving:e.workspaceSaving,workspaceRemoveConfirm:e.workspaceRemoveConfirm,newWorkspacePin:e.newWorkspacePin,onSetNewWorkspacePin:y=>{e.newWorkspacePin=y},onWorkspaceCreate:async(y,b)=>{const k=e.newWorkspacePin;await e.handleWorkspaceCreate(y,b),k.match(/^\d{4,6}$/)&&(await Ph(e,y,k),e.newWorkspacePin="")},onWorkspaceRemove:y=>e.handleWorkspaceRemove(y),onSetAddingWorkspace:y=>{e.addingWorkspace=y},onSetNewWorkspaceName:y=>{e.newWorkspaceName=y},onSetNewWorkspacePath:y=>{e.newWorkspacePath=y},onSetWorkspaceRemoveConfirm:y=>{e.workspaceRemoveConfirm=y},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(y,b)=>e.handleWorkspaceRename(y,b),whatsappDmPolicy:(()=>{const y=we(e),b=y==null?void 0:y.whatsappAccountId,k=b?p.find(A=>A.accountId===b):p[0];return(k==null?void 0:k.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var P;const y=we(e),b=y==null?void 0:y.whatsappAccountId,k=b?p.find(D=>D.accountId===b):p[0];if(!k)return;const E=k.dmPolicy!=null&&k.dmPolicy!=="disabled"?"disabled":"open",T=E==="open"?{dmPolicy:E,allowFrom:["*"]}:{dmPolicy:E};try{const D=await e.client.request("config.get"),W=D.config,K=(P=W==null?void 0:W.channels)==null?void 0:P.whatsapp,ke=((K==null?void 0:K.accounts)??{})[k.accountId]?{channels:{whatsapp:{accounts:{[k.accountId]:T}}}}:{channels:{whatsapp:T}};await e.client.request("config.patch",{raw:JSON.stringify(ke),baseHash:D.hash,note:`WhatsApp DM policy → ${E}`,skipRestart:!0}),await Z(e,!1)}catch(D){console.error("DM toggle failed:",D)}},whatsappGroupPolicy:(()=>{var D,W;const y=(D=e.configSnapshot)==null?void 0:D.config,b=(W=y==null?void 0:y.channels)==null?void 0:W.whatsapp,k=we(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},T=A?E[A]:void 0;return(T==null?void 0:T.groupPolicy)??(b==null?void 0:b.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var W,K;const y=(W=e.configSnapshot)==null?void 0:W.config,b=(K=y==null?void 0:y.channels)==null?void 0:K.whatsapp,k=we(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},T=A?E[A]:void 0,D=((T==null?void 0:T.groups)??(b==null?void 0:b.groups)??{})["*"];return(D==null?void 0:D.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var k;const y=we(e),b=y==null?void 0:y.whatsappAccountId;try{const A=await e.client.request("config.get"),E=A.config,T=((k=E==null?void 0:E.channels)==null?void 0:k.whatsapp)??{},P=T.accounts??{},D=b?P[b]:void 0,W=(D==null?void 0:D.groupPolicy)??T.groupPolicy??"allowlist",K=W==="disabled"||W==="allowlist",H=K?"open":"disabled",ke=K?{"*":{}}:void 0,Ie={groupPolicy:H};ke&&(Ie.groups=ke);const Ke=D?{channels:{whatsapp:{accounts:{[b]:Ie}}}}:{channels:{whatsapp:Ie}};await e.client.request("config.patch",{raw:JSON.stringify(Ke),baseHash:A.hash,note:`WhatsApp groups → ${H}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Group toggle failed:",A)}},onWhatsAppGroupMentionChange:async y=>{var A;const b=we(e),k=b==null?void 0:b.whatsappAccountId;try{const E=await e.client.request("config.get"),T=E.config,D=(((A=T==null?void 0:T.channels)==null?void 0:A.whatsapp)??{}).accounts??{},W=k?D[k]:void 0,K={"*":{requireMention:y}},H=W?{channels:{whatsapp:{accounts:{[k]:{groups:K}}}}}:{channels:{whatsapp:{groups:K}}};await e.client.request("config.patch",{raw:JSON.stringify(H),baseHash:E.hash,note:`WhatsApp group mention → ${y?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(E){console.error("Group mention change failed:",E)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:v.configured,imessageRunning:v.running,imessageConnected:v.connected,imessageLastError:v.lastError,imessageSelfChatMode:v.selfChatMode,imessageCliPath:v.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:$,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,k=(b==null?void 0:b.bindings)??[],A=we(e),E=A==null?void 0:A.agents.find(K=>K.id.endsWith("-admin")||K.id==="admin"),T=(E==null?void 0:E.id)??"admin",P=k.filter(K=>{var H;return((H=K.match)==null?void 0:H.channel)!=="imessage"}),D=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],W=[...P,...D];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:W}),baseHash:y.hash,note:"Enable iMessage (self-chat) for "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Z(e,!0),We(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await Z(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,A=((b==null?void 0:b.bindings)??[]).filter(E=>{var T;return((T=E.match)==null?void 0:T.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:A}),baseHash:y.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Z(e,!0),We(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,k=(b==null?void 0:b.bindings)??[],A=we(e),E=A==null?void 0:A.agents.find(W=>W.id.endsWith("-admin")||W.id==="admin"),T=(E==null?void 0:E.id)??"admin",P=k.filter(W=>{var K;return((K=W.match)==null?void 0:K.channel)!=="imessage"}),D=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:[...P,...D]}),baseHash:y.hash,note:"Reassign iMessage to "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Z(e,!0),We(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:y=>{var b,k,A,E;if(e.infoModalOpen=y,y==="remote-access"){const T=((b=e.tailscaleStatus)==null?void 0:b.tailnetUrl)??((k=e.tailscaleStatus)!=null&&k.hostname?`https://${e.tailscaleStatus.hostname}`:null);T&&!e.remoteAccessQrDataUrl&&e.client.request("qr.generate",{url:T}).then(P=>{e.remoteAccessQrDataUrl=(P==null?void 0:P.dataUrl)??null}).catch(()=>{})}else if(y==="public-chat"){const T=((A=e.tailscaleStatus)==null?void 0:A.publicUrl)??((E=e.tailscaleStatus)==null?void 0:E.tailnetUrl)??null,P=e.selectedWorkspace??null;if(T&&P){const D=`${T}/public/chat/${encodeURIComponent(P)}`;e.publicChatQrDataUrl||e.client.request("qr.generate",{url:D}).then(W=>{e.publicChatQrDataUrl=(W==null?void 0:W.dataUrl)??null}).catch(()=>{})}}},onInfoModalClose:()=>{e.infoModalOpen=null},remoteAccessQrDataUrl:e.remoteAccessQrDataUrl??null,publicChatQrDataUrl:e.publicChatQrDataUrl??null,publicChatFullUrl:(()=>{var k,A;const y=((k=e.tailscaleStatus)==null?void 0:k.publicUrl)??((A=e.tailscaleStatus)==null?void 0:A.tailnetUrl)??null,b=e.selectedWorkspace??null;return!y||!b?null:`${y}/public/chat/${encodeURIComponent(b)}`})(),isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,apiKeySavingProvider:e.apiKeySavingProvider,onApiKeyModalOpen:()=>{e.apiKeyModalOpen=!0,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeyModalClose:()=>{e.apiKeyModalOpen=!1,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeySave:async(y,b)=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await El(e.client,y,b);const k=`${y} key saved`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}y==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async y=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Nk(e.client,y);const b=`${y} key removed`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to remove key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyDisable:async(y,b)=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Ok(e.client,y,b);const k=`${y} ${b?"disabled":"enabled"}`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:`Failed to ${b?"disable":"enable"} key`,e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},authApiKeyMode:e.authApiKeyMode,authApiKeyInput:e.authApiKeyInput,authApiKeyBusy:e.authApiKeyBusy,authApiKeyError:e.authApiKeyError,onAuthApiKeyToggle:()=>{e.authApiKeyMode=!e.authApiKeyMode,e.authApiKeyError=null},onAuthApiKeyChange:y=>{e.authApiKeyInput=y},onAuthApiKeySubmit:async()=>{const y=e.authApiKeyInput.trim();if(y){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await El(e.client,"anthropic",y),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(b){e.authApiKeyError=b instanceof Error?b.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var b;const y=e.selectedWorkspace??((b=e.workspaces[0])==null?void 0:b.name);return y?e.accessState.accounts.some(k=>k.id===y):!1})(),accountPinModalOpen:e.accountPinModalOpen,accountPinBusy:e.accountPinBusy,accountPinError:e.accountPinError,accountPinSuccess:e.accountPinSuccess,onAccountPinModalOpen:()=>{e.accountPinModalOpen=!0,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinModalClose:()=>{e.accountPinModalOpen=!1,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinSave:(y,b)=>{var A;const k=e.selectedWorkspace??((A=e.workspaces[0])==null?void 0:A.name);k&&e.handleAccountPinSave(k,y,b)},publicChatAccountId:e.selectedWorkspace??null,publicChatSettingsOpen:e.publicChatSettingsOpen,onPublicChatSettingsOpen:()=>{e.publicChatSettingsOpen=!0},onPublicChatSettingsClose:()=>{e.publicChatSettingsOpen=!1},publicChatWidgetModalOpen:e.publicChatWidgetModalOpen,onPublicChatWidgetModalOpen:()=>{e.publicChatWidgetModalOpen=!0},onPublicChatWidgetModalClose:()=>{e.publicChatWidgetModalOpen=!1},publicChatEnabled:(()=>{var k;const y=(k=e.configSnapshot)==null?void 0:k.config,b=y==null?void 0:y.publicChat;return(b==null?void 0:b.enabled)===!0})(),publicChatAuthMode:(()=>{var T,P;const y=(T=e.configSnapshot)==null?void 0:T.config,b=y==null?void 0:y.publicChat,k=e.selectedWorkspace??"",A=b==null?void 0:b.accountSettings,E=((P=A==null?void 0:A[k])==null?void 0:P.auth)??(b==null?void 0:b.auth);return E==="verified"||E==="choice"?E:"anonymous"})(),publicChatGreeting:(()=>{var E;const y=(E=e.configSnapshot)==null?void 0:E.config,b=y==null?void 0:y.publicChat,k=b==null?void 0:b.greetings,A=e.selectedWorkspace??"";return(A&&(k==null?void 0:k[A]))??""})(),publicChatGreetingBusy:e.publicChatGreetingBusy,onPublicChatGreetingToggle:async()=>{var b;if(e.publicChatGreetingBusy)return;const y=e.selectedWorkspace??"";if(y){e.publicChatGreetingBusy=!0;try{const k=await e.client.request("config.get"),A=k.config,E=(b=A==null?void 0:A.publicChat)==null?void 0:b.greetings;if(E==null?void 0:E[y]){const P={publicChat:{greetings:{[y]:null}}};await e.client.request("config.patch",{raw:JSON.stringify(P),baseHash:k.hash,note:`Public chat greeting → disabled (${y})`,skipRestart:!0})}else{const P=await e.client.request("public.greeting.generate",{accountId:y});if(P!=null&&P.ok&&P.greeting){const D=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[y]:P.greeting}}}),baseHash:D.hash,note:`Public chat greeting → enabled (${y})`,skipRestart:!0})}}e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat greeting toggle failed:",k)}finally{e.publicChatGreetingBusy=!1}}},onPublicChatGreetingSave:async y=>{const b=e.selectedWorkspace??"";if(b)try{const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[b]:y}}}),baseHash:k.hash,note:`Public chat greeting text updated (${b})`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat greeting save failed:",k)}},onPublicChatGreetingRegenerate:async()=>{if(e.publicChatGreetingBusy)return;const y=e.selectedWorkspace??"";if(y){e.publicChatGreetingBusy=!0;try{const b=await e.client.request("public.greeting.generate",{accountId:y});if(b!=null&&b.ok&&b.greeting){const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[y]:b.greeting}}}),baseHash:k.hash,note:`Public chat greeting regenerated (${y})`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}}catch(b){console.error("Public chat greeting regeneration failed:",b)}finally{e.publicChatGreetingBusy=!1}}},publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var y;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get"),k=b.config,A=((y=k==null?void 0:k.publicChat)==null?void 0:y.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!A}}),baseHash:b.hash,note:`Public chat → ${A?"disabled":"enabled"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get"),e.publicChatQrDataUrl=null}catch(b){console.error("Public chat toggle failed:",b)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async y=>{if(e.publicChatToggleBusy)return;const b=e.selectedWorkspace??"";if(b){e.publicChatToggleBusy=!0;try{const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{accountSettings:{[b]:{auth:y}}}}),baseHash:k.hash,note:`Public chat auth → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat auth mode change failed:",k)}finally{e.publicChatToggleBusy=!1}}},publicChatEmailFrom:(()=>{var k,A;const y=(k=e.configSnapshot)==null?void 0:k.config,b=(A=y==null?void 0:y.publicChat)==null?void 0:A.email;return(b==null?void 0:b.from)??""})(),publicChatEmailBusy:e.publicChatEmailBusy,publicChatVerifyMethods:(()=>{var T,P;const y=(T=e.configSnapshot)==null?void 0:T.config,b=y==null?void 0:y.publicChat,k=e.selectedWorkspace??"",A=b==null?void 0:b.accountSettings,E=((P=A==null?void 0:A[k])==null?void 0:P.verifyMethods)??(b==null?void 0:b.verifyMethods);return Array.isArray(E)?E:["whatsapp","sms"]})(),onPublicChatEmailSave:async(y,b)=>{if(e.publicChatEmailBusy)return;const k=e.selectedWorkspace??"";if(k){e.publicChatEmailBusy=!0;try{const A=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{email:{from:y||void 0},accountSettings:{[k]:{verifyMethods:b}}}}),baseHash:A.hash,note:"Update email verification settings for public chat",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Email verification save failed:",A)}finally{e.publicChatEmailBusy=!1}}},brandAccentColor:(()=>{var k;const y=e.selectedWorkspace;return y?((k=Fe()[y])==null?void 0:k.accentColor)??"":""})(),brandBackgroundColor:(()=>{var k;const y=e.selectedWorkspace;return y?((k=Fe()[y])==null?void 0:k.backgroundColor)??"":""})(),brandHasLogo:(()=>{var k;const y=e.selectedWorkspace;return y?!!((k=Fe()[y])!=null&&k.logoUrl):!1})(),agentSettingsOpen:e.agentSettingsOpen,agentSettingsAgents:(()=>{var A,E;const y=we(e);if(!y)return[];const b=(A=e.configSnapshot)==null?void 0:A.config,k=(E=b==null?void 0:b.agents)==null?void 0:E.list;return y.agents.map(T=>{var H;const P=Array.isArray(k)?k.find(ke=>ke.id===T.id):void 0,D=P==null?void 0:P.model,W=typeof D=="string"?D:(D==null?void 0:D.primary)??null,K=T.id.endsWith("-admin")||T.id==="admin";return{id:T.id,label:K?"Admin":"Public",model:(W==null?void 0:W.trim())||null,thinkingLevel:((H=P==null?void 0:P.thinkingLevel)==null?void 0:H.trim())||null}})})(),agentSettingsModelCatalog:e.chatModelCatalog??[],memoryProvider:(()=>{var k,A,E;const y=(k=e.configSnapshot)==null?void 0:k.config,b=(E=(A=y==null?void 0:y.agents)==null?void 0:A.defaults)==null?void 0:E.memorySearch;return typeof(b==null?void 0:b.provider)=="string"&&b.provider?b.provider:"local"})(),memoryFallback:(()=>{var k,A,E;const y=(k=e.configSnapshot)==null?void 0:k.config,b=(E=(A=y==null?void 0:y.agents)==null?void 0:A.defaults)==null?void 0:E.memorySearch;return typeof(b==null?void 0:b.fallback)=="string"&&b.fallback?b.fallback:"none"})(),onAgentSettingsToggle:()=>{e.agentSettingsOpen=!e.agentSettingsOpen},onAgentModelChange:async(y,b)=>{try{const k=await e.client.request("config.get"),A=k.config,E=(A==null?void 0:A.agents)??{},T=Array.isArray(E.list)?[...E.list]:[],P=T.findIndex(W=>W.id===y);if(b)P>=0?T[P]={...T[P],model:b}:T.push({id:y,model:b});else if(P>=0){const{model:W,...K}=T[P];Object.keys(K).length<=1?T.splice(P,1):T[P]=K}const D=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(D),baseHash:k.hash,note:`Agent ${y} model → ${b||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Agent model change failed:",k)}},onAgentThinkingChange:async(y,b)=>{try{const k=await e.client.request("config.get"),A=k.config,E=(A==null?void 0:A.agents)??{},T=Array.isArray(E.list)?[...E.list]:[],P=T.findIndex(K=>K.id===y),D=b==="off"?void 0:b;if(D)P>=0?T[P]={...T[P],thinkingLevel:D}:T.push({id:y,thinkingLevel:D});else if(P>=0){const{thinkingLevel:K,...H}=T[P];Object.keys(H).length<=1?T.splice(P,1):T[P]=H}const W=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(W),baseHash:k.hash,note:`Agent ${y} thinking → ${D||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Agent thinking change failed:",k)}},onMemoryProviderChange:async y=>{try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({agents:{defaults:{memorySearch:{provider:y}}}}),baseHash:b.hash,note:`Memory search provider → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Memory provider change failed:",b)}},onMemoryFallbackChange:async y=>{try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({agents:{defaults:{memorySearch:{fallback:y}}}}),baseHash:b.hash,note:`Memory search fallback → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Memory fallback change failed:",b)}},brandingBusy:e.brandingBusy,brandingExpanded:e.brandingExpanded,onBrandingToggle:()=>{e.brandingExpanded=!e.brandingExpanded},onBrandAccentColorChange:async y=>{var k;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const A=await e.client.request("config.get"),E=A.config,T=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=T.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...T,brand:{...P,accentColor:y}}}}),baseHash:A.hash,note:`Brand accent → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const D=Fe();D[b]||(D[b]={}),D[b].accentColor=y,Tn(b)}catch(A){console.error("Brand accent change failed:",A)}finally{e.brandingBusy=!1}}},onBrandBackgroundColorChange:async y=>{var k;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const A=await e.client.request("config.get"),E=A.config,T=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=T.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...T,brand:{...P,backgroundColor:y}}}}),baseHash:A.hash,note:`Brand background → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const D=Fe();D[b]||(D[b]={}),D[b].backgroundColor=y,Tn(b)}catch(A){console.error("Brand background change failed:",A)}finally{e.brandingBusy=!1}}},onBrandLogoUpload:async y=>{const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const k=await y.arrayBuffer(),A=new Uint8Array(k);let E="";for(let D=0;D<A.length;D++)E+=String.fromCharCode(A[D]);const T=btoa(E);await e.client.request("brand.uploadLogo",{workspace:b,data:T,mimeType:y.type});const P=Fe();P[b]||(P[b]={}),P[b].logoUrl=`/brand-logo/${encodeURIComponent(b)}`}catch(k){console.error("Brand logo upload failed:",k)}finally{e.brandingBusy=!1}}},onBrandLogoRemove:async()=>{const y=e.selectedWorkspace;if(!(!y||e.brandingBusy)){e.brandingBusy=!0;try{await e.client.request("brand.removeLogo",{workspace:y});const b=Fe();b[y]&&delete b[y].logoUrl}catch(b){console.error("Brand logo remove failed:",b)}finally{e.brandingBusy=!1}}},onBrandReset:async()=>{var b;const y=e.selectedWorkspace;if(!(!y||e.brandingBusy)){e.brandingBusy=!0;try{const k=await e.client.request("config.get"),A=k.config,E=((b=A==null?void 0:A.workspaces)==null?void 0:b[y])??{},{brand:T,...P}=E;await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[y]:{...P,brand:null}}}),baseHash:k.hash,note:"Brand reset to defaults",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");try{await e.client.request("brand.removeLogo",{workspace:y})}catch{}const D=Fe();delete D[y],Tn(y)}catch(k){console.error("Brand reset failed:",k)}finally{e.brandingBusy=!1}}},tailscaleStatus:e.tailscaleStatus,tailscaleBusy:e.tailscaleBusy,tailscaleAuthUrl:e.tailscaleAuthUrl,tailscaleError:e.tailscaleError,tailscaleServeEnableUrl:e.tailscaleServeEnableUrl,tailscaleFunnelEnableUrl:e.tailscaleFunnelEnableUrl,tailscaleDisableConfirm:e.tailscaleDisableConfirm,tailscaleConnectProgress:e.tailscaleConnectProgress,tailscaleConnectMessage:e.tailscaleConnectMessage,tailscaleConnectSuccess:e.tailscaleConnectSuccess,onTailscaleEnable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleAuthUrl=null,M();try{const y=await e.client.request("tailscale.enable");y.authUrl?(kt&&(clearInterval(kt),kt=null),e.tailscaleConnectProgress=100,e.tailscaleConnectMessage="Waiting for authentication...",e.tailscaleAuthUrl=y.authUrl,Mi=setInterval(async()=>{try{const b=await e.client.request("tailscale.status");e.tailscaleStatus=b,e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,b.loggedIn&&(Kt(),e.tailscaleAuthUrl=null,e.tailscaleConnectSuccess=!0,e.tailscaleConnectMessage="Connected!",setTimeout(()=>{e.tailscaleConnectSuccess=!1,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1},1500))}catch{}},3e3),Pi=setTimeout(()=>{Kt(),e.tailscaleBusy&&(e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)},3e5)):y.alreadyLoggedIn?(Kt(),e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1):(Kt(),e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)}catch(y){console.error("Tailscale enable failed:",y),Kt(),e.tailscaleError=y.message||"Failed to enable Remote Access",e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1}}},onTailscaleErrorDismiss:()=>{e.tailscaleError=null},onTailscaleServeEnable:async()=>{var y;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleServeEnableUrl=null;try{await e.client.request("tailscale.serve.enable"),await S()}catch(b){console.error("Tailscale serve enable failed:",b);const k=b;(y=k.payload)!=null&&y.enableUrl&&(e.tailscaleServeEnableUrl=k.payload.enableUrl),e.tailscaleError=k.message||"Failed to enable Remote Access"}finally{e.tailscaleBusy=!1}}},onTailscaleServeDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.serve.disable"),await S()}catch(y){console.error("Tailscale serve disable failed:",y)}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelEnable:async()=>{var y;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleFunnelEnableUrl=null;try{await e.client.request("tailscale.funnel.enable"),await S()}catch(b){console.error("Tailscale funnel enable failed:",b);const k=b;(y=k.payload)!=null&&y.enableUrl&&(e.tailscaleFunnelEnableUrl=k.payload.enableUrl),e.tailscaleError=k.message||"Failed to enable Funnel"}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.funnel.disable"),await S()}catch(y){console.error("Tailscale funnel disable failed:",y)}finally{e.tailscaleBusy=!1}}},onTailscaleDisableConfirmToggle:()=>{e.tailscaleDisableConfirm=!e.tailscaleDisableConfirm},wifiModalOpen:e.wifiModalOpen,onWifiModalToggle:()=>{e.wifiModalOpen=!e.wifiModalOpen,e.wifiModalOpen||(e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null)},wifiStatus:e.wifiStatus,wifiNetworks:e.wifiNetworks,wifiBusy:e.wifiBusy,wifiError:e.wifiError,wifiPassword:e.wifiPassword,wifiSelectedSsid:e.wifiSelectedSsid,onWifiScan:async()=>{var y;if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{const[b,k]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(e.wifiNetworks=b.networks,k.connected&&k.signal==null&&((y=b.networks)!=null&&y.length)){const A=b.networks.find(E=>E.active)||b.networks.find(E=>E.ssid===k.ssid);A&&(k.signal=A.signal)}e.wifiStatus=k}catch(b){console.error("WiFi scan failed:",b),e.wifiError=b.message||"Failed to scan networks"}finally{e.wifiBusy=!1}}},onWifiConnect:async()=>{var b;if(e.wifiBusy||!e.wifiSelectedSsid)return;const y=e.wifiSelectedSsid;e.wifiBusy=!0,e.wifiError=null;try{const k=await e.client.request("wifi.connect",{ssid:y,password:e.wifiPassword});e.wifiPassword="",e.wifiSelectedSsid=null,e.wifiNetworks=[],e.wifiStatus={available:!0,connected:k.connected,ssid:k.ssid,signal:null,ip:k.ip,savedSsid:k.ssid,autoconnect:!0},e.wifiBusy=!1;try{const[A,E]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(E.connected&&E.signal==null&&((b=A.networks)!=null&&b.length)){const T=A.networks.find(P=>P.active)||A.networks.find(P=>P.ssid===E.ssid);T&&(E.signal=T.signal)}e.wifiStatus=E}catch{}}catch(k){console.error("WiFi connect failed:",k),e.wifiError=k.message||"Failed to connect",e.wifiBusy=!1}},onWifiDisconnect:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.disconnect"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const y=await e.client.request("wifi.status");e.wifiStatus=y}catch(y){console.error("WiFi disconnect failed:",y),e.wifiError=y.message||"Failed to disconnect"}finally{e.wifiBusy=!1}}},onWifiForget:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.forget"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const y=await e.client.request("wifi.status");e.wifiStatus=y}catch(y){console.error("WiFi forget failed:",y),e.wifiError=y.message||"Failed to forget network"}finally{e.wifiBusy=!1}}},onWifiDismiss:()=>{e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null},onWifiSelectSsid:y=>{e.wifiSelectedSsid=y,e.wifiPassword="",e.wifiError=null},onWifiPasswordChange:y=>{e.wifiPassword=y},networkPort:e.networkPort,networkHostname:e.networkHostname,networkPortInput:e.networkPortInput,networkHostnameInput:e.networkHostnameInput,networkModalOpen:e.networkModalOpen,networkBusy:e.networkBusy,networkError:e.networkError,networkSuccess:e.networkSuccess,onNetworkModalToggle:()=>{e.networkModalOpen=!e.networkModalOpen,e.networkModalOpen&&(e.networkPortInput=String(e.networkPort??""),e.networkHostnameInput=e.networkHostname,e.networkError=null,e.networkSuccess=null)},onNetworkPortChange:y=>{e.networkPortInput=y,e.networkError=null,e.networkSuccess=null},onNetworkHostnameChange:y=>{e.networkHostnameInput=y,e.networkError=null,e.networkSuccess=null},onNetworkSave:async()=>{if(e.networkBusy)return;e.networkBusy=!0,e.networkError=null,e.networkSuccess=null;const y=e.networkPortInput.trim(),b=Number.parseInt(y,10),k=e.networkHostnameInput.trim();if(!y||!Number.isFinite(b)||b<1024||b>65535){e.networkError="Port must be a number between 1024 and 65535",e.networkBusy=!1;return}const A=b!==e.networkPort,E=k!==e.networkHostname;if(!A&&!E){e.networkBusy=!1;return}try{E&&await e.client.request("network.setHostname",{hostname:k});const T={};A&&(T.gateway={port:b}),E&&(T.discovery={bonjourHostname:k});const P=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify(T),baseHash:P.hash,note:[A?`Port → ${b}`:null,E?`Hostname → ${k}`:null].filter(Boolean).join(", "),restartDelayMs:2e3}),e.networkSuccess="Saved — redirecting...";const D=window.location.protocol,W=E?`${k}.local`:window.location.hostname,K=A?b:e.networkPort,H=`${D}//${W}:${K}/setup`;setTimeout(()=>{window.location.href=H},1500)}catch(T){console.error("Network save failed:",T),e.networkError=T.message||"Failed to save network settings",e.networkBusy=!1}},wsProps:r0(e)})}if(e.filesPage){const u=c0(e);return wg({connected:e.connected,wsProps:Sn(e),loading:e.filesLoading,tree:e.filesTree,root:e.filesRoot,error:e.filesError,selectedPath:e.filesSelectedPath,selectedPaths:e.filesSelectedPaths,previewContent:e.filesPreviewContent,previewLoading:e.filesPreviewLoading,previewBinary:e.filesPreviewBinary,previewSize:e.filesPreviewSize,expandedDirs:e.filesExpandedDirs,currentDir:e.filesCurrentDir,message:e.filesMessage,uploadBusy:e.filesUploadBusy,reindexBusy:e.filesReindexBusy,memoryStatus:e.filesMemoryStatus,onRefresh:()=>{rn(e,u),cs(e,u)},onReindex:()=>Lf(e,u),onSelectFile:p=>{e.filesPendingDeletePath=null,Cf(e,p,u)},onToggleSelectFile:p=>Ef(e,p,u),onToggleDir:p=>Df(e,p),onUpload:(p,v)=>Mf(e,p,v,u),onNewFolder:(p,v)=>Pf(e,p,v,u),onDownload:p=>ld(e,p,u),onBulkDownload:()=>Tf(e,u),onDelete:p=>{e.filesPendingDeletePath=null,If(e,p,u)},pendingDeletePath:e.filesPendingDeletePath,onArmDelete:p=>{e.filesPendingDeletePath=p||null},onMoveToDir:(p,v)=>_f(e,p,v,u),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:p=>{const v=e.filesSearchAgentId??u;Bf(e,p,v)},onSearchAgentChange:p=>{e.filesSearchAgentId=p},onSearchClear:()=>{Nf(e)},onSearchQueryChange:p=>{e.filesSearchQuery=p}})}if(e.browserPage)return fg({connected:e.connected,active:e.browserScreencastActive,loading:e.browserLoading,error:e.browserError,inputMode:e.browserInputMode,fullscreen:e.browserFullscreen,handoffPending:e.browserHandoffPending,handoffReason:e.browserHandoffReason,onStart:()=>_k(e),onStop:()=>Mk(e),onToggleInput:()=>Ik(e),onToggleFullscreen:()=>Rk(e),onCompleteHandoff:()=>Pk(e),onCanvasMouseDown:u=>{const v=u.target.getBoundingClientRect(),S=Bn().translateCoordinates(u.clientX-v.left,u.clientY-v.top);po(e,"mousePressed",S.x,S.y,u.button===2?"right":u.button===1?"middle":"left")},onCanvasMouseUp:u=>{const v=u.target.getBoundingClientRect(),S=Bn().translateCoordinates(u.clientX-v.left,u.clientY-v.top);po(e,"mouseReleased",S.x,S.y)},onCanvasMouseMove:u=>{const p=Bn();if(p.shouldThrottleMouseMove())return;const $=u.target.getBoundingClientRect(),S=p.translateCoordinates(u.clientX-$.left,u.clientY-$.top);po(e,"mouseMoved",S.x,S.y)},onCanvasKeyDown:u=>{let p=0;u.altKey&&(p|=1),u.ctrlKey&&(p|=2),u.metaKey&&(p|=4),u.shiftKey&&(p|=8),ho(e,"keyDown",u.key,{code:u.code,modifiers:p||void 0}),u.key.length===1&&ho(e,"char",u.key,{text:u.key})},onCanvasKeyUp:u=>{ho(e,"keyUp",u.key,{code:u.code})}});if(e.adminsPage){const u=l0(e),p=za(e);return cm({connected:e.connected,wsProps:Sn(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>ys(e,u),onAdd:v=>{Ru(e,v,u,p).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:v=>Lu(e,v,u,p),onNewPhoneChange:v=>e.handleAdminsNewPhoneChange(v)})}if(e.contactsPage){const u=d0(e);return gm({connected:e.connected,wsProps:Sn(e),loading:e.contactsLoading,saving:e.contactsSaving,records:e.contactsRecords,error:e.contactsError,searchQuery:e.contactsSearchQuery,editingId:e.contactsEditingId,showAddForm:e.contactsShowAddForm,newRecordPhone:e.contactsNewPhone,newRecordName:e.contactsNewName,deleteConfirmId:e.contactsDeleteConfirmId,addFieldForId:e.contactsAddFieldForId,addFieldKey:e.contactsAddFieldKey,addFieldValue:e.contactsAddFieldValue,onSearch:p=>e.contactsSearchQuery=p,onSearchSubmit:()=>It(e,u),onAdd:(p,v)=>Du(e,p,v,u),onDelete:p=>Bu(e,p,u),onSetField:(p,v,$)=>jo(e,p,v,$,u),onDeleteField:(p,v)=>Nu(e,p,v,u),onToggleExpand:p=>{e.contactsEditingId=e.contactsEditingId===p?null:p},onShowAddForm:()=>e.contactsShowAddForm=!0,onCancelAddForm:()=>{e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName=""},onNewRecordPhoneChange:p=>e.handleContactsNewPhoneChange(p),onNewRecordNameChange:p=>e.handleContactsNewNameChange(p),onRefresh:()=>It(e,u),onDeleteConfirmOpen:p=>e.contactsDeleteConfirmId=p,onDeleteConfirmClose:()=>e.contactsDeleteConfirmId=null,onAddFieldOpen:p=>{e.contactsAddFieldForId=p,e.contactsAddFieldKey="",e.contactsAddFieldValue=""},onAddFieldClose:()=>{e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue=""},onAddFieldKeyChange:p=>e.contactsAddFieldKey=p,onAddFieldValueChange:p=>e.contactsAddFieldValue=p,onAddFieldSubmit:()=>{const p=e.contactsAddFieldForId,v=e.contactsAddFieldKey.trim();!p||!v||(jo(e,p,v,e.contactsAddFieldValue,u),e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue="")}})}if(e.chatPage){const u=e.connected?null:"Disconnected from gateway.",p=Dl(e),v=e.chatAvatarUrl??p??null,$=(()=>{var y;const S=(y=e.configSnapshot)==null?void 0:y.config,M=S==null?void 0:S.publicChat;return(M==null?void 0:M.enabled)===!0})();return mw({connected:e.connected,wsProps:Sn(e),publicChatEnabled:$,publicChatAccountId:e.selectedWorkspace??void 0,chatPageTab:e.chatPageTab??"chat",onChatPageTabChange:S=>{if(e.chatPageTab=S,S==="whatsapp"&&!e.waLoading&&e.waConversations.length===0){const M=Ii(e);bu(M).then(()=>e.requestUpdate())}},whatsappProps:y0(e),sessionKey:e.sessionKey,onSessionKeyChange:S=>{const M=e.selectedWorkspace??"";wo(),Wn(M,e.sessionKey,e.chatMessage),e.sessionKey=S,e.chatMessage=zn(M,S),e.chatAttachments=[],e.chatStream=null,e.chatInterimText=null,e.chatSuggestions=[],e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:S,lastActiveSessionKey:S}),e.loadAssistantIdentity(),Jt(e),Eo(e)},showThinking:e.settings.chatShowThinking??!1,verboseLevel:e.chatVerboseLevel,suggestions:e.chatSuggestions,onSuggestionClick:S=>{e.chatMessage=S,e.chatSuggestions=[],e.handleSendChat()},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:v,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:u,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>{e.resetToolStream();const S=Math.max(e.chatMessages.length+10,nn);return Promise.all([Jt(e,{limit:S}),Eo(e)])},onToggleFocusMode:()=>{},onChatScroll:S=>e.handleChatScroll(S),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:S=>{e.chatMessage=S,wr(e.selectedWorkspace??"",e.sessionKey,S)},requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:S=>e.chatAttachments=S,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:S=>e.removeQueuedMessage(S),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:S=>e.handleOpenSidebar(S),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:S=>e.handleSplitRatioChange(S),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?mk({connected:e.connected,wsProps:Sn(e),activeTab:e.advancedTab,onTabChange:u=>{e.advancedTab=u,u==="cron"&&e.loadCron(),u==="skills"&&Pe(e,{clearMessages:!0}),u==="opening-hours"&&Wa(e),u==="logs"&&(e.logsSubTab==="session"?Pn(e,{reset:!0}):bt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(r=(a=e.channelsSnapshot)==null?void 0:a.channelMeta)!=null&&r.length?e.channelsSnapshot.channelMeta.map(u=>u.id):((l=e.channelsSnapshot)==null?void 0:l.channelOrder)??[],channelLabels:((d=e.channelsSnapshot)==null?void 0:d.channelLabels)??{},channelMeta:((h=e.channelsSnapshot)==null?void 0:h.channelMeta)??[],agentIds:(()=>{var p;const u=we(e);return((p=u==null?void 0:u.agents)==null?void 0:p.map(v=>v.id))??[]})(),runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1,e.cronEditJobId=null},detailJobId:e.cronDetailJobId,editJobId:e.cronEditJobId,onDetailOpen:u=>{e.cronDetailJobId=u.id,xo(e,u.id)},onDetailClose:()=>{e.cronDetailJobId=null},onEdit:u=>{e.cronForm=Ah(u),e.cronEditJobId=u.id,e.cronDetailJobId=null},onEditSave:()=>{const u=e.cronEditJobId;u&&Ch(e,u).then(()=>{e.cronEditJobId=null})},onFormChange:u=>e.cronForm={...e.cronForm,...u},onRefresh:()=>e.loadCron(),onAdd:()=>{wh(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(u,p)=>kh(e,u,p),onRun:u=>xh(e,u),onRemove:u=>{e.cronPendingDeleteId=null,Sh(e,u)},pendingDeleteId:e.cronPendingDeleteId,onArmDelete:u=>{e.cronPendingDeleteId=u||null},onLoadRuns:u=>xo(e,u),runModalJobId:e.cronRunModalJobId,runModalJobName:e.cronRunModalJobName,runResult:e.cronRunResult,onRunModalClose:()=>{e.cronRunModalJobId=null,e.cronRunModalJobName="",e.cronRunResult=null}},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,typeFilter:e.skillsTypeFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,detail:e.skillDetail,detailTab:e.skillDetailTab,addModal:e.skillAddModal,addForm:e.skillAddForm,formSource:e.skillAddFormSource,editTab:e.skillEditTab,drafts:e.skillDrafts,onFilterChange:u=>e.skillsFilter=u,onTypeFilterChange:u=>e.skillsTypeFilter=u,onRefresh:()=>Pe(e,{clearMessages:!0}),onToggle:(u,p)=>Oc(e,u,p),onEdit:(u,p)=>Nc(e,u,p),onSaveKey:u=>Fc(e,u),onInstall:(u,p,v)=>Uc(e,u,p,v),onViewDetail:u=>Wc(e,u),onDetailClose:()=>zc(e),onDetailTab:u=>Kc(e,u),onAddOpen:()=>Hc(e),onAddClose:()=>qc(e),onImportDraft:u=>jc(e,u),onInstallDraft:u=>Gc(e,u),onDeleteDraft:u=>Vc(e,u),onAddSave:()=>ua(e),onAddFormUpdate:(u,p)=>{e.skillAddForm={...e.skillAddForm,[u]:p}},onAlwaysActiveToggle:(u,p)=>Zc(e,u,p),onDelete:u=>td(e,u),onEditSkill:u=>Qc(e,u),onEditDetail:u=>Jc(e,u),onRefUpdate:(u,p)=>Yc(e,u,p),onEditTab:u=>Xc(e,u),agentFilter:e.skillsAgentFilter,onAgentFilterChange:u=>e.skillsAgentFilter=u,onAgentsChange:(u,p)=>ed(e,u,p)},logsProps:{logsSubTab:e.logsSubTab,isAdmin:e.accessState.master||!e.accessState.hasPins,onSubTabChange:u=>{e.logsSubTab=u,u==="session"?Pn(e,{reset:!0}):bt(e,{reset:!0})},sessionLogsProps:{loading:e.sessionLogsLoading,error:e.sessionLogsError,entries:e.sessionLogsEntries,agents:e.sessionLogsAgents,filterText:e.sessionLogsFilterText,typeFilters:e.sessionLogsTypeFilters,agentFilters:e.sessionLogsAgentFilters,autoFollow:e.sessionLogsAutoFollow,chipsExpanded:e.sessionLogsChipsExpanded,expandedIds:e.sessionLogsExpandedIds,onFilterTextChange:u=>e.sessionLogsFilterText=u,onTypeToggle:(u,p)=>{const v=e;v.sessionLogsTypeFilters={...v.sessionLogsTypeFilters,[u]:p}},onAgentToggle:(u,p)=>{const v=e;v.sessionLogsAgentFilters={...v.sessionLogsAgentFilters,[u]:p}},onToggleAutoFollow:u=>e.sessionLogsAutoFollow=u,onToggleChips:()=>{const u=e;u.sessionLogsChipsExpanded=!u.sessionLogsChipsExpanded},onToggleExpand:u=>{const p=e,v=new Set(p.sessionLogsExpandedIds);v.has(u)?v.delete(u):v.add(u),p.sessionLogsExpandedIds=v,p.requestUpdate()},onRefresh:()=>{Pn(e,{reset:!0})},onExport:(u,p)=>e.exportSessionLogs(u,p),onScroll:u=>e.handleSessionLogsScroll(u)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,chipsExpanded:e.logsChipsExpanded,truncated:e.logsTruncated,selectedDate:e.logsDate,availableDates:e.logsAvailableDates,onDateChange:u=>{e.logsDate=u,bt(e,{reset:!0})},onFilterTextChange:u=>e.logsFilterText=u,onLevelToggle:(u,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[u]:p}},onToggleAutoFollow:u=>e.logsAutoFollow=u,onToggleChips:()=>{const u=e;u.logsChipsExpanded=!u.logsChipsExpanded},onRefresh:()=>bt(e,{reset:!0}),onExport:(u,p)=>e.exportSessionLogs(u,p),onScroll:u=>e.handleLogsScroll(u)},openingHoursProps:{loading:e.openingHoursLoading,error:e.openingHoursError,busy:e.openingHoursBusy,form:e.openingHoursForm,onFormChange:u=>{const p=e;p.openingHoursForm={...p.openingHoursForm,...u}},onDayChange:(u,p,v)=>{const $=e,S={...$.openingHoursForm.days};S[u]={...S[u],[p]:v},$.openingHoursForm={...$.openingHoursForm,days:S}},onAddClosedDate:u=>{const p=e;p.openingHoursForm.closedDates.includes(u)||(p.openingHoursForm={...p.openingHoursForm,closedDates:[...p.openingHoursForm.closedDates,u].sort()})},onRemoveClosedDate:u=>{const p=e;p.openingHoursForm={...p.openingHoursForm,closedDates:p.openingHoursForm.closedDates.filter(v=>v!==u)}},onSave:()=>{Pu(e)}}}):(window.location.replace("/chat"),c``)}function b0(e){const t=new Date(e),n=t.toLocaleDateString("en-GB",{day:"2-digit",month:"short"}),i=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} ${i}`}function Bl(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function w0(e,t,n){return c`
|
|
4910
4900
|
<div class="audit-modal-overlay" @click=${s=>{s.target.classList.contains("audit-modal-overlay")&&n()}}>
|
|
4911
4901
|
<div class="audit-modal-card">
|
|
4912
4902
|
<div class="audit-modal-header">
|
|
@@ -4938,7 +4928,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
4938
4928
|
`}
|
|
4939
4929
|
</div>
|
|
4940
4930
|
</div>
|
|
4941
|
-
`}const k0={trace:!1,debug:!1,info:!0,warn:!0,error:!0,fatal:!0},x0={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",recipients:[],toAdmins:!1,timeoutSeconds:"",postToMainPrefix:""};function $0(e){e.basePath=Gf();const t=Xe();Gl(t.accentColor),Vl(t.backgroundColor);const n=document.querySelector('link[rel="icon"]');if(n&&(n.href=t.iconUrl),window.scrollTo(0,0),Uf(e),e.publicChat){const i=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__,s=(i==null?void 0:i.accountId)??"",o=s?s.charAt(0).toUpperCase()+s.slice(1):"Assistant";document.title=`Chat with ${o}`,Oe(e);return}if(e.setup){document.title=`${t.name} Setup`,Oe(e);return}if(e.filesPage){document.title=`${t.name} Files`,zf(e),Oe(e);return}if(e.browserPage){document.title=`${t.name} Browser`,Oe(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,Oe(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,Oe(e);return}if(e.chatPage){document.title=`${t.name} Chat`,Oe(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,Oe(e);return}Yf(e,!0),Vf(e),Qf(e),window.addEventListener("popstate",e.popStateHandler),Hf(e),Oe(e),Of(e),e.tab==="logs"&&(e.logsSubTab==="session"?ga(e):ha(e)),e.tab==="debug"&&ya(e)}function S0(e){mh(e)}function A0(e){var t;window.removeEventListener("popstate",e.popStateHandler),Ff(e),fa(e),ma(e),va(e),Wf(e),Kf(e),Jf(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function C0(e,t){if(!e.publicChat){if(e.filesPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleFilesLoad&&e.handleFilesLoad(),e.adminsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdminsLoad&&e.handleAdminsLoad(),e.contactsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleContactsLoad&&e.handleContactsLoad(),e.chatPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleChatLoad&&e.handleChatLoad(),e.advancedPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdvancedLoad&&e.handleAdvancedLoad(),e.setup&&e.connected){const n=t.has("connected")&&t.get("connected")===!1;n&&e.handleLicenseStatusCheck&&e.licenseValid===null&&!e.licenseBusy&&e.handleLicenseStatusCheck(),n&&e.handleUpdateCheck&&e.handleUpdateCheck();const i=t.has("setupStep")&&e.setupStep==="auth",s=t.has("setupStep")&&e.setupStep==="setup";(n||i||s)&&e.handleAuthStatusCheck&&e.authConnected===null&&!e.authBusy&&e.handleAuthStatusCheck(),e.setupStep==="setup"&&t.has("setupStep")&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(a=>{e.channelsSnapshot=a,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1})),t.has("whatsappLoginConnected")&&e.whatsappLoginConnected===!0&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(o=>{e.channelsSnapshot=o,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1}))}if(e.tab==="chat"&&!e.advancedPage&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),i=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;sn(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&lc(e,t.has("tab")||t.has("logsAutoFollow"))}}function E0(e){const t={name:(e==null?void 0:e.name)??"",displayName:(e==null?void 0:e.displayName)??"",about:(e==null?void 0:e.about)??"",picture:(e==null?void 0:e.picture)??"",banner:(e==null?void 0:e.banner)??"",website:(e==null?void 0:e.website)??"",nip05:(e==null?void 0:e.nip05)??"",lud16:(e==null?void 0:e.lud16)??""};return{values:t,original:{...t},saving:!1,importing:!1,error:null,success:null,fieldErrors:{},showAdvanced:!!(e!=null&&e.banner||e!=null&&e.website||e!=null&&e.nip05||e!=null&&e.lud16)}}async function T0(e,t,n){await ea(e,t,n),await ee(e,!0)}async function _0(e,t){await hc(e,t),await ee(e,!0)}async function M0(e,t){await fc(e,t),await ee(e,!0)}async function P0(e,t){await gc(e,t)}async function I0(e,t){await mc(e,t)}async function R0(e){await bh(e),await We(e),await ee(e,!0)}async function L0(e){await We(e),await ee(e,!0)}function D0(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[i,...s]=n.split(":");if(!i||s.length===0)continue;const o=i.trim(),a=s.join(":").trim();o&&a&&(t[o]=a)}return t}function Ou(e){var n,i,s;return((s=(((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.nostr)??[])[0])==null?void 0:s.accountId)??e.nostrProfileAccountId??"default"}function Fu(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function B0(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=E0(n??void 0)}function N0(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function O0(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function F0(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function U0(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Ou(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(Fu(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const o=(s==null?void 0:s.error)??`Profile update failed (${i.status})`;e.nostrProfileFormState={...t,saving:!1,error:o,success:null,fieldErrors:D0(s==null?void 0:s.details)};return}if(!s.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await ee(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function W0(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Ou(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(Fu(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const l=(s==null?void 0:s.error)??`Profile import failed (${i.status})`;e.nostrProfileFormState={...t,importing:!1,error:l,success:null};return}const o=s.merged??s.imported??null,a=o?{...t.values,...o}:t.values,r=!!(a.banner||a.website||a.nip05||a.lud16);e.nostrProfileFormState={...t,importing:!1,values:a,error:null,success:s.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:r},s.saved&&await ee(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function z0(e){if(!e.client)return;const t=e.authRefreshTokenInput.trim();if(t){e.authRefreshTokenBusy=!0,e.authRefreshTokenError=null;try{const n=await e.client.request("auth.importRefreshToken",{refreshToken:t});e.authConnected=n.connected,e.authExpiresIn=n.expiresIn??null,e.authMessage=n.message??null,e.authRefreshToken=t,e.authRefreshTokenInput="",e.claudeAuthModalOpen=!1}catch(n){e.authRefreshTokenError=n instanceof Error?n.message:"Failed to import token"}finally{e.authRefreshTokenBusy=!1}}}async function K0(e){if(e.client){e.authBusy=!0,e.authMessage=null;try{const t=await e.client.request("auth.status",{});e.authConnected=t.connected,e.authExpiresIn=t.expiresIn??null,e.authMessage=t.message??null,e.authRefreshToken=t.refreshToken??null}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to check auth status"}finally{e.authBusy=!1}}}async function H0(e){if(e.client){e.authBusy=!0,e.authMessage=null,e.authUrl=null,e.authConnected=null;try{const t=await e.client.request("auth.oauth.start",{provider:"anthropic"});e.authUrl=t.authUrl,e.authMessage=t.message??"Sign in with your Claude Pro account"}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to start auth flow"}finally{e.authBusy=!1}}}async function q0(e,t){if(e.client){e.authBusy=!0,e.authMessage="Verifying code...";try{await e.client.request("auth.oauth.code",{code:t});const n=await e.client.request("auth.oauth.wait",{timeoutMs:3e4});n.connected?(e.authConnected=!0,e.authMessage=n.message??"Connected to Claude!",e.authUrl=null,e.authCodeInput=""):e.authMessage=n.message??"Still waiting for authorization..."}catch(n){e.authConnected=!1,e.authMessage=n instanceof Error?n.message:"Verification failed"}finally{e.authBusy=!1}}}function j0(e,t){e.authCodeInput=t}async function G0(e){if(e.client){e.licenseBusy=!0,e.licenseMessage=null;try{const t=await e.client.request("license.status",{});e.licenseDeviceId=t.deviceId??null,e.licenseStoredKey=t.key??null,t.licensed?(e.licenseValid=!0,e.licenseTier=t.tier??null,e.setupStep="setup"):(e.licenseValid=null,e.setupStep="license")}catch(t){const n=t instanceof Error?t.message:String(t);n.includes("unknown method")?(e.licenseValid=!0,e.setupStep="setup"):(e.licenseValid=null,e.licenseMessage=n,e.setupStep="license")}finally{e.licenseBusy=!1}}}async function V0(e){if(e.client&&e.licenseKey.trim()){e.licenseBusy=!0,e.licenseMessage=null,e.licenseValid=null;try{const t=await e.client.request("license.activate",{key:e.licenseKey.trim()});t.valid?(e.licenseValid=!0,e.licenseMessage=t.message??"License activated",e.licenseTier=t.tier??null,setTimeout(()=>{e.setupStep="setup"},1500)):(e.licenseValid=!1,e.licenseMessage=t.message??"Invalid license key")}catch(t){e.licenseValid=!1,e.licenseMessage=t instanceof Error?t.message:"Activation failed"}finally{e.licenseBusy=!1}}}async function Q0(e){if(e.client){e.licenseBusy=!0;try{await e.client.request("license.remove",{}),e.licenseValid=null,e.licenseKey="",e.licenseTier=null,e.licenseMessage=null,e.setupStep="license"}catch(t){e.licenseMessage=t instanceof Error?t.message:"Failed to remove license"}finally{e.licenseBusy=!1}}}function J0(e,t){e.licenseKey=t}async function Y0(e){var t,n;if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("health",{probe:!0});e.gatewayHealthy=i.ok===!0,e.gatewayHealthMessage=i.ok?`Healthy${i.durationMs?` (${i.durationMs}ms)`:""}`:"Unhealthy"}catch(i){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(i)}`}finally{e.gatewayHealthLoading=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function X0(e){var t,n,i;if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(s.ok&&((n=s.restart)!=null&&n.ok))e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(s){e.gatewayHealthMessage=`Restart failed: ${String(s)}`,e.gatewayRestartBusy=!1,(i=e.requestUpdate)==null||i.call(e)}}}var Z0=Object.defineProperty,ex=Object.getOwnPropertyDescriptor,g=(e,t,n,i)=>{for(var s=i>1?void 0:i?ex(t,n):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(s=(i?a(t,n,s):a(s))||s);return i&&s&&Z0(t,n,s),s};const yo=Sp();function tx(){if(!window.location.search)return!1;const t=new URLSearchParams(window.location.search).get("onboarding");if(!t)return!1;const n=t.trim().toLowerCase();return n==="1"||n==="true"||n==="yes"||n==="on"}function nx(){const e=window.location.pathname;if(e==="/setup"||e.endsWith("/setup"))return!0;if(!window.location.search)return!1;const n=new URLSearchParams(window.location.search).get("setup");if(!n)return!1;const i=n.trim().toLowerCase();return i==="1"||i==="true"||i==="yes"||i==="on"}function ix(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function sx(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function ox(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function ax(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function rx(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function lx(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let f=class extends Gt{constructor(){super(...arguments),this.settings=Ls(),this.password="",this.tab="chat",this.onboarding=tx(),this.setup=nx(),this.filesPage=ix(),this.browserPage=sx(),this.adminsPage=ox(),this.contactsPage=ax(),this.chatPage=rx(),this.advancedPage=lx(),this.advancedTab="cron",this.publicChat=!!window.__TASKMASTER_PUBLIC_CHAT__,this.publicChatConfig=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__??{},this.publicChatSessionKey=null,this.publicChatAuthenticated=!1,this.publicChatAuthStep="idle",this.connected=!1,this.accessState=yc,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=yo.name,this.assistantAvatar=yo.avatar,this.assistantAgentId=yo.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatHistoryTotal=0,this.chatHistoryHasMore=!1,this.chatLoadingOlder=!1,this.chatToolMessages=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestions=[],this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatModelCatalog=[],this.chatVerboseLevel=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=`{
|
|
4931
|
+
`}const k0={trace:!1,debug:!1,info:!0,warn:!0,error:!0,fatal:!0},x0={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",recipients:[],toAdmins:!1,timeoutSeconds:"",postToMainPrefix:""};function $0(e){e.basePath=Gf();const t=Xe();Gl(t.accentColor),Vl(t.backgroundColor);const n=document.querySelector('link[rel="icon"]');if(n&&(n.href=t.iconUrl),window.scrollTo(0,0),Uf(e),e.publicChat){const i=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__,s=(i==null?void 0:i.accountId)??"",o=s?s.charAt(0).toUpperCase()+s.slice(1):"Assistant";document.title=`Chat with ${o}`,Oe(e);return}if(e.setup){document.title=`${t.name} Setup`,Oe(e);return}if(e.filesPage){document.title=`${t.name} Files`,zf(e),Oe(e);return}if(e.browserPage){document.title=`${t.name} Browser`,Oe(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,Oe(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,Oe(e);return}if(e.chatPage){document.title=`${t.name} Chat`,Oe(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,Oe(e);return}Yf(e,!0),Vf(e),Qf(e),window.addEventListener("popstate",e.popStateHandler),Hf(e),Oe(e),Of(e),e.tab==="logs"&&(e.logsSubTab==="session"?ga(e):ha(e)),e.tab==="debug"&&ya(e)}function S0(e){mh(e)}function A0(e){var t;window.removeEventListener("popstate",e.popStateHandler),Ff(e),fa(e),ma(e),va(e),Wf(e),Kf(e),Jf(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function C0(e,t){if(!e.publicChat){if(e.filesPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleFilesLoad&&e.handleFilesLoad(),e.adminsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdminsLoad&&e.handleAdminsLoad(),e.contactsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleContactsLoad&&e.handleContactsLoad(),e.chatPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleChatLoad&&e.handleChatLoad(),e.advancedPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdvancedLoad&&e.handleAdvancedLoad(),e.setup&&e.connected){const n=t.has("connected")&&t.get("connected")===!1;n&&e.handleLicenseStatusCheck&&e.licenseValid===null&&!e.licenseBusy&&e.handleLicenseStatusCheck(),n&&e.handleUpdateCheck&&e.handleUpdateCheck();const i=t.has("setupStep")&&e.setupStep==="auth",s=t.has("setupStep")&&e.setupStep==="setup";(n||i||s)&&e.handleAuthStatusCheck&&e.authConnected===null&&!e.authBusy&&e.handleAuthStatusCheck(),e.setupStep==="setup"&&t.has("setupStep")&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(a=>{e.channelsSnapshot=a,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1})),t.has("whatsappLoginConnected")&&e.whatsappLoginConnected===!0&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(o=>{e.channelsSnapshot=o,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1}))}if(e.tab==="chat"&&!e.advancedPage&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),i=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;sn(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&lc(e,t.has("tab")||t.has("logsAutoFollow"))}}function E0(e){const t={name:(e==null?void 0:e.name)??"",displayName:(e==null?void 0:e.displayName)??"",about:(e==null?void 0:e.about)??"",picture:(e==null?void 0:e.picture)??"",banner:(e==null?void 0:e.banner)??"",website:(e==null?void 0:e.website)??"",nip05:(e==null?void 0:e.nip05)??"",lud16:(e==null?void 0:e.lud16)??""};return{values:t,original:{...t},saving:!1,importing:!1,error:null,success:null,fieldErrors:{},showAdvanced:!!(e!=null&&e.banner||e!=null&&e.website||e!=null&&e.nip05||e!=null&&e.lud16)}}async function T0(e,t,n){await ea(e,t,n),await Z(e,!0)}async function _0(e,t){await hc(e,t),await Z(e,!0)}async function M0(e,t){await fc(e,t),await Z(e,!0)}async function P0(e,t){await gc(e,t)}async function I0(e,t){await mc(e,t)}async function R0(e){await bh(e),await We(e),await Z(e,!0)}async function L0(e){await We(e),await Z(e,!0)}function D0(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[i,...s]=n.split(":");if(!i||s.length===0)continue;const o=i.trim(),a=s.join(":").trim();o&&a&&(t[o]=a)}return t}function Ou(e){var n,i,s;return((s=(((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.nostr)??[])[0])==null?void 0:s.accountId)??e.nostrProfileAccountId??"default"}function Fu(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function B0(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=E0(n??void 0)}function N0(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function O0(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function F0(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function U0(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Ou(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(Fu(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const o=(s==null?void 0:s.error)??`Profile update failed (${i.status})`;e.nostrProfileFormState={...t,saving:!1,error:o,success:null,fieldErrors:D0(s==null?void 0:s.details)};return}if(!s.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await Z(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function W0(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Ou(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(Fu(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const l=(s==null?void 0:s.error)??`Profile import failed (${i.status})`;e.nostrProfileFormState={...t,importing:!1,error:l,success:null};return}const o=s.merged??s.imported??null,a=o?{...t.values,...o}:t.values,r=!!(a.banner||a.website||a.nip05||a.lud16);e.nostrProfileFormState={...t,importing:!1,values:a,error:null,success:s.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:r},s.saved&&await Z(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function z0(e){if(!e.client)return;const t=e.authRefreshTokenInput.trim();if(t){e.authRefreshTokenBusy=!0,e.authRefreshTokenError=null;try{const n=await e.client.request("auth.importRefreshToken",{refreshToken:t});e.authConnected=n.connected,e.authExpiresIn=n.expiresIn??null,e.authMessage=n.message??null,e.authRefreshToken=t,e.authRefreshTokenInput="",e.claudeAuthModalOpen=!1}catch(n){e.authRefreshTokenError=n instanceof Error?n.message:"Failed to import token"}finally{e.authRefreshTokenBusy=!1}}}async function K0(e){if(e.client){e.authBusy=!0,e.authMessage=null;try{const t=await e.client.request("auth.status",{});e.authConnected=t.connected,e.authExpiresIn=t.expiresIn??null,e.authMessage=t.message??null,e.authRefreshToken=t.refreshToken??null}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to check auth status"}finally{e.authBusy=!1}}}async function H0(e){if(e.client){e.authBusy=!0,e.authMessage=null,e.authUrl=null,e.authConnected=null;try{const t=await e.client.request("auth.oauth.start",{provider:"anthropic"});e.authUrl=t.authUrl,e.authMessage=t.message??"Sign in with your Claude Pro account"}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to start auth flow"}finally{e.authBusy=!1}}}async function q0(e,t){if(e.client){e.authBusy=!0,e.authMessage="Verifying code...";try{await e.client.request("auth.oauth.code",{code:t});const n=await e.client.request("auth.oauth.wait",{timeoutMs:3e4});n.connected?(e.authConnected=!0,e.authMessage=n.message??"Connected to Claude!",e.authUrl=null,e.authCodeInput=""):e.authMessage=n.message??"Still waiting for authorization..."}catch(n){e.authConnected=!1,e.authMessage=n instanceof Error?n.message:"Verification failed"}finally{e.authBusy=!1}}}function j0(e,t){e.authCodeInput=t}async function G0(e){if(e.client){e.licenseBusy=!0,e.licenseMessage=null;try{const t=await e.client.request("license.status",{});e.licenseDeviceId=t.deviceId??null,e.licenseStoredKey=t.key??null,t.licensed?(e.licenseValid=!0,e.licenseTier=t.tier??null,e.setupStep="setup"):(e.licenseValid=null,e.setupStep="license")}catch(t){const n=t instanceof Error?t.message:String(t);n.includes("unknown method")?(e.licenseValid=!0,e.setupStep="setup"):(e.licenseValid=null,e.licenseMessage=n,e.setupStep="license")}finally{e.licenseBusy=!1}}}async function V0(e){if(e.client&&e.licenseKey.trim()){e.licenseBusy=!0,e.licenseMessage=null,e.licenseValid=null;try{const t=await e.client.request("license.activate",{key:e.licenseKey.trim()});t.valid?(e.licenseValid=!0,e.licenseMessage=t.message??"License activated",e.licenseTier=t.tier??null,setTimeout(()=>{e.setupStep="setup"},1500)):(e.licenseValid=!1,e.licenseMessage=t.message??"Invalid license key")}catch(t){e.licenseValid=!1,e.licenseMessage=t instanceof Error?t.message:"Activation failed"}finally{e.licenseBusy=!1}}}async function Q0(e){if(e.client){e.licenseBusy=!0;try{await e.client.request("license.remove",{}),e.licenseValid=null,e.licenseKey="",e.licenseTier=null,e.licenseMessage=null,e.setupStep="license"}catch(t){e.licenseMessage=t instanceof Error?t.message:"Failed to remove license"}finally{e.licenseBusy=!1}}}function J0(e,t){e.licenseKey=t}async function Y0(e){var t,n;if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("health",{probe:!0});e.gatewayHealthy=i.ok===!0,e.gatewayHealthMessage=i.ok?`Healthy${i.durationMs?` (${i.durationMs}ms)`:""}`:"Unhealthy"}catch(i){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(i)}`}finally{e.gatewayHealthLoading=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function X0(e){var t,n,i;if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(s.ok&&((n=s.restart)!=null&&n.ok))e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(s){e.gatewayHealthMessage=`Restart failed: ${String(s)}`,e.gatewayRestartBusy=!1,(i=e.requestUpdate)==null||i.call(e)}}}var Z0=Object.defineProperty,ex=Object.getOwnPropertyDescriptor,g=(e,t,n,i)=>{for(var s=i>1?void 0:i?ex(t,n):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(s=(i?a(t,n,s):a(s))||s);return i&&s&&Z0(t,n,s),s};const yo=Sp();function tx(){if(!window.location.search)return!1;const t=new URLSearchParams(window.location.search).get("onboarding");if(!t)return!1;const n=t.trim().toLowerCase();return n==="1"||n==="true"||n==="yes"||n==="on"}function nx(){const e=window.location.pathname;if(e==="/setup"||e.endsWith("/setup"))return!0;if(!window.location.search)return!1;const n=new URLSearchParams(window.location.search).get("setup");if(!n)return!1;const i=n.trim().toLowerCase();return i==="1"||i==="true"||i==="yes"||i==="on"}function ix(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function sx(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function ox(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function ax(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function rx(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function lx(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let f=class extends Gt{constructor(){super(...arguments),this.settings=Ls(),this.password="",this.tab="chat",this.onboarding=tx(),this.setup=nx(),this.filesPage=ix(),this.browserPage=sx(),this.adminsPage=ox(),this.contactsPage=ax(),this.chatPage=rx(),this.advancedPage=lx(),this.advancedTab="cron",this.publicChat=!!window.__TASKMASTER_PUBLIC_CHAT__,this.publicChatConfig=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__??{},this.publicChatSessionKey=null,this.publicChatAuthenticated=!1,this.publicChatAuthStep="idle",this.connected=!1,this.accessState=yc,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=yo.name,this.assistantAvatar=yo.avatar,this.assistantAgentId=yo.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatHistoryTotal=0,this.chatHistoryHasMore=!1,this.chatLoadingOlder=!1,this.chatToolMessages=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestions=[],this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatModelCatalog=[],this.chatVerboseLevel=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=`{
|
|
4942
4932
|
}
|
|
4943
4933
|
`,this.configRawOriginal="",this.configValid=null,this.configIssues=[],this.configSaving=!1,this.configApplying=!1,this.updateRunning=!1,this.applySessionKey=this.settings.lastActiveSessionKey,this.configSnapshot=null,this.configSchema=null,this.configSchemaVersion=null,this.configSchemaLoading=!1,this.configUiHints={},this.configForm=null,this.configFormOriginal=null,this.configFormDirty=!1,this.configFormMode="form",this.configSearchQuery="",this.configActiveSection=null,this.configActiveSubsection=null,this.channelsLoading=!1,this.channelsSnapshot=null,this.channelsError=null,this.channelsLastSuccess=null,this.whatsappLoginMessage=null,this.whatsappLoginQrDataUrl=null,this.whatsappLoginConnected=null,this.whatsappBusy=!1,this.whatsappActiveQrAccountId=null,this.whatsappPairedPhone=null,this.addingWhatsAppAccount=!1,this.newWhatsAppAccountName="",this.whatsappAccountError=null,this.whatsappAccountSaving=!1,this.whatsappSettingsOpen=!1,this.publicChatToggleBusy=!1,this.publicChatGreetingBusy=!1,this.publicChatEmailBusy=!1,this.publicChatSettingsOpen=!1,this.publicChatWidgetModalOpen=!1,this.brandingBusy=!1,this.agentSettingsOpen=!1,this.brandingExpanded=!1,this.tailscaleStatus=null,this.tailscaleBusy=!1,this.tailscaleAuthUrl=null,this.tailscaleError=null,this.tailscaleServeEnableUrl=null,this.tailscaleFunnelEnableUrl=null,this.tailscaleDisableConfirm=!1,this.tailscaleConnectProgress=0,this.tailscaleConnectMessage="",this.tailscaleConnectSuccess=!1,this.wifiStatus=null,this.wifiNetworks=[],this.wifiBusy=!1,this.wifiError=null,this.wifiPassword="",this.wifiSelectedSsid=null,this.networkPort=null,this.networkHostname="",this.networkPortInput="",this.networkHostnameInput="",this.networkModalOpen=!1,this.networkBusy=!1,this.networkError=null,this.networkSuccess=null,this.wifiModalOpen=!1,this.licenseKey="",this.licenseBusy=!1,this.licenseValid=null,this.licenseMessage=null,this.licenseTier=null,this.licenseDeviceId=null,this.licenseStoredKey=null,this.licenseRemoveConfirm=!1,this.authConnected=null,this.authBusy=!1,this.authMessage=null,this.authUrl=null,this.authCodeInput="",this.authExpiresIn=null,this.authRefreshToken=null,this.claudeAuthModalOpen=!1,this.authRefreshTokenInput="",this.authRefreshTokenBusy=!1,this.authRefreshTokenError=null,this.setupStep="license",this.gatewayHealthy=null,this.gatewayHealthLoading=!1,this.gatewayHealthMessage=null,this.gatewayRestartBusy=!1,this.updateAvailable=null,this.currentVersion=null,this.latestVersion=null,this.updateChecking=!1,this.updateMessage=null,this.updateProgressSteps=[],this.updateLastResult=null,this.uninstallConfirm=!1,this.uninstallBusy=!1,this.uninstallDone=!1,this.uninstallError=null,this.uninstallConfirmText="",this.nostrProfileFormState=null,this.nostrProfileAccountId=null,this.presenceLoading=!1,this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.sessionsLoading=!1,this.sessionsResult=null,this.sessionsError=null,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...x0},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.cronEditJobId=null,this.cronPendingDeleteId=null,this.cronRunModalJobId=null,this.cronRunModalJobName="",this.cronRunResult=null,this.openingHoursLoading=!1,this.openingHoursError=null,this.openingHoursBusy=!1,this.openingHoursForm=Ua(),this.browserScreencastActive=!1,this.browserScreencastFrame=null,this.browserScreencastMetadata=null,this.browserHandoffPending=!1,this.browserHandoffReason=null,this.browserHandoffId=null,this.browserInputMode=!1,this.browserFullscreen=!1,this.browserLoading=!1,this.browserError=null,this.filesLoading=!1,this.filesTree=[],this.filesRoot="",this.filesError=null,this.filesSelectedPath=null,this.filesSelectedPaths=new Set,this.filesPreviewContent=null,this.filesPreviewLoading=!1,this.filesPreviewBinary=!1,this.filesPreviewSize=null,this.filesExpandedDirs=new Set,this.filesCurrentDir=".",this.filesPendingDeletePath=null,this.filesMessage=null,this.filesUploadBusy=!1,this.filesReindexBusy=!1,this.filesMemoryStatus=null,this.embeddingDownloading=!1,this.embeddingPollTimer=null,this.filesSearchQuery="",this.filesSearchResults=null,this.filesSearchLoading=!1,this.filesSearchAgentId=null,this.filesResolvedAgentId=void 0,this.auditEntries=[],this.auditLoading=!1,this.auditModalOpen=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillsTypeFilter="all",this.skillsAgentFilter="all",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.skillDetail=null,this.skillDetailTab="",this.skillAddModal=!1,this.skillAddForm={name:"",skillContent:"",references:[]},this.skillAddFormSource="draft",this.skillEditTab="SKILL.md",this.skillDrafts=[],this.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.contactsLoading=!1,this.contactsSaving=!1,this.contactsRecords=[],this.contactsError=null,this.contactsSearchQuery="",this.contactsEditingId=null,this.contactsShowAddForm=!1,this.contactsNewPhone="",this.contactsNewName="",this.contactsDeleteConfirmId=null,this.contactsAddFieldForId=null,this.contactsAddFieldKey="",this.contactsAddFieldValue="",this.imessageEnableConfirm=!1,this.imessageEnabling=!1,this.chatPageTab="chat",this.waConversations=[],this.waSelectedJid=null,this.waMessages=[],this.waGroupInfo=null,this.waLoading=!1,this.waMessagesLoading=!1,this.waSearchQuery="",this.waComposeDraft="",this.waSending=!1,this.waLastError=null,this.infoModalOpen=null,this.remoteAccessQrDataUrl=null,this.publicChatQrDataUrl=null,this.workspaces=[],this.workspacesLoading=!1,this.workspacesError=null,this.selectedWorkspace=null,this.addingWorkspace=!1,this.newWorkspaceName="",this.newWorkspacePath="",this.newWorkspacePin="",this.accountPinModalOpen=!1,this.accountPinBusy=!1,this.accountPinError=null,this.accountPinSuccess=null,this.apiKeyProviders=[],this.apiKeyModalOpen=!1,this.apiKeyBusy=!1,this.apiKeyError=null,this.apiKeySuccess=null,this.apiKeySavingProvider=null,this.authApiKeyMode=!1,this.authApiKeyInput="",this.authApiKeyBusy=!1,this.authApiKeyError=null,this.pinChanging=null,this.pinChangeBusy=!1,this.pinChangeError=null,this.loginChangePinMode=!1,this.changePinBusy=!1,this.changePinError=null,this.changePinSuccess=null,this.workspaceSaving=!1,this.workspaceRemoveConfirm=null,this.renamingWorkspace=!1,this.renameWorkspaceName="",this.debugLoading=!1,this.debugStatus=null,this.debugHealth=null,this.debugModels=[],this.debugHeartbeat=null,this.debugCallMethod="",this.debugCallParams="{}",this.debugCallResult=null,this.debugCallError=null,this.logsLoading=!1,this.logsError=null,this.logsFile=null,this.logsEntries=[],this.logsFilterText="",this.logsLevelFilters={...k0},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.logsDate=null,this.logsAvailableDates=[],this.logsSubTab="session",this.logsChipsExpanded=!1,this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,tool_call:!0,tool_result:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsChipsExpanded=!1,this.sessionLogsExpandedIds=new Set,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.onLoadOlder=()=>this.handleLoadOlderChat(),this.nodesPollInterval=null,this.logsPollInterval=null,this.sessionLogsPollInterval=null,this.debugPollInterval=null,this.auditPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>Xf(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null,this._beforeUnloadHandler=()=>{var t;wo();const e=this.selectedWorkspace??((t=this.publicChatConfig)==null?void 0:t.accountId)??"";e&&Wn(e,this.sessionKey,this.chatMessage)}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),$0(this),window.addEventListener("beforeunload",this._beforeUnloadHandler)}firstUpdated(){S0(this)}disconnectedCallback(){window.removeEventListener("beforeunload",this._beforeUnloadHandler),this.stopEmbeddingPoll(),A0(this),super.disconnectedCallback()}startEmbeddingPoll(){if(this.embeddingPollTimer!=null)return;const e=async()=>{if(!(!this.client||!this.connected)){try{const t=await this.client.request("memory.status",{});if((t==null?void 0:t.embeddingState)==="downloading")this.embeddingDownloading=!0;else{this.embeddingDownloading&&(this.embeddingDownloading=!1),this.stopEmbeddingPoll();return}}catch{this.embeddingDownloading=!1,this.stopEmbeddingPoll();return}this.embeddingPollTimer=window.setTimeout(e,3e3)}};e()}stopEmbeddingPoll(){this.embeddingPollTimer!=null&&(window.clearTimeout(this.embeddingPollTimer),this.embeddingPollTimer=null)}updated(e){C0(this,e)}connect(){Oe(this)}handleChatScroll(e){ch(this,e)}handleLogsScroll(e){uh(this,e)}handleSessionLogsScroll(e){ph(this,e)}exportLogs(e,t){fh(e,t)}exportSessionLogs(e,t){gh(e,t)}resetToolStream(){Zo(this)}resetChatScroll(){hh(this)}async loadAssistantIdentity(){await qo(this)}applySettings(e){at(this,e)}setTab(e){qf(this,e)}setTheme(e,t){jf(this,e,t)}async loadOverview(){await pd(this)}async loadCron(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.accountId=this.selectedWorkspace??void 0,this.cronForm={...this.cronForm,accountId:this.selectedWorkspace??void 0},await hd(this)}async handleAbortChat(){await gd(this)}removeQueuedMessage(e){ng(this,e)}async handleSendChat(e,t){await ig(this,e,t)}async handleWhatsAppStart(e,t){await T0(this,e,t)}async handleWhatsAppWait(e){await _0(this,e)}async handleWhatsAppLogout(e){await M0(this,e)}async handleAddWhatsAppAccount(e){await P0(this,e)}async handleRemoveWhatsAppAccount(e){await I0(this,e)}async handleAccessCheck(){await Cr(this)}async handlePinSubmit(e,t){await _h(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await Mh(this,e)}async handleLogout(){await Ih(this)}toggleChangePinMode(){this.loginChangePinMode=!this.loginChangePinMode,this.changePinError=null,this.changePinSuccess=null}async handleChangePin(e,t,n){if(this.client){this.changePinBusy=!0,this.changePinError=null,this.changePinSuccess=null;try{const i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.changePinError=i.message??"Incorrect current PIN",this.changePinBusy=!1;return}e==="__master__"?await this.client.request("access.setMasterPin",{pin:n}):await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.changePinSuccess="PIN changed successfully",this.changePinBusy=!1,setTimeout(()=>{this.loginChangePinMode=!1,this.changePinSuccess=null},2e3)}catch{this.changePinError="Failed to change PIN",this.changePinBusy=!1}}}async handleAccountPinSave(e,t,n){if(this.client){this.accountPinBusy=!0,this.accountPinError=null,this.accountPinSuccess=null;try{if(t!==null){const i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.accountPinError=i.message??"Incorrect current PIN",this.accountPinBusy=!1;return}}await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.accountPinSuccess="PIN saved",this.accountPinBusy=!1,await Cr(this),setTimeout(()=>{this.accountPinModalOpen=!1,this.accountPinSuccess=null,this.accountPinError=null},1500)}catch{this.accountPinError="Failed to save PIN",this.accountPinBusy=!1}}}async handleLicenseStatusCheck(){await G0(this)}async handleLicenseActivate(){await V0(this)}async handleLicenseRemove(){await Q0(this)}handleLicenseKeyChange(e){J0(this,e)}async handleAuthStatusCheck(){await K0(this)}async handleAuthStart(){await H0(this)}async handleAuthSubmitCode(e){await q0(this,e)}handleAuthCodeChange(e){j0(this,e)}handleClaudeAuthModalOpen(){this.claudeAuthModalOpen=!0}handleClaudeAuthModalClose(){this.claudeAuthModalOpen=!1,this.authUrl=null,this.authRefreshTokenInput="",this.authRefreshTokenError=null}async handleImportRefreshToken(){await z0(this)}async handleGatewayHealthCheck(){await Y0(this)}async handleGatewayRestart(){await X0(this)}async handleUpdateCheck(){await Eu(this)}async handleUpdateRun(){await Fk(this)}handleUpdateDismissResult(){zk(this)}handleUninstallConfirm(){this.uninstallConfirm=!0,this.uninstallConfirmText=""}handleUninstallCancel(){this.uninstallConfirm=!1,this.uninstallConfirmText="",this.uninstallError=null}handleUninstallConfirmTextChange(e){this.uninstallConfirmText=e}async handleUninstallRun(){const{runUninstall:e}=await ae(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Lr);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){ae(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Lr);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await ad(this)}async clearAudit(){await Af(this),this.auditModalOpen=!1}handleFilesLoad(){var n;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((n=e==null?void 0:e.agents)==null?void 0:n.map(i=>i.id))??void 0;const t=this.resolveFilesAgentId();this.filesResolvedAgentId=t,rn(this,t),cs(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();ae(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>o0);return{loadAdmins:t}},void 0,import.meta.url).then(({loadAdmins:t})=>{t(this,e)})}resolveAdminAgentId(){const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(n=>n.id.endsWith("-admin")||n.id==="admin");return t==null?void 0:t.id}resolveFilesAgentId(){var n;const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(i=>i.id.endsWith("-admin")||i.id==="admin");return(t==null?void 0:t.id)??((n=e.agents[0])==null?void 0:n.id)}handleChatLoad(){const e=this.resolveAdminAgentId();if(e){const t=`agent:${e}:main`;t!==this.sessionKey&&(this.sessionKey=t,this.chatMessages=[],this.chatStream=null,this.chatInterimText=null,this.chatRunId=null,this.chatSuggestions=[],this.resetChatScroll(),this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}ae(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this).then(()=>{sn(this,!0)})})}async handleLoadOlderChat(){if(this.chatLoadingOlder||!this.chatHistoryHasMore)return;const e=dh(this),{loadOlderChatHistory:t}=await ae(async()=>{const{loadOlderChatHistory:i}=await Promise.resolve().then(()=>Oi);return{loadOlderChatHistory:i}},void 0,import.meta.url);await t(this)&&e&&(await this.updateComplete,e())}handleAdvancedLoad(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.sessionLogsEntries=[],this.sessionLogsCursors={},this.sessionLogsAgents=[],this.advancedTab==="cron"&&this.selectedWorkspace&&this.loadCron(),this.advancedTab==="opening-hours"&&ae(async()=>{const{loadOpeningHours:n}=await Promise.resolve().then(()=>i0);return{loadOpeningHours:n}},void 0,import.meta.url).then(({loadOpeningHours:n})=>{n(this)}),this.advancedTab==="logs"&&(this.logsSubTab==="session"?ae(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>od);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):ae(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>Nh);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&ae(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>vf);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await R0(this)}async handleChannelConfigReload(){await L0(this)}handleNostrProfileEdit(e,t){B0(this,e,t)}handleNostrProfileCancel(){N0(this)}handleNostrProfileFieldChange(e,t){O0(this,e,t)}async handleNostrProfileSave(){await U0(this)}async handleNostrProfileImport(){await W0(this)}handleNostrProfileToggleAdvanced(){F0(this)}async handleExecApprovalDecision(e){const t=this.execApprovalQueue[0];if(!(!t||!this.client||this.execApprovalBusy)){this.execApprovalBusy=!0,this.execApprovalError=null;try{await this.client.request("exec.approval.resolve",{id:t.id,decision:e}),this.execApprovalQueue=this.execApprovalQueue.filter(n=>n.id!==t.id)}catch(n){this.execApprovalError=`Exec approval failed: ${String(n)}`}finally{this.execApprovalBusy=!1}}}handleOpenSidebar(e){this.sidebarCloseTimer!=null&&(window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=null),this.sidebarContent=e,this.sidebarError=null,this.sidebarOpen=!0}handleCloseSidebar(){this.sidebarOpen=!1,this.sidebarCloseTimer!=null&&window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=window.setTimeout(()=>{this.sidebarOpen||(this.sidebarContent=null,this.sidebarError=null,this.sidebarCloseTimer=null)},200)}handleSplitRatioChange(e){const t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}handleAdminsNewPhoneChange(e){this.adminsNewPhone=e,this.adminsError&&(this.adminsError=null)}handleContactsLoad(){const e=this.selectedWorkspace??void 0;ae(async()=>{const{loadContacts:t}=await Promise.resolve().then(()=>a0);return{loadContacts:t}},void 0,import.meta.url).then(({loadContacts:t})=>{t(this,e)})}handleContactsNewPhoneChange(e){this.contactsNewPhone=e,this.contactsError&&(this.contactsError=null)}handleContactsNewNameChange(e){this.contactsNewName=e,this.contactsError&&(this.contactsError=null)}async handleWorkspacesLoad(){const{loadWorkspaces:e}=await ae(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>ki);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await ae(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>ki);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await ae(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>Eh);return{loadChannels:s}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:s=>{if(!s.whatsappAccountId)return;const o=s.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await i(this,!0),await this.handleWhatsAppStart(!0,o),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(o),await i(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await ae(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>ki);return{removeWorkspace:n}},void 0,import.meta.url);await t(this,e)}handleWorkspaceRenameStart(){const e=this.getSelectedWorkspaceInfo();this.renameWorkspaceName=(e==null?void 0:e.displayName)??(e==null?void 0:e.name)??"",this.renamingWorkspace=!0}handleWorkspaceRenameCancel(){this.renamingWorkspace=!1,this.renameWorkspaceName=""}async handleWorkspaceRename(e,t){const{renameWorkspace:n}=await ae(async()=>{const{renameWorkspace:i}=await Promise.resolve().then(()=>ki);return{renameWorkspace:i}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){wo(),this.selectedWorkspace&&Wn(this.selectedWorkspace,this.sessionKey,this.chatMessage),this.selectedWorkspace=e,this.publicChatQrDataUrl=null,localStorage.setItem("taskmaster-selected-workspace",e),Tn(e),br(e),this.settings=Ls(),this.chatMessage=zn(e,this.settings.sessionKey),this.chatAttachments=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestions=[],this.chatStreamStartedAt=null,this.chatRunId=null,this.chatQueue=[],this.lastError=null,this.waConversations=[],this.waSelectedJid=null,this.waMessages=[],this.waGroupInfo=null,this.waLastError=null,this.waSearchQuery="",this.waComposeDraft="",this.reloadCurrentPageData()}getSelectedWorkspaceInfo(){return this.selectedWorkspace?this.workspaces.find(e=>e.name===this.selectedWorkspace)??null:null}reloadCurrentPageData(){this.loadAuditEntries(),this.adminsPage?this.handleAdminsLoad():this.contactsPage?this.handleContactsLoad():this.filesPage?this.handleFilesLoad():this.chatPage?(this.handleChatLoad(),this.chatPageTab==="whatsapp"&&!this.waLoading&&this.waConversations.length===0&&this.reloadWhatsAppConversations()):this.advancedPage&&this.handleAdvancedLoad()}async reloadWhatsAppConversations(){if(!(!this.client||!this.connected)){this.waLoading=!0,this.waLastError=null;try{const e=this.getSelectedWorkspaceInfo(),t=e==null?void 0:e.whatsappAccountId,n=await this.client.request("whatsapp.conversations",{accountId:t});this.waConversations=n.conversations}catch(e){this.waLastError=String(e)}finally{this.waLoading=!1}}}initWorkspaceSelection(){if(this.workspaces.length===0){this.reloadCurrentPageData();return}const e=localStorage.getItem("taskmaster-selected-workspace"),t=e?this.workspaces.find(n=>n.name===e):null;if(t)this.selectedWorkspace=t.name;else{const n=this.workspaces.find(i=>i.isDefault)??this.workspaces[0];this.selectedWorkspace=n.name,localStorage.setItem("taskmaster-selected-workspace",n.name)}Tn(this.selectedWorkspace),br(this.selectedWorkspace),this.settings=Ls(),this.chatMessage=zn(this.selectedWorkspace,this.settings.sessionKey),this.reloadCurrentPageData()}render(){return c`${v0(this)}${this.auditModalOpen?w0(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):w}`}};g([m()],f.prototype,"settings",2);g([m()],f.prototype,"password",2);g([m()],f.prototype,"tab",2);g([m()],f.prototype,"onboarding",2);g([m()],f.prototype,"setup",2);g([m()],f.prototype,"filesPage",2);g([m()],f.prototype,"browserPage",2);g([m()],f.prototype,"adminsPage",2);g([m()],f.prototype,"contactsPage",2);g([m()],f.prototype,"chatPage",2);g([m()],f.prototype,"advancedPage",2);g([m()],f.prototype,"advancedTab",2);g([m()],f.prototype,"publicChat",2);g([m()],f.prototype,"publicChatConfig",2);g([m()],f.prototype,"publicChatSessionKey",2);g([m()],f.prototype,"publicChatAuthenticated",2);g([m()],f.prototype,"publicChatAuthStep",2);g([m()],f.prototype,"connected",2);g([m()],f.prototype,"accessState",2);g([m()],f.prototype,"theme",2);g([m()],f.prototype,"themeResolved",2);g([m()],f.prototype,"hello",2);g([m()],f.prototype,"lastError",2);g([m()],f.prototype,"eventLog",2);g([m()],f.prototype,"assistantName",2);g([m()],f.prototype,"assistantAvatar",2);g([m()],f.prototype,"assistantAgentId",2);g([m()],f.prototype,"sessionKey",2);g([m()],f.prototype,"chatLoading",2);g([m()],f.prototype,"chatSending",2);g([m()],f.prototype,"chatMessage",2);g([m()],f.prototype,"chatMessages",2);g([m()],f.prototype,"chatHistoryTotal",2);g([m()],f.prototype,"chatHistoryHasMore",2);g([m()],f.prototype,"chatLoadingOlder",2);g([m()],f.prototype,"chatToolMessages",2);g([m()],f.prototype,"chatStream",2);g([m()],f.prototype,"chatInterimText",2);g([m()],f.prototype,"chatSuggestions",2);g([m()],f.prototype,"chatStreamStartedAt",2);g([m()],f.prototype,"chatRunId",2);g([m()],f.prototype,"compactionStatus",2);g([m()],f.prototype,"chatAvatarUrl",2);g([m()],f.prototype,"chatModelCatalog",2);g([m()],f.prototype,"chatVerboseLevel",2);g([m()],f.prototype,"chatQueue",2);g([m()],f.prototype,"chatAttachments",2);g([m()],f.prototype,"sidebarOpen",2);g([m()],f.prototype,"sidebarContent",2);g([m()],f.prototype,"sidebarError",2);g([m()],f.prototype,"splitRatio",2);g([m()],f.prototype,"nodesLoading",2);g([m()],f.prototype,"nodes",2);g([m()],f.prototype,"devicesLoading",2);g([m()],f.prototype,"devicesError",2);g([m()],f.prototype,"devicesList",2);g([m()],f.prototype,"execApprovalsLoading",2);g([m()],f.prototype,"execApprovalsSaving",2);g([m()],f.prototype,"execApprovalsDirty",2);g([m()],f.prototype,"execApprovalsSnapshot",2);g([m()],f.prototype,"execApprovalsForm",2);g([m()],f.prototype,"execApprovalsSelectedAgent",2);g([m()],f.prototype,"execApprovalsTarget",2);g([m()],f.prototype,"execApprovalsTargetNodeId",2);g([m()],f.prototype,"execApprovalQueue",2);g([m()],f.prototype,"execApprovalBusy",2);g([m()],f.prototype,"execApprovalError",2);g([m()],f.prototype,"configLoading",2);g([m()],f.prototype,"configRaw",2);g([m()],f.prototype,"configRawOriginal",2);g([m()],f.prototype,"configValid",2);g([m()],f.prototype,"configIssues",2);g([m()],f.prototype,"configSaving",2);g([m()],f.prototype,"configApplying",2);g([m()],f.prototype,"updateRunning",2);g([m()],f.prototype,"applySessionKey",2);g([m()],f.prototype,"configSnapshot",2);g([m()],f.prototype,"configSchema",2);g([m()],f.prototype,"configSchemaVersion",2);g([m()],f.prototype,"configSchemaLoading",2);g([m()],f.prototype,"configUiHints",2);g([m()],f.prototype,"configForm",2);g([m()],f.prototype,"configFormOriginal",2);g([m()],f.prototype,"configFormDirty",2);g([m()],f.prototype,"configFormMode",2);g([m()],f.prototype,"configSearchQuery",2);g([m()],f.prototype,"configActiveSection",2);g([m()],f.prototype,"configActiveSubsection",2);g([m()],f.prototype,"channelsLoading",2);g([m()],f.prototype,"channelsSnapshot",2);g([m()],f.prototype,"channelsError",2);g([m()],f.prototype,"channelsLastSuccess",2);g([m()],f.prototype,"whatsappLoginMessage",2);g([m()],f.prototype,"whatsappLoginQrDataUrl",2);g([m()],f.prototype,"whatsappLoginConnected",2);g([m()],f.prototype,"whatsappBusy",2);g([m()],f.prototype,"whatsappActiveQrAccountId",2);g([m()],f.prototype,"whatsappPairedPhone",2);g([m()],f.prototype,"addingWhatsAppAccount",2);g([m()],f.prototype,"newWhatsAppAccountName",2);g([m()],f.prototype,"whatsappAccountError",2);g([m()],f.prototype,"whatsappAccountSaving",2);g([m()],f.prototype,"whatsappSettingsOpen",2);g([m()],f.prototype,"publicChatToggleBusy",2);g([m()],f.prototype,"publicChatGreetingBusy",2);g([m()],f.prototype,"publicChatEmailBusy",2);g([m()],f.prototype,"publicChatSettingsOpen",2);g([m()],f.prototype,"publicChatWidgetModalOpen",2);g([m()],f.prototype,"brandingBusy",2);g([m()],f.prototype,"agentSettingsOpen",2);g([m()],f.prototype,"brandingExpanded",2);g([m()],f.prototype,"tailscaleStatus",2);g([m()],f.prototype,"tailscaleBusy",2);g([m()],f.prototype,"tailscaleAuthUrl",2);g([m()],f.prototype,"tailscaleError",2);g([m()],f.prototype,"tailscaleServeEnableUrl",2);g([m()],f.prototype,"tailscaleFunnelEnableUrl",2);g([m()],f.prototype,"tailscaleDisableConfirm",2);g([m()],f.prototype,"tailscaleConnectProgress",2);g([m()],f.prototype,"tailscaleConnectMessage",2);g([m()],f.prototype,"tailscaleConnectSuccess",2);g([m()],f.prototype,"wifiStatus",2);g([m()],f.prototype,"wifiNetworks",2);g([m()],f.prototype,"wifiBusy",2);g([m()],f.prototype,"wifiError",2);g([m()],f.prototype,"wifiPassword",2);g([m()],f.prototype,"wifiSelectedSsid",2);g([m()],f.prototype,"networkPort",2);g([m()],f.prototype,"networkHostname",2);g([m()],f.prototype,"networkPortInput",2);g([m()],f.prototype,"networkHostnameInput",2);g([m()],f.prototype,"networkModalOpen",2);g([m()],f.prototype,"networkBusy",2);g([m()],f.prototype,"networkError",2);g([m()],f.prototype,"networkSuccess",2);g([m()],f.prototype,"wifiModalOpen",2);g([m()],f.prototype,"licenseKey",2);g([m()],f.prototype,"licenseBusy",2);g([m()],f.prototype,"licenseValid",2);g([m()],f.prototype,"licenseMessage",2);g([m()],f.prototype,"licenseTier",2);g([m()],f.prototype,"licenseDeviceId",2);g([m()],f.prototype,"licenseStoredKey",2);g([m()],f.prototype,"licenseRemoveConfirm",2);g([m()],f.prototype,"authConnected",2);g([m()],f.prototype,"authBusy",2);g([m()],f.prototype,"authMessage",2);g([m()],f.prototype,"authUrl",2);g([m()],f.prototype,"authCodeInput",2);g([m()],f.prototype,"authExpiresIn",2);g([m()],f.prototype,"authRefreshToken",2);g([m()],f.prototype,"claudeAuthModalOpen",2);g([m()],f.prototype,"authRefreshTokenInput",2);g([m()],f.prototype,"authRefreshTokenBusy",2);g([m()],f.prototype,"authRefreshTokenError",2);g([m()],f.prototype,"setupStep",2);g([m()],f.prototype,"gatewayHealthy",2);g([m()],f.prototype,"gatewayHealthLoading",2);g([m()],f.prototype,"gatewayHealthMessage",2);g([m()],f.prototype,"gatewayRestartBusy",2);g([m()],f.prototype,"updateAvailable",2);g([m()],f.prototype,"currentVersion",2);g([m()],f.prototype,"latestVersion",2);g([m()],f.prototype,"updateChecking",2);g([m()],f.prototype,"updateMessage",2);g([m()],f.prototype,"updateProgressSteps",2);g([m()],f.prototype,"updateLastResult",2);g([m()],f.prototype,"uninstallConfirm",2);g([m()],f.prototype,"uninstallBusy",2);g([m()],f.prototype,"uninstallDone",2);g([m()],f.prototype,"uninstallError",2);g([m()],f.prototype,"uninstallConfirmText",2);g([m()],f.prototype,"nostrProfileFormState",2);g([m()],f.prototype,"nostrProfileAccountId",2);g([m()],f.prototype,"presenceLoading",2);g([m()],f.prototype,"presenceEntries",2);g([m()],f.prototype,"presenceError",2);g([m()],f.prototype,"presenceStatus",2);g([m()],f.prototype,"agentsLoading",2);g([m()],f.prototype,"agentsList",2);g([m()],f.prototype,"agentsError",2);g([m()],f.prototype,"sessionsLoading",2);g([m()],f.prototype,"sessionsResult",2);g([m()],f.prototype,"sessionsError",2);g([m()],f.prototype,"cronLoading",2);g([m()],f.prototype,"cronJobs",2);g([m()],f.prototype,"cronStatus",2);g([m()],f.prototype,"cronError",2);g([m()],f.prototype,"cronForm",2);g([m()],f.prototype,"cronRunsJobId",2);g([m()],f.prototype,"cronRuns",2);g([m()],f.prototype,"cronBusy",2);g([m()],f.prototype,"cronNewEventModal",2);g([m()],f.prototype,"cronDetailJobId",2);g([m()],f.prototype,"cronEditJobId",2);g([m()],f.prototype,"cronPendingDeleteId",2);g([m()],f.prototype,"cronRunModalJobId",2);g([m()],f.prototype,"cronRunModalJobName",2);g([m()],f.prototype,"cronRunResult",2);g([m()],f.prototype,"openingHoursLoading",2);g([m()],f.prototype,"openingHoursError",2);g([m()],f.prototype,"openingHoursBusy",2);g([m()],f.prototype,"openingHoursForm",2);g([m()],f.prototype,"browserScreencastActive",2);g([m()],f.prototype,"browserScreencastFrame",2);g([m()],f.prototype,"browserScreencastMetadata",2);g([m()],f.prototype,"browserHandoffPending",2);g([m()],f.prototype,"browserHandoffReason",2);g([m()],f.prototype,"browserHandoffId",2);g([m()],f.prototype,"browserInputMode",2);g([m()],f.prototype,"browserFullscreen",2);g([m()],f.prototype,"browserLoading",2);g([m()],f.prototype,"browserError",2);g([m()],f.prototype,"filesLoading",2);g([m()],f.prototype,"filesTree",2);g([m()],f.prototype,"filesRoot",2);g([m()],f.prototype,"filesError",2);g([m()],f.prototype,"filesSelectedPath",2);g([m()],f.prototype,"filesSelectedPaths",2);g([m()],f.prototype,"filesPreviewContent",2);g([m()],f.prototype,"filesPreviewLoading",2);g([m()],f.prototype,"filesPreviewBinary",2);g([m()],f.prototype,"filesPreviewSize",2);g([m()],f.prototype,"filesExpandedDirs",2);g([m()],f.prototype,"filesCurrentDir",2);g([m()],f.prototype,"filesPendingDeletePath",2);g([m()],f.prototype,"filesMessage",2);g([m()],f.prototype,"filesUploadBusy",2);g([m()],f.prototype,"filesReindexBusy",2);g([m()],f.prototype,"filesMemoryStatus",2);g([m()],f.prototype,"embeddingDownloading",2);g([m()],f.prototype,"filesSearchQuery",2);g([m()],f.prototype,"filesSearchResults",2);g([m()],f.prototype,"filesSearchLoading",2);g([m()],f.prototype,"filesSearchAgentId",2);g([m()],f.prototype,"auditEntries",2);g([m()],f.prototype,"auditLoading",2);g([m()],f.prototype,"auditModalOpen",2);g([m()],f.prototype,"skillsLoading",2);g([m()],f.prototype,"skillsReport",2);g([m()],f.prototype,"skillsError",2);g([m()],f.prototype,"skillsFilter",2);g([m()],f.prototype,"skillsTypeFilter",2);g([m()],f.prototype,"skillsAgentFilter",2);g([m()],f.prototype,"skillEdits",2);g([m()],f.prototype,"skillsBusyKey",2);g([m()],f.prototype,"skillMessages",2);g([m()],f.prototype,"skillDetail",2);g([m()],f.prototype,"skillDetailTab",2);g([m()],f.prototype,"skillAddModal",2);g([m()],f.prototype,"skillAddForm",2);g([m()],f.prototype,"skillAddFormSource",2);g([m()],f.prototype,"skillEditTab",2);g([m()],f.prototype,"skillDrafts",2);g([m()],f.prototype,"adminsLoading",2);g([m()],f.prototype,"adminPhones",2);g([m()],f.prototype,"adminsError",2);g([m()],f.prototype,"adminsSaving",2);g([m()],f.prototype,"adminsNewPhone",2);g([m()],f.prototype,"contactsLoading",2);g([m()],f.prototype,"contactsSaving",2);g([m()],f.prototype,"contactsRecords",2);g([m()],f.prototype,"contactsError",2);g([m()],f.prototype,"contactsSearchQuery",2);g([m()],f.prototype,"contactsEditingId",2);g([m()],f.prototype,"contactsShowAddForm",2);g([m()],f.prototype,"contactsNewPhone",2);g([m()],f.prototype,"contactsNewName",2);g([m()],f.prototype,"contactsDeleteConfirmId",2);g([m()],f.prototype,"contactsAddFieldForId",2);g([m()],f.prototype,"contactsAddFieldKey",2);g([m()],f.prototype,"contactsAddFieldValue",2);g([m()],f.prototype,"imessageEnableConfirm",2);g([m()],f.prototype,"imessageEnabling",2);g([m()],f.prototype,"chatPageTab",2);g([m()],f.prototype,"waConversations",2);g([m()],f.prototype,"waSelectedJid",2);g([m()],f.prototype,"waMessages",2);g([m()],f.prototype,"waGroupInfo",2);g([m()],f.prototype,"waLoading",2);g([m()],f.prototype,"waMessagesLoading",2);g([m()],f.prototype,"waSearchQuery",2);g([m()],f.prototype,"waComposeDraft",2);g([m()],f.prototype,"waSending",2);g([m()],f.prototype,"waLastError",2);g([m()],f.prototype,"infoModalOpen",2);g([m()],f.prototype,"remoteAccessQrDataUrl",2);g([m()],f.prototype,"publicChatQrDataUrl",2);g([m()],f.prototype,"workspaces",2);g([m()],f.prototype,"workspacesLoading",2);g([m()],f.prototype,"workspacesError",2);g([m()],f.prototype,"selectedWorkspace",2);g([m()],f.prototype,"addingWorkspace",2);g([m()],f.prototype,"newWorkspaceName",2);g([m()],f.prototype,"newWorkspacePath",2);g([m()],f.prototype,"newWorkspacePin",2);g([m()],f.prototype,"accountPinModalOpen",2);g([m()],f.prototype,"accountPinBusy",2);g([m()],f.prototype,"accountPinError",2);g([m()],f.prototype,"accountPinSuccess",2);g([m()],f.prototype,"apiKeyProviders",2);g([m()],f.prototype,"apiKeyModalOpen",2);g([m()],f.prototype,"apiKeyBusy",2);g([m()],f.prototype,"apiKeyError",2);g([m()],f.prototype,"apiKeySuccess",2);g([m()],f.prototype,"apiKeySavingProvider",2);g([m()],f.prototype,"authApiKeyMode",2);g([m()],f.prototype,"authApiKeyInput",2);g([m()],f.prototype,"authApiKeyBusy",2);g([m()],f.prototype,"authApiKeyError",2);g([m()],f.prototype,"pinChanging",2);g([m()],f.prototype,"pinChangeBusy",2);g([m()],f.prototype,"pinChangeError",2);g([m()],f.prototype,"loginChangePinMode",2);g([m()],f.prototype,"changePinBusy",2);g([m()],f.prototype,"changePinError",2);g([m()],f.prototype,"changePinSuccess",2);g([m()],f.prototype,"workspaceSaving",2);g([m()],f.prototype,"workspaceRemoveConfirm",2);g([m()],f.prototype,"renamingWorkspace",2);g([m()],f.prototype,"renameWorkspaceName",2);g([m()],f.prototype,"debugLoading",2);g([m()],f.prototype,"debugStatus",2);g([m()],f.prototype,"debugHealth",2);g([m()],f.prototype,"debugModels",2);g([m()],f.prototype,"debugHeartbeat",2);g([m()],f.prototype,"debugCallMethod",2);g([m()],f.prototype,"debugCallParams",2);g([m()],f.prototype,"debugCallResult",2);g([m()],f.prototype,"debugCallError",2);g([m()],f.prototype,"logsLoading",2);g([m()],f.prototype,"logsError",2);g([m()],f.prototype,"logsFile",2);g([m()],f.prototype,"logsEntries",2);g([m()],f.prototype,"logsFilterText",2);g([m()],f.prototype,"logsLevelFilters",2);g([m()],f.prototype,"logsAutoFollow",2);g([m()],f.prototype,"logsTruncated",2);g([m()],f.prototype,"logsCursor",2);g([m()],f.prototype,"logsLastFetchAt",2);g([m()],f.prototype,"logsLimit",2);g([m()],f.prototype,"logsMaxBytes",2);g([m()],f.prototype,"logsAtBottom",2);g([m()],f.prototype,"logsDate",2);g([m()],f.prototype,"logsAvailableDates",2);g([m()],f.prototype,"logsSubTab",2);g([m()],f.prototype,"logsChipsExpanded",2);g([m()],f.prototype,"sessionLogsLoading",2);g([m()],f.prototype,"sessionLogsError",2);g([m()],f.prototype,"sessionLogsEntries",2);g([m()],f.prototype,"sessionLogsFilterText",2);g([m()],f.prototype,"sessionLogsTypeFilters",2);g([m()],f.prototype,"sessionLogsAgentFilters",2);g([m()],f.prototype,"sessionLogsAgents",2);g([m()],f.prototype,"sessionLogsAutoFollow",2);g([m()],f.prototype,"sessionLogsChipsExpanded",2);g([m()],f.prototype,"sessionLogsCursors",2);g([m()],f.prototype,"sessionLogsLastFetchAt",2);g([m()],f.prototype,"sessionLogsAtBottom",2);g([m()],f.prototype,"chatUserNearBottom",2);f=g([ql("taskmaster-app")],f);
|
|
4944
|
-
//# sourceMappingURL=index-
|
|
4934
|
+
//# sourceMappingURL=index-B9ScTH-4.js.map
|