@seqyuan/ennote 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/ennote.js +67 -4
- package/out/404.html +1 -1
- package/out/__next.__PAGE__.txt +3 -3
- package/out/__next._full.txt +14 -14
- package/out/__next._head.txt +4 -4
- package/out/__next._index.txt +8 -8
- package/out/__next._tree.txt +3 -3
- package/out/_next/static/chunks/0g-kg938ndquq.js +1 -0
- package/out/_next/static/chunks/0idisn4yqj2rr.js +5 -0
- package/out/_next/static/chunks/0l-yuxi7.69...css +4 -0
- package/out/_next/static/chunks/{0.wpvl571pzdr.js → 0pj391wb1h7.m.js} +1 -1
- package/out/_next/static/chunks/0ri8s9~7lcxyn.css +1 -0
- package/out/_next/static/chunks/{0oyu_2qstzqx..js → 0s_nb9cy-6day.js} +1 -1
- package/out/_next/static/chunks/{04p06dbbab3-j.js → 0twsdyb7~zp7n.js} +1 -1
- package/out/_not-found/__next._full.txt +13 -13
- package/out/_not-found/__next._head.txt +4 -4
- package/out/_not-found/__next._index.txt +8 -8
- package/out/_not-found/__next._not-found.__PAGE__.txt +2 -2
- package/out/_not-found/__next._not-found.txt +3 -3
- package/out/_not-found/__next._tree.txt +3 -3
- package/out/_not-found.html +1 -1
- package/out/_not-found.txt +13 -13
- package/out/graphs/__next._full.txt +14 -14
- package/out/graphs/__next._head.txt +4 -4
- package/out/graphs/__next._index.txt +8 -8
- package/out/graphs/__next._tree.txt +3 -3
- package/out/graphs/__next.graphs.__PAGE__.txt +3 -3
- package/out/graphs/__next.graphs.txt +3 -3
- package/out/graphs.html +1 -1
- package/out/graphs.txt +14 -14
- package/out/index.html +2 -2
- package/out/index.txt +14 -14
- package/out/roles/__next._full.txt +14 -14
- package/out/roles/__next._head.txt +4 -4
- package/out/roles/__next._index.txt +8 -8
- package/out/roles/__next._tree.txt +3 -3
- package/out/roles/__next.roles.__PAGE__.txt +3 -3
- package/out/roles/__next.roles.txt +3 -3
- package/out/roles.html +1 -1
- package/out/roles.txt +14 -14
- package/package.json +1 -1
- package/out/_next/static/chunks/0ombdwxw-jhba.js +0 -5
- package/out/_next/static/chunks/0xrv715wp_u0r.js +0 -1
- package/out/_next/static/chunks/13l74abld3yhh.css +0 -4
- package/out/_next/static/chunks/17ew~_kbp84gv.css +0 -1
- /package/out/_next/static/{OkDTUeyrr8mnrVgOvGEDk → KIuAhMlwtN3Tw5BdPWx9k}/_buildManifest.js +0 -0
- /package/out/_next/static/{OkDTUeyrr8mnrVgOvGEDk → KIuAhMlwtN3Tw5BdPWx9k}/_clientMiddlewareManifest.js +0 -0
- /package/out/_next/static/{OkDTUeyrr8mnrVgOvGEDk → KIuAhMlwtN3Tw5BdPWx9k}/_ssgManifest.js +0 -0
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,26568,(e,t,n)=>{"use strict";var r=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,i=/\n/g,s=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,l=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,d=/^\s+|\s+$/g;function u(e){return e?e.replace(d,""):""}t.exports=function(e,t){if("string"!=typeof e)throw TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,d=1;function p(e){var t=e.match(i);t&&(n+=t.length);var r=e.lastIndexOf("\n");d=~r?e.length-r:d+e.length}function h(){var e={line:n,column:d};return function(t){return t.position=new m(e),g(s),t}}function m(e){this.start=e,this.end={line:n,column:d},this.source=t.source}function f(r){var i=Error(t.source+":"+n+":"+d+": "+r);if(i.reason=r,i.filename=t.source,i.line=n,i.column=d,i.source=e,t.silent);else throw i}function g(t){var n=t.exec(e);if(n){var r=n[0];return p(r),e=e.slice(r.length),n}}function x(e){var t;for(e=e||[];t=y();)!1!==t&&e.push(t);return e}function y(){var t=h();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var n=2;""!=e.charAt(n)&&("*"!=e.charAt(n)||"/"!=e.charAt(n+1));)++n;if(n+=2,""===e.charAt(n-1))return f("End of comment missing");var r=e.slice(2,n-2);return d+=2,p(r),e=e.slice(n),d+=2,t({type:"comment",comment:r})}}m.prototype.content=e,g(s);var v,b=[];for(x(b);v=function(){var e=h(),t=g(a);if(t){if(y(),!g(l))return f("property missing ':'");var n=g(o),i=e({type:"declaration",property:u(t[0].replace(r,"")),value:n?u(n[0].replace(r,"")):""});return g(c),i}}();)!1!==v&&(b.push(v),x(b));return b}},30070,(e,t,n)=>{"use strict";var r=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t){let n=null;if(!e||"string"!=typeof e)return n;let r=(0,i.default)(e),s="function"==typeof t;return r.forEach(e=>{if("declaration"!==e.type)return;let{property:r,value:i}=e;s?t(r,i,e):i&&((n=n||{})[r]=i)}),n};let i=r(e.r(26568))},65185,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.camelCase=void 0;var r=/^--[a-zA-Z0-9_-]+$/,i=/-([a-z])/g,s=/^[^-]+$/,a=/^-(webkit|moz|ms|o|khtml)-/,l=/^-(ms)-/,o=function(e,t){return t.toUpperCase()},c=function(e,t){return"".concat(t,"-")};n.camelCase=function(e,t){var n;return(void 0===t&&(t={}),!(n=e)||s.test(n)||r.test(n))?e:(e=e.toLowerCase(),(e=t.reactCompat?e.replace(l,c):e.replace(a,c)).replace(i,o))}},15511,(e,t,n)=>{"use strict";var r=(e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(e.r(30070)),i=e.r(65185);function s(e,t){var n={};return e&&"string"==typeof e&&(0,r.default)(e,function(e,r){e&&r&&(n[(0,i.camelCase)(e,t)]=r)}),n}s.default=s,t.exports=s},4100,(e,t,n)=>{"use strict";var r=Object.prototype.hasOwnProperty,i=Object.prototype.toString,s=Object.defineProperty,a=Object.getOwnPropertyDescriptor,l=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===i.call(e)},o=function(e){if(!e||"[object Object]"!==i.call(e))return!1;var t,n=r.call(e,"constructor"),s=e.constructor&&e.constructor.prototype&&r.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!s)return!1;for(t in e);return void 0===t||r.call(e,t)},c=function(e,t){s&&"__proto__"===t.name?s(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},d=function(e,t){if("__proto__"===t){if(!r.call(e,t))return;else if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,s,a,u=arguments[0],p=1,h=arguments.length,m=!1;for("boolean"==typeof u&&(m=u,u=arguments[1]||{},p=2),(null==u||"object"!=typeof u&&"function"!=typeof u)&&(u={});p<h;++p)if(t=arguments[p],null!=t)for(n in t)r=d(u,n),u!==(i=d(t,n))&&(m&&i&&(o(i)||(s=l(i)))?(s?(s=!1,a=r&&l(r)?r:[]):a=r&&o(r)?r:{},c(u,{name:n,newValue:e(m,a,i)})):void 0!==i&&c(u,{name:n,newValue:i}));return u}},59665,e=>{"use strict";var t=e.i(18050),n=e.i(71645);let r=(...e)=>e.filter((e,t,n)=>!!e&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim(),i=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)};var s={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let a=(0,n.createContext)({}),l=(0,n.forwardRef)(({color:e,size:t,strokeWidth:i,absoluteStrokeWidth:l,className:o="",children:c,iconNode:d,...u},p)=>{let{size:h=24,strokeWidth:m=2,absoluteStrokeWidth:f=!1,color:g="currentColor",className:x=""}=(0,n.useContext)(a)??{},y=l??f?24*Number(i??m)/Number(t??h):i??m;return(0,n.createElement)("svg",{ref:p,...s,width:t??h??s.width,height:t??h??s.height,stroke:e??g,strokeWidth:y,className:r("lucide",x,o),...!c&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1})(u)&&{"aria-hidden":"true"},...u},[...d.map(([e,t])=>(0,n.createElement)(e,t)),...Array.isArray(c)?c:[c]])}),o=(e,t)=>{let s=(0,n.forwardRef)(({className:s,...a},o)=>(0,n.createElement)(l,{ref:o,iconNode:t,className:r(`lucide-${i(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,s),...a}));return s.displayName=i(e),s},c=o("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]),d=o("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),u=o("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),p=o("settings-2",[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]),h=o("workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]),m=o("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);var f=e.i(27437);function g(e){let{onToggleSidebar:n,onCloseNavigation:r}=e,i=(0,f.useT)();return(0,t.jsxs)("div",{className:"sidebar-logo-row",children:[(0,t.jsxs)("div",{className:"sidebar-brand",children:[(0,t.jsx)("span",{className:"brand-mark",children:"E"}),(0,t.jsx)("strong",{children:"Ennote"})]}),(0,t.jsx)("button",{type:"button",className:"sidebar-collapse-toggle",onClick:n,title:i("sidebar.collapse"),"aria-label":i("sidebar.collapseNav"),"aria-expanded":"true","aria-controls":"workspace-navigation",children:(0,t.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,t.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,t.jsx)("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),(0,t.jsx)("button",{type:"button",className:"sidebar-close-nav navigation-close",onClick:r,"aria-label":i("sidebar.closeNav"),children:(0,t.jsx)(m,{size:15})})]})}let x=o("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);function y(e){let{disabled:n,onClick:r}=e,i=(0,f.useT)();return(0,t.jsxs)("button",{type:"button",className:"sidebar-new-session",disabled:n,onClick:r,"aria-label":i("sidebar.newChatAria"),title:i(n?"sidebar.selectProjectFirst":"sidebar.newChatAria"),children:[(0,t.jsx)(x,{size:14,"aria-hidden":"true"}),(0,t.jsx)("span",{children:i("sidebar.newChat")})]})}function v({active:e,label:n,icon:r,onClick:i}){return(0,t.jsxs)("button",{type:"button",className:`sidebar-nav-item ${e?"active":""}`,"aria-current":e?"page":void 0,onClick:i,children:[(0,t.jsx)("span",{className:"nav-icon",children:r}),(0,t.jsx)("span",{children:n})]})}let b=o("archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),j=o("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),k=o("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),w=o("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]),S=o("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]),C=o("triangle",[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]]);function N({title:e,initialName:r,onCancel:i,onConfirm:s}){let[a,l]=(0,n.useState)(r),[o,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(null),p=(0,n.useRef)(null),h=(0,f.useT)();(0,n.useEffect)(()=>{p.current?.select()},[]);let m=a.trim(),g=o||""===m||m===r,x=async()=>{if(!g){c(!0),u(null);try{await s(m)}catch(e){u(e.message),c(!1)}}};return(0,t.jsx)("div",{className:"sb-dialog-overlay",onPointerDown:e=>{e.target!==e.currentTarget||o||i()},children:(0,t.jsxs)("div",{className:"sb-dialog",role:"dialog","aria-modal":"true","aria-label":e,children:[(0,t.jsx)("h3",{children:e}),(0,t.jsx)("input",{ref:p,className:"sb-dialog-input",value:a,disabled:o,onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"===e.key&&x(),"Escape"===e.key&&i()}}),d&&(0,t.jsx)("div",{className:"sb-dialog-error",role:"alert",children:d}),(0,t.jsxs)("div",{className:"sb-dialog-actions",children:[(0,t.jsx)("button",{type:"button",onClick:i,disabled:o,children:h("sidebar.cancel")}),(0,t.jsx)("button",{type:"button",className:"sb-primary",onClick:x,disabled:g,children:h("sidebar.save")})]})]})})}let I=o("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);function T(e){let t=new Map(e.map(e=>[e.id,{session:e,children:[]}])),n=[];for(let e of t.values()){let r=e.session.sourceSessionId;if(!r||!t.has(r)||function(e,t,n){let r=new Set([e]),i=t;for(;i;){if(r.has(i))return!0;r.add(i),i=n.get(i)?.session.sourceSessionId}return!1}(e.session.id,r,t)){n.push(e);continue}t.get(r).children.push(e)}let r=e=>{e.sort((e,t)=>t.session.updatedAt.localeCompare(e.session.updatedAt)),e.forEach(e=>r(e.children))};return r(n),n}function M(e,n,r,i,s,a,l,o,c,d){return e.flatMap(e=>{let u=e.session,p=u.id===n,h=d?.has(u.id);return[(0,t.jsx)(R,{session:u,view:i,isSelected:p,isRunning:h,depth:c,mutatingId:o,switchSession:r,archiveSession:s,restoreSession:a,renameSession:l},u.id),...M(e.children,n,r,i,s,a,l,o,c+1,d)]})}function R({session:e,view:r,isSelected:i,isRunning:s,depth:a,mutatingId:l,switchSession:o,archiveSession:c,restoreSession:d,renameSession:u}){var p;let h,[m,g]=(0,n.useState)(!1),[x,y]=(0,n.useState)(!1),v=(0,n.useRef)(null),w=(0,f.useT)();return(0,n.useEffect)(()=>{if(!m)return;let e=e=>{v.current?.contains(e.target)||g(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[m]),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("li",{className:`sb-session-row${i?" sb-selected":""}${m?" sb-menu-open":""}`,style:{marginLeft:22*a},children:[(0,t.jsxs)("div",{className:"sb-session-body",role:"button",tabIndex:0,"aria-current":i?"page":void 0,"aria-label":e.title,onClick:()=>"active"===r&&o(e.id),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&"active"===r&&(t.preventDefault(),o(e.id))},children:[(0,t.jsx)("span",{className:"sb-row-slot sb-session-status",children:s&&(0,t.jsx)("span",{className:"sb-running-dot","aria-hidden":"true"})}),(0,t.jsx)("span",{className:"sb-session-title",children:e.title}),(0,t.jsx)("span",{className:"sb-session-time","aria-hidden":"true",children:(p=e.updatedAt,(h=Math.max(0,Date.now()-new Date(p).getTime()))<6e4?w("time.now"):h<36e5?`${Math.floor(h/6e4)}${w("time.minutes")}`:h<864e5?`${Math.floor(h/36e5)}${w("time.hours")}`:h<2592e6?`${Math.floor(h/864e5)}${w("time.days")}`:h<31536e6?`${Math.floor(h/2592e6)}${w("time.months")}`:`${Math.floor(h/31536e6)}${w("time.years")}`)})]}),(0,t.jsxs)("span",{className:"sb-row-actions",ref:v,children:[(0,t.jsx)("button",{type:"button",className:"sb-row-icon-btn","aria-label":`Actions for ${e.title}`,"aria-haspopup":"menu","aria-expanded":m,onClick:e=>{e.stopPropagation(),g(e=>!e)},children:(0,t.jsx)(j,{size:15,"aria-hidden":"true"})}),m&&(0,t.jsxs)("div",{className:"sb-row-menu",role:"menu",children:[(0,t.jsxs)("button",{type:"button",role:"menuitem",disabled:l===e.id||"archived"===r,onClick:e=>{e.stopPropagation(),g(!1),y(!0)},children:[(0,t.jsx)(k,{size:13,"aria-hidden":"true"})," ",w("sidebar.renameSession")]}),(0,t.jsxs)("button",{type:"button",role:"menuitem",disabled:l===e.id,onClick:t=>{t.stopPropagation(),g(!1),"active"===r?c(e):d(e)},children:["active"===r?(0,t.jsx)(b,{size:13,"aria-hidden":"true"}):(0,t.jsx)(I,{size:13,"aria-hidden":"true"}),w("active"===r?"sidebar.archive":"sidebar.restore")]})]})]})]}),x&&(0,t.jsx)(N,{title:w("sidebar.renameSession"),initialName:e.title,onCancel:()=>y(!1),onConfirm:async t=>{await u(e,t),y(!1)}})]})}function E({group:e,isCurrent:r,isPinned:i,isCollapsed:s,onToggleCollapsed:a,onTogglePin:l,query:o,selectedSession:c,switchSession:d,archiveSession:u,restoreSession:p,renameSession:h,renameProject:m,deleteProject:g,createSessionIn:y,mutatingId:v,archived:I,onOpenArchived:R,runningSessionIds:A}){let[P,$]=(0,n.useState)(!1),[L,F]=(0,n.useState)(!1),[D,_]=(0,n.useState)(!1),[O,W]=(0,n.useState)(!1),U=(0,n.useRef)(null),q=(0,f.useT)();(0,n.useEffect)(()=>{if(!L)return;let e=e=>{U.current?.contains(e.target)||F(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[L]);let B=o?e.sessions.filter(e=>e.title.toLowerCase().includes(o)):e.sessions;return(0,t.jsxs)("div",{className:"sidebar-project-group",children:[(0,t.jsxs)("div",{role:"treeitem",tabIndex:0,"aria-expanded":!s,"aria-selected":r,className:`sb-project-row${L?" sb-menu-open":""}`,onClick:a,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),a())},title:e.projectName,children:[(0,t.jsx)("span",{className:`sb-row-slot sb-folder${r?" sb-folder-active":""}`,children:s?(0,t.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M1.5 5A1.5 1.5 0 0 1 3 3.5h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6.5L13.6 11A1.5 1.5 0 0 1 12.1 12.5H3A1.5 1.5 0 0 1 1.5 11V5Z"})}):(0,t.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M1.5 5A1.5 1.5 0 0 1 3 3.5h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6.5L13.6 11A1.5 1.5 0 0 1 12.1 12.5H3A1.5 1.5 0 0 1 1.5 11V5ZM1.5 8V11A1.5 1.5 0 0 0 3 12.5h10A1.5 1.5 0 0 0 14.5 11V8"})})}),(0,t.jsx)("span",{className:"sb-row-slot sb-chevron",children:(0,t.jsx)(C,{size:10,fill:"currentColor",stroke:"none",style:{transform:s?"none":"rotate(90deg)",transition:"transform 0.15s"},"aria-hidden":"true"})}),(0,t.jsx)("span",{className:"sb-project-title",children:e.projectName}),(0,t.jsxs)("span",{className:"sb-row-actions",ref:U,children:[(0,t.jsx)("button",{type:"button",className:"sb-pin-star",title:q(i?"sidebar.unpin":"sidebar.pin"),"aria-label":q(i?"sidebar.unpin":"sidebar.pin"),onClick:e=>{e.stopPropagation(),l()},children:(0,t.jsx)(w,{size:13,fill:i?"currentColor":"none","aria-hidden":"true"})}),(0,t.jsx)("button",{type:"button",className:"sb-row-icon-btn","aria-label":q("sidebar.newSession"),title:q("sidebar.newSession"),onClick:t=>{t.stopPropagation(),y(e.projectId)},children:(0,t.jsx)(x,{size:14,"aria-hidden":"true"})}),(0,t.jsx)("button",{type:"button",className:"sb-row-icon-btn","aria-label":q("sidebar.deleteProject"),"aria-haspopup":"menu","aria-expanded":L,onClick:e=>{e.stopPropagation(),F(e=>!e)},children:(0,t.jsx)(j,{size:15,"aria-hidden":"true"})}),L&&(0,t.jsxs)("div",{className:"sb-row-menu",role:"menu",children:[(0,t.jsxs)("button",{type:"button",role:"menuitem",onClick:e=>{e.stopPropagation(),F(!1),_(!0)},children:[(0,t.jsx)(k,{size:13,"aria-hidden":"true"})," ",q("sidebar.renameProject")]}),(0,t.jsxs)("button",{type:"button",role:"menuitem",className:"is-danger",onClick:e=>{e.stopPropagation(),F(!1),W(!0)},children:[(0,t.jsx)(S,{size:13,"aria-hidden":"true"})," ",q("sidebar.deleteProject")]})]})]})]}),!s&&(0,t.jsxs)("div",{className:"sb-project-children",children:[e.error&&(0,t.jsx)("div",{className:"sidebar-empty",style:{color:"var(--danger)"},children:e.error}),e.loading&&0===B.length?(0,t.jsx)("div",{className:"sidebar-empty",children:q("sidebar.loading")}):0===B.length?(0,t.jsx)("div",{className:"sidebar-empty",role:"status",children:o?`${q("sidebar.noSessionsMatch")} "${o}"`:q("sidebar.noSessions")}):(0,t.jsx)("ul",{className:"session-list","aria-label":`Sessions in ${e.projectName}`,children:M(T(B),c,d,"active",u,p,h,v,0,A)}),(0,t.jsxs)("button",{type:"button",className:"sidebar-archived-toggle","aria-expanded":P,onClick:()=>{let e=!P;$(e),e&&R()},children:[(0,t.jsx)(b,{size:12,"aria-hidden":"true"}),q(P?"sidebar.hideArchived":"sidebar.showArchived")]}),P&&I.length>0&&(0,t.jsx)("ul",{className:"session-list","aria-label":`Archived sessions in ${e.projectName}`,children:M(T(I),c,d,"archived",u,p,h,v,0,A)}),P&&0===I.length&&(0,t.jsx)("div",{className:"sidebar-empty",children:q("sidebar.noArchived")})]}),D&&(0,t.jsx)(N,{title:q("sidebar.renameProject"),initialName:e.projectName,onCancel:()=>_(!1),onConfirm:async t=>{await m(e.projectId,t),_(!1)}}),O&&(0,t.jsx)(z,{projectName:e.projectName,onCancel:()=>W(!1),onConfirm:async()=>{await g(e.projectId),W(!1)}})]})}function z({projectName:e,onCancel:r,onConfirm:i}){let[s,a]=(0,n.useState)(!1),[l,o]=(0,n.useState)(null),c=(0,f.useT)(),d=async()=>{a(!0),o(null);try{await i()}catch(e){o(e.message),a(!1)}};return(0,t.jsx)("div",{className:"sb-dialog-overlay",onPointerDown:e=>{e.target!==e.currentTarget||s||r()},children:(0,t.jsxs)("div",{className:"sb-dialog",role:"dialog","aria-modal":"true","aria-label":c("sidebar.deleteProject"),children:[(0,t.jsx)("h3",{children:c("sidebar.deleteProjectTitle").replace("{name}",e)}),(0,t.jsx)("p",{children:c("sidebar.deleteProjectBody")}),l&&(0,t.jsx)("div",{className:"sb-dialog-error",role:"alert",children:l}),(0,t.jsxs)("div",{className:"sb-dialog-actions",children:[(0,t.jsx)("button",{type:"button",onClick:r,disabled:s,children:c("sidebar.cancel")}),(0,t.jsx)("button",{type:"button",className:"sb-danger",onClick:d,disabled:s,children:c("sidebar.deleteProjectConfirm")})]})]})})}function A(e){let{projects:n,selectedProject:r,pinnedProjectIds:i,togglePinProject:s,onSelect:a,className:l}=e,o=(0,f.useT)();return(0,t.jsxs)("div",{role:"menu","aria-label":"Projects",className:`project-menu ${l??""}`,children:[0===n.length&&(0,t.jsx)("div",{style:{padding:"10px 12px",color:"var(--text-dim)",fontSize:11},children:o("sidebar.noProjects")}),n.map(e=>(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[(0,t.jsxs)("button",{type:"button",onClick:()=>a(e.id),style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0,padding:"8px 4px 8px 10px",background:e.id===r?"var(--bg-selected)":"transparent",border:"none",color:"var(--text)",cursor:"pointer",textAlign:"left",fontSize:12,fontWeight:e.id===r?600:400,transition:"background 0.1s"},onMouseEnter:t=>{e.id!==r&&(t.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:t=>{e.id!==r&&(t.currentTarget.style.background="transparent")},children:[(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:"var(--accent)",opacity:e.id===r?1:.6},children:(0,t.jsx)("path",{d:"M1.5 5A1.5 1.5 0 0 1 3 3.5h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6.5L13.6 11A1.5 1.5 0 0 1 12.1 12.5H3A1.5 1.5 0 0 1 1.5 11V5Z"})}),(0,t.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]}),(0,t.jsx)("button",{type:"button",title:`${i.includes(e.id)?o("sidebar.unpin"):o("sidebar.pin")} ${e.name}`,"aria-label":i.includes(e.id)?o("sidebar.unpin"):o("sidebar.pin"),onClick:()=>s(e.id),style:{display:"grid",placeItems:"center",width:26,height:30,marginRight:2,padding:0,border:"none",borderRadius:5,background:"transparent",cursor:"pointer",flexShrink:0,color:i.includes(e.id)?"#ca8a04":"var(--text-dim)"},children:(0,t.jsx)(w,{size:13,fill:i.includes(e.id)?"currentColor":"none","aria-hidden":"true"})})]},e.id))]})}function P(e){let{projects:n,selectedProject:r,pinnedProjectIds:i,togglePinProject:s,onSelect:a,control:l}=e,{open:o,toggle:c,close:d,rootRef:u}=l,p=(0,f.useT)();return(0,t.jsxs)("div",{ref:u,className:"sidebar-project-selector",style:{position:"relative",padding:"0 10px",display:"flex",alignItems:"stretch",gap:4},children:[(0,t.jsxs)("button",{type:"button",onClick:c,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,padding:"6px 10px",background:r?"var(--bg-hover)":"rgba(37,99,235,0.06)",border:r?"1px solid var(--border)":"1px solid rgba(37,99,235,0.4)",borderRadius:7,cursor:"pointer",fontSize:12,color:"var(--text)",textAlign:"left"},title:r?n.find(e=>e.id===r)?.name??p("sidebar.selectProject"):p("sidebar.selectProject"),"aria-haspopup":"menu","aria-expanded":o,children:[(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:"var(--accent)"},children:(0,t.jsx)("path",{d:"M1.5 5A1.5 1.5 0 0 1 3 3.5h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6.5L13.6 11A1.5 1.5 0 0 1 12.1 12.5H3A1.5 1.5 0 0 1 1.5 11V5Z"})}),(0,t.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--font-mono)",fontSize:11,color:r?"var(--text)":"var(--text-dim)"},children:r?n.find(e=>e.id===r)?.name??p("sidebar.unknown"):p("sidebar.selectProjectEllipsis")}),(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:o?"rotate(180deg)":"none",transition:"transform 0.15s"},children:(0,t.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),o&&(0,t.jsx)(A,{projects:n,selectedProject:r,pinnedProjectIds:i,togglePinProject:s,onSelect:e=>{a(e),d()},className:"sidebar-project-menu"})]})}function $({projects:e,groups:r,selectedProject:i,selectedSession:s,settingsOpen:a,query:l,setQuery:o,mutatingId:x,announcement:b,pinnedProjectIds:j,togglePinProject:k,renameProject:w,deleteProject:S,renameSession:C,createSessionIn:N,collapsed:I,toggleCollapsed:T,archived:M,openArchived:R,createProject:z,createSession:A,switchProject:L,switchSession:F,archiveSession:D,restoreSession:_,openSettings:O,closeNavigation:W,runningSessionIds:U,onToggleSidebar:q,projectSelector:B,view:H,setView:V}){let K=(0,f.useT)(),J=(0,n.useRef)(null),[G,Z]=(0,n.useState)(!1);(0,n.useEffect)(()=>{G&&J.current?.focus({preventScroll:!0})},[G]);let Q=()=>{o(""),Z(!1)};return(0,t.jsxs)("aside",{className:"sidebar","aria-label":K("sidebar.aria"),children:[(0,t.jsx)(g,{onToggleSidebar:q,onCloseNavigation:W}),(0,t.jsx)(y,{disabled:!i,onClick:A}),(0,t.jsxs)("nav",{style:{flexShrink:0,padding:"0 0 8px",display:"flex",flexDirection:"column",gap:2},"aria-label":"Workspace",children:[(0,t.jsx)(v,{active:"roles"===H,label:K("sidebar.roles"),icon:(0,t.jsx)(c,{size:15}),onClick:()=>V("roles")}),(0,t.jsx)(v,{active:"graphs"===H,label:K("sidebar.graphs"),icon:(0,t.jsx)(h,{size:15}),onClick:()=>V("graphs")})]}),(0,t.jsxs)("div",{className:`sidebar-workspace-head${G?" search-expanded":""}`,children:[(0,t.jsx)("span",{className:"workspace-label",children:K("sidebar.workspaces")}),(0,t.jsx)("div",{className:"workspace-search-slot",children:(0,t.jsxs)("div",{className:"workspace-search",children:[(0,t.jsx)("button",{type:"button",className:"workspace-action-button workspace-search-button","aria-label":K("sidebar.searchSessions"),"aria-expanded":G,title:G?void 0:K("sidebar.searchSessions"),onClick:()=>Z(!0),children:(0,t.jsx)(u,{size:G?11:14,"aria-hidden":"true"})}),(0,t.jsx)("input",{ref:J,type:"text",value:l,tabIndex:G?0:-1,placeholder:K("sidebar.searchSessions"),"aria-label":K("sidebar.searchSessions"),onChange:e=>o(e.target.value),onKeyDown:e=>{"Escape"===e.key&&Q()}}),G&&(0,t.jsx)("button",{type:"button",className:"workspace-search-clear","aria-label":K("sidebar.clearSearch"),onClick:Q,children:(0,t.jsx)(m,{size:13,"aria-hidden":"true"})})]})}),(0,t.jsx)("div",{className:"workspace-head-actions",children:(0,t.jsx)("button",{type:"button",className:"workspace-action-button","aria-label":K("sidebar.addWorkspace"),title:K("sidebar.addWorkspace"),onClick:z,children:(0,t.jsx)(d,{size:16,"aria-hidden":"true"})})})]}),(0,t.jsx)(P,{projects:e,selectedProject:i,pinnedProjectIds:j,togglePinProject:k,onSelect:L,control:B}),i&&(0,t.jsx)("section",{className:"sidebar-section sidebar-sessions","aria-label":K("sidebar.sessions"),style:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column"},children:(0,t.jsx)("div",{style:{flex:"1 1 auto",overflowY:"auto",minHeight:0,padding:"0 6px 8px"},children:0===r.length?(0,t.jsx)("div",{className:"sidebar-empty",children:K("sidebar.loadingSessions")}):r.map(e=>(0,t.jsx)(E,{group:e,isCurrent:e.projectId===i,isPinned:j.includes(e.projectId),isCollapsed:I.has(e.projectId),onToggleCollapsed:()=>T(e.projectId),onTogglePin:()=>k(e.projectId),query:l.trim(),selectedSession:s,switchSession:F,archiveSession:D,restoreSession:_,renameSession:C,renameProject:w,deleteProject:S,createSessionIn:N,mutatingId:x,archived:M[e.projectId]??[],onOpenArchived:()=>R(e.projectId),runningSessionIds:U},e.projectId))})}),!i&&(0,t.jsx)("div",{style:{flex:"1 1 auto",display:"flex",alignItems:"center",justifyContent:"center",padding:18},children:(0,t.jsx)("div",{style:{textAlign:"center",color:"var(--text-dim)",fontSize:12},children:(0,t.jsx)("div",{children:K("sidebar.chooseProject")})})}),(0,t.jsx)("span",{className:"sr-only",role:"status","aria-live":"polite",children:b}),(0,t.jsx)("div",{className:"sidebar-section sidebar-settings",style:{flexShrink:0},children:(0,t.jsxs)("button",{className:`sidebar-item sidebar-button ${a?"active":""}`,onClick:()=>O(),"aria-haspopup":"dialog","aria-expanded":a,children:[(0,t.jsx)(p,{size:15,"aria-hidden":"true"}),(0,t.jsx)("span",{children:K("sidebar.settings")})]})})]})}let L=o("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]);function F({onClick:e}){let n=(0,f.useT)();return(0,t.jsx)("button",{type:"button",className:"sidebar-expand-fab","aria-label":n("sidebar.openNav"),title:n("sidebar.expand"),"aria-expanded":"false","aria-controls":"workspace-navigation",onClick:e,children:(0,t.jsx)(L,{size:18,"aria-hidden":"true"})})}let D=o("image-plus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]),_=o("list-plus",[["path",{d:"M16 5H3",key:"m91uny"}],["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 19H3",key:"zzsher"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]),O=o("minimize-2",[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]),W=o("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]),U=o("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),q=o("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),B=o("user-round",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);function H({roles:e,selectedRoleId:r,disabled:i,onSelect:s}){let[a,l]=(0,n.useState)(!1),[o,d]=(0,n.useState)(""),p=(0,n.useRef)(null),h=e.find(e=>e.id===r)??null,m=(0,n.useMemo)(()=>{let t=o.trim().toLowerCase();return t?e.filter(e=>[e.name,e.handle,e.positioning].some(e=>e.toLowerCase().includes(t))):e},[o,e]);function f(e){s(e),l(!1),d("")}return(0,n.useEffect)(()=>{if(!a)return;let e=e=>{p.current?.contains(e.target)||l(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[a]),(0,t.jsxs)("div",{className:"role-target-picker",ref:p,children:[(0,t.jsxs)("button",{type:"button",className:"role-target-trigger",disabled:i,"aria-haspopup":"listbox","aria-expanded":a,onClick:()=>l(e=>!e),title:"Invocation target",children:[h?(0,t.jsx)(c,{size:13,"aria-hidden":"true"}):(0,t.jsx)(B,{size:13,"aria-hidden":"true"}),(0,t.jsx)("span",{children:h?`@${h.handle}`:"Host"}),(0,t.jsx)(q,{size:12,"aria-hidden":"true"})]}),a&&(0,t.jsxs)("div",{className:"role-target-menu",children:[(0,t.jsxs)("label",{children:[(0,t.jsx)(u,{size:13,"aria-hidden":"true"}),(0,t.jsx)("input",{autoFocus:!0,value:o,placeholder:"Find a Role",onChange:e=>d(e.target.value)})]}),(0,t.jsxs)("div",{role:"listbox","aria-label":"Invocation target",children:[(0,t.jsxs)("button",{type:"button",role:"option","aria-selected":!h,onClick:()=>f(null),children:[(0,t.jsx)(B,{size:14}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:"Host"}),(0,t.jsx)("small",{children:"Default assistant"})]}),!h&&(0,t.jsx)(U,{size:13})]}),m.map(e=>(0,t.jsxs)("button",{type:"button",role:"option","aria-selected":e.id===r,onClick:()=>f(e.id),children:[(0,t.jsx)("span",{className:"role-target-swatch",style:{color:e.color},children:(0,t.jsx)(c,{size:14})}),(0,t.jsxs)("span",{children:[(0,t.jsxs)("strong",{children:["@",e.handle]}),(0,t.jsx)("small",{children:e.positioning||e.name})]}),e.id===r&&(0,t.jsx)(U,{size:13})]},e.id)),0===m.length&&(0,t.jsx)("span",{className:"role-target-empty",children:"No matching Roles"})]})]})]})}function V(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??`{${n}}`)}function K(e){return e.charAt(0).toUpperCase()+e.slice(1)}function J(){return(0,t.jsx)("svg",{className:"model-select-cell-chevron",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M5.25 3.5L8.75 7L5.25 10.5"})})}function G({size:e=16}){return(0,t.jsx)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("polyline",{points:"3 8.5 6.5 12 13 4.5"})})}function Z({models:e,selectedModelId:r,setSelectedModelId:i,thinkingEffort:s,setThinkingEffort:a,disabled:l}){let o=0,c=(0,f.useT)(),[d,u]=(0,n.useState)(!1),[p,h]=(0,n.useState)("root"),m=(0,n.useRef)(null),g=(0,n.useRef)(null),x=(0,n.useId)(),y=(0,n.useMemo)(()=>e.find(e=>e.id===r)??null,[e,r]),v=(0,n.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.providerId)??[];e.push(n),t.set(n.providerId,e)}return[...t.entries()]},[e]),b=y?.supportsThinking?y:null,j=(0,n.useMemo)(()=>{if(!b)return[];let e=b.supportedThinkingEfforts;return e&&e.length>0?e:["default"]},[b]),k=j.length>0&&j.includes(s)?s:"default",w=null===b?void 0:K(k);(0,n.useEffect)(()=>{!y||(y.supportsThinking&&y.supportedThinkingEfforts?.length?y.supportedThinkingEfforts:["default"]).includes(s)||a("default")},[r]);let S=y?.displayName||y?.modelName||c("composer.modelSelect.triggerFallback"),C=void 0===w?S:`${S} \xb7 ${w}`,N=null===y?c("composer.modelSelect.selectAria"):void 0===w?V(c("composer.modelSelect.aria"),{model:S}):V(c("composer.modelSelect.ariaEffort"),{model:S,effort:w}),I=(e=!1)=>{u(!1),h("root"),e&&queueMicrotask(()=>{g.current?.focus()})};return(0,n.useEffect)(()=>{if(!d)return;let e=e=>{m.current?.contains(e.target)||u(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[d]),(0,n.useEffect)(()=>{if(!d)return;let e=e=>{if("Escape"===e.key){e.preventDefault(),"root"!==p?h("root"):I(!0);return}("ArrowDown"===e.key||"ArrowUp"===e.key)&&(e.preventDefault(),(e=>{let t=Array.from(m.current?.querySelectorAll("[data-menu-index]")??[]);if(0===t.length)return;let n=(Math.max(t.findIndex(e=>e===document.activeElement),0)+e+t.length)%t.length;t[n]?.focus()})("ArrowDown"===e.key?1:-1))};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[d,p]),(0,t.jsxs)("div",{ref:m,className:"model-select",onBlur:e=>{e.relatedTarget instanceof Node&&(m.current?.contains(e.relatedTarget)||I())},children:[(0,t.jsxs)("button",{ref:g,type:"button",className:"model-select-trigger","aria-label":N,"aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?`${x}-menu`:void 0,title:C,disabled:l,onClick:()=>{d?I():(h("root"),u(!0))},children:[(0,t.jsx)("span",{className:"model-select-trigger-label",children:S}),void 0!==w&&(0,t.jsx)("span",{className:"model-select-trigger-effort",children:w}),(0,t.jsx)("svg",{className:d?"model-select-chevron open":"model-select-chevron",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M3.5 5.25L7 8.75L10.5 5.25"})})]}),d&&(0,t.jsxs)("div",{id:`${x}-menu`,className:"model-select-menu",role:"menu","aria-label":c("composer.modelSelect.menu"),children:["root"===p&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{"data-menu-index":o++,type:"button",role:"menuitem",className:"model-select-cell",onClick:()=>{h("model")},children:[(0,t.jsx)("span",{className:"model-select-cell-label",children:c("composer.modelSelect.model")}),(0,t.jsx)("span",{className:"model-select-cell-value",children:S}),(0,t.jsx)(J,{})]}),null!==b&&(0,t.jsxs)("button",{"data-menu-index":o++,type:"button",role:"menuitem",className:"model-select-cell",onClick:()=>{h("effort")},children:[(0,t.jsx)("span",{className:"model-select-cell-label",children:c("composer.modelSelect.effort")}),(0,t.jsx)("span",{className:"model-select-cell-value",children:w}),(0,t.jsx)(J,{})]})]}),"model"===p&&(0,t.jsxs)("div",{className:"model-select-groups",children:[v.map(([e,n])=>(0,t.jsxs)("section",{role:"group","aria-labelledby":`${x}-${e}`,className:"model-select-group",children:[(0,t.jsx)("div",{className:"model-select-group-title",id:`${x}-${e}`,children:e}),n.map(e=>{let n=r===e.id;return(0,t.jsxs)("button",{"data-menu-index":o++,type:"button",role:"menuitemradio","aria-checked":n,className:n?"model-select-option selected":"model-select-option",title:e.displayName||e.modelName,onClick:()=>{r===e.id||i(e.id),I(!0)},children:[(0,t.jsx)("span",{className:"model-select-option-copy",children:(0,t.jsx)("span",{className:"model-select-option-name",children:e.displayName||e.modelName})}),(0,t.jsx)("span",{className:"model-select-check",children:n&&(0,t.jsx)(G,{})})]},e.id)})]},e)),0===e.length&&(0,t.jsx)("div",{className:"model-select-empty",children:c("composer.modelSelect.emptyModels")})]}),"effort"===p&&(0,t.jsxs)(t.Fragment,{children:[j.map(e=>{let n=k===e;return(0,t.jsxs)("button",{"data-menu-index":o++,type:"button",role:"menuitemradio","aria-checked":n,className:n?"model-select-option selected":"model-select-option",onClick:()=>{k===e||a(e),I(!0)},children:[(0,t.jsxs)("span",{className:"model-select-option-copy",children:[(0,t.jsx)("span",{className:"model-select-option-name",children:K(e)}),(0,t.jsx)("span",{className:"model-select-option-desc",children:c(`composer.thinking.${e}`)})]}),(0,t.jsx)("span",{className:"model-select-check",children:n&&(0,t.jsx)(G,{})})]},e)}),0===j.length&&(0,t.jsx)("div",{className:"model-select-empty",children:c("composer.modelSelect.emptyEfforts")})]})]})]})}function Q(e){let t=e=>e>=100?String(Math.round(e)):String(Math.round(10*e)/10);return e<1e3?String(e):e<1e6?`${t(e/1e3)}K`:`${t(e/1e6)}M`}function Y(e){let t=e/1e3;if(t<60)return`${Math.round(10*t)/10}s`;let n=Math.round(t);return`${Math.floor(n/60)}m${n%60}s`}function X(e){let t=Math.max(0,e);return t>=10?String(Math.round(t)):String(Math.round(10*t)/10)}let ee=2*Math.PI*5.5,et=[{key:"systemTokens",label:"context.system",color:"cm-color-system"},{key:"toolsTokens",label:"context.tools",color:"cm-color-tools"},{key:"messageTokens",label:"context.messages",color:"cm-color-messages"}];function en({contextUsage:e}){let r=(0,f.useT)(),[i,s]=(0,n.useState)(!1),a=(0,n.useRef)(null),l=null!==e;if((0,n.useEffect)(()=>{!l&&i&&s(!1)},[l,i]),(0,n.useEffect)(()=>{if(!i||!l)return;let e=e=>{e.target instanceof Node&&a.current?.contains(e.target)===!0||s(!1)},t=e=>{"Escape"===e.key&&s(!1)};return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)}},[l,i]),null===e||e.contextWindow<=0)return null;let o=Math.min(100,Math.round(e.projectedTokens/e.contextWindow*100)),c=`${o}%`,d=r("context.aria"),[u="",p=""]=d.replace("{percent}","\0").split("\0").map(e=>e.trim()),h=e.systemTokens+e.toolsTokens+e.messageTokens,m=(0===h?[{key:"total",color:void 0,width:o}]:et.map(t=>({key:t.key,color:t.color,width:o*e[t.key]/h}))).filter(e=>e.width>0);return(0,t.jsxs)("span",{ref:a,className:"context-meter",children:[(0,t.jsx)("button",{type:"button",className:"context-meter-trigger","aria-label":d.replace("{percent}",c),"aria-haspopup":"dialog","aria-expanded":i,title:d.replace("{percent}",c),onClick:()=>s(e=>!e),children:(0,t.jsxs)("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[(0,t.jsx)("circle",{className:"context-meter-track",cx:"7",cy:"7",r:5.5}),(0,t.jsx)("circle",{className:"context-meter-fill",cx:"7",cy:"7",r:5.5,strokeDasharray:`${ee*o/100} ${ee}`,transform:"rotate(-90 7 7)"})]})}),i&&(0,t.jsxs)("div",{className:"context-meter-panel",role:"dialog","aria-label":r("context.used"),children:[(0,t.jsxs)("div",{className:"context-meter-header",children:[(0,t.jsx)("span",{className:"context-meter-headline",children:u}),(0,t.jsx)("span",{className:"context-meter-percent",children:c}),(0,t.jsx)("span",{className:"context-meter-headline",children:p}),(0,t.jsx)("span",{className:"context-meter-figures",children:`~${Q(e.projectedTokens)} / ${Q(e.contextWindow)}`})]}),(0,t.jsx)("div",{className:"context-meter-bar",children:m.map(e=>(0,t.jsx)("div",{className:`context-meter-segment${void 0===e.color?"":` ${e.color}`}`,style:{width:`${e.width}%`}},e.key))}),(0,t.jsx)("dl",{className:"context-meter-rows",children:et.map(n=>(0,t.jsxs)("div",{className:"context-meter-row",children:[(0,t.jsxs)("dt",{children:[(0,t.jsx)("span",{className:`context-meter-swatch ${n.color}`,"aria-hidden":"true"}),r(n.label)]}),(0,t.jsx)("dd",{children:`~${Q(e[n.key])}`})]},n.key))})]})]})}function er(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??`{${n}}`)}function ei({stats:e}){let r=(0,f.useT)(),i=[];if(null!==e){if(e.steps>0){i.push(er(r("stats.counts"),{turns:String(e.turns),steps:String(e.steps)}));let t=[];e.llmMs>0&&t.push(er(r("stats.llm"),{duration:Y(e.llmMs)})),e.toolMs>0&&t.push(er(r("stats.toolCall"),{duration:Y(e.toolMs)})),t.length>0&&i.push(t.join(" · "));let n=[];e.ttftSteps>0&&n.push(er(r("stats.ttftAverage"),{duration:Y(e.ttftMs/e.ttftSteps)})),e.decodeMs>0&&n.push(er(r("stats.tokensPerSecond"),{throughput:X(e.decodeTokens/(e.decodeMs/1e3))})),n.length>0&&i.push(n.join(" · "))}let t=e.uncachedInputTokens+e.cacheReadTokens+e.cacheWriteTokens;(t>0||e.outputTokens>0)&&(t>0&&i.push(er(r("stats.cacheHit"),{percent:String(Math.round(e.cacheReadTokens/t*100))})),i.push(er(r("stats.tokens"),{input:Q(t),output:Q(e.outputTokens)})))}let s=i.join(" | "),a=(0,n.useRef)(null),[l,o]=(0,n.useState)(!1);return((0,n.useLayoutEffect)(()=>{let e=a.current;if(null===e)return;let t=()=>{o(e.scrollWidth>e.clientWidth)};if(t(),"u"<typeof ResizeObserver)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[s]),0===i.length)?null:(0,t.jsx)("div",{ref:a,className:"stats-line",title:l?s:void 0,children:i.map((e,n)=>(0,t.jsxs)("span",{children:[n>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"stats-line-sep","aria-hidden":"true",children:"|"})," "]}),(0,t.jsx)("span",{children:e})]},e))})}let es=encodeURIComponent;function ea(e,t){return`/api/worker/v1/sessions/${es(e)}/artifacts/${es(t)}`}function el(e,t,n){let r=`${ea(e,t)}/preview`;return n?`${r}?${new URLSearchParams({sheet:n}).toString()}`:r}function eo(e,t){return(e.startsWith(`${t}:`)?e.slice(t.length+1):e.slice(t.length)).split(/\s/)[0].toLowerCase()}function ec({templates:e,roles:r,flows:i,input:s,onSelectTemplate:a,onSelectRole:l,onSelectFlow:o,onClose:c}){let[d,u]=(0,n.useState)(0),p=(0,n.useRef)(null),h=(0,n.useRef)(0);(0,n.useEffect)(()=>{h.current=Date.now()},[]);let m=s.startsWith("/")?"template":s.startsWith("@role")?"role":s.startsWith("@graph")?"flow":s.startsWith("@")?"all":null,f=(()=>{if("template"===m){let t=s.slice(1).split(/\s/)[0].toLowerCase();return e.filter(e=>!t||e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)).map(e=>({key:`t:${e.name}`,label:`/${e.name}`,hint:e.argumentHint,desc:e.description,onPick:()=>a(e.name)}))}if("role"===m){let e=eo(s,"@role");return r.filter(t=>!e||t.handle.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)).map(e=>({key:`r:${e.id}`,label:`@role:${e.handle}`,hint:e.name,desc:e.description,onPick:()=>l(e.id,e.handle)}))}if("flow"===m){let e=eo(s,"@graph");return i.filter(t=>!e||t.name.toLowerCase().includes(e)).map(e=>({key:`f:${e.name}`,label:`@graph:${e.name}${e.version?`@${e.version}`:""}`,hint:e.version?`v${e.version}`:"",desc:e.description,onPick:()=>o(e.name,e.version)}))}if("all"===m){let e=s.slice(1).split(/\s/)[0].toLowerCase(),t=r.filter(t=>!e||t.handle.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)),n=i.filter(t=>!e||t.name.toLowerCase().includes(e));return[...t.map(e=>({key:`r:${e.id}`,label:`@role:${e.handle}`,hint:e.name,desc:e.description,onPick:()=>l(e.id,e.handle)})),...n.map(e=>({key:`f:${e.name}`,label:`@graph:${e.name}${e.version?`@${e.version}`:""}`,hint:e.version?`v${e.version}`:"",desc:e.description,onPick:()=>o(e.name,e.version)}))]}return[]})(),g=d>=f.length&&f.length>0?0:d;(0,n.useEffect)(()=>{let e=e=>{!(Date.now()-h.current<100)&&(e.target.closest(".prompt-command-menu")||c())};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[c]),(0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&(c(),e.preventDefault())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[c]);let x=(0,n.useCallback)(e=>{switch(e.key){case"ArrowDown":e.preventDefault(),u(e=>Math.min(e+1,f.length-1));break;case"ArrowUp":e.preventDefault(),u(e=>Math.max(e-1,0));break;case"Enter":case"Tab":e.preventDefault(),f[g]&&f[g].onPick()}},[f,g]);return((0,n.useEffect)(()=>{p.current?.children[g]?.scrollIntoView({block:"nearest"})},[g]),0!==f.length&&m)?(0,t.jsx)("div",{className:"prompt-command-menu",role:"listbox","aria-label":"template"===m?"Prompt templates":"role"===m?"Role targets":"Graphs",children:(0,t.jsx)("ul",{ref:p,onKeyDown:x,children:f.map((e,n)=>(0,t.jsxs)("li",{role:"option","aria-selected":n===g,className:n===g?"active":"",onMouseEnter:()=>u(n),onMouseDown:t=>{t.preventDefault(),e.onPick()},children:[(0,t.jsx)("span",{className:"pcm-name",children:e.label}),e.hint&&(0,t.jsx)("span",{className:"pcm-hint",children:e.hint}),e.desc&&(0,t.jsx)("span",{className:"pcm-desc",children:e.desc})]},e.key))})}):null}let ed={pdf:{emoji:"📄",color:"#ef4444"},docx:{emoji:"📝",color:"#3b82f6"},doc:{emoji:"📝",color:"#3b82f6"},xlsx:{emoji:"📊",color:"#22c55e"},xls:{emoji:"📊",color:"#22c55e"},pptx:{emoji:"📽",color:"#f97316"},ppt:{emoji:"📽",color:"#f97316"}};function eu({selectedSession:e,activeLeafMessageId:r,input:i,setInput:s,activeRun:a,compacting:l,hasPendingImage:o,reconnecting:d,permissionMode:u,permissionReady:p,setPermissionMode:h,models:m,selectedModelId:g,setSelectedModelId:y,thinkingEffort:v,setThinkingEffort:b,roles:j,selectedRoleId:k,setSelectedRoleId:w,textAttachments:S,removeTextAttachment:C,pendingImage:N,clearPendingImage:I,attachFiles:T,uploadImage:M,submit:R,steer:E,followUp:z,cancel:A,compactSession:P,pendingFollowUps:$,promptTemplates:L,showPromptPanel:F,onPromptSelect:U,onPromptPanelClose:q,expanding:B,expandDiag:V,panelRoles:K,panelFlows:J,onRoleSelect:G,onFlowSelect:Q,contextUsage:Y,stats:X,onRequestProject:ee}){let et=(0,n.useRef)(null),er=(0,n.useRef)(null),es=(0,n.useRef)(null),ea=(0,n.useRef)(null),[eo,ep]=(0,n.useState)(!1),eh=(0,n.useRef)(0),[em,ef]=(0,n.useState)(!1),eg=(0,n.useRef)(null),ex=(0,f.useT)();(0,n.useEffect)(()=>{if(!em)return;let e=e=>{eg.current?.contains(e.target)||ef(!1)},t=e=>{"Escape"===e.key&&ef(!1)};return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)}},[em]);let ey=!!k||"discuss"!==u;(0,n.useEffect)(()=>{let e=et.current;e&&(e.style.height="0px",e.style.height=`${Math.min(e.scrollHeight,176)}px`)},[i]);let ev=!!e&&!a&&!l,eb=(0,n.useCallback)(e=>{ev&&e.dataTransfer.types.includes("Files")&&(e.preventDefault(),eh.current+=1,1===eh.current&&ep(!0))},[ev]),ej=(0,n.useCallback)(e=>{eo&&(e.preventDefault(),eh.current-=1,eh.current<=0&&(eh.current=0,ep(!1)))},[eo]),ek=(0,n.useCallback)(e=>{ev&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[ev]),ew=(0,n.useCallback)(e=>{if(!ev)return;e.preventDefault(),eh.current=0,ep(!1);let t=Array.from(e.dataTransfer.files);t.length&&T(t)},[T,ev]);return(0,t.jsxs)("div",{className:"composer-shell",onDragEnter:eb,onDragLeave:ej,onDragOver:ek,onDrop:ew,children:[eo&&(0,t.jsxs)("div",{className:"composer-drop-zone",children:[(0,t.jsx)(W,{size:18}),ex("composer.dropFiles")]}),(N||S.length>0)&&(0,t.jsxs)("div",{className:"composer-attachments","aria-label":ex("composer.attachedFiles"),children:[N&&e&&(0,t.jsxs)("div",{className:"composer-image-preview",children:[(0,t.jsx)("img",{src:el(e,N.id),alt:N.name}),(0,t.jsx)("button",{type:"button",onClick:I,"aria-label":ex("composer.removeImage"),children:(0,t.jsxs)("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round","aria-hidden":"true",children:[(0,t.jsx)("line",{x1:"1",y1:"1",x2:"7",y2:"7"}),(0,t.jsx)("line",{x1:"7",y1:"1",x2:"1",y2:"7"})]})})]}),S.map(e=>{var n;let r=ed[e.name.toLowerCase().split(".").pop()??""]??{emoji:"📎",color:"var(--text-muted)"},i=e.name.toLowerCase().split(".").pop()??"";return(0,t.jsxs)("span",{className:"composer-attachment",title:e.name,children:[(0,t.jsx)("span",{className:"composer-attachment-icon",style:{color:r.color},children:r.emoji}),(0,t.jsxs)("span",{className:"composer-attachment-body",children:[(0,t.jsx)("span",{className:"composer-attachment-name",children:e.name}),(0,t.jsxs)("span",{className:"composer-attachment-meta",children:[i.toUpperCase()," · ",(n=e.size)<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(1)} KB`:`${(n/1048576).toFixed(1)} MB`," · text"]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>C(e.id),"aria-label":`${ex("composer.remove")} ${e.name}`,children:(0,t.jsxs)("svg",{width:"7",height:"7",viewBox:"0 0 7 7",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round","aria-hidden":"true",children:[(0,t.jsx)("line",{x1:"1",y1:"1",x2:"6",y2:"6"}),(0,t.jsx)("line",{x1:"6",y1:"1",x2:"1",y2:"6"})]})})]},e.id)})]}),(0,t.jsx)("form",{className:"composer",onSubmit:function(e){e.preventDefault(),a?l||d||E():R()},ref:er,children:(0,t.jsxs)("div",{className:`composer-editor${!e?" composer-no-session":""}`,ref:eg,onClick:()=>{e||ee?.()},children:[em&&(0,t.jsxs)("div",{className:"composer-config-panel",role:"dialog","aria-label":ex("composer.runConfiguration"),children:[(0,t.jsxs)("div",{className:"composer-config-row",children:[(0,t.jsx)("span",{className:"composer-config-label",children:ex("composer.target")}),(0,t.jsx)(H,{roles:j,selectedRoleId:k,onSelect:w,disabled:!e||a||l})]}),(0,t.jsxs)("div",{className:"composer-config-row",children:[(0,t.jsx)("span",{className:"composer-config-label",children:ex("composer.permission")}),(0,t.jsx)("div",{className:"permission-segment",role:"group","aria-label":"Permission mode",children:["discuss","ask","auto"].map(n=>(0,t.jsx)("button",{type:"button","aria-pressed":u===n,disabled:!e||a||!p||!!k,onClick:()=>h(n),children:"discuss"===n?"Discuss":"ask"===n?"Ask":"Auto"},n))})]}),(0,t.jsxs)("div",{className:"composer-config-row",children:[(0,t.jsx)("span",{className:"composer-config-label",children:ex("composer.attach")}),(0,t.jsxs)("div",{className:"composer-config-tools",children:[(0,t.jsx)("button",{type:"button",className:"icon-command",disabled:!ev,onClick:()=>es.current?.click(),"aria-label":ex("composer.attachFiles"),title:ex("composer.attachFiles"),children:(0,t.jsx)(W,{size:15,"aria-hidden":"true"})}),(0,t.jsx)("button",{type:"button",className:"icon-command",disabled:!ev,onClick:()=>ea.current?.click(),"aria-label":ex("composer.attachImage"),title:ex("composer.attachImage"),children:(0,t.jsx)(D,{size:15,"aria-hidden":"true"})}),(0,t.jsx)("button",{type:"button",className:"icon-command",onClick:P,disabled:!e||!r||a,"aria-label":ex("composer.compactContext"),title:ex("composer.compactContext"),children:(0,t.jsx)(O,{size:15,"aria-hidden":"true"})})]})]})]}),F&&(0,t.jsx)(ec,{templates:L,roles:K,flows:J,input:i,onSelectTemplate:U,onSelectRole:G,onSelectFlow:Q,onClose:q}),(0,t.jsx)("textarea",{ref:et,value:i,onChange:e=>s(e.target.value),onKeyDown:function(t){!e||"Enter"!==t.key||t.shiftKey||t.nativeEvent.isComposing||(t.preventDefault(),er.current?.requestSubmit())},rows:1,readOnly:!e,disabled:l,placeholder:l?ex("composer.placeholderCompacting"):a?ex("composer.placeholderSteer"):e?ex("composer.placeholderDefault"):ex("composer.placeholderNoSession"),"aria-label":a?ex("composer.steerAria"):ex("composer.messageAria")}),(0,t.jsx)("input",{ref:ea,className:"sr-only",type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",disabled:!ev,onChange:e=>{let t=e.target.files?.[0];t&&M(t),e.currentTarget.value=""}}),(0,t.jsx)("input",{ref:es,className:"sr-only",type:"file",multiple:!0,accept:"image/png,image/jpeg,image/gif,image/webp,text/*,.md,.mdx,.json,.yaml,.yml,.toml,.csv,.tsv,.js,.jsx,.ts,.tsx,.py,.r,.go,.rs,.java,.c,.cpp,.h,.hpp,.css,.html,.xml,.sh,.sql",disabled:!ev,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);t.length&&T(t),e.currentTarget.value=""}}),(0,t.jsxs)("div",{className:"composer-toolbar-row",children:[(0,t.jsxs)("div",{className:"composer-tools",children:[(0,t.jsxs)("button",{type:"button",className:"composer-plus","aria-expanded":em,"aria-label":ex("composer.configureRun"),title:ex("composer.configureRun"),disabled:!e||l,onClick:()=>ef(e=>!e),children:[(0,t.jsx)(x,{size:15,"aria-hidden":"true"}),ey&&(0,t.jsx)("span",{className:"composer-plus-dot","aria-hidden":"true"})]}),e&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"composer-tag",title:ex("composer.permissionMode"),"aria-label":`${ex("composer.permissionMode")}: ${"discuss"===u?"Discuss":"ask"===u?"Ask":"Auto"}`,children:"discuss"===u?"Discuss":"ask"===u?"Ask":"Auto"}),k&&(0,t.jsxs)("span",{className:"composer-tag composer-tag-role",title:ex("composer.roleTarget"),children:[(0,t.jsx)(c,{size:11,"aria-hidden":"true"}),(0,t.jsx)("span",{children:j.find(e=>e.id===k)?.name??"Role"})]})]})]}),(0,t.jsxs)("div",{className:"composer-trailing",children:[(0,t.jsx)(Z,{models:m,selectedModelId:g,setSelectedModelId:y,thinkingEffort:v,setThinkingEffort:b,disabled:!e||a||0===m.length||!!k}),(0,t.jsx)(en,{contextUsage:Y}),a&&(0,t.jsxs)("button",{type:"button",className:"composer-followup","aria-label":ex("composer.queueFollowUp"),disabled:!i.trim()||l||d,onClick:z,children:[(0,t.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,t.jsx)("line",{x1:"5",y1:"1",x2:"5",y2:"6"}),(0,t.jsx)("polyline",{points:"2.5 3.5 5 1 7.5 3.5"}),(0,t.jsx)("line",{x1:"2",y1:"9",x2:"8",y2:"9"})]}),(0,t.jsx)("span",{children:ex("composer.followUp")})]}),a?(0,t.jsx)("button",{type:"button",className:"composer-primary","aria-label":ex("composer.stopRun"),title:ex("composer.stopRun"),onClick:A,children:(0,t.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:(0,t.jsx)("rect",{x:"1.5",y:"1.5",width:"7",height:"7",rx:"1.5",fill:"currentColor"})})}):(0,t.jsx)("button",{type:"submit",className:"composer-primary","aria-label":ex("composer.send"),disabled:!e||!p&&!k||!i.trim()&&!o&&0===S.length,children:(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M8.3125 0.980183C8.66767 1.0531 8.97902 1.20418 9.2627 1.43233C9.48724 1.61297 9.73029 1.85793 9.97949 2.10714L14.707 6.83468L13.293 8.24874L9 3.95577V15.0417H7V3.95577L2.70703 8.24874L1.29297 6.83468L6.02051 2.10714C6.26971 1.85793 6.51277 1.61297 6.7373 1.43233C6.97662 1.23986 7.28445 1.04402 7.6875 0.980183C7.8973 0.947006 8.1031 0.95516 8.3125 0.980183Z",fill:"currentColor"})})})]})]})]})}),(0,t.jsx)(ei,{stats:X}),(0,t.jsxs)("div",{className:"composer-status-line",children:[a&&(0,t.jsxs)("span",{className:"composer-config-hint",children:[u," ",ex("composer.frozenForRun")]}),!p&&e&&!k&&(0,t.jsx)("span",{className:"composer-config-hint is-danger",children:ex("composer.policyUnavailable")}),B&&(0,t.jsx)("span",{className:"composer-status","aria-live":"polite",children:ex("composer.expanding")}),V&&(0,t.jsx)("span",{className:"composer-status diag-warning","aria-live":"polite",children:V}),$.length>0&&(0,t.jsxs)("div",{className:"composer-followup-queue","aria-live":"polite",role:"status",children:[(0,t.jsx)(_,{size:13,"aria-hidden":"true"}),(0,t.jsxs)("span",{children:[ex("composer.queued"),": ",$.map(e=>e.text).join(" · ")]})]})]})]})}function ep(e){let{selectedProject:n,hasModel:r,onNewSession:i,onOpenSettings:s}=e,a=(0,f.useT)();return(0,t.jsxs)("div",{className:"empty-hero","data-testid":"empty-hero",children:[(0,t.jsx)("div",{className:"empty-hero-glow","aria-hidden":"true"}),n?(0,t.jsxs)("div",{className:"empty-hero-stack",children:[(0,t.jsx)("div",{className:"empty-hero-mark","aria-hidden":"true",children:"E"}),(0,t.jsx)("h1",{className:"empty-hero-title",children:a("empty.session.title")}),(0,t.jsx)("p",{className:"empty-hero-body",children:a("empty.session.body")}),(0,t.jsx)("div",{className:"empty-hero-actions",children:(0,t.jsxs)("button",{type:"button",className:"empty-hero-primary",onClick:i,children:[(0,t.jsx)(c,{size:15,"aria-hidden":"true"}),a("empty.session.create")]})}),(0,t.jsx)("p",{className:"empty-hero-hint",children:a("empty.session.hint")}),!r&&(0,t.jsx)("button",{type:"button",className:"empty-hero-settings",onClick:()=>s(),children:a("empty.noModel")})]}):(0,t.jsxs)("div",{className:"empty-hero-stack",children:[(0,t.jsx)("div",{className:"empty-hero-mark","aria-hidden":"true",children:"E"}),(0,t.jsx)("h1",{className:"empty-hero-title",children:a("empty.project.title")}),(0,t.jsx)("p",{className:"empty-hero-body",children:a("empty.project.body")}),!r&&(0,t.jsx)("button",{type:"button",className:"empty-hero-settings",onClick:()=>s(),children:a("empty.noModel")})]})]})}function eh(e){let{projects:n,selectedProject:r,pinnedProjectIds:i,togglePinProject:s,onRequestProject:a,onSwitchProject:l,projectSelector:o}=e,{open:c,close:d,rootRef:u}=o,p=(0,f.useT)(),h=r?n.find(e=>e.id===r)?.name??null:null;return(0,t.jsxs)("div",{ref:u,className:"hero-project-chip-wrap",children:[(0,t.jsxs)("button",{type:"button",className:"hero-project-chip",onClick:a,title:h??p("empty.project.choose"),"aria-label":h?`${h} \xb7 ${p("sidebar.selectProject")}`:p("sidebar.selectProjectEllipsis"),"aria-haspopup":"menu","aria-expanded":c,children:[h?(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:"var(--accent)"},children:(0,t.jsx)("path",{d:"M1.5 5A1.5 1.5 0 0 1 3 3.5h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6.5L13.6 11A1.5 1.5 0 0 1 12.1 12.5H3A1.5 1.5 0 0 1 1.5 11V5ZM1.5 8V11A1.5 1.5 0 0 0 3 12.5h10A1.5 1.5 0 0 0 14.5 11V8"})}):(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:"var(--accent)"},children:(0,t.jsx)("path",{d:"M1.5 5A1.5 1.5 0 0 1 3 3.5h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6.5L13.6 11A1.5 1.5 0 0 1 12.1 12.5H3A1.5 1.5 0 0 1 1.5 11V5Z"})}),(0,t.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h??p("empty.project.choose")}),(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:c?"rotate(180deg)":"none",transition:"transform 0.15s"},children:(0,t.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),c&&(0,t.jsx)(A,{projects:n,selectedProject:r,pinnedProjectIds:i,togglePinProject:s,onSelect:e=>{d(),l(e)},className:"hero-project-menu"})]})}let em=o("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),ef=o("timer-reset",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M12 14v-4",key:"1evpnu"}],["path",{d:"M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6",key:"1ts96g"}],["path",{d:"M9 17H4v5",key:"8t5av"}]]),eg=o("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),ex=o("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),ey=o("clock-3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]]);function ev({completion:e}){let n=e.kind??"completed",r=e.deliveryStatus??"pending",i="pending"===r||"resume_queued"===r,s="cancelled"===n?(0,t.jsx)(eg,{size:13,"aria-hidden":"true"}):i?(0,t.jsx)(ey,{size:13,"aria-hidden":"true"}):(0,t.jsx)(ex,{size:13,"aria-hidden":"true"});return(0,t.jsxs)("div",{className:"delivery-row","data-delivery-status":r,role:"listitem",children:[(0,t.jsx)("span",{className:"delivery-icon",children:s}),(0,t.jsxs)("span",{className:"delivery-identity",children:[(0,t.jsxs)("strong",{children:["Background delegation · generation ",e.generation]}),(0,t.jsx)("span",{children:r.replaceAll("_"," ")})]}),(0,t.jsxs)("span",{className:"delivery-summary",children:[(0,t.jsx)(c,{size:11,"aria-hidden":"true"}),function(e){if(!e)return"";let t="string"==typeof e?e:JSON.stringify(e);return t.length>300?t.slice(0,300)+"…":t}(e.result)]})]})}var eb=e.i(9323);function ej({sessionId:e}){let{deliveries:r,refreshing:i}=function(e){let[t,r]=(0,n.useState)({}),[i,s]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{let n;if(!e)return;let i=new AbortController,a=!1,l=async()=>{try{s(!0);let n=await (0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/delegation-handles?limit=20`,{signal:i.signal});if(a||i.signal.aborted)return;let l={...t};if(await Promise.all(n.items.map(async e=>{try{let t=await (0,eb.apiFetch)(`/v1/delegation-handles/${encodeURIComponent(e.id)}`,{signal:i.signal});if(a||i.signal.aborted)return;l[e.id]={handle:t.handle,completion:t.completion}}catch{l[e.id]||(l[e.id]={handle:e})}})),a||i.signal.aborted)return;r(l)}catch{}finally{a||s(!1),n=window.setTimeout(l,4e3)}};return l(),()=>{a=!0,i.abort(),void 0!==n&&window.clearTimeout(n)}},[e]),{deliveries:(0,n.useMemo)(()=>Object.values(t).sort((e,t)=>(e.handle.createdAt??"").localeCompare(t.handle.createdAt??"")),[t]),refreshing:i}}(e);if(!r.length)return null;let s=r.filter(e=>"active"===e.handle.status);return(0,t.jsxs)("div",{className:"background-delegation-strip",role:"status","aria-label":"Background delegation",children:[(0,t.jsxs)("div",{className:"background-delegation-header",children:[(0,t.jsxs)("span",{children:[(0,t.jsx)(ef,{size:13,"aria-hidden":"true"})," Background delegation"]}),(0,t.jsx)("span",{children:s.length?`${s.length} active`:"all settled"}),i&&(0,t.jsx)(em,{size:12,"aria-hidden":"true",className:"delivery-spinner"})]}),(0,t.jsx)("div",{className:"delivery-list",role:"list",children:r.map(e=>e.completion?(0,t.jsx)(ev,{completion:e.completion},e.handle.id):(0,t.jsxs)("div",{className:"delivery-row",role:"listitem",children:[(0,t.jsx)("span",{className:"delivery-icon",children:(0,t.jsx)(ef,{size:13,"aria-hidden":"true"})}),(0,t.jsxs)("span",{className:"delivery-identity",children:[(0,t.jsx)("strong",{children:"Background delegation"}),(0,t.jsxs)("span",{children:[e.handle.executionMode," · ",e.handle.status]})]}),(0,t.jsx)("span",{className:"delivery-summary",children:"running in background…"})]},e.handle.id))})]})}function ek({value:e,onChange:r,busy:i,onConfirm:s,onCancel:a}){let l=(0,n.useRef)(null);return(0,n.useEffect)(()=>{l.current?.focus()},[]),(0,t.jsxs)("div",{className:"compaction-prompt-bar",role:"dialog","aria-label":"Create context checkpoint",children:[(0,t.jsxs)("div",{className:"compaction-prompt-header",children:[(0,t.jsxs)("span",{children:[(0,t.jsx)(O,{size:13,"aria-hidden":"true"})," Create context checkpoint"]}),(0,t.jsx)("button",{type:"button",className:"follow-up-close","aria-label":"Cancel",title:"Cancel",onClick:a,disabled:i,children:(0,t.jsx)(m,{size:13,"aria-hidden":"true"})})]}),(0,t.jsxs)("div",{className:"compaction-prompt-body",children:[(0,t.jsx)("input",{ref:l,value:e,onChange:e=>r(e.target.value),placeholder:"Optional focus for the checkpoint…",disabled:i,onKeyDown:e=>{"Enter"!==e.key||i||(e.preventDefault(),s())}}),(0,t.jsxs)("div",{className:"compaction-prompt-actions",children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",onClick:a,disabled:i,children:"Cancel"}),(0,t.jsx)("button",{type:"button",className:"compaction-prompt-confirm",onClick:s,disabled:i,children:i?"Creating…":"Create checkpoint"})]})]})]})}let ew=o("archive-restore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]),eS=o("corner-down-right",[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]),eC=o("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]),eN=o("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]),eI={read_only:"Read only",local_write:"Local write",shell:"Shell",external:"External",delegation:"Delegation",sensitive:"Sensitive"};function eT({item:e,checked:n,onChange:r}){return e.standingScope?(0,t.jsxs)("label",{className:"standing-remember",children:[(0,t.jsx)("input",{type:"checkbox",checked:n,onChange:()=>r(e.callIndex)}),"Remember for ",e.standingScope.display," in this session"]}):null}function eM({item:e}){return e.delegations?.length?(0,t.jsx)("div",{className:"approval-delegations",children:e.delegations.map((e,n)=>{let r=e.role||e.roleHandle,i=e.goalPreview||e.assignmentPreview;return(0,t.jsxs)("div",{className:"approval-delegation",children:[(0,t.jsx)("span",{className:"approval-delegation-icon",children:(0,t.jsx)(eN,{size:14,"aria-hidden":"true"})}),(0,t.jsxs)("span",{className:"approval-delegation-copy",children:[(0,t.jsx)("strong",{children:e.name}),(0,t.jsxs)("span",{children:["@",r]}),(0,t.jsx)("small",{children:i}),!!e.skills?.length&&(0,t.jsxs)("small",{className:"approval-delegation-meta",children:["skills: ",(e.skills??[]).join(", ")]}),!!e.depends?.length&&(0,t.jsxs)("small",{className:"approval-delegation-meta",children:["after: ",(e.depends??[]).join(", ")]})]}),(0,t.jsxs)("span",{className:"approval-delegation-budget",children:[e.budget.maxModelCalls," model · ",e.budget.maxToolCalls," tool"]})]},`${r}-${n}`)})}):(0,t.jsx)("pre",{children:e.argumentsPreview})}function eR({approval:e,resolving:r,decide:i}){let[s,a]=(0,n.useState)(()=>({approvalID:e.id,indexes:[]})),l=(0,n.useMemo)(()=>s.approvalID===e.id?s.indexes:[],[e.id,s]),o=(0,n.useMemo)(()=>new Set(l),[l]),c=e.items.some(e=>"delegate_tasks"===e.toolName||"delegate_roles"===e.toolName),d=(0,n.useCallback)(t=>{a(n=>{let r=new Set(n.approvalID===e.id?n.indexes:[]);return r.has(t)?r.delete(t):r.add(t),{approvalID:e.id,indexes:Array.from(r).sort((e,t)=>e-t)}})},[e.id]),u=(0,n.useCallback)(()=>{i("approved",l)},[i,l]),p=(0,n.useCallback)(()=>{i("rejected",[])},[i]);return(0,t.jsxs)("section",{className:"approval-panel","aria-label":"Tool approval required",children:[(0,t.jsxs)("div",{className:"approval-heading",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:c?"Delegation approval required":"Approval required"}),e.attribution?.speakerKind==="role"&&(0,t.jsxs)("span",{className:"approval-attribution",children:["@",e.attribution.handle||e.attribution.displayName," · ",e.attribution.authority," · ",e.attribution.permissionCeiling]}),(0,t.jsxs)("span",{children:["Batch ",e.iteration," · ",e.items.length," ",1===e.items.length?"action":"actions"]})]}),(0,t.jsx)("span",{className:"approval-waiting",children:"Waiting"})]}),(0,t.jsx)("div",{className:"approval-items",children:e.items.map(e=>(0,t.jsxs)("div",{className:"approval-item",children:[(0,t.jsxs)("div",{className:"approval-item-title",children:[(0,t.jsx)("code",{children:e.toolName}),(0,t.jsx)("span",{"data-risk":e.riskClass,children:eI[e.riskClass]??"Sensitive"})]}),"delegate_tasks"===e.toolName||"delegate_roles"===e.toolName?(0,t.jsx)(eM,{item:e}):(0,t.jsx)("pre",{children:e.argumentsPreview}),(0,t.jsx)(eT,{item:e,checked:o.has(e.callIndex),onChange:d})]},`${e.callIndex}-${e.toolCallId}`))}),(0,t.jsxs)("div",{className:"approval-actions",children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",disabled:!!r,onClick:p,children:"rejected"===r?"Rejecting…":"Reject batch"}),(0,t.jsx)("button",{type:"button",disabled:!!r,onClick:u,children:"approved"===r?"Approving…":"Approve batch"})]})]})}let eE=o("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),ez=o("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),eA=o("git-fork",[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]);function eP(e){return String(e).padStart(2,"0")}function e$(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function eL(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??`{${n}}`)}function eF({text:e,time:r,runMs:i,ttftMs:s,tokensPerSecond:a,branchMessageId:l,branchDisabled:o,onBranch:c}){let d,u,p,h,m=(0,f.useT)(),[g,x]=(0,n.useState)(!1),y=(0,n.useRef)(null),v=(0,n.useCallback)(()=>{navigator.clipboard?.writeText(e).then(()=>{x(!0),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>x(!1),1e3)}).catch(()=>{})},[e]),b=r?function(e,t=Date.now()){let n=new Date(e);if(Number.isNaN(n.getTime()))return"";let r=new Date(t),i=`${eP(n.getHours())}:${eP(n.getMinutes())}`;if(n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate())return i;let s=`${n.getMonth()+1}/${n.getDate()}`;return n.getFullYear()===r.getFullYear()?`${s} ${i}`:`${n.getFullYear()}/${s} ${i}`}(r):null,j=[];void 0!==i&&j.push(eL(m("message.ranFor"),{duration:(u=Math.floor((d=Math.max(0,Math.floor(i/1e3)))/60),p=d%60,u>0?eL(m("duration.minutes"),{minutes:String(u),seconds:String(p).padStart(2,"0")}):eL(m("duration.seconds"),{seconds:String(p)}))})),void 0!==s&&j.push(eL(m("message.ttft"),{seconds:(h=Math.max(0,s)/1e3)<10?String(Math.round(10*h)/10):String(Math.round(h))})),void 0!==a&&j.push(eL(m("message.tokensPerSecond"),{tps:X(a)}));let k=[b,...j].filter(Boolean).join(" · "),w=!!(l&&c);return k||w||e?(0,t.jsxs)("div",{className:"message-actions",children:[k&&(0,t.jsx)("span",{className:"message-clock",children:k}),(0,t.jsx)("button",{type:"button",className:"message-action","aria-label":m(g?"copied":"copy"),title:m(g?"copied":"copy"),onClick:v,children:g?(0,t.jsx)(U,{size:13,"aria-hidden":"true"}):(0,t.jsx)(ez,{size:13,"aria-hidden":"true"})}),w&&(0,t.jsx)("button",{type:"button",className:"message-action","aria-label":m("message.branch"),title:m("message.branch"),disabled:o,onClick:()=>c(l),children:(0,t.jsx)(eA,{size:13,"aria-hidden":"true"})})]}):null}function eD(){}function e_(){}var eO=e.i(76696);let eW=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,eU=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,eq={};function eB(e,t){return((t||eq).jsx?eU:eW).test(e)}var eH=e.i(24963),eV=e.i(40553);let eK={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"};var eJ=e.i(57871),eG=e.i(59091),eZ=e.i(15511);let eQ=eX("end"),eY=eX("start");function eX(e){return function(t){let n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function e0(e){return e&&"object"==typeof e?"position"in e||"type"in e?e2(e.position):"start"in e||"end"in e?e2(e):"line"in e||"column"in e?e1(e):"":""}function e1(e){return e4(e&&e.line)+":"+e4(e&&e.column)}function e2(e){return e1(e&&e.start)+"-"+e1(e&&e.end)}function e4(e){return e&&"number"==typeof e?e:1}class e5 extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",i={},s=!1;if(t&&(i="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!i.cause&&e&&(s=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){const e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}const a=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=a?a.line:void 0,this.name=e0(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=s&&i.cause&&"string"==typeof i.cause.stack?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}e5.prototype.file="",e5.prototype.name="",e5.prototype.reason="",e5.prototype.message="",e5.prototype.stack="",e5.prototype.column=void 0,e5.prototype.line=void 0,e5.prototype.ancestors=void 0,e5.prototype.cause=void 0,e5.prototype.fatal=void 0,e5.prototype.place=void 0,e5.prototype.ruleId=void 0,e5.prototype.source=void 0;let e6={}.hasOwnProperty,e3=new Map,e9=/[A-Z]/g,e8=new Set(["table","tbody","thead","tfoot","tr"]),e7=new Set(["td","th"]),te="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function tt(e,t,n){var r,i,s,a,l,o,c,d,u;let p,h,m,f,g,x,y,v,b,j,k;return"element"===t.type?(r=e,i=t,s=n,h=p=r.schema,"svg"===i.tagName.toLowerCase()&&"html"===p.space&&(r.schema=eJ.svg),r.ancestors.push(i),m=ts(r,i.tagName,!1),f=function(e,t){let n,r,i={};for(r in t.properties)if("children"!==r&&e6.call(t.properties,r)){let s=function(e,t,n){let r=(0,eV.find)(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?(0,eO.stringify)(n):(0,eG.stringify)(n)),"style"===r.property){let t="object"==typeof n?n:function(e,t){try{return(0,eZ.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let t=new e5("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw t.file=e.filePath||void 0,t.url=te+"#cannot-parse-style-attribute",t}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){let t,n={};for(t in e)e6.call(e,t)&&(n[function(e){let t=e.replace(e9,tl);return"ms-"===t.slice(0,3)&&(t="-"+t),t}(t)]=e[t]);return n}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?eK[r.property]||r.property:r.attribute,n]}}(e,r,t.properties[r]);if(s){let[r,a]=s;e.tableCellAlignToStyle&&"align"===r&&"string"==typeof a&&e7.has(t.tagName)?n=a:i[r]=a}}return n&&((i.style||(i.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=n),i}(r,i),g=ti(r,i),e8.has(i.tagName)&&(g=g.filter(function(e){return"string"!=typeof e||!(0,eH.whitespace)(e)})),tn(r,f,m,i),tr(f,g),r.ancestors.pop(),r.schema=p,r.create(i,m,f,s)):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return eD("ExpressionStatement"===n.type),e.evaluater.evaluateExpression(n.expression)}ta(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?(a=e,l=t,o=n,y=x=a.schema,"svg"===l.name&&"html"===x.space&&(a.schema=eJ.svg),a.ancestors.push(l),v=null===l.name?a.Fragment:ts(a,l.name,!0),b=function(e,t){let n={};for(let r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];eD("ExpressionStatement"===t.type);let i=t.expression;eD("ObjectExpression"===i.type);let s=i.properties[0];eD("SpreadElement"===s.type),Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else ta(e,t.position);else{let i,s=r.name;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];eD("ExpressionStatement"===t.type),i=e.evaluater.evaluateExpression(t.expression)}else ta(e,t.position);else i=null===r.value||r.value;n[s]=i}return n}(a,l),j=ti(a,l),tn(a,b,v,l),tr(b,j),a.ancestors.pop(),a.schema=x,a.create(l,v,b,o)):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ta(e,t.position)}(e,t):"root"===t.type?(c=e,d=t,u=n,tr(k={},ti(c,d)),c.create(d,c.Fragment,k,u)):"text"===t.type?t.value:void 0}function tn(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function tr(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function ti(e,t){let n=[],r=-1,i=e.passKeys?new Map:e3;for(;++r<t.children.length;){let s,a=t.children[r];if(e.passKeys){let e="element"===a.type?a.tagName:"mdxJsxFlowElement"===a.type||"mdxJsxTextElement"===a.type?a.name:void 0;if(e){let t=i.get(e)||0;s=e+"-"+t,i.set(e,t+1)}}let l=tt(e,a,s);void 0!==l&&n.push(l)}return n}function ts(e,t,n){let r;if(n)if(t.includes(".")){let e,n=t.split("."),i=-1;for(;++i<n.length;){let t=eB(n[i])?{type:"Identifier",name:n[i]}:{type:"Literal",value:n[i]};e=e?{type:"MemberExpression",object:e,property:t,computed:!!(i&&"Literal"===t.type),optional:!1}:t}eD(e,"always a result"),r=e}else r=eB(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){let t=r.value;return e6.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);ta(e)}function ta(e,t){let n=new e5("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=te+"#cannot-handle-mdx-estrees-without-createevaluater",n}function tl(e){return"-"+e.toLowerCase()}let to={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"]},tc={};function td(e,t){let n=t||tc;return tu(e,"boolean"!=typeof n.includeImageAlt||n.includeImageAlt,"boolean"!=typeof n.includeHtml||n.includeHtml)}function tu(e,t,n){var r;if((r=e)&&"object"==typeof r){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return tp(e.children,t,n)}return Array.isArray(e)?tp(e,t,n):""}function tp(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=tu(e[i],t,n);return r.join("")}function th(e,t,n,r){let i,s=e.length,a=0;if(t=t<0?-t>s?0:s+t:t>s?s:t,n=n>0?n:0,r.length<1e4)(i=Array.from(r)).unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);a<r.length;)(i=r.slice(a,a+1e4)).unshift(t,0),e.splice(...i),a+=1e4,t+=1e4}function tm(e,t){return e.length>0?(th(e,e.length,0,t),e):t}let tf={}.hasOwnProperty;function tg(e){let t={},n=-1;for(;++n<e.length;)!function(e,t){let n;for(n in t){let r,i=(tf.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];if(s)for(r in s){tf.call(i,r)||(i[r]=[]);let e=s[r];!function(e,t){let n=-1,r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);th(e,0,0,r)}(i[r],Array.isArray(e)?e:e?[e]:[])}}}(t,e[n]);return t}let tx=tM(/[A-Za-z]/),ty=tM(/[\dA-Za-z]/),tv=tM(/[#-'*+\--9=?A-Z^-~]/);function tb(e){return null!==e&&(e<32||127===e)}let tj=tM(/\d/),tk=tM(/[\dA-Fa-f]/),tw=tM(/[!-/:-@[-`{-~]/);function tS(e){return null!==e&&e<-2}function tC(e){return null!==e&&(e<0||32===e)}function tN(e){return -2===e||-1===e||32===e}let tI=tM(/\p{P}|\p{S}/u),tT=tM(/\s/);function tM(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function tR(e,t,n,r){let i=r?r-1:1/0,s=0;return function(r){return tN(r)?(e.enter(n),function r(a){return tN(a)&&s++<i?(e.consume(a),r):(e.exit(n),t(a))}(r)):t(r)}}let tE={tokenize:function(e){let t,n=e.attempt(this.parser.constructs.contentInitial,function(t){return null===t?void e.consume(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),tR(e,n,"linePrefix"))},function(n){return e.enter("paragraph"),function n(r){let i=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=i),t=i,function t(r){if(null===r){e.exit("chunkText"),e.exit("paragraph"),e.consume(r);return}return tS(r)?(e.consume(r),e.exit("chunkText"),n):(e.consume(r),t)}(r)}(n)});return n}},tz={tokenize:function(e){let t,n,r,i=this,s=[],a=0;return l;function l(t){if(a<s.length){let n=s[a];return i.containerState=n[1],e.attempt(n[0].continuation,o,c)(t)}return c(t)}function o(e){if(a++,i.containerState._closeFlow){let n;i.containerState._closeFlow=void 0,t&&x();let r=i.events.length,s=r;for(;s--;)if("exit"===i.events[s][0]&&"chunkFlow"===i.events[s][1].type){n=i.events[s][1].end;break}g(a);let l=r;for(;l<i.events.length;)i.events[l][1].end={...n},l++;return th(i.events,s+1,0,i.events.slice(r)),i.events.length=l,c(e)}return l(e)}function c(n){if(a===s.length){if(!t)return p(n);if(t.currentConstruct&&t.currentConstruct.concrete)return m(n);i.interrupt=!!(t.currentConstruct&&!t._gfmTableDynamicInterruptHack)}return i.containerState={},e.check(tA,d,u)(n)}function d(e){return t&&x(),g(a),p(e)}function u(e){return i.parser.lazy[i.now().line]=a!==s.length,r=i.now().offset,m(e)}function p(t){return i.containerState={},e.attempt(tA,h,m)(t)}function h(e){return a++,s.push([i.currentConstruct,i.containerState]),p(e)}function m(r){if(null===r){t&&x(),g(0),e.consume(r);return}return t=t||i.parser.flow(i.now()),e.enter("chunkFlow",{_tokenizer:t,contentType:"flow",previous:n}),function t(n){if(null===n){f(e.exit("chunkFlow"),!0),g(0),e.consume(n);return}return tS(n)?(e.consume(n),f(e.exit("chunkFlow")),a=0,i.interrupt=void 0,l):(e.consume(n),t)}(r)}function f(e,s){let l=i.sliceStream(e);if(s&&l.push(null),e.previous=n,n&&(n.next=e),n=e,t.defineSkip(e.start),t.write(l),i.parser.lazy[e.start.line]){let e,n,s=t.events.length;for(;s--;)if(t.events[s][1].start.offset<r&&(!t.events[s][1].end||t.events[s][1].end.offset>r))return;let l=i.events.length,o=l;for(;o--;)if("exit"===i.events[o][0]&&"chunkFlow"===i.events[o][1].type){if(e){n=i.events[o][1].end;break}e=!0}for(g(a),s=l;s<i.events.length;)i.events[s][1].end={...n},s++;th(i.events,o+1,0,i.events.slice(l)),i.events.length=s}}function g(t){let n=s.length;for(;n-- >t;){let t=s[n];i.containerState=t[1],t[0].exit.call(i,e)}s.length=t}function x(){t.write([null]),n=void 0,t=void 0,i.containerState._closeFlow=void 0}}},tA={tokenize:function(e,t,n){return tR(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},tP={partial:!0,tokenize:function(e,t,n){return function(t){return tN(t)?tR(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||tS(e)?t(e):n(e)}}};class t${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,t){let n=null==t?1/0:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){this.setCursor(Math.trunc(e));let r=this.right.splice(this.right.length-(t||0),1/0);return n&&tL(this.left,n),r.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),tL(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),tL(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 t=this.left.splice(e,1/0);tL(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);tL(this.left,t.reverse())}}}function tL(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function tF(e){let t,n,r,i,s,a,l,o={},c=-1,d=new t$(e);for(;++c<d.length;){for(;c in o;)c=o[c];if(t=d.get(c),c&&"chunkFlow"===t[1].type&&"listItemPrefix"===d.get(c-1)[1].type&&((r=0)<(a=t[1]._tokenizer.events).length&&"lineEndingBlank"===a[r][1].type&&(r+=2),r<a.length&&"content"===a[r][1].type))for(;++r<a.length&&"content"!==a[r][1].type;)"chunkText"===a[r][1].type&&(a[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===t[0])t[1].contentType&&(Object.assign(o,function(e,t){let n,r,i=e.get(t)[1],s=e.get(t)[2],a=t-1,l=[],o=i._tokenizer;!o&&(o=s.parser[i.contentType](i.start),i._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let c=o.events,d=[],u={},p=-1,h=i,m=0,f=0,g=[0];for(;h;){for(;e.get(++a)[1]!==h;);l.push(a),!h._tokenizer&&(n=s.sliceStream(h),h.next||n.push(null),r&&o.defineSkip(h.start),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(n),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),r=h,h=h.next}for(h=i;++p<c.length;)"exit"===c[p][0]&&"enter"===c[p-1][0]&&c[p][1].type===c[p-1][1].type&&c[p][1].start.line!==c[p][1].end.line&&(f=p+1,g.push(f),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(o.events=[],h?(h._tokenizer=void 0,h.previous=void 0):g.pop(),p=g.length;p--;){let t=c.slice(g[p],g[p+1]),n=l.pop();d.push([n,n+t.length-1]),e.splice(n,2,t)}for(d.reverse(),p=-1;++p<d.length;)u[m+d[p][0]]=m+d[p][1],m+=d[p][1]-d[p][0]-1;return u}(d,c)),c=o[c],l=!0);else if(t[1]._container){for(r=c,n=void 0;r--;)if("lineEnding"===(i=d.get(r))[1].type||"lineEndingBlank"===i[1].type)"enter"===i[0]&&(n&&(d.get(n)[1].type="lineEndingBlank"),i[1].type="lineEnding",n=r);else if("linePrefix"===i[1].type||"listItemIndent"===i[1].type);else break;n&&(t[1].end={...d.get(n)[1].start},(s=d.slice(n,c)).unshift(t),d.splice(n,c-n+1,s))}}return th(e,0,1/0,d.slice(0)),!l}let tD={resolve:function(e){return tF(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?i(t):tS(t)?e.check(t_,s,i)(t):(e.consume(t),r)}function i(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function s(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},t_={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),tR(e,i,"linePrefix")};function i(i){if(null===i||tS(i))return n(i);let s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}},tO={tokenize:function(e){let t=this,n=e.attempt(tP,function(r){return null===r?void e.consume(r):(e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n)},e.attempt(this.parser.constructs.flowInitial,r,tR(e,e.attempt(this.parser.constructs.flow,r,e.attempt(tD,r)),"linePrefix")));return n;function r(r){return null===r?void e.consume(r):(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n)}}},tW={resolveAll:tH()},tU=tB("string"),tq=tB("text");function tB(e){return{resolveAll:tH("text"===e?tV:void 0),tokenize:function(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,s,a);return s;function s(e){return o(e)?i(e):a(e)}function a(e){return null===e?void t.consume(e):(t.enter("data"),t.consume(e),l)}function l(e){return o(e)?(t.exit("data"),i(e)):(t.consume(e),l)}function o(e){if(null===e)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function tH(e){return function(t,n){let r,i=-1;for(;++i<=t.length;)void 0===r?t[i]&&"data"===t[i][1].type&&(r=i,i++):t[i]&&"data"===t[i][1].type||(i!==r+2&&(t[r][1].end=t[i-1][1].end,t.splice(r+2,i-r-2),i=r+2),r=void 0);return e?e(t,n):t}}function tV(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){let r,i=e[n-1][1],s=t.sliceStream(i),a=s.length,l=-1,o=0;for(;a--;){let e=s[a];if("string"==typeof e){for(l=e.length;32===e.charCodeAt(l-1);)o++,l--;if(l)break;l=-1}else if(-2===e)r=!0,o++;else if(-1===e);else{a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){let s={type:n===e.length||r||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?l:i.start._bufferIndex+l,_index:i.start._index+a,line:i.end.line,column:i.end.column-o,offset:i.end.offset-o},end:{...i.end}};i.end={...s.start},i.start.offset===i.end.offset?Object.assign(i,s):(e.splice(n,0,["enter",s,t],["exit",s,t]),n+=2)}n++}return e}function tK(e){return null===e||tC(e)||tT(e)?1:tI(e)?2:void 0}function tJ(e,t,n){let r=[],i=-1;for(;++i<e.length;){let s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}let tG={name:"attention",resolveAll:function(e,t){let n,r,i,s,a,l,o,c,d=-1;for(;++d<e.length;)if("enter"===e[d][0]&&"attentionSequence"===e[d][1].type&&e[d][1]._close){for(n=d;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[d][1]).charCodeAt(0)){if((e[n][1]._close||e[d][1]._open)&&(e[d][1].end.offset-e[d][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[d][1].end.offset-e[d][1].start.offset)%3))continue;l=e[n][1].end.offset-e[n][1].start.offset>1&&e[d][1].end.offset-e[d][1].start.offset>1?2:1;let u={...e[n][1].end},p={...e[d][1].start};tZ(u,-l),tZ(p,l),s={type:l>1?"strongSequence":"emphasisSequence",start:u,end:{...e[n][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[d][1].start},end:p},i={type:l>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[d][1].start}},r={type:l>1?"strong":"emphasis",start:{...s.start},end:{...a.end}},e[n][1].end={...s.start},e[d][1].start={...a.end},o=[],e[n][1].end.offset-e[n][1].start.offset&&(o=tm(o,[["enter",e[n][1],t],["exit",e[n][1],t]])),o=tm(o,[["enter",r,t],["enter",s,t],["exit",s,t],["enter",i,t]]),o=tm(o,tJ(t.parser.constructs.insideSpan.null,e.slice(n+1,d),t)),o=tm(o,[["exit",i,t],["enter",a,t],["exit",a,t],["exit",r,t]]),e[d][1].end.offset-e[d][1].start.offset?(c=2,o=tm(o,[["enter",e[d][1],t],["exit",e[d][1],t]])):c=0,th(e,n-1,d-n+3,o),d=n+o.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,t){let n,r=this.parser.constructs.attentionMarkers.null,i=this.previous,s=tK(i);return function(a){return n=a,e.enter("attentionSequence"),function a(l){if(l===n)return e.consume(l),a;let o=e.exit("attentionSequence"),c=tK(l),d=!c||2===c&&s||r.includes(l),u=!s||2===s&&c||r.includes(i);return o._open=!!(42===n?d:d&&(s||!u)),o._close=!!(42===n?u:u&&(c||!d)),t(l)}(a)}}};function tZ(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}let tQ={continuation:{tokenize:function(e,t,n){let r=this;return function(t){return tN(t)?tR(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):i(t)};function i(r){return e.attempt(tQ,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){let r=this;return function(t){if(62===t){let n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),i}return n(t)};function i(n){return tN(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}},tY={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return tw(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}},tX=document.createElement("i");function t0(e){let t="&"+e+";";tX.innerHTML=t;let n=tX.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&n!==t&&n}let t1={name:"characterReference",tokenize:function(e,t,n){let r,i,s=this,a=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),l};function l(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),o):(e.enter("characterReferenceValue"),r=31,i=ty,c(t))}function o(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,i=tk,c):(e.enter("characterReferenceValue"),r=7,i=tj,c(t))}function c(l){if(59===l&&a){let r=e.exit("characterReferenceValue");return i!==ty||t0(s.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(l),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(l)}return i(l)&&a++<r?(e.consume(l),c):n(l)}}},t2={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return null===t?n(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},t4={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){let r,i=this,s={partial:!0,tokenize:function(e,t,n){let s=0;return function(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a};function a(t){return e.enter("codeFencedFence"),tN(t)?tR(e,o,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):o(t)}function o(t){return t===r?(e.enter("codeFencedFenceSequence"),function t(i){return i===r?(s++,e.consume(i),t):s>=l?(e.exit("codeFencedFenceSequence"),tN(i)?tR(e,c,"whitespace")(i):c(i)):n(i)}(t)):n(t)}function c(r){return null===r||tS(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}},a=0,l=0;return function(t){var s;let c;return s=t,a=(c=i.events[i.events.length-1])&&"linePrefix"===c[1].type?c[2].sliceSerialize(c[1],!0).length:0,r=s,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function t(i){return i===r?(l++,e.consume(i),t):l<3?n(i):(e.exit("codeFencedFenceSequence"),tN(i)?tR(e,o,"whitespace")(i):o(i))}(s)};function o(s){return null===s||tS(s)?(e.exit("codeFencedFence"),i.interrupt?t(s):e.check(t2,d,m)(s)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||tS(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),o(i)):tN(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),tR(e,c,"whitespace")(i)):96===i&&i===r?n(i):(e.consume(i),t)}(s))}function c(t){return null===t||tS(t)?o(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||tS(i)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),o(i)):96===i&&i===r?n(i):(e.consume(i),t)}(t))}function d(t){return e.attempt(s,m,u)(t)}function u(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),p}function p(t){return a>0&&tN(t)?tR(e,h,"linePrefix",a+1)(t):h(t)}function h(t){return null===t||tS(t)?e.check(t2,d,m)(t):(e.enter("codeFlowValue"),function t(n){return null===n||tS(n)?(e.exit("codeFlowValue"),h(n)):(e.consume(n),t)}(t))}function m(n){return e.exit("codeFenced"),t(n)}}},t5={name:"codeIndented",tokenize:function(e,t,n){let r=this;return function(t){return e.enter("codeIndented"),tR(e,i,"linePrefix",5)(t)};function i(t){let i=r.events[r.events.length-1];return i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?function t(n){return null===n?s(n):tS(n)?e.attempt(t6,t,s)(n):(e.enter("codeFlowValue"),function n(r){return null===r||tS(r)?(e.exit("codeFlowValue"),t(r)):(e.consume(r),n)}(n))}(t):n(t)}function s(n){return e.exit("codeIndented"),t(n)}}},t6={partial:!0,tokenize:function(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):tS(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):tR(e,s,"linePrefix",5)(t)}function s(e){let s=r.events[r.events.length-1];return s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(e):tS(e)?i(e):n(e)}}};function t3(e,t,n,r,i,s,a,l,o){let c=o||1/0,d=0;return function(t){return 60===t?(e.enter(r),e.enter(i),e.enter(s),e.consume(t),e.exit(s),u):null===t||32===t||41===t||tb(t)?n(t):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),m(t))};function u(n){return 62===n?(e.enter(s),e.consume(n),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),p(n))}function p(t){return 62===t?(e.exit("chunkString"),e.exit(l),u(t)):null===t||60===t||tS(t)?n(t):(e.consume(t),92===t?h:p)}function h(t){return 60===t||62===t||92===t?(e.consume(t),p):p(t)}function m(i){return!d&&(null===i||41===i||tC(i))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(i)):d<c&&40===i?(e.consume(i),d++,m):41===i?(e.consume(i),d--,m):null===i||32===i||40===i||tb(i)?n(i):(e.consume(i),92===i?f:m)}function f(t){return 40===t||41===t||92===t?(e.consume(t),m):m(t)}}function t9(e,t,n,r,i,s){let a,l=this,o=0;return function(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(s),c};function c(u){return o>999||null===u||91===u||93===u&&!a||94===u&&!o&&"_hiddenFootnoteSupport"in l.parser.constructs?n(u):93===u?(e.exit(s),e.enter(i),e.consume(u),e.exit(i),e.exit(r),t):tS(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(t){return null===t||91===t||93===t||tS(t)||o++>999?(e.exit("chunkString"),c(t)):(e.consume(t),a||(a=!tN(t)),92===t?u:d)}function u(t){return 91===t||92===t||93===t?(e.consume(t),o++,d):d(t)}}function t8(e,t,n,r,i,s){let a;return function(t){return 34===t||39===t||40===t?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),a=40===t?41:t,l):n(t)};function l(n){return n===a?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(s),o(n))}function o(t){return t===a?(e.exit(s),l(a)):null===t?n(t):tS(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),tR(e,o,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===a||null===t||tS(t)?(e.exit("chunkString"),o(t)):(e.consume(t),92===t?d:c)}function d(t){return t===a||92===t?(e.consume(t),c):c(t)}}function t7(e,t){let n;return function r(i){return tS(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):tN(i)?tR(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}function ne(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}let nt={partial:!0,tokenize:function(e,t,n){return function(t){return tC(t)?t7(e,r)(t):n(t)};function r(t){return t8(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function i(t){return tN(t)?tR(e,s,"whitespace")(t):s(t)}function s(e){return null===e||tS(e)?t(e):n(e)}}},nn=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","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"],nr=["pre","script","style","textarea"],ni={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(tP,t,n)}}},ns={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return tS(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):n(t)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},na={name:"labelEnd",resolveAll:function(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){let e="labelImage"===r.type?4:2;r.type="data",t+=e}}return e.length!==n.length&&th(e,0,e.length,n),e},resolveTo:function(e,t){let n,r,i,s,a=e.length,l=0;for(;a--;)if(n=e[a][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[a][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(i){if("enter"===e[a][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=a,"labelLink"!==n.type)){l=2;break}}else"labelEnd"===n.type&&(i=a);let o={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[r][1].start},end:{...e[i][1].end}},d={type:"labelText",start:{...e[r+l+2][1].end},end:{...e[i-2][1].start}};return s=tm(s=[["enter",o,t],["enter",c,t]],e.slice(r+1,r+l+3)),s=tm(s,[["enter",d,t]]),s=tm(s,tJ(t.parser.constructs.insideSpan.null,e.slice(r+l+4,i-3),t)),s=tm(s,[["exit",d,t],e[i-2],e[i-1],["exit",c,t]]),s=tm(s,e.slice(i+1)),s=tm(s,[["exit",o,t]]),th(e,r,e.length,s),e},tokenize:function(e,t,n){let r,i,s=this,a=s.events.length;for(;a--;)if(("labelImage"===s.events[a][1].type||"labelLink"===s.events[a][1].type)&&!s.events[a][1]._balanced){r=s.events[a][1];break}return function(t){return r?r._inactive?d(t):(i=s.parser.defined.includes(ne(s.sliceSerialize({start:r.end,end:s.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),l):n(t)};function l(t){return 40===t?e.attempt(nl,c,i?c:d)(t):91===t?e.attempt(no,c,i?o:d)(t):i?c(t):d(t)}function o(t){return e.attempt(nc,c,d)(t)}function c(e){return t(e)}function d(e){return r._balanced=!0,n(e)}}},nl={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return tC(t)?t7(e,i)(t):i(t)}function i(t){return 41===t?c(t):t3(e,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function s(t){return tC(t)?t7(e,l)(t):c(t)}function a(e){return n(e)}function l(t){return 34===t||39===t||40===t?t8(e,o,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function o(t){return tC(t)?t7(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},no={tokenize:function(e,t,n){let r=this;return function(t){return t9.call(r,e,i,s,"reference","referenceMarker","referenceString")(t)};function i(e){return r.parser.defined.includes(ne(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function s(e){return n(e)}}},nc={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}},nd={name:"labelStartImage",resolveAll:na.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),i};function i(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),s):n(t)}function s(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},nu={name:"labelStartLink",resolveAll:na.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),i};function i(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},np={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),tR(e,t,"linePrefix")}}},nh={name:"thematicBreak",tokenize:function(e,t,n){let r,i=0;return function(s){var a;return e.enter("thematicBreak"),r=a=s,function s(a){return a===r?(e.enter("thematicBreakSequence"),function t(n){return n===r?(e.consume(n),i++,t):(e.exit("thematicBreakSequence"),tN(n)?tR(e,s,"whitespace")(n):s(n))}(a)):i>=3&&(null===a||tS(a))?(e.exit("thematicBreak"),t(a)):n(a)}(a)}}},nm={continuation:{tokenize:function(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(tP,function(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,tR(e,t,"listItemIndent",r.containerState.size+1)(n)},function(n){return r.containerState.furtherBlankLines||!tN(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(ng,t,i)(n))});function i(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,tR(e,e.attempt(nm,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){let r=this,i=r.events[r.events.length-1],s=i&&"linePrefix"===i[1].type?i[2].sliceSerialize(i[1],!0).length:0,a=0;return function(t){let i=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===i?!r.containerState.marker||t===r.containerState.marker:tj(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),"listUnordered"===i)return e.enter("listItemPrefix"),42===t||45===t?e.check(nh,n,l)(t):l(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),function t(i){return tj(i)&&++a<10?(e.consume(i),t):(!r.interrupt||a<2)&&(r.containerState.marker?i===r.containerState.marker:41===i||46===i)?(e.exit("listItemValue"),l(i)):n(i)}(t)}return n(t)};function l(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(tP,r.interrupt?n:o,e.attempt(nf,d,c))}function o(e){return r.containerState.initialBlankLine=!0,s++,d(e)}function c(t){return tN(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),d):n(t)}function d(n){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},nf={partial:!0,tokenize:function(e,t,n){let r=this;return tR(e,function(e){let i=r.events[r.events.length-1];return!tN(e)&&i&&"listItemPrefixWhitespace"===i[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},ng={partial:!0,tokenize:function(e,t,n){let r=this;return tR(e,function(e){let i=r.events[r.events.length-1];return i&&"listItemIndent"===i[1].type&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)},"listItemIndent",r.containerState.size+1)}},nx={name:"setextUnderline",resolveTo:function(e,t){let n,r,i,s=e.length;for(;s--;)if("enter"===e[s][0]){if("content"===e[s][1].type){n=s;break}"paragraph"===e[s][1].type&&(r=s)}else"content"===e[s][1].type&&e.splice(s,1),i||"definition"!==e[s][1].type||(i=s);let a={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",i?(e.splice(r,0,["enter",a,t]),e.splice(i+1,0,["exit",e[n][1],t]),e[n][1].end={...e[i][1].end}):e[n][1]=a,e.push(["exit",a,t]),e},tokenize:function(e,t,n){let r,i=this;return function(t){var a;let l,o=i.events.length;for(;o--;)if("lineEnding"!==i.events[o][1].type&&"linePrefix"!==i.events[o][1].type&&"content"!==i.events[o][1].type){l="paragraph"===i.events[o][1].type;break}return!i.parser.lazy[i.now().line]&&(i.interrupt||l)?(e.enter("setextHeadingLine"),r=t,a=t,e.enter("setextHeadingLineSequence"),function t(n){return n===r?(e.consume(n),t):(e.exit("setextHeadingLineSequence"),tN(n)?tR(e,s,"lineSuffix")(n):s(n))}(a)):n(t)};function s(r){return null===r||tS(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};e.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(e,t,n){let r,i=this;return function(t){var r;return e.enter("definition"),r=t,t9.call(i,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(r)};function s(t){return(r=ne(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),58===t)?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),a):n(t)}function a(t){return tC(t)?t7(e,l)(t):l(t)}function l(t){return t3(e,o,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function o(t){return e.attempt(nt,c,c)(t)}function c(t){return tN(t)?tR(e,d,"whitespace")(t):d(t)}function d(s){return null===s||tS(s)?(e.exit("definition"),i.parser.defined.push(r),t(s)):n(s)}}}},"disable",0,{null:[]},"document",0,{42:nm,43:nm,45:nm,48:nm,49:nm,50:nm,51:nm,52:nm,53:nm,54:nm,55:nm,56:nm,57:nm,62:tQ},"flow",0,{35:{name:"headingAtx",resolve:function(e,t){let n,r,i=e.length-2,s=3;return"whitespace"===e[3][1].type&&(s+=2),i-2>s&&"whitespace"===e[i][1].type&&(i-=2),"atxHeadingSequence"===e[i][1].type&&(s===i-1||i-4>s&&"whitespace"===e[i-2][1].type)&&(i-=s+1===i?2:4),i>s&&(n={type:"atxHeadingText",start:e[s][1].start,end:e[i][1].end},r={type:"chunkText",start:e[s][1].start,end:e[i][1].end,contentType:"text"},th(e,s,i-s+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]])),e},tokenize:function(e,t,n){let r=0;return function(i){var s;return e.enter("atxHeading"),s=i,e.enter("atxHeadingSequence"),function i(s){return 35===s&&r++<6?(e.consume(s),i):null===s||tC(s)?(e.exit("atxHeadingSequence"),function n(r){return 35===r?(e.enter("atxHeadingSequence"),function t(r){return 35===r?(e.consume(r),t):(e.exit("atxHeadingSequence"),n(r))}(r)):null===r||tS(r)?(e.exit("atxHeading"),t(r)):tN(r)?tR(e,n,"whitespace")(r):(e.enter("atxHeadingText"),function t(r){return null===r||35===r||tC(r)?(e.exit("atxHeadingText"),n(r)):(e.consume(r),t)}(r))}(s)):n(s)}(s)}}},42:nh,45:[nx,nh],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e},tokenize:function(e,t,n){let r,i,s,a,l,o=this;return function(t){var n;return n=t,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(n),c};function c(a){return 33===a?(e.consume(a),d):47===a?(e.consume(a),i=!0,h):63===a?(e.consume(a),r=3,o.interrupt?t:z):tx(a)?(e.consume(a),s=String.fromCharCode(a),m):n(a)}function d(i){return 45===i?(e.consume(i),r=2,u):91===i?(e.consume(i),r=5,a=0,p):tx(i)?(e.consume(i),r=4,o.interrupt?t:z):n(i)}function u(r){return 45===r?(e.consume(r),o.interrupt?t:z):n(r)}function p(r){let i="CDATA[";return r===i.charCodeAt(a++)?(e.consume(r),a===i.length)?o.interrupt?t:S:p:n(r)}function h(t){return tx(t)?(e.consume(t),s=String.fromCharCode(t),m):n(t)}function m(a){if(null===a||47===a||62===a||tC(a)){let l=47===a,c=s.toLowerCase();return!l&&!i&&nr.includes(c)?(r=1,o.interrupt?t(a):S(a)):nn.includes(s.toLowerCase())?(r=6,l)?(e.consume(a),f):o.interrupt?t(a):S(a):(r=7,o.interrupt&&!o.parser.lazy[o.now().line]?n(a):i?function t(n){return tN(n)?(e.consume(n),t):k(n)}(a):g(a))}return 45===a||ty(a)?(e.consume(a),s+=String.fromCharCode(a),m):n(a)}function f(r){return 62===r?(e.consume(r),o.interrupt?t:S):n(r)}function g(t){return 47===t?(e.consume(t),k):58===t||95===t||tx(t)?(e.consume(t),x):tN(t)?(e.consume(t),g):k(t)}function x(t){return 45===t||46===t||58===t||95===t||ty(t)?(e.consume(t),x):y(t)}function y(t){return 61===t?(e.consume(t),v):tN(t)?(e.consume(t),y):g(t)}function v(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,b):tN(t)?(e.consume(t),v):function t(n){return null===n||34===n||39===n||47===n||60===n||61===n||62===n||96===n||tC(n)?y(n):(e.consume(n),t)}(t)}function b(t){return t===l?(e.consume(t),l=null,j):null===t||tS(t)?n(t):(e.consume(t),b)}function j(e){return 47===e||62===e||tN(e)?g(e):n(e)}function k(t){return 62===t?(e.consume(t),w):n(t)}function w(t){return null===t||tS(t)?S(t):tN(t)?(e.consume(t),w):n(t)}function S(t){return 45===t&&2===r?(e.consume(t),T):60===t&&1===r?(e.consume(t),M):62===t&&4===r?(e.consume(t),A):63===t&&3===r?(e.consume(t),z):93===t&&5===r?(e.consume(t),E):tS(t)&&(6===r||7===r)?(e.exit("htmlFlowData"),e.check(ni,P,C)(t)):null===t||tS(t)?(e.exit("htmlFlowData"),C(t)):(e.consume(t),S)}function C(t){return e.check(ns,N,P)(t)}function N(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),I}function I(t){return null===t||tS(t)?C(t):(e.enter("htmlFlowData"),S(t))}function T(t){return 45===t?(e.consume(t),z):S(t)}function M(t){return 47===t?(e.consume(t),s="",R):S(t)}function R(t){if(62===t){let n=s.toLowerCase();return nr.includes(n)?(e.consume(t),A):S(t)}return tx(t)&&s.length<8?(e.consume(t),s+=String.fromCharCode(t),R):S(t)}function E(t){return 93===t?(e.consume(t),z):S(t)}function z(t){return 62===t?(e.consume(t),A):45===t&&2===r?(e.consume(t),z):S(t)}function A(t){return null===t||tS(t)?(e.exit("htmlFlowData"),P(t)):(e.consume(t),A)}function P(n){return e.exit("htmlFlow"),t(n)}}},61:nx,95:nh,96:t4,126:t4},"flowInitial",0,{[-2]:t5,[-1]:t5,32:t5},"insideSpan",0,{null:[tG,tW]},"string",0,{38:t1,92:tY},"text",0,{[-5]:np,[-4]:np,[-3]:np,33:nd,38:t1,42:tG,60:[{name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i};function i(t){return tx(t)?(e.consume(t),s):64===t?n(t):l(t)}function s(t){return 43===t||45===t||46===t||ty(t)?(r=1,function t(n){return 58===n?(e.consume(n),r=0,a):(43===n||45===n||46===n||ty(n))&&r++<32?(e.consume(n),t):(r=0,l(n))}(t)):l(t)}function a(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||tb(r)?n(r):(e.consume(r),a)}function l(t){return 64===t?(e.consume(t),o):tv(t)?(e.consume(t),l):n(t)}function o(i){return ty(i)?function i(s){return 46===s?(e.consume(s),r=0,o):62===s?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(s),e.exit("autolinkMarker"),e.exit("autolink"),t):function t(s){if((45===s||ty(s))&&r++<63){let n=45===s?t:i;return e.consume(s),n}return n(s)}(s)}(i):n(i)}}},{name:"htmlText",tokenize:function(e,t,n){let r,i,s,a=this;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),l};function l(t){return 33===t?(e.consume(t),o):47===t?(e.consume(t),b):63===t?(e.consume(t),y):tx(t)?(e.consume(t),k):n(t)}function o(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),i=0,h):tx(t)?(e.consume(t),x):n(t)}function c(t){return 45===t?(e.consume(t),p):n(t)}function d(t){return null===t?n(t):45===t?(e.consume(t),u):tS(t)?(s=d,R(t)):(e.consume(t),d)}function u(t){return 45===t?(e.consume(t),p):d(t)}function p(e){return 62===e?M(e):45===e?u(e):d(e)}function h(t){let r="CDATA[";return t===r.charCodeAt(i++)?(e.consume(t),i===r.length?m:h):n(t)}function m(t){return null===t?n(t):93===t?(e.consume(t),f):tS(t)?(s=m,R(t)):(e.consume(t),m)}function f(t){return 93===t?(e.consume(t),g):m(t)}function g(t){return 62===t?M(t):93===t?(e.consume(t),g):m(t)}function x(t){return null===t||62===t?M(t):tS(t)?(s=x,R(t)):(e.consume(t),x)}function y(t){return null===t?n(t):63===t?(e.consume(t),v):tS(t)?(s=y,R(t)):(e.consume(t),y)}function v(e){return 62===e?M(e):y(e)}function b(t){return tx(t)?(e.consume(t),j):n(t)}function j(t){return 45===t||ty(t)?(e.consume(t),j):function t(n){return tS(n)?(s=t,R(n)):tN(n)?(e.consume(n),t):M(n)}(t)}function k(t){return 45===t||ty(t)?(e.consume(t),k):47===t||62===t||tC(t)?w(t):n(t)}function w(t){return 47===t?(e.consume(t),M):58===t||95===t||tx(t)?(e.consume(t),S):tS(t)?(s=w,R(t)):tN(t)?(e.consume(t),w):M(t)}function S(t){return 45===t||46===t||58===t||95===t||ty(t)?(e.consume(t),S):function t(n){return 61===n?(e.consume(n),C):tS(n)?(s=t,R(n)):tN(n)?(e.consume(n),t):w(n)}(t)}function C(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,N):tS(t)?(s=C,R(t)):tN(t)?(e.consume(t),C):(e.consume(t),I)}function N(t){return t===r?(e.consume(t),r=void 0,T):null===t?n(t):tS(t)?(s=N,R(t)):(e.consume(t),N)}function I(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||tC(t)?w(t):(e.consume(t),I)}function T(e){return 47===e||62===e||tC(e)?w(e):n(e)}function M(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function R(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),E}function E(t){return tN(t)?tR(e,z,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):z(t)}function z(t){return e.enter("htmlTextData"),s(t)}}}],91:nu,92:[{name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return tS(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}},tY],93:na,95:tG,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,i=3;if(("lineEnding"===e[3][1].type||"space"===e[i][1].type)&&("lineEnding"===e[r][1].type||"space"===e[r][1].type)){for(t=i;++t<r;)if("codeTextData"===e[t][1].type){e[i][1].type="codeTextPadding",e[r][1].type="codeTextPadding",i+=2,r-=2;break}}for(t=i-1,r++;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):(t===r||"lineEnding"===e[t][1].type)&&(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,i,s=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),function t(n){return 96===n?(e.consume(n),s++,t):(e.exit("codeTextSequence"),a(n))}(t)};function a(o){return null===o?n(o):32===o?(e.enter("space"),e.consume(o),e.exit("space"),a):96===o?(i=e.enter("codeTextSequence"),r=0,function n(a){return 96===a?(e.consume(a),r++,n):r===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(a)):(i.type="codeTextData",l(a))}(o)):tS(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):(e.enter("codeTextData"),l(o))}function l(t){return null===t||32===t||96===t||tS(t)?(e.exit("codeTextData"),a(t)):(e.consume(t),l)}}}}],4127);var ny=e.i(4127);let nv=/[\0\t\n\r]/g;function nb(e,t){let n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(65535&n)==65535||(65535&n)==65534||n>1114111?"�":String.fromCodePoint(n)}let nj=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function nk(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){let e=n.charCodeAt(1),t=120===e||88===e;return nb(n.slice(t?2:1),t?16:10)}return t0(n)||e}let nw={}.hasOwnProperty;function nS(e){return{line:e.line,column:e.column,offset:e.offset}}function nC(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+e0({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+e0({start:t.start,end:t.end})+") is open");throw Error("Cannot close document, a token (`"+t.type+"`, "+e0({start:t.start,end:t.end})+") is still open")}function nN(e){let t=this;t.parser=function(n){var r,i;let s,a,l,o;return"object"==typeof(r={...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})&&(i=r,r=void 0),(function(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:r(x),autolinkProtocol:c,autolinkEmail:c,atxHeading:r(m),blockQuote:r(function(){return{type:"blockquote",children:[]}}),characterEscape:c,characterReference:c,codeFenced:r(h),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:r(h,i),codeText:r(function(){return{type:"inlineCode",value:""}},i),codeTextData:c,data:c,codeFlowValue:c,definition:r(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:r(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:r(f),hardBreakTrailing:r(f),htmlFlow:r(g,i),htmlFlowData:c,htmlText:r(g,i),htmlTextData:c,image:r(function(){return{type:"image",title:null,url:"",alt:null}}),label:i,link:r(x),listItem:r(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:r(y,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:r(y),paragraph:r(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:r(m),strong:r(function(){return{type:"strong",children:[]}}),thematicBreak:r(function(){return{type:"thematicBreak"}})},exit:{atxHeading:a(),atxHeadingSequence:function(e){let t=this.stack[this.stack.length-1];t.depth||(t.depth=this.sliceSerialize(e).length)},autolink:a(),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:a(),characterEscapeValue:d,characterReferenceMarkerHexadecimal:p,characterReferenceMarkerNumeric:p,characterReferenceValue:function(e){let t,n=this.sliceSerialize(e),r=this.data.characterReferenceType;r?(t=nb(n,"characterReferenceMarkerNumeric"===r?10:16),this.data.characterReferenceType=void 0):t=t0(n);let i=this.stack[this.stack.length-1];i.value+=t},characterReference:function(e){this.stack.pop().position.end=nS(e.end)},codeFenced:a(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:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:d,data:d,definition:a(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=ne(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:a(),hardBreakEscape:a(u),hardBreakTrailing:a(u),htmlFlow:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:d,htmlText:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:d,image:a(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,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],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===n.type?n.children=e.children:n.alt=t},labelText:function(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=t.replace(nj,nk),n.identifier=ne(t).toLowerCase()},lineEnding:function(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){n.children[n.children.length-1].position.end=nS(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(c.call(this,e),d.call(this,e))},link:a(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=ne(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:a(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:a(),thematicBreak:a()}};!function e(t,n){let r=-1;for(;++r<n.length;){let i=n[r];Array.isArray(i)?e(t,i):function(e,t){let n;for(n in t)if(nw.call(t,n))switch(n){case"canContainEols":{let r=t[n];r&&e[n].push(...r);break}case"transforms":{let r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=t[n];r&&Object.assign(e[n],r)}}}(t,i)}}(t,(e||{}).mdastExtensions||[]);let n={};return function(e){let r={type:"root",children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:i,resume:o,data:n},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,t,n){let r,i,s,a,l=t-1,o=-1,c=!1;for(;++l<=n;){let t=e[l];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?o++:o--,a=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||a||o||s||(s=l),a=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:a=void 0}if(!o&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===o&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let a=l;for(i=void 0;a--;){let t=e[a];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;i&&(e[i][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",i=a}else if("linePrefix"===t[1].type||"blockQuotePrefix"===t[1].type||"blockQuotePrefixWhitespace"===t[1].type||"blockQuoteMarker"===t[1].type||"listItemIndent"===t[1].type);else break}s&&(!i||s<i)&&(r._spread=!0),r.end=Object.assign({},i?e[i][1].start:t[1].end),e.splice(i||l,0,["exit",r,t[2]]),l++,n++}if("listItemPrefix"===t[1].type){let i={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=i,e.splice(l,0,["enter",i,t[2]]),l++,n++,s=void 0,a=!0}}}return e[t][1]._spread=c,n}(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];nw.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||nC).call(a,void 0,e[0])}for(r.position={start:nS(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:nS(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r};function r(e,t){return function(n){s.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:nS(t.start),end:void 0}}function a(e){return function(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||nC).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+e0({start:e.start,end:e.end})+"): it’s not open");n.position.end=nS(e.end)}function o(){return td(this.stack.pop())}function c(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&"text"===n.type||((n={type:"text",value:""}).position={start:nS(e.start),end:void 0},t.push(n)),this.stack.push(n)}function d(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=nS(e.end)}function u(){this.data.atHardBreak=!0}function p(e){this.data.characterReferenceType=e.type}function h(){return{type:"code",lang:null,meta:null,value:""}}function m(){return{type:"heading",depth:0,children:[]}}function f(){return{type:"break"}}function g(){return{type:"html",value:""}}function x(){return{type:"link",title:null,url:"",children:[]}}function y(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(i)(function(e){for(;!tF(e););return e}((function(e){let t={constructs:tg([ny,...(e||{}).extensions||[]]),content:n(tE),defined:[],document:n(tz),flow:n(tO),lazy:{},string:n(tU),text:n(tq)};return t;function n(e){return function(n){return function(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},s=[],a=[],l=[],o={attempt:m(function(e,t){f(e,t.from)}),check:m(h),consume:function(e){tS(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,g()):-1!==e&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=e},enter:function(e,t){let n=t||{};return n.type=e,n.start=p(),c.events.push(["enter",n,c]),l.push(n),n},exit:function(e){let t=l.pop();return t.end=p(),c.events.push(["exit",t,c]),t},interrupt:m(h,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){i[e.line]=e.column,g()},events:[],now:p,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n,r=-1,i=[];for(;++r<e.length;){let s,a=e[r];if("string"==typeof a)s=a;else switch(a){case -5:s="\r";break;case -4:s="\n";break;case -3:s="\r\n";break;case -2:s=t?" ":" ";break;case -1:if(!t&&n)continue;s=" ";break;default:s=String.fromCharCode(a)}n=-2===a,i.push(s)}return i.join("")}(u(e),t)},sliceStream:u,write:function(e){return(a=tm(a,e),function(){let e;for(;r._index<a.length;){let n=a[r._index];if("string"==typeof n)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<n.length;){var t;t=n.charCodeAt(r._bufferIndex),d=d(t)}else d=d(n)}}(),null!==a[a.length-1])?[]:(f(t,0),c.events=tJ(s,c.events,c),c.events)}},d=t.tokenize.call(c,o);return t.resolveAll&&s.push(t),c;function u(e){return function(e,t){let n,r=t.start._index,i=t.start._bufferIndex,s=t.end._index,a=t.end._bufferIndex;if(r===s)n=[e[r].slice(i,a)];else{if(n=e.slice(r,s),i>-1){let e=n[0];"string"==typeof e?n[0]=e.slice(i):n.shift()}a>0&&n.push(e[s].slice(0,a))}return n}(a,e)}function p(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:s}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:s}}function h(e,t){t.restore()}function m(e,t){return function(n,i,s){var a;let d,u,h,m;return Array.isArray(n)?f(n):"tokenize"in n?f([n]):(a=n,function(e){let t=null!==e&&a[e],n=null!==e&&a.null;return f([...Array.isArray(t)?t:t?[t]:[],...Array.isArray(n)?n:n?[n]:[]])(e)});function f(e){return(d=e,u=0,0===e.length)?s:x(e[u])}function x(e){return function(n){let i,s,a,d,u;return(i=p(),s=c.previous,a=c.currentConstruct,d=c.events.length,u=Array.from(l),m={from:d,restore:function(){r=i,c.previous=s,c.currentConstruct=a,c.events.length=d,l=u,g()}},h=e,e.partial||(c.currentConstruct=e),e.name&&c.parser.constructs.disable.null.includes(e.name))?v(n):e.tokenize.call(t?Object.assign(Object.create(c),t):c,o,y,v)(n)}}function y(t){return e(h,m),i}function v(e){return(m.restore(),++u<d.length)?x(d[u]):s}}}function f(e,t){e.resolveAll&&!s.includes(e)&&s.push(e),e.resolve&&th(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function g(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}(t,e,n)}}})(i).document().write((a=1,l="",o=!0,function(e,t,n){let r,i,c,d,u,p=[];for(e=l+("string"==typeof e?e.toString():new TextDecoder(t||void 0).decode(e)),c=0,l="",o&&(65279===e.charCodeAt(0)&&c++,o=void 0);c<e.length;){if(nv.lastIndex=c,d=(r=nv.exec(e))&&void 0!==r.index?r.index:e.length,u=e.charCodeAt(d),!r){l=e.slice(c);break}if(10===u&&c===d&&s)p.push(-3),s=void 0;else switch(s&&(p.push(-5),s=void 0),c<d&&(p.push(e.slice(c,d)),a+=d-c),u){case 0:p.push(65533),a++;break;case 9:for(i=4*Math.ceil(a/4),p.push(-2);a++<i;)p.push(-1);break;case 10:p.push(-4),a=1;break;default:s=!0,a=1}c=d+1}return n&&(s&&p.push(-5),l&&p.push(l),p.push(null)),p})(n,r,!0))))}}let nI="object"==typeof self?self:globalThis,nT=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw TypeError("unable to deserialize "+e)}return new nI[e](t)},nM=e=>{var t;let n,r;return(t=new Map,n=(e,n)=>(t.set(n,e),e),r=i=>{if(t.has(i))return t.get(i);let[s,a]=e[i];switch(s){case 0:case -1:return n(a,i);case 1:{let e=n([],i);for(let t of a)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of a)e[r(t)]=r(n);return e}case 3:return n(new Date(a),i);case 4:{let{source:e,flags:t}=a;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of a)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of a)e.add(r(t));return e}case 7:{let{name:e,message:t}=a;return n("function"==typeof nI[e]?nT(e,t):Error(t),i)}case 8:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{let{buffer:e}=new Uint8Array(a);return n(new DataView(e),a)}}return n(nT(s,a),i)})(0)},{toString:nR}={},{keys:nE}=Object,nz=e=>{let t=typeof e;if("object"!==t||!e)return[0,t];let n=nR.call(e).slice(8,-1);switch(n){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,n]}return n.includes("Array")?[1,n]:e instanceof Error?[7,e.name||"Error"]:[2,n]},nA=([e,t])=>0===e&&("function"===t||"symbol"===t),nP=(e,{json:t,lossy:n}={})=>{var r,i,s;let a,l,o=[];return(r=!(t||n),i=!!t,s=new Map,a=(e,t)=>{let n=o.push(e)-1;return s.set(t,n),n},l=e=>{if(s.has(e))return s.get(e);let[t,n]=nz(e);switch(t){case 0:{let i=e;switch(n){case"bigint":t=8,i=e.toString();break;case"function":case"symbol":if(r)throw TypeError("unable to serialize "+n);i=null;break;case"undefined":return a([-1],e)}return a([t,i],e)}case 1:{if(n){let t=e;return"DataView"===n?t=new Uint8Array(e.buffer):"ArrayBuffer"===n&&(t=new Uint8Array(e)),a([n,[...t]],e)}let r=[],i=a([t,r],e);for(let t of e)r.push(l(t));return i}case 2:{if(n)switch(n){case"BigInt":return a([n,e.toString()],e);case"Boolean":case"Number":case"String":return a([n,e.valueOf()],e)}if(i&&"toJSON"in e)return l(e.toJSON());let s=[],o=a([t,s],e);for(let t of nE(e))(r||!nA(nz(e[t])))&&s.push([l(t),l(e[t])]);return o}case 3:return a([t,isNaN(e.getTime())?"":e.toISOString()],e);case 4:{let{source:n,flags:r}=e;return a([t,{source:n,flags:r}],e)}case 5:{let n=[],i=a([t,n],e);for(let[t,i]of e)(r||!(nA(nz(t))||nA(nz(i))))&&n.push([l(t),l(i)]);return i}case 6:{let n=[],i=a([t,n],e);for(let t of e)(r||!nA(nz(t)))&&n.push(l(t));return i}}let{message:o}=e;return a([t,{name:n,message:o}],e)})(e),o},n$="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?nM(nP(e,t)):structuredClone(e):(e,t)=>nM(nP(e,t));function nL(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let s=e.charCodeAt(n),a="";if(37===s&&ty(e.charCodeAt(n+1))&&ty(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){let t=e.charCodeAt(n+1);s<56320&&t>56319&&t<57344?(a=String.fromCharCode(s,t),i=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function nF(e,t){let n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function nD(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}let n_=function(e){var t,n;if(null==e)return nW;if("function"==typeof e)return nO(e);if("object"==typeof e){return Array.isArray(e)?function(e){let t=[],n=-1;for(;++n<e.length;)t[n]=n_(e[n]);return nO(function(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1})}(e):(t=e,nO(function(e){let n;for(n in t)if(e[n]!==t[n])return!1;return!0}))}if("string"==typeof e){return n=e,nO(function(e){return e&&e.type===n})}throw Error("Expected function, string, or object as test")};function nO(e){return function(t,n,r){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function nW(){return!0}let nU=[];function nq(e,t,n,r){let i;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):i=t;let s=n_(i),a=r?-1:1;(function e(i,l,o){let c=i&&"object"==typeof i?i:{};if("string"==typeof c.type){let e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(d,"name",{value:"node ("+i.type+(e?"<"+e+">":"")+")"})}return d;function d(){var c;let d,u,p,h=nU;if((!t||s(i,l,o[o.length-1]||void 0))&&!1===(h=Array.isArray(c=n(i,o))?c:"number"==typeof c?[!0,c]:null==c?nU:[c])[0])return h;if("children"in i&&i.children&&i.children&&"skip"!==h[0])for(u=(r?i.children.length:-1)+a,p=o.concat(i);u>-1&&u<i.children.length;){if(!1===(d=e(i.children[u],u,p)())[0])return d;u="number"==typeof d[1]?d[1]:u+a}return h}})(e,void 0,[])()}function nB(e,t,n,r){let i,s,a;"function"==typeof t&&"function"!=typeof n?(s=void 0,a=t,i=n):(s=t,a=n,i=r),nq(e,s,function(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return a(e,r,n)},i)}function nH(e,t){let n=t.referenceType,r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];let i=e.all(t),s=i[0];s&&"text"===s.type?s.value="["+s.value:i.unshift({type:"text",value:"["});let a=i[i.length-1];return a&&"text"===a.type?a.value+=r:i.push({type:"text",value:r}),i}function nV(e){let t=e.spread;return null==t?e.children.length>1:t}function nK(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;9===t||32===t;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;9===t||32===t;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}let nJ={blockquote:function(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){let n=t.value?t.value+"\n":"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s={type:"element",tagName:"pre",properties:{},children:[s=e.applyData(t,s)]},e.patch(t,s),s},delete:function(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){let n,r="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),s=nL(i.toLowerCase()),a=e.footnoteOrder.indexOf(i),l=e.footnoteCounts.get(i);void 0===l?(l=0,e.footnoteOrder.push(i),n=e.footnoteOrder.length):n=a+1,l+=1,e.footnoteCounts.set(i,l);let o={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+s,id:r+"fnref-"+s+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(n)}]};e.patch(t,o);let c={type:"element",tagName:"sup",properties:{},children:[o]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return nH(e,t);let i={src:nL(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(i.title=r.title);let s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)},image:function(e,t){let n={src:nL(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return nH(e,t);let i={href:nL(r.url||"")};null!==r.title&&void 0!==r.title&&(i.title=r.title);let s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)},link:function(e,t){let n={href:nL(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){let r=e.all(t),i=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=nV(n[r])}return t}(n):nV(t),s={},a=[];if("boolean"==typeof t.checked){let e,n=r[0];n&&"element"===n.type&&"p"===n.tagName?e=n:(e={type:"element",tagName:"p",properties:{},children:[]},r.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let l=-1;for(;++l<r.length;){let e=r[l];(i||0!==l||"element"!==e.type||"p"!==e.tagName)&&a.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||i?a.push(e):a.push(...e.children)}let o=r[r.length-1];o&&(i||"element"!==o.type||"p"!==o.tagName)&&a.push({type:"text",value:"\n"});let c={type:"element",tagName:"li",properties:s,children:a};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){let n={},r=e.all(t),i=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++i<r.length;){let e=r[i];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)},paragraph:function(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},s=eY(t.children[1]),a=eQ(t.children[t.children.length-1]);s&&a&&(r.position={start:s,end:a}),i.push(r)}let s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)},tableCell:function(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){let r=n?n.children:void 0,i=0===(r?r.indexOf(t):1)?"th":"td",s=n&&"table"===n.type?n.align:void 0,a=s?s.length:t.children.length,l=-1,o=[];for(;++l<a;){let n=t.children[l],r={},a=s?s[l]:void 0;a&&(r.align=a);let c={type:"element",tagName:i,properties:r,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),o.push(c)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(o,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){let n={type:"text",value:function(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,s=[];for(;r;)s.push(nK(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(nK(t.slice(i),i>0,!1)),s.join("")}(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:nG,yaml:nG,definition:nG,footnoteDefinition:nG};function nG(){}let nZ={}.hasOwnProperty,nQ={};function nY(e,t){e.position&&(t.position=function(e){let t=eY(e),n=eQ(e);if(t&&n)return{start:t,end:n}}(e))}function nX(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;"string"==typeof t&&("element"===n.type?n.tagName=t:n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}),"element"===n.type&&i&&Object.assign(n.properties,n$(i)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function n0(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function n1(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function n2(e,t){let n,r,i,s,a=(n=t||nQ,r=new Map,i=new Map,s={all:function(e){let t=[];if("children"in e){let n=e.children,r=-1;for(;++r<n.length;){let i=s.one(n[r],e);if(i){if(r&&"break"===n[r-1].type&&(Array.isArray(i)||"text"!==i.type||(i.value=n1(i.value)),!Array.isArray(i)&&"element"===i.type)){let e=i.children[0];e&&"text"===e.type&&(e.value=n1(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t},applyData:nX,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...nJ,...n.handlers},one:function(e,t){let n=e.type,r=s.handlers[n];if(nZ.call(s.handlers,n)&&r)return r(s,e,t);if(s.options.passThrough&&s.options.passThrough.includes(n)){if("children"in e){let{children:t,...n}=e,r=n$(n);return r.children=s.all(e),r}return n$(e)}return(s.options.unknownHandler||function(e,t){let n=t.data||{},r="value"in t&&!(nZ.call(n,"hProperties")||nZ.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)})(s,e,t)},options:n,patch:nY,wrap:n0},nB(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let t="definition"===e.type?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),s),l=a.one(e,void 0),o=function(e){let t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||nF,r=e.options.footnoteBackLabel||nD,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[],o=-1;for(;++o<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[o]);if(!i)continue;let s=e.all(i),a=String(i.identifier).toUpperCase(),c=nL(a.toLowerCase()),d=0,u=[],p=e.footnoteCounts.get(a);for(;void 0!==p&&++d<=p;){u.length>0&&u.push({type:"text",value:" "});let e="string"==typeof n?n:n(o,d);"string"==typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(o,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let h=s[s.length-1];if(h&&"element"===h.type&&"p"===h.tagName){let e=h.children[h.children.length-1];e&&"text"===e.type?e.value+=" ":h.children.push({type:"text",value:" "}),h.children.push(...u)}else s.push(...u);let m={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(s,!0)};e.patch(i,m),l.push(m)}if(0!==l.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...n$(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:"\n"}]}}(a),c=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return o&&(eD("children"in c),c.children.push({type:"text",value:"\n"},o)),c}function n4(e,t){return e&&"run"in e?async function(n,r){let i=n2(n,{file:r,...t});await e.run(i,r)}:function(n,r){return n2(n,{file:r,...e||t})}}function n5(e){if(e)throw e}var n6=e.i(4100);function n3(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let n9=function(e,t){let n;if(void 0!==t&&"string"!=typeof t)throw TypeError('"ext" argument must be a string');rt(e);let r=0,i=-1,s=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;s--;)if(47===e.codePointAt(s)){if(n){r=s+1;break}}else i<0&&(n=!0,i=s+1);return i<0?"":e.slice(r,i)}if(t===e)return"";let a=-1,l=t.length-1;for(;s--;)if(47===e.codePointAt(s)){if(n){r=s+1;break}}else a<0&&(n=!0,a=s+1),l>-1&&(e.codePointAt(s)===t.codePointAt(l--)?l<0&&(i=s):(l=-1,i=a));return r===i?i=a:i<0&&(i=e.length),e.slice(r,i)},n8=function(e){let t;if(rt(e),0===e.length)return".";let n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},n7=function(e){let t;rt(e);let n=e.length,r=-1,i=0,s=-1,a=0;for(;n--;){let l=e.codePointAt(n);if(47===l){if(t){i=n+1;break}continue}r<0&&(t=!0,r=n+1),46===l?s<0?s=n:1!==a&&(a=1):s>-1&&(a=-1)}return s<0||r<0||0===a||1===a&&s===r-1&&s===i+1?"":e.slice(s,r)},re=function(...e){var t;let n,r,i,s=-1;for(;++s<e.length;)rt(e[s]),e[s]&&(i=void 0===i?e[s]:i+"/"+e[s]);return void 0===i?".":(rt(t=i),n=47===t.codePointAt(0),0!==(r=function(e,t){let n,r,i="",s=0,a=-1,l=0,o=-1;for(;++o<=e.length;){if(o<e.length)n=e.codePointAt(o);else if(47===n)break;else n=47;if(47===n){if(a===o-1||1===l);else if(a!==o-1&&2===l){if(i.length<2||2!==s||46!==i.codePointAt(i.length-1)||46!==i.codePointAt(i.length-2)){if(i.length>2){if((r=i.lastIndexOf("/"))!==i.length-1){r<0?(i="",s=0):s=(i=i.slice(0,r)).length-1-i.lastIndexOf("/"),a=o,l=0;continue}}else if(i.length>0){i="",s=0,a=o,l=0;continue}}t&&(i=i.length>0?i+"/..":"..",s=2)}else i.length>0?i+="/"+e.slice(a+1,o):i=e.slice(a+1,o),s=o-a-1;a=o,l=0}else 46===n&&l>-1?l++:l=-1}return i}(t,!n)).length||n||(r="."),r.length>0&&47===t.codePointAt(t.length-1)&&(r+="/"),n?"/"+r:r)};function rt(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function rn(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let rr=["history","path","basename","stem","extname","dirname"];class ri{constructor(e){let t,n;t=e?rn(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 t?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<rr.length;){const e=rr[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)rr.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?n9(this.path):void 0}set basename(e){ra(e,"basename"),rs(e,"basename"),this.path=re(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?n8(this.path):void 0}set dirname(e){rl(this.basename,"dirname"),this.path=re(e||"",this.basename)}get extname(){return"string"==typeof this.path?n7(this.path):void 0}set extname(e){if(rs(e,"extname"),rl(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=re(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){rn(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!rn(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}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 t=e.pathname,n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){let e=t.codePointAt(n+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(t)}(e)}(e)),ra(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?n9(this.path,this.extname):void 0}set stem(e){ra(e,"stem"),rs(e,"stem"),this.path=re(this.dirname||"",e+(this.extname||""))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new e5(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function rs(e,t){if(e&&e.includes("/"))throw Error("`"+t+"` cannot be a path: did not expect `/`")}function ra(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function rl(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}let ro=function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},rc={}.hasOwnProperty;class rd extends ro{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=[],t={run:function(...t){let n=-1,r=t.pop();if("function"!=typeof r)throw TypeError("Expected function as last argument, not "+r);!function i(s,...a){let l=e[++n],o=-1;if(s)return void r(s);for(;++o<t.length;)(null===a[o]||void 0===a[o])&&(a[o]=t[o]);t=a,l?(function(e,t){let n;return function(...t){let s,a=e.length>t.length;a&&t.push(r);try{s=e.apply(this,t)}catch(e){if(a&&n)throw e;return r(e)}a||(s&&s.then&&"function"==typeof s.then?s.then(i,r):s instanceof Error?r(s):i(s))};function r(e,...i){n||(n=!0,t(e,...i))}function i(e){r(null,e)}})(l,i)(...a):r(null,...a)}(null,...t)},use:function(n){if("function"!=typeof n)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}()}copy(){let e=new rd,t=-1;for(;++t<this.attachers.length;){let n=this.attachers[t];e.use(...n)}return e.data((0,n6.default)(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2==arguments.length?(rm("data",this.frozen),this.namespace[e]=t,this):rc.call(this.namespace,e)&&this.namespace[e]||void 0:e?(rm("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...t]=this.attachers[this.freezeIndex];if(!1===t[0])continue;!0===t[0]&&(t[0]=void 0);let n=e.call(this,...t);"function"==typeof n&&this.transformers.use(n)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=rx(e),n=this.parser||this.Parser;return rp("parse",n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),rp("process",this.parser||this.Parser),rh("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let s=rx(e),a=n.parse(s);function l(e,n){e||!n?i(e):r?r(n):(eD(t,"`done` is defined if `resolve` is not"),t(void 0,n))}n.run(a,s,function(e,t,r){var i,s;if(e||!t||!r)return l(e);let a=n.stringify(t,r);"string"==typeof(i=a)||(s=i)&&"object"==typeof s&&"byteLength"in s&&"byteOffset"in s?r.value=a:r.result=a,l(e,r)})}}processSync(e){let t,n=!1;return this.freeze(),rp("processSync",this.parser||this.Parser),rh("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,n5(e),t=r}),rg("processSync","process",n),eD(t,"we either bailed on an error or have a tree"),t}run(e,t,n){rf(e),this.freeze();let r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,s){eD("function"!=typeof t,"`file` can’t be a `done` anymore, we checked");let a=rx(t);r.run(e,a,function(t,r,a){let l=r||e;t?s(t):i?i(l):(eD(n,"`done` is defined if `resolve` is not"),n(void 0,l,a))})}}runSync(e,t){let n,r=!1;return this.run(e,t,function(e,t){n5(e),n=t,r=!0}),rg("runSync","run",r),eD(n,"we either bailed on an error or have a tree"),n}stringify(e,t){this.freeze();let n=rx(t),r=this.compiler||this.Compiler;return rh("stringify",r),rf(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(rm("use",this.frozen),null==e);else if("function"==typeof e)a(e,t);else if("object"==typeof e)Array.isArray(e)?s(e):i(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(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");s(e.plugins),e.settings&&(r.settings=(0,n6.default)(!0,r.settings,e.settings))}function s(e){let t=-1;if(null==e);else if(Array.isArray(e))for(;++t<e.length;)!function(e){if("function"==typeof e)a(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[t,...n]=e;a(t,n)}else i(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[t]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function a(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(-1===i)n.push([e,...t]);else if(t.length>0){let[r,...s]=t,a=n[i][1];n3(a)&&n3(r)&&(r=(0,n6.default)(!0,a,r)),n[i]=[e,r,...s]}}}}let ru=new rd().freeze();function rp(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `parser`")}function rh(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `compiler`")}function rm(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function rf(e){if(!n3(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function rg(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function rx(e){var t;return(t=e)&&"object"==typeof t&&"message"in t&&"messages"in t?e:new ri(e)}let ry=[],rv={allowDangerousHtml:!0},rb=/^(https?|ircs?|mailto|xmpp)$/i,rj=[{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 rk(e){var n;let r,i,s,a,l,o=(r=(n=e).rehypePlugins||ry,i=n.remarkPlugins||ry,s=n.remarkRehypeOptions?{...n.remarkRehypeOptions,...rv}:rv,ru().use(nN).use(i).use(n4,s).use(r)),c=(a=e.children||"",l=new ri,"string"==typeof a?l.value=a:e_("Unexpected value `"+a+"` for `children` prop, expected `string`"),l);return function(e,n){let r=n.allowedElements,i=n.allowElement,s=n.components,a=n.disallowedElements,l=n.skipHtml,o=n.unwrapDisallowed,c=n.urlTransform||rw;for(let e of rj)Object.hasOwn(n,e.from)&&e_("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&&a&&e_("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),nB(e,function(e,t,n){if("raw"===e.type&&n&&"number"==typeof t)return l?n.children.splice(t,1):n.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in to)if(Object.hasOwn(to,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=to[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=c(String(n||""),t,e))}}if("element"===e.type){let s=r?!r.includes(e.tagName):!!a&&a.includes(e.tagName);if(!s&&i&&"number"==typeof t&&(s=!i(e,t,n)),s&&n&&"number"==typeof t)return o&&e.children?n.children.splice(t,1,...e.children):n.children.splice(t,1),t}}),function(e,t){var n,r,i,s;let a;if(!t||void 0===t.Fragment)throw TypeError("Expected `Fragment` in options");let l=t.filePath||void 0;if(t.development){if("function"!=typeof t.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");n=l,r=t.jsxDEV,a=function(e,t,i,s){let a=Array.isArray(i.children),l=eY(e);return r(t,i,s,a,{columnNumber:l?l.column-1:void 0,fileName:n,lineNumber:l?l.line:void 0},void 0)}}else{if("function"!=typeof t.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw TypeError("Expected `jsxs` in production options");i=t.jsx,s=t.jsxs,a=function(e,t,n,r){let a=Array.isArray(n.children)?s:i;return r?a(t,n,r):a(t,n)}}let o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:a,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:l,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?eJ.svg:eJ.html,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},c=tt(o,e,void 0);return c&&"string"!=typeof c?c:o.create(e,o.Fragment,{children:c||void 0},void 0)}(e,{Fragment:t.Fragment,components:s,ignoreInvalidStyle:!0,jsx:t.jsx,jsxs:t.jsxs,passKeys:!0,passNode:!0})}(o.runSync(o.parse(c),c),e)}function rw(e){let t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return -1===t||-1!==i&&t>i||-1!==n&&t>n||-1!==r&&t>r||rb.test(e.slice(0,t))?e:""}var rS=e.i(96481);let rC="phrasing",rN=["autolink","link","image","label"];function rI(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function rT(e){this.config.enter.autolinkProtocol.call(this,e)}function rM(e){this.config.exit.autolinkProtocol.call(this,e)}function rR(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];eD("link"===t.type),t.url="http://"+this.sliceSerialize(e)}function rE(e){this.config.exit.autolinkEmail.call(this,e)}function rz(e){this.exit(e)}function rA(e){!function(e,t,n){let r=n_((n||{}).ignore||[]),i=function(e){let t=[];if(!Array.isArray(e))throw TypeError("Expected find and replace tuple or list of tuples");let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){var i;let e=n[r];t.push(["string"==typeof(i=e[0])?RegExp(function(e){if("string"!=typeof e)throw TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(i),"g"):i,function(e){return"function"==typeof e?e:function(){return e}}(e[1])])}return t}(t),s=-1;for(;++s<i.length;)nq(e,"text",a);function a(e,t){let n,a=-1;for(;++a<t.length;){let e=t[a],i=n?n.children:void 0;if(r(e,i?i.indexOf(e):void 0,n))return;n=e}if(n)return function(e,t){let n=t[t.length-1],r=i[s][0],a=i[s][1],l=0,o=n.children.indexOf(e),c=!1,d=[];r.lastIndex=0;let u=r.exec(e.value);for(;u;){let n=u.index,i={index:u.index,input:u.input,stack:[...t,e]},s=a(...u,i);if("string"==typeof s&&(s=s.length>0?{type:"text",value:s}:void 0),!1===s?r.lastIndex=n+1:(l!==n&&d.push({type:"text",value:e.value.slice(l,n)}),Array.isArray(s)?d.push(...s):s&&d.push(s),l=n+u[0].length,c=!0),!r.global)break;u=r.exec(e.value)}return c?(l<e.value.length&&d.push({type:"text",value:e.value.slice(l)}),n.children.splice(o,1,...d)):d=[e],o+d.length}(e,t)}}(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,rP],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,r$]],{ignore:["link","linkReference"]})}function rP(e,t,n,r,i){let s,a="";if(!rL(i))return!1;if(/^w/i.test(t)&&(n=t+n,t="",a="http://"),(s=n.split(".")).length<2||s[s.length-1]&&(/_/.test(s[s.length-1])||!/[a-zA-Z\d]/.test(s[s.length-1]))||s[s.length-2]&&(/_/.test(s[s.length-2])||!/[a-zA-Z\d]/.test(s[s.length-2])))return!1;let l=function(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")"),i=(0,rS.ccount)(e,"("),s=(0,rS.ccount)(e,")");for(;-1!==r&&i>s;)e+=n.slice(0,r+1),r=(n=n.slice(r+1)).indexOf(")"),s++;return[e,n]}(n+r);if(!l[0])return!1;let o={type:"link",title:null,url:a+t+l[0],children:[{type:"text",value:t+l[0]}]};return l[1]?[o,{type:"text",value:l[1]}]:o}function r$(e,t,n,r){return!(!rL(r,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function rL(e,t){let n=e.input.charCodeAt(e.index-1);return(0===e.index||tT(n)||tI(n))&&(!t||47!==n)}function rF(){this.buffer()}function rD(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function r_(){this.buffer()}function rO(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function rW(e){let t=this.resume(),n=this.stack[this.stack.length-1];eD("footnoteReference"===n.type),n.identifier=ne(this.sliceSerialize(e)).toLowerCase(),n.label=t}function rU(e){this.exit(e)}function rq(e){let t=this.resume(),n=this.stack[this.stack.length-1];eD("footnoteDefinition"===n.type),n.identifier=ne(this.sliceSerialize(e)).toLowerCase(),n.label=t}function rB(e){this.exit(e)}function rH(e,t,n,r){let i=n.createTracker(r),s=i.move("[^"),a=n.enter("footnoteReference"),l=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),l(),a(),s+=i.move("]")}function rV(e,t,n){return 0===t?e:rK(e,t,n)}function rK(e,t,n){return(n?"":" ")+e}rH.peek=function(){return"["};let rJ=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function rG(e){this.enter({type:"delete",children:[]},e)}function rZ(e){this.exit(e)}function rQ(e,t,n,r){let i=n.createTracker(r),s=n.enter("strikethrough"),a=i.move("~~");return a+=n.containerPhrasing(e,{...i.current(),before:a,after:"~"}),a+=i.move("~~"),s(),a}function rY(e){return e.length}function rX(e){let t="string"==typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:114*(82===t||114===t)}rQ.peek=function(){return"~"};function r0(e,t,n){let r=e.value||"",i="`",s=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){let e,t=n.unsafe[s],i=n.compilePattern(t);if(t.atBreak)for(;e=i.exec(r);){let t=e.index;10===r.charCodeAt(t)&&13===r.charCodeAt(t-1)&&t--,r=r.slice(0,t)+" "+r.slice(e.index+1)}}return i+r+i}r0.peek=function(){return"`"};n_(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);let r1=function(e,t,n,r){let i=function(e){let t=e.options.listItemIndent||"one";if("tab"!==t&&"one"!==t&&"mixed"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}(n),s=n.bulletCurrent||function(e){let t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}(n);t&&"list"===t.type&&t.ordered&&(s=("number"==typeof t.start&&t.start>-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+s);let a=s.length+1;("tab"===i||"mixed"===i&&(t&&"list"===t.type&&t.spread||e.spread))&&(a=4*Math.ceil(a/4));let l=n.createTracker(r);l.move(s+" ".repeat(a-s.length)),l.shift(a);let o=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,l.current()),function(e,t,n){return t?(n?"":" ".repeat(a))+e:(n?s:s+" ".repeat(a-s.length))+e});return o(),c};function r2(e){let t=e._align;eD(t,"expected `_align` on table"),this.enter({type:"table",align:t.map(function(e){return"none"===e?null:e}),children:[]},e),this.data.inTable=!0}function r4(e){this.exit(e),this.data.inTable=void 0}function r5(e){this.enter({type:"tableRow",children:[]},e)}function r6(e){this.exit(e)}function r3(e){this.enter({type:"tableCell",children:[]},e)}function r9(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,r8));let n=this.stack[this.stack.length-1];eD("inlineCode"===n.type),n.value=t,this.exit(e)}function r8(e,t){return"|"===t?t:e}function r7(e){let t=this.stack[this.stack.length-2];eD("listItem"===t.type),t.checked="taskListCheckValueChecked"===e.type}function ie(e){let t=this.stack[this.stack.length-2];if(t&&"listItem"===t.type&&"boolean"==typeof t.checked){let e=this.stack[this.stack.length-1];eD("paragraph"===e.type);let n=e.children[0];if(n&&"text"===n.type){let r,i=t.children,s=-1;for(;++s<i.length;){let e=i[s];if("paragraph"===e.type){r=e;break}}r===e&&(n.value=n.value.slice(1),0===n.value.length?e.children.shift():e.position&&n.position&&"number"==typeof n.position.start.offset&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function it(e,t,n,r){let i=e.children[0],s="boolean"==typeof e.checked&&i&&"paragraph"===i.type,a="["+(e.checked?"x":" ")+"] ",l=n.createTracker(r);s&&l.move(a);let o=r1(e,t,n,{...r,...l.current()});return s&&(o=o.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+a})),o}let ir={tokenize:function(e,t,n){let r=0;return function t(s){return(87===s||119===s)&&r<3?(r++,e.consume(s),t):46===s&&3===r?(e.consume(s),i):n(s)};function i(e){return null===e?n(e):t(e)}},partial:!0},ii={tokenize:function(e,t,n){let r,i,s;return a;function a(t){return 46===t||95===t?e.check(ia,o,l)(t):null===t||tC(t)||tT(t)||45!==t&&tI(t)?o(t):(s=!0,e.consume(t),a)}function l(t){return 95===t?r=!0:(i=r,r=void 0),e.consume(t),a}function o(e){return i||r||!s?n(e):t(e)}},partial:!0},is={tokenize:function(e,t){let n=0,r=0;return i;function i(a){return 40===a?(n++,e.consume(a),i):41===a&&r<n?s(a):33===a||34===a||38===a||39===a||41===a||42===a||44===a||46===a||58===a||59===a||60===a||63===a||93===a||95===a||126===a?e.check(ia,t,s)(a):null===a||tC(a)||tT(a)?t(a):(e.consume(a),i)}function s(t){return 41===t&&r++,e.consume(t),i}},partial:!0},ia={tokenize:function(e,t,n){return r;function r(a){return 33===a||34===a||39===a||41===a||42===a||44===a||46===a||58===a||59===a||63===a||95===a||126===a?(e.consume(a),r):38===a?(e.consume(a),s):93===a?(e.consume(a),i):60===a||null===a||tC(a)||tT(a)?t(a):n(a)}function i(e){return null===e||40===e||91===e||tC(e)||tT(e)?t(e):r(e)}function s(t){return tx(t)?function t(i){return 59===i?(e.consume(i),r):tx(i)?(e.consume(i),t):n(i)}(t):n(t)}},partial:!0},il={tokenize:function(e,t,n){return function(t){return e.consume(t),r};function r(e){return ty(e)?n(e):t(e)}},partial:!0},io={name:"wwwAutolink",tokenize:function(e,t,n){let r=this;return function(t){return 87!==t&&119!==t||!ih.call(r,r.previous)||iy(r.events)?n(t):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(ir,e.attempt(ii,e.attempt(is,i),n),n)(t))};function i(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:ih},ic={name:"protocolAutolink",tokenize:function(e,t,n){let r=this,i="",s=!1;return function(t){return(72===t||104===t)&&im.call(r,r.previous)&&!iy(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(t),e.consume(t),a):n(t)};function a(t){if(tx(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),a;if(58===t){let n=i.toLowerCase();if("http"===n||"https"===n)return e.consume(t),l}return n(t)}function l(t){return 47===t?(e.consume(t),s)?o:(s=!0,l):n(t)}function o(t){return null===t||tb(t)||tC(t)||tT(t)||tI(t)?n(t):e.attempt(ii,e.attempt(is,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:im},id={name:"emailAutolink",tokenize:function(e,t,n){let r,i,s=this;return function(t){return!ix(t)||!ig.call(s,s.previous)||iy(s.events)?n(t):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),function t(r){return ix(r)?(e.consume(r),t):64===r?(e.consume(r),a):n(r)}(t))};function a(t){return 46===t?e.check(il,o,l)(t):45===t||95===t||ty(t)?(i=!0,e.consume(t),a):o(t)}function l(t){return e.consume(t),r=!0,a}function o(a){return i&&r&&tx(s.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(a)):n(a)}},previous:ig},iu={},ip=48;for(;ip<123;)iu[ip]=id,58==++ip?ip=65:91===ip&&(ip=97);function ih(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||tC(e)}function im(e){return!tx(e)}function ig(e){return!(47===e||ix(e))}function ix(e){return 43===e||45===e||46===e||95===e||ty(e)}function iy(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if(("labelLink"===r.type||"labelImage"===r.type)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}iu[43]=id,iu[45]=id,iu[46]=id,iu[95]=id,iu[72]=[id,ic],iu[104]=[id,ic],iu[87]=[id,io],iu[119]=[id,io];let iv={tokenize:function(e,t,n){let r=this;return tR(e,function(e){let i=r.events[r.events.length-1];return i&&"gfmFootnoteDefinitionIndent"===i[1].type&&4===i[2].sliceSerialize(i[1],!0).length?t(e):n(e)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function ib(e,t,n){let r,i=this,s=i.events.length,a=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);for(;s--;){let e=i.events[s][1];if("labelImage"===e.type){r=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(s){if(!r||!r._balanced)return n(s);let l=ne(i.sliceSerialize({start:r.end,end:i.now()}));return 94===l.codePointAt(0)&&a.includes(l.slice(1))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(s),e.exit("gfmFootnoteCallLabelMarker"),t(s)):n(s)}}function ij(e,t){let n=e.length;for(;n--;)if("labelImage"===e[n][1].type&&"enter"===e[n][0]){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";let r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},l=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",a,t],["exit",a,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...l),e}function ik(e,t,n){let r,i=this,s=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]),a=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),l};function l(t){return 94!==t?n(t):(e.enter("gfmFootnoteCallMarker"),e.consume(t),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",o)}function o(l){if(a>999||93===l&&!r||null===l||91===l||tC(l))return n(l);if(93===l){e.exit("chunkString");let r=e.exit("gfmFootnoteCallString");return s.includes(ne(i.sliceSerialize(r)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(l)}return tC(l)||(r=!0),a++,e.consume(l),92===l?c:o}function c(t){return 91===t||92===t||93===t?(e.consume(t),a++,o):o(t)}}function iw(e,t,n){let r,i,s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]),l=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),o};function o(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(t)}function c(t){if(l>999||93===t&&!i||null===t||91===t||tC(t))return n(t);if(93===t){e.exit("chunkString");let n=e.exit("gfmFootnoteDefinitionLabelString");return r=ne(s.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),u}return tC(t)||(i=!0),l++,e.consume(t),92===t?d:c}function d(t){return 91===t||92===t||93===t?(e.consume(t),l++,c):c(t)}function u(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),a.includes(r)||a.push(r),tR(e,p,"gfmFootnoteDefinitionWhitespace")):n(t)}function p(e){return t(e)}}function iS(e,t,n){return e.check(tP,t,e.attempt(iv,t,n))}function iC(e){e.exit("gfmFootnoteDefinition")}class iN{constructor(){this.map=[]}add(e,t,n){!function(e,t,n,r){let i=0;if(0!==n||0!==r.length){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),0===this.map.length)return;let t=this.map.length,n=[];for(;t>0;)t-=1,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}}function iI(e,t,n){let r,i=this,s=0,a=0;return function(e){let t=i.events.length-1;for(;t>-1;){let e=i.events[t][1].type;if("lineEnding"===e||"linePrefix"===e)t--;else break}let r=t>-1?i.events[t][1].type:null,s="tableHead"===r||"tableRow"===r?y:l;return s===y&&i.parser.lazy[i.now().line]?n(e):s(e)};function l(t){var n;return e.enter("tableHead"),e.enter("tableRow"),124===(n=t)||(r=!0,a+=1),o(n)}function o(t){return null===t?n(t):tS(t)?a>1?(a=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),u):n(t):tN(t)?tR(e,o,"whitespace")(t):(a+=1,r&&(r=!1,s+=1),124===t)?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),r=!0,o):(e.enter("data"),c(t))}function c(t){return null===t||124===t||tC(t)?(e.exit("data"),o(t)):(e.consume(t),92===t?d:c)}function d(t){return 92===t||124===t?(e.consume(t),c):c(t)}function u(t){return(i.interrupt=!1,i.parser.lazy[i.now().line])?n(t):(e.enter("tableDelimiterRow"),r=!1,tN(t))?tR(e,p,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):p(t)}function p(t){return 45===t||58===t?m(t):124===t?(r=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),h):n(t)}function h(t){return tN(t)?tR(e,m,"whitespace")(t):m(t)}function m(t){return 58===t?(a+=1,r=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),f):45===t?(a+=1,f(t)):null===t||tS(t)?x(t):n(t)}function f(t){return 45===t?(e.enter("tableDelimiterFiller"),function t(n){return 45===n?(e.consume(n),t):58===n?(r=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(n),e.exit("tableDelimiterMarker"),g):(e.exit("tableDelimiterFiller"),g(n))}(t)):n(t)}function g(t){return tN(t)?tR(e,x,"whitespace")(t):x(t)}function x(i){if(124===i)return p(i);if(null===i||tS(i))return r&&s===a?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(i)):n(i);return n(i)}function y(t){return e.enter("tableRow"),v(t)}function v(n){return 124===n?(e.enter("tableCellDivider"),e.consume(n),e.exit("tableCellDivider"),v):null===n||tS(n)?(e.exit("tableRow"),t(n)):tN(n)?tR(e,v,"whitespace")(n):(e.enter("data"),b(n))}function b(t){return null===t||124===t||tC(t)?(e.exit("data"),v(t)):(e.consume(t),92===t?j:b)}function j(t){return 92===t||124===t?(e.consume(t),b):b(t)}}function iT(e,t){let n,r,i,s=-1,a=!0,l=0,o=[0,0,0,0],c=[0,0,0,0],d=!1,u=0,p=new iN;for(;++s<e.length;){let h=e[s],m=h[1];"enter"===h[0]?"tableHead"===m.type?(d=!1,0!==u&&(iR(p,t,u,n,r),r=void 0,u=0),n={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(s,0,[["enter",n,t]])):"tableRow"===m.type||"tableDelimiterRow"===m.type?(a=!0,i=void 0,o=[0,0,0,0],c=[0,s+1,0,0],d&&(d=!1,r={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(s,0,[["enter",r,t]])),l="tableDelimiterRow"===m.type?2:r?3:1):l&&("data"===m.type||"tableDelimiterMarker"===m.type||"tableDelimiterFiller"===m.type)?(a=!1,0===c[2]&&(0!==o[1]&&(c[0]=c[1],i=iM(p,t,o,l,void 0,i),o=[0,0,0,0]),c[2]=s)):"tableCellDivider"===m.type&&(a?a=!1:(0!==o[1]&&(c[0]=c[1],i=iM(p,t,o,l,void 0,i)),c=[(o=c)[1],s,0,0])):"tableHead"===m.type?(d=!0,u=s):"tableRow"===m.type||"tableDelimiterRow"===m.type?(u=s,0!==o[1]?(c[0]=c[1],i=iM(p,t,o,l,s,i)):0!==c[1]&&(i=iM(p,t,c,l,s,i)),l=0):l&&("data"===m.type||"tableDelimiterMarker"===m.type||"tableDelimiterFiller"===m.type)&&(c[3]=s)}for(0!==u&&iR(p,t,u,n,r),p.consume(t.events),s=-1;++s<t.events.length;){let e=t.events[s];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=function(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if("enter"===i[0])"tableContent"===i[1].type&&r.push("tableDelimiterMarker"===e[t+1][1].type?"left":"none");else if("tableContent"===i[1].type){if("tableDelimiterMarker"===e[t-1][1].type){let e=r.length-1;r[e]="left"===r[e]?"center":"right"}}else if("tableDelimiterRow"===i[1].type)break}else"enter"===i[0]&&"tableDelimiterRow"===i[1].type&&(n=!0);t+=1}return r}(t.events,s))}return e}function iM(e,t,n,r,i,s){0!==n[0]&&(s.end=Object.assign({},iE(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));let a=iE(t.events,n[1]);if(s={type:1===r?"tableHeader":2===r?"tableDelimiter":"tableData",start:Object.assign({},a),end:Object.assign({},a)},e.add(n[1],0,[["enter",s,t]]),0!==n[2]){let i=iE(t.events,n[2]),s=iE(t.events,n[3]),a={type:"tableContent",start:Object.assign({},i),end:Object.assign({},s)};if(e.add(n[2],0,[["enter",a,t]]),2!==r){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type="chunkText",r[1].contentType="text",n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[["exit",a,t]])}return void 0!==i&&(s.end=Object.assign({},iE(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function iR(e,t,n,r,i){let s=[],a=iE(t.events,n);i&&(i.end=Object.assign({},a),s.push(["exit",i,t])),r.end=Object.assign({},a),s.push(["exit",r,t]),e.add(n+1,0,s)}function iE(e,t){let n=e[t],r="enter"===n[0]?"start":"end";return n[1][r]}let iz={name:"tasklistCheck",tokenize:function(e,t,n){let r=this;return function(t){return null===r.previous&&r._gfmTasklistFirstContentOfListItem?(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),i):n(t)};function i(t){return tC(t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),s):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),s):n(t)}function s(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(t)}function a(r){return tS(r)?t(r):tN(r)?e.check({tokenize:iA},t,n)(r):n(r)}}};function iA(e,t,n){return tR(e,function(e){return null===e?n(e):t(e)},"whitespace")}let iP={};function i$(e){let t,n,r,i=e||iP,s=this.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),l=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),o=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(tg([{text:iu},{document:{91:{name:"gfmFootnoteDefinition",tokenize:iw,continuation:{tokenize:iS},exit:iC}},text:{91:{name:"gfmFootnoteCall",tokenize:ik},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:ib,resolveTo:ij}}},(t=(i||{}).singleTilde,n={name:"strikethrough",tokenize:function(e,n,r){let i=this.previous,s=this.events,a=0;return function(l){return 126===i&&"characterEscape"!==s[s.length-1][1].type?r(l):(e.enter("strikethroughSequenceTemporary"),function s(l){let o=tK(i);if(126===l)return a>1?r(l):(e.consume(l),a++,s);if(a<2&&!t)return r(l);let c=e.exit("strikethroughSequenceTemporary"),d=tK(l);return c._open=!d||2===d&&!!o,c._close=!o||2===o&&!!d,n(l)}(l))}},resolveAll:function(e,t){let n=-1;for(;++n<e.length;)if("enter"===e[n][0]&&"strikethroughSequenceTemporary"===e[n][1].type&&e[n][1]._close){let r=n;for(;r--;)if("exit"===e[r][0]&&"strikethroughSequenceTemporary"===e[r][1].type&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset==e[r][1].end.offset-e[r][1].start.offset){e[n][1].type="strikethroughSequence",e[r][1].type="strikethroughSequence";let i={type:"strikethrough",start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},s={type:"strikethroughText",start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},a=[["enter",i,t],["enter",e[r][1],t],["exit",e[r][1],t],["enter",s,t]],l=t.parser.constructs.insideSpan.null;l&&th(a,a.length,0,tJ(l,e.slice(r+1,n),t)),th(a,a.length,0,[["exit",s,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",i,t]]),th(e,r-1,n-r+3,a),n=r+a.length-2;break}}for(n=-1;++n<e.length;)"strikethroughSequenceTemporary"===e[n][1].type&&(e[n][1].type="data");return e}},null==t&&(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}}),{flow:{null:{name:"table",tokenize:iI,resolveAll:iT}}},{text:{91:iz}}])),l.push([{transforms:[rA],enter:{literalAutolink:rI,literalAutolinkEmail:rT,literalAutolinkHttp:rT,literalAutolinkWww:rT},exit:{literalAutolink:rz,literalAutolinkEmail:rE,literalAutolinkHttp:rM,literalAutolinkWww:rR}},{enter:{gfmFootnoteCallString:rF,gfmFootnoteCall:rD,gfmFootnoteDefinitionLabelString:r_,gfmFootnoteDefinition:rO},exit:{gfmFootnoteCallString:rW,gfmFootnoteCall:rU,gfmFootnoteDefinitionLabelString:rq,gfmFootnoteDefinition:rB}},{canContainEols:["delete"],enter:{strikethrough:rG},exit:{strikethrough:rZ}},{enter:{table:r2,tableData:r3,tableHeader:r3,tableRow:r5},exit:{codeText:r9,table:r4,tableData:r6,tableHeader:r6,tableRow:r6}},{exit:{taskListCheckValueChecked:r7,taskListCheckValueUnchecked:r7,paragraph:ie}}]),o.push({extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:rC,notInConstruct:rN},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:rC,notInConstruct:rN},{character:":",before:"[ps]",after:"\\/",inConstruct:rC,notInConstruct:rN}]},(r=!1,i&&i.firstLineBlank&&(r=!0),{handlers:{footnoteDefinition:function(e,t,n,i){let s=n.createTracker(i),a=s.move("[^"),l=n.enter("footnoteDefinition"),o=n.enter("label");return a+=s.move(n.safe(n.associationId(e),{before:a,after:"]"})),o(),a+=s.move("]:"),e.children&&e.children.length>0&&(s.shift(4),a+=s.move((r?"\n":" ")+n.indentLines(n.containerFlow(e,s.current()),r?rK:rV))),l(),a},footnoteReference:rH},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:rJ}],handlers:{delete:rQ}},function(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(e,t,n){let r=r0(e,t,n);return n.stack.includes("tableCell")&&(r=r.replace(/\|/g,"\\$&")),r},table:function(e,t,n,r){return l(function(e,t,n){let r=e.children,i=-1,s=[],a=t.enter("table");for(;++i<r.length;)s[i]=o(r[i],t,n);return a(),s}(e,n,r),e.align)},tableCell:a,tableRow:function(e,t,n,r){let i=l([o(e,n,r)]);return i.slice(0,i.indexOf("\n"))}}};function a(e,t,n,r){let i=n.enter("tableCell"),a=n.enter("phrasing"),l=n.containerPhrasing(e,{...r,before:s,after:s});return a(),i(),l}function l(e,t){return function(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||rY,s=[],a=[],l=[],o=[],c=0,d=-1;for(;++d<e.length;){let t=[],r=[],s=-1;for(e[d].length>c&&(c=e[d].length);++s<e[d].length;){var u;let a=null==(u=e[d][s])?"":String(u);if(!1!==n.alignDelimiters){let e=i(a);r[s]=e,(void 0===o[s]||e>o[s])&&(o[s]=e)}t.push(a)}a[d]=t,l[d]=r}let p=-1;if("object"==typeof r&&"length"in r)for(;++p<c;)s[p]=rX(r[p]);else{let e=rX(r);for(;++p<c;)s[p]=e}p=-1;let h=[],m=[];for(;++p<c;){let e=s[p],t="",r="";99===e?(t=":",r=":"):108===e?t=":":114===e&&(r=":");let i=!1===n.alignDelimiters?1:Math.max(1,o[p]-t.length-r.length),a=t+"-".repeat(i)+r;!1!==n.alignDelimiters&&((i=t.length+i+r.length)>o[p]&&(o[p]=i),m[p]=i),h[p]=a}a.splice(1,0,h),l.splice(1,0,m),d=-1;let f=[];for(;++d<a.length;){let e=a[d],t=l[d];p=-1;let r=[];for(;++p<c;){let i=e[p]||"",a="",l="";if(!1!==n.alignDelimiters){let e=o[p]-(t[p]||0),n=s[p];114===n?a=" ".repeat(e):99===n?e%2?(a=" ".repeat(e/2+.5),l=" ".repeat(e/2-.5)):l=a=" ".repeat(e/2):l=" ".repeat(e)}!1===n.delimiterStart||p||r.push("|"),!1!==n.padding&&(!1!==n.alignDelimiters||""!==i)&&(!1!==n.delimiterStart||p)&&r.push(" "),!1!==n.alignDelimiters&&r.push(a),r.push(i),!1!==n.alignDelimiters&&r.push(l),!1!==n.padding&&r.push(" "),(!1!==n.delimiterEnd||p!==c-1)&&r.push("|")}f.push(!1===n.delimiterEnd?r.join("").replace(/ +$/,""):r.join(""))}return f.join("\n")}(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function o(e,t,n){let r=e.children,i=-1,s=[],l=t.enter("tableRow");for(;++i<r.length;)s[i]=a(r[i],e,t,n);return l(),s}}(i),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:it}}]})}function iL({text:e,className:n=""}){return(0,t.jsx)("div",{className:`markdown-body ${n}`.trim(),children:(0,t.jsx)(rk,{remarkPlugins:[i$],children:e})})}let iF=o("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]);function iD({text:e}){return(0,t.jsxs)("details",{className:"thinking-block",children:[(0,t.jsxs)("summary",{children:[(0,t.jsx)(iF,{size:14,"aria-hidden":"true"}),(0,t.jsx)("span",{children:"Reasoning"})]}),(0,t.jsx)("div",{className:"thinking-content",children:e})]})}let i_=(0,n.memo)(function({step:e,activeLeafMessageId:n,branchDisabled:r,createBranch:i,metrics:s}){let a=e.speaker?.kind==="role",l=e.speaker?.handle?`@${e.speaker.handle}`:e.speaker?.displayName||"Host",o=e.speaker?.modelName,d=e.blocks.filter(e=>"text"===e.kind).map(e=>e.text).join("\n\n");return(0,t.jsxs)("section",{className:"assistant-step","data-message-id":e.sourceMessageId,children:[(0,t.jsxs)("div",{className:a?"assistant-speaker role":"assistant-speaker",children:[(0,t.jsx)("span",{style:e.speaker?.color?{color:e.speaker.color}:void 0,children:(0,t.jsx)(c,{size:13,"aria-hidden":"true"})}),(0,t.jsx)("strong",{children:l}),a&&(0,t.jsx)("small",{children:"Role"}),o&&(0,t.jsx)("small",{className:"assistant-model",children:o})]}),e.blocks.map((e,n)=>"text"===e.kind?(0,t.jsx)(iL,{text:e.text},n):"thinking"===e.kind?(0,t.jsx)(iD,{text:e.text},n):"image"===e.kind?(0,t.jsxs)("div",{className:"image-reference",children:[(0,t.jsx)(eE,{size:15,"aria-hidden":"true"})," Image ",e.width,"×",e.height]},n):(0,t.jsxs)("details",{className:"image-description",children:[(0,t.jsx)("summary",{children:"Image description"}),(0,t.jsx)("div",{children:e.text})]},n)),(0,t.jsx)(eF,{text:d,time:e.createdAt,runMs:s?.runMs,ttftMs:s?.ttftMs,tokensPerSecond:s?.tokensPerSecond,branchMessageId:e.sourceMessageId!==n?e.sourceMessageId:void 0,branchDisabled:r,onBranch:i})]})}),iO=o("circle-pause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]),iW=o("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);function iU({status:e,active:n,waiting:r,reconnecting:i,compacting:s,permissionMode:a}){if(!n&&!e)return null;let l=i?"Reconnecting to run":r?"Waiting for approval":e||(s?"Compacting context":"Running"),o=i?iW:r?iO:n?em:e.toLowerCase().includes("fail")?eg:ex;return(0,t.jsxs)("div",{className:`run-status ${n?"is-active":""} ${r?"is-waiting":""}`,role:"status",children:[(0,t.jsx)(o,{size:14,"aria-hidden":"true",className:n&&!r?"status-spin":""}),(0,t.jsx)("span",{children:l}),n&&a&&(0,t.jsxs)("span",{className:"run-mode",children:[a," · frozen"]})]})}let iq=o("file-pen-line",[["path",{d:"M14.364 13.634a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506l4.013-4.009a1 1 0 0 0-3.004-3.004z",key:"ukzhwg"}],["path",{d:"M14.487 7.858A1 1 0 0 1 14 7V2",key:"1klhew"}],["path",{d:"M20 19.645V20a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l2.516 2.516",key:"rxaxab"}],["path",{d:"M8 18h1",key:"13wk12"}]]),iB=o("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),iH=o("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),iV=o("earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),iK=o("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),iJ=o("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),iG=o("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),iZ=o("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]),iQ=o("file-code-corner",[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]]),iY=o("table-2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]);function iX({sessionId:e,artifact:r}){let[i,s]=(0,n.useState)(""),[a,l]=(0,n.useState)(null),[o,c]=(0,n.useState)(!1);return((0,n.useEffect)(()=>{let t=new AbortController;return(0,eb.apiFetch)(el(e,r.artifactId,i||void 0),{signal:t.signal}).then(e=>{c(!1),l(e)}).catch(e=>{"AbortError"!==e.name&&c(!0)}),()=>t.abort()},[r.artifactId,e,i]),a||o)?o||!a?(0,t.jsx)("div",{className:"artifact-preview-state is-error",role:"alert",children:"Preview unavailable"}):(0,t.jsxs)("div",{className:"artifact-table-preview",children:[(a.sheets?.length??0)>1&&(0,t.jsxs)("label",{className:"artifact-sheet-control",children:[(0,t.jsx)("span",{children:"Worksheet"}),(0,t.jsx)("select",{value:i||a.sheet||"",onChange:e=>s(e.target.value),children:a.sheets?.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]}),(0,t.jsx)("div",{className:"artifact-table-scroll",tabIndex:0,"aria-label":`Scrollable preview of ${r.name}`,children:(0,t.jsxs)("table",{children:[(0,t.jsxs)("caption",{className:"sr-only",children:["Preview of ",r.name]}),(0,t.jsx)("thead",{children:(0,t.jsx)("tr",{children:a.columns.map((e,n)=>(0,t.jsx)("th",{scope:"col",title:e,children:e||`Column ${n+1}`},`${e}-${n}`))})}),(0,t.jsx)("tbody",{children:a.rows.map((e,n)=>(0,t.jsx)("tr",{children:a.columns.map((n,r)=>(0,t.jsx)("td",{title:e[r]??"",children:e[r]??""},r))},n))})]})}),(a.truncatedRows||a.truncatedColumns)&&(0,t.jsxs)("div",{className:"artifact-preview-limit",children:["Preview limited to ",a.rowLimit," rows x ",a.columnLimit," columns"]})]}):(0,t.jsx)("div",{className:"artifact-preview-state",role:"status","aria-live":"polite",children:"Loading preview..."})}function i0({sessionId:e,artifact:n}){var r,i,s;let a,l=el(e,n.artifactId),o=(r=n.artifactId,`${ea(e,r)}/download`);return(0,t.jsxs)("section",{className:"artifact-result","aria-label":`Artifact ${n.name}`,"data-artifact-kind":n.kind,"data-artifact-id":n.artifactId,children:[(0,t.jsxs)("header",{className:"artifact-result-header",children:[(0,t.jsx)("span",{className:"artifact-result-icon",children:(s=n.kind,a={size:15,"aria-hidden":!0},"image"===s?(0,t.jsx)(eE,{...a}):"table"===s?(0,t.jsx)(iY,{...a}):"static_html"===s?(0,t.jsx)(iQ,{...a}):(0,t.jsx)(iB,{...a}))}),(0,t.jsx)("span",{className:"artifact-result-name",title:n.name,children:n.name}),(0,t.jsxs)("span",{className:"artifact-result-meta",children:[n.mimeType," · ",(i=n.sizeBytes)<1024?`${i} B`:i<1048576?`${(i/1024).toFixed(+(i<10240))} KB`:`${(i/1048576).toFixed(+(i<0xa00000))} MB`]}),(0,t.jsx)("a",{className:"artifact-download",href:o,download:n.name,"aria-label":`Download ${n.name}`,title:`Download ${n.name}`,children:(0,t.jsx)(iZ,{size:15,"aria-hidden":"true"})})]}),"image"===n.kind&&(0,t.jsx)(i1,{artifact:n,previewURL:l}),"table"===n.kind&&(0,t.jsx)(iX,{sessionId:e,artifact:n}),"static_html"===n.kind&&(0,t.jsx)("iframe",{className:"artifact-html-preview",src:l,title:`${n.name} preview`,sandbox:"",referrerPolicy:"no-referrer",loading:"lazy"}),"text"===n.kind&&(0,t.jsx)(i2,{sessionId:e,artifact:n})]})}function i1({artifact:e,previewURL:r}){let[i,s]=(0,n.useState)(!1);return i?(0,t.jsx)("div",{className:"artifact-preview-state is-error",role:"alert",children:"Preview unavailable"}):(0,t.jsxs)("figure",{className:"artifact-image-preview",children:[(0,t.jsx)("img",{src:r,alt:e.name,width:e.width,height:e.height,loading:"lazy",onError:()=>s(!0)}),(e.width||e.height)&&(0,t.jsxs)("figcaption",{children:[e.width," x ",e.height]})]})}function i2({sessionId:e,artifact:r}){let[i,s]=(0,n.useState)(null),[a,l]=(0,n.useState)(!1);return((0,n.useEffect)(()=>{let t=new AbortController;return(0,eb.apiFetch)(el(e,r.artifactId),{signal:t.signal}).then(s).catch(e=>{"AbortError"!==e.name&&l(!0)}),()=>t.abort()},[r.artifactId,e]),a)?(0,t.jsx)("div",{className:"artifact-preview-state is-error",role:"alert",children:"Preview unavailable"}):i?(0,t.jsxs)("div",{className:"artifact-text-preview",children:[(0,t.jsx)("pre",{children:i.text}),i.truncated&&(0,t.jsx)("span",{children:"Preview truncated"})]}):(0,t.jsx)("div",{className:"artifact-preview-state",role:"status","aria-live":"polite",children:"Loading preview..."})}let i4=o("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]),i5=o("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),i6=o("message-square-more",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 11h.01",key:"z322tv"}],["path",{d:"M16 11h.01",key:"xkw8gn"}],["path",{d:"M8 11h.01",key:"1dfujw"}]]),i3=new Set(["read","ls","list","grep","search","find","search_compacted_history","todo"]),i9=new Set(["write","edit","publish_artifact"]),i8=new Set(["bash","exec"]),i7=new Set(["http","http_request","fetch","web_search","web_fetch"]),se=/api[_-]?key|token|secret|password|credential|authorization|cookie/i;function st(e){let t=e.toLowerCase();return i3.has(t)?"read_only":i9.has(t)?"local_write":i8.has(t)?"shell":i7.has(t)?"external":"delegate_tasks"===t||"delegate_roles"===t?"delegation":"sensitive"}function sn(e,t=0){return t>8?"[nested value omitted]":Array.isArray(e)?e.slice(0,50).map(e=>sn(e,t+1)):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).slice(0,80).map(([e,n])=>[e,se.test(e)?"[redacted]":sn(n,t+1)])):e}function sr(e,t=4e3){return e.length<=t?e:`${e.slice(0,t)}
|
|
2
|
-
[${e.length-t} characters omitted]`}function si(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}function ss(e){return"string"==typeof e?e:""}function sa(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function sl(e){return"string"==typeof e?`${e.length.toLocaleString()} characters`:void 0}function so(e,t){let n=e.replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function sc({child:e,reused:n=!1,activity:r,onRetry:i,onContinue:s}){var a,l,o;let d,u,p=function(e){if("blocked"===e.itemStatus)return"blocked";switch(e.runStatus){case"queued":return"queued";case"running":return"running";case"waiting_for_approval":return"approval";case"succeeded":return"completed";case"failed":return"failed";case"interrupted":return"interrupted";case"cancelled":return"cancelled"}return"succeeded"===e.itemStatus?"completed":"failed"===e.itemStatus||"not_authorized"===e.itemStatus?"failed":"cancelled"===e.itemStatus?"cancelled":"queued"}(e),h=e.result?.summary||e.errorMessage||"",m=void 0!==i&&("failed"===p||"interrupted"===p||"cancelled"===p),f=void 0!==s?(d=(a=e).result,d?.status==="needs_input"?"input":d?.status==="blocked"||"succeeded"===a.itemStatus?"follow_up":null):null,g=("running"===p||"queued"===p)&&r?r:void 0;return(0,t.jsxs)("div",{className:"child-run-row","data-child-run-id":e.childRunId,"data-state":p,role:"listitem",children:[(0,t.jsx)("span",{className:"child-run-icon",children:(0,t.jsx)(c,{size:14,"aria-hidden":"true"})}),(0,t.jsxs)("span",{className:"child-run-identity",children:[(0,t.jsx)("strong",{children:e.name}),(0,t.jsxs)("span",{children:["@",e.roleHandle]}),n&&(0,t.jsx)("span",{className:"child-run-reused",children:"Reused"})]}),(0,t.jsxs)("span",{className:"child-run-actions",children:[m&&(0,t.jsx)("button",{type:"button",className:"child-run-retry","aria-label":`Retry ${e.name}`,title:"Retry this delegated task",onClick:()=>i(e.itemId),children:(0,t.jsx)(I,{size:13,"aria-hidden":"true"})}),f&&s&&(0,t.jsx)("button",{type:"button",className:"child-run-retry","aria-label":`${"input"===f?"Reply":"Follow up"} ${e.name}`,title:"input"===f?"Reply to this delegated task":"Follow up privately",onClick:()=>s(e.itemId,f),children:(0,t.jsx)(i6,{size:13,"aria-hidden":"true"})}),(0,t.jsxs)("span",{className:"child-run-status",children:[(u={size:13,"aria-hidden":!0},"completed"===(l=p)?(0,t.jsx)(ex,{...u}):"failed"===l?(0,t.jsx)(eg,{...u}):"blocked"===l||"interrupted"===l?(0,t.jsx)(iO,{...u}):"cancelled"===l?(0,t.jsx)(iG,{...u}):(0,t.jsx)(ey,{...u})),"queued"===(o=p)?"Queued":"running"===o?"Running":"approval"===o?"Approval":"completed"===o?"Completed":"blocked"===o?"Blocked":"interrupted"===o?"Interrupted":"cancelled"===o?"Cancelled":"Failed",g&&(0,t.jsx)("span",{className:"child-run-activity",title:g,children:g}),sd(e)&&("failed"===p||"blocked"===p)&&(0,t.jsx)("span",{className:"child-run-error-code",children:sd(e)})]})]}),h&&(0,t.jsxs)("details",{className:"child-run-result",children:[(0,t.jsx)("summary",{children:e.result?"Result":"Failure"}),(0,t.jsx)("div",{children:sr(h,1200)})]})]})}function sd(e){if("blocked"===e.itemStatus)return"Blocked";switch(e.errorCode){case"delegation_budget_exceeded":return"Budget exceeded";case"delegation_not_authorized":return"Not authorized";case"delegation_dag_invalid":return"Blocked";case"tool_batch_failed":return"Tool failure";case"process_not_allowed":return"Process not allowed";case"permission_mode_sensitive":return"Sensitive action";default:return e.errorCode?e.errorCode:null}}let su=o("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);function sp({itemID:e,itemName:r,kind:i,sourceAttemptID:s,expectedGeneration:a,onDone:l}){let[o,c]=(0,n.useState)(""),[d,u]=(0,n.useState)(!1),[p,h]=(0,n.useState)(null),f=(0,n.useRef)(null);(0,n.useEffect)(()=>{f.current?.focus()},[]);let g="input"===i?"input":"follow-up",x=async()=>{if(!d&&o.trim()){u(!0),h(null);try{await (0,eb.apiFetch)(`/v1/delegation-items/${encodeURIComponent(e)}/${g}`,{method:"POST",body:JSON.stringify({sourceAttemptId:s,expectedGeneration:a,text:o,clientRequestId:crypto.randomUUID()})}),l()}catch(e){h(e.message),l(),c(o)}finally{u(!1)}}};return(0,t.jsxs)("div",{className:"follow-up-dialog",role:"dialog","aria-label":`${"input"===i?"Reply":"Follow up"} ${r}`,children:[(0,t.jsxs)("div",{className:"follow-up-header",children:[(0,t.jsxs)("span",{children:[(0,t.jsx)(i6,{size:14,"aria-hidden":"true"}),"input"===i?"Reply to delegated task":"Private follow-up"]}),(0,t.jsx)("button",{type:"button",className:"follow-up-close","aria-label":"Close",title:"Close",onClick:l,children:(0,t.jsx)(m,{size:14,"aria-hidden":"true"})})]}),(0,t.jsxs)("div",{className:"follow-up-meta",children:[(0,t.jsx)("strong",{children:r}),(0,t.jsxs)("span",{children:["generation ",a," → ",a+1]})]}),(0,t.jsx)("textarea",{ref:f,className:"follow-up-input",rows:3,placeholder:"input"===i?"Answer the question the delegated task asked…":"Additional private instruction…",value:o,onChange:e=>c(e.target.value)}),p&&(0,t.jsxs)("div",{className:"follow-up-error",role:"status",children:["Refreshed: ",p]}),(0,t.jsx)("div",{className:"follow-up-actions",children:(0,t.jsxs)("button",{type:"button",className:"follow-up-submit",disabled:d||!o.trim(),onClick:x,children:[(0,t.jsx)(su,{size:13,"aria-hidden":"true"})," ","input"===i?"Send reply":"Follow up"]})})]})}let sh=o("rotate-ccw-clock",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);function sm(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function sf({inspection:e}){let n=e.generations??[];if(0===n.length)return null;let r=e.currentGeneration??0;return(0,t.jsxs)("details",{className:"generation-history",children:[(0,t.jsxs)("summary",{children:[(0,t.jsx)(sh,{size:12,"aria-hidden":"true"}),(0,t.jsxs)("span",{children:["Generations (",n.length,")"]})]}),(0,t.jsx)("div",{className:"generation-history-body",children:n.map(e=>(0,t.jsxs)("div",{className:"generation-row","data-generation":e.generation,children:[(0,t.jsx)("strong",{children:e.generation===r?`Generation ${e.generation} (current)`:`Generation ${e.generation}`}),(0,t.jsxs)("span",{children:[e.kind," · ",e.retrySelection?.length??0," selected"," · ",e.reusedAttempts?.length??0," reused"]}),(0,t.jsx)("span",{className:"generation-status-tag","data-status":e.status,children:e.status}),(0,t.jsxs)("details",{className:"generation-detail",children:[(0,t.jsx)("summary",{children:"Details"}),(0,t.jsxs)("ul",{children:[(0,t.jsxs)("li",{children:["Created: ",(0,t.jsx)("time",{children:sm(e.createdAt)})]}),e.completedAt&&(0,t.jsxs)("li",{children:["Completed: ",(0,t.jsx)("time",{children:sm(e.completedAt)})]}),e.retrySelection?.length>0&&(0,t.jsxs)("li",{children:["Retried items: ",e.retrySelection.join(", ")]}),e.reusedAttempts?.map(e=>(0,t.jsxs)("li",{children:["Reused ",e.itemId," · attempt ",e.generation,e.resultDigest?` \xb7 ${e.resultDigest.slice(0,12)}…`:""]},e.attemptId))]})]})]},e.id))})]})}let sg=null,sx=(0,n.createContext)(null);function sy({children:e}){let[r,i]=(0,n.useState)(new Map);(0,n.useEffect)(()=>(sg=e=>{i(t=>{let n=new Map(t),r=new Map(n.get(e.delegationGroupId)??[]);return r.set(e.taskName,e.activity),n.set(e.delegationGroupId,r),n})},()=>void(sg=null)),[]);let s=(0,n.useMemo)(()=>({progress:r}),[r]);return(0,t.jsx)(sx.Provider,{value:s,children:e})}let sv=new Map;function sb({parentRunId:e,toolCallId:r}){let[i,s]=(0,n.useState)(null),[a,l]=(0,n.useState)({}),[o,c]=(0,n.useState)(null),[d,u]=(0,n.useState)(!0),[p,h]=(0,n.useState)(0),[m,f]=(0,n.useState)(!0),[g,x]=(0,n.useState)(null),y=function(){let e=(0,n.useContext)(sx);if(!e)throw Error("useChildProgress must be used inside ChildProgressProvider");return e.progress}(),[v,b]=(0,n.useState)(null);(0,n.useEffect)(()=>{let t,n=new AbortController,i=0,a=async()=>{try{let l=await (0,eb.apiFetch)(`/v1/runs/${encodeURIComponent(e)}/children`,{signal:n.signal});if(n.signal.aborted)return;s(l),c(null);let o=l.groups.filter(e=>e.parentToolCallId===r),d=o.some(e=>{var t;return t=e,"settled"!==t.status&&"cancelled"!==t.status||t.children.some(e=>e.runStatus?!sw(e.runStatus):"pending"===e.itemStatus||"running"===e.itemStatus)});0===o.length?i+=1:i=0;let p=d||0===o.length&&i<20;u(0===o.length&&p),p&&(t=window.setTimeout(a,1200))}catch(e){if(n.signal.aborted)return;c(e.message),u(!1)}};return a(),()=>{n.abort(),void 0!==t&&window.clearTimeout(t)}},[e,p,r]);let j=(0,n.useMemo)(()=>i?.groups.filter(e=>e.parentToolCallId===r)??[],[i,r]),k=(0,n.useMemo)(()=>j.map(e=>e.id).join(","),[j]);(0,n.useEffect)(()=>{let e=new AbortController;for(let t of k.split(",").filter(Boolean))(0,eb.apiFetch)(`/v1/delegations/${encodeURIComponent(t)}`,{signal:e.signal}).then(n=>{e.signal.aborted||l(e=>({...e,[t]:n}))}).catch(()=>{});return()=>e.abort()},[k,p]);let w=j.flatMap(e=>e.children),S=w.filter(e=>e.runStatus&&!sw(e.runStatus)).length,C=(0,n.useCallback)(async(e,t)=>{if(g)return;let n=a[e.id],r=n?.currentGeneration??0;x(t);try{await (0,eb.apiFetch)(`/v1/delegations/${encodeURIComponent(e.id)}/retry`,{method:"POST",body:JSON.stringify({expectedGeneration:r,itemIds:[t],clientRequestId:crypto.randomUUID()})}),h(e=>e+1)}catch(e){c(e.message),h(e=>e+1)}finally{x(null)}},[g,a]),N=(0,n.useCallback)(async e=>{if(!g&&window.confirm("Cancel all active tasks in this delegation?")){x(`${e.id}:cancel`);try{await (0,eb.apiFetch)(`/v1/delegations/${encodeURIComponent(e.id)}/cancel`,{method:"POST"}),c(null),h(e=>e+1)}catch(e){c(e.message)}finally{x(null)}}},[g]),I=(0,n.useCallback)(async(e,t)=>{if(!g){x(e+t);try{await (0,eb.apiFetch)(`/v1/delegation-approvals/${encodeURIComponent(e)}/decision`,{method:"POST",body:JSON.stringify({decision:t,clientRequestId:crypto.randomUUID()})}),h(e=>e+1)}catch(e){c(e.message)}finally{x(null)}}},[g]);return(0,t.jsxs)("details",{className:"nested-activity",open:m,onToggle:e=>f(e.currentTarget.open),children:[(0,t.jsxs)("summary",{children:[(0,t.jsxs)("span",{children:[(0,t.jsx)(eN,{size:14,"aria-hidden":"true"})," Delegated roles"]}),(0,t.jsx)("span",{children:w.length?`${w.length} ${S?`\xb7 ${S} active`:"· settled"}`:""})]}),(0,t.jsxs)("div",{className:"nested-activity-body",children:[!i&&!o&&(0,t.jsx)("div",{className:"nested-activity-state",children:"Loading delegated activity…"}),i&&0===j.length&&d&&(0,t.jsx)("div",{className:"nested-activity-state",children:"Preparing delegated runs…"}),i&&0===j.length&&!d&&!o&&(0,t.jsx)("div",{className:"nested-activity-state",children:"No delegated runs were recorded."}),o&&(0,t.jsxs)("div",{className:"nested-activity-error",role:"status",children:[(0,t.jsx)("span",{children:"Delegation activity unavailable"}),(0,t.jsx)("button",{type:"button","aria-label":"Retry delegation activity",title:"Retry",onClick:()=>h(e=>e+1),children:(0,t.jsx)(i5,{size:14,"aria-hidden":"true"})})]}),j.map(e=>(0,t.jsx)(sj,{group:e,inspection:a[e.id],busy:g,progress:y.get(e.id)??sv,onRetry:C,onCancel:N,onDecide:I,onContinue:(e,t,n,r,i)=>b({itemID:e,itemName:t,kind:n,sourceAttemptID:r,expectedGeneration:i})},e.id))]}),v&&(0,t.jsx)(sp,{itemID:v.itemID,itemName:v.itemName,kind:v.kind,sourceAttemptID:v.sourceAttemptID,expectedGeneration:v.expectedGeneration,onDone:()=>{b(null),h(e=>e+1)}})]})}function sj({group:e,inspection:r,busy:i,onRetry:s,onCancel:a,onDecide:l,onContinue:o,progress:c}){let d=(0,n.useMemo)(()=>{let e=new Set;for(let t of r?.generations??[])for(let n of t.reusedAttempts??[])n.childRunId&&e.add(n.childRunId);return e},[r]),u=r?.pendingApproval,p=r?.validActions.includes("cancel")??!1;return(0,t.jsxs)(t.Fragment,{children:[p&&(0,t.jsxs)("div",{className:"delegation-group-actions",children:[(0,t.jsx)("span",{children:"Delegation in progress"}),(0,t.jsxs)("button",{type:"button",className:"child-run-reject",disabled:null!==i,onClick:()=>a(e),children:[(0,t.jsx)(i4,{size:13,"aria-hidden":"true"})," Cancel delegation"]})]}),(0,t.jsx)("div",{className:"child-run-list",role:"list",children:e.children.map(n=>(0,t.jsx)(sc,{child:n,reused:d.has(n.childRunId??""),activity:c.get(n.name),onRetry:t=>s(e,t),onContinue:sk(r,n.itemId)?(e,t)=>{let i=sk(r,e);o(e,n.name,t,i,r?.currentGeneration??0)}:void 0},n.itemId))}),u&&(0,t.jsxs)("div",{className:"delegation-approval-banner",role:"status",children:[(0,t.jsx)("span",{children:"Retry budget increase awaits approval"}),(0,t.jsxs)("span",{className:"banner-actions",children:[(0,t.jsxs)("button",{type:"button",className:"child-run-approve","aria-label":"Approve retry budget",title:"Approve",disabled:null!==i,onClick:()=>l(u.id,"approved"),children:[(0,t.jsx)(U,{size:13,"aria-hidden":"true"})," Approve"]}),(0,t.jsxs)("button",{type:"button",className:"child-run-reject","aria-label":"Reject retry budget",title:"Reject",disabled:null!==i,onClick:()=>l(u.id,"rejected"),children:[(0,t.jsx)(m,{size:13,"aria-hidden":"true"})," Reject"]})]})]}),r&&(0,t.jsx)(sf,{inspection:r})]})}function sk(e,t){if(!e)return"";let n=e.generations.find(t=>t.generation===e.currentGeneration),r=n?.reusedAttempts.find(e=>e.itemId===t);if(r)return r.attemptId;let i=e.items.find(e=>e.itemId===t);return i?.attempts.find(t=>t.generation===e.currentGeneration)?.attemptId??""}function sw(e){return"succeeded"===e||"failed"===e||"cancelled"===e||"interrupted"===e}let sS={read_only:"Read only",local_write:"Local write",shell:"Shell",external:"External",delegation:"Delegation",sensitive:"Sensitive"};function sC({arguments:e}){let r=(0,n.useMemo)(()=>{let t=e&&"object"==typeof e?e:{};return(Array.isArray(t.tasks)?t.tasks:Array.isArray(t.delegations)?t.delegations:[]).map(e=>{let t=e&&"object"==typeof e?e:{},n=String(t.role??t.roleHandle??""),r=Array.isArray(t.depends)?t.depends.map(String).filter(Boolean):[];return{name:String(t.name??""),role:n,depends:r}}).filter(e=>e.name||e.role)},[e]);return 0===r.length?null:(0,t.jsx)("div",{className:"delegation-task-list",role:"list",children:r.map((e,n)=>(0,t.jsxs)("div",{className:"delegation-task",role:"listitem",children:[(0,t.jsx)("span",{className:"delegation-task-name",children:e.name||"(task)"}),e.role&&(0,t.jsxs)("span",{className:"delegation-task-role",children:["@",e.role]}),e.depends.length>0&&(0,t.jsxs)("span",{className:"delegation-task-depends",children:["after ",e.depends.join(", ")]})]},`${e.name}-${n}`))})}function sN({activity:e,sessionId:n}){var r,i,s,a;let l,o=function(e,t){let n=si(sn(t)),r=ss(n.path??n.filePath??n.directory??n.cwd);switch(e.toLowerCase()){case"read":{let e=sa(n.offset),t=sa(n.limit);return{label:"Read file",target:r||"Workspace file",detail:void 0!==e&&void 0!==t?`lines ${e}-${e+t-1}`:void 0}}case"ls":case"list":return{label:"List directory",target:r||"Workspace"};case"grep":case"search":return{label:"Search text",target:ss(n.query??n.pattern)||"Search",detail:r||void 0};case"find":return{label:"Find files",target:ss(n.pattern??n.name)||"Files",detail:r||void 0};case"write":return{label:"Write file",target:r||"Workspace file",detail:sl(n.content)};case"edit":return{label:"Edit file",target:r||"Workspace file",detail:sl(n.newText??n.replacement)};case"publish_artifact":return{label:"Publish artifact",target:ss(n.name)||r||"Workspace file"};case"bash":case"exec":return{label:"Run command",target:so(ss(n.command??n.cmd)||"Shell command",180),detail:r||void 0};case"web_fetch":return{label:"Fetch external page",target:so(ss(n.url)||"External URL",180)};case"http":case"http_request":case"fetch":return{label:"External request",target:so(ss(n.url)||"External service",180)};case"search_compacted_history":return{label:"Search compacted history",target:so(ss(n.query)||"Session history",180)};case"delegate_tasks":case"delegate_roles":{let e=Array.isArray(n.tasks)?n.tasks:Array.isArray(n.delegations)?n.delegations:[],t=e.map(e=>si(e)).map(e=>ss(e.role??e.roleHandle)).filter(Boolean);return{label:"Delegate tasks",target:1===e.length?"1 task":`${e.length} tasks`,detail:t.length?t.map(e=>`@${e}`).join(", "):void 0}}case"todo":{let e=Array.isArray(t&&"object"==typeof t&&"todos"in t?t.todos:void 0)?t.todos:[],n=e.filter(e=>e&&"object"==typeof e&&"completed"===e.status).length;return{label:"Update task list",target:`${n}/${e.length} completed`}}default:if(e.includes("__")){let t=e.indexOf("__"),n=e.slice(0,t);return{label:e.slice(t+2)||e,target:`MCP \xb7 ${n}`}}return{label:e||"Unknown tool",target:"Sensitive tool call"}}}(e.toolName,e.arguments),c=e.arguments?sr(JSON.stringify(sn(e.arguments),null,2),2200):e.argumentsFragment?"Arguments were incomplete.":"No arguments recorded.",d=e.result?sr(e.result.content):"";return(0,t.jsxs)("div",{className:"tool-activity-entry",children:[(0,t.jsxs)("details",{className:"tool-activity","data-risk":e.riskClass,"data-state":e.state,"data-tool-call-id":e.toolCallId,open:(r=e.riskClass,"completed"!==e.state||"read_only"!==r||void 0),children:[(0,t.jsxs)("summary",{children:[(0,t.jsx)("span",{className:"tool-icon",children:function(e){let n={size:15,"aria-hidden":!0};switch(e.toLowerCase()){case"read":return(0,t.jsx)(iB,{...n});case"ls":case"list":return(0,t.jsx)(iH,{...n});case"grep":case"search":case"find":case"search_compacted_history":return(0,t.jsx)(u,{...n});case"write":case"edit":case"publish_artifact":return(0,t.jsx)(iq,{...n});case"bash":case"exec":return(0,t.jsx)(iJ,{...n});case"delegate_tasks":case"delegate_roles":return(0,t.jsx)(eN,{...n});case"http":case"http_request":case"fetch":case"web_search":return(0,t.jsx)(iV,{...n});default:return(0,t.jsx)(iK,{...n})}}(e.toolName)}),(0,t.jsxs)("span",{className:"tool-summary",children:[(0,t.jsx)("strong",{children:o.label}),(0,t.jsx)("span",{className:"tool-target",children:o.target}),o.detail&&(0,t.jsx)("span",{className:"tool-detail",children:o.detail})]}),(0,t.jsx)("span",{className:"tool-risk",children:sS[e.riskClass]}),(0,t.jsxs)("span",{className:"tool-state",children:[(s=e.state,l={size:14,"aria-hidden":!0},"completed"===s?(0,t.jsx)(ex,{...l}):"pending"===s||"running"===s?(0,t.jsx)(ey,{...l}):"rejected"===s?(0,t.jsx)(iG,{...l}):(0,t.jsx)(eg,{...l})),"completed"===(a=e.state)?"Done":"pending"===a?"Pending":"running"===a?"Running":"rejected"===a?"Rejected":"interrupted"===a?"Interrupted":"Failed"]})]}),(0,t.jsxs)("div",{className:"tool-activity-details",children:["delegate_tasks"===(i=e.toolName)||"delegate_roles"===i?(0,t.jsx)(sC,{arguments:e.arguments}):(0,t.jsxs)("details",{className:"tool-detail-disclosure",children:[(0,t.jsx)("summary",{children:"Arguments"}),(0,t.jsx)("pre",{children:c})]}),e.result&&(0,t.jsxs)("details",{className:"tool-detail-disclosure",open:"completed"!==e.state||void 0,children:[(0,t.jsx)("summary",{children:e.result.isError?"Error output":"Result"}),(0,t.jsx)("pre",{children:d||"No output"})]})]})]}),("delegate_tasks"===e.toolName||"delegate_roles"===e.toolName)&&e.runId&&(0,t.jsx)(sb,{parentRunId:e.runId,toolCallId:e.toolCallId}),(e.result?.artifacts.length??0)>0&&(0,t.jsx)("div",{className:"tool-artifact-results",children:e.result?.artifacts.map(e=>(0,t.jsx)(i0,{sessionId:n,artifact:e},e.artifactId))})]})}let sI=(0,n.memo)(function({sessionId:e,turn:n,active:r=!1,pendingApproval:i,resolvingApproval:s,decideApproval:a,runStatus:l,activeLeafMessageId:o,branchDisabled:c,createBranch:d}){let u=i?n.steps.find(e=>"tool_batch"===e.kind&&i.items.some(t=>e.activities.some(e=>e.toolCallId===t.toolCallId)))?.id:void 0,p=n.steps.map(e=>e.kind).lastIndexOf("assistant");return(0,t.jsxs)("article",{className:`conversation-turn ${r?"is-active":""}`,"data-turn-id":n.id,children:[n.user&&(0,t.jsxs)("div",{className:"user-row","data-message-id":n.user.sourceMessageId??n.user.id,children:[(0,t.jsx)("div",{className:"user-message",children:(0,t.jsx)(iL,{text:n.user.text})}),(0,t.jsx)(eF,{text:n.user.text,time:n.user.createdAt,branchMessageId:n.user.sourceMessageId!==o?n.user.sourceMessageId:void 0,branchDisabled:c,onBranch:d})]}),(0,t.jsxs)("div",{className:"agent-flow",children:[n.steps.map((r,l)=>{if("assistant"===r.kind)return(0,t.jsx)(i_,{step:r,metrics:l===p?n.metrics:void 0,activeLeafMessageId:o,branchDisabled:c,createBranch:d},r.id);if("steer"===r.kind)return(0,t.jsxs)("div",{className:"steer-message",children:[(0,t.jsx)(eS,{size:14,"aria-hidden":"true"}),(0,t.jsx)("span",{children:r.text})]},r.id);let h=r.id===u;return(0,t.jsx)(sT,{sessionId:e,batch:r,approval:h?i:null,resolving:s,decide:a},r.id)}),i&&!u&&(0,t.jsx)(sM,{approval:i,resolving:s,decide:a}),l&&(0,t.jsx)(iU,{...l})]})]})}),sT=(0,n.memo)(function({sessionId:e,batch:n,approval:r,resolving:i,decide:s}){return(0,t.jsxs)("section",{className:"tool-batch","aria-label":`Tool batch with ${n.activities.length} actions`,children:[(0,t.jsxs)("div",{className:"tool-batch-heading",children:[(0,t.jsx)(eC,{size:14,"aria-hidden":"true"}),(0,t.jsx)("span",{children:1===n.activities.length?"Tool activity":`${n.activities.length} tool activities`})]}),(0,t.jsx)("div",{className:"tool-activity-list",children:n.activities.map(n=>(0,t.jsx)(sN,{sessionId:e,activity:n},n.toolCallId))}),r&&s&&(0,t.jsx)(eR,{approval:r,resolving:i??null,decide:s})]})});function sM({approval:e,resolving:n,decide:r}){return r?(0,t.jsxs)("section",{className:"tool-batch pending-tool-batch","aria-label":`Pending tool batch with ${e.items.length} actions`,children:[(0,t.jsxs)("div",{className:"tool-batch-heading",children:[(0,t.jsx)(eC,{size:14,"aria-hidden":"true"}),(0,t.jsx)("span",{children:1===e.items.length?"Pending tool activity":`${e.items.length} pending tool activities`})]}),(0,t.jsx)(eR,{approval:e,resolving:n??null,decide:r})]}):null}function sR({sessionId:e,nodes:n,pendingApproval:r,resolvingApproval:i,decideApproval:s,runStatus:a,activeLeafMessageId:l,branchDisabled:o,createBranch:c}){let d=-1;for(let e=n.length-1;e>=0;e-=1)if("turn"===n[e].kind){d=e;break}return(0,t.jsxs)("div",{className:"conversation-list",children:[n.map((n,u)=>"checkpoint"===n.kind?(0,t.jsx)(sE,{node:n},n.id):(0,t.jsx)(sI,{sessionId:e,turn:n,active:u===d&&!!a?.active,pendingApproval:u===d?r:null,resolvingApproval:i,decideApproval:s,branchDisabled:o,activeLeafMessageId:l,createBranch:c,runStatus:u===d?a:void 0},n.id)),d<0&&r&&(0,t.jsxs)("div",{className:"orphan-active-flow",children:[(0,t.jsx)(sM,{approval:r,resolving:i,decide:s}),a&&(0,t.jsx)(iU,{...a})]})]})}function sE({node:e}){return(0,t.jsxs)("div",{className:"checkpoint-separator","data-checkpoint-id":e.id,children:[(0,t.jsx)("span",{className:"checkpoint-line"}),(0,t.jsxs)("details",{children:[(0,t.jsxs)("summary",{children:[(0,t.jsx)(ew,{size:14,"aria-hidden":"true"})," Context checkpoint",e.reclaimedTokens>0&&(0,t.jsxs)("span",{children:[e.reclaimedTokens.toLocaleString()," tokens reclaimed"]})]}),(0,t.jsx)("div",{children:e.summary})]}),(0,t.jsx)("span",{className:"checkpoint-line"})]})}function sz({status:e,activeRun:r,waiting:i,reconnecting:s,compacting:a,cacheReadTokens:l=0,inputTokens:o=0,outputTokens:c=0}){let[d,u]=(0,n.useState)(null),[p,h]=(0,n.useState)(0);if((0,n.useEffect)(()=>{let e=window.requestAnimationFrame(()=>{if(!r){u(null),h(0);return}let e=Date.now();u(e),h(e)});if(!r)return()=>window.cancelAnimationFrame(e);let t=window.setInterval(()=>h(Date.now()),1e3);return()=>{window.cancelAnimationFrame(e),window.clearInterval(t)}},[r]),!r&&!e)return null;let m=d?Math.max(0,Math.floor((p-d)/1e3)):0;return(0,t.jsx)("div",{className:"streaming-status",role:"status","aria-live":"polite",children:(0,t.jsxs)("span",{children:[a?"Compacting context...":s?"Reconnecting...":i?"Waiting for approval...":e||"Working...",d?` ${function(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);return`${t}m ${String(e%60).padStart(2,"0")}s`}(m)}`:"",l>0?` \xb7 cache ${e$(l)}`:"",o>0||c>0?` \xb7 ↑${e$(o)} ↓${e$(c)}`:""]})})}function sA(){let[e,t]=(0,n.useState)(!1),r=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!e)return;let n=e=>{r.current?.contains(e.target)||t(!1)};return document.addEventListener("pointerdown",n),()=>document.removeEventListener("pointerdown",n)},[e]);let i=(0,n.useCallback)(()=>t(e=>!e),[]);return{open:e,toggle:i,openDropdown:(0,n.useCallback)(()=>t(!0),[]),close:(0,n.useCallback)(()=>t(!1),[]),rootRef:r}}function sP({history:e,run:r,branches:i,composer:s,actions:a,error:l,clearError:o,projects:c,selectedProject:d,hasModel:u,pinnedProjectIds:p,togglePinProject:h,onSwitchProject:f,onNewProject:g,onNewSession:x,onOpenSettings:y}){let v=(0,n.useRef)(null),b=(0,n.useRef)(null),j=(0,n.useRef)(!1),k=(0,n.useRef)(0),w=sA(),S="waiting_for_approval"===r.activeRunStatus||"waiting_delegation_admission"===r.activeRunStatus||!!r.pendingApproval,C="Run connection interrupted"===r.status&&!S,N=(0,n.useCallback)(()=>{0===c.length?g():w.open?w.close():w.openDropdown()},[w,g,c.length]);async function I(){let t=v.current;if(!t)return;let n=t.scrollHeight,r=t.scrollTop;j.current=!0,await e.loadOlder()?requestAnimationFrame(()=>requestAnimationFrame(()=>{t.scrollTop=r+(t.scrollHeight-n),j.current=!1,k.current=e.messages.length})):j.current=!1}return(0,n.useEffect)(()=>{let t=v.current;if(!t||j.current)return;let n=t.scrollHeight-t.scrollTop-t.clientHeight<120;(0===k.current||n)&&b.current?.scrollIntoView({behavior:0===k.current?"auto":"smooth"}),k.current=e.messages.length},[e.messages,r.status]),(0,n.useEffect)(()=>{k.current=0},[e.activeBranchId,e.sessionId]),(0,t.jsxs)("main",{className:"chat-area",children:[l&&(0,t.jsxs)("div",{className:"error-bar",role:"alert",children:[(0,t.jsx)("span",{children:l}),(0,t.jsx)("button",{onClick:o,"aria-label":"Dismiss error",children:(0,t.jsx)(m,{size:15,"aria-hidden":"true"})})]}),r.recovery&&(0,t.jsxs)("div",{className:`recovery-bar ${r.recovery.retryable?"is-retryable":"is-blocked"}`,"data-testid":"run-recovery",children:[(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:"interrupted"===r.recovery.run.status?"Run interrupted":"Run failed"}),r.recovery.retryable?`Attempt ${r.recovery.run.attempt} can be retried safely.`:function(e){switch(e){case"side_effect_boundary":return"Retry is unavailable because tools may have changed external state.";case"projected_output":return"Retry is unavailable because this attempt already committed output.";case"active_run":return"Another run is active.";default:return"This attempt is no longer on the active branch."}}(r.recovery.blockedReason)]}),r.recovery.retryable&&(0,t.jsx)("button",{type:"button",onClick:r.retryRun,disabled:r.retrying||!!r.activeRun,children:r.retrying?"Retrying…":"Retry"})]}),(0,t.jsx)("div",{className:"messages",ref:v,"data-testid":"chat-messages",children:(0,t.jsxs)("div",{className:"conversation-viewport",children:[e.sessionId&&e.hasMore&&(0,t.jsx)("div",{className:"history-control",children:(0,t.jsx)("button",{type:"button",onClick:I,disabled:e.loadingOlder,children:e.loadingOlder?"Loading earlier messages…":"Load earlier messages"})}),e.loading&&(0,t.jsx)("div",{className:"history-state",children:"Loading conversation…"}),e.error&&(0,t.jsxs)("div",{className:"history-state history-state-error",children:["Conversation history unavailable: ",e.error]}),!e.loading&&e.sessionId&&0===e.messages.length&&!e.error&&!r.pendingApproval&&(0,t.jsxs)("div",{className:"history-empty",children:[(0,t.jsx)("strong",{children:"New conversation"}),(0,t.jsx)("span",{children:"Start with a question, file, or analysis task."})]}),!e.sessionId&&(0,t.jsx)(ep,{selectedProject:d,hasModel:u,onNewSession:x,onOpenSettings:y}),(0,t.jsx)(sR,{sessionId:e.sessionId??"",nodes:e.messages,pendingApproval:r.pendingApproval,resolvingApproval:r.resolvingApproval,decideApproval:r.decideApproval,activeLeafMessageId:e.activeLeafMessageId,branchDisabled:!!r.activeRun||i.changing,createBranch:i.createBranch,runStatus:r.activeRun||r.status?{status:r.status,active:!!r.activeRun,waiting:S,reconnecting:C,compacting:r.compacting,permissionMode:s.displayedPermissionMode}:void 0}),(0,t.jsx)(sz,{status:r.activeRun?r.status:"",activeRun:!!r.activeRun,waiting:S,reconnecting:C,compacting:r.compacting,cacheReadTokens:r.usage?.cacheReadTokens??0,inputTokens:(r.usage?.uncachedInputTokens??0)+(r.usage?.cacheReadTokens??0)+(r.usage?.cacheWriteTokens??0),outputTokens:r.usage?.outputTokens??0}),(0,t.jsx)("div",{ref:b})]})}),(0,t.jsx)(ej,{sessionId:e.sessionId??void 0}),s.compaction.open&&(0,t.jsx)(ek,{value:s.compaction.instructions,onChange:s.compaction.setInstructions,busy:s.compaction.busy,onConfirm:s.compaction.confirm,onCancel:s.compaction.cancel}),!e.sessionId&&(0,t.jsx)("div",{className:"hero-workspace-row",children:(0,t.jsx)(eh,{projects:c,selectedProject:d,pinnedProjectIds:p,togglePinProject:h,onRequestProject:N,onSwitchProject:f,projectSelector:w})}),(0,t.jsx)(eu,{selectedSession:e.sessionId,activeLeafMessageId:e.activeLeafMessageId,input:s.input,setInput:s.setInput,activeRun:!!r.activeRun,compacting:r.compacting,hasPendingImage:!!s.pendingImage,reconnecting:C,onRequestProject:N,permissionMode:s.displayedPermissionMode,permissionReady:s.permissionReady,setPermissionMode:s.setPermissionMode,models:s.models,selectedModelId:s.selectedModelId,setSelectedModelId:s.setSelectedModelId,thinkingEffort:s.thinkingEffort,setThinkingEffort:s.setThinkingEffort,roles:s.roles,selectedRoleId:s.selectedRoleId,setSelectedRoleId:s.setSelectedRoleId,textAttachments:s.textAttachments,removeTextAttachment:s.removeTextAttachment,pendingImage:s.pendingImage,clearPendingImage:s.clearPendingImage,attachFiles:s.attachFiles,uploadImage:s.uploadImage,submit:a.submit,steer:a.steer,followUp:a.followUp,cancel:r.cancel,compactSession:s.compactSession,pendingFollowUps:r.pendingFollowUps,promptTemplates:s.promptPanel.templates,showPromptPanel:s.promptPanel.show,onPromptSelect:s.promptPanel.onSelect,panelRoles:s.promptPanel.roles,panelFlows:s.promptPanel.flows,onRoleSelect:s.promptPanel.onRoleSelect,onFlowSelect:s.promptPanel.onFlowSelect,onPromptPanelClose:s.promptPanel.onClose,expanding:s.promptPanel.expanding,expandDiag:s.promptPanel.expandDiag,contextUsage:r.contextUsage,stats:r.stats})]})}let s$=o("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]),sL=o("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);function sF({item:e,onNavigate:n,onDismiss:r}){let i,s=!e.requiresAction;return(0,t.jsxs)("div",{className:"attention-row",role:"listitem","data-kind":e.kind,"data-attention-id":e.id,children:[(0,t.jsx)("span",{className:"attention-icon",children:(i={size:13,"aria-hidden":!0},"needs_input"===e.kind?(0,t.jsx)(i6,{...i}):"approval_required"===e.kind?(0,t.jsx)(sL,{...i}):(e.kind,(0,t.jsx)(eg,{...i})))}),(0,t.jsxs)("button",{type:"button",className:"attention-main",onClick:()=>n(e),children:[(0,t.jsx)("strong",{children:function(e){let t=e.display;switch(e.kind){case"approval_required":return t?.kind==="retry_budget"?"Retry budget increase awaits approval":"Approval required";case"needs_input":return"Delegated task needs your input";case"delegation_completed":return"Background delegation completed";case"delegation_failed":return"Background delegation failed"}return"Attention"}(e)}),(0,t.jsx)("span",{children:e.display?.summary??e.sessionId})]}),s?(0,t.jsx)("button",{type:"button",className:"attention-dismiss","aria-label":"Dismiss",title:"Dismiss",onClick:()=>r(e),children:(0,t.jsx)(m,{size:13,"aria-hidden":"true"})}):(0,t.jsx)("span",{className:"attention-action-tag",children:e.action?.kind??"action"})]})}function sD({projectId:e,onNavigate:r}){let{items:i,pendingCount:s,refresh:a}=function(e){let[t,r]=(0,n.useState)([]),[i,s]=(0,n.useState)(0);(0,n.useEffect)(()=>{let t;if(!e)return;let n=new AbortController,i=async()=>{try{let t=await (0,eb.apiFetch)(`/v1/attention?projectId=${encodeURIComponent(e)}&status=pending&limit=50`,{signal:n.signal});n.signal.aborted||r(t.items??[])}catch{}finally{n.signal.aborted||(t=window.setTimeout(i,5e3))}};return i(),()=>{n.abort(),void 0!==t&&window.clearTimeout(t)}},[e,i]);let a=(0,n.useMemo)(()=>t.filter(e=>"pending"===e.status).length,[t]);return{items:t,pendingCount:a,refresh:()=>s(e=>e+1)}}(e),[l,o]=(0,n.useState)(!1),c=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!l)return;let e=e=>{c.current?.contains(e.target)||o(!1)},t=e=>{"Escape"===e.key&&o(!1)};return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)}},[l]);let d=async e=>{try{await (0,eb.apiFetch)(`/v1/attention/${encodeURIComponent(e.id)}/dismiss`,{method:"POST",body:JSON.stringify({clientRequestId:crypto.randomUUID()})}),a()}catch{a()}},u=[...i].sort((e,t)=>!!t.requiresAction-!!e.requiresAction);return(0,t.jsxs)("div",{className:"attention-panel",ref:c,children:[(0,t.jsxs)("button",{type:"button",className:"attention-bell","aria-label":`Attention (${s})`,title:"Attention",onClick:()=>o(e=>!e),children:[(0,t.jsx)(s$,{size:15,"aria-hidden":"true"}),s>0&&(0,t.jsx)("span",{className:"attention-badge",children:s>99?"99+":s})]}),l&&(0,t.jsxs)("div",{className:"attention-popover",role:"dialog","aria-label":"Attention",children:[(0,t.jsxs)("div",{className:"attention-popover-header",children:[(0,t.jsx)("strong",{children:"Attention"}),(0,t.jsxs)("span",{children:[s," pending"]})]}),(0,t.jsxs)("div",{className:"attention-list",role:"list",children:[0===u.length&&(0,t.jsx)("div",{className:"attention-empty",children:"Nothing needs attention."}),u.map(e=>(0,t.jsx)(sF,{item:e,onNavigate:e=>{o(!1),r(e)},onDismiss:d},e.id))]})]})]})}let s_=o("git-branch",[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]]);function sO({branches:e,activeBranchId:r,loading:i,changing:s,disabled:a,activate:l}){let[o,c]=(0,n.useState)(!1),d=(0,n.useRef)(null),u=e.find(e=>e.id===r);return(0,n.useEffect)(()=>{if(!o)return;let e=e=>{d.current?.contains(e.target)||c(!1)};return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e)},[o]),(0,t.jsxs)("div",{className:"branch-control",ref:d,children:[(0,t.jsxs)("button",{type:"button",className:"branch-trigger","aria-label":"Choose conversation branch",title:"Choose conversation branch","aria-haspopup":"menu","aria-expanded":o,disabled:a||i||s,onClick:()=>c(e=>!e),children:[(0,t.jsx)(s_,{size:15,"aria-hidden":"true"}),(0,t.jsx)("span",{children:u?.label??(i?"Loading":"Main")}),e.length>1&&(0,t.jsx)("small",{children:e.length})]}),o&&(0,t.jsx)("div",{className:"branch-menu",role:"menu","aria-label":"Conversation branches",children:e.map(e=>(0,t.jsxs)("button",{type:"button",role:"menuitemradio","aria-checked":e.id===r,onClick:()=>{c(!1),l(e.id)},children:[(0,t.jsx)(s_,{size:14,"aria-hidden":"true"}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:e.label}),(0,t.jsxs)("small",{children:[e.messageCount," messages"]})]}),e.id===r&&(0,t.jsx)(U,{size:14,"aria-hidden":"true"})]},e.id))})]})}let sW=o("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),sU=o("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),sq=new Set;function sB(){let e=window.localStorage.getItem("ennote-theme");return"light"===e||"dark"===e?e:"system"}function sH(e=sB()){return"dark"===e?"dark":"light"===e?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function sV(){let e=sB();return`${e}:${sH(e)}`}function sK(e){sq.add(e);let t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>{"system"===sB()&&(sJ(sH("system")),sq.forEach(e=>e()))},r=e=>{"ennote-theme"===e.key&&(sJ(sH()),sq.forEach(e=>e()))};return t.addEventListener("change",n),window.addEventListener("storage",r),()=>{sq.delete(e),t.removeEventListener("change",n),window.removeEventListener("storage",r)}}function sJ(e){document.documentElement.classList.toggle("dark","dark"===e),document.documentElement.dataset.theme=e}function sG(e,t){let n=()=>{"system"===e?window.localStorage.removeItem("ennote-theme"):window.localStorage.setItem("ennote-theme",e),sJ(sH(e)),sq.forEach(e=>e())},r=window.matchMedia("(prefers-reduced-motion: reduce)").matches;if("function"!=typeof document.startViewTransition||r)return void n();let i=t?.x??window.innerWidth/2,s=t?.y??window.innerHeight/2,a=Math.hypot(Math.max(i,window.innerWidth-i),Math.max(s,window.innerHeight-s));document.startViewTransition(n).ready.then(()=>document.documentElement.animate({clipPath:[`circle(0 at ${i}px ${s}px)`,`circle(${a}px at ${i}px ${s}px)`]},{duration:420,easing:"cubic-bezier(0.22, 0.61, 0.36, 1)",pseudoElement:"::view-transition-new(root)"})).catch(()=>void 0)}function sZ(){let[e,t]=(0,n.useSyncExternalStore)(sK,sV,()=>"system:light").split(":"),r=(0,n.useCallback)((e,t)=>sG(e,t),[]),i=(0,n.useCallback)(e=>sG("dark"===t?"light":"dark",e),[t]);return{mode:e,theme:t,isDark:"dark"===t,setThemeMode:r,toggleTheme:i}}function sQ(){let{isDark:e,toggleTheme:n}=sZ();return(0,t.jsx)("button",{type:"button",className:"topbar-icon-button",onClick:e=>{let t=e.currentTarget.getBoundingClientRect();n({x:t.left+t.width/2,y:t.top+t.height/2})},title:e?"Switch to light mode":"Switch to dark mode","aria-label":e?"Switch to light mode":"Switch to dark mode","aria-pressed":e,children:e?(0,t.jsx)(sU,{size:15,"aria-hidden":"true"}):(0,t.jsx)(sW,{size:15,"aria-hidden":"true"})})}function sY(e){let{sidebarOpen:n,onToggleSidebar:r,navigationTriggerRef:i,session:s,title:a,projectName:l,projectPath:o,branch:c,rightPanelOpen:d,onToggleRightPanel:u,attention:p}=e,{title:h,editing:m,draft:f,setDraft:g,startEdit:x,save:y,keyDown:v,inputRef:b}=a;return(0,t.jsxs)("div",{className:"app-topbar",children:[(0,t.jsx)("button",{ref:i,className:"topbar-sidebar-toggle",onClick:r,title:n?"Hide sidebar":"Show sidebar","aria-label":"Open navigation","aria-expanded":n,"aria-controls":"workspace-navigation",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:7,color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"color 0.12s, background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="var(--bg-panel)"},children:n?(0,t.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,t.jsx)("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]}):(0,t.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,t.jsx)("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),(0,t.jsx)("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),(0,t.jsx)("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})}),(0,t.jsxs)("div",{className:"topbar-title-area",style:{display:"flex",alignItems:"center",gap:7,minWidth:0,flex:1},children:[(0,t.jsx)("div",{style:{minWidth:0,display:"flex",alignItems:"center",gap:6},children:m&&s?(0,t.jsx)("input",{ref:b,value:f,onChange:e=>g(e.target.value),onKeyDown:v,onBlur:()=>void y(),style:{width:"min(360px, 34vw)",height:28,boxSizing:"border-box",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text)",padding:"0 8px",fontSize:13,fontWeight:500,outline:"none"}}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"topbar-session-title",title:h,style:{minWidth:0,maxWidth:"min(420px, 36vw)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text)",fontSize:14,fontWeight:600,lineHeight:1.2},children:h}),s&&(0,t.jsx)("button",{type:"button",onClick:x,title:"Rename session",style:{width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",padding:0,border:"none",borderRadius:5,background:"transparent",color:"var(--text-dim)",cursor:"pointer",flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="transparent"},children:(0,t.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M12 20h9"}),(0,t.jsx)("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"})]})})]})}),l&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"topbar-project-crumb",style:{color:"var(--text-dim)",fontSize:12,flexShrink:0},children:"/"}),(0,t.jsx)("span",{className:"topbar-project-crumb",title:o||l,style:{minWidth:0,maxWidth:"min(280px, 24vw)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-muted)",fontSize:12,lineHeight:1.2},children:l})]})]}),s&&(0,t.jsx)(sO,{branches:c.branches,activeBranchId:c.activeBranchId,loading:c.loading,changing:c.changing,disabled:c.disabled,activate:c.onActivate}),(0,t.jsx)(sQ,{}),(0,t.jsx)("button",{type:"button",onClick:u,title:d?"Hide panel":"Show panel",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:d?"var(--bg-selected)":"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:7,color:d?"var(--accent)":"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"color 0.12s, background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color=d?"var(--accent)":"var(--text-muted)",e.currentTarget.style.background=d?"var(--bg-selected)":"var(--bg-panel)"},children:(0,t.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("rect",{x:"14",y:"3",width:"7",height:"18",rx:"1"}),(0,t.jsx)("rect",{x:"3",y:"3",width:"7",height:"18",rx:"1"})]})}),(0,t.jsx)(sD,{projectId:p.projectId,onNavigate:p.onNavigate})]})}let sX=o("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),s0=o("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),s1="var(--text-dim)";function s2({size:e=14,open:n=!1}){return n?(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:[(0,t.jsx)("path",{d:"M1 4.5A1 1 0 0 1 2 3.5H5.5L7 5h7.5v1H1V4.5Z",fill:s1}),(0,t.jsx)("path",{d:"M1 6h14.5L14 13H2L1 6Z",stroke:s1,strokeWidth:"1",fill:s1,fillOpacity:"0.12"})]}):(0,t.jsx)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:(0,t.jsx)("path",{d:"M1 4.5A1 1 0 0 1 2 3.5H5.5L7 5H14a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4.5Z",stroke:s1,strokeWidth:"1",fill:s1,fillOpacity:"0.1"})})}function s4({size:e=14}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:[(0,t.jsx)("path",{d:"M3 2h7l3 3v9H3V2Z",stroke:s1,strokeWidth:"1",fill:s1,fillOpacity:"0.08"}),(0,t.jsx)("path",{d:"M10 2v3h3",stroke:s1,strokeWidth:"1",fill:"none",strokeLinejoin:"round"})]})}function s5({label:e,size:n=14}){return(0,t.jsxs)("svg",{width:n,height:n,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:s1,strokeWidth:"0.9",fill:s1,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:s1,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("text",{x:"7",y:"9.5",textAnchor:"middle",fontSize:"3.4",fontFamily:"var(--font-mono), monospace",fontWeight:"600",fill:s1,children:e})]})}function s6({size:e=14}){return(0,t.jsx)(s5,{label:"PY",size:e})}function s3({size:e=14}){return(0,t.jsx)(s5,{label:"R",size:e})}function s9({size:e=14}){return(0,t.jsx)(s5,{label:"TS",size:e})}function s8({size:e=14}){return(0,t.jsx)(s5,{label:"JS",size:e})}function s7({size:e=14}){return(0,t.jsx)(s5,{label:"{}",size:e})}function ae({size:e=14}){return(0,t.jsx)(s5,{label:"CSS",size:e})}function at({size:e=14}){return(0,t.jsx)(s5,{label:"HTM",size:e})}function an({size:e=14}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:s1,strokeWidth:"0.9",fill:s1,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:s1,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M3.5 9.5V7l1.5 1.5L6.5 7v2.5",stroke:s1,strokeWidth:"0.9",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),(0,t.jsx)("path",{d:"M8 7v2.5M7 9l1 1.5 1-1.5",stroke:s1,strokeWidth:"0.9",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function ar({size:e=14}){return(0,t.jsx)(s5,{label:"YML",size:e})}function ai({size:e=14}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:s1,strokeWidth:"0.9",fill:s1,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:s1,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M4 7.5l2 1.5-2 1.5",stroke:s1,strokeWidth:"0.95",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),(0,t.jsx)("path",{d:"M7.5 10.5h2.5",stroke:s1,strokeWidth:"0.95",strokeLinecap:"round"})]})}function as({size:e=14}){return(0,t.jsx)(s5,{label:"GO",size:e})}function aa({size:e=14}){return(0,t.jsx)(s5,{label:"RS",size:e})}function al({size:e=14}){return(0,t.jsx)(s5,{label:"SQL",size:e})}function ao({size:e=14}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:s1,strokeWidth:"0.9",fill:s1,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:s1,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("rect",{x:"3.5",y:"6.5",width:"2",height:"1.5",rx:"0.3",stroke:s1,strokeWidth:"0.8"}),(0,t.jsx)("rect",{x:"6",y:"6.5",width:"2",height:"1.5",rx:"0.3",stroke:s1,strokeWidth:"0.8"}),(0,t.jsx)("rect",{x:"3.5",y:"8.5",width:"2",height:"1.5",rx:"0.3",stroke:s1,strokeWidth:"0.8"})]})}function ac({size:e=14}){return(0,t.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:s1,strokeWidth:"0.9",fill:s1,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:s1,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("circle",{cx:"7",cy:"8.5",r:"1.3",stroke:s1,strokeWidth:"0.9"}),(0,t.jsx)("path",{d:"M7 6.5v.7M7 10.3v.7M5 8.5h.7M8.3 8.5H9M5.5 6.9l.5.5M8.5 9.6l-.5-.5M5.5 10.1l.5-.5M8.5 7.4l-.5.5",stroke:s1,strokeWidth:"0.8",strokeLinecap:"round"})]})}function ad(e,n=14){let r=e.toLowerCase(),i=r.split(".").pop()??"";return"dockerfile"===r||r.startsWith("dockerfile.")?(0,t.jsx)(ao,{size:n}):"py"===i?(0,t.jsx)(s6,{size:n}):"r"===i||"rds"===i||"qs"===i?(0,t.jsx)(s3,{size:n}):"ts"===i?(0,t.jsx)(s9,{size:n}):"tsx"===i?(0,t.jsx)(s5,{label:"TSX",size:n}):"js"===i||"mjs"===i||"cjs"===i?(0,t.jsx)(s8,{size:n}):"jsx"===i?(0,t.jsx)(s5,{label:"JSX",size:n}):"json"===i||"jsonl"===i?(0,t.jsx)(s7,{size:n}):"css"===i||"less"===i?(0,t.jsx)(ae,{size:n}):"scss"===i?(0,t.jsx)(s5,{label:"SC",size:n}):"html"===i||"htm"===i?(0,t.jsx)(at,{size:n}):"md"===i||"mdx"===i?(0,t.jsx)(an,{size:n}):"yaml"===i||"yml"===i?(0,t.jsx)(ar,{size:n}):"toml"===i?(0,t.jsx)(s5,{label:"TOM",size:n}):"sh"===i||"bash"===i||"zsh"===i||"fish"===i?(0,t.jsx)(ai,{size:n}):"rs"===i?(0,t.jsx)(aa,{size:n}):"go"===i?(0,t.jsx)(as,{size:n}):"sql"===i?(0,t.jsx)(al,{size:n}):"tf"===i||"hcl"===i?(0,t.jsx)(s5,{label:"TF",size:n}):"lock"===i?(0,t.jsx)(s5,{label:"LK",size:n}):i.endsWith("config.ts")||i.endsWith("config.js")||i.endsWith("config.mjs")?(0,t.jsx)(ac,{size:n}):(0,t.jsx)(s4,{size:n})}function au(e,t){let n=new URLSearchParams({path:t});return`/v1/projects/${encodeURIComponent(e)}/files/content?${n.toString()}`}async function ap(e,t="/workspace",n){let r;return(0,eb.apiFetch)((r=new URLSearchParams({path:t}),`/v1/projects/${encodeURIComponent(e)}/files?${r.toString()}`),{signal:n})}async function ah(e,t,n){let r=await (0,eb.apiResponse)(au(e,t),{signal:n});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error?.message??`HTTP ${r.status}`)}return r}function am({projectId:e,displayPath:r,onOpenFile:i,onPreviewFile:s}){let[a,l]=(0,n.useState)([]),[o,c]=(0,n.useState)(!!e),[d,p]=(0,n.useState)(null),[h,m]=(0,n.useState)(""),[f,g]=(0,n.useState)(new Set),[x,y]=(0,n.useState)(new Set),[v,b]=(0,n.useState)(new Map),j=(0,n.useRef)(new Map);(0,n.useEffect)(()=>{if(!e)return;let t=new AbortController,n=j.current;return ap(e,"/workspace",t.signal).then(e=>{l(e),p(null)}).catch(e=>{t.signal.aborted||p(e.message)}).finally(()=>{t.signal.aborted||c(!1)}),()=>{t.abort(),n.forEach(e=>e.abort()),n.clear()}},[e]);let k=(0,n.useCallback)(async t=>{if(!e)return;if(f.has(t))return void g(e=>{let n=new Set(e);return n.delete(t),n});if(g(e=>new Set(e).add(t)),v.has(t))return;let n=new AbortController;j.current.set(t,n),y(e=>new Set(e).add(t));try{let r=await ap(e,t,n.signal);b(e=>new Map(e).set(t,r)),p(null)}catch(e){n.signal.aborted||p(e.message)}finally{j.current.delete(t),y(e=>{let n=new Set(e);return n.delete(t),n})}},[v,f,e]),w=h.trim().toLowerCase(),S=a.filter(e=>!w||e.name.toLowerCase().includes(w)),C=(e,n)=>e.map(e=>{var r;let a=f.has(e.path),l=v.get(e.path),o=x.has(e.path);return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"file-tree-row",style:{paddingLeft:8+16*n},children:[(0,t.jsxs)("button",{type:"button",className:"file-tree-main",onClick:()=>e.isDir?void k(e.path):i(e.path,e.name),title:e.path,"aria-expanded":e.isDir?a:void 0,children:[(0,t.jsx)("span",{className:"file-tree-icon",children:e.isDir?(0,t.jsx)(s2,{size:14,open:a}):ad(e.name,14)}),(0,t.jsx)("span",{className:"file-tree-name",children:e.name}),!e.isDir&&(0,t.jsx)("span",{className:"file-tree-size",children:(r=e.size)<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} K`:`${(r/1048576).toFixed(1)} M`}),o&&(0,t.jsx)("span",{className:"file-tree-loading",children:"..."})]}),!e.isDir&&(0,t.jsx)("button",{type:"button",className:"file-preview-action",onClick:()=>s(e.path,e.name),"aria-label":`Preview ${e.name} in a floating window`,title:"Open floating preview",children:(0,t.jsx)(s0,{size:12,"aria-hidden":"true"})})]}),e.isDir&&a&&l&&C(l,n+1)]},e.path)});return(0,t.jsxs)("div",{className:"file-tree-panel",children:[(0,t.jsxs)("div",{className:"file-tree-header",children:[(0,t.jsx)("div",{className:"file-tree-heading",children:"Files"}),(0,t.jsx)("div",{className:"file-tree-path",title:r??"/workspace",children:e?r??"/workspace":"No project selected"}),(0,t.jsxs)("label",{className:"file-filter",children:[(0,t.jsx)(u,{size:12,"aria-hidden":"true"}),(0,t.jsx)("span",{className:"sr-only",children:"Filter files"}),(0,t.jsx)("input",{value:h,onChange:e=>m(e.target.value),placeholder:"Filter files...",disabled:!e})]})]}),(0,t.jsx)("div",{className:"file-tree-list",children:e?o?(0,t.jsx)("div",{className:"file-tree-state",children:"Loading..."}):d&&0===a.length?(0,t.jsx)("div",{className:"file-tree-state is-error",children:d}):0===S.length?(0,t.jsx)("div",{className:"file-tree-state",children:w?"No files match.":"No files found."}):(0,t.jsxs)(t.Fragment,{children:[d&&(0,t.jsx)("div",{className:"file-tree-inline-error",role:"alert",children:d}),C(S,0)]}):(0,t.jsx)("div",{className:"file-tree-empty",children:"Select a project to browse files."})})]})}let af=o("file-exclamation-point",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),ag=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"]),ax=new Set(["md","mdx","rmd","qmd"]),ay=new Set(["txt","json","yaml","yml","toml","csv","tsv","log","ts","tsx","js","jsx","mjs","cjs","py","r","rb","go","rs","java","c","cpp","h","hpp","css","scss","less","html","htm","xml","sh","bash","zsh","fish","ps1","bat","sql","graphql","gql","conf","cfg","ini","properties"]);function av({projectId:r,filePath:i,fileName:s}){var a;let[l,o]=(0,n.useState)({kind:"loading"}),c=s??i.split("/").pop()??i,d=ab(c);(0,n.useEffect)(()=>{let t=new AbortController,n=null;return async function(){o({kind:"loading"});try{var s,a,l;let u,p,h=await ah(r,i,t.signal),m=Number(h.headers.get("Content-Length")??0),f=h.headers.get("Content-Type")?.split(";",1)[0]??"application/octet-stream";if(ax.has(d)){if(m>4194304)throw Error("Text preview exceeds the 4 MiB limit");let e=await h.text();t.signal.aborted||o({kind:"markdown",content:e,size:e.length});return}if(s=c,a=f,u=ab(s),p=s.toLowerCase(),a.startsWith("text/")||ay.has(u)||["dockerfile","makefile"].includes(p)||p.startsWith(".env")){let n,r;if(m>4194304)throw Error("Text preview exceeds the 4 MiB limit");let i=await h.text(),s=(l=c,n=ab(l),r=l.toLowerCase(),"dockerfile"===r?"dockerfile":"makefile"===r?"makefile":({ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",py:"python",r:"r",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",css:"css",scss:"scss",less:"less",html:"html",htm:"html",xml:"xml",json:"json",yaml:"yaml",yml:"yaml",toml:"toml",sh:"bash",bash:"bash",zsh:"bash",fish:"fish",ps1:"powershell",sql:"sql",graphql:"graphql",gql:"graphql"})[n]??null),a=null;if(s)try{let{codeToHtml:t}=await e.A(140);a=await t(i,{lang:s,themes:{light:"github-light",dark:"github-dark"},defaultColor:!1})}catch{a=null}t.signal.aborted||o({kind:"code",content:i,highlighted:a,language:s??"text",size:i.length});return}if(ag.has(d)||f.startsWith("image/")){let e=await h.blob();n=URL.createObjectURL(e),t.signal.aborted||o({kind:"image",url:n,mime:f,size:e.size});return}if("pdf"===d||"application/pdf"===f){let e=await h.blob();n=URL.createObjectURL(e),t.signal.aborted||o({kind:"pdf",url:n,mime:f,size:e.size});return}o({kind:"unsupported",mime:f,size:m})}catch(e){t.signal.aborted||o({kind:"error",message:e.message})}}(),()=>{t.abort(),n&&URL.revokeObjectURL(n)}},[d,i,c,r]);let u="size"in l?(a=l.size)?a<1024?`${a} B`:a<1048576?`${(a/1024).toFixed(1)} KB`:`${(a/1048576).toFixed(1)} MB`:"0 B":null,p="code"===l.kind?l.language:d||l.kind,h=(0,eb.workerAPIPath)(au(r,i));return(0,t.jsxs)("div",{className:"file-viewer",children:[(0,t.jsxs)("div",{className:"file-viewer-status",children:[(0,t.jsx)("span",{className:"file-viewer-type",children:p}),(0,t.jsx)("span",{className:"file-viewer-path",title:i,children:i}),u&&(0,t.jsx)("span",{children:u}),(0,t.jsx)("a",{className:"file-viewer-download",href:h,download:c,title:"Download file","aria-label":`Download ${c}`,children:(0,t.jsx)(iZ,{size:13,"aria-hidden":"true"})})]}),(0,t.jsxs)("div",{className:"file-viewer-body",children:["loading"===l.kind&&(0,t.jsxs)("div",{className:"file-viewer-empty",children:[(0,t.jsx)(em,{className:"spin",size:18}),"Loading preview..."]}),"error"===l.kind&&(0,t.jsxs)("div",{className:"file-viewer-empty is-error",children:[(0,t.jsx)(af,{size:20}),l.message]}),"markdown"===l.kind&&(0,t.jsx)("article",{className:"markdown-body file-markdown",children:(0,t.jsx)(rk,{remarkPlugins:[i$],children:l.content})}),"code"===l.kind&&l.highlighted&&(0,t.jsx)("div",{className:"file-code",dangerouslySetInnerHTML:{__html:l.highlighted}}),"code"===l.kind&&!l.highlighted&&(0,t.jsx)("pre",{className:"file-code-plain",children:l.content}),"image"===l.kind&&(0,t.jsx)("div",{className:"file-image-stage",children:(0,t.jsx)("img",{src:l.url,alt:c})}),"pdf"===l.kind&&(0,t.jsx)("iframe",{className:"file-pdf",src:l.url,title:c}),"unsupported"===l.kind&&(0,t.jsxs)("div",{className:"file-viewer-empty",children:[(0,t.jsx)(af,{size:20}),"Preview is not available for ",l.mime,"."]})]})]})}function ab(e){return e.includes(".")?e.toLowerCase().split(".").pop()??"":""}let aj={pending:"Pending",running:"Running",completed:"Done",failed:"Failed",blocked:"Blocked",cancelled:"Cancelled",interrupted:"Interrupted"},ak={pending:"Pending",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled",convergence_exceeded:"Convergence exceeded",budget_exceeded:"Budget exceeded"};function aw({sessionId:e}){let[r,i]=(0,n.useState)([]),[s,a]=(0,n.useState)({}),[l,o]=(0,n.useState)(null),[c,d]=(0,n.useState)(null),u=(0,n.useCallback)(async()=>{if(e)try{let t=await (0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/graph-runs`)??[];i(t),d(null),o(e=>{if(0===t.length)return null;let n=t[0].runId??null;if(null===n)return null;if(null===e||!t.some(t=>t.runId===e))return n;let r=t[0].createdAt,i=t.find(t=>t.runId===e)?.createdAt;return r&&i&&i<r?n:e})}catch(e){d(e.message)}},[e]);(0,n.useEffect)(()=>{let e,t=new AbortController,n=!1,r=async()=>{await u(),n||(e=window.setTimeout(r,1500))};return r(),()=>{n=!0,t.abort(),void 0!==e&&window.clearTimeout(e)}},[u]),(0,n.useEffect)(()=>{if(!e||!l)return;let t=!1;return(0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/graph-runs/${encodeURIComponent(l)}`).then(e=>{t||a(t=>({...t,[l]:e.nodes??[]}))}).catch(()=>{t||d("Failed to load graph tasks")}),()=>{t=!0}},[l,e]);let p=(0,n.useMemo)(()=>r.some(e=>"running"===e.state),[r]);return(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[(0,t.jsxs)("div",{style:{padding:"10px 14px 6px",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,t.jsxs)("span",{style:{fontSize:12,fontWeight:600,color:"var(--text)",display:"flex",alignItems:"center",gap:6},children:[(0,t.jsx)(aC,{}),"Graph runs"]}),p&&(0,t.jsxs)("span",{style:{fontSize:10,color:"#2563EB",display:"flex",alignItems:"center",gap:4},children:[(0,t.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:"#2563EB",animation:"pulse 2s infinite"}}),"running"]})]}),c&&(0,t.jsx)("div",{style:{padding:"8px 14px",fontSize:11,color:"#DC2626"},children:c}),(0,t.jsx)("div",{style:{flex:1,minHeight:0,overflowY:"auto",padding:"0 8px 12px"},children:e?0===r.length?(0,t.jsx)("div",{style:{padding:16,color:"var(--text-dim)",fontSize:12,textAlign:"center"},children:"No graph runs in this session yet."}):r.map(e=>(0,t.jsx)(aS,{run:e,nodes:s[e.runId??""]??[],expanded:l===e.runId,onToggle:()=>o(t=>t===e.runId?null:e.runId??null),nodesLoading:l===e.runId&&void 0===s[e.runId??""]},e.runId)):(0,t.jsx)("div",{style:{padding:16,color:"var(--text-dim)",fontSize:12,textAlign:"center"},children:"Select a session to see its graph runs."})})]})}function aS({run:e,nodes:n,expanded:r,onToggle:i,nodesLoading:s}){let a=e.state,l=n.length,o=n.filter(e=>"completed"===e.terminalState).length;return(0,t.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:8,marginBottom:8,overflow:"hidden"},children:[(0,t.jsxs)("button",{type:"button",onClick:i,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 10px",background:r?"var(--bg-selected)":"transparent",border:"none",cursor:"pointer",color:"var(--text)",textAlign:"left",fontSize:12},"aria-expanded":r,children:[(0,t.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:r?"rotate(90deg)":"none",transition:"transform 0.15s"},children:(0,t.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})}),(0,t.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:function(e){switch(e){case"running":return"#2563EB";case"completed":return"#16A34A";case"failed":return"#DC2626";case"cancelled":case"convergence_exceeded":case"budget_exceeded":return"#D97706";default:return"var(--text-dim)"}}(a),flexShrink:0}}),(0,t.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.inputs?.name?String(e.inputs.name):"Graph run"}),(0,t.jsx)("span",{style:{flexShrink:0,fontSize:10,color:"var(--text-dim)"},children:l>0?`${o}/${l} tasks`:ak[a??""]??a})]}),r&&(0,t.jsxs)("div",{style:{borderTop:"1px solid var(--border)",padding:"6px 10px 10px 22px"},children:[(0,t.jsxs)("div",{style:{fontSize:10,color:"var(--text-dim)",marginBottom:6,display:"flex",gap:12,flexWrap:"wrap"},children:[(0,t.jsxs)("span",{children:["state: ",ak[a??""]??a]}),e.totalTokensUsed?(0,t.jsxs)("span",{children:["tokens: ",e.totalTokensUsed]}):null,e.createdAt?(0,t.jsx)("span",{children:function(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=Math.floor((new Date().getTime()-t.getTime())/6e4);return n<1?"just now":n<60?`${n}m ago`:t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}(e.createdAt)}):null]}),s?(0,t.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)",padding:"4px 0"},children:"Loading tasks…"}):0===n.length?(0,t.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)",padding:"4px 0"},children:"No task checkpoints."}):(0,t.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0},children:n.map(e=>(0,t.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:7,padding:"3px 0",fontSize:11},children:[(0,t.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:function(e){switch(e){case"running":return"#2563EB";case"completed":return"#16A34A";case"failed":return"#DC2626";case"blocked":return"#D97706";default:return"var(--text-dim)"}}(e.terminalState),flexShrink:0}}),(0,t.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text)"},children:e.handle}),(0,t.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:10},children:aj[e.terminalState??""]??e.terminalState})]},e.taskIndex??e.handle))})]})]})}function aC(){return(0,t.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,t.jsx)("circle",{cx:"5",cy:"19",r:"2"}),(0,t.jsx)("circle",{cx:"19",cy:"19",r:"2"}),(0,t.jsx)("path",{d:"M12 7v4M5 17v-2h6v4M19 17v-2h-6"})]})}function aN({tabs:e,activeTabId:r,onSelectTab:i,onCloseTab:s}){let[a,l]=(0,n.useState)(null);return(0,t.jsx)("div",{role:"tablist","aria-label":"Workspace panel tabs",style:{display:"flex",alignItems:"flex-end",background:"var(--bg-panel)",overflowX:"auto",flexShrink:0,height:36},children:e.map((n,o)=>{let c=n.id===r,d=!1!==n.closable;return(0,t.jsxs)("div",{role:"tab",tabIndex:c?0:-1,"aria-selected":c,onClick:()=>i(n.id),onKeyDown:t=>{if("Enter"===t.key||" "===t.key){t.preventDefault(),i(n.id);return}if("ArrowLeft"!==t.key&&"ArrowRight"!==t.key)return;t.preventDefault();let r=(o+("ArrowRight"===t.key?1:-1)+e.length)%e.length;i(e[r].id),t.currentTarget.parentElement?.children[r]?.focus()},style:{display:"flex",alignItems:"center",gap:6,height:36,paddingLeft:12,paddingRight:6,borderRight:"1px solid var(--border)",background:c?"var(--bg)":"var(--bg-panel)",cursor:"pointer",fontSize:12,color:c?"var(--text)":"var(--text-muted)",whiteSpace:"nowrap",maxWidth:180,minWidth:80,flexShrink:0,userSelect:"none",transition:"background 0.1s, color 0.1s"},children:[(0,t.jsx)("span",{style:{flexShrink:0,opacity:c?1:.7,display:"flex",alignItems:"center"},children:"files"===n.icon?(0,t.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M3 7.5V6a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v1.5"}),(0,t.jsx)("path",{d:"M3 7.5h18l-1.6 9.6A2 2 0 0 1 17.4 19H6.6a2 2 0 0 1-2-1.9z"})]}):"report"===n.icon?(0,t.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,t.jsx)("polyline",{points:"14 2 14 8 20 8"})]}):"tools"===n.icon?(0,t.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.1-3.1a6 6 0 0 1-7.9 7.9l-5.7 5.7a2.1 2.1 0 0 1-3-3l5.7-5.7a6 6 0 0 1 7.9-7.9z"})}):"graph"===n.icon?(0,t.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,t.jsx)("circle",{cx:"5",cy:"19",r:"2"}),(0,t.jsx)("circle",{cx:"19",cy:"19",r:"2"}),(0,t.jsx)("path",{d:"M12 7v4M5 17v-2h6v4M19 17v-2h-6"})]}):ad(n.filePath??n.label,13)}),(0,t.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,fontWeight:c?500:400},title:n.filePath??n.label,children:n.label}),d&&(0,t.jsx)("button",{onClick:e=>{e.stopPropagation(),s(n.id)},onMouseEnter:()=>l(n.id),onMouseLeave:()=>l(null),style:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,background:a===n.id?"var(--bg-hover)":"transparent",border:"none",borderRadius:3,color:a===n.id?"var(--text)":"var(--text-dim)",cursor:"pointer",padding:0,flexShrink:0,transition:"background 0.1s, color 0.1s"},title:"Close","aria-label":`Close ${n.label}`,children:(0,t.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,t.jsx)("line",{x1:"2",y1:"2",x2:"8",y2:"8"}),(0,t.jsx)("line",{x1:"8",y1:"2",x2:"2",y2:"8"})]})})]},n.id)})})}function aI(e){let{open:n,onClose:r,resize:i,tabs:s,activeTabId:a,onSelectTab:l,onCloseTab:o,projectId:c,displayPath:d,onOpenFile:u,onPreviewFile:p,selectedSession:h,sessionTitle:m,activeRun:f,status:g,permissionMode:x}=e,y=s.find(e=>e.id===a);return(0,t.jsxs)("div",{className:`right-panel-container${n?" right-panel-open":" right-panel-closed"}`,style:{background:"var(--bg)",borderLeft:"1px solid var(--border)",display:"flex",flexDirection:"column",width:i.width,minWidth:i.width,transition:i.isResizing?"none":void 0},children:[(0,t.jsxs)("button",{type:"button",className:"right-panel-back-button",onClick:r,children:[(0,t.jsx)(sX,{size:15,"aria-hidden":"true"}),"Back to conversation"]}),(0,t.jsx)(aN,{tabs:s,activeTabId:a,onSelectTab:l,onCloseTab:o}),(0,t.jsxs)("div",{style:{flex:1,minHeight:0,overflow:"hidden"},children:["files"===a&&(0,t.jsx)(am,{projectId:c,displayPath:d,onOpenFile:u,onPreviewFile:p},c??"no-project"),"graph"===a&&(0,t.jsx)(aw,{sessionId:h}),"tools"===a&&(0,t.jsxs)("div",{style:{padding:18,color:"var(--text-muted)",fontSize:13},children:[(0,t.jsx)("div",{style:{fontWeight:600,marginBottom:12},children:"Session Status"}),(0,t.jsx)("div",{style:{fontSize:12},children:h?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{children:["Session: ",m]}),(0,t.jsxs)("div",{children:["Active run: ",f||"none"]}),(0,t.jsxs)("div",{children:["Status: ",g||"idle"]}),(0,t.jsxs)("div",{children:["Permission: ",x]})]}):(0,t.jsx)("div",{children:"No session selected"})})]}),y?.projectId&&y.filePath&&(0,t.jsx)(av,{projectId:y.projectId,filePath:y.filePath,fileName:y.label})]})]})}function aT({projectId:e,filePath:r,fileName:i,onClose:s}){let[a,l]=(0,n.useState)(()=>aM()),o=(0,n.useRef)(null),c=(0,n.useRef)(null),d=(0,n.useCallback)((e,t)=>{0!==t.button||a.maximized||(t.preventDefault(),c.current={kind:e,x:t.clientX,y:t.clientY,bounds:a},t.currentTarget.setPointerCapture(t.pointerId))},[a]),u=(0,n.useCallback)(e=>{let t=c.current;if(!t)return;e.preventDefault();let n=e.clientX-t.x,r=e.clientY-t.y,i=window.innerWidth,s=window.innerHeight;"move"===t.kind?l({...t.bounds,x:aR(t.bounds.x+n,0,Math.max(0,i-160)),y:aR(t.bounds.y+r,0,Math.max(0,s-44))}):l({...t.bounds,width:aR(t.bounds.width+n,360,Math.max(360,i-t.bounds.x)),height:aR(t.bounds.height+r,260,Math.max(260,s-t.bounds.y))})},[]),p=(0,n.useCallback)(e=>{c.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},[]),h=(0,n.useCallback)(()=>{l(e=>e.maximized?o.current??aM():(o.current=e,{x:12,y:12,width:window.innerWidth-24,height:window.innerHeight-24,maximized:!0}))},[]);return(0,t.jsxs)("section",{className:`file-preview-window${a.maximized?" is-maximized":""}`,role:"dialog","aria-label":`Preview ${i}`,style:{left:a.x,top:a.y,width:a.width,height:a.height},children:[(0,t.jsxs)("header",{className:"file-preview-titlebar",onDoubleClick:h,onPointerDown:e=>d("move",e),onPointerMove:u,onPointerUp:p,onPointerCancel:p,children:[(0,t.jsx)("span",{title:r,children:i}),(0,t.jsxs)("div",{className:"file-preview-window-actions",onPointerDown:e=>e.stopPropagation(),children:[(0,t.jsx)("button",{type:"button",onClick:h,"aria-label":a.maximized?"Restore preview":"Maximize preview",title:a.maximized?"Restore preview":"Maximize preview",children:a.maximized?(0,t.jsx)(O,{size:14}):(0,t.jsx)(s0,{size:14})}),(0,t.jsx)("button",{type:"button",onClick:s,"aria-label":"Close preview",title:"Close preview",children:(0,t.jsx)(m,{size:15})})]})]}),(0,t.jsx)("div",{className:"file-preview-content",children:(0,t.jsx)(av,{projectId:e,filePath:r,fileName:i})}),!a.maximized&&(0,t.jsx)("div",{className:"file-preview-resize",role:"separator","aria-label":"Resize preview",onPointerDown:e=>d("resize",e),onPointerMove:u,onPointerUp:p,onPointerCancel:p})]})}function aM(){let e=window.innerWidth,t=window.innerHeight,n=Math.min(760,Math.max(360,e-48)),r=Math.min(600,Math.max(260,t-72));return{x:Math.max(12,Math.round((e-n)/2)),y:Math.max(12,Math.round((t-r)/2)),width:n,height:r,maximized:!1}}function aR(e,t,n){return Math.min(n,Math.max(t,e))}function aE(){document.body.style.cursor="",document.body.style.userSelect=""}function az({side:e,onResize:r,onResizeStart:i,onResizeEnd:s,ariaLabel:a,value:l,min:o,max:c}){let d=(0,n.useRef)(null),u=(0,n.useRef)(!1),p=(0,n.useRef)(0),[h,m]=(0,n.useState)(!1),f=(0,n.useCallback)(e=>{if(!u.current)return;u.current=!1,m(!1);let t=d.current;t&&void 0!==e&&t.hasPointerCapture(e)&&t.releasePointerCapture(e),aE(),s?.()},[s]),g=(0,n.useCallback)(e=>{0===e.button&&e.isPrimary&&(e.preventDefault(),u.current=!0,p.current=e.clientX,m(!0),i?.(),e.currentTarget.setPointerCapture(e.pointerId),document.body.style.cursor="col-resize",document.body.style.userSelect="none")},[i]),x=(0,n.useCallback)(e=>{if(!u.current)return;e.preventDefault();let t=e.clientX-p.current;p.current=e.clientX,r(t)},[r]),y=(0,n.useCallback)(e=>{e.preventDefault(),f(e.pointerId)},[f]),v=(0,n.useCallback)(e=>{f(e.pointerId)},[f]);(0,n.useEffect)(()=>()=>{u.current&&(u.current=!1,aE(),s?.())},[s]);let b=(0,n.useCallback)(e=>{if("ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;e.preventDefault();let t="ArrowRight"===e.key?16:-16;i?.(),r(t),s?.()},[r,s,i]);return(0,t.jsx)("div",{ref:d,role:"separator","aria-label":a??"Resize panel","aria-orientation":"vertical","aria-valuemin":o,"aria-valuemax":c,"aria-valuenow":l,tabIndex:0,className:`resize-handle${h?" resize-handle-dragging":""}`,"data-side":e,onPointerDown:g,onPointerMove:x,onPointerUp:y,onPointerCancel:v,onKeyDown:b,style:{alignSelf:"stretch",cursor:"col-resize",display:"flex",flexShrink:0,justifyContent:"center",marginLeft:-5,marginRight:-5,position:"relative",touchAction:"none",width:10,zIndex:250},children:(0,t.jsx)("div",{className:"resize-handle-line"})})}let aA=o("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),aP=o("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);function a$({listing:e,selectedPath:n,showHidden:r,disabled:i,onSelect:s}){let a=r?e.entries:e.entries.filter(e=>!e.hidden||e.path===n);return(0,t.jsx)("div",{className:"project-picker-column",role:"list",children:a.map(e=>{let r=e.path===n;return(0,t.jsx)("span",{role:"listitem",className:"project-picker-row-seat",children:(0,t.jsxs)("button",{type:"button",className:`project-picker-row${r?" selected":""}`,"aria-current":r||void 0,disabled:i,onClick:()=>s(e),children:[r?(0,t.jsx)(iH,{size:16,className:"project-picker-folder selected","aria-hidden":"true"}):(0,t.jsx)(aP,{size:16,className:"project-picker-folder","aria-hidden":"true"}),(0,t.jsx)("span",{children:e.name}),(0,t.jsx)(aA,{size:12,className:"project-picker-row-chevron","aria-hidden":"true"})]})},e.path)})})}function aL({busy:e,onCreate:r,onClose:i}){let s=(0,f.useT)(),[a,l]=(0,n.useState)(null),[o,c]=(0,n.useState)(null),[d,u]=(0,n.useState)(null),[p,h]=(0,n.useState)(!0),[m,g]=(0,n.useState)(null),[y,v]=(0,n.useState)(null),[b,j]=(0,n.useState)(!1),[k,w]=(0,n.useState)(null),[S,C]=(0,n.useState)(!1),[N,I]=(0,n.useState)(null),T=(0,n.useRef)(0),M=(0,n.useRef)(null),R=(0,n.useCallback)(async e=>{let t=e?`?${new URLSearchParams({path:e})}`:"";return(0,eb.apiFetch)(`/v1/host/directories${t}`)},[]),E=(0,n.useCallback)(async e=>{let t=++T.current;h(!0),g(null);try{let n=await R(e);if(t!==T.current)return;l(n),c(null),u(null),v(null)}catch(e){t===T.current&&g(e.message)}finally{t===T.current&&h(!1)}},[R]);(0,n.useEffect)(()=>{let e=++T.current;return R().then(t=>{e===T.current&&(l(t),h(!1))},t=>{e===T.current&&(g(t.message),h(!1))}),()=>{T.current+=1}},[R]),(0,n.useEffect)(()=>{null!==y&&M.current?.focus()},[y]);let z=(0,n.useCallback)(async e=>{let t=++T.current;c(e),u(null),h(!0),g(null);try{let n=await R(e.path);t===T.current&&u(n)}catch(e){t===T.current&&(c(null),g(e.message))}finally{t===T.current&&h(!1)}},[R]),A=(0,n.useCallback)(e=>{d&&(l(d),z(e))},[d,z]),P=o?.path??a?.path??null,$=P?P.replace(/[\\/]+$/,"").split(/[\\/]/).at(-1)||P:"",L=(0,n.useMemo)(()=>{var e;let t;return a?(e=s("directory.home"),(t=a.crumbs.findIndex(e=>e.path===a.home))<0?a.crumbs:[{name:e,path:a.home,hidden:!1},...a.crumbs.slice(t+1)]):[]},[a,s]),F=e||S,D=async()=>{if(P&&null!==k&&k.trim()&&!S){C(!0),I(null);try{let e=await (0,eb.apiFetch)("/v1/host/directories",{method:"POST",body:JSON.stringify({path:P,name:k})});if(w(null),o&&d){let t=await R(o.path);l(t);let n=t.entries.find(t=>t.path===e.path);n&&await z(n)}else{let t=await R(a?.path);l(t);let n=t.entries.find(t=>t.path===e.path);n&&z(n)}}catch(e){I(e.message)}finally{C(!1)}}},_=async()=>{if(P&&!e&&!p&&null===y){g(null);try{await r($,P)}catch(e){g(e.message)}}};return(0,t.jsxs)("div",{className:"project-picker-overlay",onPointerDown:e=>{e.target!==e.currentTarget||F||null!==k||i()},children:[(0,t.jsxs)("div",{className:"project-picker-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"project-picker-title",children:[(0,t.jsxs)("header",{className:"project-picker-header",children:[(0,t.jsx)("h2",{id:"project-picker-title",children:s("directory.title")}),(0,t.jsx)("div",{className:`project-picker-crumb-bar${null!==y?" editing":""}`,children:null===y?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("nav",{className:"project-picker-crumbs","aria-label":s("directory.path"),children:L.map((e,n)=>(0,t.jsxs)("span",{children:[n>0&&(0,t.jsx)(aA,{size:12,"aria-hidden":"true"}),(0,t.jsx)("button",{type:"button",disabled:F,onClick:()=>void E(e.path),children:e.name})]},e.path))}),(0,t.jsx)("button",{type:"button",className:"project-picker-edit-path","aria-label":s("directory.editPath"),title:s("directory.editPath"),disabled:F,onClick:()=>{if(!a||F)return;let e=o?.path??a.path,t=a.home.includes("\\")?"\\":"/";v(e.endsWith(t)?e:`${e}${t}`)},children:(0,t.jsx)(iq,{size:14,"aria-hidden":"true"})})]}):(0,t.jsx)("input",{ref:M,value:y,"aria-label":s("directory.editPath"),disabled:F,onChange:e=>v(e.target.value),onKeyDown:e=>{"Enter"===e.key&&y.trim()&&E(y),"Escape"===e.key&&(e.stopPropagation(),v(null))}})})]}),(0,t.jsxs)("main",{className:"project-picker-content",children:[(0,t.jsxs)("div",{className:"project-picker-miller-row",children:[a&&(0,t.jsx)(a$,{listing:a,selectedPath:o?.path??null,showHidden:b,disabled:F,onSelect:e=>void z(e)}),o&&(0,t.jsx)("span",{className:"project-picker-divider"}),o&&d&&(0,t.jsx)(a$,{listing:d,selectedPath:null,showHidden:b,disabled:F,onSelect:A})]}),p&&(0,t.jsx)("div",{className:"project-picker-loading",role:"status",children:s("directory.loading")}),(a?.truncated||d?.truncated)&&(0,t.jsx)("div",{className:"project-picker-status",children:s("directory.truncated")}),m&&(0,t.jsx)("div",{className:"project-picker-error",role:"alert",children:m})]}),(0,t.jsxs)("footer",{className:"project-picker-footer",children:[(0,t.jsxs)("button",{type:"button",className:"project-picker-button outline new-folder",disabled:!a||p||F||null!==y,onClick:()=>{w(""),I(null)},children:[(0,t.jsx)(x,{size:14,"aria-hidden":"true"})," ",s("directory.newFolder")]}),(0,t.jsxs)("button",{type:"button",className:`project-picker-show-hidden${b?" active":""}`,"aria-pressed":b,disabled:F,onClick:()=>j(e=>!e),children:[s("directory.showHidden"),b&&(0,t.jsx)(U,{size:14,"aria-hidden":"true"})]}),(0,t.jsx)("span",{className:"project-picker-footer-gap"}),(0,t.jsx)("button",{type:"button",className:"project-picker-button outline",disabled:F,onClick:i,children:s("directory.cancel")}),(0,t.jsx)("button",{type:"button",className:"project-picker-button primary",disabled:!P||p||F||null!==y,onClick:()=>void _(),children:e?s("directory.opening"):s("directory.open")})]})]}),null!==k&&(0,t.jsx)("div",{className:"project-picker-nested-overlay",onPointerDown:e=>{e.target!==e.currentTarget||S||w(null)},children:(0,t.jsxs)("div",{className:"project-picker-create-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"project-folder-title",children:[(0,t.jsx)("h3",{id:"project-folder-title",children:s("directory.newFolder")}),(0,t.jsx)("p",{children:s("directory.createIn").replace("{name}",$)}),(0,t.jsx)("input",{value:k,"aria-label":s("directory.folderName"),placeholder:s("directory.untitledFolder"),autoFocus:!0,disabled:S,onChange:e=>w(e.target.value),onKeyDown:e=>{"Enter"===e.key&&D(),"Escape"!==e.key||S||(e.stopPropagation(),w(null))}}),N&&(0,t.jsx)("div",{className:"project-picker-error",role:"alert",children:N}),(0,t.jsxs)("div",{className:"project-picker-create-actions",children:[(0,t.jsx)("button",{type:"button",className:"project-picker-button outline",disabled:S,onClick:()=>w(null),children:s("directory.cancel")}),(0,t.jsx)("button",{type:"button",className:"project-picker-button primary",disabled:S||!k.trim(),onClick:()=>void D(),children:s("directory.create")})]})]})})]})}function aF({policies:e,models:n,session:r,refresh:i,setError:s,onSessionUpdated:a}){async function l(e,t){try{await (0,eb.apiFetch)("/v1/policy-profiles",{method:"POST",body:JSON.stringify({name:e,kind:"compaction",config:t})}),s(null),await i()}catch(e){s(e.message)}}async function o(e){try{await (0,eb.apiFetch)(`/v1/policy-profiles/${encodeURIComponent(e)}/default`,{method:"PUT"}),s(null),await i()}catch(e){s(e.message)}}async function c(e){if(r)try{let t=await (0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(r.id)}`,{method:"PATCH",body:JSON.stringify(e)});a(t),s(null)}catch(e){s(e.message)}}return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-context-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-context-heading",children:"Context & session"}),(0,t.jsx)("p",{children:"Compaction policy versions and defaults frozen into the next Session Run."})]}),(0,t.jsx)(aD,{policies:e,models:n,onCreate:l,onDefault:o}),(0,t.jsxs)("section",{className:"settings-subsection current-session-settings",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h3",{children:"Current session"}),(0,t.jsx)("p",{children:r?r.title:"Select a Session to configure its defaults."})]}),(0,t.jsxs)("div",{className:"session-default-grid",children:[(0,t.jsxs)("label",{className:"session-model-select",children:["Default model",(0,t.jsxs)("select",{disabled:!r,value:r?.defaultModelProfileId??"",onChange:e=>void c({defaultModelProfileId:e.target.value||null}),children:[(0,t.jsx)("option",{value:"",children:"Use global default"}),n.map(e=>(0,t.jsx)("option",{value:e.id,children:e.displayName||e.modelName},e.id))]})]}),(0,t.jsxs)("label",{className:"session-model-select",children:["Context compaction",(0,t.jsxs)("select",{disabled:!r,value:r?.compactionPolicyProfileId??"",onChange:e=>void c({compactionPolicyProfileId:e.target.value||null}),children:[(0,t.jsx)("option",{value:"",children:"Use global default"}),e.filter(e=>"compaction"===e.kind&&"active"===e.status).map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.name," v",e.version]},e.id))]})]})]})]}),(0,t.jsx)(a_,{sessionId:r?.id??null})]})}function aD({policies:e,models:r,onCreate:i,onDefault:s}){let[a,l]=(0,n.useState)([]),o=(e,t)=>l(n=>n.map((n,r)=>r===e?{...n,...t}:n));async function c(e){e.preventDefault();let t=e.currentTarget,n=new FormData(t),r=String(n.get("mode")),s="manual_and_auto"===r&&"on"===n.get("allowOverflowRecovery"),o=a.filter(e=>e.modelProfileId).map(e=>({modelProfileId:e.modelProfileId,...void 0!==e.triggerRatio?{triggerRatio:e.triggerRatio}:{},...void 0!==e.tailMaxTokens?{tailMaxTokens:e.tailMaxTokens}:{},...void 0!==e.summaryMaxOutputTokens?{summaryMaxOutputTokens:e.summaryMaxOutputTokens}:{}}));await i(String(n.get("name")),{mode:r,triggerRatio:Number(n.get("triggerRatio")),keepRecentTurns:Number(n.get("keepRecentTurns")),tailTokenRatio:Number(n.get("tailTokenRatio")),tailMinTokens:Number(n.get("tailMinTokens")),tailMaxTokens:Number(n.get("tailMaxTokens")),summaryInputRatio:Number(n.get("summaryInputRatio")),compactionModelProfileId:n.get("compactionModelProfileId")||null,summaryMaxOutputTokens:Number(n.get("summaryMaxOutputTokens")),...o.length>0?{modelPolicies:o}:{},includeReasoning:"on"===n.get("includeReasoning"),allowHistoryLookup:"on"===n.get("allowHistoryLookup"),allowOverflowRecovery:s,maxOverflowRecoveries:+!!s,ineffectiveReclaimRatio:Number(n.get("ineffectiveReclaimRatio")),ineffectiveLimit:Number(n.get("ineffectiveLimit")),failureCooldownSeconds:Number(n.get("failureCooldownSeconds")),promptVersion:"v1"}),t.reset(),l([])}return(0,t.jsxs)("section",{className:"settings-subsection",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h3",{children:"Context compaction"}),(0,t.jsx)("p",{children:"Manual and bounded automatic context checkpoint behavior."})]}),(0,t.jsxs)("form",{className:"settings-form compaction-form",onSubmit:c,children:[(0,t.jsxs)("label",{children:["Name",(0,t.jsx)("input",{name:"name",required:!0})]}),(0,t.jsxs)("label",{children:["Mode",(0,t.jsxs)("select",{name:"mode",defaultValue:"manual_only",children:[(0,t.jsx)("option",{value:"disabled",children:"Disabled"}),(0,t.jsx)("option",{value:"manual_only",children:"Manual only"}),(0,t.jsx)("option",{value:"manual_and_auto",children:"Manual and automatic"})]})]}),(0,t.jsxs)("label",{children:["Summary model",(0,t.jsxs)("select",{name:"compactionModelProfileId",defaultValue:"",children:[(0,t.jsx)("option",{value:"",children:"Use run model"}),r.map(e=>(0,t.jsx)("option",{value:e.id,children:e.displayName||e.modelName},e.id))]})]}),(0,t.jsxs)("label",{children:["Trigger ratio",(0,t.jsx)("input",{name:"triggerRatio",type:"number",min:"0.01",max:"0.99",step:"0.01",defaultValue:"0.75",required:!0})]}),(0,t.jsxs)("label",{children:["Recent turns",(0,t.jsx)("input",{name:"keepRecentTurns",type:"number",min:"1",step:"1",defaultValue:"2",required:!0})]}),(0,t.jsxs)("label",{children:["Tail ratio",(0,t.jsx)("input",{name:"tailTokenRatio",type:"number",min:"0.01",max:"0.99",step:"0.01",defaultValue:"0.2",required:!0})]}),(0,t.jsxs)("label",{children:["Tail minimum",(0,t.jsx)("input",{name:"tailMinTokens",type:"number",min:"1",step:"1",defaultValue:"8000",required:!0})]}),(0,t.jsxs)("label",{children:["Tail maximum",(0,t.jsx)("input",{name:"tailMaxTokens",type:"number",min:"1",step:"1",defaultValue:"32000",required:!0})]}),(0,t.jsxs)("label",{children:["Summary input ratio",(0,t.jsx)("input",{name:"summaryInputRatio",type:"number",min:"0.01",max:"0.99",step:"0.01",defaultValue:"0.7",required:!0})]}),(0,t.jsxs)("label",{children:["Summary output",(0,t.jsx)("input",{name:"summaryMaxOutputTokens",type:"number",min:"1",step:"1",defaultValue:"4096",required:!0})]}),(0,t.jsxs)("label",{children:["Cooldown seconds",(0,t.jsx)("input",{name:"failureCooldownSeconds",type:"number",min:"0",step:"1",defaultValue:"600",required:!0})]}),(0,t.jsxs)("label",{children:["Ineffective ratio",(0,t.jsx)("input",{name:"ineffectiveReclaimRatio",type:"number",min:"0",max:"0.99",step:"0.01",defaultValue:"0.1",required:!0})]}),(0,t.jsxs)("label",{children:["Ineffective limit",(0,t.jsx)("input",{name:"ineffectiveLimit",type:"number",min:"1",step:"1",defaultValue:"3",required:!0})]}),(0,t.jsxs)("div",{className:"settings-toggles compaction-toggles",children:[(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{name:"allowHistoryLookup",type:"checkbox",defaultChecked:!0})," History lookup"]}),(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{name:"allowOverflowRecovery",type:"checkbox",defaultChecked:!0})," Overflow recovery"]}),(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{name:"includeReasoning",type:"checkbox"})," Include reasoning"]})]}),(0,t.jsxs)("div",{className:"settings-subsection compaction-model-policies",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h4",{children:"Per-model overrides"}),(0,t.jsx)("p",{children:"Optional budget overrides for a specific model."})]}),a.map((e,n)=>(0,t.jsxs)("div",{className:"model-policy-row",children:[(0,t.jsxs)("select",{value:e.modelProfileId,onChange:e=>o(n,{modelProfileId:e.target.value}),"aria-label":`Override model ${n+1}`,children:[(0,t.jsx)("option",{value:"",children:"Select model…"}),r.map(e=>(0,t.jsx)("option",{value:e.id,children:e.displayName||e.modelName},e.id))]}),(0,t.jsx)("input",{type:"number",step:"0.01",min:"0.01",max:"0.99",placeholder:"Trigger ratio",value:e.triggerRatio??"",onChange:e=>o(n,{triggerRatio:""===e.target.value?void 0:Number(e.target.value)})}),(0,t.jsx)("input",{type:"number",step:"1",min:"1",placeholder:"Tail max tokens",value:e.tailMaxTokens??"",onChange:e=>o(n,{tailMaxTokens:""===e.target.value?void 0:Number(e.target.value)})}),(0,t.jsx)("input",{type:"number",step:"1",min:"1",placeholder:"Summary output",value:e.summaryMaxOutputTokens??"",onChange:e=>o(n,{summaryMaxOutputTokens:""===e.target.value?void 0:Number(e.target.value)})}),(0,t.jsx)("button",{type:"button",className:"secondary-btn",onClick:()=>l(e=>e.filter((e,t)=>t!==n)),"aria-label":`Remove override ${n+1}`,children:"✕"})]},n)),(0,t.jsx)("button",{type:"button",className:"secondary-btn",onClick:()=>l(e=>[...e,{modelProfileId:""}]),children:"+ Add override"})]}),(0,t.jsx)("button",{type:"submit",children:"Create version"})]}),(0,t.jsx)("div",{className:"settings-list",children:e.filter(e=>"compaction"===e.kind).map(e=>(0,t.jsxs)("div",{className:"settings-row",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:e.name}),(0,t.jsxs)("span",{children:["v",e.version," · ",String(e.config.mode??"configured")]})]}),(0,t.jsx)("button",{className:"secondary-btn",disabled:"active"!==e.status,onClick:()=>s(e.id),children:"Use as default"})]},e.id))})]})}function a_({sessionId:e}){let[r,i]=(0,n.useState)([]),[s,a]=(0,n.useState)(null),[l,o]=(0,n.useState)(null);(0,n.useEffect)(()=>{if(!e)return;let t=!1;return(0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/standing-approvals`).then(n=>{t||(i(n?.items??[]),o(null),a(e))}).catch(n=>{t||(i([]),o(n.message),a(e))}),()=>{t=!0}},[e]);let c=s===e,d=c?r:[],u=!c,p=c?l:null,h=(0,n.useCallback)(async t=>{if(e)try{await (0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/standing-approvals/${encodeURIComponent(t)}/revoke`,{method:"POST"}),i(e=>e.filter(e=>e.id!==t)),o(null)}catch(e){o(e.message)}},[e]);return e?(0,t.jsxs)("section",{className:"settings-subsection standing-approvals-section",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h3",{children:"Standing approvals"}),(0,t.jsx)("p",{children:"Tools automatically authorised for this session. Revoke to require approval again."})]}),u&&(0,t.jsx)("div",{className:"settings-empty",children:"Loading…"}),!u&&p&&(0,t.jsx)("div",{className:"settings-error",children:p}),!u&&!p&&0===d.length&&(0,t.jsx)("div",{className:"settings-empty",children:"No standing approvals for this session."}),!u&&d.length>0&&(0,t.jsx)("div",{className:"settings-list",children:d.map(e=>(0,t.jsxs)("div",{className:"settings-row",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:e.toolName}),(0,t.jsx)("span",{children:e.scopeDisplay})]}),(0,t.jsx)("button",{className:"secondary-btn",onClick:()=>h(e.id),children:"Revoke"})]},e.id))})]}):null}let aO=o("monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]),aW="ennote-default-permission",aU="ennote-default-permission-change",aq=["discuss","ask","auto"];function aB(){try{let e=window.localStorage.getItem(aW);if(null!==e&&aq.includes(e))return e}catch{}return"discuss"}var aH=e.i(18929),aV=e.i(426);let aK=["discuss","ask","auto"];function aJ(){let{mode:e,setThemeMode:r}=sZ(),{locale:i,setLocale:s}=(0,f.useLocale)(),[a,l]=(0,n.useState)(()=>aB()),o=e=>(0,aV.translate)(i,e),c=[{id:"light",label:"Light",icon:(0,t.jsx)(sU,{size:15,"aria-hidden":"true"})},{id:"dark",label:"Dark",icon:(0,t.jsx)(sW,{size:15,"aria-hidden":"true"})},{id:"system",label:"System",icon:(0,t.jsx)(aO,{size:15,"aria-hidden":"true"})}];return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-general-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-general-heading",children:o("general.title")}),(0,t.jsx)("p",{children:o("general.desc")})]}),(0,t.jsxs)("section",{className:"settings-subsection appearance-group",children:[(0,t.jsx)("div",{className:"appearance-title",children:o("general.appearance")}),(0,t.jsx)("div",{className:"appearance-cubes",role:"group","aria-label":o("general.appearance"),children:c.map(n=>(0,t.jsxs)("button",{type:"button",className:`appearance-cube ${e===n.id?"selected":""}`,"aria-pressed":e===n.id,onClick:()=>r(n.id),children:[n.icon,(0,t.jsx)("span",{children:n.label})]},n.id))})]}),(0,t.jsxs)("section",{className:"settings-subsection permission-group",children:[(0,t.jsx)("div",{className:"appearance-title",children:o("general.permission")}),(0,t.jsx)("p",{className:"settings-note",children:o("general.permission.desc")}),(0,t.jsx)("div",{className:"appearance-cubes",role:"group","aria-label":o("general.permission"),children:aK.map(e=>(0,t.jsx)("button",{type:"button",className:`appearance-cube ${a===e?"selected":""}`,"aria-pressed":a===e,onClick:()=>{l(e);try{window.localStorage.setItem(aW,e)}catch{}window.dispatchEvent(new CustomEvent(aU,{detail:e}))},children:(0,t.jsx)("span",{children:"discuss"===e?"Discuss":"ask"===e?"Ask":"Auto"})},e))})]}),(0,t.jsxs)("section",{className:"settings-subsection language-group",children:[(0,t.jsx)("div",{className:"appearance-title",children:o("general.language")}),(0,t.jsx)("div",{className:"appearance-cubes",role:"group","aria-label":o("general.language"),children:aH.LOCALES.map(e=>(0,t.jsx)("button",{type:"button",className:`appearance-cube ${i===e?"selected":""}`,"aria-pressed":i===e,onClick:()=>s(e),children:(0,t.jsx)("span",{children:"en"===e?o("language.en"):o("language.zh")})},e))})]})]})}let aG={stdio:"stdio",streamable_http:"Streamable HTTP",legacy_sse:"HTTP + SSE"},aZ={display:"flex",flexDirection:"column",gap:3,fontSize:11,color:"var(--text-muted)",fontWeight:600},aQ={padding:"6px 8px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:12,width:"100%"},aY={padding:"4px 8px",borderRadius:6,fontSize:11,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",cursor:"pointer"};function aX({mcp:e}){let{showCreate:n,transport:r,setTransport:i,displayName:s,setDisplayName:a,slug:l,setSlug:o,executable:c,setExecutable:d,argv:u,setArgv:p,endpoint:h,setEndpoint:m,createProfile:f}=e;return(0,t.jsx)(t.Fragment,{children:n&&(0,t.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:8,padding:12,display:"flex",flexDirection:"column",gap:8},children:[(0,t.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[(0,t.jsxs)("label",{style:aZ,children:["Display name",(0,t.jsx)("input",{value:s,onChange:e=>a(e.target.value),style:aQ,placeholder:"PubMed"})]}),(0,t.jsxs)("label",{style:aZ,children:["Slug (fixed once bound)",(0,t.jsx)("input",{value:l,onChange:e=>o(e.target.value),style:aQ,placeholder:"pubmed"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{style:{display:"flex",gap:6,marginBottom:6},children:["stdio","streamable_http","legacy_sse"].map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>i(e),style:{padding:"4px 10px",borderRadius:6,fontSize:11,border:"1px solid var(--border)",background:r===e?"var(--bg-selected)":"var(--bg)",color:r===e?"var(--text)":"var(--text-muted)",cursor:"pointer"},children:aG[e]},e))}),"stdio"===r?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("label",{style:aZ,children:["Executable",(0,t.jsx)("input",{value:c,onChange:e=>d(e.target.value),style:aQ,placeholder:"/usr/bin/python3"})]}),(0,t.jsxs)("label",{style:aZ,children:["Arguments (space-separated)",(0,t.jsx)("input",{value:u,onChange:e=>p(e.target.value),style:aQ,placeholder:"/path/to/server.py"})]})]}):(0,t.jsxs)("label",{style:aZ,children:["Endpoint URL",(0,t.jsx)("input",{value:h,onChange:e=>m(e.target.value),style:aQ,placeholder:"https://example.com/mcp"})]})]}),(0,t.jsx)("button",{type:"button",onClick:f,disabled:!s.trim()||!l.trim()||("stdio"===r?!c.trim():!h.trim()),style:{padding:"6px 12px",borderRadius:6,border:"none",background:"var(--accent)",color:"#fff",fontSize:12,cursor:"pointer",alignSelf:"flex-start"},children:"Create profile"})]})})}function a0({mcp:e,binding:n}){let{catalogs:r,toolSearch:i,setToolSearch:s,showCreds:a,setShowCreds:l,credEnv:o,setCredEnv:c,credRef:d,setCredRef:u,versionFor:p,updateBinding:h,toggleTool:m,selectAllTools:f,addCredential:g,removeCredential:x,testBinding:y,refreshCatalog:v,removeBinding:b}=e,j=r[n.id]??[],k=n.selectedRemoteToolNames??[],w=p(n),S=w?"stdio"===w.transport?`${w.executable??""} ${(w.argv??[]).join(" ")}`.trim():w.endpoint??"":"";return(0,t.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:8,padding:10,display:"flex",flexDirection:"column",gap:8},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,t.jsxs)("div",{style:{minWidth:0},children:[(0,t.jsxs)("div",{style:{fontSize:12,fontWeight:700,color:"var(--text)"},children:[w?aG[w.transport]??w.transport:"MCP server",(0,t.jsxs)("span",{style:{color:"var(--text-dim)",fontWeight:400,marginLeft:6},children:["rev ",n.revision??0," · ",k.length," tools selected"]})]}),S&&(0,t.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:360},children:S})]}),(0,t.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[(0,t.jsx)("button",{type:"button",title:n.required?"Server is required: Run start fails when unreachable":"Server is optional: Run start continues when unreachable",onClick:()=>h(n,{required:!n.required}),style:{fontSize:10,color:n.required?"var(--text)":"var(--text-muted)",border:"1px solid var(--border)",borderRadius:4,padding:"1px 6px",background:"var(--bg)",cursor:"pointer"},children:n.required?"required":"optional"}),(0,t.jsx)("button",{type:"button",title:"Edit credential references for this binding",onClick:()=>l(e=>({...e,[n.id]:!e[n.id]})),style:aY,children:"Credentials"}),(0,t.jsx)("button",{type:"button",onClick:async()=>{let e=!n.desiredEnabled;if(e){let e=w?"stdio"===w.transport?`Command: ${S}`:`Endpoint: ${w.endpoint??""}`:"";if(!window.confirm(`Enable this MCP server?
|
|
3
|
-
${e}
|
|
4
|
-
|
|
5
|
-
Only selected tools will be exposed to Runs.`))return}await h(n,{desiredEnabled:e})},style:{padding:"4px 10px",borderRadius:6,fontSize:11,border:"1px solid var(--border)",background:n.desiredEnabled?"var(--accent)":"var(--bg)",color:n.desiredEnabled?"#fff":"var(--text)",cursor:"pointer"},children:n.desiredEnabled?"Enabled":"Disabled"}),(0,t.jsx)("button",{type:"button",title:"Test connection",onClick:()=>y(n),style:aY,children:"Test"}),(0,t.jsx)("button",{type:"button",title:"Refresh tool catalog",onClick:()=>v(n),style:aY,children:"Refresh"}),(0,t.jsx)("button",{type:"button",title:"Remove binding",onClick:()=>b(n),style:{...aY,color:"#E11D48",borderColor:"var(--border)"},children:"Remove"})]})]}),n.desiredEnabled&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[(0,t.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)"},children:"Selected tools (exact, frozen per Run)"}),j.length>0&&(0,t.jsx)("button",{type:"button",onClick:()=>f(n,j),style:aY,children:"Select all current"})]}),0===j.length?(0,t.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:"No catalog yet — press Refresh to discover tools from the server."}):(0,t.jsxs)("div",{children:[(0,t.jsx)("input",{type:"search",placeholder:"Search tools…",value:i[n.id]??"",onChange:e=>s(t=>({...t,[n.id]:e.target.value})),style:{...aQ,marginBottom:6}}),(0,t.jsx)("div",{style:{maxHeight:220,overflowY:"auto",border:"1px solid var(--border)",borderRadius:6},children:(0,t.jsx)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:11},children:(0,t.jsx)("tbody",{children:j.filter(e=>{let t=(i[n.id]??"").toLowerCase();return!t||e.remoteName.toLowerCase().includes(t)||(e.description??"").toLowerCase().includes(t)}).map(e=>(0,t.jsxs)("tr",{style:{borderBottom:"1px solid var(--border)"},children:[(0,t.jsx)("td",{style:{padding:"5px 8px",width:28},children:(0,t.jsx)("input",{type:"checkbox",checked:k.includes(e.remoteName),onChange:()=>m(n,e.remoteName),style:{accentColor:"var(--accent)"}})}),(0,t.jsx)("td",{style:{padding:"5px 8px",color:"var(--text)",fontWeight:600},children:e.remoteName}),(0,t.jsx)("td",{style:{padding:"5px 8px",color:"var(--text-dim)",maxWidth:260,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.description||"—"})]},e.remoteName))})})})]})]}),a[n.id]&&(0,t.jsxs)("div",{style:{borderTop:"1px solid var(--border)",paddingTop:8,display:"flex",flexDirection:"column",gap:6},children:[(0,t.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:"Credential references (env: / file: / keyring: refs only — values never stored or shown)"}),Object.entries(n.credentialRefs??{}).map(([e,r])=>(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11},children:[(0,t.jsx)("code",{style:{color:"var(--text)",minWidth:120},children:e}),(0,t.jsx)("code",{style:{color:"var(--text-dim)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r}),(0,t.jsx)("button",{type:"button",onClick:()=>x(n,e),style:aY,children:"Remove"})]},e)),0===Object.keys(n.credentialRefs??{}).length&&(0,t.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:"No binding-level credentials. The profile version's defaults apply."}),(0,t.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[(0,t.jsx)("input",{value:o[n.id]??"",onChange:e=>c(t=>({...t,[n.id]:e.target.value})),placeholder:"ENV_NAME",style:{...aQ,width:140}}),(0,t.jsx)("input",{value:d[n.id]??"",onChange:e=>u(t=>({...t,[n.id]:e.target.value})),placeholder:"env:MY_REF / file:... / keyring:...",style:{...aQ,flex:1}}),(0,t.jsx)("button",{type:"button",onClick:()=>g(n),disabled:!(o[n.id]??"").trim()||!(d[n.id]??"").trim(),style:aY,children:"Add"})]})]})]},n.id)}function a1({mcp:e}){let{profiles:n,candidates:r,bindings:i,versions:s,diffView:a,bindCandidate:l,openProfileDiff:o,archiveProfile:c}=e;return 0===r.length&&0===n.length?null:(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{style:{fontSize:12,fontWeight:700,color:"var(--text)",marginBottom:6},children:"Discovered servers"}),(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.map(e=>{let r;return(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,padding:"6px 10px",border:"1px solid var(--border)",borderRadius:6},children:[(0,t.jsxs)("div",{style:{minWidth:0},children:[(0,t.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"var(--text)"},children:e.displayName??e.slug}),(0,t.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",marginLeft:6},children:[e.transport," · ",e.sourceKind]}),"project_file"===e.sourceKind&&(0,t.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:300},children:e.sourceLocator})]}),(0,t.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.alreadyBound?(0,t.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",border:"1px solid var(--border)",borderRadius:4,padding:"2px 8px"},children:"Bound"}):(0,t.jsx)("button",{type:"button",onClick:()=>l(e),style:aY,children:"Bind"}),e.alreadyBound&&e.updateAvailable&&(0,t.jsx)("button",{type:"button",title:"Project file changed; rebind to the new immutable version",onClick:()=>l(e),style:{...aY,color:"var(--accent)",borderColor:"var(--accent)"},children:"Update available"}),e.alreadyBound&&e.updateAvailable&&(0,t.jsx)("button",{type:"button",title:"Show the read-only diff between the bound version and the project file",onClick:()=>o(e),style:aY,children:"View diff"}),"managed"===e.sourceKind&&!e.alreadyBound&&((r=n.find(t=>t.slug===e.slug&&"active"===t.lifecycleStatus))?(0,t.jsx)("button",{type:"button",title:"Archive MCP profile","aria-label":`Archive MCP profile ${r.displayName??r.slug}`,onClick:()=>c(r),style:{...aY,color:"#E11D48",padding:4},children:(0,t.jsx)(b,{size:14,"aria-hidden":"true"})}):null)]})]}),a&&a.slug===e.slug&&(0,t.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:6,padding:8,marginTop:6},children:[(0,t.jsxs)("div",{style:{fontSize:11,fontWeight:700,color:"var(--text)",marginBottom:4},children:["Read-only diff: bound version vs project file",a.digestTo&&(0,t.jsxs)("span",{style:{fontWeight:400,color:"var(--text-dim)",marginLeft:6,fontFamily:"var(--font-mono, monospace)",fontSize:10},children:["new config ",a.digestTo.slice(0,8)]})]}),a.lines.some(e=>e.startsWith("+ ")||e.startsWith("- "))?(0,t.jsx)("div",{style:{maxHeight:200,overflowY:"auto",fontSize:10,fontFamily:"var(--font-mono, monospace)",color:"var(--text-muted)",whiteSpace:"pre-wrap"},children:a.lines.map((e,n)=>(0,t.jsx)("div",{style:{color:e.startsWith("- ")?"#E11D48":e.startsWith("+ ")?"#059669":void 0},children:e},n))}):(0,t.jsxs)("div",{style:{fontSize:10,color:"var(--text-dim)"},children:["Connection fields are unchanged — the project file changed argv, env, headers, or timeout (config digest ",a.digestTo?a.digestTo.slice(0,8):"changed",")."]})]})]},`${e.sourceKind}:${e.slug}`)}),n.filter(e=>!r.some(t=>t.slug===e.slug)).map(e=>{let n=new Set((s[e.id]??[]).map(e=>e.id)),r=i.some(e=>n.has(e.profileVersionId));return(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,padding:"6px 10px",border:"1px solid var(--border)",borderRadius:6},children:[(0,t.jsxs)("div",{style:{minWidth:0},children:[(0,t.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"var(--text)"},children:e.displayName}),(0,t.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",marginLeft:6},children:[e.slug," · v",e.latestVersion??0," · managed"]})]}),(0,t.jsx)("div",{style:{display:"flex",gap:6,alignItems:"center"},children:r?(0,t.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",border:"1px solid var(--border)",borderRadius:4,padding:"2px 8px"},children:"Bound"}):(0,t.jsx)("button",{type:"button",title:"Archive MCP profile","aria-label":`Archive MCP profile ${e.displayName??e.slug}`,onClick:()=>c(e),style:{...aY,color:"#E11D48",padding:4},children:(0,t.jsx)(b,{size:14,"aria-hidden":"true"})})})]},e.id)})]})]})}function a2({projectId:e,setError:r}){let i=function(e,t){let[r,i]=(0,n.useState)([]),[s,a]=(0,n.useState)([]),[l,o]=(0,n.useState)([]),[c,d]=(0,n.useState)({}),[u,p]=(0,n.useState)({}),[h,m]=(0,n.useState)({}),[f,g]=(0,n.useState)({}),[x,y]=(0,n.useState)({}),[v,b]=(0,n.useState)({}),[j,k]=(0,n.useState)(null),[w,S]=(0,n.useState)(!1),[C,N]=(0,n.useState)(!1),[I,T]=(0,n.useState)("stdio"),[M,R]=(0,n.useState)(""),[E,z]=(0,n.useState)(""),[A,P]=(0,n.useState)(""),[$,L]=(0,n.useState)(""),[F,D]=(0,n.useState)(""),_=(0,n.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{try{t[e.id]=await (0,eb.apiFetch)(`/v1/mcp/server-profiles/${e.id}/versions`)}catch{}})),p(t)},[]),O=(0,n.useCallback)(e=>{for(let t of Object.values(u)){let n=t.find(t=>t.id===e.profileVersionId);if(n)return n}},[u]),W=(0,n.useCallback)(e=>{if(e)for(let t of Object.values(u)){let n=t.find(t=>t.id===e);if(n)return n}},[u]),U=(0,n.useCallback)(e=>{let t=W(e.boundVersionId),n=JSON.stringify(t?{transport:t.transport,..."stdio"===t.transport?{executable:t.executable??""}:{endpoint:t.endpoint??""}}:{transport:"(unknown bound version)"},null,2),r=JSON.stringify({transport:e.transport,..."stdio"===e.transport?{executable:e.executable??""}:{endpoint:e.endpoint??""}},null,2);k({slug:e.slug??"",lines:function(e,t){let n=e.split("\n"),r=t.split("\n"),i=[],s=Math.max(n.length,r.length);for(let e=0;e<s;e++){let t=n[e],s=r[e];void 0===t?i.push(`+ ${s}`):void 0===s?i.push(`- ${t}`):t===s?i.push(` ${t}`):(i.push(`- ${t}`),i.push(`+ ${s}`))}return i}(n,r),digestTo:e.configDigest??""})},[W]),q=(0,n.useCallback)(async()=>{if(e){S(!0);try{let[t,n,r]=await Promise.all([(0,eb.apiFetch)("/v1/mcp/server-profiles"),(0,eb.apiFetch)(`/v1/projects/${e}/mcp/bindings`),(0,eb.apiFetch)(`/v1/projects/${e}/mcp/candidates`)]);i(t),o(n),a(r),_(t);let s={};for(let t of n)if(t.desiredEnabled)try{s[t.id]=await (0,eb.apiFetch)(`/v1/projects/${e}/mcp/bindings/${t.id}/catalog`)}catch{}d(s)}catch(e){t(e instanceof Error?e.message:"Failed to load MCP settings")}finally{S(!1)}}},[e,t,_]);(0,n.useEffect)(()=>{let n=!1;if(e)return Promise.all([(0,eb.apiFetch)("/v1/mcp/server-profiles"),(0,eb.apiFetch)(`/v1/projects/${e}/mcp/bindings`),(0,eb.apiFetch)(`/v1/projects/${e}/mcp/candidates`).catch(()=>{throw Error("Failed to load discovered servers")})]).then(async([t,r,s])=>{if(n)return;i(t),o(r),a(s),_(t);let l={};for(let t of r)if(t.desiredEnabled)try{l[t.id]=await (0,eb.apiFetch)(`/v1/projects/${e}/mcp/bindings/${t.id}/catalog`)}catch{}n||d(l)}).catch(e=>{n||t(e instanceof Error?e.message:"Failed to load MCP settings")}),()=>{n=!0}},[e,t,_]);let B=async()=>{try{let e=await (0,eb.apiFetch)("/v1/mcp/server-profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:M,slug:E,sourceKind:"managed"})}),t={transport:I};if("stdio"===I){t.executable=A.trim();let e=$.split(/\s+/).filter(Boolean);e.length>0&&(t.argv=e)}else t.endpoint=F.trim();await (0,eb.apiFetch)(`/v1/mcp/server-profiles/${e.id}/versions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),N(!1),R(""),z(""),P(""),L(""),D(""),await q()}catch(e){t(e instanceof Error?e.message:"Failed to create MCP profile")}},H=async(n,r)=>{if(e)try{await (0,eb.apiFetch)(`/v1/projects/${e}/mcp/bindings/${n.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),await q()}catch(e){t(e instanceof Error?e.message:"Failed to update MCP binding")}},V=async(e,t)=>{let n=e.selectedRemoteToolNames??[],r=n.includes(t)?n.filter(e=>e!==t):[...n,t];await H(e,{selectedRemoteToolNames:r})},K=async(e,t)=>{await H(e,{selectedRemoteToolNames:t.map(e=>e.remoteName)})},J=async e=>{let t=(x[e.id]??"").trim(),n=(v[e.id]??"").trim();if(!t||!n)return;let r={...e.credentialRefs??{}};r[t]=n,await H(e,{credentialRefs:r}),y(t=>({...t,[e.id]:""})),b(t=>({...t,[e.id]:""}))},G=async(e,t)=>{let n={...e.credentialRefs??{}};delete n[t],await H(e,{credentialRefs:n})};return{profiles:r,candidates:s,bindings:l,catalogs:c,versions:u,toolSearch:h,setToolSearch:m,showCreds:f,setShowCreds:g,credEnv:x,setCredEnv:y,credRef:v,setCredRef:b,diffView:j,loading:w,showCreate:C,setShowCreate:N,transport:I,setTransport:T,displayName:M,setDisplayName:R,slug:E,setSlug:z,executable:A,setExecutable:P,argv:$,setArgv:L,endpoint:F,setEndpoint:D,versionFor:O,openProfileDiff:U,createProfile:B,bindCandidate:async n=>{if(e)try{("project_file"!==n.sourceKind||n.boundVersionId||n.updateAvailable)&&n.boundVersionId&&!n.updateAvailable?await (0,eb.apiFetch)(`/v1/projects/${e}/mcp/bindings`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileVersionId:n.boundVersionId})}):await (0,eb.apiFetch)(`/v1/projects/${e}/mcp/bindings/from-candidate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:n.slug,transport:n.transport})}),await q()}catch(e){t(e instanceof Error?e.message:"Failed to bind MCP candidate")}},updateBinding:H,toggleTool:V,selectAllTools:K,addCredential:J,removeCredential:G,testBinding:async n=>{if(e)try{await (0,eb.apiFetch)(`/v1/projects/${e}/mcp/bindings/${n.id}/test`,{method:"POST"}),t(null)}catch(e){t(e instanceof Error?e.message:"Test failed")}},refreshCatalog:async n=>{if(e)try{let r=await (0,eb.apiFetch)(`/v1/projects/${e}/mcp/bindings/${n.id}/catalog/refresh`,{method:"POST"});d(e=>({...e,[n.id]:r})),t(null)}catch(e){t(e instanceof Error?e.message:"Catalog refresh failed")}},removeBinding:async n=>{if(e&&window.confirm("Remove this MCP binding? Tools will no longer be available to Runs."))try{await (0,eb.apiFetch)(`/v1/projects/${e}/mcp/bindings/${n.id}`,{method:"DELETE"}),await q()}catch(e){t(e instanceof Error?e.message:"Failed to remove binding")}},archiveProfile:async e=>{if(e.id&&window.confirm(`Archive MCP profile “${e.displayName??e.slug}”?`))try{await (0,eb.apiFetch)(`/v1/mcp/server-profiles/${encodeURIComponent(e.id)}`,{method:"DELETE"}),t(null),await q()}catch(e){t(e instanceof Error?e.message:"Failed to archive MCP profile")}}}}(e,r);return e?(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{style:{fontSize:13,fontWeight:700,color:"var(--text)"},children:"MCP servers"}),(0,t.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)",marginTop:2},children:"Tools-first client. Servers are discovered, tested, then explicitly enabled per project."})]}),(0,t.jsx)("button",{type:"button",onClick:()=>i.setShowCreate(e=>!e),style:{padding:"5px 10px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:i.showCreate?"Cancel":"+ Add server"})]}),(0,t.jsx)(aX,{mcp:i}),(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[0===i.bindings.length&&!i.loading&&(0,t.jsx)("div",{style:{fontSize:12,color:"var(--text-dim)"},children:"No MCP servers bound to this project yet."}),i.bindings.map(e=>(0,t.jsx)(a0,{mcp:i,binding:e},e.id))]}),(0,t.jsx)(a1,{mcp:i}),i.loading&&(0,t.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:"Loading…"})]}):(0,t.jsx)("div",{style:{fontSize:12,color:"var(--text-dim)"},children:"Open a project to manage MCP servers."})}let a4=o("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),a5={padding:"6px 8px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:12,flex:1,minWidth:180},a6={padding:"3px 8px",borderRadius:6,fontSize:10,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4};function a3(e){let{roots:n,loading:r,control:i}=e,{showRootForm:s,setShowRootForm:a,rootName:l,setRootName:o,rootPreset:c,setRootPreset:d,rootPath:u,setRootPath:p,rootBusy:h,addRoot:f,toggleRoot:g,removeRoot:x}=i;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{style:{fontSize:12,fontWeight:700,color:"var(--text)",marginTop:12,marginBottom:6},children:["Skills roots ",(0,t.jsxs)("span",{style:{fontWeight:400,color:"var(--text-dim)",marginLeft:4},children:[n.length," additional"]})]}),(0,t.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",marginBottom:6},children:"Resolution paths are on the Worker host. Remote clients (Tauri) read the same configured roots — no per-client setup."}),(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[0===n.length&&!r&&(0,t.jsxs)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:["No additional roots. Ennote reads ",(0,t.jsx)("code",{children:"$ENNOTE_HOME/skills"})," on the Worker host by default; add pi, Claude Code, Codex, or Cursor skill directories here."]}),n.map(e=>(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",border:"1px solid var(--border)",borderRadius:6},children:[(0,t.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,t.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"var(--text)"},children:e.name}),(0,t.jsx)("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:8,border:"1px solid var(--border)",color:"var(--text-muted)",flexShrink:0},children:e.agentKind}),(0,t.jsxs)("span",{style:{fontSize:9,color:"var(--text-dim)",flexShrink:0},children:["pri ",e.priority]})]}),(0,t.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",fontFamily:"var(--font-mono, monospace)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:380},children:e.path})]}),(0,t.jsx)("button",{type:"button",onClick:()=>void g(e),disabled:null!==h,style:{fontSize:10,padding:"2px 8px",borderRadius:6,border:"1px solid var(--border)",background:e.enabled?"var(--accent)":"var(--bg)",color:e.enabled?"#fff":"var(--text)",cursor:"pointer",flexShrink:0},children:e.enabled?"Enabled":"Disabled"}),(0,t.jsx)("button",{type:"button",onClick:()=>void x(e),disabled:null!==h,title:`Stop reading skills from ${e.path}`,style:{...a6,color:"#E11D48"},children:(0,t.jsx)(m,{size:12,"aria-hidden":"true"})})]},e.id)),s?(0,t.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:8,padding:10,display:"flex",flexDirection:"column",gap:8},children:[(0,t.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[(0,t.jsxs)("select",{value:c,onChange:e=>d(e.target.value),"aria-label":"Ecosystem preset",style:{...a5,width:130},disabled:!!u.trim(),children:[(0,t.jsx)("option",{value:"pi",children:"pi"}),(0,t.jsx)("option",{value:"claude",children:"Claude Code"}),(0,t.jsx)("option",{value:"codex",children:"Codex"}),(0,t.jsx)("option",{value:"cursor",children:"Cursor"}),(0,t.jsx)("option",{value:"generic",children:"Custom path"})]}),(0,t.jsx)("input",{value:l,onChange:e=>o(e.target.value),placeholder:"Name (defaults to preset)","aria-label":"Root name",style:{...a5,minWidth:140,flex:0}}),(0,t.jsx)("input",{value:u,onChange:e=>p(e.target.value),placeholder:"generic"===c?"/absolute/path/to/skills":"Optional explicit path (else preset)","aria-label":"Root path",style:a5})]}),(0,t.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,t.jsx)("button",{type:"button",onClick:()=>void f(),disabled:null!==h,style:{padding:"4px 12px",borderRadius:6,border:"none",background:"var(--accent)",color:"#fff",fontSize:11,cursor:"pointer"},children:"add"===h?"Adding…":"Add root"}),(0,t.jsx)("button",{type:"button",onClick:()=>a(!1),style:a6,children:"Cancel"})]})]}):(0,t.jsx)("button",{type:"button",onClick:()=>a(!0),style:a6,children:"+ Add skills root"})]})]})}function a9(e){let{projectId:n,projectTrusted:r,query:i,setQuery:s,results:a,searching:l,searched:o,installScope:c,setInstallScope:d,installing:p,onSearch:h,onInstall:m}=e;return(0,t.jsxs)("div",{className:"skills-market-panel",style:{border:"1px solid var(--border)",borderRadius:8,padding:10,display:"flex",flexDirection:"column",gap:8},children:[(0,t.jsx)("div",{style:{fontSize:12,fontWeight:700,color:"var(--text)"},children:"Marketplace"}),(0,t.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[(0,t.jsx)("input",{type:"search",value:i,onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"===e.key&&h()},placeholder:"Search skills.sh…","aria-label":"Search skills.sh",style:a5}),(0,t.jsxs)("select",{value:c,onChange:e=>d(e.target.value),"aria-label":"Install scope",style:{...a5,width:110},children:[(0,t.jsx)("option",{value:"global",children:"Global"}),(0,t.jsxs)("option",{value:"project",disabled:!n||!r,children:["Project",!r&&n?" (needs trust)":""]})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>void h(),disabled:l||!i.trim(),style:{...a6,display:"inline-flex",alignItems:"center",gap:5},children:[(0,t.jsx)(u,{size:13,"aria-hidden":"true"})," ",l?"Searching…":"Search"]})]}),o&&0===a.length&&!l&&(0,t.jsxs)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:['No skills match "',i.trim(),'".']}),a.map(e=>(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",border:"1px solid var(--border)",borderRadius:6},children:[(0,t.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--font-mono, monospace)",fontSize:11,color:"var(--text)"},children:e.package}),e.installs&&(0,t.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",flexShrink:0},children:e.installs}),e.url&&(0,t.jsxs)("a",{href:e.url,target:"_blank",rel:"noreferrer",title:e.url,style:{color:"var(--text-muted)",display:"inline-flex",flexShrink:0},children:[(0,t.jsx)(a4,{size:13,"aria-hidden":"true"}),(0,t.jsxs)("span",{className:"sr-only",children:["Open ",e.package]})]}),(0,t.jsx)("button",{type:"button",disabled:null!==p,onClick:()=>void m(e.package),style:{padding:"3px 10px",borderRadius:6,fontSize:11,border:"none",background:p===e.package?"var(--bg-selected)":"var(--accent)",color:p===e.package?"var(--text)":"#fff",cursor:"pointer",flexShrink:0},children:p===e.package?"Installing…":"Install"})]},e.package))]})}function a8(e){let{installed:n,loading:r,updateKey:i,updates:s,checking:a,toggling:l,removing:o,onCheck:c,onUpdate:d,onToggle:u,onRemove:p}=e;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{style:{fontSize:12,fontWeight:700,color:"var(--text)",marginTop:12,marginBottom:6},children:["Installed ",(0,t.jsx)("span",{style:{fontWeight:400,color:"var(--text-dim)",marginLeft:4},children:n.length})]}),r&&(0,t.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:"Loading…"}),!r&&0===n.length&&(0,t.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:"No installed skills yet — search the marketplace above."}),!r&&n.length>0&&(0,t.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:n.map(e=>{let n=e.install,r=i(n),h=s[r];return(0,t.jsx)("div",{style:{border:"1px solid var(--border)",borderRadius:8,padding:8,display:"flex",flexDirection:"column",gap:6},children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,t.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[(0,t.jsx)("strong",{style:{fontSize:12,color:"var(--text)"},children:e.name}),(0,t.jsx)("span",{className:"skill-row-scope",style:{fontSize:9,padding:"1px 6px",borderRadius:8,border:"1px solid var(--border)",color:"var(--text-muted)",flexShrink:0},children:n.scope}),h?.state==="update-available"&&(0,t.jsx)("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:8,background:"#FFFBEB",border:"1px solid #FDE68A",color:"#92400E",flexShrink:0},children:"Update available"})]}),e.description&&(0,t.jsx)("div",{style:{fontSize:10,color:"var(--text-muted)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:420},children:e.description}),(0,t.jsxs)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2,display:"flex",gap:8,flexWrap:"wrap",alignItems:"center"},children:[(0,t.jsx)("span",{style:{fontFamily:"var(--font-mono, monospace)"},children:n.package}),n.versionHash&&(0,t.jsxs)("span",{style:{fontFamily:"var(--font-mono, monospace)"},children:["v",n.versionHash.slice(0,8)]}),n.skillsShUrl&&(0,t.jsxs)("a",{href:n.skillsShUrl,target:"_blank",rel:"noreferrer",style:{display:"inline-flex",alignItems:"center",gap:3},children:["skills.sh ",(0,t.jsx)(a4,{size:10,"aria-hidden":"true"})]})]})]}),(0,t.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center",flexShrink:0},children:[(0,t.jsx)("button",{type:"button",title:"Allow or block model invocation for this skill",onClick:()=>void u(e),disabled:l===e.relPath,style:{fontSize:10,padding:"2px 8px",borderRadius:6,border:"1px solid var(--border)",background:e.disableModelInvocation?"var(--bg-selected)":"var(--bg)",color:e.disableModelInvocation?"var(--text-dim)":"var(--text)",cursor:"pointer"},children:e.disableModelInvocation?"Disabled":"Enabled"}),(0,t.jsx)("button",{type:"button",title:"Check for updates",onClick:()=>void c(n),disabled:null!==a,style:a6,children:a===r?(0,t.jsx)(i5,{size:12,"aria-hidden":"true",className:"delivery-spinner"}):"Check"}),h?.state==="update-available"&&(0,t.jsx)("button",{type:"button",onClick:()=>void d(n),disabled:null!==a,style:{...a6,color:"#92400E",borderColor:"#FDE68A"},children:"Update"}),h?.state==="up-to-date"&&(0,t.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:"Up to date"}),h?.state==="error"&&h.message&&(0,t.jsx)("span",{style:{fontSize:10,color:"#E11D48",maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:h.message,children:h.message}),h?.state==="unsupported"&&(0,t.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},title:h.message??"",children:"No updates"}),(0,t.jsx)("button",{type:"button",title:"Remove skill",onClick:()=>void p(e),disabled:null!==o,style:{...a6,color:"#E11D48"},children:o===e.relPath?"Removing…":(0,t.jsx)(m,{size:12,"aria-hidden":"true"})})]})]})},`${e.relPath}:${e.skillId}`)})})]})}function a7({local:e}){return 0===e.length?null:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{style:{fontSize:12,fontWeight:700,color:"var(--text)",marginTop:12,marginBottom:6},children:["Catalog ",(0,t.jsx)("span",{style:{fontWeight:400,color:"var(--text-dim)",marginLeft:4},children:e.length})]}),(0,t.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:e.map(e=>(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 8px",border:"1px solid var(--border)",borderRadius:6},children:[(0,t.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:11,color:"var(--text)"},children:e.name}),(0,t.jsx)("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:8,border:"1px solid var(--border)",color:"var(--text-muted)",flexShrink:0},children:e.sourceInfo.scope??"local"}),e.disableModelInvocation&&(0,t.jsx)("span",{style:{fontSize:9,color:"var(--text-dim)",flexShrink:0},children:"invocation disabled"})]},`${e.relPath}:${e.skillId}`))})]})}function le({diagnostics:e}){return 0===e.length?null:(0,t.jsxs)("div",{style:{marginTop:12},children:[(0,t.jsx)("div",{style:{fontSize:11,fontWeight:700,color:"var(--text-muted)",marginBottom:4},children:"Catalog diagnostics"}),(0,t.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:e.map((e,n)=>(0,t.jsxs)("div",{style:{fontSize:10,color:"skip"===e.level?"#92400E":"var(--text-dim)",fontFamily:"var(--font-mono, monospace)"},children:["[",e.level,"] ",e.relPath?`${e.relPath}: `:"",e.message]},n))})]})}function lt({projectId:e,setError:r}){let i=function(e,t){let[r,i]=(0,n.useState)([]),[s,a]=(0,n.useState)([]),[l,o]=(0,n.useState)(!1),[c,d]=(0,n.useState)(!1),[u,p]=(0,n.useState)([]),h=(0,n.useCallback)(async()=>{d(!0);try{let n=e?`?projectID=${encodeURIComponent(e)}`:"",r=await (0,eb.apiFetch)(`/v1/skills${n}`);i(r.skills??[]),a(r.diagnostics??[]),o(!!r.projectResourcesLoaded);let s=await (0,eb.apiFetch)("/v1/skills/roots");p(s.items??[]),t(null)}catch(e){t(e instanceof Error?e.message:"Failed to load skills")}finally{d(!1)}},[e,t]);return(0,n.useEffect)(()=>{let e=window.setTimeout(()=>void h(),0);return()=>window.clearTimeout(e)},[h]),{skills:r,setSkills:i,diagnostics:s,projectTrusted:l,loading:c,roots:u,setRoots:p,load:h}}(e,r),s=function(e,t,r){let[i,s]=(0,n.useState)(!1),[a,l]=(0,n.useState)(""),[o,c]=(0,n.useState)("pi"),[d,u]=(0,n.useState)(""),[p,h]=(0,n.useState)(null),m=(0,n.useCallback)(async()=>{h("add");try{await (0,eb.apiFetch)("/v1/skills/roots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a.trim()||o,agentKind:d.trim()?"generic":o,path:d.trim()||void 0})}),l(""),u(""),s(!1),r(null),await t()}catch(e){r(e instanceof Error?e.message:"Failed to add skill root")}finally{h(null)}},[a,o,d,r,t]);return{showRootForm:i,setShowRootForm:s,rootName:a,setRootName:l,rootPreset:o,setRootPreset:c,rootPath:d,setRootPath:u,rootBusy:p,addRoot:m,toggleRoot:(0,n.useCallback)(async n=>{h(n.id);try{let i=await (0,eb.apiFetch)(`/v1/skills/roots/${n.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!n.enabled})});e(e=>e.map(e=>e.id===n.id?i:e)),r(null),await t()}catch(e){r(e instanceof Error?e.message:"Toggle failed")}finally{h(null)}},[e,r,t]),removeRoot:(0,n.useCallback)(async n=>{if(window.confirm(`Stop reading skills from "${n.path}"?`)){h(n.id);try{await (0,eb.apiFetch)(`/v1/skills/roots/${n.id}`,{method:"DELETE"}),e(e=>e.filter(e=>e.id!==n.id)),r(null),await t()}catch(e){r(e instanceof Error?e.message:"Remove failed")}finally{h(null)}}},[e,r,t])}}(i.setRoots,i.load,r),a=function(e,t,r,i){let[s,a]=(0,n.useState)(""),[l,o]=(0,n.useState)([]),[c,d]=(0,n.useState)(!1),[u,p]=(0,n.useState)(!1),[h,m]=(0,n.useState)("global"),[f,g]=(0,n.useState)(null),x=(0,n.useCallback)(async()=>{let e=s.trim();if(e){d(!0);try{let t=await (0,eb.apiFetch)(`/v1/skills/search?q=${encodeURIComponent(e)}&limit=20`);o(t.results??[]),p(!0),i(null)}catch(e){i(e instanceof Error?e.message:"Search failed")}finally{d(!1)}}},[s,i]),y=(0,n.useCallback)(async n=>{if("project"===h&&!t)return void i("Project resources must be trusted before installing project skills.");g(n);try{await (0,eb.apiFetch)("/v1/skills/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({package:n,scope:h,..."project"===h&&e?{projectId:e}:{}})}),i(null),o(e=>e.filter(e=>e.package!==n)),await r()}catch(e){i(e instanceof Error?e.message:"Install failed")}finally{g(null)}},[h,t,e,i,r]);return{query:s,setQuery:a,results:l,searching:c,searched:u,installScope:h,setInstallScope:m,installing:f,search:x,install:y}}(e,i.projectTrusted,i.load,r),l=function(e,t,r,i){let[s,a]=(0,n.useState)({}),[l,o]=(0,n.useState)(null),[c,d]=(0,n.useState)(null),[u,p]=(0,n.useState)(null),h=(0,n.useCallback)(e=>`${e.scope}\u0000${e.package}`,[]),m=(0,n.useCallback)(async t=>{o(h(t));try{let n=await (0,eb.apiFetch)("/v1/skills/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({package:t.package,scope:t.scope,..."project"===t.scope&&e?{projectId:e}:{}})});a(e=>{let t={...e};for(let e of n.updates??[])t[h(e)]=e;return t}),i(null)}catch(e){i(e instanceof Error?e.message:"Update check failed")}finally{o(null)}},[e,i,h]),f=(0,n.useCallback)(async t=>{let n=h(t);o(n);try{await (0,eb.apiFetch)("/v1/skills/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({package:t.package,scope:t.scope,..."project"===t.scope&&e?{projectId:e}:{}})}),i(null),a(e=>{let t={...e};return delete t[n],t}),await r()}catch(e){i(e instanceof Error?e.message:"Update failed")}finally{o(null)}},[e,i,h,r]);return{updateKey:h,updates:s,checking:l,toggling:c,removing:u,check:m,update:f,toggle:(0,n.useCallback)(async e=>{d(e.relPath);try{await (0,eb.apiFetch)(`/v1/skills/disabled/${e.relPath}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabled:!e.disableModelInvocation})}),t(t=>t.map(t=>t.relPath===e.relPath?{...t,disableModelInvocation:!e.disableModelInvocation}:t)),i(null)}catch(e){i(e instanceof Error?e.message:"Toggle failed")}finally{d(null)}},[t,i]),remove:(0,n.useCallback)(async e=>{if(window.confirm(`Remove the skill "${e.name}"?`)){p(e.relPath);try{await (0,eb.apiFetch)(`/v1/skills/remove/${e.relPath}`,{method:"POST"}),t(t=>t.filter(t=>t.relPath!==e.relPath)),i(null)}catch(e){i(e instanceof Error?e.message:"Remove failed")}finally{p(null)}}},[t,i])}}(e,i.setSkills,i.load,r),o=i.skills.filter(e=>!!e.install),c=i.skills.filter(e=>!e.install);return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-skills-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-skills-heading",children:"Skills"}),(0,t.jsx)("p",{children:"Marketplace installs, catalog browsing, and per-skill invocation control."})]}),(0,t.jsx)(a3,{roots:i.roots,loading:i.loading,control:s}),(0,t.jsx)(a9,{projectId:e,projectTrusted:i.projectTrusted,query:a.query,setQuery:a.setQuery,results:a.results,searching:a.searching,searched:a.searched,installScope:a.installScope,setInstallScope:a.setInstallScope,installing:a.installing,onSearch:a.search,onInstall:a.install}),(0,t.jsx)(a8,{installed:o,loading:i.loading,updateKey:l.updateKey,updates:l.updates,checking:l.checking,toggling:l.toggling,removing:l.removing,onCheck:l.check,onUpdate:l.update,onToggle:l.toggle,onRemove:l.remove}),(0,t.jsx)(a7,{local:c}),(0,t.jsx)(le,{diagnostics:i.diagnostics})]})}function ln({configured:e,missing:n}){let r=(0,f.useT)();return e?(0,t.jsx)("span",{role:"img","aria-label":r("settings.models.credentialConfigured"),title:r("settings.models.credentialConfigured"),style:{width:8,height:8,borderRadius:"50%",background:"#2f9e44",display:"inline-block",flexShrink:0}}):n?(0,t.jsx)("span",{role:"img","aria-label":r("settings.models.credentialMissing"),title:r("settings.models.credentialMissing"),style:{width:8,height:8,borderRadius:"50%",background:"var(--stg-danger)",display:"inline-block",flexShrink:0}}):null}let lr=o("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),li=o("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);function ls({value:e,onChange:r,placeholder:i}){let[s,a]=(0,n.useState)(!1);return(0,t.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4,minWidth:0},children:[(0,t.jsx)("input",{type:s?"text":"password",value:e,placeholder:i,autoComplete:"off",spellCheck:!1,onChange:e=>r(e.target.value),style:{flex:1,minWidth:0,height:30,padding:"0 8px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg)",color:"var(--text)",font:"12px var(--font-mono)"}}),(0,t.jsx)("button",{type:"button",title:s?"Hide key":"Show key","aria-label":s?"Hide key":"Show key",onClick:()=>a(e=>!e),style:{display:"grid",placeItems:"center",width:28,height:30,padding:0,border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer",flexShrink:0},children:s?(0,t.jsx)(li,{size:13,"aria-hidden":"true"}):(0,t.jsx)(lr,{size:13,"aria-hidden":"true"})})]})}function la(e){return{id:e.modelName,...e.displayName?{name:e.displayName}:{},...e.contextWindow?{contextWindow:e.contextWindow}:{},...e.maxOutputTokens?{maxTokens:e.maxOutputTokens}:{}}}function ll({probe:e,existingIds:r,onAdopt:i,onError:s,disabled:a}){let l=(0,f.useT)(),[o,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(null),[p,h]=(0,n.useState)(!1),[m,g]=(0,n.useState)(new Set),x=async()=>{h(!0),u(null);try{let t=await (0,eb.apiFetch)("/v1/provider-profiles/discover-models",{method:"POST",body:JSON.stringify({baseUrl:e.baseUrl||void 0,apiKey:e.apiKey||void 0})})??[],n=new Set(r);u(t),g(new Set(t.filter(e=>!n.has(e.modelName)).map(e=>e.modelName))),c(!0)}catch(e){s?.(e.message)}finally{h(!1)}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",style:{minHeight:26,height:26,padding:"0 10px",borderRadius:13,fontSize:11,marginLeft:"auto"},disabled:a||p,onClick:()=>{x()},children:l(p?"settings.models.fetching":"settings.models.fetchModels")}),o&&d&&(0,t.jsx)("div",{className:"settings-overlay",style:{display:"grid",placeItems:"center"},role:"dialog","aria-modal":"true","aria-label":l("settings.models.fetchTitle"),children:(0,t.jsxs)("div",{className:"project-create-dialog",style:{maxWidth:420},children:[(0,t.jsxs)("div",{className:"project-create-header",children:[(0,t.jsx)("span",{children:l("settings.models.fetchTitle")}),(0,t.jsx)("button",{type:"button",className:"follow-up-close","aria-label":l("settings.models.close"),title:l("settings.models.close"),onClick:()=>{c(!1),u(null)},children:"✕"})]}),(0,t.jsxs)("div",{className:"project-create-form",children:[(0,t.jsx)("p",{style:{margin:0,fontSize:12,lineHeight:"18px",color:"var(--stg-text-secondary)"},children:l("settings.models.fetchDescription")}),(0,t.jsx)("div",{style:{maxHeight:240,overflowY:"auto",border:"1px solid var(--stg-border-l2)",borderRadius:6},children:d.map(e=>(0,t.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",borderBottom:"1px solid var(--stg-border-l2)",fontSize:12,cursor:"pointer"},children:[(0,t.jsx)("input",{type:"checkbox",checked:m.has(e.modelName),onChange:()=>{g(t=>{let n=new Set(t);return n.delete(e.modelName)||n.add(e.modelName),n})}}),(0,t.jsx)("code",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.modelName})]},e.modelName))}),(0,t.jsxs)("div",{className:"project-create-actions",style:{justifyContent:"flex-end"},children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",onClick:()=>{c(!1),u(null)},children:l("settings.models.cancel")}),(0,t.jsx)("button",{type:"button",className:"project-create-submit",onClick:()=>{d&&(i(d.filter(e=>m.has(e.modelName)).map(la)),c(!1),u(null))},children:l("settings.models.fetchAdopt")})]})]})]})})]})}function lo(e){let t=e.trim();return 0===t.length?0===e.length?void 0:"keyBlank":/[^\x21-\x7E]/.test(t)||/^[A-Za-z_][A-Za-z0-9_]*=/.test(t)||t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?"keyIllegalCharacters":void 0}async function lc(e){for(let t of(await (0,eb.apiFetch)("/v1/provider-profiles",{method:"POST",body:JSON.stringify({key:e.key,name:e.name,providerType:e.providerType,baseUrl:e.baseUrl,apiKey:e.apiKey||void 0})}),e.models)){let n=String(t.id??"").trim();0!==n.length&&await (0,eb.apiFetch)("/v1/model-profiles",{method:"POST",body:JSON.stringify({providerId:e.key,modelName:n,..."string"==typeof t.name&&t.name.length>0?{displayName:t.name}:{},contextWindow:"number"==typeof t.contextWindow?t.contextWindow:131072,maxOutputTokens:"number"==typeof t.maxTokens?t.maxTokens:16384,supportsToolUse:!0})})}}function ld(e){if(void 0===e)return;let t=Array.isArray(e)?e.map(e=>"object"!=typeof e||null===e||Array.isArray(e)?{}:e):[],n=new Set;for(let[e,r]of t.entries()){let t=r.id,i="string"==typeof t?t.trim():void 0;if(void 0===i||0===i.length)return{index:e,key:"modelIdRequired"};if(n.has(i))return{index:e,key:"modelIdDuplicate"};n.add(i);let s=r.name;if(void 0!==s&&("string"!=typeof s||0===s.length))return{index:e,key:"modelNameInvalid"};let a=r.contextWindow;if(void 0!==a&&("number"!=typeof a||!Number.isInteger(a)||a<=0))return{index:e,key:"modelContextInvalid"};let l=r.maxTokens;if(void 0!==l&&("number"!=typeof l||!Number.isInteger(l)||l<=0))return{index:e,key:"modelMaxTokensInvalid"}}}let lu=/^(\d+(?:\.\d+)?)([km])?$/i,lp={k:1e3,m:1e6};function lh(e,t){let n=e[t];return"string"==typeof n?n:""}function lm({models:e,onChange:r,overridden:i,onReset:s,disabled:a}){let l=(0,f.useT)(),[o,c]=(0,n.useState)(()=>new Set),[d,u]=(0,n.useState)(()=>new Map),p=(e,t)=>`${String(e)}:${t}`,h=(t,n)=>{r(e.map((e,r)=>{if(r!==t)return e;let i=new Set(Object.entries(n).filter(([,e])=>void 0===e||""===e).map(([e])=>e));return Object.fromEntries(Object.entries({...e,...n}).filter(([e])=>!i.has(e)))}))},m=(e,t,n)=>{u(r=>new Map(r).set(p(e,t),n)),h(e,{[t]:function(e){let t=e.trim();if(0===t.length)return;let n=lu.exec(t);if(null===n)return NaN;let r=n[2]?.toLowerCase(),i="k"===r||"m"===r?lp[r]:1,s=Number(n[1])*i,a=Math.round(s);return 1e-6>Math.abs(s-a)?a:s}(n)})},g=(e,t,n)=>{let r,i=d.get(p(t,n));if(void 0!==i)return i;let s="number"==typeof(r=e[n])?r:void 0;return void 0===s?"":!Number.isInteger(s)||s<=0?String(s):s%lp.m==0?`${String(s/lp.m)}M`:s%lp.k==0?`${String(s/lp.k)}K`:String(s)},y={height:30,padding:"0 8px",border:"1px solid var(--stg-border-l2)",borderRadius:6,background:"var(--stg-input-fill)",color:"var(--stg-text-primary)",font:"13px/20px var(--font-sans)",minWidth:0},v={display:"grid",placeItems:"center",width:28,height:28,padding:0,flexShrink:0,border:"1px solid var(--stg-border-l2)",borderRadius:6,background:"transparent",color:"var(--stg-text-secondary)",cursor:"pointer"};return(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,t.jsx)("span",{style:{fontSize:12,fontWeight:500,color:"var(--stg-text-primary)"},children:l("settings.models.models")}),void 0!==i&&(0,t.jsx)("span",{style:{fontSize:11,color:"var(--stg-text-tertiary)"},children:i?l("settings.models.modelsCustomized"):l("settings.models.modelsInherited")}),!0===i&&void 0!==s&&(0,t.jsx)("button",{type:"button",className:"secondary-btn",style:{minHeight:26,height:26,padding:"0 10px",borderRadius:13,fontSize:11,marginLeft:"auto"},disabled:a,onClick:s,children:l("settings.models.resetModels")})]}),0===e.length&&(0,t.jsx)("p",{style:{margin:0,fontSize:12,lineHeight:"18px",color:"var(--stg-text-tertiary)"},children:l("settings.models.modelsEmpty")}),e.map((n,i)=>(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,padding:"6px 0"},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,t.jsx)("input",{type:"text",value:lh(n,"id"),placeholder:l("settings.models.modelId"),"aria-label":`${l("settings.models.modelId")} ${i+1}`,disabled:a,style:{...y,flex:1},onChange:e=>{h(i,{id:e.target.value})}}),(0,t.jsx)("input",{type:"text",value:lh(n,"name"),placeholder:l("settings.models.modelName"),"aria-label":`${l("settings.models.modelName")} ${i+1}`,disabled:a,style:{...y,flex:1},onChange:e=>{h(i,{name:""===e.target.value?void 0:e.target.value})}}),(0,t.jsx)("button",{type:"button","aria-label":`${l("settings.models.modelAdvanced")} ${i+1}`,"aria-expanded":o.has(i),title:l("settings.models.modelAdvanced"),style:v,onClick:()=>{c(e=>{let t=new Set(e);return t.delete(i)||t.add(i),t})},children:o.has(i)?(0,t.jsx)(q,{size:13,"aria-hidden":"true"}):(0,t.jsx)(aA,{size:13,"aria-hidden":"true"})}),(0,t.jsx)("button",{type:"button","aria-label":`${l("settings.models.removeModel")} ${i+1}`,title:l("settings.models.removeModel"),disabled:a,style:{...v,color:"var(--stg-danger)"},onClick:()=>{r(e.filter((e,t)=>t!==i)),c(e=>{let t=new Set;for(let n of e)n<i?t.add(n):n>i&&t.add(n-1);return t}),u(e=>((e,t)=>{let n=new Map;for(let[r,i]of e){let e=Number(r.slice(0,r.indexOf(":")));e!==t&&n.set(e>t?r.replace(/^\d+/,String(e-1)):r,i)}return n})(e,i))},children:(0,t.jsx)(S,{size:13,"aria-hidden":"true"})})]}),o.has(i)&&(0,t.jsxs)("div",{style:{display:"flex",gap:8,paddingLeft:2},children:[(0,t.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:1,fontSize:11,color:"var(--stg-text-secondary)"},children:[l("settings.models.contextWindow"),(0,t.jsx)("input",{type:"text",inputMode:"numeric",value:g(n,i,"contextWindow"),placeholder:"256K","aria-label":`${l("settings.models.contextWindow")} ${i+1}`,disabled:a,style:y,onChange:e=>{m(i,"contextWindow",e.target.value)}})]}),(0,t.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:1,fontSize:11,color:"var(--stg-text-secondary)"},children:[l("settings.models.maxTokens"),(0,t.jsx)("input",{type:"text",inputMode:"numeric",value:g(n,i,"maxTokens"),placeholder:"32K","aria-label":`${l("settings.models.maxTokens")} ${i+1}`,disabled:a,style:y,onChange:e=>{m(i,"maxTokens",e.target.value)}})]})]})]},i)),(0,t.jsxs)("button",{type:"button",className:"secondary-btn",style:{alignSelf:"flex-start",minHeight:28,height:28,padding:"0 12px",borderRadius:14,fontSize:12,display:"inline-flex",alignItems:"center",gap:5},disabled:a,onClick:()=>{r([...e,{id:""}])},children:[(0,t.jsx)(x,{size:13,"aria-hidden":"true"}),l("settings.models.addModel")]})]})}let lf=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,lg=["openai-compatible","anthropic"],lx={height:32,padding:"0 10px",border:"1px solid var(--stg-border-l2)",borderRadius:8,background:"var(--stg-input-fill)",color:"var(--stg-text-primary)",font:"14px/22px var(--font-sans)",minWidth:0};function ly({taken:e,onClose:r,refresh:i,setError:s,onSaved:a}){let l,o=(0,f.useT)(),[c,d]=(0,n.useState)(""),[u,p]=(0,n.useState)(""),[h,m]=(0,n.useState)(""),[g,x]=(0,n.useState)(lg[0]),[y,v]=(0,n.useState)(""),[b,j]=(0,n.useState)([]),[k,w]=(0,n.useState)(!1),[S,C]=(0,n.useState)(void 0),N=c.length>0&&!lf.test(c),I=e.includes(c),T=ld(b),M=lo(y),R=y.trim(),E=c.length>0&&!N&&!I&&h.trim().length>0&&b.length>0&&void 0===T&&void 0===M;async function z(){w(!0),C(void 0);try{await lc({key:c,name:u.trim()||c,providerType:g,baseUrl:h.trim(),apiKey:R||void 0,models:b}),s(null),a?.(u.trim()||c),await i(),r(!0)}catch(e){C(e.message)}finally{w(!1)}}return void 0!==S||E||N||I||void 0!==M||(0===c.length?l=o("settings.models.customRouteHint"):0===h.trim().length?l=o("settings.models.customNeedsBaseUrl"):0===b.length?l=o("settings.models.customNeedsModels"):void 0!==T&&(l=`${o("settings.models.model")} ${T.index+1}: ${o(`settings.models.${T.key}`)}`)),(0,t.jsxs)("div",{className:"settings-row provider-settings-row",style:{flexDirection:"column",gap:12},children:[(0,t.jsx)("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:(0,t.jsx)("strong",{style:{fontSize:14,fontWeight:500},children:o("settings.models.customTitle")})}),(0,t.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4,fontSize:12,color:"var(--stg-text-secondary)"},children:[o("settings.models.customRoute"),(0,t.jsx)("input",{type:"text",value:c,placeholder:"acme-gateway",disabled:k,style:lx,"aria-label":o("settings.models.customRoute"),onChange:e=>{d(e.target.value)}}),N||I?(0,t.jsx)("span",{style:{fontSize:11,color:"var(--stg-danger)"},children:o(N?"settings.models.customRouteInvalid":"settings.models.customRouteTaken")}):(0,t.jsx)("span",{style:{fontSize:11,color:"var(--stg-text-tertiary)"},children:o("settings.models.customRouteHint")})]}),(0,t.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4,fontSize:12,color:"var(--stg-text-secondary)"},children:[o("settings.models.customDisplayName"),(0,t.jsx)("input",{type:"text",value:u,placeholder:0===c.length?o("settings.models.customDisplayName"):c,disabled:k,style:lx,"aria-label":o("settings.models.customDisplayName"),onChange:e=>{p(e.target.value)}})]}),(0,t.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4,fontSize:12,color:"var(--stg-text-secondary)"},children:[o("settings.models.baseUrl"),(0,t.jsx)("input",{type:"text",value:h,placeholder:"https://gateway.example/v1",disabled:k,style:lx,"aria-label":o("settings.models.baseUrl"),onChange:e=>{m(e.target.value)}})]}),(0,t.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4,fontSize:12,color:"var(--stg-text-secondary)"},children:[o("settings.models.customApi"),(0,t.jsx)("select",{value:g,disabled:k,style:lx,"aria-label":o("settings.models.customApi"),onChange:e=>{x(e.target.value)},children:lg.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]}),(0,t.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4,fontSize:12,color:"var(--stg-text-secondary)"},children:[o("settings.models.keyInput"),(0,t.jsx)(ls,{value:y,onChange:v,placeholder:o("settings.models.keyPlaceholder")}),void 0===M?null:(0,t.jsx)("span",{style:{fontSize:11,color:"var(--stg-danger)"},children:o(`settings.models.${M}`)})]}),(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,t.jsx)("span",{style:{fontSize:12,fontWeight:500,color:"var(--stg-text-primary)"},children:o("settings.models.models")}),(0,t.jsx)(ll,{probe:{baseUrl:h.trim(),apiKey:R},existingIds:b.map(e=>String(e.id??"").trim()),onAdopt:e=>{let t=new Map(b.map(e=>[String(e.id??"").trim(),e]));for(let n of e)t.set(String(n.id??"").trim(),t.get(String(n.id??"").trim())??n);j([...t.values()])},onError:C,disabled:k})]}),(0,t.jsx)(lm,{models:b,onChange:j,disabled:k}),void 0!==S?(0,t.jsx)("span",{style:{fontSize:12,color:"var(--stg-danger)"},children:S}):null,void 0===l?null:(0,t.jsx)("span",{style:{fontSize:11,color:"var(--stg-text-tertiary)"},children:l}),(0,t.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",disabled:k,onClick:()=>r(!1),children:o("settings.models.cancel")}),(0,t.jsx)("button",{type:"button",className:"settings-form button",disabled:k||!E,style:{minHeight:36,padding:"0 14px",border:"none",borderRadius:18,background:"var(--stg-brand)",color:"#fff",fontWeight:500,cursor:"pointer"},onClick:()=>{z()},children:o(k?"settings.models.creating":"settings.models.create")})]})]})}function lv({open:e,providerName:n,busy:r,failure:i,onCancel:s,onConfirm:a}){let l=(0,f.useT)();if(!e)return null;let o=l("settings.models.deleteTitle").replace("{provider}",n),c=l("settings.models.deleteDescriptionWithCredential").replace("{provider}",n),d=l("settings.models.deleteConfirm").replace("{provider}",n),u=l("settings.models.deleting").replace("{provider}",n);return(0,t.jsx)("div",{className:"settings-overlay",style:{display:"grid",placeItems:"center"},role:"dialog","aria-modal":"true","aria-label":o,children:(0,t.jsxs)("div",{className:"project-create-dialog",style:{maxWidth:420},children:[(0,t.jsxs)("div",{className:"project-create-header",children:[(0,t.jsx)("span",{children:o}),(0,t.jsx)("button",{type:"button",className:"follow-up-close","aria-label":l("settings.models.close"),title:l("settings.models.close"),onClick:s,children:"✕"})]}),(0,t.jsxs)("div",{className:"project-create-form",children:[(0,t.jsx)("p",{style:{margin:0,fontSize:13,lineHeight:"20px",color:"var(--stg-text-secondary)"},children:c}),i&&(0,t.jsx)("p",{style:{margin:0,fontSize:12,lineHeight:"18px",color:"var(--stg-danger)"},children:i}),(0,t.jsxs)("div",{className:"project-create-actions",style:{justifyContent:"flex-end"},children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",disabled:r,onClick:s,children:l("settings.models.cancel")}),(0,t.jsx)("button",{type:"button",className:"project-create-submit",disabled:r,onClick:a,children:r?u:d})]})]})]})})}function lb(e,t){let n=e[t];return"string"==typeof n&&n.trim().length>0?n.trim():void 0}function lj(e,t){let n=e[t];return"number"==typeof n?n:void 0}let lk={height:32,padding:"0 10px",border:"1px solid var(--stg-border-l2)",borderRadius:8,background:"var(--stg-input-fill)",color:"var(--stg-text-primary)",font:"14px/22px var(--font-sans)",minWidth:0};function lw(e){return("string"==typeof e.id?e.id:"").trim()}async function lS(e){for(let t of e.toDelete)await (0,eb.apiFetch)(`/v1/model-profiles/${encodeURIComponent(t)}`,{method:"DELETE"});for(let{id:t,input:n}of e.toUpdate)await (0,eb.apiFetch)(`/v1/model-profiles/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(n)});for(let t of e.toCreate)await (0,eb.apiFetch)("/v1/model-profiles",{method:"POST",body:JSON.stringify(t)})}function lC({provider:e,models:r,creating:i,hideTitle:s,onClose:a,refresh:l,setError:o,onSaved:c}){let d=(0,f.useT)(),[u,p]=(0,n.useState)(""),[h,m]=(0,n.useState)(e.baseUrl??""),[g,x]=(0,n.useState)(e.name??""),[y,v]=(0,n.useState)(()=>i?[]:r.map(e=>({id:e.modelName,...e.displayName&&e.displayName!==e.modelName?{name:e.displayName}:{},contextWindow:e.contextWindow,maxTokens:e.maxOutputTokens}))),[b,j]=(0,n.useState)(!1),[k,w]=(0,n.useState)(void 0),S=lo(u),C=ld(y),N=u.trim(),I=r.map(e=>({id:e.id,modelName:e.modelName,displayName:e.displayName,contextWindow:e.contextWindow,maxOutputTokens:e.maxOutputTokens}));async function T(){j(!0),w(void 0);try{if(i)await lc({key:e.id,name:g.trim()||e.name,providerType:e.providerType,baseUrl:h.trim()||e.baseUrl,apiKey:N||void 0,models:y});else{await (0,eb.apiFetch)(`/v1/provider-profiles/${encodeURIComponent(e.id)}`,{method:"PUT",body:JSON.stringify({name:g.trim()||void 0,baseUrl:h.trim()||void 0,apiKey:N||void 0})});let t=function(e,t,n,r=131072,i=16384){let s={toCreate:[],toDelete:[],toUpdate:[]},a=new Map(t.map(e=>[e.modelName,e])),l=new Set;for(let t of n){var o,c;let n=lb(t,"id");if(void 0===n)continue;l.add(n);let d=a.get(n);if(void 0===d){s.toCreate.push({providerId:e,modelName:n,...void 0===lb(t,"name")?{}:{displayName:lb(t,"name")},contextWindow:lj(t,"contextWindow")??r,maxOutputTokens:lj(t,"maxTokens")??i,supportsToolUse:!0});continue}o=t,c=d,(lb(o,"name")!==(c.displayName&&c.displayName!==c.modelName?c.displayName:void 0)||lj(o,"contextWindow")!==c.contextWindow||lj(o,"maxTokens")!==c.maxOutputTokens)&&s.toUpdate.push({id:d.id,input:{displayName:lb(t,"name")??null,contextWindow:lj(t,"contextWindow")??null,maxOutputTokens:lj(t,"maxTokens")??null}})}for(let e of t)l.has(e.modelName)||s.toDelete.push(e.id);return s}(e.id,I,y);await lS(t)}o(null),c?.(g.trim()||e.name),await l(),a(!0)}catch(e){w(e.message)}finally{j(!1)}}let M=b||void 0!==S||void 0!==C;return(0,t.jsxs)("div",{className:"settings-row provider-settings-row",style:{flexDirection:"column",gap:12},children:[!s&&(0,t.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[(0,t.jsx)("strong",{style:{fontSize:14,fontWeight:500},children:e.name}),e.name!==e.id&&(0,t.jsx)("span",{style:{fontSize:11,color:"var(--stg-text-tertiary)"},children:e.id})]}),(0,t.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4,fontSize:12,color:"var(--stg-text-secondary)"},children:[d("settings.models.keyInput"),(0,t.jsx)(ls,{value:u,onChange:p,placeholder:d(e.credentialConfigured?"settings.models.keyStored":"settings.models.keyPlaceholder")}),void 0===S?null:(0,t.jsx)("span",{style:{fontSize:11,color:"var(--stg-danger)"},children:d(`settings.models.${S}`)})]}),(0,t.jsxs)("details",{style:{fontSize:12},children:[(0,t.jsx)("summary",{style:{cursor:"pointer",color:"var(--stg-text-secondary)",fontWeight:500,fontSize:12},children:d("settings.models.customized")}),(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10,paddingTop:10},children:[e.custom&&(0,t.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4,fontSize:12,color:"var(--stg-text-secondary)"},children:[d("settings.models.customDisplayName"),(0,t.jsx)("input",{type:"text",value:g,disabled:b,style:lk,"aria-label":d("settings.models.customDisplayName"),onChange:e=>{x(e.target.value)}})]}),(0,t.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4,fontSize:12,color:"var(--stg-text-secondary)"},children:[d("settings.models.baseUrl"),(0,t.jsx)("input",{type:"text",value:h,disabled:b,style:lk,"aria-label":d("settings.models.baseUrl"),onChange:e=>{m(e.target.value)}})]}),(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,t.jsx)("span",{style:{fontSize:12,fontWeight:500,color:"var(--stg-text-primary)"},children:d("settings.models.models")}),i&&0===y.length&&(0,t.jsx)("span",{style:{fontSize:11,color:"var(--stg-text-tertiary)"},children:d("settings.models.modelsInherited")}),(0,t.jsx)(ll,{probe:{baseUrl:h.trim(),apiKey:N},existingIds:y.map(lw),onAdopt:e=>{let t=new Map(y.map(e=>[lw(e),e]));for(let n of e)t.set(lw(n),t.get(lw(n))??n);v([...t.values()])},onError:w,disabled:b})]}),(0,t.jsx)(lm,{models:y,onChange:v,disabled:b})]})]}),void 0!==k?(0,t.jsx)("span",{style:{fontSize:12,color:"var(--stg-danger)"},children:k}):null,(0,t.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[(0,t.jsx)("button",{type:"button",className:"secondary-btn",disabled:b,onClick:()=>a(!1),children:d("settings.models.cancel")}),(0,t.jsx)("button",{type:"button",disabled:M,style:{minHeight:36,padding:"0 14px",border:"none",borderRadius:18,background:"var(--stg-brand)",color:"#fff",fontWeight:500,cursor:"pointer",opacity:M?.5:1},onClick:()=>{T()},children:d(b?i?"settings.models.creating":"settings.models.applying":i?"settings.models.create":"settings.models.apply")})]})]})}function lN({providers:e,models:r,refresh:i,setError:s}){let a=(0,f.useT)(),[l,o]=(0,n.useState)(null),[c,d]=(0,n.useState)(!1),[u,p]=(0,n.useState)(!1),[h,m]=(0,n.useState)(null),[g,x]=(0,n.useState)(!1),[y,v]=(0,n.useState)(void 0),[b,j]=(0,n.useState)(null),[k,w]=(0,n.useState)(()=>new Set),S=e.some(e=>e.credentialConfigured),C=e.filter(e=>e.directory),N=c?e.find(e=>e.directory&&e.id===l)??null:null,I=e=>{j(e)},T=async()=>{if(null!==h&&!g){x(!0),v(void 0);try{await (0,eb.apiFetch)(`/v1/provider-profiles/${encodeURIComponent(h.id)}`,{method:"DELETE"}),s(null),m(null),await i()}catch(e){v(e.message)}finally{x(!1)}}};return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-models-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-models-heading",children:a("settings.models.title")}),(0,t.jsx)("p",{children:a("settings.models.intro")})]}),null!==b&&(0,t.jsx)("p",{className:"settings-models-saved",role:"status","aria-live":"polite",children:a("settings.models.savedProvider").replace("{provider}",b)}),(0,t.jsx)("ul",{className:"settings-models-rows",children:e.map(e=>{if(!S&&e.directory&&!k.has(e.id))return(0,t.jsx)("li",{className:"settings-models-setupcard",children:(0,t.jsx)(lC,{provider:e,models:[],creating:!0,refresh:i,setError:s,onSaved:I,onClose:()=>{w(t=>new Set([...t,e.id]))}})},e.id);let n=!c&&l===e.id;return(0,t.jsxs)("li",{className:"settings-models-rowcard",children:[(0,t.jsxs)("div",{className:"settings-models-rowhead",children:[(0,t.jsxs)("span",{className:"settings-models-rowidentity",children:[(0,t.jsx)("span",{className:"settings-models-rowname",children:e.name}),e.custom?(0,t.jsx)("span",{className:"settings-models-rowtag",children:a("settings.models.customTag")}):null,(0,t.jsx)(ln,{configured:e.credentialConfigured,missing:!e.credentialConfigured})]}),(0,t.jsxs)("span",{className:"settings-models-rowactions",children:[(0,t.jsx)("button",{type:"button",className:"settings-models-btn","aria-label":a("settings.models.editProvider").replace("{provider}",e.name),onClick:()=>{j(null),p(!1),d(!1),o(n?null:e.id)},children:a("settings.models.edit")}),e.directory?null:(0,t.jsx)("button",{type:"button",className:"settings-models-btn settings-models-danger","aria-label":a("settings.models.removeProvider").replace("{provider}",e.name),onClick:()=>{j(null),v(void 0),m(e)},children:a("settings.models.remove")})]})]}),n&&(0,t.jsx)(lC,{provider:e,models:r.filter(t=>t.providerId===e.id),creating:e.directory,refresh:i,setError:s,onSaved:I,onClose:()=>{o(null)}})]},e.id)})}),(0,t.jsxs)("div",{className:"settings-models-addblock",children:[null!==N&&(0,t.jsxs)("div",{className:"settings-models-addcard",children:[(0,t.jsxs)("div",{className:"settings-models-field",children:[(0,t.jsx)("span",{className:"settings-models-fieldlabel",children:a("settings.models.provider")}),(0,t.jsx)("select",{className:"settings-models-input settings-models-select",value:N.id,"aria-label":a("settings.models.provider"),onChange:e=>{o(e.target.value)},children:C.map(e=>(0,t.jsx)("option",{value:e.id,children:e.name},e.id))})]}),(0,t.jsx)(lC,{provider:N,models:[],creating:!0,hideTitle:!0,refresh:i,setError:s,onSaved:I,onClose:()=>{d(!1),o(null)}},N.id)]}),u&&(0,t.jsx)("div",{className:"settings-models-addcard",children:(0,t.jsx)(ly,{taken:e.map(e=>e.id),refresh:i,setError:s,onSaved:I,onClose:e=>{p(!1),e&&i()}})}),null===N&&!u&&(0,t.jsxs)("div",{className:"settings-models-addactions",children:[(0,t.jsx)("button",{type:"button",className:"settings-models-addbutton",disabled:0===C.length,onClick:()=>{j(null),p(!1),d(!0),o(C[0]?.id??null)},children:a("settings.models.add")}),(0,t.jsx)("button",{type:"button",className:"settings-models-addbutton",onClick:()=>{j(null),d(!1),o(null),p(!0)},children:a("settings.models.customAdd")})]})]}),(0,t.jsx)(lv,{open:null!==h,providerName:h?.name??"",busy:g,failure:y,onCancel:()=>{g||(m(null),v(void 0))},onConfirm:()=>{T()}})]})}let lI=[{kind:"tool",title:"Tool policy",description:"Permission mode and allowed local execution boundaries.",defaultConfig:'{"mode":"restricted","allowedTools":["read","ls","grep","find"],"allowedExecutables":["git","rg"],"maxTimeoutSeconds":300}'},{kind:"turn",title:"Turn routing",description:"Model routing candidates and upgrade thresholds.",defaultConfig:'{"mode":"context_upgrade","threshold":0.7,"candidateModelProfileIds":[]}'},{kind:"vision",title:"Vision",description:"Native image handling and descriptor fallback boundaries.",defaultConfig:'{"mode":"reject","maxImageBytes":10485760,"maxPixels":40000000}'}];function lT({policies:e,refresh:n,setError:r}){async function i(e,t){e.preventDefault();let i=e.currentTarget,s=new FormData(i);try{let e=JSON.parse(String(s.get("config")||"{}"));await (0,eb.apiFetch)("/v1/policy-profiles",{method:"POST",body:JSON.stringify({name:s.get("name"),kind:t,config:e})}),i.reset(),r(null),await n()}catch(e){r(e.message)}}async function s(e){try{await (0,eb.apiFetch)(`/v1/policy-profiles/${encodeURIComponent(e)}/default`,{method:"PUT"}),r(null),await n()}catch(e){r(e.message)}}async function a(e){if(window.confirm(`Deactivate policy “${e.name}” v${e.version}?`))try{await (0,eb.apiFetch)(`/v1/policy-profiles/${encodeURIComponent(e.id)}`,{method:"DELETE"}),r(null),await n()}catch(e){r(e.message)}}return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-policies-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-policies-heading",children:"Policies"}),(0,t.jsx)("p",{children:"Immutable versioned execution, routing, and image handling configuration."})]}),lI.map(n=>(0,t.jsx)(lM,{...n,policies:e,onSubmit:i,onDefault:s,onDeactivate:a},n.kind))]})}function lM({kind:e,title:n,description:r,policies:i,defaultConfig:s,onSubmit:a,onDefault:l,onDeactivate:o}){return(0,t.jsxs)("section",{className:"settings-subsection",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h3",{children:n}),(0,t.jsx)("p",{children:r})]}),(0,t.jsxs)("form",{className:"settings-form policy-form",onSubmit:t=>a(t,e),children:[(0,t.jsxs)("label",{children:["Name",(0,t.jsx)("input",{name:"name",required:!0})]}),(0,t.jsxs)("label",{children:["Configuration JSON",(0,t.jsx)("textarea",{name:"config",required:!0,defaultValue:s})]}),(0,t.jsx)("button",{type:"submit",children:"Create version"})]}),(0,t.jsx)("div",{className:"settings-list",children:i.filter(t=>t.kind===e).map(e=>(0,t.jsxs)("div",{className:"settings-row",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:e.name}),(0,t.jsxs)("span",{children:["v",e.version," · ",String(e.config.mode??"configured")]})]}),(0,t.jsx)("button",{className:"secondary-btn",disabled:"active"!==e.status,onClick:()=>l(e.id),children:"Use as default"}),(0,t.jsx)("button",{className:"secondary-btn",type:"button",disabled:"active"!==e.status,title:"Deactivate policy","aria-label":`Deactivate policy ${e.name} version ${e.version}`,onClick:()=>o(e),children:(0,t.jsx)(b,{size:14,"aria-hidden":"true"})})]},e.id))})]})}let lR=o("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),lE=o("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),lz=o("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);function lA(e){return Promise.all([(0,eb.apiFetch)("/v1/prompt-templates").catch(()=>null),e?(0,eb.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/prompt-templates`).catch(()=>null):Promise.resolve(null)])}function lP({projectId:e,setError:r}){let[i,s]=(0,n.useState)(null),[a,l]=(0,n.useState)(null),[o,c]=(0,n.useState)(void 0),[d,u]=(0,n.useState)(!1),[p,h]=(0,n.useState)(""),[m,f]=(0,n.useState)(""),[g,y]=(0,n.useState)(""),[v,b]=(0,n.useState)(""),[j,k]=(0,n.useState)(!1),[w,C]=(0,n.useState)(null),[N,I]=(0,n.useState)(""),[T,M]=(0,n.useState)(""),[R,E]=(0,n.useState)(""),[z,A]=(0,n.useState)(null),[P,$]=(0,n.useState)(null),L=(0,n.useCallback)(async()=>{try{let[t,n]=await lA(e);s(t),l(n),c(e),r(null)}catch{c(e),r("Failed to load prompt templates")}},[e,r]);(0,n.useEffect)(()=>{let t=!1;return lA(e).then(([n,i])=>{t||(s(n),l(i),c(e),r(null))}).catch(()=>{t||(c(e),r("Failed to load prompt templates"))}),()=>{t=!0}},[e,r]);let F=a??i;async function D(e){if(e.preventDefault(),p.trim()&&v.trim()){k(!0);try{await (0,eb.apiFetch)("/v1/prompt-templates",{method:"POST",body:JSON.stringify({name:p.trim(),description:m.trim(),argumentHint:g.trim(),body:v})}),h(""),f(""),y(""),b(""),u(!1),await L()}catch(e){r(e.message)}finally{k(!1)}}}async function _(e){try{await (0,eb.apiFetch)(`/v1/prompt-templates/${encodeURIComponent(e)}`,{method:"DELETE"}),$(null),await L()}catch(e){r(e.message)}}async function O(e){if(R.trim()){k(!0);try{await (0,eb.apiFetch)(`/v1/prompt-templates/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({description:N.trim(),argumentHint:T.trim(),body:R})}),C(null),await L()}catch(e){r(e.message)}finally{k(!1)}}}if(o!==e&&!i)return(0,t.jsx)("div",{className:"settings-tab-section",children:(0,t.jsx)("p",{children:"Loading…"})});let W=[...i?.diagnostics??[],...a?.diagnostics??[]],U=i?.globalRecoveryMode??!1;return(0,t.jsxs)("section",{className:"settings-tab-section","aria-labelledby":"settings-templates-heading",children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("h2",{id:"settings-templates-heading",children:"Prompt templates"}),(0,t.jsx)("p",{children:"Manage slash-command prompt templates across builtin, settings, global, and project sources."})]}),W.length>0&&(0,t.jsx)("div",{className:"templates-diag-banner",role:"status",children:W.map((e,n)=>(0,t.jsxs)("div",{className:`templates-diag ${"warning"===e.level?"diag-warn":"diag-info"}`,children:[(0,t.jsx)("span",{className:"templates-diag-icon",children:"warning"===e.level?(0,t.jsx)(lR,{size:14}):(0,t.jsx)(lE,{size:14})}),(0,t.jsxs)("span",{className:"templates-diag-msg",children:[(0,t.jsx)("code",{children:e.code})," ",e.message]})]},n))}),F&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("header",{className:"templates-section-header",children:(0,t.jsxs)("h3",{children:["Effective templates ",e?"(project)":"(global)"]})}),0===F.templates.length?(0,t.jsxs)("p",{className:"templates-empty",children:["No templates available. Create a global template below or add markdown files to your project's ",(0,t.jsx)("code",{children:".ennote/prompts/"})," directory."]}):(0,t.jsx)("ul",{className:"templates-list",children:F.templates.map(e=>(0,t.jsxs)("li",{className:"template-row",children:[(0,t.jsxs)("span",{className:"template-name",children:["/",e.name]}),e.argumentHint&&(0,t.jsx)("span",{className:"template-hint",children:e.argumentHint}),(0,t.jsx)("span",{className:"template-source source-{t.source}",children:e.source}),(0,t.jsx)("span",{className:"template-desc",children:e.description})]},e.name))})]}),(0,t.jsxs)("header",{className:"templates-section-header",children:[(0,t.jsx)("h3",{children:"My global templates"}),!U&&(0,t.jsxs)("button",{type:"button",className:"settings-btn",onClick:()=>u(!d),children:[(0,t.jsx)(x,{size:14})," New"]})]}),U&&(0,t.jsxs)("div",{className:"templates-diag diag-warn",style:{marginBottom:12},children:[(0,t.jsx)(lR,{size:14}),(0,t.jsx)("span",{children:"Global store is in recovery mode. Delete some entries to restore normal operation. Create is disabled."})]}),d&&(0,t.jsxs)("form",{className:"template-edit-form",onSubmit:D,children:[(0,t.jsxs)("label",{children:["Name ",(0,t.jsx)("input",{value:p,onChange:e=>h(e.target.value),placeholder:"my-command",required:!0,disabled:j})]}),(0,t.jsxs)("label",{children:["Description ",(0,t.jsx)("input",{value:m,onChange:e=>f(e.target.value),placeholder:"Optional",disabled:j})]}),(0,t.jsxs)("label",{children:["Argument hint ",(0,t.jsx)("input",{value:g,onChange:e=>y(e.target.value),placeholder:"<path> [focus]",disabled:j})]}),(0,t.jsxs)("label",{children:["Body ",(0,t.jsx)("textarea",{value:v,onChange:e=>b(e.target.value),rows:4,placeholder:"Template body with $1, $@, etc.",required:!0,disabled:j})]}),(0,t.jsxs)("div",{className:"template-form-actions",children:[(0,t.jsxs)("button",{type:"submit",className:"settings-btn primary",disabled:j||!p.trim()||!v.trim(),children:[(0,t.jsx)(lz,{size:14})," ",j?"Saving…":"Create"]}),(0,t.jsx)("button",{type:"button",className:"settings-btn",onClick:()=>u(!1),children:"Cancel"})]})]}),i?.globalTemplates&&i.globalTemplates.length>0&&(0,t.jsx)("ul",{className:"templates-list",children:i.globalTemplates.map(e=>(0,t.jsxs)("li",{className:`template-row ${!e.valid?"invalid":""}`,children:[(0,t.jsxs)("span",{className:"template-name",children:["/",e.name]}),e.argumentHint&&(0,t.jsx)("span",{className:"template-hint",children:e.argumentHint}),e.valid?(0,t.jsx)("span",{className:"template-desc",children:e.description}):(0,t.jsxs)("span",{className:"template-desc diag-text",children:[e.diagnostic?.code,": ",e.diagnostic?.message]}),(0,t.jsx)("div",{className:"template-actions",children:e.editable&&w===e.name?(0,t.jsxs)("div",{className:"template-edit-form",style:{width:"100%",marginTop:6},children:[e.valid&&(0,t.jsxs)("div",{className:"template-edit-readonly",children:["Name: ",e.name]}),(0,t.jsxs)("label",{children:["Description ",(0,t.jsx)("input",{value:N,onChange:e=>I(e.target.value),disabled:j})]}),(0,t.jsxs)("label",{children:["Argument hint ",(0,t.jsx)("input",{value:T,onChange:e=>M(e.target.value),disabled:j})]}),(0,t.jsxs)("label",{children:["Body ",(0,t.jsx)("textarea",{value:R,onChange:e=>E(e.target.value),rows:4,disabled:j})]}),(0,t.jsxs)("div",{className:"template-form-actions",children:[(0,t.jsxs)("button",{type:"button",className:"settings-btn primary",onClick:()=>O(e.name),disabled:j||!R.trim(),children:[(0,t.jsx)(lz,{size:14})," ",j?"Saving…":e.valid?"Update":"Repair"]}),(0,t.jsx)("button",{type:"button",className:"settings-btn",onClick:()=>C(null),children:"Cancel"})]})]}):e.editable?P===e.name?(0,t.jsxs)("span",{className:"template-confirm",children:[(0,t.jsxs)("span",{children:["Delete /",e.name,"?"]}),(0,t.jsx)("button",{type:"button",className:"settings-btn danger",onClick:()=>_(e.name),disabled:j,children:"Delete"}),(0,t.jsx)("button",{type:"button",className:"settings-btn",onClick:()=>$(null),children:"Cancel"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",className:"settings-btn",onClick:()=>{C(e.name),e.valid?(0,eb.apiFetch)(`/v1/prompt-templates/${encodeURIComponent(e.name)}`).then(e=>{I(e.description),M(e.argumentHint),E(e.body)}).catch(()=>{}):(I(""),M(""),E(""))},children:e.valid?"Edit":"Repair"}),(0,t.jsx)("button",{type:"button",className:"settings-btn danger",onClick:()=>$(e.name),children:(0,t.jsx)(S,{size:14})})]}):(0,t.jsx)("span",{className:"template-manual-cleanup",children:"Manual cleanup required in $ENNOTE_HOME/prompts/"})}),e.valid&&z===e.name&&(0,t.jsx)(l$,{name:e.name,onClose:()=>A(null)})]},e.name))}),(!i?.globalTemplates||0===i.globalTemplates.length)&&!U&&(0,t.jsx)("p",{className:"templates-empty",children:"No global templates yet. Create one above."})]})}function l$({name:e,onClose:r}){let[i,s]=(0,n.useState)(null);return((0,n.useEffect)(()=>{(0,eb.apiFetch)(`/v1/prompt-templates/${encodeURIComponent(e)}`).then(e=>s(e.body)).catch(()=>s("Failed to load"))},[e]),null===i)?(0,t.jsx)("div",{className:"template-body-preview",children:"Loading…"}):(0,t.jsxs)("div",{className:"template-body-preview",children:[(0,t.jsx)("pre",{children:i}),(0,t.jsx)("button",{type:"button",className:"settings-btn",onClick:r,children:"Close"})]})}function lL(e){return"general"===e?(0,t.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("line",{x1:"4",y1:"21",x2:"4",y2:"14"}),(0,t.jsx)("line",{x1:"4",y1:"10",x2:"4",y2:"3"}),(0,t.jsx)("line",{x1:"12",y1:"21",x2:"12",y2:"12"}),(0,t.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"3"}),(0,t.jsx)("line",{x1:"20",y1:"21",x2:"20",y2:"16"}),(0,t.jsx)("line",{x1:"20",y1:"12",x2:"20",y2:"3"}),(0,t.jsx)("line",{x1:"1",y1:"14",x2:"7",y2:"14"}),(0,t.jsx)("line",{x1:"9",y1:"8",x2:"15",y2:"8"}),(0,t.jsx)("line",{x1:"17",y1:"16",x2:"23",y2:"16"})]}):"models"===e?(0,t.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,t.jsx)("rect",{x:"9",y:"9",width:"6",height:"6"}),(0,t.jsx)("line",{x1:"9",y1:"1",x2:"9",y2:"4"}),(0,t.jsx)("line",{x1:"15",y1:"1",x2:"15",y2:"4"}),(0,t.jsx)("line",{x1:"9",y1:"20",x2:"9",y2:"23"}),(0,t.jsx)("line",{x1:"15",y1:"20",x2:"15",y2:"23"})]}):"policies"===e?(0,t.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}):"mcp"===e?(0,t.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2"}),(0,t.jsx)("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),(0,t.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"22"})]}):"skills"===e?(0,t.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M12 3l1.9 4.6L18.5 9l-4.6 1.9L12 15.5l-1.9-4.6L5.5 9l4.6-1.4z"}),(0,t.jsx)("path",{d:"M19 15l.9 2.1L22 18l-2.1.9L19 21l-.9-2.1L16 18l2.1-.9z"})]}):(0,t.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("path",{d:"M21 12a9 9 0 0 1-9 9m9-9a9 9 0 0 0-9-9m9 9H3m9 9a9 9 0 0 1-9-9m9 9c1.66 0 3-4.03 3-9s-1.34-9-3-9m0 18c-1.66 0-3-4.03-3-9s1.34-9 3-9m-9 9a9 9 0 0 1 9-9"})})}function lF({open:e,onClose:n,initialTab:r,providers:i,models:s,policies:a,session:l,refresh:o,error:c,setError:d,onSessionUpdated:u,projectId:p}){return e?(0,t.jsx)("div",{className:"settings-dialog-backdrop",onClick:e=>{e.target===e.currentTarget&&n()},children:(0,t.jsx)(lD,{initialTab:r,onClose:n,providers:i,models:s,policies:a,session:l,refresh:o,error:c,setError:d,onSessionUpdated:u,projectId:p},r??"general")}):null}function lD({onClose:e,initialTab:r,providers:i,models:s,policies:a,session:l,refresh:o,error:c,setError:d,onSessionUpdated:u,projectId:p}){let[h,f]=(0,n.useState)(r??"general"),g=(0,n.useRef)(null),x=(0,n.useRef)(null);(0,n.useEffect)(()=>{let t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=window.requestAnimationFrame(()=>x.current?.focus()),r=t=>{if("Escape"===t.key){t.preventDefault(),e();return}if("Tab"!==t.key||!g.current)return;let n=Array.from(g.current.querySelectorAll('button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [href], [tabindex]:not([tabindex="-1"])'));if(0===n.length)return;let r=n[0],i=n[n.length-1];t.shiftKey&&document.activeElement===r?(t.preventDefault(),i.focus()):t.shiftKey||document.activeElement!==i||(t.preventDefault(),r.focus())};return window.addEventListener("keydown",r),()=>{window.cancelAnimationFrame(n),window.removeEventListener("keydown",r),t?.focus()}},[e]);let y=[{id:"general",label:"General",description:"Appearance and theme",icon:lL("general")},{id:"models",label:"Models",description:"Providers, API keys, and model profiles",icon:lL("models")},{id:"policies",label:"Policies",description:"Tool permission and routing policies",icon:lL("policies")},{id:"context",label:"Context & session",description:l?"Session defaults and compaction":"Compaction policy defaults",icon:lL("context")},{id:"templates",label:"Templates",description:"Slash-command prompt templates",icon:lL("templates")},{id:"mcp",label:"MCP",description:"MCP servers and project bindings",icon:lL("mcp")},{id:"skills",label:"Skills",description:"Skill catalog, marketplace, and updates",icon:lL("skills")}];return(0,t.jsx)("div",{ref:g,className:"settings-dialog-shell",role:"dialog","aria-modal":"true","aria-labelledby":"settings-dialog-title settings-dialog-current",children:(0,t.jsxs)("div",{className:"settings-dialog-body",children:[(0,t.jsxs)("div",{className:"settings-dialog-tabs",role:"tablist","aria-label":"Settings sections",children:[(0,t.jsx)("div",{id:"settings-dialog-title",className:"settings-dialog-navtitle",children:"Settings"}),y.map((e,n)=>{let r=h===e.id;return(0,t.jsxs)("button",{type:"button",onClick:()=>f(e.id),onKeyDown:e=>{let t=null;if(("ArrowRight"===e.key||"ArrowDown"===e.key)&&(t=(n+1)%y.length),("ArrowLeft"===e.key||"ArrowUp"===e.key)&&(t=(n-1+y.length)%y.length),"Home"===e.key&&(t=0),"End"===e.key&&(t=y.length-1),null===t)return;e.preventDefault();let r=y[t];f(r.id),window.requestAnimationFrame(()=>document.getElementById(`settings-tab-${r.id}`)?.focus())},className:`settings-dialog-tab ${r?"active":""}`,role:"tab",id:`settings-tab-${e.id}`,"aria-selected":r,"aria-controls":`settings-panel-${e.id}`,children:[(0,t.jsx)("span",{className:"settings-tab-icon",children:e.icon}),(0,t.jsx)("span",{className:"settings-tab-label",children:e.label})]},e.id)})]}),(0,t.jsxs)("div",{className:"settings-dialog-content",children:[(0,t.jsxs)("div",{className:"settings-dialog-header",children:[(0,t.jsx)("div",{className:"settings-dialog-actions",children:(0,t.jsx)("span",{id:"settings-dialog-current",className:"settings-dialog-current",children:y.find(e=>e.id===h)?.label})}),(0,t.jsx)("button",{ref:x,type:"button",className:"settings-dialog-close",title:"Close settings","aria-label":"Close settings",onClick:e,children:(0,t.jsx)(m,{size:14,"aria-hidden":"true"})})]}),c&&(0,t.jsxs)("div",{className:"error-bar",role:"alert",children:[(0,t.jsx)("span",{children:c}),(0,t.jsx)("button",{type:"button",onClick:()=>d(null),"aria-label":"Dismiss error",children:(0,t.jsx)(m,{size:15,"aria-hidden":"true"})})]}),(0,t.jsxs)("div",{className:"settings-dialog-panel",role:"tabpanel",id:`settings-panel-${h}`,"aria-labelledby":`settings-tab-${h}`,children:["general"===h&&(0,t.jsx)("div",{style:{height:"100%",overflowY:"auto"},children:(0,t.jsx)(aJ,{})}),"models"===h&&(0,t.jsx)("div",{style:{height:"100%",overflowY:"auto"},children:(0,t.jsx)(lN,{providers:i,models:s,refresh:o,setError:d})}),"policies"===h&&(0,t.jsx)("div",{style:{height:"100%",overflowY:"auto"},children:(0,t.jsx)(lT,{policies:a,refresh:o,setError:d})}),"context"===h&&(0,t.jsx)("div",{style:{height:"100%",overflowY:"auto"},children:(0,t.jsx)(aF,{policies:a,models:s,session:l,refresh:o,setError:d,onSessionUpdated:u})}),"templates"===h&&(0,t.jsx)("div",{style:{height:"100%",overflowY:"auto"},children:(0,t.jsx)(lP,{projectId:p,setError:d})}),"mcp"===h&&(0,t.jsx)("div",{style:{height:"100%",overflowY:"auto"},children:(0,t.jsx)(a2,{projectId:p,setError:d})}),"skills"===h&&(0,t.jsx)("div",{style:{height:"100%",overflowY:"auto"},children:(0,t.jsx)(lt,{projectId:p,setError:d})})]})]})]})})}function l_({initialWidth:e,minWidth:t,maxWidth:r,storageKey:i,direction:s="right"}){let[a,l]=(0,n.useState)(e),[o,c]=(0,n.useState)(!1),d=(0,n.useRef)(e),u=(0,n.useCallback)(e=>{let n=Math.max(t,Math.min(r,e));l(n),d.current=n,document.documentElement.style.setProperty(i,`${n}px`)},[t,r,i]);(0,n.useEffect)(()=>{let e=window.requestAnimationFrame(()=>{let e=d.current;try{let n=localStorage.getItem(i),s=n?Number.parseInt(n,10):NaN;Number.isFinite(s)&&s>=t&&s<=r&&(e=s)}catch{}u(e)});return()=>window.cancelAnimationFrame(e)},[i,t,r,u]);let p=(0,n.useCallback)(()=>{c(!0)},[]),h=(0,n.useCallback)(e=>{let t="left"===s?-1:1;u(d.current+e*t)},[u,s]);return{beginResize:p,endResize:(0,n.useCallback)(()=>{c(!1);try{localStorage.setItem(i,String(d.current))}catch{}},[i]),isResizing:o,resizeBy:h,width:a}}let lO="ennote:sidebar:collapsed-projects";function lW(){try{let e=window.localStorage.getItem(lO);return e?new Set(JSON.parse(e)):new Set}catch{return new Set}}var lU=e.i(85026);let lq="ennote-onboarding-done";function lB(){let[e,t]=(0,n.useState)([]),[r,i]=(0,n.useState)([]),[s,a]=(0,n.useState)([]),[l,o]=(0,n.useState)(null),[c,d]=(0,n.useState)(!0),u=(0,n.useRef)(0),p=(0,n.useRef)(null),h=(0,n.useCallback)(async()=>{p.current?.abort();let e=new AbortController;p.current=e;let n=++u.current;try{let[r,s,l]=await Promise.all([(0,eb.apiFetch)("/v1/provider-profiles",{signal:e.signal}),(0,eb.apiFetch)("/v1/model-profiles",{signal:e.signal}),(0,eb.apiFetch)("/v1/policy-profiles",{signal:e.signal})]);if(e.signal.aborted||u.current!==n)return;t(r),i(s),a(l),o(null)}catch(t){e.signal.aborted||u.current!==n||o(t.message)}finally{e.signal.aborted||u.current!==n||d(!1)}},[]);return(0,n.useEffect)(()=>{let e=window.setTimeout(()=>void h(),0);return()=>{window.clearTimeout(e),p.current?.abort()}},[h]),{providers:e,models:r,policies:s,error:l,loading:c,setError:o,refresh:h}}let lH={provider_configuration_invalid:"The provider runtime configuration is invalid.",provider_credential_unavailable:"The configured credential could not be resolved.",provider_authentication_failed:"The provider rejected the configured credential.",provider_model_not_found:"The configured model was not found by the provider.",provider_rate_limited:"The provider rate limit was reached. Try again later.",provider_request_timeout:"The provider did not respond before the timeout.",provider_request_rejected:"The provider rejected the model request.",provider_unavailable:"The provider is currently unavailable.",model_protocol_error:"The provider returned an invalid response.",model_stream_interrupted:"The provider response was interrupted.",context_overflow:"The request exceeds the model context window.",context_overflow_after_compaction:"The request still exceeds the context window after compaction.",context_overflow_in_run:"The active run exceeded the model context window."};function lV(e){let t="string"==typeof e?e:"";return lH[t]??(t?`The run failed (${t}).`:"The run failed.")}function lK(e,t){return e instanceof Error&&e.message?e.message:"string"==typeof e&&e.trim()?e:(console.warn("[ennote] non-Error rejection captured",e),t)}function lJ(){return"u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36)}class lG extends Error{}async function lZ(e,t,n){let r=await (0,eb.apiResponse)(`/v1/runs/${encodeURIComponent(e)}/events`,{signal:n});if(!r.ok)throw Error(`HTTP ${r.status}`);let i=r.body?.getReader();if(!i)return!1;let s=new TextDecoder,a="";try{for(;;){let{done:e,value:n}=await i.read();if(e)break;let r=(a+=s.decode(n,{stream:!0})).split("\n");for(let e of(a=r.pop()??"",r)){let n=e.endsWith("\r")?e.slice(0,-1):e;if(!n.startsWith("data:"))continue;let r=JSON.parse(n.slice(5).trimStart());switch(r.type){case"context_compaction_started":t("Compacting context…");break;case"context_compaction_retry_scheduled":t(`Retrying compaction in ${r.payload?.delayMs??0} ms…`);break;case"context_compaction_retry_started":t("Retrying compaction…");break;case"context_compaction_completed":t("Context checkpoint ready");break;case"context_compaction_failed":throw new lG("Context compaction failed.");case"context_compaction_cancelled":case"run_cancelled":throw new lG("Context compaction was cancelled.");case"run_succeeded":return!0;case"run_failed":throw new lG(lV(r.payload?.errorCode))}}}}finally{i.releaseLock()}return!1}async function lQ(e,t,n,r,i,s,a){let l=await (0,eb.apiResponse)(`/v1/runs/${encodeURIComponent(e)}/events`,{signal:s});if(!l.ok)throw Error(`HTTP ${l.status}`);let o=l.body?.getReader();if(!o)return!1;let c=new TextDecoder,d="",u=new Map,p=new Map,h=new Map,m=null,f=!1,g=new Map;function x(e){let t=u.get(e)??{text:"",thinking:""};return u.set(e,t),t}function y(n){let r=x(n);t({id:`${e}-assistant-${n}`,role:"assistant",text:r.text,thinking:r.thinking})}function v(n,r,i){let s=String(n.toolCallId??n.id??n.recordId??`event-${n.callIndex??"unknown"}`),a=n.arguments&&"object"==typeof n.arguments&&!Array.isArray(n.arguments)?n.arguments:void 0;t({id:`${e}-tool-${s}`,role:"tool",kind:"tool",toolCallId:s,toolName:String(n.toolName??n.name??"tool"),text:String(n.content??n.reason??i),arguments:a,argumentsFragment:"string"==typeof n.argumentsFragment?n.argumentsFragment:void 0,isError:!!n.isError||"failed"===r,toolState:r,runId:e})}try{for(;;){let{done:s,value:l}=await o.read();if(s)break;let j=(d+=c.decode(l,{stream:!0})).split("\n");for(let s of(d=j.pop()??"",j)){let l=s.endsWith("\r")?s.slice(0,-1):s;if(l.startsWith("event:")){m=l.slice(6).trim(),f="live"===m;continue}if(l.startsWith(":")||!l.startsWith("data:"))continue;let o=JSON.parse(l.slice(5).trimStart()),c=f;f=!1;let d=o.payload??{},j="number"==typeof d.iteration?d.iteration:1;switch(o.type){case"usage_updated":{let e=d.usage;e&&function(e,t){g.set(e,{uncachedInputTokens:Number(t.uncachedInputTokens??0),cacheReadTokens:Number(t.cacheReadTokens??0),cacheWriteTokens:Number(t.cacheWriteTokens??0),outputTokens:Number(t.outputTokens??0),reasoningTokens:Number(t.reasoningTokens??0)});let n={uncachedInputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,outputTokens:0,reasoningTokens:0};for(let e of g.values())n.uncachedInputTokens+=e.uncachedInputTokens,n.cacheReadTokens+=e.cacheReadTokens,n.cacheWriteTokens+=e.cacheWriteTokens,n.outputTokens+=e.outputTokens,n.reasoningTokens+=e.reasoningTokens;r(n)}(j,e);break}case"context_usage":d&&"number"==typeof d.contextWindow&&i(d);break;case"text_delta":case"thinking_delta":if(!c)break;"text_delta"===o.type?x(j).text+=String(d.text??""):x(j).thinking+=String(d.text??""),y(j);break;case"model_call_retry_scheduled":u.set(j,{text:"",thinking:""}),y(j),n(`Retrying model in ${d.delayMs??0} ms…`);break;case"context_pruned":n("Preparing context…");break;case"context_compaction_planned":n("Compaction queued…");break;case"context_compaction_started":n("Compacting context…");break;case"context_compaction_retry_scheduled":n(`Retrying compaction in ${d.delayMs??0} ms…`);break;case"context_compaction_completed":n("Context checkpoint ready");break;case"run_context_compaction_planned":n("Preparing current run context…");break;case"run_context_compaction_started":n("Compacting current run context…");break;case"run_context_compaction_retry_scheduled":n(`Retrying run compaction in ${d.delayMs??0} ms…`);break;case"run_context_compaction_completed":n("Current run context compacted");break;case"run_context_compaction_failed":n("Run compaction skipped");break;case"run_context_compaction_cancelled":n("");break;case"context_checkpoint_selected":n("Using context checkpoint…");break;case"output_truncated":n(Number(d.partialToolCallCount??0)>0?"Recovering truncated tool call…":"Model output truncated");break;case"tool_call_delta":{if(!c)break;let e=`${j}:${d.index??0}`,t=p.get(e)??{id:"",name:"tool",argumentsFragment:""};d.id&&(t.id=String(d.id)),d.name&&(t.name=String(d.name)),t.argumentsFragment+=String(d.argumentsFragment??""),p.set(e,t),v({...d,toolCallId:t.id||e,toolName:t.name,argumentsFragment:t.argumentsFragment},"pending","Collecting tool arguments…");break}case"child_progress":var b;if(!c)break;b={delegationGroupId:String(d.delegationGroupId??""),taskName:String(d.taskName??""),childRunId:String(d.childRunId??""),activity:String(d.activity??""),tokens:Number(d.tokens??0)},sg?.(b);break;case"tool_output_delta":{if(!c)break;let n=String(d.toolCallId??`event-${d.callIndex??"unknown"}`),r=String(d.stream??"stdout"),i=String(d.text??""),s=h.get(n)??{text:"",name:String(d.toolName??"tool")};d.toolName&&(s.name=String(d.toolName)),"stderr"===r?s.text+=`[stderr] ${i}`:s.text+=i,h.set(n,s),t({id:`${e}-tool-${n}`,role:"tool",kind:"tool",toolCallId:n,toolName:s.name,text:s.text,isError:!1,toolState:"running",runId:e});break}case"tool_call_started":n(`Running: ${d.toolName??"tool"}…`),v(d,"running","Running");break;case"tool_call_completed":{n(""),("delegate_tasks"===d.toolName||"delegate_roles"===d.toolName)&&a.delegated();let e=String(d.toolCallId??d.recordId??`event-${d.callIndex??"unknown"}`);h.delete(e),v(d,d.isError?"failed":"completed","No output");break}case"tool_call_failed":{let e=String(d.toolCallId??d.recordId??`event-${d.callIndex??"unknown"}`);h.delete(e),v(d,"failed","Tool call failed.");break}case"tool_policy_denied":case"tool_policy_terminated":case"tool_call_skipped":v(d,String(d.reason??"").includes("approval_rejected")?"rejected":"failed","Tool call skipped.");break;case"model_route_selected":n(`Using ${d.apiModel??"selected model"}…`);break;case"vision_fallback_started":n("Describing image…");break;case"vision_fallback_completed":n("Image description ready");break;case"approval_requested":n("Waiting for approval"),a.requested();break;case"approval_resolved":n("Resuming…"),a.resolved();break;case"follow_up_consumed":a.followUpConsumed();break;case"run_succeeded":return n("Completed"),!0;case"run_cancelled":return n("Cancelled"),!0;case"run_interrupted":return n("Interrupted"),!0;case"run_failed":throw new lG(lV(d.errorCode))}}}}finally{o.releaseLock()}return!1}function lY(e,t,n){let r=e.steps[e.steps.length-1];for(let i of(r?.kind==="tool_batch"?r.activities.push(...t):e.steps.push({kind:"tool_batch",id:`batch-${t[0].id}`,activities:t}),t))n.set(i.toolCallId,i)}function lX(e,t,n){e.set(t,[...e.get(t)??[],n])}function l0(e,t){return/approval[_ ]rejected/i.test(e)?"rejected":t?"failed":"completed"}class l1{sessionId;dataBranchId;requestedBranchId;loaded=!1;canonical=[];checkpoints=[];transient=[];nextCursor;hasMore=!1;loading=!1;loadingOlder=!1;error=null;requestVersion=0;requestController=null;activeRun=null;pendingApproval=null;queuedInputs=[];delegationActive=!1;lastSeq=0;workerInstanceId=null;streamController=null;streamOpen=!1;reconnectTimer=null;reconnectAttempt=0;eventCursor;disposed=!1;listeners=new Set;snapshot=null;constructor(e){this.sessionId=e}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>(this.snapshot||(this.snapshot=this.buildSnapshot()),this.snapshot);getServerSnapshot=()=>(this.snapshot||(this.snapshot=this.buildSnapshot()),this.snapshot);ensureLoaded=e=>(this.requestedBranchId=e,this.openStream(),this.loaded&&this.dataBranchId===e)?Promise.resolve():(this.resetForBranch(),this.loadInitial(e));loadOlder=async()=>{if(!this.loaded||!this.hasMore||!this.nextCursor||this.loadingOlder)return!1;this.requestVersion+=1;let e=this.requestVersion;this.requestController?.abort();let t=new AbortController;this.requestController=t,this.loadingOlder=!0,this.error=null,this.notify();try{let n,r=await (0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/messages?limit=50&before=${encodeURIComponent(this.nextCursor)}`,{signal:t.signal});if(t.signal.aborted||this.requestVersion!==e)return!1;let i=r.messages??[],s=this.canonical,a=i.length>0?i[i.length-1].seq??0:0,l=s.length>0?s[0].seq??0:0;if(a>0&&l>0&&a+1!==l)return this.error="History window is out of order; re-open the session to re-sync.",!1;return this.canonical=(n=new Set,[...i,...s].filter(e=>!n.has(e.id)&&(n.add(e.id),!0))),this.nextCursor=r.nextCursor,this.hasMore=r.hasMore,!0}catch(n){return t.signal.aborted||this.requestVersion!==e||(this.error=n.message),!1}finally{t.signal.aborted||this.requestVersion!==e||(this.loadingOlder=!1),this.notify()}};refreshLatest=async()=>{this.requestVersion+=1;let e=this.requestVersion;this.requestController?.abort();let t=new AbortController;this.requestController=t,this.loadingOlder=!1;try{let[n,r]=await Promise.all([(0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/messages?limit=50`,{signal:t.signal}),(0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/compactions`,{signal:t.signal})]);if(t.signal.aborted||this.requestVersion!==e)return;let i=!this.loaded;this.canonical=i?n.messages??[]:function(e,t){if(0===e.length)return t;if(0===t.length)return e;let n=new Set(t.map(e=>e.id)),r=e.findIndex(e=>n.has(e.id));return r<0?t:[...e.slice(0,r),...t]}(this.canonical,n.messages??[]),this.checkpoints=r??[],i&&(this.nextCursor=n.nextCursor,this.hasMore=n.hasMore),this.dataBranchId=this.requestedBranchId,this.loaded=!0,this.transient=[],this.error=null}catch(n){t.signal.aborted||this.requestVersion!==e||(this.error=n.message)}finally{this.notify()}};appendTransient=e=>{this.transient.some(t=>t.id===e.id)||(this.transient=[...this.transient,e],this.notify())};upsertTransient=e=>{let t=this.transient.findIndex(t=>t.id===e.id);if(t<0)this.transient=[...this.transient,e];else{let n=[...this.transient];n[t]={...n[t],...e},this.transient=n}this.notify()};openStream=()=>{this.disposed||this.streamOpen||this.streamController||this.openStreamInternal()};dispose=()=>{this.disposed=!0,this.requestController?.abort(),this.streamController?.abort(),this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.listeners.clear()};async openStreamInternal(){if(this.disposed)return;let e=new AbortController;this.streamController=e,this.streamOpen=!0,this.notify();try{let t={};this.eventCursor&&(t["Last-Event-ID"]=this.eventCursor),await (0,eb.apiEventStream)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/events`,e=>this.handleStreamFrame(e),{signal:e.signal,headers:t})}catch(e){e instanceof eb.WorkerGenerationChangedError&&this.handleGenerationChanged()}finally{this.streamController=null,this.streamOpen=!1,this.notify(),this.disposed||this.scheduleReconnect()}}handleStreamFrame(e){e.id&&(this.eventCursor=e.id),this.reconnectAttempt=0;let t=e.data;if(t&&"object"==typeof t)switch(t.type){case"subscribed":this.workerInstanceId=t.instanceId??null,this.lastSeq=t.lastSeq??0,this.applySnapshot(t.snapshot);break;case"snapshot":this.lastSeq=t.lastSeq??0,this.applySnapshot(t.snapshot);break;case"message_committed":this.lastSeq=Math.max(this.lastSeq,t.lastSeq??0),this.refreshLatest();break;case"run_succeeded":case"run_failed":case"run_cancelled":case"run_interrupted":case"context_compaction_completed":case"run_context_compaction_completed":this.refreshLatest()}}applySnapshot(e){e&&(this.activeRun=e.activeRun??null,this.pendingApproval=e.pendingApproval??null,this.queuedInputs=e.queuedInputs??[],this.delegationActive=e.delegationActive??!1,e.checkpoints&&(this.checkpoints=e.checkpoints.map(e=>({id:e.id,status:e.status,reason:e.reason,summary:e.summary,reclaimedTokens:e.reclaimedTokens,firstKeptMessageId:e.firstKeptMessageId,sourceThroughMessageId:e.sourceThroughMessageId,baseLeafMessageId:e.baseLeafMessageId,createdAt:e.createdAt}))),this.notify())}handleGenerationChanged(){this.workerInstanceId=null,this.eventCursor=void 0,this.reconnectAttempt=0,this.activeRun=null,this.pendingApproval=null,this.queuedInputs=[],this.delegationActive=!1}scheduleReconnect(){if(this.disposed||this.reconnectTimer)return;let e=Math.min(1e3*2**this.reconnectAttempt,15e3);this.reconnectAttempt+=1,this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.openStream()},e)}resetForBranch(){this.requestVersion+=1,this.requestController?.abort(),this.requestController=new AbortController,this.dataBranchId=void 0,this.loaded=!1,this.canonical=[],this.checkpoints=[],this.transient=[],this.nextCursor=void 0,this.hasMore=!1,this.error=null,this.loading=!0,this.loadingOlder=!1,this.notify()}async loadInitial(e){let t=this.requestVersion,n=this.requestController;try{let[r,i]=await Promise.all([(0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/messages?limit=50`,{signal:n.signal}),(0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(this.sessionId)}/compactions`,{signal:n.signal})]);if(n.signal.aborted||this.requestVersion!==t)return;this.dataBranchId=e,this.canonical=r.messages??[],this.checkpoints=i??[],this.nextCursor=r.nextCursor,this.hasMore=r.hasMore,this.loaded=!0}catch(e){n.signal.aborted||this.requestVersion!==t||(this.error=e.message)}finally{n.signal.aborted||this.requestVersion!==t||(this.loading=!1),this.notify()}}buildSnapshot(){return{sessionId:this.sessionId,dataBranchId:this.dataBranchId,loaded:this.loaded,canonical:this.canonical,checkpoints:this.checkpoints,transient:this.transient,nextCursor:this.nextCursor,hasMore:this.hasMore,loading:this.loading,loadingOlder:this.loadingOlder,error:this.error,activeRun:this.activeRun,pendingApproval:this.pendingApproval,queuedInputs:this.queuedInputs,delegationActive:this.delegationActive,lastSeq:this.lastSeq,workerInstanceId:this.workerInstanceId,streamOpen:this.streamOpen}}notify(){for(let e of(this.snapshot=null,this.listeners))e()}}class l2{stores=new Map;order=[];getStore=e=>{let t=this.stores.get(e);return t||(t=new l1(e),this.stores.set(e,t),this.order.push(e),this.prune(16)),this.touch(e),t};has=e=>this.stores.has(e);disposeStore=e=>{let t=this.stores.get(e);t&&(t.dispose(),this.stores.delete(e));let n=this.order.indexOf(e);n>=0&&this.order.splice(n,1)};prune=e=>{for(;this.order.length>e;){let e=this.order.shift();void 0!==e&&this.disposeStore(e)}};touch(e){let t=this.order.indexOf(e);t>=0&&this.order.splice(t,1),this.order.push(e)}}let l4=new l2,l5={sessionId:"",dataBranchId:void 0,loaded:!1,canonical:[],checkpoints:[],transient:[],nextCursor:void 0,hasMore:!1,loading:!1,loadingOlder:!1,error:null,activeRun:null,pendingApproval:null,queuedInputs:[],delegationActive:!1,lastSeq:0,workerInstanceId:null,streamOpen:!1},l6=()=>()=>{},l3=async()=>!1,l9=async()=>{},l8=()=>{},l7=()=>{},oe={nodes:[],openTurn:null,calls:new Map,syntheticTurn:0},ot=new Set(["txt","md","mdx","json","yaml","yml","toml","csv","tsv","log","js","jsx","ts","tsx","py","r","go","rs","java","c","cpp","h","hpp","css","html","xml","sh","bash","sql"]);function on(){return"u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36)}function or(e,t){let n=new Map(t.map(e=>[e.id,e.name]));return e.filter(e=>"active"===e.status).map(e=>({ref:`${n.get(e.providerId)??e.providerId}/${e.modelName}`,label:e.displayName||e.modelName,model:e}))}function oi({models:e,providers:r,setError:i}){let s=(0,n.useMemo)(()=>or(e,r),[e,r]),[a,l]=(0,n.useState)([]),[o,d]=(0,n.useState)(null),[p,h]=(0,n.useState)(null),[m,f]=(0,n.useState)(""),[g,y]=(0,n.useState)(null),[v,b]=(0,n.useState)(!1),[j,k]=(0,n.useState)({id:"",name:""}),[w,S]=(0,n.useState)(!1),[C,N]=(0,n.useState)(null),I=(0,n.useCallback)(async()=>{let e=await (0,eb.apiFetch)("/v1/global-roles");return l(e),e},[]),T=(0,n.useCallback)(async e=>{y("loading"),d(e);try{h(await (0,eb.apiFetch)(`/v1/global-roles/${encodeURIComponent(e)}`)),S(!1),N(null),i(null)}catch(e){h(null),i(e.message)}finally{y(null)}},[i]);(0,n.useEffect)(()=>{let e=!1,t=window.setTimeout(()=>{I().then(t=>{let n=t.find(e=>!e.error);!e&&n&&T(n.id)}).catch(t=>{e||i(t.message)})},0);return()=>{e=!0,window.clearTimeout(t)}},[T,I,i]);let M=async()=>{if(!s[0])return void i("Create an active model before creating a Role.");let e=j.id.trim(),t=j.name.trim();if(e&&t){y("creating");try{var n;let r=await (0,eb.apiFetch)("/v1/global-roles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({document:(n=s[0].ref,{schemaVersion:1,handle:e,name:t,description:"",positioning:"",icon:"bot",color:"neutral",model:{ref:n,thinkingEffort:"default",fallbacks:[]},skills:[],authority:"read_only",permissionCeiling:"discuss",allowedTools:["read","ls","grep","find"],context:{defaultMode:"room",allowedModes:["room","fresh"],ownExecutionContinuity:"none"},delegation:{admission:"auto_within_budget",allowedCallerKinds:["host"],allowedStrategies:["single","parallel"],maxInvocationsPerParentRun:16,maxConcurrentInstances:16,budgetCeiling:{maxModelCalls:4,maxToolCalls:8,maxTotalTokens:2e4,maxOutputTokens:4e3,maxCostUsdMicros:1e5,maxWallTimeMs:12e4}},outputContract:"text-v1",maxLoopIterations:8,prompt:"Perform the requested work independently. Distinguish evidence from assumptions and report a concise result."})})});b(!1),k({id:"",name:""}),h(r),d(r.id),await I(),i(null)}catch(e){i(e.message)}finally{y(null)}}},R=async e=>{if(p&&!g){y("saving");try{let t=await (0,eb.apiFetch)(`/v1/global-roles/${encodeURIComponent(p.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedDigest:p.digest,document:e})});h(t),l(e=>e.map(e=>e.id===t.id?{...e,name:t.name,digest:t.digest,error:void 0}:e)),S(!1),N(null),i(null)}catch(e){S(!0),i(e.message)}finally{y(null)}}},E=async()=>{if(p)try{N(await (0,eb.apiFetch)(`/v1/global-roles/${encodeURIComponent(p.id)}`))}catch(e){i(e.message)}},z=async()=>{if(p&&!g){y("publishing");try{await (0,eb.apiFetch)(`/v1/global-roles/${encodeURIComponent(p.id)}/publish`,{method:"POST"}),i(null)}catch(e){i(e.message)}finally{y(null)}}},A=e=>{p&&h({...p,document:e(p.document)})},P=e=>{if(!p)return;let t=e(p.document);h({...p,document:t}),R(t)},$=a.filter(e=>`${e.name} ${e.id}`.toLowerCase().includes(m.trim().toLowerCase()));return(0,t.jsxs)("div",{className:`global-roles ${o?"has-selection":""}`,children:[(0,t.jsxs)("aside",{className:"global-roles-list",children:[(0,t.jsxs)("header",{children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:"Role catalog"}),(0,t.jsxs)("span",{children:[a.length," global Roles"]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>b(e=>!e),"aria-label":"Add Role",children:(0,t.jsx)(x,{size:18})})]}),v&&(0,t.jsxs)("div",{className:"global-role-create",children:[(0,t.jsx)("input",{value:j.id,onChange:e=>k(t=>({...t,id:e.target.value})),placeholder:"role-id"}),(0,t.jsx)("input",{value:j.name,onChange:e=>k(t=>({...t,name:e.target.value})),placeholder:"Role name"}),(0,t.jsx)("button",{type:"button",onClick:()=>void M(),disabled:"creating"===g,children:"creating"===g?"Creating…":"Create"})]}),(0,t.jsxs)("label",{className:"global-role-search",children:[(0,t.jsx)(u,{size:15}),(0,t.jsx)("input",{value:m,onChange:e=>f(e.target.value),placeholder:"Search Roles"})]}),(0,t.jsxs)("div",{role:"listbox","aria-label":"Global Roles",children:[$.map(e=>(0,t.jsxs)("button",{type:"button",role:"option","aria-selected":o===e.id,onClick:()=>void T(e.id),children:[(0,t.jsx)(c,{size:17}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:e.name}),(0,t.jsx)("code",{children:e.id}),e.error&&(0,t.jsx)("small",{children:e.error})]}),(0,t.jsx)(iB,{size:14})]},e.id)),0===$.length&&(0,t.jsx)("div",{className:"roles-empty",children:"No global Roles"})]})]}),(0,t.jsxs)("section",{className:"global-role-detail",children:[!p&&"loading"===g&&(0,t.jsxs)("div",{className:"roles-detail-empty",children:[(0,t.jsx)(em,{className:"spin",size:18})," Loading Role…"]}),!p&&"loading"!==g&&(0,t.jsxs)("div",{className:"roles-detail-empty",children:[(0,t.jsx)(c,{size:26})," Select or create a Role"]}),p&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("header",{className:"global-role-commandbar",children:[(0,t.jsxs)("button",{type:"button",className:"global-role-back",onClick:()=>{d(null),h(null)},children:[(0,t.jsx)(sX,{size:17})," Roles"]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:p.document.name}),(0,t.jsx)("code",{children:p.path})]}),(0,t.jsxs)("div",{className:"global-role-command-actions",children:[w?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"role-conflict-state",children:"File changed on disk"}),(0,t.jsx)("button",{type:"button",onClick:()=>void E(),children:"Diff"}),(0,t.jsx)("button",{type:"button",onClick:()=>void T(p.id),children:"Reload"})]}):(0,t.jsx)("span",{className:"saving"===g?"is-saving":"",children:"saving"===g?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(em,{className:"spin",size:14})," Saving"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U,{size:14})," Saved"]})}),(0,t.jsx)("button",{type:"button",onClick:()=>void z(),disabled:!!g||w,children:"publishing"===g?"Publishing…":"Publish"})]})]}),(0,t.jsxs)("div",{className:"global-role-form",children:[(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{children:"Identity"}),(0,t.jsxs)("div",{className:"global-role-grid",children:[(0,t.jsxs)("label",{children:["Name",(0,t.jsx)("input",{value:p.document.name,onChange:e=>A(t=>({...t,name:e.target.value})),onBlur:()=>void R(p.document)})]}),(0,t.jsxs)("label",{children:["Handle",(0,t.jsx)("input",{value:p.document.handle,disabled:!0})]}),(0,t.jsxs)("label",{className:"wide",children:["Description",(0,t.jsx)("input",{value:p.document.description,onChange:e=>A(t=>({...t,description:e.target.value})),onBlur:()=>void R(p.document)})]})]})]}),(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{children:"Runtime"}),(0,t.jsxs)("div",{className:"global-role-grid",children:[(0,t.jsxs)("label",{className:"wide",children:["Model",(0,t.jsx)("select",{value:p.document.model.ref,onChange:e=>P(t=>({...t,model:{...t.model,ref:e.target.value}})),children:s.map(e=>(0,t.jsxs)("option",{value:e.ref,children:[e.label," · ",e.ref]},e.ref))})]}),(0,t.jsxs)("label",{children:["Thinking",(0,t.jsx)("select",{value:p.document.model.thinkingEffort,onChange:e=>P(t=>({...t,model:{...t.model,thinkingEffort:e.target.value}})),children:["default","low","medium","high"].map(e=>(0,t.jsx)("option",{children:e},e))})]}),(0,t.jsxs)("label",{children:["Permission ceiling",(0,t.jsxs)("select",{value:p.document.permissionCeiling,onChange:e=>P(t=>({...t,permissionCeiling:e.target.value})),children:[(0,t.jsx)("option",{value:"discuss",children:"Discuss"}),(0,t.jsx)("option",{value:"auto",children:"Auto"}),(0,t.jsx)("option",{value:"ask",children:"Ask"})]})]}),(0,t.jsxs)("label",{className:"wide",children:["Skills",(0,t.jsx)("input",{value:p.document.skills.map(e=>e.id).join(", "),onChange:e=>A(t=>({...t,skills:e.target.value.split(",").map(e=>e.trim()).filter(Boolean).map(e=>({id:e,mode:"available"}))})),onBlur:()=>void R(p.document),placeholder:"report-writing, code-review"})]})]})]}),(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{children:"Role prompt"}),(0,t.jsx)("label",{className:"global-role-prompt",children:(0,t.jsx)("textarea",{"aria-label":"Role prompt",value:p.document.prompt,onChange:e=>A(t=>({...t,prompt:e.target.value})),onBlur:()=>void R(p.document)})})]})]}),C&&(0,t.jsxs)("div",{className:"role-conflict-dialog",role:"dialog","aria-modal":"true","aria-label":"Role file diff",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("strong",{children:"Local edits"}),(0,t.jsx)("button",{type:"button",onClick:()=>N(null),children:"Close"})]}),(0,t.jsx)("pre",{children:JSON.stringify(p.document,null,2)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("header",{children:(0,t.jsx)("strong",{children:"File on disk"})}),(0,t.jsx)("pre",{children:JSON.stringify(C.document,null,2)})]})]})]})]})]})}function os({graphId:e,models:r,onApplied:i,setError:s}){let[a,l]=(0,n.useState)(null),[o,d]=(0,n.useState)(""),[u,p]=(0,n.useState)(""),[h,m]=(0,n.useState)(null),f=(0,n.useCallback)(async()=>{m("loading");try{let t=await (0,eb.apiFetch)(`/v1/graphs/${encodeURIComponent(e)}/builder`);l(t),d(t.modelProfileId||r[0]?.model.id||"")}catch(e){s(e.message)}finally{m(null)}},[e,r,s]);(0,n.useEffect)(()=>{let e=window.setTimeout(()=>void f(),0);return()=>window.clearTimeout(e)},[f]);let g=async()=>{if(u.trim()&&o&&!h){m("sending");try{let t=await (0,eb.apiFetch)(`/v1/graphs/${encodeURIComponent(e)}/builder/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelProfileId:o,instruction:u.trim()})});l(t),p(""),s(null)}catch(e){s(e.message)}finally{m(null)}}},x=async()=>{if(a?.proposal&&!(a.proposal.diagnostics.length>0)&&!h){m("applying");try{let t=await (0,eb.apiFetch)(`/v1/graphs/${encodeURIComponent(e)}/builder/proposals/${encodeURIComponent(a.proposal.id)}/apply`,{method:"POST"});i(t),await f(),s(null)}catch(e){s(e.message)}finally{m(null)}}};return(0,t.jsxs)("aside",{className:"graph-builder-pane",children:[(0,t.jsxs)("div",{className:"graph-section-heading",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{children:"Builder"}),(0,t.jsx)("p",{children:"Persistent conversation for this Graph."})]}),(0,t.jsx)(c,{size:18})]}),(0,t.jsxs)("div",{className:"graph-builder-content",children:[(0,t.jsxs)("label",{className:"graph-builder-model",children:["Builder model",(0,t.jsx)("select",{value:o,onChange:e=>d(e.target.value),disabled:!!h,children:r.map(e=>(0,t.jsx)("option",{value:e.model.id,children:e.label},e.model.id))})]}),(0,t.jsxs)("div",{className:"graph-builder-messages","aria-live":"polite",children:["loading"===h&&(0,t.jsxs)("div",{className:"graph-builder-loading",children:[(0,t.jsx)(em,{className:"spin",size:16})," Loading conversation…"]}),a?.messages.map(e=>(0,t.jsxs)("div",{className:`graph-builder-message is-${e.role}`,children:[(0,t.jsx)("span",{children:"user"===e.role?"You":"Builder"}),(0,t.jsx)("p",{children:e.content})]},e.id)),!h&&(a?.messages.length??0)===0&&(0,t.jsxs)("div",{className:"graph-builder-intro",children:[(0,t.jsx)(c,{size:22}),(0,t.jsx)("p",{children:"Describe Tasks, execution choices, and dependencies. Builder will return a validated proposal."})]})]}),a?.proposal&&(0,t.jsxs)("div",{className:`graph-builder-proposal ${a.proposal.diagnostics.length?"is-invalid":""}`,children:[(0,t.jsxs)("header",{children:[a.proposal.diagnostics.length?(0,t.jsx)(lR,{size:15}):(0,t.jsx)(U,{size:15}),(0,t.jsx)("strong",{children:"Proposal"}),(0,t.jsxs)("span",{children:[a.proposal.operations.length," changes"]})]}),(0,t.jsx)("p",{children:a.proposal.summary}),(0,t.jsx)("ul",{children:a.proposal.operations.map((e,n)=>(0,t.jsxs)("li",{children:[(0,t.jsx)("code",{children:e.kind}),e.taskId?` \xb7 ${e.taskId}`:""]},n))}),a.proposal.diagnostics.map(e=>(0,t.jsx)("div",{className:"graph-builder-diagnostic",children:e},e)),(0,t.jsx)("button",{type:"button",onClick:()=>void x(),disabled:a.proposal.diagnostics.length>0||!!h,children:"applying"===h?"Applying…":"Apply proposal"})]}),(0,t.jsxs)("div",{className:"graph-builder-composer",children:[(0,t.jsx)("textarea",{value:u,onChange:e=>p(e.target.value),"aria-label":"Graph Builder instruction",placeholder:"Describe the Graph change…",disabled:!!h||!o,onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&g()}}),(0,t.jsx)("button",{type:"button",onClick:()=>void g(),disabled:!u.trim()||!o||!!h,"aria-label":"Send Builder instruction",children:"sending"===h?(0,t.jsx)(em,{className:"spin",size:17}):(0,t.jsx)(su,{size:17})})]})]})]})}function oa(e){let t=new Set(Object.keys(e.tasks)),n=new Set,r=[];for(;t.size>0;){let i=[...t].filter(t=>(e.graph[t]??[]).every(e=>n.has(e))).sort();if(0===i.length)return[...r,[...t].sort()];r.push(i),i.forEach(e=>{t.delete(e),n.add(e)})}return r}function ol({document:e,busy:n,onOpenTask:r,onChange:i}){let s=Object.keys(e.tasks).sort();return 0===s.length?(0,t.jsx)("div",{className:"graph-empty-state",children:"Add a Task to start the Graph."}):(0,t.jsxs)("div",{className:"graph-dependency-editor",children:[(0,t.jsx)("div",{className:"graph-levels","aria-label":"Task dependency levels",children:oa(e).map((n,i)=>(0,t.jsxs)("div",{className:"graph-level",children:[(0,t.jsxs)("span",{className:"graph-level-label",children:["Level ",i+1]}),(0,t.jsx)("div",{children:n.map(n=>(0,t.jsx)("button",{type:"button",onClick:()=>r(n),children:e.tasks[n].name},n))}),i<oa(e).length-1&&(0,t.jsx)(aA,{size:16,"aria-hidden":!0})]},i))}),(0,t.jsx)("div",{className:"graph-dependency-list",children:s.map(r=>{let a=new Set(e.graph[r]??[]);return(0,t.jsxs)("fieldset",{disabled:n,children:[(0,t.jsx)("legend",{children:e.tasks[r].name}),(0,t.jsxs)("div",{children:[s.filter(e=>e!==r).map(n=>(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{type:"checkbox",checked:a.has(n),onChange:e=>{let t=new Set(a);e.target.checked?t.add(n):t.delete(n),i(r,[...t].sort())}}),e.tasks[n].name]},n)),1===s.length&&(0,t.jsx)("span",{children:"No other Tasks"})]})]},r)})})]})}function oo({graphs:e,selected:n,onSelect:r,onAdd:i}){return(0,t.jsxs)("div",{className:"graph-tabs-row",children:[(0,t.jsx)("div",{className:"graph-tabs",role:"tablist","aria-label":"Graphs",children:e.map(e=>(0,t.jsxs)("button",{type:"button",role:"tab","aria-selected":n===e.id,className:"graph-tab",onClick:()=>r(e.id),children:[(0,t.jsx)("span",{children:e.name}),e.error&&(0,t.jsx)("i",{title:e.error,children:"!"})]},e.id))}),(0,t.jsx)("button",{type:"button",className:"graph-add-tab",onClick:i,"aria-label":"Add Graph",title:"Add Graph",children:(0,t.jsx)(x,{size:18})})]})}function oc({id:e,task:n,expanded:r,busy:i,models:s,onToggle:a,onSave:l,onRemove:o}){let c=!!n.role,d=s.find(e=>e.ref===n.model),u=d?.model.supportsThinking?d.model.supportedThinkingEfforts:["default"],p=(e,t)=>l({...n,[e]:t});return(0,t.jsxs)("section",{className:"graph-task","data-task-id":e,children:[(0,t.jsxs)("button",{type:"button",className:"graph-task-summary",onClick:a,"aria-expanded":r,children:[r?(0,t.jsx)(q,{size:17}):(0,t.jsx)(aA,{size:17}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:n.name}),(0,t.jsx)("code",{children:e})]}),(0,t.jsxs)("small",{children:[c?n.role:n.model,!c&&n.thinking&&"default"!==n.thinking?` \xb7 ${n.thinking}`:""]})]}),r&&(0,t.jsxs)("div",{className:"graph-task-form",children:[(0,t.jsxs)("label",{children:["Task name",(0,t.jsx)("input",{defaultValue:n.name,disabled:i,onBlur:e=>p("name",e.target.value)})]}),(0,t.jsxs)("div",{className:"graph-execution-mode",role:"group","aria-label":"Execution mode",children:[(0,t.jsx)("button",{type:"button","aria-pressed":!c,disabled:i||!s[0],onClick:()=>l({name:n.name,model:n.model||s[0]?.ref,thinking:"default",skills:[],goal:n.goal,writes:n.writes,budget:n.budget}),children:"Inline configuration"}),(0,t.jsx)("button",{type:"button","aria-pressed":c,disabled:i,onClick:()=>l({name:n.name,role:n.role||`local/${e}`,goal:n.goal,writes:n.writes,budget:n.budget}),children:"Use a Role"})]}),c?(0,t.jsxs)("label",{children:["Role",(0,t.jsx)("input",{defaultValue:n.role,disabled:i,placeholder:"local/alignment or global/reviewer",onBlur:e=>p("role",e.target.value)}),(0,t.jsx)("span",{children:"Local Roles belong only to this Graph. Global Roles are shared and read-only here."})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("label",{children:["Model",(0,t.jsx)("select",{value:n.model??"",disabled:i,onChange:e=>p("model",e.target.value),children:s.map(e=>(0,t.jsxs)("option",{value:e.ref,children:[e.label," · ",e.ref]},e.ref))})]}),d?.model.supportsThinking&&(0,t.jsxs)("label",{children:["Thinking",(0,t.jsx)("select",{value:n.thinking??"default",disabled:i,onChange:e=>p("thinking",e.target.value),children:u.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]}),(0,t.jsxs)("label",{children:["Skills",(0,t.jsx)("input",{defaultValue:(n.skills??[]).join(", "),disabled:i,placeholder:"local/alignment, global/report-writing",onBlur:e=>p("skills",e.target.value.split(",").map(e=>e.trim()).filter(Boolean))}),(0,t.jsx)("span",{children:"Use explicit local/ or global/ references."})]})]}),(0,t.jsxs)("label",{className:"graph-task-goal",children:["Goal",(0,t.jsx)("textarea",{defaultValue:n.goal,disabled:i,onBlur:e=>p("goal",e.target.value)})]}),(0,t.jsxs)("details",{children:[(0,t.jsx)("summary",{children:"Advanced"}),(0,t.jsxs)("label",{children:["Writes",(0,t.jsx)("input",{defaultValue:(n.writes??[]).join(", "),disabled:i,onBlur:e=>p("writes",e.target.value.split(",").map(e=>e.trim()).filter(Boolean))})]})]}),(0,t.jsxs)("button",{type:"button",className:"graph-task-remove",onClick:o,disabled:i,children:[(0,t.jsx)(S,{size:15})," Remove Task"]})]})]})}function od({setError:e}){let r=lB(),i=(0,n.useMemo)(()=>or(r.models,r.providers),[r.models,r.providers]),[s,a]=(0,n.useState)([]),[l,o]=(0,n.useState)(null),[c,d]=(0,n.useState)(null),[u,p]=(0,n.useState)(null),[m,f]=(0,n.useState)(null),[g,y]=(0,n.useState)(0),[v,b]=(0,n.useState)(!1),[j,k]=(0,n.useState)({id:"",name:""}),[w,S]=(0,n.useState)(!1),[C,N]=(0,n.useState)({id:"",name:""}),[I,T]=(0,n.useState)("tasks"),M=(0,n.useCallback)(async e=>{let t=await (0,eb.apiFetch)("/v1/graphs");a(t);let n=e??t.find(e=>!e.error)?.id??null;return o(n),n},[]),R=(0,n.useCallback)(async t=>{f("loading"),o(t),p(null);try{let[n,r]=await Promise.all([(0,eb.apiFetch)(`/v1/graphs/${encodeURIComponent(t)}`),(0,eb.apiFetch)(`/v1/graphs/${encodeURIComponent(t)}/versions`)]);d(n),y(r.reduce((e,t)=>Math.max(e,t.version),0)),e(null)}catch(t){d(null),e(t.message)}finally{f(null)}},[e]);(0,n.useEffect)(()=>{let t=!1,n=window.setTimeout(()=>{M().then(e=>{!t&&e&&R(e)}).catch(n=>{t||e(n.message)})},0);return()=>{t=!0,window.clearTimeout(n)}},[R,M,e]);let E=async()=>{if(j.id.trim()&&j.name.trim()){f("creating");try{let t=await (0,eb.apiFetch)("/v1/graphs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:j.id.trim(),name:j.name.trim()})});b(!1),k({id:"",name:""}),d(t),y(0),o(t.id),await M(t.id),e(null)}catch(t){e(t.message)}finally{f(null)}}},z=async t=>{if(c&&!m){f("saving");try{let n=await (0,eb.apiFetch)(`/v1/graphs/${encodeURIComponent(c.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedDigest:c.digest,...t})});d(n),a(e=>e.map(e=>e.id===n.id?{...e,name:n.name,digest:n.digest,error:void 0}:e)),e(null)}catch(t){e(t.message)}finally{f(null)}}},A=async()=>{if(c&&!m){f("publishing");try{let t=await (0,eb.apiFetch)(`/v1/graphs/${encodeURIComponent(c.id)}/publish`,{method:"POST"});y(t.version),e(null)}catch(t){e(t.message)}finally{f(null)}}},P=async()=>{let t=i[0];if(!t)return void e("Create an active model before adding an inline Task.");let n=C.id.trim(),r=C.name.trim();n&&r&&(await z({task:{id:n,value:{name:r,model:t.ref,thinking:"default",skills:[],goal:"Describe the outcome this Task must produce."}}}),N({id:"",name:""}),S(!1),p(n))};return(0,t.jsxs)("div",{className:"graph-workspace",children:[(0,t.jsx)(oo,{graphs:s,selected:l,onSelect:e=>void R(e),onAdd:()=>b(!0)}),v&&(0,t.jsxs)("div",{className:"graph-create-strip",role:"dialog","aria-label":"Add Graph",children:[(0,t.jsxs)("label",{children:["ID",(0,t.jsx)("input",{autoFocus:!0,value:j.id,onChange:e=>k(t=>({...t,id:e.target.value})),placeholder:"rna-seq"})]}),(0,t.jsxs)("label",{children:["Name",(0,t.jsx)("input",{value:j.name,onChange:e=>k(t=>({...t,name:e.target.value})),placeholder:"RNA-seq"})]}),(0,t.jsx)("button",{type:"button",onClick:()=>void E(),disabled:"creating"===m,children:"creating"===m?"Creating…":"Create Graph"}),(0,t.jsx)("button",{type:"button",onClick:()=>b(!1),children:"Cancel"})]}),(0,t.jsx)("div",{className:"graph-mobile-segments",role:"tablist","aria-label":"Graph views",children:["tasks","graph","build"].map(e=>(0,t.jsx)("button",{type:"button",role:"tab","aria-selected":I===e,onClick:()=>T(e),children:e},e))}),!c&&"loading"===m&&(0,t.jsxs)("div",{className:"graph-loading",children:[(0,t.jsx)(em,{className:"spin",size:18})," Loading Graph…"]}),!c&&"loading"!==m&&0===s.length&&(0,t.jsxs)("div",{className:"graph-welcome",children:[(0,t.jsx)(h,{size:28}),(0,t.jsx)("h2",{children:"Create your first Graph"}),(0,t.jsx)("p",{children:"Compose reusable Tasks and their dependencies without choosing a Project."}),(0,t.jsxs)("button",{type:"button",onClick:()=>b(!0),children:[(0,t.jsx)(x,{size:16})," Add Graph"]})]}),c&&(0,t.jsxs)("div",{className:"graph-document",children:[(0,t.jsxs)("header",{className:"graph-document-header",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{children:"Graph"}),(0,t.jsx)("h2",{children:c.document.name}),(0,t.jsx)("code",{children:c.document.id})]}),(0,t.jsxs)("div",{className:"graph-document-actions",children:[(0,t.jsxs)("span",{children:["v",g||"draft"]}),(0,t.jsx)("div",{className:`graph-save-state ${"saving"===m?"is-saving":""}`,children:"saving"===m?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(em,{className:"spin",size:14})," Saving"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U,{size:14})," Saved"]})}),(0,t.jsx)("button",{type:"button",onClick:()=>void A(),disabled:!!m||0===Object.keys(c.document.tasks).length,children:"publishing"===m?"Publishing…":"Publish"})]})]}),(0,t.jsxs)("main",{className:`graph-editor-view is-${I}`,children:[(0,t.jsxs)("section",{className:"graph-tasks-pane",children:[(0,t.jsxs)("div",{className:"graph-section-heading",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{children:"Tasks"}),(0,t.jsx)("p",{children:"Execution configuration. Tasks are collapsed by default."})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>S(e=>!e),children:[(0,t.jsx)(x,{size:16})," Add Task"]})]}),w&&(0,t.jsxs)("div",{className:"graph-add-task",children:[(0,t.jsx)("input",{value:C.id,onChange:e=>N(t=>({...t,id:e.target.value})),placeholder:"task_id"}),(0,t.jsx)("input",{value:C.name,onChange:e=>N(t=>({...t,name:e.target.value})),placeholder:"Task name"}),(0,t.jsx)("button",{type:"button",onClick:()=>void P(),children:"Add"})]}),(0,t.jsxs)("div",{className:"graph-task-list",children:[Object.keys(c.document.tasks).sort().map(e=>(0,t.jsx)(oc,{id:e,task:c.document.tasks[e],expanded:u===e,busy:!!m,models:i,onToggle:()=>p(t=>t===e?null:e),onSave:t=>{z({task:{id:e,value:t}})},onRemove:()=>{window.confirm(`Remove Task “${c?.document.tasks[e]?.name??e}”?`)&&z({task:{id:e,value:null}})}},e)),0===Object.keys(c.document.tasks).length&&(0,t.jsx)("div",{className:"graph-empty-state",children:"No Tasks yet. Add one or ask Builder to draft the Graph."})]})]}),(0,t.jsxs)("section",{className:"graph-dependencies-pane",children:[(0,t.jsx)("div",{className:"graph-section-heading",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{children:"Graph"}),(0,t.jsx)("p",{children:"Dependency orchestration. Role details stay inside Tasks."})]})}),(0,t.jsx)(ol,{document:c.document,busy:!!m,onOpenTask:e=>{p(e),T("tasks"),requestAnimationFrame(()=>document.querySelector(`[data-task-id="${CSS.escape(e)}"]`)?.scrollIntoView({behavior:"smooth",block:"start"}))},onChange:(e,t)=>void z({dependencies:{taskId:e,depends:t}})})]}),(0,t.jsx)(os,{graphId:c.id,models:i,setError:e,onApplied:e=>{d(e),a(t=>t.map(t=>t.id===e.id?{...t,name:e.name,digest:e.digest,error:void 0}:t))}})]})]})]})}function ou({view:e,models:r,providers:i,onBackToChat:s,onOpenMobileNav:a,menuTriggerRef:l}){let[o,c]=(0,n.useState)(null);return(0,t.jsxs)("div",{className:"settings-view","data-testid":"roles"===e?"roles-page":"graphs-page",children:[(0,t.jsx)("button",{ref:l,type:"button",className:"workspace-mobile-menu",onClick:a,"aria-label":"Open navigation",children:(0,t.jsx)(L,{size:20})}),(0,t.jsxs)("header",{className:"workspace-page-header",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{children:"roles"===e?"Roles":"Graphs"}),(0,t.jsx)("p",{children:"roles"===e?"Global reusable execution presets for Chat and Graph Tasks.":"Global Task graphs. Every published Graph can run in any Session."})]}),(0,t.jsxs)("button",{type:"button",className:"settings-view-back",onClick:s,children:[(0,t.jsx)(sX,{size:15})," Chat"]})]}),o&&(0,t.jsxs)("div",{className:"error-bar workspace-page-error",role:"alert",children:[(0,t.jsx)("span",{children:o}),(0,t.jsx)("button",{type:"button",onClick:()=>c(null),"aria-label":"Dismiss error",children:(0,t.jsx)(m,{size:16})})]}),(0,t.jsx)("div",{className:"workspace-page-body",children:"roles"===e?(0,t.jsx)(oi,{models:r,providers:i,setError:c}):(0,t.jsx)(od,{setError:c})})]})}e.s(["AppShell",0,function({initialView:e="chat"}){var r;let i,s,a=(r="(max-width: 640px)",i=(0,n.useCallback)(e=>{let t=window.matchMedia(r);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},[r]),s=(0,n.useCallback)(()=>window.matchMedia(r).matches,[r]),(0,n.useSyncExternalStore)(i,s,()=>!1)),{projects:l,selectedProject:o,switchProject:c,createProjectOpen:d,openCreateProject:u,confirmCreateProject:p,cancelCreateProject:h,createProjectBusy:m,settingsOpen:f,settingsTab:g,openSettings:x,closeSettings:y,workspaceFor:v,togglePinProject:b,pinnedProjectIds:j,renameProject:k,deleteProject:w}=(0,lU.useWorkspace)(),[S,C]=(0,n.useState)(null),[N,I]=(0,n.useState)(e??"chat"),T=(0,n.useCallback)(e=>{I(e),window.history.replaceState(null,"","chat"===e?"/":`/?view=${e}`)},[]);(0,n.useEffect)(()=>{let e=()=>{let e=new URLSearchParams(window.location.search).get("view");("roles"===e||"graphs"===e||"chat"===e)&&I(e)};return e(),window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]);let M=(0,n.useCallback)(e=>{C(e)},[]),R=l_({initialWidth:280,minWidth:264,maxWidth:420,storageKey:"--ennote-sidebar-width"}),E=l_({initialWidth:420,minWidth:280,maxWidth:1e3,storageKey:"--ennote-right-panel-width",direction:"left"}),z=sA(),[A,P]=(0,n.useState)(!0),[L,D]=(0,n.useState)(!1),[_,O]=(0,n.useState)(null),W=(0,n.useRef)(null),U=(0,n.useRef)(null),q=(0,n.useCallback)(()=>{P(!1),window.requestAnimationFrame(()=>{(W.current??U.current)?.focus()})},[]);(0,n.useEffect)(()=>{if(!a)return;let e=window.requestAnimationFrame(()=>P(!1));return()=>window.cancelAnimationFrame(e)},[a]),(0,n.useEffect)(()=>{if(!a||!A)return;let e=document.querySelector(".sidebar-container");if(!e)return;let t=t=>{if("Escape"===t.key){t.preventDefault(),q();return}if("Tab"!==t.key)return;let n=Array.from(e.querySelectorAll('button:not(:disabled), input:not(:disabled), select:not(:disabled), [href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getClientRects().length>0);if(!n.length)return;let r=n[0],i=n[n.length-1];t.shiftKey&&document.activeElement===r?(t.preventDefault(),i.focus()):t.shiftKey||document.activeElement!==i||(t.preventDefault(),r.focus())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[q,a,A]);let B=function(e){let[t,r]=(0,n.useState)([]),[i,s]=(0,n.useState)([]),[a,l]=(0,n.useState)("active"),[o,c]=(0,n.useState)(""),[d,u]=(0,n.useState)(!1),[p,h]=(0,n.useState)(null),[m,f]=(0,n.useState)(null),[g,x]=(0,n.useState)(null),[y,v]=(0,n.useState)(""),b=(0,n.useRef)(0),j=(0,n.useRef)(null),k=(0,n.useRef)(a),w=(0,n.useCallback)(e=>{k.current=e,l(e)},[]),S=(0,n.useCallback)(async(t=0)=>{if(j.current?.abort(),!e){r([]),s([]),h(null),u(!1);return}let n=new AbortController;j.current=n;let i=++b.current;if(t>0&&await new Promise(e=>setTimeout(e,t)),n.signal.aborted||b.current!==i)return;u(!0);let l=`/v1/projects/${encodeURIComponent(e)}/sessions`,c=new URLSearchParams({status:a}),d=o.trim(),p=`${e}:${a}:${d}`;d&&c.set("q",d);try{let e=(0,eb.apiFetch)(`${l}?status=active`,{signal:n.signal}),t="active"!==a||d?(0,eb.apiFetch)(`${l}?${c.toString()}`,{signal:n.signal}):e,[o,u]=await Promise.all([e,t]);if(n.signal.aborted||b.current!==i)return;r(o),s(u),h(p),x(null)}catch(e){n.signal.aborted||b.current!==i||(h(p),x(e.message))}finally{n.signal.aborted||b.current!==i||u(!1)}},[e,o,a]);(0,n.useEffect)(()=>{let e=window.setTimeout(()=>void S(0),200);return()=>{window.clearTimeout(e),j.current?.abort()}},[S]);let C=(0,n.useCallback)(()=>S(0),[S]),N=(0,n.useCallback)(e=>{r(t=>"active"===e.status?t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[e,...t]:t.filter(t=>t.id!==e.id)),s(t=>t.map(t=>t.id===e.id?e:t).filter(e=>e.status===k.current))},[]),I=(0,n.useCallback)(async(e,t)=>{f(e.id);try{return await (0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(e.id)}/${t}`,{method:"POST",body:"{}"}),v(`${"archive"===t?"Archived":"Restored"} ${e.title}`),x(null),await C(),!0}catch(e){return x(e.message),!1}finally{f(null)}},[C]),T=e?`${e}:${a}:${o.trim()}`:null;return{activeSessions:t,visibleSessions:i,view:a,setView:w,query:o,setQuery:c,loading:d||null!==T&&p!==T,mutatingId:m,error:g,setError:x,announcement:y,refresh:C,replaceSession:N,archive:e=>I(e,"archive"),restore:e=>I(e,"restore")}}(o),H=function(e,t,r){let[i,s]=(0,n.useState)({}),[a,l]=(0,n.useState)({}),[o,c]=(0,n.useState)(lW),d=(0,n.useRef)(0),u=(0,n.useMemo)(()=>{let e=[],n=t=>{t&&!e.includes(t)&&e.push(t)};for(let e of(n(r),t))n(e);return e},[r,t]),p=(0,n.useCallback)(async t=>{let n=++d.current,r=e.find(e=>e.id===t),i=r?.name??t;s(e=>({...e,[t]:{projectId:t,projectName:i,sessions:[],loading:!0,error:null}}));try{let e=await (0,eb.apiFetch)(`/v1/projects/${encodeURIComponent(t)}/sessions?status=active`);if(d.current!==n)return;s(n=>({...n,[t]:{projectId:t,projectName:i,sessions:e,loading:!1,error:null}}))}catch(e){if(d.current!==n)return;s(n=>({...n,[t]:{projectId:t,projectName:i,sessions:[],loading:!1,error:e.message}}))}},[e]);(0,n.useEffect)(()=>{for(let e of u)i[e]||p(e)},[u,i,p]),(0,n.useEffect)(()=>{r&&p(r)},[r,p]),(0,n.useEffect)(()=>{let e=window.setInterval(()=>{for(let e of u)p(e)},3e4);return()=>window.clearInterval(e)},[u,p]);let h=(0,n.useCallback)(e=>void p(e),[p]),m=(0,n.useCallback)(()=>{for(let e of u)p(e)},[u,p]),f=(0,n.useCallback)(async e=>{if(!a[e])try{let t=await (0,eb.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/sessions?status=archived`);l(n=>({...n,[e]:t}))}catch{l(t=>({...t,[e]:[]}))}},[a]),g=(0,n.useCallback)(async e=>{try{let t=await (0,eb.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/sessions?status=archived`);l(n=>({...n,[e]:t}))}catch{l(t=>({...t,[e]:[]}))}},[]),x=(0,n.useCallback)(e=>{c(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{window.localStorage.setItem(lO,JSON.stringify([...n]))}catch{}return n})},[]);return{groups:(0,n.useMemo)(()=>u.map(e=>i[e]).filter(e=>!!e),[u,i]),archived:a,collapsed:o,toggleCollapsed:x,refresh:h,refreshAll:m,openArchived:f,refreshArchived:g}}(l,j,o),V=lB(),K=B.replaceSession,J=B.activeSessions.find(e=>e.id===S),G=function(e){let[t,r]=(0,n.useState)({templates:[],diagnostics:[],loading:!1,error:null}),i=(0,n.useRef)(null),s=(0,n.useCallback)(async()=>{if(!e)return void r({templates:[],diagnostics:[],loading:!1,error:null});i.current?.abort();let t=new AbortController;i.current=t,r(e=>({...e,loading:!0,error:null}));try{let n=await (0,eb.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/prompt-templates`,{signal:t.signal});if(t.signal.aborted)return;r({templates:n.templates,diagnostics:n.diagnostics,loading:!1,error:null})}catch(e){if(t.signal.aborted)return;r(t=>({...t,loading:!1,error:e.message??"Failed to load prompt templates"}))}},[e]);return(0,n.useEffect)(()=>{e&&s()},[s,e]),(0,n.useEffect)(()=>()=>{i.current?.abort()},[]),{...t,refresh:s}}(o),Z=function(e){var t;let r,i,s,a,l,o,{selectedSession:c,sessionRecord:d,selectedProject:u,promptCatalog:p,settings:h,replaceSession:m}=e,f=(0,n.useMemo)(()=>new Map(h.models.map(e=>[e.id,e.displayName||e.modelName])),[h.models]),g=(0,n.useCallback)((e,t)=>(e?f.get(e):void 0)??t,[f]),x=d?.activeBranchId,y=d?.activeLeafMessageId,v=(0,n.useCallback)(e=>m(e),[m]),b=(0,n.useCallback)(async()=>{if(!c)return null;let e=await (0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(c)}`);return m(e),e},[m,c]),j=(t={resolveModel:g},r=t?.resolveModel,i=c?l4.getStore(c):null,s=(0,n.useSyncExternalStore)(i?i.subscribe:l6,i?i.getSnapshot:()=>l5,i?i.getServerSnapshot:()=>l5),(0,n.useEffect)(()=>{i&&i.ensureLoaded(x)},[i,x]),a=!!c&&s.loaded&&s.dataBranchId===x,l=function(e,t){let[r,i]=(0,n.useState)(new Map);return(0,n.useEffect)(()=>{if(!e)return void i(new Map);let t=!1;return(0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/turn-metrics`).then(e=>{t||i(new Map(e.map(e=>[e.runId,e])))}).catch(()=>{}),()=>{t=!0}},[e,t]),r}(c,s.activeRun?.id??null),o=(0,n.useMemo)(()=>a?function(e,t,n,r){let i=[],s=null,a=0,l=new Map,o=()=>{s&&(s.runId&&(s.metrics=n?.get(s.runId)),(s.user||s.steps.length>0)&&i.push(s),s=null,l.clear())};for(let n of function(e,t){let n=e.filter(e=>"private"!==e.visibility&&"room_control"!==e.visibility),r=new Set(n.map(e=>e.id)),i=[...new Map(t.filter(e=>"completed"===e.status).map(e=>[e.id,e])).values()].sort((e,t)=>e.createdAt.localeCompare(t.createdAt)),s=new Map,a=new Map;for(let e of i)e.firstKeptMessageId&&r.has(e.firstKeptMessageId)?lX(s,e.firstKeptMessageId,e):e.sourceThroughMessageId&&r.has(e.sourceThroughMessageId)&&lX(a,e.sourceThroughMessageId,e);return n.flatMap(e=>[...(s.get(e.id)??[]).map(e=>({kind:"checkpoint",value:e})),{kind:"message",value:e},...(a.get(e.id)??[]).map(e=>({kind:"checkpoint",value:e}))])}(e,t)){if("checkpoint"===n.kind){var c;o(),i.push((c=n.value,{kind:"checkpoint",id:`compaction-${c.id}`,reason:c.reason,summary:c.summary,reclaimedTokens:c.reclaimedTokens,createdAt:c.createdAt}));continue}!function(e){if("user"===e.role){o(),s={kind:"turn",id:`turn-${e.id}`,user:{id:e.id,sourceMessageId:e.id,text:e.parts.map(e=>"text"===e.type?e.text:"image"===e.type?`[Image \xb7 ${e.image.width}\xd7${e.image.height}]`:"image_description"===e.type?e.imageDescription.text:"").filter(Boolean).join("\n\n"),createdAt:e.createdAt},steps:[],messageIds:[e.id]};return}let t=(s||(a+=1,s={kind:"turn",id:`turn-orphan-${a}`,steps:[],messageIds:[]}),s);t.messageIds.push(e.id),e.runId&&(t.runId=t.runId??e.runId),"assistant"===e.role?function(e,t){let n=[],i=[],s=()=>{if(0===n.length)return;let i={...t.speakerSnapshot,modelProfileId:t.modelProfileId,apiModel:t.apiModel};if(r){let e=r(t.modelProfileId,t.apiModel);e&&(i.modelName=e)}e.steps.push({kind:"assistant",id:`${t.id}-assistant-${e.steps.length}`,sourceMessageId:t.id,blocks:n,speaker:i,createdAt:t.createdAt}),n=[]},a=()=>{0!==i.length&&(lY(e,i,l),i=[])};for(let e of t.parts)if("tool_call"===e.type){s();let n={id:`${t.id}-${e.toolCall.id}`,toolCallId:e.toolCall.id,toolName:e.toolCall.name,arguments:e.toolCall.arguments,argumentsFragment:e.toolCall.argumentsFragment,state:e.toolCall.partial?"interrupted":"pending",riskClass:st(e.toolCall.name),sourceMessageIds:[t.id],runId:t.runId};i.push(n),l.set(n.toolCallId,n)}else{var o;a();let t="text"===(o=e).type?{kind:"text",text:o.text}:"thinking"===o.type?{kind:"thinking",text:o.text}:"image"===o.type?{kind:"image",artifactId:o.image.artifactId,mimeType:o.image.mimeType,width:o.image.width,height:o.image.height}:"image_description"===o.type?{kind:"image_description",artifactId:o.imageDescription.artifactId,text:o.imageDescription.text}:null;t&&n.push(t)}s(),a()}(t,e):"tool"===e.role&&function(e,t){let n=[];for(let e of t.parts){if("tool_result"!==e.type)continue;let r=l.get(e.toolResult.toolCallId);if(r)r.result={content:e.toolResult.content,isError:e.toolResult.isError,artifacts:e.toolResult.artifacts??[]},r.state=l0(e.toolResult.content,e.toolResult.isError),r.sourceMessageIds.push(t.id);else{let r={id:`${t.id}-${e.toolResult.toolCallId}`,toolCallId:e.toolResult.toolCallId,toolName:e.toolResult.toolName,result:{content:e.toolResult.content,isError:e.toolResult.isError,artifacts:e.toolResult.artifacts??[]},state:l0(e.toolResult.content,e.toolResult.isError),riskClass:st(e.toolResult.toolName),sourceMessageIds:[t.id],runId:t.runId};l.set(r.toolCallId,r),n.push(r)}}n.length>0&&lY(e,n,l)}(t,e)}(n.value)}return{nodes:i,openTurn:s,calls:l,syntheticTurn:a}}(s.canonical,s.checkpoints,l,r):oe,[a,s.canonical,s.checkpoints,l,r]),{messages:(0,n.useMemo)(()=>(function(e,t,n,r,i){if(0===t.length){let t=function(e,t){if(!e)return null;let n={...e};return(n.runId&&(n.metrics=t?.get(n.runId)),n.user||0!==n.steps.length)?n:null}(e.openTurn,n);return t?[...e.nodes,t]:e.nodes}let s=[...e.nodes],a=new Map(e.calls),l=e.syntheticTurn,o=e.openTurn,c=null!==o,d=()=>{if(!o)return;let e=c?{...o}:o;e.runId&&(e.metrics=n?.get(e.runId)),(e.user||e.steps.length>0)&&s.push(e),o=null,c=!1,a.clear()};for(let e of t)!function(e){if("user"===e.role&&"steer"!==e.kind){d(),o={kind:"turn",id:`turn-${e.id}`,user:{id:e.id,text:e.text,sourceMessageId:e.sourceMessageId,createdAt:e.createdAt},steps:[],messageIds:[e.sourceMessageId??e.id]},c=!1;return}let t=(()=>{if(null===o)return l+=1,o={kind:"turn",id:`turn-orphan-${l}`,steps:[],messageIds:[]},c=!1,o;if(c){var e;for(let t of(o={...e=o,messageIds:[...e.messageIds],steps:e.steps.map(e=>"tool_batch"===e.kind?{...e,activities:e.activities.map(e=>({...e,sourceMessageIds:[...e.sourceMessageIds],result:e.result?{...e.result}:void 0}))}:e)},a.clear(),o.steps))if("tool_batch"===t.kind)for(let e of t.activities)a.set(e.toolCallId,e);c=!1}return o})();if(t.messageIds.push(e.sourceMessageId??e.id),e.runId&&(t.runId=t.runId??e.runId),"user"===e.role&&"steer"===e.kind)return t.steps.push({kind:"steer",id:e.id,text:e.text.replace(/^↪\s*/,""),createdAt:e.createdAt});if("assistant"===e.role){let n=[];e.thinking&&n.push({kind:"thinking",text:e.thinking}),e.text&&n.push({kind:"text",text:e.text}),n.length>0&&t.steps.push({kind:"assistant",id:e.id,sourceMessageId:e.sourceMessageId,blocks:n,speaker:function(e,t){if(!e)return;let n=e.effectiveConfig??{},r=e.requestedConfig??{},i="string"==typeof n.modelProfileId&&n.modelProfileId?n.modelProfileId:"string"==typeof r.modelProfileId?r.modelProfileId:void 0,s="string"==typeof n.apiModel&&n.apiModel?n.apiModel:"string"==typeof r.apiModel?r.apiModel:void 0,a=t?t(i,s):void 0;return{...e.speakerSnapshot,modelProfileId:i,apiModel:s,modelName:a}}(i,r),createdAt:e.createdAt});return}if("tool"===e.role){let n=e.toolCallId??e.id,r=a.get(n);if(r){e.arguments&&(r.arguments=e.arguments),e.runId&&(r.runId=e.runId),r.result="running"===e.toolState?r.result:{content:e.text,isError:!!e.isError,artifacts:[]},r.state=e.toolState??l0(e.text,!!e.isError),r.sourceMessageIds.push(e.sourceMessageId??e.id);return}lY(t,[{id:e.id,toolCallId:n,toolName:e.toolName??"tool",arguments:e.arguments,argumentsFragment:e.argumentsFragment,result:"running"===e.toolState?void 0:{content:e.text,isError:!!e.isError,artifacts:[]},state:e.toolState??l0(e.text,!!e.isError),riskClass:st(e.toolName??"tool"),sourceMessageIds:[e.sourceMessageId??e.id],runId:e.runId}],a)}}(e);return d(),s})(o,s.transient,l,r,s.activeRun),[o,s.transient,l,r,s.activeRun]),loading:!!c&&!a&&!s.error||s.loading,loadingOlder:s.loadingOlder,historyError:s.error,hasMore:s.hasMore,loadOlder:i?i.loadOlder:l3,refreshLatest:i?i.refreshLatest:l9,appendTransient:i?i.appendTransient:l8,upsertTransient:i?i.upsertTransient:l7,activeRun:s.activeRun,pendingApproval:s.pendingApproval,queuedInputs:s.queuedInputs,delegationActive:s.delegationActive,lastSeq:s.lastSeq,workerInstanceId:s.workerInstanceId,streamOpen:s.streamOpen}),k=function({sessionId:e,lineageId:t,appendMessage:r,upsertMessage:i,refreshLatest:s,refreshSession:a,activeRun:l,pendingApproval:o}){let[c,d]=(0,n.useState)(null),[u,p]=(0,n.useState)(""),[h,m]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[x,y]=(0,n.useState)(null),[v,b]=(0,n.useState)([]),j=(0,n.useRef)(null),k=(0,n.useRef)(null),w=(0,n.useRef)(0),S=(0,n.useRef)(0),C=(0,n.useRef)(e),N=(0,n.useRef)(!1),I=(0,n.useRef)(null),[T,M]=(0,n.useState)(0);(0,n.useEffect)(()=>{C.current=e},[e]);let R=(0,n.useCallback)(async(e,t,n)=>{let r=C.current;if(!r||e.sessionId!==r)return;I.current=e.id,N.current=!0,p(o?"Waiting for approval":"context_compaction"===e.runKind?"Compaction queued…":"waiting_children"===e.status?"Delegated roles are working…":"waiting_delegation_admission"===e.status?"Waiting for delegation approval":"Running…"),m(null);let l=!1;try{l="context_compaction"===e.runKind?await lZ(e.id,p,t):await lQ(e.id,i,p,m,g,t,{requested:()=>{},resolved:()=>{},delegated:()=>{},followUpConsumed:()=>{w.current===n&&b(e=>e.slice(1))}})}catch(e){l=e instanceof lG,t.aborted||w.current!==n||y(e.message)}finally{w.current===n&&(N.current=!1),l||t.aborted||w.current!==n||p("Run connection interrupted"),l&&!t.aborted&&w.current===n&&C.current===r&&(b([]),j.current=null,await a().catch(()=>null),await s(),window.setTimeout(()=>{w.current===n&&C.current===r&&p("")},1600))}},[s,a,i,o]),E=(0,n.useCallback)(e=>{let t=C.current;if(!t||e.sessionId!==t)return;let n=++w.current;j.current?.abort();let r=new AbortController;j.current=r,R(e,r.signal,n)},[R]),z=(0,n.useCallback)(()=>{d(null),p(""),m(null),g(null),y(null),b([])},[]);(0,n.useEffect)(()=>{w.current+=1,j.current?.abort(),k.current?.abort(),I.current=null,z()},[t,e,z]),(0,n.useEffect)(()=>{if(!e||l?.id)return;let t=!1;return(0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/context-usage`).then(e=>{t||g(e)}).catch(()=>{}),()=>{t=!0}},[e,l?.id]),(0,n.useEffect)(()=>{l?l.id!==I.current&&E(l):I.current&&(j.current?.abort(),I.current=null,z())},[l,E,z]);let A=l?.id??null;(0,n.useEffect)(()=>{if("Run connection interrupted"!==u||!A)return;let e=window.setTimeout(()=>M(e=>e+1),1e3);return()=>window.clearTimeout(e)},[u,A]);let P=(0,n.useRef)(l);(0,n.useEffect)(()=>{P.current=l},[l]),(0,n.useEffect)(()=>{if(0===T)return;let e=P.current;e&&(I.current=null,E(e))},[T,E]);let $=(0,n.useCallback)(async()=>{if(l)try{await (0,eb.apiFetch)(`/v1/runs/${encodeURIComponent(l.id)}/cancel`,{method:"POST"}),j.current?.abort(),w.current+=1,p("cancelled"),await a().catch(()=>null),await s()}catch(e){y(e.message)}},[l,s,a]),L=(0,n.useCallback)(async e=>{if(!l||!e.trim())return!1;try{return p("steering…"),await (0,eb.apiFetch)(`/v1/runs/${encodeURIComponent(l.id)}/inputs`,{method:"POST",body:JSON.stringify({kind:"steer",text:e,clientRequestId:lJ()})}),r({id:lJ(),role:"user",text:`↪ ${e}`,kind:"steer"}),p("waiting_for_approval"===l.status?"Waiting for approval":""),!0}catch(e){return y(lK(e,"Failed to steer the run")),!1}},[l,r]),F=(0,n.useCallback)(async e=>{if(!l||!e.trim())return{queued:!1,runEnded:!1};try{return await (0,eb.apiFetch)(`/v1/runs/${encodeURIComponent(l.id)}/inputs`,{method:"POST",body:JSON.stringify({kind:"follow_up",text:e,clientRequestId:lJ()})}),b(t=>[...t,{id:lJ(),text:e}]),{queued:!0,runEnded:!1}}catch(n){let e=lK(n,"Failed to send follow-up"),t=/not active|not_active/i.test(e);return t||y(e),{queued:!1,runEnded:t}}},[l]),D=(0,n.useCallback)(async(e,t)=>{if(!o||c)return;k.current?.abort();let n=new AbortController;k.current=n;let r=++S.current;d(e);try{if(await (0,eb.apiFetch)(`/v1/approval-requests/${encodeURIComponent(o.id)}/decision`,{method:"POST",headers:{"Idempotency-Key":lJ()},body:JSON.stringify({decision:e,clientRequestId:lJ(),standingGrantCallIndexes:t??[]}),signal:n.signal}),n.signal.aborted||S.current!==r)return;p("approved"===e?"Approval granted. Resuming…":"Approval rejected. Resuming…"),!N.current&&l&&(I.current=null,E({...l,status:"queued"}))}catch(e){n.signal.aborted||S.current!==r||y(e.message)}finally{n.signal.aborted||S.current!==r||d(null)}},[l,o,c,E]);return{activeRun:l,activeRunID:l?.id??null,contextUsage:f,compacting:l?.runKind==="context_compaction",pendingApproval:o,resolvingApproval:c,status:u,setStatus:p,usage:h,error:x,setError:y,watchRun:E,cancel:$,steer:L,followUp:F,pendingFollowUps:v,decideApproval:D}}({sessionId:c,lineageId:x,appendMessage:j.appendTransient,upsertMessage:j.upsertTransient,refreshLatest:j.refreshLatest,refreshSession:b,activeRun:j.activeRun,pendingApproval:j.pendingApproval}),w=function(e,t,r){let[i,s]=(0,n.useState)(null),[a,l]=(0,n.useState)(),[o,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(null),p=(0,n.useRef)(0),h=(0,n.useCallback)(async n=>{if(!e||r)return void s(null);let i=p.current;try{let r=await (0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/recovery`,{signal:n});n?.aborted||p.current!==i||(s(r),l(t),u(null))}catch(e){n?.aborted||p.current!==i||u(e.message)}},[r,t,e]);(0,n.useEffect)(()=>{let e=++p.current,t=new AbortController;return queueMicrotask(()=>{p.current===e&&(s(null),l(void 0),u(null),h(t.signal))}),()=>t.abort()},[t,h]);let m=(0,n.useCallback)(async()=>{if(!i?.retryable||o)return null;c(!0);try{let e="u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36),t=await (0,eb.apiFetch)(`/v1/runs/${encodeURIComponent(i.run.id)}/retry`,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":e},body:JSON.stringify({clientRequestId:e})});return s(null),u(null),t.run}catch(e){return u(e.message),null}finally{c(!1)}},[i,o]);return{recovery:a===t?i:null,retrying:o,error:d,clearError:(0,n.useCallback)(()=>u(null),[]),retry:m,refresh:h}}(c,x,k.activeRunID),S=function(e,t){let[r,i]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e)return void i(null);let n=!1,r=()=>{(0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/stats`).then(e=>{n||i(e)}).catch(()=>{})};r();let s=t?window.setInterval(r,2e3):void 0;return()=>{n=!0,void 0!==s&&window.clearInterval(s)}},[e,t]),r}(c,k.activeRunID),C=function({sessionId:e,activeBranchId:t,onSessionUpdated:r}){let[i,s]=(0,n.useState)([]),[a,l]=(0,n.useState)(null),[o,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(!1),[p,h]=(0,n.useState)(null),m=(0,n.useRef)(0),f=(0,n.useCallback)(async t=>{if(!e)return;let n=m.current;c(!0);try{let r=await (0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/branches`,{signal:t});t?.aborted||m.current!==n||(s(r??[]),l(e),h(null))}catch(e){t?.aborted||m.current!==n||h(e.message)}finally{t?.aborted||m.current!==n||c(!1)}},[e]);(0,n.useEffect)(()=>{let t=++m.current,n=new AbortController;return queueMicrotask(()=>{m.current===t&&(h(null),e?f(n.signal):c(!1))}),()=>n.abort()},[t,f,e]);let g=(0,n.useCallback)(e=>{m.current+=1,s(e.branches),l(e.session.id),r(e.session),h(null)},[r]),x=(0,n.useCallback)(async(t,n)=>{if(!e||d)return!1;u(!0);try{let r=await (0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/branches`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fromMessageId:t,...n?.trim()?{label:n.trim()}:{}})});return g(r),!0}catch(e){return h(e.message),!1}finally{u(!1)}},[g,d,e]),y=(0,n.useCallback)(async n=>{if(!e||d||n===t)return!1;u(!0);try{let t=await (0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}/branches/${encodeURIComponent(n)}/activate`,{method:"POST"});return g(t),!0}catch(e){return h(e.message),!1}finally{u(!1)}},[t,g,d,e]);return{branches:a===e?i:[],loading:o,changing:d,error:p,clearError:(0,n.useCallback)(()=>h(null),[]),refresh:f,createBranch:x,activateBranch:y}}({sessionId:c,activeBranchId:x,onSessionUpdated:v}),{composer:N,actions:I}=function(e){let{selectedSession:t,selectedProject:r,sessionRecord:i,promptCatalog:s,settings:a,runtime:l}=e,[o,c]=(0,n.useState)(""),{pendingImage:d,textAttachments:u,uploadImage:p,attachFiles:h,removeTextAttachment:m,clearPendingImage:f,clearAttachments:g,restoreAttachments:x}=function(e){let{selectedProject:t,selectedSession:r,runtime:i}=e,[s,a]=(0,n.useState)(null),[l,o]=(0,n.useState)([]),c=(0,n.useCallback)(async e=>{if(!t||!r)return;let n=new FormData;n.set("sessionId",r),n.set("file",e);try{i.setStatus("uploading image...");let e=await (0,eb.apiFetch)(`/v1/projects/${encodeURIComponent(t)}/attachments/images`,{method:"POST",body:n});a(e),i.setError(null)}catch(e){i.setError(lK(e,"Failed to attach the image"))}finally{i.setStatus("")}},[t,r,i]),d=(0,n.useCallback)(async e=>{if(!r)return;let t=e.filter(e=>e.type.startsWith("image/")),n=e.filter(e=>!e.type.startsWith("image/"));t[0]&&await c(t[0]),t.length>1&&i.setError("Only one image can be attached to a turn.");let s=[];for(let e of n){if(!function(e){if(e.type.startsWith("text/"))return!0;let t=e.name.toLowerCase().split(".").pop()??"";return ot.has(t)||["dockerfile","makefile"].includes(e.name.toLowerCase())}(e)){i.setError(`${e.name} is not a supported text attachment.`);continue}if(e.size>1048576){i.setError(`${e.name} exceeds the 1 MiB text attachment limit.`);continue}s.push({id:"u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36),name:e.name,size:e.size,text:await e.text()})}s.length&&(o(e=>[...e,...s].slice(0,3)),l.length+s.length>3&&i.setError("A turn can include at most three text files."))},[r,i,l.length,c]),u=(0,n.useCallback)(e=>{o(t=>t.filter(t=>t.id!==e))},[]),p=(0,n.useCallback)(()=>a(null),[]);return{pendingImage:s,textAttachments:l,uploadImage:c,attachFiles:d,removeTextAttachment:u,clearPendingImage:p,clearAttachments:(0,n.useCallback)(()=>{a(null),o([])},[]),restoreAttachments:(0,n.useCallback)((e,t)=>{a(e),o(t)},[])}}({selectedProject:r,selectedSession:t,runtime:l}),[y,v]=(0,n.useState)({}),[b,j]=(0,n.useState)("discuss");(0,n.useEffect)(()=>{j(aB());let e=e=>{let t=e.detail;("discuss"===t||"ask"===t||"auto"===t)&&j(t)};return window.addEventListener(aU,e),()=>window.removeEventListener(aU,e)},[]);let[k,w]=(0,n.useState)("default"),[S,C]=(0,n.useState)({open:!1,instructions:"",busy:!1}),{roles:N,selectedRoleId:I,setSelectedRoleId:T}=function(e){let[t,r]=(0,n.useState)(null),[i,s]=(0,n.useState)([]);return(0,n.useLayoutEffect)(()=>{r(null)},[e]),(0,n.useEffect)(()=>{if(!e)return;let t=!1;return(0,eb.apiFetch)("/v1/global-roles").then(async e=>{let n=await Promise.all(e.filter(e=>!e.error).map(async e=>{try{let[t,n]=await Promise.all([(0,eb.apiFetch)(`/v1/global-roles/${encodeURIComponent(e.id)}`),(0,eb.apiFetch)(`/v1/global-roles/${encodeURIComponent(e.id)}/versions`)]),r=n.at(-1);if(!r)return null;return{id:e.id,handle:t.document.handle,name:t.document.name,description:t.document.description,positioning:t.document.positioning,icon:t.document.icon,color:t.document.color,scope:"global",status:"active",sourceKind:"managed",sourceLocator:t.path,currentVersionId:`v${String(r.version).padStart(6,"0")}`,currentVersion:r.version,updatedAt:r.publishedAt}}catch{return null}}));if(t)return;let i=n.filter(e=>null!==e);s(i),r(e=>i.some(t=>t.id===e)?e:null)}).catch(async()=>{try{let n=new URLSearchParams({projectId:e,status:"active",limit:"100"}),i=await (0,eb.apiFetch)(`/v1/roles?${n}`);if(t)return;let a=i.items.filter(e=>!!e.currentVersionId);s(a),r(e=>a.some(t=>t.id===e)?e:null)}catch{t||s([])}}),()=>{t=!0}},[e]),{roles:i,selectedRoleId:t,setSelectedRoleId:r}}(r),M=(0,n.useRef)(t),{setInputVersioned:R,expandDraftOrFallback:E,expandedVersion:z,draftVersion:A,flowCatalog:P,commandPanelOpen:$,promptPanelDismissed:L,setPromptPanelDismissed:F,expanding:D,expandDiag:_,setExpandDiag:O}=function(e){let{selectedProject:t,selectedSession:r,input:i,promptCatalog:s,roles:a,setInput:l,setError:o}=e,[c,d]=(0,n.useState)(0),[u,p]=(0,n.useState)(null),[h,m]=(0,n.useState)(!1),[f,g]=(0,n.useState)(null),[x,y]=(0,n.useState)(!1),v=(0,n.useRef)(null),[b,j]=(0,n.useState)([]),k=(0,n.useCallback)(e=>{l(e),d(e=>e+1),p(null),(!e.startsWith("/")||/\s/.test(e.slice(1)))&&y(!1)},[l]),w=(0,n.useCallback)(async()=>{try{let e=await (0,eb.apiFetch)("/v1/graphs");j((e??[]).filter(e=>(e.latestVersion??0)>0).map(e=>({name:e.id,version:e.latestVersion})))}catch{}},[]);(0,n.useEffect)(()=>{let e=window.setTimeout(()=>void w(),0);return()=>window.clearTimeout(e)},[w]);let S=!!(t&&!i.slice(1).match(/[\s]/)&&(i.startsWith("/")&&s.templates.length>0||i.startsWith("@role")&&a.length>0||i.startsWith("@graph")&&b.length>0||i.startsWith("@")&&(a.length>0||b.length>0))),C=(0,n.useRef)(!1);(0,n.useEffect)(()=>{S&&!C.current&&(s.refresh(),w()),C.current=S},[S,s,w]);let N=(0,n.useCallback)(async(e,t)=>{v.current?.abort();let n=new AbortController;v.current=n;try{let r=await (0,eb.apiFetch)(`/v1/projects/${encodeURIComponent(t)}/prompt-templates/expand`,{method:"POST",body:JSON.stringify({invocation:e}),signal:n.signal});if(n.signal.aborted)return null;return r}catch(e){if(n.signal.aborted)return null;throw e}},[]);return{setInputVersioned:k,expandDraftOrFallback:(0,n.useCallback)(async(e,n,i)=>{m(!0),g(null);try{let i=await N(e,n.project);if(!i||n.project!==t||n.session!==r||n.draftVersion!==c)return null;switch(i.case){case"matched":{let e=i.text.trim();if(!e)return o("Expanded prompt is empty."),{status:"empty"};return l(e),d(e=>e+1),p(c+1),{status:"matched",text:e,diagnostics:i.diagnostics}}case"not_found":case"invalid_invocation":return{status:"fallthrough"}}}catch(e){return o(lK(e,i)),null}finally{m(!1)}},[o,t,r,c,N,l,d,p,m,g]),expandedVersion:u,draftVersion:c,flowCatalog:b,commandPanelOpen:S,promptPanelDismissed:x,setPromptPanelDismissed:y,expanding:h,expandDiag:f,setExpandDiag:g}}({selectedProject:r,selectedSession:t,input:o,promptCatalog:s,roles:N,setInput:c,setError:l.setError});(0,n.useEffect)(()=>{M.current=t},[t]),(0,n.useLayoutEffect)(()=>{R(""),g()},[t,R,g]);let W=t?y[t]??i?.defaultModelProfileId??a.models.find(e=>e.isDefault)?.id??a.models[0]?.id??null:null,U=(0,n.useCallback)(()=>{var e;let t,n;return e=a.policies,t=e.filter(e=>"tool"===e.kind&&"active"===e.status&&e.config.mode===b),n=`builtin-tool-${b}-v1`,t.find(e=>e.id===n)?.id??t[0]?.id},[b,a.policies]),q=(0,n.useCallback)(()=>{let e=l.activeRunRecord?.requestedConfig;return function(e,t){if("string"!=typeof t||!t)return;let n=e.find(e=>e.id===t&&"tool"===e.kind),r=n?.config.mode;if("discuss"===r||"ask"===r||"auto"===r)return r;let i=/^builtin-tool-(discuss|ask|auto)-v\d+$/.exec(t)?.[1];return"discuss"===i||"ask"===i||"auto"===i?i:void 0}(a.policies,e?.toolPolicyProfileId)??b},[l.activeRunRecord,b,a.policies]),B=(0,n.useCallback)(async(e,n)=>{if(!t)return;let r=function(e,t){if(0===t.length)return e;let n=t.map(e=>[`--- Attached file: ${e.name} ---`,e.text,`--- End attached file: ${e.name} ---`].join("\n"));return[e.trim(),...n].filter(Boolean).join("\n\n")}(e,u),i=u.length?`[Files: ${u.map(e=>e.name).join(", ")}]`:"";R(""),g(),l.setStatus("sending..."),l.appendTransient({id:on(),role:"user",text:[e,d?`[Image: ${d.name}]`:"",i].filter(Boolean).join("\n")});try{let e=d?{content:[...r?[{type:"text",text:r}]:[],{type:"image",artifactId:d.id}]}:{text:r},i=N.find(e=>e.id===I)??null,s=`/v1/sessions/${encodeURIComponent(t)}/invocations`,a=i&&i.currentVersionId?{...e,target:{kind:"role",objectId:i.id,versionId:i.currentVersionId,contextMode:"room"}}:{...{...e,config:{toolPolicyProfileId:n,...W?{modelProfileId:W}:{},...k?{thinkingEffort:k}:{}}},target:{kind:"host"}},o=await (0,eb.apiFetch)(s,{method:"POST",headers:{"Idempotency-Key":on()},body:JSON.stringify(a)});if(M.current!==t)return;l.setError(null),l.watchRun(o.run)}catch(e){M.current===t&&(x(d,u),l.setError(lK(e,"Failed to send the message")))}},[t,d,u,l,W,I,N,R,k,g,x]),H=(0,n.useCallback)(async(e,n,r)=>{if(!t)return l.setError("Select a session before invoking a graph."),!1;let i={};if(r)for(let e of r.split(/\s+/)){let[t,...n]=e.split("=");t&&n.length>0&&(i[t]=n.join("="))}try{return await (0,eb.apiFetch)(`/v1/graphs/${encodeURIComponent(e)}/runs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:t,name:e,version:n??0,inputs:i})}),R(""),l.setError(null),!0}catch(e){return l.setError(e instanceof Error?e.message:"Failed to invoke graph"),!1}},[t,l,R]),V=U(),K=(0,n.useCallback)(async()=>{if(!t||!o.trim()&&!d&&0===u.length||l.activeRunID)return;let e=o.trim().match(/^\/invoke_agent_flow\s+(\S+)(?:\s+([\s\S]+))?$/);if(e){let[t,n]=e[1].split("@");H(t,n?Number(n):void 0,e[2]);return}let n=o.trim().match(/^@graph:([\w.-]+)(?:@(\d+))?(?:\s+([\s\S]+))?$/);if(n)return void H(n[1],n[2]?Number(n[2]):void 0,n[3]);if(!V&&!I)return void l.setError(`The ${b} permission policy is unavailable.`);if(o.startsWith("/")&&z!==A&&r){let e=await E(o,{project:r,session:t,draftVersion:A},"Failed to expand prompt template");if(!e)return;if("matched"===e.status){e.diagnostics.some(e=>"arguments_fallback"===e.code)&&O("Arguments could not be fully parsed; using raw input.");return}"fallthrough"===e.status&&B(o,V??"");return}B(o,V??"")},[t,o,d,u.length,V,b,l,B,r,I,z,A,H,E,O]),J=(0,n.useCallback)(async()=>{if(l.activeRunID&&o.trim()){if(o.startsWith("/")&&z!==A&&r){let e=await E(o,{project:r,session:t,draftVersion:A},"Failed to expand");if(!e||"matched"===e.status)return;"fallthrough"===e.status&&(R(""),await l.steer(o)||R(o));return}R(""),await l.steer(o)||R(o)}},[l,o,r,t,z,A,R,E]),G=(0,n.useCallback)(async()=>{if(!l.activeRunID||!o.trim())return;R("");let{queued:e,runEnded:n}=await l.followUp(o);if(!e){if(n&&t)return void B(o,V??"");R(o)}},[l,o,B,V,t,R]),Z=(0,n.useCallback)(e=>{t&&v(n=>({...n,[t]:e}))},[t]),Q=(0,n.useCallback)(async()=>{if(!t||l.activeRunID)return;let e=await l.refreshSelectedSession();e?.activeLeafMessageId?C({open:!0,instructions:"",busy:!1}):l.setError("This session has no conversation history to compact.")},[l,t]),Y=(0,n.useCallback)(async()=>{if(!t||l.activeRunID)return;let e=S.instructions.trim();C(e=>({...e,busy:!0}));try{let n=await l.refreshSelectedSession();if(!n?.activeLeafMessageId){l.setError("This session has no conversation history to compact."),C({open:!1,instructions:"",busy:!1});return}let r=await (0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(t)}/compactions`,{method:"POST",headers:{"Idempotency-Key":on()},body:JSON.stringify({baseMessageId:n.activeLeafMessageId,instructions:e})}),i=await (0,eb.apiFetch)(`/v1/runs/${encodeURIComponent(r.runId)}`);l.setError(null),C({open:!1,instructions:"",busy:!1}),l.watchRun(i)}catch(e){l.setError(e.message),C(e=>({...e,busy:!1}))}},[l,S.instructions,t]),X=(0,n.useCallback)(()=>{C(e=>e.busy?e:{open:!1,instructions:"",busy:!1})},[]);return{composer:{sessionId:t,activeLeafMessageId:i?.activeLeafMessageId,input:o,setInput:R,pendingImage:d,clearPendingImage:f,uploadImage:e=>void p(e),textAttachments:u,removeTextAttachment:m,attachFiles:e=>void h(e),models:a.models.filter(e=>"active"===e.status),selectedModelId:W,setSelectedModelId:Z,thinkingEffort:k,setThinkingEffort:w,roles:N,selectedRoleId:I,setSelectedRoleId:T,permissionMode:b,displayedPermissionMode:q(),permissionReady:!!V,setPermissionMode:j,compactSession:()=>void Q(),compaction:{open:S.open,instructions:S.instructions,busy:S.busy,setInstructions:e=>C(t=>({...t,instructions:e})),confirm:()=>void Y(),cancel:X},promptPanel:{templates:s.templates,roles:N.map(e=>({id:e.id,handle:e.handle,name:e.name,description:e.description})),flows:P,show:$&&!L,onSelect:e=>{F(!1),R(`/${e} `)},onRoleSelect:e=>{T(e),F(!0),R("")},onFlowSelect:(e,t)=>{F(!1),R(`@graph:${e}${t?`@${t}`:""} `)},onClose:()=>F(!0),expanding:D,expandDiag:_}},actions:{submit:K,steer:J,followUp:G}}}({selectedSession:c,selectedProject:u,sessionRecord:d,promptCatalog:p,settings:h,runtime:{activeRunID:k.activeRunID,activeRunRecord:k.activeRun,setStatus:k.setStatus,setError:k.setError,watchRun:k.watchRun,steer:k.steer,followUp:k.followUp,appendTransient:j.appendTransient,refreshSelectedSession:b}}),T=k.activeRunID,{decideApproval:M}=k,{createBranch:R}=C,E=(0,n.useCallback)(async e=>{T||await R(e)},[T,R]),z=async e=>{T||await C.activateBranch(e)},A=(0,n.useCallback)(e=>void M(e),[M]),P=(0,n.useCallback)(e=>void E(e),[E]),$=(0,n.useCallback)(async()=>{let e=await w.retry();e&&k.watchRun(e)},[w,k]),L=(0,n.useCallback)(()=>{k.setError(null),w.clearError(),C.clearError()},[k,w,C]),F=k.error??w.error??C.error,D={sessionId:c,activeBranchId:x,activeLeafMessageId:y,messages:j.messages,loading:j.loading,loadingOlder:j.loadingOlder,error:j.historyError,hasMore:j.hasMore,loadOlder:j.loadOlder};return{history:D,run:{activeRun:k.activeRunID,activeRunStatus:k.activeRun?.status,status:k.status,usage:k.usage,contextUsage:k.contextUsage,stats:S,compacting:k.compacting,pendingApproval:k.pendingApproval,resolvingApproval:k.resolvingApproval,decideApproval:A,cancel:()=>void k.cancel(),pendingFollowUps:k.pendingFollowUps,recovery:w.recovery,retrying:w.retrying,retryRun:()=>void $(),error:k.error,setError:k.setError,clearError:()=>k.setError(null)},branches:{branches:C.branches,activeBranchId:x,loading:C.loading,changing:C.changing,error:C.error,createBranch:P,activateBranch:e=>void z(e)},composer:N,actions:I,error:F,clearError:L}}({selectedSession:S,sessionRecord:J,selectedProject:o,promptCatalog:G,settings:V,replaceSession:K}),Q=function(e,t){let[r,i]=(0,n.useState)(new Set),s=[...new Set(e)].sort().join("\0"),a=(0,n.useMemo)(()=>s?s.split("\0"):[],[s]);return(0,n.useEffect)(()=>{if(!s)return;let e=new AbortController,t=async()=>{let t=await Promise.all(a.slice(0,50).map(async t=>{try{return await (0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(t)}/active-run`,{signal:e.signal})?t:null}catch{return null}}));e.signal.aborted||i(new Set(t.filter(e=>!!e)))};t();let n=window.setInterval(()=>void t(),15e3);return()=>{e.abort(),window.clearInterval(n)}},[s,a]),(0,n.useMemo)(()=>{let e=new Set(r);return t&&e.add(t),e},[t,r])}(H.groups.flatMap(e=>e.sessions.map(e=>e.id)),Z.run.activeRun?S:null),Y=V.refresh,X=(0,n.useCallback)(e=>{x(e),Y()},[Y,x]),{closeSettings:ee}=function({loading:e,error:t,providers:r,openSettings:i,closeSettings:s}){let a=(0,n.useRef)(!1),l=(0,n.useCallback)(()=>{try{window.localStorage.setItem(lq,"1")}catch{}s()},[s]);return(0,n.useEffect)(()=>{if(a.current||e||t||r.some(e=>e.credentialConfigured))return;let n=!1;try{n="1"===window.localStorage.getItem(lq)}catch{}n||(a.current=!0,i("models"))},[e,t,r,i]),{closeSettings:l}}({loading:V.loading,error:V.error,providers:V.providers,openSettings:X,closeSettings:y}),et=(0,n.useCallback)(e=>{c(e),T("chat"),M(null),B.setView("active"),B.setQuery(""),a&&q()},[T,q,a,M,B,c]),en=(0,n.useCallback)(async e=>{try{let t=await (0,eb.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/sessions`,{method:"POST",body:JSON.stringify({title:`Chat ${new Date().toLocaleTimeString()}`})});Z.run.setError(null),B.replaceSession(t),M(t.id),T("chat"),await B.refresh(),H.refresh(e)}catch(e){Z.run.setError(e.message)}},[T,M,B,H,Z.run]),er=(0,n.useCallback)(async()=>{o&&await en(o)},[en,o]),ei=(0,n.useCallback)(async(e,t)=>{let n=await (0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(e.id)}`,{method:"PATCH",body:JSON.stringify({title:t})});B.replaceSession(n),H.refresh(e.projectId)},[B,H]),es=(0,n.useCallback)(async(e,t)=>{await k(e,t),H.refresh(e)},[k,H]),ea=(0,n.useCallback)(async e=>{await w(e)},[w]),el=(0,n.useCallback)(e=>{ee(),T("chat"),M(e),(0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(e)}`).then(B.replaceSession).catch(()=>{}),a&&q()},[T,q,ee,a,M,B]),eo=(0,n.useCallback)(async e=>{let t=await B.archive(e);t&&(H.refresh(e.projectId),H.refreshArchived(e.projectId)),t&&S===e.id&&M(null)},[M,B,H,S]),ec=(0,n.useCallback)(async e=>{await B.restore(e),H.refresh(e.projectId),H.refreshArchived(e.projectId)},[B,H]),ed=J?.projectId??o,{currentCwd:eu,rightTabs:ep,activeRightTabId:eh,setActiveRightTabId:em,handleOpenFile:ef,handlePreviewFile:eg,closeTab:ex}=function({projectId:e,workspaceFor:t,setRunError:r,onOpenPanel:i,onPreviewFile:s}){let a=e?t(e)??null:null,l=a?.hostPath??null;(0,n.useEffect)(()=>{if(!e||t(e))return;let n=new AbortController;return(0,eb.apiFetch)(`/v1/projects/${encodeURIComponent(e)}/workspace`,{signal:n.signal}).catch(e=>{n.signal.aborted||r(e.message)}),()=>n.abort()},[e,r,t]);let{fileTabs:o,activeTabId:c,setActiveTabId:d,openFile:u,closeTab:p}=function(e){let[t,r]=(0,n.useState)([]),[i,s]=(0,n.useState)("files"),a=(0,n.useCallback)((t,n)=>{if(!e)return;let i=`file:${e}:${t}`;r(r=>r.find(e=>e.id===i)?r:[...r,{id:i,label:n,filePath:t,projectId:e}]),s(i)},[e]),l=(0,n.useCallback)(e=>{"files"!==e&&"tools"!==e&&(r(t=>t.filter(t=>t.id!==e)),s(n=>{if(n!==e)return n;let r=t.filter(t=>t.id!==e);return r.length>0?r[r.length-1].id:"files"}))},[t]);return{fileTabs:t,activeTabId:i,setActiveTabId:s,openFile:a,closeTab:l}}(e),h=(0,n.useCallback)((e,t)=>{u(e,t),i()},[u,i]),m=(0,n.useCallback)((t,n)=>{e&&s({projectId:e,path:t,name:n})},[e,s]),f=[{id:"files",label:"Files",closable:!1,icon:"files"},{id:"graph",label:"Graphs",closable:!1,icon:"graph"},{id:"tools",label:"Status",closable:!1,icon:"tools"},...o];return{currentWorkspace:a,currentCwd:l,fileTabs:o,rightTabs:f,activeRightTabId:c,setActiveRightTabId:d,handleOpenFile:h,handlePreviewFile:m,closeTab:p}}({projectId:ed,workspaceFor:v,setRunError:Z.run.setError,onOpenPanel:()=>D(!0),onPreviewFile:O}),ey=function(e){let{session:t,replaceSession:r}=e,[i,s]=(0,n.useState)(!1),[a,l]=(0,n.useState)(""),o=(0,n.useRef)(null),c=(0,n.useCallback)(e=>e&&(e.title||e.id?.slice(0,12))||"",[]),d=(0,n.useCallback)(()=>{t&&(l(t.title||c(t)),s(!0),setTimeout(()=>o.current?.select(),0))},[c,t]),u=(0,n.useCallback)(async()=>{if(!t)return void s(!1);let e=a.trim();if(s(!1),e!==(t.title??""))try{let n=await (0,eb.apiFetch)(`/v1/sessions/${encodeURIComponent(t.id)}`,{method:"PATCH",body:JSON.stringify({title:e})});r(n)}catch{}},[t,a,r]),p=(0,n.useCallback)(e=>{"Enter"===e.key?(e.preventDefault(),u()):"Escape"===e.key&&s(!1)},[u]);return{title:t?c(t):"No session",editing:i,draft:a,setDraft:l,startEdit:d,save:u,keyDown:p,inputRef:o}}({session:J,replaceSession:B.replaceSession}),ev=eu?eu.replace(/\/+$/,"").split(/[\\/]/).filter(Boolean).pop()||eu:"",ej=(0,t.jsx)($,{projects:l,groups:H.groups,selectedProject:o,selectedSession:S,settingsOpen:f,query:B.query,setQuery:B.setQuery,mutatingId:B.mutatingId,announcement:B.announcement,pinnedProjectIds:j,togglePinProject:b,renameProject:es,deleteProject:ea,collapsed:H.collapsed,toggleCollapsed:H.toggleCollapsed,archived:H.archived,openArchived:H.openArchived,createProject:u,createSession:er,createSessionIn:en,renameSession:ei,switchProject:et,switchSession:el,archiveSession:e=>void eo(e),restoreSession:e=>void ec(e),openSettings:X,closeNavigation:q,runningSessionIds:Q,onToggleSidebar:()=>P(e=>!e),projectSelector:z,view:N,setView:T}),ek=Z.error??B.error;return(0,t.jsx)(sy,{children:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:`app-shell${!A&&!a?" sidebar-collapsed":""}`,"data-testid":"ennote-shell",children:[!A&&!a&&(0,t.jsx)(F,{onClick:()=>P(!0)}),(0,t.jsx)("div",{className:"sidebar-overlay-backdrop",onClick:q,style:{opacity:+!!A,pointerEvents:A?"auto":"none"}}),(0,t.jsx)("div",{className:`sidebar-container${A?" sidebar-open":" sidebar-closed"}`,role:a&&A?"dialog":void 0,"aria-modal":a&&A?"true":void 0,"aria-label":a&&A?"Navigation":void 0,id:"workspace-navigation",style:{width:a?void 0:A?R.width:56,minWidth:a?void 0:A?R.width:56,transition:A||R.isResizing?"none":void 0},children:ej}),A&&!a&&(0,t.jsx)(az,{side:"right",ariaLabel:"Resize sidebar",value:R.width,min:264,max:420,onResizeStart:R.beginResize,onResize:R.resizeBy,onResizeEnd:R.endResize}),(0,t.jsx)("div",{className:"workspace-content",inert:a&&A,style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},children:"chat"===N?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(sY,{sidebarOpen:A,onToggleSidebar:()=>P(e=>!e),navigationTriggerRef:W,session:J,title:ey,projectName:ev,projectPath:eu,branch:{branches:Z.branches.branches,activeBranchId:Z.branches.activeBranchId,loading:Z.branches.loading,changing:Z.branches.changing,disabled:!!Z.run.activeRun,onActivate:Z.branches.activateBranch},rightPanelOpen:L,onToggleRightPanel:()=>D(e=>!e),attention:{projectId:o??ed??void 0,onNavigate:e=>{e.sessionId&&e.sessionId!==S&&el(e.sessionId)}}}),(0,t.jsx)(sP,{history:Z.history,run:Z.run,branches:Z.branches,composer:Z.composer,actions:Z.actions,error:ek,clearError:()=>{Z.clearError(),B.setError(null)},projects:l,selectedProject:o,hasModel:V.models.length>0,pinnedProjectIds:j,togglePinProject:b,onSwitchProject:et,onNewProject:u,onNewSession:()=>void er(),onOpenSettings:X})]}):(0,t.jsx)(ou,{view:N,models:V.models,providers:V.providers,onBackToChat:()=>T("chat"),onOpenMobileNav:()=>P(!0),menuTriggerRef:U})}),"chat"===N&&L&&(0,t.jsx)(az,{side:"left",ariaLabel:"Resize right panel",value:E.width,min:280,max:1e3,onResizeStart:E.beginResize,onResize:E.resizeBy,onResizeEnd:E.endResize}),"chat"===N&&(0,t.jsx)(aI,{open:L,onClose:()=>D(!1),resize:E,tabs:ep,activeTabId:eh,onSelectTab:em,onCloseTab:ex,projectId:ed??null,displayPath:eu,onOpenFile:ef,onPreviewFile:eg,selectedSession:S,sessionTitle:J?.title||S||"",activeRun:Z.run.activeRun,status:Z.run.status,permissionMode:Z.composer.displayedPermissionMode})]}),_&&(0,t.jsx)(aT,{projectId:_.projectId,filePath:_.path,fileName:_.name,onClose:()=>O(null)}),(0,t.jsx)(lF,{open:f,onClose:ee,initialTab:g,providers:V.providers,models:V.models,policies:V.policies,session:J,refresh:V.refresh,error:V.error,setError:V.setError,onSessionUpdated:B.replaceSession,projectId:o}),d&&(0,t.jsx)(aL,{busy:m,onCreate:p,onClose:h})]})})}],59665)}]);
|