@timqi/pier 0.0.29 → 0.1.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/agent/config.js +22 -0
- package/dist/agent/events.js +4 -1
- package/dist/agent/listing.js +114 -16
- package/dist/agent/pi.js +158 -16
- package/dist/channels/lark-panel.js +1 -1
- package/dist/core/inbox.js +1 -1
- package/dist/core/router.js +4 -0
- package/dist/core/types.js +13 -1
- package/dist/db.js +30 -0
- package/dist/drain.js +1 -1
- package/dist/extensions/web/content.js +2 -2
- package/dist/main.js +8 -1
- package/dist/secrets.js +1 -1
- package/dist/service.js +2 -2
- package/dist/settings.js +31 -10
- package/dist/tasks/agent.js +109 -73
- package/dist/tasks/callbacks.js +1 -3
- package/dist/tasks/command.js +27 -8
- package/dist/tasks/execution.js +6 -4
- package/dist/tasks/groups.js +35 -26
- package/dist/tasks/messages.js +33 -27
- package/dist/tasks/outbox.js +48 -21
- package/dist/tasks/routes.js +1 -4
- package/dist/tasks/runs.js +10 -4
- package/dist/tasks/service.js +24 -12
- package/dist/tasks/store.js +17 -3
- package/dist/tasks/tool.js +97 -25
- package/dist/tools.js +2 -2
- package/dist/update.js +1 -1
- package/dist/web/instance.js +10 -3
- package/dist/web/providers.js +9 -2
- package/dist/web/public/assets/{activity-D3m4L2IL.js → activity-Bl3vZukb.js} +2 -2
- package/dist/web/public/assets/activity-Bl3vZukb.js.br +0 -0
- package/dist/web/public/assets/activity-Bl3vZukb.js.gz +0 -0
- package/dist/web/public/assets/boards-DYuf4Mlj.js +1 -0
- package/dist/web/public/assets/boards-DYuf4Mlj.js.br +0 -0
- package/dist/web/public/assets/boards-DYuf4Mlj.js.gz +0 -0
- package/dist/web/public/assets/explorer-qJH_9nTE.js +4 -0
- package/dist/web/public/assets/explorer-qJH_9nTE.js.br +0 -0
- package/dist/web/public/assets/explorer-qJH_9nTE.js.gz +0 -0
- package/dist/web/public/assets/index-Dqdb-Eqt.js +85 -0
- package/dist/web/public/assets/index-Dqdb-Eqt.js.br +0 -0
- package/dist/web/public/assets/index-Dqdb-Eqt.js.gz +0 -0
- package/dist/web/public/assets/index-DzmMzvi_.css +2 -0
- package/dist/web/public/assets/index-DzmMzvi_.css.br +0 -0
- package/dist/web/public/assets/index-DzmMzvi_.css.gz +0 -0
- package/dist/web/public/assets/runs-BLJu7EXN.js +1 -0
- package/dist/web/public/assets/runs-BLJu7EXN.js.br +0 -0
- package/dist/web/public/assets/runs-BLJu7EXN.js.gz +0 -0
- package/dist/web/public/assets/settings-BrdVh-Zi.js +5 -0
- package/dist/web/public/assets/settings-BrdVh-Zi.js.br +0 -0
- package/dist/web/public/assets/settings-BrdVh-Zi.js.gz +0 -0
- package/dist/web/public/assets/task-runs-CeQS1rxa.js +3 -0
- package/dist/web/public/assets/task-runs-CeQS1rxa.js.br +0 -0
- package/dist/web/public/assets/task-runs-CeQS1rxa.js.gz +0 -0
- package/dist/web/public/assets/tasks-bcb3fYdK.js +4 -0
- package/dist/web/public/assets/tasks-bcb3fYdK.js.br +0 -0
- package/dist/web/public/assets/tasks-bcb3fYdK.js.gz +0 -0
- package/dist/web/public/index.html +76 -120
- package/dist/web/public/index.html.br +0 -0
- package/dist/web/public/index.html.gz +0 -0
- package/dist/web/public/manifest.webmanifest +2 -2
- package/dist/web/public/manifest.webmanifest.br +0 -0
- package/dist/web/public/manifest.webmanifest.gz +0 -0
- package/dist/web/server.js +40 -8
- package/dist/web/session-state.js +5 -5
- package/package.json +2 -1
- package/skills/pier-tasks/SKILL.md +145 -160
- package/dist/web/public/assets/activity-D3m4L2IL.js.br +0 -0
- package/dist/web/public/assets/activity-D3m4L2IL.js.gz +0 -0
- package/dist/web/public/assets/boards-BIObcQeX.js +0 -1
- package/dist/web/public/assets/boards-BIObcQeX.js.br +0 -0
- package/dist/web/public/assets/boards-BIObcQeX.js.gz +0 -0
- package/dist/web/public/assets/explorer-C_rSWPNB.js +0 -4
- package/dist/web/public/assets/explorer-C_rSWPNB.js.br +0 -0
- package/dist/web/public/assets/explorer-C_rSWPNB.js.gz +0 -0
- package/dist/web/public/assets/index-CX3fYZY5.css +0 -2
- package/dist/web/public/assets/index-CX3fYZY5.css.br +0 -0
- package/dist/web/public/assets/index-CX3fYZY5.css.gz +0 -0
- package/dist/web/public/assets/index-uFsZkKOQ.js +0 -85
- package/dist/web/public/assets/index-uFsZkKOQ.js.br +0 -0
- package/dist/web/public/assets/index-uFsZkKOQ.js.gz +0 -0
- package/dist/web/public/assets/runs-Ch6DZq6O.js +0 -1
- package/dist/web/public/assets/runs-Ch6DZq6O.js.br +0 -0
- package/dist/web/public/assets/runs-Ch6DZq6O.js.gz +0 -0
- package/dist/web/public/assets/settings-BWcEIEcv.js +0 -5
- package/dist/web/public/assets/settings-BWcEIEcv.js.br +0 -0
- package/dist/web/public/assets/settings-BWcEIEcv.js.gz +0 -0
- package/dist/web/public/assets/task-runs-DPkwv2UE.js +0 -3
- package/dist/web/public/assets/task-runs-DPkwv2UE.js.br +0 -0
- package/dist/web/public/assets/task-runs-DPkwv2UE.js.gz +0 -0
- package/dist/web/public/assets/tasks-DTiCi2mH.js +0 -4
- package/dist/web/public/assets/tasks-DTiCi2mH.js.br +0 -0
- package/dist/web/public/assets/tasks-DTiCi2mH.js.gz +0 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/tasks-bcb3fYdK.js","assets/task-runs-CeQS1rxa.js","assets/runs-BLJu7EXN.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},t=([e,n,r])=>{let i=document.createElementNS(`http://www.w3.org/2000/svg`,e);return Object.keys(n).forEach(e=>{i.setAttribute(e,String(n[e]))}),r?.length&&r.forEach(e=>{let n=t(e);i.appendChild(n)}),i},n=(n,r={})=>t([`svg`,{...e,...r},n]),r=[[`path`,{d:`m12 19-7-7 7-7`}],[`path`,{d:`M19 12H5`}]],i=[[`path`,{d:`M7 7h10v10`}],[`path`,{d:`M7 17 17 7`}]],a=[[`path`,{d:`M20 6 9 17l-5-5`}]],o=[[`path`,{d:`m6 9 6 6 6-6`}]],s=[[`path`,{d:`m15 18-6-6 6-6`}]],c=[[`path`,{d:`m9 18 6-6-6-6`}]],l=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`}],[`path`,{d:`M12 17h.01`}]],u=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 6v6l4 2`}]],d=[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`}],[`path`,{d:`m9 10-5 5 5 5`}]],ee=[[`path`,{d:`M12 15V3`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}],[`path`,{d:`m7 10 5 5 5-5`}]],f=[[`circle`,{cx:`12`,cy:`12`,r:`1`}],[`circle`,{cx:`19`,cy:`12`,r:`1`}],[`circle`,{cx:`5`,cy:`12`,r:`1`}]],p=[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],te=[[`path`,{d:`M12 10v6`}],[`path`,{d:`M9 13h6`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`}]],ne=[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`}]],re=[[`path`,{d:`M13 5h8`}],[`path`,{d:`M13 12h8`}],[`path`,{d:`M13 19h8`}],[`path`,{d:`m3 17 2 2 4-4`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`}]],ie=[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`}]],ae=[[`path`,{d:`M4 5h16`}],[`path`,{d:`M4 12h16`}],[`path`,{d:`M4 19h16`}]],oe=[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`}]],se=[[`path`,{d:`M5 12h14`}]],ce=[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`}]],le=[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`}]],m=[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`}]],ue=[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`}],[`path`,{d:`m15 5 4 4`}]],de=[[`path`,{d:`M5 12h14`}],[`path`,{d:`M12 5v14`}]],fe=[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`}],[`path`,{d:`M21 3v5h-5`}]],pe=[[`path`,{d:`m21 21-4.34-4.34`}],[`circle`,{cx:`11`,cy:`11`,r:`8`}]],me=[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`}],[`path`,{d:`m21.854 2.147-10.94 10.939`}]],he=[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],ge=[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}]],_e=[[`circle`,{cx:`12`,cy:`12`,r:`4`}],[`path`,{d:`M12 2v2`}],[`path`,{d:`M12 20v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`m17.66 17.66 1.41 1.41`}],[`path`,{d:`M2 12h2`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m6.34 17.66-1.41 1.41`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}]],ve=[[`path`,{d:`M9 14 4 9l5-5`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`}]],ye=[[`path`,{d:`M18 6 6 18`}],[`path`,{d:`m6 6 12 12`}]],h=(e,t=`h-3.5 w-3.5`)=>n(e,{class:`flex-none ${t}`,"aria-hidden":`true`,focusable:`false`});function be(){let e={ChevronLeft:s,ChevronRight:c,Clock:u,Ellipsis:f,LayoutDashboard:ne,ListTodo:re,Menu:ae,Plus:de,RotateCw:fe,Search:pe,Send:me,Settings:he,Square:ge,Undo2:ve};for(let t of document.querySelectorAll(`[data-icon]`)){let n=e[t.dataset.icon];if(!n)throw Error(`Unknown shell icon: ${t.dataset.icon}`);t.replaceChildren(h(n,`h-full w-full`))}let t=h(o);t.setAttribute(`stroke`,`#737373`),document.documentElement.style.setProperty(`--select-chevron`,`url("data:image/svg+xml,${encodeURIComponent(t.outerHTML)}")`)}var xe=/[\u201c\u201d"\u2018\u2019'()\uff08\uff09\u300c\u300d\u300e\u300f\u3010\u3011\u300a\u300b\u3008\u3009[\]]/;function Se(e){let t=[],n=e=>`\uE010${t.push(e)-1}\uE011`,r=e.replace(/```[\s\S]*?```/g,e=>n(e)).replace(/`[^`\n]+`/g,e=>n(e));return r=r.replace(/\*\*(\S|\S[\s\S]*?\S)\*\*/g,(e,t)=>{let n=``,r=``,i=t;for(;i.length>1&&xe.test(i[0]);)n+=i[0],i=i.slice(1);for(;i.length>1&&xe.test(i.at(-1));)r=i.at(-1)+r,i=i.slice(0,-1);return n||r?`${n}**${i}**${r}`:e}),r.replace(/\uE010(\d+)\uE011/g,(e,n)=>t[Number(n)]??``)}var g=e=>!e.text.trim()&&e.suggestions.length===0,Ce=e=>e===`xhigh`?`Extra high`:e[0].toUpperCase()+e.slice(1),we=e=>{if(e<1e3)return String(e);let t=e/1e3;return t>=9.95?`${Math.round(t)}K`:`${t.toFixed(1)}K`},Te=/(?:^|\n)[ \t]*-{3,}[ \t]*\r?\n((?:[ \t]*\[[^\]\r\n]+\][ \t]*(?:[||][ \t]*)?)+)\s*$/,Ee=/\[([^\]\r\n]+)\]/g,De=5,Oe=/<silent>([\s\S]*?)<\/silent>/gi;function ke(e){let t=[...e.matchAll(Oe)].map(e=>(e[1]??``).trim()).filter(Boolean);return t.length?t.join(` · `):void 0}function Ae(e,t){let n=je(e),r=ke(e),i=Te.exec(n);if(!i?.[1])return{text:n,suggestions:[],meta:t,silence:r};let a=[...i[1].matchAll(Ee)].map(e=>(e[1]??``).trim()).filter(Boolean).slice(0,De);return a.length?{text:n.slice(0,i.index).trimEnd(),suggestions:a,meta:t,silence:r}:{text:n,suggestions:[],meta:t,silence:r}}var je=e=>Se(e.replace(Oe,``).trim()),_=/^(?:\s|[-*+>]|\d+[.)])/;function Me(e,t=0){let n=e.lastIndexOf(`
|
|
3
|
+
`)+1,r=``,i=!1,a=t,o=-1,s=``;for(let c=t;c<n;){let t=e.indexOf(`
|
|
4
|
+
`,c),n=e.slice(c,t);c=t+1;let l=/^\s*(`{3,}|~{3,})(.*)$/.exec(n);if(!r&&!i&&!n.trim()){o<0&&s&&(o=c);continue}!r&&!i&&o>=0&&!(_.test(s)&&_.test(n))&&(a=o);let u=l?.[1]??``;if(!r&&u&&!i?r=u:r&&u[0]===r[0]&&u.length>=r.length&&!l?.[2]?.trim()&&(r=``),!r&&(!u||i))for(let e of n.matchAll(/<(\/?)silent>/gi))i=!e[1];o=-1,s=n}return a}var v=/^\[(?:([^\n[\]<>]*)<([^\n[\]<>]+)>)? ?((?:\d{4}-\d{2}-\d{2} )?\d{1,2}:\d{2})?\]\n/;function Ne(e){let t=v.exec(e);return!t?.[2]&&!t?.[3]?{text:e}:{...t[1]?{name:t[1]}:{},...t[2]?{id:t[2]}:{},...t[3]?{when:t[3]}:{},text:e.slice(t[0].length)}}var Pe=/(?:\n\[[^\]\n]*(?:\]\(\s*<?file:\/\/[^\n]*|$))+$/,Fe=/^\s*`[^`\n]{40,}`\s+(\S[\s\S]*)$/;function Ie(e){if(!e)return e;let{text:t}=Ne(e);return t===e?e:t.replace(Pe,``).replace(Fe,`$1`).replace(/\s+/g,` `).trim()||e}function Le(e){let t,n=!1;return()=>(n=!0,t??=(async()=>{for(;n;)n=!1,await e()})().finally(()=>{t=void 0}))}var y=(e,t,n=`POST`)=>fetch(e,{method:n,headers:{"content-type":`application/json`},body:JSON.stringify(t)});async function b(e,t){return(await e.json().catch(()=>({}))).error??`${t} (${e.status})`}async function Re(e,t,n){let r;try{r=await fetch(e,n)}catch(e){return{ok:!1,error:`${t}: ${String(e)}`}}if(!r.ok)return{ok:!1,error:await b(r,t)};try{return{ok:!0,value:await r.json()}}catch(e){return{ok:!1,error:`${t}: ${String(e)}`}}}async function ze(e,t,n){let r=await Re(e,t,n);if(!r.ok)throw Error(r.error);return r.value}async function Be(e,t,n){try{let r=await fetch(e,{method:t});return r.ok?void 0:await b(r,n)}catch(e){return`${n}: ${String(e)}`}}function Ve(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 He(e){if(Array.isArray(e))return e}function Ue(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 We(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ge(e,t){return He(e)||Ue(e,t)||Ke(e,t)||We()}function Ke(e,t){if(e){if(typeof e==`string`)return Ve(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)?Ve(e,t):void 0}}var qe=Object.entries,Je=Object.setPrototypeOf,Ye=Object.isFrozen,Xe=Object.getPrototypeOf,Ze=Object.getOwnPropertyDescriptor,x=Object.freeze,S=Object.seal,Qe=Object.create,$e=typeof Reflect<`u`&&Reflect,et=$e.apply,tt=$e.construct;x||=function(e){return e},S||=function(e){return e},et||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},tt||=function(e){return new e(...[...arguments].slice(1))};var nt=T(Array.prototype.forEach),rt=T(Array.prototype.lastIndexOf),it=T(Array.prototype.pop),at=T(Array.prototype.push),ot=T(Array.prototype.splice),st=Array.isArray,ct=T(String.prototype.toLowerCase),lt=T(String.prototype.toString),ut=T(String.prototype.match),dt=T(String.prototype.replace),ft=T(String.prototype.indexOf),pt=T(String.prototype.trim),mt=T(Number.prototype.toString),ht=T(Boolean.prototype.toString),gt=typeof BigInt>`u`?null:T(BigInt.prototype.toString),_t=typeof Symbol>`u`?null:T(Symbol.prototype.toString),C=T(Object.prototype.hasOwnProperty),vt=T(Object.prototype.toString),w=T(RegExp.prototype.test),yt=bt(TypeError);function T(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return et(e,t,n)}}function bt(e){return function(){return tt(e,[...arguments])}}function E(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ct;if(Je&&Je(e,null),!st(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(Ye(t)||(t[r]=e),i=e)}e[i]=!0}return e}function xt(e){for(let t=0;t<e.length;t++)C(e,t)||(e[t]=null);return e}function D(e){let t=Qe(null);for(let r of qe(e)){var n=Ge(r,2);let i=n[0],a=n[1];C(e,i)&&(t[i]=st(a)?xt(a):a&&typeof a==`object`&&a.constructor===Object?D(a):a)}return t}function St(e){switch(typeof e){case`string`:return e;case`number`:return mt(e);case`boolean`:return ht(e);case`bigint`:return gt?gt(e):`0`;case`symbol`:return _t?_t(e):`Symbol()`;case`undefined`:return vt(e);case`function`:case`object`:{if(e===null)return vt(e);let t=e,n=Ct(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:vt(e)}return vt(e)}default:return vt(e)}}function Ct(e,t){for(;e!==null;){let n=Ze(e,t);if(n){if(n.get)return T(n.get);if(typeof n.value==`function`)return T(n.value)}e=Xe(e)}function n(){return null}return n}function wt(e){try{return w(e,``),!0}catch{return!1}}var Tt=x(`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(`.`)),Et=x(`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(`.`)),Dt=x([`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`]),Ot=x([`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`]),kt=x(`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(`.`)),At=x([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),jt=x([`#text`]),Mt=x(`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(`.`)),Nt=x(`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.dominant-baseline.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.pointer-events.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-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.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(`.`)),Pt=x(`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(`.`)),Ft=x([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),It=S(/{{[\w\W]*|^[\w\W]*}}/g),Lt=S(/<%[\w\W]*|^[\w\W]*%>/g),Rt=S(/\${[\w\W]*/g),zt=S(/^data-[\-\w.\u00B7-\uFFFF]+$/),Bt=S(/^aria-[\-\w]+$/),Vt=S(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ht=S(/^(?:\w+script|data):/i),Ut=S(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Wt=S(/^html$/i),Gt=S(/^[a-z][.\w]*(-[.\w]+)+$/i),Kt=S(/<[/\w!]/g),qt=S(/<[/\w]/g),Jt=S(/<\/no(script|embed|frames)/i),Yt=S(/\/>/i),O={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Xt=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],Zt=x(E({},Xt)),Qt=function(){let e={};return nt(Xt,t=>{e[t]=S(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),x(e)}(),$t=function(){return typeof window>`u`?null:window},en=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}},tn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},nn=function(e,t,n,r){return C(e,t)&&st(e[t])?E(r.base?D(r.base):{},e[t],r.transform):n},rn=function(e,t,n){let r=C(e,t)?e[t]:void 0;return r&&typeof r==`object`?D(r):n()};function an(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:$t(),t=e=>an(e);if(t.version=`3.4.14`,t.removed=[],!e||!e.document||e.document.nodeType!==O.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,d=s.prototype,ee=Ct(d,`cloneNode`),f=Ct(d,`remove`),p=Ct(d,`nextSibling`),te=Ct(d,`childNodes`),ne=Ct(d,`parentNode`),re=Ct(d,`shadowRoot`),ie=Ct(d,`attributes`),ae=o&&o.prototype?Ct(o.prototype,`nodeType`):null,oe=o&&o.prototype?Ct(o.prototype,`nodeName`):null,se=o&&o.prototype?Ct(o.prototype,`ownerDocument`):null,ce=function(e){return ae?ae(e):e.nodeType},le=function(e){return oe?oe(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let m,ue=``,de,fe=!1,pe=0,me=function(){if(pe>0)throw yt(`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.`)},he=function(e){me(),pe++;try{return m.createHTML(e)}finally{pe--}},ge=function(e){me(),pe++;try{return m.createScriptURL(e)}finally{pe--}},_e=function(){return fe||=(de=en(u,i),!0),de},ve=n,ye=ve.implementation,h=ve.createNodeIterator,be=ve.createDocumentFragment,xe=ve.getElementsByTagName,Se=r.importNode,g=tn();t.isSupported=typeof qe==`function`&&typeof ne==`function`&&ye&&ye.createHTMLDocument!==void 0;let Ce=It,we=Lt,Te=Rt,Ee=zt,De=Bt,Oe=Ht,ke=Ut,Ae=Gt,je=Vt,_=null,Me=E({},[...Tt,...Et,...Dt,...kt,...jt]),v=null,Ne=E({},[...Mt,...Nt,...Pt,...Ft]),Pe=Object.seal(Qe(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}})),Fe=null,Ie=null,Le=Object.seal(Qe(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),y=!0,b=!0,Re=!1,ze=!0,Be=!1,Ve=!0,He=!1,Ue=!1,We=null,Ge=null,Ke=!1,Je=!1,Ye=!1,Xe=!1,Ze=!0,$e=!1,et=`user-content-`,tt=!0,mt=!1,ht={},gt=null,_t=E({},`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(`.`)),vt=null,T=E({},[`audio`,`video`,`img`,`source`,`image`,`track`]),bt=null,xt=E({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Xt=`http://www.w3.org/1998/Math/MathML`,on=`http://www.w3.org/2000/svg`,k=`http://www.w3.org/1999/xhtml`,A=k,sn=!1,cn=null,ln=E({},[Xt,on,k],lt),j=x([`mi`,`mo`,`mn`,`ms`,`mtext`]),un=E({},j),M=x([`annotation-xml`]),dn=E({},M),fn=E({},[`title`,`style`,`font`,`a`,`script`]),pn=null,mn=[`application/xhtml+xml`,`text/html`],N=null,hn=null,gn=n.createElement(`form`),_n=function(e){return e instanceof RegExp||e instanceof Function},vn=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(hn&&hn===e)return;(!e||typeof e!=`object`)&&(e={}),e=D(e),pn=mn.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,N=pn===`application/xhtml+xml`?lt:ct,_=nn(e,`ALLOWED_TAGS`,Me,{transform:N}),v=nn(e,`ALLOWED_ATTR`,Ne,{transform:N}),cn=nn(e,`ALLOWED_NAMESPACES`,ln,{transform:lt}),bt=nn(e,`ADD_URI_SAFE_ATTR`,xt,{transform:N,base:xt}),vt=nn(e,`ADD_DATA_URI_TAGS`,T,{transform:N,base:T}),gt=nn(e,`FORBID_CONTENTS`,_t,{transform:N}),Fe=nn(e,`FORBID_TAGS`,D({}),{transform:N}),Ie=nn(e,`FORBID_ATTR`,D({}),{transform:N}),ht=C(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?D(e.USE_PROFILES):e.USE_PROFILES:!1,y=e.ALLOW_ARIA_ATTR!==!1,b=e.ALLOW_DATA_ATTR!==!1,Re=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ze=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Be=e.SAFE_FOR_TEMPLATES||!1,Ve=e.SAFE_FOR_XML!==!1,He=e.WHOLE_DOCUMENT||!1,Je=e.RETURN_DOM||!1,Ye=e.RETURN_DOM_FRAGMENT||!1,Xe=e.RETURN_TRUSTED_TYPE||!1,Ke=e.FORCE_BODY||!1,Ze=e.SANITIZE_DOM!==!1,$e=e.SANITIZE_NAMED_PROPS||!1,tt=e.KEEP_CONTENT!==!1,mt=e.IN_PLACE||!1,je=wt(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Vt,A=typeof e.NAMESPACE==`string`?e.NAMESPACE:k,un=rn(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>E({},j)),dn=rn(e,`HTML_INTEGRATION_POINTS`,()=>E({},M));let t=rn(e,`CUSTOM_ELEMENT_HANDLING`,()=>Qe(null));if(Pe=Qe(null),C(t,`tagNameCheck`)&&_n(t.tagNameCheck)&&(Pe.tagNameCheck=t.tagNameCheck),C(t,`attributeNameCheck`)&&_n(t.attributeNameCheck)&&(Pe.attributeNameCheck=t.attributeNameCheck),C(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(Pe.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),S(Pe),Be&&(b=!1),Ye&&(Je=!0),ht&&(_=E({},jt),v=Qe(null),ht.html===!0&&(E(_,Tt),E(v,Mt)),ht.svg===!0&&(E(_,Et),E(v,Nt),E(v,Ft)),ht.svgFilters===!0&&(E(_,Dt),E(v,Nt),E(v,Ft)),ht.mathMl===!0&&(E(_,kt),E(v,Pt),E(v,Ft))),Le.tagCheck=null,Le.attributeCheck=null,C(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?Le.tagCheck=e.ADD_TAGS:st(e.ADD_TAGS)&&(_===Me&&(_=D(_)),E(_,e.ADD_TAGS,N))),C(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?Le.attributeCheck=e.ADD_ATTR:st(e.ADD_ATTR)&&(v===Ne&&(v=D(v)),E(v,e.ADD_ATTR,N))),C(e,`ADD_FORBID_CONTENTS`)&&st(e.ADD_FORBID_CONTENTS)&&(gt===_t&&(gt=D(gt)),E(gt,e.ADD_FORBID_CONTENTS,N)),tt&&(_[`#text`]=!0),He&&E(_,[`html`,`head`,`body`]),_.table&&(E(_,[`tbody`]),delete Fe.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw yt(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw yt(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=m;m=e.TRUSTED_TYPES_POLICY;try{ue=he(``)}catch(e){throw m=t,e}}else e.TRUSTED_TYPES_POLICY===null?(m=void 0,ue=``):(m===void 0&&(m=_e()),m&&typeof ue==`string`&&(ue=he(``)));x&&x(e),hn=e},yn=E({},[...Et,...Dt,...Ot]),bn=E({},[...kt,...At]),xn=function(e,t,n){return t.namespaceURI===k?e===`svg`:t.namespaceURI===Xt?e===`svg`&&(n===`annotation-xml`||un[n]):!!yn[e]},Sn=function(e,t,n){return t.namespaceURI===k?e===`math`:t.namespaceURI===on?e===`math`&&dn[n]:!!bn[e]},Cn=function(e,t,n){return t.namespaceURI===on&&!dn[n]||t.namespaceURI===Xt&&!un[n]?!1:!bn[e]&&(fn[e]||!yn[e])},wn=function(e){let t=ne(e);(!t||!t.tagName)&&(t={namespaceURI:A,tagName:`template`});let n=ct(e.tagName),r=ct(t.tagName);return cn[e.namespaceURI]?e.namespaceURI===on?xn(n,t,r):e.namespaceURI===Xt?Sn(n,t,r):e.namespaceURI===k?Cn(n,t,r):!!(pn===`application/xhtml+xml`&&cn[e.namespaceURI]):!1},Tn=function(e){at(t.removed,{element:e});try{ne(e).removeChild(e)}catch{if(f(e),!ne(e))throw yt(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},En=function(e,t,n){try{e.removeAttributeNode(t)}catch{try{e.removeAttribute(n)}catch{}}},Dn=function(e){An(e);let t=te(e);if(t){let e=[];nt(t,t=>{at(e,t)}),nt(e,e=>{try{f(e)}catch{}})}let n=ie(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&En(e,r,i)}},On=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}at(t.removed,{attribute:r||null,from:n});try{r?n.removeAttributeNode(r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Je||Ye)try{Tn(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},kn=function(e){let t=ie(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||v[N(i)]||En(e,r,i)}},An=function(e){let t=[e];for(;t.length>0;){let e=t.pop();ce(e)===O.element&&kn(e);let n=te(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},jn=function(e,t){return Ve?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Mn=function(e){if(!Ve)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=ce(e);if(n===O.processingInstruction||n===O.comment&&w(qt,e.data)){try{f(e)}catch{}continue}if(n===O.element){let t=e,n=N(le(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&jn(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=te(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},Nn=function(e){let t=null,r=null;if(Ke)e=`<remove></remove>`+e;else{let t=ut(e,/^[\r\n\t ]+/);r=t&&t[0]}pn===`application/xhtml+xml`&&A===k&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=m?he(e):e;if(A===k)try{t=new l().parseFromString(i,pn)}catch{}if(!t||!t.documentElement){t=ye.createDocument(A,`template`,null);try{t.documentElement.innerHTML=sn?ue:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),A===k?xe.call(t,He?`html`:`body`)[0]:He?t.documentElement:a},Pn=function(e){let t=se?se(e):e.ownerDocument;return h.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Fn=function(e){return e=dt(e,Ce,` `),e=dt(e,we,` `),e=dt(e,Te,` `),e},In=function(e){e.normalize();let t=se?se(e):e.ownerDocument,n=h.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=Fn(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&nt(i,e=>{P(e.content)&&In(e.content)})},Ln=function(e){let t=oe?oe(e):null;return typeof t!=`string`||N(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==ie(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==ae(e)||e.childNodes!==te(e)},P=function(e){if(!ae||typeof e!=`object`||!e)return!1;try{return ae(e)===O.documentFragment}catch{return!1}},Rn=function(e){if(!ae||typeof e!=`object`||!e)return!1;try{return typeof ae(e)==`number`}catch{return!1}};function F(e,n,r){e.length!==0&&nt(e,e=>{e.call(t,n,r,hn)})}let zn=function(e,t){return!!(Ve&&e.hasChildNodes()&&!Rn(e.firstElementChild)&&w(Kt,e.textContent)&&w(Kt,e.innerHTML)||Ve&&e.namespaceURI===k&&Zt[t]&&(Rn(e.firstElementChild)||typeof e.textContent==`string`&&w(Qt[t],e.textContent))||e.nodeType===O.processingInstruction||Ve&&e.nodeType===O.comment&&w(qt,e.data))},Bn=function(e,t){return e instanceof RegExp?w(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Vn=function(e,t,n){if(!Fe[t]&&qn(t)&&Bn(Pe.tagNameCheck,t))return!1;if(tt&&!gt[t]){let t=ne(e),r=te(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?ee(r[a],!0):r[a];t.insertBefore(i,p(e))}}}return Tn(e),!0},Hn=function(e,t,n,r){return e.length===0?t:t===n||t===r?D(t):t},Un=function(e,t){return e===t||ne(e)!==null?!1:(mt&&An(e),!0)},Wn=function(e,n){if(F(g.beforeSanitizeElements,e,null),Un(e,n))return!0;if(Ln(e))return Tn(e),!0;let r=N(le(e));if(_=Hn(g.uponSanitizeElement,_,Me,We),F(g.uponSanitizeElement,e,{tagName:r,allowedTags:_}),Un(e,n))return!0;if(zn(e,r))return Tn(e),!0;if(Fe[r]||!(Le.tagCheck instanceof Function&&Le.tagCheck(r))&&!_[r]){let t=Vn(e,r,n);return t===!1&&F(g.afterSanitizeElements,e,null),t}if(ce(e)===O.element&&!wn(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&w(Jt,e.innerHTML))return Tn(e),!0;if(Be&&e.nodeType===O.text){let n=Fn(e.textContent);e.textContent!==n&&(at(t.removed,{element:e.cloneNode()}),e.textContent=n)}return F(g.afterSanitizeElements,e,null),!1},Gn=function(e,t,r){if(Ie[t]||jn(t,e)||Ze&&(t===`id`||t===`name`)&&(r in n||r in gn))return!1;let i=v[t]||Le.attributeCheck instanceof Function&&Le.attributeCheck(t,e);return b&&w(Ee,t)||y&&w(De,t)?!0:i?bt[t]||w(je,dt(r,ke,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&ft(r,`data:`)===0&&vt[e]||Re&&!w(Oe,dt(r,ke,``))?!0:!r:qn(e)&&Bn(Pe.tagNameCheck,e)&&Bn(Pe.attributeNameCheck,t,e)||t===`is`&&Pe.allowCustomizedBuiltInElements&&Bn(Pe.tagNameCheck,r)},Kn=E({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),qn=function(e){return!Kn[ct(e)]&&w(Ae,e)},Jn=function(e,t,n,r){if(m&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return he(r);case`TrustedScriptURL`:return ge(r)}return r},Yn=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),Ln(e)?Tn(e):it(t.removed)}catch{On(n,e)}},Xn=function(e){F(g.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||Ln(e))return;v=Hn(g.uponSanitizeAttribute,v,Ne,Ge);let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:v,forceKeepAttr:void 0},r=t.length,i=N(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=N(o),u=c,d=o===`value`?u:pt(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,F(g.uponSanitizeAttribute,e,n),d=n.attrValue,$e&&(l===`id`||l===`name`)&&ft(d,et)!==0&&(On(o,e,a),d=et+d),Ve&&w(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){On(o,e,a);continue}if(l===`attributename`&&ut(d,`href`)){On(o,e,a);continue}if(!n.forceKeepAttr){if(!n.keepAttr){On(o,e,a);continue}if(!ze&&w(Yt,d)){On(o,e,a);continue}if(Be&&(d=Fn(d)),!Gn(i,l,d)){On(o,e,a);continue}d=Jn(i,l,s,d),d!==u&&Yn(e,o,s,d)}}F(g.afterSanitizeAttributes,e,null)},Zn=function(e){let t=null,n=Pn(e);for(F(g.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(F(g.uponSanitizeShadowNode,t,null),Wn(t,e),Xn(t),P(t.content)&&Zn(t.content),ce(t)===O.element){let e=re(t);P(e)&&(Qn(e),Zn(e))}F(g.afterSanitizeShadowDOM,e,null)},Qn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Zn(e.shadow);continue}let n=e.node,r=ce(n)===O.element,i=te(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=oe?oe(n):null;if(typeof e==`string`&&N(e)===`template`){let e=n.content;P(e)&&t.push({node:e,shadow:null})}}if(r){let e=re(n);P(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(sn=!e,sn&&(e=`<!-->`),typeof e!=`string`&&!Rn(e)&&(e=St(e),typeof e!=`string`))throw yt(`dirty is not a string, aborting`);if(!t.isSupported)return e;Ue?(_=We,v=Ge):vn(n),(g.uponSanitizeElement.length>0||g.uponSanitizeAttribute.length>0)&&(_=D(_)),g.uponSanitizeAttribute.length>0&&(v=D(v)),t.removed=[];let c=mt&&typeof e!=`string`&&Rn(e);if(c){Mn(e);let t=le(e);if(typeof t==`string`){let n=N(t);if(!_[n]||Fe[n])throw Dn(e),yt(`root node is forbidden and cannot be sanitized in-place`)}if(Ln(e))throw Dn(e),yt(`root node is clobbered and cannot be sanitized in-place`);try{Qn(e)}catch(t){throw Dn(e),t}}else if(Rn(e))i=Nn(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===O.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Qn(a);else{if(!Je&&!Be&&!He&&e.indexOf(`<`)===-1)return m&&Xe?he(e):e;if(i=Nn(e),!i)return Je?null:Xe?ue:``}i&&Ke&&Tn(i.firstChild);let l=c?e:i;try{let e=Pn(l);for(;o=e.nextNode();)Wn(o,l),Xn(o),P(o.content)&&Zn(o.content)}catch(n){throw c&&(Dn(e),nt(t.removed,e=>{e.element&&An(e.element)})),n}if(c)return nt(t.removed,e=>{e.element&&An(e.element)}),Be&&In(e),e;if(Je){if(Be&&In(i),Ye)for(s=be.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(v.shadowroot||v.shadowrootmode)&&(s=Se.call(r,s,!0)),s}let u=He?i.outerHTML:i.innerHTML;return He&&_[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&w(Wt,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
6
|
+
`+u),Be&&(u=Fn(u)),m&&Xe?he(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};vn(e),Ue=!0,We=_,Ge=v},t.clearConfig=function(){hn=null,Ue=!1,We=null,Ge=null,m=de,ue=``},t.isValidAttribute=function(e,t,n){hn||vn({});let r=N(e),i=N(t);return Gn(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&C(g,e)&&at(g[e],t)},t.removeHook=function(e,t){if(C(g,e)){if(t!==void 0){let n=rt(g[e],t);return n===-1?void 0:ot(g[e],n,1)[0]}return it(g[e])}},t.removeHooks=function(e){C(g,e)&&(g[e]=[])},t.removeAllHooks=function(){g=tn()},t}var on=an();function k(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var A=k();function sn(e){A=e}var cn={exec:()=>null};function ln(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 j(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(M.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var un=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),M={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:ln(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:ln(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:ln(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:ln(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:ln(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:ln(e=>RegExp(`^ {0,${e}}>`))},dn=/^(?:[ \t]*(?:\n|$))+/,fn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,pn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,mn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,N=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,gn=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_n=j(gn).replace(/bull/g,hn).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}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),vn=j(gn).replace(/bull/g,hn).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}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),yn=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,bn=/^[^\n]+/,xn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Sn=j(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,xn).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Cn=j(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,hn).getRegex(),wn=`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`,Tn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,En=j(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\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`,Tn).replace(`tag`,wn).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Dn=e=>j(yn).replace(`hr`,mn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,wn).getRegex(),On=Dn(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),kn=Dn(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),An={blockquote:j(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,kn).getRegex(),code:fn,def:Sn,fences:pn,heading:N,hr:mn,html:En,lheading:_n,list:Cn,newline:dn,paragraph:On,table:cn,text:bn},jn=j(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,mn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,wn).getRegex(),Mn={...An,lheading:vn,table:jn,paragraph:j(yn).replace(`hr`,mn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,jn).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,wn).getRegex()},Nn={...An,html:j(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Tn).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:cn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:j(yn).replace(`hr`,mn).replace(`heading`,` *#{1,6} *[^
|
|
7
|
+
]`).replace(`lheading`,_n).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Pn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Fn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,In=/^( {2,}|\\)\n(?!\s*$)/,Ln=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,P=/[\p{P}\p{S}]/u,Rn=/[\s\p{P}\p{S}]/u,F=/[^\s\p{P}\p{S}]/u,zn=j(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Rn).getRegex(),Bn=/[\p{Pi}\p{Ps}"']/u,Vn=/(?!~)[\p{P}\p{S}]/u,Hn=/(?!~)[\s\p{P}\p{S}]/u,Un=/(?:[^\s\p{P}\p{S}]|~)/u,Wn=j(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,un?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Gn=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Kn=j(Gn,`u`).replace(/punct/g,P).getRegex(),qn=j(Gn,`u`).replace(/punct/g,Vn).getRegex(),Jn=j(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,Bn).replace(/punct/g,P).getRegex(),Yn=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Xn=j(Yn,`gu`).replace(/notPunctSpace/g,F).replace(/punctSpace/g,Rn).replace(/punct/g,P).getRegex(),Zn=j(Yn,`gu`).replace(/notPunctSpace/g,Un).replace(/punctSpace/g,Hn).replace(/punct/g,Vn).getRegex(),Qn=j(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,F).replace(/punctSpace/g,Rn).replace(/punct/g,P).getRegex(),$n=j(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,F).replace(/punctSpace/g,Rn).replace(/punct/g,P).getRegex(),er=j(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,F).replace(/punctSpace/g,Rn).replace(/punct/g,P).getRegex(),tr=j(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,P).getRegex(),nr=j(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,F).replace(/punctSpace/g,Rn).replace(/punct/g,P).getRegex(),rr=j(/\\(punct)/,`gu`).replace(/punct/g,P).getRegex(),ir=j(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ar=j(Tn).replace(`(?:-->|$)`,`-->`).getRegex(),or=j(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,ar).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),sr=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,cr=j(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,sr).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),lr=j(/^!?\[(label)\]\[(ref)\]/).replace(`label`,sr).replace(`ref`,xn).getRegex(),ur=j(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,xn).getRegex(),dr=j(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,lr).replace(`nolink`,ur).getRegex(),fr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,pr={_backpedal:cn,anyPunctuation:rr,autolink:ir,blockSkip:Wn,br:In,code:Fn,del:cn,delLDelim:cn,delRDelim:cn,emStrongLDelim:Kn,emStrongRDelimAst:Xn,emStrongRDelimUnd:$n,escape:Pn,link:cr,nolink:ur,punctuation:zn,reflink:lr,reflinkSearch:dr,tag:or,text:Ln,url:cn},mr={...pr,emStrongLDelim:Jn,emStrongRDelimAst:Qn,emStrongRDelimUnd:er,link:j(/^!?\[(label)\]\((.*?)\)/).replace(`label`,sr).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,sr).getRegex()},hr={...pr,emStrongRDelimAst:Zn,emStrongLDelim:qn,delLDelim:tr,delRDelim:nr,url:j(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,fr).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:j(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,fr).getRegex()},gr={...hr,br:j(In).replace(`{2,}`,`*`).getRegex(),text:j(hr.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},_r={normal:An,gfm:Mn,pedantic:Nn},vr={normal:pr,gfm:hr,breaks:gr,pedantic:mr},yr={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},br=e=>yr[e];function xr(e,t){if(t){if(M.escapeTest.test(e))return e.replace(M.escapeReplace,br)}else if(M.escapeTestNoEncode.test(e))return e.replace(M.escapeReplaceNoEncode,br);return e}function Sr(e){try{e=encodeURI(e).replace(M.percentDecode,`%`)}catch{return null}return e}function Cr(e,t){let n=e.replace(M.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(M.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(M.slashPipe,`|`);return n}function wr(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 Tr(e){let t=e.split(`
|
|
8
|
+
`),n=t.length-1;for(;n>=0&&M.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
9
|
+
`)}function Er(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 Dr(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 Or(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 kr(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
10
|
+
`).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(`
|
|
11
|
+
`)}var Ar=class{options;rules;lexer;constructor(e){this.options=e||A}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]:Tr(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=kr(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=wr(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:wr(t[0],`
|
|
12
|
+
`),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:wr(t[0],`
|
|
13
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=wr(t[0],`
|
|
14
|
+
`).split(`
|
|
15
|
+
`),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(`
|
|
16
|
+
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
17
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
18
|
+
${s}`:s,r=r?`${r}
|
|
19
|
+
${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=e.join(`
|
|
20
|
+
`),o=t.raw+`
|
|
21
|
+
`+a.replace(this.rules.other.blockquoteSetextReplace2,``),s=this.blockquote(o);i[i.length-1]=s,n=`${n}
|
|
22
|
+
${a}`,r=r.substring(0,r.length-t.text.length)+s.text;break}if(u?.type===`list`){let t=u,a=t.raw+`
|
|
23
|
+
`+e.join(`
|
|
24
|
+
`),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(`
|
|
25
|
+
`);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=Dr(t[2].split(`
|
|
26
|
+
`,1)[0],t[1].length),l=e.split(`
|
|
27
|
+
`,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+`
|
|
28
|
+
`,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),ee=this.rules.other.blockquoteBeginRegex(d);for(;e;){let f=e.split(`
|
|
29
|
+
`,1)[0],p;if(l=f,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)||ee.test(l)||t.test(l)||n.test(l))break;if(p.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
|
|
30
|
+
`+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+=`
|
|
31
|
+
`+l}u=!l.trim(),r+=f+`
|
|
32
|
+
`,e=e.substring(f.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)if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),!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))}for(let e of i.items){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)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=Tr(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:wr(t[0],`
|
|
33
|
+
`),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=Cr(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
34
|
+
`):[],a={type:`table`,raw:wr(t[0],`
|
|
35
|
+
`),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(Cr(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:wr(t[0],`
|
|
36
|
+
`),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)===`
|
|
37
|
+
`?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=wr(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=Er(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)),Or(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 Or(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 i=[...r[0]].length-1,a,o,s=i,c=0,l=r[0][0],u=n===l,d=l===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+i);(r=d.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(o=[...a].length,r[3]||r[4]){s+=o;continue}if(r[5]||r[6]){if(i%3&&!((i+o)%3)){c+=o;continue}if(u)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+c);let t=[...r[0]][0].length,n=e.slice(0,i+r.index+t+o);if(Math.min(i,o)%2){let e=n.slice(1,-1);return{type:`em`,raw:n,text:e,tokens:this.lexer.inlineTokens(e)}}let l=n.slice(2,-2);return{type:`strong`,raw:n,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}}}},jr=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||A,this.options.tokenizer=this.options.tokenizer||new Ar,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:M,block:_r.normal,inline:vr.normal};this.options.pedantic?(t.block=_r.pedantic,t.inline=vr.pedantic):this.options.gfm&&(t.block=_r.gfm,t.inline=this.options.breaks?vr.breaks:vr.gfm),this.tokenizer.rules=t}static get rules(){return{block:_r,inline:vr}}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(M.carriageReturn,`
|
|
38
|
+
`),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(M.tabCharGlobal,` `).replace(M.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+=`
|
|
39
|
+
`: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(`
|
|
40
|
+
`)?``:`
|
|
41
|
+
`)+i.raw,n.text+=`
|
|
42
|
+
`+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(`
|
|
43
|
+
`)?``:`
|
|
44
|
+
`)+i.raw,n.text+=`
|
|
45
|
+
`+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(`
|
|
46
|
+
`)?``:`
|
|
47
|
+
`)+i.raw,r.text+=`
|
|
48
|
+
`+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(`
|
|
49
|
+
`)?``:`
|
|
50
|
+
`)+i.raw,n.text+=`
|
|
51
|
+
`+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;if(this.tokens.links){let e=Object.keys(this.tokens.links);e.length>0&&(n=n.replace(this.tokenizer.rules.inline.reflinkSearch,t=>e.includes(t.slice(t.lastIndexOf(`[`)+1,-1))?`[`+`a`.repeat(t.length-2)+`]`:t))}n=n.replace(this.tokenizer.rules.inline.anyPunctuation,e=>`+`.repeat(e.length)),n=n.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let r=n?n.length:0;return e.slice(0,r)+`[`+`a`.repeat(e.length-r-2)+`]`}),n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let r=!1,i=``,a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=``),r=!1;let o;if(this.options.extensions?.inline?.some(n=>(o=n.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let n=t.at(-1);o.type===`text`&&n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let s=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&&(s=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(s)){e=e.substring(o.raw.length),o.raw.slice(-1)!==`_`&&(i=o.raw.slice(-1)),r=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);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)}},Mr=class{options;parser;constructor(e){this.options=e||A}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(M.notSpaceStart)?.[0],i=e.replace(M.endingNewline,``)+`
|
|
52
|
+
`;return r?`<pre><code class="language-`+xr(r)+`">`+(n?i:xr(i,!0))+`</code></pre>
|
|
53
|
+
`:`<pre><code>`+(n?i:xr(i,!0))+`</code></pre>
|
|
54
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
55
|
+
${this.parser.parse(e)}</blockquote>
|
|
56
|
+
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
57
|
+
`}hr(e){return`<hr>
|
|
58
|
+
`}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+`>
|
|
59
|
+
`+r+`</`+i+`>
|
|
60
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
61
|
+
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
62
|
+
`}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>
|
|
63
|
+
<thead>
|
|
64
|
+
`+t+`</thead>
|
|
65
|
+
`+r+`</table>
|
|
66
|
+
`}tablerow({text:e}){return`<tr>
|
|
67
|
+
${e}</tr>
|
|
68
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
69
|
+
`}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>${xr(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=Sr(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+xr(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=Sr(e);if(i===null)return xr(n);e=i;let a=`<img src="${e}" alt="${xr(n)}"`;return t&&(a+=` title="${xr(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:xr(e.text)}},Nr=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}},Pr=class e{options;renderer;textRenderer;constructor(e){this.options=e||A,this.options.renderer=this.options.renderer||new Mr,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Nr}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`,`checkbox`,`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`,`checkbox`,`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}},Fr=class{options;block;constructor(e){this.options=e||A}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?jr.lex:jr.lexInline}provideParser(e=this.block){return e?Pr.parse:Pr.parseInline}},Ir=new class{defaults=k();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Pr;Renderer=Mr;TextRenderer=Nr;Lexer=jr;Tokenizer=Ar;Hooks=Fr;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 Mr(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 Ar(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 Fr;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];t[r]=Fr.passThroughHooks.has(n)?e=>{if(this.defaults.async&&Fr.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)}:(...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 jr.lex(e,t??this.defaults)}parser(e,t){return Pr.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?jr.lex:jr.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?Pr.parse:Pr.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?jr.lex:jr.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?Pr.parse:Pr.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+=`
|
|
70
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+xr(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function I(e,t){return Ir.parse(e,t)}I.options=I.setOptions=function(e){return Ir.setOptions(e),I.defaults=Ir.defaults,sn(I.defaults),I},I.getDefaults=k,I.defaults=A;function Lr(...e){return Ir.use(...e),I.defaults=Ir.defaults,sn(I.defaults),I}I.use=Lr,I.walkTokens=function(e,t){return Ir.walkTokens(e,t)},I.parseInline=Ir.parseInline,I.Parser=Pr,I.parser=Pr.parse,I.Renderer=Mr,I.TextRenderer=Nr,I.Lexer=jr,I.lexer=jr.lex,I.Tokenizer=Ar,I.Hooks=Fr,I.parse=I,I.options,I.setOptions,I.walkTokens,I.parseInline,Pr.parse,jr.lex;var L=e=>{let t=document.querySelector(e);if(!t)throw Error(`missing element: ${e}`);return t};function Rr(e){let t=Math.round((Date.now()-e)/6e4);return t<1?`now`:t<60?`${t}m`:t<1440?`${Math.round(t/60)}h`:`${Math.round(t/1440)}d`}var zr=e=>{let t=Rr(e);return t===`now`?`just now`:`${t} ago`};function R(e,t,...n){let r=document.createElement(e);return t&&(r.className=t),r.append(...n),r}var Br=e=>e.split(`/`).filter(Boolean).pop()??e,Vr=e=>`New session in ${Br(e)}`;function Hr(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function Ur(e){let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Wr(e,t,n){return{visible:!1,show(n,r){this.visible=!0,e.classList.remove(`hidden`),e.classList.add(`flex`),t(n,r)},hide(){n?.(),this.visible=!1,e.classList.add(`hidden`),e.classList.remove(`flex`)}}}function Gr(e){let t=R(`span`,`help`);return t.innerHTML=on.sanitize(I.parseInline(e,{async:!1})),Kr(t),t}function Kr(e){for(let t of e.querySelectorAll(`a`))(t.getAttribute(`href`)??``).startsWith(`#`)||(t.target=`_blank`,t.rel=`noreferrer`)}async function qr(e){if(navigator.clipboard)return navigator.clipboard.writeText(e);let t=document.createElement(`textarea`);t.value=e,t.className=`fixed opacity-0`,document.body.append(t),t.select();let n=document.execCommand(`copy`);if(t.remove(),!n)throw Error(`clipboard unavailable`)}function Jr(e,t){let n=R(`button`,e,`Copy`);n.title=`Copy to clipboard`;let r;return n.onclick=async e=>{e.stopPropagation(),n.textContent=await qr(t()).then(()=>`Copied`,()=>`Failed`),clearTimeout(r),r=setTimeout(()=>n.textContent=`Copy`,1200)},n}function Yr(e,t){let n=document.createElement(`details`);n.className=e;let r=R(`summary`,`flex cursor-pointer select-none items-center gap-1.5`);return r.append(h(c,`chev h-3 w-3`),...t),n.append(r),{el:n,summary:r}}var Xr=(e,t=!1)=>Zr(e,`${t?`btn btn-primary`:`btn`} text-[12.5px]`),Zr=(e,t=``)=>{let n=R(`button`,t,e);return n.type=`button`,n},Qr=e=>R(`span`,`mr-1 flex-none font-medium max-md:hidden`,e),$r=(...e)=>R(`div`,`toolbar flex min-h-10 flex-none flex-wrap items-center gap-2 px-4 py-2`,...e);function ei(e,t,n){let r=R(`div`,`inline-flex flex-none items-center gap-0.5 rounded-full bg-neutral-100 p-1`);for(let[i,a]of e){let e=a===t,o=Zr(i,`cursor-pointer whitespace-nowrap rounded-full px-3 py-1 text-[12px] transition-colors ${e?`bg-white font-medium text-neutral-800 shadow-xs`:`text-neutral-500 hover:text-neutral-700`}`);o.setAttribute(`aria-pressed`,String(e)),o.onclick=()=>n(a),r.append(o)}return r}function ti(e,t,n){let r=Zr(e,`flex cursor-pointer items-center gap-1.5 rounded-full px-3.5 py-2 text-[13px] transition-colors ${t?`bg-indigo-50 font-medium text-indigo-700 ring-1 ring-indigo-200/70`:`text-neutral-600 hover:bg-neutral-100`}`);return r.onclick=n,r}var ni=`rounded-3xl border border-neutral-200 bg-white shadow-sm`,ri=`border-b border-neutral-200/70 bg-neutral-50/50`;function ii(e,t,...n){let r=R(`section`,ni),i=R(`div`,`rounded-t-3xl ${ri} px-5 py-4`);return i.append(R(`h2`,`text-[14px] font-semibold text-neutral-800`,e)),t&&i.append(R(`p`,`mt-1 text-[12px] leading-normal text-neutral-500`,t)),r.append(i,R(`div`,`flex flex-col gap-4 px-5 py-5`,...n)),r}function ai(e,t,n={}){let r=R(`div`,`flex flex-col gap-1.5`),i=R(`div`,`flex items-center gap-1.5`,R(`span`,`field-label`,e));return n.help&&i.append(n.help),r.append(i,t),n.hint&&r.append(R(`span`,`text-[11.5px] leading-snug text-neutral-400`,n.hint)),r}var oi=`w-full rounded-xl border border-neutral-200 bg-neutral-50/60 px-3 py-2.5 text-[12.5px] transition-colors placeholder:text-neutral-400 hover:border-neutral-300 focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100 focus:outline-none`,si=(e,t,n,r=!1)=>{let i=document.createElement(`input`);return i.className=r?`${oi} font-mono`:oi,i.value=e,i.placeholder=t,i.oninput=()=>n(i.value),i},ci=(e=``,t=`text`)=>{let n=document.createElement(`input`);return n.type=t,n.className=oi,n.value=e,n},li=(e,t)=>{let n=document.createElement(`select`);return n.className=`${oi} select`,n.append(...e.map(([e,t])=>new Option(e,t))),n.value=t,n},ui=(e=``,t=4)=>{let n=document.createElement(`textarea`);return n.className=`${oi} resize-y font-mono`,n.value=e,n.rows=t,n.spellcheck=!1,n};function di(e,t,n,r,i){let a=document.createElement(`input`);a.type=`checkbox`,a.className=`peer sr-only`,a.checked=n,a.onchange=()=>r(a.checked);let o=R(`span`,`relative h-4 w-7 flex-none rounded-full bg-neutral-300 transition-colors after:absolute after:left-0.5 after:top-0.5 after:h-3 after:w-3 after:rounded-full after:bg-white dark:after:bg-neutral-950 after:shadow-sm after:transition-transform peer-checked:bg-indigo-600 peer-checked:after:translate-x-3 peer-focus-visible:ring-2 peer-focus-visible:ring-indigo-200`),s=R(`label`,`flex cursor-pointer gap-2.5 ${e?`items-start`:`items-center`}`);if(s.append(a,o),e){let n=R(`span`,`flex items-center gap-1.5`,R(`span`,`text-[13px] text-neutral-700`,e));i&&n.append(i);let r=R(`span`,`flex min-w-0 flex-col`,n);t&&r.append(R(`span`,`text-[11.5px] leading-snug text-neutral-400`,t)),s.append(r)}return s}var fi={idle:`text-neutral-400`,saving:`text-neutral-400`,saved:`text-green-700`,failed:`text-red-600`};function pi(e,t,n){e.className=`text-[11.5px] ${fi[t]}`,e.textContent=n}var mi=(e,t,n)=>R(`span`,`inline-flex flex-none items-center gap-1 rounded-full px-1.5 py-px text-[10px] font-medium uppercase tracking-wide ring-1 ${t}`,...n?[R(`span`,`inline-block h-1.5 w-1.5 flex-none rounded-full ${n}`)]:[],e),hi=e=>R(`p`,`rounded-lg border border-dashed border-neutral-200 px-3 py-4 text-center text-[12.5px] text-neutral-400`,e);function gi(e,t,n=`left`){let r=R(`span`,`group relative inline-flex`),i=Zr(``,`flex h-4 w-4 cursor-help items-center justify-center text-neutral-400 transition-colors group-hover:text-indigo-500`);i.append(h(l,`h-full w-full`)),i.setAttribute(`aria-label`,e);let a=R(`span`,`absolute ${n===`right`?`right-0`:`left-0`} top-full z-20 hidden w-[min(27rem,calc(100vw-3rem))] pt-1.5 group-hover:block`),o=R(`span`,`flex flex-col gap-2 rounded-xl border border-neutral-200 bg-white p-3.5 text-[12px] font-normal normal-case leading-[1.55] tracking-normal text-neutral-600 shadow-xl`);o.append(R(`span`,`text-[12.5px] font-semibold text-neutral-800`,e));let s=R(`ol`,`flex list-decimal flex-col gap-1.5 pl-4`);for(let e of t){let t=R(`li`,`marker:text-neutral-400`);t.append(typeof e==`string`?Gr(e):e),s.append(t)}return o.append(s),a.append(o),i.onclick=()=>{let e=a.classList.contains(`hidden`);a.classList.toggle(`hidden`,!e),a.classList.toggle(`block`,e),i.classList.toggle(`text-indigo-500`,e)},r.append(i,a),r}var _i=(e,t)=>R(`span`,`flex flex-col gap-1`,Gr(e),t),vi=e=>`[${e.split(`/`).pop()??`file`}](file://${encodeURI(e).replace(/\(/g,`%28`).replace(/\)/g,`%29`)})`,yi=/^ {0,3}(`{3,}|~{3,})/;function bi(e){let t=[],n,r=0;for(let i of e.split(`
|
|
71
|
+
`)){let e=yi.exec(i)?.[1];if(n!==void 0)t.push([r,r+i.length]),e&&e[0]===n[0]&&e.length>=n.length&&(n=void 0);else if(e)n=e,t.push([r,r+i.length]);else{let e=[...i.matchAll(/`+/g)];for(let n=0;n<e.length;n++){let i=e[n],a=n+1;for(;a<e.length&&e[a][0].length!==i[0].length;)a++;if(a===e.length)break;t.push([r+i.index,r+e[a].index+e[a][0].length]),n=a}}r+=i.length+1}return t}function xi(e,t,n){let r=bi(e),i=``,a=0;for(let o of e.matchAll(t)){let t=o.index,s=t+o[0].length;r.some(([e,n])=>t<n&&s>e)||(i+=e.slice(a,t)+n(o),a=s)}return i+e.slice(a)}var Si=/^\[[^\]\n]*\]\(\s*<?file:\/\/(\/[^)>\s]*)>?\s*\)$/;function Ci(e){let t=e.split(`
|
|
72
|
+
`),n=t.length;for(;n>0&&Si.test(t[n-1].trim());)n--;let r=t.slice(n).map(e=>{let t=Si.exec(e.trim())[1];try{return decodeURIComponent(t)}catch{return t}});return{text:t.slice(0,n).join(`
|
|
73
|
+
`).trimEnd(),paths:r}}var wi=`modulepreload`,Ti=function(e){return`/`+e},Ei={},Di=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Ti(t,n),t=s(t),t in Ei)return;Ei[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:wi,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Oi,ki;function Ai(){return ki??=Di(()=>import(`./hljs-tWqyD59G.js`).then(e=>Oi=e.default,e=>{console.warn(`highlighting unavailable — code stays plain text`,e)}),[]),ki}async function ji(e){let t=await Ai();if(t)for(let n of e.querySelectorAll(`pre code[class]`)){let e=/(?:language|lang)-(\S+)/.exec(n.className)?.[1]?.toLowerCase();!e||!t.getLanguage(e)||(n.innerHTML=t.highlight(n.textContent??``,{language:e}).value)}}var Mi={ts:`typescript`,tsx:`typescript`,mts:`typescript`,cts:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,py:`python`,rs:`rust`,sh:`bash`,zsh:`bash`,md:`markdown`,yml:`yaml`,html:`xml`,htm:`xml`,svg:`xml`,patch:`diff`};async function Ni(e){let t=await Ai(),n=e.split(`.`).pop()?.toLowerCase()??``,r=Mi[n]??n;return t?.getLanguage(r)?r:null}function Pi(e,t){let n=document.createElement(`span`);return Oi&&t&&e.length<=500?n.innerHTML=Oi.highlight(e,{language:t}).value:n.textContent=e,n}var Fi=2e4;function Ii(e){let t=e.split(`
|
|
74
|
+
`);return t.at(-1)===``&&t.pop(),t.map((e,t)=>({nums:[t+1],text:e,tone:``}))}function Li(e,t){let n=e.length<=Fi?t:null,r=Math.max(2,...e.map(e=>e.nums.reduce((e,t)=>Math.max(e,String(t).length),0))),i=R(`div`,`py-2 font-mono text-[12px] leading-[1.5]`);for(let t of e){let e=R(`div`,`flex pl-2 pr-4 ${t.tone===`add`?`bg-emerald-50`:t.tone===`del`?`bg-red-50`:``}`);for(let n of t.nums){let t=R(`span`,`flex-none select-none pr-1.5 text-right text-neutral-300`,n===``?``:String(n));t.style.width=`calc(${r}ch + 0.375rem)`,e.append(t)}e.append(Ri(t,n)),i.append(e)}return i}function Ri(e,t){let n=`min-w-0 flex-1 whitespace-pre-wrap [overflow-wrap:anywhere]`;if(!e.mark||e.mark[0]>=e.mark[1]){let r=Pi(e.text,t);return r.className=n,r}let[r,i]=e.mark,a=Pi(e.text.slice(r,i),t);return a.className=`rounded-xs ${e.tone===`add`?`bg-emerald-200/80`:`bg-red-200/70`}`,R(`span`,n,Pi(e.text.slice(0,r),t),a,Pi(e.text.slice(i),t))}var zi=L(`#image-dialog`),Bi=L(`#image-stage`),Vi=L(`#image-full`),Hi=L(`#image-prev`),Ui=L(`#image-next`),Wi=[],Gi=0;function Ki(e){Wi.length<2||(Gi=(Gi+e+Wi.length)%Wi.length,Yi(!1),Vi.src=Wi[Gi])}var qi=2.5,Ji=()=>Bi.dataset.zoom!==void 0;function Yi(e,t){if(!e){delete Bi.dataset.zoom,Vi.style.cssText=``;return}let n=Vi.getBoundingClientRect(),r=Bi.getBoundingClientRect(),i=t?(t.x-n.left)/n.width:.5,a=t?(t.y-n.top)/n.height:.5,o=n.width*qi,s=n.height*qi;Bi.dataset.zoom=``,Vi.style.width=`${String(o)}px`,Vi.style.height=`${String(s)}px`,Bi.scrollLeft=i*o-r.width/2,Bi.scrollTop=a*s-r.height/2}function Xi(e){let t=e.closest(`[data-gallery]`);Wi=t?[...t.querySelectorAll(`img.thumb`)].map(e=>e.src):[e.src],Gi=Math.max(0,Wi.indexOf(e.src)),Vi.src=e.src;let n=Wi.length<2?`none`:`flex`;Hi.style.display=n,Ui.style.display=n,zi.showModal()}var Zi=260,Qi;Bi.onclick=e=>{if(Qi!==void 0){clearTimeout(Qi),Qi=void 0,Yi(!Ji(),{x:e.clientX,y:e.clientY});return}Qi=window.setTimeout(()=>{Qi=void 0,Ji()?Yi(!1):zi.close()},Zi)},zi.onclose=()=>{clearTimeout(Qi),Qi=void 0,Yi(!1)},Hi.onclick=()=>Ki(-1),Ui.onclick=()=>Ki(1),zi.onkeydown=e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),Ki(e.key===`ArrowLeft`?-1:1))};function $i(e){let t=e.querySelector(`:scope > .thumbs`);if(t)return t;let n=R(`div`,`thumbs`);return e.append(n),n}function ea(e){let t=document.createElement(`img`);return t.src=e,t.loading=`lazy`,t.className=`thumb`,t.onclick=()=>Xi(t),t}var ta=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`bmp`]),na=524288,ra=L(`#file-dialog`),ia=L(`#file-name`),aa=L(`#file-text`),oa=L(`#file-download`);L(`#file-close`).onclick=()=>ra.close();var sa=e=>e.split(`.`).pop()?.toLowerCase()??``,ca=(e,t,n=!1)=>`/api/sessions/${encodeURIComponent(e)}/files?path=${encodeURIComponent(t)}${n?`&download=1`:``}`;function la(e,t){return xi(e,/\]\(\s*<?file:\/\/(\/[^)>\s]*)>?\s*\)/g,e=>{let n=e[1];try{n=decodeURIComponent(n)}catch{}return`](${ca(t,n)})`})}var ua=e=>/^\/api\/sessions\/[^/]+\/files\?/.test(e);function da(e,t){let n=Br(t)||`file`,r=ca(e,t);return ta.has(sa(n))?ga(r,n):_a(r,n)}function fa(e){return new URLSearchParams(e.slice(e.indexOf(`?`)+1)).get(`path`)??``}var pa=(e,t=`text-neutral-500`)=>R(`div`,`px-3 py-2 text-[12.5px] ${t}`,e),ma=0;async function ha(e,t){let n=++ma;ia.textContent=t,oa.href=`${e}&download=1`,aa.replaceChildren(pa(`loading…`)),ra.showModal();let r=e=>{n===ma&&aa.replaceChildren(e)},i;try{i=await fetch(e)}catch(e){return r(pa(`failed to load: ${String(e)}`,`text-red-600`))}if(!i.ok)return r(pa(await b(i,`failed to load`),`text-red-600`));let a=i.headers.get(`content-type`)??``;if(!a.startsWith(`text/`)&&!a.startsWith(`image/svg+xml`))return r(pa(`Binary file — use Download.`));let o=await i.text(),s=o.length>na?`${o.slice(0,na)}\n…`:o,c=await Ni(t);r(Li(Ii(s),c))}function ga(e,t){let n=ea(e);return n.alt=t,n}function _a(e,t){let n=sa(t),r=R(`span`,`inline-flex max-w-full items-center gap-2.5 rounded-lg border border-neutral-200 bg-neutral-50 px-2.5 py-1.5 no-underline`),i=R(`span`,`flex h-7 w-7 flex-none items-center justify-center rounded-md bg-indigo-50 text-[10px] font-semibold uppercase text-indigo-600`,n.slice(0,4)||`file`),a=R(`span`,`min-w-0 truncate text-[13px] font-medium text-neutral-800`,t),o=R(`span`,`ml-1 flex flex-none items-center gap-0.5`),s=R(`button`,`icon-btn h-6 w-6 text-[13px]`,h(p));s.setAttribute(`aria-label`,`Preview`),s.title=`Preview`,s.onclick=r=>{r.preventDefault(),n===`pdf`?window.open(e,`_blank`,`noopener`):ha(e,t)},o.append(s);let c=document.createElement(`a`);return c.className=`icon-btn h-6 w-6 text-[13px] no-underline`,c.href=`${e}&download=1`,c.download=t,c.title=`Download`,c.append(h(ee)),c.setAttribute(`aria-label`,`Download`),o.append(c),r.append(i,a,o),r}function va(e){let t=new Set;for(let n of e)n.parentElement&&t.add(n.parentElement);for(let n of t){let t=[...n.children].filter(t=>e.includes(t));if([...n.childNodes].every(e=>e.nodeType===Node.TEXT_NODE?!e.textContent?.trim():t.includes(e))){n.classList.add(`thumbs`);continue}let r=R(`div`,`thumbs`);r.append(...t),n.after(r)}}function ya(e){let t=[];for(let n of e.querySelectorAll(`img`)){let e=n.getAttribute(`src`)??``;if(!ua(e))continue;let r=ga(e,Br(fa(e)));n.replaceWith(r),t.push(r)}for(let n of e.querySelectorAll(`a`)){let e=n.getAttribute(`href`)??``;if(!ua(e))continue;let r=Br(fa(e))||n.textContent?.trim()||`file`,i=ta.has(sa(r))?ga(e,r):_a(e,r);n.replaceWith(i),t.push(i)}t.length&&va(t)}var ba=null,xa=`max-w-full cursor-pointer break-words rounded-full border border-indigo-200 bg-indigo-50 px-2.5 py-0.5 text-left text-[12.5px] text-indigo-700 transition-colors hover:border-indigo-300 hover:bg-indigo-100`;function Sa(){ba=null}function Ca(e,t,n){if(ba?.remove(),ba=null,!t.length)return;let r=R(`div`,`mt-1.5 flex flex-wrap gap-1.5`);for(let e of t){let t=R(`button`,xa,e);t.type=`button`,t.onclick=()=>{ba===r&&(ba=null),r.remove(),n(e)},r.append(t)}e.append(r),ba=r}var wa=8e3,Ta=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],Ea=e=>typeof e==`string`&&Ta.includes(e),Da,Oa;function ka(e,t){Da=e,Oa=t}var Aa=e=>e.slice(0,8),ja=e=>`system-card group relative mt-1.5 rounded-xl px-4 py-2.5 ${e}`,Ma=e=>R(`div`,ja(e));function Na(e){let t=e.length>240||e.split(`
|
|
75
|
+
`).length>4,n=[`max-h-[4lh]`,`overflow-hidden`],r=R(`div`,`mt-1 whitespace-pre-wrap break-words text-[12.5px] leading-normal text-neutral-500 ${n.join(` `)}`,e),i=R(`button`,`mt-1 hidden w-fit rounded-md px-1 py-1 text-[11px] pointer-coarse:min-h-11 pointer-coarse:px-2 text-neutral-500 hover:bg-neutral-100 hover:text-neutral-700`,`Show full message`);return i.setAttribute(`type`,`button`),i.setAttribute(`aria-expanded`,`false`),i.onclick=()=>{let e=r.getBoundingClientRect().height;r.getAnimations().forEach(e=>e.cancel());let t=r.classList.toggle(n[0]),a=r.getBoundingClientRect().height,o=matchMedia(`(prefers-reduced-motion: reduce)`).matches;r.animate(o?[{opacity:.8},{opacity:1}]:[{maxHeight:`${e}px`,opacity:.8},{maxHeight:`${a}px`,opacity:1}],{duration:o?120:180,easing:`cubic-bezier(0.2, 0.8, 0.2, 1)`}),i.textContent=t?`Show full message`:`Collapse message`,i.setAttribute(`aria-expanded`,String(!t)),r.tabIndex=-1,r.focus({preventScroll:!0})},queueMicrotask(()=>{(r.clientHeight?r.scrollHeight>r.clientHeight+1:t)?i.classList.remove(`hidden`):r.classList.remove(...n)}),[r,i]}function Pa(e){let t=R(`div`,`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-neutral-500`,e.glyph);t.append(R(`span`,`run-label flex-none font-semibold ${e.labelCls}`,e.label)),e.taskName&&t.append(R(`span`,`min-w-0 grow basis-0 truncate text-[12.5px] font-medium text-neutral-800 max-md:order-1 max-md:basis-full max-md:whitespace-normal max-md:line-clamp-2`,e.taskName));let n=R(`div`,`ml-auto flex min-w-0 flex-wrap items-center gap-x-2 font-mono`);if(e.note&&n.append(R(`span`,`flex-none`,e.note)),e.model){let t=R(`span`,`flex-none rounded bg-black/[0.05] px-1.5 py-px font-medium text-neutral-700 dark:bg-neutral-200`,e.model.id);t.title=`${e.model.provider} / ${e.model.id}`,n.append(t)}if(e.thinking){let t=R(`span`,`flex-none`,e.thinking);t.title=`Reasoning effort`,n.append(t)}let r=R(`button`,`flex-none hover:underline`,Aa(e.runId));if(r.title=`Run ${e.runId}`,r.onclick=()=>Da.showRun(e.runId),n.append(r),e.sessionId&&e.sessionId!==`console`){let t=e.sessionId,r=R(`button`,`flex-none text-indigo-600 hover:underline`,Aa(t));r.title=`Open session ${t}`,r.onclick=()=>Da.select(t),n.append(r)}return t.append(n),t}var Fa={queued:{edge:`border-l-amber-400`,label:`text-amber-700`,glyph:ie},running:{edge:`border-l-fuchsia-500`,label:`text-fuchsia-700`,glyph:ie},succeeded:{edge:`border-l-green-500`,label:`text-green-700`,glyph:a},failed:{edge:`border-l-red-500`,label:`text-red-600`,glyph:ye},cancelled:{edge:`border-l-neutral-300`,label:`text-neutral-500`,glyph:se},interrupted:{edge:`border-l-amber-400`,label:`text-amber-700`,glyph:m},skipped:{edge:`border-l-neutral-300`,label:`text-neutral-500`,glyph:se}},Ia=e=>h(Fa[e].glyph,`h-3 w-3 ${e===`queued`||e===`running`?`spinner`:``} ${Fa[e].label}`),La=new Map,Ra=new WeakMap;async function za(e,t){let n=await Be(e,`POST`,t);n&&Oa.append(`error`,n)}function Ba(e){for(let[e,t]of La)t.isConnected||La.delete(e);let t=La.get(e.runId);t||(t=Ma(Fa[e.state].edge),t.dataset.kind=`background-run`,Oa.el.append(t),La.set(e.runId,t)),t.className=ja(Fa[e.state].edge);let n=e.state===`queued`||e.state===`running`,r=`/api/task-runs/${e.runId}`,i=Math.max(0,Math.round(((e.finishedAt??Date.now())-(e.startedAt??e.queuedAt))/1e3)),a=Pa({glyph:Ia(e.state),label:`run · ${e.state}`,labelCls:Fa[e.state].label,taskName:e.taskName,note:`${e.sessionMode??`task`} · depth ${String(e.depth)} · ${String(i)}s`,runId:e.runId,sessionId:e.targetSessionId}),o=R(`div`,`flex flex-none items-center gap-2 text-[11px] font-semibold text-neutral-700`);if(n){let t=R(`button`,`hover:underline`,`Stop`);t.onclick=()=>{window.confirm(`Stop "${e.taskName}"?`)&&za(`${r}/cancel`,`could not stop the run`)},o.append(t)}o.childElementCount&&a.append(o);let s=Ra.get(t);!s&&e.prompt!==null&&(s=Na(e.prompt),Ra.set(t,s)),t.replaceChildren(a,...s??[]),Oa.scroll()}var z=null,Va=null,Ha=null,Ua=!1;function Wa(){if(!Va)return;Va.text=Va.text.slice(-4e3),Va.pre.textContent=Va.text;let e=Va.text.split(`
|
|
76
|
+
`).filter(Boolean).pop()??`thinking…`,t=Va.summary.lastElementChild;t.textContent=e.length>90?`…`+e.slice(-90):e}function Ga(){if(Ha){Ua=!0;return}Ua=!1,Wa(),Ha=setTimeout(()=>{Ha=null,Ua&&Ga()},80)}function Ka(){Ha&&clearTimeout(Ha),Ha=null,Ua&&Wa(),Ua=!1}var qa=new WeakMap,Ja=e=>{let t=qa.get(e)??[];return qa.set(e,t),t};function Ya(){z&&!z.toolRows.size&&lo(`done`)}var Xa=null;function Za(){z=null,Xa=null,Va=null,Ka(),La.clear()}function Qa(){let e=Xa;return!e||z?.el===e||(Xa=null,e!==Oa.el.lastElementChild)?null:(e.remove(),e.dataset.adopted=`1`,eo(e,e.dataset.status),e)}var $a={running:`text-green-700 open:bg-green-50`,done:`text-neutral-400 hover:text-neutral-600 open:bg-black/[0.02] open:text-neutral-500 dark:open:bg-neutral-100`,failed:`text-red-600 open:bg-red-50`,interrupted:`text-amber-700 open:bg-amber-50`};function eo(e,t){e.dataset.status=t,e.className=`px-2 py-1 rounded-xl text-[11.5px] leading-normal open:border open:border-neutral-200 open:px-3 open:py-2 ${$a[t]}`}var to={failed:ye,interrupted:m};function no(e){return e===`running`?h(ie,`spinner`):e===`done`?R(`span`,`hidden`):h(to[e],`h-3 w-3`)}function ro(e){if(z)return z;let t=no(`running`),n=R(`span`,`min-w-0 truncate`,`working…`),{el:r}=Yr(``,[t,n]);r.dataset.kind=`activity`,eo(r,`running`);let i=R(`div`,`mt-1.5 flex max-h-64 flex-col gap-1 overflow-y-auto overscroll-contain border-t border-black/5 pt-1.5 dark:border-neutral-200`);return r.append(i),oo(r,i),Oa.el.append(r),Xa=r,Oa.scroll(),z={el:r,statusIcon:t,headline:n,rowsEl:i,toolRows:new Map,thinking:null,steps:0,failedSteps:0,startTs:e,sawError:!1},z}function io(e,t=``){let n=ro(e);Ka(),n.thinking=null;let r=R(`div`,`whitespace-pre-wrap break-words text-[13px] text-neutral-600`,t);r.dataset.raw=t;let i=R(`div`,`rounded-lg bg-neutral-50 px-2 py-1.5`,R(`span`,`text-[10px] font-medium text-neutral-400`,`Update`),r);return i.dataset.kind=`progress`,n.rowsEl.append(i),co(n,`running`,`writing…`),so(n),Oa.scroll(),r}function ao(e){let t=e.closest(`details[data-kind="activity"]`);e.parentElement?.remove(),t&&!t.lastElementChild?.childElementCount&&(z?.el===t&&(z=null),Xa===t&&(Xa=null),t.remove())}function oo(e,t){t.dataset.follow=`1`,t.addEventListener(`scroll`,()=>{let e=t.scrollHeight-t.scrollTop-t.clientHeight<24;t.dataset.follow=e?`1`:``}),e.addEventListener(`toggle`,()=>{e.open&&(t.scrollTop=t.scrollHeight,t.dataset.follow=`1`)})}function so(e){Oa.bulk()||!e.el.open||!e.rowsEl.dataset.follow||(e.rowsEl.scrollTop=e.rowsEl.scrollHeight)}function co(e,t,n){let r=Math.max(1,Math.round((Date.now()-e.startTs)/1e3)),i=`${e.steps?`${e.steps} step${e.steps===1?``:`s`}`:`Progress`} · ${r}s`;e.headline.textContent=t===`running`&&n?`${i} · ${n}`:t===`done`?`Completed · ${i}`:`${i} · ${t}`,eo(e.el,t);let a=no(t);e.statusIcon.replaceWith(a),e.statusIcon=a}function lo(e){if(!z)return;Ka();for(let{statusEl:e}of z.toolRows.values())e.textContent===`running…`&&(e.textContent=`interrupted`);let t=z.steps>0&&z.failedSteps===z.steps;co(z,(z.sawError||t)&&e===`done`?`failed`:e===`done`&&z.toolRows.size?`interrupted`:e),z=null}function uo(){z&&(z.sawError=!0)}function fo(e){let t=e.slice(0,400).replace(/\s+/g,` `);return t.length>100?t.slice(0,100)+`…`:t}function po(e,t,n,r){let i=ro(e);i.steps+=1,Ka(),i.thinking=null;let a=JSON.stringify(r,null,2)??``,o=R(`span`,`ml-auto flex-none text-neutral-400`,`running…`),s=R(`span`,`min-w-0 truncate text-neutral-500`,fo(a)),{el:c}=Yr(`rounded-md px-1 py-0.5 font-mono text-[12.5px] hover:bg-black/[0.03] dark:hover:bg-neutral-100`,[R(`span`,`flex-none font-semibold`,n),s,o]),l=R(`pre`,`max-h-40 overflow-y-auto whitespace-pre-wrap break-words rounded bg-black/[0.04] p-1.5 text-[12px] dark:bg-neutral-100`,a),u=R(`pre`,`hidden max-h-56 overflow-y-auto whitespace-pre-wrap break-words rounded bg-black/[0.04] p-1.5 text-[12px] dark:bg-neutral-100`);c.append(R(`div`,`mt-1 flex flex-col gap-1 pl-4`,l,u)),Ja(i.el).push({tool:n,call:t,preview:s,argsPre:l,outputPre:u}),i.toolRows.set(t,{el:c,statusEl:o,outputPre:u}),i.rowsEl.append(c),so(i),co(i,`running`,n),Oa.scroll()}function mo(e,t,n){let r=z;if(!r)return;let i=r.toolRows.get(e);r.toolRows.delete(e),i&&(i.statusEl.textContent=t?`failed`:`ok`,i.statusEl.className=`ml-auto flex-none ${t?`text-red-600`:`text-green-700`}`,i.el.classList.toggle(`bg-red-50`,t),i.el.classList.toggle(`text-red-700`,t),n&&(i.outputPre.textContent=n.length>8e3?n.slice(0,wa)+`…`:n,i.outputPre.classList.remove(`hidden`)),t&&(r.failedSteps+=1)),co(r,`running`)}function ho(e,t){let n=ro(e);if(!n.thinking){Ka();let{el:e,summary:t}=Yr(`rounded-md px-1 py-0.5 text-[12.5px] italic text-neutral-500 hover:bg-black/[0.03] dark:hover:bg-neutral-100`,[R(`span`,`min-w-0 truncate`,`thinking…`)]),r=R(`div`,`mt-1 max-h-56 overflow-y-auto whitespace-pre-wrap break-words pl-4 not-italic text-neutral-500`,``);e.append(r),n.rowsEl.append(e),n.thinking={pre:r,summary:t,text:``},Va=n.thinking,so(n),co(n,`running`,`thinking…`)}n.thinking.text+=t,Ga()}var go=0;function _o(e,t=0,n=!1,r){let i=Date.now()-t,a=ro(i).el;for(let t of e){if(t.kind===`progress`){io(i,t.text??``);continue}if(t.kind===`thinking`){ho(i,t.text??``);continue}let e=t.id??`replay-${++go}`;po(i,e,t.toolName??``,t.args),t.done&&mo(e,t.isError??!1,t.output??``)}r!==void 0&&e.some(e=>e.kind===`tool`&&e.args===void 0)&&vo(a,r),!n&&lo(e.some(e=>e.kind===`tool`&&!e.done)?`interrupted`:`done`)}function vo(e,t){let n=()=>{e.open&&(e.removeEventListener(`toggle`,n),yo(e,t))};e.addEventListener(`toggle`,n)}async function yo(e,t){let n=Da.sessionId(),r=Ja(e),i=new Set(r.filter(e=>!e.argsPre.textContent)),a=e=>{for(let t of i)t.argsPre.textContent=e};if(a(`loading…`),!n)return a(`no session`);let o=await Re(`/api/sessions/${n}/turns/${t}/steps`,`could not load these steps`);if(!o.ok)return a(o.error);let s=o.value.steps.filter(e=>e.kind===`tool`);for(let[e,t]of r.entries()){if(!i.has(t))continue;let n=s[e];if(!(n&&(n.id?n.id===t.call:n.toolName===t.tool))){t.argsPre.textContent=`detail no longer available — reload the session`;continue}let r=JSON.stringify(n.args,null,2)??``;t.argsPre.textContent=r,t.preview.textContent=fo(r),n.output&&(t.outputPre.textContent=n.output,t.outputPre.classList.remove(`hidden`))}}var bo,B=L(`#turns`);function xo(e){bo=e,ka(e,{el:B,append:V,scroll:Oo,bulk:()=>So})}var So=!1,Co=()=>B.scrollHeight-B.scrollTop-B.clientHeight<80,wo=!0;B.addEventListener(`scroll`,()=>{So||(wo=Co())},{passive:!0});var To=0;function Eo(){!wo||So||To||(To=requestAnimationFrame(()=>{To=0,wo&&!So&&(B.scrollTop=B.scrollHeight)}))}new ResizeObserver(Eo).observe(B),B.addEventListener(`load`,Eo,!0),new MutationObserver(Eo).observe(B,{childList:!0,subtree:!0,characterData:!0});function Do(){Co()&&(wo=!0)}function Oo(e=!1){So||(e&&(wo=!0),wo&&(B.scrollTop=B.scrollHeight))}var ko=1200;function Ao(e,t){let n=B.querySelector(`[data-kind="${e}"][data-at="${t}"]`);return n?(wo=!1,n.scrollIntoView({block:n.offsetHeight>B.clientHeight?`start`:`center`}),n.dataset.reveal=``,setTimeout(()=>delete n.dataset.reveal,ko),!0):!1}var jo=500,Mo=0,No=0,Po=null;function Fo(){for(;B.childElementCount>jo;){let e=B.firstElementChild;e.remove(),e!==Po&&(e.dataset.kind===`user`&&Mo++,No++)}No&&(Po||(Po=R(`div`,`px-5 py-2 text-center text-[11.5px] italic text-neutral-400`),Po.dataset.kind=`trim`),Po.textContent=`${No} earlier row${No===1?``:`s`} not shown — still in the transcript, not on this screen`,B.firstElementChild!==Po&&B.prepend(Po))}var Io={user:{row:``,body:`text-inherit`},assistant:{row:``,body:`text-neutral-900`},error:{row:`border-l-red-400 bg-red-50`,body:`text-red-700`},system:{row:`system-card border-l-cyan-500`,body:`text-neutral-500`}};function V(e,t,n=!1,r){Ya();let i=e===`assistant`?Qa():null,a=Io[e],o=e===`user`&&r!==void 0&&Zo(r)?r:void 0,s=o===void 0&&B.lastElementChild?.dataset.kind===e,c=R(`div`,`group relative ${a.row}`);c.dataset.kind=e,s&&(c.dataset.grouped=``),So||(c.dataset.enter=``);let l=e===`user`?Ci(t):null,u=l?.text??t,d=e===`user`?Ne(u):null,ee=d?.id||d?.when?d:null,f=ee?.id&&ee.id!==`web`?ee:null,p=R(`div`,`whitespace-pre-wrap break-words ${a.body}`,ee?.text??u);(l?.paths.length||ee)&&(p.dataset.raw=t),n&&ns(p,t),r!==void 0&&$o(c,r),f&&c.append(Lo(f)),c.append(p);let te=bo.sessionId();if(l?.paths.length&&te){let e=$i(c);for(let t of l.paths)e.append(da(te,t))}if(e===`user`){Vo?.(),B.querySelector(`.message-edit`)?.remove();let e=R(`button`,`message-edit absolute right-full top-1 flex h-8 w-8 items-center justify-center rounded-full`);e.title=`Edit latest message — resends it and replaces the reply`,e.setAttribute(`type`,`button`),e.setAttribute(`aria-label`,`Edit message`),e.append(h(ue)),e.onclick=()=>Uo(c,p),c.append(e)}if(o!==void 0){let e=R(`div`,`my-3 text-center text-[11px] text-neutral-400`);e.dataset.kind=`time`,e.dataset.at=String(o),Jo(e),qo??=setInterval(Yo,6e4),e.title=Hr(o),B.append(e)}return i&&B.append(i),B.append(c),Fo(),Oo(),p}function Lo(e){let t=R(`div`,`mb-1 flex flex-wrap items-baseline gap-x-2 gap-y-1 text-[11.5px] leading-tight opacity-85`),n=e?.name??e?.id;if(n){let r=R(`span`,`font-semibold text-inherit`,n);e?.id&&(r.title=e.id),t.append(r)}return t}var Ro={"task-delegation":[i,`delegated`,`text-cyan-700`],"task-callback":[d,`callback`,`text-cyan-700`],decision:[l,`decision needed`,`text-amber-700`]};function zo(e){let t=e.indexOf(`
|
|
77
|
+
|
|
78
|
+
`);if(t<0)return[null,e];let n=e.slice(0,t);return n.length>600||n.split(`
|
|
79
|
+
`).length>6?[null,e]:[n,e.slice(t+2)]}function Bo(e,t){let n=t.kind===`task-message`?t.messageKind:t.kind,[r,i,a]=Ro[n]??[d,n.replace(`_`,` `),`text-cyan-700`];Ya();let o=t.kind===`task-callback`?t.state:void 0,s=Ma(o?Fa[o].edge:n===`decision`?`border-l-amber-400`:`border-l-cyan-500`);s.dataset.kind=`system`;let[c,l]=zo(e),u=Pa({glyph:o?Ia(o):h(r,`h-3 w-3 ${a}`),label:o?`${i} \u00b7 ${o}`:i,labelCls:o?Fa[o].label:a,...t.source?{taskName:t.source.taskName,model:t.source.model,thinking:t.source.thinking}:c?{taskName:c.split(`
|
|
80
|
+
`)[0]}:{},runId:t.runId,sessionId:t.sourceSessionId});s.append(u),s.append(...Na(l)),B.append(s),Fo(),Oo()}var Vo=null,Ho=e=>e.isConnected&&B.querySelector(`.message-edit`)?.parentElement===e;function Uo(e,t){if(!Ho(e))return;if(bo.sessionState()!==`idle`){V(`error`,`can't edit while streaming — stop the turn first`);return}if(e.querySelector(`textarea`))return;let n=document.createElement(`textarea`);n.value=t.dataset.raw??t.textContent??``,n.className=`block w-full resize-none rounded-xl border border-indigo-300 bg-white px-3 py-2 text-neutral-900 focus:outline-none`,n.setAttribute(`aria-label`,`Edit latest message`);let r=Xr(`Send edit`,!0),i=Xr(`Cancel`),a=R(`div`,`message-editor`,n,R(`div`,`mt-2 flex flex-wrap justify-end gap-2`,i,r)),o=()=>{n.style.height=`auto`,n.style.height=`${Math.min(n.scrollHeight,192)}px`,r.disabled=!n.value.trim()};n.oninput=o,e.dataset.editing=``,t.classList.add(`hidden`),t.after(a),o(),n.focus(),n.setSelectionRange(n.value.length,n.value.length);let s=()=>{a.remove(),t.classList.remove(`hidden`),delete e.dataset.editing,Vo=null};Vo=s,i.onclick=()=>{s(),e.querySelector(`.message-edit`)?.focus({preventScroll:!0})},r.onclick=()=>{let t=n.value.trim();t&&Wo(e,t)},a.onkeydown=e=>{e.isComposing||e.keyCode===229||(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i.click()),e.key===`Enter`&&!e.shiftKey&&e.target===n&&(e.preventDefault(),r.click()))}}async function Wo(e,t){let n=bo.sessionId();if(!n||!Ho(e))return;if(bo.sessionState()!==`idle`){V(`error`,`can't edit while streaming — stop the turn first`);return}Vo?.();let r=[...B.querySelectorAll(`[data-kind="user"]`)],i=Mo+r.indexOf(e),a=r[r.length-2]?.dataset.at;Ko=a===void 0?null:Number(a);let o=e.previousElementSibling;for(o?.dataset.kind===`time`&&o.remove();e.nextElementSibling;)e.nextElementSibling.remove();e.remove(),bo.ownTurn(t),V(`user`,t,!1,Date.now()),Oo(!0);let s=await y(`/api/sessions/${n}/turns/${i}/edit`,{text:t});if(!s.ok){let e=await b(s,`edit failed`);await bo.reload(n),V(`error`,e)}}var Go=6e5,Ko=null,qo;function Jo(e){let t=Number(e.dataset.at);e.textContent=`${Hr(t).slice(0,16)} · ${zr(t)}`}function Yo(){let e=B.querySelectorAll(`[data-kind="time"]`);for(let t of e)Jo(t);e.length||(clearInterval(qo),qo=void 0)}var Xo=(e,t)=>new Date(e).toDateString()===new Date(t).toDateString();function Zo(e){let t=Ko;return Ko=e,t===null||e-t>=Go||!Xo(t,e)}function Qo(e,t){t&&$o(e.parentElement??e,t.completedAt)}function $o(e,t){e.dataset.at=String(t),e.dataset.time=Hr(t).slice(11)}function es(e){for(let t of e.querySelectorAll(`pre`)){let e=t.querySelector(`code`);if(!e)continue;let n=R(`div`,`group/code relative`);t.replaceWith(n),n.append(t,Jr(`absolute right-1.5 top-1.5 cursor-pointer rounded border border-black/[0.08] bg-white/85 px-1.5 py-0.5 text-[11px] text-neutral-500 opacity-0 transition-opacity hover:bg-white hover:text-neutral-800 focus:opacity-100 group-hover/code:opacity-100 pointer-coarse:opacity-100 dark:border-neutral-200`,()=>e.textContent??``))}}function ts(e){let t=bo.sessionId(),n=R(`div`,``);return n.innerHTML=on.sanitize(I.parse(t?la(e,t):e,{async:!1})),Kr(n),n}function ns(e,t){e.replaceChildren(...ts(t).childNodes),e.classList.remove(`whitespace-pre-wrap`),e.classList.add(`md`),ji(e),es(e),ya(e)}function rs(e,t,n,r=!1){let{text:i,suggestions:a}=Ae(t);return g({text:i,suggestions:a})?is(e,ke(t)):ns(e,i),r&&Ca(e.parentElement??e,a,e=>bo.send(`auto`,e)),Qo(e,n),e}function is(e,t){e.classList.remove(`md`,`whitespace-pre-wrap`),e.replaceChildren(R(`span`,`text-[12.5px] italic text-neutral-400`,t?`Stayed silent — ${t}`:`Stayed silent.`))}var as=(e,t,n=!1)=>rs(V(`assistant`,``),e,t,n),H=null,os=null,ss=!1,cs=0,ls=0;function us(e){let t=e.dataset.raw??``;for(;e.childNodes.length>ls;)e.lastChild.remove();let n=Me(t,cs);n>cs&&(e.append(...ts(je(t.slice(cs,n))).childNodes),cs=n,ls=e.childNodes.length),e.append(...ts(Ae(t.slice(cs)).text).childNodes),e.classList.remove(`whitespace-pre-wrap`),e.classList.add(`md`)}function ds(){if(os){ss=!0;return}ss=!1,H&&(us(H),Oo()),os=setTimeout(()=>{os=null,ss&&ds()},80)}function fs(){os&&clearTimeout(os),os=null,ss=!1}function ps(e){H||(H=io(Date.now()),cs=0,ls=0),H.dataset.raw=(H.dataset.raw??``)+e,ds()}function ms(){if(!H)return;let e=H;H=null,fs(),e.classList.remove(`md`),e.classList.add(`whitespace-pre-wrap`),e.textContent=e.dataset.raw??``}function hs(){if(!H)return;let e=H.dataset.raw;return ao(H),H=null,fs(),e}function gs(e,t){e===``&&ms();let n=hs();lo(`done`);let r=e??n;r&&as(r,t,!0)}function _s(){let e=hs();lo(`interrupted`),e&&as(e)}function vs(){Vo?.(),clearInterval(qo),qo=void 0,B.replaceChildren(),Mo=0,No=0,Po=null,Ko=null,H=null,fs(),Za(),Sa()}function ys(e){if(!e){B.querySelector(`[data-kind="loading"]`)?.remove();return}let t=R(`div`,`flex flex-col gap-3 px-5 py-4`);t.dataset.kind=`loading`;for(let e of[`w-2/5`,`w-4/5`,`w-3/5`,`w-1/3`,`w-2/3`])t.append(R(`div`,`skeleton h-3.5 ${e}`));B.append(t)}function bs(e,t,n){ys(!1);let r=new Map(n.map(e=>[e.runId,e])),i=e=>[...r].filter(([,t])=>t.queuedAt<=e).map(([e])=>e),a=e=>{for(let t of e){let e=r.get(t);e&&(Ba(e),r.delete(t))}},o=e.reduce((e,t,n)=>t.role===`assistant`?n:e,-1);So=!0;try{for(let[n,r]of e.entries()){let s=t===`streaming`&&n===e.length-1&&r.role===`assistant`,c=r.steps;if(c?.length&&(_o(c,r.meta?.durationMs,s,n),r.meta&&a(i(r.meta.completedAt))),r.text){if(r.role===`system`&&r.origin){a(r.origin.kind===`task-message`?[r.origin.runId]:r.origin.runIds??[r.origin.runId]),Bo(r.text,r.origin);continue}s?ps(r.text):r.role===`assistant`?as(r.text,r.meta,t===`idle`&&n===o):V(r.role,r.text,!1,r.at)}}for(let e of r.values())Ba(e)}finally{So=!1}Oo(!0)}var xs=window.fetch.bind(window),Ss=20,Cs=6e4,ws=[],Ts=new Map,Es=e=>e instanceof Error?e.stack??`${e.name}: ${e.message}`:void 0;function Ds(e,t){let n=t===void 0?e:`${e}: ${String(t)}`,r=Date.now();return r-(Ts.get(n)??-6e4)<Cs||(Ts.size>100&&Ts.clear(),Ts.set(n,r),ws=ws.filter(e=>r-e<6e4),ws.length>=Ss)?null:(ws.push(r),xs(`/api/client-log`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:n,stack:Es(t),view:location.hash||`/`}),keepalive:!0}).catch(()=>{}),V(`error`,n))}function Os(){window.__pierReporting=!0,window.addEventListener(`error`,e=>{!e.error&&e.message.includes(`ResizeObserver loop`)||Ds(`script error: ${e.message}`,e.error)}),window.addEventListener(`unhandledrejection`,e=>{Ds(`unhandled rejection`,e.reason)})}var ks=window.fetch.bind(window),As=()=>{location.assign(`/login?next=${encodeURIComponent(location.pathname+location.hash)}`)};function js(){window.fetch=async(...e)=>{let t=await ks(...e);return t.status===401&&As(),t}}function Ms(e,t){if(e.readyState!==EventSource.CLOSED)return;let n=()=>{let e=Ds(`${t} stream disconnected`);if(!e)return;let n=Xr(`Reload`);n.classList.add(`ml-2`,`align-middle`),n.onclick=()=>location.reload(),e.append(` `,n)};ks(`/api/sessions`).then(e=>e.status===401?As():n(),n)}var Ns=/Mac|iP(?:hone|ad|od)/.test(navigator.userAgent),Ps=Ns?`⌘`:`Ctrl+`,Fs=Ns?`⇧`:`Shift+`,Is=e=>{let t=e.startsWith(`meta+`),n=t?e.slice(5):e;return n.startsWith(`shift+`)?{key:n.slice(6),shift:!0,meta:t}:{key:n,shift:!1,meta:t}};function Ls(e){let{key:t,shift:n,meta:r}=Is(e);return`${r?`⌘`:Ps}${n?Fs:``}${t.toUpperCase()}`}var Rs=()=>document.querySelector(`dialog[open]`)!==null,zs={"[":`{`,"]":`}`},Bs=`pointer-events-none fixed z-50 flex items-center gap-2 whitespace-nowrap rounded-md bg-neutral-800 px-2 py-1 text-[11.5px] text-neutral-100 shadow-lg`;function Vs(e,t,n){e.removeAttribute(`title`);let r=null,i=()=>{r?.remove(),r=null,document.removeEventListener(`keydown`,i,!0)};e.addEventListener(`pointerenter`,a=>{if(a.pointerType!==`mouse`)return;i(),r=R(`div`,Bs,t,R(`kbd`,`rounded bg-white/15 px-1 py-px font-sans text-[10.5px]`,n)),document.body.append(r);let o=e.getBoundingClientRect(),s=o.bottom+6,c=s+r.offsetHeight+8<=window.innerHeight;r.style.top=`${c?s:Math.max(8,o.top-r.offsetHeight-6)}px`,r.style.left=`${Math.max(8,Math.min(o.left,window.innerWidth-r.offsetWidth-8))}px`,document.addEventListener(`keydown`,i,!0)}),e.addEventListener(`pointerleave`,i),e.addEventListener(`pointerdown`,i)}function Hs(e,t,n,r,i){Vs(e,n,Ls(t)),Ks(t,r,i)}function Us(e,t,n,r){Vs(e,t,`Esc`),document.addEventListener(`keydown`,e=>{e.key!==`Escape`||e.isComposing||e.defaultPrevented||Rs()||!r()||(e.preventDefault(),n())})}var Ws=`input, textarea, select, [contenteditable]`;function Gs(e,t,n,r,i){Vs(e,n,t[0].toUpperCase()),document.addEventListener(`keydown`,e=>{e.metaKey||e.ctrlKey||e.altKey||e.isComposing||e.defaultPrevented||!e.key||!t.includes(e.key.toLowerCase())||e.target?.closest?.(Ws)||Rs()||!i()||(e.preventDefault(),r())})}function Ks(e,t,n){let{key:r,shift:i,meta:a}=Is(e),o=zs[r];document.addEventListener(`keydown`,e=>{if(!e.key||e.altKey||e.shiftKey!==i)return;let s=e.key.toLowerCase();(s===r||s===o)&&((a?!e.metaKey:!e.metaKey&&!e.ctrlKey)||n?.()||(e.preventDefault(),e.stopPropagation(),t()))},!0)}var U,qs=L(`#composer`),W=L(`#input`),Js=L(`#send`),Ys=L(`#send-plane`),Xs=L(`#send-queue`),Zs=L(`#stop`),Qs=L(`#queue-panel`),$s=L(`#queue-rows`),ec=L(`#queue-label`),tc=R(`div`,`hidden max-h-48 overflow-y-auto border-t border-neutral-200 px-4 py-2 text-[13px]`);tc.id=`recovery-panel`,Qs.after(tc);var nc=L(`#image-strip`),rc=L(`#attach-input`),ic=!1,ac=0,oc=new Set,sc=[],cc=[];function lc(){let e=window.visualViewport;if(!e)return;let t=()=>{let t=e.scale<=1.05&&window.innerHeight-e.height-e.offsetTop>80;t?document.body.dataset.kb=``:delete document.body.dataset.kb,document.body.style.height=t?`${String(e.height)}px`:``,t&&window.scrollY&&window.scrollTo(0,0)};e.addEventListener(`resize`,t),e.addEventListener(`scroll`,t)}function uc(){let e=qs.parentElement,t=[Qs,tc,qs],n=new ResizeObserver(()=>{let n=t.reduce((e,t)=>e+t.offsetHeight,0);e.style.setProperty(`--dock-h`,`${String(n)}px`)});for(let e of t)n.observe(e)}function dc(){W.focus()}function fc(e){let t=cc.indexOf(e);return t<0?!1:(cc.splice(t,1),!0)}function pc(e){cc.push(e)}function mc(){cc=[]}function hc(){let e=U.sessionState()===`streaming`,t=U.sessionId()!==null,n=U.starting();Js.disabled=!t,Js.className=`flex h-7 w-7 flex-none items-center justify-center rounded-lg ${t?e?`cursor-pointer bg-amber-100 text-amber-700 hover:bg-amber-200 active:bg-amber-300`:`cursor-pointer bg-indigo-600 text-white hover:bg-indigo-500 active:bg-indigo-700 dark:text-neutral-50`:`cursor-default bg-neutral-100 text-neutral-400`}`,Js.title=t?e?`Queue — delivered when the turn ends`:`Send`:n?`Starting the session…`:`No session`,W.placeholder=n?`Starting the session…`:`Message…`,Ys.classList.toggle(`hidden`,e),Xs.classList.toggle(`hidden`,!e),Zs.classList.toggle(`hidden`,!e),Zs.classList.toggle(`flex`,e)}function gc(){let e=U.chatVisible()&⁣Qs.classList.toggle(`hidden`,!e),Qs.classList.toggle(`flex`,e),tc.classList.toggle(`hidden`,!U.chatVisible()||!tc.childElementCount)}function _c(e,t=!1){let n=U.sessionId();if(tc.replaceChildren(...e.map(e=>{let t=R(`details`,`py-1`),r=e.status===`submitting`?`Handing off`:e.status===`not-submitted`?`Not submitted`:`Acceptance unknown`,i=e.status===`submitting`?``:`; automatic queue paused`;t.append(R(`summary`,`cursor-pointer break-words text-amber-700`,`Queue recovery: ${r}${i} (in memory)`));for(let n of[...e.steering,...e.followUp]){let e=R(`div`,`flex items-start gap-2 border-t border-neutral-100 py-1`);e.append(R(`span`,`min-w-0 flex-1 whitespace-pre-wrap break-words`,n),Jr(`flex-none cursor-pointer px-1 text-neutral-500 hover:text-neutral-800`,()=>n)),t.append(e)}e.error&&t.append(R(`div`,`break-words text-red-600`,e.error));let a=R(`button`,`cursor-pointer py-1 text-neutral-500 disabled:cursor-default disabled:opacity-40`,`Acknowledge`);return a.type=`button`,a.disabled=e.status===`submitting`,a.title=`Remove this recovery copy without sending it`,a.onclick=async()=>{if(!n||!confirm(`Remove this recovery copy? This does not resend the messages.`))return;let t=await y(`/api/sessions/${n}/queue/recovery/${e.id}/ack`,{}),r=t.ok?null:await b(t,`Could not acknowledge queue recovery`);U.sessionId()===n&&(r===null?await U.reload(n):V(`error`,r))},t.append(a),t})),t){let e=R(`div`,`flex flex-wrap items-center gap-x-2 py-1 text-amber-700`,`Automatic queue paused: acceptance unknown (in memory)`),t=R(`button`,`cursor-pointer underline`,`Recall queue`);t.title=`Clear the live queue and return its messages to the composer`,t.onclick=()=>void jc(),e.append(t),tc.prepend(e)}gc()}function vc(e,t){++ac;let n=[...e.map(e=>({mode:`steer`,text:e})),...t.map(e=>({mode:`queued`,text:e}))];ic=n.length>0,ec.textContent=n.length>1?`Queued · ${n.length}`:`Queued`,gc(),$s.replaceChildren(...n.map(e=>{let t=R(`li`,`flex items-start gap-2 text-[13px] leading-[18px]`);return e.mode===`steer`&&t.append(R(`span`,`flex-none rounded bg-indigo-100 px-1 py-0.5 text-[10.5px] font-semibold uppercase tracking-wide text-indigo-700`,e.mode)),t.append(R(`span`,`min-w-0 whitespace-pre-wrap break-words text-neutral-700`,e.text)),t}))}var yc=8;function bc(){nc.classList.toggle(`hidden`,sc.length===0),nc.classList.toggle(`flex`,sc.length>0),nc.replaceChildren(...sc.map((e,t)=>{let n=e.mimeType.startsWith(`image/`)?ea(`data:${e.mimeType};base64,${e.data}`):R(`span`,`flex h-16 max-w-40 items-center truncate rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[12px] text-neutral-700`,e.name??`file`),r=R(`button`,`absolute -right-1.5 -top-1.5 flex h-4 w-4 cursor-pointer items-center justify-center rounded-full bg-neutral-700 text-[10px] leading-none text-white hover:bg-red-600`,h(ye,`h-3 w-3`));return r.setAttribute(`type`,`button`),r.setAttribute(`aria-label`,`Remove ${e.name??`attachment`}`),r.onclick=()=>{sc.splice(t,1),bc()},R(`div`,`relative`,n,r)}))}function xc(e){if(sc.length>=yc){V(`error`,`attachment limit is ${yc} files per message`);return}if(e.size>33554432){V(`error`,`${e.name||`file`} is too large (32MB max)`);return}let t=new FileReader;t.onload=()=>{let n=t.result;sc.push({data:n.slice(n.indexOf(`,`)+1),mimeType:e.type||`application/octet-stream`,name:e.name||void 0}),bc()},t.readAsDataURL(e)}async function Sc(e){let t=[];for(let n of e){let e=await y(`/api/inbox`,n);if(!e.ok)return null;let{path:r}=await e.json();t.push(vi(r))}return t}var Cc=e=>`pier.draft.${e}`,wc=0;function Tc(e=U.sessionId(),t=W.value){e&&(t?localStorage.setItem(Cc(e),t):localStorage.removeItem(Cc(e)))}function Ec(e){++wc,W.value=localStorage.getItem(Cc(e))??``,Dc(),sc=[],bc()}function Dc(){let e=W.style.height;W.style.height=`auto`;let t=`${Math.min(W.scrollHeight,192)}px`;W.style.height=t,t!==e&&Oo()}var Oc=!1;async function kc(e,t){let n=(t??W.value).trim(),r=t===void 0?sc:[],i=U.sessionId();if(!(!n&&r.length===0||!i)){if(t===void 0){if(Oc)return;Oc=!0,W.value=``,Dc(),Tc(),sc=[],bc()}try{let t=[];if(r.length){let e=await Sc(r);if(e===null){V(`error`,`attachment upload failed`),W.value=[n,W.value.trim()].filter(Boolean).join(`
|
|
81
|
+
`),Dc(),Tc(),sc=r,bc();return}t=e}let a=[n,...t].filter(Boolean).join(`
|
|
82
|
+
`),o=U.sessionState()===`idle`&&e===`auto`;o?U.setState(`streaming`):hc(),(o||e===`steer`)&&(pc(a),V(`user`,a,!1,Date.now()),Oo(!0));let s=await y(`/api/sessions/${i}/messages`,{text:a,mode:e});if(!s.ok){let e=await b(s,`send failed`);await U.reload(i),V(`error`,e)}}finally{t===void 0&&(Oc=!1)}}}async function Ac(e){let t=U.sessionId();if(!t)return;vc([],[]);let n=await y(`/api/sessions/${t}/queue/deliver`,{mode:e});if(!n.ok){let r=await b(n,`Queue ${e} failed`);await U.reload(t),U.sessionId()===t&&V(`error`,r)}}async function jc(){let e=U.sessionId();if(!e||oc.has(e))return;oc.add(e);let t=ac,n=wc,r=document.activeElement;try{Tc();let i=await fetch(`/api/sessions/${e}/queue/recall`,{method:`POST`});if(!i.ok){let t=await b(i,`Could not recall queued messages`);U.sessionId()===e&&V(`error`,t);return}let{messages:a}=await i.json(),o=U.sessionId()===e;if(a.length)try{let t=o?W.value:localStorage.getItem(Cc(e))??``,i=(t?[t,...a]:a).join(`
|
|
83
|
+
`);o&&(W.value=i,Dc(),n===wc&&U.chatVisible()&&document.activeElement===r&&W.focus()),Tc(e,i)}catch(t){V(`error`,`Could not save recalled messages for session ${e}: ${String(t)}\nRecalled messages (not saved):\n${a.join(`
|
|
84
|
+
`)}`)}o&&t===ac&&vc([],[])}finally{oc.delete(e)}}function Mc(e){U=e,lc(),uc();let t=()=>{let e=U.sessionId();e&&fetch(`/api/sessions/${e}/abort`,{method:`POST`})};Zs.onclick=t,Us(Zs,`Stop the running turn`,t,()=>U.sessionState()===`streaming`&&U.chatVisible()),L(`#queue-steer`).onclick=()=>void Ac(`steer`),L(`#queue-restart`).onclick=()=>void Ac(`restart`),L(`#queue-recall`).onclick=()=>void jc(),qs.onsubmit=e=>{e.preventDefault(),kc(`auto`)},Gs(W,[`/`],`Write a message`,dc,U.chatVisible),W.onfocus=Do,W.oninput=()=>{Dc(),Tc()};let n=!matchMedia(`(pointer: coarse)`).matches;W.onkeydown=e=>{e.isComposing||e.keyCode===229||n&&e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),kc(`auto`))},W.onpaste=e=>{for(let t of e.clipboardData?.items??[]){let e=t.kind===`file`?t.getAsFile():null;e&&xc(e)}let t=e.clipboardData?.getData(`text/plain`)??``,n=t.trim();!n||n===t||(e.preventDefault(),W.setRangeText(n,W.selectionStart??0,W.selectionEnd??0,`end`),Dc(),Tc())},B.ondragover=e=>e.preventDefault(),B.ondrop=e=>{e.preventDefault();for(let t of e.dataTransfer?.files??[])xc(t)},L(`#attach`).onclick=()=>rc.click(),rc.onchange=()=>{for(let e of rc.files??[])xc(e);rc.value=``},hc()}var Nc=`pier.push`,Pc=`/sw.js`,Fc=()=>/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.maxTouchPoints>1&&/Macintosh/.test(navigator.userAgent),Ic=()=>matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0;function Lc(){return window.isSecureContext?Fc()&&!Ic()?`On iPhone and iPad, notifications work only from the installed app: Share → Add to Home Screen, then open Pier from that icon.`:!(`serviceWorker`in navigator)||!(`PushManager`in window)||!(`Notification`in window)?`This browser has no Web Push support.`:``:`Notifications need HTTPS. Reach this Pier through its public URL, not over plain http.`}var Rc=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/Macintosh/,`Mac`],[/Windows/,`Windows`]],zc=[[/Edg\//,`Edge`],[/Chrome\//,`Chrome`],[/Firefox\//,`Firefox`],[/Safari\//,`Safari`]];function Bc(){let e=navigator.userAgent,t=(t,n)=>t.find(([t])=>t.test(e))?.[1]??n;return`${t(Rc,`Linux`)} · ${t(zc,`browser`)}${Ic()?` (installed)`:``}`}var Vc=e=>{let t=atob(e.replace(/-/g,`+`).replace(/_/g,`/`)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n},Hc=null;async function Uc(){return!(`serviceWorker`in navigator)||!window.isSecureContext?null:(Hc??=await navigator.serviceWorker.register(Pc,{scope:`/`}).catch(e=>(console.warn(`service worker registration failed`,e),null)),Hc)}var Wc=(e,t)=>{let n=e?new Uint8Array(e):null;return n?.length===t.length&&n.every((e,n)=>e===t[n])};async function Gc(e){let{publicKey:t}=await ze(`/api/push`,`Could not read this instance's push key`),n=Vc(t),r=await e.pushManager.getSubscription();if(r){if(Wc(r.options.applicationServerKey,n))return r;await r.unsubscribe()}return e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:n})}async function Kc(e){return y(`/api/push/subscribe`,{...e.toJSON(),label:Bc()})}async function qc(){Xc();let e=await Uc();if(!(!e||localStorage.getItem(Nc)!==`on`)&&!(!(`Notification`in window)||Notification.permission!==`granted`))try{await Kc(await Gc(e))}catch(e){console.warn(`re-registering this browser for notifications failed`,e)}}var Jc=null,Yc=null;function Xc(){window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),Jc=e,Yc?.()}),window.addEventListener(`appinstalled`,()=>{Jc=null,Yc?.()})}function Zc(e){let t=navigator;(e>0?t.setAppBadge?.(e):t.clearAppBadge?.())?.catch(()=>{})}function Qc(){let e=R(`span`,`text-[11.5px]`,``),t=Xr(`Send a test notification`),n=R(`div`,`flex items-center gap-3`,t,e),r=R(`div`,`flex flex-col gap-4`),i=()=>localStorage.getItem(Nc)===`on`;async function a(){pi(e,`saving`,`asking this browser…`);let t=await Notification.requestPermission();if(t!==`granted`)return localStorage.setItem(Nc,`off`),c(),pi(e,`failed`,t===`denied`?`Notifications are blocked for this site — allow them in the browser's site settings, then try again.`:`No answer to the permission prompt.`);let n=await Uc();if(!n)return pi(e,`failed`,`This browser refused to register a service worker.`);try{let t=await Kc(await Gc(n));if(!t.ok)return pi(e,`failed`,await b(t,`Could not register this browser`));localStorage.setItem(Nc,`on`),c(),pi(e,`saved`,`This browser will be notified when a turn finishes unseen.`)}catch(t){pi(e,`failed`,`Could not subscribe: ${String(t)}`)}}async function o(){localStorage.setItem(Nc,`off`),c();let t=await(await Uc())?.pushManager.getSubscription();t&&(await y(`/api/push/unsubscribe`,{endpoint:t.endpoint}),await t.unsubscribe()),pi(e,`idle`,`This browser will not be notified.`)}t.onclick=()=>{pi(e,`saving`,`sending…`),(async()=>{let t=await y(`/api/push/test`,{});if(!t.ok)return pi(e,`failed`,await b(t,`Could not send`));let{sent:n,failed:r}=await t.json();pi(e,r?`failed`:`saved`,`Handed ${String(n)} device(s) to their push service${r?`, ${String(r)} refused`:``}.`)})()};function s(){if(!Jc)return[];let e=Xr(`Install Pier`,!0);return e.onclick=()=>{let e=Jc;e&&e.prompt().then(()=>e.userChoice).finally(()=>{Jc=null,c()})},[R(`div`,`flex items-center gap-3`,e,R(`span`,`text-[11.5px] leading-snug text-neutral-500`,`Its own window and icon — and where notifications look like an app's.`))]}function c(){let e=Lc();if(e){r.replaceChildren(...s(),R(`p`,`text-[12.5px] leading-snug text-neutral-500`,e));return}let c=i()&&Notification.permission===`granted`;t.disabled=!c,r.replaceChildren(...s(),di(`Notify this device`,`A turn that finishes while nobody is looking at it becomes a notification here. Per browser — each device is enabled on its own.`,c,e=>void(e?a():o())),n)}return Yc=c,c(),ii(`Notifications`,`Web Push, so a finished turn reaches you with the workbench closed. Installed — Chrome's address-bar icon, or Share → Add to Home Screen on iOS — Pier notifies you the way an app does.`,r)}var G=null,$c=null,el=null;function tl(e){G&&!G.contains(e.target)&&e.target!==el&&K()}var nl={ArrowDown:1,ArrowUp:-1},rl={n:1,j:1,p:-1,k:-1};function il(e){if(!(e.altKey||e.metaKey||e.shiftKey||!e.key))return e.ctrlKey?rl[e.key.toLowerCase()]:nl[e.key]}function al(e){let t=il(e);if(G?.dataset.menu===`true`&&(t!==void 0||e.key===`Home`||e.key===`End`)){let n=[...G.querySelectorAll(`button:not(:disabled)`)];if(!n.length)return;let r=n.indexOf(document.activeElement),i=e.key===`Home`?0:e.key===`End`?n.length-1:r<0?t===1?0:n.length-1:(r+(t??0)+n.length)%n.length;e.preventDefault(),n[i]?.focus();return}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),K())}function ol(e){G&&!G.contains(e.target)&&K()}function K(){if(!G)return;document.removeEventListener(`pointerdown`,tl,!0),document.removeEventListener(`focusin`,tl,!0),document.removeEventListener(`keydown`,al,!0),window.removeEventListener(`scroll`,ol,!0),window.removeEventListener(`resize`,K);let e=G;G=null,el?.remove(),el=null,e.contains(document.activeElement)&&$c?.focus({preventScroll:!0}),$c?.removeAttribute(`aria-expanded`),$c=null,e.inert=!0,e.dataset.closing=``,Promise.allSettled(e.getAnimations().map(e=>e.finished)).then(()=>e.remove())}var sl=null;function cl(e){let t=e.getBoundingClientRect(),n={top:t.bottom+4,left:t.left};return t.width||t.height?n:sl?.anchor===e?{top:sl.top,left:sl.left}:n}var ll=()=>window.innerWidth<640;function ul(e,t){K(),document.querySelectorAll(`.glass-menu[data-closing]`).forEach(e=>e.remove());let n=ll();G=R(`div`,`glass-menu fixed z-50 border border-neutral-200 p-2 font-sans leading-6 ${n?`rounded-3xl inset-x-2 bottom-2 max-h-[70dvh] overflow-y-auto pb-[calc(0.25rem+env(safe-area-inset-bottom))] text-[16px]`:`rounded-2xl min-w-60 max-w-[min(42rem,calc(100vw-1rem))] max-h-[calc(100dvh-1rem)] overflow-y-auto text-[15px]`}`),G.dataset.presentation=n?`sheet`:`popover`,G.append(t);let r=e.closest(`dialog[open]`)??document.body;if(n&&(el=R(`div`,`fixed inset-0 z-50 bg-black/15`),el.onclick=e=>{e.stopPropagation(),K()},r.append(el)),r.append(G),!n){let t=cl(e);sl={anchor:e,...t},G.style.top=`${Math.max(8,Math.min(t.top,window.innerHeight-G.offsetHeight-8))}px`,G.style.left=`${Math.max(8,Math.min(t.left,window.innerWidth-G.offsetWidth-8))}px`}$c=e,$c.setAttribute(`aria-expanded`,`true`),G.tabIndex=-1,(G.querySelector(`button, input, select, [tabindex='0']`)??G).focus({preventScroll:!0}),document.addEventListener(`pointerdown`,tl,!0),document.addEventListener(`focusin`,tl,!0),document.addEventListener(`keydown`,al,!0),window.addEventListener(`scroll`,ol,!0),window.addEventListener(`resize`,K)}function dl(e){let t=R(`button`,`flex w-full cursor-pointer items-center gap-2 rounded-xl px-3 text-left transition-colors hover:bg-indigo-50 hover:text-indigo-700 active:bg-indigo-100 ${ll()?`min-h-12 py-3`:`min-h-10 py-2`}`,...e.checked===void 0?[]:[h(a,`h-3 w-3 text-indigo-600 ${e.checked?``:`invisible`}`)],R(`span`,`min-w-0 truncate`,e.label));if(e.hint){let n=R(`span`,`ml-auto max-w-28 shrink-[999] truncate text-[13px] text-neutral-500`,e.hint);n.title=e.hint,t.append(n)}return t.onclick=()=>e.onSelect(),t}function fl(e,t,n){let r=R(`div`,``);if(n&&ll()){let e=R(`button`,`icon-btn h-11 w-11`,h(ye));e.setAttribute(`aria-label`,`Close session actions`),e.onclick=K,r.append(R(`div`,`flex items-center gap-3 border-b border-neutral-200 px-3 pb-1 mb-1`,R(`span`,`min-w-0 flex-1 truncate text-sm font-medium text-neutral-500`,n),e))}for(let e of t)e.separatorBefore&&r.append(R(`hr`,`my-2 border-neutral-200`)),r.append(dl(e));ul(e,r),G&&(G.dataset.menu=`true`,G.setAttribute(`aria-label`,n?`Actions for ${n}`:`Actions`),G.setAttribute(`role`,`group`))}var pl=async e=>{let t=await Re(`/api/fs/ls${e?.startsWith(`/`)?`?path=${encodeURIComponent(e)}`:``}`,`Could not list directories`);return t.ok?t.value:null},ml=e=>e.entries.filter(e=>e.dir&&!e.name.startsWith(`.`)).map(e=>e.name),hl=`flex w-full min-h-10 cursor-pointer items-center gap-2 rounded-xl px-3 py-2 text-left transition-colors hover:bg-indigo-50 hover:text-indigo-700 active:bg-indigo-100`,gl=`font-mono text-[0.875rem]`,_l=(e,t,n)=>{let r=Zr(e,`${hl} ${t}`);return r.onclick=n,r};function vl(e,t){let n=R(`div`,`mt-2 flex-none border-t border-neutral-200 pt-2`),r=_l(`New folder`,`text-neutral-500`,()=>{let r=document.createElement(`input`);r.className=`w-full rounded-xl border-0 bg-neutral-100 px-3 py-2 ${gl} focus:outline-none`,r.placeholder=`folder-name`;let i=R(`p`,`hidden px-3 pt-1 text-[0.8125rem] text-red-600`);r.onkeydown=async n=>{if(n.key!==`Enter`)return;n.preventDefault();let a=await y(`/api/fs/mkdir`,{path:e,name:r.value});if(!a.ok){i.textContent=(await a.json()).error??`could not create`,i.classList.remove(`hidden`);return}t((await a.json()).path)},n.replaceChildren(r,i),r.focus()});return r.prepend(h(de)),n.append(r),n}function yl(e,t,n){let r=e=>{n(e),K()};async function i(t){let n=await pl(t);if(!n)return;let a=R(`div`,`flex max-h-[60dvh] w-full flex-col sm:w-88`),o=Zr(`Use`,`btn btn-primary ml-auto flex-none px-3 py-1 text-[0.8125rem]`);o.onclick=()=>r(n.path);let s=document.createElement(`input`);s.className=`min-w-0 flex-1 border-0 bg-transparent ${gl} text-neutral-600 focus:outline-none`,s.value=n.path,s.spellcheck=!1,s.title=`Type or paste a path, then Enter`,s.onfocus=()=>s.select();let c=R(`p`,`hidden flex-none px-3 pb-1 text-[0.8125rem] text-red-600`);s.onkeydown=async e=>{if(e.key!==`Enter`)return;e.preventDefault(),e.stopPropagation();let t=s.value.trim();if(!t)return;let n=await pl(t);if(!n){c.textContent=`${t} is not a folder this can read`,c.classList.remove(`hidden`);return}r(n.path)};let l=R(`div`,`mb-2 flex flex-none items-center gap-2 border-b border-neutral-200 px-3 pb-2 pt-1`,s,o),u=R(`div`,`min-h-0 flex-1 overflow-y-auto`);n.parent&&u.append(_l(`../`,`${gl} text-neutral-500`,()=>void i(n.parent)));let d=ml(n);for(let e of d)u.append(_l(e,`truncate`,()=>void i(`${n.path}/${e}`.replace(`//`,`/`))));d.length||u.append(R(`p`,`px-3 py-2 text-[0.8125rem] text-neutral-400`,`No sub-folders.`)),a.append(l,c,u,vl(n.path,e=>void i(e))),ul(e,a)}i(t)}function bl(e,t,n,r){fl(e,[...t.map(e=>({label:e.path,...e.hint?{hint:e.hint}:{},checked:e.path===n,onSelect:()=>{K(),r(e.path)}})),{label:`Browse…`,onSelect:()=>yl(e,n||void 0,r)}])}var xl=(e,t)=>n=>{e.value=n,e.dispatchEvent(new Event(`input`,{bubbles:!0})),t?.(n)};function Sl(e,t){let n=Zr(`Browse…`,`flex-none cursor-pointer rounded-md border border-neutral-300 px-2 py-1 text-[12px] text-neutral-600 hover:bg-neutral-100`);return n.onclick=()=>yl(n,e.value.trim()||void 0,xl(e,t)),n}function Cl(e,t,n){let r=document.createElement(`input`);return r.className=`min-w-0 flex-1 rounded-md border border-neutral-300 bg-white px-2 py-1 font-mono text-[12.5px] focus:border-indigo-400 focus:outline-none`,r.value=e,r.placeholder=t,r.oninput=()=>n(r.value),{el:R(`div`,`flex items-center gap-1.5`,r,Sl(r,n)),input:r}}var q=L(`#sidebar`),wl=L(`#drawer-scrim`),Tl=L(`#mobile-title`),El=L(`#mobile-menu`),Dl=L(`#session-meta`);function Ol(){delete q.dataset.open,wl.classList.add(`hidden`),Il()}function kl(e,t){Tl.textContent=e,Tl.classList.toggle(`cursor-pointer`,t),El.classList.toggle(`hidden`,!t)}var Al=`pier.railClosed`;localStorage.getItem(Al)===`1`&&(document.body.dataset.rail=`closed`);function jl(e){document.body.dataset.rail=e?`closed`:``,localStorage.setItem(Al,e?`1`:`0`),Il()}function Ml(){if(q.dataset.open!==void 0)return Ol();q.dataset.open=``,wl.classList.remove(`hidden`),Il()}var Nl=window.matchMedia(`(width < 48rem)`),Pl=()=>Nl.matches;function Fl(){Pl()?L(`#mobile-bar`).append(Dl):L(`#chat-menu`).before(Dl)}function Il(){let e=Pl()&&q.dataset.open!==void 0,t=L(`main`);t.inert=e,q.inert=Pl()?!e:document.body.dataset.rail===`closed`,L(`#drawer-toggle`).setAttribute(`aria-expanded`,String(e)),e&&!q.contains(document.activeElement)&&L(`#new-session`).focus(),q.inert&&q.contains(document.activeElement)&&L(Pl()?`#drawer-toggle`:`#rail-toggle`).focus()}var Ll=[L(`#rail-toggle`),L(`#drawer-toggle`)],Rl=`attention absolute -right-0.5 -top-0.5 rounded-full bg-amber-500`,zl=e=>e===1?R(`span`,`${Rl} h-2 w-2`):R(`span`,`${Rl} flex h-3.5 min-w-3.5 items-center justify-center px-0.5 text-[9px] font-semibold text-white`,e>9?`9+`:String(e));function Bl(e){for(let t of Ll)t.querySelector(`.attention`)?.remove(),e&&t.append(zl(e))}var Vl=20,Hl=.35,Ul=8;function Wl(){let e=-1,t=0,n=!1,r=!1,i=1,a=e=>{q.style.transition=`none`,q.style.transform=`translateX(${String(e-i)}px)`,wl.style.transition=`none`,wl.classList.remove(`hidden`),wl.style.opacity=String(e/i)},o=t=>{q.style.transition=``,q.style.transform=``,wl.style.transition=``,wl.style.opacity=``,t?(q.dataset.open=``,wl.classList.remove(`hidden`),Il()):Ol(),e=-1,r=!1};window.addEventListener(`touchstart`,a=>{if(r||(e=-1,!Pl()||a.touches.length!==1))return;let o=a.touches[0],s=q.dataset.open!==void 0;if(i=q.offsetWidth||1,s){if(o.clientX>i)return}else{if(o.clientX>Vl||a.target?.closest(`button, a, input, textarea, select`))return;a.preventDefault()}e=o.clientX,t=o.clientY,n=!s},{passive:!1}),window.addEventListener(`touchmove`,o=>{if(e<0)return;let s=o.touches[0],c=s.clientX-e;if(!r){if(Math.abs(s.clientY-t)>Math.abs(c))return void(e=-1);if(Math.abs(c)<Ul)return;r=!0}o.preventDefault(),a(Math.max(0,Math.min(i,n?c:i+c)))},{passive:!1});let s=()=>{if(e<0)return;if(!r)return void(e=-1);let t=q.getBoundingClientRect().right;o(n?t>i*Hl:t>i*.65)};window.addEventListener(`touchend`,s),window.addEventListener(`touchcancel`,s)}function Gl(e){Wl(),Il(),Fl(),Nl.addEventListener(`change`,()=>{Ol(),Fl()}),L(`#drawer-toggle`).setAttribute(`aria-controls`,`sidebar`),q.addEventListener(`keydown`,e=>{if(!(!Pl()||q.dataset.open===void 0||e.defaultPrevented||e.isComposing)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),Ol();else if(e.key===`Tab`){let t=[...q.querySelectorAll(`button, a[href], summary`)].filter(e=>e.getClientRects().length&&!e.matches(`:disabled`)),n=e.shiftKey?t.at(-1):t[0],r=e.shiftKey?t[0]:t.at(-1);document.activeElement===r&&(e.preventDefault(),n?.focus())}}}),L(`#drawer-toggle`).onclick=Ml,wl.onclick=Ol,El.onclick=()=>e.sessionMenu(El),Tl.onclick=()=>{El.classList.contains(`hidden`)||e.sessionInfo(Tl)};let t=L(`#rail-toggle`);t.onclick=()=>jl(document.body.dataset.rail!==`closed`),Hs(t,`meta+b`,`Toggle sidebar`,()=>Pl()?Ml():jl(document.body.dataset.rail!==`closed`))}var J,Kl=L(`#session-list`),ql=L(`#new-session`),Jl=e=>e.modified??e.createdAt;function Yl(e){return{top:e.filter(e=>e.rank!==void 0).sort((e,t)=>(e.rank??0)-(t.rank??0)),rest:e.filter(e=>e.rank===void 0).sort((e,t)=>t.createdAt-e.createdAt)}}function Xl(e,t){let{top:n,rest:r}=Yl(e),i=[...n,...r].slice(0,t);return{rows:i,hidden:e.length-i.length}}function Zl(e,t,n){let{top:r,rest:i}=Yl(e),a=[...r,...i];if(!a.length)return;let o=a.findIndex(e=>e.id===t),s=o<0?a[0]:a[(o+n+a.length)%a.length];return s&&s.id!==t?s.id:void 0}var Ql=8,$l=e=>[...new Set([...e].sort((e,t)=>t.createdAt-e.createdAt).map(e=>e.cwd))];function eu(e){let t=$l(e),n=new Set(t);return t.filter(e=>{let t=e.lastIndexOf(`/`),r=e.indexOf(`.`,t+2);return r<0||!n.has(e.slice(0,r))})}var tu=`session-more hidden h-7 w-7 flex-none cursor-pointer items-center justify-center rounded-lg text-neutral-400 hover:bg-neutral-200 hover:text-neutral-700`,nu=e=>e.unread;function ru(e){let t=e.state===`streaming`?[`bg-green-500 animate-pulse`,`working…`]:nu(e)?[`bg-amber-500`,`turn finished — not viewed yet`]:e.activeRuns>0?[`bg-sky-500`,`${e.activeRuns} subagent${e.activeRuns>1?`s`:``} running`]:null;if(!t)return[];let n=R(`span`,`h-2 w-2 flex-none rounded-full ${t[0]}`);return n.title=t[1],[n]}async function iu(e){let t=window.prompt(`Session name — empty resets it to the first message`,e.title??``);if(t===null)return;let n=e.title,r=t=>{e.title=t,du(),J.onTitleChanged()};r(t.trim()||void 0),(await y(`/api/sessions/${e.id}/rename`,{name:t})).ok||r(n)}var au=`flex-none text-xs font-medium uppercase leading-5 text-neutral-500`,ou=e=>e.channel&&e.channel!==`web`?[R(`span`,au,e.channel[0]??``)]:[];function su(e,t=R(`button`,tu,h(f))){let n=e.id===J.currentId(),r=R(`li`,`flex items-center gap-1 hover:bg-neutral-100 ${n?`bg-indigo-50 hover:bg-indigo-50`:``}`);t.setAttribute(`type`,`button`),t.setAttribute(`aria-label`,`Session actions: ${e.title??`untitled`}`),t.title=`Session actions`,t.onclick=n=>{n.stopPropagation(),J.sessionMenu(t,e)};let i=R(`button`,`session-open flex min-w-0 flex-1 cursor-pointer items-center gap-1.5 rounded-lg text-left`,R(`span`,`min-w-0 flex-1 truncate`,e.title??`untitled`),...ru(e));return i.setAttribute(`type`,`button`),n&&i.setAttribute(`aria-current`,`page`),i.onclick=()=>J.select(e.id),r.dataset.sessionId=e.id,r.append(i,...ou(e),t),r.title=[e.cwd,`active ${Rr(Jl(e))} ago · created ${new Date(e.createdAt).toLocaleDateString()}`,...e.channel&&e.channel!==`web`?[`answering ${e.channel}`]:[]].join(`
|
|
85
|
+
`),r}var cu=()=>`${J.currentId()??``}\n${uu}\n${JSON.stringify(J.sessions())}`,lu=``,uu=20;function du(){let e=cu();if(e===lu)return;lu=e;let t=J.sessions(),n=t.filter(nu);Bl(n.length),Zc(n.length);let{rows:r,hidden:i}=Xl(t,uu),a=Kl.querySelector(`.session-more[aria-expanded='true']`),o=a?.closest(`[data-session-id]`)?.dataset.sessionId,s=r.map(e=>su(e,e.id===o?a:void 0));if(i>0){let e=R(`button`,`session-open w-full cursor-pointer rounded-lg text-left text-sm text-neutral-500`,`Load more (${i})`);e.id=`session-load-more`,e.setAttribute(`type`,`button`),e.onclick=()=>{uu+=20,du(),Kl.querySelectorAll(`.session-open`)[r.length]?.focus()},s.push(R(`li`,`hover:bg-neutral-100`,e))}let c=document.activeElement,l=c?.closest(`[data-session-id]`)?.dataset.sessionId,u=c?.classList.contains(`session-more`)?`.session-more`:`.session-open`;if(Kl.replaceChildren(...s.length?[R(`ul`,`pb-1`,...s)]:[R(`p`,`px-3 py-2 text-sm leading-normal text-neutral-500`,`No sessions yet — create one.`)]),l){let e=[...Kl.querySelectorAll(`[data-session-id]`)].find(e=>e.dataset.sessionId===l);e?.querySelector(`.session-open`)?.focus({preventScroll:!0}),u===`.session-more`&&e?.querySelector(u)?.focus({preventScroll:!0})}else c?.id===`session-load-more`&&(Kl.querySelector(`#session-load-more`)??Kl.querySelector(`.session-open`)??L(`#new-session`)).focus({preventScroll:!0});Wu()}function fu(){if(ql.getAttribute(`aria-expanded`)===`true`)return K();let e=J.sessions().find(e=>e.id===J.currentId())?.cwd,t=eu(J.sessions()).slice(0,Ql);if(e&&!t.includes(e)&&t.unshift(e),!t.length)return yl(ql,void 0,J.createSession);bl(ql,t.map(e=>({path:e,hint:Br(e)})),e,J.createSession)}function pu(e){J=e,ql.onclick=fu,Hs(ql,`shift+o`,`New session`,fu);let t=e=>{let t=Zl(J.sessions(),J.currentId(),e);t&&J.select(t)};Ks(`shift+[`,()=>t(-1),Rs),Ks(`shift+]`,()=>t(1),Rs)}var mu,hu=L(`#palette`),gu=L(`#palette-input`),_u=L(`#palette-list`),vu=L(`#palette-count`),yu=[{name:`tasks`,icon:re,label:`Tasks`,detail:`Automation — task definitions and schedules`},{name:`runs`,icon:re,label:`Runs`,detail:`Automation — executions, subagents, decisions and callbacks`},{name:`activity`,icon:re,label:`Activity`,detail:`Automation — sessions and relationships`},{name:`boards`,icon:ne,label:`Boards`,detail:`Console — the static pages Pier publishes`},{name:`settings`,icon:he,label:`Settings`,detail:`Console — models and providers, agent files and extensions, channels, password, sign out, security`}],bu=7,xu=3,Su=8,Cu=80,wu=``,Tu,Eu,Du;function Ou(e){wu!==e&&(clearTimeout(Du),Eu?.abort(),Eu=void 0,wu=e,Tu=void 0,e&&(Du=setTimeout(()=>{let t=Eu=new AbortController;Re(`/api/search?q=${encodeURIComponent(e)}`,`Search unavailable`,{signal:t.signal}).then(n=>{t.signal.aborted||wu!==e||(Eu=void 0,Tu=n.ok?{hits:n.value.hits}:{error:n.error},hu.open&&Uu())})},Cu)))}var ku=[],Au=0;function ju(e){if(ku.length){Au=(e+ku.length)%ku.length;for(let[e,{el:t}]of ku.entries())t.classList.toggle(`bg-indigo-50`,e===Au),t.setAttribute(`aria-selected`,String(e===Au));ku[Au]?.el.scrollIntoView({block:`nearest`})}}var Mu=e=>e.hit?.at??e.session?.createdAt;function Nu(e){let t=R(`span`,`min-w-0 flex-1 truncate text-neutral-500`),[n=``,r=``]=e.replaceAll(/\s+/g,` `).split(``,2),[i=``,a=``]=r.split(``,2);return t.append(n,R(`span`,`font-medium text-neutral-800`,i),a),t}var Pu=`flex min-w-0 flex-1 items-baseline gap-2`,Fu=`shrink-0 truncate`,Iu=`min-w-[2.5em] truncate text-[0.8125rem] text-neutral-400`,Lu=`flex-none text-[0.75rem] tabular-nums text-neutral-400`,Ru=`flex h-7 w-7 flex-none items-center justify-center rounded-[8px] bg-neutral-100 text-neutral-500`;function zu(e){let t=R(`li`,`palette-row flex cursor-pointer items-center gap-3 rounded-[10px] px-2 leading-5 ${e.hit?`py-1.5`:`min-h-10`}`);t.setAttribute(`role`,`option`),t.append(R(`span`,Ru,h(e.icon,`h-4 w-4`)));let n=R(`div`,`flex min-w-0 flex-1 flex-col`),r=R(`div`,`flex items-center gap-2`);e.session&&r.append(...ru(e.session));let i=R(`span`,Pu,R(`span`,`${Fu} ${e.detail?`max-w-[calc(100%-3em)]`:`max-w-full`}`,e.label));e.detail&&i.append(R(`span`,Iu,e.detail)),r.append(i);let a=Mu(e);return a!==void 0&&r.append(R(`span`,Lu,Rr(a))),n.append(r),e.hit&&n.append(R(`div`,`flex items-baseline gap-2 text-[0.8125rem] leading-5`,R(`span`,`flex-none text-[0.75rem] text-neutral-400`,e.hit.role===`user`?`You`:`Agent`),Nu(e.hit.snippet))),t.append(n),t.onclick=e.open,t}var Bu=e=>R(`li`,`px-2 pb-1.5 pt-4 text-[0.6875rem] font-semibold leading-4 tracking-[0.02em] text-neutral-400 first:pt-2`,e);function Vu(e,t){let n=R(`li`,`px-2 py-2 pl-12 text-[0.8125rem] leading-5 text-neutral-400`,e);return t&&(n.title=t),n}var Hu=e=>e.channel&&e.channel!==`web`?e.channel:``;function Uu(){let e=gu.value.trim(),t=e.toLowerCase(),n=e=>e.toLowerCase().includes(t),r=e=>()=>{hu.close(),e()},i=mu.sessions(),a=new Map(i.map(e=>[e.id,e])),{top:o,rest:s}=Yl(i),c=[...o,...s],l=e=>({icon:oe,label:e.title??Vr(e.cwd),detail:[Br(e.cwd),Hu(e)].filter(Boolean).join(` · `),open:r(()=>void mu.select(e.id)),session:e}),u=e=>({icon:te,label:Vr(e),detail:e,open:r(()=>void mu.createSession(e))}),d=yu.filter(t=>!e||n(`${t.label} ${t.detail}`)).map(({name:e,icon:t,label:n,detail:i})=>({icon:t,label:n,detail:i,open:r(()=>mu.openConsole(e))})),ee={icon:te,label:`New session in…`,detail:`Pick a directory`,open:r(fu)},f=[];if(e){let t=eu(i).filter(e=>n(Br(e))).slice(0,xu),o=c.filter(e=>n(`${e.title??``} ${e.cwd} ${Hu(e)}`)).slice(0,Su),s=new Set(o.map(e=>e.id)),p=o.map(l);if(wu!==e||!Tu)p.push(Vu(`Searching messages…`));else if(`error`in Tu)p.push(Vu(`Message search unavailable`,Tu.error));else{for(let e of Tu.hits){if(p.length>=Su)break;let t=a.get(e.sessionId);!t||s.has(t.id)||p.push({...l(t),hit:e,open:r(()=>void mu.select(t.id).then(()=>Ao(e.role,e.at)))})}p.length||p.push(Vu(`No sessions match`))}f.push([`Actions`,[...t.map(u),...n(ee.label)?[ee]:[],...d]],[`Sessions`,p])}else{let e=c.filter(e=>e.state===`streaming`),t=a.get(mu.currentId()??``);f.push([`Running`,e.map(l)],[`Recent`,c.filter(e=>e.state!==`streaming`).slice(0,bu).map(l)],[`Actions`,[...t?[u(t.cwd)]:[],ee]],[`Console`,d])}ku=[];let p=[];for(let[e,t]of f)if(t.length){p.push(Bu(e));for(let e of t){if(e instanceof HTMLElement){p.push(e);continue}let t=zu(e);ku.push({el:t,open:e.open}),p.push(t)}}_u.replaceChildren(...p.length?p:[Vu(`Nothing matches`)]),vu.textContent=`${ku.length} ${ku.length===1?`row`:`rows`}`,ju(Math.min(Au,Math.max(0,ku.length-1)))}function Wu(){hu.open&&Uu()}function Gu(){if(hu.open)return hu.close();gu.value=``,Au=0,Ou(``),Uu(),hu.showModal(),gu.focus(),mu.loadSessions().then(Wu)}function Ku(e){mu=e;let t=L(`#open-palette`);t.onclick=Gu,Hs(t,`k`,`Search sessions, messages and Console`,Gu,()=>hu.open),hu.onclick=e=>{e.target===hu&&hu.close()},hu.onclose=()=>Ou(``),gu.oninput=()=>{Au=0,Ou(gu.value.trim()),Uu()},gu.onkeydown=e=>{let t=il(e);if(t!==void 0){e.preventDefault(),ju(Au+t);return}e.key===`Enter`&&!e.ctrlKey&&(e.preventDefault(),ku[Au]?.open())}}var qu=0,Ju=e=>`${e.provider}/${e.id}`,Yu=null;async function Xu(){let{modelMenu:e}=await ze(`/api/settings`,`Could not read the pinned model menu`);return e}function Zu(e){let t=R(`button`,`flex w-full min-w-0 cursor-pointer items-center gap-2 px-3 py-1.5 text-left hover:bg-neutral-100`,h(a,`h-3 w-3 text-indigo-600 ${e.checked?``:`invisible`}`),R(`span`,`truncate`,e.label));return e.hint&&t.append(R(`span`,`ml-auto flex-none text-[11.5px] text-neutral-400`,e.hint)),e.title&&(t.title=e.title),t.onclick=()=>e.onSelect(),t}function Qu({models:e,current:t,thinkingLevel:n,thinkingLevels:r,onPick:i,onThinkingPick:a}){let o=n,s=R(`div`,`flex w-full min-w-0 flex-col sm:min-w-72`),l=R(`div`,`flex flex-col gap-2 border-b border-neutral-200 px-2 py-2`),u=document.createElement(`input`);if(u.type=`search`,u.placeholder=`Search models`,u.setAttribute(`aria-label`,`Search models`),u.className=`w-full rounded-md border border-neutral-300 px-2 py-1.5 text-[12.5px] focus:border-indigo-400 focus:outline-none`,l.append(u),r.length){let e=document.createElement(`details`),t=R(`span`,`ml-auto font-medium text-indigo-700`,Ce(o)),n=R(`summary`,`flex min-h-11 cursor-pointer list-none items-center gap-2 rounded-xl px-3 text-sm text-neutral-700 hover:bg-neutral-100 [&::-webkit-details-marker]:hidden`,R(`span`,`font-medium`,`Reasoning effort`),t,h(c,`chev h-3 w-3 text-neutral-400`)),i=R(`fieldset`,`grid grid-cols-2 gap-1 rounded-xl bg-neutral-50 p-1`);i.append(R(`legend`,`sr-only`,`Reasoning effort`));let s=`reasoning-${++qu}`;for(let e of r){let n=document.createElement(`input`);n.type=`radio`,n.name=s,n.value=e,n.checked=e===o,n.className=`peer sr-only`,n.onchange=()=>{n.checked&&(o=e,t.textContent=Ce(o),p(u.value),a(o))},i.append(R(`label`,`relative cursor-pointer`,n,R(`span`,`flex min-h-11 items-center rounded-lg border border-transparent px-3 text-sm text-neutral-700 hover:bg-neutral-100 peer-checked:border-indigo-200 peer-checked:bg-indigo-50 peer-checked:font-semibold peer-checked:text-indigo-700 peer-focus-visible:outline-2 peer-focus-visible:outline-indigo-500`,Ce(e))))}e.append(n,i),l.append(e)}let d=R(`div`,`max-h-72 overflow-y-auto py-1`),ee=new Map(e.map(e=>[Ju(e),e])),f=e=>{let n=(Yu??[]).map(e=>({e,model:ee.get(Ju(e))})).filter(t=>!!t.model&&(!e||Ju(t.model).toLowerCase().includes(e)));n.length&&d.append(R(`div`,`px-3 pb-0.5 pt-1 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,`Pinned`),...n.map(({e,model:n})=>Zu({label:n.id,hint:Ce(e.thinking),title:e.note,checked:!!t&&Ju(t)===Ju(n)&&o===e.thinking,onSelect:()=>i(n,e.thinking)})),R(`div`,`my-1 border-t border-neutral-100`))},p=n=>{d.replaceChildren();let r=n.trim().toLowerCase();f(r);let a=new Map;for(let t of e){if(r&&!Ju(t).toLowerCase().includes(r))continue;let e=a.get(t.provider);e?e.push(t):a.set(t.provider,[t])}if(!a.size){d.append(R(`div`,`px-3 py-2 text-[12.5px] text-neutral-400`,e.length?`No matching models.`:`No models available.`));return}for(let[e,n]of a){let a=n.some(e=>!!t&&Ju(t)===Ju(e)),o=document.createElement(`details`);o.open=a||r.length>0;let s=R(`summary`,`flex cursor-pointer select-none items-center gap-1.5 px-3 py-1 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400 hover:bg-neutral-100`,h(c,`chev h-3 w-3`),R(`span`,`truncate`,e),R(`span`,`ml-auto flex-none normal-case text-neutral-300`,String(n.length)));o.append(s,...n.map(e=>Zu({label:e.id,checked:!!t&&Ju(t)===Ju(e),onSelect:()=>i(e)}))),d.append(o)}};return u.oninput=()=>p(u.value),p(``),Xu().then(e=>{let t=JSON.stringify(e)!==JSON.stringify(Yu);Yu=e,t&&p(u.value)}).catch(e=>Ds(`model menu unavailable`,e)),s.append(l,d),queueMicrotask(()=>u.focus()),s}function $u(e,t,n,r){let i=Zr(t.model?`${t.model.id}${t.thinking?` · ${Ce(t.thinking)}`:``}`:t.thinking?`Pi default · ${Ce(t.thinking)}`:`Pi default`,`${oi} flex cursor-pointer items-center gap-1.5 truncate text-left hover:bg-neutral-50 ${t.model?`text-neutral-700`:`text-neutral-400`}`);return i.title=t.model?`${t.model.provider}/${t.model.id}`:`Whatever the project and Pi pick`,i.onclick=()=>{let e=Qu({models:n,current:t.model,thinkingLevel:t.thinking??`medium`,thinkingLevels:[...Ta],onPick:(e,n)=>{K(),r({model:e,thinking:n??t.thinking})},onThinkingPick:e=>{t={...t,thinking:e},r(t)}}),a=Zr(`Pi default`,`w-full cursor-pointer px-3 py-1.5 text-left text-[12.5px] text-neutral-500 hover:bg-neutral-100`);a.onclick=()=>{K(),r({model:null,thinking:null})};let o=R(`div`,`flex flex-col`);o.append(e,R(`div`,`border-t border-neutral-200`),a),ul(i,o)},ai(e,i)}var Y;function ed(e){Y=e,Ks(td,()=>{Y.currentSession()&&(K(),Y.toggleFiles())},Rs)}var td=`i`,nd=L(`#chat-title`),rd=L(`#chat-menu`),id=L(`#session-meta`),ad=null,od=new Map,sd=e=>`${e.provider}/${e.id}`,X=null,cd=null,ld=null,ud=null;function dd(){X=null,cd=null,ld=null,ud=null,bd()}function fd(e,t,n,r){X=e,cd=t,ld=n,ud=r,gd()}function pd(e){ud=e.completedAt,cd&&={...cd,tokens:e.tokens},bd()}var md=null;function hd(e){md=e===null?null:Vr(e),gd()}function gd(){let e=Y.currentSession();e&&(md=null),nd.textContent=e?e.title??Vr(e.cwd):md??Y.currentId()??`no session`,nd.classList.toggle(`cursor-pointer`,!!e),nd.title=e?`Session info`:``,nd.onclick=e?()=>xd(nd,e):null,rd.classList.toggle(`hidden`,!e),e&&(rd.onclick=()=>Ed(rd,e)),bd(),Y.syncBar()}var _d=70,vd=(e,t)=>Math.min(100,Math.round(e/t.contextWindow*100)),yd=e=>e.tokens===null?`?/${we(e.contextWindow)}`:`${we(e.tokens)}/${we(e.contextWindow)} · ${100-vd(e.tokens,e)}% left`;function bd(){let e=cd,t=e?.tokens??null,n=Y.currentId(),r=[];if(!n&&md&&r.push(R(`span`,`flex flex-none items-center gap-1.5 text-neutral-500`,h(ie,`spinner`),`starting…`)),n){let e=(e,t)=>{let r=R(`button`,`flex-none cursor-pointer font-mono ${t}`,e);return r.title=`Change model or reasoning`,r.onclick=()=>void Sd(r,n),r};X&&r.push(e(X.id,`rounded bg-indigo-50 px-1.5 py-px font-medium text-indigo-700 hover:bg-indigo-100`)),ld&&r.push(e(ld,`text-neutral-500 hover:text-indigo-700`))}let i=0;if(e&&t!==null){i=vd(t,e);let n=i>=90?`text-red-700`:i>=_d?`text-amber-700`:`text-neutral-500`;r.push(R(`span`,`flex-none font-mono ${n}`,we(t).toLowerCase()))}let a=r.flatMap((e,t)=>t===0?[e]:[R(`span`,`text-neutral-300`,`·`),e]);id.replaceChildren(...a),id.classList.toggle(`hidden`,r.length===0),id.classList.toggle(`flex`,r.length>0),id.toggleAttribute(`data-urgent`,!n&&!!md||i>=_d)}function xd(e,t,n=!1){let i=[[`Directory`,t.cwd],[`Session`,t.id]],a=t.id===Y.currentId();if(a&&(i.push([`Model`,X?.id??`—`]),i.push([`Reasoning`,ld??`—`]),i.push([`Context`,cd?yd(cd):`—`])),i.push([`Created`,Hr(t.createdAt),zr(t.createdAt)]),a){let e=ud;i.push(e===null?[`Last reply`,`—`]:[`Last reply`,Hr(e),zr(e)])}let o=R(`div`,`w-[min(26rem,calc(100vw-2rem))] max-sm:w-full rounded-xl bg-white px-3 py-3 font-sans text-[15px] leading-normal`),s=R(`button`,`icon-btn h-11 w-11 sm:h-8 sm:w-8`,h(ye));s.setAttribute(`aria-label`,`Close session info`),s.onclick=K;let c=R(`div`,`sticky top-0 z-10 flex items-start gap-2 bg-white pb-2`,R(`div`,`min-w-0 flex-1`,R(`div`,`text-sm font-medium text-neutral-500`,`Session info`),R(`h2`,`mt-1 [overflow-wrap:anywhere] text-lg leading-7 font-semibold text-neutral-900`,t.title??Vr(t.cwd))),s);if(n){let n=R(`button`,`icon-btn h-11 w-11 sm:h-8 sm:w-8`,h(r));n.setAttribute(`aria-label`,`Back to session actions`),n.onclick=()=>Ed(e,t),c.prepend(n)}o.append(c);let l=R(`dl`,``);for(let[e,t,n]of i){let r=e===`Directory`||e===`Session`,i=R(`dd`,`min-w-0 flex items-start gap-2 text-neutral-700 ${r?`font-mono text-sm leading-6`:``}`,R(`span`,`min-w-0 flex-1 [overflow-wrap:anywhere]`,t));if(r){let n=Jr(`min-h-11 min-w-11 sm:min-h-8 shrink-0 cursor-pointer rounded-lg px-2 py-1 text-[13px] font-sans text-neutral-500 hover:bg-neutral-100 focus-visible:outline-2`,()=>t);n.setAttribute(`aria-label`,`Copy ${e.toLowerCase()}`),i.append(n)}n&&i.firstElementChild?.append(R(`span`,`ml-2 inline-block font-sans text-[13px] leading-5 text-neutral-500`,n));let a=e===`Model`||e===`Created`;l.append(R(`div`,`grid gap-1 py-1.5 sm:grid-cols-[5.5rem_minmax(0,1fr)] sm:gap-3 ${a?`mt-2 border-t border-neutral-200 pt-2.5`:``}`,R(`dt`,`text-[15px] text-neutral-500`,e===`Session`?`Session ID`:e),i))}o.append(l),ul(e,o)}async function Sd(e,t,n){let i=R(`div`,`px-3 py-3 text-[15px] text-neutral-500`,`Loading models…`),a=R(`div`,`w-[min(24rem,calc(100vw-2rem))] min-w-0 max-sm:w-full`,i),o=i;if(n){let t=R(`button`,`icon-btn h-11 w-11`,h(r));t.setAttribute(`aria-label`,`Back to session actions`),t.onclick=()=>Ed(e,n);let i=R(`button`,`icon-btn h-11 w-11`,h(ye));i.setAttribute(`aria-label`,`Close model picker`),i.onclick=K;let o=R(`span`,`min-w-0 flex-1 truncate text-sm font-medium`,n.title??Vr(n.cwd));o.title=o.textContent??``,a.prepend(R(`div`,`flex items-center gap-2 border-b border-neutral-200 pb-2 mb-2`,t,o,i))}ul(e,a);let s=()=>o.isConnected&&!o.closest(`[inert]`),c=``,l=(n,r,i)=>{let s=JSON.stringify([n,r,i]);if(s===c)return;c=s;let l=Qu({models:n,current:t===Y.currentId()?X:null,thinkingLevel:r,thinkingLevels:i,onPick:(e,n)=>{K(),Cd(t,e,n)},onThinkingPick:e=>void Td(t,e)});o.replaceWith(l),o=l,ul(e,a)},u=t===Y.currentId()&&X?od.get(sd(X)):void 0;ad&&u&&ld&&l(ad,ld,u);try{let[e,n]=await Promise.all([ze(`/api/sessions/${t}/models`,`Could not load models`),ze(`/api/sessions/${t}/thinking`,`Could not read the reasoning level`)]);if(ad=e,t===Y.currentId()&&X&&od.set(sd(X),n.levels),!s())return;l(e,n.level,n.levels)}catch(e){c?V(`error`,`model options are stale: ${String(e)}`):s()?(i.textContent=`Could not load models: ${String(e)}`,i.setAttribute(`role`,`alert`)):V(`error`,`model options failed: ${String(e)}`)}}async function Cd(e,t,n){await wd(e,t)&&n&&await Td(e,n)}async function wd(e,t){let n=X;e===Y.currentId()&&(X=t,gd());let r=await y(`/api/sessions/${e}/model`,t);if(!r.ok){let{error:t}=await r.json().catch(()=>({}));return e===Y.currentId()&&(X=n,gd()),V(`error`,`model change failed: ${t??r.status}`),!1}let{model:i}=await r.json();return e===Y.currentId()&&i&&(X=i,gd()),!0}async function Td(e,t){let n=await y(`/api/sessions/${e}/thinking`,{level:t});if(!n.ok){V(`error`,`reasoning change failed: ${n.status}`);return}let{level:r}=await n.json();e===Y.currentId()&&(ld=r,bd())}function Ed(e,t){let n=t.id===Y.currentId();fl(e,[{label:`Rename…`,onSelect:()=>{K(),iu(t)}},{label:`Session info`,onSelect:()=>xd(e,t,!0)},{label:`New session here`,separatorBefore:!0,hint:Br(t.cwd),onSelect:()=>{K(),Y.createSession(t.cwd)}},{label:`Browse files`,hint:n?Ls(td):``,onSelect:()=>{K(),Y.openFiles(n?void 0:t.cwd)}},{label:`Model & reasoning…`,separatorBefore:!0,hint:n?X?.id??`…`:``,onSelect:()=>void Sd(e,t.id,t)}],t.title??Vr(t.cwd))}var Dd=`pier.theme`,Od=[`system`,`light`,`dark`],kd=window.matchMedia(`(prefers-color-scheme: dark)`),Ad={system:ce,light:_e,dark:le},jd=()=>{let e=null;try{e=localStorage.getItem(Dd)}catch{return`system`}return e===`light`||e===`dark`?e:`system`},Md=()=>{let e=jd();return e===`system`?kd.matches?`dark`:`light`:e};function Nd(){let e=Md();document.documentElement.dataset.theme=e;let t=getComputedStyle(document.documentElement).getPropertyValue(`--workbench-canvas`).trim();L(`meta[name="theme-color"]`).setAttribute(`content`,t),window.dispatchEvent(new Event(`pier:theme`))}function Pd(){let e=L(`#theme-toggle`),t=()=>{let t=jd();e.title=`Theme: ${t}${t===`system`?` (${Md()})`:``}`,e.replaceChildren(h(Ad[t])),e.setAttribute(`aria-label`,e.title),Nd()};e.onclick=()=>{let e=Od[(Od.indexOf(jd())+1)%Od.length];try{e===`system`?localStorage.removeItem(Dd):localStorage.setItem(Dd,e)}catch{}t()},kd.addEventListener(`change`,t),t()}var Fd=`https://github.com/timqi/pier`,Id=[`text-neutral-400`,`hover:text-neutral-700`],Ld=[`rounded-full`,`bg-emerald-50`,`px-1.5`,`text-emerald-700`,`ring-1`,`ring-inset`,`ring-emerald-600/20`,`hover:bg-emerald-100`],Rd=18e5,Z=null,zd=L(`#version`);function Bd(e){let t=Z?.available===!0&&Z.latest!==null;zd.textContent=`v${e}`,zd.title=t?`Pier ${Z?.latest} is out`:``,zd.classList.remove(...t?Id:Ld),zd.classList.add(...t?Ld:Id)}var Vd=e=>R(`p`,`px-3 py-1 text-[12px] leading-snug text-neutral-500`,e);function Hd(){let e=R(`div`,`flex w-72 flex-col gap-1 py-1`);if(!Z)return e.append(Vd(`Checking the registry…`)),e;let{current:t,latest:n,available:r,canApply:i,problem:a}=Z;e.append(R(`p`,`px-3 py-1 text-[12.5px] font-medium text-neutral-700`,r?`Pier ${n} is out`:`Pier ${t}`)),e.append(Vd(r?`You are running ${t}.`:n===null?`The registry could not be reached, so this may not be the latest.`:`This is the latest release.`));let o=R(`span`,`px-3 text-[11.5px] text-neutral-400`,``),s=R(`div`,`flex items-center gap-2 px-3 py-1.5`);if(a&&e.append(R(`p`,`mx-3 my-1 rounded-md bg-red-50 px-2 py-1.5 text-[11.5px] leading-snug text-red-700`,a)),r&&i&&!a){let e=Xr(`Update now`,!0);e.onclick=()=>{e.disabled=!0,o.className=`px-3 text-[11.5px] text-neutral-400`,o.textContent=`starting the updater…`,(async()=>{let t=await y(`/api/update`,{});if(!t.ok){e.disabled=!1,o.className=`px-3 text-[11.5px] text-red-600`,o.textContent=await b(t,`Could not update`);return}let{draining:n}=await t.json();o.textContent=n?`Waiting for running work to finish — Pier then installs and restarts.`:`Installing — Pier restarts once it is on disk, and this page reconnects on its own.`})()},s.append(e)}let c=R(`a`,`btn text-[12.5px] no-underline`,`Source`);c.href=r?`${Fd}/releases`:Fd,c.target=`_blank`,c.rel=`noreferrer`,c.title=`Pier is free software (AGPL-3.0)`,s.append(c),e.append(s,o),r&&!i&&!a&&e.append(Vd(`No service manager owns this Pier, so it cannot restart itself — update it with: pier update`));let l=di(`Update automatically`,i?`Installs a new release once nothing is running — no turn in flight, no task run.`:`Needs the systemd service (pier service install); nothing here can restart Pier.`,Z.autoUpdate,e=>{Z&&(Z.autoUpdate=e),(async()=>{let t=await y(`/api/settings`,{autoUpdate:e},`PUT`);if(t.ok)return;Z&&(Z.autoUpdate=!e);let n=l.querySelector(`input`);n&&(n.checked=!e),o.className=`px-3 text-[11.5px] text-red-600`,o.textContent=await b(t,`Could not save`)})()});if(!i){let e=l.querySelector(`input`);e&&(e.disabled=!0)}return e.append(R(`div`,`mt-1 border-t border-neutral-200 px-3 pb-1 pt-2`,l)),e}async function Ud(e){let t=await Re(`/api/update`,`Update check failed`);t.ok&&(Z=t.value,Bd(Z.current||e))}function Wd(e){Bd(e),zd.onclick=e=>{e.preventDefault(),ul(zd,Hd())};let t=()=>void Ud(e).catch(()=>{});t(),setInterval(t,Rd)}var Q,Gd=L(`#chat-header`),Kd=L(`#chat-title`),qd=[Gd,B,L(`#composer`)],Jd=()=>tf===null,Yd,Xd,Zd,Qd=new Map,$d=new Map,ef=new Map,tf=null,nf=0,rf=[`files`],af=new Map,of={tasks:`Tasks`,runs:`Runs`,activity:`Activity`,boards:`Boards`,settings:`Settings`,files:`Files`},sf=[`tasks`,`runs`,`activity`],cf=`Automation`,lf=L(`#automation-view`),uf=L(`#automation-tabs`),df=e=>sf.includes(e)?`tasks`:e;function ff(e,t){let n=e!==null&&sf.includes(e);if(lf.classList.toggle(`hidden`,!n),lf.classList.toggle(`flex`,n),!n)return;let r=[];if(e===`tasks`&&!t){let e=Xr(`New task`,!0);e.classList.add(`ml-auto`),e.disabled=!Yd,e.onclick=()=>Yd?.create(),r.push(e)}uf.replaceChildren(Qr(cf),...sf.map(t=>ti(of[t],t===e,()=>_f(t))),...r)}var pf=e=>Yd?.refresh(e),mf=()=>Xd?.refresh(),hf=()=>Zd?.refresh();function gf(){tf?kl(sf.includes(tf)?cf:of[tf],!1):kl(Kd.textContent??``,Q.currentSession()!==void 0)}function _f(e,t,n){if(rf.includes(e)){let t=kf();t&&(t.kind!==`console`||t.name!==e)&&af.set(e,t)}jf({kind:`console`,name:e,arg:t,query:n}),Ol(),tf=e;for(let e of qd)e.classList.add(`hidden`);gc();for(let[t,n]of Qd)t!==e&&n.hide();for(let[t,n]of ef)n.classList.toggle(`bg-indigo-50`,t===df(e));ff(e,t),gf(),vf(e,t,n,++nf)}async function vf(e,t,n,r){let i=Qd.get(e);if(!i){let t=$d.get(e);if(!t){let n=L(`#${e}-view`);t=Pf[e](n).catch(t=>(console.warn(`${e} view failed to load`,t),Wr(n,()=>n.replaceChildren(R(`p`,`p-4 text-[13px] text-red-600`,`Could not load ${of[e]} — reload the page.`))))),$d.set(e,t)}i=await t,Qd.set(e,i),$d.delete(e)}tf===e&&r===nf&&(i.show(t,n),e===`tasks`&&ff(e,t))}var yf=e=>_f(`tasks`,e),bf=(e={},t)=>_f(`runs`,t,new URLSearchParams(e).toString()),xf=e=>bf({},e),Sf=e=>_f(`files`,e),Cf=(e,t)=>{tf===e?Tf(e):_f(e,t)},wf=e=>Cf(`files`,e);function Tf(e){let t=Q.currentId(),n=af.get(e)??(t?{kind:`session`,id:t}:null);af.delete(e),n?jf(n):(history.replaceState(null,``,`#/`),Ef())}function Ef(){if(tf){tf=null;for(let e of Qd.values())e.hide();for(let e of ef.values())e.classList.remove(`bg-indigo-50`);ff(null);for(let e of qd)e.classList.remove(`hidden`);gc(),gf(),Q.maybeAckRead()}}var Df=e=>e.kind===`session`?`#/session/${encodeURIComponent(e.id)}`:`#/${e.name}${e.arg?`/${encodeURIComponent(e.arg)}`:``}${e.query?`?${e.query}`:``}`,Of={config:`files`,channels:`channels`,providers:`models`};function kf(){let e=location.hash.replace(/^#\/?/,``),t=e.indexOf(`?`),[n=``,r]=(t<0?e:e.slice(0,t)).split(`/`),i=t<0?void 0:e.slice(t+1)||void 0,a;try{a=r?decodeURIComponent(r):void 0}catch{return null}return Of[n]?{kind:`console`,name:`settings`,arg:Of[n]}:Object.hasOwn(of,n)?{kind:`console`,name:n,arg:a,query:i}:n===`session`&&a?{kind:`session`,id:a}:null}var Af=!1;function jf(e,t=!1){if(Af)return;let n=Df(e);location.hash!==n&&(t?history.replaceState(null,``,n):location.hash=n)}var Mf=e=>jf({kind:`session`,id:e});function Nf(){let e=kf(),t=Q.sessions(),n=Q.currentId(),r=e?.kind===`session`?e.id:null,{top:i,rest:a}=Yl(t),o=r??n??(i[0]??a[0])?.id??null;Af=!0;try{o&&o!==n&&Q.select(o),e?.kind===`console`?_f(e.name,e.arg,e.query):Ef(),o||gd()}finally{Af=!1}e?.kind!==`console`&&o&&jf({kind:`session`,id:o},!0)}var Pf={tasks:async e=>Yd=(await Di(async()=>{let{createTasksView:e}=await import(`./tasks-bcb3fYdK.js`);return{createTasksView:e}},__vite__mapDeps([0,1]))).createTasksView(e,()=>Q.sessions().map(({id:e,cwd:t,title:n})=>({id:e,cwd:t,title:n})),Q.loadSessions,Q.select,()=>Q.currentId(),bf,yf),runs:async e=>Xd=(await Di(async()=>{let{createRunsView:e}=await import(`./runs-BLJu7EXN.js`);return{createRunsView:e}},__vite__mapDeps([2,1]))).createRunsView(e,Q.select,bf,yf),activity:async e=>Zd=(await Di(async()=>{let{createActivityView:e}=await import(`./activity-Bl3vZukb.js`);return{createActivityView:e}},[])).createActivityView(e,Q.select,xf),boards:async e=>(await Di(async()=>{let{createBoardsView:e}=await import(`./boards-DYuf4Mlj.js`);return{createBoardsView:e}},[])).createBoardsView(e,Q.select),files:async e=>(await Di(async()=>{let{createExplorerView:e}=await import(`./explorer-qJH_9nTE.js`);return{createExplorerView:e}},[])).createExplorerView(e,()=>Q.currentSession(),e=>_f(`files`,e),()=>Tf(`files`)),settings:async e=>(await Di(async()=>{let{createSettingsView:e}=await import(`./settings-BrdVh-Zi.js`);return{createSettingsView:e}},[])).createSettingsView(e,()=>$l(Q.sessions()),e=>_f(`settings`,e))};function Ff(e){Q=e;for(let e of[`tasks`,`boards`,`settings`]){let t=L(`#open-${e}`);ef.set(e,t),t.onclick=()=>_f(e)}let t=L(`#console-section`);t.open=localStorage.getItem(`pier.consoleCollapsed`)!==`1`,t.ontoggle=()=>localStorage.setItem(`pier.consoleCollapsed`,t.open?`0`:`1`),window.onhashchange=Nf}var If=[],Lf=0,Rf=0,zf=!1,$=null,Bf=`idle`,Vf=null,Hf=0,Uf=!1,Wf=!1;async function Gf(e){let t=++Lf;++Rf,zf=!1,Ef(),Ol(),$=null,Vf?.close(),Vf=null,vs(),_c([]),dd(),hd(e),ys(!0),Wf=!0,hc();let n=await y(`/api/sessions`,{cwd:e});if(t!==Lf)return;if(Wf=!1,!n.ok){ys(!1),hd(null),hc(),V(`error`,`session create failed: ${n.status}`);return}let{id:r}=await n.json();t===Lf&&(If.unshift({id:r,cwd:e,createdAt:Date.now(),state:`idle`,unread:!1,channel:`web`,activeRuns:0}),await tp(r),$===r&&dc())}function Kf(e){If=e.map(e=>({...e,title:Ie(e.title)})),If.sort((e,t)=>t.createdAt-e.createdAt),du(),Jf()}var qf=Le(async()=>{Kf(await ze(`/api/sessions`,`Could not load sessions`))});function Jf(){if(document.hidden||!document.hasFocus()||!Jd())return;let e=If.find(e=>e.id===$);e?.unread&&(e.unread=!1,du(),fetch(`/api/sessions/${e.id}/read`,{method:`POST`}))}function Yf(){return If.find(e=>e.id===$)}function Xf(e,t){let n=If.find(t=>t.id===e);!n||n.title||!t.trim()||(n.title=t.trim().slice(0,80),du(),gd())}function Zf(e){Bf=e;let t=If.find(e=>e.id===$);t&&(t.state=e),du(),gd(),hc(),e===`idle`&&qf()}function Qf(e){if(!(e.sessionId!==$||e.seq<=Hf))switch(Hf=e.seq,e.type){case`turn-start`:Uf=!0;break;case`system-input`:ms(),Bo(e.text,e.origin);break;case`task-status`:Ba(e.run);break;case`user-message`:{let t=Ne(e.text).text;if(Xf(e.sessionId,t),fc(t))break;ms(),V(`user`,e.text,!1,e.ts),Oo();break}case`text-start`:ms();break;case`text-delta`:ps(e.text);break;case`thinking-delta`:ms(),ho(e.ts,e.text);break;case`tool-start`:ms(),po(e.ts,e.toolCallId,e.toolName,e.args);break;case`tool-end`:mo(e.toolCallId,e.isError,e.output);break;case`turn-end`:Uf=!1,gs(e.text,e.meta),e.meta&&pd(e.meta);break;case`queue-state`:vc(e.steering,e.followUp);break;case`queue-recovery`:_c(e.batches,e.uncertain);break;case`context-compacted`:ms(),V(`system`,`Context compacted — ${we(e.before)} → ${we(e.after)}`,!1,e.ts),Oo();break;case`error`:uo(),V(`error`,e.message);break;case`state`:e.state===`idle`&&Uf&&(Uf=!1,_s()),e.state===`idle`&&vc([],[]),Zf(e.state)}}function $f(){let e=new EventSource(`/api/events`);e.onopen=()=>void qf(),e.onerror=()=>Ms(e,`Workspace`),e.onmessage=e=>{let t=JSON.parse(e.data);if(t.type===`sessions-changed`){qf();return}if(t.type===`tasks-changed`||t.type===`task-run-changed`||t.type===`task-message-changed`||t.type===`task-group-changed`){pf(t.type===`task-run-changed`?t.taskId:void 0),mf(),hf(),t.type===`task-run-changed`&&qf();return}if(hf(),t.sessionId===$)return;let n=If.find(e=>e.id===t.sessionId);n&&(n.state=t.state,du())}}function ep(e,t,n){Vf?.close();let r=new EventSource(`/api/sessions/${e}/events?after=${t}`),i=()=>Vf===r&&$===e&&n===Rf;r.onmessage=e=>{i()&&Qf(JSON.parse(e.data))},r.addEventListener(`reset`,()=>{i()&&np(e)}),r.onerror=()=>{i()&&Ms(r,`Session`)},Vf=r}async function tp(e){Ef(),Ol(),Mf(e),!(e===$&&(Vf||zf))&&(++Lf,++Rf,Wf=!1,Tc(),$=e,Bf=If.find(t=>t.id===e)?.state??`idle`,Ec(e),du(),gd(),Jf(),await np(e))}async function np(e){if($!==e)return;let t=++Rf;Vf?.close(),Vf=null,zf=!0,vs(),vc([],[]),_c([]),dd(),Uf=!1,mc(),Hf=0,ys(!0);let n=await Re(`/api/sessions/${e}/history`,`failed to load session`);if($!==e||t!==Rf)return;if(zf=!1,!n.ok){ys(!1),V(`error`,n.error);return}let r=n.value;bs(r.turns,r.state,r.backgroundRuns),Hf=r.lastSeq,Uf=r.state===`streaming`,Zf(r.state),vc(r.queue.steering,r.queue.followUp),_c(r.queueRecovery,r.queueUncertain);let i=r.turns.reduce((e,t)=>t.meta?.completedAt??e,null);fd(r.model,r.context,r.thinkingLevel,i),ep(e,`${r.epoch}:${r.lastSeq}`,t)}Os(),be(),js(),Pd();var rp=async e=>{$===e&&await np(e)};xo({sessionId:()=>$,sessionState:()=>Bf,select:e=>void tp(e),showRun:xf,send:(e,t)=>void kc(e,t),ownTurn:e=>{pc(e),Zf(`streaming`)},reload:rp}),Mc({sessionId:()=>$,starting:()=>Wf,sessionState:()=>Bf,chatVisible:Jd,setState:Zf,reload:rp}),Gl({sessionMenu:e=>{let t=Yf();t&&Ed(e,t)},sessionInfo:e=>{let t=Yf();t&&xd(e,t)}}),pu({sessions:()=>If,currentId:()=>$,select:e=>void tp(e),sessionMenu:Ed,createSession:Gf,onTitleChanged:gd}),Ku({sessions:()=>If,loadSessions:qf,currentId:()=>$,select:tp,createSession:Gf,openConsole:_f}),ed({currentId:()=>$,currentSession:Yf,createSession:e=>void Gf(e),syncBar:gf,openFiles:Sf,toggleFiles:wf}),Ff({sessions:()=>If,loadSessions:qf,currentId:()=>$,currentSession:Yf,select:e=>void tp(e),maybeAckRead:Jf}),Wd(`0.1.0`),qc(),document.addEventListener(`gesturestart`,e=>e.preventDefault()),document.addEventListener(`visibilitychange`,Jf),window.addEventListener(`focus`,Jf),$f(),qf().then(Nf);export{h as $,pi as A,Yr as B,ai as C,ti as D,Qr as E,_i as F,Le as G,R as H,zr as I,ze as J,b as K,Br as L,ui as M,di as N,ei as O,$r as P,Ce as Q,Wr as R,hi as S,ci as T,Rr as U,Ur as V,Vr as W,y as X,Be as Y,Ie as Z,fi as _,K as a,Xr as b,Gs as c,Li as d,ye as et,Ii as f,ri as g,ni as h,bl as i,a as it,si as j,li as k,Ta as l,oi as m,Qu as n,ie as nt,ul as o,Ni as p,Re as q,Cl as r,c as rt,Qc as s,$u as t,de as tt,Ea as u,mi as v,gi as w,ii as x,Zr as y,Jr as z};
|
|
Binary file
|
|
Binary file
|