openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
4,503 lines • 583 kB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./agents-B-6PXFWd.js","./lit-BZwq2xLD.js","./format-DeRVtGzv.js","./channel-config-extras-UBRJa-vU.js","./skills-shared-CPLqvR1x.js","./channels-DcDh7rxN.js","./cron-DwIMARE-.js","./debug-YIHGg52o.js","./instances-C8om8LL2.js","./logs-BbHV8FOx.js","./nodes-BXlsFQVB.js","./sessions-DMIQd5yR.js","./skills-BaxA3XRt.js"])))=>i.map(i=>d[i]);
import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"./lit-BZwq2xLD.js";import{a as l,c as u,d,i as f,l as p,n as m,o as h,s as g,u as _}from"./format-DeRVtGzv.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var v=e=>(t,n)=>{n===void 0?customElements.define(e,t):n.addInitializer(()=>{customElements.define(e,t)})},y={attribute:!0,type:String,converter:t,reflect:!1,hasChanged:s},b=(e=y,t,n)=>{let{kind:r,metadata:i}=n,a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),r===`setter`&&((e=Object.create(e)).wrapped=!0),a.set(n.name,e),r===`accessor`){let{name:r}=n;return{set(n){let i=t.get.call(this);t.set.call(this,n),this.requestUpdate(r,i,e,!0,n)},init(t){return t!==void 0&&this.C(r,void 0,e,t),t}}}if(r===`setter`){let{name:r}=n;return function(n){let i=this[r];t.call(this,n),this.requestUpdate(r,i,e,!0,n)}}throw Error(`Unsupported decorator location: `+r)};function x(e){return(t,n)=>typeof n==`object`?b(e,t,n):((e,t,n)=>{let r=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),r?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)}function S(e){return x({...e,state:!0,attribute:!1})}function C(e){return!!e&&typeof e.getItem==`function`&&typeof e.setItem==`function`}function w(){let e=Object.getOwnPropertyDescriptor(globalThis,`localStorage`);if(typeof process<`u`&&{}?.VITEST)return e&&!e.get&&C(e.value)?e.value:null;if(typeof window<`u`&&typeof document<`u`)try{return C(window.localStorage)?window.localStorage:null}catch{return null}return e&&!e.get&&C(e.value)?e.value:null}var T={common:{health:`Health`,ok:`OK`,online:`Online`,offline:`Offline`,connect:`Connect`,refresh:`Refresh`,enabled:`Enabled`,disabled:`Disabled`,na:`n/a`,version:`Version`,docs:`Docs`,theme:`Theme`,resources:`Resources`,search:`Search`},nav:{chat:`Chat`,control:`Control`,agent:`Agent`,settings:`Settings`,expand:`Expand sidebar`,collapse:`Collapse sidebar`,resize:`Resize sidebar`},tabs:{agents:`Agents`,overview:`Overview`,channels:`Channels`,instances:`Instances`,sessions:`Sessions`,usage:`Usage`,cron:`Cron Jobs`,skills:`Skills`,nodes:`Nodes`,chat:`Chat`,config:`Config`,communications:`Communications`,appearance:`Appearance`,automation:`Automation`,infrastructure:`Infrastructure`,aiAgents:`AI & Agents`,debug:`Debug`,logs:`Logs`},subtitles:{agents:`Workspaces, tools, identities.`,overview:`Status, entry points, health.`,channels:`Channels and settings.`,instances:`Connected clients and nodes.`,sessions:`Active sessions and defaults.`,usage:`API usage and costs.`,cron:`Wakeups and recurring runs.`,skills:`Skills and API keys.`,nodes:`Paired devices and commands.`,chat:`Gateway chat for quick interventions.`,config:`Edit openclaw.json.`,communications:`Channels, messages, and audio settings.`,appearance:`Theme, UI, and setup wizard settings.`,automation:`Commands, hooks, cron, and plugins.`,infrastructure:`Gateway, web, browser, and media settings.`,aiAgents:`Agents, models, skills, tools, memory, session.`,debug:`Snapshots, events, RPC.`,logs:`Live gateway logs.`},overview:{access:{title:`Gateway Access`,subtitle:`Where the dashboard connects and how it authenticates.`,wsUrl:`WebSocket URL`,token:`Gateway Token`,password:`Password (not stored)`,sessionKey:`Default Session Key`,language:`Language`,connectHint:`Click Connect to apply connection changes.`,trustedProxy:`Authenticated via trusted proxy.`},snapshot:{title:`Snapshot`,subtitle:`Latest gateway handshake information.`,status:`Status`,uptime:`Uptime`,tickInterval:`Tick Interval`,lastChannelsRefresh:`Last Channels Refresh`,channelsHint:`Use Channels to link WhatsApp, Telegram, Discord, Signal, or iMessage.`},stats:{instances:`Instances`,instancesHint:`Presence beacons in the last 5 minutes.`,sessions:`Sessions`,sessionsHint:`Recent session keys tracked by the gateway.`,cron:`Cron`,cronNext:`Next wake {time}`},notes:{title:`Notes`,subtitle:`Quick reminders for remote control setups.`,tailscaleTitle:`Tailscale serve`,tailscaleText:`Prefer serve mode to keep the gateway on loopback with tailnet auth.`,sessionTitle:`Session hygiene`,sessionText:`Use /new or sessions.patch to reset context.`,cronTitle:`Cron reminders`,cronText:`Use isolated sessions for recurring runs.`},auth:{required:`This gateway requires auth. Add a token or password, then click Connect.`,failed:`Auth failed. Re-copy a tokenized URL with {command}, or update the token, then click Connect.`},pairing:{hint:`This device needs pairing approval from the gateway host.`,mobileHint:`On mobile? Copy the full URL (including #token=...) from openclaw dashboard --no-open on your desktop.`},insecure:{hint:`This page is HTTP, so the browser blocks device identity. Use HTTPS (Tailscale Serve) or open {url} on the gateway host.`,stayHttp:`If you must stay on HTTP, set {config} (token-only).`},connection:{title:`How to connect`,step1:`Start the gateway on your host machine:`,step2:`Get a tokenized dashboard URL:`,step3:`Paste the WebSocket URL and token above, or open the tokenized URL directly.`,step4:`Or generate a reusable token:`,docsHint:`For remote access, Tailscale Serve is recommended. `,docsLink:`Read the docs →`},cards:{cost:`Cost`,skills:`Skills`,recentSessions:`Recent Sessions`},attention:{title:`Attention`},eventLog:{title:`Event Log`},logTail:{title:`Gateway Logs`},quickActions:{newSession:`New Session`,automation:`Automation`,refreshAll:`Refresh All`,terminal:`Terminal`},palette:{placeholder:`Type a command…`,noResults:`No results`}},usage:{page:{subtitle:`See where tokens go, when sessions spike, and what drives cost.`},common:{emptyValue:`—`,unknown:`unknown`},loading:{title:`Usage Overview`,badge:`Loading`},metrics:{tokens:`Tokens`,cost:`Cost`,session:`session`,sessions:`sessions`},presets:{today:`Today`,last7d:`7d`,last30d:`30d`},filters:{title:`Filters`,to:`to`,startDate:`Start date`,endDate:`End date`,timeZone:`Time zone`,timeZoneLocal:`Local`,timeZoneUtc:`UTC`,pin:`Pin`,pinned:`Pinned`,unpin:`Unpin filters`,selectAll:`Select All`,clear:`Clear`,clearAll:`Clear All`,remove:`Remove filter`,all:`All`,days:`Days`,hours:`Hours`,session:`Session`,agent:`Agent`,channel:`Channel`,provider:`Provider`,model:`Model`,tool:`Tool`,daysCount:`{count} days`,hoursCount:`{count} hours`,sessionsCount:`{count} sessions`},query:{placeholder:`Filter sessions (e.g. key:agent:main:cron* model:gpt-4o has:errors minTokens:2000)`,apply:`Filter (client-side)`,matching:`{shown} of {total} sessions match`,inRange:`{total} sessions in range`,tip:`Tip: use filters or click bars to refine days.`},export:{label:`Export`,sessionsCsv:`Sessions CSV`,dailyCsv:`Daily CSV`,json:`JSON`},empty:{title:`Start with a date range`,subtitle:`Load usage data to compare costs, inspect sessions, and drill into timelines without leaving the dashboard.`,hint:`Select a date range and click Refresh to load usage.`,noData:`No data`,featureOverview:`Overview cards`,featureSessions:`Session ranking`,featureTimeline:`Timeline drilldown`},daily:{title:`Daily Usage`,total:`Total`,byType:`By Type`,tokensTitle:`Daily Token Usage`,costTitle:`Daily Cost`},breakdown:{output:`Output`,input:`Input`,cacheWrite:`Cache Write`,cacheRead:`Cache Read`,total:`Total`,tokensByType:`Tokens by Type`,costByType:`Cost by Type`},overview:{title:`Usage Overview`,messages:`Messages`,messagesHint:`Total user and assistant messages in range.`,messagesAbbrev:`msgs`,user:`user`,assistant:`assistant`,toolCalls:`Tool Calls`,toolCallsHint:`Total tool call count across sessions.`,toolsUsed:`tools used`,errors:`Errors`,errorsHint:`Total message and tool errors in range.`,toolResults:`tool results`,avgTokens:`Avg Tokens / Msg`,avgTokensHint:`Average tokens per message in this range.`,avgCost:`Avg Cost / Msg`,avgCostHint:`Average cost per message when providers report costs.`,avgCostHintMissing:`Average cost per message when providers report costs. Cost data is missing for some or all sessions in this range.`,acrossMessages:`Across {count} messages`,sessions:`Sessions`,sessionsHint:`Distinct sessions in the range.`,sessionsInRange:`of {count} in range`,throughput:`Throughput`,throughputHint:`Throughput shows tokens per minute over active time. Higher is better.`,tokensPerMinute:`tok/min`,perMinute:`/ min`,errorRate:`Error Rate`,errorHint:`Error rate = errors / total messages. Lower is better.`,avgSession:`avg session`,cacheHitRate:`Cache Hit Rate`,cacheHint:`Cache hit rate = cache read / (input + cache read). Higher is better.`,cached:`cached`,prompt:`prompt`,calls:`calls`,topModels:`Top Models`,topProviders:`Top Providers`,topTools:`Top Tools`,topAgents:`Top Agents`,topChannels:`Top Channels`,peakErrorDays:`Peak Error Days`,peakErrorHours:`Peak Error Hours`,noModelData:`No model data`,noProviderData:`No provider data`,noToolCalls:`No tool calls`,noAgentData:`No agent data`,noChannelData:`No channel data`,noErrorData:`No error data`},sessions:{title:`Sessions`,shown:`{count} shown`,total:`{count} total`,avg:`avg`,all:`All`,recent:`Recently viewed`,recentShort:`Recent`,sort:`Sort`,ascending:`Ascending`,descending:`Descending`,clearSelection:`Clear Selection`,noRecent:`No recent sessions`,noneInRange:`No sessions in range`,more:`+{count} more`,selected:`Selected ({count})`,copy:`Copy`,copyName:`Copy session name`,limitReached:`Showing first 1,000 sessions. Narrow date range for complete results.`},details:{noUsageData:`No usage data for this session.`,duration:`Duration`,modelMix:`Model Mix`,filtered:`(filtered)`,close:`Close session details`,noTimeline:`No timeline data`,noDataInRange:`No data in range`,usageOverTime:`Usage Over Time`,reset:`Reset`,perTurn:`Per Turn`,cumulative:`Cumulative`,turnRange:`Turns {start}–{end} of {total}`,assistantOutputTokens:`Assistant output tokens`,userToolInputTokens:`User + tool input tokens`,tokensWrittenToCache:`Tokens written to cache`,tokensReadFromCache:`Tokens read from cache`,noContextData:`No context data`,systemPromptBreakdown:`System Prompt Breakdown`,collapse:`Collapse`,collapseAll:`Collapse All`,expandAll:`Expand All`,baseContextPerMessage:`Base context per message`,system:`System`,systemShort:`Sys`,skills:`Skills`,tools:`Tools`,files:`Files`,ofInput:`of input`,of:`of`,timelineFiltered:`timeline filtered`,conversation:`Conversation`,noMessages:`No messages`,tool:`Tool`,toolResult:`Tool result`,hasTools:`Has tools`,searchConversation:`Search conversation`,you:`You`,noMessagesMatch:`No messages match the filters.`},mosaic:{title:`Activity by Time`,subtitleEmpty:`Estimates require session timestamps.`,subtitle:`Estimated from session spans (first/last activity). Time zone: {zone}.`,noTimelineData:`No timeline data yet.`,dayOfWeek:`Day of Week`,midnight:`Midnight`,fourAm:`4am`,eightAm:`8am`,noon:`Noon`,fourPm:`4pm`,eightPm:`8pm`,legend:`Low → High token density`,sun:`Sun`,mon:`Mon`,tue:`Tue`,wed:`Wed`,thu:`Thu`,fri:`Fri`,sat:`Sat`}},login:{subtitle:`Gateway Dashboard`,passwordPlaceholder:`optional`},chat:{disconnected:`Disconnected from gateway.`,refreshTitle:`Refresh chat data`,thinkingToggle:`Toggle assistant thinking/working output`,toolCallsToggle:`Toggle tool calls and tool results`,focusToggle:`Toggle focus mode (hide sidebar + page header)`,hideCronSessions:`Hide cron sessions`,showCronSessions:`Show cron sessions`,showCronSessionsHidden:`Show cron sessions ({count} hidden)`,onboardingDisabled:`Disabled during setup`},languages:{en:`English`,zhCN:`简体中文 (Simplified Chinese)`,zhTW:`繁體中文 (Traditional Chinese)`,ptBR:`Português (Brazilian Portuguese)`,de:`Deutsch (German)`,es:`Español (Spanish)`},cron:{summary:{enabled:`Enabled`,yes:`Yes`,no:`No`,jobs:`Jobs`,nextWake:`Next wake`,refreshing:`Refreshing...`,refresh:`Refresh`},jobs:{title:`Jobs`,subtitle:`All scheduled jobs stored in the gateway.`,shownOf:`{shown} shown of {total}`,searchJobs:`Search jobs`,searchPlaceholder:`Name, description, or agent`,enabled:`Enabled`,schedule:`Schedule`,lastRun:`Last run`,all:`All`,sort:`Sort`,nextRun:`Next run`,recentlyUpdated:`Recently updated`,name:`Name`,direction:`Direction`,ascending:`Ascending`,descending:`Descending`,reset:`Reset`,noMatching:`No matching jobs.`,loading:`Loading...`,loadMore:`Load more jobs`},runs:{title:`Run history`,subtitleAll:`Latest runs across all jobs.`,subtitleJob:`Latest runs for {title}.`,scope:`Scope`,allJobs:`All jobs`,selectedJob:`Selected job`,searchRuns:`Search runs`,searchPlaceholder:`Summary, error, or job`,newestFirst:`Newest first`,oldestFirst:`Oldest first`,status:`Status`,delivery:`Delivery`,clear:`Clear`,allStatuses:`All statuses`,allDelivery:`All delivery`,selectJobHint:`Select a job to inspect run history.`,noMatching:`No matching runs.`,loadMore:`Load more runs`,runStatusOk:`OK`,runStatusError:`Error`,runStatusSkipped:`Skipped`,runStatusUnknown:`Unknown`,deliveryDelivered:`Delivered`,deliveryNotDelivered:`Not delivered`,deliveryUnknown:`Unknown`,deliveryNotRequested:`Not requested`},form:{editJob:`Edit Job`,newJob:`New Job`,updateSubtitle:`Update the selected scheduled job.`,createSubtitle:`Create a scheduled wakeup or agent run.`,required:`Required`,requiredSr:`required`,basics:`Basics`,basicsSub:`Name it, choose the assistant, and set enabled state.`,fieldName:`Name`,description:`Description`,agentId:`Agent ID`,namePlaceholder:`Morning brief`,descriptionPlaceholder:`Optional context for this job`,agentPlaceholder:`main or ops`,agentHelp:`Start typing to pick a known agent, or enter a custom one.`,schedule:`Schedule`,scheduleSub:`Control when this job runs.`,every:`Every`,at:`At`,cronOption:`Cron`,runAt:`Run at`,unit:`Unit`,minutes:`Minutes`,hours:`Hours`,days:`Days`,expression:`Expression`,expressionPlaceholder:`0 7 * * *`,everyAmountPlaceholder:`30`,timezoneOptional:`Timezone (optional)`,timezonePlaceholder:`America/Los_Angeles`,timezoneHelp:`Pick a common timezone or enter any valid IANA timezone.`,jitterHelp:`Need jitter? Use Advanced → Stagger window / Stagger unit.`,execution:`Execution`,executionSub:`Choose when to wake, and what this job should do.`,session:`Session`,main:`Main`,isolated:`Isolated`,sessionHelp:`Main posts a system event. Isolated runs a dedicated agent turn.`,wakeMode:`Wake mode`,now:`Now`,nextHeartbeat:`Next heartbeat`,wakeModeHelp:`Now triggers immediately. Next heartbeat waits for the next cycle.`,payloadKind:`What should run?`,systemEvent:`Post message to main timeline`,agentTurn:`Run assistant task (isolated)`,systemEventHelp:`Sends your text to the gateway main timeline (good for reminders/triggers).`,agentTurnHelp:`Starts an assistant run in its own session using your prompt.`,timeoutSeconds:`Timeout (seconds)`,timeoutPlaceholder:`Optional, e.g. 90`,timeoutHelp:`Optional. Leave blank to use the gateway default timeout behavior for this run.`,mainTimelineMessage:`Main timeline message`,assistantTaskPrompt:`Assistant task prompt`,deliverySection:`Delivery`,deliverySub:`Choose where run summaries are sent.`,resultDelivery:`Result delivery`,announceDefault:`Announce summary (default)`,webhookPost:`Webhook POST`,noneInternal:`None (internal)`,deliveryHelp:`Announce posts a summary to chat. None keeps execution internal.`,webhookUrl:`Webhook URL`,channel:`Channel`,webhookPlaceholder:`https://example.com/cron`,channelHelp:`Choose which connected channel receives the summary.`,webhookHelp:`Send run summaries to a webhook endpoint.`,to:`To`,toPlaceholder:`+1555... or chat id`,toHelp:`Optional recipient override (chat id, phone, or user id).`,advanced:`Advanced`,advancedHelp:`Optional overrides for delivery guarantees, schedule jitter, and model controls.`,deleteAfterRun:`Delete after run`,deleteAfterRunHelp:`Best for one-shot reminders that should auto-clean up.`,clearAgentOverride:`Clear agent override`,clearAgentHelp:`Force this job to use the gateway default assistant.`,exactTiming:`Exact timing (no stagger)`,exactTimingHelp:`Run on exact cron boundaries with no spread.`,staggerWindow:`Stagger window`,staggerUnit:`Stagger unit`,staggerPlaceholder:`30`,seconds:`Seconds`,model:`Model`,modelPlaceholder:`openai/gpt-5.2`,modelHelp:`Start typing to pick a known model, or enter a custom one.`,thinking:`Thinking`,thinkingPlaceholder:`low`,thinkingHelp:`Use a suggested level or enter a provider-specific value.`,bestEffortDelivery:`Best effort delivery`,bestEffortHelp:`Do not fail the job if delivery itself fails.`,cantAddYet:`Can't add job yet`,fillRequired:`Fill the required fields below to enable submit.`,fixFields:`Fix {count} field to continue.`,fixFieldsPlural:`Fix {count} fields to continue.`,saving:`Saving...`,saveChanges:`Save changes`,addJob:`Add job`,cancel:`Cancel`},jobList:{allJobs:`all jobs`,selectJob:`(select a job)`,enabled:`enabled`,disabled:`disabled`,edit:`Edit`,clone:`Clone`,disable:`Disable`,enable:`Enable`,run:`Run`,history:`History`,remove:`Remove`},jobDetail:{system:`System`,prompt:`Prompt`,delivery:`Delivery`,agent:`Agent`},jobState:{status:`Status`,next:`Next`,last:`Last`},runEntry:{noSummary:`No summary.`,runAt:`Run at`,openRunChat:`Open run chat`,next:`Next {rel}`,due:`Due {rel}`},errors:{nameRequired:`Name is required.`,scheduleAtInvalid:`Enter a valid date/time.`,everyAmountInvalid:`Interval must be greater than 0.`,cronExprRequired:`Cron expression is required.`,staggerAmountInvalid:`Stagger must be greater than 0.`,systemTextRequired:`System text is required.`,agentMessageRequired:`Agent message is required.`,timeoutInvalid:`If set, timeout must be greater than 0 seconds.`,webhookUrlRequired:`Webhook URL is required.`,webhookUrlInvalid:`Webhook URL must start with http:// or https://.`,invalidRunTime:`Invalid run time.`,invalidIntervalAmount:`Invalid interval amount.`,cronExprRequiredShort:`Cron expression required.`,invalidStaggerAmount:`Invalid stagger amount.`,systemEventTextRequired:`System event text required.`,agentMessageRequiredShort:`Agent message required.`,nameRequiredShort:`Name required.`}}},E=`modulepreload`,D=function(e,t){return new URL(e,t).href},O={},k=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=D(t,n),t in O)return;O[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:E,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},A=[`zh-CN`,`zh-TW`,`pt-BR`,`de`,`es`],ee={"zh-CN":{exportName:`zh_CN`,loader:()=>k(()=>import(`./zh-CN-DYuK7yBr.js`),[],import.meta.url)},"zh-TW":{exportName:`zh_TW`,loader:()=>k(()=>import(`./zh-TW-CM-C0Ey2.js`),[],import.meta.url)},"pt-BR":{exportName:`pt_BR`,loader:()=>k(()=>import(`./pt-BR-CUPpmFmM.js`),[],import.meta.url)},de:{exportName:`de`,loader:()=>k(()=>import(`./de-DaHzXuN7.js`),[],import.meta.url)},es:{exportName:`es`,loader:()=>k(()=>import(`./es-CSJZiMH1.js`),[],import.meta.url)}},j=[`en`,...A];function te(e){return e!=null&&j.includes(e)}function M(e){return A.includes(e)}function ne(e){return e.startsWith(`zh`)?e===`zh-TW`||e===`zh-HK`?`zh-TW`:`zh-CN`:e.startsWith(`pt`)?`pt-BR`:e.startsWith(`de`)?`de`:e.startsWith(`es`)?`es`:`en`}async function re(e){if(!M(e))return null;let t=ee[e];return(await t.loader())[t.exportName]??null}var N=new class{constructor(){this.locale=`en`,this.translations={en:T},this.subscribers=new Set,this.loadLocale()}readStoredLocale(){let e=w();if(!e)return null;try{return e.getItem(`openclaw.i18n.locale`)}catch{return null}}persistLocale(e){let t=w();if(t)try{t.setItem(`openclaw.i18n.locale`,e)}catch{}}resolveInitialLocale(){let e=this.readStoredLocale();return te(e)?e:ne((typeof globalThis.navigator?.language==`string`?globalThis.navigator.language:null)??``)}loadLocale(){let e=this.resolveInitialLocale();if(e===`en`){this.locale=`en`;return}this.setLocale(e)}getLocale(){return this.locale}async setLocale(e){let t=e!==`en`&&!this.translations[e];if(!(this.locale===e&&!t)){if(t)try{let t=await re(e);if(!t)return;this.translations[e]=t}catch(t){console.error(`Failed to load locale: ${e}`,t);return}this.locale=e,this.persistLocale(e),this.notify()}}registerTranslation(e,t){this.translations[e]=t}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}notify(){this.subscribers.forEach(e=>e(this.locale))}t(e,t){let n=e.split(`.`),r=this.translations[this.locale]||this.translations.en;for(let e of n)if(r&&typeof r==`object`)r=r[e];else{r=void 0;break}if(r===void 0&&this.locale!==`en`){r=this.translations.en;for(let e of n)if(r&&typeof r==`object`)r=r[e];else{r=void 0;break}}return typeof r==`string`?t?r.replace(/\{(\w+)\}/g,(e,n)=>t[n]||`{${n}}`):r:e}},P=(e,t)=>N.t(e,t),F=class{constructor(e){this.host=e,this.host.addController(this)}hostConnected(){this.unsubscribe=N.subscribe(()=>{this.host.requestUpdate()})}hostDisconnected(){this.unsubscribe?.()}},I={AUTH_REQUIRED:`AUTH_REQUIRED`,AUTH_UNAUTHORIZED:`AUTH_UNAUTHORIZED`,AUTH_TOKEN_MISSING:`AUTH_TOKEN_MISSING`,AUTH_TOKEN_MISMATCH:`AUTH_TOKEN_MISMATCH`,AUTH_TOKEN_NOT_CONFIGURED:`AUTH_TOKEN_NOT_CONFIGURED`,AUTH_PASSWORD_MISSING:`AUTH_PASSWORD_MISSING`,AUTH_PASSWORD_MISMATCH:`AUTH_PASSWORD_MISMATCH`,AUTH_PASSWORD_NOT_CONFIGURED:`AUTH_PASSWORD_NOT_CONFIGURED`,AUTH_BOOTSTRAP_TOKEN_INVALID:`AUTH_BOOTSTRAP_TOKEN_INVALID`,AUTH_DEVICE_TOKEN_MISMATCH:`AUTH_DEVICE_TOKEN_MISMATCH`,AUTH_RATE_LIMITED:`AUTH_RATE_LIMITED`,AUTH_TAILSCALE_IDENTITY_MISSING:`AUTH_TAILSCALE_IDENTITY_MISSING`,AUTH_TAILSCALE_PROXY_MISSING:`AUTH_TAILSCALE_PROXY_MISSING`,AUTH_TAILSCALE_WHOIS_FAILED:`AUTH_TAILSCALE_WHOIS_FAILED`,AUTH_TAILSCALE_IDENTITY_MISMATCH:`AUTH_TAILSCALE_IDENTITY_MISMATCH`,CONTROL_UI_ORIGIN_NOT_ALLOWED:`CONTROL_UI_ORIGIN_NOT_ALLOWED`,CONTROL_UI_DEVICE_IDENTITY_REQUIRED:`CONTROL_UI_DEVICE_IDENTITY_REQUIRED`,DEVICE_IDENTITY_REQUIRED:`DEVICE_IDENTITY_REQUIRED`,DEVICE_AUTH_INVALID:`DEVICE_AUTH_INVALID`,DEVICE_AUTH_DEVICE_ID_MISMATCH:`DEVICE_AUTH_DEVICE_ID_MISMATCH`,DEVICE_AUTH_SIGNATURE_EXPIRED:`DEVICE_AUTH_SIGNATURE_EXPIRED`,DEVICE_AUTH_NONCE_REQUIRED:`DEVICE_AUTH_NONCE_REQUIRED`,DEVICE_AUTH_NONCE_MISMATCH:`DEVICE_AUTH_NONCE_MISMATCH`,DEVICE_AUTH_SIGNATURE_INVALID:`DEVICE_AUTH_SIGNATURE_INVALID`,DEVICE_AUTH_PUBLIC_KEY_INVALID:`DEVICE_AUTH_PUBLIC_KEY_INVALID`,PAIRING_REQUIRED:`PAIRING_REQUIRED`},L=new Set([`retry_with_device_token`,`update_auth_configuration`,`update_auth_credentials`,`wait_then_retry`,`review_auth_configuration`]);function ie(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.code;return typeof t==`string`&&t.trim().length>0?t:null}function ae(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t=e,n=typeof t.canRetryWithDeviceToken==`boolean`?t.canRetryWithDeviceToken:void 0,r=typeof t.recommendedNextStep==`string`?t.recommendedNextStep.trim():``;return{canRetryWithDeviceToken:n,recommendedNextStep:L.has(r)?r:void 0}}function R(e){let t=e.scopes.join(`,`),n=e.token??``;return[`v2`,e.deviceId,e.clientId,e.clientMode,e.role,t,String(e.signedAtMs),n,e.nonce].join(`|`)}var oe={WEBCHAT_UI:`webchat-ui`,CONTROL_UI:`openclaw-control-ui`,WEBCHAT:`webchat`,CLI:`cli`,GATEWAY_CLIENT:`gateway-client`,MACOS_APP:`openclaw-macos`,IOS_APP:`openclaw-ios`,ANDROID_APP:`openclaw-android`,NODE_HOST:`node-host`,TEST:`test`,FINGERPRINT:`fingerprint`,PROBE:`openclaw-probe`},se=oe,ce={WEBCHAT:`webchat`,CLI:`cli`,UI:`ui`,BACKEND:`backend`,NODE:`node`,PROBE:`probe`,TEST:`test`};new Set(Object.values(oe)),new Set(Object.values(ce));function le(e){return e.trim()}function ue(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return t.has(`operator.admin`)?(t.add(`operator.read`),t.add(`operator.write`)):t.has(`operator.write`)&&t.add(`operator.read`),[...t].toSorted()}function de(e){let t=e.adapter.readStore();if(!t||t.deviceId!==e.deviceId)return null;let n=le(e.role),r=t.tokens[n];return!r||typeof r.token!=`string`?null:r}function fe(e){let t=le(e.role),n=e.adapter.readStore(),r={version:1,deviceId:e.deviceId,tokens:n&&n.deviceId===e.deviceId&&n.tokens?{...n.tokens}:{}},i={token:e.token,role:t,scopes:ue(e.scopes),updatedAtMs:Date.now()};return r.tokens[t]=i,e.adapter.writeStore(r),i}function pe(e){let t=e.adapter.readStore();if(!t||t.deviceId!==e.deviceId)return;let n=le(e.role);if(!t.tokens[n])return;let r={version:1,deviceId:t.deviceId,tokens:{...t.tokens}};delete r.tokens[n],e.adapter.writeStore(r)}var me=`openclaw.device.auth.v1`;function he(){try{let e=w()?.getItem(me);if(!e)return null;let 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 ge(e){try{w()?.setItem(me,JSON.stringify(e))}catch{}}function _e(e){return de({adapter:{readStore:he,writeStore:ge},deviceId:e.deviceId,role:e.role})}function ve(e){return fe({adapter:{readStore:he,writeStore:ge},deviceId:e.deviceId,role:e.role,token:e.token,scopes:e.scopes})}function ye(e){pe({adapter:{readStore:he,writeStore:ge},deviceId:e.deviceId,role:e.role})}var be={p:57896044618658097711785492504343953926634992332820282019728792003956564819949n,n:7237005577332262213973186563042994240857116359379907606001950938285454250989n,h:8n,a:57896044618658097711785492504343953926634992332820282019728792003956564819948n,d:37095705934669439343138083508754565189542113879843219016388785533085940283555n,Gx:15112221349535400772501151409588531511454012693041857206046113283949847762202n,Gy:46316835694926478169428394003475163141307993866256225615783033603165251855960n},{p:z,n:xe,Gx:Se,Gy:Ce,a:we,d:Te,h:Ee}=be,De=32,Oe=64,ke=(...e)=>{`captureStackTrace`in Error&&typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(...e)},B=(e=``)=>{let t=Error(e);throw ke(t,B),t},Ae=e=>typeof e==`bigint`,je=e=>typeof e==`string`,Me=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`,Ne=(e,t,n=``)=>{let r=Me(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`;B(o+`expected Uint8Array`+s+`, got `+c)}return e},Pe=e=>new Uint8Array(e),Fe=e=>Uint8Array.from(e),Ie=(e,t)=>e.toString(16).padStart(t,`0`),Le=e=>Array.from(Ne(e)).map(e=>Ie(e,2)).join(``),Re={_0:48,_9:57,A:65,F:70,a:97,f:102},V=e=>{if(e>=Re._0&&e<=Re._9)return e-Re._0;if(e>=Re.A&&e<=Re.F)return e-(Re.A-10);if(e>=Re.a&&e<=Re.f)return e-(Re.a-10)},ze=e=>{let t=`hex invalid`;if(!je(e))return B(t);let n=e.length,r=n/2;if(n%2)return B(t);let i=Pe(r);for(let n=0,a=0;n<r;n++,a+=2){let r=V(e.charCodeAt(a)),o=V(e.charCodeAt(a+1));if(r===void 0||o===void 0)return B(t);i[n]=r*16+o}return i},Be=()=>globalThis?.crypto,Ve=()=>Be()?.subtle??B(`crypto.subtle must be defined, consider polyfill`),He=(...e)=>{let t=Pe(e.reduce((e,t)=>e+Ne(t).length,0)),n=0;return e.forEach(e=>{t.set(e,n),n+=e.length}),t},Ue=(e=De)=>Be().getRandomValues(Pe(e)),We=BigInt,Ge=(e,t,n,r=`bad number: out of range`)=>Ae(e)&&t<=e&&e<n?e:B(r),H=(e,t=z)=>{let n=e%t;return n>=0n?n:t+n},Ke=e=>H(e,xe),qe=(e,t)=>{(e===0n||t<=0n)&&B(`no inverse n=`+e+` mod=`+t);let n=H(e,t),r=t,i=0n,a=1n,o=1n,s=0n;for(;n!==0n;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}return r===1n?H(i,t):B(`no inverse`)},Je=e=>{let t=gt[e];return typeof t!=`function`&&B(`hashes.`+e+` not set`),t},Ye=e=>e instanceof Ze?e:B(`Point expected`),Xe=2n**256n,Ze=class e{static BASE;static ZERO;X;Y;Z;T;constructor(e,t,n,r){let i=Xe;this.X=Ge(e,0n,i),this.Y=Ge(t,0n,i),this.Z=Ge(n,1n,i),this.T=Ge(r,0n,i),Object.freeze(this)}static CURVE(){return be}static fromAffine(t){return new e(t.x,t.y,1n,H(t.x*t.y))}static fromBytes(t,n=!1){let r=Te,i=Fe(Ne(t,De)),a=t[31];i[31]=a&-129;let o=tt(i);Ge(o,0n,n?Xe:z);let s=H(o*o),{isValid:c,value:l}=at(H(s-1n),H(r*s+1n));c||B(`bad point: y not sqrt`);let u=(l&1n)==1n,d=(a&128)!=0;return!n&&l===0n&&d&&B(`bad point: x==0, isLastByteOdd`),d!==u&&(l=H(-l)),new e(l,o,1n,H(l*o))}static fromHex(t,n){return e.fromBytes(ze(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){let e=we,t=Te,n=this;if(n.is0())return B(`bad point: ZERO`);let{X:r,Y:i,Z:a,T:o}=n,s=H(r*r),c=H(i*i),l=H(a*a),u=H(l*l);return H(l*H(H(s*e)+c))===H(u+H(t*H(s*c)))?H(r*i)===H(a*o)?this:B(`bad point: equation left != right (2)`):B(`bad point: equation left != right (1)`)}equals(e){let{X:t,Y:n,Z:r}=this,{X:i,Y:a,Z:o}=Ye(e),s=H(t*o),c=H(i*r),l=H(n*o),u=H(a*r);return s===c&&l===u}is0(){return this.equals($e)}negate(){return new e(H(-this.X),this.Y,this.Z,H(-this.T))}double(){let{X:t,Y:n,Z:r}=this,i=we,a=H(t*t),o=H(n*n),s=H(2n*H(r*r)),c=H(i*a),l=t+n,u=H(H(l*l)-a-o),d=c+o,f=d-s,p=c-o,m=H(u*f),h=H(d*p),g=H(u*p);return new e(m,h,H(f*d),g)}add(t){let{X:n,Y:r,Z:i,T:a}=this,{X:o,Y:s,Z:c,T:l}=Ye(t),u=we,d=Te,f=H(n*o),p=H(r*s),m=H(a*d*l),h=H(i*c),g=H((n+r)*(o+s)-f-p),_=H(h-m),v=H(h+m),y=H(p-u*f),b=H(g*_),x=H(v*y),S=H(g*y);return new e(b,x,H(_*v),S)}subtract(e){return this.add(Ye(e).negate())}multiply(e,t=!0){if(!t&&(e===0n||this.is0()))return $e;if(Ge(e,1n,xe),e===1n)return this;if(this.equals(Qe))return wt(e).p;let n=$e,r=Qe;for(let i=this;e>0n;i=i.double(),e>>=1n)e&1n?n=n.add(i):t&&(r=r.add(i));return n}multiplyUnsafe(e){return this.multiply(e,!1)}toAffine(){let{X:e,Y:t,Z:n}=this;if(this.equals($e))return{x:0n,y:1n};let r=qe(n,z);return H(n*r)!==1n&&B(`invalid inverse`),{x:H(e*r),y:H(t*r)}}toBytes(){let{x:e,y:t}=this.assertValidity().toAffine(),n=et(t);return n[31]|=e&1n?128:0,n}toHex(){return Le(this.toBytes())}clearCofactor(){return this.multiply(We(Ee),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.multiply(xe/2n,!1).double();return xe%2n&&(e=e.add(this)),e.is0()}},Qe=new Ze(Se,Ce,1n,H(Se*Ce)),$e=new Ze(0n,1n,1n,0n);Ze.BASE=Qe,Ze.ZERO=$e;var et=e=>ze(Ie(Ge(e,0n,Xe),Oe)).reverse(),tt=e=>We(`0x`+Le(Fe(Ne(e)).reverse())),nt=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=z;return n},rt=e=>{let t=e*e%z*e%z,n=nt(nt(t,2n)*t%z,1n)*e%z,r=nt(n,5n)*n%z,i=nt(r,10n)*r%z,a=nt(i,20n)*i%z,o=nt(a,40n)*a%z;return{pow_p_5_8:nt(nt(nt(nt(o,80n)*o%z,80n)*o%z,10n)*r%z,2n)*e%z,b2:t}},it=19681161376707505956807079304988542015446066515923890162744021073123829784752n,at=(e,t)=>{let n=H(t*t*t),r=rt(e*H(n*n*t)).pow_p_5_8,i=H(e*n*r),a=H(t*i*i),o=i,s=H(i*it),c=a===e,l=a===H(-e),u=a===H(-e*it);return c&&(i=o),(l||u)&&(i=s),(H(i)&1n)==1n&&(i=H(-i)),{isValid:c||l,value:i}},ot=e=>Ke(tt(e)),st=(...e)=>gt.sha512Async(He(...e)),ct=(...e)=>Je(`sha512`)(He(...e)),lt=e=>{let t=e.slice(0,De);t[0]&=248,t[31]&=127,t[31]|=64;let n=e.slice(De,Oe),r=ot(t),i=Qe.multiply(r);return{head:t,prefix:n,scalar:r,point:i,pointBytes:i.toBytes()}},ut=e=>st(Ne(e,De)).then(lt),dt=e=>lt(ct(Ne(e,De))),ft=e=>ut(e).then(e=>e.pointBytes),pt=e=>st(e.hashable).then(e.finish),mt=(e,t,n)=>{let{pointBytes:r,scalar:i}=e,a=ot(t),o=Qe.multiply(a).toBytes();return{hashable:He(o,r,n),finish:e=>Ne(He(o,et(Ke(a+ot(e)*i))),Oe)}},ht=async(e,t)=>{let n=Ne(e),r=await ut(t);return pt(mt(r,await st(r.prefix,n),n))},gt={sha512Async:async e=>{let t=Ve(),n=He(e);return Pe(await t.digest(`SHA-512`,n.buffer))},sha512:void 0},_t={getExtendedPublicKeyAsync:ut,getExtendedPublicKey:dt,randomSecretKey:(e=Ue(De))=>e},vt=8,yt=Math.ceil(256/vt)+1,bt=2**(vt-1),xt=()=>{let e=[],t=Qe,n=t;for(let r=0;r<yt;r++){n=t,e.push(n);for(let r=1;r<bt;r++)n=n.add(t),e.push(n);t=n.double()}return e},St=void 0,Ct=(e,t)=>{let n=t.negate();return e?n:t},wt=e=>{let t=St||=xt(),n=$e,r=Qe,i=2**vt,a=i,o=We(i-1),s=We(vt);for(let i=0;i<yt;i++){let c=Number(e&o);e>>=s,c>bt&&(c-=a,e+=1n);let l=i*bt,u=l,d=l+Math.abs(c)-1,f=i%2!=0,p=c<0;c===0?r=r.add(Ct(f,t[u])):n=n.add(Ct(p,t[d]))}return e!==0n&&B(`invalid wnaf`),{p:n,f:r}},Tt=`openclaw-device-identity-v1`;function Et(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replace(/=+$/g,``)}function Dt(e){let t=e.replaceAll(`-`,`+`).replaceAll(`_`,`/`),n=t+`=`.repeat((4-t.length%4)%4),r=atob(n),i=new Uint8Array(r.length);for(let e=0;e<r.length;e+=1)i[e]=r.charCodeAt(e);return i}function Ot(e){return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}async function kt(e){let t=await crypto.subtle.digest(`SHA-256`,e.slice().buffer);return Ot(new Uint8Array(t))}async function At(){let e=_t.randomSecretKey(),t=await ft(e);return{deviceId:await kt(t),publicKey:Et(t),privateKey:Et(e)}}async function jt(){let e=w();try{let t=e?.getItem(Tt);if(t){let n=JSON.parse(t);if(n?.version===1&&typeof n.deviceId==`string`&&typeof n.publicKey==`string`&&typeof n.privateKey==`string`){let t=await kt(Dt(n.publicKey));if(t!==n.deviceId){let r={...n,deviceId:t};return e?.setItem(Tt,JSON.stringify(r)),{deviceId:t,publicKey:n.publicKey,privateKey:n.privateKey}}return{deviceId:n.deviceId,publicKey:n.publicKey,privateKey:n.privateKey}}}}catch{}let t=await At(),n={version:1,deviceId:t.deviceId,publicKey:t.publicKey,privateKey:t.privateKey,createdAtMs:Date.now()};return e?.setItem(Tt,JSON.stringify(n)),t}async function Mt(e,t){let n=Dt(e);return Et(await ht(new TextEncoder().encode(t),n))}var Nt=!1;function Pt(e){e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=``;for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,`0`);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Ft(){let e=new Uint8Array(16),t=Date.now();for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256);return e[0]^=t&255,e[1]^=t>>>8&255,e[2]^=t>>>16&255,e[3]^=t>>>24&255,e}function It(){Nt||(Nt=!0,console.warn(`[uuid] crypto API missing; falling back to weak randomness`))}function Lt(e=globalThis.crypto){if(e&&typeof e.randomUUID==`function`)return e.randomUUID();if(e&&typeof e.getRandomValues==`function`){let t=new Uint8Array(16);return e.getRandomValues(t),Pt(t)}return It(),Pt(Ft())}var Rt=class extends Error{constructor(e){super(e.message),this.name=`GatewayRequestError`,this.gatewayCode=e.code,this.details=e.details}};function zt(e){return ie(e?.details)}function Bt(e){if(!e)return!1;let t=zt(e);return t===I.AUTH_TOKEN_MISSING||t===I.AUTH_BOOTSTRAP_TOKEN_INVALID||t===I.AUTH_PASSWORD_MISSING||t===I.AUTH_PASSWORD_MISMATCH||t===I.AUTH_RATE_LIMITED||t===I.PAIRING_REQUIRED||t===I.CONTROL_UI_DEVICE_IDENTITY_REQUIRED||t===I.DEVICE_IDENTITY_REQUIRED}function Vt(e){try{let t=new URL(e,window.location.href),n=t.hostname.trim().toLowerCase(),r=n===`localhost`||n===`::1`||n===`[::1]`||n===`127.0.0.1`,i=n.startsWith(`127.`);if(r||i)return!0;let a=new URL(window.location.href);return t.host===a.host}catch{return!1}}var Ht=`operator`,Ut=[`operator.admin`,`operator.read`,`operator.write`,`operator.approvals`,`operator.pairing`],Wt=4008;function Gt(e){let t=e.authToken;if(t||e.authPassword)return{token:t,deviceToken:e.authDeviceToken??e.resolvedDeviceToken,password:e.authPassword}}async function Kt(e){let{deviceIdentity:t}=e;if(!t)return;let n=Date.now(),r=e.connectNonce??``,i=R({deviceId:t.deviceId,clientId:e.client.id,clientMode:e.client.mode,role:e.role,scopes:e.scopes,signedAtMs:n,token:e.authToken??null,nonce:r}),a=await Mt(t.privateKey,i);return{id:t.deviceId,publicKey:t.publicKey,signature:a,signedAt:n,nonce:r}}function qt(e){return!e.deviceTokenRetryBudgetUsed&&!e.authDeviceToken&&!!e.explicitGatewayToken&&!!e.deviceIdentity&&!!e.storedToken&&e.canRetryWithDeviceTokenHint&&Vt(e.url)}var Jt=class{constructor(e){this.opts=e,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800,this.pendingDeviceTokenRetry=!1,this.deviceTokenRetryBudgetUsed=!1}start(){this.closed=!1,this.connect()}stop(){this.closed=!0,this.ws?.close(),this.ws=null,this.pendingConnectError=void 0,this.pendingDeviceTokenRetry=!1,this.deviceTokenRetryBudgetUsed=!1,this.flushPending(Error(`gateway client stopped`))}get connected(){return this.ws?.readyState===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.addEventListener(`open`,()=>this.queueConnect()),this.ws.addEventListener(`message`,e=>this.handleMessage(String(e.data??``))),this.ws.addEventListener(`close`,e=>{let t=String(e.reason??``),n=this.pendingConnectError;this.pendingConnectError=void 0,this.ws=null,this.flushPending(Error(`gateway closed (${e.code}): ${t}`)),this.opts.onClose?.({code:e.code,reason:t,error:n}),!(zt(n)===I.AUTH_TOKEN_MISMATCH&&this.deviceTokenRetryBudgetUsed&&!this.pendingDeviceTokenRetry)&&(Bt(n)||this.scheduleReconnect())}),this.ws.addEventListener(`error`,()=>{}))}scheduleReconnect(){if(this.closed)return;let e=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),e)}flushPending(e){for(let[,t]of this.pending)t.reject(e);this.pending.clear()}buildConnectClient(){return{id:this.opts.clientName??se.CONTROL_UI,version:this.opts.clientVersion??`control-ui`,platform:this.opts.platform??navigator.platform??`web`,mode:this.opts.mode??ce.WEBCHAT,instanceId:this.opts.instanceId}}buildConnectParams(e){return{minProtocol:3,maxProtocol:3,client:e.client,role:e.role,scopes:e.scopes,device:e.device,caps:[`tool-events`],auth:e.auth,userAgent:navigator.userAgent,locale:navigator.language}}async buildConnectPlan(){let e=Ht,t=[...Ut],n=this.buildConnectClient(),r=this.opts.token?.trim()||void 0,i=this.opts.password?.trim()||void 0,a=typeof crypto<`u`&&!!crypto.subtle,o=null,s={authToken:r,authPassword:i,canFallbackToShared:!1};return a&&(o=await jt(),s=this.selectConnectAuth({role:e,deviceId:o.deviceId}),this.pendingDeviceTokenRetry&&s.authDeviceToken&&(this.pendingDeviceTokenRetry=!1)),{role:e,scopes:t,client:n,explicitGatewayToken:r,selectedAuth:s,auth:Gt(s),deviceIdentity:o,device:await Kt({deviceIdentity:o,client:n,role:e,scopes:t,authToken:s.authToken,connectNonce:this.connectNonce})}}handleConnectHello(e,t){this.pendingDeviceTokenRetry=!1,this.deviceTokenRetryBudgetUsed=!1,e?.auth?.deviceToken&&t.deviceIdentity&&ve({deviceId:t.deviceIdentity.deviceId,role:e.auth.role??t.role,token:e.auth.deviceToken,scopes:e.auth.scopes??[]}),this.backoffMs=800,this.opts.onHello?.(e)}handleConnectFailure(e,t){let n=e instanceof Rt?zt(e):null,r=e instanceof Rt?ae(e.details):{},i=r.recommendedNextStep===`retry_with_device_token`,a=r.canRetryWithDeviceToken===!0||i||n===I.AUTH_TOKEN_MISMATCH;qt({deviceTokenRetryBudgetUsed:this.deviceTokenRetryBudgetUsed,authDeviceToken:t.selectedAuth.authDeviceToken,explicitGatewayToken:t.explicitGatewayToken,deviceIdentity:t.deviceIdentity,storedToken:t.selectedAuth.storedToken,canRetryWithDeviceTokenHint:a,url:this.opts.url})&&(this.pendingDeviceTokenRetry=!0,this.deviceTokenRetryBudgetUsed=!0),e instanceof Rt?this.pendingConnectError={code:e.gatewayCode,message:e.message,details:e.details}:this.pendingConnectError=void 0,t.selectedAuth.canFallbackToShared&&t.deviceIdentity&&n===I.AUTH_DEVICE_TOKEN_MISMATCH&&ye({deviceId:t.deviceIdentity.deviceId,role:t.role}),this.ws?.close(Wt,`connect failed`)}async sendConnect(){if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);let e=await this.buildConnectPlan();this.request(`connect`,this.buildConnectParams(e)).then(t=>this.handleConnectHello(t,e)).catch(t=>this.handleConnectFailure(t,e))}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}let n=t;if(n.type===`event`){let e=t;if(e.event===`connect.challenge`){let t=e.payload,n=t&&typeof t.nonce==`string`?t.nonce:null;n&&(this.connectNonce=n,this.sendConnect());return}let n=typeof e.seq==`number`?e.seq:null;n!==null&&(this.lastSeq!==null&&n>this.lastSeq+1&&this.opts.onGap?.({expected:this.lastSeq+1,received:n}),this.lastSeq=n);try{this.opts.onEvent?.(e)}catch(e){console.error(`[gateway] event handler error:`,e)}return}if(n.type===`res`){let e=t,n=this.pending.get(e.id);if(!n)return;this.pending.delete(e.id),e.ok?n.resolve(e.payload):n.reject(new Rt({code:e.error?.code??`UNAVAILABLE`,message:e.error?.message??`request failed`,details:e.error?.details}));return}}selectConnectAuth(e){let t=this.opts.token?.trim()||void 0,n=this.opts.password?.trim()||void 0,r=_e({deviceId:e.deviceId,role:e.role}),i=r?.scopes??[],a=e.role!==`operator`||i.includes(`operator.read`)||i.includes(`operator.write`)||i.includes(`operator.admin`)?r?.token:void 0,o=this.pendingDeviceTokenRetry&&!!t&&!!a&&Vt(this.opts.url),s=t||n?void 0:a??void 0;return{authToken:t??s,authDeviceToken:o?a??void 0:void 0,authPassword:n,resolvedDeviceToken:s,storedToken:a??void 0,canFallbackToShared:!!(a&&t)}}request(e,t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(Error(`gateway not connected`));let n=Lt(),r={type:`req`,id:n,method:e,params:t},i=new Promise((e,t)=>{this.pending.set(n,{resolve:t=>e(t),reject:t})});return this.ws.send(JSON.stringify(r)),i}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}};function Yt(e){return e instanceof Rt?zt(e)===I.AUTH_UNAUTHORIZED?!0:e.message.includes(`missing scope: operator.read`):!1}function Xt(e){return`This connection is missing operator.read, so ${e} cannot be loaded yet.`}async function Zt(e,t){if(!(!e.client||!e.connected)&&!e.channelsLoading){e.channelsLoading=!0,e.channelsError=null;try{e.channelsSnapshot=await e.client.request(`channels.status`,{probe:t,timeoutMs:8e3}),e.channelsLastSuccess=Date.now()}catch(t){Yt(t)?(e.channelsSnapshot=null,e.channelsError=Xt(`channel status`)):e.channelsError=String(t)}finally{e.channelsLoading=!1}}}async function Qt(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{let n=await e.client.request(`web.login.start`,{force:t,timeoutMs:3e4});e.whatsappLoginMessage=n.message??null,e.whatsappLoginQrDataUrl=n.qrDataUrl??null,e.whatsappLoginConnected=null}catch(t){e.whatsappLoginMessage=String(t),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function $t(e){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{let t=await e.client.request(`web.login.wait`,{timeoutMs:12e4});e.whatsappLoginMessage=t.message??null,e.whatsappLoginConnected=t.connected??null,t.connected&&(e.whatsappLoginQrDataUrl=null)}catch(t){e.whatsappLoginMessage=String(t),e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function en(e){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{await e.client.request(`channels.logout`,{channel:`whatsapp`}),e.whatsappLoginMessage=`Logged out.`,e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}catch(t){e.whatsappLoginMessage=String(t)}finally{e.whatsappBusy=!1}}}function U(e){if(e)return Array.isArray(e.type)?e.type.filter(e=>e!==`null`)[0]??e.type[0]:e.type}function tn(e){if(!e)return``;if(e.default!==void 0)return e.default;switch(U(e)){case`object`:return{};case`array`:return[];case`boolean`:return!1;case`number`:case`integer`:return 0;case`string`:return``;default:return``}}function nn(e){return e.filter(e=>typeof e==`string`).join(`.`)}function rn(e,t){let n=nn(e),r=t[n];if(r)return r;let i=n.split(`.`);for(let[e,n]of Object.entries(t)){if(!e.includes(`*`))continue;let t=e.split(`.`);if(t.length!==i.length)continue;let r=!0;for(let e=0;e<i.length;e+=1)if(t[e]!==`*`&&t[e]!==i[e]){r=!1;break}if(r)return n}}function an(e){return e.replace(/_/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/\s+/g,` `).replace(/^./,e=>e.toUpperCase())}var on=[`maxtokens`,`maxoutputtokens`,`maxinputtokens`,`maxcompletiontokens`,`contexttokens`,`totaltokens`,`tokencount`,`tokenlimit`,`tokenbudget`,`passwordfile`],sn=[/token$/i,/password/i,/secret/i,/api.?key/i,/serviceaccount(?:ref)?$/i],cn=/^\$\{[^}]*\}$/,ln=`[redacted - click reveal to view]`;function un(e){return cn.test(e.trim())}function dn(e){let t=e.toLowerCase();return!on.some(e=>t.endsWith(e))&&sn.some(t=>t.test(e))}function fn(e){return typeof e==`string`?e.trim().length>0&&!un(e):e!=null}function pn(e){return e?.sensitive??!1}function mn(e,t,n){let r=nn(t);return(pn(rn(t,n))||dn(r))&&fn(e)?!0:Array.isArray(e)?e.some((e,r)=>mn(e,[...t,r],n)):e&&typeof e==`object`?Object.entries(e).some(([e,r])=>mn(r,[...t,e],n)):!1}function hn(e,t,n){if(e==null)return 0;let r=nn(t);return(pn(rn(t,n))||dn(r))&&fn(e)?1:Array.isArray(e)?e.reduce((e,r,i)=>e+hn(r,[...t,i],n),0):e&&typeof e==`object`?Object.entries(e).reduce((e,[r,i])=>e+hn(i,[...t,r],n),0):0}function gn(e,t){let n=e.trim();if(n===``)return;let r=Number(n);return!Number.isFinite(r)||t&&!Number.isInteger(r)?e:r}function _n(e){let t=e.trim();return t===`true`?!0:t===`false`?!1:e}function vn(e,t){if(e==null)return e;if(t.allOf&&t.allOf.length>0){let n=e;for(let e of t.allOf)n=vn(n,e);return n}let n=U(t);if(t.anyOf||t.oneOf){let n=(t.anyOf??t.oneOf??[]).filter(e=>!(e.type===`null`||Array.isArray(e.type)&&e.type.includes(`null`)));if(n.length===1)return vn(e,n[0]);if(typeof e==`string`)for(let t of n){let n=U(t);if(n===`number`||n===`integer`){let t=gn(e,n===`integer`);if(t===void 0||typeof t==`number`)return t}if(n===`boolean`){let t=_n(e);if(typeof t==`boolean`)return t}}for(let t of n){let n=U(t);if(n===`object`&&typeof e==`object`&&!Array.isArray(e)||n===`array`&&Array.isArray(e))return vn(e,t)}return e}if(n===`number`||n===`integer`){if(typeof e==`string`){let t=gn(e,n===`integer`);if(t===void 0||typeof t==`number`)return t}return e}if(n===`boolean`){if(typeof e==`string`){let t=_n(e);if(typeof t==`boolean`)return t}return e}if(n===`object`){if(typeof e!=`object`||Array.isArray(e))return e;let n=e,r=t.properties??{},i=t.additionalProperties&&typeof t.additionalProperties==`object`?t.additionalProperties:null,a={};for(let[e,t]of Object.entries(n)){let n=r[e]??i,o=n?vn(t,n):t;o!==void 0&&(a[e]=o)}return a}if(n===`array`){if(!Array.isArray(e))return e;if(Array.isArray(t.items)){let n=t.items;return e.map((e,t)=>{let r=t<n.length?n[t]:void 0;return r?vn(e,r):e})}let n=t.items;return n?e.map(e=>vn(e,n)).filter(e=>e!==void 0):e}return e}function yn(e){return typeof structuredClone==`function`?structuredClone(e):JSON.parse(JSON.stringify(e))}function bn(e){return`${JSON.stringify(e,null,2).trimEnd()}\n`}var xn=new Set([`__proto__`,`prototype`,`constructor`]);function Sn(e){return typeof e==`string`&&xn.has(e)}function Cn(e,t,n){if(t.length===0||t.some(Sn))return;let r=e;for(let e=0;e<t.length-1;e+=1){let n=t[e],i=t[e+1];if(typeof n==`number`){if(!Array.isArray(r))return;r[n]??(r[n]=typeof i==`number`?[]:{}),r=r[n]}else{if(typeof r!=`object`||!r)return;let e=r;e[n]??(e[n]=typeof i==`number`?[]:{}),r=e[n]}}let i=t[t.length-1];if(typeof i==`number`){Array.isArray(r)&&(r[i]=n);return}typeof r==`object`&&r&&(r[i]=n)}function wn(e,t){if(t.length===0||t.some(Sn))return;let n=e;for(let e=0;e<t.length-1;e+=1){let r=t[e];if(typeof r==`number`){if(!Array.isArray(n))return;n=n[r]}else{if(typeof n!=`object`||!n)return;n=n[r]}if(n==null)return}let r=t[t.length-1];if(typeof r==`number`){Array.isArray(n)&&n.splice(r,1);return}typeof n==`object`&&n&&delete n[r]}async function Tn(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{On(e,await e.client.request(`config.get`,{}))}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function En(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{Dn(e,await e.client.request(`config.schema`,{}))}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function Dn(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function On(e,t){e.configSnapshot=t;let n=typeof t.raw==`string`?t.raw:t.config&&typeof t.config==`object`?bn(t.config):e.configRaw;!e.configFormDirty||e.configFormMode===`raw`?e.configRaw=n:e.configForm?e.configRaw=bn(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=yn(t.config??{}),e.configFormOriginal=yn(t.config??{}),e.configRawOriginal=n)}function kn(e){return!e||typeof e!=`object`||Array.isArray(e)?null:e}function An(e){if(e.configFormMode!==`form`||!e.configForm)return e.configRaw;let t=kn(e.configSchema);return bn(t?vn(e.configForm,t):e.configForm)}async function jn(e){if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{let t=An(e),n=e.configSnapshot?.hash;if(!n){e.lastError=`Config hash missing; reload and retry.`;return}await e.client.request(`config.set`,{raw:t,baseHash:n}),e.configFormDirty=!1,await Tn(e)}catch(t){e.lastError=String(t)}finally{e.configSaving=!1}}}async function Mn(e){if(!(!e.client||!e.connected)){e.configApplying=!0,e.lastError=null;try{let t=An(e),n=e.configSnapshot?.hash;if(!n){e.lastError=`Config hash missing; reload and retry.`;return}await e.client.request(`config.apply`,{raw:t,baseHash:n,sessionKey:e.applySessionKey}),e.configFormDirty=!1,await Tn(e)}catch(t){e.lastError=String(t)}finally{e.configApplying=!1}}}async function Nn(e){if(!(!e.client||!e.connected)){e.updateRunning=!0,e.lastError=null;try{let t=await e.client.request(`update.run`,{sessionKey:e.applySessionKey});t&&t.ok===!1&&(e.lastError=`Update ${t.result?.status??`error`}: ${t.result?.reason??`Update failed.`}`)}catch(t){e.lastError=String(t)}finally{e.updateRunning=!1}}}function W(e,t,n){let r=yn(e.configForm??e.configSnapshot?.config??{});Cn(r,t,n),e.configForm=r,e.configFormDirty=!0,e.configFormMode===`form`&&(e.configRaw=bn(r))}function Pn(e,t){let n=yn(e.configForm??e.configSnapshot?.config??{});wn(n,t),e.configForm=n,e.configFormDirty=!0,e.configFormMode===`form`&&(e.configRaw=bn(n))}function Fn(e,t){let n=t.trim();if(!n)return-1;let r=e?.agents?.list;return Array.isArray(r)?r.findIndex(e=>e&&typeof e==`object`&&`id`in e&&e.id===n):-1}function In(e,t){let n=t.trim();if(!n)return-1;let r=e.configForm??e.configSnapshot?.config,i=Fn(r,n);if(i>=0)return i;let a=r?.agents?.list,o=Array.isArray(a)?a.length:0;return W(e,[`agents`,`list`,o,`id`],n),o}async function Ln(e){if(!(!e.client||!e.connected))try{await e.client.request(`config.openFile`,{})}catch{let t=e.configSnapshot?.path;if(t)try{await navigator.clipboard.writeText(t)}catch{}}}function Rn(e){let{values:t,original:n}=e;return t.name!==n.name||t.displayName!==n.displayName||t.about!==n.about||t.picture!==n.picture||t.banner!==n.banner||t.website!==n.website||t.nip05!==n.nip05||t.lud16!==n.lud16}function zn(e){let{state:t,callbacks:r,accountId:a}=e,o=Rn(t),s=(e,a,o={})=>{let{type:s=`text`,placeholder:c,maxLength:l,help:u}=o,d=t.values[e]??``,f=t.fieldErrors[e],p=`nostr-profile-${e}`;return s===`textarea`?n`
<div class="form-field" style="margin-bottom: 12px;">
<label for="${p}" style="display: block; margin-bottom: 4px; font-weight: 500;">
${a}
</label>
<textarea
id="${p}"
.value=${d}
placeholder=${c??``}
maxlength=${l??2e3}
rows="3"
style="width: 100%; padding: 8px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); resize: vertical; font-family: inherit;"
@input=${t=>{let n=t.target;r.onFieldChange(e,n.value)}}
?disabled=${t.saving}
></textarea>
${u?n`<div style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">${u}</div>`:i}
${f?n`<div style="font-size: 12px; color: var(--danger-color); margin-top: 2px;">${f}</div>`:i}
</div>
`:n`
<div class="form-field" style="margin-bottom: 12px;">
<label for="${p}" style="display: block; margin-bottom: 4px; font-weight: 500;">
${a}
</label>
<input
id="${p}"
type=${s}
.value=${d}
placeholder=${c??``}
maxlength=${l??256}
style="width: 100%; padding: 8px; border: 1px solid var(--border-color); border-radius: var(--radius-sm);"
@input=${t=>{let n=t.target;r.onFieldChange(e,n.value)}}
?disabled=${t.saving}
/>
${u?n`<div style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">${u}</div>`:i}
${f?n`<div style="font-size: 12px; color: var(--danger-color); margin-top: 2px;">${f}</div>`:i}
</div>
`};return n`
<div class="nostr-profile-form" style="padding: 16px; background: var(--bg-secondary); border-radius: var(--radius-md); margin-top: 12px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;">
<div style="font-weight: 600; font-size: 16px;">Edit Profile</div>
<div style="font-size: 12px; color: var(--text-muted);">Account: ${a}</div>
</div>
${t.error?n`<div class="callout danger" style="margin-bottom: 12px;">${t.error}</div>`:i}
${t.success?n`<div class="callout success" style="margin-bottom: 12px;">${t.success}</div>`:i}
${(()=>{let e=t.values.picture;return e?n`
<div style="margin-bottom: 12px;">
<img
src=${e}
alt="Profile picture preview"
style="max-width: 80px; max-height: 80px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-color);"
@error=${e=>{let t=e.target;t.style.display=`none`}}
@load=${e=>{let t=e.target;t.style.display=`block`}}
/>
</div>
`:i})()}
${s(`name`,`Username`,{placeholder:`satoshi`,maxLength:256,help:`Short username (e.g., satoshi)`})}
${s(`displayName`,`Display Name`,{placeholder:`Satoshi Nakamoto`,maxLength:256,help:`Your full display name`})}
${s(`about`,`Bio`,{type:`textarea`,placeholder:`Tell people about yourself...`,maxLength:2e3,help:`A brief bio or description`})}
${s(`picture`,`Avatar URL`,{type:`url`,placeholder:`https://example.com/avatar.jpg`,help:`HTTPS URL to your profile picture`})}
${t.showAdvanced?n`
<div style="border-top: 1px solid var(--border-color); padding-top: 12px; margin-top: 12px;">
<div style="font-weight: 500; margin-bottom: 12px; color: var(--text-muted);">Advanced</div>
${s(`banner`,`Banner URL`,{type:`url`,placeholder:`https://example.com/banner.jpg`,help:`HTTPS URL to a banner image`})}
${s(`website`,`Website`,{type:`url`,placeholder:`https://example.com`,help:`Your personal website`})}
${s(`nip05`,`NIP-05 Identifier`,{placeholder:`you@example.com`,help:`Verifiable identifier (e.g., you@domain.com)`})}
${s(`lud16`,`Lightning Address`,{placeholder:`you@getalby.com`,help:`Lightning address for tips (LUD-16)`})}
</div>
`:i}
<div style="display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap;">
<button
class="btn primary"
@click=${r.onSave}
?disabled=${t.saving||!o}
>
${t.saving?`Saving...`:`Save & Publish`}
</button>
<button
class="btn"
@click=${r.onImport}
?disabled=${t.importing||t.saving}
>
${t.importing?`Importing...`:`Import from Relays`}
</button>
<button
class="btn"
@click=${r.onToggleAdvanced}
>
${t.showAdvanced?`Hide Advanced`:`Show Advanced`}
</button>
<button
class="btn"
@click=${r.onCancel}
?disabled=${t.saving}
>
Cancel
</button>
</div>
${o?n`
<div style="font-size: 12px; color: var(--warning-color); margin-top: 8px">
You have unsaved changes
</div>
`:i}
</div>
`}function Bn(e){let t={name:e?.name??``,displayName:e?.displayName??``,about:e?.about??``,picture:e?.picture??``,banner:e?.banner??``,website:e?.website??``,nip05:e?.nip05??``,lud16:e?.lud16??``};return{values:t,original:{...t},saving:!1,importing:!1,error:null,success:null,fieldErrors:{},showAdvanced:!!(e?.banner||e?.website||e?.nip05||e?.lud16)}}async function Vn(e,t){await Qt(e,t),await Zt(e,!0)}async function Hn(e){await $t(e),await Zt(e,!0)}async function Un(e){await en(e),await Zt(e,!0)}async function Wn(e){await jn(e),await Tn(e),await Zt(e,!0)}async function Gn(e){await Tn(e),await Zt(e,!0)}function Kn(e){if(!Array.isArray(e))return{};let t={};for(let n of e){if(typeof n!=`string`)continue;let[e,...r]=n.split(`:`);if(!e||r.length===0)continue;let i=e.trim(),a=r.join(`:`).trim();i&&a&&(t[i]=a)}return t}function qn(e){return(e.channelsSnapshot?.channelAccounts?.nostr??[])[0]?.accountId??e.nostrProfileAccountId??`default`}function Jn(e,t=``){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function Yn(e){let t=e.hello?.auth?.deviceToken?.trim();if(t)return`Bearer ${t}`;let n=e.settings.token.trim();if(n)return`Bearer ${n}`;let r=e.password.trim();return r?`Bearer ${r}`:null}function Xn(e){let t=Yn(e);return t?{Authorization:t}:{}}function Zn(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Bn(n??void 0)}function Qn(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function $n(e,t,n){let r=e.nostrProfileFormState;r&&(e.nostrProfileFormState={...r,values:{...r.values,[t]:n},fieldErrors:{...r.fieldErrors,[t]:``}})}function er(e){let t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function tr(e){let t=e.nostrProfileFormState;if(!t||t.saving)return;let n=qn(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{let r=await fetch(Jn(n),{method:`PUT`,headers:{"Content-Type":`application/json`,...Xn(e)},body:JSON.stringify(t.values)}),i=await r.json().catch(()=>null);if(!r.ok||i?.ok===!1||!i){let n=i?.error??`Profile update failed (${r.status})`;e.nostrProfileFormState={...t,saving:!1,error:n,success:null,fieldErrors:Kn(i?.details)};return}if(!i.persisted){e.nostrProfileFormState={...t,saving:!1,error:`Profile publish failed on all relays.`,success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:`Profile published to relays.`,fieldErrors:{},original:{...t.values}},await Zt(e,!0)}catch(n){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(n)}`,success:null}}}async function nr(e){let t=e.nostrProfileFormState;if(!t||t.importing)return;let n=qn(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{let r=await fetch(Jn(n,`/import`),{method:`POST`,headers:{"Content-Type":`application/json`,...Xn(e)},body:JSON.stringify({autoMerge:!0})}),i=await r.json().catch(()=>null);if(!r.ok||i?.ok===!1||!i){let n=i?.error??`Profile import failed (${r.status})`;e.nostrProfileFormState={...t,importing:!1,error:n,success:null};return}let a=i.merged??i.imported??null,o=a?{...t.values,...a}:t.values,s=!!(o.banner||o.website||o.nip05||o.lud16);e.nostrProfileFormState={...t,importing:!1,values:o,error:null,success:i.saved?`Profile imported from relays. Review and publish.`:`Profile imported. Review and publish.`,showAdvanced:s},i.saved&&await Zt(e,!0)}catch(n){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(n)}`,success:null}}}function rr(e){let t=(e??``).trim().toLowerCase();if(!t)return null;let n=t.split(`:`).filter(Boolean);if(n.length<3||n[0]!==`agent`)return null;let r=n[1]?.trim(),i=n.slice(2).join(`:`);return!r||!i?null:{agentId:r,rest:i}}function ir(e){let t=(e??``).trim();return t?t.toLowerCase().startsWith(`subagent:`)?!0:!!(rr(t)?.rest??``).toLowerCase().startsWith(`subagent:`):!1}var ar=450;function or(e,t){return typeof e.querySelector==`function`?e.querySelector(t):null}function sr(e,t=!1,n=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);let r=()=>{let t=or(e,`.chat-thread`);if(t){let e=getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`||t.scrollHeight-t.clientHeight>1)return t}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{e.chatScrollFrame=requestAnimationFrame(()=>{e.chatScrollFrame=null;let i=r();if(!i)return;let a=i.scrollHeight-i.scrollTop-i.clientHeight,o=t&&!e.chatHasAutoScrolled;if(!(o||e.chatUserNearBottom||a<ar)){e.chatNewMessagesBelow=!0;return}o&&(e.chatHasAutoScrolled=!0);let s=n&&(typeof window>`u`||typeof window.matchMedia!=`function`||!window.matchMedia(`(prefers-reduced-motion: reduce)`).matches),c=i.scrollHeight;typeof i.scrollTo==`function`?i.scrollTo({top:c,behavior:s?`smooth`:`auto`}):i.scrollTop=c,e.chatUserNearBottom=!0,e.chatNewMessagesBelow=!1;let l=o?150:120;e.chatScrollTimeout=window.setTimeout(()=>{e.chatScrollTimeout=null;let t=r();if(!t)return;let n=t.scrollHeight-t.scrollTop-t.clientHeight;(o||e.chatUserNearBottom||n<ar)&&(t.scrollTop=t.scrollHeight,e.chatUserNearBottom=!0)},l)})})}function cr(e,t=!1){e.logsScrollFrame&&cancelAnimationFrame(e.logsScrollFrame),e.updateComplete.then(()=>{e.logsScrollFrame=requestAnimationFrame(()=>{e.logsScrollFrame=null;let n=or(e,`.log-stream`);if(!n)return;let r=n.scrollHeight-n.scrollTop-n.clientHeight;(t||r<80)&&(n.scrollTop=n.scrollHeight)})})}function lr(e,t){let n=t.currentTarget;n&&(e.chatUserNearBottom=n.scrollHeight-n.scrollTop-n.clientHeight<ar,e.chatUserNearBottom&&(e.chatNewMessagesBelow=!1))}function ur(e,t){let n=t.currentTarget;n&&(e.logsAtBottom=n.scrollHeight-n.scrollTop-n.clientHeight<80)}function dr(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0,e.chatNewMessagesBelow=!1}function fr(e,t){if(e.length===0)return;let n=new Blob([`${e.join(`
`)}\n`],{type:`text/plain`}),r=URL.createObjectURL(n),i=document.createElement(`a`),a=new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`);i.href=r,i.download=`openclaw-logs-${t}-${a}.log`,i.click(),URL.revokeObjectURL(r)}function pr(e){if(typeof ResizeObserver>`u`)return;let t=or(e,`.topbar`);if(!t)return;let n=()=>{let{height:n}=t.getBoundingClientRect();e.style.setProperty(`--topbar-height`,`${n}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}var mr=`operator`,hr=`operator.admin`,gr=`operator.read`,_r=`operator.write`,vr=`operator.`;function yr(e){let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function br(e,t){return t.has(hr)&&e.startsWith(vr)?!0:e===gr?t.has(gr)||t.has(_r):e===_r?t.has(_r):t.has(e)}function xr(e){let t=yr(e.requestedScopes);if(t.length===0)return!0;let n=yr(e.allowedScopes);if(n.length===0)return!1;let r=new Set(n);return e.role.trim()===mr?t.every(e=>br(e,r)):t.every(e=>r.has(e))}async function Sr(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{let[t,n,r,i]=await Promise.all([e.client.request(`status`,{}),e.client.request(`health`,{}),e.client.request(`models.list`,{}),e.client.request(`last-heartbeat`,{})]);e.debugStatus=t,e.debugHealth=n;let a=r;e.debugModels=Array.isArray(a?.models)?a?.models:[],e.debugHeartbeat=i}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}async function Cr(e){if(!(!e.client||!e.connected)){e.debugCallError=null,e.debugCallResult=null;try{let t=e.debugCallParams.trim()?JSON.parse(e.debugCallParams):{},n=await e.client.request(e.debugCallMethod.trim(),t);e.debugCallResult=JSON.stringify(n,null,2)}catch(t){e.debugCallError=String(t)}}}var wr=2e3,Tr=new Set([`trace`,`debug`,`info`,`warn`,`error`,`fatal`]);function Er(e){if(typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`)||!t.endsWith(`}`))return null;try{let e=JSON.parse(t);return!e||typeof e!=`object`?null:e}catch{return null}}function Dr(e){if(typeof e!=`string`)return null;let t=e.toLowerCase();return Tr.has(t)?t:null}function Or(e){if(!e.trim())return{raw:e,message:e};try{let t=JSON.parse(e),n=t&&typeof t._meta==`object`&&t._meta!==null?t._meta:null,r=typeof t.time==`string`?t.time:typeof n?.date==`string`?n?.date:null,i=Dr(n?.logLevelName??n?.level),a=typeof t[0]==`string`?t[0]:typeof n?.name==`string`?n?.name:null,o=Er(a),s=null;o&&(typeof o.subsystem==`string`?s=o.subsystem:typeof o.module==`string`&&(s=o.module)),!s&&a&&a.length<120&&(s=a);let c=null;return typeof t[1]==`string`?c=t[1]:typeof t[2]==`string`?c=t[2]:!o&&typeof t[0]==`string`?c=t[0]:typeof t.message==`string`&&(c=t.message),{raw:e,time:r,level:i,subsystem:s,message:c??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function kr(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!t?.quiet)){t?.quiet||(e.logsLoading=!0),e.logsError=null;try{let n=await e.client.request(`logs.tail`,{cursor:t?.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),r=(Array.isArray(n.lines)?n.lines.filter(e=>typeof e==`string`):[]).map(Or);e.logsEntries=t?.reset||n.reset||e.logsCursor==null?r:[...e.logsEntries,...r].slice(-wr),typeof n.cursor==`number`&&(e.logsCursor=n.cursor),typeof n.file==`string`&&(e.logsFile=n.file),e.logsTruncated=!!n.truncated,e.logsLastFetchAt=Date.now()}catch(t){Yt(t)?(e.logsEntries=[],e.logsError=Xt(`logs`)):e.logsError=String(t)}finally{t?.quiet||(e.logsLoading=!1)}}}async function Ar(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,t?.quiet||(e.lastError=null);try{let t=await e.client.request(`node.list`,{});e.nodes=Array.isArray(t.nodes)?t.nodes:[]}catch(n){t?.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function jr(e){e.nodesPollInterval??=window.setInterval(()=>void Ar(e,{quiet:!0}),5e3)}function Mr(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function Nr(e){e.logsPollInterval??=window.setInterval(()=>{e.tab===`logs`&&kr(e,{quiet:!0})},2e3)}function Pr(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function Fr(e){e.debugPollInterval??=window.setInterval(()=>{e.tab===`debug`&&Sr(e)},3e3)}function Ir(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}async function Lr(e,t){if(!(!e.client||!e.connected||e.agentIdentityLoading)&&!e.agentIdentityById[t]){e.agentIdentityLoading=!0,e.agentIdentityError=null;try{let n=await e.client.request(`agent.identity.get`,{agentId:t});n&&(e.agentIdentityById={...e.agentIdentityById,[t]:n})}catch(t){e.agentIdentityError=String(t)}finally{e.agentIdentityLoading=!1}}}async function Rr(e,t){if(!e.client||!e.connected||e.agentIdentityLoading)return;let n=t.filter(t=>!e.agentIdentityById[t]);if(n.length!==0){e.agentIdentityLoading=!0,e.agentIdentityError=null;try{for(let t of n){let n=await e.client.request(`agent.identity.get`,{agentId:t});n&&(e.agentIdentityById={...e.agentIdentityById,[t]:n})}}catch(t){e.agentIdentityError=String(t)}finally{e.agentIdentityLoading=!1}}}async function zr(e,t){if(!(!e.client||!e.connected)&&!e.agentSkillsLoading){e.agentSkillsLoading=!0,e.agentSkillsError=null;try{let n=await e.client.request(`skills.status`,{agentId:t});n&&(e.agentSkillsReport=n,e.agentSkillsAgentId=t)}catch(t){e.agentSkillsError=String(t)}finally{e.agentSkillsLoading=!1}}}async function Br(e){if(!(!e.client||!e.connected)&&!e.agentsLoading){e.agentsLoading=!0,e.agentsError=null;try{let t=await e.client.request(`agents.list`,{});if(t){e.agentsList=t;let n=e.agentsSelectedId,r=t.agents.some(e=>e.id===n);(!n||!r)&&(e.agentsSelectedId=t.defaultId??t.agents[0]?.id??null)}}catch(t){Yt(t)?(e.agentsList=null,e.agentsError=Xt(`agent list`)):e.agentsError=String(t)}finally{e.agentsLoading=!1}}}async function Vr(e,t){let n=t.trim();if(!(!e.client||!e.connected||!n)&&!(e.toolsCatalogLoading&&e.toolsCatalogLoadingAgentId===n)){e.toolsCatalogLoading=!0,e.toolsCatalogLoadingAgentId=n,e.toolsCatalogError=null,e.toolsCatalogResult=null;try{let t=await e.client.request(`tools.catalog`,{agentId:n,includePlugins:!0});if(e.toolsCatalogLoadingAgentId!==n||e.agentsSelectedId&&e.agentsSelectedId!==n)return;e.toolsCatalogResult=t}catch(t){if(e.toolsCatalogLoadingAgentId!==n||e.agentsSelectedId&&e.agentsSelectedId!==n)return;e.toolsCatalogResult=null,e.toolsCatalogError=Yt(t)?Xt(`tools catalog`):String(t)}finally{e.toolsCatalogLoadingAgentId===n&&(e.toolsCatalogLoadingAgentId=null,e.toolsCatalogLoading=!1)}}}async function Hr(e){let t=e.agentsSelectedId;await jn(e),await Br(e),t&&e.agentsList?.agents.some(e=>e.id===t)&&(e.agentsSelectedId=t)}var Ur={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Wr={name:``,description:``,agentId:``,sessionKey:``,clearAgent:!1,enabled:!0,deleteAfterRun:!0,scheduleKind:`every`,scheduleAt:``,everyAmount:`30`,everyUnit:`minutes`,cronExpr:`0 7 * * *`,cronTz:``,scheduleExact:!1,staggerAmount:``,staggerUnit:`seconds`,sessionTarget:`isolated`,wakeMode:`now`,payloadKind:`agentTurn`,payloadText:``,payloadModel:``,payloadThinking:``,payloadLightContext:!1,deliveryMode:`announce`,deliveryChannel:`last`,deliveryTo:``,deliveryAccountId:``,deliveryBestEffort:!1,failureAlertMode:`inherit`,failureAlertAfter:`2`,failureAlertCooldownSeconds:`3600`,failureAlertChannel:`last`,failureAlertTo:``,failureAlertDeliveryMode:`announce`,failureAlertAccountId:``,timeoutSeconds:``},Gr=`last`;function Kr(e){return e.sessionTarget!==`main`&&e.payloadKind===`agentTurn`}function qr(e){return e.deliveryMode!==`announce`||Kr(e)?e:{...e,deliveryMode:`none`}}function Jr(e){let t={};if(e.name.trim()||(t.name=`cron.errors.nameRequired`),e.scheduleKind===`at`){let n=Date.parse(e.scheduleAt);Number.isFinite(n)||(t.scheduleAt=`cron.errors.scheduleAtInvalid`)}else if(e.scheduleKind===`every`)g(e.everyAmount,0)<=0&&(t.everyAmount=`cron.errors.everyAmountInvalid`);else if(e.cronExpr.trim()||(t.cronExpr=`cron.errors.cronExprRequired`),!e.scheduleExact){let n=e.staggerAmount.trim();n&&g(n,0)<=0&&(t.staggerAmount=`cron.errors.staggerAmountInvalid`)}if(e.payloadText.trim()||(t.payloadText=e.payloadKind===`systemEvent`?`cron.errors.systemTextRequired`:`cron.errors.agentMessageRequired`),e.payloadKind===`agentTurn`){let n=e.timeoutSeconds.trim();n&&g(n,0)<=0&&(t.timeoutSeconds=`cron.errors.timeoutInvalid`)}if(e.deliveryMode===`webhook`){let n=e.deliveryTo.trim();n?/^https?:\/\//i.test(n)||(t.deliveryTo=`cron.errors.webhookUrlInvalid`):t.deliveryTo=`cron.errors.webhookUrlRequired`}if(e.failureAlertMode===`custom`){let n=e.failureAlertAfter.trim();if(n){let e=g(n,0);(!Number.isFinite(e)||e<=0)&&(t.failureAlertAfter=`Failure alert threshold must be greater than 0.`)}let r=e.failureAlertCooldownSeconds.trim();if(r){let e=g(r,-1);(!Number.isFinite(e)||e<0)&&(t.failureAlertCooldownSeconds=`Cooldown must be 0 or greater.`)}}return t}function Yr(e){return Object.keys(e).length>0}async function Xr(e){if(!(!e.client||!e.connected))try{e.cronStatus=await e.client.request(`cron.status`,{})}catch(t){Yt(t)?(e.cronStatus=null,e.cronError=Xt(`cron status`)):e.cronError=String(t)}}async function Zr(e){return await $r(e,{append:!1})}function Qr(e){let t=typeof e.totalRaw==`number`&&Number.isFinite(e.totalRaw)?Math.max(0,Math.floor(e.totalRaw)):e.pageCount,n=typeof e.limitRaw==`number`&&Number.isFinite(e.limitRaw)?Math.max(1,Math.floor(e.limitRaw)):Math.max(1,e.pageCount),r=typeof e.offsetRaw==`number`&&Number.isFinite(e.offsetRaw)?Math.max(0,Math.floor(e.offsetRaw)):0,i=typeof e.hasMoreRaw==`boolean`?e.hasMoreRaw:r+e.pageCount<Math.max(t,r+e.pageCount);return{total:t,limit:n,offset:r,hasMore:i,nextOffset:typeof e.nextOffsetRaw==`number`&&Number.isFinite(e.nextOffsetRaw)?Math.max(0,Math.floor(e.nextOffsetRaw)):i?r+e.pageCount:null}}async function $r(e,t){if(!e.client||!e.connected||e.cronLoading||e.cronJobsLoadingMore)return;let n=t?.append===!0;if(n){if(!e.cronJobsHasMore)return;e.cronJobsLoadingMore=!0}else e.cronLoading=!0;e.cronError=null;try{let t=n?Math.max(0,e.cronJobsNextOffset??e.cronJobs.length):0,r=await e.client.request(`cron.list`,{includeDisabled:e.cronJobsEnabledFilter===`all`,limit:e.cronJobsLimit,offset:t,query:e.cronJobsQuery.trim()||void 0,enabled:e.cronJobsEnabledFilter,sortBy:e.cronJobsSortBy,sortDir:e.cronJobsSortDir}),i=Array.isArray(r.jobs)?r.jobs:[];e.cronJobs=n?[...e.cronJobs,...i]:i;let a=Qr({totalRaw:r.total,limitRaw:r.limit,offsetRaw:r.offset,nextOffsetRaw:r.nextOffset,hasMoreRaw:r.hasMore,pageCount:i.length});e.cronJobsTotal=Math.max(a.total,e.cronJobs.length),e.cronJobsHasMore=a.hasMore,e.cronJobsNextOffset=a.nextOffset,e.cronEditingJobId&&!e.cronJobs.some(t=>t.id===e.cronEditingJobId)&&ii(e)}catch(t){e.cronError=String(t)}finally{n?e.cronJobsLoadingMore=!1:e.cronLoading=!1}}async function ei(e){await $r(e,{append:!0})}async function ti(e){await $r(e,{append:!1})}function ni(e,t){typeof t.cronJobsQuery==`string`&&(e.cronJobsQuery=t.cronJobsQuery),t.cronJobsEnabledFilter&&(e.cronJobsEnabledFilter=t.cronJobsEnabledFilter),t.cronJobsScheduleKindFilter&&(e.cronJobsScheduleKindFilter=t.cronJobsScheduleKindFilter),t.cronJobsLastStatusFilter&&(e.cronJobsLastStatusFilter=t.cronJobsLastStatusFilter),t.cronJobsSortBy&&(e.cronJobsSortBy=t.cronJobsSortBy),t.cronJobsSortDir&&(e.cronJobsSortDir=t.cronJobsSortDir)}function ri(e){return e.cronJobs.filter(t=>!(e.cronJobsScheduleKindFilter!==`all`&&t.schedule.kind!==e.cronJobsScheduleKindFilter||e.cronJobsLastStatusFilter!==`all`&&t.state?.lastStatus!==e.cronJobsLastStatusFilter))}function ii(e){e.cronEditingJobId=null}function ai(e){e.cronForm={...Wr},e.cronFieldErrors=Jr(e.cronForm)}function oi(e){let t=Date.parse(e);if(!Number.isFinite(t))return``;let n=new Date(t);return`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,`0`)}-${String(n.getDate()).padStart(2,`0`)}T${String(n.getHours()).padStart(2,`0`)}:${String(n.getMinutes()).padStart(2,`0`)}`}function si(e){if(e%864e5==0)return{everyAmount:String(Math.max(1,e/864e5)),everyUnit:`days`};if(e%36e5==0)return{everyAmount:String(Math.max(1,e/36e5)),everyUnit:`hours`};let t=Math.max(1,Math.ceil(e/6e4));return{everyAmount:String(t),everyUnit:`minutes`}}function ci(e){return e===0?{scheduleExact:!0,staggerAmount:``,staggerUnit:`seconds`}:typeof e!=`number`||!Number.isFinite(e)||e<0?{scheduleExact:!1,staggerAmount:``,staggerUnit:`seconds`}:e%6e4==0?{scheduleExact:!1,staggerAmount:String(Math.max(1,e/6e4)),staggerUnit:`minutes`}:{scheduleExact:!1,staggerAmount:String(Math.max(1,Math.ceil(e/1e3))),staggerUnit:`seconds`}}function li(e,t){let n=e.failureAlert,r={...t,name:e.name,description:e.description??``,agentId:e.agentId??``,sessionKey:e.sessionKey??``,clearAgent:!1,enabled:e.enabled,deleteAfterRun:e.deleteAfterRun??!1,scheduleKind:e.schedule.kind,scheduleAt:``,everyAmount:t.everyAmount,everyUnit:t.everyUnit,cronExpr:t.cronExpr,cronTz:``,scheduleExact:!1,staggerAmount:``,staggerUnit:`seconds`,sessionTarget:e.sessionTarget,wakeMode:e.wakeMode,payloadKind:e.payload.kind,payloadText:e.payload.kind===`systemEvent`?e.payload.text:e.payload.message,payloadModel:e.payload.kind===`agentTurn`?e.payload.model??``:``,payloadThinking:e.payload.kind===`agentTurn`?e.payload.thinking??``:``,payloadLightContext:e.payload.kind===`agentTurn`?e.payload.lightContext===!0:!1,deliveryMode:e.delivery?.mode??`none`,deliveryChannel:e.delivery?.channel??`last`,deliveryTo:e.delivery?.to??``,deliveryAccountId:e.delivery?.accountId??``,deliveryBestEffort:e.delivery?.bestEffort??!1,failureAlertMode:n===!1?`disabled`:n&&typeof n==`object`?`custom`:`inherit`,failureAlertAfter:n&&typeof n==`object`&&typeof n.after==`number`?String(n.after):Wr.failureAlertAfter,failureAlertCooldownSeconds:n&&typeof n==`object`&&typeof n.cooldownMs==`number`?String(Math.floor(n.cooldownMs/1e3)):Wr.failureAlertCooldownSeconds,failureAlertChannel:n&&typeof n==`object`?n.channel??`last`:Gr,failureAlertTo:n&&typeof n==`object`?n.to??``:``,failureAlertDeliveryMode:n&&typeof n==`object`?n.mode??`announce`:`announce`,failureAlertAccountId:n&&typeof n==`object`?n.accountId??``:``,timeoutSeconds:e.payload.kind===`agentTurn`&&typeof e.payload.timeoutSeconds==`number`?String(e.payload.timeoutSeconds):``};if(e.schedule.kind===`at`)r.scheduleAt=oi(e.schedule.at);else if(e.schedule.kind===`every`){let t=si(e.schedule.everyMs);r.everyAmount=t.everyAmount,r.everyUnit=t.everyUnit}else{r.cronExpr=e.schedule.expr,r.cronTz=e.schedule.tz??``;let t=ci(e.schedule.staggerMs);r.scheduleExact=t.scheduleExact,r.staggerAmount=t.staggerAmount,r.staggerUnit=t.staggerUnit}return qr(r)}function ui(e){if(e.scheduleKind===`at`){let t=Date.parse(e.scheduleAt);if(!Number.isFinite(t))throw Error(P(`cron.errors.invalidRunTime`));return{kind:`at`,at:new Date(t).toISOString()}}if(e.scheduleKind===`every`){let t=g(e.everyAmount,0);if(t<=0)throw Error(P(`cron.errors.invalidIntervalAmount`));let n=e.everyUnit;return{kind:`every`,everyMs:t*(n===`minutes`?6e4:n===`hours`?36e5:864e5)}}let t=e.cronExpr.trim();if(!t)throw Error(P(`cron.errors.cronExprRequiredShort`));if(e.scheduleExact)return{kind:`cron`,expr:t,tz:e.cronTz.trim()||void 0,staggerMs:0};let n=e.staggerAmount.trim();if(!n)return{kind:`cron`,expr:t,tz:e.cronTz.trim()||void 0};let r=g(n,0);if(r<=0)throw Error(P(`cron.errors.invalidStaggerAmount`));let i=e.staggerUnit===`minutes`?r*6e4:r*1e3;return{kind:`cron`,expr:t,tz:e.cronTz.trim()||void 0,staggerMs:i}}function di(e){if(e.payloadKind===`systemEvent`){let t=e.payloadText.trim();if(!t)throw Error(P(`cron.errors.systemEventTextRequired`));return{kind:`systemEvent`,text:t}}let t=e.payloadText.trim();if(!t)throw Error(P(`cron.errors.agentMessageRequiredShort`));let n={kind:`agentTurn`,message:t},r=e.payloadModel.trim();r&&(n.model=r);let i=e.payloadThinking.trim();i&&(n.thinking=i);let a=g(e.timeoutSeconds,0);return a>0&&(n.timeoutSeconds=a),e.payloadLightContext&&(n.lightContext=!0),n}function fi(e){if(e.failureAlertMode===`disabled`)return!1;if(e.failureAlertMode!==`custom`)return;let t=g(e.failureAlertAfter.trim(),0),n=e.failureAlertCooldownSeconds.trim(),r=n.length>0?g(n,0):void 0,i=r!==void 0&&Number.isFinite(r)&&r>=0?Math.floor(r*1e3):void 0,a=e.failureAlertDeliveryMode,o=e.failureAlertAccountId.trim(),s={after:t>0?Math.floor(t):void 0,channel:e.failureAlertChannel.trim()||`last`,to:e.failureAlertTo.trim()||void 0,...i===void 0?{}:{cooldownMs:i}};return a&&(s.mode=a),s.accountId=o||void 0,s}async function pi(e){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{let t=qr(e.cronForm);t!==e.cronForm&&(e.cronForm=t);let n=Jr(t);if(e.cronFieldErrors=n,Yr(n))return;let r=ui(t),i=di(t),a=e.cronEditingJobId?e.cronJobs.find(t=>t.id===e.cronEditingJobId):void 0;if(i.kind===`agentTurn`){let n=a?.payload.kind===`agentTurn`?a.payload.lightContext:void 0;!t.payloadLightContext&&e.cronEditingJobId&&n!==void 0&&(i.lightContext=!1)}let o=t.deliveryMode,s=o&&o!==`none`?{mode:o,channel:o===`announce`?t.deliveryChannel.trim()||`last`:void 0,to:t.deliveryTo.trim()||void 0,accountId:o===`announce`?t.deliveryAccountId.trim():void 0,bestEffort:t.deliveryBestEffort}:o===`none`?{mode:`none`}:void 0,c=fi(t),l=t.clearAgent?null:t.agentId.trim(),u=t.sessionKey.trim()||(a?.sessionKey?null:void 0),d={name:t.name.trim(),description:t.description.trim(),agentId:l===null?null:l||void 0,sessionKey:u,enabled:t.enabled,deleteAfterRun:t.deleteAfterRun,schedule:r,sessionTarget:t.sessionTarget,wakeMode:t.wakeMode,payload:i,delivery:s,failureAlert:c};if(!d.name)throw Error(P(`cron.errors.nameRequiredShort`));e.cronEditingJobId?(await e.client.request(`cron.update`,{id:e.cronEditingJobId,patch:d}),ii(e)):(await e.client.request(`cron.add`,d),ai(e)),await Zr(e),await Xr(e)}catch(t){e.cronError=String(t)}finally{e.cronBusy=!1}}}async function mi(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 Zr(e),await Xr(e)}catch(t){e.cronError=String(t)}finally{e.cronBusy=!1}}}async function hi(e,t,n=`force`){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request(`cron.run`,{id:t.id,mode:n}),e.cronRunsScope===`all`?await _i(e,null):await _i(e,t.id)}catch(t){e.cronError=String(t)}finally{e.cronBusy=!1}}}async function gi(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.cronEditingJobId===t.id&&ii(e),e.cronRunsJobId===t.id&&(e.cronRunsJobId=null,e.cronRuns=[],e.cronRunsTotal=0,e.cronRunsHasMore=!1,e.cronRunsNextOffset=null),await Zr(e),await Xr(e)}catch(t){e.cronError=String(t)}finally{e.cronBusy=!1}}}async function _i(e,t,n){if(!e.client||!e.connected)return;let r=e.cronRunsScope,i=t??e.cronRunsJobId;if(r===`job`&&!i){e.cronRuns=[],e.cronRunsTotal=0,e.cronRunsHasMore=!1,e.cronRunsNextOffset=null;return}let a=n?.append===!0;if(!(a&&!e.cronRunsHasMore))try{a&&(e.cronRunsLoadingMore=!0);let t=a?Math.max(0,e.cronRunsNextOffset??e.cronRuns.length):0,n=await e.client.request(`cron.runs`,{scope:r,id:r===`job`?i??void 0:void 0,limit:e.cronRunsLimit,offset:t,statuses:e.cronRunsStatuses.length>0?e.cronRunsStatuses:void 0,status:e.cronRunsStatusFilter,deliveryStatuses:e.cronRunsDeliveryStatuses.length>0?e.cronRunsDeliveryStatuses:void 0,query:e.cronRunsQuery.trim()||void 0,sortDir:e.cronRunsSortDir}),o=Array.isArray(n.entries)?n.entries:[];e.cronRuns=a&&(r===`all`||e.cronRunsJobId===i)?[...e.cronRuns,...o]:o,r===`job`&&(e.cronRunsJobId=i??null);let s=Qr({totalRaw:n.total,limitRaw:n.limit,offsetRaw:n.offset,nextOffsetRaw:n.nextOffset,hasMoreRaw:n.hasMore,pageCount:o.length});e.cronRunsTotal=Math.max(s.total,e.cronRuns.length),e.cronRunsHasMore=s.hasMore,e.cronRunsNextOffset=s.nextOffset}catch(t){e.cronError=String(t)}finally{a&&(e.cronRunsLoadingMore=!1)}}async function vi(e){e.cronRunsScope===`job`&&!e.cronRunsJobId||await _i(e,e.cronRunsJobId,{append:!0})}function yi(e,t){t.cronRunsScope&&(e.cronRunsScope=t.cronRunsScope),Array.isArray(t.cronRunsStatuses)&&(e.cronRunsStatuses=t.cronRunsStatuses,e.cronRunsStatusFilter=t.cronRunsStatuses.length===1?t.cronRunsStatuses[0]:`all`),Array.isArray(t.cronRunsDeliveryStatuses)&&(e.cronRunsDeliveryStatuses=t.cronRunsDeliveryStatuses),t.cronRunsStatusFilter&&(e.cronRunsStatusFilter=t.cronRunsStatusFilter,e.cronRunsStatuses=t.cronRunsStatusFilter===`all`?[]:[t.cronRunsStatusFilter]),typeof t.cronRunsQuery==`string`&&(e.cronRunsQuery=t.cronRunsQuery),t.cronRunsSortDir&&(e.cronRunsSortDir=t.cronRunsSortDir)}function bi(e,t){e.cronEditingJobId=t.id,e.cronRunsJobId=t.id,e.cronForm=li(t,e.cronForm),e.cronFieldErrors=Jr(e.cronForm)}function xi(e,t){let n=e.trim()||`Job`,r=`${n} copy`;if(!t.has(r.toLowerCase()))return r;let i=2;for(;i<1e3;){let e=`${n} copy ${i}`;if(!t.has(e.toLowerCase()))return e;i+=1}return`${n} copy ${Date.now()}`}function Si(e,t){ii(e),e.cronRunsJobId=t.id;let n=new Set(e.cronJobs.map(e=>e.name.trim().toLowerCase())),r=li(t,e.cronForm);r.name=xi(t.name,n),e.cronForm=r,e.cronFieldErrors=Jr(e.cronForm)}function Ci(e){ii(e),ai(e)}async function wi(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t?.quiet||(e.devicesError=null);try{let t=await e.client.request(`device.pair.list`,{});e.devicesList={pending:Array.isArray(t?.pending)?t.pending:[],paired:Array.isArray(t?.paired)?t.paired:[]}}catch(n){t?.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function Ti(e,t){if(!(!e.client||!e.connected))try{await e.client.request(`device.pair.approve`,{requestId:t}),await wi(e)}catch(t){e.devicesError=String(t)}}async function Ei(e,t){if(!(!e.client||!e.connected)&&window.confirm(`Reject this device pairing request?`))try{await e.client.request(`device.pair.reject`,{requestId:t}),await wi(e)}catch(t){e.devicesError=String(t)}}async function Di(e,t){if(!(!e.client||!e.connected))try{let n=await e.client.request(`device.token.rotate`,t);if(n?.token){let e=await jt(),r=n.role??t.role;(n.deviceId===e.deviceId||t.deviceId===e.deviceId)&&ve({deviceId:e.deviceId,role:r,token:n.token,scopes:n.scopes??t.scopes??[]}),window.prompt(`New device token (copy and store securely):`,n.token)}await wi(e)}catch(t){e.devicesError=String(t)}}async function Oi(e,t){if(!(!e.client||!e.connected)&&window.confirm(`Revoke token for ${t.deviceId} (${t.role})?`))try{await e.client.request(`device.token.revoke`,t);let n=await jt();t.deviceId===n.deviceId&&ye({deviceId:n.deviceId,role:t.role}),await wi(e)}catch(t){e.devicesError=String(t)}}function ki(e){if(!e||e.kind===`gateway`)return{method:`exec.approvals.get`,params:{}};let t=e.nodeId.trim();return t?{method:`exec.approvals.node.get`,params:{nodeId:t}}:null}function Ai(e,t){if(!e||e.kind===`gateway`)return{method:`exec.approvals.set`,params:t};let n=e.nodeId.trim();return n?{method:`exec.approvals.node.set`,params:{...t,nodeId:n}}:null}async function ji(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{let n=ki(t);if(!n){e.lastError=`Select a node before loading exec approvals.`;return}Mi(e,await e.client.request(n.method,n.params))}catch(t){e.lastError=String(t)}finally{e.execApprovalsLoading=!1}}}function Mi(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=yn(t.file??{}))}async function Ni(e,t){if(!(!e.client||!e.connected)){e.execApprovalsSaving=!0,e.lastError=null;try{let n=e.execApprovalsSnapshot?.hash;if(!n){e.lastError=`Exec approvals hash missing; reload and retry.`;return}let r=Ai(t,{file:e.execApprovalsForm??e.execApprovalsSnapshot?.file??{},baseHash:n});if(!r){e.lastError=`Select a node before saving exec approvals.`;return}await e.client.request(r.method,r.params),e.execApprovalsDirty=!1,await ji(e,t)}catch(t){e.lastError=String(t)}finally{e.execApprovalsSaving=!1}}}function Pi(e,t,n){let r=yn(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});Cn(r,t,n),e.execApprovalsForm=r,e.execApprovalsDirty=!0}function Fi(e,t){let n=yn(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});wn(n,t),e.execApprovalsForm=n,e.execApprovalsDirty=!0}async function Ii(e){if(!(!e.client||!e.connected)&&!e.presenceLoading){e.presenceLoading=!0,e.presenceError=null,e.presenceStatus=null;try{let 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){Yt(t)?(e.presenceEntries=[],e.presenceStatus=null,e.presenceError=Xt(`instance presence`)):e.presenceError=String(t)}finally{e.presenceLoading=!1}}}async function Li(e){if(!(!e.client||!e.connected))try{await e.client.request(`sessions.subscribe`,{})}catch(t){e.sessionsError=String(t)}}async function Ri(e,t){if(!(!e.client||!e.connected)&&!e.sessionsLoading){e.sessionsLoading=!0,e.sessionsError=null;try{let n=t?.includeGlobal??e.sessionsIncludeGlobal,r=t?.includeUnknown??e.sessionsIncludeUnknown,i=t?.activeMinutes??g(e.sessionsFilterActive,0),a=t?.limit??g(e.sessionsFilterLimit,0),o={includeGlobal:n,includeUnknown:r};i>0&&(o.activeMinutes=i),a>0&&(o.limit=a);let s=await e.client.request(`sessions.list`,o);s&&(e.sessionsResult=s)}catch(t){Yt(t)?(e.sessionsResult=null,e.sessionsError=Xt(`sessions`)):e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}async function zi(e,t,n){if(!e.client||!e.connected)return;let r={key:t};`label`in n&&(r.label=n.label),`thinkingLevel`in n&&(r.thinkingLevel=n.thinkingLevel),`fastMode`in n&&(r.fastMode=n.fastMode),`verboseLevel`in n&&(r.verboseLevel=n.verboseLevel),`reasoningLevel`in n&&(r.reasoningLevel=n.reasoningLevel);try{await e.client.request(`sessions.patch`,r),await Ri(e)}catch(t){e.sessionsError=String(t)}}async function Bi(e,t){if(!e.client||!e.connected||t.length===0||e.sessionsLoading)return[];let n=t.length===1?`session`:`sessions`;if(!window.confirm(`Delete ${t.length} ${n}?\n\nThis will delete the session entries and archive their transcripts.`))return[];e.sessionsLoading=!0,e.sessionsError=null;let r=[],i=[];try{for(let n of t)try{await e.client.request(`sessions.delete`,{key:n,deleteTranscript:!0}),r.push(n)}catch(e){i.push(String(e))}}finally{e.sessionsLoading=!1}return r.length>0&&await Ri(e),i.length>0&&(e.sessionsError=i.join(`; `)),r}function Vi(e,t,n){if(!t.trim())return;let r={...e.skillMessages};n?r[t]=n:delete r[t],e.skillMessages=r}function Hi(e){return e instanceof Error?e.message:String(e)}async function Ui(e,t){if(t?.clearMessages&&Object.keys(e.skillMessages).length>0&&(e.skillMessages={}),!(!e.client||!e.connected)&&!e.skillsLoading){e.skillsLoading=!0,e.skillsError=null;try{let t=await e.client.request(`skills.status`,{});t&&(e.skillsReport=t)}catch(t){e.skillsError=Hi(t)}finally{e.skillsLoading=!1}}}function Wi(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Gi(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 Ui(e),Vi(e,t,{kind:`success`,message:n?`Skill enabled`:`Skill disabled`})}catch(n){let r=Hi(n);e.skillsError=r,Vi(e,t,{kind:`error`,message:r})}finally{e.skillsBusyKey=null}}}async function Ki(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{let n=e.skillEdits[t]??``;await e.client.request(`skills.update`,{skillKey:t,apiKey:n}),await Ui(e),Vi(e,t,{kind:`success`,message:`API key saved`})}catch(n){let r=Hi(n);e.skillsError=r,Vi(e,t,{kind:`error`,message:r})}finally{e.skillsBusyKey=null}}}async function qi(e,t,n,r){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{let i=await e.client.request(`skills.install`,{name:n,installId:r,timeoutMs:12e4});await Ui(e),Vi(e,t,{kind:`success`,message:i?.message??`Installed`})}catch(n){let r=Hi(n);e.skillsError=r,Vi(e,t,{kind:`error`,message:r})}finally{e.skillsBusyKey=null}}}var Ji=`openclaw.control.usage.date-params.v1`,Yi=`__default__`,Xi=/unexpected property ['"]mode['"]/i,Zi=/unexpected property ['"]utcoffset['"]/i,Qi=/invalid sessions\.usage params/i,$i=null;function ea(){return w()}function ta(){let e=ea();if(!e)return new Set;try{let t=e.getItem(Ji);if(!t)return new Set;let n=JSON.parse(t);return!n||!Array.isArray(n.unsupportedGatewayKeys)?new Set:new Set(n.unsupportedGatewayKeys.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean))}catch{return new Set}}function na(e){let t=ea();if(t)try{t.setItem(Ji,JSON.stringify({unsupportedGatewayKeys:Array.from(e)}))}catch{}}function ra(){return $i||=ta(),$i}function ia(e){let t=e?.trim();if(!t)return Yi;try{let e=new URL(t),n=e.pathname===`/`?``:e.pathname;return`${e.protocol}//${e.host}${n}`.toLowerCase()}catch{return t.toLowerCase()}}function aa(e){return ia(e.settings?.gatewayUrl)}function oa(e){return!ra().has(aa(e))}function sa(e){let t=ra();t.add(aa(e)),na(t)}function ca(e){let t=da(e);return Qi.test(t)&&(Xi.test(t)||Zi.test(t))}var la=e=>{let t=-e,n=t>=0?`+`:`-`,r=Math.abs(t),i=Math.floor(r/60),a=r%60;return a===0?`UTC${n}${i}`:`UTC${n}${i}:${a.toString().padStart(2,`0`)}`},ua=(e,t)=>{if(t)return e===`utc`?{mode:`utc`}:{mode:`specific`,utcOffset:la(new Date().getTimezoneOffset())}};function da(e){if(typeof e==`string`)return e;if(e instanceof Error&&typeof e.message==`string`&&e.message.trim())return e.message;if(e&&typeof e==`object`)try{let t=JSON.stringify(e);if(t)return t}catch{}return`request failed`}async function fa(e,t){let n=e.client;if(!(!n||!e.connected)&&!e.usageLoading){e.usageLoading=!0,e.usageError=null;try{let r=t?.startDate??e.usageStartDate,i=t?.endDate??e.usageEndDate,a=async t=>{let a=ua(e.usageTimeZone,t);return await Promise.all([n.request(`sessions.usage`,{startDate:r,endDate:i,...a,limit:1e3,includeContextWeight:!0}),n.request(`usage.cost`,{startDate:r,endDate:i,...a})])},o=(t,n)=>{t&&(e.usageResult=t),n&&(e.usageCostSummary=n)},s=oa(e);try{let[e,t]=await a(s);o(e,t)}catch(t){if(s&&ca(t)){sa(e);let[t,n]=await a(!1);o(t,n)}else throw t}}catch(t){Yt(t)?(e.usageResult=null,e.usageCostSummary=null,e.usageError=Xt(`usage`)):e.usageError=da(t)}finally{e.usageLoading=!1}}}async function pa(e,t){if(!(!e.client||!e.connected)&&!e.usageTimeSeriesLoading){e.usageTimeSeriesLoading=!0,e.usageTimeSeries=null;try{let n=await e.client.request(`sessions.usage.timeseries`,{key:t});n&&(e.usageTimeSeries=n)}catch{e.usageTimeSeries=null}finally{e.usageTimeSeriesLoading=!1}}}async function ma(e,t){if(!(!e.client||!e.connected)&&!e.usageSessionLogsLoading){e.usageSessionLogsLoading=!0,e.usageSessionLogs=null;try{let n=await e.client.request(`sessions.usage.logs`,{key:t,limit:1e3});n&&Array.isArray(n.logs)&&(e.usageSessionLogs=n.logs)}catch{e.usageSessionLogs=null}finally{e.usageSessionLogsLoading=!1}}}var ha=[{label:`chat`,tabs:[`chat`]},{label:`control`,tabs:[`overview`,`channels`,`instances`,`sessions`,`usage`,`cron`]},{label:`agent`,tabs:[`agents`,`skills`,`nodes`]},{label:`settings`,tabs:[`config`,`communications`,`appearance`,`automation`,`infrastructure`,`aiAgents`,`debug`,`logs`]}],ga={agents:`/agents`,overview:`/overview`,channels:`/channels`,instances:`/instances`,sessions:`/sessions`,usage:`/usage`,cron:`/cron`,skills:`/skills`,nodes:`/nodes`,chat:`/chat`,config:`/config`,communications:`/communications`,appearance:`/appearance`,automation:`/automation`,infrastructure:`/infrastructure`,aiAgents:`/ai-agents`,debug:`/debug`,logs:`/logs`},_a=new Map(Object.entries(ga).map(([e,t])=>[t,e]));function va(e){if(!e)return``;let t=e.trim();return t.startsWith(`/`)||(t=`/${t}`),t===`/`?``:(t.endsWith(`/`)&&(t=t.slice(0,-1)),t)}function ya(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 ba(e,t=``){let n=va(t),r=ga[e];return n?`${n}${r}`:r}function xa(e,t=``){let n=va(t),r=e||`/`;n&&(r===n?r=`/`:r.startsWith(`${n}/`)&&(r=r.slice(n.length)));let i=ya(r).toLowerCase();return i.endsWith(`/index.html`)&&(i=`/`),i===`/`?`chat`:_a.get(i)??null}function Sa(e){let t=ya(e);if(t.endsWith(`/index.html`)&&(t=ya(t.slice(0,-11))),t===`/`)return``;let n=t.split(`/`).filter(Boolean);if(n.length===0)return``;for(let e=0;e<n.length;e++){let t=`/${n.slice(e).join(`/`)}`.toLowerCase();if(_a.has(t)){let t=n.slice(0,e);return t.length?`/${t.join(`/`)}`:``}}return`/${n.join(`/`)}`}function Ca(e){switch(e){case`agents`:return`folder`;case`chat`:return`messageSquare`;case`overview`:return`barChart`;case`channels`:return`link`;case`instances`:return`radio`;case`sessions`:return`fileText`;case`usage`:return`barChart`;case`cron`:return`loader`;case`skills`:return`zap`;case`nodes`:return`monitor`;case`config`:return`settings`;case`communications`:return`send`;case`appearance`:return`spark`;case`automation`:return`terminal`;case`infrastructure`:return`globe`;case`aiAgents`:return`brain`;case`debug`:return`bug`;case`logs`:return`scrollText`;default:return`folder`}}function wa(e){return P(`tabs.${e}`)}function Ta(e){return P(`subtitles.${e}`)}var Ea=new Set([`claw`,`knot`,`dash`]),Da=new Set([`system`,`light`,`dark`]),Oa={defaultTheme:{theme:`claw`,mode:`dark`},docsTheme:{theme:`claw`,mode:`light`},lightTheme:{theme:`knot`,mode:`dark`},landingTheme:{theme:`knot`,mode:`dark`},newTheme:{theme:`knot`,mode:`dark`},dark:{theme:`claw`,mode:`dark`},light:{theme:`claw`,mode:`light`},openknot:{theme:`knot`,mode:`dark`},fieldmanual:{theme:`dash`,mode:`dark`},clawdash:{theme:`dash`,mode:`light`},system:{theme:`claw`,mode:`system`}};function ka(){return typeof globalThis.matchMedia==`function`?globalThis.matchMedia(`(prefers-color-scheme: light)`).matches:!1}function Aa(e,t){let n=typeof e==`string`?e:``,r=typeof t==`string`?t:``;return{theme:Ea.has(n)?n:Oa[n]?.theme??`claw`,mode:Da.has(r)?r:Oa[n]?.mode??`system`}}function ja(e){return e===`system`?ka()?`light`:`dark`:e}function Ma(e,t){let n=ja(t);return e===`claw`?n===`light`?`light`:`dark`:e===`knot`?n===`light`?`openknot-light`:`openknot`:n===`light`?`dash-light`:`dash`}var Na=`openclaw.control.settings.v1:`,Pa=`openclaw.control.settings.v1`,Fa=`openclaw.control.token.v1`,Ia=`openclaw.control.token.v1:`,La=10;function Ra(e){return`${Na}${Ga(e)}`}var za=[0,25,50,75,100];function Ba(e){let t=za[0],n=Math.abs(e-t);for(let r of za){let i=Math.abs(e-r);i<n&&(t=r,n=i)}return t}function Va(){return typeof document>`u`?!1:!!document.querySelector(`script[src*="/@vite/client"]`)}function Ha(e,t){return`${e.includes(`:`)?`[${e}]`:e}:${t}`}function Ua(){let e=location.protocol===`https:`?`wss`:`ws`,t=typeof window<`u`&&typeof window.__OPENCLAW_CONTROL_UI_BASE_PATH__==`string`&&window.__OPENCLAW_CONTROL_UI_BASE_PATH__.trim(),n=t?va(t):Sa(location.pathname),r=`${e}://${location.host}${n}`;return Va()?{pageUrl:r,effectiveUrl:`${e}://${Ha(location.hostname,`18789`)}`}:{pageUrl:r,effectiveUrl:r}}function Wa(){return typeof window<`u`&&window.sessionStorage?window.sessionStorage:typeof sessionStorage<`u`?sessionStorage:null}function Ga(e){let t=e.trim();if(!t)return`default`;try{let e=typeof location<`u`?`${location.protocol}//${location.host}${location.pathname||`/`}`:void 0,n=e?new URL(t,e):new URL(t),r=n.pathname===`/`?``:n.pathname.replace(/\/+$/,``)||n.pathname;return`${n.protocol}//${n.host}${r}`}catch{return t}}function Ka(e){return`${Ia}${Ga(e)}`}function qa(e,t,n){let r=Ga(e),i=t.sessionsByGateway?.[r];if(i&&typeof i.sessionKey==`string`&&i.sessionKey.trim()&&typeof i.lastActiveSessionKey==`string`&&i.lastActiveSessionKey.trim())return{sessionKey:i.sessionKey.trim(),lastActiveSessionKey:i.lastActiveSessionKey.trim()};let a=typeof t.sessionKey==`string`&&t.sessionKey.trim()?t.sessionKey.trim():n.sessionKey;return{sessionKey:a,lastActiveSessionKey:typeof t.lastActiveSessionKey==`string`&&t.lastActiveSessionKey.trim()?t.lastActiveSessionKey.trim():a||n.lastActiveSessionKey}}function Ja(e){try{let t=Wa();return t?(t.removeItem(Fa),(t.getItem(Ka(e))??``).trim()):``}catch{return``}}function Ya(e,t){try{let n=Wa();if(!n)return;n.removeItem(Fa);let r=Ka(e),i=t.trim();if(i){n.setItem(r,i);return}n.removeItem(r)}catch{}}function Xa(){let{pageUrl:e,effectiveUrl:t}=Ua(),n=w(),r={gatewayUrl:t,token:Ja(t),sessionKey:`main`,lastActiveSessionKey:`main`,theme:`claw`,themeMode:`system`,chatFocusMode:!1,chatShowThinking:!0,chatShowToolCalls:!0,splitRatio:.6,navCollapsed:!1,navWidth:220,navGroupsCollapsed:{},borderRadius:50};try{let i=Ra(r.gatewayUrl),a=n?.getItem(i)??n?.getItem(Na+`default`)??n?.getItem(Pa);if(!a)return r;let o=JSON.parse(a),s=typeof o.gatewayUrl==`string`&&o.gatewayUrl.trim()?o.gatewayUrl.trim():r.gatewayUrl,c=s===e?t:s,l=qa(c,o,r),{theme:u,mode:d}=Aa(o.theme,o.themeMode),f={gatewayUrl:c,token:Ja(c),sessionKey:l.sessionKey,lastActiveSessionKey:l.lastActiveSessionKey,theme:u,themeMode:d,chatFocusMode:typeof o.chatFocusMode==`boolean`?o.chatFocusMode:r.chatFocusMode,chatShowThinking:typeof o.chatShowThinking==`boolean`?o.chatShowThinking:r.chatShowThinking,chatShowToolCalls:typeof o.chatShowToolCalls==`boolean`?o.chatShowToolCalls:r.chatShowToolCalls,splitRatio:typeof o.splitRatio==`number`&&o.splitRatio>=.4&&o.splitRatio<=.7?o.splitRatio:r.splitRatio,navCollapsed:typeof o.navCollapsed==`boolean`?o.navCollapsed:r.navCollapsed,navWidth:typeof o.navWidth==`number`&&o.navWidth>=200&&o.navWidth<=400?o.navWidth:r.navWidth,navGroupsCollapsed:typeof o.navGroupsCollapsed==`object`&&o.navGroupsCollapsed!==null?o.navGroupsCollapsed:r.navGroupsCollapsed,borderRadius:typeof o.borderRadius==`number`&&o.borderRadius>=0&&o.borderRadius<=100?Ba(o.borderRadius):r.borderRadius,locale:te(o.locale)?o.locale:void 0};return`token`in o&&Qa(f),f}catch{return r}}function Za(e){Qa(e)}function Qa(e){Ya(e.gatewayUrl,e.token);let t=w(),n=Ga(e.gatewayUrl),r=Ra(e.gatewayUrl),i={};try{let e=t?.getItem(r)??t?.getItem(Na+`default`)??t?.getItem(`openclaw.control.settings.v1`);if(e){let t=JSON.parse(e);t.sessionsByGateway&&typeof t.sessionsByGateway==`object`&&(i=t.sessionsByGateway)}}catch{}let a=Object.fromEntries([...Object.entries(i).filter(([e])=>e!==n),[n,{sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey}]].slice(-La)),o={gatewayUrl:e.gatewayUrl,theme:e.theme,themeMode:e.themeMode,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,chatShowToolCalls:e.chatShowToolCalls,splitRatio:e.splitRatio,navCollapsed:e.navCollapsed,navWidth:e.navWidth,navGroupsCollapsed:e.navGroupsCollapsed,borderRadius:e.borderRadius,sessionsByGateway:a,...e.locale?{locale:e.locale}:{}},s=JSON.stringify(o);try{t?.setItem(r,s),t?.setItem(Pa,s)}catch{}}var $a=e=>{e.classList.remove(`theme-transition`),e.style.removeProperty(`--theme-switch-x`),e.style.removeProperty(`--theme-switch-y`)},eo=({nextTheme:e,applyTheme:t,currentTheme:n})=>{if(n===e){t();return}let r=globalThis.document??null;if(!r){t();return}let i=r.documentElement;t(),$a(i)},{I:to}=e,no=e=>e,ro=e=>e.strings===void 0,io=()=>document.createComment(``),ao=(e,t,n)=>{let r=e._$AA.parentNode,i=t===void 0?e._$AB:t._$AA;if(n===void 0)n=new to(r.insertBefore(io(),i),r.insertBefore(io(),i),e,e.options);else{let t=n._$AB.nextSibling,a=n._$AM,o=a!==e;if(o){let t;n._$AQ?.(e),n._$AM=e,n._$AP!==void 0&&(t=e._$AU)!==a._$AU&&n._$AP(t)}if(t!==i||o){let e=n._$AA;for(;e!==t;){let t=no(e).nextSibling;no(r).insertBefore(e,i),e=t}}}return n},oo=(e,t,n=e)=>(e._$AI(t,n),e),so={},co=(e,t=so)=>e._$AH=t,lo=e=>e._$AH,uo=e=>{e._$AR(),e._$AA.remove()},fo={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},po=e=>(...t)=>({_$litDirective$:e,values:t}),mo=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n){this._$Ct=e,this._$AM=t,this._$Ci=n}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}},ho=(e,t)=>{let n=e._$AN;if(n===void 0)return!1;for(let e of n)e._$AO?.(t,!1),ho(e,t);return!0},go=e=>{let t,n;do{if((t=e._$AM)===void 0)break;n=t._$AN,n.delete(e),e=t}while(n?.size===0)},_o=e=>{for(let t;t=e._$AM;e=t){let n=t._$AN;if(n===void 0)t._$AN=n=new Set;else if(n.has(e))break;n.add(e),bo(t)}};function vo(e){this._$AN===void 0?this._$AM=e:(go(this),this._$AM=e,_o(this))}function yo(e,t=!1,n=0){let r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(t)if(Array.isArray(r))for(let e=n;e<r.length;e++)ho(r[e],!1),go(r[e]);else r!=null&&(ho(r,!1),go(r));else ho(this,e)}var bo=e=>{e.type==fo.CHILD&&(e._$AP??=yo,e._$AQ??=vo)},xo=class extends mo{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,n){super._$AT(e,t,n),_o(this),this.isConnected=e._$AU}_$AO(e,t=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),t&&(ho(this,e),go(this))}setValue(e){if(ro(this._$Ct))this._$Ct._$AI(e,this);else{let t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}},So=new WeakMap,Co=po(class extends xo{render(e){return i}update(e,[t]){let n=t!==this.G;return n&&this.G!==void 0&&this.rt(void 0),(n||this.lt!==this.ct)&&(this.G=t,this.ht=e.options?.host,this.rt(this.ct=e.element)),i}rt(e){if(this.isConnected||(e=void 0),typeof this.G==`function`){let t=this.ht??globalThis,n=So.get(t);n===void 0&&(n=new WeakMap,So.set(t,n)),n.get(this.G)!==void 0&&this.G.call(this.ht,void 0),n.set(this.G,e),e!==void 0&&this.G.call(this.ht,e)}else this.G.value=e}get lt(){return typeof this.G==`function`?So.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}}),wo=(e,t,n)=>{let r=new Map;for(let i=t;i<=n;i++)r.set(e[i],i);return r},To=po(class extends mo{constructor(e){if(super(e),e.type!==fo.CHILD)throw Error(`repeat() can only be used in text expressions`)}dt(e,t,n){let r;n===void 0?n=t:t!==void 0&&(r=t);let i=[],a=[],o=0;for(let t of e)i[o]=r?r(t,o):o,a[o]=n(t,o),o++;return{values:a,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,r]){let i=lo(e),{values:a,keys:s}=this.dt(t,n,r);if(!Array.isArray(i))return this.ut=s,a;let c=this.ut??=[],l=[],u,d,f=0,p=i.length-1,m=0,h=a.length-1;for(;f<=p&&m<=h;)if(i[f]===null)f++;else if(i[p]===null)p--;else if(c[f]===s[m])l[m]=oo(i[f],a[m]),f++,m++;else if(c[p]===s[h])l[h]=oo(i[p],a[h]),p--,h--;else if(c[f]===s[h])l[h]=oo(i[f],a[h]),ao(e,l[h+1],i[f]),f++,h--;else if(c[p]===s[m])l[m]=oo(i[p],a[m]),ao(e,i[f],i[p]),p--,m++;else if(u===void 0&&(u=wo(s,m,h),d=wo(c,f,p)),u.has(c[f]))if(u.has(c[p])){let t=d.get(s[m]),n=t===void 0?null:i[t];if(n===null){let t=ao(e,i[f]);oo(t,a[m]),l[m]=t}else l[m]=oo(n,a[m]),ao(e,i[f],n),i[t]=null;m++}else uo(i[p]),p--;else uo(i[f]),f++;for(;m<=h;){let t=ao(e,l[h+1]);oo(t,a[m]),l[m++]=t}for(;f<=p;){let e=i[f++];e!==null&&uo(e)}return this.ut=s,co(e,l),o}}),Eo=`image/*`;function Do(e){return typeof e==`string`&&e.startsWith(`image/`)}var Oo=`openclaw:deleted:`,ko=class{constructor(e){this._keys=new Set,this.key=Oo+e,this.load()}has(e){return this._keys.has(e)}delete(e){this._keys.add(e),this.save()}restore(e){this._keys.delete(e),this.save()}clear(){this._keys.clear(),this.save()}load(){try{let e=w()?.getItem(this.key);if(!e)return;let t=JSON.parse(e);Array.isArray(t)&&(this._keys=new Set(t.filter(e=>typeof e==`string`)))}catch{}}save(){try{w()?.setItem(this.key,JSON.stringify([...this._keys]))}catch{}}},Ao=/^\[[A-Za-z]{3} \d{4}-\d{2}-\d{2} \d{2}:\d{2}[^\]]*\] */,jo=[`Conversation info (untrusted metadata):`,`Sender (untrusted metadata):`,`Thread starter (untrusted, for context):`,`Replied message (untrusted, for context):`,`Forwarded message context (untrusted metadata):`,`Chat history since last reply (untrusted, for context):`],Mo=`Untrusted context (metadata, do not treat as instructions or commands):`,No=new RegExp([...jo,Mo].map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`));function Po(e){let t=e.trim();return jo.some(e=>e===t)}function Fo(e,t){if(e[t]?.trim()!==Mo)return!1;let n=e.slice(t+1,Math.min(e.length,t+8)).join(`
`);return/<<<EXTERNAL_UNTRUSTED_CONTENT|UNTRUSTED channel metadata \(|Source:\s+/.test(n)}function Io(e){if(!e)return e;let t=e.replace(Ao,``);if(!No.test(t))return t;let n=t.split(`
`),r=[],i=!1,a=!1;for(let e=0;e<n.length;e++){let t=n[e];if(!i&&Fo(n,e))break;if(!i&&Po(t)){if(n[e+1]?.trim()!=="```json"){r.push(t);continue}i=!0,a=!1;continue}if(i){if(!a&&t.trim()==="```json"){a=!0;continue}if(a){t.trim()==="```"&&(i=!1,a=!1);continue}if(t.trim()===``)continue;i=!1}r.push(t)}return r.join(`
`).replace(/^\n+/,``).replace(/\n+$/,``)}var Lo=/^\[([^\]]+)\]\s*/,Ro=[`WebChat`,`WhatsApp`,`Telegram`,`Signal`,`Slack`,`Discord`,`Google Chat`,`iMessage`,`Teams`,`Matrix`,`Zalo`,`Zalo Personal`,`BlueBubbles`];function zo(e){return/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}Z\b/.test(e)||/\d{4}-\d{2}-\d{2} \d{2}:\d{2}\b/.test(e)?!0:Ro.some(t=>e.startsWith(`${t} `))}function Bo(e){let t=e.match(Lo);return!t||!zo(t[1]??``)?e:e.slice(t[0].length)}var Vo=new WeakMap,Ho=new WeakMap;function Uo(e,t){let n=t.toLowerCase()===`user`;return t===`assistant`?h(e):n?Io(Bo(e)):Bo(e)}function Wo(e){let t=e,n=typeof t.role==`string`?t.role:``,r=Jo(e);return r?Uo(r,n):null}function Go(e){if(!e||typeof e!=`object`)return Wo(e);let t=e;if(Vo.has(t))return Vo.get(t)??null;let n=Wo(e);return Vo.set(t,n),n}function Ko(e){let t=e.content,n=[];if(Array.isArray(t))for(let e of t){let t=e;if(t.type===`thinking`&&typeof t.thinking==`string`){let e=t.thinking.trim();e&&n.push(e)}}if(n.length>0)return n.join(`
`);let r=Jo(e);if(!r)return null;let i=[...r.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(e=>(e[1]??``).trim()).filter(Boolean);return i.length>0?i.join(`
`):null}function qo(e){if(!e||typeof e!=`object`)return Ko(e);let t=e;if(Ho.has(t))return Ho.get(t)??null;let n=Ko(e);return Ho.set(t,n),n}function Jo(e){let t=e,n=t.content;if(typeof n==`string`)return n;if(Array.isArray(n)){let e=n.map(e=>{let t=e;return t.type===`text`&&typeof t.text==`string`?t.text:null}).filter(e=>typeof e==`string`);if(e.length>0)return e.join(`
`)}return typeof t.text==`string`?t.text:null}function Yo(e){let t=e.trim();if(!t)return``;let n=t.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>`_${e}_`);return n.length?[`_Reasoning:_`,...n].join(`
`):``}function Xo(e,t){let n=Zo(e,t);if(!n)return;let r=new Blob([n],{type:`text/markdown`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`chat-${t}-${Date.now()}.md`,a.click(),URL.revokeObjectURL(i)}function Zo(e,t){let n=Array.isArray(e)?e:[];if(n.length===0)return null;let r=[`# Chat with ${t}`,``];for(let e of n){let n=e,i=n.role===`user`?`You`:n.role===`assistant`?t:`Tool`,a=Go(e)??``,o=typeof n.timestamp==`number`?new Date(n.timestamp).toISOString():``;r.push(`## ${i}${o?` (${o})`:``}`,``,a,``)}return r.join(`
`)}var Qo=class extends mo{constructor(e){if(super(e),this.it=i,e.type!==fo.CHILD)throw Error(this.constructor.directiveName+`() can only be used in child bindings`)}render(e){if(e===i||e==null)return this._t=void 0,this.it=e;if(e===o)return e;if(typeof e!=`string`)throw Error(this.constructor.directiveName+`() called with a non-string value`);if(e===this.it)return this._t;this.it=e;let t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};Qo.directiveName=`unsafeHTML`,Qo.resultType=1;var $o=po(Qo),G={messageSquare:n`
<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:n`
<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:n`
<svg viewBox="0 0 24 24">
<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" />
<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />
</svg>
`,radio:n`
<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:n`
<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:n`
<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2" /></svg>
`,monitor:n`
<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>
`,sun:n`
<svg viewBox="0 0 24 24">
<circle cx="12" cy="12" r="4" />
<path d="M12 2v2" />
<path d="M12 20v2" />
<path d="m4.93 4.93 1.41 1.41" />
<path d="m17.66 17.66 1.41 1.41" />
<path d="M2 12h2" />
<path d="M20 12h2" />
<path d="m6.34 17.66-1.41 1.41" />
<path d="m19.07 4.93-1.41 1.41" />
</svg>
`,moon:n`
<svg viewBox="0 0 24 24">
<path d="M12 3a6.5 6.5 0 0 0 9 9 9 9 0 1 1-9-9Z" />
</svg>
`,settings:n`
<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:n`
<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:n`
<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:n`
<svg viewBox="0 0 24 24">
<path
d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
/>
</svg>
`,menu:n`
<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:n`
<svg viewBox="0 0 24 24">
<path d="M18 6 6 18" />
<path d="m6 6 12 12" />
</svg>
`,check:n`
<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5" /></svg>
`,arrowDown:n`
<svg viewBox="0 0 24 24">
<path d="M12 5v14" />
<path d="m19 12-7 7-7-7" />
</svg>
`,copy:n`
<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:n`
<svg viewBox="0 0 24 24">
<circle cx="11" cy="11" r="8" />
<path d="m21 21-4.3-4.3" />
</svg>
`,brain:n`
<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:n`
<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:n`
<svg viewBox="0 0 24 24">
<path d="M12 2v4" />
<path d="m16.2 7.8 2.9-2.9" />
<path d="M18 12h4" />
<path d="m16.2 16.2 2.9 2.9" />
<path d="M12 18v4" />
<path d="m4.9 19.1 2.9-2.9" />
<path d="M2 12h4" />
<path d="m4.9 4.9 2.9 2.9" />
</svg>
`,wrench:n`
<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:n`
<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:n`
<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:n`
<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:n`
<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:n`
<svg viewBox="0 0 24 24">
<circle cx="12" cy="12" r="10" />
<path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20" />
<path d="M2 12h20" />
</svg>
`,image:n`
<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:n`
<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:n`
<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:n`
<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" /></svg>
`,puzzle:n`
<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>
`,panelLeftClose:n`
<svg viewBox="0 0 24 24">
<rect x="3" y="3" width="18" height="18" rx="2" />
<path d="M9 3v18" stroke-linecap="round" />
<path d="M16 10l-3 2 3 2" stroke-linecap="round" stroke-linejoin="round" />
</svg>
`,panelLeftOpen:n`
<svg viewBox="0 0 24 24">
<rect x="3" y="3" width="18" height="18" rx="2" />
<path d="M9 3v18" stroke-linecap="round" />
<path d="M14 10l3 2-3 2" stroke-linecap="round" stroke-linejoin="round" />
</svg>
`,chevronDown:n`
<svg viewBox="0 0 24 24">
<path d="M6 9l6 6 6-6" stroke-linecap="round" stroke-linejoin="round" />
</svg>
`,chevronRight:n`
<svg viewBox="0 0 24 24">
<path d="M9 18l6-6-6-6" stroke-linecap="round" stroke-linejoin="round" />
</svg>
`,externalLink:n`
<svg viewBox="0 0 24 24">
<path
d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path d="M15 3h6v6M10 14L21 3" stroke-linecap="round" stroke-linejoin="round" />
</svg>
`,send:n`
<svg viewBox="0 0 24 24">
<path d="m22 2-7 20-4-9-9-4Z" />
<path d="M22 2 11 13" />
</svg>
`,stop:n`
<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="1" /></svg>
`,pin:n`
<svg viewBox="0 0 24 24">
<line x1="12" x2="12" y1="17" y2="22" />
<path
d="M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"
/>
</svg>
`,pinOff:n`
<svg viewBox="0 0 24 24">
<line x1="2" x2="22" y1="2" y2="22" />
<line x1="12" x2="12" y1="17" y2="22" />
<path
d="M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0-.39.04"
/>
</svg>
`,download:n`
<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>
`,mic:n`
<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>
`,micOff:n`
<svg viewBox="0 0 24 24">
<line x1="2" x2="22" y1="2" y2="22" />
<path d="M18.89 13.23A7.12 7.12 0 0 0 19 12v-2" />
<path d="M5 10v2a7 7 0 0 0 12 5" />
<path d="M15 9.34V5a3 3 0 0 0-5.68-1.33" />
<path d="M9 9v3a3 3 0 0 0 5.12 2.12" />
<line x1="12" x2="12" y1="19" y2="22" />
</svg>
`,volume2:n`
<svg viewBox="0 0 24 24">
<polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5" />
<path d="M15.54 8.46a5 5 0 0 1 0 7.07" />
<path d="M19.07 4.93a10 10 0 0 1 0 14.14" />
</svg>
`,volumeOff:n`
<svg viewBox="0 0 24 24">
<polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5" />
<line x1="22" x2="16" y1="9" y2="15" />
<line x1="16" x2="22" y1="9" y2="15" />
</svg>
`,bookmark:n`
<svg viewBox="0 0 24 24"><path d="m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z" /></svg>
`,plus:n`
<svg viewBox="0 0 24 24">
<path d="M5 12h14" />
<path d="M12 5v14" />
</svg>
`,terminal:n`
<svg viewBox="0 0 24 24">
<polyline points="4 17 10 11 4 5" />
<line x1="12" x2="20" y1="19" y2="19" />
</svg>
`,spark:n`
<svg viewBox="0 0 24 24">
<path
d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"
/>
</svg>
`,lobster:n`
<svg viewBox="0 0 120 120" fill="none">
<defs>
<linearGradient id="lob-g" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#ff4d4d" />
<stop offset="100%" stop-color="#991b1b" />
</linearGradient>
</defs>
<path
d="M60 10C30 10 15 35 15 55C15 75 30 95 45 100L45 110L55 110L55 100C55 100 60 102 65 100L65 110L75 110L75 100C90 95 105 75 105 55C105 35 90 10 60 10Z"
fill="url(#lob-g)"
/>
<path d="M20 45C5 40 0 50 5 60C10 70 20 65 25 55C28 48 25 45 20 45Z" fill="url(#lob-g)" />
<path
d="M100 45C115 40 120 50 115 60C110 70 100 65 95 55C92 48 95 45 100 45Z"
fill="url(#lob-g)"
/>
<path d="M45 15Q35 5 30 8" stroke="#ff4d4d" stroke-width="3" stroke-linecap="round" />
<path d="M75 15Q85 5 90 8" stroke="#ff4d4d" stroke-width="3" stroke-linecap="round" />
<circle cx="45" cy="35" r="6" fill="#050810" />
<circle cx="75" cy="35" r="6" fill="#050810" />
<circle cx="46" cy="34" r="2.5" fill="#00e5cc" />
<circle cx="76" cy="34" r="2.5" fill="#00e5cc" />
</svg>
`,refresh:n`
<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>
`,trash:n`
<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" />
<line x1="10" x2="10" y1="11" y2="17" />
<line x1="14" x2="14" y1="11" y2="17" />
</svg>
`,eye:n`
<svg viewBox="0 0 24 24">
<path
d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"
/>
<circle cx="12" cy="12" r="3" />
</svg>
`,eyeOff:n`
<svg viewBox="0 0 24 24">
<path
d="M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"
/>
<path d="M14.084 14.158a3 3 0 0 1-4.242-4.242" />
<path
d="M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"
/>
<path d="m2 2 20 20" />
</svg>
`,moreHorizontal:n`
<svg viewBox="0 0 24 24">
<circle cx="12" cy="12" r="1.5" />
<circle cx="6" cy="12" r="1.5" />
<circle cx="18" cy="12" r="1.5" />
</svg>
`,arrowUpDown:n`
<svg viewBox="0 0 24 24">
<path d="m21 16-4 4-4-4" />
<path d="M17 20V4" />
<path d="m3 8 4-4 4 4" />
<path d="M7 4v16" />
</svg>
`,panelRightOpen:n`
<svg viewBox="0 0 24 24">
<rect x="3" y="3" width="18" height="18" rx="2" />
<path d="M15 3v18" stroke-linecap="round" />
<path d="M10 10l-3 2 3 2" stroke-linecap="round" stroke-linejoin="round" />
</svg>
`},{entries:es,setPrototypeOf:ts,isFrozen:ns,getPrototypeOf:rs,getOwnPropertyDescriptor:is}=Object,{freeze:as,seal:os,create:ss}=Object,{apply:cs,construct:ls}=typeof Reflect<`u`&&Reflect;as||=function(e){return e},os||=function(e){return e},cs||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},ls||=function(e){return new e(...[...arguments].slice(1))};var us=ws(Array.prototype.forEach),ds=ws(Array.prototype.lastIndexOf),fs=ws(Array.prototype.pop),ps=ws(Array.prototype.push),ms=ws(Array.prototype.splice),hs=ws(String.prototype.toLowerCase),gs=ws(String.prototype.toString),_s=ws(String.prototype.match),vs=ws(String.prototype.replace),ys=ws(String.prototype.indexOf),bs=ws(String.prototype.trim),xs=ws(Object.prototype.hasOwnProperty),Ss=ws(RegExp.prototype.test),Cs=Ts(TypeError);function ws(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return cs(e,t,n)}}function Ts(e){return function(){return ls(e,[...arguments])}}function K(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:hs;ts&&ts(e,null);let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(ns(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Es(e){for(let t=0;t<e.length;t++)xs(e,t)||(e[t]=null);return e}function Ds(e){let t=ss(null);for(let[n,r]of es(e))xs(e,n)&&(Array.isArray(r)?t[n]=Es(r):r&&typeof r==`object`&&r.constructor===Object?t[n]=Ds(r):t[n]=r);return t}function Os(e,t){for(;e!==null;){let n=is(e,t);if(n){if(n.get)return ws(n.get);if(typeof n.value==`function`)return ws(n.value)}e=rs(e)}function n(){return null}return n}var ks=as(`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`.split(`.`)),As=as(`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`.split(`.`)),js=as([`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`]),Ms=as([`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`]),Ns=as(`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`.split(`.`)),Ps=as([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Fs=as([`#text`]),Is=as(`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`.split(`.`)),Ls=as(`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`.split(`.`)),Rs=as(`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`.split(`.`)),zs=as([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Bs=os(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Vs=os(/<%[\w\W]*|[\w\W]*%>/gm),Hs=os(/\$\{[\w\W]*/gm),Us=os(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ws=os(/^aria-[\-\w]+$/),Gs=os(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ks=os(/^(?:\w+script|data):/i),qs=os(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Js=os(/^html$/i),Ys=os(/^[a-z][.\w]*(-[.\w]+)+$/i),Xs=Object.freeze({__proto__:null,ARIA_ATTR:Ws,ATTR_WHITESPACE:qs,CUSTOM_ELEMENT:Ys,DATA_ATTR:Us,DOCTYPE_NAME:Js,ERB_EXPR:Vs,IS_ALLOWED_URI:Gs,IS_SCRIPT_OR_DATA:Ks,MUSTACHE_EXPR:Bs,TMPLIT_EXPR:Hs}),Zs={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Qs=function(){return typeof window>`u`?null:window},$s=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},ec=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function tc(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Qs(),t=e=>tc(e);if(t.version=`3.3.3`,t.removed=[],!e||!e.document||e.document.nodeType!==Zs.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e,r=n,i=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:s,Element:c,NodeFilter:l,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:f,trustedTypes:p}=e,m=c.prototype,h=Os(m,`cloneNode`),g=Os(m,`remove`),_=Os(m,`nextSibling`),v=Os(m,`childNodes`),y=Os(m,`parentNode`);if(typeof o==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let b,x=``,{implementation:S,createNodeIterator:C,createDocumentFragment:w,getElementsByTagName:T}=n,{importNode:E}=r,D=ec();t.isSupported=typeof es==`function`&&typeof y==`function`&&S&&S.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:O,ERB_EXPR:k,TMPLIT_EXPR:A,DATA_ATTR:ee,ARIA_ATTR:j,IS_SCRIPT_OR_DATA:te,ATTR_WHITESPACE:M,CUSTOM_ELEMENT:ne}=Xs,{IS_ALLOWED_URI:re}=Xs,N=null,P=K({},[...ks,...As,...js,...Ns,...Fs]),F=null,I=K({},[...Is,...Ls,...Rs,...zs]),L=Object.seal(ss(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}})),ie=null,ae=null,R=Object.seal(ss(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),oe=!0,se=!0,ce=!1,le=!0,ue=!1,de=!0,fe=!1,pe=!1,me=!1,he=!1,ge=!1,_e=!1,ve=!0,ye=!1,be=!0,z=!1,xe={},Se=null,Ce=K({},[`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`]),we=null,Te=K({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ee=null,De=K({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Oe=`http://www.w3.org/1998/Math/MathML`,ke=`http://www.w3.org/2000/svg`,B=`http://www.w3.org/1999/xhtml`,Ae=B,je=!1,Me=null,Ne=K({},[Oe,ke,B],gs),Pe=K({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Fe=K({},[`annotation-xml`]),Ie=K({},[`title`,`style`,`font`,`a`,`script`]),Le=null,Re=[`application/xhtml+xml`,`text/html`],V=null,ze=null,Be=n.createElement(`form`),Ve=function(e){return e instanceof RegExp||e instanceof Function},He=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ze&&ze===e)){if((!e||typeof e!=`object`)&&(e={}),e=Ds(e),Le=Re.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,V=Le===`application/xhtml+xml`?gs:hs,N=xs(e,`ALLOWED_TAGS`)?K({},e.ALLOWED_TAGS,V):P,F=xs(e,`ALLOWED_ATTR`)?K({},e.ALLOWED_ATTR,V):I,Me=xs(e,`ALLOWED_NAMESPACES`)?K({},e.ALLOWED_NAMESPACES,gs):Ne,Ee=xs(e,`ADD_URI_SAFE_ATTR`)?K(Ds(De),e.ADD_URI_SAFE_ATTR,V):De,we=xs(e,`ADD_DATA_URI_TAGS`)?K(Ds(Te),e.ADD_DATA_URI_TAGS,V):Te,Se=xs(e,`FORBID_CONTENTS`)?K({},e.FORBID_CONTENTS,V):Ce,ie=xs(e,`FORBID_TAGS`)?K({},e.FORBID_TAGS,V):Ds({}),ae=xs(e,`FORBID_ATTR`)?K({},e.FORBID_ATTR,V):Ds({}),xe=xs(e,`USE_PROFILES`)?e.USE_PROFILES:!1,oe=e.ALLOW_ARIA_ATTR!==!1,se=e.ALLOW_DATA_ATTR!==!1,ce=e.ALLOW_UNKNOWN_PROTOCOLS||!1,le=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ue=e.SAFE_FOR_TEMPLATES||!1,de=e.SAFE_FOR_XML!==!1,fe=e.WHOLE_DOCUMENT||!1,he=e.RETURN_DOM||!1,ge=e.RETURN_DOM_FRAGMENT||!1,_e=e.RETURN_TRUSTED_TYPE||!1,me=e.FORCE_BODY||!1,ve=e.SANITIZE_DOM!==!1,ye=e.SANITIZE_NAMED_PROPS||!1,be=e.KEEP_CONTENT!==!1,z=e.IN_PLACE||!1,re=e.ALLOWED_URI_REGEXP||Gs,Ae=e.NAMESPACE||B,Pe=e.MATHML_TEXT_INTEGRATION_POINTS||Pe,Fe=e.HTML_INTEGRATION_POINTS||Fe,L=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&Ve(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(L.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&Ve(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(L.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements==`boolean`&&(L.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ue&&(se=!1),ge&&(he=!0),xe&&(N=K({},Fs),F=ss(null),xe.html===!0&&(K(N,ks),K(F,Is)),xe.svg===!0&&(K(N,As),K(F,Ls),K(F,zs)),xe.svgFilters===!0&&(K(N,js),K(F,Ls),K(F,zs)),xe.mathMl===!0&&(K(N,Ns),K(F,Rs),K(F,zs))),xs(e,`ADD_TAGS`)||(R.tagCheck=null),xs(e,`ADD_ATTR`)||(R.attributeCheck=null),e.ADD_TAGS&&(typeof e.ADD_TAGS==`function`?R.tagCheck=e.ADD_TAGS:(N===P&&(N=Ds(N)),K(N,e.ADD_TAGS,V))),e.ADD_ATTR&&(typeof e.ADD_ATTR==`function`?R.attributeCheck=e.ADD_ATTR:(F===I&&(F=Ds(F)),K(F,e.ADD_ATTR,V))),e.ADD_URI_SAFE_ATTR&&K(Ee,e.ADD_URI_SAFE_ATTR,V),e.FORBID_CONTENTS&&(Se===Ce&&(Se=Ds(Se)),K(Se,e.FORBID_CONTENTS,V)),e.ADD_FORBID_CONTENTS&&(Se===Ce&&(Se=Ds(Se)),K(Se,e.ADD_FORBID_CONTENTS,V)),be&&(N[`#text`]=!0),fe&&K(N,[`html`,`head`,`body`]),N.table&&(K(N,[`tbody`]),delete ie.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Cs(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Cs(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);b=e.TRUSTED_TYPES_POLICY,x=b.createHTML(``)}else b===void 0&&(b=$s(p,i)),b!==null&&typeof x==`string`&&(x=b.createHTML(``));as&&as(e),ze=e}},Ue=K({},[...As,...js,...Ms]),We=K({},[...Ns,...Ps]),Ge=function(e){let t=y(e);(!t||!t.tagName)&&(t={namespaceURI:Ae,tagName:`template`});let n=hs(e.tagName),r=hs(t.tagName);return Me[e.namespaceURI]?e.namespaceURI===ke?t.namespaceURI===B?n===`svg`:t.namespaceURI===Oe?n===`svg`&&(r===`annotation-xml`||Pe[r]):!!Ue[n]:e.namespaceURI===Oe?t.namespaceURI===B?n===`math`:t.namespaceURI===ke?n===`math`&&Fe[r]:!!We[n]:e.namespaceURI===B?t.namespaceURI===ke&&!Fe[r]||t.namespaceURI===Oe&&!Pe[r]?!1:!We[n]&&(Ie[n]||!Ue[n]):!!(Le===`application/xhtml+xml`&&Me[e.namespaceURI]):!1},H=function(e){ps(t.removed,{element:e});try{y(e).removeChild(e)}catch{g(e)}},Ke=function(e,n){try{ps(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{ps(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(he||ge)try{H(n)}catch{}else try{n.setAttribute(e,``)}catch{}},qe=function(e){let t=null,r=null;if(me)e=`<remove></remove>`+e;else{let t=_s(e,/^[\r\n\t ]+/);r=t&&t[0]}Le===`application/xhtml+xml`&&Ae===B&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=b?b.createHTML(e):e;if(Ae===B)try{t=new f().parseFromString(i,Le)}catch{}if(!t||!t.documentElement){t=S.createDocument(Ae,`template`,null);try{t.documentElement.innerHTML=je?x:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ae===B?T.call(t,fe?`html`:`body`)[0]:fe?t.documentElement:a},Je=function(e){return C.call(e.ownerDocument||e,e,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Ye=function(e){return e instanceof d&&(typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||!(e.attributes instanceof u)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`)},Xe=function(e){return typeof s==`function`&&e instanceof s};function Ze(e,n,r){us(e,e=>{e.call(t,n,r,ze)})}let Qe=function(e){let n=null;if(Ze(D.beforeSanitizeElements,e,null),Ye(e))return H(e),!0;let r=V(e.nodeName);if(Ze(D.uponSanitizeElement,e,{tagName:r,allowedTags:N}),de&&e.hasChildNodes()&&!Xe(e.firstElementChild)&&Ss(/<[/\w!]/g,e.innerHTML)&&Ss(/<[/\w!]/g,e.textContent)||e.nodeType===Zs.progressingInstruction||de&&e.nodeType===Zs.comment&&Ss(/<[/\w]/g,e.data))return H(e),!0;if(!(R.tagCheck instanceof Function&&R.tagCheck(r))&&(!N[r]||ie[r])){if(!ie[r]&&et(r)&&(L.tagNameCheck instanceof RegExp&&Ss(L.tagNameCheck,r)||L.tagNameCheck instanceof Function&&L.tagNameCheck(r)))return!1;if(be&&!Se[r]){let t=y(e)||e.parentNode,n=v(e)||e.childNodes;if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=h(n[i],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,_(e))}}}return H(e),!0}return e instanceof c&&!Ge(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&Ss(/<\/no(script|embed|frames)/i,e.innerHTML)?(H(e),!0):(ue&&e.nodeType===Zs.text&&(n=e.textContent,us([O,k,A],e=>{n=vs(n,e,` `)}),e.textContent!==n&&(ps(t.removed,{element:e.cloneNode()}),e.textContent=n)),Ze(D.afterSanitizeElements,e,null),!1)},$e=function(e,t,r){if(ae[t]||ve&&(t===`id`||t===`name`)&&(r in n||r in Be))return!1;if(!(se&&!ae[t]&&Ss(ee,t))&&!(oe&&Ss(j,t))&&!(R.attributeCheck instanceof Function&&R.attributeCheck(t,e))){if(!F[t]||ae[t]){if(!(et(e)&&(L.tagNameCheck instanceof RegExp&&Ss(L.tagNameCheck,e)||L.tagNameCheck instanceof Function&&L.tagNameCheck(e))&&(L.attributeNameCheck instanceof RegExp&&Ss(L.attributeNameCheck,t)||L.attributeNameCheck instanceof Function&&L.attributeNameCheck(t,e))||t===`is`&&L.allowCustomizedBuiltInElements&&(L.tagNameCheck instanceof RegExp&&Ss(L.tagNameCheck,r)||L.tagNameCheck instanceof Function&&L.tagNameCheck(r))))return!1}else if(!Ee[t]&&!Ss(re,vs(r,M,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&ys(r,`data:`)===0&&we[e])&&!(ce&&!Ss(te,vs(r,M,``)))&&r)return!1}return!0},et=function(e){return e!==`annotation-xml`&&_s(e,ne)},tt=function(e){Ze(D.beforeSanitizeAttributes,e,null);let{attributes:n}=e;if(!n||Ye(e))return;let r={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:F,forceKeepAttr:void 0},i=n.length;for(;i--;){let{name:a,namespaceURI:o,value:s}=n[i],c=V(a),l=s,u=a===`value`?l:bs(l);if(r.attrName=c,r.attrValue=u,r.keepAttr=!0,r.forceKeepAttr=void 0,Ze(D.uponSanitizeAttribute,e,r),u=r.attrValue,ye&&(c===`id`||c===`name`)&&(Ke(a,e),u=`user-content-`+u),de&&Ss(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)){Ke(a,e);continue}if(c===`attributename`&&_s(u,`href`)){Ke(a,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){Ke(a,e);continue}if(!le&&Ss(/\/>/i,u)){Ke(a,e);continue}ue&&us([O,k,A],e=>{u=vs(u,e,` `)});let d=V(e.nodeName);if(!$e(d,c,u)){Ke(a,e);continue}if(b&&typeof p==`object`&&typeof p.getAttributeType==`function`&&!o)switch(p.getAttributeType(d,c)){case`TrustedHTML`:u=b.createHTML(u);break;case`TrustedScriptURL`:u=b.createScriptURL(u);break}if(u!==l)try{o?e.setAttributeNS(o,a,u):e.setAttribute(a,u),Ye(e)?H(e):fs(t.removed)}catch{Ke(a,e)}}Ze(D.afterSanitizeAttributes,e,null)},nt=function e(t){let n=null,r=Je(t);for(Ze(D.beforeSanitizeShadowDOM,t,null);n=r.nextNode();)Ze(D.uponSanitizeShadowNode,n,null),Qe(n),tt(n),n.content instanceof a&&e(n.content);Ze(D.afterSanitizeShadowDOM,t,null)};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,o=null,c=null,l=null;if(je=!e,je&&(e=`<!-->`),typeof e!=`string`&&!Xe(e))if(typeof e.toString==`function`){if(e=e.toString(),typeof e!=`string`)throw Cs(`dirty is not a string, aborting`)}else throw Cs(`toString is not a function`);if(!t.isSupported)return e;if(pe||He(n),t.removed=[],typeof e==`string`&&(z=!1),z){if(e.nodeName){let t=V(e.nodeName);if(!N[t]||ie[t])throw Cs(`root node is forbidden and cannot be sanitized in-place`)}}else if(e instanceof s)i=qe(`<!---->`),o=i.ownerDocument.importNode(e,!0),o.nodeType===Zs.element&&o.nodeName===`BODY`||o.nodeName===`HTML`?i=o:i.appendChild(o);else{if(!he&&!ue&&!fe&&e.indexOf(`<`)===-1)return b&&_e?b.createHTML(e):e;if(i=qe(e),!i)return he?null:_e?x:``}i&&me&&H(i.firstChild);let u=Je(z?e:i);for(;c=u.nextNode();)Qe(c),tt(c),c.content instanceof a&&nt(c.content);if(z)return e;if(he){if(ge)for(l=w.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(F.shadowroot||F.shadowrootmode)&&(l=E.call(r,l,!0)),l}let d=fe?i.outerHTML:i.innerHTML;return fe&&N[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Ss(Js,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
`+d),ue&&us([O,k,A],e=>{d=vs(d,e,` `)}),b&&_e?b.createHTML(d):d},t.setConfig=function(){He(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),pe=!0},t.clearConfig=function(){ze=null,pe=!1},t.isValidAttribute=function(e,t,n){return ze||He({}),$e(V(e),V(t),n)},t.addHook=function(e,t){typeof t==`function`&&ps(D[e],t)},t.removeHook=function(e,t){if(t!==void 0){let n=ds(D[e],t);return n===-1?void 0:ms(D[e],n,1)[0]}return fs(D[e])},t.removeHooks=function(e){D[e]=[]},t.removeAllHooks=function(){D=ec()},t}var nc=tc();function rc(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ic=rc();function ac(e){ic=e}var oc={exec:()=>null};function q(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(cc.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var sc=(()=>{try{return!0}catch{return!1}})(),cc={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,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,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},lc=/^(?:[ \t]*(?:\n|$))+/,uc=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,dc=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,fc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,pc=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,mc=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,hc=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,gc=q(hc).replace(/bull/g,mc).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(),_c=q(hc).replace(/bull/g,mc).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(),vc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,yc=/^[^\n]+/,bc=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,xc=q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,bc).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Sc=q(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,mc).getRegex(),Cc=`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`,wc=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Tc=q(`^ {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`,wc).replace(`tag`,Cc).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ec=q(vc).replace(`hr`,fc).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[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Cc).getRegex(),Dc={blockquote:q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Ec).getRegex(),code:uc,def:xc,fences:dc,heading:pc,hr:fc,html:Tc,lheading:gc,list:Sc,newline:lc,paragraph:Ec,table:oc,text:yc},Oc=q(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,fc).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[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Cc).getRegex(),kc={...Dc,lheading:_c,table:Oc,paragraph:q(vc).replace(`hr`,fc).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Oc).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Cc).getRegex()},Ac={...Dc,html:q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,wc).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:oc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:q(vc).replace(`hr`,fc).replace(`heading`,` *#{1,6} *[^
]`).replace(`lheading`,gc).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},jc=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Mc=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Nc=/^( {2,}|\\)\n(?!\s*$)/,Pc=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Fc=/[\p{P}\p{S}]/u,Ic=/[\s\p{P}\p{S}]/u,Lc=/[^\s\p{P}\p{S}]/u,Rc=q(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Ic).getRegex(),zc=/(?!~)[\p{P}\p{S}]/u,Bc=/(?!~)[\s\p{P}\p{S}]/u,Vc=/(?:[^\s\p{P}\p{S}]|~)/u,Hc=q(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,sc?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Uc=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Wc=q(Uc,`u`).replace(/punct/g,Fc).getRegex(),Gc=q(Uc,`u`).replace(/punct/g,zc).getRegex(),Kc=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,qc=q(Kc,`gu`).replace(/notPunctSpace/g,Lc).replace(/punctSpace/g,Ic).replace(/punct/g,Fc).getRegex(),Jc=q(Kc,`gu`).replace(/notPunctSpace/g,Vc).replace(/punctSpace/g,Bc).replace(/punct/g,zc).getRegex(),Yc=q(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Lc).replace(/punctSpace/g,Ic).replace(/punct/g,Fc).getRegex(),Xc=q(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Fc).getRegex(),Zc=q(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Lc).replace(/punctSpace/g,Ic).replace(/punct/g,Fc).getRegex(),Qc=q(/\\(punct)/,`gu`).replace(/punct/g,Fc).getRegex(),$c=q(/^<(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(),el=q(wc).replace(`(?:-->|$)`,`-->`).getRegex(),tl=q(`^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`,el).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),nl=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,rl=q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,nl).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),il=q(/^!?\[(label)\]\[(ref)\]/).replace(`label`,nl).replace(`ref`,bc).getRegex(),al=q(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,bc).getRegex(),ol=q(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,il).replace(`nolink`,al).getRegex(),sl=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,cl={_backpedal:oc,anyPunctuation:Qc,autolink:$c,blockSkip:Hc,br:Nc,code:Mc,del:oc,delLDelim:oc,delRDelim:oc,emStrongLDelim:Wc,emStrongRDelimAst:qc,emStrongRDelimUnd:Yc,escape:jc,link:rl,nolink:al,punctuation:Rc,reflink:il,reflinkSearch:ol,tag:tl,text:Pc,url:oc},ll={...cl,link:q(/^!?\[(label)\]\((.*?)\)/).replace(`label`,nl).getRegex(),reflink:q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,nl).getRegex()},ul={...cl,emStrongRDelimAst:Jc,emStrongLDelim:Gc,delLDelim:Xc,delRDelim:Zc,url:q(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,sl).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:q(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,sl).getRegex()},dl={...ul,br:q(Nc).replace(`{2,}`,`*`).getRegex(),text:q(ul.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},fl={normal:Dc,gfm:kc,pedantic:Ac},pl={normal:cl,gfm:ul,breaks:dl,pedantic:ll},ml={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},hl=e=>ml[e];function gl(e,t){if(t){if(cc.escapeTest.test(e))return e.replace(cc.escapeReplace,hl)}else if(cc.escapeTestNoEncode.test(e))return e.replace(cc.escapeReplaceNoEncode,hl);return e}function _l(e){try{e=encodeURI(e).replace(cc.percentDecode,`%`)}catch{return null}return e}function vl(e,t){let n=e.replace(cc.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(cc.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(cc.slashPipe,`|`);return n}function yl(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function bl(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function xl(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function Sl(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function Cl(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
`)}var wl=class{options;rules;lexer;constructor(e){this.options=e||ic}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:yl(e,`
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Cl(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=yl(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:yl(t[0],`
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=yl(t[0],`
`).split(`
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
${s}`:s,r=r?`${r}
${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=t.raw+`
`+e.join(`
`),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
`+e.join(`
`),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
`);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=xl(t[2].split(`
`,1)[0],t[1].length),l=e.split(`
`,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
`,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
`,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
`+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
`+l}u=!l.trim(),r+=p+`
`,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,``),e.tokens[0]?.type===`text`||e.tokens[0]?.type===`paragraph`){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,``),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:`checkbox`,raw:t[0]+` `,checked:t[0]!==`[ ]`};e.checked=n.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:`paragraph`,raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=vl(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
`):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(vl(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=yl(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=bl(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Sl(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return Sl(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},Tl=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ic,this.options.tokenizer=this.options.tokenizer||new wl,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:cc,block:fl.normal,inline:pl.normal};this.options.pedantic?(t.block=fl.pedantic,t.inline=pl.pedantic):this.options.gfm&&(t.block=fl.gfm,this.options.breaks?t.inline=pl.breaks:t.inline=pl.gfm),this.tokenizer.rules=t}static get rules(){return{block:fl,inline:pl}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(cc.carriageReturn,`
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(cc.tabCharGlobal,` `).replace(cc.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
`:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
`)?``:`
`)+r.raw,n.text+=`
`+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
`)?``:`
`)+r.raw,n.text+=`
`+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=t.at(-1);n&&a?.type===`paragraph`?(a.raw+=(a.raw.endsWith(`
`)?``:`
`)+r.raw,a.text+=`
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
`)?``:`
`)+r.raw,n.text+=`
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},El=class{options;parser;constructor(e){this.options=e||ic}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(cc.notSpaceStart)?.[0],i=e.replace(cc.endingNewline,``)+`
`;return r?`<pre><code class="language-`+gl(r)+`">`+(n?i:gl(i,!0))+`</code></pre>
`:`<pre><code>`+(n?i:gl(i,!0))+`</code></pre>
`}blockquote({tokens:e}){return`<blockquote>
${this.parser.parse(e)}</blockquote>
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
`}hr(e){return`<hr>
`}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
`+r+`</`+i+`>
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
`}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
<thead>
`+t+`</thead>
`+r+`</table>
`}tablerow({text:e}){return`<tr>
${e}</tr>
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${gl(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=_l(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+gl(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=_l(e);if(i===null)return gl(n);e=i;let a=`<img src="${e}" alt="${gl(n)}"`;return t&&(a+=` title="${gl(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:gl(e.text)}},Dl=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Ol=class e{options;renderer;textRenderer;constructor(e){this.options=e||ic,this.options.renderer=this.options.renderer||new El,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Dl}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},kl=class{options;block;constructor(e){this.options=e||ic}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Tl.lex:Tl.lexInline}provideParser(){return this.block?Ol.parse:Ol.parseInline}},Al=new class{defaults=rc();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ol;Renderer=El;TextRenderer=Dl;Lexer=Tl;Tokenizer=wl;Hooks=kl;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new El(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new wl(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new kl;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];kl.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&kl.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Tl.lex(e,t??this.defaults)}parser(e,t){return Ol.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?Tl.lex:Tl.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser():e?Ol.parse:Ol.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?Tl.lex:Tl.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?Ol.parse:Ol.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+gl(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function J(e,t){return Al.parse(e,t)}J.options=J.setOptions=function(e){return Al.setOptions(e),J.defaults=Al.defaults,ac(J.defaults),J},J.getDefaults=rc,J.defaults=ic,J.use=function(...e){return Al.use(...e),J.defaults=Al.defaults,ac(J.defaults),J},J.walkTokens=function(e,t){return Al.walkTokens(e,t)},J.parseInline=Al.parseInline,J.Parser=Ol,J.parser=Ol.parse,J.Renderer=El,J.TextRenderer=Dl,J.Lexer=Tl,J.lexer=Tl.lex,J.Tokenizer=wl,J.Hooks=kl,J.parse=J,J.options,J.setOptions,J.use,J.walkTokens,J.parseInline,Ol.parse,Tl.lex;var jl={ALLOWED_TAGS:`a.b.blockquote.br.button.code.del.details.div.em.h1.h2.h3.h4.hr.i.li.ol.p.pre.span.strong.summary.table.tbody.td.th.thead.tr.ul.img`.split(`.`),ALLOWED_ATTR:[`class`,`href`,`rel`,`target`,`title`,`start`,`src`,`alt`,`data-code`,`type`,`aria-label`],ADD_DATA_URI_TAGS:[`img`]},Ml=!1,Nl=14e4,Pl=4e4,Fl=200,Il=5e4,Ll=/^data:image\/[a-z0-9.+-]+;base64,/i,Rl=new Map,zl=`chat-link-tail-blur`;function Bl(e){let t=Rl.get(e);return t===void 0?null:(Rl.delete(e),Rl.set(e,t),t)}function Vl(e,t){if(Rl.set(e,t),Rl.size<=Fl)return;let n=Rl.keys().next().value;n&&Rl.delete(n)}function Hl(){Ml||(Ml=!0,nc.addHook(`afterSanitizeAttributes`,e=>{if(!(e instanceof HTMLAnchorElement))return;let t=e.getAttribute(`href`);t&&(e.setAttribute(`rel`,`noreferrer noopener`),e.setAttribute(`target`,`_blank`),t.toLowerCase().includes(`tail`)&&e.classList.add(zl))}))}function Ul(e){let t=e.trim();if(!t)return``;if(Hl(),t.length<=Il){let e=Bl(t);if(e!==null)return e}let n=u(t,Nl),r=n.truncated?`\n\n… truncated (${n.total} chars, showing first ${n.text.length}).`:``;if(n.text.length>Pl){let e=ql(`${n.text}${r}`),i=nc.sanitize(e,jl);return t.length<=Il&&Vl(t,i),i}let i;try{i=J.parse(`${n.text}${r}`,{renderer:Wl,gfm:!0,breaks:!0})}catch(e){console.warn(`[markdown] marked.parse failed, falling back to plain text:`,e),i=`<pre class="code-block">${Kl(`${n.text}${r}`)}</pre>`}let a=nc.sanitize(i,jl);return t.length<=Il&&Vl(t,a),a}var Wl=new J.Renderer;Wl.html=({text:e})=>Kl(e),Wl.image=e=>{let t=Gl(e.text),n=e.href?.trim()??``;return Ll.test(n)?`<img class="markdown-inline-image" src="${Kl(n)}" alt="${Kl(t)}">`:Kl(t)};function Gl(e){return e?.trim()||`image`}Wl.code=({text:e,lang:t,escaped:n})=>{let r=`<pre><code${t?` class="language-${Kl(t)}"`:``}>${n?e:Kl(e)}</code></pre>`,i=`<div class="code-block-header">${t?`<span class="code-block-lang">${Kl(t)}</span>`:``}${`<button type="button" class="code-block-copy" data-code="${e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}" aria-label="Copy code"><span class="code-block-copy__idle">Copy</span><span class="code-block-copy__done">Copied!</span></button>`}</div>`,a=e.trim();if(t===`json`||!t&&(a.startsWith(`{`)&&a.endsWith(`}`)||a.startsWith(`[`)&&a.endsWith(`]`))){let t=e.split(`
`).length;return`<details class="json-collapse"><summary>${t>1?`JSON · ${t} lines`:`JSON`}</summary><div class="code-block-wrapper">${i}${r}</div></details>`}return`<div class="code-block-wrapper">${i}${r}</div>`};function Kl(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function ql(e){return`<div class="markdown-plain-text-fallback">${Kl(e.replace(/\r\n?/g,`
`))}</div>`}var Jl=`data:`,Yl=new Set([`http:`,`https:`,`blob:`]),Xl=new Set([`image/svg+xml`]);function Zl(e){if(!e.toLowerCase().startsWith(Jl))return!1;let t=e.indexOf(`,`);if(t<5)return!1;let n=e.slice(5,t).split(`;`)[0]?.trim().toLowerCase()??``;return n.startsWith(`image/`)?!Xl.has(n):!1}function Ql(e,t,n={}){let r=e.trim();if(!r)return null;if(n.allowDataImage===!0&&Zl(r))return r;if(r.toLowerCase().startsWith(Jl))return null;try{let e=new URL(r,t);return Yl.has(e.protocol.toLowerCase())?e.toString():null}catch{return null}}function $l(e,t={}){let n=Ql(e,t.baseHref??window.location.href,t);if(!n)return null;let r=window.open(n,`_blank`,`noopener,noreferrer`);return r&&(r.opener=null),r}var eu=/\p{Script=Hebrew}|\p{Script=Arabic}|\p{Script=Syriac}|\p{Script=Thaana}|\p{Script=Nko}|\p{Script=Samaritan}|\p{Script=Mandaic}|\p{Script=Adlam}|\p{Script=Phoenician}|\p{Script=Lydian}/u;function tu(e,t=/[\s\p{P}\p{S}]/u){if(!e)return`ltr`;for(let n of e)if(!t.test(n))return eu.test(n)?`rtl`:`ltr`;return`ltr`}var nu=[{id:`read`,label:`read`,description:`Read file contents`,sectionId:`fs`,profiles:[`coding`]},{id:`write`,label:`write`,description:`Create or overwrite files`,sectionId:`fs`,profiles:[`coding`]},{id:`edit`,label:`edit`,description:`Make precise edits`,sectionId:`fs`,profiles:[`coding`]},{id:`apply_patch`,label:`apply_patch`,description:`Patch files (OpenAI)`,sectionId:`fs`,profiles:[`coding`]},{id:`exec`,label:`exec`,description:`Run shell commands`,sectionId:`runtime`,profiles:[`coding`]},{id:`process`,label:`process`,description:`Manage background processes`,sectionId:`runtime`,profiles:[`coding`]},{id:`web_search`,label:`web_search`,description:`Search the web`,sectionId:`web`,profiles:[`coding`],includeInOpenClawGroup:!0},{id:`web_fetch`,label:`web_fetch`,description:`Fetch web content`,sectionId:`web`,profiles:[`coding`],includeInOpenClawGroup:!0},{id:`memory_search`,label:`memory_search`,description:`Semantic search`,sectionId:`memory`,profiles:[`coding`],includeInOpenClawGroup:!0},{id:`memory_get`,label:`memory_get`,description:`Read memory files`,sectionId:`memory`,profiles:[`coding`],includeInOpenClawGroup:!0},{id:`sessions_list`,label:`sessions_list`,description:`List sessions`,sectionId:`sessions`,profiles:[`coding`,`messaging`],includeInOpenClawGroup:!0},{id:`sessions_history`,label:`sessions_history`,description:`Session history`,sectionId:`sessions`,profiles:[`coding`,`messaging`],includeInOpenClawGroup:!0},{id:`sessions_send`,label:`sessions_send`,description:`Send to session`,sectionId:`sessions`,profiles:[`coding`,`messaging`],includeInOpenClawGroup:!0},{id:`sessions_spawn`,label:`sessions_spawn`,description:`Spawn sub-agent`,sectionId:`sessions`,profiles:[`coding`],includeInOpenClawGroup:!0},{id:`sessions_yield`,label:`sessions_yield`,description:`End turn to receive sub-agent results`,sectionId:`sessions`,profiles:[`coding`],includeInOpenClawGroup:!0},{id:`subagents`,label:`subagents`,description:`Manage sub-agents`,sectionId:`sessions`,profiles:[`coding`],includeInOpenClawGroup:!0},{id:`session_status`,label:`session_status`,description:`Session status`,sectionId:`sessions`,profiles:[`minimal`,`coding`,`messaging`],includeInOpenClawGroup:!0},{id:`browser`,label:`browser`,description:`Control web browser`,sectionId:`ui`,profiles:[],includeInOpenClawGroup:!0},{id:`canvas`,label:`canvas`,description:`Control canvases`,sectionId:`ui`,profiles:[],includeInOpenClawGroup:!0},{id:`message`,label:`message`,description:`Send messages`,sectionId:`messaging`,profiles:[`messaging`],includeInOpenClawGroup:!0},{id:`cron`,label:`cron`,description:`Schedule tasks`,sectionId:`automation`,profiles:[`coding`],includeInOpenClawGroup:!0},{id:`gateway`,label:`gateway`,description:`Gateway control`,sectionId:`automation`,profiles:[],includeInOpenClawGroup:!0},{id:`nodes`,label:`nodes`,description:`Nodes + devices`,sectionId:`nodes`,profiles:[],includeInOpenClawGroup:!0},{id:`agents_list`,label:`agents_list`,description:`List agents`,sectionId:`agents`,profiles:[],includeInOpenClawGroup:!0},{id:`image`,label:`image`,description:`Image understanding`,sectionId:`media`,profiles:[`coding`],includeInOpenClawGroup:!0},{id:`image_generate`,label:`image_generate`,description:`Image generation`,sectionId:`media`,profiles:[`coding`],includeInOpenClawGroup:!0},{id:`tts`,label:`tts`,description:`Text-to-speech conversion`,sectionId:`media`,profiles:[],includeInOpenClawGroup:!0}];new Map(nu.map(e=>[e.id,e]));function ru(e){return nu.filter(t=>t.profiles.includes(e)).map(e=>e.id)}var iu={minimal:{allow:ru(`minimal`)},coding:{allow:ru(`coding`)},messaging:{allow:ru(`messaging`)},full:{}};function au(){let e=new Map;for(let t of nu){let n=`group:${t.sectionId}`,r=e.get(n)??[];r.push(t.id),e.set(n,r)}let t=nu.filter(e=>e.includeInOpenClawGroup).map(e=>e.id);return{"group:openclaw":t,...Object.fromEntries(e.entries())}}var ou=au();function su(e){if(!e)return;let t=iu[e];if(t&&!(!t.allow&&!t.deny))return{allow:t.allow?[...t.allow]:void 0,deny:t.deny?[...t.deny]:void 0}}var cu={bash:`exec`,"apply-patch":`apply_patch`},lu={...ou};function uu(e){let t=e.trim().toLowerCase();return cu[t]??t}function du(e){return e?e.map(uu).filter(Boolean):[]}function fu(e){let t=du(e),n=[];for(let e of t){let t=lu[e];if(t){n.push(...t);continue}n.push(e)}return Array.from(new Set(n))}function pu(e){return su(e)}var mu=[{id:`fs`,label:`Files`,tools:[{id:`read`,label:`read`,description:`Read file contents`},{id:`write`,label:`write`,description:`Create or overwrite files`},{id:`edit`,label:`edit`,description:`Make precise edits`},{id:`apply_patch`,label:`apply_patch`,description:`Patch files (OpenAI)`}]},{id:`runtime`,label:`Runtime`,tools:[{id:`exec`,label:`exec`,description:`Run shell commands`},{id:`process`,label:`process`,description:`Manage background processes`}]},{id:`web`,label:`Web`,tools:[{id:`web_search`,label:`web_search`,description:`Search the web`},{id:`web_fetch`,label:`web_fetch`,description:`Fetch web content`}]},{id:`memory`,label:`Memory`,tools:[{id:`memory_search`,label:`memory_search`,description:`Semantic search`},{id:`memory_get`,label:`memory_get`,description:`Read memory files`}]},{id:`sessions`,label:`Sessions`,tools:[{id:`sessions_list`,label:`sessions_list`,description:`List sessions`},{id:`sessions_history`,label:`sessions_history`,description:`Session history`},{id:`sessions_send`,label:`sessions_send`,description:`Send to session`},{id:`sessions_spawn`,label:`sessions_spawn`,description:`Spawn sub-agent`},{id:`session_status`,label:`session_status`,description:`Session status`}]},{id:`ui`,label:`UI`,tools:[{id:`browser`,label:`browser`,description:`Control web browser`},{id:`canvas`,label:`canvas`,description:`Control canvases`}]},{id:`messaging`,label:`Messaging`,tools:[{id:`message`,label:`message`,description:`Send messages`}]},{id:`automation`,label:`Automation`,tools:[{id:`cron`,label:`cron`,description:`Schedule tasks`},{id:`gateway`,label:`gateway`,description:`Gateway control`}]},{id:`nodes`,label:`Nodes`,tools:[{id:`nodes`,label:`nodes`,description:`Nodes + devices`}]},{id:`agents`,label:`Agents`,tools:[{id:`agents_list`,label:`agents_list`,description:`List agents`}]},{id:`media`,label:`Media`,tools:[{id:`image`,label:`image`,description:`Image understanding`}]}],hu=[{id:`minimal`,label:`Minimal`},{id:`coding`,label:`Coding`},{id:`messaging`,label:`Messaging`},{id:`full`,label:`Full`}];function gu(e){return e?.groups?.length?e.groups.map(e=>({id:e.id,label:e.label,source:e.source,pluginId:e.pluginId,tools:e.tools.map(e=>({id:e.id,label:e.label,description:e.description,source:e.source,pluginId:e.pluginId,optional:e.optional,defaultProfiles:[...e.defaultProfiles]}))})):mu}function _u(e){return e?.profiles?.length?e.profiles:hu}function vu(e){return e.name?.trim()||e.identity?.name?.trim()||e.id}var yu=/^(https?:\/\/|data:image\/|\/)/i;function bu(e,t){let n=[t?.avatar?.trim(),e.identity?.avatarUrl?.trim(),e.identity?.avatar?.trim()];for(let e of n)if(e&&yu.test(e))return e;return null}function xu(e){let t=e?.trim()?e.replace(/\/$/,``):``;return t?`${t}/favicon.svg`:`favicon.svg`}function Su(e,t){return t&&e===t?`default`:null}function Cu(e){if(e==null||!Number.isFinite(e))return`-`;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(n<10?1:0)} ${t[r]}`}function wu(e,t){let n=e;return{entry:(n?.agents?.list??[]).find(e=>e?.id===t),defaults:n?.agents?.defaults,globalTools:n?.tools}}function Tu(e,t,n,r,i){let a=wu(t,e.id),o=(n&&n.agentId===e.id?n.workspace:null)||a.entry?.workspace||a.defaults?.workspace||`default`,s=a.entry?.model?Eu(a.entry?.model):Eu(a.defaults?.model),c=i?.name?.trim()||e.identity?.name?.trim()||e.name?.trim()||a.entry?.name||e.id,l=bu(e,i)?`custom`:`—`,u=Array.isArray(a.entry?.skills)?a.entry?.skills:null,d=u?.length??null;return{workspace:o,model:s,identityName:c,identityAvatar:l,skillsLabel:u?`${d} selected`:`all skills`,isDefault:!!(r&&e.id===r)}}function Eu(e){if(!e)return`-`;if(typeof e==`string`)return e.trim()||`-`;if(typeof e==`object`&&e){let t=e,n=t.primary?.trim();if(n){let e=Array.isArray(t.fallbacks)?t.fallbacks.length:0;return e>0?`${n} (+${e} fallback)`:n}}return`-`}function Du(e){let t=e.match(/^(.+) \(\+\d+ fallback\)$/);return t?t[1]:e}function Ou(e){if(!e)return null;if(typeof e==`string`)return e.trim()||null;if(typeof e==`object`&&e){let t=e;return(typeof t.primary==`string`?t.primary:typeof t.model==`string`?t.model:typeof t.id==`string`?t.id:typeof t.value==`string`?t.value:null)?.trim()||null}return null}function ku(e){if(!e||typeof e==`string`)return null;if(typeof e==`object`&&e){let t=e,n=Array.isArray(t.fallbacks)?t.fallbacks:Array.isArray(t.fallback)?t.fallback:null;return n?n.filter(e=>typeof e==`string`):null}return null}function Au(e,t){return ku(e)??ku(t)}function ju(e,t){if(typeof t!=`string`)return;let n=t.trim();n&&e.add(n)}function Mu(e,t){if(!t)return;if(typeof t==`string`){ju(e,t);return}if(typeof t!=`object`)return;let n=t;ju(e,n.primary),ju(e,n.model),ju(e,n.id),ju(e,n.value);let r=Array.isArray(n.fallbacks)?n.fallbacks:Array.isArray(n.fallback)?n.fallback:[];for(let t of r)ju(e,t)}function Nu(e){let t=Array.from(e),n=Array.from({length:t.length},()=>``),r=(e,r,i)=>{let a=e,o=r,s=e;for(;a<r&&o<i;)n[s++]=t[a].localeCompare(t[o])<=0?t[a++]:t[o++];for(;a<r;)n[s++]=t[a++];for(;o<i;)n[s++]=t[o++];for(let r=e;r<i;r+=1)t[r]=n[r]},i=(e,t)=>{if(t-e<=1)return;let n=e+t>>>1;i(e,n),i(n,t),r(e,n,t)};return i(0,t.length),t}function Pu(e){if(!e||typeof e!=`object`)return[];let t=e.agents;if(!t||typeof t!=`object`)return[];let n=new Set,r=t.defaults;if(r&&typeof r==`object`){let e=r;Mu(n,e.model);let t=e.models;if(t&&typeof t==`object`)for(let e of Object.keys(t))ju(n,e)}let i=t.list;if(i&&typeof i==`object`)for(let e of Object.values(i))!e||typeof e!=`object`||Mu(n,e.model);return Nu(n)}function Fu(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}function Iu(e){let t=e?.agents?.defaults?.models;if(!t||typeof t!=`object`)return[];let n=[];for(let[e,r]of Object.entries(t)){let t=e.trim();if(!t)continue;let i=r&&typeof r==`object`&&`alias`in r&&typeof r.alias==`string`?r.alias?.trim():void 0,a=i&&i!==t?`${i} (${t})`:t;n.push({value:t,label:a})}return n}function Lu(e,t){let r=Iu(e),i=t?r.some(e=>e.value===t):!1;return t&&!i&&r.unshift({value:t,label:`Current (${t})`}),r.length===0?n`
<option value="" disabled>No configured models</option>
`:r.map(e=>n`<option value=${e.value}>${e.label}</option>`)}function Ru(e){let t=uu(e);if(!t)return{kind:`exact`,value:``};if(t===`*`)return{kind:`all`};if(!t.includes(`*`))return{kind:`exact`,value:t};let n=t.replace(/[.*+?^${}()|[\\]\\]/g,`\\$&`);return{kind:`regex`,value:RegExp(`^${n.replaceAll(`\\*`,`.*`)}$`)}}function zu(e){return Array.isArray(e)?fu(e).map(Ru).filter(e=>e.kind!==`exact`||e.value.length>0):[]}function Bu(e,t){for(let n of t)if(n.kind===`all`||n.kind===`exact`&&e===n.value||n.kind===`regex`&&n.value.test(e))return!0;return!1}function Vu(e,t){if(!t)return!0;let n=uu(e);if(Bu(n,zu(t.deny)))return!1;let r=zu(t.allow);return!!(r.length===0||Bu(n,r)||n===`apply_patch`&&Bu(`exec`,r))}function Hu(e,t){if(!Array.isArray(t)||t.length===0)return!1;let n=uu(e),r=zu(t);return!!(Bu(n,r)||n===`apply_patch`&&Bu(`exec`,r))}function Uu(e){return pu(e)??void 0}var Wu=1500,Gu=2e3,Ku=`Copy as markdown`,qu=`Copied`,Ju=`Copy failed`;async function Yu(e){if(!e)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function Xu(e,t){e.title=t,e.setAttribute(`aria-label`,t)}function Zu(e){let t=e.label??Ku;return n`
<button
class="btn btn--xs chat-copy-btn"
type="button"
title=${t}
aria-label=${t}
@click=${async n=>{let r=n.currentTarget;if(!r||r.dataset.copying===`1`)return;r.dataset.copying=`1`,r.setAttribute(`aria-busy`,`true`),r.disabled=!0;let i=await Yu(e.text());if(r.isConnected){if(delete r.dataset.copying,r.removeAttribute(`aria-busy`),r.disabled=!1,!i){r.dataset.error=`1`,Xu(r,Ju),window.setTimeout(()=>{r.isConnected&&(delete r.dataset.error,Xu(r,t))},Gu);return}r.dataset.copied=`1`,Xu(r,qu),window.setTimeout(()=>{r.isConnected&&(delete r.dataset.copied,Xu(r,t))},Wu)}}}
>
<span class="chat-copy-btn__icon" aria-hidden="true">
<span class="chat-copy-btn__icon-copy">${G.copy}</span>
<span class="chat-copy-btn__icon-check">${G.check}</span>
</span>
</button>
`}function Qu(e){return Zu({text:()=>e,label:Ku})}function $u(e){let t=e,n=typeof t.role==`string`?t.role:`unknown`,r=typeof t.toolCallId==`string`||typeof t.tool_call_id==`string`,i=t.content,a=Array.isArray(i)?i:null,o=Array.isArray(a)&&a.some(e=>{let t=e,n=(typeof t.type==`string`?t.type:``).toLowerCase();return n===`toolresult`||n===`tool_result`}),s=typeof t.toolName==`string`||typeof t.tool_name==`string`;(r||o||s)&&(n=`toolResult`);let c=[];typeof t.content==`string`?c=[{type:`text`,text:t.content}]:Array.isArray(t.content)?c=t.content.map(e=>({type:e.type||`text`,text:e.text,name:e.name,args:e.args||e.arguments})):typeof t.text==`string`&&(c=[{type:`text`,text:t.text}]);let l=typeof t.timestamp==`number`?t.timestamp:Date.now(),u=typeof t.id==`string`?t.id:void 0,d=typeof t.senderLabel==`string`&&t.senderLabel.trim()?t.senderLabel.trim():null;return(n===`user`||n===`User`)&&(c=c.map(e=>e.type===`text`&&typeof e.text==`string`?{...e,text:Io(e.text)}:e)),{role:n,content:c,timestamp:l,id:u,senderLabel:d}}function ed(e){let t=e.toLowerCase();return e===`user`||e===`User`?e:e===`assistant`?`assistant`:e===`system`?`system`:t===`toolresult`||t===`tool_result`||t===`tool`||t===`function`?`tool`:e}function td(e){let t=e,n=typeof t.role==`string`?t.role.toLowerCase():``;return n===`toolresult`||n===`tool_result`}function nd(){let e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function rd(){return nd()!==null}var id=null;function ad(e){let t=nd();if(!t)return e.onError?.(`Speech recognition is not supported in this browser`),!1;od();let n=new t;return n.continuous=!0,n.interimResults=!0,n.lang=navigator.language||`en-US`,n.addEventListener(`start`,()=>e.onStart?.()),n.addEventListener(`result`,t=>{let n=t,r=``,i=``;for(let e=n.resultIndex;e<n.results.length;e++){let t=n.results[e];if(!t?.[0])continue;let a=t[0].transcript;t.isFinal?i+=a:r+=a}i?e.onTranscript(i,!0):r&&e.onTranscript(r,!1)}),n.addEventListener(`error`,t=>{let n=t;n.error===`aborted`||n.error===`no-speech`||e.onError?.(n.error)}),n.addEventListener(`end`,()=>{id===n&&(id=null),e.onEnd?.()}),id=n,n.start(),!0}function od(){if(id){let e=id;id=null;try{e.stop()}catch{}}}function sd(){return`speechSynthesis`in globalThis}var cd=null;function ld(e,t){if(!sd())return t?.onError?.(`Speech synthesis is not supported in this browser`),!1;ud();let n=fd(e);if(!n.trim())return!1;let r=new SpeechSynthesisUtterance(n);return r.rate=1,r.pitch=1,r.addEventListener(`start`,()=>t?.onStart?.()),r.addEventListener(`end`,()=>{cd===r&&(cd=null),t?.onEnd?.()}),r.addEventListener(`error`,e=>{cd===r&&(cd=null),!(e.error===`canceled`||e.error===`interrupted`)&&t?.onError?.(e.error)}),cd=r,speechSynthesis.speak(r),!0}function ud(){cd&&=null,sd()&&speechSynthesis.cancel()}function dd(){return sd()&&speechSynthesis.speaking}function fd(e){return e.replace(/```[\s\S]*?```/g,``).replace(/`[^`]+`/g,``).replace(/!\[.*?\]\(.*?\)/g,``).replace(/\[([^\]]+)\]\(.*?\)/g,`$1`).replace(/^#{1,6}\s+/gm,``).replace(/\*{1,3}(.*?)\*{1,3}/g,`$1`).replace(/_{1,3}(.*?)_{1,3}/g,`$1`).replace(/^>\s?/gm,``).replace(/^[-*_]{3,}\s*$/gm,``).replace(/^\s*[-*+]\s+/gm,``).replace(/^\s*\d+\.\s+/gm,``).replace(/<[^>]+>/g,``).replace(/\n{3,}/g,`
`).trim()}var pd={version:1,fallback:{emoji:`🧩`,detailKeys:[`command`,`path`,`url`,`targetUrl`,`targetId`,`ref`,`element`,`node`,`nodeId`,`id`,`requestId`,`to`,`channelId`,`guildId`,`userId`,`name`,`query`,`pattern`,`messageId`]},tools:{bash:{emoji:`🛠️`,title:`Bash`,detailKeys:[`command`]},process:{emoji:`🧰`,title:`Process`,detailKeys:[`sessionId`]},read:{emoji:`📖`,title:`Read`,detailKeys:[`path`]},write:{emoji:`✍️`,title:`Write`,detailKeys:[`path`]},edit:{emoji:`📝`,title:`Edit`,detailKeys:[`path`]},attach:{emoji:`📎`,title:`Attach`,detailKeys:[`path`,`url`,`fileName`]},browser:{emoji:`🌐`,title:`Browser`,actions:{status:{label:`status`},start:{label:`start`},stop:{label:`stop`},tabs:{label:`tabs`},open:{label:`open`,detailKeys:[`targetUrl`]},focus:{label:`focus`,detailKeys:[`targetId`]},close:{label:`close`,detailKeys:[`targetId`]},snapshot:{label:`snapshot`,detailKeys:[`targetUrl`,`targetId`,`ref`,`element`,`format`]},screenshot:{label:`screenshot`,detailKeys:[`targetUrl`,`targetId`,`ref`,`element`]},navigate:{label:`navigate`,detailKeys:[`targetUrl`,`targetId`]},console:{label:`console`,detailKeys:[`level`,`targetId`]},pdf:{label:`pdf`,detailKeys:[`targetId`]},upload:{label:`upload`,detailKeys:[`paths`,`ref`,`inputRef`,`element`,`targetId`]},dialog:{label:`dialog`,detailKeys:[`accept`,`promptText`,`targetId`]},act:{label:`act`,detailKeys:[`request.kind`,`request.ref`,`request.selector`,`request.text`,`request.value`]}}},canvas:{emoji:`🖼️`,title:`Canvas`,actions:{present:{label:`present`,detailKeys:[`target`,`node`,`nodeId`]},hide:{label:`hide`,detailKeys:[`node`,`nodeId`]},navigate:{label:`navigate`,detailKeys:[`url`,`node`,`nodeId`]},eval:{label:`eval`,detailKeys:[`javaScript`,`node`,`nodeId`]},snapshot:{label:`snapshot`,detailKeys:[`format`,`node`,`nodeId`]},a2ui_push:{label:`A2UI push`,detailKeys:[`jsonlPath`,`node`,`nodeId`]},a2ui_reset:{label:`A2UI reset`,detailKeys:[`node`,`nodeId`]}}},nodes:{emoji:`📱`,title:`Nodes`,actions:{status:{label:`status`},describe:{label:`describe`,detailKeys:[`node`,`nodeId`]},pending:{label:`pending`},approve:{label:`approve`,detailKeys:[`requestId`]},reject:{label:`reject`,detailKeys:[`requestId`]},notify:{label:`notify`,detailKeys:[`node`,`nodeId`,`title`,`body`]},camera_snap:{label:`camera snap`,detailKeys:[`node`,`nodeId`,`facing`,`deviceId`]},camera_list:{label:`camera list`,detailKeys:[`node`,`nodeId`]},camera_clip:{label:`camera clip`,detailKeys:[`node`,`nodeId`,`facing`,`duration`,`durationMs`]},screen_record:{label:`screen record`,detailKeys:[`node`,`nodeId`,`duration`,`durationMs`,`fps`,`screenIndex`]}}},cron:{emoji:`⏰`,title:`Cron`,actions:{status:{label:`status`},list:{label:`list`},add:{label:`add`,detailKeys:[`job.name`,`job.id`,`job.schedule`,`job.cron`]},update:{label:`update`,detailKeys:[`id`]},remove:{label:`remove`,detailKeys:[`id`]},run:{label:`run`,detailKeys:[`id`]},runs:{label:`runs`,detailKeys:[`id`]},wake:{label:`wake`,detailKeys:[`text`,`mode`]}}},gateway:{emoji:`🔌`,title:`Gateway`,actions:{restart:{label:`restart`,detailKeys:[`reason`,`delayMs`]}}},whatsapp_login:{emoji:`🟢`,title:`WhatsApp Login`,actions:{start:{label:`start`},wait:{label:`wait`}}},discord:{emoji:`💬`,title:`Discord`,actions:{react:{label:`react`,detailKeys:[`channelId`,`messageId`,`emoji`]},reactions:{label:`reactions`,detailKeys:[`channelId`,`messageId`]},sticker:{label:`sticker`,detailKeys:[`to`,`stickerIds`]},poll:{label:`poll`,detailKeys:[`question`,`to`]},permissions:{label:`permissions`,detailKeys:[`channelId`]},readMessages:{label:`read messages`,detailKeys:[`channelId`,`limit`]},sendMessage:{label:`send`,detailKeys:[`to`,`content`]},editMessage:{label:`edit`,detailKeys:[`channelId`,`messageId`]},deleteMessage:{label:`delete`,detailKeys:[`channelId`,`messageId`]},threadCreate:{label:`thread create`,detailKeys:[`channelId`,`name`]},threadList:{label:`thread list`,detailKeys:[`guildId`,`channelId`]},threadReply:{label:`thread reply`,detailKeys:[`channelId`,`content`]},pinMessage:{label:`pin`,detailKeys:[`channelId`,`messageId`]},unpinMessage:{label:`unpin`,detailKeys:[`channelId`,`messageId`]},listPins:{label:`list pins`,detailKeys:[`channelId`]},searchMessages:{label:`search`,detailKeys:[`guildId`,`content`]},memberInfo:{label:`member`,detailKeys:[`guildId`,`userId`]},roleInfo:{label:`roles`,detailKeys:[`guildId`]},emojiList:{label:`emoji list`,detailKeys:[`guildId`]},roleAdd:{label:`role add`,detailKeys:[`guildId`,`userId`,`roleId`]},roleRemove:{label:`role remove`,detailKeys:[`guildId`,`userId`,`roleId`]},channelInfo:{label:`channel`,detailKeys:[`channelId`]},channelList:{label:`channels`,detailKeys:[`guildId`]},voiceStatus:{label:`voice`,detailKeys:[`guildId`,`userId`]},eventList:{label:`events`,detailKeys:[`guildId`]},eventCreate:{label:`event create`,detailKeys:[`guildId`,`name`]},timeout:{label:`timeout`,detailKeys:[`guildId`,`userId`]},kick:{label:`kick`,detailKeys:[`guildId`,`userId`]},ban:{label:`ban`,detailKeys:[`guildId`,`userId`]}}}}};function md(e){return e&&typeof e==`object`?e:void 0}function hd(e){return(e??`tool`).trim()}function gd(e){let t=e.replace(/_/g,` `).trim();return t?t.split(/\s+/).map(e=>e.length<=2&&e.toUpperCase()===e?e:`${e.at(0)?.toUpperCase()??``}${e.slice(1)}`).join(` `):`Tool`}function _d(e){let t=e?.trim();if(t)return t.replace(/_/g,` `)}function vd(e){if(!e||typeof e!=`object`)return;let t=e.action;if(typeof t==`string`)return t.trim()||void 0}function yd(e){return Zd({toolKey:e.toolKey,args:e.args,meta:e.meta,action:vd(e.args),spec:e.spec,fallbackDetailKeys:e.fallbackDetailKeys,detailMode:e.detailMode,detailCoerce:e.detailCoerce,detailMaxEntries:e.detailMaxEntries,detailFormatKey:e.detailFormatKey})}function bd(e,t={}){let n=t.maxStringChars??160,r=t.maxArrayEntries??3;if(e!=null){if(typeof e==`string`){let t=e.trim();if(!t)return;let r=t.split(/\r?\n/)[0]?.trim()??``;return r?r.length>n?`${r.slice(0,Math.max(0,n-3))}…`:r:void 0}if(typeof e==`boolean`)return!e&&!t.includeFalse?void 0:e?`true`:`false`;if(typeof e==`number`)return Number.isFinite(e)?e===0&&!t.includeZero?void 0:String(e):t.includeNonFinite?String(e):void 0;if(Array.isArray(e)){let n=e.map(e=>bd(e,t)).filter(e=>!!e);if(n.length===0)return;let i=n.slice(0,r).join(`, `);return n.length>r?`${i}…`:i}}}function xd(e,t){if(!e||typeof e!=`object`)return;let n=e;for(let e of t.split(`.`)){if(!e||!n||typeof n!=`object`)return;n=n[e]}return n}function Sd(e){let t=md(e);if(t)for(let e of[t.path,t.file_path,t.filePath]){if(typeof e!=`string`)continue;let t=e.trim();if(t)return t}}function Cd(e){let t=md(e);if(!t)return;let n=Sd(t);if(!n)return;let r=typeof t.offset==`number`&&Number.isFinite(t.offset)?Math.floor(t.offset):void 0,i=typeof t.limit==`number`&&Number.isFinite(t.limit)?Math.floor(t.limit):void 0,a=r===void 0?void 0:Math.max(1,r),o=i===void 0?void 0:Math.max(1,i);return a!==void 0&&o!==void 0?`${o===1?`line`:`lines`} ${a}-${a+o-1} from ${n}`:a===void 0?o===void 0?`from ${n}`:`first ${o} ${o===1?`line`:`lines`} of ${n}`:`from line ${a} in ${n}`}function wd(e,t){let n=md(t);if(!n)return;let r=Sd(n)??(typeof n.url==`string`?n.url.trim():void 0);if(!r)return;if(e===`attach`)return`from ${r}`;let i=e===`edit`?`in`:`to`,a=typeof n.content==`string`?n.content:typeof n.newText==`string`?n.newText:typeof n.new_string==`string`?n.new_string:void 0;return a&&a.length>0?`${i} ${r} (${a.length} chars)`:`${i} ${r}`}function Td(e){let t=md(e);if(!t)return;let n=typeof t.query==`string`?t.query.trim():void 0,r=typeof t.count==`number`&&Number.isFinite(t.count)&&t.count>0?Math.floor(t.count):void 0;if(n)return r===void 0?`for "${n}"`:`for "${n}" (top ${r})`}function Ed(e){let t=md(e);if(!t)return;let n=typeof t.url==`string`?t.url.trim():void 0;if(!n)return;let r=typeof t.extractMode==`string`?t.extractMode.trim():void 0,i=typeof t.maxChars==`number`&&Number.isFinite(t.maxChars)&&t.maxChars>0?Math.floor(t.maxChars):void 0,a=[r?`mode ${r}`:void 0,i===void 0?void 0:`max ${i} chars`].filter(e=>!!e).join(`, `);return a?`from ${n} (${a})`:`from ${n}`}function Dd(e){if(!e)return e;let t=e.trim();return t.length>=2&&(t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`))?t.slice(1,-1).trim():t}function Od(e,t=48){if(!e)return[];let n=[],r=``,i,a=!1;for(let o=0;o<e.length;o+=1){let s=e[o];if(a){r+=s,a=!1;continue}if(s===`\\`){a=!0;continue}if(i){s===i?i=void 0:r+=s;continue}if(s===`"`||s===`'`){i=s;continue}if(/\s/.test(s)){if(!r)continue;if(n.push(r),n.length>=t)return n;r=``;continue}r+=s}return r&&n.push(r),n}function kd(e){if(!e)return;let t=Dd(e)??e;return(t.split(/[/]/).at(-1)??t).trim().toLowerCase()}function Ad(e,t){let n=new Set(t);for(let r=0;r<e.length;r+=1){let i=e[r];if(i){if(n.has(i)){let t=e[r+1];if(t&&!t.startsWith(`-`))return t;continue}for(let e of t)if(e.startsWith(`--`)&&i.startsWith(`${e}=`))return i.slice(e.length+1)}}}function jd(e,t=1,n=[]){let r=[],i=new Set(n);for(let n=t;n<e.length;n+=1){let t=e[n];if(t){if(t===`--`){for(let t=n+1;t<e.length;t+=1){let n=e[t];n&&r.push(n)}break}if(t.startsWith(`--`)){if(t.includes(`=`))continue;i.has(t)&&(n+=1);continue}if(t.startsWith(`-`)){i.has(t)&&(n+=1);continue}r.push(t)}}return r}function Md(e,t=1,n=[]){return jd(e,t,n)[0]}function Nd(e){if(e.length===0)return e;let t=0;if(kd(e[0])===`env`){for(t=1;t<e.length;){let n=e[t];if(!n)break;if(n.startsWith(`-`)){t+=1;continue}if(/^[A-Za-z_][A-Za-z0-9_]*=/.test(n)){t+=1;continue}break}return e.slice(t)}for(;t<e.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[t]);)t+=1;return e.slice(t)}function Pd(e){let t=Od(e,10);if(t.length<3)return e;let n=kd(t[0]);if(!(n===`bash`||n===`sh`||n===`zsh`||n===`fish`))return e;let r=t.findIndex((e,t)=>t>0&&(e===`-c`||e===`-lc`||e===`-ic`));if(r===-1)return e;let i=t.slice(r+1).join(` `).trim();return i?Dd(i)??e:e}function Fd(e,t){let n,r=!1;for(let i=0;i<e.length;i+=1){let a=e[i];if(r){r=!1;continue}if(a===`\\`){r=!0;continue}if(n){a===n&&(n=void 0);continue}if(a===`"`||a===`'`){n=a;continue}if(t(a,i)===!1)return}}function Id(e){let t=[],n=0;return Fd(e,(r,i)=>r===`;`?(t.push(e.slice(n,i)),n=i+1,!0):(r===`&`||r===`|`)&&e[i+1]===r?(t.push(e.slice(n,i)),n=i+2,!0):!0),t.push(e.slice(n)),t.map(e=>e.trim()).filter(e=>e.length>0)}function Ld(e){let t=[],n=0;return Fd(e,(r,i)=>(r===`|`&&e[i-1]!==`|`&&e[i+1]!==`|`&&(t.push(e.slice(n,i)),n=i+1),!0)),t.push(e.slice(n)),t.map(e=>e.trim()).filter(e=>e.length>0)}function Rd(e){let t=Od(e,3),n=kd(t[0]);if(n===`cd`||n===`pushd`)return t[1]||void 0}function zd(e){let t=kd(Od(e,2)[0]);return t===`cd`||t===`pushd`||t===`popd`}function Bd(e){return kd(Od(e,2)[0])===`popd`}function Vd(e){let t=e.trim(),n;for(let e=0;e<4;e+=1){let r;Fd(t,(e,n)=>{if(e===`&`&&t[n+1]===`&`)return r={index:n,length:2},!1;if(e===`|`&&t[n+1]===`|`)return r={index:n,length:2,isOr:!0},!1;if(e===`;`||e===`
`)return r={index:n,length:1},!1});let i=(r?t.slice(0,r.index):t).trim(),a=(r?!r.isOr:e>0)&&zd(i);if(!(i.startsWith(`set `)||i.startsWith(`export `)||i.startsWith(`unset `)||a)||(a&&(n=Bd(i)?void 0:Rd(i)??n),t=r?t.slice(r.index+r.length).trimStart():``,!t))break}return{command:t.trim(),chdirPath:n}}function Hd(e){if(e.length===0)return`run command`;let t=kd(e[0])??`command`;if(t===`git`){let t=new Set([`-C`,`-c`,`--git-dir`,`--work-tree`,`--namespace`,`--config-env`]),n=Ad(e,[`-C`]),r;for(let n=1;n<e.length;n+=1){let i=e[n];if(i){if(i===`--`){r=Md(e,n+1);break}if(i.startsWith(`--`)){if(i.includes(`=`))continue;t.has(i)&&(n+=1);continue}if(i.startsWith(`-`)){t.has(i)&&(n+=1);continue}r=i;break}}let i={status:`check git status`,diff:`check git diff`,log:`view git history`,show:`show git object`,branch:`list git branches`,checkout:`switch git branch`,switch:`switch git branch`,commit:`create git commit`,pull:`pull git changes`,push:`push git changes`,fetch:`fetch git changes`,merge:`merge git changes`,rebase:`rebase git branch`,add:`stage git changes`,restore:`restore git files`,reset:`reset git state`,stash:`stash git changes`};return r&&i[r]?i[r]:!r||r.startsWith(`/`)||r.startsWith(`~`)||r.includes(`/`)?n?`run git command in ${n}`:`run git command`:`run git ${r}`}if(t===`grep`||t===`rg`||t===`ripgrep`){let t=jd(e,1,[`-e`,`--regexp`,`-f`,`--file`,`-m`,`--max-count`,`-A`,`--after-context`,`-B`,`--before-context`,`-C`,`--context`]),n=Ad(e,[`-e`,`--regexp`])??t[0],r=t.length>1?t.at(-1):void 0;return n?r?`search "${n}" in ${r}`:`search "${n}"`:`search text`}if(t===`find`){let t=e[1]&&!e[1].startsWith(`-`)?e[1]:`.`,n=Ad(e,[`-name`,`-iname`]);return n?`find files named "${n}" in ${t}`:`find files in ${t}`}if(t===`ls`){let t=Md(e,1);return t?`list files in ${t}`:`list files`}if(t===`head`||t===`tail`){let n=Ad(e,[`-n`,`--lines`])??e.slice(1).find(e=>/^-\d+$/.test(e))?.slice(1),r=jd(e,1,[`-n`,`--lines`]),i=r.at(-1);i&&/^\d+$/.test(i)&&r.length===1&&(i=void 0);let a=t===`head`?`first`:`last`,o=n===`1`?`line`:`lines`;return n&&i?`show ${a} ${n} ${o} of ${i}`:n?`show ${a} ${n} ${o}`:i?`show ${i}`:`show ${t} output`}if(t===`cat`){let t=Md(e,1);return t?`show ${t}`:`show output`}if(t===`sed`){let t=Ad(e,[`-e`,`--expression`]),n=jd(e,1,[`-e`,`--expression`,`-f`,`--file`]),r=t??n[0],i=t?n[0]:n[1];if(r){let e=(Dd(r)??r).replace(/\s+/g,``),t=e.match(/^([0-9]+),([0-9]+)p$/);if(t)return i?`print lines ${t[1]}-${t[2]} from ${i}`:`print lines ${t[1]}-${t[2]}`;let n=e.match(/^([0-9]+)p$/);if(n)return i?`print line ${n[1]} from ${i}`:`print line ${n[1]}`}return i?`run sed on ${i}`:`run sed transform`}if(t===`printf`||t===`echo`)return`print text`;if(t===`cp`||t===`mv`){let n=jd(e,1,[`-t`,`--target-directory`,`-S`,`--suffix`]),r=n[0],i=n[1],a=t===`cp`?`copy`:`move`;return r&&i?`${a} ${r} to ${i}`:r?`${a} ${r}`:`${a} files`}if(t===`rm`){let t=Md(e,1);return t?`remove ${t}`:`remove files`}if(t===`mkdir`){let t=Md(e,1);return t?`create folder ${t}`:`create folder`}if(t===`touch`){let t=Md(e,1);return t?`create file ${t}`:`create file`}if(t===`curl`||t===`wget`){let t=e.find(e=>/^https?:\/\//i.test(e));return t?`fetch ${t}`:`fetch url`}if(t===`npm`||t===`pnpm`||t===`yarn`||t===`bun`){let n=jd(e,1,[`--prefix`,`-C`,`--cwd`,`--config`]),r=n[0]??`command`;return{install:`install dependencies`,test:`run tests`,build:`run build`,start:`start app`,lint:`run lint`,run:n[1]?`run ${n[1]}`:`run script`}[r]??`run ${t} ${r}`}if(t===`node`||t===`python`||t===`python3`||t===`ruby`||t===`php`){if(e.slice(1).find(e=>e.startsWith(`<<`)))return`run ${t} inline script (heredoc)`;if((t===`node`?Ad(e,[`-e`,`--eval`]):t===`python`||t===`python3`?Ad(e,[`-c`]):void 0)!==void 0)return`run ${t} inline script`;let n=Md(e,1,t===`node`?[`-e`,`--eval`,`-m`]:[`-c`,`-e`,`--eval`,`-m`]);return n?t===`node`?`${e.includes(`--check`)||e.includes(`-c`)?`check js syntax for`:`run node script`} ${n}`:`run ${t} ${n}`:`run ${t}`}if(t===`openclaw`){let t=Md(e,1);return t?`run openclaw ${t}`:`run openclaw`}let n=Md(e,1);return!n||n.length>48?`run ${t}`:/^[A-Za-z0-9._/-]+$/.test(n)?`run ${t} ${n}`:`run ${t}`}function Ud(e){let t=Ld(e);return t.length>1?`${Hd(Nd(Od(t[0])))} -> ${Hd(Nd(Od(t[t.length-1])))}${t.length>2?` (+${t.length-2} steps)`:``}`:Hd(Nd(Od(e)))}function Wd(e){let{command:t,chdirPath:n}=Vd(e);if(!t)return n?{text:``,chdirPath:n}:void 0;let r=Id(t);if(r.length===0)return;let i=r.map(e=>Ud(e));return{text:i.length===1?i[0]:i.join(` → `),chdirPath:n,allGeneric:i.every(e=>Kd(e))}}var Gd=`check git.view git.show git.list git.switch git.create git.pull git.push git.fetch git.merge git.rebase git.stage git.restore git.reset git.stash git.search .find files.list files.show first.show last.print line.print text.copy .move .remove .create folder.create file.fetch http.install dependencies.run tests.run build.start app.run lint.run openclaw.run node script.run node .run python.run ruby.run php.run sed.run git .run npm .run pnpm .run yarn .run bun .check js syntax`.split(`.`);function Kd(e){return e===`run command`?!0:e.startsWith(`run `)?!Gd.some(t=>e.startsWith(t)):!1}function qd(e,t=120){let n=e.replace(/\s*\n\s*/g,` `).replace(/\s{2,}/g,` `).trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-1))}…`}function Jd(e){let t=md(e);if(!t)return;let n=typeof t.command==`string`?t.command.trim():void 0;if(!n)return;let r=Pd(n),i=Wd(r)??Wd(n),a=i?.text||`run command`,o=(typeof t.workdir==`string`?t.workdir:typeof t.cwd==`string`?t.cwd:void 0)?.trim()||i?.chdirPath||void 0,s=qd(r);if(i?.allGeneric!==!1&&Kd(a))return o?`${s} (in ${o})`:s;let c=o?`${a} (in ${o})`:a;return s&&s!==c&&s!==a?`${c} · \`${s}\``:c}function Yd(e,t){if(!(!e||!t))return e.actions?.[t]??void 0}function Xd(e,t,n){if(n.mode===`first`){for(let r of t){let t=bd(xd(e,r),n.coerce);if(t)return t}return}let r=[];for(let i of t){let t=bd(xd(e,i),n.coerce);t&&r.push({label:n.formatKey?n.formatKey(i):i,value:t})}if(r.length===0)return;if(r.length===1)return r[0].value;let i=new Set,a=[];for(let e of r){let t=`${e.label}:${e.value}`;i.has(t)||(i.add(t),a.push(e))}if(a.length!==0)return a.slice(0,n.maxEntries??8).map(e=>`${e.label} ${e.value}`).join(` · `)}function Zd(e){let t=Yd(e.spec,e.action),n=e.toolKey===`web_search`?`search`:e.toolKey===`web_fetch`?`fetch`:e.toolKey.replace(/_/g,` `).replace(/\./g,` `),r=_d(t?.label??e.action??n),i;e.toolKey===`exec`&&(i=Jd(e.args)),!i&&e.toolKey===`read`&&(i=Cd(e.args)),!i&&(e.toolKey===`write`||e.toolKey===`edit`||e.toolKey===`attach`)&&(i=wd(e.toolKey,e.args)),!i&&e.toolKey===`web_search`&&(i=Td(e.args)),!i&&e.toolKey===`web_fetch`&&(i=Ed(e.args));let a=t?.detailKeys??e.spec?.detailKeys??e.fallbackDetailKeys??[];return!i&&a.length>0&&(i=Xd(e.args,a,{mode:e.detailMode,coerce:e.detailCoerce,maxEntries:e.detailMaxEntries,formatKey:e.detailFormatKey})),!i&&e.meta&&(i=e.meta),{verb:r,detail:i}}function Qd(e,t={}){if(!e)return;let n=e.includes(` · `)?e.split(` · `).map(e=>e.trim()).filter(e=>e.length>0).join(`, `):e;if(n)return t.prefixWithWith?`with ${n}`:n}var $d={"🧩":`puzzle`,"🛠️":`wrench`,"🧰":`wrench`,"📖":`fileText`,"✍️":`edit`,"📝":`penLine`,"📎":`paperclip`,"🌐":`globe`,"📺":`monitor`,"🧾":`fileText`,"🔐":`settings`,"💻":`monitor`,"🔌":`plug`,"💬":`messageSquare`},ef={icon:`messageSquare`,title:`Slack`,actions:{react:{label:`react`,detailKeys:[`channelId`,`messageId`,`emoji`]},reactions:{label:`reactions`,detailKeys:[`channelId`,`messageId`]},sendMessage:{label:`send`,detailKeys:[`to`,`content`]},editMessage:{label:`edit`,detailKeys:[`channelId`,`messageId`]},deleteMessage:{label:`delete`,detailKeys:[`channelId`,`messageId`]},readMessages:{label:`read messages`,detailKeys:[`channelId`,`limit`]},pinMessage:{label:`pin`,detailKeys:[`channelId`,`messageId`]},unpinMessage:{label:`unpin`,detailKeys:[`channelId`,`messageId`]},listPins:{label:`list pins`,detailKeys:[`channelId`]},memberInfo:{label:`member`,detailKeys:[`userId`]},emojiList:{label:`emoji list`}}};function tf(e){return e?$d[e]??`puzzle`:`puzzle`}function nf(e){return{icon:tf(e?.emoji),title:e?.title,label:e?.label,detailKeys:e?.detailKeys,actions:e?.actions}}var rf=pd,af=nf(rf.fallback??{emoji:`🧩`}),of=Object.fromEntries(Object.entries(rf.tools??{}).map(([e,t])=>[e,nf(t)]));of.slack=ef;function sf(e){if(!e)return e;for(let t of[{re:/^\/Users\/[^/]+(\/|$)/,replacement:`~$1`},{re:/^\/home\/[^/]+(\/|$)/,replacement:`~$1`},{re:/^C:\\Users\\[^\\]+(\\|$)/i,replacement:`~$1`}])if(t.re.test(e))return e.replace(t.re,t.replacement);return e}function cf(e){let t=hd(e.name),n=t.toLowerCase(),r=of[n],i=r?.icon??af.icon??`puzzle`,a=r?.title??gd(t),o=r?.label??a,{verb:s,detail:c}=yd({toolKey:n,args:e.args,meta:e.meta,spec:r,fallbackDetailKeys:af.detailKeys,detailMode:`first`,detailCoerce:{includeFalse:!0,includeZero:!0}});return c&&=sf(c),{name:t,icon:i,title:a,label:o,verb:s,detail:c}}function lf(e){return Qd(e.detail,{prefixWithWith:!0})}function uf(e){let t=e.trim();if(t.startsWith(`{`)||t.startsWith(`[`))try{let e=JSON.parse(t);return"```json\n"+JSON.stringify(e,null,2)+"\n```"}catch{}return e}function df(e){let t=e.split(`
`),n=t.slice(0,2),r=n.join(`
`);return r.length>100?r.slice(0,100)+`…`:n.length<t.length?r+`…`:r}function ff(e){let t=e,n=mf(t.content),r=[];for(let e of n){let t=(typeof e.type==`string`?e.type:``).toLowerCase();([`toolcall`,`tool_call`,`tooluse`,`tool_use`].includes(t)||typeof e.name==`string`&&e.arguments!=null)&&r.push({kind:`call`,name:e.name??`tool`,args:hf(e.arguments??e.args)})}for(let e of n){let t=(typeof e.type==`string`?e.type:``).toLowerCase();if(t!==`toolresult`&&t!==`tool_result`)continue;let n=gf(e),i=typeof e.name==`string`?e.name:`tool`;r.push({kind:`result`,name:i,text:n})}if(td(e)&&!r.some(e=>e.kind===`result`)){let n=typeof t.toolName==`string`&&t.toolName||typeof t.tool_name==`string`&&t.tool_name||`tool`,i=Go(e)??void 0;r.push({kind:`result`,name:n,text:i})}return r}function pf(e,t){let r=cf({name:e.name,args:e.args}),a=lf(r),o=!!e.text?.trim(),s=!!t,c=s?()=>{if(o){t(uf(e.text));return}t(`## ${r.label}\n\n${a?`**Command:** \`${a}\`\n\n`:``}*No output — tool completed successfully.*`)}:void 0,l=o&&(e.text?.length??0)<=80,u=o&&!l,d=o&&l,f=!o;return n`
<div
class="chat-tool-card ${s?`chat-tool-card--clickable`:``}"
@click=${c}
role=${s?`button`:i}
tabindex=${s?`0`:i}
@keydown=${s?e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),c?.())}:i}
>
<div class="chat-tool-card__header">
<div class="chat-tool-card__title">
<span class="chat-tool-card__icon">${G[r.icon]}</span>
<span>${r.label}</span>
</div>
${s?n`<span class="chat-tool-card__action">${o?`View`:``} ${G.check}</span>`:i}
${f&&!s?n`<span class="chat-tool-card__status">${G.check}</span>`:i}
</div>
${a?n`<div class="chat-tool-card__detail">${a}</div>`:i}
${f?n`
<div class="chat-tool-card__status-text muted">Completed</div>
`:i}
${u?n`<div class="chat-tool-card__preview mono">${df(e.text)}</div>`:i}
${d?n`<div class="chat-tool-card__inline mono">${e.text}</div>`:i}
</div>
`}function mf(e){return Array.isArray(e)?e.filter(Boolean):[]}function hf(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t||!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}}function gf(e){if(typeof e.text==`string`)return e.text;if(typeof e.content==`string`)return e.content}function _f(e){let t=e.content,n=[];if(Array.isArray(t))for(let e of t){if(typeof e!=`object`||!e)continue;let t=e;if(t.type===`image`){let e=t.source;if(e?.type===`base64`&&typeof e.data==`string`){let t=e.data,r=e.media_type||`image/png`,i=t.startsWith(`data:`)?t:`data:${r};base64,${t}`;n.push({url:i})}else typeof t.url==`string`&&n.push({url:t.url})}else if(t.type===`image_url`){let e=t.image_url;typeof e?.url==`string`&&n.push({url:e.url})}}return n}function vf(e,t){return n`
<div class="chat-group assistant">
${kf(`assistant`,e,t)}
<div class="chat-group-messages">
<div class="chat-bubble chat-reading-indicator" aria-hidden="true">
<span class="chat-reading-indicator__dots">
<span></span><span></span><span></span>
</span>
</div>
</div>
</div>
`}function yf(e,t,r,i,a){let o=new Date(t).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`}),s=i?.name??`Assistant`;return n`
<div class="chat-group assistant">
${kf(`assistant`,i,a)}
<div class="chat-group-messages">
${Lf({role:`assistant`,content:[{type:`text`,text:e}],timestamp:t},{isStreaming:!0,showReasoning:!1},r)}
<div class="chat-group-footer">
<span class="chat-sender-name">${s}</span>
<span class="chat-group-timestamp">${o}</span>
</div>
</div>
</div>
`}function bf(e,t){let r=ed(e.role),a=t.assistantName??`Assistant`,o=e.senderLabel?.trim(),s=r===`user`?o??`You`:r===`assistant`?a:r===`tool`?`Tool`:r,c=r===`user`?`user`:r===`assistant`?`assistant`:r===`tool`?`tool`:`other`,l=new Date(e.timestamp).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`}),u=xf(e,t.contextWindow??null);return n`
<div class="chat-group ${c}">
${kf(e.role,{name:a,avatar:t.assistantAvatar??null},t.basePath)}
<div class="chat-group-messages">
${e.messages.map((n,r)=>Lf(n.message,{isStreaming:e.isStreaming&&r===e.messages.length-1,showReasoning:t.showReasoning,showToolCalls:t.showToolCalls??!0},t.onOpenSidebar))}
<div class="chat-group-footer">
<span class="chat-sender-name">${s}</span>
<span class="chat-group-timestamp">${l}</span>
${Cf(u)}
${r===`assistant`&&sd()?Of(e):i}
${t.onDelete?Df(t.onDelete,r===`user`?`left`:`right`):i}
</div>
</div>
</div>
`}function xf(e,t){let n=0,r=0,i=0,a=0,o=0,s=null,c=!1;for(let{message:t}of e.messages){let e=t;if(e.role!==`assistant`)continue;let l=e.usage;l&&(c=!0,n+=l.input??l.inputTokens??0,r+=l.output??l.outputTokens??0,i+=l.cacheRead??l.cache_read_input_tokens??0,a+=l.cacheWrite??l.cache_creation_input_tokens??0);let u=e.cost;u?.total&&(o+=u.total),typeof e.model==`string`&&e.model!==`gateway-injected`&&(s=e.model)}if(!c&&!s)return null;let l=t&&n>0?Math.min(Math.round(n/t*100),100):null;return{input:n,output:r,cacheRead:i,cacheWrite:a,cost:o,model:s,contextPercent:l}}function Sf(e){return e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`:String(e)}function Cf(e){if(!e)return i;let t=[];if(e.input&&t.push(n`<span class="msg-meta__tokens">↑${Sf(e.input)}</span>`),e.output&&t.push(n`<span class="msg-meta__tokens">↓${Sf(e.output)}</span>`),e.cacheRead&&t.push(n`<span class="msg-meta__cache">R${Sf(e.cacheRead)}</span>`),e.cacheWrite&&t.push(n`<span class="msg-meta__cache">W${Sf(e.cacheWrite)}</span>`),e.cost>0&&t.push(n`<span class="msg-meta__cost">$${e.cost.toFixed(4)}</span>`),e.contextPercent!==null){let r=e.contextPercent,i=r>=90?`msg-meta__ctx msg-meta__ctx--danger`:r>=75?`msg-meta__ctx msg-meta__ctx--warn`:`msg-meta__ctx`;t.push(n`<span class="${i}">${r}% ctx</span>`)}if(e.model){let r=e.model.includes(`/`)?e.model.split(`/`).pop():e.model;t.push(n`<span class="msg-meta__model">${r}</span>`)}return t.length===0?i:n`<span class="msg-meta">${t}</span>`}function wf(e){let t=[];for(let{message:n}of e.messages){let e=Go(n);e?.trim()&&t.push(e.trim())}return t.join(`
`)}var Tf=`openclaw:skipDeleteConfirm`;function Ef(){try{return w()?.getItem(Tf)===`1`}catch{return!1}}function Df(e,t){return n`
<span class="chat-delete-wrap">
<button
class="chat-group-delete"
title="Delete"
aria-label="Delete message"
@click=${n=>{if(Ef()){e();return}let r=n.currentTarget,i=r.closest(`.chat-delete-wrap`),a=i?.querySelector(`.chat-delete-confirm`);if(a){a.remove();return}let o=document.createElement(`div`);o.className=`chat-delete-confirm chat-delete-confirm--${t}`,o.innerHTML=`
<p class="chat-delete-confirm__text">Delete this message?</p>
<label class="chat-delete-confirm__remember">
<input type="checkbox" class="chat-delete-confirm__check" />
<span>Don't ask again</span>
</label>
<div class="chat-delete-confirm__actions">
<button class="chat-delete-confirm__cancel" type="button">Cancel</button>
<button class="chat-delete-confirm__yes" type="button">Delete</button>
</div>
`,i.appendChild(o);let s=o.querySelector(`.chat-delete-confirm__cancel`),c=o.querySelector(`.chat-delete-confirm__yes`),l=o.querySelector(`.chat-delete-confirm__check`);s.addEventListener(`click`,()=>o.remove()),c.addEventListener(`click`,()=>{if(l.checked)try{w()?.setItem(Tf,`1`)}catch{}o.remove(),e()});let u=e=>{!o.contains(e.target)&&e.target!==r&&(o.remove(),document.removeEventListener(`click`,u,!0))};requestAnimationFrame(()=>document.addEventListener(`click`,u,!0))}}
>${G.trash??G.x}</button>
</span>
`}function Of(e){return n`
<button
class="btn btn--xs chat-tts-btn"
type="button"
title=${dd()?`Stop speaking`:`Read aloud`}
aria-label=${dd()?`Stop speaking`:`Read aloud`}
@click=${t=>{let n=t.currentTarget;if(dd()){ud(),n.classList.remove(`chat-tts-btn--active`),n.title=`Read aloud`;return}let r=wf(e);r&&(n.classList.add(`chat-tts-btn--active`),n.title=`Stop speaking`,ld(r,{onEnd:()=>{n.isConnected&&(n.classList.remove(`chat-tts-btn--active`),n.title=`Read aloud`)},onError:()=>{n.isConnected&&(n.classList.remove(`chat-tts-btn--active`),n.title=`Read aloud`)}}))}}
>
${G.volume2}
</button>
`}function kf(e,t,r){let i=ed(e),a=t?.name?.trim()||`Assistant`,o=t?.avatar?.trim()||``,s=i===`user`?n`
<svg viewBox="0 0 24 24" fill="currentColor" width="18" height="18">
<circle cx="12" cy="8" r="4" />
<path d="M20 21a8 8 0 1 0-16 0" />
</svg>
`:i===`assistant`?n`
<svg viewBox="0 0 24 24" fill="currentColor" width="18" height="18">
<path d="M12 2l2.4 7.2H22l-6 4.8 2.4 7.2L12 16l-6.4 5.2L8 14 2 9.2h7.6z" />
</svg>
`:i===`tool`?n`
<svg viewBox="0 0 24 24" fill="currentColor" width="18" height="18">
<path
d="M12 15.5A3.5 3.5 0 0 1 8.5 12 3.5 3.5 0 0 1 12 8.5a3.5 3.5 0 0 1 3.5 3.5 3.5 3.5 0 0 1-3.5 3.5m7.43-2.53a7.76 7.76 0 0 0 .07-1 7.76 7.76 0 0 0-.07-.97l2.11-1.63a.5.5 0 0 0 .12-.64l-2-3.46a.5.5 0 0 0-.61-.22l-2.49 1a7.15 7.15 0 0 0-1.69-.98l-.38-2.65A.49.49 0 0 0 14 2h-4a.49.49 0 0 0-.49.42l-.38 2.65a7.15 7.15 0 0 0-1.69.98l-2.49-1a.5.5 0 0 0-.61.22l-2 3.46a.49.49 0 0 0 .12.64L4.57 11a7.9 7.9 0 0 0 0 1.94l-2.11 1.69a.49.49 0 0 0-.12.64l2 3.46a.5.5 0 0 0 .61.22l2.49-1c.52.4 1.08.72 1.69.98l.38 2.65c.05.24.26.42.49.42h4c.23 0 .44-.18.49-.42l.38-2.65a7.15 7.15 0 0 0 1.69-.98l2.49 1a.5.5 0 0 0 .61-.22l2-3.46a.49.49 0 0 0-.12-.64z"
/>
</svg>
`:n`
<svg viewBox="0 0 24 24" fill="currentColor" width="18" height="18">
<circle cx="12" cy="12" r="10" />
<text
x="12"
y="16.5"
text-anchor="middle"
font-size="14"
font-weight="600"
fill="var(--bg, #fff)"
>
?
</text>
</svg>
`,c=i===`user`?`user`:i===`assistant`?`assistant`:i===`tool`?`tool`:`other`;return o&&i===`assistant`?Af(o)?n`<img
class="chat-avatar ${c}"
src="${o}"
alt="${a}"
/>`:n`<img
class="chat-avatar ${c} chat-avatar--logo"
src="${xu(r??``)}"
alt="${a}"
/>`:i===`assistant`&&r?n`<img
class="chat-avatar ${c} chat-avatar--logo"
src="${xu(r)}"
alt="${a}"
/>`:n`<div class="chat-avatar ${c}">${s}</div>`}function Af(e){return/^https?:\/\//i.test(e)||/^data:image\//i.test(e)||e.startsWith(`/`)}function jf(e){if(e.length===0)return i;let t=e=>{$l(e,{allowDataImage:!0})};return n`
<div class="chat-message-images">
${e.map(e=>n`
<img
src=${e.url}
alt=${e.alt??`Attached image`}
class="chat-message-image"
@click=${()=>t(e.url)}
/>
`)}
</div>
`}function Mf(e,t){let r=e.filter(e=>e.kind===`call`),i=e.filter(e=>e.kind===`result`),a=Math.max(r.length,i.length)||e.length,o=[...new Set(e.map(e=>e.name))],s=o.length<=3?o.join(`, `):`${o.slice(0,2).join(`, `)} +${o.length-2} more`;return n`
<details class="chat-tools-collapse">
<summary class="chat-tools-summary">
<span class="chat-tools-summary__icon">${G.zap}</span>
<span class="chat-tools-summary__count">${a} tool${a===1?``:`s`}</span>
<span class="chat-tools-summary__names">${s}</span>
</summary>
<div class="chat-tools-collapse__body">
${e.map(e=>pf(e,t))}
</div>
</details>
`}var Nf=2e4;function Pf(e){let t=e.trim();if(t.length>Nf)return null;if(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith(`[`)&&t.endsWith(`]`))try{let e=JSON.parse(t);return{parsed:e,pretty:JSON.stringify(e,null,2)}}catch{return null}return null}function Ff(e){if(Array.isArray(e))return`Array (${e.length} item${e.length===1?``:`s`})`;if(e&&typeof e==`object`){let t=Object.keys(e);return t.length<=4?`{ ${t.join(`, `)} }`:`Object (${t.length} keys)`}return`JSON`}function If(e,t){return n`
<button
class="btn btn--xs chat-expand-btn"
type="button"
title="Open in canvas"
aria-label="Open in canvas"
@click=${()=>t(e)}
>
<span class="chat-expand-btn__icon" aria-hidden="true">${G.panelRightOpen}</span>
</button>
`}function Lf(e,t,r){let a=e,o=typeof a.role==`string`?a.role:`unknown`,s=ed(o),c=td(e)||o.toLowerCase()===`toolresult`||o.toLowerCase()===`tool_result`||typeof a.toolCallId==`string`||typeof a.tool_call_id==`string`,l=t.showToolCalls??!0?ff(e):[],u=l.length>0,d=_f(e),f=d.length>0,p=Go(e),m=t.showReasoning&&o===`assistant`?qo(e):null,h=p?.trim()?p:null,g=m?Yo(m):null,_=h,v=o===`assistant`&&!!_?.trim(),y=o===`assistant`&&!!(r&&_?.trim()),b=_&&!t.isStreaming?Pf(_):null,x=[`chat-bubble`,t.isStreaming?`streaming`:``,`fade-in`].filter(Boolean).join(` `);if(!_&&u&&c)return Mf(l,r);let S=u&&(t.showToolCalls??!0);if(!_&&!S&&!f)return i;let C=s===`tool`||c,w=[...new Set(l.map(e=>e.name))],T=w.length<=3?w.join(`, `):`${w.slice(0,2).join(`, `)} +${w.length-2} more`,E=_&&!T?_.trim().replace(/\s+/g,` `).slice(0,120):``;return n`
<div class="${x}">
${v||y?n`<div class="chat-bubble-actions">
${y?If(_,r):i}
${v?Qu(_):i}
</div>`:i}
${C?n`
<details class="chat-tool-msg-collapse">
<summary class="chat-tool-msg-summary">
<span class="chat-tool-msg-summary__icon">${G.zap}</span>
<span class="chat-tool-msg-summary__label">Tool output</span>
${T?n`<span class="chat-tool-msg-summary__names">${T}</span>`:E?n`<span class="chat-tool-msg-summary__preview">${E}</span>`:i}
</summary>
<div class="chat-tool-msg-body">
${jf(d)}
${g?n`<div class="chat-thinking">${$o(Ul(g))}</div>`:i}
${b?n`<details class="chat-json-collapse">
<summary class="chat-json-summary">
<span class="chat-json-badge">JSON</span>
<span class="chat-json-label">${Ff(b.parsed)}</span>
</summary>
<pre class="chat-json-content"><code>${b.pretty}</code></pre>
</details>`:_?n`<div class="chat-text" dir="${tu(_)}">${$o(Ul(_))}</div>`:i}
${u?Mf(l,r):i}
</div>
</details>
`:n`
${jf(d)}
${g?n`<div class="chat-thinking">${$o(Ul(g))}</div>`:i}
${b?n`<details class="chat-json-collapse">
<summary class="chat-json-summary">
<span class="chat-json-badge">JSON</span>
<span class="chat-json-label">${Ff(b.parsed)}</span>
</summary>
<pre class="chat-json-content"><code>${b.pretty}</code></pre>
</details>`:_?n`<div class="chat-text" dir="${tu(_)}">${$o(Ul(_))}</div>`:i}
${u?Mf(l,r):i}
`}
</div>
`}var Rf=50,zf=class{constructor(){this.items=[],this.cursor=-1}push(e){let t=e.trim();t&&this.items[this.items.length-1]!==t&&(this.items.push(t),this.items.length>Rf&&this.items.shift(),this.cursor=-1)}up(){return this.items.length===0?null:(this.cursor<0?this.cursor=this.items.length-1:this.cursor>0&&this.cursor--,this.items[this.cursor]??null)}down(){return this.cursor<0?null:(this.cursor++,this.cursor>=this.items.length?(this.cursor=-1,null):this.items[this.cursor]??null)}reset(){this.cursor=-1}},Bf=`openclaw:pinned:`,Vf=class{constructor(e){this._indices=new Set,this.key=Bf+e,this.load()}get indices(){return this._indices}has(e){return this._indices.has(e)}pin(e){this._indices.add(e),this.save()}unpin(e){this._indices.delete(e),this.save()}toggle(e){this._indices.has(e)?this.unpin(e):this.pin(e)}clear(){this._indices.clear(),this.save()}load(){try{let e=w()?.getItem(this.key);if(!e)return;let t=JSON.parse(e);Array.isArray(t)&&(this._indices=new Set(t.filter(e=>typeof e==`number`)))}catch{}}save(){try{w()?.setItem(this.key,JSON.stringify([...this._indices]))}catch{}}};function Hf(e){return Go(e)??``}function Uf(e,t){let n=t.trim().toLowerCase();return n?(Go(e)??``).toLowerCase().includes(n):!0}function Wf(e,t,n){if(e.has(t)){let n=e.get(t);return e.delete(t),e.set(t,n),n}let r=n();for(e.set(t,r);e.size>20;){let t=e.keys().next().value;if(typeof t!=`string`)break;e.delete(t)}return r}var Gf=[{name:`new`,description:`Start a new session`,icon:`plus`,category:`session`,executeLocal:!0},{name:`reset`,description:`Reset current session`,icon:`refresh`,category:`session`,executeLocal:!0},{name:`compact`,description:`Compact session context`,icon:`loader`,category:`session`,executeLocal:!0},{name:`stop`,description:`Stop current run`,icon:`stop`,category:`session`,executeLocal:!0},{name:`clear`,description:`Clear chat history`,icon:`trash`,category:`session`,executeLocal:!0},{name:`focus`,description:`Toggle focus mode`,icon:`eye`,category:`session`,executeLocal:!0},{name:`model`,description:`Show or set model`,args:`<name>`,icon:`brain`,category:`model`,executeLocal:!0},{name:`think`,description:`Set thinking level`,args:`<level>`,icon:`brain`,category:`model`,executeLocal:!0,argOptions:[`off`,`low`,`medium`,`high`]},{name:`verbose`,description:`Toggle verbose mode`,args:`<on|off|full>`,icon:`terminal`,category:`model`,executeLocal:!0,argOptions:[`on`,`off`,`full`]},{name:`fast`,description:`Toggle fast mode`,args:`<status|on|off>`,icon:`zap`,category:`model`,executeLocal:!0,argOptions:[`status`,`on`,`off`]},{name:`help`,description:`Show available commands`,icon:`book`,category:`tools`,executeLocal:!0},{name:`status`,description:`Show session status`,icon:`barChart`,category:`tools`},{name:`export`,description:`Export session to Markdown`,icon:`download`,category:`tools`,executeLocal:!0},{name:`usage`,description:`Show token usage`,icon:`barChart`,category:`tools`,executeLocal:!0},{name:`agents`,description:`List agents`,icon:`monitor`,category:`agents`,executeLocal:!0},{name:`kill`,description:`Abort sub-agents`,args:`<id|all>`,icon:`x`,category:`agents`,executeLocal:!0},{name:`skill`,description:`Run a skill`,args:`<name>`,icon:`zap`,category:`tools`},{name:`steer`,description:`Steer a sub-agent`,args:`<id> <msg>`,icon:`send`,category:`agents`}],Kf=[`session`,`model`,`tools`,`agents`],qf={session:`Session`,model:`Model`,agents:`Agents`,tools:`Tools`};function Jf(e){let t=e.toLowerCase();return(t?Gf.filter(e=>e.name.startsWith(t)||e.description.toLowerCase().includes(t)):Gf).toSorted((e,n)=>{let r=Kf.indexOf(e.category??`session`),i=Kf.indexOf(n.category??`session`);if(r!==i)return r-i;if(t){let r=e.name.startsWith(t)?0:1,i=n.name.startsWith(t)?0:1;if(r!==i)return r-i}return 0})}function Yf(e){let t=e.trim();if(!t.startsWith(`/`))return null;let n=t.slice(1),r=n.search(/[\s:]/u),i=r===-1?n:n.slice(0,r),a=r===-1?``:n.slice(r).trimStart();a.startsWith(`:`)&&(a=a.slice(1).trimStart());let o=a.trim();if(!i)return null;let s=Gf.find(e=>e.name===i.toLowerCase());return s?{command:s,args:o}:null}function Xf(e){return n`
<div class="sidebar-panel">
<div class="sidebar-header">
<div class="sidebar-title">Tool Output</div>
<button @click=${e.onClose} class="btn" title="Close sidebar">
${G.x}
</button>
</div>
<div class="sidebar-content">
${e.error?n`
<div class="callout danger">${e.error}</div>
<button @click=${e.onViewRawText} class="btn" style="margin-top: 12px;">
View Raw Text
</button>
`:e.content?n`<div class="sidebar-markdown">${$o(Ul(e.content))}</div>`:n`
<div class="muted">No content available</div>
`}
</div>
</div>
`}function Y(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var Zf=class extends c{constructor(...e){super(...e),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.isDragging=!1,this.startX=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startX=e.clientX,this.startRatio=this.splitRatio,this.classList.add(`dragging`),document.addEventListener(`mousemove`,this.handleMouseMove),document.addEventListener(`mouseup`,this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;let t=this.parentElement;if(!t)return;let n=t.getBoundingClientRect().width,r=(e.clientX-this.startX)/n,i=this.startRatio+r;i=Math.max(this.minRatio,Math.min(this.maxRatio,i)),this.dispatchEvent(new CustomEvent(`resize`,{detail:{splitRatio:i},bubbles:!0,composed:!0}))},this.handleMouseUp=()=>{this.isDragging=!1,this.classList.remove(`dragging`),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp)}}static{this.styles=r`
:host {
width: 4px;
cursor: col-resize;
background: var(--border, #333);
transition: background 150ms ease-out;
flex-shrink: 0;
position: relative;
}
:host::before {
content: "";
position: absolute;
top: 0;
left: -4px;
right: -4px;
bottom: 0;
}
:host(:hover) {
background: var(--accent, #007bff);
}
:host(.dragging) {
background: var(--accent, #007bff);
}
`}render(){return i}connectedCallback(){super.connectedCallback(),this.addEventListener(`mousedown`,this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`mousedown`,this.handleMouseDown),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp)}};Y([x({type:Number})],Zf.prototype,`splitRatio`,void 0),Y([x({type:Number})],Zf.prototype,`minRatio`,void 0),Y([x({type:Number})],Zf.prototype,`maxRatio`,void 0),Zf=Y([v(`resizable-divider`)],Zf);var Qf=5e3,$f=8e3,ep=new Map,tp=new Map,np=new Map;function rp(e){return Wf(ep,e,()=>new zf)}function ip(e){return Wf(tp,e,()=>new Vf(e))}function ap(e){return Wf(np,e,()=>new ko(e))}function op(){return{sttRecording:!1,sttInterimText:``,slashMenuOpen:!1,slashMenuItems:[],slashMenuIndex:0,slashMenuMode:`command`,slashMenuCommand:null,slashMenuArgItems:[],searchOpen:!1,searchQuery:``,pinnedExpanded:!1}}var X=op();function sp(){X.sttRecording&&od(),Object.assign(X,op())}function cp(e){e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,150)}px`}function lp(e){return e?e.active?n`
<div class="compaction-indicator compaction-indicator--active" role="status" aria-live="polite">
${G.loader} Compacting context...
</div>
`:e.completedAt&&Date.now()-e.completedAt<Qf?n`
<div class="compaction-indicator compaction-indicator--complete" role="status" aria-live="polite">
${G.check} Context compacted
</div>
`:i:i}function up(e){if(!e)return i;let t=e.phase??`active`;if(Date.now()-e.occurredAt>=$f)return i;let r=[`Selected: ${e.selected}`,t===`cleared`?`Active: ${e.selected}`:`Active: ${e.active}`,t===`cleared`&&e.previous?`Previous fallback: ${e.previous}`:null,e.reason?`Reason: ${e.reason}`:null,e.attempts.length>0?`Attempts: ${e.attempts.slice(0,3).join(` | `)}`:null].filter(Boolean).join(` • `),a=t===`cleared`?`Fallback cleared: ${e.selected}`:`Fallback active: ${e.active}`;return n`
<div class=${t===`cleared`?`compaction-indicator compaction-indicator--fallback-cleared`:`compaction-indicator compaction-indicator--fallback`} role="status" aria-live="polite" title=${r}>
${t===`cleared`?G.check:G.brain} ${a}
</div>
`}function dp(e){let t=e.trim().replace(/^#/,``);return/^[0-9a-fA-F]{6}$/.test(t)?[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]:null}var fp=null;function pp(){if(fp)return fp;let e=getComputedStyle(document.documentElement),t=e.getPropertyValue(`--warn`).trim()||`#f59e0b`,n=e.getPropertyValue(`--danger`).trim()||`#ef4444`;return fp={warnHex:t,dangerHex:n,warnRgb:dp(t)??[245,158,11],dangerRgb:dp(n)??[239,68,68]},fp}function mp(e,t){if(e?.totalTokensFresh===!1)return i;let r=e?.totalTokens??0,a=e?.contextTokens??t??0;if(!r||!a)return i;let o=r/a;if(o<.85)return i;let s=Math.min(Math.round(o*100),100),{warnRgb:c,dangerRgb:l}=pp(),[u,d,f]=c,[p,m,h]=l,g=Math.min(Math.max((o-.85)/.1,0),1),_=Math.round(u+(p-u)*g),v=Math.round(d+(m-d)*g),y=Math.round(f+(h-f)*g);return n`
<div class="context-notice" role="status" style="--ctx-color:${`rgb(${_}, ${v}, ${y})`};--ctx-bg:${`rgba(${_}, ${v}, ${y}, ${.08+.08*g})`}">
<svg class="context-notice__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
<span>${s}% context used</span>
<span class="context-notice__detail">${hp(r)} / ${hp(a)}</span>
</div>
`}function hp(e){return e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`:String(e)}function gp(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function _p(e,t){let n=e.clipboardData?.items;if(!n||!t.onAttachmentsChange)return;let r=[];for(let e=0;e<n.length;e++){let t=n[e];t.type.startsWith(`image/`)&&r.push(t)}if(r.length!==0){e.preventDefault();for(let e of r){let n=e.getAsFile();if(!n)continue;let r=new FileReader;r.addEventListener(`load`,()=>{let e=r.result,i={id:gp(),dataUrl:e,mimeType:n.type},a=t.attachments??[];t.onAttachmentsChange?.([...a,i])}),r.readAsDataURL(n)}}}function vp(e,t){let n=e.target;if(!n.files||!t.onAttachmentsChange)return;let r=t.attachments??[],i=[],a=0;for(let e of n.files){if(!Do(e.type))continue;a++;let n=new FileReader;n.addEventListener(`load`,()=>{i.push({id:gp(),dataUrl:n.result,mimeType:e.type}),a--,a===0&&t.onAttachmentsChange?.([...r,...i])}),n.readAsDataURL(e)}n.value=``}function yp(e,t){e.preventDefault();let n=e.dataTransfer?.files;if(!n||!t.onAttachmentsChange)return;let r=t.attachments??[],i=[],a=0;for(let e of n){if(!Do(e.type))continue;a++;let n=new FileReader;n.addEventListener(`load`,()=>{i.push({id:gp(),dataUrl:n.result,mimeType:e.type}),a--,a===0&&t.onAttachmentsChange?.([...r,...i])}),n.readAsDataURL(e)}}function bp(e){let t=e.attachments??[];return t.length===0?i:n`
<div class="chat-attachments-preview">
${t.map(t=>n`
<div class="chat-attachment-thumb">
<img src=${t.dataUrl} alt="Attachment preview" />
<button
class="chat-attachment-remove"
type="button"
aria-label="Remove attachment"
@click=${()=>{let n=(e.attachments??[]).filter(e=>e.id!==t.id);e.onAttachmentsChange?.(n)}}
>×</button>
</div>
`)}
</div>
`}function xp(){X.slashMenuMode=`command`,X.slashMenuCommand=null,X.slashMenuArgItems=[],X.slashMenuItems=[]}function Sp(e,t){let n=e.match(/^\/(\S+)\s(.*)$/);if(n){let e=n[1].toLowerCase(),r=n[2].toLowerCase(),i=Gf.find(t=>t.name===e);if(i?.argOptions?.length){let e=r?i.argOptions.filter(e=>e.toLowerCase().startsWith(r)):i.argOptions;if(e.length>0){X.slashMenuMode=`args`,X.slashMenuCommand=i,X.slashMenuArgItems=e,X.slashMenuOpen=!0,X.slashMenuIndex=0,X.slashMenuItems=[],t();return}}X.slashMenuOpen=!1,xp(),t();return}let r=e.match(/^\/(\S*)$/);if(r){let e=Jf(r[1]);X.slashMenuItems=e,X.slashMenuOpen=e.length>0,X.slashMenuIndex=0,X.slashMenuMode=`command`,X.slashMenuCommand=null,X.slashMenuArgItems=[]}else X.slashMenuOpen=!1,xp();t()}function Cp(e,t,n){if(e.argOptions?.length){t.onDraftChange(`/${e.name} `),X.slashMenuMode=`args`,X.slashMenuCommand=e,X.slashMenuArgItems=e.argOptions,X.slashMenuOpen=!0,X.slashMenuIndex=0,X.slashMenuItems=[],n();return}X.slashMenuOpen=!1,xp(),e.executeLocal&&!e.args?(t.onDraftChange(`/${e.name}`),n(),t.onSend()):(t.onDraftChange(`/${e.name} `),n())}function wp(e,t,n){if(e.argOptions?.length){t.onDraftChange(`/${e.name} `),X.slashMenuMode=`args`,X.slashMenuCommand=e,X.slashMenuArgItems=e.argOptions,X.slashMenuOpen=!0,X.slashMenuIndex=0,X.slashMenuItems=[],n();return}X.slashMenuOpen=!1,xp(),t.onDraftChange(e.args?`/${e.name} `:`/${e.name}`),n()}function Tp(e,t,n,r){let i=X.slashMenuCommand?.name??``;X.slashMenuOpen=!1,xp(),t.onDraftChange(`/${i} ${e}`),n(),r&&t.onSend()}function Ep(e){return e.length<100?null:`~${Math.ceil(e.length/4)} tokens`}function Dp(e){Xo(e.messages,e.assistantName)}var Op=[`What can you do?`,`Summarize my recent sessions`,`Help me configure a channel`,`Check system health`];function kp(e){let t=e.assistantName||`Assistant`,r=bu({identity:{avatar:e.assistantAvatar??void 0,avatarUrl:e.assistantAvatarUrl??void 0}}),i=xu(e.basePath??``);return n`
<div class="agent-chat__welcome" style="--agent-color: var(--accent)">
<div class="agent-chat__welcome-glow"></div>
${r?n`<img src=${r} alt=${t} style="width:56px; height:56px; border-radius:50%; object-fit:cover;" />`:n`<div class="agent-chat__avatar agent-chat__avatar--logo"><img src=${i} alt="OpenClaw" /></div>`}
<h2>${t}</h2>
<div class="agent-chat__badges">
<span class="agent-chat__badge"><img src=${i} alt="" /> Ready to chat</span>
</div>
<p class="agent-chat__hint">
Type a message below · <kbd>/</kbd> for commands
</p>
<div class="agent-chat__suggestions">
${Op.map(t=>n`
<button
type="button"
class="agent-chat__suggestion"
@click=${()=>{e.onDraftChange(t),e.onSend()}}
>${t}</button>
`)}
</div>
</div>
`}function Ap(e){return X.searchOpen?n`
<div class="agent-chat__search-bar">
${G.search}
<input
type="text"
placeholder="Search messages..."
.value=${X.searchQuery}
@input=${t=>{X.searchQuery=t.target.value,e()}}
/>
<button class="btn btn--ghost" @click=${()=>{X.searchOpen=!1,X.searchQuery=``,e()}}>
${G.x}
</button>
</div>
`:i}function jp(e,t,r){let a=Array.isArray(e.messages)?e.messages:[],o=[];for(let e of t.indices){let t=a[e];if(!t)continue;let n=Hf(t),r=typeof t.role==`string`?t.role:`unknown`;o.push({index:e,text:n,role:r})}return o.length===0?i:n`
<div class="agent-chat__pinned">
<button class="agent-chat__pinned-toggle" @click=${()=>{X.pinnedExpanded=!X.pinnedExpanded,r()}}>
${G.bookmark}
${o.length} pinned
<span class="collapse-chevron ${X.pinnedExpanded?``:`collapse-chevron--collapsed`}">${G.chevronDown}</span>
</button>
${X.pinnedExpanded?n`
<div class="agent-chat__pinned-list">
${o.map(({index:e,text:i,role:a})=>n`
<div class="agent-chat__pinned-item">
<span class="agent-chat__pinned-role">${a===`user`?`You`:`Assistant`}</span>
<span class="agent-chat__pinned-text">${i.slice(0,100)}${i.length>100?`...`:``}</span>
<button class="btn btn--ghost" @click=${()=>{t.unpin(e),r()}} title="Unpin">
${G.x}
</button>
</div>
`)}
</div>
`:i}
</div>
`}function Mp(e,t){if(!X.slashMenuOpen)return i;if(X.slashMenuMode===`args`&&X.slashMenuCommand&&X.slashMenuArgItems.length>0)return n`
<div class="slash-menu">
<div class="slash-menu-group">
<div class="slash-menu-group__label">/${X.slashMenuCommand.name} ${X.slashMenuCommand.description}</div>
${X.slashMenuArgItems.map((r,a)=>n`
<div
class="slash-menu-item ${a===X.slashMenuIndex?`slash-menu-item--active`:``}"
@click=${()=>Tp(r,t,e,!0)}
@mouseenter=${()=>{X.slashMenuIndex=a,e()}}
>
${X.slashMenuCommand?.icon?n`<span class="slash-menu-icon">${G[X.slashMenuCommand.icon]}</span>`:i}
<span class="slash-menu-name">${r}</span>
<span class="slash-menu-desc">/${X.slashMenuCommand?.name} ${r}</span>
</div>
`)}
</div>
<div class="slash-menu-footer">
<kbd>↑↓</kbd> navigate
<kbd>Tab</kbd> fill
<kbd>Enter</kbd> run
<kbd>Esc</kbd> close
</div>
</div>
`;if(X.slashMenuItems.length===0)return i;let r=new Map;for(let e=0;e<X.slashMenuItems.length;e++){let t=X.slashMenuItems[e],n=t.category??`session`,i=r.get(n);i||(i=[],r.set(n,i)),i.push({cmd:t,globalIdx:e})}let a=[];for(let[o,s]of r)a.push(n`
<div class="slash-menu-group">
<div class="slash-menu-group__label">${qf[o]}</div>
${s.map(({cmd:r,globalIdx:a})=>n`
<div
class="slash-menu-item ${a===X.slashMenuIndex?`slash-menu-item--active`:``}"
@click=${()=>Cp(r,t,e)}
@mouseenter=${()=>{X.slashMenuIndex=a,e()}}
>
${r.icon?n`<span class="slash-menu-icon">${G[r.icon]}</span>`:i}
<span class="slash-menu-name">/${r.name}</span>
${r.args?n`<span class="slash-menu-args">${r.args}</span>`:i}
<span class="slash-menu-desc">${r.description}</span>
${r.argOptions?.length?n`<span class="slash-menu-badge">${r.argOptions.length} options</span>`:r.executeLocal&&!r.args?n`
<span class="slash-menu-badge">instant</span>
`:i}
</div>
`)}
</div>
`);return n`
<div class="slash-menu">
${a}
<div class="slash-menu-footer">
<kbd>↑↓</kbd> navigate
<kbd>Tab</kbd> fill
<kbd>Enter</kbd> select
<kbd>Esc</kbd> close
</div>
</div>
`}function Np(e){let t=e.connected,r=e.sending||e.stream!==null,a=!!(e.canAbort&&e.onAbort),o=e.sessions?.sessions?.find(t=>t.key===e.sessionKey),s=o?.reasoningLevel??`off`,c=e.showThinking&&s!==`off`,l={name:e.assistantName,avatar:bu({identity:{avatar:e.assistantAvatar??void 0,avatarUrl:e.assistantAvatarUrl??void 0}})??null},u=ip(e.sessionKey),d=ap(e.sessionKey),f=rp(e.sessionKey),p=(e.attachments?.length??0)>0,m=Ep(e.draft),h=e.connected?p?`Add a message or paste more images...`:`Message ${e.assistantName||`agent`} (Enter to send)`:`Connect to the gateway to start chatting...`,g=e.onRequestUpdate??(()=>{}),_=e.getDraft??(()=>e.draft),v=e.splitRatio??.6,y=!!(e.sidebarOpen&&e.onCloseSidebar),b=e=>{let t=e.target.closest(`.code-block-copy`);if(!t)return;let n=t.dataset.code??``;navigator.clipboard.writeText(n).then(()=>{t.classList.add(`copied`),setTimeout(()=>t.classList.remove(`copied`),1500)},()=>{})},x=Ip(e),S=x.length===0&&!e.loading,C=n`
<div
class="chat-thread"
role="log"
aria-live="polite"
@scroll=${e.onChatScroll}
@click=${b}
>
<div class="chat-thread-inner">
${e.loading?n`
<div class="chat-loading-skeleton" aria-label="Loading chat">
<div class="chat-line assistant">
<div class="chat-msg">
<div class="chat-bubble">
<div class="skeleton skeleton-line skeleton-line--long" style="margin-bottom: 8px"></div>
<div class="skeleton skeleton-line skeleton-line--medium" style="margin-bottom: 8px"></div>
<div class="skeleton skeleton-line skeleton-line--short"></div>
</div>
</div>
</div>
<div class="chat-line user" style="margin-top: 12px">
<div class="chat-msg">
<div class="chat-bubble">
<div class="skeleton skeleton-line skeleton-line--medium"></div>
</div>
</div>
</div>
<div class="chat-line assistant" style="margin-top: 12px">
<div class="chat-msg">
<div class="chat-bubble">
<div class="skeleton skeleton-line skeleton-line--long" style="margin-bottom: 8px"></div>
<div class="skeleton skeleton-line skeleton-line--short"></div>
</div>
</div>
</div>
</div>
`:i}
${S&&!X.searchOpen?kp(e):i}
${S&&X.searchOpen?n`
<div class="agent-chat__empty">No matching messages</div>
`:i}
${To(x,e=>e.key,t=>t.kind===`divider`?n`
<div class="chat-divider" role="separator" data-ts=${String(t.timestamp)}>
<span class="chat-divider__line"></span>
<span class="chat-divider__label">${t.label}</span>
<span class="chat-divider__line"></span>
</div>
`:t.kind===`reading-indicator`?vf(l,e.basePath):t.kind===`stream`?yf(t.text,t.startedAt,e.onOpenSidebar,l,e.basePath):t.kind===`group`?d.has(t.key)?i:bf(t,{onOpenSidebar:e.onOpenSidebar,showReasoning:c,showToolCalls:e.showToolCalls,assistantName:e.assistantName,assistantAvatar:l.avatar,basePath:e.basePath,contextWindow:o?.contextTokens??e.sessions?.defaults?.contextTokens??null,onDelete:()=>{d.delete(t.key),g()}}):i)}
</div>
</div>
`;return n`
<section
class="card chat"
@drop=${t=>yp(t,e)}
@dragover=${e=>e.preventDefault()}
>
${e.disabledReason?n`<div class="callout">${e.disabledReason}</div>`:i}
${e.error?n`<div class="callout danger">${e.error}</div>`:i}
${e.focusMode?n`
<button
class="chat-focus-exit"
type="button"
@click=${e.onToggleFocusMode}
aria-label="Exit focus mode"
title="Exit focus mode"
>
${G.x}
</button>
`:i}
${Ap(g)}
${jp(e,u,g)}
<div class="chat-split-container ${y?`chat-split-container--open`:``}">
<div
class="chat-main"
style="flex: ${y?`0 0 ${v*100}%`:`1 1 100%`}"
>
${C}
</div>
${y?n`
<resizable-divider
.splitRatio=${v}
@resize=${t=>e.onSplitRatioChange?.(t.detail.splitRatio)}
></resizable-divider>
<div class="chat-sidebar">
${Xf({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`\n${e.sidebarContent}\n\`\`\``)}})}
</div>
`:i}
</div>
${e.queue.length?n`
<div class="chat-queue" role="status" aria-live="polite">
<div class="chat-queue__title">Queued (${e.queue.length})</div>
<div class="chat-queue__list">
${e.queue.map(t=>n`
<div class="chat-queue__item">
<div class="chat-queue__text">
${t.text||(t.attachments?.length?`Image (${t.attachments.length})`:``)}
</div>
<button
class="btn chat-queue__remove"
type="button"
aria-label="Remove queued message"
@click=${()=>e.onQueueRemove(t.id)}
>
${G.x}
</button>
</div>
`)}
</div>
</div>
`:i}
${up(e.fallbackStatus)}
${lp(e.compactionStatus)}
${mp(o,e.sessions?.defaults?.contextTokens??null)}
${e.showNewMessages?n`
<button
class="chat-new-messages"
type="button"
@click=${e.onScrollToBottom}
>
${G.arrowDown} New messages
</button>
`:i}
<!-- Input bar -->
<div class="agent-chat__input">
${Mp(g,e)}
${bp(e)}
<input
type="file"
accept=${Eo}
multiple
class="agent-chat__file-input"
@change=${t=>vp(t,e)}
/>
${X.sttRecording&&X.sttInterimText?n`<div class="agent-chat__stt-interim">${X.sttInterimText}</div>`:i}
<textarea
${Co(e=>e&&cp(e))}
.value=${e.draft}
dir=${tu(e.draft)}
?disabled=${!e.connected}
@keydown=${n=>{if(X.slashMenuOpen&&X.slashMenuMode===`args`&&X.slashMenuArgItems.length>0){let t=X.slashMenuArgItems.length;switch(n.key){case`ArrowDown`:n.preventDefault(),X.slashMenuIndex=(X.slashMenuIndex+1)%t,g();return;case`ArrowUp`:n.preventDefault(),X.slashMenuIndex=(X.slashMenuIndex-1+t)%t,g();return;case`Tab`:n.preventDefault(),Tp(X.slashMenuArgItems[X.slashMenuIndex],e,g,!1);return;case`Enter`:n.preventDefault(),Tp(X.slashMenuArgItems[X.slashMenuIndex],e,g,!0);return;case`Escape`:n.preventDefault(),X.slashMenuOpen=!1,xp(),g();return}}if(X.slashMenuOpen&&X.slashMenuItems.length>0){let t=X.slashMenuItems.length;switch(n.key){case`ArrowDown`:n.preventDefault(),X.slashMenuIndex=(X.slashMenuIndex+1)%t,g();return;case`ArrowUp`:n.preventDefault(),X.slashMenuIndex=(X.slashMenuIndex-1+t)%t,g();return;case`Tab`:n.preventDefault(),wp(X.slashMenuItems[X.slashMenuIndex],e,g);return;case`Enter`:n.preventDefault(),Cp(X.slashMenuItems[X.slashMenuIndex],e,g);return;case`Escape`:n.preventDefault(),X.slashMenuOpen=!1,xp(),g();return}}if(!e.draft.trim()){if(n.key===`ArrowUp`){let t=f.up();t!==null&&(n.preventDefault(),e.onDraftChange(t));return}if(n.key===`ArrowDown`){let t=f.down();n.preventDefault(),e.onDraftChange(t??``);return}}if((n.metaKey||n.ctrlKey)&&!n.shiftKey&&n.key===`f`){n.preventDefault(),X.searchOpen=!X.searchOpen,X.searchOpen||(X.searchQuery=``),g();return}if(n.key===`Enter`&&!n.shiftKey){if(n.isComposing||n.keyCode===229||!e.connected)return;n.preventDefault(),t&&(e.draft.trim()&&f.push(e.draft),e.onSend())}}}
@input=${t=>{let n=t.target;cp(n),Sp(n.value,g),f.reset(),e.onDraftChange(n.value)}}
@paste=${t=>_p(t,e)}
placeholder=${X.sttRecording?`Listening...`:h}
rows="1"
></textarea>
<div class="agent-chat__toolbar">
<div class="agent-chat__toolbar-left">
<button
class="agent-chat__input-btn"
@click=${()=>{document.querySelector(`.agent-chat__file-input`)?.click()}}
title="Attach file"
?disabled=${!e.connected}
>
${G.paperclip}
</button>
${rd()?n`
<button
class="agent-chat__input-btn ${X.sttRecording?`agent-chat__input-btn--recording`:``}"
@click=${()=>{X.sttRecording?(od(),X.sttRecording=!1,X.sttInterimText=``,g()):ad({onTranscript:(t,n)=>{if(n){let n=_(),r=n&&!n.endsWith(` `)?` `:``;e.onDraftChange(n+r+t),X.sttInterimText=``}else X.sttInterimText=t;g()},onStart:()=>{X.sttRecording=!0,g()},onEnd:()=>{X.sttRecording=!1,X.sttInterimText=``,g()},onError:()=>{X.sttRecording=!1,X.sttInterimText=``,g()}})&&(X.sttRecording=!0,g())}}
title=${X.sttRecording?`Stop recording`:`Voice input`}
?disabled=${!e.connected}
>
${X.sttRecording?G.micOff:G.mic}
</button>
`:i}
${m?n`<span class="agent-chat__token-count">${m}</span>`:i}
</div>
<div class="agent-chat__toolbar-right">
${i}
${a?i:n`
<button
class="btn btn--ghost"
@click=${e.onNewSession}
title="New session"
aria-label="New session"
>
${G.plus}
</button>
`}
<button class="btn btn--ghost" @click=${()=>Dp(e)} title="Export" ?disabled=${e.messages.length===0}>
${G.download}
</button>
${a&&(r||e.sending)?n`
<button class="chat-send-btn chat-send-btn--stop" @click=${e.onAbort} title="Stop">
${G.stop}
</button>
`:n`
<button
class="chat-send-btn"
@click=${()=>{e.draft.trim()&&f.push(e.draft),e.onSend()}}
?disabled=${!e.connected||e.sending}
title=${r?`Queue`:`Send`}
>
${G.send}
</button>
`}
</div>
</div>
</div>
</section>
`}var Pp=200;function Fp(e){let t=[],n=null;for(let r of e){if(r.kind!==`message`){n&&=(t.push(n),null),t.push(r);continue}let e=$u(r.message),i=ed(e.role),a=i.toLowerCase()===`user`?e.senderLabel??null:null,o=e.timestamp||Date.now();!n||n.role!==i||i.toLowerCase()===`user`&&n.senderLabel!==a?(n&&t.push(n),n={kind:`group`,key:`group:${i}:${r.key}`,role:i,senderLabel:a,messages:[{message:r.message,key:r.key}],timestamp:o,isStreaming:!1}):n.messages.push({message:r.message,key:r.key})}return n&&t.push(n),t}function Ip(e){let t=[],n=Array.isArray(e.messages)?e.messages:[],r=Array.isArray(e.toolMessages)?e.toolMessages:[],i=Math.max(0,n.length-Pp);i>0&&t.push({kind:`message`,key:`chat:history:notice`,message:{role:`system`,content:`Showing last ${Pp} messages (${i} hidden).`,timestamp:Date.now()}});for(let r=i;r<n.length;r++){let i=n[r],a=$u(i),o=i.__openclaw;if(o&&o.kind===`compaction`){t.push({kind:`divider`,key:typeof o.id==`string`?`divider:compaction:${o.id}`:`divider:compaction:${a.timestamp}:${r}`,label:`Compaction`,timestamp:a.timestamp??Date.now()});continue}!e.showToolCalls&&a.role.toLowerCase()===`toolresult`||X.searchOpen&&X.searchQuery.trim()&&!Uf(i,X.searchQuery)||t.push({kind:`message`,key:Lp(i,r),message:i})}let a=e.streamSegments??[],o=Math.max(a.length,r.length);for(let i=0;i<o;i++)i<a.length&&a[i].text.trim().length>0&&t.push({kind:`stream`,key:`stream-seg:${e.sessionKey}:${i}`,text:a[i].text,startedAt:a[i].ts}),i<r.length&&e.showToolCalls&&t.push({kind:`message`,key:Lp(r[i],i+n.length),message:r[i]});if(e.stream!==null){let n=`stream:${e.sessionKey}:${e.streamStartedAt??`live`}`;e.stream.trim().length>0?t.push({kind:`stream`,key:n,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:`reading-indicator`,key:n})}return Fp(t)}function Lp(e,t){let n=e,r=typeof n.toolCallId==`string`?n.toolCallId:``;if(r)return`tool:${r}`;let i=typeof n.id==`string`?n.id:``;if(i)return`msg:${i}`;let a=typeof n.messageId==`string`?n.messageId:``;if(a)return`msg:${a}`;let o=typeof n.timestamp==`number`?n.timestamp:null,s=typeof n.role==`string`?n.role:`unknown`;return o==null?`msg:${s}:${t}`:`msg:${s}:${o}:${t}`}function Rp(e,t){let n={...t,lastActiveSessionKey:t.lastActiveSessionKey?.trim()||t.sessionKey.trim()||`main`};e.settings=n,Za(n),(t.theme!==e.theme||t.themeMode!==e.themeMode)&&(e.theme=t.theme,e.themeMode=t.themeMode,Zp(e,Ma(t.theme,t.themeMode))),Xp(t.borderRadius),e.applySessionKey=e.settings.lastActiveSessionKey}function zp(e,t){let n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&Rp(e,{...e.settings,lastActiveSessionKey:n})}function Bp(e){if(!window.location.search&&!window.location.hash)return;let t=new URL(window.location.href),n=new URLSearchParams(t.search),r=new URLSearchParams(t.hash.startsWith(`#`)?t.hash.slice(1):t.hash),i=n.get(`gatewayUrl`)??r.get(`gatewayUrl`),a=i?.trim()??``,o=!!(a&&a!==e.settings.gatewayUrl),s=r.get(`token`)??n.get(`token`),c=n.get(`password`)??r.get(`password`),l=n.get(`session`)??r.get(`session`),u=!!(s?.trim()&&!l?.trim()&&!o),d=!1;if(n.has(`token`)&&(n.delete(`token`),d=!0),s!=null){let t=s.trim();t&&o?e.pendingGatewayToken=t:t&&t!==e.settings.token&&Rp(e,{...e.settings,token:t}),r.delete(`token`),d=!0}if(u&&(e.sessionKey=`main`,Rp(e,{...e.settings,sessionKey:`main`,lastActiveSessionKey:`main`})),c!=null&&(n.delete(`password`),r.delete(`password`),d=!0),l!=null){let t=l.trim();t&&(e.sessionKey=t,Rp(e,{...e.settings,sessionKey:t,lastActiveSessionKey:t}))}if(i!=null&&(o?(e.pendingGatewayUrl=a,s?.trim()||(e.pendingGatewayToken=null)):(e.pendingGatewayUrl=null,e.pendingGatewayToken=null),n.delete(`gatewayUrl`),r.delete(`gatewayUrl`),d=!0),!d)return;t.search=n.toString();let f=r.toString();t.hash=f?`#${f}`:``,window.history.replaceState({},``,t.toString())}function Vp(e,t){nm(e,t,{refreshPolicy:`always`,syncUrl:!0})}function Hp(e,t,n){eo({nextTheme:Ma(t,e.themeMode),applyTheme:()=>{Rp(e,{...e.settings,theme:t})},context:n,currentTheme:e.themeResolved}),Qp(e)}function Up(e,t,n){eo({nextTheme:Ma(e.theme,t),applyTheme:()=>{Rp(e,{...e.settings,themeMode:t})},context:n,currentTheme:e.themeResolved}),Qp(e)}async function Wp(e){if(e.tab===`overview`&&await am(e),e.tab===`channels`&&await um(e),e.tab===`instances`&&await Ii(e),e.tab===`usage`&&await fa(e),e.tab===`sessions`&&await Ri(e),e.tab===`cron`&&await dm(e),e.tab===`skills`&&await Ui(e),e.tab===`agents`){await Br(e),await Tn(e);let t=e.agentsList?.agents?.map(e=>e.id)??[];t.length>0&&Rr(e,t);let n=e.agentsSelectedId??e.agentsList?.defaultId??e.agentsList?.agents?.[0]?.id;n&&(Lr(e,n),e.agentsPanel===`skills`&&zr(e,n),e.agentsPanel===`channels`&&Zt(e,!1),e.agentsPanel===`cron`&&dm(e))}e.tab===`nodes`&&(await Ar(e),await wi(e),await Tn(e),await ji(e)),e.tab===`chat`&&(await rg(e),sr(e,!e.chatHasAutoScrolled)),(e.tab===`config`||e.tab===`communications`||e.tab===`appearance`||e.tab===`automation`||e.tab===`infrastructure`||e.tab===`aiAgents`)&&(await En(e),await Tn(e)),e.tab===`debug`&&(await Sr(e),e.eventLog=e.eventLogBuffer),e.tab===`logs`&&(e.logsAtBottom=!0,await kr(e,{reset:!0}),cr(e,!0))}function Gp(){if(typeof window>`u`)return``;let e=window.__OPENCLAW_CONTROL_UI_BASE_PATH__;return typeof e==`string`&&e.trim()?va(e):Sa(window.location.pathname)}function Kp(e){e.theme=e.settings.theme??`claw`,e.themeMode=e.settings.themeMode??`system`,Zp(e,Ma(e.theme,e.themeMode)),Xp(e.settings.borderRadius??50),Qp(e)}function qp(e){Qp(e)}function Jp(e){e.systemThemeCleanup?.(),e.systemThemeCleanup=null}var Yp={sm:6,md:10,lg:14,xl:20,full:9999,default:10};function Xp(e){if(typeof document>`u`)return;let t=document.documentElement,n=e/50;t.style.setProperty(`--radius-sm`,`${Math.round(Yp.sm*n)}px`),t.style.setProperty(`--radius-md`,`${Math.round(Yp.md*n)}px`),t.style.setProperty(`--radius-lg`,`${Math.round(Yp.lg*n)}px`),t.style.setProperty(`--radius-xl`,`${Math.round(Yp.xl*n)}px`),t.style.setProperty(`--radius-full`,`${Math.round(Yp.full*n)}px`),t.style.setProperty(`--radius`,`${Math.round(Yp.default*n)}px`)}function Zp(e,t){if(e.themeResolved=t,typeof document>`u`)return;let n=document.documentElement,r=t.endsWith(`light`)?`light`:`dark`;n.dataset.theme=t,n.dataset.themeMode=r,n.style.colorScheme=r}function Qp(e){if(e.themeMode!==`system`){e.systemThemeCleanup?.(),e.systemThemeCleanup=null;return}if(e.systemThemeCleanup||typeof globalThis.matchMedia!=`function`)return;let t=globalThis.matchMedia(`(prefers-color-scheme: light)`),n=()=>{e.themeMode===`system`&&Zp(e,Ma(e.theme,`system`))};if(typeof t.addEventListener==`function`){t.addEventListener(`change`,n),e.systemThemeCleanup=()=>t.removeEventListener(`change`,n);return}typeof t.addListener==`function`&&(t.addListener(n),e.systemThemeCleanup=()=>t.removeListener(n))}function $p(e,t){if(typeof window>`u`)return;let n=xa(window.location.pathname,e.basePath)??`chat`;tm(e,n),rm(e,n,t)}function em(e){if(typeof window>`u`)return;let t=xa(window.location.pathname,e.basePath);if(!t)return;let n=new URL(window.location.href).searchParams.get(`session`)?.trim();n&&(e.sessionKey=n,Rp(e,{...e.settings,sessionKey:n,lastActiveSessionKey:n})),tm(e,t)}function tm(e,t){nm(e,t,{refreshPolicy:`connected`})}function nm(e,t,n){let r=e.tab;e.tab!==t&&(e.tab=t),r===`chat`&&t!==`chat`&&sp(),t===`chat`&&(e.chatHasAutoScrolled=!1),t===`logs`?Nr(e):Pr(e),t===`debug`?Fr(e):Ir(e),(n.refreshPolicy===`always`||e.connected)&&Wp(e),n.syncUrl&&rm(e,t,!1)}function rm(e,t,n){if(typeof window>`u`)return;let r=ya(ba(t,e.basePath)),i=ya(window.location.pathname),a=new URL(window.location.href);t===`chat`&&e.sessionKey?a.searchParams.set(`session`,e.sessionKey):a.searchParams.delete(`session`),i!==r&&(a.pathname=r),n?window.history.replaceState({},``,a.toString()):window.history.pushState({},``,a.toString())}function im(e,t,n){if(typeof window>`u`)return;let r=new URL(window.location.href);r.searchParams.set(`session`,t),n?window.history.replaceState({},``,r.toString()):window.history.pushState({},``,r.toString())}async function am(e){let t=e;await Promise.allSettled([Zt(t,!1),Ii(t),Ri(t),Xr(t),Zr(t),Sr(t),Ui(t),fa(t),cm(t)]),lm(t)}function om(e){return e?.scopes?xr({role:e.role??`operator`,requestedScopes:[`operator.read`],allowedScopes:e.scopes}):!1}function sm(e){return e?Object.values(e).some(e=>Array.isArray(e)&&e.length>0):!1}async function cm(e){if(!(!e.client||!e.connected))try{let t=await e.client.request(`logs.tail`,{cursor:e.overviewLogCursor||void 0,limit:100,maxBytes:5e4}),n=Array.isArray(t.lines)?t.lines.filter(e=>typeof e==`string`):[];e.overviewLogLines=[...e.overviewLogLines,...n].slice(-500),typeof t.cursor==`number`&&(e.overviewLogCursor=t.cursor)}catch{}}function lm(e){let t=[];e.lastError&&t.push({severity:`error`,icon:`x`,title:`Gateway Error`,description:e.lastError});let n=e.hello?.auth??null;n?.scopes&&!om(n)&&t.push({severity:`warning`,icon:`key`,title:`Missing operator.read scope`,description:`This connection does not have the operator.read scope. Some features may be unavailable.`,href:`https://docs.openclaw.ai/web/dashboard`,external:!0});let r=e.skillsReport?.skills??[],i=r.filter(e=>!e.disabled&&sm(e.missing));if(i.length>0){let e=i.slice(0,3).map(e=>e.name),n=i.length>3?` +${i.length-3} more`:``;t.push({severity:`warning`,icon:`zap`,title:`Skills with missing dependencies`,description:`${e.join(`, `)}${n}`})}let a=r.filter(e=>e.blockedByAllowlist);a.length>0&&t.push({severity:`warning`,icon:`shield`,title:`${a.length} skill${a.length>1?`s`:``} blocked`,description:a.map(e=>e.name).join(`, `)});let o=e.cronJobs??[],s=o.filter(e=>e.state?.lastStatus===`error`);s.length>0&&t.push({severity:`error`,icon:`clock`,title:`${s.length} cron job${s.length>1?`s`:``} failed`,description:s.map(e=>e.name).join(`, `)});let c=Date.now(),l=o.filter(e=>e.enabled&&e.state?.nextRunAtMs!=null&&c-e.state.nextRunAtMs>3e5);l.length>0&&t.push({severity:`warning`,icon:`clock`,title:`${l.length} overdue job${l.length>1?`s`:``}`,description:l.map(e=>e.name).join(`, `)}),e.attentionItems=t}async function um(e){await Promise.all([Zt(e,!0),En(e),Tn(e)])}async function dm(e){let t=e,n=t.cronRunsScope===`job`?t.cronRunsJobId:null;await Promise.all([Zt(t,!1),Xr(t),Zr(t),_i(t,n)])}var fm=50,pm=80,mm=12e4;function hm(e){return typeof e==`string`&&e.trim()||null}function gm(e,t){let n=hm(t);if(!n)return null;let r=hm(e);if(r){let e=`${r}/`;if(n.toLowerCase().startsWith(e.toLowerCase())){let t=n.slice(e.length).trim();if(t)return`${r}/${t}`}return`${r}/${n}`}let i=n.indexOf(`/`);if(i>0){let e=n.slice(0,i).trim(),t=n.slice(i+1).trim();if(e&&t)return`${e}/${t}`}return n}function _m(e){return Array.isArray(e)?e.map(e=>hm(e)).filter(e=>!!e):[]}function vm(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n,r=hm(e.provider),i=hm(e.model);if(!r||!i)continue;let a=hm(e.reason)?.replace(/_/g,` `)??hm(e.code)??(typeof e.status==`number`?`HTTP ${e.status}`:null)??hm(e.error)??`error`;t.push({provider:r,model:i,reason:a})}return t}function ym(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.text==`string`)return t.text;let n=t.content;if(!Array.isArray(n))return null;let r=n.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;return t.type===`text`&&typeof t.text==`string`?t.text:null}).filter(e=>!!e);return r.length===0?null:r.join(`
`)}function bm(e){if(e==null)return null;if(typeof e==`number`||typeof e==`boolean`)return String(e);let t=ym(e),n;if(typeof e==`string`)n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}let r=u(n,mm);return r.truncated?`${r.text}\n\n… truncated (${r.total} chars, showing first ${r.text.length}).`:r.text}function xm(e){let t=[];return t.push({type:`toolcall`,name:e.name,arguments:e.args??{}}),e.output&&t.push({type:`toolresult`,name:e.name,text:e.output}),{role:`assistant`,toolCallId:e.toolCallId,runId:e.runId,content:t,timestamp:e.startedAt}}function Sm(e){if(e.toolStreamOrder.length<=fm)return;let t=e.toolStreamOrder.length-fm,n=e.toolStreamOrder.splice(0,t);for(let t of n)e.toolStreamById.delete(t)}function Cm(e){e.chatToolMessages=e.toolStreamOrder.map(t=>e.toolStreamById.get(t)?.message).filter(e=>!!e)}function wm(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),Cm(e)}function Tm(e,t=!1){if(t){wm(e);return}e.toolStreamSyncTimer??=window.setTimeout(()=>wm(e),pm)}function Em(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],e.chatStreamSegments=[]}var Dm=5e3,Om=8e3;function km(e,t){let n=t.data??{},r=typeof n.phase==`string`?n.phase:``;e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),r===`start`?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:r===`end`&&(e.compactionStatus={active:!1,startedAt:e.compactionStatus?.startedAt??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},Dm))}function Am(e,t,n){let r=typeof t.sessionKey==`string`?t.sessionKey:void 0;return r&&r!==e.sessionKey?{accepted:!1}:!e.chatRunId&&n?.allowSessionScopedWhenIdle&&r?{accepted:!0,sessionKey:r}:!r&&e.chatRunId&&t.runId!==e.chatRunId||e.chatRunId&&t.runId!==e.chatRunId||!e.chatRunId?{accepted:!1}:{accepted:!0,sessionKey:r}}function jm(e,t){let n=t.data??{},r=t.stream===`fallback`?`fallback`:hm(n.phase);if(t.stream===`lifecycle`&&r!==`fallback`&&r!==`fallback_cleared`||!Am(e,t,{allowSessionScopedWhenIdle:!0}).accepted)return;let i=gm(n.selectedProvider,n.selectedModel)??gm(n.fromProvider,n.fromModel),a=gm(n.activeProvider,n.activeModel)??gm(n.toProvider,n.toModel),o=gm(n.previousActiveProvider,n.previousActiveModel)??hm(n.previousActiveModel);if(!i||!a||r===`fallback`&&i===a)return;let s=hm(n.reasonSummary)??hm(n.reason),c=(()=>{let e=_m(n.attemptSummaries);return e.length>0?e:vm(n.attempts).map(e=>`${gm(e.provider,e.model)??`${e.provider}/${e.model}`}: ${e.reason}`)})();e.fallbackClearTimer!=null&&(window.clearTimeout(e.fallbackClearTimer),e.fallbackClearTimer=null),e.fallbackStatus={phase:r===`fallback_cleared`?`cleared`:`active`,selected:i,active:r===`fallback_cleared`?i:a,previous:r===`fallback_cleared`?o??(a===i?void 0:a):void 0,reason:s??void 0,attempts:c,occurredAt:Date.now()},e.fallbackClearTimer=window.setTimeout(()=>{e.fallbackStatus=null,e.fallbackClearTimer=null},Om)}function Mm(e,t){if(!t)return;if(t.stream===`compaction`){km(e,t);return}if(t.stream===`lifecycle`||t.stream===`fallback`){jm(e,t);return}if(t.stream!==`tool`)return;let n=typeof t.sessionKey==`string`?t.sessionKey:void 0;if(n&&n!==e.sessionKey)return;let r=t.data??{},i=typeof r.toolCallId==`string`?r.toolCallId:``;if(!i)return;let a=typeof r.name==`string`?r.name:`tool`,o=typeof r.phase==`string`?r.phase:``,s=o===`start`?r.args:void 0,c=o===`update`?bm(r.partialResult):o===`result`?bm(r.result):void 0,l=Date.now(),u=e.toolStreamById.get(i);u?(u.name=a,s!==void 0&&(u.args=s),c!==void 0&&(u.output=c||void 0),u.updatedAt=l):(e.chatStream&&e.chatStream.trim().length>0&&(e.chatStreamSegments=[...e.chatStreamSegments,{text:e.chatStream,ts:l}],e.chatStream=null,e.chatStreamStartedAt=null),u={toolCallId:i,runId:t.runId,sessionKey:n,name:a,args:s,output:c||void 0,startedAt:typeof t.ts==`number`?t.ts:l,updatedAt:l,message:{}},e.toolStreamById.set(i,u),e.toolStreamOrder.push(i)),u.message=xm(u),Sm(e),Tm(e,o===`result`)}var Nm=[`off`,`minimal`,`low`,`medium`,`high`,`adaptive`],Pm=/^claude-(?:opus|sonnet)-4(?:\.|-)6(?:$|[-.])/i,Fm=/claude-(?:opus|sonnet)-4(?:\.|-)6(?:$|[-.])/i;function Im(e){if(!e)return``;let t=e.trim().toLowerCase();return t===`z.ai`||t===`z-ai`?`zai`:t===`bedrock`||t===`aws-bedrock`?`amazon-bedrock`:t}function Lm(e){return Im(e)===`zai`}function Rm(e){if(!e)return;let t=e.trim().toLowerCase(),n=t.replace(/[\s_-]+/g,``);if(n===`adaptive`||n===`auto`)return`adaptive`;if(n===`xhigh`||n===`extrahigh`)return`xhigh`;if([`off`].includes(t))return`off`;if([`on`,`enable`,`enabled`].includes(t))return`low`;if([`min`,`minimal`].includes(t))return`minimal`;if([`low`,`thinkhard`,`think-hard`,`think_hard`].includes(t))return`low`;if([`mid`,`med`,`medium`,`thinkharder`,`think-harder`,`harder`].includes(t))return`medium`;if([`high`,`ultra`,`ultrathink`,`think-hard`,`thinkhardest`,`highest`,`max`].includes(t))return`high`;if([`think`].includes(t))return`minimal`}function zm(e,t){return[...Nm]}function Bm(e,t){return Lm(e)?[`off`,`on`]:zm(e,t)}function Vm(e,t,n=`, `){return Bm(e,t).join(n)}function Hm(e){let t=Im(e.provider),n=e.model.trim();return t===`anthropic`&&Pm.test(n)||t===`amazon-bedrock`&&Fm.test(n)?`adaptive`:e.catalog?.find(t=>t.provider===e.provider&&t.id===e.model)?.reasoning?`low`:`off`}function Um(e){if(!e)return;let t=e.toLowerCase();if([`off`,`false`,`no`,`0`].includes(t))return`off`;if([`full`,`all`,`everything`].includes(t))return`full`;if([`on`,`minimal`,`true`,`yes`,`1`].includes(t))return`on`}function Wm(e){return Um(e)}var Gm=`main`,Km=`main`,qm=/^[a-z0-9][a-z0-9_-]{0,63}$/i,Jm=/[^a-z0-9_-]+/g,Ym=/^-+/,Xm=/-+$/;function Zm(e){let t=(e??``).trim();return t?t.toLowerCase():Km}function Qm(e){let t=(e??``).trim();return t?qm.test(t)?t.toLowerCase():t.toLowerCase().replace(Jm,`-`).replace(Ym,``).replace(Xm,``).slice(0,64)||`main`:Gm}function $m(e){return`agent:${Qm(e.agentId)}:${Zm(e.mainKey)}`}function eh(e,t){let n=e.trim();if(!n)return``;let r=t?.trim();return r?`${r}/${n}`:n}function th(e){let t=e.trim();return t?t.includes(`/`)?{kind:`qualified`,value:t}:{kind:`raw`,value:t}:null}function nh(e,t){if(!e)return``;let n=e?.value.trim();if(!n)return``;if(e.kind===`qualified`)return n;let r=``;for(let e of t){if(e.id.trim().toLowerCase()!==n.toLowerCase())continue;let t=eh(e.id,e.provider);if(!r){r=t;continue}if(r.toLowerCase()!==t.toLowerCase())return n}return r||n}function rh(e,t){return typeof e==`string`?eh(e,t):``}function ih(e){let t=e.trim();if(!t)return``;let n=t.indexOf(`/`);return n<=0?t:`${t.slice(n+1)} · ${t.slice(0,n)}`}function ah(e){let t=e.provider?.trim();return{value:eh(e.id,t),label:t?`${e.id} · ${t}`:e.id}}async function oh(e,t,n,r){switch(n){case`help`:return sh();case`new`:return{content:`Starting new session...`,action:`new-session`};case`reset`:return{content:`Resetting session...`,action:`reset`};case`stop`:return{content:`Stopping current run...`,action:`stop`};case`clear`:return{content:`Chat history cleared.`,action:`clear`};case`focus`:return{content:`Toggled focus mode.`,action:`toggle-focus`};case`compact`:return await ch(e,t);case`model`:return await lh(e,t,r);case`think`:return await uh(e,t,r);case`fast`:return await fh(e,t,r);case`verbose`:return await dh(e,t,r);case`export`:return{content:`Exporting session...`,action:`export`};case`usage`:return await ph(e,t);case`agents`:return await mh(e);case`kill`:return await hh(e,t,r);default:return{content:`Unknown command: \`/${n}\``}}}function sh(){let e=[`**Available Commands**
`],t=``;for(let n of Gf){let r=n.category??`session`;r!==t&&(t=r,e.push(`**${r.charAt(0).toUpperCase()+r.slice(1)}**`));let i=n.args?` ${n.args}`:``,a=n.executeLocal?``:` *(agent)*`;e.push(`\`/${n.name}${i}\` — ${n.description}${a}`)}return e.push("\nType `/` to open the command menu."),{content:e.join(`
`)}}async function ch(e,t){try{return await e.request(`sessions.compact`,{key:t}),{content:`Context compacted successfully.`,action:`refresh`}}catch(e){return{content:`Compaction failed: ${String(e)}`}}}async function lh(e,t,n){if(!n)try{let[n,r]=await Promise.all([e.request(`sessions.list`,{}),e.request(`models.list`,{})]),i=Ch(n,t)?.model||n?.defaults?.model||`default`,a=r?.models?.map(e=>e.id)??[],o=[`**Current model:** \`${i}\``];return a.length>0&&o.push(`**Available:** ${a.slice(0,10).map(e=>`\`${e}\``).join(`, `)}${a.length>10?` +${a.length-10} more`:``}`),{content:o.join(`
`)}}catch(e){return{content:`Failed to get model info: ${String(e)}`}}try{let r=await e.request(`sessions.patch`,{key:t,model:n.trim()}),i=rh(r.resolved?.model??n.trim(),r.resolved?.modelProvider);return{content:`Model set to \`${n.trim()}\`.`,action:`refresh`,sessionPatch:{modelOverride:th(i)}}}catch(e){return{content:`Failed to set model: ${String(e)}`}}}async function uh(e,t,n){let r=n.trim();if(!r)try{let{session:n,models:r}=await wh(e,t);return{content:xh(`Current thinking level: ${Th(n,r)}.`,Vm(n?.modelProvider,n?.model))}}catch(e){return{content:`Failed to get thinking level: ${String(e)}`}}let i=Rm(r);if(!i)try{let n=await Sh(e,t);return{content:`Unrecognized thinking level "${r}". Valid levels: ${Vm(n?.modelProvider,n?.model)}.`}}catch(e){return{content:`Failed to validate thinking level: ${String(e)}`}}try{return await e.request(`sessions.patch`,{key:t,thinkingLevel:i}),{content:`Thinking level set to **${i}**.`,action:`refresh`}}catch(e){return{content:`Failed to set thinking level: ${String(e)}`}}}async function dh(e,t,n){let r=n.trim();if(!r)try{return{content:xh(`Current verbose level: ${Wm((await Sh(e,t))?.verboseLevel)??`off`}.`,`on, full, off`)}}catch(e){return{content:`Failed to get verbose level: ${String(e)}`}}let i=Wm(r);if(!i)return{content:`Unrecognized verbose level "${r}". Valid levels: off, on, full.`};try{return await e.request(`sessions.patch`,{key:t,verboseLevel:i}),{content:`Verbose mode set to **${i}**.`,action:`refresh`}}catch(e){return{content:`Failed to set verbose mode: ${String(e)}`}}}async function fh(e,t,n){let r=n.trim().toLowerCase();if(!r||r===`status`)try{return{content:xh(`Current fast mode: ${Eh(await Sh(e,t))}.`,`status, on, off`)}}catch(e){return{content:`Failed to get fast mode: ${String(e)}`}}if(r!==`on`&&r!==`off`)return{content:`Unrecognized fast mode "${n.trim()}". Valid levels: status, on, off.`};try{return await e.request(`sessions.patch`,{key:t,fastMode:r===`on`}),{content:`Fast mode ${r===`on`?`enabled`:`disabled`}.`,action:`refresh`}}catch(e){return{content:`Failed to set fast mode: ${String(e)}`}}}async function ph(e,t){try{let n=Ch(await e.request(`sessions.list`,{}),t);if(!n)return{content:`No active session.`};let r=n.inputTokens??0,i=n.outputTokens??0,a=n.totalTokens??r+i,o=n.contextTokens??0,s=o>0?Math.round(r/o*100):null,c=[`**Session Usage**`,`Input: **${Dh(r)}** tokens`,`Output: **${Dh(i)}** tokens`,`Total: **${Dh(a)}** tokens`];return s!==null&&c.push(`Context: **${s}%** of ${Dh(o)}`),n.model&&c.push(`Model: \`${n.model}\``),{content:c.join(`
`)}}catch(e){return{content:`Failed to get usage: ${String(e)}`}}}async function mh(e){try{let t=await e.request(`agents.list`,{}),n=t?.agents??[];if(n.length===0)return{content:`No agents configured.`};let r=[`**Agents** (${n.length})\n`];for(let e of n){let n=e.id===t?.defaultId,i=e.identity?.name||e.name||e.id,a=n?` *(default)*`:``;r.push(`- \`${e.id}\` — ${i}${a}`)}return{content:r.join(`
`)}}catch(e){return{content:`Failed to list agents: ${String(e)}`}}}async function hh(e,t,n){let r=n.trim();if(!r)return{content:"Usage: `/kill <id|all>`"};try{let n=gh((await e.request(`sessions.list`,{}))?.sessions??[],t,r);if(n.length===0)return{content:r.toLowerCase()===`all`?`No active sub-agent sessions found.`:`No matching sub-agent sessions found for \`${r}\`.`};let i=await Promise.allSettled(n.map(t=>e.request(`chat.abort`,{sessionKey:t}))),a=i.filter(e=>e.status===`rejected`),o=i.filter(e=>e.status===`fulfilled`&&e.value?.aborted!==!1).length;if(o===0){if(a.length===0)return{content:r.toLowerCase()===`all`?`No active sub-agent runs to abort.`:`No active runs matched \`${r}\`.`};throw a[0]?.reason??Error(`abort failed`)}return r.toLowerCase()===`all`?{content:o===n.length?`Aborted ${o} sub-agent session${o===1?``:`s`}.`:`Aborted ${o} of ${n.length} sub-agent sessions.`}:{content:o===n.length?`Aborted ${o} matching sub-agent session${o===1?``:`s`} for \`${r}\`.`:`Aborted ${o} of ${n.length} matching sub-agent sessions for \`${r}\`.`}}catch(e){return{content:`Failed to abort: ${String(e)}`}}}function gh(e,t,n){let r=n.trim().toLowerCase();if(!r)return[];let i=new Set,a=t.trim().toLowerCase(),o=rr(a)?.agentId??(a===`main`?`main`:void 0),s=vh(e);for(let t of e){let e=t?.key?.trim();if(!e||!ir(e))continue;let n=e.toLowerCase(),c=rr(n),l=_h(n,a,s,o,c?.agentId);(r===`all`&&l||l&&n===r||l&&((c?.agentId??``)===r||n.endsWith(`:subagent:${r}`)||n===`subagent:${r}`))&&i.add(e)}return[...i]}function _h(e,t,n,r,i){if(!r||i!==r)return!1;let a=bh(t,r),o=new Set,s=yh(n.get(e)?.spawnedBy);for(;s&&!o.has(s);){if(a.has(s))return!0;o.add(s),s=yh(n.get(s)?.spawnedBy)}return ir(t)?e.startsWith(`${t}:subagent:`):!1}function vh(e){let t=new Map;for(let n of e){let e=yh(n?.key);e&&t.set(e,n)}return t}function yh(e){return e?.trim().toLowerCase()||void 0}function bh(e,t){let n=new Set([e]);if(t===`main`){let t=`agent:${Gm}:main`;e===`main`?n.add(t):e===t&&n.add(Km)}return n}function xh(e,t){return`${e}\nOptions: ${t}.`}async function Sh(e,t){return Ch(await e.request(`sessions.list`,{}),t)}function Ch(e,t){let n=yh(t),r=rr(n??``)?.agentId??(n===`main`?`main`:void 0),i=n?bh(n,r):new Set;return e?.sessions?.find(e=>{let t=yh(e.key);return t?i.has(t):!1})}async function wh(e,t){let[n,r]=await Promise.all([e.request(`sessions.list`,{}),e.request(`models.list`,{})]);return{session:Ch(n,t),models:r?.models??[]}}function Th(e,t){return Rm(e?.thinkingLevel)||(!e?.modelProvider||!e.model?`off`:Hm({provider:e.modelProvider,model:e.model,catalog:t}))}function Eh(e){return e?.fastMode===!0?`on`:`off`}function Dh(e){return e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`:String(e)}function Oh(e){return typeof e==`string`?e:e instanceof Error&&typeof e.message==`string`?e.message:`unknown error`}function kh(e){let t=Oh(e.message);switch(zt(e)){case I.AUTH_TOKEN_MISMATCH:return`gateway token mismatch`;case I.AUTH_UNAUTHORIZED:return`gateway auth failed`;case I.AUTH_RATE_LIMITED:return`too many failed authentication attempts`;case I.PAIRING_REQUIRED:return`gateway pairing required`;case I.CONTROL_UI_DEVICE_IDENTITY_REQUIRED:return`device identity required (use HTTPS/localhost or allow insecure auth explicitly)`;case I.CONTROL_UI_ORIGIN_NOT_ALLOWED:return`origin not allowed (open the Control UI from the gateway host or allow it in gateway.controlUi.allowedOrigins)`;case I.AUTH_TOKEN_MISSING:return`gateway token missing`;default:break}let n=t.trim().toLowerCase();return n===`fetch failed`||n===`failed to fetch`||n===`connect failed`?`gateway connect failed`:t}function Ah(e){return e&&typeof e==`object`?kh(e):Oh(e)}var jh=/^\s*NO_REPLY\s*$/;function Mh(e){return jh.test(e)}function Nh(e){if(!e||typeof e!=`object`)return!1;let t=e;if((typeof t.role==`string`?t.role.toLowerCase():``)!==`assistant`)return!1;if(typeof t.text==`string`)return Mh(t.text);let n=Wo(e);return typeof n==`string`&&Mh(n)}function Ph(e){let t=e;t.toolStreamById instanceof Map&&Array.isArray(t.toolStreamOrder)&&Array.isArray(t.chatToolMessages)&&Array.isArray(t.chatStreamSegments)&&Em(t)}async function Fh(e){if(!(!e.client||!e.connected)){e.chatLoading=!0,e.lastError=null;try{let t=await e.client.request(`chat.history`,{sessionKey:e.sessionKey,limit:200});e.chatMessages=(Array.isArray(t.messages)?t.messages:[]).filter(e=>!Nh(e)),e.chatThinkingLevel=t.thinkingLevel??null,Ph(e),e.chatStream=null,e.chatStreamStartedAt=null}catch(t){Yt(t)?(e.chatMessages=[],e.chatThinkingLevel=null,e.lastError=Xt(`existing chat history`)):e.lastError=String(t)}finally{e.chatLoading=!1}}}function Ih(e){let t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}function Lh(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=n.role;if(typeof r==`string`){if((t.roleCaseSensitive?r:r.toLowerCase())!==`assistant`)return null}else if(t.roleRequirement===`required`)return null;return t.requireContentArray?Array.isArray(n.content)?n:null:!(`content`in n)&&!(t.allowTextField&&`text`in n)?null:n}function Rh(e){return Lh(e,{roleRequirement:`required`,roleCaseSensitive:!0,requireContentArray:!0})}function zh(e){return Lh(e,{roleRequirement:`optional`,allowTextField:!0})}async function Bh(e,t,n){if(!e.client||!e.connected)return null;let r=t.trim(),i=n&&n.length>0;if(!r&&!i)return null;let a=Date.now(),o=[];if(r&&o.push({type:`text`,text:r}),i)for(let e of n)o.push({type:`image`,source:{type:`base64`,media_type:e.mimeType,data:e.dataUrl}});e.chatMessages=[...e.chatMessages,{role:`user`,content:o,timestamp:a}],e.chatSending=!0,e.lastError=null;let s=Lt();e.chatRunId=s,e.chatStream=``,e.chatStreamStartedAt=a;let c=i?n.map(e=>{let t=Ih(e.dataUrl);return t?{type:`image`,mimeType:t.mimeType,content:t.content}:null}).filter(e=>e!==null):void 0;try{return await e.client.request(`chat.send`,{sessionKey:e.sessionKey,message:r,deliver:!1,idempotencyKey:s,attachments:c}),s}catch(t){let n=Ah(t);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=n,e.chatMessages=[...e.chatMessages,{role:`assistant`,content:[{type:`text`,text:`Error: `+n}],timestamp:Date.now()}],null}finally{e.chatSending=!1}}async function Vh(e){if(!e.client||!e.connected)return!1;let t=e.chatRunId;try{return await e.client.request(`chat.abort`,t?{sessionKey:e.sessionKey,runId:t}:{sessionKey:e.sessionKey}),!0}catch(t){return e.lastError=Ah(t),!1}}function Hh(e,t){if(!t||t.sessionKey!==e.sessionKey)return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId){if(t.state===`final`){let n=zh(t.message);return n&&!Nh(n)?(e.chatMessages=[...e.chatMessages,n],null):`final`}return null}if(t.state===`delta`){let n=Wo(t.message);if(typeof n==`string`&&!Mh(n)){let t=e.chatStream??``;(!t||n.length>=t.length)&&(e.chatStream=n)}}else if(t.state===`final`){let n=zh(t.message);n&&!Nh(n)?e.chatMessages=[...e.chatMessages,n]:e.chatStream?.trim()&&!Mh(e.chatStream)&&(e.chatMessages=[...e.chatMessages,{role:`assistant`,content:[{type:`text`,text:e.chatStream}],timestamp:Date.now()}]),e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null}else if(t.state===`aborted`){let n=Rh(t.message);if(n&&!Nh(n))e.chatMessages=[...e.chatMessages,n];else{let t=e.chatStream??``;t.trim()&&!Mh(t)&&(e.chatMessages=[...e.chatMessages,{role:`assistant`,content:[{type:`text`,text:t}],timestamp:Date.now()}])}e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null}else t.state===`error`&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.lastError=t.errorMessage??`chat error`);return t.state}async function Uh(e){try{return(await e.request(`models.list`,{}))?.models??[]}catch{return[]}}function Wh(e){return e.chatSending||!!e.chatRunId}function Gh(e){let t=e.trim();if(!t)return!1;let n=t.toLowerCase();return n===`/stop`?!0:n===`stop`||n===`esc`||n===`abort`||n===`wait`||n===`exit`}function Kh(e){let t=e.trim();if(!t)return!1;let n=t.toLowerCase();return n===`/new`||n===`/reset`?!0:n.startsWith(`/new `)||n.startsWith(`/reset `)}async function qh(e){e.connected&&(e.chatMessage=``,await Vh(e))}function Jh(e,t,n,r,i){let a=t.trim(),o=!!(n&&n.length>0);!a&&!o||(e.chatQueue=[...e.chatQueue,{id:Lt(),text:a,createdAt:Date.now(),attachments:o?n?.map(e=>({...e})):void 0,refreshSessions:r,localCommandArgs:i?.args,localCommandName:i?.name}])}async function Yh(e,t,n){Em(e),dr(e);let r=await Bh(e,t,n?.attachments),i=!!r;return!i&&n?.previousDraft!=null&&(e.chatMessage=n.previousDraft),!i&&n?.previousAttachments&&(e.chatAttachments=n.previousAttachments),i&&zp(e,e.sessionKey),i&&n?.restoreDraft&&n.previousDraft?.trim()&&(e.chatMessage=n.previousDraft),i&&n?.restoreAttachments&&n.previousAttachments?.length&&(e.chatAttachments=n.previousAttachments),sr(e,!0),i&&!e.chatRunId&&Xh(e),i&&n?.refreshSessions&&r&&e.refreshSessionsAfterChat.add(r),i}async function Xh(e){if(!e.connected||Wh(e))return;let[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n;let r=!1;try{t.localCommandName?(await eg(e,t.localCommandName,t.localCommandArgs??``),r=!0):r=await Yh(e,t.text,{attachments:t.attachments,refreshSessions:t.refreshSessions})}catch(t){e.lastError=String(t)}r?e.chatQueue.length>0&&Xh(e):e.chatQueue=[t,...e.chatQueue]}function Zh(e,t){e.chatQueue=e.chatQueue.filter(e=>e.id!==t)}async function Qh(e,t,n){if(!e.connected)return;let r=e.chatMessage,i=(t??e.chatMessage).trim(),a=e.chatAttachments??[],o=t==null?a:[],s=o.length>0;if(!i&&!s)return;if(Gh(i)){await qh(e);return}let c=Yf(i);if(c?.command.executeLocal){if(Wh(e)&&$h(c.command.name)){t??(e.chatMessage=``,e.chatAttachments=[]),Jh(e,i,void 0,Kh(i),{args:c.args,name:c.command.name});return}let a=t==null?r:void 0;t??(e.chatMessage=``,e.chatAttachments=[]),await eg(e,c.command.name,c.args,{previousDraft:a,restoreDraft:!!(t&&n?.restoreDraft)});return}let l=Kh(i);if(t??(e.chatMessage=``,e.chatAttachments=[]),Wh(e)){Jh(e,i,o,l);return}await Yh(e,i,{previousDraft:t==null?r:void 0,restoreDraft:!!(t&&n?.restoreDraft),attachments:s?o:void 0,previousAttachments:t==null?a:void 0,restoreAttachments:!!(t&&n?.restoreDraft),refreshSessions:l})}function $h(e){return![`stop`,`focus`,`export`].includes(e)}async function eg(e,t,n,r){switch(t){case`stop`:await qh(e);return;case`new`:await Yh(e,`/new`,{refreshSessions:!0,previousDraft:r?.previousDraft,restoreDraft:r?.restoreDraft});return;case`reset`:await Yh(e,`/reset`,{refreshSessions:!0,previousDraft:r?.previousDraft,restoreDraft:r?.restoreDraft});return;case`clear`:await tg(e);return;case`focus`:e.onSlashAction?.(`toggle-focus`);return;case`export`:e.onSlashAction?.(`export`);return}if(!e.client)return;let i=e.sessionKey,a=await oh(e.client,i,t,n);a.content&&ng(e,a.content),a.sessionPatch&&`modelOverride`in a.sessionPatch&&(e.chatModelOverrides={...e.chatModelOverrides,[i]:a.sessionPatch.modelOverride??null}),a.action===`refresh`&&await rg(e),sr(e)}async function tg(e){if(!(!e.client||!e.connected)){try{await e.client.request(`sessions.reset`,{key:e.sessionKey}),e.chatMessages=[],e.chatStream=null,e.chatRunId=null,await Fh(e)}catch(t){e.lastError=String(t)}sr(e)}}function ng(e,t){e.chatMessages=[...e.chatMessages,{role:`system`,content:t,timestamp:Date.now()}]}async function rg(e,t){await Promise.all([Fh(e),Ri(e,{activeMinutes:0,limit:0,includeGlobal:!0,includeUnknown:!0}),cg(e),ig(e)]),t?.scheduleScroll!==!1&&sr(e)}async function ig(e){if(!e.client||!e.connected){e.chatModelsLoading=!1,e.chatModelCatalog=[];return}e.chatModelsLoading=!0;try{e.chatModelCatalog=await Uh(e.client)}finally{e.chatModelsLoading=!1}}var ag=Xh;function og(e){let t=rr(e.sessionKey);return t?.agentId?t.agentId:(e.hello?.snapshot)?.sessionDefaults?.defaultAgentId?.trim()||`main`}function sg(e,t){let n=va(e),r=encodeURIComponent(t);return n?`${n}/avatar/${r}?meta=1`:`avatar/${r}?meta=1`}async function cg(e){if(!e.connected){e.chatAvatarUrl=null;return}let t=og(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;let n=sg(e.basePath,t);try{let t=await fetch(n,{method:`GET`});if(!t.ok){e.chatAvatarUrl=null;return}let r=await t.json();e.chatAvatarUrl=(typeof r.avatarUrl==`string`?r.avatarUrl.trim():``)||null}catch{e.chatAvatarUrl=null}}function lg(e){if(!e||e.state!==`final`)return!1;if(!e.message||typeof e.message!=`object`)return!0;let t=e.message,n=typeof t.role==`string`?t.role.toLowerCase():``;return!!(n&&n!==`assistant`)}function ug(e,t){if(typeof e!=`string`)return;let n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}var dg=50,fg=200;function pg(e){let t=ug(e?.name,dg)??`Assistant`,n=ug(e?.avatar??void 0,fg)??null;return{agentId:typeof e?.agentId==`string`&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}async function mg(e,t){if(!e.client||!e.connected)return;let n=t?.sessionKey?.trim()||e.sessionKey.trim(),r=n?{sessionKey:n}:{};try{let t=await e.client.request(`agent.identity.get`,r);if(!t)return;let n=pg(t);e.assistantName=n.name,e.assistantAvatar=n.avatar,e.assistantAgentId=n.agentId??null}catch{}}function hg(e){return typeof e==`object`&&!!e}function gg(e){if(!hg(e))return null;let t=typeof e.id==`string`?e.id.trim():``,n=e.request;if(!t||!hg(n))return null;let r=typeof n.command==`string`?n.command.trim():``;if(!r)return null;let i=typeof e.createdAtMs==`number`?e.createdAtMs:0,a=typeof e.expiresAtMs==`number`?e.expiresAtMs:0;return!i||!a?null:{id:t,request:{command:r,cwd:typeof n.cwd==`string`?n.cwd:null,host:typeof n.host==`string`?n.host:null,security:typeof n.security==`string`?n.security:null,ask:typeof n.ask==`string`?n.ask:null,agentId:typeof n.agentId==`string`?n.agentId:null,resolvedPath:typeof n.resolvedPath==`string`?n.resolvedPath:null,sessionKey:typeof n.sessionKey==`string`?n.sessionKey:null},createdAtMs:i,expiresAtMs:a}}function _g(e){if(!hg(e))return null;let t=typeof e.id==`string`?e.id.trim():``;return t?{id:t,decision:typeof e.decision==`string`?e.decision:null,resolvedBy:typeof e.resolvedBy==`string`?e.resolvedBy:null,ts:typeof e.ts==`number`?e.ts:null}:null}function vg(e){let t=Date.now();return e.filter(e=>e.expiresAtMs>t)}function yg(e,t){let n=vg(e).filter(e=>e.id!==t.id);return n.push(t),n}function bg(e,t){return vg(e).filter(e=>e.id!==t)}var xg={ok:!1,ts:0,durationMs:0,heartbeatSeconds:0,defaultAgentId:``,agents:[],sessions:{path:``,count:0,recent:[]}};async function Sg(e){try{return await e.request(`health`,{})??xg}catch{return xg}}async function Cg(e){if(!(!e.client||!e.connected)&&!e.healthLoading){e.healthLoading=!0,e.healthError=null;try{e.healthResult=await Sg(e.client)}catch(t){e.healthError=String(t)}finally{e.healthLoading=!1}}}function wg(e){return/^(?:typeerror:\s*)?(?:fetch failed|failed to fetch)$/i.test(e.trim())}function Tg(e){let t=e.serverVersion?.trim();if(!t)return;let n=e.pageUrl??(typeof window>`u`?void 0:window.location.href);if(n)try{let r=new URL(n),i=new URL(e.gatewayUrl,r);return!new Set([`ws:`,`wss:`,`http:`,`https:`]).has(i.protocol)||i.host!==r.host?void 0:t}catch{return}}function Eg(e,t){let n=(e??``).trim(),r=t.mainSessionKey?.trim();if(!r)return n;if(!n)return r;let i=t.mainKey?.trim()||`main`,a=t.defaultAgentId?.trim();return n===`main`||n===i||a&&(n===`agent:${a}:main`||n===`agent:${a}:${i}`)?r:n}function Dg(e,t){if(!t?.mainSessionKey)return;let n=Eg(e.sessionKey,t),r=Eg(e.settings.sessionKey,t),i=Eg(e.settings.lastActiveSessionKey,t),a=n||r||e.sessionKey,o={...e.settings,sessionKey:r||a,lastActiveSessionKey:i||a},s=o.sessionKey!==e.settings.sessionKey||o.lastActiveSessionKey!==e.settings.lastActiveSessionKey;a!==e.sessionKey&&(e.sessionKey=a),s&&Rp(e,o)}function Og(e){let t=e;t.pendingShutdownMessage=null,e.lastError=null,e.lastErrorCode=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;let n=e.client,r=Tg({gatewayUrl:e.settings.gatewayUrl,serverVersion:e.serverVersion}),i=new Jt({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:`openclaw-control-ui`,clientVersion:r,mode:`webchat`,instanceId:e.clientInstanceId,onHello:n=>{e.client===i&&(t.pendingShutdownMessage=null,e.connected=!0,e.lastError=null,e.lastErrorCode=null,e.hello=n,Ng(e,n),e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,Em(e),Li(e),mg(e),Br(e),Cg(e),Ar(e,{quiet:!0}),wi(e,{quiet:!0}),Wp(e))},onClose:({code:n,reason:r,error:a})=>{if(e.client===i)if(e.connected=!1,e.lastErrorCode=zt(a)??(typeof a?.code==`string`?a.code:null),n!==1012){if(a?.message){e.lastError=e.lastErrorCode&&wg(a.message)?Ah({message:a.message,details:a.details,code:a.code}):a.message;return}e.lastError=t.pendingShutdownMessage??`disconnected (${n}): ${r||`no reason`}`}else e.lastError=t.pendingShutdownMessage??null,e.lastErrorCode=null},onEvent:t=>{e.client===i&&kg(e,t)},onGap:({expected:t,received:n})=>{e.client===i&&(e.lastError=`event gap detected (expected seq ${t}, got ${n}); refresh recommended`,e.lastErrorCode=null)}});e.client=i,n?.stop(),i.start()}function kg(e,t){try{Mg(e,t)}catch(e){console.error(`[gateway] handleGatewayEvent error:`,t.event,e)}}function Ag(e,t,n){if(n!==`final`&&n!==`error`&&n!==`aborted`)return!1;let r=e,i=r.toolStreamOrder.length>0;Em(r),ag(e);let a=t?.runId;return a&&e.refreshSessionsAfterChat.has(a)&&(e.refreshSessionsAfterChat.delete(a),n===`final`&&Ri(e,{activeMinutes:120})),i&&n===`final`?(Fh(e),!0):!1}function jg(e,t){t?.sessionKey&&zp(e,t.sessionKey);let n=Hh(e,t),r=Ag(e,t,n);n===`final`&&!r&&lg(t)&&Fh(e)}function Mg(e,t){if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),(e.tab===`debug`||e.tab===`overview`)&&(e.eventLog=e.eventLogBuffer),t.event===`agent`){if(e.onboarding)return;Mm(e,t.payload);return}if(t.event===`chat`){jg(e,t.payload);return}if(t.event===`presence`){let n=t.payload;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event===`shutdown`){let n=t.payload,r=n&&typeof n.reason==`string`&&n.reason.trim()?n.reason.trim():`gateway stopping`,i=typeof n?.restartExpectedMs==`number`?`Restarting: ${r}`:`Disconnected: ${r}`;e.pendingShutdownMessage=i,e.lastError=i,e.lastErrorCode=null;return}if(t.event===`sessions.changed`){Ri(e);return}if(t.event===`cron`&&e.tab===`cron`&&dm(e),(t.event===`device.pair.requested`||t.event===`device.pair.resolved`)&&wi(e,{quiet:!0}),t.event===`exec.approval.requested`){let n=gg(t.payload);if(n){e.execApprovalQueue=yg(e.execApprovalQueue,n),e.execApprovalError=null;let t=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=bg(e.execApprovalQueue,n.id)},t)}return}if(t.event===`exec.approval.resolved`){let n=_g(t.payload);n&&(e.execApprovalQueue=bg(e.execApprovalQueue,n.id));return}t.event===`update.available`&&(e.updateAvailable=t.payload?.updateAvailable??null)}function Ng(e,t){let n=t.snapshot;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n?.health&&(e.debugHealth=n.health,e.healthResult=n.health),n?.sessionDefaults&&Dg(e,n.sessionDefaults),e.updateAvailable=n?.updateAvailable??null}var Pg=`/__openclaw/control-ui-config.json`;async function Fg(e){if(typeof window>`u`||typeof fetch!=`function`)return;let t=va(e.basePath??``),n=t?`${t}${Pg}`:Pg;try{let t=await fetch(n,{method:`GET`,headers:{Accept:`application/json`},credentials:`same-origin`});if(!t.ok)return;let r=await t.json(),i=pg({agentId:r.assistantAgentId??null,name:r.assistantName,avatar:r.assistantAvatar??null});e.assistantName=i.name,e.assistantAvatar=i.avatar,e.assistantAgentId=i.agentId??null,e.serverVersion=r.serverVersion??null}catch{}}function Ig(e){let t=++e.connectGeneration;e.basePath=Gp(),Bp(e);let n=Fg(e);$p(e,!0),Kp(e),qp(e),window.addEventListener(`popstate`,e.popStateHandler),n.finally(()=>{e.connectGeneration===t&&Og(e)}),jr(e),e.tab===`logs`&&Nr(e),e.tab===`debug`&&Fr(e)}function Lg(e){pr(e)}function Rg(e){e.connectGeneration+=1,window.removeEventListener(`popstate`,e.popStateHandler),Mr(e),Pr(e),Ir(e),e.client?.stop(),e.client=null,e.connected=!1,Jp(e),e.topbarObserver?.disconnect(),e.topbarObserver=null}function zg(e,t){if(!(e.tab===`chat`&&e.chatManualRefreshInFlight)){if(e.tab===`chat`&&(t.has(`chatMessages`)||t.has(`chatToolMessages`)||t.has(`chatStream`)||t.has(`chatLoading`)||t.has(`tab`))){let n=t.has(`tab`),r=t.has(`chatLoading`)&&t.get(`chatLoading`)===!0&&!e.chatLoading,i=t.get(`chatStream`),a=t.has(`chatStream`)&&i==null&&typeof e.chatStream==`string`;sr(e,n||r||a||!e.chatHasAutoScrolled)}e.tab===`logs`&&(t.has(`logsEntries`)||t.has(`logsAutoFollow`)||t.has(`tab`))&&e.logsAutoFollow&&e.logsAtBottom&&cr(e,t.has(`tab`)||t.has(`logsAutoFollow`))}}var Bg=new Set([`agent`,`channel`,`chat`,`provider`,`model`,`tool`,`label`,`key`,`session`,`id`,`has`,`mintokens`,`maxtokens`,`mincost`,`maxcost`,`minmessages`,`maxmessages`]),Vg=e=>e.trim().toLowerCase(),Hg=e=>{let t=e.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`.*`).replace(/\?/g,`.`);return RegExp(`^${t}$`,`i`)},Ug=e=>{let t=e.trim().toLowerCase();if(!t)return null;t.startsWith(`$`)&&(t=t.slice(1));let n=1;t.endsWith(`k`)?(n=1e3,t=t.slice(0,-1)):t.endsWith(`m`)&&(n=1e6,t=t.slice(0,-1));let r=Number(t);return Number.isFinite(r)?r*n:null},Wg=e=>(e.match(/"[^"]+"|\S+/g)??[]).map(e=>{let t=e.replace(/^"|"$/g,``),n=t.indexOf(`:`);return n>0?{key:t.slice(0,n),value:t.slice(n+1),raw:t}:{value:t,raw:t}}),Gg=e=>[e.label,e.key,e.sessionId].filter(e=>!!e).map(e=>e.toLowerCase()),Kg=e=>{let t=new Set;e.modelProvider&&t.add(e.modelProvider.toLowerCase()),e.providerOverride&&t.add(e.providerOverride.toLowerCase()),e.origin?.provider&&t.add(e.origin.provider.toLowerCase());for(let n of e.usage?.modelUsage??[])n.provider&&t.add(n.provider.toLowerCase());return Array.from(t)},qg=e=>{let t=new Set;e.model&&t.add(e.model.toLowerCase());for(let n of e.usage?.modelUsage??[])n.model&&t.add(n.model.toLowerCase());return Array.from(t)},Jg=e=>(e.usage?.toolUsage?.tools??[]).map(e=>e.name.toLowerCase()),Yg=(e,t)=>{let n=Vg(t.value??``);if(!n)return!0;if(!t.key)return Gg(e).some(e=>e.includes(n));switch(Vg(t.key)){case`agent`:return e.agentId?.toLowerCase().includes(n)??!1;case`channel`:return e.channel?.toLowerCase().includes(n)??!1;case`chat`:return e.chatType?.toLowerCase().includes(n)??!1;case`provider`:return Kg(e).some(e=>e.includes(n));case`model`:return qg(e).some(e=>e.includes(n));case`tool`:return Jg(e).some(e=>e.includes(n));case`label`:return e.label?.toLowerCase().includes(n)??!1;case`key`:case`session`:case`id`:if(n.includes(`*`)||n.includes(`?`)){let t=Hg(n);return t.test(e.key)||(e.sessionId?t.test(e.sessionId):!1)}return e.key.toLowerCase().includes(n)||(e.sessionId?.toLowerCase().includes(n)??!1);case`has`:switch(n){case`tools`:return(e.usage?.toolUsage?.totalCalls??0)>0;case`errors`:return(e.usage?.messageCounts?.errors??0)>0;case`context`:return!!e.contextWeight;case`usage`:return!!e.usage;case`model`:return qg(e).length>0;case`provider`:return Kg(e).length>0;default:return!0}case`mintokens`:{let t=Ug(n);return t===null?!0:(e.usage?.totalTokens??0)>=t}case`maxtokens`:{let t=Ug(n);return t===null?!0:(e.usage?.totalTokens??0)<=t}case`mincost`:{let t=Ug(n);return t===null?!0:(e.usage?.totalCost??0)>=t}case`maxcost`:{let t=Ug(n);return t===null?!0:(e.usage?.totalCost??0)<=t}case`minmessages`:{let t=Ug(n);return t===null?!0:(e.usage?.messageCounts?.total??0)>=t}case`maxmessages`:{let t=Ug(n);return t===null?!0:(e.usage?.messageCounts?.total??0)<=t}default:return!0}},Xg=(e,t)=>{let n=Wg(t);if(n.length===0)return{sessions:e,warnings:[]};let r=[];for(let e of n){if(!e.key)continue;let t=Vg(e.key);if(!Bg.has(t)){r.push(`Unknown filter: ${e.key}`);continue}if(e.value===``&&r.push(`Missing value for ${e.key}`),t===`has`){let t=new Set([`tools`,`errors`,`context`,`usage`,`model`,`provider`]);e.value&&!t.has(Vg(e.value))&&r.push(`Unknown has:${e.value}`)}[`mintokens`,`maxtokens`,`mincost`,`maxcost`,`minmessages`,`maxmessages`].includes(t)&&e.value&&Ug(e.value)===null&&r.push(`Invalid number for ${e.key}`)}return{sessions:e.filter(e=>n.every(t=>Yg(e,t))),warnings:r}};function Zg(e){let t=e.split(`
`),n=new Map,r=[];for(let e of t){let t=/^\[Tool:\s*([^\]]+)\]/.exec(e.trim());if(t){let e=t[1];n.set(e,(n.get(e)??0)+1);continue}e.trim().startsWith(`[Tool Result]`)||r.push(e)}let i=Array.from(n.entries()).toSorted((e,t)=>t[1]-e[1]),a=i.reduce((e,[,t])=>e+t,0);return{tools:i,summary:i.length>0?`Tools: ${i.map(([e,t])=>`${e}×${t}`).join(`, `)} (${a} calls)`:``,cleanContent:r.join(`
`).trim()}}function Qg(e,t){!t||t.count<=0||(e.count+=t.count,e.sum+=t.avgMs*t.count,e.min=Math.min(e.min,t.minMs),e.max=Math.max(e.max,t.maxMs),e.p95Max=Math.max(e.p95Max,t.p95Ms))}function $g(e,t){for(let n of t??[]){let t=e.get(n.date)??{date:n.date,count:0,sum:0,min:1/0,max:0,p95Max:0};t.count+=n.count,t.sum+=n.avgMs*n.count,t.min=Math.min(t.min,n.minMs),t.max=Math.max(t.max,n.maxMs),t.p95Max=Math.max(t.p95Max,n.p95Ms),e.set(n.date,t)}}function e_(e){return{byChannel:Array.from(e.byChannelMap.entries()).map(([e,t])=>({channel:e,totals:t})).toSorted((e,t)=>t.totals.totalCost-e.totals.totalCost),latency:e.latencyTotals.count>0?{count:e.latencyTotals.count,avgMs:e.latencyTotals.sum/e.latencyTotals.count,minMs:e.latencyTotals.min===1/0?0:e.latencyTotals.min,maxMs:e.latencyTotals.max,p95Ms:e.latencyTotals.p95Max}:void 0,dailyLatency:Array.from(e.dailyLatencyMap.values()).map(e=>({date:e.date,count:e.count,avgMs:e.count?e.sum/e.count:0,minMs:e.min===1/0?0:e.min,maxMs:e.max,p95Ms:e.p95Max})).toSorted((e,t)=>e.date.localeCompare(t.date)),modelDaily:Array.from(e.modelDailyMap.values()).toSorted((e,t)=>e.date.localeCompare(t.date)||t.cost-e.cost),daily:Array.from(e.dailyMap.values()).toSorted((e,t)=>e.date.localeCompare(t.date))}}var t_=4;function n_(e){return Math.round(e/t_)}function Z(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function r_(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString(void 0,{hour:`numeric`})}function i_(e,t){let n=Array.from({length:24},()=>0),r=Array.from({length:24},()=>0);for(let i of e){let e=i.usage;if(!e?.messageCounts||e.messageCounts.total===0)continue;let a=e.firstActivity??i.updatedAt,o=e.lastActivity??i.updatedAt;if(!a||!o)continue;let s=Math.min(a,o),c=Math.max(a,o),l=Math.max(c-s,1)/6e4,u=s;for(;u<c;){let i=new Date(u),a=a_(i,t),o=s_(i,t),s=Math.min(o.getTime(),c),d=Math.max((s-u)/6e4,0)/l;n[a]+=e.messageCounts.errors*d,r[a]+=e.messageCounts.total*d,u=s+1}}return r.map((e,t)=>{let r=n[t];return{hour:t,rate:e>0?r/e:0,errors:r,msgs:e}}).filter(e=>e.msgs>0&&e.errors>0).toSorted((e,t)=>t.rate-e.rate).slice(0,5).map(e=>({label:r_(e.hour),value:`${(e.rate*100).toFixed(2)}%`,sub:`${Math.round(e.errors)} ${P(`usage.overview.errors`).toLowerCase()} · ${Math.round(e.msgs)} ${P(`usage.overview.messagesAbbrev`)}`}))}function a_(e,t){return t===`utc`?e.getUTCHours():e.getHours()}function o_(e,t){return t===`utc`?e.getUTCDay():e.getDay()}function s_(e,t){let n=new Date(e);return t===`utc`?n.setUTCMinutes(59,59,999):n.setMinutes(59,59,999),n}function c_(e,t){let n=Array.from({length:24},()=>0),r=Array.from({length:7},()=>0),i=0,a=!1;for(let o of e){let e=o.usage;if(!e||!e.totalTokens||e.totalTokens<=0)continue;i+=e.totalTokens;let s=e.firstActivity??o.updatedAt,c=e.lastActivity??o.updatedAt;if(!s||!c)continue;a=!0;let l=Math.min(s,c),u=Math.max(s,c),d=Math.max(u-l,1)/6e4,f=l;for(;f<u;){let i=new Date(f),a=a_(i,t),o=o_(i,t),s=s_(i,t),c=Math.min(s.getTime(),u),l=Math.max((c-f)/6e4,0)/d;n[a]+=e.totalTokens*l,r[o]+=e.totalTokens*l,f=c+1}}let o=[P(`usage.mosaic.sun`),P(`usage.mosaic.mon`),P(`usage.mosaic.tue`),P(`usage.mosaic.wed`),P(`usage.mosaic.thu`),P(`usage.mosaic.fri`),P(`usage.mosaic.sat`)].map((e,t)=>({label:e,tokens:r[t]}));return{hasData:a,totalTokens:i,hourTotals:n,weekdayTotals:o}}function l_(e,t,r,i){let a=c_(e,t);if(!a.hasData)return n`
<div class="card usage-mosaic">
<div class="usage-mosaic-header">
<div>
<div class="usage-mosaic-title">${P(`usage.mosaic.title`)}</div>
<div class="usage-mosaic-sub">${P(`usage.mosaic.subtitleEmpty`)}</div>
</div>
<div class="usage-mosaic-total">${Z(0)} ${P(`usage.metrics.tokens`).toLowerCase()}</div>
</div>
<div class="usage-empty-block usage-empty-block--compact">
${P(`usage.mosaic.noTimelineData`)}
</div>
</div>
`;let o=Math.max(...a.hourTotals,1),s=Math.max(...a.weekdayTotals.map(e=>e.tokens),1);return n`
<div class="card usage-mosaic">
<div class="usage-mosaic-header">
<div>
<div class="usage-mosaic-title">${P(`usage.mosaic.title`)}</div>
<div class="usage-mosaic-sub">
${P(`usage.mosaic.subtitle`,{zone:P(t===`utc`?`usage.filters.timeZoneUtc`:`usage.filters.timeZoneLocal`)})}
</div>
</div>
<div class="usage-mosaic-total">
${Z(a.totalTokens)} ${P(`usage.metrics.tokens`).toLowerCase()}
</div>
</div>
<div class="usage-mosaic-grid">
<div class="usage-mosaic-section">
<div class="usage-mosaic-section-title">${P(`usage.mosaic.dayOfWeek`)}</div>
<div class="usage-daypart-grid">
${a.weekdayTotals.map(e=>{let t=Math.min(e.tokens/s,1);return n`
<div class="usage-daypart-cell" style="background: ${e.tokens>0?`color-mix(in srgb, var(--accent) ${(12+t*60).toFixed(1)}%, transparent)`:`transparent`};">
<div class="usage-daypart-label">${e.label}</div>
<div class="usage-daypart-value">${Z(e.tokens)}</div>
</div>
`})}
</div>
</div>
<div class="usage-mosaic-section">
<div class="usage-mosaic-section-title">
<span>${P(`usage.filters.hours`)}</span>
<span class="usage-mosaic-sub">0 → 23</span>
</div>
<div class="usage-hour-grid">
${a.hourTotals.map((e,t)=>{let a=Math.min(e/o,1),s=e>0?`color-mix(in srgb, var(--accent) ${(8+a*70).toFixed(1)}%, transparent)`:`transparent`,c=`${t}:00 · ${Z(e)} ${P(`usage.metrics.tokens`).toLowerCase()}`,l=a>.7?`color-mix(in srgb, var(--accent) 60%, transparent)`:`color-mix(in srgb, var(--accent) 24%, transparent)`;return n`
<div
class="usage-hour-cell ${r.includes(t)?`selected`:``}"
style="background: ${s}; border-color: ${l};"
title="${c}"
@click=${e=>i(t,e.shiftKey)}
></div>
`})}
</div>
<div class="usage-hour-labels">
<span>${P(`usage.mosaic.midnight`)}</span>
<span>${P(`usage.mosaic.fourAm`)}</span>
<span>${P(`usage.mosaic.eightAm`)}</span>
<span>${P(`usage.mosaic.noon`)}</span>
<span>${P(`usage.mosaic.fourPm`)}</span>
<span>${P(`usage.mosaic.eightPm`)}</span>
</div>
<div class="usage-hour-legend">
<span></span>
${P(`usage.mosaic.legend`)}
</div>
</div>
</div>
</div>
`}function Q(e,t=2){return`$${e.toFixed(t)}`}function u_(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function d_(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let[,n,r,i]=t,a=new Date(Date.UTC(Number(n),Number(r)-1,Number(i)));return Number.isNaN(a.valueOf())?null:a}function f_(e){let t=d_(e);return t?t.toLocaleDateString(void 0,{month:`short`,day:`numeric`}):e}function p_(e){let t=d_(e);return t?t.toLocaleDateString(void 0,{month:`long`,day:`numeric`,year:`numeric`}):e}var m_=()=>({input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,totalCost:0,inputCost:0,outputCost:0,cacheReadCost:0,cacheWriteCost:0,missingCostEntries:0}),h_=(e,t)=>{e.input+=t.input??0,e.output+=t.output??0,e.cacheRead+=t.cacheRead??0,e.cacheWrite+=t.cacheWrite??0,e.totalTokens+=t.totalTokens??0,e.totalCost+=t.totalCost??0,e.inputCost+=t.inputCost??0,e.outputCost+=t.outputCost??0,e.cacheReadCost+=t.cacheReadCost??0,e.cacheWriteCost+=t.cacheWriteCost??0,e.missingCostEntries+=t.missingCostEntries??0},g_=(e,t)=>{if(e.length===0)return t??{messages:{total:0,user:0,assistant:0,toolCalls:0,toolResults:0,errors:0},tools:{totalCalls:0,uniqueTools:0,tools:[]},byModel:[],byProvider:[],byAgent:[],byChannel:[],daily:[]};let n={total:0,user:0,assistant:0,toolCalls:0,toolResults:0,errors:0},r=new Map,i=new Map,a=new Map,o=new Map,s=new Map,c=new Map,l=new Map,u=new Map,d={count:0,sum:0,min:1/0,max:0,p95Max:0};for(let t of e){let e=t.usage;if(e){if(e.messageCounts&&(n.total+=e.messageCounts.total,n.user+=e.messageCounts.user,n.assistant+=e.messageCounts.assistant,n.toolCalls+=e.messageCounts.toolCalls,n.toolResults+=e.messageCounts.toolResults,n.errors+=e.messageCounts.errors),e.toolUsage)for(let t of e.toolUsage.tools)r.set(t.name,(r.get(t.name)??0)+t.count);if(e.modelUsage)for(let t of e.modelUsage){let e=`${t.provider??`unknown`}::${t.model??`unknown`}`,n=i.get(e)??{provider:t.provider,model:t.model,count:0,totals:m_()};n.count+=t.count,h_(n.totals,t.totals),i.set(e,n);let r=t.provider??`unknown`,o=a.get(r)??{provider:t.provider,model:void 0,count:0,totals:m_()};o.count+=t.count,h_(o.totals,t.totals),a.set(r,o)}if(Qg(d,e.latency),t.agentId){let n=o.get(t.agentId)??m_();h_(n,e),o.set(t.agentId,n)}if(t.channel){let n=s.get(t.channel)??m_();h_(n,e),s.set(t.channel,n)}for(let t of e.dailyBreakdown??[]){let e=c.get(t.date)??{date:t.date,tokens:0,cost:0,messages:0,toolCalls:0,errors:0};e.tokens+=t.tokens,e.cost+=t.cost,c.set(t.date,e)}for(let t of e.dailyMessageCounts??[]){let e=c.get(t.date)??{date:t.date,tokens:0,cost:0,messages:0,toolCalls:0,errors:0};e.messages+=t.total,e.toolCalls+=t.toolCalls,e.errors+=t.errors,c.set(t.date,e)}$g(l,e.dailyLatency);for(let t of e.dailyModelUsage??[]){let e=`${t.date}::${t.provider??`unknown`}::${t.model??`unknown`}`,n=u.get(e)??{date:t.date,provider:t.provider,model:t.model,tokens:0,cost:0,count:0};n.tokens+=t.tokens,n.cost+=t.cost,n.count+=t.count,u.set(e,n)}}}let f=e_({byChannelMap:s,latencyTotals:d,dailyLatencyMap:l,modelDailyMap:u,dailyMap:c});return{messages:n,tools:{totalCalls:Array.from(r.values()).reduce((e,t)=>e+t,0),uniqueTools:r.size,tools:Array.from(r.entries()).map(([e,t])=>({name:e,count:t})).toSorted((e,t)=>t.count-e.count)},byModel:Array.from(i.values()).toSorted((e,t)=>t.totals.totalCost-e.totals.totalCost),byProvider:Array.from(a.values()).toSorted((e,t)=>t.totals.totalCost-e.totals.totalCost),byAgent:Array.from(o.entries()).map(([e,t])=>({agentId:e,totals:t})).toSorted((e,t)=>t.totals.totalCost-e.totals.totalCost),...f}},__=(e,t,n)=>{let r=0,i=0;for(let t of e){let e=t.usage?.durationMs??0;e>0&&(r+=e,i+=1)}let a=i?r/i:0,o=t&&r>0?t.totalTokens/(r/6e4):void 0,s=t&&r>0?t.totalCost/(r/6e4):void 0,c=n.messages.total?n.messages.errors/n.messages.total:0,l=n.daily.filter(e=>e.messages>0&&e.errors>0).map(e=>({date:e.date,errors:e.errors,messages:e.messages,rate:e.errors/e.messages})).toSorted((e,t)=>t.rate-e.rate||t.errors-e.errors)[0];return{durationSumMs:r,durationCount:i,avgDurationMs:a,throughputTokensPerMin:o,throughputCostPerMin:s,errorRate:c,peakErrorDay:l}};function v_(e,t,n=`text/plain`){let r=new Blob([t],{type:`${n};charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,a.click(),URL.revokeObjectURL(i)}function y_(e){return/[",\n]/.test(e)?`"${e.replaceAll(`"`,`""`)}"`:e}function b_(e){return e.map(e=>e==null?``:y_(String(e))).join(`,`)}var x_=e=>{let t=[b_([`key`,`label`,`agentId`,`channel`,`provider`,`model`,`updatedAt`,`durationMs`,`messages`,`errors`,`toolCalls`,`inputTokens`,`outputTokens`,`cacheReadTokens`,`cacheWriteTokens`,`totalTokens`,`totalCost`])];for(let n of e){let e=n.usage;t.push(b_([n.key,n.label??``,n.agentId??``,n.channel??``,n.modelProvider??n.providerOverride??``,n.model??n.modelOverride??``,n.updatedAt?new Date(n.updatedAt).toISOString():``,e?.durationMs??``,e?.messageCounts?.total??``,e?.messageCounts?.errors??``,e?.messageCounts?.toolCalls??``,e?.input??``,e?.output??``,e?.cacheRead??``,e?.cacheWrite??``,e?.totalTokens??``,e?.totalCost??``]))}return t.join(`
`)},S_=e=>{let t=[b_([`date`,`inputTokens`,`outputTokens`,`cacheReadTokens`,`cacheWriteTokens`,`totalTokens`,`inputCost`,`outputCost`,`cacheReadCost`,`cacheWriteCost`,`totalCost`])];for(let n of e)t.push(b_([n.date,n.input,n.output,n.cacheRead,n.cacheWrite,n.totalTokens,n.inputCost??``,n.outputCost??``,n.cacheReadCost??``,n.cacheWriteCost??``,n.totalCost]));return t.join(`
`)},C_=(e,t,n)=>{let r=e.trim();if(!r)return[];let i=r.length?r.split(/\s+/):[],a=i.length?i[i.length-1]:``,[o,s]=a.includes(`:`)?[a.slice(0,a.indexOf(`:`)),a.slice(a.indexOf(`:`)+1)]:[``,``],c=o.toLowerCase(),l=s.toLowerCase(),u=e=>{let t=new Set;for(let n of e)n&&t.add(n);return Array.from(t)},d=u(t.map(e=>e.agentId)).slice(0,6),f=u(t.map(e=>e.channel)).slice(0,6),p=u([...t.map(e=>e.modelProvider),...t.map(e=>e.providerOverride),...n?.byProvider.map(e=>e.provider)??[]]).slice(0,6),m=u([...t.map(e=>e.model),...n?.byModel.map(e=>e.model)??[]]).slice(0,6),h=u(n?.tools.tools.map(e=>e.name)??[]).slice(0,6);if(!c)return[{label:`agent:`,value:`agent:`},{label:`channel:`,value:`channel:`},{label:`provider:`,value:`provider:`},{label:`model:`,value:`model:`},{label:`tool:`,value:`tool:`},{label:`has:errors`,value:`has:errors`},{label:`has:tools`,value:`has:tools`},{label:`minTokens:`,value:`minTokens:`},{label:`maxCost:`,value:`maxCost:`}];let g=[],_=(e,t)=>{for(let n of t)(!l||n.toLowerCase().includes(l))&&g.push({label:`${e}:${n}`,value:`${e}:${n}`})};switch(c){case`agent`:_(`agent`,d);break;case`channel`:_(`channel`,f);break;case`provider`:_(`provider`,p);break;case`model`:_(`model`,m);break;case`tool`:_(`tool`,h);break;case`has`:[`errors`,`tools`,`context`,`usage`,`model`,`provider`].forEach(e=>{(!l||e.includes(l))&&g.push({label:`has:${e}`,value:`has:${e}`})});break;default:break}return g},w_=(e,t)=>{let n=e.trim();if(!n)return`${t} `;let r=n.split(/\s+/);return r[r.length-1]=t,`${r.join(` `)} `},T_=e=>e.trim().toLowerCase(),E_=(e,t)=>{let n=e.trim();if(!n)return`${t} `;let r=n.split(/\s+/),i=r[r.length-1]??``,a=t.includes(`:`)?t.split(`:`)[0]:null,o=i.includes(`:`)?i.split(`:`)[0]:null;return i.endsWith(`:`)&&a&&o===a?(r[r.length-1]=t,`${r.join(` `)} `):r.includes(t)?`${r.join(` `)} `:`${r.join(` `)} ${t} `},D_=(e,t)=>{let n=e.trim().split(/\s+/).filter(Boolean).filter(e=>e!==t);return n.length?`${n.join(` `)} `:``},O_=(e,t,n)=>{let r=T_(t),i=[...Wg(e).filter(e=>T_(e.key??``)!==r).map(e=>e.raw),...n.map(e=>`${t}:${e}`)];return i.length?`${i.join(` `)} `:``};function k_(e,t){return t===0?0:e/t*100}function A_(e){let t=e.totalCost||0;return{input:{tokens:e.input,cost:e.inputCost||0,pct:k_(e.inputCost||0,t)},output:{tokens:e.output,cost:e.outputCost||0,pct:k_(e.outputCost||0,t)},cacheRead:{tokens:e.cacheRead,cost:e.cacheReadCost||0,pct:k_(e.cacheReadCost||0,t)},cacheWrite:{tokens:e.cacheWrite,cost:e.cacheWriteCost||0,pct:k_(e.cacheWriteCost||0,t)},totalCost:t}}function j_(e,t,r,a,o,s,c,l){if(!(e.length>0||t.length>0||r.length>0))return i;let u=r.length===1?a.find(e=>e.key===r[0]):null,d=u?(u.label||u.key).slice(0,20)+((u.label||u.key).length>20?`…`:``):r.length===1?r[0].slice(0,8)+`…`:P(`usage.filters.sessionsCount`,{count:String(r.length)}),f=u?u.label||u.key:r.length===1?r[0]:r.join(`, `),p=e.length===1?e[0]:P(`usage.filters.daysCount`,{count:String(e.length)}),m=t.length===1?`${t[0]}:00`:P(`usage.filters.hoursCount`,{count:String(t.length)});return n`
<div class="active-filters">
${e.length>0?n`
<div class="filter-chip">
<span class="filter-chip-label">${P(`usage.filters.days`)}: ${p}</span>
<button
class="filter-chip-remove"
@click=${o}
title=${P(`usage.filters.remove`)}
aria-label="Remove days filter"
>
×
</button>
</div>
`:i}
${t.length>0?n`
<div class="filter-chip">
<span class="filter-chip-label">${P(`usage.filters.hours`)}: ${m}</span>
<button
class="filter-chip-remove"
@click=${s}
title=${P(`usage.filters.remove`)}
aria-label="Remove hours filter"
>
×
</button>
</div>
`:i}
${r.length>0?n`
<div class="filter-chip" title="${f}">
<span class="filter-chip-label">${P(`usage.filters.session`)}: ${d}</span>
<button
class="filter-chip-remove"
@click=${c}
title=${P(`usage.filters.remove`)}
aria-label="Remove session filter"
>
×
</button>
</div>
`:i}
${(e.length>0||t.length>0)&&r.length>0?n`
<button class="btn btn--sm" @click=${l}>
${P(`usage.filters.clearAll`)}
</button>
`:i}
</div>
`}function M_(e,t,r,a,o,s){if(!e.length)return n`
<div class="daily-chart-compact">
<div class="card-title usage-section-title">${P(`usage.daily.title`)}</div>
<div class="usage-empty-block">${P(`usage.empty.noData`)}</div>
</div>
`;let c=r===`tokens`,l=e.map(e=>c?e.totalTokens:e.totalCost),u=Math.max(...l,c?1:1e-4),d=e.length>30?12:e.length>20?18:e.length>14?24:32,f=e.length<=14;return n`
<div class="daily-chart-compact">
<div class="daily-chart-header">
<div class="chart-toggle small sessions-toggle">
<button
class="btn btn--sm toggle-btn ${a===`total`?`active`:``}"
@click=${()=>o(`total`)}
>
${P(`usage.daily.total`)}
</button>
<button
class="btn btn--sm toggle-btn ${a===`by-type`?`active`:``}"
@click=${()=>o(`by-type`)}
>
${P(`usage.daily.byType`)}
</button>
</div>
<div class="card-title">
${P(c?`usage.daily.tokensTitle`:`usage.daily.costTitle`)}
</div>
</div>
<div class="daily-chart">
<div class="daily-chart-bars" style="--bar-max-width: ${d}px">
${e.map((r,o)=>{let d=l[o]/u*100,p=t.includes(r.date),m=f_(r.date),h=e.length>20?String(parseInt(r.date.slice(8),10)):m,g=e.length>20?`daily-bar-label daily-bar-label--compact`:`daily-bar-label`,_=a===`by-type`?c?[{value:r.output,class:`output`},{value:r.input,class:`input`},{value:r.cacheWrite,class:`cache-write`},{value:r.cacheRead,class:`cache-read`}]:[{value:r.outputCost??0,class:`output`},{value:r.inputCost??0,class:`input`},{value:r.cacheWriteCost??0,class:`cache-write`},{value:r.cacheReadCost??0,class:`cache-read`}]:[],v=a===`by-type`?c?[`${P(`usage.breakdown.output`)} ${Z(r.output)}`,`${P(`usage.breakdown.input`)} ${Z(r.input)}`,`${P(`usage.breakdown.cacheWrite`)} ${Z(r.cacheWrite)}`,`${P(`usage.breakdown.cacheRead`)} ${Z(r.cacheRead)}`]:[`${P(`usage.breakdown.output`)} ${Q(r.outputCost??0)}`,`${P(`usage.breakdown.input`)} ${Q(r.inputCost??0)}`,`${P(`usage.breakdown.cacheWrite`)} ${Q(r.cacheWriteCost??0)}`,`${P(`usage.breakdown.cacheRead`)} ${Q(r.cacheReadCost??0)}`]:[],y=c?Z(r.totalTokens):Q(r.totalCost);return n`
<div
class="daily-bar-wrapper ${p?`selected`:``}"
@click=${e=>s(r.date,e.shiftKey)}
>
${a===`by-type`?n`
<div
class="daily-bar daily-bar--stacked"
style="height: ${d.toFixed(1)}%;"
>
${(()=>{let e=_.reduce((e,t)=>e+t.value,0)||1;return _.map(t=>n`
<div
class="cost-segment ${t.class}"
style="height: ${t.value/e*100}%"
></div>
`)})()}
</div>
`:n`
<div class="daily-bar" style="height: ${d.toFixed(1)}%"></div>
`}
${f?n`<div class="daily-bar-total">${y}</div>`:i}
<div class="${g}">${h}</div>
<div class="daily-bar-tooltip">
<strong>${p_(r.date)}</strong><br />
${Z(r.totalTokens)} ${P(`usage.metrics.tokens`).toLowerCase()}<br />
${Q(r.totalCost)}
${v.length?n`${v.map(e=>n`<div>${e}</div>`)}`:i}
</div>
</div>
`})}
</div>
</div>
</div>
`}function N_(e,t){let r=A_(e),i=t===`tokens`,a=e.totalTokens||1,o={output:k_(e.output,a),input:k_(e.input,a),cacheWrite:k_(e.cacheWrite,a),cacheRead:k_(e.cacheRead,a)};return n`
<div class="cost-breakdown cost-breakdown-compact">
<div class="cost-breakdown-header">
${P(i?`usage.breakdown.tokensByType`:`usage.breakdown.costByType`)}
</div>
<div class="cost-breakdown-bar">
<div class="cost-segment output" style="width: ${(i?o.output:r.output.pct).toFixed(1)}%"
title="${P(`usage.breakdown.output`)}: ${i?Z(e.output):Q(r.output.cost)}"></div>
<div class="cost-segment input" style="width: ${(i?o.input:r.input.pct).toFixed(1)}%"
title="${P(`usage.breakdown.input`)}: ${i?Z(e.input):Q(r.input.cost)}"></div>
<div class="cost-segment cache-write" style="width: ${(i?o.cacheWrite:r.cacheWrite.pct).toFixed(1)}%"
title="${P(`usage.breakdown.cacheWrite`)}: ${i?Z(e.cacheWrite):Q(r.cacheWrite.cost)}"></div>
<div class="cost-segment cache-read" style="width: ${(i?o.cacheRead:r.cacheRead.pct).toFixed(1)}%"
title="${P(`usage.breakdown.cacheRead`)}: ${i?Z(e.cacheRead):Q(r.cacheRead.cost)}"></div>
</div>
<div class="cost-breakdown-legend">
<span class="legend-item"><span class="legend-dot output"></span>${P(`usage.breakdown.output`)} ${i?Z(e.output):Q(r.output.cost)}</span>
<span class="legend-item"><span class="legend-dot input"></span>${P(`usage.breakdown.input`)} ${i?Z(e.input):Q(r.input.cost)}</span>
<span class="legend-item"><span class="legend-dot cache-write"></span>${P(`usage.breakdown.cacheWrite`)} ${i?Z(e.cacheWrite):Q(r.cacheWrite.cost)}</span>
<span class="legend-item"><span class="legend-dot cache-read"></span>${P(`usage.breakdown.cacheRead`)} ${i?Z(e.cacheRead):Q(r.cacheRead.cost)}</span>
</div>
<div class="cost-breakdown-total">
${P(`usage.breakdown.total`)}: ${i?Z(e.totalTokens):Q(e.totalCost)}
</div>
</div>
`}function P_(e,t,r){return n`
<div class="usage-insight-card">
<div class="usage-insight-title">${e}</div>
${t.length===0?n`<div class="muted">${r}</div>`:n`
<div class="usage-list">
${t.map(e=>n`
<div class="usage-list-item">
<span>${e.label}</span>
<span class="usage-list-value">
<span>${e.value}</span>
${e.sub?n`<span class="usage-list-sub">${e.sub}</span>`:i}
</span>
</div>
`)}
</div>
`}
</div>
`}function F_(e,t,r,a){let o=[`usage-insight-card`,a?.className].filter(Boolean).join(` `),s=[`usage-error-list`,a?.listClassName].filter(Boolean).join(` `);return n`
<div class=${o}>
<div class="usage-insight-title">${e}</div>
${t.length===0?n`<div class="muted">${r}</div>`:n`
<div class=${s}>
${t.map(e=>n`
<div class="usage-error-row">
<div class="usage-error-date">${e.label}</div>
<div class="usage-error-rate">${e.value}</div>
${e.sub?n`<div class="usage-error-sub">${e.sub}</div>`:i}
</div>
`)}
</div>
`}
</div>
`}function I_(e){let t=[`stat`,`usage-summary-card`,e.className,e.tone?`usage-summary-card--${e.tone}`:``].filter(Boolean).join(` `),r=[`stat-value`,`usage-summary-value`,e.tone??``,e.compactValue?`usage-summary-value--compact`:``].filter(Boolean).join(` `);return n`
<div class=${t}>
<div class="usage-summary-title">
${e.title}
<span class="usage-summary-hint" title=${e.hint}>?</span>
</div>
<div class=${r}>${e.value}</div>
<div class="usage-summary-sub">${e.sub}</div>
</div>
`}function L_(e,t,r,a,o,s,c){if(!e)return i;let l=t.messages.total?Math.round(e.totalTokens/t.messages.total):0,u=t.messages.total?e.totalCost/t.messages.total:0,d=e.input+e.cacheRead,f=d>0?e.cacheRead/d:0,p=d>0?`${(f*100).toFixed(1)}%`:P(`usage.common.emptyValue`),m=r.errorRate*100,h=r.throughputTokensPerMin===void 0?P(`usage.common.emptyValue`):`${Z(Math.round(r.throughputTokensPerMin))} ${P(`usage.overview.tokensPerMinute`)}`,g=r.throughputCostPerMin===void 0?P(`usage.common.emptyValue`):`${Q(r.throughputCostPerMin,4)} ${P(`usage.overview.perMinute`)}`,v=r.durationCount>0?_(r.avgDurationMs,{spaced:!0})??P(`usage.common.emptyValue`):P(`usage.common.emptyValue`),y=P(`usage.overview.cacheHint`),b=P(`usage.overview.errorHint`),x=P(`usage.overview.throughputHint`),S=P(`usage.overview.avgTokensHint`),C=P(a?`usage.overview.avgCostHintMissing`:`usage.overview.avgCostHint`),w=t.daily.filter(e=>e.messages>0&&e.errors>0).map(e=>{let t=e.errors/e.messages;return{label:f_(e.date),value:`${(t*100).toFixed(2)}%`,sub:`${e.errors} ${P(`usage.overview.errors`).toLowerCase()} · ${e.messages} ${P(`usage.overview.messagesAbbrev`)} · ${Z(e.tokens)}`,rate:t}}).toSorted((e,t)=>t.rate-e.rate).slice(0,5).map(({rate:e,...t})=>t),T=t.byModel.slice(0,5).map(e=>({label:e.model??P(`usage.common.unknown`),value:Q(e.totals.totalCost),sub:`${Z(e.totals.totalTokens)} · ${e.count} ${P(`usage.overview.messagesAbbrev`)}`})),E=t.byProvider.slice(0,5).map(e=>({label:e.provider??P(`usage.common.unknown`),value:Q(e.totals.totalCost),sub:`${Z(e.totals.totalTokens)} · ${e.count} ${P(`usage.overview.messagesAbbrev`)}`})),D=t.tools.tools.slice(0,6).map(e=>({label:e.name,value:`${e.count}`,sub:P(`usage.overview.calls`)})),O=t.byAgent.slice(0,5).map(e=>({label:e.agentId,value:Q(e.totals.totalCost),sub:Z(e.totals.totalTokens)})),k=t.byChannel.slice(0,5).map(e=>({label:e.channel,value:Q(e.totals.totalCost),sub:Z(e.totals.totalTokens)}));return n`
<section class="card usage-overview-card">
<div class="card-title">${P(`usage.overview.title`)}</div>
<div class="usage-overview-layout">
<div class="usage-summary-grid">
${I_({title:P(`usage.overview.messages`),hint:P(`usage.overview.messagesHint`),value:t.messages.total,sub:`${t.messages.user} ${P(`usage.overview.user`).toLowerCase()} · ${t.messages.assistant} ${P(`usage.overview.assistant`).toLowerCase()}`,className:`usage-summary-card--hero`})}
${I_({title:P(`usage.overview.throughput`),hint:x,value:h,sub:g,className:`usage-summary-card--hero usage-summary-card--throughput`,compactValue:!0})}
${I_({title:P(`usage.overview.toolCalls`),hint:P(`usage.overview.toolCallsHint`),value:t.tools.totalCalls,sub:`${t.tools.uniqueTools} ${P(`usage.overview.toolsUsed`)}`,className:`usage-summary-card--half`})}
${I_({title:P(`usage.overview.avgTokens`),hint:S,value:Z(l),sub:P(`usage.overview.acrossMessages`,{count:String(t.messages.total||0)}),className:`usage-summary-card--half`})}
${I_({title:P(`usage.overview.cacheHitRate`),hint:y,value:p,sub:`${Z(e.cacheRead)} ${P(`usage.overview.cached`)} · ${Z(d)} ${P(`usage.overview.prompt`)}`,tone:f>.6?`good`:f>.3?`warn`:`bad`,className:`usage-summary-card--medium`})}
${I_({title:P(`usage.overview.errorRate`),hint:b,value:`${m.toFixed(2)}%`,sub:`${t.messages.errors} ${P(`usage.overview.errors`).toLowerCase()} · ${v} ${P(`usage.overview.avgSession`)}`,tone:m>5?`bad`:m>1?`warn`:`good`,className:`usage-summary-card--medium`})}
${I_({title:P(`usage.overview.avgCost`),hint:C,value:Q(u,4),sub:`${Q(e.totalCost)} ${P(`usage.breakdown.total`).toLowerCase()}`,className:`usage-summary-card--compact`})}
${I_({title:P(`usage.overview.sessions`),hint:P(`usage.overview.sessionsHint`),value:s,sub:P(`usage.overview.sessionsInRange`,{count:String(c)}),className:`usage-summary-card--compact`})}
${I_({title:P(`usage.overview.errors`),hint:P(`usage.overview.errorsHint`),value:t.messages.errors,sub:`${t.messages.toolResults} ${P(`usage.overview.toolResults`)}`,className:`usage-summary-card--compact`})}
</div>
<div class="usage-insights-grid">
${P_(P(`usage.overview.topModels`),T,P(`usage.overview.noModelData`))}
${P_(P(`usage.overview.topProviders`),E,P(`usage.overview.noProviderData`))}
${P_(P(`usage.overview.topTools`),D,P(`usage.overview.noToolCalls`))}
${P_(P(`usage.overview.topAgents`),O,P(`usage.overview.noAgentData`))}
${P_(P(`usage.overview.topChannels`),k,P(`usage.overview.noChannelData`))}
${F_(P(`usage.overview.peakErrorDays`),w,P(`usage.overview.noErrorData`))}
${F_(P(`usage.overview.peakErrorHours`),o,P(`usage.overview.noErrorData`),{className:`usage-insight-card--wide`,listClassName:`usage-error-list--hours`})}
</div>
</div>
</section>
`}function R_(e,t,r,a,o,s,c,l,u,d,f,p,m,h,g){let v=e=>m.includes(e),y=e=>{let t=e.label||e.key;return t.startsWith(`agent:`)&&t.includes(`?token=`)?t.slice(0,t.indexOf(`?token=`)):t},b=async e=>{let t=y(e);try{await navigator.clipboard.writeText(t)}catch{}},x=e=>{let t=[];return v(`channel`)&&e.channel&&t.push(`channel:${e.channel}`),v(`agent`)&&e.agentId&&t.push(`agent:${e.agentId}`),v(`provider`)&&(e.modelProvider||e.providerOverride)&&t.push(`provider:${e.modelProvider??e.providerOverride}`),v(`model`)&&e.model&&t.push(`model:${e.model}`),v(`messages`)&&e.usage?.messageCounts&&t.push(`msgs:${e.usage.messageCounts.total}`),v(`tools`)&&e.usage?.toolUsage&&t.push(`tools:${e.usage.toolUsage.totalCalls}`),v(`errors`)&&e.usage?.messageCounts&&t.push(`errors:${e.usage.messageCounts.errors}`),v(`duration`)&&e.usage?.durationMs&&t.push(`dur:${_(e.usage.durationMs,{spaced:!0})??`—`}`),t},S=e=>{let t=e.usage;if(!t)return 0;if(r.length>0&&t.dailyBreakdown&&t.dailyBreakdown.length>0){let e=t.dailyBreakdown.filter(e=>r.includes(e.date));return a?e.reduce((e,t)=>e+t.tokens,0):e.reduce((e,t)=>e+t.cost,0)}return a?t.totalTokens??0:t.totalCost??0},C=[...e].toSorted((e,t)=>{switch(o){case`recent`:return(t.updatedAt??0)-(e.updatedAt??0);case`messages`:return(t.usage?.messageCounts?.total??0)-(e.usage?.messageCounts?.total??0);case`errors`:return(t.usage?.messageCounts?.errors??0)-(e.usage?.messageCounts?.errors??0);case`cost`:return S(t)-S(e);default:return S(t)-S(e)}}),w=s===`asc`?C.toReversed():C,T=w.reduce((e,t)=>e+S(t),0),E=w.length?T/w.length:0,D=w.reduce((e,t)=>e+(t.usage?.messageCounts?.errors??0),0),O=(e,t)=>{let r=S(e),o=y(e),s=x(e);return n`
<div
class="session-bar-row ${t?`selected`:``}"
@click=${t=>u(e.key,t.shiftKey)}
title="${e.key}"
>
<div class="session-bar-label">
<div class="session-bar-title">${o}</div>
${s.length>0?n`<div class="session-bar-meta">${s.join(` · `)}</div>`:i}
</div>
<div class="session-bar-actions">
<button
class="btn btn--sm btn--ghost"
title=${P(`usage.sessions.copyName`)}
@click=${t=>{t.stopPropagation(),b(e)}}
>
${P(`usage.sessions.copy`)}
</button>
<div class="session-bar-value">${a?Z(r):Q(r)}</div>
</div>
</div>
`},k=new Set(t),A=w.filter(e=>k.has(e.key)),ee=A.length,j=new Map(w.map(e=>[e.key,e])),te=c.map(e=>j.get(e)).filter(e=>!!e);return n`
<div class="card sessions-card">
<div class="sessions-card-header">
<div class="card-title">${P(`usage.sessions.title`)}</div>
<div class="sessions-card-count">
${P(`usage.sessions.shown`,{count:String(e.length)})}
${h===e.length?``:` · ${P(`usage.sessions.total`,{count:String(h)})}`}
</div>
</div>
<div class="sessions-card-meta">
<div class="sessions-card-stats">
<span>
${a?Z(E):Q(E)} ${P(`usage.sessions.avg`)}
</span>
<span>${D} ${P(`usage.overview.errors`).toLowerCase()}</span>
</div>
<div class="chart-toggle small">
<button
class="btn btn--sm toggle-btn ${l===`all`?`active`:``}"
@click=${()=>p(`all`)}
>
${P(`usage.sessions.all`)}
</button>
<button
class="btn btn--sm toggle-btn ${l===`recent`?`active`:``}"
@click=${()=>p(`recent`)}
>
${P(`usage.sessions.recent`)}
</button>
</div>
<label class="sessions-sort">
<span>${P(`usage.sessions.sort`)}</span>
<select
@change=${e=>d(e.target.value)}
>
<option value="cost" ?selected=${o===`cost`}>${P(`usage.metrics.cost`)}</option>
<option value="errors" ?selected=${o===`errors`}>${P(`usage.overview.errors`)}</option>
<option value="messages" ?selected=${o===`messages`}>${P(`usage.overview.messages`)}</option>
<option value="recent" ?selected=${o===`recent`}>${P(`usage.sessions.recentShort`)}</option>
<option value="tokens" ?selected=${o===`tokens`}>${P(`usage.metrics.tokens`)}</option>
</select>
</label>
<button
class="btn btn--sm"
@click=${()=>f(s===`desc`?`asc`:`desc`)}
title=${P(s===`desc`?`usage.sessions.descending`:`usage.sessions.ascending`)}
>
${s===`desc`?`↓`:`↑`}
</button>
${ee>0?n`
<button class="btn btn--sm" @click=${g}>
${P(`usage.sessions.clearSelection`)}
</button>
`:i}
</div>
${l===`recent`?te.length===0?n`
<div class="usage-empty-block">${P(`usage.sessions.noRecent`)}</div>
`:n`
<div class="session-bars session-bars--recent">
${te.map(e=>O(e,k.has(e.key)))}
</div>
`:e.length===0?n`
<div class="usage-empty-block">${P(`usage.sessions.noneInRange`)}</div>
`:n`
<div class="session-bars">
${w.slice(0,50).map(e=>O(e,k.has(e.key)))}
${e.length>50?n`
<div class="usage-more-sessions">
${P(`usage.sessions.more`,{count:String(e.length-50)})}
</div>
`:i}
</div>
`}
${ee>1?n`
<div class="sessions-selected-group">
<div class="sessions-card-count">
${P(`usage.sessions.selected`,{count:String(ee)})}
</div>
<div class="session-bars session-bars--selected">
${A.map(e=>O(e,!0))}
</div>
</div>
`:i}
</div>
`}var z_=.75,B_=.06,V_=5,H_=12,U_=.7;function W_(e,t){return!t||t<=0?0:e/t*100}function G_(e){return e<0xe8d4a51000?e*1e3:e}function K_(e,t,n){let r=Math.min(t,n),i=Math.max(t,n);return e.filter(e=>{if(e.timestamp<=0)return!0;let t=G_(e.timestamp);return t>=r&&t<=i})}function q_(e,t,r){let a=t||e.usage;if(!a)return n`
<div class="usage-empty-block">${P(`usage.details.noUsageData`)}</div>
`;let o=e=>e?new Date(e).toLocaleString():P(`usage.common.emptyValue`),s=[];e.channel&&s.push(`channel:${e.channel}`),e.agentId&&s.push(`agent:${e.agentId}`),(e.modelProvider||e.providerOverride)&&s.push(`provider:${e.modelProvider??e.providerOverride}`),e.model&&s.push(`model:${e.model}`);let c=a.toolUsage?.tools.slice(0,6)??[],l,u,d;if(r){let e=new Map;for(let t of r){let{tools:n}=Zg(t.content);for(let[t]of n)e.set(t,(e.get(t)||0)+1)}d=c.map(t=>({label:t.name,value:`${e.get(t.name)??0}`,sub:P(`usage.overview.calls`)})),l=[...e.values()].reduce((e,t)=>e+t,0),u=e.size}else d=c.map(e=>({label:e.name,value:`${e.count}`,sub:P(`usage.overview.calls`)})),l=a.toolUsage?.totalCalls??0,u=a.toolUsage?.uniqueTools??0;let f=a.modelUsage?.slice(0,6).map(e=>({label:e.model??P(`usage.common.unknown`),value:Q(e.totals.totalCost),sub:Z(e.totals.totalTokens)}))??[];return n`
${s.length>0?n`<div class="usage-badges">${s.map(e=>n`<span class="usage-badge">${e}</span>`)}</div>`:i}
<div class="session-summary-grid">
<div class="stat session-summary-card">
<div class="session-summary-title">${P(`usage.overview.messages`)}</div>
<div class="stat-value session-summary-value">${a.messageCounts?.total??0}</div>
<div class="session-summary-meta">
${a.messageCounts?.user??0} ${P(`usage.overview.user`).toLowerCase()} ·
${a.messageCounts?.assistant??0} ${P(`usage.overview.assistant`).toLowerCase()}
</div>
</div>
<div class="stat session-summary-card">
<div class="session-summary-title">${P(`usage.overview.toolCalls`)}</div>
<div class="stat-value session-summary-value">${l}</div>
<div class="session-summary-meta">${u} ${P(`usage.overview.toolsUsed`)}</div>
</div>
<div class="stat session-summary-card">
<div class="session-summary-title">${P(`usage.overview.errors`)}</div>
<div class="stat-value session-summary-value">${a.messageCounts?.errors??0}</div>
<div class="session-summary-meta">
${a.messageCounts?.toolResults??0} ${P(`usage.overview.toolResults`)}
</div>
</div>
<div class="stat session-summary-card">
<div class="session-summary-title">${P(`usage.details.duration`)}</div>
<div class="stat-value session-summary-value">
${_(a.durationMs,{spaced:!0})??P(`usage.common.emptyValue`)}
</div>
<div class="session-summary-meta">${o(a.firstActivity)} → ${o(a.lastActivity)}</div>
</div>
</div>
<div class="usage-insights-grid usage-insights-grid--tight">
${P_(P(`usage.overview.topTools`),d,P(`usage.overview.noToolCalls`))}
${P_(P(`usage.details.modelMix`),f,P(`usage.overview.noModelData`))}
</div>
`}function J_(e,t,n,r){let i=Math.min(n,r),a=Math.max(n,r),o=t.filter(e=>e.timestamp>=i&&e.timestamp<=a);if(o.length===0)return;let s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0;for(let e of o)s+=e.totalTokens||0,c+=e.cost||0,d+=e.input||0,f+=e.output||0,p+=e.cacheRead||0,m+=e.cacheWrite||0,e.output>0&&u++,e.input>0&&l++;return{...e,totalTokens:s,totalCost:c,input:d,output:f,cacheRead:p,cacheWrite:m,durationMs:o[o.length-1].timestamp-o[0].timestamp,firstActivity:o[0].timestamp,lastActivity:o[o.length-1].timestamp,messageCounts:{total:o.length,user:l,assistant:u,toolCalls:0,toolResults:0,errors:0}}}function Y_(e,t,r,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D){let O=e.label||e.key,k=O.length>50?O.slice(0,50)+`…`:O,A=e.usage,ee=l!==null&&u!==null,j=l!==null&&u!==null&&t?.points&&A?J_(A,t.points,l,u):void 0,te=j?{totalTokens:j.totalTokens,totalCost:j.totalCost}:{totalTokens:A?.totalTokens??0,totalCost:A?.totalCost??0},M=j?P(`usage.details.filtered`):``;return n`
<div class="card session-detail-panel">
<div class="session-detail-header">
<div class="session-detail-header-left">
<div class="session-detail-title">
${k}
${M?n`<span class="session-detail-indicator">${M}</span>`:i}
</div>
</div>
<div class="session-detail-stats">
${A?n`
<span><strong>${Z(te.totalTokens)}</strong> ${P(`usage.metrics.tokens`).toLowerCase()}${M}</span>
<span><strong>${Q(te.totalCost)}</strong>${M}</span>
`:i}
</div>
<button
class="btn btn--sm btn--ghost"
@click=${D}
title=${P(`usage.details.close`)}
aria-label=${P(`usage.details.close`)}
>
×
</button>
</div>
<div class="session-detail-content">
${q_(e,j,l!=null&&u!=null&&h?K_(h,l,u):void 0)}
<div class="session-detail-row">
${X_(t,r,a,o,s,c,f,p,m,l,u,d)}
</div>
<div class="session-detail-bottom">
${Q_(h,g,_,v,y,b,x,S,C,w,ee?l:null,ee?u:null)}
${Z_(e.contextWeight,A,T,E)}
</div>
</div>
</div>
`}function X_(e,t,r,o,s,c,l,u,d,f,p,m){if(t)return n`
<div class="session-timeseries-compact">
<div class="usage-empty-block">${P(`usage.loading.badge`)}</div>
</div>
`;if(!e||e.points.length<2)return n`
<div class="session-timeseries-compact">
<div class="usage-empty-block">${P(`usage.details.noTimeline`)}</div>
</div>
`;let h=e.points;if(l||u||d&&d.length>0){let t=l?new Date(l+`T00:00:00`).getTime():0,n=u?new Date(u+`T23:59:59`).getTime():1/0;h=e.points.filter(e=>{if(e.timestamp<t||e.timestamp>n)return!1;if(d&&d.length>0){let t=new Date(e.timestamp),n=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`;return d.includes(n)}return!0})}if(h.length<2)return n`
<div class="session-timeseries-compact">
<div class="usage-empty-block">${P(`usage.details.noDataInRange`)}</div>
</div>
`;let g=0,_=0,v=0,y=0,b=0,x=0;h=h.map(e=>(g+=e.totalTokens,_+=e.cost,v+=e.output,y+=e.input,b+=e.cacheRead,x+=e.cacheWrite,{...e,cumulativeTokens:g,cumulativeCost:_}));let S=f!=null&&p!=null,C=S?Math.min(f,p):0,w=S?Math.max(f,p):1/0,T=0,E=h.length;if(S){T=h.findIndex(e=>e.timestamp>=C),T===-1&&(T=h.length);let e=h.findIndex(e=>e.timestamp>w);E=e===-1?h.length:e}let D=S?h.slice(T,E):h,O=0,k=0,A=0,ee=0;for(let e of D)O+=e.output,k+=e.input,A+=e.cacheRead,ee+=e.cacheWrite;let j={top:8,right:4,bottom:14,left:30},te=400-j.left-j.right,M=100-j.top-j.bottom,ne=r===`cumulative`,re=r===`per-turn`&&s===`by-type`,N=O+k+A+ee,F=h.map(e=>ne?e.cumulativeTokens:re?e.input+e.output+e.cacheRead+e.cacheWrite:e.totalTokens),I=Math.max(...F,1),L=te/h.length,ie=Math.min(8,Math.max(1,L*z_)),ae=L-ie,R=j.left+T*(ie+ae),oe=E>=h.length?j.left+(h.length-1)*(ie+ae)+ie:j.left+(E-1)*(ie+ae)+ie;return n`
<div class="session-timeseries-compact">
<div class="timeseries-header-row">
<div class="card-title usage-section-title">${P(`usage.details.usageOverTime`)}</div>
<div class="timeseries-controls">
${S?n`
<div class="chart-toggle small">
<button class="btn btn--sm toggle-btn active" @click=${()=>m?.(null,null)}>
${P(`usage.details.reset`)}
</button>
</div>
`:i}
<div class="chart-toggle small">
<button
class="btn btn--sm toggle-btn ${ne?``:`active`}"
@click=${()=>o(`per-turn`)}
>
${P(`usage.details.perTurn`)}
</button>
<button
class="btn btn--sm toggle-btn ${ne?`active`:``}"
@click=${()=>o(`cumulative`)}
>
${P(`usage.details.cumulative`)}
</button>
</div>
${ne?i:n`
<div class="chart-toggle small">
<button
class="btn btn--sm toggle-btn ${s===`total`?`active`:``}"
@click=${()=>c(`total`)}
>
${P(`usage.daily.total`)}
</button>
<button
class="btn btn--sm toggle-btn ${s===`by-type`?`active`:``}"
@click=${()=>c(`by-type`)}
>
${P(`usage.daily.byType`)}
</button>
</div>
`}
</div>
</div>
<div class="timeseries-chart-wrapper">
<svg
viewBox="0 0 ${400} ${118}"
class="timeseries-svg"
>
<!-- Y axis -->
<line x1="${j.left}" y1="${j.top}" x2="${j.left}" y2="${j.top+M}" stroke="var(--border)" />
<!-- X axis -->
<line x1="${j.left}" y1="${j.top+M}" x2="${400-j.right}" y2="${j.top+M}" stroke="var(--border)" />
<!-- Y axis labels -->
<text x="${j.left-4}" y="${j.top+5}" text-anchor="end" class="ts-axis-label">${Z(I)}</text>
<text x="${j.left-4}" y="${j.top+M}" text-anchor="end" class="ts-axis-label">0</text>
<!-- X axis labels (first and last) -->
${h.length>0?a`
<text x="${j.left}" y="${j.top+M+10}" text-anchor="start" class="ts-axis-label">${new Date(h[0].timestamp).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}</text>
<text x="${400-j.right}" y="${j.top+M+10}" text-anchor="end" class="ts-axis-label">${new Date(h[h.length-1].timestamp).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}</text>
`:i}
<!-- Bars -->
${h.map((e,t)=>{let n=F[t],r=j.left+t*(ie+ae),o=n/I*M,s=j.top+M-o,c=[new Date(e.timestamp).toLocaleDateString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),`${Z(n)} ${P(`usage.metrics.tokens`).toLowerCase()}`];re&&(c.push(`Out ${Z(e.output)}`),c.push(`In ${Z(e.input)}`),c.push(`CW ${Z(e.cacheWrite)}`),c.push(`CR ${Z(e.cacheRead)}`));let l=c.join(` · `),u=S&&(t<T||t>=E);if(!re)return a`<rect x="${r}" y="${s}" width="${ie}" height="${o}" class="ts-bar${u?` dimmed`:``}" rx="1"><title>${l}</title></rect>`;let d=[{value:e.output,cls:`output`},{value:e.input,cls:`input`},{value:e.cacheWrite,cls:`cache-write`},{value:e.cacheRead,cls:`cache-read`}],f=j.top+M,p=u?` dimmed`:``;return a`
${d.map(e=>{if(e.value<=0||n<=0)return i;let t=o*(e.value/n);return f-=t,a`<rect x="${r}" y="${f}" width="${ie}" height="${t}" class="ts-bar ${e.cls}${p}" rx="1"><title>${l}</title></rect>`})}
`})}
<!-- Selection highlight overlay (always visible between handles) -->
${a`
<rect
x="${R}"
y="${j.top}"
width="${Math.max(1,oe-R)}"
height="${M}"
fill="var(--accent)"
opacity="${B_}"
pointer-events="none"
/>
`}
<!-- Left cursor line + handle -->
${a`
<line x1="${R}" y1="${j.top}" x2="${R}" y2="${j.top+M}" stroke="var(--accent)" stroke-width="0.8" opacity="0.7" />
<rect x="${R-V_/2}" y="${j.top+M/2-H_/2}" width="${V_}" height="${H_}" rx="1.5" fill="var(--accent)" class="cursor-handle" />
<line x1="${R-U_}" y1="${j.top+M/2-H_/5}" x2="${R-U_}" y2="${j.top+M/2+H_/5}" stroke="var(--bg)" stroke-width="0.4" pointer-events="none" />
<line x1="${R+U_}" y1="${j.top+M/2-H_/5}" x2="${R+U_}" y2="${j.top+M/2+H_/5}" stroke="var(--bg)" stroke-width="0.4" pointer-events="none" />
`}
<!-- Right cursor line + handle -->
${a`
<line x1="${oe}" y1="${j.top}" x2="${oe}" y2="${j.top+M}" stroke="var(--accent)" stroke-width="0.8" opacity="0.7" />
<rect x="${oe-V_/2}" y="${j.top+M/2-H_/2}" width="${V_}" height="${H_}" rx="1.5" fill="var(--accent)" class="cursor-handle" />
<line x1="${oe-U_}" y1="${j.top+M/2-H_/5}" x2="${oe-U_}" y2="${j.top+M/2+H_/5}" stroke="var(--bg)" stroke-width="0.4" pointer-events="none" />
<line x1="${oe+U_}" y1="${j.top+M/2-H_/5}" x2="${oe+U_}" y2="${j.top+M/2+H_/5}" stroke="var(--bg)" stroke-width="0.4" pointer-events="none" />
`}
</svg>
<!-- Handle drag zones (only on handles, not full chart) -->
${(()=>{let e=`${(R/400*100).toFixed(1)}%`,t=`${(oe/400*100).toFixed(1)}%`,r=e=>t=>{if(!m)return;t.preventDefault(),t.stopPropagation();let n=t.currentTarget.closest(`.timeseries-chart-wrapper`)?.querySelector(`svg`);if(!n)return;let r=n.getBoundingClientRect(),i=r.width,a=j.left/400*i,o=(400-j.right)/400*i-a,s=e=>{let t=Math.max(0,Math.min(1,(e-r.left-a)/o));return Math.min(Math.floor(t*h.length),h.length-1)},c=e===`left`?R:oe,l=r.left+c/400*i,u=t.clientX-l;document.body.style.cursor=`col-resize`;let d=t=>{let n=s(t.clientX-u),r=h[n];if(r)if(e===`left`){let e=p??h[h.length-1].timestamp;m(Math.min(r.timestamp,e),e)}else{let e=f??h[0].timestamp;m(e,Math.max(r.timestamp,e))}},g=()=>{document.body.style.cursor=``,document.removeEventListener(`mousemove`,d),document.removeEventListener(`mouseup`,g)};document.addEventListener(`mousemove`,d),document.addEventListener(`mouseup`,g)};return n`
<div class="chart-handle-zone chart-handle-left"
style="left: ${e};"
@mousedown=${r(`left`)}></div>
<div class="chart-handle-zone chart-handle-right"
style="left: ${t};"
@mousedown=${r(`right`)}></div>
`})()}
</div>
<div class="timeseries-summary">
${S?n`
<span class="timeseries-summary__range">
${P(`usage.details.turnRange`,{start:String(T+1),end:String(E),total:String(h.length)})}
</span> ·
${new Date(C).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}–${new Date(w).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})} ·
${Z(O+k+A+ee)} ·
${Q(D.reduce((e,t)=>e+(t.cost||0),0))}
`:n`${h.length} ${P(`usage.overview.messagesAbbrev`)} · ${Z(g)} · ${Q(_)}`}
</div>
${re?n`
<div class="timeseries-breakdown">
<div class="card-title usage-section-title">${P(`usage.breakdown.tokensByType`)}</div>
<div class="cost-breakdown-bar cost-breakdown-bar--compact">
<div class="cost-segment output" style="width: ${W_(O,N).toFixed(1)}%"></div>
<div class="cost-segment input" style="width: ${W_(k,N).toFixed(1)}%"></div>
<div class="cost-segment cache-write" style="width: ${W_(ee,N).toFixed(1)}%"></div>
<div class="cost-segment cache-read" style="width: ${W_(A,N).toFixed(1)}%"></div>
</div>
<div class="cost-breakdown-legend">
<div class="legend-item" title=${P(`usage.details.assistantOutputTokens`)}>
<span class="legend-dot output"></span>${P(`usage.breakdown.output`)} ${Z(O)}
</div>
<div class="legend-item" title=${P(`usage.details.userToolInputTokens`)}>
<span class="legend-dot input"></span>${P(`usage.breakdown.input`)} ${Z(k)}
</div>
<div class="legend-item" title=${P(`usage.details.tokensWrittenToCache`)}>
<span class="legend-dot cache-write"></span>${P(`usage.breakdown.cacheWrite`)} ${Z(ee)}
</div>
<div class="legend-item" title=${P(`usage.details.tokensReadFromCache`)}>
<span class="legend-dot cache-read"></span>${P(`usage.breakdown.cacheRead`)} ${Z(A)}
</div>
</div>
<div class="cost-breakdown-total">
${P(`usage.breakdown.total`)}: ${Z(N)}
</div>
</div>
`:i}
</div>
`}function Z_(e,t,r,a){if(!e)return n`
<div class="context-details-panel">
<div class="usage-empty-block">${P(`usage.details.noContextData`)}</div>
</div>
`;let o=n_(e.systemPrompt.chars),s=n_(e.skills.promptChars),c=n_(e.tools.listChars+e.tools.schemaChars),l=n_(e.injectedWorkspaceFiles.reduce((e,t)=>e+t.injectedChars,0)),u=o+s+c+l,d=``;if(t&&t.totalTokens>0){let e=t.input+t.cacheRead;e>0&&(d=`~${Math.min(u/e*100,100).toFixed(0)}% ${P(`usage.details.ofInput`)}`)}let f=e.skills.entries.toSorted((e,t)=>t.blockChars-e.blockChars),p=e.tools.entries.toSorted((e,t)=>t.summaryChars+t.schemaChars-(e.summaryChars+e.schemaChars)),m=e.injectedWorkspaceFiles.toSorted((e,t)=>t.injectedChars-e.injectedChars),h=r,g=h?f:f.slice(0,4),_=h?p:p.slice(0,4),v=h?m:m.slice(0,4),y=f.length>4||p.length>4||m.length>4;return n`
<div class="context-details-panel">
<div class="context-breakdown-header">
<div class="card-title usage-section-title">${P(`usage.details.systemPromptBreakdown`)}</div>
${y?n`<button class="btn btn--sm" @click=${a}>
${P(h?`usage.details.collapse`:`usage.details.expandAll`)}
</button>`:i}
</div>
<p class="context-weight-desc">
${d||P(`usage.details.baseContextPerMessage`)}
</p>
<div class="context-stacked-bar">
<div class="context-segment system" style="width: ${W_(o,u).toFixed(1)}%" title="${P(`usage.details.system`)}: ~${Z(o)}"></div>
<div class="context-segment skills" style="width: ${W_(s,u).toFixed(1)}%" title="${P(`usage.details.skills`)}: ~${Z(s)}"></div>
<div class="context-segment tools" style="width: ${W_(c,u).toFixed(1)}%" title="${P(`usage.details.tools`)}: ~${Z(c)}"></div>
<div class="context-segment files" style="width: ${W_(l,u).toFixed(1)}%" title="${P(`usage.details.files`)}: ~${Z(l)}"></div>
</div>
<div class="context-legend">
<span class="legend-item"><span class="legend-dot system"></span>${P(`usage.details.systemShort`)} ~${Z(o)}</span>
<span class="legend-item"><span class="legend-dot skills"></span>${P(`usage.details.skills`)} ~${Z(s)}</span>
<span class="legend-item"><span class="legend-dot tools"></span>${P(`usage.details.tools`)} ~${Z(c)}</span>
<span class="legend-item"><span class="legend-dot files"></span>${P(`usage.details.files`)} ~${Z(l)}</span>
</div>
<div class="context-total">${P(`usage.breakdown.total`)}: ~${Z(u)}</div>
<div class="context-breakdown-grid">
${f.length>0?(()=>{let e=f.length-g.length;return n`
<div class="context-breakdown-card">
<div class="context-breakdown-title">
${P(`usage.details.skills`)} (${f.length})
</div>
<div class="context-breakdown-list">
${g.map(e=>n`
<div class="context-breakdown-item">
<span class="mono">${e.name}</span>
<span class="muted">~${Z(n_(e.blockChars))}</span>
</div>
`)}
</div>
${e>0?n`
<div class="context-breakdown-more">
${P(`usage.sessions.more`,{count:String(e)})}
</div>
`:i}
</div>
`})():i}
${p.length>0?(()=>{let e=p.length-_.length;return n`
<div class="context-breakdown-card">
<div class="context-breakdown-title">
${P(`usage.details.tools`)} (${p.length})
</div>
<div class="context-breakdown-list">
${_.map(e=>n`
<div class="context-breakdown-item">
<span class="mono">${e.name}</span>
<span class="muted">~${Z(n_(e.summaryChars+e.schemaChars))}</span>
</div>
`)}
</div>
${e>0?n`
<div class="context-breakdown-more">
${P(`usage.sessions.more`,{count:String(e)})}
</div>
`:i}
</div>
`})():i}
${m.length>0?(()=>{let e=m.length-v.length;return n`
<div class="context-breakdown-card">
<div class="context-breakdown-title">
${P(`usage.details.files`)} (${m.length})
</div>
<div class="context-breakdown-list">
${v.map(e=>n`
<div class="context-breakdown-item">
<span class="mono">${e.name}</span>
<span class="muted">~${Z(n_(e.injectedChars))}</span>
</div>
`)}
</div>
${e>0?n`
<div class="context-breakdown-more">
${P(`usage.sessions.more`,{count:String(e)})}
</div>
`:i}
</div>
`})():i}
</div>
</div>
`}function Q_(e,t,r,a,o,s,c,l,u,d,f,p){if(t)return n`
<div class="session-logs-compact">
<div class="session-logs-header">${P(`usage.details.conversation`)}</div>
<div class="usage-empty-block">${P(`usage.loading.badge`)}</div>
</div>
`;if(!e||e.length===0)return n`
<div class="session-logs-compact">
<div class="session-logs-header">${P(`usage.details.conversation`)}</div>
<div class="usage-empty-block">${P(`usage.details.noMessages`)}</div>
</div>
`;let m=o.query.trim().toLowerCase(),h=e.map(e=>{let t=Zg(e.content);return{log:e,toolInfo:t,cleanContent:t.cleanContent||e.content}}),g=Array.from(new Set(h.flatMap(e=>e.toolInfo.tools.map(([e])=>e)))).toSorted((e,t)=>e.localeCompare(t)),_=h.filter(e=>{if(f!=null&&p!=null){let t=e.log.timestamp;if(t>0){let e=Math.min(f,p),n=Math.max(f,p),r=G_(t);if(r<e||r>n)return!1}}return!(o.roles.length>0&&!o.roles.includes(e.log.role)||o.hasTools&&e.toolInfo.tools.length===0||o.tools.length>0&&!e.toolInfo.tools.some(([e])=>o.tools.includes(e))||m&&!e.cleanContent.toLowerCase().includes(m))}),v=o.roles.length>0||o.tools.length>0||o.hasTools||m,y=f!=null&&p!=null,b=v||y?`${_.length} ${P(`usage.details.of`)} ${e.length}${y?` (${P(`usage.details.timelineFiltered`)})`:``}`:`${e.length}`,x=new Set(o.roles),S=new Set(o.tools);return n`
<div class="session-logs-compact">
<div class="session-logs-header">
<span>
${P(`usage.details.conversation`)}
<span class="session-logs-header-count">
(${b} ${P(`usage.overview.messages`).toLowerCase()})
</span>
</span>
<button class="btn btn--sm" @click=${a}>
${P(r?`usage.details.collapseAll`:`usage.details.expandAll`)}
</button>
</div>
<div class="usage-filters-inline session-log-filters">
<select
multiple
size="4"
aria-label="Filter by role"
@change=${e=>s(Array.from(e.target.selectedOptions).map(e=>e.value))}
>
<option value="user" ?selected=${x.has(`user`)}>${P(`usage.overview.user`)}</option>
<option value="assistant" ?selected=${x.has(`assistant`)}>${P(`usage.overview.assistant`)}</option>
<option value="tool" ?selected=${x.has(`tool`)}>${P(`usage.details.tool`)}</option>
<option value="toolResult" ?selected=${x.has(`toolResult`)}>${P(`usage.details.toolResult`)}</option>
</select>
<select
multiple
size="4"
aria-label="Filter by tool"
@change=${e=>c(Array.from(e.target.selectedOptions).map(e=>e.value))}
>
${g.map(e=>n`<option value=${e} ?selected=${S.has(e)}>${e}</option>`)}
</select>
<label class="usage-filters-inline session-log-has-tools">
<input
type="checkbox"
.checked=${o.hasTools}
@change=${e=>l(e.target.checked)}
/>
${P(`usage.details.hasTools`)}
</label>
<input
type="text"
placeholder=${P(`usage.details.searchConversation`)}
aria-label=${P(`usage.details.searchConversation`)}
.value=${o.query}
@input=${e=>u(e.target.value)}
/>
<button class="btn btn--sm" @click=${d}>
${P(`usage.filters.clear`)}
</button>
</div>
<div class="session-logs-list">
${_.map(e=>{let{log:t,toolInfo:a,cleanContent:o}=e;return n`
<div class="session-log-entry ${t.role===`user`?`user`:`assistant`}">
<div class="session-log-meta">
<span class="session-log-role">${t.role===`user`?P(`usage.details.you`):t.role===`assistant`?P(`usage.overview.assistant`):P(`usage.details.tool`)}</span>
<span>${new Date(t.timestamp).toLocaleString()}</span>
${t.tokens?n`<span>${Z(t.tokens)}</span>`:i}
</div>
<div class="session-log-content">${o}</div>
${a.tools.length>0?n`
<details class="session-log-tools" ?open=${r}>
<summary>${a.summary}</summary>
<div class="session-log-tools-list">
${a.tools.map(([e,t])=>n`
<span class="session-log-tools-pill">${e} × ${t}</span>
`)}
</div>
</details>
`:i}
</div>
`})}
${_.length===0?n`
<div class="usage-empty-block usage-empty-block--compact">
${P(`usage.details.noMessagesMatch`)}
</div>
`:i}
</div>
</div>
`}function $_(){return{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,totalCost:0,inputCost:0,outputCost:0,cacheReadCost:0,cacheWriteCost:0,missingCostEntries:0}}function ev(e,t){return e.input+=t.input,e.output+=t.output,e.cacheRead+=t.cacheRead,e.cacheWrite+=t.cacheWrite,e.totalTokens+=t.totalTokens,e.totalCost+=t.totalCost,e.inputCost+=t.inputCost??0,e.outputCost+=t.outputCost??0,e.cacheReadCost+=t.cacheReadCost??0,e.cacheWriteCost+=t.cacheWriteCost??0,e.missingCostEntries+=t.missingCostEntries??0,e}function tv(e){return n`
<section class="card usage-loading-card">
<div class="usage-loading-header">
<div class="usage-loading-title-group">
<div class="card-title usage-section-title">${P(`usage.loading.title`)}</div>
<span class="usage-loading-badge">
<span class="usage-loading-spinner" aria-hidden="true"></span>
${P(`usage.loading.badge`)}
</span>
</div>
<div class="usage-loading-controls">
<div class="usage-date-range usage-date-range--loading">
<input class="usage-date-input" type="date" .value=${e.startDate} disabled />
<span class="usage-separator">${P(`usage.filters.to`)}</span>
<input class="usage-date-input" type="date" .value=${e.endDate} disabled />
</div>
</div>
</div>
<div class="usage-loading-grid">
<div class="usage-skeleton-block usage-skeleton-block--tall"></div>
<div class="usage-skeleton-block"></div>
<div class="usage-skeleton-block"></div>
</div>
</section>
`}function nv(e){return n`
<section class="card usage-empty-state">
<div class="usage-empty-state__title">${P(`usage.empty.title`)}</div>
<div class="card-sub usage-empty-state__subtitle">${P(`usage.empty.subtitle`)}</div>
<div class="usage-empty-state__features">
<span class="usage-empty-state__feature">${P(`usage.empty.featureOverview`)}</span>
<span class="usage-empty-state__feature">${P(`usage.empty.featureSessions`)}</span>
<span class="usage-empty-state__feature">${P(`usage.empty.featureTimeline`)}</span>
</div>
<div class="usage-empty-state__actions">
<button class="btn primary" @click=${e}>
${P(`common.refresh`)}
</button>
</div>
</section>
`}function rv(e){let{data:t,filters:r,display:a,detail:o,callbacks:s}=e,c=s.filters,l=s.display,u=s.details;if(t.loading&&!t.totals)return n`<div class="usage-page">${tv(r)}</div>`;let d=a.chartMode===`tokens`,f=r.query.trim().length>0,p=r.queryDraft.trim().length>0,m=[...t.sessions].toSorted((e,t)=>{let n=d?e.usage?.totalTokens??0:e.usage?.totalCost??0;return(d?t.usage?.totalTokens??0:t.usage?.totalCost??0)-n}),h=r.selectedDays.length>0?m.filter(e=>{if(e.usage?.activityDates?.length)return e.usage.activityDates.some(e=>r.selectedDays.includes(e));if(!e.updatedAt)return!1;let t=new Date(e.updatedAt),n=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`;return r.selectedDays.includes(n)}):m,g=(e,t)=>{if(t.length===0)return!0;let n=e.usage,i=n?.firstActivity??e.updatedAt,a=n?.lastActivity??e.updatedAt;if(!i||!a)return!1;let o=Math.min(i,a),s=Math.max(i,a),c=o;for(;c<=s;){let e=new Date(c),n=a_(e,r.timeZone);if(t.includes(n))return!0;let i=s_(e,r.timeZone);c=Math.min(i.getTime(),s)+1}return!1},_=Xg(r.selectedHours.length>0?h.filter(e=>g(e,r.selectedHours)):h,r.query),v=_.sessions,y=_.warnings,b=C_(r.queryDraft,m,t.aggregates),x=Wg(r.query),S=e=>{let t=T_(e);return x.filter(e=>T_(e.key??``)===t).map(e=>e.value).filter(Boolean)},C=e=>{let t=new Set;for(let n of e)n&&t.add(n);return Array.from(t)},w=C(m.map(e=>e.agentId)).slice(0,12),T=C(m.map(e=>e.channel)).slice(0,12),E=C([...m.map(e=>e.modelProvider),...m.map(e=>e.providerOverride),...t.aggregates?.byProvider.map(e=>e.provider)??[]]).slice(0,12),D=C([...m.map(e=>e.model),...t.aggregates?.byModel.map(e=>e.model)??[]]).slice(0,12),O=C(t.aggregates?.tools.tools.map(e=>e.name)??[]).slice(0,12),k=r.selectedSessions.length===1?t.sessions.find(e=>e.key===r.selectedSessions[0])??v.find(e=>e.key===r.selectedSessions[0]):null,A=e=>e.reduce((e,t)=>t.usage?ev(e,t.usage):e,$_()),ee=e=>t.costDaily.filter(t=>e.includes(t.date)).reduce((e,t)=>ev(e,t),$_()),j,te,M=m.length;if(r.selectedSessions.length>0){let e=v.filter(e=>r.selectedSessions.includes(e.key));j=A(e),te=e.length}else r.selectedDays.length>0&&r.selectedHours.length===0?(j=ee(r.selectedDays),te=v.length):r.selectedHours.length>0||f?(j=A(v),te=v.length):(j=t.totals,te=M);let ne=r.selectedSessions.length>0?v.filter(e=>r.selectedSessions.includes(e.key)):f||r.selectedHours.length>0?v:r.selectedDays.length>0?h:m,re=g_(ne,t.aggregates),N=r.selectedSessions.length>0?(()=>{let e=v.filter(e=>r.selectedSessions.includes(e.key)),n=new Set;for(let t of e)for(let e of t.usage?.activityDates??[])n.add(e);return n.size>0?t.costDaily.filter(e=>n.has(e.date)):t.costDaily})():t.costDaily,F=__(ne,j,re),I=!t.loading&&!t.totals&&t.sessions.length===0,L=(j?.missingCostEntries??0)>0||(j?j.totalTokens>0&&j.totalCost===0&&j.input+j.output+j.cacheRead+j.cacheWrite>0:!1),ie=[{label:P(`usage.presets.today`),days:1},{label:P(`usage.presets.last7d`),days:7},{label:P(`usage.presets.last30d`),days:30}],ae=e=>{let t=new Date,n=new Date;n.setDate(n.getDate()-(e-1)),c.onStartDateChange(u_(n)),c.onEndDateChange(u_(t))},R=(e,t,a)=>{if(a.length===0)return i;let o=S(e),s=new Set(o.map(e=>T_(e))),l=a.length>0&&a.every(e=>s.has(T_(e))),u=o.length;return n`
<details
class="usage-filter-select"
@toggle=${e=>{let t=e.currentTarget;if(!t.open)return;let n=e=>{e.composedPath().includes(t)||(t.open=!1,window.removeEventListener(`click`,n,!0))};window.addEventListener(`click`,n,!0)}}
>
<summary>
<span>${t}</span>
${u>0?n`<span class="usage-filter-badge">${u}</span>`:n`
<span class="usage-filter-badge">${P(`usage.filters.all`)}</span>
`}
</summary>
<div class="usage-filter-popover">
<div class="usage-filter-actions">
<button
class="btn btn--sm"
@click=${t=>{t.preventDefault(),t.stopPropagation(),c.onQueryDraftChange(O_(r.queryDraft,e,a))}}
?disabled=${l}
>
${P(`usage.filters.selectAll`)}
</button>
<button
class="btn btn--sm"
@click=${t=>{t.preventDefault(),t.stopPropagation(),c.onQueryDraftChange(O_(r.queryDraft,e,[]))}}
?disabled=${u===0}
>
${P(`usage.filters.clear`)}
</button>
</div>
<div class="usage-filter-options">
${a.map(t=>n`
<label class="usage-filter-option">
<input
type="checkbox"
.checked=${s.has(T_(t))}
@change=${n=>{let i=n.target,a=`${e}:${t}`;c.onQueryDraftChange(i.checked?E_(r.queryDraft,a):D_(r.queryDraft,a))}}
/>
<span>${t}</span>
</label>
`)}
</div>
</div>
</details>
`},oe=u_(new Date);return n`
<div class="usage-page">
<section class="usage-page-header">
<div class="usage-page-title">${P(`tabs.usage`)}</div>
<div class="usage-page-subtitle">${P(`usage.page.subtitle`)}</div>
</section>
<section class="card usage-header ${a.headerPinned?`pinned`:``}">
<div class="usage-header-row">
<div class="usage-header-title">
<div class="card-title usage-section-title">${P(`usage.filters.title`)}</div>
${t.loading?n`<span class="usage-refresh-indicator">${P(`usage.loading.badge`)}</span>`:i}
${I?n`<span class="usage-query-hint">${P(`usage.empty.hint`)}</span>`:i}
</div>
<div class="usage-header-metrics">
${j?n`
<span class="usage-metric-badge">
<strong>${Z(j.totalTokens)}</strong>
${P(`usage.metrics.tokens`)}
</span>
<span class="usage-metric-badge">
<strong>${Q(j.totalCost)}</strong>
${P(`usage.metrics.cost`)}
</span>
<span class="usage-metric-badge">
<strong>${te}</strong>
${P(te===1?`usage.metrics.session`:`usage.metrics.sessions`)}
</span>
`:i}
<button
class="btn btn--sm usage-pin-btn ${a.headerPinned?`active`:``}"
title=${a.headerPinned?P(`usage.filters.unpin`):P(`usage.filters.pin`)}
@click=${c.onToggleHeaderPinned}
>
${a.headerPinned?P(`usage.filters.pinned`):P(`usage.filters.pin`)}
</button>
<details
class="usage-export-menu"
@toggle=${e=>{let t=e.currentTarget;if(!t.open)return;let n=e=>{e.composedPath().includes(t)||(t.open=!1,window.removeEventListener(`click`,n,!0))};window.addEventListener(`click`,n,!0)}}
>
<summary class="btn btn--sm">${P(`usage.export.label`)} ▾</summary>
<div class="usage-export-popover">
<div class="usage-export-list">
<button
class="usage-export-item"
@click=${()=>v_(`openclaw-usage-sessions-${oe}.csv`,x_(v),`text/csv`)}
?disabled=${v.length===0}
>
${P(`usage.export.sessionsCsv`)}
</button>
<button
class="usage-export-item"
@click=${()=>v_(`openclaw-usage-daily-${oe}.csv`,S_(N),`text/csv`)}
?disabled=${N.length===0}
>
${P(`usage.export.dailyCsv`)}
</button>
<button
class="usage-export-item"
@click=${()=>v_(`openclaw-usage-${oe}.json`,JSON.stringify({totals:j,sessions:v,daily:N,aggregates:re},null,2),`application/json`)}
?disabled=${v.length===0&&N.length===0}
>
${P(`usage.export.json`)}
</button>
</div>
</div>
</details>
</div>
</div>
<div class="usage-header-row">
<div class="usage-controls">
${j_(r.selectedDays,r.selectedHours,r.selectedSessions,t.sessions,c.onClearDays,c.onClearHours,c.onClearSessions,c.onClearFilters)}
<div class="usage-presets">
${ie.map(e=>n`
<button class="btn btn--sm" @click=${()=>ae(e.days)}>
${e.label}
</button>
`)}
</div>
<div class="usage-date-range">
<input
class="usage-date-input"
type="date"
.value=${r.startDate}
title=${P(`usage.filters.startDate`)}
@change=${e=>c.onStartDateChange(e.target.value)}
/>
<span class="usage-separator">${P(`usage.filters.to`)}</span>
<input
class="usage-date-input"
type="date"
.value=${r.endDate}
title=${P(`usage.filters.endDate`)}
@change=${e=>c.onEndDateChange(e.target.value)}
/>
</div>
<select
class="usage-select"
title=${P(`usage.filters.timeZone`)}
.value=${r.timeZone}
@change=${e=>c.onTimeZoneChange(e.target.value)}
>
<option value="local">${P(`usage.filters.timeZoneLocal`)}</option>
<option value="utc">${P(`usage.filters.timeZoneUtc`)}</option>
</select>
<div class="chart-toggle">
<button
class="btn btn--sm toggle-btn ${d?`active`:``}"
@click=${()=>l.onChartModeChange(`tokens`)}
>
${P(`usage.metrics.tokens`)}
</button>
<button
class="btn btn--sm toggle-btn ${d?``:`active`}"
@click=${()=>l.onChartModeChange(`cost`)}
>
${P(`usage.metrics.cost`)}
</button>
</div>
<button
class="btn btn--sm primary"
@click=${c.onRefresh}
?disabled=${t.loading}
>
${P(`common.refresh`)}
</button>
</div>
</div>
<div class="usage-query-section">
<div class="usage-query-bar">
<input
class="usage-query-input"
type="text"
.value=${r.queryDraft}
placeholder=${P(`usage.query.placeholder`)}
@input=${e=>c.onQueryDraftChange(e.target.value)}
@keydown=${e=>{e.key===`Enter`&&(e.preventDefault(),c.onApplyQuery())}}
/>
<div class="usage-query-actions">
<button
class="btn btn--sm"
@click=${c.onApplyQuery}
?disabled=${t.loading||!p&&!f}
>
${P(`usage.query.apply`)}
</button>
${p||f?n`
<button
class="btn btn--sm"
@click=${c.onClearQuery}
>
${P(`usage.filters.clear`)}
</button>
`:i}
<span class="usage-query-hint">
${f?P(`usage.query.matching`,{shown:String(v.length),total:String(M)}):P(`usage.query.inRange`,{total:String(M)})}
</span>
</div>
</div>
<div class="usage-filter-row">
${R(`agent`,P(`usage.filters.agent`),w)}
${R(`channel`,P(`usage.filters.channel`),T)}
${R(`provider`,P(`usage.filters.provider`),E)}
${R(`model`,P(`usage.filters.model`),D)}
${R(`tool`,P(`usage.filters.tool`),O)}
<span class="usage-query-hint">${P(`usage.query.tip`)}</span>
</div>
${x.length>0?n`
<div class="usage-query-chips">
${x.map(e=>{let t=e.raw;return n`
<span class="usage-query-chip">
${t}
<button
title=${P(`usage.filters.remove`)}
@click=${()=>c.onQueryDraftChange(D_(r.queryDraft,t))}
>
×
</button>
</span>
`})}
</div>
`:i}
${b.length>0?n`
<div class="usage-query-suggestions">
${b.map(e=>n`
<button
class="usage-query-suggestion"
@click=${()=>c.onQueryDraftChange(w_(r.queryDraft,e.value))}
>
${e.label}
</button>
`)}
</div>
`:i}
${y.length>0?n`
<div class="callout warning usage-callout usage-callout--tight">
${y.join(` · `)}
</div>
`:i}
</div>
${t.error?n`<div class="callout danger usage-callout">${t.error}</div>`:i}
${t.sessionsLimitReached?n`
<div class="callout warning usage-callout">
${P(`usage.sessions.limitReached`)}
</div>
`:i}
</section>
${I?nv(c.onRefresh):n`
${L_(j,re,F,L,i_(ne,r.timeZone),te,M)}
${l_(ne,r.timeZone,r.selectedHours,c.onSelectHour)}
<div class="usage-grid">
<div class="usage-grid-column">
<div class="card usage-left-card">
${M_(N,r.selectedDays,a.chartMode,a.dailyChartMode,l.onDailyChartModeChange,c.onSelectDay)}
${j?N_(j,a.chartMode):i}
</div>
${R_(v,r.selectedSessions,r.selectedDays,d,a.sessionSort,a.sessionSortDir,a.recentSessions,a.sessionsTab,u.onSelectSession,l.onSessionSortChange,l.onSessionSortDirChange,l.onSessionsTabChange,a.visibleColumns,M,c.onClearSessions)}
</div>
${k?n`<div class="usage-grid-column">
${Y_(k,o.timeSeries,o.timeSeriesLoading,o.timeSeriesMode,u.onTimeSeriesModeChange,o.timeSeriesBreakdownMode,u.onTimeSeriesBreakdownChange,o.timeSeriesCursorStart,o.timeSeriesCursorEnd,u.onTimeSeriesCursorRangeChange,r.startDate,r.endDate,r.selectedDays,o.sessionLogs,o.sessionLogsLoading,o.sessionLogsExpanded,u.onToggleSessionLogsExpanded,o.logFilters,u.onLogFilterRolesChange,u.onLogFilterToolsChange,u.onLogFilterHasToolsChange,u.onLogFilterQueryChange,u.onLogFilterClear,a.contextExpanded,u.onToggleContextExpanded,c.onClearSessions)}
</div>`:i}
</div>
`}
</div>
`}var iv=null,av=e=>{iv&&clearTimeout(iv),iv=window.setTimeout(()=>void fa(e),400)};function ov(e){return e.tab===`usage`?rv({data:{loading:e.usageLoading,error:e.usageError,sessions:e.usageResult?.sessions??[],sessionsLimitReached:(e.usageResult?.sessions?.length??0)>=1e3,totals:e.usageResult?.totals??null,aggregates:e.usageResult?.aggregates??null,costDaily:e.usageCostSummary?.daily??[]},filters:{startDate:e.usageStartDate,endDate:e.usageEndDate,selectedSessions:e.usageSelectedSessions,selectedDays:e.usageSelectedDays,selectedHours:e.usageSelectedHours,query:e.usageQuery,queryDraft:e.usageQueryDraft,timeZone:e.usageTimeZone},display:{chartMode:e.usageChartMode,dailyChartMode:e.usageDailyChartMode,sessionSort:e.usageSessionSort,sessionSortDir:e.usageSessionSortDir,recentSessions:e.usageRecentSessions,sessionsTab:e.usageSessionsTab,visibleColumns:e.usageVisibleColumns,contextExpanded:e.usageContextExpanded,headerPinned:e.usageHeaderPinned},detail:{timeSeriesMode:e.usageTimeSeriesMode,timeSeriesBreakdownMode:e.usageTimeSeriesBreakdownMode,timeSeries:e.usageTimeSeries,timeSeriesLoading:e.usageTimeSeriesLoading,timeSeriesCursorStart:e.usageTimeSeriesCursorStart,timeSeriesCursorEnd:e.usageTimeSeriesCursorEnd,sessionLogs:e.usageSessionLogs,sessionLogsLoading:e.usageSessionLogsLoading,sessionLogsExpanded:e.usageSessionLogsExpanded,logFilters:{roles:e.usageLogFilterRoles,tools:e.usageLogFilterTools,hasTools:e.usageLogFilterHasTools,query:e.usageLogFilterQuery}},callbacks:{filters:{onStartDateChange:t=>{e.usageStartDate=t,e.usageSelectedDays=[],e.usageSelectedHours=[],e.usageSelectedSessions=[],av(e)},onEndDateChange:t=>{e.usageEndDate=t,e.usageSelectedDays=[],e.usageSelectedHours=[],e.usageSelectedSessions=[],av(e)},onRefresh:()=>fa(e),onTimeZoneChange:t=>{e.usageTimeZone=t,e.usageSelectedDays=[],e.usageSelectedHours=[],e.usageSelectedSessions=[],fa(e)},onToggleHeaderPinned:()=>{e.usageHeaderPinned=!e.usageHeaderPinned},onSelectHour:(t,n)=>{if(n&&e.usageSelectedHours.length>0){let n=Array.from({length:24},(e,t)=>t),r=e.usageSelectedHours[e.usageSelectedHours.length-1],i=n.indexOf(r),a=n.indexOf(t);if(i!==-1&&a!==-1){let[t,r]=i<a?[i,a]:[a,i],o=n.slice(t,r+1);e.usageSelectedHours=[...new Set([...e.usageSelectedHours,...o])]}}else e.usageSelectedHours.includes(t)?e.usageSelectedHours=e.usageSelectedHours.filter(e=>e!==t):e.usageSelectedHours=[...e.usageSelectedHours,t]},onQueryDraftChange:t=>{e.usageQueryDraft=t,e.usageQueryDebounceTimer&&window.clearTimeout(e.usageQueryDebounceTimer),e.usageQueryDebounceTimer=window.setTimeout(()=>{e.usageQuery=e.usageQueryDraft,e.usageQueryDebounceTimer=null},250)},onApplyQuery:()=>{e.usageQueryDebounceTimer&&=(window.clearTimeout(e.usageQueryDebounceTimer),null),e.usageQuery=e.usageQueryDraft},onClearQuery:()=>{e.usageQueryDebounceTimer&&=(window.clearTimeout(e.usageQueryDebounceTimer),null),e.usageQueryDraft=``,e.usageQuery=``},onSelectDay:(t,n)=>{if(n&&e.usageSelectedDays.length>0){let n=(e.usageCostSummary?.daily??[]).map(e=>e.date),r=e.usageSelectedDays[e.usageSelectedDays.length-1],i=n.indexOf(r),a=n.indexOf(t);if(i!==-1&&a!==-1){let[t,r]=i<a?[i,a]:[a,i],o=n.slice(t,r+1);e.usageSelectedDays=[...new Set([...e.usageSelectedDays,...o])]}}else e.usageSelectedDays.includes(t)?e.usageSelectedDays=e.usageSelectedDays.filter(e=>e!==t):e.usageSelectedDays=[t]},onClearDays:()=>{e.usageSelectedDays=[]},onClearHours:()=>{e.usageSelectedHours=[]},onClearSessions:()=>{e.usageSelectedSessions=[],e.usageTimeSeries=null,e.usageSessionLogs=null},onClearFilters:()=>{e.usageSelectedDays=[],e.usageSelectedHours=[],e.usageSelectedSessions=[],e.usageTimeSeries=null,e.usageSessionLogs=null}},display:{onChartModeChange:t=>{e.usageChartMode=t},onDailyChartModeChange:t=>{e.usageDailyChartMode=t},onSessionSortChange:t=>{e.usageSessionSort=t},onSessionSortDirChange:t=>{e.usageSessionSortDir=t},onSessionsTabChange:t=>{e.usageSessionsTab=t},onToggleColumn:t=>{e.usageVisibleColumns.includes(t)?e.usageVisibleColumns=e.usageVisibleColumns.filter(e=>e!==t):e.usageVisibleColumns=[...e.usageVisibleColumns,t]}},details:{onToggleContextExpanded:()=>{e.usageContextExpanded=!e.usageContextExpanded},onToggleSessionLogsExpanded:()=>{e.usageSessionLogsExpanded=!e.usageSessionLogsExpanded},onLogFilterRolesChange:t=>{e.usageLogFilterRoles=t},onLogFilterToolsChange:t=>{e.usageLogFilterTools=t},onLogFilterHasToolsChange:t=>{e.usageLogFilterHasTools=t},onLogFilterQueryChange:t=>{e.usageLogFilterQuery=t},onLogFilterClear:()=>{e.usageLogFilterRoles=[],e.usageLogFilterTools=[],e.usageLogFilterHasTools=!1,e.usageLogFilterQuery=``},onSelectSession:(t,n)=>{if(e.usageTimeSeries=null,e.usageSessionLogs=null,e.usageRecentSessions=[t,...e.usageRecentSessions.filter(e=>e!==t)].slice(0,8),n&&e.usageSelectedSessions.length>0){let n=e.usageChartMode===`tokens`,r=[...e.usageResult?.sessions??[]].toSorted((e,t)=>{let r=n?e.usage?.totalTokens??0:e.usage?.totalCost??0;return(n?t.usage?.totalTokens??0:t.usage?.totalCost??0)-r}).map(e=>e.key),i=e.usageSelectedSessions[e.usageSelectedSessions.length-1],a=r.indexOf(i),o=r.indexOf(t);if(a!==-1&&o!==-1){let[t,n]=a<o?[a,o]:[o,a],i=r.slice(t,n+1);e.usageSelectedSessions=[...new Set([...e.usageSelectedSessions,...i])]}}else e.usageSelectedSessions.length===1&&e.usageSelectedSessions[0]===t?e.usageSelectedSessions=[]:e.usageSelectedSessions=[t];e.usageTimeSeriesCursorStart=null,e.usageTimeSeriesCursorEnd=null,e.usageSelectedSessions.length===1&&(pa(e,e.usageSelectedSessions[0]),ma(e,e.usageSelectedSessions[0]))},onTimeSeriesModeChange:t=>{e.usageTimeSeriesMode=t},onTimeSeriesBreakdownChange:t=>{e.usageTimeSeriesBreakdownMode=t},onTimeSeriesCursorRangeChange:(t,n)=>{e.usageTimeSeriesCursorStart=t,e.usageTimeSeriesCursorEnd=n}}}}):i}function sv(e){let t=e.hello?.snapshot;return t?.sessionDefaults?.mainSessionKey?.trim()||t?.sessionDefaults?.mainKey?.trim()||`main`}function cv(e,t){e.sessionKey=t,e.chatMessage=``,e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:t,lastActiveSessionKey:t})}function lv(e,t,r){let a=ba(t,e.basePath),o=e.tab===t,s=r?.collapsed??e.settings.navCollapsed;return n`
<a
href=${a}
class="nav-item ${o?`nav-item--active`:``}"
@click=${n=>{if(!(n.defaultPrevented||n.button!==0||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey)){if(n.preventDefault(),t===`chat`){let t=sv(e);e.sessionKey!==t&&(cv(e,t),e.loadAssistantIdentity())}e.setTab(t)}}}
title=${wa(t)}
>
<span class="nav-item__icon" aria-hidden="true">${G[Ca(t)]}</span>
${s?i:n`<span class="nav-item__text">${wa(t)}</span>`}
</a>
`}function uv(e){return n`
<span style="position: relative; display: inline-flex; align-items: center;">
<svg
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<circle cx="12" cy="12" r="10"></circle>
<polyline points="12 6 12 12 16 14"></polyline>
</svg>
${e>0?n`<span
style="
position: absolute;
top: -5px;
right: -6px;
background: var(--color-accent, #6366f1);
color: #fff;
border-radius: var(--radius-full);
font-size: 9px;
line-height: 1;
padding: 1px 3px;
pointer-events: none;
"
>${e}</span
>`:``}
</span>
`}function dv(e){let t=Ov(e,e.sessionKey,e.sessionsResult),r=bv(e);return n`
<div class="chat-controls__session-row">
<label class="field chat-controls__session">
<select
.value=${e.sessionKey}
?disabled=${!e.connected||t.length===0}
@change=${t=>{let n=t.target.value;e.sessionKey!==n&&mv(e,n)}}
>
${To(t,e=>e.id,e=>n`<optgroup label=${e.label}>
${To(e.options,e=>e.key,e=>n`<option value=${e.key} title=${e.title}>
${e.label}
</option>`)}
</optgroup>`)}
</select>
</label>
${r}
</div>
`}function fv(e){let t=e.sessionsHideCron??!0,r=t?kv(e.sessionKey,e.sessionsResult):0,i=e.onboarding,a=e.onboarding,o=e.onboarding?!1:e.settings.chatShowThinking,s=e.onboarding?!0:e.settings.chatShowToolCalls,c=e.onboarding?!0:e.settings.chatFocusMode,l=n`
<svg
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path
d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"
></path>
</svg>
`,u=n`
<svg
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"></path>
<path d="M21 3v5h-5"></path>
</svg>
`,d=n`
<svg
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M4 7V4h3"></path>
<path d="M20 7V4h-3"></path>
<path d="M4 17v3h3"></path>
<path d="M20 17v3h-3"></path>
<circle cx="12" cy="12" r="3"></circle>
</svg>
`;return n`
<div class="chat-controls">
<button
class="btn btn--sm btn--icon"
?disabled=${e.chatLoading||!e.connected}
@click=${async()=>{let t=e;t.chatManualRefreshInFlight=!0,t.chatNewMessagesBelow=!1,await t.updateComplete,t.resetToolStream();try{await rg(e,{scheduleScroll:!1}),t.scrollToBottom({smooth:!0})}finally{requestAnimationFrame(()=>{t.chatManualRefreshInFlight=!1,t.chatNewMessagesBelow=!1})}}}
title=${P(`chat.refreshTitle`)}
>
${u}
</button>
<span class="chat-controls__separator">|</span>
<button
class="btn btn--sm btn--icon ${o?`active`:``}"
?disabled=${i}
@click=${()=>{i||e.applySettings({...e.settings,chatShowThinking:!e.settings.chatShowThinking})}}
aria-pressed=${o}
title=${P(i?`chat.onboardingDisabled`:`chat.thinkingToggle`)}
>
${G.brain}
</button>
<button
class="btn btn--sm btn--icon ${s?`active`:``}"
?disabled=${i}
@click=${()=>{i||e.applySettings({...e.settings,chatShowToolCalls:!e.settings.chatShowToolCalls})}}
aria-pressed=${s}
title=${P(i?`chat.onboardingDisabled`:`chat.toolCallsToggle`)}
>
${l}
</button>
<button
class="btn btn--sm btn--icon ${c?`active`:``}"
?disabled=${a}
@click=${()=>{a||e.applySettings({...e.settings,chatFocusMode:!e.settings.chatFocusMode})}}
aria-pressed=${c}
title=${P(a?`chat.onboardingDisabled`:`chat.focusToggle`)}
>
${d}
</button>
<button
class="btn btn--sm btn--icon ${t?`active`:``}"
@click=${()=>{e.sessionsHideCron=!t}}
aria-pressed=${t}
title=${t?r>0?P(`chat.showCronSessionsHidden`,{count:String(r)}):P(`chat.showCronSessions`):P(`chat.hideCronSessions`)}
>
${uv(r)}
</button>
</div>
`}function pv(e){let t=Ov(e,e.sessionKey,e.sessionsResult),r=e.onboarding,i=e.onboarding,a=e.onboarding?!1:e.settings.chatShowThinking,o=e.onboarding?!0:e.settings.chatShowToolCalls,s=e.onboarding?!0:e.settings.chatFocusMode,c=n`
<svg
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path
d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"
></path>
</svg>
`,l=n`
<svg
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M4 7V4h3"></path>
<path d="M20 7V4h-3"></path>
<path d="M4 17v3h3"></path>
<path d="M20 17v3h-3"></path>
<circle cx="12" cy="12" r="3"></circle>
</svg>
`;return n`
<div class="chat-mobile-controls-wrapper">
<button
class="btn btn--sm btn--icon chat-controls-mobile-toggle"
@click=${e=>{e.stopPropagation();let t=e.currentTarget.nextElementSibling;if(t&&t.classList.toggle(`open`)){let e=()=>{t.classList.remove(`open`),document.removeEventListener(`click`,e)};setTimeout(()=>document.addEventListener(`click`,e,{once:!0}),0)}}}
title="Chat settings"
aria-label="Chat settings"
>
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="3"></circle>
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"></path>
</svg>
</button>
<div class="chat-controls-dropdown" @click=${e=>{e.stopPropagation()}}>
<div class="chat-controls">
<label class="field chat-controls__session">
<select
.value=${e.sessionKey}
@change=${t=>{let n=t.target.value;mv(e,n)}}
>
${t.map(e=>n`
<optgroup label=${e.label}>
${e.options.map(e=>n`
<option value=${e.key} title=${e.title}>
${e.label}
</option>
`)}
</optgroup>
`)}
</select>
</label>
<div class="chat-controls__thinking">
<button
class="btn btn--sm btn--icon ${a?`active`:``}"
?disabled=${r}
@click=${()=>{r||e.applySettings({...e.settings,chatShowThinking:!e.settings.chatShowThinking})}}
aria-pressed=${a}
title=${P(`chat.thinkingToggle`)}
>
${G.brain}
</button>
<button
class="btn btn--sm btn--icon ${o?`active`:``}"
?disabled=${r}
@click=${()=>{r||e.applySettings({...e.settings,chatShowToolCalls:!e.settings.chatShowToolCalls})}}
aria-pressed=${o}
title=${P(`chat.toolCallsToggle`)}
>
${c}
</button>
<button
class="btn btn--sm btn--icon ${s?`active`:``}"
?disabled=${i}
@click=${()=>{i||e.applySettings({...e.settings,chatFocusMode:!e.settings.chatFocusMode})}}
aria-pressed=${s}
title=${P(`chat.focusToggle`)}
>
${l}
</button>
</div>
</div>
</div>
</div>
`}function mv(e,t){e.sessionKey=t,e.chatMessage=``,e.chatStream=null,e.chatQueue=[],e.chatStreamStartedAt=null,e.chatRunId=null,e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:t,lastActiveSessionKey:t}),e.loadAssistantIdentity(),im(e,t,!0),Fh(e),hv(e)}async function hv(e){await Ri(e,{activeMinutes:0,limit:0,includeGlobal:!0,includeUnknown:!0})}function gv(e){return e.sessionsResult?.sessions?.find(t=>t.key===e.sessionKey)}function _v(e){let t=e.chatModelOverrides[e.sessionKey];if(t)return nh(t,e.chatModelCatalog??[]);if(t===null)return``;let n=gv(e);return n&&typeof n.model==`string`&&n.model.trim()?rh(n.model,n.modelProvider):``}function vv(e){let t=e.sessionsResult?.defaults;return rh(t?.model,t?.modelProvider)}function yv(e,t,n){let r=new Set,i=[],a=(e,t)=>{let n=e.trim();if(!n)return;let a=n.toLowerCase();r.has(a)||(r.add(a),i.push({value:n,label:t??n}))};for(let t of e){let e=ah(t);a(e.value,e.label)}return t&&a(t),n&&a(n),i}function bv(e){let t=_v(e),r=vv(e),i=yv(e.chatModelCatalog??[],t,r),a=ih(r),o=r?`Default (${a})`:`Default model`,s=e.chatLoading||e.chatSending||!!e.chatRunId||e.chatStream!==null;return n`
<label class="field chat-controls__session chat-controls__model">
<select
data-chat-model-select="true"
aria-label="Chat model"
?disabled=${!e.connected||s||e.chatModelsLoading&&i.length===0||!e.client}
@change=${async t=>{await xv(e,t.target.value.trim())}}
>
<option value="" ?selected=${t===``}>${o}</option>
${To(i,e=>e.value,e=>n`<option value=${e.value} ?selected=${e.value===t}>
${e.label}
</option>`)}
</select>
</label>
`}async function xv(e,t){if(!e.client||!e.connected||_v(e)===t)return;let n=e.sessionKey,r=e.chatModelOverrides[n];e.lastError=null,e.chatModelOverrides={...e.chatModelOverrides,[n]:th(t)};try{await e.client.request(`sessions.patch`,{key:n,model:t||null}),await hv(e)}catch(t){e.chatModelOverrides={...e.chatModelOverrides,[n]:r},e.lastError=`Failed to set model: ${String(t)}`}}var Sv={bluebubbles:`iMessage`,telegram:`Telegram`,discord:`Discord`,signal:`Signal`,slack:`Slack`,whatsapp:`WhatsApp`,matrix:`Matrix`,email:`Email`,sms:`SMS`},Cv=Object.keys(Sv);function wv(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Tv(e){let t=e.toLowerCase();if(e===`main`||e===`agent:main:main`)return{prefix:``,fallbackName:`Main Session`};if(e.includes(`:subagent:`))return{prefix:`Subagent:`,fallbackName:`Subagent:`};if(t.startsWith(`cron:`)||e.includes(`:cron:`))return{prefix:`Cron:`,fallbackName:`Cron Job:`};let n=e.match(/^agent:[^:]+:([^:]+):direct:(.+)$/);if(n){let e=n[1],t=n[2];return{prefix:``,fallbackName:`${Sv[e]??wv(e)} · ${t}`}}let r=e.match(/^agent:[^:]+:([^:]+):group:(.+)$/);if(r){let e=r[1];return{prefix:``,fallbackName:`${Sv[e]??wv(e)} Group`}}for(let t of Cv)if(e===t||e.startsWith(`${t}:`))return{prefix:``,fallbackName:`${Sv[t]} Session`};return{prefix:``,fallbackName:e}}function Ev(e,t){let n=t?.label?.trim()||``,r=t?.displayName?.trim()||``,{prefix:i,fallbackName:a}=Tv(e),o=e=>i?RegExp(`^${i.replace(/[.*+?^${}()|[\\]\\]/g,`\\$&`)}\\s*`,`i`).test(e)?e:`${i} ${e}`:e;return n&&n!==e?o(n):r&&r!==e?o(r):a}function Dv(e){let t=e.trim().toLowerCase();if(!t)return!1;if(t.startsWith(`cron:`))return!0;if(!t.startsWith(`agent:`))return!1;let n=t.split(`:`).filter(Boolean);return n.length<3?!1:n.slice(2).join(`:`).startsWith(`cron:`)}function Ov(e,t,n){let r=n?.sessions??[],i=e.sessionsHideCron??!0,a=new Map;for(let e of r)a.set(e.key,e);let o=new Set,s=new Map,c=(e,t)=>{let n=s.get(e);if(n)return n;let r={id:e,label:t,options:[]};return s.set(e,r),r},l=t=>{if(!t||o.has(t))return;o.add(t);let n=a.get(t),r=rr(t),i=r?c(`agent:${r.agentId.toLowerCase()}`,Av(e,r.agentId)):c(`other`,`Other Sessions`),s=r?.rest?.trim()||t,l=jv(t,n,r?.rest);i.options.push({key:t,label:l,scopeLabel:s,title:t})};for(let e of r)e.key!==t&&(e.kind===`global`||e.kind===`unknown`)||i&&e.key!==t&&Dv(e.key)||l(e.key);l(t);for(let e of s.values()){let t=new Map;for(let n of e.options)t.set(n.label,(t.get(n.label)??0)+1);for(let n of e.options)(t.get(n.label)??0)>1&&n.scopeLabel!==n.label&&(n.label=`${n.label} · ${n.scopeLabel}`)}let u=Array.from(s.values()).flatMap(e=>e.options.map(t=>({groupLabel:e.label,option:t}))),d=new Map(u.map(({option:e})=>[e,e.label])),f=()=>{let e=new Map;for(let{option:t}of u){let n=d.get(t)??t.label;e.set(n,(e.get(n)??0)+1)}return e},p=(e,t)=>{let n=t.trim();return n?e===n||e.endsWith(` · ${n}`)||e.endsWith(` / ${n}`):!1},m=f();for(let{groupLabel:e,option:t}of u){let n=d.get(t)??t.label;if((m.get(n)??0)<=1)continue;let r=`${e} / `;n.startsWith(r)||d.set(t,`${e} / ${n}`)}let h=f();for(let{option:e}of u){let t=d.get(e)??e.label;(h.get(t)??0)<=1||p(t,e.scopeLabel)||d.set(e,`${t} · ${e.scopeLabel}`)}let g=f();for(let{option:e}of u){let t=d.get(e)??e.label;(g.get(t)??0)<=1||d.set(e,`${t} · ${e.key}`)}for(let{option:e}of u)e.label=d.get(e)??e.label;return Array.from(s.values())}function kv(e,t){return t?.sessions?t.sessions.filter(t=>Dv(t.key)&&t.key!==e).length:0}function Av(e,t){let n=t.trim().toLowerCase(),r=(e.agentsList?.agents??[]).find(e=>e.id.trim().toLowerCase()===n),i=r?.identity?.name?.trim()||r?.name?.trim()||``;return i&&i!==t?`${i} (${t})`:t}function jv(e,t,n){let r=n?.trim()||e;if(!t)return r;let i=t.label?.trim()||``,a=t.displayName?.trim()||``;return i&&i!==e||a&&a!==e?Ev(e,t):r}var Mv=[{id:`system`,label:`System`,short:`SYS`},{id:`light`,label:`Light`,short:`LIGHT`},{id:`dark`,label:`Dark`,short:`DARK`}];function Nv(e){let t=e=>e===`system`?G.monitor:e===`light`?G.sun:G.moon,r=(t,n)=>{t!==e.themeMode&&e.setThemeMode(t,{element:n.currentTarget})};return n`
<div class="topbar-theme-mode" role="group" aria-label="Color mode">
${Mv.map(i=>n`
<button
type="button"
class="topbar-theme-mode__btn ${i.id===e.themeMode?`topbar-theme-mode__btn--active`:``}"
title=${i.label}
aria-label="Color mode: ${i.label}"
aria-pressed=${i.id===e.themeMode}
@click=${e=>r(i.id,e)}
>
${t(i.id)}
</button>
`)}
</div>
`}function Pv(e){let t=e.connected?P(`common.online`):P(`common.offline`);return n`
<span
class="sidebar-version__status ${e.connected?`sidebar-connection-status--online`:`sidebar-connection-status--offline`}"
role="img"
aria-live="polite"
aria-label="Gateway status: ${t}"
title="Gateway status: ${t}"
></span>
`}function Fv(e,t){if(!e)return e;let n=e.files.some(e=>e.name===t.name)?e.files.map(e=>e.name===t.name?t:e):[...e.files,t];return{...e,files:n}}async function Iv(e,t){if(!(!e.client||!e.connected||e.agentFilesLoading)){e.agentFilesLoading=!0,e.agentFilesError=null;try{let n=await e.client.request(`agents.files.list`,{agentId:t});n&&(e.agentFilesList=n,e.agentFileActive&&!n.files.some(t=>t.name===e.agentFileActive)&&(e.agentFileActive=null))}catch(t){e.agentFilesError=String(t)}finally{e.agentFilesLoading=!1}}}async function Lv(e,t,n,r){if(!(!e.client||!e.connected||e.agentFilesLoading)&&!(!r?.force&&Object.hasOwn(e.agentFileContents,n))){e.agentFilesLoading=!0,e.agentFilesError=null;try{let i=await e.client.request(`agents.files.get`,{agentId:t,name:n});if(i?.file){let t=i.file.content??``,a=e.agentFileContents[n]??``,o=e.agentFileDrafts[n],s=r?.preserveDraft??!0;e.agentFilesList=Fv(e.agentFilesList,i.file),e.agentFileContents={...e.agentFileContents,[n]:t},(!s||!Object.hasOwn(e.agentFileDrafts,n)||o===a)&&(e.agentFileDrafts={...e.agentFileDrafts,[n]:t})}}catch(t){e.agentFilesError=String(t)}finally{e.agentFilesLoading=!1}}}async function Rv(e,t,n,r){if(!(!e.client||!e.connected||e.agentFileSaving)){e.agentFileSaving=!0,e.agentFilesError=null;try{let i=await e.client.request(`agents.files.set`,{agentId:t,name:n,content:r});i?.file&&(e.agentFilesList=Fv(e.agentFilesList,i.file),e.agentFileContents={...e.agentFileContents,[n]:r},e.agentFileDrafts={...e.agentFileDrafts,[n]:r})}catch(t){e.agentFilesError=String(t)}finally{e.agentFileSaving=!1}}}var zv=class extends c{constructor(...e){super(...e),this.tab=`overview`}createRenderRoot(){return this}render(){return n`
<div class="dashboard-header">
<div class="dashboard-header__breadcrumb">
<span
class="dashboard-header__breadcrumb-link"
@click=${()=>this.dispatchEvent(new CustomEvent(`navigate`,{detail:`overview`,bubbles:!0,composed:!0}))}
>
OpenClaw
</span>
<span class="dashboard-header__breadcrumb-sep">›</span>
<span class="dashboard-header__breadcrumb-current">${wa(this.tab)}</span>
</div>
<div class="dashboard-header__actions">
<slot></slot>
</div>
</div>
`}};Y([x()],zv.prototype,`tab`,void 0),zv=Y([v(`dashboard-header`)],zv);var Bv=[`noopener`,`noreferrer`],Vv=`_blank`;function Hv(e){let t=[],n=new Set(Bv);for(let r of(e??``).split(/\s+/)){let e=r.trim().toLowerCase();!e||n.has(e)||(n.add(e),t.push(e))}return[...Bv,...t].join(` `)}var Uv=[...Gf.map(e=>({id:`slash:${e.name}`,label:`/${e.name}`,icon:e.icon??`terminal`,category:`search`,action:`/${e.name}`,description:e.description})),{id:`nav-overview`,label:`Overview`,icon:`barChart`,category:`navigation`,action:`nav:overview`},{id:`nav-sessions`,label:`Sessions`,icon:`fileText`,category:`navigation`,action:`nav:sessions`},{id:`nav-cron`,label:`Scheduled`,icon:`scrollText`,category:`navigation`,action:`nav:cron`},{id:`nav-skills`,label:`Skills`,icon:`zap`,category:`navigation`,action:`nav:skills`},{id:`nav-config`,label:`Settings`,icon:`settings`,category:`navigation`,action:`nav:config`},{id:`nav-agents`,label:`Agents`,icon:`folder`,category:`navigation`,action:`nav:agents`},{id:`skill-shell`,label:`Shell Command`,icon:`monitor`,category:`skills`,action:`/skill shell`,description:`Run shell`},{id:`skill-debug`,label:`Debug Mode`,icon:`bug`,category:`skills`,action:`/verbose full`,description:`Toggle debug`}];function Wv(e){if(!e)return Uv;let t=e.toLowerCase();return Uv.filter(e=>e.label.toLowerCase().includes(t)||(e.description?.toLowerCase().includes(t)??!1))}function Gv(e){let t=new Map;for(let n of e){let e=t.get(n.category)??[];e.push(n),t.set(n.category,e)}return[...t.entries()]}var Kv=null;function qv(){Kv=document.activeElement}function Jv(){Kv&&Kv instanceof HTMLElement&&requestAnimationFrame(()=>Kv&&Kv.focus()),Kv=null}function Yv(e,t){e.action.startsWith(`nav:`)?t.onNavigate(e.action.slice(4)):t.onSlashCommand(e.action),t.onToggle(),Jv()}function Xv(){requestAnimationFrame(()=>{document.querySelector(`.cmd-palette__item--active`)?.scrollIntoView({block:`nearest`})})}function Zv(e,t){let n=Wv(t.query);if(!(n.length===0&&(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Enter`)))switch(e.key){case`ArrowDown`:e.preventDefault(),t.onActiveIndexChange((t.activeIndex+1)%n.length),Xv();break;case`ArrowUp`:e.preventDefault(),t.onActiveIndexChange((t.activeIndex-1+n.length)%n.length),Xv();break;case`Enter`:e.preventDefault(),n[t.activeIndex]&&Yv(n[t.activeIndex],t);break;case`Escape`:e.preventDefault(),t.onToggle(),Jv();break}}var Qv={search:`Search`,navigation:`Navigation`,skills:`Skills`};function $v(e){e&&(qv(),requestAnimationFrame(()=>e.focus()))}function ey(e){if(!e.open)return i;let t=Wv(e.query),r=Gv(t);return n`
<div class="cmd-palette-overlay" @click=${()=>{e.onToggle(),Jv()}}>
<div
class="cmd-palette"
@click=${e=>e.stopPropagation()}
@keydown=${t=>Zv(t,e)}
>
<input
${Co($v)}
class="cmd-palette__input"
placeholder="${P(`overview.palette.placeholder`)}"
.value=${e.query}
@input=${t=>{e.onQueryChange(t.target.value),e.onActiveIndexChange(0)}}
/>
<div class="cmd-palette__results">
${r.length===0?n`<div class="cmd-palette__empty">
<span class="nav-item__icon" style="opacity:0.3;width:20px;height:20px">${G.search}</span>
<span>${P(`overview.palette.noResults`)}</span>
</div>`:r.map(([r,a])=>n`
<div class="cmd-palette__group-label">${Qv[r]??r}</div>
${a.map(r=>{let a=t.indexOf(r);return n`
<div
class="cmd-palette__item ${a===e.activeIndex?`cmd-palette__item--active`:``}"
@click=${t=>{t.stopPropagation(),Yv(r,e)}}
@mouseenter=${()=>e.onActiveIndexChange(a)}
>
<span class="nav-item__icon">${G[r.icon]}</span>
<span>${r.label}</span>
${r.description?n`<span class="cmd-palette__item-desc muted">${r.description}</span>`:i}
</div>
`})}
`)}
</div>
<div class="cmd-palette__footer">
<span><kbd>↑↓</kbd> navigate</span>
<span><kbd>↵</kbd> select</span>
<span><kbd>esc</kbd> close</span>
</div>
</div>
</div>
`}var ty=new Set([`title`,`description`,`default`,`nullable`,`tags`,`x-tags`]);function ny(e){return Object.keys(e??{}).filter(e=>!ty.has(e)).length===0}function ry(e){if(e===void 0)return``;try{return JSON.stringify(e,null,2)??``}catch{return``}}var iy={chevronDown:n`
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
`,plus:n`
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<line x1="12" y1="5" x2="12" y2="19"></line>
<line x1="5" y1="12" x2="19" y2="12"></line>
</svg>
`,minus:n`
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<line x1="5" y1="12" x2="19" y2="12"></line>
</svg>
`,trash:n`
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<polyline points="3 6 5 6 21 6"></polyline>
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
</svg>
`,edit:n`
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path>
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path>
</svg>
`};function ay(e){let t=mn(e.value,e.path,e.hints),n=t&&(e.revealSensitive||(e.isSensitivePathRevealed?.(e.path)??!1));return{isSensitive:t,isRedacted:t&&!n,isRevealed:n,canReveal:t}}function oy(e){let{state:t}=e;return!t.isSensitive||!e.onToggleSensitivePath?i:n`
<button
type="button"
class="btn btn--icon ${t.isRevealed?`active`:``}"
style="width:28px;height:28px;padding:0;"
title=${t.canReveal?t.isRevealed?`Hide value`:`Reveal value`:`Disable stream mode to reveal value`}
aria-label=${t.canReveal?t.isRevealed?`Hide value`:`Reveal value`:`Disable stream mode to reveal value`}
aria-pressed=${t.isRevealed}
?disabled=${e.disabled||!t.canReveal}
@click=${()=>e.onToggleSensitivePath?.(e.path)}
>
${t.isRevealed?G.eye:G.eyeOff}
</button>
`}function sy(e){return!!(e&&(e.text.length>0||e.tags.length>0))}function cy(e){let t=[],n=new Set;return{text:e.trim().replace(/(^|\s)tag:([^\s]+)/gi,(e,r,i)=>{let a=i.trim().toLowerCase();return a&&!n.has(a)&&(n.add(a),t.push(a)),r}).trim().toLowerCase(),tags:t}}function ly(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e){if(typeof r!=`string`)continue;let e=r.trim();if(!e)continue;let i=e.toLowerCase();t.has(i)||(t.add(i),n.push(e))}return n}function uy(e,t,n){let r=rn(e,n),i=r?.label??t.title??an(String(e.at(-1))),a=r?.help??t.description,o=ly(t[`x-tags`]??t.tags),s=ly(r?.tags);return{label:i,help:a,tags:s.length>0?s:o}}function dy(e,t){if(!e)return!0;for(let n of t)if(n&&n.toLowerCase().includes(e))return!0;return!1}function fy(e,t){if(e.length===0)return!0;let n=new Set(t.map(e=>e.toLowerCase()));return e.every(e=>n.has(e))}function py(e){let{schema:t,path:n,hints:r,criteria:i}=e;if(!sy(i))return!0;let{label:a,help:o,tags:s}=uy(n,t,r);if(!fy(i.tags,s))return!1;if(!i.text)return!0;let c=n.filter(e=>typeof e==`string`).join(`.`),l=t.enum&&t.enum.length>0?t.enum.map(e=>String(e)).join(` `):``;return dy(i.text,[a,o,t.title,t.description,c,l])}function my(e){let{schema:t,value:n,path:r,hints:i,criteria:a}=e;if(!sy(a)||py({schema:t,path:r,hints:i,criteria:a}))return!0;let o=U(t);if(o===`object`){let e=n??t.default,o=e&&typeof e==`object`&&!Array.isArray(e)?e:{},s=t.properties??{};for(let[e,t]of Object.entries(s))if(my({schema:t,value:o[e],path:[...r,e],hints:i,criteria:a}))return!0;let c=t.additionalProperties;if(c&&typeof c==`object`){let e=new Set(Object.keys(s));for(let[t,n]of Object.entries(o))if(!e.has(t)&&my({schema:c,value:n,path:[...r,t],hints:i,criteria:a}))return!0}return!1}if(o===`array`){let e=Array.isArray(t.items)?t.items[0]:t.items;if(!e)return!1;let o=Array.isArray(n)?n:Array.isArray(t.default)?t.default:[];if(o.length===0)return!1;for(let t=0;t<o.length;t+=1)if(my({schema:e,value:o[t],path:[...r,t],hints:i,criteria:a}))return!0}return!1}function hy(e){return e.length===0?i:n`
<div class="cfg-tags">
${e.map(e=>n`<span class="cfg-tag">${e}</span>`)}
</div>
`}function gy(e){let{schema:t,value:r,path:a,hints:o,unsupported:s,disabled:c,onPatch:l}=e,u=e.showLabel??!0,d=U(t),{label:f,help:p,tags:m}=uy(a,t,o),h=nn(a),g=e.searchCriteria;if(s.has(h))return n`<div class="cfg-field cfg-field--error">
<div class="cfg-field__label">${f}</div>
<div class="cfg-field__error">Unsupported schema node. Use Raw mode.</div>
</div>`;if(g&&sy(g)&&!my({schema:t,value:r,path:a,hints:o,criteria:g}))return i;if(t.anyOf||t.oneOf){let s=(t.anyOf??t.oneOf??[]).filter(e=>!(e.type===`null`||Array.isArray(e.type)&&e.type.includes(`null`)));if(s.length===1)return gy({...e,schema:s[0]});let d=s.map(e=>{if(e.const!==void 0)return e.const;if(e.enum&&e.enum.length===1)return e.enum[0]}),h=d.every(e=>e!==void 0);if(h&&d.length>0&&d.length<=5){let e=r??t.default;return n`
<div class="cfg-field">
${u?n`<label class="cfg-field__label">${f}</label>`:i}
${p?n`<div class="cfg-field__help">${p}</div>`:i}
${hy(m)}
<div class="cfg-segmented">
${d.map(t=>n`
<button
type="button"
class="cfg-segmented__btn ${t===e||String(t)===String(e)?`active`:``}"
?disabled=${c}
@click=${()=>l(a,t)}
>
${String(t)}
</button>
`)}
</div>
</div>
`}if(h&&d.length>5)return yy({...e,options:d,value:r??t.default});let g=new Set(s.map(e=>U(e)).filter(Boolean)),_=new Set([...g].map(e=>e===`integer`?`number`:e));if([..._].every(e=>[`string`,`number`,`boolean`].includes(e))){let n=_.has(`string`),r=_.has(`number`);if(_.has(`boolean`)&&_.size===1)return gy({...e,schema:{...t,type:`boolean`,anyOf:void 0,oneOf:void 0}});if(n||r)return _y({...e,inputType:r&&!n?`number`:`text`})}return by({schema:t,value:r,path:a,hints:o,disabled:c,showLabel:u,revealSensitive:e.revealSensitive??!1,isSensitivePathRevealed:e.isSensitivePathRevealed,onToggleSensitivePath:e.onToggleSensitivePath,onPatch:l})}if(t.enum){let o=t.enum;if(o.length<=5){let e=r??t.default;return n`
<div class="cfg-field">
${u?n`<label class="cfg-field__label">${f}</label>`:i}
${p?n`<div class="cfg-field__help">${p}</div>`:i}
${hy(m)}
<div class="cfg-segmented">
${o.map(t=>n`
<button
type="button"
class="cfg-segmented__btn ${t===e||String(t)===String(e)?`active`:``}"
?disabled=${c}
@click=${()=>l(a,t)}
>
${String(t)}
</button>
`)}
</div>
</div>
`}return yy({...e,options:o,value:r??t.default})}if(d===`object`)return xy(e);if(d===`array`)return Sy(e);if(d===`boolean`){let e=typeof r==`boolean`?r:typeof t.default==`boolean`?t.default:!1;return n`
<label class="cfg-toggle-row ${c?`disabled`:``}">
<div class="cfg-toggle-row__content">
<span class="cfg-toggle-row__label">${f}</span>
${p?n`<span class="cfg-toggle-row__help">${p}</span>`:i}
${hy(m)}
</div>
<div class="cfg-toggle">
<input
type="checkbox"
.checked=${e}
?disabled=${c}
@change=${e=>l(a,e.target.checked)}
/>
<span class="cfg-toggle__track"></span>
</div>
</label>
`}return d===`number`||d===`integer`?vy(e):d===`string`?_y({...e,inputType:`text`}):n`
<div class="cfg-field cfg-field--error">
<div class="cfg-field__label">${f}</div>
<div class="cfg-field__error">Unsupported type: ${d}. Use Raw mode.</div>
</div>
`}function _y(e){let{schema:t,value:r,path:a,hints:o,disabled:s,onPatch:c,inputType:l}=e,u=e.showLabel??!0,d=rn(a,o),{label:f,help:p,tags:m}=uy(a,t,o),h=ay({path:a,value:r,hints:o,revealSensitive:e.revealSensitive??!1,isSensitivePathRevealed:e.isSensitivePathRevealed}),g=h.isRedacted?ln:d?.placeholder??(t.default===void 0?``:`Default: ${String(t.default)}`),_=h.isRedacted?``:r??``,v=h.isSensitive&&!h.isRedacted?`text`:l;return n`
<div class="cfg-field">
${u?n`<label class="cfg-field__label">${f}</label>`:i}
${p?n`<div class="cfg-field__help">${p}</div>`:i}
${hy(m)}
<div class="cfg-input-wrap">
<input
type=${v}
class="cfg-input${h.isRedacted?` cfg-input--redacted`:``}"
placeholder=${g}
.value=${_==null?``:String(_)}
?disabled=${s}
?readonly=${h.isRedacted}
@click=${()=>{h.isRedacted&&e.onToggleSensitivePath&&e.onToggleSensitivePath(a)}}
@input=${e=>{if(h.isRedacted)return;let t=e.target.value;if(l===`number`){if(t.trim()===``){c(a,void 0);return}let e=Number(t);c(a,Number.isNaN(e)?t:e);return}c(a,t)}}
@change=${e=>{if(l===`number`||h.isRedacted)return;let t=e.target.value;c(a,t.trim())}}
/>
${oy({path:a,state:h,disabled:s,onToggleSensitivePath:e.onToggleSensitivePath})}
${t.default===void 0?i:n`
<button
type="button"
class="cfg-input__reset"
title="Reset to default"
?disabled=${s||h.isRedacted}
@click=${()=>c(a,t.default)}
>↺</button>
`}
</div>
</div>
`}function vy(e){let{schema:t,value:r,path:a,hints:o,disabled:s,onPatch:c}=e,l=e.showLabel??!0,{label:u,help:d,tags:f}=uy(a,t,o),p=r??t.default??``,m=typeof p==`number`?p:0;return n`
<div class="cfg-field">
${l?n`<label class="cfg-field__label">${u}</label>`:i}
${d?n`<div class="cfg-field__help">${d}</div>`:i}
${hy(f)}
<div class="cfg-number">
<button
type="button"
class="cfg-number__btn"
?disabled=${s}
@click=${()=>c(a,m-1)}
>−</button>
<input
type="number"
class="cfg-number__input"
.value=${p==null?``:String(p)}
?disabled=${s}
@input=${e=>{let t=e.target.value;c(a,t===``?void 0:Number(t))}}
/>
<button
type="button"
class="cfg-number__btn"
?disabled=${s}
@click=${()=>c(a,m+1)}
>+</button>
</div>
</div>
`}function yy(e){let{schema:t,value:r,path:a,hints:o,disabled:s,options:c,onPatch:l}=e,u=e.showLabel??!0,{label:d,help:f,tags:p}=uy(a,t,o),m=r??t.default,h=c.findIndex(e=>e===m||String(e)===String(m)),g=`__unset__`;return n`
<div class="cfg-field">
${u?n`<label class="cfg-field__label">${d}</label>`:i}
${f?n`<div class="cfg-field__help">${f}</div>`:i}
${hy(p)}
<select
class="cfg-select"
?disabled=${s}
.value=${h>=0?String(h):g}
@change=${e=>{let t=e.target.value;l(a,t===g?void 0:c[Number(t)])}}
>
<option value=${g}>Select...</option>
${c.map((e,t)=>n`
<option value=${String(t)}>${String(e)}</option>
`)}
</select>
</div>
`}function by(e){let{schema:t,value:r,path:a,hints:o,disabled:s,onPatch:c}=e,l=e.showLabel??!0,{label:u,help:d,tags:f}=uy(a,t,o),p=ry(r),m=ay({path:a,value:r,hints:o,revealSensitive:e.revealSensitive??!1,isSensitivePathRevealed:e.isSensitivePathRevealed}),h=m.isRedacted?``:p;return n`
<div class="cfg-field">
${l?n`<label class="cfg-field__label">${u}</label>`:i}
${d?n`<div class="cfg-field__help">${d}</div>`:i}
${hy(f)}
<div class="cfg-input-wrap">
<textarea
class="cfg-textarea${m.isRedacted?` cfg-textarea--redacted`:``}"
placeholder=${m.isRedacted?ln:`JSON value`}
rows="3"
.value=${h}
?disabled=${s}
?readonly=${m.isRedacted}
@click=${()=>{m.isRedacted&&e.onToggleSensitivePath&&e.onToggleSensitivePath(a)}}
@change=${e=>{if(m.isRedacted)return;let t=e.target,n=t.value.trim();if(!n){c(a,void 0);return}try{c(a,JSON.parse(n))}catch{t.value=p}}}
></textarea>
${oy({path:a,state:m,disabled:s,onToggleSensitivePath:e.onToggleSensitivePath})}
</div>
</div>
`}function xy(e){let{schema:t,value:r,path:a,hints:o,unsupported:s,disabled:c,onPatch:l,searchCriteria:u,revealSensitive:d,isSensitivePathRevealed:f,onToggleSensitivePath:p}=e,m=e.showLabel??!0,{label:h,help:g,tags:_}=uy(a,t,o),v=u&&sy(u)&&py({schema:t,path:a,hints:o,criteria:u})?void 0:u,y=r??t.default,b=y&&typeof y==`object`&&!Array.isArray(y)?y:{},x=t.properties??{},S=Object.entries(x).toSorted((e,t)=>{let n=rn([...a,e[0]],o)?.order??0,r=rn([...a,t[0]],o)?.order??0;return n===r?e[0].localeCompare(t[0]):n-r}),C=new Set(Object.keys(x)),w=t.additionalProperties,T=!!w&&typeof w==`object`,E=n`
${S.map(([e,t])=>gy({schema:t,value:b[e],path:[...a,e],hints:o,unsupported:s,disabled:c,searchCriteria:v,revealSensitive:d,isSensitivePathRevealed:f,onToggleSensitivePath:p,onPatch:l}))}
${T?Cy({schema:w,value:b,path:a,hints:o,unsupported:s,disabled:c,reservedKeys:C,searchCriteria:v,revealSensitive:d,isSensitivePathRevealed:f,onToggleSensitivePath:p,onPatch:l}):i}
`;return a.length===1?n`
<div class="cfg-fields">
${E}
</div>
`:m?n`
<details class="cfg-object" ?open=${a.length<=2}>
<summary class="cfg-object__header">
<span class="cfg-object__title-wrap">
<span class="cfg-object__title">${h}</span>
${hy(_)}
</span>
<span class="cfg-object__chevron">${iy.chevronDown}</span>
</summary>
${g?n`<div class="cfg-object__help">${g}</div>`:i}
<div class="cfg-object__content">
${E}
</div>
</details>
`:n`
<div class="cfg-fields cfg-fields--inline">
${E}
</div>
`}function Sy(e){let{schema:t,value:r,path:a,hints:o,unsupported:s,disabled:c,onPatch:l,searchCriteria:u,revealSensitive:d,isSensitivePathRevealed:f,onToggleSensitivePath:p}=e,m=e.showLabel??!0,{label:h,help:g,tags:_}=uy(a,t,o),v=u&&sy(u)&&py({schema:t,path:a,hints:o,criteria:u})?void 0:u,y=Array.isArray(t.items)?t.items[0]:t.items;if(!y)return n`
<div class="cfg-field cfg-field--error">
<div class="cfg-field__label">${h}</div>
<div class="cfg-field__error">Unsupported array schema. Use Raw mode.</div>
</div>
`;let b=Array.isArray(r)?r:Array.isArray(t.default)?t.default:[];return n`
<div class="cfg-array">
<div class="cfg-array__header">
<div class="cfg-array__title">
${m?n`<span class="cfg-array__label">${h}</span>`:i}
${hy(_)}
</div>
<span class="cfg-array__count">${b.length} item${b.length===1?``:`s`}</span>
<button
type="button"
class="cfg-array__add"
?disabled=${c}
@click=${()=>{l(a,[...b,tn(y)])}}
>
<span class="cfg-array__add-icon">${iy.plus}</span>
Add
</button>
</div>
${g?n`<div class="cfg-array__help">${g}</div>`:i}
${b.length===0?n`
<div class="cfg-array__empty">No items yet. Click "Add" to create one.</div>
`:n`
<div class="cfg-array__items">
${b.map((e,t)=>n`
<div class="cfg-array__item">
<div class="cfg-array__item-header">
<span class="cfg-array__item-index">#${t+1}</span>
<button
type="button"
class="cfg-array__item-remove"
title="Remove item"
?disabled=${c}
@click=${()=>{let e=[...b];e.splice(t,1),l(a,e)}}
>
${iy.trash}
</button>
</div>
<div class="cfg-array__item-content">
${gy({schema:y,value:e,path:[...a,t],hints:o,unsupported:s,disabled:c,searchCriteria:v,showLabel:!1,revealSensitive:d,isSensitivePathRevealed:f,onToggleSensitivePath:p,onPatch:l})}
</div>
</div>
`)}
</div>
`}
</div>
`}function Cy(e){let{schema:t,value:r,path:i,hints:a,unsupported:o,disabled:s,reservedKeys:c,onPatch:l,searchCriteria:u,revealSensitive:d,isSensitivePathRevealed:f,onToggleSensitivePath:p}=e,m=ny(t),h=Object.entries(r??{}).filter(([e])=>!c.has(e)),g=u&&sy(u)?h.filter(([e,n])=>my({schema:t,value:n,path:[...i,e],hints:a,criteria:u})):h;return n`
<div class="cfg-map">
<div class="cfg-map__header">
<span class="cfg-map__label">Custom entries</span>
<button
type="button"
class="cfg-map__add"
?disabled=${s}
@click=${()=>{let e={...r},n=1,a=`custom-${n}`;for(;a in e;)n+=1,a=`custom-${n}`;e[a]=m?{}:tn(t),l(i,e)}}
>
<span class="cfg-map__add-icon">${iy.plus}</span>
Add Entry
</button>
</div>
${g.length===0?n`
<div class="cfg-map__empty">No custom entries.</div>
`:n`
<div class="cfg-map__items">
${g.map(([e,c])=>{let h=[...i,e],g=ry(c),_=ay({path:h,value:c,hints:a,revealSensitive:d??!1,isSensitivePathRevealed:f});return n`
<div class="cfg-map__item">
<div class="cfg-map__item-header">
<div class="cfg-map__item-key">
<input
type="text"
class="cfg-input cfg-input--sm"
placeholder="Key"
.value=${e}
?disabled=${s}
@change=${t=>{let n=t.target.value.trim();if(!n||n===e)return;let a={...r};n in a||(a[n]=a[e],delete a[e],l(i,a))}}
/>
</div>
<button
type="button"
class="cfg-map__item-remove"
title="Remove entry"
?disabled=${s}
@click=${()=>{let t={...r};delete t[e],l(i,t)}}
>
${iy.trash}
</button>
</div>
<div class="cfg-map__item-value">
${m?n`
<div class="cfg-input-wrap">
<textarea
class="cfg-textarea cfg-textarea--sm${_.isRedacted?` cfg-textarea--redacted`:``}"
placeholder=${_.isRedacted?ln:`JSON value`}
rows="2"
.value=${_.isRedacted?``:g}
?disabled=${s}
?readonly=${_.isRedacted}
@click=${()=>{_.isRedacted&&p&&p(h)}}
@change=${e=>{if(_.isRedacted)return;let t=e.target,n=t.value.trim();if(!n){l(h,void 0);return}try{l(h,JSON.parse(n))}catch{t.value=g}}}
></textarea>
${oy({path:h,state:_,disabled:s,onToggleSensitivePath:p})}
</div>
`:gy({schema:t,value:c,path:h,hints:a,unsupported:o,disabled:s,searchCriteria:u,showLabel:!1,revealSensitive:d,isSensitivePathRevealed:f,onToggleSensitivePath:p,onPatch:l})}
</div>
</div>
`})}
</div>
`}
</div>
`}var wy={env:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<circle cx="12" cy="12" r="3"></circle>
<path
d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"
></path>
</svg>
`,update:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
<polyline points="7 10 12 15 17 10"></polyline>
<line x1="12" y1="15" x2="12" y2="3"></line>
</svg>
`,agents:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path
d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2z"
></path>
<circle cx="8" cy="14" r="1"></circle>
<circle cx="16" cy="14" r="1"></circle>
</svg>
`,auth:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
<path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
</svg>
`,channels:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
</svg>
`,messages:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path>
<polyline points="22,6 12,13 2,6"></polyline>
</svg>
`,commands:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<polyline points="4 17 10 11 4 5"></polyline>
<line x1="12" y1="19" x2="20" y2="19"></line>
</svg>
`,hooks:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path>
<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path>
</svg>
`,skills:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<polygon
points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"
></polygon>
</svg>
`,tools:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path
d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"
></path>
</svg>
`,gateway:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<circle cx="12" cy="12" r="10"></circle>
<line x1="2" y1="12" x2="22" y2="12"></line>
<path
d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"
></path>
</svg>
`,wizard:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M15 4V2"></path>
<path d="M15 16v-2"></path>
<path d="M8 9h2"></path>
<path d="M20 9h2"></path>
<path d="M17.8 11.8 19 13"></path>
<path d="M15 9h0"></path>
<path d="M17.8 6.2 19 5"></path>
<path d="m3 21 9-9"></path>
<path d="M12.2 6.2 11 5"></path>
</svg>
`,meta:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M12 20h9"></path>
<path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"></path>
</svg>
`,logging:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
<polyline points="14 2 14 8 20 8"></polyline>
<line x1="16" y1="13" x2="8" y2="13"></line>
<line x1="16" y1="17" x2="8" y2="17"></line>
<polyline points="10 9 9 9 8 9"></polyline>
</svg>
`,browser:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<circle cx="12" cy="12" r="10"></circle>
<circle cx="12" cy="12" r="4"></circle>
<line x1="21.17" y1="8" x2="12" y2="8"></line>
<line x1="3.95" y1="6.06" x2="8.54" y2="14"></line>
<line x1="10.88" y1="21.94" x2="15.46" y2="14"></line>
</svg>
`,ui:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
<line x1="3" y1="9" x2="21" y2="9"></line>
<line x1="9" y1="21" x2="9" y2="9"></line>
</svg>
`,models:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path
d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"
></path>
<polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline>
<line x1="12" y1="22.08" x2="12" y2="12"></line>
</svg>
`,bindings:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect>
<rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect>
<line x1="6" y1="6" x2="6.01" y2="6"></line>
<line x1="6" y1="18" x2="6.01" y2="18"></line>
</svg>
`,broadcast:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"></path>
<path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5"></path>
<circle cx="12" cy="12" r="2"></circle>
<path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5"></path>
<path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"></path>
</svg>
`,audio:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M9 18V5l12-2v13"></path>
<circle cx="6" cy="18" r="3"></circle>
<circle cx="18" cy="16" r="3"></circle>
</svg>
`,session:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
<circle cx="9" cy="7" r="4"></circle>
<path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
<path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
</svg>
`,cron:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<circle cx="12" cy="12" r="10"></circle>
<polyline points="12 6 12 12 16 14"></polyline>
</svg>
`,web:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<circle cx="12" cy="12" r="10"></circle>
<line x1="2" y1="12" x2="22" y2="12"></line>
<path
d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"
></path>
</svg>
`,discovery:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<circle cx="11" cy="11" r="8"></circle>
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
</svg>
`,canvasHost:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
<circle cx="8.5" cy="8.5" r="1.5"></circle>
<polyline points="21 15 16 10 5 21"></polyline>
</svg>
`,talk:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path>
<path d="M19 10v2a7 7 0 0 1-14 0v-2"></path>
<line x1="12" y1="19" x2="12" y2="23"></line>
<line x1="8" y1="23" x2="16" y2="23"></line>
</svg>
`,plugins:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M12 2v6"></path>
<path d="m4.93 10.93 4.24 4.24"></path>
<path d="M2 12h6"></path>
<path d="m4.93 13.07 4.24-4.24"></path>
<path d="M12 22v-6"></path>
<path d="m19.07 13.07-4.24-4.24"></path>
<path d="M22 12h-6"></path>
<path d="m19.07 10.93-4.24 4.24"></path>
</svg>
`,diagnostics:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline>
</svg>
`,cli:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<polyline points="4 17 10 11 4 5"></polyline>
<line x1="12" y1="19" x2="20" y2="19"></line>
</svg>
`,secrets:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path
d="m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"
></path>
</svg>
`,acp:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
<circle cx="9" cy="7" r="4"></circle>
<path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
<path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
</svg>
`,mcp:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect>
<rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect>
<line x1="6" y1="6" x2="6.01" y2="6"></line>
<line x1="6" y1="18" x2="6.01" y2="18"></line>
</svg>
`,default:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
<polyline points="14 2 14 8 20 8"></polyline>
</svg>
`},Ty={env:{label:`Environment Variables`,description:`Environment variables passed to the gateway process`},update:{label:`Updates`,description:`Auto-update settings and release channel`},agents:{label:`Agents`,description:`Agent configurations, models, and identities`},auth:{label:`Authentication`,description:`API keys and authentication profiles`},channels:{label:`Channels`,description:`Messaging channels (Telegram, Discord, Slack, etc.)`},messages:{label:`Messages`,description:`Message handling and routing settings`},commands:{label:`Commands`,description:`Custom slash commands`},hooks:{label:`Hooks`,description:`Webhooks and event hooks`},skills:{label:`Skills`,description:`Skill packs and capabilities`},tools:{label:`Tools`,description:`Tool configurations (browser, search, etc.)`},gateway:{label:`Gateway`,description:`Gateway server settings (port, auth, binding)`},wizard:{label:`Setup Wizard`,description:`Setup wizard state and history`},meta:{label:`Metadata`,description:`Gateway metadata and version information`},logging:{label:`Logging`,description:`Log levels and output configuration`},browser:{label:`Browser`,description:`Browser automation settings`},ui:{label:`UI`,description:`User interface preferences`},models:{label:`Models`,description:`AI model configurations and providers`},bindings:{label:`Bindings`,description:`Key bindings and shortcuts`},broadcast:{label:`Broadcast`,description:`Broadcast and notification settings`},audio:{label:`Audio`,description:`Audio input/output settings`},session:{label:`Session`,description:`Session management and persistence`},cron:{label:`Cron`,description:`Scheduled tasks and automation`},web:{label:`Web`,description:`Web server and API settings`},discovery:{label:`Discovery`,description:`Service discovery and networking`},canvasHost:{label:`Canvas Host`,description:`Canvas rendering and display`},talk:{label:`Talk`,description:`Voice and speech settings`},plugins:{label:`Plugins`,description:`Plugin management and extensions`},diagnostics:{label:`Diagnostics`,description:`Instrumentation, OpenTelemetry, and cache-trace settings`},cli:{label:`CLI`,description:`CLI banner and startup behavior`},secrets:{label:`Secrets`,description:`Secret provider configuration`},acp:{label:`ACP`,description:`Agent Communication Protocol runtime and streaming settings`},mcp:{label:`MCP`,description:`Model Context Protocol server definitions`}};function Ey(e){return wy[e]??wy.default}function Dy(e){if(!e.query)return!0;let t=cy(e.query),n=t.text,r=Ty[e.key];return n&&(e.key.toLowerCase().includes(n)||r?.label&&r.label.toLowerCase().includes(n)||r?.description&&r.description.toLowerCase().includes(n))&&t.tags.length===0?!0:my({schema:e.schema,value:e.sectionValue,path:[e.key],hints:e.uiHints,criteria:t})}function Oy(e){if(!e.schema)return n`
<div class="muted">Schema unavailable.</div>
`;let t=e.schema,r=e.value??{};if(U(t)!==`object`||!t.properties)return n`
<div class="callout danger">Unsupported schema. Use Raw.</div>
`;let a=new Set(e.unsupportedPaths??[]),o=t.properties,s=e.searchQuery??``,c=cy(s),l=e.activeSection,u=e.activeSubsection??null,d=Object.entries(o).toSorted((t,n)=>{let r=rn([t[0]],e.uiHints)?.order??50,i=rn([n[0]],e.uiHints)?.order??50;return r===i?t[0].localeCompare(n[0]):r-i}).filter(([t,n])=>!(l&&t!==l||s&&!Dy({key:t,schema:n,sectionValue:r[t],uiHints:e.uiHints,query:s}))),f=null;if(l&&u&&d.length===1){let e=d[0]?.[1];e&&U(e)===`object`&&e.properties&&e.properties[u]&&(f={sectionKey:l,subsectionKey:u,schema:e.properties[u]})}return d.length===0?n`
<div class="config-empty">
<div class="config-empty__icon">${G.search}</div>
<div class="config-empty__text">
${s?`No settings match "${s}"`:`No settings in this section`}
</div>
</div>
`:n`
<div class="config-form config-form--modern">
${f?(()=>{let{sectionKey:t,subsectionKey:o,schema:s}=f,l=rn([t,o],e.uiHints),u=l?.label??s.title??an(o),d=l?.help??s.description??``,p=r[t],m=p&&typeof p==`object`?p[o]:void 0;return n`
<section class="config-section-card" id=${`config-section-${t}-${o}`}>
<div class="config-section-card__header">
<span class="config-section-card__icon">${Ey(t)}</span>
<div class="config-section-card__titles">
<h3 class="config-section-card__title">${u}</h3>
${d?n`<p class="config-section-card__desc">${d}</p>`:i}
</div>
</div>
<div class="config-section-card__content">
${gy({schema:s,value:m,path:[t,o],hints:e.uiHints,unsupported:a,disabled:e.disabled??!1,showLabel:!1,searchCriteria:c,revealSensitive:e.revealSensitive??!1,isSensitivePathRevealed:e.isSensitivePathRevealed,onToggleSensitivePath:e.onToggleSensitivePath,onPatch:e.onPatch})}
</div>
</section>
`})():d.map(([t,o])=>{let s=Ty[t]??{label:t.charAt(0).toUpperCase()+t.slice(1),description:o.description??``};return n`
<section class="config-section-card" id="config-section-${t}">
<div class="config-section-card__header">
<span class="config-section-card__icon">${Ey(t)}</span>
<div class="config-section-card__titles">
<h3 class="config-section-card__title">${s.label}</h3>
${s.description?n`<p class="config-section-card__desc">${s.description}</p>`:i}
</div>
</div>
<div class="config-section-card__content">
${gy({schema:o,value:r[t],path:[t],hints:e.uiHints,unsupported:a,disabled:e.disabled??!1,showLabel:!1,searchCriteria:c,revealSensitive:e.revealSensitive??!1,isSensitivePathRevealed:e.isSensitivePathRevealed,onToggleSensitivePath:e.onToggleSensitivePath,onPatch:e.onPatch})}
</div>
</section>
`})}
</div>
`}var ky=new Set([`title`,`description`,`default`,`nullable`]);function Ay(e){return Object.keys(e??{}).filter(e=>!ky.has(e)).length===0}function jy(e){let t=e.filter(e=>e!=null),n=t.length!==e.length,r=[];for(let e of t)r.some(t=>Object.is(t,e))||r.push(e);return{enumValues:r,nullable:n}}function My(e){return!e||typeof e!=`object`?{schema:null,unsupportedPaths:[`<root>`]}:Ny(e,[])}function Ny(e,t){let n=new Set,r={...e},i=nn(t)||`<root>`;if(e.anyOf||e.oneOf||e.allOf)return Ly(e,t)||{schema:e,unsupportedPaths:[i]};let a=Array.isArray(e.type)&&e.type.includes(`null`),o=U(e)??(e.properties||e.additionalProperties?`object`:void 0);if(r.type=o??e.type,r.nullable=a||e.nullable,r.enum){let{enumValues:e,nullable:t}=jy(r.enum);r.enum=e,t&&(r.nullable=!0),e.length===0&&n.add(i)}if(o===`object`){let a=e.properties??{},o={};for(let[e,r]of Object.entries(a)){let i=Ny(r,[...t,e]);i.schema&&(o[e]=i.schema);for(let e of i.unsupportedPaths)n.add(e)}if(r.properties=o,e.additionalProperties===!0)r.additionalProperties={};else if(e.additionalProperties===!1)r.additionalProperties=!1;else if(e.additionalProperties&&typeof e.additionalProperties==`object`&&!Ay(e.additionalProperties)){let a=Ny(e.additionalProperties,[...t,`*`]);r.additionalProperties=a.schema??e.additionalProperties,a.unsupportedPaths.length>0&&n.add(i)}}else if(o===`array`){let a=Array.isArray(e.items)?e.items[0]:e.items;if(!a)n.add(i);else{let e=Ny(a,[...t,`*`]);r.items=e.schema??a,e.unsupportedPaths.length>0&&n.add(i)}}else o!==`string`&&o!==`number`&&o!==`integer`&&o!==`boolean`&&!r.enum&&n.add(i);return{schema:r,unsupportedPaths:Array.from(n)}}function Py(e){if(U(e)!==`object`)return!1;let t=e.properties?.source,n=e.properties?.provider,r=e.properties?.id;return!t||!n||!r?!1:typeof t.const==`string`&&U(n)===`string`&&U(r)===`string`}function Fy(e){let t=e.oneOf??e.anyOf;return!t||t.length===0?!1:t.every(e=>Py(e))}function Iy(e,t,n,r){let i=n.findIndex(e=>U(e)===`string`);if(i<0)return null;let a=n.filter((e,t)=>t!==i);return a.length!==1||!Fy(a[0])?null:Ny({...e,...n[i],nullable:r,anyOf:void 0,oneOf:void 0,allOf:void 0},t)}function Ly(e,t){if(e.allOf)return null;let n=e.anyOf??e.oneOf;if(!n)return null;let r=[],i=[],a=!1;for(let e of n){if(!e||typeof e!=`object`)return null;if(Array.isArray(e.enum)){let{enumValues:t,nullable:n}=jy(e.enum);r.push(...t),n&&(a=!0);continue}if(`const`in e){if(e.const==null){a=!0;continue}r.push(e.const);continue}if(U(e)===`null`){a=!0;continue}i.push(e)}let o=Iy(e,t,i,a);if(o)return o;if(r.length>0&&i.length===0){let t=[];for(let e of r)t.some(t=>Object.is(t,e))||t.push(e);return{schema:{...e,enum:t,nullable:a,anyOf:void 0,oneOf:void 0,allOf:void 0},unsupportedPaths:[]}}if(i.length===1){let e=Ny(i[0],t);return e.schema&&(e.schema.nullable=a||e.schema.nullable),e}let s=new Set([`string`,`number`,`integer`,`boolean`,`object`,`array`]);return i.length>0&&r.length===0&&i.every(e=>{let t=U(e);return!!t&&s.has(String(t))})?{schema:{...e,nullable:a},unsupportedPaths:[]}:null}var Ry={0:`None`,25:`Slight`,50:`Default`,75:`Round`,100:`Full`},zy={all:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="3" width="7" height="7"></rect>
<rect x="14" y="3" width="7" height="7"></rect>
<rect x="14" y="14" width="7" height="7"></rect>
<rect x="3" y="14" width="7" height="7"></rect>
</svg>
`,env:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="3"></circle>
<path
d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"
></path>
</svg>
`,update:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
<polyline points="7 10 12 15 17 10"></polyline>
<line x1="12" y1="15" x2="12" y2="3"></line>
</svg>
`,agents:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path
d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2z"
></path>
<circle cx="8" cy="14" r="1"></circle>
<circle cx="16" cy="14" r="1"></circle>
</svg>
`,auth:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
<path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
</svg>
`,channels:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
</svg>
`,messages:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path>
<polyline points="22,6 12,13 2,6"></polyline>
</svg>
`,commands:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="4 17 10 11 4 5"></polyline>
<line x1="12" y1="19" x2="20" y2="19"></line>
</svg>
`,hooks:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path>
<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path>
</svg>
`,skills:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polygon
points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"
></polygon>
</svg>
`,tools:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path
d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"
></path>
</svg>
`,gateway:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"></circle>
<line x1="2" y1="12" x2="22" y2="12"></line>
<path
d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"
></path>
</svg>
`,wizard:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M15 4V2"></path>
<path d="M15 16v-2"></path>
<path d="M8 9h2"></path>
<path d="M20 9h2"></path>
<path d="M17.8 11.8 19 13"></path>
<path d="M15 9h0"></path>
<path d="M17.8 6.2 19 5"></path>
<path d="m3 21 9-9"></path>
<path d="M12.2 6.2 11 5"></path>
</svg>
`,meta:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M12 20h9"></path>
<path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"></path>
</svg>
`,logging:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
<polyline points="14 2 14 8 20 8"></polyline>
<line x1="16" y1="13" x2="8" y2="13"></line>
<line x1="16" y1="17" x2="8" y2="17"></line>
<polyline points="10 9 9 9 8 9"></polyline>
</svg>
`,browser:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"></circle>
<circle cx="12" cy="12" r="4"></circle>
<line x1="21.17" y1="8" x2="12" y2="8"></line>
<line x1="3.95" y1="6.06" x2="8.54" y2="14"></line>
<line x1="10.88" y1="21.94" x2="15.46" y2="14"></line>
</svg>
`,ui:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
<line x1="3" y1="9" x2="21" y2="9"></line>
<line x1="9" y1="21" x2="9" y2="9"></line>
</svg>
`,models:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path
d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"
></path>
<polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline>
<line x1="12" y1="22.08" x2="12" y2="12"></line>
</svg>
`,bindings:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect>
<rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect>
<line x1="6" y1="6" x2="6.01" y2="6"></line>
<line x1="6" y1="18" x2="6.01" y2="18"></line>
</svg>
`,broadcast:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"></path>
<path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5"></path>
<circle cx="12" cy="12" r="2"></circle>
<path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5"></path>
<path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"></path>
</svg>
`,audio:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M9 18V5l12-2v13"></path>
<circle cx="6" cy="18" r="3"></circle>
<circle cx="18" cy="16" r="3"></circle>
</svg>
`,session:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
<circle cx="9" cy="7" r="4"></circle>
<path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
<path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
</svg>
`,cron:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"></circle>
<polyline points="12 6 12 12 16 14"></polyline>
</svg>
`,web:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"></circle>
<line x1="2" y1="12" x2="22" y2="12"></line>
<path
d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"
></path>
</svg>
`,discovery:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="11" cy="11" r="8"></circle>
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
</svg>
`,canvasHost:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
<circle cx="8.5" cy="8.5" r="1.5"></circle>
<polyline points="21 15 16 10 5 21"></polyline>
</svg>
`,talk:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path>
<path d="M19 10v2a7 7 0 0 1-14 0v-2"></path>
<line x1="12" y1="19" x2="12" y2="23"></line>
<line x1="8" y1="23" x2="16" y2="23"></line>
</svg>
`,plugins:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M12 2v6"></path>
<path d="m4.93 10.93 4.24 4.24"></path>
<path d="M2 12h6"></path>
<path d="m4.93 13.07 4.24-4.24"></path>
<path d="M12 22v-6"></path>
<path d="m19.07 13.07-4.24-4.24"></path>
<path d="M22 12h-6"></path>
<path d="m19.07 10.93-4.24 4.24"></path>
</svg>
`,diagnostics:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline>
</svg>
`,cli:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="4 17 10 11 4 5"></polyline>
<line x1="12" y1="19" x2="20" y2="19"></line>
</svg>
`,secrets:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path
d="m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"
></path>
</svg>
`,acp:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
<circle cx="9" cy="7" r="4"></circle>
<path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
<path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
</svg>
`,mcp:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect>
<rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect>
<line x1="6" y1="6" x2="6.01" y2="6"></line>
<line x1="6" y1="18" x2="6.01" y2="18"></line>
</svg>
`,__appearance__:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="5"></circle>
<line x1="12" y1="1" x2="12" y2="3"></line>
<line x1="12" y1="21" x2="12" y2="23"></line>
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
<line x1="1" y1="12" x2="3" y2="12"></line>
<line x1="21" y1="12" x2="23" y2="12"></line>
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
</svg>
`,default:n`
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
<polyline points="14 2 14 8 20 8"></polyline>
</svg>
`},By=[{id:`core`,label:`Core`,sections:[{key:`env`,label:`Environment`},{key:`auth`,label:`Authentication`},{key:`update`,label:`Updates`},{key:`meta`,label:`Meta`},{key:`logging`,label:`Logging`},{key:`diagnostics`,label:`Diagnostics`},{key:`cli`,label:`Cli`},{key:`secrets`,label:`Secrets`}]},{id:`ai`,label:`AI & Agents`,sections:[{key:`agents`,label:`Agents`},{key:`models`,label:`Models`},{key:`skills`,label:`Skills`},{key:`tools`,label:`Tools`},{key:`memory`,label:`Memory`},{key:`session`,label:`Session`}]},{id:`communication`,label:`Communication`,sections:[{key:`channels`,label:`Channels`},{key:`messages`,label:`Messages`},{key:`broadcast`,label:`Broadcast`},{key:`talk`,label:`Talk`},{key:`audio`,label:`Audio`}]},{id:`automation`,label:`Automation`,sections:[{key:`commands`,label:`Commands`},{key:`hooks`,label:`Hooks`},{key:`bindings`,label:`Bindings`},{key:`cron`,label:`Cron`},{key:`approvals`,label:`Approvals`},{key:`plugins`,label:`Plugins`}]},{id:`infrastructure`,label:`Infrastructure`,sections:[{key:`gateway`,label:`Gateway`},{key:`web`,label:`Web`},{key:`browser`,label:`Browser`},{key:`nodeHost`,label:`NodeHost`},{key:`canvasHost`,label:`CanvasHost`},{key:`discovery`,label:`Discovery`},{key:`media`,label:`Media`},{key:`acp`,label:`Acp`},{key:`mcp`,label:`Mcp`}]},{id:`appearance`,label:`Appearance`,sections:[{key:`__appearance__`,label:`Appearance`},{key:`ui`,label:`UI`},{key:`wizard`,label:`Setup Wizard`}]}],Vy=new Set(By.flatMap(e=>e.sections.map(e=>e.key)));function Hy(e){return zy[e]??zy.default}function Uy(e,t){if(!e||U(e)!==`object`||!e.properties)return e;let n=t.include,r=t.exclude,i={};for(let[t,a]of Object.entries(e.properties))n&&n.size>0&&!n.has(t)||r&&r.size>0&&r.has(t)||(i[t]=a);return{...e,properties:i}}function Wy(e,t){let n=t.include,r=t.exclude;return(!n||n.size===0)&&(!r||r.size===0)?e:e.filter(e=>{if(e===`<root>`)return!0;let[t]=e.split(`.`);return n&&n.size>0?n.has(t):r&&r.size>0?!r.has(t):!0})}function Gy(e,t){return Ty[e]||{label:t?.title??an(e),description:t?.description??``}}function Ky(e,t){if(!e||!t)return[];let n=[];function r(e,t,i){if(e===t)return;if(typeof e!=typeof t){n.push({path:i,from:e,to:t});return}if(typeof e!=`object`||!e||t===null){e!==t&&n.push({path:i,from:e,to:t});return}if(Array.isArray(e)&&Array.isArray(t)){JSON.stringify(e)!==JSON.stringify(t)&&n.push({path:i,from:e,to:t});return}let a=e,o=t,s=new Set([...Object.keys(a),...Object.keys(o)]);for(let e of s)r(a[e],o[e],i?`${i}.${e}`:e)}return r(e,t,``),n}function qy(e,t=40){let n;try{n=JSON.stringify(e)??String(e)}catch{n=String(e)}return n.length<=t?n:n.slice(0,t-3)+`...`}function Jy(e,t,n){return dn(e)&&t!=null&&qy(t).trim()!==``?ln:qy(t)}var Yy=[{id:`claw`,label:`Claw`,description:`Chroma family`,icon:G.zap},{id:`knot`,label:`Knot`,description:`Black & red`,icon:G.link},{id:`dash`,label:`Dash`,description:`Chocolate blueprint`,icon:G.barChart}];function Xy(e){return n`
<div class="settings-appearance">
<div class="settings-appearance__section">
<h3 class="settings-appearance__heading">Theme</h3>
<p class="settings-appearance__hint">Choose a theme family.</p>
<div class="settings-theme-grid">
${Yy.map(t=>n`
<button
class="settings-theme-card ${t.id===e.theme?`settings-theme-card--active`:``}"
title=${t.description}
@click=${n=>{if(t.id!==e.theme){let r={element:n.currentTarget??void 0};e.setTheme(t.id,r)}}}
>
<span class="settings-theme-card__icon" aria-hidden="true">${t.icon}</span>
<span class="settings-theme-card__label">${t.label}</span>
${t.id===e.theme?n`<span class="settings-theme-card__check" aria-hidden="true">${G.check}</span>`:i}
</button>
`)}
</div>
</div>
<div class="settings-appearance__section">
<h3 class="settings-appearance__heading">Roundness</h3>
<p class="settings-appearance__hint">Adjust corner radius across the UI.</p>
<div class="settings-roundness">
<div class="settings-roundness__options">
${za.map(t=>n`
<button
type="button"
class="settings-roundness__btn ${t===e.borderRadius?`active`:``}"
@click=${()=>e.setBorderRadius(t)}
>
<span
class="settings-roundness__swatch"
style="border-radius: ${Math.round(t/50*10)}px"
></span>
<span class="settings-roundness__label">${Ry[t]}</span>
</button>
`)}
</div>
</div>
</div>
<div class="settings-appearance__section">
<h3 class="settings-appearance__heading">Connection</h3>
<div class="settings-info-grid">
<div class="settings-info-row">
<span class="settings-info-row__label">Gateway</span>
<span class="settings-info-row__value mono">${e.gatewayUrl||`-`}</span>
</div>
<div class="settings-info-row">
<span class="settings-info-row__label">Status</span>
<span class="settings-info-row__value">
<span class="settings-status-dot ${e.connected?`settings-status-dot--ok`:``}"></span>
${e.connected?`Connected`:`Offline`}
</span>
</div>
${e.assistantName?n`
<div class="settings-info-row">
<span class="settings-info-row__label">Assistant</span>
<span class="settings-info-row__value">${e.assistantName}</span>
</div>
`:i}
</div>
</div>
</div>
`}function Zy(){return{rawRevealed:!1,envRevealed:!1,validityDismissed:!1,revealedSensitivePaths:new Set}}var Qy=Zy();function $y(e){let t=nn(e);return t?Qy.revealedSensitivePaths.has(t):!1}function eb(e){let t=nn(e);t&&(Qy.revealedSensitivePaths.has(t)?Qy.revealedSensitivePaths.delete(t):Qy.revealedSensitivePaths.add(t))}function tb(e){let t=e.showModeToggle??!1,r=e.valid==null?`unknown`:e.valid?`valid`:`invalid`,a=e.includeVirtualSections??!0,o=e.includeSections?.length?new Set(e.includeSections):null,s=e.excludeSections?.length?new Set(e.excludeSections):null,c=My(e.schema),l={schema:Uy(c.schema,{include:o,exclude:s}),unsupportedPaths:Wy(c.unsupportedPaths,{include:o,exclude:s})},u=l.schema?l.unsupportedPaths.length>0:!1,d=t?e.formMode:`form`,f=Qy.envRevealed,p=e.onRequestUpdate??(()=>e.onRawChange(e.raw)),m=l.schema?.properties??{},h=new Set([`__appearance__`]),g=By.map(e=>({...e,sections:e.sections.filter(e=>a&&h.has(e.key)||e.key in m)})).filter(e=>e.sections.length>0),_=Object.keys(m).filter(e=>!Vy.has(e)).map(e=>({key:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),v=_.length>0?{id:`other`,label:`Other`,sections:_}:null,y=a&&e.activeSection!=null&&h.has(e.activeSection),b=e.activeSection&&!y&&l.schema&&U(l.schema)===`object`?l.schema.properties?.[e.activeSection]:void 0,x=e.activeSection&&!y?Gy(e.activeSection,b):null,S=[{key:null,label:e.navRootLabel??`Settings`},...[...g,...v?[v]:[]].flatMap(e=>e.sections.map(e=>({key:e.key,label:e.label})))],C=d===`form`?Ky(e.originalValue,e.formValue):[],w=d===`raw`&&e.raw!==e.originalRaw,T=d===`form`?C.length>0:w,E=!!e.formValue&&!e.loading&&!!l.schema,D=e.connected&&!e.saving&&T&&(d===`raw`?!0:E),O=e.connected&&!e.applying&&!e.updating&&T&&(d===`raw`?!0:E),k=e.connected&&!e.applying&&!e.updating,A=a&&d===`form`&&e.activeSection===null&&!!o?.has(`__appearance__`);return n`
<div class="config-layout">
<main class="config-main">
<div class="config-actions">
<div class="config-actions__left">
${t?n`
<div class="config-mode-toggle">
<button
class="config-mode-toggle__btn ${d===`form`?`active`:``}"
?disabled=${e.schemaLoading||!e.schema}
title=${u?`Form view can't safely edit some fields`:``}
@click=${()=>e.onFormModeChange(`form`)}
>
Form
</button>
<button
class="config-mode-toggle__btn ${d===`raw`?`active`:``}"
@click=${()=>e.onFormModeChange(`raw`)}
>
Raw
</button>
</div>
`:i}
${T?n`
<span class="config-changes-badge"
>${d===`raw`?`Unsaved changes`:`${C.length} unsaved change${C.length===1?``:`s`}`}</span
>
`:n`
<span class="config-status muted">No changes</span>
`}
</div>
<div class="config-actions__right">
${e.onOpenFile?n`
<button
class="btn btn--sm"
title=${e.configPath?`Open ${e.configPath}`:`Open config file`}
@click=${e.onOpenFile}
>
${G.fileText} Open
</button>
`:i}
<button
class="btn btn--sm"
?disabled=${e.loading}
@click=${e.onReload}
>
${e.loading?`Loading…`:`Reload`}
</button>
<button
class="btn btn--sm primary"
?disabled=${!D}
@click=${e.onSave}
>
${e.saving?`Saving…`:`Save`}
</button>
<button
class="btn btn--sm"
?disabled=${!O}
@click=${e.onApply}
>
${e.applying?`Applying…`:`Apply`}
</button>
<button
class="btn btn--sm"
?disabled=${!k}
@click=${e.onUpdate}
>
${e.updating?`Updating…`:`Update`}
</button>
</div>
</div>
<div class="config-top-tabs">
${d===`form`?n`
<div class="config-search config-search--top">
<div class="config-search__input-row">
<svg
class="config-search__icon"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
>
<circle cx="11" cy="11" r="8"></circle>
<path d="M21 21l-4.35-4.35"></path>
</svg>
<input
type="text"
class="config-search__input"
placeholder="Search settings..."
.value=${e.searchQuery}
@input=${t=>e.onSearchChange(t.target.value)}
/>
${e.searchQuery?n`
<button
class="config-search__clear"
@click=${()=>e.onSearchChange(``)}
>
×
</button>
`:i}
</div>
</div>
`:i}
<div class="config-top-tabs__scroller" role="tablist" aria-label="Settings sections">
${S.map(t=>n`
<button
class="config-top-tabs__tab ${e.activeSection===t.key?`active`:``}"
role="tab"
aria-selected=${e.activeSection===t.key}
@click=${()=>e.onSectionChange(t.key)}
title=${t.label}
>
${t.label}
</button>
`)}
</div>
</div>
${r===`invalid`&&!Qy.validityDismissed?n`
<div class="config-validity-warning">
<svg class="config-validity-warning__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="16" height="16">
<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path>
<line x1="12" y1="9" x2="12" y2="13"></line>
<line x1="12" y1="17" x2="12.01" y2="17"></line>
</svg>
<span class="config-validity-warning__text">Your configuration is invalid. Some settings may not work as expected.</span>
<button
class="btn btn--sm"
@click=${()=>{Qy.validityDismissed=!0,p()}}
>Don't remind again</button>
</div>
`:i}
<!-- Diff panel (form mode only - raw mode doesn't have granular diff) -->
${T&&d===`form`?n`
<details class="config-diff">
<summary class="config-diff__summary">
<span
>View ${C.length} pending
change${C.length===1?``:`s`}</span
>
<svg
class="config-diff__chevron"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
>
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
</summary>
<div class="config-diff__content">
${C.map(t=>n`
<div class="config-diff__item">
<div class="config-diff__path">${t.path}</div>
<div class="config-diff__values">
<span class="config-diff__from"
>${Jy(t.path,t.from,e.uiHints)}</span
>
<span class="config-diff__arrow">→</span>
<span class="config-diff__to"
>${Jy(t.path,t.to,e.uiHints)}</span
>
</div>
</div>
`)}
</div>
</details>
`:i}
${x&&d===`form`?n`
<div class="config-section-hero">
<div class="config-section-hero__icon">
${Hy(e.activeSection??``)}
</div>
<div class="config-section-hero__text">
<div class="config-section-hero__title">
${x.label}
</div>
${x.description?n`<div class="config-section-hero__desc">
${x.description}
</div>`:i}
</div>
${e.activeSection===`env`?n`
<button
class="config-env-peek-btn ${f?`config-env-peek-btn--active`:``}"
title=${f?`Hide env values`:`Reveal env values`}
@click=${()=>{Qy.envRevealed=!Qy.envRevealed,p()}}
>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="16" height="16">
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path>
<circle cx="12" cy="12" r="3"></circle>
</svg>
Peek
</button>
`:i}
</div>
`:i}
<!-- Form content -->
<div class="config-content">
${e.activeSection===`__appearance__`?a?Xy(e):i:d===`form`?n`
${A?Xy(e):i}
${e.schemaLoading?n`
<div class="config-loading">
<div class="config-loading__spinner"></div>
<span>Loading schema…</span>
</div>
`:Oy({schema:l.schema,uiHints:e.uiHints,value:e.formValue,disabled:e.loading||!e.formValue,unsupportedPaths:l.unsupportedPaths,onPatch:e.onFormPatch,searchQuery:e.searchQuery,activeSection:e.activeSection,activeSubsection:null,revealSensitive:e.activeSection===`env`?f:!1,isSensitivePathRevealed:$y,onToggleSensitivePath:e=>{eb(e),p()}})}
`:(()=>{let t=hn(e.formValue,[],e.uiHints),r=t>0&&!Qy.rawRevealed;return n`
${u?n`
<div class="callout info" style="margin-bottom: 12px">
Your config contains fields the form editor can't safely represent. Use Raw mode to edit those
entries.
</div>
`:i}
<div class="field config-raw-field">
<span style="display:flex;align-items:center;gap:8px;">
Raw config (JSON/JSON5)
${t>0?n`
<span class="pill pill--sm">${t} secret${t===1?``:`s`} ${r?`redacted`:`visible`}</span>
<button
class="btn btn--icon config-raw-toggle ${r?``:`active`}"
title=${r?`Reveal sensitive values`:`Hide sensitive values`}
aria-label="Toggle raw config redaction"
aria-pressed=${!r}
@click=${()=>{Qy.rawRevealed=!Qy.rawRevealed,p()}}
>
${r?G.eyeOff:G.eye}
</button>
`:i}
</span>
<textarea
class="${r?`config-raw-redacted`:``}"
placeholder=${r?ln:`Raw config (JSON/JSON5)`}
.value=${r?``:e.raw}
?readonly=${r}
@input=${t=>{r||e.onRawChange(t.target.value)}}
></textarea>
</div>
`})()}
</div>
${e.issues.length>0?n`<div class="callout danger" style="margin-top: 12px;">
<pre class="code-block">
${JSON.stringify(e.issues,null,2)}</pre
>
</div>`:i}
</main>
</div>
`}function nb(e){let t=Math.max(0,e),n=Math.floor(t/1e3);if(n<60)return`${n}s`;let r=Math.floor(n/60);return r<60?`${r}m`:`${Math.floor(r/60)}h`}function rb(e,t){return t?n`<div class="exec-approval-meta-row"><span>${e}</span><span>${t}</span></div>`:i}function ib(e){let t=e.execApprovalQueue[0];if(!t)return i;let r=t.request,a=t.expiresAtMs-Date.now(),o=a>0?`expires in ${nb(a)}`:`expired`,s=e.execApprovalQueue.length;return n`
<div class="exec-approval-overlay" role="dialog" aria-live="polite">
<div class="exec-approval-card">
<div class="exec-approval-header">
<div>
<div class="exec-approval-title">Exec approval needed</div>
<div class="exec-approval-sub">${o}</div>
</div>
${s>1?n`<div class="exec-approval-queue">${s} pending</div>`:i}
</div>
<div class="exec-approval-command mono">${r.command}</div>
<div class="exec-approval-meta">
${rb(`Host`,r.host)}
${rb(`Agent`,r.agentId)}
${rb(`Session`,r.sessionKey)}
${rb(`CWD`,r.cwd)}
${rb(`Resolved`,r.resolvedPath)}
${rb(`Security`,r.security)}
${rb(`Ask`,r.ask)}
</div>
${e.execApprovalError?n`<div class="exec-approval-error">${e.execApprovalError}</div>`:i}
<div class="exec-approval-actions">
<button
class="btn primary"
?disabled=${e.execApprovalBusy}
@click=${()=>e.handleExecApprovalDecision(`allow-once`)}
>
Allow once
</button>
<button
class="btn"
?disabled=${e.execApprovalBusy}
@click=${()=>e.handleExecApprovalDecision(`allow-always`)}
>
Always allow
</button>
<button
class="btn danger"
?disabled=${e.execApprovalBusy}
@click=${()=>e.handleExecApprovalDecision(`deny`)}
>
Deny
</button>
</div>
</div>
</div>
`}function ab(e){let{pendingGatewayUrl:t}=e;return t?n`
<div class="exec-approval-overlay" role="dialog" aria-modal="true" aria-live="polite">
<div class="exec-approval-card">
<div class="exec-approval-header">
<div>
<div class="exec-approval-title">Change Gateway URL</div>
<div class="exec-approval-sub">This will reconnect to a different gateway server</div>
</div>
</div>
<div class="exec-approval-command mono">${t}</div>
<div class="callout danger" style="margin-top: 12px;">
Only confirm if you trust this URL. Malicious URLs can compromise your system.
</div>
<div class="exec-approval-actions">
<button
class="btn primary"
@click=${()=>e.handleGatewayUrlConfirm()}
>
Confirm
</button>
<button
class="btn"
@click=${()=>e.handleGatewayUrlCancel()}
>
Cancel
</button>
</div>
</div>
</div>
`:i}function ob(e){return n`
<div class="login-gate">
<div class="login-gate__card">
<div class="login-gate__header">
<img class="login-gate__logo" src=${xu(va(e.basePath??``))} alt="OpenClaw" />
<div class="login-gate__title">OpenClaw</div>
<div class="login-gate__sub">${P(`login.subtitle`)}</div>
</div>
<div class="login-gate__form">
<label class="field">
<span>${P(`overview.access.wsUrl`)}</span>
<input
.value=${e.settings.gatewayUrl}
@input=${t=>{let n=t.target.value;e.applySettings({...e.settings,gatewayUrl:n})}}
placeholder="ws://127.0.0.1:18789"
/>
</label>
<label class="field">
<span>${P(`overview.access.token`)}</span>
<div class="login-gate__secret-row">
<input
type=${e.loginShowGatewayToken?`text`:`password`}
autocomplete="off"
spellcheck="false"
.value=${e.settings.token}
@input=${t=>{let n=t.target.value;e.applySettings({...e.settings,token:n})}}
placeholder="OPENCLAW_GATEWAY_TOKEN (${P(`login.passwordPlaceholder`)})"
@keydown=${t=>{t.key===`Enter`&&e.connect()}}
/>
<button
type="button"
class="btn btn--icon ${e.loginShowGatewayToken?`active`:``}"
title=${e.loginShowGatewayToken?`Hide token`:`Show token`}
aria-label="Toggle token visibility"
aria-pressed=${e.loginShowGatewayToken}
@click=${()=>{e.loginShowGatewayToken=!e.loginShowGatewayToken}}
>
${e.loginShowGatewayToken?G.eye:G.eyeOff}
</button>
</div>
</label>
<label class="field">
<span>${P(`overview.access.password`)}</span>
<div class="login-gate__secret-row">
<input
type=${e.loginShowGatewayPassword?`text`:`password`}
autocomplete="off"
spellcheck="false"
.value=${e.password}
@input=${t=>{e.password=t.target.value}}
placeholder="${P(`login.passwordPlaceholder`)}"
@keydown=${t=>{t.key===`Enter`&&e.connect()}}
/>
<button
type="button"
class="btn btn--icon ${e.loginShowGatewayPassword?`active`:``}"
title=${e.loginShowGatewayPassword?`Hide password`:`Show password`}
aria-label="Toggle password visibility"
aria-pressed=${e.loginShowGatewayPassword}
@click=${()=>{e.loginShowGatewayPassword=!e.loginShowGatewayPassword}}
>
${e.loginShowGatewayPassword?G.eye:G.eyeOff}
</button>
</div>
</label>
<button
class="btn primary login-gate__connect"
@click=${()=>e.connect()}
>
${P(`common.connect`)}
</button>
</div>
${e.lastError?n`<div class="callout danger" style="margin-top: 14px;">
<div>${e.lastError}</div>
</div>`:``}
<div class="login-gate__help">
<div class="login-gate__help-title">${P(`overview.connection.title`)}</div>
<ol class="login-gate__steps">
<li>${P(`overview.connection.step1`)}<code>openclaw gateway run</code></li>
<li>${P(`overview.connection.step2`)}<code>openclaw dashboard --no-open</code></li>
<li>${P(`overview.connection.step3`)}</li>
</ol>
<div class="login-gate__docs">
<a
class="session-link"
href="https://docs.openclaw.ai/web/dashboard"
target="_blank"
rel="noreferrer"
>${P(`overview.connection.docsLink`)}</a>
</div>
</div>
</div>
</div>
`}function sb(e){return e===`error`?`danger`:e===`warning`?`warn`:``}function cb(e){return e in G?G[e]:G.radio}function lb(e){return e.items.length===0?i:n`
<section class="card ov-attention">
<div class="card-title">${P(`overview.attention.title`)}</div>
<div class="ov-attention-list">
${e.items.map(e=>n`
<div class="ov-attention-item ${sb(e.severity)}">
<span class="ov-attention-icon">${cb(e.icon)}</span>
<div class="ov-attention-body">
<div class="ov-attention-title">${e.title}</div>
<div class="muted">${e.description}</div>
</div>
${e.href?n`<a
class="ov-attention-link"
href=${e.href}
target=${e.external?Vv:i}
rel=${e.external?Hv():i}
>${P(`common.docs`)}</a>`:i}
</div>
`)}
</div>
</section>
`}function ub(e){let t=e.ts??null;return t?p(t):`n/a`}function db(e){return e?`${new Date(e).toLocaleDateString(void 0,{weekday:`short`})}, ${f(e)} (${p(e)})`:`n/a`}function fb(e){if(e.totalTokens==null)return`n/a`;let t=e.totalTokens??0,n=e.contextTokens??0;return n?`${t} / ${n}`:String(t)}function pb(e){if(e==null)return``;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function mb(e){let t=e.state??{},n=t.nextRunAtMs?f(t.nextRunAtMs):`n/a`,r=t.lastRunAtMs?f(t.lastRunAtMs):`n/a`;return`${t.lastStatus??`n/a`} · next ${n} · last ${r}`}function hb(e){let t=e.schedule;if(t.kind===`at`){let e=Date.parse(t.at);return Number.isFinite(e)?`At ${f(e)}`:`At ${t.at}`}return t.kind===`every`?`Every ${d(t.everyMs)}`:`Cron ${t.expr}${t.tz?` (${t.tz})`:``}`}function gb(e){let t=e.payload;if(t.kind===`systemEvent`)return`System: ${t.text}`;let n=`Agent: ${t.message}`,r=e.delivery;if(r&&r.mode!==`none`){let e=r.mode===`webhook`?r.to?` (${r.to})`:``:r.channel||r.to?` (${r.channel??`last`}${r.to?` -> ${r.to}`:``})`:``;return`${n} · ${r.mode}${e}`}return n}var _b=/\d{3,}/g;function vb(e){return n`${$o(e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(_b,e=>`<span class="blur-digits">${e}</span>`))}`}function yb(e,t){return n`
<button class="ov-card" data-kind=${e.kind} @click=${()=>t(e.tab)}>
<span class="ov-card__label">${e.label}</span>
<span class="ov-card__value">${e.value}</span>
<span class="ov-card__hint">${e.hint}</span>
</button>
`}function bb(){return n`
<section class="ov-cards">
${[0,1,2,3].map(e=>n`
<div class="ov-card" style="cursor:default;animation-delay:${e*50}ms">
<span class="skeleton skeleton-line" style="width:60px;height:10px"></span>
<span class="skeleton skeleton-stat"></span>
<span class="skeleton skeleton-line skeleton-line--medium" style="height:12px"></span>
</div>
`)}
</section>
`}function xb(e){if(!(e.usageResult!=null||e.sessionsResult!=null||e.skillsReport!=null))return bb();let t=e.usageResult?.totals,r=m(t?.totalCost),a=l(t?.totalTokens),o=t?String(e.usageResult?.aggregates?.messages?.total??0):`0`,s=e.sessionsResult?.count??null,c=e.skillsReport?.skills??[],u=c.filter(e=>!e.disabled).length,d=c.filter(e=>e.blockedByAllowlist).length,f=c.length,h=e.cronStatus?.enabled??null,g=e.cronStatus?.nextWakeAtMs??null,_=e.cronJobs.length,v=e.cronJobs.filter(e=>e.state?.lastStatus===`error`).length,y=h==null?P(`common.na`):h?`${_} jobs`:P(`common.disabled`),b=v>0?n`<span class="danger">${v} failed</span>`:g?P(`overview.stats.cronNext`,{time:db(g)}):``,x=[{kind:`cost`,tab:`usage`,label:P(`overview.cards.cost`),value:r,hint:`${a} tokens · ${o} msgs`},{kind:`sessions`,tab:`sessions`,label:P(`overview.stats.sessions`),value:String(s??P(`common.na`)),hint:P(`overview.stats.sessionsHint`)},{kind:`skills`,tab:`skills`,label:P(`overview.cards.skills`),value:`${u}/${f}`,hint:d>0?`${d} blocked`:`${u} active`},{kind:`cron`,tab:`cron`,label:P(`overview.stats.cron`),value:y,hint:b}],S=e.sessionsResult?.sessions.slice(0,5)??[];return n`
<section class="ov-cards">
${x.map(t=>yb(t,e.onNavigate))}
</section>
${S.length>0?n`
<section class="ov-recent">
<h3 class="ov-recent__title">${P(`overview.cards.recentSessions`)}</h3>
<ul class="ov-recent__list">
${S.map(e=>n`
<li class="ov-recent__row">
<span class="ov-recent__key">${vb(e.displayName||e.label||e.key)}</span>
<span class="ov-recent__model">${e.model??``}</span>
<span class="ov-recent__time">${e.updatedAt?p(e.updatedAt):``}</span>
</li>
`)}
</ul>
</section>
`:i}
`}function Sb(e){if(e.events.length===0)return i;let t=e.events.slice(0,20);return n`
<details class="card ov-event-log" open>
<summary class="ov-expandable-toggle">
<span class="nav-item__icon">${G.radio}</span>
${P(`overview.eventLog.title`)}
<span class="ov-count-badge">${e.events.length}</span>
</summary>
<div class="ov-event-log-list">
${t.map(e=>n`
<div class="ov-event-log-entry">
<span class="ov-event-log-ts">${new Date(e.ts).toLocaleTimeString()}</span>
<span class="ov-event-log-name">${e.event}</span>
${e.payload?n`<span class="ov-event-log-payload muted">${pb(e.payload).slice(0,120)}</span>`:i}
</div>
`)}
</div>
</details>
`}var Cb=new Set([I.AUTH_REQUIRED,I.AUTH_TOKEN_MISSING,I.AUTH_PASSWORD_MISSING,I.AUTH_TOKEN_NOT_CONFIGURED,I.AUTH_PASSWORD_NOT_CONFIGURED]),wb=new Set([...Cb,I.AUTH_UNAUTHORIZED,I.AUTH_TOKEN_MISMATCH,I.AUTH_PASSWORD_MISMATCH,I.AUTH_DEVICE_TOKEN_MISMATCH,I.AUTH_RATE_LIMITED,I.AUTH_TAILSCALE_IDENTITY_MISSING,I.AUTH_TAILSCALE_PROXY_MISSING,I.AUTH_TAILSCALE_WHOIS_FAILED,I.AUTH_TAILSCALE_IDENTITY_MISMATCH]),Tb=new Set([I.CONTROL_UI_DEVICE_IDENTITY_REQUIRED,I.DEVICE_IDENTITY_REQUIRED]);function Eb(e,t,n){return e||!t?!1:n===I.PAIRING_REQUIRED?!0:t.toLowerCase().includes(`pairing required`)}function Db(e){return e.connected||!e.lastError?null:e.lastErrorCode?wb.has(e.lastErrorCode)?Cb.has(e.lastErrorCode)?`required`:`failed`:null:e.lastError.toLowerCase().includes(`unauthorized`)?!e.hasToken&&!e.hasPassword?`required`:`failed`:null}function Ob(e,t,n){if(e||!t)return!1;if(n)return Tb.has(n);let r=t.toLowerCase();return r.includes(`secure context`)||r.includes(`device identity required`)}function kb(e){return e.replace(/\x1b\]8;;.*?\x1b\\|\x1b\]8;;\x1b\\/g,``).replace(/\x1b\[[0-9;]*m/g,``)}function Ab(e){if(e.lines.length===0)return i;let t=e.lines.slice(-50).map(e=>kb(e)).join(`
`);return n`
<details class="card ov-log-tail" open>
<summary class="ov-expandable-toggle">
<span class="nav-item__icon">${G.scrollText}</span>
${P(`overview.logTail.title`)}
<span class="ov-count-badge">${e.lines.length}</span>
<span
class="ov-log-refresh"
@click=${t=>{t.preventDefault(),t.stopPropagation(),e.onRefreshLogs()}}
>${G.loader}</span>
</summary>
<pre class="ov-log-tail-content">${t}</pre>
</details>
`}function jb(e){let t=e.hello?.snapshot,r=t?.uptimeMs?d(t.uptimeMs):P(`common.na`),a=e.hello?.policy?.tickIntervalMs,o=a?`${(a/1e3).toFixed(a%1e3==0?0:1)}s`:P(`common.na`),s=t?.authMode===`trusted-proxy`,c=Eb(e.connected,e.lastError,e.lastErrorCode)?n`
<div class="muted" style="margin-top: 8px">
${P(`overview.pairing.hint`)}
<div style="margin-top: 6px">
<span class="mono">openclaw devices list</span><br />
<span class="mono">openclaw devices approve <requestId></span>
</div>
<div style="margin-top: 6px; font-size: 12px;">
${P(`overview.pairing.mobileHint`)}
</div>
<div style="margin-top: 6px">
<a
class="session-link"
href="https://docs.openclaw.ai/web/control-ui#device-pairing-first-connection"
target=${Vv}
rel=${Hv()}
title="Device pairing docs (opens in new tab)"
>Docs: Device pairing</a
>
</div>
</div>
`:null,l=(()=>{let t=Db({connected:e.connected,lastError:e.lastError,lastErrorCode:e.lastErrorCode,hasToken:!!e.settings.token.trim(),hasPassword:!!e.password.trim()});return t==null?null:t===`required`?n`
<div class="muted" style="margin-top: 8px">
${P(`overview.auth.required`)}
<div style="margin-top: 6px">
<span class="mono">openclaw dashboard --no-open</span> → tokenized URL<br />
<span class="mono">openclaw doctor --generate-gateway-token</span> → set token
</div>
<div style="margin-top: 6px">
<a
class="session-link"
href="https://docs.openclaw.ai/web/dashboard"
target=${Vv}
rel=${Hv()}
title="Control UI auth docs (opens in new tab)"
>Docs: Control UI auth</a
>
</div>
</div>
`:n`
<div class="muted" style="margin-top: 8px">
${P(`overview.auth.failed`,{command:`openclaw dashboard --no-open`})}
<div style="margin-top: 6px">
<a
class="session-link"
href="https://docs.openclaw.ai/web/dashboard"
target=${Vv}
rel=${Hv()}
title="Control UI auth docs (opens in new tab)"
>Docs: Control UI auth</a
>
</div>
</div>
`})(),u=e.connected||!e.lastError||!(typeof window<`u`)||window.isSecureContext||!Ob(e.connected,e.lastError,e.lastErrorCode)?null:n`
<div class="muted" style="margin-top: 8px">
${P(`overview.insecure.hint`,{url:`http://127.0.0.1:18789`})}
<div style="margin-top: 6px">
${P(`overview.insecure.stayHttp`,{config:`gateway.controlUi.allowInsecureAuth: true`})}
</div>
<div style="margin-top: 6px">
<a
class="session-link"
href="https://docs.openclaw.ai/gateway/tailscale"
target=${Vv}
rel=${Hv()}
title="Tailscale Serve docs (opens in new tab)"
>Docs: Tailscale Serve</a
>
<span class="muted"> · </span>
<a
class="session-link"
href="https://docs.openclaw.ai/web/control-ui#insecure-http"
target=${Vv}
rel=${Hv()}
title="Insecure HTTP docs (opens in new tab)"
>Docs: Insecure HTTP</a
>
</div>
</div>
`,f=te(e.settings.locale)?e.settings.locale:N.getLocale();return n`
<section class="grid">
<div class="card">
<div class="card-title">${P(`overview.access.title`)}</div>
<div class="card-sub">${P(`overview.access.subtitle`)}</div>
<div class="ov-access-grid" style="margin-top: 16px;">
<label class="field ov-access-grid__full">
<span>${P(`overview.access.wsUrl`)}</span>
<input
.value=${e.settings.gatewayUrl}
@input=${t=>{let n=t.target.value;e.onSettingsChange({...e.settings,gatewayUrl:n,token:n.trim()===e.settings.gatewayUrl.trim()?e.settings.token:``})}}
placeholder="ws://100.x.y.z:18789"
/>
</label>
${s?``:n`
<label class="field">
<span>${P(`overview.access.token`)}</span>
<div style="display: flex; align-items: center; gap: 8px;">
<input
type=${e.showGatewayToken?`text`:`password`}
autocomplete="off"
style="flex: 1;"
.value=${e.settings.token}
@input=${t=>{let n=t.target.value;e.onSettingsChange({...e.settings,token:n})}}
placeholder="OPENCLAW_GATEWAY_TOKEN"
/>
<button
type="button"
class="btn btn--icon ${e.showGatewayToken?`active`:``}"
style="width: 36px; height: 36px;"
title=${e.showGatewayToken?`Hide token`:`Show token`}
aria-label="Toggle token visibility"
aria-pressed=${e.showGatewayToken}
@click=${e.onToggleGatewayTokenVisibility}
>
${e.showGatewayToken?G.eye:G.eyeOff}
</button>
</div>
</label>
<label class="field">
<span>${P(`overview.access.password`)}</span>
<div style="display: flex; align-items: center; gap: 8px;">
<input
type=${e.showGatewayPassword?`text`:`password`}
autocomplete="off"
style="flex: 1;"
.value=${e.password}
@input=${t=>{let n=t.target.value;e.onPasswordChange(n)}}
placeholder="system or shared password"
/>
<button
type="button"
class="btn btn--icon ${e.showGatewayPassword?`active`:``}"
style="width: 36px; height: 36px;"
title=${e.showGatewayPassword?`Hide password`:`Show password`}
aria-label="Toggle password visibility"
aria-pressed=${e.showGatewayPassword}
@click=${e.onToggleGatewayPasswordVisibility}
>
${e.showGatewayPassword?G.eye:G.eyeOff}
</button>
</div>
</label>
`}
<label class="field">
<span>${P(`overview.access.sessionKey`)}</span>
<input
.value=${e.settings.sessionKey}
@input=${t=>{let n=t.target.value;e.onSessionKeyChange(n)}}
/>
</label>
<label class="field">
<span>${P(`overview.access.language`)}</span>
<select
.value=${f}
@change=${t=>{let n=t.target.value;N.setLocale(n),e.onSettingsChange({...e.settings,locale:n})}}
>
${j.map(e=>{let t=e.replace(/-([a-zA-Z])/g,(e,t)=>t.toUpperCase());return n`<option value=${e} ?selected=${f===e}>
${P(`languages.${t}`)}
</option>`})}
</select>
</label>
</div>
<div class="row" style="margin-top: 14px;">
<button class="btn" @click=${()=>e.onConnect()}>${P(`common.connect`)}</button>
<button class="btn" @click=${()=>e.onRefresh()}>${P(`common.refresh`)}</button>
<span class="muted">${P(s?`overview.access.trustedProxy`:`overview.access.connectHint`)}</span>
</div>
${e.connected?i:n`
<div class="login-gate__help" style="margin-top: 16px;">
<div class="login-gate__help-title">${P(`overview.connection.title`)}</div>
<ol class="login-gate__steps">
<li>${P(`overview.connection.step1`)}<code>openclaw gateway run</code></li>
<li>${P(`overview.connection.step2`)}<code>openclaw dashboard --no-open</code></li>
<li>${P(`overview.connection.step3`)}</li>
<li>${P(`overview.connection.step4`)}<code>openclaw doctor --generate-gateway-token</code></li>
</ol>
<div class="login-gate__docs">
${P(`overview.connection.docsHint`)}
<a
class="session-link"
href="https://docs.openclaw.ai/web/dashboard"
target="_blank"
rel="noreferrer"
>${P(`overview.connection.docsLink`)}</a>
</div>
</div>
`}
</div>
<div class="card">
<div class="card-title">${P(`overview.snapshot.title`)}</div>
<div class="card-sub">${P(`overview.snapshot.subtitle`)}</div>
<div class="stat-grid" style="margin-top: 16px;">
<div class="stat">
<div class="stat-label">${P(`overview.snapshot.status`)}</div>
<div class="stat-value ${e.connected?`ok`:`warn`}">
${e.connected?P(`common.ok`):P(`common.offline`)}
</div>
</div>
<div class="stat">
<div class="stat-label">${P(`overview.snapshot.uptime`)}</div>
<div class="stat-value">${r}</div>
</div>
<div class="stat">
<div class="stat-label">${P(`overview.snapshot.tickInterval`)}</div>
<div class="stat-value">${o}</div>
</div>
<div class="stat">
<div class="stat-label">${P(`overview.snapshot.lastChannelsRefresh`)}</div>
<div class="stat-value">
${e.lastChannelsRefresh?p(e.lastChannelsRefresh):P(`common.na`)}
</div>
</div>
</div>
${e.lastError?n`<div class="callout danger" style="margin-top: 14px;">
<div>${e.lastError}</div>
${c??``}
${l??``}
${u??``}
</div>`:n`
<div class="callout" style="margin-top: 14px">
${P(`overview.snapshot.channelsHint`)}
</div>
`}
</div>
</section>
<div class="ov-section-divider"></div>
${xb({usageResult:e.usageResult,sessionsResult:e.sessionsResult,skillsReport:e.skillsReport,cronJobs:e.cronJobs,cronStatus:e.cronStatus,presenceCount:e.presenceCount,onNavigate:e.onNavigate})}
${lb({items:e.attentionItems})}
<div class="ov-section-divider"></div>
<div class="ov-bottom-grid">
${Sb({events:e.eventLog})}
${Ab({lines:e.overviewLogLines,onRefreshLogs:e.onRefreshLogs})}
</div>
`}var Mb;function Nb(e){let t={mod:null,promise:null};return()=>t.mod?t.mod:(t.promise||=e().then(e=>(t.mod=e,Mb?.(),e)),null)}var Pb=Nb(()=>k(()=>import(`./agents-B-6PXFWd.js`),__vite__mapDeps([0,1,2,3,4]),import.meta.url)),Fb=Nb(()=>k(()=>import(`./channels-DcDh7rxN.js`),__vite__mapDeps([5,1,2,3]),import.meta.url)),Ib=Nb(()=>k(()=>import(`./cron-DwIMARE-.js`),__vite__mapDeps([6,1,2]),import.meta.url)),Lb=Nb(()=>k(()=>import(`./debug-YIHGg52o.js`),__vite__mapDeps([7,1]),import.meta.url)),Rb=Nb(()=>k(()=>import(`./instances-C8om8LL2.js`),__vite__mapDeps([8,1]),import.meta.url)),zb=Nb(()=>k(()=>import(`./logs-BbHV8FOx.js`),__vite__mapDeps([9,1]),import.meta.url)),Bb=Nb(()=>k(()=>import(`./nodes-BXlsFQVB.js`),__vite__mapDeps([10,1,2]),import.meta.url)),Vb=Nb(()=>k(()=>import(`./sessions-DMIQd5yR.js`),__vite__mapDeps([11,1,2]),import.meta.url)),Hb=Nb(()=>k(()=>import(`./skills-BaxA3XRt.js`),__vite__mapDeps([12,1,2,4]),import.meta.url));function Ub(e,t){let n=e();return n?t(n):i}var Wb=`openclaw:control-ui:update-banner-dismissed:v1`,Gb=[`off`,`minimal`,`low`,`medium`,`high`],Kb=[`UTC`,`America/Los_Angeles`,`America/Denver`,`America/Chicago`,`America/New_York`,`Europe/London`,`Europe/Berlin`,`Asia/Tokyo`];function qb(e){return/^https?:\/\//i.test(e.trim())}function Jb(e){return typeof e==`string`?e.trim():``}function Yb(e){let t=new Set,n=[];for(let r of e){let e=r.trim();if(!e)continue;let i=e.toLowerCase();t.has(i)||(t.add(i),n.push(e))}return n}function Xb(){try{let e=w()?.getItem(Wb);if(!e)return null;let t=JSON.parse(e);return!t||typeof t.latestVersion!=`string`?null:{latestVersion:t.latestVersion,channel:typeof t.channel==`string`?t.channel:null,dismissedAtMs:typeof t.dismissedAtMs==`number`?t.dismissedAtMs:Date.now()}}catch{return null}}function Zb(e){let t=Xb();if(!t)return!1;let n=e,r=n&&typeof n.latestVersion==`string`?n.latestVersion:null,i=n&&typeof n.channel==`string`?n.channel:null;return!!(r&&t.latestVersion===r&&t.channel===i)}function Qb(e){let t=e,n=t&&typeof t.latestVersion==`string`?t.latestVersion:null;if(!n)return;let r={latestVersion:n,channel:t&&typeof t.channel==`string`?t.channel:null,dismissedAtMs:Date.now()};try{w()?.setItem(Wb,JSON.stringify(r))}catch{}}var $b=/^data:/i,ex=/^https?:\/\//i,tx=[`channels`,`messages`,`broadcast`,`talk`,`audio`],nx=[`__appearance__`,`ui`,`wizard`],rx=[`commands`,`hooks`,`bindings`,`cron`,`approvals`,`plugins`],ix=[`gateway`,`web`,`browser`,`nodeHost`,`canvasHost`,`discovery`,`media`,`acp`,`mcp`],ax=[`agents`,`models`,`skills`,`tools`,`memory`,`session`];function ox(e){let t=e.agentsList?.agents??[],n=rr(e.sessionKey)?.agentId??e.agentsList?.defaultId??`main`,r=t.find(e=>e.id===n)?.identity,i=r?.avatarUrl??r?.avatar;if(i)return $b.test(i)||ex.test(i)?i:r?.avatarUrl}function sx(e){let t=e,r=typeof t.requestUpdate==`function`?()=>t.requestUpdate?.():void 0;if(Mb=r,!e.connected)return n`
${ob(e)}
${ab(e)}
`;let a=e.presenceEntries.length,o=e.sessionsResult?.count??null,s=e.cronStatus?.nextWakeAtMs??null,c=e.connected?null:P(`chat.disconnected`),l=e.tab===`chat`,u=l&&(e.settings.chatFocusMode||e.onboarding),d=!!(e.navDrawerOpen&&!u&&!e.onboarding),f=!!(e.settings.navCollapsed&&!d),p=e.onboarding?!1:e.settings.chatShowThinking,m=e.onboarding?!0:e.settings.chatShowToolCalls,h=ox(e),g=e.chatAvatarUrl??h??null,_=e.configForm??e.configSnapshot?.config,v=va(e.basePath??``),y=e.agentsSelectedId??e.agentsList?.defaultId??e.agentsList?.agents?.[0]?.id??null,b=()=>e.configForm??e.configSnapshot?.config,x=e=>Fn(b(),e),S=t=>In(e,t),C=Nu(new Set([...e.agentsList?.agents?.map(e=>e.id.trim())??[],...e.cronJobs.map(e=>typeof e.agentId==`string`?e.agentId.trim():``).filter(Boolean)].filter(Boolean))),w=Nu(new Set([...e.cronModelSuggestions,...Pu(_),...e.cronJobs.map(e=>e.payload.kind!==`agentTurn`||typeof e.payload.model!=`string`?``:e.payload.model.trim()).filter(Boolean)].filter(Boolean))),T=ri(e),E=e.cronForm.deliveryChannel&&e.cronForm.deliveryChannel.trim()?e.cronForm.deliveryChannel.trim():`last`,D=e.cronJobs.map(e=>Jb(e.delivery?.to)).filter(Boolean),O=(E===`last`?Object.values(e.channelsSnapshot?.channelAccounts??{}).flat():e.channelsSnapshot?.channelAccounts?.[E]??[]).flatMap(e=>[Jb(e.accountId),Jb(e.name)]).filter(Boolean),k=Yb([...D,...O]),A=Yb(O),ee=e.cronForm.deliveryMode===`webhook`?k.filter(e=>qb(e)):k;return n`
${ey({open:e.paletteOpen,query:e.paletteQuery,activeIndex:e.paletteActiveIndex,onToggle:()=>{e.paletteOpen=!e.paletteOpen},onQueryChange:t=>{e.paletteQuery=t},onActiveIndexChange:t=>{e.paletteActiveIndex=t},onNavigate:t=>{e.setTab(t)},onSlashCommand:t=>{e.setTab(`chat`),e.chatMessage=t.endsWith(` `)?t:`${t} `}})}
<div
class="shell ${l?`shell--chat`:``} ${u?`shell--chat-focus`:``} ${f?`shell--nav-collapsed`:``} ${d?`shell--nav-drawer-open`:``} ${e.onboarding?`shell--onboarding`:``}"
>
<button
type="button"
class="shell-nav-backdrop"
aria-label="${P(`nav.collapse`)}"
@click=${()=>{e.navDrawerOpen=!1}}
></button>
<header class="topbar">
<div class="topnav-shell">
<button
type="button"
class="topbar-nav-toggle"
@click=${()=>{e.navDrawerOpen=!d}}
title="${P(d?`nav.collapse`:`nav.expand`)}"
aria-label="${P(d?`nav.collapse`:`nav.expand`)}"
aria-expanded=${d}
>
<span class="nav-collapse-toggle__icon" aria-hidden="true">${G.menu}</span>
</button>
<div class="topnav-shell__content">
<dashboard-header .tab=${e.tab}></dashboard-header>
</div>
<div class="topnav-shell__actions">
<button
class="topbar-search"
@click=${()=>{e.paletteOpen=!e.paletteOpen}}
title="Search or jump to… (⌘K)"
aria-label="Open command palette"
>
<span class="topbar-search__label">${P(`common.search`)}</span>
<kbd class="topbar-search__kbd">⌘K</kbd>
</button>
<div class="topbar-status">
${l?pv(e):i}
${Nv(e)}
</div>
</div>
</div>
</header>
<div class="shell-nav">
<aside class="sidebar ${f?`sidebar--collapsed`:``}">
<div class="sidebar-shell">
<div class="sidebar-shell__header">
<div class="sidebar-brand">
${f?i:n`
<img class="sidebar-brand__logo" src="${xu(v)}" alt="OpenClaw" />
<span class="sidebar-brand__copy">
<span class="sidebar-brand__eyebrow">${P(`nav.control`)}</span>
<span class="sidebar-brand__title">OpenClaw</span>
</span>
`}
</div>
<button
type="button"
class="nav-collapse-toggle"
@click=${()=>e.applySettings({...e.settings,navCollapsed:!e.settings.navCollapsed})}
title="${P(f?`nav.expand`:`nav.collapse`)}"
aria-label="${P(f?`nav.expand`:`nav.collapse`)}"
>
<span class="nav-collapse-toggle__icon" aria-hidden="true">${f?G.panelLeftOpen:G.panelLeftClose}</span>
</button>
</div>
<div class="sidebar-shell__body">
<nav class="sidebar-nav">
${ha.map(t=>{let r=e.settings.navGroupsCollapsed[t.label]??!1,a=t.tabs.some(t=>t===e.tab),o=f||a||!r;return n`
<section class="nav-section ${o?``:`nav-section--collapsed`}">
${f?i:n`
<button
class="nav-section__label"
@click=${()=>{let n={...e.settings.navGroupsCollapsed};n[t.label]=!r,e.applySettings({...e.settings,navGroupsCollapsed:n})}}
aria-expanded=${o}
>
<span class="nav-section__label-text">${P(`nav.${t.label}`)}</span>
<span class="nav-section__chevron">
${G.chevronDown}
</span>
</button>
`}
<div class="nav-section__items">
${t.tabs.map(t=>lv(e,t,{collapsed:f}))}
</div>
</section>
`})}
</nav>
</div>
<div class="sidebar-shell__footer">
<div class="sidebar-utility-group">
<a
class="nav-item nav-item--external sidebar-utility-link"
href="https://docs.openclaw.ai"
target=${Vv}
rel=${Hv()}
title="${P(`common.docs`)} (opens in new tab)"
>
<span class="nav-item__icon" aria-hidden="true">${G.book}</span>
${f?i:n`
<span class="nav-item__text">${P(`common.docs`)}</span>
<span class="nav-item__external-icon">${G.externalLink}</span>
`}
</a>
<div class="sidebar-mode-switch">
${Nv(e)}
</div>
${(()=>{let t=e.hello?.server?.version??``;return t?n`
<div class="sidebar-version" title=${`v${t}`}>
${f?n`
${Pv(e)}
`:n`
<span class="sidebar-version__label">${P(`common.version`)}</span>
<span class="sidebar-version__text">v${t}</span>
${Pv(e)}
`}
</div>
`:i})()}
</div>
</div>
</div>
</aside>
</div>
<main class="content ${l?`content--chat`:``}">
${e.updateAvailable&&e.updateAvailable.latestVersion!==e.updateAvailable.currentVersion&&!Zb(e.updateAvailable)?n`<div class="update-banner callout danger" role="alert">
<strong>Update available:</strong> v${e.updateAvailable.latestVersion}
(running v${e.updateAvailable.currentVersion}).
<button
class="btn btn--sm update-banner__btn"
?disabled=${e.updateRunning||!e.connected}
@click=${()=>Nn(e)}
>${e.updateRunning?`Updating…`:`Update now`}</button>
<button
class="update-banner__close"
type="button"
title="Dismiss"
aria-label="Dismiss update banner"
@click=${()=>{Qb(e.updateAvailable),e.updateAvailable=null}}
>
${G.x}
</button>
</div>`:i}
${e.tab===`config`?i:n`<section class="content-header">
<div>
${l?dv(e):n`<div class="page-title">${wa(e.tab)}</div>`}
${l?i:n`<div class="page-sub">${Ta(e.tab)}</div>`}
</div>
<div class="page-meta">
${e.lastError?n`<div class="pill danger">${e.lastError}</div>`:i}
${l?fv(e):i}
</div>
</section>`}
${e.tab===`overview`?jb({connected:e.connected,hello:e.hello,settings:e.settings,password:e.password,lastError:e.lastError,lastErrorCode:e.lastErrorCode,presenceCount:a,sessionsCount:o,cronEnabled:e.cronStatus?.enabled??null,cronNext:s,lastChannelsRefresh:e.channelsLastSuccess,usageResult:e.usageResult,sessionsResult:e.sessionsResult,skillsReport:e.skillsReport,cronJobs:e.cronJobs,cronStatus:e.cronStatus,attentionItems:e.attentionItems,eventLog:e.eventLog,overviewLogLines:e.overviewLogLines,showGatewayToken:e.overviewShowGatewayToken,showGatewayPassword:e.overviewShowGatewayPassword,onSettingsChange:t=>e.applySettings(t),onPasswordChange:t=>e.password=t,onSessionKeyChange:t=>{e.sessionKey=t,e.chatMessage=``,e.resetToolStream(),e.applySettings({...e.settings,sessionKey:t,lastActiveSessionKey:t}),e.loadAssistantIdentity()},onToggleGatewayTokenVisibility:()=>{e.overviewShowGatewayToken=!e.overviewShowGatewayToken},onToggleGatewayPasswordVisibility:()=>{e.overviewShowGatewayPassword=!e.overviewShowGatewayPassword},onConnect:()=>e.connect(),onRefresh:()=>e.loadOverview(),onNavigate:t=>e.setTab(t),onRefreshLogs:()=>e.loadOverview()}):i}
${e.tab===`channels`?Ub(Fb,t=>t.renderChannels({connected:e.connected,loading:e.channelsLoading,snapshot:e.channelsSnapshot,lastError:e.channelsError,lastSuccessAt:e.channelsLastSuccess,whatsappMessage:e.whatsappLoginMessage,whatsappQrDataUrl:e.whatsappLoginQrDataUrl,whatsappConnected:e.whatsappLoginConnected,whatsappBusy:e.whatsappBusy,configSchema:e.configSchema,configSchemaLoading:e.configSchemaLoading,configForm:e.configForm,configUiHints:e.configUiHints,configSaving:e.configSaving,configFormDirty:e.configFormDirty,nostrProfileFormState:e.nostrProfileFormState,nostrProfileAccountId:e.nostrProfileAccountId,onRefresh:t=>Zt(e,t),onWhatsAppStart:t=>e.handleWhatsAppStart(t),onWhatsAppWait:()=>e.handleWhatsAppWait(),onWhatsAppLogout:()=>e.handleWhatsAppLogout(),onConfigPatch:(t,n)=>W(e,t,n),onConfigSave:()=>e.handleChannelConfigSave(),onConfigReload:()=>e.handleChannelConfigReload(),onNostrProfileEdit:(t,n)=>e.handleNostrProfileEdit(t,n),onNostrProfileCancel:()=>e.handleNostrProfileCancel(),onNostrProfileFieldChange:(t,n)=>e.handleNostrProfileFieldChange(t,n),onNostrProfileSave:()=>e.handleNostrProfileSave(),onNostrProfileImport:()=>e.handleNostrProfileImport(),onNostrProfileToggleAdvanced:()=>e.handleNostrProfileToggleAdvanced()})):i}
${e.tab===`instances`?Ub(Rb,t=>t.renderInstances({loading:e.presenceLoading,entries:e.presenceEntries,lastError:e.presenceError,statusMessage:e.presenceStatus,onRefresh:()=>Ii(e)})):i}
${e.tab===`sessions`?Ub(Vb,t=>t.renderSessions({loading:e.sessionsLoading,result:e.sessionsResult,error:e.sessionsError,activeMinutes:e.sessionsFilterActive,limit:e.sessionsFilterLimit,includeGlobal:e.sessionsIncludeGlobal,includeUnknown:e.sessionsIncludeUnknown,basePath:e.basePath,searchQuery:e.sessionsSearchQuery,sortColumn:e.sessionsSortColumn,sortDir:e.sessionsSortDir,page:e.sessionsPage,pageSize:e.sessionsPageSize,selectedKeys:e.sessionsSelectedKeys,onFiltersChange:t=>{e.sessionsFilterActive=t.activeMinutes,e.sessionsFilterLimit=t.limit,e.sessionsIncludeGlobal=t.includeGlobal,e.sessionsIncludeUnknown=t.includeUnknown},onSearchChange:t=>{e.sessionsSearchQuery=t,e.sessionsPage=0},onSortChange:(t,n)=>{e.sessionsSortColumn=t,e.sessionsSortDir=n,e.sessionsPage=0},onPageChange:t=>{e.sessionsPage=t},onPageSizeChange:t=>{e.sessionsPageSize=t,e.sessionsPage=0},onRefresh:()=>Ri(e),onPatch:(t,n)=>zi(e,t,n),onToggleSelect:t=>{let n=new Set(e.sessionsSelectedKeys);n.has(t)?n.delete(t):n.add(t),e.sessionsSelectedKeys=n},onSelectPage:t=>{let n=new Set(e.sessionsSelectedKeys);for(let e of t)n.add(e);e.sessionsSelectedKeys=n},onDeselectPage:t=>{let n=new Set(e.sessionsSelectedKeys);for(let e of t)n.delete(e);e.sessionsSelectedKeys=n},onDeselectAll:()=>{e.sessionsSelectedKeys=new Set},onDeleteSelected:async()=>{let t=await Bi(e,[...e.sessionsSelectedKeys]);if(t.length>0){let n=new Set(e.sessionsSelectedKeys);for(let e of t)n.delete(e);e.sessionsSelectedKeys=n}},onNavigateToChat:t=>{mv(e,t),e.setTab(`chat`)}})):i}
${ov(e)}
${e.tab===`cron`?Ub(Ib,t=>t.renderCron({basePath:e.basePath,loading:e.cronLoading,status:e.cronStatus,jobs:T,jobsLoadingMore:e.cronJobsLoadingMore,jobsTotal:e.cronJobsTotal,jobsHasMore:e.cronJobsHasMore,jobsQuery:e.cronJobsQuery,jobsEnabledFilter:e.cronJobsEnabledFilter,jobsScheduleKindFilter:e.cronJobsScheduleKindFilter,jobsLastStatusFilter:e.cronJobsLastStatusFilter,jobsSortBy:e.cronJobsSortBy,jobsSortDir:e.cronJobsSortDir,editingJobId:e.cronEditingJobId,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:e.channelsSnapshot?.channelMeta?.length?e.channelsSnapshot.channelMeta.map(e=>e.id):e.channelsSnapshot?.channelOrder??[],channelLabels:e.channelsSnapshot?.channelLabels??{},channelMeta:e.channelsSnapshot?.channelMeta??[],runsJobId:e.cronRunsJobId,runs:e.cronRuns,runsTotal:e.cronRunsTotal,runsHasMore:e.cronRunsHasMore,runsLoadingMore:e.cronRunsLoadingMore,runsScope:e.cronRunsScope,runsStatuses:e.cronRunsStatuses,runsDeliveryStatuses:e.cronRunsDeliveryStatuses,runsStatusFilter:e.cronRunsStatusFilter,runsQuery:e.cronRunsQuery,runsSortDir:e.cronRunsSortDir,fieldErrors:e.cronFieldErrors,canSubmit:!Yr(e.cronFieldErrors),agentSuggestions:C,modelSuggestions:w,thinkingSuggestions:Gb,timezoneSuggestions:Kb,deliveryToSuggestions:ee,accountSuggestions:A,onFormChange:t=>{e.cronForm=qr({...e.cronForm,...t}),e.cronFieldErrors=Jr(e.cronForm)},onRefresh:()=>e.loadCron(),onAdd:()=>pi(e),onEdit:t=>bi(e,t),onClone:t=>Si(e,t),onCancelEdit:()=>Ci(e),onToggle:(t,n)=>mi(e,t,n),onRun:(t,n)=>hi(e,t,n??`force`),onRemove:t=>gi(e,t),onLoadRuns:async t=>{yi(e,{cronRunsScope:`job`}),await _i(e,t)},onLoadMoreJobs:()=>ei(e),onJobsFiltersChange:async t=>{ni(e,t),(typeof t.cronJobsQuery==`string`||t.cronJobsEnabledFilter||t.cronJobsSortBy||t.cronJobsSortDir)&&await ti(e)},onJobsFiltersReset:async()=>{ni(e,{cronJobsQuery:``,cronJobsEnabledFilter:`all`,cronJobsScheduleKindFilter:`all`,cronJobsLastStatusFilter:`all`,cronJobsSortBy:`nextRunAtMs`,cronJobsSortDir:`asc`}),await ti(e)},onLoadMoreRuns:()=>vi(e),onRunsFiltersChange:async t=>{if(yi(e,t),e.cronRunsScope===`all`){await _i(e,null);return}await _i(e,e.cronRunsJobId)},onNavigateToChat:t=>{mv(e,t),e.setTab(`chat`)}})):i}
${e.tab===`agents`?Ub(Pb,t=>t.renderAgents({basePath:e.basePath??``,loading:e.agentsLoading,error:e.agentsError,agentsList:e.agentsList,selectedAgentId:y,activePanel:e.agentsPanel,config:{form:_,loading:e.configLoading,saving:e.configSaving,dirty:e.configFormDirty},channels:{snapshot:e.channelsSnapshot,loading:e.channelsLoading,error:e.channelsError,lastSuccess:e.channelsLastSuccess},cron:{status:e.cronStatus,jobs:e.cronJobs,loading:e.cronLoading,error:e.cronError},agentFiles:{list:e.agentFilesList,loading:e.agentFilesLoading,error:e.agentFilesError,active:e.agentFileActive,contents:e.agentFileContents,drafts:e.agentFileDrafts,saving:e.agentFileSaving},agentIdentityLoading:e.agentIdentityLoading,agentIdentityError:e.agentIdentityError,agentIdentityById:e.agentIdentityById,agentSkills:{report:e.agentSkillsReport,loading:e.agentSkillsLoading,error:e.agentSkillsError,agentId:e.agentSkillsAgentId,filter:e.skillsFilter},toolsCatalog:{loading:e.toolsCatalogLoading,error:e.toolsCatalogError,result:e.toolsCatalogResult},onRefresh:async()=>{await Br(e);let t=e.agentsList?.agents?.map(e=>e.id)??[];t.length>0&&Rr(e,t);let n=e.agentsSelectedId??e.agentsList?.defaultId??e.agentsList?.agents?.[0]?.id??null;e.agentsPanel===`files`&&n&&Iv(e,n),e.agentsPanel===`skills`&&n&&zr(e,n),e.agentsPanel===`tools`&&n&&Vr(e,n),e.agentsPanel===`channels`&&Zt(e,!1),e.agentsPanel===`cron`&&e.loadCron()},onSelectAgent:t=>{e.agentsSelectedId!==t&&(e.agentsSelectedId=t,e.agentFilesList=null,e.agentFilesError=null,e.agentFilesLoading=!1,e.agentFileActive=null,e.agentFileContents={},e.agentFileDrafts={},e.agentSkillsReport=null,e.agentSkillsError=null,e.agentSkillsAgentId=null,e.toolsCatalogResult=null,e.toolsCatalogError=null,e.toolsCatalogLoading=!1,Lr(e,t),e.agentsPanel===`files`&&Iv(e,t),e.agentsPanel===`tools`&&Vr(e,t),e.agentsPanel===`skills`&&zr(e,t))},onSelectPanel:t=>{e.agentsPanel=t,t===`files`&&y&&e.agentFilesList?.agentId!==y&&(e.agentFilesList=null,e.agentFilesError=null,e.agentFileActive=null,e.agentFileContents={},e.agentFileDrafts={},Iv(e,y)),t===`skills`&&y&&zr(e,y),t===`tools`&&y&&(e.toolsCatalogResult?.agentId!==y||e.toolsCatalogError)&&Vr(e,y),t===`channels`&&Zt(e,!1),t===`cron`&&e.loadCron()},onLoadFiles:t=>Iv(e,t),onSelectFile:t=>{e.agentFileActive=t,y&&Lv(e,y,t)},onFileDraftChange:(t,n)=>{e.agentFileDrafts={...e.agentFileDrafts,[t]:n}},onFileReset:t=>{let n=e.agentFileContents[t]??``;e.agentFileDrafts={...e.agentFileDrafts,[t]:n}},onFileSave:t=>{y&&Rv(e,y,t,e.agentFileDrafts[t]??e.agentFileContents[t]??``)},onToolsProfileChange:(t,n,r)=>{let i=n||r?S(t):x(t);if(i<0)return;let a=[`agents`,`list`,i,`tools`];n?W(e,[...a,`profile`],n):Pn(e,[...a,`profile`]),r&&Pn(e,[...a,`allow`])},onToolsOverridesChange:(t,n,r)=>{let i=n.length>0||r.length>0?S(t):x(t);if(i<0)return;let a=[`agents`,`list`,i,`tools`];n.length>0?W(e,[...a,`alsoAllow`],n):Pn(e,[...a,`alsoAllow`]),r.length>0?W(e,[...a,`deny`],r):Pn(e,[...a,`deny`])},onConfigReload:()=>Tn(e),onConfigSave:()=>Hr(e),onChannelsRefresh:()=>Zt(e,!1),onCronRefresh:()=>e.loadCron(),onCronRunNow:t=>{let n=e.cronJobs.find(e=>e.id===t);n&&hi(e,n,`force`)},onSkillsFilterChange:t=>e.skillsFilter=t,onSkillsRefresh:()=>{y&&zr(e,y)},onAgentSkillToggle:(t,n,r)=>{let i=S(t);if(i<0)return;let a=b()?.agents?.list,o=Array.isArray(a)?a[i]:void 0,s=n.trim();if(!s)return;let c=e.agentSkillsReport?.skills?.map(e=>e.name).filter(Boolean)??[],l=(Array.isArray(o?.skills)?o.skills.map(e=>String(e).trim()).filter(Boolean):void 0)??c,u=new Set(l);r?u.add(s):u.delete(s),W(e,[`agents`,`list`,i,`skills`],[...u])},onAgentSkillsClear:t=>{let n=x(t);n<0||Pn(e,[`agents`,`list`,n,`skills`])},onAgentSkillsDisableAll:t=>{let n=S(t);n<0||W(e,[`agents`,`list`,n,`skills`],[])},onModelChange:(t,n)=>{let r=n?S(t):x(t);if(r<0)return;let i=b()?.agents?.list,a=[`agents`,`list`,r,`model`];if(!n){Pn(e,a);return}let o=(Array.isArray(i)?i[r]:void 0)?.model;if(o&&typeof o==`object`&&!Array.isArray(o)){let t=o.fallbacks;W(e,a,{primary:n,...Array.isArray(t)?{fallbacks:t}:{}})}else W(e,a,n)},onModelFallbacksChange:(t,n)=>{let r=n.map(e=>e.trim()).filter(Boolean),i=wu(b(),t),a=Ou(i.entry?.model)??Ou(i.defaults?.model),o=Au(i.entry?.model,i.defaults?.model),s=r.length>0?a?S(t):-1:(o?.length??0)>0||x(t)>=0?S(t):-1;if(s<0)return;let c=b()?.agents?.list,l=[`agents`,`list`,s,`model`],u=(Array.isArray(c)?c[s]:void 0)?.model,d=(()=>{if(typeof u==`string`)return u.trim()||null;if(u&&typeof u==`object`&&!Array.isArray(u)){let e=u.primary;if(typeof e==`string`)return e.trim()||null}return null})()??a;if(r.length===0){d?W(e,l,d):Pn(e,l);return}d&&W(e,l,{primary:d,fallbacks:r})},onSetDefault:t=>{_&&W(e,[`agents`,`defaultId`],t)}})):i}
${e.tab===`skills`?Ub(Hb,t=>t.renderSkills({connected:e.connected,loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,onFilterChange:t=>e.skillsFilter=t,onRefresh:()=>Ui(e,{clearMessages:!0}),onToggle:(t,n)=>Gi(e,t,n),onEdit:(t,n)=>Wi(e,t,n),onSaveKey:t=>Ki(e,t),onInstall:(t,n,r)=>qi(e,t,n,r)})):i}
${e.tab===`nodes`?Ub(Bb,t=>t.renderNodes({loading:e.nodesLoading,nodes:e.nodes,devicesLoading:e.devicesLoading,devicesError:e.devicesError,devicesList:e.devicesList,configForm:e.configForm??e.configSnapshot?.config,configLoading:e.configLoading,configSaving:e.configSaving,configDirty:e.configFormDirty,configFormMode:e.configFormMode,execApprovalsLoading:e.execApprovalsLoading,execApprovalsSaving:e.execApprovalsSaving,execApprovalsDirty:e.execApprovalsDirty,execApprovalsSnapshot:e.execApprovalsSnapshot,execApprovalsForm:e.execApprovalsForm,execApprovalsSelectedAgent:e.execApprovalsSelectedAgent,execApprovalsTarget:e.execApprovalsTarget,execApprovalsTargetNodeId:e.execApprovalsTargetNodeId,onRefresh:()=>Ar(e),onDevicesRefresh:()=>wi(e),onDeviceApprove:t=>Ti(e,t),onDeviceReject:t=>Ei(e,t),onDeviceRotate:(t,n,r)=>Di(e,{deviceId:t,role:n,scopes:r}),onDeviceRevoke:(t,n)=>Oi(e,{deviceId:t,role:n}),onLoadConfig:()=>Tn(e),onLoadExecApprovals:()=>ji(e,e.execApprovalsTarget===`node`&&e.execApprovalsTargetNodeId?{kind:`node`,nodeId:e.execApprovalsTargetNodeId}:{kind:`gateway`}),onBindDefault:t=>{t?W(e,[`tools`,`exec`,`node`],t):Pn(e,[`tools`,`exec`,`node`])},onBindAgent:(t,n)=>{let r=[`agents`,`list`,t,`tools`,`exec`,`node`];n?W(e,r,n):Pn(e,r)},onSaveBindings:()=>jn(e),onExecApprovalsTargetChange:(t,n)=>{e.execApprovalsTarget=t,e.execApprovalsTargetNodeId=n,e.execApprovalsSnapshot=null,e.execApprovalsForm=null,e.execApprovalsDirty=!1,e.execApprovalsSelectedAgent=null},onExecApprovalsSelectAgent:t=>{e.execApprovalsSelectedAgent=t},onExecApprovalsPatch:(t,n)=>Pi(e,t,n),onExecApprovalsRemove:t=>Fi(e,t),onSaveExecApprovals:()=>Ni(e,e.execApprovalsTarget===`node`&&e.execApprovalsTargetNodeId?{kind:`node`,nodeId:e.execApprovalsTargetNodeId}:{kind:`gateway`})})):i}
${e.tab===`chat`?Np({sessionKey:e.sessionKey,onSessionKeyChange:t=>{e.sessionKey=t,e.chatMessage=``,e.chatAttachments=[],e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:t,lastActiveSessionKey:t}),e.loadAssistantIdentity(),Fh(e),cg(e)},thinkingLevel:e.chatThinkingLevel,showThinking:p,showToolCalls:m,loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,fallbackStatus:e.fallbackStatus,assistantAvatarUrl:g,messages:e.chatMessages,toolMessages:e.chatToolMessages,streamSegments:e.chatStreamSegments,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,draft:e.chatMessage,queue:e.chatQueue,connected:e.connected,canSend:e.connected,disabledReason:c,error:e.lastError,sessions:e.sessionsResult,focusMode:u,onRefresh:()=>(e.resetToolStream(),Promise.all([Fh(e),cg(e)])),onToggleFocusMode:()=>{e.onboarding||e.applySettings({...e.settings,chatFocusMode:!e.settings.chatFocusMode})},onChatScroll:t=>e.handleChatScroll(t),getDraft:()=>e.chatMessage,onDraftChange:t=>e.chatMessage=t,onRequestUpdate:r,attachments:e.chatAttachments,onAttachmentsChange:t=>e.chatAttachments=t,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>void e.handleAbortChat(),onQueueRemove:t=>e.removeQueuedMessage(t),onNewSession:()=>e.handleSendChat(`/new`,{restoreDraft:!0}),onClearHistory:async()=>{if(!(!e.client||!e.connected))try{await e.client.request(`sessions.reset`,{key:e.sessionKey}),e.chatMessages=[],e.chatStream=null,e.chatRunId=null,await Fh(e)}catch(t){e.lastError=String(t)}},agentsList:e.agentsList,currentAgentId:y??`main`,onAgentChange:t=>{e.sessionKey=$m({agentId:t}),e.chatMessages=[],e.chatStream=null,e.chatRunId=null,e.applySettings({...e.settings,sessionKey:e.sessionKey,lastActiveSessionKey:e.sessionKey}),Fh(e),e.loadAssistantIdentity()},onNavigateToAgent:()=>{e.agentsSelectedId=y,e.setTab(`agents`)},onSessionSelect:t=>{mv(e,t)},showNewMessages:e.chatNewMessagesBelow&&!e.chatManualRefreshInFlight,onScrollToBottom:()=>e.scrollToBottom(),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:t=>e.handleOpenSidebar(t),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:t=>e.handleSplitRatioChange(t),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,basePath:e.basePath??``}):i}
${e.tab===`config`?tb({raw:e.configRaw,originalRaw:e.configRawOriginal,valid:e.configValid,issues:e.configIssues,loading:e.configLoading,saving:e.configSaving,applying:e.configApplying,updating:e.updateRunning,connected:e.connected,schema:e.configSchema,schemaLoading:e.configSchemaLoading,uiHints:e.configUiHints,formMode:e.configFormMode,showModeToggle:!0,formValue:e.configForm,originalValue:e.configFormOriginal,searchQuery:e.configSearchQuery,activeSection:e.configActiveSection&&(tx.includes(e.configActiveSection)||nx.includes(e.configActiveSection)||rx.includes(e.configActiveSection)||ix.includes(e.configActiveSection)||ax.includes(e.configActiveSection))?null:e.configActiveSection,activeSubsection:e.configActiveSection&&(tx.includes(e.configActiveSection)||nx.includes(e.configActiveSection)||rx.includes(e.configActiveSection)||ix.includes(e.configActiveSection)||ax.includes(e.configActiveSection))?null:e.configActiveSubsection,onRawChange:t=>{e.configRaw=t},onRequestUpdate:r,onFormModeChange:t=>e.configFormMode=t,onFormPatch:(t,n)=>W(e,t,n),onSearchChange:t=>e.configSearchQuery=t,onSectionChange:t=>{e.configActiveSection=t,e.configActiveSubsection=null},onSubsectionChange:t=>e.configActiveSubsection=t,onReload:()=>Tn(e),onSave:()=>jn(e),onApply:()=>Mn(e),onUpdate:()=>Nn(e),onOpenFile:()=>Ln(e),version:e.hello?.server?.version??``,theme:e.theme,themeMode:e.themeMode,setTheme:(t,n)=>e.setTheme(t,n),setThemeMode:(t,n)=>e.setThemeMode(t,n),borderRadius:e.settings.borderRadius,setBorderRadius:t=>e.setBorderRadius(t),gatewayUrl:e.settings.gatewayUrl,assistantName:e.assistantName,configPath:e.configSnapshot?.path??null,excludeSections:[...tx,...rx,...ix,...ax,`ui`,`wizard`],includeVirtualSections:!1}):i}
${e.tab===`communications`?tb({raw:e.configRaw,originalRaw:e.configRawOriginal,valid:e.configValid,issues:e.configIssues,loading:e.configLoading,saving:e.configSaving,applying:e.configApplying,updating:e.updateRunning,connected:e.connected,schema:e.configSchema,schemaLoading:e.configSchemaLoading,uiHints:e.configUiHints,formMode:e.communicationsFormMode,formValue:e.configForm,originalValue:e.configFormOriginal,searchQuery:e.communicationsSearchQuery,activeSection:e.communicationsActiveSection&&!tx.includes(e.communicationsActiveSection)?null:e.communicationsActiveSection,activeSubsection:e.communicationsActiveSection&&!tx.includes(e.communicationsActiveSection)?null:e.communicationsActiveSubsection,onRawChange:t=>{e.configRaw=t},onRequestUpdate:r,onFormModeChange:t=>e.communicationsFormMode=t,onFormPatch:(t,n)=>W(e,t,n),onSearchChange:t=>e.communicationsSearchQuery=t,onSectionChange:t=>{e.communicationsActiveSection=t,e.communicationsActiveSubsection=null},onSubsectionChange:t=>e.communicationsActiveSubsection=t,onReload:()=>Tn(e),onSave:()=>jn(e),onApply:()=>Mn(e),onUpdate:()=>Nn(e),onOpenFile:()=>Ln(e),version:e.hello?.server?.version??``,theme:e.theme,themeMode:e.themeMode,setTheme:(t,n)=>e.setTheme(t,n),setThemeMode:(t,n)=>e.setThemeMode(t,n),borderRadius:e.settings.borderRadius,setBorderRadius:t=>e.setBorderRadius(t),gatewayUrl:e.settings.gatewayUrl,assistantName:e.assistantName,configPath:e.configSnapshot?.path??null,navRootLabel:`Communication`,includeSections:[...tx],includeVirtualSections:!1}):i}
${e.tab===`appearance`?tb({raw:e.configRaw,originalRaw:e.configRawOriginal,valid:e.configValid,issues:e.configIssues,loading:e.configLoading,saving:e.configSaving,applying:e.configApplying,updating:e.updateRunning,connected:e.connected,schema:e.configSchema,schemaLoading:e.configSchemaLoading,uiHints:e.configUiHints,formMode:e.appearanceFormMode,formValue:e.configForm,originalValue:e.configFormOriginal,searchQuery:e.appearanceSearchQuery,activeSection:e.appearanceActiveSection&&!nx.includes(e.appearanceActiveSection)?null:e.appearanceActiveSection,activeSubsection:e.appearanceActiveSection&&!nx.includes(e.appearanceActiveSection)?null:e.appearanceActiveSubsection,onRawChange:t=>{e.configRaw=t},onRequestUpdate:r,onFormModeChange:t=>e.appearanceFormMode=t,onFormPatch:(t,n)=>W(e,t,n),onSearchChange:t=>e.appearanceSearchQuery=t,onSectionChange:t=>{e.appearanceActiveSection=t,e.appearanceActiveSubsection=null},onSubsectionChange:t=>e.appearanceActiveSubsection=t,onReload:()=>Tn(e),onSave:()=>jn(e),onApply:()=>Mn(e),onUpdate:()=>Nn(e),onOpenFile:()=>Ln(e),version:e.hello?.server?.version??``,theme:e.theme,themeMode:e.themeMode,setTheme:(t,n)=>e.setTheme(t,n),setThemeMode:(t,n)=>e.setThemeMode(t,n),borderRadius:e.settings.borderRadius,setBorderRadius:t=>e.setBorderRadius(t),gatewayUrl:e.settings.gatewayUrl,assistantName:e.assistantName,configPath:e.configSnapshot?.path??null,navRootLabel:`Appearance`,includeSections:[...nx],includeVirtualSections:!0}):i}
${e.tab===`automation`?tb({raw:e.configRaw,originalRaw:e.configRawOriginal,valid:e.configValid,issues:e.configIssues,loading:e.configLoading,saving:e.configSaving,applying:e.configApplying,updating:e.updateRunning,connected:e.connected,schema:e.configSchema,schemaLoading:e.configSchemaLoading,uiHints:e.configUiHints,formMode:e.automationFormMode,formValue:e.configForm,originalValue:e.configFormOriginal,searchQuery:e.automationSearchQuery,activeSection:e.automationActiveSection&&!rx.includes(e.automationActiveSection)?null:e.automationActiveSection,activeSubsection:e.automationActiveSection&&!rx.includes(e.automationActiveSection)?null:e.automationActiveSubsection,onRawChange:t=>{e.configRaw=t},onRequestUpdate:r,onFormModeChange:t=>e.automationFormMode=t,onFormPatch:(t,n)=>W(e,t,n),onSearchChange:t=>e.automationSearchQuery=t,onSectionChange:t=>{e.automationActiveSection=t,e.automationActiveSubsection=null},onSubsectionChange:t=>e.automationActiveSubsection=t,onReload:()=>Tn(e),onSave:()=>jn(e),onApply:()=>Mn(e),onUpdate:()=>Nn(e),onOpenFile:()=>Ln(e),version:e.hello?.server?.version??``,theme:e.theme,themeMode:e.themeMode,setTheme:(t,n)=>e.setTheme(t,n),setThemeMode:(t,n)=>e.setThemeMode(t,n),borderRadius:e.settings.borderRadius,setBorderRadius:t=>e.setBorderRadius(t),gatewayUrl:e.settings.gatewayUrl,assistantName:e.assistantName,configPath:e.configSnapshot?.path??null,navRootLabel:`Automation`,includeSections:[...rx],includeVirtualSections:!1}):i}
${e.tab===`infrastructure`?tb({raw:e.configRaw,originalRaw:e.configRawOriginal,valid:e.configValid,issues:e.configIssues,loading:e.configLoading,saving:e.configSaving,applying:e.configApplying,updating:e.updateRunning,connected:e.connected,schema:e.configSchema,schemaLoading:e.configSchemaLoading,uiHints:e.configUiHints,formMode:e.infrastructureFormMode,formValue:e.configForm,originalValue:e.configFormOriginal,searchQuery:e.infrastructureSearchQuery,activeSection:e.infrastructureActiveSection&&!ix.includes(e.infrastructureActiveSection)?null:e.infrastructureActiveSection,activeSubsection:e.infrastructureActiveSection&&!ix.includes(e.infrastructureActiveSection)?null:e.infrastructureActiveSubsection,onRawChange:t=>{e.configRaw=t},onRequestUpdate:r,onFormModeChange:t=>e.infrastructureFormMode=t,onFormPatch:(t,n)=>W(e,t,n),onSearchChange:t=>e.infrastructureSearchQuery=t,onSectionChange:t=>{e.infrastructureActiveSection=t,e.infrastructureActiveSubsection=null},onSubsectionChange:t=>e.infrastructureActiveSubsection=t,onReload:()=>Tn(e),onSave:()=>jn(e),onApply:()=>Mn(e),onUpdate:()=>Nn(e),onOpenFile:()=>Ln(e),version:e.hello?.server?.version??``,theme:e.theme,themeMode:e.themeMode,setTheme:(t,n)=>e.setTheme(t,n),setThemeMode:(t,n)=>e.setThemeMode(t,n),borderRadius:e.settings.borderRadius,setBorderRadius:t=>e.setBorderRadius(t),gatewayUrl:e.settings.gatewayUrl,assistantName:e.assistantName,configPath:e.configSnapshot?.path??null,navRootLabel:`Infrastructure`,includeSections:[...ix],includeVirtualSections:!1}):i}
${e.tab===`aiAgents`?tb({raw:e.configRaw,originalRaw:e.configRawOriginal,valid:e.configValid,issues:e.configIssues,loading:e.configLoading,saving:e.configSaving,applying:e.configApplying,updating:e.updateRunning,connected:e.connected,schema:e.configSchema,schemaLoading:e.configSchemaLoading,uiHints:e.configUiHints,formMode:e.aiAgentsFormMode,formValue:e.configForm,originalValue:e.configFormOriginal,searchQuery:e.aiAgentsSearchQuery,activeSection:e.aiAgentsActiveSection&&!ax.includes(e.aiAgentsActiveSection)?null:e.aiAgentsActiveSection,activeSubsection:e.aiAgentsActiveSection&&!ax.includes(e.aiAgentsActiveSection)?null:e.aiAgentsActiveSubsection,onRawChange:t=>{e.configRaw=t},onRequestUpdate:r,onFormModeChange:t=>e.aiAgentsFormMode=t,onFormPatch:(t,n)=>W(e,t,n),onSearchChange:t=>e.aiAgentsSearchQuery=t,onSectionChange:t=>{e.aiAgentsActiveSection=t,e.aiAgentsActiveSubsection=null},onSubsectionChange:t=>e.aiAgentsActiveSubsection=t,onReload:()=>Tn(e),onSave:()=>jn(e),onApply:()=>Mn(e),onUpdate:()=>Nn(e),onOpenFile:()=>Ln(e),version:e.hello?.server?.version??``,theme:e.theme,themeMode:e.themeMode,setTheme:(t,n)=>e.setTheme(t,n),setThemeMode:(t,n)=>e.setThemeMode(t,n),borderRadius:e.settings.borderRadius,setBorderRadius:t=>e.setBorderRadius(t),gatewayUrl:e.settings.gatewayUrl,assistantName:e.assistantName,configPath:e.configSnapshot?.path??null,navRootLabel:`AI & Agents`,includeSections:[...ax],includeVirtualSections:!1}):i}
${e.tab===`debug`?Ub(Lb,t=>t.renderDebug({loading:e.debugLoading,status:e.debugStatus,health:e.debugHealth,models:e.debugModels,heartbeat:e.debugHeartbeat,eventLog:e.eventLog,methods:(e.hello?.features?.methods??[]).toSorted(),callMethod:e.debugCallMethod,callParams:e.debugCallParams,callResult:e.debugCallResult,callError:e.debugCallError,onCallMethodChange:t=>e.debugCallMethod=t,onCallParamsChange:t=>e.debugCallParams=t,onRefresh:()=>Sr(e),onCall:()=>Cr(e)})):i}
${e.tab===`logs`?Ub(zb,t=>t.renderLogs({loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,truncated:e.logsTruncated,onFilterTextChange:t=>e.logsFilterText=t,onLevelToggle:(t,n)=>{e.logsLevelFilters={...e.logsLevelFilters,[t]:n}},onToggleAutoFollow:t=>e.logsAutoFollow=t,onRefresh:()=>kr(e,{reset:!0}),onExport:(t,n)=>e.exportLogs(t,n),onScroll:t=>e.handleLogsScroll(t)})):i}
</main>
${ib(e)}
${ab(e)}
${i}
</div>
`}var cx=pg({});function lx(){if(!window.location.search)return!1;let e=new URLSearchParams(window.location.search).get(`onboarding`);if(!e)return!1;let t=e.trim().toLowerCase();return t===`1`||t===`true`||t===`yes`||t===`on`}var $=class extends c{constructor(){super(),this.i18nController=new F(this),this.clientInstanceId=Lt(),this.connectGeneration=0,this.settings=Xa(),this.password=``,this.loginShowGatewayToken=!1,this.loginShowGatewayPassword=!1,this.tab=`chat`,this.onboarding=lx(),this.connected=!1,this.theme=this.settings.theme??`claw`,this.themeMode=this.settings.themeMode??`system`,this.themeResolved=`dark`,this.themeOrder=this.buildThemeOrder(this.theme),this.hello=null,this.lastError=null,this.lastErrorCode=null,this.eventLog=[],this.eventLogBuffer=[],this.toolStreamSyncTimer=null,this.sidebarCloseTimer=null,this.assistantName=cx.name,this.assistantAvatar=cx.avatar,this.assistantAgentId=cx.agentId??null,this.serverVersion=null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage=``,this.chatMessages=[],this.chatToolMessages=[],this.chatStreamSegments=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.fallbackStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.chatModelOverrides={},this.chatModelsLoading=!1,this.chatModelCatalog=[],this.chatQueue=[],this.chatAttachments=[],this.chatManualRefreshInFlight=!1,this.navDrawerOpen=!1,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.pendingGatewayUrl=null,this.pendingGatewayToken=null,this.configLoading=!1,this.configRaw=`{
}
`,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.communicationsFormMode=`form`,this.communicationsSearchQuery=``,this.communicationsActiveSection=null,this.communicationsActiveSubsection=null,this.appearanceFormMode=`form`,this.appearanceSearchQuery=``,this.appearanceActiveSection=null,this.appearanceActiveSubsection=null,this.automationFormMode=`form`,this.automationSearchQuery=``,this.automationActiveSection=null,this.automationActiveSubsection=null,this.infrastructureFormMode=`form`,this.infrastructureSearchQuery=``,this.infrastructureActiveSection=null,this.infrastructureActiveSubsection=null,this.aiAgentsFormMode=`form`,this.aiAgentsSearchQuery=``,this.aiAgentsActiveSection=null,this.aiAgentsActiveSubsection=null,this.channelsLoading=!1,this.channelsSnapshot=null,this.channelsError=null,this.channelsLastSuccess=null,this.whatsappLoginMessage=null,this.whatsappLoginQrDataUrl=null,this.whatsappLoginConnected=null,this.whatsappBusy=!1,this.nostrProfileFormState=null,this.nostrProfileAccountId=null,this.presenceLoading=!1,this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.agentsSelectedId=null,this.toolsCatalogLoading=!1,this.toolsCatalogError=null,this.toolsCatalogResult=null,this.agentsPanel=`overview`,this.agentFilesLoading=!1,this.agentFilesError=null,this.agentFilesList=null,this.agentFileContents={},this.agentFileDrafts={},this.agentFileActive=null,this.agentFileSaving=!1,this.agentIdentityLoading=!1,this.agentIdentityError=null,this.agentIdentityById={},this.agentSkillsLoading=!1,this.agentSkillsError=null,this.agentSkillsReport=null,this.agentSkillsAgentId=null,this.sessionsLoading=!1,this.sessionsResult=null,this.sessionsError=null,this.sessionsFilterActive=``,this.sessionsFilterLimit=`120`,this.sessionsIncludeGlobal=!0,this.sessionsIncludeUnknown=!1,this.sessionsHideCron=!0,this.sessionsSearchQuery=``,this.sessionsSortColumn=`updated`,this.sessionsSortDir=`desc`,this.sessionsPage=0,this.sessionsPageSize=25,this.sessionsSelectedKeys=new Set,this.usageLoading=!1,this.usageResult=null,this.usageCostSummary=null,this.usageError=null,this.usageStartDate=(()=>{let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`})(),this.usageEndDate=(()=>{let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`})(),this.usageSelectedSessions=[],this.usageSelectedDays=[],this.usageSelectedHours=[],this.usageChartMode=`tokens`,this.usageDailyChartMode=`by-type`,this.usageTimeSeriesMode=`per-turn`,this.usageTimeSeriesBreakdownMode=`by-type`,this.usageTimeSeries=null,this.usageTimeSeriesLoading=!1,this.usageTimeSeriesCursorStart=null,this.usageTimeSeriesCursorEnd=null,this.usageSessionLogs=null,this.usageSessionLogsLoading=!1,this.usageSessionLogsExpanded=!1,this.usageQuery=``,this.usageQueryDraft=``,this.usageSessionSort=`recent`,this.usageSessionSortDir=`desc`,this.usageRecentSessions=[],this.usageTimeZone=`local`,this.usageContextExpanded=!1,this.usageHeaderPinned=!1,this.usageSessionsTab=`all`,this.usageVisibleColumns=[`channel`,`agent`,`provider`,`model`,`messages`,`tools`,`errors`,`duration`],this.usageLogFilterRoles=[],this.usageLogFilterTools=[],this.usageLogFilterHasTools=!1,this.usageLogFilterQuery=``,this.usageQueryDebounceTimer=null,this.cronLoading=!1,this.cronJobsLoadingMore=!1,this.cronJobs=[],this.cronJobsTotal=0,this.cronJobsHasMore=!1,this.cronJobsNextOffset=null,this.cronJobsLimit=50,this.cronJobsQuery=``,this.cronJobsEnabledFilter=`all`,this.cronJobsScheduleKindFilter=`all`,this.cronJobsLastStatusFilter=`all`,this.cronJobsSortBy=`nextRunAtMs`,this.cronJobsSortDir=`asc`,this.cronStatus=null,this.cronError=null,this.cronForm={...Wr},this.cronFieldErrors={},this.cronEditingJobId=null,this.cronRunsJobId=null,this.cronRunsLoadingMore=!1,this.cronRuns=[],this.cronRunsTotal=0,this.cronRunsHasMore=!1,this.cronRunsNextOffset=null,this.cronRunsLimit=50,this.cronRunsScope=`all`,this.cronRunsStatuses=[],this.cronRunsDeliveryStatuses=[],this.cronRunsStatusFilter=`all`,this.cronRunsQuery=``,this.cronRunsSortDir=`desc`,this.cronModelSuggestions=[],this.cronBusy=!1,this.updateAvailable=null,this.attentionItems=[],this.paletteOpen=!1,this.paletteQuery=``,this.paletteActiveIndex=0,this.overviewShowGatewayToken=!1,this.overviewShowGatewayPassword=!1,this.overviewLogLines=[],this.overviewLogCursor=0,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter=``,this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.healthLoading=!1,this.healthResult=null,this.healthError=null,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={...Ur},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.chatNewMessagesBelow=!1,this.nodesPollInterval=null,this.logsPollInterval=null,this.debugPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.refreshSessionsAfterChat=new Set,this.basePath=``,this.popStateHandler=()=>em(this),this.topbarObserver=null,this.globalKeydownHandler=e=>{(e.metaKey||e.ctrlKey)&&!e.shiftKey&&e.key===`k`&&(e.preventDefault(),this.paletteOpen=!this.paletteOpen,this.paletteOpen&&(this.paletteQuery=``,this.paletteActiveIndex=0))},te(this.settings.locale)&&N.setLocale(this.settings.locale)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.onSlashAction=e=>{switch(e){case`toggle-focus`:this.applySettings({...this.settings,chatFocusMode:!this.settings.chatFocusMode});break;case`export`:Xo(this.chatMessages,this.assistantName);break}},document.addEventListener(`keydown`,this.globalKeydownHandler),Ig(this)}firstUpdated(){Lg(this)}disconnectedCallback(){document.removeEventListener(`keydown`,this.globalKeydownHandler),Rg(this),super.disconnectedCallback()}updated(e){zg(this,e)}connect(){Og(this)}handleChatScroll(e){lr(this,e)}handleLogsScroll(e){ur(this,e)}exportLogs(e,t){fr(e,t)}resetToolStream(){Em(this)}resetChatScroll(){dr(this)}scrollToBottom(e){dr(this),sr(this,!0,!!e?.smooth)}async loadAssistantIdentity(){await mg(this)}applySettings(e){Rp(this,e)}setTab(e){Vp(this,e),this.navDrawerOpen=!1}setTheme(e,t){Hp(this,e,t),this.themeOrder=this.buildThemeOrder(e)}setThemeMode(e,t){Up(this,e,t)}setBorderRadius(e){Rp(this,{...this.settings,borderRadius:e}),this.requestUpdate()}buildThemeOrder(e){return[e,...[...Ea].filter(t=>t!==e)]}async loadOverview(){await am(this)}async loadCron(){await dm(this)}async handleAbortChat(){await qh(this)}removeQueuedMessage(e){Zh(this,e)}async handleSendChat(e,t){await Qh(this,e,t)}async handleWhatsAppStart(e){await Vn(this,e)}async handleWhatsAppWait(){await Hn(this)}async handleWhatsAppLogout(){await Un(this)}async handleChannelConfigSave(){await Wn(this)}async handleChannelConfigReload(){await Gn(this)}handleNostrProfileEdit(e,t){Zn(this,e,t)}handleNostrProfileCancel(){Qn(this)}handleNostrProfileFieldChange(e,t){$n(this,e,t)}async handleNostrProfileSave(){await tr(this)}async handleNostrProfileImport(){await nr(this)}handleNostrProfileToggleAdvanced(){er(this)}async handleExecApprovalDecision(e){let 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(e=>e.id!==t.id)}catch(e){this.execApprovalError=`Exec approval failed: ${String(e)}`}finally{this.execApprovalBusy=!1}}}handleGatewayUrlConfirm(){let e=this.pendingGatewayUrl;if(!e)return;let t=this.pendingGatewayToken?.trim()||``;this.pendingGatewayUrl=null,this.pendingGatewayToken=null,Rp(this,{...this.settings,gatewayUrl:e,token:t}),this.connect()}handleGatewayUrlCancel(){this.pendingGatewayUrl=null,this.pendingGatewayToken=null}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){let t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}render(){return sx(this)}};Y([S()],$.prototype,`settings`,void 0),Y([S()],$.prototype,`password`,void 0),Y([S()],$.prototype,`loginShowGatewayToken`,void 0),Y([S()],$.prototype,`loginShowGatewayPassword`,void 0),Y([S()],$.prototype,`tab`,void 0),Y([S()],$.prototype,`onboarding`,void 0),Y([S()],$.prototype,`connected`,void 0),Y([S()],$.prototype,`theme`,void 0),Y([S()],$.prototype,`themeMode`,void 0),Y([S()],$.prototype,`themeResolved`,void 0),Y([S()],$.prototype,`themeOrder`,void 0),Y([S()],$.prototype,`hello`,void 0),Y([S()],$.prototype,`lastError`,void 0),Y([S()],$.prototype,`lastErrorCode`,void 0),Y([S()],$.prototype,`eventLog`,void 0),Y([S()],$.prototype,`assistantName`,void 0),Y([S()],$.prototype,`assistantAvatar`,void 0),Y([S()],$.prototype,`assistantAgentId`,void 0),Y([S()],$.prototype,`serverVersion`,void 0),Y([S()],$.prototype,`sessionKey`,void 0),Y([S()],$.prototype,`chatLoading`,void 0),Y([S()],$.prototype,`chatSending`,void 0),Y([S()],$.prototype,`chatMessage`,void 0),Y([S()],$.prototype,`chatMessages`,void 0),Y([S()],$.prototype,`chatToolMessages`,void 0),Y([S()],$.prototype,`chatStreamSegments`,void 0),Y([S()],$.prototype,`chatStream`,void 0),Y([S()],$.prototype,`chatStreamStartedAt`,void 0),Y([S()],$.prototype,`chatRunId`,void 0),Y([S()],$.prototype,`compactionStatus`,void 0),Y([S()],$.prototype,`fallbackStatus`,void 0),Y([S()],$.prototype,`chatAvatarUrl`,void 0),Y([S()],$.prototype,`chatThinkingLevel`,void 0),Y([S()],$.prototype,`chatModelOverrides`,void 0),Y([S()],$.prototype,`chatModelsLoading`,void 0),Y([S()],$.prototype,`chatModelCatalog`,void 0),Y([S()],$.prototype,`chatQueue`,void 0),Y([S()],$.prototype,`chatAttachments`,void 0),Y([S()],$.prototype,`chatManualRefreshInFlight`,void 0),Y([S()],$.prototype,`navDrawerOpen`,void 0),Y([S()],$.prototype,`sidebarOpen`,void 0),Y([S()],$.prototype,`sidebarContent`,void 0),Y([S()],$.prototype,`sidebarError`,void 0),Y([S()],$.prototype,`splitRatio`,void 0),Y([S()],$.prototype,`nodesLoading`,void 0),Y([S()],$.prototype,`nodes`,void 0),Y([S()],$.prototype,`devicesLoading`,void 0),Y([S()],$.prototype,`devicesError`,void 0),Y([S()],$.prototype,`devicesList`,void 0),Y([S()],$.prototype,`execApprovalsLoading`,void 0),Y([S()],$.prototype,`execApprovalsSaving`,void 0),Y([S()],$.prototype,`execApprovalsDirty`,void 0),Y([S()],$.prototype,`execApprovalsSnapshot`,void 0),Y([S()],$.prototype,`execApprovalsForm`,void 0),Y([S()],$.prototype,`execApprovalsSelectedAgent`,void 0),Y([S()],$.prototype,`execApprovalsTarget`,void 0),Y([S()],$.prototype,`execApprovalsTargetNodeId`,void 0),Y([S()],$.prototype,`execApprovalQueue`,void 0),Y([S()],$.prototype,`execApprovalBusy`,void 0),Y([S()],$.prototype,`execApprovalError`,void 0),Y([S()],$.prototype,`pendingGatewayUrl`,void 0),Y([S()],$.prototype,`configLoading`,void 0),Y([S()],$.prototype,`configRaw`,void 0),Y([S()],$.prototype,`configRawOriginal`,void 0),Y([S()],$.prototype,`configValid`,void 0),Y([S()],$.prototype,`configIssues`,void 0),Y([S()],$.prototype,`configSaving`,void 0),Y([S()],$.prototype,`configApplying`,void 0),Y([S()],$.prototype,`updateRunning`,void 0),Y([S()],$.prototype,`applySessionKey`,void 0),Y([S()],$.prototype,`configSnapshot`,void 0),Y([S()],$.prototype,`configSchema`,void 0),Y([S()],$.prototype,`configSchemaVersion`,void 0),Y([S()],$.prototype,`configSchemaLoading`,void 0),Y([S()],$.prototype,`configUiHints`,void 0),Y([S()],$.prototype,`configForm`,void 0),Y([S()],$.prototype,`configFormOriginal`,void 0),Y([S()],$.prototype,`configFormDirty`,void 0),Y([S()],$.prototype,`configFormMode`,void 0),Y([S()],$.prototype,`configSearchQuery`,void 0),Y([S()],$.prototype,`configActiveSection`,void 0),Y([S()],$.prototype,`configActiveSubsection`,void 0),Y([S()],$.prototype,`communicationsFormMode`,void 0),Y([S()],$.prototype,`communicationsSearchQuery`,void 0),Y([S()],$.prototype,`communicationsActiveSection`,void 0),Y([S()],$.prototype,`communicationsActiveSubsection`,void 0),Y([S()],$.prototype,`appearanceFormMode`,void 0),Y([S()],$.prototype,`appearanceSearchQuery`,void 0),Y([S()],$.prototype,`appearanceActiveSection`,void 0),Y([S()],$.prototype,`appearanceActiveSubsection`,void 0),Y([S()],$.prototype,`automationFormMode`,void 0),Y([S()],$.prototype,`automationSearchQuery`,void 0),Y([S()],$.prototype,`automationActiveSection`,void 0),Y([S()],$.prototype,`automationActiveSubsection`,void 0),Y([S()],$.prototype,`infrastructureFormMode`,void 0),Y([S()],$.prototype,`infrastructureSearchQuery`,void 0),Y([S()],$.prototype,`infrastructureActiveSection`,void 0),Y([S()],$.prototype,`infrastructureActiveSubsection`,void 0),Y([S()],$.prototype,`aiAgentsFormMode`,void 0),Y([S()],$.prototype,`aiAgentsSearchQuery`,void 0),Y([S()],$.prototype,`aiAgentsActiveSection`,void 0),Y([S()],$.prototype,`aiAgentsActiveSubsection`,void 0),Y([S()],$.prototype,`channelsLoading`,void 0),Y([S()],$.prototype,`channelsSnapshot`,void 0),Y([S()],$.prototype,`channelsError`,void 0),Y([S()],$.prototype,`channelsLastSuccess`,void 0),Y([S()],$.prototype,`whatsappLoginMessage`,void 0),Y([S()],$.prototype,`whatsappLoginQrDataUrl`,void 0),Y([S()],$.prototype,`whatsappLoginConnected`,void 0),Y([S()],$.prototype,`whatsappBusy`,void 0),Y([S()],$.prototype,`nostrProfileFormState`,void 0),Y([S()],$.prototype,`nostrProfileAccountId`,void 0),Y([S()],$.prototype,`presenceLoading`,void 0),Y([S()],$.prototype,`presenceEntries`,void 0),Y([S()],$.prototype,`presenceError`,void 0),Y([S()],$.prototype,`presenceStatus`,void 0),Y([S()],$.prototype,`agentsLoading`,void 0),Y([S()],$.prototype,`agentsList`,void 0),Y([S()],$.prototype,`agentsError`,void 0),Y([S()],$.prototype,`agentsSelectedId`,void 0),Y([S()],$.prototype,`toolsCatalogLoading`,void 0),Y([S()],$.prototype,`toolsCatalogError`,void 0),Y([S()],$.prototype,`toolsCatalogResult`,void 0),Y([S()],$.prototype,`agentsPanel`,void 0),Y([S()],$.prototype,`agentFilesLoading`,void 0),Y([S()],$.prototype,`agentFilesError`,void 0),Y([S()],$.prototype,`agentFilesList`,void 0),Y([S()],$.prototype,`agentFileContents`,void 0),Y([S()],$.prototype,`agentFileDrafts`,void 0),Y([S()],$.prototype,`agentFileActive`,void 0),Y([S()],$.prototype,`agentFileSaving`,void 0),Y([S()],$.prototype,`agentIdentityLoading`,void 0),Y([S()],$.prototype,`agentIdentityError`,void 0),Y([S()],$.prototype,`agentIdentityById`,void 0),Y([S()],$.prototype,`agentSkillsLoading`,void 0),Y([S()],$.prototype,`agentSkillsError`,void 0),Y([S()],$.prototype,`agentSkillsReport`,void 0),Y([S()],$.prototype,`agentSkillsAgentId`,void 0),Y([S()],$.prototype,`sessionsLoading`,void 0),Y([S()],$.prototype,`sessionsResult`,void 0),Y([S()],$.prototype,`sessionsError`,void 0),Y([S()],$.prototype,`sessionsFilterActive`,void 0),Y([S()],$.prototype,`sessionsFilterLimit`,void 0),Y([S()],$.prototype,`sessionsIncludeGlobal`,void 0),Y([S()],$.prototype,`sessionsIncludeUnknown`,void 0),Y([S()],$.prototype,`sessionsHideCron`,void 0),Y([S()],$.prototype,`sessionsSearchQuery`,void 0),Y([S()],$.prototype,`sessionsSortColumn`,void 0),Y([S()],$.prototype,`sessionsSortDir`,void 0),Y([S()],$.prototype,`sessionsPage`,void 0),Y([S()],$.prototype,`sessionsPageSize`,void 0),Y([S()],$.prototype,`sessionsSelectedKeys`,void 0),Y([S()],$.prototype,`usageLoading`,void 0),Y([S()],$.prototype,`usageResult`,void 0),Y([S()],$.prototype,`usageCostSummary`,void 0),Y([S()],$.prototype,`usageError`,void 0),Y([S()],$.prototype,`usageStartDate`,void 0),Y([S()],$.prototype,`usageEndDate`,void 0),Y([S()],$.prototype,`usageSelectedSessions`,void 0),Y([S()],$.prototype,`usageSelectedDays`,void 0),Y([S()],$.prototype,`usageSelectedHours`,void 0),Y([S()],$.prototype,`usageChartMode`,void 0),Y([S()],$.prototype,`usageDailyChartMode`,void 0),Y([S()],$.prototype,`usageTimeSeriesMode`,void 0),Y([S()],$.prototype,`usageTimeSeriesBreakdownMode`,void 0),Y([S()],$.prototype,`usageTimeSeries`,void 0),Y([S()],$.prototype,`usageTimeSeriesLoading`,void 0),Y([S()],$.prototype,`usageTimeSeriesCursorStart`,void 0),Y([S()],$.prototype,`usageTimeSeriesCursorEnd`,void 0),Y([S()],$.prototype,`usageSessionLogs`,void 0),Y([S()],$.prototype,`usageSessionLogsLoading`,void 0),Y([S()],$.prototype,`usageSessionLogsExpanded`,void 0),Y([S()],$.prototype,`usageQuery`,void 0),Y([S()],$.prototype,`usageQueryDraft`,void 0),Y([S()],$.prototype,`usageSessionSort`,void 0),Y([S()],$.prototype,`usageSessionSortDir`,void 0),Y([S()],$.prototype,`usageRecentSessions`,void 0),Y([S()],$.prototype,`usageTimeZone`,void 0),Y([S()],$.prototype,`usageContextExpanded`,void 0),Y([S()],$.prototype,`usageHeaderPinned`,void 0),Y([S()],$.prototype,`usageSessionsTab`,void 0),Y([S()],$.prototype,`usageVisibleColumns`,void 0),Y([S()],$.prototype,`usageLogFilterRoles`,void 0),Y([S()],$.prototype,`usageLogFilterTools`,void 0),Y([S()],$.prototype,`usageLogFilterHasTools`,void 0),Y([S()],$.prototype,`usageLogFilterQuery`,void 0),Y([S()],$.prototype,`cronLoading`,void 0),Y([S()],$.prototype,`cronJobsLoadingMore`,void 0),Y([S()],$.prototype,`cronJobs`,void 0),Y([S()],$.prototype,`cronJobsTotal`,void 0),Y([S()],$.prototype,`cronJobsHasMore`,void 0),Y([S()],$.prototype,`cronJobsNextOffset`,void 0),Y([S()],$.prototype,`cronJobsLimit`,void 0),Y([S()],$.prototype,`cronJobsQuery`,void 0),Y([S()],$.prototype,`cronJobsEnabledFilter`,void 0),Y([S()],$.prototype,`cronJobsScheduleKindFilter`,void 0),Y([S()],$.prototype,`cronJobsLastStatusFilter`,void 0),Y([S()],$.prototype,`cronJobsSortBy`,void 0),Y([S()],$.prototype,`cronJobsSortDir`,void 0),Y([S()],$.prototype,`cronStatus`,void 0),Y([S()],$.prototype,`cronError`,void 0),Y([S()],$.prototype,`cronForm`,void 0),Y([S()],$.prototype,`cronFieldErrors`,void 0),Y([S()],$.prototype,`cronEditingJobId`,void 0),Y([S()],$.prototype,`cronRunsJobId`,void 0),Y([S()],$.prototype,`cronRunsLoadingMore`,void 0),Y([S()],$.prototype,`cronRuns`,void 0),Y([S()],$.prototype,`cronRunsTotal`,void 0),Y([S()],$.prototype,`cronRunsHasMore`,void 0),Y([S()],$.prototype,`cronRunsNextOffset`,void 0),Y([S()],$.prototype,`cronRunsLimit`,void 0),Y([S()],$.prototype,`cronRunsScope`,void 0),Y([S()],$.prototype,`cronRunsStatuses`,void 0),Y([S()],$.prototype,`cronRunsDeliveryStatuses`,void 0),Y([S()],$.prototype,`cronRunsStatusFilter`,void 0),Y([S()],$.prototype,`cronRunsQuery`,void 0),Y([S()],$.prototype,`cronRunsSortDir`,void 0),Y([S()],$.prototype,`cronModelSuggestions`,void 0),Y([S()],$.prototype,`cronBusy`,void 0),Y([S()],$.prototype,`updateAvailable`,void 0),Y([S()],$.prototype,`attentionItems`,void 0),Y([S()],$.prototype,`paletteOpen`,void 0),Y([S()],$.prototype,`paletteQuery`,void 0),Y([S()],$.prototype,`paletteActiveIndex`,void 0),Y([S()],$.prototype,`overviewShowGatewayToken`,void 0),Y([S()],$.prototype,`overviewShowGatewayPassword`,void 0),Y([S()],$.prototype,`overviewLogLines`,void 0),Y([S()],$.prototype,`overviewLogCursor`,void 0),Y([S()],$.prototype,`skillsLoading`,void 0),Y([S()],$.prototype,`skillsReport`,void 0),Y([S()],$.prototype,`skillsError`,void 0),Y([S()],$.prototype,`skillsFilter`,void 0),Y([S()],$.prototype,`skillEdits`,void 0),Y([S()],$.prototype,`skillsBusyKey`,void 0),Y([S()],$.prototype,`skillMessages`,void 0),Y([S()],$.prototype,`healthLoading`,void 0),Y([S()],$.prototype,`healthResult`,void 0),Y([S()],$.prototype,`healthError`,void 0),Y([S()],$.prototype,`debugLoading`,void 0),Y([S()],$.prototype,`debugStatus`,void 0),Y([S()],$.prototype,`debugHealth`,void 0),Y([S()],$.prototype,`debugModels`,void 0),Y([S()],$.prototype,`debugHeartbeat`,void 0),Y([S()],$.prototype,`debugCallMethod`,void 0),Y([S()],$.prototype,`debugCallParams`,void 0),Y([S()],$.prototype,`debugCallResult`,void 0),Y([S()],$.prototype,`debugCallError`,void 0),Y([S()],$.prototype,`logsLoading`,void 0),Y([S()],$.prototype,`logsError`,void 0),Y([S()],$.prototype,`logsFile`,void 0),Y([S()],$.prototype,`logsEntries`,void 0),Y([S()],$.prototype,`logsFilterText`,void 0),Y([S()],$.prototype,`logsLevelFilters`,void 0),Y([S()],$.prototype,`logsAutoFollow`,void 0),Y([S()],$.prototype,`logsTruncated`,void 0),Y([S()],$.prototype,`logsCursor`,void 0),Y([S()],$.prototype,`logsLastFetchAt`,void 0),Y([S()],$.prototype,`logsLimit`,void 0),Y([S()],$.prototype,`logsMaxBytes`,void 0),Y([S()],$.prototype,`logsAtBottom`,void 0),Y([S()],$.prototype,`chatNewMessagesBelow`,void 0),$=Y([v(`openclaw-app`)],$);export{ba as A,Uu as C,Ul as D,uu as E,U as M,P as N,G as O,Ou as S,gu as T,Du as _,db as a,ku as b,My as c,Tu as d,Lu as f,vu as g,Hu as h,pb as i,zn as j,$o as k,gy as l,Vu as m,hb as n,ub as o,Cu as p,mb as r,fb as s,gb as t,Su as u,Fu as v,_u as w,Eu as x,wu as y};
//# sourceMappingURL=index-sc9GrLxu.js.map