quadwork 1.6.0 → 1.6.2

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 (81) hide show
  1. package/bridges/discord/discord_bridge.py +480 -0
  2. package/bridges/discord/requirements.txt +2 -0
  3. package/out/404.html +1 -1
  4. package/out/__next.__PAGE__.txt +1 -1
  5. package/out/__next._full.txt +2 -2
  6. package/out/__next._head.txt +1 -1
  7. package/out/__next._index.txt +2 -2
  8. package/out/__next._tree.txt +2 -2
  9. package/out/_next/static/chunks/0j-zyy6.adwtl.css +2 -0
  10. package/out/_next/static/chunks/{07wbvkahjk4k3.js → 0ksh60pbzmyjf.js} +2 -2
  11. package/out/_next/static/chunks/{0c280.d83m4fs.js → 0zy-ktdv5zuby.js} +1 -1
  12. package/out/_not-found/__next._full.txt +2 -2
  13. package/out/_not-found/__next._head.txt +1 -1
  14. package/out/_not-found/__next._index.txt +2 -2
  15. package/out/_not-found/__next._not-found.__PAGE__.txt +1 -1
  16. package/out/_not-found/__next._not-found.txt +1 -1
  17. package/out/_not-found/__next._tree.txt +2 -2
  18. package/out/_not-found.html +1 -1
  19. package/out/_not-found.txt +2 -2
  20. package/out/app-shell/__next._full.txt +2 -2
  21. package/out/app-shell/__next._head.txt +1 -1
  22. package/out/app-shell/__next._index.txt +2 -2
  23. package/out/app-shell/__next._tree.txt +2 -2
  24. package/out/app-shell/__next.app-shell.__PAGE__.txt +1 -1
  25. package/out/app-shell/__next.app-shell.txt +1 -1
  26. package/out/app-shell.html +1 -1
  27. package/out/app-shell.txt +2 -2
  28. package/out/icon.svg +9 -0
  29. package/out/index.html +1 -1
  30. package/out/index.txt +2 -2
  31. package/out/project/_/__next._full.txt +3 -3
  32. package/out/project/_/__next._head.txt +1 -1
  33. package/out/project/_/__next._index.txt +2 -2
  34. package/out/project/_/__next._tree.txt +2 -2
  35. package/out/project/_/__next.project.$d$id.__PAGE__.txt +2 -2
  36. package/out/project/_/__next.project.$d$id.txt +1 -1
  37. package/out/project/_/__next.project.txt +1 -1
  38. package/out/project/_/memory/__next._full.txt +2 -2
  39. package/out/project/_/memory/__next._head.txt +1 -1
  40. package/out/project/_/memory/__next._index.txt +2 -2
  41. package/out/project/_/memory/__next._tree.txt +2 -2
  42. package/out/project/_/memory/__next.project.$d$id.memory.__PAGE__.txt +1 -1
  43. package/out/project/_/memory/__next.project.$d$id.memory.txt +1 -1
  44. package/out/project/_/memory/__next.project.$d$id.txt +1 -1
  45. package/out/project/_/memory/__next.project.txt +1 -1
  46. package/out/project/_/memory.html +1 -1
  47. package/out/project/_/memory.txt +2 -2
  48. package/out/project/_/queue/__next._full.txt +2 -2
  49. package/out/project/_/queue/__next._head.txt +1 -1
  50. package/out/project/_/queue/__next._index.txt +2 -2
  51. package/out/project/_/queue/__next._tree.txt +2 -2
  52. package/out/project/_/queue/__next.project.$d$id.queue.__PAGE__.txt +1 -1
  53. package/out/project/_/queue/__next.project.$d$id.queue.txt +1 -1
  54. package/out/project/_/queue/__next.project.$d$id.txt +1 -1
  55. package/out/project/_/queue/__next.project.txt +1 -1
  56. package/out/project/_/queue.html +1 -1
  57. package/out/project/_/queue.txt +2 -2
  58. package/out/project/_.html +1 -1
  59. package/out/project/_.txt +3 -3
  60. package/out/settings/__next._full.txt +2 -2
  61. package/out/settings/__next._head.txt +1 -1
  62. package/out/settings/__next._index.txt +2 -2
  63. package/out/settings/__next._tree.txt +2 -2
  64. package/out/settings/__next.settings.__PAGE__.txt +1 -1
  65. package/out/settings/__next.settings.txt +1 -1
  66. package/out/settings.html +1 -1
  67. package/out/settings.txt +2 -2
  68. package/out/setup/__next._full.txt +2 -2
  69. package/out/setup/__next._head.txt +1 -1
  70. package/out/setup/__next._index.txt +2 -2
  71. package/out/setup/__next._tree.txt +2 -2
  72. package/out/setup/__next.setup.__PAGE__.txt +1 -1
  73. package/out/setup/__next.setup.txt +1 -1
  74. package/out/setup.html +1 -1
  75. package/out/setup.txt +2 -2
  76. package/package.json +2 -1
  77. package/server/index.js +194 -21
  78. package/out/_next/static/chunks/0gbucesq78fzb.css +0 -2
  79. /package/out/_next/static/{vgerah8Gaf36Lt50oHob8 → AQ0US7_Pm9gOOelb-ks5q}/_buildManifest.js +0 -0
  80. /package/out/_next/static/{vgerah8Gaf36Lt50oHob8 → AQ0US7_Pm9gOOelb-ks5q}/_clientMiddlewareManifest.js +0 -0
  81. /package/out/_next/static/{vgerah8Gaf36Lt50oHob8 → AQ0US7_Pm9gOOelb-ks5q}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,26568,(e,i,r)=>{"use strict";var s=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,o=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,h=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,d=/^\s+|\s+$/g;function u(e){return e?e.replace(d,""):""}i.exports=function(e,i){if("string"!=typeof e)throw TypeError("First argument must be a string");if(!e)return[];i=i||{};var r=1,d=1;function f(e){var i=e.match(n);i&&(r+=i.length);var s=e.lastIndexOf("\n");d=~s?e.length-s:d+e.length}function p(){var e={line:r,column:d};return function(i){return i.position=new _(e),g(o),i}}function _(e){this.start=e,this.end={line:r,column:d},this.source=i.source}function m(s){var n=Error(i.source+":"+r+":"+d+": "+s);if(n.reason=s,n.filename=i.source,n.line=r,n.column=d,n.source=e,i.silent);else throw n}function g(i){var r=i.exec(e);if(r){var s=r[0];return f(s),e=e.slice(s.length),r}}function v(e){var i;for(e=e||[];i=x();)!1!==i&&e.push(i);return e}function x(){var i=p();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var r=2;""!=e.charAt(r)&&("*"!=e.charAt(r)||"/"!=e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return m("End of comment missing");var s=e.slice(2,r-2);return d+=2,f(s),e=e.slice(r),d+=2,i({type:"comment",comment:s})}}_.prototype.content=e,g(o);var b,y=[];for(v(y);b=function(){var e=p(),i=g(l);if(i){if(x(),!g(a))return m("property missing ':'");var r=g(h),n=e({type:"declaration",property:u(i[0].replace(s,"")),value:r?u(r[0].replace(s,"")):""});return g(c),n}}();)!1!==b&&(y.push(b),v(y));return y}},70454,(e,i,r)=>{"use strict";var s=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,i){let r=null;if(!e||"string"!=typeof e)return r;let s=(0,n.default)(e),o="function"==typeof i;return s.forEach(e=>{if("declaration"!==e.type)return;let{property:s,value:n}=e;o?i(s,n,e):n&&((r=r||{})[s]=n)}),r};let n=s(e.r(26568))},65185,(e,i,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.camelCase=void 0;var s=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,o=/^[^-]+$/,l=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,h=function(e,i){return i.toUpperCase()},c=function(e,i){return"".concat(i,"-")};r.camelCase=function(e,i){var r;return(void 0===i&&(i={}),!(r=e)||o.test(r)||s.test(r))?e:(e=e.toLowerCase(),(e=i.reactCompat?e.replace(a,c):e.replace(l,c)).replace(n,h))}},15511,(e,i,r)=>{"use strict";var s=(e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(e.r(70454)),n=e.r(65185);function o(e,i){var r={};return e&&"string"==typeof e&&(0,s.default)(e,function(e,s){e&&s&&(r[(0,n.camelCase)(e,i)]=s)}),r}o.default=o,i.exports=o},4100,(e,i,r)=>{"use strict";var s=Object.prototype.hasOwnProperty,n=Object.prototype.toString,o=Object.defineProperty,l=Object.getOwnPropertyDescriptor,a=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===n.call(e)},h=function(e){if(!e||"[object Object]"!==n.call(e))return!1;var i,r=s.call(e,"constructor"),o=e.constructor&&e.constructor.prototype&&s.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!r&&!o)return!1;for(i in e);return void 0===i||s.call(e,i)},c=function(e,i){o&&"__proto__"===i.name?o(e,i.name,{enumerable:!0,configurable:!0,value:i.newValue,writable:!0}):e[i.name]=i.newValue},d=function(e,i){if("__proto__"===i){if(!s.call(e,i))return;else if(l)return l(e,i).value}return e[i]};i.exports=function e(){var i,r,s,n,o,l,u=arguments[0],f=1,p=arguments.length,_=!1;for("boolean"==typeof u&&(_=u,u=arguments[1]||{},f=2),(null==u||"object"!=typeof u&&"function"!=typeof u)&&(u={});f<p;++f)if(i=arguments[f],null!=i)for(r in i)s=d(u,r),u!==(n=d(i,r))&&(_&&n&&(h(n)||(o=a(n)))?(o?(o=!1,l=s&&a(s)?s:[]):l=s&&h(s)?s:{},c(u,{name:r,newValue:e(_,l,n)})):void 0!==n&&c(u,{name:r,newValue:n}));return u}},55601,e=>{"use strict";let i,r,s,n,o,l,a,h,c,d,u,f;var p=e.i(43476),_=e.i(71645);function m({label:e,status:i,projectId:r,agentId:s,onStatusChange:n,tooltip:o}){let l="running"===i?"bg-accent":"error"===i?"bg-error":"bg-text-muted",a=e=>{r&&s&&fetch(`/api/agents?project=${encodeURIComponent(r)}&agent=${encodeURIComponent(s)}&action=${e}`,{method:"POST"}).then(e=>e.json()).then(e=>{n&&e.state&&n(e.state)}).catch(()=>{})};return(0,p.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 h-7 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[i&&(0,p.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${l}`}),(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:e}),o]}),r&&s&&(0,p.jsxs)("div",{className:"flex items-center gap-1",children:["running"!==i&&(0,p.jsx)("button",{onClick:()=>a("start"),className:"text-[10px] text-text-muted hover:text-accent transition-colors px-1",title:"Start",children:"▶"}),"running"===i&&(0,p.jsx)("button",{onClick:()=>a("stop"),className:"text-[10px] text-text-muted hover:text-error transition-colors px-1",title:"Stop",children:"■"}),(0,p.jsx)("button",{onClick:()=>a("restart"),className:"text-[10px] text-text-muted hover:text-accent transition-colors px-1",title:"Restart",children:"↻"})]})]})}function g({children:e}){let[i,r]=(0,_.useState)(!1),s=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(!i)return;let e=e=>{s.current&&!s.current.contains(e.target)&&r(!1)},n=e=>{"Escape"===e.key&&r(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",n),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",n)}},[i]),(0,p.jsxs)("div",{ref:s,className:"relative inline-flex items-center",children:[(0,p.jsx)("button",{type:"button",onClick:()=>r(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"}),i&&(0,p.jsx)("div",{className:"absolute left-0 top-5 z-30 w-64 p-2 text-[10px] leading-snug text-text bg-bg-surface border border-border rounded shadow-lg",children:e})]})}var v=e.i(78759);let x=["@head start a new feature: <describe>","@head review the latest PR","@head what's our current sprint?"];function b({onInsert:e}){let[i,r]=(0,_.useState)(!1);return(0,p.jsxs)("div",{className:"flex flex-col items-center justify-center text-center px-6 py-10 gap-3",children:[(0,p.jsxs)("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none","aria-hidden":!0,className:"text-accent",children:[(0,p.jsx)("path",{d:"M6 8h28a2 2 0 0 1 2 2v17a2 2 0 0 1-2 2H16l-7 6v-6h-3a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2Z",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),(0,p.jsx)("circle",{cx:"14",cy:"18",r:"1.4",fill:"currentColor"}),(0,p.jsx)("circle",{cx:"20",cy:"18",r:"1.4",fill:"currentColor"}),(0,p.jsx)("circle",{cx:"26",cy:"18",r:"1.4",fill:"currentColor"})]}),(0,p.jsx)("div",{className:"text-[13px] font-semibold text-text",children:"Ready when you are"}),(0,p.jsx)("div",{className:"text-[11px] text-text-muted",children:"Tell your team what to build. Try something like:"}),(0,p.jsx)("div",{className:"flex flex-col gap-1.5 mt-1 w-full max-w-sm",children:x.map(i=>(0,p.jsx)("button",{type:"button",onClick:()=>e(i),className:"text-left px-2 py-1 text-[11px] font-mono text-text-muted border border-border hover:text-accent hover:border-accent transition-colors truncate",children:i},i))}),(0,p.jsx)("button",{type:"button",onClick:()=>r(!0),className:"mt-2 text-[11px] text-text-muted underline underline-offset-2 hover:text-text",children:"How to Work"}),(0,p.jsx)(v.default,{open:i,onClose:()=>r(!1)})]})}let y={head:"#00ff88",re1:"#4488ff",re2:"#cc44ff",dev:"#ffcc00",user:"#e0e0e0",system:"#737373"},S=["head","re1","re2","dev","user"],w=[{command:"/artchallenge",description:"SVG art challenge — all agents create artwork (optional theme)"},{command:"/hatmaking",description:"All agents design a hat to wear on their avatar"},{command:"/roastreview",description:"Get all agents to review and roast each other's work"},{command:"/poetry haiku",description:"Agents write a haiku about the codebase"},{command:"/poetry limerick",description:"Agents write a limerick about the codebase"},{command:"/poetry sonnet",description:"Agents write a sonnet about the codebase"},{command:"/summary",description:"Summarize recent messages — tag an agent (e.g. /summary @head)"},{command:"/continue",description:"Resume after loop guard pauses"},{command:"/clear",description:"Clear messages in current channel"}];function C(e){return y[e.toLowerCase()]||"#e0e0e0"}let k=/(^|\s)(@(?:head|dev|re1|re2|user))(?![\w-])/gi;function E({projectId:e}){let[i,r]=(0,_.useState)("loading"),[s,n]=(0,_.useState)(""),[o,l]=(0,_.useState)("");return((0,_.useEffect)(()=>{fetch("/api/config").then(e=>{if(!e.ok)throw Error("config fetch failed");return e.json()}).then(i=>{let r=e?i.projects?.find(i=>i.id===e):null;n(r?.agentchattr_url||i.agentchattr_url||"http://127.0.0.1:8300"),l(r?.agentchattr_token||i.agentchattr_token||"")}).catch(()=>n("http://127.0.0.1:8300"))},[e]),(0,_.useEffect)(()=>{if("loading"!==i)return;let e=setTimeout(()=>{r(e=>"loading"===e?"api":e)},3e3);return()=>clearTimeout(e)},[i]),s)?"loading"===i||"iframe"===i?(0,p.jsxs)("div",{className:"w-full h-full",children:[(0,p.jsx)("iframe",{ref:e=>{e&&(e.onload=()=>{try{let i=e.contentDocument||e.contentWindow?.document;i&&i.body&&i.body.innerHTML.length>0?r("iframe"):r("api")}catch{r("api")}},e.onerror=()=>r("api"))},src:o?`${s}?token=${encodeURIComponent(o)}`:s,className:"w-full h-full border-0",style:{display:"loading"===i?"none":"block"},sandbox:"allow-same-origin allow-scripts allow-forms allow-popups"}),"loading"===i&&(0,p.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,p.jsx)("span",{className:"text-xs text-text-muted",children:"Connecting to AgentChattr..."})})]}):(0,p.jsx)(N,{projectId:e}):null}function N({projectId:e}){let i="general",[r,s]=(0,_.useState)([]),[n,o]=(0,_.useState)(!1),[l,a]=(0,_.useState)(""),[h,c]=(0,_.useState)(!1),[d,u]=(0,_.useState)(""),[f,m]=(0,_.useState)(!1),[g,v]=(0,_.useState)(0),[x,y]=(0,_.useState)(null),[E,R]=(0,_.useState)(null),D=(0,_.useRef)(0),M=(0,_.useRef)(null),T=(0,_.useRef)(null),P=(0,_.useRef)(!1),j=(0,_.useRef)(!0),B=(0,_.useRef)(0);(0,_.useEffect)(()=>{D.current=0,s([]),o(!1)},[e]);let L=(0,_.useCallback)(()=>{fetch(`/api/chat?path=/api/messages&channel=${encodeURIComponent(i)}&cursor=${D.current}${e?`&project=${encodeURIComponent(e)}`:""}`).then(e=>{if(403===e.status)throw B.current<3?y(null):y("Chat authentication failed (403). Set agentchattr_token in Settings or ~/.quadwork/config.json."),Error("auth failed");if(!e.ok)throw Error(`Poll failed: ${e.status}`);return e.json()}).then(e=>{y(null);let i=Array.isArray(e)?e:e.messages||[];if(i.length>0){s(e=>{let r=new Set(e.map(e=>e.id)),s=i.filter(e=>!r.has(e.id));return s.length>0?[...e,...s]:e});let e=Math.max(...i.map(e=>e.id));e>D.current&&(D.current=e)}}).catch(()=>{}).finally(()=>{o(!0)})},[i,e]);(0,_.useEffect)(()=>{L();let e=setInterval(L,3e3);return()=>clearInterval(e)},[L]),(0,_.useEffect)(()=>{j.current&&M.current&&(M.current.scrollTop=M.current.scrollHeight)},[r]);let[A,I]=(0,_.useState)(!1),[O,z]=(0,_.useState)(null);(0,_.useEffect)(()=>{let e=T.current;e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,120)+"px")},[l]);let H=()=>{let r=l.trim();if(!r||A)return;let s=r.startsWith("/")||/@(head|dev|re1|re2)\b/i.test(r)?r:`@head ${r}`;I(!0),z(null),fetch(`/api/chat${e?`?project=${encodeURIComponent(e)}`:""}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:s,channel:i,sender:"user",...E?{reply_to:E.id}:{}})}).then(e=>{if(!e.ok)throw Error(`Send failed: ${e.status}`);a(""),R(null),setTimeout(L,300)}).catch(e=>{z(e.message),console.error(e.message)}).finally(()=>I(!1))},F=e=>{a(l.replace(/@\w*$/,`@${e} `)),c(!1),T.current?.focus()},W=e=>{a(e.includes(" ")?e:`${e} `),m(!1),T.current?.focus()},$=S.filter(e=>e.toLowerCase().startsWith(d)),U=w.filter(e=>e.command.toLowerCase().startsWith(l.toLowerCase()));return(0,p.jsxs)("div",{className:"flex flex-col h-full bg-bg",children:[x&&(0,p.jsx)("div",{className:"px-3 py-2 bg-red-900/30 border-b border-red-700/50 text-[11px] text-red-400",children:x}),(0,p.jsxs)("div",{ref:M,onScroll:()=>{if(!M.current)return;let{scrollTop:e,scrollHeight:i,clientHeight:r}=M.current;j.current=i-e-r<40},className:"flex-1 min-h-0 overflow-y-auto px-3 py-2 space-y-0.5",children:[!n&&0===r.length&&(0,p.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,p.jsx)("span",{className:"text-xs text-text-muted",children:"Loading messages..."})}),n&&0===r.length&&(0,p.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,p.jsx)(b,{onInsert:e=>{a(e),T.current?.focus()}})}),r.map(e=>{var i;let r;return(0,p.jsxs)("div",{className:"group flex gap-2 text-[12px] leading-5",children:[(0,p.jsx)("span",{className:"text-text-muted shrink-0 w-12 text-right tabular-nums",children:e.time?.slice(0,5)||""}),(0,p.jsx)("span",{className:"shrink-0 font-semibold w-10 text-right",style:{color:C(e.sender)},children:"re1"===(r=(i=e.sender).toLowerCase())?"RE1":"re2"===r?"RE2":i}),(0,p.jsx)("span",{className:"text-text break-words min-w-0 whitespace-pre-wrap flex-1",children:function(e){let i=[],r=0,s=0;for(let n of e.matchAll(k)){let o=n.index??0,l=n[1],a=n[2],h=o+l.length;h>r&&i.push(e.slice(r,h));let c=C(a.slice(1).toLowerCase());i.push((0,p.jsx)("span",{className:"inline-block px-1 py-0 rounded font-mono",style:{backgroundColor:`${c}22`,color:c},children:a},`m${s++}`)),r=h+a.length}return r<e.length&&i.push(e.slice(r)),i.length>0?i:[e]}(e.text)}),(0,p.jsx)("button",{type:"button",onClick:()=>{if(R({id:e.id,sender:e.sender}),new Set(["head","dev","re1","re2"]).has(e.sender.toLowerCase())){let i=`@${e.sender} `;a(e=>e.startsWith(i)?e:i)}T.current?.focus()},className:"shrink-0 self-start opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity text-[10px] text-text-muted hover:text-text px-1 py-0.5 border border-border/50 rounded",title:`Reply to message #${e.id}`,children:"reply"})]},e.id)})]}),(0,p.jsxs)("div",{className:"relative shrink-0 border-t border-border",children:[h&&$.length>0&&(0,p.jsx)("div",{className:"absolute bottom-full left-0 right-0 border border-border bg-bg-surface",children:$.map(e=>(0,p.jsxs)("button",{onClick:()=>F(e),className:"w-full text-left px-3 py-1 text-[12px] hover:bg-[#1a1a1a] transition-colors",style:{color:C(e)},children:["@",e]},e))}),f&&U.length>0&&(0,p.jsx)("div",{className:"absolute bottom-full left-0 right-0 max-h-60 overflow-y-auto border border-border bg-bg-surface z-10",children:U.map((e,i)=>{let r=i===Math.min(g,U.length-1);return(0,p.jsxs)("button",{onClick:()=>W(e.command),onMouseEnter:()=>v(i),className:`w-full text-left px-3 py-1 transition-colors flex items-baseline gap-2 ${r?"bg-[#1a1a1a]":"hover:bg-[#1a1a1a]"}`,children:[(0,p.jsx)("span",{className:"text-[12px] text-accent font-mono",children:e.command}),(0,p.jsx)("span",{className:"text-[10px] text-text-muted truncate",children:e.description})]},e.command)})}),O&&(0,p.jsx)("div",{className:"px-3 py-1 text-[11px] text-red-400 bg-red-900/20 border-b border-red-700/40",children:O}),E&&(0,p.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1 text-[11px] text-text-muted bg-bg-surface border-b border-border/50",children:[(0,p.jsxs)("span",{children:["Replying to ",(0,p.jsxs)("span",{style:{color:C(E.sender)},children:["@",E.sender]})," #",E.id]}),(0,p.jsx)("button",{type:"button",onClick:()=>R(null),className:"ml-auto hover:text-text",title:"Cancel reply (Esc)",children:"✕"})]}),(0,p.jsxs)("div",{className:"flex items-end gap-1 px-1",children:[(0,p.jsx)("textarea",{ref:T,rows:1,value:l,onChange:e=>(e=>{a(e);let i=e.match(/@(\w*)$/);if(i){c(!0),u(i[1].toLowerCase()),m(!1);return}if(c(!1),e.startsWith("/")){let i=e.slice(1).includes(" "),r=e.startsWith("/poetry");m(!i||r),v(0)}else m(!1)})(e.target.value),onCompositionStart:()=>{P.current=!0},onCompositionEnd:()=>{P.current=!1},onKeyDown:e=>{if("Tab"===e.key&&h&&$.length>0){e.preventDefault(),F($[0]);return}if(f&&U.length>0){if("ArrowDown"===e.key){e.preventDefault(),v(e=>(e+1)%U.length);return}if("ArrowUp"===e.key){e.preventDefault(),v(e=>(e-1+U.length)%U.length);return}if("Tab"===e.key||"Enter"===e.key&&!e.shiftKey){e.preventDefault();let i=Math.min(g,U.length-1);W(U[i].command);return}}"Enter"!==e.key||e.shiftKey||P.current||e.nativeEvent.isComposing||(e.preventDefault(),H()),"Escape"===e.key&&(c(!1),m(!1),E&&R(null))},placeholder:`Message #${i}...`,disabled:A,className:"flex-1 bg-transparent px-2 py-2 text-[12px] font-mono text-text placeholder:text-text-muted outline-none focus:ring-1 focus:ring-accent disabled:opacity-50 resize-none overflow-y-auto leading-snug",style:{maxHeight:120}}),(0,p.jsx)("button",{onClick:H,disabled:A||!l.trim(),className:"shrink-0 px-2 py-1 text-[11px] font-mono text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:"Send (Enter)",children:A?"…":"Send"})]})]})]})}function R(){}function D(){}let M=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,T=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,P={};function j(e,i){return((i||P).jsx?T:M).test(e)}let B=/[ \t\n\f\r]/g;function L(e){return""===e.replace(B,"")}class A{constructor(e,i){this.attribute=i,this.property=e}}A.prototype.attribute="",A.prototype.booleanish=!1,A.prototype.boolean=!1,A.prototype.commaOrSpaceSeparated=!1,A.prototype.commaSeparated=!1,A.prototype.defined=!1,A.prototype.mustUseProperty=!1,A.prototype.number=!1,A.prototype.overloadedBoolean=!1,A.prototype.property="",A.prototype.spaceSeparated=!1,A.prototype.space=void 0;let I=0,O=K(),z=K(),H=K(),F=K(),W=K(),$=K(),U=K();function K(){return 2**++I}e.s(["boolean",0,O,"booleanish",0,z,"commaOrSpaceSeparated",0,U,"commaSeparated",0,$,"number",0,F,"overloadedBoolean",0,H,"spaceSeparated",0,W],744);var q=e.i(744);let V=Object.keys(q);class Y extends A{constructor(e,i,r,s){let n=-1;if(super(e,i),function(e,i,r){r&&(e[i]=r)}(this,"space",s),"number"==typeof r)for(;++n<V.length;){const e=V[n];!function(e,i,r){r&&(e[i]=r)}(this,V[n],(r&q[e])===q[e])}}}function G(e){return e.toLowerCase()}Y.prototype.defined=!0;let X=/[A-Z]/g,J=/-[a-z]/g,Q=/^data[-\w.:]+$/i;function Z(e){return"-"+e.toLowerCase()}function ee(e){return e.charAt(1).toUpperCase()}let et={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};class ei{constructor(e,i,r){this.normal=i,this.property=e,r&&(this.space=r)}}function er(e,i){let r={},s={};for(let i of e)Object.assign(r,i.property),Object.assign(s,i.normal);return new ei(r,s,i)}function es(e){let i={},r={};for(let[s,n]of Object.entries(e.properties)){let o=new Y(s,e.transform(e.attributes||{},s),n,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(o.mustUseProperty=!0),i[s]=o,r[G(s)]=s,r[G(o.attribute)]=s}return new ei(i,r,e.space)}ei.prototype.normal={},ei.prototype.property={},ei.prototype.space=void 0;let en=es({properties:{ariaActiveDescendant:null,ariaAtomic:z,ariaAutoComplete:null,ariaBusy:z,ariaChecked:z,ariaColCount:F,ariaColIndex:F,ariaColSpan:F,ariaControls:W,ariaCurrent:null,ariaDescribedBy:W,ariaDetails:null,ariaDisabled:z,ariaDropEffect:W,ariaErrorMessage:null,ariaExpanded:z,ariaFlowTo:W,ariaGrabbed:z,ariaHasPopup:null,ariaHidden:z,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:W,ariaLevel:F,ariaLive:null,ariaModal:z,ariaMultiLine:z,ariaMultiSelectable:z,ariaOrientation:null,ariaOwns:W,ariaPlaceholder:null,ariaPosInSet:F,ariaPressed:z,ariaReadOnly:z,ariaRelevant:null,ariaRequired:z,ariaRoleDescription:W,ariaRowCount:F,ariaRowIndex:F,ariaRowSpan:F,ariaSelected:z,ariaSetSize:F,ariaSort:null,ariaValueMax:F,ariaValueMin:F,ariaValueNow:F,ariaValueText:null,role:null},transform:(e,i)=>"role"===i?i:"aria-"+i.slice(4).toLowerCase()});function eo(e,i){return i in e?e[i]:i}function el(e,i){return eo(e,i.toLowerCase())}let ea=es({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:$,acceptCharset:W,accessKey:W,action:null,allow:null,allowFullScreen:O,allowPaymentRequest:O,allowUserMedia:O,alt:null,as:null,async:O,autoCapitalize:null,autoComplete:W,autoFocus:O,autoPlay:O,blocking:W,capture:null,charSet:null,checked:O,cite:null,className:W,cols:F,colSpan:null,content:null,contentEditable:z,controls:O,controlsList:W,coords:F|$,crossOrigin:null,data:null,dateTime:null,decoding:null,default:O,defer:O,dir:null,dirName:null,disabled:O,download:H,draggable:z,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:O,formTarget:null,headers:W,height:F,hidden:H,high:F,href:null,hrefLang:null,htmlFor:W,httpEquiv:W,id:null,imageSizes:null,imageSrcSet:null,inert:O,inputMode:null,integrity:null,is:null,isMap:O,itemId:null,itemProp:W,itemRef:W,itemScope:O,itemType:W,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:O,low:F,manifest:null,max:null,maxLength:F,media:null,method:null,min:null,minLength:F,multiple:O,muted:O,name:null,nonce:null,noModule:O,noValidate:O,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:O,optimum:F,pattern:null,ping:W,placeholder:null,playsInline:O,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:O,referrerPolicy:null,rel:W,required:O,reversed:O,rows:F,rowSpan:F,sandbox:W,scope:null,scoped:O,seamless:O,selected:O,shadowRootClonable:O,shadowRootDelegatesFocus:O,shadowRootMode:null,shape:null,size:F,sizes:null,slot:null,span:F,spellCheck:z,src:null,srcDoc:null,srcLang:null,srcSet:null,start:F,step:null,style:null,tabIndex:F,target:null,title:null,translate:null,type:null,typeMustMatch:O,useMap:null,value:z,width:F,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:W,axis:null,background:null,bgColor:null,border:F,borderColor:null,bottomMargin:F,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:O,declare:O,event:null,face:null,frame:null,frameBorder:null,hSpace:F,leftMargin:F,link:null,longDesc:null,lowSrc:null,marginHeight:F,marginWidth:F,noResize:O,noHref:O,noShade:O,noWrap:O,object:null,profile:null,prompt:null,rev:null,rightMargin:F,rules:null,scheme:null,scrolling:z,standby:null,summary:null,text:null,topMargin:F,valueType:null,version:null,vAlign:null,vLink:null,vSpace:F,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:O,disableRemotePlayback:O,prefix:null,property:null,results:F,security:null,unselectable:null},space:"html",transform:el}),eh=es({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:U,accentHeight:F,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:F,amplitude:F,arabicForm:null,ascent:F,attributeName:null,attributeType:null,azimuth:F,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:F,by:null,calcMode:null,capHeight:F,className:W,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:F,diffuseConstant:F,direction:null,display:null,dur:null,divisor:F,dominantBaseline:null,download:O,dx:null,dy:null,edgeMode:null,editable:null,elevation:F,enableBackground:null,end:null,event:null,exponent:F,externalResourcesRequired:null,fill:null,fillOpacity:F,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:$,g2:$,glyphName:$,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:F,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:F,horizOriginX:F,horizOriginY:F,id:null,ideographic:F,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:F,k:F,k1:F,k2:F,k3:F,k4:F,kernelMatrix:U,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:F,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:F,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:F,overlineThickness:F,paintOrder:null,panose1:null,path:null,pathLength:F,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:W,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:F,pointsAtY:F,pointsAtZ:F,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:U,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:U,rev:U,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:U,requiredFeatures:U,requiredFonts:U,requiredFormats:U,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:F,specularExponent:F,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:F,strikethroughThickness:F,string:null,stroke:null,strokeDashArray:U,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:F,strokeOpacity:F,strokeWidth:null,style:null,surfaceScale:F,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:U,tabIndex:F,tableValues:null,target:null,targetX:F,targetY:F,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:U,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:F,underlineThickness:F,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:F,values:null,vAlphabetic:F,vMathematical:F,vectorEffect:null,vHanging:F,vIdeographic:F,version:null,vertAdvY:F,vertOriginX:F,vertOriginY:F,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:F,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:eo}),ec=es({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,i)=>"xlink:"+i.slice(5).toLowerCase()}),ed=es({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:el}),eu=es({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,i)=>"xml:"+i.slice(3).toLowerCase()}),ef=er([en,ea,ec,ed,eu],"html"),ep=er([en,eh,ec,ed,eu],"svg");var e_=e.i(15511);let em=ev("end"),eg=ev("start");function ev(e){return function(i){let r=i&&i.position&&i.position[e]||{};if("number"==typeof r.line&&r.line>0&&"number"==typeof r.column&&r.column>0)return{line:r.line,column:r.column,offset:"number"==typeof r.offset&&r.offset>-1?r.offset:void 0}}}function ex(e){return e&&"object"==typeof e?"position"in e||"type"in e?ey(e.position):"start"in e||"end"in e?ey(e):"line"in e||"column"in e?eb(e):"":""}function eb(e){return eS(e&&e.line)+":"+eS(e&&e.column)}function ey(e){return eb(e&&e.start)+"-"+eb(e&&e.end)}function eS(e){return e&&"number"==typeof e?e:1}class ew extends Error{constructor(e,i,r){super(),"string"==typeof i&&(r=i,i=void 0);let s="",n={},o=!1;if(i&&(n="line"in i&&"column"in i||"start"in i&&"end"in i?{place:i}:"type"in i?{ancestors:[i],place:i.position}:{...i}),"string"==typeof e?s=e:!n.cause&&e&&(o=!0,s=e.message,n.cause=e),!n.ruleId&&!n.source&&"string"==typeof r){const e=r.indexOf(":");-1===e?n.ruleId=r:(n.source=r.slice(0,e),n.ruleId=r.slice(e+1))}if(!n.place&&n.ancestors&&n.ancestors){const e=n.ancestors[n.ancestors.length-1];e&&(n.place=e.position)}const l=n.place&&"start"in n.place?n.place.start:n.place;this.ancestors=n.ancestors||void 0,this.cause=n.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=l?l.line:void 0,this.name=ex(n.place)||"1:1",this.place=n.place||void 0,this.reason=this.message,this.ruleId=n.ruleId||void 0,this.source=n.source||void 0,this.stack=o&&n.cause&&"string"==typeof n.cause.stack?n.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ew.prototype.file="",ew.prototype.name="",ew.prototype.reason="",ew.prototype.message="",ew.prototype.stack="",ew.prototype.column=void 0,ew.prototype.line=void 0,ew.prototype.ancestors=void 0,ew.prototype.cause=void 0,ew.prototype.fatal=void 0,ew.prototype.place=void 0,ew.prototype.ruleId=void 0,ew.prototype.source=void 0;let eC={}.hasOwnProperty,ek=new Map,eE=/[A-Z]/g,eN=new Set(["table","tbody","thead","tfoot","tr"]),eR=new Set(["td","th"]),eD="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function eM(e,i,r){var s,n,o,l,a,h,c,d,u;let f,p,_,m,g,v,x,b,y,S,w;return"element"===i.type?(s=e,n=i,o=r,p=f=s.schema,"svg"===n.tagName.toLowerCase()&&"html"===f.space&&(s.schema=ep),s.ancestors.push(n),_=eB(s,n.tagName,!1),m=function(e,i){let r,s,n={};for(s in i.properties)if("children"!==s&&eC.call(i.properties,s)){let o=function(e,i,r){let s=function(e,i){let r=G(i),s=i,n=A;if(r in e.normal)return e.property[e.normal[r]];if(r.length>4&&"data"===r.slice(0,4)&&Q.test(i)){if("-"===i.charAt(4)){let e=i.slice(5).replace(J,ee);s="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=i.slice(4);if(!J.test(e)){let r=e.replace(X,Z);"-"!==r.charAt(0)&&(r="-"+r),i="data"+r}}n=Y}return new n(s,i)}(e.schema,i);if(!(null==r||"number"==typeof r&&Number.isNaN(r))){var n;let i;if(Array.isArray(r)&&(r=s.commaSeparated?(i={},(""===(n=r)[n.length-1]?[...n,""]:n).join((i.padRight?" ":"")+","+(!1===i.padLeft?"":" ")).trim()):r.join(" ").trim()),"style"===s.property){let i="object"==typeof r?r:function(e,i){try{return(0,e_.default)(i,{reactCompat:!0})}catch(r){if(e.ignoreInvalidStyle)return{};let i=new ew("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=eD+"#cannot-parse-style-attribute",i}}(e,String(r));return"css"===e.stylePropertyNameCase&&(i=function(e){let i,r={};for(i in e)eC.call(e,i)&&(r[function(e){let i=e.replace(eE,eA);return"ms-"===i.slice(0,3)&&(i="-"+i),i}(i)]=e[i]);return r}(i)),["style",i]}return["react"===e.elementAttributeNameCase&&s.space?et[s.property]||s.property:s.attribute,r]}}(e,s,i.properties[s]);if(o){let[s,l]=o;e.tableCellAlignToStyle&&"align"===s&&"string"==typeof l&&eR.has(i.tagName)?r=l:n[s]=l}}return r&&((n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=r),n}(s,n),g=ej(s,n),eN.has(n.tagName)&&(g=g.filter(function(e){return"string"!=typeof e||!("object"==typeof e?"text"===e.type&&L(e.value):L(e))})),eT(s,m,_,n),eP(m,g),s.ancestors.pop(),s.schema=f,s.create(n,_,m,o)):"mdxFlowExpression"===i.type||"mdxTextExpression"===i.type?function(e,i){if(i.data&&i.data.estree&&e.evaluater){let r=i.data.estree.body[0];return R("ExpressionStatement"===r.type),e.evaluater.evaluateExpression(r.expression)}eL(e,i.position)}(e,i):"mdxJsxFlowElement"===i.type||"mdxJsxTextElement"===i.type?(l=e,a=i,h=r,x=v=l.schema,"svg"===a.name&&"html"===v.space&&(l.schema=ep),l.ancestors.push(a),b=null===a.name?l.Fragment:eB(l,a.name,!0),y=function(e,i){let r={};for(let s of i.attributes)if("mdxJsxExpressionAttribute"===s.type)if(s.data&&s.data.estree&&e.evaluater){let i=s.data.estree.body[0];R("ExpressionStatement"===i.type);let n=i.expression;R("ObjectExpression"===n.type);let o=n.properties[0];R("SpreadElement"===o.type),Object.assign(r,e.evaluater.evaluateExpression(o.argument))}else eL(e,i.position);else{let n,o=s.name;if(s.value&&"object"==typeof s.value)if(s.value.data&&s.value.data.estree&&e.evaluater){let i=s.value.data.estree.body[0];R("ExpressionStatement"===i.type),n=e.evaluater.evaluateExpression(i.expression)}else eL(e,i.position);else n=null===s.value||s.value;r[o]=n}return r}(l,a),S=ej(l,a),eT(l,y,b,a),eP(y,S),l.ancestors.pop(),l.schema=v,l.create(a,b,y,h)):"mdxjsEsm"===i.type?function(e,i){if(i.data&&i.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(i.data.estree);eL(e,i.position)}(e,i):"root"===i.type?(c=e,d=i,u=r,eP(w={},ej(c,d)),c.create(d,c.Fragment,w,u)):"text"===i.type?i.value:void 0}function eT(e,i,r,s){"string"!=typeof r&&r!==e.Fragment&&e.passNode&&(i.node=s)}function eP(e,i){if(i.length>0){let r=i.length>1?i:i[0];r&&(e.children=r)}}function ej(e,i){let r=[],s=-1,n=e.passKeys?new Map:ek;for(;++s<i.children.length;){let o,l=i.children[s];if(e.passKeys){let e="element"===l.type?l.tagName:"mdxJsxFlowElement"===l.type||"mdxJsxTextElement"===l.type?l.name:void 0;if(e){let i=n.get(e)||0;o=e+"-"+i,n.set(e,i+1)}}let a=eM(e,l,o);void 0!==a&&r.push(a)}return r}function eB(e,i,r){let s;if(r)if(i.includes(".")){let e,r=i.split("."),n=-1;for(;++n<r.length;){let i=j(r[n])?{type:"Identifier",name:r[n]}:{type:"Literal",value:r[n]};e=e?{type:"MemberExpression",object:e,property:i,computed:!!(n&&"Literal"===i.type),optional:!1}:i}R(e,"always a result"),s=e}else s=j(i)&&!/^[a-z]/.test(i)?{type:"Identifier",name:i}:{type:"Literal",value:i};else s={type:"Literal",value:i};if("Literal"===s.type){let i=s.value;return eC.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(s);eL(e)}function eL(e,i){let r=new ew("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:i,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=eD+"#cannot-handle-mdx-estrees-without-createevaluater",r}function eA(e){return"-"+e.toLowerCase()}let eI={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},eO={};function ez(e,i,r){var s;if((s=e)&&"object"==typeof s){if("value"in e)return"html"!==e.type||r?e.value:"";if(i&&"alt"in e&&e.alt)return e.alt;if("children"in e)return eH(e.children,i,r)}return Array.isArray(e)?eH(e,i,r):""}function eH(e,i,r){let s=[],n=-1;for(;++n<e.length;)s[n]=ez(e[n],i,r);return s.join("")}function eF(e,i,r,s){let n,o=e.length,l=0;if(i=i<0?-i>o?0:o+i:i>o?o:i,r=r>0?r:0,s.length<1e4)(n=Array.from(s)).unshift(i,r),e.splice(...n);else for(r&&e.splice(i,r);l<s.length;)(n=s.slice(l,l+1e4)).unshift(i,0),e.splice(...n),l+=1e4,i+=1e4}function eW(e,i){return e.length>0?(eF(e,e.length,0,i),e):i}let e$={}.hasOwnProperty,eU=e2(/[A-Za-z]/),eK=e2(/[\dA-Za-z]/),eq=e2(/[#-'*+\--9=?A-Z^-~]/);function eV(e){return null!==e&&(e<32||127===e)}let eY=e2(/\d/),eG=e2(/[\dA-Fa-f]/),eX=e2(/[!-/:-@[-`{-~]/);function eJ(e){return null!==e&&e<-2}function eQ(e){return null!==e&&(e<0||32===e)}function eZ(e){return -2===e||-1===e||32===e}let e0=e2(/\p{P}|\p{S}/u),e1=e2(/\s/);function e2(e){return function(i){return null!==i&&i>-1&&e.test(String.fromCharCode(i))}}function e5(e,i,r,s){let n=s?s-1:1/0,o=0;return function(s){return eZ(s)?(e.enter(r),function s(l){return eZ(l)&&o++<n?(e.consume(l),s):(e.exit(r),i(l))}(s)):i(s)}}let e3={tokenize:function(e){let i,r=e.attempt(this.parser.constructs.contentInitial,function(i){return null===i?void e.consume(i):(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e5(e,r,"linePrefix"))},function(r){return e.enter("paragraph"),function r(s){let n=e.enter("chunkText",{contentType:"text",previous:i});return i&&(i.next=n),i=n,function i(s){if(null===s){e.exit("chunkText"),e.exit("paragraph"),e.consume(s);return}return eJ(s)?(e.consume(s),e.exit("chunkText"),r):(e.consume(s),i)}(s)}(r)});return r}},e4={tokenize:function(e){let i,r,s,n=this,o=[],l=0;return a;function a(i){if(l<o.length){let r=o[l];return n.containerState=r[1],e.attempt(r[0].continuation,h,c)(i)}return c(i)}function h(e){if(l++,n.containerState._closeFlow){let r;n.containerState._closeFlow=void 0,i&&v();let s=n.events.length,o=s;for(;o--;)if("exit"===n.events[o][0]&&"chunkFlow"===n.events[o][1].type){r=n.events[o][1].end;break}g(l);let a=s;for(;a<n.events.length;)n.events[a][1].end={...r},a++;return eF(n.events,o+1,0,n.events.slice(s)),n.events.length=a,c(e)}return a(e)}function c(r){if(l===o.length){if(!i)return f(r);if(i.currentConstruct&&i.currentConstruct.concrete)return _(r);n.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(e6,d,u)(r)}function d(e){return i&&v(),g(l),f(e)}function u(e){return n.parser.lazy[n.now().line]=l!==o.length,s=n.now().offset,_(e)}function f(i){return n.containerState={},e.attempt(e6,p,_)(i)}function p(e){return l++,o.push([n.currentConstruct,n.containerState]),f(e)}function _(s){if(null===s){i&&v(),g(0),e.consume(s);return}return i=i||n.parser.flow(n.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:r}),function i(r){if(null===r){m(e.exit("chunkFlow"),!0),g(0),e.consume(r);return}return eJ(r)?(e.consume(r),m(e.exit("chunkFlow")),l=0,n.interrupt=void 0,a):(e.consume(r),i)}(s)}function m(e,o){let a=n.sliceStream(e);if(o&&a.push(null),e.previous=r,r&&(r.next=e),r=e,i.defineSkip(e.start),i.write(a),n.parser.lazy[e.start.line]){let e,r,o=i.events.length;for(;o--;)if(i.events[o][1].start.offset<s&&(!i.events[o][1].end||i.events[o][1].end.offset>s))return;let a=n.events.length,h=a;for(;h--;)if("exit"===n.events[h][0]&&"chunkFlow"===n.events[h][1].type){if(e){r=n.events[h][1].end;break}e=!0}for(g(l),o=a;o<n.events.length;)n.events[o][1].end={...r},o++;eF(n.events,h+1,0,n.events.slice(a)),n.events.length=o}}function g(i){let r=o.length;for(;r-- >i;){let i=o[r];n.containerState=i[1],i[0].exit.call(n,e)}o.length=i}function v(){i.write([null]),r=void 0,i=void 0,n.containerState._closeFlow=void 0}}},e6={tokenize:function(e,i,r){return e5(e,e.attempt(this.parser.constructs.document,i,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},e9={partial:!0,tokenize:function(e,i,r){return function(i){return eZ(i)?e5(e,s,"linePrefix")(i):s(i)};function s(e){return null===e||eJ(e)?i(e):r(e)}}};class e8{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,i){let r=null==i?1/0:i;return r<this.left.length?this.left.slice(e,r):e>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,i,r){this.setCursor(Math.trunc(e));let s=this.right.splice(this.right.length-(i||0),1/0);return r&&e7(this.left,r),s.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),e7(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),e7(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let i=this.left.splice(e,1/0);e7(this.right,i.reverse())}else{let i=this.right.splice(this.left.length+this.right.length-e,1/0);e7(this.left,i.reverse())}}}function e7(e,i){let r=0;if(i.length<1e4)e.push(...i);else for(;r<i.length;)e.push(...i.slice(r,r+1e4)),r+=1e4}function te(e){let i,r,s,n,o,l,a,h={},c=-1,d=new e8(e);for(;++c<d.length;){for(;c in h;)c=h[c];if(i=d.get(c),c&&"chunkFlow"===i[1].type&&"listItemPrefix"===d.get(c-1)[1].type&&((s=0)<(l=i[1]._tokenizer.events).length&&"lineEndingBlank"===l[s][1].type&&(s+=2),s<l.length&&"content"===l[s][1].type))for(;++s<l.length&&"content"!==l[s][1].type;)"chunkText"===l[s][1].type&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if("enter"===i[0])i[1].contentType&&(Object.assign(h,function(e,i){let r,s,n=e.get(i)[1],o=e.get(i)[2],l=i-1,a=[],h=n._tokenizer;!h&&(h=o.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(h._contentTypeTextTrailing=!0));let c=h.events,d=[],u={},f=-1,p=n,_=0,m=0,g=[0];for(;p;){for(;e.get(++l)[1]!==p;);a.push(l),!p._tokenizer&&(r=o.sliceStream(p),p.next||r.push(null),s&&h.defineSkip(p.start),p._isInFirstContentOfListItem&&(h._gfmTasklistFirstContentOfListItem=!0),h.write(r),p._isInFirstContentOfListItem&&(h._gfmTasklistFirstContentOfListItem=void 0)),s=p,p=p.next}for(p=n;++f<c.length;)"exit"===c[f][0]&&"enter"===c[f-1][0]&&c[f][1].type===c[f-1][1].type&&c[f][1].start.line!==c[f][1].end.line&&(m=f+1,g.push(m),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(h.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let i=c.slice(g[f],g[f+1]),r=a.pop();d.push([r,r+i.length-1]),e.splice(r,2,i)}for(d.reverse(),f=-1;++f<d.length;)u[_+d[f][0]]=_+d[f][1],_+=d[f][1]-d[f][0]-1;return u}(d,c)),c=h[c],a=!0);else if(i[1]._container){for(s=c,r=void 0;s--;)if("lineEnding"===(n=d.get(s))[1].type||"lineEndingBlank"===n[1].type)"enter"===n[0]&&(r&&(d.get(r)[1].type="lineEndingBlank"),n[1].type="lineEnding",r=s);else if("linePrefix"===n[1].type||"listItemIndent"===n[1].type);else break;r&&(i[1].end={...d.get(r)[1].start},(o=d.slice(r,c)).unshift(i),d.splice(r,c-r+1,o))}}return eF(e,0,1/0,d.slice(0)),!a}let tt={resolve:function(e){return te(e),e},tokenize:function(e,i){let r;return function(i){return e.enter("content"),r=e.enter("chunkContent",{contentType:"content"}),s(i)};function s(i){return null===i?n(i):eJ(i)?e.check(ti,o,n)(i):(e.consume(i),s)}function n(r){return e.exit("chunkContent"),e.exit("content"),i(r)}function o(i){return e.consume(i),e.exit("chunkContent"),r.next=e.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,s}}},ti={partial:!0,tokenize:function(e,i,r){let s=this;return function(i){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e5(e,n,"linePrefix")};function n(n){if(null===n||eJ(n))return r(n);let o=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?i(n):e.interrupt(s.parser.constructs.flow,r,i)(n)}}},tr={tokenize:function(e){let i=this,r=e.attempt(e9,function(s){return null===s?void e.consume(s):(e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),i.currentConstruct=void 0,r)},e.attempt(this.parser.constructs.flowInitial,s,e5(e,e.attempt(this.parser.constructs.flow,s,e.attempt(tt,s)),"linePrefix")));return r;function s(s){return null===s?void e.consume(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i.currentConstruct=void 0,r)}}},ts={resolveAll:ta()},tn=tl("string"),to=tl("text");function tl(e){return{resolveAll:ta("text"===e?th:void 0),tokenize:function(i){let r=this,s=this.parser.constructs[e],n=i.attempt(s,o,l);return o;function o(e){return h(e)?n(e):l(e)}function l(e){return null===e?void i.consume(e):(i.enter("data"),i.consume(e),a)}function a(e){return h(e)?(i.exit("data"),n(e)):(i.consume(e),a)}function h(e){if(null===e)return!0;let i=s[e],n=-1;if(i)for(;++n<i.length;){let e=i[n];if(!e.previous||e.previous.call(r,r.previous))return!0}return!1}}}}function ta(e){return function(i,r){let s,n=-1;for(;++n<=i.length;)void 0===s?i[n]&&"data"===i[n][1].type&&(s=n,n++):i[n]&&"data"===i[n][1].type||(n!==s+2&&(i[s][1].end=i[n-1][1].end,i.splice(s+2,n-s-2),n=s+2),s=void 0);return e?e(i,r):i}}function th(e,i){let r=0;for(;++r<=e.length;)if((r===e.length||"lineEnding"===e[r][1].type)&&"data"===e[r-1][1].type){let s,n=e[r-1][1],o=i.sliceStream(n),l=o.length,a=-1,h=0;for(;l--;){let e=o[l];if("string"==typeof e){for(a=e.length;32===e.charCodeAt(a-1);)h++,a--;if(a)break;a=-1}else if(-2===e)s=!0,h++;else if(-1===e);else{l++;break}}if(i._contentTypeTextTrailing&&r===e.length&&(h=0),h){let o={type:r===e.length||s||h<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?a:n.start._bufferIndex+a,_index:n.start._index+l,line:n.end.line,column:n.end.column-h,offset:n.end.offset-h},end:{...n.end}};n.end={...o.start},n.start.offset===n.end.offset?Object.assign(n,o):(e.splice(r,0,["enter",o,i],["exit",o,i]),r+=2)}r++}return e}function tc(e){return null===e||eQ(e)||e1(e)?1:e0(e)?2:void 0}function td(e,i,r){let s=[],n=-1;for(;++n<e.length;){let o=e[n].resolveAll;o&&!s.includes(o)&&(i=o(i,r),s.push(o))}return i}let tu={name:"attention",resolveAll:function(e,i){let r,s,n,o,l,a,h,c,d=-1;for(;++d<e.length;)if("enter"===e[d][0]&&"attentionSequence"===e[d][1].type&&e[d][1]._close){for(r=d;r--;)if("exit"===e[r][0]&&"attentionSequence"===e[r][1].type&&e[r][1]._open&&i.sliceSerialize(e[r][1]).charCodeAt(0)===i.sliceSerialize(e[d][1]).charCodeAt(0)){if((e[r][1]._close||e[d][1]._open)&&(e[d][1].end.offset-e[d][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[d][1].end.offset-e[d][1].start.offset)%3))continue;a=e[r][1].end.offset-e[r][1].start.offset>1&&e[d][1].end.offset-e[d][1].start.offset>1?2:1;let u={...e[r][1].end},f={...e[d][1].start};tf(u,-a),tf(f,a),o={type:a>1?"strongSequence":"emphasisSequence",start:u,end:{...e[r][1].end}},l={type:a>1?"strongSequence":"emphasisSequence",start:{...e[d][1].start},end:f},n={type:a>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[d][1].start}},s={type:a>1?"strong":"emphasis",start:{...o.start},end:{...l.end}},e[r][1].end={...o.start},e[d][1].start={...l.end},h=[],e[r][1].end.offset-e[r][1].start.offset&&(h=eW(h,[["enter",e[r][1],i],["exit",e[r][1],i]])),h=eW(h,[["enter",s,i],["enter",o,i],["exit",o,i],["enter",n,i]]),h=eW(h,td(i.parser.constructs.insideSpan.null,e.slice(r+1,d),i)),h=eW(h,[["exit",n,i],["enter",l,i],["exit",l,i],["exit",s,i]]),e[d][1].end.offset-e[d][1].start.offset?(c=2,h=eW(h,[["enter",e[d][1],i],["exit",e[d][1],i]])):c=0,eF(e,r-1,d-r+3,h),d=r+h.length-c-2;break}}for(d=-1;++d<e.length;)"attentionSequence"===e[d][1].type&&(e[d][1].type="data");return e},tokenize:function(e,i){let r,s=this.parser.constructs.attentionMarkers.null,n=this.previous,o=tc(n);return function(l){return r=l,e.enter("attentionSequence"),function l(a){if(a===r)return e.consume(a),l;let h=e.exit("attentionSequence"),c=tc(a),d=!c||2===c&&o||s.includes(a),u=!o||2===o&&c||s.includes(n);return h._open=!!(42===r?d:d&&(o||!u)),h._close=!!(42===r?u:u&&(c||!d)),i(a)}(l)}}};function tf(e,i){e.column+=i,e.offset+=i,e._bufferIndex+=i}let tp={continuation:{tokenize:function(e,i,r){let s=this;return function(i){return eZ(i)?e5(e,n,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):n(i)};function n(s){return e.attempt(tp,i,r)(s)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,i,r){let s=this;return function(i){if(62===i){let r=s.containerState;return r.open||(e.enter("blockQuote",{_container:!0}),r.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(i),e.exit("blockQuoteMarker"),n}return r(i)};function n(r){return eZ(r)?(e.enter("blockQuotePrefixWhitespace"),e.consume(r),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),i):(e.exit("blockQuotePrefix"),i(r))}}},t_={name:"characterEscape",tokenize:function(e,i,r){return function(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),s};function s(s){return eX(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),i):r(s)}}},tm=document.createElement("i");function tg(e){let i="&"+e+";";tm.innerHTML=i;let r=tm.textContent;return(59!==r.charCodeAt(r.length-1)||"semi"===e)&&r!==i&&r}let tv={name:"characterReference",tokenize:function(e,i,r){let s,n,o=this,l=0;return function(i){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(i),e.exit("characterReferenceMarker"),a};function a(i){return 35===i?(e.enter("characterReferenceMarkerNumeric"),e.consume(i),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),s=31,n=eK,c(i))}function h(i){return 88===i||120===i?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(i),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,n=eG,c):(e.enter("characterReferenceValue"),s=7,n=eY,c(i))}function c(a){if(59===a&&l){let s=e.exit("characterReferenceValue");return n!==eK||tg(o.sliceSerialize(s))?(e.enter("characterReferenceMarker"),e.consume(a),e.exit("characterReferenceMarker"),e.exit("characterReference"),i):r(a)}return n(a)&&l++<s?(e.consume(a),c):r(a)}}},tx={partial:!0,tokenize:function(e,i,r){let s=this;return function(i){return null===i?r(i):(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n)};function n(e){return s.parser.lazy[s.now().line]?r(e):i(e)}}},tb={concrete:!0,name:"codeFenced",tokenize:function(e,i,r){let s,n=this,o={partial:!0,tokenize:function(e,i,r){let o=0;return function(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),l};function l(i){return e.enter("codeFencedFence"),eZ(i)?e5(e,h,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):h(i)}function h(i){return i===s?(e.enter("codeFencedFenceSequence"),function i(n){return n===s?(o++,e.consume(n),i):o>=a?(e.exit("codeFencedFenceSequence"),eZ(n)?e5(e,c,"whitespace")(n):c(n)):r(n)}(i)):r(i)}function c(s){return null===s||eJ(s)?(e.exit("codeFencedFence"),i(s)):r(s)}}},l=0,a=0;return function(i){var o;let c;return o=i,l=(c=n.events[n.events.length-1])&&"linePrefix"===c[1].type?c[2].sliceSerialize(c[1],!0).length:0,s=o,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function i(n){return n===s?(a++,e.consume(n),i):a<3?r(n):(e.exit("codeFencedFenceSequence"),eZ(n)?e5(e,h,"whitespace")(n):h(n))}(o)};function h(o){return null===o||eJ(o)?(e.exit("codeFencedFence"),n.interrupt?i(o):e.check(tx,d,_)(o)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function i(n){return null===n||eJ(n)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(n)):eZ(n)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),e5(e,c,"whitespace")(n)):96===n&&n===s?r(n):(e.consume(n),i)}(o))}function c(i){return null===i||eJ(i)?h(i):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function i(n){return null===n||eJ(n)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(n)):96===n&&n===s?r(n):(e.consume(n),i)}(i))}function d(i){return e.attempt(o,_,u)(i)}function u(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),f}function f(i){return l>0&&eZ(i)?e5(e,p,"linePrefix",l+1)(i):p(i)}function p(i){return null===i||eJ(i)?e.check(tx,d,_)(i):(e.enter("codeFlowValue"),function i(r){return null===r||eJ(r)?(e.exit("codeFlowValue"),p(r)):(e.consume(r),i)}(i))}function _(r){return e.exit("codeFenced"),i(r)}}},ty={name:"codeIndented",tokenize:function(e,i,r){let s=this;return function(i){return e.enter("codeIndented"),e5(e,n,"linePrefix",5)(i)};function n(i){let n=s.events[s.events.length-1];return n&&"linePrefix"===n[1].type&&n[2].sliceSerialize(n[1],!0).length>=4?function i(r){return null===r?o(r):eJ(r)?e.attempt(tS,i,o)(r):(e.enter("codeFlowValue"),function r(s){return null===s||eJ(s)?(e.exit("codeFlowValue"),i(s)):(e.consume(s),r)}(r))}(i):r(i)}function o(r){return e.exit("codeIndented"),i(r)}}},tS={partial:!0,tokenize:function(e,i,r){let s=this;return n;function n(i){return s.parser.lazy[s.now().line]?r(i):eJ(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n):e5(e,o,"linePrefix",5)(i)}function o(e){let o=s.events[s.events.length-1];return o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?i(e):eJ(e)?n(e):r(e)}}};function tw(e,i,r,s,n,o,l,a,h){let c=h||1/0,d=0;return function(i){return 60===i?(e.enter(s),e.enter(n),e.enter(o),e.consume(i),e.exit(o),u):null===i||32===i||41===i||eV(i)?r(i):(e.enter(s),e.enter(l),e.enter(a),e.enter("chunkString",{contentType:"string"}),_(i))};function u(r){return 62===r?(e.enter(o),e.consume(r),e.exit(o),e.exit(n),e.exit(s),i):(e.enter(a),e.enter("chunkString",{contentType:"string"}),f(r))}function f(i){return 62===i?(e.exit("chunkString"),e.exit(a),u(i)):null===i||60===i||eJ(i)?r(i):(e.consume(i),92===i?p:f)}function p(i){return 60===i||62===i||92===i?(e.consume(i),f):f(i)}function _(n){return!d&&(null===n||41===n||eQ(n))?(e.exit("chunkString"),e.exit(a),e.exit(l),e.exit(s),i(n)):d<c&&40===n?(e.consume(n),d++,_):41===n?(e.consume(n),d--,_):null===n||32===n||40===n||eV(n)?r(n):(e.consume(n),92===n?m:_)}function m(i){return 40===i||41===i||92===i?(e.consume(i),_):_(i)}}function tC(e,i,r,s,n,o){let l,a=this,h=0;return function(i){return e.enter(s),e.enter(n),e.consume(i),e.exit(n),e.enter(o),c};function c(u){return h>999||null===u||91===u||93===u&&!l||94===u&&!h&&"_hiddenFootnoteSupport"in a.parser.constructs?r(u):93===u?(e.exit(o),e.enter(n),e.consume(u),e.exit(n),e.exit(s),i):eJ(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(i){return null===i||91===i||93===i||eJ(i)||h++>999?(e.exit("chunkString"),c(i)):(e.consume(i),l||(l=!eZ(i)),92===i?u:d)}function u(i){return 91===i||92===i||93===i?(e.consume(i),h++,d):d(i)}}function tk(e,i,r,s,n,o){let l;return function(i){return 34===i||39===i||40===i?(e.enter(s),e.enter(n),e.consume(i),e.exit(n),l=40===i?41:i,a):r(i)};function a(r){return r===l?(e.enter(n),e.consume(r),e.exit(n),e.exit(s),i):(e.enter(o),h(r))}function h(i){return i===l?(e.exit(o),a(l)):null===i?r(i):eJ(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e5(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(i))}function c(i){return i===l||null===i||eJ(i)?(e.exit("chunkString"),h(i)):(e.consume(i),92===i?d:c)}function d(i){return i===l||92===i?(e.consume(i),c):c(i)}}function tE(e,i){let r;return function s(n){return eJ(n)?(e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),r=!0,s):eZ(n)?e5(e,s,r?"linePrefix":"lineSuffix")(n):i(n)}}function tN(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}let tR={partial:!0,tokenize:function(e,i,r){return function(i){return eQ(i)?tE(e,s)(i):r(i)};function s(i){return tk(e,n,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(i)}function n(i){return eZ(i)?e5(e,o,"whitespace")(i):o(i)}function o(e){return null===e||eJ(e)?i(e):r(e)}}},tD=["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","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],tM=["pre","script","style","textarea"],tT={partial:!0,tokenize:function(e,i,r){return function(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(e9,i,r)}}},tP={partial:!0,tokenize:function(e,i,r){let s=this;return function(i){return eJ(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n):r(i)};function n(e){return s.parser.lazy[s.now().line]?r(e):i(e)}}},tj={name:"labelEnd",resolveAll:function(e){let i=-1,r=[];for(;++i<e.length;){let s=e[i][1];if(r.push(e[i]),"labelImage"===s.type||"labelLink"===s.type||"labelEnd"===s.type){let e="labelImage"===s.type?4:2;s.type="data",i+=e}}return e.length!==r.length&&eF(e,0,e.length,r),e},resolveTo:function(e,i){let r,s,n,o,l=e.length,a=0;for(;l--;)if(r=e[l][1],s){if("link"===r.type||"labelLink"===r.type&&r._inactive)break;"enter"===e[l][0]&&"labelLink"===r.type&&(r._inactive=!0)}else if(n){if("enter"===e[l][0]&&("labelImage"===r.type||"labelLink"===r.type)&&!r._balanced&&(s=l,"labelLink"!==r.type)){a=2;break}}else"labelEnd"===r.type&&(n=l);let h={type:"labelLink"===e[s][1].type?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[n][1].end}},d={type:"labelText",start:{...e[s+a+2][1].end},end:{...e[n-2][1].start}};return o=eW(o=[["enter",h,i],["enter",c,i]],e.slice(s+1,s+a+3)),o=eW(o,[["enter",d,i]]),o=eW(o,td(i.parser.constructs.insideSpan.null,e.slice(s+a+4,n-3),i)),o=eW(o,[["exit",d,i],e[n-2],e[n-1],["exit",c,i]]),o=eW(o,e.slice(n+1)),o=eW(o,[["exit",h,i]]),eF(e,s,e.length,o),e},tokenize:function(e,i,r){let s,n,o=this,l=o.events.length;for(;l--;)if(("labelImage"===o.events[l][1].type||"labelLink"===o.events[l][1].type)&&!o.events[l][1]._balanced){s=o.events[l][1];break}return function(i){return s?s._inactive?d(i):(n=o.parser.defined.includes(tN(o.sliceSerialize({start:s.end,end:o.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelEnd"),a):r(i)};function a(i){return 40===i?e.attempt(tB,c,n?c:d)(i):91===i?e.attempt(tL,c,n?h:d)(i):n?c(i):d(i)}function h(i){return e.attempt(tA,c,d)(i)}function c(e){return i(e)}function d(e){return s._balanced=!0,r(e)}}},tB={tokenize:function(e,i,r){return function(i){return e.enter("resource"),e.enter("resourceMarker"),e.consume(i),e.exit("resourceMarker"),s};function s(i){return eQ(i)?tE(e,n)(i):n(i)}function n(i){return 41===i?c(i):tw(e,o,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(i)}function o(i){return eQ(i)?tE(e,a)(i):c(i)}function l(e){return r(e)}function a(i){return 34===i||39===i||40===i?tk(e,h,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(i):c(i)}function h(i){return eQ(i)?tE(e,c)(i):c(i)}function c(s){return 41===s?(e.enter("resourceMarker"),e.consume(s),e.exit("resourceMarker"),e.exit("resource"),i):r(s)}}},tL={tokenize:function(e,i,r){let s=this;return function(i){return tC.call(s,e,n,o,"reference","referenceMarker","referenceString")(i)};function n(e){return s.parser.defined.includes(tN(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?i(e):r(e)}function o(e){return r(e)}}},tA={tokenize:function(e,i,r){return function(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),s};function s(s){return 93===s?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),i):r(s)}}},tI={name:"labelStartImage",resolveAll:tj.resolveAll,tokenize:function(e,i,r){let s=this;return function(i){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(i),e.exit("labelImageMarker"),n};function n(i){return 91===i?(e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelImage"),o):r(i)}function o(e){return 94===e&&"_hiddenFootnoteSupport"in s.parser.constructs?r(e):i(e)}}},tO={name:"labelStartLink",resolveAll:tj.resolveAll,tokenize:function(e,i,r){let s=this;return function(i){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelLink"),n};function n(e){return 94===e&&"_hiddenFootnoteSupport"in s.parser.constructs?r(e):i(e)}}},tz={name:"lineEnding",tokenize:function(e,i){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e5(e,i,"linePrefix")}}},tH={name:"thematicBreak",tokenize:function(e,i,r){let s,n=0;return function(o){var l;return e.enter("thematicBreak"),s=l=o,function o(l){return l===s?(e.enter("thematicBreakSequence"),function i(r){return r===s?(e.consume(r),n++,i):(e.exit("thematicBreakSequence"),eZ(r)?e5(e,o,"whitespace")(r):o(r))}(l)):n>=3&&(null===l||eJ(l))?(e.exit("thematicBreak"),i(l)):r(l)}(l)}}},tF={continuation:{tokenize:function(e,i,r){let s=this;return s.containerState._closeFlow=void 0,e.check(e9,function(r){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,e5(e,i,"listItemIndent",s.containerState.size+1)(r)},function(r){return s.containerState.furtherBlankLines||!eZ(r)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,n(r)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(t$,i,n)(r))});function n(n){return s.containerState._closeFlow=!0,s.interrupt=void 0,e5(e,e.attempt(tF,i,r),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(n)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,i,r){let s=this,n=s.events[s.events.length-1],o=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,l=0;return function(i){let n=s.containerState.type||(42===i||43===i||45===i?"listUnordered":"listOrdered");if("listUnordered"===n?!s.containerState.marker||i===s.containerState.marker:eY(i)){if(s.containerState.type||(s.containerState.type=n,e.enter(n,{_container:!0})),"listUnordered"===n)return e.enter("listItemPrefix"),42===i||45===i?e.check(tH,r,a)(i):a(i);if(!s.interrupt||49===i)return e.enter("listItemPrefix"),e.enter("listItemValue"),function i(n){return eY(n)&&++l<10?(e.consume(n),i):(!s.interrupt||l<2)&&(s.containerState.marker?n===s.containerState.marker:41===n||46===n)?(e.exit("listItemValue"),a(n)):r(n)}(i)}return r(i)};function a(i){return e.enter("listItemMarker"),e.consume(i),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||i,e.check(e9,s.interrupt?r:h,e.attempt(tW,d,c))}function h(e){return s.containerState.initialBlankLine=!0,o++,d(e)}function c(i){return eZ(i)?(e.enter("listItemPrefixWhitespace"),e.consume(i),e.exit("listItemPrefixWhitespace"),d):r(i)}function d(r){return s.containerState.size=o+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,i(r)}}},tW={partial:!0,tokenize:function(e,i,r){let s=this;return e5(e,function(e){let n=s.events[s.events.length-1];return!eZ(e)&&n&&"listItemPrefixWhitespace"===n[1].type?i(e):r(e)},"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},t$={partial:!0,tokenize:function(e,i,r){let s=this;return e5(e,function(e){let n=s.events[s.events.length-1];return n&&"listItemIndent"===n[1].type&&n[2].sliceSerialize(n[1],!0).length===s.containerState.size?i(e):r(e)},"listItemIndent",s.containerState.size+1)}},tU={name:"setextUnderline",resolveTo:function(e,i){let r,s,n,o=e.length;for(;o--;)if("enter"===e[o][0]){if("content"===e[o][1].type){r=o;break}"paragraph"===e[o][1].type&&(s=o)}else"content"===e[o][1].type&&e.splice(o,1),n||"definition"!==e[o][1].type||(n=o);let l={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",n?(e.splice(s,0,["enter",l,i]),e.splice(n+1,0,["exit",e[r][1],i]),e[r][1].end={...e[n][1].end}):e[r][1]=l,e.push(["exit",l,i]),e},tokenize:function(e,i,r){let s,n=this;return function(i){var l;let a,h=n.events.length;for(;h--;)if("lineEnding"!==n.events[h][1].type&&"linePrefix"!==n.events[h][1].type&&"content"!==n.events[h][1].type){a="paragraph"===n.events[h][1].type;break}return!n.parser.lazy[n.now().line]&&(n.interrupt||a)?(e.enter("setextHeadingLine"),s=i,l=i,e.enter("setextHeadingLineSequence"),function i(r){return r===s?(e.consume(r),i):(e.exit("setextHeadingLineSequence"),eZ(r)?e5(e,o,"lineSuffix")(r):o(r))}(l)):r(i)};function o(s){return null===s||eJ(s)?(e.exit("setextHeadingLine"),i(s)):r(s)}}};e.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(e,i,r){let s,n=this;return function(i){var s;return e.enter("definition"),s=i,tC.call(n,e,o,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(s)};function o(i){return(s=tN(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)),58===i)?(e.enter("definitionMarker"),e.consume(i),e.exit("definitionMarker"),l):r(i)}function l(i){return eQ(i)?tE(e,a)(i):a(i)}function a(i){return tw(e,h,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(i)}function h(i){return e.attempt(tR,c,c)(i)}function c(i){return eZ(i)?e5(e,d,"whitespace")(i):d(i)}function d(o){return null===o||eJ(o)?(e.exit("definition"),n.parser.defined.push(s),i(o)):r(o)}}}},"disable",0,{null:[]},"document",0,{42:tF,43:tF,45:tF,48:tF,49:tF,50:tF,51:tF,52:tF,53:tF,54:tF,55:tF,56:tF,57:tF,62:tp},"flow",0,{35:{name:"headingAtx",resolve:function(e,i){let r,s,n=e.length-2,o=3;return"whitespace"===e[3][1].type&&(o+=2),n-2>o&&"whitespace"===e[n][1].type&&(n-=2),"atxHeadingSequence"===e[n][1].type&&(o===n-1||n-4>o&&"whitespace"===e[n-2][1].type)&&(n-=o+1===n?2:4),n>o&&(r={type:"atxHeadingText",start:e[o][1].start,end:e[n][1].end},s={type:"chunkText",start:e[o][1].start,end:e[n][1].end,contentType:"text"},eF(e,o,n-o+1,[["enter",r,i],["enter",s,i],["exit",s,i],["exit",r,i]])),e},tokenize:function(e,i,r){let s=0;return function(n){var o;return e.enter("atxHeading"),o=n,e.enter("atxHeadingSequence"),function n(o){return 35===o&&s++<6?(e.consume(o),n):null===o||eQ(o)?(e.exit("atxHeadingSequence"),function r(s){return 35===s?(e.enter("atxHeadingSequence"),function i(s){return 35===s?(e.consume(s),i):(e.exit("atxHeadingSequence"),r(s))}(s)):null===s||eJ(s)?(e.exit("atxHeading"),i(s)):eZ(s)?e5(e,r,"whitespace")(s):(e.enter("atxHeadingText"),function i(s){return null===s||35===s||eQ(s)?(e.exit("atxHeadingText"),r(s)):(e.consume(s),i)}(s))}(o)):r(o)}(o)}}},42:tH,45:[tU,tH],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let i=e.length;for(;i--&&("enter"!==e[i][0]||"htmlFlow"!==e[i][1].type););return i>1&&"linePrefix"===e[i-2][1].type&&(e[i][1].start=e[i-2][1].start,e[i+1][1].start=e[i-2][1].start,e.splice(i-2,2)),e},tokenize:function(e,i,r){let s,n,o,l,a,h=this;return function(i){var r;return r=i,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(r),c};function c(l){return 33===l?(e.consume(l),d):47===l?(e.consume(l),n=!0,p):63===l?(e.consume(l),s=3,h.interrupt?i:j):eU(l)?(e.consume(l),o=String.fromCharCode(l),_):r(l)}function d(n){return 45===n?(e.consume(n),s=2,u):91===n?(e.consume(n),s=5,l=0,f):eU(n)?(e.consume(n),s=4,h.interrupt?i:j):r(n)}function u(s){return 45===s?(e.consume(s),h.interrupt?i:j):r(s)}function f(s){let n="CDATA[";return s===n.charCodeAt(l++)?(e.consume(s),l===n.length)?h.interrupt?i:k:f:r(s)}function p(i){return eU(i)?(e.consume(i),o=String.fromCharCode(i),_):r(i)}function _(l){if(null===l||47===l||62===l||eQ(l)){let a=47===l,c=o.toLowerCase();return!a&&!n&&tM.includes(c)?(s=1,h.interrupt?i(l):k(l)):tD.includes(o.toLowerCase())?(s=6,a)?(e.consume(l),m):h.interrupt?i(l):k(l):(s=7,h.interrupt&&!h.parser.lazy[h.now().line]?r(l):n?function i(r){return eZ(r)?(e.consume(r),i):w(r)}(l):g(l))}return 45===l||eK(l)?(e.consume(l),o+=String.fromCharCode(l),_):r(l)}function m(s){return 62===s?(e.consume(s),h.interrupt?i:k):r(s)}function g(i){return 47===i?(e.consume(i),w):58===i||95===i||eU(i)?(e.consume(i),v):eZ(i)?(e.consume(i),g):w(i)}function v(i){return 45===i||46===i||58===i||95===i||eK(i)?(e.consume(i),v):x(i)}function x(i){return 61===i?(e.consume(i),b):eZ(i)?(e.consume(i),x):g(i)}function b(i){return null===i||60===i||61===i||62===i||96===i?r(i):34===i||39===i?(e.consume(i),a=i,y):eZ(i)?(e.consume(i),b):function i(r){return null===r||34===r||39===r||47===r||60===r||61===r||62===r||96===r||eQ(r)?x(r):(e.consume(r),i)}(i)}function y(i){return i===a?(e.consume(i),a=null,S):null===i||eJ(i)?r(i):(e.consume(i),y)}function S(e){return 47===e||62===e||eZ(e)?g(e):r(e)}function w(i){return 62===i?(e.consume(i),C):r(i)}function C(i){return null===i||eJ(i)?k(i):eZ(i)?(e.consume(i),C):r(i)}function k(i){return 45===i&&2===s?(e.consume(i),D):60===i&&1===s?(e.consume(i),M):62===i&&4===s?(e.consume(i),B):63===i&&3===s?(e.consume(i),j):93===i&&5===s?(e.consume(i),P):eJ(i)&&(6===s||7===s)?(e.exit("htmlFlowData"),e.check(tT,L,E)(i)):null===i||eJ(i)?(e.exit("htmlFlowData"),E(i)):(e.consume(i),k)}function E(i){return e.check(tP,N,L)(i)}function N(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),R}function R(i){return null===i||eJ(i)?E(i):(e.enter("htmlFlowData"),k(i))}function D(i){return 45===i?(e.consume(i),j):k(i)}function M(i){return 47===i?(e.consume(i),o="",T):k(i)}function T(i){if(62===i){let r=o.toLowerCase();return tM.includes(r)?(e.consume(i),B):k(i)}return eU(i)&&o.length<8?(e.consume(i),o+=String.fromCharCode(i),T):k(i)}function P(i){return 93===i?(e.consume(i),j):k(i)}function j(i){return 62===i?(e.consume(i),B):45===i&&2===s?(e.consume(i),j):k(i)}function B(i){return null===i||eJ(i)?(e.exit("htmlFlowData"),L(i)):(e.consume(i),B)}function L(r){return e.exit("htmlFlow"),i(r)}}},61:tU,95:tH,96:tb,126:tb},"flowInitial",0,{[-2]:ty,[-1]:ty,32:ty},"insideSpan",0,{null:[tu,ts]},"string",0,{38:tv,92:t_},"text",0,{[-5]:tz,[-4]:tz,[-3]:tz,33:tI,38:tv,42:tu,60:[{name:"autolink",tokenize:function(e,i,r){let s=0;return function(i){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(i),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),n};function n(i){return eU(i)?(e.consume(i),o):64===i?r(i):a(i)}function o(i){return 43===i||45===i||46===i||eK(i)?(s=1,function i(r){return 58===r?(e.consume(r),s=0,l):(43===r||45===r||46===r||eK(r))&&s++<32?(e.consume(r),i):(s=0,a(r))}(i)):a(i)}function l(s){return 62===s?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(s),e.exit("autolinkMarker"),e.exit("autolink"),i):null===s||32===s||60===s||eV(s)?r(s):(e.consume(s),l)}function a(i){return 64===i?(e.consume(i),h):eq(i)?(e.consume(i),a):r(i)}function h(n){return eK(n)?function n(o){return 46===o?(e.consume(o),s=0,h):62===o?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(o),e.exit("autolinkMarker"),e.exit("autolink"),i):function i(o){if((45===o||eK(o))&&s++<63){let r=45===o?i:n;return e.consume(o),r}return r(o)}(o)}(n):r(n)}}},{name:"htmlText",tokenize:function(e,i,r){let s,n,o,l=this;return function(i){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(i),a};function a(i){return 33===i?(e.consume(i),h):47===i?(e.consume(i),y):63===i?(e.consume(i),x):eU(i)?(e.consume(i),w):r(i)}function h(i){return 45===i?(e.consume(i),c):91===i?(e.consume(i),n=0,p):eU(i)?(e.consume(i),v):r(i)}function c(i){return 45===i?(e.consume(i),f):r(i)}function d(i){return null===i?r(i):45===i?(e.consume(i),u):eJ(i)?(o=d,T(i)):(e.consume(i),d)}function u(i){return 45===i?(e.consume(i),f):d(i)}function f(e){return 62===e?M(e):45===e?u(e):d(e)}function p(i){let s="CDATA[";return i===s.charCodeAt(n++)?(e.consume(i),n===s.length?_:p):r(i)}function _(i){return null===i?r(i):93===i?(e.consume(i),m):eJ(i)?(o=_,T(i)):(e.consume(i),_)}function m(i){return 93===i?(e.consume(i),g):_(i)}function g(i){return 62===i?M(i):93===i?(e.consume(i),g):_(i)}function v(i){return null===i||62===i?M(i):eJ(i)?(o=v,T(i)):(e.consume(i),v)}function x(i){return null===i?r(i):63===i?(e.consume(i),b):eJ(i)?(o=x,T(i)):(e.consume(i),x)}function b(e){return 62===e?M(e):x(e)}function y(i){return eU(i)?(e.consume(i),S):r(i)}function S(i){return 45===i||eK(i)?(e.consume(i),S):function i(r){return eJ(r)?(o=i,T(r)):eZ(r)?(e.consume(r),i):M(r)}(i)}function w(i){return 45===i||eK(i)?(e.consume(i),w):47===i||62===i||eQ(i)?C(i):r(i)}function C(i){return 47===i?(e.consume(i),M):58===i||95===i||eU(i)?(e.consume(i),k):eJ(i)?(o=C,T(i)):eZ(i)?(e.consume(i),C):M(i)}function k(i){return 45===i||46===i||58===i||95===i||eK(i)?(e.consume(i),k):function i(r){return 61===r?(e.consume(r),E):eJ(r)?(o=i,T(r)):eZ(r)?(e.consume(r),i):C(r)}(i)}function E(i){return null===i||60===i||61===i||62===i||96===i?r(i):34===i||39===i?(e.consume(i),s=i,N):eJ(i)?(o=E,T(i)):eZ(i)?(e.consume(i),E):(e.consume(i),R)}function N(i){return i===s?(e.consume(i),s=void 0,D):null===i?r(i):eJ(i)?(o=N,T(i)):(e.consume(i),N)}function R(i){return null===i||34===i||39===i||60===i||61===i||96===i?r(i):47===i||62===i||eQ(i)?C(i):(e.consume(i),R)}function D(e){return 47===e||62===e||eQ(e)?C(e):r(e)}function M(s){return 62===s?(e.consume(s),e.exit("htmlTextData"),e.exit("htmlText"),i):r(s)}function T(i){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),P}function P(i){return eZ(i)?e5(e,j,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):j(i)}function j(i){return e.enter("htmlTextData"),o(i)}}}],91:tO,92:[{name:"hardBreakEscape",tokenize:function(e,i,r){return function(i){return e.enter("hardBreakEscape"),e.consume(i),s};function s(s){return eJ(s)?(e.exit("hardBreakEscape"),i(s)):r(s)}}},t_],93:tj,95:tu,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let i,r,s=e.length-4,n=3;if(("lineEnding"===e[3][1].type||"space"===e[n][1].type)&&("lineEnding"===e[s][1].type||"space"===e[s][1].type)){for(i=n;++i<s;)if("codeTextData"===e[i][1].type){e[n][1].type="codeTextPadding",e[s][1].type="codeTextPadding",n+=2,s-=2;break}}for(i=n-1,s++;++i<=s;)void 0===r?i!==s&&"lineEnding"!==e[i][1].type&&(r=i):(i===s||"lineEnding"===e[i][1].type)&&(e[r][1].type="codeTextData",i!==r+2&&(e[r][1].end=e[i-1][1].end,e.splice(r+2,i-r-2),s-=i-r-2,i=r+2),r=void 0);return e},tokenize:function(e,i,r){let s,n,o=0;return function(i){return e.enter("codeText"),e.enter("codeTextSequence"),function i(r){return 96===r?(e.consume(r),o++,i):(e.exit("codeTextSequence"),l(r))}(i)};function l(h){return null===h?r(h):32===h?(e.enter("space"),e.consume(h),e.exit("space"),l):96===h?(n=e.enter("codeTextSequence"),s=0,function r(l){return 96===l?(e.consume(l),s++,r):s===o?(e.exit("codeTextSequence"),e.exit("codeText"),i(l)):(n.type="codeTextData",a(l))}(h)):eJ(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),l):(e.enter("codeTextData"),a(h))}function a(i){return null===i||32===i||96===i||eJ(i)?(e.exit("codeTextData"),l(i)):(e.consume(i),a)}}}}],4127);var tK=e.i(4127);let tq=/[\0\t\n\r]/g;function tV(e,i){let r=Number.parseInt(e,i);return r<9||11===r||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(65535&r)==65535||(65535&r)==65534||r>1114111?"�":String.fromCodePoint(r)}let tY=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function tG(e,i,r){if(i)return i;if(35===r.charCodeAt(0)){let e=r.charCodeAt(1),i=120===e||88===e;return tV(r.slice(i?2:1),i?16:10)}return tg(r)||e}let tX={}.hasOwnProperty;function tJ(e){return{line:e.line,column:e.column,offset:e.offset}}function tQ(e,i){if(e)throw Error("Cannot close `"+e.type+"` ("+ex({start:e.start,end:e.end})+"): a different token (`"+i.type+"`, "+ex({start:i.start,end:i.end})+") is open");throw Error("Cannot close document, a token (`"+i.type+"`, "+ex({start:i.start,end:i.end})+") is still open")}function tZ(e){let i=this;i.parser=function(r){var s,n;let o,l,a,h;return"object"==typeof(s={...i.data("settings"),...e,extensions:i.data("micromarkExtensions")||[],mdastExtensions:i.data("fromMarkdownExtensions")||[]})&&(n=s,s=void 0),(function(e){let i={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(v),autolinkProtocol:c,autolinkEmail:c,atxHeading:s(_),blockQuote:s(function(){return{type:"blockquote",children:[]}}),characterEscape:c,characterReference:c,codeFenced:s(p),codeFencedFenceInfo:n,codeFencedFenceMeta:n,codeIndented:s(p,n),codeText:s(function(){return{type:"inlineCode",value:""}},n),codeTextData:c,data:c,codeFlowValue:c,definition:s(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:n,definitionLabelString:n,definitionTitleString:n,emphasis:s(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:s(m),hardBreakTrailing:s(m),htmlFlow:s(g,n),htmlFlowData:c,htmlText:s(g,n),htmlTextData:c,image:s(function(){return{type:"image",title:null,url:"",alt:null}}),label:n,link:s(v),listItem:s(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:s(x,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:s(x),paragraph:s(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:n,resourceDestinationString:n,resourceTitleString:n,setextHeading:s(_),strong:s(function(){return{type:"strong",children:[]}}),thematicBreak:s(function(){return{type:"thematicBreak"}})},exit:{atxHeading:l(),atxHeadingSequence:function(e){let i=this.stack[this.stack.length-1];i.depth||(i.depth=this.sliceSerialize(e).length)},autolink:l(),autolinkEmail:function(e){d.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){d.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:l(),characterEscapeValue:d,characterReferenceMarkerHexadecimal:f,characterReferenceMarkerNumeric:f,characterReferenceValue:function(e){let i,r=this.sliceSerialize(e),s=this.data.characterReferenceType;s?(i=tV(r,"characterReferenceMarkerNumeric"===s?10:16),this.data.characterReferenceType=void 0):i=tg(r);let n=this.stack[this.stack.length-1];n.value+=i},characterReference:function(e){this.stack.pop().position.end=tJ(e.end)},codeFenced:l(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){let e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:d,codeIndented:l(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:l(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:d,data:d,definition:l(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let i=this.resume(),r=this.stack[this.stack.length-1];r.label=i,r.identifier=tN(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:l(),hardBreakEscape:l(u),hardBreakTrailing:l(u),htmlFlow:l(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:d,htmlText:l(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:d,image:l(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let i=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=i,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],i=this.resume(),r=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===r.type?r.children=e.children:r.alt=i},labelText:function(e){let i=this.sliceSerialize(e),r=this.stack[this.stack.length-2];r.label=i.replace(tY,tG),r.identifier=tN(i).toLowerCase()},lineEnding:function(e){let r=this.stack[this.stack.length-1];if(this.data.atHardBreak){r.children[r.children.length-1].position.end=tJ(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&i.canContainEols.includes(r.type)&&(c.call(this,e),d.call(this,e))},link:l(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let i=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=i,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:function(e){let i=this.resume(),r=this.stack[this.stack.length-1];r.label=i,r.identifier=tN(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:l(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:l(),thematicBreak:l()}};!function e(i,r){let s=-1;for(;++s<r.length;){let n=r[s];Array.isArray(n)?e(i,n):function(e,i){let r;for(r in i)if(tX.call(i,r))switch(r){case"canContainEols":{let s=i[r];s&&e[r].push(...s);break}case"transforms":{let s=i[r];s&&e[r].push(...s);break}case"enter":case"exit":{let s=i[r];s&&Object.assign(e[r],s)}}}(i,n)}}(i,(e||{}).mdastExtensions||[]);let r={};return function(e){let s={type:"root",children:[]},l={stack:[s],tokenStack:[],config:i,enter:o,exit:a,buffer:n,resume:h,data:r},c=[],d=-1;for(;++d<e.length;)("listOrdered"===e[d][1].type||"listUnordered"===e[d][1].type)&&("enter"===e[d][0]?c.push(d):d=function(e,i,r){let s,n,o,l,a=i-1,h=-1,c=!1;for(;++a<=r;){let i=e[a];switch(i[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===i[0]?h++:h--,l=void 0;break;case"lineEndingBlank":"enter"===i[0]&&(!s||l||h||o||(o=a),l=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:l=void 0}if(!h&&"enter"===i[0]&&"listItemPrefix"===i[1].type||-1===h&&"exit"===i[0]&&("listUnordered"===i[1].type||"listOrdered"===i[1].type)){if(s){let l=a;for(n=void 0;l--;){let i=e[l];if("lineEnding"===i[1].type||"lineEndingBlank"===i[1].type){if("exit"===i[0])continue;n&&(e[n][1].type="lineEndingBlank",c=!0),i[1].type="lineEnding",n=l}else if("linePrefix"===i[1].type||"blockQuotePrefix"===i[1].type||"blockQuotePrefixWhitespace"===i[1].type||"blockQuoteMarker"===i[1].type||"listItemIndent"===i[1].type);else break}o&&(!n||o<n)&&(s._spread=!0),s.end=Object.assign({},n?e[n][1].start:i[1].end),e.splice(n||a,0,["exit",s,i[2]]),a++,r++}if("listItemPrefix"===i[1].type){let n={type:"listItem",_spread:!1,start:Object.assign({},i[1].start),end:void 0};s=n,e.splice(a,0,["enter",n,i[2]]),a++,r++,o=void 0,l=!0}}}return e[i][1]._spread=c,r}(e,c.pop(),d));for(d=-1;++d<e.length;){let r=i[e[d][0]];tX.call(r,e[d][1].type)&&r[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},l),e[d][1])}if(l.tokenStack.length>0){let e=l.tokenStack[l.tokenStack.length-1];(e[1]||tQ).call(l,void 0,e[0])}for(s.position={start:tJ(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:tJ(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<i.transforms.length;)s=i.transforms[d](s)||s;return s};function s(e,i){return function(r){o.call(this,e(r),r),i&&i.call(this,r)}}function n(){this.stack.push({type:"fragment",children:[]})}function o(e,i,r){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([i,r||void 0]),e.position={start:tJ(i.start),end:void 0}}function l(e){return function(i){e&&e.call(this,i),a.call(this,i)}}function a(e,i){let r=this.stack.pop(),s=this.tokenStack.pop();if(s)s[0].type!==e.type&&(i?i.call(this,e,s[0]):(s[1]||tQ).call(this,e,s[0]));else throw Error("Cannot close `"+e.type+"` ("+ex({start:e.start,end:e.end})+"): it’s not open");r.position.end=tJ(e.end)}function h(){var e;return e=this.stack.pop(),ez(e,"boolean"!=typeof eO.includeImageAlt||eO.includeImageAlt,"boolean"!=typeof eO.includeHtml||eO.includeHtml)}function c(e){let i=this.stack[this.stack.length-1].children,r=i[i.length-1];r&&"text"===r.type||((r={type:"text",value:""}).position={start:tJ(e.start),end:void 0},i.push(r)),this.stack.push(r)}function d(e){let i=this.stack.pop();i.value+=this.sliceSerialize(e),i.position.end=tJ(e.end)}function u(){this.data.atHardBreak=!0}function f(e){this.data.characterReferenceType=e.type}function p(){return{type:"code",lang:null,meta:null,value:""}}function _(){return{type:"heading",depth:0,children:[]}}function m(){return{type:"break"}}function g(){return{type:"html",value:""}}function v(){return{type:"link",title:null,url:"",children:[]}}function x(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(n)(function(e){for(;!te(e););return e}((function(e){let i={constructs:function(e){let i={},r=-1;for(;++r<e.length;)!function(e,i){let r;for(r in i){let s,n=(e$.call(e,r)?e[r]:void 0)||(e[r]={}),o=i[r];if(o)for(s in o){e$.call(n,s)||(n[s]=[]);let e=o[s];!function(e,i){let r=-1,s=[];for(;++r<i.length;)("after"===i[r].add?e:s).push(i[r]);eF(e,0,0,s)}(n[s],Array.isArray(e)?e:e?[e]:[])}}}(i,e[r]);return i}([tK,...(e||{}).extensions||[]]),content:r(e3),defined:[],document:r(e4),flow:r(tr),lazy:{},string:r(tn),text:r(to)};return i;function r(e){return function(r){return function(e,i,r){let s={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0},n={},o=[],l=[],a=[],h={attempt:_(function(e,i){m(e,i.from)}),check:_(p),consume:function(e){eJ(e)?(s.line++,s.column=1,s.offset+=-3===e?2:1,g()):-1!==e&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===l[s._index].length&&(s._bufferIndex=-1,s._index++)),c.previous=e},enter:function(e,i){let r=i||{};return r.type=e,r.start=f(),c.events.push(["enter",r,c]),a.push(r),r},exit:function(e){let i=a.pop();return i.end=f(),c.events.push(["exit",i,c]),i},interrupt:_(p,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){n[e.line]=e.column,g()},events:[],now:f,parser:e,previous:null,sliceSerialize:function(e,i){return function(e,i){let r,s=-1,n=[];for(;++s<e.length;){let o,l=e[s];if("string"==typeof l)o=l;else switch(l){case -5:o="\r";break;case -4:o="\n";break;case -3:o="\r\n";break;case -2:o=i?" ":" ";break;case -1:if(!i&&r)continue;o=" ";break;default:o=String.fromCharCode(l)}r=-2===l,n.push(o)}return n.join("")}(u(e),i)},sliceStream:u,write:function(e){return(l=eW(l,e),function(){let e;for(;s._index<l.length;){let r=l[s._index];if("string"==typeof r)for(e=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===e&&s._bufferIndex<r.length;){var i;i=r.charCodeAt(s._bufferIndex),d=d(i)}else d=d(r)}}(),null!==l[l.length-1])?[]:(m(i,0),c.events=td(o,c.events,c),c.events)}},d=i.tokenize.call(c,h);return i.resolveAll&&o.push(i),c;function u(e){return function(e,i){let r,s=i.start._index,n=i.start._bufferIndex,o=i.end._index,l=i.end._bufferIndex;if(s===o)r=[e[s].slice(n,l)];else{if(r=e.slice(s,o),n>-1){let e=r[0];"string"==typeof e?r[0]=e.slice(n):r.shift()}l>0&&r.push(e[o].slice(0,l))}return r}(l,e)}function f(){let{_bufferIndex:e,_index:i,line:r,column:n,offset:o}=s;return{_bufferIndex:e,_index:i,line:r,column:n,offset:o}}function p(e,i){i.restore()}function _(e,i){return function(r,n,o){var l;let d,u,p,_;return Array.isArray(r)?m(r):"tokenize"in r?m([r]):(l=r,function(e){let i=null!==e&&l[e],r=null!==e&&l.null;return m([...Array.isArray(i)?i:i?[i]:[],...Array.isArray(r)?r:r?[r]:[]])(e)});function m(e){return(d=e,u=0,0===e.length)?o:v(e[u])}function v(e){return function(r){let n,o,l,d,u;return(n=f(),o=c.previous,l=c.currentConstruct,d=c.events.length,u=Array.from(a),_={from:d,restore:function(){s=n,c.previous=o,c.currentConstruct=l,c.events.length=d,a=u,g()}},p=e,e.partial||(c.currentConstruct=e),e.name&&c.parser.constructs.disable.null.includes(e.name))?b(r):e.tokenize.call(i?Object.assign(Object.create(c),i):c,h,x,b)(r)}}function x(i){return e(p,_),n}function b(e){return(_.restore(),++u<d.length)?v(d[u]):o}}}function m(e,i){e.resolveAll&&!o.includes(e)&&o.push(e),e.resolve&&eF(c.events,i,c.events.length-i,e.resolve(c.events.slice(i),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function g(){s.line in n&&s.column<2&&(s.column=n[s.line],s.offset+=n[s.line]-1)}}(i,e,r)}}})(n).document().write((l=1,a="",h=!0,function(e,i,r){let s,n,c,d,u,f=[];for(e=a+("string"==typeof e?e.toString():new TextDecoder(i||void 0).decode(e)),c=0,a="",h&&(65279===e.charCodeAt(0)&&c++,h=void 0);c<e.length;){if(tq.lastIndex=c,d=(s=tq.exec(e))&&void 0!==s.index?s.index:e.length,u=e.charCodeAt(d),!s){a=e.slice(c);break}if(10===u&&c===d&&o)f.push(-3),o=void 0;else switch(o&&(f.push(-5),o=void 0),c<d&&(f.push(e.slice(c,d)),l+=d-c),u){case 0:f.push(65533),l++;break;case 9:for(n=4*Math.ceil(l/4),f.push(-2);l++<n;)f.push(-1);break;case 10:f.push(-4),l=1;break;default:o=!0,l=1}c=d+1}return r&&(o&&f.push(-5),a&&f.push(a),f.push(null)),f})(r,s,!0))))}}let t0="object"==typeof self?self:globalThis,t1=e=>{var i;let r,s;return(i=new Map,r=(e,r)=>(i.set(r,e),e),s=n=>{if(i.has(n))return i.get(n);let[o,l]=e[n];switch(o){case 0:case -1:return r(l,n);case 1:{let e=r([],n);for(let i of l)e.push(s(i));return e}case 2:{let e=r({},n);for(let[i,r]of l)e[s(i)]=s(r);return e}case 3:return r(new Date(l),n);case 4:{let{source:e,flags:i}=l;return r(new RegExp(e,i),n)}case 5:{let e=r(new Map,n);for(let[i,r]of l)e.set(s(i),s(r));return e}case 6:{let e=r(new Set,n);for(let i of l)e.add(s(i));return e}case 7:{let{name:e,message:i}=l;return r(new t0[e](i),n)}case 8:return r(BigInt(l),n);case"BigInt":return r(Object(BigInt(l)),n);case"ArrayBuffer":return r(new Uint8Array(l).buffer,l);case"DataView":{let{buffer:e}=new Uint8Array(l);return r(new DataView(e),l)}}return r(new t0[o](l),n)})(0)},{toString:t2}={},{keys:t5}=Object,t3=e=>{let i=typeof e;if("object"!==i||!e)return[0,i];let r=t2.call(e).slice(8,-1);switch(r){case"Array":return[1,""];case"Object":return[2,""];case"Date":return[3,""];case"RegExp":return[4,""];case"Map":return[5,""];case"Set":return[6,""];case"DataView":return[1,r]}return r.includes("Array")?[1,r]:r.includes("Error")?[7,r]:[2,r]},t4=([e,i])=>0===e&&("function"===i||"symbol"===i),t6=(e,{json:i,lossy:r}={})=>{var s,n,o;let l,a,h=[];return(s=!(i||r),n=!!i,o=new Map,l=(e,i)=>{let r=h.push(e)-1;return o.set(i,r),r},a=e=>{if(o.has(e))return o.get(e);let[i,r]=t3(e);switch(i){case 0:{let n=e;switch(r){case"bigint":i=8,n=e.toString();break;case"function":case"symbol":if(s)throw TypeError("unable to serialize "+r);n=null;break;case"undefined":return l([-1],e)}return l([i,n],e)}case 1:{if(r){let i=e;return"DataView"===r?i=new Uint8Array(e.buffer):"ArrayBuffer"===r&&(i=new Uint8Array(e)),l([r,[...i]],e)}let s=[],n=l([i,s],e);for(let i of e)s.push(a(i));return n}case 2:{if(r)switch(r){case"BigInt":return l([r,e.toString()],e);case"Boolean":case"Number":case"String":return l([r,e.valueOf()],e)}if(n&&"toJSON"in e)return a(e.toJSON());let o=[],h=l([i,o],e);for(let i of t5(e))(s||!t4(t3(e[i])))&&o.push([a(i),a(e[i])]);return h}case 3:return l([i,e.toISOString()],e);case 4:{let{source:r,flags:s}=e;return l([i,{source:r,flags:s}],e)}case 5:{let r=[],n=l([i,r],e);for(let[i,n]of e)(s||!(t4(t3(i))||t4(t3(n))))&&r.push([a(i),a(n)]);return n}case 6:{let r=[],n=l([i,r],e);for(let i of e)(s||!t4(t3(i)))&&r.push(a(i));return n}}let{message:h}=e;return l([i,{name:r,message:h}],e)})(e),h},t9="function"==typeof structuredClone?(e,i)=>i&&("json"in i||"lossy"in i)?t1(t6(e,i)):structuredClone(e):(e,i)=>t1(t6(e,i));function t8(e){let i=[],r=-1,s=0,n=0;for(;++r<e.length;){let o=e.charCodeAt(r),l="";if(37===o&&eK(e.charCodeAt(r+1))&&eK(e.charCodeAt(r+2)))n=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(l=String.fromCharCode(o));else if(o>55295&&o<57344){let i=e.charCodeAt(r+1);o<56320&&i>56319&&i<57344?(l=String.fromCharCode(o,i),n=1):l="�"}else l=String.fromCharCode(o);l&&(i.push(e.slice(s,r),encodeURIComponent(l)),s=r+n+1,l=""),n&&(r+=n,n=0)}return i.join("")+e.slice(s)}function t7(e,i){let r=[{type:"text",value:"↩"}];return i>1&&r.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(i)}]}),r}function ie(e,i){return"Back to reference "+(e+1)+(i>1?"-"+i:"")}let it=function(e){var i,r;if(null==e)return ir;if("function"==typeof e)return ii(e);if("object"==typeof e){return Array.isArray(e)?function(e){let i=[],r=-1;for(;++r<e.length;)i[r]=it(e[r]);return ii(function(...e){let r=-1;for(;++r<i.length;)if(i[r].apply(this,e))return!0;return!1})}(e):(i=e,ii(function(e){let r;for(r in i)if(e[r]!==i[r])return!1;return!0}))}if("string"==typeof e){return r=e,ii(function(e){return e&&e.type===r})}throw Error("Expected function, string, or object as test")};function ii(e){return function(i,r,s){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(i)&&e.call(this,i,"number"==typeof r?r:void 0,s||void 0))}}function ir(){return!0}let is=[];function io(e,i,r,s){var n,o,l;let a,h,c,d,u,f;"function"==typeof i&&"function"!=typeof r?(h=void 0,c=i,a=r):(h=i,c=r,a=s),n=h,o=function(e,i){let r=i[i.length-1],s=r?r.children.indexOf(e):void 0;return c(e,s,r)},l=a,"function"==typeof n&&"function"!=typeof o?(l=o,o=n):d=n,u=it(d),f=l?-1:1,(function e(i,r,s){let a=i&&"object"==typeof i?i:{};if("string"==typeof a.type){let e="string"==typeof a.tagName?a.tagName:"string"==typeof a.name?a.name:void 0;Object.defineProperty(h,"name",{value:"node ("+i.type+(e?"<"+e+">":"")+")"})}return h;function h(){var a;let h,c,d,p=is;if((!n||u(i,r,s[s.length-1]||void 0))&&!1===(p=Array.isArray(a=o(i,s))?a:"number"==typeof a?[!0,a]:null==a?is:[a])[0])return p;if("children"in i&&i.children&&i.children&&"skip"!==p[0])for(c=(l?i.children.length:-1)+f,d=s.concat(i);c>-1&&c<i.children.length;){if(!1===(h=e(i.children[c],c,d)())[0])return h;c="number"==typeof h[1]?h[1]:c+f}return p}})(e,void 0,[])()}function il(e,i){let r=i.referenceType,s="]";if("collapsed"===r?s+="[]":"full"===r&&(s+="["+(i.label||i.identifier)+"]"),"imageReference"===i.type)return[{type:"text",value:"!["+i.alt+s}];let n=e.all(i),o=n[0];o&&"text"===o.type?o.value="["+o.value:n.unshift({type:"text",value:"["});let l=n[n.length-1];return l&&"text"===l.type?l.value+=s:n.push({type:"text",value:s}),n}function ia(e){let i=e.spread;return null==i?e.children.length>1:i}function ih(e,i,r){let s=0,n=e.length;if(i){let i=e.codePointAt(s);for(;9===i||32===i;)s++,i=e.codePointAt(s)}if(r){let i=e.codePointAt(n-1);for(;9===i||32===i;)n--,i=e.codePointAt(n-1)}return n>s?e.slice(s,n):""}let ic={blockquote:function(e,i){let r={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(i),!0)};return e.patch(i,r),e.applyData(i,r)},break:function(e,i){let r={type:"element",tagName:"br",properties:{},children:[]};return e.patch(i,r),[e.applyData(i,r),{type:"text",value:"\n"}]},code:function(e,i){let r=i.value?i.value+"\n":"",s={},n=i.lang?i.lang.split(/\s+/):[];n.length>0&&(s.className=["language-"+n[0]]);let o={type:"element",tagName:"code",properties:s,children:[{type:"text",value:r}]};return i.meta&&(o.data={meta:i.meta}),e.patch(i,o),o={type:"element",tagName:"pre",properties:{},children:[o=e.applyData(i,o)]},e.patch(i,o),o},delete:function(e,i){let r={type:"element",tagName:"del",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},emphasis:function(e,i){let r={type:"element",tagName:"em",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},footnoteReference:function(e,i){let r,s="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=String(i.identifier).toUpperCase(),o=t8(n.toLowerCase()),l=e.footnoteOrder.indexOf(n),a=e.footnoteCounts.get(n);void 0===a?(a=0,e.footnoteOrder.push(n),r=e.footnoteOrder.length):r=l+1,a+=1,e.footnoteCounts.set(n,a);let h={type:"element",tagName:"a",properties:{href:"#"+s+"fn-"+o,id:s+"fnref-"+o+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(r)}]};e.patch(i,h);let c={type:"element",tagName:"sup",properties:{},children:[h]};return e.patch(i,c),e.applyData(i,c)},heading:function(e,i){let r={type:"element",tagName:"h"+i.depth,properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},html:function(e,i){if(e.options.allowDangerousHtml){let r={type:"raw",value:i.value};return e.patch(i,r),e.applyData(i,r)}},imageReference:function(e,i){let r=String(i.identifier).toUpperCase(),s=e.definitionById.get(r);if(!s)return il(e,i);let n={src:t8(s.url||""),alt:i.alt};null!==s.title&&void 0!==s.title&&(n.title=s.title);let o={type:"element",tagName:"img",properties:n,children:[]};return e.patch(i,o),e.applyData(i,o)},image:function(e,i){let r={src:t8(i.url)};null!==i.alt&&void 0!==i.alt&&(r.alt=i.alt),null!==i.title&&void 0!==i.title&&(r.title=i.title);let s={type:"element",tagName:"img",properties:r,children:[]};return e.patch(i,s),e.applyData(i,s)},inlineCode:function(e,i){let r={type:"text",value:i.value.replace(/\r?\n|\r/g," ")};e.patch(i,r);let s={type:"element",tagName:"code",properties:{},children:[r]};return e.patch(i,s),e.applyData(i,s)},linkReference:function(e,i){let r=String(i.identifier).toUpperCase(),s=e.definitionById.get(r);if(!s)return il(e,i);let n={href:t8(s.url||"")};null!==s.title&&void 0!==s.title&&(n.title=s.title);let o={type:"element",tagName:"a",properties:n,children:e.all(i)};return e.patch(i,o),e.applyData(i,o)},link:function(e,i){let r={href:t8(i.url)};null!==i.title&&void 0!==i.title&&(r.title=i.title);let s={type:"element",tagName:"a",properties:r,children:e.all(i)};return e.patch(i,s),e.applyData(i,s)},listItem:function(e,i,r){let s=e.all(i),n=r?function(e){let i=!1;if("list"===e.type){i=e.spread||!1;let r=e.children,s=-1;for(;!i&&++s<r.length;)i=ia(r[s])}return i}(r):ia(i),o={},l=[];if("boolean"==typeof i.checked){let e,r=s[0];r&&"element"===r.type&&"p"===r.tagName?e=r:(e={type:"element",tagName:"p",properties:{},children:[]},s.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:i.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let a=-1;for(;++a<s.length;){let e=s[a];(n||0!==a||"element"!==e.type||"p"!==e.tagName)&&l.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||n?l.push(e):l.push(...e.children)}let h=s[s.length-1];h&&(n||"element"!==h.type||"p"!==h.tagName)&&l.push({type:"text",value:"\n"});let c={type:"element",tagName:"li",properties:o,children:l};return e.patch(i,c),e.applyData(i,c)},list:function(e,i){let r={},s=e.all(i),n=-1;for("number"==typeof i.start&&1!==i.start&&(r.start=i.start);++n<s.length;){let e=s[n];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){r.className=["contains-task-list"];break}}let o={type:"element",tagName:i.ordered?"ol":"ul",properties:r,children:e.wrap(s,!0)};return e.patch(i,o),e.applyData(i,o)},paragraph:function(e,i){let r={type:"element",tagName:"p",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},root:function(e,i){let r={type:"root",children:e.wrap(e.all(i))};return e.patch(i,r),e.applyData(i,r)},strong:function(e,i){let r={type:"element",tagName:"strong",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},table:function(e,i){let r=e.all(i),s=r.shift(),n=[];if(s){let r={type:"element",tagName:"thead",properties:{},children:e.wrap([s],!0)};e.patch(i.children[0],r),n.push(r)}if(r.length>0){let s={type:"element",tagName:"tbody",properties:{},children:e.wrap(r,!0)},o=eg(i.children[1]),l=em(i.children[i.children.length-1]);o&&l&&(s.position={start:o,end:l}),n.push(s)}let o={type:"element",tagName:"table",properties:{},children:e.wrap(n,!0)};return e.patch(i,o),e.applyData(i,o)},tableCell:function(e,i){let r={type:"element",tagName:"td",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},tableRow:function(e,i,r){let s=r?r.children:void 0,n=0===(s?s.indexOf(i):1)?"th":"td",o=r&&"table"===r.type?r.align:void 0,l=o?o.length:i.children.length,a=-1,h=[];for(;++a<l;){let r=i.children[a],s={},l=o?o[a]:void 0;l&&(s.align=l);let c={type:"element",tagName:n,properties:s,children:[]};r&&(c.children=e.all(r),e.patch(r,c),c=e.applyData(r,c)),h.push(c)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(i,c),e.applyData(i,c)},text:function(e,i){let r={type:"text",value:function(e){let i=String(e),r=/\r?\n|\r/g,s=r.exec(i),n=0,o=[];for(;s;)o.push(ih(i.slice(n,s.index),n>0,!0),s[0]),n=s.index+s[0].length,s=r.exec(i);return o.push(ih(i.slice(n),n>0,!1)),o.join("")}(String(i.value))};return e.patch(i,r),e.applyData(i,r)},thematicBreak:function(e,i){let r={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(i,r),e.applyData(i,r)},toml:id,yaml:id,definition:id,footnoteDefinition:id};function id(){}let iu={}.hasOwnProperty,ip={};function i_(e,i){e.position&&(i.position=function(e){let i=eg(e),r=em(e);if(i&&r)return{start:i,end:r}}(e))}function im(e,i){let r=i;if(e&&e.data){let i=e.data.hName,s=e.data.hChildren,n=e.data.hProperties;"string"==typeof i&&("element"===r.type?r.tagName=i:r={type:"element",tagName:i,properties:{},children:"children"in r?r.children:[r]}),"element"===r.type&&n&&Object.assign(r.properties,t9(n)),"children"in r&&r.children&&null!=s&&(r.children=s)}return r}function ig(e,i){let r=[],s=-1;for(i&&r.push({type:"text",value:"\n"});++s<e.length;)s&&r.push({type:"text",value:"\n"}),r.push(e[s]);return i&&e.length>0&&r.push({type:"text",value:"\n"}),r}function iv(e){let i=0,r=e.charCodeAt(i);for(;9===r||32===r;)i++,r=e.charCodeAt(i);return e.slice(i)}function ix(e,i){let r,s,n,o,l=(r=i||ip,s=new Map,n=new Map,o={all:function(e){let i=[];if("children"in e){let r=e.children,s=-1;for(;++s<r.length;){let n=o.one(r[s],e);if(n){if(s&&"break"===r[s-1].type&&(Array.isArray(n)||"text"!==n.type||(n.value=iv(n.value)),!Array.isArray(n)&&"element"===n.type)){let e=n.children[0];e&&"text"===e.type&&(e.value=iv(e.value))}Array.isArray(n)?i.push(...n):i.push(n)}}}return i},applyData:im,definitionById:s,footnoteById:n,footnoteCounts:new Map,footnoteOrder:[],handlers:{...ic,...r.handlers},one:function(e,i){let r=e.type,s=o.handlers[r];if(iu.call(o.handlers,r)&&s)return s(o,e,i);if(o.options.passThrough&&o.options.passThrough.includes(r)){if("children"in e){let{children:i,...r}=e,s=t9(r);return s.children=o.all(e),s}return t9(e)}return(o.options.unknownHandler||function(e,i){let r=i.data||{},s="value"in i&&!(iu.call(r,"hProperties")||iu.call(r,"hChildren"))?{type:"text",value:i.value}:{type:"element",tagName:"div",properties:{},children:e.all(i)};return e.patch(i,s),e.applyData(i,s)})(o,e,i)},options:r,patch:i_,wrap:ig},io(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let i="definition"===e.type?s:n,r=String(e.identifier).toUpperCase();i.has(r)||i.set(r,e)}}),o),a=l.one(e,void 0),h=function(e){let i="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",r=e.options.footnoteBackContent||t7,s=e.options.footnoteBackLabel||ie,n=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",l=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[],h=-1;for(;++h<e.footnoteOrder.length;){let n=e.footnoteById.get(e.footnoteOrder[h]);if(!n)continue;let o=e.all(n),l=String(n.identifier).toUpperCase(),c=t8(l.toLowerCase()),d=0,u=[],f=e.footnoteCounts.get(l);for(;void 0!==f&&++d<=f;){u.length>0&&u.push({type:"text",value:" "});let e="string"==typeof r?r:r(h,d);"string"==typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+i+"fnref-"+c+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof s?s:s(h,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let p=o[o.length-1];if(p&&"element"===p.type&&"p"===p.tagName){let e=p.children[p.children.length-1];e&&"text"===e.type?e.value+=" ":p.children.push({type:"text",value:" "}),p.children.push(...u)}else o.push(...u);let _={type:"element",tagName:"li",properties:{id:i+"fn-"+c},children:e.wrap(o,!0)};e.patch(n,_),a.push(_)}if(0!==a.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...t9(l),id:"footnote-label"},children:[{type:"text",value:n}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:"\n"}]}}(l),c=Array.isArray(a)?{type:"root",children:a}:a||{type:"root",children:[]};return h&&(R("children"in c),c.children.push({type:"text",value:"\n"},h)),c}function ib(e,i){return e&&"run"in e?async function(r,s){let n=ix(r,{file:s,...i});await e.run(n,s)}:function(r,s){return ix(r,{file:s,...e||i})}}function iy(e){if(e)throw e}var iS=e.i(4100);function iw(e){if("object"!=typeof e||null===e)return!1;let i=Object.getPrototypeOf(e);return(null===i||i===Object.prototype||null===Object.getPrototypeOf(i))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let iC=function(e,i){let r;if(void 0!==i&&"string"!=typeof i)throw TypeError('"ext" argument must be a string');iR(e);let s=0,n=-1,o=e.length;if(void 0===i||0===i.length||i.length>e.length){for(;o--;)if(47===e.codePointAt(o)){if(r){s=o+1;break}}else n<0&&(r=!0,n=o+1);return n<0?"":e.slice(s,n)}if(i===e)return"";let l=-1,a=i.length-1;for(;o--;)if(47===e.codePointAt(o)){if(r){s=o+1;break}}else l<0&&(r=!0,l=o+1),a>-1&&(e.codePointAt(o)===i.codePointAt(a--)?a<0&&(n=o):(a=-1,n=l));return s===n?n=l:n<0&&(n=e.length),e.slice(s,n)},ik=function(e){let i;if(iR(e),0===e.length)return".";let r=-1,s=e.length;for(;--s;)if(47===e.codePointAt(s)){if(i){r=s;break}}else i||(i=!0);return r<0?47===e.codePointAt(0)?"/":".":1===r&&47===e.codePointAt(0)?"//":e.slice(0,r)},iE=function(e){let i;iR(e);let r=e.length,s=-1,n=0,o=-1,l=0;for(;r--;){let a=e.codePointAt(r);if(47===a){if(i){n=r+1;break}continue}s<0&&(i=!0,s=r+1),46===a?o<0?o=r:1!==l&&(l=1):o>-1&&(l=-1)}return o<0||s<0||0===l||1===l&&o===s-1&&o===n+1?"":e.slice(o,s)},iN=function(...e){var i;let r,s,n,o=-1;for(;++o<e.length;)iR(e[o]),e[o]&&(n=void 0===n?e[o]:n+"/"+e[o]);return void 0===n?".":(iR(i=n),r=47===i.codePointAt(0),0!==(s=function(e,i){let r,s,n="",o=0,l=-1,a=0,h=-1;for(;++h<=e.length;){if(h<e.length)r=e.codePointAt(h);else if(47===r)break;else r=47;if(47===r){if(l===h-1||1===a);else if(l!==h-1&&2===a){if(n.length<2||2!==o||46!==n.codePointAt(n.length-1)||46!==n.codePointAt(n.length-2)){if(n.length>2){if((s=n.lastIndexOf("/"))!==n.length-1){s<0?(n="",o=0):o=(n=n.slice(0,s)).length-1-n.lastIndexOf("/"),l=h,a=0;continue}}else if(n.length>0){n="",o=0,l=h,a=0;continue}}i&&(n=n.length>0?n+"/..":"..",o=2)}else n.length>0?n+="/"+e.slice(l+1,h):n=e.slice(l+1,h),o=h-l-1;l=h,a=0}else 46===r&&a>-1?a++:a=-1}return n}(i,!r)).length||r||(s="."),s.length>0&&47===i.codePointAt(i.length-1)&&(s+="/"),r?"/"+s:s)};function iR(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function iD(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let iM=["history","path","basename","stem","extname","dirname"];class iT{constructor(e){let i,r;i=e?iD(e)?{path:e}:"string"==typeof e||function(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in i?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<iM.length;){const e=iM[s];e in i&&void 0!==i[e]&&null!==i[e]&&(this[e]="history"===e?[...i[e]]:i[e])}for(r in i)iM.includes(r)||(this[r]=i[r])}get basename(){return"string"==typeof this.path?iC(this.path):void 0}set basename(e){ij(e,"basename"),iP(e,"basename"),this.path=iN(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?ik(this.path):void 0}set dirname(e){iB(this.basename,"dirname"),this.path=iN(e||"",this.basename)}get extname(){return"string"==typeof this.path?iE(this.path):void 0}set extname(e){if(iP(e,"extname"),iB(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=iN(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){iD(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!iD(e)){let i=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw i.code="ERR_INVALID_ARG_TYPE",i}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let i=e.pathname,r=-1;for(;++r<i.length;)if(37===i.codePointAt(r)&&50===i.codePointAt(r+1)){let e=i.codePointAt(r+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(i)}(e)}(e)),ij(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?iC(this.path,this.extname):void 0}set stem(e){ij(e,"stem"),iP(e,"stem"),this.path=iN(this.dirname||"",e+(this.extname||""))}fail(e,i,r){let s=this.message(e,i,r);throw s.fatal=!0,s}info(e,i,r){let s=this.message(e,i,r);return s.fatal=void 0,s}message(e,i,r){let s=new ew(e,i,r);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function iP(e,i){if(e&&e.includes("/"))throw Error("`"+i+"` cannot be a path: did not expect `/`")}function ij(e,i){if(!e)throw Error("`"+i+"` cannot be empty")}function iB(e,i){if(!e)throw Error("Setting `"+i+"` requires `path` to be set too")}let iL=function(e){let i=this.constructor.prototype,r=i[e],s=function(){return r.apply(s,arguments)};return Object.setPrototypeOf(s,i),s},iA={}.hasOwnProperty;class iI extends iL{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){let e=[],i={run:function(...i){let r=-1,s=i.pop();if("function"!=typeof s)throw TypeError("Expected function as last argument, not "+s);!function n(o,...l){let a=e[++r],h=-1;if(o)return void s(o);for(;++h<i.length;)(null===l[h]||void 0===l[h])&&(l[h]=i[h]);i=l,a?(function(e,i){let r;return function(...i){let o,l=e.length>i.length;l&&i.push(s);try{o=e.apply(this,i)}catch(e){if(l&&r)throw e;return s(e)}l||(o&&o.then&&"function"==typeof o.then?o.then(n,s):o instanceof Error?s(o):n(o))};function s(e,...n){r||(r=!0,i(e,...n))}function n(e){s(null,e)}})(a,n)(...l):s(null,...l)}(null,...i)},use:function(r){if("function"!=typeof r)throw TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),i}};return i}()}copy(){let e=new iI,i=-1;for(;++i<this.attachers.length;){let r=this.attachers[i];e.use(...r)}return e.data((0,iS.default)(!0,{},this.namespace)),e}data(e,i){return"string"==typeof e?2==arguments.length?(iF("data",this.frozen),this.namespace[e]=i,this):iA.call(this.namespace,e)&&this.namespace[e]||void 0:e?(iF("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...i]=this.attachers[this.freezeIndex];if(!1===i[0])continue;!0===i[0]&&(i[0]=void 0);let r=e.call(this,...i);"function"==typeof r&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let i=iU(e),r=this.parser||this.Parser;return iz("parse",r),r(String(i),i)}process(e,i){let r=this;return this.freeze(),iz("process",this.parser||this.Parser),iH("process",this.compiler||this.Compiler),i?s(void 0,i):new Promise(s);function s(s,n){let o=iU(e),l=r.parse(o);function a(e,r){e||!r?n(e):s?s(r):(R(i,"`done` is defined if `resolve` is not"),i(void 0,r))}r.run(l,o,function(e,i,s){var n,o;if(e||!i||!s)return a(e);let l=r.stringify(i,s);"string"==typeof(n=l)||(o=n)&&"object"==typeof o&&"byteLength"in o&&"byteOffset"in o?s.value=l:s.result=l,a(e,s)})}}processSync(e){let i,r=!1;return this.freeze(),iz("processSync",this.parser||this.Parser),iH("processSync",this.compiler||this.Compiler),this.process(e,function(e,s){r=!0,iy(e),i=s}),i$("processSync","process",r),R(i,"we either bailed on an error or have a tree"),i}run(e,i,r){iW(e),this.freeze();let s=this.transformers;return r||"function"!=typeof i||(r=i,i=void 0),r?n(void 0,r):new Promise(n);function n(n,o){R("function"!=typeof i,"`file` can’t be a `done` anymore, we checked");let l=iU(i);s.run(e,l,function(i,s,l){let a=s||e;i?o(i):n?n(a):(R(r,"`done` is defined if `resolve` is not"),r(void 0,a,l))})}}runSync(e,i){let r,s=!1;return this.run(e,i,function(e,i){iy(e),r=i,s=!0}),i$("runSync","run",s),R(r,"we either bailed on an error or have a tree"),r}stringify(e,i){this.freeze();let r=iU(i),s=this.compiler||this.Compiler;return iH("stringify",s),iW(e),s(e,r)}use(e,...i){let r=this.attachers,s=this.namespace;if(iF("use",this.frozen),null==e);else if("function"==typeof e)l(e,i);else if("object"==typeof e)Array.isArray(e)?o(e):n(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function n(e){if(!("plugins"in e)&&!("settings"in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(s.settings=(0,iS.default)(!0,s.settings,e.settings))}function o(e){let i=-1;if(null==e);else if(Array.isArray(e))for(;++i<e.length;)!function(e){if("function"==typeof e)l(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[i,...r]=e;l(i,r)}else n(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[i]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function l(e,i){let s=-1,n=-1;for(;++s<r.length;)if(r[s][0]===e){n=s;break}if(-1===n)r.push([e,...i]);else if(i.length>0){let[s,...o]=i,l=r[n][1];iw(l)&&iw(s)&&(s=(0,iS.default)(!0,l,s)),r[n]=[e,s,...o]}}}}let iO=new iI().freeze();function iz(e,i){if("function"!=typeof i)throw TypeError("Cannot `"+e+"` without `parser`")}function iH(e,i){if("function"!=typeof i)throw TypeError("Cannot `"+e+"` without `compiler`")}function iF(e,i){if(i)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function iW(e){if(!iw(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function i$(e,i,r){if(!r)throw Error("`"+e+"` finished async. Use `"+i+"` instead")}function iU(e){var i;return(i=e)&&"object"==typeof i&&"message"in i&&"messages"in i?e:new iT(e)}let iK=[],iq={allowDangerousHtml:!0},iV=/^(https?|ircs?|mailto|xmpp)$/i,iY=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function iG(e){var i;let r,s,n,o,l,a=(r=(i=e).rehypePlugins||iK,s=i.remarkPlugins||iK,n=i.remarkRehypeOptions?{...i.remarkRehypeOptions,...iq}:iq,iO().use(tZ).use(s).use(ib,n).use(r)),h=(o=e.children||"",l=new iT,"string"==typeof o?l.value=o:D("Unexpected value `"+o+"` for `children` prop, expected `string`"),l);return function(e,i){let r=i.allowedElements,s=i.allowElement,n=i.components,o=i.disallowedElements,l=i.skipHtml,a=i.unwrapDisallowed,h=i.urlTransform||iX;for(let e of iY)Object.hasOwn(i,e.from)&&D("Unexpected `"+e.from+"` prop, "+(e.to?"use `"+e.to+"` instead":"remove it")+" (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#"+e.id+"> for more info)");return r&&o&&D("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),io(e,function(e,i,n){if("raw"===e.type&&n&&"number"==typeof i)return l?n.children.splice(i,1):n.children[i]={type:"text",value:e.value},i;if("element"===e.type){let i;for(i in eI)if(Object.hasOwn(eI,i)&&Object.hasOwn(e.properties,i)){let r=e.properties[i],s=eI[i];(null===s||s.includes(e.tagName))&&(e.properties[i]=h(String(r||""),i,e))}}if("element"===e.type){let l=r?!r.includes(e.tagName):!!o&&o.includes(e.tagName);if(!l&&s&&"number"==typeof i&&(l=!s(e,i,n)),l&&n&&"number"==typeof i)return a&&e.children?n.children.splice(i,1,...e.children):n.children.splice(i,1),i}}),function(e,i){var r,s,n,o;let l;if(!i||void 0===i.Fragment)throw TypeError("Expected `Fragment` in options");let a=i.filePath||void 0;if(i.development){if("function"!=typeof i.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=a,s=i.jsxDEV,l=function(e,i,n,o){let l=Array.isArray(n.children),a=eg(e);return s(i,n,o,l,{columnNumber:a?a.column-1:void 0,fileName:r,lineNumber:a?a.line:void 0},void 0)}}else{if("function"!=typeof i.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof i.jsxs)throw TypeError("Expected `jsxs` in production options");n=i.jsx,o=i.jsxs,l=function(e,i,r,s){let l=Array.isArray(r.children)?o:n;return s?l(i,r,s):l(i,r)}}let h={Fragment:i.Fragment,ancestors:[],components:i.components||{},create:l,elementAttributeNameCase:i.elementAttributeNameCase||"react",evaluater:i.createEvaluater?i.createEvaluater():void 0,filePath:a,ignoreInvalidStyle:i.ignoreInvalidStyle||!1,passKeys:!1!==i.passKeys,passNode:i.passNode||!1,schema:"svg"===i.space?ep:ef,stylePropertyNameCase:i.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==i.tableCellAlignToStyle},c=eM(h,e,void 0);return c&&"string"!=typeof c?c:h.create(e,h.Fragment,{children:c||void 0},void 0)}(e,{Fragment:p.Fragment,components:n,ignoreInvalidStyle:!0,jsx:p.jsx,jsxs:p.jsxs,passKeys:!0,passNode:!0})}(a.runSync(a.parse(h),h),e)}function iX(e){let i=e.indexOf(":"),r=e.indexOf("?"),s=e.indexOf("#"),n=e.indexOf("/");return -1===i||-1!==n&&i>n||-1!==r&&i>r||-1!==s&&i>s||iV.test(e.slice(0,i))?e:""}function iJ({projectId:e,startInEditMode:i=!1}){let[r,s]=(0,_.useState)(""),[n,o]=(0,_.useState)(null),[l,a]=(0,_.useState)(i),[h,c]=(0,_.useState)(""),[d,u]=(0,_.useState)(!1),[f,m]=(0,_.useState)(null),g=(0,_.useRef)(!1);g.current=l;let v=(0,_.useRef)(i),x=(0,_.useCallback)(async()=>{try{let i=await fetch(`/api/queue?project=${encodeURIComponent(e)}`);if(!i.ok)throw Error(`${i.status}`);let r=await i.json();o(!!r.exists),g.current||s(r.content||""),v.current&&(c(r.content||""),v.current=!1),m(null)}catch(e){m(e.message)}},[e]);(0,_.useEffect)(()=>{x();let e=setInterval(x,1e4);return()=>clearInterval(e)},[x]);let b=async()=>{u(!0),m(null);try{let i=await fetch(`/api/queue?project=${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:h})});if(!i.ok)throw Error(`${i.status}`);s(h),a(!1)}catch(e){m(e.message)}finally{u(!1)}},y=async()=>{u(!0);try{let i=await fetch(`/api/queue?project=${encodeURIComponent(e)}`,{method:"POST"});if(!i.ok)throw Error(`${i.status}`);await x()}catch(e){m(e.message)}finally{u(!1)}};return(0,p.jsxs)("div",{className:"flex flex-col h-full min-h-0 border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:"OVERNIGHT-QUEUE.md"}),(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[f&&(0,p.jsxs)("span",{className:"text-[10px] text-error",children:["err: ",f]}),!l&&n&&(0,p.jsx)("button",{onClick:()=>{c(r),a(!0)},className:"text-[10px] text-text-muted hover:text-accent uppercase tracking-wider",children:"Edit"}),l&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("button",{onClick:b,disabled:d,className:"text-[10px] text-accent hover:text-accent-dim uppercase tracking-wider disabled:opacity-50",children:d?"Saving…":"Save"}),(0,p.jsx)("button",{onClick:()=>{a(!1),c(""),x()},disabled:d,className:"text-[10px] text-text-muted hover:text-text uppercase tracking-wider disabled:opacity-50",children:"Cancel"})]})]})]}),l&&(0,p.jsx)("div",{className:"shrink-0 px-3 py-1.5 border-b border-border bg-bg-surface text-[10px] text-text-muted leading-snug",children:"⚠️ Editing manually may conflict with the Head agent. Use the chat panel to ask Head to update the queue when possible."}),(0,p.jsx)("div",{className:"flex-1 min-h-0 overflow-auto",children:!1===n?(0,p.jsxs)("div",{className:"p-3 text-[11px] text-text-muted",children:[(0,p.jsx)("p",{className:"mb-2",children:"No OVERNIGHT-QUEUE.md for this project yet."}),(0,p.jsx)("button",{onClick:y,disabled:d,className:"px-2 py-1 border border-border hover:border-accent hover:text-accent text-[11px] disabled:opacity-50",children:"Create OVERNIGHT-QUEUE.md from template"})]}):l?(0,p.jsx)("textarea",{value:h,onChange:e=>c(e.target.value),spellCheck:!1,className:"w-full h-full p-3 bg-bg text-text text-[11px] font-mono resize-none outline-none"}):(0,p.jsx)("div",{className:"p-3 text-[12px] text-text prose prose-invert prose-sm max-w-none [&_h1]:text-[14px] [&_h1]:font-semibold [&_h1]:mt-3 [&_h1]:mb-2 [&_h2]:text-[13px] [&_h2]:font-semibold [&_h2]:mt-3 [&_h2]:mb-1.5 [&_h3]:text-[12px] [&_h3]:font-semibold [&_h3]:mt-2 [&_h3]:mb-1 [&_p]:my-1.5 [&_ul]:my-1.5 [&_ul]:pl-4 [&_ul]:list-disc [&_ol]:my-1.5 [&_ol]:pl-4 [&_ol]:list-decimal [&_li]:my-0.5 [&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-2 [&_blockquote]:text-text-muted [&_hr]:my-3 [&_hr]:border-border [&_code]:bg-bg-surface [&_code]:px-1 [&_code]:rounded [&_code]:text-[11px] [&_strong]:text-text [&_a]:text-accent [&_a]:underline",children:(0,p.jsx)(iG,{children:r})})})]})}function iQ({open:e,projectId:i,onClose:r}){return((0,_.useEffect)(()=>{if(!e)return;let i=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e,r]),e)?(0,p.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:r,role:"dialog","aria-modal":"true","aria-labelledby":"queue-modal-title",children:(0,p.jsxs)("div",{className:"relative mx-4 w-full max-w-3xl h-[80vh] flex flex-col rounded-lg border border-white/10 bg-neutral-950 shadow-2xl overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,p.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-white/10",children:[(0,p.jsx)("h2",{id:"queue-modal-title",className:"text-[12px] font-semibold text-white",children:"OVERNIGHT-QUEUE.md"}),(0,p.jsx)("button",{type:"button",onClick:r,"aria-label":"Close",className:"rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,p.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,p.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})})]}),(0,p.jsx)("div",{className:"flex-1 min-h-0",children:(0,p.jsx)(iJ,{projectId:i,startInEditMode:!0})})]})}):null}function iZ({percent:e}){let i=Math.round(e/100*20);return(0,p.jsxs)("span",{className:"font-mono text-[11px] tabular-nums whitespace-nowrap",children:[(0,p.jsx)("span",{className:"text-accent",children:"█".repeat(i)}),(0,p.jsx)("span",{className:"text-text-muted",children:"░".repeat(20-i)})]})}function i0({projectId:e}){let[i,r]=(0,_.useState)(null),s=(0,_.useCallback)(()=>{fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{e&&r(e)}).catch(()=>{})},[e]);return((0,_.useEffect)(()=>{s();let e=setInterval(s,3e4);return()=>clearInterval(e)},[s]),i)?i.items&&0!==i.items.length?i.complete?(0,p.jsxs)("div",{className:"border-t border-border",children:[(0,p.jsxs)("div",{className:"px-3 py-1.5 flex items-center gap-2",children:[(0,p.jsxs)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:["Current Batch: Batch ",i.batch_number??"—"]}),(0,p.jsx)("span",{className:"text-[10px] text-accent",children:"✅ COMPLETE"})]}),(0,p.jsxs)("div",{className:"px-3 pb-2 text-[11px] text-text-muted",children:["All ",i.items.length," items merged. Waiting for the next batch."]})]}):(0,p.jsxs)("div",{className:"border-t border-border",children:[(0,p.jsxs)("div",{className:"px-3 py-1.5 flex items-center gap-2 border-b border-border/40",children:[(0,p.jsxs)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:["Current Batch: Batch ",i.batch_number??"—"]}),(0,p.jsxs)("span",{className:"text-[10px] text-text-muted",children:["(",i.items.length," items)"]}),(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Current Batch"}),"— progress tracker for the active batch. Polls GitHub to resolve each issue's status (queued → in review → approved → merged)."]})]}),(0,p.jsx)("div",{className:"max-h-40 overflow-y-auto",children:i.items.map(e=>{let i=(0,p.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1 font-mono",children:[(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0 tabular-nums",children:["#",e.issue_number]}),(0,p.jsx)(iZ,{percent:e.progress}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted tabular-nums shrink-0 w-9 text-right",children:[e.progress,"%"]}),(0,p.jsx)("span",{className:"text-[11px] text-text truncate flex-1 min-w-0",children:e.label})]});return e.url?(0,p.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"block hover:bg-[#1a1a1a] transition-colors border-b border-border/30",children:i},e.issue_number):(0,p.jsx)("div",{children:i},e.issue_number)})}),i.summary&&(0,p.jsx)("div",{className:"px-3 py-1.5 text-[11px] text-text-muted border-t border-border/40",children:i.summary})]}):(0,p.jsxs)("div",{className:"border-t border-border",children:[(0,p.jsx)("div",{className:"px-3 py-1.5 flex items-center gap-2",children:(0,p.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:"Current Batch: (none)"})}),(0,p.jsx)("div",{className:"px-3 pb-2 text-[11px] text-text-muted",children:"No active batch. Ask Head to start one via the chat."})]}):(0,p.jsx)("div",{className:"px-3 py-1.5 text-[11px] text-text-muted border-t border-border",children:"Loading batch progress…"})}function i1({color:e}){return(0,p.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full shrink-0 ${e}`})}function i2({projectId:e}){let[i,r]=(0,_.useState)([]),[s,n]=(0,_.useState)([]),[o,l]=(0,_.useState)([]),[a,h]=(0,_.useState)([]),[c,d]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let i=!1;return fetch(`/api/queue?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(r=>{if(!i&&r&&!r.exists)return fetch(`/api/queue?project=${encodeURIComponent(e)}`,{method:"POST"})}).catch(()=>{}),()=>{i=!0}},[e]);let u=(0,_.useCallback)(()=>{fetch(`/api/github/issues?project=${encodeURIComponent(e)}`).then(e=>{if(!e.ok)throw Error(`${e.status}`);return e.json()}).then(e=>{Array.isArray(e)&&r(e)}).catch(()=>{}),fetch(`/api/github/prs?project=${encodeURIComponent(e)}`).then(e=>{if(!e.ok)throw Error(`${e.status}`);return e.json()}).then(e=>{Array.isArray(e)&&n(e)}).catch(()=>{}),fetch(`/api/github/closed-issues?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{Array.isArray(e)&&l(e)}).catch(()=>{}),fetch(`/api/github/merged-prs?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{Array.isArray(e)&&h(e)}).catch(()=>{})},[e]);return(0,_.useEffect)(()=>{u();let e=setInterval(u,3e4);return()=>clearInterval(e)},[u]),(0,p.jsxs)("div",{className:"flex flex-col h-full min-h-0",children:[(0,p.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,p.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col border-r border-border",children:[(0,p.jsxs)("div",{className:"px-3 py-1.5 border-b border-border shrink-0 flex items-center gap-1.5",children:[(0,p.jsxs)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:["Issues (",i.length,")"]}),(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Issues"}),"— open issues on the project's GitHub repo. Click any item to open it on GitHub."]})]}),(0,p.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[0===i.length&&(0,p.jsx)("div",{className:"px-3 py-2 text-[11px] text-text-muted",children:"No issues"}),i.map(e=>(0,p.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono hover:bg-[#1a1a1a] transition-colors cursor-pointer border-b border-border/50",children:[(0,p.jsx)(i1,{color:"OPEN"===e.state?"bg-accent":"bg-error"}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,p.jsx)("span",{className:"text-[11px] text-text truncate flex-1 min-w-0",children:e.title}),e.assignees?.[0]&&(0,p.jsx)("span",{className:"text-[10px] text-text-muted shrink-0",children:e.assignees[0].login})]},e.number)),(0,p.jsx)("div",{className:"px-3 pt-2 pb-1 text-[9px] text-text-muted uppercase tracking-wider",children:"Recently closed"}),0===o.length&&(0,p.jsx)("div",{className:"px-3 py-1 text-[11px] text-text-muted",children:"None yet"}),o.map(e=>(0,p.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono opacity-60 hover:opacity-100 hover:bg-[#1a1a1a] transition-all cursor-pointer border-b border-border/30",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted shrink-0",children:"✓"}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,p.jsx)("span",{className:"text-[11px] text-text-muted truncate flex-1 min-w-0",children:e.title})]},`closed-${e.number}`))]})]}),(0,p.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col",children:[(0,p.jsxs)("div",{className:"px-3 py-1.5 border-b border-border shrink-0 flex items-center gap-1.5",children:[(0,p.jsxs)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:["Pull Requests (",s.length,")"]}),(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Pull Requests"})," — open PRs awaiting review or merge. Click to open on GitHub."]})]}),(0,p.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[0===s.length&&(0,p.jsx)("div",{className:"px-3 py-2 text-[11px] text-text-muted",children:"No PRs"}),s.map(e=>{let i=e.reviews||[],r=e.reviewDecision||"REVIEW_REQUIRED",s={};for(let e of i){let i=(e.body||"").trim();/^(?:RE2|Reviewer2|T2b)\b/i.test(i)?s.re2=e.state:(/^(?:RE1|Reviewer1|T2a)\b/i.test(i)||/^##\s*Verdict/i.test(i))&&(s.re1=e.state)}return(0,p.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono hover:bg-[#1a1a1a] transition-colors cursor-pointer border-b border-border/50",children:[(0,p.jsx)(i1,{color:"APPROVED"===r?"bg-accent":"CHANGES_REQUESTED"===r?"bg-error":"bg-[#ffcc00]"}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,p.jsx)("span",{className:"text-[11px] text-text truncate flex-1 min-w-0",children:e.title}),e.assignees?.[0]&&(0,p.jsx)("span",{className:"text-[10px] text-text-muted shrink-0",children:e.assignees[0].login}),["re1","re2"].map(e=>{let i=s[e];return(0,p.jsxs)("span",{className:`text-[10px] shrink-0 ${i?"APPROVED"===i?"text-accent":"CHANGES_REQUESTED"===i?"text-error":"text-[#ffcc00]":"text-text-muted"}`,children:[e,":",i?"APPROVED"===i?"ok":"CHANGES_REQUESTED"===i?"chg":"rev":"—"]},e)}),(0,p.jsx)("span",{className:`text-[10px] shrink-0 ${function(e){if(!e||0===e.length)return"text-text-muted";let i=e.map(e=>e.state);return i.every(e=>"SUCCESS"===e)?"text-accent":i.some(e=>"FAILURE"===e||"ERROR"===e)?"text-error":"text-[#ffcc00]"}(e.statusCheckRollup)}`,children:function(e){if(!e||0===e.length)return"—";let i=e.map(e=>e.state);return i.every(e=>"SUCCESS"===e)?"pass":i.some(e=>"FAILURE"===e||"ERROR"===e)?"fail":"run"}(e.statusCheckRollup)})]},e.number)}),(0,p.jsx)("div",{className:"px-3 pt-2 pb-1 text-[9px] text-text-muted uppercase tracking-wider",children:"Recently merged"}),0===a.length&&(0,p.jsx)("div",{className:"px-3 py-1 text-[11px] text-text-muted",children:"None yet"}),a.map(e=>(0,p.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono opacity-60 hover:opacity-100 hover:bg-[#1a1a1a] transition-all cursor-pointer border-b border-border/30",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted shrink-0",children:"✓"}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,p.jsx)("span",{className:"text-[11px] text-text-muted truncate flex-1 min-w-0",children:e.title})]},`merged-${e.number}`))]})]})]}),(0,p.jsx)("div",{className:"shrink-0",children:(0,p.jsx)(i0,{projectId:e})}),(0,p.jsxs)("div",{className:"shrink-0 flex items-center justify-between px-3 py-1.5 border-t border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted font-mono",children:"OVERNIGHT-QUEUE.md"}),(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Overnight Queue"})," — the task queue file Head reads to pick the next ticket. Click Edit to modify batch contents and ordering."]})]}),(0,p.jsx)("button",{onClick:()=>d(!0),className:"px-2 py-0.5 text-[10px] text-text-muted hover:text-accent border border-border hover:border-accent transition-colors uppercase tracking-wider",children:"Edit"})]}),(0,p.jsx)(iQ,{open:c,projectId:e,onClose:()=>d(!1)})]})}var i5=e.i(67449);function i3({projectId:e}){let[i,r]=(0,_.useState)(null),[s,n]=(0,_.useState)(null),[o,l]=(0,_.useState)(!1),a=()=>{setTimeout(()=>n(null),3e3)};(0,_.useEffect)(()=>{if(!o)return;let e=setTimeout(()=>l(!1),4e3);return()=>clearTimeout(e)},[o]);let h=async()=>{if(!o)return void l(!0);l(!1),r("stop");try{let i=await fetch(`/api/agentchattr/${encodeURIComponent(e)}/stop`,{method:"POST"}),r=await i.json();n(r.ok?"Stopped":"Failed")}catch{n("Error")}r(null),a()},c=async()=>{r("restart");try{let i=await fetch(`/api/agentchattr/${encodeURIComponent(e)}/restart`,{method:"POST"}),r=await i.json();r.ok&&r.pid?n(`Restarted (PID: ${r.pid})`):n(r.error||"Failed to restart")}catch{n("Error")}r(null),a()},d=async()=>{r("reset");try{let i=await fetch(`/api/agents/${encodeURIComponent(e)}/reset`,{method:"POST"}),r=await i.json();n(r.ok?`Reset — ${r.cleared} of ${r.total} slot${1!==r.total?"s":""} deregistered`:"Failed")}catch{n("Error")}r(null),a()};return(0,p.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,p.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider font-semibold",children:"Server"}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,p.jsx)("button",{onClick:h,disabled:!!i,className:`px-1.5 py-0.5 text-[10px] border transition-colors disabled:opacity-50 ${o?"text-error border-error/60 bg-error/10 hover:bg-error/20":"text-text-muted border-border hover:text-error hover:border-error/40"}`,children:"stop"===i?"...":o?"Confirm Stop?":"Stop"}),(0,p.jsx)("button",{onClick:c,disabled:!!i,className:"px-1.5 py-0.5 text-[10px] text-text-muted border border-border hover:text-accent hover:border-accent/40 transition-colors disabled:opacity-50",children:"restart"===i?"...":"Restart"}),(0,p.jsx)("button",{onClick:d,disabled:!!i,className:"px-1.5 py-0.5 text-[10px] text-text-muted border border-border hover:text-accent hover:border-accent/40 transition-colors disabled:opacity-50",children:"reset"===i?"...":"Reset Agents"})]}),s&&(0,p.jsx)("div",{className:"text-[10px] text-accent",children:s})]})}function i4(e){return Number.isFinite(e)?Math.min(Math.max(e,.1),24):3}function i6(e){let i=Math.floor(e/3600),r=Math.floor(e%3600/60);return i>0?`${i}h ${r}m`:`${r}m`}function i9(){let[e,i]=(0,_.useState)(!1),[r,s]=(0,_.useState)(null),[n,o]=(0,_.useState)(""),[l,a]=(0,_.useState)(!1),[h,c]=(0,_.useState)(String(3)),[d,u]=(0,_.useState)(!1),[f,m]=(0,_.useState)(!1),[g,v]=(0,_.useState)(!1),[x,b]=(0,_.useState)(!1),[y,S]=(0,_.useState)(!0),[w,C]=(0,_.useState)("soft-chime"),[k,E]=(0,_.useState)(!0);(0,_.useEffect)(()=>{S((0,i5.getNotificationEnabled)()),C((0,i5.getNotificationChoice)()),E((0,i5.getNotificationBackgroundOnly)())},[]);let N=(0,_.useCallback)(()=>{fetch("/api/caffeinate/status").then(e=>e.ok?e.json():null).then(e=>{e&&(i(e.active),s(e.remaining),o(e.platform))}).catch(()=>{})},[]);(0,_.useEffect)(()=>{N();let e=setInterval(N,5e3);return()=>clearInterval(e)},[N]);let R=e=>{fetch("/api/caffeinate/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({duration:e})}).then(e=>e.json()).then(r=>{r.ok&&(i(!0),s(e||null))}).catch(()=>{}),a(!1)},D=!n||"darwin"===n;return(0,p.jsxs)("div",{className:"flex flex-col md:flex-row md:items-start gap-2 md:gap-6 relative",children:[D&&(0,p.jsxs)("div",{className:"flex flex-col gap-0.5 relative",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-text-muted uppercase tracking-wider font-semibold",children:[(0,p.jsx)("span",{children:"Keep Mac Awake"}),(0,p.jsx)("button",{type:"button","aria-label":"About Keep Mac Awake",onClick:()=>v(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"})]}),g&&(0,p.jsxs)("div",{className:"absolute left-0 top-4 z-30 w-64 p-2 text-[10px] leading-snug text-text bg-bg-surface border border-border rounded shadow-lg",children:[(0,p.jsx)("b",{children:"Keep Mac Awake"})," runs macOS ",(0,p.jsx)("code",{children:"caffeinate"})," to stop the screen, disk, and system idle timers from sleeping your Mac during an overnight run. Make sure the laptop is plugged in — caffeinate blocks sleep but not battery drain."]}),(0,p.jsx)("div",{className:"text-[10px] text-text-muted leading-tight",children:e&&null!==r&&r>0?`Awake for ${i6(r)} more — keep Mac plugged in`:e&&null===r?"Awake indefinitely — keep Mac plugged in":"Prevents your Mac from sleeping during overnight runs."}),(0,p.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap mt-0.5",children:(0,p.jsxs)("button",{onClick:()=>e?void fetch("/api/caffeinate/stop",{method:"POST"}).then(()=>{i(!1),s(null)}).catch(()=>{}):a(!l),title:"Keep Mac awake (caffeinate)",className:`px-1.5 py-0.5 text-[10px] border transition-colors ${e?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:[e?"Awake":"Start",e&&null!==r&&r>0&&(0,p.jsx)("span",{className:"ml-1 text-accent/70",children:i6(r)}),e&&null===r&&(0,p.jsx)("span",{className:"ml-1 text-accent/70",children:"on"})]})})]}),D&&(0,p.jsx)("div",{className:"border-t border-border/40 md:border-t-0 md:w-px md:h-auto md:self-stretch md:bg-border"}),(0,p.jsxs)("div",{className:"flex flex-col gap-0.5 relative",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-text-muted uppercase tracking-wider font-semibold",children:[(0,p.jsx)("span",{children:"Notification Sound"}),(0,p.jsx)("button",{type:"button","aria-label":"About Notification Sound",onClick:()=>b(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"})]}),x&&(0,p.jsxs)("div",{className:"absolute left-0 top-4 z-30 w-64 p-2 text-[10px] leading-snug text-text bg-bg-surface border border-border rounded shadow-lg",children:[(0,p.jsx)("b",{children:"Notification Sound"}),"plays a brief chime when an agent posts a new message (not your own sends, not system events). Sound choice picks one of the bundled chimes. Background-only mode suppresses the chime while the tab is focused — ding only when you're looking elsewhere. All prefs persist in localStorage."]}),(0,p.jsx)("div",{className:"text-[10px] text-text-muted leading-tight",children:"Plays a chime when an agent posts a new message."}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap mt-0.5",children:[(0,p.jsxs)("button",{type:"button",onClick:()=>{let e=!y;S(e),(0,i5.setNotificationEnabled)(e)},title:y?"Notification sound on (click to mute)":"Notification sound off (click to unmute)",className:`px-1.5 py-0.5 text-[10px] border transition-colors ${y?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:[y?"🔔":"🔕"," Sound"]}),y&&(0,p.jsx)("select",{value:w,onChange:e=>(e=>{if(C(e),(0,i5.setNotificationChoice)(e),y)try{let i=new Audio(`/sounds/${e}.mp3`);i.volume=.6,i.play().catch(()=>{})}catch{}})(e.target.value),title:"Notification sound",className:"bg-transparent border border-border px-1 py-0.5 text-[10px] text-text outline-none focus:border-accent cursor-pointer",children:i5.NOTIFICATION_SOUND_OPTIONS.map(e=>(0,p.jsx)("option",{value:e.value,className:"bg-bg-surface",children:e.label},e.value))})]}),y&&(0,p.jsxs)("label",{className:"flex items-center gap-1 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,p.jsx)("input",{type:"checkbox",checked:k,onChange:e=>{var i;E(i=e.target.checked),(0,i5.setNotificationBackgroundOnly)(i)}}),"Only when tab is in background"]})]}),l&&!e&&(0,p.jsxs)("div",{className:"absolute bottom-full left-0 mb-1 p-2 border border-border bg-bg-surface z-20 min-w-[220px] flex flex-col gap-1.5",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between",children:[(0,p.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:"Keep Awake"}),(0,p.jsx)("button",{type:"button","aria-label":"About Keep Awake",onClick:()=>m(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"})]}),f&&(0,p.jsxs)("div",{className:"p-1.5 text-[10px] leading-snug text-text bg-bg border border-border/60 rounded",children:[(0,p.jsx)("b",{children:"Keep Awake"})," prevents your Mac from sleeping for the duration you set. Use this when you want agents to keep working overnight.",(0,p.jsx)("br",{}),(0,p.jsx)("br",{}),"Under the hood, this runs macOS's ",(0,p.jsx)("code",{children:"caffeinate"})," command. While it's active your screen, disk, and system idle timers are all paused — make sure your Mac is ",(0,p.jsx)("b",{children:"plugged in"})," to avoid draining the battery."]}),(0,p.jsx)("p",{className:"text-[10px] text-[#ffcc00]",children:"Make sure Mac is plugged in"}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px]",children:[(0,p.jsx)("span",{className:"text-text-muted",children:"for"}),(0,p.jsx)("input",{type:"number",value:h,onChange:e=>c(e.target.value),onBlur:()=>{let e=parseFloat(h);c(String(Math.round(10*(Number.isFinite(e)?i4(e):3))/10))},disabled:d,min:.1,max:24,step:.1,className:"w-14 bg-transparent border border-border px-1 py-0.5 text-text outline-none focus:border-accent text-center disabled:opacity-40"}),(0,p.jsx)("span",{className:"text-text-muted",children:"hours"})]}),(0,p.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,p.jsx)("input",{type:"checkbox",checked:d,onChange:e=>u(e.target.checked)}),"Until stopped (no expiry)"]}),(0,p.jsx)("button",{type:"button",onClick:()=>{if(d)return void R(0);let e=parseFloat(h);R(Math.round(3600*(Number.isFinite(e)?i4(e):3)))},className:"self-start px-2 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors",children:"Start"})]})]})}function i8({projectId:e}){return(0,p.jsx)("div",{className:"border-t border-border px-3 py-2",children:(0,p.jsxs)("div",{className:"flex flex-col md:flex-row md:items-start gap-2 md:gap-6",children:[(0,p.jsx)(i3,{projectId:e}),(0,p.jsx)("div",{className:"border-t border-border/40 md:border-t-0 md:w-px md:h-auto md:self-stretch md:bg-border"}),(0,p.jsx)(i9,{})]})})}var i7=e.i(47167),re=Object.defineProperty,rt=Object.getOwnPropertyDescriptor,ri=(e,i,r,s)=>{for(var n,o=s>1?void 0:s?rt(i,r):i,l=e.length-1;l>=0;l--)(n=e[l])&&(o=(s?n(i,r,o):n(o))||o);return s&&o&&re(i,r,o),o},rr=(e,i)=>(r,s)=>i(r,s,e),rs="Terminal input",rn="Too much output to announce, navigate to rows manually to read";function ro(e,i,r,s){var n;n=e=e.replace(/\r?\n/g,"\r"),e=r.decPrivateModes.bracketedPasteMode&&!0!==s.rawOptions.ignoreBracketedPasteMode?"\x1b[200~"+n+"\x1b[201~":n,r.triggerDataEvent(e,!0),i.value=""}function rl(e,i,r){let s=r.getBoundingClientRect(),n=e.clientX-s.left-10,o=e.clientY-s.top-10;i.style.width="20px",i.style.height="20px",i.style.left=`${n}px`,i.style.top=`${o}px`,i.style.zIndex="1000",i.focus()}function ra(e,i,r,s,n){rl(e,i,r),n&&s.rightClickSelect(e),i.value=s.selectionText,i.select()}function rh(e){return e>65535?String.fromCharCode(((e-=65536)>>10)+55296)+String.fromCharCode(e%1024+56320):String.fromCharCode(e)}function rc(e,i=0,r=e.length){let s="";for(let n=i;n<r;++n){let i=e[n];i>65535?(i-=65536,s+=String.fromCharCode((i>>10)+55296)+String.fromCharCode(i%1024+56320)):s+=String.fromCharCode(i)}return s}var rd=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,i){let r=e.length;if(!r)return 0;let s=0,n=0;if(this._interim){let r=e.charCodeAt(n++);56320<=r&&r<=57343?i[s++]=(this._interim-55296)*1024+r-56320+65536:(i[s++]=this._interim,i[s++]=r),this._interim=0}for(let o=n;o<r;++o){let n=e.charCodeAt(o);if(55296<=n&&n<=56319){if(++o>=r)return this._interim=n,s;let l=e.charCodeAt(o);56320<=l&&l<=57343?i[s++]=(n-55296)*1024+l-56320+65536:(i[s++]=n,i[s++]=l);continue}65279!==n&&(i[s++]=n)}return s}},ru=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,i){let r=e.length;if(!r)return 0;let s=0,n,o,l,a,h=0,c=0;if(this.interim[0]){let n=!1,o=this.interim[0];o&=(224&o)==192?31:(240&o)==224?15:7;let l=0,a;for(;(a=63&this.interim[++l])&&l<4;)o<<=6,o|=a;let h=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,d=h-l;for(;c<d;){if(c>=r)return 0;if((192&(a=e[c++]))!=128){c--,n=!0;break}this.interim[l++]=a,o<<=6,o|=63&a}n||(2===h?o<128?c--:i[s++]=o:3===h?o<2048||o>=55296&&o<=57343||65279===o||(i[s++]=o):o<65536||o>1114111||(i[s++]=o)),this.interim.fill(0)}let d=r-4,u=c;for(;u<r;){for(;u<d&&!(128&(n=e[u]))&&!(128&(o=e[u+1]))&&!(128&(l=e[u+2]))&&!(128&(a=e[u+3]));)i[s++]=n,i[s++]=o,i[s++]=l,i[s++]=a,u+=4;if((n=e[u++])<128)i[s++]=n;else if((224&n)==192){if(u>=r)return this.interim[0]=n,s;if((192&(o=e[u++]))!=128||(h=(31&n)<<6|63&o)<128){u--;continue}i[s++]=h}else if((240&n)==224){if(u>=r)return this.interim[0]=n,s;if((192&(o=e[u++]))!=128){u--;continue}if(u>=r)return this.interim[0]=n,this.interim[1]=o,s;if((192&(l=e[u++]))!=128){u--;continue}if((h=(15&n)<<12|(63&o)<<6|63&l)<2048||h>=55296&&h<=57343||65279===h)continue;i[s++]=h}else if((248&n)==240){if(u>=r)return this.interim[0]=n,s;if((192&(o=e[u++]))!=128){u--;continue}if(u>=r)return this.interim[0]=n,this.interim[1]=o,s;if((192&(l=e[u++]))!=128){u--;continue}if(u>=r)return this.interim[0]=n,this.interim[1]=o,this.interim[2]=l,s;if((192&(a=e[u++]))!=128){u--;continue}if((h=(7&n)<<18|(63&o)<<12|(63&l)<<6|63&a)<65536||h>1114111)continue;i[s++]=h}}return s}},rf=class e{constructor(){this.fg=0,this.bg=0,this.extended=new rp}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let i=new e;return i.fg=this.fg,i.bg=this.bg,i.extended=this.extended.clone(),i}isInverse(){return 0x4000000&this.fg}isBold(){return 0x8000000&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:0x10000000&this.fg}isBlink(){return 0x20000000&this.fg}isInvisible(){return 0x40000000&this.fg}isItalic(){return 0x4000000&this.bg}isDim(){return 0x8000000&this.bg}isStrikethrough(){return 0x80000000&this.fg}isProtected(){return 0x20000000&this.bg}isOverline(){return 0x40000000&this.bg}getFgColorMode(){return 0x3000000&this.fg}getBgColorMode(){return 0x3000000&this.bg}isFgRGB(){return(0x3000000&this.fg)==0x3000000}isBgRGB(){return(0x3000000&this.bg)==0x3000000}isFgPalette(){return(0x3000000&this.fg)==0x1000000||(0x3000000&this.fg)==0x2000000}isBgPalette(){return(0x3000000&this.bg)==0x1000000||(0x3000000&this.bg)==0x2000000}isFgDefault(){return(0x3000000&this.fg)==0}isBgDefault(){return(0x3000000&this.bg)==0}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(0x3000000&this.fg){case 0x1000000:case 0x2000000:return 255&this.fg;case 0x3000000:return 0xffffff&this.fg;default:return -1}}getBgColor(){switch(0x3000000&this.bg){case 0x1000000:case 0x2000000:return 255&this.bg;case 0x3000000:return 0xffffff&this.bg;default:return -1}}hasExtendedAttrs(){return 0x10000000&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-0x10000001:this.bg|=0x10000000}getUnderlineColor(){if(0x10000000&this.bg&&~this.extended.underlineColor)switch(0x3000000&this.extended.underlineColor){case 0x1000000:case 0x2000000:return 255&this.extended.underlineColor;case 0x3000000:return 0xffffff&this.extended.underlineColor}return this.getFgColor()}getUnderlineColorMode(){return 0x10000000&this.bg&&~this.extended.underlineColor?0x3000000&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x3000000:this.isFgRGB()}isUnderlineColorPalette(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x1000000||(0x3000000&this.extended.underlineColor)==0x2000000:this.isFgPalette()}isUnderlineColorDefault(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 0x10000000&this.fg?0x10000000&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},rp=class e{constructor(e=0,i=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=i}get ext(){return this._urlId?-0x1c000001&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(0x1c000000&this._ext)>>26}set underlineStyle(e){this._ext&=-0x1c000001,this._ext|=e<<26&0x1c000000}get underlineColor(){return 0x3ffffff&this._ext}set underlineColor(e){this._ext&=-0x4000000,this._ext|=0x3ffffff&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(0xe0000000&this._ext)>>29;return e<0?0xfffffff8^e:e}set underlineVariantOffset(e){this._ext&=0x1fffffff,this._ext|=e<<29&0xe0000000}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},r_=class e extends rf{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new rp,this.combinedData=""}static fromCharData(i){let r=new e;return r.setFromCharData(i),r}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?rh(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let i=!1;if(e[1].length>2)i=!0;else if(2===e[1].length){let r=e[1].charCodeAt(0);if(55296<=r&&r<=56319){let s=e[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(r-55296)*1024+s-56320+65536|e[2]<<22:i=!0}else i=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;i&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},rm="di$target",rg="di$dependencies",rv=new Map;function rx(e){if(rv.has(e))return rv.get(e);let i=function(e,r,s){var n,o,l;if(3!=arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");n=i,o=e,l=s,o[rm]===o?o[rg].push({id:n,index:l}):(o[rg]=[{id:n,index:l}],o[rm]=o)};return i._id=e,rv.set(e,i),i}var rb=rx("BufferService"),ry=rx("CoreMouseService"),rS=rx("CoreService"),rw=rx("CharsetService"),rC=rx("InstantiationService"),rk=rx("LogService"),rE=rx("OptionsService"),rN=rx("OscLinkService"),rR=rx("UnicodeService"),rD=rx("DecorationService"),rM=class{constructor(e,i,r){this._bufferService=e,this._optionsService=i,this._oscLinkService=r}provideLinks(e,i){let r=this._bufferService.buffer.lines.get(e-1);if(!r)return void i(void 0);let s=[],n=this._optionsService.rawOptions.linkHandler,o=new r_,l=r.getTrimmedLength(),a=-1,h=-1,c=!1;for(let i=0;i<l;i++)if(!(-1===h&&!r.hasContent(i))){if(r.loadCell(i,o),o.hasExtendedAttrs()&&o.extended.urlId)if(-1===h){h=i,a=o.extended.urlId;continue}else c=o.extended.urlId!==a;else -1!==h&&(c=!0);if(c||-1!==h&&i===l-1){let r=this._oscLinkService.getLinkData(a)?.uri;if(r){let o={start:{x:h+1,y:e},end:{x:i+ +(!c&&i===l-1),y:e}},a=!1;if(!n?.allowNonHttpProtocols)try{let e=new URL(r);["http:","https:"].includes(e.protocol)||(a=!0)}catch{a=!0}a||s.push({text:r,range:o,activate:(e,i)=>n?n.activate(e,i,o):function(e){if(confirm(`Do you want to navigate to ${e}?
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,26568,(e,i,r)=>{"use strict";var s=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,o=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,h=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,d=/^\s+|\s+$/g;function u(e){return e?e.replace(d,""):""}i.exports=function(e,i){if("string"!=typeof e)throw TypeError("First argument must be a string");if(!e)return[];i=i||{};var r=1,d=1;function f(e){var i=e.match(n);i&&(r+=i.length);var s=e.lastIndexOf("\n");d=~s?e.length-s:d+e.length}function p(){var e={line:r,column:d};return function(i){return i.position=new _(e),g(o),i}}function _(e){this.start=e,this.end={line:r,column:d},this.source=i.source}function m(s){var n=Error(i.source+":"+r+":"+d+": "+s);if(n.reason=s,n.filename=i.source,n.line=r,n.column=d,n.source=e,i.silent);else throw n}function g(i){var r=i.exec(e);if(r){var s=r[0];return f(s),e=e.slice(s.length),r}}function v(e){var i;for(e=e||[];i=x();)!1!==i&&e.push(i);return e}function x(){var i=p();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var r=2;""!=e.charAt(r)&&("*"!=e.charAt(r)||"/"!=e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return m("End of comment missing");var s=e.slice(2,r-2);return d+=2,f(s),e=e.slice(r),d+=2,i({type:"comment",comment:s})}}_.prototype.content=e,g(o);var b,y=[];for(v(y);b=function(){var e=p(),i=g(l);if(i){if(x(),!g(a))return m("property missing ':'");var r=g(h),n=e({type:"declaration",property:u(i[0].replace(s,"")),value:r?u(r[0].replace(s,"")):""});return g(c),n}}();)!1!==b&&(y.push(b),v(y));return y}},70454,(e,i,r)=>{"use strict";var s=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,i){let r=null;if(!e||"string"!=typeof e)return r;let s=(0,n.default)(e),o="function"==typeof i;return s.forEach(e=>{if("declaration"!==e.type)return;let{property:s,value:n}=e;o?i(s,n,e):n&&((r=r||{})[s]=n)}),r};let n=s(e.r(26568))},65185,(e,i,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.camelCase=void 0;var s=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,o=/^[^-]+$/,l=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,h=function(e,i){return i.toUpperCase()},c=function(e,i){return"".concat(i,"-")};r.camelCase=function(e,i){var r;return(void 0===i&&(i={}),!(r=e)||o.test(r)||s.test(r))?e:(e=e.toLowerCase(),(e=i.reactCompat?e.replace(a,c):e.replace(l,c)).replace(n,h))}},15511,(e,i,r)=>{"use strict";var s=(e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(e.r(70454)),n=e.r(65185);function o(e,i){var r={};return e&&"string"==typeof e&&(0,s.default)(e,function(e,s){e&&s&&(r[(0,n.camelCase)(e,i)]=s)}),r}o.default=o,i.exports=o},4100,(e,i,r)=>{"use strict";var s=Object.prototype.hasOwnProperty,n=Object.prototype.toString,o=Object.defineProperty,l=Object.getOwnPropertyDescriptor,a=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===n.call(e)},h=function(e){if(!e||"[object Object]"!==n.call(e))return!1;var i,r=s.call(e,"constructor"),o=e.constructor&&e.constructor.prototype&&s.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!r&&!o)return!1;for(i in e);return void 0===i||s.call(e,i)},c=function(e,i){o&&"__proto__"===i.name?o(e,i.name,{enumerable:!0,configurable:!0,value:i.newValue,writable:!0}):e[i.name]=i.newValue},d=function(e,i){if("__proto__"===i){if(!s.call(e,i))return;else if(l)return l(e,i).value}return e[i]};i.exports=function e(){var i,r,s,n,o,l,u=arguments[0],f=1,p=arguments.length,_=!1;for("boolean"==typeof u&&(_=u,u=arguments[1]||{},f=2),(null==u||"object"!=typeof u&&"function"!=typeof u)&&(u={});f<p;++f)if(i=arguments[f],null!=i)for(r in i)s=d(u,r),u!==(n=d(i,r))&&(_&&n&&(h(n)||(o=a(n)))?(o?(o=!1,l=s&&a(s)?s:[]):l=s&&h(s)?s:{},c(u,{name:r,newValue:e(_,l,n)})):void 0!==n&&c(u,{name:r,newValue:n}));return u}},55601,e=>{"use strict";let i,r,s,n,o,l,a,h,c,d,u,f;var p=e.i(43476),_=e.i(71645);function m({label:e,status:i,projectId:r,agentId:s,onStatusChange:n,tooltip:o}){let l="running"===i?"bg-accent":"error"===i?"bg-error":"bg-text-muted",a=e=>{r&&s&&fetch(`/api/agents?project=${encodeURIComponent(r)}&agent=${encodeURIComponent(s)}&action=${e}`,{method:"POST"}).then(e=>e.json()).then(e=>{n&&e.state&&n(e.state)}).catch(()=>{})};return(0,p.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 h-7 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[i&&(0,p.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${l}`}),(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:e}),o]}),r&&s&&(0,p.jsxs)("div",{className:"flex items-center gap-1",children:["running"!==i&&(0,p.jsx)("button",{onClick:()=>a("start"),className:"text-[10px] text-text-muted hover:text-accent transition-colors px-1",title:"Start",children:"▶"}),"running"===i&&(0,p.jsx)("button",{onClick:()=>a("stop"),className:"text-[10px] text-text-muted hover:text-error transition-colors px-1",title:"Stop",children:"■"}),(0,p.jsx)("button",{onClick:()=>a("restart"),className:"text-[10px] text-text-muted hover:text-accent transition-colors px-1",title:"Restart",children:"↻"})]})]})}function g({children:e,position:i="below"}){let[r,s]=(0,_.useState)(!1),n=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(!r)return;let e=e=>{n.current&&!n.current.contains(e.target)&&s(!1)},i=e=>{"Escape"===e.key&&s(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",i)}},[r]),(0,p.jsxs)("div",{ref:n,className:"relative inline-flex items-center",children:[(0,p.jsx)("button",{type:"button",onClick:()=>s(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"}),r&&(0,p.jsx)("div",{className:`absolute left-0 z-30 w-64 p-2 text-[10px] leading-snug text-text bg-bg-surface border border-border rounded shadow-lg ${"above"===i?"bottom-5":"top-5"}`,children:e})]})}var v=e.i(78759);let x=["@head start a new feature: <describe>","@head review the latest PR","@head what's our current sprint?"];function b({onInsert:e}){let[i,r]=(0,_.useState)(!1);return(0,p.jsxs)("div",{className:"flex flex-col items-center justify-center text-center px-6 py-10 gap-3",children:[(0,p.jsxs)("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none","aria-hidden":!0,className:"text-accent",children:[(0,p.jsx)("path",{d:"M6 8h28a2 2 0 0 1 2 2v17a2 2 0 0 1-2 2H16l-7 6v-6h-3a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2Z",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),(0,p.jsx)("circle",{cx:"14",cy:"18",r:"1.4",fill:"currentColor"}),(0,p.jsx)("circle",{cx:"20",cy:"18",r:"1.4",fill:"currentColor"}),(0,p.jsx)("circle",{cx:"26",cy:"18",r:"1.4",fill:"currentColor"})]}),(0,p.jsx)("div",{className:"text-[13px] font-semibold text-text",children:"Ready when you are"}),(0,p.jsx)("div",{className:"text-[11px] text-text-muted",children:"Tell your team what to build. Try something like:"}),(0,p.jsx)("div",{className:"flex flex-col gap-1.5 mt-1 w-full max-w-sm",children:x.map(i=>(0,p.jsx)("button",{type:"button",onClick:()=>e(i),className:"text-left px-2 py-1 text-[11px] font-mono text-text-muted border border-border hover:text-accent hover:border-accent transition-colors truncate",children:i},i))}),(0,p.jsx)("button",{type:"button",onClick:()=>r(!0),className:"mt-2 text-[11px] text-text-muted underline underline-offset-2 hover:text-text",children:"How to Work"}),(0,p.jsx)(v.default,{open:i,onClose:()=>r(!1)})]})}let y={head:"#00ff88",re1:"#4488ff",re2:"#cc44ff",dev:"#ffcc00",user:"#e0e0e0",system:"#737373"},S=["head","re1","re2","dev","user"],w=[{command:"/artchallenge",description:"SVG art challenge — all agents create artwork (optional theme)"},{command:"/hatmaking",description:"All agents design a hat to wear on their avatar"},{command:"/roastreview",description:"Get all agents to review and roast each other's work"},{command:"/poetry haiku",description:"Agents write a haiku about the codebase"},{command:"/poetry limerick",description:"Agents write a limerick about the codebase"},{command:"/poetry sonnet",description:"Agents write a sonnet about the codebase"},{command:"/summary",description:"Summarize recent messages — tag an agent (e.g. /summary @head)"},{command:"/continue",description:"Resume after loop guard pauses"},{command:"/clear",description:"Clear messages in current channel"}];function C(e){return y[e.toLowerCase()]||"#e0e0e0"}let k=/(^|\s)(@(?:head|dev|re1|re2|user))(?![\w-])/gi;function E({projectId:e}){return(0,p.jsx)(N,{projectId:e})}function N({projectId:e}){let i="general",[r,s]=(0,_.useState)([]),[n,o]=(0,_.useState)(!1),[l,a]=(0,_.useState)(""),[h,c]=(0,_.useState)(!1),[d,u]=(0,_.useState)(""),[f,m]=(0,_.useState)(!1),[g,v]=(0,_.useState)(0),[x,y]=(0,_.useState)(null),[E,R]=(0,_.useState)(null),D=(0,_.useRef)(0),M=(0,_.useRef)(null),T=(0,_.useRef)(null),P=(0,_.useRef)(!1),j=(0,_.useRef)(!0),B=(0,_.useRef)(0);(0,_.useEffect)(()=>{D.current=0,s([]),o(!1)},[e]);let L=(0,_.useCallback)(()=>{fetch(`/api/chat?path=/api/messages&channel=${encodeURIComponent(i)}&cursor=${D.current}${e?`&project=${encodeURIComponent(e)}`:""}`).then(e=>{if(403===e.status)throw B.current<3?y(null):y("Chat authentication failed (403). Set agentchattr_token in Settings or ~/.quadwork/config.json."),Error("auth failed");if(!e.ok)throw Error(`Poll failed: ${e.status}`);return e.json()}).then(e=>{y(null);let i=Array.isArray(e)?e:e.messages||[];if(i.length>0){s(e=>{let r=new Set(e.map(e=>e.id)),s=i.filter(e=>!r.has(e.id));return s.length>0?[...e,...s]:e});let e=Math.max(...i.map(e=>e.id));e>D.current&&(D.current=e)}}).catch(()=>{}).finally(()=>{o(!0)})},[i,e]);(0,_.useEffect)(()=>{L();let e=setInterval(L,3e3);return()=>clearInterval(e)},[L]),(0,_.useEffect)(()=>{j.current&&M.current&&(M.current.scrollTop=M.current.scrollHeight)},[r]);let[A,I]=(0,_.useState)(!1),[O,z]=(0,_.useState)(null);(0,_.useEffect)(()=>{let e=T.current;e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,120)+"px")},[l]);let H=()=>{let r=l.trim();if(!r||A)return;let s=r.startsWith("/")||/^@(head|dev|re1|re2)\b/i.test(r)?r:`@head ${r}`;I(!0),z(null),fetch(`/api/chat${e?`?project=${encodeURIComponent(e)}`:""}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:s,channel:i,sender:"user",...E?{reply_to:E.id}:{}})}).then(e=>{if(!e.ok)throw Error(`Send failed: ${e.status}`);a(""),R(null),setTimeout(L,300)}).catch(e=>{z(e.message),console.error(e.message)}).finally(()=>I(!1))},F=e=>{a(l.replace(/@\w*$/,`@${e} `)),c(!1),T.current?.focus()},W=e=>{a(e.includes(" ")?e:`${e} `),m(!1),T.current?.focus()},$=S.filter(e=>e.toLowerCase().startsWith(d)),U=w.filter(e=>e.command.toLowerCase().startsWith(l.toLowerCase()));return(0,p.jsxs)("div",{className:"flex flex-col h-full bg-bg",children:[x&&(0,p.jsx)("div",{className:"px-3 py-2 bg-red-900/30 border-b border-red-700/50 text-[11px] text-red-400",children:x}),(0,p.jsxs)("div",{ref:M,onScroll:()=>{if(!M.current)return;let{scrollTop:e,scrollHeight:i,clientHeight:r}=M.current;j.current=i-e-r<40},className:"flex-1 min-h-0 overflow-y-auto px-3 py-2 space-y-0.5",children:[!n&&0===r.length&&(0,p.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,p.jsx)("span",{className:"text-xs text-text-muted",children:"Loading messages..."})}),n&&0===r.length&&(0,p.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,p.jsx)(b,{onInsert:e=>{a(e),T.current?.focus()}})}),r.map(e=>{var i;let r;return(0,p.jsxs)("div",{className:"group flex gap-2 text-[12px] leading-5",children:[(0,p.jsx)("span",{className:"text-text-muted shrink-0 w-12 text-right tabular-nums",children:e.time?.slice(0,5)||""}),(0,p.jsx)("span",{className:"shrink-0 font-semibold w-10 text-right",style:{color:C(e.sender)},children:"re1"===(r=(i=e.sender).toLowerCase())?"RE1":"re2"===r?"RE2":i}),(0,p.jsx)("span",{className:"text-text break-words min-w-0 whitespace-pre-wrap flex-1",children:function(e){let i=[],r=0,s=0;for(let n of e.matchAll(k)){let o=n.index??0,l=n[1],a=n[2],h=o+l.length;h>r&&i.push(e.slice(r,h));let c=C(a.slice(1).toLowerCase());i.push((0,p.jsx)("span",{className:"inline-block px-1 py-0 rounded font-mono",style:{backgroundColor:`${c}22`,color:c},children:a},`m${s++}`)),r=h+a.length}return r<e.length&&i.push(e.slice(r)),i.length>0?i:[e]}(e.text)}),(0,p.jsx)("button",{type:"button",onClick:()=>{if(R({id:e.id,sender:e.sender}),new Set(["head","dev","re1","re2"]).has(e.sender.toLowerCase())){let i=`@${e.sender} `;a(e=>e.startsWith(i)?e:i)}T.current?.focus()},className:"shrink-0 self-start opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity text-[10px] text-text-muted hover:text-text px-1 py-0.5 border border-border/50 rounded",title:`Reply to message #${e.id}`,children:"reply"})]},e.id)})]}),(0,p.jsxs)("div",{className:"relative shrink-0 border-t border-border",children:[h&&$.length>0&&(0,p.jsx)("div",{className:"absolute bottom-full left-0 right-0 border border-border bg-bg-surface",children:$.map(e=>(0,p.jsxs)("button",{onClick:()=>F(e),className:"w-full text-left px-3 py-1 text-[12px] hover:bg-[#1a1a1a] transition-colors",style:{color:C(e)},children:["@",e]},e))}),f&&U.length>0&&(0,p.jsx)("div",{className:"absolute bottom-full left-0 right-0 max-h-60 overflow-y-auto border border-border bg-bg-surface z-10",children:U.map((e,i)=>{let r=i===Math.min(g,U.length-1);return(0,p.jsxs)("button",{onClick:()=>W(e.command),onMouseEnter:()=>v(i),className:`w-full text-left px-3 py-1 transition-colors flex items-baseline gap-2 ${r?"bg-[#1a1a1a]":"hover:bg-[#1a1a1a]"}`,children:[(0,p.jsx)("span",{className:"text-[12px] text-accent font-mono",children:e.command}),(0,p.jsx)("span",{className:"text-[10px] text-text-muted truncate",children:e.description})]},e.command)})}),O&&(0,p.jsx)("div",{className:"px-3 py-1 text-[11px] text-red-400 bg-red-900/20 border-b border-red-700/40",children:O}),E&&(0,p.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1 text-[11px] text-text-muted bg-bg-surface border-b border-border/50",children:[(0,p.jsxs)("span",{children:["Replying to ",(0,p.jsxs)("span",{style:{color:C(E.sender)},children:["@",E.sender]})," #",E.id]}),(0,p.jsx)("button",{type:"button",onClick:()=>R(null),className:"ml-auto hover:text-text",title:"Cancel reply (Esc)",children:"✕"})]}),(0,p.jsxs)("div",{className:"flex items-end gap-1 px-1",children:[(0,p.jsx)("textarea",{ref:T,rows:1,value:l,onChange:e=>(e=>{a(e);let i=e.match(/@(\w*)$/);if(i){c(!0),u(i[1].toLowerCase()),m(!1);return}if(c(!1),e.startsWith("/")){let i=e.slice(1).includes(" "),r=e.startsWith("/poetry");m(!i||r),v(0)}else m(!1)})(e.target.value),onCompositionStart:()=>{P.current=!0},onCompositionEnd:()=>{P.current=!1},onKeyDown:e=>{if("Tab"===e.key&&h&&$.length>0){e.preventDefault(),F($[0]);return}if(f&&U.length>0){if("ArrowDown"===e.key){e.preventDefault(),v(e=>(e+1)%U.length);return}if("ArrowUp"===e.key){e.preventDefault(),v(e=>(e-1+U.length)%U.length);return}if("Tab"===e.key||"Enter"===e.key&&!e.shiftKey){e.preventDefault();let i=Math.min(g,U.length-1);W(U[i].command);return}}"Enter"!==e.key||e.shiftKey||P.current||e.nativeEvent.isComposing||(e.preventDefault(),H()),"Escape"===e.key&&(c(!1),m(!1),E&&R(null))},placeholder:`Message #${i}...`,disabled:A,className:"flex-1 bg-transparent px-2 py-2 text-[12px] font-mono text-text placeholder:text-text-muted outline-none focus:ring-1 focus:ring-accent disabled:opacity-50 resize-none overflow-y-auto leading-snug",style:{maxHeight:120}}),(0,p.jsx)("button",{onClick:H,disabled:A||!l.trim(),className:"shrink-0 px-2 py-1 text-[11px] font-mono text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:"Send (Enter)",children:A?"…":"Send"})]})]})]})}function R(){}function D(){}let M=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,T=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,P={};function j(e,i){return((i||P).jsx?T:M).test(e)}let B=/[ \t\n\f\r]/g;function L(e){return""===e.replace(B,"")}class A{constructor(e,i){this.attribute=i,this.property=e}}A.prototype.attribute="",A.prototype.booleanish=!1,A.prototype.boolean=!1,A.prototype.commaOrSpaceSeparated=!1,A.prototype.commaSeparated=!1,A.prototype.defined=!1,A.prototype.mustUseProperty=!1,A.prototype.number=!1,A.prototype.overloadedBoolean=!1,A.prototype.property="",A.prototype.spaceSeparated=!1,A.prototype.space=void 0;let I=0,O=K(),z=K(),H=K(),F=K(),W=K(),$=K(),U=K();function K(){return 2**++I}e.s(["boolean",0,O,"booleanish",0,z,"commaOrSpaceSeparated",0,U,"commaSeparated",0,$,"number",0,F,"overloadedBoolean",0,H,"spaceSeparated",0,W],744);var q=e.i(744);let V=Object.keys(q);class Y extends A{constructor(e,i,r,s){let n=-1;if(super(e,i),function(e,i,r){r&&(e[i]=r)}(this,"space",s),"number"==typeof r)for(;++n<V.length;){const e=V[n];!function(e,i,r){r&&(e[i]=r)}(this,V[n],(r&q[e])===q[e])}}}function G(e){return e.toLowerCase()}Y.prototype.defined=!0;let X=/[A-Z]/g,J=/-[a-z]/g,Q=/^data[-\w.:]+$/i;function Z(e){return"-"+e.toLowerCase()}function ee(e){return e.charAt(1).toUpperCase()}let et={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};class ei{constructor(e,i,r){this.normal=i,this.property=e,r&&(this.space=r)}}function er(e,i){let r={},s={};for(let i of e)Object.assign(r,i.property),Object.assign(s,i.normal);return new ei(r,s,i)}function es(e){let i={},r={};for(let[s,n]of Object.entries(e.properties)){let o=new Y(s,e.transform(e.attributes||{},s),n,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(o.mustUseProperty=!0),i[s]=o,r[G(s)]=s,r[G(o.attribute)]=s}return new ei(i,r,e.space)}ei.prototype.normal={},ei.prototype.property={},ei.prototype.space=void 0;let en=es({properties:{ariaActiveDescendant:null,ariaAtomic:z,ariaAutoComplete:null,ariaBusy:z,ariaChecked:z,ariaColCount:F,ariaColIndex:F,ariaColSpan:F,ariaControls:W,ariaCurrent:null,ariaDescribedBy:W,ariaDetails:null,ariaDisabled:z,ariaDropEffect:W,ariaErrorMessage:null,ariaExpanded:z,ariaFlowTo:W,ariaGrabbed:z,ariaHasPopup:null,ariaHidden:z,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:W,ariaLevel:F,ariaLive:null,ariaModal:z,ariaMultiLine:z,ariaMultiSelectable:z,ariaOrientation:null,ariaOwns:W,ariaPlaceholder:null,ariaPosInSet:F,ariaPressed:z,ariaReadOnly:z,ariaRelevant:null,ariaRequired:z,ariaRoleDescription:W,ariaRowCount:F,ariaRowIndex:F,ariaRowSpan:F,ariaSelected:z,ariaSetSize:F,ariaSort:null,ariaValueMax:F,ariaValueMin:F,ariaValueNow:F,ariaValueText:null,role:null},transform:(e,i)=>"role"===i?i:"aria-"+i.slice(4).toLowerCase()});function eo(e,i){return i in e?e[i]:i}function el(e,i){return eo(e,i.toLowerCase())}let ea=es({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:$,acceptCharset:W,accessKey:W,action:null,allow:null,allowFullScreen:O,allowPaymentRequest:O,allowUserMedia:O,alt:null,as:null,async:O,autoCapitalize:null,autoComplete:W,autoFocus:O,autoPlay:O,blocking:W,capture:null,charSet:null,checked:O,cite:null,className:W,cols:F,colSpan:null,content:null,contentEditable:z,controls:O,controlsList:W,coords:F|$,crossOrigin:null,data:null,dateTime:null,decoding:null,default:O,defer:O,dir:null,dirName:null,disabled:O,download:H,draggable:z,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:O,formTarget:null,headers:W,height:F,hidden:H,high:F,href:null,hrefLang:null,htmlFor:W,httpEquiv:W,id:null,imageSizes:null,imageSrcSet:null,inert:O,inputMode:null,integrity:null,is:null,isMap:O,itemId:null,itemProp:W,itemRef:W,itemScope:O,itemType:W,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:O,low:F,manifest:null,max:null,maxLength:F,media:null,method:null,min:null,minLength:F,multiple:O,muted:O,name:null,nonce:null,noModule:O,noValidate:O,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:O,optimum:F,pattern:null,ping:W,placeholder:null,playsInline:O,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:O,referrerPolicy:null,rel:W,required:O,reversed:O,rows:F,rowSpan:F,sandbox:W,scope:null,scoped:O,seamless:O,selected:O,shadowRootClonable:O,shadowRootDelegatesFocus:O,shadowRootMode:null,shape:null,size:F,sizes:null,slot:null,span:F,spellCheck:z,src:null,srcDoc:null,srcLang:null,srcSet:null,start:F,step:null,style:null,tabIndex:F,target:null,title:null,translate:null,type:null,typeMustMatch:O,useMap:null,value:z,width:F,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:W,axis:null,background:null,bgColor:null,border:F,borderColor:null,bottomMargin:F,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:O,declare:O,event:null,face:null,frame:null,frameBorder:null,hSpace:F,leftMargin:F,link:null,longDesc:null,lowSrc:null,marginHeight:F,marginWidth:F,noResize:O,noHref:O,noShade:O,noWrap:O,object:null,profile:null,prompt:null,rev:null,rightMargin:F,rules:null,scheme:null,scrolling:z,standby:null,summary:null,text:null,topMargin:F,valueType:null,version:null,vAlign:null,vLink:null,vSpace:F,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:O,disableRemotePlayback:O,prefix:null,property:null,results:F,security:null,unselectable:null},space:"html",transform:el}),eh=es({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:U,accentHeight:F,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:F,amplitude:F,arabicForm:null,ascent:F,attributeName:null,attributeType:null,azimuth:F,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:F,by:null,calcMode:null,capHeight:F,className:W,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:F,diffuseConstant:F,direction:null,display:null,dur:null,divisor:F,dominantBaseline:null,download:O,dx:null,dy:null,edgeMode:null,editable:null,elevation:F,enableBackground:null,end:null,event:null,exponent:F,externalResourcesRequired:null,fill:null,fillOpacity:F,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:$,g2:$,glyphName:$,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:F,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:F,horizOriginX:F,horizOriginY:F,id:null,ideographic:F,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:F,k:F,k1:F,k2:F,k3:F,k4:F,kernelMatrix:U,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:F,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:F,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:F,overlineThickness:F,paintOrder:null,panose1:null,path:null,pathLength:F,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:W,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:F,pointsAtY:F,pointsAtZ:F,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:U,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:U,rev:U,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:U,requiredFeatures:U,requiredFonts:U,requiredFormats:U,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:F,specularExponent:F,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:F,strikethroughThickness:F,string:null,stroke:null,strokeDashArray:U,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:F,strokeOpacity:F,strokeWidth:null,style:null,surfaceScale:F,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:U,tabIndex:F,tableValues:null,target:null,targetX:F,targetY:F,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:U,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:F,underlineThickness:F,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:F,values:null,vAlphabetic:F,vMathematical:F,vectorEffect:null,vHanging:F,vIdeographic:F,version:null,vertAdvY:F,vertOriginX:F,vertOriginY:F,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:F,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:eo}),ec=es({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,i)=>"xlink:"+i.slice(5).toLowerCase()}),ed=es({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:el}),eu=es({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,i)=>"xml:"+i.slice(3).toLowerCase()}),ef=er([en,ea,ec,ed,eu],"html"),ep=er([en,eh,ec,ed,eu],"svg");var e_=e.i(15511);let em=ev("end"),eg=ev("start");function ev(e){return function(i){let r=i&&i.position&&i.position[e]||{};if("number"==typeof r.line&&r.line>0&&"number"==typeof r.column&&r.column>0)return{line:r.line,column:r.column,offset:"number"==typeof r.offset&&r.offset>-1?r.offset:void 0}}}function ex(e){return e&&"object"==typeof e?"position"in e||"type"in e?ey(e.position):"start"in e||"end"in e?ey(e):"line"in e||"column"in e?eb(e):"":""}function eb(e){return eS(e&&e.line)+":"+eS(e&&e.column)}function ey(e){return eb(e&&e.start)+"-"+eb(e&&e.end)}function eS(e){return e&&"number"==typeof e?e:1}class ew extends Error{constructor(e,i,r){super(),"string"==typeof i&&(r=i,i=void 0);let s="",n={},o=!1;if(i&&(n="line"in i&&"column"in i||"start"in i&&"end"in i?{place:i}:"type"in i?{ancestors:[i],place:i.position}:{...i}),"string"==typeof e?s=e:!n.cause&&e&&(o=!0,s=e.message,n.cause=e),!n.ruleId&&!n.source&&"string"==typeof r){const e=r.indexOf(":");-1===e?n.ruleId=r:(n.source=r.slice(0,e),n.ruleId=r.slice(e+1))}if(!n.place&&n.ancestors&&n.ancestors){const e=n.ancestors[n.ancestors.length-1];e&&(n.place=e.position)}const l=n.place&&"start"in n.place?n.place.start:n.place;this.ancestors=n.ancestors||void 0,this.cause=n.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=l?l.line:void 0,this.name=ex(n.place)||"1:1",this.place=n.place||void 0,this.reason=this.message,this.ruleId=n.ruleId||void 0,this.source=n.source||void 0,this.stack=o&&n.cause&&"string"==typeof n.cause.stack?n.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ew.prototype.file="",ew.prototype.name="",ew.prototype.reason="",ew.prototype.message="",ew.prototype.stack="",ew.prototype.column=void 0,ew.prototype.line=void 0,ew.prototype.ancestors=void 0,ew.prototype.cause=void 0,ew.prototype.fatal=void 0,ew.prototype.place=void 0,ew.prototype.ruleId=void 0,ew.prototype.source=void 0;let eC={}.hasOwnProperty,ek=new Map,eE=/[A-Z]/g,eN=new Set(["table","tbody","thead","tfoot","tr"]),eR=new Set(["td","th"]),eD="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function eM(e,i,r){var s,n,o,l,a,h,c,d,u;let f,p,_,m,g,v,x,b,y,S,w;return"element"===i.type?(s=e,n=i,o=r,p=f=s.schema,"svg"===n.tagName.toLowerCase()&&"html"===f.space&&(s.schema=ep),s.ancestors.push(n),_=eB(s,n.tagName,!1),m=function(e,i){let r,s,n={};for(s in i.properties)if("children"!==s&&eC.call(i.properties,s)){let o=function(e,i,r){let s=function(e,i){let r=G(i),s=i,n=A;if(r in e.normal)return e.property[e.normal[r]];if(r.length>4&&"data"===r.slice(0,4)&&Q.test(i)){if("-"===i.charAt(4)){let e=i.slice(5).replace(J,ee);s="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=i.slice(4);if(!J.test(e)){let r=e.replace(X,Z);"-"!==r.charAt(0)&&(r="-"+r),i="data"+r}}n=Y}return new n(s,i)}(e.schema,i);if(!(null==r||"number"==typeof r&&Number.isNaN(r))){var n;let i;if(Array.isArray(r)&&(r=s.commaSeparated?(i={},(""===(n=r)[n.length-1]?[...n,""]:n).join((i.padRight?" ":"")+","+(!1===i.padLeft?"":" ")).trim()):r.join(" ").trim()),"style"===s.property){let i="object"==typeof r?r:function(e,i){try{return(0,e_.default)(i,{reactCompat:!0})}catch(r){if(e.ignoreInvalidStyle)return{};let i=new ew("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=eD+"#cannot-parse-style-attribute",i}}(e,String(r));return"css"===e.stylePropertyNameCase&&(i=function(e){let i,r={};for(i in e)eC.call(e,i)&&(r[function(e){let i=e.replace(eE,eA);return"ms-"===i.slice(0,3)&&(i="-"+i),i}(i)]=e[i]);return r}(i)),["style",i]}return["react"===e.elementAttributeNameCase&&s.space?et[s.property]||s.property:s.attribute,r]}}(e,s,i.properties[s]);if(o){let[s,l]=o;e.tableCellAlignToStyle&&"align"===s&&"string"==typeof l&&eR.has(i.tagName)?r=l:n[s]=l}}return r&&((n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=r),n}(s,n),g=ej(s,n),eN.has(n.tagName)&&(g=g.filter(function(e){return"string"!=typeof e||!("object"==typeof e?"text"===e.type&&L(e.value):L(e))})),eT(s,m,_,n),eP(m,g),s.ancestors.pop(),s.schema=f,s.create(n,_,m,o)):"mdxFlowExpression"===i.type||"mdxTextExpression"===i.type?function(e,i){if(i.data&&i.data.estree&&e.evaluater){let r=i.data.estree.body[0];return R("ExpressionStatement"===r.type),e.evaluater.evaluateExpression(r.expression)}eL(e,i.position)}(e,i):"mdxJsxFlowElement"===i.type||"mdxJsxTextElement"===i.type?(l=e,a=i,h=r,x=v=l.schema,"svg"===a.name&&"html"===v.space&&(l.schema=ep),l.ancestors.push(a),b=null===a.name?l.Fragment:eB(l,a.name,!0),y=function(e,i){let r={};for(let s of i.attributes)if("mdxJsxExpressionAttribute"===s.type)if(s.data&&s.data.estree&&e.evaluater){let i=s.data.estree.body[0];R("ExpressionStatement"===i.type);let n=i.expression;R("ObjectExpression"===n.type);let o=n.properties[0];R("SpreadElement"===o.type),Object.assign(r,e.evaluater.evaluateExpression(o.argument))}else eL(e,i.position);else{let n,o=s.name;if(s.value&&"object"==typeof s.value)if(s.value.data&&s.value.data.estree&&e.evaluater){let i=s.value.data.estree.body[0];R("ExpressionStatement"===i.type),n=e.evaluater.evaluateExpression(i.expression)}else eL(e,i.position);else n=null===s.value||s.value;r[o]=n}return r}(l,a),S=ej(l,a),eT(l,y,b,a),eP(y,S),l.ancestors.pop(),l.schema=v,l.create(a,b,y,h)):"mdxjsEsm"===i.type?function(e,i){if(i.data&&i.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(i.data.estree);eL(e,i.position)}(e,i):"root"===i.type?(c=e,d=i,u=r,eP(w={},ej(c,d)),c.create(d,c.Fragment,w,u)):"text"===i.type?i.value:void 0}function eT(e,i,r,s){"string"!=typeof r&&r!==e.Fragment&&e.passNode&&(i.node=s)}function eP(e,i){if(i.length>0){let r=i.length>1?i:i[0];r&&(e.children=r)}}function ej(e,i){let r=[],s=-1,n=e.passKeys?new Map:ek;for(;++s<i.children.length;){let o,l=i.children[s];if(e.passKeys){let e="element"===l.type?l.tagName:"mdxJsxFlowElement"===l.type||"mdxJsxTextElement"===l.type?l.name:void 0;if(e){let i=n.get(e)||0;o=e+"-"+i,n.set(e,i+1)}}let a=eM(e,l,o);void 0!==a&&r.push(a)}return r}function eB(e,i,r){let s;if(r)if(i.includes(".")){let e,r=i.split("."),n=-1;for(;++n<r.length;){let i=j(r[n])?{type:"Identifier",name:r[n]}:{type:"Literal",value:r[n]};e=e?{type:"MemberExpression",object:e,property:i,computed:!!(n&&"Literal"===i.type),optional:!1}:i}R(e,"always a result"),s=e}else s=j(i)&&!/^[a-z]/.test(i)?{type:"Identifier",name:i}:{type:"Literal",value:i};else s={type:"Literal",value:i};if("Literal"===s.type){let i=s.value;return eC.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(s);eL(e)}function eL(e,i){let r=new ew("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:i,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=eD+"#cannot-handle-mdx-estrees-without-createevaluater",r}function eA(e){return"-"+e.toLowerCase()}let eI={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},eO={};function ez(e,i,r){var s;if((s=e)&&"object"==typeof s){if("value"in e)return"html"!==e.type||r?e.value:"";if(i&&"alt"in e&&e.alt)return e.alt;if("children"in e)return eH(e.children,i,r)}return Array.isArray(e)?eH(e,i,r):""}function eH(e,i,r){let s=[],n=-1;for(;++n<e.length;)s[n]=ez(e[n],i,r);return s.join("")}function eF(e,i,r,s){let n,o=e.length,l=0;if(i=i<0?-i>o?0:o+i:i>o?o:i,r=r>0?r:0,s.length<1e4)(n=Array.from(s)).unshift(i,r),e.splice(...n);else for(r&&e.splice(i,r);l<s.length;)(n=s.slice(l,l+1e4)).unshift(i,0),e.splice(...n),l+=1e4,i+=1e4}function eW(e,i){return e.length>0?(eF(e,e.length,0,i),e):i}let e$={}.hasOwnProperty,eU=e2(/[A-Za-z]/),eK=e2(/[\dA-Za-z]/),eq=e2(/[#-'*+\--9=?A-Z^-~]/);function eV(e){return null!==e&&(e<32||127===e)}let eY=e2(/\d/),eG=e2(/[\dA-Fa-f]/),eX=e2(/[!-/:-@[-`{-~]/);function eJ(e){return null!==e&&e<-2}function eQ(e){return null!==e&&(e<0||32===e)}function eZ(e){return -2===e||-1===e||32===e}let e0=e2(/\p{P}|\p{S}/u),e1=e2(/\s/);function e2(e){return function(i){return null!==i&&i>-1&&e.test(String.fromCharCode(i))}}function e5(e,i,r,s){let n=s?s-1:1/0,o=0;return function(s){return eZ(s)?(e.enter(r),function s(l){return eZ(l)&&o++<n?(e.consume(l),s):(e.exit(r),i(l))}(s)):i(s)}}let e3={tokenize:function(e){let i,r=e.attempt(this.parser.constructs.contentInitial,function(i){return null===i?void e.consume(i):(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e5(e,r,"linePrefix"))},function(r){return e.enter("paragraph"),function r(s){let n=e.enter("chunkText",{contentType:"text",previous:i});return i&&(i.next=n),i=n,function i(s){if(null===s){e.exit("chunkText"),e.exit("paragraph"),e.consume(s);return}return eJ(s)?(e.consume(s),e.exit("chunkText"),r):(e.consume(s),i)}(s)}(r)});return r}},e4={tokenize:function(e){let i,r,s,n=this,o=[],l=0;return a;function a(i){if(l<o.length){let r=o[l];return n.containerState=r[1],e.attempt(r[0].continuation,h,c)(i)}return c(i)}function h(e){if(l++,n.containerState._closeFlow){let r;n.containerState._closeFlow=void 0,i&&v();let s=n.events.length,o=s;for(;o--;)if("exit"===n.events[o][0]&&"chunkFlow"===n.events[o][1].type){r=n.events[o][1].end;break}g(l);let a=s;for(;a<n.events.length;)n.events[a][1].end={...r},a++;return eF(n.events,o+1,0,n.events.slice(s)),n.events.length=a,c(e)}return a(e)}function c(r){if(l===o.length){if(!i)return f(r);if(i.currentConstruct&&i.currentConstruct.concrete)return _(r);n.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(e6,d,u)(r)}function d(e){return i&&v(),g(l),f(e)}function u(e){return n.parser.lazy[n.now().line]=l!==o.length,s=n.now().offset,_(e)}function f(i){return n.containerState={},e.attempt(e6,p,_)(i)}function p(e){return l++,o.push([n.currentConstruct,n.containerState]),f(e)}function _(s){if(null===s){i&&v(),g(0),e.consume(s);return}return i=i||n.parser.flow(n.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:r}),function i(r){if(null===r){m(e.exit("chunkFlow"),!0),g(0),e.consume(r);return}return eJ(r)?(e.consume(r),m(e.exit("chunkFlow")),l=0,n.interrupt=void 0,a):(e.consume(r),i)}(s)}function m(e,o){let a=n.sliceStream(e);if(o&&a.push(null),e.previous=r,r&&(r.next=e),r=e,i.defineSkip(e.start),i.write(a),n.parser.lazy[e.start.line]){let e,r,o=i.events.length;for(;o--;)if(i.events[o][1].start.offset<s&&(!i.events[o][1].end||i.events[o][1].end.offset>s))return;let a=n.events.length,h=a;for(;h--;)if("exit"===n.events[h][0]&&"chunkFlow"===n.events[h][1].type){if(e){r=n.events[h][1].end;break}e=!0}for(g(l),o=a;o<n.events.length;)n.events[o][1].end={...r},o++;eF(n.events,h+1,0,n.events.slice(a)),n.events.length=o}}function g(i){let r=o.length;for(;r-- >i;){let i=o[r];n.containerState=i[1],i[0].exit.call(n,e)}o.length=i}function v(){i.write([null]),r=void 0,i=void 0,n.containerState._closeFlow=void 0}}},e6={tokenize:function(e,i,r){return e5(e,e.attempt(this.parser.constructs.document,i,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},e9={partial:!0,tokenize:function(e,i,r){return function(i){return eZ(i)?e5(e,s,"linePrefix")(i):s(i)};function s(e){return null===e||eJ(e)?i(e):r(e)}}};class e8{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,i){let r=null==i?1/0:i;return r<this.left.length?this.left.slice(e,r):e>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,i,r){this.setCursor(Math.trunc(e));let s=this.right.splice(this.right.length-(i||0),1/0);return r&&e7(this.left,r),s.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),e7(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),e7(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let i=this.left.splice(e,1/0);e7(this.right,i.reverse())}else{let i=this.right.splice(this.left.length+this.right.length-e,1/0);e7(this.left,i.reverse())}}}function e7(e,i){let r=0;if(i.length<1e4)e.push(...i);else for(;r<i.length;)e.push(...i.slice(r,r+1e4)),r+=1e4}function te(e){let i,r,s,n,o,l,a,h={},c=-1,d=new e8(e);for(;++c<d.length;){for(;c in h;)c=h[c];if(i=d.get(c),c&&"chunkFlow"===i[1].type&&"listItemPrefix"===d.get(c-1)[1].type&&((s=0)<(l=i[1]._tokenizer.events).length&&"lineEndingBlank"===l[s][1].type&&(s+=2),s<l.length&&"content"===l[s][1].type))for(;++s<l.length&&"content"!==l[s][1].type;)"chunkText"===l[s][1].type&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if("enter"===i[0])i[1].contentType&&(Object.assign(h,function(e,i){let r,s,n=e.get(i)[1],o=e.get(i)[2],l=i-1,a=[],h=n._tokenizer;!h&&(h=o.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(h._contentTypeTextTrailing=!0));let c=h.events,d=[],u={},f=-1,p=n,_=0,m=0,g=[0];for(;p;){for(;e.get(++l)[1]!==p;);a.push(l),!p._tokenizer&&(r=o.sliceStream(p),p.next||r.push(null),s&&h.defineSkip(p.start),p._isInFirstContentOfListItem&&(h._gfmTasklistFirstContentOfListItem=!0),h.write(r),p._isInFirstContentOfListItem&&(h._gfmTasklistFirstContentOfListItem=void 0)),s=p,p=p.next}for(p=n;++f<c.length;)"exit"===c[f][0]&&"enter"===c[f-1][0]&&c[f][1].type===c[f-1][1].type&&c[f][1].start.line!==c[f][1].end.line&&(m=f+1,g.push(m),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(h.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let i=c.slice(g[f],g[f+1]),r=a.pop();d.push([r,r+i.length-1]),e.splice(r,2,i)}for(d.reverse(),f=-1;++f<d.length;)u[_+d[f][0]]=_+d[f][1],_+=d[f][1]-d[f][0]-1;return u}(d,c)),c=h[c],a=!0);else if(i[1]._container){for(s=c,r=void 0;s--;)if("lineEnding"===(n=d.get(s))[1].type||"lineEndingBlank"===n[1].type)"enter"===n[0]&&(r&&(d.get(r)[1].type="lineEndingBlank"),n[1].type="lineEnding",r=s);else if("linePrefix"===n[1].type||"listItemIndent"===n[1].type);else break;r&&(i[1].end={...d.get(r)[1].start},(o=d.slice(r,c)).unshift(i),d.splice(r,c-r+1,o))}}return eF(e,0,1/0,d.slice(0)),!a}let tt={resolve:function(e){return te(e),e},tokenize:function(e,i){let r;return function(i){return e.enter("content"),r=e.enter("chunkContent",{contentType:"content"}),s(i)};function s(i){return null===i?n(i):eJ(i)?e.check(ti,o,n)(i):(e.consume(i),s)}function n(r){return e.exit("chunkContent"),e.exit("content"),i(r)}function o(i){return e.consume(i),e.exit("chunkContent"),r.next=e.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,s}}},ti={partial:!0,tokenize:function(e,i,r){let s=this;return function(i){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e5(e,n,"linePrefix")};function n(n){if(null===n||eJ(n))return r(n);let o=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?i(n):e.interrupt(s.parser.constructs.flow,r,i)(n)}}},tr={tokenize:function(e){let i=this,r=e.attempt(e9,function(s){return null===s?void e.consume(s):(e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),i.currentConstruct=void 0,r)},e.attempt(this.parser.constructs.flowInitial,s,e5(e,e.attempt(this.parser.constructs.flow,s,e.attempt(tt,s)),"linePrefix")));return r;function s(s){return null===s?void e.consume(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i.currentConstruct=void 0,r)}}},ts={resolveAll:ta()},tn=tl("string"),to=tl("text");function tl(e){return{resolveAll:ta("text"===e?th:void 0),tokenize:function(i){let r=this,s=this.parser.constructs[e],n=i.attempt(s,o,l);return o;function o(e){return h(e)?n(e):l(e)}function l(e){return null===e?void i.consume(e):(i.enter("data"),i.consume(e),a)}function a(e){return h(e)?(i.exit("data"),n(e)):(i.consume(e),a)}function h(e){if(null===e)return!0;let i=s[e],n=-1;if(i)for(;++n<i.length;){let e=i[n];if(!e.previous||e.previous.call(r,r.previous))return!0}return!1}}}}function ta(e){return function(i,r){let s,n=-1;for(;++n<=i.length;)void 0===s?i[n]&&"data"===i[n][1].type&&(s=n,n++):i[n]&&"data"===i[n][1].type||(n!==s+2&&(i[s][1].end=i[n-1][1].end,i.splice(s+2,n-s-2),n=s+2),s=void 0);return e?e(i,r):i}}function th(e,i){let r=0;for(;++r<=e.length;)if((r===e.length||"lineEnding"===e[r][1].type)&&"data"===e[r-1][1].type){let s,n=e[r-1][1],o=i.sliceStream(n),l=o.length,a=-1,h=0;for(;l--;){let e=o[l];if("string"==typeof e){for(a=e.length;32===e.charCodeAt(a-1);)h++,a--;if(a)break;a=-1}else if(-2===e)s=!0,h++;else if(-1===e);else{l++;break}}if(i._contentTypeTextTrailing&&r===e.length&&(h=0),h){let o={type:r===e.length||s||h<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?a:n.start._bufferIndex+a,_index:n.start._index+l,line:n.end.line,column:n.end.column-h,offset:n.end.offset-h},end:{...n.end}};n.end={...o.start},n.start.offset===n.end.offset?Object.assign(n,o):(e.splice(r,0,["enter",o,i],["exit",o,i]),r+=2)}r++}return e}function tc(e){return null===e||eQ(e)||e1(e)?1:e0(e)?2:void 0}function td(e,i,r){let s=[],n=-1;for(;++n<e.length;){let o=e[n].resolveAll;o&&!s.includes(o)&&(i=o(i,r),s.push(o))}return i}let tu={name:"attention",resolveAll:function(e,i){let r,s,n,o,l,a,h,c,d=-1;for(;++d<e.length;)if("enter"===e[d][0]&&"attentionSequence"===e[d][1].type&&e[d][1]._close){for(r=d;r--;)if("exit"===e[r][0]&&"attentionSequence"===e[r][1].type&&e[r][1]._open&&i.sliceSerialize(e[r][1]).charCodeAt(0)===i.sliceSerialize(e[d][1]).charCodeAt(0)){if((e[r][1]._close||e[d][1]._open)&&(e[d][1].end.offset-e[d][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[d][1].end.offset-e[d][1].start.offset)%3))continue;a=e[r][1].end.offset-e[r][1].start.offset>1&&e[d][1].end.offset-e[d][1].start.offset>1?2:1;let u={...e[r][1].end},f={...e[d][1].start};tf(u,-a),tf(f,a),o={type:a>1?"strongSequence":"emphasisSequence",start:u,end:{...e[r][1].end}},l={type:a>1?"strongSequence":"emphasisSequence",start:{...e[d][1].start},end:f},n={type:a>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[d][1].start}},s={type:a>1?"strong":"emphasis",start:{...o.start},end:{...l.end}},e[r][1].end={...o.start},e[d][1].start={...l.end},h=[],e[r][1].end.offset-e[r][1].start.offset&&(h=eW(h,[["enter",e[r][1],i],["exit",e[r][1],i]])),h=eW(h,[["enter",s,i],["enter",o,i],["exit",o,i],["enter",n,i]]),h=eW(h,td(i.parser.constructs.insideSpan.null,e.slice(r+1,d),i)),h=eW(h,[["exit",n,i],["enter",l,i],["exit",l,i],["exit",s,i]]),e[d][1].end.offset-e[d][1].start.offset?(c=2,h=eW(h,[["enter",e[d][1],i],["exit",e[d][1],i]])):c=0,eF(e,r-1,d-r+3,h),d=r+h.length-c-2;break}}for(d=-1;++d<e.length;)"attentionSequence"===e[d][1].type&&(e[d][1].type="data");return e},tokenize:function(e,i){let r,s=this.parser.constructs.attentionMarkers.null,n=this.previous,o=tc(n);return function(l){return r=l,e.enter("attentionSequence"),function l(a){if(a===r)return e.consume(a),l;let h=e.exit("attentionSequence"),c=tc(a),d=!c||2===c&&o||s.includes(a),u=!o||2===o&&c||s.includes(n);return h._open=!!(42===r?d:d&&(o||!u)),h._close=!!(42===r?u:u&&(c||!d)),i(a)}(l)}}};function tf(e,i){e.column+=i,e.offset+=i,e._bufferIndex+=i}let tp={continuation:{tokenize:function(e,i,r){let s=this;return function(i){return eZ(i)?e5(e,n,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):n(i)};function n(s){return e.attempt(tp,i,r)(s)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,i,r){let s=this;return function(i){if(62===i){let r=s.containerState;return r.open||(e.enter("blockQuote",{_container:!0}),r.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(i),e.exit("blockQuoteMarker"),n}return r(i)};function n(r){return eZ(r)?(e.enter("blockQuotePrefixWhitespace"),e.consume(r),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),i):(e.exit("blockQuotePrefix"),i(r))}}},t_={name:"characterEscape",tokenize:function(e,i,r){return function(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),s};function s(s){return eX(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),i):r(s)}}},tm=document.createElement("i");function tg(e){let i="&"+e+";";tm.innerHTML=i;let r=tm.textContent;return(59!==r.charCodeAt(r.length-1)||"semi"===e)&&r!==i&&r}let tv={name:"characterReference",tokenize:function(e,i,r){let s,n,o=this,l=0;return function(i){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(i),e.exit("characterReferenceMarker"),a};function a(i){return 35===i?(e.enter("characterReferenceMarkerNumeric"),e.consume(i),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),s=31,n=eK,c(i))}function h(i){return 88===i||120===i?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(i),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,n=eG,c):(e.enter("characterReferenceValue"),s=7,n=eY,c(i))}function c(a){if(59===a&&l){let s=e.exit("characterReferenceValue");return n!==eK||tg(o.sliceSerialize(s))?(e.enter("characterReferenceMarker"),e.consume(a),e.exit("characterReferenceMarker"),e.exit("characterReference"),i):r(a)}return n(a)&&l++<s?(e.consume(a),c):r(a)}}},tx={partial:!0,tokenize:function(e,i,r){let s=this;return function(i){return null===i?r(i):(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n)};function n(e){return s.parser.lazy[s.now().line]?r(e):i(e)}}},tb={concrete:!0,name:"codeFenced",tokenize:function(e,i,r){let s,n=this,o={partial:!0,tokenize:function(e,i,r){let o=0;return function(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),l};function l(i){return e.enter("codeFencedFence"),eZ(i)?e5(e,h,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):h(i)}function h(i){return i===s?(e.enter("codeFencedFenceSequence"),function i(n){return n===s?(o++,e.consume(n),i):o>=a?(e.exit("codeFencedFenceSequence"),eZ(n)?e5(e,c,"whitespace")(n):c(n)):r(n)}(i)):r(i)}function c(s){return null===s||eJ(s)?(e.exit("codeFencedFence"),i(s)):r(s)}}},l=0,a=0;return function(i){var o;let c;return o=i,l=(c=n.events[n.events.length-1])&&"linePrefix"===c[1].type?c[2].sliceSerialize(c[1],!0).length:0,s=o,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function i(n){return n===s?(a++,e.consume(n),i):a<3?r(n):(e.exit("codeFencedFenceSequence"),eZ(n)?e5(e,h,"whitespace")(n):h(n))}(o)};function h(o){return null===o||eJ(o)?(e.exit("codeFencedFence"),n.interrupt?i(o):e.check(tx,d,_)(o)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function i(n){return null===n||eJ(n)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(n)):eZ(n)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),e5(e,c,"whitespace")(n)):96===n&&n===s?r(n):(e.consume(n),i)}(o))}function c(i){return null===i||eJ(i)?h(i):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function i(n){return null===n||eJ(n)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(n)):96===n&&n===s?r(n):(e.consume(n),i)}(i))}function d(i){return e.attempt(o,_,u)(i)}function u(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),f}function f(i){return l>0&&eZ(i)?e5(e,p,"linePrefix",l+1)(i):p(i)}function p(i){return null===i||eJ(i)?e.check(tx,d,_)(i):(e.enter("codeFlowValue"),function i(r){return null===r||eJ(r)?(e.exit("codeFlowValue"),p(r)):(e.consume(r),i)}(i))}function _(r){return e.exit("codeFenced"),i(r)}}},ty={name:"codeIndented",tokenize:function(e,i,r){let s=this;return function(i){return e.enter("codeIndented"),e5(e,n,"linePrefix",5)(i)};function n(i){let n=s.events[s.events.length-1];return n&&"linePrefix"===n[1].type&&n[2].sliceSerialize(n[1],!0).length>=4?function i(r){return null===r?o(r):eJ(r)?e.attempt(tS,i,o)(r):(e.enter("codeFlowValue"),function r(s){return null===s||eJ(s)?(e.exit("codeFlowValue"),i(s)):(e.consume(s),r)}(r))}(i):r(i)}function o(r){return e.exit("codeIndented"),i(r)}}},tS={partial:!0,tokenize:function(e,i,r){let s=this;return n;function n(i){return s.parser.lazy[s.now().line]?r(i):eJ(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n):e5(e,o,"linePrefix",5)(i)}function o(e){let o=s.events[s.events.length-1];return o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?i(e):eJ(e)?n(e):r(e)}}};function tw(e,i,r,s,n,o,l,a,h){let c=h||1/0,d=0;return function(i){return 60===i?(e.enter(s),e.enter(n),e.enter(o),e.consume(i),e.exit(o),u):null===i||32===i||41===i||eV(i)?r(i):(e.enter(s),e.enter(l),e.enter(a),e.enter("chunkString",{contentType:"string"}),_(i))};function u(r){return 62===r?(e.enter(o),e.consume(r),e.exit(o),e.exit(n),e.exit(s),i):(e.enter(a),e.enter("chunkString",{contentType:"string"}),f(r))}function f(i){return 62===i?(e.exit("chunkString"),e.exit(a),u(i)):null===i||60===i||eJ(i)?r(i):(e.consume(i),92===i?p:f)}function p(i){return 60===i||62===i||92===i?(e.consume(i),f):f(i)}function _(n){return!d&&(null===n||41===n||eQ(n))?(e.exit("chunkString"),e.exit(a),e.exit(l),e.exit(s),i(n)):d<c&&40===n?(e.consume(n),d++,_):41===n?(e.consume(n),d--,_):null===n||32===n||40===n||eV(n)?r(n):(e.consume(n),92===n?m:_)}function m(i){return 40===i||41===i||92===i?(e.consume(i),_):_(i)}}function tC(e,i,r,s,n,o){let l,a=this,h=0;return function(i){return e.enter(s),e.enter(n),e.consume(i),e.exit(n),e.enter(o),c};function c(u){return h>999||null===u||91===u||93===u&&!l||94===u&&!h&&"_hiddenFootnoteSupport"in a.parser.constructs?r(u):93===u?(e.exit(o),e.enter(n),e.consume(u),e.exit(n),e.exit(s),i):eJ(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(i){return null===i||91===i||93===i||eJ(i)||h++>999?(e.exit("chunkString"),c(i)):(e.consume(i),l||(l=!eZ(i)),92===i?u:d)}function u(i){return 91===i||92===i||93===i?(e.consume(i),h++,d):d(i)}}function tk(e,i,r,s,n,o){let l;return function(i){return 34===i||39===i||40===i?(e.enter(s),e.enter(n),e.consume(i),e.exit(n),l=40===i?41:i,a):r(i)};function a(r){return r===l?(e.enter(n),e.consume(r),e.exit(n),e.exit(s),i):(e.enter(o),h(r))}function h(i){return i===l?(e.exit(o),a(l)):null===i?r(i):eJ(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e5(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(i))}function c(i){return i===l||null===i||eJ(i)?(e.exit("chunkString"),h(i)):(e.consume(i),92===i?d:c)}function d(i){return i===l||92===i?(e.consume(i),c):c(i)}}function tE(e,i){let r;return function s(n){return eJ(n)?(e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),r=!0,s):eZ(n)?e5(e,s,r?"linePrefix":"lineSuffix")(n):i(n)}}function tN(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}let tR={partial:!0,tokenize:function(e,i,r){return function(i){return eQ(i)?tE(e,s)(i):r(i)};function s(i){return tk(e,n,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(i)}function n(i){return eZ(i)?e5(e,o,"whitespace")(i):o(i)}function o(e){return null===e||eJ(e)?i(e):r(e)}}},tD=["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","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],tM=["pre","script","style","textarea"],tT={partial:!0,tokenize:function(e,i,r){return function(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(e9,i,r)}}},tP={partial:!0,tokenize:function(e,i,r){let s=this;return function(i){return eJ(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n):r(i)};function n(e){return s.parser.lazy[s.now().line]?r(e):i(e)}}},tj={name:"labelEnd",resolveAll:function(e){let i=-1,r=[];for(;++i<e.length;){let s=e[i][1];if(r.push(e[i]),"labelImage"===s.type||"labelLink"===s.type||"labelEnd"===s.type){let e="labelImage"===s.type?4:2;s.type="data",i+=e}}return e.length!==r.length&&eF(e,0,e.length,r),e},resolveTo:function(e,i){let r,s,n,o,l=e.length,a=0;for(;l--;)if(r=e[l][1],s){if("link"===r.type||"labelLink"===r.type&&r._inactive)break;"enter"===e[l][0]&&"labelLink"===r.type&&(r._inactive=!0)}else if(n){if("enter"===e[l][0]&&("labelImage"===r.type||"labelLink"===r.type)&&!r._balanced&&(s=l,"labelLink"!==r.type)){a=2;break}}else"labelEnd"===r.type&&(n=l);let h={type:"labelLink"===e[s][1].type?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[n][1].end}},d={type:"labelText",start:{...e[s+a+2][1].end},end:{...e[n-2][1].start}};return o=eW(o=[["enter",h,i],["enter",c,i]],e.slice(s+1,s+a+3)),o=eW(o,[["enter",d,i]]),o=eW(o,td(i.parser.constructs.insideSpan.null,e.slice(s+a+4,n-3),i)),o=eW(o,[["exit",d,i],e[n-2],e[n-1],["exit",c,i]]),o=eW(o,e.slice(n+1)),o=eW(o,[["exit",h,i]]),eF(e,s,e.length,o),e},tokenize:function(e,i,r){let s,n,o=this,l=o.events.length;for(;l--;)if(("labelImage"===o.events[l][1].type||"labelLink"===o.events[l][1].type)&&!o.events[l][1]._balanced){s=o.events[l][1];break}return function(i){return s?s._inactive?d(i):(n=o.parser.defined.includes(tN(o.sliceSerialize({start:s.end,end:o.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelEnd"),a):r(i)};function a(i){return 40===i?e.attempt(tB,c,n?c:d)(i):91===i?e.attempt(tL,c,n?h:d)(i):n?c(i):d(i)}function h(i){return e.attempt(tA,c,d)(i)}function c(e){return i(e)}function d(e){return s._balanced=!0,r(e)}}},tB={tokenize:function(e,i,r){return function(i){return e.enter("resource"),e.enter("resourceMarker"),e.consume(i),e.exit("resourceMarker"),s};function s(i){return eQ(i)?tE(e,n)(i):n(i)}function n(i){return 41===i?c(i):tw(e,o,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(i)}function o(i){return eQ(i)?tE(e,a)(i):c(i)}function l(e){return r(e)}function a(i){return 34===i||39===i||40===i?tk(e,h,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(i):c(i)}function h(i){return eQ(i)?tE(e,c)(i):c(i)}function c(s){return 41===s?(e.enter("resourceMarker"),e.consume(s),e.exit("resourceMarker"),e.exit("resource"),i):r(s)}}},tL={tokenize:function(e,i,r){let s=this;return function(i){return tC.call(s,e,n,o,"reference","referenceMarker","referenceString")(i)};function n(e){return s.parser.defined.includes(tN(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?i(e):r(e)}function o(e){return r(e)}}},tA={tokenize:function(e,i,r){return function(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),s};function s(s){return 93===s?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),i):r(s)}}},tI={name:"labelStartImage",resolveAll:tj.resolveAll,tokenize:function(e,i,r){let s=this;return function(i){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(i),e.exit("labelImageMarker"),n};function n(i){return 91===i?(e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelImage"),o):r(i)}function o(e){return 94===e&&"_hiddenFootnoteSupport"in s.parser.constructs?r(e):i(e)}}},tO={name:"labelStartLink",resolveAll:tj.resolveAll,tokenize:function(e,i,r){let s=this;return function(i){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelLink"),n};function n(e){return 94===e&&"_hiddenFootnoteSupport"in s.parser.constructs?r(e):i(e)}}},tz={name:"lineEnding",tokenize:function(e,i){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e5(e,i,"linePrefix")}}},tH={name:"thematicBreak",tokenize:function(e,i,r){let s,n=0;return function(o){var l;return e.enter("thematicBreak"),s=l=o,function o(l){return l===s?(e.enter("thematicBreakSequence"),function i(r){return r===s?(e.consume(r),n++,i):(e.exit("thematicBreakSequence"),eZ(r)?e5(e,o,"whitespace")(r):o(r))}(l)):n>=3&&(null===l||eJ(l))?(e.exit("thematicBreak"),i(l)):r(l)}(l)}}},tF={continuation:{tokenize:function(e,i,r){let s=this;return s.containerState._closeFlow=void 0,e.check(e9,function(r){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,e5(e,i,"listItemIndent",s.containerState.size+1)(r)},function(r){return s.containerState.furtherBlankLines||!eZ(r)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,n(r)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(t$,i,n)(r))});function n(n){return s.containerState._closeFlow=!0,s.interrupt=void 0,e5(e,e.attempt(tF,i,r),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(n)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,i,r){let s=this,n=s.events[s.events.length-1],o=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,l=0;return function(i){let n=s.containerState.type||(42===i||43===i||45===i?"listUnordered":"listOrdered");if("listUnordered"===n?!s.containerState.marker||i===s.containerState.marker:eY(i)){if(s.containerState.type||(s.containerState.type=n,e.enter(n,{_container:!0})),"listUnordered"===n)return e.enter("listItemPrefix"),42===i||45===i?e.check(tH,r,a)(i):a(i);if(!s.interrupt||49===i)return e.enter("listItemPrefix"),e.enter("listItemValue"),function i(n){return eY(n)&&++l<10?(e.consume(n),i):(!s.interrupt||l<2)&&(s.containerState.marker?n===s.containerState.marker:41===n||46===n)?(e.exit("listItemValue"),a(n)):r(n)}(i)}return r(i)};function a(i){return e.enter("listItemMarker"),e.consume(i),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||i,e.check(e9,s.interrupt?r:h,e.attempt(tW,d,c))}function h(e){return s.containerState.initialBlankLine=!0,o++,d(e)}function c(i){return eZ(i)?(e.enter("listItemPrefixWhitespace"),e.consume(i),e.exit("listItemPrefixWhitespace"),d):r(i)}function d(r){return s.containerState.size=o+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,i(r)}}},tW={partial:!0,tokenize:function(e,i,r){let s=this;return e5(e,function(e){let n=s.events[s.events.length-1];return!eZ(e)&&n&&"listItemPrefixWhitespace"===n[1].type?i(e):r(e)},"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},t$={partial:!0,tokenize:function(e,i,r){let s=this;return e5(e,function(e){let n=s.events[s.events.length-1];return n&&"listItemIndent"===n[1].type&&n[2].sliceSerialize(n[1],!0).length===s.containerState.size?i(e):r(e)},"listItemIndent",s.containerState.size+1)}},tU={name:"setextUnderline",resolveTo:function(e,i){let r,s,n,o=e.length;for(;o--;)if("enter"===e[o][0]){if("content"===e[o][1].type){r=o;break}"paragraph"===e[o][1].type&&(s=o)}else"content"===e[o][1].type&&e.splice(o,1),n||"definition"!==e[o][1].type||(n=o);let l={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",n?(e.splice(s,0,["enter",l,i]),e.splice(n+1,0,["exit",e[r][1],i]),e[r][1].end={...e[n][1].end}):e[r][1]=l,e.push(["exit",l,i]),e},tokenize:function(e,i,r){let s,n=this;return function(i){var l;let a,h=n.events.length;for(;h--;)if("lineEnding"!==n.events[h][1].type&&"linePrefix"!==n.events[h][1].type&&"content"!==n.events[h][1].type){a="paragraph"===n.events[h][1].type;break}return!n.parser.lazy[n.now().line]&&(n.interrupt||a)?(e.enter("setextHeadingLine"),s=i,l=i,e.enter("setextHeadingLineSequence"),function i(r){return r===s?(e.consume(r),i):(e.exit("setextHeadingLineSequence"),eZ(r)?e5(e,o,"lineSuffix")(r):o(r))}(l)):r(i)};function o(s){return null===s||eJ(s)?(e.exit("setextHeadingLine"),i(s)):r(s)}}};e.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(e,i,r){let s,n=this;return function(i){var s;return e.enter("definition"),s=i,tC.call(n,e,o,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(s)};function o(i){return(s=tN(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)),58===i)?(e.enter("definitionMarker"),e.consume(i),e.exit("definitionMarker"),l):r(i)}function l(i){return eQ(i)?tE(e,a)(i):a(i)}function a(i){return tw(e,h,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(i)}function h(i){return e.attempt(tR,c,c)(i)}function c(i){return eZ(i)?e5(e,d,"whitespace")(i):d(i)}function d(o){return null===o||eJ(o)?(e.exit("definition"),n.parser.defined.push(s),i(o)):r(o)}}}},"disable",0,{null:[]},"document",0,{42:tF,43:tF,45:tF,48:tF,49:tF,50:tF,51:tF,52:tF,53:tF,54:tF,55:tF,56:tF,57:tF,62:tp},"flow",0,{35:{name:"headingAtx",resolve:function(e,i){let r,s,n=e.length-2,o=3;return"whitespace"===e[3][1].type&&(o+=2),n-2>o&&"whitespace"===e[n][1].type&&(n-=2),"atxHeadingSequence"===e[n][1].type&&(o===n-1||n-4>o&&"whitespace"===e[n-2][1].type)&&(n-=o+1===n?2:4),n>o&&(r={type:"atxHeadingText",start:e[o][1].start,end:e[n][1].end},s={type:"chunkText",start:e[o][1].start,end:e[n][1].end,contentType:"text"},eF(e,o,n-o+1,[["enter",r,i],["enter",s,i],["exit",s,i],["exit",r,i]])),e},tokenize:function(e,i,r){let s=0;return function(n){var o;return e.enter("atxHeading"),o=n,e.enter("atxHeadingSequence"),function n(o){return 35===o&&s++<6?(e.consume(o),n):null===o||eQ(o)?(e.exit("atxHeadingSequence"),function r(s){return 35===s?(e.enter("atxHeadingSequence"),function i(s){return 35===s?(e.consume(s),i):(e.exit("atxHeadingSequence"),r(s))}(s)):null===s||eJ(s)?(e.exit("atxHeading"),i(s)):eZ(s)?e5(e,r,"whitespace")(s):(e.enter("atxHeadingText"),function i(s){return null===s||35===s||eQ(s)?(e.exit("atxHeadingText"),r(s)):(e.consume(s),i)}(s))}(o)):r(o)}(o)}}},42:tH,45:[tU,tH],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let i=e.length;for(;i--&&("enter"!==e[i][0]||"htmlFlow"!==e[i][1].type););return i>1&&"linePrefix"===e[i-2][1].type&&(e[i][1].start=e[i-2][1].start,e[i+1][1].start=e[i-2][1].start,e.splice(i-2,2)),e},tokenize:function(e,i,r){let s,n,o,l,a,h=this;return function(i){var r;return r=i,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(r),c};function c(l){return 33===l?(e.consume(l),d):47===l?(e.consume(l),n=!0,p):63===l?(e.consume(l),s=3,h.interrupt?i:j):eU(l)?(e.consume(l),o=String.fromCharCode(l),_):r(l)}function d(n){return 45===n?(e.consume(n),s=2,u):91===n?(e.consume(n),s=5,l=0,f):eU(n)?(e.consume(n),s=4,h.interrupt?i:j):r(n)}function u(s){return 45===s?(e.consume(s),h.interrupt?i:j):r(s)}function f(s){let n="CDATA[";return s===n.charCodeAt(l++)?(e.consume(s),l===n.length)?h.interrupt?i:k:f:r(s)}function p(i){return eU(i)?(e.consume(i),o=String.fromCharCode(i),_):r(i)}function _(l){if(null===l||47===l||62===l||eQ(l)){let a=47===l,c=o.toLowerCase();return!a&&!n&&tM.includes(c)?(s=1,h.interrupt?i(l):k(l)):tD.includes(o.toLowerCase())?(s=6,a)?(e.consume(l),m):h.interrupt?i(l):k(l):(s=7,h.interrupt&&!h.parser.lazy[h.now().line]?r(l):n?function i(r){return eZ(r)?(e.consume(r),i):w(r)}(l):g(l))}return 45===l||eK(l)?(e.consume(l),o+=String.fromCharCode(l),_):r(l)}function m(s){return 62===s?(e.consume(s),h.interrupt?i:k):r(s)}function g(i){return 47===i?(e.consume(i),w):58===i||95===i||eU(i)?(e.consume(i),v):eZ(i)?(e.consume(i),g):w(i)}function v(i){return 45===i||46===i||58===i||95===i||eK(i)?(e.consume(i),v):x(i)}function x(i){return 61===i?(e.consume(i),b):eZ(i)?(e.consume(i),x):g(i)}function b(i){return null===i||60===i||61===i||62===i||96===i?r(i):34===i||39===i?(e.consume(i),a=i,y):eZ(i)?(e.consume(i),b):function i(r){return null===r||34===r||39===r||47===r||60===r||61===r||62===r||96===r||eQ(r)?x(r):(e.consume(r),i)}(i)}function y(i){return i===a?(e.consume(i),a=null,S):null===i||eJ(i)?r(i):(e.consume(i),y)}function S(e){return 47===e||62===e||eZ(e)?g(e):r(e)}function w(i){return 62===i?(e.consume(i),C):r(i)}function C(i){return null===i||eJ(i)?k(i):eZ(i)?(e.consume(i),C):r(i)}function k(i){return 45===i&&2===s?(e.consume(i),D):60===i&&1===s?(e.consume(i),M):62===i&&4===s?(e.consume(i),B):63===i&&3===s?(e.consume(i),j):93===i&&5===s?(e.consume(i),P):eJ(i)&&(6===s||7===s)?(e.exit("htmlFlowData"),e.check(tT,L,E)(i)):null===i||eJ(i)?(e.exit("htmlFlowData"),E(i)):(e.consume(i),k)}function E(i){return e.check(tP,N,L)(i)}function N(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),R}function R(i){return null===i||eJ(i)?E(i):(e.enter("htmlFlowData"),k(i))}function D(i){return 45===i?(e.consume(i),j):k(i)}function M(i){return 47===i?(e.consume(i),o="",T):k(i)}function T(i){if(62===i){let r=o.toLowerCase();return tM.includes(r)?(e.consume(i),B):k(i)}return eU(i)&&o.length<8?(e.consume(i),o+=String.fromCharCode(i),T):k(i)}function P(i){return 93===i?(e.consume(i),j):k(i)}function j(i){return 62===i?(e.consume(i),B):45===i&&2===s?(e.consume(i),j):k(i)}function B(i){return null===i||eJ(i)?(e.exit("htmlFlowData"),L(i)):(e.consume(i),B)}function L(r){return e.exit("htmlFlow"),i(r)}}},61:tU,95:tH,96:tb,126:tb},"flowInitial",0,{[-2]:ty,[-1]:ty,32:ty},"insideSpan",0,{null:[tu,ts]},"string",0,{38:tv,92:t_},"text",0,{[-5]:tz,[-4]:tz,[-3]:tz,33:tI,38:tv,42:tu,60:[{name:"autolink",tokenize:function(e,i,r){let s=0;return function(i){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(i),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),n};function n(i){return eU(i)?(e.consume(i),o):64===i?r(i):a(i)}function o(i){return 43===i||45===i||46===i||eK(i)?(s=1,function i(r){return 58===r?(e.consume(r),s=0,l):(43===r||45===r||46===r||eK(r))&&s++<32?(e.consume(r),i):(s=0,a(r))}(i)):a(i)}function l(s){return 62===s?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(s),e.exit("autolinkMarker"),e.exit("autolink"),i):null===s||32===s||60===s||eV(s)?r(s):(e.consume(s),l)}function a(i){return 64===i?(e.consume(i),h):eq(i)?(e.consume(i),a):r(i)}function h(n){return eK(n)?function n(o){return 46===o?(e.consume(o),s=0,h):62===o?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(o),e.exit("autolinkMarker"),e.exit("autolink"),i):function i(o){if((45===o||eK(o))&&s++<63){let r=45===o?i:n;return e.consume(o),r}return r(o)}(o)}(n):r(n)}}},{name:"htmlText",tokenize:function(e,i,r){let s,n,o,l=this;return function(i){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(i),a};function a(i){return 33===i?(e.consume(i),h):47===i?(e.consume(i),y):63===i?(e.consume(i),x):eU(i)?(e.consume(i),w):r(i)}function h(i){return 45===i?(e.consume(i),c):91===i?(e.consume(i),n=0,p):eU(i)?(e.consume(i),v):r(i)}function c(i){return 45===i?(e.consume(i),f):r(i)}function d(i){return null===i?r(i):45===i?(e.consume(i),u):eJ(i)?(o=d,T(i)):(e.consume(i),d)}function u(i){return 45===i?(e.consume(i),f):d(i)}function f(e){return 62===e?M(e):45===e?u(e):d(e)}function p(i){let s="CDATA[";return i===s.charCodeAt(n++)?(e.consume(i),n===s.length?_:p):r(i)}function _(i){return null===i?r(i):93===i?(e.consume(i),m):eJ(i)?(o=_,T(i)):(e.consume(i),_)}function m(i){return 93===i?(e.consume(i),g):_(i)}function g(i){return 62===i?M(i):93===i?(e.consume(i),g):_(i)}function v(i){return null===i||62===i?M(i):eJ(i)?(o=v,T(i)):(e.consume(i),v)}function x(i){return null===i?r(i):63===i?(e.consume(i),b):eJ(i)?(o=x,T(i)):(e.consume(i),x)}function b(e){return 62===e?M(e):x(e)}function y(i){return eU(i)?(e.consume(i),S):r(i)}function S(i){return 45===i||eK(i)?(e.consume(i),S):function i(r){return eJ(r)?(o=i,T(r)):eZ(r)?(e.consume(r),i):M(r)}(i)}function w(i){return 45===i||eK(i)?(e.consume(i),w):47===i||62===i||eQ(i)?C(i):r(i)}function C(i){return 47===i?(e.consume(i),M):58===i||95===i||eU(i)?(e.consume(i),k):eJ(i)?(o=C,T(i)):eZ(i)?(e.consume(i),C):M(i)}function k(i){return 45===i||46===i||58===i||95===i||eK(i)?(e.consume(i),k):function i(r){return 61===r?(e.consume(r),E):eJ(r)?(o=i,T(r)):eZ(r)?(e.consume(r),i):C(r)}(i)}function E(i){return null===i||60===i||61===i||62===i||96===i?r(i):34===i||39===i?(e.consume(i),s=i,N):eJ(i)?(o=E,T(i)):eZ(i)?(e.consume(i),E):(e.consume(i),R)}function N(i){return i===s?(e.consume(i),s=void 0,D):null===i?r(i):eJ(i)?(o=N,T(i)):(e.consume(i),N)}function R(i){return null===i||34===i||39===i||60===i||61===i||96===i?r(i):47===i||62===i||eQ(i)?C(i):(e.consume(i),R)}function D(e){return 47===e||62===e||eQ(e)?C(e):r(e)}function M(s){return 62===s?(e.consume(s),e.exit("htmlTextData"),e.exit("htmlText"),i):r(s)}function T(i){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),P}function P(i){return eZ(i)?e5(e,j,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):j(i)}function j(i){return e.enter("htmlTextData"),o(i)}}}],91:tO,92:[{name:"hardBreakEscape",tokenize:function(e,i,r){return function(i){return e.enter("hardBreakEscape"),e.consume(i),s};function s(s){return eJ(s)?(e.exit("hardBreakEscape"),i(s)):r(s)}}},t_],93:tj,95:tu,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let i,r,s=e.length-4,n=3;if(("lineEnding"===e[3][1].type||"space"===e[n][1].type)&&("lineEnding"===e[s][1].type||"space"===e[s][1].type)){for(i=n;++i<s;)if("codeTextData"===e[i][1].type){e[n][1].type="codeTextPadding",e[s][1].type="codeTextPadding",n+=2,s-=2;break}}for(i=n-1,s++;++i<=s;)void 0===r?i!==s&&"lineEnding"!==e[i][1].type&&(r=i):(i===s||"lineEnding"===e[i][1].type)&&(e[r][1].type="codeTextData",i!==r+2&&(e[r][1].end=e[i-1][1].end,e.splice(r+2,i-r-2),s-=i-r-2,i=r+2),r=void 0);return e},tokenize:function(e,i,r){let s,n,o=0;return function(i){return e.enter("codeText"),e.enter("codeTextSequence"),function i(r){return 96===r?(e.consume(r),o++,i):(e.exit("codeTextSequence"),l(r))}(i)};function l(h){return null===h?r(h):32===h?(e.enter("space"),e.consume(h),e.exit("space"),l):96===h?(n=e.enter("codeTextSequence"),s=0,function r(l){return 96===l?(e.consume(l),s++,r):s===o?(e.exit("codeTextSequence"),e.exit("codeText"),i(l)):(n.type="codeTextData",a(l))}(h)):eJ(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),l):(e.enter("codeTextData"),a(h))}function a(i){return null===i||32===i||96===i||eJ(i)?(e.exit("codeTextData"),l(i)):(e.consume(i),a)}}}}],4127);var tK=e.i(4127);let tq=/[\0\t\n\r]/g;function tV(e,i){let r=Number.parseInt(e,i);return r<9||11===r||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(65535&r)==65535||(65535&r)==65534||r>1114111?"�":String.fromCodePoint(r)}let tY=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function tG(e,i,r){if(i)return i;if(35===r.charCodeAt(0)){let e=r.charCodeAt(1),i=120===e||88===e;return tV(r.slice(i?2:1),i?16:10)}return tg(r)||e}let tX={}.hasOwnProperty;function tJ(e){return{line:e.line,column:e.column,offset:e.offset}}function tQ(e,i){if(e)throw Error("Cannot close `"+e.type+"` ("+ex({start:e.start,end:e.end})+"): a different token (`"+i.type+"`, "+ex({start:i.start,end:i.end})+") is open");throw Error("Cannot close document, a token (`"+i.type+"`, "+ex({start:i.start,end:i.end})+") is still open")}function tZ(e){let i=this;i.parser=function(r){var s,n;let o,l,a,h;return"object"==typeof(s={...i.data("settings"),...e,extensions:i.data("micromarkExtensions")||[],mdastExtensions:i.data("fromMarkdownExtensions")||[]})&&(n=s,s=void 0),(function(e){let i={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(v),autolinkProtocol:c,autolinkEmail:c,atxHeading:s(_),blockQuote:s(function(){return{type:"blockquote",children:[]}}),characterEscape:c,characterReference:c,codeFenced:s(p),codeFencedFenceInfo:n,codeFencedFenceMeta:n,codeIndented:s(p,n),codeText:s(function(){return{type:"inlineCode",value:""}},n),codeTextData:c,data:c,codeFlowValue:c,definition:s(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:n,definitionLabelString:n,definitionTitleString:n,emphasis:s(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:s(m),hardBreakTrailing:s(m),htmlFlow:s(g,n),htmlFlowData:c,htmlText:s(g,n),htmlTextData:c,image:s(function(){return{type:"image",title:null,url:"",alt:null}}),label:n,link:s(v),listItem:s(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:s(x,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:s(x),paragraph:s(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:n,resourceDestinationString:n,resourceTitleString:n,setextHeading:s(_),strong:s(function(){return{type:"strong",children:[]}}),thematicBreak:s(function(){return{type:"thematicBreak"}})},exit:{atxHeading:l(),atxHeadingSequence:function(e){let i=this.stack[this.stack.length-1];i.depth||(i.depth=this.sliceSerialize(e).length)},autolink:l(),autolinkEmail:function(e){d.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){d.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:l(),characterEscapeValue:d,characterReferenceMarkerHexadecimal:f,characterReferenceMarkerNumeric:f,characterReferenceValue:function(e){let i,r=this.sliceSerialize(e),s=this.data.characterReferenceType;s?(i=tV(r,"characterReferenceMarkerNumeric"===s?10:16),this.data.characterReferenceType=void 0):i=tg(r);let n=this.stack[this.stack.length-1];n.value+=i},characterReference:function(e){this.stack.pop().position.end=tJ(e.end)},codeFenced:l(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){let e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:d,codeIndented:l(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:l(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:d,data:d,definition:l(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let i=this.resume(),r=this.stack[this.stack.length-1];r.label=i,r.identifier=tN(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:l(),hardBreakEscape:l(u),hardBreakTrailing:l(u),htmlFlow:l(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:d,htmlText:l(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:d,image:l(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let i=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=i,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],i=this.resume(),r=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===r.type?r.children=e.children:r.alt=i},labelText:function(e){let i=this.sliceSerialize(e),r=this.stack[this.stack.length-2];r.label=i.replace(tY,tG),r.identifier=tN(i).toLowerCase()},lineEnding:function(e){let r=this.stack[this.stack.length-1];if(this.data.atHardBreak){r.children[r.children.length-1].position.end=tJ(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&i.canContainEols.includes(r.type)&&(c.call(this,e),d.call(this,e))},link:l(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let i=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=i,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:function(e){let i=this.resume(),r=this.stack[this.stack.length-1];r.label=i,r.identifier=tN(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:l(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:l(),thematicBreak:l()}};!function e(i,r){let s=-1;for(;++s<r.length;){let n=r[s];Array.isArray(n)?e(i,n):function(e,i){let r;for(r in i)if(tX.call(i,r))switch(r){case"canContainEols":{let s=i[r];s&&e[r].push(...s);break}case"transforms":{let s=i[r];s&&e[r].push(...s);break}case"enter":case"exit":{let s=i[r];s&&Object.assign(e[r],s)}}}(i,n)}}(i,(e||{}).mdastExtensions||[]);let r={};return function(e){let s={type:"root",children:[]},l={stack:[s],tokenStack:[],config:i,enter:o,exit:a,buffer:n,resume:h,data:r},c=[],d=-1;for(;++d<e.length;)("listOrdered"===e[d][1].type||"listUnordered"===e[d][1].type)&&("enter"===e[d][0]?c.push(d):d=function(e,i,r){let s,n,o,l,a=i-1,h=-1,c=!1;for(;++a<=r;){let i=e[a];switch(i[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===i[0]?h++:h--,l=void 0;break;case"lineEndingBlank":"enter"===i[0]&&(!s||l||h||o||(o=a),l=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:l=void 0}if(!h&&"enter"===i[0]&&"listItemPrefix"===i[1].type||-1===h&&"exit"===i[0]&&("listUnordered"===i[1].type||"listOrdered"===i[1].type)){if(s){let l=a;for(n=void 0;l--;){let i=e[l];if("lineEnding"===i[1].type||"lineEndingBlank"===i[1].type){if("exit"===i[0])continue;n&&(e[n][1].type="lineEndingBlank",c=!0),i[1].type="lineEnding",n=l}else if("linePrefix"===i[1].type||"blockQuotePrefix"===i[1].type||"blockQuotePrefixWhitespace"===i[1].type||"blockQuoteMarker"===i[1].type||"listItemIndent"===i[1].type);else break}o&&(!n||o<n)&&(s._spread=!0),s.end=Object.assign({},n?e[n][1].start:i[1].end),e.splice(n||a,0,["exit",s,i[2]]),a++,r++}if("listItemPrefix"===i[1].type){let n={type:"listItem",_spread:!1,start:Object.assign({},i[1].start),end:void 0};s=n,e.splice(a,0,["enter",n,i[2]]),a++,r++,o=void 0,l=!0}}}return e[i][1]._spread=c,r}(e,c.pop(),d));for(d=-1;++d<e.length;){let r=i[e[d][0]];tX.call(r,e[d][1].type)&&r[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},l),e[d][1])}if(l.tokenStack.length>0){let e=l.tokenStack[l.tokenStack.length-1];(e[1]||tQ).call(l,void 0,e[0])}for(s.position={start:tJ(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:tJ(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<i.transforms.length;)s=i.transforms[d](s)||s;return s};function s(e,i){return function(r){o.call(this,e(r),r),i&&i.call(this,r)}}function n(){this.stack.push({type:"fragment",children:[]})}function o(e,i,r){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([i,r||void 0]),e.position={start:tJ(i.start),end:void 0}}function l(e){return function(i){e&&e.call(this,i),a.call(this,i)}}function a(e,i){let r=this.stack.pop(),s=this.tokenStack.pop();if(s)s[0].type!==e.type&&(i?i.call(this,e,s[0]):(s[1]||tQ).call(this,e,s[0]));else throw Error("Cannot close `"+e.type+"` ("+ex({start:e.start,end:e.end})+"): it’s not open");r.position.end=tJ(e.end)}function h(){var e;return e=this.stack.pop(),ez(e,"boolean"!=typeof eO.includeImageAlt||eO.includeImageAlt,"boolean"!=typeof eO.includeHtml||eO.includeHtml)}function c(e){let i=this.stack[this.stack.length-1].children,r=i[i.length-1];r&&"text"===r.type||((r={type:"text",value:""}).position={start:tJ(e.start),end:void 0},i.push(r)),this.stack.push(r)}function d(e){let i=this.stack.pop();i.value+=this.sliceSerialize(e),i.position.end=tJ(e.end)}function u(){this.data.atHardBreak=!0}function f(e){this.data.characterReferenceType=e.type}function p(){return{type:"code",lang:null,meta:null,value:""}}function _(){return{type:"heading",depth:0,children:[]}}function m(){return{type:"break"}}function g(){return{type:"html",value:""}}function v(){return{type:"link",title:null,url:"",children:[]}}function x(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(n)(function(e){for(;!te(e););return e}((function(e){let i={constructs:function(e){let i={},r=-1;for(;++r<e.length;)!function(e,i){let r;for(r in i){let s,n=(e$.call(e,r)?e[r]:void 0)||(e[r]={}),o=i[r];if(o)for(s in o){e$.call(n,s)||(n[s]=[]);let e=o[s];!function(e,i){let r=-1,s=[];for(;++r<i.length;)("after"===i[r].add?e:s).push(i[r]);eF(e,0,0,s)}(n[s],Array.isArray(e)?e:e?[e]:[])}}}(i,e[r]);return i}([tK,...(e||{}).extensions||[]]),content:r(e3),defined:[],document:r(e4),flow:r(tr),lazy:{},string:r(tn),text:r(to)};return i;function r(e){return function(r){return function(e,i,r){let s={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0},n={},o=[],l=[],a=[],h={attempt:_(function(e,i){m(e,i.from)}),check:_(p),consume:function(e){eJ(e)?(s.line++,s.column=1,s.offset+=-3===e?2:1,g()):-1!==e&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===l[s._index].length&&(s._bufferIndex=-1,s._index++)),c.previous=e},enter:function(e,i){let r=i||{};return r.type=e,r.start=f(),c.events.push(["enter",r,c]),a.push(r),r},exit:function(e){let i=a.pop();return i.end=f(),c.events.push(["exit",i,c]),i},interrupt:_(p,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){n[e.line]=e.column,g()},events:[],now:f,parser:e,previous:null,sliceSerialize:function(e,i){return function(e,i){let r,s=-1,n=[];for(;++s<e.length;){let o,l=e[s];if("string"==typeof l)o=l;else switch(l){case -5:o="\r";break;case -4:o="\n";break;case -3:o="\r\n";break;case -2:o=i?" ":" ";break;case -1:if(!i&&r)continue;o=" ";break;default:o=String.fromCharCode(l)}r=-2===l,n.push(o)}return n.join("")}(u(e),i)},sliceStream:u,write:function(e){return(l=eW(l,e),function(){let e;for(;s._index<l.length;){let r=l[s._index];if("string"==typeof r)for(e=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===e&&s._bufferIndex<r.length;){var i;i=r.charCodeAt(s._bufferIndex),d=d(i)}else d=d(r)}}(),null!==l[l.length-1])?[]:(m(i,0),c.events=td(o,c.events,c),c.events)}},d=i.tokenize.call(c,h);return i.resolveAll&&o.push(i),c;function u(e){return function(e,i){let r,s=i.start._index,n=i.start._bufferIndex,o=i.end._index,l=i.end._bufferIndex;if(s===o)r=[e[s].slice(n,l)];else{if(r=e.slice(s,o),n>-1){let e=r[0];"string"==typeof e?r[0]=e.slice(n):r.shift()}l>0&&r.push(e[o].slice(0,l))}return r}(l,e)}function f(){let{_bufferIndex:e,_index:i,line:r,column:n,offset:o}=s;return{_bufferIndex:e,_index:i,line:r,column:n,offset:o}}function p(e,i){i.restore()}function _(e,i){return function(r,n,o){var l;let d,u,p,_;return Array.isArray(r)?m(r):"tokenize"in r?m([r]):(l=r,function(e){let i=null!==e&&l[e],r=null!==e&&l.null;return m([...Array.isArray(i)?i:i?[i]:[],...Array.isArray(r)?r:r?[r]:[]])(e)});function m(e){return(d=e,u=0,0===e.length)?o:v(e[u])}function v(e){return function(r){let n,o,l,d,u;return(n=f(),o=c.previous,l=c.currentConstruct,d=c.events.length,u=Array.from(a),_={from:d,restore:function(){s=n,c.previous=o,c.currentConstruct=l,c.events.length=d,a=u,g()}},p=e,e.partial||(c.currentConstruct=e),e.name&&c.parser.constructs.disable.null.includes(e.name))?b(r):e.tokenize.call(i?Object.assign(Object.create(c),i):c,h,x,b)(r)}}function x(i){return e(p,_),n}function b(e){return(_.restore(),++u<d.length)?v(d[u]):o}}}function m(e,i){e.resolveAll&&!o.includes(e)&&o.push(e),e.resolve&&eF(c.events,i,c.events.length-i,e.resolve(c.events.slice(i),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function g(){s.line in n&&s.column<2&&(s.column=n[s.line],s.offset+=n[s.line]-1)}}(i,e,r)}}})(n).document().write((l=1,a="",h=!0,function(e,i,r){let s,n,c,d,u,f=[];for(e=a+("string"==typeof e?e.toString():new TextDecoder(i||void 0).decode(e)),c=0,a="",h&&(65279===e.charCodeAt(0)&&c++,h=void 0);c<e.length;){if(tq.lastIndex=c,d=(s=tq.exec(e))&&void 0!==s.index?s.index:e.length,u=e.charCodeAt(d),!s){a=e.slice(c);break}if(10===u&&c===d&&o)f.push(-3),o=void 0;else switch(o&&(f.push(-5),o=void 0),c<d&&(f.push(e.slice(c,d)),l+=d-c),u){case 0:f.push(65533),l++;break;case 9:for(n=4*Math.ceil(l/4),f.push(-2);l++<n;)f.push(-1);break;case 10:f.push(-4),l=1;break;default:o=!0,l=1}c=d+1}return r&&(o&&f.push(-5),a&&f.push(a),f.push(null)),f})(r,s,!0))))}}let t0="object"==typeof self?self:globalThis,t1=e=>{var i;let r,s;return(i=new Map,r=(e,r)=>(i.set(r,e),e),s=n=>{if(i.has(n))return i.get(n);let[o,l]=e[n];switch(o){case 0:case -1:return r(l,n);case 1:{let e=r([],n);for(let i of l)e.push(s(i));return e}case 2:{let e=r({},n);for(let[i,r]of l)e[s(i)]=s(r);return e}case 3:return r(new Date(l),n);case 4:{let{source:e,flags:i}=l;return r(new RegExp(e,i),n)}case 5:{let e=r(new Map,n);for(let[i,r]of l)e.set(s(i),s(r));return e}case 6:{let e=r(new Set,n);for(let i of l)e.add(s(i));return e}case 7:{let{name:e,message:i}=l;return r(new t0[e](i),n)}case 8:return r(BigInt(l),n);case"BigInt":return r(Object(BigInt(l)),n);case"ArrayBuffer":return r(new Uint8Array(l).buffer,l);case"DataView":{let{buffer:e}=new Uint8Array(l);return r(new DataView(e),l)}}return r(new t0[o](l),n)})(0)},{toString:t2}={},{keys:t5}=Object,t3=e=>{let i=typeof e;if("object"!==i||!e)return[0,i];let r=t2.call(e).slice(8,-1);switch(r){case"Array":return[1,""];case"Object":return[2,""];case"Date":return[3,""];case"RegExp":return[4,""];case"Map":return[5,""];case"Set":return[6,""];case"DataView":return[1,r]}return r.includes("Array")?[1,r]:r.includes("Error")?[7,r]:[2,r]},t4=([e,i])=>0===e&&("function"===i||"symbol"===i),t6=(e,{json:i,lossy:r}={})=>{var s,n,o;let l,a,h=[];return(s=!(i||r),n=!!i,o=new Map,l=(e,i)=>{let r=h.push(e)-1;return o.set(i,r),r},a=e=>{if(o.has(e))return o.get(e);let[i,r]=t3(e);switch(i){case 0:{let n=e;switch(r){case"bigint":i=8,n=e.toString();break;case"function":case"symbol":if(s)throw TypeError("unable to serialize "+r);n=null;break;case"undefined":return l([-1],e)}return l([i,n],e)}case 1:{if(r){let i=e;return"DataView"===r?i=new Uint8Array(e.buffer):"ArrayBuffer"===r&&(i=new Uint8Array(e)),l([r,[...i]],e)}let s=[],n=l([i,s],e);for(let i of e)s.push(a(i));return n}case 2:{if(r)switch(r){case"BigInt":return l([r,e.toString()],e);case"Boolean":case"Number":case"String":return l([r,e.valueOf()],e)}if(n&&"toJSON"in e)return a(e.toJSON());let o=[],h=l([i,o],e);for(let i of t5(e))(s||!t4(t3(e[i])))&&o.push([a(i),a(e[i])]);return h}case 3:return l([i,e.toISOString()],e);case 4:{let{source:r,flags:s}=e;return l([i,{source:r,flags:s}],e)}case 5:{let r=[],n=l([i,r],e);for(let[i,n]of e)(s||!(t4(t3(i))||t4(t3(n))))&&r.push([a(i),a(n)]);return n}case 6:{let r=[],n=l([i,r],e);for(let i of e)(s||!t4(t3(i)))&&r.push(a(i));return n}}let{message:h}=e;return l([i,{name:r,message:h}],e)})(e),h},t9="function"==typeof structuredClone?(e,i)=>i&&("json"in i||"lossy"in i)?t1(t6(e,i)):structuredClone(e):(e,i)=>t1(t6(e,i));function t8(e){let i=[],r=-1,s=0,n=0;for(;++r<e.length;){let o=e.charCodeAt(r),l="";if(37===o&&eK(e.charCodeAt(r+1))&&eK(e.charCodeAt(r+2)))n=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(l=String.fromCharCode(o));else if(o>55295&&o<57344){let i=e.charCodeAt(r+1);o<56320&&i>56319&&i<57344?(l=String.fromCharCode(o,i),n=1):l="�"}else l=String.fromCharCode(o);l&&(i.push(e.slice(s,r),encodeURIComponent(l)),s=r+n+1,l=""),n&&(r+=n,n=0)}return i.join("")+e.slice(s)}function t7(e,i){let r=[{type:"text",value:"↩"}];return i>1&&r.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(i)}]}),r}function ie(e,i){return"Back to reference "+(e+1)+(i>1?"-"+i:"")}let it=function(e){var i,r;if(null==e)return ir;if("function"==typeof e)return ii(e);if("object"==typeof e){return Array.isArray(e)?function(e){let i=[],r=-1;for(;++r<e.length;)i[r]=it(e[r]);return ii(function(...e){let r=-1;for(;++r<i.length;)if(i[r].apply(this,e))return!0;return!1})}(e):(i=e,ii(function(e){let r;for(r in i)if(e[r]!==i[r])return!1;return!0}))}if("string"==typeof e){return r=e,ii(function(e){return e&&e.type===r})}throw Error("Expected function, string, or object as test")};function ii(e){return function(i,r,s){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(i)&&e.call(this,i,"number"==typeof r?r:void 0,s||void 0))}}function ir(){return!0}let is=[];function io(e,i,r,s){var n,o,l;let a,h,c,d,u,f;"function"==typeof i&&"function"!=typeof r?(h=void 0,c=i,a=r):(h=i,c=r,a=s),n=h,o=function(e,i){let r=i[i.length-1],s=r?r.children.indexOf(e):void 0;return c(e,s,r)},l=a,"function"==typeof n&&"function"!=typeof o?(l=o,o=n):d=n,u=it(d),f=l?-1:1,(function e(i,r,s){let a=i&&"object"==typeof i?i:{};if("string"==typeof a.type){let e="string"==typeof a.tagName?a.tagName:"string"==typeof a.name?a.name:void 0;Object.defineProperty(h,"name",{value:"node ("+i.type+(e?"<"+e+">":"")+")"})}return h;function h(){var a;let h,c,d,p=is;if((!n||u(i,r,s[s.length-1]||void 0))&&!1===(p=Array.isArray(a=o(i,s))?a:"number"==typeof a?[!0,a]:null==a?is:[a])[0])return p;if("children"in i&&i.children&&i.children&&"skip"!==p[0])for(c=(l?i.children.length:-1)+f,d=s.concat(i);c>-1&&c<i.children.length;){if(!1===(h=e(i.children[c],c,d)())[0])return h;c="number"==typeof h[1]?h[1]:c+f}return p}})(e,void 0,[])()}function il(e,i){let r=i.referenceType,s="]";if("collapsed"===r?s+="[]":"full"===r&&(s+="["+(i.label||i.identifier)+"]"),"imageReference"===i.type)return[{type:"text",value:"!["+i.alt+s}];let n=e.all(i),o=n[0];o&&"text"===o.type?o.value="["+o.value:n.unshift({type:"text",value:"["});let l=n[n.length-1];return l&&"text"===l.type?l.value+=s:n.push({type:"text",value:s}),n}function ia(e){let i=e.spread;return null==i?e.children.length>1:i}function ih(e,i,r){let s=0,n=e.length;if(i){let i=e.codePointAt(s);for(;9===i||32===i;)s++,i=e.codePointAt(s)}if(r){let i=e.codePointAt(n-1);for(;9===i||32===i;)n--,i=e.codePointAt(n-1)}return n>s?e.slice(s,n):""}let ic={blockquote:function(e,i){let r={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(i),!0)};return e.patch(i,r),e.applyData(i,r)},break:function(e,i){let r={type:"element",tagName:"br",properties:{},children:[]};return e.patch(i,r),[e.applyData(i,r),{type:"text",value:"\n"}]},code:function(e,i){let r=i.value?i.value+"\n":"",s={},n=i.lang?i.lang.split(/\s+/):[];n.length>0&&(s.className=["language-"+n[0]]);let o={type:"element",tagName:"code",properties:s,children:[{type:"text",value:r}]};return i.meta&&(o.data={meta:i.meta}),e.patch(i,o),o={type:"element",tagName:"pre",properties:{},children:[o=e.applyData(i,o)]},e.patch(i,o),o},delete:function(e,i){let r={type:"element",tagName:"del",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},emphasis:function(e,i){let r={type:"element",tagName:"em",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},footnoteReference:function(e,i){let r,s="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=String(i.identifier).toUpperCase(),o=t8(n.toLowerCase()),l=e.footnoteOrder.indexOf(n),a=e.footnoteCounts.get(n);void 0===a?(a=0,e.footnoteOrder.push(n),r=e.footnoteOrder.length):r=l+1,a+=1,e.footnoteCounts.set(n,a);let h={type:"element",tagName:"a",properties:{href:"#"+s+"fn-"+o,id:s+"fnref-"+o+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(r)}]};e.patch(i,h);let c={type:"element",tagName:"sup",properties:{},children:[h]};return e.patch(i,c),e.applyData(i,c)},heading:function(e,i){let r={type:"element",tagName:"h"+i.depth,properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},html:function(e,i){if(e.options.allowDangerousHtml){let r={type:"raw",value:i.value};return e.patch(i,r),e.applyData(i,r)}},imageReference:function(e,i){let r=String(i.identifier).toUpperCase(),s=e.definitionById.get(r);if(!s)return il(e,i);let n={src:t8(s.url||""),alt:i.alt};null!==s.title&&void 0!==s.title&&(n.title=s.title);let o={type:"element",tagName:"img",properties:n,children:[]};return e.patch(i,o),e.applyData(i,o)},image:function(e,i){let r={src:t8(i.url)};null!==i.alt&&void 0!==i.alt&&(r.alt=i.alt),null!==i.title&&void 0!==i.title&&(r.title=i.title);let s={type:"element",tagName:"img",properties:r,children:[]};return e.patch(i,s),e.applyData(i,s)},inlineCode:function(e,i){let r={type:"text",value:i.value.replace(/\r?\n|\r/g," ")};e.patch(i,r);let s={type:"element",tagName:"code",properties:{},children:[r]};return e.patch(i,s),e.applyData(i,s)},linkReference:function(e,i){let r=String(i.identifier).toUpperCase(),s=e.definitionById.get(r);if(!s)return il(e,i);let n={href:t8(s.url||"")};null!==s.title&&void 0!==s.title&&(n.title=s.title);let o={type:"element",tagName:"a",properties:n,children:e.all(i)};return e.patch(i,o),e.applyData(i,o)},link:function(e,i){let r={href:t8(i.url)};null!==i.title&&void 0!==i.title&&(r.title=i.title);let s={type:"element",tagName:"a",properties:r,children:e.all(i)};return e.patch(i,s),e.applyData(i,s)},listItem:function(e,i,r){let s=e.all(i),n=r?function(e){let i=!1;if("list"===e.type){i=e.spread||!1;let r=e.children,s=-1;for(;!i&&++s<r.length;)i=ia(r[s])}return i}(r):ia(i),o={},l=[];if("boolean"==typeof i.checked){let e,r=s[0];r&&"element"===r.type&&"p"===r.tagName?e=r:(e={type:"element",tagName:"p",properties:{},children:[]},s.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:i.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let a=-1;for(;++a<s.length;){let e=s[a];(n||0!==a||"element"!==e.type||"p"!==e.tagName)&&l.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||n?l.push(e):l.push(...e.children)}let h=s[s.length-1];h&&(n||"element"!==h.type||"p"!==h.tagName)&&l.push({type:"text",value:"\n"});let c={type:"element",tagName:"li",properties:o,children:l};return e.patch(i,c),e.applyData(i,c)},list:function(e,i){let r={},s=e.all(i),n=-1;for("number"==typeof i.start&&1!==i.start&&(r.start=i.start);++n<s.length;){let e=s[n];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){r.className=["contains-task-list"];break}}let o={type:"element",tagName:i.ordered?"ol":"ul",properties:r,children:e.wrap(s,!0)};return e.patch(i,o),e.applyData(i,o)},paragraph:function(e,i){let r={type:"element",tagName:"p",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},root:function(e,i){let r={type:"root",children:e.wrap(e.all(i))};return e.patch(i,r),e.applyData(i,r)},strong:function(e,i){let r={type:"element",tagName:"strong",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},table:function(e,i){let r=e.all(i),s=r.shift(),n=[];if(s){let r={type:"element",tagName:"thead",properties:{},children:e.wrap([s],!0)};e.patch(i.children[0],r),n.push(r)}if(r.length>0){let s={type:"element",tagName:"tbody",properties:{},children:e.wrap(r,!0)},o=eg(i.children[1]),l=em(i.children[i.children.length-1]);o&&l&&(s.position={start:o,end:l}),n.push(s)}let o={type:"element",tagName:"table",properties:{},children:e.wrap(n,!0)};return e.patch(i,o),e.applyData(i,o)},tableCell:function(e,i){let r={type:"element",tagName:"td",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},tableRow:function(e,i,r){let s=r?r.children:void 0,n=0===(s?s.indexOf(i):1)?"th":"td",o=r&&"table"===r.type?r.align:void 0,l=o?o.length:i.children.length,a=-1,h=[];for(;++a<l;){let r=i.children[a],s={},l=o?o[a]:void 0;l&&(s.align=l);let c={type:"element",tagName:n,properties:s,children:[]};r&&(c.children=e.all(r),e.patch(r,c),c=e.applyData(r,c)),h.push(c)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(i,c),e.applyData(i,c)},text:function(e,i){let r={type:"text",value:function(e){let i=String(e),r=/\r?\n|\r/g,s=r.exec(i),n=0,o=[];for(;s;)o.push(ih(i.slice(n,s.index),n>0,!0),s[0]),n=s.index+s[0].length,s=r.exec(i);return o.push(ih(i.slice(n),n>0,!1)),o.join("")}(String(i.value))};return e.patch(i,r),e.applyData(i,r)},thematicBreak:function(e,i){let r={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(i,r),e.applyData(i,r)},toml:id,yaml:id,definition:id,footnoteDefinition:id};function id(){}let iu={}.hasOwnProperty,ip={};function i_(e,i){e.position&&(i.position=function(e){let i=eg(e),r=em(e);if(i&&r)return{start:i,end:r}}(e))}function im(e,i){let r=i;if(e&&e.data){let i=e.data.hName,s=e.data.hChildren,n=e.data.hProperties;"string"==typeof i&&("element"===r.type?r.tagName=i:r={type:"element",tagName:i,properties:{},children:"children"in r?r.children:[r]}),"element"===r.type&&n&&Object.assign(r.properties,t9(n)),"children"in r&&r.children&&null!=s&&(r.children=s)}return r}function ig(e,i){let r=[],s=-1;for(i&&r.push({type:"text",value:"\n"});++s<e.length;)s&&r.push({type:"text",value:"\n"}),r.push(e[s]);return i&&e.length>0&&r.push({type:"text",value:"\n"}),r}function iv(e){let i=0,r=e.charCodeAt(i);for(;9===r||32===r;)i++,r=e.charCodeAt(i);return e.slice(i)}function ix(e,i){let r,s,n,o,l=(r=i||ip,s=new Map,n=new Map,o={all:function(e){let i=[];if("children"in e){let r=e.children,s=-1;for(;++s<r.length;){let n=o.one(r[s],e);if(n){if(s&&"break"===r[s-1].type&&(Array.isArray(n)||"text"!==n.type||(n.value=iv(n.value)),!Array.isArray(n)&&"element"===n.type)){let e=n.children[0];e&&"text"===e.type&&(e.value=iv(e.value))}Array.isArray(n)?i.push(...n):i.push(n)}}}return i},applyData:im,definitionById:s,footnoteById:n,footnoteCounts:new Map,footnoteOrder:[],handlers:{...ic,...r.handlers},one:function(e,i){let r=e.type,s=o.handlers[r];if(iu.call(o.handlers,r)&&s)return s(o,e,i);if(o.options.passThrough&&o.options.passThrough.includes(r)){if("children"in e){let{children:i,...r}=e,s=t9(r);return s.children=o.all(e),s}return t9(e)}return(o.options.unknownHandler||function(e,i){let r=i.data||{},s="value"in i&&!(iu.call(r,"hProperties")||iu.call(r,"hChildren"))?{type:"text",value:i.value}:{type:"element",tagName:"div",properties:{},children:e.all(i)};return e.patch(i,s),e.applyData(i,s)})(o,e,i)},options:r,patch:i_,wrap:ig},io(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let i="definition"===e.type?s:n,r=String(e.identifier).toUpperCase();i.has(r)||i.set(r,e)}}),o),a=l.one(e,void 0),h=function(e){let i="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",r=e.options.footnoteBackContent||t7,s=e.options.footnoteBackLabel||ie,n=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",l=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[],h=-1;for(;++h<e.footnoteOrder.length;){let n=e.footnoteById.get(e.footnoteOrder[h]);if(!n)continue;let o=e.all(n),l=String(n.identifier).toUpperCase(),c=t8(l.toLowerCase()),d=0,u=[],f=e.footnoteCounts.get(l);for(;void 0!==f&&++d<=f;){u.length>0&&u.push({type:"text",value:" "});let e="string"==typeof r?r:r(h,d);"string"==typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+i+"fnref-"+c+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof s?s:s(h,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let p=o[o.length-1];if(p&&"element"===p.type&&"p"===p.tagName){let e=p.children[p.children.length-1];e&&"text"===e.type?e.value+=" ":p.children.push({type:"text",value:" "}),p.children.push(...u)}else o.push(...u);let _={type:"element",tagName:"li",properties:{id:i+"fn-"+c},children:e.wrap(o,!0)};e.patch(n,_),a.push(_)}if(0!==a.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...t9(l),id:"footnote-label"},children:[{type:"text",value:n}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:"\n"}]}}(l),c=Array.isArray(a)?{type:"root",children:a}:a||{type:"root",children:[]};return h&&(R("children"in c),c.children.push({type:"text",value:"\n"},h)),c}function ib(e,i){return e&&"run"in e?async function(r,s){let n=ix(r,{file:s,...i});await e.run(n,s)}:function(r,s){return ix(r,{file:s,...e||i})}}function iy(e){if(e)throw e}var iS=e.i(4100);function iw(e){if("object"!=typeof e||null===e)return!1;let i=Object.getPrototypeOf(e);return(null===i||i===Object.prototype||null===Object.getPrototypeOf(i))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let iC=function(e,i){let r;if(void 0!==i&&"string"!=typeof i)throw TypeError('"ext" argument must be a string');iR(e);let s=0,n=-1,o=e.length;if(void 0===i||0===i.length||i.length>e.length){for(;o--;)if(47===e.codePointAt(o)){if(r){s=o+1;break}}else n<0&&(r=!0,n=o+1);return n<0?"":e.slice(s,n)}if(i===e)return"";let l=-1,a=i.length-1;for(;o--;)if(47===e.codePointAt(o)){if(r){s=o+1;break}}else l<0&&(r=!0,l=o+1),a>-1&&(e.codePointAt(o)===i.codePointAt(a--)?a<0&&(n=o):(a=-1,n=l));return s===n?n=l:n<0&&(n=e.length),e.slice(s,n)},ik=function(e){let i;if(iR(e),0===e.length)return".";let r=-1,s=e.length;for(;--s;)if(47===e.codePointAt(s)){if(i){r=s;break}}else i||(i=!0);return r<0?47===e.codePointAt(0)?"/":".":1===r&&47===e.codePointAt(0)?"//":e.slice(0,r)},iE=function(e){let i;iR(e);let r=e.length,s=-1,n=0,o=-1,l=0;for(;r--;){let a=e.codePointAt(r);if(47===a){if(i){n=r+1;break}continue}s<0&&(i=!0,s=r+1),46===a?o<0?o=r:1!==l&&(l=1):o>-1&&(l=-1)}return o<0||s<0||0===l||1===l&&o===s-1&&o===n+1?"":e.slice(o,s)},iN=function(...e){var i;let r,s,n,o=-1;for(;++o<e.length;)iR(e[o]),e[o]&&(n=void 0===n?e[o]:n+"/"+e[o]);return void 0===n?".":(iR(i=n),r=47===i.codePointAt(0),0!==(s=function(e,i){let r,s,n="",o=0,l=-1,a=0,h=-1;for(;++h<=e.length;){if(h<e.length)r=e.codePointAt(h);else if(47===r)break;else r=47;if(47===r){if(l===h-1||1===a);else if(l!==h-1&&2===a){if(n.length<2||2!==o||46!==n.codePointAt(n.length-1)||46!==n.codePointAt(n.length-2)){if(n.length>2){if((s=n.lastIndexOf("/"))!==n.length-1){s<0?(n="",o=0):o=(n=n.slice(0,s)).length-1-n.lastIndexOf("/"),l=h,a=0;continue}}else if(n.length>0){n="",o=0,l=h,a=0;continue}}i&&(n=n.length>0?n+"/..":"..",o=2)}else n.length>0?n+="/"+e.slice(l+1,h):n=e.slice(l+1,h),o=h-l-1;l=h,a=0}else 46===r&&a>-1?a++:a=-1}return n}(i,!r)).length||r||(s="."),s.length>0&&47===i.codePointAt(i.length-1)&&(s+="/"),r?"/"+s:s)};function iR(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function iD(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let iM=["history","path","basename","stem","extname","dirname"];class iT{constructor(e){let i,r;i=e?iD(e)?{path:e}:"string"==typeof e||function(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in i?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<iM.length;){const e=iM[s];e in i&&void 0!==i[e]&&null!==i[e]&&(this[e]="history"===e?[...i[e]]:i[e])}for(r in i)iM.includes(r)||(this[r]=i[r])}get basename(){return"string"==typeof this.path?iC(this.path):void 0}set basename(e){ij(e,"basename"),iP(e,"basename"),this.path=iN(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?ik(this.path):void 0}set dirname(e){iB(this.basename,"dirname"),this.path=iN(e||"",this.basename)}get extname(){return"string"==typeof this.path?iE(this.path):void 0}set extname(e){if(iP(e,"extname"),iB(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=iN(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){iD(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!iD(e)){let i=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw i.code="ERR_INVALID_ARG_TYPE",i}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let i=e.pathname,r=-1;for(;++r<i.length;)if(37===i.codePointAt(r)&&50===i.codePointAt(r+1)){let e=i.codePointAt(r+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(i)}(e)}(e)),ij(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?iC(this.path,this.extname):void 0}set stem(e){ij(e,"stem"),iP(e,"stem"),this.path=iN(this.dirname||"",e+(this.extname||""))}fail(e,i,r){let s=this.message(e,i,r);throw s.fatal=!0,s}info(e,i,r){let s=this.message(e,i,r);return s.fatal=void 0,s}message(e,i,r){let s=new ew(e,i,r);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function iP(e,i){if(e&&e.includes("/"))throw Error("`"+i+"` cannot be a path: did not expect `/`")}function ij(e,i){if(!e)throw Error("`"+i+"` cannot be empty")}function iB(e,i){if(!e)throw Error("Setting `"+i+"` requires `path` to be set too")}let iL=function(e){let i=this.constructor.prototype,r=i[e],s=function(){return r.apply(s,arguments)};return Object.setPrototypeOf(s,i),s},iA={}.hasOwnProperty;class iI extends iL{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){let e=[],i={run:function(...i){let r=-1,s=i.pop();if("function"!=typeof s)throw TypeError("Expected function as last argument, not "+s);!function n(o,...l){let a=e[++r],h=-1;if(o)return void s(o);for(;++h<i.length;)(null===l[h]||void 0===l[h])&&(l[h]=i[h]);i=l,a?(function(e,i){let r;return function(...i){let o,l=e.length>i.length;l&&i.push(s);try{o=e.apply(this,i)}catch(e){if(l&&r)throw e;return s(e)}l||(o&&o.then&&"function"==typeof o.then?o.then(n,s):o instanceof Error?s(o):n(o))};function s(e,...n){r||(r=!0,i(e,...n))}function n(e){s(null,e)}})(a,n)(...l):s(null,...l)}(null,...i)},use:function(r){if("function"!=typeof r)throw TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),i}};return i}()}copy(){let e=new iI,i=-1;for(;++i<this.attachers.length;){let r=this.attachers[i];e.use(...r)}return e.data((0,iS.default)(!0,{},this.namespace)),e}data(e,i){return"string"==typeof e?2==arguments.length?(iF("data",this.frozen),this.namespace[e]=i,this):iA.call(this.namespace,e)&&this.namespace[e]||void 0:e?(iF("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...i]=this.attachers[this.freezeIndex];if(!1===i[0])continue;!0===i[0]&&(i[0]=void 0);let r=e.call(this,...i);"function"==typeof r&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let i=iU(e),r=this.parser||this.Parser;return iz("parse",r),r(String(i),i)}process(e,i){let r=this;return this.freeze(),iz("process",this.parser||this.Parser),iH("process",this.compiler||this.Compiler),i?s(void 0,i):new Promise(s);function s(s,n){let o=iU(e),l=r.parse(o);function a(e,r){e||!r?n(e):s?s(r):(R(i,"`done` is defined if `resolve` is not"),i(void 0,r))}r.run(l,o,function(e,i,s){var n,o;if(e||!i||!s)return a(e);let l=r.stringify(i,s);"string"==typeof(n=l)||(o=n)&&"object"==typeof o&&"byteLength"in o&&"byteOffset"in o?s.value=l:s.result=l,a(e,s)})}}processSync(e){let i,r=!1;return this.freeze(),iz("processSync",this.parser||this.Parser),iH("processSync",this.compiler||this.Compiler),this.process(e,function(e,s){r=!0,iy(e),i=s}),i$("processSync","process",r),R(i,"we either bailed on an error or have a tree"),i}run(e,i,r){iW(e),this.freeze();let s=this.transformers;return r||"function"!=typeof i||(r=i,i=void 0),r?n(void 0,r):new Promise(n);function n(n,o){R("function"!=typeof i,"`file` can’t be a `done` anymore, we checked");let l=iU(i);s.run(e,l,function(i,s,l){let a=s||e;i?o(i):n?n(a):(R(r,"`done` is defined if `resolve` is not"),r(void 0,a,l))})}}runSync(e,i){let r,s=!1;return this.run(e,i,function(e,i){iy(e),r=i,s=!0}),i$("runSync","run",s),R(r,"we either bailed on an error or have a tree"),r}stringify(e,i){this.freeze();let r=iU(i),s=this.compiler||this.Compiler;return iH("stringify",s),iW(e),s(e,r)}use(e,...i){let r=this.attachers,s=this.namespace;if(iF("use",this.frozen),null==e);else if("function"==typeof e)l(e,i);else if("object"==typeof e)Array.isArray(e)?o(e):n(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function n(e){if(!("plugins"in e)&&!("settings"in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(s.settings=(0,iS.default)(!0,s.settings,e.settings))}function o(e){let i=-1;if(null==e);else if(Array.isArray(e))for(;++i<e.length;)!function(e){if("function"==typeof e)l(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[i,...r]=e;l(i,r)}else n(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[i]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function l(e,i){let s=-1,n=-1;for(;++s<r.length;)if(r[s][0]===e){n=s;break}if(-1===n)r.push([e,...i]);else if(i.length>0){let[s,...o]=i,l=r[n][1];iw(l)&&iw(s)&&(s=(0,iS.default)(!0,l,s)),r[n]=[e,s,...o]}}}}let iO=new iI().freeze();function iz(e,i){if("function"!=typeof i)throw TypeError("Cannot `"+e+"` without `parser`")}function iH(e,i){if("function"!=typeof i)throw TypeError("Cannot `"+e+"` without `compiler`")}function iF(e,i){if(i)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function iW(e){if(!iw(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function i$(e,i,r){if(!r)throw Error("`"+e+"` finished async. Use `"+i+"` instead")}function iU(e){var i;return(i=e)&&"object"==typeof i&&"message"in i&&"messages"in i?e:new iT(e)}let iK=[],iq={allowDangerousHtml:!0},iV=/^(https?|ircs?|mailto|xmpp)$/i,iY=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function iG(e){var i;let r,s,n,o,l,a=(r=(i=e).rehypePlugins||iK,s=i.remarkPlugins||iK,n=i.remarkRehypeOptions?{...i.remarkRehypeOptions,...iq}:iq,iO().use(tZ).use(s).use(ib,n).use(r)),h=(o=e.children||"",l=new iT,"string"==typeof o?l.value=o:D("Unexpected value `"+o+"` for `children` prop, expected `string`"),l);return function(e,i){let r=i.allowedElements,s=i.allowElement,n=i.components,o=i.disallowedElements,l=i.skipHtml,a=i.unwrapDisallowed,h=i.urlTransform||iX;for(let e of iY)Object.hasOwn(i,e.from)&&D("Unexpected `"+e.from+"` prop, "+(e.to?"use `"+e.to+"` instead":"remove it")+" (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#"+e.id+"> for more info)");return r&&o&&D("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),io(e,function(e,i,n){if("raw"===e.type&&n&&"number"==typeof i)return l?n.children.splice(i,1):n.children[i]={type:"text",value:e.value},i;if("element"===e.type){let i;for(i in eI)if(Object.hasOwn(eI,i)&&Object.hasOwn(e.properties,i)){let r=e.properties[i],s=eI[i];(null===s||s.includes(e.tagName))&&(e.properties[i]=h(String(r||""),i,e))}}if("element"===e.type){let l=r?!r.includes(e.tagName):!!o&&o.includes(e.tagName);if(!l&&s&&"number"==typeof i&&(l=!s(e,i,n)),l&&n&&"number"==typeof i)return a&&e.children?n.children.splice(i,1,...e.children):n.children.splice(i,1),i}}),function(e,i){var r,s,n,o;let l;if(!i||void 0===i.Fragment)throw TypeError("Expected `Fragment` in options");let a=i.filePath||void 0;if(i.development){if("function"!=typeof i.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=a,s=i.jsxDEV,l=function(e,i,n,o){let l=Array.isArray(n.children),a=eg(e);return s(i,n,o,l,{columnNumber:a?a.column-1:void 0,fileName:r,lineNumber:a?a.line:void 0},void 0)}}else{if("function"!=typeof i.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof i.jsxs)throw TypeError("Expected `jsxs` in production options");n=i.jsx,o=i.jsxs,l=function(e,i,r,s){let l=Array.isArray(r.children)?o:n;return s?l(i,r,s):l(i,r)}}let h={Fragment:i.Fragment,ancestors:[],components:i.components||{},create:l,elementAttributeNameCase:i.elementAttributeNameCase||"react",evaluater:i.createEvaluater?i.createEvaluater():void 0,filePath:a,ignoreInvalidStyle:i.ignoreInvalidStyle||!1,passKeys:!1!==i.passKeys,passNode:i.passNode||!1,schema:"svg"===i.space?ep:ef,stylePropertyNameCase:i.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==i.tableCellAlignToStyle},c=eM(h,e,void 0);return c&&"string"!=typeof c?c:h.create(e,h.Fragment,{children:c||void 0},void 0)}(e,{Fragment:p.Fragment,components:n,ignoreInvalidStyle:!0,jsx:p.jsx,jsxs:p.jsxs,passKeys:!0,passNode:!0})}(a.runSync(a.parse(h),h),e)}function iX(e){let i=e.indexOf(":"),r=e.indexOf("?"),s=e.indexOf("#"),n=e.indexOf("/");return -1===i||-1!==n&&i>n||-1!==r&&i>r||-1!==s&&i>s||iV.test(e.slice(0,i))?e:""}function iJ({projectId:e,startInEditMode:i=!1}){let[r,s]=(0,_.useState)(""),[n,o]=(0,_.useState)(null),[l,a]=(0,_.useState)(i),[h,c]=(0,_.useState)(""),[d,u]=(0,_.useState)(!1),[f,m]=(0,_.useState)(null),g=(0,_.useRef)(!1);g.current=l;let v=(0,_.useRef)(i),x=(0,_.useCallback)(async()=>{try{let i=await fetch(`/api/queue?project=${encodeURIComponent(e)}`);if(!i.ok)throw Error(`${i.status}`);let r=await i.json();o(!!r.exists),g.current||s(r.content||""),v.current&&(c(r.content||""),v.current=!1),m(null)}catch(e){m(e.message)}},[e]);(0,_.useEffect)(()=>{x();let e=setInterval(x,1e4);return()=>clearInterval(e)},[x]);let b=async()=>{u(!0),m(null);try{let i=await fetch(`/api/queue?project=${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:h})});if(!i.ok)throw Error(`${i.status}`);s(h),a(!1)}catch(e){m(e.message)}finally{u(!1)}},y=async()=>{u(!0);try{let i=await fetch(`/api/queue?project=${encodeURIComponent(e)}`,{method:"POST"});if(!i.ok)throw Error(`${i.status}`);await x()}catch(e){m(e.message)}finally{u(!1)}};return(0,p.jsxs)("div",{className:"flex flex-col h-full min-h-0 border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:"OVERNIGHT-QUEUE.md"}),(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[f&&(0,p.jsxs)("span",{className:"text-[10px] text-error",children:["err: ",f]}),!l&&n&&(0,p.jsx)("button",{onClick:()=>{c(r),a(!0)},className:"text-[10px] text-text-muted hover:text-accent uppercase tracking-wider",children:"Edit"}),l&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("button",{onClick:b,disabled:d,className:"text-[10px] text-accent hover:text-accent-dim uppercase tracking-wider disabled:opacity-50",children:d?"Saving…":"Save"}),(0,p.jsx)("button",{onClick:()=>{a(!1),c(""),x()},disabled:d,className:"text-[10px] text-text-muted hover:text-text uppercase tracking-wider disabled:opacity-50",children:"Cancel"})]})]})]}),l&&(0,p.jsx)("div",{className:"shrink-0 px-3 py-1.5 border-b border-border bg-bg-surface text-[10px] text-text-muted leading-snug",children:"⚠️ Editing manually may conflict with the Head agent. Use the chat panel to ask Head to update the queue when possible."}),(0,p.jsx)("div",{className:"flex-1 min-h-0 overflow-auto",children:!1===n?(0,p.jsxs)("div",{className:"p-3 text-[11px] text-text-muted",children:[(0,p.jsx)("p",{className:"mb-2",children:"No OVERNIGHT-QUEUE.md for this project yet."}),(0,p.jsx)("button",{onClick:y,disabled:d,className:"px-2 py-1 border border-border hover:border-accent hover:text-accent text-[11px] disabled:opacity-50",children:"Create OVERNIGHT-QUEUE.md from template"})]}):l?(0,p.jsx)("textarea",{value:h,onChange:e=>c(e.target.value),spellCheck:!1,className:"w-full h-full p-3 bg-bg text-text text-[11px] font-mono resize-none outline-none"}):(0,p.jsx)("div",{className:"p-3 text-[12px] text-text prose prose-invert prose-sm max-w-none [&_h1]:text-[14px] [&_h1]:font-semibold [&_h1]:mt-3 [&_h1]:mb-2 [&_h2]:text-[13px] [&_h2]:font-semibold [&_h2]:mt-3 [&_h2]:mb-1.5 [&_h3]:text-[12px] [&_h3]:font-semibold [&_h3]:mt-2 [&_h3]:mb-1 [&_p]:my-1.5 [&_ul]:my-1.5 [&_ul]:pl-4 [&_ul]:list-disc [&_ol]:my-1.5 [&_ol]:pl-4 [&_ol]:list-decimal [&_li]:my-0.5 [&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-2 [&_blockquote]:text-text-muted [&_hr]:my-3 [&_hr]:border-border [&_code]:bg-bg-surface [&_code]:px-1 [&_code]:rounded [&_code]:text-[11px] [&_strong]:text-text [&_a]:text-accent [&_a]:underline",children:(0,p.jsx)(iG,{children:r})})})]})}function iQ({open:e,projectId:i,onClose:r}){return((0,_.useEffect)(()=>{if(!e)return;let i=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e,r]),e)?(0,p.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:r,role:"dialog","aria-modal":"true","aria-labelledby":"queue-modal-title",children:(0,p.jsxs)("div",{className:"relative mx-4 w-full max-w-3xl h-[80vh] flex flex-col rounded-lg border border-white/10 bg-neutral-950 shadow-2xl overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,p.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-white/10",children:[(0,p.jsx)("h2",{id:"queue-modal-title",className:"text-[12px] font-semibold text-white",children:"OVERNIGHT-QUEUE.md"}),(0,p.jsx)("button",{type:"button",onClick:r,"aria-label":"Close",className:"rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,p.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,p.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})})]}),(0,p.jsx)("div",{className:"flex-1 min-h-0",children:(0,p.jsx)(iJ,{projectId:i,startInEditMode:!0})})]})}):null}function iZ({percent:e}){let i=Math.round(e/100*20);return(0,p.jsxs)("span",{className:"font-mono text-[11px] tabular-nums whitespace-nowrap",children:[(0,p.jsx)("span",{className:"text-accent",children:"█".repeat(i)}),(0,p.jsx)("span",{className:"text-text-muted",children:"░".repeat(20-i)})]})}function i0({projectId:e}){let[i,r]=(0,_.useState)(null),s=(0,_.useCallback)(()=>{fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{e&&r(e)}).catch(()=>{})},[e]);return((0,_.useEffect)(()=>{s();let e=setInterval(s,3e4);return()=>clearInterval(e)},[s]),i)?i.items&&0!==i.items.length?i.complete?(0,p.jsxs)("div",{className:"border-t border-border",children:[(0,p.jsxs)("div",{className:"px-3 py-1.5 flex items-center gap-2",children:[(0,p.jsxs)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:["Current Batch: Batch ",i.batch_number??"—"]}),(0,p.jsx)("span",{className:"text-[10px] text-accent",children:"✅ COMPLETE"})]}),(0,p.jsxs)("div",{className:"px-3 pb-2 text-[11px] text-text-muted",children:["All ",i.items.length," items merged. Waiting for the next batch."]})]}):(0,p.jsxs)("div",{className:"border-t border-border",children:[(0,p.jsxs)("div",{className:"px-3 py-1.5 flex items-center gap-2 border-b border-border/40",children:[(0,p.jsxs)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:["Current Batch: Batch ",i.batch_number??"—"]}),(0,p.jsxs)("span",{className:"text-[10px] text-text-muted",children:["(",i.items.length," items)"]}),(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Current Batch"}),"— progress tracker for the active batch. Polls GitHub to resolve each issue's status (queued → in review → approved → merged)."]})]}),(0,p.jsx)("div",{className:"max-h-40 overflow-y-auto",children:i.items.map(e=>{let i=(0,p.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1 font-mono",children:[(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0 tabular-nums",children:["#",e.issue_number]}),(0,p.jsx)(iZ,{percent:e.progress}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted tabular-nums shrink-0 w-9 text-right",children:[e.progress,"%"]}),(0,p.jsx)("span",{className:"text-[11px] text-text truncate flex-1 min-w-0",children:e.label})]});return e.url?(0,p.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"block hover:bg-[#1a1a1a] transition-colors border-b border-border/30",children:i},e.issue_number):(0,p.jsx)("div",{children:i},e.issue_number)})}),i.summary&&(0,p.jsx)("div",{className:"px-3 py-1.5 text-[11px] text-text-muted border-t border-border/40",children:i.summary})]}):(0,p.jsxs)("div",{className:"border-t border-border",children:[(0,p.jsx)("div",{className:"px-3 py-1.5 flex items-center gap-2",children:(0,p.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:"Current Batch: (none)"})}),(0,p.jsx)("div",{className:"px-3 pb-2 text-[11px] text-text-muted",children:"No active batch. Ask Head to start one via the chat."})]}):(0,p.jsx)("div",{className:"px-3 py-1.5 text-[11px] text-text-muted border-t border-border",children:"Loading batch progress…"})}function i1({color:e}){return(0,p.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full shrink-0 ${e}`})}function i2({projectId:e}){let[i,r]=(0,_.useState)([]),[s,n]=(0,_.useState)([]),[o,l]=(0,_.useState)([]),[a,h]=(0,_.useState)([]),[c,d]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let i=!1;return fetch(`/api/queue?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(r=>{if(!i&&r&&!r.exists)return fetch(`/api/queue?project=${encodeURIComponent(e)}`,{method:"POST"})}).catch(()=>{}),()=>{i=!0}},[e]);let u=(0,_.useCallback)(()=>{fetch(`/api/github/issues?project=${encodeURIComponent(e)}`).then(e=>{if(!e.ok)throw Error(`${e.status}`);return e.json()}).then(e=>{Array.isArray(e)&&r(e)}).catch(()=>{}),fetch(`/api/github/prs?project=${encodeURIComponent(e)}`).then(e=>{if(!e.ok)throw Error(`${e.status}`);return e.json()}).then(e=>{Array.isArray(e)&&n(e)}).catch(()=>{}),fetch(`/api/github/closed-issues?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{Array.isArray(e)&&l(e)}).catch(()=>{}),fetch(`/api/github/merged-prs?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{Array.isArray(e)&&h(e)}).catch(()=>{})},[e]);return(0,_.useEffect)(()=>{u();let e=setInterval(u,3e4);return()=>clearInterval(e)},[u]),(0,p.jsxs)("div",{className:"flex flex-col h-full min-h-0",children:[(0,p.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,p.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col border-r border-border",children:[(0,p.jsxs)("div",{className:"px-3 py-1.5 border-b border-border shrink-0 flex items-center gap-1.5",children:[(0,p.jsxs)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:["Issues (",i.length,")"]}),(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Issues"}),"— open issues on the project's GitHub repo. Click any item to open it on GitHub."]})]}),(0,p.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[0===i.length&&(0,p.jsx)("div",{className:"px-3 py-2 text-[11px] text-text-muted",children:"No issues"}),i.map(e=>(0,p.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono hover:bg-[#1a1a1a] transition-colors cursor-pointer border-b border-border/50",children:[(0,p.jsx)(i1,{color:"OPEN"===e.state?"bg-accent":"bg-error"}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,p.jsx)("span",{className:"text-[11px] text-text truncate flex-1 min-w-0",children:e.title}),e.assignees?.[0]&&(0,p.jsx)("span",{className:"text-[10px] text-text-muted shrink-0",children:e.assignees[0].login})]},e.number)),(0,p.jsx)("div",{className:"px-3 pt-2 pb-1 text-[9px] text-text-muted uppercase tracking-wider",children:"Recently closed"}),0===o.length&&(0,p.jsx)("div",{className:"px-3 py-1 text-[11px] text-text-muted",children:"None yet"}),o.map(e=>(0,p.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono opacity-60 hover:opacity-100 hover:bg-[#1a1a1a] transition-all cursor-pointer border-b border-border/30",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted shrink-0",children:"✓"}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,p.jsx)("span",{className:"text-[11px] text-text-muted truncate flex-1 min-w-0",children:e.title})]},`closed-${e.number}`))]})]}),(0,p.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col",children:[(0,p.jsxs)("div",{className:"px-3 py-1.5 border-b border-border shrink-0 flex items-center gap-1.5",children:[(0,p.jsxs)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:["Pull Requests (",s.length,")"]}),(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Pull Requests"})," — open PRs awaiting review or merge. Click to open on GitHub."]})]}),(0,p.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[0===s.length&&(0,p.jsx)("div",{className:"px-3 py-2 text-[11px] text-text-muted",children:"No PRs"}),s.map(e=>{let i=e.reviews||[],r=e.reviewDecision||"REVIEW_REQUIRED",s={};for(let e of i){let i=(e.body||"").trim();/^(?:RE2|Reviewer2|T2b)\b/i.test(i)?s.re2=e.state:(/^(?:RE1|Reviewer1|T2a)\b/i.test(i)||/^##\s*Verdict/i.test(i))&&(s.re1=e.state)}return(0,p.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono hover:bg-[#1a1a1a] transition-colors cursor-pointer border-b border-border/50",children:[(0,p.jsx)(i1,{color:"APPROVED"===r?"bg-accent":"CHANGES_REQUESTED"===r?"bg-error":"bg-[#ffcc00]"}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,p.jsx)("span",{className:"text-[11px] text-text truncate flex-1 min-w-0",children:e.title}),e.assignees?.[0]&&(0,p.jsx)("span",{className:"text-[10px] text-text-muted shrink-0",children:e.assignees[0].login}),["re1","re2"].map(e=>{let i=s[e];return(0,p.jsxs)("span",{className:`text-[10px] shrink-0 ${i?"APPROVED"===i?"text-accent":"CHANGES_REQUESTED"===i?"text-error":"text-[#ffcc00]":"text-text-muted"}`,children:[e,":",i?"APPROVED"===i?"ok":"CHANGES_REQUESTED"===i?"chg":"rev":"—"]},e)}),(0,p.jsx)("span",{className:`text-[10px] shrink-0 ${function(e){if(!e||0===e.length)return"text-text-muted";let i=e.map(e=>e.state);return i.every(e=>"SUCCESS"===e)?"text-accent":i.some(e=>"FAILURE"===e||"ERROR"===e)?"text-error":"text-[#ffcc00]"}(e.statusCheckRollup)}`,children:function(e){if(!e||0===e.length)return"—";let i=e.map(e=>e.state);return i.every(e=>"SUCCESS"===e)?"pass":i.some(e=>"FAILURE"===e||"ERROR"===e)?"fail":"run"}(e.statusCheckRollup)})]},e.number)}),(0,p.jsx)("div",{className:"px-3 pt-2 pb-1 text-[9px] text-text-muted uppercase tracking-wider",children:"Recently merged"}),0===a.length&&(0,p.jsx)("div",{className:"px-3 py-1 text-[11px] text-text-muted",children:"None yet"}),a.map(e=>(0,p.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono opacity-60 hover:opacity-100 hover:bg-[#1a1a1a] transition-all cursor-pointer border-b border-border/30",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted shrink-0",children:"✓"}),(0,p.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,p.jsx)("span",{className:"text-[11px] text-text-muted truncate flex-1 min-w-0",children:e.title})]},`merged-${e.number}`))]})]})]}),(0,p.jsx)("div",{className:"shrink-0",children:(0,p.jsx)(i0,{projectId:e})}),(0,p.jsxs)("div",{className:"shrink-0 flex items-center justify-between px-3 py-1.5 border-t border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted font-mono",children:"OVERNIGHT-QUEUE.md"}),(0,p.jsxs)(g,{position:"above",children:[(0,p.jsx)("b",{children:"Overnight Queue"})," — the task queue file Head reads to pick the next ticket. Click Edit to modify batch contents and ordering."]})]}),(0,p.jsx)("button",{onClick:()=>d(!0),className:"px-2 py-0.5 text-[10px] text-text-muted hover:text-accent border border-border hover:border-accent transition-colors uppercase tracking-wider",children:"Edit"})]}),(0,p.jsx)(iQ,{open:c,projectId:e,onClose:()=>d(!1)})]})}var i5=e.i(67449);function i3({projectId:e}){let[i,r]=(0,_.useState)(null),[s,n]=(0,_.useState)(null),[o,l]=(0,_.useState)(!1),[a,h]=(0,_.useState)(null);(0,_.useEffect)(()=>{let i=()=>{fetch(`/api/agentchattr/${encodeURIComponent(e)}/health`).then(e=>e.ok?e.json():null).then(e=>{if(!e)return void h(null);if(e.autoRestart?.gaveUp)h("AC auto-restart failed 3x — manual restart required");else if(e.autoRestart?.lastRestart)if(300>Math.round((Date.now()-e.autoRestart.lastRestart)/1e3)){let i=new Date(e.autoRestart.lastRestart).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});h(`AC auto-restarted at ${i}`)}else h(null);else h(null)}).catch(()=>h(null))};i();let r=setInterval(i,3e4);return()=>clearInterval(r)},[e]);let c=()=>{setTimeout(()=>n(null),3e3)};(0,_.useEffect)(()=>{if(!o)return;let e=setTimeout(()=>l(!1),4e3);return()=>clearTimeout(e)},[o]);let d=async()=>{if(!o)return void l(!0);l(!1),r("stop");try{let i=await fetch(`/api/agentchattr/${encodeURIComponent(e)}/stop`,{method:"POST"}),r=await i.json();n(r.ok?"Stopped":"Failed")}catch{n("Error")}r(null),c()},u=async()=>{r("restart");try{let i=await fetch(`/api/agentchattr/${encodeURIComponent(e)}/restart`,{method:"POST"}),r=await i.json();if(r.ok&&r.pid){n(`AC restarted (PID: ${r.pid}) — resetting agents...`);try{let i=await fetch(`/api/agents/${encodeURIComponent(e)}/reset`,{method:"POST"}),r=await i.json();r.ok?n(`AC + ${r.restarted} agent${1!==r.restarted?"s":""} restarted`):n("AC restarted — agent reset failed")}catch{n("AC restarted — agent reset failed")}}else n(r.error||"Failed to restart")}catch{n("Error")}r(null),c()},f=async()=>{r("reset");try{let i=await fetch(`/api/agents/${encodeURIComponent(e)}/reset`,{method:"POST"}),r=await i.json();n(r.ok?`Reset — ${r.restarted} of ${r.total} agent${1!==r.total?"s":""} restarted`:r.error||"Failed")}catch{n("Error")}r(null),c()};return(0,p.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,p.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider font-semibold",children:"Server"}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,p.jsx)("button",{onClick:d,disabled:!!i,className:`px-1.5 py-0.5 text-[10px] border transition-colors disabled:opacity-50 ${o?"text-error border-error/60 bg-error/10 hover:bg-error/20":"text-text-muted border-border hover:text-error hover:border-error/40"}`,children:"stop"===i?"...":o?"Confirm Stop?":"Stop"}),(0,p.jsx)("button",{onClick:u,disabled:!!i,className:"px-1.5 py-0.5 text-[10px] text-text-muted border border-border hover:text-accent hover:border-accent/40 transition-colors disabled:opacity-50",children:"restart"===i?"...":"Restart"}),(0,p.jsx)("button",{onClick:f,disabled:!!i,className:"px-1.5 py-0.5 text-[10px] text-text-muted border border-border hover:text-accent hover:border-accent/40 transition-colors disabled:opacity-50",children:"reset"===i?"...":"Reset Agents"})]}),s&&(0,p.jsx)("div",{className:"text-[10px] text-accent",children:s}),a&&!s&&(0,p.jsx)("div",{className:`text-[10px] ${a.includes("failed")?"text-error":"text-[#ffcc00]"}`,children:a})]})}function i4(e){return Number.isFinite(e)?Math.min(Math.max(e,.1),24):3}function i6(e){let i=Math.floor(e/3600),r=Math.floor(e%3600/60);return i>0?`${i}h ${r}m`:`${r}m`}function i9(){let[e,i]=(0,_.useState)(!1),[r,s]=(0,_.useState)(null),[n,o]=(0,_.useState)(""),[l,a]=(0,_.useState)(!1),[h,c]=(0,_.useState)(String(3)),[d,u]=(0,_.useState)(!1),[f,m]=(0,_.useState)(!1),[g,v]=(0,_.useState)(!1),[x,b]=(0,_.useState)(!1),[y,S]=(0,_.useState)(!0),[w,C]=(0,_.useState)("soft-chime"),[k,E]=(0,_.useState)(!0);(0,_.useEffect)(()=>{S((0,i5.getNotificationEnabled)()),C((0,i5.getNotificationChoice)()),E((0,i5.getNotificationBackgroundOnly)())},[]);let N=(0,_.useCallback)(()=>{fetch("/api/caffeinate/status").then(e=>e.ok?e.json():null).then(e=>{e&&(i(e.active),s(e.remaining),o(e.platform))}).catch(()=>{})},[]);(0,_.useEffect)(()=>{N();let e=setInterval(N,5e3);return()=>clearInterval(e)},[N]);let R=e=>{fetch("/api/caffeinate/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({duration:e})}).then(e=>e.json()).then(r=>{r.ok&&(i(!0),s(e||null))}).catch(()=>{}),a(!1)},D=!n||"darwin"===n;return(0,p.jsxs)("div",{className:"flex flex-col md:flex-row md:items-start gap-2 md:gap-6 relative",children:[D&&(0,p.jsxs)("div",{className:"flex flex-col gap-0.5 relative",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-text-muted uppercase tracking-wider font-semibold",children:[(0,p.jsx)("span",{children:"Keep Mac Awake"}),(0,p.jsx)("button",{type:"button","aria-label":"About Keep Mac Awake",onClick:()=>v(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"})]}),g&&(0,p.jsxs)("div",{className:"absolute left-0 top-4 z-30 w-64 p-2 text-[10px] leading-snug text-text bg-bg-surface border border-border rounded shadow-lg",children:[(0,p.jsx)("b",{children:"Keep Mac Awake"})," runs macOS ",(0,p.jsx)("code",{children:"caffeinate"})," to stop the screen, disk, and system idle timers from sleeping your Mac during an overnight run. Make sure the laptop is plugged in — caffeinate blocks sleep but not battery drain."]}),(0,p.jsx)("div",{className:"text-[10px] text-text-muted leading-tight",children:e&&null!==r&&r>0?`Awake for ${i6(r)} more — keep Mac plugged in`:e&&null===r?"Awake indefinitely — keep Mac plugged in":"Prevents your Mac from sleeping during overnight runs."}),(0,p.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap mt-0.5",children:(0,p.jsxs)("button",{onClick:()=>e?void fetch("/api/caffeinate/stop",{method:"POST"}).then(()=>{i(!1),s(null)}).catch(()=>{}):a(!l),title:"Keep Mac awake (caffeinate)",className:`px-1.5 py-0.5 text-[10px] border transition-colors ${e?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:[e?"Awake":"Start",e&&null!==r&&r>0&&(0,p.jsx)("span",{className:"ml-1 text-accent/70",children:i6(r)}),e&&null===r&&(0,p.jsx)("span",{className:"ml-1 text-accent/70",children:"on"})]})})]}),D&&(0,p.jsx)("div",{className:"border-t border-border/40 md:border-t-0 md:w-px md:h-auto md:self-stretch md:bg-border"}),(0,p.jsxs)("div",{className:"flex flex-col gap-0.5 relative",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-text-muted uppercase tracking-wider font-semibold",children:[(0,p.jsx)("span",{children:"Notification Sound"}),(0,p.jsx)("button",{type:"button","aria-label":"About Notification Sound",onClick:()=>b(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"})]}),x&&(0,p.jsxs)("div",{className:"absolute left-0 top-4 z-30 w-64 p-2 text-[10px] leading-snug text-text bg-bg-surface border border-border rounded shadow-lg",children:[(0,p.jsx)("b",{children:"Notification Sound"}),"plays a brief chime when an agent posts a new message (not your own sends, not system events). Sound choice picks one of the bundled chimes. Background-only mode suppresses the chime while the tab is focused — ding only when you're looking elsewhere. All prefs persist in localStorage."]}),(0,p.jsx)("div",{className:"text-[10px] text-text-muted leading-tight",children:"Plays a chime when an agent posts a new message."}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap mt-0.5",children:[(0,p.jsxs)("button",{type:"button",onClick:()=>{let e=!y;S(e),(0,i5.setNotificationEnabled)(e)},title:y?"Notification sound on (click to mute)":"Notification sound off (click to unmute)",className:`px-1.5 py-0.5 text-[10px] border transition-colors ${y?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:[y?"🔔":"🔕"," Sound"]}),y&&(0,p.jsx)("select",{value:w,onChange:e=>(e=>{if(C(e),(0,i5.setNotificationChoice)(e),y)try{let i=new Audio(`/sounds/${e}.mp3`);i.volume=.6,i.play().catch(()=>{})}catch{}})(e.target.value),title:"Notification sound",className:"bg-transparent border border-border px-1 py-0.5 text-[10px] text-text outline-none focus:border-accent cursor-pointer",children:i5.NOTIFICATION_SOUND_OPTIONS.map(e=>(0,p.jsx)("option",{value:e.value,className:"bg-bg-surface",children:e.label},e.value))})]}),y&&(0,p.jsxs)("label",{className:"flex items-center gap-1 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,p.jsx)("input",{type:"checkbox",checked:k,onChange:e=>{var i;E(i=e.target.checked),(0,i5.setNotificationBackgroundOnly)(i)}}),"Only when tab is in background"]})]}),l&&!e&&(0,p.jsxs)("div",{className:"absolute bottom-full left-0 mb-1 p-2 border border-border bg-bg-surface z-20 min-w-[220px] flex flex-col gap-1.5",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between",children:[(0,p.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:"Keep Awake"}),(0,p.jsx)("button",{type:"button","aria-label":"About Keep Awake",onClick:()=>m(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"})]}),f&&(0,p.jsxs)("div",{className:"p-1.5 text-[10px] leading-snug text-text bg-bg border border-border/60 rounded",children:[(0,p.jsx)("b",{children:"Keep Awake"})," prevents your Mac from sleeping for the duration you set. Use this when you want agents to keep working overnight.",(0,p.jsx)("br",{}),(0,p.jsx)("br",{}),"Under the hood, this runs macOS's ",(0,p.jsx)("code",{children:"caffeinate"})," command. While it's active your screen, disk, and system idle timers are all paused — make sure your Mac is ",(0,p.jsx)("b",{children:"plugged in"})," to avoid draining the battery."]}),(0,p.jsx)("p",{className:"text-[10px] text-[#ffcc00]",children:"Make sure Mac is plugged in"}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px]",children:[(0,p.jsx)("span",{className:"text-text-muted",children:"for"}),(0,p.jsx)("input",{type:"number",value:h,onChange:e=>c(e.target.value),onBlur:()=>{let e=parseFloat(h);c(String(Math.round(10*(Number.isFinite(e)?i4(e):3))/10))},disabled:d,min:.1,max:24,step:.1,className:"w-14 bg-transparent border border-border px-1 py-0.5 text-text outline-none focus:border-accent text-center disabled:opacity-40"}),(0,p.jsx)("span",{className:"text-text-muted",children:"hours"})]}),(0,p.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,p.jsx)("input",{type:"checkbox",checked:d,onChange:e=>u(e.target.checked)}),"Until stopped (no expiry)"]}),(0,p.jsx)("button",{type:"button",onClick:()=>{if(d)return void R(0);let e=parseFloat(h);R(Math.round(3600*(Number.isFinite(e)?i4(e):3)))},className:"self-start px-2 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors",children:"Start"})]})]})}function i8({projectId:e}){return(0,p.jsx)("div",{className:"border-t border-border px-3 py-2",children:(0,p.jsxs)("div",{className:"flex flex-col md:flex-row md:items-start gap-2 md:gap-6",children:[(0,p.jsx)(i3,{projectId:e}),(0,p.jsx)("div",{className:"border-t border-border/40 md:border-t-0 md:w-px md:h-auto md:self-stretch md:bg-border"}),(0,p.jsx)(i9,{})]})})}var i7=e.i(47167),re=Object.defineProperty,rt=Object.getOwnPropertyDescriptor,ri=(e,i,r,s)=>{for(var n,o=s>1?void 0:s?rt(i,r):i,l=e.length-1;l>=0;l--)(n=e[l])&&(o=(s?n(i,r,o):n(o))||o);return s&&o&&re(i,r,o),o},rr=(e,i)=>(r,s)=>i(r,s,e),rs="Terminal input",rn="Too much output to announce, navigate to rows manually to read";function ro(e,i,r,s){var n;n=e=e.replace(/\r?\n/g,"\r"),e=r.decPrivateModes.bracketedPasteMode&&!0!==s.rawOptions.ignoreBracketedPasteMode?"\x1b[200~"+n+"\x1b[201~":n,r.triggerDataEvent(e,!0),i.value=""}function rl(e,i,r){let s=r.getBoundingClientRect(),n=e.clientX-s.left-10,o=e.clientY-s.top-10;i.style.width="20px",i.style.height="20px",i.style.left=`${n}px`,i.style.top=`${o}px`,i.style.zIndex="1000",i.focus()}function ra(e,i,r,s,n){rl(e,i,r),n&&s.rightClickSelect(e),i.value=s.selectionText,i.select()}function rh(e){return e>65535?String.fromCharCode(((e-=65536)>>10)+55296)+String.fromCharCode(e%1024+56320):String.fromCharCode(e)}function rc(e,i=0,r=e.length){let s="";for(let n=i;n<r;++n){let i=e[n];i>65535?(i-=65536,s+=String.fromCharCode((i>>10)+55296)+String.fromCharCode(i%1024+56320)):s+=String.fromCharCode(i)}return s}var rd=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,i){let r=e.length;if(!r)return 0;let s=0,n=0;if(this._interim){let r=e.charCodeAt(n++);56320<=r&&r<=57343?i[s++]=(this._interim-55296)*1024+r-56320+65536:(i[s++]=this._interim,i[s++]=r),this._interim=0}for(let o=n;o<r;++o){let n=e.charCodeAt(o);if(55296<=n&&n<=56319){if(++o>=r)return this._interim=n,s;let l=e.charCodeAt(o);56320<=l&&l<=57343?i[s++]=(n-55296)*1024+l-56320+65536:(i[s++]=n,i[s++]=l);continue}65279!==n&&(i[s++]=n)}return s}},ru=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,i){let r=e.length;if(!r)return 0;let s=0,n,o,l,a,h=0,c=0;if(this.interim[0]){let n=!1,o=this.interim[0];o&=(224&o)==192?31:(240&o)==224?15:7;let l=0,a;for(;(a=63&this.interim[++l])&&l<4;)o<<=6,o|=a;let h=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,d=h-l;for(;c<d;){if(c>=r)return 0;if((192&(a=e[c++]))!=128){c--,n=!0;break}this.interim[l++]=a,o<<=6,o|=63&a}n||(2===h?o<128?c--:i[s++]=o:3===h?o<2048||o>=55296&&o<=57343||65279===o||(i[s++]=o):o<65536||o>1114111||(i[s++]=o)),this.interim.fill(0)}let d=r-4,u=c;for(;u<r;){for(;u<d&&!(128&(n=e[u]))&&!(128&(o=e[u+1]))&&!(128&(l=e[u+2]))&&!(128&(a=e[u+3]));)i[s++]=n,i[s++]=o,i[s++]=l,i[s++]=a,u+=4;if((n=e[u++])<128)i[s++]=n;else if((224&n)==192){if(u>=r)return this.interim[0]=n,s;if((192&(o=e[u++]))!=128||(h=(31&n)<<6|63&o)<128){u--;continue}i[s++]=h}else if((240&n)==224){if(u>=r)return this.interim[0]=n,s;if((192&(o=e[u++]))!=128){u--;continue}if(u>=r)return this.interim[0]=n,this.interim[1]=o,s;if((192&(l=e[u++]))!=128){u--;continue}if((h=(15&n)<<12|(63&o)<<6|63&l)<2048||h>=55296&&h<=57343||65279===h)continue;i[s++]=h}else if((248&n)==240){if(u>=r)return this.interim[0]=n,s;if((192&(o=e[u++]))!=128){u--;continue}if(u>=r)return this.interim[0]=n,this.interim[1]=o,s;if((192&(l=e[u++]))!=128){u--;continue}if(u>=r)return this.interim[0]=n,this.interim[1]=o,this.interim[2]=l,s;if((192&(a=e[u++]))!=128){u--;continue}if((h=(7&n)<<18|(63&o)<<12|(63&l)<<6|63&a)<65536||h>1114111)continue;i[s++]=h}}return s}},rf=class e{constructor(){this.fg=0,this.bg=0,this.extended=new rp}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let i=new e;return i.fg=this.fg,i.bg=this.bg,i.extended=this.extended.clone(),i}isInverse(){return 0x4000000&this.fg}isBold(){return 0x8000000&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:0x10000000&this.fg}isBlink(){return 0x20000000&this.fg}isInvisible(){return 0x40000000&this.fg}isItalic(){return 0x4000000&this.bg}isDim(){return 0x8000000&this.bg}isStrikethrough(){return 0x80000000&this.fg}isProtected(){return 0x20000000&this.bg}isOverline(){return 0x40000000&this.bg}getFgColorMode(){return 0x3000000&this.fg}getBgColorMode(){return 0x3000000&this.bg}isFgRGB(){return(0x3000000&this.fg)==0x3000000}isBgRGB(){return(0x3000000&this.bg)==0x3000000}isFgPalette(){return(0x3000000&this.fg)==0x1000000||(0x3000000&this.fg)==0x2000000}isBgPalette(){return(0x3000000&this.bg)==0x1000000||(0x3000000&this.bg)==0x2000000}isFgDefault(){return(0x3000000&this.fg)==0}isBgDefault(){return(0x3000000&this.bg)==0}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(0x3000000&this.fg){case 0x1000000:case 0x2000000:return 255&this.fg;case 0x3000000:return 0xffffff&this.fg;default:return -1}}getBgColor(){switch(0x3000000&this.bg){case 0x1000000:case 0x2000000:return 255&this.bg;case 0x3000000:return 0xffffff&this.bg;default:return -1}}hasExtendedAttrs(){return 0x10000000&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-0x10000001:this.bg|=0x10000000}getUnderlineColor(){if(0x10000000&this.bg&&~this.extended.underlineColor)switch(0x3000000&this.extended.underlineColor){case 0x1000000:case 0x2000000:return 255&this.extended.underlineColor;case 0x3000000:return 0xffffff&this.extended.underlineColor}return this.getFgColor()}getUnderlineColorMode(){return 0x10000000&this.bg&&~this.extended.underlineColor?0x3000000&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x3000000:this.isFgRGB()}isUnderlineColorPalette(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x1000000||(0x3000000&this.extended.underlineColor)==0x2000000:this.isFgPalette()}isUnderlineColorDefault(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 0x10000000&this.fg?0x10000000&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},rp=class e{constructor(e=0,i=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=i}get ext(){return this._urlId?-0x1c000001&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(0x1c000000&this._ext)>>26}set underlineStyle(e){this._ext&=-0x1c000001,this._ext|=e<<26&0x1c000000}get underlineColor(){return 0x3ffffff&this._ext}set underlineColor(e){this._ext&=-0x4000000,this._ext|=0x3ffffff&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(0xe0000000&this._ext)>>29;return e<0?0xfffffff8^e:e}set underlineVariantOffset(e){this._ext&=0x1fffffff,this._ext|=e<<29&0xe0000000}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},r_=class e extends rf{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new rp,this.combinedData=""}static fromCharData(i){let r=new e;return r.setFromCharData(i),r}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?rh(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let i=!1;if(e[1].length>2)i=!0;else if(2===e[1].length){let r=e[1].charCodeAt(0);if(55296<=r&&r<=56319){let s=e[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(r-55296)*1024+s-56320+65536|e[2]<<22:i=!0}else i=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;i&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},rm="di$target",rg="di$dependencies",rv=new Map;function rx(e){if(rv.has(e))return rv.get(e);let i=function(e,r,s){var n,o,l;if(3!=arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");n=i,o=e,l=s,o[rm]===o?o[rg].push({id:n,index:l}):(o[rg]=[{id:n,index:l}],o[rm]=o)};return i._id=e,rv.set(e,i),i}var rb=rx("BufferService"),ry=rx("CoreMouseService"),rS=rx("CoreService"),rw=rx("CharsetService"),rC=rx("InstantiationService"),rk=rx("LogService"),rE=rx("OptionsService"),rN=rx("OscLinkService"),rR=rx("UnicodeService"),rD=rx("DecorationService"),rM=class{constructor(e,i,r){this._bufferService=e,this._optionsService=i,this._oscLinkService=r}provideLinks(e,i){let r=this._bufferService.buffer.lines.get(e-1);if(!r)return void i(void 0);let s=[],n=this._optionsService.rawOptions.linkHandler,o=new r_,l=r.getTrimmedLength(),a=-1,h=-1,c=!1;for(let i=0;i<l;i++)if(!(-1===h&&!r.hasContent(i))){if(r.loadCell(i,o),o.hasExtendedAttrs()&&o.extended.urlId)if(-1===h){h=i,a=o.extended.urlId;continue}else c=o.extended.urlId!==a;else -1!==h&&(c=!0);if(c||-1!==h&&i===l-1){let r=this._oscLinkService.getLinkData(a)?.uri;if(r){let o={start:{x:h+1,y:e},end:{x:i+ +(!c&&i===l-1),y:e}},a=!1;if(!n?.allowNonHttpProtocols)try{let e=new URL(r);["http:","https:"].includes(e.protocol)||(a=!0)}catch{a=!0}a||s.push({text:r,range:o,activate:(e,i)=>n?n.activate(e,i,o):function(e){if(confirm(`Do you want to navigate to ${e}?
2
2
 
3
3
  WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}(i),hover:(e,i)=>n?.hover?.(e,i,o),leave:(e,i)=>n?.leave?.(e,i,o)})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=i,a=o.extended.urlId):(h=-1,a=-1)}}i(s)}};rM=ri([rr(0,rb),rr(1,rE),rr(2,rN)],rM);var rT=rx("CharSizeService"),rP=rx("CoreBrowserService"),rj=rx("MouseService"),rB=rx("RenderService"),rL=rx("SelectionService"),rA=rx("CharacterJoinerService"),rI=rx("ThemeService"),rO=rx("LinkProviderService"),rz=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?r$.isErrorNoTelemetry(e)?new r$(e.message+`
4
4
 
@@ -22,6 +22,6 @@ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){t
22
22
  @head: Merge any PR with both approvals, assign next from ${i}.
23
23
  @dev: Work on assigned ticket or address review feedback.
24
24
  @re1 & @re2: Review open PRs. If @dev pushed fixes, re-review. Post verdict on PR AND notify @dev here.
25
- ALL: Communicate via this chat by tagging agents. Your terminal is NOT visible.`},[e]),[j,B]=(0,_.useState)(!1),[L,A]=(0,_.useState)(!1),[I,O]=(0,_.useState)(null),z=(0,_.useRef)(null),H=(0,_.useRef)(!1);(0,_.useEffect)(()=>{H.current=!1,z.current=null,B(!1),A(!1),O(null)},[e]),(0,_.useEffect)(()=>{H.current||fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i)return;let r=(i.projects||[]).find(i=>i.id===e);r?.trigger_auto&&B(!0),H.current=!0}).catch(()=>{})},[e]);let F=(0,_.useCallback)(async()=>{try{let i=await fetch("/api/triggers");if(!i.ok)throw Error(`${i.status}`);let s=(await i.json())[e]||null;if(r(s),s){if(s.message&&!y.current&&(n(s.message),y.current=s.message),!S.current)if(s.enabled&&s.interval){let e=Math.max(1,Math.round(s.interval/6e4));l(e),h(String(e))}else"number"==typeof s.intervalMin&&s.intervalMin>0&&(l(s.intervalMin),h(String(s.intervalMin)));!w.current&&"number"==typeof s.durationMin&&s.durationMin>=0&&(d(s.durationMin),f(aI(s.durationMin)))}N(null)}catch(e){N(e.message)}},[e]);(0,_.useEffect)(()=>{s||n(P)},[P,s]),(0,_.useEffect)(()=>{F();let e=window.setInterval(F,5e3);return()=>window.clearInterval(e)},[F]),(0,_.useEffect)(()=>{if(!i?.enabled){D(""),T("");return}let e=()=>{if(i.nextAt&&D(aO(Math.max(0,i.nextAt-Date.now()))),i.expiresAt){let e=Math.max(0,i.expiresAt-Date.now());T(aO(e)),e<=0&&F()}else T("")};e();let r=window.setInterval(e,1e3);return()=>window.clearInterval(r)},[i?.enabled,i?.nextAt,i?.expiresAt,F]);let W=async()=>{k(!0),N(null);let i=parseFloat(u),r=Math.round(60*(Number.isFinite(i)?aA(i):3));r!==c&&(d(r),f(aI(r)));let n=parseInt(a,10),p=Number.isFinite(n)?Math.max(1,Math.min(1440,n)):15;p!==o&&(l(p),h(String(p)));try{let i=await fetch(`/api/triggers/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({interval:p,duration:r,message:s})});if(!i.ok)throw Error(`${i.status}`);v(!1),b(!1),await F()}catch(e){N(e.message)}finally{k(!1)}},$=async()=>{k(!0),N(null);try{let n=await fetch(`/api/triggers/${encodeURIComponent(e)}/stop`,{method:"POST"});if(!n.ok)throw Error(`${n.status}`);A(!1),r({...i||{interval:0,lastSent:null,nextAt:null,expiresAt:null,message:s,intervalMin:o,durationMin:c},enabled:!1}),await F()}catch(e){N(e.message)}finally{k(!1)}},U=(0,_.useCallback)(async()=>{let i=!j;B(i),i||(O(null),z.current=null);try{let r=await fetch("/api/config");if(!r.ok)return;let s=await r.json(),n=(s.projects||[]).find(i=>i.id===e);n&&(n.trigger_auto=i,await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}))}catch{}},[j,e]),K=(0,_.useRef)(j),q=(0,_.useRef)(i);(0,_.useEffect)(()=>{K.current=j},[j]),(0,_.useEffect)(()=>{q.current=i},[i]);let V=(0,_.useCallback)(async()=>{if(K.current)try{let i=await fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`);if(!i.ok)return;let r=await i.json(),s=r.items.length>0,n=z.current;if(z.current={complete:r.complete,hasItems:s},!n){if(s&&!r.complete&&!q.current?.enabled){A(!0),O(null);let i=parseFloat(u),r=Number.isFinite(i)?aA(i):3,s=Math.round(60*r),n=parseInt(a,10),o=Number.isFinite(n)?Math.max(1,Math.min(1440,n)):15;await fetch(`/api/triggers/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({interval:o,duration:s,message:y.current||P})}),await F()}return}if(s&&r.complete&&!n.complete&&q.current?.enabled){await fetch(`/api/triggers/${encodeURIComponent(e)}/stop`,{method:"POST"}),A(!1),O("Batch complete — trigger paused. Waiting for next batch."),await F();return}if(s&&!r.complete&&(n.complete||!n.hasItems)&&!q.current?.enabled){A(!0),O(null);let i=parseFloat(u),r=Number.isFinite(i)?aA(i):3,s=Math.round(60*r),n=parseInt(a,10),o=Number.isFinite(n)?Math.max(1,Math.min(1440,n)):15;await fetch(`/api/triggers/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({interval:o,duration:s,message:y.current||P})}),await F()}}catch{}},[e,u,a,P,F]);(0,_.useEffect)(()=>{if(!j)return;V();let e=window.setInterval(V,3e4);return()=>window.clearInterval(e)},[j,V]);let Y=!!i?.enabled;return(0,p.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsxs)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:["Scheduled Trigger",Y?L?" (auto)":" (running)":""]}),(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Scheduled Trigger"})," sends a periodic message to all agents on a timer. Use this to keep the autonomous workflow running overnight. First message fires after the configured interval, not immediately."]})]}),(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[E&&(0,p.jsxs)("span",{className:"text-[10px] text-error",children:["err: ",E]}),(0,p.jsxs)("button",{type:"button",onClick:U,title:j?"Auto-trigger ON — trigger follows batch lifecycle":"Auto-trigger OFF — manual start/stop only",className:`px-1.5 py-0.5 text-[10px] border transition-colors ${j?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:["Auto ",j?"●":"○"]})]})]}),I&&(0,p.jsx)("div",{className:"px-3 py-1 text-[10px] text-accent bg-accent/5 border-b border-border/50",children:I}),Y?(0,p.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[(0,p.jsx)("div",{className:"text-[11px] text-text-muted",children:"Sending:"}),(0,p.jsx)("pre",{className:"text-[11px] font-mono whitespace-pre-wrap text-text bg-bg-surface border border-border p-2 max-h-28 overflow-auto",children:(i?.message||s).slice(0,400)}),(0,p.jsxs)("div",{className:"flex items-center gap-3 flex-wrap text-[11px]",children:[(0,p.jsxs)("span",{className:"flex items-center gap-1",children:[(0,p.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:[(0,p.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,p.jsx)("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),(0,p.jsx)("span",{className:"text-accent",children:"Running"})]}),(0,p.jsxs)("span",{className:"tabular-nums text-text",children:["Next: ",R]}),M&&(0,p.jsxs)("span",{className:"tabular-nums text-text-muted",children:["Stops in: ",M]}),!i?.expiresAt&&(0,p.jsx)("span",{className:"text-text-muted",children:"(until stopped)"})]}),(0,p.jsx)("button",{onClick:$,disabled:C,className:"self-start px-3 py-1 text-[11px] text-text-muted border border-border hover:text-error hover:border-error/40 disabled:opacity-50 transition-colors",children:C?"Stopping…":"Stop Trigger"})]}):(0,p.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[(0,p.jsx)("label",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:"Message"}),(0,p.jsx)("textarea",{value:s,onChange:e=>n(e.target.value),rows:6,spellCheck:!1,className:"w-full bg-bg text-text text-[11px] font-mono p-2 border border-border outline-none focus:border-accent resize-y"}),(0,p.jsxs)("div",{className:"flex items-center gap-2 flex-wrap text-[11px]",children:[(0,p.jsx)("span",{className:"text-text-muted",children:"Send every"}),(0,p.jsx)("input",{type:"number",value:a,onChange:e=>{h(e.target.value),v(!0)},onBlur:()=>{let e=parseInt(a,10),i=Number.isFinite(e)?Math.max(1,Math.min(1440,e)):15;l(i),h(String(i))},min:1,max:1440,className:"w-12 bg-transparent border border-border px-1 py-0.5 text-[11px] text-text outline-none focus:border-accent text-center"}),(0,p.jsx)("span",{className:"text-text-muted",children:"min for"}),(0,p.jsx)("input",{type:"number",value:u,onChange:e=>{f(e.target.value),b(!0)},onBlur:()=>{let e=parseFloat(u),i=Math.round(60*(Number.isFinite(e)?aA(e):3));d(i),f(aI(i))},min:.1,max:24,step:.1,className:"w-14 bg-transparent border border-border px-1 py-0.5 text-[11px] text-text outline-none focus:border-accent text-center"}),(0,p.jsx)("span",{className:"text-text-muted",children:"hours"})]}),(0,p.jsx)("button",{onClick:W,disabled:C||!s.trim(),className:"self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:C?"Starting…":"Start Trigger"})]})]})}function aH({open:e,initialChatId:i="",onClose:r,onSave:s}){let[n,o]=(0,_.useState)(""),[l,a]=(0,_.useState)(i),[h,c]=(0,_.useState)(!1),[d,u]=(0,_.useState)(null),[f,m]=(0,_.useState)(!1);if((0,_.useEffect)(()=>{e&&a(i)},[e,i]),(0,_.useEffect)(()=>{if(!e)return;let i=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e,r]),!e)return null;let g=async()=>{c(!0),u(null);try{await s(n.trim(),l.trim()),r()}catch(e){u(e.message||"Save failed")}finally{c(!1)}};return(0,p.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:r,role:"dialog","aria-modal":"true","aria-labelledby":"telegram-setup-title",children:(0,p.jsxs)("div",{className:"relative mx-4 max-w-xl w-full max-h-[90vh] overflow-auto rounded-lg border border-white/10 bg-neutral-950 p-6 shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,p.jsx)("button",{type:"button",onClick:r,"aria-label":"Close",className:"absolute right-3 top-3 rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,p.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,p.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})}),(0,p.jsx)("h2",{id:"telegram-setup-title",className:"text-base font-semibold text-white",children:"Set up your Telegram Bridge"}),(0,p.jsx)("p",{className:"mt-2 text-[12px] leading-relaxed text-neutral-300",children:"The bridge forwards AgentChattr messages from your project to a Telegram chat, so you can read and reply on your phone."}),(0,p.jsxs)("div",{className:"mt-4 text-[12px] text-neutral-300 space-y-3",children:[(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 1 — Create a Telegram bot"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["Open Telegram and search for ",(0,p.jsx)("b",{children:"@BotFather"}),"."]}),(0,p.jsxs)("li",{children:["Send ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"/newbot"})," and follow the prompts."]}),(0,p.jsxs)("li",{children:["Choose a name and username (must end in ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"bot"}),")."]}),(0,p.jsxs)("li",{children:["BotFather replies with a ",(0,p.jsx)("b",{children:"bot token"})," that looks like ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"123456:ABC-DEF1234ghIkl…"}),". Copy it."]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 2 — Get your chat ID"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["Open Telegram and search for your new bot by its exact ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"@username"}),"."]}),(0,p.jsxs)("li",{children:["Tap ",(0,p.jsx)("b",{children:"Start"})," and send any message (e.g. ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"hello"}),")."," ",(0,p.jsxs)("span",{className:"text-neutral-400",children:["You must send at least one message first — ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"getUpdates"})," returns ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:'{"ok":true,"result":[]}'})," until Telegram has an inbound message on record."]})]}),(0,p.jsxs)("li",{children:["Open this URL in your browser (replace ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"YOUR_TOKEN"}),"):",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"https://api.telegram.org/botYOUR_TOKEN/getUpdates"})]}),(0,p.jsxs)("li",{children:["Look for ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:'"chat":{"id":<NUMBER>'})," in the JSON. That number is your ",(0,p.jsx)("b",{children:"chat id"}),". Group chat ids are negative (e.g. ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"-1001234567890"}),") — paste the full value ",(0,p.jsx)("b",{children:"including the minus sign"}),"."]})]}),(0,p.jsx)("p",{className:"mt-1 text-neutral-400",children:"Or use one of these terminal one-liners:"}),(0,p.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-400",children:["With ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"jq"})," (cleanest):"]}),(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"curl -s \"https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates\" | jq '.result[-1].message.chat.id'"}),(0,p.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-400",children:["Without ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"jq"})," (pure grep):"]}),(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:'curl -s "https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates" | grep -o \'"chat":{"id":-\\?[0-9]*\' | tail -1'}),(0,p.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-500",children:["The first message from a brand-new bot sometimes doesn't propagate to ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"getUpdates"})," instantly. If ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"result"})," is empty, send 2-3 more messages and retry."]}),(0,p.jsx)("button",{type:"button",onClick:()=>m(e=>!e),className:"mt-2 text-[11px] text-accent hover:underline","aria-expanded":f,children:f?"Hide troubleshooting ▾":"Still empty? Troubleshooting ▸"}),f&&(0,p.jsxs)("div",{className:"mt-2 p-2 border border-white/10 rounded text-[11px] text-neutral-300 space-y-2",children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Webhook conflict."})," Something else may be consuming updates. Check and delete any active webhook:",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:'curl -s "https://api.telegram.org/bot<TOKEN>/getWebhookInfo" curl -s "https://api.telegram.org/bot<TOKEN>/deleteWebhook"'})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Stale bridge process."}),"A leftover bridge from a previous install will hold the update queue. Two consumers can't share one bot:",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"ps aux | grep telegram_bridge | grep -v grep"}),"Kill any PIDs that show up before retrying the curl."]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Token / bot mismatch."})," A token that doesn't match the bot you're messaging silently returns empty results. Confirm the token's ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"username"})," matches the ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"@username"}),"you're chatting with:",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:'curl -s "https://api.telegram.org/bot<TOKEN>/getMe"'})]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 3 — Paste credentials below"}),(0,p.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,p.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Bot token",(0,p.jsx)("input",{type:"password",value:n,onChange:e=>o(e.target.value),placeholder:"123456:ABC-DEF…",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),(0,p.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Chat id",(0,p.jsx)("input",{type:"text",value:l,onChange:e=>a(e.target.value),placeholder:"123456789",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),d&&(0,p.jsx)("div",{className:"text-[11px] text-error",children:d}),(0,p.jsx)("button",{type:"button",onClick:g,disabled:h||!n.trim()||!l.trim(),className:"mt-1 self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:h?"Saving…":"Save and start bridge"})]})]})]})]})})}async function aF(e,i){let r=await fetch(`/api/telegram?action=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),s=await r.json();if(!r.ok||!1===s.ok)throw Error(s.error||`${r.status}`);return s}function aW({projectId:e}){let[i,r]=(0,_.useState)(null),[s,n]=(0,_.useState)(!1),[o,l]=(0,_.useState)(null),[a,h]=(0,_.useState)(null),[c,d]=(0,_.useState)(!1),[u,f]=(0,_.useState)(null),m=(0,_.useCallback)(async()=>{try{let i=await fetch(`/api/telegram?project=${encodeURIComponent(e)}`);if(!i.ok)throw Error(`${i.status}`);let s=await i.json();r(s),h(null)}catch(e){h(e.message)}},[e]);(0,_.useEffect)(()=>{m();let e=window.setInterval(m,5e3);return()=>window.clearInterval(e)},[m]);let v=e=>{let i=Array.isArray(e?.patched_projects)?e.patched_projects:[];i.length>0?f(`Install Bridge patched ${i.length} AgentChattr config(s) (${i.join(", ")}) to declare [agents.telegram-bridge]. Click SERVER → Restart so AgentChattr picks up the new agent slug, then click Start again. Without the restart, Start will fail with a 400 registration loop.`):f(null)},x=async()=>{n(!0),l(null);try{if(i&&!i.bridge_installed){let e=await aF("install",{});v(e)}await aF("start",{project_id:e}),await m()}catch(e){l(e.message)}finally{n(!1)}},b=async()=>{n(!0),l(null);try{await aF("stop",{project_id:e}),await m()}catch(e){l(e.message)}finally{n(!1)}},y=async(r,s)=>{await aF("save-config",{project_id:e,bot_token:r,chat_id:s});try{if(i&&!i.bridge_installed){let e=await aF("install",{});v(e)}await aF("start",{project_id:e})}catch(e){l(e.message)}await m()},S=!!i?.configured,w=!!i?.running,C=o||a||!w&&i?.last_error||"";return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:"Telegram Bridge"}),(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Telegram Bridge"})," forwards AgentChattr messages to a Telegram bot so you can monitor from your phone. Bidirectional — replies from Telegram appear in chat."]})]}),C&&(0,p.jsx)("span",{className:"text-[10px] text-error",children:"error"})]}),(0,p.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[S?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex items-center gap-2 text-[11px] flex-wrap",children:[w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:[(0,p.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,p.jsx)("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),(0,p.jsx)("span",{className:"text-accent",children:"Running"})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,p.jsx)("span",{className:"text-text-muted",children:"Stopped"})]}),i?.bot_username&&(0,p.jsxs)("span",{className:"text-text-muted",children:["· Bot: @",i.bot_username]}),i?.chat_id&&(0,p.jsxs)("span",{className:"text-text-muted tabular-nums",children:["· Chat: ",i.chat_id]})]}),(0,p.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[w?(0,p.jsx)("button",{onClick:b,disabled:s,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-error hover:border-error/40 disabled:opacity-50 transition-colors",children:s?"Stopping…":"Stop"}):(0,p.jsx)("button",{onClick:x,disabled:s,className:"px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:s?"Starting…":"Start"}),(0,p.jsx)("button",{onClick:()=>d(!0),disabled:s,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:"How to set up"}),(0,p.jsx)("button",{onClick:()=>d(!0),disabled:s,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:"Edit credentials"})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,p.jsx)("span",{children:"Not configured"})]}),(0,p.jsx)("button",{onClick:()=>d(!0),disabled:s,className:"self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:"Set up Telegram Bridge"})]}),u&&(0,p.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-accent border border-accent/40 bg-accent/5 whitespace-pre-wrap break-words",children:[u,(0,p.jsx)("button",{type:"button",onClick:()=>f(null),className:"block mt-1 text-text-muted hover:text-text underline",children:"dismiss"})]}),C&&(0,p.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-error border border-error/40 bg-error/5 font-mono whitespace-pre-wrap break-words max-h-40 overflow-y-auto",children:[C,o&&(0,p.jsx)("button",{type:"button",onClick:()=>l(null),className:"block mt-1 text-text-muted hover:text-text underline",children:"dismiss"})]})]})]}),(0,p.jsx)(aH,{open:c,initialChatId:i?.chat_id||"",onClose:()=>d(!1),onSave:y})]})}function a$({open:e,initialChannelId:i="",onClose:r,onSave:s}){let[n,o]=(0,_.useState)(""),[l,a]=(0,_.useState)(i),[h,c]=(0,_.useState)(!1),[d,u]=(0,_.useState)(null),[f,m]=(0,_.useState)(!1);if((0,_.useEffect)(()=>{e&&a(i)},[e,i]),(0,_.useEffect)(()=>{if(!e)return;let i=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e,r]),!e)return null;let g=async()=>{c(!0),u(null);try{await s(n.trim(),l.trim()),r()}catch(e){u(e.message||"Save failed")}finally{c(!1)}};return(0,p.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:r,role:"dialog","aria-modal":"true","aria-labelledby":"discord-setup-title",children:(0,p.jsxs)("div",{className:"relative mx-4 max-w-xl w-full max-h-[90vh] overflow-auto rounded-lg border border-white/10 bg-neutral-950 p-6 shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,p.jsx)("button",{type:"button",onClick:r,"aria-label":"Close",className:"absolute right-3 top-3 rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,p.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,p.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})}),(0,p.jsx)("h2",{id:"discord-setup-title",className:"text-base font-semibold text-white",children:"Set up your Discord Bridge"}),(0,p.jsx)("p",{className:"mt-2 text-[12px] leading-relaxed text-neutral-300",children:"The bridge forwards AgentChattr messages from your project to a Discord channel, so you can read and reply from Discord."}),(0,p.jsxs)("div",{className:"mt-4 text-[12px] text-neutral-300 space-y-3",children:[(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 1 — Create a Discord Application + Bot"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["Go to the ",(0,p.jsx)("a",{href:"https://discord.com/developers/applications",target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Discord Developer Portal"}),"."]}),(0,p.jsxs)("li",{children:["Click ",(0,p.jsx)("b",{children:"New Application"}),' → name it (e.g. "QuadWork") → ',(0,p.jsx)("b",{children:"Create"}),"."]}),(0,p.jsxs)("li",{children:["Go to the ",(0,p.jsx)("b",{children:"Bot"})," tab in the left sidebar."]}),(0,p.jsxs)("li",{children:["Click ",(0,p.jsx)("b",{children:"Reset Token"})," → copy the bot token. Save it somewhere safe."]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 2 — Enable MESSAGE_CONTENT intent (critical)"}),(0,p.jsxs)("div",{className:"mt-1.5 rounded border border-amber-500/40 bg-amber-500/5 p-3",children:[(0,p.jsxs)("div",{className:"flex items-start gap-2",children:[(0,p.jsx)("span",{className:"text-amber-400 text-[16px] leading-none shrink-0",children:"⚠"}),(0,p.jsxs)("div",{className:"text-[12px] text-amber-200/90 leading-relaxed",children:[(0,p.jsx)("b",{className:"text-amber-300",children:"This step is required."}),"Without it, the bot connects successfully but receives empty message content — no error, no warning, just silent empty messages. This is the #1 cause of Discord bot setup issues."]})]}),(0,p.jsxs)("ol",{className:"mt-2 pl-6 list-decimal space-y-0.5 text-neutral-300 text-[12px]",children:[(0,p.jsxs)("li",{children:["On the same ",(0,p.jsx)("b",{children:"Bot"})," tab, scroll down to ",(0,p.jsx)("b",{children:"Privileged Gateway Intents"}),"."]}),(0,p.jsxs)("li",{children:["Toggle ",(0,p.jsx)("b",{children:"ON"}),": ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"MESSAGE CONTENT INTENT"}),"."]}),(0,p.jsxs)("li",{children:["Click ",(0,p.jsx)("b",{children:"Save Changes"}),"."]})]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 3 — Invite the bot to your server"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["Go to the ",(0,p.jsx)("b",{children:"OAuth2"})," tab → ",(0,p.jsx)("b",{children:"URL Generator"}),"."]}),(0,p.jsxs)("li",{children:["Under ",(0,p.jsx)("b",{children:"Scopes"}),", check ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"bot"}),"."]}),(0,p.jsxs)("li",{children:["Under ",(0,p.jsx)("b",{children:"Bot Permissions"}),", check:",(0,p.jsxs)("ul",{className:"mt-0.5 pl-4 list-disc text-neutral-400",children:[(0,p.jsx)("li",{children:(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"Send Messages"})}),(0,p.jsx)("li",{children:(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"Read Message History"})}),(0,p.jsx)("li",{children:(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"View Channels"})})]})]}),(0,p.jsxs)("li",{children:["Copy the generated URL at the bottom. It will look like:",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"https://discord.com/oauth2/authorize?client_id=YOUR_APP_ID&permissions=66560&scope=bot"})]}),(0,p.jsxs)("li",{children:["Open it in your browser → select your Discord server → ",(0,p.jsx)("b",{children:"Authorize"}),"."]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 4 — Get your channel ID"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["In Discord, go to ",(0,p.jsx)("b",{children:"User Settings"})," → ",(0,p.jsx)("b",{children:"Advanced"})," → enable ",(0,p.jsx)("b",{children:"Developer Mode"}),"."]}),(0,p.jsxs)("li",{children:["Right-click the channel you want to bridge → ",(0,p.jsx)("b",{children:"Copy Channel ID"}),"."]})]}),(0,p.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-500",children:["Channel IDs are large numbers like ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"1234567890123456789"}),"."]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 5 — Paste credentials below"}),(0,p.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,p.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Bot token",(0,p.jsx)("input",{type:"password",value:n,onChange:e=>o(e.target.value),placeholder:"MTIzNDU2Nzg5MDEyMzQ1Njc4OQ...",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),(0,p.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Channel ID",(0,p.jsx)("input",{type:"text",value:l,onChange:e=>a(e.target.value),placeholder:"1234567890123456789",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),d&&(0,p.jsx)("div",{className:"text-[11px] text-error",children:d}),(0,p.jsx)("button",{type:"button",onClick:g,disabled:h||!n.trim()||!l.trim(),className:"mt-1 self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:h?"Saving…":"Save and start bridge"})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("button",{type:"button",onClick:()=>m(e=>!e),className:"text-[11px] text-accent hover:underline","aria-expanded":f,children:f?"Hide troubleshooting ▾":"Troubleshooting ▸"}),f&&(0,p.jsxs)("div",{className:"mt-2 p-2 border border-white/10 rounded text-[11px] text-neutral-300 space-y-2",children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Bot connects but messages are empty."})," ","MESSAGE_CONTENT intent is not enabled. Go back to Step 2 — toggle it on in the Developer Portal under Bot → Privileged Gateway Intents, then restart the bridge."]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Bot can't see the channel."})," ","The bot wasn't invited to the server (Step 3) or it lacks the ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"View Channels"}),"permission for that specific channel. Check your server's role permissions."]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:'"Disallowed intents" error in logs.'})," ","MESSAGE_CONTENT intent is not toggled in the Developer Portal. This is different from not requesting it in code — the portal toggle is the gatekeeper."]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Rate limited."})," ","Normal for high-traffic channels. ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"discord.py"})," handles backoff automatically. If persistent, increase the AC poll interval in the bridge config."]})]})]})]})]})})}async function aU(e,i){let r=await fetch(`/api/discord?action=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),s=await r.json();if(!r.ok||!1===s.ok)throw Error(s.error||`${r.status}`);return s}function aK({projectId:e}){let[i,r]=(0,_.useState)(null),[s,n]=(0,_.useState)(!1),[o,l]=(0,_.useState)(null),[a,h]=(0,_.useState)(null),[c,d]=(0,_.useState)(!1),[u,f]=(0,_.useState)(null),m=(0,_.useCallback)(async()=>{try{let i=await fetch(`/api/discord?project=${encodeURIComponent(e)}`);if(!i.ok)throw Error(`${i.status}`);let s=await i.json();r(s),h(null)}catch(e){h(e.message)}},[e]);(0,_.useEffect)(()=>{m();let e=window.setInterval(m,5e3);return()=>window.clearInterval(e)},[m]);let v=e=>{let i=Array.isArray(e?.patched_projects)?e.patched_projects:[];i.length>0?f(`Install Bridge patched ${i.length} AgentChattr config(s) (${i.join(", ")}) to declare [agents.discord-bridge]. Click SERVER → Restart so AgentChattr picks up the new agent slug, then click Start again. Without the restart, Start will fail with a 400 registration loop.`):f(null)},x=async()=>{n(!0),l(null);try{if(i&&!i.bridge_installed){let e=await aU("install",{});v(e)}await aU("start",{project_id:e}),await m()}catch(e){l(e.message)}finally{n(!1)}},b=async()=>{n(!0),l(null);try{await aU("stop",{project_id:e}),await m()}catch(e){l(e.message)}finally{n(!1)}},y=async(r,s)=>{await aU("save-config",{project_id:e,bot_token:r,channel_id:s});try{if(i&&!i.bridge_installed){let e=await aU("install",{});v(e)}await aU("start",{project_id:e})}catch(e){l(e.message)}await m()},S=!!i?.configured,w=!!i?.running,C=o||a||!w&&i?.last_error||"";return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:"Discord Bridge"}),(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Discord Bridge"})," forwards AgentChattr messages to a Discord channel so you can monitor from Discord. Bidirectional — replies from Discord appear in chat."]})]}),C&&(0,p.jsx)("span",{className:"text-[10px] text-error",children:"error"})]}),(0,p.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[S?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex items-center gap-2 text-[11px] flex-wrap",children:[w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:[(0,p.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,p.jsx)("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),(0,p.jsx)("span",{className:"text-accent",children:"Running"})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,p.jsx)("span",{className:"text-text-muted",children:"Stopped"})]}),i?.bot_username&&(0,p.jsxs)("span",{className:"text-text-muted",children:["· Bot: ",i.bot_username]}),i?.channel_id&&(0,p.jsxs)("span",{className:"text-text-muted tabular-nums",children:["· Channel: ",i.channel_id]})]}),(0,p.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[w?(0,p.jsx)("button",{onClick:b,disabled:s,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-error hover:border-error/40 disabled:opacity-50 transition-colors",children:s?"Stopping…":"Stop"}):(0,p.jsx)("button",{onClick:x,disabled:s,className:"px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:s?"Starting…":"Start"}),(0,p.jsx)("button",{onClick:()=>d(!0),disabled:s,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:"How to set up"}),(0,p.jsx)("button",{onClick:()=>d(!0),disabled:s,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:"Edit credentials"})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,p.jsx)("span",{children:"Not configured"})]}),(0,p.jsx)("button",{onClick:()=>d(!0),disabled:s,className:"self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:"Set up Discord Bridge"})]}),u&&(0,p.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-accent border border-accent/40 bg-accent/5 whitespace-pre-wrap break-words",children:[u,(0,p.jsx)("button",{type:"button",onClick:()=>f(null),className:"block mt-1 text-text-muted hover:text-text underline",children:"dismiss"})]}),C&&(0,p.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-error border border-error/40 bg-error/5 font-mono whitespace-pre-wrap break-words max-h-40 overflow-y-auto",children:[C,o&&(0,p.jsx)("button",{type:"button",onClick:()=>l(null),className:"block mt-1 text-text-muted hover:text-text underline",children:"dismiss"})]})]})]}),(0,p.jsx)(a$,{open:c,initialChannelId:i?.channel_id||"",onClose:()=>d(!1),onSave:y})]})}function aq({projectId:e}){let[i,r]=(0,_.useState)(30),[s,n]=(0,_.useState)("30"),[o,l]=(0,_.useState)(!1),[a,h]=(0,_.useState)(null),[c,d]=(0,_.useState)(null),[u,f]=(0,_.useState)(!1),[m,g]=(0,_.useState)(!1),[v,x]=(0,_.useState)(30),[b,y]=(0,_.useState)("30"),[S,w]=(0,_.useState)(!1);(0,_.useEffect)(()=>{fetch(`/api/loop-guard?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{e&&"number"==typeof e.value&&(r(e.value),n(String(e.value)))}).catch(()=>{}),fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i||!Array.isArray(i.projects))return;let r=i.projects.find(i=>i.id===e);if(!r)return;g(!!r.auto_continue_loop_guard);let s=Number.isFinite(r.auto_continue_delay_sec)?r.auto_continue_delay_sec:30;x(s),y(String(s))}).catch(()=>{})},[e]);let C=async(i,r)=>{w(!0);try{let s=await fetch("/api/config");if(!s.ok)throw Error(`GET /api/config ${s.status}`);let n=await s.json();if(!n||!Array.isArray(n.projects))throw Error("config shape");let o=n.projects.findIndex(i=>i.id===e);if(o<0)throw Error(`project ${e} not found`);n.projects[o]={...n.projects[o],auto_continue_loop_guard:i,auto_continue_delay_sec:r};let l=await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!l.ok)throw Error(`PUT /api/config ${l.status}`)}finally{w(!1)}};return(0,p.jsxs)("div",{className:"border border-border rounded p-2 text-[11px] font-mono",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,p.jsx)("span",{className:"uppercase tracking-wider text-text-muted",children:"Loop Guard"}),(0,p.jsx)("button",{type:"button","aria-label":"About loop guard",onClick:()=>f(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"})]}),u&&(0,p.jsxs)("div",{className:"mb-1.5 p-1.5 text-[10px] leading-snug text-text bg-bg-surface border border-border/60 rounded",children:[(0,p.jsx)("b",{children:"Loop Guard"})," pauses agent-to-agent message chains after this many hops with no human reply. Higher values let agents work longer overnight; lower values add safety against runaway loops. AgentChattr accepts ",(0,p.jsx)("b",{children:"4–50"}),"; QuadWork defaults to ",(0,p.jsx)("b",{children:"30"})," (about 5–6 full PR cycles). Posting any chat message yourself resets the counter immediately."]}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-text-muted",children:"Pause after"}),(0,p.jsx)("input",{type:"number",min:4,max:50,value:s,onChange:e=>n(e.target.value),disabled:o,className:"w-12 bg-transparent px-1 py-0.5 border border-border rounded text-text outline-none focus:ring-1 focus:ring-accent"}),(0,p.jsx)("span",{className:"text-text-muted",children:"hops"}),(0,p.jsx)("button",{type:"button",onClick:()=>{let i=parseInt(s,10);!Number.isInteger(i)||i<4||i>50?h("Must be an integer between 4 and 50."):(l(!0),h(null),fetch(`/api/loop-guard?project=${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:i})}).then(async e=>{if(!e.ok){let i=await e.text().catch(()=>"");throw Error(`${e.status}: ${i.slice(0,120)}`)}return e.json()}).then(e=>{r(e.value),d(e.live)}).catch(e=>h(e.message||String(e))).finally(()=>l(!1)))},disabled:o||s===String(i),className:"ml-auto px-2 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:"Apply (writes config.toml + live-pushes to AgentChattr)",children:o?"…":"Apply"})]}),a&&(0,p.jsx)("div",{className:"mt-1 text-[10px] text-red-400",children:a}),!1===c&&!a&&(0,p.jsx)("div",{className:"mt-1 text-[10px] text-text-muted",children:"Saved to config.toml — live update failed; takes effect on next AC restart."}),(0,p.jsxs)("label",{className:"mt-2 flex items-center gap-1.5 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,p.jsx)("input",{type:"checkbox",checked:m,disabled:S,onChange:e=>{let i=e.target.checked;g(i),C(i,v).catch(()=>{g(!i)})}}),"Auto-continue after pause",(0,p.jsx)("span",{className:"text-text-muted",children:"— wait"}),(0,p.jsx)("input",{type:"number",min:5,max:300,value:b,disabled:S||!m,onChange:e=>y(e.target.value),onBlur:()=>{let e=parseInt(b,10),i=Number.isFinite(e)?Math.max(5,Math.min(300,e)):30;x(i),y(String(i)),i!==v&&C(m,i).catch(()=>{})},className:"w-10 bg-transparent px-1 py-0.5 border border-border rounded text-text outline-none focus:ring-1 focus:ring-accent disabled:opacity-40 text-center"}),(0,p.jsx)("span",{className:"text-text-muted",children:"s before /continue"})]})]})}function aV({projectId:e}){let i=(0,_.useRef)(null),[r,s]=(0,_.useState)(null),[n,o]=(0,_.useState)(null),[l,a]=(0,_.useState)(null),[h,c]=(0,_.useState)([]),[d,u]=(0,_.useState)(!1),[f,m]=(0,_.useState)(!1);(0,_.useEffect)(()=>{fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i||!Array.isArray(i.projects))return;let r=i.projects.find(i=>i.id===e);r&&u(!!r.auto_restore_after_restart)}).catch(()=>{})},[e]);let v=async i=>{m(!0);try{let r=await fetch("/api/config");if(!r.ok)throw Error(`GET /api/config ${r.status}`);let s=await r.json(),n=s.projects?.findIndex(i=>i.id===e)??-1;if(n<0)throw Error("project not found");s.projects[n]={...s.projects[n],auto_restore_after_restart:i};let o=await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!o.ok)throw Error(`PUT /api/config ${o.status}`)}finally{m(!1)}},x=()=>{fetch(`/api/project-history/snapshots?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{e&&Array.isArray(e.snapshots)&&c(e.snapshots)}).catch(()=>{})};(0,_.useEffect)(()=>{x();let e=setInterval(x,15e3);return()=>clearInterval(e)},[e]);let b=async i=>{if(window.confirm(`Restore snapshot ${i}? This will replay every message through AgentChattr (tagged by the original sender) and may duplicate history already in the chat. Continue?`)){s("restore"),o(null),a(null);try{let r=await fetch(`/api/project-history/restore?project=${encodeURIComponent(e)}&name=${encodeURIComponent(i)}`,{method:"POST"}),s=await r.json().catch(()=>null);if(!r.ok)throw Error(s&&s.error||`HTTP ${r.status}`);s&&"number"==typeof s.imported&&a(s)}catch(e){o(e.message||String(e))}finally{s(null),x()}}},y=async()=>{s("export"),o(null),a(null);try{let i=await fetch(`/api/project-history?project=${encodeURIComponent(e)}`);if(!i.ok){let e=await i.text().catch(()=>"");throw Error(`HTTP ${i.status}: ${e.slice(0,200)}`)}let r=await i.blob(),s=URL.createObjectURL(r),n=document.createElement("a"),o=new Date().toISOString().slice(0,10);n.href=s,n.download=`${e}-history-${o}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(s)}catch(e){o(e.message||String(e))}finally{s(null)}},S=async r=>{let n;if(r.size>0xa00000)return void o(`File too large (${r.size} bytes; limit 10485760)`);s("import"),o(null),a(null);try{let e=await r.text();n=JSON.parse(e)}catch(e){s(null),o(`Invalid JSON: ${e.message||String(e)}`);return}if(!n||"object"!=typeof n||!Array.isArray(n.messages)){s(null),o("File missing 'messages' array");return}let l=!1;if(n.project_id&&n.project_id!==e){if(!window.confirm(`This export is from project '${n.project_id}' but you're importing into '${e}'. Continue anyway?`))return void s(null);l=!0}let h=new Set(["head","dev","reviewer1","reviewer2","re1","re2","t1","t2a","t2b","t3","system"]),c=!1,d=new Set;for(let e of n.messages)if(e&&"object"==typeof e){let i=e.sender;if("string"==typeof i&&h.has(i.toLowerCase())&&(d.add(i),d.size>=5))break}if(d.size>0){if(!window.confirm(`This export contains messages attributed to reserved agent/system identities (${[...d].join(", ")}). Importing will replay them as those agents — only do this for a legitimate disaster-recovery restore. Continue?`))return void s(null);c=!0}let u=!1,f=i=>fetch(`/api/project-history?project=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...n,allow_project_mismatch:l,allow_agent_senders:c,allow_duplicate:u,...i})});try{let e=await f({}),i=await e.json().catch(()=>null);if(409===e.status&&i&&"string"==typeof i.error&&/already imported/i.test(i.error)){if(!window.confirm(`${i.error}
25
+ ALL: Communicate via this chat by tagging agents. Your terminal is NOT visible.`},[e]),[j,B]=(0,_.useState)(!1),[L,A]=(0,_.useState)(!1),[I,O]=(0,_.useState)(null),z=(0,_.useRef)(null),H=(0,_.useRef)(!1);(0,_.useEffect)(()=>{H.current=!1,z.current=null,B(!1),A(!1),O(null)},[e]),(0,_.useEffect)(()=>{H.current||fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i)return;let r=(i.projects||[]).find(i=>i.id===e);r?.trigger_auto&&B(!0),H.current=!0}).catch(()=>{})},[e]);let F=(0,_.useCallback)(async()=>{try{let i=await fetch("/api/triggers");if(!i.ok)throw Error(`${i.status}`);let s=(await i.json())[e]||null;if(r(s),s){if(s.message&&!y.current&&(n(s.message),y.current=s.message),!S.current)if(s.enabled&&s.interval){let e=Math.max(1,Math.round(s.interval/6e4));l(e),h(String(e))}else"number"==typeof s.intervalMin&&s.intervalMin>0&&(l(s.intervalMin),h(String(s.intervalMin)));!w.current&&"number"==typeof s.durationMin&&s.durationMin>=0&&(d(s.durationMin),f(aI(s.durationMin)))}N(null)}catch(e){N(e.message)}},[e]);(0,_.useEffect)(()=>{s||n(P)},[P,s]),(0,_.useEffect)(()=>{F();let e=window.setInterval(F,5e3);return()=>window.clearInterval(e)},[F]),(0,_.useEffect)(()=>{if(!i?.enabled){D(""),T("");return}let e=()=>{if(i.nextAt&&D(aO(Math.max(0,i.nextAt-Date.now()))),i.expiresAt){let e=Math.max(0,i.expiresAt-Date.now());T(aO(e)),e<=0&&F()}else T("")};e();let r=window.setInterval(e,1e3);return()=>window.clearInterval(r)},[i?.enabled,i?.nextAt,i?.expiresAt,F]);let W=async()=>{k(!0),N(null);let i=parseFloat(u),r=Math.round(60*(Number.isFinite(i)?aA(i):3));r!==c&&(d(r),f(aI(r)));let n=parseInt(a,10),p=Number.isFinite(n)?Math.max(1,Math.min(1440,n)):15;p!==o&&(l(p),h(String(p)));try{let i=await fetch(`/api/triggers/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({interval:p,duration:r,message:s})});if(!i.ok)throw Error(`${i.status}`);v(!1),b(!1),await F()}catch(e){N(e.message)}finally{k(!1)}},$=async()=>{k(!0),N(null);try{let n=await fetch(`/api/triggers/${encodeURIComponent(e)}/stop`,{method:"POST"});if(!n.ok)throw Error(`${n.status}`);A(!1),r({...i||{interval:0,lastSent:null,nextAt:null,expiresAt:null,message:s,intervalMin:o,durationMin:c},enabled:!1}),await F()}catch(e){N(e.message)}finally{k(!1)}},U=(0,_.useCallback)(async()=>{let i=!j;B(i),i||(O(null),z.current=null);try{let r=await fetch("/api/config");if(!r.ok)return;let s=await r.json(),n=(s.projects||[]).find(i=>i.id===e);n&&(n.trigger_auto=i,await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}))}catch{}},[j,e]),K=(0,_.useRef)(j),q=(0,_.useRef)(i);(0,_.useEffect)(()=>{K.current=j},[j]),(0,_.useEffect)(()=>{q.current=i},[i]);let V=(0,_.useCallback)(async()=>{if(K.current)try{let i=await fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`);if(!i.ok)return;let r=await i.json(),s=r.items.length>0,n=z.current;if(z.current={complete:r.complete,hasItems:s},!n){if(s&&!r.complete&&!q.current?.enabled){A(!0),O(null);let i=parseFloat(u),r=Number.isFinite(i)?aA(i):3,s=Math.round(60*r),n=parseInt(a,10),o=Number.isFinite(n)?Math.max(1,Math.min(1440,n)):15;await fetch(`/api/triggers/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({interval:o,duration:s,message:y.current||P})}),await F()}return}if(s&&r.complete&&!n.complete&&q.current?.enabled){await fetch(`/api/triggers/${encodeURIComponent(e)}/stop`,{method:"POST"}),A(!1),O("Batch complete — trigger paused. Waiting for next batch."),await F();return}if(s&&!r.complete&&(n.complete||!n.hasItems)&&!q.current?.enabled){A(!0),O(null);let i=parseFloat(u),r=Number.isFinite(i)?aA(i):3,s=Math.round(60*r),n=parseInt(a,10),o=Number.isFinite(n)?Math.max(1,Math.min(1440,n)):15;await fetch(`/api/triggers/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({interval:o,duration:s,message:y.current||P})}),await F()}}catch{}},[e,u,a,P,F]);(0,_.useEffect)(()=>{if(!j)return;V();let e=window.setInterval(V,3e4);return()=>window.clearInterval(e)},[j,V]);let Y=!!i?.enabled;return(0,p.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsxs)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:["Scheduled Trigger",Y?L?" (auto)":" (running)":""]}),(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Scheduled Trigger"})," sends a periodic message to all agents on a timer. Use this to keep the autonomous workflow running overnight. First message fires after the configured interval, not immediately."]})]}),(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[E&&(0,p.jsxs)("span",{className:"text-[10px] text-error",children:["err: ",E]}),(0,p.jsxs)("button",{type:"button",onClick:U,title:j?"Auto-trigger ON — trigger follows batch lifecycle":"Auto-trigger OFF — manual start/stop only",className:`px-1.5 py-0.5 text-[10px] border transition-colors ${j?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:["Auto ",j?"●":"○"]})]})]}),I&&(0,p.jsx)("div",{className:"px-3 py-1 text-[10px] text-accent bg-accent/5 border-b border-border/50",children:I}),Y?(0,p.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[(0,p.jsx)("div",{className:"text-[11px] text-text-muted",children:"Sending:"}),(0,p.jsx)("pre",{className:"text-[11px] font-mono whitespace-pre-wrap text-text bg-bg-surface border border-border p-2 max-h-28 overflow-auto",children:(i?.message||s).slice(0,400)}),(0,p.jsxs)("div",{className:"flex items-center gap-3 flex-wrap text-[11px]",children:[(0,p.jsxs)("span",{className:"flex items-center gap-1",children:[(0,p.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:[(0,p.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,p.jsx)("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),(0,p.jsx)("span",{className:"text-accent",children:"Running"})]}),(0,p.jsxs)("span",{className:"tabular-nums text-text",children:["Next: ",R]}),M&&(0,p.jsxs)("span",{className:"tabular-nums text-text-muted",children:["Stops in: ",M]}),!i?.expiresAt&&(0,p.jsx)("span",{className:"text-text-muted",children:"(until stopped)"})]}),(0,p.jsx)("button",{onClick:$,disabled:C,className:"self-start px-3 py-1 text-[11px] text-text-muted border border-border hover:text-error hover:border-error/40 disabled:opacity-50 transition-colors",children:C?"Stopping…":"Stop Trigger"})]}):(0,p.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[(0,p.jsx)("label",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:"Message"}),(0,p.jsx)("textarea",{value:s,onChange:e=>n(e.target.value),rows:6,spellCheck:!1,className:"w-full bg-bg text-text text-[11px] font-mono p-2 border border-border outline-none focus:border-accent resize-y"}),(0,p.jsxs)("div",{className:"flex items-center gap-2 flex-wrap text-[11px]",children:[(0,p.jsx)("span",{className:"text-text-muted",children:"Send every"}),(0,p.jsx)("input",{type:"number",value:a,onChange:e=>{h(e.target.value),v(!0)},onBlur:()=>{let e=parseInt(a,10),i=Number.isFinite(e)?Math.max(1,Math.min(1440,e)):15;l(i),h(String(i))},min:1,max:1440,className:"w-12 bg-transparent border border-border px-1 py-0.5 text-[11px] text-text outline-none focus:border-accent text-center"}),(0,p.jsx)("span",{className:"text-text-muted",children:"min for"}),(0,p.jsx)("input",{type:"number",value:u,onChange:e=>{f(e.target.value),b(!0)},onBlur:()=>{let e=parseFloat(u),i=Math.round(60*(Number.isFinite(e)?aA(e):3));d(i),f(aI(i))},min:.1,max:24,step:.1,className:"w-14 bg-transparent border border-border px-1 py-0.5 text-[11px] text-text outline-none focus:border-accent text-center"}),(0,p.jsx)("span",{className:"text-text-muted",children:"hours"})]}),(0,p.jsx)("button",{onClick:W,disabled:C||!s.trim(),className:"self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:C?"Starting…":"Start Trigger"})]})]})}function aH({open:e,initialChatId:i="",onClose:r,onSave:s}){let[n,o]=(0,_.useState)(""),[l,a]=(0,_.useState)(i),[h,c]=(0,_.useState)(!1),[d,u]=(0,_.useState)(null),[f,m]=(0,_.useState)(!1);if((0,_.useEffect)(()=>{e&&a(i)},[e,i]),(0,_.useEffect)(()=>{if(!e)return;let i=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e,r]),!e)return null;let g=async()=>{c(!0),u(null);try{await s(n.trim(),l.trim()),r()}catch(e){u(e.message||"Save failed")}finally{c(!1)}};return(0,p.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:r,role:"dialog","aria-modal":"true","aria-labelledby":"telegram-setup-title",children:(0,p.jsxs)("div",{className:"relative mx-4 max-w-xl w-full max-h-[90vh] overflow-auto rounded-lg border border-white/10 bg-neutral-950 p-6 shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,p.jsx)("button",{type:"button",onClick:r,"aria-label":"Close",className:"absolute right-3 top-3 rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,p.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,p.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})}),(0,p.jsx)("h2",{id:"telegram-setup-title",className:"text-base font-semibold text-white",children:"Set up your Telegram Bridge"}),(0,p.jsx)("p",{className:"mt-2 text-[12px] leading-relaxed text-neutral-300",children:"The bridge forwards AgentChattr messages from your project to a Telegram chat, so you can read and reply on your phone."}),(0,p.jsxs)("div",{className:"mt-4 text-[12px] text-neutral-300 space-y-3",children:[(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 1 — Create a Telegram bot"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["Open Telegram and search for ",(0,p.jsx)("b",{children:"@BotFather"}),"."]}),(0,p.jsxs)("li",{children:["Send ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"/newbot"})," and follow the prompts."]}),(0,p.jsxs)("li",{children:["Choose a name and username (must end in ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"bot"}),")."]}),(0,p.jsxs)("li",{children:["BotFather replies with a ",(0,p.jsx)("b",{children:"bot token"})," that looks like ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"123456:ABC-DEF1234ghIkl…"}),". Copy it."]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 2 — Get your chat ID"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["Open Telegram and search for your new bot by its exact ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"@username"}),"."]}),(0,p.jsxs)("li",{children:["Tap ",(0,p.jsx)("b",{children:"Start"})," and send any message (e.g. ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"hello"}),")."," ",(0,p.jsxs)("span",{className:"text-neutral-400",children:["You must send at least one message first — ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"getUpdates"})," returns ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:'{"ok":true,"result":[]}'})," until Telegram has an inbound message on record."]})]}),(0,p.jsxs)("li",{children:["Open this URL in your browser (replace ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"YOUR_TOKEN"}),"):",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"https://api.telegram.org/botYOUR_TOKEN/getUpdates"})]}),(0,p.jsxs)("li",{children:["Look for ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:'"chat":{"id":<NUMBER>'})," in the JSON. That number is your ",(0,p.jsx)("b",{children:"chat id"}),". Group chat ids are negative (e.g. ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"-1001234567890"}),") — paste the full value ",(0,p.jsx)("b",{children:"including the minus sign"}),"."]})]}),(0,p.jsx)("p",{className:"mt-1 text-neutral-400",children:"Or use one of these terminal one-liners:"}),(0,p.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-400",children:["With ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"jq"})," (cleanest):"]}),(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"curl -s \"https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates\" | jq '.result[-1].message.chat.id'"}),(0,p.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-400",children:["Without ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"jq"})," (pure grep):"]}),(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:'curl -s "https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates" | grep -o \'"chat":{"id":-\\?[0-9]*\' | tail -1'}),(0,p.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-500",children:["The first message from a brand-new bot sometimes doesn't propagate to ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"getUpdates"})," instantly. If ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"result"})," is empty, send 2-3 more messages and retry."]}),(0,p.jsx)("button",{type:"button",onClick:()=>m(e=>!e),className:"mt-2 text-[11px] text-accent hover:underline","aria-expanded":f,children:f?"Hide troubleshooting ▾":"Still empty? Troubleshooting ▸"}),f&&(0,p.jsxs)("div",{className:"mt-2 p-2 border border-white/10 rounded text-[11px] text-neutral-300 space-y-2",children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Webhook conflict."})," Something else may be consuming updates. Check and delete any active webhook:",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:'curl -s "https://api.telegram.org/bot<TOKEN>/getWebhookInfo" curl -s "https://api.telegram.org/bot<TOKEN>/deleteWebhook"'})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Stale bridge process."}),"A leftover bridge from a previous install will hold the update queue. Two consumers can't share one bot:",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"ps aux | grep telegram_bridge | grep -v grep"}),"Kill any PIDs that show up before retrying the curl."]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Token / bot mismatch."})," A token that doesn't match the bot you're messaging silently returns empty results. Confirm the token's ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"username"})," matches the ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"@username"}),"you're chatting with:",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:'curl -s "https://api.telegram.org/bot<TOKEN>/getMe"'})]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 3 — Paste credentials below"}),(0,p.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,p.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Bot token",(0,p.jsx)("input",{type:"password",value:n,onChange:e=>o(e.target.value),placeholder:"123456:ABC-DEF…",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),(0,p.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Chat id",(0,p.jsx)("input",{type:"text",value:l,onChange:e=>a(e.target.value),placeholder:"123456789",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),d&&(0,p.jsx)("div",{className:"text-[11px] text-error",children:d}),(0,p.jsx)("button",{type:"button",onClick:g,disabled:h||!n.trim()||!l.trim(),className:"mt-1 self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:h?"Saving…":"Save and start bridge"})]})]})]})]})})}async function aF(e,i){let r=await fetch(`/api/telegram?action=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),s=await r.json();if(!r.ok||!1===s.ok)throw Error(s.error||`${r.status}`);return s}function aW({projectId:e}){let[i,r]=(0,_.useState)(null),[s,n]=(0,_.useState)(!1),[o,l]=(0,_.useState)(null),[a,h]=(0,_.useState)(null),[c,d]=(0,_.useState)(!1),[u,f]=(0,_.useState)(null),m=(0,_.useCallback)(async()=>{try{let i=await fetch(`/api/telegram?project=${encodeURIComponent(e)}`);if(!i.ok)throw Error(`${i.status}`);let s=await i.json();r(s),h(null)}catch(e){h(e.message)}},[e]);(0,_.useEffect)(()=>{m();let e=window.setInterval(m,5e3);return()=>window.clearInterval(e)},[m]);let v=e=>{let i=Array.isArray(e?.patched_projects)?e.patched_projects:[];i.length>0?f(`Install Bridge patched ${i.length} AgentChattr config(s) (${i.join(", ")}) to declare [agents.telegram-bridge]. Click SERVER → Restart so AgentChattr picks up the new agent slug, then click Start again. Without the restart, Start will fail with a 400 registration loop.`):f(null)},x=async()=>{n(!0),l(null);try{if(i&&!i.bridge_installed){let e=await aF("install",{});v(e)}await aF("start",{project_id:e}),await m()}catch(e){l(e.message)}finally{n(!1)}},b=async()=>{n(!0),l(null);try{await aF("stop",{project_id:e}),await m()}catch(e){l(e.message)}finally{n(!1)}},y=async(r,s)=>{await aF("save-config",{project_id:e,bot_token:r,chat_id:s});try{if(i&&!i.bridge_installed){let e=await aF("install",{});v(e)}await aF("start",{project_id:e})}catch(e){l(e.message)}await m()},S=!!i?.configured,w=!!i?.running,C=o||a||!w&&i?.last_error||"";return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:"Telegram Bridge"}),(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Telegram Bridge"})," forwards AgentChattr messages to a Telegram bot so you can monitor from your phone. Bidirectional — replies from Telegram appear in chat."]})]}),C&&(0,p.jsx)("span",{className:"text-[10px] text-error",children:"error"})]}),(0,p.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[S?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex items-center gap-2 text-[11px] flex-wrap",children:[w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:[(0,p.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,p.jsx)("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),(0,p.jsx)("span",{className:"text-accent",children:"Running"})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,p.jsx)("span",{className:"text-text-muted",children:"Stopped"})]}),i?.bot_username&&(0,p.jsxs)("span",{className:"text-text-muted",children:["· Bot: @",i.bot_username]}),i?.chat_id&&(0,p.jsxs)("span",{className:"text-text-muted tabular-nums",children:["· Chat: ",i.chat_id]})]}),(0,p.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[w?(0,p.jsx)("button",{onClick:b,disabled:s,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-error hover:border-error/40 disabled:opacity-50 transition-colors",children:s?"Stopping…":"Stop"}):(0,p.jsx)("button",{onClick:x,disabled:s,className:"px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:s?"Starting…":"Start"}),(0,p.jsx)("button",{onClick:()=>d(!0),disabled:s,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:"How to set up"}),(0,p.jsx)("button",{onClick:()=>d(!0),disabled:s,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:"Edit credentials"})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,p.jsx)("span",{children:"Not configured"})]}),(0,p.jsx)("button",{onClick:()=>d(!0),disabled:s,className:"self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:"Set up Telegram Bridge"})]}),u&&(0,p.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-accent border border-accent/40 bg-accent/5 whitespace-pre-wrap break-words",children:[u,(0,p.jsx)("button",{type:"button",onClick:()=>f(null),className:"block mt-1 text-text-muted hover:text-text underline",children:"dismiss"})]}),C&&(0,p.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-error border border-error/40 bg-error/5 font-mono whitespace-pre-wrap break-words max-h-40 overflow-y-auto",children:[C,o&&(0,p.jsx)("button",{type:"button",onClick:()=>l(null),className:"block mt-1 text-text-muted hover:text-text underline",children:"dismiss"})]})]})]}),(0,p.jsx)(aH,{open:c,initialChatId:i?.chat_id||"",onClose:()=>d(!1),onSave:y})]})}function a$({open:e,initialChannelId:i="",onClose:r,onSave:s}){let[n,o]=(0,_.useState)(""),[l,a]=(0,_.useState)(i),[h,c]=(0,_.useState)(!1),[d,u]=(0,_.useState)(null),[f,m]=(0,_.useState)(!1);if((0,_.useEffect)(()=>{e&&a(i)},[e,i]),(0,_.useEffect)(()=>{if(!e)return;let i=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e,r]),!e)return null;let g=async()=>{c(!0),u(null);try{await s(n.trim(),l.trim()),r()}catch(e){u(e.message||"Save failed")}finally{c(!1)}};return(0,p.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:r,role:"dialog","aria-modal":"true","aria-labelledby":"discord-setup-title",children:(0,p.jsxs)("div",{className:"relative mx-4 max-w-xl w-full max-h-[90vh] overflow-auto rounded-lg border border-white/10 bg-neutral-950 p-6 shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,p.jsx)("button",{type:"button",onClick:r,"aria-label":"Close",className:"absolute right-3 top-3 rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,p.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,p.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})}),(0,p.jsx)("h2",{id:"discord-setup-title",className:"text-base font-semibold text-white",children:"Set up your Discord Bridge"}),(0,p.jsx)("p",{className:"mt-2 text-[12px] leading-relaxed text-neutral-300",children:"The bridge forwards AgentChattr messages from your project to a Discord channel, so you can read and reply from Discord."}),(0,p.jsxs)("div",{className:"mt-4 text-[12px] text-neutral-300 space-y-3",children:[(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 1 — Create a Discord Application + Bot"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["Go to the ",(0,p.jsx)("a",{href:"https://discord.com/developers/applications",target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Discord Developer Portal"}),"."]}),(0,p.jsxs)("li",{children:["Click ",(0,p.jsx)("b",{children:"New Application"}),' → name it (e.g. "QuadWork") → ',(0,p.jsx)("b",{children:"Create"}),"."]}),(0,p.jsxs)("li",{children:["Go to the ",(0,p.jsx)("b",{children:"Bot"})," tab in the left sidebar."]}),(0,p.jsxs)("li",{children:["Click ",(0,p.jsx)("b",{children:"Reset Token"})," → copy the bot token. Save it somewhere safe."]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 2 — Enable MESSAGE_CONTENT intent (critical)"}),(0,p.jsxs)("div",{className:"mt-1.5 rounded border border-amber-500/40 bg-amber-500/5 p-3",children:[(0,p.jsxs)("div",{className:"flex items-start gap-2",children:[(0,p.jsx)("span",{className:"text-amber-400 text-[16px] leading-none shrink-0",children:"⚠"}),(0,p.jsxs)("div",{className:"text-[12px] text-amber-200/90 leading-relaxed",children:[(0,p.jsx)("b",{className:"text-amber-300",children:"This step is required."}),"Without it, the bot connects successfully but receives empty message content — no error, no warning, just silent empty messages. This is the #1 cause of Discord bot setup issues."]})]}),(0,p.jsxs)("ol",{className:"mt-2 pl-6 list-decimal space-y-0.5 text-neutral-300 text-[12px]",children:[(0,p.jsxs)("li",{children:["On the same ",(0,p.jsx)("b",{children:"Bot"})," tab, scroll down to ",(0,p.jsx)("b",{children:"Privileged Gateway Intents"}),"."]}),(0,p.jsxs)("li",{children:["Toggle ",(0,p.jsx)("b",{children:"ON"}),": ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"MESSAGE CONTENT INTENT"}),"."]}),(0,p.jsxs)("li",{children:["Click ",(0,p.jsx)("b",{children:"Save Changes"}),"."]})]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 3 — Invite the bot to your server"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["Go to the ",(0,p.jsx)("b",{children:"OAuth2"})," tab → ",(0,p.jsx)("b",{children:"URL Generator"}),"."]}),(0,p.jsxs)("li",{children:["Under ",(0,p.jsx)("b",{children:"Scopes"}),", check ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"bot"}),"."]}),(0,p.jsxs)("li",{children:["Under ",(0,p.jsx)("b",{children:"Bot Permissions"}),", check:",(0,p.jsxs)("ul",{className:"mt-0.5 pl-4 list-disc text-neutral-400",children:[(0,p.jsx)("li",{children:(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"Send Messages"})}),(0,p.jsx)("li",{children:(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"Read Message History"})}),(0,p.jsx)("li",{children:(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"View Channels"})})]})]}),(0,p.jsxs)("li",{children:["Copy the generated URL at the bottom. It will look like:",(0,p.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"https://discord.com/oauth2/authorize?client_id=YOUR_APP_ID&permissions=66560&scope=bot"})]}),(0,p.jsxs)("li",{children:["Open it in your browser → select your Discord server → ",(0,p.jsx)("b",{children:"Authorize"}),"."]})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 4 — Get your channel ID"}),(0,p.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,p.jsxs)("li",{children:["In Discord, go to ",(0,p.jsx)("b",{children:"User Settings"})," → ",(0,p.jsx)("b",{children:"Advanced"})," → enable ",(0,p.jsx)("b",{children:"Developer Mode"}),"."]}),(0,p.jsxs)("li",{children:["Right-click the channel you want to bridge → ",(0,p.jsx)("b",{children:"Copy Channel ID"}),"."]})]}),(0,p.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-500",children:["Channel IDs are large numbers like ",(0,p.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"1234567890123456789"}),"."]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 5 — Paste credentials below"}),(0,p.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,p.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Bot token",(0,p.jsx)("input",{type:"password",value:n,onChange:e=>o(e.target.value),placeholder:"MTIzNDU2Nzg5MDEyMzQ1Njc4OQ...",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),(0,p.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Channel ID",(0,p.jsx)("input",{type:"text",value:l,onChange:e=>a(e.target.value),placeholder:"1234567890123456789",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),d&&(0,p.jsx)("div",{className:"text-[11px] text-error",children:d}),(0,p.jsx)("button",{type:"button",onClick:g,disabled:h||!n.trim()||!l.trim(),className:"mt-1 self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:h?"Saving…":"Save and start bridge"})]})]}),(0,p.jsxs)("section",{children:[(0,p.jsx)("button",{type:"button",onClick:()=>m(e=>!e),className:"text-[11px] text-accent hover:underline","aria-expanded":f,children:f?"Hide troubleshooting ▾":"Troubleshooting ▸"}),f&&(0,p.jsxs)("div",{className:"mt-2 p-2 border border-white/10 rounded text-[11px] text-neutral-300 space-y-2",children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Bot connects but messages are empty."})," ","MESSAGE_CONTENT intent is not enabled. Go back to Step 2 — toggle it on in the Developer Portal under Bot → Privileged Gateway Intents, then restart the bridge."]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Bot can't see the channel."})," ","The bot wasn't invited to the server (Step 3) or it lacks the ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"View Channels"}),"permission for that specific channel. Check your server's role permissions."]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:'"Disallowed intents" error in logs.'})," ","MESSAGE_CONTENT intent is not toggled in the Developer Portal. This is different from not requesting it in code — the portal toggle is the gatekeeper."]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("b",{className:"text-white",children:"Rate limited."})," ","Normal for high-traffic channels. ",(0,p.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"discord.py"})," handles backoff automatically. If persistent, increase the AC poll interval in the bridge config."]})]})]})]})]})})}async function aU(e,i){let r=await fetch(`/api/discord?action=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),s=await r.json();if(!r.ok||!1===s.ok)throw Error(s.error||`${r.status}`);return s}function aK({projectId:e}){let[i,r]=(0,_.useState)(null),[s,n]=(0,_.useState)(!1),[o,l]=(0,_.useState)(null),[a,h]=(0,_.useState)(null),[c,d]=(0,_.useState)(!1),[u,f]=(0,_.useState)(null),m=(0,_.useCallback)(async()=>{try{let i=await fetch(`/api/discord?project=${encodeURIComponent(e)}`);if(!i.ok)throw Error(`${i.status}`);let s=await i.json();r(s),h(null)}catch(e){h(e.message)}},[e]);(0,_.useEffect)(()=>{m();let e=window.setInterval(m,5e3);return()=>window.clearInterval(e)},[m]);let v=e=>{let i=Array.isArray(e?.patched_projects)?e.patched_projects:[];i.length>0?f(`Install Bridge patched ${i.length} AgentChattr config(s) (${i.join(", ")}) to declare [agents.discord-bridge]. Click SERVER → Restart so AgentChattr picks up the new agent slug, then click Start again. Without the restart, Start will fail with a 400 registration loop.`):f(null)},x=async()=>{n(!0),l(null);try{if(i&&!i.bridge_installed){let e=await aU("install",{});v(e)}await aU("start",{project_id:e}),await m()}catch(e){l(e.message)}finally{n(!1)}},b=async()=>{n(!0),l(null);try{await aU("stop",{project_id:e}),await m()}catch(e){l(e.message)}finally{n(!1)}},y=async(r,s)=>{await aU("save-config",{project_id:e,bot_token:r,channel_id:s});try{if(i&&!i.bridge_installed){let e=await aU("install",{});v(e)}await aU("start",{project_id:e})}catch(e){l(e.message)}await m()},S=!!i?.configured,w=!!i?.running,C=o||a||!w&&i?.last_error||"";return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:"Discord Bridge"}),(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Discord Bridge"})," forwards AgentChattr messages to a Discord channel so you can monitor from Discord. Bidirectional — replies from Discord appear in chat."]})]}),C&&(0,p.jsx)("span",{className:"text-[10px] text-error",children:"error"})]}),(0,p.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[S?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex items-center gap-2 text-[11px] flex-wrap",children:[w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:[(0,p.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,p.jsx)("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),(0,p.jsx)("span",{className:"text-accent",children:"Running"})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,p.jsx)("span",{className:"text-text-muted",children:"Stopped"})]}),i?.bot_username&&(0,p.jsxs)("span",{className:"text-text-muted",children:["· Bot: ",i.bot_username]}),i?.channel_id&&(0,p.jsxs)("span",{className:"text-text-muted tabular-nums",children:["· Channel: ",i.channel_id]})]}),(0,p.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[w?(0,p.jsx)("button",{onClick:b,disabled:s,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-error hover:border-error/40 disabled:opacity-50 transition-colors",children:s?"Stopping…":"Stop"}):(0,p.jsx)("button",{onClick:x,disabled:s,className:"px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:s?"Starting…":"Start"}),(0,p.jsx)("button",{onClick:()=>d(!0),disabled:s,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:"How to set up"}),(0,p.jsx)("button",{onClick:()=>d(!0),disabled:s,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:"Edit credentials"})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,p.jsx)("span",{children:"Not configured"})]}),(0,p.jsx)("button",{onClick:()=>d(!0),disabled:s,className:"self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:"Set up Discord Bridge"})]}),u&&(0,p.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-accent border border-accent/40 bg-accent/5 whitespace-pre-wrap break-words",children:[u,(0,p.jsx)("button",{type:"button",onClick:()=>f(null),className:"block mt-1 text-text-muted hover:text-text underline",children:"dismiss"})]}),C&&(0,p.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-error border border-error/40 bg-error/5 font-mono whitespace-pre-wrap break-words max-h-40 overflow-y-auto",children:[C,o&&(0,p.jsx)("button",{type:"button",onClick:()=>l(null),className:"block mt-1 text-text-muted hover:text-text underline",children:"dismiss"})]})]})]}),(0,p.jsx)(a$,{open:c,initialChannelId:i?.channel_id||"",onClose:()=>d(!1),onSave:y})]})}function aq({projectId:e}){let[i,r]=(0,_.useState)(30),[s,n]=(0,_.useState)("30"),[o,l]=(0,_.useState)(!1),[a,h]=(0,_.useState)(null),[c,d]=(0,_.useState)(null),[u,f]=(0,_.useState)(!1),[m,v]=(0,_.useState)(30),[x,b]=(0,_.useState)("30"),[y,S]=(0,_.useState)(!1);(0,_.useEffect)(()=>{fetch(`/api/loop-guard?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{e&&"number"==typeof e.value&&(r(e.value),n(String(e.value)))}).catch(()=>{}),fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i||!Array.isArray(i.projects))return;let r=i.projects.find(i=>i.id===e);if(!r)return;f(!!r.auto_continue_loop_guard);let s=Number.isFinite(r.auto_continue_delay_sec)?r.auto_continue_delay_sec:30;v(s),b(String(s))}).catch(()=>{})},[e]);let w=async(i,r)=>{S(!0);try{let s=await fetch("/api/config");if(!s.ok)throw Error(`GET /api/config ${s.status}`);let n=await s.json();if(!n||!Array.isArray(n.projects))throw Error("config shape");let o=n.projects.findIndex(i=>i.id===e);if(o<0)throw Error(`project ${e} not found`);n.projects[o]={...n.projects[o],auto_continue_loop_guard:i,auto_continue_delay_sec:r};let l=await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!l.ok)throw Error(`PUT /api/config ${l.status}`)}finally{S(!1)}};return(0,p.jsxs)("div",{className:"border border-border rounded p-2 text-[11px] font-mono",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,p.jsx)("span",{className:"uppercase tracking-wider text-text-muted",children:"Loop Guard"}),(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Loop Guard"})," pauses agent-to-agent message chains after this many hops with no human reply. Higher values let agents work longer overnight; lower values add safety against runaway loops. AgentChattr accepts ",(0,p.jsx)("b",{children:"4–50"}),"; QuadWork defaults to ",(0,p.jsx)("b",{children:"30"})," (about 5–6 full PR cycles). Posting any chat message yourself resets the counter immediately."]})]}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-text-muted",children:"Pause after"}),(0,p.jsx)("input",{type:"number",min:4,max:50,value:s,onChange:e=>n(e.target.value),disabled:o,className:"w-12 bg-transparent px-1 py-0.5 border border-border rounded text-text outline-none focus:ring-1 focus:ring-accent"}),(0,p.jsx)("span",{className:"text-text-muted",children:"hops"}),(0,p.jsx)("button",{type:"button",onClick:()=>{let i=parseInt(s,10);!Number.isInteger(i)||i<4||i>50?h("Must be an integer between 4 and 50."):(l(!0),h(null),fetch(`/api/loop-guard?project=${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:i})}).then(async e=>{if(!e.ok){let i=await e.text().catch(()=>"");throw Error(`${e.status}: ${i.slice(0,120)}`)}return e.json()}).then(e=>{r(e.value),d(e.live)}).catch(e=>h(e.message||String(e))).finally(()=>l(!1)))},disabled:o||s===String(i),className:"ml-auto px-2 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:"Apply (writes config.toml + live-pushes to AgentChattr)",children:o?"…":"Apply"})]}),a&&(0,p.jsx)("div",{className:"mt-1 text-[10px] text-red-400",children:a}),!1===c&&!a&&(0,p.jsx)("div",{className:"mt-1 text-[10px] text-text-muted",children:"Saved to config.toml — live update failed; takes effect on next AC restart."}),(0,p.jsxs)("label",{className:"mt-2 flex items-center gap-1.5 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,p.jsx)("input",{type:"checkbox",checked:u,disabled:y,onChange:e=>{let i=e.target.checked;f(i),w(i,m).catch(()=>{f(!i)})}}),"Auto-continue after pause",(0,p.jsx)("span",{className:"text-text-muted",children:"— wait"}),(0,p.jsx)("input",{type:"number",min:5,max:300,value:x,disabled:y||!u,onChange:e=>b(e.target.value),onBlur:()=>{let e=parseInt(x,10),i=Number.isFinite(e)?Math.max(5,Math.min(300,e)):30;v(i),b(String(i)),i!==m&&w(u,i).catch(()=>{})},className:"w-10 bg-transparent px-1 py-0.5 border border-border rounded text-text outline-none focus:ring-1 focus:ring-accent disabled:opacity-40 text-center"}),(0,p.jsx)("span",{className:"text-text-muted",children:"s before /continue"})]})]})}function aV({projectId:e}){let i=(0,_.useRef)(null),[r,s]=(0,_.useState)(null),[n,o]=(0,_.useState)(null),[l,a]=(0,_.useState)(null),[h,c]=(0,_.useState)([]),[d,u]=(0,_.useState)(!1),[f,m]=(0,_.useState)(!1);(0,_.useEffect)(()=>{fetch("/api/config").then(e=>e.ok?e.json():null).then(i=>{if(!i||!Array.isArray(i.projects))return;let r=i.projects.find(i=>i.id===e);r&&u(!!r.auto_restore_after_restart)}).catch(()=>{})},[e]);let v=async i=>{m(!0);try{let r=await fetch("/api/config");if(!r.ok)throw Error(`GET /api/config ${r.status}`);let s=await r.json(),n=s.projects?.findIndex(i=>i.id===e)??-1;if(n<0)throw Error("project not found");s.projects[n]={...s.projects[n],auto_restore_after_restart:i};let o=await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!o.ok)throw Error(`PUT /api/config ${o.status}`)}finally{m(!1)}},x=()=>{fetch(`/api/project-history/snapshots?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{e&&Array.isArray(e.snapshots)&&c(e.snapshots)}).catch(()=>{})};(0,_.useEffect)(()=>{x();let e=setInterval(x,15e3);return()=>clearInterval(e)},[e]);let b=async i=>{if(window.confirm(`Restore snapshot ${i}? This will replay every message through AgentChattr (tagged by the original sender) and may duplicate history already in the chat. Continue?`)){s("restore"),o(null),a(null);try{let r=await fetch(`/api/project-history/restore?project=${encodeURIComponent(e)}&name=${encodeURIComponent(i)}`,{method:"POST"}),s=await r.json().catch(()=>null);if(!r.ok)throw Error(s&&s.error||`HTTP ${r.status}`);s&&"number"==typeof s.imported&&a(s)}catch(e){o(e.message||String(e))}finally{s(null),x()}}},y=async()=>{s("export"),o(null),a(null);try{let i=await fetch(`/api/project-history?project=${encodeURIComponent(e)}`);if(!i.ok){let e=await i.text().catch(()=>"");throw Error(`HTTP ${i.status}: ${e.slice(0,200)}`)}let r=await i.blob(),s=URL.createObjectURL(r),n=document.createElement("a"),o=new Date().toISOString().slice(0,10);n.href=s,n.download=`${e}-history-${o}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(s)}catch(e){o(e.message||String(e))}finally{s(null)}},S=async r=>{let n;if(r.size>0xa00000)return void o(`File too large (${r.size} bytes; limit 10485760)`);s("import"),o(null),a(null);try{let e=await r.text();n=JSON.parse(e)}catch(e){s(null),o(`Invalid JSON: ${e.message||String(e)}`);return}if(!n||"object"!=typeof n||!Array.isArray(n.messages)){s(null),o("File missing 'messages' array");return}let l=!1;if(n.project_id&&n.project_id!==e){if(!window.confirm(`This export is from project '${n.project_id}' but you're importing into '${e}'. Continue anyway?`))return void s(null);l=!0}let h=new Set(["head","dev","reviewer1","reviewer2","re1","re2","t1","t2a","t2b","t3","system"]),c=!1,d=new Set;for(let e of n.messages)if(e&&"object"==typeof e){let i=e.sender;if("string"==typeof i&&h.has(i.toLowerCase())&&(d.add(i),d.size>=5))break}if(d.size>0){if(!window.confirm(`This export contains messages attributed to reserved agent/system identities (${[...d].join(", ")}). Importing will replay them as those agents — only do this for a legitimate disaster-recovery restore. Continue?`))return void s(null);c=!0}let u=!1,f=i=>fetch(`/api/project-history?project=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...n,allow_project_mismatch:l,allow_agent_senders:c,allow_duplicate:u,...i})});try{let e=await f({}),i=await e.json().catch(()=>null);if(409===e.status&&i&&"string"==typeof i.error&&/already imported/i.test(i.error)){if(!window.confirm(`${i.error}
26
26
 
27
27
  This file looks like it was already imported. Re-import will duplicate every message. Continue anyway?`))return void s(null);u=!0,e=await f({allow_duplicate:!0}),i=await e.json().catch(()=>null)}if(!e.ok)throw Error(i&&i.error||`HTTP ${e.status}`);a(i)}catch(e){o(e.message||String(e))}finally{s(null),i.current&&(i.current.value="")}};return(0,p.jsxs)("div",{className:"border border-border rounded p-2 text-[11px] font-mono",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted uppercase tracking-wider mb-1.5",children:["Project History",(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Project History"})," — export or import the full AgentChattr chat history for this project. Useful for backup, migration, or resuming after a fresh install."]})]}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,p.jsx)("button",{type:"button",onClick:y,disabled:null!==r,className:"px-2 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:"Download a JSON snapshot of this project's chat history",children:"export"===r?"…":`Export ${e} chat`}),(0,p.jsx)("button",{type:"button",onClick:()=>{o(null),a(null),i.current?.click()},disabled:null!==r,className:"px-2 py-0.5 text-[10px] text-text-muted border border-border rounded hover:text-text hover:border-accent transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:"Restore a previously exported chat history (JSON)",children:"import"===r?"Importing…":"Import history…"}),(0,p.jsx)("input",{ref:i,type:"file",accept:"application/json,.json",className:"hidden",onChange:e=>{let i=e.target.files&&e.target.files[0];i&&S(i)}})]}),n&&(0,p.jsx)("div",{className:"mt-1 text-[10px] text-red-400",children:n}),l&&(0,p.jsxs)("div",{className:"mt-1 text-[10px] text-text-muted",children:["Imported ",l.imported," / ",l.total,l.skipped>0&&` \xb7 skipped ${l.skipped}`,l.errors.length>0&&` \xb7 ${l.errors.length} errors`]}),(0,p.jsxs)("label",{className:"mt-2 flex items-center gap-1.5 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,p.jsx)("input",{type:"checkbox",checked:d,disabled:f,onChange:e=>{let i=e.target.checked;u(i),v(i).catch(()=>u(!i))}}),"Auto-restore newest snapshot after AC restart"]}),h.length>0&&(0,p.jsxs)("div",{className:"mt-2 border-t border-border/50 pt-1.5",children:[(0,p.jsx)("div",{className:"text-[9px] text-text-muted uppercase tracking-wider mb-0.5",children:"Auto-snapshots (before restart)"}),h.map(e=>{let i=new Date(e.mtime).toLocaleString();return(0,p.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] py-0.5",children:[(0,p.jsx)("span",{className:"text-text-muted tabular-nums flex-1 truncate",title:e.name,children:i}),(0,p.jsxs)("span",{className:"text-text-muted tabular-nums shrink-0",children:[Math.round(e.size/1024),"KB"]}),(0,p.jsx)("button",{type:"button",onClick:()=>b(e.name),disabled:null!==r,className:"px-1.5 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:`Restore ${e.name}`,children:"restore"===r?"…":"Restore"})]},e.name)})]})]})}let aY=["minimal","low","medium","high"],aG={codex:[{value:"",label:"(CLI default)"},{value:"gpt-5.4",label:"gpt-5.4"},{value:"gpt-5",label:"gpt-5"},{value:"gpt-4o",label:"gpt-4o"}],claude:[{value:"",label:"(CLI default)"},{value:"claude-opus-4-6",label:"claude-opus-4-6"},{value:"claude-sonnet-4-6",label:"claude-sonnet-4-6"},{value:"claude-haiku-4-5-20251001",label:"claude-haiku-4-5"}]};function aX(e){return aG[e]||[{value:"",label:"(CLI default)"}]}function aJ({projectId:e,onClose:i}){let[r,s]=(0,_.useState)(null),[n,o]=(0,_.useState)(null),[l,a]=(0,_.useState)(null),[h,c]=(0,_.useState)(new Set),d=(0,_.useCallback)(async()=>{try{let i=await fetch(`/api/project/${encodeURIComponent(e)}/agent-models`);if(!i.ok)throw Error(`${i.status}`);let r=await i.json();s(r.agents||[]),o(null)}catch(e){o(e.message)}},[e]);(0,_.useEffect)(()=>{d()},[d]),(0,_.useEffect)(()=>{let e=e=>{"Escape"===e.key&&i()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[i]);let u=async(i,r)=>{a(i),o(null);try{let s=await fetch(`/api/project/${encodeURIComponent(e)}/agent-models/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),n=await s.json();if(!s.ok||!1===n.ok)throw Error(n.error||`${s.status}`);c(e=>{let r=new Set(e);return r.add(i),r}),await d()}catch(e){o(e.message)}finally{a(null)}},f=async i=>{a(i),o(null);try{let r=await fetch(`/api/agents/${encodeURIComponent(e)}/${encodeURIComponent(i)}/restart`,{method:"POST"}),s=await r.json();if(!r.ok||!1===s.ok)throw Error(s.error||`${r.status}`);c(e=>{let r=new Set(e);return r.delete(i),r})}catch(e){o(e.message)}finally{a(null)}};return(0,p.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:i,role:"dialog","aria-modal":"true","aria-labelledby":"agent-models-title",children:(0,p.jsxs)("div",{className:"relative mx-4 w-full max-w-[520px] max-h-[90vh] overflow-auto rounded-lg border border-white/10 bg-neutral-950 p-6 shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,p.jsx)("button",{type:"button",onClick:i,"aria-label":"Close",className:"absolute right-3 top-3 rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,p.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,p.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})}),(0,p.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,p.jsx)("h2",{id:"agent-models-title",className:"text-base font-semibold text-white",children:"Agent Models"}),n&&(0,p.jsxs)("span",{className:"text-[10px] text-error max-w-[60%] truncate ml-2",title:n,children:["err: ",n]})]}),(0,p.jsxs)("div",{className:"flex flex-col gap-1.5",children:[!r&&(0,p.jsx)("div",{className:"text-[11px] text-text-muted",children:"Loading…"}),r&&0===r.length&&(0,p.jsx)("div",{className:"text-[11px] text-text-muted",children:"No agents configured."}),r&&r.map(e=>(0,p.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,p.jsx)("span",{className:"text-[11px] text-text font-semibold w-16 shrink-0",children:e.agent_id}),(0,p.jsx)("span",{className:"text-[10px] text-text-muted w-12 shrink-0",children:e.backend}),h.has(e.agent_id)&&(0,p.jsx)("span",{className:"text-[9px] text-[#ffcc00] border border-[#ffcc00]/40 px-1 py-[1px] shrink-0",title:"Config changed — running session is still on the old model/effort. Click Restart to apply.",children:"restart required"}),(0,p.jsxs)("select",{value:e.model,disabled:l===e.agent_id,onChange:i=>u(e.agent_id,{model:i.target.value}),className:"flex-1 min-w-[140px] bg-transparent border border-border px-1 py-0.5 text-[11px] font-mono text-text outline-none focus:border-accent cursor-pointer disabled:opacity-50",children:[aX(e.backend).map(e=>(0,p.jsx)("option",{value:e.value,className:"bg-bg-surface",children:e.label},e.value)),e.model&&!aX(e.backend).some(i=>i.value===e.model)&&(0,p.jsxs)("option",{value:e.model,className:"bg-bg-surface",children:[e.model," (custom)"]})]}),e.reasoning_supported?(0,p.jsxs)("select",{value:e.reasoning_effort||"",disabled:l===e.agent_id,onChange:i=>u(e.agent_id,{reasoning_effort:i.target.value}),className:"bg-transparent border border-border px-1 py-0.5 text-[11px] text-text outline-none focus:border-accent cursor-pointer disabled:opacity-50",children:[(0,p.jsx)("option",{value:"",className:"bg-bg-surface",children:"(default)"}),aY.map(e=>(0,p.jsx)("option",{value:e,className:"bg-bg-surface",children:e},e))]}):(0,p.jsx)("span",{className:"text-[10px] text-text-muted w-16 text-center",children:"—"}),(0,p.jsx)("button",{type:"button",onClick:()=>f(e.agent_id),disabled:l===e.agent_id,title:"Restart this agent to pick up the new model / reasoning setting",className:"shrink-0 px-1.5 py-0.5 text-[10px] text-text-muted border border-border hover:text-accent hover:border-accent/40 disabled:opacity-50 transition-colors",children:l===e.agent_id?"…":"Restart"})]},e.agent_id)),(0,p.jsxs)("p",{className:"mt-2 text-[10px] text-text-muted leading-snug",children:["Codex reasoning effort defaults to ",(0,p.jsx)("code",{className:"text-text",children:"medium"})," for new projects. Blank model falls back to the CLI default. Click Restart to apply changes to a live session."]})]})]})})}function aQ({projectId:e}){let[i,r]=(0,_.useState)(!1),[s,n]=(0,_.useState)(null);return(0,_.useEffect)(()=>{let i=!1;return fetch(`/api/project/${encodeURIComponent(e)}/agent-models`).then(e=>e.ok?e.json():null).then(e=>{i||!e||n((e.agents||[]).map(e=>({id:e.agent_id,backend:e.backend})))}).catch(()=>{}),()=>{i=!0}},[e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,p.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,p.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:"Agent Models"}),(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Agent Models"})," — configure which LLM model and reasoning effort each agent uses. Changes require an agent restart to take effect."]})]}),(0,p.jsx)("button",{type:"button",onClick:()=>r(!0),className:"px-2 py-0.5 text-[10px] text-text-muted border border-border hover:text-accent hover:border-accent/40 transition-colors",children:"Configure →"})]}),s&&s.length>0&&(0,p.jsx)("div",{className:"px-3 py-1 text-[10px] text-text-muted truncate",title:s.map(e=>`${e.id}: ${e.backend}`).join(" · "),children:s.map((e,i)=>(0,p.jsxs)("span",{children:[i>0&&(0,p.jsx)("span",{className:"text-text-muted/60",children:" · "}),(0,p.jsx)("span",{className:"text-text",children:e.id}),(0,p.jsxs)("span",{children:[": ",e.backend]})]},e.id))})]}),i&&(0,p.jsx)(aJ,{projectId:e,onClose:()=>r(!1)})]})}function aZ({projectId:e}){return(0,p.jsxs)("div",{className:"flex flex-col h-full min-h-0",children:[(0,p.jsx)(m,{label:"Operator Features",tooltip:(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Operator Features"})," — tools for running autonomous overnight batches. Includes the Scheduled Trigger, Telegram Bridge, Loop Guard, Project History, and Agent Models."]})}),(0,p.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col lg:flex-row gap-2 p-2 overflow-auto lg:overflow-hidden",children:[(0,p.jsx)("div",{className:"lg:flex-1 lg:min-w-[280px] lg:min-h-0",children:(0,p.jsx)(az,{projectId:e})}),(0,p.jsx)("div",{className:"hidden lg:block w-px self-stretch bg-border"}),(0,p.jsxs)("div",{className:"lg:flex-1 lg:min-h-0 lg:overflow-y-auto flex flex-col gap-2",children:[(0,p.jsx)(aQ,{projectId:e}),(0,p.jsx)(aW,{projectId:e}),(0,p.jsx)(aK,{projectId:e}),(0,p.jsx)(aq,{projectId:e}),(0,p.jsx)(aV,{projectId:e})]})]})]})}e.s(["default",0,function({projectId:e}){let i=(0,_.useRef)(null),[r,s]=(0,_.useState)(.5),[n,o]=(0,_.useState)(.5),l=(0,_.useRef)(null),[a,h]=(0,_.useState)({});(0,_.useEffect)(()=>{let i=()=>{fetch("/api/agents").then(e=>e.ok?e.json():{}).then(i=>{let r={};for(let[s,n]of Object.entries(i))s.startsWith(`${e}/`)&&(r[s.split("/")[1]]=n.state);h(r)}).catch(()=>{})};i();let r=setInterval(i,5e3);return()=>clearInterval(r)},[e]);let c=(0,_.useCallback)((e,i)=>Math.min((i-4-150)/i,Math.max(150/i,e)),[]);(0,_.useEffect)(()=>{let e=e=>{if(!l.current||!i.current)return;let r=i.current.getBoundingClientRect();"col"===l.current?s(c((e.clientX-r.left)/r.width,r.width)):o(c((e.clientY-r.top)/r.height,r.height))},r=()=>{l.current=null,document.body.style.cursor="",document.body.style.userSelect=""};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",r),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",r)}},[c]);let d=e=>{l.current=e,document.body.style.cursor="col"===e?"col-resize":"row-resize",document.body.style.userSelect="none"},u=`${100*r}% 4px 1fr`,f=`${100*n}% 4px 1fr`;return(0,p.jsxs)("div",{ref:i,className:"w-full h-full",style:{display:"grid",gridTemplateColumns:u,gridTemplateRows:f},children:[(0,p.jsxs)("div",{className:"flex flex-col overflow-hidden border-2 border-accent",children:[(0,p.jsx)(m,{label:"AgentChattr — primary chat",tooltip:(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"Primary Chat"})," — live chat between you and the 4 AI agents. Messages you type here trigger agent actions. Use @mentions to address specific agents."]})}),(0,p.jsx)("div",{className:"flex-1 min-h-0",children:(0,p.jsx)(E,{projectId:e})}),(0,p.jsx)(i8,{projectId:e})]}),(0,p.jsx)("div",{className:"bg-border cursor-col-resize hover:bg-accent-dim transition-colors",onMouseDown:()=>d("col")}),(0,p.jsx)("div",{className:"flex flex-col overflow-hidden",children:(0,p.jsx)(aL,{projectId:e,agentStates:a,onStatusChange:(e,i)=>{h(r=>({...r,[e]:i}))}})}),(0,p.jsx)("div",{className:"bg-border cursor-row-resize hover:bg-accent-dim transition-colors",onMouseDown:()=>d("row")}),(0,p.jsx)("div",{className:"bg-border cursor-move",onMouseDown:()=>d("col")}),(0,p.jsx)("div",{className:"bg-border cursor-row-resize hover:bg-accent-dim transition-colors",onMouseDown:()=>d("row")}),(0,p.jsxs)("div",{className:"flex flex-col overflow-hidden",children:[(0,p.jsx)(m,{label:"GitHub",tooltip:(0,p.jsxs)(g,{children:[(0,p.jsx)("b",{children:"GitHub"}),"— open issues and pull requests on this project's repo. Click any item to open it on GitHub. The batch progress panel tracks the active batch's lifecycle from queued to merged."]})}),(0,p.jsx)("div",{className:"flex-1 min-h-0",children:(0,p.jsx)(i2,{projectId:e})})]}),(0,p.jsx)("div",{className:"bg-border cursor-col-resize hover:bg-accent-dim transition-colors",onMouseDown:()=>d("col")}),(0,p.jsx)(aZ,{projectId:e})]})}],55601)},73766,e=>{e.n(e.i(55601))}]);