@pi-chamber/web 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/bin/cli.js +5 -2
  2. package/bin/cli.test.js +44 -0
  3. package/bin/lib/DOCUMENTATION.md +5 -5
  4. package/bin/lib/cli-args.js +19 -4
  5. package/bin/lib/commands-lifecycle.js +14 -0
  6. package/bin/lib/commands-logs.js +2 -1
  7. package/bin/lib/commands-serve.js +166 -2
  8. package/bin/lib/commands-tunnel.js +21 -0
  9. package/bin/lib/commands-update.js +97 -33
  10. package/bin/lib/commands-update.test.js +96 -1
  11. package/dist/assets/{DiagramEditor-D_3eJVSw.js → DiagramEditor-CcbnMl1H.js} +1 -1
  12. package/dist/assets/{DiagramView-pGYm0-DR.js → DiagramView-DTW5jwK3.js} +1 -1
  13. package/dist/assets/DiffView-CZyHHAOB.js +18 -0
  14. package/dist/assets/FilesView-BJYLFR3H.js +6 -0
  15. package/dist/assets/GitView-Cg_5UU7E.js +8 -0
  16. package/dist/assets/{JsonTreeView-CpgqCk9_.js → JsonTreeView-GTdKGEdy.js} +1 -1
  17. package/dist/assets/{MarkdownRendererImpl-fI6n3kqT.js → MarkdownRendererImpl-WqBwxlso.js} +1 -1
  18. package/dist/assets/{PatchDiff-BRloGXPs.js → PatchDiff-BRi23N1l.js} +1 -1
  19. package/dist/assets/{SessionSwitcherContent-BQc-vW4s.js → SessionSwitcherContent-7VAU5pwZ.js} +1 -1
  20. package/dist/assets/{SessionSwitcherDropdown-v_8TaIZm.js → SessionSwitcherDropdown-BslRtccE.js} +2 -2
  21. package/dist/assets/{SessionUnreadDot-A7vSfll2.js → SessionUnreadDot-1nV0Z2ZA.js} +1 -1
  22. package/dist/assets/SettingsView-UIaAyjTo.js +2 -0
  23. package/dist/assets/{SettingsWindow-D7UDhYd4.js → SettingsWindow-D4jZHl8X.js} +1 -1
  24. package/dist/assets/{ToolOutputDialog-wpU0ylYS.js → ToolOutputDialog-BoeJONiR.js} +1 -1
  25. package/dist/assets/{ToolPartDiffPreview-BvoQK5Gm.js → ToolPartDiffPreview-9FLv2fWD.js} +1 -1
  26. package/dist/assets/{VirtualizedFileDiff-DdPbLdh7.js → VirtualizedFileDiff-ywmPBXAG.js} +4 -4
  27. package/dist/assets/{collapsible-BO6FIjvn.js → collapsible-6mCYf7Ky.js} +1 -1
  28. package/dist/assets/{computeVirtualFileMetrics-DMvXzUJh.js → computeVirtualFileMetrics-3H6mg13G.js} +1 -1
  29. package/dist/assets/{contextFileOpenGuard-BwXQVjtS.js → contextFileOpenGuard-CKyf-TZ7.js} +1 -1
  30. package/dist/assets/gitStatusPredicates-UsytDMy_.js +134 -0
  31. package/dist/assets/index-C8NYcA8-.css +1 -0
  32. package/dist/assets/{index-C3SyF-cA.js → index-D1IaU-Q7.js} +1 -1
  33. package/dist/assets/index-yWgKW2Fx.js +8 -0
  34. package/dist/assets/{isDiffPlainText-BboRbmcm.js → isDiffPlainText-DPCilEx_.js} +1 -1
  35. package/dist/assets/{isFilePlainText-BpTnLRyI.js → isFilePlainText-XdCAgm8R.js} +1 -1
  36. package/dist/assets/main-DcAMXRSi.js +135 -0
  37. package/dist/assets/{main-xLwCWLu-.js → main-DhvLreEl.js} +2 -2
  38. package/dist/assets/{markdownCore-CmFv4H-w.js → markdownCore-BF0Dqwm4.js} +1 -1
  39. package/dist/assets/{miniChat-Vwo4K1IK.js → miniChat-DsCx0dsW.js} +2 -2
  40. package/dist/assets/{mobile-BRaxtEoC.js → mobile-C-IN49xX.js} +2 -2
  41. package/dist/assets/{renderElectronMiniChatApp-DM4rRUUz.js → renderElectronMiniChatApp-C13HXGZL.js} +2 -2
  42. package/dist/assets/renderMobileApp-xCdVzvyf.js +11 -0
  43. package/dist/assets/runtimeEndpointReset-CT3WShpj.js +54 -0
  44. package/dist/assets/{runtimeSurface-SmPSdfop.js → runtimeSurface-C_3mcJ01.js} +1 -1
  45. package/dist/assets/{useAppFontEffects-Bg-8jtrQ.js → useAppFontEffects-BgK55NDM.js} +105 -105
  46. package/dist/assets/{useFilesViewSearch-GLcYNIUV.js → useFilesViewSearch-CWx24PZg.js} +1 -1
  47. package/dist/assets/{usePushVisibilityBeacon-VSYBfNoY.js → usePushVisibilityBeacon-swMQLm-i.js} +1 -1
  48. package/dist/assets/{useSwitcherItems-BkEt9K-N.js → useSwitcherItems-CrS-F6DY.js} +1 -1
  49. package/dist/assets/{vendor-codemirror-language-data-B5cJDWBR.js → vendor-codemirror-language-data-BzeePAPn.js} +2 -2
  50. package/dist/assets/{vendor-dnd-kit-core-CP8ck10N.js → vendor-dnd-kit-core-C9qcAm_1.js} +1 -1
  51. package/dist/assets/{vendor-dnd-kit-sortable-B-Icjoj4.js → vendor-dnd-kit-sortable-D8ozj8M-.js} +1 -1
  52. package/dist/assets/vendor-xterm-addon-fit-DX4qG4td.js +1 -0
  53. package/dist/assets/vendor-xterm-xterm-CrXqRur4.js +16 -0
  54. package/dist/assets/vendor-xterm-xterm-DDGTF8rc.css +1 -0
  55. package/dist/assets/{web-components-0H9kvZwn.js → web-components-DAkBDXRk.js} +3 -3
  56. package/dist/index.html +4 -4
  57. package/dist/mini-chat.html +3 -3
  58. package/dist/mobile.html +3 -3
  59. package/package.json +1 -2
  60. package/server/lib/pi/routes.test.js +39 -0
  61. package/server/lib/pi/session-daemon/DOCUMENTATION.md +1 -1
  62. package/server/lib/pi/session-daemon/extension-bridge.js +14 -11
  63. package/server/lib/pi/session-daemon/prompt-operations.test.js +73 -6
  64. package/server/lib/pi/session-daemon/session-daemon.js +163 -21
  65. package/server/lib/relay/host-client.test.js +3 -1
  66. package/server/lib/stt/DOCUMENTATION.md +1 -1
  67. package/server/lib/terminal/DOCUMENTATION.md +2 -2
  68. package/server/lib/ui-auth/DOCUMENTATION.md +1 -1
  69. package/server/lib/ui-auth/ui-auth.js +23 -26
  70. package/server/lib/ui-auth/ui-auth.test.js +27 -0
  71. package/dist/assets/DiffView-BApPTLGp.js +0 -18
  72. package/dist/assets/FilesView-CiPpuGiF.js +0 -6
  73. package/dist/assets/GitView-uW3w_LlQ.js +0 -8
  74. package/dist/assets/SettingsView-CphlZvfd.js +0 -2
  75. package/dist/assets/gitStatusPredicates-CgNk6M2_.js +0 -134
  76. package/dist/assets/index-BebQicw3.css +0 -1
  77. package/dist/assets/index-Bkz23mZq.js +0 -8
  78. package/dist/assets/main-CMOAwZnJ.js +0 -135
  79. package/dist/assets/renderMobileApp-DWWewNhc.js +0 -11
  80. package/dist/assets/runtimeEndpointReset-BF60eHSx.js +0 -54
  81. package/dist/assets/vendor-ghostty-web-CrxinGGH.js +0 -13
@@ -0,0 +1,134 @@
1
+ import{R as Q,j as o,r as v}from"./vendor-react-B5Z1Mdn3.js";import{D as fe,a as ge,I as pe,b as me,ao as ve,ap as N,i as be,aq as ye}from"./useAppFontEffects-BgK55NDM.js";import{a as we}from"./web-components-DAkBDXRk.js";import{l as ee}from"./computeVirtualFileMetrics-3H6mg13G.js";import{V as xe,F as Re}from"./VirtualizedFileDiff-ywmPBXAG.js";import{u as Se}from"./runtimeEndpointReset-CT3WShpj.js";import{ensurePierreThemeRegistered as te,getResolvedShikiTheme as ne}from"./appThemeRegistry-gegrE2dq.js";import{g as ie,c as re}from"./index-yWgKW2Fx.js";const G=new Set;let X=null;function E(r){G.add(r),X??=requestAnimationFrame(ce)}function ce(r){const e=new Set(G);G.clear();for(const t of e)try{t(r)}catch(n){console.error(n)}G.size>0?X=requestAnimationFrame(ce):X=null}function se({scrollTop:r,scrollHeight:e,height:t,fitPerfectly:n=!1,fitPerfectlyOverscroll:i=0,overscrollSize:s}){const a=t+s*2,d=n?t+i*2:a;if(e=Math.max(e,d),a>=e||n){const f=Math.max(r-i,0),p=Math.min(r+d,e);return{top:f,bottom:Math.max(p,f)}}let l=r+t/2-a/2,u=l+a;return l<0&&(l=0),u>e&&(u=e),l=Math.floor(Math.max(l,0)),{top:l,bottom:Math.ceil(Math.max(Math.min(u,e),l))}}function ke(r,e){return r==null||e==null?r===e:r.top===e.top&&r.bottom===e.bottom}const de=1e3,Ee=de*4,Te=[0,1e-6,.99999,1],Oe={overscrollSize:de,intersectionObserverMargin:Ee,resizeDebugging:!1};let $=0,De=-1;var ze=class D{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++De}`;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={...Oe,...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:Te,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),e instanceof Document?this.setupWindow():this.setupElement(t),window.__INSTANCE=this,window.__TOGGLE=()=>{D.__STOP?(D.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:D.__lastScrollPosition}),E(this.computeRenderRangeAndEmit)):(D.__lastScrollPosition=this.getScrollTop(),D.__STOP=!0)};for(const[n,i]of this.connectQueue.entries())this.connect(n,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=se({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize})),this.windowSpecs}isInstanceVisible(e,t){const n=this.getScrollTop(),i=this.getHeight(),s=this.config.intersectionObserverMargin,a=n-s,d=n+i+s;return!(e<a-t||e>d)}handleContainerResize=e=>{if(this.root==null)return;let t=!1;for(const n of e){const i=n.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-$,newSize:i}),$=i)):n.target===this.root?i!==this.height&&(this.heightDirty=!0,t=!0):n.target===this.contentContainer&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: scroller size change",this.__id,{sizeChange:i-$,newSize:i}),$=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()+V(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=()=>{D.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,E(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{D.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{D.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(D.__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=se({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!e&&ke(this.windowSpecs,s)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty)return;this.windowSpecs=s}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;const n=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(n);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:n,lineOffset:i,fileElement:s,fileOffset:a,fileTypeOffset:d}=e;if(n!=null&&i!=null){const u=s.shadowRoot?.querySelector(`[data-line][data-line-index="${n}"]`);if(u instanceof HTMLElement){const f=V(u,t);if(f!==i){const p=f-i;this.applyScrollFix(p)}return}}const l=V(s,t);if(d==="top")l!==a&&this.applyScrollFix(l-a);else{const u=l+s.getBoundingClientRect().height;u!==a&&this.applyScrollFix(u-a)}}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 n;for(const[i]of this.visibleInstances.entries()){const s=V(i,t),a=s+i.offsetHeight;let d,l;a<=0?(d=a,l="bottom"):(d=s,l="top");let u,f;if(a>0&&s<e)for(const k of i.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(k instanceof HTMLElement))continue;const T=k.dataset.lineIndex;if(T==null)continue;const w=V(k,t);if(!(w<0)){u=T,f=w;break}}if(n?.lineOffset!=null&&f==null)continue;let p=!1;(n==null||f!=null&&(n.lineOffset==null||f<n.lineOffset)||f==null&&n.lineOffset==null&&(d>=0&&(n.fileOffset<0||d<n.fileOffset)||d<0&&n.fileOffset<0&&d>n.fileOffset))&&(p=!0),p&&(n={fileElement:i,fileTypeOffset:l,fileOffset:d,lineIndex:u,lineOffset:f})}return n}handleIntersectionChange=e=>{this.scrollDirty=!0;for(const{target:t,isIntersecting:n}of e){if(!(t instanceof HTMLElement))throw new Error("Virtualizer.handleIntersectionChange: target not an HTMLElement");const i=this.observers.get(t);i!=null&&(n&&!this.visibleInstances.has(t)?(i.setVisibility(!0),this.visibleInstances.set(t,i),this.visibleInstancesDirty=!0):!n&&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 V(r,e){const t=r.getBoundingClientRect(),n=e?.getBoundingClientRect().top??0;return t.top-n}const Ye=Q.memo(function({scope:e,isGitRepo:t,branchAvailable:n,allCount:i,workingCount:s,stagedCount:a,turnCount:d,branchCount:l,onScopeChange:u}){const[f,p]=Q.useState(!1),k=e==="all"?i:e==="staged"?a:e==="turn"?d:e==="branch"?l:s,T=e==="staged"?"Staged":e==="turn"?"Last turn":e==="branch"?"Branch":e==="all"?"All":"Changed";return o.jsxs(fe,{open:f,onOpenChange:p,children:[o.jsx(ge,{asChild:!0,children:o.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":"Select change mode",children:[o.jsxs("span",{className:"whitespace-nowrap",children:[T,o.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",k]})]}),o.jsx(pe,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"})]})}),o.jsx(me,{align:"start",className:"w-40",children:o.jsxs(ve,{value:e,onValueChange:w=>{(w==="all"||w==="working"||w==="staged"||w==="turn"||w==="branch")&&(u?.(w),p(!1))},children:[t!==!1?o.jsx(N,{value:"all",children:o.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[o.jsx("span",{children:"All"}),o.jsx("span",{className:"typography-meta text-muted-foreground",children:i})]})}):null,t!==!1?o.jsx(N,{value:"working",children:o.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[o.jsx("span",{children:"Changed"}),o.jsx("span",{className:"typography-meta text-muted-foreground",children:s})]})}):null,t!==!1?o.jsx(N,{value:"staged",children:o.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[o.jsx("span",{children:"Staged"}),o.jsx("span",{className:"typography-meta text-muted-foreground",children:a})]})}):null,o.jsx(N,{value:"turn",children:o.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[o.jsx("span",{children:"Last turn"}),o.jsx("span",{className:"typography-meta text-muted-foreground",children:d})]})}),n?o.jsx(N,{value:"branch",children:o.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[o.jsx("span",{children:"Branch"}),o.jsx("span",{className:"typography-meta text-muted-foreground",children:l})]})}):null]})})]})}),oe=5e5,Ce=`
2
+ :host {
3
+ font-family: var(--font-mono);
4
+ font-size: var(--text-code);
5
+ }
6
+
7
+ pre, [data-code] {
8
+ font-family: var(--font-mono);
9
+ font-size: var(--text-code);
10
+ }
11
+
12
+ /* Mobile touch selection support */
13
+ [data-line-number] {
14
+ touch-action: manipulation;
15
+ -webkit-tap-highlight-color: transparent;
16
+ cursor: pointer;
17
+ }
18
+
19
+ /* Ensure interactive line numbers work on touch */
20
+ pre[data-interactive-line-numbers] [data-line-number] {
21
+ touch-action: manipulation;
22
+ }
23
+ `,Me=`
24
+ ${Ce}
25
+
26
+ :host {
27
+ --diffs-bg-separator-override: var(--surface-elevated);
28
+ }
29
+
30
+ [data-diff-header],
31
+ [data-diff] {
32
+ [data-separator] {
33
+ height: 24px !important;
34
+ }
35
+ }
36
+
37
+ [data-separator="line-info-basic"] {
38
+ height: 24px !important;
39
+ background: var(--diffs-bg) !important;
40
+ position: relative;
41
+ }
42
+
43
+ [data-diff-type="single"] [data-gutter],
44
+ [data-diff-type="split"] [data-deletions] [data-gutter] {
45
+ [data-separator-wrapper] {
46
+ position: absolute;
47
+ left: 100%;
48
+ display: flex;
49
+ align-items: center;
50
+ gap: unset;
51
+ width: max-content;
52
+ background: transparent;
53
+ color: var(--diffs-fg-number);
54
+ font-family: var(--diffs-header-font-family, var(--font-sans));
55
+ font-size: 0.75rem;
56
+ line-height: 1;
57
+ margin-left: calc(-2ch - 2px);
58
+ }
59
+
60
+ [data-separator-wrapper][data-separator-multi-button] {
61
+ margin-left: calc(-3ch - 2px);
62
+ }
63
+
64
+ [data-expand-button],
65
+ [data-separator-content] {
66
+ display: block;
67
+ align-self: unset;
68
+ min-width: unset;
69
+ min-height: unset;
70
+ padding: 0;
71
+ flex-shrink: 0;
72
+ grid-column: unset;
73
+ border: none;
74
+ width: auto;
75
+ height: auto;
76
+ background-color: transparent;
77
+ color: inherit;
78
+ font: inherit;
79
+ }
80
+
81
+ [data-expand-button]:not([data-expand-all-button]) {
82
+ &[data-expand-down]::before {
83
+ content: '\\2191';
84
+ }
85
+
86
+ &[data-expand-up]::before {
87
+ content: '\\2193';
88
+ }
89
+
90
+ &[data-expand-both]::before {
91
+ content: '\\2195';
92
+ }
93
+
94
+ svg {
95
+ display: none;
96
+ }
97
+ }
98
+
99
+ [data-separator-content] {
100
+ background: transparent;
101
+ margin-left: calc(2px + 1ch);
102
+ }
103
+
104
+ [data-expand-all-button] {
105
+ position: relative;
106
+ margin-left: 14px;
107
+ text-transform: lowercase;
108
+ }
109
+
110
+ [data-expand-all-button]::before {
111
+ content: '';
112
+ display: block;
113
+ position: absolute;
114
+ top: 50%;
115
+ left: -8px;
116
+ margin-top: -1px;
117
+ width: 3px;
118
+ height: 3px;
119
+ border-radius: 2px;
120
+ background-color: var(--diffs-fg-number);
121
+ pointer-events: none;
122
+ }
123
+
124
+ [data-separator-content]:hover,
125
+ [data-expand-button]:hover,
126
+ [data-expand-all-button]:hover {
127
+ color: var(--diffs-fg);
128
+ }
129
+
130
+ [data-expand-all-button]:hover {
131
+ text-decoration: underline;
132
+ }
133
+ }
134
+ `;function Ie(r){let e=2166136261;for(let t=0;t<r.length;t+=1)e^=r.charCodeAt(t),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return e.toString(16)}function le(r){const e=r.length>400?`${r.slice(0,200)}${r.slice(-200)}`:r;return`${r.length}:${Ie(e)}`}const He=r=>r==="auto"||r==="scroll"||r==="overlay",Pe=r=>{let e=r?.parentElement??null;for(;e;){const t=window.getComputedStyle(e);if(He(t.overflowY))return e;e=e.parentElement}return null},Le=(r,e)=>{if(!r||!e||typeof window>"u")return()=>{};const t=Pe(r);if(!t)return()=>{};const n=e.getBoundingClientRect().height;if(!n)return()=>{};const i=r.getBoundingClientRect().top-t.getBoundingClientRect().top,s=e.style.minHeight;e.style.minHeight=`${Math.ceil(n)}px`;let a=!1;return()=>{if(a)return;a=!0,e.style.minHeight=s;const l=r.getBoundingClientRect().top-t.getBoundingClientRect().top-i;l&&(t.scrollTop+=l)}},Ae=(r,e)=>{if(typeof window>"u")return()=>{};let t=null,n=null,i=!1;const s=()=>{i||(n?.disconnect(),n=null,t=window.requestAnimationFrame(()=>{t=window.requestAnimationFrame(()=>{i||e()})}))},a=()=>r.querySelector("diffs-container")?.shadowRoot??void 0,d=(l=a())=>!!l?.querySelector("[data-line]");return d()?s():typeof MutationObserver<"u"?(n=new MutationObserver(()=>{const l=a();if(l){if(d(l)){s();return}n?.disconnect(),n=new MutationObserver(()=>{d(l)&&s()}),n.observe(l,{childList:!0,subtree:!0})}}),n.observe(r,{childList:!0,subtree:!0})):t=window.requestAnimationFrame(s),()=>{i=!0,n?.disconnect(),t!==null&&window.cancelAnimationFrame(t)}},U=new WeakMap,_e={lineHeight:24,hunkSeparatorHeight:24,spacing:0};function je(r){const e=r.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 Fe(r){if(typeof document>"u")return null;const e=je(r);let t=U.get(e.key);if(!t){const i=new ze;i.setup(e.root,e.content),t={virtualizer:i,refs:0},U.set(e.key,t)}t.refs+=1;let n=!1;return{virtualizer:t.virtualizer,root:e.root,release:()=>{if(n)return;n=!0;const i=U.get(e.key);i&&(i.refs-=1,!(i.refs>0)&&(i.virtualizer.cleanUp(),U.delete(e.key)))}}}const Ne=(r,e,t)=>{if(typeof window>"u")return()=>{};const n=[],i=()=>{try{r.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 n.push(window.requestAnimationFrame(i)),n.push(window.requestAnimationFrame(()=>{n.push(window.requestAnimationFrame(i))})),()=>{for(const s of n)window.cancelAnimationFrame(s)}},Ze=({original:r,modified:e,fileDiff:t,language:n,fileName:i,renderSideBySide:s,wrapLines:a,layout:d="fill"})=>{const l=be(),u=l?.currentTheme.metadata.variant==="dark",f=l?.availableThemes.find(h=>h.metadata.id===l.lightThemeId)??ie(!1),p=l?.availableThemes.find(h=>h.metadata.id===l.darkThemeId)??ie(!0);te(f),te(p);const k=`${f.metadata.id}:${p.metadata.id}:${u?"dark":"light"}`,T=v.useMemo(()=>{if(t){const h=t.deletionLines.reduce((m,g)=>m+g.length,0),c=t.additionLines.reduce((m,g)=>m+g.length,0);return Math.max(h,c)>oe}return Math.max(r.length,e.length)>oe},[t,e.length,r.length]),w=v.useRef(null),j=v.useRef(null),L=v.useRef(null),F=v.useRef(null),K=v.useRef(null),Y=v.useRef(null),Z=v.useRef(void 0),q=v.useRef(void 0),B=v.useRef(void 0),W=v.useRef(void 0),[,J]=Q.useReducer(h=>h+1,0),A=Se(T?"unified":s?"split":"unified"),z=v.useMemo(()=>ne(f),[f]),C=v.useMemo(()=>ne(p),[p]);Q.useLayoutEffect(()=>{const h=w.current;if(!h)return;const c=h.querySelector("diffs-container");if(!c)return;const m=u?C:z,g=(he,ue)=>he.colors?.[ue],R=g(z,"terminal.ansiGreen"),y=g(z,"terminal.ansiRed"),x=g(z,"terminal.ansiBlue"),H=g(C,"terminal.ansiGreen"),O=g(C,"terminal.ansiRed"),M=g(C,"terminal.ansiBlue");c.style.setProperty("--shiki-light",z.fg),c.style.setProperty("--shiki-light-bg",z.bg),R&&c.style.setProperty("--shiki-light-addition-color",R),y&&c.style.setProperty("--shiki-light-deletion-color",y),x&&c.style.setProperty("--shiki-light-modified-color",x),c.style.setProperty("--shiki-dark",C.fg),c.style.setProperty("--shiki-dark-bg",C.bg),H&&c.style.setProperty("--shiki-dark-addition-color",H),O&&c.style.setProperty("--shiki-dark-deletion-color",O),M&&c.style.setProperty("--shiki-dark-modified-color",M),c.style.setProperty("--diffs-bg",m.bg),c.style.setProperty("--diffs-fg",m.fg);const S=u?H:R,P=u?O:y,_=u?M:x;S&&c.style.setProperty("--diffs-addition-color-override",S),P&&c.style.setProperty("--diffs-deletion-color-override",P),_&&c.style.setProperty("--diffs-modified-color-override",_);const b=c.shadowRoot?.querySelector("pre");b&&(b.style.setProperty("--shiki-light",z.fg),b.style.setProperty("--shiki-light-bg",z.bg),R&&b.style.setProperty("--shiki-light-addition-color",R),y&&b.style.setProperty("--shiki-light-deletion-color",y),x&&b.style.setProperty("--shiki-light-modified-color",x),b.style.setProperty("--shiki-dark",C.fg),b.style.setProperty("--shiki-dark-bg",C.bg),H&&b.style.setProperty("--shiki-dark-addition-color",H),O&&b.style.setProperty("--shiki-dark-deletion-color",O),M&&b.style.setProperty("--shiki-dark-modified-color",M),b.style.setProperty("--diffs-bg",m.bg),b.style.setProperty("--diffs-fg",m.fg),S&&b.style.setProperty("--diffs-addition-color-override",S),P&&b.style.setProperty("--diffs-deletion-color-override",P),_&&b.style.setProperty("--diffs-modified-color-override",_))},[C,k,u,z]);const I=v.useMemo(()=>({theme:{dark:p.metadata.id,light:f.metadata.id},themeType:u?"dark":"light",diffStyle:s?"split":"unified",diffIndicators:"none",hunkSeparators:"line-info-basic",lineDiffType:"none",maxLineDiffLength:T?0:1e3,maxLineLengthForHighlighting:T?1:1e3,tokenizeMaxLineLength:T?1:1e3,collapsedContextThreshold:0,expansionLineCount:20,overflow:a?"wrap":"scroll",disableFileHeader:!0,enableLineSelection:!1,enableHoverUtility:!1,unsafeCSS:Me}),[p.metadata.id,u,T,f.metadata.id,s,a]);return v.useEffect(()=>{const h=j.current;return()=>{L.current?.cleanUp(),L.current=null,F.current?.release(),F.current=null,K.current=null,Y.current=null,Z.current=void 0,q.current=void 0,B.current=void 0,W.current=void 0,h&&(h.innerHTML="")}},[]),v.useEffect(()=>{if(typeof window>"u")return;const h=j.current,c=w.current;if(!h||!A)return;const m=Le(c,h);let g=F.current;g||(g=Fe(h),F.current=g),F.current=g;const R=g?.virtualizer??null,y=t?void 0:{name:i||"",contents:r,lang:n,cacheKey:`old:${k}:${i}:${le(r)}`},x=t?void 0:{name:i||"",contents:e,lang:n,cacheKey:`new:${k}:${i}:${le(e)}`},H=t?q.current!==t:q.current!==void 0||!y||!x||!B.current||!W.current||!ee(B.current,y)||!ee(W.current,x),O=L.current,M=!!(O&&(K.current!==R||Y.current!==A||R&&(Z.current!==I.hunkSeparators||H)));M&&(O?.cleanUp(),L.current=null,h.innerHTML="");let S=L.current;const P=!M&&O?!we(O.options,I):!1;if(S?S.setOptions(I):(S=g?new xe(I,g.virtualizer,_e,A):new Re(I,A),L.current=S),K.current=R,Y.current=A,Z.current=R?I.hunkSeparators:void 0,q.current=t,B.current=y,W.current=x,t)S.render({fileDiff:t,forceRender:P,containerWrapper:h});else{if(!y||!x)return;S.render({oldFile:y,newFile:x,forceRender:P,containerWrapper:h})}const _=Ae(h,()=>{m(),Ne(S,g,J)});return()=>{_(),m()}},[k,t,i,n,e,I,r,A]),v.useEffect(()=>{const h=j.current;if(!h)return;let c=null,m=null;const R=setTimeout(()=>{const y=h.querySelector("diffs-container");if(!(y instanceof HTMLElement))return;const x=y.shadowRoot;c=new MutationObserver(()=>{m&&cancelAnimationFrame(m),m=requestAnimationFrame(()=>{J(),m=null})}),c.observe(y,{childList:!0,subtree:!0}),x&&c.observe(x,{childList:!0,subtree:!0})},100);return()=>{clearTimeout(R),m&&cancelAnimationFrame(m),c?.disconnect()}},[k,i]),typeof window>"u"?null:d==="fill"?o.jsx("div",{className:re("flex flex-col relative","size-full"),"data-diff-virtual-root":!0,children:o.jsx("div",{className:"flex-1 relative min-h-0",children:o.jsx(ye,{outerClassName:"pierre-diff-wrapper size-full",disableHorizontal:!1,fillContainer:!0,"data-diff-virtual-content":!0,children:o.jsx("div",{ref:w,className:"size-full relative",children:o.jsx("div",{ref:j,className:"size-full"})})})})}):o.jsx("div",{className:re("relative","w-full"),children:o.jsx("div",{ref:w,className:"pierre-diff-wrapper w-full overflow-x-auto overflow-y-visible relative","data-no-drawer-swipe":"true",children:o.jsx("div",{ref:j,className:"w-full"})})})},ae={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}};function Xe(r){const e=r.index?.trim(),t=r.working_dir?.trim(),n=e&&e!=="?"?e.charAt(0):t?.charAt(0)||e?.charAt(0)||"M";return ae[n]??ae.M}function Je(r){const e=r.index?.trim();return!!(e&&e!=="?")}function et(r){return!!r.working_dir?.trim()||r.index?.trim()==="?"}function tt(r){const e=r.index?.trim(),t=r.working_dir?.trim();return e==="A"||t==="A"||e==="?"||t==="?"}export{Ye as C,Ze as P,et as a,tt as b,Xe as d,Je as i};