@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
@@ -0,0 +1,85 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/tasks-kIXfyOri.js","assets/task-runs-BjD8rJs0.js","assets/runs-CG0zz7Gm.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`}]],h=[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`}]],ie=[[`path`,{d:`M4 5h16`}],[`path`,{d:`M4 12h16`}],[`path`,{d:`M4 19h16`}]],ae=[[`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`}]],oe=[[`path`,{d:`M5 12h14`}]],se=[[`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`}]],g=[[`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`}]],ce=[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`}]],le=[[`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`}]],ue=[[`path`,{d:`M5 12h14`}],[`path`,{d:`M12 5v14`}]],de=[[`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`}]],fe=[[`path`,{d:`m21 21-4.34-4.34`}],[`circle`,{cx:`11`,cy:`11`,r:`8`}]],pe=[[`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`}]],me=[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}]],he=[[`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`}]],ge=[[`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`}]],_e=[[`path`,{d:`M18 6 6 18`}],[`path`,{d:`m6 6 12 12`}]],_=(e,t=`h-3.5 w-3.5`)=>n(e,{class:`flex-none ${t}`,"aria-hidden":`true`,focusable:`false`});function ve(){let e={ArrowUp:a,ChevronLeft:c,ChevronRight:l,Clock:d,Ellipsis:m,LayoutDashboard:ne,ListTodo:re,Menu:ie,Plus:ue,RotateCw:de,Search:fe,Settings:pe,Square:me,Undo2:ge,X:_e};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(_(n,`h-full w-full`))}let t=_(s);t.setAttribute(`stroke`,`#737373`),document.documentElement.style.setProperty(`--select-chevron`,`url("data:image/svg+xml,${encodeURIComponent(t.outerHTML)}")`)}var ye=/[\u201c\u201d"\u2018\u2019'()\uff08\uff09\u300c\u300d\u300e\u300f\u3010\u3011\u300a\u300b\u3008\u3009[\]]/;function be(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&&ye.test(i[0]);)n+=i[0],i=i.slice(1);for(;i.length>1&&ye.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 v=e=>!e.text.trim()&&e.suggestions.length===0,xe=e=>e===`xhigh`?`Extra high`:e[0].toUpperCase()+e.slice(1),Se=e=>{if(e<1e3)return String(e);let t=e/1e3;return t>=9.95?`${Math.round(t)}K`:`${t.toFixed(1)}K`},Ce=/(?:^|\n)[ \t]*-{3,}[ \t]*\r?\n((?:[ \t]*\[[^\]\r\n]+\][ \t]*(?:[||][ \t]*)?)+)\s*$/,we=/\[([^\]\r\n]+)\]/g,Te=5,Ee=String.raw`[\u200B-\u200D\u2060\uFEFF]*`,De=e=>e.split(``).join(Ee),Oe=RegExp(`${De(`<silent>`)}([\\s\\S]*?)${De(`</silent>`)}`,`gi`),ke=RegExp(`<(\\/?)${De(`silent>`)}`,`gi`);function y(e){let t=[...e.matchAll(Oe)].map(e=>(e[1]??``).trim()).filter(Boolean);return t.length?t.join(` · `):void 0}function Ae(e,t){let n=b(e),r=y(e),i=Ce.exec(n);if(!i?.[1])return{text:n,suggestions:[],meta:t,silence:r};let a=[...i[1].matchAll(we)].map(e=>(e[1]??``).trim()).filter(Boolean).slice(0,Te);return a.length?{text:n.slice(0,i.index).trimEnd(),suggestions:a,meta:t,silence:r}:{text:n,suggestions:[],meta:t,silence:r}}var b=e=>be(e.replace(Oe,``).trim()),je=/^(?:\s|[-*+>]|\d+[.)])/;function Me(e,t=0){let n=e.lastIndexOf(`
3
+ `)+1,r=``,i=!1,a=t,o=-1,s=``;for(let c=t;c<n;){let t=e.indexOf(`
4
+ `,c),n=e.slice(c,t);c=t+1;let l=/^\s*(`{3,}|~{3,})(.*)$/.exec(n);if(!r&&!i&&!n.trim()){o<0&&s&&(o=c);continue}!r&&!i&&o>=0&&!(je.test(s)&&je.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(ke))i=!e[1];o=-1,s=n}return a}var Ne=String.raw`(?<when>(?:\d{4}-\d{2}-\d{2} )?\d{1,2}:\d{2})`,Pe=new RegExp(String.raw`^\[(?:(?<name>[^\n[\]<>]*)<(?<id>[^\n[\]<>]+)>)? ?${Ne}? ?(?<where>[a-z]+:[^\s[\]<>]+)?\]\n`),Fe=new RegExp(String.raw`^\[(?<name>[^\n[\]<>]*?) ${Ne}(?: (?<where>[a-z]+))?\]\n`);function Ie(e){let t=Pe.exec(e),{id:n,when:r,where:i}=t?.groups??{},a=n||r||i?t:Fe.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 Le=/(?:\n\[[^\]\n]*(?:\]\(\s*<?file:\/\/[^\n]*|$))+$/,Re=/^\s*`[^`\n]{40,}`\s+(\S[\s\S]*)$/;function ze(e){if(!e)return e;let{text:t}=Ie(e);return t===e?e:t.replace(Le,``).replace(Re,`$1`).replace(/\s+/g,` `).trim()||e}var Be=e=>[...new Set([...e].sort((e,t)=>t.createdAt-e.createdAt).map(e=>e.cwd))];function Ve(e){let t=Be(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 He(e){let t,n=!1;return()=>(n=!0,t??=(async()=>{for(;n;)n=!1,await e()})().finally(()=>{t=void 0}))}var Ue=(e,t)=>({method:t,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),x=(e,t,n=`POST`)=>fetch(e,Ue(t,n)),We=(e,t,n,r=`POST`)=>C(e,n,Ue(t,r));async function S(e,t){return(await e.json().catch(()=>({}))).error??`${t} (${e.status})`}async function C(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 S(r,t)};try{return{ok:!0,value:await r.json()}}catch(e){return{ok:!1,error:`${t}: ${String(e)}`}}}async function Ge(e,t,n){let r=await C(e,t,n);if(!r.ok)throw Error(r.error);return r.value}async function Ke(e,t,n){try{let r=await fetch(e,{method:t});return r.ok?void 0:await S(r,n)}catch(e){return`${n}: ${String(e)}`}}function qe(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 Je(e){if(Array.isArray(e))return e}function Ye(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 Xe(){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 Ze(e,t){return Je(e)||Ye(e,t)||Qe(e,t)||Xe()}function Qe(e,t){if(e){if(typeof e==`string`)return qe(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)?qe(e,t):void 0}}var $e=Object.entries,et=Object.setPrototypeOf,tt=Object.isFrozen,nt=Object.getPrototypeOf,rt=Object.getOwnPropertyDescriptor,w=Object.freeze,T=Object.seal,it=Object.create,at=typeof Reflect<`u`&&Reflect,ot=at.apply,st=at.construct;w||=function(e){return e},T||=function(e){return e},ot||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},st||=function(e){return new e(...[...arguments].slice(1))};var ct=O(Array.prototype.forEach),lt=O(Array.prototype.lastIndexOf),ut=O(Array.prototype.pop),dt=O(Array.prototype.push),ft=O(Array.prototype.splice),pt=Array.isArray,mt=O(String.prototype.toLowerCase),ht=O(String.prototype.toString),gt=O(String.prototype.match),_t=O(String.prototype.replace),vt=O(String.prototype.indexOf),yt=O(String.prototype.trim),bt=O(Number.prototype.toString),xt=O(Boolean.prototype.toString),St=typeof BigInt>`u`?null:O(BigInt.prototype.toString),Ct=typeof Symbol>`u`?null:O(Symbol.prototype.toString),E=O(Object.prototype.hasOwnProperty),wt=O(Object.prototype.toString),D=O(RegExp.prototype.test),Tt=Et(TypeError);function O(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return ot(e,t,n)}}function Et(e){return function(){return st(e,[...arguments])}}function k(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:mt;if(et&&et(e,null),!pt(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(tt(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Dt(e){for(let t=0;t<e.length;t++)E(e,t)||(e[t]=null);return e}function Ot(e){let t=it(null);for(let r of $e(e)){var n=Ze(r,2);let i=n[0],a=n[1];E(e,i)&&(t[i]=pt(a)?Dt(a):a&&typeof a==`object`&&a.constructor===Object?Ot(a):a)}return t}function kt(e){switch(typeof e){case`string`:return e;case`number`:return bt(e);case`boolean`:return xt(e);case`bigint`:return St?St(e):`0`;case`symbol`:return Ct?Ct(e):`Symbol()`;case`undefined`:return wt(e);case`function`:case`object`:{if(e===null)return wt(e);let t=e,n=At(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:wt(e)}return wt(e)}default:return wt(e)}}function At(e,t){for(;e!==null;){let n=rt(e,t);if(n){if(n.get)return O(n.get);if(typeof n.value==`function`)return O(n.value)}e=nt(e)}function n(){return null}return n}function jt(e){try{return D(e,``),!0}catch{return!1}}var Mt=w(`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=w(`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=w([`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=w([`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=w(`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=w([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Rt=w([`#text`]),zt=w(`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=w(`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=w(`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=w([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Ut=T(/{{[\w\W]*|^[\w\W]*}}/g),Wt=T(/<%[\w\W]*|^[\w\W]*%>/g),Gt=T(/\${[\w\W]*/g),Kt=T(/^data-[\-\w.\u00B7-\uFFFF]+$/),qt=T(/^aria-[\-\w]+$/),Jt=T(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Yt=T(/^(?:\w+script|data):/i),Xt=T(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Zt=T(/^html$/i),Qt=T(/^[a-z][.\w]*(-[.\w]+)+$/i),$t=T(/<[/\w!]/g),en=T(/<[/\w]/g),tn=T(/<\/no(script|embed|frames)/i),nn=T(/\/>/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=w(k({},rn)),on=function(){let e={};return ct(rn,t=>{e[t]=T(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),w(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 E(e,t)&&pt(e[t])?k(r.base?Ot(r.base):{},e[t],r.transform):n},dn=function(e,t,n){let r=E(e,t)?e[t]:void 0;return r&&typeof r==`object`?Ot(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`),h=o&&o.prototype?At(o.prototype,`nodeType`):null,ie=o&&o.prototype?At(o.prototype,`nodeName`):null,ae=o&&o.prototype?At(o.prototype,`ownerDocument`):null,oe=function(e){return h?h(e):e.nodeType},se=function(e){return ie?ie(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let g,ce=``,le,ue=!1,de=0,fe=function(){if(de>0)throw Tt(`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.`)},pe=function(e){fe(),de++;try{return g.createHTML(e)}finally{de--}},me=function(e){fe(),de++;try{return g.createScriptURL(e)}finally{de--}},he=function(){return ue||=(le=cn(u,i),!0),le},ge=n,_e=ge.implementation,_=ge.createNodeIterator,ve=ge.createDocumentFragment,ye=ge.getElementsByTagName,be=r.importNode,v=ln();t.isSupported=typeof $e==`function`&&typeof te==`function`&&_e&&_e.createHTMLDocument!==void 0;let xe=Ut,Se=Wt,Ce=Gt,we=Kt,Te=qt,Ee=Yt,De=Xt,Oe=Qt,ke=Jt,y=null,Ae=k({},[...Mt,...Nt,...Pt,...It,...Rt]),b=null,je=k({},[...zt,...Bt,...Vt,...Ht]),Me=Object.seal(it(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}})),Ne=null,Pe=null,Fe=Object.seal(it(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ie=!0,Le=!0,Re=!1,ze=!0,Be=!1,Ve=!0,He=!1,Ue=!1,x=null,We=null,S=!1,C=!1,Ge=!1,Ke=!1,qe=!0,Je=!1,Ye=`user-content-`,Xe=!0,Ze=!1,Qe={},et=null,tt=k({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),nt=null,rt=k({},[`audio`,`video`,`img`,`source`,`image`,`track`]),at=null,ot=k({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),st=`http://www.w3.org/1998/Math/MathML`,bt=`http://www.w3.org/2000/svg`,xt=`http://www.w3.org/1999/xhtml`,St=xt,Ct=!1,wt=null,O=k({},[st,bt,xt],ht),Et=w([`mi`,`mo`,`mn`,`ms`,`mtext`]),Dt=k({},Et),rn=w([`annotation-xml`]),pn=k({},rn),mn=k({},[`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=Ot(e),hn=gn.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,j=hn===`application/xhtml+xml`?ht:mt,y=un(e,`ALLOWED_TAGS`,Ae,{transform:j}),b=un(e,`ALLOWED_ATTR`,je,{transform:j}),wt=un(e,`ALLOWED_NAMESPACES`,O,{transform:ht}),at=un(e,`ADD_URI_SAFE_ATTR`,ot,{transform:j,base:ot}),nt=un(e,`ADD_DATA_URI_TAGS`,rt,{transform:j,base:rt}),et=un(e,`FORBID_CONTENTS`,tt,{transform:j}),Ne=un(e,`FORBID_TAGS`,Ot({}),{transform:j}),Pe=un(e,`FORBID_ATTR`,Ot({}),{transform:j}),Qe=E(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Ot(e.USE_PROFILES):e.USE_PROFILES:!1,Ie=e.ALLOW_ARIA_ATTR!==!1,Le=e.ALLOW_DATA_ATTR!==!1,Re=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ze=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Be=e.SAFE_FOR_TEMPLATES||!1,Ve=e.SAFE_FOR_XML!==!1,He=e.WHOLE_DOCUMENT||!1,C=e.RETURN_DOM||!1,Ge=e.RETURN_DOM_FRAGMENT||!1,Ke=e.RETURN_TRUSTED_TYPE||!1,S=e.FORCE_BODY||!1,qe=e.SANITIZE_DOM!==!1,Je=e.SANITIZE_NAMED_PROPS||!1,Xe=e.KEEP_CONTENT!==!1,Ze=e.IN_PLACE||!1,ke=jt(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Jt,St=typeof e.NAMESPACE==`string`?e.NAMESPACE:xt,Dt=dn(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>k({},Et)),pn=dn(e,`HTML_INTEGRATION_POINTS`,()=>k({},rn));let t=dn(e,`CUSTOM_ELEMENT_HANDLING`,()=>it(null));if(Me=it(null),E(t,`tagNameCheck`)&&vn(t.tagNameCheck)&&(Me.tagNameCheck=t.tagNameCheck),E(t,`attributeNameCheck`)&&vn(t.attributeNameCheck)&&(Me.attributeNameCheck=t.attributeNameCheck),E(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(Me.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),T(Me),Be&&(Le=!1),Ge&&(C=!0),Qe&&(y=k({},Rt),b=it(null),Qe.html===!0&&(k(y,Mt),k(b,zt)),Qe.svg===!0&&(k(y,Nt),k(b,Bt),k(b,Ht)),Qe.svgFilters===!0&&(k(y,Pt),k(b,Bt),k(b,Ht)),Qe.mathMl===!0&&(k(y,It),k(b,Vt),k(b,Ht))),Fe.tagCheck=null,Fe.attributeCheck=null,E(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?Fe.tagCheck=e.ADD_TAGS:pt(e.ADD_TAGS)&&(y===Ae&&(y=Ot(y)),k(y,e.ADD_TAGS,j))),E(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?Fe.attributeCheck=e.ADD_ATTR:pt(e.ADD_ATTR)&&(b===je&&(b=Ot(b)),k(b,e.ADD_ATTR,j))),E(e,`ADD_FORBID_CONTENTS`)&&pt(e.ADD_FORBID_CONTENTS)&&(et===tt&&(et=Ot(et)),k(et,e.ADD_FORBID_CONTENTS,j)),Xe&&(y[`#text`]=!0),He&&k(y,[`html`,`head`,`body`]),y.table&&(k(y,[`tbody`]),delete Ne.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Tt(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Tt(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=g;g=e.TRUSTED_TYPES_POLICY;try{ce=pe(``)}catch(e){throw g=t,e}}else e.TRUSTED_TYPES_POLICY===null?(g=void 0,ce=``):(g===void 0&&(g=he()),g&&typeof ce==`string`&&(ce=pe(``)));w&&w(e),_n=e},yn=k({},[...Nt,...Pt,...Ft]),bn=k({},[...It,...Lt]),xn=function(e,t,n){return t.namespaceURI===xt?e===`svg`:t.namespaceURI===st?e===`svg`&&(n===`annotation-xml`||Dt[n]):!!yn[e]},Sn=function(e,t,n){return t.namespaceURI===xt?e===`math`:t.namespaceURI===bt?e===`math`&&pn[n]:!!bn[e]},Cn=function(e,t,n){return t.namespaceURI===bt&&!pn[n]||t.namespaceURI===st&&!Dt[n]?!1:!bn[e]&&(mn[e]||!yn[e])},wn=function(e){let t=te(e);(!t||!t.tagName)&&(t={namespaceURI:St,tagName:`template`});let n=mt(e.tagName),r=mt(t.tagName);return wt[e.namespaceURI]?e.namespaceURI===bt?xn(n,t,r):e.namespaceURI===st?Sn(n,t,r):e.namespaceURI===xt?Cn(n,t,r):!!(hn===`application/xhtml+xml`&&wt[e.namespaceURI]):!1},Tn=function(e){dt(t.removed,{element:e});try{te(e).removeChild(e)}catch{if(p(e),!te(e))throw Tt(`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=[];ct(t,t=>{dt(e,t)}),ct(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}dt(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(C||Ge)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`||b[j(i)]||En(e,r,i)}},An=function(e){let t=[e];for(;t.length>0;){let e=t.pop();oe(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 Ve?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Mn=function(e){if(!Ve)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=oe(e);if(n===A.processingInstruction||n===A.comment&&D(en,e.data)){try{p(e)}catch{}continue}if(n===A.element){let t=e,n=j(se(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(S)e=`<remove></remove>`+e;else{let t=gt(e,/^[\r\n\t ]+/);r=t&&t[0]}hn===`application/xhtml+xml`&&St===xt&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=g?pe(e):e;if(St===xt)try{t=new l().parseFromString(i,hn)}catch{}if(!t||!t.documentElement){t=_e.createDocument(St,`template`,null);try{t.documentElement.innerHTML=Ct?ce:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),St===xt?ye.call(t,He?`html`:`body`)[0]:He?t.documentElement:a},Pn=function(e){let t=ae?ae(e):e.ownerDocument;return _.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=_t(e,xe,` `),e=_t(e,Se,` `),e=_t(e,Ce,` `),e},In=function(e){e.normalize();let t=ae?ae(e):e.ownerDocument,n=_.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&&ct(i,e=>{Rn(e.content)&&In(e.content)})},Ln=function(e){let t=ie?ie(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!==h(e)||e.childNodes!==ee(e)},Rn=function(e){if(!h||typeof e!=`object`||!e)return!1;try{return h(e)===A.documentFragment}catch{return!1}},zn=function(e){if(!h||typeof e!=`object`||!e)return!1;try{return typeof h(e)==`number`}catch{return!1}};function Bn(e,n,r){e.length!==0&&ct(e,e=>{e.call(t,n,r,_n)})}let Vn=function(e,t){return!!(Ve&&e.hasChildNodes()&&!zn(e.firstElementChild)&&D($t,e.textContent)&&D($t,e.innerHTML)||Ve&&e.namespaceURI===xt&&an[t]&&(zn(e.firstElementChild)||typeof e.textContent==`string`&&D(on[t],e.textContent))||e.nodeType===A.processingInstruction||Ve&&e.nodeType===A.comment&&D(en,e.data))},Hn=function(e,t){return e instanceof RegExp?D(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Un=function(e,t,n){if(!Ne[t]&&Yn(t)&&Hn(Me.tagNameCheck,t))return!1;if(Xe&&!et[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?Ot(t):t},Gn=function(e,t){return e===t||te(e)!==null?!1:(Ze&&An(e),!0)},Kn=function(e,n){if(Bn(v.beforeSanitizeElements,e,null),Gn(e,n))return!0;if(Ln(e))return Tn(e),!0;let r=j(se(e));if(y=Wn(v.uponSanitizeElement,y,Ae,x),Bn(v.uponSanitizeElement,e,{tagName:r,allowedTags:y}),Gn(e,n))return!0;if(Vn(e,r))return Tn(e),!0;if(Ne[r]||!(Fe.tagCheck instanceof Function&&Fe.tagCheck(r))&&!y[r]){let t=Un(e,r,n);return t===!1&&Bn(v.afterSanitizeElements,e,null),t}if(oe(e)===A.element&&!wn(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&D(tn,e.innerHTML))return Tn(e),!0;if(Be&&e.nodeType===A.text){let n=Fn(e.textContent);e.textContent!==n&&(dt(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Bn(v.afterSanitizeElements,e,null),!1},qn=function(e,t,r){if(Pe[t]||jn(t,e)||qe&&(t===`id`||t===`name`)&&(r in n||r in M))return!1;let i=b[t]||Fe.attributeCheck instanceof Function&&Fe.attributeCheck(t,e);return Le&&D(we,t)||Ie&&D(Te,t)?!0:i?at[t]||D(ke,_t(r,De,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&vt(r,`data:`)===0&&nt[e]||Re&&!D(Ee,_t(r,De,``))?!0:!r:Yn(e)&&Hn(Me.tagNameCheck,e)&&Hn(Me.attributeNameCheck,t,e)||t===`is`&&Me.allowCustomizedBuiltInElements&&Hn(Me.tagNameCheck,r)},Jn=k({},[`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[mt(e)]&&D(Oe,e)},Xn=function(e,t,n,r){if(g&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return pe(r);case`TrustedScriptURL`:return me(r)}return r},Zn=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),Ln(e)?Tn(e):ut(t.removed)}catch{On(n,e)}},Qn=function(e){Bn(v.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||Ln(e))return;b=Wn(v.uponSanitizeAttribute,b,je,We);let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:b,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:yt(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,Bn(v.uponSanitizeAttribute,e,n),d=n.attrValue,Je&&(l===`id`||l===`name`)&&vt(d,Ye)!==0&&(On(o,e,a),d=Ye+d),Ve&&D(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){On(o,e,a);continue}if(l===`attributename`&&gt(d,`href`)){On(o,e,a);continue}if(!n.forceKeepAttr){if(!n.keepAttr){On(o,e,a);continue}if(!ze&&D(nn,d)){On(o,e,a);continue}if(Be&&(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(v.afterSanitizeAttributes,e,null)},$n=function(e){let t=null,n=Pn(e);for(Bn(v.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Bn(v.uponSanitizeShadowNode,t,null),Kn(t,e),Qn(t),Rn(t.content)&&$n(t.content),oe(t)===A.element){let e=ne(t);Rn(e)&&(er(e),$n(e))}Bn(v.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=oe(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=ie?ie(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(Ct=!e,Ct&&(e=`<!-->`),typeof e!=`string`&&!zn(e)&&(e=kt(e),typeof e!=`string`))throw Tt(`dirty is not a string, aborting`);if(!t.isSupported)return e;Ue?(y=x,b=We):N(n),(v.uponSanitizeElement.length>0||v.uponSanitizeAttribute.length>0)&&(y=Ot(y)),v.uponSanitizeAttribute.length>0&&(b=Ot(b)),t.removed=[];let c=Ze&&typeof e!=`string`&&zn(e);if(c){Mn(e);let t=se(e);if(typeof t==`string`){let n=j(t);if(!y[n]||Ne[n])throw Dn(e),Tt(`root node is forbidden and cannot be sanitized in-place`)}if(Ln(e))throw Dn(e),Tt(`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(!C&&!Be&&!He&&e.indexOf(`<`)===-1)return g&&Ke?pe(e):e;if(i=Nn(e),!i)return C?null:Ke?ce:``}i&&S&&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),ct(t.removed,e=>{e.element&&An(e.element)})),n}if(c)return ct(t.removed,e=>{e.element&&An(e.element)}),Be&&In(e),e;if(C){if(Be&&In(i),Ge)for(s=ve.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(b.shadowroot||b.shadowrootmode)&&(s=be.call(r,s,!0)),s}let u=He?i.outerHTML:i.innerHTML;return He&&y[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&D(Zt,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
6
+ `+u),Be&&(u=Fn(u)),g&&Ke?pe(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};N(e),Ue=!0,x=y,We=b},t.clearConfig=function(){_n=null,Ue=!1,x=null,We=null,g=le,ce=``},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`&&E(v,e)&&dt(v[e],t)},t.removeHook=function(e,t){if(E(v,e)){if(t!==void 0){let n=lt(v[e],t);return n===-1?void 0:ft(v[e],n,1)[0]}return ut(v[e])}},t.removeHooks=function(e){E(v,e)&&(v[e]=[])},t.removeAllHooks=function(){v=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(_(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(_(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?[_(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),Mi=(e=`hover:text-red-600`)=>`flex-none cursor-pointer text-[11.5px] text-neutral-400 opacity-0 transition-opacity ${e} group-hover:opacity-100 pointer-coarse:opacity-100`;function Ni(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 Pi=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 Fi(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(_(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 Ii=(e,t)=>I(`span`,`flex flex-col gap-1`,ni(e),t),Li=e=>`[${e.split(`/`).pop()??`file`}](file://${encodeURI(e).replace(/\(/g,`%28`).replace(/\)/g,`%29`)})`,Ri=/^ {0,3}(`{3,}|~{3,})/;function zi(e){let t=[],n,r=0;for(let i of e.split(`
71
+ `)){let e=Ri.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 Bi(e,t,n){let r=zi(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 Vi=/^\[[^\]\n]*\]\(\s*<?file:\/\/(\/[^)>\s]*)>?\s*\)$/;function Hi(e){let t=e.split(`
72
+ `),n=t.length;for(;n>0&&Vi.test(t[n-1].trim());)n--;let r=t.slice(n).map(e=>{let t=Vi.exec(e.trim())[1];try{return decodeURIComponent(t)}catch{return t}});return{text:t.slice(0,n).join(`
73
+ `).trimEnd(),paths:r}}var Ui=`modulepreload`,Wi=function(e){return`/app/`+e},Gi={},Ki=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=Wi(t,n),t=s(t),t in Gi)return;Gi[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`:Ui,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)})},qi,Ji;function Yi(){return Ji??=Ki(()=>import(`./hljs-tWqyD59G.js`).then(e=>qi=e.default,e=>{console.warn(`highlighting unavailable — code stays plain text`,e)}),[]),Ji}async function Xi(e){let t=await Yi();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 Zi={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 Qi(e){let t=await Yi(),n=e.split(`.`).pop()?.toLowerCase()??``,r=Zi[n]??n;return t?.getLanguage(r)?r:null}function $i(e,t){let n=document.createElement(`span`);return qi&&t&&e.length<=500?n.innerHTML=qi.highlight(e,{language:t}).value:n.textContent=e,n}var ea=2e4;function ta(e){let t=e.split(`
74
+ `);return t.at(-1)===``&&t.pop(),t.map((e,t)=>({nums:[t+1],text:e,tone:``}))}function na(e,t){let n=e.length<=ea?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(ra(t,n)),i.append(e)}return i}function ra(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=$i(e.text,t);return r.className=n,r}let[r,i]=e.mark,a=$i(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,$i(e.text.slice(0,r),t),a,$i(e.text.slice(i),t))}var z=null,ia=null,aa=null;function oa(e){z&&!z.contains(e.target)&&e.target!==aa&&B()}var sa={ArrowDown:1,ArrowUp:-1},ca={n:1,j:1,p:-1,k:-1},la=()=>z!==null;function ua(e){if(!(e.altKey||e.metaKey||e.shiftKey||!e.key))return e.ctrlKey?ca[e.key.toLowerCase()]:sa[e.key]}function da(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 fa(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 pa(e){let t=z?fa(z):null;if(t){let n=(t.ends?e.key===`Home`?`first`:e.key===`End`?`last`:void 0:void 0)??ua(e);if(n!==void 0&&da(t.rows,n)){e.preventDefault();return}}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),B())}function ma(e){z&&!z.contains(e.target)&&B()}function B(){if(!z)return;document.removeEventListener(`pointerdown`,oa,!0),document.removeEventListener(`focusin`,oa,!0),document.removeEventListener(`keydown`,pa,!0),window.removeEventListener(`scroll`,ma,!0),window.removeEventListener(`resize`,B);let e=z;z=null,aa?.remove(),aa=null,e.contains(document.activeElement)&&ia?.focus({preventScroll:!0}),ia?.removeAttribute(`aria-expanded`),ia=null,e.inert=!0,e.dataset.closing=``,Promise.allSettled(e.getAnimations().map(e=>e.finished)).then(()=>e.remove())}var ha=null;function ga(e){let t=e.getBoundingClientRect(),n={top:t.bottom+4,left:t.left};return t.width||t.height?n:ha?.anchor===e?{top:ha.top,left:ha.left}:n}var _a=()=>window.innerWidth<640;function va(e,t){B(),document.querySelectorAll(`.glass-menu[data-closing]`).forEach(e=>e.remove());let n=_a();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&&(aa=I(`div`,`fixed inset-0 z-50 bg-black/15`),aa.onclick=e=>{e.stopPropagation(),B()},r.append(aa)),r.append(z),!n){let t=ga(e);ha={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 ia=e,ia.setAttribute(`aria-expanded`,`true`),z.tabIndex=-1,(z.querySelector(`button, input, select, [tabindex='0']`)??z).focus({preventScroll:!0}),document.addEventListener(`pointerdown`,oa,!0),document.addEventListener(`focusin`,oa,!0),document.addEventListener(`keydown`,pa,!0),window.addEventListener(`scroll`,ma,!0),window.addEventListener(`resize`,B),z}function ya(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 ${_a()?`min-h-12 py-3`:`min-h-10 py-2`}`,...e.checked===void 0?[]:[_(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 ba(e,t,n){let r=I(`div`,``);if(n&&_a()){let e=I(`button`,`icon-btn h-11 w-11`,_(_e));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(ya(e));va(e,r),z&&(z.dataset.menu=`true`,z.setAttribute(`aria-label`,n?`Actions for ${n}`:`Actions`),z.setAttribute(`role`,`group`))}var xa=async e=>{let t=await C(`/api/fs/ls${e?.startsWith(`/`)?`?path=${encodeURIComponent(e)}`:``}`,`Could not list directories`);return t.ok?t.value:null},Sa=e=>e.entries.filter(e=>e.dir&&!e.name.startsWith(`.`)).map(e=>e.name),Ca=`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`,wa=`font-mono text-[0.875rem]`,Ta=(e,t,n)=>{let r=L(e,`${Ca} ${t}`);return r.onclick=n,r};function Ea(e,t){let n=I(`div`,`mt-2 flex-none border-t border-neutral-200 pt-2`),r=Ta(`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 ${wa} 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 x(`/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(_(ue)),n.append(r),n}function Da(e,t,n){let r=e=>{n(e),B()};async function i(t){let n=await xa(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 ${wa} 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 xa(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(Ta(`../`,`${wa} text-neutral-500`,()=>void i(n.parent)));let d=Sa(n);for(let e of d)u.append(Ta(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,Ea(n.path,e=>void i(e))),va(e,a)}i(t)}function Oa(e,t,n,r){ba(e,[...t.map(e=>({label:e.path,...e.hint?{hint:e.hint}:{},checked:e.path===n,onSelect:()=>{B(),r(e.path)}})),{label:`Browse…`,onSelect:()=>Da(e,n||void 0,r)}])}var ka=(e,t)=>n=>{e.value=n,e.dispatchEvent(new Event(`input`,{bubbles:!0})),t?.(n)};function Aa(e,t){let n=L(`Browse…`,`btn flex-none self-stretch rounded-xl px-3 text-[12.5px] text-neutral-600`);return n.onclick=()=>Da(n,e.value.trim()||void 0,ka(e,t)),n}function ja(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,Aa(r,n)),input:r}}var Ma=F(`#image-dialog`),V=F(`#image-stage`),Na=F(`#image-full`),Pa=F(`#image-prev`),Fa=F(`#image-next`),Ia=F(`#image-close`),La=[],Ra=0;function za(e){La.length<2||(Ra=(Ra+e+La.length)%La.length,Ha(!1),Na.src=La[Ra])}var Ba=2.5,Va=()=>V.dataset.zoom!==void 0;function Ha(e,t){if(!e){delete V.dataset.zoom,Na.style.cssText=``;return}let n=Na.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*Ba,s=n.height*Ba;V.dataset.zoom=``,Na.style.width=`${String(o)}px`,Na.style.height=`${String(s)}px`,V.scrollLeft=i*o-r.width/2,V.scrollTop=a*s-r.height/2}function Ua(e){let t=e.closest(`[data-gallery]`);La=t?[...t.querySelectorAll(`img.thumb`)].map(e=>e.src):[e.src],Ra=Math.max(0,La.indexOf(e.src)),Na.src=e.src;let n=La.length<2?`none`:`flex`;Pa.style.display=n,Fa.style.display=n,Ma.showModal()}var Wa=4,Ga,Ka=!1;V.onpointerdown=e=>{Ka=!1,!(!Va()||e.button!==0)&&(Ga={x:e.clientX,y:e.clientY,left:V.scrollLeft,top:V.scrollTop},V.setPointerCapture(e.pointerId))},V.onpointermove=e=>{if(!Ga)return;let t=e.clientX-Ga.x,n=e.clientY-Ga.y;(Math.abs(t)>Wa||Math.abs(n)>Wa)&&(Ka=!0),V.scrollLeft=Ga.left-t,V.scrollTop=Ga.top-n};var qa=()=>{Ga=void 0};V.onpointerup=qa,V.onpointercancel=qa,V.onclick=e=>{Ka||(e.target===Na?Ha(!Va(),{x:e.clientX,y:e.clientY}):Ma.close())},Ia.onclick=()=>Ma.close(),Ma.onclose=()=>Ha(!1),Pa.onclick=()=>za(-1),Fa.onclick=()=>za(1),Ma.onkeydown=e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),za(e.key===`ArrowLeft`?-1:1))};function Ja(e){let t=e.querySelector(`:scope > .thumbs`);if(t)return t;let n=I(`div`,`thumbs`);return e.append(n),n}function Ya(e){let t=document.createElement(`img`);return t.src=e,t.loading=`lazy`,t.className=`thumb`,t.onclick=()=>Ua(t),t}var Xa=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`bmp`]),Za=524288,Qa=F(`#file-dialog`),$a=F(`#file-name`),eo=F(`#file-text`),to=F(`#file-download`);F(`#file-close`).onclick=()=>Qa.close();var no=e=>e.split(`.`).pop()?.toLowerCase()??``,ro=(e,t,n=!1)=>`/api/sessions/${encodeURIComponent(e)}/files?path=${encodeURIComponent(t)}${n?`&download=1`:``}`,io=e=>decodeURIComponent(/^\/api\/sessions\/([^/]+)\//.exec(e)?.[1]??``),ao=e=>e.slice(0,e.lastIndexOf(`/`))||`/`,oo=(e,t)=>`${e===`/`?``:e}/${t}`;function so(e,t){return Bi(e,/\]\(\s*<?file:\/\/(\/[^)>\s]*)>?\s*\)/g,e=>{let n=e[1];try{n=decodeURIComponent(n)}catch{}return`](${ro(t,n)})`})}var co=e=>/^\/api\/sessions\/[^/]+\/files\?/.test(e);function lo(e,t){let n=Zr(t)||`file`,r=ro(e,t);return Xa.has(no(n))?wo(r,n):To(r,n)}function uo(e){return new URLSearchParams(e.slice(e.indexOf(`?`)+1)).get(`path`)??``}var fo=(e,t=`text-neutral-500`)=>I(`div`,`px-3 py-2 text-[12.5px] [overflow-wrap:anywhere] ${t}`,e),po=0;function mo(e,t,n){if(to.hidden=n,n){$a.replaceChildren(t);return}let r=ao(t),i=L(`${r}/`,`min-w-0 cursor-pointer truncate text-neutral-400 hover:text-indigo-600`);i.title=`Browse ${r}`,i.onclick=()=>void go(e,r),$a.replaceChildren(i,I(`span`,`flex-none`,Zr(t)))}function ho(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 go(e,t.parent)));for(let i of t.entries){let a=oo(t.path,i.name);n.append(i.dir?r(`${i.name}/`,`text-neutral-800`,()=>void go(e,a)):r(i.name,`text-neutral-600`,()=>void _o(ro(e,a),i.name)))}return t.entries.length||n.append(fo(`Empty folder.`)),n}async function go(e,t){let n=++po;mo(e,t,!0),eo.replaceChildren(fo(`loading…`)),Qa.open||Qa.showModal();let r=await xa(t);n===po&&eo.replaceChildren(r?ho(e,r):fo(`failed to list: ${t}`,`text-red-600`))}async function _o(e,t,n){let r=++po;mo(io(e),uo(e)||t,!1),to.href=`${e}&download=1`,eo.replaceChildren(fo(`loading…`)),Qa.open||Qa.showModal();let i=e=>{r===po&&eo.replaceChildren(e)},a;try{a=await fetch(e)}catch(e){return i(fo(`failed to load: ${String(e)}`,`text-red-600`))}if(!a.ok){let t=uo(e),n=a.status===404?await xa(t):null;return r===po?n?void go(io(e),t):i(fo(`${await S(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(fo(`Binary file — use Download.`));let s=await a.text(),c=s.length>Za?`${s.slice(0,Za)}\n…`:s,l=await Qi(t),u=na(ta(c),l);if(i(u),n===void 0||r!==po)return;let d=u.querySelector(`[data-line="${String(n)}"]`);d?.classList.add(`bg-indigo-100`),d?.scrollIntoView({block:`center`})}var vo=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(`.`)),yo=/^(?:~|\/(?:home|Users|root|tmp|var|opt|etc|srv|mnt|media|data|usr))(?:\/|$)/;function bo(e){let t=/^([^\s`"'()[\]{}<>]+?)(?::(\d+))?(?::\d+)?$/.exec(e);if(!t||e.includes(`://`))return null;let n=t[1],r=n.includes(`.`)?no(n):``;return!yo.test(n)&&(!r||!vo.has(r)&&!n.includes(`/`))?null:{path:n,line:t[2]===void 0?void 0:Number(t[2])}}var xo;async function So(e,t,n){let r=t;r.startsWith(`~`)&&(xo??=xa().then(e=>e?.path??null),r=`${await xo??`~`}${r.slice(1)}`),await _o(ro(e,r),Zr(r),n)}function Co(e,t,n){for(let r of e.querySelectorAll(`:not(pre) > code`)){let e=bo(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 So(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 wo(e,t){let n=Ya(e);return n.alt=t,n}function To(e,t){let n=no(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]`,_(ee));s.setAttribute(`aria-label`,`Preview`),s.title=`Preview`,s.onclick=r=>{r.preventDefault(),n===`pdf`?window.open(e,`_blank`,`noopener`):_o(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(_(p)),c.setAttribute(`aria-label`,`Download`),o.append(c),r.append(i,a,o),r}function Eo(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 Do(e){let t=[];for(let n of e.querySelectorAll(`img`)){let e=n.getAttribute(`src`)??``;if(!co(e))continue;let r=wo(e,Zr(uo(e)));n.replaceWith(r),t.push(r)}for(let n of e.querySelectorAll(`a`)){let e=n.getAttribute(`href`)??``;if(!co(e))continue;let r=Zr(uo(e))||n.textContent?.trim()||`file`,i=Xa.has(no(r))?wo(e,r):To(e,r);n.replaceWith(i),t.push(i)}t.length&&Eo(t)}var Oo=null,ko=`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 Ao(){Oo=null}function jo(e,t,n){if(Oo?.remove(),Oo=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`,ko,e);t.type=`button`,t.onclick=()=>{Oo===r&&(Oo=null),r.remove(),n(e)},r.append(t)}e.append(r),Oo=r}var Mo=8e3,No=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],Po=e=>typeof e==`string`&&No.includes(e),Fo,Io;function Lo(e,t){Fo=e,Io=t}var Ro=e=>e.slice(0,8),zo=e=>`system-card group relative mt-1.5 rounded-xl px-4 py-2.5 ${e}`,Bo=e=>I(`div`,zo(e));function Vo(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 Ho(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`,Ro(e.runId));if(r.title=`Run ${e.runId}`,r.onclick=()=>Fo.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`,Ro(t));r.title=`Open session ${t}`,r.onclick=()=>Fo.select(t),n.append(r)}return t.append(n),t}var Uo={queued:{edge:`border-l-amber-400`,label:`text-amber-700`,glyph:h},running:{edge:`border-l-neutral-400`,label:`text-neutral-600`,glyph:h},succeeded:{edge:`border-l-green-500`,label:`text-green-700`,glyph:o},failed:{edge:`border-l-red-500`,label:`text-red-600`,glyph:_e},cancelled:{edge:`border-l-neutral-300`,label:`text-neutral-500`,glyph:oe},interrupted:{edge:`border-l-amber-400`,label:`text-amber-700`,glyph:ce},skipped:{edge:`border-l-neutral-300`,label:`text-neutral-500`,glyph:oe}},Wo=e=>_(Uo[e].glyph,`h-3 w-3 ${e===`queued`||e===`running`?`spinner`:``} ${Uo[e].label}`),Go=new Map,Ko=new WeakMap;function qo(e){for(let[e,t]of Go)t.isConnected||Go.delete(e);let t=Go.get(e.runId);t||(t=Bo(Uo[e.state].edge),t.dataset.kind=`background-run`,Io.el.append(t),Go.set(e.runId,t)),t.className=zo(Uo[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=Ho({glyph:Wo(e.state),label:`run · ${e.state}`,labelCls:Uo[e.state].label,taskName:e.taskName,note:`${e.sessionMode??`task`} · ${String(r)}s`,runId:e.runId,sessionId:e.targetSessionId}),a=Ko.get(t);!a&&e.prompt!==null&&(a=Vo(e.prompt),Ko.set(t,a)),t.replaceChildren(i,...a??[]),Io.scroll()}var H=null,Jo=null,Yo=null,Xo=!1;function Zo(){if(!Jo)return;Jo.text=Jo.text.slice(-4e3),Jo.pre.textContent=Jo.text;let e=(Jo.text.split(`
76
+ `).filter(Boolean).pop()??``).replace(/^[\s*_#]+|[\s*_]+$/g,``)||`thinking…`,t=Jo.summary.lastElementChild;t.textContent=e.length>90?`…`+e.slice(-90):e}function Qo(){if(Yo){Xo=!0;return}Xo=!1,Zo(),Yo=setTimeout(()=>{Yo=null,Xo&&Qo()},80)}function $o(){Yo&&clearTimeout(Yo),Yo=null,Xo&&Zo(),Xo=!1}var es=new WeakMap,ts=e=>{let t=es.get(e)??[];return es.set(e,t),t};function ns(){H&&!H.toolRows.size&&gs(`done`)}var rs=null;function is(){H=null,rs=null,Jo=null,$o(),Go.clear()}function as(){let e=rs;return!e||H?.el===e||(rs=null,e!==Io.el.lastElementChild)?null:(e.remove(),e.dataset.adopted=`1`,ss(e,e.dataset.status),e)}var os={running:`text-neutral-500 open:bg-black/[0.02] dark:open:bg-neutral-100`,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 ss(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 ${os[t]}`}var cs={failed:_e,interrupted:ce};function ls(e){return e===`running`?_(h,`spinner`):e===`done`?I(`span`,`hidden`):_(cs[e],`h-3 w-3`)}function us(e){if(H)return H;let t=ls(`running`),n=I(`span`,`min-w-0 truncate`,`working…`),{el:r}=ui(``,[t,n]);r.dataset.kind=`activity`,ss(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),ps(r,i),Io.el.append(r),rs=r,Io.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 ds(e,t=``){let n=us(e);$o(),n.thinking=null,n.steps+=1;let r=I(`div`,`whitespace-pre-wrap break-words text-[12.5px] text-neutral-600`,t);r.dataset.raw=t;let i=I(`div`,`border-l-2 border-neutral-200 py-0.5 pl-5`,r);return i.dataset.kind=`progress`,n.rowsEl.append(i),hs(n,`running`,`writing…`),ms(n),Io.scroll(),r}function fs(e){let t=e.closest(`details[data-kind="activity"]`);e.parentElement?.remove(),t&&!t.lastElementChild?.childElementCount&&(H?.el===t&&(H=null),rs===t&&(rs=null),t.remove())}function ps(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 ms(e){Io.bulk()||!e.el.open||!e.rowsEl.dataset.follow||(e.rowsEl.scrollTop=e.rowsEl.scrollHeight)}function hs(e,t,n){let r=Math.max(1,Math.round((Date.now()-e.startTs)/1e3)),i=[t===`running`?`working`:t===`done`?`Completed`:t,e.steps?`${e.steps} step${e.steps===1?``:`s`}`:``,`${r}s`,t===`running`?n:``];e.headline.textContent=i.filter(Boolean).join(` · `),ss(e.el,t);let a=ls(t);e.statusIcon.replaceWith(a),e.statusIcon=a}function gs(e){if(!H)return;$o();for(let e of H.toolRows.values())e.el.dataset.state===`running`&&bs(e,`interrupted`);let t=ts(H.el).length,n=t>0&&H.failedSteps===t;hs(H,(H.sawError||n)&&e===`done`?`failed`:e===`done`&&H.toolRows.size?`interrupted`:e),H=null}function _s(){H&&(H.sawError=!0)}function vs(e){let t=e.slice(0,400).replace(/\s+/g,` `);return t.length>100?t.slice(0,100)+`…`:t}function ys(e,t,n,r){let i=us(e);i.steps+=1,$o(),i.thinking=null;let a=JSON.stringify(r,null,2)??``,o=I(`span`,`ml-auto flex flex-none`),s=I(`span`,`min-w-0 truncate text-neutral-500`,vs(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)),ts(i.el).push({tool:n,call:t,preview:s,argsPre:l,outputPre:u});let d={el:c,statusEl:o,outputPre:u};bs(d,`running`),i.toolRows.set(t,d),i.rowsEl.append(c),ms(i),hs(i,`running`,n),Io.scroll()}function bs(e,t){e.el.dataset.state=t,e.statusEl.replaceChildren(Wo(t)),e.statusEl.title=t;let n=e.el.firstElementChild;for(let e of[`rounded`,`bg-red-50`,`text-red-700`])n.classList.toggle(e,t===`failed`)}function xs(e,t,n){let r=H;if(!r)return;let i=r.toolRows.get(e);r.toolRows.delete(e),i&&(bs(i,t?`failed`:`succeeded`),n&&(i.outputPre.textContent=n.length>8e3?n.slice(0,Mo)+`…`:n,i.outputPre.classList.remove(`hidden`)),t&&(r.failedSteps+=1)),hs(r,`running`)}function Ss(e,t){let n=us(e);if(!n.thinking){$o();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.steps+=1,n.thinking={pre:r,summary:t,text:``},Jo=n.thinking,ms(n),hs(n,`running`,`thinking…`)}n.thinking.text+=t,Qo()}var Cs=0;function ws(e,t=0,n=!1,r){let i=Date.now()-t,a=us(i).el;for(let t of e){if(t.kind===`progress`){ds(i,t.text??``);continue}if(t.kind===`thinking`){Ss(i,t.text??``);continue}let e=t.id??`replay-${++Cs}`;ys(i,e,t.toolName??``,t.args),t.done&&xs(e,t.isError??!1,t.output??``)}r!==void 0&&e.some(e=>e.kind===`tool`&&e.args===void 0)&&Ts(a,r),!n&&gs(e.some(e=>e.kind===`tool`&&!e.done)?`interrupted`:`done`)}function Ts(e,t){let n=()=>{e.open&&(e.removeEventListener(`toggle`,n),Es(e,t))};e.addEventListener(`toggle`,n)}async function Es(e,t){let n=Fo.sessionId(),r=ts(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 C(`/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=vs(r),n.output&&(t.outputPre.textContent=n.output,t.outputPre.classList.remove(`hidden`))}}var Ds,U=F(`#turns`);function Os(e){Ds=e,Lo(e,{el:U,scroll:Is,bulk:()=>ks})}var ks=!1,As=()=>U.scrollHeight-U.scrollTop-U.clientHeight<80,js=!0,Ms=0;U.addEventListener(`scroll`,()=>{let e=U.scrollTop,t=e<Ms-4;Ms=e,!ks&&(t||As())&&(js=As())},{passive:!0});var Ns=0;function Ps(){!js||ks||Ns||(Ns=requestAnimationFrame(()=>{Ns=0,js&&!ks&&(U.scrollTop=U.scrollHeight)}))}new ResizeObserver(Ps).observe(U),U.addEventListener(`load`,Ps,!0),new MutationObserver(Ps).observe(U,{childList:!0,subtree:!0,characterData:!0});function Fs(){As()&&(js=!0)}function Is(e=!1){ks||(e&&(js=!0),js&&(U.scrollTop=U.scrollHeight))}var Ls=1200;function Rs(e,t){let n=U.querySelector(`[data-kind="${e}"][data-at="${t}"]`);return n?(Bs(n),!0):!1}function zs(){let e=U.querySelectorAll(`[data-kind="background-run"][data-active]`),t=e[e.length-1];return t?(Bs(t),!0):!1}function Bs(e){js=!1,e.scrollIntoView({block:e.offsetHeight>U.clientHeight?`start`:`center`}),e.dataset.reveal=``,setTimeout(()=>delete e.dataset.reveal,Ls)}var Vs=500,Hs=0,Us=0,Ws=null;function Gs(){for(;U.childElementCount>Vs;){let e=U.firstElementChild;e.remove(),e!==Ws&&(e.dataset.kind===`user`&&Hs++,Us++)}Us&&(Ws||(Ws=I(`div`,`px-5 py-2 text-center text-[11.5px] italic text-neutral-400`),Ws.dataset.kind=`trim`),Ws.textContent=`${Us} earlier row${Us===1?``:`s`} not shown — still in the transcript, not on this screen`,U.firstElementChild!==Ws&&U.prepend(Ws))}var Ks={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){ns();let i=e===`assistant`?as():null,a=Ks[e],o=e===`user`&&r!==void 0&&cc(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=``),ks||(c.dataset.enter=``);let l=e===`user`?Hi(t):null,u=l?.text??t,d=e===`user`?Ie(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&&fc(m,t),r!==void 0&&lc(c,r),p&&c.append(qs(p)),c.append(m);let ee=Ds.sessionId();if(l?.paths.length&&ee){let e=Ja(c);for(let t of l.paths)e.append(lo(ee,t))}if(e===`user`){Zs?.();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(_(le)),e.onclick=()=>ec(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),ac(e),ic??=setInterval(oc,6e4),e.title=$r(o),U.append(e)}return i&&U.append(i),U.append(c),Gs(),Is(),m}function qs(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=Ds.sessionChannel();return r&&r!==`web`&&t.append(I(`span`,`text-[10px] uppercase tracking-wide opacity-60`,r)),t}var Js={"task-delegation":[i,`delegated`,`text-cyan-700`],"task-callback":[f,`callback`,`text-cyan-700`]};function Ys(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 Xs(e,t){let n=t.kind===`task-message`?t.messageKind:t.kind,[r,i,a]=Js[n]??[f,n.replace(`_`,` `),`text-cyan-700`];ns();let o=t.kind===`task-callback`?t.state:void 0,s=Bo(o?Uo[o].edge:`border-l-cyan-500`);s.dataset.kind=`system`;let[c,l]=Ys(e),u=Ho({glyph:o?Wo(o):_(r,`h-3 w-3 ${a}`),label:o?`${i} \u00b7 ${o}`:i,labelCls:o?Uo[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(...Vo(l)),U.append(s),Gs(),Is()}var Zs=null,Qs=e=>e.isConnected&&e.dataset.kind===`user`;function $s(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 ec(e,t){if(!Qs(e)||e.querySelector(`textarea`))return;if(Zs?.(),Ds.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=$s(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,Zs=null};Zs=l,i.onclick=()=>{l(),e.querySelector(`.message-edit`)?.focus({preventScroll:!0})},r.onclick=()=>{let t=n.value.trim();t&&tc(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 tc(e,t){let n=Ds.sessionId();if(!n||!Qs(e))return;if(Ds.sessionState()!==`idle`){W(`error`,`can't edit while streaming — stop the turn first`);return}Zs?.();let r=[...U.querySelectorAll(`[data-kind="user"]`)],i=r.indexOf(e),a=Hs+i,o=r[i-1]?.dataset.at;rc=o===void 0?null:Number(o);let s=e.previousElementSibling;for(s?.dataset.kind===`time`&&s.remove();e.nextElementSibling;)e.nextElementSibling.remove();e.remove(),Ds.ownTurn(t),W(`user`,t,!1,Date.now()),Is(!0);let c=await x(`/api/sessions/${n}/turns/${a}/edit`,{text:t});if(!c.ok){let e=await S(c,`edit failed`);await Ds.reload(n),W(`error`,e)}}var nc=6e5,rc=null,ic;function ac(e){let t=Number(e.dataset.at);e.textContent=`${$r(t).slice(0,16)} · ${Xr(t)}`}function oc(){let e=U.querySelectorAll(`[data-kind="time"]`);for(let t of e)ac(t);e.length||(clearInterval(ic),ic=void 0)}var sc=(e,t)=>new Date(e).toDateString()===new Date(t).toDateString();function cc(e){let t=rc;return rc=e,t===null||e-t>=nc||!sc(t,e)}function lc(e,t){e.dataset.at=String(t),e.dataset.time=$r(t).slice(11)}function uc(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 dc(e){let t=Ds.sessionId(),n=I(`div`,``);return n.innerHTML=pn.sanitize(P.parse(t?so(e,t):e,{async:!1})),ri(n),n}function fc(e,t){e.replaceChildren(...dc(t).childNodes),e.classList.remove(`whitespace-pre-wrap`),e.classList.add(`md`),Xi(e),uc(e);for(let t of e.querySelectorAll(`:not(pre) > code`))li(t,()=>t.textContent??``);Do(e);let n=Ds.sessionId();n&&Co(e,n,Ds.sessionCwd())}function pc(e,t,n,r=!1){let{text:i,suggestions:a}=Ae(t);return v({text:i,suggestions:a})?mc(e,y(t)):fc(e,i),r&&jo(e.parentElement??e,a,e=>Ds.send(`auto`,e)),n&&lc(e.parentElement??e,n.completedAt),e}function mc(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 hc=(e,t,n=!1)=>pc(W(`assistant`,``),e,t,n),G=null,gc=null,_c=!1,vc=0,yc=0;function bc(e){let t=e.dataset.raw??``;for(;e.childNodes.length>yc;)e.lastChild.remove();let n=Me(t,vc);n>vc&&(e.append(...dc(b(t.slice(vc,n))).childNodes),vc=n,yc=e.childNodes.length),e.append(...dc(Ae(t.slice(vc)).text).childNodes),e.classList.remove(`whitespace-pre-wrap`),e.classList.add(`md`)}function xc(){if(gc){_c=!0;return}_c=!1,G&&(bc(G),Is()),gc=setTimeout(()=>{gc=null,_c&&xc()},80)}function Sc(){gc&&clearTimeout(gc),gc=null,_c=!1}function Cc(e){G||(G=ds(Date.now()),vc=0,yc=0),G.dataset.raw=(G.dataset.raw??``)+e,xc()}function wc(){if(!G)return;let e=G;G=null,Sc(),e.classList.remove(`md`),e.classList.add(`whitespace-pre-wrap`),e.textContent=e.dataset.raw??``}function Tc(){if(!G)return;let e=G.dataset.raw;return fs(G),G=null,Sc(),e}function Ec(e,t){e===``&&wc();let n=Tc();gs(`done`);let r=e??n;r&&hc(r,t,!0)}function Dc(){let e=Tc();gs(`interrupted`),e&&hc(e)}function Oc(){Zs?.(),clearInterval(ic),ic=void 0,U.replaceChildren(),Hs=0,Us=0,Ws=null,rc=null,G=null,Sc(),is(),Ao()}function kc(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 Ac(e,t,n){kc(!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&&(qo(e),r.delete(t))}},o=e.reduce((e,t,n)=>t.role===`assistant`?n:e,-1);ks=!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&&(ws(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]),Xs(r.text,r.origin);continue}s?Cc(r.text):r.role===`assistant`?hc(r.text,r.meta,t===`idle`&&n===o):W(r.role,r.text,!1,r.at)}}for(let e of r.values())qo(e)}finally{ks=!1}Is(!0)}var jc=window.fetch.bind(window),Mc=20,Nc=6e4,Pc=[],Fc=new Map,Ic=e=>e instanceof Error?e.stack??`${e.name}: ${e.message}`:void 0;function Lc(e,t){let n=t===void 0?e:`${e}: ${String(t)}`,r=Date.now();return r-(Fc.get(n)??-6e4)<Nc||(Fc.size>100&&Fc.clear(),Fc.set(n,r),Pc=Pc.filter(e=>r-e<6e4),Pc.length>=Mc)?null:(Pc.push(r),jc(`/api/client-log`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:n,stack:Ic(t),view:location.hash||`/`}),keepalive:!0}).catch(()=>{}),W(`error`,n))}function Rc(){window.__pierReporting=!0,window.addEventListener(`error`,e=>{!e.error&&e.message.includes(`ResizeObserver loop`)||Lc(`script error: ${e.message}`,e.error)}),window.addEventListener(`unhandledrejection`,e=>{Lc(`unhandled rejection`,e.reason)})}var zc=window.fetch.bind(window),Bc=()=>{location.assign(`/login?next=${encodeURIComponent(location.pathname+location.hash)}`)};function Vc(){window.fetch=async(...e)=>{let t=await zc(...e);return t.status===401&&Bc(),t}}function Hc(e,t){if(e.readyState!==EventSource.CLOSED)return;let n=()=>{let e=Lc(`${t} stream disconnected`);if(!e)return;let n=di(`Reload`);n.classList.add(`ml-2`,`align-middle`),n.onclick=()=>location.reload(),e.append(` `,n)};zc(`/api/sessions`).then(e=>e.status===401?Bc():n(),n)}var Uc=/Mac|iP(?:hone|ad|od)/.test(navigator.userAgent),Wc=Uc?`⌘`:`Ctrl+`,Gc=Uc?`⇧`:`Shift+`,Kc=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 qc(e){let{key:t,shift:n,meta:r}=Kc(e);return`${r?`⌘`:Wc}${n?Gc:``}${t.toUpperCase()}`}var Jc=()=>document.querySelector(`dialog[open]`)!==null,Yc={"[":`{`,"]":`}`},Xc=`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 Zc(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`,Xc,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 Qc(e,t,n,r,i){Zc(e,n,qc(t)),nl(t,r,i)}function $c(e,t,n,r){Zc(e,t,`Esc`),document.addEventListener(`keydown`,e=>{e.key!==`Escape`||e.isComposing||e.defaultPrevented||Jc()||!r()||(e.preventDefault(),n())})}var el=`input, textarea, select, [contenteditable]`;function tl(e,t,n,r,i){Zc(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?.(el)||Jc()||!i()||(e.preventDefault(),r())})}function nl(e,t,n){let{key:r,shift:i,meta:a}=Kc(e),o=Yc[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,rl=F(`#composer`),q=F(`#input`),il=F(`#send`),al=F(`#send-arrow`),ol=F(`#send-queue`),sl=F(`#stop`),cl=F(`#queue-panel`),ll=F(`#queue-rows`),ul=F(`#queue-label`),dl=I(`div`,`hidden max-h-48 overflow-y-auto border-t border-neutral-200 px-4 py-2 text-[13px]`);dl.id=`recovery-panel`,cl.after(dl);var fl=F(`#image-strip`),pl=F(`#attach-input`),ml=!1,hl=0,gl=new Set,_l=[],vl=[];function yl(){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 bl(){let e=rl.parentElement,t=[cl,dl,rl],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 xl(){q.focus()}function Sl(e){let t=vl.indexOf(e);return t<0?!1:(vl.splice(t,1),!0)}function Cl(e){vl.push(e)}function wl(){vl=[]}function Tl(){let e=K.sessionState()===`streaming`,t=K.sessionId()!==null,n=K.starting();il.disabled=!t,il.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`}`,il.title=t?e?`Queue — delivered when the turn ends`:`Send`:n?`Starting the session…`:`No session`,q.placeholder=n?`Starting the session…`:`Message…`,al.classList.toggle(`hidden`,e),ol.classList.toggle(`hidden`,!e),sl.classList.toggle(`hidden`,!e),sl.classList.toggle(`flex`,e)}function El(){let e=K.chatVisible()&&ml;cl.classList.toggle(`hidden`,!e),cl.classList.toggle(`flex`,e),dl.classList.toggle(`hidden`,!K.chatVisible()||!dl.childElementCount)}function Dl(e,t=!1){let n=K.sessionId();if(dl.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 x(`/api/sessions/${n}/queue/recovery/${e.id}/ack`,{}),r=t.ok?null:await S(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 Gl(),e.append(t),dl.prepend(e)}El()}function Ol(e,t){++hl;let n=[...e.map(e=>({mode:`steer`,text:e})),...t.map(e=>({mode:`queued`,text:e}))];ml=n.length>0,ul.textContent=n.length>1?`Queued · ${n.length}`:`Queued`,El(),ll.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 kl=8;function Al(){let e=K.sessionId();e&&_l.length?Rl.set(e,_l):e&&Rl.delete(e),fl.classList.toggle(`hidden`,_l.length===0),fl.classList.toggle(`flex`,_l.length>0),fl.replaceChildren(..._l.map((e,t)=>{let n=e.mimeType.startsWith(`image/`)?Ya(`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`,_(_e,`h-3 w-3`));return r.setAttribute(`type`,`button`),r.setAttribute(`aria-label`,`Remove ${e.name??`attachment`}`),r.onclick=()=>{_l.splice(t,1),Al()},I(`div`,`relative`,n,r)}))}function jl(e){if(_l.length>=kl){W(`error`,`attachment limit is ${kl} 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;_l.push(Ml({data:n.slice(n.indexOf(`,`)+1),mimeType:e.type||`application/octet-stream`,name:e.name||void 0})),Al()},t.readAsDataURL(e)}function Ml({data:e,mimeType:t,name:n}){let r={data:e,mimeType:t,name:n},i=x(`/api/inbox`,r).then(async e=>e.ok?Li((await e.json()).path):null).catch(()=>null);return{...r,marker:i}}async function Nl(e){let t=await Promise.all(e.map(e=>e.marker));return t.every(e=>e!==null)?t:null}var Pl=`pier.draft.`,Fl=e=>`${Pl}${e}`,Il=0;function Ll(){try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(Pl)&&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 Rl=new Map;function zl(e=K.sessionId(),t=q.value){e&&(t?sessionStorage.setItem(Fl(e),t):sessionStorage.removeItem(Fl(e)))}function Bl(e){++Il,q.value=sessionStorage.getItem(Fl(e))??``,Vl(),_l=Rl.get(e)??[],Al()}function Vl(){let e=q.style.height;q.style.height=`auto`;let t=`${Math.min(q.scrollHeight,192)}px`;q.style.height=t,t!==e&&Is()}var Hl=!1;async function Ul(e,t){let n=(t??q.value).trim(),r=t===void 0?_l:[],i=K.sessionId();if(!(!n&&r.length===0||!i)){if(t===void 0){if(Hl)return;Hl=!0,q.value=``,Vl(),zl(),_l=[],Al()}try{let t=[];if(r.length){let e=await Nl(r);if(e===null){W(`error`,`attachment upload failed`),q.value=[n,q.value.trim()].filter(Boolean).join(`
81
+ `),Vl(),zl(),_l=r.map(Ml),Al();return}t=e}let a=[n,...t].filter(Boolean).join(`
82
+ `),o=K.sessionState()===`idle`&&e===`auto`;o?K.setState(`streaming`):Tl(),(o||e===`steer`)&&(Cl(a),W(`user`,a,!1,Date.now()),Is(!0));let s=await x(`/api/sessions/${i}/messages`,{text:a,mode:e});if(!s.ok){let e=await S(s,`send failed`);await K.reload(i),W(`error`,e)}}finally{t===void 0&&(Hl=!1)}}}async function Wl(e){let t=K.sessionId();if(!t)return;Ol([],[]);let n=await x(`/api/sessions/${t}/queue/deliver`,{mode:e});if(!n.ok){let r=await S(n,`Queue ${e} failed`);await K.reload(t),K.sessionId()===t&&W(`error`,r)}}async function Gl(){let e=K.sessionId();if(!e||gl.has(e))return;gl.add(e);let t=hl,n=Il,r=document.activeElement;try{zl();let i=await fetch(`/api/sessions/${e}/queue/recall`,{method:`POST`});if(!i.ok){let t=await S(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(Fl(e))??``,i=(t?[t,...a]:a).join(`
83
+ `);o&&(q.value=i,Vl(),n===Il&&K.chatVisible()&&document.activeElement===r&&q.focus()),zl(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===hl&&Ol([],[])}finally{gl.delete(e)}}function Kl(e){K=e,Ll(),yl(),bl();let t=()=>{let e=K.sessionId();e&&fetch(`/api/sessions/${e}/abort`,{method:`POST`})};sl.onclick=t,$c(sl,`Stop the running turn`,t,()=>K.sessionState()===`streaming`&&K.chatVisible()),F(`#queue-steer`).onclick=()=>void Wl(`steer`),F(`#queue-restart`).onclick=()=>void Wl(`restart`),F(`#queue-recall`).onclick=()=>void Gl(),rl.onsubmit=e=>{e.preventDefault(),Ul(`auto`)},tl(q,[`/`],`Write a message`,xl,K.chatVisible),q.onfocus=Fs,q.oninput=()=>{Vl(),zl()};let n=!matchMedia(`(pointer: coarse)`).matches;q.onkeydown=e=>{e.isComposing||e.keyCode===229||n&&e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Ul(`auto`))},q.onpaste=e=>{for(let t of e.clipboardData?.items??[]){let e=t.kind===`file`?t.getAsFile():null;e&&jl(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`),Vl(),zl())},U.ondragover=e=>e.preventDefault(),U.ondrop=e=>{e.preventDefault();for(let t of e.dataTransfer?.files??[])jl(t)},F(`#attach`).onclick=()=>pl.click(),pl.onchange=()=>{for(let e of pl.files??[])jl(e);pl.value=``},Tl()}var ql=`pier.push`,Jl=`/app/sw.js`,Yl=()=>/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.maxTouchPoints>1&&/Macintosh/.test(navigator.userAgent),Xl=()=>matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0;function Zl(){return window.isSecureContext?Yl()&&!Xl()?`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 Ql=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/Macintosh/,`Mac`],[/Windows/,`Windows`]],$l=[[/Edg\//,`Edge`],[/Chrome\//,`Chrome`],[/Firefox\//,`Firefox`],[/Safari\//,`Safari`]];function eu(){let e=navigator.userAgent,t=(t,n)=>t.find(([t])=>t.test(e))?.[1]??n;return`${t(Ql,`Linux`)} · ${t($l,`browser`)}${Xl()?` (installed)`:``}`}var tu=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},nu=null;async function ru(){return!(`serviceWorker`in navigator)||!window.isSecureContext?null:(nu??=await navigator.serviceWorker.register(Jl,{scope:`/app/`}).catch(e=>(console.warn(`service worker registration failed`,e),null)),nu)}var iu=(e,t)=>{let n=e?new Uint8Array(e):null;return n?.length===t.length&&n.every((e,n)=>e===t[n])};async function au(e){let{publicKey:t}=await Ge(`/api/push`,`Could not read this instance's push key`),n=tu(t),r=await e.pushManager.getSubscription();if(r){if(iu(r.options.applicationServerKey,n))return r;await r.unsubscribe()}return e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:n})}async function ou(e){return x(`/api/push/subscribe`,{...e.toJSON(),label:eu()})}async function su(){uu();let e=await ru();if(!(!e||localStorage.getItem(ql)!==`on`)&&!(!(`Notification`in window)||Notification.permission!==`granted`))try{await ou(await au(e))}catch(e){console.warn(`re-registering this browser for notifications failed`,e)}}var cu=null,lu=null;function uu(){window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),cu=e,lu?.()}),window.addEventListener(`appinstalled`,()=>{cu=null,lu?.()})}function du(e){let t=navigator;(e>0?t.setAppBadge?.(e):t.clearAppBadge?.())?.catch(()=>{})}function fu(){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(ql)===`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 x(`/api/push/unsubscribe`,{endpoint:e.endpoint});if(!t.ok)R(o,`failed`,await S(t,`Could not remove it`));else{let t=await(await ru())?.pushManager.getSubscription();t?.endpoint===e.endpoint&&(localStorage.setItem(ql,`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 C(`/api/push/subscriptions`,`Could not load subscribed devices`);if(!e.ok)return R(o,`failed`,e.error);if(!e.value.devices.length){a.replaceChildren(Pi(`No device is subscribed.`));return}a.replaceChildren(...e.value.devices.map(e=>{let t=di(`Remove`);return t.onclick=()=>{t.disabled=!0,c(e)},Ni(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(ql,`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 ru();if(!n)return R(e,`failed`,`This browser refused to register a service worker.`);try{let t=await ou(await au(n));if(!t.ok)return R(e,`failed`,await S(t,`Could not register this browser`));localStorage.setItem(ql,`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(ql,`off`),p();let t=await(await ru())?.pushManager.getSubscription();t&&(await x(`/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 x(`/api/push/test`,{});if(!t.ok)return R(e,`failed`,await S(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(!cu)return[];let e=di(`Install Pier`,!0);return e.onclick=()=>{let e=cu;e&&e.prompt().then(()=>e.userChoice).finally(()=>{cu=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=Zl();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 lu=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`),pu=F(`#drawer-scrim`),mu=F(`#mobile-title`),hu=F(`#mobile-menu`),gu=F(`#session-meta`);function _u(){delete J.dataset.open,pu.classList.add(`hidden`),Tu()}function vu(e,t){mu.textContent=e,mu.classList.toggle(`cursor-pointer`,t),hu.classList.toggle(`hidden`,!t)}var yu=`pier.railClosed`;localStorage.getItem(yu)===`1`&&(document.body.dataset.rail=`closed`);function bu(e){document.body.dataset.rail=e?`closed`:``,localStorage.setItem(yu,e?`1`:`0`),Tu()}function xu(){if(J.dataset.open!==void 0)return _u();J.dataset.open=``,pu.classList.remove(`hidden`),Tu()}var Su=window.matchMedia(`(width < 48rem)`),Cu=()=>Su.matches;function wu(){Cu()?F(`#mobile-bar`).append(gu):F(`#chat-menu`).before(gu)}function Tu(){let e=Cu()&&J.dataset.open!==void 0,t=F(`main`);t.inert=e,J.inert=Cu()?!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(Cu()?`#drawer-toggle`:`#rail-toggle`).focus()}var Eu=[F(`#rail-toggle`),F(`#drawer-toggle`)],Du=`attention absolute -right-0.5 -top-0.5 rounded-full bg-amber-500`,Ou=e=>e===1?I(`span`,`${Du} h-2 w-2`):I(`span`,`${Du} 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 ku(e){for(let t of Eu)t.querySelector(`.attention`)?.remove(),e&&t.append(Ou(e))}var Au=20,ju=.35,Mu=8;function Nu(){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)`,pu.style.transition=`none`,pu.classList.remove(`hidden`),pu.style.opacity=String(e/i)},o=t=>{J.style.transition=``,J.style.transform=``,pu.style.transition=``,pu.style.opacity=``,t?(J.dataset.open=``,pu.classList.remove(`hidden`),Tu()):_u(),e=-1,r=!1};window.addEventListener(`touchstart`,a=>{if(r||(e=-1,!Cu()||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>Au||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)<Mu)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*ju:t>i*.65)};window.addEventListener(`touchend`,s),window.addEventListener(`touchcancel`,s)}function Pu(e){Nu(),Tu(),wu(),Su.addEventListener(`change`,()=>{_u(),wu()}),F(`#drawer-toggle`).setAttribute(`aria-controls`,`sidebar`),J.addEventListener(`keydown`,e=>{if(!(!Cu()||J.dataset.open===void 0||e.defaultPrevented||e.isComposing)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),_u();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=xu,pu.onclick=_u,hu.onclick=()=>e.sessionMenu(hu),mu.onclick=()=>{hu.classList.contains(`hidden`)||e.sessionInfo(mu)};let t=F(`#rail-toggle`);t.onclick=()=>bu(document.body.dataset.rail!==`closed`),Qc(t,`meta+b`,`Toggle sidebar`,()=>Cu()?xu():bu(document.body.dataset.rail!==`closed`))}var Y,Fu=F(`#session-list`),Iu=F(`#new-session`),Lu=e=>e.modified??e.createdAt;function Ru(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 zu(e,t){let{top:n,rest:r}=Ru(e),i=[...n,...r].slice(0,t);return{rows:i,hidden:e.length-i.length}}function Bu(e,t,n){let{top:r,rest:i}=Ru(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 Vu=8,Hu=`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`,Uu=e=>e.unread,Wu=e=>`${e} subagent${e>1?`s`:``} running`,Gu=e=>e.state===`streaming`||Uu(e)||e.activeRuns>0;function Ku(e){if(!Gu(e))return[];let t=e.state===`streaming`?[`bg-green-500 animate-pulse`,`working…`]:Uu(e)?[`bg-amber-500`,`turn finished — not viewed yet`]:[`bg-sky-500`,Wu(e.activeRuns)],n=I(`span`,`h-2 w-2 flex-none rounded-full ${t[0]}`);return n.title=t[1],[n]}async function qu(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,ed(),Y.onTitleChanged()};r(t.trim()||void 0),(await x(`/api/sessions/${e.id}/rename`,{name:t})).ok||r(n)}var Ju=`flex-none text-xs font-medium uppercase leading-5 text-neutral-500`,Yu=e=>e.channel&&e.channel!==`web`?[I(`span`,Ju,e.channel[0]??``)]:[];function Xu(e,t=I(`button`,Hu,_(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`),...Ku(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,...Yu(e),t),r.title=[e.cwd,`active ${Yr(Lu(e))} ago · created ${new Date(e.createdAt).toLocaleDateString()}`,...e.channel&&e.channel!==`web`?[`answering ${e.channel}`]:[]].join(`
85
+ `),r}var Zu=()=>`${Y.currentId()??``}\n${$u}\n${JSON.stringify(Y.sessions())}`,Qu=``,$u=20;function ed(){let e=Zu();if(e===Qu)return;Qu=e;let t=Y.sessions(),n=t.filter(Uu);ku(n.length),du(n.length);let{rows:r,hidden:i}=zu(t,$u),a=Fu.querySelector(`.session-more[aria-expanded='true']`),o=a?.closest(`[data-session-id]`)?.dataset.sessionId,s=r.map(e=>Xu(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=()=>{$u+=20,ed(),Fu.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(Fu.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=[...Fu.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`&&(Fu.querySelector(`#session-load-more`)??Fu.querySelector(`.session-open`)??F(`#new-session`)).focus({preventScroll:!0});Nd()}function td(){if(Iu.getAttribute(`aria-expanded`)===`true`)return B();let e=Y.sessions().find(e=>e.id===Y.currentId())?.cwd,t=Ve(Y.sessions()).slice(0,Vu);if(e&&!t.includes(e)&&t.unshift(e),!t.length)return Da(Iu,void 0,Y.createSession);Oa(Iu,t.map(e=>({path:e,hint:Zr(e)})),e,Y.createSession)}function nd(e){Y=e,Iu.onclick=td,Qc(Iu,`shift+o`,`New session`,td,Jc);let t=e=>{let t=Bu(Y.sessions(),Y.currentId(),e);t&&Y.select(t)};nl(`shift+[`,()=>t(-1),Jc),nl(`shift+]`,()=>t(1),Jc)}var rd,id=F(`#palette`),ad=F(`#palette-input`),od=F(`#palette-list`),sd=F(`#palette-count`),cd=[{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:pe,label:`Settings`,detail:`Console — models and providers, agent files and extensions, channels, password, sign out, security`}],ld=7,ud=3,dd=8,fd=80,pd=``,md,hd,gd;function _d(e){pd!==e&&(clearTimeout(gd),hd?.abort(),hd=void 0,pd=e,md=void 0,e&&(gd=setTimeout(()=>{let t=hd=new AbortController;C(`/api/search?q=${encodeURIComponent(e)}`,`Search unavailable`,{signal:t.signal}).then(n=>{t.signal.aborted||pd!==e||(hd=void 0,md=n.ok?{hits:n.value.hits}:{error:n.error},id.open&&Md())})},fd)))}var vd=[],yd=0;function bd(e){if(vd.length){yd=(e+vd.length)%vd.length;for(let[e,{el:t}]of vd.entries())t.classList.toggle(`bg-indigo-50`,e===yd),t.setAttribute(`aria-selected`,String(e===yd));vd[yd]?.el.scrollIntoView({block:`nearest`})}}var xd=e=>e.hit?.at??e.session?.createdAt;function Sd(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 Cd=`flex min-w-0 flex-1 items-baseline gap-2`,wd=`shrink-0 truncate`,Td=`min-w-[2.5em] truncate text-[0.8125rem] text-neutral-400`,Ed=`flex-none text-[0.75rem] tabular-nums text-neutral-400`,Dd=`flex h-7 w-7 flex-none items-center justify-center rounded-[8px] bg-neutral-100 text-neutral-500`;function Od(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`,Dd,_(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(...Ku(e.session));let i=I(`span`,Cd,I(`span`,`${wd} ${e.detail?`max-w-[calc(100%-3em)]`:`max-w-full`}`,e.label));e.detail&&i.append(I(`span`,Td,e.detail)),r.append(i);let a=xd(e);return a!==void 0&&r.append(I(`span`,Ed,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`),Sd(e.hit.snippet))),t.append(n),t.onclick=e.open,t}var kd=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 Ad(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 jd=e=>e.channel&&e.channel!==`web`?e.channel:``;function Md(){let e=ad.value.trim(),t=e.toLowerCase().split(/\s+/).filter(Boolean),n=e=>{let n=e.toLowerCase();return t.every(e=>n.includes(e))},r=e=>()=>{id.close(),e()},i=rd.sessions(),a=new Map(i.map(e=>[e.id,e])),{top:o,rest:s}=Ru(i),c=[...o,...s],l=e=>({icon:ae,label:e.title??Qr(e.cwd),detail:[Zr(e.cwd),jd(e)].filter(Boolean).join(` · `),open:r(()=>void rd.select(e.id)),session:e}),u=e=>({icon:te,label:Qr(e),detail:e,open:r(()=>void rd.createSession(e))}),d=cd.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(()=>rd.openConsole(e))})),f={icon:te,label:`New session in…`,detail:`Pick a directory`,open:r(td)},p=[];if(e){let t=Ve(i).filter(e=>n(Zr(e))).slice(0,ud),o=c.filter(e=>n(`${e.title??``} ${e.cwd} ${jd(e)}`)).slice(0,dd),s=new Set(o.map(e=>e.id)),m=o.map(l);if(pd!==e||!md)m.push(Ad(`Searching messages…`));else if(`error`in md)m.push(Ad(`Message search unavailable`,md.error));else{for(let e of md.hits){if(m.length>=dd)break;let t=a.get(e.sessionId);!t||s.has(t.id)||m.push({...l(t),hit:e,open:r(()=>void rd.select(t.id).then(()=>Rs(e.role,e.at)))})}m.length||m.push(Ad(`No sessions match`))}p.push([`Actions`,[...t.map(u),...n(f.label)?[f]:[],...d]],[`Sessions`,m])}else{let e=a.get(rd.currentId()??``);p.push([`Running`,c.filter(Gu).map(l)],[`Recent`,c.filter(e=>!Gu(e)).slice(0,ld).map(l)],[`Actions`,[...e?[u(e.cwd)]:[],f]],[`Console`,d])}vd=[];let m=[];for(let[e,t]of p)if(t.length){m.push(kd(e));for(let e of t){if(e instanceof HTMLElement){m.push(e);continue}let t=Od(e);vd.push({el:t,open:e.open}),m.push(t)}}od.replaceChildren(...m.length?m:[Ad(`Nothing matches`)]),sd.textContent=`${vd.length} ${vd.length===1?`row`:`rows`}`,bd(Math.min(yd,Math.max(0,vd.length-1)))}function Nd(){id.open&&Md()}function Pd(){if(id.open)return id.close();ad.value=``,yd=0,_d(``),Md(),id.showModal(),ad.focus(),rd.loadSessions().then(Nd)}function Fd(e){rd=e;let t=F(`#open-palette`);t.onclick=Pd,Qc(t,`k`,`Search sessions, messages and Console`,Pd,()=>id.open||la()),id.onclick=e=>{e.target===id&&id.close()},id.onclose=()=>_d(``),ad.oninput=()=>{yd=0,_d(ad.value.trim()),Md()},ad.onkeydown=e=>{let t=ua(e);if(t!==void 0){e.preventDefault(),bd(yd+t);return}e.key===`Enter`&&!e.ctrlKey&&(e.preventDefault(),vd[yd]?.open())}}var Id=0,Ld=e=>`${e.provider}/${e.id}`,Rd=null;async function zd(){let{modelMenu:e}=await Ge(`/api/settings`,`Could not read the pinned model menu`);return e}function Bd(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`,_(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 Vd({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`,xe(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,_(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-${++Id}`;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=xe(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`,xe(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=>[Ld(e),e])),p=e=>{let n=(Rd??[]).map(e=>({e,model:f.get(Ld(e))})).filter(t=>!!t.model&&(!e||Ld(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})=>Bd({label:n.id,hint:xe(e.thinking),title:e.note,checked:!!t&&Ld(t)===Ld(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&&!Ld(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&&Ld(t)===Ld(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`,_(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=>Bd({label:e.id,checked:!!t&&Ld(t)===Ld(e),onSelect:()=>i(e)}))),d.append(o)}};return u.oninput=()=>m(u.value),m(``),zd().then(e=>{let t=JSON.stringify(e)!==JSON.stringify(Rd);Rd=e,t&&m(u.value)}).catch(e=>Lc(`model menu unavailable`,e)),s.append(c,d),queueMicrotask(()=>u.focus()),s}function Hd(e,t,n,r){let i=L(t.model?`${t.model.id}${t.thinking?` · ${xe(t.thinking)}`:``}`:t.thinking?`Pi default · ${xe(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=Vd({models:n,current:t.model,thinkingLevel:t.thinking??`medium`,thinkingLevels:[...No],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),va(i,o)},Si(e,i)}var X;function Ud(e){X=e,nl(Wd,()=>{X.currentSession()&&(B(),X.toggleFiles())},Jc)}var Wd=`i`,Gd=F(`#chat-title`),Kd=F(`#chat-menu`),qd=F(`#session-meta`),Jd=null,Yd=new Map,Xd=e=>`${e.provider}/${e.id}`,Z=null,Zd=null,Qd=null,$d=null;function ef(){Z=null,Zd=null,Qd=null,$d=null,uf()}function tf(e,t,n,r){Z=e,Zd=t,Qd=n,$d=r,of()}function nf(e){$d=e.completedAt,Zd&&={...Zd,tokens:e.tokens},uf()}var rf=null;function af(e){rf=e===null?null:Qr(e),of()}function of(){let e=X.currentSession();e&&(rf=null),Gd.textContent=e?e.title??Qr(e.cwd):rf??X.currentId()??`no session`,Gd.classList.toggle(`cursor-pointer`,!!e),Gd.title=e?`Session info`:``,Gd.onclick=e?()=>df(Gd,e):null,Kd.classList.toggle(`hidden`,!e),e&&(Kd.onclick=()=>vf(Kd,e)),uf(),X.syncBar()}var sf=70,cf=(e,t)=>Math.min(100,Math.round(e/t.contextWindow*100)),lf=e=>e.tokens===null?`?/${Se(e.contextWindow)}`:`${Se(e.tokens)}/${Se(e.contextWindow)} · ${100-cf(e.tokens,e)}% left`;function uf(){let e=Zd,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`,_(h,`spinner h-3 w-3`),`${r} running`);e.title=`${Wu(r)} · show the newest`,e.onclick=()=>{zs()||W(`error`,`no run card left in this transcript — reload the session to see it`)},i.push(e)}if(!n&&rf&&i.push(I(`span`,`flex flex-none items-center gap-1.5 text-neutral-500`,_(h,`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 ff(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`)),Qd&&i.push(e(Qd,`flex-none text-neutral-500 hover:text-indigo-700`))}let a=0;if(e&&t!==null){a=cf(t,e);let n=a>=90?`text-red-700`:a>=sf?`text-amber-700`:`text-neutral-500`;i.push(I(`span`,`flex-none font-mono ${n}`,Se(t).toLowerCase()))}let o=i.flatMap((e,t)=>t===0?[e]:[I(`span`,`flex-none text-neutral-300`,`·`),e]);qd.replaceChildren(...o),qd.classList.toggle(`hidden`,i.length===0),qd.classList.toggle(`flex`,i.length>0),qd.toggleAttribute(`data-urgent`,!n&&!!rf||r>0||a>=sf)}function df(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`,Qd??`—`]),i.push([`Context`,Zd?lf(Zd):`—`])),i.push([`Created`,$r(t.createdAt),Xr(t.createdAt)]),a){let e=$d;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`,_(_e));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`,_(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),va(e,o)}async function ff(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(gf(e,n,`Close model picker`)),va(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=Vd({models:n,current:t===X.currentId()?Z:null,thinkingLevel:r,thinkingLevels:o,onPick:(e,n)=>{B(),pf(t,e,n)},onThinkingPick:e=>void hf(t,e)});a.replaceWith(l),a=l,va(e,i)},l=t===X.currentId()&&Z?Yd.get(Xd(Z)):void 0;Jd&&l&&Qd&&c(Jd,Qd,l);try{let[e,n]=await Promise.all([Ge(`/api/sessions/${t}/models`,`Could not load models`),Ge(`/api/sessions/${t}/thinking`,`Could not read the reasoning level`)]);if(Jd=e,t===X.currentId()&&Z&&Yd.set(Xd(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 pf(e,t,n){await mf(e,t)&&n&&await hf(e,n)}async function mf(e,t){let n=Z;e===X.currentId()&&(Z=t,of());let r=await x(`/api/sessions/${e}/model`,t);if(!r.ok){let{error:t}=await r.json().catch(()=>({}));return e===X.currentId()&&(Z=n,of()),W(`error`,`model change failed: ${t??r.status}`),!1}let{model:i}=await r.json();return e===X.currentId()&&i&&(Z=i,of()),!0}async function hf(e,t){let n=await x(`/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()&&(Qd=r,uf())}function gf(e,t,n){let i=I(`button`,`icon-btn h-11 w-11`,_(r));i.setAttribute(`aria-label`,`Back to session actions`),i.onclick=()=>vf(e,t);let a=I(`button`,`icon-btn h-11 w-11`,_(_e));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 _f(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`,gf(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);va(e,r);let i=await C(`/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 x(`/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 vf(e,t){let n=t.id===X.currentId();ba(e,[{label:`Rename…`,onSelect:()=>{B(),qu(t)}},{label:`Session info`,onSelect:()=>df(e,t,()=>vf(e,t))},{label:`New session here`,separatorBefore:!0,hint:Zr(t.cwd),onSelect:()=>{B(),X.createSession(t.cwd)}},{label:`Browse files`,hint:n?qc(Wd):``,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 _f(e,t)},{label:`Model & reasoning…`,separatorBefore:!0,hint:n?Z?.id??`…`:``,onSelect:()=>void ff(e,t.id,t)}],t.title??Qr(t.cwd))}var yf=`pier.theme`,bf=[`system`,`light`,`dark`],xf=window.matchMedia(`(prefers-color-scheme: dark)`),Sf={system:se,light:he,dark:g},Cf=()=>{let e=null;try{e=localStorage.getItem(yf)}catch{return`system`}return e===`light`||e===`dark`?e:`system`},wf=()=>{let e=Cf();return e===`system`?xf.matches?`dark`:`light`:e};function Tf(){let e=wf();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 Ef(){let e=F(`#theme-toggle`),t=()=>{let t=Cf();e.title=`Theme: ${t}${t===`system`?` (${wf()})`:``}`,e.replaceChildren(_(Sf[t])),e.setAttribute(`aria-label`,e.title),Tf()};e.onclick=()=>{let e=bf[(bf.indexOf(Cf())+1)%bf.length];try{e===`system`?localStorage.removeItem(yf):localStorage.setItem(yf,e)}catch{}t()},xf.addEventListener(`change`,t),t()}var Df=`https://github.com/timqi/pier`,Of=[`text-neutral-400`,`hover:text-neutral-700`],kf=[`rounded-full`,`bg-emerald-50`,`px-1.5`,`text-emerald-700`,`ring-1`,`ring-inset`,`ring-emerald-600/20`,`hover:bg-emerald-100`],Af=18e5,jf=null,Mf=F(`#version`);function Nf(e){let t=jf?.available===!0&&jf.latest!==null;Mf.textContent=`v${e}`,Mf.title=t?`Pier ${jf?.latest} is out`:``,Mf.classList.remove(...t?Of:kf),Mf.classList.add(...t?kf:Of)}var Pf=(e,t=`px-3 py-1 text-[12px] leading-snug text-neutral-500`)=>I(`p`,t,e);function Ff(){let e=I(`div`,`flex w-72 flex-col gap-1 py-1`);if(!jf)return e.append(Pf(`Checking the registry…`)),e;let{current:t,latest:n,available:r,canApply:i,problem:a}=jf,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(Pf(r?`Pier ${n} is out`:`Pier ${t}`,`px-3 py-1 text-[12.5px] font-medium text-neutral-700`),Pf(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(Pf(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 x(`/api/update`,{});if(!t.ok)return e.disabled=!1,s(!0,await S(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?`${Df}/releases`:Df,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(Pf(`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.`,jf.autoUpdate,e=>void(async()=>{jf&&(jf.autoUpdate=e);let t=await x(`/api/settings`,{autoUpdate:e},`PUT`);t.ok||(jf&&(jf.autoUpdate=!e),u&&(u.checked=!e),s(!0,await S(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 If(e){let t=await C(`/api/update`,`Update check failed`);t.ok&&Nf((jf=t.value).current||e)}function Lf(e){Nf(e),Mf.onclick=e=>{e.preventDefault(),va(Mf,Ff())};let t=()=>void If(e);t(),setInterval(t,Af)}var Q,Rf=F(`#chat-header`),zf=F(`#chat-title`),Bf=[Rf,U,F(`#composer`)],Vf=()=>Jf===null,Hf,Uf,Wf,Gf=new Map,Kf=new Map,qf=new Map,Jf=null,Yf=0,Xf=[`files`],Zf=new Map,Qf={tasks:`Tasks`,runs:`Runs`,activity:`Activity`,boards:`Boards`,settings:`Settings`,files:`Files`},$f=[`tasks`,`runs`,`activity`],ep=`Automation`,tp=F(`#automation-view`),np=F(`#automation-tabs`),rp=e=>$f.includes(e)?`tasks`:e;function ip(e,t){let n=e!==null&&$f.includes(e);if(tp.classList.toggle(`hidden`,!n),tp.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=!Hf,e.onclick=()=>Hf?.create(),r.push(e)}np.replaceChildren(fi(ep),...$f.map(t=>gi(Qf[t],t===e,()=>lp(t))),...r)}var ap=e=>Hf?.refresh(e),op=()=>Uf?.refresh(),sp=()=>Wf?.refresh();function cp(){Jf?vu($f.includes(Jf)?ep:Qf[Jf],!1):vu(zf.textContent??``,Q.currentSession()!==void 0)}function lp(e,t,n){if(Xf.includes(e)){let t=xp();t&&(t.kind!==`console`||t.name!==e)&&Zf.set(e,t)}Cp({kind:`console`,name:e,arg:t,query:n}),_u(),Jf=e;for(let e of Bf)e.classList.add(`hidden`);El();for(let[t,n]of Gf)t!==e&&n.hide();for(let[t,n]of qf)n.classList.toggle(`bg-indigo-50`,t===rp(e));ip(e,t),cp(),up(e,t,n,++Yf)}async function up(e,t,n,r){let i=Gf.get(e);if(!i){let t=Kf.get(e);if(!t){let n=F(`#${e}-view`);t=Ep[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 ${Qf[e]} — reload the page.`))))),Kf.set(e,t)}i=await t,Gf.set(e,i),Kf.delete(e)}Jf===e&&r===Yf&&(i.show(t,n),e===`tasks`&&ip(e,t))}var dp=e=>lp(`tasks`,e),fp=(e={},t)=>lp(`runs`,t,new URLSearchParams(e).toString()),pp=e=>fp({},e),mp=(e,t)=>lp(`files`,e,t?new URLSearchParams({select:t}).toString():void 0),hp=(e,t)=>{Jf===e?_p(e):lp(e,t)},gp=e=>hp(`files`,e);function _p(e){let t=Q.currentId(),n=Zf.get(e)??(t?{kind:`session`,id:t}:null);Zf.delete(e),n?Cp(n):(history.replaceState(null,``,`#/`),vp())}function vp(){if(Jf){Jf=null;for(let e of Gf.values())e.hide();for(let e of qf.values())e.classList.remove(`bg-indigo-50`);ip(null);for(let e of Bf)e.classList.remove(`hidden`);El(),cp(),Q.maybeAckRead()}}var yp=e=>e.kind===`session`?`#/session/${encodeURIComponent(e.id)}`:`#/${e.name}${e.arg?`/${encodeURIComponent(e.arg)}`:``}${e.query?`?${e.query}`:``}`,bp={config:`files`,channels:`channels`,providers:`models`};function xp(){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 bp[n]?{kind:`console`,name:`settings`,arg:bp[n]}:Object.hasOwn(Qf,n)?{kind:`console`,name:n,arg:a,query:i}:n===`session`&&a?{kind:`session`,id:a}:null}var Sp=!1;function Cp(e,t=!1){if(Sp)return;let n=yp(e);location.hash!==n&&(t?history.replaceState(null,``,n):location.hash=n)}var wp=e=>Cp({kind:`session`,id:e});function Tp(){let e=xp(),t=Q.sessions(),n=Q.currentId(),r=e?.kind===`session`?e.id:null,{top:i,rest:a}=Ru(t),o=r??n??(i[0]??a[0])?.id??null;Sp=!0;try{o&&o!==n&&Q.select(o),e?.kind===`console`?lp(e.name,e.arg,e.query):vp(),o||of()}finally{Sp=!1}e?.kind!==`console`&&o&&Cp({kind:`session`,id:o},!0)}var Ep={tasks:async e=>Hf=(await Ki(async()=>{let{createTasksView:e}=await import(`./tasks-kIXfyOri.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(),fp,dp),runs:async e=>Uf=(await Ki(async()=>{let{createRunsView:e}=await import(`./runs-CG0zz7Gm.js`);return{createRunsView:e}},__vite__mapDeps([2,1]))).createRunsView(e,Q.select,fp,dp),activity:async e=>Wf=(await Ki(async()=>{let{createActivityView:e}=await import(`./activity-DjZb4ZV0.js`);return{createActivityView:e}},[])).createActivityView(e,Q.select,pp),boards:async e=>(await Ki(async()=>{let{createBoardsView:e}=await import(`./boards-C3wVfF2L.js`);return{createBoardsView:e}},[])).createBoardsView(e,Q.select),files:async e=>(await Ki(async()=>{let{createExplorerView:e}=await import(`./explorer-Dv6dIcpa.js`);return{createExplorerView:e}},[])).createExplorerView(e,()=>Q.currentSession(),e=>lp(`files`,e),()=>_p(`files`)),settings:async e=>(await Ki(async()=>{let{createSettingsView:e}=await import(`./settings-DmRxpIWY.js`);return{createSettingsView:e}},[])).createSettingsView(e,()=>Ve(Q.sessions()),e=>lp(`settings`,e),mp)};function Dp(e){Q=e;for(let e of[`tasks`,`boards`,`settings`]){let t=F(`#open-${e}`);qf.set(e,t),t.onclick=()=>lp(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=Tp}var Op=[],kp=null,Ap=0,jp=0,Mp=!1,$=null,Np=`idle`,Pp=null,Fp=0,Ip=!1,Lp=!1;async function Rp(e){let t=++Ap;++jp,Mp=!1,vp(),_u(),$=null,Pp?.close(),Pp=null,Oc(),Dl([]),ef(),af(e),kc(!0),Lp=!0,Tl();let n=await x(`/api/sessions`,{cwd:e});if(t!==Ap)return;if(Lp=!1,!n.ok){kc(!1),af(null),Tl(),W(`error`,`session create failed: ${n.status}`);return}let{id:r}=await n.json();t===Ap&&(Op.unshift({id:r,cwd:e,createdAt:Date.now(),state:`idle`,unread:!1,channel:`web`,activeRuns:0}),await Yp(r),$===r&&xl())}function zp(e){Op=e.map(e=>({...e,title:ze(e.title)})),Op.sort((e,t)=>t.createdAt-e.createdAt),ed(),of(),Vp()}var Bp=He(async()=>{zp(await Ge(`/api/sessions`,`Could not load sessions`))});function Vp(){if(document.hidden||!document.hasFocus()||!Vf())return;let e=Op.find(e=>e.id===$);e?.unread&&(e.unread=!1,ed(),fetch(`/api/sessions/${e.id}/read`,{method:`POST`}))}function Hp(){return Op.find(e=>e.id===$)??(kp&&kp.id===$?kp:void 0)}async function Up(e){let t=await C(`/api/sessions/${e}`,`failed to load session`);$!==e||!t.ok||(kp={...t.value,title:ze(t.value.title)},of())}function Wp(e,t){let n=Op.find(t=>t.id===e);!n||n.title||!t.trim()||(n.title=t.trim().slice(0,80),ed(),of())}function Gp(e){Np=e;let t=Op.find(e=>e.id===$);t&&(t.state=e),ed(),of(),Tl(),e===`idle`&&Bp()}function Kp(e){if(!(e.sessionId!==$||e.seq<=Fp))switch(Fp=e.seq,e.type){case`turn-start`:Ip=!0;break;case`system-input`:wc(),Xs(e.text,e.origin);break;case`task-status`:qo(e.run);break;case`user-message`:{let t=Ie(e.text).text;if(Wp(e.sessionId,t),Sl(t))break;wc(),W(`user`,e.text,!1,e.ts),Is();break}case`text-start`:wc();break;case`text-delta`:Cc(e.text);break;case`thinking-delta`:wc(),Ss(e.ts,e.text);break;case`tool-start`:wc(),ys(e.ts,e.toolCallId,e.toolName,e.args);break;case`tool-end`:xs(e.toolCallId,e.isError,e.output);break;case`turn-end`:Ip=!1,Ec(e.text,e.meta),e.meta&&nf(e.meta);break;case`queue-state`:Ol(e.steering,e.followUp);break;case`queue-recovery`:Dl(e.batches,e.uncertain);break;case`context-compacted`:wc(),W(`system`,`Context compacted — ${Se(e.before)} → ${Se(e.after)}`,!1,e.ts),Is();break;case`error`:_s(),W(`error`,e.message);break;case`state`:e.state===`idle`&&Ip&&(Ip=!1,Dc()),e.state===`idle`&&Ol([],[]),Gp(e.state)}}function qp(){let e=new EventSource(`/api/events`);e.onopen=()=>{Bp(),ap(),op(),sp()},e.onerror=()=>Hc(e,`Workspace`),e.onmessage=e=>{let t=JSON.parse(e.data);if(t.type===`sessions-changed`){Bp();return}if(t.type===`tasks-changed`||t.type===`task-run-changed`||t.type===`task-message-changed`||t.type===`task-group-changed`){ap(t.type===`task-run-changed`?t.taskId:void 0),op(),sp(),t.type===`task-run-changed`&&Bp();return}if(sp(),t.sessionId===$)return;let n=Op.find(e=>e.id===t.sessionId);n&&(n.state=t.state,ed())}}function Jp(e,t,n){Pp?.close();let r=new EventSource(`/api/sessions/${e}/events?after=${t}`),i=()=>Pp===r&&$===e&&n===jp;r.onmessage=e=>{i()&&Kp(JSON.parse(e.data))},r.addEventListener(`reset`,()=>{i()&&Xp(e)}),r.onerror=()=>{i()&&Hc(r,`Session`)},Pp=r}async function Yp(e){vp(),_u(),wp(e),!(e===$&&(Pp||Mp))&&(++Ap,++jp,Lp=!1,zl(),$=e,kp=null,Op.some(t=>t.id===e)||Up(e),Np=Op.find(t=>t.id===e)?.state??`idle`,Bl(e),ed(),of(),Vp(),await Xp(e))}async function Xp(e){if($!==e)return;let t=++jp;Pp?.close(),Pp=null,Mp=!0,Oc(),Ol([],[]),Dl([]),ef(),Ip=!1,wl(),Fp=0,kc(!0);let n=await C(`/api/sessions/${e}/history`,`failed to load session`);if($!==e||t!==jp)return;if(Mp=!1,!n.ok){kc(!1),W(`error`,n.error);return}let r=n.value;Ac(r.turns,r.state,r.backgroundRuns),Fp=r.lastSeq,Ip=r.state===`streaming`,Gp(r.state),Ol(r.queue.steering,r.queue.followUp),Dl(r.queueRecovery,r.queueUncertain);let i=r.turns.reduce((e,t)=>t.meta?.completedAt??e,null);tf(r.model,r.context,r.thinkingLevel,i),Jp(e,`${r.epoch}:${r.lastSeq}`,t)}Rc(),ve(),Vc(),Ef();var Zp=async e=>{$===e&&await Xp(e)};Os({sessionId:()=>$,sessionCwd:()=>Hp()?.cwd??null,sessionChannel:()=>Hp()?.channel??null,sessionState:()=>Np,select:e=>void Yp(e),showRun:pp,send:(e,t)=>void Ul(e,t),ownTurn:e=>{Cl(e),Gp(`streaming`)},reload:Zp}),Kl({sessionId:()=>$,starting:()=>Lp,sessionState:()=>Np,chatVisible:Vf,setState:Gp,reload:Zp}),Pu({sessionMenu:e=>{let t=Hp();t&&vf(e,t)},sessionInfo:e=>{let t=Hp();t&&df(e,t)}}),nd({sessions:()=>Op,currentId:()=>$,select:e=>void Yp(e),sessionMenu:vf,createSession:Rp,onTitleChanged:of}),Fd({sessions:()=>Op,loadSessions:Bp,currentId:()=>$,select:Yp,createSession:Rp,openConsole:lp}),Ud({currentId:()=>$,currentSession:Hp,createSession:e=>void Rp(e),syncBar:cp,openFiles:mp,toggleFiles:gp}),Dp({sessions:()=>Op,loadSessions:Bp,currentId:()=>$,currentSession:Hp,select:e=>void Yp(e),maybeAckRead:Vp}),Lf(`0.1.13`),su(),document.addEventListener(`gesturestart`,e=>e.preventDefault()),document.addEventListener(`visibilitychange`,Vp),window.addEventListener(`focus`,Vp),qp(),Bp().then(Tp);export{He as $,Fi as A,Oi as B,ji as C,Ni as D,xi as E,mi as F,Zr as G,pi as H,Di as I,ui as J,ti as K,R as L,fi as M,gi as N,Pi as O,Mi as P,Qr as Q,hi as R,Ai as S,di as T,Ii as U,ki as V,Xr as W,I as X,ei as Y,Yr as Z,Ci as _,tl as a,x as at,_i as b,ja as c,_ as ct,ba as d,h as dt,S as et,va as f,l as ft,bi as g,Qi as h,a as ht,fu as i,Ke as it,Ei as j,Si as k,Oa as l,_e as lt,ta as m,o as mt,Hd as n,Ge as nt,No as o,ze as ot,na as p,s as pt,ai as q,Vd as r,We as rt,Po as s,xe as st,df as t,C as tt,B as u,ue as ut,wi as v,L as w,vi as x,yi as y,Ti as z};