From 07007b849f51e497cc58f3575b37d216c1f18694 Mon Sep 17 00:00:00 2001 From: Chrys Bader Date: Thu, 12 Mar 2026 23:16:34 -0700 Subject: [PATCH 1/5] Add WhatsApp channel support and QR login flow parity. Restore the WhatsApp provisioning and login behavior on top of current main, including plugin setup, route response parity, onboarding/watchdog wiring, and a resizable QR output UI. References #8. --- lib/public/assets/icons/whatsapp.svg | 14 ++ .../agents-tab/create-channel-modal.js | 48 +++-- .../js/components/channel-login-modal.js | 78 +++++++ lib/public/js/components/channels.js | 63 +++++- .../components/onboarding/welcome-config.js | 15 +- .../onboarding/welcome-pairing-step.js | 8 + lib/public/js/lib/api.js | 9 + .../js/lib/channel-provider-availability.js | 2 +- lib/server.js | 2 +- lib/server/agents/channels.js | 195 +++++++++++++++++- lib/server/agents/service.js | 1 + lib/server/agents/shared.js | 52 +++-- lib/server/commands.js | 6 +- lib/server/constants.js | 7 + .../onboarding/import/secret-detector.js | 9 + lib/server/onboarding/openclaw.js | 39 ++++ lib/server/onboarding/validation.js | 2 +- lib/server/routes/agents.js | 22 ++ lib/server/routes/pairings.js | 4 +- lib/server/watchdog-notify.js | 26 ++- tests/server/agents-service.test.js | 149 +++++++++++++ tests/server/onboarding-validation.test.js | 40 ++++ tests/server/routes-agents.test.js | 58 ++++++ tests/server/watchdog-notify.test.js | 53 +++++ 24 files changed, 848 insertions(+), 54 deletions(-) create mode 100644 lib/public/assets/icons/whatsapp.svg create mode 100644 lib/public/js/components/channel-login-modal.js create mode 100644 tests/server/onboarding-validation.test.js create mode 100644 tests/server/watchdog-notify.test.js diff --git a/lib/public/assets/icons/whatsapp.svg b/lib/public/assets/icons/whatsapp.svg new file mode 100644 index 0000000..70e0037 --- /dev/null +++ b/lib/public/assets/icons/whatsapp.svg @@ -0,0 +1,14 @@ + + + + + diff --git a/lib/public/js/components/agents-tab/create-channel-modal.js b/lib/public/js/components/agents-tab/create-channel-modal.js index 903bc70..dff1153 100644 --- a/lib/public/js/components/agents-tab/create-channel-modal.js +++ b/lib/public/js/components/agents-tab/create-channel-modal.js @@ -15,6 +15,7 @@ const kChannelEnvKeys = { telegram: "TELEGRAM_BOT_TOKEN", discord: "DISCORD_BOT_TOKEN", slack: "SLACK_BOT_TOKEN", + whatsapp: "WHATSAPP_OWNER_NUMBER", }; const kChannelExtraEnvKeys = { @@ -152,10 +153,13 @@ export const CreateChannelModal = ({ } setName(providerLabel); }, [provider, providerHasAccounts, nameEditedManually, isEditMode]); + const normalizedProvider = String(provider || "").trim(); const isSingleAccountProvider = - String(provider || "").trim() === "discord" || - String(provider || "").trim() === "slack"; - const needsAppToken = String(provider || "").trim() === "slack"; + normalizedProvider === "discord" || + normalizedProvider === "slack" || + normalizedProvider === "whatsapp"; + const needsAppToken = normalizedProvider === "slack"; + const isWhatsApp = normalizedProvider === "whatsapp"; const accountId = useMemo(() => { if (isEditMode) { @@ -326,20 +330,34 @@ export const CreateChannelModal = ({ diff --git a/lib/public/js/components/channel-login-modal.js b/lib/public/js/components/channel-login-modal.js new file mode 100644 index 0000000..9bfcac9 --- /dev/null +++ b/lib/public/js/components/channel-login-modal.js @@ -0,0 +1,78 @@ +import { h } from "https://esm.sh/preact"; +import htm from "https://esm.sh/htm"; +import { ActionButton } from "./action-button.js"; +import { CloseIcon } from "./icons.js"; +import { ModalShell } from "./modal-shell.js"; +import { PageHeader } from "./page-header.js"; + +const html = htm.bind(h); + +export const ChannelLoginModal = ({ + visible = false, + loading = false, + title = "Link Channel", + output = "", + error = "", + onRun = async () => {}, + onClose = () => {}, +}) => { + if (!visible) return null; + const hasOutput = !!String(output || "").trim(); + const hasError = !!String(error || "").trim(); + const displayOutput = hasOutput + ? String(output) + : hasError + ? String(error) + : "No output yet. Generate QR to start login."; + return html` + <${ModalShell} + visible=${visible} + onClose=${onClose} + panelClassName="bg-modal border border-border rounded-xl p-6 max-w-2xl w-full space-y-4" + > + <${PageHeader} + title=${title} + actions=${html` + + `} + /> +
+

+ Click "Generate QR" to run channel login and capture terminal output. +

+
- <${Z} + <${Y} onClick=${c} disabled=${w} tone="secondary" size="md" idleLabel=${l} /> - <${Z} + <${Y} onClick=${S} disabled=${!m||h||!!b||!String(x||"").trim()} loading=${w} @@ -5645,8 +5721,8 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s loadingLabel=${a} />
- - `};var a3=P.bind(T),gw=({visible:t=!1,card:e=null,onClose:n=()=>{},onComplete:s=()=>{}})=>{let o=async({selectedSession:r,message:i})=>{if(!e?.id)return!1;try{await nm({cardId:e.id,sessionId:r?.sessionId||"",replyChannel:r?.replyChannel||"",replyTo:r?.replyTo||"",prompt:i});try{await pa({cardId:e.id,status:"fixed"}),N("Doctor fix request sent and finding marked fixed","success")}catch(a){N(a.message||"Doctor fix request sent, but could not mark the finding fixed","warning")}return await s(),!0}catch(a){return N(a.message||"Could not send Doctor fix request","error"),!1}};return a3` + + `};var p3=P.bind(T),yw=({visible:t=!1,card:e=null,onClose:n=()=>{},onComplete:s=()=>{}})=>{let o=async({selectedSession:r,message:i})=>{if(!e?.id)return!1;try{await nm({cardId:e.id,sessionId:r?.sessionId||"",replyChannel:r?.replyChannel||"",replyTo:r?.replyTo||"",prompt:i});try{await pa({cardId:e.id,status:"fixed"}),I("Doctor fix request sent and finding marked fixed","success")}catch(a){I(a.message||"Doctor fix request sent, but could not mark the finding fixed","warning")}return await s(),!0}catch(a){return I(a.message||"Could not send Doctor fix request","error"),!1}};return p3` <${mc} visible=${t} title="Ask agent to fix" @@ -5658,7 +5734,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s onClose=${n} onSubmit=${o} /> - `};var wt=P.bind(T),cf=15e3,bw=2e3,l3=()=>wt` + `};var wt=P.bind(T),cf=15e3,vw=2e3,f3=()=>wt` {r.current&&(r.current.destroy(),r.current=null)}},[f,i,s d="M8 20V14H16V20H19V4H5V20H8ZM10 20H14V16H10V20ZM21 20H23V22H1V20H3V3C3 2.44772 3.44772 2 4 2H20C20.5523 2 21 2.44772 21 3V20ZM11 8V6H13V8H15V10H13V12H11V10H9V8H11Z" > -`,xw=({isActive:t=!1,onOpenFile:e=()=>{}})=>{let n=Re(ua,cf,{enabled:t}),s=n.data?.status||null,o=s?.runInProgress?bw:cf,r=Re(()=>em(10),o,{enabled:t}),[i,a]=y("all"),[l,c]=y("open"),[d,u]=y(0),[p,f]=y(null),[g,m]=y(""),h=r.data?.runs||[],b=String(s?.activeRunId||""),x=String(i||""),w=x!==""&&x!=="all"&&!h.some(J=>String(J.id||"")===x)&&(g===x||s?.runInProgress&&b===x)?{id:Number(x||0),status:"running",summary:"",priorityCounts:{P0:0,P1:0,P2:0},statusCounts:{open:0,dismissed:0,fixed:0}}:null,$=w?[w,...h]:h,S=i!=="all"&&!!b&&String(i||"")===b,C=i==="all"?null:$.find(J=>String(J.id||"")===String(i||""))||null,_=Re(()=>tm({runId:i||"all"}),s?.runInProgress||C?.status==="running"?bw:cf,{enabled:t}),k=_.data?.cards||[];L(()=>{t&&(n.refresh(),r.refresh())},[t]),L(()=>{if(!h.length){if(g&&x===g||S&&s?.runInProgress)return;i!=="all"&&a("all");return}i==="all"||h.some(oe=>String(oe.id||"")===String(i||""))||S&&s?.runInProgress||a("all")},[h,x,i,S,g,s?.runInProgress]),L(()=>{if(!g)return;if(i!==g){a(g);return}let J=h.some(ce=>String(ce.id||"")===String(g||"")),oe=!!b&&b===g&&!!s?.runInProgress;!J&&!oe||m("")},[b,s?.runInProgress,g,h,i]),L(()=>{_.refresh()},[i]);let A=C?.status==="running"||S&&s?.runInProgress,O=F(()=>A?"":C?.summary||"",[C,A]),D=F(()=>uw(),[]),z=F(()=>lw(s?.changeSummary||null),[s]),E=F(()=>s?.runInProgress||s?.needsInitialRun?!0:Number(s?.changeSummary?.changedFilesCount||0)>0,[s]),M=E?"":"No workspace changes since the last completed Drift Doctor run.",R=F(()=>fc(s,0),[s]),B=F(()=>iw(s),[s]),I=F(()=>aw(s),[s]),U=F(()=>hc(s),[s]),W=!!s?.lastRunAt,G=h.length>0,se=r.data!==null||r.error!==null,K=_.data!==null||_.error!==null,j=!se||G&&!K,X=F(()=>l==="all"?k:k.filter(J=>String(J?.status||"open").trim().toLowerCase()===l),[k,l]),de=F(()=>k.filter(J=>String(J?.status||"open").trim().toLowerCase()==="open"),[k]),le=F(()=>$.slice(0,2),[$]),ie=F(()=>$.slice(2),[$]),ne=F(()=>i==="all"?"":ie.some(J=>String(J.id||"")===String(i||""))?String(i||""):"",[ie,i]),xe=(J=!1)=>["inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs transition-colors",J?"border-cyan-500/40 bg-cyan-500/10 text-status-info shadow-[0_0_0_1px_rgba(34,211,238,0.08)]":"border-border bg-field text-body hover:border-fg-muted hover:text-bright"].join(" "),he=(J="neutral")=>J==="success"?"bg-green-400":J==="warning"?"bg-yellow-400":J==="danger"?"bg-red-400":J==="cyan"?"ac-status-dot ac-status-dot--info":"bg-gray-500",ue=!j&&(h.length>0||!!g||!!b||!!s?.runInProgress),me=async()=>{try{let J=await Qh();if(N(J?.reusedPreviousRun?"No workspace changes since the last scan; reused previous findings":"Doctor run started","success"),J?.runId){let oe=String(J.runId);m(oe),a(oe)}n.refresh(),r.refresh(),_.refresh(),setTimeout(n.refresh,1200),setTimeout(r.refresh,1200),setTimeout(_.refresh,1200)}catch(J){N(J.message||"Could not start Doctor run","error")}},V=async(J,oe)=>{if(!(!J?.id||d))try{u(J.id),await pa({cardId:J.id,status:oe}),N("Doctor card updated","success"),await _.refresh(),await r.refresh(),await n.refresh()}catch(ce){N(ce.message||"Could not update Doctor card","error")}finally{u(0)}};return wt` +`,$w=({isActive:t=!1,onOpenFile:e=()=>{}})=>{let n=Ee(ua,cf,{enabled:t}),s=n.data?.status||null,o=s?.runInProgress?vw:cf,r=Ee(()=>em(10),o,{enabled:t}),[i,a]=y("all"),[l,c]=y("open"),[d,u]=y(0),[p,f]=y(null),[g,m]=y(""),h=r.data?.runs||[],b=String(s?.activeRunId||""),x=String(i||""),w=x!==""&&x!=="all"&&!h.some(J=>String(J.id||"")===x)&&(g===x||s?.runInProgress&&b===x)?{id:Number(x||0),status:"running",summary:"",priorityCounts:{P0:0,P1:0,P2:0},statusCounts:{open:0,dismissed:0,fixed:0}}:null,$=w?[w,...h]:h,S=i!=="all"&&!!b&&String(i||"")===b,C=i==="all"?null:$.find(J=>String(J.id||"")===String(i||""))||null,_=Ee(()=>tm({runId:i||"all"}),s?.runInProgress||C?.status==="running"?vw:cf,{enabled:t}),k=_.data?.cards||[];L(()=>{t&&(n.refresh(),r.refresh())},[t]),L(()=>{if(!h.length){if(g&&x===g||S&&s?.runInProgress)return;i!=="all"&&a("all");return}i==="all"||h.some(ie=>String(ie.id||"")===String(i||""))||S&&s?.runInProgress||a("all")},[h,x,i,S,g,s?.runInProgress]),L(()=>{if(!g)return;if(i!==g){a(g);return}let J=h.some(de=>String(de.id||"")===String(g||"")),ie=!!b&&b===g&&!!s?.runInProgress;!J&&!ie||m("")},[b,s?.runInProgress,g,h,i]),L(()=>{_.refresh()},[i]);let A=C?.status==="running"||S&&s?.runInProgress,D=F(()=>A?"":C?.summary||"",[C,A]),N=F(()=>hw(),[]),U=F(()=>uw(s?.changeSummary||null),[s]),O=F(()=>s?.runInProgress||s?.needsInitialRun?!0:Number(s?.changeSummary?.changedFilesCount||0)>0,[s]),M=O?"":"No workspace changes since the last completed Drift Doctor run.",R=F(()=>fc(s,0),[s]),B=F(()=>cw(s),[s]),E=F(()=>dw(s),[s]),G=F(()=>hc(s),[s]),H=!!s?.lastRunAt,z=h.length>0,te=r.data!==null||r.error!==null,K=_.data!==null||_.error!==null,V=!te||z&&!K,Z=F(()=>l==="all"?k:k.filter(J=>String(J?.status||"open").trim().toLowerCase()===l),[k,l]),ue=F(()=>k.filter(J=>String(J?.status||"open").trim().toLowerCase()==="open"),[k]),re=F(()=>$.slice(0,2),[$]),oe=F(()=>$.slice(2),[$]),ne=F(()=>i==="all"?"":oe.some(J=>String(J.id||"")===String(i||""))?String(i||""):"",[oe,i]),me=(J=!1)=>["inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs transition-colors",J?"border-cyan-500/40 bg-cyan-500/10 text-status-info shadow-[0_0_0_1px_rgba(34,211,238,0.08)]":"border-border bg-field text-body hover:border-fg-muted hover:text-bright"].join(" "),pe=(J="neutral")=>J==="success"?"bg-green-400":J==="warning"?"bg-yellow-400":J==="danger"?"bg-red-400":J==="cyan"?"ac-status-dot ac-status-dot--info":"bg-gray-500",ce=!V&&(h.length>0||!!g||!!b||!!s?.runInProgress),ge=async()=>{try{let J=await Qh();if(I(J?.reusedPreviousRun?"No workspace changes since the last scan; reused previous findings":"Doctor run started","success"),J?.runId){let ie=String(J.runId);m(ie),a(ie)}n.refresh(),r.refresh(),_.refresh(),setTimeout(n.refresh,1200),setTimeout(r.refresh,1200),setTimeout(_.refresh,1200)}catch(J){I(J.message||"Could not start Doctor run","error")}},j=async(J,ie)=>{if(!(!J?.id||d))try{u(J.id),await pa({cardId:J.id,status:ie}),I("Doctor card updated","success"),await _.refresh(),await r.refresh(),await n.refresh()}catch(de){I(de.message||"Could not update Doctor card","error")}finally{u(0)}};return wt`
- ${ue?wt` - <${Ne} + ${ce?wt` + <${Pe} title="Drift Doctor" actions=${wt` - <${Z} - onClick=${me} - disabled=${!E} + <${Y} + onClick=${ge} + disabled=${!O} loading=${!!s?.runInProgress} idleLabel="Run Drift Doctor" loadingLabel="Running..." @@ -5686,7 +5762,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s `} /> `:null} - ${j?wt` + ${V?wt`
<${Ce} className="h-4 w-4" /> @@ -5694,11 +5770,11 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
`:null} - ${!j&&G?wt` + ${!V&&z?wt`
- <${pw} cards=${de} /> + <${mw} cards=${ue} />
- ${W?wt` + ${H?wt`
@@ -5709,7 +5785,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s - ${z} + ${U}
${B?wt` @@ -5717,10 +5793,10 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s class="bg-surface border border-border rounded-xl p-4 space-y-3" >
- ⚠️ ${I} + ⚠️ ${E}
- ${U.map(J=>wt` + ${G.map(J=>wt`
@@ -5766,7 +5842,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
`:null} - ${ue?wt` + ${ce?wt`

Findings

@@ -5774,46 +5850,46 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
- ${le.map(J=>{let oe=String(i||"")===String(J.id||""),ce=dw(J);return wt` + ${re.map(J=>{let ie=String(i||"")===String(J.id||""),de=fw(J);return wt` `})} - ${ie.length?wt` + ${oe.length?wt`
- ${O?wt` + ${D?wt`
{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s ${C?.id?`Run #${C.id} summary`:"Run summary"}

- ${O} + ${D}

`:null} @@ -5855,11 +5931,11 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
`:null}
- <${hw} - cards=${X} + <${bw} + cards=${Z} busyCardId=${d} onAskAgentFix=${f} - onUpdateStatus=${V} + onUpdateStatus=${j} onOpenFile=${e} changedPaths=${s?.changeSummary?.changedPaths||[]} showRunMeta=${i==="all"} @@ -5868,12 +5944,12 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
`:null} - ${!j&&!ue?wt` + ${!V&&!ce?wt`
- <${l3} /> + <${f3} />

Workspace health review @@ -5885,9 +5961,9 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s

- <${Z} - onClick=${me} - disabled=${!E} + <${Y} + onClick=${ge} + disabled=${!O} loading=${!!s?.runInProgress} size="lg" idleLabel="Run Drift Doctor" @@ -5902,21 +5978,21 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
`:null} - <${gw} + <${yw} visible=${!!p} card=${p} onClose=${()=>f(null)} onComplete=${async()=>{await n.refresh(),await r.refresh(),await _.refresh()}} />
- `};var c3=P.bind(T),df=({onNavigateToBrowseFile:t=()=>{}})=>c3` + `};var h3=P.bind(T),df=({onNavigateToBrowseFile:t=()=>{}})=>h3`
- <${xw} + <${$w} isActive=${!0} onOpenFile=${(e,n={})=>{let s=`workspace/${String(e||"").trim().replace(/^workspace\//,"")}`;t(s,{view:"edit",...n.line?{line:n.line}:{},...n.lineEnd?{lineEnd:n.lineEnd}:{}})}} />
-`;var d3=P.bind(T),zn=({header:t,children:e})=>d3` +`;var m3=P.bind(T),Un=({header:t,children:e})=>m3`
@@ -5929,7 +6005,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
-`;var Ue=P.bind(T),yw={ai:"AI Provider Keys",github:"GitHub",channels:"Channels",tools:"Tools",custom:"Custom"},u3=["ai","github","channels","tools","custom"],p3=new Set(["OPENAI_API_KEY","GEMINI_API_KEY"]),ww={Embeddings:{Icon:_a,label:"Memory embeddings"},Image:{Icon:nb,label:"Image generation"},TTS:{Icon:sb,label:"Text to speech"},STT:{Icon:ob,label:"Speech to text"}},vw=t=>t.trim().toUpperCase().replace(/[^A-Z0-9_]/g,"_"),f3=/^(?:TELEGRAM_BOT_TOKEN|DISCORD_BOT_TOKEN|SLACK_BOT_TOKEN|SLACK_APP_TOKEN)(?:_[A-Z0-9_]+)?$/,h3=t=>{let e=String(t||"").trim();if(e.length<2)return e;let n=e.startsWith('"'),s=e.endsWith('"');if(n&&s)return e.slice(1,-1);let o=e.startsWith("'"),r=e.endsWith("'");return o&&r?e.slice(1,-1):e},gc=(t="")=>f3.test(String(t||"").trim().toUpperCase()),$w=t=>JSON.stringify((t||[]).map(e=>({key:String(e?.key||""),value:String(e?.value||"")})).sort((e,n)=>e.key.localeCompare(n.key))),m3=t=>{let e=Array.isArray(t)?[...t]:[],n=e.filter(o=>(o?.group||"custom")==="custom").sort((o,r)=>String(o?.key||"").localeCompare(String(r?.key||""))),s=0;return e.map(o=>{if((o?.group||"custom")!=="custom")return o;let r=n[s];return s+=1,r})},g3={ANTHROPIC_API_KEY:Ue`from${" "} +`;var Ue=P.bind(T),ww={ai:"AI Provider Keys",github:"GitHub",channels:"Channels",tools:"Tools",custom:"Custom"},g3=["ai","github","channels","tools","custom"],b3=new Set(["OPENAI_API_KEY","GEMINI_API_KEY"]),Cw={Embeddings:{Icon:_a,label:"Memory embeddings"},Image:{Icon:sb,label:"Image generation"},TTS:{Icon:ob,label:"Text to speech"},STT:{Icon:rb,label:"Speech to text"}},kw=t=>t.trim().toUpperCase().replace(/[^A-Z0-9_]/g,"_"),x3=/^(?:TELEGRAM_BOT_TOKEN|DISCORD_BOT_TOKEN|SLACK_BOT_TOKEN|SLACK_APP_TOKEN)(?:_[A-Z0-9_]+)?$/,y3=t=>{let e=String(t||"").trim();if(e.length<2)return e;let n=e.startsWith('"'),s=e.endsWith('"');if(n&&s)return e.slice(1,-1);let o=e.startsWith("'"),r=e.endsWith("'");return o&&r?e.slice(1,-1):e},gc=(t="")=>x3.test(String(t||"").trim().toUpperCase()),Sw=t=>JSON.stringify((t||[]).map(e=>({key:String(e?.key||""),value:String(e?.value||"")})).sort((e,n)=>e.key.localeCompare(n.key))),v3=t=>{let e=Array.isArray(t)?[...t]:[],n=e.filter(o=>(o?.group||"custom")==="custom").sort((o,r)=>String(o?.key||"").localeCompare(String(r?.key||""))),s=0;return e.map(o=>{if((o?.group||"custom")!=="custom")return o;let r=n[s];return s+=1,r})},$3={ANTHROPIC_API_KEY:Ue`from${" "} {r.current&&(r.current.destroy(),r.current=null)}},[f,i,s class="hover:underline" style="color: var(--accent-link)" >brave.com/search/api${" "} — free tier available`},b3=t=>g3[t.key]||t.hint||"",x3=t=>(Array.isArray(t?.features)?t.features:[]).filter(e=>!!ww[e]),y3=t=>{let e=[],n=[];return(t||[]).forEach(s=>{let o=!!String(s?.value||"").trim();if(p3.has(s?.key)||o){e.push(s);return}n.push(s)}),{visible:e,hidden:n}},v3=({feature:t})=>{let e=ww[t];if(!e)return null;let{Icon:n,label:s}=e;return Ue` + >${" "} — free tier available`},w3=t=>$3[t.key]||t.hint||"",k3=t=>(Array.isArray(t?.features)?t.features:[]).filter(e=>!!Cw[e]),S3=t=>{let e=[],n=[];return(t||[]).forEach(s=>{let o=!!String(s?.value||"").trim();if(b3.has(s?.key)||o){e.push(s);return}n.push(s)}),{visible:e,hidden:n}},C3=({feature:t})=>{let e=Cw[t];if(!e)return null;let{Icon:n,label:s}=e;return Ue` <${yt} text=${s} widthClass="w-auto" tooltipClassName="whitespace-nowrap"> {r.current&&(r.current.destroy(),r.current=null)}},[f,i,s <${n} className="w-3.5 h-3.5" /> - `},$3=({envVar:t,onChange:e,onDelete:n,disabled:s})=>{let o=b3(t),r=x3(t);return Ue` + `},_3=({envVar:t,onChange:e,onDelete:n,disabled:s})=>{let o=w3(t),r=k3(t);return Ue`
@@ -6050,7 +6126,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
${r.length>0?Ue`
- ${r.map(i=>Ue`<${v3} key=${i} feature=${i} />`)} + ${r.map(i=>Ue`<${C3} key=${i} feature=${i} />`)}
`:null}
@@ -6075,20 +6151,20 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s ${o?Ue`

${o}

`:null}
- `},kw=({onRestartRequired:t=()=>{}})=>{let[e,n]=y([]),[s,o]=y(()=>new Set),[r,i]=y([]),[a,l]=y(0),[c,d]=y(!1),[u,p]=y(!1),[f,g]=y(!1),[m,h]=y(""),b=ee("[]"),{data:x,error:v,loading:w,refresh:$}=ct("/api/env",Vr,{maxAgeMs:3e4}),S=q(j=>{if(!j)return;let X=m3(j.vars||[]);b.current=$w(X),n(X),i([]),o(new Set(j.reservedKeys||[])),j.restartRequired&&t(!0)},[t]),C=q(async()=>{try{let j=await $({force:!0});S(j)}catch(j){console.error("Failed to load env vars:",j)}},[S,$]);L(()=>{x&&(c||u||S(x))},[S,c,x,u]),L(()=>{v&&console.error("Failed to load env vars:",v)},[v]),L(()=>{d($w(e)!==b.current)},[e]);let _=(j,X)=>{n(de=>de.map(le=>le.key===j?{...le,value:X}:le))},k=j=>{n(X=>X.filter(de=>de.key!==j)),i(X=>X.filter(de=>de!==j))},A=async()=>{if(!u){p(!0);try{let j=e.filter(ie=>ie.editable&&!gc(ie?.key)).map(ie=>({key:ie.key,value:ie.value})),de=!!(await dd(j))?.restartRequired;de&&t(!0),N(de?"Environment variables saved. Restart gateway to apply.":"Environment variables saved","success");let le=await $({force:!0});S(le),l(ie=>ie+1),d(!1)}catch(j){N("Failed to save: "+j.message,"error")}finally{p(!1)}}},[O,D]=y(""),z=j=>{let X=j.split(` -`).map(le=>le.trim()).filter(Boolean).filter(le=>!le.startsWith("#")),de=[];for(let le of X){let ie=le.indexOf("=");ie>0&&de.push({key:le.slice(0,ie).trim(),value:h3(le.slice(ie+1))})}return de},E=j=>{let X=0,de=[],le=[],ie=[];return n(ne=>{let xe=[...ne];for(let{key:he,value:ue}of j){let me=vw(he);if(!me)continue;if(gc(me)){le.push(me);continue}if(s.has(me)){de.push(me);continue}let V=xe.find(J=>J.key===me);V?V.value=ue:(xe.push({key:me,value:ue,label:me,group:"custom",hint:"",source:"env_file",editable:!0}),ie.push(me)),X++}return xe}),ie.length&&i(ne=>[...ne,...ie]),{added:X,blocked:de,managedChannelKeys:le}},M=(j,X)=>{let de=(j.clipboardData||window.clipboardData).getData("text"),le=z(de);if(le.length>1){j.preventDefault();let{added:ie,blocked:ne,managedChannelKeys:xe}=E(le);if(h(""),D(""),ne.length){let he=Array.from(new Set(ne));N(`Reserved vars can't be added: ${he.join(", ")}`,"error")}if(xe.length){let he=Array.from(new Set(xe));N(`Channel tokens are managed from Channels: ${he.join(", ")}`,"error")}ie&&N(`Added ${ie} variable${ie!==1?"s":""}`,"success");return}if(le.length===1){j.preventDefault(),h(le[0].key),D(le[0].value);return}},R=j=>{let X=z(j);if(X.length===1){h(X[0].key),D(X[0].value);return}h(j)},B=j=>{let X=z(j);if(X.length===1){h(X[0].key),D(X[0].value);return}D(j)},I=()=>{let j=vw(m);if(j){if(gc(j)){N(`Channel tokens are managed from Channels: ${j}`,"error");return}if(s.has(j)){N(`Reserved var can't be added: ${j}`,"error");return}E([{key:j,value:O}]),h(""),D("")}},U=e.filter(j=>!gc(j?.key)),W={};for(let j of U){let X=j.group||"custom";W[X]||(W[X]=[]),W[X].push(j)}if(W.custom?.length){let j=new Set(r),X=W.custom.filter(le=>!j.has(le.key)).sort((le,ie)=>String(le?.key||"").localeCompare(String(ie?.key||""))),de=W.custom.filter(le=>j.has(le.key));W.custom=[...X,...de]}let G=y3(W.ai||[]),se=j=>j.map(X=>Ue`<${$3} - key=${`${a}:${X.key}`} - envVar=${X} + `},_w=({onRestartRequired:t=()=>{}})=>{let[e,n]=y([]),[s,o]=y(()=>new Set),[r,i]=y([]),[a,l]=y(0),[c,d]=y(!1),[u,p]=y(!1),[f,g]=y(!1),[m,h]=y(""),b=ee("[]"),{data:x,error:v,loading:w,refresh:$}=ct("/api/env",Vr,{maxAgeMs:3e4}),S=q(V=>{if(!V)return;let Z=v3(V.vars||[]);b.current=Sw(Z),n(Z),i([]),o(new Set(V.reservedKeys||[])),V.restartRequired&&t(!0)},[t]),C=q(async()=>{try{let V=await $({force:!0});S(V)}catch(V){console.error("Failed to load env vars:",V)}},[S,$]);L(()=>{x&&(c||u||S(x))},[S,c,x,u]),L(()=>{v&&console.error("Failed to load env vars:",v)},[v]),L(()=>{d(Sw(e)!==b.current)},[e]);let _=(V,Z)=>{n(ue=>ue.map(re=>re.key===V?{...re,value:Z}:re))},k=V=>{n(Z=>Z.filter(ue=>ue.key!==V)),i(Z=>Z.filter(ue=>ue!==V))},A=async()=>{if(!u){p(!0);try{let V=e.filter(oe=>oe.editable&&!gc(oe?.key)).map(oe=>({key:oe.key,value:oe.value})),ue=!!(await dd(V))?.restartRequired;ue&&t(!0),I(ue?"Environment variables saved. Restart gateway to apply.":"Environment variables saved","success");let re=await $({force:!0});S(re),l(oe=>oe+1),d(!1)}catch(V){I("Failed to save: "+V.message,"error")}finally{p(!1)}}},[D,N]=y(""),U=V=>{let Z=V.split(` +`).map(re=>re.trim()).filter(Boolean).filter(re=>!re.startsWith("#")),ue=[];for(let re of Z){let oe=re.indexOf("=");oe>0&&ue.push({key:re.slice(0,oe).trim(),value:y3(re.slice(oe+1))})}return ue},O=V=>{let Z=0,ue=[],re=[],oe=[];return n(ne=>{let me=[...ne];for(let{key:pe,value:ce}of V){let ge=kw(pe);if(!ge)continue;if(gc(ge)){re.push(ge);continue}if(s.has(ge)){ue.push(ge);continue}let j=me.find(J=>J.key===ge);j?j.value=ce:(me.push({key:ge,value:ce,label:ge,group:"custom",hint:"",source:"env_file",editable:!0}),oe.push(ge)),Z++}return me}),oe.length&&i(ne=>[...ne,...oe]),{added:Z,blocked:ue,managedChannelKeys:re}},M=(V,Z)=>{let ue=(V.clipboardData||window.clipboardData).getData("text"),re=U(ue);if(re.length>1){V.preventDefault();let{added:oe,blocked:ne,managedChannelKeys:me}=O(re);if(h(""),N(""),ne.length){let pe=Array.from(new Set(ne));I(`Reserved vars can't be added: ${pe.join(", ")}`,"error")}if(me.length){let pe=Array.from(new Set(me));I(`Channel tokens are managed from Channels: ${pe.join(", ")}`,"error")}oe&&I(`Added ${oe} variable${oe!==1?"s":""}`,"success");return}if(re.length===1){V.preventDefault(),h(re[0].key),N(re[0].value);return}},R=V=>{let Z=U(V);if(Z.length===1){h(Z[0].key),N(Z[0].value);return}h(V)},B=V=>{let Z=U(V);if(Z.length===1){h(Z[0].key),N(Z[0].value);return}N(V)},E=()=>{let V=kw(m);if(V){if(gc(V)){I(`Channel tokens are managed from Channels: ${V}`,"error");return}if(s.has(V)){I(`Reserved var can't be added: ${V}`,"error");return}O([{key:V,value:D}]),h(""),N("")}},G=e.filter(V=>!gc(V?.key)),H={};for(let V of G){let Z=V.group||"custom";H[Z]||(H[Z]=[]),H[Z].push(V)}if(H.custom?.length){let V=new Set(r),Z=H.custom.filter(re=>!V.has(re.key)).sort((re,oe)=>String(re?.key||"").localeCompare(String(oe?.key||""))),ue=H.custom.filter(re=>V.has(re.key));H.custom=[...Z,...ue]}let z=S3(H.ai||[]),te=V=>V.map(Z=>Ue`<${_3} + key=${`${a}:${Z.key}`} + envVar=${Z} onChange=${_} onDelete=${k} disabled=${u} - />`),K=j=>{let X=W[j]||[];if(!X.length)return null;if(j==="ai"){let{visible:de,hidden:le}=G,ie=f&&le.length>0;return Ue` + />`),K=V=>{let Z=H[V]||[];if(!Z.length)return null;if(V==="ai"){let{visible:ue,hidden:re}=z,oe=f&&re.length>0;return Ue`

- ${yw[j]||j} + ${ww[V]||V}

-
${se(de)}
- ${le.length>0?Ue` +
${te(ue)}
+ ${re.length>0?Ue`
`:null} - ${ie?Ue`
- ${se(le)} + ${oe?Ue`
+ ${te(re)}
`:null}
`}return Ue`

- ${yw[j]||j} + ${ww[V]||V}

-
${se(X)}
+
${te(Z)}
`};return w&&!e.length?Ue` - <${zn} - header=${Ue`<${Ne} title="Envars" />`} + <${Un} + header=${Ue`<${Pe} title="Envars" />`} >
Loading environment variables...
- + `:Ue` - <${zn} + <${Un} header=${Ue` - <${Ne} + <${Pe} title="Envars" actions=${Ue` - <${Qn} visible=${c}> - <${Z} + <${es} visible=${c}> + <${Y} onClick=${C} disabled=${u} tone="secondary" @@ -6136,7 +6212,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s idleLabel="Cancel" className="text-xs" /> - <${Z} + <${Y} onClick=${A} disabled=${u} loading=${u} @@ -6147,12 +6223,12 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s loadingLabel="Saving…" className="text-xs" /> - + `} /> `} > - ${u3.filter(j=>W[j]?.length).map(j=>K(j))} + ${g3.filter(V=>H[V]?.length).map(V=>K(V))}
{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s type="text" value=${m} placeholder="KEY" - onInput=${j=>R(j.target.value)} - onPaste=${j=>M(j,"key")} - onKeyDown=${j=>j.key==="Enter"&&I()} + onInput=${V=>R(V.target.value)} + onPaste=${V=>M(V,"key")} + onKeyDown=${V=>V.key==="Enter"&&E()} class="w-full bg-field border border-border rounded-lg px-3 py-1.5 text-sm text-body outline-none focus:border-fg-muted font-mono uppercase" />
B(j.target.value)} - onPaste=${j=>M(j,"val")} - onKeyDown=${j=>j.key==="Enter"&&I()} + onInput=${V=>B(V.target.value)} + onPaste=${V=>M(V,"val")} + onKeyDown=${V=>V.key==="Enter"&&E()} class="flex-1 bg-field border border-border rounded-lg px-3 py-1.5 text-sm text-body outline-none focus:border-fg-muted font-mono" />
- - `};var w3=P.bind(T),uf=({onRestartRequired:t=()=>{}})=>w3` - <${kw} onRestartRequired=${t} /> -`;var Qt=P.bind(T),k3=t=>{let e=Number(t||0);if(!Number.isFinite(e)||e<=0)return"0s";let n=Math.floor(e/1e3),s=Math.floor(n/86400),o=Math.floor(n/3600),r=Math.floor(n%3600/60),i=n%60;return s>0?`${s}d ${o%24}h ${r}m ${i}s`:o>0?`${o}h ${r}m ${i}s`:r>0?`${r}m ${i}s`:`${i}s`},S3=({label:t,currentVersion:e,fetchVersion:n,applyUpdate:s,updateInProgress:o=!1,onActionComplete:r=()=>{}})=>{let[i,a]=y(!1),[l,c]=y(e||null),[d,u]=y(null),[p,f]=y(!1),[g,m]=y(""),[h,b]=y(!1),[x,v]=y(!1),w=(()=>{try{return new URLSearchParams(window.location.search).get("simulateUpdate")==="1"}catch{return!1}})(),$=(()=>{if(!w)return null;try{return new URLSearchParams(window.location.search).get("simulateVersion")||"v0.0.0-preview"}catch{return"v0.0.0-preview"}})(),S=w||p,C=$||d,_=o||S,k=C?`Update to ${C}`:"Update",A="https://github.com/openclaw/openclaw/tags",O=S&&C;L(()=>{c(e||null)},[e]),L(()=>{let R=!0;return(async(I=!1)=>{try{let U=await n(I);if(!R)return;c(U.currentVersion||e||null),u(U.latestVersion||null),f(!!U.hasUpdate),m(U.ok?"":U.error||"")}catch(U){if(!R)return;m(U.message||"Could not check updates")}})(!1),()=>{R=!1}},[e,n]),L(()=>{if(o)return()=>{};let R=!0,B=setTimeout(async()=>{try{let I=await n(!0);if(!R)return;c(I.currentVersion||e||null),u(I.latestVersion||null),f(!!I.hasUpdate),m(I.ok?"":I.error||"")}catch{}},1200);return()=>{R=!1,clearTimeout(B)}},[o,e,n]),L(()=>{if(!S||!C){b(!1);return}b(!1)},[S,C]);let D=async()=>{let R=!!S;if(!(_?i||o:i)){a(!0),m("");try{let I=R?await s():await n(!0);c(I.currentVersion||l),u(I.latestVersion||null),f(!!I.hasUpdate),m(I.ok?"":I.error||""),R?I.ok?I.updated||I.restarting?N(I.restarting?`${t} updated \u2014 restarting...`:`Updated ${t} to ${I.currentVersion}`,"success"):N(`Already at latest ${t} version`,"success"):N(I.error||`${t} update failed`,"error"):I.hasUpdate&&I.latestVersion?N(`${t} update available: ${I.latestVersion}`,"warning"):N(`${t} is up to date`,"success"),await r({type:R?"update":"check",ok:!!I?.ok,result:I})}catch(I){m(I.message||(R?`Could not update ${t}`:"Could not check updates")),N(R?`Could not update ${t}`:"Could not check updates","error"),await r({type:R?"update":"check",ok:!1,error:I})}finally{a(!1)}}},z=()=>{if(!(_?i||o:i)){if(S&&C&&!h){v(!0);return}D()}},E=()=>{v(!1),D()},M=_?i||o:i;return Qt` + + `};var A3=P.bind(T),uf=({onRestartRequired:t=()=>{}})=>A3` + <${_w} onRestartRequired=${t} /> +`;var en=P.bind(T),M3=t=>{let e=Number(t||0);if(!Number.isFinite(e)||e<=0)return"0s";let n=Math.floor(e/1e3),s=Math.floor(n/86400),o=Math.floor(n/3600),r=Math.floor(n%3600/60),i=n%60;return s>0?`${s}d ${o%24}h ${r}m ${i}s`:o>0?`${o}h ${r}m ${i}s`:r>0?`${r}m ${i}s`:`${i}s`},T3=({label:t,currentVersion:e,fetchVersion:n,applyUpdate:s,updateInProgress:o=!1,onActionComplete:r=()=>{}})=>{let[i,a]=y(!1),[l,c]=y(e||null),[d,u]=y(null),[p,f]=y(!1),[g,m]=y(""),[h,b]=y(!1),[x,v]=y(!1),w=(()=>{try{return new URLSearchParams(window.location.search).get("simulateUpdate")==="1"}catch{return!1}})(),$=(()=>{if(!w)return null;try{return new URLSearchParams(window.location.search).get("simulateVersion")||"v0.0.0-preview"}catch{return"v0.0.0-preview"}})(),S=w||p,C=$||d,_=o||S,k=C?`Update to ${C}`:"Update",A="https://github.com/openclaw/openclaw/tags",D=S&&C;L(()=>{c(e||null)},[e]),L(()=>{let R=!0;return(async(E=!1)=>{try{let G=await n(E);if(!R)return;c(G.currentVersion||e||null),u(G.latestVersion||null),f(!!G.hasUpdate),m(G.ok?"":G.error||"")}catch(G){if(!R)return;m(G.message||"Could not check updates")}})(!1),()=>{R=!1}},[e,n]),L(()=>{if(o)return()=>{};let R=!0,B=setTimeout(async()=>{try{let E=await n(!0);if(!R)return;c(E.currentVersion||e||null),u(E.latestVersion||null),f(!!E.hasUpdate),m(E.ok?"":E.error||"")}catch{}},1200);return()=>{R=!1,clearTimeout(B)}},[o,e,n]),L(()=>{if(!S||!C){b(!1);return}b(!1)},[S,C]);let N=async()=>{let R=!!S;if(!(_?i||o:i)){a(!0),m("");try{let E=R?await s():await n(!0);c(E.currentVersion||l),u(E.latestVersion||null),f(!!E.hasUpdate),m(E.ok?"":E.error||""),R?E.ok?E.updated||E.restarting?I(E.restarting?`${t} updated \u2014 restarting...`:`Updated ${t} to ${E.currentVersion}`,"success"):I(`Already at latest ${t} version`,"success"):I(E.error||`${t} update failed`,"error"):E.hasUpdate&&E.latestVersion?I(`${t} update available: ${E.latestVersion}`,"warning"):I(`${t} is up to date`,"success"),await r({type:R?"update":"check",ok:!!E?.ok,result:E})}catch(E){m(E.message||(R?`Could not update ${t}`:"Could not check updates")),I(R?`Could not update ${t}`:"Could not check updates","error"),await r({type:R?"update":"check",ok:!1,error:E})}finally{a(!1)}}},U=()=>{if(!(_?i||o:i)){if(S&&C&&!h){v(!0);return}N()}},O=()=>{v(!1),N()},M=_?i||o:i;return en`

${t}${" "}${l?`${l}`:"..."}

- ${g&&S&&Qt`
${g}
`}
- ${S&&C&&Qt` + ${S&&C&&en` {r.current&&(r.current.destroy(),r.current=null)}},[f,i,s >View changelog `} - ${O?Qt` + ${D?en` <${tn} - onClick=${z} + onClick=${U} loading=${M} warning=${_} idleLabel=${_?k:"Check updates"} loadingLabel=${_?"Updating...":"Checking..."} className="hidden md:inline-flex" /> - `:Qt` + `:en` <${tn} - onClick=${z} + onClick=${U} loading=${M} warning=${_} idleLabel=${_?k:"Check updates"} @@ -6242,7 +6318,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s `}
- ${O&&Qt` + ${D&&en`
{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s >View changelog <${tn} - onClick=${z} + onClick=${U} loading=${M} warning=${_} idleLabel=${k} @@ -6270,9 +6346,9 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s cancelLabel="Cancel" confirmTone="warning" onCancel=${()=>v(!1)} - onConfirm=${E} + onConfirm=${O} /> - `},bc=({status:t,openclawVersion:e,restarting:n=!1,onRestart:s,watchdogStatus:o=null,onOpenWatchdog:r,onRepair:i,repairing:a=!1,openclawUpdateInProgress:l=!1,onOpenclawVersionActionComplete:c=()=>{},onOpenclawUpdate:d=ma})=>{let[u,p]=y(()=>Date.now()),f=t==="running"&&!n,g=f?"ac-status-dot ac-status-dot--healthy":"w-2 h-2 rounded-full bg-yellow-500 animate-pulse",m=o?.lifecycle==="crash_loop"?"crash_loop":o?.health,h=m==="healthy"?"ac-status-dot ac-status-dot--healthy ac-status-dot--healthy-offset":m==="degraded"?"bg-yellow-500":m==="unhealthy"||m==="crash_loop"?"bg-red-500":"bg-gray-500",b=m==="unknown"?"initializing":m||"unknown",x=a||!!o?.operationInProgress,v=m==="degraded"&&!!r,w=x||o?.health==="degraded"&&!r||o?.lifecycle==="crash_loop"||o?.health==="unhealthy"||o?.health==="crashed",$=F(()=>{let S=o?.uptimeStartedAt?Date.parse(o.uptimeStartedAt):null;return Number.isFinite(S)?Math.max(0,u-S):o?.uptimeMs||0},[o?.uptimeStartedAt,o?.uptimeMs,u]);return L(()=>{let S=setInterval(()=>{p(Date.now())},1e3);return()=>clearInterval(S)},[]),Qt`
+ `},bc=({status:t,openclawVersion:e,restarting:n=!1,onRestart:s,watchdogStatus:o=null,onOpenWatchdog:r,onRepair:i,repairing:a=!1,openclawUpdateInProgress:l=!1,onOpenclawVersionActionComplete:c=()=>{},onOpenclawUpdate:d=ma})=>{let[u,p]=y(()=>Date.now()),f=t==="running"&&!n,g=f?"ac-status-dot ac-status-dot--healthy":"w-2 h-2 rounded-full bg-yellow-500 animate-pulse",m=o?.lifecycle==="crash_loop"?"crash_loop":o?.health,h=m==="healthy"?"ac-status-dot ac-status-dot--healthy ac-status-dot--healthy-offset":m==="degraded"?"bg-yellow-500":m==="unhealthy"||m==="crash_loop"?"bg-red-500":"bg-gray-500",b=m==="unknown"?"initializing":m||"unknown",x=a||!!o?.operationInProgress,v=m==="degraded"&&!!r,w=x||o?.health==="degraded"&&!r||o?.lifecycle==="crash_loop"||o?.health==="unhealthy"||o?.health==="crashed",$=F(()=>{let S=o?.uptimeStartedAt?Date.parse(o.uptimeStartedAt):null;return Number.isFinite(S)?Math.max(0,u-S):o?.uptimeMs||0},[o?.uptimeStartedAt,o?.uptimeMs,u]);return L(()=>{let S=setInterval(()=>{p(Date.now())},1e3);return()=>clearInterval(S)},[]),en`
@@ -6283,9 +6359,9 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s >
- ${!n&&f?Qt` + ${!n&&f?en` Uptime: ${k3($)}Uptime: ${M3($)} `:null} <${tn} @@ -6299,7 +6375,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
- ${r?Qt` + ${r?en` - `:Qt` + `:en`
{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s ${b}
`} - ${i?Qt` + ${i?en`
- ${v?Qt` + ${v?en` <${tn} onClick=${r} warning=${!1} @@ -6330,7 +6406,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s loadingLabel="Inspect" className="w-full justify-center" /> - `:w?Qt` + `:w?en` <${tn} onClick=${i} loading=${x} @@ -6339,7 +6415,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s loadingLabel="Repairing..." className="w-full justify-center" /> - `:Qt``} @@ -6348,7 +6424,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
- <${S3} + <${T3} label="OpenClaw" currentVersion=${e} fetchVersion=${mm} @@ -6357,7 +6433,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s onActionComplete=${c} />
-
`};var $r=P.bind(T),C3={webchat:"Browser",cli:"CLI"},_3=t=>C3[t.clientMode]||t.clientId||"Device",M3=t=>{let e=[];return t.platform&&e.push(t.platform),t.role&&e.push(t.role),e.join(" \xB7 ")},A3=({d:t,onApprove:e,onReject:n})=>{let[s,o]=y(null),r=async l=>{o(l);try{l==="approve"?await e(t.id):await n(t.id)}catch{o(null)}},i=_3(t),a=M3(t);return s==="approve"?$r` +
`};var $r=P.bind(T),P3={webchat:"Browser",cli:"CLI"},R3=t=>P3[t.clientMode]||t.clientId||"Device",L3=t=>{let e=[];return t.platform&&e.push(t.platform),t.role&&e.push(t.role),e.join(" \xB7 ")},E3=({d:t,onApprove:e,onReject:n})=>{let[s,o]=y(null),r=async l=>{o(l);try{l==="approve"?await e(t.id):await n(t.id)}catch{o(null)}},i=R3(t),a=L3(t);return s==="approve"?$r`
Approved ${i} @@ -6372,14 +6448,14 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s ${a&&$r`${a}`}
- <${Z} + <${Y} onClick=${()=>r("approve")} tone="success" size="sm" idleLabel="Approve" className="font-medium px-3 py-1.5" /> - <${Z} + <${Y} onClick=${()=>r("reject")} tone="secondary" size="sm" @@ -6390,9 +6466,9 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
`},xc=({pending:t,onApprove:e,onReject:n})=>!t||t.length===0?null:$r`

Pending device pairings

- ${t.map(s=>$r`<${A3} key=${s.id} d=${s} onApprove=${e} onReject=${n} />`)} -
`;var fo=P.bind(T),Vi=[{key:"gmail",icon:"\u{1F4E7}",label:"Gmail",defaultRead:!0,defaultWrite:!1},{key:"calendar",icon:"\u{1F4C5}",label:"Calendar",defaultRead:!0,defaultWrite:!0},{key:"drive",icon:"\u{1F4C1}",label:"Drive",defaultRead:!0,defaultWrite:!1},{key:"sheets",icon:"\u{1F4CA}",label:"Sheets",defaultRead:!0,defaultWrite:!1},{key:"docs",icon:"\u{1F4DD}",label:"Docs",defaultRead:!0,defaultWrite:!1},{key:"tasks",icon:"\u2705",label:"Tasks",defaultRead:!1,defaultWrite:!1},{key:"contacts",icon:"\u{1F464}",label:"Contacts",defaultRead:!1,defaultWrite:!1},{key:"meet",icon:"\u{1F3A5}",label:"Meet",defaultRead:!1,defaultWrite:!1}],T3={gmail:"gmail.googleapis.com",calendar:"calendar-json.googleapis.com",tasks:"tasks.googleapis.com",drive:"drive.googleapis.com",contacts:"people.googleapis.com",sheets:"sheets.googleapis.com",docs:"docs.googleapis.com",meet:"meet.googleapis.com"};function Sw(t){return`https://console.developers.google.com/apis/api/${T3[t]||""}/overview`}function Cw({scopes:t,onToggle:e,apiStatus:n,loading:s}){let[o,r]=y(!1),i=n||{},a=5,l=Vi.length>a,c=o?Vi:Vi.slice(0,a);return fo`
- ${c.map(d=>{let u=t.includes(`${d.key}:read`),p=t.includes(`${d.key}:write`),f=i[d.key],g=null;return s&&!f&&(u||p)?g=fo``:f&&(f.status==="ok"?g=fo`API ✓`:f.status==="not_enabled"?g=fo`Enable API`:f.status==="error"&&(g=fo`Enable API`)),fo` + ${t.map(s=>$r`<${E3} key=${s.id} d=${s} onApprove=${e} onReject=${n} />`)} +
`;var fo=P.bind(T),Vi=[{key:"gmail",icon:"\u{1F4E7}",label:"Gmail",defaultRead:!0,defaultWrite:!1},{key:"calendar",icon:"\u{1F4C5}",label:"Calendar",defaultRead:!0,defaultWrite:!0},{key:"drive",icon:"\u{1F4C1}",label:"Drive",defaultRead:!0,defaultWrite:!1},{key:"sheets",icon:"\u{1F4CA}",label:"Sheets",defaultRead:!0,defaultWrite:!1},{key:"docs",icon:"\u{1F4DD}",label:"Docs",defaultRead:!0,defaultWrite:!1},{key:"tasks",icon:"\u2705",label:"Tasks",defaultRead:!1,defaultWrite:!1},{key:"contacts",icon:"\u{1F464}",label:"Contacts",defaultRead:!1,defaultWrite:!1},{key:"meet",icon:"\u{1F3A5}",label:"Meet",defaultRead:!1,defaultWrite:!1}],I3={gmail:"gmail.googleapis.com",calendar:"calendar-json.googleapis.com",tasks:"tasks.googleapis.com",drive:"drive.googleapis.com",contacts:"people.googleapis.com",sheets:"sheets.googleapis.com",docs:"docs.googleapis.com",meet:"meet.googleapis.com"};function Aw(t){return`https://console.developers.google.com/apis/api/${I3[t]||""}/overview`}function Mw({scopes:t,onToggle:e,apiStatus:n,loading:s}){let[o,r]=y(!1),i=n||{},a=5,l=Vi.length>a,c=o?Vi:Vi.slice(0,a);return fo`
+ ${c.map(d=>{let u=t.includes(`${d.key}:read`),p=t.includes(`${d.key}:write`),f=i[d.key],g=null;return s&&!f&&(u||p)?g=fo``:f&&(f.status==="ok"?g=fo`API ✓`:f.status==="not_enabled"?g=fo`Enable API`:f.status==="error"&&(g=fo`Enable API`)),fo`
${d.icon} ${d.label}
@@ -6410,7 +6486,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s ${o?"Show fewer services":`Show more services (${Vi.length-a})`} `:null} -
`}function _w(t,e){let n=t.includes(e),s=n?t.filter(o=>o!==e):[...t,e];if(e.endsWith(":write")&&!n){let o=e.replace(":write",":read");s.includes(o)||s.push(o)}if(e.endsWith(":read")&&n){let o=e.replace(":read",":write");s=s.filter(r=>r!==o)}return s}function wr(){let t=[];for(let e of Vi)e.defaultRead&&t.push(`${e.key}:read`),e.defaultWrite&&t.push(`${e.key}:write`);return t}var kr=P.bind(T),Mw=({visible:t,onClose:e,onSaved:n,title:s="Connect Google Workspace",submitLabel:o="Connect Google",defaultInstrType:r="workspace",client:i="default",personal:a=!1,accountId:l="",initialValues:c={}})=>{let[d,u]=y(""),[p,f]=y(""),[g,m]=y(""),[h,b]=y(""),[x,v]=y(!1),[w,$]=y(r),[S,C]=y(!1),_=ee(null);if(L(()=>{t&&(u(String(c.clientId||"")),f(String(c.clientSecret||"")),m(String(c.email||"")),$(r),b(""),C(!1))},[t,c,r]),!t)return null;let k=`${window.location.origin}/auth/google/callback`,A=async()=>{try{await navigator.clipboard.writeText(k),C(!0),window.setTimeout(()=>C(!1),1500)}catch{b("Unable to copy redirect URI")}},O=async R=>{let B=R.target.files[0];if(B)try{let I=await B.text(),U=JSON.parse(I),W=U.installed||U.web||U;W.client_id&&u(W.client_id),W.client_secret&&f(W.client_secret)}catch{b("Invalid JSON file")}},D=async()=>{if(b(""),!d||!p||!g){b("Client ID, Client Secret, and Email are required");return}v(!0);try{let R=await zh({clientId:d,clientSecret:p,email:g,client:i,personal:a,accountId:l});R.ok?(e(),n?.(R.account)):b(R.error||"Failed to save credentials")}catch{b("Request failed")}finally{v(!1)}},z=R=>`flex-1 text-center border-0 cursor-pointer transition-colors ${w===R?"":"hover:text-white"}`,E=R=>"font-family: inherit; font-size: 11px; letter-spacing: 0.03em; padding: 5px 10px;"+(w===R?" color: var(--accent); background: var(--bg-active);":" color: var(--text-muted); background: transparent;"),M=()=>kr` +
`}function Tw(t,e){let n=t.includes(e),s=n?t.filter(o=>o!==e):[...t,e];if(e.endsWith(":write")&&!n){let o=e.replace(":write",":read");s.includes(o)||s.push(o)}if(e.endsWith(":read")&&n){let o=e.replace(":read",":write");s=s.filter(r=>r!==o)}return s}function wr(){let t=[];for(let e of Vi)e.defaultRead&&t.push(`${e.key}:read`),e.defaultWrite&&t.push(`${e.key}:write`);return t}var kr=P.bind(T),Pw=({visible:t,onClose:e,onSaved:n,title:s="Connect Google Workspace",submitLabel:o="Connect Google",defaultInstrType:r="workspace",client:i="default",personal:a=!1,accountId:l="",initialValues:c={}})=>{let[d,u]=y(""),[p,f]=y(""),[g,m]=y(""),[h,b]=y(""),[x,v]=y(!1),[w,$]=y(r),[S,C]=y(!1),_=ee(null);if(L(()=>{t&&(u(String(c.clientId||"")),f(String(c.clientSecret||"")),m(String(c.email||"")),$(r),b(""),C(!1))},[t,c,r]),!t)return null;let k=`${window.location.origin}/auth/google/callback`,A=async()=>{try{await navigator.clipboard.writeText(k),C(!0),window.setTimeout(()=>C(!1),1500)}catch{b("Unable to copy redirect URI")}},D=async R=>{let B=R.target.files[0];if(B)try{let E=await B.text(),G=JSON.parse(E),H=G.installed||G.web||G;H.client_id&&u(H.client_id),H.client_secret&&f(H.client_secret)}catch{b("Invalid JSON file")}},N=async()=>{if(b(""),!d||!p||!g){b("Client ID, Client Secret, and Email are required");return}v(!0);try{let R=await zh({clientId:d,clientSecret:p,email:g,client:i,personal:a,accountId:l});R.ok?(e(),n?.(R.account)):b(R.error||"Failed to save credentials")}catch{b("Request failed")}finally{v(!1)}},U=R=>`flex-1 text-center border-0 cursor-pointer transition-colors ${w===R?"":"hover:text-white"}`,O=R=>"font-family: inherit; font-size: 11px; letter-spacing: 0.03em; padding: 5px 10px;"+(w===R?" color: var(--accent); background: var(--bg-active);":" color: var(--text-muted); background: transparent;"),M=()=>kr`
{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s ${S?"Copied":"Copy"}
- `;return kr` <${De} + `;return kr` <${Te} visible=${t} onClose=${e} closeOnOverlayClick=${!1} panelClassName="bg-modal border border-border rounded-xl p-6 max-w-lg w-full space-y-4" > - <${Ne} + <${Pe} title=${s} actions=${kr` `} /> @@ -6471,15 +6547,15 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s > @@ -6610,7 +6686,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s type="file" ref=${_} accept=".json" - onchange=${O} + onchange=${D} class="hidden" />
- <${Z} - onClick=${D} + <${Y} + onClick=${N} disabled=${x} loading=${x} tone="primary" @@ -6673,14 +6749,14 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s />
${h?kr`
${h}
`:null} - `};var Aw=P.bind(T),P3=({watchStatus:t,busy:e=!1})=>e?{label:t?.enabled?"Stopping":"Starting",tone:"warning"}:t?.enabled?t.enabled&&!t.running?{label:"Error",tone:"danger"}:{label:"Watching",tone:"success"}:{label:"Stopped",tone:"neutral"},Tw=({account:t,watchStatus:e=null,busy:n=!1,onEnable:s=()=>{},onDisable:o=()=>{},onOpenWebhook:r=()=>{}})=>{if(!(Array.isArray(t?.activeScopes)?t.activeScopes.includes("gmail:read"):Array.isArray(t?.services)?t.services.includes("gmail:read"):!1))return Aw` + `};var Rw=P.bind(T),D3=({watchStatus:t,busy:e=!1})=>e?{label:t?.enabled?"Stopping":"Starting",tone:"warning"}:t?.enabled?t.enabled&&!t.running?{label:"Error",tone:"danger"}:{label:"Watching",tone:"success"}:{label:"Stopped",tone:"neutral"},Lw=({account:t,watchStatus:e=null,busy:n=!1,onEnable:s=()=>{},onDisable:o=()=>{},onOpenWebhook:r=()=>{}})=>{if(!(Array.isArray(t?.activeScopes)?t.activeScopes.includes("gmail:read"):Array.isArray(t?.services)?t.services.includes("gmail:read"):!1))return Rw`
Gmail watch requires gmail:read. Add it in permissions above, then update permissions.
- `;let a=P3({watchStatus:e,busy:n}),l=!!e?.enabled;return Aw` + `;let a=D3({watchStatus:e,busy:n}),l=!!e?.enabled;return Rw`
{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s onClick=${c=>c.stopPropagation()} onKeyDown=${c=>c.stopPropagation()} > - <${ae} tone=${a.tone}>${a.label} + <${le} tone=${a.tone}>${a.label} <${vn} checked=${l} disabled=${n} @@ -6709,7 +6785,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s />
- `};var ji=P.bind(T),R3=(t=[],e=[])=>t.length===e.length&&t.every(n=>e.includes(n)),Pw=({account:t,personal:e=!1,expanded:n,onToggleExpanded:s,scopes:o=[],savedScopes:r=[],apiStatus:i={},checkingApis:a=!1,onToggleScope:l,onCheckApis:c,onUpdatePermissions:d,onEditCredentials:u,onDisconnect:p,gmailWatchStatus:f=null,gmailWatchBusy:g=!1,onEnableGmailWatch:m,onDisableGmailWatch:h,onOpenGmailSetup:b,onOpenGmailWebhook:x})=>{let v=!R3(o,r);return ji` + `};var ji=P.bind(T),N3=(t=[],e=[])=>t.length===e.length&&t.every(n=>e.includes(n)),Ew=({account:t,personal:e=!1,expanded:n,onToggleExpanded:s,scopes:o=[],savedScopes:r=[],apiStatus:i={},checkingApis:a=!1,onToggleScope:l,onCheckApis:c,onUpdatePermissions:d,onEditCredentials:u,onDisconnect:p,gmailWatchStatus:f=null,gmailWatchBusy:g=!1,onEnableGmailWatch:m,onDisableGmailWatch:h,onOpenGmailSetup:b,onOpenGmailWebhook:x})=>{let v=!N3(o,r);return ji`
- ${e?ji`<${ae} tone="neutral">Personal`:null} - <${ae} tone=${t.authenticated?"success":"warning"}> + ${e?ji`<${le} tone="neutral">Personal`:null} + <${le} tone=${t.authenticated?"success":"warning"}> ${t.authenticated?"Connected":"Awaiting sign-in"} - + ${n?"\u25BE":"\u25B8"}
@@ -6740,7 +6816,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s ${a?"Checking APIs...":"\u21BB Check APIs"} `:null}
- <${Cw} + <${Mw} scopes=${o} onToggle=${w=>l?.(t.id,w)} apiStatus=${t.authenticated?i:{}} @@ -6759,7 +6835,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s Configure - <${Tw} + <${Lw} account=${t} watchStatus=${f} busy=${g} @@ -6799,13 +6875,13 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s `:null} - `};var pf=P.bind(T),Rw=({visible:t,onClose:e,onSubmit:n,loading:s=!1,defaultEmail:o="",title:r="Add Company Account"})=>{let[i,a]=y(""),[l,c]=y("");if(L(()=>{t&&(a(String(o||"")),c(""))},[t,o]),!t)return null;let d=async()=>{c("");let u=String(i||"").trim();if(!u){c("Email is required");return}await n?.({email:u,setError:c})};return pf`<${De} + `};var pf=P.bind(T),Iw=({visible:t,onClose:e,onSubmit:n,loading:s=!1,defaultEmail:o="",title:r="Add Company Account"})=>{let[i,a]=y(""),[l,c]=y("");if(L(()=>{t&&(a(String(o||"")),c(""))},[t,o]),!t)return null;let d=async()=>{c("");let u=String(i||"").trim();if(!u){c("Email is required");return}await n?.({email:u,setError:c})};return pf`<${Te} visible=${t} onClose=${e} closeOnOverlayClick=${!1} panelClassName="bg-modal border border-border rounded-xl p-6 max-w-md w-full space-y-4" > - <${Ne} + <${Pe} title=${r} actions=${pf` `} /> @@ -6837,7 +6913,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s ${l?pf`
${l}
`:null}
- <${Z} + <${Y} onClick=${d} disabled=${s} loading=${s} @@ -6848,7 +6924,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s className="w-full px-4 py-2 rounded-lg text-sm" />
- `};var Lw=({gatewayStatus:t})=>{let e=ee(!1),{data:n,loading:s,refresh:o}=ct("/api/google/accounts",Wh,{maxAgeMs:3e4}),r=F(()=>Array.isArray(n?.accounts)?n.accounts:[],[n?.accounts]),i=!!n?.hasCompanyCredentials,a=!!n?.hasPersonalCredentials,l=q(async()=>o({force:!0}),[o]);return L(()=>{if(t!=="running"){e.current=!1;return}e.current||(e.current=!0,l().catch(()=>{}))},[t,l]),{accounts:r,loading:s,hasCompanyCredentials:i,hasPersonalCredentials:a,refreshAccounts:l}};var Ew=({gatewayStatus:t,accounts:e=[]})=>{let[n,s]=y({}),[o,r]=y(!1),i=F(()=>e.map(x=>String(x?.id||"").trim()).filter(Boolean).sort().join("|"),[e]),{data:a,loading:l,refresh:c}=ct("/api/gmail/config",Gh,{enabled:t==="running",maxAgeMs:3e4}),d=q(async()=>c({force:!0}),[c]);L(()=>{t==="running"&&e.length&&d().catch(()=>{})},[i,e.length,t,d]);let u=F(()=>{let x=new Map;for(let v of a?.accounts||[])x.set(String(v.accountId||""),v);return x},[a]),p=F(()=>{let x=new Map;for(let v of a?.clients||[])x.set(String(v.client||"default"),v);return x},[a]),f=(x,v)=>{s(w=>{let $=String(x||"");if(!$)return w;if(v)return{...w,[$]:!0};if(!w[$])return w;let S={...w};return delete S[$],S})},g=q(async(x,{destination:v=null}={})=>{let w=String(x||"");f(w,!0);try{let $=await Jh(w,{destination:v});return await d(),$}finally{f(w,!1)}},[d]),m=q(async x=>{let v=String(x||"");f(v,!0);try{await Zh(v),await d()}finally{f(v,!1)}},[d]),h=q(async(x="")=>{let v=String(x||"");v&&f(v,!0);try{await Yh({accountId:v,force:!0}),await d()}finally{v&&f(v,!1)}},[d]),b=q(async({client:x="default",projectId:v="",regeneratePushToken:w=!1}={})=>{r(!0);try{let $=await qh({client:x,projectId:v,regeneratePushToken:w});return await d(),$}catch($){throw String($?.message||"").toLowerCase().includes("not found")?new Error("Gmail watch API route not found. Restart AlphaClaw so /api/gmail routes are loaded."):$}finally{r(!1)}},[d]);return{loading:l,config:a,watchByAccountId:u,clientConfigByClient:p,busyByAccountId:n,savingClient:o,refresh:d,saveClientSetup:b,startWatchForAccount:g,stopWatchForAccount:m,renewForAccount:h}};var mt=P.bind(T),L3=async t=>{let e=String(t||"");if(!e)return!1;try{if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{let n=document.createElement("textarea");return n.value=e,n.setAttribute("readonly",""),n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),!0}catch{return!1}},Iw=["Install + Authenticate gcloud","Enable APIs","Create Topic + IAM","Create Push Subscription","Build with your Agent"],E3=Iw.slice(0,3),yc=Is,vc=(t="",e=()=>{})=>mt` + `};var Dw=({gatewayStatus:t})=>{let e=ee(!1),{data:n,loading:s,refresh:o}=ct("/api/google/accounts",Wh,{maxAgeMs:3e4}),r=F(()=>Array.isArray(n?.accounts)?n.accounts:[],[n?.accounts]),i=!!n?.hasCompanyCredentials,a=!!n?.hasPersonalCredentials,l=q(async()=>o({force:!0}),[o]);return L(()=>{if(t!=="running"){e.current=!1;return}e.current||(e.current=!0,l().catch(()=>{}))},[t,l]),{accounts:r,loading:s,hasCompanyCredentials:i,hasPersonalCredentials:a,refreshAccounts:l}};var Nw=({gatewayStatus:t,accounts:e=[]})=>{let[n,s]=y({}),[o,r]=y(!1),i=F(()=>e.map(x=>String(x?.id||"").trim()).filter(Boolean).sort().join("|"),[e]),{data:a,loading:l,refresh:c}=ct("/api/gmail/config",Gh,{enabled:t==="running",maxAgeMs:3e4}),d=q(async()=>c({force:!0}),[c]);L(()=>{t==="running"&&e.length&&d().catch(()=>{})},[i,e.length,t,d]);let u=F(()=>{let x=new Map;for(let v of a?.accounts||[])x.set(String(v.accountId||""),v);return x},[a]),p=F(()=>{let x=new Map;for(let v of a?.clients||[])x.set(String(v.client||"default"),v);return x},[a]),f=(x,v)=>{s(w=>{let $=String(x||"");if(!$)return w;if(v)return{...w,[$]:!0};if(!w[$])return w;let S={...w};return delete S[$],S})},g=q(async(x,{destination:v=null}={})=>{let w=String(x||"");f(w,!0);try{let $=await Jh(w,{destination:v});return await d(),$}finally{f(w,!1)}},[d]),m=q(async x=>{let v=String(x||"");f(v,!0);try{await Zh(v),await d()}finally{f(v,!1)}},[d]),h=q(async(x="")=>{let v=String(x||"");v&&f(v,!0);try{await Yh({accountId:v,force:!0}),await d()}finally{v&&f(v,!1)}},[d]),b=q(async({client:x="default",projectId:v="",regeneratePushToken:w=!1}={})=>{r(!0);try{let $=await qh({client:x,projectId:v,regeneratePushToken:w});return await d(),$}catch($){throw String($?.message||"").toLowerCase().includes("not found")?new Error("Gmail watch API route not found. Restart AlphaClaw so /api/gmail routes are loaded."):$}finally{r(!1)}},[d]);return{loading:l,config:a,watchByAccountId:u,clientConfigByClient:p,busyByAccountId:n,savingClient:o,refresh:d,saveClientSetup:b,startWatchForAccount:g,stopWatchForAccount:m,renewForAccount:h}};var mt=P.bind(T),O3=async t=>{let e=String(t||"");if(!e)return!1;try{if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{let n=document.createElement("textarea");return n.value=e,n.setAttribute("readonly",""),n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),!0}catch{return!1}},Ow=["Install + Authenticate gcloud","Enable APIs","Create Topic + IAM","Create Push Subscription","Build with your Agent"],B3=Ow.slice(0,3),yc=Ds,vc=(t="",e=()=>{})=>mt`
     
-`,Dw=({visible:t=!1,account:e=null,clientConfig:n=null,saving:s=!1,onClose:o=()=>{},onSaveSetup:r=async()=>{},onFinish:i=async()=>{}})=>{let[a,l]=y(0),[c,d]=y(""),[u,p]=y(!1),[f,g]=y(""),[m,h]=y(!1),[b,x]=y(!1),[v,w]=y(!1),[$,S]=y(!1),[C,_]=y(!1),{selectedSessionKey:k,setSelectedSessionKey:A,loading:O,error:D}=yr({enabled:t,filter:pc}),{sessions:z,destinationSessionKey:E,setDestinationSessionKey:M,selectedDestination:R}=Ds({enabled:t,resetKey:String(e?.id||"")});L(()=>{t&&(l(0),g(""),d(""),p(!1),h(!1),x(!1),w(!1),S(!1),_(!!n?.webhookExists))},[t,e?.id]);let B=n?.commands||null,I=!!(String(n?.projectId||"").trim()||B),U=u||!I&&!m,W=String(c||"").trim()||String(n?.projectId||"").trim()||"",G=C,se=G?E3:Iw,K=se.length,j=String(e?.client||n?.client||"default").trim()||"default",X=F(()=>U?String(c||"").trim().length>0:!0,[U,c]),de=q(async he=>{if(await L3(he)){N("Copied to clipboard","success");return}N("Could not copy text","error")},[]),le=q(()=>{g(""),d(String(n?.projectId||"").trim()),h(!1),p(!0)},[n?.projectId]),ie=async()=>{try{g(""),await i({client:j,projectId:String(c||"").trim(),destination:R}),x(!0),l(he=>Math.min(he+1,K-1))}catch(he){g(he.message||"Could not finish setup")}},ne=async()=>{if(!s){if(U){if(!X)return;g("");try{await r({client:j,projectId:String(c||"").trim()}),p(!1),h(!0)}catch(he){g(he.message||"Could not save project id");return}return}l(he=>Math.min(he+1,K-1))}},xe=async()=>{if(!(v||$))try{w(!0);let ue=`I just enabled Gmail watch for "${String(e?.email||"this account").trim()||"this account"}", set up the webhook, and created the transform file. Help me set up what I want to do with incoming email.`;await fa({message:ue,sessionKey:k}),S(!0),N("Message sent to your agent","success")}catch(he){N(he.message||"Could not send message to agent","error")}finally{w(!1)}};return mt` - <${De} +`,Bw=({visible:t=!1,account:e=null,clientConfig:n=null,saving:s=!1,onClose:o=()=>{},onSaveSetup:r=async()=>{},onFinish:i=async()=>{}})=>{let[a,l]=y(0),[c,d]=y(""),[u,p]=y(!1),[f,g]=y(""),[m,h]=y(!1),[b,x]=y(!1),[v,w]=y(!1),[$,S]=y(!1),[C,_]=y(!1),{selectedSessionKey:k,setSelectedSessionKey:A,loading:D,error:N}=yr({enabled:t,filter:pc}),{sessions:U,destinationSessionKey:O,setDestinationSessionKey:M,selectedDestination:R}=Ns({enabled:t,resetKey:String(e?.id||"")});L(()=>{t&&(l(0),g(""),d(""),p(!1),h(!1),x(!1),w(!1),S(!1),_(!!n?.webhookExists))},[t,e?.id]);let B=n?.commands||null,E=!!(String(n?.projectId||"").trim()||B),G=u||!E&&!m,H=String(c||"").trim()||String(n?.projectId||"").trim()||"",z=C,te=z?B3:Ow,K=te.length,V=String(e?.client||n?.client||"default").trim()||"default",Z=F(()=>G?String(c||"").trim().length>0:!0,[G,c]),ue=q(async pe=>{if(await O3(pe)){I("Copied to clipboard","success");return}I("Could not copy text","error")},[]),re=q(()=>{g(""),d(String(n?.projectId||"").trim()),h(!1),p(!0)},[n?.projectId]),oe=async()=>{try{g(""),await i({client:V,projectId:String(c||"").trim(),destination:R}),x(!0),l(pe=>Math.min(pe+1,K-1))}catch(pe){g(pe.message||"Could not finish setup")}},ne=async()=>{if(!s){if(G){if(!Z)return;g("");try{await r({client:V,projectId:String(c||"").trim()}),p(!1),h(!0)}catch(pe){g(pe.message||"Could not save project id");return}return}l(pe=>Math.min(pe+1,K-1))}},me=async()=>{if(!(v||$))try{w(!0);let ce=`I just enabled Gmail watch for "${String(e?.email||"this account").trim()||"this account"}", set up the webhook, and created the transform file. Help me set up what I want to do with incoming email.`;await fa({message:ce,sessionKey:k}),S(!0),I("Message sent to your agent","success")}catch(pe){I(pe.message||"Could not send message to agent","error")}finally{w(!1)}};return mt` + <${Te} visible=${t} onClose=${o} closeOnOverlayClick=${!1} @@ -6879,24 +6955,24 @@ ${t} - <${nt} className="w-3.5 h-3.5 text-body" /> + <${Ze} className="w-3.5 h-3.5 text-body" />
Gmail Pub / Sub Setup
- ${se.map((he,ue)=>mt` + ${te.map((pe,ce)=>mt`
`)}
- <${Ne} - title=${`Step ${a+1} of ${K}: ${se[a]}`} + <${Pe} + title=${`Step ${a+1} of ${K}: ${te[a]}`} actions=${null} /> ${f?mt`
${f}
`:null} - ${U?mt` + ${G?mt`
@@ -6917,16 +6993,16 @@ ${t}d(he.target.value)} + oninput=${pe=>d(pe.target.value)} class="w-full bg-field border border-border rounded-lg px-2.5 py-2 text-xs font-mono focus:border-fg-muted focus:outline-none" placeholder="my-gcp-project" />
`:null} - ${!U&&a===0?mt` + ${!G&&a===0?mt`
- Using project ${W}. + Using project ${H}.
If gcloud is not installed on your computer, @@ -6942,35 +7018,35 @@ ${t}
${vc(`gcloud auth login -gcloud config set project ${W}`,()=>de(`gcloud auth login -gcloud config set project ${W}`))} +gcloud config set project ${H}`,()=>ue(`gcloud auth login +gcloud config set project ${H}`))} `:null} - ${!U&&a===1?vc(B?.enableApis||"",()=>de(B?.enableApis||"")):null} - ${!U&&a===2?mt` + ${!G&&a===1?vc(B?.enableApis||"",()=>ue(B?.enableApis||"")):null} + ${!G&&a===2?mt` ${vc(`${B?.createTopic||""} -${B?.grantPublisher||""}`.trim(),()=>de(`${B?.createTopic||""} +${B?.grantPublisher||""}`.trim(),()=>ue(`${B?.createTopic||""} ${B?.grantPublisher||""}`.trim()))} `:null} - ${!G&&!U&&a===3?mt` - ${vc(B?.createSubscription||"",()=>de(B?.createSubscription||""))} + ${!z&&!G&&a===3?mt` + ${vc(B?.createSubscription||"",()=>ue(B?.createSubscription||""))}
<${vr} label="Deliver to" - sessions=${z} - selectedSessionKey=${E} + sessions=${U} + selectedSessionKey=${O} onChangeSessionKey=${M} - disabled=${G||O||s} - loading=${O} - error=${D} + disabled=${z||D||s} + loading=${D} + error=${N} allowNone=${!0} noneValue=${yc} noneLabel="Default" loadingLabel="Loading sessions..." - helperText=${G?"This Gmail webhook has already been created. To edit delivery routing, ask your agent.":null} + helperText=${z?"This Gmail webhook has already been created. To edit delivery routing, ask your agent.":null} selectClassName="w-full bg-field border border-border rounded-lg px-2.5 py-2 text-xs font-mono focus:border-fg-muted focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed" helperClassName="text-xs text-fg-muted" statusClassName="text-[11px] text-fg-muted" @@ -6978,7 +7054,7 @@ ${B?.grantPublisher||""}`.trim()))} />
`:null} - ${!G&&a===4?mt` + ${!z&&a===4?mt`
@@ -6995,21 +7071,21 @@ ${B?.grantPublisher||""}`.trim()))}
- <${Z} - onClick=${xe} + <${Y} + onClick=${me} disabled=${!k||$} loading=${v} idleLabel=${$?"Sent":"Send to Agent"} @@ -7019,33 +7095,33 @@ ${B?.grantPublisher||""}`.trim()))} className="h-[34px] px-3" />
- ${O?mt`
+ ${D?mt`
Loading sessions...
`:null} - ${D?mt`
- ${D} + ${N?mt`
+ ${N}
`:null}
`:null}
- ${a===0?mt`${U?mt`
`:mt`
`:mt``}`:mt`<${Z} - onClick=${()=>l(he=>Math.max(he-1,0))} + `}`:mt`<${Y} + onClick=${()=>l(pe=>Math.max(pe-1,0))} disabled=${s} idleLabel="Back" tone="secondary" size="md" className="w-full justify-center" />`} - ${!G&&a===K-2?mt`<${Z} - onClick=${ie} + ${!z&&a===K-2?mt`<${Y} + onClick=${oe} disabled=${!1} loading=${s} idleLabel="Enable watch" @@ -7053,14 +7129,14 @@ ${B?.grantPublisher||""}`.trim()))} tone="primary" size="md" className="w-full justify-center" - />`:a`:a`:mt`<${Z} + />`:mt`<${Y} onClick=${o} disabled=${s||v} idleLabel="Done" @@ -7069,13 +7145,13 @@ ${B?.grantPublisher||""}`.trim()))} className="w-full justify-center" />`}
- - `};var Ns=P.bind(T),I3=(t=[],e=[])=>t.length!==e.length||t.some(n=>!e.includes(n)),$c=(t={})=>!!t.personal,D3="/assets/icons/google_icon.svg",Nw=({gatewayStatus:t,onRestartRequired:e=()=>{},onOpenGmailWebhook:n=()=>{}})=>{let{accounts:s,loading:o,hasCompanyCredentials:r,refreshAccounts:i}=Lw({gatewayStatus:t}),[a,l]=y(""),[c,d]=y({}),[u,p]=y({}),[f,g]=y({}),[m,h]=y({}),[b,x]=y(!1),[v,w]=y({visible:!1,accountId:"",client:"default",personal:!1,title:"Connect Google Workspace",submitLabel:"Connect Google",defaultInstrType:"workspace",initialValues:{}}),[$,S]=y(!1),[C,_]=y(!1),[k,A]=y(""),[O,D]=y({visible:!1,accountId:""}),{loading:z,watchByAccountId:E,clientConfigByClient:M,busyByAccountId:R,savingClient:B,refresh:I,saveClientSetup:U,startWatchForAccount:W,stopWatchForAccount:G}=Ew({gatewayStatus:t,accounts:s}),se=F(()=>s.some(Q=>$c(Q)),[s]),K=F(()=>s.some(Q=>!$c(Q)),[s]),j=q(Q=>s.find(pe=>pe.id===Q)||null,[s]),X=q(Q=>{let pe=Array.isArray(Q.activeScopes)&&Q.activeScopes.length?Q.activeScopes:Array.isArray(Q.services)&&Q.services.length?Q.services:wr();p(te=>({...te,[Q.id]:[...pe]})),d(te=>{let Ee=te[Q.id];return!Ee||!I3(Ee,pe)?{...te,[Q.id]:[...pe]}:te})},[]);L(()=>{if(!s.length){l("");return}let Q=s.find(pe=>!pe.authenticated)?.id||"";l(pe=>pe&&s.some(te=>te.id===pe)?pe:Q),s.forEach(pe=>X(pe))},[s,X]);let de=q(Q=>{let pe=j(Q);if(!pe)return;let te=c[Q]||pe.activeScopes||wr();if(!te.length){window.alert("Select at least one service");return}let Ee=`/auth/google/start?accountId=${encodeURIComponent(Q)}&services=${encodeURIComponent(te.join(","))}&_ts=${Date.now()}`,ke=window.open(Ee,`google-auth-${Q}`,"popup=yes,width=500,height=700");(!ke||ke.closed)&&(window.location.href=Ee)},[j,c]),le=(Q,pe)=>{d(te=>({...te,[Q]:_w(te[Q]||[],pe)}))},ie=q(async Q=>{g(pe=>{let te={...pe};return delete te[Q],te}),h({[Q]:!0});try{let pe=await jh(Q);pe.results&&g(te=>({...te,[Q]:pe.results}))}finally{h(pe=>{if(!pe[Q])return pe;let te={...pe};return delete te[Q],te})}},[]);L(()=>{let Q=async pe=>{if(pe.data?.google==="success"){N("\u2713 Google account connected","success");let te=String(pe.data?.accountId||"").trim();g({}),await i(),await I(),te&&await ie(te)}else pe.data?.google==="error"&&N(`\u2717 Google auth failed: ${pe.data.message||"unknown"}`,"error")};return window.addEventListener("message",Q),()=>window.removeEventListener("message",Q)},[ie,i,I]),L(()=>{!a||!j(a)?.authenticated||m[a]||f[a]||ie(a)},[s,f,m,a,j,ie]);let ne=async Q=>{let pe=await Kh(Q);if(!pe.ok){N(`Failed to disconnect: ${pe.error||"unknown"}`,"error");return}N("Google account disconnected","success"),g(te=>{let Ee={...te};return delete Ee[Q],Ee}),await i(),await I()},xe=({accountId:Q="",client:pe="default",personal:te=!1,title:Ee="Connect Google Workspace",submitLabel:ke="Connect Google",defaultInstrType:H=te?"personal":"workspace",initialValues:re={}})=>{w({visible:!0,accountId:Q,client:pe,personal:te,title:Ee,submitLabel:ke,defaultInstrType:H,initialValues:re})},he=()=>{w(Q=>({...Q,visible:!1}))},ue=async Q=>{Q?.id&&l(Q.id),await i(),Q?.id&&de(Q.id)},me=async({email:Q,setError:pe})=>{_(!0);try{let te=await Uh({email:Q,client:"default",personal:!1,services:wr()});if(!te.ok){pe?.(te.error||"Could not add account");return}S(!1),te.accountId&&l(te.accountId),await i(),te.accountId&&de(te.accountId)}finally{_(!1)}},V=()=>{if(x(!1),K&&r){S(!0);return}xe({client:"default",personal:!1,title:"Add Company Account",submitLabel:"Save Credentials",defaultInstrType:"workspace"})},J=()=>{x(!1),xe({client:"personal",personal:!0,title:"Add Personal Account",submitLabel:"Save Credentials",defaultInstrType:"personal"})},oe=async Q=>{let pe=j(Q);if(!pe)return;let te=$c(pe),Ee=te?"personal":pe.client||"default",ke={};try{let H=await Vh({accountId:pe.id,client:Ee});H?.ok&&(ke={clientId:String(H.clientId||""),clientSecret:String(H.clientSecret||"")})}catch{N("Could not load saved client credentials","warning")}xe({accountId:pe.id,client:Ee,personal:te,title:`Edit Credentials (${pe.email})`,submitLabel:"Save Credentials",defaultInstrType:te?"personal":"workspace",initialValues:{email:pe.email,...ke}})},ce=Q=>{D({visible:!0,accountId:String(Q||"")})},be=()=>{D({visible:!1,accountId:""})},Ve=async Q=>{let pe=j(Q);if(!pe)return;let te=String(pe.client||"default").trim()||"default",Ee=M.get(te);if(!Ee?.configured||!Ee?.webhookExists){ce(Q);return}try{(await W(Q))?.restartRequired&&e(!0),N("Gmail watch enabled","success")}catch(ke){N(ke.message||"Could not enable Gmail watch","error")}},et=async Q=>{try{await G(Q),N("Gmail watch disabled","info")}catch(pe){N(pe.message||"Could not disable Gmail watch","error")}},kt=async({client:Q,projectId:pe,destination:te=null})=>{let Ee=String(O.accountId||"").trim();Ee&&(await U({client:Q,projectId:pe,regeneratePushToken:!1}),await W(Ee,{destination:te}),N("Gmail setup complete and watch enabled","success"))},Ot=()=>Ns` + + `};var Os=P.bind(T),F3=(t=[],e=[])=>t.length!==e.length||t.some(n=>!e.includes(n)),$c=(t={})=>!!t.personal,H3="/assets/icons/google_icon.svg",Fw=({gatewayStatus:t,onRestartRequired:e=()=>{},onOpenGmailWebhook:n=()=>{}})=>{let{accounts:s,loading:o,hasCompanyCredentials:r,refreshAccounts:i}=Dw({gatewayStatus:t}),[a,l]=y(""),[c,d]=y({}),[u,p]=y({}),[f,g]=y({}),[m,h]=y({}),[b,x]=y(!1),[v,w]=y({visible:!1,accountId:"",client:"default",personal:!1,title:"Connect Google Workspace",submitLabel:"Connect Google",defaultInstrType:"workspace",initialValues:{}}),[$,S]=y(!1),[C,_]=y(!1),[k,A]=y(""),[D,N]=y({visible:!1,accountId:""}),{loading:U,watchByAccountId:O,clientConfigByClient:M,busyByAccountId:R,savingClient:B,refresh:E,saveClientSetup:G,startWatchForAccount:H,stopWatchForAccount:z}=Nw({gatewayStatus:t,accounts:s}),te=F(()=>s.some(Q=>$c(Q)),[s]),K=F(()=>s.some(Q=>!$c(Q)),[s]),V=q(Q=>s.find(fe=>fe.id===Q)||null,[s]),Z=q(Q=>{let fe=Array.isArray(Q.activeScopes)&&Q.activeScopes.length?Q.activeScopes:Array.isArray(Q.services)&&Q.services.length?Q.services:wr();p(se=>({...se,[Q.id]:[...fe]})),d(se=>{let De=se[Q.id];return!De||!F3(De,fe)?{...se,[Q.id]:[...fe]}:se})},[]);L(()=>{if(!s.length){l("");return}let Q=s.find(fe=>!fe.authenticated)?.id||"";l(fe=>fe&&s.some(se=>se.id===fe)?fe:Q),s.forEach(fe=>Z(fe))},[s,Z]);let ue=q(Q=>{let fe=V(Q);if(!fe)return;let se=c[Q]||fe.activeScopes||wr();if(!se.length){window.alert("Select at least one service");return}let De=`/auth/google/start?accountId=${encodeURIComponent(Q)}&services=${encodeURIComponent(se.join(","))}&_ts=${Date.now()}`,ke=window.open(De,`google-auth-${Q}`,"popup=yes,width=500,height=700");(!ke||ke.closed)&&(window.location.href=De)},[V,c]),re=(Q,fe)=>{d(se=>({...se,[Q]:Tw(se[Q]||[],fe)}))},oe=q(async Q=>{g(fe=>{let se={...fe};return delete se[Q],se}),h({[Q]:!0});try{let fe=await jh(Q);fe.results&&g(se=>({...se,[Q]:fe.results}))}finally{h(fe=>{if(!fe[Q])return fe;let se={...fe};return delete se[Q],se})}},[]);L(()=>{let Q=async fe=>{if(fe.data?.google==="success"){I("\u2713 Google account connected","success");let se=String(fe.data?.accountId||"").trim();g({}),await i(),await E(),se&&await oe(se)}else fe.data?.google==="error"&&I(`\u2717 Google auth failed: ${fe.data.message||"unknown"}`,"error")};return window.addEventListener("message",Q),()=>window.removeEventListener("message",Q)},[oe,i,E]),L(()=>{!a||!V(a)?.authenticated||m[a]||f[a]||oe(a)},[s,f,m,a,V,oe]);let ne=async Q=>{let fe=await Kh(Q);if(!fe.ok){I(`Failed to disconnect: ${fe.error||"unknown"}`,"error");return}I("Google account disconnected","success"),g(se=>{let De={...se};return delete De[Q],De}),await i(),await E()},me=({accountId:Q="",client:fe="default",personal:se=!1,title:De="Connect Google Workspace",submitLabel:ke="Connect Google",defaultInstrType:W=se?"personal":"workspace",initialValues:ae={}})=>{w({visible:!0,accountId:Q,client:fe,personal:se,title:De,submitLabel:ke,defaultInstrType:W,initialValues:ae})},pe=()=>{w(Q=>({...Q,visible:!1}))},ce=async Q=>{Q?.id&&l(Q.id),await i(),Q?.id&&ue(Q.id)},ge=async({email:Q,setError:fe})=>{_(!0);try{let se=await Uh({email:Q,client:"default",personal:!1,services:wr()});if(!se.ok){fe?.(se.error||"Could not add account");return}S(!1),se.accountId&&l(se.accountId),await i(),se.accountId&&ue(se.accountId)}finally{_(!1)}},j=()=>{if(x(!1),K&&r){S(!0);return}me({client:"default",personal:!1,title:"Add Company Account",submitLabel:"Save Credentials",defaultInstrType:"workspace"})},J=()=>{x(!1),me({client:"personal",personal:!0,title:"Add Personal Account",submitLabel:"Save Credentials",defaultInstrType:"personal"})},ie=async Q=>{let fe=V(Q);if(!fe)return;let se=$c(fe),De=se?"personal":fe.client||"default",ke={};try{let W=await Vh({accountId:fe.id,client:De});W?.ok&&(ke={clientId:String(W.clientId||""),clientSecret:String(W.clientSecret||"")})}catch{I("Could not load saved client credentials","warning")}me({accountId:fe.id,client:De,personal:se,title:`Edit Credentials (${fe.email})`,submitLabel:"Save Credentials",defaultInstrType:se?"personal":"workspace",initialValues:{email:fe.email,...ke}})},de=Q=>{N({visible:!0,accountId:String(Q||"")})},be=()=>{N({visible:!1,accountId:""})},Ve=async Q=>{let fe=V(Q);if(!fe)return;let se=String(fe.client||"default").trim()||"default",De=M.get(se);if(!De?.configured||!De?.webhookExists){de(Q);return}try{(await H(Q))?.restartRequired&&e(!0),I("Gmail watch enabled","success")}catch(ke){I(ke.message||"Could not enable Gmail watch","error")}},tt=async Q=>{try{await z(Q),I("Gmail watch disabled","info")}catch(fe){I(fe.message||"Could not disable Gmail watch","error")}},kt=async({client:Q,projectId:fe,destination:se=null})=>{let De=String(D.accountId||"").trim();De&&(await G({client:Q,projectId:fe,regeneratePushToken:!1}),await H(De,{destination:se}),I("Gmail setup complete and watch enabled","success"))},Ot=()=>Os`
Google logo
- <${Z} - onClick=${V} + <${Y} + onClick=${j} tone="primary" size="sm" idleLabel="Add Company Account" className="w-full font-medium" /> - <${Z} + <${Y} onClick=${J} tone="secondary" size="sm" @@ -7104,11 +7180,11 @@ ${B?.grantPublisher||""}`.trim()))} />
- `;return Ns` + `;return Os`

Google Accounts

- ${s.length?Ns` + ${s.length?Os`
<${pt} open=${b} @@ -7116,63 +7192,63 @@ ${B?.grantPublisher||""}`.trim()))} title="Add Google account" onClose=${()=>x(!1)} onToggle=${()=>x(Q=>!Q)} - renderTrigger=${({onToggle:Q,ariaLabel:pe,title:te})=>Ns` - <${Z} + renderTrigger=${({onToggle:Q,ariaLabel:fe,title:se})=>Os` + <${Y} onClick=${Q} tone="subtle" size="sm" idleLabel="+ Add Account" - ariaLabel=${pe} - title=${te} + ariaLabel=${fe} + title=${se} /> `} > - <${We} onClick=${V}> + <${Oe} onClick=${j}> Company account - - ${se?null:Ns` - <${We} onClick=${J}> + + ${te?null:Os` + <${Oe} onClick=${J}> Personal account - + `}
`:null}
- ${o?Ns`
+ ${o?Os`
Loading... -
`:s.length?Ns` +
`:s.length?Os`
- ${s.map(Q=>Ns`<${Pw} + ${s.map(Q=>Os`<${Ew} key=${Q.id} account=${Q} personal=${$c(Q)} expanded=${a===Q.id} - onToggleExpanded=${pe=>l(te=>te===pe?"":pe)} + onToggleExpanded=${fe=>l(se=>se===fe?"":fe)} scopes=${c[Q.id]||Q.activeScopes||wr()} savedScopes=${u[Q.id]||Q.activeScopes||wr()} apiStatus=${f[Q.id]||{}} checkingApis=${a===Q.id&&!!m[Q.id]} - onToggleScope=${le} - onCheckApis=${ie} - onUpdatePermissions=${pe=>de(pe)} - onEditCredentials=${oe} - onDisconnect=${pe=>A(pe)} - gmailWatchStatus=${E.get(Q.id)||null} + onToggleScope=${re} + onCheckApis=${oe} + onUpdatePermissions=${fe=>ue(fe)} + onEditCredentials=${ie} + onDisconnect=${fe=>A(fe)} + gmailWatchStatus=${O.get(Q.id)||null} gmailWatchBusy=${!!R[Q.id]} onEnableGmailWatch=${Ve} - onDisableGmailWatch=${et} - onOpenGmailSetup=${ce} + onDisableGmailWatch=${tt} + onOpenGmailSetup=${de} onOpenGmailWebhook=${n} />`)}
`:Ot()}
- <${Mw} + <${Pw} visible=${v.visible} - onClose=${he} - onSaved=${ue} + onClose=${pe} + onSaved=${ce} title=${v.title} submitLabel=${v.submitLabel} defaultInstrType=${v.defaultInstrType} @@ -7182,21 +7258,21 @@ ${B?.grantPublisher||""}`.trim()))} initialValues=${v.initialValues} /> - <${Rw} + <${Iw} visible=${$} onClose=${()=>S(!1)} - onSubmit=${me} + onSubmit=${ge} loading=${C} title="Add Company Account" /> - <${Dw} - visible=${O.visible} - account=${j(O.accountId)} - clientConfig=${M.get(String(j(O.accountId)?.client||"default").trim()||"default")||null} - saving=${B||z} + <${Bw} + visible=${D.visible} + account=${V(D.accountId)} + clientConfig=${M.get(String(V(D.accountId)?.client||"default").trim()||"default")||null} + saving=${B||U} onClose=${be} - onSaveSetup=${U} + onSaveSetup=${G} onFinish=${kt} /> @@ -7209,19 +7285,19 @@ ${B?.grantPublisher||""}`.trim()))} onCancel=${()=>A("")} onConfirm=${async()=>{let Q=k;A(""),await ne(Q)}} /> - `};var wc=P.bind(T),N3=(t,e)=>t.find(n=>n.key===e)?.value||"",O3=(t,e)=>{for(let n of t.providers)if((Mn[n]||[]).some(r=>!!N3(e,r.key)))return{active:!0,provider:n};return{active:!1,provider:null}},Ow=({onSwitchTab:t})=>{let{data:e,loading:n}=ct("/api/env",Vr,{maxAgeMs:3e4}),s=Array.isArray(e?.vars)?e.vars:[];return n?null:wc` + `};var wc=P.bind(T),W3=(t,e)=>t.find(n=>n.key===e)?.value||"",V3=(t,e)=>{for(let n of t.providers)if((An[n]||[]).some(r=>!!W3(e,r.key)))return{active:!0,provider:n};return{active:!1,provider:null}},Hw=({onSwitchTab:t})=>{let{data:e,loading:n}=ct("/api/env",Vr,{maxAgeMs:3e4}),s=Array.isArray(e?.vars)?e.vars:[];return n?null:wc`

Features

- ${gg.map(r=>{let i=O3(r,s);return wc` + ${bg.map(r=>{let i=V3(r,s);return wc`
${r.label} ${i.active?wc` - ${zs[i.provider]||i.provider} + ${Us[i.provider]||i.provider} - <${ae} tone="success">Enabled + <${le} tone="success">Enabled `:wc` @@ -7230,27 +7306,27 @@ ${B?.grantPublisher||""}`.trim()))} onclick=${a=>{a.preventDefault(),t?.("envars")}} class="text-xs px-2 py-1 rounded-lg ac-btn-ghost" >Add provider - <${ae} tone=${r.hasDefault?"neutral":"danger"}>Disabled + <${le} tone=${r.hasDefault?"neutral":"danger"}>Disabled `}
`})}
- `};var B3=P.bind(T),Bw=({doctorStatus:t=null,dismissedUntilMs:e=0,onOpenDoctor:n=()=>{},onDismiss:s=()=>{}})=>fc(t,e)?B3` + `};var j3=P.bind(T),Ww=({doctorStatus:t=null,dismissedUntilMs:e=0,onOpenDoctor:n=()=>{},onDismiss:s=()=>{}})=>fc(t,e)?j3`

Drift Doctor

-

${rw(t)}

+

${lw(t)}

- <${Z} + <${Y} onClick=${s} tone="secondary" idleLabel="Dismiss for 1 week" /> - <${Z} + <${Y} onClick=${n} tone="warning" idleLabel="Open Drift Doctor" @@ -7258,7 +7334,7 @@ ${B?.grantPublisher||""}`.trim()))}
- `:null;var kc="0 * * * *",Fw=({statusData:t=null,watchdogData:e=null,doctorStatusData:n=null,onRefreshStatuses:s=()=>{},isActive:o=!1,restartSignal:r=0}={})=>{let[i,a]=y(!1),[l,c]=y(!1),[d,u]=y(!0),[p,f]=y(kc),[g,m]=y(!1),[h,b]=y(kc),[x,v]=y(!1),[w,$]=y(!1),[S,C]=y(!1),_=ee(null),k=t,A=e,O=n,D=k?.gateway??null,z=k?.channels??null,E=k?.repo||null,M=k?.syncCron||null,R=k?.openclawVersion||null,B=bs.some(ue=>{let me=z?.[ue];if(!me)return!1;let V=me.accounts&&typeof me.accounts=="object"?me.accounts:{};return Object.keys(V).length>0?Object.values(V).some(J=>J&&J.status!=="paired"):me.status!=="paired"}),I=Re(async()=>(await Co()).pending||[],3e3,{enabled:B&&D==="running",cacheKey:"/api/pairings"}),U=I.data||[],W=D==="running"&&(w||!S),G=Re(async()=>{let ue=await ga();return C(ue?.cliAutoApproveComplete===!0),ue.pending||[]},5e3,{enabled:W,cacheKey:"/api/devices"}),se=G.data||[];L(()=>{o&&(I.refresh(),W&&G.refresh())},[G.refresh,o,s,I.refresh,w,W]),L(()=>{if(!r||!o)return;s(),I.refresh(),W&&G.refresh();let ue=setTimeout(()=>{s(),I.refresh(),W&&G.refresh()},1200),me=setTimeout(()=>{s(),I.refresh(),W&&G.refresh()},3500);return()=>{clearTimeout(ue),clearTimeout(me)}},[G.refresh,o,s,I.refresh,r,w,W]),L(()=>{M&&(u(M.enabled!==!1),f(M.schedule||kc),b(M.enabled===!1?"disabled":M.schedule||kc))},[M?.enabled,M?.schedule]),L(()=>()=>{_.current&&clearTimeout(_.current)},[]);let K=()=>{v(!0),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{v(!1),_.current=null},2800),s(),I.refresh(),setTimeout(()=>{s(),I.refresh()},700),setTimeout(()=>{s(),I.refresh()},1800)},j=async({enabled:ue=d,schedule:me=p}={})=>{if(!g){m(!0);try{let V=await ym({enabled:ue,schedule:me});if(!V.ok)throw new Error(V.error||"Could not save sync settings");N("Sync schedule updated","success"),s()}catch(V){N(V.message||"Could not save sync settings","error")}finally{m(!1)}}};return{state:{channels:z,dashboardLoading:i,devicePending:se,doctorStatus:O,gatewayStatus:D,hasUnpaired:B,openclawVersion:R,pending:U,pairingStatusRefreshing:x,repairingWatchdog:l,repo:E,savingSyncCron:g,syncCron:M,syncCronChoice:h,syncCronEnabled:d,syncCronSchedule:p,syncCronStatusText:d?"Enabled":"Disabled",watchdogStatus:A},actions:{handleApprove:async(ue,me,V="")=>{await _o(ue,me,V),K()},handleDeviceApprove:async ue=>{await ba(ue),setTimeout(G.refresh,500),setTimeout(G.refresh,2e3)},handleDeviceReject:async ue=>{await xa(ue),setTimeout(G.refresh,500),setTimeout(G.refresh,2e3)},handleOpenDashboard:async()=>{if(!i){$(!0),a(!0);try{let ue=await hm();console.log("[dashboard] response:",JSON.stringify(ue)),window.open(ue.url||"/openclaw","_blank")}catch(ue){console.error("[dashboard] error:",ue),window.open("/openclaw","_blank")}finally{a(!1)}}},handleReject:async(ue,me,V="")=>{try{await Mo(ue,me,V),K()}catch(J){N(J.message||"Could not reject pairing","error")}},handleSyncCronChoiceChange:async ue=>{b(ue);let me=ue!=="disabled",V=me?ue:p;u(me),f(V),await j({enabled:me,schedule:V})},handleWatchdogRepair:async()=>{if(!l){c(!0);try{let ue=await ha();if(!ue.ok)throw new Error(ue.error||"Repair failed");N("Repair triggered","success"),setTimeout(()=>{s()},800)}catch(ue){N(ue.message||"Could not run repair","error")}finally{c(!1)}}}}}};var Sc=P.bind(T),Hw=({statusData:t=null,watchdogData:e=null,doctorStatusData:n=null,agents:s=[],doctorWarningDismissedUntilMs:o=0,onRefreshStatuses:r=()=>{},onSwitchTab:i=()=>{},onNavigate:a=()=>{},onOpenGmailWebhook:l=()=>{},isActive:c=!1,restartingGateway:d=!1,onRestartGateway:u=()=>{},restartSignal:p=0,openclawUpdateInProgress:f=!1,onOpenclawVersionActionComplete:g=()=>{},onOpenclawUpdate:m=()=>{},onRestartRequired:h=()=>{},onDismissDoctorWarning:b=()=>{}})=>{let{state:x,actions:v}=Fw({statusData:t,watchdogData:e,doctorStatusData:n,onRefreshStatuses:r,isActive:c,restartSignal:p});return Sc` + `:null;var kc="0 * * * *",Vw=({statusData:t=null,watchdogData:e=null,doctorStatusData:n=null,onRefreshStatuses:s=()=>{},isActive:o=!1,restartSignal:r=0}={})=>{let[i,a]=y(!1),[l,c]=y(!1),[d,u]=y(!0),[p,f]=y(kc),[g,m]=y(!1),[h,b]=y(kc),[x,v]=y(!1),[w,$]=y(!1),[S,C]=y(!1),_=ee(null),k=t,A=e,D=n,N=k?.gateway??null,U=k?.channels??null,O=k?.repo||null,M=k?.syncCron||null,R=k?.openclawVersion||null,B=xs.some(ce=>{let ge=U?.[ce];if(!ge)return!1;let j=ge.accounts&&typeof ge.accounts=="object"?ge.accounts:{};return Object.keys(j).length>0?Object.values(j).some(J=>J&&J.status!=="paired"):ge.status!=="paired"}),E=Ee(async()=>(await Co()).pending||[],3e3,{enabled:B&&N==="running",cacheKey:"/api/pairings"}),G=E.data||[],H=N==="running"&&(w||!S),z=Ee(async()=>{let ce=await ga();return C(ce?.cliAutoApproveComplete===!0),ce.pending||[]},5e3,{enabled:H,cacheKey:"/api/devices"}),te=z.data||[];L(()=>{o&&(E.refresh(),H&&z.refresh())},[z.refresh,o,s,E.refresh,w,H]),L(()=>{if(!r||!o)return;s(),E.refresh(),H&&z.refresh();let ce=setTimeout(()=>{s(),E.refresh(),H&&z.refresh()},1200),ge=setTimeout(()=>{s(),E.refresh(),H&&z.refresh()},3500);return()=>{clearTimeout(ce),clearTimeout(ge)}},[z.refresh,o,s,E.refresh,r,w,H]),L(()=>{M&&(u(M.enabled!==!1),f(M.schedule||kc),b(M.enabled===!1?"disabled":M.schedule||kc))},[M?.enabled,M?.schedule]),L(()=>()=>{_.current&&clearTimeout(_.current)},[]);let K=()=>{v(!0),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{v(!1),_.current=null},2800),s(),E.refresh(),setTimeout(()=>{s(),E.refresh()},700),setTimeout(()=>{s(),E.refresh()},1800)},V=async({enabled:ce=d,schedule:ge=p}={})=>{if(!g){m(!0);try{let j=await ym({enabled:ce,schedule:ge});if(!j.ok)throw new Error(j.error||"Could not save sync settings");I("Sync schedule updated","success"),s()}catch(j){I(j.message||"Could not save sync settings","error")}finally{m(!1)}}};return{state:{channels:U,dashboardLoading:i,devicePending:te,doctorStatus:D,gatewayStatus:N,hasUnpaired:B,openclawVersion:R,pending:G,pairingStatusRefreshing:x,repairingWatchdog:l,repo:O,savingSyncCron:g,syncCron:M,syncCronChoice:h,syncCronEnabled:d,syncCronSchedule:p,syncCronStatusText:d?"Enabled":"Disabled",watchdogStatus:A},actions:{handleApprove:async(ce,ge,j="")=>{await _o(ce,ge,j),K()},handleDeviceApprove:async ce=>{await ba(ce),setTimeout(z.refresh,500),setTimeout(z.refresh,2e3)},handleDeviceReject:async ce=>{await xa(ce),setTimeout(z.refresh,500),setTimeout(z.refresh,2e3)},handleOpenDashboard:async()=>{if(!i){$(!0),a(!0);try{let ce=await hm();console.log("[dashboard] response:",JSON.stringify(ce)),window.open(ce.url||"/openclaw","_blank")}catch(ce){console.error("[dashboard] error:",ce),window.open("/openclaw","_blank")}finally{a(!1)}}},handleReject:async(ce,ge,j="")=>{try{await Ao(ce,ge,j),K()}catch(J){I(J.message||"Could not reject pairing","error")}},handleSyncCronChoiceChange:async ce=>{b(ce);let ge=ce!=="disabled",j=ge?ce:p;u(ge),f(j),await V({enabled:ge,schedule:j})},handleWatchdogRepair:async()=>{if(!l){c(!0);try{let ce=await ha();if(!ce.ok)throw new Error(ce.error||"Repair failed");I("Repair triggered","success"),setTimeout(()=>{s()},800)}catch(ce){I(ce.message||"Could not run repair","error")}finally{c(!1)}}}}}};var Sc=P.bind(T),jw=({statusData:t=null,watchdogData:e=null,doctorStatusData:n=null,agents:s=[],doctorWarningDismissedUntilMs:o=0,onRefreshStatuses:r=()=>{},onSwitchTab:i=()=>{},onNavigate:a=()=>{},onOpenGmailWebhook:l=()=>{},isActive:c=!1,restartingGateway:d=!1,onRestartGateway:u=()=>{},restartSignal:p=0,openclawUpdateInProgress:f=!1,onOpenclawVersionActionComplete:g=()=>{},onOpenclawUpdate:m=()=>{},onRestartRequired:h=()=>{},onDismissDoctorWarning:b=()=>{}})=>{let{state:x,actions:v}=Vw({statusData:t,watchdogData:e,doctorStatusData:n,onRefreshStatuses:r,isActive:c,restartSignal:p});return Sc`
<${bc} status=${x.gatewayStatus} @@ -7273,7 +7349,7 @@ ${B?.grantPublisher||""}`.trim()))} onOpenclawVersionActionComplete=${g} onOpenclawUpdate=${m} /> - <${Bw} + <${Ww} doctorStatus=${x.doctorStatus} dismissedUntilMs=${o} onOpenDoctor=${()=>i("doctor")} @@ -7281,7 +7357,7 @@ ${B?.grantPublisher||""}`.trim()))} /> <${nl} channelsSection=${Sc` - <${Cb} + <${Mb} channels=${x.channels} agents=${s} onNavigate=${a} @@ -7299,8 +7375,8 @@ ${B?.grantPublisher||""}`.trim()))} /> `} /> - <${Ow} onSwitchTab=${i} /> - <${Nw} + <${Hw} onSwitchTab=${i} /> + <${Fw} gatewayStatus=${x.gatewayStatus} onRestartRequired=${h} onOpenGmailWebhook=${l} @@ -7370,9 +7446,9 @@ ${B?.grantPublisher||""}`.trim()))} />
- `};var F3=P.bind(T),ff=({statusData:t=null,watchdogData:e=null,doctorStatusData:n=null,agents:s=[],doctorWarningDismissedUntilMs:o=0,onRefreshStatuses:r=()=>{},onSetLocation:i=()=>{},onNavigate:a=()=>{},restartingGateway:l=!1,onRestartGateway:c=()=>{},restartSignal:d=0,openclawUpdateInProgress:u=!1,onOpenclawVersionActionComplete:p=()=>{},onOpenclawUpdate:f=()=>{},onRestartRequired:g=()=>{},onDismissDoctorWarning:m=()=>{}})=>F3` + `};var z3=P.bind(T),ff=({statusData:t=null,watchdogData:e=null,doctorStatusData:n=null,agents:s=[],doctorWarningDismissedUntilMs:o=0,onRefreshStatuses:r=()=>{},onSetLocation:i=()=>{},onNavigate:a=()=>{},restartingGateway:l=!1,onRestartGateway:c=()=>{},restartSignal:d=0,openclawUpdateInProgress:u=!1,onOpenclawVersionActionComplete:p=()=>{},onOpenclawUpdate:f=()=>{},onRestartRequired:g=()=>{},onDismissDoctorWarning:m=()=>{}})=>z3`
- <${Hw} + <${jw} statusData=${t} watchdogData=${e} doctorStatusData=${n} @@ -7393,11 +7469,11 @@ ${B?.grantPublisher||""}`.trim()))} onDismissDoctorWarning=${m} />
-`;var Nt=P.bind(T),H3={anthropic:{label:"Anthropic",modes:[{id:"api_key",label:"API Key",profileSuffix:"default",placeholder:"sk-ant-api03-...",url:"https://console.anthropic.com",field:"key"},{id:"token",label:"Setup Token",profileSuffix:"manual",placeholder:"sk-ant-oat01-...",hint:"From claude setup-token (uses your Claude subscription)",field:"token"}]},openai:{label:"OpenAI",modes:[{id:"api_key",label:"API Key",profileSuffix:"default",placeholder:"sk-...",url:"https://platform.openai.com",field:"key"}]},"openai-codex":{label:"OpenAI Codex",modes:[{id:"oauth",label:"Codex OAuth",isCodexOauth:!0}]},google:{label:"Gemini",modes:[{id:"api_key",label:"API Key",profileSuffix:"default",placeholder:"AI...",url:"https://aistudio.google.com",field:"key"}]}},W3={id:"api_key",label:"API Key",profileSuffix:"default",placeholder:"...",field:"key"},V3=t=>{let e=Mn[t]||[];return e.length===0?[W3]:e.map(n=>({id:"api_key",label:n.label||"API Key",profileSuffix:"default",placeholder:n.placeholder||"...",hint:n.hint,url:n.url,field:"key"}))},j3=t=>H3[t]||{label:zs[t]||t,modes:V3(t)},zi=(t,e)=>`${t.provider||e}:${t.profileSuffix||"default"}`,Cc=t=>String(t?.key||t?.token||t?.access||"").trim(),z3=({codexStatus:t,onRefreshCodex:e})=>{let[n,s]=y(!1),[o,r]=y(!1),[i,a]=y(""),[l,c]=y(!1),d=ee(null);L(()=>()=>{d.current&&clearInterval(d.current)},[]),L(()=>{let g=async m=>{m.data?.codex==="success"?(N("Codex connected","success"),s(!1),r(!1),await e()):m.data?.codex==="error"&&N(`Codex auth failed: ${m.data.message||"unknown error"}`,"error")};return window.addEventListener("message",g),()=>window.removeEventListener("message",g)},[e]);let u=()=>{s(!0),r(!0);let g=window.open("/auth/codex/start","codex-auth","popup=yes,width=640,height=780");if(!g||g.closed){r(!1),window.location.href="/auth/codex/start";return}d.current&&clearInterval(d.current),d.current=setInterval(()=>{g.closed&&(clearInterval(d.current),d.current=null,r(!1))},500)},p=async()=>{if(!(!i.trim()||l)){c(!0);try{let g=await Wr(i.trim());if(!g.ok)throw new Error(g.error||"Codex OAuth exchange failed");a(""),N("Codex connected","success"),s(!1),r(!1),await e()}catch(g){N(g.message||"Codex OAuth exchange failed","error")}finally{c(!1)}}},f=async()=>{let g=await Hr();if(!g.ok){N(g.error||"Failed to disconnect Codex","error");return}N("Codex disconnected","success"),s(!1),r(!1),a(""),await e()};return Nt` +`;var Nt=P.bind(T),U3={anthropic:{label:"Anthropic",modes:[{id:"api_key",label:"API Key",profileSuffix:"default",placeholder:"sk-ant-api03-...",url:"https://console.anthropic.com",field:"key"},{id:"token",label:"Setup Token",profileSuffix:"manual",placeholder:"sk-ant-oat01-...",hint:"From claude setup-token (uses your Claude subscription)",field:"token"}]},openai:{label:"OpenAI",modes:[{id:"api_key",label:"API Key",profileSuffix:"default",placeholder:"sk-...",url:"https://platform.openai.com",field:"key"}]},"openai-codex":{label:"OpenAI Codex",modes:[{id:"oauth",label:"Codex OAuth",isCodexOauth:!0}]},google:{label:"Gemini",modes:[{id:"api_key",label:"API Key",profileSuffix:"default",placeholder:"AI...",url:"https://aistudio.google.com",field:"key"}]}},K3={id:"api_key",label:"API Key",profileSuffix:"default",placeholder:"...",field:"key"},G3=t=>{let e=An[t]||[];return e.length===0?[K3]:e.map(n=>({id:"api_key",label:n.label||"API Key",profileSuffix:"default",placeholder:n.placeholder||"...",hint:n.hint,url:n.url,field:"key"}))},q3=t=>U3[t]||{label:Us[t]||t,modes:G3(t)},zi=(t,e)=>`${t.provider||e}:${t.profileSuffix||"default"}`,Cc=t=>String(t?.key||t?.token||t?.access||"").trim(),J3=({codexStatus:t,onRefreshCodex:e})=>{let[n,s]=y(!1),[o,r]=y(!1),[i,a]=y(""),[l,c]=y(!1),d=ee(null);L(()=>()=>{d.current&&clearInterval(d.current)},[]),L(()=>{let g=async m=>{m.data?.codex==="success"?(I("Codex connected","success"),s(!1),r(!1),await e()):m.data?.codex==="error"&&I(`Codex auth failed: ${m.data.message||"unknown error"}`,"error")};return window.addEventListener("message",g),()=>window.removeEventListener("message",g)},[e]);let u=()=>{s(!0),r(!0);let g=window.open("/auth/codex/start","codex-auth","popup=yes,width=640,height=780");if(!g||g.closed){r(!1),window.location.href="/auth/codex/start";return}d.current&&clearInterval(d.current),d.current=setInterval(()=>{g.closed&&(clearInterval(d.current),d.current=null,r(!1))},500)},p=async()=>{if(!(!i.trim()||l)){c(!0);try{let g=await Wr(i.trim());if(!g.ok)throw new Error(g.error||"Codex OAuth exchange failed");a(""),I("Codex connected","success"),s(!1),r(!1),await e()}catch(g){I(g.message||"Codex OAuth exchange failed","error")}finally{c(!1)}}},f=async()=>{let g=await Hr();if(!g.ok){I(g.error||"Failed to disconnect Codex","error");return}I("Codex disconnected","success"),s(!1),r(!1),a(""),await e()};return Nt`
Codex OAuth - ${t.connected?Nt`<${ae} tone="success">Connected`:Nt`<${ae} tone="warning">Not connected`} + ${t.connected?Nt`<${le} tone="success">Connected`:Nt`<${le} tone="warning">Not connected`}
${t.connected?Nt`
@@ -7448,7 +7524,7 @@ ${B?.grantPublisher||""}`.trim()))} placeholder="http://localhost:1455/auth/callback?code=...&state=..." class="w-full bg-field border border-border rounded-lg px-3 py-2 text-xs text-body outline-none focus:border-fg-muted" /> - <${Z} + <${Y} onClick=${p} disabled=${!i.trim()||l} loading=${l} @@ -7460,11 +7536,11 @@ ${B?.grantPublisher||""}`.trim()))} /> `:null}
- `},Ww=({provider:t,authProfiles:e,authOrder:n,codexStatus:s,onEditProfile:o,onEditAuthOrder:r,getProfileValue:i,getEffectiveOrder:a,onRefreshCodex:l})=>{let c=j3(t),d=c.modes.filter($=>!$.isCodexOauth),u=d.length>1,p=c.modes.some($=>$.isCodexOauth),f=a(t),g=f?.[0]||null,m=n[t]||null,h=d.some($=>{let S=zi($,t),C=e.find(k=>k.id===S)||null,_=i(S);return Cc(_)!==Cc(C)}),b=JSON.stringify(f||null)!==JSON.stringify(m),x=h||b,v=d.some($=>{let S=zi($,t),C=i(S);return!!(C?.key||C?.token||C?.access)})||t==="openai-codex"&&!!s?.connected,w=$=>{let S=zi($,t),C=d.map(k=>zi(k,t)),_=[S,...C.filter(k=>k!==S)];r(t,_)};return Nt` + `},zw=({provider:t,authProfiles:e,authOrder:n,codexStatus:s,onEditProfile:o,onEditAuthOrder:r,getProfileValue:i,getEffectiveOrder:a,onRefreshCodex:l})=>{let c=q3(t),d=c.modes.filter($=>!$.isCodexOauth),u=d.length>1,p=c.modes.some($=>$.isCodexOauth),f=a(t),g=f?.[0]||null,m=n[t]||null,h=d.some($=>{let S=zi($,t),C=e.find(k=>k.id===S)||null,_=i(S);return Cc(_)!==Cc(C)}),b=JSON.stringify(f||null)!==JSON.stringify(m),x=h||b,v=d.some($=>{let S=zi($,t),C=i(S);return!!(C?.key||C?.token||C?.access)})||t==="openai-codex"&&!!s?.connected,w=$=>{let S=zi($,t),C=d.map(k=>zi(k,t)),_=[S,...C.filter(k=>k!==S)];r(t,_)};return Nt`

${c.label}

- ${p&&d.length===0?null:x?Nt`<${ae} tone="warning">Unsaved`:v?Nt`<${ae} tone="success">Connected`:Nt`<${ae} tone="warning">Not configured`} + ${p&&d.length===0?null:x?Nt`<${le} tone="warning">Unsaved`:v?Nt`<${le} tone="success">Connected`:Nt`<${le} tone="warning">Not configured`}
${d.map($=>{let S=zi($,t),C=$.provider||t,_=i(S),k=_?.[$.field]||"",A=!u||g===S||!g&&$===d[0];return Nt`
@@ -7472,7 +7548,7 @@ ${B?.grantPublisher||""}`.trim()))} - ${u&&A?Nt`<${ae} tone="cyan">Primary`:null} + ${u&&A?Nt`<${le} tone="cyan">Primary`:null} ${u&&!A&&k?Nt`
<${Rt} value=${k} - onInput=${O=>{let D=O.target.value,z={type:$.id,provider:C,[$.field]:D};_?.expires&&(z.expires=_.expires),o(S,z);let E=e.find(R=>R.id===S)||null;Cc(z)===Cc(E)&&u?r(t,m):u&&D&&!A&&w($)}} + onInput=${D=>{let N=D.target.value,U={type:$.id,provider:C,[$.field]:N};_?.expires&&(U.expires=_.expires),o(S,U);let O=e.find(R=>R.id===S)||null;Cc(U)===Cc(O)&&u?r(t,m):u&&N&&!A&&w($)}} placeholder=${$.placeholder||""} isSecret=${!0} inputClass="flex-1 w-full bg-field border border-border rounded-lg px-3 py-2 text-sm text-body outline-none focus:border-fg-muted font-mono" @@ -7499,16 +7575,16 @@ ${B?.grantPublisher||""}`.trim()))} `})} ${c.modes.some($=>$.isCodexOauth)?Nt`
- <${z3} + <${J3} codexStatus=${s} onRefreshCodex=${l} />
`:null}
- `};var Mt=P.bind(T),U3=t=>{let e=new Set;for(let n of Object.keys(t)){let s=ri(n);s&&e.add(s)}return[...e]},K3=["anthropic","openai","openai-codex",...jr.filter(t=>!["anthropic","openai"].includes(t))],Vw=({onRestartRequired:t=()=>{},agentId:e,embedded:n=!1})=>{let{catalog:s,primary:o,configuredModels:r,authProfiles:i,authOrder:a,codexStatus:l,loading:c,saving:d,ready:u,error:p,isDirty:f,addModel:g,removeModel:m,setPrimaryModel:h,editProfile:b,editAuthOrder:x,getProfileValue:v,getEffectiveOrder:w,cancelChanges:$,saveAll:S,refreshCodexStatus:C}=rl(e),_=F(()=>new Set(Object.keys(r)),[r]),k=F(()=>Lo(s),[s]),A=F(()=>k.filter(I=>!_.has(I.key)),[k,_]),O=F(()=>[...s].filter(I=>!_.has(I.key)).sort((I,U)=>{let W=jo(vs(I))-jo(vs(U));return W!==0?W:String(I.label||I.key).localeCompare(String(U.label||U.key))}),[s,_]),D=F(()=>U3(r),[r]),z=F(()=>{let I=[];for(let U of K3)D.includes(U)&&I.push(U);for(let U of D)I.includes(U)||I.push(U);return I},[D]),E=F(()=>sl({authProfiles:i,codexStatus:l}),[i,l]),M=F(()=>Object.keys(r).map(I=>{let U=s.find(se=>se.key===I),W=ri(I),G=!!E[W];return{key:I,label:U?.label||I,isPrimary:I===o,hasAuth:G}}),[r,s,o,E]),R=Mt` - <${Qn} visible=${f}> - <${Z} + `};var At=P.bind(T),Z3=t=>{let e=new Set;for(let n of Object.keys(t)){let s=ri(n);s&&e.add(s)}return[...e]},Y3=["anthropic","openai","openai-codex",...jr.filter(t=>!["anthropic","openai"].includes(t))],Uw=({onRestartRequired:t=()=>{},agentId:e,embedded:n=!1})=>{let{catalog:s,primary:o,configuredModels:r,authProfiles:i,authOrder:a,codexStatus:l,loading:c,saving:d,ready:u,error:p,isDirty:f,addModel:g,removeModel:m,setPrimaryModel:h,editProfile:b,editAuthOrder:x,getProfileValue:v,getEffectiveOrder:w,cancelChanges:$,saveAll:S,refreshCodexStatus:C}=rl(e),_=F(()=>new Set(Object.keys(r)),[r]),k=F(()=>Lo(s),[s]),A=F(()=>k.filter(E=>!_.has(E.key)),[k,_]),D=F(()=>[...s].filter(E=>!_.has(E.key)).sort((E,G)=>{let H=jo($s(E))-jo($s(G));return H!==0?H:String(E.label||E.key).localeCompare(String(G.label||G.key))}),[s,_]),N=F(()=>Z3(r),[r]),U=F(()=>{let E=[];for(let G of Y3)N.includes(G)&&E.push(G);for(let G of N)E.includes(G)||E.push(G);return E},[N]),O=F(()=>sl({authProfiles:i,codexStatus:l}),[i,l]),M=F(()=>Object.keys(r).map(E=>{let G=s.find(te=>te.key===E),H=ri(E),z=!!O[H];return{key:E,label:G?.label||E,isPrimary:E===o,hasAuth:z}}),[r,s,o,O]),R=At` + <${es} visible=${f}> + <${Y} onClick=${$} disabled=${d} tone="secondary" @@ -7516,7 +7592,7 @@ ${B?.grantPublisher||""}`.trim()))} idleLabel="Cancel" className="text-xs" /> - <${Z} + <${Y} onClick=${S} disabled=${d} loading=${d} @@ -7527,48 +7603,48 @@ ${B?.grantPublisher||""}`.trim()))} loadingLabel="Saving…" className="text-xs" /> - - `;if(!u){let I=Mt` + + `;if(!u){let E=At`
<${Ce} className="h-4 w-4" /> Loading model settings...
- `;return n?I:Mt` - <${zn} - header=${Mt`<${Ne} title="Models" />`} + `;return n?E:At` + <${Un} + header=${At`<${Pe} title="Models" />`} > - ${I} - - `}let B=Mt` + ${E} + + `}let B=At`

Available Models

- ${M.length===0?Mt`

+ ${M.length===0?At`

No models configured. Add a model below. -

`:Mt` +

`:At`
- ${M.map(I=>Mt` + ${M.map(E=>At`
${I.label}${E.label} - ${I.isPrimary?Mt`<${ae} tone="cyan">Primary`:I.hasAuth?Mt` + ${E.isPrimary?At`<${le} tone="cyan">Primary`:E.hasAuth?At` - `:Mt`<${ae} tone="warning">Needs auth`} + `:At`<${le} tone="warning">Needs auth`}
- ${z.length>0?Mt` + ${U.length>0?At`

Provider Authentication

- ${z.map(I=>Mt` - <${Ww} - provider=${I} + ${U.map(E=>At` + <${zw} + provider=${E} authProfiles=${i} authOrder=${a} codexStatus=${l} @@ -7613,22 +7689,22 @@ ${B?.grantPublisher||""}`.trim()))} `)}
`:null} - `;return n?Mt` + `;return n?At`
${R}
${B}
- `:Mt` - <${zn} - header=${Mt`<${Ne} title="Models" actions=${R} />`} + `:At` + <${Un} + header=${At`<${Pe} title="Models" actions=${R} />`} > ${B} - - `};var G3=P.bind(T),hf=({onRestartRequired:t=()=>{}})=>G3` - <${Vw} onRestartRequired=${t} /> -`;var q3=1e4,jw=({enabled:t=!0}={})=>{let e=Re(async()=>{let n=await Pm(),s=Array.isArray(n?.nodes)?n.nodes:[],o=Array.isArray(n?.pending)?n.pending:[];return{nodes:s,pending:o}},q3,{enabled:t,cacheKey:"/api/nodes"});return{nodes:Array.isArray(e.data?.nodes)?e.data.nodes:[],pending:Array.isArray(e.data?.pending)?e.data.pending:[],loading:e.data===null&&!e.error,error:e.error?String(e.error.message||"Could not load nodes"):"",refresh:e.refresh}};var zw=()=>{let t=jw({enabled:!0}),[e,n]=y(!1),[s,o]=y(!1),{data:r,error:i}=ct("/api/nodes/connect-info",ya,{maxAgeMs:6e4}),a=Array.isArray(t.nodes)?t.nodes.filter(c=>c?.paired!==!1):[];L(()=>{i&&N(i.message||"Could not load node connect command","error")},[i]);let l=q(async()=>{if(!s){o(!0);try{await t.refresh()}finally{o(!1)}}},[t.refresh,s]);return{state:{wizardVisible:e,nodes:a,pending:t.pending,loadingNodes:t.loading,refreshingNodes:s,nodesError:t.error,connectInfo:r},actions:{openWizard:()=>n(!0),closeWizard:()=>n(!1),refreshNodes:l}}};var J3=35e3,Z3=1e4,Kw="nodesBrowserAttachStateByNode",Y3=/selected page has been closed/i,X3=async(t,e=J3)=>{let n=null;try{return await Promise.race([t,new Promise((s,o)=>{n=setTimeout(()=>{o(new Error("Browser check timed out"))},e)})])}finally{n&&clearTimeout(n)}},Uw=t=>{let e=Array.isArray(t?.caps)?t.caps:[],n=Array.isArray(t?.commands)?t.commands:[];return e.includes("browser")||n.includes("browser.proxy")},Q3=t=>{let e=String(t?.message||"Could not check node browser status").trim();return Y3.test(e)?"Selected Chrome page was closed. Click Attach to reconnect.":e},eR=()=>{let e=Fe()?.[Kw];return!e||typeof e!="object"||Array.isArray(e)?{}:e},tR=(t={})=>{vx(e=>({...e&&typeof e=="object"?e:{},[Kw]:t&&typeof t=="object"?t:{}}))},Gw=({nodes:t=[],onRefreshNodes:e=async()=>{}}={})=>{let[n,s]=y({}),[o,r]=y({}),[i,a]=y(""),[l,c]=y(()=>eR()),[d,u]=y(""),[p,f]=y(null),[g,m]=y(""),h=ee(0),b=ee(""),x=async(k,{successMessage:A="Connection command copied",errorMessage:O="Could not copy connection command"}={})=>{if(await Ho(k)){N(A,"success");return}N(O,"error")},v=q(async(k,{silent:A=!1}={})=>{let O=String(k||"").trim();if(!(!O||b.current)){b.current=O,A||a(O),r(D=>({...D,[O]:""}));try{let D=await X3(Em(O,"user")),z=D?.status&&typeof D.status=="object"?D.status:null;s(E=>({...E,[O]:z}))}catch(D){let z=Q3(D);s(E=>({...E,[O]:null})),r(E=>({...E,[O]:z})),A||N(z,"error")}finally{b.current="",A||a("")}}},[]),w=q((k,A)=>{let O=String(k||"").trim();O&&c(D=>{let z={...D&&typeof D=="object"?D:{},[O]:A===!0};return tR(z),z})},[]),$=q(async k=>{let A=String(k||"").trim();A&&(w(A,!0),await v(A))},[v,w]),S=q(k=>{let A=String(k||"").trim();A&&(w(A,!1),s(O=>{let D={...O||{}};return delete D[A],D}),r(O=>{let D={...O||{}};return delete D[A],D}))},[w]),C=q(k=>{let A=String(k||"").trim();A&&u(O=>O===A?"":A)},[]),_=q(async()=>{let k=String(p?.nodeId||"").trim();if(!(!k||g)){m(k);try{await Rm(k),S(k),N("Device removed","success"),f(null),u(""),await e()}catch(A){N(A.message||"Could not remove node","error")}finally{m("")}}},[S,e,p,g]);return L(()=>{if(i)return;let k=t.map(A=>({nodeId:String(A?.nodeId||"").trim(),connected:A?.connected===!0,browserCapable:Uw(A)})).find(A=>!(!A.nodeId||!A.connected||!A.browserCapable||l?.[A.nodeId]!==!0||n?.[A.nodeId]||o?.[A.nodeId]))?.nodeId;k&&v(k,{silent:!0})},[l,o,n,i,v,t]),L(()=>{if(i)return;let k=t.map(z=>({nodeId:String(z?.nodeId||"").trim(),connected:z?.connected===!0,browserCapable:Uw(z),browserRunning:n?.[String(z?.nodeId||"").trim()]?.running===!0})).filter(z=>z.nodeId&&z.connected&&z.browserCapable&&l?.[z.nodeId]===!0&&z.browserRunning).map(z=>z.nodeId);if(!k.length)return;let A=!0,D=setInterval(async()=>{if(!A||b.current)return;let z=h.current%k.length;h.current+=1;let E=k[z];await v(E,{silent:!0})},Z3);return()=>{A=!1,clearInterval(D)}},[l,n,i,v,t]),{browserStatusByNodeId:n,browserErrorByNodeId:o,checkingBrowserNodeId:i,browserAttachStateByNodeId:l,menuOpenNodeId:d,removeDialogNode:p,removingNodeId:g,handleCopyText:x,handleCheckNodeBrowser:v,handleAttachNodeBrowser:$,handleDetachNodeBrowser:S,handleOpenNodeMenu:C,handleRemoveNode:_,setMenuOpenNodeId:u,setRemoveDialogNode:f}};var ot=P.bind(T),nR=t=>String(t||"").replace(/"/g,'\\"'),qw=({node:t,connectInfo:e,maskToken:n=!1})=>{let s=String(e?.gatewayHost||"").trim()||"localhost",o=Number(e?.gatewayPort)||3e3,r=String(e?.gatewayToken||"").trim(),i=e?.tls===!0?"--tls":"",a=String(t?.displayName||t?.nodeId||"My Node").trim(),l=n?"****":r;return[l?`OPENCLAW_GATEWAY_TOKEN=${l}`:"","openclaw node run",`--host ${s}`,`--port ${o}`,i,`--display-name "${nR(a)}"`].filter(Boolean).join(" ")},sR=t=>t?.connected?ot`<${ae} tone="success">Connected`:t?.paired?ot`<${ae} tone="warning">Disconnected`:ot`<${ae} tone="danger">Pending approval`,oR=t=>{let e=Array.isArray(t?.caps)?t.caps:[],n=Array.isArray(t?.commands)?t.commands:[];return e.includes("browser")||n.includes("browser.proxy")},rR=t=>t.running?"success":"warning",iR=t=>t.running?"Attached":"Not connected",Jw=({nodes:t=[],pending:e=[],loading:n=!1,error:s="",connectInfo:o=null,onRefreshNodes:r=async()=>{}})=>{let i=Gw({nodes:t,onRefreshNodes:r}),{browserStatusByNodeId:a,browserErrorByNodeId:l,checkingBrowserNodeId:c,browserAttachStateByNodeId:d,menuOpenNodeId:u,removeDialogNode:p,removingNodeId:f,handleCopyText:g,handleCheckNodeBrowser:m,handleAttachNodeBrowser:h,handleDetachNodeBrowser:b,handleOpenNodeMenu:x,handleRemoveNode:v,setMenuOpenNodeId:w,setRemoveDialogNode:$}=i;return ot` + + `};var X3=P.bind(T),hf=({onRestartRequired:t=()=>{}})=>X3` + <${Uw} onRestartRequired=${t} /> +`;var Q3=1e4,Kw=({enabled:t=!0}={})=>{let e=Ee(async()=>{let n=await Pm(),s=Array.isArray(n?.nodes)?n.nodes:[],o=Array.isArray(n?.pending)?n.pending:[];return{nodes:s,pending:o}},Q3,{enabled:t,cacheKey:"/api/nodes"});return{nodes:Array.isArray(e.data?.nodes)?e.data.nodes:[],pending:Array.isArray(e.data?.pending)?e.data.pending:[],loading:e.data===null&&!e.error,error:e.error?String(e.error.message||"Could not load nodes"):"",refresh:e.refresh}};var Gw=()=>{let t=Kw({enabled:!0}),[e,n]=y(!1),[s,o]=y(!1),{data:r,error:i}=ct("/api/nodes/connect-info",ya,{maxAgeMs:6e4}),a=Array.isArray(t.nodes)?t.nodes.filter(c=>c?.paired!==!1):[];L(()=>{i&&I(i.message||"Could not load node connect command","error")},[i]);let l=q(async()=>{if(!s){o(!0);try{await t.refresh()}finally{o(!1)}}},[t.refresh,s]);return{state:{wizardVisible:e,nodes:a,pending:t.pending,loadingNodes:t.loading,refreshingNodes:s,nodesError:t.error,connectInfo:r},actions:{openWizard:()=>n(!0),closeWizard:()=>n(!1),refreshNodes:l}}};var eR=35e3,tR=1e4,Jw="nodesBrowserAttachStateByNode",nR=/selected page has been closed/i,sR=async(t,e=eR)=>{let n=null;try{return await Promise.race([t,new Promise((s,o)=>{n=setTimeout(()=>{o(new Error("Browser check timed out"))},e)})])}finally{n&&clearTimeout(n)}},qw=t=>{let e=Array.isArray(t?.caps)?t.caps:[],n=Array.isArray(t?.commands)?t.commands:[];return e.includes("browser")||n.includes("browser.proxy")},oR=t=>{let e=String(t?.message||"Could not check node browser status").trim();return nR.test(e)?"Selected Chrome page was closed. Click Attach to reconnect.":e},rR=()=>{let e=He()?.[Jw];return!e||typeof e!="object"||Array.isArray(e)?{}:e},iR=(t={})=>{kx(e=>({...e&&typeof e=="object"?e:{},[Jw]:t&&typeof t=="object"?t:{}}))},Zw=({nodes:t=[],onRefreshNodes:e=async()=>{}}={})=>{let[n,s]=y({}),[o,r]=y({}),[i,a]=y(""),[l,c]=y(()=>rR()),[d,u]=y(""),[p,f]=y(null),[g,m]=y(""),h=ee(0),b=ee(""),x=async(k,{successMessage:A="Connection command copied",errorMessage:D="Could not copy connection command"}={})=>{if(await Ho(k)){I(A,"success");return}I(D,"error")},v=q(async(k,{silent:A=!1}={})=>{let D=String(k||"").trim();if(!(!D||b.current)){b.current=D,A||a(D),r(N=>({...N,[D]:""}));try{let N=await sR(Em(D,"user")),U=N?.status&&typeof N.status=="object"?N.status:null;s(O=>({...O,[D]:U}))}catch(N){let U=oR(N);s(O=>({...O,[D]:null})),r(O=>({...O,[D]:U})),A||I(U,"error")}finally{b.current="",A||a("")}}},[]),w=q((k,A)=>{let D=String(k||"").trim();D&&c(N=>{let U={...N&&typeof N=="object"?N:{},[D]:A===!0};return iR(U),U})},[]),$=q(async k=>{let A=String(k||"").trim();A&&(w(A,!0),await v(A))},[v,w]),S=q(k=>{let A=String(k||"").trim();A&&(w(A,!1),s(D=>{let N={...D||{}};return delete N[A],N}),r(D=>{let N={...D||{}};return delete N[A],N}))},[w]),C=q(k=>{let A=String(k||"").trim();A&&u(D=>D===A?"":A)},[]),_=q(async()=>{let k=String(p?.nodeId||"").trim();if(!(!k||g)){m(k);try{await Rm(k),S(k),I("Device removed","success"),f(null),u(""),await e()}catch(A){I(A.message||"Could not remove node","error")}finally{m("")}}},[S,e,p,g]);return L(()=>{if(i)return;let k=t.map(A=>({nodeId:String(A?.nodeId||"").trim(),connected:A?.connected===!0,browserCapable:qw(A)})).find(A=>!(!A.nodeId||!A.connected||!A.browserCapable||l?.[A.nodeId]!==!0||n?.[A.nodeId]||o?.[A.nodeId]))?.nodeId;k&&v(k,{silent:!0})},[l,o,n,i,v,t]),L(()=>{if(i)return;let k=t.map(U=>({nodeId:String(U?.nodeId||"").trim(),connected:U?.connected===!0,browserCapable:qw(U),browserRunning:n?.[String(U?.nodeId||"").trim()]?.running===!0})).filter(U=>U.nodeId&&U.connected&&U.browserCapable&&l?.[U.nodeId]===!0&&U.browserRunning).map(U=>U.nodeId);if(!k.length)return;let A=!0,N=setInterval(async()=>{if(!A||b.current)return;let U=h.current%k.length;h.current+=1;let O=k[U];await v(O,{silent:!0})},tR);return()=>{A=!1,clearInterval(N)}},[l,n,i,v,t]),{browserStatusByNodeId:n,browserErrorByNodeId:o,checkingBrowserNodeId:i,browserAttachStateByNodeId:l,menuOpenNodeId:d,removeDialogNode:p,removingNodeId:g,handleCopyText:x,handleCheckNodeBrowser:v,handleAttachNodeBrowser:$,handleDetachNodeBrowser:S,handleOpenNodeMenu:C,handleRemoveNode:_,setMenuOpenNodeId:u,setRemoveDialogNode:f}};var ot=P.bind(T),aR=t=>String(t||"").replace(/"/g,'\\"'),Yw=({node:t,connectInfo:e,maskToken:n=!1})=>{let s=String(e?.gatewayHost||"").trim()||"localhost",o=Number(e?.gatewayPort)||3e3,r=String(e?.gatewayToken||"").trim(),i=e?.tls===!0?"--tls":"",a=String(t?.displayName||t?.nodeId||"My Node").trim(),l=n?"****":r;return[l?`OPENCLAW_GATEWAY_TOKEN=${l}`:"","openclaw node run",`--host ${s}`,`--port ${o}`,i,`--display-name "${aR(a)}"`].filter(Boolean).join(" ")},lR=t=>t?.connected?ot`<${le} tone="success">Connected`:t?.paired?ot`<${le} tone="warning">Disconnected`:ot`<${le} tone="danger">Pending approval`,cR=t=>{let e=Array.isArray(t?.caps)?t.caps:[],n=Array.isArray(t?.commands)?t.commands:[];return e.includes("browser")||n.includes("browser.proxy")},dR=t=>t.running?"success":"warning",uR=t=>t.running?"Attached":"Not connected",Xw=({nodes:t=[],pending:e=[],loading:n=!1,error:s="",connectInfo:o=null,onRefreshNodes:r=async()=>{}})=>{let i=Zw({nodes:t,onRefreshNodes:r}),{browserStatusByNodeId:a,browserErrorByNodeId:l,checkingBrowserNodeId:c,browserAttachStateByNodeId:d,menuOpenNodeId:u,removeDialogNode:p,removingNodeId:f,handleCopyText:g,handleCheckNodeBrowser:m,handleAttachNodeBrowser:h,handleDetachNodeBrowser:b,handleOpenNodeMenu:x,handleRemoveNode:v,setMenuOpenNodeId:w,setRemoveDialogNode:$}=i;return ot`
${e.length?ot`
`:t.length?ot`
- ${t.map(S=>{let C=String(S?.nodeId||"").trim(),_=a[C]||null,k=l[C]||"",A=c===C,O=S?.connected&&oR(S)&&C,D=d?.[C]===!0,z=!!_||!!k,E=_?.running===!0,M=D&&!z&&!A,R=O&&D&&!A&&z&&!E;return ot` + ${t.map(S=>{let C=String(S?.nodeId||"").trim(),_=a[C]||null,k=l[C]||"",A=c===C,D=S?.connected&&cR(S)&&C,N=d?.[C]===!0,U=!!_||!!k,O=_?.running===!0,M=N&&!U&&!A,R=D&&N&&!A&&U&&!O;return ot`
@@ -7669,7 +7745,7 @@ ${B?.grantPublisher||""}`.trim()))} class="shrink-0 inline-flex items-center gap-1 text-[11px] text-fg-muted hover:text-body" onclick=${()=>g(C,{successMessage:"Device ID copied",errorMessage:"Could not copy device ID"})} > - <${Us} + <${Ks} className="w-3.5 h-3.5" /> Copy device id @@ -7678,7 +7754,7 @@ ${B?.grantPublisher||""}`.trim()))}
- ${sR(S)} + ${lR(S)} ${S?.paired?ot` <${pt} open=${u===C} @@ -7687,12 +7763,12 @@ ${B?.grantPublisher||""}`.trim()))} onClose=${()=>w("")} onToggle=${()=>x(C)} > - <${We} + <${Oe} className="text-status-error hover:text-status-error" onClick=${()=>{w(""),$(S)}} > Remove device - + `:null}
@@ -7713,7 +7789,7 @@ ${B?.grantPublisher||""}`.trim()))} >
- ${O?ot` + ${D?ot`
Browser
- ${D?ot` + ${N?ot`
@@ -7746,8 +7822,8 @@ ${B?.grantPublisher||""}`.trim()))}
${_?ot` - <${ae} tone=${rR(_)} - >${iR(_)}${uR(_)} `:null} @@ -7761,8 +7837,8 @@ ${B?.grantPublisher||""}`.trim()))} className="h-3.5 w-3.5" /> `:null} - ${O&&!D?ot` - <${Z} + ${D&&!N?ot` + <${Y} onClick=${()=>h(C)} idleLabel="Attach" tone="primary" @@ -7770,14 +7846,14 @@ ${B?.grantPublisher||""}`.trim()))} /> `:null} ${R?ot` - <${Z} + <${Y} onClick=${()=>m(C)} idleLabel="Check" tone="secondary" size="sm" /> `:null} - ${O&&D&&!A?ot` + ${D&&N&&!A?ot`
- `};var Yw=3e3,Xw=({visible:t=!1,nodes:e=[],refreshNodes:n=async()=>{},onRestartRequired:s=()=>{},onClose:o=()=>{}}={})=>{let[r,i]=y(0),[a,l]=y(null),[c,d]=y(!1),[u,p]=y("My Mac Node"),[f,g]=y(""),[m,h]=y(!1),[b,x]=y([]),[v,w]=y(!1),$=ee(!1);L(()=>{t&&(i(0),g(""),h(!1),w(!1))},[t]),L(()=>{t&&(d(!0),ya().then(E=>{l(E||null)}).catch(E=>{N(E.message||"Could not load node connect command","error")}).finally(()=>{d(!1)}))},[t]);let S=F(()=>{let E=new Set,M=[];for(let R of e){let B=String(R?.nodeId||"").trim();!B||E.has(B)||R?.paired!==!1&&(E.add(B),M.push({nodeId:B,displayName:String(R?.displayName||R?.name||B),connected:R?.connected===!0}))}return M},[e]),C=F(()=>S.find(E=>E.nodeId===String(f||"").trim())||null,[S,f]),_=F(()=>{if(!a)return"";let E=String(a.gatewayHost||"").trim()||"localhost",M=Number(a.gatewayPort)||3e3,R=String(a.gatewayToken||"").trim(),B=a.tls===!0?" --tls":"",I=String(u||"").trim().replace(/"/g,'\\"');return[R?`OPENCLAW_GATEWAY_TOKEN=${R}`:"","openclaw node run",`--host ${E}`,`--port ${M}`,B.trim(),I?`--display-name "${I}"`:""].filter(Boolean).join(" ")},[a,u]),k=q(async()=>{if(!$.current){$.current=!0;try{await n();let E=await ga(),M=Array.isArray(E?.pending)?E.pending:[];x(M)}finally{$.current=!1}}},[n]);L(()=>{if(!t||r!==1)return;let E=!0,M=async()=>{if(E)try{await k()}catch{}};M();let R=setInterval(M,Yw);return()=>{E=!1,clearInterval(R)}},[k,r,t]),L(()=>{if(!t||r!==1)return;let E=S.some(B=>B.nodeId===String(f||"").trim()),M=String(u||"").trim().toLowerCase(),R=S.find(B=>String(B?.displayName||"").trim().toLowerCase()===M)||S[0];R&&(E&&String(f||"").trim()===R.nodeId||g(R.nodeId))},[u,S,f,r,t]);let A=q(async E=>{try{await ba(E),N("Pairing approved","success"),w(!0),await k()}catch(M){N(M.message||"Could not approve pairing","error")}},[k]),O=q(async E=>{try{await xa(E),N("Pairing rejected","info"),await k()}catch(M){N(M.message||"Could not reject pairing","error")}},[k]),D=q(async()=>{let E=String(f||"").trim();if(!E||m)return!1;h(!0);try{return await Lm(E),s(!0),N("Gateway routing now points to the selected node","success"),!0}catch(M){return N(M.message||"Could not configure gateway node routing","error"),!1}finally{h(!1)}},[m,s,f]),z=q(()=>{o()},[o]);return{step:r,setStep:i,connectInfo:a,loadingConnectInfo:c,displayName:u,setDisplayName:p,selectedNodeId:f,setSelectedNodeId:g,pairedNodes:S,selectedPairedNode:C,devicePending:b,approvedInSession:v,configuring:m,canFinish:v&&!!C?.connected,connectCommand:_,refreshNodeList:k,nodeDiscoveryPollIntervalMs:Yw,handleDeviceApprove:A,handleDeviceReject:O,applyGatewayNodeRouting:D,completeWizard:z}};var an=P.bind(T),Ui=["Install OpenClaw CLI","Connect Node"],Qw=({command:t="",onCopy:e=()=>{}})=>an` + `};var e1=3e3,t1=({visible:t=!1,nodes:e=[],refreshNodes:n=async()=>{},onRestartRequired:s=()=>{},onClose:o=()=>{}}={})=>{let[r,i]=y(0),[a,l]=y(null),[c,d]=y(!1),[u,p]=y("My Mac Node"),[f,g]=y(""),[m,h]=y(!1),[b,x]=y([]),[v,w]=y(!1),$=ee(!1);L(()=>{t&&(i(0),g(""),h(!1),w(!1))},[t]),L(()=>{t&&(d(!0),ya().then(O=>{l(O||null)}).catch(O=>{I(O.message||"Could not load node connect command","error")}).finally(()=>{d(!1)}))},[t]);let S=F(()=>{let O=new Set,M=[];for(let R of e){let B=String(R?.nodeId||"").trim();!B||O.has(B)||R?.paired!==!1&&(O.add(B),M.push({nodeId:B,displayName:String(R?.displayName||R?.name||B),connected:R?.connected===!0}))}return M},[e]),C=F(()=>S.find(O=>O.nodeId===String(f||"").trim())||null,[S,f]),_=F(()=>{if(!a)return"";let O=String(a.gatewayHost||"").trim()||"localhost",M=Number(a.gatewayPort)||3e3,R=String(a.gatewayToken||"").trim(),B=a.tls===!0?" --tls":"",E=String(u||"").trim().replace(/"/g,'\\"');return[R?`OPENCLAW_GATEWAY_TOKEN=${R}`:"","openclaw node run",`--host ${O}`,`--port ${M}`,B.trim(),E?`--display-name "${E}"`:""].filter(Boolean).join(" ")},[a,u]),k=q(async()=>{if(!$.current){$.current=!0;try{await n();let O=await ga(),M=Array.isArray(O?.pending)?O.pending:[];x(M)}finally{$.current=!1}}},[n]);L(()=>{if(!t||r!==1)return;let O=!0,M=async()=>{if(O)try{await k()}catch{}};M();let R=setInterval(M,e1);return()=>{O=!1,clearInterval(R)}},[k,r,t]),L(()=>{if(!t||r!==1)return;let O=S.some(B=>B.nodeId===String(f||"").trim()),M=String(u||"").trim().toLowerCase(),R=S.find(B=>String(B?.displayName||"").trim().toLowerCase()===M)||S[0];R&&(O&&String(f||"").trim()===R.nodeId||g(R.nodeId))},[u,S,f,r,t]);let A=q(async O=>{try{await ba(O),I("Pairing approved","success"),w(!0),await k()}catch(M){I(M.message||"Could not approve pairing","error")}},[k]),D=q(async O=>{try{await xa(O),I("Pairing rejected","info"),await k()}catch(M){I(M.message||"Could not reject pairing","error")}},[k]),N=q(async()=>{let O=String(f||"").trim();if(!O||m)return!1;h(!0);try{return await Lm(O),s(!0),I("Gateway routing now points to the selected node","success"),!0}catch(M){return I(M.message||"Could not configure gateway node routing","error"),!1}finally{h(!1)}},[m,s,f]),U=q(()=>{o()},[o]);return{step:r,setStep:i,connectInfo:a,loadingConnectInfo:c,displayName:u,setDisplayName:p,selectedNodeId:f,setSelectedNodeId:g,pairedNodes:S,selectedPairedNode:C,devicePending:b,approvedInSession:v,configuring:m,canFinish:v&&!!C?.connected,connectCommand:_,refreshNodeList:k,nodeDiscoveryPollIntervalMs:e1,handleDeviceApprove:A,handleDeviceReject:D,applyGatewayNodeRouting:N,completeWizard:U}};var an=P.bind(T),Ui=["Install OpenClaw CLI","Connect Node"],n1=({command:t="",onCopy:e=()=>{}})=>an`
-        <${Us} className="w-3.5 h-3.5" />
+        <${Ks} className="w-3.5 h-3.5" />
         Copy
       
     
-`,e1=async(t,e="text")=>{if(await Ho(t)){N("Copied to clipboard","success");return}N(`Could not copy ${e}`,"error")},t1=({visible:t=!1,nodes:e=[],refreshNodes:n=async()=>{},onRestartRequired:s=()=>{},onClose:o=()=>{}})=>{let r=Xw({visible:t,nodes:e,refreshNodes:n,onRestartRequired:s,onClose:o}),i=r.step===Ui.length-1;return an` - <${De} +`,s1=async(t,e="text")=>{if(await Ho(t)){I("Copied to clipboard","success");return}I(`Could not copy ${e}`,"error")},o1=({visible:t=!1,nodes:e=[],refreshNodes:n=async()=>{},onRestartRequired:s=()=>{},onClose:o=()=>{}})=>{let r=t1({visible:t,nodes:e,refreshNodes:n,onRestartRequired:s,onClose:o}),i=r.step===Ui.length-1;return an` + <${Te} visible=${t} onClose=${o} closeOnOverlayClick=${!1} @@ -7963,7 +8039,7 @@ ${t} - <${nt} className="w-3.5 h-3.5 text-body" /> + <${Ze} className="w-3.5 h-3.5 text-body" />
Node Setup Wizard
@@ -7983,7 +8059,7 @@ ${t} Install OpenClaw on the machine you want to connect as a node.
- ${Qw({command:"npm install -g openclaw",onCopy:()=>e1("npm install -g openclaw","command")})} + ${n1({command:"npm install -g openclaw",onCopy:()=>s1("npm install -g openclaw","command")})}
Requires Node.js 22+.
`:null} @@ -8005,7 +8081,7 @@ ${t} ${r.loadingConnectInfo?an`
Loading command... -
`:Qw({command:r.connectCommand||"Could not build connect command.",onCopy:()=>e1(r.connectCommand||"","command")})} +
`:n1({command:r.connectCommand||"Could not build connect command.",onCopy:()=>s1(r.connectCommand||"","command")})}
${r.devicePending.length?an` <${xc} @@ -8033,7 +8109,7 @@ ${t} ${r.step===0?an`
`:an` - <${Z} + <${Y} onClick=${()=>r.setStep(Math.max(0,r.step-1))} idleLabel="Back" tone="secondary" @@ -8042,7 +8118,7 @@ ${t} `} ${i?an` - <${Z} + <${Y} onClick=${async()=>{await r.applyGatewayNodeRouting()&&(r.completeWizard(),Promise.resolve(n()).catch(()=>{}))}} loading=${r.configuring} idleLabel=${r.canFinish?"Finish":"Awaiting pairing"} @@ -8053,7 +8129,7 @@ ${t} `:an` - <${Z} + <${Y} onClick=${()=>r.setStep(Math.min(Ui.length-1,r.step+1))} idleLabel="Next" tone="primary" @@ -8062,13 +8138,13 @@ ${t} `}
- - `};var n1=P.bind(T),s1=({onRestartRequired:t=()=>{}})=>{let{state:e,actions:n}=zw();return n1` + + `};var r1=P.bind(T),i1=({onRestartRequired:t=()=>{}})=>{let{state:e,actions:n}=Gw();return r1`
- <${Ne} + <${Pe} title="Nodes" - actions=${n1` - <${Z} + actions=${r1` + <${Y} onClick=${n.refreshNodes} loading=${e.refreshingNodes} loadingMode="inline" @@ -8076,7 +8152,7 @@ ${t} - <${Z} + <${Y} onClick=${n.openWizard} idleLabel="Connect Node" tone="primary" @@ -8085,7 +8161,7 @@ ${t} - <${Jw} + <${Xw} nodes=${e.nodes} pending=${e.pending} loading=${e.loadingNodes} @@ -8094,9 +8170,9 @@ ${t} - <${Zw} /> + <${Qw} /> - <${t1} + <${o1} visible=${e.wizardVisible} nodes=${e.nodes} refreshNodes=${n.refreshNodes} @@ -8104,38 +8180,38 @@ ${t}
- `};var dR=P.bind(T),mf=({onRestartRequired:t=()=>{}})=>dR` + `};var mR=P.bind(T),mf=({onRestartRequired:t=()=>{}})=>mR`
- <${s1} onRestartRequired=${t} /> + <${i1} onRestartRequired=${t} />
-`;var NU=P.bind(T);var OU=Object.values(Mn).flat().map(t=>t.key).filter((t,e,n)=>n.indexOf(t)===e);var jU=P.bind(T);var Ki=({to:t})=>{let[,e]=ca();return L(()=>{e(t)},[t,e]),null};var Gi=(t,e)=>{let n=String(e||"").trim();n&&t.set("accountId",n)},o1=async({accountId:t=""}={})=>{let e=new URLSearchParams;Gi(e,t);let n=e.toString()?`?${e.toString()}`:"";return(await Y(`/api/telegram/bot${n}`)).json()},r1=async({accountId:t=""}={})=>{let e=new URLSearchParams;Gi(e,t);let n=e.toString()?`?${e.toString()}`:"";return(await Y(`/api/telegram/workspace${n}`)).json()},i1=async({accountId:t=""}={})=>{let e=new URLSearchParams;Gi(e,t);let n=e.toString()?`?${e.toString()}`:"";return(await Y(`/api/telegram/workspace/reset${n}`,{method:"POST"})).json()},a1=async(t,{accountId:e=""}={})=>(await Y("/api/telegram/groups/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupId:t,accountId:e})})).json(),_c=async(t,{accountId:e=""}={})=>{let n=new URLSearchParams;Gi(n,e);let s=n.toString()?`?${n.toString()}`:"";return(await Y(`/api/telegram/groups/${encodeURIComponent(t)}/topics${s}`)).json()},Mc=async(t,e,{accountId:n=""}={})=>(await Y(`/api/telegram/groups/${encodeURIComponent(t)}/topics/bulk`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topics:e,accountId:n})})).json(),Ac=async(t,e,{accountId:n=""}={})=>{let s=new URLSearchParams;Gi(s,n);let o=s.toString()?`?${s.toString()}`:"";return(await Y(`/api/telegram/groups/${encodeURIComponent(t)}/topics/${e}${o}`,{method:"DELETE"})).json()},l1=async(t,e,n,{accountId:s=""}={})=>(await Y(`/api/telegram/groups/${encodeURIComponent(t)}/topics/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...n,accountId:s})})).json(),c1=async(t,e,{accountId:n=""}={})=>(await Y(`/api/telegram/groups/${encodeURIComponent(t)}/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,accountId:n})})).json();var At=P.bind(T),d1=({currentStep:t,steps:e})=>At` +`;var JU=P.bind(T);var ZU=Object.values(An).flat().map(t=>t.key).filter((t,e,n)=>n.indexOf(t)===e);var nK=P.bind(T);var Ki=({to:t})=>{let[,e]=ca();return L(()=>{e(t)},[t,e]),null};var Gi=(t,e)=>{let n=String(e||"").trim();n&&t.set("accountId",n)},a1=async({accountId:t=""}={})=>{let e=new URLSearchParams;Gi(e,t);let n=e.toString()?`?${e.toString()}`:"";return(await X(`/api/telegram/bot${n}`)).json()},l1=async({accountId:t=""}={})=>{let e=new URLSearchParams;Gi(e,t);let n=e.toString()?`?${e.toString()}`:"";return(await X(`/api/telegram/workspace${n}`)).json()},c1=async({accountId:t=""}={})=>{let e=new URLSearchParams;Gi(e,t);let n=e.toString()?`?${e.toString()}`:"";return(await X(`/api/telegram/workspace/reset${n}`,{method:"POST"})).json()},d1=async(t,{accountId:e=""}={})=>(await X("/api/telegram/groups/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupId:t,accountId:e})})).json(),_c=async(t,{accountId:e=""}={})=>{let n=new URLSearchParams;Gi(n,e);let s=n.toString()?`?${n.toString()}`:"";return(await X(`/api/telegram/groups/${encodeURIComponent(t)}/topics${s}`)).json()},Ac=async(t,e,{accountId:n=""}={})=>(await X(`/api/telegram/groups/${encodeURIComponent(t)}/topics/bulk`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topics:e,accountId:n})})).json(),Mc=async(t,e,{accountId:n=""}={})=>{let s=new URLSearchParams;Gi(s,n);let o=s.toString()?`?${s.toString()}`:"";return(await X(`/api/telegram/groups/${encodeURIComponent(t)}/topics/${e}${o}`,{method:"DELETE"})).json()},u1=async(t,e,n,{accountId:s=""}={})=>(await X(`/api/telegram/groups/${encodeURIComponent(t)}/topics/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...n,accountId:s})})).json(),p1=async(t,e,{accountId:n=""}={})=>(await X(`/api/telegram/groups/${encodeURIComponent(t)}/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,accountId:n})})).json();var Mt=P.bind(T),f1=({currentStep:t,steps:e})=>Mt`
- ${e.map((n,s)=>At` + ${e.map((n,s)=>Mt`
`)}
-`,u1=({accountId:t,botInfo:e,setBotInfo:n,onNext:s})=>{let[o,r]=y(!1),[i,a]=y(null),l=async()=>{r(!0),a(null);try{let c=await o1({accountId:t});if(!c.ok)throw new Error(c.error);n(c.bot)}catch(c){a(c.message)}r(!1)};return L(()=>{e||l()},[]),At` +`,h1=({accountId:t,botInfo:e,setBotInfo:n,onNext:s})=>{let[o,r]=y(!1),[i,a]=y(null),l=async()=>{r(!0),a(null);try{let c=await a1({accountId:t});if(!c.ok)throw new Error(c.error);n(c.bot)}catch(c){a(c.message)}r(!1)};return L(()=>{e||l()},[]),Mt`

Verify Bot Setup

- ${e&&At` + ${e&&Mt`
@${e.username} - <${ae} tone="success">Connected + <${le} tone="success">Connected

${e.first_name}

`} - ${i&&At` + ${i&&Mt`

${i}

`} - ${!e&&!o&&!i&&At`

Checking bot token...

`} + ${!e&&!o&&!i&&Mt`

Checking bot token...

`}

@@ -8168,7 +8244,7 @@ ${t}

- `},p1=({onNext:t,onBack:e})=>At` + `},m1=({onNext:t,onBack:e})=>Mt`

Create a Telegram Group

@@ -8236,7 +8312,7 @@ ${t}
-`,f1=({accountId:t,groupId:e,setGroupId:n,groupInfo:s,setGroupInfo:o,userId:r,setUserId:i,verifyGroupError:a,setVerifyGroupError:l,onNext:c,onBack:d})=>{let[u,p]=y(e||""),[f,g]=y(!1),[m,h]=y(!1),b=s?[...s.chat?.isForum?[]:["Topics are OFF. Enable Topics in Telegram group settings."],...s.bot?.isAdmin?[]:["Bot is not an admin. Promote it to admin in group members."],...s.bot?.canManageTopics?[]:["Bot is missing Manage Topics permission. Enable it in admin permissions."]]:[],x=async()=>{let $=u.trim();if($){g(!0),l(null);try{let S=await a1($,{accountId:t});if(!S.ok)throw new Error(S.error);n($),o(S),!String(r||"").trim()&&S.suggestedUserId&&i(String(S.suggestedUserId))}catch(S){l(S.message),o(null)}g(!1)}},v=!!(s&&s.chat?.isForum&&s.bot?.isAdmin&&s.bot?.canManageTopics),w=async()=>{if(!(!v||m)){l(null),h(!0);try{let $=String(r||"").trim(),S=await c1(e,{...$?{userId:$}:{},groupName:s?.chat?.title||e,requireMention:!1},{accountId:t});if(!S?.ok)throw new Error(S?.error||"Failed to configure Telegram group");S.userId&&i(String(S.userId)),c()}catch($){l($.message)}h(!1)}};return At` +`,g1=({accountId:t,groupId:e,setGroupId:n,groupInfo:s,setGroupInfo:o,userId:r,setUserId:i,verifyGroupError:a,setVerifyGroupError:l,onNext:c,onBack:d})=>{let[u,p]=y(e||""),[f,g]=y(!1),[m,h]=y(!1),b=s?[...s.chat?.isForum?[]:["Topics are OFF. Enable Topics in Telegram group settings."],...s.bot?.isAdmin?[]:["Bot is not an admin. Promote it to admin in group members."],...s.bot?.canManageTopics?[]:["Bot is missing Manage Topics permission. Enable it in admin permissions."]]:[],x=async()=>{let $=u.trim();if($){g(!0),l(null);try{let S=await d1($,{accountId:t});if(!S.ok)throw new Error(S.error);n($),o(S),!String(r||"").trim()&&S.suggestedUserId&&i(String(S.suggestedUserId))}catch(S){l(S.message),o(null)}g(!1)}},v=!!(s&&s.chat?.isForum&&s.bot?.isAdmin&&s.bot?.canManageTopics),w=async()=>{if(!(!v||m)){l(null),h(!0);try{let $=String(r||"").trim(),S=await p1(e,{...$?{userId:$}:{},groupName:s?.chat?.title||e,requireMention:!1},{accountId:t});if(!S?.ok)throw new Error(S?.error||"Failed to configure Telegram group");S.userId&&i(String(S.userId)),c()}catch($){l($.message)}h(!1)}};return Mt`

Verify Group

@@ -8264,7 +8340,7 @@ ${t} - <${Z} + <${Y} onClick=${x} disabled=${!u.trim()||f} loading=${f} @@ -8276,16 +8352,16 @@ ${t}
- ${a&&At` + ${a&&Mt`

${a}

`} - ${s&&At` + ${s&&Mt`
${s.chat.title} - <${ae} tone="success">Verified + <${le} tone="success">Verified
Topics: ${s.chat.isForum?"ON":"OFF"} @@ -8293,7 +8369,7 @@ ${t}
`} - ${s&&b.length===0&&At` + ${s&&b.length===0&&Mt`

Your Telegram User ID

`} - ${b.length>0&&At` + ${b.length>0&&Mt`
@@ -8316,7 +8392,7 @@ ${t}
    - ${b.map($=>At`
  • ${$}
  • `)} + ${b.map($=>Mt`
  • ${$}
  • `)}

Once fixed, hit Verify again.

@@ -8338,11 +8414,11 @@ ${t}
- `},h1=({accountId:t,groupId:e,topics:n,setTopics:s,onNext:o,onBack:r})=>{let[i,a]=y(""),[l,c]=y(""),[d,u]=y(!1),[p,f]=y(null),[g,m]=y(null),[h,b]=y(null),x=async()=>{let S=await _c(e,{accountId:t});S.ok&&s(S.topics)};L(()=>{x()},[e]);let v=async()=>{let S=i.trim(),C=l.trim();if(S){u(!0),f(null);try{let _=await Mc(e,[{name:S,...C?{systemInstructions:C}:{}}],{accountId:t});if(!_.ok)throw new Error(_.results?.[0]?.error||"Failed to create topic");let k=_.results.filter(A=>!A.ok);if(k.length>0)throw new Error(k[0].error);a(""),c(""),await x(),N(`Created topic: ${S}`,"success")}catch(_){f(_.message)}u(!1)}},w=async(S,C)=>{m(S);try{let _=await Ac(e,S,{accountId:t});if(!_.ok)throw new Error(_.error);await x(),_.removedFromRegistryOnly?N(`Removed stale topic from registry: ${C}`,"success"):N(`Deleted topic: ${C}`,"success")}catch(_){N(`Failed to delete: ${_.message}`,"error")}m(null)},$=Object.entries(n||{});return At` + `},b1=({accountId:t,groupId:e,topics:n,setTopics:s,onNext:o,onBack:r})=>{let[i,a]=y(""),[l,c]=y(""),[d,u]=y(!1),[p,f]=y(null),[g,m]=y(null),[h,b]=y(null),x=async()=>{let S=await _c(e,{accountId:t});S.ok&&s(S.topics)};L(()=>{x()},[e]);let v=async()=>{let S=i.trim(),C=l.trim();if(S){u(!0),f(null);try{let _=await Ac(e,[{name:S,...C?{systemInstructions:C}:{}}],{accountId:t});if(!_.ok)throw new Error(_.results?.[0]?.error||"Failed to create topic");let k=_.results.filter(A=>!A.ok);if(k.length>0)throw new Error(k[0].error);a(""),c(""),await x(),I(`Created topic: ${S}`,"success")}catch(_){f(_.message)}u(!1)}},w=async(S,C)=>{m(S);try{let _=await Mc(e,S,{accountId:t});if(!_.ok)throw new Error(_.error);await x(),_.removedFromRegistryOnly?I(`Removed stale topic from registry: ${C}`,"success"):I(`Deleted topic: ${C}`,"success")}catch(_){I(`Failed to delete: ${_.message}`,"error")}m(null)},$=Object.entries(n||{});return Mt`

Create Topics

- ${$.length>0&&At` + ${$.length>0&&Mt`
@@ -8359,7 +8435,7 @@ ${t} - ${$.map(([S,C])=>At` + ${$.map(([S,C])=>Mt` ${C.name} ${S} @@ -8410,7 +8486,7 @@ ${t}
- <${Z} + <${Y} onClick=${v} disabled=${d||!i.trim()} loading=${d} @@ -8425,7 +8501,7 @@ ${t}
- ${p&&At` + ${p&&Mt`

${p}

@@ -8459,7 +8535,7 @@ ${t}{if(!h)return;let S=h;b(null),await w(S.id,S.name)}} />
- `},m1=({groupId:t,groupInfo:e,topics:n,onBack:s,onDone:o})=>At` + `},x1=({groupId:t,groupInfo:e,topics:n,onBack:s,onDone:o})=>Mt`

🎉 Setup complete

@@ -8492,7 +8568,7 @@ ${t}
- `;var Tt=P.bind(T),g1=({value:t,agents:e,onChange:n,className:s=""})=>Tt` + `;var Tt=P.bind(T),y1=({value:t,agents:e,onChange:n,className:s=""})=>Tt` -`,bf=({accountId:t,groupId:e,groupName:n,initialTopics:s,configAgentMaxConcurrent:o,configSubagentMaxConcurrent:r,debugEnabled:i,onResetOnboarding:a})=>{let[l,c]=y(s||{}),[d,u]=y(""),[p,f]=y(""),[g,m]=y(""),[h,b]=y(!1),[x,v]=y(!1),[w,$]=y(null),[S,C]=y(""),[_,k]=y(""),[A,O]=y(""),[D,z]=y(""),[E,M]=y(""),[R,B]=y(null),[I,U]=y(null),[W,G]=y([]),se=async()=>{let V=await _c(e,{accountId:t});V.ok&&c(V.topics||{})};L(()=>{se()},[e]),L(()=>{s&&Object.keys(s).length>0&&c(s)},[s]),L(()=>{Ao().then(V=>G(Array.isArray(V?.agents)?V.agents:[])).catch(()=>{})},[]);let K=async()=>{let V=d.trim(),J=p.trim(),oe=g.trim();if(V){v(!0),B(null);try{let ce=await Mc(e,[{name:V,...J?{systemInstructions:J}:{},...oe?{agentId:oe}:{}}],{accountId:t});if(!ce.ok)throw new Error(ce.results?.[0]?.error||"Failed to create topic");let be=ce.results.filter(Ve=>!Ve.ok);if(be.length>0)throw new Error(be[0].error);u(""),f(""),m(""),b(!1),await se(),N(`Created topic: ${V}`,"success")}catch(ce){B(ce.message)}v(!1)}},j=async(V,J)=>{$(V);try{let oe=await Ac(e,V,{accountId:t});if(!oe.ok)throw new Error(oe.error);await se(),oe.removedFromRegistryOnly?N(`Removed stale topic from registry: ${J}`,"success"):N(`Deleted topic: ${J}`,"success")}catch(oe){N(`Failed to delete: ${oe.message}`,"error")}$(null)},X=(V,J,oe="",ce="")=>{C(String(V)),k(String(J||"")),O(String(oe||"")),z(String(ce||""))},de=()=>{C(""),k(""),O(""),z("")},le=async V=>{let J=_.trim(),oe=A.trim(),ce=D.trim();if(!J){B("Topic name is required");return}M(String(V)),B(null);try{let be=await l1(e,V,{name:J,systemInstructions:oe,agentId:ce},{accountId:t});if(!be.ok)throw new Error(be.error||"Failed to update topic");await se(),N(`Updated topic: ${J}`,"success"),de()}catch(be){B(be.message)}M("")},ie=Object.entries(l||{}),ne=ie.length,xe=Math.max(ne*3,8),he=Math.max(xe-2,4),ue=Number.isFinite(o)?o:xe,me=Number.isFinite(r)?r:he;return Tt` +`,bf=({accountId:t,groupId:e,groupName:n,initialTopics:s,configAgentMaxConcurrent:o,configSubagentMaxConcurrent:r,debugEnabled:i,onResetOnboarding:a})=>{let[l,c]=y(s||{}),[d,u]=y(""),[p,f]=y(""),[g,m]=y(""),[h,b]=y(!1),[x,v]=y(!1),[w,$]=y(null),[S,C]=y(""),[_,k]=y(""),[A,D]=y(""),[N,U]=y(""),[O,M]=y(""),[R,B]=y(null),[E,G]=y(null),[H,z]=y([]),te=async()=>{let j=await _c(e,{accountId:t});j.ok&&c(j.topics||{})};L(()=>{te()},[e]),L(()=>{s&&Object.keys(s).length>0&&c(s)},[s]),L(()=>{Mo().then(j=>z(Array.isArray(j?.agents)?j.agents:[])).catch(()=>{})},[]);let K=async()=>{let j=d.trim(),J=p.trim(),ie=g.trim();if(j){v(!0),B(null);try{let de=await Ac(e,[{name:j,...J?{systemInstructions:J}:{},...ie?{agentId:ie}:{}}],{accountId:t});if(!de.ok)throw new Error(de.results?.[0]?.error||"Failed to create topic");let be=de.results.filter(Ve=>!Ve.ok);if(be.length>0)throw new Error(be[0].error);u(""),f(""),m(""),b(!1),await te(),I(`Created topic: ${j}`,"success")}catch(de){B(de.message)}v(!1)}},V=async(j,J)=>{$(j);try{let ie=await Mc(e,j,{accountId:t});if(!ie.ok)throw new Error(ie.error);await te(),ie.removedFromRegistryOnly?I(`Removed stale topic from registry: ${J}`,"success"):I(`Deleted topic: ${J}`,"success")}catch(ie){I(`Failed to delete: ${ie.message}`,"error")}$(null)},Z=(j,J,ie="",de="")=>{C(String(j)),k(String(J||"")),D(String(ie||"")),U(String(de||""))},ue=()=>{C(""),k(""),D(""),U("")},re=async j=>{let J=_.trim(),ie=A.trim(),de=N.trim();if(!J){B("Topic name is required");return}M(String(j)),B(null);try{let be=await u1(e,j,{name:J,systemInstructions:ie,agentId:de},{accountId:t});if(!be.ok)throw new Error(be.error||"Failed to update topic");await te(),I(`Updated topic: ${J}`,"success"),ue()}catch(be){B(be.message)}M("")},oe=Object.entries(l||{}),ne=oe.length,me=Math.max(ne*3,8),pe=Math.max(me-2,4),ce=Number.isFinite(o)?o:me,ge=Number.isFinite(r)?r:pe;return Tt`
${i&&Tt`
@@ -8520,7 +8596,7 @@ ${t}

Existing Topics

- ${ie.length>0?Tt` + ${oe.length>0?Tt`
@@ -8535,7 +8611,7 @@ ${t} Thread ID - ${W.length>0&&Tt` + ${H.length>0&&Tt` @@ -8546,47 +8622,47 @@ ${t} - ${ie.map(([V,J])=>Tt` - ${S===String(V)?Tt` + ${oe.map(([j,J])=>Tt` + ${S===String(j)?Tt` - 0?4:3}> + 0?4:3}>
k(oe.target.value)} - onKeyDown=${oe=>{oe.key==="Enter"&&le(V),oe.key==="Escape"&&de()}} + onInput=${ie=>k(ie.target.value)} + onKeyDown=${ie=>{ie.key==="Enter"&&re(j),ie.key==="Escape"&&ue()}} class="w-full bg-field border border-border rounded-lg px-2 py-1.5 text-xs text-body placeholder-fg-dim focus:outline-none focus:border-fg-muted" />
- <${Y} + <${Z} onClick=${c} - disabled=${w} + disabled=${$} tone="secondary" size="md" idleLabel=${l} /> - <${Y} + <${Z} onClick=${S} disabled=${!m||h||!!b||!String(x||"").trim()} - loading=${w} + loading=${$} tone="primary" size="md" idleLabel=${i} loadingLabel=${a} />
- - `};var p3=P.bind(T),yw=({visible:t=!1,card:e=null,onClose:n=()=>{},onComplete:s=()=>{}})=>{let o=async({selectedSession:r,message:i})=>{if(!e?.id)return!1;try{await nm({cardId:e.id,sessionId:r?.sessionId||"",replyChannel:r?.replyChannel||"",replyTo:r?.replyTo||"",prompt:i});try{await pa({cardId:e.id,status:"fixed"}),I("Doctor fix request sent and finding marked fixed","success")}catch(a){I(a.message||"Doctor fix request sent, but could not mark the finding fixed","warning")}return await s(),!0}catch(a){return I(a.message||"Could not send Doctor fix request","error"),!1}};return p3` - <${mc} + + `};var b3=P.bind(T),Sw=({visible:t=!1,card:e=null,onClose:n=()=>{},onComplete:s=()=>{}})=>{let o=async({selectedSession:r,message:i})=>{if(!e?.id)return!1;try{await om({cardId:e.id,sessionId:r?.sessionId||"",replyChannel:r?.replyChannel||"",replyTo:r?.replyTo||"",prompt:i});try{await ma({cardId:e.id,status:"fixed"}),I("Doctor fix request sent and finding marked fixed","success")}catch(a){I(a.message||"Doctor fix request sent, but could not mark the finding fixed","warning")}return await s(),!0}catch(a){return I(a.message||"Could not send Doctor fix request","error"),!1}};return b3` + <${yc} visible=${t} title="Ask agent to fix" messageLabel="Instructions" @@ -5734,7 +5741,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s onClose=${n} onSubmit=${o} /> - `};var wt=P.bind(T),cf=15e3,vw=2e3,f3=()=>wt` + `};var St=P.bind(T),uf=15e3,Cw=2e3,x3=()=>St` {r.current&&(r.current.destroy(),r.current=null)}},[f,i,s d="M8 20V14H16V20H19V4H5V20H8ZM10 20H14V16H10V20ZM21 20H23V22H1V20H3V3C3 2.44772 3.44772 2 4 2H20C20.5523 2 21 2.44772 21 3V20ZM11 8V6H13V8H15V10H13V12H11V10H9V8H11Z" > -`,$w=({isActive:t=!1,onOpenFile:e=()=>{}})=>{let n=Ee(ua,cf,{enabled:t}),s=n.data?.status||null,o=s?.runInProgress?vw:cf,r=Ee(()=>em(10),o,{enabled:t}),[i,a]=y("all"),[l,c]=y("open"),[d,u]=y(0),[p,f]=y(null),[g,m]=y(""),h=r.data?.runs||[],b=String(s?.activeRunId||""),x=String(i||""),w=x!==""&&x!=="all"&&!h.some(J=>String(J.id||"")===x)&&(g===x||s?.runInProgress&&b===x)?{id:Number(x||0),status:"running",summary:"",priorityCounts:{P0:0,P1:0,P2:0},statusCounts:{open:0,dismissed:0,fixed:0}}:null,$=w?[w,...h]:h,S=i!=="all"&&!!b&&String(i||"")===b,C=i==="all"?null:$.find(J=>String(J.id||"")===String(i||""))||null,_=Ee(()=>tm({runId:i||"all"}),s?.runInProgress||C?.status==="running"?vw:cf,{enabled:t}),k=_.data?.cards||[];L(()=>{t&&(n.refresh(),r.refresh())},[t]),L(()=>{if(!h.length){if(g&&x===g||S&&s?.runInProgress)return;i!=="all"&&a("all");return}i==="all"||h.some(ie=>String(ie.id||"")===String(i||""))||S&&s?.runInProgress||a("all")},[h,x,i,S,g,s?.runInProgress]),L(()=>{if(!g)return;if(i!==g){a(g);return}let J=h.some(de=>String(de.id||"")===String(g||"")),ie=!!b&&b===g&&!!s?.runInProgress;!J&&!ie||m("")},[b,s?.runInProgress,g,h,i]),L(()=>{_.refresh()},[i]);let A=C?.status==="running"||S&&s?.runInProgress,D=F(()=>A?"":C?.summary||"",[C,A]),N=F(()=>hw(),[]),U=F(()=>uw(s?.changeSummary||null),[s]),O=F(()=>s?.runInProgress||s?.needsInitialRun?!0:Number(s?.changeSummary?.changedFilesCount||0)>0,[s]),M=O?"":"No workspace changes since the last completed Drift Doctor run.",R=F(()=>fc(s,0),[s]),B=F(()=>cw(s),[s]),E=F(()=>dw(s),[s]),G=F(()=>hc(s),[s]),H=!!s?.lastRunAt,z=h.length>0,te=r.data!==null||r.error!==null,K=_.data!==null||_.error!==null,V=!te||z&&!K,Z=F(()=>l==="all"?k:k.filter(J=>String(J?.status||"open").trim().toLowerCase()===l),[k,l]),ue=F(()=>k.filter(J=>String(J?.status||"open").trim().toLowerCase()==="open"),[k]),re=F(()=>$.slice(0,2),[$]),oe=F(()=>$.slice(2),[$]),ne=F(()=>i==="all"?"":oe.some(J=>String(J.id||"")===String(i||""))?String(i||""):"",[oe,i]),me=(J=!1)=>["inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs transition-colors",J?"border-cyan-500/40 bg-cyan-500/10 text-status-info shadow-[0_0_0_1px_rgba(34,211,238,0.08)]":"border-border bg-field text-body hover:border-fg-muted hover:text-bright"].join(" "),pe=(J="neutral")=>J==="success"?"bg-green-400":J==="warning"?"bg-yellow-400":J==="danger"?"bg-red-400":J==="cyan"?"ac-status-dot ac-status-dot--info":"bg-gray-500",ce=!V&&(h.length>0||!!g||!!b||!!s?.runInProgress),ge=async()=>{try{let J=await Qh();if(I(J?.reusedPreviousRun?"No workspace changes since the last scan; reused previous findings":"Doctor run started","success"),J?.runId){let ie=String(J.runId);m(ie),a(ie)}n.refresh(),r.refresh(),_.refresh(),setTimeout(n.refresh,1200),setTimeout(r.refresh,1200),setTimeout(_.refresh,1200)}catch(J){I(J.message||"Could not start Doctor run","error")}},j=async(J,ie)=>{if(!(!J?.id||d))try{u(J.id),await pa({cardId:J.id,status:ie}),I("Doctor card updated","success"),await _.refresh(),await r.refresh(),await n.refresh()}catch(de){I(de.message||"Could not update Doctor card","error")}finally{u(0)}};return wt` +`,_w=({isActive:t=!1,onOpenFile:e=()=>{}})=>{let n=Re(ha,uf,{enabled:t}),s=n.data?.status||null,o=s?.runInProgress?Cw:uf,r=Re(()=>nm(10),o,{enabled:t}),[i,a]=y("all"),[l,c]=y("open"),[d,u]=y(0),[p,f]=y(null),[g,m]=y(""),h=r.data?.runs||[],b=String(s?.activeRunId||""),x=String(i||""),$=x!==""&&x!=="all"&&!h.some(q=>String(q.id||"")===x)&&(g===x||s?.runInProgress&&b===x)?{id:Number(x||0),status:"running",summary:"",priorityCounts:{P0:0,P1:0,P2:0},statusCounts:{open:0,dismissed:0,fixed:0}}:null,w=$?[$,...h]:h,S=i!=="all"&&!!b&&String(i||"")===b,C=i==="all"?null:w.find(q=>String(q.id||"")===String(i||""))||null,_=Re(()=>sm({runId:i||"all"}),s?.runInProgress||C?.status==="running"?Cw:uf,{enabled:t}),k=_.data?.cards||[];R(()=>{t&&(n.refresh(),r.refresh())},[t]),R(()=>{if(!h.length){if(g&&x===g||S&&s?.runInProgress)return;i!=="all"&&a("all");return}i==="all"||h.some(ae=>String(ae.id||"")===String(i||""))||S&&s?.runInProgress||a("all")},[h,x,i,S,g,s?.runInProgress]),R(()=>{if(!g)return;if(i!==g){a(g);return}let q=h.some(fe=>String(fe.id||"")===String(g||"")),ae=!!b&&b===g&&!!s?.runInProgress;!q&&!ae||m("")},[b,s?.runInProgress,g,h,i]),R(()=>{_.refresh()},[i]);let A=C?.status==="running"||S&&s?.runInProgress,D=W(()=>A?"":C?.summary||"",[C,A]),O=W(()=>yw(),[]),z=W(()=>gw(s?.changeSummary||null),[s]),N=W(()=>s?.runInProgress||s?.needsInitialRun?!0:Number(s?.changeSummary?.changedFilesCount||0)>0,[s]),M=N?"":"No workspace changes since the last completed Drift Doctor run.",L=W(()=>bc(s,0),[s]),B=W(()=>hw(s),[s]),E=W(()=>mw(s),[s]),U=W(()=>xc(s),[s]),F=!!s?.lastRunAt,K=h.length>0,re=r.data!==null||r.error!==null,Y=_.data!==null||_.error!==null,j=!re||K&&!Y,J=W(()=>l==="all"?k:k.filter(q=>String(q?.status||"open").trim().toLowerCase()===l),[k,l]),pe=W(()=>k.filter(q=>String(q?.status||"open").trim().toLowerCase()==="open"),[k]),le=W(()=>w.slice(0,2),[w]),ie=W(()=>w.slice(2),[w]),se=W(()=>i==="all"?"":ie.some(q=>String(q.id||"")===String(i||""))?String(i||""):"",[ie,i]),xe=(q=!1)=>["inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs transition-colors",q?"border-cyan-500/40 bg-cyan-500/10 text-status-info shadow-[0_0_0_1px_rgba(34,211,238,0.08)]":"border-border bg-field text-body hover:border-fg-muted hover:text-bright"].join(" "),he=(q="neutral")=>q==="success"?"bg-green-400":q==="warning"?"bg-yellow-400":q==="danger"?"bg-red-400":q==="cyan"?"ac-status-dot ac-status-dot--info":"bg-gray-500",ue=!j&&(h.length>0||!!g||!!b||!!s?.runInProgress),be=async()=>{try{let q=await tm();if(I(q?.reusedPreviousRun?"No workspace changes since the last scan; reused previous findings":"Doctor run started","success"),q?.runId){let ae=String(q.runId);m(ae),a(ae)}n.refresh(),r.refresh(),_.refresh(),setTimeout(n.refresh,1200),setTimeout(r.refresh,1200),setTimeout(_.refresh,1200)}catch(q){I(q.message||"Could not start Doctor run","error")}},V=async(q,ae)=>{if(!(!q?.id||d))try{u(q.id),await ma({cardId:q.id,status:ae}),I("Doctor card updated","success"),await _.refresh(),await r.refresh(),await n.refresh()}catch(fe){I(fe.message||"Could not update Doctor card","error")}finally{u(0)}};return St`
- ${ce?wt` - <${Pe} + ${ue?St` + <${De} title="Drift Doctor" - actions=${wt` - <${Y} - onClick=${ge} - disabled=${!O} + actions=${St` + <${Z} + onClick=${be} + disabled=${!N} loading=${!!s?.runInProgress} idleLabel="Run Drift Doctor" loadingLabel="Running..." @@ -5762,33 +5769,33 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s `} /> `:null} - ${V?wt` + ${j?St`
- <${Ce} className="h-4 w-4" /> + <${Ae} className="h-4 w-4" /> Loading Drift Doctor...
`:null} - ${!V&&z?wt` + ${!j&&K?St`
- <${mw} cards=${ue} /> + <${vw} cards=${pe} />
- ${H?wt` + ${F?St`
Last run ·${" "} - ${Wo(s?.lastRunAt,{fallback:"Never"})} + ${Ho(s?.lastRunAt,{fallback:"Never"})} - ${U} + ${z}
- ${B?wt` + ${B?St`
@@ -5796,27 +5803,27 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s ⚠️ ${E}
- ${G.map(J=>wt` + ${U.map(q=>St`
- ${J.size} + ${q.size} - ${J.statusText} + ${q.statusText}
@@ -5830,7 +5837,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
`:null} `:null} - ${R?wt` + ${L?St`
@@ -5842,7 +5849,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
`:null} - ${ce?wt` + ${ue?St`

Findings

@@ -5850,46 +5857,46 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
- ${re.map(J=>{let ie=String(i||"")===String(J.id||""),de=fw(J);return wt` + ${le.map(q=>{let ae=String(i||"")===String(q.id||""),fe=xw(q);return St` `})} - ${oe.length?wt` + ${ie.length?St`
- ${D?wt` + ${D?St`
{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s

`:null} - ${A?wt` + ${A?St`
- <${Ce} className="h-3.5 w-3.5" /> + <${Ae} className="h-3.5 w-3.5" /> Run in progress. Findings will appear when analysis completes. @@ -5931,11 +5938,11 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
`:null}
- <${bw} - cards=${Z} + <${ww} + cards=${J} busyCardId=${d} onAskAgentFix=${f} - onUpdateStatus=${j} + onUpdateStatus=${V} onOpenFile=${e} changedPaths=${s?.changeSummary?.changedPaths||[]} showRunMeta=${i==="all"} @@ -5944,12 +5951,12 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
`:null} - ${!V&&!ce?wt` + ${!j&&!ue?St`
- <${f3} /> + <${x3} />

Workspace health review @@ -5961,9 +5968,9 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s

- <${Y} - onClick=${ge} - disabled=${!O} + <${Z} + onClick=${be} + disabled=${!N} loading=${!!s?.runInProgress} size="lg" idleLabel="Run Drift Doctor" @@ -5978,21 +5985,21 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
`:null} - <${yw} + <${Sw} visible=${!!p} card=${p} onClose=${()=>f(null)} onComplete=${async()=>{await n.refresh(),await r.refresh(),await _.refresh()}} />
- `};var h3=P.bind(T),df=({onNavigateToBrowseFile:t=()=>{}})=>h3` + `};var y3=P.bind(T),pf=({onNavigateToBrowseFile:t=()=>{}})=>y3`
- <${$w} + <${_w} isActive=${!0} onOpenFile=${(e,n={})=>{let s=`workspace/${String(e||"").trim().replace(/^workspace\//,"")}`;t(s,{view:"edit",...n.line?{line:n.line}:{},...n.lineEnd?{lineEnd:n.lineEnd}:{}})}} />
-`;var m3=P.bind(T),Un=({header:t,children:e})=>m3` +`;var v3=P.bind(T),Un=({header:t,children:e})=>v3`
@@ -6005,29 +6012,29 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
-`;var Ue=P.bind(T),ww={ai:"AI Provider Keys",github:"GitHub",channels:"Channels",tools:"Tools",custom:"Custom"},g3=["ai","github","channels","tools","custom"],b3=new Set(["OPENAI_API_KEY","GEMINI_API_KEY"]),Cw={Embeddings:{Icon:_a,label:"Memory embeddings"},Image:{Icon:sb,label:"Image generation"},TTS:{Icon:ob,label:"Text to speech"},STT:{Icon:rb,label:"Speech to text"}},kw=t=>t.trim().toUpperCase().replace(/[^A-Z0-9_]/g,"_"),x3=/^(?:TELEGRAM_BOT_TOKEN|DISCORD_BOT_TOKEN|SLACK_BOT_TOKEN|SLACK_APP_TOKEN)(?:_[A-Z0-9_]+)?$/,y3=t=>{let e=String(t||"").trim();if(e.length<2)return e;let n=e.startsWith('"'),s=e.endsWith('"');if(n&&s)return e.slice(1,-1);let o=e.startsWith("'"),r=e.endsWith("'");return o&&r?e.slice(1,-1):e},gc=(t="")=>x3.test(String(t||"").trim().toUpperCase()),Sw=t=>JSON.stringify((t||[]).map(e=>({key:String(e?.key||""),value:String(e?.value||"")})).sort((e,n)=>e.key.localeCompare(n.key))),v3=t=>{let e=Array.isArray(t)?[...t]:[],n=e.filter(o=>(o?.group||"custom")==="custom").sort((o,r)=>String(o?.key||"").localeCompare(String(r?.key||""))),s=0;return e.map(o=>{if((o?.group||"custom")!=="custom")return o;let r=n[s];return s+=1,r})},$3={ANTHROPIC_API_KEY:Ue`from${" "} +`;var Ge=P.bind(T),Aw={ai:"AI Provider Keys",github:"GitHub",channels:"Channels",tools:"Tools",custom:"Custom"},$3=["ai","github","channels","tools","custom"],w3=new Set(["OPENAI_API_KEY","GEMINI_API_KEY"]),Pw={Embeddings:{Icon:Pa,label:"Memory embeddings"},Image:{Icon:rb,label:"Image generation"},TTS:{Icon:ib,label:"Text to speech"},STT:{Icon:ab,label:"Speech to text"}},Mw=t=>t.trim().toUpperCase().replace(/[^A-Z0-9_]/g,"_"),k3=/^(?:TELEGRAM_BOT_TOKEN|DISCORD_BOT_TOKEN|SLACK_BOT_TOKEN|SLACK_APP_TOKEN)(?:_[A-Z0-9_]+)?$/,S3=t=>{let e=String(t||"").trim();if(e.length<2)return e;let n=e.startsWith('"'),s=e.endsWith('"');if(n&&s)return e.slice(1,-1);let o=e.startsWith("'"),r=e.endsWith("'");return o&&r?e.slice(1,-1):e},vc=(t="")=>k3.test(String(t||"").trim().toUpperCase()),Tw=t=>JSON.stringify((t||[]).map(e=>({key:String(e?.key||""),value:String(e?.value||"")})).sort((e,n)=>e.key.localeCompare(n.key))),C3=t=>{let e=Array.isArray(t)?[...t]:[],n=e.filter(o=>(o?.group||"custom")==="custom").sort((o,r)=>String(o?.key||"").localeCompare(String(r?.key||""))),s=0;return e.map(o=>{if((o?.group||"custom")!=="custom")return o;let r=n[s];return s+=1,r})},_3={ANTHROPIC_API_KEY:Ge`from${" "} console.anthropic.com`,ANTHROPIC_TOKEN:Ue`from - claude setup-token`,OPENAI_API_KEY:Ue`from${" "} + >`,ANTHROPIC_TOKEN:Ge`from + claude setup-token`,OPENAI_API_KEY:Ge`from${" "} platform.openai.com`,GEMINI_API_KEY:Ue`from${" "} + >`,GEMINI_API_KEY:Ge`from${" "} aistudio.google.com`,ELEVENLABS_API_KEY:Ue`from${" "} + >`,ELEVENLABS_API_KEY:Ge`from${" "} {r.current&&(r.current.destroy(),r.current=null)}},[f,i,s >elevenlabs.io${" "} · ${" "} XI_API_KEY also - supported`,GITHUB_WORKSPACE_REPO:Ue`use + supported`,GITHUB_WORKSPACE_REPO:Ge`use owner/repo or https://github.com/owner/repo`,TELEGRAM_BOT_TOKEN:Ue`from${" "} + >`,TELEGRAM_BOT_TOKEN:Ge`from${" "} {r.current&&(r.current.destroy(),r.current=null)}},[f,i,s class="hover:underline" style="color: var(--accent-link)" >full guide`,DISCORD_BOT_TOKEN:Ue`from${" "} + >`,DISCORD_BOT_TOKEN:Ge`from${" "} {r.current&&(r.current.destroy(),r.current=null)}},[f,i,s class="hover:underline" style="color: var(--accent-link)" >full guide`,MISTRAL_API_KEY:Ue`from${" "} + >`,MISTRAL_API_KEY:Ge`from${" "} console.mistral.ai`,VOYAGE_API_KEY:Ue`from${" "} + >`,VOYAGE_API_KEY:Ge`from${" "} dash.voyageai.com`,GROQ_API_KEY:Ue`from${" "} + >`,GROQ_API_KEY:Ge`from${" "} console.groq.com`,DEEPGRAM_API_KEY:Ue`from${" "} + >`,DEEPGRAM_API_KEY:Ge`from${" "} console.deepgram.com`,BRAVE_API_KEY:Ue`from${" "} + >`,BRAVE_API_KEY:Ge`from${" "} brave.com/search/api${" "} — free tier available`},w3=t=>$3[t.key]||t.hint||"",k3=t=>(Array.isArray(t?.features)?t.features:[]).filter(e=>!!Cw[e]),S3=t=>{let e=[],n=[];return(t||[]).forEach(s=>{let o=!!String(s?.value||"").trim();if(b3.has(s?.key)||o){e.push(s);return}n.push(s)}),{visible:e,hidden:n}},C3=({feature:t})=>{let e=Cw[t];if(!e)return null;let{Icon:n,label:s}=e;return Ue` - <${yt} text=${s} widthClass="w-auto" tooltipClassName="whitespace-nowrap"> + >${" "} — free tier available`},A3=t=>_3[t.key]||t.hint||"",M3=t=>(Array.isArray(t?.features)?t.features:[]).filter(e=>!!Pw[e]),T3=t=>{let e=[],n=[];return(t||[]).forEach(s=>{let o=!!String(s?.value||"").trim();if(w3.has(s?.key)||o){e.push(s);return}n.push(s)}),{visible:e,hidden:n}},P3=({feature:t})=>{let e=Pw[t];if(!e)return null;let{Icon:n,label:s}=e;return Ge` + <${$t} text=${s} widthClass="w-auto" tooltipClassName="whitespace-nowrap"> {r.current&&(r.current.destroy(),r.current=null)}},[f,i,s > <${n} className="w-3.5 h-3.5" /> - - `},_3=({envVar:t,onChange:e,onDelete:n,disabled:s})=>{let o=w3(t),r=k3(t);return Ue` + + `},R3=({envVar:t,onChange:e,onDelete:n,disabled:s})=>{let o=A3(t),r=M3(t);return Ge`
@@ -6124,15 +6131,15 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s /> ${t.key}
- ${r.length>0?Ue` + ${r.length>0?Ge`
- ${r.map(i=>Ue`<${C3} key=${i} feature=${i} />`)} + ${r.map(i=>Ge`<${P3} key=${i} feature=${i} />`)}
`:null}
- <${Rt} + <${Et} value=${t.value} onInput=${i=>e(t.key,i.target.value)} placeholder=${t.value?"":"not set"} @@ -6140,7 +6147,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s inputClass="flex-1 min-w-0 bg-field border border-border rounded-lg px-3 py-1.5 text-sm text-body outline-none focus:border-fg-muted font-mono" disabled=${s} /> - ${t.group==="custom"?Ue``:null}
- ${o?Ue`

${o}

`:null} + ${o?Ge`

${o}

`:null}
- `},_w=({onRestartRequired:t=()=>{}})=>{let[e,n]=y([]),[s,o]=y(()=>new Set),[r,i]=y([]),[a,l]=y(0),[c,d]=y(!1),[u,p]=y(!1),[f,g]=y(!1),[m,h]=y(""),b=ee("[]"),{data:x,error:v,loading:w,refresh:$}=ct("/api/env",Vr,{maxAgeMs:3e4}),S=q(V=>{if(!V)return;let Z=v3(V.vars||[]);b.current=Sw(Z),n(Z),i([]),o(new Set(V.reservedKeys||[])),V.restartRequired&&t(!0)},[t]),C=q(async()=>{try{let V=await $({force:!0});S(V)}catch(V){console.error("Failed to load env vars:",V)}},[S,$]);L(()=>{x&&(c||u||S(x))},[S,c,x,u]),L(()=>{v&&console.error("Failed to load env vars:",v)},[v]),L(()=>{d(Sw(e)!==b.current)},[e]);let _=(V,Z)=>{n(ue=>ue.map(re=>re.key===V?{...re,value:Z}:re))},k=V=>{n(Z=>Z.filter(ue=>ue.key!==V)),i(Z=>Z.filter(ue=>ue!==V))},A=async()=>{if(!u){p(!0);try{let V=e.filter(oe=>oe.editable&&!gc(oe?.key)).map(oe=>({key:oe.key,value:oe.value})),ue=!!(await dd(V))?.restartRequired;ue&&t(!0),I(ue?"Environment variables saved. Restart gateway to apply.":"Environment variables saved","success");let re=await $({force:!0});S(re),l(oe=>oe+1),d(!1)}catch(V){I("Failed to save: "+V.message,"error")}finally{p(!1)}}},[D,N]=y(""),U=V=>{let Z=V.split(` -`).map(re=>re.trim()).filter(Boolean).filter(re=>!re.startsWith("#")),ue=[];for(let re of Z){let oe=re.indexOf("=");oe>0&&ue.push({key:re.slice(0,oe).trim(),value:y3(re.slice(oe+1))})}return ue},O=V=>{let Z=0,ue=[],re=[],oe=[];return n(ne=>{let me=[...ne];for(let{key:pe,value:ce}of V){let ge=kw(pe);if(!ge)continue;if(gc(ge)){re.push(ge);continue}if(s.has(ge)){ue.push(ge);continue}let j=me.find(J=>J.key===ge);j?j.value=ce:(me.push({key:ge,value:ce,label:ge,group:"custom",hint:"",source:"env_file",editable:!0}),oe.push(ge)),Z++}return me}),oe.length&&i(ne=>[...ne,...oe]),{added:Z,blocked:ue,managedChannelKeys:re}},M=(V,Z)=>{let ue=(V.clipboardData||window.clipboardData).getData("text"),re=U(ue);if(re.length>1){V.preventDefault();let{added:oe,blocked:ne,managedChannelKeys:me}=O(re);if(h(""),N(""),ne.length){let pe=Array.from(new Set(ne));I(`Reserved vars can't be added: ${pe.join(", ")}`,"error")}if(me.length){let pe=Array.from(new Set(me));I(`Channel tokens are managed from Channels: ${pe.join(", ")}`,"error")}oe&&I(`Added ${oe} variable${oe!==1?"s":""}`,"success");return}if(re.length===1){V.preventDefault(),h(re[0].key),N(re[0].value);return}},R=V=>{let Z=U(V);if(Z.length===1){h(Z[0].key),N(Z[0].value);return}h(V)},B=V=>{let Z=U(V);if(Z.length===1){h(Z[0].key),N(Z[0].value);return}N(V)},E=()=>{let V=kw(m);if(V){if(gc(V)){I(`Channel tokens are managed from Channels: ${V}`,"error");return}if(s.has(V)){I(`Reserved var can't be added: ${V}`,"error");return}O([{key:V,value:D}]),h(""),N("")}},G=e.filter(V=>!gc(V?.key)),H={};for(let V of G){let Z=V.group||"custom";H[Z]||(H[Z]=[]),H[Z].push(V)}if(H.custom?.length){let V=new Set(r),Z=H.custom.filter(re=>!V.has(re.key)).sort((re,oe)=>String(re?.key||"").localeCompare(String(oe?.key||""))),ue=H.custom.filter(re=>V.has(re.key));H.custom=[...Z,...ue]}let z=S3(H.ai||[]),te=V=>V.map(Z=>Ue`<${_3} - key=${`${a}:${Z.key}`} - envVar=${Z} + `},Rw=({onRestartRequired:t=()=>{}})=>{let[e,n]=y([]),[s,o]=y(()=>new Set),[r,i]=y([]),[a,l]=y(0),[c,d]=y(!1),[u,p]=y(!1),[f,g]=y(!1),[m,h]=y(""),b=te("[]"),{data:x,error:v,loading:$,refresh:w}=pt("/api/env",Ur,{maxAgeMs:3e4}),S=G(j=>{if(!j)return;let J=C3(j.vars||[]);b.current=Tw(J),n(J),i([]),o(new Set(j.reservedKeys||[])),j.restartRequired&&t(!0)},[t]),C=G(async()=>{try{let j=await w({force:!0});S(j)}catch(j){console.error("Failed to load env vars:",j)}},[S,w]);R(()=>{x&&(c||u||S(x))},[S,c,x,u]),R(()=>{v&&console.error("Failed to load env vars:",v)},[v]),R(()=>{d(Tw(e)!==b.current)},[e]);let _=(j,J)=>{n(pe=>pe.map(le=>le.key===j?{...le,value:J}:le))},k=j=>{n(J=>J.filter(pe=>pe.key!==j)),i(J=>J.filter(pe=>pe!==j))},A=async()=>{if(!u){p(!0);try{let j=e.filter(ie=>ie.editable&&!vc(ie?.key)).map(ie=>({key:ie.key,value:ie.value})),pe=!!(await ud(j))?.restartRequired;pe&&t(!0),I(pe?"Environment variables saved. Restart gateway to apply.":"Environment variables saved","success");let le=await w({force:!0});S(le),l(ie=>ie+1),d(!1)}catch(j){I("Failed to save: "+j.message,"error")}finally{p(!1)}}},[D,O]=y(""),z=j=>{let J=j.split(` +`).map(le=>le.trim()).filter(Boolean).filter(le=>!le.startsWith("#")),pe=[];for(let le of J){let ie=le.indexOf("=");ie>0&&pe.push({key:le.slice(0,ie).trim(),value:S3(le.slice(ie+1))})}return pe},N=j=>{let J=0,pe=[],le=[],ie=[];return n(se=>{let xe=[...se];for(let{key:he,value:ue}of j){let be=Mw(he);if(!be)continue;if(vc(be)){le.push(be);continue}if(s.has(be)){pe.push(be);continue}let V=xe.find(q=>q.key===be);V?V.value=ue:(xe.push({key:be,value:ue,label:be,group:"custom",hint:"",source:"env_file",editable:!0}),ie.push(be)),J++}return xe}),ie.length&&i(se=>[...se,...ie]),{added:J,blocked:pe,managedChannelKeys:le}},M=(j,J)=>{let pe=(j.clipboardData||window.clipboardData).getData("text"),le=z(pe);if(le.length>1){j.preventDefault();let{added:ie,blocked:se,managedChannelKeys:xe}=N(le);if(h(""),O(""),se.length){let he=Array.from(new Set(se));I(`Reserved vars can't be added: ${he.join(", ")}`,"error")}if(xe.length){let he=Array.from(new Set(xe));I(`Channel tokens are managed from Channels: ${he.join(", ")}`,"error")}ie&&I(`Added ${ie} variable${ie!==1?"s":""}`,"success");return}if(le.length===1){j.preventDefault(),h(le[0].key),O(le[0].value);return}},L=j=>{let J=z(j);if(J.length===1){h(J[0].key),O(J[0].value);return}h(j)},B=j=>{let J=z(j);if(J.length===1){h(J[0].key),O(J[0].value);return}O(j)},E=()=>{let j=Mw(m);if(j){if(vc(j)){I(`Channel tokens are managed from Channels: ${j}`,"error");return}if(s.has(j)){I(`Reserved var can't be added: ${j}`,"error");return}N([{key:j,value:D}]),h(""),O("")}},U=e.filter(j=>!vc(j?.key)),F={};for(let j of U){let J=j.group||"custom";F[J]||(F[J]=[]),F[J].push(j)}if(F.custom?.length){let j=new Set(r),J=F.custom.filter(le=>!j.has(le.key)).sort((le,ie)=>String(le?.key||"").localeCompare(String(ie?.key||""))),pe=F.custom.filter(le=>j.has(le.key));F.custom=[...J,...pe]}let K=T3(F.ai||[]),re=j=>j.map(J=>Ge`<${R3} + key=${`${a}:${J.key}`} + envVar=${J} onChange=${_} onDelete=${k} disabled=${u} - />`),K=V=>{let Z=H[V]||[];if(!Z.length)return null;if(V==="ai"){let{visible:ue,hidden:re}=z,oe=f&&re.length>0;return Ue` + />`),Y=j=>{let J=F[j]||[];if(!J.length)return null;if(j==="ai"){let{visible:pe,hidden:le}=K,ie=f&&le.length>0;return Ge`

- ${ww[V]||V} + ${Aw[j]||j}

-
${te(ue)}
- ${re.length>0?Ue` +
${re(pe)}
+ ${le.length>0?Ge`
`:null} - ${oe?Ue`
- ${te(re)} + ${ie?Ge`
+ ${re(le)}
`:null}
- `}return Ue` + `}return Ge`

- ${ww[V]||V} + ${Aw[j]||j}

-
${te(Z)}
+
${re(J)}
- `};return w&&!e.length?Ue` + `};return $&&!e.length?Ge` <${Un} - header=${Ue`<${Pe} title="Envars" />`} + header=${Ge`<${De} title="Envars" />`} >
Loading environment variables...
- `:Ue` + `:Ge` <${Un} - header=${Ue` - <${Pe} + header=${Ge` + <${De} title="Envars" - actions=${Ue` - <${es} visible=${c}> - <${Y} + actions=${Ge` + <${ts} visible=${c}> + <${Z} onClick=${C} disabled=${u} tone="secondary" @@ -6212,7 +6219,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s idleLabel="Cancel" className="text-xs" /> - <${Y} + <${Z} onClick=${A} disabled=${u} loading=${u} @@ -6223,12 +6230,12 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s loadingLabel="Saving…" className="text-xs" /> - + `} /> `} > - ${g3.filter(V=>H[V]?.length).map(V=>K(V))} + ${$3.filter(j=>F[j]?.length).map(j=>Y(j))}
{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s type="text" value=${m} placeholder="KEY" - onInput=${V=>R(V.target.value)} - onPaste=${V=>M(V,"key")} - onKeyDown=${V=>V.key==="Enter"&&E()} + onInput=${j=>L(j.target.value)} + onPaste=${j=>M(j,"key")} + onKeyDown=${j=>j.key==="Enter"&&E()} class="w-full bg-field border border-border rounded-lg px-3 py-1.5 text-sm text-body outline-none focus:border-fg-muted font-mono uppercase" />
@@ -6258,9 +6265,9 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s type="text" value=${D} placeholder="value" - onInput=${V=>B(V.target.value)} - onPaste=${V=>M(V,"val")} - onKeyDown=${V=>V.key==="Enter"&&E()} + onInput=${j=>B(j.target.value)} + onPaste=${j=>M(j,"val")} + onKeyDown=${j=>j.key==="Enter"&&E()} class="flex-1 bg-field border border-border rounded-lg px-3 py-1.5 text-sm text-body outline-none focus:border-fg-muted font-mono" />
- `};var A3=P.bind(T),uf=({onRestartRequired:t=()=>{}})=>A3` - <${_w} onRestartRequired=${t} /> -`;var en=P.bind(T),M3=t=>{let e=Number(t||0);if(!Number.isFinite(e)||e<=0)return"0s";let n=Math.floor(e/1e3),s=Math.floor(n/86400),o=Math.floor(n/3600),r=Math.floor(n%3600/60),i=n%60;return s>0?`${s}d ${o%24}h ${r}m ${i}s`:o>0?`${o}h ${r}m ${i}s`:r>0?`${r}m ${i}s`:`${i}s`},T3=({label:t,currentVersion:e,fetchVersion:n,applyUpdate:s,updateInProgress:o=!1,onActionComplete:r=()=>{}})=>{let[i,a]=y(!1),[l,c]=y(e||null),[d,u]=y(null),[p,f]=y(!1),[g,m]=y(""),[h,b]=y(!1),[x,v]=y(!1),w=(()=>{try{return new URLSearchParams(window.location.search).get("simulateUpdate")==="1"}catch{return!1}})(),$=(()=>{if(!w)return null;try{return new URLSearchParams(window.location.search).get("simulateVersion")||"v0.0.0-preview"}catch{return"v0.0.0-preview"}})(),S=w||p,C=$||d,_=o||S,k=C?`Update to ${C}`:"Update",A="https://github.com/openclaw/openclaw/tags",D=S&&C;L(()=>{c(e||null)},[e]),L(()=>{let R=!0;return(async(E=!1)=>{try{let G=await n(E);if(!R)return;c(G.currentVersion||e||null),u(G.latestVersion||null),f(!!G.hasUpdate),m(G.ok?"":G.error||"")}catch(G){if(!R)return;m(G.message||"Could not check updates")}})(!1),()=>{R=!1}},[e,n]),L(()=>{if(o)return()=>{};let R=!0,B=setTimeout(async()=>{try{let E=await n(!0);if(!R)return;c(E.currentVersion||e||null),u(E.latestVersion||null),f(!!E.hasUpdate),m(E.ok?"":E.error||"")}catch{}},1200);return()=>{R=!1,clearTimeout(B)}},[o,e,n]),L(()=>{if(!S||!C){b(!1);return}b(!1)},[S,C]);let N=async()=>{let R=!!S;if(!(_?i||o:i)){a(!0),m("");try{let E=R?await s():await n(!0);c(E.currentVersion||l),u(E.latestVersion||null),f(!!E.hasUpdate),m(E.ok?"":E.error||""),R?E.ok?E.updated||E.restarting?I(E.restarting?`${t} updated \u2014 restarting...`:`Updated ${t} to ${E.currentVersion}`,"success"):I(`Already at latest ${t} version`,"success"):I(E.error||`${t} update failed`,"error"):E.hasUpdate&&E.latestVersion?I(`${t} update available: ${E.latestVersion}`,"warning"):I(`${t} is up to date`,"success"),await r({type:R?"update":"check",ok:!!E?.ok,result:E})}catch(E){m(E.message||(R?`Could not update ${t}`:"Could not check updates")),I(R?`Could not update ${t}`:"Could not check updates","error"),await r({type:R?"update":"check",ok:!1,error:E})}finally{a(!1)}}},U=()=>{if(!(_?i||o:i)){if(S&&C&&!h){v(!0);return}N()}},O=()=>{v(!1),N()},M=_?i||o:i;return en` + `};var L3=P.bind(T),ff=({onRestartRequired:t=()=>{}})=>L3` + <${Rw} onRestartRequired=${t} /> +`;var en=P.bind(T),E3=t=>{let e=Number(t||0);if(!Number.isFinite(e)||e<=0)return"0s";let n=Math.floor(e/1e3),s=Math.floor(n/86400),o=Math.floor(n/3600),r=Math.floor(n%3600/60),i=n%60;return s>0?`${s}d ${o%24}h ${r}m ${i}s`:o>0?`${o}h ${r}m ${i}s`:r>0?`${r}m ${i}s`:`${i}s`},I3=({label:t,currentVersion:e,fetchVersion:n,applyUpdate:s,updateInProgress:o=!1,onActionComplete:r=()=>{}})=>{let[i,a]=y(!1),[l,c]=y(e||null),[d,u]=y(null),[p,f]=y(!1),[g,m]=y(""),[h,b]=y(!1),[x,v]=y(!1),$=(()=>{try{return new URLSearchParams(window.location.search).get("simulateUpdate")==="1"}catch{return!1}})(),w=(()=>{if(!$)return null;try{return new URLSearchParams(window.location.search).get("simulateVersion")||"v0.0.0-preview"}catch{return"v0.0.0-preview"}})(),S=$||p,C=w||d,_=o||S,k=C?`Update to ${C}`:"Update",A="https://github.com/openclaw/openclaw/tags",D=S&&C;R(()=>{c(e||null)},[e]),R(()=>{let L=!0;return(async(E=!1)=>{try{let U=await n(E);if(!L)return;c(U.currentVersion||e||null),u(U.latestVersion||null),f(!!U.hasUpdate),m(U.ok?"":U.error||"")}catch(U){if(!L)return;m(U.message||"Could not check updates")}})(!1),()=>{L=!1}},[e,n]),R(()=>{if(o)return()=>{};let L=!0,B=setTimeout(async()=>{try{let E=await n(!0);if(!L)return;c(E.currentVersion||e||null),u(E.latestVersion||null),f(!!E.hasUpdate),m(E.ok?"":E.error||"")}catch{}},1200);return()=>{L=!1,clearTimeout(B)}},[o,e,n]),R(()=>{if(!S||!C){b(!1);return}b(!1)},[S,C]);let O=async()=>{let L=!!S;if(!(_?i||o:i)){a(!0),m("");try{let E=L?await s():await n(!0);c(E.currentVersion||l),u(E.latestVersion||null),f(!!E.hasUpdate),m(E.ok?"":E.error||""),L?E.ok?E.updated||E.restarting?I(E.restarting?`${t} updated \u2014 restarting...`:`Updated ${t} to ${E.currentVersion}`,"success"):I(`Already at latest ${t} version`,"success"):I(E.error||`${t} update failed`,"error"):E.hasUpdate&&E.latestVersion?I(`${t} update available: ${E.latestVersion}`,"warning"):I(`${t} is up to date`,"success"),await r({type:L?"update":"check",ok:!!E?.ok,result:E})}catch(E){m(E.message||(L?`Could not update ${t}`:"Could not check updates")),I(L?`Could not update ${t}`:"Could not check updates","error"),await r({type:L?"update":"check",ok:!1,error:E})}finally{a(!1)}}},z=()=>{if(!(_?i||o:i)){if(S&&C&&!h){v(!0);return}O()}},N=()=>{v(!1),O()},M=_?i||o:i;return en`

@@ -6300,7 +6307,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s `} ${D?en` <${tn} - onClick=${U} + onClick=${z} loading=${M} warning=${_} idleLabel=${_?k:"Check updates"} @@ -6309,7 +6316,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s /> `:en` <${tn} - onClick=${U} + onClick=${z} loading=${M} warning=${_} idleLabel=${_?k:"Check updates"} @@ -6329,7 +6336,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s >View changelog <${tn} - onClick=${U} + onClick=${z} loading=${M} warning=${_} idleLabel=${k} @@ -6338,7 +6345,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s />

`} - <${st} + <${rt} visible=${x} title="Update without changelog?" message="Are you sure you want to update without viewing the changelog?" @@ -6346,9 +6353,9 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s cancelLabel="Cancel" confirmTone="warning" onCancel=${()=>v(!1)} - onConfirm=${O} + onConfirm=${N} /> - `},bc=({status:t,openclawVersion:e,restarting:n=!1,onRestart:s,watchdogStatus:o=null,onOpenWatchdog:r,onRepair:i,repairing:a=!1,openclawUpdateInProgress:l=!1,onOpenclawVersionActionComplete:c=()=>{},onOpenclawUpdate:d=ma})=>{let[u,p]=y(()=>Date.now()),f=t==="running"&&!n,g=f?"ac-status-dot ac-status-dot--healthy":"w-2 h-2 rounded-full bg-yellow-500 animate-pulse",m=o?.lifecycle==="crash_loop"?"crash_loop":o?.health,h=m==="healthy"?"ac-status-dot ac-status-dot--healthy ac-status-dot--healthy-offset":m==="degraded"?"bg-yellow-500":m==="unhealthy"||m==="crash_loop"?"bg-red-500":"bg-gray-500",b=m==="unknown"?"initializing":m||"unknown",x=a||!!o?.operationInProgress,v=m==="degraded"&&!!r,w=x||o?.health==="degraded"&&!r||o?.lifecycle==="crash_loop"||o?.health==="unhealthy"||o?.health==="crashed",$=F(()=>{let S=o?.uptimeStartedAt?Date.parse(o.uptimeStartedAt):null;return Number.isFinite(S)?Math.max(0,u-S):o?.uptimeMs||0},[o?.uptimeStartedAt,o?.uptimeMs,u]);return L(()=>{let S=setInterval(()=>{p(Date.now())},1e3);return()=>clearInterval(S)},[]),en`
+ `},$c=({status:t,openclawVersion:e,restarting:n=!1,onRestart:s,watchdogStatus:o=null,onOpenWatchdog:r,onRepair:i,repairing:a=!1,openclawUpdateInProgress:l=!1,onOpenclawVersionActionComplete:c=()=>{},onOpenclawUpdate:d=ya})=>{let[u,p]=y(()=>Date.now()),f=t==="running"&&!n,g=f?"ac-status-dot ac-status-dot--healthy":"w-2 h-2 rounded-full bg-yellow-500 animate-pulse",m=o?.lifecycle==="crash_loop"?"crash_loop":o?.health,h=m==="healthy"?"ac-status-dot ac-status-dot--healthy ac-status-dot--healthy-offset":m==="degraded"?"bg-yellow-500":m==="unhealthy"||m==="crash_loop"?"bg-red-500":"bg-gray-500",b=m==="unknown"?"initializing":m||"unknown",x=a||!!o?.operationInProgress,v=m==="degraded"&&!!r,$=x||o?.health==="degraded"&&!r||o?.lifecycle==="crash_loop"||o?.health==="unhealthy"||o?.health==="crashed",w=W(()=>{let S=o?.uptimeStartedAt?Date.parse(o.uptimeStartedAt):null;return Number.isFinite(S)?Math.max(0,u-S):o?.uptimeMs||0},[o?.uptimeStartedAt,o?.uptimeMs,u]);return R(()=>{let S=setInterval(()=>{p(Date.now())},1e3);return()=>clearInterval(S)},[]),en`
@@ -6361,7 +6368,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
${!n&&f?en` Uptime: ${M3($)}Uptime: ${E3(w)} `:null} <${tn} @@ -6406,7 +6413,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s loadingLabel="Inspect" className="w-full justify-center" /> - `:w?en` + `:$?en` <${tn} onClick=${i} loading=${x} @@ -6424,16 +6431,16 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
- <${T3} + <${I3} label="OpenClaw" currentVersion=${e} - fetchVersion=${mm} + fetchVersion=${gm} applyUpdate=${d} updateInProgress=${l} onActionComplete=${c} />
-
`};var $r=P.bind(T),P3={webchat:"Browser",cli:"CLI"},R3=t=>P3[t.clientMode]||t.clientId||"Device",L3=t=>{let e=[];return t.platform&&e.push(t.platform),t.role&&e.push(t.role),e.join(" \xB7 ")},E3=({d:t,onApprove:e,onReject:n})=>{let[s,o]=y(null),r=async l=>{o(l);try{l==="approve"?await e(t.id):await n(t.id)}catch{o(null)}},i=R3(t),a=L3(t);return s==="approve"?$r` +
`};var $r=P.bind(T),D3={webchat:"Browser",cli:"CLI"},O3=t=>D3[t.clientMode]||t.clientId||"Device",N3=t=>{let e=[];return t.platform&&e.push(t.platform),t.role&&e.push(t.role),e.join(" \xB7 ")},B3=({d:t,onApprove:e,onReject:n})=>{let[s,o]=y(null),r=async l=>{o(l);try{l==="approve"?await e(t.id):await n(t.id)}catch{o(null)}},i=O3(t),a=N3(t);return s==="approve"?$r`
Approved ${i} @@ -6448,14 +6455,14 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s ${a&&$r`${a}`}
- <${Y} + <${Z} onClick=${()=>r("approve")} tone="success" size="sm" idleLabel="Approve" className="font-medium px-3 py-1.5" /> - <${Y} + <${Z} onClick=${()=>r("reject")} tone="secondary" size="sm" @@ -6463,12 +6470,12 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s className="font-medium px-3 py-1.5" />
-
`},xc=({pending:t,onApprove:e,onReject:n})=>!t||t.length===0?null:$r` +
`},wc=({pending:t,onApprove:e,onReject:n})=>!t||t.length===0?null:$r`

Pending device pairings

- ${t.map(s=>$r`<${E3} key=${s.id} d=${s} onApprove=${e} onReject=${n} />`)} -
`;var fo=P.bind(T),Vi=[{key:"gmail",icon:"\u{1F4E7}",label:"Gmail",defaultRead:!0,defaultWrite:!1},{key:"calendar",icon:"\u{1F4C5}",label:"Calendar",defaultRead:!0,defaultWrite:!0},{key:"drive",icon:"\u{1F4C1}",label:"Drive",defaultRead:!0,defaultWrite:!1},{key:"sheets",icon:"\u{1F4CA}",label:"Sheets",defaultRead:!0,defaultWrite:!1},{key:"docs",icon:"\u{1F4DD}",label:"Docs",defaultRead:!0,defaultWrite:!1},{key:"tasks",icon:"\u2705",label:"Tasks",defaultRead:!1,defaultWrite:!1},{key:"contacts",icon:"\u{1F464}",label:"Contacts",defaultRead:!1,defaultWrite:!1},{key:"meet",icon:"\u{1F3A5}",label:"Meet",defaultRead:!1,defaultWrite:!1}],I3={gmail:"gmail.googleapis.com",calendar:"calendar-json.googleapis.com",tasks:"tasks.googleapis.com",drive:"drive.googleapis.com",contacts:"people.googleapis.com",sheets:"sheets.googleapis.com",docs:"docs.googleapis.com",meet:"meet.googleapis.com"};function Aw(t){return`https://console.developers.google.com/apis/api/${I3[t]||""}/overview`}function Mw({scopes:t,onToggle:e,apiStatus:n,loading:s}){let[o,r]=y(!1),i=n||{},a=5,l=Vi.length>a,c=o?Vi:Vi.slice(0,a);return fo`
- ${c.map(d=>{let u=t.includes(`${d.key}:read`),p=t.includes(`${d.key}:write`),f=i[d.key],g=null;return s&&!f&&(u||p)?g=fo``:f&&(f.status==="ok"?g=fo`API ✓`:f.status==="not_enabled"?g=fo`Enable API`:f.status==="error"&&(g=fo`Enable API`)),fo` + ${t.map(s=>$r`<${B3} key=${s.id} d=${s} onApprove=${e} onReject=${n} />`)} +
`;var fo=P.bind(T),Ui=[{key:"gmail",icon:"\u{1F4E7}",label:"Gmail",defaultRead:!0,defaultWrite:!1},{key:"calendar",icon:"\u{1F4C5}",label:"Calendar",defaultRead:!0,defaultWrite:!0},{key:"drive",icon:"\u{1F4C1}",label:"Drive",defaultRead:!0,defaultWrite:!1},{key:"sheets",icon:"\u{1F4CA}",label:"Sheets",defaultRead:!0,defaultWrite:!1},{key:"docs",icon:"\u{1F4DD}",label:"Docs",defaultRead:!0,defaultWrite:!1},{key:"tasks",icon:"\u2705",label:"Tasks",defaultRead:!1,defaultWrite:!1},{key:"contacts",icon:"\u{1F464}",label:"Contacts",defaultRead:!1,defaultWrite:!1},{key:"meet",icon:"\u{1F3A5}",label:"Meet",defaultRead:!1,defaultWrite:!1}],F3={gmail:"gmail.googleapis.com",calendar:"calendar-json.googleapis.com",tasks:"tasks.googleapis.com",drive:"drive.googleapis.com",contacts:"people.googleapis.com",sheets:"sheets.googleapis.com",docs:"docs.googleapis.com",meet:"meet.googleapis.com"};function Lw(t){return`https://console.developers.google.com/apis/api/${F3[t]||""}/overview`}function Ew({scopes:t,onToggle:e,apiStatus:n,loading:s}){let[o,r]=y(!1),i=n||{},a=5,l=Ui.length>a,c=o?Ui:Ui.slice(0,a);return fo`
+ ${c.map(d=>{let u=t.includes(`${d.key}:read`),p=t.includes(`${d.key}:write`),f=i[d.key],g=null;return s&&!f&&(u||p)?g=fo``:f&&(f.status==="ok"?g=fo`API ✓`:f.status==="not_enabled"?g=fo`Enable API`:f.status==="error"&&(g=fo`Enable API`)),fo`
${d.icon} ${d.label}
@@ -6483,17 +6490,17 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s onclick=${()=>r(d=>!d)} class="ml-3 text-xs text-fg-muted hover:text-body" > - ${o?"Show fewer services":`Show more services (${Vi.length-a})`} + ${o?"Show fewer services":`Show more services (${Ui.length-a})`} `:null} -
`}function Tw(t,e){let n=t.includes(e),s=n?t.filter(o=>o!==e):[...t,e];if(e.endsWith(":write")&&!n){let o=e.replace(":write",":read");s.includes(o)||s.push(o)}if(e.endsWith(":read")&&n){let o=e.replace(":read",":write");s=s.filter(r=>r!==o)}return s}function wr(){let t=[];for(let e of Vi)e.defaultRead&&t.push(`${e.key}:read`),e.defaultWrite&&t.push(`${e.key}:write`);return t}var kr=P.bind(T),Pw=({visible:t,onClose:e,onSaved:n,title:s="Connect Google Workspace",submitLabel:o="Connect Google",defaultInstrType:r="workspace",client:i="default",personal:a=!1,accountId:l="",initialValues:c={}})=>{let[d,u]=y(""),[p,f]=y(""),[g,m]=y(""),[h,b]=y(""),[x,v]=y(!1),[w,$]=y(r),[S,C]=y(!1),_=ee(null);if(L(()=>{t&&(u(String(c.clientId||"")),f(String(c.clientSecret||"")),m(String(c.email||"")),$(r),b(""),C(!1))},[t,c,r]),!t)return null;let k=`${window.location.origin}/auth/google/callback`,A=async()=>{try{await navigator.clipboard.writeText(k),C(!0),window.setTimeout(()=>C(!1),1500)}catch{b("Unable to copy redirect URI")}},D=async R=>{let B=R.target.files[0];if(B)try{let E=await B.text(),G=JSON.parse(E),H=G.installed||G.web||G;H.client_id&&u(H.client_id),H.client_secret&&f(H.client_secret)}catch{b("Invalid JSON file")}},N=async()=>{if(b(""),!d||!p||!g){b("Client ID, Client Secret, and Email are required");return}v(!0);try{let R=await zh({clientId:d,clientSecret:p,email:g,client:i,personal:a,accountId:l});R.ok?(e(),n?.(R.account)):b(R.error||"Failed to save credentials")}catch{b("Request failed")}finally{v(!1)}},U=R=>`flex-1 text-center border-0 cursor-pointer transition-colors ${w===R?"":"hover:text-white"}`,O=R=>"font-family: inherit; font-size: 11px; letter-spacing: 0.03em; padding: 5px 10px;"+(w===R?" color: var(--accent); background: var(--bg-active);":" color: var(--text-muted); background: transparent;"),M=()=>kr` +
`}function Iw(t,e){let n=t.includes(e),s=n?t.filter(o=>o!==e):[...t,e];if(e.endsWith(":write")&&!n){let o=e.replace(":write",":read");s.includes(o)||s.push(o)}if(e.endsWith(":read")&&n){let o=e.replace(":read",":write");s=s.filter(r=>r!==o)}return s}function wr(){let t=[];for(let e of Ui)e.defaultRead&&t.push(`${e.key}:read`),e.defaultWrite&&t.push(`${e.key}:write`);return t}var kr=P.bind(T),Dw=({visible:t,onClose:e,onSaved:n,title:s="Connect Google Workspace",submitLabel:o="Connect Google",defaultInstrType:r="workspace",client:i="default",personal:a=!1,accountId:l="",initialValues:c={}})=>{let[d,u]=y(""),[p,f]=y(""),[g,m]=y(""),[h,b]=y(""),[x,v]=y(!1),[$,w]=y(r),[S,C]=y(!1),_=te(null);if(R(()=>{t&&(u(String(c.clientId||"")),f(String(c.clientSecret||"")),m(String(c.email||"")),w(r),b(""),C(!1))},[t,c,r]),!t)return null;let k=`${window.location.origin}/auth/google/callback`,A=async()=>{try{await navigator.clipboard.writeText(k),C(!0),window.setTimeout(()=>C(!1),1500)}catch{b("Unable to copy redirect URI")}},D=async L=>{let B=L.target.files[0];if(B)try{let E=await B.text(),U=JSON.parse(E),F=U.installed||U.web||U;F.client_id&&u(F.client_id),F.client_secret&&f(F.client_secret)}catch{b("Invalid JSON file")}},O=async()=>{if(b(""),!d||!p||!g){b("Client ID, Client Secret, and Email are required");return}v(!0);try{let L=await Kh({clientId:d,clientSecret:p,email:g,client:i,personal:a,accountId:l});L.ok?(e(),n?.(L.account)):b(L.error||"Failed to save credentials")}catch{b("Request failed")}finally{v(!1)}},z=L=>`flex-1 text-center border-0 cursor-pointer transition-colors ${$===L?"":"hover:text-white"}`,N=L=>"font-family: inherit; font-size: 11px; letter-spacing: 0.03em; padding: 5px 10px;"+($===L?" color: var(--accent); background: var(--bg-active);":" color: var(--text-muted); background: transparent;"),M=()=>kr`
R.target.select()} - onclick=${R=>R.target.select()} + onFocus=${L=>L.target.select()} + onclick=${L=>L.target.select()} class="flex-1 min-w-0 bg-field border border-border rounded px-2 py-1 text-body text-xs focus:outline-none focus:border-fg-muted" />
- `;return kr` <${Te} + `;return kr` <${Ie} visible=${t} onClose=${e} closeOnOverlayClick=${!1} panelClassName="bg-modal border border-border rounded-xl p-6 max-w-lg w-full space-y-4" > - <${Pe} + <${De} title=${s} actions=${kr` `} /> @@ -6546,21 +6553,21 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s style="border: 1px solid var(--border); border-radius: 6px; background: rgba(255,255,255,0.02)" >
- ${w==="personal"?kr` + ${$==="personal"?kr`
  1. @@ -6704,9 +6711,9 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
- <${Rt} + <${Et} value=${d} - onInput=${R=>u(R.target.value)} + onInput=${L=>u(L.target.value)} placeholder="xxxx.apps.googleusercontent.com" inputClass="flex-1 bg-field border border-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-fg-muted" /> @@ -6715,9 +6722,9 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s - <${Rt} + <${Et} value=${p} - onInput=${R=>f(R.target.value)} + onInput=${L=>f(L.target.value)} placeholder="GOCSPX-..." inputClass="flex-1 bg-field border border-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-fg-muted" /> @@ -6729,7 +6736,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s m(R.target.value)} + onInput=${L=>m(L.target.value)} placeholder="you@gmail.com" class="w-full bg-field border border-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-fg-muted" /> @@ -6737,8 +6744,8 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
- <${Y} - onClick=${N} + <${Z} + onClick=${O} disabled=${x} loading=${x} tone="primary" @@ -6749,14 +6756,14 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s />
${h?kr`
${h}
`:null} - `};var Rw=P.bind(T),D3=({watchStatus:t,busy:e=!1})=>e?{label:t?.enabled?"Stopping":"Starting",tone:"warning"}:t?.enabled?t.enabled&&!t.running?{label:"Error",tone:"danger"}:{label:"Watching",tone:"success"}:{label:"Stopped",tone:"neutral"},Lw=({account:t,watchStatus:e=null,busy:n=!1,onEnable:s=()=>{},onDisable:o=()=>{},onOpenWebhook:r=()=>{}})=>{if(!(Array.isArray(t?.activeScopes)?t.activeScopes.includes("gmail:read"):Array.isArray(t?.services)?t.services.includes("gmail:read"):!1))return Rw` + `};var Ow=P.bind(T),W3=({watchStatus:t,busy:e=!1})=>e?{label:t?.enabled?"Stopping":"Starting",tone:"warning"}:t?.enabled?t.enabled&&!t.running?{label:"Error",tone:"danger"}:{label:"Watching",tone:"success"}:{label:"Stopped",tone:"neutral"},Nw=({account:t,watchStatus:e=null,busy:n=!1,onEnable:s=()=>{},onDisable:o=()=>{},onOpenWebhook:r=()=>{}})=>{if(!(Array.isArray(t?.activeScopes)?t.activeScopes.includes("gmail:read"):Array.isArray(t?.services)?t.services.includes("gmail:read"):!1))return Ow`
Gmail watch requires gmail:read. Add it in permissions above, then update permissions.
- `;let a=D3({watchStatus:e,busy:n}),l=!!e?.enabled;return Rw` + `;let a=W3({watchStatus:e,busy:n}),l=!!e?.enabled;return Ow`
{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s onClick=${c=>c.stopPropagation()} onKeyDown=${c=>c.stopPropagation()} > - <${le} tone=${a.tone}>${a.label} + <${de} tone=${a.tone}>${a.label} <${vn} checked=${l} disabled=${n} @@ -6785,7 +6792,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s />
- `};var ji=P.bind(T),N3=(t=[],e=[])=>t.length===e.length&&t.every(n=>e.includes(n)),Ew=({account:t,personal:e=!1,expanded:n,onToggleExpanded:s,scopes:o=[],savedScopes:r=[],apiStatus:i={},checkingApis:a=!1,onToggleScope:l,onCheckApis:c,onUpdatePermissions:d,onEditCredentials:u,onDisconnect:p,gmailWatchStatus:f=null,gmailWatchBusy:g=!1,onEnableGmailWatch:m,onDisableGmailWatch:h,onOpenGmailSetup:b,onOpenGmailWebhook:x})=>{let v=!N3(o,r);return ji` + `};var Ki=P.bind(T),H3=(t=[],e=[])=>t.length===e.length&&t.every(n=>e.includes(n)),Bw=({account:t,personal:e=!1,expanded:n,onToggleExpanded:s,scopes:o=[],savedScopes:r=[],apiStatus:i={},checkingApis:a=!1,onToggleScope:l,onCheckApis:c,onUpdatePermissions:d,onEditCredentials:u,onDisconnect:p,gmailWatchStatus:f=null,gmailWatchBusy:g=!1,onEnableGmailWatch:m,onDisableGmailWatch:h,onOpenGmailSetup:b,onOpenGmailWebhook:x})=>{let v=!H3(o,r);return Ki`
- ${e?ji`<${le} tone="neutral">Personal`:null} - <${le} tone=${t.authenticated?"success":"warning"}> + ${e?Ki`<${de} tone="neutral">Personal`:null} + <${de} tone=${t.authenticated?"success":"warning"}> ${t.authenticated?"Connected":"Awaiting sign-in"} - + ${n?"\u25BE":"\u25B8"}
- ${n?ji` + ${n?Ki`
Select permissions - ${t.authenticated?ji``:null}
- <${Mw} + <${Ew} scopes=${o} - onToggle=${w=>l?.(t.id,w)} + onToggle=${$=>l?.(t.id,$)} apiStatus=${t.authenticated?i:{}} loading=${t.authenticated&&a} /> - ${t.authenticated?ji` + ${t.authenticated?Ki`
@@ -6835,7 +6842,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s Configure
- <${Lw} + <${Nw} account=${t} watchStatus=${f} busy=${g} @@ -6875,22 +6882,22 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s
`:null}
- `};var pf=P.bind(T),Iw=({visible:t,onClose:e,onSubmit:n,loading:s=!1,defaultEmail:o="",title:r="Add Company Account"})=>{let[i,a]=y(""),[l,c]=y("");if(L(()=>{t&&(a(String(o||"")),c(""))},[t,o]),!t)return null;let d=async()=>{c("");let u=String(i||"").trim();if(!u){c("Email is required");return}await n?.({email:u,setError:c})};return pf`<${Te} + `};var hf=P.bind(T),Fw=({visible:t,onClose:e,onSubmit:n,loading:s=!1,defaultEmail:o="",title:r="Add Company Account"})=>{let[i,a]=y(""),[l,c]=y("");if(R(()=>{t&&(a(String(o||"")),c(""))},[t,o]),!t)return null;let d=async()=>{c("");let u=String(i||"").trim();if(!u){c("Email is required");return}await n?.({email:u,setError:c})};return hf`<${Ie} visible=${t} onClose=${e} closeOnOverlayClick=${!1} panelClassName="bg-modal border border-border rounded-xl p-6 max-w-md w-full space-y-4" > - <${Pe} + <${De} title=${r} - actions=${pf` + actions=${hf` `} /> @@ -6910,10 +6917,10 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s class="w-full bg-field border border-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-fg-muted" />
- ${l?pf`
${l}
`:null} + ${l?hf`
${l}
`:null}
- <${Y} + <${Z} onClick=${d} disabled=${s} loading=${s} @@ -6924,7 +6931,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s className="w-full px-4 py-2 rounded-lg text-sm" />
- `};var Dw=({gatewayStatus:t})=>{let e=ee(!1),{data:n,loading:s,refresh:o}=ct("/api/google/accounts",Wh,{maxAgeMs:3e4}),r=F(()=>Array.isArray(n?.accounts)?n.accounts:[],[n?.accounts]),i=!!n?.hasCompanyCredentials,a=!!n?.hasPersonalCredentials,l=q(async()=>o({force:!0}),[o]);return L(()=>{if(t!=="running"){e.current=!1;return}e.current||(e.current=!0,l().catch(()=>{}))},[t,l]),{accounts:r,loading:s,hasCompanyCredentials:i,hasPersonalCredentials:a,refreshAccounts:l}};var Nw=({gatewayStatus:t,accounts:e=[]})=>{let[n,s]=y({}),[o,r]=y(!1),i=F(()=>e.map(x=>String(x?.id||"").trim()).filter(Boolean).sort().join("|"),[e]),{data:a,loading:l,refresh:c}=ct("/api/gmail/config",Gh,{enabled:t==="running",maxAgeMs:3e4}),d=q(async()=>c({force:!0}),[c]);L(()=>{t==="running"&&e.length&&d().catch(()=>{})},[i,e.length,t,d]);let u=F(()=>{let x=new Map;for(let v of a?.accounts||[])x.set(String(v.accountId||""),v);return x},[a]),p=F(()=>{let x=new Map;for(let v of a?.clients||[])x.set(String(v.client||"default"),v);return x},[a]),f=(x,v)=>{s(w=>{let $=String(x||"");if(!$)return w;if(v)return{...w,[$]:!0};if(!w[$])return w;let S={...w};return delete S[$],S})},g=q(async(x,{destination:v=null}={})=>{let w=String(x||"");f(w,!0);try{let $=await Jh(w,{destination:v});return await d(),$}finally{f(w,!1)}},[d]),m=q(async x=>{let v=String(x||"");f(v,!0);try{await Zh(v),await d()}finally{f(v,!1)}},[d]),h=q(async(x="")=>{let v=String(x||"");v&&f(v,!0);try{await Yh({accountId:v,force:!0}),await d()}finally{v&&f(v,!1)}},[d]),b=q(async({client:x="default",projectId:v="",regeneratePushToken:w=!1}={})=>{r(!0);try{let $=await qh({client:x,projectId:v,regeneratePushToken:w});return await d(),$}catch($){throw String($?.message||"").toLowerCase().includes("not found")?new Error("Gmail watch API route not found. Restart AlphaClaw so /api/gmail routes are loaded."):$}finally{r(!1)}},[d]);return{loading:l,config:a,watchByAccountId:u,clientConfigByClient:p,busyByAccountId:n,savingClient:o,refresh:d,saveClientSetup:b,startWatchForAccount:g,stopWatchForAccount:m,renewForAccount:h}};var mt=P.bind(T),O3=async t=>{let e=String(t||"");if(!e)return!1;try{if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{let n=document.createElement("textarea");return n.value=e,n.setAttribute("readonly",""),n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),!0}catch{return!1}},Ow=["Install + Authenticate gcloud","Enable APIs","Create Topic + IAM","Create Push Subscription","Build with your Agent"],B3=Ow.slice(0,3),yc=Ds,vc=(t="",e=()=>{})=>mt` + `};var Ww=({gatewayStatus:t})=>{let e=te(!1),{data:n,loading:s,refresh:o}=pt("/api/google/accounts",jh,{maxAgeMs:3e4}),r=W(()=>Array.isArray(n?.accounts)?n.accounts:[],[n?.accounts]),i=!!n?.hasCompanyCredentials,a=!!n?.hasPersonalCredentials,l=G(async()=>o({force:!0}),[o]);return R(()=>{if(t!=="running"){e.current=!1;return}e.current||(e.current=!0,l().catch(()=>{}))},[t,l]),{accounts:r,loading:s,hasCompanyCredentials:i,hasPersonalCredentials:a,refreshAccounts:l}};var Hw=({gatewayStatus:t,accounts:e=[]})=>{let[n,s]=y({}),[o,r]=y(!1),i=W(()=>e.map(x=>String(x?.id||"").trim()).filter(Boolean).sort().join("|"),[e]),{data:a,loading:l,refresh:c}=pt("/api/gmail/config",Jh,{enabled:t==="running",maxAgeMs:3e4}),d=G(async()=>c({force:!0}),[c]);R(()=>{t==="running"&&e.length&&d().catch(()=>{})},[i,e.length,t,d]);let u=W(()=>{let x=new Map;for(let v of a?.accounts||[])x.set(String(v.accountId||""),v);return x},[a]),p=W(()=>{let x=new Map;for(let v of a?.clients||[])x.set(String(v.client||"default"),v);return x},[a]),f=(x,v)=>{s($=>{let w=String(x||"");if(!w)return $;if(v)return{...$,[w]:!0};if(!$[w])return $;let S={...$};return delete S[w],S})},g=G(async(x,{destination:v=null}={})=>{let $=String(x||"");f($,!0);try{let w=await Yh($,{destination:v});return await d(),w}finally{f($,!1)}},[d]),m=G(async x=>{let v=String(x||"");f(v,!0);try{await Xh(v),await d()}finally{f(v,!1)}},[d]),h=G(async(x="")=>{let v=String(x||"");v&&f(v,!0);try{await Qh({accountId:v,force:!0}),await d()}finally{v&&f(v,!1)}},[d]),b=G(async({client:x="default",projectId:v="",regeneratePushToken:$=!1}={})=>{r(!0);try{let w=await Zh({client:x,projectId:v,regeneratePushToken:$});return await d(),w}catch(w){throw String(w?.message||"").toLowerCase().includes("not found")?new Error("Gmail watch API route not found. Restart AlphaClaw so /api/gmail routes are loaded."):w}finally{r(!1)}},[d]);return{loading:l,config:a,watchByAccountId:u,clientConfigByClient:p,busyByAccountId:n,savingClient:o,refresh:d,saveClientSetup:b,startWatchForAccount:g,stopWatchForAccount:m,renewForAccount:h}};var xt=P.bind(T),V3=async t=>{let e=String(t||"");if(!e)return!1;try{if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{let n=document.createElement("textarea");return n.value=e,n.setAttribute("readonly",""),n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),!0}catch{return!1}},Vw=["Install + Authenticate gcloud","Enable APIs","Create Topic + IAM","Create Push Subscription","Build with your Agent"],j3=Vw.slice(0,3),kc=Os,Sc=(t="",e=()=>{})=>xt`
     
-`,Bw=({visible:t=!1,account:e=null,clientConfig:n=null,saving:s=!1,onClose:o=()=>{},onSaveSetup:r=async()=>{},onFinish:i=async()=>{}})=>{let[a,l]=y(0),[c,d]=y(""),[u,p]=y(!1),[f,g]=y(""),[m,h]=y(!1),[b,x]=y(!1),[v,w]=y(!1),[$,S]=y(!1),[C,_]=y(!1),{selectedSessionKey:k,setSelectedSessionKey:A,loading:D,error:N}=yr({enabled:t,filter:pc}),{sessions:U,destinationSessionKey:O,setDestinationSessionKey:M,selectedDestination:R}=Ns({enabled:t,resetKey:String(e?.id||"")});L(()=>{t&&(l(0),g(""),d(""),p(!1),h(!1),x(!1),w(!1),S(!1),_(!!n?.webhookExists))},[t,e?.id]);let B=n?.commands||null,E=!!(String(n?.projectId||"").trim()||B),G=u||!E&&!m,H=String(c||"").trim()||String(n?.projectId||"").trim()||"",z=C,te=z?B3:Ow,K=te.length,V=String(e?.client||n?.client||"default").trim()||"default",Z=F(()=>G?String(c||"").trim().length>0:!0,[G,c]),ue=q(async pe=>{if(await O3(pe)){I("Copied to clipboard","success");return}I("Could not copy text","error")},[]),re=q(()=>{g(""),d(String(n?.projectId||"").trim()),h(!1),p(!0)},[n?.projectId]),oe=async()=>{try{g(""),await i({client:V,projectId:String(c||"").trim(),destination:R}),x(!0),l(pe=>Math.min(pe+1,K-1))}catch(pe){g(pe.message||"Could not finish setup")}},ne=async()=>{if(!s){if(G){if(!Z)return;g("");try{await r({client:V,projectId:String(c||"").trim()}),p(!1),h(!0)}catch(pe){g(pe.message||"Could not save project id");return}return}l(pe=>Math.min(pe+1,K-1))}},me=async()=>{if(!(v||$))try{w(!0);let ce=`I just enabled Gmail watch for "${String(e?.email||"this account").trim()||"this account"}", set up the webhook, and created the transform file. Help me set up what I want to do with incoming email.`;await fa({message:ce,sessionKey:k}),S(!0),I("Message sent to your agent","success")}catch(pe){I(pe.message||"Could not send message to agent","error")}finally{w(!1)}};return mt` - <${Te} +`,jw=({visible:t=!1,account:e=null,clientConfig:n=null,saving:s=!1,onClose:o=()=>{},onSaveSetup:r=async()=>{},onFinish:i=async()=>{}})=>{let[a,l]=y(0),[c,d]=y(""),[u,p]=y(!1),[f,g]=y(""),[m,h]=y(!1),[b,x]=y(!1),[v,$]=y(!1),[w,S]=y(!1),[C,_]=y(!1),{selectedSessionKey:k,setSelectedSessionKey:A,loading:D,error:O}=yr({enabled:t,filter:gc}),{sessions:z,destinationSessionKey:N,setDestinationSessionKey:M,selectedDestination:L}=Ns({enabled:t,resetKey:String(e?.id||"")});R(()=>{t&&(l(0),g(""),d(""),p(!1),h(!1),x(!1),$(!1),S(!1),_(!!n?.webhookExists))},[t,e?.id]);let B=n?.commands||null,E=!!(String(n?.projectId||"").trim()||B),U=u||!E&&!m,F=String(c||"").trim()||String(n?.projectId||"").trim()||"",K=C,re=K?j3:Vw,Y=re.length,j=String(e?.client||n?.client||"default").trim()||"default",J=W(()=>U?String(c||"").trim().length>0:!0,[U,c]),pe=G(async he=>{if(await V3(he)){I("Copied to clipboard","success");return}I("Could not copy text","error")},[]),le=G(()=>{g(""),d(String(n?.projectId||"").trim()),h(!1),p(!0)},[n?.projectId]),ie=async()=>{try{g(""),await i({client:j,projectId:String(c||"").trim(),destination:L}),x(!0),l(he=>Math.min(he+1,Y-1))}catch(he){g(he.message||"Could not finish setup")}},se=async()=>{if(!s){if(U){if(!J)return;g("");try{await r({client:j,projectId:String(c||"").trim()}),p(!1),h(!0)}catch(he){g(he.message||"Could not save project id");return}return}l(he=>Math.min(he+1,Y-1))}},xe=async()=>{if(!(v||w))try{$(!0);let ue=`I just enabled Gmail watch for "${String(e?.email||"this account").trim()||"this account"}", set up the webhook, and created the transform file. Help me set up what I want to do with incoming email.`;await ga({message:ue,sessionKey:k}),S(!0),I("Message sent to your agent","success")}catch(he){I(he.message||"Could not send message to agent","error")}finally{$(!1)}};return xt` + <${Ie} visible=${t} onClose=${o} closeOnOverlayClick=${!1} @@ -6955,24 +6962,24 @@ ${t} - <${Ze} className="w-3.5 h-3.5 text-body" /> + <${Qe} className="w-3.5 h-3.5 text-body" />
Gmail Pub / Sub Setup
- ${te.map((pe,ce)=>mt` + ${re.map((he,ue)=>xt`
`)}
- <${Pe} - title=${`Step ${a+1} of ${K}: ${te[a]}`} + <${De} + title=${`Step ${a+1} of ${Y}: ${re[a]}`} actions=${null} /> - ${f?mt`
${f}
`:null} - ${G?mt` + ${f?xt`
${f}
`:null} + ${U?xt`
@@ -6993,16 +7000,16 @@ ${t}d(pe.target.value)} + oninput=${he=>d(he.target.value)} class="w-full bg-field border border-border rounded-lg px-2.5 py-2 text-xs font-mono focus:border-fg-muted focus:outline-none" placeholder="my-gcp-project" />
`:null} - ${!G&&a===0?mt` + ${!U&&a===0?xt`
- Using project ${H}. + Using project ${F}.
If gcloud is not installed on your computer, @@ -7017,36 +7024,36 @@ ${t}
- ${vc(`gcloud auth login -gcloud config set project ${H}`,()=>ue(`gcloud auth login -gcloud config set project ${H}`))} + ${Sc(`gcloud auth login +gcloud config set project ${F}`,()=>pe(`gcloud auth login +gcloud config set project ${F}`))} `:null} - ${!G&&a===1?vc(B?.enableApis||"",()=>ue(B?.enableApis||"")):null} - ${!G&&a===2?mt` - ${vc(`${B?.createTopic||""} + ${!U&&a===1?Sc(B?.enableApis||"",()=>pe(B?.enableApis||"")):null} + ${!U&&a===2?xt` + ${Sc(`${B?.createTopic||""} -${B?.grantPublisher||""}`.trim(),()=>ue(`${B?.createTopic||""} +${B?.grantPublisher||""}`.trim(),()=>pe(`${B?.createTopic||""} ${B?.grantPublisher||""}`.trim()))} `:null} - ${!z&&!G&&a===3?mt` - ${vc(B?.createSubscription||"",()=>ue(B?.createSubscription||""))} + ${!K&&!U&&a===3?xt` + ${Sc(B?.createSubscription||"",()=>pe(B?.createSubscription||""))}
<${vr} label="Deliver to" - sessions=${U} - selectedSessionKey=${O} + sessions=${z} + selectedSessionKey=${N} onChangeSessionKey=${M} - disabled=${z||D||s} + disabled=${K||D||s} loading=${D} - error=${N} + error=${O} allowNone=${!0} - noneValue=${yc} + noneValue=${kc} noneLabel="Default" loadingLabel="Loading sessions..." - helperText=${z?"This Gmail webhook has already been created. To edit delivery routing, ask your agent.":null} + helperText=${K?"This Gmail webhook has already been created. To edit delivery routing, ask your agent.":null} selectClassName="w-full bg-field border border-border rounded-lg px-2.5 py-2 text-xs font-mono focus:border-fg-muted focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed" helperClassName="text-xs text-fg-muted" statusClassName="text-[11px] text-fg-muted" @@ -7054,7 +7061,7 @@ ${B?.grantPublisher||""}`.trim()))} />
`:null} - ${!z&&a===4?mt` + ${!K&&a===4?xt`
@@ -7070,58 +7077,58 @@ ${B?.grantPublisher||""}`.trim()))}
- <${Y} - onClick=${me} - disabled=${!k||$} + <${Z} + onClick=${xe} + disabled=${!k||w} loading=${v} - idleLabel=${$?"Sent":"Send to Agent"} + idleLabel=${w?"Sent":"Send to Agent"} loadingLabel="Sending..." tone="primary" size="sm" className="h-[34px] px-3" />
- ${D?mt`
+ ${D?xt`
Loading sessions...
`:null} - ${N?mt`
- ${N} + ${O?xt`
+ ${O}
`:null}
`:null}
- ${a===0?mt`${G?mt`
`:mt`
`:xt``}`:mt`<${Y} - onClick=${()=>l(pe=>Math.max(pe-1,0))} + `}`:xt`<${Z} + onClick=${()=>l(he=>Math.max(he-1,0))} disabled=${s} idleLabel="Back" tone="secondary" size="md" className="w-full justify-center" />`} - ${!z&&a===K-2?mt`<${Y} - onClick=${oe} + ${!K&&a===Y-2?xt`<${Z} + onClick=${ie} disabled=${!1} loading=${s} idleLabel="Enable watch" @@ -7129,14 +7136,14 @@ ${B?.grantPublisher||""}`.trim()))} tone="primary" size="md" className="w-full justify-center" - />`:a`:a`:mt`<${Y} + />`:xt`<${Z} onClick=${o} disabled=${s||v} idleLabel="Done" @@ -7145,13 +7152,13 @@ ${B?.grantPublisher||""}`.trim()))} className="w-full justify-center" />`}
- - `};var Os=P.bind(T),F3=(t=[],e=[])=>t.length!==e.length||t.some(n=>!e.includes(n)),$c=(t={})=>!!t.personal,H3="/assets/icons/google_icon.svg",Fw=({gatewayStatus:t,onRestartRequired:e=()=>{},onOpenGmailWebhook:n=()=>{}})=>{let{accounts:s,loading:o,hasCompanyCredentials:r,refreshAccounts:i}=Dw({gatewayStatus:t}),[a,l]=y(""),[c,d]=y({}),[u,p]=y({}),[f,g]=y({}),[m,h]=y({}),[b,x]=y(!1),[v,w]=y({visible:!1,accountId:"",client:"default",personal:!1,title:"Connect Google Workspace",submitLabel:"Connect Google",defaultInstrType:"workspace",initialValues:{}}),[$,S]=y(!1),[C,_]=y(!1),[k,A]=y(""),[D,N]=y({visible:!1,accountId:""}),{loading:U,watchByAccountId:O,clientConfigByClient:M,busyByAccountId:R,savingClient:B,refresh:E,saveClientSetup:G,startWatchForAccount:H,stopWatchForAccount:z}=Nw({gatewayStatus:t,accounts:s}),te=F(()=>s.some(Q=>$c(Q)),[s]),K=F(()=>s.some(Q=>!$c(Q)),[s]),V=q(Q=>s.find(fe=>fe.id===Q)||null,[s]),Z=q(Q=>{let fe=Array.isArray(Q.activeScopes)&&Q.activeScopes.length?Q.activeScopes:Array.isArray(Q.services)&&Q.services.length?Q.services:wr();p(se=>({...se,[Q.id]:[...fe]})),d(se=>{let De=se[Q.id];return!De||!F3(De,fe)?{...se,[Q.id]:[...fe]}:se})},[]);L(()=>{if(!s.length){l("");return}let Q=s.find(fe=>!fe.authenticated)?.id||"";l(fe=>fe&&s.some(se=>se.id===fe)?fe:Q),s.forEach(fe=>Z(fe))},[s,Z]);let ue=q(Q=>{let fe=V(Q);if(!fe)return;let se=c[Q]||fe.activeScopes||wr();if(!se.length){window.alert("Select at least one service");return}let De=`/auth/google/start?accountId=${encodeURIComponent(Q)}&services=${encodeURIComponent(se.join(","))}&_ts=${Date.now()}`,ke=window.open(De,`google-auth-${Q}`,"popup=yes,width=500,height=700");(!ke||ke.closed)&&(window.location.href=De)},[V,c]),re=(Q,fe)=>{d(se=>({...se,[Q]:Tw(se[Q]||[],fe)}))},oe=q(async Q=>{g(fe=>{let se={...fe};return delete se[Q],se}),h({[Q]:!0});try{let fe=await jh(Q);fe.results&&g(se=>({...se,[Q]:fe.results}))}finally{h(fe=>{if(!fe[Q])return fe;let se={...fe};return delete se[Q],se})}},[]);L(()=>{let Q=async fe=>{if(fe.data?.google==="success"){I("\u2713 Google account connected","success");let se=String(fe.data?.accountId||"").trim();g({}),await i(),await E(),se&&await oe(se)}else fe.data?.google==="error"&&I(`\u2717 Google auth failed: ${fe.data.message||"unknown"}`,"error")};return window.addEventListener("message",Q),()=>window.removeEventListener("message",Q)},[oe,i,E]),L(()=>{!a||!V(a)?.authenticated||m[a]||f[a]||oe(a)},[s,f,m,a,V,oe]);let ne=async Q=>{let fe=await Kh(Q);if(!fe.ok){I(`Failed to disconnect: ${fe.error||"unknown"}`,"error");return}I("Google account disconnected","success"),g(se=>{let De={...se};return delete De[Q],De}),await i(),await E()},me=({accountId:Q="",client:fe="default",personal:se=!1,title:De="Connect Google Workspace",submitLabel:ke="Connect Google",defaultInstrType:W=se?"personal":"workspace",initialValues:ae={}})=>{w({visible:!0,accountId:Q,client:fe,personal:se,title:De,submitLabel:ke,defaultInstrType:W,initialValues:ae})},pe=()=>{w(Q=>({...Q,visible:!1}))},ce=async Q=>{Q?.id&&l(Q.id),await i(),Q?.id&&ue(Q.id)},ge=async({email:Q,setError:fe})=>{_(!0);try{let se=await Uh({email:Q,client:"default",personal:!1,services:wr()});if(!se.ok){fe?.(se.error||"Could not add account");return}S(!1),se.accountId&&l(se.accountId),await i(),se.accountId&&ue(se.accountId)}finally{_(!1)}},j=()=>{if(x(!1),K&&r){S(!0);return}me({client:"default",personal:!1,title:"Add Company Account",submitLabel:"Save Credentials",defaultInstrType:"workspace"})},J=()=>{x(!1),me({client:"personal",personal:!0,title:"Add Personal Account",submitLabel:"Save Credentials",defaultInstrType:"personal"})},ie=async Q=>{let fe=V(Q);if(!fe)return;let se=$c(fe),De=se?"personal":fe.client||"default",ke={};try{let W=await Vh({accountId:fe.id,client:De});W?.ok&&(ke={clientId:String(W.clientId||""),clientSecret:String(W.clientSecret||"")})}catch{I("Could not load saved client credentials","warning")}me({accountId:fe.id,client:De,personal:se,title:`Edit Credentials (${fe.email})`,submitLabel:"Save Credentials",defaultInstrType:se?"personal":"workspace",initialValues:{email:fe.email,...ke}})},de=Q=>{N({visible:!0,accountId:String(Q||"")})},be=()=>{N({visible:!1,accountId:""})},Ve=async Q=>{let fe=V(Q);if(!fe)return;let se=String(fe.client||"default").trim()||"default",De=M.get(se);if(!De?.configured||!De?.webhookExists){de(Q);return}try{(await H(Q))?.restartRequired&&e(!0),I("Gmail watch enabled","success")}catch(ke){I(ke.message||"Could not enable Gmail watch","error")}},tt=async Q=>{try{await z(Q),I("Gmail watch disabled","info")}catch(fe){I(fe.message||"Could not disable Gmail watch","error")}},kt=async({client:Q,projectId:fe,destination:se=null})=>{let De=String(D.accountId||"").trim();De&&(await G({client:Q,projectId:fe,regeneratePushToken:!1}),await H(De,{destination:se}),I("Gmail setup complete and watch enabled","success"))},Ot=()=>Os` + + `};var Bs=P.bind(T),z3=(t=[],e=[])=>t.length!==e.length||t.some(n=>!e.includes(n)),Cc=(t={})=>!!t.personal,U3="/assets/icons/google_icon.svg",zw=({gatewayStatus:t,onRestartRequired:e=()=>{},onOpenGmailWebhook:n=()=>{}})=>{let{accounts:s,loading:o,hasCompanyCredentials:r,refreshAccounts:i}=Ww({gatewayStatus:t}),[a,l]=y(""),[c,d]=y({}),[u,p]=y({}),[f,g]=y({}),[m,h]=y({}),[b,x]=y(!1),[v,$]=y({visible:!1,accountId:"",client:"default",personal:!1,title:"Connect Google Workspace",submitLabel:"Connect Google",defaultInstrType:"workspace",initialValues:{}}),[w,S]=y(!1),[C,_]=y(!1),[k,A]=y(""),[D,O]=y({visible:!1,accountId:""}),{loading:z,watchByAccountId:N,clientConfigByClient:M,busyByAccountId:L,savingClient:B,refresh:E,saveClientSetup:U,startWatchForAccount:F,stopWatchForAccount:K}=Hw({gatewayStatus:t,accounts:s}),re=W(()=>s.some(Q=>Cc(Q)),[s]),Y=W(()=>s.some(Q=>!Cc(Q)),[s]),j=G(Q=>s.find(ce=>ce.id===Q)||null,[s]),J=G(Q=>{let ce=Array.isArray(Q.activeScopes)&&Q.activeScopes.length?Q.activeScopes:Array.isArray(Q.services)&&Q.services.length?Q.services:wr();p(ee=>({...ee,[Q.id]:[...ce]})),d(ee=>{let Ee=ee[Q.id];return!Ee||!z3(Ee,ce)?{...ee,[Q.id]:[...ce]}:ee})},[]);R(()=>{if(!s.length){l("");return}let Q=s.find(ce=>!ce.authenticated)?.id||"";l(ce=>ce&&s.some(ee=>ee.id===ce)?ce:Q),s.forEach(ce=>J(ce))},[s,J]);let pe=G(Q=>{let ce=j(Q);if(!ce)return;let ee=c[Q]||ce.activeScopes||wr();if(!ee.length){window.alert("Select at least one service");return}let Ee=`/auth/google/start?accountId=${encodeURIComponent(Q)}&services=${encodeURIComponent(ee.join(","))}&_ts=${Date.now()}`,ke=window.open(Ee,`google-auth-${Q}`,"popup=yes,width=500,height=700");(!ke||ke.closed)&&(window.location.href=Ee)},[j,c]),le=(Q,ce)=>{d(ee=>({...ee,[Q]:Iw(ee[Q]||[],ce)}))},ie=G(async Q=>{g(ce=>{let ee={...ce};return delete ee[Q],ee}),h({[Q]:!0});try{let ce=await Uh(Q);ce.results&&g(ee=>({...ee,[Q]:ce.results}))}finally{h(ce=>{if(!ce[Q])return ce;let ee={...ce};return delete ee[Q],ee})}},[]);R(()=>{let Q=async ce=>{if(ce.data?.google==="success"){I("\u2713 Google account connected","success");let ee=String(ce.data?.accountId||"").trim();g({}),await i(),await E(),ee&&await ie(ee)}else ce.data?.google==="error"&&I(`\u2717 Google auth failed: ${ce.data.message||"unknown"}`,"error")};return window.addEventListener("message",Q),()=>window.removeEventListener("message",Q)},[ie,i,E]),R(()=>{!a||!j(a)?.authenticated||m[a]||f[a]||ie(a)},[s,f,m,a,j,ie]);let se=async Q=>{let ce=await qh(Q);if(!ce.ok){I(`Failed to disconnect: ${ce.error||"unknown"}`,"error");return}I("Google account disconnected","success"),g(ee=>{let Ee={...ee};return delete Ee[Q],Ee}),await i(),await E()},xe=({accountId:Q="",client:ce="default",personal:ee=!1,title:Ee="Connect Google Workspace",submitLabel:ke="Connect Google",defaultInstrType:H=ee?"personal":"workspace",initialValues:oe={}})=>{$({visible:!0,accountId:Q,client:ce,personal:ee,title:Ee,submitLabel:ke,defaultInstrType:H,initialValues:oe})},he=()=>{$(Q=>({...Q,visible:!1}))},ue=async Q=>{Q?.id&&l(Q.id),await i(),Q?.id&&pe(Q.id)},be=async({email:Q,setError:ce})=>{_(!0);try{let ee=await Gh({email:Q,client:"default",personal:!1,services:wr()});if(!ee.ok){ce?.(ee.error||"Could not add account");return}S(!1),ee.accountId&&l(ee.accountId),await i(),ee.accountId&&pe(ee.accountId)}finally{_(!1)}},V=()=>{if(x(!1),Y&&r){S(!0);return}xe({client:"default",personal:!1,title:"Add Company Account",submitLabel:"Save Credentials",defaultInstrType:"workspace"})},q=()=>{x(!1),xe({client:"personal",personal:!0,title:"Add Personal Account",submitLabel:"Save Credentials",defaultInstrType:"personal"})},ae=async Q=>{let ce=j(Q);if(!ce)return;let ee=Cc(ce),Ee=ee?"personal":ce.client||"default",ke={};try{let H=await zh({accountId:ce.id,client:Ee});H?.ok&&(ke={clientId:String(H.clientId||""),clientSecret:String(H.clientSecret||"")})}catch{I("Could not load saved client credentials","warning")}xe({accountId:ce.id,client:Ee,personal:ee,title:`Edit Credentials (${ce.email})`,submitLabel:"Save Credentials",defaultInstrType:ee?"personal":"workspace",initialValues:{email:ce.email,...ke}})},fe=Q=>{O({visible:!0,accountId:String(Q||"")})},ne=()=>{O({visible:!1,accountId:""})},ve=async Q=>{let ce=j(Q);if(!ce)return;let ee=String(ce.client||"default").trim()||"default",Ee=M.get(ee);if(!Ee?.configured||!Ee?.webhookExists){fe(Q);return}try{(await F(Q))?.restartRequired&&e(!0),I("Gmail watch enabled","success")}catch(ke){I(ke.message||"Could not enable Gmail watch","error")}},ge=async Q=>{try{await K(Q),I("Gmail watch disabled","info")}catch(ce){I(ce.message||"Could not disable Gmail watch","error")}},Ne=async({client:Q,projectId:ce,destination:ee=null})=>{let Ee=String(D.accountId||"").trim();Ee&&(await U({client:Q,projectId:ce,regeneratePushToken:!1}),await F(Ee,{destination:ee}),I("Gmail setup complete and watch enabled","success"))},qe=()=>Bs`
Google logo
- <${Y} - onClick=${j} + <${Z} + onClick=${V} tone="primary" size="sm" idleLabel="Add Company Account" className="w-full font-medium" /> - <${Y} - onClick=${J} + <${Z} + onClick=${q} tone="secondary" size="sm" idleLabel="Add Personal Account" @@ -7180,75 +7187,75 @@ ${B?.grantPublisher||""}`.trim()))} />
- `;return Os` + `;return Bs`

Google Accounts

- ${s.length?Os` + ${s.length?Bs`
- <${pt} + <${mt} open=${b} ariaLabel="Add Google account" title="Add Google account" onClose=${()=>x(!1)} onToggle=${()=>x(Q=>!Q)} - renderTrigger=${({onToggle:Q,ariaLabel:fe,title:se})=>Os` - <${Y} + renderTrigger=${({onToggle:Q,ariaLabel:ce,title:ee})=>Bs` + <${Z} onClick=${Q} tone="subtle" size="sm" idleLabel="+ Add Account" - ariaLabel=${fe} - title=${se} + ariaLabel=${ce} + title=${ee} /> `} > - <${Oe} onClick=${j}> + <${We} onClick=${V}> Company account - - ${te?null:Os` - <${Oe} onClick=${J}> + + ${re?null:Bs` + <${We} onClick=${q}> Personal account - + `} - +
`:null}
- ${o?Os`
+ ${o?Bs`
Loading... -
`:s.length?Os` +
`:s.length?Bs`
- ${s.map(Q=>Os`<${Ew} + ${s.map(Q=>Bs`<${Bw} key=${Q.id} account=${Q} - personal=${$c(Q)} + personal=${Cc(Q)} expanded=${a===Q.id} - onToggleExpanded=${fe=>l(se=>se===fe?"":fe)} + onToggleExpanded=${ce=>l(ee=>ee===ce?"":ce)} scopes=${c[Q.id]||Q.activeScopes||wr()} savedScopes=${u[Q.id]||Q.activeScopes||wr()} apiStatus=${f[Q.id]||{}} checkingApis=${a===Q.id&&!!m[Q.id]} - onToggleScope=${re} - onCheckApis=${oe} - onUpdatePermissions=${fe=>ue(fe)} - onEditCredentials=${ie} - onDisconnect=${fe=>A(fe)} - gmailWatchStatus=${O.get(Q.id)||null} - gmailWatchBusy=${!!R[Q.id]} - onEnableGmailWatch=${Ve} - onDisableGmailWatch=${tt} - onOpenGmailSetup=${de} + onToggleScope=${le} + onCheckApis=${ie} + onUpdatePermissions=${ce=>pe(ce)} + onEditCredentials=${ae} + onDisconnect=${ce=>A(ce)} + gmailWatchStatus=${N.get(Q.id)||null} + gmailWatchBusy=${!!L[Q.id]} + onEnableGmailWatch=${ve} + onDisableGmailWatch=${ge} + onOpenGmailSetup=${fe} onOpenGmailWebhook=${n} />`)}
- `:Ot()} + `:qe()}
- <${Pw} + <${Dw} visible=${v.visible} - onClose=${pe} - onSaved=${ce} + onClose=${he} + onSaved=${ue} title=${v.title} submitLabel=${v.submitLabel} defaultInstrType=${v.defaultInstrType} @@ -7258,75 +7265,75 @@ ${B?.grantPublisher||""}`.trim()))} initialValues=${v.initialValues} /> - <${Iw} - visible=${$} + <${Fw} + visible=${w} onClose=${()=>S(!1)} - onSubmit=${ge} + onSubmit=${be} loading=${C} title="Add Company Account" /> - <${Bw} + <${jw} visible=${D.visible} - account=${V(D.accountId)} - clientConfig=${M.get(String(V(D.accountId)?.client||"default").trim()||"default")||null} - saving=${B||U} - onClose=${be} - onSaveSetup=${G} - onFinish=${kt} + account=${j(D.accountId)} + clientConfig=${M.get(String(j(D.accountId)?.client||"default").trim()||"default")||null} + saving=${B||z} + onClose=${ne} + onSaveSetup=${U} + onFinish=${Ne} /> - <${st} + <${rt} visible=${!!k} title="Disconnect Google account?" message="Your agent will lose access to Gmail, Calendar, and other Google Workspace services until you reconnect." confirmLabel="Disconnect" cancelLabel="Cancel" onCancel=${()=>A("")} - onConfirm=${async()=>{let Q=k;A(""),await ne(Q)}} + onConfirm=${async()=>{let Q=k;A(""),await se(Q)}} /> - `};var wc=P.bind(T),W3=(t,e)=>t.find(n=>n.key===e)?.value||"",V3=(t,e)=>{for(let n of t.providers)if((An[n]||[]).some(r=>!!W3(e,r.key)))return{active:!0,provider:n};return{active:!1,provider:null}},Hw=({onSwitchTab:t})=>{let{data:e,loading:n}=ct("/api/env",Vr,{maxAgeMs:3e4}),s=Array.isArray(e?.vars)?e.vars:[];return n?null:wc` + `};var _c=P.bind(T),K3=(t,e)=>t.find(n=>n.key===e)?.value||"",G3=(t,e)=>{for(let n of t.providers)if((An[n]||[]).some(r=>!!K3(e,r.key)))return{active:!0,provider:n};return{active:!1,provider:null}},Uw=({onSwitchTab:t})=>{let{data:e,loading:n}=pt("/api/env",Ur,{maxAgeMs:3e4}),s=Array.isArray(e?.vars)?e.vars:[];return n?null:_c`

Features

- ${bg.map(r=>{let i=V3(r,s);return wc` + ${yg.map(r=>{let i=G3(r,s);return _c`
${r.label} - ${i.active?wc` + ${i.active?_c` - ${Us[i.provider]||i.provider} + ${Ks[i.provider]||i.provider} - <${le} tone="success">Enabled + <${de} tone="success">Enabled - `:wc` + `:_c` {a.preventDefault(),t?.("envars")}} class="text-xs px-2 py-1 rounded-lg ac-btn-ghost" >Add provider - <${le} tone=${r.hasDefault?"neutral":"danger"}>Disabled + <${de} tone=${r.hasDefault?"neutral":"danger"}>Disabled `}
`})}
- `};var j3=P.bind(T),Ww=({doctorStatus:t=null,dismissedUntilMs:e=0,onOpenDoctor:n=()=>{},onDismiss:s=()=>{}})=>fc(t,e)?j3` + `};var q3=P.bind(T),Kw=({doctorStatus:t=null,dismissedUntilMs:e=0,onOpenDoctor:n=()=>{},onDismiss:s=()=>{}})=>bc(t,e)?q3`

Drift Doctor

-

${lw(t)}

+

${fw(t)}

- <${Y} + <${Z} onClick=${s} tone="secondary" idleLabel="Dismiss for 1 week" /> - <${Y} + <${Z} onClick=${n} tone="warning" idleLabel="Open Drift Doctor" @@ -7334,9 +7341,9 @@ ${B?.grantPublisher||""}`.trim()))}
- `:null;var kc="0 * * * *",Vw=({statusData:t=null,watchdogData:e=null,doctorStatusData:n=null,onRefreshStatuses:s=()=>{},isActive:o=!1,restartSignal:r=0}={})=>{let[i,a]=y(!1),[l,c]=y(!1),[d,u]=y(!0),[p,f]=y(kc),[g,m]=y(!1),[h,b]=y(kc),[x,v]=y(!1),[w,$]=y(!1),[S,C]=y(!1),_=ee(null),k=t,A=e,D=n,N=k?.gateway??null,U=k?.channels??null,O=k?.repo||null,M=k?.syncCron||null,R=k?.openclawVersion||null,B=xs.some(ce=>{let ge=U?.[ce];if(!ge)return!1;let j=ge.accounts&&typeof ge.accounts=="object"?ge.accounts:{};return Object.keys(j).length>0?Object.values(j).some(J=>J&&J.status!=="paired"):ge.status!=="paired"}),E=Ee(async()=>(await Co()).pending||[],3e3,{enabled:B&&N==="running",cacheKey:"/api/pairings"}),G=E.data||[],H=N==="running"&&(w||!S),z=Ee(async()=>{let ce=await ga();return C(ce?.cliAutoApproveComplete===!0),ce.pending||[]},5e3,{enabled:H,cacheKey:"/api/devices"}),te=z.data||[];L(()=>{o&&(E.refresh(),H&&z.refresh())},[z.refresh,o,s,E.refresh,w,H]),L(()=>{if(!r||!o)return;s(),E.refresh(),H&&z.refresh();let ce=setTimeout(()=>{s(),E.refresh(),H&&z.refresh()},1200),ge=setTimeout(()=>{s(),E.refresh(),H&&z.refresh()},3500);return()=>{clearTimeout(ce),clearTimeout(ge)}},[z.refresh,o,s,E.refresh,r,w,H]),L(()=>{M&&(u(M.enabled!==!1),f(M.schedule||kc),b(M.enabled===!1?"disabled":M.schedule||kc))},[M?.enabled,M?.schedule]),L(()=>()=>{_.current&&clearTimeout(_.current)},[]);let K=()=>{v(!0),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{v(!1),_.current=null},2800),s(),E.refresh(),setTimeout(()=>{s(),E.refresh()},700),setTimeout(()=>{s(),E.refresh()},1800)},V=async({enabled:ce=d,schedule:ge=p}={})=>{if(!g){m(!0);try{let j=await ym({enabled:ce,schedule:ge});if(!j.ok)throw new Error(j.error||"Could not save sync settings");I("Sync schedule updated","success"),s()}catch(j){I(j.message||"Could not save sync settings","error")}finally{m(!1)}}};return{state:{channels:U,dashboardLoading:i,devicePending:te,doctorStatus:D,gatewayStatus:N,hasUnpaired:B,openclawVersion:R,pending:G,pairingStatusRefreshing:x,repairingWatchdog:l,repo:O,savingSyncCron:g,syncCron:M,syncCronChoice:h,syncCronEnabled:d,syncCronSchedule:p,syncCronStatusText:d?"Enabled":"Disabled",watchdogStatus:A},actions:{handleApprove:async(ce,ge,j="")=>{await _o(ce,ge,j),K()},handleDeviceApprove:async ce=>{await ba(ce),setTimeout(z.refresh,500),setTimeout(z.refresh,2e3)},handleDeviceReject:async ce=>{await xa(ce),setTimeout(z.refresh,500),setTimeout(z.refresh,2e3)},handleOpenDashboard:async()=>{if(!i){$(!0),a(!0);try{let ce=await hm();console.log("[dashboard] response:",JSON.stringify(ce)),window.open(ce.url||"/openclaw","_blank")}catch(ce){console.error("[dashboard] error:",ce),window.open("/openclaw","_blank")}finally{a(!1)}}},handleReject:async(ce,ge,j="")=>{try{await Ao(ce,ge,j),K()}catch(J){I(J.message||"Could not reject pairing","error")}},handleSyncCronChoiceChange:async ce=>{b(ce);let ge=ce!=="disabled",j=ge?ce:p;u(ge),f(j),await V({enabled:ge,schedule:j})},handleWatchdogRepair:async()=>{if(!l){c(!0);try{let ce=await ha();if(!ce.ok)throw new Error(ce.error||"Repair failed");I("Repair triggered","success"),setTimeout(()=>{s()},800)}catch(ce){I(ce.message||"Could not run repair","error")}finally{c(!1)}}}}}};var Sc=P.bind(T),jw=({statusData:t=null,watchdogData:e=null,doctorStatusData:n=null,agents:s=[],doctorWarningDismissedUntilMs:o=0,onRefreshStatuses:r=()=>{},onSwitchTab:i=()=>{},onNavigate:a=()=>{},onOpenGmailWebhook:l=()=>{},isActive:c=!1,restartingGateway:d=!1,onRestartGateway:u=()=>{},restartSignal:p=0,openclawUpdateInProgress:f=!1,onOpenclawVersionActionComplete:g=()=>{},onOpenclawUpdate:m=()=>{},onRestartRequired:h=()=>{},onDismissDoctorWarning:b=()=>{}})=>{let{state:x,actions:v}=Vw({statusData:t,watchdogData:e,doctorStatusData:n,onRefreshStatuses:r,isActive:c,restartSignal:p});return Sc` + `:null;var Ac="0 * * * *",Gw=({statusData:t=null,watchdogData:e=null,doctorStatusData:n=null,onRefreshStatuses:s=()=>{},isActive:o=!1,restartSignal:r=0}={})=>{let[i,a]=y(!1),[l,c]=y(!1),[d,u]=y(!0),[p,f]=y(Ac),[g,m]=y(!1),[h,b]=y(Ac),[x,v]=y(!1),[$,w]=y(!1),[S,C]=y(!1),_=te(null),k=t,A=e,D=n,O=k?.gateway??null,z=k?.channels??null,N=k?.repo||null,M=k?.syncCron||null,L=k?.openclawVersion||null,B=ys.some(ue=>{let be=z?.[ue];if(!be)return!1;let V=be.accounts&&typeof be.accounts=="object"?be.accounts:{};return Object.keys(V).length>0?Object.values(V).some(q=>q&&q.status!=="paired"):be.status!=="paired"}),E=Re(async()=>(await Co()).pending||[],3e3,{enabled:B&&O==="running",cacheKey:"/api/pairings"}),U=E.data||[],F=O==="running"&&($||!S),K=Re(async()=>{let ue=await va();return C(ue?.cliAutoApproveComplete===!0),ue.pending||[]},5e3,{enabled:F,cacheKey:"/api/devices"}),re=K.data||[];R(()=>{o&&(E.refresh(),F&&K.refresh())},[K.refresh,o,s,E.refresh,$,F]),R(()=>{if(!r||!o)return;s(),E.refresh(),F&&K.refresh();let ue=setTimeout(()=>{s(),E.refresh(),F&&K.refresh()},1200),be=setTimeout(()=>{s(),E.refresh(),F&&K.refresh()},3500);return()=>{clearTimeout(ue),clearTimeout(be)}},[K.refresh,o,s,E.refresh,r,$,F]),R(()=>{M&&(u(M.enabled!==!1),f(M.schedule||Ac),b(M.enabled===!1?"disabled":M.schedule||Ac))},[M?.enabled,M?.schedule]),R(()=>()=>{_.current&&clearTimeout(_.current)},[]);let Y=()=>{v(!0),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{v(!1),_.current=null},2800),s(),E.refresh(),setTimeout(()=>{s(),E.refresh()},700),setTimeout(()=>{s(),E.refresh()},1800)},j=async({enabled:ue=d,schedule:be=p}={})=>{if(!g){m(!0);try{let V=await vm({enabled:ue,schedule:be});if(!V.ok)throw new Error(V.error||"Could not save sync settings");I("Sync schedule updated","success"),s()}catch(V){I(V.message||"Could not save sync settings","error")}finally{m(!1)}}};return{state:{channels:z,dashboardLoading:i,devicePending:re,doctorStatus:D,gatewayStatus:O,hasUnpaired:B,openclawVersion:L,pending:U,pairingStatusRefreshing:x,repairingWatchdog:l,repo:N,savingSyncCron:g,syncCron:M,syncCronChoice:h,syncCronEnabled:d,syncCronSchedule:p,syncCronStatusText:d?"Enabled":"Disabled",watchdogStatus:A},actions:{handleApprove:async(ue,be,V="")=>{await _o(ue,be,V),Y()},handleDeviceApprove:async ue=>{await $a(ue),setTimeout(K.refresh,500),setTimeout(K.refresh,2e3)},handleDeviceReject:async ue=>{await wa(ue),setTimeout(K.refresh,500),setTimeout(K.refresh,2e3)},handleOpenDashboard:async()=>{if(!i){w(!0),a(!0);try{let ue=await mm();console.log("[dashboard] response:",JSON.stringify(ue)),window.open(ue.url||"/openclaw","_blank")}catch(ue){console.error("[dashboard] error:",ue),window.open("/openclaw","_blank")}finally{a(!1)}}},handleReject:async(ue,be,V="")=>{try{await Ao(ue,be,V),Y()}catch(q){I(q.message||"Could not reject pairing","error")}},handleSyncCronChoiceChange:async ue=>{b(ue);let be=ue!=="disabled",V=be?ue:p;u(be),f(V),await j({enabled:be,schedule:V})},handleWatchdogRepair:async()=>{if(!l){c(!0);try{let ue=await xa();if(!ue.ok)throw new Error(ue.error||"Repair failed");I("Repair triggered","success"),setTimeout(()=>{s()},800)}catch(ue){I(ue.message||"Could not run repair","error")}finally{c(!1)}}}}}};var Sr=P.bind(T),J3=()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("alphaclaw:open-whatsapp-qr"))},qw=({statusData:t=null,watchdogData:e=null,doctorStatusData:n=null,agents:s=[],doctorWarningDismissedUntilMs:o=0,onRefreshStatuses:r=()=>{},onSwitchTab:i=()=>{},onNavigate:a=()=>{},onOpenGmailWebhook:l=()=>{},isActive:c=!1,restartingGateway:d=!1,onRestartGateway:u=()=>{},restartSignal:p=0,openclawUpdateInProgress:f=!1,onOpenclawVersionActionComplete:g=()=>{},onOpenclawUpdate:m=()=>{},onRestartRequired:h=()=>{},onDismissDoctorWarning:b=()=>{}})=>{let{state:x,actions:v}=Gw({statusData:t,watchdogData:e,doctorStatusData:n,onRefreshStatuses:r,isActive:c,restartSignal:p}),$=x.channels?.whatsapp||null,w=$?.accounts&&typeof $.accounts=="object"?$.accounts:{},S=Object.keys(w).length>0?Object.values(w).some(_=>_&&_.status!=="paired"):String($?.status||"").trim()==="configured",C=x.hasUnpaired&&!x.pairingStatusRefreshing&&Array.isArray(x.pending)&&x.pending.length===0&&S;return Sr`
- <${bc} + <${$c} status=${x.gatewayStatus} openclawVersion=${x.openclawVersion} restarting=${d} @@ -7349,40 +7356,63 @@ ${B?.grantPublisher||""}`.trim()))} onOpenclawVersionActionComplete=${g} onOpenclawUpdate=${m} /> - <${Ww} + <${Kw} doctorStatus=${x.doctorStatus} dismissedUntilMs=${o} onOpenDoctor=${()=>i("doctor")} onDismiss=${b} /> - <${nl} - channelsSection=${Sc` - <${Mb} + <${il} + channelsSection=${Sr` + <${Eb} channels=${x.channels} agents=${s} onNavigate=${a} onRefreshStatuses=${r} + onRestartGateway=${u} /> `} - pairingsSection=${Sc` - <${tl} - pending=${x.pending} - channels=${x.channels} - visible=${x.hasUnpaired} - statusRefreshing=${x.pairingStatusRefreshing} - onApprove=${v.handleApprove} - onReject=${v.handleReject} - /> + pairingsSection=${Sr` + ${C?Sr` +
+

Pending Pairings

+
+ +

WhatsApp needs to be linked

+

Scan the QR code to finish pairing this channel.

+ <${Z} + onClick=${J3} + tone="primary" + size="sm" + idleLabel="Open QR Code" + /> +
+
+ `:Sr` + <${rl} + pending=${x.pending} + channels=${x.channels} + visible=${x.hasUnpaired} + statusRefreshing=${x.pairingStatusRefreshing} + onApprove=${v.handleApprove} + onReject=${v.handleReject} + /> + `} `} /> - <${Hw} onSwitchTab=${i} /> - <${Fw} + <${Uw} onSwitchTab=${i} /> + <${zw} gatewayStatus=${x.gatewayStatus} onRestartRequired=${h} onOpenGmailWebhook=${l} /> - ${x.repo&&Sc` + ${x.repo&&Sr`
@@ -7407,7 +7437,7 @@ ${B?.grantPublisher||""}`.trim()))}
- <${Ca} + <${Ta} className="pointer-events-none absolute right-2.5 top-1/2 -translate-y-1/2 text-fg-muted" />
@@ -7439,16 +7469,16 @@ ${B?.grantPublisher||""}`.trim()))} loadingLabel="Opening..." />
- <${xc} + <${wc} pending=${x.devicePending} onApprove=${v.handleDeviceApprove} onReject=${v.handleDeviceReject} />
- `};var z3=P.bind(T),ff=({statusData:t=null,watchdogData:e=null,doctorStatusData:n=null,agents:s=[],doctorWarningDismissedUntilMs:o=0,onRefreshStatuses:r=()=>{},onSetLocation:i=()=>{},onNavigate:a=()=>{},restartingGateway:l=!1,onRestartGateway:c=()=>{},restartSignal:d=0,openclawUpdateInProgress:u=!1,onOpenclawVersionActionComplete:p=()=>{},onOpenclawUpdate:f=()=>{},onRestartRequired:g=()=>{},onDismissDoctorWarning:m=()=>{}})=>z3` + `};var Z3=P.bind(T),mf=({statusData:t=null,watchdogData:e=null,doctorStatusData:n=null,agents:s=[],doctorWarningDismissedUntilMs:o=0,onRefreshStatuses:r=()=>{},onSetLocation:i=()=>{},onNavigate:a=()=>{},restartingGateway:l=!1,onRestartGateway:c=()=>{},restartSignal:d=0,openclawUpdateInProgress:u=!1,onOpenclawVersionActionComplete:p=()=>{},onOpenclawUpdate:f=()=>{},onRestartRequired:g=()=>{},onDismissDoctorWarning:m=()=>{}})=>Z3`
- <${jw} + <${qw} statusData=${t} watchdogData=${e} doctorStatusData=${n} @@ -7469,11 +7499,11 @@ ${B?.grantPublisher||""}`.trim()))} onDismissDoctorWarning=${m} />
-`;var Nt=P.bind(T),U3={anthropic:{label:"Anthropic",modes:[{id:"api_key",label:"API Key",profileSuffix:"default",placeholder:"sk-ant-api03-...",url:"https://console.anthropic.com",field:"key"},{id:"token",label:"Setup Token",profileSuffix:"manual",placeholder:"sk-ant-oat01-...",hint:"From claude setup-token (uses your Claude subscription)",field:"token"}]},openai:{label:"OpenAI",modes:[{id:"api_key",label:"API Key",profileSuffix:"default",placeholder:"sk-...",url:"https://platform.openai.com",field:"key"}]},"openai-codex":{label:"OpenAI Codex",modes:[{id:"oauth",label:"Codex OAuth",isCodexOauth:!0}]},google:{label:"Gemini",modes:[{id:"api_key",label:"API Key",profileSuffix:"default",placeholder:"AI...",url:"https://aistudio.google.com",field:"key"}]}},K3={id:"api_key",label:"API Key",profileSuffix:"default",placeholder:"...",field:"key"},G3=t=>{let e=An[t]||[];return e.length===0?[K3]:e.map(n=>({id:"api_key",label:n.label||"API Key",profileSuffix:"default",placeholder:n.placeholder||"...",hint:n.hint,url:n.url,field:"key"}))},q3=t=>U3[t]||{label:Us[t]||t,modes:G3(t)},zi=(t,e)=>`${t.provider||e}:${t.profileSuffix||"default"}`,Cc=t=>String(t?.key||t?.token||t?.access||"").trim(),J3=({codexStatus:t,onRefreshCodex:e})=>{let[n,s]=y(!1),[o,r]=y(!1),[i,a]=y(""),[l,c]=y(!1),d=ee(null);L(()=>()=>{d.current&&clearInterval(d.current)},[]),L(()=>{let g=async m=>{m.data?.codex==="success"?(I("Codex connected","success"),s(!1),r(!1),await e()):m.data?.codex==="error"&&I(`Codex auth failed: ${m.data.message||"unknown error"}`,"error")};return window.addEventListener("message",g),()=>window.removeEventListener("message",g)},[e]);let u=()=>{s(!0),r(!0);let g=window.open("/auth/codex/start","codex-auth","popup=yes,width=640,height=780");if(!g||g.closed){r(!1),window.location.href="/auth/codex/start";return}d.current&&clearInterval(d.current),d.current=setInterval(()=>{g.closed&&(clearInterval(d.current),d.current=null,r(!1))},500)},p=async()=>{if(!(!i.trim()||l)){c(!0);try{let g=await Wr(i.trim());if(!g.ok)throw new Error(g.error||"Codex OAuth exchange failed");a(""),I("Codex connected","success"),s(!1),r(!1),await e()}catch(g){I(g.message||"Codex OAuth exchange failed","error")}finally{c(!1)}}},f=async()=>{let g=await Hr();if(!g.ok){I(g.error||"Failed to disconnect Codex","error");return}I("Codex disconnected","success"),s(!1),r(!1),a(""),await e()};return Nt` +`;var Nt=P.bind(T),Y3={anthropic:{label:"Anthropic",modes:[{id:"api_key",label:"API Key",profileSuffix:"default",placeholder:"sk-ant-api03-...",url:"https://console.anthropic.com",field:"key"},{id:"token",label:"Setup Token",profileSuffix:"manual",placeholder:"sk-ant-oat01-...",hint:"From claude setup-token (uses your Claude subscription)",field:"token"}]},openai:{label:"OpenAI",modes:[{id:"api_key",label:"API Key",profileSuffix:"default",placeholder:"sk-...",url:"https://platform.openai.com",field:"key"}]},"openai-codex":{label:"OpenAI Codex",modes:[{id:"oauth",label:"Codex OAuth",isCodexOauth:!0}]},google:{label:"Gemini",modes:[{id:"api_key",label:"API Key",profileSuffix:"default",placeholder:"AI...",url:"https://aistudio.google.com",field:"key"}]}},X3={id:"api_key",label:"API Key",profileSuffix:"default",placeholder:"...",field:"key"},Q3=t=>{let e=An[t]||[];return e.length===0?[X3]:e.map(n=>({id:"api_key",label:n.label||"API Key",profileSuffix:"default",placeholder:n.placeholder||"...",hint:n.hint,url:n.url,field:"key"}))},eR=t=>Y3[t]||{label:Ks[t]||t,modes:Q3(t)},Gi=(t,e)=>`${t.provider||e}:${t.profileSuffix||"default"}`,Mc=t=>String(t?.key||t?.token||t?.access||"").trim(),tR=({codexStatus:t,onRefreshCodex:e})=>{let[n,s]=y(!1),[o,r]=y(!1),[i,a]=y(""),[l,c]=y(!1),d=te(null);R(()=>()=>{d.current&&clearInterval(d.current)},[]),R(()=>{let g=async m=>{m.data?.codex==="success"?(I("Codex connected","success"),s(!1),r(!1),await e()):m.data?.codex==="error"&&I(`Codex auth failed: ${m.data.message||"unknown error"}`,"error")};return window.addEventListener("message",g),()=>window.removeEventListener("message",g)},[e]);let u=()=>{s(!0),r(!0);let g=window.open("/auth/codex/start","codex-auth","popup=yes,width=640,height=780");if(!g||g.closed){r(!1),window.location.href="/auth/codex/start";return}d.current&&clearInterval(d.current),d.current=setInterval(()=>{g.closed&&(clearInterval(d.current),d.current=null,r(!1))},500)},p=async()=>{if(!(!i.trim()||l)){c(!0);try{let g=await zr(i.trim());if(!g.ok)throw new Error(g.error||"Codex OAuth exchange failed");a(""),I("Codex connected","success"),s(!1),r(!1),await e()}catch(g){I(g.message||"Codex OAuth exchange failed","error")}finally{c(!1)}}},f=async()=>{let g=await jr();if(!g.ok){I(g.error||"Failed to disconnect Codex","error");return}I("Codex disconnected","success"),s(!1),r(!1),a(""),await e()};return Nt`
Codex OAuth - ${t.connected?Nt`<${le} tone="success">Connected`:Nt`<${le} tone="warning">Not connected`} + ${t.connected?Nt`<${de} tone="success">Connected`:Nt`<${de} tone="warning">Not connected`}
${t.connected?Nt`
@@ -7524,7 +7554,7 @@ ${B?.grantPublisher||""}`.trim()))} placeholder="http://localhost:1455/auth/callback?code=...&state=..." class="w-full bg-field border border-border rounded-lg px-3 py-2 text-xs text-body outline-none focus:border-fg-muted" /> - <${Y} + <${Z} onClick=${p} disabled=${!i.trim()||l} loading=${l} @@ -7536,63 +7566,63 @@ ${B?.grantPublisher||""}`.trim()))} /> `:null}
- `},zw=({provider:t,authProfiles:e,authOrder:n,codexStatus:s,onEditProfile:o,onEditAuthOrder:r,getProfileValue:i,getEffectiveOrder:a,onRefreshCodex:l})=>{let c=q3(t),d=c.modes.filter($=>!$.isCodexOauth),u=d.length>1,p=c.modes.some($=>$.isCodexOauth),f=a(t),g=f?.[0]||null,m=n[t]||null,h=d.some($=>{let S=zi($,t),C=e.find(k=>k.id===S)||null,_=i(S);return Cc(_)!==Cc(C)}),b=JSON.stringify(f||null)!==JSON.stringify(m),x=h||b,v=d.some($=>{let S=zi($,t),C=i(S);return!!(C?.key||C?.token||C?.access)})||t==="openai-codex"&&!!s?.connected,w=$=>{let S=zi($,t),C=d.map(k=>zi(k,t)),_=[S,...C.filter(k=>k!==S)];r(t,_)};return Nt` + `},Jw=({provider:t,authProfiles:e,authOrder:n,codexStatus:s,onEditProfile:o,onEditAuthOrder:r,getProfileValue:i,getEffectiveOrder:a,onRefreshCodex:l})=>{let c=eR(t),d=c.modes.filter(w=>!w.isCodexOauth),u=d.length>1,p=c.modes.some(w=>w.isCodexOauth),f=a(t),g=f?.[0]||null,m=n[t]||null,h=d.some(w=>{let S=Gi(w,t),C=e.find(k=>k.id===S)||null,_=i(S);return Mc(_)!==Mc(C)}),b=JSON.stringify(f||null)!==JSON.stringify(m),x=h||b,v=d.some(w=>{let S=Gi(w,t),C=i(S);return!!(C?.key||C?.token||C?.access)})||t==="openai-codex"&&!!s?.connected,$=w=>{let S=Gi(w,t),C=d.map(k=>Gi(k,t)),_=[S,...C.filter(k=>k!==S)];r(t,_)};return Nt`

${c.label}

- ${p&&d.length===0?null:x?Nt`<${le} tone="warning">Unsaved`:v?Nt`<${le} tone="success">Connected`:Nt`<${le} tone="warning">Not configured`} + ${p&&d.length===0?null:x?Nt`<${de} tone="warning">Unsaved`:v?Nt`<${de} tone="success">Connected`:Nt`<${de} tone="warning">Not configured`}
- ${d.map($=>{let S=zi($,t),C=$.provider||t,_=i(S),k=_?.[$.field]||"",A=!u||g===S||!g&&$===d[0];return Nt` + ${d.map(w=>{let S=Gi(w,t),C=w.provider||t,_=i(S),k=_?.[w.field]||"",A=!u||g===S||!g&&w===d[0];return Nt`
${w.label} - ${u&&A?Nt`<${le} tone="cyan">Primary`:null} + ${u&&A?Nt`<${de} tone="cyan">Primary`:null} ${u&&!A&&k?Nt``:null} - ${$.url&&!k?Nt`Get`:null}
- <${Rt} + <${Et} value=${k} - onInput=${D=>{let N=D.target.value,U={type:$.id,provider:C,[$.field]:N};_?.expires&&(U.expires=_.expires),o(S,U);let O=e.find(R=>R.id===S)||null;Cc(U)===Cc(O)&&u?r(t,m):u&&N&&!A&&w($)}} - placeholder=${$.placeholder||""} + onInput=${D=>{let O=D.target.value,z={type:w.id,provider:C,[w.field]:O};_?.expires&&(z.expires=_.expires),o(S,z);let N=e.find(L=>L.id===S)||null;Mc(z)===Mc(N)&&u?r(t,m):u&&O&&!A&&$(w)}} + placeholder=${w.placeholder||""} isSecret=${!0} inputClass="flex-1 w-full bg-field border border-border rounded-lg px-3 py-2 text-sm text-body outline-none focus:border-fg-muted font-mono" /> - ${$.hint?Nt`

${$.hint}

`:null} + ${w.hint?Nt`

${w.hint}

`:null}
`})} - ${c.modes.some($=>$.isCodexOauth)?Nt` + ${c.modes.some(w=>w.isCodexOauth)?Nt`
- <${J3} + <${tR} codexStatus=${s} onRefreshCodex=${l} />
`:null}
- `};var At=P.bind(T),Z3=t=>{let e=new Set;for(let n of Object.keys(t)){let s=ri(n);s&&e.add(s)}return[...e]},Y3=["anthropic","openai","openai-codex",...jr.filter(t=>!["anthropic","openai"].includes(t))],Uw=({onRestartRequired:t=()=>{},agentId:e,embedded:n=!1})=>{let{catalog:s,primary:o,configuredModels:r,authProfiles:i,authOrder:a,codexStatus:l,loading:c,saving:d,ready:u,error:p,isDirty:f,addModel:g,removeModel:m,setPrimaryModel:h,editProfile:b,editAuthOrder:x,getProfileValue:v,getEffectiveOrder:w,cancelChanges:$,saveAll:S,refreshCodexStatus:C}=rl(e),_=F(()=>new Set(Object.keys(r)),[r]),k=F(()=>Lo(s),[s]),A=F(()=>k.filter(E=>!_.has(E.key)),[k,_]),D=F(()=>[...s].filter(E=>!_.has(E.key)).sort((E,G)=>{let H=jo($s(E))-jo($s(G));return H!==0?H:String(E.label||E.key).localeCompare(String(G.label||G.key))}),[s,_]),N=F(()=>Z3(r),[r]),U=F(()=>{let E=[];for(let G of Y3)N.includes(G)&&E.push(G);for(let G of N)E.includes(G)||E.push(G);return E},[N]),O=F(()=>sl({authProfiles:i,codexStatus:l}),[i,l]),M=F(()=>Object.keys(r).map(E=>{let G=s.find(te=>te.key===E),H=ri(E),z=!!O[H];return{key:E,label:G?.label||E,isPrimary:E===o,hasAuth:z}}),[r,s,o,O]),R=At` - <${es} visible=${f}> - <${Y} - onClick=${$} + `};var Tt=P.bind(T),nR=t=>{let e=new Set;for(let n of Object.keys(t)){let s=li(n);s&&e.add(s)}return[...e]},sR=["anthropic","openai","openai-codex",...Kr.filter(t=>!["anthropic","openai"].includes(t))],Zw=({onRestartRequired:t=()=>{},agentId:e,embedded:n=!1})=>{let{catalog:s,primary:o,configuredModels:r,authProfiles:i,authOrder:a,codexStatus:l,loading:c,saving:d,ready:u,error:p,isDirty:f,addModel:g,removeModel:m,setPrimaryModel:h,editProfile:b,editAuthOrder:x,getProfileValue:v,getEffectiveOrder:$,cancelChanges:w,saveAll:S,refreshCodexStatus:C}=cl(e),_=W(()=>new Set(Object.keys(r)),[r]),k=W(()=>Lo(s),[s]),A=W(()=>k.filter(E=>!_.has(E.key)),[k,_]),D=W(()=>[...s].filter(E=>!_.has(E.key)).sort((E,U)=>{let F=jo(ws(E))-jo(ws(U));return F!==0?F:String(E.label||E.key).localeCompare(String(U.label||U.key))}),[s,_]),O=W(()=>nR(r),[r]),z=W(()=>{let E=[];for(let U of sR)O.includes(U)&&E.push(U);for(let U of O)E.includes(U)||E.push(U);return E},[O]),N=W(()=>al({authProfiles:i,codexStatus:l}),[i,l]),M=W(()=>Object.keys(r).map(E=>{let U=s.find(re=>re.key===E),F=li(E),K=!!N[F];return{key:E,label:U?.label||E,isPrimary:E===o,hasAuth:K}}),[r,s,o,N]),L=Tt` + <${ts} visible=${f}> + <${Z} + onClick=${w} disabled=${d} tone="secondary" size="sm" idleLabel="Cancel" className="text-xs" /> - <${Y} + <${Z} onClick=${S} disabled=${d} loading=${d} @@ -7603,30 +7633,30 @@ ${B?.grantPublisher||""}`.trim()))} loadingLabel="Saving…" className="text-xs" /> - - `;if(!u){let E=At` + + `;if(!u){let E=Tt`
- <${Ce} className="h-4 w-4" /> + <${Ae} className="h-4 w-4" /> Loading model settings...
- `;return n?E:At` + `;return n?E:Tt` <${Un} - header=${At`<${Pe} title="Models" />`} + header=${Tt`<${De} title="Models" />`} > ${E} - `}let B=At` + `}let B=Tt`

Available Models

- ${M.length===0?At`

+ ${M.length===0?Tt`

No models configured. Add a model below. -

`:At` +

`:Tt`
- ${M.map(E=>At` + ${M.map(E=>Tt`
@@ -7634,14 +7664,14 @@ ${B?.grantPublisher||""}`.trim()))} ${E.label} - ${E.isPrimary?At`<${le} tone="cyan">Primary`:E.hasAuth?At` + ${E.isPrimary?Tt`<${de} tone="cyan">Primary`:E.hasAuth?Tt` - `:At`<${le} tone="warning">Needs auth`} + `:Tt`<${de} tone="warning">Needs auth`}
- ${U.length>0?At` + ${z.length>0?Tt`

Provider Authentication

- ${U.map(E=>At` - <${zw} + ${z.map(E=>Tt` + <${Jw} provider=${E} authProfiles=${i} authOrder=${a} @@ -7683,30 +7713,30 @@ ${B?.grantPublisher||""}`.trim()))} onEditProfile=${b} onEditAuthOrder=${x} getProfileValue=${v} - getEffectiveOrder=${w} + getEffectiveOrder=${$} onRefreshCodex=${C} /> `)}
`:null} - `;return n?At` + `;return n?Tt`
- ${R} + ${L}
${B}
- `:At` + `:Tt` <${Un} - header=${At`<${Pe} title="Models" actions=${R} />`} + header=${Tt`<${De} title="Models" actions=${L} />`} > ${B} - `};var X3=P.bind(T),hf=({onRestartRequired:t=()=>{}})=>X3` - <${Uw} onRestartRequired=${t} /> -`;var Q3=1e4,Kw=({enabled:t=!0}={})=>{let e=Ee(async()=>{let n=await Pm(),s=Array.isArray(n?.nodes)?n.nodes:[],o=Array.isArray(n?.pending)?n.pending:[];return{nodes:s,pending:o}},Q3,{enabled:t,cacheKey:"/api/nodes"});return{nodes:Array.isArray(e.data?.nodes)?e.data.nodes:[],pending:Array.isArray(e.data?.pending)?e.data.pending:[],loading:e.data===null&&!e.error,error:e.error?String(e.error.message||"Could not load nodes"):"",refresh:e.refresh}};var Gw=()=>{let t=Kw({enabled:!0}),[e,n]=y(!1),[s,o]=y(!1),{data:r,error:i}=ct("/api/nodes/connect-info",ya,{maxAgeMs:6e4}),a=Array.isArray(t.nodes)?t.nodes.filter(c=>c?.paired!==!1):[];L(()=>{i&&I(i.message||"Could not load node connect command","error")},[i]);let l=q(async()=>{if(!s){o(!0);try{await t.refresh()}finally{o(!1)}}},[t.refresh,s]);return{state:{wizardVisible:e,nodes:a,pending:t.pending,loadingNodes:t.loading,refreshingNodes:s,nodesError:t.error,connectInfo:r},actions:{openWizard:()=>n(!0),closeWizard:()=>n(!1),refreshNodes:l}}};var eR=35e3,tR=1e4,Jw="nodesBrowserAttachStateByNode",nR=/selected page has been closed/i,sR=async(t,e=eR)=>{let n=null;try{return await Promise.race([t,new Promise((s,o)=>{n=setTimeout(()=>{o(new Error("Browser check timed out"))},e)})])}finally{n&&clearTimeout(n)}},qw=t=>{let e=Array.isArray(t?.caps)?t.caps:[],n=Array.isArray(t?.commands)?t.commands:[];return e.includes("browser")||n.includes("browser.proxy")},oR=t=>{let e=String(t?.message||"Could not check node browser status").trim();return nR.test(e)?"Selected Chrome page was closed. Click Attach to reconnect.":e},rR=()=>{let e=He()?.[Jw];return!e||typeof e!="object"||Array.isArray(e)?{}:e},iR=(t={})=>{kx(e=>({...e&&typeof e=="object"?e:{},[Jw]:t&&typeof t=="object"?t:{}}))},Zw=({nodes:t=[],onRefreshNodes:e=async()=>{}}={})=>{let[n,s]=y({}),[o,r]=y({}),[i,a]=y(""),[l,c]=y(()=>rR()),[d,u]=y(""),[p,f]=y(null),[g,m]=y(""),h=ee(0),b=ee(""),x=async(k,{successMessage:A="Connection command copied",errorMessage:D="Could not copy connection command"}={})=>{if(await Ho(k)){I(A,"success");return}I(D,"error")},v=q(async(k,{silent:A=!1}={})=>{let D=String(k||"").trim();if(!(!D||b.current)){b.current=D,A||a(D),r(N=>({...N,[D]:""}));try{let N=await sR(Em(D,"user")),U=N?.status&&typeof N.status=="object"?N.status:null;s(O=>({...O,[D]:U}))}catch(N){let U=oR(N);s(O=>({...O,[D]:null})),r(O=>({...O,[D]:U})),A||I(U,"error")}finally{b.current="",A||a("")}}},[]),w=q((k,A)=>{let D=String(k||"").trim();D&&c(N=>{let U={...N&&typeof N=="object"?N:{},[D]:A===!0};return iR(U),U})},[]),$=q(async k=>{let A=String(k||"").trim();A&&(w(A,!0),await v(A))},[v,w]),S=q(k=>{let A=String(k||"").trim();A&&(w(A,!1),s(D=>{let N={...D||{}};return delete N[A],N}),r(D=>{let N={...D||{}};return delete N[A],N}))},[w]),C=q(k=>{let A=String(k||"").trim();A&&u(D=>D===A?"":A)},[]),_=q(async()=>{let k=String(p?.nodeId||"").trim();if(!(!k||g)){m(k);try{await Rm(k),S(k),I("Device removed","success"),f(null),u(""),await e()}catch(A){I(A.message||"Could not remove node","error")}finally{m("")}}},[S,e,p,g]);return L(()=>{if(i)return;let k=t.map(A=>({nodeId:String(A?.nodeId||"").trim(),connected:A?.connected===!0,browserCapable:qw(A)})).find(A=>!(!A.nodeId||!A.connected||!A.browserCapable||l?.[A.nodeId]!==!0||n?.[A.nodeId]||o?.[A.nodeId]))?.nodeId;k&&v(k,{silent:!0})},[l,o,n,i,v,t]),L(()=>{if(i)return;let k=t.map(U=>({nodeId:String(U?.nodeId||"").trim(),connected:U?.connected===!0,browserCapable:qw(U),browserRunning:n?.[String(U?.nodeId||"").trim()]?.running===!0})).filter(U=>U.nodeId&&U.connected&&U.browserCapable&&l?.[U.nodeId]===!0&&U.browserRunning).map(U=>U.nodeId);if(!k.length)return;let A=!0,N=setInterval(async()=>{if(!A||b.current)return;let U=h.current%k.length;h.current+=1;let O=k[U];await v(O,{silent:!0})},tR);return()=>{A=!1,clearInterval(N)}},[l,n,i,v,t]),{browserStatusByNodeId:n,browserErrorByNodeId:o,checkingBrowserNodeId:i,browserAttachStateByNodeId:l,menuOpenNodeId:d,removeDialogNode:p,removingNodeId:g,handleCopyText:x,handleCheckNodeBrowser:v,handleAttachNodeBrowser:$,handleDetachNodeBrowser:S,handleOpenNodeMenu:C,handleRemoveNode:_,setMenuOpenNodeId:u,setRemoveDialogNode:f}};var ot=P.bind(T),aR=t=>String(t||"").replace(/"/g,'\\"'),Yw=({node:t,connectInfo:e,maskToken:n=!1})=>{let s=String(e?.gatewayHost||"").trim()||"localhost",o=Number(e?.gatewayPort)||3e3,r=String(e?.gatewayToken||"").trim(),i=e?.tls===!0?"--tls":"",a=String(t?.displayName||t?.nodeId||"My Node").trim(),l=n?"****":r;return[l?`OPENCLAW_GATEWAY_TOKEN=${l}`:"","openclaw node run",`--host ${s}`,`--port ${o}`,i,`--display-name "${aR(a)}"`].filter(Boolean).join(" ")},lR=t=>t?.connected?ot`<${le} tone="success">Connected`:t?.paired?ot`<${le} tone="warning">Disconnected`:ot`<${le} tone="danger">Pending approval`,cR=t=>{let e=Array.isArray(t?.caps)?t.caps:[],n=Array.isArray(t?.commands)?t.commands:[];return e.includes("browser")||n.includes("browser.proxy")},dR=t=>t.running?"success":"warning",uR=t=>t.running?"Attached":"Not connected",Xw=({nodes:t=[],pending:e=[],loading:n=!1,error:s="",connectInfo:o=null,onRefreshNodes:r=async()=>{}})=>{let i=Zw({nodes:t,onRefreshNodes:r}),{browserStatusByNodeId:a,browserErrorByNodeId:l,checkingBrowserNodeId:c,browserAttachStateByNodeId:d,menuOpenNodeId:u,removeDialogNode:p,removingNodeId:f,handleCopyText:g,handleCheckNodeBrowser:m,handleAttachNodeBrowser:h,handleDetachNodeBrowser:b,handleOpenNodeMenu:x,handleRemoveNode:v,setMenuOpenNodeId:w,setRemoveDialogNode:$}=i;return ot` + `};var oR=P.bind(T),gf=({onRestartRequired:t=()=>{}})=>oR` + <${Zw} onRestartRequired=${t} /> +`;var rR=1e4,Yw=({enabled:t=!0}={})=>{let e=Re(async()=>{let n=await Rm(),s=Array.isArray(n?.nodes)?n.nodes:[],o=Array.isArray(n?.pending)?n.pending:[];return{nodes:s,pending:o}},rR,{enabled:t,cacheKey:"/api/nodes"});return{nodes:Array.isArray(e.data?.nodes)?e.data.nodes:[],pending:Array.isArray(e.data?.pending)?e.data.pending:[],loading:e.data===null&&!e.error,error:e.error?String(e.error.message||"Could not load nodes"):"",refresh:e.refresh}};var Xw=()=>{let t=Yw({enabled:!0}),[e,n]=y(!1),[s,o]=y(!1),{data:r,error:i}=pt("/api/nodes/connect-info",ka,{maxAgeMs:6e4}),a=Array.isArray(t.nodes)?t.nodes.filter(c=>c?.paired!==!1):[];R(()=>{i&&I(i.message||"Could not load node connect command","error")},[i]);let l=G(async()=>{if(!s){o(!0);try{await t.refresh()}finally{o(!1)}}},[t.refresh,s]);return{state:{wizardVisible:e,nodes:a,pending:t.pending,loadingNodes:t.loading,refreshingNodes:s,nodesError:t.error,connectInfo:r},actions:{openWizard:()=>n(!0),closeWizard:()=>n(!1),refreshNodes:l}}};var iR=35e3,aR=1e4,e1="nodesBrowserAttachStateByNode",lR=/selected page has been closed/i,cR=async(t,e=iR)=>{let n=null;try{return await Promise.race([t,new Promise((s,o)=>{n=setTimeout(()=>{o(new Error("Browser check timed out"))},e)})])}finally{n&&clearTimeout(n)}},Qw=t=>{let e=Array.isArray(t?.caps)?t.caps:[],n=Array.isArray(t?.commands)?t.commands:[];return e.includes("browser")||n.includes("browser.proxy")},dR=t=>{let e=String(t?.message||"Could not check node browser status").trim();return lR.test(e)?"Selected Chrome page was closed. Click Attach to reconnect.":e},uR=()=>{let e=je()?.[e1];return!e||typeof e!="object"||Array.isArray(e)?{}:e},pR=(t={})=>{Mx(e=>({...e&&typeof e=="object"?e:{},[e1]:t&&typeof t=="object"?t:{}}))},t1=({nodes:t=[],onRefreshNodes:e=async()=>{}}={})=>{let[n,s]=y({}),[o,r]=y({}),[i,a]=y(""),[l,c]=y(()=>uR()),[d,u]=y(""),[p,f]=y(null),[g,m]=y(""),h=te(0),b=te(""),x=async(k,{successMessage:A="Connection command copied",errorMessage:D="Could not copy connection command"}={})=>{if(await Wo(k)){I(A,"success");return}I(D,"error")},v=G(async(k,{silent:A=!1}={})=>{let D=String(k||"").trim();if(!(!D||b.current)){b.current=D,A||a(D),r(O=>({...O,[D]:""}));try{let O=await cR(Im(D,"user")),z=O?.status&&typeof O.status=="object"?O.status:null;s(N=>({...N,[D]:z}))}catch(O){let z=dR(O);s(N=>({...N,[D]:null})),r(N=>({...N,[D]:z})),A||I(z,"error")}finally{b.current="",A||a("")}}},[]),$=G((k,A)=>{let D=String(k||"").trim();D&&c(O=>{let z={...O&&typeof O=="object"?O:{},[D]:A===!0};return pR(z),z})},[]),w=G(async k=>{let A=String(k||"").trim();A&&($(A,!0),await v(A))},[v,$]),S=G(k=>{let A=String(k||"").trim();A&&($(A,!1),s(D=>{let O={...D||{}};return delete O[A],O}),r(D=>{let O={...D||{}};return delete O[A],O}))},[$]),C=G(k=>{let A=String(k||"").trim();A&&u(D=>D===A?"":A)},[]),_=G(async()=>{let k=String(p?.nodeId||"").trim();if(!(!k||g)){m(k);try{await Lm(k),S(k),I("Device removed","success"),f(null),u(""),await e()}catch(A){I(A.message||"Could not remove node","error")}finally{m("")}}},[S,e,p,g]);return R(()=>{if(i)return;let k=t.map(A=>({nodeId:String(A?.nodeId||"").trim(),connected:A?.connected===!0,browserCapable:Qw(A)})).find(A=>!(!A.nodeId||!A.connected||!A.browserCapable||l?.[A.nodeId]!==!0||n?.[A.nodeId]||o?.[A.nodeId]))?.nodeId;k&&v(k,{silent:!0})},[l,o,n,i,v,t]),R(()=>{if(i)return;let k=t.map(z=>({nodeId:String(z?.nodeId||"").trim(),connected:z?.connected===!0,browserCapable:Qw(z),browserRunning:n?.[String(z?.nodeId||"").trim()]?.running===!0})).filter(z=>z.nodeId&&z.connected&&z.browserCapable&&l?.[z.nodeId]===!0&&z.browserRunning).map(z=>z.nodeId);if(!k.length)return;let A=!0,O=setInterval(async()=>{if(!A||b.current)return;let z=h.current%k.length;h.current+=1;let N=k[z];await v(N,{silent:!0})},aR);return()=>{A=!1,clearInterval(O)}},[l,n,i,v,t]),{browserStatusByNodeId:n,browserErrorByNodeId:o,checkingBrowserNodeId:i,browserAttachStateByNodeId:l,menuOpenNodeId:d,removeDialogNode:p,removingNodeId:g,handleCopyText:x,handleCheckNodeBrowser:v,handleAttachNodeBrowser:w,handleDetachNodeBrowser:S,handleOpenNodeMenu:C,handleRemoveNode:_,setMenuOpenNodeId:u,setRemoveDialogNode:f}};var it=P.bind(T),fR=t=>String(t||"").replace(/"/g,'\\"'),n1=({node:t,connectInfo:e,maskToken:n=!1})=>{let s=String(e?.gatewayHost||"").trim()||"localhost",o=Number(e?.gatewayPort)||3e3,r=String(e?.gatewayToken||"").trim(),i=e?.tls===!0?"--tls":"",a=String(t?.displayName||t?.nodeId||"My Node").trim(),l=n?"****":r;return[l?`OPENCLAW_GATEWAY_TOKEN=${l}`:"","openclaw node run",`--host ${s}`,`--port ${o}`,i,`--display-name "${fR(a)}"`].filter(Boolean).join(" ")},hR=t=>t?.connected?it`<${de} tone="success">Connected`:t?.paired?it`<${de} tone="warning">Disconnected`:it`<${de} tone="danger">Pending approval`,mR=t=>{let e=Array.isArray(t?.caps)?t.caps:[],n=Array.isArray(t?.commands)?t.commands:[];return e.includes("browser")||n.includes("browser.proxy")},gR=t=>t.running?"success":"warning",bR=t=>t.running?"Attached":"Not connected",s1=({nodes:t=[],pending:e=[],loading:n=!1,error:s="",connectInfo:o=null,onRefreshNodes:r=async()=>{}})=>{let i=t1({nodes:t,onRefreshNodes:r}),{browserStatusByNodeId:a,browserErrorByNodeId:l,checkingBrowserNodeId:c,browserAttachStateByNodeId:d,menuOpenNodeId:u,removeDialogNode:p,removingNodeId:f,handleCopyText:g,handleCheckNodeBrowser:m,handleAttachNodeBrowser:h,handleDetachNodeBrowser:b,handleOpenNodeMenu:x,handleRemoveNode:v,setMenuOpenNodeId:$,setRemoveDialogNode:w}=i;return it`
- ${e.length?ot` + ${e.length?it`
@@ -7714,22 +7744,22 @@ ${B?.grantPublisher||""}`.trim()))} waiting for approval.
`:null} - ${n?ot` + ${n?it`
- <${Ce} className="h-4 w-4" /> + <${Ae} className="h-4 w-4" /> Loading nodes...
- `:s?ot` + `:s?it`
${s}
- `:t.length?ot` + `:t.length?it`
- ${t.map(S=>{let C=String(S?.nodeId||"").trim(),_=a[C]||null,k=l[C]||"",A=c===C,D=S?.connected&&cR(S)&&C,N=d?.[C]===!0,U=!!_||!!k,O=_?.running===!0,M=N&&!U&&!A,R=D&&N&&!A&&U&&!O;return ot` + ${t.map(S=>{let C=String(S?.nodeId||"").trim(),_=a[C]||null,k=l[C]||"",A=c===C,D=S?.connected&&mR(S)&&C,O=d?.[C]===!0,z=!!_||!!k,N=_?.running===!0,M=O&&!z&&!A,L=D&&O&&!A&&z&&!N;return it`
@@ -7739,13 +7769,13 @@ ${B?.grantPublisher||""}`.trim()))}
${S?.displayName||S?.nodeId||"Unnamed node"}
- ${C?ot` + ${C?it`
- ${lR(S)} - ${S?.paired?ot` - <${pt} + ${hR(S)} + ${S?.paired?it` + <${mt} open=${u===C} ariaLabel="Open node actions" title="Open node actions" - onClose=${()=>w("")} + onClose=${()=>$("")} onToggle=${()=>x(C)} > - <${Oe} + <${We} className="text-status-error hover:text-status-error" - onClick=${()=>{w(""),$(S)}} + onClick=${()=>{$(""),w(S)}} > Remove device - - + + `:null}
@@ -7789,7 +7819,7 @@ ${B?.grantPublisher||""}`.trim()))} >
- ${D?ot` + ${D?it`
Browser
- ${N?ot` + ${O?it`
profile: user
- `:ot` + `:it`
@@ -7820,40 +7850,40 @@ ${B?.grantPublisher||""}`.trim()))} `}
- ${_?ot` + ${_?it` - <${le} tone=${dR(_)} - >${uR(_)}${bR(_)} `:null} - ${M?ot` - <${Ce} + ${M?it` + <${Ae} className="h-3.5 w-3.5" /> `:null} - ${A?ot` - <${Ce} + ${A?it` + <${Ae} className="h-3.5 w-3.5" /> `:null} - ${D&&!N?ot` - <${Y} + ${D&&!O?it` + <${Z} onClick=${()=>h(C)} idleLabel="Attach" tone="primary" size="sm" /> `:null} - ${R?ot` - <${Y} + ${L?it` + <${Z} onClick=${()=>m(C)} idleLabel="Check" tone="secondary" size="sm" /> `:null} - ${D&&N&&!A?ot` + ${D&&O&&!A?it`
- ${_?ot` + ${_?it`
@@ -7886,7 +7916,7 @@ ${B?.grantPublisher||""}`.trim()))}
`:null} - ${k?ot`
${k} @@ -7894,7 +7924,7 @@ ${B?.grantPublisher||""}`.trim()))}
`:null} - ${S?.paired&&!S?.connected&&o?ot` + ${S?.paired&&!S?.connected&&o?it`
@@ -7905,15 +7935,15 @@ ${B?.grantPublisher||""}`.trim()))} - <${Y} - onClick=${()=>g(Yw({node:S,connectInfo:o,maskToken:!1}),{successMessage:"Connection command copied",errorMessage:"Could not copy connection command"})} + <${Z} + onClick=${()=>g(n1({node:S,connectInfo:o,maskToken:!1}),{successMessage:"Connection command copied",errorMessage:"Could not copy connection command"})} tone="secondary" size="sm" iconOnly=${!0} - idleIcon=${Ks} + idleIcon=${Gs} idleIconClassName="w-3.5 h-3.5" ariaLabel="Copy reconnect command" title="Copy reconnect command" @@ -7924,12 +7954,12 @@ ${B?.grantPublisher||""}`.trim()))}
`})}
- `:ot` + `:it`
- <${Pa} className="h-12 w-12 text-cyan-400" /> + <${Ia} className="h-12 w-12 text-cyan-400" />

No connected nodes yet @@ -7943,7 +7973,7 @@ ${B?.grantPublisher||""}`.trim()))}

`}
- <${st} + <${rt} visible=${!!p} title="Remove device?" message=${p?.connected?"This device is currently connected. Removing it will disconnect and remove the paired device from this gateway (equivalent to running openclaw devices remove for this device id). The device can reconnect and pair again later.":"This removes the paired device from this gateway (equivalent to running openclaw devices remove for this device id). The device can reconnect and pair again later."} @@ -7952,10 +7982,10 @@ ${B?.grantPublisher||""}`.trim()))} confirmTone="warning" confirmLoading=${!!f} confirmDisabled=${!!f} - onCancel=${()=>{f||$(null)}} + onCancel=${()=>{f||w(null)}} onConfirm=${v} /> - `};var pR=P.bind(T),fR="https://github.com/openclaw/openclaw/releases/tag/v2026.3.13",hR=`Release reference: [OpenClaw 2026.3.13](${fR}) + `};var xR=P.bind(T),yR="https://github.com/openclaw/openclaw/releases/tag/v2026.3.13",vR=`Release reference: [OpenClaw 2026.3.13](${yR}) ## Requirements @@ -7995,7 +8025,7 @@ On first connect, Chrome prompts for DevTools MCP access. Click **Allow**. | Config validation error on existing-session | Do not define a custom existing-session profile. Use \`defaultProfile: "user"\`. | | EADDRINUSE on port 9222 | Quit Chrome launched with \`--remote-debugging-port\` and relaunch normally. | | Consent dialog appears but attach hangs | Quit Chrome, relaunch, and approve the dialog again. | -| \`npx chrome-devtools-mcp\` not found | Install Node.js on the Mac node so \`npx\` exists in PATH. |`,Qw=()=>{let t=F(()=>Ie.parse(hR,{gfm:!0,breaks:!0}),[]);return pR` +| \`npx chrome-devtools-mcp\` not found | Install Node.js on the Mac node so \`npx\` exists in PATH. |`,o1=()=>{let t=W(()=>Fe.parse(vR,{gfm:!0,breaks:!0}),[]);return xR`
@@ -8007,7 +8037,7 @@ On first connect, Chrome prompts for DevTools MCP access. Click **Allow**. dangerouslySetInnerHTML=${{__html:t}} >
- `};var e1=3e3,t1=({visible:t=!1,nodes:e=[],refreshNodes:n=async()=>{},onRestartRequired:s=()=>{},onClose:o=()=>{}}={})=>{let[r,i]=y(0),[a,l]=y(null),[c,d]=y(!1),[u,p]=y("My Mac Node"),[f,g]=y(""),[m,h]=y(!1),[b,x]=y([]),[v,w]=y(!1),$=ee(!1);L(()=>{t&&(i(0),g(""),h(!1),w(!1))},[t]),L(()=>{t&&(d(!0),ya().then(O=>{l(O||null)}).catch(O=>{I(O.message||"Could not load node connect command","error")}).finally(()=>{d(!1)}))},[t]);let S=F(()=>{let O=new Set,M=[];for(let R of e){let B=String(R?.nodeId||"").trim();!B||O.has(B)||R?.paired!==!1&&(O.add(B),M.push({nodeId:B,displayName:String(R?.displayName||R?.name||B),connected:R?.connected===!0}))}return M},[e]),C=F(()=>S.find(O=>O.nodeId===String(f||"").trim())||null,[S,f]),_=F(()=>{if(!a)return"";let O=String(a.gatewayHost||"").trim()||"localhost",M=Number(a.gatewayPort)||3e3,R=String(a.gatewayToken||"").trim(),B=a.tls===!0?" --tls":"",E=String(u||"").trim().replace(/"/g,'\\"');return[R?`OPENCLAW_GATEWAY_TOKEN=${R}`:"","openclaw node run",`--host ${O}`,`--port ${M}`,B.trim(),E?`--display-name "${E}"`:""].filter(Boolean).join(" ")},[a,u]),k=q(async()=>{if(!$.current){$.current=!0;try{await n();let O=await ga(),M=Array.isArray(O?.pending)?O.pending:[];x(M)}finally{$.current=!1}}},[n]);L(()=>{if(!t||r!==1)return;let O=!0,M=async()=>{if(O)try{await k()}catch{}};M();let R=setInterval(M,e1);return()=>{O=!1,clearInterval(R)}},[k,r,t]),L(()=>{if(!t||r!==1)return;let O=S.some(B=>B.nodeId===String(f||"").trim()),M=String(u||"").trim().toLowerCase(),R=S.find(B=>String(B?.displayName||"").trim().toLowerCase()===M)||S[0];R&&(O&&String(f||"").trim()===R.nodeId||g(R.nodeId))},[u,S,f,r,t]);let A=q(async O=>{try{await ba(O),I("Pairing approved","success"),w(!0),await k()}catch(M){I(M.message||"Could not approve pairing","error")}},[k]),D=q(async O=>{try{await xa(O),I("Pairing rejected","info"),await k()}catch(M){I(M.message||"Could not reject pairing","error")}},[k]),N=q(async()=>{let O=String(f||"").trim();if(!O||m)return!1;h(!0);try{return await Lm(O),s(!0),I("Gateway routing now points to the selected node","success"),!0}catch(M){return I(M.message||"Could not configure gateway node routing","error"),!1}finally{h(!1)}},[m,s,f]),U=q(()=>{o()},[o]);return{step:r,setStep:i,connectInfo:a,loadingConnectInfo:c,displayName:u,setDisplayName:p,selectedNodeId:f,setSelectedNodeId:g,pairedNodes:S,selectedPairedNode:C,devicePending:b,approvedInSession:v,configuring:m,canFinish:v&&!!C?.connected,connectCommand:_,refreshNodeList:k,nodeDiscoveryPollIntervalMs:e1,handleDeviceApprove:A,handleDeviceReject:D,applyGatewayNodeRouting:N,completeWizard:U}};var an=P.bind(T),Ui=["Install OpenClaw CLI","Connect Node"],n1=({command:t="",onCopy:e=()=>{}})=>an` + `};var r1=3e3,i1=({visible:t=!1,nodes:e=[],refreshNodes:n=async()=>{},onRestartRequired:s=()=>{},onClose:o=()=>{}}={})=>{let[r,i]=y(0),[a,l]=y(null),[c,d]=y(!1),[u,p]=y("My Mac Node"),[f,g]=y(""),[m,h]=y(!1),[b,x]=y([]),[v,$]=y(!1),w=te(!1);R(()=>{t&&(i(0),g(""),h(!1),$(!1))},[t]),R(()=>{t&&(d(!0),ka().then(N=>{l(N||null)}).catch(N=>{I(N.message||"Could not load node connect command","error")}).finally(()=>{d(!1)}))},[t]);let S=W(()=>{let N=new Set,M=[];for(let L of e){let B=String(L?.nodeId||"").trim();!B||N.has(B)||L?.paired!==!1&&(N.add(B),M.push({nodeId:B,displayName:String(L?.displayName||L?.name||B),connected:L?.connected===!0}))}return M},[e]),C=W(()=>S.find(N=>N.nodeId===String(f||"").trim())||null,[S,f]),_=W(()=>{if(!a)return"";let N=String(a.gatewayHost||"").trim()||"localhost",M=Number(a.gatewayPort)||3e3,L=String(a.gatewayToken||"").trim(),B=a.tls===!0?" --tls":"",E=String(u||"").trim().replace(/"/g,'\\"');return[L?`OPENCLAW_GATEWAY_TOKEN=${L}`:"","openclaw node run",`--host ${N}`,`--port ${M}`,B.trim(),E?`--display-name "${E}"`:""].filter(Boolean).join(" ")},[a,u]),k=G(async()=>{if(!w.current){w.current=!0;try{await n();let N=await va(),M=Array.isArray(N?.pending)?N.pending:[];x(M)}finally{w.current=!1}}},[n]);R(()=>{if(!t||r!==1)return;let N=!0,M=async()=>{if(N)try{await k()}catch{}};M();let L=setInterval(M,r1);return()=>{N=!1,clearInterval(L)}},[k,r,t]),R(()=>{if(!t||r!==1)return;let N=S.some(B=>B.nodeId===String(f||"").trim()),M=String(u||"").trim().toLowerCase(),L=S.find(B=>String(B?.displayName||"").trim().toLowerCase()===M)||S[0];L&&(N&&String(f||"").trim()===L.nodeId||g(L.nodeId))},[u,S,f,r,t]);let A=G(async N=>{try{await $a(N),I("Pairing approved","success"),$(!0),await k()}catch(M){I(M.message||"Could not approve pairing","error")}},[k]),D=G(async N=>{try{await wa(N),I("Pairing rejected","info"),await k()}catch(M){I(M.message||"Could not reject pairing","error")}},[k]),O=G(async()=>{let N=String(f||"").trim();if(!N||m)return!1;h(!0);try{return await Em(N),s(!0),I("Gateway routing now points to the selected node","success"),!0}catch(M){return I(M.message||"Could not configure gateway node routing","error"),!1}finally{h(!1)}},[m,s,f]),z=G(()=>{o()},[o]);return{step:r,setStep:i,connectInfo:a,loadingConnectInfo:c,displayName:u,setDisplayName:p,selectedNodeId:f,setSelectedNodeId:g,pairedNodes:S,selectedPairedNode:C,devicePending:b,approvedInSession:v,configuring:m,canFinish:v&&!!C?.connected,connectCommand:_,refreshNodeList:k,nodeDiscoveryPollIntervalMs:r1,handleDeviceApprove:A,handleDeviceReject:D,applyGatewayNodeRouting:O,completeWizard:z}};var an=P.bind(T),qi=["Install OpenClaw CLI","Connect Node"],a1=({command:t="",onCopy:e=()=>{}})=>an`
-        <${Ks} className="w-3.5 h-3.5" />
+        <${Gs} className="w-3.5 h-3.5" />
         Copy
       
     
-`,s1=async(t,e="text")=>{if(await Ho(t)){I("Copied to clipboard","success");return}I(`Could not copy ${e}`,"error")},o1=({visible:t=!1,nodes:e=[],refreshNodes:n=async()=>{},onRestartRequired:s=()=>{},onClose:o=()=>{}})=>{let r=t1({visible:t,nodes:e,refreshNodes:n,onRestartRequired:s,onClose:o}),i=r.step===Ui.length-1;return an` - <${Te} +`,l1=async(t,e="text")=>{if(await Wo(t)){I("Copied to clipboard","success");return}I(`Could not copy ${e}`,"error")},c1=({visible:t=!1,nodes:e=[],refreshNodes:n=async()=>{},onRestartRequired:s=()=>{},onClose:o=()=>{}})=>{let r=i1({visible:t,nodes:e,refreshNodes:n,onRestartRequired:s,onClose:o}),i=r.step===qi.length-1;return an` + <${Ie} visible=${t} onClose=${o} closeOnOverlayClick=${!1} @@ -8039,12 +8069,12 @@ ${t} - <${Ze} className="w-3.5 h-3.5 text-body" /> + <${Qe} className="w-3.5 h-3.5 text-body" />
Node Setup Wizard
- ${Ui.map((a,l)=>an` + ${qi.map((a,l)=>an`

- Step ${r.step+1} of ${Ui.length}: ${Ui[r.step]} + Step ${r.step+1} of ${qi.length}: ${qi[r.step]}

${r.step===0?an`
Install OpenClaw on the machine you want to connect as a node.
- ${n1({command:"npm install -g openclaw",onCopy:()=>s1("npm install -g openclaw","command")})} + ${a1({command:"npm install -g openclaw",onCopy:()=>l1("npm install -g openclaw","command")})}
Requires Node.js 22+.
`:null} @@ -8081,10 +8111,10 @@ ${t} ${r.loadingConnectInfo?an`
Loading command... -
`:n1({command:r.connectCommand||"Could not build connect command.",onCopy:()=>s1(r.connectCommand||"","command")})} +
`:a1({command:r.connectCommand||"Could not build connect command.",onCopy:()=>l1(r.connectCommand||"","command")})}
${r.devicePending.length?an` - <${xc} + <${wc} pending=${r.devicePending} onApprove=${r.handleDeviceApprove} onReject=${r.handleDeviceReject} @@ -8109,7 +8139,7 @@ ${t} ${r.step===0?an`
`:an` - <${Y} + <${Z} onClick=${()=>r.setStep(Math.max(0,r.step-1))} idleLabel="Back" tone="secondary" @@ -8118,7 +8148,7 @@ ${t} `} ${i?an` - <${Y} + <${Z} onClick=${async()=>{await r.applyGatewayNodeRouting()&&(r.completeWizard(),Promise.resolve(n()).catch(()=>{}))}} loading=${r.configuring} idleLabel=${r.canFinish?"Finish":"Awaiting pairing"} @@ -8129,8 +8159,8 @@ ${t} `:an` - <${Y} - onClick=${()=>r.setStep(Math.min(Ui.length-1,r.step+1))} + <${Z} + onClick=${()=>r.setStep(Math.min(qi.length-1,r.step+1))} idleLabel="Next" tone="primary" size="md" @@ -8138,13 +8168,13 @@ ${t} `}
- - `};var r1=P.bind(T),i1=({onRestartRequired:t=()=>{}})=>{let{state:e,actions:n}=Gw();return r1` + + `};var d1=P.bind(T),u1=({onRestartRequired:t=()=>{}})=>{let{state:e,actions:n}=Xw();return d1`
- <${Pe} + <${De} title="Nodes" - actions=${r1` - <${Y} + actions=${d1` + <${Z} onClick=${n.refreshNodes} loading=${e.refreshingNodes} loadingMode="inline" @@ -8152,7 +8182,7 @@ ${t} - <${Y} + <${Z} onClick=${n.openWizard} idleLabel="Connect Node" tone="primary" @@ -8161,7 +8191,7 @@ ${t} - <${Xw} + <${s1} nodes=${e.nodes} pending=${e.pending} loading=${e.loadingNodes} @@ -8170,9 +8200,9 @@ ${t} - <${Qw} /> + <${o1} /> - <${o1} + <${c1} visible=${e.wizardVisible} nodes=${e.nodes} refreshNodes=${n.refreshNodes} @@ -8180,38 +8210,38 @@ ${t}
- `};var mR=P.bind(T),mf=({onRestartRequired:t=()=>{}})=>mR` + `};var $R=P.bind(T),bf=({onRestartRequired:t=()=>{}})=>$R`
- <${i1} onRestartRequired=${t} /> + <${u1} onRestartRequired=${t} />
-`;var JU=P.bind(T);var ZU=Object.values(An).flat().map(t=>t.key).filter((t,e,n)=>n.indexOf(t)===e);var nK=P.bind(T);var Ki=({to:t})=>{let[,e]=ca();return L(()=>{e(t)},[t,e]),null};var Gi=(t,e)=>{let n=String(e||"").trim();n&&t.set("accountId",n)},a1=async({accountId:t=""}={})=>{let e=new URLSearchParams;Gi(e,t);let n=e.toString()?`?${e.toString()}`:"";return(await X(`/api/telegram/bot${n}`)).json()},l1=async({accountId:t=""}={})=>{let e=new URLSearchParams;Gi(e,t);let n=e.toString()?`?${e.toString()}`:"";return(await X(`/api/telegram/workspace${n}`)).json()},c1=async({accountId:t=""}={})=>{let e=new URLSearchParams;Gi(e,t);let n=e.toString()?`?${e.toString()}`:"";return(await X(`/api/telegram/workspace/reset${n}`,{method:"POST"})).json()},d1=async(t,{accountId:e=""}={})=>(await X("/api/telegram/groups/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupId:t,accountId:e})})).json(),_c=async(t,{accountId:e=""}={})=>{let n=new URLSearchParams;Gi(n,e);let s=n.toString()?`?${n.toString()}`:"";return(await X(`/api/telegram/groups/${encodeURIComponent(t)}/topics${s}`)).json()},Ac=async(t,e,{accountId:n=""}={})=>(await X(`/api/telegram/groups/${encodeURIComponent(t)}/topics/bulk`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topics:e,accountId:n})})).json(),Mc=async(t,e,{accountId:n=""}={})=>{let s=new URLSearchParams;Gi(s,n);let o=s.toString()?`?${s.toString()}`:"";return(await X(`/api/telegram/groups/${encodeURIComponent(t)}/topics/${e}${o}`,{method:"DELETE"})).json()},u1=async(t,e,n,{accountId:s=""}={})=>(await X(`/api/telegram/groups/${encodeURIComponent(t)}/topics/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...n,accountId:s})})).json(),p1=async(t,e,{accountId:n=""}={})=>(await X(`/api/telegram/groups/${encodeURIComponent(t)}/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,accountId:n})})).json();var Mt=P.bind(T),f1=({currentStep:t,steps:e})=>Mt` +`;var nK=P.bind(T);var sK=Object.values(An).flat().map(t=>t.key).filter((t,e,n)=>n.indexOf(t)===e);var cK=P.bind(T);var Ji=({to:t})=>{let[,e]=pa();return R(()=>{e(t)},[t,e]),null};var Zi=(t,e)=>{let n=String(e||"").trim();n&&t.set("accountId",n)},p1=async({accountId:t=""}={})=>{let e=new URLSearchParams;Zi(e,t);let n=e.toString()?`?${e.toString()}`:"";return(await X(`/api/telegram/bot${n}`)).json()},f1=async({accountId:t=""}={})=>{let e=new URLSearchParams;Zi(e,t);let n=e.toString()?`?${e.toString()}`:"";return(await X(`/api/telegram/workspace${n}`)).json()},h1=async({accountId:t=""}={})=>{let e=new URLSearchParams;Zi(e,t);let n=e.toString()?`?${e.toString()}`:"";return(await X(`/api/telegram/workspace/reset${n}`,{method:"POST"})).json()},m1=async(t,{accountId:e=""}={})=>(await X("/api/telegram/groups/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupId:t,accountId:e})})).json(),Tc=async(t,{accountId:e=""}={})=>{let n=new URLSearchParams;Zi(n,e);let s=n.toString()?`?${n.toString()}`:"";return(await X(`/api/telegram/groups/${encodeURIComponent(t)}/topics${s}`)).json()},Pc=async(t,e,{accountId:n=""}={})=>(await X(`/api/telegram/groups/${encodeURIComponent(t)}/topics/bulk`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topics:e,accountId:n})})).json(),Rc=async(t,e,{accountId:n=""}={})=>{let s=new URLSearchParams;Zi(s,n);let o=s.toString()?`?${s.toString()}`:"";return(await X(`/api/telegram/groups/${encodeURIComponent(t)}/topics/${e}${o}`,{method:"DELETE"})).json()},g1=async(t,e,n,{accountId:s=""}={})=>(await X(`/api/telegram/groups/${encodeURIComponent(t)}/topics/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...n,accountId:s})})).json(),b1=async(t,e,{accountId:n=""}={})=>(await X(`/api/telegram/groups/${encodeURIComponent(t)}/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,accountId:n})})).json();var Pt=P.bind(T),x1=({currentStep:t,steps:e})=>Pt`
- ${e.map((n,s)=>Mt` + ${e.map((n,s)=>Pt`
`)}
-`,h1=({accountId:t,botInfo:e,setBotInfo:n,onNext:s})=>{let[o,r]=y(!1),[i,a]=y(null),l=async()=>{r(!0),a(null);try{let c=await a1({accountId:t});if(!c.ok)throw new Error(c.error);n(c.bot)}catch(c){a(c.message)}r(!1)};return L(()=>{e||l()},[]),Mt` +`,y1=({accountId:t,botInfo:e,setBotInfo:n,onNext:s})=>{let[o,r]=y(!1),[i,a]=y(null),l=async()=>{r(!0),a(null);try{let c=await p1({accountId:t});if(!c.ok)throw new Error(c.error);n(c.bot)}catch(c){a(c.message)}r(!1)};return R(()=>{e||l()},[]),Pt`

Verify Bot Setup

- ${e&&Mt` + ${e&&Pt`
@${e.username} - <${le} tone="success">Connected + <${de} tone="success">Connected

${e.first_name}

`} - ${i&&Mt` + ${i&&Pt`

${i}

`} - ${!e&&!o&&!i&&Mt`

Checking bot token...

`} + ${!e&&!o&&!i&&Pt`

Checking bot token...

`}

@@ -8244,7 +8274,7 @@ ${t}

- `},m1=({onNext:t,onBack:e})=>Mt` + `},v1=({onNext:t,onBack:e})=>Pt`

Create a Telegram Group

@@ -8312,7 +8342,7 @@ ${t}
-`,g1=({accountId:t,groupId:e,setGroupId:n,groupInfo:s,setGroupInfo:o,userId:r,setUserId:i,verifyGroupError:a,setVerifyGroupError:l,onNext:c,onBack:d})=>{let[u,p]=y(e||""),[f,g]=y(!1),[m,h]=y(!1),b=s?[...s.chat?.isForum?[]:["Topics are OFF. Enable Topics in Telegram group settings."],...s.bot?.isAdmin?[]:["Bot is not an admin. Promote it to admin in group members."],...s.bot?.canManageTopics?[]:["Bot is missing Manage Topics permission. Enable it in admin permissions."]]:[],x=async()=>{let $=u.trim();if($){g(!0),l(null);try{let S=await d1($,{accountId:t});if(!S.ok)throw new Error(S.error);n($),o(S),!String(r||"").trim()&&S.suggestedUserId&&i(String(S.suggestedUserId))}catch(S){l(S.message),o(null)}g(!1)}},v=!!(s&&s.chat?.isForum&&s.bot?.isAdmin&&s.bot?.canManageTopics),w=async()=>{if(!(!v||m)){l(null),h(!0);try{let $=String(r||"").trim(),S=await p1(e,{...$?{userId:$}:{},groupName:s?.chat?.title||e,requireMention:!1},{accountId:t});if(!S?.ok)throw new Error(S?.error||"Failed to configure Telegram group");S.userId&&i(String(S.userId)),c()}catch($){l($.message)}h(!1)}};return Mt` +`,$1=({accountId:t,groupId:e,setGroupId:n,groupInfo:s,setGroupInfo:o,userId:r,setUserId:i,verifyGroupError:a,setVerifyGroupError:l,onNext:c,onBack:d})=>{let[u,p]=y(e||""),[f,g]=y(!1),[m,h]=y(!1),b=s?[...s.chat?.isForum?[]:["Topics are OFF. Enable Topics in Telegram group settings."],...s.bot?.isAdmin?[]:["Bot is not an admin. Promote it to admin in group members."],...s.bot?.canManageTopics?[]:["Bot is missing Manage Topics permission. Enable it in admin permissions."]]:[],x=async()=>{let w=u.trim();if(w){g(!0),l(null);try{let S=await m1(w,{accountId:t});if(!S.ok)throw new Error(S.error);n(w),o(S),!String(r||"").trim()&&S.suggestedUserId&&i(String(S.suggestedUserId))}catch(S){l(S.message),o(null)}g(!1)}},v=!!(s&&s.chat?.isForum&&s.bot?.isAdmin&&s.bot?.canManageTopics),$=async()=>{if(!(!v||m)){l(null),h(!0);try{let w=String(r||"").trim(),S=await b1(e,{...w?{userId:w}:{},groupName:s?.chat?.title||e,requireMention:!1},{accountId:t});if(!S?.ok)throw new Error(S?.error||"Failed to configure Telegram group");S.userId&&i(String(S.userId)),c()}catch(w){l(w.message)}h(!1)}};return Pt`

Verify Group

@@ -8336,11 +8366,11 @@ ${t}p($.target.value)} + onInput=${w=>p(w.target.value)} placeholder="-100XXXXXXXXXX" class="flex-1 bg-field border border-border rounded-lg px-3 py-2 text-sm text-body placeholder-fg-dim focus:outline-none focus:border-fg-muted" /> - <${Y} + <${Z} onClick=${x} disabled=${!u.trim()||f} loading=${f} @@ -8352,16 +8382,16 @@ ${t}
- ${a&&Mt` + ${a&&Pt`

${a}

`} - ${s&&Mt` + ${s&&Pt`
${s.chat.title} - <${le} tone="success">Verified + <${de} tone="success">Verified
Topics: ${s.chat.isForum?"ON":"OFF"} @@ -8369,13 +8399,13 @@ ${t}
`} - ${s&&b.length===0&&Mt` + ${s&&b.length===0&&Pt`

Your Telegram User ID

i($.target.value)} + onInput=${w=>i(w.target.value)} placeholder="e.g. 123456789" class="w-full bg-field border border-border rounded-lg px-3 py-2 text-sm text-body placeholder-fg-dim focus:outline-none focus:border-fg-muted" /> @@ -8384,7 +8414,7 @@ ${t}
`} - ${b.length>0&&Mt` + ${b.length>0&&Pt`
@@ -8392,7 +8422,7 @@ ${t}
    - ${b.map($=>Mt`
  • ${$}
  • `)} + ${b.map(w=>Pt`
  • ${w}
  • `)}

Once fixed, hit Verify again.

@@ -8406,7 +8436,7 @@ ${t}
- `},b1=({accountId:t,groupId:e,topics:n,setTopics:s,onNext:o,onBack:r})=>{let[i,a]=y(""),[l,c]=y(""),[d,u]=y(!1),[p,f]=y(null),[g,m]=y(null),[h,b]=y(null),x=async()=>{let S=await _c(e,{accountId:t});S.ok&&s(S.topics)};L(()=>{x()},[e]);let v=async()=>{let S=i.trim(),C=l.trim();if(S){u(!0),f(null);try{let _=await Ac(e,[{name:S,...C?{systemInstructions:C}:{}}],{accountId:t});if(!_.ok)throw new Error(_.results?.[0]?.error||"Failed to create topic");let k=_.results.filter(A=>!A.ok);if(k.length>0)throw new Error(k[0].error);a(""),c(""),await x(),I(`Created topic: ${S}`,"success")}catch(_){f(_.message)}u(!1)}},w=async(S,C)=>{m(S);try{let _=await Mc(e,S,{accountId:t});if(!_.ok)throw new Error(_.error);await x(),_.removedFromRegistryOnly?I(`Removed stale topic from registry: ${C}`,"success"):I(`Deleted topic: ${C}`,"success")}catch(_){I(`Failed to delete: ${_.message}`,"error")}m(null)},$=Object.entries(n||{});return Mt` + `},w1=({accountId:t,groupId:e,topics:n,setTopics:s,onNext:o,onBack:r})=>{let[i,a]=y(""),[l,c]=y(""),[d,u]=y(!1),[p,f]=y(null),[g,m]=y(null),[h,b]=y(null),x=async()=>{let S=await Tc(e,{accountId:t});S.ok&&s(S.topics)};R(()=>{x()},[e]);let v=async()=>{let S=i.trim(),C=l.trim();if(S){u(!0),f(null);try{let _=await Pc(e,[{name:S,...C?{systemInstructions:C}:{}}],{accountId:t});if(!_.ok)throw new Error(_.results?.[0]?.error||"Failed to create topic");let k=_.results.filter(A=>!A.ok);if(k.length>0)throw new Error(k[0].error);a(""),c(""),await x(),I(`Created topic: ${S}`,"success")}catch(_){f(_.message)}u(!1)}},$=async(S,C)=>{m(S);try{let _=await Rc(e,S,{accountId:t});if(!_.ok)throw new Error(_.error);await x(),_.removedFromRegistryOnly?I(`Removed stale topic from registry: ${C}`,"success"):I(`Deleted topic: ${C}`,"success")}catch(_){I(`Failed to delete: ${_.message}`,"error")}m(null)},w=Object.entries(n||{});return Pt`

Create Topics

- ${$.length>0&&Mt` + ${w.length>0&&Pt`
@@ -8435,7 +8465,7 @@ ${t} - ${$.map(([S,C])=>Mt` + ${w.map(([S,C])=>Pt` ${C.name} ${S} @@ -8486,7 +8516,7 @@ ${t}
- <${Y} + <${Z} onClick=${v} disabled=${d||!i.trim()} loading=${d} @@ -8501,7 +8531,7 @@ ${t}
- ${p&&Mt` + ${p&&Pt`

${p}

@@ -8516,13 +8546,13 @@ ${t}
- <${st} + <${rt} visible=${!!h} title="Delete topic?" message=${h?`This will delete "${h.name}" (thread ${h.id}) from your Telegram workspace.`:"This will delete this topic from your Telegram workspace."} @@ -8532,10 +8562,10 @@ ${t}{g||b(null)}} - onConfirm=${async()=>{if(!h)return;let S=h;b(null),await w(S.id,S.name)}} + onConfirm=${async()=>{if(!h)return;let S=h;b(null),await $(S.id,S.name)}} />
- `},x1=({groupId:t,groupInfo:e,topics:n,onBack:s,onDone:o})=>Mt` + `},k1=({groupId:t,groupInfo:e,topics:n,onBack:s,onDone:o})=>Pt`

🎉 Setup complete

@@ -8568,18 +8598,18 @@ ${t}
- `;var Tt=P.bind(T),y1=({value:t,agents:e,onChange:n,className:s=""})=>Tt` + `;var Rt=P.bind(T),S1=({value:t,agents:e,onChange:n,className:s=""})=>Rt` -`,bf=({accountId:t,groupId:e,groupName:n,initialTopics:s,configAgentMaxConcurrent:o,configSubagentMaxConcurrent:r,debugEnabled:i,onResetOnboarding:a})=>{let[l,c]=y(s||{}),[d,u]=y(""),[p,f]=y(""),[g,m]=y(""),[h,b]=y(!1),[x,v]=y(!1),[w,$]=y(null),[S,C]=y(""),[_,k]=y(""),[A,D]=y(""),[N,U]=y(""),[O,M]=y(""),[R,B]=y(null),[E,G]=y(null),[H,z]=y([]),te=async()=>{let j=await _c(e,{accountId:t});j.ok&&c(j.topics||{})};L(()=>{te()},[e]),L(()=>{s&&Object.keys(s).length>0&&c(s)},[s]),L(()=>{Mo().then(j=>z(Array.isArray(j?.agents)?j.agents:[])).catch(()=>{})},[]);let K=async()=>{let j=d.trim(),J=p.trim(),ie=g.trim();if(j){v(!0),B(null);try{let de=await Ac(e,[{name:j,...J?{systemInstructions:J}:{},...ie?{agentId:ie}:{}}],{accountId:t});if(!de.ok)throw new Error(de.results?.[0]?.error||"Failed to create topic");let be=de.results.filter(Ve=>!Ve.ok);if(be.length>0)throw new Error(be[0].error);u(""),f(""),m(""),b(!1),await te(),I(`Created topic: ${j}`,"success")}catch(de){B(de.message)}v(!1)}},V=async(j,J)=>{$(j);try{let ie=await Mc(e,j,{accountId:t});if(!ie.ok)throw new Error(ie.error);await te(),ie.removedFromRegistryOnly?I(`Removed stale topic from registry: ${J}`,"success"):I(`Deleted topic: ${J}`,"success")}catch(ie){I(`Failed to delete: ${ie.message}`,"error")}$(null)},Z=(j,J,ie="",de="")=>{C(String(j)),k(String(J||"")),D(String(ie||"")),U(String(de||""))},ue=()=>{C(""),k(""),D(""),U("")},re=async j=>{let J=_.trim(),ie=A.trim(),de=N.trim();if(!J){B("Topic name is required");return}M(String(j)),B(null);try{let be=await u1(e,j,{name:J,systemInstructions:ie,agentId:de},{accountId:t});if(!be.ok)throw new Error(be.error||"Failed to update topic");await te(),I(`Updated topic: ${J}`,"success"),ue()}catch(be){B(be.message)}M("")},oe=Object.entries(l||{}),ne=oe.length,me=Math.max(ne*3,8),pe=Math.max(me-2,4),ce=Number.isFinite(o)?o:me,ge=Number.isFinite(r)?r:pe;return Tt` +`,yf=({accountId:t,groupId:e,groupName:n,initialTopics:s,configAgentMaxConcurrent:o,configSubagentMaxConcurrent:r,debugEnabled:i,onResetOnboarding:a})=>{let[l,c]=y(s||{}),[d,u]=y(""),[p,f]=y(""),[g,m]=y(""),[h,b]=y(!1),[x,v]=y(!1),[$,w]=y(null),[S,C]=y(""),[_,k]=y(""),[A,D]=y(""),[O,z]=y(""),[N,M]=y(""),[L,B]=y(null),[E,U]=y(null),[F,K]=y([]),re=async()=>{let V=await Tc(e,{accountId:t});V.ok&&c(V.topics||{})};R(()=>{re()},[e]),R(()=>{s&&Object.keys(s).length>0&&c(s)},[s]),R(()=>{Mo().then(V=>K(Array.isArray(V?.agents)?V.agents:[])).catch(()=>{})},[]);let Y=async()=>{let V=d.trim(),q=p.trim(),ae=g.trim();if(V){v(!0),B(null);try{let fe=await Pc(e,[{name:V,...q?{systemInstructions:q}:{},...ae?{agentId:ae}:{}}],{accountId:t});if(!fe.ok)throw new Error(fe.results?.[0]?.error||"Failed to create topic");let ne=fe.results.filter(ve=>!ve.ok);if(ne.length>0)throw new Error(ne[0].error);u(""),f(""),m(""),b(!1),await re(),I(`Created topic: ${V}`,"success")}catch(fe){B(fe.message)}v(!1)}},j=async(V,q)=>{w(V);try{let ae=await Rc(e,V,{accountId:t});if(!ae.ok)throw new Error(ae.error);await re(),ae.removedFromRegistryOnly?I(`Removed stale topic from registry: ${q}`,"success"):I(`Deleted topic: ${q}`,"success")}catch(ae){I(`Failed to delete: ${ae.message}`,"error")}w(null)},J=(V,q,ae="",fe="")=>{C(String(V)),k(String(q||"")),D(String(ae||"")),z(String(fe||""))},pe=()=>{C(""),k(""),D(""),z("")},le=async V=>{let q=_.trim(),ae=A.trim(),fe=O.trim();if(!q){B("Topic name is required");return}M(String(V)),B(null);try{let ne=await g1(e,V,{name:q,systemInstructions:ae,agentId:fe},{accountId:t});if(!ne.ok)throw new Error(ne.error||"Failed to update topic");await re(),I(`Updated topic: ${q}`,"success"),pe()}catch(ne){B(ne.message)}M("")},ie=Object.entries(l||{}),se=ie.length,xe=Math.max(se*3,8),he=Math.max(xe-2,4),ue=Number.isFinite(o)?o:xe,be=Number.isFinite(r)?r:he;return Rt`
- ${i&&Tt` + ${i&&Rt`
- ${c_.map(d=>{let u=c[d]||[];return u.length===0?null:wl` + ${d_.map(d=>{let u=c[d]||[];return u.length===0?null:wl`
-
${d_[d]||"Other"}
+
${u_[d]||"Other"}
${u.map(p=>{let f=nv(p),g=e===String(p.id||"");return wl`
`:null}
- `};var b_=P.bind(T),x_=[{label:"7d",value:7},{label:"30d",value:30}],y_=(t=null)=>{let e=Array.isArray(t?.modelBreakdown)?t.modelBreakdown:[];if(e.length===0)return"\u2014";let n=e[0],s=String(n?.model||"").trim(),o=String(n?.provider||"").trim();return!s&&!o?"\u2014":o?s?`${o} / ${s}`:o:s},cv=({usage:t=null,usageDays:e=30,onSetUsageDays:n=()=>{}})=>{let s=t?.totals||{},o=Number(s?.runCount||0),r=Number(s?.totalTokens||0),i=Number(s?.totalCost||0),a=Number(s?.avgDurationMs||0),l=o>0?Math.round(r/o):0,c=o>0?i/o:0;return b_` + `};var x_=P.bind(T),y_=[{label:"7d",value:7},{label:"30d",value:30}],v_=(t=null)=>{let e=Array.isArray(t?.modelBreakdown)?t.modelBreakdown:[];if(e.length===0)return"\u2014";let n=e[0],s=String(n?.model||"").trim(),o=String(n?.provider||"").trim();return!s&&!o?"\u2014":o?s?`${o} / ${s}`:o:s},cv=({usage:t=null,usageDays:e=30,onSetUsageDays:n=()=>{}})=>{let s=t?.totals||{},o=Number(s?.runCount||0),r=Number(s?.totalTokens||0),i=Number(s?.totalCost||0),a=Number(s?.avgDurationMs||0),l=o>0?Math.round(r/o):0,c=o>0?i/o:0;return x_`

Usage

<${nt} - options=${x_} + options=${y_} value=${e} onChange=${n} /> @@ -4464,11 +4464,11 @@ ${(n||"").split(`
Total runs
-
${Oe(o)}
+
${Ne(o)}
Total tokens
-
${Oe(r)}
+
${Ne(r)}
Total cost
@@ -4482,7 +4482,7 @@ ${(n||"").split(`
Avg tokens/run
-
${Oe(l)}
+
${Ne(l)}
Avg cost/run
@@ -4491,12 +4491,12 @@ ${(n||"").split(`
Dominant model:${" "} - ${y_(t)} + ${v_(t)}
- `};function mi(t){return t+.5|0}var Cs=(t,e,n)=>Math.max(Math.min(t,n),e);function fi(t){return Cs(mi(t*2.55),0,255)}function _s(t){return Cs(mi(t*255),0,255)}function ss(t){return Cs(mi(t/2.55)/100,0,1)}function dv(t){return Cs(mi(t*100),0,100)}var un={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},mu=[..."0123456789ABCDEF"],v_=t=>mu[t&15],$_=t=>mu[(t&240)>>4]+mu[t&15],Cl=t=>(t&240)>>4===(t&15),w_=t=>Cl(t.r)&&Cl(t.g)&&Cl(t.b)&&Cl(t.a);function k_(t){var e=t.length,n;return t[0]==="#"&&(e===4||e===5?n={r:255&un[t[1]]*17,g:255&un[t[2]]*17,b:255&un[t[3]]*17,a:e===5?un[t[4]]*17:255}:(e===7||e===9)&&(n={r:un[t[1]]<<4|un[t[2]],g:un[t[3]]<<4|un[t[4]],b:un[t[5]]<<4|un[t[6]],a:e===9?un[t[7]]<<4|un[t[8]]:255})),n}var S_=(t,e)=>t<255?e(t):"";function C_(t){var e=w_(t)?v_:$_;return t?"#"+e(t.r)+e(t.g)+e(t.b)+S_(t.a,e):void 0}var __=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function hv(t,e,n){let s=e*Math.min(n,1-n),o=(r,i=(r+t/30)%12)=>n-s*Math.max(Math.min(i-3,9-i,1),-1);return[o(0),o(8),o(4)]}function A_(t,e,n){let s=(o,r=(o+t/60)%6)=>n-n*e*Math.max(Math.min(r,4-r,1),0);return[s(5),s(3),s(1)]}function M_(t,e,n){let s=hv(t,1,.5),o;for(e+n>1&&(o=1/(e+n),e*=o,n*=o),o=0;o<3;o++)s[o]*=1-e-n,s[o]+=e;return s}function T_(t,e,n,s,o){return t===o?(e-n)/s+(e.5?d/(2-r-i):d/(r+i),l=T_(n,s,o,d,r),l=l*60+.5),[l|0,c||0,a]}function bu(t,e,n,s){return(Array.isArray(e)?t(e[0],e[1],e[2]):t(e,n,s)).map(_s)}function xu(t,e,n){return bu(hv,t,e,n)}function P_(t,e,n){return bu(M_,t,e,n)}function R_(t,e,n){return bu(A_,t,e,n)}function mv(t){return(t%360+360)%360}function L_(t){let e=__.exec(t),n=255,s;if(!e)return;e[5]!==s&&(n=e[6]?fi(+e[5]):_s(+e[5]));let o=mv(+e[2]),r=+e[3]/100,i=+e[4]/100;return e[1]==="hwb"?s=P_(o,r,i):e[1]==="hsv"?s=R_(o,r,i):s=xu(o,r,i),{r:s[0],g:s[1],b:s[2],a:n}}function E_(t,e){var n=gu(t);n[0]=mv(n[0]+e),n=xu(n),t.r=n[0],t.g=n[1],t.b=n[2]}function I_(t){if(!t)return;let e=gu(t),n=e[0],s=dv(e[1]),o=dv(e[2]);return t.a<255?`hsla(${n}, ${s}%, ${o}%, ${ss(t.a)})`:`hsl(${n}, ${s}%, ${o}%)`}var uv={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},pv={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};function D_(){let t={},e=Object.keys(pv),n=Object.keys(uv),s,o,r,i,a;for(s=0;s>16&255,r>>8&255,r&255]}return t}var _l;function O_(t){_l||(_l=D_(),_l.transparent=[0,0,0,0]);let e=_l[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:e.length===4?e[3]:255}}var N_=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function B_(t){let e=N_.exec(t),n=255,s,o,r;if(e){if(e[7]!==s){let i=+e[7];n=e[8]?fi(i):Cs(i*255,0,255)}return s=+e[1],o=+e[3],r=+e[5],s=255&(e[2]?fi(s):Cs(s,0,255)),o=255&(e[4]?fi(o):Cs(o,0,255)),r=255&(e[6]?fi(r):Cs(r,0,255)),{r:s,g:o,b:r,a:n}}}function F_(t){return t&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${ss(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`)}var hu=t=>t<=.0031308?t*12.92:Math.pow(t,1/2.4)*1.055-.055,tr=t=>t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4);function W_(t,e,n){let s=tr(ss(t.r)),o=tr(ss(t.g)),r=tr(ss(t.b));return{r:_s(hu(s+n*(tr(ss(e.r))-s))),g:_s(hu(o+n*(tr(ss(e.g))-o))),b:_s(hu(r+n*(tr(ss(e.b))-r))),a:t.a+n*(e.a-t.a)}}function Al(t,e,n){if(t){let s=gu(t);s[e]=Math.max(0,Math.min(s[e]+s[e]*n,e===0?360:1)),s=xu(s),t.r=s[0],t.g=s[1],t.b=s[2]}}function gv(t,e){return t&&Object.assign(e||{},t)}function fv(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=_s(t[3]))):(e=gv(t,{r:0,g:0,b:0,a:1}),e.a=_s(e.a)),e}function H_(t){return t.charAt(0)==="r"?B_(t):L_(t)}var hi=class t{constructor(e){if(e instanceof t)return e;let n=typeof e,s;n==="object"?s=fv(e):n==="string"&&(s=k_(e)||O_(e)||H_(e)),this._rgb=s,this._valid=!!s}get valid(){return this._valid}get rgb(){var e=gv(this._rgb);return e&&(e.a=ss(e.a)),e}set rgb(e){this._rgb=fv(e)}rgbString(){return this._valid?F_(this._rgb):void 0}hexString(){return this._valid?C_(this._rgb):void 0}hslString(){return this._valid?I_(this._rgb):void 0}mix(e,n){if(e){let s=this.rgb,o=e.rgb,r,i=n===r?.5:n,a=2*i-1,l=s.a-o.a,c=((a*l===-1?a:(a+l)/(1+a*l))+1)/2;r=1-c,s.r=255&c*s.r+r*o.r+.5,s.g=255&c*s.g+r*o.g+.5,s.b=255&c*s.b+r*o.b+.5,s.a=i*s.a+(1-i)*o.a,this.rgb=s}return this}interpolate(e,n){return e&&(this._rgb=W_(this._rgb,e._rgb,n)),this}clone(){return new t(this.rgb)}alpha(e){return this._rgb.a=_s(e),this}clearer(e){let n=this._rgb;return n.a*=1-e,this}greyscale(){let e=this._rgb,n=mi(e.r*.3+e.g*.59+e.b*.11);return e.r=e.g=e.b=n,this}opaquer(e){let n=this._rgb;return n.a*=1+e,this}negate(){let e=this._rgb;return e.r=255-e.r,e.g=255-e.g,e.b=255-e.b,this}lighten(e){return Al(this._rgb,2,e),this}darken(e){return Al(this._rgb,2,-e),this}saturate(e){return Al(this._rgb,1,e),this}desaturate(e){return Al(this._rgb,1,-e),this}rotate(e){return E_(this._rgb,e),this}};function Bn(){}var Av=(()=>{let t=0;return()=>t++})();function Me(t){return t==null}function et(t){if(Array.isArray&&Array.isArray(t))return!0;let e=Object.prototype.toString.call(t);return e.slice(0,7)==="[object"&&e.slice(-6)==="Array]"}function Le(t){return t!==null&&Object.prototype.toString.call(t)==="[object Object]"}function dt(t){return(typeof t=="number"||t instanceof Number)&&isFinite(+t)}function Yt(t,e){return dt(t)?t:e}function Se(t,e){return typeof t>"u"?e:t}var Mv=(t,e)=>typeof t=="string"&&t.endsWith("%")?parseFloat(t)/100:+t/e,wu=(t,e)=>typeof t=="string"&&t.endsWith("%")?parseFloat(t)/100*e:+t;function Ye(t,e,n){if(t&&typeof t.call=="function")return t.apply(n,e)}function Ke(t,e,n,s){let o,r,i;if(et(t))if(r=t.length,s)for(o=r-1;o>=0;o--)e.call(n,t[o],o);else for(o=0;ot,x:t=>t.x,y:t=>t.y};function z_(t){let e=t.split("."),n=[],s="";for(let o of e)s+=o,s.endsWith("\\")?s=s.slice(0,-1)+".":(n.push(s),s="");return n}function U_(t){let e=z_(t);return n=>{for(let s of e){if(s==="")break;n=n&&n[s]}return n}}function is(t,e){return(bv[e]||(bv[e]=U_(e)))(t)}function Dl(t){return t.charAt(0).toUpperCase()+t.slice(1)}var ir=t=>typeof t<"u",os=t=>typeof t=="function",ku=(t,e)=>{if(t.size!==e.size)return!1;for(let n of t)if(!e.has(n))return!1;return!0};function Pv(t){return t.type==="mouseup"||t.type==="click"||t.type==="contextmenu"}var He=Math.PI,tt=2*He,K_=tt+He,Ll=Number.POSITIVE_INFINITY,G_=He/180,ft=He/2,so=He/4,xv=He*2/3,rs=Math.log10,wn=Math.sign;function ar(t,e,n){return Math.abs(t-e)o-r).pop(),e}function q_(t){return typeof t=="symbol"||typeof t=="object"&&t!==null&&!(Symbol.toPrimitive in t||"toString"in t||"valueOf"in t)}function io(t){return!q_(t)&&!isNaN(parseFloat(t))&&isFinite(t)}function Lv(t,e){let n=Math.round(t);return n-e<=t&&n+e>=t}function Cu(t,e,n){let s,o,r;for(s=0,o=t.length;sl&&c=Math.min(e,n)-s&&t<=Math.max(e,n)+s}function Nl(t,e,n){n=n||(i=>t[i]1;)r=o+s>>1,n(r)?o=r:s=r;return{lo:o,hi:s}}var On=(t,e,n,s)=>Nl(t,n,s?o=>{let r=t[o][e];return rt[o][e]Nl(t,n,s=>t[s][e]>=n);function Dv(t,e,n){let s=0,o=t.length;for(;ss&&t[o-1]>n;)o--;return s>0||o{let s="_onData"+Dl(n),o=t[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!1,value(...r){let i=o.apply(this,r);return t._chartjs.listeners.forEach(a=>{typeof a[s]=="function"&&a[s](...r)}),i}})})}function Mu(t,e){let n=t._chartjs;if(!n)return;let s=n.listeners,o=s.indexOf(e);o!==-1&&s.splice(o,1),!(s.length>0)&&(Ov.forEach(r=>{delete t[r]}),delete t._chartjs)}function Tu(t){let e=new Set(t);return e.size===t.length?t:Array.from(e)}var Pu=(function(){return typeof window>"u"?function(t){return t()}:window.requestAnimationFrame})();function Ru(t,e){let n=[],s=!1;return function(...o){n=o,s||(s=!0,Pu.call(window,()=>{s=!1,t.apply(e,n)}))}}function Bv(t,e){let n;return function(...s){return e?(clearTimeout(n),n=setTimeout(t,e,s)):t.apply(this,s),e}}var Bl=t=>t==="start"?"left":t==="end"?"right":"center",Dt=(t,e,n)=>t==="start"?e:t==="end"?n:(e+n)/2,Fv=(t,e,n,s)=>t===(s?"left":"right")?n:t==="center"?(e+n)/2:e;function Lu(t,e,n){let s=e.length,o=0,r=s;if(t._sorted){let{iScale:i,vScale:a,_parsed:l}=t,c=t.dataset&&t.dataset.options?t.dataset.options.spanGaps:null,d=i.axis,{min:u,max:p,minDefined:f,maxDefined:g}=i.getUserBounds();if(f){if(o=Math.min(On(l,d,u).lo,n?s:On(e,d,i.getPixelForValue(u)).lo),c){let m=l.slice(0,o+1).reverse().findIndex(h=>!Me(h[a.axis]));o-=Math.max(0,m)}o=wt(o,0,s-1)}if(g){let m=Math.max(On(l,i.axis,p,!0).hi+1,n?0:On(e,d,i.getPixelForValue(p),!0).hi+1);if(c){let h=l.slice(m-1).findIndex(b=>!Me(b[a.axis]));m+=Math.max(0,h)}r=wt(m,o,s)-o}else r=s-o}return{start:o,count:r}}function Eu(t){let{xScale:e,yScale:n,_scaleRanges:s}=t,o={xmin:e.min,xmax:e.max,ymin:n.min,ymax:n.max};if(!s)return t._scaleRanges=o,!0;let r=s.xmin!==e.min||s.xmax!==e.max||s.ymin!==n.min||s.ymax!==n.max;return Object.assign(s,o),r}var Ml=t=>t===0||t===1,yv=(t,e,n)=>-(Math.pow(2,10*(t-=1))*Math.sin((t-e)*tt/n)),vv=(t,e,n)=>Math.pow(2,-10*t)*Math.sin((t-e)*tt/n)+1,nr={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>-Math.cos(t*ft)+1,easeOutSine:t=>Math.sin(t*ft),easeInOutSine:t=>-.5*(Math.cos(He*t)-1),easeInExpo:t=>t===0?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>t===1?1:-Math.pow(2,-10*t)+1,easeInOutExpo:t=>Ml(t)?t:t<.5?.5*Math.pow(2,10*(t*2-1)):.5*(-Math.pow(2,-10*(t*2-1))+2),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>Ml(t)?t:yv(t,.075,.3),easeOutElastic:t=>Ml(t)?t:vv(t,.075,.3),easeInOutElastic(t){return Ml(t)?t:t<.5?.5*yv(t*2,.1125,.45):.5+.5*vv(t*2-1,.1125,.45)},easeInBack(t){return t*t*((1.70158+1)*t-1.70158)},easeOutBack(t){return(t-=1)*t*((1.70158+1)*t+1.70158)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?.5*(t*t*(((e*=1.525)+1)*t-e)):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:t=>1-nr.easeOutBounce(1-t),easeOutBounce(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},easeInOutBounce:t=>t<.5?nr.easeInBounce(t*2)*.5:nr.easeOutBounce(t*2-1)*.5+.5};function Iu(t){if(t&&typeof t=="object"){let e=t.toString();return e==="[object CanvasPattern]"||e==="[object CanvasGradient]"}return!1}function Du(t){return Iu(t)?t:new hi(t)}function yu(t){return Iu(t)?t:new hi(t).saturate(.5).darken(.1).hexString()}var Z_=["x","y","borderWidth","radius","tension"],Y_=["color","borderColor","backgroundColor"];function X_(t){t.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),t.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:e=>e!=="onProgress"&&e!=="onComplete"&&e!=="fn"}),t.set("animations",{colors:{type:"color",properties:Y_},numbers:{type:"number",properties:Z_}}),t.describe("animations",{_fallback:"animation"}),t.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:e=>e|0}}}})}function Q_(t){t.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}var $v=new Map;function e5(t,e){e=e||{};let n=t+JSON.stringify(e),s=$v.get(n);return s||(s=new Intl.NumberFormat(t,e),$v.set(n,s)),s}function cr(t,e,n){return e5(e,n).format(t)}var Wv={values(t){return et(t)?t:""+t},numeric(t,e,n){if(t===0)return"0";let s=this.chart.options.locale,o,r=t;if(n.length>1){let c=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(c<1e-4||c>1e15)&&(o="scientific"),r=t5(t,n)}let i=rs(Math.abs(r)),a=isNaN(i)?1:Math.max(Math.min(-1*Math.floor(i),20),0),l={notation:o,minimumFractionDigits:a,maximumFractionDigits:a};return Object.assign(l,this.options.ticks.format),cr(t,s,l)},logarithmic(t,e,n){if(t===0)return"0";let s=n[e].significand||t/Math.pow(10,Math.floor(rs(t)));return[1,2,3,5,10,15].includes(s)||e>.8*n.length?Wv.numeric.call(this,t,e,n):""}};function t5(t,e){let n=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;return Math.abs(n)>=1&&t!==Math.floor(t)&&(n=t-Math.floor(t)),n}var yi={formatters:Wv};function n5(t){t.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(e,n)=>n.lineWidth,tickColor:(e,n)=>n.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:yi.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),t.route("scale.ticks","color","","color"),t.route("scale.grid","color","","borderColor"),t.route("scale.border","color","","borderColor"),t.route("scale.title","color","","color"),t.describe("scale",{_fallback:!1,_scriptable:e=>!e.startsWith("before")&&!e.startsWith("after")&&e!=="callback"&&e!=="parser",_indexable:e=>e!=="borderDash"&&e!=="tickBorderDash"&&e!=="dash"}),t.describe("scales",{_fallback:"scale"}),t.describe("scale.ticks",{_scriptable:e=>e!=="backdropPadding"&&e!=="callback",_indexable:e=>e!=="backdropPadding"})}var Ts=Object.create(null),Fl=Object.create(null);function gi(t,e){if(!e)return t;let n=e.split(".");for(let s=0,o=n.length;ss.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(s,o)=>yu(o.backgroundColor),this.hoverBorderColor=(s,o)=>yu(o.borderColor),this.hoverColor=(s,o)=>yu(o.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(e),this.apply(n)}set(e,n){return vu(this,e,n)}get(e){return gi(this,e)}describe(e,n){return vu(Fl,e,n)}override(e,n){return vu(Ts,e,n)}route(e,n,s,o){let r=gi(this,e),i=gi(this,s),a="_"+n;Object.defineProperties(r,{[a]:{value:r[n],writable:!0},[n]:{enumerable:!0,get(){let l=this[a],c=i[o];return Le(l)?Object.assign({},c,l):Se(l,c)},set(l){this[a]=l}}})}apply(e){e.forEach(n=>n(this))}},st=new $u({_scriptable:t=>!t.startsWith("on"),_indexable:t=>t!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[X_,Q_,n5]);function s5(t){return!t||Me(t.size)||Me(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}function bi(t,e,n,s,o){let r=e[o];return r||(r=e[o]=t.measureText(o).width,n.push(o)),r>s&&(s=r),s}function Hv(t,e,n,s){s=s||{};let o=s.data=s.data||{},r=s.garbageCollect=s.garbageCollect||[];s.font!==e&&(o=s.data={},r=s.garbageCollect=[],s.font=e),t.save(),t.font=e;let i=0,a=n.length,l,c,d,u,p;for(l=0;ln.length){for(l=0;l0&&t.stroke()}}function Nn(t,e,n){return n=n||.5,!e||t&&t.x>e.left-n&&t.xe.top-n&&t.y0&&r.strokeColor!=="",l,c;for(t.save(),t.font=o.string,o5(t,r),l=0;l+t||0;function Hl(t,e){let n={},s=Le(e),o=s?Object.keys(e):e,r=Le(t)?s?i=>Se(t[i],t[e[i]]):i=>t[i]:()=>t;for(let i of o)n[i]=d5(r(i));return n}function Bu(t){return Hl(t,{top:"y",right:"x",bottom:"y",left:"x"})}function Ls(t){return Hl(t,["topLeft","topRight","bottomLeft","bottomRight"])}function Ot(t){let e=Bu(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function bt(t,e){t=t||{},e=e||st.font;let n=Se(t.size,e.size);typeof n=="string"&&(n=parseInt(n,10));let s=Se(t.style,e.style);s&&!(""+s).match(l5)&&(console.warn('Invalid font style specified: "'+s+'"'),s=void 0);let o={family:Se(t.family,e.family),lineHeight:c5(Se(t.lineHeight,e.lineHeight),n),size:n,style:s,weight:Se(t.weight,e.weight),string:""};return o.string=s5(o),o}function ur(t,e,n,s){let o=!0,r,i,a;for(r=0,i=t.length;rn&&a===0?0:a+l;return{min:i(s,-Math.abs(r)),max:i(o,r)}}function as(t,e){return Object.assign(Object.create(t),e)}function Vl(t,e=[""],n,s,o=()=>t[0]){let r=n||t;typeof s>"u"&&(s=Gv("_fallback",t));let i={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:r,_fallback:s,_getTarget:o,override:a=>Vl([a,...t],e,r,s)};return new Proxy(i,{deleteProperty(a,l){return delete a[l],delete a._keys,delete t[0][l],!0},get(a,l){return Uv(a,l,()=>x5(l,e,t,a))},getOwnPropertyDescriptor(a,l){return Reflect.getOwnPropertyDescriptor(a._scopes[0],l)},getPrototypeOf(){return Reflect.getPrototypeOf(t[0])},has(a,l){return kv(a).includes(l)},ownKeys(a){return kv(a)},set(a,l,c){let d=a._storage||(a._storage=o());return a[l]=d[l]=c,delete a._keys,!0}})}function ro(t,e,n,s){let o={_cacheable:!1,_proxy:t,_context:e,_subProxy:n,_stack:new Set,_descriptors:Fu(t,s),setContext:r=>ro(t,r,n,s),override:r=>ro(t.override(r),e,n,s)};return new Proxy(o,{deleteProperty(r,i){return delete r[i],delete t[i],!0},get(r,i,a){return Uv(r,i,()=>p5(r,i,a))},getOwnPropertyDescriptor(r,i){return r._descriptors.allKeys?Reflect.has(t,i)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,i)},getPrototypeOf(){return Reflect.getPrototypeOf(t)},has(r,i){return Reflect.has(t,i)},ownKeys(){return Reflect.ownKeys(t)},set(r,i,a){return t[i]=a,delete r[i],!0}})}function Fu(t,e={scriptable:!0,indexable:!0}){let{_scriptable:n=e.scriptable,_indexable:s=e.indexable,_allKeys:o=e.allKeys}=t;return{allKeys:o,scriptable:n,indexable:s,isScriptable:os(n)?n:()=>n,isIndexable:os(s)?s:()=>s}}var u5=(t,e)=>t?t+Dl(e):e,Wu=(t,e)=>Le(e)&&t!=="adapters"&&(Object.getPrototypeOf(e)===null||e.constructor===Object);function Uv(t,e,n){if(Object.prototype.hasOwnProperty.call(t,e)||e==="constructor")return t[e];let s=n();return t[e]=s,s}function p5(t,e,n){let{_proxy:s,_context:o,_subProxy:r,_descriptors:i}=t,a=s[e];return os(a)&&i.isScriptable(e)&&(a=f5(e,a,t,n)),et(a)&&a.length&&(a=h5(e,a,t,i.isIndexable)),Wu(e,a)&&(a=ro(a,o,r&&r[e],i)),a}function f5(t,e,n,s){let{_proxy:o,_context:r,_subProxy:i,_stack:a}=n;if(a.has(t))throw new Error("Recursion detected: "+Array.from(a).join("->")+"->"+t);a.add(t);let l=e(r,i||s);return a.delete(t),Wu(t,l)&&(l=Hu(o._scopes,o,t,l)),l}function h5(t,e,n,s){let{_proxy:o,_context:r,_subProxy:i,_descriptors:a}=n;if(typeof r.index<"u"&&s(t))return e[r.index%e.length];if(Le(e[0])){let l=e,c=o._scopes.filter(d=>d!==l);e=[];for(let d of l){let u=Hu(c,o,t,d);e.push(ro(u,r,i&&i[t],a))}}return e}function Kv(t,e,n){return os(t)?t(e,n):t}var m5=(t,e)=>t===!0?e:typeof t=="string"?is(e,t):void 0;function g5(t,e,n,s,o){for(let r of e){let i=m5(n,r);if(i){t.add(i);let a=Kv(i._fallback,n,o);if(typeof a<"u"&&a!==n&&a!==s)return a}else if(i===!1&&typeof s<"u"&&n!==s)return null}return!1}function Hu(t,e,n,s){let o=e._rootScopes,r=Kv(e._fallback,n,s),i=[...t,...o],a=new Set;a.add(s);let l=wv(a,i,n,r||n,s);return l===null||typeof r<"u"&&r!==n&&(l=wv(a,i,r,l,s),l===null)?!1:Vl(Array.from(a),[""],o,r,()=>b5(e,n,s))}function wv(t,e,n,s,o){for(;n;)n=g5(t,e,n,s,o);return n}function b5(t,e,n){let s=t._getTarget();e in s||(s[e]={});let o=s[e];return et(o)&&Le(n)?n:o||{}}function x5(t,e,n,s){let o;for(let r of e)if(o=Gv(u5(r,t),n),typeof o<"u")return Wu(t,o)?Hu(n,s,t,o):o}function Gv(t,e){for(let n of e){if(!n)continue;let s=n[t];if(typeof s<"u")return s}}function kv(t){let e=t._keys;return e||(e=t._keys=y5(t._scopes)),e}function y5(t){let e=new Set;for(let n of t)for(let s of Object.keys(n).filter(o=>!o.startsWith("_")))e.add(s);return Array.from(e)}function Vu(t,e,n,s){let{iScale:o}=t,{key:r="r"}=this._parsing,i=new Array(s),a,l,c,d;for(a=0,l=s;aet==="x"?"y":"x";function $5(t,e,n,s){let o=t.skip?e:t,r=e,i=n.skip?e:n,a=El(r,o),l=El(i,r),c=a/(a+l),d=l/(a+l);c=isNaN(c)?0:c,d=isNaN(d)?0:d;let u=s*c,p=s*d;return{previous:{x:r.x-u*(i.x-o.x),y:r.y-u*(i.y-o.y)},next:{x:r.x+p*(i.x-o.x),y:r.y+p*(i.y-o.y)}}}function w5(t,e,n){let s=t.length,o,r,i,a,l,c=or(t,0);for(let d=0;d!c.skip)),e.cubicInterpolationMode==="monotone")S5(t,o);else{let c=s?t[t.length-1]:t[0];for(r=0,i=t.length;rt.ownerDocument.defaultView.getComputedStyle(t,null);function _5(t,e){return Ul(t).getPropertyValue(e)}var A5=["top","right","bottom","left"];function oo(t,e,n){let s={};n=n?"-"+n:"";for(let o=0;o<4;o++){let r=A5[o];s[r]=parseFloat(t[e+"-"+r+n])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}var M5=(t,e,n)=>(t>0||e>0)&&(!n||!n.shadowRoot);function T5(t,e){let n=t.touches,s=n&&n.length?n[0]:t,{offsetX:o,offsetY:r}=s,i=!1,a,l;if(M5(o,r,t.target))a=o,l=r;else{let c=e.getBoundingClientRect();a=s.clientX-c.left,l=s.clientY-c.top,i=!0}return{x:a,y:l,box:i}}function Es(t,e){if("native"in t)return t;let{canvas:n,currentDevicePixelRatio:s}=e,o=Ul(n),r=o.boxSizing==="border-box",i=oo(o,"padding"),a=oo(o,"border","width"),{x:l,y:c,box:d}=T5(t,n),u=i.left+(d&&a.left),p=i.top+(d&&a.top),{width:f,height:g}=e;return r&&(f-=i.width+a.width,g-=i.height+a.height),{x:Math.round((l-u)/f*n.width/s),y:Math.round((c-p)/g*n.height/s)}}function P5(t,e,n){let s,o;if(e===void 0||n===void 0){let r=t&&zl(t);if(!r)e=t.clientWidth,n=t.clientHeight;else{let i=r.getBoundingClientRect(),a=Ul(r),l=oo(a,"border","width"),c=oo(a,"padding");e=i.width-c.width-l.width,n=i.height-c.height-l.height,s=Il(a.maxWidth,r,"clientWidth"),o=Il(a.maxHeight,r,"clientHeight")}}return{width:e,height:n,maxWidth:s||Ll,maxHeight:o||Ll}}var Ms=t=>Math.round(t*10)/10;function Zv(t,e,n,s){let o=Ul(t),r=oo(o,"margin"),i=Il(o.maxWidth,t,"clientWidth")||Ll,a=Il(o.maxHeight,t,"clientHeight")||Ll,l=P5(t,e,n),{width:c,height:d}=l;if(o.boxSizing==="content-box"){let p=oo(o,"border","width"),f=oo(o,"padding");c-=f.width+p.width,d-=f.height+p.height}return c=Math.max(0,c-r.width),d=Math.max(0,s?c/s:d-r.height),c=Ms(Math.min(c,i,l.maxWidth)),d=Ms(Math.min(d,a,l.maxHeight)),c&&!d&&(d=Ms(c/2)),(e!==void 0||n!==void 0)&&s&&l.height&&d>l.height&&(d=l.height,c=Ms(Math.floor(d*s))),{width:c,height:d}}function ju(t,e,n){let s=e||1,o=Ms(t.height*s),r=Ms(t.width*s);t.height=Ms(t.height),t.width=Ms(t.width);let i=t.canvas;return i.style&&(n||!i.style.height&&!i.style.width)&&(i.style.height=`${t.height}px`,i.style.width=`${t.width}px`),t.currentDevicePixelRatio!==s||i.height!==o||i.width!==r?(t.currentDevicePixelRatio=s,i.height=o,i.width=r,t.ctx.setTransform(s,0,0,s,0,0),!0):!1}var Yv=(function(){let t=!1;try{let e={get passive(){return t=!0,!1}};jl()&&(window.addEventListener("test",null,e),window.removeEventListener("test",null,e))}catch{}return t})();function zu(t,e){let n=_5(t,e),s=n&&n.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function As(t,e,n,s){return{x:t.x+n*(e.x-t.x),y:t.y+n*(e.y-t.y)}}function Xv(t,e,n,s){return{x:t.x+n*(e.x-t.x),y:s==="middle"?n<.5?t.y:e.y:s==="after"?n<1?t.y:e.y:n>0?e.y:t.y}}function Qv(t,e,n,s){let o={x:t.cp2x,y:t.cp2y},r={x:e.cp1x,y:e.cp1y},i=As(t,o,n),a=As(o,r,n),l=As(r,e,n),c=As(i,a,n),d=As(a,l,n);return As(c,d,n)}var R5=function(t,e){return{x(n){return t+t+e-n},setWidth(n){e=n},textAlign(n){return n==="center"?n:n==="right"?"left":"right"},xPlus(n,s){return n-s},leftForLtr(n,s){return n-s}}},L5=function(){return{x(t){return t},setWidth(t){},textAlign(t){return t},xPlus(t,e){return t+e},leftForLtr(t,e){return t}}};function ao(t,e,n){return t?R5(e,n):L5()}function Uu(t,e){let n,s;(e==="ltr"||e==="rtl")&&(n=t.canvas.style,s=[n.getPropertyValue("direction"),n.getPropertyPriority("direction")],n.setProperty("direction",e,"important"),t.prevTextDirection=s)}function Ku(t,e){e!==void 0&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function e$(t){return t==="angle"?{between:lr,compare:J_,normalize:It}:{between:Fn,compare:(e,n)=>e-n,normalize:e=>e}}function Sv({start:t,end:e,count:n,loop:s,style:o}){return{start:t%n,end:e%n,loop:s&&(e-t+1)%n===0,style:o}}function E5(t,e,n){let{property:s,start:o,end:r}=n,{between:i,normalize:a}=e$(s),l=e.length,{start:c,end:d,loop:u}=t,p,f;if(u){for(c+=l,d+=l,p=0,f=l;pl(o,v,b)&&a(o,v)!==0,w=()=>a(r,b)===0||l(r,v,b),S=()=>m||$(),C=()=>!m||w();for(let _=d,k=d;_<=u;++_)x=e[_%i],!x.skip&&(b=c(x[s]),b!==v&&(m=l(b,o,r),h===null&&S()&&(h=a(b,o)===0?_:k),h!==null&&C()&&(g.push(Sv({start:h,end:_,loop:p,count:i,style:f})),h=null),k=_,v=b));return h!==null&&g.push(Sv({start:h,end:u,loop:p,count:i,style:f})),g}function qu(t,e){let n=[],s=t.segments;for(let o=0;oo&&t[r%e].skip;)r--;return r%=e,{start:o,end:r}}function D5(t,e,n,s){let o=t.length,r=[],i=e,a=t[e],l;for(l=e+1;l<=n;++l){let c=t[l%o];c.skip||c.stop?a.skip||(s=!1,r.push({start:e%o,end:(l-1)%o,loop:s}),e=i=c.stop?l:null):(i=l,a.skip&&(e=l)),a=c}return i!==null&&r.push({start:e%o,end:i%o,loop:s}),r}function t$(t,e){let n=t.points,s=t.options.spanGaps,o=n.length;if(!o)return[];let r=!!t._loop,{start:i,end:a}=I5(n,o,r,s);if(s===!0)return Cv(t,[{start:i,end:a,loop:r}],n,e);let l=aa({chart:e,initial:n.initial,numSteps:i,currentStep:Math.min(s-n.start,i)}))}_refresh(){this._request||(this._running=!0,this._request=Pu.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(e=Date.now()){let n=0;this._charts.forEach((s,o)=>{if(!s.running||!s.items.length)return;let r=s.items,i=r.length-1,a=!1,l;for(;i>=0;--i)l=r[i],l._active?(l._total>s.duration&&(s.duration=l._total),l.tick(e),a=!0):(r[i]=r[r.length-1],r.pop());a&&(o.draw(),this._notify(o,s,e,"progress")),r.length||(s.running=!1,this._notify(o,s,e,"complete"),s.initial=!1),n+=r.length}),this._lastDate=e,n===0&&(this._running=!1)}_getAnims(e){let n=this._charts,s=n.get(e);return s||(s={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},n.set(e,s)),s}listen(e,n,s){this._getAnims(e).listeners[n].push(s)}add(e,n){!n||!n.length||this._getAnims(e).items.push(...n)}has(e){return this._getAnims(e).items.length>0}start(e){let n=this._charts.get(e);n&&(n.running=!0,n.start=Date.now(),n.duration=n.items.reduce((s,o)=>Math.max(s,o._duration),0),this._refresh())}running(e){if(!this._running)return!1;let n=this._charts.get(e);return!(!n||!n.running||!n.items.length)}stop(e){let n=this._charts.get(e);if(!n||!n.items.length)return;let s=n.items,o=s.length-1;for(;o>=0;--o)s[o].cancel();n.items=[],this._notify(e,n,Date.now(),"complete")}remove(e){return this._charts.delete(e)}},ls=new ap,n$="transparent",F5={boolean(t,e,n){return n>.5?e:t},color(t,e,n){let s=Du(t||n$),o=s.valid&&Du(e||n$);return o&&o.valid?o.mix(s,n).hexString():e},number(t,e,n){return t+(e-t)*n}},lp=class{constructor(e,n,s,o){let r=n[s];o=ur([e.to,o,r,e.from]);let i=ur([e.from,r,o]);this._active=!0,this._fn=e.fn||F5[e.type||typeof i],this._easing=nr[e.easing]||nr.linear,this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=this._total=Math.floor(e.duration),this._loop=!!e.loop,this._target=n,this._prop=s,this._from=i,this._to=o,this._promises=void 0}active(){return this._active}update(e,n,s){if(this._active){this._notify(!1);let o=this._target[this._prop],r=s-this._start,i=this._duration-r;this._start=s,this._duration=Math.floor(Math.max(i,e.duration)),this._total+=r,this._loop=!!e.loop,this._to=ur([e.to,n,o,e.from]),this._from=ur([e.from,o,n])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(e){let n=e-this._start,s=this._duration,o=this._prop,r=this._from,i=this._loop,a=this._to,l;if(this._active=r!==a&&(i||n1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[o]=this._fn(r,a,l)}wait(){let e=this._promises||(this._promises=[]);return new Promise((n,s)=>{e.push({res:n,rej:s})})}_notify(e){let n=e?"res":"rej",s=this._promises||[];for(let o=0;o{let r=e[o];if(!Le(r))return;let i={};for(let a of n)i[a]=r[a];(et(r.properties)&&r.properties||[o]).forEach(a=>{(a===o||!s.has(a))&&s.set(a,i)})})}_animateOptions(e,n){let s=n.options,o=H5(e,s);if(!o)return[];let r=this._createAnimations(o,s);return s.$shared&&W5(e.options.$animations,s).then(()=>{e.options=s},()=>{}),r}_createAnimations(e,n){let s=this._properties,o=[],r=e.$animations||(e.$animations={}),i=Object.keys(n),a=Date.now(),l;for(l=i.length-1;l>=0;--l){let c=i[l];if(c.charAt(0)==="$")continue;if(c==="options"){o.push(...this._animateOptions(e,n));continue}let d=n[c],u=r[c],p=s.get(c);if(u)if(p&&u.active()){u.update(p,d,a);continue}else u.cancel();if(!p||!p.duration){e[c]=d;continue}r[c]=u=new lp(p,e,c,d),o.push(u)}return o}update(e,n){if(this._properties.size===0){Object.assign(e,n);return}let s=this._createAnimations(e,n);if(s.length)return ls.add(this._chart,s),!0}};function W5(t,e){let n=[],s=Object.keys(e);for(let o=0;o0||!n&&r<0)return o.index}return null}function i$(t,e){let{chart:n,_cachedMeta:s}=t,o=n._stacks||(n._stacks={}),{iScale:r,vScale:i,index:a}=s,l=r.axis,c=i.axis,d=U5(r,i,s),u=e.length,p;for(let f=0;fn[s].axis===e).shift()}function q5(t,e){return as(t,{active:!1,dataset:void 0,datasetIndex:e,index:e,mode:"default",type:"dataset"})}function J5(t,e,n){return as(t,{active:!1,dataIndex:e,parsed:void 0,raw:void 0,element:n,index:e,mode:"default",type:"data"})}function wi(t,e){let n=t.controller.index,s=t.vScale&&t.vScale.axis;if(s){e=e||t._parsed;for(let o of e){let r=o._stacks;if(!r||r[s]===void 0||r[s][n]===void 0)return;delete r[s][n],r[s]._visualValues!==void 0&&r[s]._visualValues[n]!==void 0&&delete r[s]._visualValues[n]}}}var Xu=t=>t==="reset"||t==="none",a$=(t,e)=>e?t:Object.assign({},t),Z5=(t,e,n)=>t&&!e.hidden&&e._stacked&&{keys:t0(n,!0),values:null},Vn=class{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(e,n){this.chart=e,this._ctx=e.ctx,this.index=n,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let e=this._cachedMeta;this.configure(),this.linkScales(),e._stacked=Zu(e.vScale,e),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(e){this.index!==e&&wi(this._cachedMeta),this.index=e}linkScales(){let e=this.chart,n=this._cachedMeta,s=this.getDataset(),o=(u,p,f,g)=>u==="x"?p:u==="r"?g:f,r=n.xAxisID=Se(s.xAxisID,Yu(e,"x")),i=n.yAxisID=Se(s.yAxisID,Yu(e,"y")),a=n.rAxisID=Se(s.rAxisID,Yu(e,"r")),l=n.indexAxis,c=n.iAxisID=o(l,r,i,a),d=n.vAxisID=o(l,i,r,a);n.xScale=this.getScaleForId(r),n.yScale=this.getScaleForId(i),n.rScale=this.getScaleForId(a),n.iScale=this.getScaleForId(c),n.vScale=this.getScaleForId(d)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(e){return this.chart.scales[e]}_getOtherScale(e){let n=this._cachedMeta;return e===n.iScale?n.vScale:n.iScale}reset(){this._update("reset")}_destroy(){let e=this._cachedMeta;this._data&&Mu(this._data,this),e._stacked&&wi(e)}_dataCheck(){let e=this.getDataset(),n=e.data||(e.data=[]),s=this._data;if(Le(n)){let o=this._cachedMeta;this._data=z5(n,o)}else if(s!==n){if(s){Mu(s,this);let o=this._cachedMeta;wi(o),o._parsed=[]}n&&Object.isExtensible(n)&&Nv(n,this),this._syncList=[],this._data=n}}addElements(){let e=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(e.dataset=new this.datasetElementType)}buildOrUpdateElements(e){let n=this._cachedMeta,s=this.getDataset(),o=!1;this._dataCheck();let r=n._stacked;n._stacked=Zu(n.vScale,n),n.stack!==s.stack&&(o=!0,wi(n),n.stack=s.stack),this._resyncElements(e),(o||r!==n._stacked)&&(i$(this,n._parsed),n._stacked=Zu(n.vScale,n))}configure(){let e=this.chart.config,n=e.datasetScopeKeys(this._type),s=e.getOptionScopes(this.getDataset(),n,!0);this.options=e.createResolver(s,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(e,n){let{_cachedMeta:s,_data:o}=this,{iScale:r,_stacked:i}=s,a=r.axis,l=e===0&&n===o.length?!0:s._sorted,c=e>0&&s._parsed[e-1],d,u,p;if(this._parsing===!1)s._parsed=o,s._sorted=!0,p=o;else{et(o[e])?p=this.parseArrayData(s,o,e,n):Le(o[e])?p=this.parseObjectData(s,o,e,n):p=this.parsePrimitiveData(s,o,e,n);let f=()=>u[a]===null||c&&u[a]m||u=0;--p)if(!g()){this.updateRangeFromParsed(c,e,f,l);break}}return c}getAllParsedValues(e){let n=this._cachedMeta._parsed,s=[],o,r,i;for(o=0,r=n.length;o=0&&ethis.getContext(s,o,n),m=c.resolveNamedOptions(p,f,g,u);return m.$shared&&(m.$shared=l,r[i]=Object.freeze(a$(m,l))),m}_resolveAnimations(e,n,s){let o=this.chart,r=this._cachedDataOpts,i=`animation-${n}`,a=r[i];if(a)return a;let l;if(o.options.animation!==!1){let d=this.chart.config,u=d.datasetAnimationScopeKeys(this._type,n),p=d.getOptionScopes(this.getDataset(),u);l=d.createResolver(p,this.getContext(e,s,n))}let c=new ec(o,l&&l.animations);return l&&l._cacheable&&(r[i]=Object.freeze(c)),c}getSharedOptions(e){if(e.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},e))}includeOptions(e,n){return!n||Xu(e)||this.chart._animationsDisabled}_getSharedOptions(e,n){let s=this.resolveDataElementOptions(e,n),o=this._sharedOptions,r=this.getSharedOptions(s),i=this.includeOptions(n,r)||r!==o;return this.updateSharedOptions(r,n,s),{sharedOptions:r,includeOptions:i}}updateElement(e,n,s,o){Xu(o)?Object.assign(e,s):this._resolveAnimations(n,o).update(e,s)}updateSharedOptions(e,n,s){e&&!Xu(n)&&this._resolveAnimations(void 0,n).update(e,s)}_setStyle(e,n,s,o){e.active=o;let r=this.getStyle(n,o);this._resolveAnimations(n,s,o).update(e,{options:!o&&this.getSharedOptions(r)||r})}removeHoverStyle(e,n,s){this._setStyle(e,s,"active",!1)}setHoverStyle(e,n,s){this._setStyle(e,s,"active",!0)}_removeDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,"active",!1)}_setDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,"active",!0)}_resyncElements(e){let n=this._data,s=this._cachedMeta.data;for(let[a,l,c]of this._syncList)this[a](l,c);this._syncList=[];let o=s.length,r=n.length,i=Math.min(r,o);i&&this.parse(0,i),r>o?this._insertElements(o,r-o,e):r{for(c.length+=n,a=c.length-1;a>=i;a--)c[a]=c[a-n]};for(l(r),a=e;ao-r))}return t._cache.$bar}function X5(t){let e=t.iScale,n=Y5(e,t.type),s=e._length,o,r,i,a,l=()=>{i===32767||i===-32768||(ir(a)&&(s=Math.min(s,Math.abs(i-a)||s)),a=i)};for(o=0,r=n.length;o0?o[t-1]:null,a=tMath.abs(a)&&(l=a,c=i),e[n.axis]=c,e._custom={barStart:l,barEnd:c,start:o,end:r,min:i,max:a}}function n0(t,e,n,s){return et(t)?tA(t,e,n,s):e[n.axis]=n.parse(t,s),e}function l$(t,e,n,s){let o=t.iScale,r=t.vScale,i=o.getLabels(),a=o===r,l=[],c,d,u,p;for(c=n,d=n+s;c=n?1:-1)}function sA(t){let e,n,s,o,r;return t.horizontal?(e=t.base>t.x,n="left",s="right"):(e=t.based.controller.options.grouped),r=s.options.stacked,i=[],a=this._cachedMeta.controller.getParsed(n),l=a&&a[s.axis],c=d=>{let u=d._parsed.find(f=>f[s.axis]===l),p=u&&u[d.vScale.axis];if(Me(p)||isNaN(p))return!0};for(let d of o)if(!(n!==void 0&&c(d))&&((r===!1||i.indexOf(d.stack)===-1||r===void 0&&d.stack===void 0)&&i.push(d.stack),d.index===e))break;return i.length||i.push(void 0),i}_getStackCount(e){return this._getStacks(void 0,e).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){let e=this.chart.scales,n=this.chart.options.indexAxis;return Object.keys(e).filter(s=>e[s].axis===n).shift()}_getAxis(){let e={},n=this.getFirstScaleIdForIndexAxis();for(let s of this.chart.data.datasets)e[Se(this.chart.options.indexAxis==="x"?s.xAxisID:s.yAxisID,n)]=!0;return Object.keys(e)}_getStackIndex(e,n,s){let o=this._getStacks(e,s),r=n!==void 0?o.indexOf(n):-1;return r===-1?o.length-1:r}_getRuler(){let e=this.options,n=this._cachedMeta,s=n.iScale,o=[],r,i;for(r=0,i=n.data.length;r=0;--s)n=Math.max(n,e[s].size(this.resolveDataElementOptions(s))/2);return n>0&&n}getLabelAndValue(e){let n=this._cachedMeta,s=this.chart.data.labels||[],{xScale:o,yScale:r}=n,i=this.getParsed(e),a=o.getLabelForValue(i.x),l=r.getLabelForValue(i.y),c=i._custom;return{label:s[e]||"",value:"("+a+", "+l+(c?", "+c:"")+")"}}update(e){let n=this._cachedMeta.data;this.updateElements(n,0,n.length,e)}updateElements(e,n,s,o){let r=o==="reset",{iScale:i,vScale:a}=this._cachedMeta,{sharedOptions:l,includeOptions:c}=this._getSharedOptions(n,o),d=i.axis,u=a.axis;for(let p=n;plr(v,a,l,!0)?1:Math.max($,$*n,w,w*n),g=(v,$,w)=>lr(v,a,l,!0)?-1:Math.min($,$*n,w,w*n),m=f(0,c,u),h=f(ft,d,p),b=g(He,c,u),x=g(He+ft,d,p);s=(m-b)/2,o=(h-x)/2,r=-(m+b)/2,i=-(h+x)/2}return{ratioX:s,ratioY:o,offsetX:r,offsetY:i}}var Ti=class extends Vn{static id="doughnut";static defaults={datasetElementType:!1,dataElementType:"arc",animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"};static descriptors={_scriptable:e=>e!=="spacing",_indexable:e=>e!=="spacing"&&!e.startsWith("borderDash")&&!e.startsWith("hoverBorderDash")};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let n=e.data,{labels:{pointStyle:s,textAlign:o,color:r,useBorderRadius:i,borderRadius:a}}=e.legend.options;return n.labels.length&&n.datasets.length?n.labels.map((l,c)=>{let u=e.getDatasetMeta(0).controller.getStyle(c);return{text:l,fillStyle:u.backgroundColor,fontColor:r,hidden:!e.getDataVisibility(c),lineDash:u.borderDash,lineDashOffset:u.borderDashOffset,lineJoin:u.borderJoinStyle,lineWidth:u.borderWidth,strokeStyle:u.borderColor,textAlign:o,pointStyle:s,borderRadius:i&&(a||u.borderRadius),index:c}}):[]}},onClick(e,n,s){s.chart.toggleDataVisibility(n.index),s.chart.update()}}}};constructor(e,n){super(e,n),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(e,n){let s=this.getDataset().data,o=this._cachedMeta;if(this._parsing===!1)o._parsed=s;else{let r=l=>+s[l];if(Le(s[e])){let{key:l="value"}=this._parsing;r=c=>+is(s[c],l)}let i,a;for(i=e,a=e+n;i0&&!isNaN(e)?tt*(Math.abs(e)/n):0}getLabelAndValue(e){let n=this._cachedMeta,s=this.chart,o=s.data.labels||[],r=cr(n._parsed[e],s.options.locale);return{label:o[e]||"",value:r}}getMaxBorderWidth(e){let n=0,s=this.chart,o,r,i,a,l;if(!e){for(o=0,r=s.data.datasets.length;o0&&this.getParsed(n-1);for(let w=0;w=x){C.skip=!0;continue}let _=this.getParsed(w),k=Me(_[f]),A=C[p]=i.getPixelForValue(_[p],w),D=C[f]=r||k?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,_,l):_[f],w);C.skip=isNaN(A)||isNaN(D)||k,C.stop=w>0&&Math.abs(_[p]-$[p])>h,m&&(C.parsed=_,C.raw=c.data[w]),u&&(C.options=d||this.resolveDataElementOptions(w,S.active?"active":o)),b||this.updateElement(S,w,C,o),$=_}}getMaxOverflow(){let e=this._cachedMeta,n=e.dataset,s=n.options&&n.options.borderWidth||0,o=e.data||[];if(!o.length)return s;let r=o[0].size(this.resolveDataElementOptions(0)),i=o[o.length-1].size(this.resolveDataElementOptions(o.length-1));return Math.max(s,r,i)/2}draw(){let e=this._cachedMeta;e.dataset.updateControlPoints(this.chart.chartArea,e.iScale.axis),super.draw()}},tc=class extends Vn{static id="polarArea";static defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let n=e.data;if(n.labels.length&&n.datasets.length){let{labels:{pointStyle:s,color:o}}=e.legend.options;return n.labels.map((r,i)=>{let l=e.getDatasetMeta(0).controller.getStyle(i);return{text:r,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:o,lineWidth:l.borderWidth,pointStyle:s,hidden:!e.getDataVisibility(i),index:i}})}return[]}},onClick(e,n,s){s.chart.toggleDataVisibility(n.index),s.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(e,n){super(e,n),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(e){let n=this._cachedMeta,s=this.chart,o=s.data.labels||[],r=cr(n._parsed[e].r,s.options.locale);return{label:o[e]||"",value:r}}parseObjectData(e,n,s,o){return Vu.bind(this)(e,n,s,o)}update(e){let n=this._cachedMeta.data;this._updateRadius(),this.updateElements(n,0,n.length,e)}getMinMax(){let e=this._cachedMeta,n={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return e.data.forEach((s,o)=>{let r=this.getParsed(o).r;!isNaN(r)&&this.chart.getDataVisibility(o)&&(rn.max&&(n.max=r))}),n}_updateRadius(){let e=this.chart,n=e.chartArea,s=e.options,o=Math.min(n.right-n.left,n.bottom-n.top),r=Math.max(o/2,0),i=Math.max(s.cutoutPercentage?r/100*s.cutoutPercentage:1,0),a=(r-i)/e.getVisibleDatasetCount();this.outerRadius=r-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(e,n,s,o){let r=o==="reset",i=this.chart,l=i.options.animation,c=this._cachedMeta.rScale,d=c.xCenter,u=c.yCenter,p=c.getIndexAngle(0)-.5*He,f=p,g,m=360/this.countVisibleElements();for(g=0;g{!isNaN(this.getParsed(o).r)&&this.chart.getDataVisibility(o)&&n++}),n}_computeAngle(e,n,s){return this.chart.getDataVisibility(e)?pn(this.resolveDataElementOptions(e,n).angle||s):0}},pp=class extends Ti{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}},fp=class extends Vn{static id="radar";static defaults={datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}};static overrides={aspectRatio:1,scales:{r:{type:"radialLinear"}}};getLabelAndValue(e){let n=this._cachedMeta.vScale,s=this.getParsed(e);return{label:n.getLabels()[e],value:""+n.getLabelForValue(s[n.axis])}}parseObjectData(e,n,s,o){return Vu.bind(this)(e,n,s,o)}update(e){let n=this._cachedMeta,s=n.dataset,o=n.data||[],r=n.iScale.getLabels();if(s.points=o,e!=="resize"){let i=this.resolveDatasetElementOptions(e);this.options.showLine||(i.borderWidth=0);let a={_loop:!0,_fullLoop:r.length===o.length,options:i};this.updateElement(s,void 0,a,e)}this.updateElements(o,0,o.length,e)}updateElements(e,n,s,o){let r=this._cachedMeta.rScale,i=o==="reset";for(let a=n;a0&&this.getParsed(n-1);for(let $=n;$0&&Math.abs(S[f]-v[f])>b,h&&(C.parsed=S,C.raw=c.data[$]),p&&(C.options=u||this.resolveDataElementOptions($,w.active?"active":o)),x||this.updateElement(w,$,C,o),v=S}this.updateSharedOptions(u,o,d)}getMaxOverflow(){let e=this._cachedMeta,n=e.data||[];if(!this.options.showLine){let a=0;for(let l=n.length-1;l>=0;--l)a=Math.max(a,n[l].size(this.resolveDataElementOptions(l))/2);return a>0&&a}let s=e.dataset,o=s.options&&s.options.borderWidth||0;if(!n.length)return o;let r=n[0].size(this.resolveDataElementOptions(0)),i=n[n.length-1].size(this.resolveDataElementOptions(n.length-1));return Math.max(o,r,i)/2}},lA=Object.freeze({__proto__:null,BarController:cp,BubbleController:dp,DoughnutController:Ti,LineController:up,PieController:pp,PolarAreaController:tc,RadarController:fp,ScatterController:hp});function lo(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}var mp=class t{static override(e){Object.assign(t.prototype,e)}options;constructor(e){this.options=e||{}}init(){}formats(){return lo()}parse(){return lo()}format(){return lo()}add(){return lo()}diff(){return lo()}startOf(){return lo()}endOf(){return lo()}},cA={_date:mp};function dA(t,e,n,s){let{controller:o,data:r,_sorted:i}=t,a=o._cachedMeta.iScale,l=t.dataset&&t.dataset.options?t.dataset.options.spanGaps:null;if(a&&e===a.axis&&e!=="r"&&i&&r.length){let c=a._reversePixels?Iv:On;if(s){if(o._sharedOptions){let d=r[0],u=typeof d.getRange=="function"&&d.getRange(e);if(u){let p=c(r,e,n-u),f=c(r,e,n+u);return{lo:p.lo,hi:f.hi}}}}else{let d=c(r,e,n);if(l){let{vScale:u}=o._cachedMeta,{_parsed:p}=t,f=p.slice(0,d.lo+1).reverse().findIndex(m=>!Me(m[u.axis]));d.lo-=Math.max(0,f);let g=p.slice(d.hi).findIndex(m=>!Me(m[u.axis]));d.hi+=Math.max(0,g)}return d}}return{lo:0,hi:r.length-1}}function Ii(t,e,n,s,o){let r=t.getSortedVisibleDatasetMetas(),i=n[e];for(let a=0,l=r.length;a{l[i]&&l[i](e[n],o)&&(r.push({element:l,datasetIndex:c,index:d}),a=a||l.inRange(e.x,e.y,o))}),s&&!a?[]:r}var hA={evaluateInteractionItems:Ii,modes:{index(t,e,n,s){let o=Es(e,t),r=n.axis||"x",i=n.includeInvisible||!1,a=n.intersect?ep(t,o,r,s,i):tp(t,o,r,!1,s,i),l=[];return a.length?(t.getSortedVisibleDatasetMetas().forEach(c=>{let d=a[0].index,u=c.data[d];u&&!u.skip&&l.push({element:u,datasetIndex:c.index,index:d})}),l):[]},dataset(t,e,n,s){let o=Es(e,t),r=n.axis||"xy",i=n.includeInvisible||!1,a=n.intersect?ep(t,o,r,s,i):tp(t,o,r,!1,s,i);if(a.length>0){let l=a[0].datasetIndex,c=t.getDatasetMeta(l).data;a=[];for(let d=0;dn.pos===e)}function p$(t,e){return t.filter(n=>s0.indexOf(n.pos)===-1&&n.box.axis===e)}function Si(t,e){return t.sort((n,s)=>{let o=e?s:n,r=e?n:s;return o.weight===r.weight?o.index-r.index:o.weight-r.weight})}function mA(t){let e=[],n,s,o,r,i,a;for(n=0,s=(t||[]).length;nc.box.fullSize),!0),s=Si(ki(e,"left"),!0),o=Si(ki(e,"right")),r=Si(ki(e,"top"),!0),i=Si(ki(e,"bottom")),a=p$(e,"x"),l=p$(e,"y");return{fullSize:n,leftAndTop:s.concat(r),rightAndBottom:o.concat(l).concat(i).concat(a),chartArea:ki(e,"chartArea"),vertical:s.concat(o).concat(l),horizontal:r.concat(i).concat(a)}}function f$(t,e,n,s){return Math.max(t[n],e[n])+Math.max(t[s],e[s])}function o0(t,e){t.top=Math.max(t.top,e.top),t.left=Math.max(t.left,e.left),t.bottom=Math.max(t.bottom,e.bottom),t.right=Math.max(t.right,e.right)}function yA(t,e,n,s){let{pos:o,box:r}=n,i=t.maxPadding;if(!Le(o)){n.size&&(t[o]-=n.size);let u=s[n.stack]||{size:0,count:1};u.size=Math.max(u.size,n.horizontal?r.height:r.width),n.size=u.size/u.count,t[o]+=n.size}r.getPadding&&o0(i,r.getPadding());let a=Math.max(0,e.outerWidth-f$(i,t,"left","right")),l=Math.max(0,e.outerHeight-f$(i,t,"top","bottom")),c=a!==t.w,d=l!==t.h;return t.w=a,t.h=l,n.horizontal?{same:c,other:d}:{same:d,other:c}}function vA(t){let e=t.maxPadding;function n(s){let o=Math.max(e[s]-t[s],0);return t[s]+=o,o}t.y+=n("top"),t.x+=n("left"),n("right"),n("bottom")}function $A(t,e){let n=e.maxPadding;function s(o){let r={left:0,top:0,right:0,bottom:0};return o.forEach(i=>{r[i]=Math.max(e[i],n[i])}),r}return s(t?["left","right"]:["top","bottom"])}function Ai(t,e,n,s){let o=[],r,i,a,l,c,d;for(r=0,i=t.length,c=0;r{typeof m.beforeLayout=="function"&&m.beforeLayout()});let d=l.reduce((m,h)=>h.box.options&&h.box.options.display===!1?m:m+1,0)||1,u=Object.freeze({outerWidth:e,outerHeight:n,padding:o,availableWidth:r,availableHeight:i,vBoxMaxWidth:r/2/d,hBoxMaxHeight:i/2}),p=Object.assign({},o);o0(p,Ot(s));let f=Object.assign({maxPadding:p,w:r,h:i,x:o.left,y:o.top},o),g=bA(l.concat(c),u);Ai(a.fullSize,f,u,g),Ai(l,f,u,g),Ai(c,f,u,g)&&Ai(l,f,u,g),vA(f),h$(a.leftAndTop,f,u,g),f.x+=f.w,f.y+=f.h,h$(a.rightAndBottom,f,u,g),t.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},Ke(a.chartArea,m=>{let h=m.box;Object.assign(h,t.chartArea),h.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})})}},nc=class{acquireContext(e,n){}releaseContext(e){return!1}addEventListener(e,n,s){}removeEventListener(e,n,s){}getDevicePixelRatio(){return 1}getMaximumSize(e,n,s,o){return n=Math.max(0,n||e.width),s=s||e.height,{width:n,height:Math.max(0,o?Math.floor(n/o):s)}}isAttached(e){return!0}updateConfig(e){}},gp=class extends nc{acquireContext(e){return e&&e.getContext&&e.getContext("2d")||null}updateConfig(e){e.options.animation=!1}},Xl="$chartjs",wA={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},m$=t=>t===null||t==="";function kA(t,e){let n=t.style,s=t.getAttribute("height"),o=t.getAttribute("width");if(t[Xl]={initial:{height:s,width:o,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",n.boxSizing=n.boxSizing||"border-box",m$(o)){let r=zu(t,"width");r!==void 0&&(t.width=r)}if(m$(s))if(t.style.height==="")t.height=t.width/(e||2);else{let r=zu(t,"height");r!==void 0&&(t.height=r)}return t}var r0=Yv?{passive:!0}:!1;function SA(t,e,n){t&&t.addEventListener(e,n,r0)}function CA(t,e,n){t&&t.canvas&&t.canvas.removeEventListener(e,n,r0)}function _A(t,e){let n=wA[t.type]||t.type,{x:s,y:o}=Es(t,e);return{type:n,chart:e,native:t,x:s!==void 0?s:null,y:o!==void 0?o:null}}function sc(t,e){for(let n of t)if(n===e||n.contains(e))return!0}function AA(t,e,n){let s=t.canvas,o=new MutationObserver(r=>{let i=!1;for(let a of r)i=i||sc(a.addedNodes,s),i=i&&!sc(a.removedNodes,s);i&&n()});return o.observe(document,{childList:!0,subtree:!0}),o}function MA(t,e,n){let s=t.canvas,o=new MutationObserver(r=>{let i=!1;for(let a of r)i=i||sc(a.removedNodes,s),i=i&&!sc(a.addedNodes,s);i&&n()});return o.observe(document,{childList:!0,subtree:!0}),o}var Pi=new Map,g$=0;function i0(){let t=window.devicePixelRatio;t!==g$&&(g$=t,Pi.forEach((e,n)=>{n.currentDevicePixelRatio!==t&&e()}))}function TA(t,e){Pi.size||window.addEventListener("resize",i0),Pi.set(t,e)}function PA(t){Pi.delete(t),Pi.size||window.removeEventListener("resize",i0)}function RA(t,e,n){let s=t.canvas,o=s&&zl(s);if(!o)return;let r=Ru((a,l)=>{let c=o.clientWidth;n(a,l),c{let l=a[0],c=l.contentRect.width,d=l.contentRect.height;c===0&&d===0||r(c,d)});return i.observe(o),TA(t,r),i}function np(t,e,n){n&&n.disconnect(),e==="resize"&&PA(t)}function LA(t,e,n){let s=t.canvas,o=Ru(r=>{t.ctx!==null&&n(_A(r,t))},t);return SA(s,e,o),o}var bp=class extends nc{acquireContext(e,n){let s=e&&e.getContext&&e.getContext("2d");return s&&s.canvas===e?(kA(e,n),s):null}releaseContext(e){let n=e.canvas;if(!n[Xl])return!1;let s=n[Xl].initial;["height","width"].forEach(r=>{let i=s[r];Me(i)?n.removeAttribute(r):n.setAttribute(r,i)});let o=s.style||{};return Object.keys(o).forEach(r=>{n.style[r]=o[r]}),n.width=n.width,delete n[Xl],!0}addEventListener(e,n,s){this.removeEventListener(e,n);let o=e.$proxies||(e.$proxies={}),i={attach:AA,detach:MA,resize:RA}[n]||LA;o[n]=i(e,n,s)}removeEventListener(e,n){let s=e.$proxies||(e.$proxies={}),o=s[n];if(!o)return;({attach:np,detach:np,resize:np}[n]||CA)(e,n,o),s[n]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,n,s,o){return Zv(e,n,s,o)}isAttached(e){let n=e&&zl(e);return!!(n&&n.isConnected)}};function EA(t){return!jl()||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas?gp:bp}var kn=class{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(e){let{x:n,y:s}=this.getProps(["x","y"],e);return{x:n,y:s}}hasValue(){return io(this.x)&&io(this.y)}getProps(e,n){let s=this.$animations;if(!n||!s)return this;let o={};return e.forEach(r=>{o[r]=s[r]&&s[r].active()?s[r]._to:this[r]}),o}};function IA(t,e){let n=t.options.ticks,s=DA(t),o=Math.min(n.maxTicksLimit||s,s),r=n.major.enabled?NA(e):[],i=r.length,a=r[0],l=r[i-1],c=[];if(i>o)return BA(e,c,r,i/o),c;let d=OA(r,e,o);if(i>0){let u,p,f=i>1?Math.round((l-a)/(i-1)):null;for(Gl(e,c,d,Me(f)?0:a-f,a),u=0,p=i-1;uo)return l}return Math.max(o,1)}function NA(t){let e=[],n,s;for(n=0,s=t.length;nt==="left"?"right":t==="right"?"left":t,b$=(t,e,n)=>e==="top"||e==="left"?t[e]+n:t[e]-n,x$=(t,e)=>Math.min(e||t,t);function y$(t,e){let n=[],s=t.length/e,o=t.length,r=0;for(;ri+a)))return l}function VA(t,e){Ke(t,n=>{let s=n.gc,o=s.length/2,r;if(o>e){for(r=0;rs?s:n,s=o&&n>s?n:s,{min:Yt(n,Yt(s,n)),max:Yt(s,Yt(n,s))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let e=this.chart.data;return this.options.labels||(this.isHorizontal()?e.xLabels:e.yLabels)||e.labels||[]}getLabelItems(e=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(e))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){Ye(this.options.beforeUpdate,[this])}update(e,n,s){let{beginAtZero:o,grace:r,ticks:i}=this.options,a=i.sampleSize;this.beforeUpdate(),this.maxWidth=e,this.maxHeight=n,this._margins=s=Object.assign({left:0,right:0,top:0,bottom:0},s),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+s.left+s.right:this.height+s.top+s.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=zv(this,r,o),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let l=a=r||s<=1||!this.isHorizontal()){this.labelRotation=o;return}let d=this._getLabelSizes(),u=d.widest.width,p=d.highest.height,f=wt(this.chart.width-u,0,this.maxWidth);a=e.offset?this.maxWidth/s:f/(s-1),u+6>a&&(a=f/(s-(e.offset?.5:1)),l=this.maxHeight-Ci(e.grid)-n.padding-v$(e.title,this.chart.options.font),c=Math.sqrt(u*u+p*p),i=Ol(Math.min(Math.asin(wt((d.highest.height+6)/a,-1,1)),Math.asin(wt(l/c,-1,1))-Math.asin(wt(p/c,-1,1)))),i=Math.max(o,Math.min(r,i))),this.labelRotation=i}afterCalculateLabelRotation(){Ye(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){Ye(this.options.beforeFit,[this])}fit(){let e={width:0,height:0},{chart:n,options:{ticks:s,title:o,grid:r}}=this,i=this._isVisible(),a=this.isHorizontal();if(i){let l=v$(o,n.options.font);if(a?(e.width=this.maxWidth,e.height=Ci(r)+l):(e.height=this.maxHeight,e.width=Ci(r)+l),s.display&&this.ticks.length){let{first:c,last:d,widest:u,highest:p}=this._getLabelSizes(),f=s.padding*2,g=pn(this.labelRotation),m=Math.cos(g),h=Math.sin(g);if(a){let b=s.mirror?0:h*u.width+m*p.height;e.height=Math.min(this.maxHeight,e.height+b+f)}else{let b=s.mirror?0:m*u.width+h*p.height;e.width=Math.min(this.maxWidth,e.width+b+f)}this._calculatePadding(c,d,h,m)}}this._handleMargins(),a?(this.width=this._length=n.width-this._margins.left-this._margins.right,this.height=e.height):(this.width=e.width,this.height=this._length=n.height-this._margins.top-this._margins.bottom)}_calculatePadding(e,n,s,o){let{ticks:{align:r,padding:i},position:a}=this.options,l=this.labelRotation!==0,c=a!=="top"&&this.axis==="x";if(this.isHorizontal()){let d=this.getPixelForTick(0)-this.left,u=this.right-this.getPixelForTick(this.ticks.length-1),p=0,f=0;l?c?(p=o*e.width,f=s*n.height):(p=s*e.height,f=o*n.width):r==="start"?f=n.width:r==="end"?p=e.width:r!=="inner"&&(p=e.width/2,f=n.width/2),this.paddingLeft=Math.max((p-d+i)*this.width/(this.width-d),0),this.paddingRight=Math.max((f-u+i)*this.width/(this.width-u),0)}else{let d=n.height/2,u=e.height/2;r==="start"?(d=0,u=e.height):r==="end"&&(d=n.height,u=0),this.paddingTop=d+i,this.paddingBottom=u+i}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){Ye(this.options.afterFit,[this])}isHorizontal(){let{axis:e,position:n}=this.options;return n==="top"||n==="bottom"||e==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(e){this.beforeTickToLabelConversion(),this.generateTickLabels(e);let n,s;for(n=0,s=e.length;n({width:i[k]||0,height:a[k]||0});return{first:_(0),last:_(n-1),widest:_(S),highest:_(C),widths:i,heights:a}}getLabelForValue(e){return e}getPixelForValue(e,n){return NaN}getValueForPixel(e){}getPixelForTick(e){let n=this.ticks;return e<0||e>n.length-1?null:this.getPixelForValue(n[e].value)}getPixelForDecimal(e){this._reversePixels&&(e=1-e);let n=this._startPixel+e*this._length;return Ev(this._alignToPixels?Ps(this.chart,n,0):n)}getDecimalForPixel(e){let n=(e-this._startPixel)/this._length;return this._reversePixels?1-n:n}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:e,max:n}=this;return e<0&&n<0?n:e>0&&n>0?e:0}getContext(e){let n=this.ticks||[];if(e>=0&&ea*o?a/s:l/o:l*o0}_computeGridLineItems(e){let n=this.axis,s=this.chart,o=this.options,{grid:r,position:i,border:a}=o,l=r.offset,c=this.isHorizontal(),u=this.ticks.length+(l?1:0),p=Ci(r),f=[],g=a.setContext(this.getContext()),m=g.display?g.width:0,h=m/2,b=function(L){return Ps(s,L,m)},x,v,$,w,S,C,_,k,A,D,O,z;if(i==="top")x=b(this.bottom),C=this.bottom-p,k=x-h,D=b(e.top)+h,z=e.bottom;else if(i==="bottom")x=b(this.top),D=e.top,z=b(e.bottom)-h,C=x+h,k=this.top+p;else if(i==="left")x=b(this.right),S=this.right-p,_=x-h,A=b(e.left)+h,O=e.right;else if(i==="right")x=b(this.left),A=e.left,O=b(e.right)-h,S=x+h,_=this.left+p;else if(n==="x"){if(i==="center")x=b((e.top+e.bottom)/2+.5);else if(Le(i)){let L=Object.keys(i)[0],B=i[L];x=b(this.chart.scales[L].getPixelForValue(B))}D=e.top,z=e.bottom,C=x+h,k=C+p}else if(n==="y"){if(i==="center")x=b((e.left+e.right)/2);else if(Le(i)){let L=Object.keys(i)[0],B=i[L];x=b(this.chart.scales[L].getPixelForValue(B))}S=x-h,_=S-p,A=e.left,O=e.right}let N=Se(o.ticks.maxTicksLimit,u),M=Math.max(1,Math.ceil(u/N));for(v=0;v0&&(pe-=j/2);break}K={left:pe,top:J,width:j+re.width,height:Y+re.height,color:M.backdropColor}}h.push({label:$,font:k,textOffset:O,options:{rotation:m,color:B,strokeColor:E,strokeWidth:U,textAlign:F,textBaseline:z,translation:[w,S],backdrop:K}})}return h}_getXAxisLabelAlignment(){let{position:e,ticks:n}=this.options;if(-pn(this.labelRotation))return e==="top"?"left":"right";let o="center";return n.align==="start"?o="left":n.align==="end"?o="right":n.align==="inner"&&(o="inner"),o}_getYAxisLabelAlignment(e){let{position:n,ticks:{crossAlign:s,mirror:o,padding:r}}=this.options,i=this._getLabelSizes(),a=e+r,l=i.widest.width,c,d;return n==="left"?o?(d=this.right+r,s==="near"?c="left":s==="center"?(c="center",d+=l/2):(c="right",d+=l)):(d=this.right-a,s==="near"?c="right":s==="center"?(c="center",d-=l/2):(c="left",d=this.left)):n==="right"?o?(d=this.left+r,s==="near"?c="right":s==="center"?(c="center",d-=l/2):(c="left",d-=l)):(d=this.left+a,s==="near"?c="left":s==="center"?(c="center",d+=l/2):(c="right",d=this.right)):c="right",{textAlign:c,x:d}}_computeLabelArea(){if(this.options.ticks.mirror)return;let e=this.chart,n=this.options.position;if(n==="left"||n==="right")return{top:0,left:this.left,bottom:e.height,right:this.right};if(n==="top"||n==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:e.width}}drawBackground(){let{ctx:e,options:{backgroundColor:n},left:s,top:o,width:r,height:i}=this;n&&(e.save(),e.fillStyle=n,e.fillRect(s,o,r,i),e.restore())}getLineWidthForValue(e){let n=this.options.grid;if(!this._isVisible()||!n.display)return 0;let o=this.ticks.findIndex(r=>r.value===e);return o>=0?n.setContext(this.getContext(o)).lineWidth:0}drawGrid(e){let n=this.options.grid,s=this.ctx,o=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(e)),r,i,a=(l,c,d)=>{!d.width||!d.color||(s.save(),s.lineWidth=d.width,s.strokeStyle=d.color,s.setLineDash(d.borderDash||[]),s.lineDashOffset=d.borderDashOffset,s.beginPath(),s.moveTo(l.x,l.y),s.lineTo(c.x,c.y),s.stroke(),s.restore())};if(n.display)for(r=0,i=o.length;r{this.draw(r)}}]:[{z:s,draw:r=>{this.drawBackground(),this.drawGrid(r),this.drawTitle()}},{z:o,draw:()=>{this.drawBorder()}},{z:n,draw:r=>{this.drawLabels(r)}}]}getMatchingVisibleMetas(e){let n=this.chart.getSortedVisibleDatasetMetas(),s=this.axis+"AxisID",o=[],r,i;for(r=0,i=n.length;r{let s=n.split("."),o=s.pop(),r=[t].concat(s).join("."),i=e[n].split("."),a=i.pop(),l=i.join(".");st.route(r,o,l,a)})}function JA(t){return"id"in t&&"defaults"in t}var xp=class{constructor(){this.controllers=new fr(Vn,"datasets",!0),this.elements=new fr(kn,"elements"),this.plugins=new fr(Object,"plugins"),this.scales=new fr(uo,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...e){this._each("register",e)}remove(...e){this._each("unregister",e)}addControllers(...e){this._each("register",e,this.controllers)}addElements(...e){this._each("register",e,this.elements)}addPlugins(...e){this._each("register",e,this.plugins)}addScales(...e){this._each("register",e,this.scales)}getController(e){return this._get(e,this.controllers,"controller")}getElement(e){return this._get(e,this.elements,"element")}getPlugin(e){return this._get(e,this.plugins,"plugin")}getScale(e){return this._get(e,this.scales,"scale")}removeControllers(...e){this._each("unregister",e,this.controllers)}removeElements(...e){this._each("unregister",e,this.elements)}removePlugins(...e){this._each("unregister",e,this.plugins)}removeScales(...e){this._each("unregister",e,this.scales)}_each(e,n,s){[...n].forEach(o=>{let r=s||this._getRegistryForType(o);s||r.isForType(o)||r===this.plugins&&o.id?this._exec(e,r,o):Ke(o,i=>{let a=s||this._getRegistryForType(i);this._exec(e,a,i)})})}_exec(e,n,s){let o=Dl(e);Ye(s["before"+o],[],s),n[e](s),Ye(s["after"+o],[],s)}_getRegistryForType(e){for(let n=0;nr.filter(a=>!i.some(l=>a.plugin.id===l.plugin.id));this._notify(o(n,s),e,"stop"),this._notify(o(s,n),e,"start")}};function ZA(t){let e={},n=[],s=Object.keys(Hn.plugins.items);for(let r=0;r1&&$$(t[0].toLowerCase());if(s)return s}throw new Error(`Cannot determine type of '${t}' axis. Please provide 'axis' or 'position' option.`)}function w$(t,e,n){if(n[e+"AxisID"]===t)return{axis:e}}function sM(t,e){if(e.data&&e.data.datasets){let n=e.data.datasets.filter(s=>s.xAxisID===t||s.yAxisID===t);if(n.length)return w$(t,"x",n[0])||w$(t,"y",n[0])}return{}}function oM(t,e){let n=Ts[t.type]||{scales:{}},s=e.scales||{},o=vp(t.type,e),r=Object.create(null);return Object.keys(s).forEach(i=>{let a=s[i];if(!Le(a))return console.error(`Invalid scale configuration for scale: ${i}`);if(a._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${i}`);let l=$p(i,a,sM(i,t),st.scales[a.type]),c=tM(l,o),d=n.scales||{};r[i]=rr(Object.create(null),[{axis:l},a,d[l],d[c]])}),t.data.datasets.forEach(i=>{let a=i.type||t.type,l=i.indexAxis||vp(a,e),d=(Ts[a]||{}).scales||{};Object.keys(d).forEach(u=>{let p=eM(u,l),f=i[p+"AxisID"]||p;r[f]=r[f]||Object.create(null),rr(r[f],[{axis:p},s[f],d[u]])})}),Object.keys(r).forEach(i=>{let a=r[i];rr(a,[st.scales[a.type],st.scale])}),r}function a0(t){let e=t.options||(t.options={});e.plugins=Se(e.plugins,{}),e.scales=oM(t,e)}function l0(t){return t=t||{},t.datasets=t.datasets||[],t.labels=t.labels||[],t}function rM(t){return t=t||{},t.data=l0(t.data),a0(t),t}var k$=new Map,c0=new Set;function ql(t,e){let n=k$.get(t);return n||(n=e(),k$.set(t,n),c0.add(n)),n}var _i=(t,e,n)=>{let s=is(e,n);s!==void 0&&t.add(s)},wp=class{constructor(e){this._config=rM(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=l0(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){let e=this._config;this.clearCache(),a0(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return ql(e,()=>[[`datasets.${e}`,""]])}datasetAnimationScopeKeys(e,n){return ql(`${e}.transition.${n}`,()=>[[`datasets.${e}.transitions.${n}`,`transitions.${n}`],[`datasets.${e}`,""]])}datasetElementScopeKeys(e,n){return ql(`${e}-${n}`,()=>[[`datasets.${e}.elements.${n}`,`datasets.${e}`,`elements.${n}`,""]])}pluginScopeKeys(e){let n=e.id,s=this.type;return ql(`${s}-plugin-${n}`,()=>[[`plugins.${n}`,...e.additionalOptionScopes||[]]])}_cachedScopes(e,n){let s=this._scopeCache,o=s.get(e);return(!o||n)&&(o=new Map,s.set(e,o)),o}getOptionScopes(e,n,s){let{options:o,type:r}=this,i=this._cachedScopes(e,s),a=i.get(n);if(a)return a;let l=new Set;n.forEach(d=>{e&&(l.add(e),d.forEach(u=>_i(l,e,u))),d.forEach(u=>_i(l,o,u)),d.forEach(u=>_i(l,Ts[r]||{},u)),d.forEach(u=>_i(l,st,u)),d.forEach(u=>_i(l,Fl,u))});let c=Array.from(l);return c.length===0&&c.push(Object.create(null)),c0.has(n)&&i.set(n,c),c}chartOptionScopes(){let{options:e,type:n}=this;return[e,Ts[n]||{},st.datasets[n]||{},{type:n},st,Fl]}resolveNamedOptions(e,n,s,o=[""]){let r={$shared:!0},{resolver:i,subPrefixes:a}=S$(this._resolverCache,e,o),l=i;if(aM(i,n)){r.$shared=!1,s=os(s)?s():s;let c=this.createResolver(e,s,a);l=ro(i,s,c)}for(let c of n)r[c]=l[c];return r}createResolver(e,n,s=[""],o){let{resolver:r}=S$(this._resolverCache,e,s);return Le(n)?ro(r,n,void 0,o):r}};function S$(t,e,n){let s=t.get(e);s||(s=new Map,t.set(e,s));let o=n.join(),r=s.get(o);return r||(r={resolver:Vl(e,n),subPrefixes:n.filter(a=>!a.toLowerCase().includes("hover"))},s.set(o,r)),r}var iM=t=>Le(t)&&Object.getOwnPropertyNames(t).some(e=>os(t[e]));function aM(t,e){let{isScriptable:n,isIndexable:s}=Fu(t);for(let o of e){let r=n(o),i=s(o),a=(i||r)&&t[o];if(r&&(os(a)||iM(a))||i&&et(a))return!0}return!1}var lM="4.5.1",cM=["top","bottom","left","right","chartArea"];function C$(t,e){return t==="top"||t==="bottom"||cM.indexOf(t)===-1&&e==="x"}function _$(t,e){return function(n,s){return n[t]===s[t]?n[e]-s[e]:n[t]-s[t]}}function A$(t){let e=t.chart,n=e.options.animation;e.notifyPlugins("afterRender"),Ye(n&&n.onComplete,[t],e)}function dM(t){let e=t.chart,n=e.options.animation;Ye(n&&n.onProgress,[t],e)}function d0(t){return jl()&&typeof t=="string"?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}var Ql={},M$=t=>{let e=d0(t);return Object.values(Ql).filter(n=>n.canvas===e).pop()};function uM(t,e,n){let s=Object.keys(t);for(let o of s){let r=+o;if(r>=e){let i=t[o];delete t[o],(n>0||r>e)&&(t[r+n]=i)}}}function pM(t,e,n,s){return!n||t.type==="mouseout"?null:s?e:t}var hr=class{static defaults=st;static instances=Ql;static overrides=Ts;static registry=Hn;static version=lM;static getChart=M$;static register(...e){Hn.add(...e),T$()}static unregister(...e){Hn.remove(...e),T$()}constructor(e,n){let s=this.config=new wp(n),o=d0(e),r=M$(o);if(r)throw new Error("Canvas is already in use. Chart with ID '"+r.id+"' must be destroyed before the canvas with ID '"+r.canvas.id+"' can be reused.");let i=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||EA(o)),this.platform.updateConfig(s);let a=this.platform.acquireContext(o,i.aspectRatio),l=a&&a.canvas,c=l&&l.height,d=l&&l.width;if(this.id=Av(),this.ctx=a,this.canvas=l,this.width=d,this.height=c,this._options=i,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new yp,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=Bv(u=>this.update(u),i.resizeDelay||0),this._dataChanges=[],Ql[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}ls.listen(this,"complete",A$),ls.listen(this,"progress",dM),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:e,maintainAspectRatio:n},width:s,height:o,_aspectRatio:r}=this;return Me(e)?n&&r?r:o?s/o:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return Hn}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():ju(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Ou(this.canvas,this.ctx),this}stop(){return ls.stop(this),this}resize(e,n){ls.running(this)?this._resizeBeforeDraw={width:e,height:n}:this._resize(e,n)}_resize(e,n){let s=this.options,o=this.canvas,r=s.maintainAspectRatio&&this.aspectRatio,i=this.platform.getMaximumSize(o,e,n,r),a=s.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=i.width,this.height=i.height,this._aspectRatio=this.aspectRatio,ju(this,a,!0)&&(this.notifyPlugins("resize",{size:i}),Ye(s.onResize,[this,i],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){let n=this.options.scales||{};Ke(n,(s,o)=>{s.id=o})}buildOrUpdateScales(){let e=this.options,n=e.scales,s=this.scales,o=Object.keys(s).reduce((i,a)=>(i[a]=!1,i),{}),r=[];n&&(r=r.concat(Object.keys(n).map(i=>{let a=n[i],l=$p(i,a),c=l==="r",d=l==="x";return{options:a,dposition:c?"chartArea":d?"bottom":"left",dtype:c?"radialLinear":d?"category":"linear"}}))),Ke(r,i=>{let a=i.options,l=a.id,c=$p(l,a),d=Se(a.type,i.dtype);(a.position===void 0||C$(a.position,c)!==C$(i.dposition))&&(a.position=i.dposition),o[l]=!0;let u=null;if(l in s&&s[l].type===d)u=s[l];else{let p=Hn.getScale(d);u=new p({id:l,type:d,ctx:this.ctx,chart:this}),s[u.id]=u}u.init(a,e)}),Ke(o,(i,a)=>{i||delete s[a]}),Ke(s,i=>{Ft.configure(this,i,i.options),Ft.addBox(this,i)})}_updateMetasets(){let e=this._metasets,n=this.data.datasets.length,s=e.length;if(e.sort((o,r)=>o.index-r.index),s>n){for(let o=n;on.length&&delete this._stacks,e.forEach((s,o)=>{n.filter(r=>r===s._dataset).length===0&&this._destroyDatasetMeta(o)})}buildOrUpdateControllers(){let e=[],n=this.data.datasets,s,o;for(this._removeUnreferencedMetasets(),s=0,o=n.length;s{this.getDatasetMeta(n).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(e){let n=this.config;n.update();let s=this._options=n.createResolver(n.chartOptionScopes(),this.getContext()),o=this._animationsDisabled=!s.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:e,cancelable:!0})===!1)return;let r=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let i=0;for(let c=0,d=this.data.datasets.length;c{c.reset()}),this._updateDatasets(e),this.notifyPlugins("afterUpdate",{mode:e}),this._layers.sort(_$("z","_idx"));let{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){Ke(this.scales,e=>{Ft.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let e=this.options,n=new Set(Object.keys(this._listeners)),s=new Set(e.events);(!ku(n,s)||!!this._responsiveListeners!==e.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:e}=this,n=this._getUniformDataChanges()||[];for(let{method:s,start:o,count:r}of n){let i=s==="_removeElements"?-r:r;uM(e,o,i)}}_getUniformDataChanges(){let e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];let n=this.data.datasets.length,s=r=>new Set(e.filter(i=>i[0]===r).map((i,a)=>a+","+i.splice(1).join(","))),o=s(0);for(let r=1;rr.split(",")).map(r=>({method:r[1],start:+r[2],count:+r[3]}))}_updateLayout(e){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;Ft.update(this,this.width,this.height,e);let n=this.chartArea,s=n.width<=0||n.height<=0;this._layers=[],Ke(this.boxes,o=>{s&&o.position==="chartArea"||(o.configure&&o.configure(),this._layers.push(...o._layers()))},this),this._layers.forEach((o,r)=>{o._idx=r}),this.notifyPlugins("afterLayout")}_updateDatasets(e){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:e,cancelable:!0})!==!1){for(let n=0,s=this.data.datasets.length;n=0;--n)this._drawDataset(e[n]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(e){let n=this.ctx,s={meta:e,index:e.index,cancelable:!0},o=Ju(this,e);this.notifyPlugins("beforeDatasetDraw",s)!==!1&&(o&&vi(n,o),e.controller.draw(),o&&$i(n),s.cancelable=!1,this.notifyPlugins("afterDatasetDraw",s))}isPointInArea(e){return Nn(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,n,s,o){let r=hA.modes[n];return typeof r=="function"?r(this,e,s,o):[]}getDatasetMeta(e){let n=this.data.datasets[e],s=this._metasets,o=s.filter(r=>r&&r._dataset===n).pop();return o||(o={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:n&&n.order||0,index:e,_dataset:n,_parsed:[],_sorted:!1},s.push(o)),o}getContext(){return this.$context||(this.$context=as(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){let n=this.data.datasets[e];if(!n)return!1;let s=this.getDatasetMeta(e);return typeof s.hidden=="boolean"?!s.hidden:!n.hidden}setDatasetVisibility(e,n){let s=this.getDatasetMeta(e);s.hidden=!n}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,n,s){let o=s?"show":"hide",r=this.getDatasetMeta(e),i=r.controller._resolveAnimations(void 0,o);ir(n)?(r.data[n].hidden=!s,this.update()):(this.setDatasetVisibility(e,s),i.update(r,{visible:s}),this.update(a=>a.datasetIndex===e?o:void 0))}hide(e,n){this._updateVisibility(e,n,!1)}show(e,n){this._updateVisibility(e,n,!0)}_destroyDatasetMeta(e){let n=this._metasets[e];n&&n.controller&&n.controller._destroy(),delete this._metasets[e]}_stop(){let e,n;for(this.stop(),ls.remove(this),e=0,n=this.data.datasets.length;e{n.addEventListener(this,r,i),e[r]=i},o=(r,i,a)=>{r.offsetX=i,r.offsetY=a,this._eventHandler(r)};Ke(this.options.events,r=>s(r,o))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});let e=this._responsiveListeners,n=this.platform,s=(l,c)=>{n.addEventListener(this,l,c),e[l]=c},o=(l,c)=>{e[l]&&(n.removeEventListener(this,l,c),delete e[l])},r=(l,c)=>{this.canvas&&this.resize(l,c)},i,a=()=>{o("attach",a),this.attached=!0,this.resize(),s("resize",r),s("detach",i)};i=()=>{this.attached=!1,o("resize",r),this._stop(),this._resize(0,0),s("attach",a)},n.isAttached(this.canvas)?a():i()}unbindEvents(){Ke(this._listeners,(e,n)=>{this.platform.removeEventListener(this,n,e)}),this._listeners={},Ke(this._responsiveListeners,(e,n)=>{this.platform.removeEventListener(this,n,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,n,s){let o=s?"set":"remove",r,i,a,l;for(n==="dataset"&&(r=this.getDatasetMeta(e[0].datasetIndex),r.controller["_"+o+"DatasetHoverStyle"]()),a=0,l=e.length;a{let a=this.getDatasetMeta(r);if(!a)throw new Error("No dataset found at index "+r);return{datasetIndex:r,element:a.data[i],index:i}});!xi(s,n)&&(this._active=s,this._lastEvent=null,this._updateHoverStyles(s,n))}notifyPlugins(e,n,s){return this._plugins.notify(this,e,n,s)}isPluginEnabled(e){return this._plugins._cache.filter(n=>n.plugin.id===e).length===1}_updateHoverStyles(e,n,s){let o=this.options.hover,r=(l,c)=>l.filter(d=>!c.some(u=>d.datasetIndex===u.datasetIndex&&d.index===u.index)),i=r(n,e),a=s?e:r(e,n);i.length&&this.updateHoverStyle(i,o.mode,!1),a.length&&o.mode&&this.updateHoverStyle(a,o.mode,!0)}_eventHandler(e,n){let s={event:e,replay:n,cancelable:!0,inChartArea:this.isPointInArea(e)},o=i=>(i.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins("beforeEvent",s,o)===!1)return;let r=this._handleEvent(e,n,s.inChartArea);return s.cancelable=!1,this.notifyPlugins("afterEvent",s,o),(r||s.changed)&&this.render(),this}_handleEvent(e,n,s){let{_active:o=[],options:r}=this,i=n,a=this._getActiveElements(e,o,s,i),l=Pv(e),c=pM(e,this._lastEvent,s,l);s&&(this._lastEvent=null,Ye(r.onHover,[e,a,this],this),l&&Ye(r.onClick,[e,a,this],this));let d=!xi(a,o);return(d||n)&&(this._active=a,this._updateHoverStyles(a,o,n)),this._lastEvent=c,d}_getActiveElements(e,n,s,o){if(e.type==="mouseout")return[];if(!s)return n;let r=this.options.hover;return this.getElementsAtEventForMode(e,r.mode,r,o)}};function T$(){return Ke(hr.instances,t=>t._plugins.invalidate())}function fM(t,e,n){let{startAngle:s,x:o,y:r,outerRadius:i,innerRadius:a,options:l}=e,{borderWidth:c,borderJoinStyle:d}=l,u=Math.min(c/i,It(s-n));if(t.beginPath(),t.arc(o,r,i-c/2,s+u/2,n-u/2),a>0){let p=Math.min(c/a,It(s-n));t.arc(o,r,a+c/2,n-p/2,s+p/2,!0)}else{let p=Math.min(c/2,i*It(s-n));if(d==="round")t.arc(o,r,p,n-He/2,s+He/2,!0);else if(d==="bevel"){let f=2*p*p,g=-f*Math.cos(n+He/2)+o,m=-f*Math.sin(n+He/2)+r,h=f*Math.cos(s+He/2)+o,b=f*Math.sin(s+He/2)+r;t.lineTo(g,m),t.lineTo(h,b)}}t.closePath(),t.moveTo(0,0),t.rect(0,0,t.canvas.width,t.canvas.height),t.clip("evenodd")}function hM(t,e,n){let{startAngle:s,pixelMargin:o,x:r,y:i,outerRadius:a,innerRadius:l}=e,c=o/a;t.beginPath(),t.arc(r,i,a,s-c,n+c),l>o?(c=o/l,t.arc(r,i,l,n+c,s-c,!0)):t.arc(r,i,o,n+ft,s-ft),t.closePath(),t.clip()}function mM(t){return Hl(t,["outerStart","outerEnd","innerStart","innerEnd"])}function gM(t,e,n,s){let o=mM(t.options.borderRadius),r=(n-e)/2,i=Math.min(r,s*e/2),a=l=>{let c=(n-Math.min(r,l))*s/2;return wt(l,0,Math.min(r,c))};return{outerStart:a(o.outerStart),outerEnd:a(o.outerEnd),innerStart:wt(o.innerStart,0,i),innerEnd:wt(o.innerEnd,0,i)}}function pr(t,e,n,s){return{x:n+t*Math.cos(e),y:s+t*Math.sin(e)}}function oc(t,e,n,s,o,r){let{x:i,y:a,startAngle:l,pixelMargin:c,innerRadius:d}=e,u=Math.max(e.outerRadius+s+n-c,0),p=d>0?d+s+n+c:0,f=0,g=o-l;if(s){let M=d>0?d-s:0,L=u>0?u-s:0,B=(M+L)/2,E=B!==0?g*B/(B+s):g;f=(g-E)/2}let m=Math.max(.001,g*u-n/He)/u,h=(g-m)/2,b=l+h+f,x=o-h-f,{outerStart:v,outerEnd:$,innerStart:w,innerEnd:S}=gM(e,p,u,x-b),C=u-v,_=u-$,k=b+v/C,A=x-$/_,D=p+w,O=p+S,z=b+w/D,N=x-S/O;if(t.beginPath(),r){let M=(k+A)/2;if(t.arc(i,a,u,k,M),t.arc(i,a,u,M,A),$>0){let U=pr(_,A,i,a);t.arc(U.x,U.y,$,A,x+ft)}let L=pr(O,x,i,a);if(t.lineTo(L.x,L.y),S>0){let U=pr(O,N,i,a);t.arc(U.x,U.y,S,x+ft,N+Math.PI)}let B=(x-S/p+(b+w/p))/2;if(t.arc(i,a,p,x-S/p,B,!0),t.arc(i,a,p,B,b+w/p,!0),w>0){let U=pr(D,z,i,a);t.arc(U.x,U.y,w,z+Math.PI,b-ft)}let E=pr(C,b,i,a);if(t.lineTo(E.x,E.y),v>0){let U=pr(C,k,i,a);t.arc(U.x,U.y,v,b-ft,k)}}else{t.moveTo(i,a);let M=Math.cos(k)*u+i,L=Math.sin(k)*u+a;t.lineTo(M,L);let B=Math.cos(A)*u+i,E=Math.sin(A)*u+a;t.lineTo(B,E)}t.closePath()}function bM(t,e,n,s,o){let{fullCircles:r,startAngle:i,circumference:a}=e,l=e.endAngle;if(r){oc(t,e,n,s,l,o);for(let c=0;c=He&&f===0&&d!=="miter"&&fM(t,e,m),r||(oc(t,e,n,s,m,o),t.stroke())}var kp=class extends kn{static id="arc";static defaults={borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:"backgroundColor"};static descriptors={_scriptable:!0,_indexable:e=>e!=="borderDash"};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(e){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,e&&Object.assign(this,e)}inRange(e,n,s){let o=this.getProps(["x","y"],s),{angle:r,distance:i}=Au(o,{x:e,y:n}),{startAngle:a,endAngle:l,innerRadius:c,outerRadius:d,circumference:u}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],s),p=(this.options.spacing+this.options.borderWidth)/2,f=Se(u,l-a),g=lr(r,a,l)&&a!==l,m=f>=tt||g,h=Fn(i,c+p,d+p);return m&&h}getCenterPoint(e){let{x:n,y:s,startAngle:o,endAngle:r,innerRadius:i,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],e),{offset:l,spacing:c}=this.options,d=(o+r)/2,u=(i+a+c+l)/2;return{x:n+Math.cos(d)*u,y:s+Math.sin(d)*u}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){let{options:n,circumference:s}=this,o=(n.offset||0)/4,r=(n.spacing||0)/2,i=n.circular;if(this.pixelMargin=n.borderAlign==="inner"?.33:0,this.fullCircles=s>tt?Math.floor(s/tt):0,s===0||this.innerRadius<0||this.outerRadius<0)return;e.save();let a=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(a)*o,Math.sin(a)*o);let l=1-Math.sin(Math.min(He,s||0)),c=o*l;e.fillStyle=n.backgroundColor,e.strokeStyle=n.borderColor,bM(e,this,c,r,i),xM(e,this,c,r,i),e.restore()}};function u0(t,e,n=e){t.lineCap=Se(n.borderCapStyle,e.borderCapStyle),t.setLineDash(Se(n.borderDash,e.borderDash)),t.lineDashOffset=Se(n.borderDashOffset,e.borderDashOffset),t.lineJoin=Se(n.borderJoinStyle,e.borderJoinStyle),t.lineWidth=Se(n.borderWidth,e.borderWidth),t.strokeStyle=Se(n.borderColor,e.borderColor)}function yM(t,e,n){t.lineTo(n.x,n.y)}function vM(t){return t.stepped?Vv:t.tension||t.cubicInterpolationMode==="monotone"?jv:yM}function p0(t,e,n={}){let s=t.length,{start:o=0,end:r=s-1}=n,{start:i,end:a}=e,l=Math.max(o,i),c=Math.min(r,a),d=oa&&r>a;return{count:s,start:l,loop:e.loop,ilen:c(i+(c?a-$:$))%r,v=()=>{m!==h&&(t.lineTo(d,h),t.lineTo(d,m),t.lineTo(d,b))};for(l&&(f=o[x(0)],t.moveTo(f.x,f.y)),p=0;p<=a;++p){if(f=o[x(p)],f.skip)continue;let $=f.x,w=f.y,S=$|0;S===g?(wh&&(h=w),d=(u*d+$)/++u):(v(),t.lineTo($,w),g=S,u=0,m=h=w),b=w}v()}function Sp(t){let e=t.options,n=e.borderDash&&e.borderDash.length;return!t._decimated&&!t._loop&&!e.tension&&e.cubicInterpolationMode!=="monotone"&&!e.stepped&&!n?wM:$M}function kM(t){return t.stepped?Xv:t.tension||t.cubicInterpolationMode==="monotone"?Qv:As}function SM(t,e,n,s){let o=e._path;o||(o=e._path=new Path2D,e.path(o,n,s)&&o.closePath()),u0(t,e.options),t.stroke(o)}function CM(t,e,n,s){let{segments:o,options:r}=e,i=Sp(e);for(let a of o)u0(t,r,a.style),t.beginPath(),i(t,e,a,{start:n,end:n+s-1})&&t.closePath(),t.stroke()}var _M=typeof Path2D=="function";function AM(t,e,n,s){_M&&!e.options.segment?SM(t,e,n,s):CM(t,e,n,s)}var mr=class extends kn{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:e=>e!=="borderDash"&&e!=="fill"};constructor(e){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,e&&Object.assign(this,e)}updateControlPoints(e,n){let s=this.options;if((s.tension||s.cubicInterpolationMode==="monotone")&&!s.stepped&&!this._pointsUpdated){let o=s.spanGaps?this._loop:this._fullLoop;Jv(this._points,s,e,o,n),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=t$(this,this.options.segment))}first(){let e=this.segments,n=this.points;return e.length&&n[e[0].start]}last(){let e=this.segments,n=this.points,s=e.length;return s&&n[e[s-1].end]}interpolate(e,n){let s=this.options,o=e[n],r=this.points,i=qu(this,{property:n,start:o,end:o});if(!i.length)return;let a=[],l=kM(s),c,d;for(c=0,d=i.length;ct.replace("rgb(","rgba(").replace(")",", 0.5)"));function h0(t){return Ap[t%Ap.length]}function m0(t){return R$[t%R$.length]}function IM(t,e){return t.borderColor=h0(e),t.backgroundColor=m0(e),++e}function DM(t,e){return t.backgroundColor=t.data.map(()=>h0(e++)),e}function OM(t,e){return t.backgroundColor=t.data.map(()=>m0(e++)),e}function NM(t){let e=0;return(n,s)=>{let o=t.getDatasetMeta(s).controller;o instanceof Ti?e=DM(n,e):o instanceof tc?e=OM(n,e):o&&(e=IM(n,e))}}function L$(t){let e;for(e in t)if(t[e].borderColor||t[e].backgroundColor)return!0;return!1}function BM(t){return t&&(t.borderColor||t.backgroundColor)}function FM(){return st.borderColor!=="rgba(0,0,0,0.1)"||st.backgroundColor!=="rgba(0,0,0,0.1)"}var WM={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(t,e,n){if(!n.enabled)return;let{data:{datasets:s},options:o}=t.config,{elements:r}=o,i=L$(s)||BM(o)||r&&L$(r)||FM();if(!n.forceOverride&&i)return;let a=NM(t);s.forEach(a)}};function HM(t,e,n,s,o){let r=o.samples||s;if(r>=n)return t.slice(e,e+n);let i=[],a=(n-2)/(r-2),l=0,c=e+n-1,d=e,u,p,f,g,m;for(i[l++]=t[d],u=0;uf&&(f=g,p=t[x],m=x);i[l++]=p,d=m}return i[l++]=t[c],i}function VM(t,e,n,s){let o=0,r=0,i,a,l,c,d,u,p,f,g,m,h=[],b=e+n-1,x=t[e].x,$=t[b].x-x;for(i=e;im&&(m=c,p=i),o=(r*o+a.x)/++r;else{let S=i-1;if(!Me(u)&&!Me(p)){let C=Math.min(u,p),_=Math.max(u,p);C!==f&&C!==S&&h.push({...t[C],x:o}),_!==f&&_!==S&&h.push({...t[_],x:o})}i>0&&S!==f&&h.push(t[S]),h.push(a),d=w,r=0,g=m=c,u=p=f=i}}return h}function g0(t){if(t._decimated){let e=t._data;delete t._decimated,delete t._data,Object.defineProperty(t,"data",{configurable:!0,enumerable:!0,writable:!0,value:e})}}function E$(t){t.data.datasets.forEach(e=>{g0(e)})}function jM(t,e){let n=e.length,s=0,o,{iScale:r}=t,{min:i,max:a,minDefined:l,maxDefined:c}=r.getUserBounds();return l&&(s=wt(On(e,r.axis,i).lo,0,n-1)),c?o=wt(On(e,r.axis,a).hi+1,s,n)-s:o=n-s,{start:s,count:o}}var zM={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,n)=>{if(!n.enabled){E$(t);return}let s=t.width;t.data.datasets.forEach((o,r)=>{let{_data:i,indexAxis:a}=o,l=t.getDatasetMeta(r),c=i||o.data;if(ur([a,t.options.indexAxis])==="y"||!l.controller.supportsDecimation)return;let d=t.scales[l.xAxisID];if(d.type!=="linear"&&d.type!=="time"||t.options.parsing)return;let{start:u,count:p}=jM(l,c),f=n.threshold||4*s;if(p<=f){g0(o);return}Me(i)&&(o._data=c,delete o.data,Object.defineProperty(o,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(m){this._data=m}}));let g;switch(n.algorithm){case"lttb":g=HM(c,u,p,s,n);break;case"min-max":g=VM(c,u,p,s);break;default:throw new Error(`Unsupported decimation algorithm '${n.algorithm}'`)}o._decimated=g})},destroy(t){E$(t)}};function UM(t,e,n){let s=t.segments,o=t.points,r=e.points,i=[];for(let a of s){let{start:l,end:c}=a;c=lc(l,c,o);let d=Mp(n,o[l],o[c],a.loop);if(!e.segments){i.push({source:a,target:d,start:o[l],end:o[c]});continue}let u=qu(e,d);for(let p of u){let f=Mp(n,r[p.start],r[p.end],p.loop),g=Gu(a,o,f);for(let m of g)i.push({source:m,target:p,start:{[n]:I$(d,f,"start",Math.max)},end:{[n]:I$(d,f,"end",Math.min)}})}}return i}function Mp(t,e,n,s){if(s)return;let o=e[t],r=n[t];return t==="angle"&&(o=It(o),r=It(r)),{property:t,start:o,end:r}}function KM(t,e){let{x:n=null,y:s=null}=t||{},o=e.points,r=[];return e.segments.forEach(({start:i,end:a})=>{a=lc(i,a,o);let l=o[i],c=o[a];s!==null?(r.push({x:l.x,y:s}),r.push({x:c.x,y:s})):n!==null&&(r.push({x:n,y:l.y}),r.push({x:n,y:c.y}))}),r}function lc(t,e,n){for(;e>t;e--){let s=n[e];if(!isNaN(s.x)&&!isNaN(s.y))break}return e}function I$(t,e,n,s){return t&&e?s(t[n],e[n]):t?t[n]:e?e[n]:0}function b0(t,e){let n=[],s=!1;return et(t)?(s=!0,n=t):n=KM(t,e),n.length?new mr({points:n,options:{tension:0},_loop:s,_fullLoop:s}):null}function D$(t){return t&&t.fill!==!1}function GM(t,e,n){let o=t[e].fill,r=[e],i;if(!n)return o;for(;o!==!1&&r.indexOf(o)===-1;){if(!dt(o))return o;if(i=t[o],!i)return!1;if(i.visible)return o;r.push(o),o=i.fill}return!1}function qM(t,e,n){let s=XM(t);if(Le(s))return isNaN(s.value)?!1:s;let o=parseFloat(s);return dt(o)&&Math.floor(o)===o?JM(s[0],e,o,n):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}function JM(t,e,n,s){return(t==="-"||t==="+")&&(n=e+n),n===e||n<0||n>=s?!1:n}function ZM(t,e){let n=null;return t==="start"?n=e.bottom:t==="end"?n=e.top:Le(t)?n=e.getPixelForValue(t.value):e.getBasePixel&&(n=e.getBasePixel()),n}function YM(t,e,n){let s;return t==="start"?s=n:t==="end"?s=e.options.reverse?e.min:e.max:Le(t)?s=t.value:s=e.getBaseValue(),s}function XM(t){let e=t.options,n=e.fill,s=Se(n&&n.target,n);return s===void 0&&(s=!!e.backgroundColor),s===!1||s===null?!1:s===!0?"origin":s}function QM(t){let{scale:e,index:n,line:s}=t,o=[],r=s.segments,i=s.points,a=eT(e,n);a.push(b0({x:null,y:e.bottom},s));for(let l=0;l=0;--i){let a=o[i].$filler;a&&(a.line.updateControlPoints(r,a.axis),s&&a.fill&&rp(t.ctx,a,r))}},beforeDatasetsDraw(t,e,n){if(n.drawTime!=="beforeDatasetsDraw")return;let s=t.getSortedVisibleDatasetMetas();for(let o=s.length-1;o>=0;--o){let r=s[o].$filler;D$(r)&&rp(t.ctx,r,t.chartArea)}},beforeDatasetDraw(t,e,n){let s=e.meta.$filler;!D$(s)||n.drawTime!=="beforeDatasetDraw"||rp(t.ctx,s,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}},F$=(t,e)=>{let{boxHeight:n=e,boxWidth:s=e}=t;return t.usePointStyle&&(n=Math.min(n,e),s=t.pointStyleWidth||Math.min(s,e)),{boxWidth:s,boxHeight:n,itemHeight:Math.max(e,n)}},uT=(t,e)=>t!==null&&e!==null&&t.datasetIndex===e.datasetIndex&&t.index===e.index,ic=class extends kn{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,n,s){this.maxWidth=e,this.maxHeight=n,this._margins=s,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){let e=this.options.labels||{},n=Ye(e.generateLabels,[this.chart],this)||[];e.filter&&(n=n.filter(s=>e.filter(s,this.chart.data))),e.sort&&(n=n.sort((s,o)=>e.sort(s,o,this.chart.data))),this.options.reverse&&n.reverse(),this.legendItems=n}fit(){let{options:e,ctx:n}=this;if(!e.display){this.width=this.height=0;return}let s=e.labels,o=bt(s.font),r=o.size,i=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=F$(s,r),c,d;n.font=o.string,this.isHorizontal()?(c=this.maxWidth,d=this._fitRows(i,r,a,l)+10):(d=this.maxHeight,c=this._fitCols(i,o,a,l)+10),this.width=Math.min(c,e.maxWidth||this.maxWidth),this.height=Math.min(d,e.maxHeight||this.maxHeight)}_fitRows(e,n,s,o){let{ctx:r,maxWidth:i,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],d=o+a,u=e;r.textAlign="left",r.textBaseline="middle";let p=-1,f=-d;return this.legendItems.forEach((g,m)=>{let h=s+n/2+r.measureText(g.text).width;(m===0||c[c.length-1]+h+2*a>i)&&(u+=d,c[c.length-(m>0?0:1)]=0,f+=d,p++),l[m]={left:0,top:f,row:p,width:h,height:o},c[c.length-1]+=h+a}),u}_fitCols(e,n,s,o){let{ctx:r,maxHeight:i,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],d=i-e,u=a,p=0,f=0,g=0,m=0;return this.legendItems.forEach((h,b)=>{let{itemWidth:x,itemHeight:v}=pT(s,n,r,h,o);b>0&&f+v+2*a>d&&(u+=p+a,c.push({width:p,height:f}),g+=p+a,m++,p=f=0),l[b]={left:g,top:f,col:m,width:x,height:v},p=Math.max(p,x),f+=v+a}),u+=p,c.push({width:p,height:f}),u}adjustHitBoxes(){if(!this.options.display)return;let e=this._computeTitleHeight(),{legendHitBoxes:n,options:{align:s,labels:{padding:o},rtl:r}}=this,i=ao(r,this.left,this.width);if(this.isHorizontal()){let a=0,l=Dt(s,this.left+o,this.right-this.lineWidths[a]);for(let c of n)a!==c.row&&(a=c.row,l=Dt(s,this.left+o,this.right-this.lineWidths[a])),c.top+=this.top+e+o,c.left=i.leftForLtr(i.x(l),c.width),l+=c.width+o}else{let a=0,l=Dt(s,this.top+e+o,this.bottom-this.columnSizes[a].height);for(let c of n)c.col!==a&&(a=c.col,l=Dt(s,this.top+e+o,this.bottom-this.columnSizes[a].height)),c.top=l,c.left+=this.left+o,c.left=i.leftForLtr(i.x(c.left),c.width),l+=c.height+o}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){let e=this.ctx;vi(e,this),this._draw(),$i(e)}}_draw(){let{options:e,columnSizes:n,lineWidths:s,ctx:o}=this,{align:r,labels:i}=e,a=st.color,l=ao(e.rtl,this.left,this.width),c=bt(i.font),{padding:d}=i,u=c.size,p=u/2,f;this.drawTitle(),o.textAlign=l.textAlign("left"),o.textBaseline="middle",o.lineWidth=.5,o.font=c.string;let{boxWidth:g,boxHeight:m,itemHeight:h}=F$(i,u),b=function(S,C,_){if(isNaN(g)||g<=0||isNaN(m)||m<0)return;o.save();let k=Se(_.lineWidth,1);if(o.fillStyle=Se(_.fillStyle,a),o.lineCap=Se(_.lineCap,"butt"),o.lineDashOffset=Se(_.lineDashOffset,0),o.lineJoin=Se(_.lineJoin,"miter"),o.lineWidth=k,o.strokeStyle=Se(_.strokeStyle,a),o.setLineDash(Se(_.lineDash,[])),i.usePointStyle){let A={radius:m*Math.SQRT2/2,pointStyle:_.pointStyle,rotation:_.rotation,borderWidth:k},D=l.xPlus(S,g/2),O=C+p;Nu(o,A,D,O,i.pointStyleWidth&&g)}else{let A=C+Math.max((u-m)/2,0),D=l.leftForLtr(S,g),O=Ls(_.borderRadius);o.beginPath(),Object.values(O).some(z=>z!==0)?dr(o,{x:D,y:A,w:g,h:m,radius:O}):o.rect(D,A,g,m),o.fill(),k!==0&&o.stroke()}o.restore()},x=function(S,C,_){Rs(o,_.text,S,C+h/2,c,{strikethrough:_.hidden,textAlign:l.textAlign(_.textAlign)})},v=this.isHorizontal(),$=this._computeTitleHeight();v?f={x:Dt(r,this.left+d,this.right-s[0]),y:this.top+d+$,line:0}:f={x:this.left+d,y:Dt(r,this.top+$+d,this.bottom-n[0].height),line:0},Uu(this.ctx,e.textDirection);let w=h+d;this.legendItems.forEach((S,C)=>{o.strokeStyle=S.fontColor,o.fillStyle=S.fontColor;let _=o.measureText(S.text).width,k=l.textAlign(S.textAlign||(S.textAlign=i.textAlign)),A=g+p+_,D=f.x,O=f.y;l.setWidth(this.width),v?C>0&&D+A+d>this.right&&(O=f.y+=w,f.line++,D=f.x=Dt(r,this.left+d,this.right-s[f.line])):C>0&&O+w>this.bottom&&(D=f.x=D+n[f.line].width+d,f.line++,O=f.y=Dt(r,this.top+$+d,this.bottom-n[f.line].height));let z=l.x(D);if(b(z,O,S),D=Fv(k,D+g+p,v?D+A:this.right,e.rtl),x(l.x(D),O,S),v)f.x+=A+d;else if(typeof S.text!="string"){let N=c.lineHeight;f.y+=x0(S,N)+d}else f.y+=w}),Ku(this.ctx,e.textDirection)}drawTitle(){let e=this.options,n=e.title,s=bt(n.font),o=Ot(n.padding);if(!n.display)return;let r=ao(e.rtl,this.left,this.width),i=this.ctx,a=n.position,l=s.size/2,c=o.top+l,d,u=this.left,p=this.width;if(this.isHorizontal())p=Math.max(...this.lineWidths),d=this.top+c,u=Dt(e.align,u,this.right-p);else{let g=this.columnSizes.reduce((m,h)=>Math.max(m,h.height),0);d=c+Dt(e.align,this.top,this.bottom-g-e.labels.padding-this._computeTitleHeight())}let f=Dt(a,u,u+p);i.textAlign=r.textAlign(Bl(a)),i.textBaseline="middle",i.strokeStyle=n.color,i.fillStyle=n.color,i.font=s.string,Rs(i,n.text,f,d,s)}_computeTitleHeight(){let e=this.options.title,n=bt(e.font),s=Ot(e.padding);return e.display?n.lineHeight+s.height:0}_getLegendItemAt(e,n){let s,o,r;if(Fn(e,this.left,this.right)&&Fn(n,this.top,this.bottom)){for(r=this.legendHitBoxes,s=0;sr.length>i.length?r:i)),e+n.size/2+s.measureText(o).width}function hT(t,e,n){let s=t;return typeof e.text!="string"&&(s=x0(e,n)),s}function x0(t,e){let n=t.text?t.text.length:0;return e*n}function mT(t,e){return!!((t==="mousemove"||t==="mouseout")&&(e.onHover||e.onLeave)||e.onClick&&(t==="click"||t==="mouseup"))}var gT={id:"legend",_element:ic,start(t,e,n){let s=t.legend=new ic({ctx:t.ctx,options:n,chart:t});Ft.configure(t,s,n),Ft.addBox(t,s)},stop(t){Ft.removeBox(t,t.legend),delete t.legend},beforeUpdate(t,e,n){let s=t.legend;Ft.configure(t,s,n),s.options=n},afterUpdate(t){let e=t.legend;e.buildLabels(),e.adjustHitBoxes()},afterEvent(t,e){e.replay||t.legend.handleEvent(e.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(t,e,n){let s=e.datasetIndex,o=n.chart;o.isDatasetVisible(s)?(o.hide(s),e.hidden=!0):(o.show(s),e.hidden=!1)},onHover:null,onLeave:null,labels:{color:t=>t.chart.options.color,boxWidth:40,padding:10,generateLabels(t){let e=t.data.datasets,{labels:{usePointStyle:n,pointStyle:s,textAlign:o,color:r,useBorderRadius:i,borderRadius:a}}=t.legend.options;return t._getSortedDatasetMetas().map(l=>{let c=l.controller.getStyle(n?0:void 0),d=Ot(c.borderWidth);return{text:e[l.index].label,fillStyle:c.backgroundColor,fontColor:r,hidden:!l.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(d.width+d.height)/4,strokeStyle:c.borderColor,pointStyle:s||c.pointStyle,rotation:c.rotation,textAlign:o||c.textAlign,borderRadius:i&&(a||c.borderRadius),datasetIndex:l.index}},this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}},Ri=class extends kn{constructor(e){super(),this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,n){let s=this.options;if(this.left=0,this.top=0,!s.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=e,this.height=this.bottom=n;let o=et(s.text)?s.text.length:1;this._padding=Ot(s.padding);let r=o*bt(s.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=r:this.width=r}isHorizontal(){let e=this.options.position;return e==="top"||e==="bottom"}_drawArgs(e){let{top:n,left:s,bottom:o,right:r,options:i}=this,a=i.align,l=0,c,d,u;return this.isHorizontal()?(d=Dt(a,s,r),u=n+e,c=r-s):(i.position==="left"?(d=s+e,u=Dt(a,o,n),l=He*-.5):(d=r-e,u=Dt(a,n,o),l=He*.5),c=o-n),{titleX:d,titleY:u,maxWidth:c,rotation:l}}draw(){let e=this.ctx,n=this.options;if(!n.display)return;let s=bt(n.font),r=s.lineHeight/2+this._padding.top,{titleX:i,titleY:a,maxWidth:l,rotation:c}=this._drawArgs(r);Rs(e,n.text,0,0,s,{color:n.color,maxWidth:l,rotation:c,textAlign:Bl(n.align),textBaseline:"middle",translation:[i,a]})}};function bT(t,e){let n=new Ri({ctx:t.ctx,options:e,chart:t});Ft.configure(t,n,e),Ft.addBox(t,n),t.titleBlock=n}var xT={id:"title",_element:Ri,start(t,e,n){bT(t,n)},stop(t){let e=t.titleBlock;Ft.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,n){let s=t.titleBlock;Ft.configure(t,s,n),s.options=n},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}},Jl=new WeakMap,yT={id:"subtitle",start(t,e,n){let s=new Ri({ctx:t.ctx,options:n,chart:t});Ft.configure(t,s,n),Ft.addBox(t,s),Jl.set(t,s)},stop(t){Ft.removeBox(t,Jl.get(t)),Jl.delete(t)},beforeUpdate(t,e,n){let s=Jl.get(t);Ft.configure(t,s,n),s.options=n},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}},Mi={average(t){if(!t.length)return!1;let e,n,s=new Set,o=0,r=0;for(e=0,n=t.length;ea+l)/s.size,y:o/r}},nearest(t,e){if(!t.length)return!1;let n=e.x,s=e.y,o=Number.POSITIVE_INFINITY,r,i,a;for(r=0,i=t.length;rMath.max(Math.min(t,n),e);function fi(t){return As(mi(t*2.55),0,255)}function Ms(t){return As(mi(t*255),0,255)}function os(t){return As(mi(t/2.55)/100,0,1)}function dv(t){return As(mi(t*100),0,100)}var un={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},mu=[..."0123456789ABCDEF"],$_=t=>mu[t&15],w_=t=>mu[(t&240)>>4]+mu[t&15],Cl=t=>(t&240)>>4===(t&15),k_=t=>Cl(t.r)&&Cl(t.g)&&Cl(t.b)&&Cl(t.a);function S_(t){var e=t.length,n;return t[0]==="#"&&(e===4||e===5?n={r:255&un[t[1]]*17,g:255&un[t[2]]*17,b:255&un[t[3]]*17,a:e===5?un[t[4]]*17:255}:(e===7||e===9)&&(n={r:un[t[1]]<<4|un[t[2]],g:un[t[3]]<<4|un[t[4]],b:un[t[5]]<<4|un[t[6]],a:e===9?un[t[7]]<<4|un[t[8]]:255})),n}var C_=(t,e)=>t<255?e(t):"";function __(t){var e=k_(t)?$_:w_;return t?"#"+e(t.r)+e(t.g)+e(t.b)+C_(t.a,e):void 0}var A_=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function hv(t,e,n){let s=e*Math.min(n,1-n),o=(r,i=(r+t/30)%12)=>n-s*Math.max(Math.min(i-3,9-i,1),-1);return[o(0),o(8),o(4)]}function M_(t,e,n){let s=(o,r=(o+t/60)%6)=>n-n*e*Math.max(Math.min(r,4-r,1),0);return[s(5),s(3),s(1)]}function T_(t,e,n){let s=hv(t,1,.5),o;for(e+n>1&&(o=1/(e+n),e*=o,n*=o),o=0;o<3;o++)s[o]*=1-e-n,s[o]+=e;return s}function P_(t,e,n,s,o){return t===o?(e-n)/s+(e.5?d/(2-r-i):d/(r+i),l=P_(n,s,o,d,r),l=l*60+.5),[l|0,c||0,a]}function bu(t,e,n,s){return(Array.isArray(e)?t(e[0],e[1],e[2]):t(e,n,s)).map(Ms)}function xu(t,e,n){return bu(hv,t,e,n)}function R_(t,e,n){return bu(T_,t,e,n)}function L_(t,e,n){return bu(M_,t,e,n)}function mv(t){return(t%360+360)%360}function E_(t){let e=A_.exec(t),n=255,s;if(!e)return;e[5]!==s&&(n=e[6]?fi(+e[5]):Ms(+e[5]));let o=mv(+e[2]),r=+e[3]/100,i=+e[4]/100;return e[1]==="hwb"?s=R_(o,r,i):e[1]==="hsv"?s=L_(o,r,i):s=xu(o,r,i),{r:s[0],g:s[1],b:s[2],a:n}}function I_(t,e){var n=gu(t);n[0]=mv(n[0]+e),n=xu(n),t.r=n[0],t.g=n[1],t.b=n[2]}function D_(t){if(!t)return;let e=gu(t),n=e[0],s=dv(e[1]),o=dv(e[2]);return t.a<255?`hsla(${n}, ${s}%, ${o}%, ${os(t.a)})`:`hsl(${n}, ${s}%, ${o}%)`}var uv={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},pv={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};function N_(){let t={},e=Object.keys(pv),n=Object.keys(uv),s,o,r,i,a;for(s=0;s>16&255,r>>8&255,r&255]}return t}var _l;function O_(t){_l||(_l=N_(),_l.transparent=[0,0,0,0]);let e=_l[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:e.length===4?e[3]:255}}var B_=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function F_(t){let e=B_.exec(t),n=255,s,o,r;if(e){if(e[7]!==s){let i=+e[7];n=e[8]?fi(i):As(i*255,0,255)}return s=+e[1],o=+e[3],r=+e[5],s=255&(e[2]?fi(s):As(s,0,255)),o=255&(e[4]?fi(o):As(o,0,255)),r=255&(e[6]?fi(r):As(r,0,255)),{r:s,g:o,b:r,a:n}}}function W_(t){return t&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${os(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`)}var hu=t=>t<=.0031308?t*12.92:Math.pow(t,1/2.4)*1.055-.055,tr=t=>t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4);function H_(t,e,n){let s=tr(os(t.r)),o=tr(os(t.g)),r=tr(os(t.b));return{r:Ms(hu(s+n*(tr(os(e.r))-s))),g:Ms(hu(o+n*(tr(os(e.g))-o))),b:Ms(hu(r+n*(tr(os(e.b))-r))),a:t.a+n*(e.a-t.a)}}function Al(t,e,n){if(t){let s=gu(t);s[e]=Math.max(0,Math.min(s[e]+s[e]*n,e===0?360:1)),s=xu(s),t.r=s[0],t.g=s[1],t.b=s[2]}}function gv(t,e){return t&&Object.assign(e||{},t)}function fv(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=Ms(t[3]))):(e=gv(t,{r:0,g:0,b:0,a:1}),e.a=Ms(e.a)),e}function V_(t){return t.charAt(0)==="r"?F_(t):E_(t)}var hi=class t{constructor(e){if(e instanceof t)return e;let n=typeof e,s;n==="object"?s=fv(e):n==="string"&&(s=S_(e)||O_(e)||V_(e)),this._rgb=s,this._valid=!!s}get valid(){return this._valid}get rgb(){var e=gv(this._rgb);return e&&(e.a=os(e.a)),e}set rgb(e){this._rgb=fv(e)}rgbString(){return this._valid?W_(this._rgb):void 0}hexString(){return this._valid?__(this._rgb):void 0}hslString(){return this._valid?D_(this._rgb):void 0}mix(e,n){if(e){let s=this.rgb,o=e.rgb,r,i=n===r?.5:n,a=2*i-1,l=s.a-o.a,c=((a*l===-1?a:(a+l)/(1+a*l))+1)/2;r=1-c,s.r=255&c*s.r+r*o.r+.5,s.g=255&c*s.g+r*o.g+.5,s.b=255&c*s.b+r*o.b+.5,s.a=i*s.a+(1-i)*o.a,this.rgb=s}return this}interpolate(e,n){return e&&(this._rgb=H_(this._rgb,e._rgb,n)),this}clone(){return new t(this.rgb)}alpha(e){return this._rgb.a=Ms(e),this}clearer(e){let n=this._rgb;return n.a*=1-e,this}greyscale(){let e=this._rgb,n=mi(e.r*.3+e.g*.59+e.b*.11);return e.r=e.g=e.b=n,this}opaquer(e){let n=this._rgb;return n.a*=1+e,this}negate(){let e=this._rgb;return e.r=255-e.r,e.g=255-e.g,e.b=255-e.b,this}lighten(e){return Al(this._rgb,2,e),this}darken(e){return Al(this._rgb,2,-e),this}saturate(e){return Al(this._rgb,1,e),this}desaturate(e){return Al(this._rgb,1,-e),this}rotate(e){return I_(this._rgb,e),this}};function Bn(){}var Av=(()=>{let t=0;return()=>t++})();function Me(t){return t==null}function et(t){if(Array.isArray&&Array.isArray(t))return!0;let e=Object.prototype.toString.call(t);return e.slice(0,7)==="[object"&&e.slice(-6)==="Array]"}function Le(t){return t!==null&&Object.prototype.toString.call(t)==="[object Object]"}function dt(t){return(typeof t=="number"||t instanceof Number)&&isFinite(+t)}function Yt(t,e){return dt(t)?t:e}function Se(t,e){return typeof t>"u"?e:t}var Mv=(t,e)=>typeof t=="string"&&t.endsWith("%")?parseFloat(t)/100:+t/e,wu=(t,e)=>typeof t=="string"&&t.endsWith("%")?parseFloat(t)/100*e:+t;function Ye(t,e,n){if(t&&typeof t.call=="function")return t.apply(n,e)}function Ke(t,e,n,s){let o,r,i;if(et(t))if(r=t.length,s)for(o=r-1;o>=0;o--)e.call(n,t[o],o);else for(o=0;ot,x:t=>t.x,y:t=>t.y};function U_(t){let e=t.split("."),n=[],s="";for(let o of e)s+=o,s.endsWith("\\")?s=s.slice(0,-1)+".":(n.push(s),s="");return n}function K_(t){let e=U_(t);return n=>{for(let s of e){if(s==="")break;n=n&&n[s]}return n}}function as(t,e){return(bv[e]||(bv[e]=K_(e)))(t)}function Dl(t){return t.charAt(0).toUpperCase()+t.slice(1)}var ir=t=>typeof t<"u",rs=t=>typeof t=="function",ku=(t,e)=>{if(t.size!==e.size)return!1;for(let n of t)if(!e.has(n))return!1;return!0};function Pv(t){return t.type==="mouseup"||t.type==="click"||t.type==="contextmenu"}var He=Math.PI,tt=2*He,G_=tt+He,Ll=Number.POSITIVE_INFINITY,q_=He/180,ft=He/2,oo=He/4,xv=He*2/3,is=Math.log10,wn=Math.sign;function ar(t,e,n){return Math.abs(t-e)o-r).pop(),e}function J_(t){return typeof t=="symbol"||typeof t=="object"&&t!==null&&!(Symbol.toPrimitive in t||"toString"in t||"valueOf"in t)}function ao(t){return!J_(t)&&!isNaN(parseFloat(t))&&isFinite(t)}function Lv(t,e){let n=Math.round(t);return n-e<=t&&n+e>=t}function Cu(t,e,n){let s,o,r;for(s=0,o=t.length;sl&&c=Math.min(e,n)-s&&t<=Math.max(e,n)+s}function Ol(t,e,n){n=n||(i=>t[i]1;)r=o+s>>1,n(r)?o=r:s=r;return{lo:o,hi:s}}var Nn=(t,e,n,s)=>Ol(t,n,s?o=>{let r=t[o][e];return rt[o][e]Ol(t,n,s=>t[s][e]>=n);function Dv(t,e,n){let s=0,o=t.length;for(;ss&&t[o-1]>n;)o--;return s>0||o{let s="_onData"+Dl(n),o=t[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!1,value(...r){let i=o.apply(this,r);return t._chartjs.listeners.forEach(a=>{typeof a[s]=="function"&&a[s](...r)}),i}})})}function Mu(t,e){let n=t._chartjs;if(!n)return;let s=n.listeners,o=s.indexOf(e);o!==-1&&s.splice(o,1),!(s.length>0)&&(Nv.forEach(r=>{delete t[r]}),delete t._chartjs)}function Tu(t){let e=new Set(t);return e.size===t.length?t:Array.from(e)}var Pu=(function(){return typeof window>"u"?function(t){return t()}:window.requestAnimationFrame})();function Ru(t,e){let n=[],s=!1;return function(...o){n=o,s||(s=!0,Pu.call(window,()=>{s=!1,t.apply(e,n)}))}}function Bv(t,e){let n;return function(...s){return e?(clearTimeout(n),n=setTimeout(t,e,s)):t.apply(this,s),e}}var Bl=t=>t==="start"?"left":t==="end"?"right":"center",Dt=(t,e,n)=>t==="start"?e:t==="end"?n:(e+n)/2,Fv=(t,e,n,s)=>t===(s?"left":"right")?n:t==="center"?(e+n)/2:e;function Lu(t,e,n){let s=e.length,o=0,r=s;if(t._sorted){let{iScale:i,vScale:a,_parsed:l}=t,c=t.dataset&&t.dataset.options?t.dataset.options.spanGaps:null,d=i.axis,{min:u,max:p,minDefined:f,maxDefined:g}=i.getUserBounds();if(f){if(o=Math.min(Nn(l,d,u).lo,n?s:Nn(e,d,i.getPixelForValue(u)).lo),c){let m=l.slice(0,o+1).reverse().findIndex(h=>!Me(h[a.axis]));o-=Math.max(0,m)}o=wt(o,0,s-1)}if(g){let m=Math.max(Nn(l,i.axis,p,!0).hi+1,n?0:Nn(e,d,i.getPixelForValue(p),!0).hi+1);if(c){let h=l.slice(m-1).findIndex(x=>!Me(x[a.axis]));m+=Math.max(0,h)}r=wt(m,o,s)-o}else r=s-o}return{start:o,count:r}}function Eu(t){let{xScale:e,yScale:n,_scaleRanges:s}=t,o={xmin:e.min,xmax:e.max,ymin:n.min,ymax:n.max};if(!s)return t._scaleRanges=o,!0;let r=s.xmin!==e.min||s.xmax!==e.max||s.ymin!==n.min||s.ymax!==n.max;return Object.assign(s,o),r}var Ml=t=>t===0||t===1,yv=(t,e,n)=>-(Math.pow(2,10*(t-=1))*Math.sin((t-e)*tt/n)),vv=(t,e,n)=>Math.pow(2,-10*t)*Math.sin((t-e)*tt/n)+1,nr={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>-Math.cos(t*ft)+1,easeOutSine:t=>Math.sin(t*ft),easeInOutSine:t=>-.5*(Math.cos(He*t)-1),easeInExpo:t=>t===0?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>t===1?1:-Math.pow(2,-10*t)+1,easeInOutExpo:t=>Ml(t)?t:t<.5?.5*Math.pow(2,10*(t*2-1)):.5*(-Math.pow(2,-10*(t*2-1))+2),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>Ml(t)?t:yv(t,.075,.3),easeOutElastic:t=>Ml(t)?t:vv(t,.075,.3),easeInOutElastic(t){return Ml(t)?t:t<.5?.5*yv(t*2,.1125,.45):.5+.5*vv(t*2-1,.1125,.45)},easeInBack(t){return t*t*((1.70158+1)*t-1.70158)},easeOutBack(t){return(t-=1)*t*((1.70158+1)*t+1.70158)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?.5*(t*t*(((e*=1.525)+1)*t-e)):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:t=>1-nr.easeOutBounce(1-t),easeOutBounce(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},easeInOutBounce:t=>t<.5?nr.easeInBounce(t*2)*.5:nr.easeOutBounce(t*2-1)*.5+.5};function Iu(t){if(t&&typeof t=="object"){let e=t.toString();return e==="[object CanvasPattern]"||e==="[object CanvasGradient]"}return!1}function Du(t){return Iu(t)?t:new hi(t)}function yu(t){return Iu(t)?t:new hi(t).saturate(.5).darken(.1).hexString()}var Y_=["x","y","borderWidth","radius","tension"],X_=["color","borderColor","backgroundColor"];function Q_(t){t.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),t.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:e=>e!=="onProgress"&&e!=="onComplete"&&e!=="fn"}),t.set("animations",{colors:{type:"color",properties:X_},numbers:{type:"number",properties:Y_}}),t.describe("animations",{_fallback:"animation"}),t.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:e=>e|0}}}})}function e5(t){t.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}var $v=new Map;function t5(t,e){e=e||{};let n=t+JSON.stringify(e),s=$v.get(n);return s||(s=new Intl.NumberFormat(t,e),$v.set(n,s)),s}function cr(t,e,n){return t5(e,n).format(t)}var Wv={values(t){return et(t)?t:""+t},numeric(t,e,n){if(t===0)return"0";let s=this.chart.options.locale,o,r=t;if(n.length>1){let c=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(c<1e-4||c>1e15)&&(o="scientific"),r=n5(t,n)}let i=is(Math.abs(r)),a=isNaN(i)?1:Math.max(Math.min(-1*Math.floor(i),20),0),l={notation:o,minimumFractionDigits:a,maximumFractionDigits:a};return Object.assign(l,this.options.ticks.format),cr(t,s,l)},logarithmic(t,e,n){if(t===0)return"0";let s=n[e].significand||t/Math.pow(10,Math.floor(is(t)));return[1,2,3,5,10,15].includes(s)||e>.8*n.length?Wv.numeric.call(this,t,e,n):""}};function n5(t,e){let n=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;return Math.abs(n)>=1&&t!==Math.floor(t)&&(n=t-Math.floor(t)),n}var yi={formatters:Wv};function s5(t){t.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(e,n)=>n.lineWidth,tickColor:(e,n)=>n.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:yi.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),t.route("scale.ticks","color","","color"),t.route("scale.grid","color","","borderColor"),t.route("scale.border","color","","borderColor"),t.route("scale.title","color","","color"),t.describe("scale",{_fallback:!1,_scriptable:e=>!e.startsWith("before")&&!e.startsWith("after")&&e!=="callback"&&e!=="parser",_indexable:e=>e!=="borderDash"&&e!=="tickBorderDash"&&e!=="dash"}),t.describe("scales",{_fallback:"scale"}),t.describe("scale.ticks",{_scriptable:e=>e!=="backdropPadding"&&e!=="callback",_indexable:e=>e!=="backdropPadding"})}var Rs=Object.create(null),Fl=Object.create(null);function gi(t,e){if(!e)return t;let n=e.split(".");for(let s=0,o=n.length;ss.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(s,o)=>yu(o.backgroundColor),this.hoverBorderColor=(s,o)=>yu(o.borderColor),this.hoverColor=(s,o)=>yu(o.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(e),this.apply(n)}set(e,n){return vu(this,e,n)}get(e){return gi(this,e)}describe(e,n){return vu(Fl,e,n)}override(e,n){return vu(Rs,e,n)}route(e,n,s,o){let r=gi(this,e),i=gi(this,s),a="_"+n;Object.defineProperties(r,{[a]:{value:r[n],writable:!0},[n]:{enumerable:!0,get(){let l=this[a],c=i[o];return Le(l)?Object.assign({},c,l):Se(l,c)},set(l){this[a]=l}}})}apply(e){e.forEach(n=>n(this))}},st=new $u({_scriptable:t=>!t.startsWith("on"),_indexable:t=>t!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[Q_,e5,s5]);function o5(t){return!t||Me(t.size)||Me(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}function bi(t,e,n,s,o){let r=e[o];return r||(r=e[o]=t.measureText(o).width,n.push(o)),r>s&&(s=r),s}function Hv(t,e,n,s){s=s||{};let o=s.data=s.data||{},r=s.garbageCollect=s.garbageCollect||[];s.font!==e&&(o=s.data={},r=s.garbageCollect=[],s.font=e),t.save(),t.font=e;let i=0,a=n.length,l,c,d,u,p;for(l=0;ln.length){for(l=0;l0&&t.stroke()}}function On(t,e,n){return n=n||.5,!e||t&&t.x>e.left-n&&t.xe.top-n&&t.y0&&r.strokeColor!=="",l,c;for(t.save(),t.font=o.string,r5(t,r),l=0;l+t||0;function Hl(t,e){let n={},s=Le(e),o=s?Object.keys(e):e,r=Le(t)?s?i=>Se(t[i],t[e[i]]):i=>t[i]:()=>t;for(let i of o)n[i]=u5(r(i));return n}function Bu(t){return Hl(t,{top:"y",right:"x",bottom:"y",left:"x"})}function Is(t){return Hl(t,["topLeft","topRight","bottomLeft","bottomRight"])}function Nt(t){let e=Bu(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function bt(t,e){t=t||{},e=e||st.font;let n=Se(t.size,e.size);typeof n=="string"&&(n=parseInt(n,10));let s=Se(t.style,e.style);s&&!(""+s).match(c5)&&(console.warn('Invalid font style specified: "'+s+'"'),s=void 0);let o={family:Se(t.family,e.family),lineHeight:d5(Se(t.lineHeight,e.lineHeight),n),size:n,style:s,weight:Se(t.weight,e.weight),string:""};return o.string=o5(o),o}function ur(t,e,n,s){let o=!0,r,i,a;for(r=0,i=t.length;rn&&a===0?0:a+l;return{min:i(s,-Math.abs(r)),max:i(o,r)}}function ls(t,e){return Object.assign(Object.create(t),e)}function Vl(t,e=[""],n,s,o=()=>t[0]){let r=n||t;typeof s>"u"&&(s=Gv("_fallback",t));let i={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:r,_fallback:s,_getTarget:o,override:a=>Vl([a,...t],e,r,s)};return new Proxy(i,{deleteProperty(a,l){return delete a[l],delete a._keys,delete t[0][l],!0},get(a,l){return Uv(a,l,()=>y5(l,e,t,a))},getOwnPropertyDescriptor(a,l){return Reflect.getOwnPropertyDescriptor(a._scopes[0],l)},getPrototypeOf(){return Reflect.getPrototypeOf(t[0])},has(a,l){return kv(a).includes(l)},ownKeys(a){return kv(a)},set(a,l,c){let d=a._storage||(a._storage=o());return a[l]=d[l]=c,delete a._keys,!0}})}function io(t,e,n,s){let o={_cacheable:!1,_proxy:t,_context:e,_subProxy:n,_stack:new Set,_descriptors:Fu(t,s),setContext:r=>io(t,r,n,s),override:r=>io(t.override(r),e,n,s)};return new Proxy(o,{deleteProperty(r,i){return delete r[i],delete t[i],!0},get(r,i,a){return Uv(r,i,()=>f5(r,i,a))},getOwnPropertyDescriptor(r,i){return r._descriptors.allKeys?Reflect.has(t,i)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,i)},getPrototypeOf(){return Reflect.getPrototypeOf(t)},has(r,i){return Reflect.has(t,i)},ownKeys(){return Reflect.ownKeys(t)},set(r,i,a){return t[i]=a,delete r[i],!0}})}function Fu(t,e={scriptable:!0,indexable:!0}){let{_scriptable:n=e.scriptable,_indexable:s=e.indexable,_allKeys:o=e.allKeys}=t;return{allKeys:o,scriptable:n,indexable:s,isScriptable:rs(n)?n:()=>n,isIndexable:rs(s)?s:()=>s}}var p5=(t,e)=>t?t+Dl(e):e,Wu=(t,e)=>Le(e)&&t!=="adapters"&&(Object.getPrototypeOf(e)===null||e.constructor===Object);function Uv(t,e,n){if(Object.prototype.hasOwnProperty.call(t,e)||e==="constructor")return t[e];let s=n();return t[e]=s,s}function f5(t,e,n){let{_proxy:s,_context:o,_subProxy:r,_descriptors:i}=t,a=s[e];return rs(a)&&i.isScriptable(e)&&(a=h5(e,a,t,n)),et(a)&&a.length&&(a=m5(e,a,t,i.isIndexable)),Wu(e,a)&&(a=io(a,o,r&&r[e],i)),a}function h5(t,e,n,s){let{_proxy:o,_context:r,_subProxy:i,_stack:a}=n;if(a.has(t))throw new Error("Recursion detected: "+Array.from(a).join("->")+"->"+t);a.add(t);let l=e(r,i||s);return a.delete(t),Wu(t,l)&&(l=Hu(o._scopes,o,t,l)),l}function m5(t,e,n,s){let{_proxy:o,_context:r,_subProxy:i,_descriptors:a}=n;if(typeof r.index<"u"&&s(t))return e[r.index%e.length];if(Le(e[0])){let l=e,c=o._scopes.filter(d=>d!==l);e=[];for(let d of l){let u=Hu(c,o,t,d);e.push(io(u,r,i&&i[t],a))}}return e}function Kv(t,e,n){return rs(t)?t(e,n):t}var g5=(t,e)=>t===!0?e:typeof t=="string"?as(e,t):void 0;function b5(t,e,n,s,o){for(let r of e){let i=g5(n,r);if(i){t.add(i);let a=Kv(i._fallback,n,o);if(typeof a<"u"&&a!==n&&a!==s)return a}else if(i===!1&&typeof s<"u"&&n!==s)return null}return!1}function Hu(t,e,n,s){let o=e._rootScopes,r=Kv(e._fallback,n,s),i=[...t,...o],a=new Set;a.add(s);let l=wv(a,i,n,r||n,s);return l===null||typeof r<"u"&&r!==n&&(l=wv(a,i,r,l,s),l===null)?!1:Vl(Array.from(a),[""],o,r,()=>x5(e,n,s))}function wv(t,e,n,s,o){for(;n;)n=b5(t,e,n,s,o);return n}function x5(t,e,n){let s=t._getTarget();e in s||(s[e]={});let o=s[e];return et(o)&&Le(n)?n:o||{}}function y5(t,e,n,s){let o;for(let r of e)if(o=Gv(p5(r,t),n),typeof o<"u")return Wu(t,o)?Hu(n,s,t,o):o}function Gv(t,e){for(let n of e){if(!n)continue;let s=n[t];if(typeof s<"u")return s}}function kv(t){let e=t._keys;return e||(e=t._keys=v5(t._scopes)),e}function v5(t){let e=new Set;for(let n of t)for(let s of Object.keys(n).filter(o=>!o.startsWith("_")))e.add(s);return Array.from(e)}function Vu(t,e,n,s){let{iScale:o}=t,{key:r="r"}=this._parsing,i=new Array(s),a,l,c,d;for(a=0,l=s;aet==="x"?"y":"x";function w5(t,e,n,s){let o=t.skip?e:t,r=e,i=n.skip?e:n,a=El(r,o),l=El(i,r),c=a/(a+l),d=l/(a+l);c=isNaN(c)?0:c,d=isNaN(d)?0:d;let u=s*c,p=s*d;return{previous:{x:r.x-u*(i.x-o.x),y:r.y-u*(i.y-o.y)},next:{x:r.x+p*(i.x-o.x),y:r.y+p*(i.y-o.y)}}}function k5(t,e,n){let s=t.length,o,r,i,a,l,c=or(t,0);for(let d=0;d!c.skip)),e.cubicInterpolationMode==="monotone")C5(t,o);else{let c=s?t[t.length-1]:t[0];for(r=0,i=t.length;rt.ownerDocument.defaultView.getComputedStyle(t,null);function A5(t,e){return Ul(t).getPropertyValue(e)}var M5=["top","right","bottom","left"];function ro(t,e,n){let s={};n=n?"-"+n:"";for(let o=0;o<4;o++){let r=M5[o];s[r]=parseFloat(t[e+"-"+r+n])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}var T5=(t,e,n)=>(t>0||e>0)&&(!n||!n.shadowRoot);function P5(t,e){let n=t.touches,s=n&&n.length?n[0]:t,{offsetX:o,offsetY:r}=s,i=!1,a,l;if(T5(o,r,t.target))a=o,l=r;else{let c=e.getBoundingClientRect();a=s.clientX-c.left,l=s.clientY-c.top,i=!0}return{x:a,y:l,box:i}}function Ds(t,e){if("native"in t)return t;let{canvas:n,currentDevicePixelRatio:s}=e,o=Ul(n),r=o.boxSizing==="border-box",i=ro(o,"padding"),a=ro(o,"border","width"),{x:l,y:c,box:d}=P5(t,n),u=i.left+(d&&a.left),p=i.top+(d&&a.top),{width:f,height:g}=e;return r&&(f-=i.width+a.width,g-=i.height+a.height),{x:Math.round((l-u)/f*n.width/s),y:Math.round((c-p)/g*n.height/s)}}function R5(t,e,n){let s,o;if(e===void 0||n===void 0){let r=t&&zl(t);if(!r)e=t.clientWidth,n=t.clientHeight;else{let i=r.getBoundingClientRect(),a=Ul(r),l=ro(a,"border","width"),c=ro(a,"padding");e=i.width-c.width-l.width,n=i.height-c.height-l.height,s=Il(a.maxWidth,r,"clientWidth"),o=Il(a.maxHeight,r,"clientHeight")}}return{width:e,height:n,maxWidth:s||Ll,maxHeight:o||Ll}}var Ps=t=>Math.round(t*10)/10;function Zv(t,e,n,s){let o=Ul(t),r=ro(o,"margin"),i=Il(o.maxWidth,t,"clientWidth")||Ll,a=Il(o.maxHeight,t,"clientHeight")||Ll,l=R5(t,e,n),{width:c,height:d}=l;if(o.boxSizing==="content-box"){let p=ro(o,"border","width"),f=ro(o,"padding");c-=f.width+p.width,d-=f.height+p.height}return c=Math.max(0,c-r.width),d=Math.max(0,s?c/s:d-r.height),c=Ps(Math.min(c,i,l.maxWidth)),d=Ps(Math.min(d,a,l.maxHeight)),c&&!d&&(d=Ps(c/2)),(e!==void 0||n!==void 0)&&s&&l.height&&d>l.height&&(d=l.height,c=Ps(Math.floor(d*s))),{width:c,height:d}}function ju(t,e,n){let s=e||1,o=Ps(t.height*s),r=Ps(t.width*s);t.height=Ps(t.height),t.width=Ps(t.width);let i=t.canvas;return i.style&&(n||!i.style.height&&!i.style.width)&&(i.style.height=`${t.height}px`,i.style.width=`${t.width}px`),t.currentDevicePixelRatio!==s||i.height!==o||i.width!==r?(t.currentDevicePixelRatio=s,i.height=o,i.width=r,t.ctx.setTransform(s,0,0,s,0,0),!0):!1}var Yv=(function(){let t=!1;try{let e={get passive(){return t=!0,!1}};jl()&&(window.addEventListener("test",null,e),window.removeEventListener("test",null,e))}catch{}return t})();function zu(t,e){let n=A5(t,e),s=n&&n.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function Ts(t,e,n,s){return{x:t.x+n*(e.x-t.x),y:t.y+n*(e.y-t.y)}}function Xv(t,e,n,s){return{x:t.x+n*(e.x-t.x),y:s==="middle"?n<.5?t.y:e.y:s==="after"?n<1?t.y:e.y:n>0?e.y:t.y}}function Qv(t,e,n,s){let o={x:t.cp2x,y:t.cp2y},r={x:e.cp1x,y:e.cp1y},i=Ts(t,o,n),a=Ts(o,r,n),l=Ts(r,e,n),c=Ts(i,a,n),d=Ts(a,l,n);return Ts(c,d,n)}var L5=function(t,e){return{x(n){return t+t+e-n},setWidth(n){e=n},textAlign(n){return n==="center"?n:n==="right"?"left":"right"},xPlus(n,s){return n-s},leftForLtr(n,s){return n-s}}},E5=function(){return{x(t){return t},setWidth(t){},textAlign(t){return t},xPlus(t,e){return t+e},leftForLtr(t,e){return t}}};function lo(t,e,n){return t?L5(e,n):E5()}function Uu(t,e){let n,s;(e==="ltr"||e==="rtl")&&(n=t.canvas.style,s=[n.getPropertyValue("direction"),n.getPropertyPriority("direction")],n.setProperty("direction",e,"important"),t.prevTextDirection=s)}function Ku(t,e){e!==void 0&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function e$(t){return t==="angle"?{between:lr,compare:Z_,normalize:It}:{between:Fn,compare:(e,n)=>e-n,normalize:e=>e}}function Sv({start:t,end:e,count:n,loop:s,style:o}){return{start:t%n,end:e%n,loop:s&&(e-t+1)%n===0,style:o}}function I5(t,e,n){let{property:s,start:o,end:r}=n,{between:i,normalize:a}=e$(s),l=e.length,{start:c,end:d,loop:u}=t,p,f;if(u){for(c+=l,d+=l,p=0,f=l;pl(o,v,x)&&a(o,v)!==0,w=()=>a(r,x)===0||l(r,v,x),S=()=>m||$(),C=()=>!m||w();for(let _=d,k=d;_<=u;++_)b=e[_%i],!b.skip&&(x=c(b[s]),x!==v&&(m=l(x,o,r),h===null&&S()&&(h=a(x,o)===0?_:k),h!==null&&C()&&(g.push(Sv({start:h,end:_,loop:p,count:i,style:f})),h=null),k=_,v=x));return h!==null&&g.push(Sv({start:h,end:u,loop:p,count:i,style:f})),g}function qu(t,e){let n=[],s=t.segments;for(let o=0;oo&&t[r%e].skip;)r--;return r%=e,{start:o,end:r}}function N5(t,e,n,s){let o=t.length,r=[],i=e,a=t[e],l;for(l=e+1;l<=n;++l){let c=t[l%o];c.skip||c.stop?a.skip||(s=!1,r.push({start:e%o,end:(l-1)%o,loop:s}),e=i=c.stop?l:null):(i=l,a.skip&&(e=l)),a=c}return i!==null&&r.push({start:e%o,end:i%o,loop:s}),r}function t$(t,e){let n=t.points,s=t.options.spanGaps,o=n.length;if(!o)return[];let r=!!t._loop,{start:i,end:a}=D5(n,o,r,s);if(s===!0)return Cv(t,[{start:i,end:a,loop:r}],n,e);let l=aa({chart:e,initial:n.initial,numSteps:i,currentStep:Math.min(s-n.start,i)}))}_refresh(){this._request||(this._running=!0,this._request=Pu.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(e=Date.now()){let n=0;this._charts.forEach((s,o)=>{if(!s.running||!s.items.length)return;let r=s.items,i=r.length-1,a=!1,l;for(;i>=0;--i)l=r[i],l._active?(l._total>s.duration&&(s.duration=l._total),l.tick(e),a=!0):(r[i]=r[r.length-1],r.pop());a&&(o.draw(),this._notify(o,s,e,"progress")),r.length||(s.running=!1,this._notify(o,s,e,"complete"),s.initial=!1),n+=r.length}),this._lastDate=e,n===0&&(this._running=!1)}_getAnims(e){let n=this._charts,s=n.get(e);return s||(s={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},n.set(e,s)),s}listen(e,n,s){this._getAnims(e).listeners[n].push(s)}add(e,n){!n||!n.length||this._getAnims(e).items.push(...n)}has(e){return this._getAnims(e).items.length>0}start(e){let n=this._charts.get(e);n&&(n.running=!0,n.start=Date.now(),n.duration=n.items.reduce((s,o)=>Math.max(s,o._duration),0),this._refresh())}running(e){if(!this._running)return!1;let n=this._charts.get(e);return!(!n||!n.running||!n.items.length)}stop(e){let n=this._charts.get(e);if(!n||!n.items.length)return;let s=n.items,o=s.length-1;for(;o>=0;--o)s[o].cancel();n.items=[],this._notify(e,n,Date.now(),"complete")}remove(e){return this._charts.delete(e)}},cs=new ap,n$="transparent",W5={boolean(t,e,n){return n>.5?e:t},color(t,e,n){let s=Du(t||n$),o=s.valid&&Du(e||n$);return o&&o.valid?o.mix(s,n).hexString():e},number(t,e,n){return t+(e-t)*n}},lp=class{constructor(e,n,s,o){let r=n[s];o=ur([e.to,o,r,e.from]);let i=ur([e.from,r,o]);this._active=!0,this._fn=e.fn||W5[e.type||typeof i],this._easing=nr[e.easing]||nr.linear,this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=this._total=Math.floor(e.duration),this._loop=!!e.loop,this._target=n,this._prop=s,this._from=i,this._to=o,this._promises=void 0}active(){return this._active}update(e,n,s){if(this._active){this._notify(!1);let o=this._target[this._prop],r=s-this._start,i=this._duration-r;this._start=s,this._duration=Math.floor(Math.max(i,e.duration)),this._total+=r,this._loop=!!e.loop,this._to=ur([e.to,n,o,e.from]),this._from=ur([e.from,o,n])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(e){let n=e-this._start,s=this._duration,o=this._prop,r=this._from,i=this._loop,a=this._to,l;if(this._active=r!==a&&(i||n1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[o]=this._fn(r,a,l)}wait(){let e=this._promises||(this._promises=[]);return new Promise((n,s)=>{e.push({res:n,rej:s})})}_notify(e){let n=e?"res":"rej",s=this._promises||[];for(let o=0;o{let r=e[o];if(!Le(r))return;let i={};for(let a of n)i[a]=r[a];(et(r.properties)&&r.properties||[o]).forEach(a=>{(a===o||!s.has(a))&&s.set(a,i)})})}_animateOptions(e,n){let s=n.options,o=V5(e,s);if(!o)return[];let r=this._createAnimations(o,s);return s.$shared&&H5(e.options.$animations,s).then(()=>{e.options=s},()=>{}),r}_createAnimations(e,n){let s=this._properties,o=[],r=e.$animations||(e.$animations={}),i=Object.keys(n),a=Date.now(),l;for(l=i.length-1;l>=0;--l){let c=i[l];if(c.charAt(0)==="$")continue;if(c==="options"){o.push(...this._animateOptions(e,n));continue}let d=n[c],u=r[c],p=s.get(c);if(u)if(p&&u.active()){u.update(p,d,a);continue}else u.cancel();if(!p||!p.duration){e[c]=d;continue}r[c]=u=new lp(p,e,c,d),o.push(u)}return o}update(e,n){if(this._properties.size===0){Object.assign(e,n);return}let s=this._createAnimations(e,n);if(s.length)return cs.add(this._chart,s),!0}};function H5(t,e){let n=[],s=Object.keys(e);for(let o=0;o0||!n&&r<0)return o.index}return null}function i$(t,e){let{chart:n,_cachedMeta:s}=t,o=n._stacks||(n._stacks={}),{iScale:r,vScale:i,index:a}=s,l=r.axis,c=i.axis,d=K5(r,i,s),u=e.length,p;for(let f=0;fn[s].axis===e).shift()}function J5(t,e){return ls(t,{active:!1,dataset:void 0,datasetIndex:e,index:e,mode:"default",type:"dataset"})}function Z5(t,e,n){return ls(t,{active:!1,dataIndex:e,parsed:void 0,raw:void 0,element:n,index:e,mode:"default",type:"data"})}function wi(t,e){let n=t.controller.index,s=t.vScale&&t.vScale.axis;if(s){e=e||t._parsed;for(let o of e){let r=o._stacks;if(!r||r[s]===void 0||r[s][n]===void 0)return;delete r[s][n],r[s]._visualValues!==void 0&&r[s]._visualValues[n]!==void 0&&delete r[s]._visualValues[n]}}}var Xu=t=>t==="reset"||t==="none",a$=(t,e)=>e?t:Object.assign({},t),Y5=(t,e,n)=>t&&!e.hidden&&e._stacked&&{keys:tw(n,!0),values:null},Vn=class{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(e,n){this.chart=e,this._ctx=e.ctx,this.index=n,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let e=this._cachedMeta;this.configure(),this.linkScales(),e._stacked=Zu(e.vScale,e),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(e){this.index!==e&&wi(this._cachedMeta),this.index=e}linkScales(){let e=this.chart,n=this._cachedMeta,s=this.getDataset(),o=(u,p,f,g)=>u==="x"?p:u==="r"?g:f,r=n.xAxisID=Se(s.xAxisID,Yu(e,"x")),i=n.yAxisID=Se(s.yAxisID,Yu(e,"y")),a=n.rAxisID=Se(s.rAxisID,Yu(e,"r")),l=n.indexAxis,c=n.iAxisID=o(l,r,i,a),d=n.vAxisID=o(l,i,r,a);n.xScale=this.getScaleForId(r),n.yScale=this.getScaleForId(i),n.rScale=this.getScaleForId(a),n.iScale=this.getScaleForId(c),n.vScale=this.getScaleForId(d)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(e){return this.chart.scales[e]}_getOtherScale(e){let n=this._cachedMeta;return e===n.iScale?n.vScale:n.iScale}reset(){this._update("reset")}_destroy(){let e=this._cachedMeta;this._data&&Mu(this._data,this),e._stacked&&wi(e)}_dataCheck(){let e=this.getDataset(),n=e.data||(e.data=[]),s=this._data;if(Le(n)){let o=this._cachedMeta;this._data=U5(n,o)}else if(s!==n){if(s){Mu(s,this);let o=this._cachedMeta;wi(o),o._parsed=[]}n&&Object.isExtensible(n)&&Ov(n,this),this._syncList=[],this._data=n}}addElements(){let e=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(e.dataset=new this.datasetElementType)}buildOrUpdateElements(e){let n=this._cachedMeta,s=this.getDataset(),o=!1;this._dataCheck();let r=n._stacked;n._stacked=Zu(n.vScale,n),n.stack!==s.stack&&(o=!0,wi(n),n.stack=s.stack),this._resyncElements(e),(o||r!==n._stacked)&&(i$(this,n._parsed),n._stacked=Zu(n.vScale,n))}configure(){let e=this.chart.config,n=e.datasetScopeKeys(this._type),s=e.getOptionScopes(this.getDataset(),n,!0);this.options=e.createResolver(s,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(e,n){let{_cachedMeta:s,_data:o}=this,{iScale:r,_stacked:i}=s,a=r.axis,l=e===0&&n===o.length?!0:s._sorted,c=e>0&&s._parsed[e-1],d,u,p;if(this._parsing===!1)s._parsed=o,s._sorted=!0,p=o;else{et(o[e])?p=this.parseArrayData(s,o,e,n):Le(o[e])?p=this.parseObjectData(s,o,e,n):p=this.parsePrimitiveData(s,o,e,n);let f=()=>u[a]===null||c&&u[a]m||u=0;--p)if(!g()){this.updateRangeFromParsed(c,e,f,l);break}}return c}getAllParsedValues(e){let n=this._cachedMeta._parsed,s=[],o,r,i;for(o=0,r=n.length;o=0&&ethis.getContext(s,o,n),m=c.resolveNamedOptions(p,f,g,u);return m.$shared&&(m.$shared=l,r[i]=Object.freeze(a$(m,l))),m}_resolveAnimations(e,n,s){let o=this.chart,r=this._cachedDataOpts,i=`animation-${n}`,a=r[i];if(a)return a;let l;if(o.options.animation!==!1){let d=this.chart.config,u=d.datasetAnimationScopeKeys(this._type,n),p=d.getOptionScopes(this.getDataset(),u);l=d.createResolver(p,this.getContext(e,s,n))}let c=new ec(o,l&&l.animations);return l&&l._cacheable&&(r[i]=Object.freeze(c)),c}getSharedOptions(e){if(e.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},e))}includeOptions(e,n){return!n||Xu(e)||this.chart._animationsDisabled}_getSharedOptions(e,n){let s=this.resolveDataElementOptions(e,n),o=this._sharedOptions,r=this.getSharedOptions(s),i=this.includeOptions(n,r)||r!==o;return this.updateSharedOptions(r,n,s),{sharedOptions:r,includeOptions:i}}updateElement(e,n,s,o){Xu(o)?Object.assign(e,s):this._resolveAnimations(n,o).update(e,s)}updateSharedOptions(e,n,s){e&&!Xu(n)&&this._resolveAnimations(void 0,n).update(e,s)}_setStyle(e,n,s,o){e.active=o;let r=this.getStyle(n,o);this._resolveAnimations(n,s,o).update(e,{options:!o&&this.getSharedOptions(r)||r})}removeHoverStyle(e,n,s){this._setStyle(e,s,"active",!1)}setHoverStyle(e,n,s){this._setStyle(e,s,"active",!0)}_removeDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,"active",!1)}_setDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,"active",!0)}_resyncElements(e){let n=this._data,s=this._cachedMeta.data;for(let[a,l,c]of this._syncList)this[a](l,c);this._syncList=[];let o=s.length,r=n.length,i=Math.min(r,o);i&&this.parse(0,i),r>o?this._insertElements(o,r-o,e):r{for(c.length+=n,a=c.length-1;a>=i;a--)c[a]=c[a-n]};for(l(r),a=e;ao-r))}return t._cache.$bar}function Q5(t){let e=t.iScale,n=X5(e,t.type),s=e._length,o,r,i,a,l=()=>{i===32767||i===-32768||(ir(a)&&(s=Math.min(s,Math.abs(i-a)||s)),a=i)};for(o=0,r=n.length;o0?o[t-1]:null,a=tMath.abs(a)&&(l=a,c=i),e[n.axis]=c,e._custom={barStart:l,barEnd:c,start:o,end:r,min:i,max:a}}function nw(t,e,n,s){return et(t)?nA(t,e,n,s):e[n.axis]=n.parse(t,s),e}function l$(t,e,n,s){let o=t.iScale,r=t.vScale,i=o.getLabels(),a=o===r,l=[],c,d,u,p;for(c=n,d=n+s;c=n?1:-1)}function oA(t){let e,n,s,o,r;return t.horizontal?(e=t.base>t.x,n="left",s="right"):(e=t.based.controller.options.grouped),r=s.options.stacked,i=[],a=this._cachedMeta.controller.getParsed(n),l=a&&a[s.axis],c=d=>{let u=d._parsed.find(f=>f[s.axis]===l),p=u&&u[d.vScale.axis];if(Me(p)||isNaN(p))return!0};for(let d of o)if(!(n!==void 0&&c(d))&&((r===!1||i.indexOf(d.stack)===-1||r===void 0&&d.stack===void 0)&&i.push(d.stack),d.index===e))break;return i.length||i.push(void 0),i}_getStackCount(e){return this._getStacks(void 0,e).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){let e=this.chart.scales,n=this.chart.options.indexAxis;return Object.keys(e).filter(s=>e[s].axis===n).shift()}_getAxis(){let e={},n=this.getFirstScaleIdForIndexAxis();for(let s of this.chart.data.datasets)e[Se(this.chart.options.indexAxis==="x"?s.xAxisID:s.yAxisID,n)]=!0;return Object.keys(e)}_getStackIndex(e,n,s){let o=this._getStacks(e,s),r=n!==void 0?o.indexOf(n):-1;return r===-1?o.length-1:r}_getRuler(){let e=this.options,n=this._cachedMeta,s=n.iScale,o=[],r,i;for(r=0,i=n.data.length;r=0;--s)n=Math.max(n,e[s].size(this.resolveDataElementOptions(s))/2);return n>0&&n}getLabelAndValue(e){let n=this._cachedMeta,s=this.chart.data.labels||[],{xScale:o,yScale:r}=n,i=this.getParsed(e),a=o.getLabelForValue(i.x),l=r.getLabelForValue(i.y),c=i._custom;return{label:s[e]||"",value:"("+a+", "+l+(c?", "+c:"")+")"}}update(e){let n=this._cachedMeta.data;this.updateElements(n,0,n.length,e)}updateElements(e,n,s,o){let r=o==="reset",{iScale:i,vScale:a}=this._cachedMeta,{sharedOptions:l,includeOptions:c}=this._getSharedOptions(n,o),d=i.axis,u=a.axis;for(let p=n;plr(v,a,l,!0)?1:Math.max($,$*n,w,w*n),g=(v,$,w)=>lr(v,a,l,!0)?-1:Math.min($,$*n,w,w*n),m=f(0,c,u),h=f(ft,d,p),x=g(He,c,u),b=g(He+ft,d,p);s=(m-x)/2,o=(h-b)/2,r=-(m+x)/2,i=-(h+b)/2}return{ratioX:s,ratioY:o,offsetX:r,offsetY:i}}var Ti=class extends Vn{static id="doughnut";static defaults={datasetElementType:!1,dataElementType:"arc",animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"};static descriptors={_scriptable:e=>e!=="spacing",_indexable:e=>e!=="spacing"&&!e.startsWith("borderDash")&&!e.startsWith("hoverBorderDash")};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let n=e.data,{labels:{pointStyle:s,textAlign:o,color:r,useBorderRadius:i,borderRadius:a}}=e.legend.options;return n.labels.length&&n.datasets.length?n.labels.map((l,c)=>{let u=e.getDatasetMeta(0).controller.getStyle(c);return{text:l,fillStyle:u.backgroundColor,fontColor:r,hidden:!e.getDataVisibility(c),lineDash:u.borderDash,lineDashOffset:u.borderDashOffset,lineJoin:u.borderJoinStyle,lineWidth:u.borderWidth,strokeStyle:u.borderColor,textAlign:o,pointStyle:s,borderRadius:i&&(a||u.borderRadius),index:c}}):[]}},onClick(e,n,s){s.chart.toggleDataVisibility(n.index),s.chart.update()}}}};constructor(e,n){super(e,n),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(e,n){let s=this.getDataset().data,o=this._cachedMeta;if(this._parsing===!1)o._parsed=s;else{let r=l=>+s[l];if(Le(s[e])){let{key:l="value"}=this._parsing;r=c=>+as(s[c],l)}let i,a;for(i=e,a=e+n;i0&&!isNaN(e)?tt*(Math.abs(e)/n):0}getLabelAndValue(e){let n=this._cachedMeta,s=this.chart,o=s.data.labels||[],r=cr(n._parsed[e],s.options.locale);return{label:o[e]||"",value:r}}getMaxBorderWidth(e){let n=0,s=this.chart,o,r,i,a,l;if(!e){for(o=0,r=s.data.datasets.length;o0&&this.getParsed(n-1);for(let w=0;w=b){C.skip=!0;continue}let _=this.getParsed(w),k=Me(_[f]),A=C[p]=i.getPixelForValue(_[p],w),D=C[f]=r||k?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,_,l):_[f],w);C.skip=isNaN(A)||isNaN(D)||k,C.stop=w>0&&Math.abs(_[p]-$[p])>h,m&&(C.parsed=_,C.raw=c.data[w]),u&&(C.options=d||this.resolveDataElementOptions(w,S.active?"active":o)),x||this.updateElement(S,w,C,o),$=_}}getMaxOverflow(){let e=this._cachedMeta,n=e.dataset,s=n.options&&n.options.borderWidth||0,o=e.data||[];if(!o.length)return s;let r=o[0].size(this.resolveDataElementOptions(0)),i=o[o.length-1].size(this.resolveDataElementOptions(o.length-1));return Math.max(s,r,i)/2}draw(){let e=this._cachedMeta;e.dataset.updateControlPoints(this.chart.chartArea,e.iScale.axis),super.draw()}},tc=class extends Vn{static id="polarArea";static defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let n=e.data;if(n.labels.length&&n.datasets.length){let{labels:{pointStyle:s,color:o}}=e.legend.options;return n.labels.map((r,i)=>{let l=e.getDatasetMeta(0).controller.getStyle(i);return{text:r,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:o,lineWidth:l.borderWidth,pointStyle:s,hidden:!e.getDataVisibility(i),index:i}})}return[]}},onClick(e,n,s){s.chart.toggleDataVisibility(n.index),s.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(e,n){super(e,n),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(e){let n=this._cachedMeta,s=this.chart,o=s.data.labels||[],r=cr(n._parsed[e].r,s.options.locale);return{label:o[e]||"",value:r}}parseObjectData(e,n,s,o){return Vu.bind(this)(e,n,s,o)}update(e){let n=this._cachedMeta.data;this._updateRadius(),this.updateElements(n,0,n.length,e)}getMinMax(){let e=this._cachedMeta,n={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return e.data.forEach((s,o)=>{let r=this.getParsed(o).r;!isNaN(r)&&this.chart.getDataVisibility(o)&&(rn.max&&(n.max=r))}),n}_updateRadius(){let e=this.chart,n=e.chartArea,s=e.options,o=Math.min(n.right-n.left,n.bottom-n.top),r=Math.max(o/2,0),i=Math.max(s.cutoutPercentage?r/100*s.cutoutPercentage:1,0),a=(r-i)/e.getVisibleDatasetCount();this.outerRadius=r-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(e,n,s,o){let r=o==="reset",i=this.chart,l=i.options.animation,c=this._cachedMeta.rScale,d=c.xCenter,u=c.yCenter,p=c.getIndexAngle(0)-.5*He,f=p,g,m=360/this.countVisibleElements();for(g=0;g{!isNaN(this.getParsed(o).r)&&this.chart.getDataVisibility(o)&&n++}),n}_computeAngle(e,n,s){return this.chart.getDataVisibility(e)?pn(this.resolveDataElementOptions(e,n).angle||s):0}},pp=class extends Ti{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}},fp=class extends Vn{static id="radar";static defaults={datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}};static overrides={aspectRatio:1,scales:{r:{type:"radialLinear"}}};getLabelAndValue(e){let n=this._cachedMeta.vScale,s=this.getParsed(e);return{label:n.getLabels()[e],value:""+n.getLabelForValue(s[n.axis])}}parseObjectData(e,n,s,o){return Vu.bind(this)(e,n,s,o)}update(e){let n=this._cachedMeta,s=n.dataset,o=n.data||[],r=n.iScale.getLabels();if(s.points=o,e!=="resize"){let i=this.resolveDatasetElementOptions(e);this.options.showLine||(i.borderWidth=0);let a={_loop:!0,_fullLoop:r.length===o.length,options:i};this.updateElement(s,void 0,a,e)}this.updateElements(o,0,o.length,e)}updateElements(e,n,s,o){let r=this._cachedMeta.rScale,i=o==="reset";for(let a=n;a0&&this.getParsed(n-1);for(let $=n;$0&&Math.abs(S[f]-v[f])>x,h&&(C.parsed=S,C.raw=c.data[$]),p&&(C.options=u||this.resolveDataElementOptions($,w.active?"active":o)),b||this.updateElement(w,$,C,o),v=S}this.updateSharedOptions(u,o,d)}getMaxOverflow(){let e=this._cachedMeta,n=e.data||[];if(!this.options.showLine){let a=0;for(let l=n.length-1;l>=0;--l)a=Math.max(a,n[l].size(this.resolveDataElementOptions(l))/2);return a>0&&a}let s=e.dataset,o=s.options&&s.options.borderWidth||0;if(!n.length)return o;let r=n[0].size(this.resolveDataElementOptions(0)),i=n[n.length-1].size(this.resolveDataElementOptions(n.length-1));return Math.max(o,r,i)/2}},cA=Object.freeze({__proto__:null,BarController:cp,BubbleController:dp,DoughnutController:Ti,LineController:up,PieController:pp,PolarAreaController:tc,RadarController:fp,ScatterController:hp});function co(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}var mp=class t{static override(e){Object.assign(t.prototype,e)}options;constructor(e){this.options=e||{}}init(){}formats(){return co()}parse(){return co()}format(){return co()}add(){return co()}diff(){return co()}startOf(){return co()}endOf(){return co()}},dA={_date:mp};function uA(t,e,n,s){let{controller:o,data:r,_sorted:i}=t,a=o._cachedMeta.iScale,l=t.dataset&&t.dataset.options?t.dataset.options.spanGaps:null;if(a&&e===a.axis&&e!=="r"&&i&&r.length){let c=a._reversePixels?Iv:Nn;if(s){if(o._sharedOptions){let d=r[0],u=typeof d.getRange=="function"&&d.getRange(e);if(u){let p=c(r,e,n-u),f=c(r,e,n+u);return{lo:p.lo,hi:f.hi}}}}else{let d=c(r,e,n);if(l){let{vScale:u}=o._cachedMeta,{_parsed:p}=t,f=p.slice(0,d.lo+1).reverse().findIndex(m=>!Me(m[u.axis]));d.lo-=Math.max(0,f);let g=p.slice(d.hi).findIndex(m=>!Me(m[u.axis]));d.hi+=Math.max(0,g)}return d}}return{lo:0,hi:r.length-1}}function Ii(t,e,n,s,o){let r=t.getSortedVisibleDatasetMetas(),i=n[e];for(let a=0,l=r.length;a{l[i]&&l[i](e[n],o)&&(r.push({element:l,datasetIndex:c,index:d}),a=a||l.inRange(e.x,e.y,o))}),s&&!a?[]:r}var mA={evaluateInteractionItems:Ii,modes:{index(t,e,n,s){let o=Ds(e,t),r=n.axis||"x",i=n.includeInvisible||!1,a=n.intersect?ep(t,o,r,s,i):tp(t,o,r,!1,s,i),l=[];return a.length?(t.getSortedVisibleDatasetMetas().forEach(c=>{let d=a[0].index,u=c.data[d];u&&!u.skip&&l.push({element:u,datasetIndex:c.index,index:d})}),l):[]},dataset(t,e,n,s){let o=Ds(e,t),r=n.axis||"xy",i=n.includeInvisible||!1,a=n.intersect?ep(t,o,r,s,i):tp(t,o,r,!1,s,i);if(a.length>0){let l=a[0].datasetIndex,c=t.getDatasetMeta(l).data;a=[];for(let d=0;dn.pos===e)}function p$(t,e){return t.filter(n=>sw.indexOf(n.pos)===-1&&n.box.axis===e)}function Si(t,e){return t.sort((n,s)=>{let o=e?s:n,r=e?n:s;return o.weight===r.weight?o.index-r.index:o.weight-r.weight})}function gA(t){let e=[],n,s,o,r,i,a;for(n=0,s=(t||[]).length;nc.box.fullSize),!0),s=Si(ki(e,"left"),!0),o=Si(ki(e,"right")),r=Si(ki(e,"top"),!0),i=Si(ki(e,"bottom")),a=p$(e,"x"),l=p$(e,"y");return{fullSize:n,leftAndTop:s.concat(r),rightAndBottom:o.concat(l).concat(i).concat(a),chartArea:ki(e,"chartArea"),vertical:s.concat(o).concat(l),horizontal:r.concat(i).concat(a)}}function f$(t,e,n,s){return Math.max(t[n],e[n])+Math.max(t[s],e[s])}function ow(t,e){t.top=Math.max(t.top,e.top),t.left=Math.max(t.left,e.left),t.bottom=Math.max(t.bottom,e.bottom),t.right=Math.max(t.right,e.right)}function vA(t,e,n,s){let{pos:o,box:r}=n,i=t.maxPadding;if(!Le(o)){n.size&&(t[o]-=n.size);let u=s[n.stack]||{size:0,count:1};u.size=Math.max(u.size,n.horizontal?r.height:r.width),n.size=u.size/u.count,t[o]+=n.size}r.getPadding&&ow(i,r.getPadding());let a=Math.max(0,e.outerWidth-f$(i,t,"left","right")),l=Math.max(0,e.outerHeight-f$(i,t,"top","bottom")),c=a!==t.w,d=l!==t.h;return t.w=a,t.h=l,n.horizontal?{same:c,other:d}:{same:d,other:c}}function $A(t){let e=t.maxPadding;function n(s){let o=Math.max(e[s]-t[s],0);return t[s]+=o,o}t.y+=n("top"),t.x+=n("left"),n("right"),n("bottom")}function wA(t,e){let n=e.maxPadding;function s(o){let r={left:0,top:0,right:0,bottom:0};return o.forEach(i=>{r[i]=Math.max(e[i],n[i])}),r}return s(t?["left","right"]:["top","bottom"])}function Ai(t,e,n,s){let o=[],r,i,a,l,c,d;for(r=0,i=t.length,c=0;r{typeof m.beforeLayout=="function"&&m.beforeLayout()});let d=l.reduce((m,h)=>h.box.options&&h.box.options.display===!1?m:m+1,0)||1,u=Object.freeze({outerWidth:e,outerHeight:n,padding:o,availableWidth:r,availableHeight:i,vBoxMaxWidth:r/2/d,hBoxMaxHeight:i/2}),p=Object.assign({},o);ow(p,Nt(s));let f=Object.assign({maxPadding:p,w:r,h:i,x:o.left,y:o.top},o),g=xA(l.concat(c),u);Ai(a.fullSize,f,u,g),Ai(l,f,u,g),Ai(c,f,u,g)&&Ai(l,f,u,g),$A(f),h$(a.leftAndTop,f,u,g),f.x+=f.w,f.y+=f.h,h$(a.rightAndBottom,f,u,g),t.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},Ke(a.chartArea,m=>{let h=m.box;Object.assign(h,t.chartArea),h.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})})}},nc=class{acquireContext(e,n){}releaseContext(e){return!1}addEventListener(e,n,s){}removeEventListener(e,n,s){}getDevicePixelRatio(){return 1}getMaximumSize(e,n,s,o){return n=Math.max(0,n||e.width),s=s||e.height,{width:n,height:Math.max(0,o?Math.floor(n/o):s)}}isAttached(e){return!0}updateConfig(e){}},gp=class extends nc{acquireContext(e){return e&&e.getContext&&e.getContext("2d")||null}updateConfig(e){e.options.animation=!1}},Xl="$chartjs",kA={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},m$=t=>t===null||t==="";function SA(t,e){let n=t.style,s=t.getAttribute("height"),o=t.getAttribute("width");if(t[Xl]={initial:{height:s,width:o,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",n.boxSizing=n.boxSizing||"border-box",m$(o)){let r=zu(t,"width");r!==void 0&&(t.width=r)}if(m$(s))if(t.style.height==="")t.height=t.width/(e||2);else{let r=zu(t,"height");r!==void 0&&(t.height=r)}return t}var rw=Yv?{passive:!0}:!1;function CA(t,e,n){t&&t.addEventListener(e,n,rw)}function _A(t,e,n){t&&t.canvas&&t.canvas.removeEventListener(e,n,rw)}function AA(t,e){let n=kA[t.type]||t.type,{x:s,y:o}=Ds(t,e);return{type:n,chart:e,native:t,x:s!==void 0?s:null,y:o!==void 0?o:null}}function sc(t,e){for(let n of t)if(n===e||n.contains(e))return!0}function MA(t,e,n){let s=t.canvas,o=new MutationObserver(r=>{let i=!1;for(let a of r)i=i||sc(a.addedNodes,s),i=i&&!sc(a.removedNodes,s);i&&n()});return o.observe(document,{childList:!0,subtree:!0}),o}function TA(t,e,n){let s=t.canvas,o=new MutationObserver(r=>{let i=!1;for(let a of r)i=i||sc(a.removedNodes,s),i=i&&!sc(a.addedNodes,s);i&&n()});return o.observe(document,{childList:!0,subtree:!0}),o}var Pi=new Map,g$=0;function iw(){let t=window.devicePixelRatio;t!==g$&&(g$=t,Pi.forEach((e,n)=>{n.currentDevicePixelRatio!==t&&e()}))}function PA(t,e){Pi.size||window.addEventListener("resize",iw),Pi.set(t,e)}function RA(t){Pi.delete(t),Pi.size||window.removeEventListener("resize",iw)}function LA(t,e,n){let s=t.canvas,o=s&&zl(s);if(!o)return;let r=Ru((a,l)=>{let c=o.clientWidth;n(a,l),c{let l=a[0],c=l.contentRect.width,d=l.contentRect.height;c===0&&d===0||r(c,d)});return i.observe(o),PA(t,r),i}function np(t,e,n){n&&n.disconnect(),e==="resize"&&RA(t)}function EA(t,e,n){let s=t.canvas,o=Ru(r=>{t.ctx!==null&&n(AA(r,t))},t);return CA(s,e,o),o}var bp=class extends nc{acquireContext(e,n){let s=e&&e.getContext&&e.getContext("2d");return s&&s.canvas===e?(SA(e,n),s):null}releaseContext(e){let n=e.canvas;if(!n[Xl])return!1;let s=n[Xl].initial;["height","width"].forEach(r=>{let i=s[r];Me(i)?n.removeAttribute(r):n.setAttribute(r,i)});let o=s.style||{};return Object.keys(o).forEach(r=>{n.style[r]=o[r]}),n.width=n.width,delete n[Xl],!0}addEventListener(e,n,s){this.removeEventListener(e,n);let o=e.$proxies||(e.$proxies={}),i={attach:MA,detach:TA,resize:LA}[n]||EA;o[n]=i(e,n,s)}removeEventListener(e,n){let s=e.$proxies||(e.$proxies={}),o=s[n];if(!o)return;({attach:np,detach:np,resize:np}[n]||_A)(e,n,o),s[n]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,n,s,o){return Zv(e,n,s,o)}isAttached(e){let n=e&&zl(e);return!!(n&&n.isConnected)}};function IA(t){return!jl()||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas?gp:bp}var kn=class{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(e){let{x:n,y:s}=this.getProps(["x","y"],e);return{x:n,y:s}}hasValue(){return ao(this.x)&&ao(this.y)}getProps(e,n){let s=this.$animations;if(!n||!s)return this;let o={};return e.forEach(r=>{o[r]=s[r]&&s[r].active()?s[r]._to:this[r]}),o}};function DA(t,e){let n=t.options.ticks,s=NA(t),o=Math.min(n.maxTicksLimit||s,s),r=n.major.enabled?BA(e):[],i=r.length,a=r[0],l=r[i-1],c=[];if(i>o)return FA(e,c,r,i/o),c;let d=OA(r,e,o);if(i>0){let u,p,f=i>1?Math.round((l-a)/(i-1)):null;for(Gl(e,c,d,Me(f)?0:a-f,a),u=0,p=i-1;uo)return l}return Math.max(o,1)}function BA(t){let e=[],n,s;for(n=0,s=t.length;nt==="left"?"right":t==="right"?"left":t,b$=(t,e,n)=>e==="top"||e==="left"?t[e]+n:t[e]-n,x$=(t,e)=>Math.min(e||t,t);function y$(t,e){let n=[],s=t.length/e,o=t.length,r=0;for(;ri+a)))return l}function jA(t,e){Ke(t,n=>{let s=n.gc,o=s.length/2,r;if(o>e){for(r=0;rs?s:n,s=o&&n>s?n:s,{min:Yt(n,Yt(s,n)),max:Yt(s,Yt(n,s))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let e=this.chart.data;return this.options.labels||(this.isHorizontal()?e.xLabels:e.yLabels)||e.labels||[]}getLabelItems(e=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(e))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){Ye(this.options.beforeUpdate,[this])}update(e,n,s){let{beginAtZero:o,grace:r,ticks:i}=this.options,a=i.sampleSize;this.beforeUpdate(),this.maxWidth=e,this.maxHeight=n,this._margins=s=Object.assign({left:0,right:0,top:0,bottom:0},s),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+s.left+s.right:this.height+s.top+s.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=zv(this,r,o),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let l=a=r||s<=1||!this.isHorizontal()){this.labelRotation=o;return}let d=this._getLabelSizes(),u=d.widest.width,p=d.highest.height,f=wt(this.chart.width-u,0,this.maxWidth);a=e.offset?this.maxWidth/s:f/(s-1),u+6>a&&(a=f/(s-(e.offset?.5:1)),l=this.maxHeight-Ci(e.grid)-n.padding-v$(e.title,this.chart.options.font),c=Math.sqrt(u*u+p*p),i=Nl(Math.min(Math.asin(wt((d.highest.height+6)/a,-1,1)),Math.asin(wt(l/c,-1,1))-Math.asin(wt(p/c,-1,1)))),i=Math.max(o,Math.min(r,i))),this.labelRotation=i}afterCalculateLabelRotation(){Ye(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){Ye(this.options.beforeFit,[this])}fit(){let e={width:0,height:0},{chart:n,options:{ticks:s,title:o,grid:r}}=this,i=this._isVisible(),a=this.isHorizontal();if(i){let l=v$(o,n.options.font);if(a?(e.width=this.maxWidth,e.height=Ci(r)+l):(e.height=this.maxHeight,e.width=Ci(r)+l),s.display&&this.ticks.length){let{first:c,last:d,widest:u,highest:p}=this._getLabelSizes(),f=s.padding*2,g=pn(this.labelRotation),m=Math.cos(g),h=Math.sin(g);if(a){let x=s.mirror?0:h*u.width+m*p.height;e.height=Math.min(this.maxHeight,e.height+x+f)}else{let x=s.mirror?0:m*u.width+h*p.height;e.width=Math.min(this.maxWidth,e.width+x+f)}this._calculatePadding(c,d,h,m)}}this._handleMargins(),a?(this.width=this._length=n.width-this._margins.left-this._margins.right,this.height=e.height):(this.width=e.width,this.height=this._length=n.height-this._margins.top-this._margins.bottom)}_calculatePadding(e,n,s,o){let{ticks:{align:r,padding:i},position:a}=this.options,l=this.labelRotation!==0,c=a!=="top"&&this.axis==="x";if(this.isHorizontal()){let d=this.getPixelForTick(0)-this.left,u=this.right-this.getPixelForTick(this.ticks.length-1),p=0,f=0;l?c?(p=o*e.width,f=s*n.height):(p=s*e.height,f=o*n.width):r==="start"?f=n.width:r==="end"?p=e.width:r!=="inner"&&(p=e.width/2,f=n.width/2),this.paddingLeft=Math.max((p-d+i)*this.width/(this.width-d),0),this.paddingRight=Math.max((f-u+i)*this.width/(this.width-u),0)}else{let d=n.height/2,u=e.height/2;r==="start"?(d=0,u=e.height):r==="end"&&(d=n.height,u=0),this.paddingTop=d+i,this.paddingBottom=u+i}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){Ye(this.options.afterFit,[this])}isHorizontal(){let{axis:e,position:n}=this.options;return n==="top"||n==="bottom"||e==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(e){this.beforeTickToLabelConversion(),this.generateTickLabels(e);let n,s;for(n=0,s=e.length;n({width:i[k]||0,height:a[k]||0});return{first:_(0),last:_(n-1),widest:_(S),highest:_(C),widths:i,heights:a}}getLabelForValue(e){return e}getPixelForValue(e,n){return NaN}getValueForPixel(e){}getPixelForTick(e){let n=this.ticks;return e<0||e>n.length-1?null:this.getPixelForValue(n[e].value)}getPixelForDecimal(e){this._reversePixels&&(e=1-e);let n=this._startPixel+e*this._length;return Ev(this._alignToPixels?Ls(this.chart,n,0):n)}getDecimalForPixel(e){let n=(e-this._startPixel)/this._length;return this._reversePixels?1-n:n}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:e,max:n}=this;return e<0&&n<0?n:e>0&&n>0?e:0}getContext(e){let n=this.ticks||[];if(e>=0&&ea*o?a/s:l/o:l*o0}_computeGridLineItems(e){let n=this.axis,s=this.chart,o=this.options,{grid:r,position:i,border:a}=o,l=r.offset,c=this.isHorizontal(),u=this.ticks.length+(l?1:0),p=Ci(r),f=[],g=a.setContext(this.getContext()),m=g.display?g.width:0,h=m/2,x=function(R){return Ls(s,R,m)},b,v,$,w,S,C,_,k,A,D,N,z;if(i==="top")b=x(this.bottom),C=this.bottom-p,k=b-h,D=x(e.top)+h,z=e.bottom;else if(i==="bottom")b=x(this.top),D=e.top,z=x(e.bottom)-h,C=b+h,k=this.top+p;else if(i==="left")b=x(this.right),S=this.right-p,_=b-h,A=x(e.left)+h,N=e.right;else if(i==="right")b=x(this.left),A=e.left,N=x(e.right)-h,S=b+h,_=this.left+p;else if(n==="x"){if(i==="center")b=x((e.top+e.bottom)/2+.5);else if(Le(i)){let R=Object.keys(i)[0],B=i[R];b=x(this.chart.scales[R].getPixelForValue(B))}D=e.top,z=e.bottom,C=b+h,k=C+p}else if(n==="y"){if(i==="center")b=x((e.left+e.right)/2);else if(Le(i)){let R=Object.keys(i)[0],B=i[R];b=x(this.chart.scales[R].getPixelForValue(B))}S=b-h,_=S-p,A=e.left,N=e.right}let O=Se(o.ticks.maxTicksLimit,u),M=Math.max(1,Math.ceil(u/O));for(v=0;v0&&(pe-=j/2);break}K={left:pe,top:J,width:j+se.width,height:Y+se.height,color:M.backdropColor}}h.push({label:$,font:k,textOffset:N,options:{rotation:m,color:B,strokeColor:E,strokeWidth:U,textAlign:H,textBaseline:z,translation:[w,S],backdrop:K}})}return h}_getXAxisLabelAlignment(){let{position:e,ticks:n}=this.options;if(-pn(this.labelRotation))return e==="top"?"left":"right";let o="center";return n.align==="start"?o="left":n.align==="end"?o="right":n.align==="inner"&&(o="inner"),o}_getYAxisLabelAlignment(e){let{position:n,ticks:{crossAlign:s,mirror:o,padding:r}}=this.options,i=this._getLabelSizes(),a=e+r,l=i.widest.width,c,d;return n==="left"?o?(d=this.right+r,s==="near"?c="left":s==="center"?(c="center",d+=l/2):(c="right",d+=l)):(d=this.right-a,s==="near"?c="right":s==="center"?(c="center",d-=l/2):(c="left",d=this.left)):n==="right"?o?(d=this.left+r,s==="near"?c="right":s==="center"?(c="center",d-=l/2):(c="left",d-=l)):(d=this.left+a,s==="near"?c="left":s==="center"?(c="center",d+=l/2):(c="right",d=this.right)):c="right",{textAlign:c,x:d}}_computeLabelArea(){if(this.options.ticks.mirror)return;let e=this.chart,n=this.options.position;if(n==="left"||n==="right")return{top:0,left:this.left,bottom:e.height,right:this.right};if(n==="top"||n==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:e.width}}drawBackground(){let{ctx:e,options:{backgroundColor:n},left:s,top:o,width:r,height:i}=this;n&&(e.save(),e.fillStyle=n,e.fillRect(s,o,r,i),e.restore())}getLineWidthForValue(e){let n=this.options.grid;if(!this._isVisible()||!n.display)return 0;let o=this.ticks.findIndex(r=>r.value===e);return o>=0?n.setContext(this.getContext(o)).lineWidth:0}drawGrid(e){let n=this.options.grid,s=this.ctx,o=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(e)),r,i,a=(l,c,d)=>{!d.width||!d.color||(s.save(),s.lineWidth=d.width,s.strokeStyle=d.color,s.setLineDash(d.borderDash||[]),s.lineDashOffset=d.borderDashOffset,s.beginPath(),s.moveTo(l.x,l.y),s.lineTo(c.x,c.y),s.stroke(),s.restore())};if(n.display)for(r=0,i=o.length;r{this.draw(r)}}]:[{z:s,draw:r=>{this.drawBackground(),this.drawGrid(r),this.drawTitle()}},{z:o,draw:()=>{this.drawBorder()}},{z:n,draw:r=>{this.drawLabels(r)}}]}getMatchingVisibleMetas(e){let n=this.chart.getSortedVisibleDatasetMetas(),s=this.axis+"AxisID",o=[],r,i;for(r=0,i=n.length;r{let s=n.split("."),o=s.pop(),r=[t].concat(s).join("."),i=e[n].split("."),a=i.pop(),l=i.join(".");st.route(r,o,l,a)})}function ZA(t){return"id"in t&&"defaults"in t}var xp=class{constructor(){this.controllers=new fr(Vn,"datasets",!0),this.elements=new fr(kn,"elements"),this.plugins=new fr(Object,"plugins"),this.scales=new fr(po,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...e){this._each("register",e)}remove(...e){this._each("unregister",e)}addControllers(...e){this._each("register",e,this.controllers)}addElements(...e){this._each("register",e,this.elements)}addPlugins(...e){this._each("register",e,this.plugins)}addScales(...e){this._each("register",e,this.scales)}getController(e){return this._get(e,this.controllers,"controller")}getElement(e){return this._get(e,this.elements,"element")}getPlugin(e){return this._get(e,this.plugins,"plugin")}getScale(e){return this._get(e,this.scales,"scale")}removeControllers(...e){this._each("unregister",e,this.controllers)}removeElements(...e){this._each("unregister",e,this.elements)}removePlugins(...e){this._each("unregister",e,this.plugins)}removeScales(...e){this._each("unregister",e,this.scales)}_each(e,n,s){[...n].forEach(o=>{let r=s||this._getRegistryForType(o);s||r.isForType(o)||r===this.plugins&&o.id?this._exec(e,r,o):Ke(o,i=>{let a=s||this._getRegistryForType(i);this._exec(e,a,i)})})}_exec(e,n,s){let o=Dl(e);Ye(s["before"+o],[],s),n[e](s),Ye(s["after"+o],[],s)}_getRegistryForType(e){for(let n=0;nr.filter(a=>!i.some(l=>a.plugin.id===l.plugin.id));this._notify(o(n,s),e,"stop"),this._notify(o(s,n),e,"start")}};function YA(t){let e={},n=[],s=Object.keys(Hn.plugins.items);for(let r=0;r1&&$$(t[0].toLowerCase());if(s)return s}throw new Error(`Cannot determine type of '${t}' axis. Please provide 'axis' or 'position' option.`)}function w$(t,e,n){if(n[e+"AxisID"]===t)return{axis:e}}function oM(t,e){if(e.data&&e.data.datasets){let n=e.data.datasets.filter(s=>s.xAxisID===t||s.yAxisID===t);if(n.length)return w$(t,"x",n[0])||w$(t,"y",n[0])}return{}}function rM(t,e){let n=Rs[t.type]||{scales:{}},s=e.scales||{},o=vp(t.type,e),r=Object.create(null);return Object.keys(s).forEach(i=>{let a=s[i];if(!Le(a))return console.error(`Invalid scale configuration for scale: ${i}`);if(a._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${i}`);let l=$p(i,a,oM(i,t),st.scales[a.type]),c=nM(l,o),d=n.scales||{};r[i]=rr(Object.create(null),[{axis:l},a,d[l],d[c]])}),t.data.datasets.forEach(i=>{let a=i.type||t.type,l=i.indexAxis||vp(a,e),d=(Rs[a]||{}).scales||{};Object.keys(d).forEach(u=>{let p=tM(u,l),f=i[p+"AxisID"]||p;r[f]=r[f]||Object.create(null),rr(r[f],[{axis:p},s[f],d[u]])})}),Object.keys(r).forEach(i=>{let a=r[i];rr(a,[st.scales[a.type],st.scale])}),r}function aw(t){let e=t.options||(t.options={});e.plugins=Se(e.plugins,{}),e.scales=rM(t,e)}function lw(t){return t=t||{},t.datasets=t.datasets||[],t.labels=t.labels||[],t}function iM(t){return t=t||{},t.data=lw(t.data),aw(t),t}var k$=new Map,cw=new Set;function ql(t,e){let n=k$.get(t);return n||(n=e(),k$.set(t,n),cw.add(n)),n}var _i=(t,e,n)=>{let s=as(e,n);s!==void 0&&t.add(s)},wp=class{constructor(e){this._config=iM(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=lw(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){let e=this._config;this.clearCache(),aw(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return ql(e,()=>[[`datasets.${e}`,""]])}datasetAnimationScopeKeys(e,n){return ql(`${e}.transition.${n}`,()=>[[`datasets.${e}.transitions.${n}`,`transitions.${n}`],[`datasets.${e}`,""]])}datasetElementScopeKeys(e,n){return ql(`${e}-${n}`,()=>[[`datasets.${e}.elements.${n}`,`datasets.${e}`,`elements.${n}`,""]])}pluginScopeKeys(e){let n=e.id,s=this.type;return ql(`${s}-plugin-${n}`,()=>[[`plugins.${n}`,...e.additionalOptionScopes||[]]])}_cachedScopes(e,n){let s=this._scopeCache,o=s.get(e);return(!o||n)&&(o=new Map,s.set(e,o)),o}getOptionScopes(e,n,s){let{options:o,type:r}=this,i=this._cachedScopes(e,s),a=i.get(n);if(a)return a;let l=new Set;n.forEach(d=>{e&&(l.add(e),d.forEach(u=>_i(l,e,u))),d.forEach(u=>_i(l,o,u)),d.forEach(u=>_i(l,Rs[r]||{},u)),d.forEach(u=>_i(l,st,u)),d.forEach(u=>_i(l,Fl,u))});let c=Array.from(l);return c.length===0&&c.push(Object.create(null)),cw.has(n)&&i.set(n,c),c}chartOptionScopes(){let{options:e,type:n}=this;return[e,Rs[n]||{},st.datasets[n]||{},{type:n},st,Fl]}resolveNamedOptions(e,n,s,o=[""]){let r={$shared:!0},{resolver:i,subPrefixes:a}=S$(this._resolverCache,e,o),l=i;if(lM(i,n)){r.$shared=!1,s=rs(s)?s():s;let c=this.createResolver(e,s,a);l=io(i,s,c)}for(let c of n)r[c]=l[c];return r}createResolver(e,n,s=[""],o){let{resolver:r}=S$(this._resolverCache,e,s);return Le(n)?io(r,n,void 0,o):r}};function S$(t,e,n){let s=t.get(e);s||(s=new Map,t.set(e,s));let o=n.join(),r=s.get(o);return r||(r={resolver:Vl(e,n),subPrefixes:n.filter(a=>!a.toLowerCase().includes("hover"))},s.set(o,r)),r}var aM=t=>Le(t)&&Object.getOwnPropertyNames(t).some(e=>rs(t[e]));function lM(t,e){let{isScriptable:n,isIndexable:s}=Fu(t);for(let o of e){let r=n(o),i=s(o),a=(i||r)&&t[o];if(r&&(rs(a)||aM(a))||i&&et(a))return!0}return!1}var cM="4.5.1",dM=["top","bottom","left","right","chartArea"];function C$(t,e){return t==="top"||t==="bottom"||dM.indexOf(t)===-1&&e==="x"}function _$(t,e){return function(n,s){return n[t]===s[t]?n[e]-s[e]:n[t]-s[t]}}function A$(t){let e=t.chart,n=e.options.animation;e.notifyPlugins("afterRender"),Ye(n&&n.onComplete,[t],e)}function uM(t){let e=t.chart,n=e.options.animation;Ye(n&&n.onProgress,[t],e)}function dw(t){return jl()&&typeof t=="string"?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}var Ql={},M$=t=>{let e=dw(t);return Object.values(Ql).filter(n=>n.canvas===e).pop()};function pM(t,e,n){let s=Object.keys(t);for(let o of s){let r=+o;if(r>=e){let i=t[o];delete t[o],(n>0||r>e)&&(t[r+n]=i)}}}function fM(t,e,n,s){return!n||t.type==="mouseout"?null:s?e:t}var hr=class{static defaults=st;static instances=Ql;static overrides=Rs;static registry=Hn;static version=cM;static getChart=M$;static register(...e){Hn.add(...e),T$()}static unregister(...e){Hn.remove(...e),T$()}constructor(e,n){let s=this.config=new wp(n),o=dw(e),r=M$(o);if(r)throw new Error("Canvas is already in use. Chart with ID '"+r.id+"' must be destroyed before the canvas with ID '"+r.canvas.id+"' can be reused.");let i=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||IA(o)),this.platform.updateConfig(s);let a=this.platform.acquireContext(o,i.aspectRatio),l=a&&a.canvas,c=l&&l.height,d=l&&l.width;if(this.id=Av(),this.ctx=a,this.canvas=l,this.width=d,this.height=c,this._options=i,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new yp,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=Bv(u=>this.update(u),i.resizeDelay||0),this._dataChanges=[],Ql[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}cs.listen(this,"complete",A$),cs.listen(this,"progress",uM),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:e,maintainAspectRatio:n},width:s,height:o,_aspectRatio:r}=this;return Me(e)?n&&r?r:o?s/o:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return Hn}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():ju(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Nu(this.canvas,this.ctx),this}stop(){return cs.stop(this),this}resize(e,n){cs.running(this)?this._resizeBeforeDraw={width:e,height:n}:this._resize(e,n)}_resize(e,n){let s=this.options,o=this.canvas,r=s.maintainAspectRatio&&this.aspectRatio,i=this.platform.getMaximumSize(o,e,n,r),a=s.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=i.width,this.height=i.height,this._aspectRatio=this.aspectRatio,ju(this,a,!0)&&(this.notifyPlugins("resize",{size:i}),Ye(s.onResize,[this,i],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){let n=this.options.scales||{};Ke(n,(s,o)=>{s.id=o})}buildOrUpdateScales(){let e=this.options,n=e.scales,s=this.scales,o=Object.keys(s).reduce((i,a)=>(i[a]=!1,i),{}),r=[];n&&(r=r.concat(Object.keys(n).map(i=>{let a=n[i],l=$p(i,a),c=l==="r",d=l==="x";return{options:a,dposition:c?"chartArea":d?"bottom":"left",dtype:c?"radialLinear":d?"category":"linear"}}))),Ke(r,i=>{let a=i.options,l=a.id,c=$p(l,a),d=Se(a.type,i.dtype);(a.position===void 0||C$(a.position,c)!==C$(i.dposition))&&(a.position=i.dposition),o[l]=!0;let u=null;if(l in s&&s[l].type===d)u=s[l];else{let p=Hn.getScale(d);u=new p({id:l,type:d,ctx:this.ctx,chart:this}),s[u.id]=u}u.init(a,e)}),Ke(o,(i,a)=>{i||delete s[a]}),Ke(s,i=>{Ft.configure(this,i,i.options),Ft.addBox(this,i)})}_updateMetasets(){let e=this._metasets,n=this.data.datasets.length,s=e.length;if(e.sort((o,r)=>o.index-r.index),s>n){for(let o=n;on.length&&delete this._stacks,e.forEach((s,o)=>{n.filter(r=>r===s._dataset).length===0&&this._destroyDatasetMeta(o)})}buildOrUpdateControllers(){let e=[],n=this.data.datasets,s,o;for(this._removeUnreferencedMetasets(),s=0,o=n.length;s{this.getDatasetMeta(n).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(e){let n=this.config;n.update();let s=this._options=n.createResolver(n.chartOptionScopes(),this.getContext()),o=this._animationsDisabled=!s.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:e,cancelable:!0})===!1)return;let r=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let i=0;for(let c=0,d=this.data.datasets.length;c{c.reset()}),this._updateDatasets(e),this.notifyPlugins("afterUpdate",{mode:e}),this._layers.sort(_$("z","_idx"));let{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){Ke(this.scales,e=>{Ft.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let e=this.options,n=new Set(Object.keys(this._listeners)),s=new Set(e.events);(!ku(n,s)||!!this._responsiveListeners!==e.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:e}=this,n=this._getUniformDataChanges()||[];for(let{method:s,start:o,count:r}of n){let i=s==="_removeElements"?-r:r;pM(e,o,i)}}_getUniformDataChanges(){let e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];let n=this.data.datasets.length,s=r=>new Set(e.filter(i=>i[0]===r).map((i,a)=>a+","+i.splice(1).join(","))),o=s(0);for(let r=1;rr.split(",")).map(r=>({method:r[1],start:+r[2],count:+r[3]}))}_updateLayout(e){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;Ft.update(this,this.width,this.height,e);let n=this.chartArea,s=n.width<=0||n.height<=0;this._layers=[],Ke(this.boxes,o=>{s&&o.position==="chartArea"||(o.configure&&o.configure(),this._layers.push(...o._layers()))},this),this._layers.forEach((o,r)=>{o._idx=r}),this.notifyPlugins("afterLayout")}_updateDatasets(e){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:e,cancelable:!0})!==!1){for(let n=0,s=this.data.datasets.length;n=0;--n)this._drawDataset(e[n]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(e){let n=this.ctx,s={meta:e,index:e.index,cancelable:!0},o=Ju(this,e);this.notifyPlugins("beforeDatasetDraw",s)!==!1&&(o&&vi(n,o),e.controller.draw(),o&&$i(n),s.cancelable=!1,this.notifyPlugins("afterDatasetDraw",s))}isPointInArea(e){return On(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,n,s,o){let r=mA.modes[n];return typeof r=="function"?r(this,e,s,o):[]}getDatasetMeta(e){let n=this.data.datasets[e],s=this._metasets,o=s.filter(r=>r&&r._dataset===n).pop();return o||(o={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:n&&n.order||0,index:e,_dataset:n,_parsed:[],_sorted:!1},s.push(o)),o}getContext(){return this.$context||(this.$context=ls(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){let n=this.data.datasets[e];if(!n)return!1;let s=this.getDatasetMeta(e);return typeof s.hidden=="boolean"?!s.hidden:!n.hidden}setDatasetVisibility(e,n){let s=this.getDatasetMeta(e);s.hidden=!n}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,n,s){let o=s?"show":"hide",r=this.getDatasetMeta(e),i=r.controller._resolveAnimations(void 0,o);ir(n)?(r.data[n].hidden=!s,this.update()):(this.setDatasetVisibility(e,s),i.update(r,{visible:s}),this.update(a=>a.datasetIndex===e?o:void 0))}hide(e,n){this._updateVisibility(e,n,!1)}show(e,n){this._updateVisibility(e,n,!0)}_destroyDatasetMeta(e){let n=this._metasets[e];n&&n.controller&&n.controller._destroy(),delete this._metasets[e]}_stop(){let e,n;for(this.stop(),cs.remove(this),e=0,n=this.data.datasets.length;e{n.addEventListener(this,r,i),e[r]=i},o=(r,i,a)=>{r.offsetX=i,r.offsetY=a,this._eventHandler(r)};Ke(this.options.events,r=>s(r,o))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});let e=this._responsiveListeners,n=this.platform,s=(l,c)=>{n.addEventListener(this,l,c),e[l]=c},o=(l,c)=>{e[l]&&(n.removeEventListener(this,l,c),delete e[l])},r=(l,c)=>{this.canvas&&this.resize(l,c)},i,a=()=>{o("attach",a),this.attached=!0,this.resize(),s("resize",r),s("detach",i)};i=()=>{this.attached=!1,o("resize",r),this._stop(),this._resize(0,0),s("attach",a)},n.isAttached(this.canvas)?a():i()}unbindEvents(){Ke(this._listeners,(e,n)=>{this.platform.removeEventListener(this,n,e)}),this._listeners={},Ke(this._responsiveListeners,(e,n)=>{this.platform.removeEventListener(this,n,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,n,s){let o=s?"set":"remove",r,i,a,l;for(n==="dataset"&&(r=this.getDatasetMeta(e[0].datasetIndex),r.controller["_"+o+"DatasetHoverStyle"]()),a=0,l=e.length;a{let a=this.getDatasetMeta(r);if(!a)throw new Error("No dataset found at index "+r);return{datasetIndex:r,element:a.data[i],index:i}});!xi(s,n)&&(this._active=s,this._lastEvent=null,this._updateHoverStyles(s,n))}notifyPlugins(e,n,s){return this._plugins.notify(this,e,n,s)}isPluginEnabled(e){return this._plugins._cache.filter(n=>n.plugin.id===e).length===1}_updateHoverStyles(e,n,s){let o=this.options.hover,r=(l,c)=>l.filter(d=>!c.some(u=>d.datasetIndex===u.datasetIndex&&d.index===u.index)),i=r(n,e),a=s?e:r(e,n);i.length&&this.updateHoverStyle(i,o.mode,!1),a.length&&o.mode&&this.updateHoverStyle(a,o.mode,!0)}_eventHandler(e,n){let s={event:e,replay:n,cancelable:!0,inChartArea:this.isPointInArea(e)},o=i=>(i.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins("beforeEvent",s,o)===!1)return;let r=this._handleEvent(e,n,s.inChartArea);return s.cancelable=!1,this.notifyPlugins("afterEvent",s,o),(r||s.changed)&&this.render(),this}_handleEvent(e,n,s){let{_active:o=[],options:r}=this,i=n,a=this._getActiveElements(e,o,s,i),l=Pv(e),c=fM(e,this._lastEvent,s,l);s&&(this._lastEvent=null,Ye(r.onHover,[e,a,this],this),l&&Ye(r.onClick,[e,a,this],this));let d=!xi(a,o);return(d||n)&&(this._active=a,this._updateHoverStyles(a,o,n)),this._lastEvent=c,d}_getActiveElements(e,n,s,o){if(e.type==="mouseout")return[];if(!s)return n;let r=this.options.hover;return this.getElementsAtEventForMode(e,r.mode,r,o)}};function T$(){return Ke(hr.instances,t=>t._plugins.invalidate())}function hM(t,e,n){let{startAngle:s,x:o,y:r,outerRadius:i,innerRadius:a,options:l}=e,{borderWidth:c,borderJoinStyle:d}=l,u=Math.min(c/i,It(s-n));if(t.beginPath(),t.arc(o,r,i-c/2,s+u/2,n-u/2),a>0){let p=Math.min(c/a,It(s-n));t.arc(o,r,a+c/2,n-p/2,s+p/2,!0)}else{let p=Math.min(c/2,i*It(s-n));if(d==="round")t.arc(o,r,p,n-He/2,s+He/2,!0);else if(d==="bevel"){let f=2*p*p,g=-f*Math.cos(n+He/2)+o,m=-f*Math.sin(n+He/2)+r,h=f*Math.cos(s+He/2)+o,x=f*Math.sin(s+He/2)+r;t.lineTo(g,m),t.lineTo(h,x)}}t.closePath(),t.moveTo(0,0),t.rect(0,0,t.canvas.width,t.canvas.height),t.clip("evenodd")}function mM(t,e,n){let{startAngle:s,pixelMargin:o,x:r,y:i,outerRadius:a,innerRadius:l}=e,c=o/a;t.beginPath(),t.arc(r,i,a,s-c,n+c),l>o?(c=o/l,t.arc(r,i,l,n+c,s-c,!0)):t.arc(r,i,o,n+ft,s-ft),t.closePath(),t.clip()}function gM(t){return Hl(t,["outerStart","outerEnd","innerStart","innerEnd"])}function bM(t,e,n,s){let o=gM(t.options.borderRadius),r=(n-e)/2,i=Math.min(r,s*e/2),a=l=>{let c=(n-Math.min(r,l))*s/2;return wt(l,0,Math.min(r,c))};return{outerStart:a(o.outerStart),outerEnd:a(o.outerEnd),innerStart:wt(o.innerStart,0,i),innerEnd:wt(o.innerEnd,0,i)}}function pr(t,e,n,s){return{x:n+t*Math.cos(e),y:s+t*Math.sin(e)}}function oc(t,e,n,s,o,r){let{x:i,y:a,startAngle:l,pixelMargin:c,innerRadius:d}=e,u=Math.max(e.outerRadius+s+n-c,0),p=d>0?d+s+n+c:0,f=0,g=o-l;if(s){let M=d>0?d-s:0,R=u>0?u-s:0,B=(M+R)/2,E=B!==0?g*B/(B+s):g;f=(g-E)/2}let m=Math.max(.001,g*u-n/He)/u,h=(g-m)/2,x=l+h+f,b=o-h-f,{outerStart:v,outerEnd:$,innerStart:w,innerEnd:S}=bM(e,p,u,b-x),C=u-v,_=u-$,k=x+v/C,A=b-$/_,D=p+w,N=p+S,z=x+w/D,O=b-S/N;if(t.beginPath(),r){let M=(k+A)/2;if(t.arc(i,a,u,k,M),t.arc(i,a,u,M,A),$>0){let U=pr(_,A,i,a);t.arc(U.x,U.y,$,A,b+ft)}let R=pr(N,b,i,a);if(t.lineTo(R.x,R.y),S>0){let U=pr(N,O,i,a);t.arc(U.x,U.y,S,b+ft,O+Math.PI)}let B=(b-S/p+(x+w/p))/2;if(t.arc(i,a,p,b-S/p,B,!0),t.arc(i,a,p,B,x+w/p,!0),w>0){let U=pr(D,z,i,a);t.arc(U.x,U.y,w,z+Math.PI,x-ft)}let E=pr(C,x,i,a);if(t.lineTo(E.x,E.y),v>0){let U=pr(C,k,i,a);t.arc(U.x,U.y,v,x-ft,k)}}else{t.moveTo(i,a);let M=Math.cos(k)*u+i,R=Math.sin(k)*u+a;t.lineTo(M,R);let B=Math.cos(A)*u+i,E=Math.sin(A)*u+a;t.lineTo(B,E)}t.closePath()}function xM(t,e,n,s,o){let{fullCircles:r,startAngle:i,circumference:a}=e,l=e.endAngle;if(r){oc(t,e,n,s,l,o);for(let c=0;c=He&&f===0&&d!=="miter"&&hM(t,e,m),r||(oc(t,e,n,s,m,o),t.stroke())}var kp=class extends kn{static id="arc";static defaults={borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:"backgroundColor"};static descriptors={_scriptable:!0,_indexable:e=>e!=="borderDash"};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(e){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,e&&Object.assign(this,e)}inRange(e,n,s){let o=this.getProps(["x","y"],s),{angle:r,distance:i}=Au(o,{x:e,y:n}),{startAngle:a,endAngle:l,innerRadius:c,outerRadius:d,circumference:u}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],s),p=(this.options.spacing+this.options.borderWidth)/2,f=Se(u,l-a),g=lr(r,a,l)&&a!==l,m=f>=tt||g,h=Fn(i,c+p,d+p);return m&&h}getCenterPoint(e){let{x:n,y:s,startAngle:o,endAngle:r,innerRadius:i,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],e),{offset:l,spacing:c}=this.options,d=(o+r)/2,u=(i+a+c+l)/2;return{x:n+Math.cos(d)*u,y:s+Math.sin(d)*u}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){let{options:n,circumference:s}=this,o=(n.offset||0)/4,r=(n.spacing||0)/2,i=n.circular;if(this.pixelMargin=n.borderAlign==="inner"?.33:0,this.fullCircles=s>tt?Math.floor(s/tt):0,s===0||this.innerRadius<0||this.outerRadius<0)return;e.save();let a=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(a)*o,Math.sin(a)*o);let l=1-Math.sin(Math.min(He,s||0)),c=o*l;e.fillStyle=n.backgroundColor,e.strokeStyle=n.borderColor,xM(e,this,c,r,i),yM(e,this,c,r,i),e.restore()}};function uw(t,e,n=e){t.lineCap=Se(n.borderCapStyle,e.borderCapStyle),t.setLineDash(Se(n.borderDash,e.borderDash)),t.lineDashOffset=Se(n.borderDashOffset,e.borderDashOffset),t.lineJoin=Se(n.borderJoinStyle,e.borderJoinStyle),t.lineWidth=Se(n.borderWidth,e.borderWidth),t.strokeStyle=Se(n.borderColor,e.borderColor)}function vM(t,e,n){t.lineTo(n.x,n.y)}function $M(t){return t.stepped?Vv:t.tension||t.cubicInterpolationMode==="monotone"?jv:vM}function pw(t,e,n={}){let s=t.length,{start:o=0,end:r=s-1}=n,{start:i,end:a}=e,l=Math.max(o,i),c=Math.min(r,a),d=oa&&r>a;return{count:s,start:l,loop:e.loop,ilen:c(i+(c?a-$:$))%r,v=()=>{m!==h&&(t.lineTo(d,h),t.lineTo(d,m),t.lineTo(d,x))};for(l&&(f=o[b(0)],t.moveTo(f.x,f.y)),p=0;p<=a;++p){if(f=o[b(p)],f.skip)continue;let $=f.x,w=f.y,S=$|0;S===g?(wh&&(h=w),d=(u*d+$)/++u):(v(),t.lineTo($,w),g=S,u=0,m=h=w),x=w}v()}function Sp(t){let e=t.options,n=e.borderDash&&e.borderDash.length;return!t._decimated&&!t._loop&&!e.tension&&e.cubicInterpolationMode!=="monotone"&&!e.stepped&&!n?kM:wM}function SM(t){return t.stepped?Xv:t.tension||t.cubicInterpolationMode==="monotone"?Qv:Ts}function CM(t,e,n,s){let o=e._path;o||(o=e._path=new Path2D,e.path(o,n,s)&&o.closePath()),uw(t,e.options),t.stroke(o)}function _M(t,e,n,s){let{segments:o,options:r}=e,i=Sp(e);for(let a of o)uw(t,r,a.style),t.beginPath(),i(t,e,a,{start:n,end:n+s-1})&&t.closePath(),t.stroke()}var AM=typeof Path2D=="function";function MM(t,e,n,s){AM&&!e.options.segment?CM(t,e,n,s):_M(t,e,n,s)}var mr=class extends kn{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:e=>e!=="borderDash"&&e!=="fill"};constructor(e){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,e&&Object.assign(this,e)}updateControlPoints(e,n){let s=this.options;if((s.tension||s.cubicInterpolationMode==="monotone")&&!s.stepped&&!this._pointsUpdated){let o=s.spanGaps?this._loop:this._fullLoop;Jv(this._points,s,e,o,n),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=t$(this,this.options.segment))}first(){let e=this.segments,n=this.points;return e.length&&n[e[0].start]}last(){let e=this.segments,n=this.points,s=e.length;return s&&n[e[s-1].end]}interpolate(e,n){let s=this.options,o=e[n],r=this.points,i=qu(this,{property:n,start:o,end:o});if(!i.length)return;let a=[],l=SM(s),c,d;for(c=0,d=i.length;ct.replace("rgb(","rgba(").replace(")",", 0.5)"));function hw(t){return Ap[t%Ap.length]}function mw(t){return R$[t%R$.length]}function DM(t,e){return t.borderColor=hw(e),t.backgroundColor=mw(e),++e}function NM(t,e){return t.backgroundColor=t.data.map(()=>hw(e++)),e}function OM(t,e){return t.backgroundColor=t.data.map(()=>mw(e++)),e}function BM(t){let e=0;return(n,s)=>{let o=t.getDatasetMeta(s).controller;o instanceof Ti?e=NM(n,e):o instanceof tc?e=OM(n,e):o&&(e=DM(n,e))}}function L$(t){let e;for(e in t)if(t[e].borderColor||t[e].backgroundColor)return!0;return!1}function FM(t){return t&&(t.borderColor||t.backgroundColor)}function WM(){return st.borderColor!=="rgba(0,0,0,0.1)"||st.backgroundColor!=="rgba(0,0,0,0.1)"}var HM={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(t,e,n){if(!n.enabled)return;let{data:{datasets:s},options:o}=t.config,{elements:r}=o,i=L$(s)||FM(o)||r&&L$(r)||WM();if(!n.forceOverride&&i)return;let a=BM(t);s.forEach(a)}};function VM(t,e,n,s,o){let r=o.samples||s;if(r>=n)return t.slice(e,e+n);let i=[],a=(n-2)/(r-2),l=0,c=e+n-1,d=e,u,p,f,g,m;for(i[l++]=t[d],u=0;uf&&(f=g,p=t[b],m=b);i[l++]=p,d=m}return i[l++]=t[c],i}function jM(t,e,n,s){let o=0,r=0,i,a,l,c,d,u,p,f,g,m,h=[],x=e+n-1,b=t[e].x,$=t[x].x-b;for(i=e;im&&(m=c,p=i),o=(r*o+a.x)/++r;else{let S=i-1;if(!Me(u)&&!Me(p)){let C=Math.min(u,p),_=Math.max(u,p);C!==f&&C!==S&&h.push({...t[C],x:o}),_!==f&&_!==S&&h.push({...t[_],x:o})}i>0&&S!==f&&h.push(t[S]),h.push(a),d=w,r=0,g=m=c,u=p=f=i}}return h}function gw(t){if(t._decimated){let e=t._data;delete t._decimated,delete t._data,Object.defineProperty(t,"data",{configurable:!0,enumerable:!0,writable:!0,value:e})}}function E$(t){t.data.datasets.forEach(e=>{gw(e)})}function zM(t,e){let n=e.length,s=0,o,{iScale:r}=t,{min:i,max:a,minDefined:l,maxDefined:c}=r.getUserBounds();return l&&(s=wt(Nn(e,r.axis,i).lo,0,n-1)),c?o=wt(Nn(e,r.axis,a).hi+1,s,n)-s:o=n-s,{start:s,count:o}}var UM={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,n)=>{if(!n.enabled){E$(t);return}let s=t.width;t.data.datasets.forEach((o,r)=>{let{_data:i,indexAxis:a}=o,l=t.getDatasetMeta(r),c=i||o.data;if(ur([a,t.options.indexAxis])==="y"||!l.controller.supportsDecimation)return;let d=t.scales[l.xAxisID];if(d.type!=="linear"&&d.type!=="time"||t.options.parsing)return;let{start:u,count:p}=zM(l,c),f=n.threshold||4*s;if(p<=f){gw(o);return}Me(i)&&(o._data=c,delete o.data,Object.defineProperty(o,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(m){this._data=m}}));let g;switch(n.algorithm){case"lttb":g=VM(c,u,p,s,n);break;case"min-max":g=jM(c,u,p,s);break;default:throw new Error(`Unsupported decimation algorithm '${n.algorithm}'`)}o._decimated=g})},destroy(t){E$(t)}};function KM(t,e,n){let s=t.segments,o=t.points,r=e.points,i=[];for(let a of s){let{start:l,end:c}=a;c=lc(l,c,o);let d=Mp(n,o[l],o[c],a.loop);if(!e.segments){i.push({source:a,target:d,start:o[l],end:o[c]});continue}let u=qu(e,d);for(let p of u){let f=Mp(n,r[p.start],r[p.end],p.loop),g=Gu(a,o,f);for(let m of g)i.push({source:m,target:p,start:{[n]:I$(d,f,"start",Math.max)},end:{[n]:I$(d,f,"end",Math.min)}})}}return i}function Mp(t,e,n,s){if(s)return;let o=e[t],r=n[t];return t==="angle"&&(o=It(o),r=It(r)),{property:t,start:o,end:r}}function GM(t,e){let{x:n=null,y:s=null}=t||{},o=e.points,r=[];return e.segments.forEach(({start:i,end:a})=>{a=lc(i,a,o);let l=o[i],c=o[a];s!==null?(r.push({x:l.x,y:s}),r.push({x:c.x,y:s})):n!==null&&(r.push({x:n,y:l.y}),r.push({x:n,y:c.y}))}),r}function lc(t,e,n){for(;e>t;e--){let s=n[e];if(!isNaN(s.x)&&!isNaN(s.y))break}return e}function I$(t,e,n,s){return t&&e?s(t[n],e[n]):t?t[n]:e?e[n]:0}function bw(t,e){let n=[],s=!1;return et(t)?(s=!0,n=t):n=GM(t,e),n.length?new mr({points:n,options:{tension:0},_loop:s,_fullLoop:s}):null}function D$(t){return t&&t.fill!==!1}function qM(t,e,n){let o=t[e].fill,r=[e],i;if(!n)return o;for(;o!==!1&&r.indexOf(o)===-1;){if(!dt(o))return o;if(i=t[o],!i)return!1;if(i.visible)return o;r.push(o),o=i.fill}return!1}function JM(t,e,n){let s=QM(t);if(Le(s))return isNaN(s.value)?!1:s;let o=parseFloat(s);return dt(o)&&Math.floor(o)===o?ZM(s[0],e,o,n):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}function ZM(t,e,n,s){return(t==="-"||t==="+")&&(n=e+n),n===e||n<0||n>=s?!1:n}function YM(t,e){let n=null;return t==="start"?n=e.bottom:t==="end"?n=e.top:Le(t)?n=e.getPixelForValue(t.value):e.getBasePixel&&(n=e.getBasePixel()),n}function XM(t,e,n){let s;return t==="start"?s=n:t==="end"?s=e.options.reverse?e.min:e.max:Le(t)?s=t.value:s=e.getBaseValue(),s}function QM(t){let e=t.options,n=e.fill,s=Se(n&&n.target,n);return s===void 0&&(s=!!e.backgroundColor),s===!1||s===null?!1:s===!0?"origin":s}function eT(t){let{scale:e,index:n,line:s}=t,o=[],r=s.segments,i=s.points,a=tT(e,n);a.push(bw({x:null,y:e.bottom},s));for(let l=0;l=0;--i){let a=o[i].$filler;a&&(a.line.updateControlPoints(r,a.axis),s&&a.fill&&rp(t.ctx,a,r))}},beforeDatasetsDraw(t,e,n){if(n.drawTime!=="beforeDatasetsDraw")return;let s=t.getSortedVisibleDatasetMetas();for(let o=s.length-1;o>=0;--o){let r=s[o].$filler;D$(r)&&rp(t.ctx,r,t.chartArea)}},beforeDatasetDraw(t,e,n){let s=e.meta.$filler;!D$(s)||n.drawTime!=="beforeDatasetDraw"||rp(t.ctx,s,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}},F$=(t,e)=>{let{boxHeight:n=e,boxWidth:s=e}=t;return t.usePointStyle&&(n=Math.min(n,e),s=t.pointStyleWidth||Math.min(s,e)),{boxWidth:s,boxHeight:n,itemHeight:Math.max(e,n)}},pT=(t,e)=>t!==null&&e!==null&&t.datasetIndex===e.datasetIndex&&t.index===e.index,ic=class extends kn{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,n,s){this.maxWidth=e,this.maxHeight=n,this._margins=s,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){let e=this.options.labels||{},n=Ye(e.generateLabels,[this.chart],this)||[];e.filter&&(n=n.filter(s=>e.filter(s,this.chart.data))),e.sort&&(n=n.sort((s,o)=>e.sort(s,o,this.chart.data))),this.options.reverse&&n.reverse(),this.legendItems=n}fit(){let{options:e,ctx:n}=this;if(!e.display){this.width=this.height=0;return}let s=e.labels,o=bt(s.font),r=o.size,i=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=F$(s,r),c,d;n.font=o.string,this.isHorizontal()?(c=this.maxWidth,d=this._fitRows(i,r,a,l)+10):(d=this.maxHeight,c=this._fitCols(i,o,a,l)+10),this.width=Math.min(c,e.maxWidth||this.maxWidth),this.height=Math.min(d,e.maxHeight||this.maxHeight)}_fitRows(e,n,s,o){let{ctx:r,maxWidth:i,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],d=o+a,u=e;r.textAlign="left",r.textBaseline="middle";let p=-1,f=-d;return this.legendItems.forEach((g,m)=>{let h=s+n/2+r.measureText(g.text).width;(m===0||c[c.length-1]+h+2*a>i)&&(u+=d,c[c.length-(m>0?0:1)]=0,f+=d,p++),l[m]={left:0,top:f,row:p,width:h,height:o},c[c.length-1]+=h+a}),u}_fitCols(e,n,s,o){let{ctx:r,maxHeight:i,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],d=i-e,u=a,p=0,f=0,g=0,m=0;return this.legendItems.forEach((h,x)=>{let{itemWidth:b,itemHeight:v}=fT(s,n,r,h,o);x>0&&f+v+2*a>d&&(u+=p+a,c.push({width:p,height:f}),g+=p+a,m++,p=f=0),l[x]={left:g,top:f,col:m,width:b,height:v},p=Math.max(p,b),f+=v+a}),u+=p,c.push({width:p,height:f}),u}adjustHitBoxes(){if(!this.options.display)return;let e=this._computeTitleHeight(),{legendHitBoxes:n,options:{align:s,labels:{padding:o},rtl:r}}=this,i=lo(r,this.left,this.width);if(this.isHorizontal()){let a=0,l=Dt(s,this.left+o,this.right-this.lineWidths[a]);for(let c of n)a!==c.row&&(a=c.row,l=Dt(s,this.left+o,this.right-this.lineWidths[a])),c.top+=this.top+e+o,c.left=i.leftForLtr(i.x(l),c.width),l+=c.width+o}else{let a=0,l=Dt(s,this.top+e+o,this.bottom-this.columnSizes[a].height);for(let c of n)c.col!==a&&(a=c.col,l=Dt(s,this.top+e+o,this.bottom-this.columnSizes[a].height)),c.top=l,c.left+=this.left+o,c.left=i.leftForLtr(i.x(c.left),c.width),l+=c.height+o}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){let e=this.ctx;vi(e,this),this._draw(),$i(e)}}_draw(){let{options:e,columnSizes:n,lineWidths:s,ctx:o}=this,{align:r,labels:i}=e,a=st.color,l=lo(e.rtl,this.left,this.width),c=bt(i.font),{padding:d}=i,u=c.size,p=u/2,f;this.drawTitle(),o.textAlign=l.textAlign("left"),o.textBaseline="middle",o.lineWidth=.5,o.font=c.string;let{boxWidth:g,boxHeight:m,itemHeight:h}=F$(i,u),x=function(S,C,_){if(isNaN(g)||g<=0||isNaN(m)||m<0)return;o.save();let k=Se(_.lineWidth,1);if(o.fillStyle=Se(_.fillStyle,a),o.lineCap=Se(_.lineCap,"butt"),o.lineDashOffset=Se(_.lineDashOffset,0),o.lineJoin=Se(_.lineJoin,"miter"),o.lineWidth=k,o.strokeStyle=Se(_.strokeStyle,a),o.setLineDash(Se(_.lineDash,[])),i.usePointStyle){let A={radius:m*Math.SQRT2/2,pointStyle:_.pointStyle,rotation:_.rotation,borderWidth:k},D=l.xPlus(S,g/2),N=C+p;Ou(o,A,D,N,i.pointStyleWidth&&g)}else{let A=C+Math.max((u-m)/2,0),D=l.leftForLtr(S,g),N=Is(_.borderRadius);o.beginPath(),Object.values(N).some(z=>z!==0)?dr(o,{x:D,y:A,w:g,h:m,radius:N}):o.rect(D,A,g,m),o.fill(),k!==0&&o.stroke()}o.restore()},b=function(S,C,_){Es(o,_.text,S,C+h/2,c,{strikethrough:_.hidden,textAlign:l.textAlign(_.textAlign)})},v=this.isHorizontal(),$=this._computeTitleHeight();v?f={x:Dt(r,this.left+d,this.right-s[0]),y:this.top+d+$,line:0}:f={x:this.left+d,y:Dt(r,this.top+$+d,this.bottom-n[0].height),line:0},Uu(this.ctx,e.textDirection);let w=h+d;this.legendItems.forEach((S,C)=>{o.strokeStyle=S.fontColor,o.fillStyle=S.fontColor;let _=o.measureText(S.text).width,k=l.textAlign(S.textAlign||(S.textAlign=i.textAlign)),A=g+p+_,D=f.x,N=f.y;l.setWidth(this.width),v?C>0&&D+A+d>this.right&&(N=f.y+=w,f.line++,D=f.x=Dt(r,this.left+d,this.right-s[f.line])):C>0&&N+w>this.bottom&&(D=f.x=D+n[f.line].width+d,f.line++,N=f.y=Dt(r,this.top+$+d,this.bottom-n[f.line].height));let z=l.x(D);if(x(z,N,S),D=Fv(k,D+g+p,v?D+A:this.right,e.rtl),b(l.x(D),N,S),v)f.x+=A+d;else if(typeof S.text!="string"){let O=c.lineHeight;f.y+=xw(S,O)+d}else f.y+=w}),Ku(this.ctx,e.textDirection)}drawTitle(){let e=this.options,n=e.title,s=bt(n.font),o=Nt(n.padding);if(!n.display)return;let r=lo(e.rtl,this.left,this.width),i=this.ctx,a=n.position,l=s.size/2,c=o.top+l,d,u=this.left,p=this.width;if(this.isHorizontal())p=Math.max(...this.lineWidths),d=this.top+c,u=Dt(e.align,u,this.right-p);else{let g=this.columnSizes.reduce((m,h)=>Math.max(m,h.height),0);d=c+Dt(e.align,this.top,this.bottom-g-e.labels.padding-this._computeTitleHeight())}let f=Dt(a,u,u+p);i.textAlign=r.textAlign(Bl(a)),i.textBaseline="middle",i.strokeStyle=n.color,i.fillStyle=n.color,i.font=s.string,Es(i,n.text,f,d,s)}_computeTitleHeight(){let e=this.options.title,n=bt(e.font),s=Nt(e.padding);return e.display?n.lineHeight+s.height:0}_getLegendItemAt(e,n){let s,o,r;if(Fn(e,this.left,this.right)&&Fn(n,this.top,this.bottom)){for(r=this.legendHitBoxes,s=0;sr.length>i.length?r:i)),e+n.size/2+s.measureText(o).width}function mT(t,e,n){let s=t;return typeof e.text!="string"&&(s=xw(e,n)),s}function xw(t,e){let n=t.text?t.text.length:0;return e*n}function gT(t,e){return!!((t==="mousemove"||t==="mouseout")&&(e.onHover||e.onLeave)||e.onClick&&(t==="click"||t==="mouseup"))}var bT={id:"legend",_element:ic,start(t,e,n){let s=t.legend=new ic({ctx:t.ctx,options:n,chart:t});Ft.configure(t,s,n),Ft.addBox(t,s)},stop(t){Ft.removeBox(t,t.legend),delete t.legend},beforeUpdate(t,e,n){let s=t.legend;Ft.configure(t,s,n),s.options=n},afterUpdate(t){let e=t.legend;e.buildLabels(),e.adjustHitBoxes()},afterEvent(t,e){e.replay||t.legend.handleEvent(e.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(t,e,n){let s=e.datasetIndex,o=n.chart;o.isDatasetVisible(s)?(o.hide(s),e.hidden=!0):(o.show(s),e.hidden=!1)},onHover:null,onLeave:null,labels:{color:t=>t.chart.options.color,boxWidth:40,padding:10,generateLabels(t){let e=t.data.datasets,{labels:{usePointStyle:n,pointStyle:s,textAlign:o,color:r,useBorderRadius:i,borderRadius:a}}=t.legend.options;return t._getSortedDatasetMetas().map(l=>{let c=l.controller.getStyle(n?0:void 0),d=Nt(c.borderWidth);return{text:e[l.index].label,fillStyle:c.backgroundColor,fontColor:r,hidden:!l.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(d.width+d.height)/4,strokeStyle:c.borderColor,pointStyle:s||c.pointStyle,rotation:c.rotation,textAlign:o||c.textAlign,borderRadius:i&&(a||c.borderRadius),datasetIndex:l.index}},this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}},Ri=class extends kn{constructor(e){super(),this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,n){let s=this.options;if(this.left=0,this.top=0,!s.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=e,this.height=this.bottom=n;let o=et(s.text)?s.text.length:1;this._padding=Nt(s.padding);let r=o*bt(s.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=r:this.width=r}isHorizontal(){let e=this.options.position;return e==="top"||e==="bottom"}_drawArgs(e){let{top:n,left:s,bottom:o,right:r,options:i}=this,a=i.align,l=0,c,d,u;return this.isHorizontal()?(d=Dt(a,s,r),u=n+e,c=r-s):(i.position==="left"?(d=s+e,u=Dt(a,o,n),l=He*-.5):(d=r-e,u=Dt(a,n,o),l=He*.5),c=o-n),{titleX:d,titleY:u,maxWidth:c,rotation:l}}draw(){let e=this.ctx,n=this.options;if(!n.display)return;let s=bt(n.font),r=s.lineHeight/2+this._padding.top,{titleX:i,titleY:a,maxWidth:l,rotation:c}=this._drawArgs(r);Es(e,n.text,0,0,s,{color:n.color,maxWidth:l,rotation:c,textAlign:Bl(n.align),textBaseline:"middle",translation:[i,a]})}};function xT(t,e){let n=new Ri({ctx:t.ctx,options:e,chart:t});Ft.configure(t,n,e),Ft.addBox(t,n),t.titleBlock=n}var yT={id:"title",_element:Ri,start(t,e,n){xT(t,n)},stop(t){let e=t.titleBlock;Ft.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,n){let s=t.titleBlock;Ft.configure(t,s,n),s.options=n},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}},Jl=new WeakMap,vT={id:"subtitle",start(t,e,n){let s=new Ri({ctx:t.ctx,options:n,chart:t});Ft.configure(t,s,n),Ft.addBox(t,s),Jl.set(t,s)},stop(t){Ft.removeBox(t,Jl.get(t)),Jl.delete(t)},beforeUpdate(t,e,n){let s=Jl.get(t);Ft.configure(t,s,n),s.options=n},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}},Mi={average(t){if(!t.length)return!1;let e,n,s=new Set,o=0,r=0;for(e=0,n=t.length;ea+l)/s.size,y:o/r}},nearest(t,e){if(!t.length)return!1;let n=e.x,s=e.y,o=Number.POSITIVE_INFINITY,r,i,a;for(r=0,i=t.length;r-1?t.split(` -`):t}function vT(t,e){let{element:n,datasetIndex:s,index:o}=e,r=t.getDatasetMeta(s).controller,{label:i,value:a}=r.getLabelAndValue(o);return{chart:t,label:i,parsed:r.getParsed(o),raw:t.data.datasets[s].data[o],formattedValue:a,dataset:r.getDataset(),dataIndex:o,datasetIndex:s,element:n}}function W$(t,e){let n=t.chart.ctx,{body:s,footer:o,title:r}=t,{boxWidth:i,boxHeight:a}=e,l=bt(e.bodyFont),c=bt(e.titleFont),d=bt(e.footerFont),u=r.length,p=o.length,f=s.length,g=Ot(e.padding),m=g.height,h=0,b=s.reduce(($,w)=>$+w.before.length+w.lines.length+w.after.length,0);if(b+=t.beforeBody.length+t.afterBody.length,u&&(m+=u*c.lineHeight+(u-1)*e.titleSpacing+e.titleMarginBottom),b){let $=e.displayColors?Math.max(a,l.lineHeight):l.lineHeight;m+=f*$+(b-f)*l.lineHeight+(b-1)*e.bodySpacing}p&&(m+=e.footerMarginTop+p*d.lineHeight+(p-1)*e.footerSpacing);let x=0,v=function($){h=Math.max(h,n.measureText($).width+x)};return n.save(),n.font=c.string,Ke(t.title,v),n.font=l.string,Ke(t.beforeBody.concat(t.afterBody),v),x=e.displayColors?i+2+e.boxPadding:0,Ke(s,$=>{Ke($.before,v),Ke($.lines,v),Ke($.after,v)}),x=0,n.font=d.string,Ke(t.footer,v),n.restore(),h+=g.width,{width:h,height:m}}function $T(t,e){let{y:n,height:s}=e;return nt.height-s/2?"bottom":"center"}function wT(t,e,n,s){let{x:o,width:r}=s,i=n.caretSize+n.caretPadding;if(t==="left"&&o+r+i>e.width||t==="right"&&o-r-i<0)return!0}function kT(t,e,n,s){let{x:o,width:r}=n,{width:i,chartArea:{left:a,right:l}}=t,c="center";return s==="center"?c=o<=(a+l)/2?"left":"right":o<=r/2?c="left":o>=i-r/2&&(c="right"),wT(c,t,e,n)&&(c="center"),c}function H$(t,e,n){let s=n.yAlign||e.yAlign||$T(t,n);return{xAlign:n.xAlign||e.xAlign||kT(t,e,n,s),yAlign:s}}function ST(t,e){let{x:n,width:s}=t;return e==="right"?n-=s:e==="center"&&(n-=s/2),n}function CT(t,e,n){let{y:s,height:o}=t;return e==="top"?s+=n:e==="bottom"?s-=o+n:s-=o/2,s}function V$(t,e,n,s){let{caretSize:o,caretPadding:r,cornerRadius:i}=t,{xAlign:a,yAlign:l}=n,c=o+r,{topLeft:d,topRight:u,bottomLeft:p,bottomRight:f}=Ls(i),g=ST(e,a),m=CT(e,l,c);return l==="center"?a==="left"?g+=c:a==="right"&&(g-=c):a==="left"?g-=Math.max(d,p)+o:a==="right"&&(g+=Math.max(u,f)+o),{x:wt(g,0,s.width-e.width),y:wt(m,0,s.height-e.height)}}function Zl(t,e,n){let s=Ot(n.padding);return e==="center"?t.x+t.width/2:e==="right"?t.x+t.width-s.right:t.x+s.left}function j$(t){return Wn([],cs(t))}function _T(t,e,n){return as(t,{tooltip:e,tooltipItems:n,type:"tooltip"})}function z$(t,e){let n=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return n?t.override(n):t}var y0={beforeTitle:Bn,title(t){if(t.length>0){let e=t[0],n=e.chart.data.labels,s=n?n.length:0;if(this&&this.options&&this.options.mode==="dataset")return e.dataset.label||"";if(e.label)return e.label;if(s>0&&e.dataIndex"u"?y0[e].call(n,s):o}var ac=class extends kn{static positioners=Mi;constructor(e){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=e.chart,this.options=e.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(e){this.options=e,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){let e=this._cachedAnimations;if(e)return e;let n=this.chart,s=this.options.setContext(this.getContext()),o=s.enabled&&n.options.animation&&s.animations,r=new ec(this.chart,o);return o._cacheable&&(this._cachedAnimations=Object.freeze(r)),r}getContext(){return this.$context||(this.$context=_T(this.chart.getContext(),this,this._tooltipItems))}getTitle(e,n){let{callbacks:s}=n,o=Xt(s,"beforeTitle",this,e),r=Xt(s,"title",this,e),i=Xt(s,"afterTitle",this,e),a=[];return a=Wn(a,cs(o)),a=Wn(a,cs(r)),a=Wn(a,cs(i)),a}getBeforeBody(e,n){return j$(Xt(n.callbacks,"beforeBody",this,e))}getBody(e,n){let{callbacks:s}=n,o=[];return Ke(e,r=>{let i={before:[],lines:[],after:[]},a=z$(s,r);Wn(i.before,cs(Xt(a,"beforeLabel",this,r))),Wn(i.lines,Xt(a,"label",this,r)),Wn(i.after,cs(Xt(a,"afterLabel",this,r))),o.push(i)}),o}getAfterBody(e,n){return j$(Xt(n.callbacks,"afterBody",this,e))}getFooter(e,n){let{callbacks:s}=n,o=Xt(s,"beforeFooter",this,e),r=Xt(s,"footer",this,e),i=Xt(s,"afterFooter",this,e),a=[];return a=Wn(a,cs(o)),a=Wn(a,cs(r)),a=Wn(a,cs(i)),a}_createItems(e){let n=this._active,s=this.chart.data,o=[],r=[],i=[],a=[],l,c;for(l=0,c=n.length;le.filter(d,u,p,s))),e.itemSort&&(a=a.sort((d,u)=>e.itemSort(d,u,s))),Ke(a,d=>{let u=z$(e.callbacks,d);o.push(Xt(u,"labelColor",this,d)),r.push(Xt(u,"labelPointStyle",this,d)),i.push(Xt(u,"labelTextColor",this,d))}),this.labelColors=o,this.labelPointStyles=r,this.labelTextColors=i,this.dataPoints=a,a}update(e,n){let s=this.options.setContext(this.getContext()),o=this._active,r,i=[];if(!o.length)this.opacity!==0&&(r={opacity:0});else{let a=Mi[s.position].call(this,o,this._eventPosition);i=this._createItems(s),this.title=this.getTitle(i,s),this.beforeBody=this.getBeforeBody(i,s),this.body=this.getBody(i,s),this.afterBody=this.getAfterBody(i,s),this.footer=this.getFooter(i,s);let l=this._size=W$(this,s),c=Object.assign({},a,l),d=H$(this.chart,s,c),u=V$(s,c,d,this.chart);this.xAlign=d.xAlign,this.yAlign=d.yAlign,r={opacity:1,x:u.x,y:u.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=i,this.$context=void 0,r&&this._resolveAnimations().update(this,r),e&&s.external&&s.external.call(this,{chart:this.chart,tooltip:this,replay:n})}drawCaret(e,n,s,o){let r=this.getCaretPosition(e,s,o);n.lineTo(r.x1,r.y1),n.lineTo(r.x2,r.y2),n.lineTo(r.x3,r.y3)}getCaretPosition(e,n,s){let{xAlign:o,yAlign:r}=this,{caretSize:i,cornerRadius:a}=s,{topLeft:l,topRight:c,bottomLeft:d,bottomRight:u}=Ls(a),{x:p,y:f}=e,{width:g,height:m}=n,h,b,x,v,$,w;return r==="center"?($=f+m/2,o==="left"?(h=p,b=h-i,v=$+i,w=$-i):(h=p+g,b=h+i,v=$-i,w=$+i),x=h):(o==="left"?b=p+Math.max(l,d)+i:o==="right"?b=p+g-Math.max(c,u)-i:b=this.caretX,r==="top"?(v=f,$=v-i,h=b-i,x=b+i):(v=f+m,$=v+i,h=b+i,x=b-i),w=v),{x1:h,x2:b,x3:x,y1:v,y2:$,y3:w}}drawTitle(e,n,s){let o=this.title,r=o.length,i,a,l;if(r){let c=ao(s.rtl,this.x,this.width);for(e.x=Zl(this,s.titleAlign,s),n.textAlign=c.textAlign(s.titleAlign),n.textBaseline="middle",i=bt(s.titleFont),a=s.titleSpacing,n.fillStyle=s.titleColor,n.font=i.string,l=0;lx!==0)?(e.beginPath(),e.fillStyle=r.multiKeyBackground,dr(e,{x:m,y:g,w:c,h:l,radius:b}),e.fill(),e.stroke(),e.fillStyle=i.backgroundColor,e.beginPath(),dr(e,{x:h,y:g+1,w:c-2,h:l-2,radius:b}),e.fill()):(e.fillStyle=r.multiKeyBackground,e.fillRect(m,g,c,l),e.strokeRect(m,g,c,l),e.fillStyle=i.backgroundColor,e.fillRect(h,g+1,c-2,l-2))}e.fillStyle=this.labelTextColors[s]}drawBody(e,n,s){let{body:o}=this,{bodySpacing:r,bodyAlign:i,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:d}=s,u=bt(s.bodyFont),p=u.lineHeight,f=0,g=ao(s.rtl,this.x,this.width),m=function(_){n.fillText(_,g.x(e.x+f),e.y+p/2),e.y+=p+r},h=g.textAlign(i),b,x,v,$,w,S,C;for(n.textAlign=i,n.textBaseline="middle",n.font=u.string,e.x=Zl(this,h,s),n.fillStyle=s.bodyColor,Ke(this.beforeBody,m),f=a&&h!=="right"?i==="center"?c/2+d:c+2+d:0,$=0,S=o.length;$0&&n.stroke()}_updateAnimationTarget(e){let n=this.chart,s=this.$animations,o=s&&s.x,r=s&&s.y;if(o||r){let i=Mi[e.position].call(this,this._active,this._eventPosition);if(!i)return;let a=this._size=W$(this,e),l=Object.assign({},i,this._size),c=H$(n,e,l),d=V$(e,l,c,n);(o._to!==d.x||r._to!==d.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=i.x,this.caretY=i.y,this._resolveAnimations().update(this,d))}}_willRender(){return!!this.opacity}draw(e){let n=this.options.setContext(this.getContext()),s=this.opacity;if(!s)return;this._updateAnimationTarget(n);let o={width:this.width,height:this.height},r={x:this.x,y:this.y};s=Math.abs(s)<.001?0:s;let i=Ot(n.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;n.enabled&&a&&(e.save(),e.globalAlpha=s,this.drawBackground(r,e,o,n),Uu(e,n.textDirection),r.y+=i.top,this.drawTitle(r,e,n),this.drawBody(r,e,n),this.drawFooter(r,e,n),Ku(e,n.textDirection),e.restore())}getActiveElements(){return this._active||[]}setActiveElements(e,n){let s=this._active,o=e.map(({datasetIndex:a,index:l})=>{let c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),r=!xi(s,o),i=this._positionChanged(o,n);(r||i)&&(this._active=o,this._eventPosition=n,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(e,n,s=!0){if(n&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let o=this.options,r=this._active||[],i=this._getActiveElements(e,r,n,s),a=this._positionChanged(i,e),l=n||!xi(i,r)||a;return l&&(this._active=i,(o.enabled||o.external)&&(this._eventPosition={x:e.x,y:e.y},this.update(!0,n))),l}_getActiveElements(e,n,s,o){let r=this.options;if(e.type==="mouseout")return[];if(!o)return n.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);let i=this.chart.getElementsAtEventForMode(e,r.mode,r,s);return r.reverse&&i.reverse(),i}_positionChanged(e,n){let{caretX:s,caretY:o,options:r}=this,i=Mi[r.position].call(this,e,n);return i!==!1&&(s!==i.x||o!==i.y)}},AT={id:"tooltip",_element:ac,positioners:Mi,afterInit(t,e,n){n&&(t.tooltip=new ac({chart:t,options:n}))},beforeUpdate(t,e,n){t.tooltip&&t.tooltip.initialize(n)},reset(t,e,n){t.tooltip&&t.tooltip.initialize(n)},afterDraw(t){let e=t.tooltip;if(e&&e._willRender()){let n={tooltip:e};if(t.notifyPlugins("beforeTooltipDraw",{...n,cancelable:!0})===!1)return;e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",n)}},afterEvent(t,e){if(t.tooltip){let n=e.replay;t.tooltip.handleEvent(e.event,n,e.inChartArea)&&(e.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:y0},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:t=>t!=="filter"&&t!=="itemSort"&&t!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},MT=Object.freeze({__proto__:null,Colors:WM,Decimation:zM,Filler:dT,Legend:gT,SubTitle:yT,Title:xT,Tooltip:AT}),TT=(t,e,n,s)=>(typeof e=="string"?(n=t.push(e)-1,s.unshift({index:n,label:e})):isNaN(e)&&(n=null),n);function PT(t,e,n,s){let o=t.indexOf(e);if(o===-1)return TT(t,e,n,s);let r=t.lastIndexOf(e);return o!==r?n:o}var RT=(t,e)=>t===null?null:wt(Math.round(t),0,e);function U$(t){let e=this.getLabels();return t>=0&&tn.length-1?null:this.getPixelForValue(n[e].value)}getValueForPixel(e){return Math.round(this._startValue+this.getDecimalForPixel(e)*this._valueRange)}getBasePixel(){return this.bottom}};function LT(t,e){let n=[],{bounds:o,step:r,min:i,max:a,precision:l,count:c,maxTicks:d,maxDigits:u,includeBounds:p}=t,f=r||1,g=d-1,{min:m,max:h}=e,b=!Me(i),x=!Me(a),v=!Me(c),$=(h-m)/(u+1),w=Su((h-m)/g/f)*f,S,C,_,k;if(w<1e-14&&!b&&!x)return[{value:m},{value:h}];k=Math.ceil(h/w)-Math.floor(m/w),k>g&&(w=Su(k*w/g/f)*f),Me(l)||(S=Math.pow(10,l),w=Math.ceil(w*S)/S),o==="ticks"?(C=Math.floor(m/w)*w,_=Math.ceil(h/w)*w):(C=m,_=h),b&&x&&r&&Lv((a-i)/r,w/1e3)?(k=Math.round(Math.min((a-i)/w,d)),w=(a-i)/k,C=i,_=a):v?(C=b?i:C,_=x?a:_,k=c-1,w=(_-C)/k):(k=(_-C)/w,ar(k,Math.round(k),w/1e3)?k=Math.round(k):k=Math.ceil(k));let A=Math.max(_u(w),_u(C));S=Math.pow(10,Me(l)?A:l),C=Math.round(C*S)/S,_=Math.round(_*S)/S;let D=0;for(b&&(p&&C!==i?(n.push({value:i}),Ca)break;n.push({value:O})}return x&&p&&_!==a?n.length&&ar(n[n.length-1].value,a,K$(a,$,t))?n[n.length-1].value=a:n.push({value:a}):(!x||_===a)&&n.push({value:_}),n}function K$(t,e,{horizontal:n,minRotation:s}){let o=pn(s),r=(n?Math.sin(o):Math.cos(o))||.001,i=.75*e*(""+t).length;return Math.min(e/r,i)}var gr=class extends uo{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(e,n){return Me(e)||(typeof e=="number"||e instanceof Number)&&!isFinite(+e)?null:+e}handleTickRangeOptions(){let{beginAtZero:e}=this.options,{minDefined:n,maxDefined:s}=this.getUserBounds(),{min:o,max:r}=this,i=l=>o=n?o:l,a=l=>r=s?r:l;if(e){let l=wn(o),c=wn(r);l<0&&c<0?a(0):l>0&&c>0&&i(0)}if(o===r){let l=r===0?1:Math.abs(r*.05);a(r+l),e||i(o-l)}this.min=o,this.max=r}getTickLimit(){let e=this.options.ticks,{maxTicksLimit:n,stepSize:s}=e,o;return s?(o=Math.ceil(this.max/s)-Math.floor(this.min/s)+1,o>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${o} ticks. Limiting to 1000.`),o=1e3)):(o=this.computeTickLimit(),n=n||11),n&&(o=Math.min(n,o)),o}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){let e=this.options,n=e.ticks,s=this.getTickLimit();s=Math.max(2,s);let o={maxTicks:s,bounds:e.bounds,min:e.min,max:e.max,precision:n.precision,step:n.stepSize,count:n.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:n.minRotation||0,includeBounds:n.includeBounds!==!1},r=this._range||this,i=LT(o,r);return e.bounds==="ticks"&&Cu(i,this,"value"),e.reverse?(i.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),i}configure(){let e=this.ticks,n=this.min,s=this.max;if(super.configure(),this.options.offset&&e.length){let o=(s-n)/Math.max(e.length-1,1)/2;n-=o,s+=o}this._startValue=n,this._endValue=s,this._valueRange=s-n}getLabelForValue(e){return cr(e,this.chart.options.locale,this.options.ticks.format)}},Pp=class extends gr{static id="linear";static defaults={ticks:{callback:yi.formatters.numeric}};determineDataLimits(){let{min:e,max:n}=this.getMinMax(!0);this.min=dt(e)?e:0,this.max=dt(n)?n:1,this.handleTickRangeOptions()}computeTickLimit(){let e=this.isHorizontal(),n=e?this.width:this.height,s=pn(this.options.ticks.minRotation),o=(e?Math.sin(s):Math.cos(s))||.001,r=this._resolveTickFontOptions(0);return Math.ceil(n/Math.min(40,r.lineHeight/o))}getPixelForValue(e){return e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getValueForPixel(e){return this._startValue+this.getDecimalForPixel(e)*this._valueRange}},Li=t=>Math.floor(rs(t)),co=(t,e)=>Math.pow(10,Li(t)+e);function G$(t){return t/Math.pow(10,Li(t))===1}function q$(t,e,n){let s=Math.pow(10,n),o=Math.floor(t/s);return Math.ceil(e/s)-o}function ET(t,e){let n=e-t,s=Li(n);for(;q$(t,e,s)>10;)s++;for(;q$(t,e,s)<10;)s--;return Math.min(s,Li(t))}function IT(t,{min:e,max:n}){e=Yt(t.min,e);let s=[],o=Li(e),r=ET(e,n),i=r<0?Math.pow(10,Math.abs(r)):1,a=Math.pow(10,r),l=o>r?Math.pow(10,o):0,c=Math.round((e-l)*i)/i,d=Math.floor((e-l)/a/10)*a*10,u=Math.floor((c-d)/Math.pow(10,r)),p=Yt(t.min,Math.round((l+d+u*Math.pow(10,r))*i)/i);for(;p=10?u=u<15?15:20:u++,u>=20&&(r++,u=2,i=r>=0?1:i),p=Math.round((l+d+u*Math.pow(10,r))*i)/i;let f=Yt(t.max,p);return s.push({value:f,major:G$(f),significand:u}),s}var Rp=class extends uo{static id="logarithmic";static defaults={ticks:{callback:yi.formatters.logarithmic,major:{enabled:!0}}};constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(e,n){let s=gr.prototype.parse.apply(this,[e,n]);if(s===0){this._zero=!0;return}return dt(s)&&s>0?s:null}determineDataLimits(){let{min:e,max:n}=this.getMinMax(!0);this.min=dt(e)?Math.max(0,e):null,this.max=dt(n)?Math.max(0,n):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!dt(this._userMin)&&(this.min=e===co(this.min,0)?co(this.min,-1):co(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:e,maxDefined:n}=this.getUserBounds(),s=this.min,o=this.max,r=a=>s=e?s:a,i=a=>o=n?o:a;s===o&&(s<=0?(r(1),i(10)):(r(co(s,-1)),i(co(o,1)))),s<=0&&r(co(o,-1)),o<=0&&i(co(s,1)),this.min=s,this.max=o}buildTicks(){let e=this.options,n={min:this._userMin,max:this._userMax},s=IT(n,this);return e.bounds==="ticks"&&Cu(s,this,"value"),e.reverse?(s.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),s}getLabelForValue(e){return e===void 0?"0":cr(e,this.chart.options.locale,this.options.ticks.format)}configure(){let e=this.min;super.configure(),this._startValue=rs(e),this._valueRange=rs(this.max)-rs(e)}getPixelForValue(e){return(e===void 0||e===0)&&(e=this.min),e===null||isNaN(e)?NaN:this.getPixelForDecimal(e===this.min?0:(rs(e)-this._startValue)/this._valueRange)}getValueForPixel(e){let n=this.getDecimalForPixel(e);return Math.pow(10,this._startValue+n*this._valueRange)}};function Lp(t){let e=t.ticks;if(e.display&&t.display){let n=Ot(e.backdropPadding);return Se(e.font&&e.font.size,st.font.size)+n.height}return 0}function DT(t,e,n){return n=et(n)?n:[n],{w:Hv(t,e.string,n),h:n.length*e.lineHeight}}function J$(t,e,n,s,o){return t===s||t===o?{start:e-n/2,end:e+n/2}:to?{start:e-n,end:e}:{start:e,end:e+n}}function OT(t){let e={l:t.left+t._padding.left,r:t.right-t._padding.right,t:t.top+t._padding.top,b:t.bottom-t._padding.bottom},n=Object.assign({},e),s=[],o=[],r=t._pointLabels.length,i=t.options.pointLabels,a=i.centerPointLabels?He/r:0;for(let l=0;le.r&&(a=(s.end-e.r)/r,t.r=Math.max(t.r,e.r+a)),o.starte.b&&(l=(o.end-e.b)/i,t.b=Math.max(t.b,e.b+l))}function BT(t,e,n){let s=t.drawingArea,{extra:o,additionalAngle:r,padding:i,size:a}=n,l=t.getPointPosition(e,s+o+i,r),c=Math.round(Ol(It(l.angle+ft))),d=jT(l.y,a.h,c),u=HT(c),p=VT(l.x,a.w,u);return{visible:!0,x:l.x,y:d,textAlign:u,left:p,top:d,right:p+a.w,bottom:d+a.h}}function FT(t,e){if(!e)return!0;let{left:n,top:s,right:o,bottom:r}=t;return!(Nn({x:n,y:s},e)||Nn({x:n,y:r},e)||Nn({x:o,y:s},e)||Nn({x:o,y:r},e))}function WT(t,e,n){let s=[],o=t._pointLabels.length,r=t.options,{centerPointLabels:i,display:a}=r.pointLabels,l={extra:Lp(r)/2,additionalAngle:i?He/o:0},c;for(let d=0;d270||n<90)&&(t-=e),t}function zT(t,e,n){let{left:s,top:o,right:r,bottom:i}=n,{backdropColor:a}=e;if(!Me(a)){let l=Ls(e.borderRadius),c=Ot(e.backdropPadding);t.fillStyle=a;let d=s-c.left,u=o-c.top,p=r-s+c.width,f=i-o+c.height;Object.values(l).some(g=>g!==0)?(t.beginPath(),dr(t,{x:d,y:u,w:p,h:f,radius:l}),t.fill()):t.fillRect(d,u,p,f)}}function UT(t,e){let{ctx:n,options:{pointLabels:s}}=t;for(let o=e-1;o>=0;o--){let r=t._pointLabelItems[o];if(!r.visible)continue;let i=s.setContext(t.getPointLabelContext(o));zT(n,i,r);let a=bt(i.font),{x:l,y:c,textAlign:d}=r;Rs(n,t._pointLabels[o],l,c+a.lineHeight/2,a,{color:i.color,textAlign:d,textBaseline:"middle"})}}function v0(t,e,n,s){let{ctx:o}=t;if(n)o.arc(t.xCenter,t.yCenter,e,0,tt);else{let r=t.getPointPosition(0,e);o.moveTo(r.x,r.y);for(let i=1;i{let o=Ye(this.options.pointLabels.callback,[n,s],this);return o||o===0?o:""}).filter((n,s)=>this.chart.getDataVisibility(s))}fit(){let e=this.options;e.display&&e.pointLabels.display?OT(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(e,n,s,o){this.xCenter+=Math.floor((e-n)/2),this.yCenter+=Math.floor((s-o)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(e,n,s,o))}getIndexAngle(e){let n=tt/(this._pointLabels.length||1),s=this.options.startAngle||0;return It(e*n+pn(s))}getDistanceFromCenterForValue(e){if(Me(e))return NaN;let n=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-e)*n:(e-this.min)*n}getValueForDistanceFromCenter(e){if(Me(e))return NaN;let n=e/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-n:this.min+n}getPointLabelContext(e){let n=this._pointLabels||[];if(e>=0&&e{if(u!==0||u===0&&this.min<0){l=this.getDistanceFromCenterForValue(d.value);let p=this.getContext(u),f=o.setContext(p),g=r.setContext(p);KT(this,f,l,i,g)}}),s.display){for(e.save(),a=i-1;a>=0;a--){let d=s.setContext(this.getPointLabelContext(a)),{color:u,lineWidth:p}=d;!p||!u||(e.lineWidth=p,e.strokeStyle=u,e.setLineDash(d.borderDash),e.lineDashOffset=d.borderDashOffset,l=this.getDistanceFromCenterForValue(n.reverse?this.min:this.max),c=this.getPointPosition(a,l),e.beginPath(),e.moveTo(this.xCenter,this.yCenter),e.lineTo(c.x,c.y),e.stroke())}e.restore()}}drawBorder(){}drawLabels(){let e=this.ctx,n=this.options,s=n.ticks;if(!s.display)return;let o=this.getIndexAngle(0),r,i;e.save(),e.translate(this.xCenter,this.yCenter),e.rotate(o),e.textAlign="center",e.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&this.min>=0&&!n.reverse)return;let c=s.setContext(this.getContext(l)),d=bt(c.font);if(r=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){e.font=d.string,i=e.measureText(a.label).width,e.fillStyle=c.backdropColor;let u=Ot(c.backdropPadding);e.fillRect(-i/2-u.left,-r-d.size/2-u.top,i+u.width,d.size+u.height)}Rs(e,a.label,0,-r,d,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),e.restore()}drawTitle(){}},cc={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Qt=Object.keys(cc);function Z$(t,e){return t-e}function Y$(t,e){if(Me(e))return null;let n=t._adapter,{parser:s,round:o,isoWeekday:r}=t._parseOpts,i=e;return typeof s=="function"&&(i=s(i)),dt(i)||(i=typeof s=="string"?n.parse(i,s):n.parse(i)),i===null?null:(o&&(i=o==="week"&&(io(r)||r===!0)?n.startOf(i,"isoWeek",r):n.startOf(i,o)),+i)}function X$(t,e,n,s){let o=Qt.length;for(let r=Qt.indexOf(t);r=Qt.indexOf(n);r--){let i=Qt[r];if(cc[i].common&&t._adapter.diff(o,s,i)>=e-1)return i}return Qt[n?Qt.indexOf(n):0]}function JT(t){for(let e=Qt.indexOf(t)+1,n=Qt.length;e=e?n[s]:n[o];t[r]=!0}}function ZT(t,e,n,s){let o=t._adapter,r=+o.startOf(e[0].value,s),i=e[e.length-1].value,a,l;for(a=r;a<=i;a=+o.add(a,1,s))l=n[a],l>=0&&(e[l].major=!0);return e}function e0(t,e,n){let s=[],o={},r=e.length,i,a;for(i=0;i+e.value))}initOffsets(e=[]){let n=0,s=0,o,r;this.options.offset&&e.length&&(o=this.getDecimalForValue(e[0]),e.length===1?n=1-o:n=(this.getDecimalForValue(e[1])-o)/2,r=this.getDecimalForValue(e[e.length-1]),e.length===1?s=r:s=(r-this.getDecimalForValue(e[e.length-2]))/2);let i=e.length<3?.5:.25;n=wt(n,0,i),s=wt(s,0,i),this._offsets={start:n,end:s,factor:1/(n+1+s)}}_generate(){let e=this._adapter,n=this.min,s=this.max,o=this.options,r=o.time,i=r.unit||X$(r.minUnit,n,s,this._getLabelCapacity(n)),a=Se(o.ticks.stepSize,1),l=i==="week"?r.isoWeekday:!1,c=io(l)||l===!0,d={},u=n,p,f;if(c&&(u=+e.startOf(u,"isoWeek",l)),u=+e.startOf(u,c?"day":i),e.diff(s,n,i)>1e5*a)throw new Error(n+" and "+s+" are too far apart with stepSize of "+a+" "+i);let g=o.ticks.source==="data"&&this.getDataTimestamps();for(p=u,f=0;p+m)}getLabelForValue(e){let n=this._adapter,s=this.options.time;return s.tooltipFormat?n.format(e,s.tooltipFormat):n.format(e,s.displayFormats.datetime)}format(e,n){let o=this.options.time.displayFormats,r=this._unit,i=n||o[r];return this._adapter.format(e,i)}_tickFormatFunction(e,n,s,o){let r=this.options,i=r.ticks.callback;if(i)return Ye(i,[e,n,s],this);let a=r.time.displayFormats,l=this._unit,c=this._majorUnit,d=l&&a[l],u=c&&a[c],p=s[n],f=c&&u&&p&&p.major;return this._adapter.format(e,o||(f?u:d))}generateTickLabels(e){let n,s,o;for(n=0,s=e.length;n0?a:1}getDataTimestamps(){let e=this._cache.data||[],n,s;if(e.length)return e;let o=this.getMatchingVisibleMetas();if(this._normalized&&o.length)return this._cache.data=o[0].controller.getAllParsedValues(this);for(n=0,s=o.length;n=t[s].pos&&e<=t[o].pos&&({lo:s,hi:o}=On(t,"pos",e)),{pos:r,time:a}=t[s],{pos:i,time:l}=t[o]):(e>=t[s].time&&e<=t[o].time&&({lo:s,hi:o}=On(t,"time",e)),{time:r,pos:a}=t[s],{time:i,pos:l}=t[o]);let c=i-r;return c?a+(l-a)*(e-r)/c:a}var Ip=class extends Ei{static id="timeseries";static defaults=Ei.defaults;constructor(e){super(e),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let e=this._getTimestampsForTable(),n=this._table=this.buildLookupTable(e);this._minPos=Yl(n,this.min),this._tableRange=Yl(n,this.max)-this._minPos,super.initOffsets(e)}buildLookupTable(e){let{min:n,max:s}=this,o=[],r=[],i,a,l,c,d;for(i=0,a=e.length;i=n&&c<=s&&o.push(c);if(o.length<2)return[{time:n,pos:0},{time:s,pos:1}];for(i=0,a=o.length;io-r)}_getTimestampsForTable(){let e=this._cache.all||[];if(e.length)return e;let n=this.getDataTimestamps(),s=this.getLabelTimestamps();return n.length&&s.length?e=this.normalize(n.concat(s)):e=n.length?n:s,e=this._cache.all=e,e}getDecimalForValue(e){return(Yl(this._table,e)-this._minPos)/this._tableRange}getValueForPixel(e){let n=this._offsets,s=this.getDecimalForPixel(e)/n.factor-n.end;return Yl(this._table,s*this._tableRange+this._minPos,!0)}},YT=Object.freeze({__proto__:null,CategoryScale:Tp,LinearScale:Pp,LogarithmicScale:Rp,RadialLinearScale:Ep,TimeScale:Ei,TimeSeriesScale:Ip}),$0=[lA,EM,MT,YT];hr.register(...$0);var ds=hr;var Dp=P.bind(T),br="outcomes",Di="tokens",Op="duration",Ds="cost",XT="24h",Np="7d",QT="30d",eP=[{label:"24h",value:XT},{label:"7d",value:Np},{label:"30d",value:QT}],tP=[{label:"outcomes",value:br},{label:"tokens",value:Di},{label:"duration",value:Op},{label:"cost",value:Ds}],nP=({trends:t=null,metric:e=br,selectedBucketKey:n=""}={})=>{let s=Array.isArray(t?.points)?t.points:[],o=String(t?.range||Np),r=s.map(d=>es(d.startMs,{range:o,valueType:"epoch-ms"})),i="0.22",a="0.86",l=d=>n&&String(s[d]?.key||"")!==n;if(e===br)return{labels:r,datasets:[{label:"ok",data:s.map(d=>Number(d?.ok||0)),stack:"outcomes",backgroundColor:s.map((d,u)=>`rgba(34,255,170,${l(u)?i:a})`),borderColor:s.map((d,u)=>`rgba(34,255,170,${l(u)?"0.35":"1"})`),borderWidth:1,borderRadius:0,borderSkipped:!1},{label:"error",data:s.map(d=>Number(d?.error||0)),stack:"outcomes",backgroundColor:s.map((d,u)=>`rgba(255,74,138,${l(u)?i:a})`),borderColor:s.map((d,u)=>`rgba(255,74,138,${l(u)?"0.35":"1"})`),borderWidth:1,borderRadius:0,borderSkipped:!1},{label:"skipped",data:s.map(d=>Number(d?.skipped||0)),stack:"outcomes",backgroundColor:s.map((d,u)=>`rgba(255,214,64,${l(u)?i:a})`),borderColor:s.map((d,u)=>`rgba(255,214,64,${l(u)?"0.35":"1"})`),borderWidth:1,borderRadius:0,borderSkipped:!1}]};let c=s.map(d=>Number(e===Di?d?.totalTokens||0:e===Ds?d?.totalCost||0:d?.avgDurationMs||0));return{labels:r,datasets:[{label:e===Di?"tokens":e===Ds?"cost":"avg duration",data:c,backgroundColor:s.map((d,u)=>e===Di?`rgba(34,211,238,${l(u)?i:"0.72"})`:e===Ds?`rgba(167,139,250,${l(u)?i:"0.72"})`:`rgba(148,163,184,${l(u)?i:"0.72"})`),borderColor:s.map((d,u)=>e===Di?`rgba(34,211,238,${l(u)?"0.35":"1"})`:e===Ds?`rgba(167,139,250,${l(u)?"0.35":"1"})`:`rgba(148,163,184,${l(u)?"0.35":"1"})`),borderWidth:1,borderRadius:0,borderSkipped:!1}]}},w0=({trends:t=null,range:e=Np,onChangeRange:n=()=>{},selectedBucketFilter:s=null,onChangeSelectedBucketFilter:o=()=>{}})=>{let r=te(null),i=te(null),[a,l]=y(br),c=W(()=>Array.isArray(t?.points)?t.points.map((f,g)=>({...f,key:String(f?.key||`point:${g}:${f?.startMs||0}`)})):[],[t?.points]),d=W(()=>s&&c.find(g=>Number(g.startMs)===Number(s.startMs)&&Number(g.endMs)===Number(s.endMs))?.key||"",[c,s]),u=W(()=>c.some(f=>Number(f?.totalRuns||0)>0||Number(f?.totalTokens||0)>0||Number(f?.totalCost||0)>0||Number(f?.avgDurationMs||0)>0),[c]),p=W(()=>nP({trends:{...t,points:c},metric:a,selectedBucketKey:d}),[a,c,d,t]);return R(()=>{let f=r.current;if(!f||!ds)return;i.current&&(i.current.destroy(),i.current=null);let g=m=>{let h=c[m];return h?{key:h.key,label:es(h.startMs,{range:e,valueType:"epoch-ms"}),startMs:Number(h.startMs||0),endMs:Number(h.endMs||0),range:e}:null};return i.current=new ds(f,{type:"bar",data:p,options:{responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},animation:!1,onHover:(m,h)=>{let b=m?.native?.target;!b||!b.style||(b.style.cursor=Array.isArray(h)&&h.length>0?"pointer":"default")},onClick:(m,h)=>{let b=Number(h?.[0]?.index);if(!Number.isFinite(b))return;let x=g(b);if(x){if(x.key===d){o(null);return}o(x)}},scales:{x:{stacked:a===br,grid:{color:"rgba(148,163,184,0.08)"},ticks:{color:"rgba(156,163,175,1)",maxRotation:0,autoSkip:!0}},y:{stacked:a===br,beginAtZero:!0,grid:{color:"rgba(148,163,184,0.12)"},ticks:{precision:a===Ds?void 0:0,color:"rgba(156,163,175,1)",callback:m=>{let h=Number(m||0);return a===Ds?ct(h):a===Op?h>0?bn(h):"0":Oe(h)}}}},plugins:{legend:{position:"bottom",labels:{color:"rgba(209,213,219,1)",boxWidth:10,boxHeight:10}},tooltip:{callbacks:{title:m=>String(m?.[0]?.label||""),label:m=>{let h=Number(m.parsed.y||0);return a===Ds?`${m.dataset.label}: ${ct(h)}`:a===Op?`${m.dataset.label}: ${h>0?bn(h):"\u2014"}`:`${m.dataset.label}: ${Oe(h)}`},footer:m=>{let h=Number(m?.[0]?.dataIndex),b=c[h];if(!b)return"";let x=`runs: ${Oe(b.totalRuns||0)}`,v=`tokens: ${Oe(b.totalTokens||0)}`,$=`cost: ${ct(b.totalCost||0)}`;return`${x} +`):t}function $T(t,e){let{element:n,datasetIndex:s,index:o}=e,r=t.getDatasetMeta(s).controller,{label:i,value:a}=r.getLabelAndValue(o);return{chart:t,label:i,parsed:r.getParsed(o),raw:t.data.datasets[s].data[o],formattedValue:a,dataset:r.getDataset(),dataIndex:o,datasetIndex:s,element:n}}function W$(t,e){let n=t.chart.ctx,{body:s,footer:o,title:r}=t,{boxWidth:i,boxHeight:a}=e,l=bt(e.bodyFont),c=bt(e.titleFont),d=bt(e.footerFont),u=r.length,p=o.length,f=s.length,g=Nt(e.padding),m=g.height,h=0,x=s.reduce(($,w)=>$+w.before.length+w.lines.length+w.after.length,0);if(x+=t.beforeBody.length+t.afterBody.length,u&&(m+=u*c.lineHeight+(u-1)*e.titleSpacing+e.titleMarginBottom),x){let $=e.displayColors?Math.max(a,l.lineHeight):l.lineHeight;m+=f*$+(x-f)*l.lineHeight+(x-1)*e.bodySpacing}p&&(m+=e.footerMarginTop+p*d.lineHeight+(p-1)*e.footerSpacing);let b=0,v=function($){h=Math.max(h,n.measureText($).width+b)};return n.save(),n.font=c.string,Ke(t.title,v),n.font=l.string,Ke(t.beforeBody.concat(t.afterBody),v),b=e.displayColors?i+2+e.boxPadding:0,Ke(s,$=>{Ke($.before,v),Ke($.lines,v),Ke($.after,v)}),b=0,n.font=d.string,Ke(t.footer,v),n.restore(),h+=g.width,{width:h,height:m}}function wT(t,e){let{y:n,height:s}=e;return nt.height-s/2?"bottom":"center"}function kT(t,e,n,s){let{x:o,width:r}=s,i=n.caretSize+n.caretPadding;if(t==="left"&&o+r+i>e.width||t==="right"&&o-r-i<0)return!0}function ST(t,e,n,s){let{x:o,width:r}=n,{width:i,chartArea:{left:a,right:l}}=t,c="center";return s==="center"?c=o<=(a+l)/2?"left":"right":o<=r/2?c="left":o>=i-r/2&&(c="right"),kT(c,t,e,n)&&(c="center"),c}function H$(t,e,n){let s=n.yAlign||e.yAlign||wT(t,n);return{xAlign:n.xAlign||e.xAlign||ST(t,e,n,s),yAlign:s}}function CT(t,e){let{x:n,width:s}=t;return e==="right"?n-=s:e==="center"&&(n-=s/2),n}function _T(t,e,n){let{y:s,height:o}=t;return e==="top"?s+=n:e==="bottom"?s-=o+n:s-=o/2,s}function V$(t,e,n,s){let{caretSize:o,caretPadding:r,cornerRadius:i}=t,{xAlign:a,yAlign:l}=n,c=o+r,{topLeft:d,topRight:u,bottomLeft:p,bottomRight:f}=Is(i),g=CT(e,a),m=_T(e,l,c);return l==="center"?a==="left"?g+=c:a==="right"&&(g-=c):a==="left"?g-=Math.max(d,p)+o:a==="right"&&(g+=Math.max(u,f)+o),{x:wt(g,0,s.width-e.width),y:wt(m,0,s.height-e.height)}}function Zl(t,e,n){let s=Nt(n.padding);return e==="center"?t.x+t.width/2:e==="right"?t.x+t.width-s.right:t.x+s.left}function j$(t){return Wn([],ds(t))}function AT(t,e,n){return ls(t,{tooltip:e,tooltipItems:n,type:"tooltip"})}function z$(t,e){let n=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return n?t.override(n):t}var yw={beforeTitle:Bn,title(t){if(t.length>0){let e=t[0],n=e.chart.data.labels,s=n?n.length:0;if(this&&this.options&&this.options.mode==="dataset")return e.dataset.label||"";if(e.label)return e.label;if(s>0&&e.dataIndex"u"?yw[e].call(n,s):o}var ac=class extends kn{static positioners=Mi;constructor(e){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=e.chart,this.options=e.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(e){this.options=e,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){let e=this._cachedAnimations;if(e)return e;let n=this.chart,s=this.options.setContext(this.getContext()),o=s.enabled&&n.options.animation&&s.animations,r=new ec(this.chart,o);return o._cacheable&&(this._cachedAnimations=Object.freeze(r)),r}getContext(){return this.$context||(this.$context=AT(this.chart.getContext(),this,this._tooltipItems))}getTitle(e,n){let{callbacks:s}=n,o=Xt(s,"beforeTitle",this,e),r=Xt(s,"title",this,e),i=Xt(s,"afterTitle",this,e),a=[];return a=Wn(a,ds(o)),a=Wn(a,ds(r)),a=Wn(a,ds(i)),a}getBeforeBody(e,n){return j$(Xt(n.callbacks,"beforeBody",this,e))}getBody(e,n){let{callbacks:s}=n,o=[];return Ke(e,r=>{let i={before:[],lines:[],after:[]},a=z$(s,r);Wn(i.before,ds(Xt(a,"beforeLabel",this,r))),Wn(i.lines,Xt(a,"label",this,r)),Wn(i.after,ds(Xt(a,"afterLabel",this,r))),o.push(i)}),o}getAfterBody(e,n){return j$(Xt(n.callbacks,"afterBody",this,e))}getFooter(e,n){let{callbacks:s}=n,o=Xt(s,"beforeFooter",this,e),r=Xt(s,"footer",this,e),i=Xt(s,"afterFooter",this,e),a=[];return a=Wn(a,ds(o)),a=Wn(a,ds(r)),a=Wn(a,ds(i)),a}_createItems(e){let n=this._active,s=this.chart.data,o=[],r=[],i=[],a=[],l,c;for(l=0,c=n.length;le.filter(d,u,p,s))),e.itemSort&&(a=a.sort((d,u)=>e.itemSort(d,u,s))),Ke(a,d=>{let u=z$(e.callbacks,d);o.push(Xt(u,"labelColor",this,d)),r.push(Xt(u,"labelPointStyle",this,d)),i.push(Xt(u,"labelTextColor",this,d))}),this.labelColors=o,this.labelPointStyles=r,this.labelTextColors=i,this.dataPoints=a,a}update(e,n){let s=this.options.setContext(this.getContext()),o=this._active,r,i=[];if(!o.length)this.opacity!==0&&(r={opacity:0});else{let a=Mi[s.position].call(this,o,this._eventPosition);i=this._createItems(s),this.title=this.getTitle(i,s),this.beforeBody=this.getBeforeBody(i,s),this.body=this.getBody(i,s),this.afterBody=this.getAfterBody(i,s),this.footer=this.getFooter(i,s);let l=this._size=W$(this,s),c=Object.assign({},a,l),d=H$(this.chart,s,c),u=V$(s,c,d,this.chart);this.xAlign=d.xAlign,this.yAlign=d.yAlign,r={opacity:1,x:u.x,y:u.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=i,this.$context=void 0,r&&this._resolveAnimations().update(this,r),e&&s.external&&s.external.call(this,{chart:this.chart,tooltip:this,replay:n})}drawCaret(e,n,s,o){let r=this.getCaretPosition(e,s,o);n.lineTo(r.x1,r.y1),n.lineTo(r.x2,r.y2),n.lineTo(r.x3,r.y3)}getCaretPosition(e,n,s){let{xAlign:o,yAlign:r}=this,{caretSize:i,cornerRadius:a}=s,{topLeft:l,topRight:c,bottomLeft:d,bottomRight:u}=Is(a),{x:p,y:f}=e,{width:g,height:m}=n,h,x,b,v,$,w;return r==="center"?($=f+m/2,o==="left"?(h=p,x=h-i,v=$+i,w=$-i):(h=p+g,x=h+i,v=$-i,w=$+i),b=h):(o==="left"?x=p+Math.max(l,d)+i:o==="right"?x=p+g-Math.max(c,u)-i:x=this.caretX,r==="top"?(v=f,$=v-i,h=x-i,b=x+i):(v=f+m,$=v+i,h=x+i,b=x-i),w=v),{x1:h,x2:x,x3:b,y1:v,y2:$,y3:w}}drawTitle(e,n,s){let o=this.title,r=o.length,i,a,l;if(r){let c=lo(s.rtl,this.x,this.width);for(e.x=Zl(this,s.titleAlign,s),n.textAlign=c.textAlign(s.titleAlign),n.textBaseline="middle",i=bt(s.titleFont),a=s.titleSpacing,n.fillStyle=s.titleColor,n.font=i.string,l=0;lb!==0)?(e.beginPath(),e.fillStyle=r.multiKeyBackground,dr(e,{x:m,y:g,w:c,h:l,radius:x}),e.fill(),e.stroke(),e.fillStyle=i.backgroundColor,e.beginPath(),dr(e,{x:h,y:g+1,w:c-2,h:l-2,radius:x}),e.fill()):(e.fillStyle=r.multiKeyBackground,e.fillRect(m,g,c,l),e.strokeRect(m,g,c,l),e.fillStyle=i.backgroundColor,e.fillRect(h,g+1,c-2,l-2))}e.fillStyle=this.labelTextColors[s]}drawBody(e,n,s){let{body:o}=this,{bodySpacing:r,bodyAlign:i,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:d}=s,u=bt(s.bodyFont),p=u.lineHeight,f=0,g=lo(s.rtl,this.x,this.width),m=function(_){n.fillText(_,g.x(e.x+f),e.y+p/2),e.y+=p+r},h=g.textAlign(i),x,b,v,$,w,S,C;for(n.textAlign=i,n.textBaseline="middle",n.font=u.string,e.x=Zl(this,h,s),n.fillStyle=s.bodyColor,Ke(this.beforeBody,m),f=a&&h!=="right"?i==="center"?c/2+d:c+2+d:0,$=0,S=o.length;$0&&n.stroke()}_updateAnimationTarget(e){let n=this.chart,s=this.$animations,o=s&&s.x,r=s&&s.y;if(o||r){let i=Mi[e.position].call(this,this._active,this._eventPosition);if(!i)return;let a=this._size=W$(this,e),l=Object.assign({},i,this._size),c=H$(n,e,l),d=V$(e,l,c,n);(o._to!==d.x||r._to!==d.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=i.x,this.caretY=i.y,this._resolveAnimations().update(this,d))}}_willRender(){return!!this.opacity}draw(e){let n=this.options.setContext(this.getContext()),s=this.opacity;if(!s)return;this._updateAnimationTarget(n);let o={width:this.width,height:this.height},r={x:this.x,y:this.y};s=Math.abs(s)<.001?0:s;let i=Nt(n.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;n.enabled&&a&&(e.save(),e.globalAlpha=s,this.drawBackground(r,e,o,n),Uu(e,n.textDirection),r.y+=i.top,this.drawTitle(r,e,n),this.drawBody(r,e,n),this.drawFooter(r,e,n),Ku(e,n.textDirection),e.restore())}getActiveElements(){return this._active||[]}setActiveElements(e,n){let s=this._active,o=e.map(({datasetIndex:a,index:l})=>{let c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),r=!xi(s,o),i=this._positionChanged(o,n);(r||i)&&(this._active=o,this._eventPosition=n,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(e,n,s=!0){if(n&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let o=this.options,r=this._active||[],i=this._getActiveElements(e,r,n,s),a=this._positionChanged(i,e),l=n||!xi(i,r)||a;return l&&(this._active=i,(o.enabled||o.external)&&(this._eventPosition={x:e.x,y:e.y},this.update(!0,n))),l}_getActiveElements(e,n,s,o){let r=this.options;if(e.type==="mouseout")return[];if(!o)return n.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);let i=this.chart.getElementsAtEventForMode(e,r.mode,r,s);return r.reverse&&i.reverse(),i}_positionChanged(e,n){let{caretX:s,caretY:o,options:r}=this,i=Mi[r.position].call(this,e,n);return i!==!1&&(s!==i.x||o!==i.y)}},MT={id:"tooltip",_element:ac,positioners:Mi,afterInit(t,e,n){n&&(t.tooltip=new ac({chart:t,options:n}))},beforeUpdate(t,e,n){t.tooltip&&t.tooltip.initialize(n)},reset(t,e,n){t.tooltip&&t.tooltip.initialize(n)},afterDraw(t){let e=t.tooltip;if(e&&e._willRender()){let n={tooltip:e};if(t.notifyPlugins("beforeTooltipDraw",{...n,cancelable:!0})===!1)return;e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",n)}},afterEvent(t,e){if(t.tooltip){let n=e.replay;t.tooltip.handleEvent(e.event,n,e.inChartArea)&&(e.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:yw},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:t=>t!=="filter"&&t!=="itemSort"&&t!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},TT=Object.freeze({__proto__:null,Colors:HM,Decimation:UM,Filler:uT,Legend:bT,SubTitle:vT,Title:yT,Tooltip:MT}),PT=(t,e,n,s)=>(typeof e=="string"?(n=t.push(e)-1,s.unshift({index:n,label:e})):isNaN(e)&&(n=null),n);function RT(t,e,n,s){let o=t.indexOf(e);if(o===-1)return PT(t,e,n,s);let r=t.lastIndexOf(e);return o!==r?n:o}var LT=(t,e)=>t===null?null:wt(Math.round(t),0,e);function U$(t){let e=this.getLabels();return t>=0&&tn.length-1?null:this.getPixelForValue(n[e].value)}getValueForPixel(e){return Math.round(this._startValue+this.getDecimalForPixel(e)*this._valueRange)}getBasePixel(){return this.bottom}};function ET(t,e){let n=[],{bounds:o,step:r,min:i,max:a,precision:l,count:c,maxTicks:d,maxDigits:u,includeBounds:p}=t,f=r||1,g=d-1,{min:m,max:h}=e,x=!Me(i),b=!Me(a),v=!Me(c),$=(h-m)/(u+1),w=Su((h-m)/g/f)*f,S,C,_,k;if(w<1e-14&&!x&&!b)return[{value:m},{value:h}];k=Math.ceil(h/w)-Math.floor(m/w),k>g&&(w=Su(k*w/g/f)*f),Me(l)||(S=Math.pow(10,l),w=Math.ceil(w*S)/S),o==="ticks"?(C=Math.floor(m/w)*w,_=Math.ceil(h/w)*w):(C=m,_=h),x&&b&&r&&Lv((a-i)/r,w/1e3)?(k=Math.round(Math.min((a-i)/w,d)),w=(a-i)/k,C=i,_=a):v?(C=x?i:C,_=b?a:_,k=c-1,w=(_-C)/k):(k=(_-C)/w,ar(k,Math.round(k),w/1e3)?k=Math.round(k):k=Math.ceil(k));let A=Math.max(_u(w),_u(C));S=Math.pow(10,Me(l)?A:l),C=Math.round(C*S)/S,_=Math.round(_*S)/S;let D=0;for(x&&(p&&C!==i?(n.push({value:i}),Ca)break;n.push({value:N})}return b&&p&&_!==a?n.length&&ar(n[n.length-1].value,a,K$(a,$,t))?n[n.length-1].value=a:n.push({value:a}):(!b||_===a)&&n.push({value:_}),n}function K$(t,e,{horizontal:n,minRotation:s}){let o=pn(s),r=(n?Math.sin(o):Math.cos(o))||.001,i=.75*e*(""+t).length;return Math.min(e/r,i)}var gr=class extends po{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(e,n){return Me(e)||(typeof e=="number"||e instanceof Number)&&!isFinite(+e)?null:+e}handleTickRangeOptions(){let{beginAtZero:e}=this.options,{minDefined:n,maxDefined:s}=this.getUserBounds(),{min:o,max:r}=this,i=l=>o=n?o:l,a=l=>r=s?r:l;if(e){let l=wn(o),c=wn(r);l<0&&c<0?a(0):l>0&&c>0&&i(0)}if(o===r){let l=r===0?1:Math.abs(r*.05);a(r+l),e||i(o-l)}this.min=o,this.max=r}getTickLimit(){let e=this.options.ticks,{maxTicksLimit:n,stepSize:s}=e,o;return s?(o=Math.ceil(this.max/s)-Math.floor(this.min/s)+1,o>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${o} ticks. Limiting to 1000.`),o=1e3)):(o=this.computeTickLimit(),n=n||11),n&&(o=Math.min(n,o)),o}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){let e=this.options,n=e.ticks,s=this.getTickLimit();s=Math.max(2,s);let o={maxTicks:s,bounds:e.bounds,min:e.min,max:e.max,precision:n.precision,step:n.stepSize,count:n.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:n.minRotation||0,includeBounds:n.includeBounds!==!1},r=this._range||this,i=ET(o,r);return e.bounds==="ticks"&&Cu(i,this,"value"),e.reverse?(i.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),i}configure(){let e=this.ticks,n=this.min,s=this.max;if(super.configure(),this.options.offset&&e.length){let o=(s-n)/Math.max(e.length-1,1)/2;n-=o,s+=o}this._startValue=n,this._endValue=s,this._valueRange=s-n}getLabelForValue(e){return cr(e,this.chart.options.locale,this.options.ticks.format)}},Pp=class extends gr{static id="linear";static defaults={ticks:{callback:yi.formatters.numeric}};determineDataLimits(){let{min:e,max:n}=this.getMinMax(!0);this.min=dt(e)?e:0,this.max=dt(n)?n:1,this.handleTickRangeOptions()}computeTickLimit(){let e=this.isHorizontal(),n=e?this.width:this.height,s=pn(this.options.ticks.minRotation),o=(e?Math.sin(s):Math.cos(s))||.001,r=this._resolveTickFontOptions(0);return Math.ceil(n/Math.min(40,r.lineHeight/o))}getPixelForValue(e){return e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getValueForPixel(e){return this._startValue+this.getDecimalForPixel(e)*this._valueRange}},Li=t=>Math.floor(is(t)),uo=(t,e)=>Math.pow(10,Li(t)+e);function G$(t){return t/Math.pow(10,Li(t))===1}function q$(t,e,n){let s=Math.pow(10,n),o=Math.floor(t/s);return Math.ceil(e/s)-o}function IT(t,e){let n=e-t,s=Li(n);for(;q$(t,e,s)>10;)s++;for(;q$(t,e,s)<10;)s--;return Math.min(s,Li(t))}function DT(t,{min:e,max:n}){e=Yt(t.min,e);let s=[],o=Li(e),r=IT(e,n),i=r<0?Math.pow(10,Math.abs(r)):1,a=Math.pow(10,r),l=o>r?Math.pow(10,o):0,c=Math.round((e-l)*i)/i,d=Math.floor((e-l)/a/10)*a*10,u=Math.floor((c-d)/Math.pow(10,r)),p=Yt(t.min,Math.round((l+d+u*Math.pow(10,r))*i)/i);for(;p=10?u=u<15?15:20:u++,u>=20&&(r++,u=2,i=r>=0?1:i),p=Math.round((l+d+u*Math.pow(10,r))*i)/i;let f=Yt(t.max,p);return s.push({value:f,major:G$(f),significand:u}),s}var Rp=class extends po{static id="logarithmic";static defaults={ticks:{callback:yi.formatters.logarithmic,major:{enabled:!0}}};constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(e,n){let s=gr.prototype.parse.apply(this,[e,n]);if(s===0){this._zero=!0;return}return dt(s)&&s>0?s:null}determineDataLimits(){let{min:e,max:n}=this.getMinMax(!0);this.min=dt(e)?Math.max(0,e):null,this.max=dt(n)?Math.max(0,n):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!dt(this._userMin)&&(this.min=e===uo(this.min,0)?uo(this.min,-1):uo(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:e,maxDefined:n}=this.getUserBounds(),s=this.min,o=this.max,r=a=>s=e?s:a,i=a=>o=n?o:a;s===o&&(s<=0?(r(1),i(10)):(r(uo(s,-1)),i(uo(o,1)))),s<=0&&r(uo(o,-1)),o<=0&&i(uo(s,1)),this.min=s,this.max=o}buildTicks(){let e=this.options,n={min:this._userMin,max:this._userMax},s=DT(n,this);return e.bounds==="ticks"&&Cu(s,this,"value"),e.reverse?(s.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),s}getLabelForValue(e){return e===void 0?"0":cr(e,this.chart.options.locale,this.options.ticks.format)}configure(){let e=this.min;super.configure(),this._startValue=is(e),this._valueRange=is(this.max)-is(e)}getPixelForValue(e){return(e===void 0||e===0)&&(e=this.min),e===null||isNaN(e)?NaN:this.getPixelForDecimal(e===this.min?0:(is(e)-this._startValue)/this._valueRange)}getValueForPixel(e){let n=this.getDecimalForPixel(e);return Math.pow(10,this._startValue+n*this._valueRange)}};function Lp(t){let e=t.ticks;if(e.display&&t.display){let n=Nt(e.backdropPadding);return Se(e.font&&e.font.size,st.font.size)+n.height}return 0}function NT(t,e,n){return n=et(n)?n:[n],{w:Hv(t,e.string,n),h:n.length*e.lineHeight}}function J$(t,e,n,s,o){return t===s||t===o?{start:e-n/2,end:e+n/2}:to?{start:e-n,end:e}:{start:e,end:e+n}}function OT(t){let e={l:t.left+t._padding.left,r:t.right-t._padding.right,t:t.top+t._padding.top,b:t.bottom-t._padding.bottom},n=Object.assign({},e),s=[],o=[],r=t._pointLabels.length,i=t.options.pointLabels,a=i.centerPointLabels?He/r:0;for(let l=0;le.r&&(a=(s.end-e.r)/r,t.r=Math.max(t.r,e.r+a)),o.starte.b&&(l=(o.end-e.b)/i,t.b=Math.max(t.b,e.b+l))}function FT(t,e,n){let s=t.drawingArea,{extra:o,additionalAngle:r,padding:i,size:a}=n,l=t.getPointPosition(e,s+o+i,r),c=Math.round(Nl(It(l.angle+ft))),d=zT(l.y,a.h,c),u=VT(c),p=jT(l.x,a.w,u);return{visible:!0,x:l.x,y:d,textAlign:u,left:p,top:d,right:p+a.w,bottom:d+a.h}}function WT(t,e){if(!e)return!0;let{left:n,top:s,right:o,bottom:r}=t;return!(On({x:n,y:s},e)||On({x:n,y:r},e)||On({x:o,y:s},e)||On({x:o,y:r},e))}function HT(t,e,n){let s=[],o=t._pointLabels.length,r=t.options,{centerPointLabels:i,display:a}=r.pointLabels,l={extra:Lp(r)/2,additionalAngle:i?He/o:0},c;for(let d=0;d270||n<90)&&(t-=e),t}function UT(t,e,n){let{left:s,top:o,right:r,bottom:i}=n,{backdropColor:a}=e;if(!Me(a)){let l=Is(e.borderRadius),c=Nt(e.backdropPadding);t.fillStyle=a;let d=s-c.left,u=o-c.top,p=r-s+c.width,f=i-o+c.height;Object.values(l).some(g=>g!==0)?(t.beginPath(),dr(t,{x:d,y:u,w:p,h:f,radius:l}),t.fill()):t.fillRect(d,u,p,f)}}function KT(t,e){let{ctx:n,options:{pointLabels:s}}=t;for(let o=e-1;o>=0;o--){let r=t._pointLabelItems[o];if(!r.visible)continue;let i=s.setContext(t.getPointLabelContext(o));UT(n,i,r);let a=bt(i.font),{x:l,y:c,textAlign:d}=r;Es(n,t._pointLabels[o],l,c+a.lineHeight/2,a,{color:i.color,textAlign:d,textBaseline:"middle"})}}function vw(t,e,n,s){let{ctx:o}=t;if(n)o.arc(t.xCenter,t.yCenter,e,0,tt);else{let r=t.getPointPosition(0,e);o.moveTo(r.x,r.y);for(let i=1;i{let o=Ye(this.options.pointLabels.callback,[n,s],this);return o||o===0?o:""}).filter((n,s)=>this.chart.getDataVisibility(s))}fit(){let e=this.options;e.display&&e.pointLabels.display?OT(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(e,n,s,o){this.xCenter+=Math.floor((e-n)/2),this.yCenter+=Math.floor((s-o)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(e,n,s,o))}getIndexAngle(e){let n=tt/(this._pointLabels.length||1),s=this.options.startAngle||0;return It(e*n+pn(s))}getDistanceFromCenterForValue(e){if(Me(e))return NaN;let n=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-e)*n:(e-this.min)*n}getValueForDistanceFromCenter(e){if(Me(e))return NaN;let n=e/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-n:this.min+n}getPointLabelContext(e){let n=this._pointLabels||[];if(e>=0&&e{if(u!==0||u===0&&this.min<0){l=this.getDistanceFromCenterForValue(d.value);let p=this.getContext(u),f=o.setContext(p),g=r.setContext(p);GT(this,f,l,i,g)}}),s.display){for(e.save(),a=i-1;a>=0;a--){let d=s.setContext(this.getPointLabelContext(a)),{color:u,lineWidth:p}=d;!p||!u||(e.lineWidth=p,e.strokeStyle=u,e.setLineDash(d.borderDash),e.lineDashOffset=d.borderDashOffset,l=this.getDistanceFromCenterForValue(n.reverse?this.min:this.max),c=this.getPointPosition(a,l),e.beginPath(),e.moveTo(this.xCenter,this.yCenter),e.lineTo(c.x,c.y),e.stroke())}e.restore()}}drawBorder(){}drawLabels(){let e=this.ctx,n=this.options,s=n.ticks;if(!s.display)return;let o=this.getIndexAngle(0),r,i;e.save(),e.translate(this.xCenter,this.yCenter),e.rotate(o),e.textAlign="center",e.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&this.min>=0&&!n.reverse)return;let c=s.setContext(this.getContext(l)),d=bt(c.font);if(r=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){e.font=d.string,i=e.measureText(a.label).width,e.fillStyle=c.backdropColor;let u=Nt(c.backdropPadding);e.fillRect(-i/2-u.left,-r-d.size/2-u.top,i+u.width,d.size+u.height)}Es(e,a.label,0,-r,d,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),e.restore()}drawTitle(){}},cc={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Qt=Object.keys(cc);function Z$(t,e){return t-e}function Y$(t,e){if(Me(e))return null;let n=t._adapter,{parser:s,round:o,isoWeekday:r}=t._parseOpts,i=e;return typeof s=="function"&&(i=s(i)),dt(i)||(i=typeof s=="string"?n.parse(i,s):n.parse(i)),i===null?null:(o&&(i=o==="week"&&(ao(r)||r===!0)?n.startOf(i,"isoWeek",r):n.startOf(i,o)),+i)}function X$(t,e,n,s){let o=Qt.length;for(let r=Qt.indexOf(t);r=Qt.indexOf(n);r--){let i=Qt[r];if(cc[i].common&&t._adapter.diff(o,s,i)>=e-1)return i}return Qt[n?Qt.indexOf(n):0]}function ZT(t){for(let e=Qt.indexOf(t)+1,n=Qt.length;e=e?n[s]:n[o];t[r]=!0}}function YT(t,e,n,s){let o=t._adapter,r=+o.startOf(e[0].value,s),i=e[e.length-1].value,a,l;for(a=r;a<=i;a=+o.add(a,1,s))l=n[a],l>=0&&(e[l].major=!0);return e}function ew(t,e,n){let s=[],o={},r=e.length,i,a;for(i=0;i+e.value))}initOffsets(e=[]){let n=0,s=0,o,r;this.options.offset&&e.length&&(o=this.getDecimalForValue(e[0]),e.length===1?n=1-o:n=(this.getDecimalForValue(e[1])-o)/2,r=this.getDecimalForValue(e[e.length-1]),e.length===1?s=r:s=(r-this.getDecimalForValue(e[e.length-2]))/2);let i=e.length<3?.5:.25;n=wt(n,0,i),s=wt(s,0,i),this._offsets={start:n,end:s,factor:1/(n+1+s)}}_generate(){let e=this._adapter,n=this.min,s=this.max,o=this.options,r=o.time,i=r.unit||X$(r.minUnit,n,s,this._getLabelCapacity(n)),a=Se(o.ticks.stepSize,1),l=i==="week"?r.isoWeekday:!1,c=ao(l)||l===!0,d={},u=n,p,f;if(c&&(u=+e.startOf(u,"isoWeek",l)),u=+e.startOf(u,c?"day":i),e.diff(s,n,i)>1e5*a)throw new Error(n+" and "+s+" are too far apart with stepSize of "+a+" "+i);let g=o.ticks.source==="data"&&this.getDataTimestamps();for(p=u,f=0;p+m)}getLabelForValue(e){let n=this._adapter,s=this.options.time;return s.tooltipFormat?n.format(e,s.tooltipFormat):n.format(e,s.displayFormats.datetime)}format(e,n){let o=this.options.time.displayFormats,r=this._unit,i=n||o[r];return this._adapter.format(e,i)}_tickFormatFunction(e,n,s,o){let r=this.options,i=r.ticks.callback;if(i)return Ye(i,[e,n,s],this);let a=r.time.displayFormats,l=this._unit,c=this._majorUnit,d=l&&a[l],u=c&&a[c],p=s[n],f=c&&u&&p&&p.major;return this._adapter.format(e,o||(f?u:d))}generateTickLabels(e){let n,s,o;for(n=0,s=e.length;n0?a:1}getDataTimestamps(){let e=this._cache.data||[],n,s;if(e.length)return e;let o=this.getMatchingVisibleMetas();if(this._normalized&&o.length)return this._cache.data=o[0].controller.getAllParsedValues(this);for(n=0,s=o.length;n=t[s].pos&&e<=t[o].pos&&({lo:s,hi:o}=Nn(t,"pos",e)),{pos:r,time:a}=t[s],{pos:i,time:l}=t[o]):(e>=t[s].time&&e<=t[o].time&&({lo:s,hi:o}=Nn(t,"time",e)),{time:r,pos:a}=t[s],{time:i,pos:l}=t[o]);let c=i-r;return c?a+(l-a)*(e-r)/c:a}var Ip=class extends Ei{static id="timeseries";static defaults=Ei.defaults;constructor(e){super(e),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let e=this._getTimestampsForTable(),n=this._table=this.buildLookupTable(e);this._minPos=Yl(n,this.min),this._tableRange=Yl(n,this.max)-this._minPos,super.initOffsets(e)}buildLookupTable(e){let{min:n,max:s}=this,o=[],r=[],i,a,l,c,d;for(i=0,a=e.length;i=n&&c<=s&&o.push(c);if(o.length<2)return[{time:n,pos:0},{time:s,pos:1}];for(i=0,a=o.length;io-r)}_getTimestampsForTable(){let e=this._cache.all||[];if(e.length)return e;let n=this.getDataTimestamps(),s=this.getLabelTimestamps();return n.length&&s.length?e=this.normalize(n.concat(s)):e=n.length?n:s,e=this._cache.all=e,e}getDecimalForValue(e){return(Yl(this._table,e)-this._minPos)/this._tableRange}getValueForPixel(e){let n=this._offsets,s=this.getDecimalForPixel(e)/n.factor-n.end;return Yl(this._table,s*this._tableRange+this._minPos,!0)}},XT=Object.freeze({__proto__:null,CategoryScale:Tp,LinearScale:Pp,LogarithmicScale:Rp,RadialLinearScale:Ep,TimeScale:Ei,TimeSeriesScale:Ip}),$w=[cA,IM,TT,XT];hr.register(...$w);var us=hr;var Dp=P.bind(T),br="outcomes",Di="tokens",Np="duration",Os="cost",QT="24h",Op="7d",eP="30d",tP=[{label:"24h",value:QT},{label:"7d",value:Op},{label:"30d",value:eP}],nP=[{label:"outcomes",value:br},{label:"tokens",value:Di},{label:"duration",value:Np},{label:"cost",value:Os}],sP=({trends:t=null,metric:e=br,selectedBucketKey:n=""}={})=>{let s=Array.isArray(t?.points)?t.points:[],o=String(t?.range||Op),r=s.map(d=>ts(d.startMs,{range:o,valueType:"epoch-ms"})),i="0.22",a="0.86",l=d=>n&&String(s[d]?.key||"")!==n;if(e===br)return{labels:r,datasets:[{label:"ok",data:s.map(d=>Number(d?.ok||0)),stack:"outcomes",backgroundColor:s.map((d,u)=>`rgba(34,255,170,${l(u)?i:a})`),borderColor:s.map((d,u)=>`rgba(34,255,170,${l(u)?"0.35":"1"})`),borderWidth:1,borderRadius:0,borderSkipped:!1},{label:"error",data:s.map(d=>Number(d?.error||0)),stack:"outcomes",backgroundColor:s.map((d,u)=>`rgba(255,74,138,${l(u)?i:a})`),borderColor:s.map((d,u)=>`rgba(255,74,138,${l(u)?"0.35":"1"})`),borderWidth:1,borderRadius:0,borderSkipped:!1},{label:"skipped",data:s.map(d=>Number(d?.skipped||0)),stack:"outcomes",backgroundColor:s.map((d,u)=>`rgba(255,214,64,${l(u)?i:a})`),borderColor:s.map((d,u)=>`rgba(255,214,64,${l(u)?"0.35":"1"})`),borderWidth:1,borderRadius:0,borderSkipped:!1}]};let c=s.map(d=>Number(e===Di?d?.totalTokens||0:e===Os?d?.totalCost||0:d?.avgDurationMs||0));return{labels:r,datasets:[{label:e===Di?"tokens":e===Os?"cost":"avg duration",data:c,backgroundColor:s.map((d,u)=>e===Di?`rgba(34,211,238,${l(u)?i:"0.72"})`:e===Os?`rgba(167,139,250,${l(u)?i:"0.72"})`:`rgba(148,163,184,${l(u)?i:"0.72"})`),borderColor:s.map((d,u)=>e===Di?`rgba(34,211,238,${l(u)?"0.35":"1"})`:e===Os?`rgba(167,139,250,${l(u)?"0.35":"1"})`:`rgba(148,163,184,${l(u)?"0.35":"1"})`),borderWidth:1,borderRadius:0,borderSkipped:!1}]}},ww=({trends:t=null,range:e=Op,onChangeRange:n=()=>{},selectedBucketFilter:s=null,onChangeSelectedBucketFilter:o=()=>{}})=>{let r=te(null),i=te(null),[a,l]=y(br),c=F(()=>Array.isArray(t?.points)?t.points.map((f,g)=>({...f,key:String(f?.key||`point:${g}:${f?.startMs||0}`)})):[],[t?.points]),d=F(()=>s&&c.find(g=>Number(g.startMs)===Number(s.startMs)&&Number(g.endMs)===Number(s.endMs))?.key||"",[c,s]),u=F(()=>c.some(f=>Number(f?.totalRuns||0)>0||Number(f?.totalTokens||0)>0||Number(f?.totalCost||0)>0||Number(f?.avgDurationMs||0)>0),[c]),p=F(()=>sP({trends:{...t,points:c},metric:a,selectedBucketKey:d}),[a,c,d,t]);return L(()=>{let f=r.current;if(!f||!us)return;i.current&&(i.current.destroy(),i.current=null);let g=m=>{let h=c[m];return h?{key:h.key,label:ts(h.startMs,{range:e,valueType:"epoch-ms"}),startMs:Number(h.startMs||0),endMs:Number(h.endMs||0),range:e}:null};return i.current=new us(f,{type:"bar",data:p,options:{responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},animation:!1,onHover:(m,h)=>{let x=m?.native?.target;!x||!x.style||(x.style.cursor=Array.isArray(h)&&h.length>0?"pointer":"default")},onClick:(m,h)=>{let x=Number(h?.[0]?.index);if(!Number.isFinite(x))return;let b=g(x);if(b){if(b.key===d){o(null);return}o(b)}},scales:{x:{stacked:a===br,grid:{color:"rgba(148,163,184,0.08)"},ticks:{color:"rgba(156,163,175,1)",maxRotation:0,autoSkip:!0}},y:{stacked:a===br,beginAtZero:!0,grid:{color:"rgba(148,163,184,0.12)"},ticks:{precision:a===Os?void 0:0,color:"rgba(156,163,175,1)",callback:m=>{let h=Number(m||0);return a===Os?ct(h):a===Np?h>0?bn(h):"0":Ne(h)}}}},plugins:{legend:{position:"bottom",labels:{color:"rgba(209,213,219,1)",boxWidth:10,boxHeight:10}},tooltip:{callbacks:{title:m=>String(m?.[0]?.label||""),label:m=>{let h=Number(m.parsed.y||0);return a===Os?`${m.dataset.label}: ${ct(h)}`:a===Np?`${m.dataset.label}: ${h>0?bn(h):"\u2014"}`:`${m.dataset.label}: ${Ne(h)}`},footer:m=>{let h=Number(m?.[0]?.dataIndex),x=c[h];if(!x)return"";let b=`runs: ${Ne(x.totalRuns||0)}`,v=`tokens: ${Ne(x.totalTokens||0)}`,$=`cost: ${ct(x.totalCost||0)}`;return`${b} ${v} ${$}`}}}}}}),()=>{i.current&&(i.current.destroy(),i.current=null)}},[p,a,o,c,e,d,t?.bucket]),Dp`
@@ -4504,12 +4504,12 @@ ${$}`}}}}}}),()=>{i.current&&(i.current.destroy(),i.current=null)}},[p,a,o,c,e,d

Trends

<${nt} - options=${tP} + options=${nP} value=${a} onChange=${l} /> <${nt} - options=${eP} + options=${tP} value=${e} onChange=${n} /> @@ -4521,7 +4521,7 @@ ${$}`}}}}}}),()=>{i.current&&(i.current.destroy(),i.current=null)}},[p,a,o,c,e,d
`:Dp`
No run data in this window yet.
`}
- `};var Mt=P.bind(T),sP=(t="")=>{let e=String(t||"").trim().toLowerCase();return e==="ok"?"text-status-success":e==="error"?"text-status-error":e==="skipped"?"text-status-warning":"text-fg-muted"},oP=t=>String(t?.deliveryStatus||"not-requested"),Fp=t=>Qn(t,{fallback:"\u2014",valueIsEpochMs:!0}).replace(/\s([AP])M\b/g,(e,n)=>`${String(n||"").toLowerCase()}m`),rP=t=>Qn(t,{fallback:"\u2014",valueIsEpochMs:!0}),Bp=(t,e="overview")=>e==="detail"?rP(t):Fp(t),iP=({runEntry:t={},variant:e="overview"})=>{let n=String(t?.status||"unknown"),s=rn(t),o=$n(t),r=String(t?.jobName||"").trim(),i=r.length>0,a=e==="detail";return Mt` + `};var Mt=P.bind(T),oP=(t="")=>{let e=String(t||"").trim().toLowerCase();return e==="ok"?"text-status-success":e==="error"?"text-status-error":e==="skipped"?"text-status-warning":"text-fg-muted"},rP=t=>String(t?.deliveryStatus||"not-requested"),Fp=t=>es(t,{fallback:"\u2014",valueIsEpochMs:!0}).replace(/\s([AP])M\b/g,(e,n)=>`${String(n||"").toLowerCase()}m`),iP=t=>es(t,{fallback:"\u2014",valueIsEpochMs:!0}),Bp=(t,e="overview")=>e==="detail"?iP(t):Fp(t),aP=({runEntry:t={},variant:e="overview"})=>{let n=String(t?.status||"unknown"),s=rn(t),o=$n(t),r=String(t?.jobName||"").trim(),i=r.length>0,a=e==="detail";return Mt`
${a?Mt` @@ -4545,13 +4545,13 @@ ${$}`}}}}}}),()=>{i.current&&(i.current.destroy(),i.current=null)}},[p,a,o,c,e,d `} - ${n} + ${n} ${bn(t.durationMs)} - ${Oe(s)} tk + ${Ne(s)} tk ${a?Mt`${oP(t)}${rP(t)}`:Mt` ${o==null?"\u2014":`~${ct(o)}`} @@ -4559,7 +4559,7 @@ ${$}`}}}}}}),()=>{i.current&&(i.current.destroy(),i.current=null)}},[p,a,o,c,e,d `}
- `},aP=(t=[])=>t.reduce((e,n)=>{e.totalTokens+=rn(n);let s=$n(n);return s!=null&&(e.totalCost+=s,e.hasAnyCost=!0),e},{totalTokens:0,totalCost:0,hasAnyCost:!1}),lP=({row:t,rowIndex:e,onSelectJob:n=()=>{}})=>{let s=Array.isArray(t?.entries)?t.entries:[],{totalTokens:o,totalCost:r,hasAnyCost:i}=aP(s),a=`${Fp(t.oldestTs)} - ${Fp(t.newestTs)}`;return Mt` + `},lP=(t=[])=>t.reduce((e,n)=>{e.totalTokens+=rn(n);let s=$n(n);return s!=null&&(e.totalCost+=s,e.hasAnyCost=!0),e},{totalTokens:0,totalCost:0,hasAnyCost:!1}),cP=({row:t,rowIndex:e,onSelectJob:n=()=>{}})=>{let s=Array.isArray(t?.entries)?t.entries:[],{totalTokens:o,totalCost:r,hasAnyCost:i}=lP(s),a=`${Fp(t.oldestTs)} - ${Fp(t.newestTs)}`;return Mt`
{i.current&&(i.current.destroy(),i.current=null)}},[p,a,o,c,e,d - ${t.jobName} - ${Oe(t.count)} runs + ${t.jobName} - ${Ne(t.count)} runs ${a}{i.current&&(i.current.destroy(),i.current=null)}},[p,a,o,c,e,d ${Oe(o)} tk${Ne(o)} tk ${i?`~${ct(r)}`:"\u2014"} @@ -4590,7 +4590,7 @@ ${$}`}}}}}}),()=>{i.current&&(i.current.destroy(),i.current=null)}},[p,a,o,c,e,d
${s.length>0?Mt`
- ${s.map((l,c)=>k0({row:{type:"entry",entry:l},rowIndex:`${e}:${c}`,variant:"overview",onSelectJob:n,showOpenJobButton:!1,itemClassName:"ac-history-item ac-history-item-flat border-b border-border rounded-none"}))} + ${s.map((l,c)=>kw({row:{type:"entry",entry:l},rowIndex:`${e}:${c}`,variant:"overview",onSelectJob:n,showOpenJobButton:!1,itemClassName:"ac-history-item ac-history-item-flat border-b border-border rounded-none"}))}
`:null} ${t?.jobId?Mt` @@ -4606,7 +4606,7 @@ ${$}`}}}}}}),()=>{i.current&&(i.current.destroy(),i.current=null)}},[p,a,o,c,e,d `:null}
- `},k0=({row:t,rowIndex:e,variant:n="overview",onSelectJob:s=()=>{},showOpenJobButton:o=!1,itemClassName:r="ac-history-item"})=>{let i=t?.entry||t||{},a=i?.usage||{},l=Number(a?.input_tokens??a?.inputTokens??0),c=Number(a?.output_tokens??a?.outputTokens??0),d=rn(i),u=$n(i);return Mt` + `},kw=({row:t,rowIndex:e,variant:n="overview",onSelectJob:s=()=>{},showOpenJobButton:o=!1,itemClassName:r="ac-history-item"})=>{let i=t?.entry||t||{},a=i?.usage||{},l=Number(a?.input_tokens??a?.inputTokens??0),c=Number(a?.output_tokens??a?.outputTokens??0),d=rn(i),u=$n(i);return Mt`
{i.current&&(i.current.destroy(),i.current=null)}},[p,a,o,c,e,d
- ${iP({runEntry:i,variant:n})} + ${aP({runEntry:i,variant:n})}
@@ -4642,18 +4642,18 @@ ${$}`}}}}}}),()=>{i.current&&(i.current.destroy(),i.current=null)}},[p,a,o,c,e,d
Tokens in: ${Oe(l)}${Ne(l)}
Tokens out: ${Oe(c)}${Ne(c)}
Total tokens: - ${Oe(d)} + ${Ne(d)}
Total cost: @@ -4716,17 +4716,17 @@ ${$}`}}}}}}),()=>{i.current&&(i.current.destroy(),i.current=null)}},[p,a,o,c,e,d `:null} ${c.length===0?Mt`
${d}
`:Mt`
- ${c.map((m,h)=>m?.type==="collapsed-group"?lP({row:m,rowIndex:h,onSelectJob:p}):k0({row:m,rowIndex:h,variant:u,onSelectJob:p,showOpenJobButton:f}))} + ${c.map((m,h)=>m?.type==="collapsed-group"?cP({row:m,rowIndex:h,onSelectJob:p}):kw({row:m,rowIndex:h,variant:u,onSelectJob:p,showOpenJobButton:f}))}
`} ${g} -`;var S0=P.bind(T),C0="cronPromptEditorHeightPx",cP=280,dP=180,_0=t=>{let e=Number(t),n=Number.isFinite(e)?Math.round(e):cP;return Math.max(dP,n)},uP=t=>{if(!t)return 0;let e=Number.parseFloat(window.getComputedStyle(t).height||"0");return Number.isFinite(e)?e:0},A0=({promptValue:t="",savedPromptValue:e="",onChangePrompt:n=()=>{},onSaveChanges:s=()=>{}})=>{let o=te(null),r=te(null),i=te(null),a=te([]),l=te(null),c=te([]),[d,u]=y(()=>{let $=je();return _0($?.[C0])}),p=yl(t),f=!vl({contentLength:t.length,lineCount:p,charThreshold:gl,lineThreshold:bl}),g=W(()=>f?hl(t,"markdown"):[],[t,f]),m=Math.max(p,Array.isArray(g)?g.length:0),h=W(()=>Array.from({length:m},($,w)=>w+1),[m]),b=t!==e;$l({enabled:f,syncKey:`${t.length}:${g.length}`,editorLineNumberRowRefs:a,editorHighlightLineRefs:c});let x=$=>{let w=$.currentTarget.scrollTop;i.current&&(i.current.scrollTop=w),l.current&&(l.current.scrollTop=w)},v=$=>{if(($.metaKey||$.ctrlKey)&&$.key.toLowerCase()==="s"&&($.preventDefault(),s()),$.key==="Tab"){$.preventDefault();let w=r.current;if(!w)return;let S=w.selectionStart,C=w.selectionEnd,_=`${t.slice(0,S)} ${t.slice(C)}`;n(_),window.requestAnimationFrame(()=>{w.selectionStart=S+2,w.selectionEnd=S+2})}};return R(()=>{let $=o.current;if(!$||typeof ResizeObserver>"u")return()=>{};let w=null,S=new ResizeObserver(C=>{let _=C?.[0],k=_0(uP(_?.target));u(A=>Math.abs(A-k)>=1?k:A),w&&window.clearTimeout(w),w=window.setTimeout(()=>{let A=je();A[C0]=k,At(A)},120)});return S.observe($),()=>{S.disconnect(),w&&window.clearTimeout(w)}},[]),S0` +`;var Sw=P.bind(T),Cw="cronPromptEditorHeightPx",dP=280,uP=180,_w=t=>{let e=Number(t),n=Number.isFinite(e)?Math.round(e):dP;return Math.max(uP,n)},pP=t=>{if(!t)return 0;let e=Number.parseFloat(window.getComputedStyle(t).height||"0");return Number.isFinite(e)?e:0},Aw=({promptValue:t="",savedPromptValue:e="",onChangePrompt:n=()=>{},onSaveChanges:s=()=>{}})=>{let o=te(null),r=te(null),i=te(null),a=te([]),l=te(null),c=te([]),[d,u]=y(()=>{let $=je();return _w($?.[Cw])}),p=yl(t),f=!vl({contentLength:t.length,lineCount:p,charThreshold:gl,lineThreshold:bl}),g=F(()=>f?hl(t,"markdown"):[],[t,f]),m=Math.max(p,Array.isArray(g)?g.length:0),h=F(()=>Array.from({length:m},($,w)=>w+1),[m]),x=t!==e;$l({enabled:f,syncKey:`${t.length}:${g.length}`,editorLineNumberRowRefs:a,editorHighlightLineRefs:c});let b=$=>{let w=$.currentTarget.scrollTop;i.current&&(i.current.scrollTop=w),l.current&&(l.current.scrollTop=w)},v=$=>{if(($.metaKey||$.ctrlKey)&&$.key.toLowerCase()==="s"&&($.preventDefault(),s()),$.key==="Tab"){$.preventDefault();let w=r.current;if(!w)return;let S=w.selectionStart,C=w.selectionEnd,_=`${t.slice(0,S)} ${t.slice(C)}`;n(_),window.requestAnimationFrame(()=>{w.selectionStart=S+2,w.selectionEnd=S+2})}};return L(()=>{let $=o.current;if(!$||typeof ResizeObserver>"u")return()=>{};let w=null,S=new ResizeObserver(C=>{let _=C?.[0],k=_w(pP(_?.target));u(A=>Math.abs(A-k)>=1?k:A),w&&window.clearTimeout(w),w=window.setTimeout(()=>{let A=je();A[Cw]=k,At(A)},120)});return S.observe($),()=>{S.disconnect(),w&&window.clearTimeout(w)}},[]),Sw`

Prompt - ${b?S0``:null} + ${x?Sw``:null}

{i.current&&(i.current.destroy(),i.current=null)}},[p,a,o,c,e,d renderContent=${t} handleContentInput=${$=>n($.target.value)} handleEditorKeyDown=${v} - handleEditorScroll=${x} + handleEditorScroll=${b} handleEditorSelectionChange=${()=>{}} isEditBlocked=${!1} isPreviewOnly=${!1} />
- `};var uc=P.bind(T),Oi="ac-surface-inset rounded-lg p-2.5 space-y-1.5",pP=[{label:"main",value:"main"},{label:"isolated",value:"isolated"}],fP=[{label:"now",value:"now"},{label:"next-heartbeat",value:"next-heartbeat"}],Wp="__none__",M0=(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),hP=t=>t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}).replace(/\s*([AP])M$/i,(e,n)=>`${String(n||"").toLowerCase()}m`).replace(/\s+/g,""),mP=t=>{let e=Number(t||0);if(!Number.isFinite(e)||e<=0)return"\u2014";let n=new Date(e);if(Number.isNaN(n.getTime()))return"\u2014";let s=new Date,o=new Date(s);o.setDate(s.getDate()+1);let r=M0(n,s),i=M0(n,o),a=hP(n);return r?a:i?`Tomorrow ${a}`:`${n.toLocaleDateString()} ${a}`},T0=({job:t=null,routingDraft:e=null,onChangeRoutingDraft:n=()=>{},destinationSessionKey:s="",onChangeDestinationSessionKey:o=()=>{},deliverySessions:r=[],loadingDeliverySessions:i=!1,deliverySessionsError:a="",savingChanges:l=!1,togglingJobEnabled:c=!1,onToggleEnabled:d=()=>{},onRunNow:u=()=>{},runningJob:p=!1,hasUnsavedChanges:f=!1})=>{if(!t)return null;let g=String(e?.sessionTarget||t?.sessionTarget||"main"),m=String(e?.wakeMode||t?.wakeMode||"now"),h=String(e?.deliveryMode||t?.delivery?.mode||"none"),b=W(()=>{let v=new Set,$=[],w=String(s||"").trim(),S=!1;if((Array.isArray(r)?r:[]).forEach(C=>{let _=String(C?.key||"").trim();if(!_)return;_===w&&(S=!0);let A=String(C?.label||C?.key||"Session").trim().toLowerCase();v.has(A)||(v.add(A),$.push(C))}),!S&&w){let C=(Array.isArray(r)?r:[]).find(_=>String(_?.key||"").trim()===w);C&&$.unshift(C)}return $},[r,s]),x=h==="announce"&&String(s||"").trim()?String(s||""):Wp;return uc` + `};var uc=P.bind(T),Ni="ac-surface-inset rounded-lg p-2.5 space-y-1.5",fP=[{label:"main",value:"main"},{label:"isolated",value:"isolated"}],hP=[{label:"now",value:"now"},{label:"next-heartbeat",value:"next-heartbeat"}],Wp="__none__",Mw=(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),mP=t=>t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}).replace(/\s*([AP])M$/i,(e,n)=>`${String(n||"").toLowerCase()}m`).replace(/\s+/g,""),gP=t=>{let e=Number(t||0);if(!Number.isFinite(e)||e<=0)return"\u2014";let n=new Date(e);if(Number.isNaN(n.getTime()))return"\u2014";let s=new Date,o=new Date(s);o.setDate(s.getDate()+1);let r=Mw(n,s),i=Mw(n,o),a=mP(n);return r?a:i?`Tomorrow ${a}`:`${n.toLocaleDateString()} ${a}`},Tw=({job:t=null,routingDraft:e=null,onChangeRoutingDraft:n=()=>{},destinationSessionKey:s="",onChangeDestinationSessionKey:o=()=>{},deliverySessions:r=[],loadingDeliverySessions:i=!1,deliverySessionsError:a="",savingChanges:l=!1,togglingJobEnabled:c=!1,onToggleEnabled:d=()=>{},onRunNow:u=()=>{},runningJob:p=!1,hasUnsavedChanges:f=!1})=>{if(!t)return null;let g=String(e?.sessionTarget||t?.sessionTarget||"main"),m=String(e?.wakeMode||t?.wakeMode||"now"),h=String(e?.deliveryMode||t?.delivery?.mode||"none"),x=F(()=>{let v=new Set,$=[],w=String(s||"").trim(),S=!1;if((Array.isArray(r)?r:[]).forEach(C=>{let _=String(C?.key||"").trim();if(!_)return;_===w&&(S=!0);let A=String(C?.label||C?.key||"Session").trim().toLowerCase();v.has(A)||(v.add(A),$.push(C))}),!S&&w){let C=(Array.isArray(r)?r:[]).find(_=>String(_?.key||"").trim()===w);C&&$.unshift(C)}return $},[r,s]),b=h==="announce"&&String(s||"").trim()?String(s||""):Wp;return uc`
ID: ${t.id}
-
+
Schedule
${Qo(t.schedule,{includeTimeZoneWhenDifferent:!0})}
-
+
Next run
- ${mP(t?.state?.nextRunAtMs)} + ${gP(t?.state?.nextRunAtMs)} ${` (${tv(t?.state?.nextRunAtMs)})`} @@ -4777,37 +4777,37 @@ ${$}`}}}}}}),()=>{i.current&&(i.current.destroy(),i.current=null)}},[p,a,o,c,e,d
-
+
Session target
<${nt} - options=${pP} + options=${fP} value=${g} onChange=${v=>n(($={})=>({...$,sessionTarget:String(v||"main")}))} />
-
+
Wake mode
<${nt} - options=${fP} + options=${hP} value=${m} onChange=${v=>n(($={})=>({...$,wakeMode:String(v||"now")}))} />
-
+
Delivery
{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s `)} `} - ${u?zn`
${u}
`:null} + ${u?zn`
${u}
`:null} ${i?zn`
${i}
`:null} - ${!r&&!i&&p&&e.length===0?zn`
${p}
`:null} + ${!r&&!i&&p&&e.length===0?zn`
${p}
`:null}
- `};var kw=P.bind(T),yc=({visible:t=!1,title:e="Send to agent",messageLabel:n="Message",messageRows:s=8,initialMessage:o="",resetKey:r="",submitLabel:i="Send message",loadingLabel:a="Sending...",cancelLabel:l="Cancel",onClose:c=()=>{},onSubmit:d=async()=>!0,sessionFilter:u=void 0})=>{let{sessions:p,selectedSessionKey:f,setSelectedSessionKey:g,selectedSession:m,loading:h,error:b}=yr({enabled:t,filter:u}),[x,v]=y(""),[$,w]=y(!1);R(()=>{t&&v(String(o||""))},[t,o,r]);let S=async()=>{if(!m||$)return;let C=String(x||"").trim();if(C){w(!0);try{await d({selectedSession:m,selectedSessionKey:f,message:C})!==!1&&c()}finally{w(!1)}}};return kw` + `};var k0=P.bind(T),yc=({visible:t=!1,title:e="Send to agent",messageLabel:n="Message",messageRows:s=8,initialMessage:o="",resetKey:r="",submitLabel:i="Send message",loadingLabel:a="Sending...",cancelLabel:l="Cancel",onClose:c=()=>{},onSubmit:d=async()=>!0,sessionFilter:u=void 0})=>{let{sessions:p,selectedSessionKey:f,setSelectedSessionKey:g,selectedSession:m,loading:h,error:x}=yr({enabled:t,filter:u}),[b,v]=y(""),[$,w]=y(!1);L(()=>{t&&v(String(o||""))},[t,o,r]);let S=async()=>{if(!m||$)return;let C=String(b||"").trim();if(C){w(!0);try{await d({selectedSession:m,selectedSessionKey:f,message:C})!==!1&&c()}finally{w(!1)}}};return k0` <${Ie} visible=${t} onClose=${()=>{$||c()}} @@ -5679,7 +5679,7 @@ cost: ${v}`}}}}}}),()=>{r.current&&(r.current.destroy(),r.current=null)}},[f,i,s > <${De} title=${e} - actions=${kw` + actions=${k0`