bazilion 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1249 -136
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +3027 -396
- package/dist/daemon.js.map +1 -1
- package/dist/migrations/0001_init.sql +20 -0
- package/dist/web/client/assets/{ProductionTeamPolicyEditor-CiQ-VVDo.js → ProductionTeamPolicyEditor-B6dbpuYy.js} +1 -1
- package/dist/web/client/assets/{ProfileCommunicationEditor-D84F5yfr.js → ProfileCommunicationEditor-Bf8UvmZT.js} +1 -1
- package/dist/web/client/assets/{TeamTabs-Btoe_FAE.js → TeamTabs-sQBHChtd.js} +1 -1
- package/dist/web/client/assets/{TemplatesTabs-CAYY03F5.js → TemplatesTabs-DPsuwsWB.js} +1 -1
- package/dist/web/client/assets/{_id-BqU2BodK.js → _id-C9rkCclz.js} +1 -1
- package/dist/web/client/assets/{_id-Q98Of6k9.js → _id-D65IzC8H.js} +1 -1
- package/dist/web/client/assets/{_id-BeauECmk.js → _id-DE4IY5bL.js} +1 -1
- package/dist/web/client/assets/{_id-CKtoio3t.js → _id-DYASsGQ8.js} +1 -1
- package/dist/web/client/assets/{activity-DXN_N85w.js → activity-C7o6-xHg.js} +1 -1
- package/dist/web/client/assets/{agents-C5Xsdge1.js → agents-UroO4d25.js} +1 -1
- package/dist/web/client/assets/{agents-Cgxo4H5G.js → agents-h8yWXQ2H.js} +1 -1
- package/dist/web/client/assets/{approvals-BnG7fbw-.js → approvals-DKhF0YLC.js} +1 -1
- package/dist/web/client/assets/chevron-down-BK6NPMMP.js +1 -0
- package/dist/web/client/assets/{config-xw4NyrXF.js → config-q8JDresK.js} +1 -1
- package/dist/web/client/assets/{context-D2V1Oi4z.js → context-CBucAoi6.js} +1 -1
- package/dist/web/client/assets/{inbox-DK6hWCMp.js → inbox-BwoRikj1.js} +1 -1
- package/dist/web/client/assets/{index-VdURSoM4.js → index-DUXAevpZ.js} +2 -2
- package/dist/web/client/assets/{login-CvptUoMR.js → login-CNAV9Wer.js} +1 -1
- package/dist/web/client/assets/{mcp-BDFM_sW-.js → mcp-BKdEFwHO.js} +1 -1
- package/dist/web/client/assets/{members-BJvph_TR.js → members-BDqZQh26.js} +1 -1
- package/dist/web/client/assets/{memory-DRytqZCD.js → memory-DVdEVr6L.js} +1 -1
- package/dist/web/client/assets/plus-b4yFXP0O.js +1 -0
- package/dist/web/client/assets/{policy-CGP50OtQ.js → policy-DdDctqvg.js} +1 -1
- package/dist/web/client/assets/{routes-DJnWYvC9.js → routes-BEfALSZv.js} +1 -1
- package/dist/web/client/assets/{services-DHheiv7L.js → services-DZP2ybzb.js} +1 -1
- package/dist/web/client/assets/{skills-DmsitluU.js → skills-DoeIjITs.js} +1 -1
- package/dist/web/client/assets/styles-BYM0UGdF.css +2 -0
- package/dist/web/client/assets/{teams-CbxSaorm.js → teams-DlHRnrQw.js} +1 -1
- package/dist/web/client/assets/{teams-BdC4gthq.js → teams-W3j-UoJ9.js} +1 -1
- package/dist/web/client/assets/telegram-2OdeGv4E.js +1 -0
- package/dist/web/client/assets/{tokens-CjRplDrJ.js → tokens-MuBfmgue.js} +1 -1
- package/dist/web/client/assets/triggers-CX7RMQFQ.js +1 -0
- package/dist/web/client/assets/{welcome-wBfX9dAd.js → welcome-CvNr5IMi.js} +1 -1
- package/dist/web/client/assets/wire-constants-BhVKOCQa.js +74 -0
- package/dist/web/server/assets/{ChatPane-eUY_dga3.js → ChatPane-Ba5wTsVk.js} +325 -36
- package/dist/web/server/assets/{_id-ClN9hY2x.js → _id-Cg7x6q3g.js} +2 -2
- package/dist/web/server/assets/{_id-DkYodSkG.js → _id-DqON-59C.js} +1 -1
- package/dist/web/server/assets/{_tanstack-start-manifest_v-D09Xu_6u.js → _tanstack-start-manifest_v-BXauUXg6.js} +51 -51
- package/dist/web/server/assets/{router-DIdp8ZNt.js → router-C5_NjTsP.js} +5 -5
- package/dist/web/server/assets/{routes-Jb0zjKav.js → routes-B6cMLIPk.js} +3 -3
- package/dist/web/server/assets/{routes-CXz4hTAr.js → routes-BrA-U_Hm.js} +1 -1
- package/dist/web/server/assets/{routes-lIclH9Br.js → routes-C19CMLZt.js} +1 -1
- package/dist/web/server/assets/{telegram-7ub--6xz.js → telegram-CBF8SJzB.js} +1 -24
- package/dist/web/server/assets/{telegram-Bazhmpr4.js → telegram-XwyKSEtj.js} +1 -1
- package/dist/web/server/assets/{triggers-Ca57_qym.js → triggers-CBl4yMyw.js} +1 -1
- package/dist/web/server/assets/{triggers-C_0y6QV9.js → triggers-D79NoSXk.js} +3 -2
- package/dist/web/server/assets/{triggers-BMpHsGIr.js → triggers-_3rdhwSN.js} +27 -3
- package/dist/web/server/server.js +4 -4
- package/dist/worker.js +1609 -135
- package/dist/worker.js.map +1 -1
- package/package.json +4 -3
- package/dist/web/client/assets/chevron-down-BhcBspw3.js +0 -1
- package/dist/web/client/assets/plus-C9ee3SIO.js +0 -1
- package/dist/web/client/assets/styles-B5eQAwLP.css +0 -2
- package/dist/web/client/assets/telegram-D61G_alO.js +0 -1
- package/dist/web/client/assets/triggers-MLzTm_DM.js +0 -1
- package/dist/web/client/assets/wire-constants-BxfyUMXB.js +0 -74
- package/dist/web/server/assets/{Sidebar-O_CH1-JD.js → Sidebar-DsRVCszF.js} +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-mNuBjNXU.js";import{m as i}from"./index-
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-mNuBjNXU.js";import{m as i}from"./index-DUXAevpZ.js";import{n as a,r as o}from"./Page-CwNuDhWz.js";import{t as s}from"./Button-ByiV6fpd.js";import{t as c}from"./TemplatesTabs-DPsuwsWB.js";var l=e(n()),u=t();function d(){let e=i.useLoaderData(),t=r();return(0,u.jsxs)(o,{size:`wide`,children:[(0,u.jsx)(a,{eyebrow:`Templates`,title:`Team templates`,description:`Create revisioned rosters with stable slots and a reusable communication policy.`}),(0,u.jsx)(c,{}),(0,u.jsx)(f,{onCreated:()=>t.invalidate()}),(0,u.jsx)(`div`,{className:`overflow-x-auto`,children:(0,u.jsxs)(`table`,{children:[(0,u.jsx)(`thead`,{children:(0,u.jsxs)(`tr`,{children:[(0,u.jsx)(`th`,{children:`id`}),(0,u.jsx)(`th`,{children:`name`}),(0,u.jsx)(`th`,{children:`slots`}),(0,u.jsx)(`th`,{children:`revision`}),(0,u.jsx)(`th`,{children:`source state`})]})}),(0,u.jsxs)(`tbody`,{children:[e.map(e=>(0,u.jsxs)(`tr`,{children:[(0,u.jsx)(`td`,{children:(0,u.jsx)(`a`,{href:`/templates/teams/${encodeURIComponent(e.id)}`,children:(0,u.jsx)(`code`,{children:e.id})})}),(0,u.jsx)(`td`,{children:e.name}),(0,u.jsx)(`td`,{children:e.slotCount}),(0,u.jsx)(`td`,{children:e.currentRevision}),(0,u.jsx)(`td`,{children:e.deletedAt?`deleted source`:`canonical`})]},e.id)),e.length===0&&(0,u.jsx)(`tr`,{children:(0,u.jsx)(`td`,{colSpan:5,className:`muted`,children:`No team templates yet.`})})]})]})})]})}function f({onCreated:e}){let[t,n]=(0,l.useState)(``),[r,i]=(0,l.useState)(``),[a,o]=(0,l.useState)(null),[c,d]=(0,l.useState)(!1);async function f(a){a.preventDefault(),d(!0),o(null);try{let a=await fetch(`/api/team-templates`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:t.trim(),name:r.trim()})});if(!a.ok)throw Error((await a.json().catch(()=>null))?.error??a.statusText);n(``),i(``),await e()}catch(e){o(e.message)}finally{d(!1)}}return(0,u.jsxs)(`form`,{className:`card`,onSubmit:f,children:[(0,u.jsx)(`h2`,{className:`text-xl`,children:`new team template`}),a&&(0,u.jsx)(`p`,{className:`err`,children:a}),(0,u.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,u.jsxs)(`label`,{children:[`id`,(0,u.jsx)(`input`,{required:!0,value:t,onChange:e=>n(e.target.value),placeholder:`review-team`})]}),(0,u.jsxs)(`label`,{children:[`name`,(0,u.jsx)(`input`,{required:!0,value:r,onChange:e=>i(e.target.value),placeholder:`Review team`})]})]}),(0,u.jsx)(s,{variant:`primary`,type:`submit`,disabled:c,children:c?`creating…`:`create team template`})]})}export{d as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-mNuBjNXU.js";import{a as i}from"./index-DUXAevpZ.js";import{t as a}from"./Button-ByiV6fpd.js";import{t as o}from"./ConfigPage-BCwfgyjD.js";var s=e(n()),c=t();function l(){let e=i.useLoaderData(),t=r(),[n,l]=(0,s.useState)(``),[m,h]=(0,s.useState)(e.chatId),[g,_]=(0,s.useState)(!1),[v,y]=(0,s.useState)(null),[b,x]=(0,s.useState)(!1),[S,C]=(0,s.useState)(null),[w,T]=(0,s.useState)(!1);async function E(e){e.preventDefault(),_(!0),y(null),x(!1);try{let e=await fetch(`/api/config/telegram`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({botToken:n,chatId:m})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`${e.status} ${e.statusText}`)}l(``),x(!0),await t.invalidate()}catch(e){y(e.message)}finally{_(!1)}}async function D(){if(confirm(`Clear the saved Telegram credentials?`))try{await fetch(`/api/config/telegram`,{method:`DELETE`}),l(``),h(``),C(null),x(!1),y(null),await t.invalidate()}catch(e){y(e.message)}}async function O(){T(!0),C(null);try{C(await(await fetch(`/api/config/telegram/health`)).json())}catch(e){C({configured:!0,preflight:null,error:{step:`getMe`,message:e.message},polling:null})}finally{T(!1)}}return(0,c.jsxs)(o,{active:`integrations`,title:`Telegram`,description:`Connect one forum-supergroup bot with one topic per agent, so conversations stay reachable from your phone.`,size:`narrow`,children:[e.migratedChatId&&(0,c.jsx)(d,{toChatId:e.migratedChatId}),(0,c.jsxs)(`section`,{className:`rounded-lg border bg-card p-5`,children:[(0,c.jsx)(`h3`,{className:`text-sm font-semibold uppercase tracking-wide text-muted-foreground mb-3`,children:`Credentials`}),e.configured&&(0,c.jsxs)(`p`,{className:`text-xs text-success mb-3`,children:[`✓ Stored: `,(0,c.jsx)(`code`,{className:`font-mono`,children:e.botTokenPreview}),` `,e.chatId&&(0,c.jsxs)(c.Fragment,{children:[`· chat `,(0,c.jsx)(`code`,{className:`font-mono`,children:e.chatId})]})]}),(0,c.jsxs)(`form`,{onSubmit:E,className:`space-y-3`,children:[(0,c.jsxs)(`label`,{className:`block`,children:[(0,c.jsx)(`span`,{className:`block text-sm font-medium mb-1`,children:`Bot token`}),(0,c.jsx)(`input`,{type:`password`,autoComplete:`off`,value:n,onChange:e=>l(e.target.value),placeholder:e.configured?`(leave blank to keep stored value)`:`1234567890:ABC...`,className:`w-full rounded-md border bg-background px-2 py-1.5 font-mono text-sm outline-none focus:ring-2 focus:ring-ring/30`,required:!e.configured}),(0,c.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`From @BotFather → /newbot. Disable Privacy Mode in `,(0,c.jsx)(`em`,{children:`Bot Settings → Team Privacy → Turn off`}),`.`]})]}),(0,c.jsxs)(`label`,{className:`block`,children:[(0,c.jsx)(`span`,{className:`block text-sm font-medium mb-1`,children:`Supergroup chat ID`}),(0,c.jsx)(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:`-1001234567890`,className:`w-full rounded-md border bg-background px-2 py-1.5 font-mono text-sm outline-none focus:ring-2 focus:ring-ring/30`,required:!0}),(0,c.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`Forum-enabled supergroup the bot is admin in (with`,` `,(0,c.jsx)(`code`,{className:`font-mono`,children:`can_manage_topics`}),`).`]})]}),(0,c.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 pt-1`,children:[(0,c.jsx)(a,{variant:`primary`,type:`submit`,disabled:g,children:g?`saving…`:`save credentials`}),e.configured&&(0,c.jsx)(a,{variant:`danger`,onClick:D,children:`clear credentials`}),b&&(0,c.jsx)(`span`,{className:`text-xs text-success`,children:`saved ✓`}),v&&(0,c.jsxs)(`span`,{className:`text-xs text-danger`,children:[`error: `,v]})]})]})]}),(0,c.jsxs)(`section`,{className:`rounded-lg border bg-card p-5`,children:[(0,c.jsxs)(`div`,{className:`mb-3 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,c.jsx)(`h3`,{className:`text-sm font-semibold uppercase tracking-wide text-muted-foreground`,children:`Preflight checks`}),(0,c.jsx)(a,{variant:`ghost`,onClick:O,disabled:w||!e.configured,children:w?`checking…`:`run preflight`})]}),!e.configured&&(0,c.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:`Save credentials above first.`}),e.configured&&!S&&!w&&(0,c.jsxs)(`p`,{className:`text-xs text-muted-foreground italic`,children:[`Click `,(0,c.jsx)(`em`,{children:`run preflight`}),` to validate the stored credentials against the Telegram Bot API.`]}),S&&(0,c.jsx)(p,{health:S}),S?.polling&&(0,c.jsx)(f,{polling:S.polling})]}),e.configured&&(0,c.jsx)(u,{})]})}function u(){let[e,t]=(0,s.useState)(null),[n,r]=(0,s.useState)(``),[i,o]=(0,s.useState)(``),[l,u]=(0,s.useState)(!1),[d,f]=(0,s.useState)(null);async function p(){try{let e=await fetch(`/api/config/telegram/acl`);if(!e.ok)throw Error(e.statusText);t(await e.json())}catch(e){f(e.message)}}(0,s.useEffect)(()=>{p()},[]);async function m(e){e.preventDefault();let t=Number(n);if(!Number.isInteger(t)){f(`user id must be an integer`);return}u(!0),f(null);try{let e=await fetch(`/api/config/telegram/acl`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({userId:t,label:i.trim()||null})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??e.statusText)}r(``),o(``),await p()}catch(e){f(e.message)}finally{u(!1)}}async function h(e){f(null);try{let t=await fetch(`/api/config/telegram/acl/${e}`,{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??t.statusText)}await p()}catch(e){f(e.message)}}return(0,c.jsxs)(`section`,{className:`rounded-lg border bg-card p-5`,children:[(0,c.jsx)(`h3`,{className:`text-sm font-semibold uppercase tracking-wide text-muted-foreground mb-1`,children:`Access control`}),(0,c.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:[`Allowlisted Telegram users can use the bot (commands + chat). While the list is empty the bot is open and the first person to message it becomes owner. Users find their id via`,` `,(0,c.jsx)(`code`,{className:`font-mono`,children:`/whoami`}),`.`]}),e===null?(0,c.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:`loading…`}):e.length===0?(0,c.jsx)(`p`,{className:`text-xs text-warning mb-3`,children:`Open — no allowlist yet. The first user to message the bot claims owner.`}):(0,c.jsx)(`ul`,{className:`mb-3 space-y-1 text-sm`,children:e.map(e=>(0,c.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,c.jsx)(`code`,{className:`font-mono`,children:e.userId}),(0,c.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.label??(e.username?`@${e.username}`:`—`),` · `,e.role]}),e.role!==`owner`&&(0,c.jsx)(`button`,{type:`button`,onClick:()=>void h(e.userId),className:`ghost-btn text-xs text-rose-baziu`,children:`remove`})]},e.userId))}),(0,c.jsxs)(`form`,{onSubmit:m,className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center`,children:[(0,c.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`user id`,className:`w-full rounded-md border bg-background px-2 py-1 font-mono text-sm sm:w-28`}),(0,c.jsx)(`input`,{value:i,onChange:e=>o(e.target.value),placeholder:`label (optional)`,className:`w-full rounded-md border bg-background px-2 py-1 text-sm sm:w-40`}),(0,c.jsx)(a,{variant:`ghost`,type:`submit`,disabled:l,children:`add`}),d&&(0,c.jsx)(`span`,{className:`text-xs text-danger`,children:d})]})]})}function d({toChatId:e}){let[t,n]=(0,s.useState)(!1),[r,i]=(0,s.useState)(null);async function o(){n(!0),i(null);try{let e=await fetch(`/api/config/telegram/reconnect`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??e.statusText)}window.location.reload()}catch(e){i(e.message),n(!1)}}return(0,c.jsxs)(`div`,{className:`rounded-md border-2 border-danger/25 bg-danger/10 px-4 py-3 text-sm`,children:[(0,c.jsx)(`div`,{className:`font-semibold text-danger mb-1`,children:`Supergroup chat id changed`}),(0,c.jsxs)(`p`,{className:`text-danger mb-2`,children:[`Telegram migrated this supergroup to a new chat id (`,(0,c.jsx)(`code`,{className:`font-mono`,children:e}),`). The bot is still pointed at the old id. Reconnect to repoint it and re-create the `,(0,c.jsx)(`code`,{className:`font-mono`,children:`⚙ bazilion`}),` `,`service chat in the new team. Agent topic bindings will reconcile on next use.`]}),(0,c.jsx)(a,{variant:`primary`,onClick:o,disabled:t,children:t?`reconnecting…`:`Reconnect to ${e}`}),r&&(0,c.jsx)(`span`,{className:`ml-3 text-xs text-danger`,children:r})]})}function f({polling:e}){let t=e.startedAt?new Date(e.startedAt).toISOString():null,n=e.lastSuccessfulPollAt?new Date(e.lastSuccessfulPollAt).toISOString():null;return(0,c.jsxs)(`div`,{className:`mt-4 rounded-md border bg-muted/30 px-3 py-2 text-xs space-y-1`,children:[(0,c.jsx)(`p`,{className:`font-semibold uppercase tracking-wide text-muted-foreground`,children:`Polling state`}),(0,c.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 font-mono`,children:[(0,c.jsx)(`span`,{className:e.running?`text-success`:`text-danger`,children:e.running?`running`:`stopped`}),(0,c.jsx)(`span`,{className:e.activated?`text-success`:`text-warning`,children:e.activated?`activated`:`awaiting activation`}),e.lastUpdateId!==null&&(0,c.jsxs)(`span`,{children:[`last update `,e.lastUpdateId]}),t&&(0,c.jsxs)(`span`,{children:[`started `,t]}),n&&(0,c.jsxs)(`span`,{children:[`last poll `,n]})]}),e.error&&(0,c.jsxs)(`p`,{className:`text-danger`,children:[`error: `,e.error]})]})}function p({health:e}){if(e.error)return(0,c.jsxs)(`div`,{className:`rounded-md border border-danger/25 bg-danger/10 px-3 py-2 text-sm`,children:[(0,c.jsxs)(`p`,{className:`font-semibold text-danger`,children:[`Failed at `,(0,c.jsx)(`code`,{className:`font-mono`,children:e.error.step})]}),(0,c.jsx)(`p`,{className:`text-danger mt-1`,children:e.error.message}),h(e.error.step)]});if(!e.preflight)return(0,c.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:`No preflight data.`});let t=e.preflight;return(0,c.jsxs)(`ul`,{className:`space-y-1.5`,children:[(0,c.jsxs)(m,{ok:t.botUsername.length>0,label:`Bot identity`,children:[`@`,t.botUsername]}),(0,c.jsx)(m,{ok:t.chatTitle.length>0,label:`Supergroup reachable`,children:t.chatTitle}),(0,c.jsx)(m,{ok:t.isForum,label:`Forum topics enabled`,children:t.isForum?`is_forum: true`:`is_forum: false — the supergroup owner must enable Topics in team settings`}),(0,c.jsx)(m,{ok:t.hasManageTopics,label:`Bot has can_manage_topics`,children:t.hasManageTopics?`admin with can_manage_topics`:`promote the bot to admin in the supergroup with the "Manage topics" permission`}),(0,c.jsx)(m,{ok:t.privacyModeOff,label:`Privacy Mode is OFF`,children:t.privacyModeOff?`can_read_all_group_messages: true`:`BotFather → /mybots → select bot → Bot Settings → Team Privacy → Turn off`})]})}function m({ok:e,label:t,children:n}){return(0,c.jsxs)(`li`,{className:`flex items-start gap-2 text-sm`,children:[(0,c.jsx)(`span`,{className:`mt-0.5 inline-flex h-4 w-4 items-center justify-center rounded-full text-[10px] font-bold leading-none ${e?`bg-success/10 text-success`:`bg-danger/10 text-danger`}`,"aria-hidden":!0,children:e?`✓`:`✕`}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{className:`font-medium`,children:t}),(0,c.jsx)(`span`,{className:`ml-2 text-xs ${e?`text-muted-foreground`:`text-danger`}`,children:n})]})]})}function h(e){switch(e){case`getMe`:return(0,c.jsx)(`p`,{className:`text-xs text-danger mt-1`,children:`The token is invalid or revoked. Re-issue with @BotFather → /token, or paste a fresh one above.`});case`getChat`:return(0,c.jsx)(`p`,{className:`text-xs text-danger mt-1`,children:`The chat id either doesn't exist, points at a basic team (not a supergroup), or the bot isn't a member. Forward any message from the supergroup to the bot to double-check the id, then add the bot to the team.`});case`getChatMember`:return(0,c.jsx)(`p`,{className:`text-xs text-danger mt-1`,children:`The bot is in the chat but the membership lookup failed. Usually means the bot was kicked or the chat id was migrated — confirm the bot is still in the supergroup.`})}}export{l as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-mNuBjNXU.js";import{_ as i}from"./index-
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-mNuBjNXU.js";import{_ as i}from"./index-DUXAevpZ.js";import{t as a}from"./ConfigPage-BCwfgyjD.js";var o=e(n()),s=t();function c(e){return new Date(e).toISOString().slice(0,16).replace(`T`,` `)}function l(){let{tokens:e}=i.useLoaderData(),{all:t}=i.useSearch(),n=t===`1`,l=r(),[u,d]=(0,o.useState)(``),[f,p]=(0,o.useState)(null),[m,h]=(0,o.useState)(null),[g,_]=(0,o.useState)(!1);async function v(e){e.preventDefault(),h(null),_(!0);try{let e=await fetch(`/api/tokens`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({label:u})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`${e.status} ${e.statusText}`)}p((await e.json()).token),d(``),await l.invalidate()}catch(e){h(e.message)}finally{_(!1)}}async function y(e){await fetch(`/api/tokens/${e}`,{method:`DELETE`}),await l.invalidate()}return(0,s.jsxs)(a,{active:`tokens`,title:`API tokens`,description:(0,s.jsxs)(s.Fragment,{children:[`Manage per-client credentials for the HTTP API and CLI. The`,` `,(0,s.jsx)(`code`,{className:`font-mono`,children:`bootstrap`}),` token from`,` `,(0,s.jsx)(`code`,{className:`font-mono`,children:`~/.bazilion/auth.json`}),` remains protected; mint separate credentials for mobile, LAN, and remote clients.`]}),children:[(0,s.jsxs)(`section`,{className:`rounded-lg border bg-card p-5`,children:[(0,s.jsx)(`h3`,{className:`font-serif text-xl mb-3`,children:`Mint a new token`}),(0,s.jsxs)(`form`,{onSubmit:v,className:`mb-3 flex flex-col items-stretch gap-2 sm:flex-row sm:items-end`,children:[(0,s.jsxs)(`label`,{className:`w-full text-sm sm:w-auto`,children:[`Label`,(0,s.jsx)(`input`,{type:`text`,value:u,onChange:e=>d(e.target.value),required:!0,placeholder:`e.g. laptop-tailscale`,autoComplete:`off`,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 text-sm sm:w-72`})]}),(0,s.jsx)(`button`,{type:`submit`,disabled:g,className:`rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50`,children:g?`creating…`:`create`})]}),f&&(0,s.jsxs)(`div`,{className:`rounded-md border border-warning/25 bg-warning/10 p-3`,children:[(0,s.jsx)(`p`,{className:`text-xs text-warning mb-1`,children:`copy this token now — it is not recoverable later.`}),(0,s.jsx)(`pre`,{className:`font-mono text-xs whitespace-pre-wrap break-all`,children:f})]}),m&&(0,s.jsx)(`p`,{className:`text-sm text-danger`,children:m})]}),(0,s.jsx)(`div`,{children:(0,s.jsxs)(`label`,{className:`text-sm flex items-center gap-2`,children:[(0,s.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>{window.location.assign(e.target.checked?`/config/tokens?all=1`:`/config/tokens`)}}),`show revoked`]})}),(0,s.jsx)(`div`,{className:`overflow-x-auto`,children:(0,s.jsxs)(`table`,{className:`w-full min-w-[720px] text-sm`,children:[(0,s.jsx)(`thead`,{className:`text-left text-muted-foreground border-b`,children:(0,s.jsxs)(`tr`,{children:[(0,s.jsx)(`th`,{className:`py-2`,children:`label`}),(0,s.jsx)(`th`,{children:`id`}),(0,s.jsx)(`th`,{children:`state`}),(0,s.jsx)(`th`,{children:`created`}),(0,s.jsx)(`th`,{children:`last used`}),(0,s.jsx)(`th`,{})]})}),(0,s.jsxs)(`tbody`,{children:[e.length===0&&(0,s.jsx)(`tr`,{children:(0,s.jsx)(`td`,{colSpan:6,className:`py-6 text-center text-muted-foreground italic`,children:`no tokens yet — mint one above`})}),e.map(e=>{let t=e.label===`bootstrap`;return(0,s.jsxs)(`tr`,{className:`border-b last:border-0 hover:bg-accent/30`,children:[(0,s.jsxs)(`td`,{className:`py-2`,children:[e.label,t&&(0,s.jsx)(`span`,{className:`ml-2 text-[0.7em] uppercase tracking-wide text-muted-foreground`,children:`auth.json`})]}),(0,s.jsx)(`td`,{children:(0,s.jsx)(`code`,{className:`font-mono text-xs`,children:e.id})}),(0,s.jsx)(`td`,{children:e.revokedAt?(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:`revoked`}):(0,s.jsx)(`span`,{className:`text-success`,children:`active`})}),(0,s.jsx)(`td`,{className:`text-muted-foreground text-xs`,children:c(e.createdAt)}),(0,s.jsx)(`td`,{className:`text-muted-foreground text-xs`,children:e.lastUsedAt?c(e.lastUsedAt):`(never)`}),(0,s.jsx)(`td`,{children:!e.revokedAt&&!t&&(0,s.jsx)(`button`,{type:`button`,onClick:()=>y(e.id),className:`rounded-md border px-2 py-1 text-xs text-danger hover:bg-danger/10`,children:`revoke`})})]},e.id)})]})]})})]})}export{l as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-mNuBjNXU.js";import{i}from"./index-DUXAevpZ.js";import{r as a}from"./Page-CwNuDhWz.js";import{t as o}from"./AgentTabs-B3hq5a3e.js";var s=e(n()),c=t();function l(){let{resolved:e,triggers:t,dispatches:n}=i.useLoaderData(),s=r();async function l(e){await fetch(`/api/triggers/${e.id}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({enabled:!e.enabled})}),await s.invalidate()}async function d(e){confirm(`delete this trigger?`)&&(await fetch(`/api/triggers/${e}`,{method:`DELETE`}),await s.invalidate())}return(0,c.jsxs)(a,{children:[(0,c.jsx)(`header`,{className:`mb-6`,children:(0,c.jsx)(`h1`,{children:e.agent.name})}),(0,c.jsx)(o,{agentId:e.agent.id,active:`triggers`,archived:e.agent.status===`archived`}),(0,c.jsx)(u,{agentId:e.agent.id,onAdded:()=>s.invalidate()}),(0,c.jsx)(`h3`,{className:`mb-3 mt-6 font-body text-[0.85em] font-semibold uppercase tracking-wider text-mocha-light`,children:`Active triggers`}),t.length===0?(0,c.jsx)(`p`,{className:`muted`,children:`no triggers yet — add one above.`}):(0,c.jsxs)(`table`,{children:[(0,c.jsx)(`thead`,{children:(0,c.jsxs)(`tr`,{children:[(0,c.jsx)(`th`,{children:`id`}),(0,c.jsx)(`th`,{children:`kind`}),(0,c.jsx)(`th`,{children:`spec`}),(0,c.jsx)(`th`,{children:`message`}),(0,c.jsx)(`th`,{children:`last fired`}),(0,c.jsx)(`th`,{})]})}),(0,c.jsx)(`tbody`,{children:t.map(e=>{let t=e.kind===`interval`?`every ${e.intervalSec}s`:e.cronExpr,n=e.lastFiredAt?new Date(e.lastFiredAt).toLocaleString():`(never)`;return(0,c.jsxs)(`tr`,{className:e.enabled?``:`opacity-60`,children:[(0,c.jsx)(`td`,{children:(0,c.jsxs)(`code`,{children:[e.id.slice(0,8),`…`]})}),(0,c.jsx)(`td`,{children:(0,c.jsx)(`span`,{className:`inline-block rounded-sm border border-frost bg-ivory px-2 py-0.5 font-mono text-[0.8em] text-mocha`,children:e.kind})}),(0,c.jsx)(`td`,{children:(0,c.jsx)(`code`,{children:t})}),(0,c.jsx)(`td`,{children:e.message.length>60?`${e.message.slice(0,60)}…`:e.message}),(0,c.jsx)(`td`,{className:`text-[0.82em] text-mocha-light`,children:n}),(0,c.jsx)(`td`,{children:(0,c.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,c.jsx)(`button`,{type:`button`,className:`ghost-btn`,onClick:()=>l(e),children:e.enabled?`disable`:`enable`}),(0,c.jsx)(`button`,{type:`button`,className:`ghost-btn`,onClick:()=>d(e.id),children:`delete`})]})})]},e.id)})})]}),(0,c.jsx)(`h3`,{className:`mb-3 mt-8 font-body text-[0.85em] font-semibold uppercase tracking-wider text-mocha-light`,children:`Recent dispatches`}),n.length===0?(0,c.jsx)(`p`,{className:`muted`,children:`no scheduled occurrences yet.`}):(0,c.jsxs)(`table`,{children:[(0,c.jsx)(`thead`,{children:(0,c.jsxs)(`tr`,{children:[(0,c.jsx)(`th`,{children:`scheduled`}),(0,c.jsx)(`th`,{children:`status`}),(0,c.jsx)(`th`,{children:`attempts`}),(0,c.jsx)(`th`,{children:`error`})]})}),(0,c.jsx)(`tbody`,{children:n.map(e=>(0,c.jsxs)(`tr`,{children:[(0,c.jsx)(`td`,{className:`text-[0.82em]`,children:new Date(e.scheduledAt).toLocaleString()}),(0,c.jsx)(`td`,{children:(0,c.jsx)(`code`,{children:e.status})}),(0,c.jsx)(`td`,{children:e.attemptCount}),(0,c.jsx)(`td`,{className:`text-[0.82em] text-mocha-light`,children:e.lastError??`—`})]},e.id))})]})]})}function u({agentId:e,onAdded:t}){let[n,r]=(0,s.useState)(`interval`),[i,a]=(0,s.useState)(300),[o,l]=(0,s.useState)(``),[u,d]=(0,s.useState)(``),[f,p]=(0,s.useState)(null),[m,h]=(0,s.useState)(!1);async function g(r){if(r.preventDefault(),p(null),!u.trim()){p(`message is required`);return}if(n===`interval`&&(!Number.isFinite(i)||i<=0)){p(`interval must be a positive number`);return}if(n===`cron`&&!o.trim()){p(`cron expression is required`);return}h(!0);try{let r={kind:n,message:u.trim()};n===`interval`?r.intervalSec=i:r.cronExpr=o.trim();let s=await fetch(`/api/agents/${encodeURIComponent(e)}/triggers`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(r)});if(!s.ok){let e=await s.json().catch(()=>null);throw Error(e?.error??s.statusText)}d(``),l(``),a(300),t()}catch(e){p(e.message)}finally{h(!1)}}return(0,c.jsxs)(`form`,{className:`card`,onSubmit:g,children:[(0,c.jsx)(`h3`,{children:`Add trigger`}),(0,c.jsxs)(`div`,{className:`mb-3 flex gap-3`,children:[(0,c.jsxs)(`label`,{className:`m-0 inline-flex cursor-pointer items-center gap-1`,children:[(0,c.jsx)(`input`,{type:`radio`,checked:n===`interval`,onChange:()=>r(`interval`)}),`interval (every N seconds)`]}),(0,c.jsxs)(`label`,{className:`m-0 inline-flex cursor-pointer items-center gap-1`,children:[(0,c.jsx)(`input`,{type:`radio`,checked:n===`cron`,onChange:()=>r(`cron`)}),`cron (5-field)`]})]}),n===`interval`?(0,c.jsxs)(`label`,{children:[`interval (seconds)`,(0,c.jsx)(`input`,{type:`number`,min:1,value:i,onChange:e=>a(Number(e.target.value))})]}):(0,c.jsxs)(`label`,{children:[`cron expression (minute hour dom month dow)`,(0,c.jsx)(`input`,{type:`text`,placeholder:`*/15 * * * *`,value:o,onChange:e=>l(e.target.value)})]}),(0,c.jsxs)(`label`,{children:[`message`,(0,c.jsx)(`textarea`,{placeholder:`e.g. check your inbox and act on anything new`,value:u,onChange:e=>d(e.target.value),className:`font-mono text-[0.9em] min-h-[80px]`})]}),(0,c.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,c.jsx)(`button`,{type:`submit`,disabled:m,children:m?`adding…`:`add`}),f&&(0,c.jsx)(`span`,{className:`text-[0.85em] text-danger`,children:f})]})]})}export{l as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-DGeXAQPT.js";import{O as t}from"./index-
|
|
1
|
+
import{t as e}from"./jsx-runtime-DGeXAQPT.js";import{O as t}from"./index-DUXAevpZ.js";import{i as n,n as r,r as i}from"./Page-CwNuDhWz.js";var a=t(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),o=e();function s(){return(0,o.jsxs)(i,{size:`narrow`,children:[(0,o.jsx)(r,{eyebrow:`First run`,title:`Welcome to bazilion`,description:`Connect one model provider, then Bazilion will prepare your default Agent template and Team.`}),(0,o.jsxs)(n,{title:`Three steps to your first conversation`,children:[(0,o.jsxs)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:[`Before you can spawn agents, enable a provider and save at least one concrete model id. Once you do, a `,(0,o.jsx)(`code`,{children:`default`}),` Agent template (and a `,(0,o.jsx)(`code`,{children:`default`}),` team directory) are created automatically and the rest of the app unlocks.`]}),(0,o.jsxs)(`ol`,{className:`my-5 space-y-4`,children:[(0,o.jsxs)(c,{n:1,children:[(0,o.jsx)(`strong`,{children:`Choose a provider.`}),` Head to the`,` `,(0,o.jsx)(`a`,{href:`/config`,children:`providers tab`}),`, pick a provider, and set credentials or a local endpoint if that provider needs one. Local providers like Ollama and LM Studio can use their default loopback URLs.`]}),(0,o.jsxs)(c,{n:2,children:[(0,o.jsx)(`strong`,{children:`Enable it and save a model.`}),` Flip the provider's toggle on, then click a catalog chip or type one exact model id (for example`,` `,(0,o.jsx)(`code`,{children:`claude-opus-4-8`}),`, `,(0,o.jsx)(`code`,{children:`gpt-5.6-luna`}),`, or `,(0,o.jsx)(`code`,{children:`llama3.3`}),`) and press `,(0,o.jsx)(`em`,{children:`save models`}),`.`]}),(0,o.jsxs)(c,{n:3,children:[(0,o.jsx)(`strong`,{children:`Start chatting.`}),` You'll be redirected to the home page automatically, where the `,(0,o.jsx)(`code`,{children:`default`}),` Agent template is ready for your first spawn.`]})]}),(0,o.jsxs)(`a`,{href:`/config`,className:`btn-primary no-underline`,children:[`Configure providers `,(0,o.jsx)(a,{className:`h-4 w-4`,"aria-hidden":`true`})]})]})]})}function c({n:e,children:t}){return(0,o.jsxs)(`li`,{className:`grid grid-cols-[2rem_1fr] gap-3 border-t border-frost pt-3 first:border-t-0 first:pt-0`,children:[(0,o.jsx)(`span`,{className:`text-center font-display text-xl text-sapphire`,children:e}),(0,o.jsx)(`div`,{className:`text-[0.92em] leading-relaxed text-mocha`,children:t})]})}export{s as component};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{t as r}from"./Button-ByiV6fpd.js";var i=e(n(),1);function a(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function o(e){if(Array.isArray(e))return e}function s(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function c(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function l(e,t){return o(e)||s(e,t)||u(e,t)||c()}function u(e,t){if(e){if(typeof e==`string`)return a(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}var d=Object.entries,f=Object.setPrototypeOf,ee=Object.isFrozen,p=Object.getPrototypeOf,m=Object.getOwnPropertyDescriptor,h=Object.freeze,g=Object.seal,_=Object.create,v=typeof Reflect<`u`&&Reflect,y=v.apply,te=v.construct;h||=function(e){return e},g||=function(e){return e},y||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},te||=function(e){return new e(...[...arguments].slice(1))};var ne=A(Array.prototype.forEach),re=A(Array.prototype.lastIndexOf),ie=A(Array.prototype.pop),ae=A(Array.prototype.push),oe=A(Array.prototype.splice),b=Array.isArray,x=A(String.prototype.toLowerCase),se=A(String.prototype.toString),ce=A(String.prototype.match),le=A(String.prototype.replace),ue=A(String.prototype.indexOf),de=A(String.prototype.trim),S=A(Number.prototype.toString),C=A(Boolean.prototype.toString),w=typeof BigInt>`u`?null:A(BigInt.prototype.toString),T=typeof Symbol>`u`?null:A(Symbol.prototype.toString),E=A(Object.prototype.hasOwnProperty),D=A(Object.prototype.toString),O=A(RegExp.prototype.test),k=fe(TypeError);function A(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return y(e,t,n)}}function fe(e){return function(){return te(e,[...arguments])}}function j(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:x;if(f&&f(e,null),!b(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(ee(t)||(t[r]=e),i=e)}e[i]=!0}return e}function M(e){for(let t=0;t<e.length;t++)E(e,t)||(e[t]=null);return e}function N(e){let t=_(null);for(let r of d(e)){var n=l(r,2);let i=n[0],a=n[1];E(e,i)&&(b(a)?t[i]=M(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=N(a):t[i]=a)}return t}function pe(e){switch(typeof e){case`string`:return e;case`number`:return S(e);case`boolean`:return C(e);case`bigint`:return w?w(e):`0`;case`symbol`:return T?T(e):`Symbol()`;case`undefined`:return D(e);case`function`:case`object`:{if(e===null)return D(e);let t=e,n=P(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:D(e)}return D(e)}default:return D(e)}}function P(e,t){for(;e!==null;){let n=m(e,t);if(n){if(n.get)return A(n.get);if(typeof n.value==`function`)return A(n.value)}e=p(e)}function n(){return null}return n}function me(e){try{return O(e,``),!0}catch{return!1}}var he=h(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),ge=h(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),_e=h([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),ve=h([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),ye=h(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),be=h([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),xe=h([`#text`]),Se=h(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Ce=h(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),we=h(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),Te=h([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Ee=g(/{{[\w\W]*|^[\w\W]*}}/g),De=g(/<%[\w\W]*|^[\w\W]*%>/g),Oe=g(/\${[\w\W]*/g),ke=g(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ae=g(/^aria-[\-\w]+$/),je=g(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Me=g(/^(?:\w+script|data):/i),Ne=g(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pe=g(/^html$/i),Fe=g(/^[a-z][.\w]*(-[.\w]+)+$/i),Ie=g(/<[/\w!]/g),Le=g(/<[/\w]/g),Re=g(/<\/no(script|embed|frames)/i),ze=g(/\/>/i),Be={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ve=function(){return typeof window>`u`?null:window},He=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Ue=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},We=function(e,t,n,r){return E(e,t)&&b(e[t])?j(r.base?N(r.base):{},e[t],r.transform):n};function Ge(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ve(),t=e=>Ge(e);if(t.version=`3.4.11`,t.removed=[],!e||!e.document||e.document.nodeType!==Be.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,f=s.prototype,ee=P(f,`cloneNode`),p=P(f,`remove`),m=P(f,`nextSibling`),v=P(f,`childNodes`),y=P(f,`parentNode`),te=P(f,`shadowRoot`),S=P(f,`attributes`),C=o&&o.prototype?P(o.prototype,`nodeType`):null,w=o&&o.prototype?P(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let T,D=``,A,fe=!1,M=0,Ke=function(){if(M>0)throw k(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},qe=function(e){Ke(),M++;try{return T.createHTML(e)}finally{M--}},Je=function(e){Ke(),M++;try{return T.createScriptURL(e)}finally{M--}},Ye=function(){return fe||=(A=He(u,i),!0),A},F=n,Xe=F.implementation,I=F.createNodeIterator,Ze=F.createDocumentFragment,L=F.getElementsByTagName,Qe=r.importNode,R=Ue();t.isSupported=typeof d==`function`&&typeof y==`function`&&Xe&&Xe.createHTMLDocument!==void 0;let $e=Ee,et=De,tt=Oe,nt=ke,rt=Ae,it=Me,at=Ne,ot=Fe,st=je,z=null,ct=j({},[...he,...ge,..._e,...ye,...xe]),B=null,lt=j({},[...Se,...Ce,...we,...Te]),V=Object.seal(_(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ut=null,dt=null,H=Object.seal(_(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ft=!0,pt=!0,mt=!1,ht=!0,gt=!1,_t=!0,vt=!1,yt=!1,bt=null,xt=null,St=!1,Ct=!1,wt=!1,Tt=!1,Et=!0,Dt=!1,Ot=`user-content-`,kt=!0,At=!1,jt={},U=null,Mt=j({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Nt=null,Pt=j({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ft=null,It=j({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Lt=`http://www.w3.org/1998/Math/MathML`,Rt=`http://www.w3.org/2000/svg`,W=`http://www.w3.org/1999/xhtml`,zt=W,Bt=!1,Vt=null,Ht=j({},[Lt,Rt,W],se),Ut=h([`mi`,`mo`,`mn`,`ms`,`mtext`]),Wt=j({},Ut),Gt=h([`annotation-xml`]),Kt=j({},Gt),qt=j({},[`title`,`style`,`font`,`a`,`script`]),Jt=null,Yt=[`application/xhtml+xml`,`text/html`],G=null,Xt=null,K=n.createElement(`form`),Zt=function(e){return e instanceof RegExp||e instanceof Function},Qt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Xt&&Xt===e)return;(!e||typeof e!=`object`)&&(e={}),e=N(e),Jt=Yt.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,G=Jt===`application/xhtml+xml`?se:x,z=We(e,`ALLOWED_TAGS`,ct,{transform:G}),B=We(e,`ALLOWED_ATTR`,lt,{transform:G}),Vt=We(e,`ALLOWED_NAMESPACES`,Ht,{transform:se}),Ft=We(e,`ADD_URI_SAFE_ATTR`,It,{transform:G,base:It}),Nt=We(e,`ADD_DATA_URI_TAGS`,Pt,{transform:G,base:Pt}),U=We(e,`FORBID_CONTENTS`,Mt,{transform:G}),ut=We(e,`FORBID_TAGS`,N({}),{transform:G}),dt=We(e,`FORBID_ATTR`,N({}),{transform:G}),jt=E(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?N(e.USE_PROFILES):e.USE_PROFILES:!1,ft=e.ALLOW_ARIA_ATTR!==!1,pt=e.ALLOW_DATA_ATTR!==!1,mt=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ht=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,gt=e.SAFE_FOR_TEMPLATES||!1,_t=e.SAFE_FOR_XML!==!1,vt=e.WHOLE_DOCUMENT||!1,Ct=e.RETURN_DOM||!1,wt=e.RETURN_DOM_FRAGMENT||!1,Tt=e.RETURN_TRUSTED_TYPE||!1,St=e.FORCE_BODY||!1,Et=e.SANITIZE_DOM!==!1,Dt=e.SANITIZE_NAMED_PROPS||!1,kt=e.KEEP_CONTENT!==!1,At=e.IN_PLACE||!1,st=me(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:je,zt=typeof e.NAMESPACE==`string`?e.NAMESPACE:W,Wt=E(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?N(e.MATHML_TEXT_INTEGRATION_POINTS):j({},Ut),Kt=E(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?N(e.HTML_INTEGRATION_POINTS):j({},Gt);let t=E(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?N(e.CUSTOM_ELEMENT_HANDLING):_(null);if(V=_(null),E(t,`tagNameCheck`)&&Zt(t.tagNameCheck)&&(V.tagNameCheck=t.tagNameCheck),E(t,`attributeNameCheck`)&&Zt(t.attributeNameCheck)&&(V.attributeNameCheck=t.attributeNameCheck),E(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(V.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),g(V),gt&&(pt=!1),wt&&(Ct=!0),jt&&(z=j({},xe),B=_(null),jt.html===!0&&(j(z,he),j(B,Se)),jt.svg===!0&&(j(z,ge),j(B,Ce),j(B,Te)),jt.svgFilters===!0&&(j(z,_e),j(B,Ce),j(B,Te)),jt.mathMl===!0&&(j(z,ye),j(B,we),j(B,Te))),H.tagCheck=null,H.attributeCheck=null,E(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?H.tagCheck=e.ADD_TAGS:b(e.ADD_TAGS)&&(z===ct&&(z=N(z)),j(z,e.ADD_TAGS,G))),E(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?H.attributeCheck=e.ADD_ATTR:b(e.ADD_ATTR)&&(B===lt&&(B=N(B)),j(B,e.ADD_ATTR,G))),E(e,`ADD_URI_SAFE_ATTR`)&&b(e.ADD_URI_SAFE_ATTR)&&j(Ft,e.ADD_URI_SAFE_ATTR,G),E(e,`FORBID_CONTENTS`)&&b(e.FORBID_CONTENTS)&&(U===Mt&&(U=N(U)),j(U,e.FORBID_CONTENTS,G)),E(e,`ADD_FORBID_CONTENTS`)&&b(e.ADD_FORBID_CONTENTS)&&(U===Mt&&(U=N(U)),j(U,e.ADD_FORBID_CONTENTS,G)),kt&&(z[`#text`]=!0),vt&&j(z,[`html`,`head`,`body`]),z.table&&(j(z,[`tbody`]),delete ut.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw k(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw k(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=T;T=e.TRUSTED_TYPES_POLICY;try{D=qe(``)}catch(e){throw T=t,e}}else e.TRUSTED_TYPES_POLICY===null?(T=void 0,D=``):(T===void 0&&(T=Ye()),T&&typeof D==`string`&&(D=qe(``)));h&&h(e),Xt=e},q=j({},[...ge,..._e,...ve]),$t=j({},[...ye,...be]),en=function(e,t,n){return t.namespaceURI===W?e===`svg`:t.namespaceURI===Lt?e===`svg`&&(n===`annotation-xml`||Wt[n]):!!q[e]},tn=function(e,t,n){return t.namespaceURI===W?e===`math`:t.namespaceURI===Rt?e===`math`&&Kt[n]:!!$t[e]},nn=function(e,t,n){return t.namespaceURI===Rt&&!Kt[n]||t.namespaceURI===Lt&&!Wt[n]?!1:!$t[e]&&(qt[e]||!q[e])},rn=function(e){let t=y(e);(!t||!t.tagName)&&(t={namespaceURI:zt,tagName:`template`});let n=x(e.tagName),r=x(t.tagName);return Vt[e.namespaceURI]?e.namespaceURI===Rt?en(n,t,r):e.namespaceURI===Lt?tn(n,t,r):e.namespaceURI===W?nn(n,t,r):!!(Jt===`application/xhtml+xml`&&Vt[e.namespaceURI]):!1},J=function(e){ae(t.removed,{element:e});try{y(e).removeChild(e)}catch{if(p(e),!y(e))throw k(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},Y=function(e){let t=v(e);if(t){let e=[];ne(t,t=>{ae(e,t)}),ne(e,e=>{try{p(e)}catch{}})}let n=S(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},X=function(e,n){try{ae(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{ae(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Ct||wt)try{J(n)}catch{}else try{n.setAttribute(e,``)}catch{}},an=function(e){let t=S(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||B[G(i)]))try{e.removeAttribute(i)}catch{}}},Z=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(C?C(e):e.nodeType)===Be.element&&an(e);let n=v(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},on=function(e){let t=null,r=null;if(St)e=`<remove></remove>`+e;else{let t=ce(e,/^[\r\n\t ]+/);r=t&&t[0]}Jt===`application/xhtml+xml`&&zt===W&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=T?qe(e):e;if(zt===W)try{t=new l().parseFromString(i,Jt)}catch{}if(!t||!t.documentElement){t=Xe.createDocument(zt,`template`,null);try{t.documentElement.innerHTML=Bt?D:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),zt===W?L.call(t,vt?`html`:`body`)[0]:vt?t.documentElement:a},sn=function(e){return I.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Q=function(e){return e=le(e,$e,` `),e=le(e,et,` `),e=le(e,tt,` `),e},cn=function(e){e.normalize();let t=I.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;)n.data=Q(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&ne(r,e=>{un(e.content)&&cn(e.content)})},ln=function(e){let t=w?w(e):null;return typeof t!=`string`||G(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==S(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==C(e)||e.childNodes!==v(e)},un=function(e){if(!C||typeof e!=`object`||!e)return!1;try{return C(e)===Be.documentFragment}catch{return!1}},dn=function(e){if(!C||typeof e!=`object`||!e)return!1;try{return typeof C(e)==`number`}catch{return!1}};function $(e,n,r){e.length!==0&&ne(e,e=>{e.call(t,n,r,Xt)})}let fn=function(e,t){return!!(_t&&e.hasChildNodes()&&!dn(e.firstElementChild)&&O(Ie,e.textContent)&&O(Ie,e.innerHTML)||_t&&e.namespaceURI===W&&t===`style`&&dn(e.firstElementChild)||e.nodeType===Be.processingInstruction||_t&&e.nodeType===Be.comment&&O(Le,e.data))},pn=function(e,t){if(!ut[t]&&_n(t)&&(V.tagNameCheck instanceof RegExp&&O(V.tagNameCheck,t)||V.tagNameCheck instanceof Function&&V.tagNameCheck(t)))return!1;if(kt&&!U[t]){let t=y(e),n=v(e);if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=At?n[i]:ee(n[i],!0);t.insertBefore(r,m(e))}}}return J(e),!0},mn=function(e){if($(R.beforeSanitizeElements,e,null),ln(e))return J(e),!0;let n=G(w?w(e):e.nodeName);if($(R.uponSanitizeElement,e,{tagName:n,allowedTags:z}),fn(e,n))return J(e),!0;if(ut[n]||!(H.tagCheck instanceof Function&&H.tagCheck(n))&&!z[n])return pn(e,n);if((C?C(e):e.nodeType)===Be.element&&!rn(e)||(n===`noscript`||n===`noembed`||n===`noframes`)&&O(Re,e.innerHTML))return J(e),!0;if(gt&&e.nodeType===Be.text){let n=Q(e.textContent);e.textContent!==n&&(ae(t.removed,{element:e.cloneNode()}),e.textContent=n)}return $(R.afterSanitizeElements,e,null),!1},hn=function(e,t,r){if(dt[t]||Et&&(t===`id`||t===`name`)&&(r in n||r in K))return!1;let i=B[t]||H.attributeCheck instanceof Function&&H.attributeCheck(t,e);if(!(pt&&O(nt,t))&&!(ft&&O(rt,t))){if(!i){if(!(_n(e)&&(V.tagNameCheck instanceof RegExp&&O(V.tagNameCheck,e)||V.tagNameCheck instanceof Function&&V.tagNameCheck(e))&&(V.attributeNameCheck instanceof RegExp&&O(V.attributeNameCheck,t)||V.attributeNameCheck instanceof Function&&V.attributeNameCheck(t,e))||t===`is`&&V.allowCustomizedBuiltInElements&&(V.tagNameCheck instanceof RegExp&&O(V.tagNameCheck,r)||V.tagNameCheck instanceof Function&&V.tagNameCheck(r))))return!1}else if(!Ft[t]&&!O(st,le(r,at,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&ue(r,`data:`)===0&&Nt[e])&&!(mt&&!O(it,le(r,at,``)))&&r)return!1}return!0},gn=j({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),_n=function(e){return!gn[x(e)]&&O(ot,e)},vn=function(e,t,n,r){if(T&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return qe(r);case`TrustedScriptURL`:return Je(r)}return r},yn=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),ln(e)?J(e):ie(t.removed)}catch{X(n,e)}},bn=function(e){$(R.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||ln(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:B,forceKeepAttr:void 0},r=t.length,i=G(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=G(o),u=c,d=o===`value`?u:de(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,$(R.uponSanitizeAttribute,e,n),d=n.attrValue,Dt&&(l===`id`||l===`name`)&&ue(d,Ot)!==0&&(X(o,e),d=Ot+d),_t&&O(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){X(o,e);continue}if(l===`attributename`&&ce(d,`href`)){X(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){X(o,e);continue}if(!ht&&O(ze,d)){X(o,e);continue}if(gt&&(d=Q(d)),!hn(i,l,d)){X(o,e);continue}d=vn(i,l,s,d),d!==u&&yn(e,o,s,d)}}$(R.afterSanitizeAttributes,e,null)},xn=function(e){let t=null,n=sn(e);for($(R.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if($(R.uponSanitizeShadowNode,t,null),mn(t),bn(t),un(t.content)&&xn(t.content),(C?C(t):t.nodeType)===Be.element){let e=te(t);un(e)&&(Sn(e),xn(e))}$(R.afterSanitizeShadowDOM,e,null)},Sn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){xn(e.shadow);continue}let n=e.node,r=(C?C(n):n.nodeType)===Be.element,i=v(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=w?w(n):null;if(typeof e==`string`&&G(e)===`template`){let e=n.content;un(e)&&t.push({node:e,shadow:null})}}if(r){let e=te(n);un(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Bt=!e,Bt&&(e=`<!-->`),typeof e!=`string`&&!dn(e)&&(e=pe(e),typeof e!=`string`))throw k(`dirty is not a string, aborting`);if(!t.isSupported)return e;yt?(z=bt,B=xt):Qt(n),(R.uponSanitizeElement.length>0||R.uponSanitizeAttribute.length>0)&&(z=N(z)),R.uponSanitizeAttribute.length>0&&(B=N(B)),t.removed=[];let c=At&&typeof e!=`string`&&dn(e);if(c){let t=w?w(e):e.nodeName;if(typeof t==`string`){let e=G(t);if(!z[e]||ut[e])throw k(`root node is forbidden and cannot be sanitized in-place`)}if(ln(e))throw k(`root node is clobbered and cannot be sanitized in-place`);try{Sn(e)}catch(t){throw Y(e),t}}else if(dn(e))i=on(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===Be.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Sn(a);else{if(!Ct&&!gt&&!vt&&e.indexOf(`<`)===-1)return T&&Tt?qe(e):e;if(i=on(e),!i)return Ct?null:Tt?D:``}i&&St&&J(i.firstChild);let l=sn(c?e:i);try{for(;o=l.nextNode();)mn(o),bn(o),un(o.content)&&xn(o.content)}catch(t){throw c&&Y(e),t}if(c)return ne(t.removed,e=>{e.element&&Z(e.element)}),gt&&cn(e),e;if(Ct){if(gt&&cn(i),wt)for(s=Ze.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(B.shadowroot||B.shadowrootmode)&&(s=Qe.call(r,s,!0)),s}let u=vt?i.outerHTML:i.innerHTML;return vt&&z[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&O(Pe,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
3
|
+
`+u),gt&&(u=Q(u)),T&&Tt?qe(u):u},t.setConfig=function(){Qt(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),yt=!0,bt=z,xt=B},t.clearConfig=function(){Xt=null,yt=!1,bt=null,xt=null,T=A,D=``},t.isValidAttribute=function(e,t,n){return Xt||Qt({}),hn(G(e),G(t),n)},t.addHook=function(e,t){typeof t==`function`&&E(R,e)&&ae(R[e],t)},t.removeHook=function(e,t){if(E(R,e)){if(t!==void 0){let n=re(R[e],t);return n===-1?void 0:oe(R[e],n,1)[0]}return ie(R[e])}},t.removeHooks=function(e){E(R,e)&&(R[e]=[])},t.removeAllHooks=function(){R=Ue()},t}var Ke=Ge();function qe(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Je=qe();function Ye(e){Je=e}var F={exec:()=>null};function Xe(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function I(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(L.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Ze=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),L={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Xe(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Xe(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Xe(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Xe(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Xe(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:Xe(e=>RegExp(`^ {0,${e}}>`))},Qe=/^(?:[ \t]*(?:\n|$))+/,R=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,$e=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,et=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,tt=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,nt=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,rt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,it=I(rt).replace(/bull/g,nt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),at=I(rt).replace(/bull/g,nt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ot=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,st=/^[^\n]+/,z=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ct=I(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,z).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),B=I(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,nt).getRegex(),lt=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,V=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ut=I(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,V).replace(`tag`,lt).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),dt=I(ot).replace(`hr`,et).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,lt).getRegex(),H={blockquote:I(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,dt).getRegex(),code:R,def:ct,fences:$e,heading:tt,hr:et,html:ut,lheading:it,list:B,newline:Qe,paragraph:dt,table:F,text:st},ft=I(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,et).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,lt).getRegex(),pt={...H,lheading:at,table:ft,paragraph:I(ot).replace(`hr`,et).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,ft).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,lt).getRegex()},mt={...H,html:I(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,V).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:F,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:I(ot).replace(`hr`,et).replace(`heading`,` *#{1,6} *[^
|
|
4
|
+
]`).replace(`lheading`,it).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},ht=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,gt=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,_t=/^( {2,}|\\)\n(?!\s*$)/,vt=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,yt=/[\p{P}\p{S}]/u,bt=/[\s\p{P}\p{S}]/u,xt=/[^\s\p{P}\p{S}]/u,St=I(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,bt).getRegex(),Ct=/(?!~)[\p{P}\p{S}]/u,wt=/(?!~)[\s\p{P}\p{S}]/u,Tt=/(?:[^\s\p{P}\p{S}]|~)/u,Et=I(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Ze?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Dt=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Ot=I(Dt,`u`).replace(/punct/g,yt).getRegex(),kt=I(Dt,`u`).replace(/punct/g,Ct).getRegex(),At=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,jt=I(At,`gu`).replace(/notPunctSpace/g,xt).replace(/punctSpace/g,bt).replace(/punct/g,yt).getRegex(),U=I(At,`gu`).replace(/notPunctSpace/g,Tt).replace(/punctSpace/g,wt).replace(/punct/g,Ct).getRegex(),Mt=I(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,xt).replace(/punctSpace/g,bt).replace(/punct/g,yt).getRegex(),Nt=I(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,yt).getRegex(),Pt=I(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,xt).replace(/punctSpace/g,bt).replace(/punct/g,yt).getRegex(),Ft=I(/\\(punct)/,`gu`).replace(/punct/g,yt).getRegex(),It=I(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Lt=I(V).replace(`(?:-->|$)`,`-->`).getRegex(),Rt=I(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,Lt).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),W=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,zt=I(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,W).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Bt=I(/^!?\[(label)\]\[(ref)\]/).replace(`label`,W).replace(`ref`,z).getRegex(),Vt=I(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,z).getRegex(),Ht=I(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Bt).replace(`nolink`,Vt).getRegex(),Ut=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Wt={_backpedal:F,anyPunctuation:Ft,autolink:It,blockSkip:Et,br:_t,code:gt,del:F,delLDelim:F,delRDelim:F,emStrongLDelim:Ot,emStrongRDelimAst:jt,emStrongRDelimUnd:Mt,escape:ht,link:zt,nolink:Vt,punctuation:St,reflink:Bt,reflinkSearch:Ht,tag:Rt,text:vt,url:F},Gt={...Wt,link:I(/^!?\[(label)\]\((.*?)\)/).replace(`label`,W).getRegex(),reflink:I(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,W).getRegex()},Kt={...Wt,emStrongRDelimAst:U,emStrongLDelim:kt,delLDelim:Nt,delRDelim:Pt,url:I(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Ut).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:I(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Ut).getRegex()},qt={...Kt,br:I(_t).replace(`{2,}`,`*`).getRegex(),text:I(Kt.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Jt={normal:H,gfm:pt,pedantic:mt},Yt={normal:Wt,gfm:Kt,breaks:qt,pedantic:Gt},G={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Xt=e=>G[e];function K(e,t){if(t){if(L.escapeTest.test(e))return e.replace(L.escapeReplace,Xt)}else if(L.escapeTestNoEncode.test(e))return e.replace(L.escapeReplaceNoEncode,Xt);return e}function Zt(e){try{e=encodeURI(e).replace(L.percentDecode,`%`)}catch{return null}return e}function Qt(e,t){let n=e.replace(L.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(L.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(L.slashPipe,`|`);return n}function q(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function $t(e){let t=e.split(`
|
|
5
|
+
`),n=t.length-1;for(;n>=0&&L.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
6
|
+
`)}function en(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function tn(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function nn(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function rn(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
7
|
+
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
|
|
8
|
+
`)}var J=class{options;rules;lexer;constructor(e){this.options=e||Je}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:$t(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=rn(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=q(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:q(t[0],`
|
|
9
|
+
`),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:q(t[0],`
|
|
10
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=q(t[0],`
|
|
11
|
+
`).split(`
|
|
12
|
+
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
13
|
+
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
14
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
15
|
+
${s}`:s,r=r?`${r}
|
|
16
|
+
${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=t.raw+`
|
|
17
|
+
`+e.join(`
|
|
18
|
+
`),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
|
|
19
|
+
`+e.join(`
|
|
20
|
+
`),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
|
|
21
|
+
`);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=tn(t[2].split(`
|
|
22
|
+
`,1)[0],t[1].length),l=e.split(`
|
|
23
|
+
`,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
|
|
24
|
+
`,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let ee=e.split(`
|
|
25
|
+
`,1)[0],p;if(l=ee,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),p=l):p=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(p.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
|
|
26
|
+
`+p.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
|
|
27
|
+
`+l}u=!l.trim(),r+=ee+`
|
|
28
|
+
`,e=e.substring(ee.length+1),c=p.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]);let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1;if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=$t(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:q(t[0],`
|
|
29
|
+
`),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Qt(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
30
|
+
`):[],a={type:`table`,raw:q(t[0],`
|
|
31
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Qt(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:q(t[0],`
|
|
32
|
+
`),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
33
|
+
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=q(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=en(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),nn(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return nn(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},Y=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Je,this.options.tokenizer=this.options.tokenizer||new J,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:L,block:Jt.normal,inline:Yt.normal};this.options.pedantic?(t.block=Jt.pedantic,t.inline=Yt.pedantic):this.options.gfm&&(t.block=Jt.gfm,this.options.breaks?t.inline=Yt.breaks:t.inline=Yt.gfm),this.tokenizer.rules=t}static get rules(){return{block:Jt,inline:Yt}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(L.carriageReturn,`
|
|
34
|
+
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(L.tabCharGlobal,` `).replace(L.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
|
|
35
|
+
`:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
36
|
+
`)?``:`
|
|
37
|
+
`)+i.raw,n.text+=`
|
|
38
|
+
`+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
39
|
+
`)?``:`
|
|
40
|
+
`)+i.raw,n.text+=`
|
|
41
|
+
`+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let r=t.at(-1);n&&r?.type===`paragraph`?(r.raw+=(r.raw.endsWith(`
|
|
42
|
+
`)?``:`
|
|
43
|
+
`)+i.raw,r.text+=`
|
|
44
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
45
|
+
`)?``:`
|
|
46
|
+
`)+i.raw,n.text+=`
|
|
47
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!==null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!==null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!==null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``,s=1/0;for(;e;){if(e.length<s)s=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},X=class{options;parser;constructor(e){this.options=e||Je}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(L.notSpaceStart)?.[0],i=e.replace(L.endingNewline,``)+`
|
|
48
|
+
`;return r?`<pre><code class="language-`+K(r)+`">`+(n?i:K(i,!0))+`</code></pre>
|
|
49
|
+
`:`<pre><code>`+(n?i:K(i,!0))+`</code></pre>
|
|
50
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
51
|
+
${this.parser.parse(e)}</blockquote>
|
|
52
|
+
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
53
|
+
`}hr(e){return`<hr>
|
|
54
|
+
`}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
|
|
55
|
+
`+r+`</`+i+`>
|
|
56
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
57
|
+
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
58
|
+
`}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
|
|
59
|
+
<thead>
|
|
60
|
+
`+t+`</thead>
|
|
61
|
+
`+r+`</table>
|
|
62
|
+
`}tablerow({text:e}){return`<tr>
|
|
63
|
+
${e}</tr>
|
|
64
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
65
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${K(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Zt(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+K(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Zt(e);if(i===null)return K(n);e=i;let a=`<img src="${e}" alt="${K(n)}"`;return t&&(a+=` title="${K(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:K(e.text)}},an=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Z=class e{options;renderer;textRenderer;constructor(e){this.options=e||Je,this.options.renderer=this.options.renderer||new X,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new an}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},on=class{options;block;constructor(e){this.options=e||Je}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Y.lex:Y.lexInline}provideParser(e=this.block){return e?Z.parse:Z.parseInline}},sn=new class{defaults=qe();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Z;Renderer=X;TextRenderer=an;Lexer=Y;Tokenizer=J;Hooks=on;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new X(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new J(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new on;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];on.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&on.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Y.lex(e,t??this.defaults)}parser(e,t){return Z.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?Y.lex:Y.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?Z.parse:Z.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?Y.lex:Y.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?Z.parse:Z.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
66
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+K(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Q(e,t){return sn.parse(e,t)}Q.options=Q.setOptions=function(e){return sn.setOptions(e),Q.defaults=sn.defaults,Ye(Q.defaults),Q},Q.getDefaults=qe,Q.defaults=Je,Q.use=function(...e){return sn.use(...e),Q.defaults=sn.defaults,Ye(Q.defaults),Q},Q.walkTokens=function(e,t){return sn.walkTokens(e,t)},Q.parseInline=sn.parseInline,Q.Parser=Z,Q.parser=Z.parse,Q.Renderer=X,Q.TextRenderer=an,Q.Lexer=Y,Q.lexer=Y.lex,Q.Tokenizer=J,Q.Hooks=on,Q.parse=Q,Q.options,Q.setOptions,Q.use,Q.walkTokens,Q.parseInline,Z.parse,Y.lex;var cn=!1;function ln(){cn||=(Q.setOptions({breaks:!0,gfm:!0}),Ke.addHook(`afterSanitizeAttributes`,e=>{e.nodeName===`A`&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))}),!0)}function un(e){if(!e)return``;if(typeof window>`u`)return dn(e);ln();try{let t=Q.parse(e,{async:!1});return Ke.sanitize(t)}catch{return dn(e)}}function dn(e){return String(e).replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}var $=t(),fn=`[[bazilion:inbox-wake]]
|
|
67
|
+
`,pn=`[conversation summary]`,mn=40,hn=1e4,gn=320,_n=200;function vn(e,t){let n=e.findIndex(e=>e.type===`command_approval`&&e.approval.id===t.id);if(n===-1)return[...e,{type:`command_approval`,approval:t}];let r=[...e];return r[n]={type:`command_approval`,approval:t},r}function yn(e,t){return{message:e,attachments:t,bashApprovalMode:`interactive`}}function bn(e){return`/api/shell-approvals?agentId=${encodeURIComponent(e)}`}var xn=`slash commands:
|
|
68
|
+
/context — context breakdown (system prompt, tools, skills, history)
|
|
69
|
+
/compact [N] — summarize the head; keep the last N messages verbatim (default 10)
|
|
70
|
+
/reset — reset chat history for this agent
|
|
71
|
+
/help — show this list`;function Sn(e){if(!e)return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Cn(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(2)} MiB`}function wn(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let n=String(r.result),i=n.indexOf(`,`);t({name:e.name,data:i>=0?n.slice(i+1):n,mimeType:e.type||`application/octet-stream`})},r.onerror=()=>n(r.error),r.readAsDataURL(e)})}var Tn=e=>e.startsWith(`image/`);function En(e){let t=[],n=null;for(let r of e)if(r.role===`user`)n=null,t.push({type:`user`,content:r.content,...r.images&&r.images.length>0?{images:r.images}:{}});else if(r.role===`assistant`){if(r.content&&(n=null,t.push({type:`assistant`,content:r.content})),r.toolCalls&&r.toolCalls.length>0){n||(n={type:`tool`,items:[]},t.push(n));for(let e of r.toolCalls)n.items.push({kind:`call`,id:e.id,name:e.name,body:e.arguments})}}else if(r.role===`tool`){n||(n={type:`tool`,items:[]},t.push(n));let e=r.content.startsWith(`Error:`)||r.content.startsWith(`error:`);n.items.push({kind:e?`error`:`result`,id:r.toolCallId??``,name:r.toolName??``,body:r.content}),r.images&&r.images.length>0&&(t.push({type:`images`,images:r.images}),n=null)}return t}function Dn({agentId:e,agentName:t,initialMessages:n,initialSessionHead:r}){let[a,o]=(0,i.useState)(n),[s,c]=(0,i.useState)([]),[l,u]=(0,i.useState)([]),[d,f]=(0,i.useState)(!1),[ee,p]=(0,i.useState)(!1),[m,h]=(0,i.useState)(null),[g,_]=(0,i.useState)(``),[v,y]=(0,i.useState)([]),[te,ne]=(0,i.useState)(!1),[re,ie]=(0,i.useState)(!1),[ae,oe]=(0,i.useState)(!1),[b,x]=(0,i.useState)({}),[se,ce]=(0,i.useState)({}),le=(0,i.useRef)(null),ue=(0,i.useRef)(null),de=(0,i.useRef)(null),S=(0,i.useRef)(null),C=(0,i.useRef)(e),w=(0,i.useRef)(!1);C.current=e;let T=(0,i.useRef)(0),E=(0,i.useRef)(0),D=(0,i.useRef)(r??{file:null,size:0}),O=(0,i.useRef)(!1);O.current=ee;let k=ee||ae;(0,i.useEffect)(()=>{S.current?.abort(),S.current=null,w.current=!1,o(n),c([]),u([]),h(null),_(``),f(!1),p(!1),ie(!1),oe(!1),x({}),ce({}),D.current=r??{file:null,size:0}},[e]),(0,i.useEffect)(()=>{let t=new AbortController,n=!1;async function r(){try{let r=await fetch(bn(e),{signal:t.signal});if(!r.ok)return;let i=(await r.json()).approvals.filter(t=>t.agentId===e&&t.status===`pending`);if(n||i.length===0)return;sessionStorage.removeItem(`bz_pending_${e}`),w.current=!0,c(e=>i.reduce(vn,e)),oe(!0)}catch(e){if(e.name===`AbortError`)return}}return r(),()=>{n=!0,t.abort()}},[e]);let A=(0,i.useRef)(!0);(0,i.useLayoutEffect)(()=>{let e=le.current;e&&A.current&&(e.scrollTop=e.scrollHeight)});function fe(){let e=le.current;if(!e){A.current=!0;return}A.current=e.scrollHeight-e.scrollTop-e.clientHeight<mn}(0,i.useLayoutEffect)(()=>{let e=de.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,_n)}px`)},[g]),(0,i.useEffect)(()=>{let t=`bz_pending_${e}`;function n(){document.visibilityState===`visible`&&sessionStorage.getItem(t)&&(sessionStorage.removeItem(t),window.location.reload())}return document.addEventListener(`visibilitychange`,n),()=>document.removeEventListener(`visibilitychange`,n)},[e]),(0,i.useEffect)(()=>{if(!r)return;let t=!1,n=null;async function i(){if(!t){if(!document.hidden&&!O.current&&!re)try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}/sessions/head`);if(t.ok){let e=await t.json();if(typeof e.size==`number`){let t=D.current;(e.file!==t.file||e.size!==t.size)&&ie(!0)}}}catch{}n=setTimeout(i,hn)}}return n=setTimeout(i,hn),()=>{t=!0,n&&clearTimeout(n)}},[e,r,re]);async function j(){if(C.current===e)try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}/sessions/head`);if(!t.ok)return;let n=await t.json();C.current===e&&typeof n.size==`number`&&(D.current={file:n.file??null,size:n.size})}catch{}}function M(e){fe(),u(t=>[...t,{id:T.current++,content:e,afterIdx:E.current}])}async function N(){try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}/chat/context`);if(!t.ok){M(`/context failed: ${t.statusText}`);return}let n=await t.json(),r=(e,t)=>`${e.toLocaleString()} chars (~${t.toLocaleString()} tok)`,i=[];i.push(`context for ${n.agentId}`),i.push(`model: ${n.model}`),i.push(``),i.push(`system prompt: ${r(n.systemPrompt.chars,n.systemPrompt.tokens)}`);for(let e of n.systemPrompt.files)i.push(` - ${e.name}: ${e.chars.toLocaleString()} chars`);i.push(``),i.push(`tools: ${n.tools.count} (${n.tools.schemaChars.toLocaleString()} chars of schema)`);for(let e of n.tools.entries.slice(0,5))i.push(` - ${e.name}: ${e.schemaChars.toLocaleString()} chars`);if(n.skills.count>0){i.push(``),i.push(`skills: ${n.skills.count}`);for(let e of n.skills.entries.slice(0,10))i.push(` - ${e.name}: ${e.blockChars.toLocaleString()} chars`)}i.push(``),i.push(`history: ${n.history.messageEntries} messages / ${n.history.compactionEntries} compactions`),i.push(` ${r(n.history.chars,n.history.tokensEstimate)}`),i.push(` bytes on disk: ${Cn(n.history.bytes)}`),i.push(``),i.push(`TOTAL: ${r(n.totals.chars,n.totals.tokens)}`),M(i.join(`
|
|
72
|
+
`))}catch(e){M(`/context failed: ${e.message}`)}}async function pe(){if(a.length===0){M(`/reset: history already empty`);return}if(confirm(`reset chat history for this agent?`)){_e();try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}/chat/reset`,{method:`POST`});if(!t.ok){let e=t.statusText;try{e=(await t.json()).error||e}catch{}M(`/reset failed: ${e}`);return}o([]),c([]),u([]),M(`/reset: history wiped`)}catch(e){M(`/reset failed: ${e.message}`)}}}async function P(t){if(a.length<2){M(`/compact: need ≥2 messages to compact`);return}let n,r=t.trim();if(r){let e=Number(r);Number.isFinite(e)&&e>=0&&(n=Math.floor(e))}_e(),p(!0),f(!0);try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}/chat/compact`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n===void 0?{}:{keepTail:n})});if(!t.ok){let e=t.statusText;try{e=(await t.json()).error||e}catch{}M(`/compact failed: ${e}`);return}let r=await t.json();M(`/compact: ${r.before} → ${r.after} entries (${r.summarized} summarized, ${r.keptTail} kept verbatim; ~${r.tokensBefore.toLocaleString()} → ~${r.tokensAfter.toLocaleString()} tok). reloading…`),setTimeout(()=>window.location.reload(),400)}catch(e){M(`/compact failed: ${e.message}`)}finally{f(!1),p(!1)}}async function me(e){let t=e.trim();if(!t.startsWith(`/`))return!1;let n=t.split(/\s+/),r=(n[0]??``).toLowerCase(),i=n.slice(1).join(` `);switch(r){case`/help`:return M(xn),!0;case`/context`:return await N(),!0;case`/reset`:return await pe(),!0;case`/compact`:return await P(i),!0;default:return!1}}function he(){for(let e=a.length-1;e>=0;e--)if(a[e]?.role===`user`)return e;return-1}function ge(){if(s.length>0||k)return;let e=he();if(e===-1)return;let t=a[e];t&&(h(e),_(t.content),de.current?.focus())}function _e(){h(null)}async function ve(e){if(!e||k)return;let t=Array.from(e);if(t.length===0)return;let n=await Promise.all(t.map(wn));y(e=>[...e,...n].slice(0,16))}function ye(e){let t=Array.from(e.clipboardData.files);t.some(e=>e.type.startsWith(`image/`))&&(e.preventDefault(),ve(t))}function be(e){if(Array.from(e.dataTransfer.types).includes(`Files`)){if(e.preventDefault(),k){ne(!1);return}ne(!0)}}function xe(e){e.currentTarget===e.target&&ne(!1)}function Se(e){e.dataTransfer.files.length!==0&&(e.preventDefault(),ne(!1),!k&&ve(e.dataTransfer.files))}let Ce=(0,i.useCallback)(async t=>{let n=v;if(!t.trim()&&n.length===0||k||(_(``),await me(t)))return;y([]);let r=null;if(m!==null){let n=m;try{let i=await fetch(`/api/agents/${encodeURIComponent(e)}/chat/truncate`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({keepCount:n})});if(!i.ok){let e=i.statusText;try{e=(await i.json()).error||e}catch{}_(t),alert(`failed to replace last turn: ${e}`);return}r=a.slice(0,n),o(r),h(null)}catch(e){_(t),alert(`failed to replace last turn: ${e.message}`);return}}fe();let i=n.filter(e=>Tn(e.mimeType)),s=n.filter(e=>!Tn(e.mimeType));c([{type:`user`,content:t,...i.length>0?{images:i}:{},...s.length>0?{files:s.map(e=>({name:e.name??`file`}))}:{}}]),oe(!1),x({}),ce({}),w.current=!1,sessionStorage.setItem(`bz_pending_${e}`,`1`);let l=new AbortController;S.current=l,p(!0),f(!0);let u=!1;try{let r=await fetch(`/api/agents/${encodeURIComponent(e)}/chat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(yn(t,n)),signal:l.signal});if(r.status===202){let t=await r.json();c(e=>[...e,{type:`error`,content:`[approval pending] ${t.approvalId} · expires ${new Date(t.expiresAt).toLocaleString()} · review in /approvals`}]),sessionStorage.removeItem(`bz_pending_${e}`);return}if(!r.ok||!r.body){let e=r.statusText;try{e=(await r.json()).error||e}catch{}c(t=>[...t,{type:`error`,content:`[error] ${e}`}]);return}let i=r.body.getReader(),a=new TextDecoder,o=``;for(;;){let{done:e,value:t}=await i.read();if(e)break;o+=a.decode(t,{stream:!0});let n=o.split(`
|
|
73
|
+
`);o=n.pop()??``;for(let e of n){if(!e.trim())continue;let t;try{t=JSON.parse(e)}catch{continue}(t.kind===`done`||t.kind===`fatal`)&&(u=!0),we(t)}}if(o.trim())try{let e=JSON.parse(o);(e.kind===`done`||e.kind===`fatal`)&&(u=!0),we(e)}catch{}await j(),sessionStorage.removeItem(`bz_pending_${e}`)}catch(t){t.name!==`AbortError`&&c(e=>[...e,{type:`error`,content:`[network error] ${t.message}`}]),sessionStorage.removeItem(`bz_pending_${e}`)}finally{C.current===e&&S.current===l&&(!u&&w.current&&oe(!0),f(!1),p(!1),S.current=null)}},[e,m,a,k,v]);function we(t){if(C.current!==e)return;if(t.kind===`fatal`){w.current=!1,c(e=>[...e.map(e=>e.type===`command_approval`&&e.approval.status===`pending`?{type:`command_approval`,approval:{...e.approval,status:`cancelled`}}:e),{type:`error`,content:`[fatal] ${t.error}`}]),oe(!1);return}if(t.kind===`done`){w.current=!1,o(t.messages),c([]),oe(!1),x({}),ce({});return}if(t.kind!==`event`)return;let n=t.event;if(fe(),n.type!==`user_message`){if(n.type===`assistant_delta`){f(!1),c(e=>{let t=[...e],r=t[t.length-1];return r?.type===`assistant`?t[t.length-1]={type:`assistant`,content:r.content+n.delta}:t.push({type:`assistant`,content:n.delta}),t});return}if(n.type===`assistant_message`){f(!1),c(e=>{let t=[...e];return t[t.length-1]?.type===`assistant`?t[t.length-1]={type:`assistant`,content:n.text}:t.push({type:`assistant`,content:n.text}),t});return}if(n.type===`command_approval`){if(n.approval.agentId!==e)return;w.current=!0,f(n.approval.status!==`pending`&&n.approval.status!==`cancelled`),c(e=>vn(e,n.approval));return}if(n.type===`tool_call`||n.type===`tool_result`||n.type===`tool_error`){f(n.type!==`tool_call`);let e=n.type===`tool_call`?{kind:`call`,id:n.id,name:n.name,body:n.arguments}:n.type===`tool_result`?{kind:`result`,id:n.id,name:n.name,body:n.result}:{kind:`error`,id:n.id,name:n.name,body:n.error},t=n.type===`tool_result`?n.images:void 0;c(n=>{let r=[...n],i=r[r.length-1];return i?.type===`tool`?r[r.length-1]={type:`tool`,items:[...i.items,e]}:r.push({type:`tool`,items:[e]}),t&&t.length>0&&r.push({type:`images`,images:t}),r});return}if(n.type===`file`){c(e=>[...e,{type:`file`,name:n.name,mimeType:n.mimeType,data:n.data}]);return}n.type===`error`&&c(e=>[...e,{type:`error`,content:`[error] ${n.error}`}])}}async function Te(t){if(C.current!==e)return null;try{let n=await fetch(bn(e));if(!n.ok)return null;let r=await n.json();if(C.current!==e)return null;let i=r.approvals.find(n=>n.id===t&&n.agentId===e);return i&&c(e=>vn(e,i)),i??null}catch{return null}}async function Ee(t,n){if(!(t.agentId!==e||t.status!==`pending`)){x(e=>({...e,[t.id]:!0})),ce(e=>{let n={...e};return delete n[t.id],n});try{let r=await fetch(`/api/shell-approvals/${encodeURIComponent(t.id)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({decision:n})}),i=await r.json().catch(()=>null);if(C.current!==e)return;if(i?.approval?.agentId===e&&c(e=>vn(e,i.approval)),!r.ok){let e=i?.error??`Decision failed (${r.status})`,n=jn(e);if(n){c(e=>vn(e,{...t,status:n}));return}throw Error(e)}}catch(n){let r=await Te(t.id);if(C.current!==e)return;(!r||r.status===`pending`)&&ce(e=>({...e,[t.id]:n instanceof Error?n.message:String(n)}))}finally{C.current===e&&x(e=>({...e,[t.id]:!1}))}}}async function De(){let t=S.current!==null;try{let n=await fetch(`/api/agents/${encodeURIComponent(e)}/cancel`,{method:`POST`});if(C.current!==e)return;if(n.ok||n.status===204){t||(w.current=!1,c(e=>e.map(e=>e.type===`command_approval`&&e.approval.status===`pending`?{type:`command_approval`,approval:{...e.approval,status:`cancelled`}}:e)),oe(!1));return}}catch{}C.current===e&&(t?S.current?.abort():c(e=>[...e,{type:`error`,content:`[cancel failed] could not reach the active turn`}]))}function Oe(e){e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),Ce(g))}let ke=En(a);E.current=ke.length+s.length;let Ae=(()=>{if(s.length>0||k)return-1;for(let e=ke.length-1;e>=0;e--)if(ke[e]?.type===`user`)return e;return-1})(),je=(()=>{if(m===null)return-1;let e=0;for(let t=0;t<ke.length;t++)if(ke[t]?.type===`user`){if(e===a.slice(0,m+1).filter(e=>e.role===`user`).length-1)return t;e++}return Ae})();return(0,$.jsxs)(`div`,{className:`relative flex h-full flex-col overflow-hidden rounded-[16px] border border-frost bg-snow shadow-baziu-sm`,onDragOver:be,onDragLeave:xe,onDrop:Se,children:[te&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-[16px] border-2 border-dashed border-sapphire bg-sapphire-glow/80 text-[0.95em] font-medium text-sapphire-deep`,children:`drop images or files to attach`}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-frost px-4 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`a`,{href:`/`,className:`inline-flex h-7 items-center rounded-md border border-frost px-2 text-xs font-semibold text-mocha lg:hidden`,children:`← agents`}),(0,$.jsx)(`h1`,{className:`truncate font-display text-[1.2rem] text-charcoal`,children:t})]}),(0,$.jsx)(`a`,{href:`/agents/${e}`,className:`shrink-0 text-xs text-mocha-light hover:text-sapphire`,children:`settings →`})]}),re&&(0,$.jsxs)(`div`,{className:`mx-5 mt-2 flex items-center gap-2 rounded-md border border-sapphire bg-frost px-4 py-2 text-[0.86em] text-mocha`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 flex-none rounded-full bg-sapphire`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`flex-1`,children:ae?`the recovered turn has new activity — reload to see it`:`new activity from another source — reload to see it`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`rounded-sm bg-sapphire px-3 py-1 text-[0.92em] text-snow hover:opacity-90`,children:`reload`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>ie(!1),className:`px-1 text-mocha-light hover:text-mocha`,"aria-label":`dismiss`,children:`×`})]}),(0,$.jsxs)(`div`,{ref:le,onScroll:fe,className:`min-h-[240px] flex-1 overflow-y-auto px-5 py-5 ${m===null?``:`is-editing`}`,children:[ke.length===0&&s.length===0&&l.length===0&&(0,$.jsx)(`p`,{className:`py-12 text-center italic text-fawn`,children:`start a conversation…`}),(()=>{let e=[],t=0,n=n=>{for(;t<l.length&&l[t].afterIdx<=n;){let n=l[t];e.push((0,$.jsx)(On,{entry:{type:`system`,content:n.content},onCommandApprovalDecision:Ee},`y-${n.id}`)),t++}};n(0);for(let t=0;t<ke.length;t++){let r=ke[t];e.push((0,$.jsx)(On,{entry:r,isLastUser:t===Ae&&m===null,isWillDrop:je!==-1&&t>=je,onEdit:ge,onCommandApprovalDecision:Ee,commandApprovalBusy:r.type===`command_approval`&&!!b[r.approval.id],commandApprovalError:r.type===`command_approval`?se[r.approval.id]:void 0},`s-${t}`)),n(t+1)}for(let t=0;t<s.length;t++){let r=s[t];e.push((0,$.jsx)(On,{entry:r,onCommandApprovalDecision:Ee,commandApprovalBusy:r.type===`command_approval`&&!!b[r.approval.id],commandApprovalError:r.type===`command_approval`?se[r.approval.id]:void 0},`l-${t}`)),n(ke.length+t+1)}for(;t<l.length;){let n=l[t];e.push((0,$.jsx)(On,{entry:{type:`system`,content:n.content},onCommandApprovalDecision:Ee},`y-${n.id}`)),t++}return e})(),d&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1 text-[0.85em] text-mocha-light`,children:[(0,$.jsx)(Pn,{}),(0,$.jsx)(Pn,{delay:`0.15s`}),(0,$.jsx)(Pn,{delay:`0.3s`}),(0,$.jsx)(`span`,{children:`agent is thinking…`})]})]}),m!==null&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-frost bg-sapphire-glow px-5 py-2 text-[0.85em] text-sapphire-deep`,children:[(0,$.jsx)(`span`,{children:`editing last message — submit to replace, or`}),(0,$.jsx)(`button`,{type:`button`,onClick:_e,className:`ml-auto rounded-sm border border-sapphire-light bg-transparent px-2 py-0.5 text-[0.92em] text-sapphire-deep hover:bg-snow`,children:`cancel`})]}),v.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 border-t border-frost bg-ivory px-5 pt-3`,children:v.map((e,t)=>{let n=()=>y(e=>e.filter((e,n)=>n!==t));return Tn(e.mimeType)?(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:`pending attachment`,className:`h-16 w-16 rounded-md border border-frost object-cover`}),(0,$.jsx)(`button`,{type:`button`,onClick:n,className:`absolute -right-1.5 -top-1.5 flex h-5 w-5 items-center justify-center rounded-full border border-frost bg-snow text-[0.7em] text-mocha hover:border-sapphire hover:text-sapphire`,"aria-label":`remove attachment`,children:`✕`})]},`${e.mimeType}-${t}`):(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border border-frost bg-snow px-2 py-1 text-[0.82em] text-mocha`,children:[(0,$.jsx)(`span`,{children:`📄`}),(0,$.jsx)(`span`,{className:`max-w-[160px] truncate`,children:e.name??`file`}),(0,$.jsx)(`button`,{type:`button`,onClick:n,className:`text-[0.85em] text-mocha hover:text-sapphire`,"aria-label":`remove attachment`,children:`✕`})]},`${e.name??`file`}-${t}`)})}),(0,$.jsxs)(`form`,{className:`flex items-end gap-2 border-t border-frost bg-ivory px-5 py-3`,onSubmit:e=>{e.preventDefault(),Ce(g)},children:[(0,$.jsx)(`input`,{ref:ue,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{ve(e.target.files),e.target.value=``}}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>ue.current?.click(),disabled:k,title:`attach images or files`,"aria-label":`attach files`,className:`rounded-md border-[1.5px] border-frost bg-snow px-3 py-2 text-[1em] text-mocha transition-colors hover:border-sapphire hover:text-sapphire disabled:cursor-not-allowed disabled:opacity-50`,children:`📎`}),(0,$.jsx)(`textarea`,{ref:de,rows:1,value:g,onChange:e=>_(e.target.value),onKeyDown:Oe,onPaste:ye,disabled:k,placeholder:`say something… (Shift+Enter for newline; paste or 📎 to attach images/files)`,autoComplete:`off`,className:`max-h-[200px] min-h-[2.4rem] flex-1 resize-none overflow-y-auto rounded-md border-[1.5px] border-frost bg-snow px-3 py-2 text-[0.93em] leading-[1.45] text-chocolate outline-none transition-colors focus:border-sapphire focus:shadow-[0_0_0_3px_var(--color-sapphire-glow)]`}),(0,$.jsx)(`button`,{type:`submit`,disabled:k||!g.trim()&&v.length===0,className:`rounded-md bg-sapphire px-4 py-2 text-[0.92em] font-semibold text-snow transition-colors hover:bg-sapphire-deep disabled:cursor-not-allowed disabled:opacity-50`,children:`send`}),k&&(0,$.jsx)(`button`,{type:`button`,onClick:De,className:`rounded-md border-[1.5px] border-frost bg-transparent px-3 py-1.5 text-[0.92em] font-medium text-mocha hover:border-sapphire-light hover:bg-sapphire-glow hover:text-sapphire`,children:`cancel`})]})]})}function On({entry:e,isLastUser:t,isWillDrop:n,onEdit:r,onCommandApprovalDecision:i,commandApprovalBusy:a,commandApprovalError:o}){let s=n?`opacity-40 [&_.bubble-content]:line-through`:``;if(e.type===`user`){if(e.content.startsWith(fn)){let t=e.content.slice(24);return(0,$.jsxs)(`div`,{className:`my-4 flex flex-col items-end ${s}`,children:[(0,$.jsx)(`span`,{className:`mb-1 text-[0.72em] font-semibold uppercase tracking-wider text-mocha opacity-90`,children:`inbox`}),(0,$.jsx)(`div`,{className:`bubble-content max-w-[85%] whitespace-pre-wrap break-words rounded-[14px_14px_4px_14px] border border-fawn border-l-[3px] border-l-mocha-light bg-ivory px-3 py-2 font-mono text-[0.88em] leading-[1.5] text-mocha`,children:t})]})}return(0,$.jsxs)(`div`,{className:`team relative my-4 flex flex-col items-end ${s}`,children:[(0,$.jsx)(`span`,{className:`sr-only`,children:`you`}),e.images&&e.images.length>0&&(0,$.jsx)(`div`,{className:`mb-1 flex max-w-[85%] flex-wrap justify-end gap-1`,children:e.images.map((e,t)=>(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:`attachment`,className:`max-h-48 rounded-lg border border-sapphire-light`},t))}),e.files&&e.files.length>0&&(0,$.jsx)(`div`,{className:`mb-1 flex max-w-[85%] flex-wrap justify-end gap-1`,children:e.files.map((e,t)=>(0,$.jsxs)(`span`,{className:`flex items-center gap-1 rounded-md border border-sapphire-light bg-sapphire-glow px-2 py-1 text-[0.8em] text-chocolate`,children:[`📄 `,(0,$.jsx)(`span`,{className:`max-w-[180px] truncate`,children:e.name})]},t))}),e.content&&(0,$.jsx)(`div`,{className:`bubble-content max-w-[85%] whitespace-pre-wrap break-words rounded-[14px_14px_4px_14px] border border-sapphire-light bg-sapphire-glow px-3 py-2 text-chocolate`,children:e.content}),t&&r&&(0,$.jsx)(`button`,{type:`button`,onClick:r,title:`edit and resend — replaces the last turn`,className:`absolute left-1 top-1 rounded-sm border border-fawn bg-ivory px-2 py-0.5 text-[0.78em] font-medium text-mocha opacity-65 transition hover:border-sapphire hover:bg-sapphire-glow hover:text-sapphire hover:opacity-100 team-hover:opacity-100 team-focus-within:opacity-100`,children:`edit`})]})}if(e.type===`assistant`){if(e.content.startsWith(pn)){let t=e.content.slice(22).trim();return(0,$.jsx)(`div`,{className:`my-3 border-y border-dashed border-frost py-2 text-[0.85em] italic text-mocha-light ${s}`,children:(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer select-none text-center [&::-webkit-details-marker]:hidden`,children:`— conversation summary (click to expand) —`}),(0,$.jsx)(`div`,{className:`md-content mt-2 rounded-sm bg-frost/40 p-2 not-italic`,dangerouslySetInnerHTML:{__html:un(t)}})]})})}return e.content.startsWith(`[error]`)||e.content.startsWith(`[fatal]`)||e.content.startsWith(`[network error]`)?(0,$.jsxs)(`div`,{className:`my-4 flex flex-col items-start ${s}`,children:[(0,$.jsx)(`span`,{className:`mb-1 text-[0.72em] font-semibold uppercase tracking-wider text-danger`,children:`error`}),(0,$.jsx)(`div`,{className:`bubble-content rounded-r-sm border-l-[3px] border-l-danger bg-danger/10 py-1 pl-3 pr-2 leading-[1.55]`,dangerouslySetInnerHTML:{__html:un(e.content)}})]}):(0,$.jsxs)(`div`,{className:`my-4 flex flex-col items-start ${s}`,children:[(0,$.jsx)(`span`,{className:`sr-only`,children:`agent`}),(0,$.jsx)(`div`,{className:`md-content bubble-content w-full leading-[1.55] text-chocolate`,dangerouslySetInnerHTML:{__html:un(e.content)}})]})}if(e.type===`tool`)return(0,$.jsx)(Mn,{items:e.items,dropCls:s});if(e.type===`images`)return(0,$.jsx)(`div`,{className:`my-2 space-y-2 ${s}`,children:e.images.map((e,t)=>(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:`screenshot`,className:`block max-w-full rounded-lg border border-fawn`},t))});if(e.type===`file`){let t=e.mimeType.startsWith(`image/`),n=`data:${e.mimeType};base64,${e.data}`;return(0,$.jsxs)(`div`,{className:`my-2 ${s}`,children:[t&&(0,$.jsx)(`img`,{src:n,alt:e.name,className:`mb-1 block max-w-full rounded-lg border border-fawn`}),(0,$.jsxs)(`a`,{href:n,download:e.name,className:`inline-flex items-center gap-2 rounded-md border border-fawn bg-ivory px-3 py-2 text-[0.88em] text-mocha hover:border-sapphire hover:text-sapphire`,children:[(0,$.jsx)(`span`,{children:`📄`}),(0,$.jsx)(`span`,{className:`max-w-[260px] truncate`,children:e.name}),(0,$.jsx)(`span`,{className:`text-[0.85em] opacity-70`,children:`download`})]})]})}return e.type===`command_approval`?(0,$.jsx)(kn,{approval:e.approval,busy:a,error:o,onDecision:i}):e.type===`system`?(0,$.jsxs)(`div`,{className:`my-3 rounded-r-sm border-l-[3px] border-sapphire bg-sapphire-glow px-3 py-1 font-mono text-[0.88em] text-sapphire-deep ${s}`,children:[(0,$.jsx)(`span`,{className:`mr-2 font-semibold uppercase tracking-wider opacity-80`,children:`system`}),(0,$.jsx)(`span`,{className:`whitespace-pre-wrap`,children:e.content})]}):e.type===`error`?(0,$.jsx)(`div`,{className:`my-3 rounded-r-sm border-l-[3px] border-danger bg-danger/10 px-3 py-1 text-[0.92em] text-danger ${s}`,children:e.content}):null}function kn({approval:e,busy:t=!1,error:n,onDecision:i}){let a=e.status===`pending`;return(0,$.jsxs)(`section`,{className:`my-3 rounded-lg border border-danger/50 bg-danger/5 p-4 text-chocolate`,"aria-label":`Shell command approval`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`m-0 text-[0.72em] font-semibold uppercase tracking-wider text-danger`,children:`Shell command approval`}),(0,$.jsx)(`h2`,{className:`m-0 mt-1 font-body text-[0.95em] font-semibold`,children:a?`A risky command is waiting for you`:`Command decision recorded`})]}),(0,$.jsx)(`span`,{className:`rounded-full border border-danger/30 px-2 py-0.5 text-[0.75em] font-semibold uppercase tracking-wide text-danger`,children:e.status.replaceAll(`_`,` `)})]}),(0,$.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto whitespace-pre-wrap break-words rounded-md border border-fawn bg-snow p-3 font-mono text-[0.82em] leading-[1.45] text-charcoal`,children:e.command}),(0,$.jsx)(`ul`,{className:`mt-3 space-y-1.5 pl-5 text-[0.84em] leading-[1.4] text-mocha`,children:e.risks.map(e=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-chocolate`,children:e.message}),` `,(0,$.jsx)(`code`,{className:`text-[0.9em]`,children:e.code})]},`${e.code}:${e.span.start}:${e.span.end}`))}),a?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`p`,{className:`mt-3 text-[0.78em] text-mocha-light`,children:[`This approval expires`,` `,(0,$.jsx)(`time`,{dateTime:new Date(e.expiresAt).toISOString(),children:new Date(e.expiresAt).toLocaleString()}),`. Deny blocks only this command; cancel stops the whole turn.`]}),n&&(0,$.jsx)(`p`,{role:`alert`,className:`mt-2 rounded-md bg-danger/10 px-3 py-2 text-[0.82em] text-danger`,children:n}),i&&(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(r,{variant:`primary`,disabled:t,onClick:()=>i(e,`deny`),children:`Deny`}),(0,$.jsx)(r,{variant:`danger`,disabled:t,onClick:()=>i(e,`allow`),children:`Allow once`})]})]}):(0,$.jsx)(`p`,{role:`status`,className:`mt-3 text-[0.84em] font-medium text-mocha`,children:An(e.status)})]})}function An(e){switch(e){case`pending`:return`Waiting for a decision.`;case`allowed`:return`Allowed once — the command may run for this tool call only.`;case`denied`:return`Denied — the command was not run.`;case`auto_denied`:return`Automatically denied — no interactive approval path was available.`;case`expired`:return`Expired — the command was not run.`;case`cancelled`:return`Cancelled — the command was not run.`}}function jn(e){if(!e.startsWith(`shell approval already decided: `))return null;let t=e.slice(32);switch(t){case`allowed`:case`denied`:case`auto_denied`:case`expired`:case`cancelled`:return t;default:return null}}function Mn({items:e,dropCls:t}){let[n,r]=(0,i.useState)(!1),a=(0,i.useRef)(null),[o,s]=(0,i.useState)(!1);return(0,i.useLayoutEffect)(()=>{let e=a.current;e&&s(e.scrollHeight>324)},[e.length]),(0,$.jsxs)(`div`,{className:`my-1.5 rounded-r-sm border-l-[3px] border-fawn bg-ivory px-3 py-2 font-mono text-[0.82em] leading-[1.5] text-mocha-light ${t}`,children:[(0,$.jsxs)(`div`,{ref:a,className:`relative overflow-hidden`,style:{maxHeight:n?`none`:`${gn}px`},children:[e.map((e,t)=>(0,$.jsx)(Nn,{item:e},t)),o&&!n&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-10`,style:{background:`linear-gradient(to bottom, rgba(247,240,229,0), var(--color-ivory))`}})]}),o&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`mt-2 rounded-sm border border-fawn bg-transparent px-2 py-0.5 text-[0.9em] text-mocha hover:border-sapphire hover:text-sapphire-deep`,children:n?`show less ↑`:`show more ↓`})]})}function Nn({item:e}){if(e.kind===`call`){let t=Sn(e.body),n=t.includes(`
|
|
74
|
+
`);return(0,$.jsxs)(`div`,{className:`whitespace-pre-wrap break-words py-0.5`,children:[(0,$.jsx)(`span`,{className:`mr-1 opacity-45`,children:`→`}),(0,$.jsx)(`span`,{className:`font-medium text-mocha`,children:e.name}),n?(0,$.jsx)(`pre`,{className:`ml-4 mt-0.5 rounded-sm bg-[rgba(42,31,22,0.04)] px-2 py-1 font-mono text-[0.95em] leading-[1.4] text-mocha`,children:t}):t?(0,$.jsxs)(`span`,{children:[` (`,t,`)`]}):null]})}return e.kind===`error`?(0,$.jsxs)(`div`,{className:`whitespace-pre-wrap break-words py-0.5 text-rose-baziu`,children:[(0,$.jsx)(`span`,{className:`mr-1 opacity-45`,children:`←`}),e.body]}):(0,$.jsxs)(`div`,{className:`whitespace-pre-wrap break-words py-0.5`,children:[(0,$.jsx)(`span`,{className:`mr-1 opacity-45`,children:`←`}),e.body]})}function Pn({delay:e=`0s`}){return(0,$.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-mocha-light/60`,style:{animationDelay:e},"aria-hidden":`true`})}var Fn=`default`,In=`default`,Ln=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];export{Dn as i,In as n,Ln as r,Fn as t};
|