@pi-chamber/web 1.0.6-rc.5 → 1.0.6
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--XO16VPB.js → DiagramView-DsCdfDOP.js} +1 -1
- package/dist/assets/{DiffView-Duy2_7Gp.js → DiffView-BWo7yT-P.js} +6 -6
- package/dist/assets/{FileSaveConflictDialog-B1DvL9zy.js → FileSaveConflictDialog-IFbuQCcP.js} +1 -1
- package/dist/assets/{FilesView-CjjPpE4c.js → FilesView-DLIQkVep.js} +4 -4
- package/dist/assets/{GitHubDetailScaffold-DqxAKqCT.js → GitHubDetailScaffold-CxGg6x7R.js} +1 -1
- package/dist/assets/{GitHubLinkPicker-ELF_chia.js → GitHubLinkPicker-BmqbTUpE.js} +1 -1
- package/dist/assets/{GitHubListPrimitives-C2nGTntk.js → GitHubListPrimitives-a1DxU6Zp.js} +1 -1
- package/dist/assets/{GitView-5fIq2nzM.js → GitView-DbqM8Qi1.js} +5 -5
- package/dist/assets/{IssuesSurface-Dq5A_bWq.js → IssuesSurface-B2EfICtZ.js} +3 -3
- package/dist/assets/{JsonTreeView-BjFFSUwi.js → JsonTreeView-DzVqgwz-.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-B9Cu4TCh.js → MarkdownRendererImpl-7yTzCIEI.js} +3 -3
- package/dist/assets/PatchDiff-Dvfm6eOV.js +1 -0
- package/dist/assets/{PierreDiffViewer-H2f4pJ1k.js → PierreDiffViewer-ByYaUifK.js} +2 -2
- package/dist/assets/{PullRequestsSurface-DPpb2RW_.js → PullRequestsSurface-1IP_dDn8.js} +2 -2
- package/dist/assets/{SessionSwitcherContent-B5DaBWZU.js → SessionSwitcherContent-DVxWhG4x.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-D86FaZg_.js → SessionSwitcherDropdown-DiBGmmtD.js} +2 -2
- package/dist/assets/{SessionUnreadDot-CY9-1iV2.js → SessionUnreadDot-qw67HcBO.js} +1 -1
- package/dist/assets/SettingsView-CMTIIpWD.js +6 -0
- package/dist/assets/{SettingsWindow-Bw1dUoJ1.js → SettingsWindow-DZUSs5Is.js} +1 -1
- package/dist/assets/{ToolOutputDialog-aR4kcgKL.js → ToolOutputDialog-pgTNzNPN.js} +5 -5
- package/dist/assets/{ToolPartDiffPreview-B_wWmhtE.js → ToolPartDiffPreview-Cvnr4JkU.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-BYby097w.js → VirtualizedFileDiff-D8dSHI_H.js} +3 -3
- package/dist/assets/{collapsible-Dz0bPrJ_.js → collapsible-ZT74WYMA.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-8MuwxSC6.js → computeVirtualFileMetrics-g1aOl5nF.js} +1 -1
- package/dist/assets/{contextFileOpenGuard-fZ2NIQMQ.js → contextFileOpenGuard-IWdho_6z.js} +1 -1
- package/dist/assets/{fileTreeStatus-BzhMMLA9.js → fileTreeStatus-trDHgX4B.js} +2 -2
- package/dist/assets/{gitStatusPredicates-Cyh9UhYX.js → gitStatusPredicates-CfBh9Rne.js} +1 -1
- package/dist/assets/{githubLink-D2PznPcI.js → githubLink-CuQ2WFBa.js} +1 -1
- package/dist/assets/index-BaLCg7tL.css +1 -0
- package/dist/assets/{index-BX5pAOQX.js → index-CK9t5Znh.js} +1 -1
- package/dist/assets/{index-Cs2nBW_t.js → index-fmzQmSSv.js} +3 -3
- package/dist/assets/{main-BI6qe8pz.js → main-DOlk_lfi.js} +2 -2
- package/dist/assets/{main-7vBNPBMb.js → main-UnRe9F68.js} +4 -4
- package/dist/assets/{markdownCore-D5jiabKe.js → markdownCore-DuZmdypZ.js} +2 -2
- package/dist/assets/{miniChat-B3up4Bnz.js → miniChat-Dy9h0B6G.js} +2 -2
- package/dist/assets/{mobile-B4vLFgBc.js → mobile-CWrtn0Si.js} +2 -2
- package/dist/assets/{nativeFileSave-DpBH1Sa3.js → nativeFileSave-B4Rg6n8u.js} +1 -1
- package/dist/assets/{pi-session-focus-preference-BrB72skF.js → pi-session-focus-preference-q-s-Bhf0.js} +1 -1
- package/dist/assets/{renderDiffWithHighlighter-B6T04JGG.js → renderDiffWithHighlighter-HRnE6vfE.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-CX10w321.js → renderElectronMiniChatApp-OZ2fG5eY.js} +2 -2
- package/dist/assets/{renderFileWithHighlighter-DtAcGyJr.js → renderFileWithHighlighter-tJRUQWjE.js} +1 -1
- package/dist/assets/{renderMobileApp-C9n-BhPZ.js → renderMobileApp-D1nkBJLP.js} +3 -3
- package/dist/assets/runtimeEndpointReset-Bby2E_Je.js +62 -0
- package/dist/assets/{runtimeSurface-DiP2a57a.js → runtimeSurface-X62LLBLv.js} +1 -1
- package/dist/assets/{useAppFontEffects-Oyin3dgQ.js → useAppFontEffects-BFgKpDYT.js} +86 -86
- package/dist/assets/{useGitHubRemoteSearch-CZ9Hauw0.js → useGitHubRemoteSearch-MxC4J-VO.js} +1 -1
- package/dist/assets/{useSwitcherItems-BSqDA1IF.js → useSwitcherItems-D5TsQEbM.js} +1 -1
- package/dist/assets/{web-components-CkTNGkJ2.js → web-components-B_NMC-2c.js} +4 -4
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/lib/pi/routes.js +5 -1
- package/server/lib/pi/routes.test.js +3 -0
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +1 -1
- package/server/lib/pi/session-daemon/session-daemon-list-live.test.js +60 -1
- package/server/lib/pi/session-daemon/session-daemon.js +34 -10
- package/server/lib/pi/session-daemon/session-engine-router.js +5 -1
- package/server/lib/pi/session-daemon/session-engine-router.test.js +21 -0
- package/dist/assets/PatchDiff-CTqTTcg7.js +0 -1
- package/dist/assets/SettingsView-CiIuOi_E.js +0 -6
- package/dist/assets/index-tmO0fZa4.css +0 -1
- package/dist/assets/runtimeEndpointReset-aGyXPXPs.js +0 -62
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{j as _}from"./vendor-boot-3SaHYVb1.js";import{R as y}from"./vendor-react-Bz1tRBxM.js";import{m as je}from"./vendor-morphdom-B7dS_VPB.js";import{r as Ze}from"./vendor-beautiful-mermaid-b48gT2g0.js";import{a as Ue,aa as Xe,h as Ae,z as Ge,Q as ee,bQ as Ye,f as U,A as te}from"./index-Cs2nBW_t.js";import{dm as ve,dn as Qe,dp as Je,ah as W,br as et,bs as tt,dq as rt,dr as nt,ds as ot,dt as re,du as at,dv as it,dw as st,z as ke,y as Ee,dx as Ce,dy as lt,ar as ct}from"./useAppFontEffects-Oyin3dgQ.js";import{r as dt,s as ut,i as mt,a as ft,b as pt}from"./markdownCore-D5jiabKe.js";import{r as ht}from"./registerCustomTheme-C-h6lsYW.js";import{saveOrShareFile as gt}from"./nativeFileSave-DpBH1Sa3.js";import{i as bt}from"./runtimeSurface-DiP2a57a.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-elkjs-D1S1RCAO.js";import"./vendor-entities-C3BA0AJP.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./vendor-marked-Be78pDn1.js";import"./vendor-dompurify-BGCr_sdL.js";import"./vendor-remend-DcBOpbSu.js";import"./themeResolver-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.js";import"./vendor-shikijs-core-Ck_OPM_T.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-DPFxvYtK.js";import"./vendor-hast-util-to-html-O3stl53j.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-C40bX6nM.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",wt={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 yt=()=>{ne||(ne=!0,ht(Se,()=>Promise.resolve(wt)))},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)),At=6,ae=1.25,vt=1.0015,kt=.5,Et=12,ie=3,Ct=400,I='[data-markdown="mermaid-block"]',M=e=>e.querySelector(I)!==null,St=e=>[e.x,e.y,e.width,e.height].map(t=>{const n=Number(t.toFixed(At));return Object.is(n,-0)?"0":String(n)}).join(" "),Mt=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)},Nt=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(":")},Me=(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}},xt=({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},Tt=(e,t)=>{const n=t.x-e.x,r=t.y-e.y;return n*n+r*r>ie*ie},Pt=({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),l=Math.max(o,a),d=Me(t,n),c=d.width/e.width,m=B(c*s,i,l),f=d.width/m,p=f/(e.width/e.height),h=B(r.x/n.width,0,1),A=B(r.y/n.height,0,1),v=e.x+h*e.width,w=e.y+A*e.height;return{x:v-h*f,y:w-A*p,width:f,height:p}},X=new WeakMap,Rt=e=>e instanceof HTMLElement?X.get(e)??null:null,_t=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 Nt({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}},It=(e,t)=>{const n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}},Ft=e=>e instanceof Element&&!!e.closest('button, a, [role="button"]'),Ot=e=>{const t=_t(e),n=e.querySelector('[data-markdown="mermaid"] svg');if(!t||!n)return null;const r=Mt({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,l=null;const d=u=>{s=u,n.setAttribute("viewBox",St(u)),n.removeAttribute("width"),n.removeAttribute("height")},c=()=>{d(Me(r,R(t)))},m=(u,E)=>{d(Pt({currentBox:s,contentBox:r,viewport:R(t),pointer:u,zoomFactor:E,minScale:kt,maxScale:Et}))},f=()=>{const u=R(t);m({x:u.width/2,y:u.height/2},ae)},p=()=>{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(It(u,t),Math.pow(vt,-u.deltaY)))},A=u=>{u.button!==0||Ft(u.target)||(o=u.pointerId,a={x:u.clientX,y:u.clientY},i=a,l!==null&&(window.clearTimeout(l),l=null),e.removeAttribute("data-mermaid-suppress-click"),t.setPointerCapture?.(u.pointerId),e.setAttribute("data-mermaid-panning","true"),u.preventDefault())},v=u=>{if(o!==u.pointerId||!i)return;const E={x:u.clientX,y:u.clientY};d(xt({currentBox:s,viewport:R(t),delta:{x:E.x-i.x,y:E.y-i.y}})),i=E,a&&Tt(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")&&(l=window.setTimeout(()=>{e.removeAttribute("data-mermaid-suppress-click"),l=null},Ct)))},g=()=>{c()};t.addEventListener("wheel",h,{passive:!1}),t.addEventListener("pointerdown",A),t.addEventListener("pointermove",v),t.addEventListener("pointerup",w),t.addEventListener("pointercancel",w),window.addEventListener("resize",g);const b=typeof ResizeObserver>"u"?null:new ResizeObserver(g);return b?.observe(t),c(),{zoomIn:f,zoomOut:p,fit:c,cleanup:()=>{t.removeEventListener("wheel",h),t.removeEventListener("pointerdown",A),t.removeEventListener("pointermove",v),t.removeEventListener("pointerup",w),t.removeEventListener("pointercancel",w),window.removeEventListener("resize",g),b?.disconnect(),l!==null&&window.clearTimeout(l),e.removeAttribute("data-mermaid-panning"),e.removeAttribute("data-mermaid-suppress-click"),X.delete(e)}}},Dt=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=Ot(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")},Le="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=Le,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(`
|
|
1
|
+
import{j as _}from"./vendor-boot-3SaHYVb1.js";import{R as y}from"./vendor-react-Bz1tRBxM.js";import{m as je}from"./vendor-morphdom-B7dS_VPB.js";import{r as Ze}from"./vendor-beautiful-mermaid-b48gT2g0.js";import{a as Ue,aa as Xe,h as Ae,z as Ge,Q as ee,bQ as Ye,f as U,A as te}from"./index-fmzQmSSv.js";import{dq as ve,dr as Qe,ds as Je,ah as W,br as et,bs as tt,dt as rt,du as nt,dv as ot,dw as re,dx as at,dy as it,dz as st,z as ke,y as Ee,dA as Ce,dB as lt,ar as ct}from"./useAppFontEffects-BFgKpDYT.js";import{r as dt,s as ut,i as mt,a as ft,b as pt}from"./markdownCore-DuZmdypZ.js";import{r as ht}from"./registerCustomTheme-C-h6lsYW.js";import{saveOrShareFile as gt}from"./nativeFileSave-B4Rg6n8u.js";import{i as bt}from"./runtimeSurface-X62LLBLv.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-elkjs-D1S1RCAO.js";import"./vendor-entities-C3BA0AJP.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./vendor-marked-Be78pDn1.js";import"./vendor-dompurify-BGCr_sdL.js";import"./vendor-remend-DcBOpbSu.js";import"./themeResolver-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.js";import"./vendor-shikijs-core-Ck_OPM_T.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-DPFxvYtK.js";import"./vendor-hast-util-to-html-O3stl53j.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-C40bX6nM.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",wt={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 yt=()=>{ne||(ne=!0,ht(Se,()=>Promise.resolve(wt)))},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)),At=6,ae=1.25,vt=1.0015,kt=.5,Et=12,ie=3,Ct=400,I='[data-markdown="mermaid-block"]',M=e=>e.querySelector(I)!==null,St=e=>[e.x,e.y,e.width,e.height].map(t=>{const n=Number(t.toFixed(At));return Object.is(n,-0)?"0":String(n)}).join(" "),Mt=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)},Nt=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(":")},Me=(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}},xt=({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},Tt=(e,t)=>{const n=t.x-e.x,r=t.y-e.y;return n*n+r*r>ie*ie},Pt=({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),l=Math.max(o,a),d=Me(t,n),c=d.width/e.width,m=B(c*s,i,l),f=d.width/m,p=f/(e.width/e.height),h=B(r.x/n.width,0,1),A=B(r.y/n.height,0,1),v=e.x+h*e.width,w=e.y+A*e.height;return{x:v-h*f,y:w-A*p,width:f,height:p}},X=new WeakMap,Rt=e=>e instanceof HTMLElement?X.get(e)??null:null,_t=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 Nt({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}},It=(e,t)=>{const n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}},Ft=e=>e instanceof Element&&!!e.closest('button, a, [role="button"]'),Ot=e=>{const t=_t(e),n=e.querySelector('[data-markdown="mermaid"] svg');if(!t||!n)return null;const r=Mt({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,l=null;const d=u=>{s=u,n.setAttribute("viewBox",St(u)),n.removeAttribute("width"),n.removeAttribute("height")},c=()=>{d(Me(r,R(t)))},m=(u,E)=>{d(Pt({currentBox:s,contentBox:r,viewport:R(t),pointer:u,zoomFactor:E,minScale:kt,maxScale:Et}))},f=()=>{const u=R(t);m({x:u.width/2,y:u.height/2},ae)},p=()=>{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(It(u,t),Math.pow(vt,-u.deltaY)))},A=u=>{u.button!==0||Ft(u.target)||(o=u.pointerId,a={x:u.clientX,y:u.clientY},i=a,l!==null&&(window.clearTimeout(l),l=null),e.removeAttribute("data-mermaid-suppress-click"),t.setPointerCapture?.(u.pointerId),e.setAttribute("data-mermaid-panning","true"),u.preventDefault())},v=u=>{if(o!==u.pointerId||!i)return;const E={x:u.clientX,y:u.clientY};d(xt({currentBox:s,viewport:R(t),delta:{x:E.x-i.x,y:E.y-i.y}})),i=E,a&&Tt(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")&&(l=window.setTimeout(()=>{e.removeAttribute("data-mermaid-suppress-click"),l=null},Ct)))},g=()=>{c()};t.addEventListener("wheel",h,{passive:!1}),t.addEventListener("pointerdown",A),t.addEventListener("pointermove",v),t.addEventListener("pointerup",w),t.addEventListener("pointercancel",w),window.addEventListener("resize",g);const b=typeof ResizeObserver>"u"?null:new ResizeObserver(g);return b?.observe(t),c(),{zoomIn:f,zoomOut:p,fit:c,cleanup:()=>{t.removeEventListener("wheel",h),t.removeEventListener("pointerdown",A),t.removeEventListener("pointermove",v),t.removeEventListener("pointerup",w),t.removeEventListener("pointercancel",w),window.removeEventListener("resize",g),b?.disconnect(),l!==null&&window.clearTimeout(l),e.removeAttribute("data-mermaid-panning"),e.removeAttribute("data-mermaid-suppress-click"),X.delete(e)}}},Dt=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=Ot(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")},Le="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)]",z=(e,t)=>{e.innerHTML=t},S=(e,t,n)=>{const r=document.createElement("button");return r.type="button",r.className=Le,r.setAttribute("data-md-action",n),r.setAttribute("title",t),r.setAttribute("aria-label",t),z(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
2
|
`),s=r?n.slice(0,-1).split(`
|
|
3
3
|
`):n.split(`
|
|
4
4
|
`),o=s.length>0?s:[""],a=Array.from(t.children).filter(d=>d.classList.contains("line"));r&&a.length===o.length+1&&a.at(-1)?.textContent===""&&a.pop();const i=a.length===o.length,l=document.createDocumentFragment();o.forEach((d,c)=>{const m=document.createElement("span");m.setAttribute("data-md-code-line","");const f=document.createElement("span");f.setAttribute("data-md-code-line-number",""),f.setAttribute("aria-hidden","true"),f.textContent=String(c+1);const p=document.createElement("span");if(p.setAttribute("data-md-code-line-content",""),i){const h=a[c];h&&p.append(...Array.from(h.childNodes))}else p.textContent=d;if(m.append(f,p),l.appendChild(m),c<o.length-1||r){const h=document.createElement("span");h.setAttribute("data-md-code-line-break",""),h.textContent=`
|
|
5
5
|
`,l.appendChild(h)}}),t.replaceChildren(l),t.setAttribute("data-md-code-lines",""),t.toggleAttribute("data-md-code-trailing-newline",r)},Te=e=>{const t=Array.from(e.querySelectorAll("[data-md-code-line-content]"));if(t.length===0)return e.textContent??"";const n=t.map(r=>r.textContent??"").join(`
|
|
6
6
|
`);return e.hasAttribute("data-md-code-trailing-newline")?`${n}
|
|
7
|
-
`:n},qt=e=>{const t=e.querySelectorAll('[data-component="markdown-code"]');for(const n of Array.from(t)){const r=n.querySelector("pre");r&&xe(r),Ne(n)}},le=(e,t,n,r)=>{
|
|
7
|
+
`:n},qt=e=>{const t=e.querySelectorAll('[data-component="markdown-code"]');for(const n of Array.from(t)){const r=n.querySelector("pre");r&&xe(r),Ne(n)}},le=(e,t,n,r)=>{z(e,q.check),e.setAttribute("title",t),e.setAttribute("aria-label",t),window.setTimeout(()=>{z(e,q[n]),e.setAttribute("title",r),e.setAttribute("aria-label",r)},2e3)},zt=e=>{const t=e.querySelectorAll(":not(pre) > code");for(const n of Array.from(t))n.getAttribute("data-markdown")!=="inline-code"&&n.setAttribute("data-markdown","inline-code")},$t=(e,t)=>{const n=e.querySelectorAll("pre");for(const r of Array.from(n)){if(r.querySelector("code.language-mermaid"))continue;const s=r.parentElement;if(!s||s.closest('[data-component="markdown-code"]'))continue;const o=r.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],a=r.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 l=document.createElement("div");l.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 c=S("copy",t.labels.copy,"copy-code");l.appendChild(d);const m=document.createElement("div");m.className="flex items-center gap-1",m.setAttribute("data-md-code-actions",""),m.appendChild(c),l.appendChild(m);const f=document.createElement("div");f.setAttribute("data-md-code-body",""),f.className="px-3 py-2.5 overflow-x-auto",s.replaceChild(i,r),r.style.margin="0",r.style.background="transparent",r.classList.add("min-w-0","w-full","flex-1"),t.deferCodeLineNumberSync||xe(r),f.appendChild(r),i.appendChild(l),i.appendChild(f),Ne(i)}},ce=e=>{const t=[],n=[],r=e.querySelectorAll("thead th");for(const o of Array.from(r))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&&n.push(a)}return{headers:t,rows:n}},Ht=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,de=({headers:e,rows:t})=>[e,...t].map(n=>n.map(Ht).join(",")).join(`
|
|
8
8
|
`),Wt=({headers:e,rows:t})=>[e,...t].map(n=>n.join(" ")).join(`
|
|
9
9
|
`),ue=({headers:e,rows:t})=>{const n=`| ${e.join(" | ")} |`,r=`| ${e.map(()=>"---").join(" | ")} |`,s=t.map(o=>`| ${o.join(" | ")} |`).join(`
|
|
10
10
|
`);return`${n}
|
|
11
11
|
${r}
|
|
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},Bt=(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 l=document.createElement("div");l.className="relative",l.appendChild(S("download",t.downloadTable,"table-download-toggle")),l.appendChild(me("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),a.appendChild(i),a.appendChild(l);const d=document.createElement("div");d.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const c=r.parentElement;if(!c)continue;c.replaceChild(o,r),r.setAttribute("data-markdown","table"),r.classList.add("w-full","border-collapse","text-sm");for(const f of Array.from(r.querySelectorAll("tr")))f.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 f of Array.from(r.querySelectorAll("th")))f.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 f of Array.from(r.querySelectorAll("td")))f.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground","last:border-r-0");d.appendChild(r),o.appendChild(a),o.appendChild(d)}},Vt=(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 l=document.createElement("div");l.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 f=document.createElement("div");if(f.setAttribute("data-markdown","mermaid"),f.setAttribute("data-md-original-svg",a.svg),f.innerHTML=a.svg,m.appendChild(f),l.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 p=S("copy",t.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",o),d.appendChild(p)}if(t.mermaidControls.download){const p=S("download",t.labels.downloadDiagram,"mermaid-download");p.setAttribute("data-md-svg","1"),d.appendChild(p)}}else{i.setAttribute("data-mermaid-render","svg");const m=document.createElement("pre");if(m.setAttribute("data-markdown","mermaid-ascii"),m.textContent=o,l.appendChild(m),t.mermaidControls.copy){const f=S("copy",t.labels.copyDiagram,"mermaid-copy");f.setAttribute("data-md-source",o),d.appendChild(f)}}i.appendChild(l),i.appendChild(d);const c=s.parentElement;c&&c.replaceChild(i,s)}},Kt=(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(!ve(s))continue;r.setAttribute("data-md-link-decorated","true");const o=Qe(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&&Je(s)){const a=document.createElement("button");a.type="button",a.className=`ml-1 align-middle ${Le}`,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)}}},fe=(e,t)=>{$t(e),Vt(e,t),zt(e,t),Bt(e,t.labels),Kt(e,t)},pe=(e,t,n)=>{gt({filename:e,mimeType:n,data:t}).catch(r=>console.warn("[markdown] Download failed",r))},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"),l=i?Te(i):"";l&&W(l).then(()=>le(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,l=i?.classList.contains("hidden")??!1;F(e),i&&l&&i.classList.remove("hidden");return}if(a.startsWith("table-copy-")){const i=a.replace("table-copy-",""),l=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const d=ce(l),c=i==="csv"?de(d):i==="tsv"?Wt(d):ue(d);W(c)}F(e);return}if(a.startsWith("table-download-")){const i=a.replace("table-download-",""),l=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const d=ce(l),c=i==="csv"?de(d):ue(d);pe(i==="csv"?"table.csv":"table.md",c,i==="csv"?"text/csv":"text/markdown")}F(e);return}if(a==="mermaid-copy"){const i=o.getAttribute("data-md-source")??"";i&&W(i).then(()=>le(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"]'),l=Rt(i);a==="mermaid-zoom-in"?l?.zoomIn():a==="mermaid-zoom-out"?l?.zoomOut():l?.fit();return}if(a==="mermaid-download"){const i=o.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),l=i?.getAttribute("data-md-original-svg")??i?.innerHTML??"";l&&pe("diagram.svg",l,"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},Zt=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),ge=Array.from(Zt).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Ut=e=>nt(e),Xt=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=ge.length>0?t.match(new RegExp(`^(.*(?:/|^)(${ge})):.*$`,"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 l=O(s[1]??""),d=Number.parseInt(s[2]??"",10),c=Number.parseInt(s[3]??"",10);return!l||!Number.isFinite(d)||!Number.isFinite(c)||c<d?null:{path:l,line:d,endLine:c}}const o=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(o){const l=O(o[1]??""),d=Number.parseInt(o[2]??"",10),c=o[3]?Number.parseInt(o[3],10):void 0;return!l||!Number.isFinite(d)?null:{path:l,line:d,column:Number.isFinite(c??Number.NaN)?c:void 0}}const a=r.match(/^(.*?):(\d+)(?::(\d+))?$/);if(a){const l=O(a[1]??""),d=Number.parseInt(a[2]??"",10),c=a[3]?Number.parseInt(a[3],10):void 0;return!l||!Number.isFinite(d)?null:{path:l,line:d,column:Number.isFinite(c??Number.NaN)?c: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")??"";ve(i)&&(s.preventDefault(),s.stopPropagation(),ot(i))};return n.addEventListener("click",r),()=>{n.removeEventListener("click",r)}},[e,t])},be='[data-pichamber-file-link="true"]',_e="data-pichamber-block-path-token",Ie=`[${_e}]`,T="data-pichamber-block-paths-scanned",Gt=2e5,Yt=4,Qt=1e3,Jt=80,we=160,L=new Map;let D=0;const ye=[],er=()=>Qt,tr=()=>Jt,rr=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),G=e=>Ut(e),nr=e=>Xt(e),or=(e,t)=>st(e,t),ar=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 rr.has(r)||r.startsWith(".")&&r.length>1?!0:ar(t)},Oe=e=>{const t=Pe(e);return t?Fe(t.path):!1},ir=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()},K=e=>{if(e.tagName.toLowerCase()==="a"){const t=e.getAttribute("href")?.trim();if(t&&Oe(t))return t}return(e.textContent||"").trim()},sr=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>Gt){r.setAttribute(T,"true");continue}const s=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=[];let a=s.nextNode();for(;a;){const c=a;c.parentElement?.closest("[data-md-code-line-number]")||o.push(c),a=s.nextNode()}const i=Te(r);if(!i.includes(".")){r.setAttribute(T,"true");continue}V.lastIndex=0;const l=[];let d=V.exec(i);for(;d;){const c=d[0];c&&Oe(c)&&l.push({start:d.index,end:d.index+c.length,raw:c}),d=V.exec(i)}for(const{start:c,end:m,raw:f}of l.reverse()){const p=he(o,c,"right"),h=he(o,m,"left");if(!p||!h)continue;const A=n.createRange();A.setStart(p.node,p.offset),A.setEnd(h.node,h.offset);const v=n.createElement("span");v.setAttribute(_e,"true"),v.textContent=f,A.deleteContents(),A.insertNode(v)}r.setAttribute(T,"true")}},j=(e,t)=>{const n=Pe(e);if(!n||!Fe(n.path))return null;const r=nr(n.path)?G(n.path):or(t,n.path);return r?{...n,resolvedPath:r}:null},lr=e=>{const t=G(e);if(!t)return Promise.resolve(!1);const n=L.get(t);if(n)return L.delete(t),L.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 l=await i.json().catch(()=>null);o(l?.exists!==!1)}).catch(()=>o(!1)).finally(()=>{D=Math.max(0,D-1),ye.shift()?.()})};if(D<Yt){a();return}ye.push(a)}),s=er();for(;L.size>=s;){const o=L.keys().next().value;if(typeof o!="string")break;L.delete(o)}return L.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 l=tr(),d=s&&!bt(),c=g=>{g.removeAttribute("data-pichamber-file-link"),g.removeAttribute("data-pichamber-file-ref"),g.removeAttribute("data-pichamber-file-path"),g.getAttribute("title")==="Open file"&&g.removeAttribute("title"),g.tagName.toLowerCase()!=="a"&&(g.removeAttribute("role"),g.removeAttribute("tabindex"))},m=()=>{const g=a.querySelectorAll(be);for(const b of Array.from(g))c(b);ir(a)};if(!d){m();return}const f=(g=0)=>{if(o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),typeof window>"u"){p();return}o.current=window.setTimeout(()=>{o.current=null,window.requestAnimationFrame(()=>{i||p()})},g)},p=()=>{d&&sr(a);const g=a.querySelectorAll(`[data-markdown="inline-code"], a, ${Ie}`);let b=0;for(const u of Array.from(g)){const E=K(u),C=j(E,t);if(c(u),!C||b>=l)continue;b+=1,(Ue()&&Xe()&&!re(C.resolvedPath,t)?Promise.resolve(!0):lr(C.resolvedPath)).then(Ke=>{if(i||!Ke||!a.contains(u))return;const J=K(u),H=j(J,t);!H||H.resolvedPath!==C.resolvedPath||(u.setAttribute("data-pichamber-file-link","true"),u.setAttribute("data-pichamber-file-ref",J),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 g=>{const b=g.getAttribute("data-pichamber-file-ref")||K(g),u=j(b,t);if(!u)return;const E=cr(t,u.resolvedPath);re(u.resolvedPath,t)||await at(u.resolvedPath,t);const C=Ae.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)},A=g=>{const b=g.target;if(!(b instanceof Element))return;const u=b.closest(be);u instanceof HTMLElement&&(g.preventDefault(),g.stopPropagation(),h(u))},v=g=>{if(g.key!=="Enter"&&g.key!==" ")return;const b=g.target;!(b instanceof HTMLElement)||b.getAttribute("data-pichamber-file-link")!=="true"||(g.preventDefault(),g.stopPropagation(),h(b))};f(we);const w=new MutationObserver(()=>{f(we)});return w.observe(a,{childList:!0,subtree:!0}),a.addEventListener("click",A),a.addEventListener("keydown",v),()=>{i=!0,o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),o.current=null,w.disconnect(),a.removeEventListener("click",A),a.removeEventListener("keydown",v)}},[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=l=>{if(!t)return;const d=l.target;if(!(d instanceof Element)||d.closest('button, a, [role="button"]'))return;const c=d.closest(I);if(!c)return;if(c instanceof HTMLElement&&c.hasAttribute("data-mermaid-suppress-click")){c.removeAttribute("data-mermaid-suppress-click");return}const f=Array.from(o.querySelectorAll(I)).indexOf(c);if(f<0)return;const p=c instanceof HTMLElement?c.getAttribute("data-md-source"):null;if(!p||p.trim().length===0)return;const h=`Diagram ${f+1}`;t({open:!0,title:h,content:"",metadata:{tool:"mermaid-preview",filename:h},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(p)}`,source:p,filename:h}})},i=l=>{if(s||(l.ctrlKey||l.metaKey)&&r)return;const d=l.target;!(d instanceof Element)||!d.closest(I)||l.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,dr=100,ur=(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>dr){const s=N.keys().next().value;s&&N.delete(s)}return r},mr=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=ct(),t=te(!1),n=te(!0);return e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?n:t)},fr=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=mr(e),a=e.metadata?.id??"theme";return{labels:s,mermaidControls:r,deferCodeLineNumberSync:t,renderMermaid:l=>ur(`${a}:svg:${l}`,()=>{try{return{svg:Ze(l,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=""},Z=(e,t)=>{We(e);const n=pt(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(()=>{yt()},[]);const a=y.useRef(null),i=y.useRef(null),l=y.useRef(r);l.current!==r&&(l.current=r,i.current=null);const d=y.useCallback(()=>{const c=e.current;if(c){if(!a.current){if(!M(c))return;a.current=Dt(c);return}a.current.refresh()}},[e]);y.useLayoutEffect(()=>{const c=e.current,m=c?.querySelector("[data-markdown-content]")??c;if(m&&t&&m.childNodes.length===0){const f=document.createElement("div");if(f.setAttribute("data-md-block",""),f.style.display="contents",n){Z(f,t),m.appendChild(f);return}f.innerHTML=dt(t),fe(f,o),m.appendChild(f),M(f)&&d()}},[e,t,n,o,d]),y.useEffect(()=>()=>{a.current?.cleanup(),a.current=null},[]),y.useEffect(()=>{const c=e.current;if(!c)return;const m=c.querySelector("[data-markdown-content]")??c;let f=!0;if(n&&i.current){const p=ut(r).update(t);if(mt(i.current,p)){const h=p[p.length-1],A=m.querySelectorAll(":scope > [data-md-block]")[p.length-1];if(h&&A){Z(A,h.raw),A.setAttribute("data-md-id",`live:${p.length-1}`),i.current=i.current.map((v,w)=>w===p.length-1?{...v,raw:h.raw,id:`live:${w}`,mode:"live"}:v);return}}}return ft(t,n,r).then(p=>{if(!f)return;const h=Array.from(m.querySelectorAll(":scope > [data-md-block]"));p.forEach((w,g)=>{let b=h[g];if(b||(b=document.createElement("div"),b.setAttribute("data-md-block",""),b.style.display="contents",m.appendChild(b)),w.mode==="live"){Z(b,w.raw),b.setAttribute("data-md-id",w.id);return}if(We(b),b.getAttribute("data-md-id")===w.id)return;const u=document.createElement("div");u.innerHTML=w.html,fe(u,o);const E=M(b),C=M(u);je(b,u,{childrenOnly:!0,onBeforeElUpdated:(Y,Q)=>!Y.isEqualNode(Q)}),b.setAttribute("data-md-id",w.id),(E||C||M(b))&&d()});const A=M(m);let v=!1;for(let w=h.length-1;w>=p.length;w-=1){const g=h[w];g&&M(g)&&(v=!0),g?.remove()}(v||h.length>p.length&&A)&&d(),i.current=p}),()=>{f=!1}},[e,t,n,r,o,d]),y.useEffect(()=>{const c=e.current;if(c)return jt(c,o)},[e,o]),y.useEffect(()=>{const c=e.current,m=c?.querySelector("[data-markdown-content]")??c;if(m)for(const[f,p]of Object.entries(s))m.style.setProperty(f,p)},[e,s]),y.useEffect(()=>{const c=e.current,m=c?.querySelector("[data-markdown-content]")??c;m&&(o.deferCodeLineNumberSync||qt(m))},[e,o.deferCodeLineNumberSync])},Ve=(e,t)=>U("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:l="assistant",onShowPopup:d,enableFileReferences:c=!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:f}=ke(),p=y.useRef(null),h=Ee()??"",A=Ae(C=>C.openContextPreview),v=y.useCallback(C=>{h&&A(h,C)},[h,A]),w=a&&!i;$e({containerRef:p,onShowPopup:d,enableFullscreen:qe,enablePanZoom:P.showPanZoomControls}),De({containerRef:p,effectiveDirectory:h,editor:f,preferRuntimeEditor:!1,enabled:c&&!a}),Re({containerRef:p});const g=y.useMemo(()=>Ce(m),[m]),b=He(m,w,h?v:void 0,P),u=`markdown-${t?.id?`part-${t.id}`:`message-${n}`}`;Be({containerRef:p,text:e,streaming:w,cacheKey:u,syntaxVars:g,ctx:b});const E=_.jsx("div",{className:U("break-words w-full min-w-0",o),ref:p,children:_.jsx("div",{className:Ve(l,w),"data-markdown-content":!0})});return r?_.jsx(lt,{skipAnimation:s,children:E},u):E},Qr=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),hr=({content:e,className:t,variant:n="assistant",disableLinkSafety:r,stripFrontmatter:s=!1,onShowPopup:o,mermaidControls:a=P,allowMermaidWheelEvents:i=!1,enableFileReferences:l=!0})=>{const{editor:d}=ke(),c=ze(),m=y.useRef(null),f=Ee()??"",p=y.useMemo(()=>s?fr(e):e,[e,s]);$e({containerRef:m,onShowPopup:o,enableFullscreen:qe,enablePanZoom:a.showPanZoomControls,allowMermaidWheelEvents:i}),De({containerRef:m,effectiveDirectory:f,editor:d,preferRuntimeEditor:!1,enabled:l}),Re({containerRef:m,enabled:!r});const h=y.useMemo(()=>Ce(c),[c]),A=He(c,!1,void 0,a);return Be({containerRef:m,text:p,streaming:!1,cacheKey:`simple:${n}`,syntaxVars:h,ctx:A}),_.jsx("div",{className:U("break-words w-full min-w-0",t),ref:m,children:_.jsx("div",{className:Ve(n),"data-markdown-content":!0})})},Jr=y.memo(hr,(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{Qr as MarkdownRenderer,Jr as SimpleMarkdownRenderer};
|
|
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},Bt=(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 l=document.createElement("div");l.className="relative",l.appendChild(S("download",t.downloadTable,"table-download-toggle")),l.appendChild(me("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),a.appendChild(i),a.appendChild(l);const d=document.createElement("div");d.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const c=r.parentElement;if(!c)continue;c.replaceChild(o,r),r.setAttribute("data-markdown","table"),r.classList.add("w-full","border-collapse","text-sm");for(const f of Array.from(r.querySelectorAll("tr")))f.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 f of Array.from(r.querySelectorAll("th")))f.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 f of Array.from(r.querySelectorAll("td")))f.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground","last:border-r-0");d.appendChild(r),o.appendChild(a),o.appendChild(d)}},Vt=(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 l=document.createElement("div");l.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 f=document.createElement("div");if(f.setAttribute("data-markdown","mermaid"),f.setAttribute("data-md-original-svg",a.svg),f.innerHTML=a.svg,m.appendChild(f),l.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 p=S("copy",t.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",o),d.appendChild(p)}if(t.mermaidControls.download){const p=S("download",t.labels.downloadDiagram,"mermaid-download");p.setAttribute("data-md-svg","1"),d.appendChild(p)}}else{i.setAttribute("data-mermaid-render","svg");const m=document.createElement("pre");if(m.setAttribute("data-markdown","mermaid-ascii"),m.textContent=o,l.appendChild(m),t.mermaidControls.copy){const f=S("copy",t.labels.copyDiagram,"mermaid-copy");f.setAttribute("data-md-source",o),d.appendChild(f)}}i.appendChild(l),i.appendChild(d);const c=s.parentElement;c&&c.replaceChild(i,s)}},Kt=(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(!ve(s))continue;r.setAttribute("data-md-link-decorated","true");const o=Qe(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&&Je(s)){const a=document.createElement("button");a.type="button",a.className=`ml-1 align-middle ${Le}`,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),z(a,q.download),r.parentNode?.insertBefore(a,r.nextSibling)}}},fe=(e,t)=>{zt(e),Vt(e,t),$t(e,t),Bt(e,t.labels),Kt(e,t)},pe=(e,t,n)=>{gt({filename:e,mimeType:n,data:t}).catch(r=>console.warn("[markdown] Download failed",r))},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"),l=i?Te(i):"";l&&W(l).then(()=>le(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,l=i?.classList.contains("hidden")??!1;F(e),i&&l&&i.classList.remove("hidden");return}if(a.startsWith("table-copy-")){const i=a.replace("table-copy-",""),l=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const d=ce(l),c=i==="csv"?de(d):i==="tsv"?Wt(d):ue(d);W(c)}F(e);return}if(a.startsWith("table-download-")){const i=a.replace("table-download-",""),l=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const d=ce(l),c=i==="csv"?de(d):ue(d);pe(i==="csv"?"table.csv":"table.md",c,i==="csv"?"text/csv":"text/markdown")}F(e);return}if(a==="mermaid-copy"){const i=o.getAttribute("data-md-source")??"";i&&W(i).then(()=>le(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"]'),l=Rt(i);a==="mermaid-zoom-in"?l?.zoomIn():a==="mermaid-zoom-out"?l?.zoomOut():l?.fit();return}if(a==="mermaid-download"){const i=o.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),l=i?.getAttribute("data-md-original-svg")??i?.innerHTML??"";l&&pe("diagram.svg",l,"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},Zt=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),ge=Array.from(Zt).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Ut=e=>nt(e),Xt=e=>rt(e),$=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=$(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=ge.length>0?t.match(new RegExp(`^(.*(?:/|^)(${ge})):.*$`,"i")):null;return s&&(t=s[1]??t),$(t)},Pe=e=>{const t=$(e);if(!t)return null;const n=t.indexOf(";"),r=n>=0?$(t.slice(0,n)):t;if(!r)return null;const s=r.match(/^(.*?):(\d+)-(\d+)$/);if(s){const l=O(s[1]??""),d=Number.parseInt(s[2]??"",10),c=Number.parseInt(s[3]??"",10);return!l||!Number.isFinite(d)||!Number.isFinite(c)||c<d?null:{path:l,line:d,endLine:c}}const o=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(o){const l=O(o[1]??""),d=Number.parseInt(o[2]??"",10),c=o[3]?Number.parseInt(o[3],10):void 0;return!l||!Number.isFinite(d)?null:{path:l,line:d,column:Number.isFinite(c??Number.NaN)?c:void 0}}const a=r.match(/^(.*?):(\d+)(?::(\d+))?$/);if(a){const l=O(a[1]??""),d=Number.parseInt(a[2]??"",10),c=a[3]?Number.parseInt(a[3],10):void 0;return!l||!Number.isFinite(d)?null:{path:l,line:d,column:Number.isFinite(c??Number.NaN)?c: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")??"";ve(i)&&(s.preventDefault(),s.stopPropagation(),ot(i))};return n.addEventListener("click",r),()=>{n.removeEventListener("click",r)}},[e,t])},be='[data-pichamber-file-link="true"]',_e="data-pichamber-block-path-token",Ie=`[${_e}]`,T="data-pichamber-block-paths-scanned",Gt=2e5,Yt=4,Qt=1e3,Jt=80,we=160,L=new Map;let D=0;const ye=[],er=()=>Qt,tr=()=>Jt,rr=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),G=e=>Ut(e),nr=e=>Xt(e),or=(e,t)=>st(e,t),ar=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 rr.has(r)||r.startsWith(".")&&r.length>1?!0:ar(t)},Oe=e=>{const t=Pe(e);return t?Fe(t.path):!1},ir=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()},K=e=>{if(e.tagName.toLowerCase()==="a"){const t=e.getAttribute("href")?.trim();if(t&&Oe(t))return t}return(e.textContent||"").trim()},sr=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>Gt){r.setAttribute(T,"true");continue}const s=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=[];let a=s.nextNode();for(;a;){const c=a;c.parentElement?.closest("[data-md-code-line-number]")||o.push(c),a=s.nextNode()}const i=Te(r);if(!i.includes(".")){r.setAttribute(T,"true");continue}V.lastIndex=0;const l=[];let d=V.exec(i);for(;d;){const c=d[0];c&&Oe(c)&&l.push({start:d.index,end:d.index+c.length,raw:c}),d=V.exec(i)}for(const{start:c,end:m,raw:f}of l.reverse()){const p=he(o,c,"right"),h=he(o,m,"left");if(!p||!h)continue;const A=n.createRange();A.setStart(p.node,p.offset),A.setEnd(h.node,h.offset);const v=n.createElement("span");v.setAttribute(_e,"true"),v.textContent=f,A.deleteContents(),A.insertNode(v)}r.setAttribute(T,"true")}},j=(e,t)=>{const n=Pe(e);if(!n||!Fe(n.path))return null;const r=nr(n.path)?G(n.path):or(t,n.path);return r?{...n,resolvedPath:r}:null},lr=e=>{const t=G(e);if(!t)return Promise.resolve(!1);const n=L.get(t);if(n)return L.delete(t),L.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 l=await i.json().catch(()=>null);o(l?.exists!==!1)}).catch(()=>o(!1)).finally(()=>{D=Math.max(0,D-1),ye.shift()?.()})};if(D<Yt){a();return}ye.push(a)}),s=er();for(;L.size>=s;){const o=L.keys().next().value;if(typeof o!="string")break;L.delete(o)}return L.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 l=tr(),d=s&&!bt(),c=g=>{g.removeAttribute("data-pichamber-file-link"),g.removeAttribute("data-pichamber-file-ref"),g.removeAttribute("data-pichamber-file-path"),g.getAttribute("title")==="Open file"&&g.removeAttribute("title"),g.tagName.toLowerCase()!=="a"&&(g.removeAttribute("role"),g.removeAttribute("tabindex"))},m=()=>{const g=a.querySelectorAll(be);for(const b of Array.from(g))c(b);ir(a)};if(!d){m();return}const f=(g=0)=>{if(o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),typeof window>"u"){p();return}o.current=window.setTimeout(()=>{o.current=null,window.requestAnimationFrame(()=>{i||p()})},g)},p=()=>{d&&sr(a);const g=a.querySelectorAll(`[data-markdown="inline-code"], a, ${Ie}`);let b=0;for(const u of Array.from(g)){const E=K(u),C=j(E,t);if(c(u),!C||b>=l)continue;b+=1,(Ue()&&Xe()&&!re(C.resolvedPath,t)?Promise.resolve(!0):lr(C.resolvedPath)).then(Ke=>{if(i||!Ke||!a.contains(u))return;const J=K(u),H=j(J,t);!H||H.resolvedPath!==C.resolvedPath||(u.setAttribute("data-pichamber-file-link","true"),u.setAttribute("data-pichamber-file-ref",J),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 g=>{const b=g.getAttribute("data-pichamber-file-ref")||K(g),u=j(b,t);if(!u)return;const E=cr(t,u.resolvedPath);re(u.resolvedPath,t)||await at(u.resolvedPath,t);const C=Ae.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)},A=g=>{const b=g.target;if(!(b instanceof Element))return;const u=b.closest(be);u instanceof HTMLElement&&(g.preventDefault(),g.stopPropagation(),h(u))},v=g=>{if(g.key!=="Enter"&&g.key!==" ")return;const b=g.target;!(b instanceof HTMLElement)||b.getAttribute("data-pichamber-file-link")!=="true"||(g.preventDefault(),g.stopPropagation(),h(b))};f(we);const w=new MutationObserver(()=>{f(we)});return w.observe(a,{childList:!0,subtree:!0}),a.addEventListener("click",A),a.addEventListener("keydown",v),()=>{i=!0,o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),o.current=null,w.disconnect(),a.removeEventListener("click",A),a.removeEventListener("keydown",v)}},[e,n,t,r,s])},P={download:!0,copy:!0,showPanZoomControls:!0},qe=!0,ze=({containerRef:e,onShowPopup:t,enableFullscreen:n,enablePanZoom:r,allowMermaidWheelEvents:s})=>{y.useEffect(()=>{const o=e.current;if(!o)return;const a=l=>{if(!t)return;const d=l.target;if(!(d instanceof Element)||d.closest('button, a, [role="button"]'))return;const c=d.closest(I);if(!c)return;if(c instanceof HTMLElement&&c.hasAttribute("data-mermaid-suppress-click")){c.removeAttribute("data-mermaid-suppress-click");return}const f=Array.from(o.querySelectorAll(I)).indexOf(c);if(f<0)return;const p=c instanceof HTMLElement?c.getAttribute("data-md-source"):null;if(!p||p.trim().length===0)return;const h=`Diagram ${f+1}`;t({open:!0,title:h,content:"",metadata:{tool:"mermaid-preview",filename:h},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(p)}`,source:p,filename:h}})},i=l=>{if(s||(l.ctrlKey||l.metaKey)&&r)return;const d=l.target;!(d instanceof Element)||!d.closest(I)||l.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,dr=100,ur=(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>dr){const s=N.keys().next().value;s&&N.delete(s)}return r},mr=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"}),$e=()=>{const e=ct(),t=te(!1),n=te(!0);return e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?n:t)},fr=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=mr(e),a=e.metadata?.id??"theme";return{labels:s,mermaidControls:r,deferCodeLineNumberSync:t,renderMermaid:l=>ur(`${a}:svg:${l}`,()=>{try{return{svg:Ze(l,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=""},Z=(e,t)=>{We(e);const n=pt(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(()=>{yt()},[]);const a=y.useRef(null),i=y.useRef(null),l=y.useRef(r);l.current!==r&&(l.current=r,i.current=null);const d=y.useCallback(()=>{const c=e.current;if(c){if(!a.current){if(!M(c))return;a.current=Dt(c);return}a.current.refresh()}},[e]);y.useLayoutEffect(()=>{const c=e.current,m=c?.querySelector("[data-markdown-content]")??c;if(m&&t&&m.childNodes.length===0){const f=document.createElement("div");if(f.setAttribute("data-md-block",""),f.style.display="contents",n){Z(f,t),m.appendChild(f);return}f.innerHTML=dt(t),fe(f,o),m.appendChild(f),M(f)&&d()}},[e,t,n,o,d]),y.useEffect(()=>()=>{a.current?.cleanup(),a.current=null},[]),y.useEffect(()=>{const c=e.current;if(!c)return;const m=c.querySelector("[data-markdown-content]")??c;let f=!0;if(n&&i.current){const p=ut(r).update(t);if(mt(i.current,p)){const h=p[p.length-1],A=m.querySelectorAll(":scope > [data-md-block]")[p.length-1];if(h&&A){Z(A,h.raw),A.setAttribute("data-md-id",`live:${p.length-1}`),i.current=i.current.map((v,w)=>w===p.length-1?{...v,raw:h.raw,id:`live:${w}`,mode:"live"}:v);return}}}return ft(t,n,r).then(p=>{if(!f)return;const h=Array.from(m.querySelectorAll(":scope > [data-md-block]"));p.forEach((w,g)=>{let b=h[g];if(b||(b=document.createElement("div"),b.setAttribute("data-md-block",""),b.style.display="contents",m.appendChild(b)),w.mode==="live"){Z(b,w.raw),b.setAttribute("data-md-id",w.id);return}if(We(b),b.getAttribute("data-md-id")===w.id)return;const u=document.createElement("div");u.innerHTML=w.html,fe(u,o);const E=M(b),C=M(u);je(b,u,{childrenOnly:!0,onBeforeElUpdated:(Y,Q)=>!Y.isEqualNode(Q)}),b.setAttribute("data-md-id",w.id),(E||C||M(b))&&d()});const A=M(m);let v=!1;for(let w=h.length-1;w>=p.length;w-=1){const g=h[w];g&&M(g)&&(v=!0),g?.remove()}(v||h.length>p.length&&A)&&d(),i.current=p}),()=>{f=!1}},[e,t,n,r,o,d]),y.useEffect(()=>{const c=e.current;if(c)return jt(c,o)},[e,o]),y.useEffect(()=>{const c=e.current,m=c?.querySelector("[data-markdown-content]")??c;if(m)for(const[f,p]of Object.entries(s))m.style.setProperty(f,p)},[e,s]),y.useEffect(()=>{const c=e.current,m=c?.querySelector("[data-markdown-content]")??c;m&&(o.deferCodeLineNumberSync||qt(m))},[e,o.deferCodeLineNumberSync])},Ve=(e,t)=>U("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:l="assistant",onShowPopup:d,enableFileReferences:c=!0})=>{ee("ui.markdown_renderer.render"),a&&ee("ui.markdown_renderer.render.streaming"),Ye("ui.markdown_renderer.content_len",e.length);const m=$e(),{editor:f}=ke(),p=y.useRef(null),h=Ee()??"",A=Ae(C=>C.openContextPreview),v=y.useCallback(C=>{h&&A(h,C)},[h,A]),w=a&&!i;ze({containerRef:p,onShowPopup:d,enableFullscreen:qe,enablePanZoom:P.showPanZoomControls}),De({containerRef:p,effectiveDirectory:h,editor:f,preferRuntimeEditor:!1,enabled:c&&!a}),Re({containerRef:p});const g=y.useMemo(()=>Ce(m),[m]),b=He(m,w,h?v:void 0,P),u=`markdown-${t?.id?`part-${t.id}`:`message-${n}`}`;Be({containerRef:p,text:e,streaming:w,cacheKey:u,syntaxVars:g,ctx:b});const E=_.jsx("div",{className:U("break-words w-full min-w-0",o),ref:p,children:_.jsx("div",{className:Ve(l,w),"data-markdown-content":!0})});return r?_.jsx(lt,{skipAnimation:s,children:E},u):E},Qr=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),hr=({content:e,className:t,variant:n="assistant",disableLinkSafety:r,stripFrontmatter:s=!1,onShowPopup:o,mermaidControls:a=P,allowMermaidWheelEvents:i=!1,enableFileReferences:l=!0})=>{const{editor:d}=ke(),c=$e(),m=y.useRef(null),f=Ee()??"",p=y.useMemo(()=>s?fr(e):e,[e,s]);ze({containerRef:m,onShowPopup:o,enableFullscreen:qe,enablePanZoom:a.showPanZoomControls,allowMermaidWheelEvents:i}),De({containerRef:m,effectiveDirectory:f,editor:d,preferRuntimeEditor:!1,enabled:l}),Re({containerRef:m,enabled:!r});const h=y.useMemo(()=>Ce(c),[c]),A=He(c,!1,void 0,a);return Be({containerRef:m,text:p,streaming:!1,cacheKey:`simple:${n}`,syntaxVars:h,ctx:A}),_.jsx("div",{className:U("break-words w-full min-w-0",t),ref:m,children:_.jsx("div",{className:Ve(n),"data-markdown-content":!0})})},Jr=y.memo(hr,(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{Qr as MarkdownRenderer,Jr as SimpleMarkdownRenderer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{es as j,dR as y,dV as D}from"./useAppFontEffects-BFgKpDYT.js";import{f as k,B as C}from"./web-components-B_NMC-2c.js";import{M as P,G as O,u as L,W as R,a as A,b as M,n as F,t as H}from"./Virtualizer-okhy9Aq3.js";import{j as d}from"./vendor-boot-3SaHYVb1.js";import{V,F as _}from"./VirtualizedFileDiff-D8dSHI_H.js";import{a as w}from"./vendor-react-Bz1tRBxM.js";function N({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function T(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:y,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:k(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:O,children:u(g)})]})}function b(e,t){const n=T(e,t);return n!=null?N({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=L(),m=l!==void 0,p=w.useContext(R),c=A(),i=w.useRef(null),v=M(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 V(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 _(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(D,{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{aR as Se,j as z}from"./vendor-boot-3SaHYVb1.js";import{a as f,R as ae}from"./vendor-react-Bz1tRBxM.js";import{B as Ee}from"./web-components-CkTNGkJ2.js";import{f as ce}from"./computeVirtualFileMetrics-8MuwxSC6.js";import{V as ke,F as xe}from"./VirtualizedFileDiff-BYby097w.js";import{ar as Te,aP as Oe}from"./useAppFontEffects-Oyin3dgQ.js";import{P as ze,S as De}from"./StickyHorizontalScrollbar-DNsbTLS7.js";import{aY as Ce}from"./runtimeEndpointReset-aGyXPXPs.js";import{ensurePierreThemeRegistered as he,getResolvedShikiTheme as ue}from"./appThemeRegistry-Ca8eGRB9.js";import{A as de,f as fe}from"./index-Cs2nBW_t.js";const J=new Set;let ne=null;function E(n){J.add(n),ne??=requestAnimationFrame(be)}function be(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(be):ne=null}function pe({scrollTop:n,scrollHeight:e,height:t,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:s}){const u=t+s*2,d=r?t+i*2:u;if(e=Math.max(e,d),u>=e||r){const p=Math.max(n-i,0),y=Math.min(n+d,e);return{top:p,bottom:Math.max(y,p)}}let c=n+t/2-u/2,m=c+u;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 Ie(n,e){return n==null||e==null?n===e:n.top===e.top&&n.bottom===e.bottom}const ye=1e3,Me=ye*4,He=[0,1e-6,.99999,1],Pe={overscrollSize:ye,intersectionObserverMargin:Me,resizeDebugging:!1};let Z=0,Le=-1;var _e=class x{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++Le}`;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={...Pe,...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:He,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=pe({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,u=r-s,d=r+i+s;return!(e<u-t||e>d)}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=pe({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!e&&Ie(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:u,fileTypeOffset:d}=e;if(r!=null&&i!=null){const m=s.shadowRoot?.querySelector(`[data-line][data-line-index="${r}"]`);if(m instanceof HTMLElement){const p=U(m,t);if(p!==i){const y=p-i;this.applyScrollFix(y)}return}}const c=U(s,t);if(d==="top")c!==u&&this.applyScrollFix(c-u);else{const m=c+s.getBoundingClientRect().height;m!==u&&this.applyScrollFix(m-u)}}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),u=s+i.offsetHeight;let d,c;u<=0?(d=u,c="bottom"):(d=s,c="top");let m,p;if(u>0&&s<e)for(const w of i.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(w instanceof HTMLElement))continue;const W=w.dataset.lineIndex;if(W==null)continue;const D=U(w,t);if(!(D<0)){m=W,p=D;break}}if(r?.lineOffset!=null&&p==null)continue;let y=!1;(r==null||p!=null&&(r.lineOffset==null||p<r.lineOffset)||p==null&&r.lineOffset==null&&(d>=0&&(r.fileOffset<0||d<r.fileOffset)||d<0&&r.fileOffset<0&&d>r.fileOffset))&&(y=!0),y&&(r={fileElement:i,fileTypeOffset:c,fileOffset:d,lineIndex:m,lineOffset:p})}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 ge=5e5,Fe=`
|
|
1
|
+
import{aR as Se,j as z}from"./vendor-boot-3SaHYVb1.js";import{a as f,R as ae}from"./vendor-react-Bz1tRBxM.js";import{B as Ee}from"./web-components-B_NMC-2c.js";import{f as ce}from"./computeVirtualFileMetrics-g1aOl5nF.js";import{V as ke,F as xe}from"./VirtualizedFileDiff-D8dSHI_H.js";import{ar as Te,aP as Oe}from"./useAppFontEffects-BFgKpDYT.js";import{P as ze,S as De}from"./StickyHorizontalScrollbar-DNsbTLS7.js";import{aX as Ce}from"./runtimeEndpointReset-Bby2E_Je.js";import{ensurePierreThemeRegistered as he,getResolvedShikiTheme as ue}from"./appThemeRegistry-Ca8eGRB9.js";import{A as de,f as fe}from"./index-fmzQmSSv.js";const J=new Set;let ne=null;function E(n){J.add(n),ne??=requestAnimationFrame(be)}function be(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(be):ne=null}function pe({scrollTop:n,scrollHeight:e,height:t,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:s}){const u=t+s*2,d=r?t+i*2:u;if(e=Math.max(e,d),u>=e||r){const p=Math.max(n-i,0),y=Math.min(n+d,e);return{top:p,bottom:Math.max(y,p)}}let c=n+t/2-u/2,m=c+u;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 Ie(n,e){return n==null||e==null?n===e:n.top===e.top&&n.bottom===e.bottom}const ye=1e3,Me=ye*4,He=[0,1e-6,.99999,1],Pe={overscrollSize:ye,intersectionObserverMargin:Me,resizeDebugging:!1};let X=0,Le=-1;var _e=class x{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++Le}`;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={...Pe,...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:He,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=pe({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,u=r-s,d=r+i+s;return!(e<u-t||e>d)}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=pe({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!e&&Ie(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:u,fileTypeOffset:d}=e;if(r!=null&&i!=null){const m=s.shadowRoot?.querySelector(`[data-line][data-line-index="${r}"]`);if(m instanceof HTMLElement){const p=U(m,t);if(p!==i){const y=p-i;this.applyScrollFix(y)}return}}const c=U(s,t);if(d==="top")c!==u&&this.applyScrollFix(c-u);else{const m=c+s.getBoundingClientRect().height;m!==u&&this.applyScrollFix(m-u)}}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),u=s+i.offsetHeight;let d,c;u<=0?(d=u,c="bottom"):(d=s,c="top");let m,p;if(u>0&&s<e)for(const w of i.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(w instanceof HTMLElement))continue;const W=w.dataset.lineIndex;if(W==null)continue;const D=U(w,t);if(!(D<0)){m=W,p=D;break}}if(r?.lineOffset!=null&&p==null)continue;let y=!1;(r==null||p!=null&&(r.lineOffset==null||p<r.lineOffset)||p==null&&r.lineOffset==null&&(d>=0&&(r.fileOffset<0||d<r.fileOffset)||d<0&&r.fileOffset<0&&d>r.fileOffset))&&(y=!0),y&&(r={fileElement:i,fileTypeOffset:c,fileOffset:d,lineIndex:m,lineOffset:p})}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 ge=5e5,Fe=`
|
|
2
2
|
:host {
|
|
3
3
|
font-family: var(--font-mono);
|
|
4
4
|
font-size: var(--text-code);
|
|
@@ -143,5 +143,5 @@ import{aR as Se,j as z}from"./vendor-boot-3SaHYVb1.js";import{a as f,R as ae}fro
|
|
|
143
143
|
text-decoration: underline;
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
`;function Ae(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 ve(n){const e=n.length>400?`${n.slice(0,200)}${n.slice(-200)}`:n;return`${n.length}:${Ae(e)}`}const Ve=n=>n==="auto"||n==="scroll"||n==="overlay",$e=n=>{let e=n?.parentElement??null;for(;e;){const t=window.getComputedStyle(e);if(Ve(t.overflowY))return e;e=e.parentElement}return null},qe=(n,e)=>{if(!n||!e||typeof window>"u")return()=>{};const t=$e(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 u=!1;return()=>{if(u)return;u=!0,e.style.minHeight=s;const c=n.getBoundingClientRect().top-t.getBoundingClientRect().top-i;c&&(t.scrollTop+=c)}},We=(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()})}))},u=()=>n.querySelector("diffs-container")?.shadowRoot??void 0,d=(c=u())=>!!c?.querySelector("[data-line]");return d()?s():typeof MutationObserver<"u"?(r=new MutationObserver(()=>{const c=u();if(c){if(d(c)){s();return}r?.disconnect(),r=new MutationObserver(()=>{d(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)}},
|
|
146
|
+
`;function Ae(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 ve(n){const e=n.length>400?`${n.slice(0,200)}${n.slice(-200)}`:n;return`${n.length}:${Ae(e)}`}const Ve=n=>n==="auto"||n==="scroll"||n==="overlay",$e=n=>{let e=n?.parentElement??null;for(;e;){const t=window.getComputedStyle(e);if(Ve(t.overflowY))return e;e=e.parentElement}return null},qe=(n,e)=>{if(!n||!e||typeof window>"u")return()=>{};const t=$e(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 u=!1;return()=>{if(u)return;u=!0,e.style.minHeight=s;const c=n.getBoundingClientRect().top-t.getBoundingClientRect().top-i;c&&(t.scrollTop+=c)}},We=(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()})}))},u=()=>n.querySelector("diffs-container")?.shadowRoot??void 0,d=(c=u())=>!!c?.querySelector("[data-line]");return d()?s():typeof MutationObserver<"u"?(r=new MutationObserver(()=>{const c=u();if(c){if(d(c)){s();return}r?.disconnect(),r=new MutationObserver(()=>{d(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,Be={lineHeight:24,hunkSeparatorHeight:24,spacing:0};function Ne(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 je(n){if(typeof document>"u")return null;const e=Ne(n);let t=Z.get(e.key);if(!t){const i=new _e;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 Ue=(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)}},nt=({original:n,modified:e,fileDiff:t,language:r,fileName:i,renderSideBySide:s,wrapLines:u,layout:d="fill",enableGutterUtility:c=!1,enableLineSelection:m=!1,onGutterUtilityClick:p,onLineSelectionEnd:y,lineAnnotations:w,renderAnnotation:W})=>{const D=Te(),C=D?.currentTheme.metadata.variant==="dark",_=D?.availableThemes.find(o=>o.metadata.id===D.lightThemeId)??de(!1),F=D?.availableThemes.find(o=>o.metadata.id===D.darkThemeId)??de(!0);he(_),he(F);const B=`${_.metadata.id}:${F.metadata.id}:${C?"dark":"light"}`,N=f.useMemo(()=>{if(t){const o=t.deletionLines.reduce((a,h)=>a+h.length,0),l=t.additionLines.reduce((a,h)=>a+h.length,0);return Math.max(o,l)>ge}return Math.max(n.length,e.length)>ge},[t,e.length,n.length]),K=f.useRef(null),A=f.useRef(null),V=f.useRef(null),j=f.useRef(null),ee=f.useRef(null),te=f.useRef(null),re=f.useRef(void 0),Q=f.useRef(void 0),Y=f.useRef(void 0),G=f.useRef(void 0),[,se]=ae.useReducer(o=>o+1,0),$=Ce(N?"unified":s?"split":"unified"),I=f.useRef(new Map),ie=f.useRef(W);ie.current=W;const oe=o=>`${o.side}:${o.lineNumber}`,le=f.useCallback(o=>{if(typeof document>"u")return;const l=`${o.side}:${o.lineNumber}`;let a=I.current.get(l);if(!a){const h=document.createElement("div");h.setAttribute("data-pichamber-line-annotation",l),a={root:Se.createRoot(h),element:h},I.current.set(l,a)}return a.root.render(ie.current?.(o)??null),a.element},[]);f.useEffect(()=>{if(!w){for(const[,a]of I.current)a.root.unmount();I.current.clear();return}const o=new Set(w.map(oe));for(const[a,h]of I.current)o.has(a)||(h.root.unmount(),I.current.delete(a));const l=ie.current;if(l)for(const a of w){const h=I.current.get(oe(a));h&&h.root.render(l(a))}},[w]),f.useEffect(()=>{const o=I.current;return()=>{for(const l of o.values())l.root.unmount();o.clear()}},[]);const T=f.useMemo(()=>ue(_),[_]),O=f.useMemo(()=>ue(F),[F]);ae.useLayoutEffect(()=>{const o=K.current;if(!o)return;const l=o.querySelector("diffs-container");if(!l)return;const a=C?O:T,h=(we,Re)=>we.colors?.[Re],R=h(T,"terminal.ansiGreen"),v=h(T,"terminal.ansiRed"),b=h(T,"terminal.ansiBlue"),P=h(O,"terminal.ansiGreen"),k=h(O,"terminal.ansiRed"),M=h(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),M&&l.style.setProperty("--shiki-dark-modified-color",M),l.style.setProperty("--diffs-bg",a.bg),l.style.setProperty("--diffs-fg",a.fg);const S=C?P:R,L=C?k:v,q=C?M:b;S&&l.style.setProperty("--diffs-addition-color-override",S),L&&l.style.setProperty("--diffs-deletion-color-override",L),q&&l.style.setProperty("--diffs-modified-color-override",q);const g=l.shadowRoot?.querySelector("pre");g&&(g.style.setProperty("--shiki-light",T.fg),g.style.setProperty("--shiki-light-bg",T.bg),R&&g.style.setProperty("--shiki-light-addition-color",R),v&&g.style.setProperty("--shiki-light-deletion-color",v),b&&g.style.setProperty("--shiki-light-modified-color",b),g.style.setProperty("--shiki-dark",O.fg),g.style.setProperty("--shiki-dark-bg",O.bg),P&&g.style.setProperty("--shiki-dark-addition-color",P),k&&g.style.setProperty("--shiki-dark-deletion-color",k),M&&g.style.setProperty("--shiki-dark-modified-color",M),g.style.setProperty("--diffs-bg",a.bg),g.style.setProperty("--diffs-fg",a.fg),S&&g.style.setProperty("--diffs-addition-color-override",S),L&&g.style.setProperty("--diffs-deletion-color-override",L),q&&g.style.setProperty("--diffs-modified-color-override",q))},[O,B,C,T]);const H=f.useMemo(()=>({theme:{dark:F.metadata.id,light:_.metadata.id},themeType:C?"dark":"light",diffStyle:s?"split":"unified",diffIndicators:"classic",hunkSeparators:"line-info-basic",lineDiffType:"none",maxLineDiffLength:N?0:1e3,maxLineLengthForHighlighting:N?1:1e3,tokenizeMaxLineLength:N?1:1e3,collapsedContextThreshold:0,expansionLineCount:20,overflow:u?"wrap":"scroll",disableFileHeader:!0,enableLineSelection:m,enableGutterUtility:c,enableHoverUtility:!1,...p?{onGutterUtilityClick:p}:{},...y?{onLineSelectionEnd:y}:{},renderAnnotation:le,unsafeCSS:d==="inline"?`${me}
|
|
147
147
|
${ze}`:me}),[le,F.metadata.id,c,m,C,N,d,_.metadata.id,p,y,s,u]);return f.useEffect(()=>{const o=A.current;return()=>{V.current?.cleanUp(),V.current=null,j.current?.release(),j.current=null,ee.current=null,te.current=null,re.current=void 0,Q.current=void 0,Y.current=void 0,G.current=void 0,o&&(o.innerHTML="")}},[]),f.useEffect(()=>{if(typeof window>"u")return;const o=A.current,l=K.current;if(!o||!$)return;const a=qe(l,o);let h=j.current;h||(h=je(o),j.current=h),j.current=h;const R=h?.virtualizer??null,v=t?void 0:{name:i||"",contents:n,lang:r,cacheKey:`old:${B}:${i}:${ve(n)}`},b=t?void 0:{name:i||"",contents:e,lang:r,cacheKey:`new:${B}:${i}:${ve(e)}`},P=t?Q.current!==t:Q.current!==void 0||!v||!b||!Y.current||!G.current||!ce(Y.current,v)||!ce(G.current,b),k=V.current,M=!!(k&&(ee.current!==R||te.current!==$||R&&(re.current!==H.hunkSeparators||P)));M&&(k?.cleanUp(),V.current=null,o.innerHTML="");let S=V.current;const L=!M&&k?!Ee(k.options,H):!1;if(S?S.setOptions(H):(S=h?new ke(H,h.virtualizer,Be,$):new xe(H,$),V.current=S),ee.current=R,te.current=$,re.current=R?H.hunkSeparators:void 0,Q.current=t,Y.current=v,G.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 q=We(o,()=>{a(),Ue(S,h,se)});return()=>{q(),a()}},[B,t,i,r,w,e,H,n,$]),f.useEffect(()=>{const o=A.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()}},[B,i]),typeof window>"u"?null:d==="fill"?z.jsx("div",{className:fe("flex flex-col relative","size-full"),"data-diff-virtual-root":!0,children:z.jsx("div",{className:"flex-1 relative min-h-0",children:z.jsx(Oe,{outerClassName:"pierre-diff-wrapper size-full",disableHorizontal:!1,fillContainer:!0,"data-diff-virtual-content":!0,children:z.jsx("div",{ref:K,className:"size-full relative",children:z.jsx("div",{ref:A,className:"size-full"})})})})}):z.jsx("div",{className:fe("relative","w-full"),children:z.jsxs("div",{ref:K,className:"pierre-diff-wrapper w-full relative","data-no-drawer-swipe":"true",children:[z.jsx("div",{ref:A,className:"w-full"}),z.jsx(De,{hostRef:A,enabled:!u})]})})};export{nt as P};
|