@pi-chamber/web 1.0.4-rc.1 → 1.0.4-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{DiagramView-DfZMQkXY.js → DiagramView-GKGxPczP.js} +1 -1
- package/dist/assets/{DiffView-BjWUdbL5.js → DiffView-Cay8VAqL.js} +1 -1
- package/dist/assets/{FileSaveConflictDialog-u5L4k_5k.js → FileSaveConflictDialog-BRM9TJo0.js} +1 -1
- package/dist/assets/{FilesView-qP1ypN9J.js → FilesView-CEeQzjc6.js} +1 -1
- package/dist/assets/{GitHubDetailScaffold-zCKCy5OJ.js → GitHubDetailScaffold-q4YP8iyJ.js} +1 -1
- package/dist/assets/{GitHubLinkPicker-CwxKY3lN.js → GitHubLinkPicker-B9xgIW8y.js} +1 -1
- package/dist/assets/{GitHubListPrimitives-Ck3zllel.js → GitHubListPrimitives-XkALat1v.js} +1 -1
- package/dist/assets/{GitView-y2k2i4gR.js → GitView-DV3d0oSJ.js} +3 -3
- package/dist/assets/{IssuesSurface-HWgR87N3.js → IssuesSurface-OTyt9f3A.js} +3 -3
- package/dist/assets/{JsonTreeView-DSuC4naV.js → JsonTreeView-X2Auiy_q.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-CT5ln9em.js → MarkdownRendererImpl-1HameF6j.js} +12 -12
- package/dist/assets/{PatchDiff-DArTeWeK.js → PatchDiff-GMQAv4en.js} +1 -1
- package/dist/assets/{PierreDiffViewer-DQKujzLb.js → PierreDiffViewer-0X__nypk.js} +2 -2
- package/dist/assets/PullRequestsSurface-Dec20SIg.js +2 -0
- package/dist/assets/{SessionSwitcherContent-DEGJyZBl.js → SessionSwitcherContent-DEw4nz7K.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-cC9wVBH7.js → SessionSwitcherDropdown-DmLhbRzE.js} +2 -2
- package/dist/assets/SessionUnreadDot-CJFawQpo.js +1 -0
- package/dist/assets/SettingsView-CwSspvq-.js +6 -0
- package/dist/assets/{SettingsWindow-CZM1dmVb.js → SettingsWindow-DkPv9MaU.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DClOSbJc.js → ToolOutputDialog-DDwbOpTO.js} +3 -3
- package/dist/assets/{ToolPartDiffPreview-BaFiGUDE.js → ToolPartDiffPreview-DZRP7p-Q.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-D6KbvKc6.js → VirtualizedFileDiff-CUWx7JVZ.js} +1 -1
- package/dist/assets/{collapsible-DhV9d4dT.js → collapsible-Ce85nuXX.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-CeMpF2xC.js → computeVirtualFileMetrics-3PpRLd5B.js} +1 -1
- package/dist/assets/{contextFileOpenGuard-Ck5u_kAP.js → contextFileOpenGuard-PoBklHMz.js} +1 -1
- package/dist/assets/{gitStatusPredicates-DEBSqUNE.js → gitStatusPredicates-BvzxqidP.js} +1 -1
- package/dist/assets/{githubLink-DT7i2NlH.js → githubLink-iQ51wqRa.js} +1 -1
- package/dist/assets/{index-eDf4LKLY.js → index-CkMnC_GK.js} +1 -1
- package/dist/assets/{index-6IO1AcJI.js → index-Dd2OcIUY.js} +9 -9
- package/dist/assets/index-DvN8zlLT.css +1 -0
- package/dist/assets/{main-BczEScAA.js → main-FasHq7Ck.js} +2 -2
- package/dist/assets/{main-CHLNMYeJ.js → main-PSCt716b.js} +8 -8
- package/dist/assets/{markdownCore-C4Gk5Zht.js → markdownCore-BH56o6Wu.js} +1 -1
- package/dist/assets/{miniChat-Do3hE87Z.js → miniChat-BzfobBDq.js} +2 -2
- package/dist/assets/{mobile-CTnihwfa.js → mobile-DAzZE2EL.js} +2 -2
- package/dist/assets/{pi-session-focus-preference-LDVCJ_YR.js → pi-session-focus-preference-D2-1HWmY.js} +3 -3
- package/dist/assets/{renderDiffWithHighlighter-CDsgOnkH.js → renderDiffWithHighlighter-l8hZWWBO.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DSa3gYqR.js → renderElectronMiniChatApp-DGYSIihR.js} +2 -2
- package/dist/assets/{renderFileWithHighlighter-TpKRyfCY.js → renderFileWithHighlighter-BvDoP7ob.js} +1 -1
- package/dist/assets/renderMobileApp-CwgWG0lU.js +11 -0
- package/dist/assets/runtimeEndpointReset-CmI6dBKM.js +62 -0
- package/dist/assets/{runtimeSurface-DW_Ia4q3.js → runtimeSurface-B1GRkkKC.js} +1 -1
- package/dist/assets/{useAppFontEffects-CG3_yteE.js → useAppFontEffects--lKKtKVo.js} +62 -62
- package/dist/assets/{useFilesViewSearch-C_LzYIgD.js → useFilesViewSearch-D1jsGQrN.js} +3 -3
- package/dist/assets/{useGitHubRemoteSearch-DsxWOzKZ.js → useGitHubRemoteSearch-zNgy2bSt.js} +1 -1
- package/dist/assets/{useSwitcherItems-BmoCnS9W.js → useSwitcherItems-OCRYcHeu.js} +1 -1
- package/dist/assets/{web-components-CH3-XV-n.js → web-components-v9fuidaX.js} +1 -1
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +2 -2
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +21 -8
- package/server/lib/pi/session-daemon/builtin-extensions.js +37 -0
- package/server/lib/pi/session-daemon/daemon-process.js +6 -0
- package/server/lib/pi/session-daemon/extension-theme.js +75 -0
- package/server/lib/pi/session-daemon/extension-theme.test.js +47 -0
- package/server/lib/pi/session-daemon/prompt-operations.test.js +3 -3
- package/server/lib/pi/session-daemon/prompt-preflight.test.js +12 -14
- package/server/lib/pi/session-daemon/sdk-upgrade.test.js +118 -2
- package/server/lib/pi/session-daemon/send-operation-dedup.test.js +1 -1
- package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +1 -1
- package/server/lib/pi/session-daemon/session-daemon-mcp.e2e.test.js +638 -0
- package/server/lib/pi/session-daemon/session-daemon-turn.e2e.test.js +437 -0
- package/server/lib/pi/session-daemon/session-daemon.js +61 -42
- package/server/lib/pi/session-daemon/session-daemon.test.js +53 -5
- package/server/lib/pi/session-daemon/session-idle-residency.test.js +1 -1
- package/server/lib/pi/session-daemon/session-replay.test.js +1 -1
- package/server/lib/pi/session-persistence-gap.test.js +2 -3
- package/server/lib/pi/ui-settings-store.js +1 -0
- package/server/lib/pi/ui-settings-store.test.js +27 -0
- package/dist/assets/PullRequestsSurface-Cfb1wSvC.js +0 -2
- package/dist/assets/SessionUnreadDot-CELKNVIM.js +0 -1
- package/dist/assets/SettingsView-CZvRRgJe.js +0 -6
- package/dist/assets/index-BAmzAlNx.css +0 -1
- package/dist/assets/renderMobileApp-CPE-3uMl.js +0 -11
- package/dist/assets/runtimeEndpointReset-CzJfovWI.js +0 -62
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{j as _}from"./vendor-boot-DyL2td56.js";import{R as y}from"./vendor-react-DASdDPIk.js";import{m as Ke}from"./vendor-morphdom-B7dS_VPB.js";import{r as Ue}from"./vendor-beautiful-mermaid-DApbjBp2.js";import{R as Ze,al as Xe,t as ve,m as Ge,a7 as ee,bL as Ye,o as Z,Z as te}from"./index-6IO1AcJI.js";import{c6 as Ae,c7 as Je,c8 as Qe,ae as W,br as et,bs as tt,c9 as rt,ca as nt,o as ot,cb as re,cc as at,cd as it,ce as st,p as ke,n as Ee,cf as Ce,cg as ct,aX as lt}from"./useAppFontEffects-CG3_yteE.js";import{r as dt,s as ut,i as mt,a as pt,b as ft}from"./markdownCore-C4Gk5Zht.js";import{r as ht}from"./registerCustomTheme-DmolaWWZ.js";import{i as bt}from"./runtimeSurface-DW_Ia4q3.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-elkjs-D27273Ms.js";import"./vendor-entities-C3BA0AJP.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-marked-CX41MkDF.js";import"./vendor-dompurify-r8glNMJW.js";import"./vendor-remend-BWYYytN3.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";const Se="pichamber-md",gt={name:Se,colors:{"editor.background":"transparent","editor.foreground":"var(--md-syntax-foreground)"},tokenColors:[{scope:["comment","punctuation.definition.comment","string.comment"],settings:{foreground:"var(--md-syntax-comment)",fontStyle:"italic"}},{scope:["string","punctuation.definition.string","string.template"],settings:{foreground:"var(--md-syntax-string)"}},{scope:["constant.numeric","constant.language","constant.character","constant"],settings:{foreground:"var(--md-syntax-number)"}},{scope:["keyword","storage","storage.type","storage.modifier","keyword.control"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["keyword.operator","punctuation.separator","punctuation.terminator"],settings:{foreground:"var(--md-syntax-operator)"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"var(--md-syntax-function)"}},{scope:["entity.name.type","entity.name.class","support.type","support.class","entity.other.inherited-class"],settings:{foreground:"var(--md-syntax-type)"}},{scope:["variable","variable.other","variable.parameter","meta.definition.variable"],settings:{foreground:"var(--md-syntax-variable)"}},{scope:["variable.other.property","meta.property-name","support.type.property-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["entity.name.tag","punctuation.definition.tag"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["entity.other.attribute-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["markup.bold","punctuation.definition.bold"],settings:{fontStyle:"bold"}},{scope:["markup.italic","punctuation.definition.italic"],settings:{fontStyle:"italic"}},{scope:["markup.heading","markup.heading entity.name"],settings:{foreground:"var(--md-syntax-keyword)",fontStyle:"bold"}},{scope:["markup.inserted","punctuation.definition.inserted"],settings:{foreground:"var(--md-syntax-inserted)"}},{scope:["markup.deleted","punctuation.definition.deleted"],settings:{foreground:"var(--md-syntax-deleted)"}},{scope:["invalid","invalid.illegal"],settings:{foreground:"var(--md-syntax-deleted)"}}]};let ne=!1;const wt=()=>{ne||(ne=!0,ht(Se,()=>Promise.resolve(gt)))},k=e=>Number.isFinite(e)&&e>0,oe=e=>{if(typeof e=="number")return k(e)?e:null;if(typeof e!="string")return null;const t=e.trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!t)return null;const n=Number(t[1]);return k(n)?n:null},B=(e,t,n)=>Math.min(n,Math.max(t,e)),yt=6,ae=1.25,vt=1.0015,At=.5,kt=12,ie=3,Et=400,I='[data-markdown="mermaid-block"]',L=e=>e.querySelector(I)!==null,Ct=e=>[e.x,e.y,e.width,e.height].map(t=>{const n=Number(t.toFixed(yt));return Object.is(n,-0)?"0":String(n)}).join(" "),St=e=>{const t=e.viewBox?.trim().split(/[\s,]+/).map(s=>Number.parseFloat(s));if(t?.length===4){const[s,o,a,i]=t;if(Number.isFinite(s)&&Number.isFinite(o)&&k(a)&&k(i))return{x:s,y:o,width:a,height:i}}const n=oe(e.width),r=oe(e.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},Lt=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)},Mt=e=>{const t=e.renderMode||"unknown",n=e.svgMarkup??"";if(!n){const r=[e.viewBox??"",e.width??"",e.height??""];return r.some(s=>s!=="")?`${t}:bounds:${r.join(":")}`:`${t}:no-svg`}return[t,Lt(n)].join(":")},Le=(e,t)=>{if(!k(t.width)||!k(t.height))return e;const n=e.width/e.height,r=t.width/t.height;if(n>r){const o=e.width/r;return{x:e.x,y:e.y-(o-e.height)/2,width:e.width,height:o}}const s=e.height*r;return{x:e.x-(s-e.width)/2,y:e.y,width:s,height:e.height}},Nt=({currentBox:e,viewport:t,delta:n})=>!k(t.width)||!k(t.height)||!k(e.width)||!k(e.height)?e:{x:e.x-n.x/t.width*e.width,y:e.y-n.y/t.height*e.height,width:e.width,height:e.height},xt=(e,t)=>{const n=t.x-e.x,r=t.y-e.y;return n*n+r*r>ie*ie},Tt=({currentBox:e,contentBox:t,viewport:n,pointer:r,zoomFactor:s,minScale:o,maxScale:a})=>{if(!k(n.width)||!k(n.height)||!k(s)||!k(e.width)||!k(e.height)||!k(t.width)||!k(t.height)||!k(o)||!k(a))return e;const i=Math.min(o,a),c=Math.max(o,a),d=Le(t,n),l=d.width/e.width,m=B(l*s,i,c),p=d.width/m,f=p/(e.width/e.height),h=B(r.x/n.width,0,1),v=B(r.y/n.height,0,1),A=e.x+h*e.width,w=e.y+v*e.height;return{x:A-h*p,y:w-v*f,width:p,height:f}},X=new WeakMap,Pt=e=>e instanceof HTMLElement?X.get(e)??null:null,Rt=e=>e.querySelector('[data-markdown="mermaid-viewport"]')??e.querySelector('[data-markdown="mermaid"]'),se=e=>{const t=e.querySelector('[data-markdown="mermaid"] svg'),n=e.querySelector('[data-markdown="mermaid"]');return Mt({renderMode:e.getAttribute("data-mermaid-render"),svgMarkup:n?.getAttribute("data-md-original-svg")??t?.outerHTML??null,viewBox:t?.getAttribute("viewBox"),width:t?.getAttribute("width"),height:t?.getAttribute("height")})},R=e=>{const t=e.getBoundingClientRect();return{width:t.width,height:t.height}},_t=(e,t)=>{const n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}},It=e=>e instanceof Element&&!!e.closest('button, a, [role="button"]'),Ft=e=>{const t=Rt(e),n=e.querySelector('[data-markdown="mermaid"] svg');if(!t||!n)return null;const r=St({viewBox:n.getAttribute("viewBox"),width:n.getAttribute("width"),height:n.getAttribute("height")});if(!r)return null;let s=r,o=null,a=null,i=null,c=null;const d=u=>{s=u,n.setAttribute("viewBox",Ct(u)),n.removeAttribute("width"),n.removeAttribute("height")},l=()=>{d(Le(r,R(t)))},m=(u,E)=>{d(Tt({currentBox:s,contentBox:r,viewport:R(t),pointer:u,zoomFactor:E,minScale:At,maxScale:kt}))},p=()=>{const u=R(t);m({x:u.width/2,y:u.height/2},ae)},f=()=>{const u=R(t);m({x:u.width/2,y:u.height/2},1/ae)},h=u=>{!u.ctrlKey&&!u.metaKey||(u.preventDefault(),u.stopPropagation(),m(_t(u,t),Math.pow(vt,-u.deltaY)))},v=u=>{u.button!==0||It(u.target)||(o=u.pointerId,a={x:u.clientX,y:u.clientY},i=a,c!==null&&(window.clearTimeout(c),c=null),e.removeAttribute("data-mermaid-suppress-click"),t.setPointerCapture?.(u.pointerId),e.setAttribute("data-mermaid-panning","true"),u.preventDefault())},A=u=>{if(o!==u.pointerId||!i)return;const E={x:u.clientX,y:u.clientY};d(Nt({currentBox:s,viewport:R(t),delta:{x:E.x-i.x,y:E.y-i.y}})),i=E,a&&xt(a,E)&&e.setAttribute("data-mermaid-suppress-click","true"),u.preventDefault()},w=u=>{o===u.pointerId&&(t.releasePointerCapture?.(u.pointerId),o=null,a=null,i=null,e.removeAttribute("data-mermaid-panning"),e.hasAttribute("data-mermaid-suppress-click")&&(c=window.setTimeout(()=>{e.removeAttribute("data-mermaid-suppress-click"),c=null},Et)))},b=()=>{l()};t.addEventListener("wheel",h,{passive:!1}),t.addEventListener("pointerdown",v),t.addEventListener("pointermove",A),t.addEventListener("pointerup",w),t.addEventListener("pointercancel",w),window.addEventListener("resize",b);const g=typeof ResizeObserver>"u"?null:new ResizeObserver(b);return g?.observe(t),l(),{zoomIn:p,zoomOut:f,fit:l,cleanup:()=>{t.removeEventListener("wheel",h),t.removeEventListener("pointerdown",v),t.removeEventListener("pointermove",A),t.removeEventListener("pointerup",w),t.removeEventListener("pointercancel",w),window.removeEventListener("resize",b),g?.disconnect(),c!==null&&window.clearTimeout(c),e.removeAttribute("data-mermaid-panning"),e.removeAttribute("data-mermaid-suppress-click"),X.delete(e)}}},Ot=e=>{const t=new Map,n=new Map,r=()=>{for(const[o,a]of Array.from(t.entries())){const i=se(o);(!e.contains(o)||i!==n.get(o))&&(a.cleanup(),t.delete(o),n.delete(o))}for(const o of Array.from(e.querySelectorAll(I))){if(t.has(o)||o.querySelector('[data-markdown="mermaid"] svg')===null)continue;const a=Ft(o);a&&(t.set(o,a),n.set(o,se(o)),X.set(o,a))}},s=()=>{for(const o of t.values())o.cleanup();t.clear(),n.clear()};return r(),{refresh:r,cleanup:s}},x=e=>`<svg class="remixicon size-3.5" viewBox="0 0 24 24" aria-hidden="true"><use href="#oc-${e}"></use></svg>`,q={copy:x("file-copy"),check:x("check"),download:x("download"),zoomIn:x("add"),zoomOut:x("subtract"),fit:x("refresh")},Me="p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--interactive-focus-ring)]",$=(e,t)=>{e.innerHTML=t},S=(e,t,n)=>{const r=document.createElement("button");return r.type="button",r.className=Me,r.setAttribute("data-md-action",n),r.setAttribute("title",t),r.setAttribute("aria-label",t),$(r,q[e]),r},Ne=e=>{const t=e.querySelector("[data-md-code-body]"),n=e.querySelector("pre"),r=e.querySelector("pre code"),s=e.querySelectorAll("[data-md-code-line-content]");e.setAttribute("data-code-wrap","true"),t?.classList.remove("overflow-x-auto"),t?.classList.add("overflow-x-hidden"),n?.classList.add("whitespace-pre-wrap","break-words"),r?.classList.add("whitespace-pre-wrap","break-words"),n&&(n.style.whiteSpace="pre-wrap",n.style.overflowWrap="anywhere"),r&&(r.style.whiteSpace="pre-wrap",r.style.overflowWrap="anywhere");for(const o of Array.from(s))o.style.whiteSpace="pre-wrap",o.style.overflowWrap="anywhere"},xe=e=>{const t=e.querySelector(":scope > code");if(!t||t.hasAttribute("data-md-code-lines"))return;const n=t.textContent??"",r=n.endsWith(`
|
|
2
|
-
`),s=r
|
|
3
|
-
`):
|
|
4
|
-
`),o=s.length>0?s:[""],a=Array.from(t.children).filter(d=>d.classList.contains("line"));
|
|
5
|
-
`,c.appendChild(h)}}),t.replaceChildren(c),t.setAttribute("data-md-code-lines",""),t.toggleAttribute("data-md-code-trailing-newline",
|
|
6
|
-
`);return e.hasAttribute("data-md-code-trailing-newline")?`${
|
|
7
|
-
`:
|
|
8
|
-
`),Ht=({headers:e,rows:t})=>[e,...t].map(
|
|
9
|
-
`),ue=({headers:e,rows:t})=>{const
|
|
10
|
-
`);return`${
|
|
11
|
-
${
|
|
12
|
-
${s}`},me=(e,t)=>{const n=document.createElement("div");n.className=`absolute top-full right-0 mt-1 hidden ${et}`,n.style.backgroundColor="var(--surface-elevated)",n.style.color="var(--surface-elevated-foreground)",n.setAttribute("data-md-menu",e);for(const r of t){const s=document.createElement("button");s.type="button",s.className=`w-full text-left ${tt}`,s.setAttribute("data-md-action",`${e}-${r.key}`),s.textContent=r.label,n.appendChild(s)}return n},Wt=(e,t)=>{const n=e.querySelectorAll("table");for(const r of Array.from(n)){if(r.closest('[data-markdown="table-wrapper"]'))continue;const o=document.createElement("div");o.className="group my-4 flex flex-col space-y-2",o.setAttribute("data-markdown","table-wrapper");const a=document.createElement("div");a.className="flex items-center justify-end gap-1";const i=document.createElement("div");i.className="relative",i.appendChild(S("copy",t.copyTable,"table-copy-toggle")),i.appendChild(me("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const c=document.createElement("div");c.className="relative",c.appendChild(S("download",t.downloadTable,"table-download-toggle")),c.appendChild(me("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),a.appendChild(i),a.appendChild(c);const d=document.createElement("div");d.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const l=r.parentElement;if(!l)continue;l.replaceChild(o,r),r.setAttribute("data-markdown","table"),r.classList.add("w-full","border-collapse","text-sm");for(const p of Array.from(r.querySelectorAll("tr")))p.classList.add("border-b","border-border/60");const m=r.querySelector("tbody tr:last-child");m?.classList.remove("border-b"),m?.classList.add("border-0");for(const p of Array.from(r.querySelectorAll("th")))p.classList.add("border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const p of Array.from(r.querySelectorAll("td")))p.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground/90","last:border-r-0");d.appendChild(r),o.appendChild(a),o.appendChild(d)}},Bt=(e,t)=>{const n=e.querySelectorAll("pre > code.language-mermaid");for(const r of Array.from(n)){const s=r.parentElement;if(!s)continue;const o=(r.textContent??"").replace(/\s+$/,""),a=t.renderMermaid(o),i=document.createElement("div");i.setAttribute("data-markdown","mermaid-block"),i.setAttribute("data-md-source",o),i.className="group relative";const c=document.createElement("div");c.setAttribute("data-markdown","mermaid-scroll");const d=document.createElement("div");if(d.setAttribute("data-markdown","mermaid-toolbar"),d.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",a.svg){i.setAttribute("data-mermaid-render","svg");const m=document.createElement("div");m.setAttribute("data-markdown","mermaid-viewport");const p=document.createElement("div");if(p.setAttribute("data-markdown","mermaid"),p.setAttribute("data-md-original-svg",a.svg),p.innerHTML=a.svg,m.appendChild(p),c.appendChild(m),t.mermaidControls.showPanZoomControls&&(d.appendChild(S("zoomIn",t.labels.zoomInDiagram,"mermaid-zoom-in")),d.appendChild(S("zoomOut",t.labels.zoomOutDiagram,"mermaid-zoom-out")),d.appendChild(S("fit",t.labels.resetDiagramView,"mermaid-fit"))),t.mermaidControls.copy){const f=S("copy",t.labels.copyDiagram,"mermaid-copy");f.setAttribute("data-md-source",o),d.appendChild(f)}if(t.mermaidControls.download){const f=S("download",t.labels.downloadDiagram,"mermaid-download");f.setAttribute("data-md-svg","1"),d.appendChild(f)}}else{i.setAttribute("data-mermaid-render","svg");const m=document.createElement("pre");if(m.setAttribute("data-markdown","mermaid-ascii"),m.textContent=o,c.appendChild(m),t.mermaidControls.copy){const p=S("copy",t.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",o),d.appendChild(p)}}i.appendChild(c),i.appendChild(d);const l=s.parentElement;l&&l.replaceChild(i,s)}},Vt=(e,t)=>{const n=e.querySelectorAll("a[href]");for(const r of Array.from(n)){if(r.getAttribute("data-md-link-decorated")==="true"||r.getAttribute("data-pichamber-file-link")==="true")continue;const s=r.getAttribute("href")??"";if(!Ae(s))continue;r.setAttribute("data-md-link-decorated","true");const o=Je(s);if(o){const a=document.createElement("span");a.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const i=document.createElement("img");i.src=o,i.alt="",i.setAttribute("aria-hidden","true"),i.loading="lazy",i.decoding="async",i.className="size-3.5 rounded-sm",i.addEventListener("error",()=>a.remove(),{once:!0}),a.appendChild(i),r.parentNode?.insertBefore(a,r)}if(t.onPreviewLoopback&&Qe(s)){const a=document.createElement("button");a.type="button",a.className=`ml-1 align-middle ${Me}`,a.setAttribute("data-md-action","preview-loopback"),a.setAttribute("data-md-url",s),a.setAttribute("title",t.labels.previewTitle),a.setAttribute("aria-label",t.labels.previewLabel),$(a,q.download),r.parentNode?.insertBefore(a,r.nextSibling)}}},pe=(e,t)=>{qt(e),Bt(e,t),$t(e,t),Wt(e,t.labels),Vt(e,t)},fe=(e,t,n)=>{const r=new Blob([t],{type:n}),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s)},F=e=>{for(const t of Array.from(e.querySelectorAll("[data-md-menu]")))t.classList.add("hidden")},jt=(e,t)=>{const n=r=>{const s=r.target;if(!(s instanceof Element))return;const o=s.closest("[data-md-action]");if(!o){F(e);return}const a=o.getAttribute("data-md-action")??"";if(a==="copy-code"){const i=o.closest('[data-component="markdown-code"]')?.querySelector("code"),c=i?Te(i):"";c&&W(c).then(()=>ce(o,t.labels.copied,"copy",t.labels.copy));return}if(a==="table-copy-toggle"||a==="table-download-toggle"){r.preventDefault();const i=o.parentElement?.querySelector("[data-md-menu]")??null,c=i?.classList.contains("hidden")??!1;F(e),i&&c&&i.classList.remove("hidden");return}if(a.startsWith("table-copy-")){const i=a.replace("table-copy-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const d=le(c),l=i==="csv"?de(d):i==="tsv"?Ht(d):ue(d);W(l)}F(e);return}if(a.startsWith("table-download-")){const i=a.replace("table-download-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const d=le(c),l=i==="csv"?de(d):ue(d);fe(i==="csv"?"table.csv":"table.md",l,i==="csv"?"text/csv":"text/markdown")}F(e);return}if(a==="mermaid-copy"){const i=o.getAttribute("data-md-source")??"";i&&W(i).then(()=>ce(o,t.labels.copied,"copy",t.labels.copyDiagram));return}if(a==="mermaid-zoom-in"||a==="mermaid-zoom-out"||a==="mermaid-fit"){r.preventDefault();const i=o.closest('[data-markdown="mermaid-block"]'),c=Pt(i);a==="mermaid-zoom-in"?c?.zoomIn():a==="mermaid-zoom-out"?c?.zoomOut():c?.fit();return}if(a==="mermaid-download"){const i=o.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),c=i?.getAttribute("data-md-original-svg")??i?.innerHTML??"";c&&fe("diagram.svg",c,"image/svg+xml;charset=utf-8");return}if(a==="preview-loopback"){r.preventDefault();const i=o.getAttribute("data-md-url")??"";i&&t.onPreviewLoopback?.(i);return}};return e.addEventListener("click",n),()=>e.removeEventListener("click",n)},he=(e,t,n)=>{let r=0;for(const o of e){const a=r+o.data.length;if(t<a||t===a&&n==="left")return{node:o,offset:Math.max(0,t-r)};r=a}const s=e.at(-1);return s?{node:s,offset:s.data.length}:null},Kt=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),be=Array.from(Kt).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Ut=e=>nt(e),Zt=e=>rt(e),z=e=>{let t=(e||"").trim();return t?((t.startsWith("`")&&t.endsWith("`")||t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1).trim()),t=t.replace(/[.,;!?]+$/g,""),t.endsWith(")")&&!t.includes("(")&&(t=t.slice(0,-1)),t.endsWith("]")&&!t.includes("[")&&(t=t.slice(0,-1)),t):""},O=e=>{let t=z(e);if(!t)return"";const n=t.indexOf(";");n>=0&&(t=t.slice(0,n)),t=t.replace(/#.*$/,"");const r=t.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);r&&(t=r[1]??t);const s=be.length>0?t.match(new RegExp(`^(.*(?:/|^)(${be})):.*$`,"i")):null;return s&&(t=s[1]??t),z(t)},Pe=e=>{const t=z(e);if(!t)return null;const n=t.indexOf(";"),r=n>=0?z(t.slice(0,n)):t;if(!r)return null;const s=r.match(/^(.*?):(\d+)-(\d+)$/);if(s){const c=O(s[1]??""),d=Number.parseInt(s[2]??"",10),l=Number.parseInt(s[3]??"",10);return!c||!Number.isFinite(d)||!Number.isFinite(l)||l<d?null:{path:c,line:d,endLine:l}}const o=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(o){const c=O(o[1]??""),d=Number.parseInt(o[2]??"",10),l=o[3]?Number.parseInt(o[3],10):void 0;return!c||!Number.isFinite(d)?null:{path:c,line:d,column:Number.isFinite(l??Number.NaN)?l:void 0}}const a=r.match(/^(.*?):(\d+)(?::(\d+))?$/);if(a){const c=O(a[1]??""),d=Number.parseInt(a[2]??"",10),l=a[3]?Number.parseInt(a[3],10):void 0;return!c||!Number.isFinite(d)?null:{path:c,line:d,column:Number.isFinite(l??Number.NaN)?l:void 0}}const i=O(r);return i?{path:i}:null},V=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,Re=({containerRef:e,enabled:t})=>{y.useEffect(()=>{if(t===!1)return;const n=e.current;if(!n)return;const r=s=>{if(s.defaultPrevented||s.button!==0||s.metaKey||s.ctrlKey||s.altKey||s.shiftKey)return;const o=s.target;if(!(o instanceof Element))return;const a=o.closest("a[href]");if(!(a instanceof HTMLAnchorElement)||a.getAttribute("data-pichamber-file-link")==="true")return;const i=a.getAttribute("href")??"";Ae(i)&&(s.preventDefault(),s.stopPropagation(),ot(i))};return n.addEventListener("click",r),()=>{n.removeEventListener("click",r)}},[e,t])},ge='[data-pichamber-file-link="true"]',_e="data-pichamber-block-path-token",Ie=`[${_e}]`,T="data-pichamber-block-paths-scanned",Xt=2e5,Gt=4,Yt=1e3,Jt=80,we=160,M=new Map;let D=0;const ye=[],Qt=()=>Yt,er=()=>Jt,tr=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),G=e=>Ut(e),rr=e=>Zt(e),nr=(e,t)=>st(e,t),or=e=>{const t=e.split("/").filter(Boolean).pop()??"";return!t||t.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(t)},Fe=e=>{if(!e||e.startsWith("--")||e.includes("://")||/[<>]/.test(e)||/\s{2,}/.test(e))return!1;const t=G(e),n=t.split("/").filter(Boolean).pop()??t;if(!n||n==="."||n==="..")return!1;const r=n.toLowerCase();return tr.has(r)||r.startsWith(".")&&r.length>1?!0:or(t)},Oe=e=>{const t=Pe(e);return t?Fe(t.path):!1},ar=e=>{const t=e.querySelectorAll(Ie);for(const r of Array.from(t))r.replaceWith(e.ownerDocument.createTextNode(r.textContent??""));const n=e.querySelectorAll(`code[${T}]`);for(const r of Array.from(n))r.removeAttribute(T),r.normalize()},j=e=>{if(e.tagName.toLowerCase()==="a"){const t=e.getAttribute("href")?.trim();if(t&&Oe(t))return t}return(e.textContent||"").trim()},ir=e=>{const t=e.querySelectorAll("pre code");if(t.length===0)return;const n=e.ownerDocument;if(n)for(const r of Array.from(t)){if(r.getAttribute(T)==="true")continue;if((r.textContent??"").length>Xt){r.setAttribute(T,"true");continue}const s=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=[];let a=s.nextNode();for(;a;){const l=a;l.parentElement?.closest("[data-md-code-line-number]")||o.push(l),a=s.nextNode()}const i=Te(r);if(!i.includes(".")){r.setAttribute(T,"true");continue}V.lastIndex=0;const c=[];let d=V.exec(i);for(;d;){const l=d[0];l&&Oe(l)&&c.push({start:d.index,end:d.index+l.length,raw:l}),d=V.exec(i)}for(const{start:l,end:m,raw:p}of c.reverse()){const f=he(o,l,"right"),h=he(o,m,"left");if(!f||!h)continue;const v=n.createRange();v.setStart(f.node,f.offset),v.setEnd(h.node,h.offset);const A=n.createElement("span");A.setAttribute(_e,"true"),A.textContent=p,v.deleteContents(),v.insertNode(A)}r.setAttribute(T,"true")}},K=(e,t)=>{const n=Pe(e);if(!n||!Fe(n.path))return null;const r=rr(n.path)?G(n.path):nr(t,n.path);return r?{...n,resolvedPath:r}:null},sr=e=>{const t=G(e);if(!t)return Promise.resolve(!1);const n=M.get(t);if(n)return M.delete(t),M.set(t,n),n;const r=new Promise(o=>{const a=()=>{D+=1,Ge(`/api/fs/stat?path=${encodeURIComponent(t)}&optional=true`,{method:"GET",cache:"no-store"}).then(async i=>{if(!i.ok){o(!1);return}const c=await i.json().catch(()=>null);o(c?.exists!==!1)}).catch(()=>o(!1)).finally(()=>{D=Math.max(0,D-1),ye.shift()?.()})};if(D<Gt){a();return}ye.push(a)}),s=Qt();for(;M.size>=s;){const o=M.keys().next().value;if(typeof o!="string")break;M.delete(o)}return M.set(t,r),r},cr=(e,t)=>e||it(e,t),De=({containerRef:e,effectiveDirectory:t,editor:n,preferRuntimeEditor:r,enabled:s})=>{const o=y.useRef(null);y.useEffect(()=>{const a=e.current;if(!a)return;let i=!1;const c=er(),d=s&&!bt(),l=b=>{b.removeAttribute("data-pichamber-file-link"),b.removeAttribute("data-pichamber-file-ref"),b.removeAttribute("data-pichamber-file-path"),b.getAttribute("title")==="Open file"&&b.removeAttribute("title"),b.tagName.toLowerCase()!=="a"&&(b.removeAttribute("role"),b.removeAttribute("tabindex"))},m=()=>{const b=a.querySelectorAll(ge);for(const g of Array.from(b))l(g);ar(a)};if(!d){m();return}const p=(b=0)=>{if(o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),typeof window>"u"){f();return}o.current=window.setTimeout(()=>{o.current=null,window.requestAnimationFrame(()=>{i||f()})},b)},f=()=>{d&&ir(a);const b=a.querySelectorAll(`[data-markdown="inline-code"], a, ${Ie}`);let g=0;for(const u of Array.from(b)){const E=j(u),C=K(E,t);if(l(u),!C||g>=c)continue;g+=1,(Ze()&&Xe()&&!re(C.resolvedPath,t)?Promise.resolve(!0):sr(C.resolvedPath)).then(je=>{if(i||!je||!a.contains(u))return;const Q=j(u),H=K(Q,t);!H||H.resolvedPath!==C.resolvedPath||(u.setAttribute("data-pichamber-file-link","true"),u.setAttribute("data-pichamber-file-ref",Q),u.setAttribute("data-pichamber-file-path",H.resolvedPath),u.setAttribute("title","Open file"),u.tagName.toLowerCase()!=="a"&&(u.setAttribute("role","button"),u.setAttribute("tabindex","0")))})}},h=async b=>{const g=b.getAttribute("data-pichamber-file-ref")||j(b),u=K(g,t);if(!u)return;const E=cr(t,u.resolvedPath);re(u.resolvedPath,t)||await at(u.resolvedPath,t);const C=ve.getState();Number.isFinite(u.line??Number.NaN)?C.openContextFileAtLine(E,u.resolvedPath,Math.max(1,Math.trunc(u.line)),Number.isFinite(u.column??Number.NaN)?Math.max(1,Math.trunc(u.column)):1):C.openContextFile(E,u.resolvedPath)},v=b=>{const g=b.target;if(!(g instanceof Element))return;const u=g.closest(ge);u instanceof HTMLElement&&(b.preventDefault(),b.stopPropagation(),h(u))},A=b=>{if(b.key!=="Enter"&&b.key!==" ")return;const g=b.target;!(g instanceof HTMLElement)||g.getAttribute("data-pichamber-file-link")!=="true"||(b.preventDefault(),b.stopPropagation(),h(g))};p(we);const w=new MutationObserver(()=>{p(we)});return w.observe(a,{childList:!0,subtree:!0}),a.addEventListener("click",v),a.addEventListener("keydown",A),()=>{i=!0,o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),o.current=null,w.disconnect(),a.removeEventListener("click",v),a.removeEventListener("keydown",A)}},[e,n,t,r,s])},P={download:!0,copy:!0,showPanZoomControls:!0},qe=!0,$e=({containerRef:e,onShowPopup:t,enableFullscreen:n,enablePanZoom:r,allowMermaidWheelEvents:s})=>{y.useEffect(()=>{const o=e.current;if(!o)return;const a=c=>{if(!t)return;const d=c.target;if(!(d instanceof Element)||d.closest('button, a, [role="button"]'))return;const l=d.closest(I);if(!l)return;if(l instanceof HTMLElement&&l.hasAttribute("data-mermaid-suppress-click")){l.removeAttribute("data-mermaid-suppress-click");return}const p=Array.from(o.querySelectorAll(I)).indexOf(l);if(p<0)return;const f=l instanceof HTMLElement?l.getAttribute("data-md-source"):null;if(!f||f.trim().length===0)return;const h=`Diagram ${p+1}`;t({open:!0,title:h,content:"",metadata:{tool:"mermaid-preview",filename:h},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(f)}`,source:f,filename:h}})},i=c=>{if(s||(c.ctrlKey||c.metaKey)&&r)return;const d=c.target;!(d instanceof Element)||!d.closest(I)||c.stopPropagation()};return o.addEventListener("click",a),o.addEventListener("wheel",i,{capture:!0,passive:!0}),()=>{o.removeEventListener("click",a),o.removeEventListener("wheel",i,!0)}},[s,e,n,r,t])},N=new Map,lr=100,dr=(e,t)=>{const n=N.get(e);if(n)return N.delete(e),N.set(e,n),n;const r=t();if(N.set(e,r),N.size>lr){const s=N.keys().next().value;s&&N.delete(s)}return r},ur=e=>({bg:e.colors.surface.elevated,fg:e.colors.surface.foreground,line:e.colors.interactive.border,accent:e.colors.primary.base,muted:e.colors.surface.mutedForeground,surface:e.colors.surface.muted,border:e.colors.interactive.border,transparent:!0,font:"system-ui, sans-serif"}),ze=()=>{const e=lt(),t=te(!1),n=te(!0);return e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?n:t)},mr=e=>{const t=e.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return t?e.slice(t[0].length):e},He=(e,t,n,r=P)=>{const s=y.useMemo(()=>({copy:"Copy code",copied:"Copied",copyTable:"Copy table",downloadTable:"Download table",copyDiagram:"Copy source",downloadDiagram:"Download SVG",zoomInDiagram:"Zoom in",zoomOutDiagram:"Zoom out",resetDiagramView:"Reset view",previewLabel:"Preview",previewTitle:"Open preview pane"}),[]);return y.useMemo(()=>{const o=ur(e),a=e.metadata?.id??"theme";return{labels:s,mermaidControls:r,deferCodeLineNumberSync:t,renderMermaid:c=>dr(`${a}:svg:${c}`,()=>{try{return{svg:Ue(c,o)}}catch{return{}}}),onPreviewLoopback:n}},[e,s,r,t,n])},We=e=>{e.style.display="contents",e.style.width="",e.style.minWidth="",e.style.maxWidth=""},U=(e,t)=>{We(e);const n=ft(t);let r=e.querySelector(":scope > [data-md-live]");const s=r?.hasAttribute("data-md-live-pre")===!0;(!r||s!==n)&&(e.replaceChildren(),r=document.createElement(n?"div":"p"),r.setAttribute("data-md-live",""),n&&r.setAttribute("data-md-live-pre",""),r.className=n?"w-full min-w-0 whitespace-pre-wrap break-words":"w-full min-w-0 break-words",r.appendChild(document.createTextNode("")),e.appendChild(r));const o=r.firstChild;if(!(o instanceof globalThis.Text)){r.replaceChildren(document.createTextNode(t));return}if(t.startsWith(o.data)){const a=t.slice(o.data.length);a.length>0&&o.appendData(a);return}o.data=t},Be=({containerRef:e,text:t,streaming:n,cacheKey:r,syntaxVars:s,ctx:o})=>{y.useEffect(()=>{wt()},[]);const a=y.useRef(null),i=y.useRef(null),c=y.useRef(r);c.current!==r&&(c.current=r,i.current=null);const d=y.useCallback(()=>{const l=e.current;if(l){if(!a.current){if(!L(l))return;a.current=Ot(l);return}a.current.refresh()}},[e]);y.useLayoutEffect(()=>{const l=e.current,m=l?.querySelector("[data-markdown-content]")??l;if(m&&t&&m.childNodes.length===0){const p=document.createElement("div");if(p.setAttribute("data-md-block",""),p.style.display="contents",n){U(p,t),m.appendChild(p);return}p.innerHTML=dt(t),pe(p,o),m.appendChild(p),L(p)&&d()}},[e,t,n,o,d]),y.useEffect(()=>()=>{a.current?.cleanup(),a.current=null},[]),y.useEffect(()=>{const l=e.current;if(!l)return;const m=l.querySelector("[data-markdown-content]")??l;let p=!0;if(n&&i.current){const f=ut(r).update(t);if(mt(i.current,f)){const h=f[f.length-1],v=m.querySelectorAll(":scope > [data-md-block]")[f.length-1];if(h&&v){U(v,h.raw),v.setAttribute("data-md-id",`live:${f.length-1}`),i.current=i.current.map((A,w)=>w===f.length-1?{...A,raw:h.raw,id:`live:${w}`,mode:"live"}:A);return}}}return pt(t,n,r).then(f=>{if(!p)return;const h=Array.from(m.querySelectorAll(":scope > [data-md-block]"));f.forEach((w,b)=>{let g=h[b];if(g||(g=document.createElement("div"),g.setAttribute("data-md-block",""),g.style.display="contents",m.appendChild(g)),w.mode==="live"){U(g,w.raw),g.setAttribute("data-md-id",w.id);return}if(We(g),g.getAttribute("data-md-id")===w.id)return;const u=document.createElement("div");u.innerHTML=w.html,pe(u,o);const E=L(g),C=L(u);Ke(g,u,{childrenOnly:!0,onBeforeElUpdated:(Y,J)=>!Y.isEqualNode(J)}),g.setAttribute("data-md-id",w.id),(E||C||L(g))&&d()});const v=L(m);let A=!1;for(let w=h.length-1;w>=f.length;w-=1){const b=h[w];b&&L(b)&&(A=!0),b?.remove()}(A||h.length>f.length&&v)&&d(),i.current=f}),()=>{p=!1}},[e,t,n,r,o,d]),y.useEffect(()=>{const l=e.current;if(l)return jt(l,o)},[e,o]),y.useEffect(()=>{const l=e.current,m=l?.querySelector("[data-markdown-content]")??l;if(m)for(const[p,f]of Object.entries(s))m.style.setProperty(p,f)},[e,s]),y.useEffect(()=>{const l=e.current,m=l?.querySelector("[data-markdown-content]")??l;m&&(o.deferCodeLineNumberSync||Dt(m))},[e,o.deferCodeLineNumberSync])},Ve=(e,t)=>Z("w-full min-w-0",e==="tool"?"markdown-content markdown-tool":e==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",t&&"markdown-streaming"),pr=({content:e,part:t,messageId:n,isAnimated:r=!0,skipFadeIn:s=!1,className:o,isStreaming:a=!1,disableStreamAnimation:i=!1,variant:c="assistant",onShowPopup:d,enableFileReferences:l=!0})=>{ee("ui.markdown_renderer.render"),a&&ee("ui.markdown_renderer.render.streaming"),Ye("ui.markdown_renderer.content_len",e.length);const m=ze(),{editor:p}=ke(),f=y.useRef(null),h=Ee()??"",v=ve(C=>C.openContextPreview),A=y.useCallback(C=>{h&&v(h,C)},[h,v]),w=a&&!i;$e({containerRef:f,onShowPopup:d,enableFullscreen:qe,enablePanZoom:P.showPanZoomControls}),De({containerRef:f,effectiveDirectory:h,editor:p,preferRuntimeEditor:!1,enabled:l&&!a}),Re({containerRef:f});const b=y.useMemo(()=>Ce(m),[m]),g=He(m,w,h?A:void 0,P),u=`markdown-${t?.id?`part-${t.id}`:`message-${n}`}`;Be({containerRef:f,text:e,streaming:w,cacheKey:u,syntaxVars:b,ctx:g});const E=_.jsx("div",{className:Z("break-words w-full min-w-0",o),ref:f,children:_.jsx("div",{className:Ve(c,w),"data-markdown-content":!0})});return r?_.jsx(ct,{skipAnimation:s,children:E},u):E},Gr=y.memo(pr,(e,t)=>e.content===t.content&&e.isStreaming===t.isStreaming&&e.disableStreamAnimation===t.disableStreamAnimation&&e.variant===t.variant&&e.isAnimated===t.isAnimated&&e.skipFadeIn===t.skipFadeIn&&e.className===t.className&&e.messageId===t.messageId&&e.onShowPopup===t.onShowPopup&&e.enableFileReferences===t.enableFileReferences&&e.part?.id===t.part?.id),fr=({content:e,className:t,variant:n="assistant",disableLinkSafety:r,stripFrontmatter:s=!1,onShowPopup:o,mermaidControls:a=P,allowMermaidWheelEvents:i=!1,enableFileReferences:c=!0})=>{const{editor:d}=ke(),l=ze(),m=y.useRef(null),p=Ee()??"",f=y.useMemo(()=>s?mr(e):e,[e,s]);$e({containerRef:m,onShowPopup:o,enableFullscreen:qe,enablePanZoom:a.showPanZoomControls,allowMermaidWheelEvents:i}),De({containerRef:m,effectiveDirectory:p,editor:d,preferRuntimeEditor:!1,enabled:c}),Re({containerRef:m,enabled:!r});const h=y.useMemo(()=>Ce(l),[l]),v=He(l,!1,void 0,a);return Be({containerRef:m,text:f,streaming:!1,cacheKey:`simple:${n}`,syntaxVars:h,ctx:v}),_.jsx("div",{className:Z("break-words w-full min-w-0",t),ref:m,children:_.jsx("div",{className:Ve(n),"data-markdown-content":!0})})},Yr=y.memo(fr,(e,t)=>{const n=e.mermaidControls??P,r=t.mermaidControls??P;return e.content===t.content&&e.variant===t.variant&&e.className===t.className&&e.disableLinkSafety===t.disableLinkSafety&&e.stripFrontmatter===t.stripFrontmatter&&e.onShowPopup===t.onShowPopup&&n.download===r.download&&n.copy===r.copy&&n.showPanZoomControls===r.showPanZoomControls&&e.allowMermaidWheelEvents===t.allowMermaidWheelEvents&&e.enableFileReferences===t.enableFileReferences});export{Gr as MarkdownRenderer,Yr as SimpleMarkdownRenderer};
|
|
1
|
+
import{j as _}from"./vendor-boot-DyL2td56.js";import{R as y}from"./vendor-react-DASdDPIk.js";import{m as Ke}from"./vendor-morphdom-B7dS_VPB.js";import{r as Ue}from"./vendor-beautiful-mermaid-DApbjBp2.js";import{S as Ze,an as Xe,t as ve,m as Ge,a8 as ee,bN as Ye,o as Z,_ as te}from"./index-Dd2OcIUY.js";import{c6 as Ae,c7 as Je,c8 as Qe,ae as W,br as et,bs as tt,c9 as nt,ca as rt,o as ot,cb as ne,cc as at,cd as it,ce as st,p as ke,n as Ee,cf as Ce,cg as ct,aX as lt}from"./useAppFontEffects--lKKtKVo.js";import{r as dt,s as ut,i as mt,a as pt,b as ft}from"./markdownCore-BH56o6Wu.js";import{r as ht}from"./registerCustomTheme-DmolaWWZ.js";import{i as bt}from"./runtimeSurface-B1GRkkKC.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-elkjs-D27273Ms.js";import"./vendor-entities-C3BA0AJP.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-marked-CX41MkDF.js";import"./vendor-dompurify-r8glNMJW.js";import"./vendor-remend-BWYYytN3.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";const Se="pichamber-md",gt={name:Se,colors:{"editor.background":"transparent","editor.foreground":"var(--md-syntax-foreground)"},tokenColors:[{scope:["comment","punctuation.definition.comment","string.comment"],settings:{foreground:"var(--md-syntax-comment)",fontStyle:"italic"}},{scope:["string","punctuation.definition.string","string.template"],settings:{foreground:"var(--md-syntax-string)"}},{scope:["constant.numeric","constant.language","constant.character","constant"],settings:{foreground:"var(--md-syntax-number)"}},{scope:["keyword","storage","storage.type","storage.modifier","keyword.control"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["keyword.operator","punctuation.separator","punctuation.terminator"],settings:{foreground:"var(--md-syntax-operator)"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"var(--md-syntax-function)"}},{scope:["entity.name.type","entity.name.class","support.type","support.class","entity.other.inherited-class"],settings:{foreground:"var(--md-syntax-type)"}},{scope:["variable","variable.other","variable.parameter","meta.definition.variable"],settings:{foreground:"var(--md-syntax-variable)"}},{scope:["variable.other.property","meta.property-name","support.type.property-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["entity.name.tag","punctuation.definition.tag"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["entity.other.attribute-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["markup.bold","punctuation.definition.bold"],settings:{fontStyle:"bold"}},{scope:["markup.italic","punctuation.definition.italic"],settings:{fontStyle:"italic"}},{scope:["markup.heading","markup.heading entity.name"],settings:{foreground:"var(--md-syntax-keyword)",fontStyle:"bold"}},{scope:["markup.inserted","punctuation.definition.inserted"],settings:{foreground:"var(--md-syntax-inserted)"}},{scope:["markup.deleted","punctuation.definition.deleted"],settings:{foreground:"var(--md-syntax-deleted)"}},{scope:["invalid","invalid.illegal"],settings:{foreground:"var(--md-syntax-deleted)"}}]};let re=!1;const wt=()=>{re||(re=!0,ht(Se,()=>Promise.resolve(gt)))},k=e=>Number.isFinite(e)&&e>0,oe=e=>{if(typeof e=="number")return k(e)?e:null;if(typeof e!="string")return null;const t=e.trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!t)return null;const r=Number(t[1]);return k(r)?r:null},B=(e,t,r)=>Math.min(r,Math.max(t,e)),yt=6,ae=1.25,vt=1.0015,At=.5,kt=12,ie=3,Et=400,I='[data-markdown="mermaid-block"]',L=e=>e.querySelector(I)!==null,Ct=e=>[e.x,e.y,e.width,e.height].map(t=>{const r=Number(t.toFixed(yt));return Object.is(r,-0)?"0":String(r)}).join(" "),St=e=>{const t=e.viewBox?.trim().split(/[\s,]+/).map(s=>Number.parseFloat(s));if(t?.length===4){const[s,o,a,i]=t;if(Number.isFinite(s)&&Number.isFinite(o)&&k(a)&&k(i))return{x:s,y:o,width:a,height:i}}const r=oe(e.width),n=oe(e.height);return r===null||n===null?null:{x:0,y:0,width:r,height:n}},Lt=e=>{let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(36)},Mt=e=>{const t=e.renderMode||"unknown",r=e.svgMarkup??"";if(!r){const n=[e.viewBox??"",e.width??"",e.height??""];return n.some(s=>s!=="")?`${t}:bounds:${n.join(":")}`:`${t}:no-svg`}return[t,Lt(r)].join(":")},Le=(e,t)=>{if(!k(t.width)||!k(t.height))return e;const r=e.width/e.height,n=t.width/t.height;if(r>n){const o=e.width/n;return{x:e.x,y:e.y-(o-e.height)/2,width:e.width,height:o}}const s=e.height*n;return{x:e.x-(s-e.width)/2,y:e.y,width:s,height:e.height}},Nt=({currentBox:e,viewport:t,delta:r})=>!k(t.width)||!k(t.height)||!k(e.width)||!k(e.height)?e:{x:e.x-r.x/t.width*e.width,y:e.y-r.y/t.height*e.height,width:e.width,height:e.height},xt=(e,t)=>{const r=t.x-e.x,n=t.y-e.y;return r*r+n*n>ie*ie},Tt=({currentBox:e,contentBox:t,viewport:r,pointer:n,zoomFactor:s,minScale:o,maxScale:a})=>{if(!k(r.width)||!k(r.height)||!k(s)||!k(e.width)||!k(e.height)||!k(t.width)||!k(t.height)||!k(o)||!k(a))return e;const i=Math.min(o,a),c=Math.max(o,a),d=Le(t,r),l=d.width/e.width,m=B(l*s,i,c),p=d.width/m,f=p/(e.width/e.height),h=B(n.x/r.width,0,1),v=B(n.y/r.height,0,1),A=e.x+h*e.width,w=e.y+v*e.height;return{x:A-h*p,y:w-v*f,width:p,height:f}},X=new WeakMap,Pt=e=>e instanceof HTMLElement?X.get(e)??null:null,Rt=e=>e.querySelector('[data-markdown="mermaid-viewport"]')??e.querySelector('[data-markdown="mermaid"]'),se=e=>{const t=e.querySelector('[data-markdown="mermaid"] svg'),r=e.querySelector('[data-markdown="mermaid"]');return Mt({renderMode:e.getAttribute("data-mermaid-render"),svgMarkup:r?.getAttribute("data-md-original-svg")??t?.outerHTML??null,viewBox:t?.getAttribute("viewBox"),width:t?.getAttribute("width"),height:t?.getAttribute("height")})},R=e=>{const t=e.getBoundingClientRect();return{width:t.width,height:t.height}},_t=(e,t)=>{const r=t.getBoundingClientRect();return{x:e.clientX-r.left,y:e.clientY-r.top}},It=e=>e instanceof Element&&!!e.closest('button, a, [role="button"]'),Ft=e=>{const t=Rt(e),r=e.querySelector('[data-markdown="mermaid"] svg');if(!t||!r)return null;const n=St({viewBox:r.getAttribute("viewBox"),width:r.getAttribute("width"),height:r.getAttribute("height")});if(!n)return null;let s=n,o=null,a=null,i=null,c=null;const d=u=>{s=u,r.setAttribute("viewBox",Ct(u)),r.removeAttribute("width"),r.removeAttribute("height")},l=()=>{d(Le(n,R(t)))},m=(u,E)=>{d(Tt({currentBox:s,contentBox:n,viewport:R(t),pointer:u,zoomFactor:E,minScale:At,maxScale:kt}))},p=()=>{const u=R(t);m({x:u.width/2,y:u.height/2},ae)},f=()=>{const u=R(t);m({x:u.width/2,y:u.height/2},1/ae)},h=u=>{!u.ctrlKey&&!u.metaKey||(u.preventDefault(),u.stopPropagation(),m(_t(u,t),Math.pow(vt,-u.deltaY)))},v=u=>{u.button!==0||It(u.target)||(o=u.pointerId,a={x:u.clientX,y:u.clientY},i=a,c!==null&&(window.clearTimeout(c),c=null),e.removeAttribute("data-mermaid-suppress-click"),t.setPointerCapture?.(u.pointerId),e.setAttribute("data-mermaid-panning","true"),u.preventDefault())},A=u=>{if(o!==u.pointerId||!i)return;const E={x:u.clientX,y:u.clientY};d(Nt({currentBox:s,viewport:R(t),delta:{x:E.x-i.x,y:E.y-i.y}})),i=E,a&&xt(a,E)&&e.setAttribute("data-mermaid-suppress-click","true"),u.preventDefault()},w=u=>{o===u.pointerId&&(t.releasePointerCapture?.(u.pointerId),o=null,a=null,i=null,e.removeAttribute("data-mermaid-panning"),e.hasAttribute("data-mermaid-suppress-click")&&(c=window.setTimeout(()=>{e.removeAttribute("data-mermaid-suppress-click"),c=null},Et)))},b=()=>{l()};t.addEventListener("wheel",h,{passive:!1}),t.addEventListener("pointerdown",v),t.addEventListener("pointermove",A),t.addEventListener("pointerup",w),t.addEventListener("pointercancel",w),window.addEventListener("resize",b);const g=typeof ResizeObserver>"u"?null:new ResizeObserver(b);return g?.observe(t),l(),{zoomIn:p,zoomOut:f,fit:l,cleanup:()=>{t.removeEventListener("wheel",h),t.removeEventListener("pointerdown",v),t.removeEventListener("pointermove",A),t.removeEventListener("pointerup",w),t.removeEventListener("pointercancel",w),window.removeEventListener("resize",b),g?.disconnect(),c!==null&&window.clearTimeout(c),e.removeAttribute("data-mermaid-panning"),e.removeAttribute("data-mermaid-suppress-click"),X.delete(e)}}},Ot=e=>{const t=new Map,r=new Map,n=()=>{for(const[o,a]of Array.from(t.entries())){const i=se(o);(!e.contains(o)||i!==r.get(o))&&(a.cleanup(),t.delete(o),r.delete(o))}for(const o of Array.from(e.querySelectorAll(I))){if(t.has(o)||o.querySelector('[data-markdown="mermaid"] svg')===null)continue;const a=Ft(o);a&&(t.set(o,a),r.set(o,se(o)),X.set(o,a))}},s=()=>{for(const o of t.values())o.cleanup();t.clear(),r.clear()};return n(),{refresh:n,cleanup:s}},x=e=>`<svg class="remixicon size-3.5" viewBox="0 0 24 24" aria-hidden="true"><use href="#oc-${e}"></use></svg>`,q={copy:x("file-copy"),check:x("check"),download:x("download"),zoomIn:x("add"),zoomOut:x("subtract"),fit:x("refresh")},Me="p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--interactive-focus-ring)]",$=(e,t)=>{e.innerHTML=t},S=(e,t,r)=>{const n=document.createElement("button");return n.type="button",n.className=Me,n.setAttribute("data-md-action",r),n.setAttribute("title",t),n.setAttribute("aria-label",t),$(n,q[e]),n},Ne=e=>{const t=e.querySelector("[data-md-code-body]"),r=e.querySelector("pre"),n=e.querySelector("pre code"),s=e.querySelectorAll("[data-md-code-line-content]");e.setAttribute("data-code-wrap","true"),t?.classList.remove("overflow-x-auto"),t?.classList.add("overflow-x-hidden"),r?.classList.add("whitespace-pre-wrap","break-words"),n?.classList.add("whitespace-pre-wrap","break-words"),r&&(r.style.whiteSpace="pre-wrap",r.style.overflowWrap="anywhere"),n&&(n.style.whiteSpace="pre-wrap",n.style.overflowWrap="anywhere");for(const o of Array.from(s))o.style.whiteSpace="pre-wrap",o.style.overflowWrap="anywhere"},xe=e=>{const t=e.querySelector(":scope > code");if(!t||t.hasAttribute("data-md-code-lines"))return;const r=t.textContent??"",n=r.endsWith(`
|
|
2
|
+
`),s=n?r.slice(0,-1).split(`
|
|
3
|
+
`):r.split(`
|
|
4
|
+
`),o=s.length>0?s:[""],a=Array.from(t.children).filter(d=>d.classList.contains("line"));n&&a.length===o.length+1&&a.at(-1)?.textContent===""&&a.pop();const i=a.length===o.length,c=document.createDocumentFragment();o.forEach((d,l)=>{const m=document.createElement("span");m.setAttribute("data-md-code-line","");const p=document.createElement("span");p.setAttribute("data-md-code-line-number",""),p.setAttribute("aria-hidden","true"),p.textContent=String(l+1);const f=document.createElement("span");if(f.setAttribute("data-md-code-line-content",""),i){const h=a[l];h&&f.append(...Array.from(h.childNodes))}else f.textContent=d;if(m.append(p,f),c.appendChild(m),l<o.length-1||n){const h=document.createElement("span");h.setAttribute("data-md-code-line-break",""),h.textContent=`
|
|
5
|
+
`,c.appendChild(h)}}),t.replaceChildren(c),t.setAttribute("data-md-code-lines",""),t.toggleAttribute("data-md-code-trailing-newline",n)},Te=e=>{const t=Array.from(e.querySelectorAll("[data-md-code-line-content]"));if(t.length===0)return e.textContent??"";const r=t.map(n=>n.textContent??"").join(`
|
|
6
|
+
`);return e.hasAttribute("data-md-code-trailing-newline")?`${r}
|
|
7
|
+
`:r},Dt=e=>{const t=e.querySelectorAll('[data-component="markdown-code"]');for(const r of Array.from(t)){const n=r.querySelector("pre");n&&xe(n),Ne(r)}},ce=(e,t,r,n)=>{$(e,q.check),e.setAttribute("title",t),e.setAttribute("aria-label",t),window.setTimeout(()=>{$(e,q[r]),e.setAttribute("title",n),e.setAttribute("aria-label",n)},2e3)},qt=e=>{const t=e.querySelectorAll(":not(pre) > code");for(const r of Array.from(t))r.getAttribute("data-markdown")!=="inline-code"&&r.setAttribute("data-markdown","inline-code")},$t=(e,t)=>{const r=e.querySelectorAll("pre");for(const n of Array.from(r)){if(n.querySelector("code.language-mermaid"))continue;const s=n.parentElement;if(!s||s.closest('[data-component="markdown-code"]'))continue;const o=n.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],a=n.getAttribute("data-md-lang")??o??"text",i=document.createElement("div");i.setAttribute("data-component","markdown-code"),i.className="my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]";const c=document.createElement("div");c.className="flex items-center justify-between border-b border-border/70 px-3 py-1.5";const d=document.createElement("span");d.className="font-mono text-[13px] text-muted-foreground",d.textContent=a;const l=S("copy",t.labels.copy,"copy-code");c.appendChild(d);const m=document.createElement("div");m.className="flex items-center gap-1",m.setAttribute("data-md-code-actions",""),m.appendChild(l),c.appendChild(m);const p=document.createElement("div");p.setAttribute("data-md-code-body",""),p.className="px-3 py-2.5 overflow-x-auto",s.replaceChild(i,n),n.style.margin="0",n.style.background="transparent",n.classList.add("min-w-0","w-full","flex-1"),t.deferCodeLineNumberSync||xe(n),p.appendChild(n),i.appendChild(c),i.appendChild(p),Ne(i)}},le=e=>{const t=[],r=[],n=e.querySelectorAll("thead th");for(const o of Array.from(n))t.push((o.textContent??"").trim());const s=e.querySelectorAll("tbody tr");for(const o of Array.from(s)){const a=Array.from(o.querySelectorAll("td")).map(i=>(i.textContent??"").trim());a.length>0&&r.push(a)}return{headers:t,rows:r}},zt=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,de=({headers:e,rows:t})=>[e,...t].map(r=>r.map(zt).join(",")).join(`
|
|
8
|
+
`),Ht=({headers:e,rows:t})=>[e,...t].map(r=>r.join(" ")).join(`
|
|
9
|
+
`),ue=({headers:e,rows:t})=>{const r=`| ${e.join(" | ")} |`,n=`| ${e.map(()=>"---").join(" | ")} |`,s=t.map(o=>`| ${o.join(" | ")} |`).join(`
|
|
10
|
+
`);return`${r}
|
|
11
|
+
${n}
|
|
12
|
+
${s}`},me=(e,t)=>{const r=document.createElement("div");r.className=`absolute top-full right-0 mt-1 hidden ${et}`,r.style.backgroundColor="var(--surface-elevated)",r.style.color="var(--surface-elevated-foreground)",r.setAttribute("data-md-menu",e);for(const n of t){const s=document.createElement("button");s.type="button",s.className=`w-full text-left ${tt}`,s.setAttribute("data-md-action",`${e}-${n.key}`),s.textContent=n.label,r.appendChild(s)}return r},Wt=(e,t)=>{const r=e.querySelectorAll("table");for(const n of Array.from(r)){if(n.closest('[data-markdown="table-wrapper"]'))continue;const o=document.createElement("div");o.className="group my-4 flex flex-col space-y-2",o.setAttribute("data-markdown","table-wrapper");const a=document.createElement("div");a.className="flex items-center justify-end gap-1";const i=document.createElement("div");i.className="relative",i.appendChild(S("copy",t.copyTable,"table-copy-toggle")),i.appendChild(me("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const c=document.createElement("div");c.className="relative",c.appendChild(S("download",t.downloadTable,"table-download-toggle")),c.appendChild(me("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),a.appendChild(i),a.appendChild(c);const d=document.createElement("div");d.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const l=n.parentElement;if(!l)continue;l.replaceChild(o,n),n.setAttribute("data-markdown","table"),n.classList.add("w-full","border-collapse","text-sm");for(const p of Array.from(n.querySelectorAll("tr")))p.classList.add("border-b","border-border/60");const m=n.querySelector("tbody tr:last-child");m?.classList.remove("border-b"),m?.classList.add("border-0");for(const p of Array.from(n.querySelectorAll("th")))p.classList.add("border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const p of Array.from(n.querySelectorAll("td")))p.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground/90","last:border-r-0");d.appendChild(n),o.appendChild(a),o.appendChild(d)}},Bt=(e,t)=>{const r=e.querySelectorAll("pre > code.language-mermaid");for(const n of Array.from(r)){const s=n.parentElement;if(!s)continue;const o=(n.textContent??"").replace(/\s+$/,""),a=t.renderMermaid(o),i=document.createElement("div");i.setAttribute("data-markdown","mermaid-block"),i.setAttribute("data-md-source",o),i.className="group relative";const c=document.createElement("div");c.setAttribute("data-markdown","mermaid-scroll");const d=document.createElement("div");if(d.setAttribute("data-markdown","mermaid-toolbar"),d.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",a.svg){i.setAttribute("data-mermaid-render","svg");const m=document.createElement("div");m.setAttribute("data-markdown","mermaid-viewport");const p=document.createElement("div");if(p.setAttribute("data-markdown","mermaid"),p.setAttribute("data-md-original-svg",a.svg),p.innerHTML=a.svg,m.appendChild(p),c.appendChild(m),t.mermaidControls.showPanZoomControls&&(d.appendChild(S("zoomIn",t.labels.zoomInDiagram,"mermaid-zoom-in")),d.appendChild(S("zoomOut",t.labels.zoomOutDiagram,"mermaid-zoom-out")),d.appendChild(S("fit",t.labels.resetDiagramView,"mermaid-fit"))),t.mermaidControls.copy){const f=S("copy",t.labels.copyDiagram,"mermaid-copy");f.setAttribute("data-md-source",o),d.appendChild(f)}if(t.mermaidControls.download){const f=S("download",t.labels.downloadDiagram,"mermaid-download");f.setAttribute("data-md-svg","1"),d.appendChild(f)}}else{i.setAttribute("data-mermaid-render","svg");const m=document.createElement("pre");if(m.setAttribute("data-markdown","mermaid-ascii"),m.textContent=o,c.appendChild(m),t.mermaidControls.copy){const p=S("copy",t.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",o),d.appendChild(p)}}i.appendChild(c),i.appendChild(d);const l=s.parentElement;l&&l.replaceChild(i,s)}},Vt=(e,t)=>{const r=e.querySelectorAll("a[href]");for(const n of Array.from(r)){if(n.getAttribute("data-md-link-decorated")==="true"||n.getAttribute("data-pichamber-file-link")==="true")continue;const s=n.getAttribute("href")??"";if(!Ae(s))continue;n.setAttribute("data-md-link-decorated","true");const o=Je(s);if(o){const a=document.createElement("span");a.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const i=document.createElement("img");i.src=o,i.alt="",i.setAttribute("aria-hidden","true"),i.loading="lazy",i.decoding="async",i.className="size-3.5 rounded-sm",i.addEventListener("error",()=>a.remove(),{once:!0}),a.appendChild(i),n.parentNode?.insertBefore(a,n)}if(t.onPreviewLoopback&&Qe(s)){const a=document.createElement("button");a.type="button",a.className=`ml-1 align-middle ${Me}`,a.setAttribute("data-md-action","preview-loopback"),a.setAttribute("data-md-url",s),a.setAttribute("title",t.labels.previewTitle),a.setAttribute("aria-label",t.labels.previewLabel),$(a,q.download),n.parentNode?.insertBefore(a,n.nextSibling)}}},pe=(e,t)=>{qt(e),Bt(e,t),$t(e,t),Wt(e,t.labels),Vt(e,t)},fe=(e,t,r)=>{const n=new Blob([t],{type:r}),s=URL.createObjectURL(n),o=document.createElement("a");o.href=s,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s)},F=e=>{for(const t of Array.from(e.querySelectorAll("[data-md-menu]")))t.classList.add("hidden")},jt=(e,t)=>{const r=n=>{const s=n.target;if(!(s instanceof Element))return;const o=s.closest("[data-md-action]");if(!o){F(e);return}const a=o.getAttribute("data-md-action")??"";if(a==="copy-code"){const i=o.closest('[data-component="markdown-code"]')?.querySelector("code"),c=i?Te(i):"";c&&W(c).then(()=>ce(o,t.labels.copied,"copy",t.labels.copy));return}if(a==="table-copy-toggle"||a==="table-download-toggle"){n.preventDefault();const i=o.parentElement?.querySelector("[data-md-menu]")??null,c=i?.classList.contains("hidden")??!1;F(e),i&&c&&i.classList.remove("hidden");return}if(a.startsWith("table-copy-")){const i=a.replace("table-copy-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const d=le(c),l=i==="csv"?de(d):i==="tsv"?Ht(d):ue(d);W(l)}F(e);return}if(a.startsWith("table-download-")){const i=a.replace("table-download-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const d=le(c),l=i==="csv"?de(d):ue(d);fe(i==="csv"?"table.csv":"table.md",l,i==="csv"?"text/csv":"text/markdown")}F(e);return}if(a==="mermaid-copy"){const i=o.getAttribute("data-md-source")??"";i&&W(i).then(()=>ce(o,t.labels.copied,"copy",t.labels.copyDiagram));return}if(a==="mermaid-zoom-in"||a==="mermaid-zoom-out"||a==="mermaid-fit"){n.preventDefault();const i=o.closest('[data-markdown="mermaid-block"]'),c=Pt(i);a==="mermaid-zoom-in"?c?.zoomIn():a==="mermaid-zoom-out"?c?.zoomOut():c?.fit();return}if(a==="mermaid-download"){const i=o.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),c=i?.getAttribute("data-md-original-svg")??i?.innerHTML??"";c&&fe("diagram.svg",c,"image/svg+xml;charset=utf-8");return}if(a==="preview-loopback"){n.preventDefault();const i=o.getAttribute("data-md-url")??"";i&&t.onPreviewLoopback?.(i);return}};return e.addEventListener("click",r),()=>e.removeEventListener("click",r)},he=(e,t,r)=>{let n=0;for(const o of e){const a=n+o.data.length;if(t<a||t===a&&r==="left")return{node:o,offset:Math.max(0,t-n)};n=a}const s=e.at(-1);return s?{node:s,offset:s.data.length}:null},Kt=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),be=Array.from(Kt).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Ut=e=>rt(e),Zt=e=>nt(e),z=e=>{let t=(e||"").trim();return t?((t.startsWith("`")&&t.endsWith("`")||t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1).trim()),t=t.replace(/[.,;!?]+$/g,""),t.endsWith(")")&&!t.includes("(")&&(t=t.slice(0,-1)),t.endsWith("]")&&!t.includes("[")&&(t=t.slice(0,-1)),t):""},O=e=>{let t=z(e);if(!t)return"";const r=t.indexOf(";");r>=0&&(t=t.slice(0,r)),t=t.replace(/#.*$/,"");const n=t.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);n&&(t=n[1]??t);const s=be.length>0?t.match(new RegExp(`^(.*(?:/|^)(${be})):.*$`,"i")):null;return s&&(t=s[1]??t),z(t)},Pe=e=>{const t=z(e);if(!t)return null;const r=t.indexOf(";"),n=r>=0?z(t.slice(0,r)):t;if(!n)return null;const s=n.match(/^(.*?):(\d+)-(\d+)$/);if(s){const c=O(s[1]??""),d=Number.parseInt(s[2]??"",10),l=Number.parseInt(s[3]??"",10);return!c||!Number.isFinite(d)||!Number.isFinite(l)||l<d?null:{path:c,line:d,endLine:l}}const o=n.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(o){const c=O(o[1]??""),d=Number.parseInt(o[2]??"",10),l=o[3]?Number.parseInt(o[3],10):void 0;return!c||!Number.isFinite(d)?null:{path:c,line:d,column:Number.isFinite(l??Number.NaN)?l:void 0}}const a=n.match(/^(.*?):(\d+)(?::(\d+))?$/);if(a){const c=O(a[1]??""),d=Number.parseInt(a[2]??"",10),l=a[3]?Number.parseInt(a[3],10):void 0;return!c||!Number.isFinite(d)?null:{path:c,line:d,column:Number.isFinite(l??Number.NaN)?l:void 0}}const i=O(n);return i?{path:i}:null},V=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,Re=({containerRef:e,enabled:t})=>{y.useEffect(()=>{if(t===!1)return;const r=e.current;if(!r)return;const n=s=>{if(s.defaultPrevented||s.button!==0||s.metaKey||s.ctrlKey||s.altKey||s.shiftKey)return;const o=s.target;if(!(o instanceof Element))return;const a=o.closest("a[href]");if(!(a instanceof HTMLAnchorElement)||a.getAttribute("data-pichamber-file-link")==="true")return;const i=a.getAttribute("href")??"";Ae(i)&&(s.preventDefault(),s.stopPropagation(),ot(i))};return r.addEventListener("click",n),()=>{r.removeEventListener("click",n)}},[e,t])},ge='[data-pichamber-file-link="true"]',_e="data-pichamber-block-path-token",Ie=`[${_e}]`,T="data-pichamber-block-paths-scanned",Xt=2e5,Gt=4,Yt=1e3,Jt=80,we=160,M=new Map;let D=0;const ye=[],Qt=()=>Yt,en=()=>Jt,tn=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),G=e=>Ut(e),nn=e=>Zt(e),rn=(e,t)=>st(e,t),on=e=>{const t=e.split("/").filter(Boolean).pop()??"";return!t||t.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(t)},Fe=e=>{if(!e||e.startsWith("--")||e.includes("://")||/[<>]/.test(e)||/\s{2,}/.test(e))return!1;const t=G(e),r=t.split("/").filter(Boolean).pop()??t;if(!r||r==="."||r==="..")return!1;const n=r.toLowerCase();return tn.has(n)||n.startsWith(".")&&n.length>1?!0:on(t)},Oe=e=>{const t=Pe(e);return t?Fe(t.path):!1},an=e=>{const t=e.querySelectorAll(Ie);for(const n of Array.from(t))n.replaceWith(e.ownerDocument.createTextNode(n.textContent??""));const r=e.querySelectorAll(`code[${T}]`);for(const n of Array.from(r))n.removeAttribute(T),n.normalize()},j=e=>{if(e.tagName.toLowerCase()==="a"){const t=e.getAttribute("href")?.trim();if(t&&Oe(t))return t}return(e.textContent||"").trim()},sn=e=>{const t=e.querySelectorAll("pre code");if(t.length===0)return;const r=e.ownerDocument;if(r)for(const n of Array.from(t)){if(n.getAttribute(T)==="true")continue;if((n.textContent??"").length>Xt){n.setAttribute(T,"true");continue}const s=r.createTreeWalker(n,NodeFilter.SHOW_TEXT),o=[];let a=s.nextNode();for(;a;){const l=a;l.parentElement?.closest("[data-md-code-line-number]")||o.push(l),a=s.nextNode()}const i=Te(n);if(!i.includes(".")){n.setAttribute(T,"true");continue}V.lastIndex=0;const c=[];let d=V.exec(i);for(;d;){const l=d[0];l&&Oe(l)&&c.push({start:d.index,end:d.index+l.length,raw:l}),d=V.exec(i)}for(const{start:l,end:m,raw:p}of c.reverse()){const f=he(o,l,"right"),h=he(o,m,"left");if(!f||!h)continue;const v=r.createRange();v.setStart(f.node,f.offset),v.setEnd(h.node,h.offset);const A=r.createElement("span");A.setAttribute(_e,"true"),A.textContent=p,v.deleteContents(),v.insertNode(A)}n.setAttribute(T,"true")}},K=(e,t)=>{const r=Pe(e);if(!r||!Fe(r.path))return null;const n=nn(r.path)?G(r.path):rn(t,r.path);return n?{...r,resolvedPath:n}:null},cn=e=>{const t=G(e);if(!t)return Promise.resolve(!1);const r=M.get(t);if(r)return M.delete(t),M.set(t,r),r;const n=new Promise(o=>{const a=()=>{D+=1,Ge(`/api/fs/stat?path=${encodeURIComponent(t)}&optional=true`,{method:"GET",cache:"no-store"}).then(async i=>{if(!i.ok){o(!1);return}const c=await i.json().catch(()=>null);o(c?.exists!==!1)}).catch(()=>o(!1)).finally(()=>{D=Math.max(0,D-1),ye.shift()?.()})};if(D<Gt){a();return}ye.push(a)}),s=Qt();for(;M.size>=s;){const o=M.keys().next().value;if(typeof o!="string")break;M.delete(o)}return M.set(t,n),n},ln=(e,t)=>e||it(e,t),De=({containerRef:e,effectiveDirectory:t,editor:r,preferRuntimeEditor:n,enabled:s})=>{const o=y.useRef(null);y.useEffect(()=>{const a=e.current;if(!a)return;let i=!1;const c=en(),d=s&&!bt(),l=b=>{b.removeAttribute("data-pichamber-file-link"),b.removeAttribute("data-pichamber-file-ref"),b.removeAttribute("data-pichamber-file-path"),b.getAttribute("title")==="Open file"&&b.removeAttribute("title"),b.tagName.toLowerCase()!=="a"&&(b.removeAttribute("role"),b.removeAttribute("tabindex"))},m=()=>{const b=a.querySelectorAll(ge);for(const g of Array.from(b))l(g);an(a)};if(!d){m();return}const p=(b=0)=>{if(o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),typeof window>"u"){f();return}o.current=window.setTimeout(()=>{o.current=null,window.requestAnimationFrame(()=>{i||f()})},b)},f=()=>{d&&sn(a);const b=a.querySelectorAll(`[data-markdown="inline-code"], a, ${Ie}`);let g=0;for(const u of Array.from(b)){const E=j(u),C=K(E,t);if(l(u),!C||g>=c)continue;g+=1,(Ze()&&Xe()&&!ne(C.resolvedPath,t)?Promise.resolve(!0):cn(C.resolvedPath)).then(je=>{if(i||!je||!a.contains(u))return;const Q=j(u),H=K(Q,t);!H||H.resolvedPath!==C.resolvedPath||(u.setAttribute("data-pichamber-file-link","true"),u.setAttribute("data-pichamber-file-ref",Q),u.setAttribute("data-pichamber-file-path",H.resolvedPath),u.setAttribute("title","Open file"),u.tagName.toLowerCase()!=="a"&&(u.setAttribute("role","button"),u.setAttribute("tabindex","0")))})}},h=async b=>{const g=b.getAttribute("data-pichamber-file-ref")||j(b),u=K(g,t);if(!u)return;const E=ln(t,u.resolvedPath);ne(u.resolvedPath,t)||await at(u.resolvedPath,t);const C=ve.getState();Number.isFinite(u.line??Number.NaN)?C.openContextFileAtLine(E,u.resolvedPath,Math.max(1,Math.trunc(u.line)),Number.isFinite(u.column??Number.NaN)?Math.max(1,Math.trunc(u.column)):1):C.openContextFile(E,u.resolvedPath)},v=b=>{const g=b.target;if(!(g instanceof Element))return;const u=g.closest(ge);u instanceof HTMLElement&&(b.preventDefault(),b.stopPropagation(),h(u))},A=b=>{if(b.key!=="Enter"&&b.key!==" ")return;const g=b.target;!(g instanceof HTMLElement)||g.getAttribute("data-pichamber-file-link")!=="true"||(b.preventDefault(),b.stopPropagation(),h(g))};p(we);const w=new MutationObserver(()=>{p(we)});return w.observe(a,{childList:!0,subtree:!0}),a.addEventListener("click",v),a.addEventListener("keydown",A),()=>{i=!0,o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),o.current=null,w.disconnect(),a.removeEventListener("click",v),a.removeEventListener("keydown",A)}},[e,r,t,n,s])},P={download:!0,copy:!0,showPanZoomControls:!0},qe=!0,$e=({containerRef:e,onShowPopup:t,enableFullscreen:r,enablePanZoom:n,allowMermaidWheelEvents:s})=>{y.useEffect(()=>{const o=e.current;if(!o)return;const a=c=>{if(!t)return;const d=c.target;if(!(d instanceof Element)||d.closest('button, a, [role="button"]'))return;const l=d.closest(I);if(!l)return;if(l instanceof HTMLElement&&l.hasAttribute("data-mermaid-suppress-click")){l.removeAttribute("data-mermaid-suppress-click");return}const p=Array.from(o.querySelectorAll(I)).indexOf(l);if(p<0)return;const f=l instanceof HTMLElement?l.getAttribute("data-md-source"):null;if(!f||f.trim().length===0)return;const h=`Diagram ${p+1}`;t({open:!0,title:h,content:"",metadata:{tool:"mermaid-preview",filename:h},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(f)}`,source:f,filename:h}})},i=c=>{if(s||(c.ctrlKey||c.metaKey)&&n)return;const d=c.target;!(d instanceof Element)||!d.closest(I)||c.stopPropagation()};return o.addEventListener("click",a),o.addEventListener("wheel",i,{capture:!0,passive:!0}),()=>{o.removeEventListener("click",a),o.removeEventListener("wheel",i,!0)}},[s,e,r,n,t])},N=new Map,dn=100,un=(e,t)=>{const r=N.get(e);if(r)return N.delete(e),N.set(e,r),r;const n=t();if(N.set(e,n),N.size>dn){const s=N.keys().next().value;s&&N.delete(s)}return n},mn=e=>({bg:e.colors.surface.elevated,fg:e.colors.surface.foreground,line:e.colors.interactive.border,accent:e.colors.primary.base,muted:e.colors.surface.mutedForeground,surface:e.colors.surface.muted,border:e.colors.interactive.border,transparent:!0,font:"system-ui, sans-serif"}),ze=()=>{const e=lt(),t=te(!1),r=te(!0);return e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?r:t)},pn=e=>{const t=e.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return t?e.slice(t[0].length):e},He=(e,t,r,n=P)=>{const s=y.useMemo(()=>({copy:"Copy code",copied:"Copied",copyTable:"Copy table",downloadTable:"Download table",copyDiagram:"Copy source",downloadDiagram:"Download SVG",zoomInDiagram:"Zoom in",zoomOutDiagram:"Zoom out",resetDiagramView:"Reset view",previewLabel:"Preview",previewTitle:"Open preview pane"}),[]);return y.useMemo(()=>{const o=mn(e),a=e.metadata?.id??"theme";return{labels:s,mermaidControls:n,deferCodeLineNumberSync:t,renderMermaid:c=>un(`${a}:svg:${c}`,()=>{try{return{svg:Ue(c,o)}}catch{return{}}}),onPreviewLoopback:r}},[e,s,n,t,r])},We=e=>{e.style.display="contents",e.style.width="",e.style.minWidth="",e.style.maxWidth=""},U=(e,t)=>{We(e);const r=ft(t);let n=e.querySelector(":scope > [data-md-live]");const s=n?.hasAttribute("data-md-live-pre")===!0;(!n||s!==r)&&(e.replaceChildren(),n=document.createElement(r?"div":"p"),n.setAttribute("data-md-live",""),r&&n.setAttribute("data-md-live-pre",""),n.className=r?"w-full min-w-0 whitespace-pre-wrap break-words":"w-full min-w-0 break-words",n.appendChild(document.createTextNode("")),e.appendChild(n));const o=n.firstChild;if(!(o instanceof globalThis.Text)){n.replaceChildren(document.createTextNode(t));return}if(t.startsWith(o.data)){const a=t.slice(o.data.length);a.length>0&&o.appendData(a);return}o.data=t},Be=({containerRef:e,text:t,streaming:r,cacheKey:n,syntaxVars:s,ctx:o})=>{y.useEffect(()=>{wt()},[]);const a=y.useRef(null),i=y.useRef(null),c=y.useRef(n);c.current!==n&&(c.current=n,i.current=null);const d=y.useCallback(()=>{const l=e.current;if(l){if(!a.current){if(!L(l))return;a.current=Ot(l);return}a.current.refresh()}},[e]);y.useLayoutEffect(()=>{const l=e.current,m=l?.querySelector("[data-markdown-content]")??l;if(m&&t&&m.childNodes.length===0){const p=document.createElement("div");if(p.setAttribute("data-md-block",""),p.style.display="contents",r){U(p,t),m.appendChild(p);return}p.innerHTML=dt(t),pe(p,o),m.appendChild(p),L(p)&&d()}},[e,t,r,o,d]),y.useEffect(()=>()=>{a.current?.cleanup(),a.current=null},[]),y.useEffect(()=>{const l=e.current;if(!l)return;const m=l.querySelector("[data-markdown-content]")??l;let p=!0;if(r&&i.current){const f=ut(n).update(t);if(mt(i.current,f)){const h=f[f.length-1],v=m.querySelectorAll(":scope > [data-md-block]")[f.length-1];if(h&&v){U(v,h.raw),v.setAttribute("data-md-id",`live:${f.length-1}`),i.current=i.current.map((A,w)=>w===f.length-1?{...A,raw:h.raw,id:`live:${w}`,mode:"live"}:A);return}}}return pt(t,r,n).then(f=>{if(!p)return;const h=Array.from(m.querySelectorAll(":scope > [data-md-block]"));f.forEach((w,b)=>{let g=h[b];if(g||(g=document.createElement("div"),g.setAttribute("data-md-block",""),g.style.display="contents",m.appendChild(g)),w.mode==="live"){U(g,w.raw),g.setAttribute("data-md-id",w.id);return}if(We(g),g.getAttribute("data-md-id")===w.id)return;const u=document.createElement("div");u.innerHTML=w.html,pe(u,o);const E=L(g),C=L(u);Ke(g,u,{childrenOnly:!0,onBeforeElUpdated:(Y,J)=>!Y.isEqualNode(J)}),g.setAttribute("data-md-id",w.id),(E||C||L(g))&&d()});const v=L(m);let A=!1;for(let w=h.length-1;w>=f.length;w-=1){const b=h[w];b&&L(b)&&(A=!0),b?.remove()}(A||h.length>f.length&&v)&&d(),i.current=f}),()=>{p=!1}},[e,t,r,n,o,d]),y.useEffect(()=>{const l=e.current;if(l)return jt(l,o)},[e,o]),y.useEffect(()=>{const l=e.current,m=l?.querySelector("[data-markdown-content]")??l;if(m)for(const[p,f]of Object.entries(s))m.style.setProperty(p,f)},[e,s]),y.useEffect(()=>{const l=e.current,m=l?.querySelector("[data-markdown-content]")??l;m&&(o.deferCodeLineNumberSync||Dt(m))},[e,o.deferCodeLineNumberSync])},Ve=(e,t)=>Z("w-full min-w-0",e==="tool"?"markdown-content markdown-tool":e==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",t&&"markdown-streaming"),fn=({content:e,part:t,messageId:r,isAnimated:n=!0,skipFadeIn:s=!1,className:o,isStreaming:a=!1,disableStreamAnimation:i=!1,variant:c="assistant",onShowPopup:d,enableFileReferences:l=!0})=>{ee("ui.markdown_renderer.render"),a&&ee("ui.markdown_renderer.render.streaming"),Ye("ui.markdown_renderer.content_len",e.length);const m=ze(),{editor:p}=ke(),f=y.useRef(null),h=Ee()??"",v=ve(C=>C.openContextPreview),A=y.useCallback(C=>{h&&v(h,C)},[h,v]),w=a&&!i;$e({containerRef:f,onShowPopup:d,enableFullscreen:qe,enablePanZoom:P.showPanZoomControls}),De({containerRef:f,effectiveDirectory:h,editor:p,preferRuntimeEditor:!1,enabled:l&&!a}),Re({containerRef:f});const b=y.useMemo(()=>Ce(m),[m]),g=He(m,w,h?A:void 0,P),u=`markdown-${t?.id?`part-${t.id}`:`message-${r}`}`;Be({containerRef:f,text:e,streaming:w,cacheKey:u,syntaxVars:b,ctx:g});const E=_.jsx("div",{className:Z("break-words w-full min-w-0",o),ref:f,children:_.jsx("div",{className:Ve(c,w),"data-markdown-content":!0})});return n?_.jsx(ct,{skipAnimation:s,children:E},u):E},Yn=y.memo(fn,(e,t)=>e.content===t.content&&e.isStreaming===t.isStreaming&&e.disableStreamAnimation===t.disableStreamAnimation&&e.variant===t.variant&&e.isAnimated===t.isAnimated&&e.skipFadeIn===t.skipFadeIn&&e.className===t.className&&e.messageId===t.messageId&&e.onShowPopup===t.onShowPopup&&e.enableFileReferences===t.enableFileReferences&&e.part?.id===t.part?.id),hn=({content:e,className:t,variant:r="assistant",disableLinkSafety:n,stripFrontmatter:s=!1,onShowPopup:o,mermaidControls:a=P,allowMermaidWheelEvents:i=!1,enableFileReferences:c=!0})=>{const{editor:d}=ke(),l=ze(),m=y.useRef(null),p=Ee()??"",f=y.useMemo(()=>s?pn(e):e,[e,s]);$e({containerRef:m,onShowPopup:o,enableFullscreen:qe,enablePanZoom:a.showPanZoomControls,allowMermaidWheelEvents:i}),De({containerRef:m,effectiveDirectory:p,editor:d,preferRuntimeEditor:!1,enabled:c}),Re({containerRef:m,enabled:!n});const h=y.useMemo(()=>Ce(l),[l]),v=He(l,!1,void 0,a);return Be({containerRef:m,text:f,streaming:!1,cacheKey:`simple:${r}`,syntaxVars:h,ctx:v}),_.jsx("div",{className:Z("break-words w-full min-w-0",t),ref:m,children:_.jsx("div",{className:Ve(r),"data-markdown-content":!0})})},Jn=y.memo(hn,(e,t)=>{const r=e.mermaidControls??P,n=t.mermaidControls??P;return e.content===t.content&&e.variant===t.variant&&e.className===t.className&&e.disableLinkSafety===t.disableLinkSafety&&e.stripFrontmatter===t.stripFrontmatter&&e.onShowPopup===t.onShowPopup&&r.download===n.download&&r.copy===n.copy&&r.showPanZoomControls===n.showPanZoomControls&&e.allowMermaidWheelEvents===t.allowMermaidWheelEvents&&e.enableFileReferences===t.enableFileReferences});export{Yn as MarkdownRenderer,Jn as SimpleMarkdownRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dL as j,dk as k,dp as y}from"./useAppFontEffects
|
|
1
|
+
import{dL as j,dk as k,dp as y}from"./useAppFontEffects--lKKtKVo.js";import{f as D,B as C}from"./web-components-v9fuidaX.js";import{M as P,G as L,u as O,W as A,a as M,b as R,n as F,t as H}from"./Virtualizer-wpC51ZBQ.js";import{j as d}from"./vendor-boot-DyL2td56.js";import{V as _,F as N}from"./VirtualizedFileDiff-CUWx7JVZ.js";import{a as w}from"./vendor-react-DASdDPIk.js";function T({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function V(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:z(n,e.startContentIndex)}}function z(e,t){let n=e.unifiedLineStart;for(let l=0;l<t;l++){const s=e.hunkContent[l];n+=s.type==="context"?s.lines:s.deletions+s.additions}return n}function U(e){const t=j(e);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=t[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function $({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:l,renderHeaderFilenameSuffix:s,renderHeaderMetadata:x,renderAnnotation:f,renderGutterUtility:u,renderMergeConflictUtility:o,lineAnnotations:a,getHoveredLine:g,getInstance:m}){const p=n?.(e),c=l?.(e),i=s?.(e),v=x?.(e);return d.jsxs(d.Fragment,{children:[p!=null?d.jsx("div",{slot:k,children:p}):d.jsxs(d.Fragment,{children:[c!=null&&d.jsx("div",{slot:"header-prefix",children:c}),i!=null&&d.jsx("div",{slot:"header-filename-suffix",children:i}),v!=null&&d.jsx("div",{slot:"header-metadata",children:v})]}),f!=null&&a?.map((r,h)=>d.jsx("div",{slot:D(r),children:f(r)},h)),t!=null&&o!=null&&m!=null&&t.map(r=>{if(r==null)return;const h=b(r,e);return d.jsx("div",{slot:h,style:P,children:o(r,m)},h)}),u!=null&&d.jsx("div",{slot:"gutter-utility-slot",style:L,children:u(g)})]})}function b(e,t){const n=V(e,t);return n!=null?T({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}const S=typeof window>"u"?w.useEffect:w.useLayoutEffect;function G({fileDiff:e,options:t,lineAnnotations:n,selectedLines:l,prerenderedHTML:s,metrics:x,hasGutterRenderUtility:f,hasCustomHeader:u,disableWorkerPool:o,contentEditable:a}){const g=O(),m=l!==void 0,p=w.useContext(A),c=M(),i=w.useRef(null),v=R(r=>{if(r!=null){if(i.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");g!=null?i.current=new _(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),g,x,o?void 0:p,!0):i.current=new N(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),o?void 0:p,!0),i.current.hydrate({fileDiff:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:s})}else{if(i.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");i.current.cleanUp(),i.current=null}});return S(()=>{const{current:r}=i;if(r==null)return;const h=E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),I=!C(r.options,h);r.setOptions(h),r.render({forceRender:I,fileDiff:e,lineAnnotations:n}),l!==void 0&&r.setSelectedLines(l)}),S(()=>{if(a&&i.current!=null){if(c===void 0)throw new Error("FileDiff: Editor is not attached");return c.edit(i.current)}},[a,c]),{ref:v,getHoveredLine:w.useCallback(()=>i.current?.getHoveredLine(),[])}}function E({options:e,controlledSelection:t,contentEditable:n,hasCustomHeader:l,hasEditor:s,hasGutterRenderUtility:x}){const f=n&&s,u=t||x||l;if(!u&&!f)return e;let o={...e};return u&&(o={...o,controlledSelection:t,renderCustomHeader:l?F:e?.renderCustomHeader,renderGutterUtility:x?F:e?.renderGutterUtility}),f&&(o={...o,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,expandUnchanged:!0,lineHoverHighlight:"disabled"}),o}function Y({patch:e,options:t,metrics:n,lineAnnotations:l,selectedLines:s,className:x,style:f,prerenderedHTML:u,renderAnnotation:o,renderCustomHeader:a,renderHeaderPrefix:g,renderHeaderFilenameSuffix:m,renderHeaderMetadata:p,renderGutterUtility:c,disableWorkerPool:i=!1,contentEditable:v=!1}){const r=q(e),{ref:h,getHoveredLine:I}=G({fileDiff:r,options:t,metrics:n,lineAnnotations:l,selectedLines:s,prerenderedHTML:u,hasGutterRenderUtility:c!=null,hasCustomHeader:a!=null,disableWorkerPool:i,contentEditable:v});return d.jsx(y,{ref:h,className:x,style:f,children:H($({fileDiff:r,renderCustomHeader:a,renderHeaderPrefix:g,renderHeaderFilenameSuffix:m,renderHeaderMetadata:p,renderAnnotation:o,lineAnnotations:l,renderGutterUtility:c,getHoveredLine:I}),u)})}function q(e){return w.useMemo(()=>U(e),[e])}export{Y as P};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aJ as Re,j as M}from"./vendor-boot-DyL2td56.js";import{a as d,R as ae}from"./vendor-react-DASdDPIk.js";import{B as Se}from"./web-components-CH3-XV-n.js";import{f as ce}from"./computeVirtualFileMetrics-CeMpF2xC.js";import{V as Ee,F as ke}from"./VirtualizedFileDiff-D6KbvKc6.js";import{aX as xe,aj as Te}from"./useAppFontEffects-CG3_yteE.js";import{aY as Oe}from"./runtimeEndpointReset-CzJfovWI.js";import{ensurePierreThemeRegistered as ue,getResolvedShikiTheme as he}from"./appThemeRegistry-gegrE2dq.js";import{Z as de,o as fe}from"./index-6IO1AcJI.js";const J=new Set;let ne=null;function E(n){J.add(n),ne??=requestAnimationFrame(ve)}function ve(n){const e=new Set(J);J.clear();for(const t of e)try{t(n)}catch(r){console.error(r)}J.size>0?ne=requestAnimationFrame(ve):ne=null}function ge({scrollTop:n,scrollHeight:e,height:t,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:s}){const h=t+s*2,f=r?t+i*2:h;if(e=Math.max(e,f),h>=e||r){const g=Math.max(n-i,0),y=Math.min(n+f,e);return{top:g,bottom:Math.max(y,g)}}let c=n+t/2-h/2,m=c+h;return c<0&&(c=0),m>e&&(m=e),c=Math.floor(Math.max(c,0)),{top:c,bottom:Math.ceil(Math.max(Math.min(m,e),c))}}function ze(n,e){return n==null||e==null?n===e:n.top===e.top&&n.bottom===e.bottom}const be=1e3,De=be*4,Ce=[0,1e-6,.99999,1],Ie={overscrollSize:be,intersectionObserverMargin:De,resizeDebugging:!1};let Z=0,Me=-1;var He=class x{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++Me}`;config;type="simple";intersectionObserver;scrollTop=0;height=0;scrollHeight=0;windowSpecs={top:0,bottom:0};root;contentContainer;resizeObserver;observers=new Map;visibleInstances=new Map;visibleInstancesDirty=!1;instancesChanged=new Set;scrollDirty=!0;heightDirty=!0;scrollHeightDirty=!0;renderedObservers=0;connectQueue=new Map;constructor(e){this.config={...Ie,...e}}setup(e,t){if(this.root==null){this.root=e,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:Ce,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),e instanceof Document?this.setupWindow():this.setupElement(t),window.__INSTANCE=this,window.__TOGGLE=()=>{x.__STOP?(x.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:x.__lastScrollPosition}),E(this.computeRenderRangeAndEmit)):(x.__lastScrollPosition=this.getScrollTop(),x.__STOP=!0)};for(const[r,i]of this.connectQueue.entries())this.connect(r,i);this.connectQueue.clear(),this.markDOMDirty(),E(this.computeRenderRangeAndEmit)}}instanceChanged(e,t){this.instancesChanged.add(e),t&&this.markDOMDirty(),E(this.computeRenderRangeAndEmit)}getWindowSpecs(){return this.windowSpecs.top===0&&this.windowSpecs.bottom===0&&(this.windowSpecs=ge({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize})),this.windowSpecs}isInstanceVisible(e,t){const r=this.getScrollTop(),i=this.getHeight(),s=this.config.intersectionObserverMargin,h=r-s,f=r+i+s;return!(e<h-t||e>f)}handleContainerResize=e=>{if(this.root==null)return;let t=!1;for(const r of e){const i=r.borderBoxSize[0].blockSize;this.root instanceof Document?i!==this.scrollHeight&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: content size change",this.__id,{sizeChange:i-Z,newSize:i}),Z=i)):r.target===this.root?i!==this.height&&(this.heightDirty=!0,t=!0):r.target===this.contentContainer&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: scroller size change",this.__id,{sizeChange:i-Z,newSize:i}),Z=i))}t&&E(this.computeRenderRangeAndEmit)};setupWindow(){if(this.root==null||!(this.root instanceof Document))throw new Error("Virtualizer.setupWindow: Invalid setup method");window.addEventListener("scroll",this.handleWindowScroll,{passive:!0}),window.addEventListener("resize",this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(e){if(this.root==null||this.root instanceof Document)throw new Error("Virtualizer.setupElement: Invalid setup method");this.root.addEventListener("scroll",this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),e??=this.root.firstElementChild??void 0,e instanceof HTMLElement&&(this.contentContainer=e,this.resizeObserver?.observe(e))}cleanUp(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener("scroll",this.handleElementScroll),window.removeEventListener("scroll",this.handleWindowScroll),window.removeEventListener("resize",this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0}getOffsetInScrollContainer(e){return this.getScrollTop()+U(e,this.getScrollContainerElement())}connect(e,t){if(this.observers.has(e))throw new Error("Virtualizer.connect: instance is already connected...");return this.intersectionObserver==null?this.connectQueue.set(e,t):(this.intersectionObserver.observe(e),this.observers.set(e,t),this.instancesChanged.add(t),this.markDOMDirty(),E(this.computeRenderRangeAndEmit)),()=>this.disconnect(e)}disconnect(e){const t=this.observers.get(e);this.connectQueue.delete(e),t!=null&&(this.intersectionObserver?.unobserve(e),this.observers.delete(e),this.visibleInstances.delete(e)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),E(this.computeRenderRangeAndEmit))}handleWindowResize=()=>{x.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,E(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{x.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{x.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(x.__STOP)return;const e=this.heightDirty||this.scrollHeightDirty;if(!this.scrollDirty&&!this.scrollHeightDirty&&!this.heightDirty&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.instancesChanged.size===0)return;let t=this.instancesChanged.size>0;if(this.instancesChanged.size===0){const s=ge({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!e&&ze(this.windowSpecs,s)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty)return;this.windowSpecs=s}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;const r=this.getScrollAnchor(this.height),i=new Set;for(const s of e?this.observers.values():this.visibleInstances.values())s.onRender(e)&&i.add(s);for(const s of this.instancesChanged)i.has(s)||s.onRender(e)&&i.add(s);this.scrollFix(r);for(const s of i)s.reconcileHeights();t||=this.instancesChanged.size>0,t&&this.markDOMDirty(),(t||e)&&E(this.computeRenderRangeAndEmit),i.clear(),this.instancesChanged.clear()};scrollFix(e){if(e==null)return;const t=this.getScrollContainerElement(),{lineIndex:r,lineOffset:i,fileElement:s,fileOffset:h,fileTypeOffset:f}=e;if(r!=null&&i!=null){const m=s.shadowRoot?.querySelector(`[data-line][data-line-index="${r}"]`);if(m instanceof HTMLElement){const g=U(m,t);if(g!==i){const y=g-i;this.applyScrollFix(y)}return}}const c=U(s,t);if(f==="top")c!==h&&this.applyScrollFix(c-h);else{const m=c+s.getBoundingClientRect().height;m!==h&&this.applyScrollFix(m-h)}}applyScrollFix(e){this.root==null||this.root instanceof Document?window.scrollTo({top:window.scrollY+e,behavior:"instant"}):this.root.scrollTo({top:this.root.scrollTop+e,behavior:"instant"}),this.markDOMDirty()}getScrollAnchor(e){const t=this.getScrollContainerElement();let r;for(const[i]of this.visibleInstances.entries()){const s=U(i,t),h=s+i.offsetHeight;let f,c;h<=0?(f=h,c="bottom"):(f=s,c="top");let m,g;if(h>0&&s<e)for(const w of i.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(w instanceof HTMLElement))continue;const q=w.dataset.lineIndex;if(q==null)continue;const z=U(w,t);if(!(z<0)){m=q,g=z;break}}if(r?.lineOffset!=null&&g==null)continue;let y=!1;(r==null||g!=null&&(r.lineOffset==null||g<r.lineOffset)||g==null&&r.lineOffset==null&&(f>=0&&(r.fileOffset<0||f<r.fileOffset)||f<0&&r.fileOffset<0&&f>r.fileOffset))&&(y=!0),y&&(r={fileElement:i,fileTypeOffset:c,fileOffset:f,lineIndex:m,lineOffset:g})}return r}handleIntersectionChange=e=>{this.scrollDirty=!0;for(const{target:t,isIntersecting:r}of e){if(!(t instanceof HTMLElement))throw new Error("Virtualizer.handleIntersectionChange: target not an HTMLElement");const i=this.observers.get(t);i!=null&&(r&&!this.visibleInstances.has(t)?(i.setVisibility(!0),this.visibleInstances.set(t,i),this.visibleInstancesDirty=!0):!r&&this.visibleInstances.has(t)&&(i.setVisibility(!1),this.visibleInstances.delete(t),this.visibleInstancesDirty=!0))}this.visibleInstancesDirty&&E(this.computeRenderRangeAndEmit)};getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root==null?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return e=Math.max(0,Math.min(e,this.getScrollHeight()-this.getHeight())),this.scrollTop=e,e}getScrollHeight(){return this.scrollHeightDirty?(this.scrollHeightDirty=!1,this.scrollHeight=this.root==null?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight,this.scrollHeight):this.scrollHeight}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root==null?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height,this.height):this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return this.root==null||this.root instanceof Document?void 0:this.root}};function U(n,e){const t=n.getBoundingClientRect(),r=e?.getBoundingClientRect().top??0;return t.top-r}const pe=5e5,Pe=`
|
|
1
|
+
import{aJ as Re,j as M}from"./vendor-boot-DyL2td56.js";import{a as d,R as ae}from"./vendor-react-DASdDPIk.js";import{B as Se}from"./web-components-v9fuidaX.js";import{f as ce}from"./computeVirtualFileMetrics-3PpRLd5B.js";import{V as Ee,F as ke}from"./VirtualizedFileDiff-CUWx7JVZ.js";import{aX as xe,aj as Te}from"./useAppFontEffects--lKKtKVo.js";import{a$ as Oe}from"./runtimeEndpointReset-CmI6dBKM.js";import{ensurePierreThemeRegistered as ue,getResolvedShikiTheme as he}from"./appThemeRegistry-gegrE2dq.js";import{_ as de,o as fe}from"./index-Dd2OcIUY.js";const J=new Set;let ne=null;function E(n){J.add(n),ne??=requestAnimationFrame(ve)}function ve(n){const e=new Set(J);J.clear();for(const t of e)try{t(n)}catch(r){console.error(r)}J.size>0?ne=requestAnimationFrame(ve):ne=null}function ge({scrollTop:n,scrollHeight:e,height:t,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:s}){const h=t+s*2,f=r?t+i*2:h;if(e=Math.max(e,f),h>=e||r){const g=Math.max(n-i,0),y=Math.min(n+f,e);return{top:g,bottom:Math.max(y,g)}}let c=n+t/2-h/2,m=c+h;return c<0&&(c=0),m>e&&(m=e),c=Math.floor(Math.max(c,0)),{top:c,bottom:Math.ceil(Math.max(Math.min(m,e),c))}}function ze(n,e){return n==null||e==null?n===e:n.top===e.top&&n.bottom===e.bottom}const be=1e3,De=be*4,Ce=[0,1e-6,.99999,1],Ie={overscrollSize:be,intersectionObserverMargin:De,resizeDebugging:!1};let X=0,Me=-1;var He=class x{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++Me}`;config;type="simple";intersectionObserver;scrollTop=0;height=0;scrollHeight=0;windowSpecs={top:0,bottom:0};root;contentContainer;resizeObserver;observers=new Map;visibleInstances=new Map;visibleInstancesDirty=!1;instancesChanged=new Set;scrollDirty=!0;heightDirty=!0;scrollHeightDirty=!0;renderedObservers=0;connectQueue=new Map;constructor(e){this.config={...Ie,...e}}setup(e,t){if(this.root==null){this.root=e,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:Ce,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),e instanceof Document?this.setupWindow():this.setupElement(t),window.__INSTANCE=this,window.__TOGGLE=()=>{x.__STOP?(x.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:x.__lastScrollPosition}),E(this.computeRenderRangeAndEmit)):(x.__lastScrollPosition=this.getScrollTop(),x.__STOP=!0)};for(const[r,i]of this.connectQueue.entries())this.connect(r,i);this.connectQueue.clear(),this.markDOMDirty(),E(this.computeRenderRangeAndEmit)}}instanceChanged(e,t){this.instancesChanged.add(e),t&&this.markDOMDirty(),E(this.computeRenderRangeAndEmit)}getWindowSpecs(){return this.windowSpecs.top===0&&this.windowSpecs.bottom===0&&(this.windowSpecs=ge({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize})),this.windowSpecs}isInstanceVisible(e,t){const r=this.getScrollTop(),i=this.getHeight(),s=this.config.intersectionObserverMargin,h=r-s,f=r+i+s;return!(e<h-t||e>f)}handleContainerResize=e=>{if(this.root==null)return;let t=!1;for(const r of e){const i=r.borderBoxSize[0].blockSize;this.root instanceof Document?i!==this.scrollHeight&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: content size change",this.__id,{sizeChange:i-X,newSize:i}),X=i)):r.target===this.root?i!==this.height&&(this.heightDirty=!0,t=!0):r.target===this.contentContainer&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: scroller size change",this.__id,{sizeChange:i-X,newSize:i}),X=i))}t&&E(this.computeRenderRangeAndEmit)};setupWindow(){if(this.root==null||!(this.root instanceof Document))throw new Error("Virtualizer.setupWindow: Invalid setup method");window.addEventListener("scroll",this.handleWindowScroll,{passive:!0}),window.addEventListener("resize",this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(e){if(this.root==null||this.root instanceof Document)throw new Error("Virtualizer.setupElement: Invalid setup method");this.root.addEventListener("scroll",this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),e??=this.root.firstElementChild??void 0,e instanceof HTMLElement&&(this.contentContainer=e,this.resizeObserver?.observe(e))}cleanUp(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener("scroll",this.handleElementScroll),window.removeEventListener("scroll",this.handleWindowScroll),window.removeEventListener("resize",this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0}getOffsetInScrollContainer(e){return this.getScrollTop()+U(e,this.getScrollContainerElement())}connect(e,t){if(this.observers.has(e))throw new Error("Virtualizer.connect: instance is already connected...");return this.intersectionObserver==null?this.connectQueue.set(e,t):(this.intersectionObserver.observe(e),this.observers.set(e,t),this.instancesChanged.add(t),this.markDOMDirty(),E(this.computeRenderRangeAndEmit)),()=>this.disconnect(e)}disconnect(e){const t=this.observers.get(e);this.connectQueue.delete(e),t!=null&&(this.intersectionObserver?.unobserve(e),this.observers.delete(e),this.visibleInstances.delete(e)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),E(this.computeRenderRangeAndEmit))}handleWindowResize=()=>{x.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,E(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{x.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{x.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(x.__STOP)return;const e=this.heightDirty||this.scrollHeightDirty;if(!this.scrollDirty&&!this.scrollHeightDirty&&!this.heightDirty&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.instancesChanged.size===0)return;let t=this.instancesChanged.size>0;if(this.instancesChanged.size===0){const s=ge({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!e&&ze(this.windowSpecs,s)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty)return;this.windowSpecs=s}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;const r=this.getScrollAnchor(this.height),i=new Set;for(const s of e?this.observers.values():this.visibleInstances.values())s.onRender(e)&&i.add(s);for(const s of this.instancesChanged)i.has(s)||s.onRender(e)&&i.add(s);this.scrollFix(r);for(const s of i)s.reconcileHeights();t||=this.instancesChanged.size>0,t&&this.markDOMDirty(),(t||e)&&E(this.computeRenderRangeAndEmit),i.clear(),this.instancesChanged.clear()};scrollFix(e){if(e==null)return;const t=this.getScrollContainerElement(),{lineIndex:r,lineOffset:i,fileElement:s,fileOffset:h,fileTypeOffset:f}=e;if(r!=null&&i!=null){const m=s.shadowRoot?.querySelector(`[data-line][data-line-index="${r}"]`);if(m instanceof HTMLElement){const g=U(m,t);if(g!==i){const y=g-i;this.applyScrollFix(y)}return}}const c=U(s,t);if(f==="top")c!==h&&this.applyScrollFix(c-h);else{const m=c+s.getBoundingClientRect().height;m!==h&&this.applyScrollFix(m-h)}}applyScrollFix(e){this.root==null||this.root instanceof Document?window.scrollTo({top:window.scrollY+e,behavior:"instant"}):this.root.scrollTo({top:this.root.scrollTop+e,behavior:"instant"}),this.markDOMDirty()}getScrollAnchor(e){const t=this.getScrollContainerElement();let r;for(const[i]of this.visibleInstances.entries()){const s=U(i,t),h=s+i.offsetHeight;let f,c;h<=0?(f=h,c="bottom"):(f=s,c="top");let m,g;if(h>0&&s<e)for(const w of i.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(w instanceof HTMLElement))continue;const q=w.dataset.lineIndex;if(q==null)continue;const z=U(w,t);if(!(z<0)){m=q,g=z;break}}if(r?.lineOffset!=null&&g==null)continue;let y=!1;(r==null||g!=null&&(r.lineOffset==null||g<r.lineOffset)||g==null&&r.lineOffset==null&&(f>=0&&(r.fileOffset<0||f<r.fileOffset)||f<0&&r.fileOffset<0&&f>r.fileOffset))&&(y=!0),y&&(r={fileElement:i,fileTypeOffset:c,fileOffset:f,lineIndex:m,lineOffset:g})}return r}handleIntersectionChange=e=>{this.scrollDirty=!0;for(const{target:t,isIntersecting:r}of e){if(!(t instanceof HTMLElement))throw new Error("Virtualizer.handleIntersectionChange: target not an HTMLElement");const i=this.observers.get(t);i!=null&&(r&&!this.visibleInstances.has(t)?(i.setVisibility(!0),this.visibleInstances.set(t,i),this.visibleInstancesDirty=!0):!r&&this.visibleInstances.has(t)&&(i.setVisibility(!1),this.visibleInstances.delete(t),this.visibleInstancesDirty=!0))}this.visibleInstancesDirty&&E(this.computeRenderRangeAndEmit)};getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root==null?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return e=Math.max(0,Math.min(e,this.getScrollHeight()-this.getHeight())),this.scrollTop=e,e}getScrollHeight(){return this.scrollHeightDirty?(this.scrollHeightDirty=!1,this.scrollHeight=this.root==null?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight,this.scrollHeight):this.scrollHeight}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root==null?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height,this.height):this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return this.root==null||this.root instanceof Document?void 0:this.root}};function U(n,e){const t=n.getBoundingClientRect(),r=e?.getBoundingClientRect().top??0;return t.top-r}const pe=5e5,Pe=`
|
|
2
2
|
:host {
|
|
3
3
|
font-family: var(--font-mono);
|
|
4
4
|
font-size: var(--text-code);
|
|
@@ -131,4 +131,4 @@ import{aJ as Re,j as M}from"./vendor-boot-DyL2td56.js";import{a as d,R as ae}fro
|
|
|
131
131
|
text-decoration: underline;
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
`;function _e(n){let e=2166136261;for(let t=0;t<n.length;t+=1)e^=n.charCodeAt(t),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return e.toString(16)}function me(n){const e=n.length>400?`${n.slice(0,200)}${n.slice(-200)}`:n;return`${n.length}:${_e(e)}`}const Fe=n=>n==="auto"||n==="scroll"||n==="overlay",Ae=n=>{let e=n?.parentElement??null;for(;e;){const t=window.getComputedStyle(e);if(Fe(t.overflowY))return e;e=e.parentElement}return null},Ve=(n,e)=>{if(!n||!e||typeof window>"u")return()=>{};const t=Ae(n);if(!t)return()=>{};const r=e.getBoundingClientRect().height;if(!r)return()=>{};const i=n.getBoundingClientRect().top-t.getBoundingClientRect().top,s=e.style.minHeight;e.style.minHeight=`${Math.ceil(r)}px`;let h=!1;return()=>{if(h)return;h=!0,e.style.minHeight=s;const c=n.getBoundingClientRect().top-t.getBoundingClientRect().top-i;c&&(t.scrollTop+=c)}},$e=(n,e)=>{if(typeof window>"u")return()=>{};let t=null,r=null,i=!1;const s=()=>{i||(r?.disconnect(),r=null,t=window.requestAnimationFrame(()=>{t=window.requestAnimationFrame(()=>{i||e()})}))},h=()=>n.querySelector("diffs-container")?.shadowRoot??void 0,f=(c=h())=>!!c?.querySelector("[data-line]");return f()?s():typeof MutationObserver<"u"?(r=new MutationObserver(()=>{const c=h();if(c){if(f(c)){s();return}r?.disconnect(),r=new MutationObserver(()=>{f(c)&&s()}),r.observe(c,{childList:!0,subtree:!0})}}),r.observe(n,{childList:!0,subtree:!0})):t=window.requestAnimationFrame(s),()=>{i=!0,r?.disconnect(),t!==null&&window.cancelAnimationFrame(t)}},
|
|
134
|
+
`;function _e(n){let e=2166136261;for(let t=0;t<n.length;t+=1)e^=n.charCodeAt(t),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return e.toString(16)}function me(n){const e=n.length>400?`${n.slice(0,200)}${n.slice(-200)}`:n;return`${n.length}:${_e(e)}`}const Fe=n=>n==="auto"||n==="scroll"||n==="overlay",Ae=n=>{let e=n?.parentElement??null;for(;e;){const t=window.getComputedStyle(e);if(Fe(t.overflowY))return e;e=e.parentElement}return null},Ve=(n,e)=>{if(!n||!e||typeof window>"u")return()=>{};const t=Ae(n);if(!t)return()=>{};const r=e.getBoundingClientRect().height;if(!r)return()=>{};const i=n.getBoundingClientRect().top-t.getBoundingClientRect().top,s=e.style.minHeight;e.style.minHeight=`${Math.ceil(r)}px`;let h=!1;return()=>{if(h)return;h=!0,e.style.minHeight=s;const c=n.getBoundingClientRect().top-t.getBoundingClientRect().top-i;c&&(t.scrollTop+=c)}},$e=(n,e)=>{if(typeof window>"u")return()=>{};let t=null,r=null,i=!1;const s=()=>{i||(r?.disconnect(),r=null,t=window.requestAnimationFrame(()=>{t=window.requestAnimationFrame(()=>{i||e()})}))},h=()=>n.querySelector("diffs-container")?.shadowRoot??void 0,f=(c=h())=>!!c?.querySelector("[data-line]");return f()?s():typeof MutationObserver<"u"?(r=new MutationObserver(()=>{const c=h();if(c){if(f(c)){s();return}r?.disconnect(),r=new MutationObserver(()=>{f(c)&&s()}),r.observe(c,{childList:!0,subtree:!0})}}),r.observe(n,{childList:!0,subtree:!0})):t=window.requestAnimationFrame(s),()=>{i=!0,r?.disconnect(),t!==null&&window.cancelAnimationFrame(t)}},Z=new WeakMap,qe={lineHeight:24,hunkSeparatorHeight:24,spacing:0};function We(n){const e=n.closest("[data-diff-virtual-root]");if(e instanceof HTMLElement){const t=e.querySelector("[data-diff-virtual-content]");return{key:e,root:e,content:t instanceof HTMLElement?t:void 0}}return{key:document,root:document,content:void 0}}function Be(n){if(typeof document>"u")return null;const e=We(n);let t=Z.get(e.key);if(!t){const i=new He;i.setup(e.root,e.content),t={virtualizer:i,refs:0},Z.set(e.key,t)}t.refs+=1;let r=!1;return{virtualizer:t.virtualizer,root:e.root,release:()=>{if(r)return;r=!0;const i=Z.get(e.key);i&&(i.refs-=1,!(i.refs>0)&&(i.virtualizer.cleanUp(),Z.delete(e.key)))}}}const Ne=(n,e,t)=>{if(typeof window>"u")return()=>{};const r=[],i=()=>{try{n.rerender()}catch{}const s=e?.root;s instanceof HTMLElement?s.dispatchEvent(new Event("scroll",{bubbles:!1})):document.dispatchEvent(new Event("scroll",{bubbles:!1})),window.dispatchEvent(new Event("resize")),t()};return r.push(window.requestAnimationFrame(i)),r.push(window.requestAnimationFrame(()=>{r.push(window.requestAnimationFrame(i))})),()=>{for(const s of r)window.cancelAnimationFrame(s)}},tt=({original:n,modified:e,fileDiff:t,language:r,fileName:i,renderSideBySide:s,wrapLines:h,layout:f="fill",enableGutterUtility:c=!1,enableLineSelection:m=!1,onGutterUtilityClick:g,onLineSelectionEnd:y,lineAnnotations:w,renderAnnotation:q})=>{const z=xe(),D=z?.currentTheme.metadata.variant==="dark",_=z?.availableThemes.find(o=>o.metadata.id===z.lightThemeId)??de(!1),F=z?.availableThemes.find(o=>o.metadata.id===z.darkThemeId)??de(!0);ue(_),ue(F);const W=`${_.metadata.id}:${F.metadata.id}:${D?"dark":"light"}`,B=d.useMemo(()=>{if(t){const o=t.deletionLines.reduce((a,u)=>a+u.length,0),l=t.additionLines.reduce((a,u)=>a+u.length,0);return Math.max(o,l)>pe}return Math.max(n.length,e.length)>pe},[t,e.length,n.length]),Q=d.useRef(null),N=d.useRef(null),A=d.useRef(null),j=d.useRef(null),ee=d.useRef(null),te=d.useRef(null),re=d.useRef(void 0),K=d.useRef(void 0),G=d.useRef(void 0),Y=d.useRef(void 0),[,se]=ae.useReducer(o=>o+1,0),V=Oe(B?"unified":s?"split":"unified"),C=d.useRef(new Map),ie=d.useRef(q);ie.current=q;const oe=o=>`${o.side}:${o.lineNumber}`,le=d.useCallback(o=>{if(typeof document>"u")return;const l=`${o.side}:${o.lineNumber}`;let a=C.current.get(l);if(!a){const u=document.createElement("div");u.setAttribute("data-pichamber-line-annotation",l),a={root:Re.createRoot(u),element:u},C.current.set(l,a)}return a.root.render(ie.current?.(o)??null),a.element},[]);d.useEffect(()=>{if(!w){for(const[,a]of C.current)a.root.unmount();C.current.clear();return}const o=new Set(w.map(oe));for(const[a,u]of C.current)o.has(a)||(u.root.unmount(),C.current.delete(a));const l=ie.current;if(l)for(const a of w){const u=C.current.get(oe(a));u&&u.root.render(l(a))}},[w]),d.useEffect(()=>{const o=C.current;return()=>{for(const l of o.values())l.root.unmount();o.clear()}},[]);const T=d.useMemo(()=>he(_),[_]),O=d.useMemo(()=>he(F),[F]);ae.useLayoutEffect(()=>{const o=Q.current;if(!o)return;const l=o.querySelector("diffs-container");if(!l)return;const a=D?O:T,u=(ye,we)=>ye.colors?.[we],R=u(T,"terminal.ansiGreen"),v=u(T,"terminal.ansiRed"),b=u(T,"terminal.ansiBlue"),P=u(O,"terminal.ansiGreen"),k=u(O,"terminal.ansiRed"),I=u(O,"terminal.ansiBlue");l.style.setProperty("--shiki-light",T.fg),l.style.setProperty("--shiki-light-bg",T.bg),R&&l.style.setProperty("--shiki-light-addition-color",R),v&&l.style.setProperty("--shiki-light-deletion-color",v),b&&l.style.setProperty("--shiki-light-modified-color",b),l.style.setProperty("--shiki-dark",O.fg),l.style.setProperty("--shiki-dark-bg",O.bg),P&&l.style.setProperty("--shiki-dark-addition-color",P),k&&l.style.setProperty("--shiki-dark-deletion-color",k),I&&l.style.setProperty("--shiki-dark-modified-color",I),l.style.setProperty("--diffs-bg",a.bg),l.style.setProperty("--diffs-fg",a.fg);const S=D?P:R,L=D?k:v,$=D?I:b;S&&l.style.setProperty("--diffs-addition-color-override",S),L&&l.style.setProperty("--diffs-deletion-color-override",L),$&&l.style.setProperty("--diffs-modified-color-override",$);const p=l.shadowRoot?.querySelector("pre");p&&(p.style.setProperty("--shiki-light",T.fg),p.style.setProperty("--shiki-light-bg",T.bg),R&&p.style.setProperty("--shiki-light-addition-color",R),v&&p.style.setProperty("--shiki-light-deletion-color",v),b&&p.style.setProperty("--shiki-light-modified-color",b),p.style.setProperty("--shiki-dark",O.fg),p.style.setProperty("--shiki-dark-bg",O.bg),P&&p.style.setProperty("--shiki-dark-addition-color",P),k&&p.style.setProperty("--shiki-dark-deletion-color",k),I&&p.style.setProperty("--shiki-dark-modified-color",I),p.style.setProperty("--diffs-bg",a.bg),p.style.setProperty("--diffs-fg",a.fg),S&&p.style.setProperty("--diffs-addition-color-override",S),L&&p.style.setProperty("--diffs-deletion-color-override",L),$&&p.style.setProperty("--diffs-modified-color-override",$))},[O,W,D,T]);const H=d.useMemo(()=>({theme:{dark:F.metadata.id,light:_.metadata.id},themeType:D?"dark":"light",diffStyle:s?"split":"unified",diffIndicators:"none",hunkSeparators:"line-info-basic",lineDiffType:"none",maxLineDiffLength:B?0:1e3,maxLineLengthForHighlighting:B?1:1e3,tokenizeMaxLineLength:B?1:1e3,collapsedContextThreshold:0,expansionLineCount:20,overflow:h?"wrap":"scroll",disableFileHeader:!0,enableLineSelection:m,enableGutterUtility:c,enableHoverUtility:!1,...g?{onGutterUtilityClick:g}:{},...y?{onLineSelectionEnd:y}:{},renderAnnotation:le,unsafeCSS:Le}),[le,F.metadata.id,c,m,D,B,_.metadata.id,g,y,s,h]);return d.useEffect(()=>{const o=N.current;return()=>{A.current?.cleanUp(),A.current=null,j.current?.release(),j.current=null,ee.current=null,te.current=null,re.current=void 0,K.current=void 0,G.current=void 0,Y.current=void 0,o&&(o.innerHTML="")}},[]),d.useEffect(()=>{if(typeof window>"u")return;const o=N.current,l=Q.current;if(!o||!V)return;const a=Ve(l,o);let u=j.current;u||(u=Be(o),j.current=u),j.current=u;const R=u?.virtualizer??null,v=t?void 0:{name:i||"",contents:n,lang:r,cacheKey:`old:${W}:${i}:${me(n)}`},b=t?void 0:{name:i||"",contents:e,lang:r,cacheKey:`new:${W}:${i}:${me(e)}`},P=t?K.current!==t:K.current!==void 0||!v||!b||!G.current||!Y.current||!ce(G.current,v)||!ce(Y.current,b),k=A.current,I=!!(k&&(ee.current!==R||te.current!==V||R&&(re.current!==H.hunkSeparators||P)));I&&(k?.cleanUp(),A.current=null,o.innerHTML="");let S=A.current;const L=!I&&k?!Se(k.options,H):!1;if(S?S.setOptions(H):(S=u?new Ee(H,u.virtualizer,qe,V):new ke(H,V),A.current=S),ee.current=R,te.current=V,re.current=R?H.hunkSeparators:void 0,K.current=t,G.current=v,Y.current=b,t)S.render({fileDiff:t,forceRender:L,containerWrapper:o,...w?{lineAnnotations:w}:{}});else{if(!v||!b)return;S.render({oldFile:v,newFile:b,forceRender:L,containerWrapper:o,...w?{lineAnnotations:w}:{}})}const $=$e(o,()=>{a(),Ne(S,u,se)});return()=>{$(),a()}},[W,t,i,r,w,e,H,n,V]),d.useEffect(()=>{const o=N.current;if(!o)return;let l=null,a=null;const R=setTimeout(()=>{const v=o.querySelector("diffs-container");if(!(v instanceof HTMLElement))return;const b=v.shadowRoot;l=new MutationObserver(()=>{a&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{se(),a=null})}),l.observe(v,{childList:!0,subtree:!0}),b&&l.observe(b,{childList:!0,subtree:!0})},100);return()=>{clearTimeout(R),a&&cancelAnimationFrame(a),l?.disconnect()}},[W,i]),typeof window>"u"?null:f==="fill"?M.jsx("div",{className:fe("flex flex-col relative","size-full"),"data-diff-virtual-root":!0,children:M.jsx("div",{className:"flex-1 relative min-h-0",children:M.jsx(Te,{outerClassName:"pierre-diff-wrapper size-full",disableHorizontal:!1,fillContainer:!0,"data-diff-virtual-content":!0,children:M.jsx("div",{ref:Q,className:"size-full relative",children:M.jsx("div",{ref:N,className:"size-full"})})})})}):M.jsx("div",{className:fe("relative","w-full"),children:M.jsx("div",{ref:Q,className:"pierre-diff-wrapper w-full overflow-x-auto overflow-y-visible relative","data-no-drawer-swipe":"true",children:M.jsx("div",{ref:N,className:"w-full"})})})};export{tt as P};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/useAppFontEffects--lKKtKVo.js","assets/index-Dd2OcIUY.js","assets/vendor-zustand-CUi8eEds.js","assets/vendor-react-DASdDPIk.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-DvN8zlLT.css","assets/vendor-boot-DyL2td56.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/runtimeSurface-B1GRkkKC.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as Ne}from"./vendor-vite-runtime-DD1OZmLC.js";import{j as e,bR as Ye,bS as Qe,bT as Xe,bU as Ze,bV as et}from"./vendor-boot-DyL2td56.js";import{R as o}from"./vendor-react-DASdDPIk.js";import{u as le,a as Le,b as ht,c as ft,G as xt,d as pt,e as gt,f as bt,r as vt,g as tt,t as yt,h as ce,i as jt,j as wt,k as kt,l as Ct,m as Nt,n as St,o as Rt}from"./useGitHubRemoteSearch-zNgy2bSt.js";import{p as Ee,t as H,a5 as Lt,B as P,I as z,b3 as Et,ai as st,a8 as Me,ab as ze,ad as Ae,cu as Ft,cv as Pt,o as Se,af as we,ag as Tt,n as Mt}from"./useAppFontEffects--lKKtKVo.js";import{Q as O,_ as zt,$ as At,R as Dt,a0 as $t,a1 as Gt,a2 as Ht,a3 as qt,a4 as It,a5 as De,a6 as Ot,a7 as Bt,a8 as _t,a9 as Ut,aa as Vt,ab as Kt,ac as Jt,ad as Wt}from"./runtimeEndpointReset-CmI6dBKM.js";import{c as Yt,d as Qt,s as Xt,m as Zt,g as nt,e as es,f as ts,h as ge,l as ss,G as ns,i as te,j as as,k as ls,n as os,o as is,b as fe,u as rs,p as cs,q as ds,r as us,t as $e,w as ke,x as Ce,y as ms,z as Ge,A as He,B as qe,C as at,D as hs,E as Ie,F as fs,H as xs,I as ps,J as gs,K as bs,P as be,L as he,M as vs,a as ys,N as Oe,O as js,Q as ws}from"./GitHubDetailScaffold-q4YP8iyJ.js";import{o as xe,aR as ks,A as Cs,t as Ns,v as Ss}from"./index-Dd2OcIUY.js";import{S as ve,G as Rs}from"./GitHubListPrimitives-XkALat1v.js";import{P as Ls}from"./PierreDiffViewer-0X__nypk.js";import{c as Es,p as Fs}from"./vendor-zustand-CUi8eEds.js";import"./vendor-clsx-B-dksMZM.js";import"./runtimeSurface-B1GRkkKC.js";import"./SessionUnreadDot-CJFawQpo.js";/* empty css */import"./permissionStore-B9Hkrqny.js";import"./vendor-dompurify-r8glNMJW.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./web-components-v9fuidaX.js";import"./computeVirtualFileMetrics-3PpRLd5B.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-CUWx7JVZ.js";import"./renderDiffWithHighlighter-l8hZWWBO.js";import"./vendor-diff-C3JhlQdm.js";import"./appThemeRegistry-gegrE2dq.js";import"./registerCustomTheme-DmolaWWZ.js";const Fe=()=>{const t=Ee(),[s,n]=o.useState(null);return{send:o.useCallback(async l=>{const d=t.github;if(!d)return H.error("GitHub is not available in this runtime"),!1;n(l.key);try{const c=await d.agentContext(l.directory,l.repo,l.contextType,l.number,l.contextOptions),r=Yt({kind:l.kind,repo:l.repo,number:l.number,detail:l.detail}),x=Qt({kind:l.kind,repo:l.repo,number:l.number,contextText:c.text}),p=Lt.getState();p.setPendingInputText(r,"append");const k=p.pendingSyntheticParts??[];return p.setPendingSyntheticParts([...k,{text:x,synthetic:!0}]),H.success("Added to composer"),!0}catch(c){return H.error(c instanceof Error?c.message:"Failed to fetch GitHub context"),!1}finally{n(null)}},[t.github]),sendingKey:s}},Ps=800,Ts=3,Pe={added:{icon:"add-circle",letter:"A",tint:"text-[var(--status-success)]"},removed:{icon:"subtract",letter:"D",tint:"text-[var(--status-error)]"},modified:{icon:"pencil",letter:"M",tint:"text-[var(--status-warning)]"},renamed:{icon:"expand-up-down",letter:"R",tint:"text-[var(--status-info)]"},other:{icon:"file",letter:"•",tint:"text-muted-foreground"}},lt=t=>{switch((t??"").toLowerCase()){case"added":return"added";case"removed":return"removed";case"modified":return"modified";case"renamed":return"renamed";default:return"other"}},ot=t=>Pe[t].icon,Ms=t=>Pe[t].letter,Re=t=>Pe[t].tint,it=t=>{const s=t.lastIndexOf("/");return s<0?{dir:"",base:t}:{dir:t.slice(0,s),base:t.slice(s+1)}},rt=t=>{const s=typeof t.additions=="number"?t.additions:0,n=typeof t.deletions=="number"?t.deletions:0;return s!==0||n!==0?s+n:typeof t.changes=="number"?t.changes:0},ct=t=>rt(t)>Ps,zs=t=>{const s=new Map;for(const a of t){const l=a.filename.lastIndexOf("/"),d=l<0?"":a.filename.slice(0,l),c=s.get(d);c?c.push(a):s.set(d,[a])}const n=[...s.entries()].map(([a,l])=>({folder:a,files:[...l].sort((d,c)=>d.filename.localeCompare(c.filename,void 0,{sensitivity:"base"}))}));return n.sort((a,l)=>a.folder===""?1:l.folder===""?-1:a.folder.localeCompare(l.folder,void 0,{sensitivity:"base"})),n},As=t=>{let s=0,n=0;for(const a of t)s+=typeof a.additions=="number"?a.additions:0,n+=typeof a.deletions=="number"?a.deletions:0;return{additions:s,deletions:n}},Ds=t=>{const s={};return t.forEach((n,a)=>{s[n.filename]=a>=Ts||ct(n)}),s},$s=(t,s,n)=>{if(!s)return null;const a=t.split("/");if(a.length!==3||a.some(r=>r.length===0))return null;const[l,d,c]=a;return`https://${l}/${d}/${c}/blob/${s}/${n}`},Gs=({comment:t,onRemove:s})=>e.jsxs("div",{className:"rounded-md border border-dashed border-border p-2.5 typography-ui text-foreground",contentEditable:!1,onPointerDown:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(z,{name:"chat-1",className:"size-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{children:"Pending — sent when you submit the review"}),e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Discard this comment",title:"Discard this comment",onClick:s,className:"ml-auto size-6",children:e.jsx(z,{name:"delete-bin",className:"size-3.5"})})]}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap break-words",children:t.body})]}),Be=({thread:t,replyAllowed:s,replyDisabledReason:n,resolveAllowed:a,resolveDisabledReason:l,busy:d,onReply:c,onToggleResolved:r})=>{const[x,p]=o.useState(!t.resolved),[k,m]=o.useState(!1),[b,h]=o.useState(""),[A,F]=o.useState(!1),T=t.comments.length,j=async()=>{const g=b.trim();if(!(g.length===0||A||d)){F(!0);try{await c(g)&&(h(""),m(!1))}finally{F(!1)}}};return e.jsxs("div",{className:"rounded-md border border-border/60 bg-[var(--surface-elevated)] p-2.5 typography-ui text-foreground",contentEditable:!1,onPointerDown:g=>g.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(z,{name:t.resolved?"check":"chat-1",className:xe("size-3.5 shrink-0",t.resolved?"text-[var(--status-success)]":""),"aria-hidden":"true"}),e.jsxs("button",{type:"button",className:"hover:text-foreground","aria-expanded":x,onClick:()=>p(g=>!g),children:[t.resolved?"Resolved":"Open"," · ",T," ",T===1?"comment":"comments"]}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"ml-auto",disabled:!a||d,title:l??(t.resolved?"Reopen this conversation":"Resolve this conversation"),"aria-label":t.resolved?"Reopen conversation":"Resolve conversation",onClick:r,children:t.resolved?"Unresolve":"Resolve"})]}),x?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 flex flex-col gap-2",children:t.comments.map((g,i)=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"typography-micro text-muted-foreground",children:g.author?.login??"ghost"}),e.jsx(ns,{markdown:g.body,html:g.bodyHtml??null,fallbackUrl:g.url})]},g.id??`${t.id}-${i}`))}),s?k?e.jsxs("div",{className:"mt-2",children:[e.jsx("textarea",{autoFocus:!0,value:b,rows:2,placeholder:"Reply","aria-label":"Reply to this conversation",disabled:A||d,onChange:g=>h(g.target.value),onKeyDown:g=>{g.nativeEvent.isComposing||(g.key==="Escape"&&(g.preventDefault(),m(!1)),g.key==="Enter"&&(g.metaKey||g.ctrlKey)&&!g.shiftKey&&!g.altKey&&!g.repeat&&(g.preventDefault(),g.stopPropagation(),j()))},className:"min-h-12 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"mt-1.5 flex justify-end gap-1.5",children:[e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>m(!1),children:"Cancel"}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:A||d||b.trim().length===0,onClick:()=>{j()},children:A?"Replying…":"Reply"})]})]}):e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"mt-2",onClick:()=>m(!0),children:"Reply"}):n?e.jsxs("p",{className:"mt-2 typography-micro text-muted-foreground",title:n,children:["Reply unavailable — ",n.charAt(0).toLowerCase()+n.slice(1)]}):null]}):null]})},Hs=({path:t,line:s,sendingToAgent:n,onCancel:a,onAddToReview:l,onSendToAgent:d})=>{const[c,r]=o.useState(""),x=o.useRef(null),p=c.trim();o.useLayoutEffect(()=>{const m=window.requestAnimationFrame(()=>{x.current?.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(m)},[]);const k=()=>{p&&l(p)};return e.jsxs("div",{className:"rounded-md border border-border/60 bg-[var(--surface-elevated)] p-2.5",contentEditable:!1,onPointerDown:m=>m.stopPropagation(),children:[e.jsxs("p",{className:"truncate font-mono typography-micro text-muted-foreground",title:`${t}:${s}`,children:[t,":",s]}),e.jsx("textarea",{ref:x,value:c,rows:3,placeholder:"Add a comment…","aria-label":`Comment on ${t} line ${s}`,onChange:m=>r(m.target.value),onFocus:m=>{const b=m.currentTarget.value.length;m.currentTarget.setSelectionRange(b,b)},onKeyDown:m=>{m.nativeEvent.isComposing||(m.key==="Escape"&&(m.preventDefault(),a()),m.key==="Enter"&&(m.metaKey||m.ctrlKey)&&!m.shiftKey&&!m.altKey&&!m.repeat&&(m.preventDefault(),m.stopPropagation(),k()))},className:"mt-1.5 min-h-16 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"mr-auto typography-micro text-muted-foreground",children:"Ctrl/Cmd+Enter to add"}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:a,children:"Cancel"}),e.jsx(P,{type:"button",variant:"outline",size:"xs",disabled:!p||n,title:"Send this line to the agent",onClick:()=>d(p),children:n?"Sending…":"Send to agent"}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:!p,onClick:k,children:"Add to review"})]})]})},qs=({file:t,collapsed:s,onToggleCollapse:n,viewed:a,onToggleViewed:l,blobUrl:d,threads:c,directory:r,repo:x,number:p,github:k,access:m,onThreadsChanged:b})=>{const h=O(w=>w.threadAction),A=le(w=>w.removeComment),F=le(w=>w.addComment),T=Le(x,p),[j,g]=o.useState(null),[i,C]=o.useState(!1),{send:L,sendingKey:f}=Fe(),{original:N,modified:E}=o.useMemo(()=>Xt(t.patch),[t.patch]),M=o.useMemo(()=>Zt(t.patch),[t.patch]),B=`pr-${p}-file-${t.filename}`,V=nt(m),S=es(m),$=ts(m),K=o.useCallback(w=>{if(!w||!V.allowed)return;const q=(w.endSide??w.side??"additions")==="deletions"?"deletions":"additions",ie=q==="deletions"?M.syntheticToOld.get(w.end):M.syntheticToNew.get(w.end);if(ie==null){H.error("That line is outside the rendered hunks");return}g({synthLine:w.end,side:q,realLine:ie,realSide:q==="deletions"?"LEFT":"RIGHT"})},[V.allowed,M]),_=lt(t.status),{dir:X,base:R}=it(t.filename),I=ct(t),[y,de]=o.useState(!1),Q=I&&!y&&!a&&t.patch!=null,ee=c.filter(w=>!w.resolved).length,Z=o.useMemo(()=>T.filter(w=>w.path===t.filename),[T,t.filename]),{annotations:se,orphans:ne}=o.useMemo(()=>{const w=new Map,G=[],q=(D,U)=>{const W=`${D}:${U}`;let J=w.get(W);return J||(J={side:D,synthLine:U,threads:[],pendings:[]},w.set(W,J)),J};for(const D of c){const U=D.line??D.originalLine??null;if(U==null){G.push(D);continue}let W,J;if(D.diffSide==="LEFT"?(J="deletions",W=M.oldToSynthetic.get(U)):D.diffSide==="RIGHT"?(J="additions",W=M.newToSynthetic.get(U)):(W=M.newToSynthetic.get(U),J="additions",W==null&&(W=M.oldToSynthetic.get(U),J="deletions")),W==null){G.push(D);continue}q(J,W).threads.push(D)}for(const D of Z){if(D.line==null)continue;const U=D.side==="LEFT"?"deletions":"additions",W=U==="deletions"?M.oldToSynthetic.get(D.line):M.newToSynthetic.get(D.line);W!=null&&q(U,W).pendings.push(D)}return j&&q(j.side,j.synthLine),{annotations:[...w.values()].sort((D,U)=>D.synthLine-U.synthLine).map(D=>({side:D.side,lineNumber:D.synthLine,metadata:{threads:D.threads,pendings:D.pendings,draft:j&&j.side===D.side&&j.synthLine===D.synthLine?{realLine:j.realLine,realSide:j.realSide}:null}})),orphans:G}},[c,Z,j,M]),oe=o.useCallback(async(w,G)=>{const q=w.comments[w.comments.length-1]?.id??null;if(typeof q!="number")return H.error("Cannot reply to this thread yet"),!1;if(i)return!1;C(!0);try{return(await h(r,x,p,w.id,{action:"reply",body:G,commentId:q},k)).ok?(H.success("Reply posted"),b(),!0):(H.error("Failed to post reply"),!1)}finally{C(!1)}},[r,x,p,k,h,i,b]),ae=o.useCallback(w=>{i||(C(!0),h(r,x,p,w.id,w.resolved?{action:"unresolve"}:{action:"resolve"},k).then(G=>{G.ok?(H.success(w.resolved?"Thread reopened":"Thread resolved"),b()):H.error("Failed to update thread")}).finally(()=>C(!1)))},[r,x,p,k,h,i,b]),ue=o.useCallback(w=>e.jsxs("div",{className:"flex flex-col gap-1.5 px-3 py-2",contentEditable:!1,onPointerDown:G=>G.stopPropagation(),children:[w.metadata.threads.map(G=>e.jsx(Be,{thread:G,replyAllowed:S.allowed,replyDisabledReason:S.reason,resolveAllowed:$.allowed,resolveDisabledReason:$.reason,busy:i,onReply:q=>oe(G,q),onToggleResolved:()=>ae(G)},G.id)),w.metadata.pendings.map(G=>e.jsx(Gs,{comment:G,onRemove:()=>A(x,p,G.id)},G.id)),w.metadata.draft?e.jsx(Hs,{path:t.filename,line:w.metadata.draft.realLine,sendingToAgent:f===`${B}-draft-agent`,onCancel:()=>g(null),onAddToReview:G=>{const q=w.metadata.draft;q&&(F(x,p,{path:t.filename,body:G,line:q.realLine,side:q.realSide}),g(null),H.success("Added to review"))},onSendToAgent:G=>{const q=w.metadata.draft;q&&L({key:`${B}-draft-agent`,kind:"lines",directory:r,repo:x,number:p,contextType:"pr",contextOptions:{includeDiff:!0},detail:`${t.filename} line ${q.realLine} ("${G.trim()}")`})}}):null]}),[S.allowed,S.reason,$.allowed,$.reason,i,oe,ae,A,F,x,p,t.filename,B,f,r,L]);return e.jsxs("article",{className:"overflow-hidden rounded-md border border-border/60",children:[e.jsxs("div",{className:"sticky top-8 z-[5] flex items-center gap-1.5 bg-[var(--surface-muted)] px-2 py-1.5",children:[e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:()=>n(t.filename),"aria-label":s?`Expand ${t.filename}`:`Collapse ${t.filename}`,title:s?"Expand":"Collapse",className:"size-6",children:e.jsx(z,{name:s?"arrow-right-s":"arrow-down-s",className:"size-4"})}),e.jsx(z,{name:ot(_),className:xe("size-3.5 shrink-0",Re(_)),"aria-hidden":"true"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono typography-micro",title:t.filename,children:[X?e.jsxs("span",{className:"text-muted-foreground",children:[X,"/"]}):null,e.jsx("span",{className:"text-foreground",children:R})]}),_!=="other"?e.jsx("span",{className:xe("shrink-0 rounded px-1 font-mono typography-micro",Re(_)),title:t.status??void 0,children:Ms(_)}):null,e.jsx(ge,{additions:t.additions,deletions:t.deletions,className:"typography-micro"}),c.length>0||Z.length>0?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-muted-foreground",title:`${c.length} ${c.length===1?"conversation":"conversations"}${Z.length>0?`, ${Z.length} pending`:""}`,children:[e.jsx(z,{name:"chat-1",className:"size-3.5","aria-hidden":"true"}),c.length>0?e.jsx("span",{className:"tabular-nums",children:ee>0?ee:c.length}):null,Z.length>0?e.jsxs("span",{className:"tabular-nums",children:["+",Z.length]}):null]}):null,e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",onClick:w=>w.stopPropagation(),children:[e.jsx(Et,{checked:a,onChange:w=>l(t.filename,w),ariaLabel:a?`Mark ${t.filename} as not viewed`:`Mark ${t.filename} as viewed`}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Viewed"})]}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{L({key:`${B}-agent`,kind:"file",directory:r,repo:x,number:p,contextType:"pr",contextOptions:{includeDiff:!0},detail:t.filename})},disabled:f===`${B}-agent`,"aria-label":`Send ${t.filename} to agent`,children:"Send to agent"})]}),s?null:e.jsxs("div",{className:"flex flex-col gap-2 p-2",children:[ne.length>0?e.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md bg-[var(--surface-muted)] px-2 py-2",children:[e.jsxs("p",{className:"typography-micro text-muted-foreground",children:["Other conversations (",ne.length,") — ",ne.length===1?"this line is":"these lines are"," no longer in the diff"]}),ne.map(w=>e.jsx(Be,{thread:w,replyAllowed:S.allowed,replyDisabledReason:S.reason,resolveAllowed:$.allowed,resolveDisabledReason:$.reason,busy:i,onReply:G=>oe(w,G),onToggleResolved:()=>ae(w)},w.id))]}):null,Q?e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-[var(--surface-muted)] px-3 py-3 typography-ui",children:[e.jsx(z,{name:"file",className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsxs("p",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:["Large diff — ",rt(t)," changed lines"]}),e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>de(!0),children:"Load diff"})]}):t.patch?e.jsx("div",{className:"min-h-24 overflow-hidden",children:e.jsx(Ls,{original:N,modified:E,language:ss(t.filename),fileName:t.filename,renderSideBySide:!1,layout:"inline",enableGutterUtility:V.allowed&&j===null,enableLineSelection:V.allowed&&j===null,onGutterUtilityClick:K,onLineSelectionEnd:K,lineAnnotations:se,renderAnnotation:w=>ue(w)})}):e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-[var(--surface-muted)] px-3 py-3 typography-ui",children:[e.jsx(z,{name:"file",className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("p",{className:"min-w-0 flex-1 text-muted-foreground",children:"Diff not available for this file."}),d?e.jsx(P,{type:"button",variant:"link",size:"sm",asChild:!0,children:e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",children:"Open on GitHub"})}):null]})]})]})},Is=o.memo(qs),Os=({directory:t,repo:s,number:n,github:a,pr:l,access:d,onCommented:c})=>{const r=O(i=>i.addComment),x=O(i=>i.performAction),p=le(i=>i.clearCommentDraft),{draft:k,onDraftChange:m,flushDraft:b}=ht(s,n),{busy:h,error:A,submit:F}=ft({postComment:i=>r(t,s,n,i,a),runFollowUp:i=>x(t,s,n,i,a),verbs:{close:"close",reopen:"reopen"},doneLabels:{close:"Closed with comment",reopen:"Reopened with comment"},afterPost:()=>{m(""),p(s,n),c()}}),T=nt(d),j=l.state==="open"?"close":l.state==="closed"?"reopen":null,g=j?te(j,l,d):null;return T.allowed?e.jsx(xt,{draft:k,onDraftChange:m,onDraftBlur:b,ariaLabel:"Leave a comment on this pull request",busy:h,error:A,disabledReason:T.reason,followUp:j?{id:j,label:j==="close"?"Close with comment":"Reopen with comment",busyLabel:j==="close"?"Closing…":"Reopening…",onRun:()=>{F(j,k)},allowed:g?.allowed===!0,reason:g?.reason}:null,onSubmitComment:()=>{F("comment",k)}}):null},Bs={comment:"Comment",approve:"Approve","request-changes":"Request changes"},_s=({repo:t,number:s,verdicts:n,summary:a,verdict:l,pendingCount:d,busy:c,textareaRef:r,onSubmit:x})=>{const p=le(h=>h.setSummary),k=le(h=>h.setVerdict),m=n.includes(l)?l:n[0]??"comment",b=ls({verdict:m,summary:a,pendingCount:d});return e.jsxs("div",{children:[e.jsx(zt,{ref:r,rows:3,value:a,placeholder:"Summarize your review (optional)","aria-label":"Review summary",disabled:c,onChange:h=>p(t,s,h.target.value),onKeyDown:h=>{h.nativeEvent.isComposing||h.key==="Enter"&&(h.metaKey||h.ctrlKey)&&!h.shiftKey&&!h.altKey&&!h.repeat&&(h.preventDefault(),h.stopPropagation(),b&&!c&&x())}}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[e.jsxs("label",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"sr-only",children:"Review verdict"}),e.jsx("select",{value:m,disabled:c,onChange:h=>k(t,s,h.target.value),"aria-label":"Review verdict",className:"h-7 max-w-40 truncate rounded-md border border-border bg-[var(--surface-elevated)] px-1.5 typography-micro text-foreground",children:n.map(h=>e.jsx("option",{value:h,children:Bs[h]},h))})]}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:c||!b,title:b?`Submit review${d>0?` with ${d} ${d===1?"line comment":"line comments"}`:""}`:"Add a summary or a line comment first",onClick:x,children:c?"Submitting…":"Submit review"})]})]})},dt=({directory:t,repo:s,number:n,github:a,access:l,size:d="sm",onReviewSubmitted:c})=>{const r=O(M=>M.submitReview),x=le(M=>M.removeComments),p=le(M=>M.clearSummary),k=le(M=>M.clearComments),m=Le(s,n),b=pt(s,n),h=gt(s,n),[A,F]=o.useState(!1),[T,j]=o.useState(!1),g=o.useRef(null),i=o.useMemo(()=>as(l),[l]),C=i.includes(h)?h:i[0]??"comment",L=m.length,f=L>0||b.trim().length>0;if(o.useEffect(()=>{if(!A)return;const M=window.requestAnimationFrame(()=>g.current?.focus({preventScroll:!0}));return()=>window.cancelAnimationFrame(M)},[A]),i.length===0)return null;const N=async()=>{if(T)return;const M=b,B=[...m];j(!0);try{const V=B.map($=>({path:$.path,body:$.body,...$.line!=null?{line:$.line}:{},...$.side?{side:$.side}:{}})),S=await r(t,s,n,{event:C,body:M.trim()?M:void 0,comments:V},a);if(!S.ok){H.error(S.error?.kind==="failed"?S.error.message:"Failed to submit review");return}x(s,n,B.map($=>$.id)),p(s,n,M),H.success(C==="approve"?"Pull request approved":C==="request-changes"?"Changes requested":"Review submitted"),F(!1),c?.()}finally{j(!1)}},E=L>0?`Review · ${L}`:"Review";return e.jsxs(Ye,{open:A,onOpenChange:F,children:[e.jsxs(Qe,{render:e.jsx(P,{type:"button",variant:L>0?"default":"outline",size:d,className:"shrink-0","aria-label":L>0?`Review pull request, ${L} ${L===1?"line comment":"line comments"} pending`:"Review pull request",title:f?"Finish your review":"Approve, request changes, or comment with a review"}),children:[e.jsx(z,{name:"file-check",className:"size-3.5","aria-hidden":"true"}),E]}),e.jsx(Xe,{children:e.jsx(Ze,{className:"z-50",side:"top",align:"end",sideOffset:8,collisionPadding:8,children:e.jsxs(et,{"aria-label":"Review pull request",className:"w-[min(24rem,calc(100vw-2rem))] rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3 shadow-lg",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 truncate typography-ui-label text-foreground",children:L>0?`Review · ${L} ${L===1?"line comment":"line comments"}`:"Review pull request"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[L>0?e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Discard pending line comments",title:"Discard pending line comments",disabled:T,onClick:()=>k(s,n),className:"size-6",children:e.jsx(z,{name:"delete-bin",className:"size-3.5"})}):null,e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Close review",onClick:()=>F(!1),className:"size-6",children:e.jsx(z,{name:"close",className:"size-3.5"})})]})]}),e.jsx(_s,{repo:s,number:n,verdicts:i,summary:b,verdict:C,pendingCount:L,busy:T,textareaRef:g,onSubmit:()=>{N()}})]})})})]})},ye=(t,s)=>`${t}#${s}`,_e=50,Us=Object.freeze([]),Ue=(t,s)=>{const n=Object.keys(t);if(n.length<=_e)return t;const a={};for(const l of n.slice(n.length-_e))a[l]=t[l];if(!(s in a)&&s in t){const l=Object.keys(a)[0];delete a[l],a[s]=t[s]}return a},pe=Es()(Fs((t,s)=>({entries:{},setViewed:(n,a,l,d)=>{const c=ye(n,a);(s().entries[c]?.viewed.includes(l)??!1)!==d&&t(p=>{const k=p.entries[c]??{viewed:[],headSha:null},m=d?[...k.viewed,l]:k.viewed.filter(b=>b!==l);return{entries:Ue({...p.entries,[c]:{...k,viewed:m}},c)}})},syncHeadSha:(n,a,l)=>{const d=ye(n,a),c=s().entries[d];c&&c.headSha===(l??null)||t(r=>({entries:Ue({...r.entries,[d]:{viewed:[],headSha:l??null}},d)}))},resetForRuntimeSwitch:()=>t({entries:{}})}),{name:"pichamber:github-viewed-files",version:1,storage:ks(),partialize:t=>({entries:t.entries})}));typeof window<"u"&&Cs(()=>{pe.getState().resetForRuntimeSwitch()});const Vs=(t,s)=>pe(n=>n.entries[ye(t,s)]?.viewed??Us),Ks=(t,s)=>pe(n=>n.entries[ye(t,s)]?.viewed.length??0),Ve=20,Js=[],Ws=[],Ke=t=>`pr-file-${encodeURIComponent(t)}`,ut=o.memo(({file:t,viewed:s,threadCount:n,pendingCount:a,showDir:l,onSelectFile:d})=>{const c=lt(t.status),{dir:r,base:x}=it(t.filename);return e.jsxs("button",{type:"button",onClick:()=>d(t.filename),title:t.filename,"aria-label":`Go to ${t.filename}`,className:"flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-left hover:bg-interactive-hover",children:[e.jsx(z,{name:ot(c),className:xe("size-3.5 shrink-0",Re(c)),"aria-hidden":"true"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono typography-micro",children:[l&&r?e.jsxs("span",{className:"text-muted-foreground",children:[r,"/"]}):null,e.jsx("span",{className:"text-foreground",children:x})]}),e.jsx(ge,{additions:t.additions,deletions:t.deletions,className:"typography-micro"}),n>0?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-0.5 typography-micro text-muted-foreground",title:`${n} ${n===1?"conversation":"conversations"}`,children:[e.jsx(z,{name:"chat-1",className:"size-3","aria-hidden":"true"}),e.jsx("span",{className:"tabular-nums",children:n})]}):null,a>0?e.jsxs("span",{className:"shrink-0 tabular-nums typography-micro text-muted-foreground",title:`${a} pending`,children:["+",a]}):null,s?e.jsx(z,{name:"check",className:"size-3.5 shrink-0 text-[var(--status-success)]","aria-label":"Viewed"}):null]})});ut.displayName="FileJumpRow";const mt=({files:t,viewedPaths:s,threadCounts:n,pendingCounts:a,onSelectFile:l})=>{const[d,c]=o.useState(""),r=o.useMemo(()=>zs(t),[t]),x=o.useMemo(()=>new Set(s),[s]),p=d.trim().toLowerCase(),k=o.useMemo(()=>p?r.map(m=>({...m,files:m.files.filter(b=>b.filename.toLowerCase().includes(p))})).filter(m=>m.files.length>0):r,[r,p]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-1",children:[e.jsx(st,{value:d,onChange:m=>c(m.target.value),placeholder:"Filter files","aria-label":"Filter files",className:"h-7 shrink-0 typography-micro"}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",role:"list","aria-label":"Changed files",children:k.length===0?e.jsx("p",{className:"px-1.5 py-2 typography-micro text-muted-foreground",children:t.length===0?"No changed files":"No files match"}):k.map(m=>e.jsxs("div",{role:"group","aria-label":m.folder||"Repository root",children:[r.length>1?e.jsx("p",{className:"truncate px-1.5 pt-1.5 pb-0.5 typography-micro text-muted-foreground",title:m.folder||"/",children:m.folder||"/"}):null,m.files.map(b=>e.jsx(ut,{file:b,viewed:x.has(b.filename),threadCount:n.get(b.filename)??0,pendingCount:a.get(b.filename)??0,showDir:r.length<=1,onSelectFile:l},b.filename))]},m.folder))})]})},Ys=t=>{const[s,n]=o.useState(!1),{onSelectFile:a}=t,l=o.useCallback(d=>{n(!1),a(d)},[a]);return e.jsxs(Ye,{open:s,onOpenChange:n,children:[e.jsxs(Qe,{render:e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0","aria-label":`Jump to file, ${t.files.length} ${t.files.length===1?"file":"files"}`,title:"Jump to file"}),children:[e.jsx(z,{name:"file",className:"size-3.5","aria-hidden":"true"}),"Files"]}),e.jsx(Xe,{children:e.jsx(Ze,{className:"z-50",side:"bottom",align:"start",sideOffset:4,collisionPadding:8,children:e.jsx(et,{"aria-label":"Jump to file",className:"flex max-h-[min(28rem,calc(100dvh-4rem))] w-[min(22rem,calc(100vw-2rem))] flex-col rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-1.5 shadow-lg",children:e.jsx(mt,{...t,onSelectFile:l})})})})]})},Qs=48,Xs=(t,s)=>{const[n,a]=o.useState(null);return o.useLayoutEffect(()=>{if(!s)return;const l=t.current?.closest("[data-diff-virtual-root]");if(!(l instanceof HTMLElement))return;const d=()=>{const r=Math.max(160,Math.floor(l.clientHeight-Qs));a(x=>x===r?x:r)};if(d(),typeof ResizeObserver>"u")return;const c=new ResizeObserver(d);return c.observe(l),()=>c.disconnect()},[t,s]),n},Zs=t=>{const{directory:s,repo:n,number:a,github:l,access:d,headSha:c=null}=t,r=t.files?.files??Js,x=Vs(n,a),p=Ks(n,a),k=Le(n,a);o.useEffect(()=>{pe.getState().syncHeadSha(n,a,c)},[n,a,c]);const m=o.useMemo(()=>Ds(r),[r]),b=o.useRef(m);b.current=m;const h=o.useRef(r);h.current=r;const[A,F]=o.useState({}),[T,j]=o.useState(Ve),g=o.useMemo(()=>As(r),[r]),i=o.useMemo(()=>{const R=new Map;for(const I of t.threads){if(!I.path)continue;const y=R.get(I.path)??[];y.push(I),R.set(I.path,y)}return R},[t.threads]),C=o.useMemo(()=>{const R=new Map;for(const[I,y]of i)R.set(I,y.length);return R},[i]),L=o.useMemo(()=>{const R=new Map;for(const I of k)R.set(I.path,(R.get(I.path)??0)+1);return R},[k]),f=o.useCallback(R=>{F(I=>({...I,[R]:!(I[R]??b.current[R]??!1)}))},[]),N=o.useCallback(()=>{F(Object.fromEntries(h.current.map(R=>[R.filename,!1])))},[]),E=o.useCallback(()=>{F(Object.fromEntries(h.current.map(R=>[R.filename,!0])))},[]),M=o.useCallback((R,I)=>{pe.getState().setViewed(n,a,R,I),F(y=>({...y,[R]:I}))},[n,a]),B=o.useCallback(R=>{F(y=>y[R]??b.current[R]??!1?{...y,[R]:!1}:y);const I=h.current.findIndex(y=>y.filename===R);I>=0&&j(y=>I<y?y:I+1),requestAnimationFrame(()=>{document.getElementById(Ke(R))?.scrollIntoView({block:"start"})})},[]),V=o.useMemo(()=>r.slice(0,T),[r,T]),S=o.useRef(null),$=Xs(S,V.length>0),K=o.useMemo(()=>new Set(x),[x]),_=r.length===1?"1 file":`${r.length} files`,X=r.length===0?"Nothing viewed yet":`${p}/${r.length} viewed`;return e.jsxs("section",{"aria-label":"Changed files",className:"@container flex flex-col gap-2","data-diff-virtual-content":!0,children:[e.jsx(ve,{error:t.filesError,onRetry:t.onRetryFiles,label:"Changed files"}),e.jsx(ve,{error:t.threadsError,onRetry:t.onRetryDetail,label:"Review threads"}),e.jsxs("div",{className:"sticky top-0 z-10 flex h-8 shrink-0 items-center gap-2 border-b border-border/60 bg-[var(--surface-background)] px-1 text-[12px]",children:[e.jsx("span",{className:"shrink-0 text-muted-foreground",children:_}),e.jsx(ge,{additions:g.additions,deletions:g.deletions}),e.jsxs("span",{className:"shrink-0 tabular-nums text-muted-foreground","aria-label":X,children:[p,"/",r.length," viewed"]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[e.jsx(dt,{directory:s,repo:n,number:a,github:l,access:d,size:"xs",onReviewSubmitted:t.onReviewSubmitted}),e.jsx("span",{className:"@4xl:hidden",children:e.jsx(Ys,{files:r,viewedPaths:x,threadCounts:C,pendingCounts:L,onSelectFile:B})}),e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:N,"aria-label":"Expand all files",title:"Expand all files",className:"size-7",children:e.jsx(z,{name:"expand-up-down",className:"size-3.5"})}),e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:E,"aria-label":"Collapse all files",title:"Collapse all files",className:"size-7",children:e.jsx(z,{name:"collapse-vertical",className:"size-3.5"})})]})]}),t.filesLoading&&V.length===0?e.jsx(Rs,{rows:5,label:"Loading changed files"}):null,!t.filesLoading&&V.length===0?e.jsx("p",{className:"px-1 py-4 typography-micro text-muted-foreground",children:"No changed files"}):null,V.length>0?e.jsxs("div",{className:"flex min-h-0 items-start gap-3",children:[e.jsx("aside",{ref:S,"aria-label":"Changed files",style:$!=null?{height:$}:void 0,className:"sticky top-10 hidden max-h-[calc(100dvh-10rem)] w-60 shrink-0 flex-col @4xl:flex",children:e.jsx(mt,{files:r,viewedPaths:x,threadCounts:C,pendingCounts:L,onSelectFile:B})}),e.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:V.map(R=>e.jsx("div",{id:Ke(R.filename),className:"scroll-mt-12",children:e.jsx(Is,{file:R,collapsed:A[R.filename]??m[R.filename]??!1,onToggleCollapse:f,viewed:K.has(R.filename),onToggleViewed:M,blobUrl:$s(n,c,R.filename),threads:i.get(R.filename)??Ws,directory:s,repo:n,number:a,github:l,access:d,onThreadsChanged:t.onRetryDetail})},R.filename))})]}):null,r.length>T?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>j(T+Ve),children:"Show more files"})}):null,t.filesHasMore?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:t.onLoadMoreFiles,children:"Load more files"})}):null]})},en=({directory:t,repo:s,number:n,github:a,checks:l,checksError:d,checksLoading:c,onRetryChecks:r,onOpenFilesAtLine:x})=>{const[p,k]=o.useState({}),[m,b]=o.useState({}),{send:h,sendingKey:A}=Fe(),F=os(l);return e.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-1 py-1",children:[e.jsx("p",{className:"min-w-0 flex-1 typography-micro text-muted-foreground","aria-live":"polite",children:F?F.text:c?"Loading checks…":"No checks reported for this pull request."}),F&&F.failed>0?e.jsxs(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{h({key:`pr-${n}-failed-checks`,kind:"checks",directory:t,repo:s,number:n,contextType:"checks"})},disabled:A===`pr-${n}-failed-checks`,"aria-label":"Send failed checks to agent",title:"Send failed checks to agent",children:[e.jsx(z,{name:"send-plane-2",className:"size-3.5"}),"Send failures to agent"]}):null,e.jsxs(P,{type:"button",variant:"ghost",size:"xs",onClick:r,"aria-label":"Refresh checks",title:"Refresh checks",children:[e.jsx(z,{name:"refresh",className:xe("size-3.5",c&&"animate-spin")}),"Refresh"]})]}),e.jsx(ve,{error:d,onRetry:r,label:"Checks"}),l?e.jsx(tn,{checks:l,directory:t,repo:s,number:n,github:a,expandedJobs:p,onToggleJob:T=>k(j=>({...j,[T]:!j[T]})),jobSteps:m,setJobSteps:b,sendingKey:A,send:h,onOpenFilesAtLine:x}):null]})},tn=({checks:t,directory:s,repo:n,number:a,github:l,expandedJobs:d,onToggleJob:c,jobSteps:r,setJobSteps:x,sendingKey:p,send:k,onOpenFilesAtLine:m})=>{const b=O(i=>i.rerunFailedChecks),[h,A]=o.useState({}),F=async i=>{const C=`run-${i.id??i.name}`;if(c(C),!(d[C]||r[C]||i.id==null)){x(L=>({...L,[C]:{steps:[],loading:!0}}));try{const f=(await l.checkJobs(s,n,i.runId??null,i.id)).jobs[0];x(E=>({...E,[C]:{steps:f?.steps??[],loading:!1}}));const N=await l.checkAnnotations(s,n,i.id).catch(()=>null);N&&A(E=>({...E,[i.id]:{loading:!1,items:N.annotations}}))}catch{x(L=>({...L,[C]:{steps:[],loading:!1}}))}}},T=async i=>{(await b(s,n,i,l)).ok?H.success("Re-run requested"):H.error("Re-run failed")},j=i=>{const C=`run-${i.id??i.name}`,L=d[C]??!1,f=r[C],N=is(i);return e.jsxs("div",{className:"rounded-md px-2 py-2 hover:bg-interactive-hover",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(fe,{state:i.conclusion??i.status}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui text-foreground",title:i.name,children:i.name}),i.conclusion?e.jsx("span",{className:"typography-micro text-muted-foreground",children:i.conclusion}):null,e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{F(i)},"aria-expanded":L,"aria-label":`${L?"Collapse":"Expand"} ${i.name}`,children:"Details"}),N&&i.runId!=null?e.jsx(P,{type:"button",variant:"outline",size:"xs",onClick:()=>{T(i.runId)},children:"Re-run"}):null,N?e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{k({key:`${C}-agent`,kind:"check",directory:s,repo:n,number:a,contextType:"checks",detail:i.name})},disabled:p===`${C}-agent`,"aria-label":`Send ${i.name} to agent`,children:"Send to agent"}):null]}),L?e.jsxs("div",{className:"mt-1.5 flex flex-col gap-1 border-t border-border/60 pt-1.5",children:[f?.loading?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Loading steps…"}):null,(f?.steps??[]).map((E,M)=>e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(fe,{state:E.conclusion??E.status}),e.jsx("span",{className:"truncate",children:E.name}),E.conclusion?e.jsxs("span",{children:["· ",E.conclusion]}):null]},`${E.name}-${M}`)),i.id!=null&&h[i.id]?.items?.length?e.jsx("div",{className:"flex flex-col gap-1",children:h[i.id]?.items.map((E,M)=>e.jsxs("div",{className:"typography-micro text-muted-foreground",children:[E.path&&E.startLine&&m?e.jsxs("button",{type:"button",className:"font-mono underline",onClick:()=>m(E.path,E.startLine),children:[E.path,":",E.startLine]}):e.jsxs("span",{className:"font-mono",children:[E.path,E.startLine?`:${E.startLine}`:""]})," ",E.title?e.jsxs("span",{className:"text-foreground",children:[E.title," — "]}):null,E.message]},M))}):null]}):null]},C)},g=(i,C)=>e.jsxs("div",{className:"flex items-center gap-1.5 rounded-md px-2 py-2 hover:bg-interactive-hover",children:[e.jsx(fe,{state:i.state}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui text-foreground",title:i.context,children:i.context}),i.description?e.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:i.description}):null]},`${i.context}-${C}`);return e.jsxs("div",{className:"flex flex-col gap-1",children:[t.sectionErrors?.runs||t.sectionErrors?.statuses?e.jsx("div",{className:"rounded-md border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-2 py-1 typography-micro text-foreground",role:"alert",children:"Some check sources failed to load; counts below are partial, not empty."}):null,t.runs.length>0?e.jsx("div",{className:"flex flex-col","aria-label":"Check runs",children:t.runs.map(j)}):null,t.statuses.length>0?e.jsx("div",{className:"flex flex-col","aria-label":"Commit statuses",children:t.statuses.map(g)}):null,t.runs.length===0&&t.statuses.length===0?e.jsx("p",{className:"typography-ui text-muted-foreground",children:"No checks reported for this pull request."}):null]})},Je=({pr:t})=>e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(at,{login:t.author?.login,avatarUrl:t.author?.avatarUrl,size:"xs"}),t.author?.login??"ghost"]}),t.updatedAt?` · updated ${bs(t.updatedAt)}`:"",t.draft?" · Draft":""]}),We=({pr:t,filesCount:s})=>e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"shrink-0 truncate",title:t.base,children:t.base}),e.jsx("span",{className:"shrink-0","aria-label":"receives changes from",children:"←"}),e.jsx("code",{className:"min-w-0 flex-1 truncate",title:t.head,children:t.head}),typeof s=="number"?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 tabular-nums",children:[e.jsx(z,{name:"file-code",className:"size-3 shrink-0","aria-hidden":"true"}),s," ",s===1?"file":"files"]}):null,e.jsx(ge,{additions:t.additions,deletions:t.deletions})]}),sn=({repo:t,pr:s,access:n,acting:a,mergeMethod:l,onMergeMethodChange:d,onRun:c,checkingOut:r,onCheckout:x,onCopyLink:p,askSending:k,onAskAgent:m})=>{const b=O(N=>N.setMergeMethod),h=s.state==="open",A=be.filter(N=>te(N.id,s,n).allowed),F=A.some(N=>N.id===l)?l:A[0]?.id??l,T=te(F,s,n),j=te("ready",s,n),g=te("draft",s,n),i=te("close",s,n),C=te("reopen",s,n),L=be.find(N=>N.id===F)??be[0],f=A.length===0||a;return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pt-1 pb-2","aria-label":"Pull request actions",children:[h&&!s.draft?e.jsxs("span",{role:"group","aria-label":"Merge pull request",className:"inline-flex shrink-0 items-center gap-1",children:[e.jsx(ce,{copy:he(F,s.base,s.head),busy:a,disabled:!T.allowed,disabledReason:T.reason??`Merge via ${L.label}`,label:F==="merge"?"Merge pull request":L.label,icon:e.jsx(z,{name:"git-merge",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c(F)}),e.jsxs(Me,{modal:!1,children:[e.jsx(ze,{asChild:!0,children:e.jsx(P,{type:"button",variant:"default",size:"xs",className:"shrink-0 px-1.5",title:"Merge options","aria-label":"Merge options",disabled:f,children:e.jsx(z,{name:"arrow-down-s",className:"size-3.5"})})}),e.jsx(Ae,{align:"start",className:"w-72",children:e.jsx(Ft,{value:F,onValueChange:N=>{const E=N;d(E),b(t,E)},children:be.map(N=>{const E=te(N.id,s,n);return e.jsx(Pt,{value:N.id,disabled:!E.allowed,title:E.reason??N.description,children:e.jsxs("span",{className:"flex min-w-0 flex-col",children:[e.jsx("span",{className:"truncate",children:N.label}),e.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:N.description})]})},N.id)})})})]})]}):null,h&&s.draft?e.jsx(ce,{copy:he("ready",s.base,s.head),busy:a,disabled:!j.allowed,disabledReason:j.reason??"Ready for review",label:"Ready for review",icon:e.jsx(z,{name:"git-pull-request",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("ready")}):null,h&&!s.draft?e.jsx(ce,{copy:he("draft",s.base,s.head),busy:a,variant:"outline",disabled:!g.allowed,disabledReason:g.reason??"Convert to draft",label:"Convert to draft",icon:e.jsx(z,{name:"pencil",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("draft")}):null,h?e.jsx(ce,{copy:he("close",s.base,s.head),busy:a,destructive:!0,variant:"outline",disabled:!i.allowed,disabledReason:i.reason??"Close pull request",label:"Close",icon:e.jsx(z,{name:"close",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("close")}):e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>c("reopen"),disabled:!C.allowed||a,title:C.reason??"Reopen pull request","aria-label":"Reopen pull request",children:[e.jsx(z,{name:"history",className:"size-3.5","aria-hidden":"true"}),"Reopen"]}),e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>x("worktree"),disabled:r,title:"Check out in a new worktree","aria-label":"Check out in a new worktree",children:[e.jsx(z,{name:"git-branch",className:"size-3.5","aria-hidden":"true"}),r?"Checking out…":"Check out"]}),e.jsx(ce,{copy:{title:"Check out this branch here?",detail:"This switches your current checkout to the PR branch. Uncommitted work may be disrupted.",confirm:"Check out here",progress:"Checking out…"},busy:r,variant:"outline",label:"Check out here",icon:e.jsx(z,{name:"git-branch",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>x("current")}),e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:m,disabled:k,title:"Send pull request context to the agent composer","aria-label":"Ask agent about this pull request",children:[e.jsx(z,{name:"send-plane-2",className:"size-3.5","aria-hidden":"true"}),k?"Asking…":"Ask agent"]}),e.jsxs(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{Se(s.url)},title:"Review on GitHub","aria-label":"Review on GitHub",children:[e.jsx(z,{name:"external-link",className:"size-3.5","aria-hidden":"true"}),"Review on GitHub"]}),e.jsxs(Me,{modal:!1,children:[e.jsx(ze,{asChild:!0,children:e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 px-1.5","aria-label":"More pull request actions",title:"More pull request actions",children:e.jsx(z,{name:"more-2",className:"size-4"})})}),e.jsxs(Ae,{align:"end",className:"w-60",children:[e.jsxs(we,{onClick:()=>{Se(s.url)},children:[e.jsx(z,{name:"external-link",className:"size-3.5"}),"Open on GitHub"]}),e.jsxs(we,{onClick:p,children:[e.jsx(z,{name:"file-copy",className:"size-3.5"}),"Copy link"]}),e.jsx(Tt,{}),e.jsxs(we,{onClick:()=>x("worktree"),disabled:r,children:[e.jsx(z,{name:"git-branch",className:"size-3.5"}),"Check out in new worktree"]})]})]})]})},nn=({pr:t,access:s,acting:n,onRun:a})=>{const l=vs(t);if(!l)return null;const d=te("update-branch",t,s),c=l.tone==="error"?"border-[var(--status-error-border)] bg-[var(--status-error-background)] text-foreground":"border-[var(--status-warning-border)] bg-[var(--status-warning-background)] text-foreground",r=l.tone==="error"?"text-[var(--status-error)]":"text-[var(--status-warning)]";return e.jsxs("div",{className:`mx-3 mb-2 flex flex-wrap items-center gap-x-2 gap-y-1.5 rounded-md border px-2.5 py-2 ${c}`,role:"status",children:[e.jsx(z,{name:l.icon,className:`size-4 shrink-0 ${r}`,"aria-hidden":"true"}),e.jsxs("p",{className:"min-w-0 flex-1 basis-48",children:[e.jsxs("span",{className:"typography-ui-label font-medium",children:[l.title," ",e.jsx("code",{className:"font-mono",children:t.base})]}),e.jsx("span",{className:"block typography-micro text-muted-foreground",children:l.detail})]}),l.canUpdate?e.jsx(ce,{copy:he("update-branch",t.base,t.head),busy:n,variant:"outline",disabled:!d.allowed,disabledReason:d.reason??"Update branch",label:"Update branch",icon:e.jsx(z,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>a("update-branch")}):e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{Se(t.url)},title:"Resolve conflicts on GitHub","aria-label":"Resolve conflicts on GitHub",children:[e.jsx(z,{name:"external-link",className:"size-3.5","aria-hidden":"true"}),"Resolve on GitHub"]})]})},an=t=>{const{directory:s,repo:n,number:a,github:l,detail:d}=t,c=O(u=>u.performAction),r=O(u=>u.updateTitleBody),x=O(u=>u.checkout),[p,k]=o.useState("summary"),[m,b]=o.useState(!1),[h,A]=o.useState(()=>At(n)??"merge"),[F,T]=o.useState(!1),[j,g]=o.useState(""),[i,C]=o.useState(!1),[L,f]=o.useState(""),[N,E]=o.useState("newest"),[M,B]=o.useState(1),[V,S]=o.useState(!1),[$,K]=o.useState(null),_=bt(n,a),{send:X,sendingKey:R}=Fe(),I=rs(s,n),y=d?.pr??null,de=d?.sectionErrors??null,Q=o.useMemo(()=>({capabilities:d?.capabilities??null,isAuthor:cs(y?.author?.login,d?.viewerLogin),permissionFallback:d?.viewerPermission?.fallback===!0}),[d?.capabilities,d?.viewerLogin,d?.viewerPermission?.fallback,y?.author?.login]),ee=ds(y,Q);o.useEffect(()=>{k("summary"),T(!1),C(!1),B(1),K(null)},[n,a]);const Z=o.useCallback(async u=>{b(!0);try{const Y=await c(s,n,a,u,l);if(!Y.ok){H.error(Y.error?.kind==="failed"?Y.error.message:"Action failed");return}u==="close"?H.success("Pull request closed"):u==="reopen"?H.success("Pull request reopened"):u==="update-branch"?H.success("Branch update requested"):u==="ready"?H.success("Marked as ready for review"):u==="draft"?H.success("Converted to draft"):H.success("Pull request merged")}finally{b(!1)}},[s,n,a,l,c]),se=o.useCallback(()=>{X({key:`pr-${a}-ask`,kind:"pr",directory:s,repo:n,number:a,contextType:"pr"})},[X,s,n,a]),ne=o.useCallback(async()=>{if(!j.trim()){H.error("Enter a title");return}const u=await r(s,n,a,{title:j.trim()},l);u.ok?(H.success("Title updated"),T(!1)):H.error(u.error?.kind==="failed"?u.error.message:"Failed to update title")},[j,s,n,a,l,r]),oe=o.useCallback(async()=>{const u=await r(s,n,a,{body:L},l);u.ok?(H.success("Description updated"),C(!1)):H.error(u.error?.kind==="failed"?u.error.message:"Failed to update description")},[L,s,n,a,l,r]),ae=Ee().git,ue=o.useCallback(async u=>{if(u==="current"){const Y=await Ne(()=>import("./useAppFontEffects--lKKtKVo.js").then(re=>re.dV),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(re=>re.useGitStore.getState().directories.get(s)?.status??null).catch(()=>null);if(Y&&!Y.isClean){H.error("Working tree has uncommitted changes. Commit or stash first, or use New worktree.");return}}S(!0);try{const Y=await x(s,n,a,u,l);Y.ok?(await vt(s,ae),K({path:Y.path??null,branch:Y.branch??""}),H.success(u==="worktree"?"Worktree created":"Branch checked out")):H.error(Y.error?.kind==="failed"?Y.error.message:"Checkout failed")}finally{S(!1)}},[s,n,a,l,ae,x]),w=o.useCallback(()=>{$?.path&&Ne(async()=>{const{useSessionUIStore:u}=await import("./useAppFontEffects--lKKtKVo.js").then(Y=>Y.dS);return{useSessionUIStore:u}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(({useSessionUIStore:u})=>{u.getState().openNewSessionDraft({directoryOverride:$.path}),Ns.getState().setActiveMainTab("chat")})},[$]),G=us(y?.url),q=o.useMemo(()=>{const u=[...t.comments];return u.sort((Y,je)=>{const re=Y.createdAt?Date.parse(Y.createdAt):0,Te=je.createdAt?Date.parse(je.createdAt):0;return N==="newest"?Te-re:re-Te}),u},[t.comments,N]),D=q.slice(0,M*20),U=D.filter(u=>!$e(u.author?.login)),W=D.filter(u=>$e(u.author?.login));if(t.detailError&&!d)return e.jsx(ke,{header:e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:I,number:a,openLabel:`Open pull request #${a} on GitHub`,title:`Pull request #${a}`}),tabs:[],activeTab:"",onTabChange:()=>{},children:e.jsx(tt,{info:yt(t.detailError),onRetry:t.onRetryDetail})});if(!y){const u=t.seed&&t.seed.number===a?t.seed:null;return e.jsx(ke,{header:e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:I,number:a,url:u?.url??null,numberTintClass:u?He("pr",u.state,u.draft):void 0,statePill:u?e.jsx(Ge,{kind:"pr",state:u.state,draft:u.draft}):void 0,openLabel:`Open pull request #${a} on GitHub`,title:u?.title??null,meta:u?e.jsx(Je,{pr:u}):void 0,branches:u?e.jsx(We,{pr:u,filesCount:u.changedFiles??null}):void 0}),tabs:[],activeTab:"",onTabChange:()=>{},children:e.jsx(ms,{label:"Loading pull request"})})}const J=t.checks?.summary??null,me=t.files?.files.length??y.changedFiles??0,v=_>0&&!t.hideFilesTab?`${me} · ${_} pending`:String(me);return e.jsx(ke,{header:e.jsxs(e.Fragment,{children:[e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:I,number:y.number,url:y.url,numberTintClass:He("pr",y.state,y.draft),statePill:e.jsx(Ge,{kind:"pr",state:y.state,draft:y.draft}),openLabel:`Open pull request #${y.number} on GitHub`,title:y.title,onEditTitle:()=>{g(y.title),T(!0)},editTitleLabel:"Edit pull request title",editTitleDisabledReason:ee.allowed?null:ee.reason,meta:e.jsx(Je,{pr:y}),branches:e.jsx(We,{pr:y,filesCount:me})}),e.jsx(sn,{directory:s,repo:n,number:a,github:l,pr:y,access:Q,acting:m,mergeMethod:h,onMergeMethodChange:A,onRun:u=>{Z(u)},checkingOut:V,onCheckout:u=>{ue(u)},onCopyLink:G,askSending:R===`pr-${a}-ask`,onAskAgent:se}),e.jsx(nn,{pr:y,access:Q,acting:m,onRun:u=>{Z(u)}})]}),tabs:[{id:"summary",label:"Summary"},...t.hideFilesTab?[]:[{id:"files",label:"Code",hint:v}],{id:"checks",label:"Checks",hint:J?`${J.success}/${J.total}`:void 0,glyph:J?e.jsx(fe,{state:J.state}):void 0}],activeTab:p,onTabChange:u=>k(u),children:e.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2",children:[t.detailStale?e.jsxs("p",{className:"typography-micro text-muted-foreground",role:"note",children:["Showing saved details — last refresh failed."," ",e.jsx("button",{type:"button",className:"underline",onClick:t.onRetryDetail,children:"Retry"})]}):null,Q.permissionFallback?e.jsx("p",{className:"typography-micro text-muted-foreground",role:"note",children:"Permissions could not be loaded — actions stay enabled and any failure will be shown after you act."}):null,F?e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 py-1",children:[e.jsx(st,{value:j,onChange:u=>g(u.target.value),"aria-label":"Pull request title",className:"h-7"}),e.jsx(P,{type:"button",variant:"default",size:"xs",onClick:()=>{ne()},children:"Save"}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>T(!1),children:"Cancel"})]}):null,$?e.jsxs("p",{className:"flex flex-wrap items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(z,{name:"check",className:"size-3.5 shrink-0 text-[var(--status-success)]"}),e.jsxs("span",{children:["Ready on ",$.branch,$.path?` at ${$.path}`:"","."]}),$.path?e.jsx(P,{type:"button",variant:"default",size:"xs",onClick:w,children:"Open session here"}):null,e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>K(null),"aria-label":"Dismiss checkout result",children:"Dismiss"})]}):null,p==="summary"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-1.5 py-1",children:[e.jsx(qe,{icon:"user",label:"Reviewers",children:e.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",children:[y.requestedReviewers.length===0?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"None"}):y.requestedReviewers.map(u=>e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",children:[e.jsx(at,{login:u.login,avatarUrl:u.avatarUrl,size:"xs"}),e.jsx("span",{className:"truncate",children:u.login})]},u.login)),e.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground",children:[y.reviewSummary.approvals," approvals · ",y.reviewSummary.changesRequested," changes requested ·"," ",y.reviewSummary.commented," commented"]})]})}),e.jsx(qe,{icon:"list-unordered",label:"Labels",children:e.jsx("span",{className:"flex min-w-0 flex-wrap items-center gap-1",children:y.labels.length===0?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"None"}):y.labels.map(u=>e.jsx(hs,{name:u.name,color:u.color},u.name))})})]}),e.jsx(Ie,{id:`pr-${a}-description`,title:"Description",action:i?void 0:e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{f(y.body??""),C(!0)},"aria-label":"Edit description",title:ee.reason??"Edit description",disabled:!ee.allowed,children:"Edit"}),children:i?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("textarea",{value:L,onChange:u=>f(u.target.value),rows:6,"aria-label":"Pull request description",className:"min-h-24 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(P,{type:"button",variant:"default",size:"sm",onClick:()=>{oe()},children:"Save"}),e.jsx(P,{type:"button",variant:"ghost",size:"sm",onClick:()=>C(!1),children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(fs,{markdown:y.body??"",html:y.bodyHtml??null,fallbackUrl:y.url,label:"pull request description"}),y.body?.trim()?null:e.jsx("p",{className:"typography-micro text-muted-foreground",children:"No description provided."})]})}),e.jsx(Ie,{id:`pr-${a}-comments`,title:`Comments${q.length?` (${q.length})`:""}`,action:e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1",children:[t.hideFilesTab?e.jsx(dt,{directory:s,repo:n,number:a,github:l,access:Q,size:"xs",onReviewSubmitted:t.onRetryDetail}):null,e.jsx(gs,{order:N,onToggle:()=>E(N==="newest"?"oldest":"newest")})]}),children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ve,{error:t.commentsError,onRetry:t.onRetryComments,label:"Comments"}),U.map(u=>e.jsx(xs,{comment:u},u.id)),e.jsx(ps,{comments:W}),t.commentsLoading&&q.length===0&&!t.commentsError?e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Loading comments…"}):null,q.length===0&&!t.commentsLoading&&!t.commentsError?e.jsx("p",{className:"typography-micro text-muted-foreground",children:"No comments yet."}):null,q.length>D.length?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>B(M+1),children:"Show older comments"})}):t.commentsHasMore?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:t.onLoadMoreComments,disabled:t.commentsLoading,children:t.commentsLoading?"Loading…":"Load older comments"})}):null,e.jsx(Os,{directory:s,repo:n,number:a,github:l,pr:y,access:Q,onCommented:()=>{t.onRetryComments(),t.onRetryDetail()}})]})})]}):null,p==="files"&&!t.hideFilesTab?e.jsx(Zs,{files:t.files,filesLoading:t.filesLoading,filesError:t.filesError,filesHasMore:t.filesHasMore,onLoadMoreFiles:t.onLoadMoreFiles,onRetryFiles:t.onRetryFiles,threads:t.threads,threadsError:de?.threads??null,onRetryDetail:t.onRetryDetail,directory:s,repo:n,number:a,github:l,access:Q,headSha:y.headSha??null,onReviewSubmitted:t.onRetryDetail},`${n}#${a}`):null,p==="checks"?e.jsx(en,{directory:s,repo:n,number:a,github:l,checks:t.checks,checksError:t.checksError,checksLoading:t.checksLoading,onRetryChecks:t.onRetryChecks,onOpenFilesAtLine:t.onOpenFilesAtLine}):null]})})},ln=({items:t,hasMore:s,isLoadingMore:n,isLoading:a,isRefreshing:l,stale:d,error:c,filters:r,checksByUrl:x,countComplete:p=!0,incompleteNotice:k=null,remote:m=null,numberJump:b=null,onFiltersChange:h,onClearFilters:A,onLoadMore:F,onRetry:T,onOpen:j,headerActionsSlot:g=null,headerActionsPresentation:i="drawer"})=>{const C=r.state==="open"&&r.involvement==="all"&&!r.search.trim(),L=o.useCallback(f=>e.jsx("li",{role:"listitem",children:e.jsx(jt,{glyph:e.jsx(ys,{kind:"pr",state:f.state,draft:f.draft}),glyphBelow:e.jsx(fe,{state:(f.url?x[f.url]:void 0)??null}),number:`#${f.number}`,title:f.title,status:e.jsx(ge,{additions:f.additions,deletions:f.deletions,className:"typography-micro"}),meta:e.jsxs(e.Fragment,{children:[e.jsx(wt,{login:f.author?.login,avatarUrl:f.author?.avatarUrl}),e.jsx(kt,{head:f.head,base:f.base}),f.draft?e.jsx("span",{className:"shrink-0 rounded bg-[var(--surface-muted)] px-1 typography-micro text-muted-foreground",children:"Draft"}):null]}),updatedAt:f.updatedAt,onOpen:()=>j(f.number),ariaLabel:`Open pull request #${f.number} ${f.title}`})},f.number),[x,j]);return e.jsx(Ct,{items:t,renderRow:L,hasMore:s,isLoadingMore:n,isLoading:a,isRefreshing:l,stale:d,error:c,searchValue:r.search,onSearchChange:f=>h({search:f}),searchPlaceholder:"Search pull requests, or label:bug",searchAriaLabel:"Search pull requests",toolbarControls:e.jsx(Nt,{stateValue:r.state,stateOptions:Oe.map(f=>({id:f.id,label:f.label})),onStateChange:f=>h({state:f}),involvementValue:r.involvement,involvementOptions:ws.map(f=>({id:f.id,label:f.label})),onInvolvementChange:f=>h({involvement:f}),sortValue:r.sort,sortOptions:js.map(f=>({id:f.id,label:f.label})),onSortChange:f=>h({sort:f}),sortAriaLabel:"Sort pull requests"}),headerActionsSlot:g,headerActionsPresentation:i,isDefaultFilters:C,stateLabel:Oe.find(f=>f.id===r.state)?.label??r.state,kindSingular:"pull request",kindPlural:"pull requests",noItemsTitle:r.state==="open"?"No open pull requests":"No pull requests yet",noItemsBody:"Pull requests for this repository appear here.",noItemsIcon:"git-pull-request",listAriaLabel:"Pull requests",skeletonLabel:"Loading pull requests",updatedAtOf:f=>f.updatedAt,countComplete:p,incompleteNotice:k,remote:m,numberJump:b,numberJumpKind:"pull request",onClearFilters:A,onLoadMore:F,onRetry:T,onOpen:j})},on=t=>{const s=Dt(n=>n.results);return o.useMemo(()=>{const n=$t(s),a={};for(const l of t){if(!l.url)continue;const d=n.get(l.url);d!==void 0&&(a[l.url]=d)}return a},[t,s])},ra=({hideFilesTab:t=!1,headerActionsSlot:s=null,headerActionsPresentation:n="drawer"})=>{const a=Mt()??"";return a?e.jsx(rn,{directory:a,hideFilesTab:t,headerActionsSlot:s,headerActionsPresentation:n}):e.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center",children:e.jsx("p",{className:"typography-ui text-muted-foreground",children:"Open a project to browse pull requests."})})},rn=({directory:t,hideFilesTab:s,headerActionsSlot:n=null,headerActionsPresentation:a="drawer"})=>{const d=Ee().github??null,[c,r]=o.useState(!1),[x,p]=o.useState(!1),k=o.useRef(null);return o.useEffect(()=>Gt(),[]),e.jsx(St,{directory:t,isRefreshing:c,onRefresh:()=>k.current?.(),children:({repo:m,directory:b})=>e.jsx(cn,{directory:b,repo:m,github:d,refreshing:c,setRefreshing:r,loadingMore:x,setLoadingMore:p,refreshRef:k,hideFilesTab:s,headerActionsSlot:n,headerActionsPresentation:a},m)})},cn=({directory:t,repo:s,github:n,refreshing:a,setRefreshing:l,loadingMore:d,setLoadingMore:c,refreshRef:r,hideFilesTab:x,headerActionsSlot:p=null,headerActionsPresentation:k="drawer"})=>{const m=O(v=>v.ensureCollectionsFresh),b=O(v=>v.searchRemote),h=O(v=>v.loadMoreRemote),A=O(v=>v.loadMoreCollection),F=O(v=>v.refreshAllForScope),T=O(v=>v.selectPullRequest),j=O(v=>v.setFilters),g=O(v=>v.resetFilters),i=Ht(t,s),C=qt(t),L=It(),f=C.repo===s?C.number:null,N=i.state==="open"?"open":i.state==="all"?"both":"closed";o.useEffect(()=>{if(!n)return;let v=!1;return l(!0),m(t,s,N,n).then(()=>{v||l(!1)}).catch(()=>{v||l(!1)}),()=>{v=!0}},[t,s,n,N]),o.useEffect(()=>{if(!n)return;const v=()=>{typeof document<"u"&&document.hidden||m(t,s,N,n).catch(()=>{})};return window.addEventListener("focus",v),document.addEventListener("visibilitychange",v),()=>{window.removeEventListener("focus",v),document.removeEventListener("visibilitychange",v)}},[t,s,n,N]);const E=De(s,"open"),M=De(s,"closed"),B=o.useMemo(()=>Ot(s),[s,E?.data,M?.data]),V=o.useMemo(()=>new Set(B.map(v=>v.number)),[B]),S=o.useMemo(()=>Bt(B,{state:i.state,involvement:i.involvement,search:i.search,sort:i.sort,viewerLogin:L}),[B,i.state,i.involvement,i.search,i.sort,L]),$=on(S),K=N==="both"?[E,M]:[N==="open"?E:M],_=K.some(v=>v?.data!=null),X=_&&K.every(v=>v?.data?.nextCursor==null),R=K.reduce((v,u)=>v+(u?.data?.items.length??0),0),I=K.find(v=>v?.error)?.error??null,y=K.some(v=>v?.isLoading),de=K.some(v=>v?.stale),Q=i.search.trim(),ee=i.involvement!=="all"&&!L,Z=Q.length>0||i.involvement!=="all",se=o.useMemo(()=>({state:i.state,involvement:i.involvement,q:Q}),[i.state,i.involvement,Q]),ne=`${se.state}|${se.involvement}|${se.q}`,oe=!X&&_&&S.length===0&&(Q.length>0||ee),ae=o.useCallback(v=>n?b(t,s,v,n):Promise.resolve(null),[t,s,n,b]),ue=o.useCallback(v=>n?h(t,s,v,n):Promise.resolve(null),[t,s,n,h]),{remoteView:w,numberJump:G,remotePending:q,handleSearchAll:ie}=Rt({repo:s,query:se,queryKey:ne,autoRemote:oe,indexNumbers:V,visibleItems:S,searchText:Q,useRemoteEntry:Wt,runSearch:ae,runLoadMore:ue}),D=o.useMemo(()=>{if(X||!_||!Z)return null;const v=S.length===1?"1 match":`${S.length} matches`,u=R===1?"1 most recent loaded pull request":`${R} most recent loaded pull requests`;return`Showing ${v} from the ${u}`},[X,_,Z,S.length,R]),U=o.useCallback(()=>{n&&(l(!0),F(t,s,n).then(()=>{l(!1)}).catch(()=>l(!1)))},[t,s,n,F,l]);o.useEffect(()=>(r.current=U,()=>{r.current===U&&(r.current=null)}),[r,U]);const W=o.useCallback(()=>{if(!n)return;c(!0);const v=N==="both"?["open","closed"]:[N];Promise.all(v.map(u=>A(t,s,u,n))).then(()=>c(!1)).catch(()=>c(!1))},[t,s,N,n,A,c]),J=o.useCallback(v=>{T(t,s,v)},[t,s,T]),me=o.useCallback(()=>{T(t,null,null)},[t,T]);return n?f!=null?e.jsx(dn,{directory:t,repo:s,number:f,github:n,onBack:me,hideFilesTab:x,seed:_t(s,f)}):e.jsx(ln,{items:S,headerActionsSlot:p,headerActionsPresentation:k,hasMore:K.some(v=>v?.data?.nextCursor!=null),isLoadingMore:d,isLoading:y,isRefreshing:a&&_,stale:de,error:I,filters:i,checksByUrl:$,countComplete:X,incompleteNotice:D?{summary:D,searching:q,onSearchAll:ie}:null,remote:w,numberJump:G,onFiltersChange:v=>j(t,s,v),onClearFilters:()=>g(t,s),onLoadMore:W,onRetry:U,onOpen:J}):e.jsx(tt,{info:{reason:"failed",message:"GitHub is not available in this runtime."}})},dn=({directory:t,repo:s,number:n,github:a,onBack:l,hideFilesTab:d,seed:c})=>{const r=O(S=>S.ensureDetail),x=O(S=>S.ensureComments),p=O(S=>S.ensureFiles),k=O(S=>S.ensureChecks),m=O(S=>S.loadMoreFiles),b=O(S=>S.loadMoreComments),h=O(S=>S.refreshComments),A=O(S=>S.refreshDetail),F=O(S=>S.refreshChecks);o.useEffect(()=>{r(t,s,n,a).catch(()=>{}),x(t,s,n,a).catch(()=>{}),d||p(t,s,n,a).catch(()=>{}),k(t,s,n,a).catch(()=>{})},[t,s,n,d]);const T=Ut(s,n),j=Vt(s,n),g=Kt(s,n),i=Jt(s,n),C=T?.data?.detail??null,L=o.useCallback((S,$)=>{const K=Ss(t);Ne(async()=>{const{useUIStore:_}=await import("./index-Dd2OcIUY.js").then(X=>X.cA);return{useUIStore:_}},__vite__mapDeps([1,2,3,4,5,6,7])).then(({useUIStore:_})=>{_.getState().openContextFileAtLine(K,S,$)}).catch(()=>{})},[t]),f=o.useCallback(()=>{m(t,s,n,a).catch(()=>{})},[t,s,n,a,m]),N=o.useCallback(()=>{b(t,s,n,a).catch(()=>{})},[t,s,n,a,b]),E=o.useCallback(()=>{h(t,s,n,a).catch(()=>{})},[t,s,n,a,h]),M=o.useCallback(()=>{A(t,s,n,a).catch(()=>{})},[t,s,n,a,A]),B=o.useCallback(()=>{p(t,s,n,a).catch(()=>{})},[t,s,n,a,p]),V=o.useCallback(()=>{F(t,s,n,a).catch(()=>{})},[t,s,n,a,F]);return e.jsx(an,{hideFilesTab:d,seed:c,directory:t,repo:s,number:n,github:a,detail:C,detailError:T?.error??null,detailStale:T?.stale??!1,files:g?.data??null,filesError:g?.error??null,filesLoading:g?.isLoading??!1,filesHasMore:g?.data?.nextCursor!=null,onLoadMoreFiles:f,checks:i?.data??null,checksError:i?.error??null,checksLoading:i?.isLoading??!1,reviews:C?.reviews??[],threads:C?.threads??[],comments:j?.data?.comments??[],commentsError:j?.error??null,commentsLoading:j?.isLoading??!1,commentsHasMore:j?.data?.nextCursor!=null,onLoadMoreComments:N,onRetryComments:E,onBack:l,onRetryDetail:M,onRetryFiles:B,onRetryChecks:V,onOpenFilesAtLine:L})};export{ra as PullRequestsSurface};
|
package/dist/assets/{SessionSwitcherContent-DEGJyZBl.js → SessionSwitcherContent-DEw4nz7K.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,bd as N}from"./vendor-boot-DyL2td56.js";import{R as f}from"./vendor-react-DASdDPIk.js";import{f as b,I as x,h as T,i as U,r as R}from"./useAppFontEffects
|
|
1
|
+
import{j as e,bd as N}from"./vendor-boot-DyL2td56.js";import{R as f}from"./vendor-react-DASdDPIk.js";import{f as b,I as x,h as T,i as U,r as R}from"./useAppFontEffects--lKKtKVo.js";import{u as E}from"./useSwitcherItems-OCRYcHeu.js";import{t as M,o as v}from"./index-Dd2OcIUY.js";import{g as P,a as G,S as B,f as F}from"./SessionUnreadDot-CJFawQpo.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-B1GRkkKC.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";function $({onSelect:t,variant:h,scopeProjectId:d}){const r=E(!0,{scopeProjectId:d}),o=b(s=>s.openNewSessionDraft),a=M(s=>s.setActiveMainTab),i=f.useCallback(()=>{a("chat"),t(),o()},[t,o,a]),[l,m]=f.useState(new Set),c=f.useCallback(s=>{m(p=>{const u=new Set(p);return u.has(s)?u.delete(s):u.add(s),u})},[]);return e.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(N,{onClick:i,className:v("group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),children:[e.jsx(x,{name:"chat-new",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate typography-ui-label font-normal leading-tight text-foreground",children:"New session"})]}),r.length===0?e.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:"No recent sessions"}):r.map(s=>e.jsx(C,{item:s,depth:0,variant:h,expandedParents:l,toggleParent:c,closeDropdown:t},s.node.session.id))]})})}function C({item:t,depth:h,variant:d,expandedParents:r,toggleParent:o,closeDropdown:a}){const{node:i,secondaryMeta:l}=t,m=i.session,c=i.children.length>0,s=r.has(m.id);return e.jsxs(e.Fragment,{children:[e.jsx(H,{session:m,depth:h,variant:d,secondaryMeta:l,hasChildren:c,isExpanded:s,onToggleExpand:c?()=>o(m.id):void 0,closeDropdown:a}),c&&s?i.children.map(p=>e.jsx(C,{item:{node:p,projectId:t.projectId,groupDirectory:t.groupDirectory,secondaryMeta:l},depth:h+1,variant:d,expandedParents:r,toggleParent:o,closeDropdown:a},p.session.id)):null]})}function H({session:t,depth:h,variant:d,secondaryMeta:r,hasChildren:o,isExpanded:a,onToggleExpand:i,closeDropdown:l}){const m=b(n=>n.currentSessionId),c=b(n=>n.setCurrentSession),s=T(t.id),p=U(t.id),u=m===t.id,k=P(t),j=s?.type??"idle",g=j==="busy"||j==="retry",D=!g&&p>0&&!u,I=t.time?.updated||t.time?.created||Date.now(),L=F(I),S=r?.projectLabel?.trim()||null,w=r?.branchLabel?.trim()||null,y=w&&w!=="HEAD"?w:null,A=f.useCallback(()=>{if(u){l();return}const n=R(t);c(t.id,n??null),l()},[l,u,t,c]);return e.jsxs(N,{onClick:n=>{if(n.target?.closest("[data-switcher-expand]")){n.preventDefault();return}A()},"data-slot":"session-switcher-item",className:v("group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),style:{paddingLeft:8+h*12},children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[d==="compact"&&o?e.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:n=>{n.preventDefault(),n.stopPropagation(),i?.()},className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":a?"Collapse subsessions":"Expand subsessions",children:a?e.jsx(x,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):e.jsx(x,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e.jsx("span",{className:"truncate typography-ui-label font-normal leading-tight text-foreground",children:k})]}),d==="default"?e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight typography-micro",children:[o?e.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:n=>{n.preventDefault(),n.stopPropagation(),i?.()},className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":a?"Collapse subsessions":"Expand subsessions",children:a?e.jsx(x,{name:"arrow-down-s",className:"h-3 w-3"}):e.jsx(x,{name:"arrow-right-s",className:"h-3 w-3"})}):null,e.jsx("span",{className:"flex-shrink-0",children:g?e.jsx(G,{sessionId:t.id,running:!0}):D?e.jsx(B,{label:"Session complete"}):L}),S?e.jsx("span",{className:"truncate",children:S}):null,y?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[e.jsx(x,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),e.jsx("span",{className:"truncate",children:y})]}):null]}):null]}),g?e.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":"Session active",title:"Session active"})}):null]})}export{$ as default};
|