@timqi/pier 0.1.11 → 0.1.13

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.
Files changed (60) hide show
  1. package/dist/boards/pier.css +37 -22
  2. package/dist/channels/config.js +24 -2
  3. package/dist/channels/routes.js +13 -1
  4. package/dist/main.js +1 -1
  5. package/dist/web/public/assets/{activity-dxSOEHmf.js → activity-DjZb4ZV0.js} +2 -2
  6. package/dist/web/public/assets/activity-DjZb4ZV0.js.br +0 -0
  7. package/dist/web/public/assets/activity-DjZb4ZV0.js.gz +0 -0
  8. package/dist/web/public/assets/boards-C3wVfF2L.js +1 -0
  9. package/dist/web/public/assets/boards-C3wVfF2L.js.br +0 -0
  10. package/dist/web/public/assets/boards-C3wVfF2L.js.gz +0 -0
  11. package/dist/web/public/assets/explorer-Dv6dIcpa.js +4 -0
  12. package/dist/web/public/assets/explorer-Dv6dIcpa.js.br +0 -0
  13. package/dist/web/public/assets/explorer-Dv6dIcpa.js.gz +0 -0
  14. package/dist/web/public/assets/index-BypxFfJa.js +85 -0
  15. package/dist/web/public/assets/index-BypxFfJa.js.br +0 -0
  16. package/dist/web/public/assets/index-BypxFfJa.js.gz +0 -0
  17. package/dist/web/public/assets/index-DiHj0w1i.css +2 -0
  18. package/dist/web/public/assets/index-DiHj0w1i.css.br +0 -0
  19. package/dist/web/public/assets/index-DiHj0w1i.css.gz +0 -0
  20. package/dist/web/public/assets/{runs-DtvDXSfo.js → runs-CG0zz7Gm.js} +1 -1
  21. package/dist/web/public/assets/runs-CG0zz7Gm.js.br +0 -0
  22. package/dist/web/public/assets/runs-CG0zz7Gm.js.gz +0 -0
  23. package/dist/web/public/assets/settings-DmRxpIWY.js +5 -0
  24. package/dist/web/public/assets/settings-DmRxpIWY.js.br +0 -0
  25. package/dist/web/public/assets/settings-DmRxpIWY.js.gz +0 -0
  26. package/dist/web/public/assets/{task-runs-DcORJXHU.js → task-runs-BjD8rJs0.js} +2 -2
  27. package/dist/web/public/assets/task-runs-BjD8rJs0.js.br +0 -0
  28. package/dist/web/public/assets/task-runs-BjD8rJs0.js.gz +0 -0
  29. package/dist/web/public/assets/tasks-kIXfyOri.js +4 -0
  30. package/dist/web/public/assets/tasks-kIXfyOri.js.br +0 -0
  31. package/dist/web/public/assets/tasks-kIXfyOri.js.gz +0 -0
  32. package/dist/web/public/index.html +2 -2
  33. package/dist/web/public/index.html.br +0 -0
  34. package/dist/web/public/index.html.gz +0 -0
  35. package/package.json +2 -2
  36. package/skills/pier-boards/SKILL.md +89 -124
  37. package/dist/web/public/assets/activity-dxSOEHmf.js.br +0 -0
  38. package/dist/web/public/assets/activity-dxSOEHmf.js.gz +0 -0
  39. package/dist/web/public/assets/boards-BRwn5UZi.js +0 -1
  40. package/dist/web/public/assets/boards-BRwn5UZi.js.br +0 -0
  41. package/dist/web/public/assets/boards-BRwn5UZi.js.gz +0 -0
  42. package/dist/web/public/assets/explorer-CCJQ22Dp.js +0 -4
  43. package/dist/web/public/assets/explorer-CCJQ22Dp.js.br +0 -0
  44. package/dist/web/public/assets/explorer-CCJQ22Dp.js.gz +0 -0
  45. package/dist/web/public/assets/index-CzV2cZEH.js +0 -85
  46. package/dist/web/public/assets/index-CzV2cZEH.js.br +0 -0
  47. package/dist/web/public/assets/index-CzV2cZEH.js.gz +0 -0
  48. package/dist/web/public/assets/index-sQWFDUPu.css +0 -2
  49. package/dist/web/public/assets/index-sQWFDUPu.css.br +0 -0
  50. package/dist/web/public/assets/index-sQWFDUPu.css.gz +0 -0
  51. package/dist/web/public/assets/runs-DtvDXSfo.js.br +0 -0
  52. package/dist/web/public/assets/runs-DtvDXSfo.js.gz +0 -0
  53. package/dist/web/public/assets/settings-CJbHCEZo.js +0 -5
  54. package/dist/web/public/assets/settings-CJbHCEZo.js.br +0 -0
  55. package/dist/web/public/assets/settings-CJbHCEZo.js.gz +0 -0
  56. package/dist/web/public/assets/task-runs-DcORJXHU.js.br +0 -0
  57. package/dist/web/public/assets/task-runs-DcORJXHU.js.gz +0 -0
  58. package/dist/web/public/assets/tasks-8l1M8EJU.js +0 -4
  59. package/dist/web/public/assets/tasks-8l1M8EJU.js.br +0 -0
  60. package/dist/web/public/assets/tasks-8l1M8EJU.js.gz +0 -0
@@ -1,85 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/tasks-8l1M8EJU.js","assets/task-runs-DcORJXHU.js","assets/runs-DtvDXSfo.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:`m5 12 7-7 7 7`}],[`path`,{d:`M12 19V5`}]],o=[[`path`,{d:`M20 6 9 17l-5-5`}]],s=[[`path`,{d:`m6 9 6 6 6-6`}]],c=[[`path`,{d:`m15 18-6-6 6-6`}]],l=[[`path`,{d:`m9 18 6-6-6-6`}]],u=[[`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`}]],d=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 6v6l4 2`}]],f=[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`}],[`path`,{d:`m9 10-5 5 5 5`}]],p=[[`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`}]],m=[[`circle`,{cx:`12`,cy:`12`,r:`1`}],[`circle`,{cx:`19`,cy:`12`,r:`1`}],[`circle`,{cx:`5`,cy:`12`,r:`1`}]],ee=[[`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`}]],h=[[`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`}]],le=[[`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:`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`}]],he=[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}]],ge=[[`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`}]],_e=[[`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`}]],ve=[[`path`,{d:`M18 6 6 18`}],[`path`,{d:`m6 6 12 12`}]],g=(e,t=`h-3.5 w-3.5`)=>n(e,{class:`flex-none ${t}`,"aria-hidden":`true`,focusable:`false`});function ye(){let e={ArrowUp:a,ChevronLeft:c,ChevronRight:l,Clock:d,Ellipsis:m,LayoutDashboard:ne,ListTodo:re,Menu:ae,Plus:de,RotateCw:fe,Search:pe,Settings:me,Square:he,Undo2:_e,X: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(g(n,`h-full w-full`))}let t=g(s);t.setAttribute(`stroke`,`#737373`),document.documentElement.style.setProperty(`--select-chevron`,`url("data:image/svg+xml,${encodeURIComponent(t.outerHTML)}")`)}var be=/[\u201c\u201d"\u2018\u2019'()\uff08\uff09\u300c\u300d\u300e\u300f\u3010\u3011\u300a\u300b\u3008\u3009[\]]/;function xe(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&&be.test(i[0]);)n+=i[0],i=i.slice(1);for(;i.length>1&&be.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 _=e=>!e.text.trim()&&e.suggestions.length===0,Se=e=>e===`xhigh`?`Extra high`:e[0].toUpperCase()+e.slice(1),Ce=e=>{if(e<1e3)return String(e);let t=e/1e3;return t>=9.95?`${Math.round(t)}K`:`${t.toFixed(1)}K`},we=/(?:^|\n)[ \t]*-{3,}[ \t]*\r?\n((?:[ \t]*\[[^\]\r\n]+\][ \t]*(?:[||][ \t]*)?)+)\s*$/,Te=/\[([^\]\r\n]+)\]/g,Ee=5,De=String.raw`[\u200B-\u200D\u2060\uFEFF]*`,Oe=e=>e.split(``).join(De),ke=RegExp(`${Oe(`<silent>`)}([\\s\\S]*?)${Oe(`</silent>`)}`,`gi`),Ae=RegExp(`<(\\/?)${Oe(`silent>`)}`,`gi`);function v(e){let t=[...e.matchAll(ke)].map(e=>(e[1]??``).trim()).filter(Boolean);return t.length?t.join(` · `):void 0}function je(e,t){let n=y(e),r=v(e),i=we.exec(n);if(!i?.[1])return{text:n,suggestions:[],meta:t,silence:r};let a=[...i[1].matchAll(Te)].map(e=>(e[1]??``).trim()).filter(Boolean).slice(0,Ee);return a.length?{text:n.slice(0,i.index).trimEnd(),suggestions:a,meta:t,silence:r}:{text:n,suggestions:[],meta:t,silence:r}}var y=e=>xe(e.replace(ke,``).trim()),Me=/^(?:\s|[-*+>]|\d+[.)])/;function Ne(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&&!(Me.test(s)&&Me.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(Ae))i=!e[1];o=-1,s=n}return a}var Pe=String.raw`(?<when>(?:\d{4}-\d{2}-\d{2} )?\d{1,2}:\d{2})`,Fe=new RegExp(String.raw`^\[(?:(?<name>[^\n[\]<>]*)<(?<id>[^\n[\]<>]+)>)? ?${Pe}? ?(?<where>[a-z]+:[^\s[\]<>]+)?\]\n`),Ie=new RegExp(String.raw`^\[(?<name>[^\n[\]<>]*?) ${Pe}(?: (?<where>[a-z]+))?\]\n`);function Le(e){let t=Fe.exec(e),{id:n,when:r,where:i}=t?.groups??{},a=n||r||i?t:Ie.exec(e);return a?.groups?{...a.groups.name?{name:a.groups.name}:{},...a.groups.id?{id:a.groups.id}:{},...a.groups.when?{when:a.groups.when}:{},...a.groups.where?{where:a.groups.where}:{},text:e.slice(a[0].length)}:{text:e}}var Re=/(?:\n\[[^\]\n]*(?:\]\(\s*<?file:\/\/[^\n]*|$))+$/,ze=/^\s*`[^`\n]{40,}`\s+(\S[\s\S]*)$/;function Be(e){if(!e)return e;let{text:t}=Le(e);return t===e?e:t.replace(Re,``).replace(ze,`$1`).replace(/\s+/g,` `).trim()||e}var Ve=e=>[...new Set([...e].sort((e,t)=>t.createdAt-e.createdAt).map(e=>e.cwd))];function He(e){let t=Ve(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))})}function Ue(e){let t,n=!1;return()=>(n=!0,t??=(async()=>{for(;n;)n=!1,await e()})().finally(()=>{t=void 0}))}var We=(e,t)=>({method:t,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),b=(e,t,n=`POST`)=>fetch(e,We(t,n)),Ge=(e,t,n,r=`POST`)=>S(e,n,We(t,r));async function x(e,t){return(await e.json().catch(()=>({}))).error??`${t} (${e.status})`}async function S(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 x(r,t)};try{return{ok:!0,value:await r.json()}}catch(e){return{ok:!1,error:`${t}: ${String(e)}`}}}async function Ke(e,t,n){let r=await S(e,t,n);if(!r.ok)throw Error(r.error);return r.value}async function qe(e,t,n){try{let r=await fetch(e,{method:t});return r.ok?void 0:await x(r,n)}catch(e){return`${n}: ${String(e)}`}}function Je(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 Ye(e){if(Array.isArray(e))return e}function Xe(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 Ze(){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 Qe(e,t){return Ye(e)||Xe(e,t)||$e(e,t)||Ze()}function $e(e,t){if(e){if(typeof e==`string`)return Je(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)?Je(e,t):void 0}}var et=Object.entries,tt=Object.setPrototypeOf,nt=Object.isFrozen,rt=Object.getPrototypeOf,it=Object.getOwnPropertyDescriptor,C=Object.freeze,w=Object.seal,at=Object.create,ot=typeof Reflect<`u`&&Reflect,st=ot.apply,ct=ot.construct;C||=function(e){return e},w||=function(e){return e},st||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},ct||=function(e){return new e(...[...arguments].slice(1))};var lt=D(Array.prototype.forEach),ut=D(Array.prototype.lastIndexOf),dt=D(Array.prototype.pop),ft=D(Array.prototype.push),pt=D(Array.prototype.splice),mt=Array.isArray,ht=D(String.prototype.toLowerCase),gt=D(String.prototype.toString),_t=D(String.prototype.match),vt=D(String.prototype.replace),yt=D(String.prototype.indexOf),bt=D(String.prototype.trim),xt=D(Number.prototype.toString),St=D(Boolean.prototype.toString),Ct=typeof BigInt>`u`?null:D(BigInt.prototype.toString),wt=typeof Symbol>`u`?null:D(Symbol.prototype.toString),T=D(Object.prototype.hasOwnProperty),Tt=D(Object.prototype.toString),E=D(RegExp.prototype.test),Et=Dt(TypeError);function D(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return st(e,t,n)}}function Dt(e){return function(){return ct(e,[...arguments])}}function O(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ht;if(tt&&tt(e,null),!mt(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(nt(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Ot(e){for(let t=0;t<e.length;t++)T(e,t)||(e[t]=null);return e}function k(e){let t=at(null);for(let r of et(e)){var n=Qe(r,2);let i=n[0],a=n[1];T(e,i)&&(t[i]=mt(a)?Ot(a):a&&typeof a==`object`&&a.constructor===Object?k(a):a)}return t}function kt(e){switch(typeof e){case`string`:return e;case`number`:return xt(e);case`boolean`:return St(e);case`bigint`:return Ct?Ct(e):`0`;case`symbol`:return wt?wt(e):`Symbol()`;case`undefined`:return Tt(e);case`function`:case`object`:{if(e===null)return Tt(e);let t=e,n=At(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Tt(e)}return Tt(e)}default:return Tt(e)}}function At(e,t){for(;e!==null;){let n=it(e,t);if(n){if(n.get)return D(n.get);if(typeof n.value==`function`)return D(n.value)}e=rt(e)}function n(){return null}return n}function jt(e){try{return E(e,``),!0}catch{return!1}}var Mt=C(`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(`.`)),Nt=C(`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(`.`)),Pt=C([`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`]),Ft=C([`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`]),It=C(`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(`.`)),Lt=C([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Rt=C([`#text`]),zt=C(`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(`.`)),Bt=C(`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(`.`)),Vt=C(`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(`.`)),Ht=C([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Ut=w(/{{[\w\W]*|^[\w\W]*}}/g),Wt=w(/<%[\w\W]*|^[\w\W]*%>/g),Gt=w(/\${[\w\W]*/g),Kt=w(/^data-[\-\w.\u00B7-\uFFFF]+$/),qt=w(/^aria-[\-\w]+$/),Jt=w(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Yt=w(/^(?:\w+script|data):/i),Xt=w(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Zt=w(/^html$/i),Qt=w(/^[a-z][.\w]*(-[.\w]+)+$/i),$t=w(/<[/\w!]/g),en=w(/<[/\w]/g),tn=w(/<\/no(script|embed|frames)/i),nn=w(/\/>/i),A={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},rn=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],an=C(O({},rn)),on=function(){let e={};return lt(rn,t=>{e[t]=w(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),C(e)}(),sn=function(){return typeof window>`u`?null:window},cn=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}},ln=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},un=function(e,t,n,r){return T(e,t)&&mt(e[t])?O(r.base?k(r.base):{},e[t],r.transform):n},dn=function(e,t,n){let r=T(e,t)?e[t]:void 0;return r&&typeof r==`object`?k(r):n()};function fn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:sn(),t=e=>fn(e);if(t.version=`3.4.14`,t.removed=[],!e||!e.document||e.document.nodeType!==A.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,f=At(d,`cloneNode`),p=At(d,`remove`),m=At(d,`nextSibling`),ee=At(d,`childNodes`),te=At(d,`parentNode`),ne=At(d,`shadowRoot`),re=At(d,`attributes`),ie=o&&o.prototype?At(o.prototype,`nodeType`):null,ae=o&&o.prototype?At(o.prototype,`nodeName`):null,oe=o&&o.prototype?At(o.prototype,`ownerDocument`):null,se=function(e){return ie?ie(e):e.nodeType},ce=function(e){return ae?ae(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let h,le=``,ue,de=!1,fe=0,pe=function(){if(fe>0)throw Et(`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.`)},me=function(e){pe(),fe++;try{return h.createHTML(e)}finally{fe--}},he=function(e){pe(),fe++;try{return h.createScriptURL(e)}finally{fe--}},ge=function(){return de||=(ue=cn(u,i),!0),ue},_e=n,ve=_e.implementation,g=_e.createNodeIterator,ye=_e.createDocumentFragment,be=_e.getElementsByTagName,xe=r.importNode,_=ln();t.isSupported=typeof et==`function`&&typeof te==`function`&&ve&&ve.createHTMLDocument!==void 0;let Se=Ut,Ce=Wt,we=Gt,Te=Kt,Ee=qt,De=Yt,Oe=Xt,ke=Qt,Ae=Jt,v=null,je=O({},[...Mt,...Nt,...Pt,...It,...Rt]),y=null,Me=O({},[...zt,...Bt,...Vt,...Ht]),Ne=Object.seal(at(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}})),Pe=null,Fe=null,Ie=Object.seal(at(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Le=!0,Re=!0,ze=!1,Be=!0,Ve=!1,He=!0,Ue=!1,We=!1,b=null,Ge=null,x=!1,S=!1,Ke=!1,qe=!1,Je=!0,Ye=!1,Xe=`user-content-`,Ze=!0,Qe=!1,$e={},tt=null,nt=O({},`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(`.`)),rt=null,it=O({},[`audio`,`video`,`img`,`source`,`image`,`track`]),ot=null,st=O({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),ct=`http://www.w3.org/1998/Math/MathML`,xt=`http://www.w3.org/2000/svg`,St=`http://www.w3.org/1999/xhtml`,Ct=St,wt=!1,Tt=null,D=O({},[ct,xt,St],gt),Dt=C([`mi`,`mo`,`mn`,`ms`,`mtext`]),Ot=O({},Dt),rn=C([`annotation-xml`]),pn=O({},rn),mn=O({},[`title`,`style`,`font`,`a`,`script`]),hn=null,gn=[`application/xhtml+xml`,`text/html`],j=null,_n=null,M=n.createElement(`form`),vn=function(e){return e instanceof RegExp||e instanceof Function},N=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(_n&&_n===e)return;(!e||typeof e!=`object`)&&(e={}),e=k(e),hn=gn.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,j=hn===`application/xhtml+xml`?gt:ht,v=un(e,`ALLOWED_TAGS`,je,{transform:j}),y=un(e,`ALLOWED_ATTR`,Me,{transform:j}),Tt=un(e,`ALLOWED_NAMESPACES`,D,{transform:gt}),ot=un(e,`ADD_URI_SAFE_ATTR`,st,{transform:j,base:st}),rt=un(e,`ADD_DATA_URI_TAGS`,it,{transform:j,base:it}),tt=un(e,`FORBID_CONTENTS`,nt,{transform:j}),Pe=un(e,`FORBID_TAGS`,k({}),{transform:j}),Fe=un(e,`FORBID_ATTR`,k({}),{transform:j}),$e=T(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?k(e.USE_PROFILES):e.USE_PROFILES:!1,Le=e.ALLOW_ARIA_ATTR!==!1,Re=e.ALLOW_DATA_ATTR!==!1,ze=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Be=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ve=e.SAFE_FOR_TEMPLATES||!1,He=e.SAFE_FOR_XML!==!1,Ue=e.WHOLE_DOCUMENT||!1,S=e.RETURN_DOM||!1,Ke=e.RETURN_DOM_FRAGMENT||!1,qe=e.RETURN_TRUSTED_TYPE||!1,x=e.FORCE_BODY||!1,Je=e.SANITIZE_DOM!==!1,Ye=e.SANITIZE_NAMED_PROPS||!1,Ze=e.KEEP_CONTENT!==!1,Qe=e.IN_PLACE||!1,Ae=jt(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Jt,Ct=typeof e.NAMESPACE==`string`?e.NAMESPACE:St,Ot=dn(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>O({},Dt)),pn=dn(e,`HTML_INTEGRATION_POINTS`,()=>O({},rn));let t=dn(e,`CUSTOM_ELEMENT_HANDLING`,()=>at(null));if(Ne=at(null),T(t,`tagNameCheck`)&&vn(t.tagNameCheck)&&(Ne.tagNameCheck=t.tagNameCheck),T(t,`attributeNameCheck`)&&vn(t.attributeNameCheck)&&(Ne.attributeNameCheck=t.attributeNameCheck),T(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(Ne.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),w(Ne),Ve&&(Re=!1),Ke&&(S=!0),$e&&(v=O({},Rt),y=at(null),$e.html===!0&&(O(v,Mt),O(y,zt)),$e.svg===!0&&(O(v,Nt),O(y,Bt),O(y,Ht)),$e.svgFilters===!0&&(O(v,Pt),O(y,Bt),O(y,Ht)),$e.mathMl===!0&&(O(v,It),O(y,Vt),O(y,Ht))),Ie.tagCheck=null,Ie.attributeCheck=null,T(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?Ie.tagCheck=e.ADD_TAGS:mt(e.ADD_TAGS)&&(v===je&&(v=k(v)),O(v,e.ADD_TAGS,j))),T(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?Ie.attributeCheck=e.ADD_ATTR:mt(e.ADD_ATTR)&&(y===Me&&(y=k(y)),O(y,e.ADD_ATTR,j))),T(e,`ADD_FORBID_CONTENTS`)&&mt(e.ADD_FORBID_CONTENTS)&&(tt===nt&&(tt=k(tt)),O(tt,e.ADD_FORBID_CONTENTS,j)),Ze&&(v[`#text`]=!0),Ue&&O(v,[`html`,`head`,`body`]),v.table&&(O(v,[`tbody`]),delete Pe.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Et(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Et(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=h;h=e.TRUSTED_TYPES_POLICY;try{le=me(``)}catch(e){throw h=t,e}}else e.TRUSTED_TYPES_POLICY===null?(h=void 0,le=``):(h===void 0&&(h=ge()),h&&typeof le==`string`&&(le=me(``)));C&&C(e),_n=e},yn=O({},[...Nt,...Pt,...Ft]),bn=O({},[...It,...Lt]),xn=function(e,t,n){return t.namespaceURI===St?e===`svg`:t.namespaceURI===ct?e===`svg`&&(n===`annotation-xml`||Ot[n]):!!yn[e]},Sn=function(e,t,n){return t.namespaceURI===St?e===`math`:t.namespaceURI===xt?e===`math`&&pn[n]:!!bn[e]},Cn=function(e,t,n){return t.namespaceURI===xt&&!pn[n]||t.namespaceURI===ct&&!Ot[n]?!1:!bn[e]&&(mn[e]||!yn[e])},wn=function(e){let t=te(e);(!t||!t.tagName)&&(t={namespaceURI:Ct,tagName:`template`});let n=ht(e.tagName),r=ht(t.tagName);return Tt[e.namespaceURI]?e.namespaceURI===xt?xn(n,t,r):e.namespaceURI===ct?Sn(n,t,r):e.namespaceURI===St?Cn(n,t,r):!!(hn===`application/xhtml+xml`&&Tt[e.namespaceURI]):!1},Tn=function(e){ft(t.removed,{element:e});try{te(e).removeChild(e)}catch{if(p(e),!te(e))throw Et(`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=ee(e);if(t){let e=[];lt(t,t=>{ft(e,t)}),lt(e,e=>{try{p(e)}catch{}})}let n=re(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}ft(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(S||Ke)try{Tn(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},kn=function(e){let t=re(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||y[j(i)]||En(e,r,i)}},An=function(e){let t=[e];for(;t.length>0;){let e=t.pop();se(e)===A.element&&kn(e);let n=ee(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},jn=function(e,t){return He?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Mn=function(e){if(!He)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=se(e);if(n===A.processingInstruction||n===A.comment&&E(en,e.data)){try{p(e)}catch{}continue}if(n===A.element){let t=e,n=j(ce(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&jn(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=ee(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(x)e=`<remove></remove>`+e;else{let t=_t(e,/^[\r\n\t ]+/);r=t&&t[0]}hn===`application/xhtml+xml`&&Ct===St&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=h?me(e):e;if(Ct===St)try{t=new l().parseFromString(i,hn)}catch{}if(!t||!t.documentElement){t=ve.createDocument(Ct,`template`,null);try{t.documentElement.innerHTML=wt?le:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ct===St?be.call(t,Ue?`html`:`body`)[0]:Ue?t.documentElement:a},Pn=function(e){let t=oe?oe(e):e.ownerDocument;return g.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=vt(e,Se,` `),e=vt(e,Ce,` `),e=vt(e,we,` `),e},In=function(e){e.normalize();let t=oe?oe(e):e.ownerDocument,n=g.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&&lt(i,e=>{Rn(e.content)&&In(e.content)})},Ln=function(e){let t=ae?ae(e):null;return typeof t!=`string`||j(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==re(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==ie(e)||e.childNodes!==ee(e)},Rn=function(e){if(!ie||typeof e!=`object`||!e)return!1;try{return ie(e)===A.documentFragment}catch{return!1}},zn=function(e){if(!ie||typeof e!=`object`||!e)return!1;try{return typeof ie(e)==`number`}catch{return!1}};function Bn(e,n,r){e.length!==0&&lt(e,e=>{e.call(t,n,r,_n)})}let Vn=function(e,t){return!!(He&&e.hasChildNodes()&&!zn(e.firstElementChild)&&E($t,e.textContent)&&E($t,e.innerHTML)||He&&e.namespaceURI===St&&an[t]&&(zn(e.firstElementChild)||typeof e.textContent==`string`&&E(on[t],e.textContent))||e.nodeType===A.processingInstruction||He&&e.nodeType===A.comment&&E(en,e.data))},Hn=function(e,t){return e instanceof RegExp?E(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Un=function(e,t,n){if(!Pe[t]&&Yn(t)&&Hn(Ne.tagNameCheck,t))return!1;if(Ze&&!tt[t]){let t=te(e),r=ee(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,m(e))}}}return Tn(e),!0},Wn=function(e,t,n,r){return e.length===0?t:t===n||t===r?k(t):t},Gn=function(e,t){return e===t||te(e)!==null?!1:(Qe&&An(e),!0)},Kn=function(e,n){if(Bn(_.beforeSanitizeElements,e,null),Gn(e,n))return!0;if(Ln(e))return Tn(e),!0;let r=j(ce(e));if(v=Wn(_.uponSanitizeElement,v,je,b),Bn(_.uponSanitizeElement,e,{tagName:r,allowedTags:v}),Gn(e,n))return!0;if(Vn(e,r))return Tn(e),!0;if(Pe[r]||!(Ie.tagCheck instanceof Function&&Ie.tagCheck(r))&&!v[r]){let t=Un(e,r,n);return t===!1&&Bn(_.afterSanitizeElements,e,null),t}if(se(e)===A.element&&!wn(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&E(tn,e.innerHTML))return Tn(e),!0;if(Ve&&e.nodeType===A.text){let n=Fn(e.textContent);e.textContent!==n&&(ft(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Bn(_.afterSanitizeElements,e,null),!1},qn=function(e,t,r){if(Fe[t]||jn(t,e)||Je&&(t===`id`||t===`name`)&&(r in n||r in M))return!1;let i=y[t]||Ie.attributeCheck instanceof Function&&Ie.attributeCheck(t,e);return Re&&E(Te,t)||Le&&E(Ee,t)?!0:i?ot[t]||E(Ae,vt(r,Oe,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&yt(r,`data:`)===0&&rt[e]||ze&&!E(De,vt(r,Oe,``))?!0:!r:Yn(e)&&Hn(Ne.tagNameCheck,e)&&Hn(Ne.attributeNameCheck,t,e)||t===`is`&&Ne.allowCustomizedBuiltInElements&&Hn(Ne.tagNameCheck,r)},Jn=O({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Yn=function(e){return!Jn[ht(e)]&&E(ke,e)},Xn=function(e,t,n,r){if(h&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return me(r);case`TrustedScriptURL`:return he(r)}return r},Zn=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),Ln(e)?Tn(e):dt(t.removed)}catch{On(n,e)}},Qn=function(e){Bn(_.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||Ln(e))return;y=Wn(_.uponSanitizeAttribute,y,Me,Ge);let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:y,forceKeepAttr:void 0},r=t.length,i=j(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=j(o),u=c,d=o===`value`?u:bt(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,Bn(_.uponSanitizeAttribute,e,n),d=n.attrValue,Ye&&(l===`id`||l===`name`)&&yt(d,Xe)!==0&&(On(o,e,a),d=Xe+d),He&&E(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){On(o,e,a);continue}if(l===`attributename`&&_t(d,`href`)){On(o,e,a);continue}if(!n.forceKeepAttr){if(!n.keepAttr){On(o,e,a);continue}if(!Be&&E(nn,d)){On(o,e,a);continue}if(Ve&&(d=Fn(d)),!qn(i,l,d)){On(o,e,a);continue}d=Xn(i,l,s,d),d!==u&&Zn(e,o,s,d)}}Bn(_.afterSanitizeAttributes,e,null)},$n=function(e){let t=null,n=Pn(e);for(Bn(_.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Bn(_.uponSanitizeShadowNode,t,null),Kn(t,e),Qn(t),Rn(t.content)&&$n(t.content),se(t)===A.element){let e=ne(t);Rn(e)&&(er(e),$n(e))}Bn(_.afterSanitizeShadowDOM,e,null)},er=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){$n(e.shadow);continue}let n=e.node,r=se(n)===A.element,i=ee(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=ae?ae(n):null;if(typeof e==`string`&&j(e)===`template`){let e=n.content;Rn(e)&&t.push({node:e,shadow:null})}}if(r){let e=ne(n);Rn(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(wt=!e,wt&&(e=`<!-->`),typeof e!=`string`&&!zn(e)&&(e=kt(e),typeof e!=`string`))throw Et(`dirty is not a string, aborting`);if(!t.isSupported)return e;We?(v=b,y=Ge):N(n),(_.uponSanitizeElement.length>0||_.uponSanitizeAttribute.length>0)&&(v=k(v)),_.uponSanitizeAttribute.length>0&&(y=k(y)),t.removed=[];let c=Qe&&typeof e!=`string`&&zn(e);if(c){Mn(e);let t=ce(e);if(typeof t==`string`){let n=j(t);if(!v[n]||Pe[n])throw Dn(e),Et(`root node is forbidden and cannot be sanitized in-place`)}if(Ln(e))throw Dn(e),Et(`root node is clobbered and cannot be sanitized in-place`);try{er(e)}catch(t){throw Dn(e),t}}else if(zn(e))i=Nn(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===A.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),er(a);else{if(!S&&!Ve&&!Ue&&e.indexOf(`<`)===-1)return h&&qe?me(e):e;if(i=Nn(e),!i)return S?null:qe?le:``}i&&x&&Tn(i.firstChild);let l=c?e:i;try{let e=Pn(l);for(;o=e.nextNode();)Kn(o,l),Qn(o),Rn(o.content)&&$n(o.content)}catch(n){throw c&&(Dn(e),lt(t.removed,e=>{e.element&&An(e.element)})),n}if(c)return lt(t.removed,e=>{e.element&&An(e.element)}),Ve&&In(e),e;if(S){if(Ve&&In(i),Ke)for(s=ye.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(y.shadowroot||y.shadowrootmode)&&(s=xe.call(r,s,!0)),s}let u=Ue?i.outerHTML:i.innerHTML;return Ue&&v[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&E(Zt,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
6
- `+u),Ve&&(u=Fn(u)),h&&qe?me(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};N(e),We=!0,b=v,Ge=y},t.clearConfig=function(){_n=null,We=!1,b=null,Ge=null,h=ue,le=``},t.isValidAttribute=function(e,t,n){_n||N({});let r=j(e),i=j(t);return qn(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&T(_,e)&&ft(_[e],t)},t.removeHook=function(e,t){if(T(_,e)){if(t!==void 0){let n=ut(_[e],t);return n===-1?void 0:pt(_[e],n,1)[0]}return dt(_[e])}},t.removeHooks=function(e){T(_,e)&&(_[e]=[])},t.removeAllHooks=function(){_=ln()},t}var pn=fn();function mn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var hn=mn();function gn(e){hn=e}var j={exec:()=>null};function _n(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 M(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(N.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var vn=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),N={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:_n(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:_n(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:_n(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:_n(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:_n(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:_n(e=>RegExp(`^ {0,${e}}>`))},yn=/^(?:[ \t]*(?:\n|$))+/,bn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,xn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Sn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Cn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,wn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Tn=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,En=M(Tn).replace(/bull/g,wn).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(),Dn=M(Tn).replace(/bull/g,wn).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(),On=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,kn=/^[^\n]+/,An=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,jn=M(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,An).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Mn=M(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,wn).getRegex(),Nn=`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`,Pn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Fn=M(`^ {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`,Pn).replace(`tag`,Nn).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),In=e=>M(On).replace(`hr`,Sn).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`,Nn).getRegex(),Ln=In(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Rn=In(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),zn={blockquote:M(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Rn).getRegex(),code:bn,def:jn,fences:xn,heading:Cn,hr:Sn,html:Fn,lheading:En,list:Mn,newline:yn,paragraph:Ln,table:j,text:kn},Bn=M(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Sn).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`,Nn).getRegex(),Vn={...zn,lheading:Dn,table:Bn,paragraph:M(On).replace(`hr`,Sn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Bn).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`,Nn).getRegex()},Hn={...zn,html:M(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Pn).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:j,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:M(On).replace(`hr`,Sn).replace(`heading`,` *#{1,6} *[^
7
- ]`).replace(`lheading`,En).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Un=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Wn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Gn=/^( {2,}|\\)\n(?!\s*$)/,Kn=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,qn=/[\p{P}\p{S}]/u,Jn=/[\s\p{P}\p{S}]/u,Yn=/[^\s\p{P}\p{S}]/u,Xn=M(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Jn).getRegex(),Zn=/[\p{Pi}\p{Ps}"']/u,Qn=/(?!~)[\p{P}\p{S}]/u,$n=/(?!~)[\s\p{P}\p{S}]/u,er=/(?:[^\s\p{P}\p{S}]|~)/u,tr=M(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,vn?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),nr=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,rr=M(nr,`u`).replace(/punct/g,qn).getRegex(),ir=M(nr,`u`).replace(/punct/g,Qn).getRegex(),ar=M(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,Zn).replace(/punct/g,qn).getRegex(),or=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,sr=M(or,`gu`).replace(/notPunctSpace/g,Yn).replace(/punctSpace/g,Jn).replace(/punct/g,qn).getRegex(),cr=M(or,`gu`).replace(/notPunctSpace/g,er).replace(/punctSpace/g,$n).replace(/punct/g,Qn).getRegex(),lr=M(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Yn).replace(/punctSpace/g,Jn).replace(/punct/g,qn).getRegex(),ur=M(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Yn).replace(/punctSpace/g,Jn).replace(/punct/g,qn).getRegex(),dr=M(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Yn).replace(/punctSpace/g,Jn).replace(/punct/g,qn).getRegex(),fr=M(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,qn).getRegex(),pr=M(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Yn).replace(/punctSpace/g,Jn).replace(/punct/g,qn).getRegex(),mr=M(/\\(punct)/,`gu`).replace(/punct/g,qn).getRegex(),hr=M(/^<(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(),gr=M(Pn).replace(`(?:-->|$)`,`-->`).getRegex(),_r=M(`^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`,gr).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),vr=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,yr=M(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,vr).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),br=M(/^!?\[(label)\]\[(ref)\]/).replace(`label`,vr).replace(`ref`,An).getRegex(),xr=M(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,An).getRegex(),Sr=M(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,br).replace(`nolink`,xr).getRegex(),Cr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,wr={_backpedal:j,anyPunctuation:mr,autolink:hr,blockSkip:tr,br:Gn,code:Wn,del:j,delLDelim:j,delRDelim:j,emStrongLDelim:rr,emStrongRDelimAst:sr,emStrongRDelimUnd:ur,escape:Un,link:yr,nolink:xr,punctuation:Xn,reflink:br,reflinkSearch:Sr,tag:_r,text:Kn,url:j},Tr={...wr,emStrongLDelim:ar,emStrongRDelimAst:lr,emStrongRDelimUnd:dr,link:M(/^!?\[(label)\]\((.*?)\)/).replace(`label`,vr).getRegex(),reflink:M(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,vr).getRegex()},Er={...wr,emStrongRDelimAst:cr,emStrongLDelim:ir,delLDelim:fr,delRDelim:pr,url:M(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Cr).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:M(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Cr).getRegex()},Dr={...Er,br:M(Gn).replace(`{2,}`,`*`).getRegex(),text:M(Er.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Or={normal:zn,gfm:Vn,pedantic:Hn},kr={normal:wr,gfm:Er,breaks:Dr,pedantic:Tr},Ar={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},jr=e=>Ar[e];function Mr(e,t){if(t){if(N.escapeTest.test(e))return e.replace(N.escapeReplace,jr)}else if(N.escapeTestNoEncode.test(e))return e.replace(N.escapeReplaceNoEncode,jr);return e}function Nr(e){try{e=encodeURI(e).replace(N.percentDecode,`%`)}catch{return null}return e}function Pr(e,t){let n=e.replace(N.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(N.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(N.slashPipe,`|`);return n}function Fr(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 Ir(e){let t=e.split(`
8
- `),n=t.length-1;for(;n>=0&&N.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
9
- `)}function Lr(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 Rr(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 zr(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 Br(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 Vr=class{options;rules;lexer;constructor(e){this.options=e||hn}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]:Ir(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=Br(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=Fr(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:Fr(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:Fr(t[0],`
13
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Fr(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=Rr(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),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
29
- `,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
30
- `+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
31
- `+l}u=!l.trim(),r+=p+`
32
- `,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items)if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),!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=Ir(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:Fr(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=Pr(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:Fr(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(Pr(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:Fr(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=Fr(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=Lr(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)),zr(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 zr(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}}}},Hr=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||hn,this.options.tokenizer=this.options.tokenizer||new Vr,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:N,block:Or.normal,inline:kr.normal};this.options.pedantic?(t.block=Or.pedantic,t.inline=kr.pedantic):this.options.gfm&&(t.block=Or.gfm,t.inline=this.options.breaks?kr.breaks:kr.gfm),this.tokenizer.rules=t}static get rules(){return{block:Or,inline:kr}}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(N.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(N.tabCharGlobal,` `).replace(N.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)}},Ur=class{options;parser;constructor(e){this.options=e||hn}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(N.notSpaceStart)?.[0],i=e.replace(N.endingNewline,``)+`
52
- `;return r?`<pre><code class="language-`+Mr(r)+`">`+(n?i:Mr(i,!0))+`</code></pre>
53
- `:`<pre><code>`+(n?i:Mr(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>${Mr(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=Nr(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+Mr(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=Nr(e);if(i===null)return Mr(n);e=i;let a=`<img src="${e}" alt="${Mr(n)}"`;return t&&(a+=` title="${Mr(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Mr(e.text)}},Wr=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}},Gr=class e{options;renderer;textRenderer;constructor(e){this.options=e||hn,this.options.renderer=this.options.renderer||new Ur,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Wr}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}},Kr=class{options;block;constructor(e){this.options=e||hn}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?Hr.lex:Hr.lexInline}provideParser(e=this.block){return e?Gr.parse:Gr.parseInline}},qr=new class{defaults=mn();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Gr;Renderer=Ur;TextRenderer=Wr;Lexer=Hr;Tokenizer=Vr;Hooks=Kr;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 Ur(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 Vr(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 Kr;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]=Kr.passThroughHooks.has(n)?e=>{if(this.defaults.async&&Kr.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 Hr.lex(e,t??this.defaults)}parser(e,t){return Gr.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?Hr.lex:Hr.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?Gr.parse:Gr.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?Hr.lex:Hr.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?Gr.parse:Gr.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>`+Mr(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function P(e,t){return qr.parse(e,t)}P.options=P.setOptions=function(e){return qr.setOptions(e),P.defaults=qr.defaults,gn(P.defaults),P},P.getDefaults=mn,P.defaults=hn;function Jr(...e){return qr.use(...e),P.defaults=qr.defaults,gn(P.defaults),P}P.use=Jr,P.walkTokens=function(e,t){return qr.walkTokens(e,t)},P.parseInline=qr.parseInline,P.Parser=Gr,P.parser=Gr.parse,P.Renderer=Ur,P.TextRenderer=Wr,P.Lexer=Hr,P.lexer=Hr.lex,P.Tokenizer=Vr,P.Hooks=Kr,P.parse=P,P.options,P.setOptions,P.walkTokens,P.parseInline,Gr.parse,Hr.lex;var F=e=>{let t=document.querySelector(e);if(!t)throw Error(`missing element: ${e}`);return t};function Yr(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 Xr=e=>{let t=Yr(e);return t===`now`?`just now`:`${t} ago`};function I(e,t,...n){let r=document.createElement(e);return t&&(r.className=t),r.append(...n),r}var Zr=e=>e.split(`/`).filter(Boolean).pop()??e,Qr=e=>`New session in ${Zr(e)}`;function $r(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 ei(e){let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function ti(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 ni(e){let t=I(`span`,`help`);return t.innerHTML=pn.sanitize(P.parseInline(e,{async:!1})),ri(t),t}function ri(e){for(let t of e.querySelectorAll(`a`))(t.getAttribute(`href`)??``).startsWith(`#`)||(t.target=`_blank`,t.rel=`noreferrer`)}async function ii(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 ai(e,t){let n=I(`button`,e,`Copy`);n.title=`Copy to clipboard`;let r;return n.onclick=async e=>{e.stopPropagation(),n.textContent=await ii(t()).then(()=>`Copied`,()=>`Failed`),clearTimeout(r),r=setTimeout(()=>n.textContent=`Copy`,1200)},n}var oi=450,si=8,ci=700;function li(e,t){let n,r,i={x:0,y:0},a=!1,o=()=>clearTimeout(n),s=t=>{e.classList.remove(`bg-emerald-100`,`bg-red-100`),e.classList.add(t),clearTimeout(r),r=setTimeout(()=>e.classList.remove(t),ci)};e.addEventListener(`pointerdown`,e=>{a=!1,i={x:e.clientX,y:e.clientY},o(),n=setTimeout(()=>{a=!0,ii(t()).then(()=>s(`bg-emerald-100`),()=>s(`bg-red-100`))},oi)}),e.addEventListener(`pointermove`,e=>{Math.hypot(e.clientX-i.x,e.clientY-i.y)>si&&o()});for(let t of[`pointerup`,`pointercancel`,`pointerleave`])e.addEventListener(t,o);e.addEventListener(`click`,e=>{a&&(e.preventDefault(),e.stopImmediatePropagation())})}function ui(e,t){let n=document.createElement(`details`);n.className=e;let r=I(`summary`,`flex cursor-pointer select-none items-center gap-1.5`);return r.append(g(l,`chev h-3 w-3`),...t),n.append(r),{el:n,summary:r}}var di=(e,t=!1)=>L(e,`${t?`btn btn-primary`:`btn`} text-[12.5px]`),L=(e,t=``)=>{let n=I(`button`,t,e);return n.type=`button`,n},fi=e=>I(`span`,`mr-1 flex-none font-medium max-md:hidden`,e),pi=(...e)=>I(`div`,`toolbar flex min-h-10 flex-none flex-wrap items-center gap-2 px-4 py-2`,...e);function mi(e,t,n){let r=I(`div`,`inline-flex flex-none items-center gap-0.5 rounded-full bg-neutral-100 p-1`);for(let[i,a,o]of e){let e=a===t,s=L(o?``:i,`cursor-pointer whitespace-nowrap rounded-full text-[12px] transition-colors ${o?`flex h-7 w-7 items-center justify-center`:`px-3 py-1`} ${e?`bg-white font-medium text-neutral-800 shadow-xs`:`text-neutral-500 hover:text-neutral-700`}`);o&&(s.append(g(o,`h-4 w-4`)),s.setAttribute(`aria-label`,i),s.title=i),s.setAttribute(`aria-pressed`,String(e)),s.onclick=()=>n(a),r.append(s)}return r}function hi(e,t,n){let r=I(`div`,`flex flex-wrap items-center gap-2`);r.setAttribute(`role`,`radiogroup`);let i=e.map(([e])=>e),a=e.map(([e,t])=>{let n=L(``,`flex h-10 w-10 cursor-pointer items-center justify-center rounded-full ring-neutral-800 ring-offset-2 ring-offset-white transition-shadow hover:ring-2`);return n.style.background=t,n.setAttribute(`role`,`radio`),n.setAttribute(`aria-label`,e),n.title=e,n}),s=e=>{a.forEach((t,n)=>{let r=i[n]===e;t.classList.toggle(`ring-2`,r),t.setAttribute(`aria-checked`,String(r)),t.tabIndex=r?0:-1,t.replaceChildren(...r?[g(o,`h-4 w-4 text-white dark:text-neutral-950`)]:[])})},c=e=>{s(e),n(e)};return a.forEach((e,t)=>{e.onclick=()=>c(i[t]),e.onkeydown=e=>{let n=e.key===`ArrowRight`||e.key===`ArrowDown`?1:e.key===`ArrowLeft`||e.key===`ArrowUp`?-1:0;if(!n)return;e.preventDefault();let r=(t+n+i.length)%i.length;a[r].focus(),c(i[r])}}),s(t),r.append(...a),r}function gi(e,t,n){let r=L(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 _i=`rounded-3xl border border-neutral-200 bg-white shadow-sm`,vi=`border-b border-neutral-200/70 bg-neutral-50/50`,yi=`${_i} flex flex-col overflow-hidden`,bi=`${vi} flex flex-none items-center`;function xi(e,t,...n){let r=I(`section`,_i),i=I(`div`,`rounded-t-3xl ${vi} px-5 py-4`);return i.append(I(`h2`,`text-[14px] font-semibold text-neutral-800`,e)),t&&i.append(I(`p`,`mt-1 text-[12px] leading-normal text-neutral-500`,t)),r.append(i,I(`div`,`flex flex-col gap-4 px-5 py-5`,...n)),r}function Si(e,t,n={}){let r=I(`div`,`flex flex-col gap-1.5`),i=I(`div`,`flex items-center gap-1.5`,I(`span`,`field-label`,e));return n.help&&i.append(n.help),r.append(i,t),n.hint&&r.append(I(`span`,`text-[11.5px] leading-snug text-neutral-400`,n.hint)),r}var Ci=`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`,wi=`${Ci} cursor-pointer truncate text-left hover:bg-neutral-50`,Ti=(e,t,n,r=!1)=>{let i=document.createElement(`input`);return i.className=r?`${Ci} font-mono`:Ci,i.value=e,i.placeholder=t,i.oninput=()=>n(i.value),i},Ei=(e=``,t=`text`)=>{let n=document.createElement(`input`);return n.type=t,n.className=Ci,n.value=e,n},Di=(e,t)=>{let n=document.createElement(`select`);return n.className=`${Ci} select`,n.append(...e.map(([e,t])=>new Option(e,t))),n.value=t,n},Oi=(e=``,t=4)=>{let n=document.createElement(`textarea`);return n.className=`${Ci} resize-y font-mono`,n.value=e,n.rows=t,n.spellcheck=!1,n};function ki(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=I(`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 peer-disabled:cursor-not-allowed peer-disabled:opacity-45`),s=I(`label`,`flex cursor-pointer gap-2.5 ${e?`items-start`:`items-center`}`);if(s.append(a,o),e){let n=I(`span`,`flex items-center gap-1.5`,I(`span`,`text-[13px] text-neutral-700`,e));i&&n.append(i);let r=I(`span`,`flex min-w-0 flex-col`,n);t&&r.append(I(`span`,`text-[11.5px] leading-snug text-neutral-400`,t)),s.append(r)}return s}var Ai={idle:`text-neutral-400`,saving:`text-neutral-400`,saved:`text-green-700`,failed:`text-red-600`};function R(e,t,n){e.className=`text-[11.5px] ${Ai[t]}`,e.textContent=n}var ji=(e,t,n)=>I(`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?[I(`span`,`inline-block h-1.5 w-1.5 flex-none rounded-full ${n}`)]:[],e);function Mi(e,t,n,r={}){let i=I(`div`,`flex min-w-0 flex-col`,I(`span`,`flex min-w-0 items-center gap-2`,I(`span`,`truncate text-[12.5px] text-neutral-700`,e),...r.tag?[r.tag]:[]),I(`span`,`truncate text-[11.5px] text-neutral-400`,t));return r.title&&(i.title=r.title),I(`div`,`flex items-center justify-between gap-3 rounded-lg border border-neutral-200 px-3 py-2`,i,n)}var Ni=e=>I(`p`,`rounded-lg border border-dashed border-neutral-200 px-3 py-4 text-center text-[12.5px] text-neutral-400`,e);function Pi(e,t){let n=I(`span`,`group relative inline-flex`),r=L(``,`flex h-4 w-4 cursor-help items-center justify-center text-neutral-400 transition-colors group-hover:text-indigo-500`);r.append(g(u,`h-full w-full`)),r.setAttribute(`aria-label`,e);let i=I(`span`,`absolute left-0 top-full z-20 hidden w-[min(27rem,calc(100vw-3rem))] pt-1.5 group-hover:block`),a=I(`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`);a.append(I(`span`,`text-[12.5px] font-semibold text-neutral-800`,e));let o=I(`ol`,`flex list-decimal flex-col gap-1.5 pl-4`);for(let e of t){let t=I(`li`,`marker:text-neutral-400`);t.append(typeof e==`string`?ni(e):e),o.append(t)}return a.append(o),i.append(a),r.onclick=()=>{let e=i.classList.contains(`hidden`);i.classList.toggle(`hidden`,!e),i.classList.toggle(`block`,e),r.classList.toggle(`text-indigo-500`,e)},n.append(r,i),n}var Fi=(e,t)=>I(`span`,`flex flex-col gap-1`,ni(e),t),Ii=e=>`[${e.split(`/`).pop()??`file`}](file://${encodeURI(e).replace(/\(/g,`%28`).replace(/\)/g,`%29`)})`,Li=/^ {0,3}(`{3,}|~{3,})/;function Ri(e){let t=[],n,r=0;for(let i of e.split(`
71
- `)){let e=Li.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 zi(e,t,n){let r=Ri(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 Bi=/^\[[^\]\n]*\]\(\s*<?file:\/\/(\/[^)>\s]*)>?\s*\)$/;function Vi(e){let t=e.split(`
72
- `),n=t.length;for(;n>0&&Bi.test(t[n-1].trim());)n--;let r=t.slice(n).map(e=>{let t=Bi.exec(e.trim())[1];try{return decodeURIComponent(t)}catch{return t}});return{text:t.slice(0,n).join(`
73
- `).trimEnd(),paths:r}}var Hi=`modulepreload`,Ui=function(e){return`/app/`+e},Wi={},Gi=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=Ui(t,n),t=s(t),t in Wi)return;Wi[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`:Hi,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)})},Ki,qi;function Ji(){return qi??=Gi(()=>import(`./hljs-tWqyD59G.js`).then(e=>Ki=e.default,e=>{console.warn(`highlighting unavailable — code stays plain text`,e)}),[]),qi}async function Yi(e){let t=await Ji();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 Xi={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 Zi(e){let t=await Ji(),n=e.split(`.`).pop()?.toLowerCase()??``,r=Xi[n]??n;return t?.getLanguage(r)?r:null}function Qi(e,t){let n=document.createElement(`span`);return Ki&&t&&e.length<=500?n.innerHTML=Ki.highlight(e,{language:t}).value:n.textContent=e,n}var $i=2e4;function ea(e){let t=e.split(`
74
- `);return t.at(-1)===``&&t.pop(),t.map((e,t)=>({nums:[t+1],text:e,tone:``}))}function ta(e,t){let n=e.length<=$i?t:null,r=Math.max(2,...e.map(e=>e.nums.reduce((e,t)=>Math.max(e,String(t).length),0))),i=I(`div`,`py-2 font-mono text-[12px] leading-[1.5]`);for(let t of e){let e=I(`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=I(`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)}t.nums.length===1&&typeof t.nums[0]==`number`&&(e.dataset.line=String(t.nums[0])),e.append(na(t,n)),i.append(e)}return i}function na(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=Qi(e.text,t);return r.className=n,r}let[r,i]=e.mark,a=Qi(e.text.slice(r,i),t);return a.className=`rounded-xs ${e.tone===`add`?`bg-emerald-200/80`:`bg-red-200/70`}`,I(`span`,n,Qi(e.text.slice(0,r),t),a,Qi(e.text.slice(i),t))}var z=null,ra=null,ia=null;function aa(e){z&&!z.contains(e.target)&&e.target!==ia&&B()}var oa={ArrowDown:1,ArrowUp:-1},sa={n:1,j:1,p:-1,k:-1},ca=()=>z!==null;function la(e){if(!(e.altKey||e.metaKey||e.shiftKey||!e.key))return e.ctrlKey?sa[e.key.toLowerCase()]:oa[e.key]}function ua(e,t){let n=[...e.querySelectorAll(`button:not(:disabled)`)];if(!n.length)return!1;let r=n.indexOf(document.activeElement);return n[t===`first`?0:t===`last`?n.length-1:r<0?t>0?0:n.length-1:(r+t+n.length)%n.length]?.focus(),!0}function da(e){if(e.dataset.menu===`true`)return{rows:e,ends:!0};let t=e.querySelector(`[data-list]`);return t?{rows:t,ends:!1}:null}function fa(e){let t=z?da(z):null;if(t){let n=(t.ends?e.key===`Home`?`first`:e.key===`End`?`last`:void 0:void 0)??la(e);if(n!==void 0&&ua(t.rows,n)){e.preventDefault();return}}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),B())}function pa(e){z&&!z.contains(e.target)&&B()}function B(){if(!z)return;document.removeEventListener(`pointerdown`,aa,!0),document.removeEventListener(`focusin`,aa,!0),document.removeEventListener(`keydown`,fa,!0),window.removeEventListener(`scroll`,pa,!0),window.removeEventListener(`resize`,B);let e=z;z=null,ia?.remove(),ia=null,e.contains(document.activeElement)&&ra?.focus({preventScroll:!0}),ra?.removeAttribute(`aria-expanded`),ra=null,e.inert=!0,e.dataset.closing=``,Promise.allSettled(e.getAnimations().map(e=>e.finished)).then(()=>e.remove())}var ma=null;function ha(e){let t=e.getBoundingClientRect(),n={top:t.bottom+4,left:t.left};return t.width||t.height?n:ma?.anchor===e?{top:ma.top,left:ma.left}:n}var ga=()=>window.innerWidth<640;function _a(e,t){B(),document.querySelectorAll(`.glass-menu[data-closing]`).forEach(e=>e.remove());let n=ga();z=I(`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]`}`),z.dataset.presentation=n?`sheet`:`popover`,z.append(t);let r=e.closest(`dialog[open]`)??document.body;if(n&&(ia=I(`div`,`fixed inset-0 z-50 bg-black/15`),ia.onclick=e=>{e.stopPropagation(),B()},r.append(ia)),r.append(z),!n){let t=ha(e);ma={anchor:e,...t},z.style.top=`${Math.max(8,Math.min(t.top,window.innerHeight-z.offsetHeight-8))}px`,z.style.left=`${Math.max(8,Math.min(t.left,window.innerWidth-z.offsetWidth-8))}px`}return ra=e,ra.setAttribute(`aria-expanded`,`true`),z.tabIndex=-1,(z.querySelector(`button, input, select, [tabindex='0']`)??z).focus({preventScroll:!0}),document.addEventListener(`pointerdown`,aa,!0),document.addEventListener(`focusin`,aa,!0),document.addEventListener(`keydown`,fa,!0),window.addEventListener(`scroll`,pa,!0),window.addEventListener(`resize`,B),z}function va(e){let t=I(`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 ${ga()?`min-h-12 py-3`:`min-h-10 py-2`}`,...e.checked===void 0?[]:[g(o,`h-3 w-3 text-indigo-600 ${e.checked?``:`invisible`}`)],I(`span`,`min-w-0 truncate`,e.label));if(e.hint){let n=I(`span`,`ml-auto max-w-28 shrink-[999] truncate text-[13px] text-neutral-500`,e.hint);n.title=e.hint,t.append(n)}return e.disabled&&(t.disabled=!0,t.classList.add(`cursor-default`,`text-neutral-400`,`hover:bg-transparent`,`hover:text-neutral-400`)),t.onclick=()=>e.onSelect(),t}function ya(e,t,n){let r=I(`div`,``);if(n&&ga()){let e=I(`button`,`icon-btn h-11 w-11`,g(ve));e.setAttribute(`aria-label`,`Close session actions`),e.onclick=B,r.append(I(`div`,`flex items-center gap-3 border-b border-neutral-200 px-3 pb-1 mb-1`,I(`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(I(`hr`,`my-2 border-neutral-200`)),r.append(va(e));_a(e,r),z&&(z.dataset.menu=`true`,z.setAttribute(`aria-label`,n?`Actions for ${n}`:`Actions`),z.setAttribute(`role`,`group`))}var ba=async e=>{let t=await S(`/api/fs/ls${e?.startsWith(`/`)?`?path=${encodeURIComponent(e)}`:``}`,`Could not list directories`);return t.ok?t.value:null},xa=e=>e.entries.filter(e=>e.dir&&!e.name.startsWith(`.`)).map(e=>e.name),Sa=`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`,Ca=`font-mono text-[0.875rem]`,wa=(e,t,n)=>{let r=L(e,`${Sa} ${t}`);return r.onclick=n,r};function Ta(e,t){let n=I(`div`,`mt-2 flex-none border-t border-neutral-200 pt-2`),r=wa(`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 ${Ca} focus:outline-none`,r.placeholder=`folder-name`;let i=I(`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 b(`/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(g(de)),n.append(r),n}function Ea(e,t,n){let r=e=>{n(e),B()};async function i(t){let n=await ba(t);if(!n)return;let a=I(`div`,`flex max-h-[60dvh] w-full flex-col sm:w-88`),o=L(`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 ${Ca} 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=I(`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 ba(t);if(!n){c.textContent=`${t} is not a folder this can read`,c.classList.remove(`hidden`);return}r(n.path)};let l=I(`div`,`mb-2 flex flex-none items-center gap-2 border-b border-neutral-200 px-3 pb-2 pt-1`,s,o),u=I(`div`,`min-h-0 flex-1 overflow-y-auto`);u.dataset.list=``,n.parent&&u.append(wa(`../`,`${Ca} text-neutral-500`,()=>void i(n.parent)));let d=xa(n);for(let e of d)u.append(wa(e,`truncate`,()=>void i(`${n.path}/${e}`.replace(`//`,`/`))));d.length||u.append(I(`p`,`px-3 py-2 text-[0.8125rem] text-neutral-400`,`No sub-folders.`)),a.append(l,c,u,Ta(n.path,e=>void i(e))),_a(e,a)}i(t)}function Da(e,t,n,r){ya(e,[...t.map(e=>({label:e.path,...e.hint?{hint:e.hint}:{},checked:e.path===n,onSelect:()=>{B(),r(e.path)}})),{label:`Browse…`,onSelect:()=>Ea(e,n||void 0,r)}])}var Oa=(e,t)=>n=>{e.value=n,e.dispatchEvent(new Event(`input`,{bubbles:!0})),t?.(n)};function ka(e,t){let n=L(`Browse…`,`btn flex-none self-stretch rounded-xl px-3 text-[12.5px] text-neutral-600`);return n.onclick=()=>Ea(n,e.value.trim()||void 0,Oa(e,t)),n}function Aa(e,t,n){let r=document.createElement(`input`);return r.className=`${Ci} min-w-0 flex-1 font-mono`,r.value=e,r.placeholder=t,r.oninput=()=>n(r.value),{el:I(`div`,`flex items-center gap-1.5`,r,ka(r,n)),input:r}}var ja=F(`#image-dialog`),V=F(`#image-stage`),Ma=F(`#image-full`),Na=F(`#image-prev`),Pa=F(`#image-next`),Fa=F(`#image-close`),Ia=[],La=0;function Ra(e){Ia.length<2||(La=(La+e+Ia.length)%Ia.length,Va(!1),Ma.src=Ia[La])}var za=2.5,Ba=()=>V.dataset.zoom!==void 0;function Va(e,t){if(!e){delete V.dataset.zoom,Ma.style.cssText=``;return}let n=Ma.getBoundingClientRect(),r=V.getBoundingClientRect(),i=t?(t.x-n.left)/n.width:.5,a=t?(t.y-n.top)/n.height:.5,o=n.width*za,s=n.height*za;V.dataset.zoom=``,Ma.style.width=`${String(o)}px`,Ma.style.height=`${String(s)}px`,V.scrollLeft=i*o-r.width/2,V.scrollTop=a*s-r.height/2}function Ha(e){let t=e.closest(`[data-gallery]`);Ia=t?[...t.querySelectorAll(`img.thumb`)].map(e=>e.src):[e.src],La=Math.max(0,Ia.indexOf(e.src)),Ma.src=e.src;let n=Ia.length<2?`none`:`flex`;Na.style.display=n,Pa.style.display=n,ja.showModal()}var Ua=4,Wa,Ga=!1;V.onpointerdown=e=>{Ga=!1,!(!Ba()||e.button!==0)&&(Wa={x:e.clientX,y:e.clientY,left:V.scrollLeft,top:V.scrollTop},V.setPointerCapture(e.pointerId))},V.onpointermove=e=>{if(!Wa)return;let t=e.clientX-Wa.x,n=e.clientY-Wa.y;(Math.abs(t)>Ua||Math.abs(n)>Ua)&&(Ga=!0),V.scrollLeft=Wa.left-t,V.scrollTop=Wa.top-n};var Ka=()=>{Wa=void 0};V.onpointerup=Ka,V.onpointercancel=Ka,V.onclick=e=>{Ga||(e.target===Ma?Va(!Ba(),{x:e.clientX,y:e.clientY}):ja.close())},Fa.onclick=()=>ja.close(),ja.onclose=()=>Va(!1),Na.onclick=()=>Ra(-1),Pa.onclick=()=>Ra(1),ja.onkeydown=e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),Ra(e.key===`ArrowLeft`?-1:1))};function qa(e){let t=e.querySelector(`:scope > .thumbs`);if(t)return t;let n=I(`div`,`thumbs`);return e.append(n),n}function Ja(e){let t=document.createElement(`img`);return t.src=e,t.loading=`lazy`,t.className=`thumb`,t.onclick=()=>Ha(t),t}var Ya=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`bmp`]),Xa=524288,Za=F(`#file-dialog`),Qa=F(`#file-name`),$a=F(`#file-text`),eo=F(`#file-download`);F(`#file-close`).onclick=()=>Za.close();var to=e=>e.split(`.`).pop()?.toLowerCase()??``,no=(e,t,n=!1)=>`/api/sessions/${encodeURIComponent(e)}/files?path=${encodeURIComponent(t)}${n?`&download=1`:``}`,ro=e=>decodeURIComponent(/^\/api\/sessions\/([^/]+)\//.exec(e)?.[1]??``),io=e=>e.slice(0,e.lastIndexOf(`/`))||`/`,ao=(e,t)=>`${e===`/`?``:e}/${t}`;function oo(e,t){return zi(e,/\]\(\s*<?file:\/\/(\/[^)>\s]*)>?\s*\)/g,e=>{let n=e[1];try{n=decodeURIComponent(n)}catch{}return`](${no(t,n)})`})}var so=e=>/^\/api\/sessions\/[^/]+\/files\?/.test(e);function co(e,t){let n=Zr(t)||`file`,r=no(e,t);return Ya.has(to(n))?Co(r,n):wo(r,n)}function lo(e){return new URLSearchParams(e.slice(e.indexOf(`?`)+1)).get(`path`)??``}var uo=(e,t=`text-neutral-500`)=>I(`div`,`px-3 py-2 text-[12.5px] [overflow-wrap:anywhere] ${t}`,e),fo=0;function po(e,t,n){if(eo.hidden=n,n){Qa.replaceChildren(t);return}let r=io(t),i=L(`${r}/`,`min-w-0 cursor-pointer truncate text-neutral-400 hover:text-indigo-600`);i.title=`Browse ${r}`,i.onclick=()=>void ho(e,r),Qa.replaceChildren(i,I(`span`,`flex-none`,Zr(t)))}function mo(e,t){let n=I(`div`,`flex flex-col py-1`),r=(e,t,n)=>{let r=L(e,`flex w-full cursor-pointer items-center px-3 py-1.5 text-left font-mono text-[12.5px] hover:bg-indigo-50 hover:text-indigo-700 ${t}`);return r.onclick=n,r};t.parent&&n.append(r(`../`,`text-neutral-500`,()=>void ho(e,t.parent)));for(let i of t.entries){let a=ao(t.path,i.name);n.append(i.dir?r(`${i.name}/`,`text-neutral-800`,()=>void ho(e,a)):r(i.name,`text-neutral-600`,()=>void go(no(e,a),i.name)))}return t.entries.length||n.append(uo(`Empty folder.`)),n}async function ho(e,t){let n=++fo;po(e,t,!0),$a.replaceChildren(uo(`loading…`)),Za.open||Za.showModal();let r=await ba(t);n===fo&&$a.replaceChildren(r?mo(e,r):uo(`failed to list: ${t}`,`text-red-600`))}async function go(e,t,n){let r=++fo;po(ro(e),lo(e)||t,!1),eo.href=`${e}&download=1`,$a.replaceChildren(uo(`loading…`)),Za.open||Za.showModal();let i=e=>{r===fo&&$a.replaceChildren(e)},a;try{a=await fetch(e)}catch(e){return i(uo(`failed to load: ${String(e)}`,`text-red-600`))}if(!a.ok){let t=lo(e),n=a.status===404?await ba(t):null;return r===fo?n?void ho(ro(e),t):i(uo(`${await x(a,`failed to load`)}: ${t}`,`text-red-600`)):void 0}let o=a.headers.get(`content-type`)??``;if(!o.startsWith(`text/`)&&!o.startsWith(`image/svg+xml`))return i(uo(`Binary file — use Download.`));let s=await a.text(),c=s.length>Xa?`${s.slice(0,Xa)}\n…`:s,l=await Zi(t),u=ta(ea(c),l);if(i(u),n===void 0||r!==fo)return;let d=u.querySelector(`[data-line="${String(n)}"]`);d?.classList.add(`bg-indigo-100`),d?.scrollIntoView({block:`center`})}var _o=new Set(`ts.tsx.mts.cts.js.jsx.mjs.cjs.json.md.css.html.py.rs.go.rb.java.c.h.cpp.hpp.sh.sql.yml.yaml.toml.ini.conf.txt.lock`.split(`.`)),vo=/^(?:~|\/(?:home|Users|root|tmp|var|opt|etc|srv|mnt|media|data|usr))(?:\/|$)/;function yo(e){let t=/^([^\s`"'()[\]{}<>]+?)(?::(\d+))?(?::\d+)?$/.exec(e);if(!t||e.includes(`://`))return null;let n=t[1],r=n.includes(`.`)?to(n):``;return!vo.test(n)&&(!r||!_o.has(r)&&!n.includes(`/`))?null:{path:n,line:t[2]===void 0?void 0:Number(t[2])}}var bo;async function xo(e,t,n){let r=t;r.startsWith(`~`)&&(bo??=ba().then(e=>e?.path??null),r=`${await bo??`~`}${r.slice(1)}`),await go(no(e,r),Zr(r),n)}function So(e,t,n){for(let r of e.querySelectorAll(`:not(pre) > code`)){let e=yo(r.textContent?.trim()??``);if(!e||r.closest(`a`))continue;let i=e.path.startsWith(`/`)||e.path.startsWith(`~`)?e.path:n?`${n}/${e.path}`:null;if(!i)continue;let a=()=>void xo(t,i,e.line);r.classList.add(`fileref`),r.tabIndex=0,r.setAttribute(`role`,`button`),r.title=e.line===void 0?i:`${i}:${String(e.line)}`,r.onclick=a,r.addEventListener(`pointerup`,()=>r.blur()),r.onkeydown=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())}}}function Co(e,t){let n=Ja(e);return n.alt=t,n}function wo(e,t){let n=to(t),r=I(`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=I(`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=I(`span`,`min-w-0 truncate text-[13px] font-medium text-neutral-800`,t),o=I(`span`,`ml-1 flex flex-none items-center gap-0.5`),s=I(`button`,`icon-btn h-6 w-6 text-[13px]`,g(ee));s.setAttribute(`aria-label`,`Preview`),s.title=`Preview`,s.onclick=r=>{r.preventDefault(),n===`pdf`?window.open(e,`_blank`,`noopener`):go(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(g(p)),c.setAttribute(`aria-label`,`Download`),o.append(c),r.append(i,a,o),r}function To(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=I(`div`,`thumbs`);r.append(...t),n.after(r)}}function Eo(e){let t=[];for(let n of e.querySelectorAll(`img`)){let e=n.getAttribute(`src`)??``;if(!so(e))continue;let r=Co(e,Zr(lo(e)));n.replaceWith(r),t.push(r)}for(let n of e.querySelectorAll(`a`)){let e=n.getAttribute(`href`)??``;if(!so(e))continue;let r=Zr(lo(e))||n.textContent?.trim()||`file`,i=Ya.has(to(r))?Co(e,r):wo(e,r);n.replaceWith(i),t.push(i)}t.length&&To(t)}var Do=null,Oo=`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 ko(){Do=null}function Ao(e,t,n){if(Do?.remove(),Do=null,!t.length)return;let r=I(`div`,`mt-1.5 flex flex-wrap gap-1.5`);for(let e of t){let t=I(`button`,Oo,e);t.type=`button`,t.onclick=()=>{Do===r&&(Do=null),r.remove(),n(e)},r.append(t)}e.append(r),Do=r}var jo=8e3,Mo=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],No=e=>typeof e==`string`&&Mo.includes(e),Po,Fo;function Io(e,t){Po=e,Fo=t}var Lo=e=>e.slice(0,8),Ro=e=>`system-card group relative mt-1.5 rounded-xl px-4 py-2.5 ${e}`,zo=e=>I(`div`,Ro(e));function Bo(e){let t=e.length>240||e.split(`
75
- `).length>4,n=[`max-h-[4lh]`,`overflow-hidden`],r=I(`div`,`mt-1 whitespace-pre-wrap break-words text-[12.5px] leading-normal text-neutral-500 ${n.join(` `)}`,e),i=I(`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 Vo(e){let t=I(`div`,`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-neutral-500`,e.glyph);t.append(I(`span`,`run-label flex-none font-semibold ${e.labelCls}`,e.label)),e.taskName&&t.append(I(`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=I(`div`,`ml-auto flex min-w-0 flex-wrap items-center gap-x-2 font-mono`);if(e.note&&n.append(I(`span`,`flex-none`,e.note)),e.model){let t=I(`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=I(`span`,`flex-none`,e.thinking);t.title=`Reasoning effort`,n.append(t)}let r=I(`button`,`flex-none hover:underline`,Lo(e.runId));if(r.title=`Run ${e.runId}`,r.onclick=()=>Po.showRun(e.runId),n.append(r),e.sessionId&&e.sessionId!==`console`){let t=e.sessionId,r=I(`button`,`flex-none text-indigo-600 hover:underline`,Lo(t));r.title=`Open session ${t}`,r.onclick=()=>Po.select(t),n.append(r)}return t.append(n),t}var Ho={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:o},failed:{edge:`border-l-red-500`,label:`text-red-600`,glyph:ve},cancelled:{edge:`border-l-neutral-300`,label:`text-neutral-500`,glyph:se},interrupted:{edge:`border-l-amber-400`,label:`text-amber-700`,glyph:le},skipped:{edge:`border-l-neutral-300`,label:`text-neutral-500`,glyph:se}},Uo=e=>g(Ho[e].glyph,`h-3 w-3 ${e===`queued`||e===`running`?`spinner`:``} ${Ho[e].label}`),Wo=new Map,Go=new WeakMap;function Ko(e){for(let[e,t]of Wo)t.isConnected||Wo.delete(e);let t=Wo.get(e.runId);t||(t=zo(Ho[e.state].edge),t.dataset.kind=`background-run`,Fo.el.append(t),Wo.set(e.runId,t)),t.className=Ro(Ho[e.state].edge);let n=e.state===`queued`||e.state===`running`;t.toggleAttribute(`data-active`,n);let r=Math.max(0,Math.round(((e.finishedAt??Date.now())-(e.startedAt??e.queuedAt))/1e3)),i=Vo({glyph:Uo(e.state),label:`run · ${e.state}`,labelCls:Ho[e.state].label,taskName:e.taskName,note:`${e.sessionMode??`task`} · ${String(r)}s`,runId:e.runId,sessionId:e.targetSessionId}),a=Go.get(t);!a&&e.prompt!==null&&(a=Bo(e.prompt),Go.set(t,a)),t.replaceChildren(i,...a??[]),Fo.scroll()}var H=null,qo=null,Jo=null,Yo=!1;function Xo(){if(!qo)return;qo.text=qo.text.slice(-4e3),qo.pre.textContent=qo.text;let e=qo.text.split(`
76
- `).filter(Boolean).pop()??`thinking…`,t=qo.summary.lastElementChild;t.textContent=e.length>90?`…`+e.slice(-90):e}function Zo(){if(Jo){Yo=!0;return}Yo=!1,Xo(),Jo=setTimeout(()=>{Jo=null,Yo&&Zo()},80)}function Qo(){Jo&&clearTimeout(Jo),Jo=null,Yo&&Xo(),Yo=!1}var $o=new WeakMap,es=e=>{let t=$o.get(e)??[];return $o.set(e,t),t};function ts(){H&&!H.toolRows.size&&hs(`done`)}var ns=null;function rs(){H=null,ns=null,qo=null,Qo(),Wo.clear()}function is(){let e=ns;return!e||H?.el===e||(ns=null,e!==Fo.el.lastElementChild)?null:(e.remove(),e.dataset.adopted=`1`,os(e,e.dataset.status),e)}var as={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 os(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 ${as[t]}`}var ss={failed:ve,interrupted:le};function cs(e){return e===`running`?g(ie,`spinner`):e===`done`?I(`span`,`hidden`):g(ss[e],`h-3 w-3`)}function ls(e){if(H)return H;let t=cs(`running`),n=I(`span`,`min-w-0 truncate`,`working…`),{el:r}=ui(``,[t,n]);r.dataset.kind=`activity`,os(r,`running`);let i=I(`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),fs(r,i),Fo.el.append(r),ns=r,Fo.scroll(),H={el:r,statusIcon:t,headline:n,rowsEl:i,toolRows:new Map,thinking:null,steps:0,failedSteps:0,startTs:e,sawError:!1},H}function us(e,t=``){let n=ls(e);Qo(),n.thinking=null;let r=I(`div`,`whitespace-pre-wrap break-words text-[13px] text-neutral-600`,t);r.dataset.raw=t;let i=I(`div`,`rounded-lg bg-neutral-50 px-2 py-1.5`,I(`span`,`text-[10px] font-medium text-neutral-400`,`Update`),r);return i.dataset.kind=`progress`,n.rowsEl.append(i),ms(n,`running`,`writing…`),ps(n),Fo.scroll(),r}function ds(e){let t=e.closest(`details[data-kind="activity"]`);e.parentElement?.remove(),t&&!t.lastElementChild?.childElementCount&&(H?.el===t&&(H=null),ns===t&&(ns=null),t.remove())}function fs(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 ps(e){Fo.bulk()||!e.el.open||!e.rowsEl.dataset.follow||(e.rowsEl.scrollTop=e.rowsEl.scrollHeight)}function ms(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}`,os(e.el,t);let a=cs(t);e.statusIcon.replaceWith(a),e.statusIcon=a}function hs(e){if(!H)return;Qo();for(let{statusEl:e}of H.toolRows.values())e.textContent===`running…`&&(e.textContent=`interrupted`);let t=H.steps>0&&H.failedSteps===H.steps;ms(H,(H.sawError||t)&&e===`done`?`failed`:e===`done`&&H.toolRows.size?`interrupted`:e),H=null}function gs(){H&&(H.sawError=!0)}function _s(e){let t=e.slice(0,400).replace(/\s+/g,` `);return t.length>100?t.slice(0,100)+`…`:t}function vs(e,t,n,r){let i=ls(e);i.steps+=1,Qo(),i.thinking=null;let a=JSON.stringify(r,null,2)??``,o=I(`span`,`ml-auto flex-none text-neutral-400`,`running…`),s=I(`span`,`min-w-0 truncate text-neutral-500`,_s(a)),{el:c}=ui(`rounded-md px-1 py-0.5 font-mono text-[12.5px] hover:bg-black/[0.03] dark:hover:bg-neutral-100`,[I(`span`,`flex-none font-semibold`,n),s,o]),l=I(`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=I(`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(I(`div`,`mt-1 flex flex-col gap-1 pl-4`,l,u)),es(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),ps(i),ms(i,`running`,n),Fo.scroll()}function ys(e,t,n){let r=H;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,jo)+`…`:n,i.outputPre.classList.remove(`hidden`)),t&&(r.failedSteps+=1)),ms(r,`running`)}function bs(e,t){let n=ls(e);if(!n.thinking){Qo();let{el:e,summary:t}=ui(`rounded-md px-1 py-0.5 text-[12.5px] italic text-neutral-500 hover:bg-black/[0.03] dark:hover:bg-neutral-100`,[I(`span`,`min-w-0 truncate`,`thinking…`)]),r=I(`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:``},qo=n.thinking,ps(n),ms(n,`running`,`thinking…`)}n.thinking.text+=t,Zo()}var xs=0;function Ss(e,t=0,n=!1,r){let i=Date.now()-t,a=ls(i).el;for(let t of e){if(t.kind===`progress`){us(i,t.text??``);continue}if(t.kind===`thinking`){bs(i,t.text??``);continue}let e=t.id??`replay-${++xs}`;vs(i,e,t.toolName??``,t.args),t.done&&ys(e,t.isError??!1,t.output??``)}r!==void 0&&e.some(e=>e.kind===`tool`&&e.args===void 0)&&Cs(a,r),!n&&hs(e.some(e=>e.kind===`tool`&&!e.done)?`interrupted`:`done`)}function Cs(e,t){let n=()=>{e.open&&(e.removeEventListener(`toggle`,n),ws(e,t))};e.addEventListener(`toggle`,n)}async function ws(e,t){let n=Po.sessionId(),r=es(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 S(`/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=_s(r),n.output&&(t.outputPre.textContent=n.output,t.outputPre.classList.remove(`hidden`))}}var Ts,U=F(`#turns`);function Es(e){Ts=e,Io(e,{el:U,scroll:Ps,bulk:()=>Ds})}var Ds=!1,Os=()=>U.scrollHeight-U.scrollTop-U.clientHeight<80,ks=!0,As=0;U.addEventListener(`scroll`,()=>{let e=U.scrollTop,t=e<As-4;As=e,!Ds&&(t||Os())&&(ks=Os())},{passive:!0});var js=0;function Ms(){!ks||Ds||js||(js=requestAnimationFrame(()=>{js=0,ks&&!Ds&&(U.scrollTop=U.scrollHeight)}))}new ResizeObserver(Ms).observe(U),U.addEventListener(`load`,Ms,!0),new MutationObserver(Ms).observe(U,{childList:!0,subtree:!0,characterData:!0});function Ns(){Os()&&(ks=!0)}function Ps(e=!1){Ds||(e&&(ks=!0),ks&&(U.scrollTop=U.scrollHeight))}var Fs=1200;function Is(e,t){let n=U.querySelector(`[data-kind="${e}"][data-at="${t}"]`);return n?(Rs(n),!0):!1}function Ls(){let e=U.querySelectorAll(`[data-kind="background-run"][data-active]`),t=e[e.length-1];return t?(Rs(t),!0):!1}function Rs(e){ks=!1,e.scrollIntoView({block:e.offsetHeight>U.clientHeight?`start`:`center`}),e.dataset.reveal=``,setTimeout(()=>delete e.dataset.reveal,Fs)}var zs=500,Bs=0,Vs=0,Hs=null;function Us(){for(;U.childElementCount>zs;){let e=U.firstElementChild;e.remove(),e!==Hs&&(e.dataset.kind===`user`&&Bs++,Vs++)}Vs&&(Hs||(Hs=I(`div`,`px-5 py-2 text-center text-[11.5px] italic text-neutral-400`),Hs.dataset.kind=`trim`),Hs.textContent=`${Vs} earlier row${Vs===1?``:`s`} not shown — still in the transcript, not on this screen`,U.firstElementChild!==Hs&&U.prepend(Hs))}var Ws={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 W(e,t,n=!1,r){ts();let i=e===`assistant`?is():null,a=Ws[e],o=e===`user`&&r!==void 0&&oc(r)?r:void 0,s=o===void 0&&U.lastElementChild?.dataset.kind===e,c=I(`div`,`group relative ${a.row}`);c.dataset.kind=e,s&&(c.dataset.grouped=``),Ds||(c.dataset.enter=``);let l=e===`user`?Vi(t):null,u=l?.text??t,d=e===`user`?Le(u):null,f=d?.id||d?.when||d?.where?d:null,p=f&&(f.id?f.id!==`web`:f.name)?f:null,m=I(`div`,`whitespace-pre-wrap break-words ${a.body}`,f?.text??u);(l?.paths.length||f)&&(m.dataset.raw=t),n&&uc(m,t),r!==void 0&&sc(c,r),p&&c.append(Gs(p)),c.append(m);let ee=Ts.sessionId();if(l?.paths.length&&ee){let e=qa(c);for(let t of l.paths)e.append(co(ee,t))}if(e===`user`){Ys?.();let e=I(`button`,`message-edit absolute right-full top-1 flex h-8 w-8 items-center justify-center rounded-full`);e.title=`Edit message — resends it and drops everything after it`,e.setAttribute(`type`,`button`),e.setAttribute(`aria-label`,`Edit message`),e.append(g(ue)),e.onclick=()=>Qs(c,m),c.append(e)}if(o!==void 0){let e=I(`div`,`my-3 text-center text-[11px] text-neutral-400`);e.dataset.kind=`time`,e.dataset.at=String(o),rc(e),nc??=setInterval(ic,6e4),e.title=$r(o),U.append(e)}return i&&U.append(i),U.append(c),Us(),Ps(),m}function Gs(e){let t=I(`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=I(`span`,`font-semibold text-inherit`,n);e?.id&&(r.title=e.id),t.append(r)}let r=Ts.sessionChannel();return r&&r!==`web`&&t.append(I(`span`,`text-[10px] uppercase tracking-wide opacity-60`,r)),t}var Ks={"task-delegation":[i,`delegated`,`text-cyan-700`],"task-callback":[f,`callback`,`text-cyan-700`]};function qs(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 Js(e,t){let n=t.kind===`task-message`?t.messageKind:t.kind,[r,i,a]=Ks[n]??[f,n.replace(`_`,` `),`text-cyan-700`];ts();let o=t.kind===`task-callback`?t.state:void 0,s=zo(o?Ho[o].edge:`border-l-cyan-500`);s.dataset.kind=`system`;let[c,l]=qs(e),u=Vo({glyph:o?Uo(o):g(r,`h-3 w-3 ${a}`),label:o?`${i} \u00b7 ${o}`:i,labelCls:o?Ho[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(...Bo(l)),U.append(s),Us(),Ps()}var Ys=null,Xs=e=>e.isConnected&&e.dataset.kind===`user`;function Zs(e){let t=0;for(let n=e.nextElementSibling;n;n=n.nextElementSibling){let e=n.dataset.kind;(e===`user`||e===`assistant`||e===`system`)&&t++}return t}function Qs(e,t){if(!Xs(e)||e.querySelector(`textarea`))return;if(Ys?.(),Ts.sessionState()!==`idle`){W(`error`,`can't edit while streaming — stop the turn first`);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 message`);let r=di(`Send edit`,!0),i=di(`Cancel`),a=Zs(e),o=I(`div`,`mt-2 flex flex-wrap items-center justify-end gap-2`);a&&o.append(I(`div`,`mr-auto text-[11.5px] text-neutral-500`,`sending drops the ${a} message${a===1?``:`s`} after this one`)),o.append(i,r);let s=I(`div`,`message-editor`,n,o),c=()=>{n.style.height=`auto`,n.style.height=`${Math.min(n.scrollHeight,192)}px`,r.disabled=!n.value.trim()};n.oninput=c,e.dataset.editing=``,t.classList.add(`hidden`),t.after(s),c(),n.focus(),n.setSelectionRange(n.value.length,n.value.length);let l=()=>{s.remove(),t.classList.remove(`hidden`),delete e.dataset.editing,Ys=null};Ys=l,i.onclick=()=>{l(),e.querySelector(`.message-edit`)?.focus({preventScroll:!0})},r.onclick=()=>{let t=n.value.trim();t&&$s(e,t)},s.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 $s(e,t){let n=Ts.sessionId();if(!n||!Xs(e))return;if(Ts.sessionState()!==`idle`){W(`error`,`can't edit while streaming — stop the turn first`);return}Ys?.();let r=[...U.querySelectorAll(`[data-kind="user"]`)],i=r.indexOf(e),a=Bs+i,o=r[i-1]?.dataset.at;tc=o===void 0?null:Number(o);let s=e.previousElementSibling;for(s?.dataset.kind===`time`&&s.remove();e.nextElementSibling;)e.nextElementSibling.remove();e.remove(),Ts.ownTurn(t),W(`user`,t,!1,Date.now()),Ps(!0);let c=await b(`/api/sessions/${n}/turns/${a}/edit`,{text:t});if(!c.ok){let e=await x(c,`edit failed`);await Ts.reload(n),W(`error`,e)}}var ec=6e5,tc=null,nc;function rc(e){let t=Number(e.dataset.at);e.textContent=`${$r(t).slice(0,16)} · ${Xr(t)}`}function ic(){let e=U.querySelectorAll(`[data-kind="time"]`);for(let t of e)rc(t);e.length||(clearInterval(nc),nc=void 0)}var ac=(e,t)=>new Date(e).toDateString()===new Date(t).toDateString();function oc(e){let t=tc;return tc=e,t===null||e-t>=ec||!ac(t,e)}function sc(e,t){e.dataset.at=String(t),e.dataset.time=$r(t).slice(11)}function cc(e){for(let t of e.querySelectorAll(`pre`)){let e=t.querySelector(`code`);if(!e)continue;let n=I(`div`,`group/code relative`);t.replaceWith(n),n.append(t,ai(`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 lc(e){let t=Ts.sessionId(),n=I(`div`,``);return n.innerHTML=pn.sanitize(P.parse(t?oo(e,t):e,{async:!1})),ri(n),n}function uc(e,t){e.replaceChildren(...lc(t).childNodes),e.classList.remove(`whitespace-pre-wrap`),e.classList.add(`md`),Yi(e),cc(e);for(let t of e.querySelectorAll(`:not(pre) > code`))li(t,()=>t.textContent??``);Eo(e);let n=Ts.sessionId();n&&So(e,n,Ts.sessionCwd())}function dc(e,t,n,r=!1){let{text:i,suggestions:a}=je(t);return _({text:i,suggestions:a})?fc(e,v(t)):uc(e,i),r&&Ao(e.parentElement??e,a,e=>Ts.send(`auto`,e)),n&&sc(e.parentElement??e,n.completedAt),e}function fc(e,t){e.classList.remove(`md`,`whitespace-pre-wrap`),e.replaceChildren(I(`span`,`text-[12.5px] italic text-neutral-400`,t?`Stayed silent — ${t}`:`Stayed silent.`))}var pc=(e,t,n=!1)=>dc(W(`assistant`,``),e,t,n),G=null,mc=null,hc=!1,gc=0,_c=0;function vc(e){let t=e.dataset.raw??``;for(;e.childNodes.length>_c;)e.lastChild.remove();let n=Ne(t,gc);n>gc&&(e.append(...lc(y(t.slice(gc,n))).childNodes),gc=n,_c=e.childNodes.length),e.append(...lc(je(t.slice(gc)).text).childNodes),e.classList.remove(`whitespace-pre-wrap`),e.classList.add(`md`)}function yc(){if(mc){hc=!0;return}hc=!1,G&&(vc(G),Ps()),mc=setTimeout(()=>{mc=null,hc&&yc()},80)}function bc(){mc&&clearTimeout(mc),mc=null,hc=!1}function xc(e){G||(G=us(Date.now()),gc=0,_c=0),G.dataset.raw=(G.dataset.raw??``)+e,yc()}function Sc(){if(!G)return;let e=G;G=null,bc(),e.classList.remove(`md`),e.classList.add(`whitespace-pre-wrap`),e.textContent=e.dataset.raw??``}function Cc(){if(!G)return;let e=G.dataset.raw;return ds(G),G=null,bc(),e}function wc(e,t){e===``&&Sc();let n=Cc();hs(`done`);let r=e??n;r&&pc(r,t,!0)}function Tc(){let e=Cc();hs(`interrupted`),e&&pc(e)}function Ec(){Ys?.(),clearInterval(nc),nc=void 0,U.replaceChildren(),Bs=0,Vs=0,Hs=null,tc=null,G=null,bc(),rs(),ko()}function Dc(e){if(!e){U.querySelector(`[data-kind="loading"]`)?.remove();return}let t=I(`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(I(`div`,`skeleton h-3.5 ${e}`));U.append(t)}function Oc(e,t,n){Dc(!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&&(Ko(e),r.delete(t))}},o=e.reduce((e,t,n)=>t.role===`assistant`?n:e,-1);Ds=!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&&(Ss(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]),Js(r.text,r.origin);continue}s?xc(r.text):r.role===`assistant`?pc(r.text,r.meta,t===`idle`&&n===o):W(r.role,r.text,!1,r.at)}}for(let e of r.values())Ko(e)}finally{Ds=!1}Ps(!0)}var kc=window.fetch.bind(window),Ac=20,jc=6e4,Mc=[],Nc=new Map,Pc=e=>e instanceof Error?e.stack??`${e.name}: ${e.message}`:void 0;function Fc(e,t){let n=t===void 0?e:`${e}: ${String(t)}`,r=Date.now();return r-(Nc.get(n)??-6e4)<jc||(Nc.size>100&&Nc.clear(),Nc.set(n,r),Mc=Mc.filter(e=>r-e<6e4),Mc.length>=Ac)?null:(Mc.push(r),kc(`/api/client-log`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:n,stack:Pc(t),view:location.hash||`/`}),keepalive:!0}).catch(()=>{}),W(`error`,n))}function Ic(){window.__pierReporting=!0,window.addEventListener(`error`,e=>{!e.error&&e.message.includes(`ResizeObserver loop`)||Fc(`script error: ${e.message}`,e.error)}),window.addEventListener(`unhandledrejection`,e=>{Fc(`unhandled rejection`,e.reason)})}var Lc=window.fetch.bind(window),Rc=()=>{location.assign(`/login?next=${encodeURIComponent(location.pathname+location.hash)}`)};function zc(){window.fetch=async(...e)=>{let t=await Lc(...e);return t.status===401&&Rc(),t}}function Bc(e,t){if(e.readyState!==EventSource.CLOSED)return;let n=()=>{let e=Fc(`${t} stream disconnected`);if(!e)return;let n=di(`Reload`);n.classList.add(`ml-2`,`align-middle`),n.onclick=()=>location.reload(),e.append(` `,n)};Lc(`/api/sessions`).then(e=>e.status===401?Rc():n(),n)}var Vc=/Mac|iP(?:hone|ad|od)/.test(navigator.userAgent),Hc=Vc?`⌘`:`Ctrl+`,Uc=Vc?`⇧`:`Shift+`,Wc=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 Gc(e){let{key:t,shift:n,meta:r}=Wc(e);return`${r?`⌘`:Hc}${n?Uc:``}${t.toUpperCase()}`}var Kc=()=>document.querySelector(`dialog[open]`)!==null,qc={"[":`{`,"]":`}`},Jc=`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 Yc(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=I(`div`,Jc,t,I(`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 Xc(e,t,n,r,i){Yc(e,n,Gc(t)),el(t,r,i)}function Zc(e,t,n,r){Yc(e,t,`Esc`),document.addEventListener(`keydown`,e=>{e.key!==`Escape`||e.isComposing||e.defaultPrevented||Kc()||!r()||(e.preventDefault(),n())})}var Qc=`input, textarea, select, [contenteditable]`;function $c(e,t,n,r,i){Yc(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?.(Qc)||Kc()||!i()||(e.preventDefault(),r())})}function el(e,t,n){let{key:r,shift:i,meta:a}=Wc(e),o=qc[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 K,tl=F(`#composer`),q=F(`#input`),nl=F(`#send`),rl=F(`#send-arrow`),il=F(`#send-queue`),al=F(`#stop`),ol=F(`#queue-panel`),sl=F(`#queue-rows`),cl=F(`#queue-label`),ll=I(`div`,`hidden max-h-48 overflow-y-auto border-t border-neutral-200 px-4 py-2 text-[13px]`);ll.id=`recovery-panel`,ol.after(ll);var ul=F(`#image-strip`),dl=F(`#attach-input`),fl=!1,pl=0,ml=new Set,hl=[],gl=[];function _l(){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 vl(){let e=tl.parentElement,t=[ol,ll,tl],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,{box:`border-box`})}function yl(){q.focus()}function bl(e){let t=gl.indexOf(e);return t<0?!1:(gl.splice(t,1),!0)}function xl(e){gl.push(e)}function Sl(){gl=[]}function Cl(){let e=K.sessionState()===`streaming`,t=K.sessionId()!==null,n=K.starting();nl.disabled=!t,nl.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`}`,nl.title=t?e?`Queue — delivered when the turn ends`:`Send`:n?`Starting the session…`:`No session`,q.placeholder=n?`Starting the session…`:`Message…`,rl.classList.toggle(`hidden`,e),il.classList.toggle(`hidden`,!e),al.classList.toggle(`hidden`,!e),al.classList.toggle(`flex`,e)}function wl(){let e=K.chatVisible()&&fl;ol.classList.toggle(`hidden`,!e),ol.classList.toggle(`flex`,e),ll.classList.toggle(`hidden`,!K.chatVisible()||!ll.childElementCount)}function Tl(e,t=!1){let n=K.sessionId();if(ll.replaceChildren(...e.map(e=>{let t=I(`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(I(`summary`,`cursor-pointer break-words text-amber-700`,`Queue recovery: ${r}${i} (in memory)`));for(let n of[...e.steering,...e.followUp]){let e=I(`div`,`flex items-start gap-2 border-t border-neutral-100 py-1`);e.append(I(`span`,`min-w-0 flex-1 whitespace-pre-wrap break-words`,n),ai(`flex-none cursor-pointer px-1 text-neutral-500 hover:text-neutral-800`,()=>n)),t.append(e)}e.error&&t.append(I(`div`,`break-words text-red-600`,e.error));let a=I(`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 b(`/api/sessions/${n}/queue/recovery/${e.id}/ack`,{}),r=t.ok?null:await x(t,`Could not acknowledge queue recovery`);K.sessionId()===n&&(r===null?await K.reload(n):W(`error`,r))},t.append(a),t})),t){let e=I(`div`,`flex flex-wrap items-center gap-x-2 py-1 text-amber-700`,`Automatic queue paused: acceptance unknown (in memory)`),t=I(`button`,`cursor-pointer underline`,`Recall queue`);t.title=`Clear the live queue and return its messages to the composer`,t.onclick=()=>void Ul(),e.append(t),ll.prepend(e)}wl()}function El(e,t){++pl;let n=[...e.map(e=>({mode:`steer`,text:e})),...t.map(e=>({mode:`queued`,text:e}))];fl=n.length>0,cl.textContent=n.length>1?`Queued · ${n.length}`:`Queued`,wl(),sl.replaceChildren(...n.map(e=>{let t=I(`li`,`flex items-start gap-2 text-[13px] leading-[18px]`);return e.mode===`steer`&&t.append(I(`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(I(`span`,`min-w-0 whitespace-pre-wrap break-words text-neutral-700`,e.text)),t}))}var Dl=8;function Ol(){let e=K.sessionId();e&&hl.length?Il.set(e,hl):e&&Il.delete(e),ul.classList.toggle(`hidden`,hl.length===0),ul.classList.toggle(`flex`,hl.length>0),ul.replaceChildren(...hl.map((e,t)=>{let n=e.mimeType.startsWith(`image/`)?Ja(`data:${e.mimeType};base64,${e.data}`):I(`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=I(`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`,g(ve,`h-3 w-3`));return r.setAttribute(`type`,`button`),r.setAttribute(`aria-label`,`Remove ${e.name??`attachment`}`),r.onclick=()=>{hl.splice(t,1),Ol()},I(`div`,`relative`,n,r)}))}function kl(e){if(hl.length>=Dl){W(`error`,`attachment limit is ${Dl} files per message`);return}if(e.size>33554432){W(`error`,`${e.name||`file`} is too large (32MB max)`);return}let t=new FileReader;t.onload=()=>{let n=t.result;hl.push(Al({data:n.slice(n.indexOf(`,`)+1),mimeType:e.type||`application/octet-stream`,name:e.name||void 0})),Ol()},t.readAsDataURL(e)}function Al({data:e,mimeType:t,name:n}){let r={data:e,mimeType:t,name:n},i=b(`/api/inbox`,r).then(async e=>e.ok?Ii((await e.json()).path):null).catch(()=>null);return{...r,marker:i}}async function jl(e){let t=await Promise.all(e.map(e=>e.marker));return t.every(e=>e!==null)?t:null}var Ml=`pier.draft.`,Nl=e=>`${Ml}${e}`,Pl=0;function Fl(){try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(Ml)&&e.push(n)}for(let t of e){let e=localStorage.getItem(t);e&&!sessionStorage.getItem(t)&&sessionStorage.setItem(t,e),localStorage.removeItem(t)}}catch(e){console.warn(`could not move older drafts out of localStorage`,e)}}var Il=new Map;function Ll(e=K.sessionId(),t=q.value){e&&(t?sessionStorage.setItem(Nl(e),t):sessionStorage.removeItem(Nl(e)))}function Rl(e){++Pl,q.value=sessionStorage.getItem(Nl(e))??``,zl(),hl=Il.get(e)??[],Ol()}function zl(){let e=q.style.height;q.style.height=`auto`;let t=`${Math.min(q.scrollHeight,192)}px`;q.style.height=t,t!==e&&Ps()}var Bl=!1;async function Vl(e,t){let n=(t??q.value).trim(),r=t===void 0?hl:[],i=K.sessionId();if(!(!n&&r.length===0||!i)){if(t===void 0){if(Bl)return;Bl=!0,q.value=``,zl(),Ll(),hl=[],Ol()}try{let t=[];if(r.length){let e=await jl(r);if(e===null){W(`error`,`attachment upload failed`),q.value=[n,q.value.trim()].filter(Boolean).join(`
81
- `),zl(),Ll(),hl=r.map(Al),Ol();return}t=e}let a=[n,...t].filter(Boolean).join(`
82
- `),o=K.sessionState()===`idle`&&e===`auto`;o?K.setState(`streaming`):Cl(),(o||e===`steer`)&&(xl(a),W(`user`,a,!1,Date.now()),Ps(!0));let s=await b(`/api/sessions/${i}/messages`,{text:a,mode:e});if(!s.ok){let e=await x(s,`send failed`);await K.reload(i),W(`error`,e)}}finally{t===void 0&&(Bl=!1)}}}async function Hl(e){let t=K.sessionId();if(!t)return;El([],[]);let n=await b(`/api/sessions/${t}/queue/deliver`,{mode:e});if(!n.ok){let r=await x(n,`Queue ${e} failed`);await K.reload(t),K.sessionId()===t&&W(`error`,r)}}async function Ul(){let e=K.sessionId();if(!e||ml.has(e))return;ml.add(e);let t=pl,n=Pl,r=document.activeElement;try{Ll();let i=await fetch(`/api/sessions/${e}/queue/recall`,{method:`POST`});if(!i.ok){let t=await x(i,`Could not recall queued messages`);K.sessionId()===e&&W(`error`,t);return}let{messages:a}=await i.json(),o=K.sessionId()===e;if(a.length)try{let t=o?q.value:sessionStorage.getItem(Nl(e))??``,i=(t?[t,...a]:a).join(`
83
- `);o&&(q.value=i,zl(),n===Pl&&K.chatVisible()&&document.activeElement===r&&q.focus()),Ll(e,i)}catch(t){W(`error`,`Could not save recalled messages for session ${e}: ${String(t)}\nRecalled messages (not saved):\n${a.join(`
84
- `)}`)}o&&t===pl&&El([],[])}finally{ml.delete(e)}}function Wl(e){K=e,Fl(),_l(),vl();let t=()=>{let e=K.sessionId();e&&fetch(`/api/sessions/${e}/abort`,{method:`POST`})};al.onclick=t,Zc(al,`Stop the running turn`,t,()=>K.sessionState()===`streaming`&&K.chatVisible()),F(`#queue-steer`).onclick=()=>void Hl(`steer`),F(`#queue-restart`).onclick=()=>void Hl(`restart`),F(`#queue-recall`).onclick=()=>void Ul(),tl.onsubmit=e=>{e.preventDefault(),Vl(`auto`)},$c(q,[`/`],`Write a message`,yl,K.chatVisible),q.onfocus=Ns,q.oninput=()=>{zl(),Ll()};let n=!matchMedia(`(pointer: coarse)`).matches;q.onkeydown=e=>{e.isComposing||e.keyCode===229||n&&e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Vl(`auto`))},q.onpaste=e=>{for(let t of e.clipboardData?.items??[]){let e=t.kind===`file`?t.getAsFile():null;e&&kl(e)}let t=e.clipboardData?.getData(`text/plain`)??``,n=t.trim();!n||n===t||(e.preventDefault(),q.setRangeText(n,q.selectionStart??0,q.selectionEnd??0,`end`),zl(),Ll())},U.ondragover=e=>e.preventDefault(),U.ondrop=e=>{e.preventDefault();for(let t of e.dataTransfer?.files??[])kl(t)},F(`#attach`).onclick=()=>dl.click(),dl.onchange=()=>{for(let e of dl.files??[])kl(e);dl.value=``},Cl()}var Gl=`pier.push`,Kl=`/app/sw.js`,ql=()=>/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.maxTouchPoints>1&&/Macintosh/.test(navigator.userAgent),Jl=()=>matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0;function Yl(){return window.isSecureContext?ql()&&!Jl()?`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 Xl=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/Macintosh/,`Mac`],[/Windows/,`Windows`]],Zl=[[/Edg\//,`Edge`],[/Chrome\//,`Chrome`],[/Firefox\//,`Firefox`],[/Safari\//,`Safari`]];function Ql(){let e=navigator.userAgent,t=(t,n)=>t.find(([t])=>t.test(e))?.[1]??n;return`${t(Xl,`Linux`)} · ${t(Zl,`browser`)}${Jl()?` (installed)`:``}`}var $l=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},eu=null;async function tu(){return!(`serviceWorker`in navigator)||!window.isSecureContext?null:(eu??=await navigator.serviceWorker.register(Kl,{scope:`/app/`}).catch(e=>(console.warn(`service worker registration failed`,e),null)),eu)}var nu=(e,t)=>{let n=e?new Uint8Array(e):null;return n?.length===t.length&&n.every((e,n)=>e===t[n])};async function ru(e){let{publicKey:t}=await Ke(`/api/push`,`Could not read this instance's push key`),n=$l(t),r=await e.pushManager.getSubscription();if(r){if(nu(r.options.applicationServerKey,n))return r;await r.unsubscribe()}return e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:n})}async function iu(e){return b(`/api/push/subscribe`,{...e.toJSON(),label:Ql()})}async function au(){cu();let e=await tu();if(!(!e||localStorage.getItem(Gl)!==`on`)&&!(!(`Notification`in window)||Notification.permission!==`granted`))try{await iu(await ru(e))}catch(e){console.warn(`re-registering this browser for notifications failed`,e)}}var ou=null,su=null;function cu(){window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),ou=e,su?.()}),window.addEventListener(`appinstalled`,()=>{ou=null,su?.()})}function lu(e){let t=navigator;(e>0?t.setAppBadge?.(e):t.clearAppBadge?.())?.catch(()=>{})}function uu(){let e=I(`span`,`text-[11.5px]`,``),t=di(`Send a test notification`),n=I(`div`,`flex items-center gap-3`,t,e),r=I(`div`,`flex flex-col gap-4`),i=()=>localStorage.getItem(Gl)===`on`,a=I(`div`,`flex flex-col gap-2`),o=I(`span`,`text-[11.5px]`,``),s=I(`div`,`flex flex-col gap-2`,a,o);async function c(e){R(o,`saving`,`removing…`);try{let t=await b(`/api/push/unsubscribe`,{endpoint:e.endpoint});if(!t.ok)R(o,`failed`,await x(t,`Could not remove it`));else{let t=await(await tu())?.pushManager.getSubscription();t?.endpoint===e.endpoint&&(localStorage.setItem(Gl,`off`),await t.unsubscribe(),p()),R(o,`saved`,`Removed.`)}}catch(e){R(o,`failed`,`Could not remove it: ${String(e)}`)}await l()}async function l(){let e=await S(`/api/push/subscriptions`,`Could not load subscribed devices`);if(!e.ok)return R(o,`failed`,e.error);if(!e.value.devices.length){a.replaceChildren(Ni(`No device is subscribed.`));return}a.replaceChildren(...e.value.devices.map(e=>{let t=di(`Remove`);return t.onclick=()=>{t.disabled=!0,c(e)},Mi(e.label,`subscribed ${Xr(e.createdAt)}`,t,{tag:e.current?ji(`This browser`,`bg-neutral-50 text-neutral-500 ring-neutral-200`):void 0})}))}async function u(){R(e,`saving`,`asking this browser…`);let t=await Notification.requestPermission();if(t!==`granted`)return localStorage.setItem(Gl,`off`),p(),R(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 tu();if(!n)return R(e,`failed`,`This browser refused to register a service worker.`);try{let t=await iu(await ru(n));if(!t.ok)return R(e,`failed`,await x(t,`Could not register this browser`));localStorage.setItem(Gl,`on`),p(),R(e,`saved`,`This browser will be notified when a turn finishes unseen.`),l()}catch(t){R(e,`failed`,`Could not subscribe: ${String(t)}`)}}async function d(){localStorage.setItem(Gl,`off`),p();let t=await(await tu())?.pushManager.getSubscription();t&&(await b(`/api/push/unsubscribe`,{endpoint:t.endpoint}),await t.unsubscribe()),R(e,`idle`,`This browser will not be notified.`),l()}t.onclick=()=>{R(e,`saving`,`sending…`),(async()=>{let t=await b(`/api/push/test`,{});if(!t.ok)return R(e,`failed`,await x(t,`Could not send`));let{sent:n,failed:r}=await t.json();R(e,r?`failed`:`saved`,`Handed ${String(n)} device(s) to their push service${r?`, ${String(r)} refused`:``}.`)})()};function f(){if(!ou)return[];let e=di(`Install Pier`,!0);return e.onclick=()=>{let e=ou;e&&e.prompt().then(()=>e.userChoice).finally(()=>{ou=null,p()})},[I(`div`,`flex items-center gap-3`,e,I(`span`,`text-[11.5px] leading-snug text-neutral-500`,`Its own window and icon — and where notifications look like an app's.`))]}function p(){let e=Yl();if(e){r.replaceChildren(...f(),I(`p`,`text-[12.5px] leading-snug text-neutral-500`,e),s);return}let a=i()&&Notification.permission===`granted`;t.disabled=!a,r.replaceChildren(...f(),ki(`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.`,a,e=>void(e?u():d())),n,s)}return su=p,p(),{el:xi(`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),load:()=>{R(o,`idle`,``),l()}}}var J=F(`#sidebar`),du=F(`#drawer-scrim`),fu=F(`#mobile-title`),pu=F(`#mobile-menu`),mu=F(`#session-meta`);function hu(){delete J.dataset.open,du.classList.add(`hidden`),Cu()}function gu(e,t){fu.textContent=e,fu.classList.toggle(`cursor-pointer`,t),pu.classList.toggle(`hidden`,!t)}var _u=`pier.railClosed`;localStorage.getItem(_u)===`1`&&(document.body.dataset.rail=`closed`);function vu(e){document.body.dataset.rail=e?`closed`:``,localStorage.setItem(_u,e?`1`:`0`),Cu()}function yu(){if(J.dataset.open!==void 0)return hu();J.dataset.open=``,du.classList.remove(`hidden`),Cu()}var bu=window.matchMedia(`(width < 48rem)`),xu=()=>bu.matches;function Su(){xu()?F(`#mobile-bar`).append(mu):F(`#chat-menu`).before(mu)}function Cu(){let e=xu()&&J.dataset.open!==void 0,t=F(`main`);t.inert=e,J.inert=xu()?!e:document.body.dataset.rail===`closed`,F(`#drawer-toggle`).setAttribute(`aria-expanded`,String(e)),e&&!J.contains(document.activeElement)&&F(`#new-session`).focus(),J.inert&&J.contains(document.activeElement)&&F(xu()?`#drawer-toggle`:`#rail-toggle`).focus()}var wu=[F(`#rail-toggle`),F(`#drawer-toggle`)],Tu=`attention absolute -right-0.5 -top-0.5 rounded-full bg-amber-500`,Eu=e=>e===1?I(`span`,`${Tu} h-2 w-2`):I(`span`,`${Tu} 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 Du(e){for(let t of wu)t.querySelector(`.attention`)?.remove(),e&&t.append(Eu(e))}var Ou=20,ku=.35,Au=8;function ju(){let e=-1,t=0,n=!1,r=!1,i=1,a=e=>{J.style.transition=`none`,J.style.transform=`translateX(${String(e-i)}px)`,du.style.transition=`none`,du.classList.remove(`hidden`),du.style.opacity=String(e/i)},o=t=>{J.style.transition=``,J.style.transform=``,du.style.transition=``,du.style.opacity=``,t?(J.dataset.open=``,du.classList.remove(`hidden`),Cu()):hu(),e=-1,r=!1};window.addEventListener(`touchstart`,a=>{if(r||(e=-1,!xu()||a.touches.length!==1))return;let o=a.touches[0],s=J.dataset.open!==void 0;if(i=J.offsetWidth||1,s){if(o.clientX>i)return}else{if(o.clientX>Ou||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)<Au)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=J.getBoundingClientRect().right;o(n?t>i*ku:t>i*.65)};window.addEventListener(`touchend`,s),window.addEventListener(`touchcancel`,s)}function Mu(e){ju(),Cu(),Su(),bu.addEventListener(`change`,()=>{hu(),Su()}),F(`#drawer-toggle`).setAttribute(`aria-controls`,`sidebar`),J.addEventListener(`keydown`,e=>{if(!(!xu()||J.dataset.open===void 0||e.defaultPrevented||e.isComposing)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),hu();else if(e.key===`Tab`){let t=[...J.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())}}}),F(`#drawer-toggle`).onclick=yu,du.onclick=hu,pu.onclick=()=>e.sessionMenu(pu),fu.onclick=()=>{pu.classList.contains(`hidden`)||e.sessionInfo(fu)};let t=F(`#rail-toggle`);t.onclick=()=>vu(document.body.dataset.rail!==`closed`),Xc(t,`meta+b`,`Toggle sidebar`,()=>xu()?yu():vu(document.body.dataset.rail!==`closed`))}var Y,Nu=F(`#session-list`),Pu=F(`#new-session`),Fu=e=>e.modified??e.createdAt;function Iu(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 Lu(e,t){let{top:n,rest:r}=Iu(e),i=[...n,...r].slice(0,t);return{rows:i,hidden:e.length-i.length}}function Ru(e,t,n){let{top:r,rest:i}=Iu(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 zu=8,Bu=`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`,Vu=e=>e.unread,Hu=e=>`${e} subagent${e>1?`s`:``} running`,Uu=e=>e.state===`streaming`||Vu(e)||e.activeRuns>0;function Wu(e){if(!Uu(e))return[];let t=e.state===`streaming`?[`bg-green-500 animate-pulse`,`working…`]:Vu(e)?[`bg-amber-500`,`turn finished — not viewed yet`]:[`bg-sky-500`,Hu(e.activeRuns)],n=I(`span`,`h-2 w-2 flex-none rounded-full ${t[0]}`);return n.title=t[1],[n]}async function Gu(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,Qu(),Y.onTitleChanged()};r(t.trim()||void 0),(await b(`/api/sessions/${e.id}/rename`,{name:t})).ok||r(n)}var Ku=`flex-none text-xs font-medium uppercase leading-5 text-neutral-500`,qu=e=>e.channel&&e.channel!==`web`?[I(`span`,Ku,e.channel[0]??``)]:[];function Ju(e,t=I(`button`,Bu,g(m))){let n=e.id===Y.currentId(),r=I(`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(),Y.sessionMenu(t,e)};let i=I(`button`,`session-open flex min-w-0 flex-1 cursor-pointer items-center gap-1.5 rounded-lg text-left`,I(`span`,`min-w-0 flex-1 truncate`,e.title??`untitled`),...Wu(e));return i.setAttribute(`type`,`button`),n&&i.setAttribute(`aria-current`,`page`),i.onclick=()=>Y.select(e.id),r.dataset.sessionId=e.id,r.append(i,...qu(e),t),r.title=[e.cwd,`active ${Yr(Fu(e))} ago · created ${new Date(e.createdAt).toLocaleDateString()}`,...e.channel&&e.channel!==`web`?[`answering ${e.channel}`]:[]].join(`
85
- `),r}var Yu=()=>`${Y.currentId()??``}\n${Zu}\n${JSON.stringify(Y.sessions())}`,Xu=``,Zu=20;function Qu(){let e=Yu();if(e===Xu)return;Xu=e;let t=Y.sessions(),n=t.filter(Vu);Du(n.length),lu(n.length);let{rows:r,hidden:i}=Lu(t,Zu),a=Nu.querySelector(`.session-more[aria-expanded='true']`),o=a?.closest(`[data-session-id]`)?.dataset.sessionId,s=r.map(e=>Ju(e,e.id===o?a:void 0));if(i>0){let e=I(`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=()=>{Zu+=20,Qu(),Nu.querySelectorAll(`.session-open`)[r.length]?.focus()},s.push(I(`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(Nu.replaceChildren(...s.length?[I(`ul`,`pb-1`,...s)]:[I(`p`,`px-3 py-2 text-sm leading-normal text-neutral-500`,`No sessions yet — create one.`)]),l){let e=[...Nu.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`&&(Nu.querySelector(`#session-load-more`)??Nu.querySelector(`.session-open`)??F(`#new-session`)).focus({preventScroll:!0});jd()}function $u(){if(Pu.getAttribute(`aria-expanded`)===`true`)return B();let e=Y.sessions().find(e=>e.id===Y.currentId())?.cwd,t=He(Y.sessions()).slice(0,zu);if(e&&!t.includes(e)&&t.unshift(e),!t.length)return Ea(Pu,void 0,Y.createSession);Da(Pu,t.map(e=>({path:e,hint:Zr(e)})),e,Y.createSession)}function ed(e){Y=e,Pu.onclick=$u,Xc(Pu,`shift+o`,`New session`,$u,Kc);let t=e=>{let t=Ru(Y.sessions(),Y.currentId(),e);t&&Y.select(t)};el(`shift+[`,()=>t(-1),Kc),el(`shift+]`,()=>t(1),Kc)}var td,nd=F(`#palette`),rd=F(`#palette-input`),id=F(`#palette-list`),ad=F(`#palette-count`),od=[{name:`tasks`,icon:re,label:`Tasks`,detail:`Automation — task definitions and schedules`},{name:`runs`,icon:re,label:`Runs`,detail:`Automation — executions, subagents 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:me,label:`Settings`,detail:`Console — models and providers, agent files and extensions, channels, password, sign out, security`}],sd=7,cd=3,ld=8,ud=80,dd=``,fd,pd,md;function hd(e){dd!==e&&(clearTimeout(md),pd?.abort(),pd=void 0,dd=e,fd=void 0,e&&(md=setTimeout(()=>{let t=pd=new AbortController;S(`/api/search?q=${encodeURIComponent(e)}`,`Search unavailable`,{signal:t.signal}).then(n=>{t.signal.aborted||dd!==e||(pd=void 0,fd=n.ok?{hits:n.value.hits}:{error:n.error},nd.open&&Ad())})},ud)))}var gd=[],_d=0;function vd(e){if(gd.length){_d=(e+gd.length)%gd.length;for(let[e,{el:t}]of gd.entries())t.classList.toggle(`bg-indigo-50`,e===_d),t.setAttribute(`aria-selected`,String(e===_d));gd[_d]?.el.scrollIntoView({block:`nearest`})}}var yd=e=>e.hit?.at??e.session?.createdAt;function bd(e){let t=I(`span`,`min-w-0 flex-1 truncate text-neutral-500`);for(let n of e.replaceAll(/\s+/g,` `).split(``)){let[e=``,r]=n.split(``,2);r===void 0?t.append(e):t.append(I(`span`,`font-medium text-neutral-800`,e),r)}return t}var xd=`flex min-w-0 flex-1 items-baseline gap-2`,Sd=`shrink-0 truncate`,Cd=`min-w-[2.5em] truncate text-[0.8125rem] text-neutral-400`,wd=`flex-none text-[0.75rem] tabular-nums text-neutral-400`,Td=`flex h-7 w-7 flex-none items-center justify-center rounded-[8px] bg-neutral-100 text-neutral-500`;function Ed(e){let t=I(`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(I(`span`,Td,g(e.icon,`h-4 w-4`)));let n=I(`div`,`flex min-w-0 flex-1 flex-col`),r=I(`div`,`flex items-center gap-2`);e.session&&r.append(...Wu(e.session));let i=I(`span`,xd,I(`span`,`${Sd} ${e.detail?`max-w-[calc(100%-3em)]`:`max-w-full`}`,e.label));e.detail&&i.append(I(`span`,Cd,e.detail)),r.append(i);let a=yd(e);return a!==void 0&&r.append(I(`span`,wd,Yr(a))),n.append(r),e.hit&&n.append(I(`div`,`flex items-baseline gap-2 text-[0.8125rem] leading-5`,I(`span`,`flex-none text-[0.75rem] text-neutral-400`,e.hit.role===`user`?`You`:`Agent`),bd(e.hit.snippet))),t.append(n),t.onclick=e.open,t}var Dd=e=>I(`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 Od(e,t){let n=I(`li`,`px-2 py-2 pl-12 text-[0.8125rem] leading-5 text-neutral-400`,e);return t&&(n.title=t),n}var kd=e=>e.channel&&e.channel!==`web`?e.channel:``;function Ad(){let e=rd.value.trim(),t=e.toLowerCase().split(/\s+/).filter(Boolean),n=e=>{let n=e.toLowerCase();return t.every(e=>n.includes(e))},r=e=>()=>{nd.close(),e()},i=td.sessions(),a=new Map(i.map(e=>[e.id,e])),{top:o,rest:s}=Iu(i),c=[...o,...s],l=e=>({icon:oe,label:e.title??Qr(e.cwd),detail:[Zr(e.cwd),kd(e)].filter(Boolean).join(` · `),open:r(()=>void td.select(e.id)),session:e}),u=e=>({icon:te,label:Qr(e),detail:e,open:r(()=>void td.createSession(e))}),d=od.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(()=>td.openConsole(e))})),f={icon:te,label:`New session in…`,detail:`Pick a directory`,open:r($u)},p=[];if(e){let t=He(i).filter(e=>n(Zr(e))).slice(0,cd),o=c.filter(e=>n(`${e.title??``} ${e.cwd} ${kd(e)}`)).slice(0,ld),s=new Set(o.map(e=>e.id)),m=o.map(l);if(dd!==e||!fd)m.push(Od(`Searching messages…`));else if(`error`in fd)m.push(Od(`Message search unavailable`,fd.error));else{for(let e of fd.hits){if(m.length>=ld)break;let t=a.get(e.sessionId);!t||s.has(t.id)||m.push({...l(t),hit:e,open:r(()=>void td.select(t.id).then(()=>Is(e.role,e.at)))})}m.length||m.push(Od(`No sessions match`))}p.push([`Actions`,[...t.map(u),...n(f.label)?[f]:[],...d]],[`Sessions`,m])}else{let e=a.get(td.currentId()??``);p.push([`Running`,c.filter(Uu).map(l)],[`Recent`,c.filter(e=>!Uu(e)).slice(0,sd).map(l)],[`Actions`,[...e?[u(e.cwd)]:[],f]],[`Console`,d])}gd=[];let m=[];for(let[e,t]of p)if(t.length){m.push(Dd(e));for(let e of t){if(e instanceof HTMLElement){m.push(e);continue}let t=Ed(e);gd.push({el:t,open:e.open}),m.push(t)}}id.replaceChildren(...m.length?m:[Od(`Nothing matches`)]),ad.textContent=`${gd.length} ${gd.length===1?`row`:`rows`}`,vd(Math.min(_d,Math.max(0,gd.length-1)))}function jd(){nd.open&&Ad()}function Md(){if(nd.open)return nd.close();rd.value=``,_d=0,hd(``),Ad(),nd.showModal(),rd.focus(),td.loadSessions().then(jd)}function Nd(e){td=e;let t=F(`#open-palette`);t.onclick=Md,Xc(t,`k`,`Search sessions, messages and Console`,Md,()=>nd.open||ca()),nd.onclick=e=>{e.target===nd&&nd.close()},nd.onclose=()=>hd(``),rd.oninput=()=>{_d=0,hd(rd.value.trim()),Ad()},rd.onkeydown=e=>{let t=la(e);if(t!==void 0){e.preventDefault(),vd(_d+t);return}e.key===`Enter`&&!e.ctrlKey&&(e.preventDefault(),gd[_d]?.open())}}var Pd=0,Fd=e=>`${e.provider}/${e.id}`,Id=null;async function Ld(){let{modelMenu:e}=await Ke(`/api/settings`,`Could not read the pinned model menu`);return e}function Rd(e){let t=I(`button`,`flex w-full min-w-0 cursor-pointer items-center gap-2 px-3 py-1.5 text-left hover:bg-neutral-100`,g(o,`h-3 w-3 text-indigo-600 ${e.checked?``:`invisible`}`),I(`span`,`truncate`,e.label));return e.hint&&t.append(I(`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 zd({models:e,current:t,thinkingLevel:n,thinkingLevels:r,onPick:i,onThinkingPick:a}){let o=n,s=I(`div`,`flex w-full min-w-0 flex-col sm:min-w-72`),c=I(`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`,c.append(u),r.length){let e=document.createElement(`details`),t=I(`span`,`ml-auto font-medium text-indigo-700`,Se(o)),n=I(`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`,I(`span`,`font-medium`,`Reasoning effort`),t,g(l,`chev h-3 w-3 text-neutral-400`)),i=I(`fieldset`,`grid grid-cols-2 gap-1 rounded-xl bg-neutral-50 p-1`);i.append(I(`legend`,`sr-only`,`Reasoning effort`));let s=`reasoning-${++Pd}`;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=Se(o),m(u.value),a(o))},i.append(I(`label`,`relative cursor-pointer`,n,I(`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`,Se(e))))}e.append(n,i),c.append(e)}let d=I(`div`,`max-h-72 overflow-y-auto py-1`),f=new Map(e.map(e=>[Fd(e),e])),p=e=>{let n=(Id??[]).map(e=>({e,model:f.get(Fd(e))})).filter(t=>!!t.model&&(!e||Fd(t.model).toLowerCase().includes(e)));n.length&&d.append(I(`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})=>Rd({label:n.id,hint:Se(e.thinking),title:e.note,checked:!!t&&Fd(t)===Fd(n)&&o===e.thinking,onSelect:()=>i(n,e.thinking)})),I(`div`,`my-1 border-t border-neutral-100`))},m=n=>{d.replaceChildren();let r=n.trim().toLowerCase();p(r);let a=new Map;for(let t of e){if(r&&!Fd(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(I(`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&&Fd(t)===Fd(e)),o=document.createElement(`details`);o.open=a||r.length>0;let s=I(`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`,g(l,`chev h-3 w-3`),I(`span`,`truncate`,e),I(`span`,`ml-auto flex-none normal-case text-neutral-300`,String(n.length)));o.append(s,...n.map(e=>Rd({label:e.id,checked:!!t&&Fd(t)===Fd(e),onSelect:()=>i(e)}))),d.append(o)}};return u.oninput=()=>m(u.value),m(``),Ld().then(e=>{let t=JSON.stringify(e)!==JSON.stringify(Id);Id=e,t&&m(u.value)}).catch(e=>Fc(`model menu unavailable`,e)),s.append(c,d),queueMicrotask(()=>u.focus()),s}function Bd(e,t,n,r){let i=L(t.model?`${t.model.id}${t.thinking?` · ${Se(t.thinking)}`:``}`:t.thinking?`Pi default · ${Se(t.thinking)}`:`Pi default`,`${wi} flex items-center gap-1.5 ${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=zd({models:n,current:t.model,thinkingLevel:t.thinking??`medium`,thinkingLevels:[...Mo],onPick:(e,n)=>{B(),r({model:e,thinking:n??t.thinking})},onThinkingPick:e=>{t={...t,thinking:e},r(t)}}),a=L(`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=()=>{B(),r({model:null,thinking:null})};let o=I(`div`,`flex flex-col`);o.append(e,I(`div`,`border-t border-neutral-200`),a),_a(i,o)},Si(e,i)}var X;function Vd(e){X=e,el(Hd,()=>{X.currentSession()&&(B(),X.toggleFiles())},Kc)}var Hd=`i`,Ud=F(`#chat-title`),Wd=F(`#chat-menu`),Gd=F(`#session-meta`),Kd=null,qd=new Map,Jd=e=>`${e.provider}/${e.id}`,Z=null,Yd=null,Xd=null,Zd=null;function Qd(){Z=null,Yd=null,Xd=null,Zd=null,cf()}function $d(e,t,n,r){Z=e,Yd=t,Xd=n,Zd=r,rf()}function ef(e){Zd=e.completedAt,Yd&&={...Yd,tokens:e.tokens},cf()}var tf=null;function nf(e){tf=e===null?null:Qr(e),rf()}function rf(){let e=X.currentSession();e&&(tf=null),Ud.textContent=e?e.title??Qr(e.cwd):tf??X.currentId()??`no session`,Ud.classList.toggle(`cursor-pointer`,!!e),Ud.title=e?`Session info`:``,Ud.onclick=e?()=>lf(Ud,e):null,Wd.classList.toggle(`hidden`,!e),e&&(Wd.onclick=()=>gf(Wd,e)),cf(),X.syncBar()}var af=70,of=(e,t)=>Math.min(100,Math.round(e/t.contextWindow*100)),sf=e=>e.tokens===null?`?/${Ce(e.contextWindow)}`:`${Ce(e.tokens)}/${Ce(e.contextWindow)} · ${100-of(e.tokens,e)}% left`;function cf(){let e=Yd,t=e?.tokens??null,n=X.currentId(),r=X.currentSession()?.activeRuns??0,i=[];if(r>0){let e=I(`button`,`flex flex-none cursor-pointer items-center gap-1 rounded bg-sky-50 px-1.5 py-px font-medium text-sky-700 hover:bg-sky-100`,g(ie,`spinner h-3 w-3`),`${r} running`);e.title=`${Hu(r)} · show the newest`,e.onclick=()=>{Ls()||W(`error`,`no run card left in this transcript — reload the session to see it`)},i.push(e)}if(!n&&tf&&i.push(I(`span`,`flex flex-none items-center gap-1.5 text-neutral-500`,g(ie,`spinner`),`starting…`)),n){let e=(e,t)=>{let r=I(`button`,`cursor-pointer font-mono ${t}`,e);return r.title=`Change model or reasoning`,r.onclick=()=>void uf(r,n),r};Z&&i.push(e(Z.id,`min-w-0 truncate rounded bg-indigo-50 px-1.5 py-px font-medium text-indigo-700 hover:bg-indigo-100`)),Xd&&i.push(e(Xd,`flex-none text-neutral-500 hover:text-indigo-700`))}let a=0;if(e&&t!==null){a=of(t,e);let n=a>=90?`text-red-700`:a>=af?`text-amber-700`:`text-neutral-500`;i.push(I(`span`,`flex-none font-mono ${n}`,Ce(t).toLowerCase()))}let o=i.flatMap((e,t)=>t===0?[e]:[I(`span`,`flex-none text-neutral-300`,`·`),e]);Gd.replaceChildren(...o),Gd.classList.toggle(`hidden`,i.length===0),Gd.classList.toggle(`flex`,i.length>0),Gd.toggleAttribute(`data-urgent`,!n&&!!tf||r>0||a>=af)}function lf(e,t,n){let i=[[`Directory`,t.cwd],[`Session`,t.id]],a=t.id===X.currentId();if(a&&(i.push([`Model`,Z?.id??`—`]),i.push([`Reasoning`,Xd??`—`]),i.push([`Context`,Yd?sf(Yd):`—`])),i.push([`Created`,$r(t.createdAt),Xr(t.createdAt)]),a){let e=Zd;i.push(e===null?[`Last reply`,`—`]:[`Last reply`,$r(e),Xr(e)])}let o=I(`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=I(`button`,`icon-btn h-11 w-11 sm:h-8 sm:w-8`,g(ve));s.setAttribute(`aria-label`,`Close session info`),s.onclick=B;let c=I(`div`,`sticky top-0 z-10 flex items-start gap-2 bg-white pb-2`,I(`div`,`min-w-0 flex-1`,I(`div`,`text-sm font-medium text-neutral-500`,`Session info`),I(`h2`,`mt-1 [overflow-wrap:anywhere] text-lg leading-7 font-semibold text-neutral-900`,t.title??Qr(t.cwd))),s);if(n){let e=I(`button`,`icon-btn h-11 w-11 sm:h-8 sm:w-8`,g(r));e.setAttribute(`aria-label`,`Back to session actions`),e.onclick=n,c.prepend(e)}o.append(c);let l=I(`dl`,``);for(let[e,t,n]of i){let r=e===`Directory`||e===`Session`,i=I(`dd`,`min-w-0 flex items-start gap-2 text-neutral-700 ${r?`font-mono text-sm leading-6`:``}`,I(`span`,`min-w-0 flex-1 [overflow-wrap:anywhere]`,t));if(r){let n=ai(`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(I(`span`,`ml-2 inline-block font-sans text-[13px] leading-5 text-neutral-500`,n));let a=e===`Model`||e===`Created`;l.append(I(`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`:``}`,I(`dt`,`text-[15px] text-neutral-500`,e===`Session`?`Session ID`:e),i))}return o.append(l),_a(e,o)}async function uf(e,t,n){let r=I(`div`,`px-3 py-3 text-[15px] text-neutral-500`,`Loading models…`),i=I(`div`,`w-[min(24rem,calc(100vw-2rem))] min-w-0 max-sm:w-full`,r),a=r;n&&i.prepend(mf(e,n,`Close model picker`)),_a(e,i);let o=()=>a.isConnected&&!a.closest(`[inert]`),s=``,c=(n,r,o)=>{let c=JSON.stringify([n,r,o]);if(c===s)return;s=c;let l=zd({models:n,current:t===X.currentId()?Z:null,thinkingLevel:r,thinkingLevels:o,onPick:(e,n)=>{B(),df(t,e,n)},onThinkingPick:e=>void pf(t,e)});a.replaceWith(l),a=l,_a(e,i)},l=t===X.currentId()&&Z?qd.get(Jd(Z)):void 0;Kd&&l&&Xd&&c(Kd,Xd,l);try{let[e,n]=await Promise.all([Ke(`/api/sessions/${t}/models`,`Could not load models`),Ke(`/api/sessions/${t}/thinking`,`Could not read the reasoning level`)]);if(Kd=e,t===X.currentId()&&Z&&qd.set(Jd(Z),n.levels),!o())return;c(e,n.level,n.levels)}catch(e){s?W(`error`,`model options are stale: ${String(e)}`):o()?(r.textContent=`Could not load models: ${String(e)}`,r.setAttribute(`role`,`alert`)):W(`error`,`model options failed: ${String(e)}`)}}async function df(e,t,n){await ff(e,t)&&n&&await pf(e,n)}async function ff(e,t){let n=Z;e===X.currentId()&&(Z=t,rf());let r=await b(`/api/sessions/${e}/model`,t);if(!r.ok){let{error:t}=await r.json().catch(()=>({}));return e===X.currentId()&&(Z=n,rf()),W(`error`,`model change failed: ${t??r.status}`),!1}let{model:i}=await r.json();return e===X.currentId()&&i&&(Z=i,rf()),!0}async function pf(e,t){let n=await b(`/api/sessions/${e}/thinking`,{level:t});if(!n.ok){W(`error`,`reasoning change failed: ${n.status}`);return}let{level:r}=await n.json();e===X.currentId()&&(Xd=r,cf())}function mf(e,t,n){let i=I(`button`,`icon-btn h-11 w-11`,g(r));i.setAttribute(`aria-label`,`Back to session actions`),i.onclick=()=>gf(e,t);let a=I(`button`,`icon-btn h-11 w-11`,g(ve));a.setAttribute(`aria-label`,n),a.onclick=B;let o=I(`span`,`min-w-0 flex-1 truncate text-sm font-medium`,t.title??Qr(t.cwd));return o.title=o.textContent??``,I(`div`,`flex items-center gap-2 border-b border-neutral-200 pb-2 mb-2`,i,o,a)}async function hf(e,t){let n=I(`p`,`px-3 py-2 text-[15px] text-neutral-500`,`Loading chats…`),r=I(`div`,`w-[min(24rem,calc(100vw-2rem))] min-w-0 max-sm:w-full`,mf(e,t,`Close chat picker`),I(`div`,`px-3 pb-1 text-sm font-medium text-neutral-500`,`Continue in a direct message`),I(`p`,`px-3 pb-2 text-[13px] text-neutral-500`,`DMs the bot has seen. A DM appears here after its first message to the bot.`),n);_a(e,r);let i=await S(`/api/handoff/targets`,`Could not list chats`);if(!r.isConnected)return;if(!i.ok){n.textContent=i.error,n.setAttribute(`role`,`alert`);return}if(!i.value.targets.length){n.textContent=`No DMs yet — message the bot once in Lark or Slack, then come back.`;return}let a=I(`p`,`hidden px-3 pt-1 text-[13px] text-red-600`);a.setAttribute(`role`,`alert`);let o=I(`div`,``);o.dataset.list=``;for(let e of i.value.targets){let n=I(`button`,`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`,I(`span`,`min-w-0 truncate`,`${e.platform[0].toUpperCase()}${e.platform.slice(1)} · ${e.name||e.chatId}`));n.onclick=async()=>{let n=await b(`/api/handoff`,{sessionId:t.id,platform:e.platform,chatId:e.chatId});if(n.ok)return B();a.textContent=(await n.json().catch(()=>({}))).error??`handoff failed: ${String(n.status)}`,a.classList.remove(`hidden`)},o.append(n)}n.replaceWith(o,a),o.querySelector(`button`)?.focus({preventScroll:!0})}function gf(e,t){let n=t.id===X.currentId();ya(e,[{label:`Rename…`,onSelect:()=>{B(),Gu(t)}},{label:`Session info`,onSelect:()=>lf(e,t,()=>gf(e,t))},{label:`New session here`,separatorBefore:!0,hint:Zr(t.cwd),onSelect:()=>{B(),X.createSession(t.cwd)}},{label:`Browse files`,hint:n?Gc(Hd):``,onSelect:()=>{B(),X.openFiles(n?void 0:t.cwd)}},{label:`Continue in Lark/Slack…`,...t.channel&&t.channel!==`web`?{hint:`answers in ${t.channel}`,disabled:!0}:{},onSelect:()=>void hf(e,t)},{label:`Model & reasoning…`,separatorBefore:!0,hint:n?Z?.id??`…`:``,onSelect:()=>void uf(e,t.id,t)}],t.title??Qr(t.cwd))}var _f=`pier.theme`,vf=[`system`,`light`,`dark`],yf=window.matchMedia(`(prefers-color-scheme: dark)`),bf={system:ce,light:ge,dark:h},xf=()=>{let e=null;try{e=localStorage.getItem(_f)}catch{return`system`}return e===`light`||e===`dark`?e:`system`},Sf=()=>{let e=xf();return e===`system`?yf.matches?`dark`:`light`:e};function Cf(){let e=Sf();document.documentElement.dataset.theme=e;let t=getComputedStyle(document.documentElement).getPropertyValue(`--workbench-canvas`).trim();F(`meta[name="theme-color"]`).setAttribute(`content`,t),window.dispatchEvent(new Event(`pier:theme`))}function wf(){let e=F(`#theme-toggle`),t=()=>{let t=xf();e.title=`Theme: ${t}${t===`system`?` (${Sf()})`:``}`,e.replaceChildren(g(bf[t])),e.setAttribute(`aria-label`,e.title),Cf()};e.onclick=()=>{let e=vf[(vf.indexOf(xf())+1)%vf.length];try{e===`system`?localStorage.removeItem(_f):localStorage.setItem(_f,e)}catch{}t()},yf.addEventListener(`change`,t),t()}var Tf=`https://github.com/timqi/pier`,Ef=[`text-neutral-400`,`hover:text-neutral-700`],Df=[`rounded-full`,`bg-emerald-50`,`px-1.5`,`text-emerald-700`,`ring-1`,`ring-inset`,`ring-emerald-600/20`,`hover:bg-emerald-100`],Of=18e5,kf=null,Af=F(`#version`);function jf(e){let t=kf?.available===!0&&kf.latest!==null;Af.textContent=`v${e}`,Af.title=t?`Pier ${kf?.latest} is out`:``,Af.classList.remove(...t?Ef:Df),Af.classList.add(...t?Df:Ef)}var Mf=(e,t=`px-3 py-1 text-[12px] leading-snug text-neutral-500`)=>I(`p`,t,e);function Nf(){let e=I(`div`,`flex w-72 flex-col gap-1 py-1`);if(!kf)return e.append(Mf(`Checking the registry…`)),e;let{current:t,latest:n,available:r,canApply:i,problem:a}=kf,o=I(`span`,``,``),s=(e,t)=>R(o,e?`failed`:`idle`,t),c=I(`div`,`flex items-center gap-2 px-3 py-1.5`);if(e.append(Mf(r?`Pier ${n} is out`:`Pier ${t}`,`px-3 py-1 text-[12.5px] font-medium text-neutral-700`),Mf(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.`)),a&&e.append(Mf(a,`mx-3 my-1 rounded-md bg-red-50 px-2 py-1.5 text-[11.5px] leading-snug text-red-700`)),r&&i&&!a){let e=di(`Update now`,!0);e.onclick=()=>void(async()=>{e.disabled=!0,s(!1,`starting the updater…`);let t=await b(`/api/update`,{});if(!t.ok)return e.disabled=!1,s(!0,await x(t,`Could not update`));let{draining:n}=await t.json();s(!1,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.`)})(),c.append(e)}c.append(Object.assign(I(`a`,`btn text-[12.5px] no-underline`,`Source`),{href:r?`${Tf}/releases`:Tf,target:`_blank`,rel:`noreferrer`,title:`Pier is free software (AGPL-3.0)`})),e.append(c,I(`div`,`px-3`,o)),r&&!i&&!a&&e.append(Mf(`No service manager owns this Pier, so it cannot restart itself — update it with: pier update`));let l=ki(`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.`,kf.autoUpdate,e=>void(async()=>{kf&&(kf.autoUpdate=e);let t=await b(`/api/settings`,{autoUpdate:e},`PUT`);t.ok||(kf&&(kf.autoUpdate=!e),u&&(u.checked=!e),s(!0,await x(t,`Could not save`)))})()),u=l.querySelector(`input`);return u&&(u.disabled=!i),e.append(I(`div`,`mt-1 border-t border-neutral-200 px-3 pb-1 pt-2`,l)),e}async function Pf(e){let t=await S(`/api/update`,`Update check failed`);t.ok&&jf((kf=t.value).current||e)}function Ff(e){jf(e),Af.onclick=e=>{e.preventDefault(),_a(Af,Nf())};let t=()=>void Pf(e);t(),setInterval(t,Of)}var Q,If=F(`#chat-header`),Lf=F(`#chat-title`),Rf=[If,U,F(`#composer`)],zf=()=>Kf===null,Bf,Vf,Hf,Uf=new Map,Wf=new Map,Gf=new Map,Kf=null,qf=0,Jf=[`files`],Yf=new Map,Xf={tasks:`Tasks`,runs:`Runs`,activity:`Activity`,boards:`Boards`,settings:`Settings`,files:`Files`},Zf=[`tasks`,`runs`,`activity`],Qf=`Automation`,$f=F(`#automation-view`),ep=F(`#automation-tabs`),tp=e=>Zf.includes(e)?`tasks`:e;function np(e,t){let n=e!==null&&Zf.includes(e);if($f.classList.toggle(`hidden`,!n),$f.classList.toggle(`flex`,n),!n)return;let r=[];if(e===`tasks`&&!t){let e=di(`New task`,!0);e.classList.add(`ml-auto`),e.disabled=!Bf,e.onclick=()=>Bf?.create(),r.push(e)}ep.replaceChildren(fi(Qf),...Zf.map(t=>gi(Xf[t],t===e,()=>sp(t))),...r)}var rp=e=>Bf?.refresh(e),ip=()=>Vf?.refresh(),ap=()=>Hf?.refresh();function op(){Kf?gu(Zf.includes(Kf)?Qf:Xf[Kf],!1):gu(Lf.textContent??``,Q.currentSession()!==void 0)}function sp(e,t,n){if(Jf.includes(e)){let t=yp();t&&(t.kind!==`console`||t.name!==e)&&Yf.set(e,t)}xp({kind:`console`,name:e,arg:t,query:n}),hu(),Kf=e;for(let e of Rf)e.classList.add(`hidden`);wl();for(let[t,n]of Uf)t!==e&&n.hide();for(let[t,n]of Gf)n.classList.toggle(`bg-indigo-50`,t===tp(e));np(e,t),op(),cp(e,t,n,++qf)}async function cp(e,t,n,r){let i=Uf.get(e);if(!i){let t=Wf.get(e);if(!t){let n=F(`#${e}-view`);t=wp[e](n).catch(t=>(console.warn(`${e} view failed to load`,t),ti(n,()=>n.replaceChildren(I(`p`,`p-4 text-[13px] text-red-600`,`Could not load ${Xf[e]} — reload the page.`))))),Wf.set(e,t)}i=await t,Uf.set(e,i),Wf.delete(e)}Kf===e&&r===qf&&(i.show(t,n),e===`tasks`&&np(e,t))}var lp=e=>sp(`tasks`,e),up=(e={},t)=>sp(`runs`,t,new URLSearchParams(e).toString()),dp=e=>up({},e),fp=(e,t)=>sp(`files`,e,t?new URLSearchParams({select:t}).toString():void 0),pp=(e,t)=>{Kf===e?hp(e):sp(e,t)},mp=e=>pp(`files`,e);function hp(e){let t=Q.currentId(),n=Yf.get(e)??(t?{kind:`session`,id:t}:null);Yf.delete(e),n?xp(n):(history.replaceState(null,``,`#/`),gp())}function gp(){if(Kf){Kf=null;for(let e of Uf.values())e.hide();for(let e of Gf.values())e.classList.remove(`bg-indigo-50`);np(null);for(let e of Rf)e.classList.remove(`hidden`);wl(),op(),Q.maybeAckRead()}}var _p=e=>e.kind===`session`?`#/session/${encodeURIComponent(e.id)}`:`#/${e.name}${e.arg?`/${encodeURIComponent(e.arg)}`:``}${e.query?`?${e.query}`:``}`,vp={config:`files`,channels:`channels`,providers:`models`};function yp(){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 vp[n]?{kind:`console`,name:`settings`,arg:vp[n]}:Object.hasOwn(Xf,n)?{kind:`console`,name:n,arg:a,query:i}:n===`session`&&a?{kind:`session`,id:a}:null}var bp=!1;function xp(e,t=!1){if(bp)return;let n=_p(e);location.hash!==n&&(t?history.replaceState(null,``,n):location.hash=n)}var Sp=e=>xp({kind:`session`,id:e});function Cp(){let e=yp(),t=Q.sessions(),n=Q.currentId(),r=e?.kind===`session`?e.id:null,{top:i,rest:a}=Iu(t),o=r??n??(i[0]??a[0])?.id??null;bp=!0;try{o&&o!==n&&Q.select(o),e?.kind===`console`?sp(e.name,e.arg,e.query):gp(),o||rf()}finally{bp=!1}e?.kind!==`console`&&o&&xp({kind:`session`,id:o},!0)}var wp={tasks:async e=>Bf=(await Gi(async()=>{let{createTasksView:e}=await import(`./tasks-8l1M8EJU.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(),up,lp),runs:async e=>Vf=(await Gi(async()=>{let{createRunsView:e}=await import(`./runs-DtvDXSfo.js`);return{createRunsView:e}},__vite__mapDeps([2,1]))).createRunsView(e,Q.select,up,lp),activity:async e=>Hf=(await Gi(async()=>{let{createActivityView:e}=await import(`./activity-dxSOEHmf.js`);return{createActivityView:e}},[])).createActivityView(e,Q.select,dp),boards:async e=>(await Gi(async()=>{let{createBoardsView:e}=await import(`./boards-BRwn5UZi.js`);return{createBoardsView:e}},[])).createBoardsView(e,Q.select),files:async e=>(await Gi(async()=>{let{createExplorerView:e}=await import(`./explorer-CCJQ22Dp.js`);return{createExplorerView:e}},[])).createExplorerView(e,()=>Q.currentSession(),e=>sp(`files`,e),()=>hp(`files`)),settings:async e=>(await Gi(async()=>{let{createSettingsView:e}=await import(`./settings-CJbHCEZo.js`);return{createSettingsView:e}},[])).createSettingsView(e,()=>He(Q.sessions()),e=>sp(`settings`,e),fp)};function Tp(e){Q=e;for(let e of[`tasks`,`boards`,`settings`]){let t=F(`#open-${e}`);Gf.set(e,t),t.onclick=()=>sp(e)}let t=F(`#console-section`);t.open=localStorage.getItem(`pier.consoleCollapsed`)!==`1`,t.ontoggle=()=>localStorage.setItem(`pier.consoleCollapsed`,t.open?`0`:`1`),window.onhashchange=Cp}var Ep=[],Dp=null,Op=0,kp=0,Ap=!1,$=null,jp=`idle`,Mp=null,Np=0,Pp=!1,Fp=!1;async function Ip(e){let t=++Op;++kp,Ap=!1,gp(),hu(),$=null,Mp?.close(),Mp=null,Ec(),Tl([]),Qd(),nf(e),Dc(!0),Fp=!0,Cl();let n=await b(`/api/sessions`,{cwd:e});if(t!==Op)return;if(Fp=!1,!n.ok){Dc(!1),nf(null),Cl(),W(`error`,`session create failed: ${n.status}`);return}let{id:r}=await n.json();t===Op&&(Ep.unshift({id:r,cwd:e,createdAt:Date.now(),state:`idle`,unread:!1,channel:`web`,activeRuns:0}),await qp(r),$===r&&yl())}function Lp(e){Ep=e.map(e=>({...e,title:Be(e.title)})),Ep.sort((e,t)=>t.createdAt-e.createdAt),Qu(),rf(),zp()}var Rp=Ue(async()=>{Lp(await Ke(`/api/sessions`,`Could not load sessions`))});function zp(){if(document.hidden||!document.hasFocus()||!zf())return;let e=Ep.find(e=>e.id===$);e?.unread&&(e.unread=!1,Qu(),fetch(`/api/sessions/${e.id}/read`,{method:`POST`}))}function Bp(){return Ep.find(e=>e.id===$)??(Dp&&Dp.id===$?Dp:void 0)}async function Vp(e){let t=await S(`/api/sessions/${e}`,`failed to load session`);$!==e||!t.ok||(Dp={...t.value,title:Be(t.value.title)},rf())}function Hp(e,t){let n=Ep.find(t=>t.id===e);!n||n.title||!t.trim()||(n.title=t.trim().slice(0,80),Qu(),rf())}function Up(e){jp=e;let t=Ep.find(e=>e.id===$);t&&(t.state=e),Qu(),rf(),Cl(),e===`idle`&&Rp()}function Wp(e){if(!(e.sessionId!==$||e.seq<=Np))switch(Np=e.seq,e.type){case`turn-start`:Pp=!0;break;case`system-input`:Sc(),Js(e.text,e.origin);break;case`task-status`:Ko(e.run);break;case`user-message`:{let t=Le(e.text).text;if(Hp(e.sessionId,t),bl(t))break;Sc(),W(`user`,e.text,!1,e.ts),Ps();break}case`text-start`:Sc();break;case`text-delta`:xc(e.text);break;case`thinking-delta`:Sc(),bs(e.ts,e.text);break;case`tool-start`:Sc(),vs(e.ts,e.toolCallId,e.toolName,e.args);break;case`tool-end`:ys(e.toolCallId,e.isError,e.output);break;case`turn-end`:Pp=!1,wc(e.text,e.meta),e.meta&&ef(e.meta);break;case`queue-state`:El(e.steering,e.followUp);break;case`queue-recovery`:Tl(e.batches,e.uncertain);break;case`context-compacted`:Sc(),W(`system`,`Context compacted — ${Ce(e.before)} → ${Ce(e.after)}`,!1,e.ts),Ps();break;case`error`:gs(),W(`error`,e.message);break;case`state`:e.state===`idle`&&Pp&&(Pp=!1,Tc()),e.state===`idle`&&El([],[]),Up(e.state)}}function Gp(){let e=new EventSource(`/api/events`);e.onopen=()=>{Rp(),rp(),ip(),ap()},e.onerror=()=>Bc(e,`Workspace`),e.onmessage=e=>{let t=JSON.parse(e.data);if(t.type===`sessions-changed`){Rp();return}if(t.type===`tasks-changed`||t.type===`task-run-changed`||t.type===`task-message-changed`||t.type===`task-group-changed`){rp(t.type===`task-run-changed`?t.taskId:void 0),ip(),ap(),t.type===`task-run-changed`&&Rp();return}if(ap(),t.sessionId===$)return;let n=Ep.find(e=>e.id===t.sessionId);n&&(n.state=t.state,Qu())}}function Kp(e,t,n){Mp?.close();let r=new EventSource(`/api/sessions/${e}/events?after=${t}`),i=()=>Mp===r&&$===e&&n===kp;r.onmessage=e=>{i()&&Wp(JSON.parse(e.data))},r.addEventListener(`reset`,()=>{i()&&Jp(e)}),r.onerror=()=>{i()&&Bc(r,`Session`)},Mp=r}async function qp(e){gp(),hu(),Sp(e),!(e===$&&(Mp||Ap))&&(++Op,++kp,Fp=!1,Ll(),$=e,Dp=null,Ep.some(t=>t.id===e)||Vp(e),jp=Ep.find(t=>t.id===e)?.state??`idle`,Rl(e),Qu(),rf(),zp(),await Jp(e))}async function Jp(e){if($!==e)return;let t=++kp;Mp?.close(),Mp=null,Ap=!0,Ec(),El([],[]),Tl([]),Qd(),Pp=!1,Sl(),Np=0,Dc(!0);let n=await S(`/api/sessions/${e}/history`,`failed to load session`);if($!==e||t!==kp)return;if(Ap=!1,!n.ok){Dc(!1),W(`error`,n.error);return}let r=n.value;Oc(r.turns,r.state,r.backgroundRuns),Np=r.lastSeq,Pp=r.state===`streaming`,Up(r.state),El(r.queue.steering,r.queue.followUp),Tl(r.queueRecovery,r.queueUncertain);let i=r.turns.reduce((e,t)=>t.meta?.completedAt??e,null);$d(r.model,r.context,r.thinkingLevel,i),Kp(e,`${r.epoch}:${r.lastSeq}`,t)}Ic(),ye(),zc(),wf();var Yp=async e=>{$===e&&await Jp(e)};Es({sessionId:()=>$,sessionCwd:()=>Bp()?.cwd??null,sessionChannel:()=>Bp()?.channel??null,sessionState:()=>jp,select:e=>void qp(e),showRun:dp,send:(e,t)=>void Vl(e,t),ownTurn:e=>{xl(e),Up(`streaming`)},reload:Yp}),Wl({sessionId:()=>$,starting:()=>Fp,sessionState:()=>jp,chatVisible:zf,setState:Up,reload:Yp}),Mu({sessionMenu:e=>{let t=Bp();t&&gf(e,t)},sessionInfo:e=>{let t=Bp();t&&lf(e,t)}}),ed({sessions:()=>Ep,currentId:()=>$,select:e=>void qp(e),sessionMenu:gf,createSession:Ip,onTitleChanged:rf}),Nd({sessions:()=>Ep,loadSessions:Rp,currentId:()=>$,select:qp,createSession:Ip,openConsole:sp}),Vd({currentId:()=>$,currentSession:Bp,createSession:e=>void Ip(e),syncBar:op,openFiles:fp,toggleFiles:mp}),Tp({sessions:()=>Ep,loadSessions:Rp,currentId:()=>$,currentSession:Bp,select:e=>void qp(e),maybeAckRead:zp}),Ff(`0.1.11`),au(),document.addEventListener(`gesturestart`,e=>e.preventDefault()),document.addEventListener(`visibilitychange`,zp),window.addEventListener(`focus`,zp),Gp(),Rp().then(Cp);export{x as $,Pi as A,ki as B,ji as C,Mi as D,xi as E,Di as F,ti as G,Fi as H,R as I,ei as J,ai as K,hi as L,fi as M,gi as N,Ni as O,mi as P,Ue as Q,Ti as R,Ai as S,di as T,Xr as U,pi as V,Zr as W,Yr as X,I as Y,Qr as Z,Ci as _,$c as a,Be as at,_i as b,Aa as c,ve as ct,ya as d,l as dt,S as et,_a as f,s as ft,bi as g,Zi as h,uu as i,b as it,Ei as j,Si as k,Da as l,de as lt,ea as m,a as mt,Bd as n,Ge as nt,Mo as o,Se as ot,ta as p,o as pt,ui as q,zd as r,qe as rt,No as s,g as st,lf as t,Ke as tt,B as u,ie as ut,wi as v,L as w,vi as x,yi as y,Oi as z};