@hienlh/ppm 0.1.2 → 0.1.3

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.
@@ -1,4 +1,4 @@
1
- import{i as e,n as t,t as n}from"./jsx-runtime-BnxRlLMJ.js";import{c as r,i,n as a,r as o,s,t as c}from"./button-BxijdhtM.js";import{t as l}from"./x-BISR7bpK.js";import{t as u}from"./utils-Cgi2TYRi.js";var d=e(t(),1),f=n();function p(e,t){let n=d.createContext(t),r=e=>{let{children:t,...r}=e,i=d.useMemo(()=>r,Object.values(r));return(0,f.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=d.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function m(e,t=[]){let n=[];function r(t,r){let i=d.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=d.useMemo(()=>o,Object.values(o));return(0,f.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=d.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>d.createContext(e));return function(n){let r=n?.[e]||t;return d.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,h(i,...t)]}function h(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}typeof window<`u`&&window.document&&window.document.createElement;function g(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var _=globalThis?.document?d.useLayoutEffect:()=>{},v=d.useInsertionEffect||_;function y({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=b({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=d.useRef(e!==void 0);d.useEffect(()=>{let e=t.current;if(e!==s){let t=e?`controlled`:`uncontrolled`,n=s?`controlled`:`uncontrolled`;console.warn(`${r} is changing from ${t} to ${n}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}t.current=s},[s,r])}return[c,d.useCallback(t=>{if(s){let n=ee(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function b({defaultProp:e,onChange:t}){let[n,r]=d.useState(e),i=d.useRef(n),a=d.useRef(t);return v(()=>{a.current=t},[t]),d.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function ee(e){return typeof e==`function`}function x(e,t){return d.useReducer((e,n)=>t[e][n]??e,e)}var S=e=>{let{present:t,children:n}=e,r=C(t),i=typeof n==`function`?n({present:r.isPresent}):d.Children.only(n),a=s(r.ref,te(i));return typeof n==`function`||r.isPresent?d.cloneElement(i,{ref:a}):null};S.displayName=`Presence`;function C(e){let[t,n]=d.useState(),r=d.useRef(null),i=d.useRef(e),a=d.useRef(`none`),[o,s]=x(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return d.useEffect(()=>{let e=w(r.current);a.current=o===`mounted`?e:`none`},[o]),_(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=w(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),_(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=w(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=w(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:d.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function w(e){return e?.animationName||`none`}function te(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ne=d.useId||(()=>void 0),re=0;function T(e){let[t,n]=d.useState(ne());return _(()=>{e||n(e=>e??String(re++))},[e]),e||(t?`radix-${t}`:``)}function E(e){let t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>(...e)=>t.current?.(...e),[])}function ie(e,t=globalThis?.document){let n=E(e);d.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var ae=`DismissableLayer`,D=`dismissableLayer.update`,oe=`dismissableLayer.pointerDownOutside`,se=`dismissableLayer.focusOutside`,ce,le=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),O=d.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:o,onInteractOutside:c,onDismiss:l,...u}=e,p=d.useContext(le),[m,h]=d.useState(null),_=m?.ownerDocument??globalThis?.document,[,v]=d.useState({}),y=s(t,e=>h(e)),b=Array.from(p.layers),[ee]=[...p.layersWithOutsidePointerEventsDisabled].slice(-1),x=b.indexOf(ee),S=m?b.indexOf(m):-1,C=p.layersWithOutsidePointerEventsDisabled.size>0,w=S>=x,te=fe(e=>{let t=e.target,n=[...p.branches].some(e=>e.contains(t));!w||n||(i?.(e),c?.(e),e.defaultPrevented||l?.())},_),ne=pe(e=>{let t=e.target;[...p.branches].some(e=>e.contains(t))||(o?.(e),c?.(e),e.defaultPrevented||l?.())},_);return ie(e=>{S===p.layers.size-1&&(r?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},_),d.useEffect(()=>{if(m)return n&&(p.layersWithOutsidePointerEventsDisabled.size===0&&(ce=_.body.style.pointerEvents,_.body.style.pointerEvents=`none`),p.layersWithOutsidePointerEventsDisabled.add(m)),p.layers.add(m),me(),()=>{n&&p.layersWithOutsidePointerEventsDisabled.size===1&&(_.body.style.pointerEvents=ce)}},[m,_,n,p]),d.useEffect(()=>()=>{m&&(p.layers.delete(m),p.layersWithOutsidePointerEventsDisabled.delete(m),me())},[m,p]),d.useEffect(()=>{let e=()=>v({});return document.addEventListener(D,e),()=>document.removeEventListener(D,e)},[]),(0,f.jsx)(a.div,{...u,ref:y,style:{pointerEvents:C?w?`auto`:`none`:void 0,...e.style},onFocusCapture:g(e.onFocusCapture,ne.onFocusCapture),onBlurCapture:g(e.onBlurCapture,ne.onBlurCapture),onPointerDownCapture:g(e.onPointerDownCapture,te.onPointerDownCapture)})});O.displayName=ae;var ue=`DismissableLayerBranch`,de=d.forwardRef((e,t)=>{let n=d.useContext(le),r=d.useRef(null),i=s(t,r);return d.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,f.jsx)(a.div,{...e,ref:i})});de.displayName=ue;function fe(e,t=globalThis?.document){let n=E(e),r=d.useRef(!1),i=d.useRef(()=>{});return d.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){he(oe,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function pe(e,t=globalThis?.document){let n=E(e),r=d.useRef(!1);return d.useEffect(()=>{let e=e=>{e.target&&!r.current&&he(se,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function me(){let e=new CustomEvent(D);document.dispatchEvent(e)}function he(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?o(i,a):i.dispatchEvent(a)}var k=`focusScope.autoFocusOnMount`,A=`focusScope.autoFocusOnUnmount`,ge={bubbles:!1,cancelable:!0},_e=`FocusScope`,j=d.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:o,...c}=e,[l,u]=d.useState(null),p=E(i),m=E(o),h=d.useRef(null),g=s(t,e=>u(e)),_=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(r){let e=function(e){if(_.paused||!l)return;let t=e.target;l.contains(t)?h.current=t:M(h.current,{select:!0})},t=function(e){if(_.paused||!l)return;let t=e.relatedTarget;t!==null&&(l.contains(t)||M(h.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&M(l)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return l&&r.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,l,_.paused]),d.useEffect(()=>{if(l){we.add(_);let e=document.activeElement;if(!l.contains(e)){let t=new CustomEvent(k,ge);l.addEventListener(k,p),l.dispatchEvent(t),t.defaultPrevented||(ve(De(be(l)),{select:!0}),document.activeElement===e&&M(l))}return()=>{l.removeEventListener(k,p),setTimeout(()=>{let t=new CustomEvent(A,ge);l.addEventListener(A,m),l.dispatchEvent(t),t.defaultPrevented||M(e??document.body,{select:!0}),l.removeEventListener(A,m),we.remove(_)},0)}}},[l,p,m,_]);let v=d.useCallback(e=>{if(!n&&!r||_.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=ye(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&M(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&M(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,_.paused]);return(0,f.jsx)(a.div,{tabIndex:-1,...c,ref:g,onKeyDown:v})});j.displayName=_e;function ve(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(M(r,{select:t}),document.activeElement!==n)return}function ye(e){let t=be(e);return[xe(t,e),xe(t.reverse(),e)]}function be(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function xe(e,t){for(let n of e)if(!Se(n,{upTo:t}))return n}function Se(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function Ce(e){return e instanceof HTMLInputElement&&`select`in e}function M(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ce(e)&&t&&e.select()}}var we=Te();function Te(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Ee(e,t),e.unshift(t)},remove(t){e=Ee(e,t),e[0]?.resume()}}}function Ee(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function De(e){return e.filter(e=>e.tagName!==`A`)}var Oe=e(r(),1),ke=`Portal`,N=d.forwardRef((e,t)=>{let{container:n,...r}=e,[i,o]=d.useState(!1);_(()=>o(!0),[]);let s=n||i&&globalThis?.document?.body;return s?Oe.createPortal((0,f.jsx)(a.div,{...r,ref:t}),s):null});N.displayName=ke;var P=0;function Ae(){d.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??je()),document.body.insertAdjacentElement(`beforeend`,e[1]??je()),P++,()=>{P===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),P--}},[])}function je(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var F=function(){return F=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},F.apply(this,arguments)};function Me(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Ne(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var I=`right-scroll-bar-position`,L=`width-before-scroll-bar`,Pe=`with-scroll-bars-hidden`,Fe=`--removed-body-scroll-bar-size`;function R(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Ie(e,t){var n=(0,d.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Le=typeof window<`u`?d.useLayoutEffect:d.useEffect,Re=new WeakMap;function ze(e,t){var n=Ie(t||null,function(t){return e.forEach(function(e){return R(e,t)})});return Le(function(){var t=Re.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||R(e,null)}),i.forEach(function(e){r.has(e)||R(e,a)})}Re.set(n,e)},[e]),n}function Be(e){return e}function Ve(e,t){t===void 0&&(t=Be);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function He(e){e===void 0&&(e={});var t=Ve(null);return t.options=F({async:!0,ssr:!1},e),t}var Ue=function(e){var t=e.sideCar,n=Me(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return d.createElement(r,F({},n))};Ue.isSideCarExport=!0;function We(e,t){return e.useMedium(t),Ue}var Ge=He(),z=function(){},B=d.forwardRef(function(e,t){var n=d.useRef(null),r=d.useState({onScrollCapture:z,onWheelCapture:z,onTouchMoveCapture:z}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,h=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,ee=Me(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=p,S=ze([n,t]),C=F(F({},ee),i);return d.createElement(d.Fragment,null,u&&d.createElement(x,{sideCar:Ge,removeScrollBar:l,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),o?d.cloneElement(d.Children.only(s),F(F({},C),{ref:S})):d.createElement(y,F({},C,{className:c,ref:S}),s))});B.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},B.classNames={fullWidth:L,zeroRight:I};var Ke,qe=function(){if(Ke)return Ke;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function Je(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=qe();return t&&e.setAttribute(`nonce`,t),e}function Ye(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Xe(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Ze=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Je())&&(Ye(t,n),Xe(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Qe=function(){var e=Ze();return function(t,n){d.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},$e=function(){var e=Qe();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},et={left:0,top:0,right:0,gap:0},V=function(e){return parseInt(e||``,10)||0},tt=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[V(n),V(r),V(i)]},nt=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return et;var t=tt(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},rt=$e(),H=`data-scroll-locked`,it=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
1
+ import{i as e,n as t,t as n}from"./jsx-runtime-BnxRlLMJ.js";import{c as r,i,n as a,r as o,s,t as c}from"./button-DxRZgE8F.js";import{t as l}from"./x-BISR7bpK.js";import{t as u}from"./utils-CiBGfeHD.js";var d=e(t(),1),f=n();function p(e,t){let n=d.createContext(t),r=e=>{let{children:t,...r}=e,i=d.useMemo(()=>r,Object.values(r));return(0,f.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=d.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function m(e,t=[]){let n=[];function r(t,r){let i=d.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=d.useMemo(()=>o,Object.values(o));return(0,f.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=d.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>d.createContext(e));return function(n){let r=n?.[e]||t;return d.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,h(i,...t)]}function h(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}typeof window<`u`&&window.document&&window.document.createElement;function g(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var _=globalThis?.document?d.useLayoutEffect:()=>{},v=d.useInsertionEffect||_;function y({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=b({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=d.useRef(e!==void 0);d.useEffect(()=>{let e=t.current;if(e!==s){let t=e?`controlled`:`uncontrolled`,n=s?`controlled`:`uncontrolled`;console.warn(`${r} is changing from ${t} to ${n}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}t.current=s},[s,r])}return[c,d.useCallback(t=>{if(s){let n=ee(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function b({defaultProp:e,onChange:t}){let[n,r]=d.useState(e),i=d.useRef(n),a=d.useRef(t);return v(()=>{a.current=t},[t]),d.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function ee(e){return typeof e==`function`}function x(e,t){return d.useReducer((e,n)=>t[e][n]??e,e)}var S=e=>{let{present:t,children:n}=e,r=C(t),i=typeof n==`function`?n({present:r.isPresent}):d.Children.only(n),a=s(r.ref,te(i));return typeof n==`function`||r.isPresent?d.cloneElement(i,{ref:a}):null};S.displayName=`Presence`;function C(e){let[t,n]=d.useState(),r=d.useRef(null),i=d.useRef(e),a=d.useRef(`none`),[o,s]=x(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return d.useEffect(()=>{let e=w(r.current);a.current=o===`mounted`?e:`none`},[o]),_(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=w(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),_(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=w(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=w(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:d.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function w(e){return e?.animationName||`none`}function te(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ne=d.useId||(()=>void 0),re=0;function T(e){let[t,n]=d.useState(ne());return _(()=>{e||n(e=>e??String(re++))},[e]),e||(t?`radix-${t}`:``)}function E(e){let t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>(...e)=>t.current?.(...e),[])}function ie(e,t=globalThis?.document){let n=E(e);d.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var ae=`DismissableLayer`,D=`dismissableLayer.update`,oe=`dismissableLayer.pointerDownOutside`,se=`dismissableLayer.focusOutside`,ce,le=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),O=d.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:o,onInteractOutside:c,onDismiss:l,...u}=e,p=d.useContext(le),[m,h]=d.useState(null),_=m?.ownerDocument??globalThis?.document,[,v]=d.useState({}),y=s(t,e=>h(e)),b=Array.from(p.layers),[ee]=[...p.layersWithOutsidePointerEventsDisabled].slice(-1),x=b.indexOf(ee),S=m?b.indexOf(m):-1,C=p.layersWithOutsidePointerEventsDisabled.size>0,w=S>=x,te=fe(e=>{let t=e.target,n=[...p.branches].some(e=>e.contains(t));!w||n||(i?.(e),c?.(e),e.defaultPrevented||l?.())},_),ne=pe(e=>{let t=e.target;[...p.branches].some(e=>e.contains(t))||(o?.(e),c?.(e),e.defaultPrevented||l?.())},_);return ie(e=>{S===p.layers.size-1&&(r?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},_),d.useEffect(()=>{if(m)return n&&(p.layersWithOutsidePointerEventsDisabled.size===0&&(ce=_.body.style.pointerEvents,_.body.style.pointerEvents=`none`),p.layersWithOutsidePointerEventsDisabled.add(m)),p.layers.add(m),me(),()=>{n&&p.layersWithOutsidePointerEventsDisabled.size===1&&(_.body.style.pointerEvents=ce)}},[m,_,n,p]),d.useEffect(()=>()=>{m&&(p.layers.delete(m),p.layersWithOutsidePointerEventsDisabled.delete(m),me())},[m,p]),d.useEffect(()=>{let e=()=>v({});return document.addEventListener(D,e),()=>document.removeEventListener(D,e)},[]),(0,f.jsx)(a.div,{...u,ref:y,style:{pointerEvents:C?w?`auto`:`none`:void 0,...e.style},onFocusCapture:g(e.onFocusCapture,ne.onFocusCapture),onBlurCapture:g(e.onBlurCapture,ne.onBlurCapture),onPointerDownCapture:g(e.onPointerDownCapture,te.onPointerDownCapture)})});O.displayName=ae;var ue=`DismissableLayerBranch`,de=d.forwardRef((e,t)=>{let n=d.useContext(le),r=d.useRef(null),i=s(t,r);return d.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,f.jsx)(a.div,{...e,ref:i})});de.displayName=ue;function fe(e,t=globalThis?.document){let n=E(e),r=d.useRef(!1),i=d.useRef(()=>{});return d.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){he(oe,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function pe(e,t=globalThis?.document){let n=E(e),r=d.useRef(!1);return d.useEffect(()=>{let e=e=>{e.target&&!r.current&&he(se,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function me(){let e=new CustomEvent(D);document.dispatchEvent(e)}function he(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?o(i,a):i.dispatchEvent(a)}var k=`focusScope.autoFocusOnMount`,A=`focusScope.autoFocusOnUnmount`,ge={bubbles:!1,cancelable:!0},_e=`FocusScope`,j=d.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:o,...c}=e,[l,u]=d.useState(null),p=E(i),m=E(o),h=d.useRef(null),g=s(t,e=>u(e)),_=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(r){let e=function(e){if(_.paused||!l)return;let t=e.target;l.contains(t)?h.current=t:M(h.current,{select:!0})},t=function(e){if(_.paused||!l)return;let t=e.relatedTarget;t!==null&&(l.contains(t)||M(h.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&M(l)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return l&&r.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,l,_.paused]),d.useEffect(()=>{if(l){we.add(_);let e=document.activeElement;if(!l.contains(e)){let t=new CustomEvent(k,ge);l.addEventListener(k,p),l.dispatchEvent(t),t.defaultPrevented||(ve(De(be(l)),{select:!0}),document.activeElement===e&&M(l))}return()=>{l.removeEventListener(k,p),setTimeout(()=>{let t=new CustomEvent(A,ge);l.addEventListener(A,m),l.dispatchEvent(t),t.defaultPrevented||M(e??document.body,{select:!0}),l.removeEventListener(A,m),we.remove(_)},0)}}},[l,p,m,_]);let v=d.useCallback(e=>{if(!n&&!r||_.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=ye(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&M(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&M(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,_.paused]);return(0,f.jsx)(a.div,{tabIndex:-1,...c,ref:g,onKeyDown:v})});j.displayName=_e;function ve(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(M(r,{select:t}),document.activeElement!==n)return}function ye(e){let t=be(e);return[xe(t,e),xe(t.reverse(),e)]}function be(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function xe(e,t){for(let n of e)if(!Se(n,{upTo:t}))return n}function Se(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function Ce(e){return e instanceof HTMLInputElement&&`select`in e}function M(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ce(e)&&t&&e.select()}}var we=Te();function Te(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Ee(e,t),e.unshift(t)},remove(t){e=Ee(e,t),e[0]?.resume()}}}function Ee(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function De(e){return e.filter(e=>e.tagName!==`A`)}var Oe=e(r(),1),ke=`Portal`,N=d.forwardRef((e,t)=>{let{container:n,...r}=e,[i,o]=d.useState(!1);_(()=>o(!0),[]);let s=n||i&&globalThis?.document?.body;return s?Oe.createPortal((0,f.jsx)(a.div,{...r,ref:t}),s):null});N.displayName=ke;var P=0;function Ae(){d.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??je()),document.body.insertAdjacentElement(`beforeend`,e[1]??je()),P++,()=>{P===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),P--}},[])}function je(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var F=function(){return F=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},F.apply(this,arguments)};function Me(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Ne(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var I=`right-scroll-bar-position`,L=`width-before-scroll-bar`,Pe=`with-scroll-bars-hidden`,Fe=`--removed-body-scroll-bar-size`;function R(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Ie(e,t){var n=(0,d.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Le=typeof window<`u`?d.useLayoutEffect:d.useEffect,Re=new WeakMap;function ze(e,t){var n=Ie(t||null,function(t){return e.forEach(function(e){return R(e,t)})});return Le(function(){var t=Re.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||R(e,null)}),i.forEach(function(e){r.has(e)||R(e,a)})}Re.set(n,e)},[e]),n}function Be(e){return e}function Ve(e,t){t===void 0&&(t=Be);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function He(e){e===void 0&&(e={});var t=Ve(null);return t.options=F({async:!0,ssr:!1},e),t}var Ue=function(e){var t=e.sideCar,n=Me(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return d.createElement(r,F({},n))};Ue.isSideCarExport=!0;function We(e,t){return e.useMedium(t),Ue}var Ge=He(),z=function(){},B=d.forwardRef(function(e,t){var n=d.useRef(null),r=d.useState({onScrollCapture:z,onWheelCapture:z,onTouchMoveCapture:z}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,h=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,ee=Me(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=p,S=ze([n,t]),C=F(F({},ee),i);return d.createElement(d.Fragment,null,u&&d.createElement(x,{sideCar:Ge,removeScrollBar:l,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),o?d.cloneElement(d.Children.only(s),F(F({},C),{ref:S})):d.createElement(y,F({},C,{className:c,ref:S}),s))});B.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},B.classNames={fullWidth:L,zeroRight:I};var Ke,qe=function(){if(Ke)return Ke;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function Je(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=qe();return t&&e.setAttribute(`nonce`,t),e}function Ye(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Xe(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Ze=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Je())&&(Ye(t,n),Xe(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Qe=function(){var e=Ze();return function(t,n){d.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},$e=function(){var e=Qe();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},et={left:0,top:0,right:0,gap:0},V=function(e){return parseInt(e||``,10)||0},tt=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[V(n),V(r),V(i)]},nt=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return et;var t=tt(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},rt=$e(),H=`data-scroll-locked`,it=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
2
2
  .${Pe} {
3
3
  overflow: hidden ${r};
4
4
  padding-right: ${s}px ${r};
@@ -1,4 +1,4 @@
1
- import{i as e,n as t,t as n}from"./jsx-runtime-BnxRlLMJ.js";import{a as r,r as i,t as a}from"./api-client-Bnf9LAt4.js";import{b as o}from"./index-DGSLw2GE.js";import{A as s,E as c,H as l,I as u,O as d,Q as f,Y as p,a as m,at as h,ct as g,et as _,i as v,it as y,j as b,k as x,n as S,nt as C,o as w,ot as T,r as E,rt as D,s as ee,st as O,t as te}from"./dist-CSp7ir0r.js";var k=e(t(),1),A=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}offset(t,n=t){return new e(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}};function j(e,t,n,r,i,a){if(e==r)return[];let o=I(e,t,n,r,i,a),s=L(e,t+o,n,r,i+o,a);t+=o,n-=s,i+=o,a-=s;let c=n-t,l=a-i;if(!c||!l)return[new A(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new A(t,t+o,i,i),new A(t+o+l,n,a,a)]}else if(l>c){let o=r.slice(i,a).indexOf(e.slice(t,n));if(o>-1)return[new A(t,t,i,i+o),new A(n,n,i+o+c,a)]}if(c==1||l==1)return[new A(t,n,i,a)];let u=se(e,t,n,r,i,a);if(u){let[o,s,c]=u;return j(e,t,o,r,i,s).concat(j(e,o+c,n,r,s+c,a))}return ne(e,t,n,r,i,a)}var M=1e9,N=0,P=!1;function ne(e,t,n,r,i,a){let o=n-t,s=a-i;if(M<1e9&&Math.min(o,s)>M*16||N>0&&Date.now()>N)return Math.min(o,s)>M*64?[new A(t,n,i,a)]:ce(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);ie.reset(c),F.reset(c);let l=(n,a)=>e.charCodeAt(t+n)==r.charCodeAt(i+a),u=(t,i)=>e.charCodeAt(n-t-1)==r.charCodeAt(a-i-1),d=(o-s)%2==0?null:F,f=d?null:ie;for(let p=0;p<c;p++){if(p>M||N>0&&!(p&63)&&Date.now()>N)return ce(e,t,n,r,i,a);let m=ie.advance(p,o,s,c,d,!1,l)||F.advance(p,o,s,c,f,!0,u);if(m)return ae(e,t,n,t+m[0],r,i,a,i+m[1])}return[new A(t,n,i,a)]}var re=class{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let e=0;e<this.len;e++)this.vec[e]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,n,r,i,a,o){for(let s=-e+this.start;s<=e-this.end;s+=2){let c=r+s,l=s==-e||s!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,u=l-s;for(;l<t&&u<n&&o(l,u);)l++,u++;if(this.vec[c]=l,l>t)this.end+=2;else if(u>n)this.start+=2;else if(i){let e=r+(t-n)-s;if(e>=0&&e<this.len&&i.vec[e]!=-1)if(a){let n=i.vec[e];if(n>=t-l)return[n,r+n-e]}else{let n=t-i.vec[e];if(l>=n)return[l,u]}}}return null}},ie=new re,F=new re;function ae(e,t,n,r,i,a,o,s){let c=!1;return!B(e,r)&&++r==n&&(c=!0),!B(i,s)&&++s==o&&(c=!0),c?[new A(t,n,a,o)]:j(e,t,r,i,a,s).concat(j(e,r,n,i,s,o))}function oe(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function I(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=oe(n-t,a-i);for(let s=t,c=i;;){let i=s+o,l=c+o;if(i>n||l>a||e.slice(s,i)!=r.slice(c,l)){if(o==1)return s-t-(B(e,s)?0:1);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function L(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=oe(n-t,a-i);for(let s=n,c=a;;){let a=s-o,l=c-o;if(a<t||l<i||e.slice(a,s)!=r.slice(l,c)){if(o==1)return n-s-(B(e,s)?0:1);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function R(e,t,n,r,i,a,o,s){let c=r.slice(i,a),l=null;for(;;){if(l||o<s)return l;for(let s=t+o;;){B(e,s)||s++;let u=s+o;if(B(e,u)||(u+=u==s+1?1:-1),u>=n)break;let d=e.slice(s,u),f=-1;for(;(f=c.indexOf(d,f+1))!=-1;){let o=I(e,u,n,r,i+f+d.length,a),c=L(e,t,s,r,i,i+f),p=d.length+o+c;(!l||l[2]<p)&&(l=[s-c,i+f-c,p])}s=u}if(s<0)return l;o>>=1}}function se(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=se(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:R(e,t,n,r,i,a,Math.floor(o/4),-1)}function ce(e,t,n,r,i,a){P=!0;let o=n-t,s=a-i,c;if(o<s){let s=R(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=R(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new A(t,n,i,a)];let[l,u,d]=c;return j(e,t,l,r,i,u).concat(j(e,l+d,n,r,u+d,a))}function le(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];r.toA>i.fromA-t&&r.toB>i.fromB-t&&(e[n-1]=new A(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function ue(e,t,n){for(;;){le(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=I(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new A(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=L(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new A(a.fromA,a.toA-s,a.fromB,a.toB-s));let c=a.toA-a.fromA,l=a.toB-a.fromB;if(c&&l)continue;let u=a.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:e.length)-a.toA;if(!u||!d)continue;let f=c?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);u<=f.length&&e.slice(a.fromA-u,a.fromA)==f.slice(f.length-u)?(n[i]=new A(a.fromA-u,a.toA-u,a.fromB-u,a.toB-u),r=!0):d<=f.length&&e.slice(a.toA,a.toA+d)==f.slice(0,d)&&(n[i]=new A(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}function de(e,t,n){for(let r=0,i=0;i<e.length;i++){let a=e[i],o=a.toA-a.fromA,s=a.toB-a.fromB;if(o&&s||o>3||s>3){let c=i==e.length-1?t.length:e[i+1].fromA,l=a.fromA-r,u=c-a.toA,d=_e(t,a.fromA,l),f=ge(t,a.toA,u),p=a.fromA-d,m=f-a.toA;if((!o||!s)&&p&&m){let l=Math.max(o,s),[u,h,g]=o?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];l>p&&t.slice(d,a.fromA)==u.slice(g-p,g)?(a=e[i]=new A(d,d+o,a.fromB-p,a.toB-p),d=a.fromA,f=ge(t,a.toA,c-a.toA)):l>m&&t.slice(a.toA,f)==u.slice(h,h+m)&&(a=e[i]=new A(f-o,f,a.fromB+m,a.toB+m),f=a.toA,d=_e(t,a.fromA,a.fromA-r)),p=a.fromA-d,m=f-a.toA}if(p||m)a=e[i]=new A(a.fromA-p,a.toA+m,a.fromB-p,a.toB+m);else if(!o){let t=ye(n,a.fromB,a.toB),r,o=t<0?-1:ve(n,a.toB,a.fromB);t>-1&&(r=t-a.fromB)<=u&&n.slice(a.fromB,t)==n.slice(a.toB,a.toB+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toB-o)<=l&&n.slice(a.fromB-r,a.fromB)==n.slice(o,a.toB)&&(a=e[i]=a.offset(-r))}else if(!s){let n=ye(t,a.fromA,a.toA),r,o=n<0?-1:ve(t,a.toA,a.fromA);n>-1&&(r=n-a.fromA)<=u&&t.slice(a.fromA,n)==t.slice(a.toA,a.toA+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toA-o)<=l&&t.slice(a.fromA-r,a.fromA)==t.slice(o,a.toA)&&(a=e[i]=a.offset(-r))}}r=a.toA}return le(e,3),e}var z;try{z=RegExp(`[\\p{Alphabetic}\\p{Number}]`,`u`)}catch{}function fe(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function pe(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?fe(n)?1:0:z?!be(n)||t==e.length-1?z.test(String.fromCharCode(n))?1:0:z.test(e.slice(t,t+2))?2:0:0}function me(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?fe(n)?1:0:z?!xe(n)||t==1?z.test(String.fromCharCode(n))?1:0:z.test(e.slice(t-2,t))?2:0:0}var he=8;function ge(e,t,n){if(t==e.length||!me(e,t))return t;for(let r=t,i=t+n,a=0;a<he;a++){let t=pe(e,r);if(!t||r+t>i)return r;r+=t}return t}function _e(e,t,n){if(!t||!pe(e,t))return t;for(let r=t,i=t-n,a=0;a<he;a++){let t=me(e,r);if(!t||r-t<i)return r;r-=t}return t}function ve(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function ye(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}var be=e=>e>=55296&&e<=56319,xe=e=>e>=56320&&e<=57343;function B(e,t){return!t||t==e.length||!be(e.charCodeAt(t-1))||!xe(e.charCodeAt(t))}function Se(e,t,n){let r=n?.override;return r?r(e,t):(M=(n?.scanLimit??1e9)>>1,N=n?.timeout?Date.now()+n.timeout:0,P=!1,ue(e,t,j(e,0,e.length,t,0,t.length)))}function Ce(){return!P}function we(e,t,n){return de(Se(e,t,n),e,t)}var V=D.define({combine:e=>e[0]}),H=O.define(),Te=D.define(),U=g.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(H)&&(e=n.value);for(let n of t.state.facet(Te))e=n(e,t);return e}}),W=class e{constructor(e,t,n,r,i,a=!0){this.changes=e,this.fromA=t,this.toA=n,this.fromB=r,this.toB=i,this.precise=a}offset(t,n){return t||n?new e(this.changes,this.fromA+t,this.toA+t,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,t,n){return Oe(we(e.toString(),t.toString(),n),e,t,0,0,Ce())}static updateA(e,t,n,r,i){return je(Ae(e,r,!0,n.length),e,t,n,i)}static updateB(e,t,n,r,i){return je(Ae(e,r,!1,t.length),e,t,n,i)}};function Ee(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.to==e&&a.to==t&&e<n.length&&t<r.length?[e+1,t+1]:[i.from,a.from]}function De(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.from==e&&a.from==t?[e,t]:[i.to+1,a.to+1]}function Oe(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length;s++){let c=e[s],[l,u]=Ee(c.fromA+r,c.fromB+i,t,n),[d,f]=De(c.toA+r,c.toB+i,t,n),p=[c.offset(-l+r,-u+i)];for(;s<e.length-1;){let a=e[s+1],[o,c]=Ee(a.fromA+r,a.fromB+i,t,n);if(o>d+1&&c>f+1)break;p.push(a.offset(-l+r,-u+i)),[d,f]=De(a.toA+r,a.toB+i,t,n),s++}o.push(new W(p,l,Math.max(l,d),u,Math.max(u,f),a))}return o}var G=1e3;function ke(e,t,n,r){let i=0,a=e.length;for(;;){if(i==a){let r=0,a=0;i&&({toA:r,toB:a}=e[i-1]);let o=t-(n?r:a);return[r+o,a+o]}let o=i+a>>1,s=e[o],[c,l]=n?[s.fromA,s.toA]:[s.fromB,s.toB];if(c>t)a=o;else if(l<=t)i=o+1;else return r?[s.fromA,s.fromB]:[s.toA,s.toB]}}function Ae(e,t,n,r){let i=[];return t.iterChangedRanges((a,o,s,c)=>{let l=0,u=n?t.length:r,d=0,f=n?r:t.length;a>G&&([l,d]=ke(e,a-G,n,!0)),o<t.length-G&&([u,f]=ke(e,o+G,n,!1));let p=c-s-(o-a),m,[h,g]=n?[p,0]:[0,p];i.length&&(m=i[i.length-1]).toA>=l?i[i.length-1]={fromA:m.fromA,fromB:m.fromB,toA:u,toB:f,diffA:m.diffA+h,diffB:m.diffB+g}:i.push({fromA:l,toA:u,fromB:d,toB:f,diffA:h,diffB:g})}),i}function je(e,t,n,r,i){if(!e.length)return t;let a=[];for(let o=0,s=0,c=0,l=0;;o++){let u=o==e.length?null:e[o],d=u?u.fromA+s:n.length,f=u?u.fromB+c:r.length;for(;l<t.length;){let e=t[l];if(u&&(e.toA+s>d||e.toB+c>f))break;a.push(e.offset(s,c)),l++}if(!u)break;let p=u.toA+s+u.diffA,m=u.toB+c+u.diffB,h=we(n.sliceString(d,p),r.sliceString(f,m),i);for(let e of Oe(h,n,r,d,f,Ce()))a.push(e);for(s+=u.diffA,c+=u.diffB;l<t.length;){let e=t[l];if(e.fromA+s>p&&e.fromB+c>m)break;l++}}return a}var Me={scanLimit:500},Ne=s.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=He(e))}update(e){(e.docChanged||e.viewportChanged||Pe(e.startState,e.state)||Fe(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=He(e.view))}},{decorations:e=>e.deco}),K=y.low(u({class:`cm-changeGutter`,markers:e=>e.plugin(Ne)?.gutter||h.empty}));function Pe(e,t){return e.field(U,!1)!=t.field(U,!1)}function Fe(e,t){return e.facet(V)!=t.facet(V)}var Ie=c.line({class:`cm-changedLine`}),Le=c.mark({class:`cm-changedText`}),Re=c.mark({tagName:`ins`,class:`cm-insertedLine`}),ze=c.mark({tagName:`del`,class:`cm-deletedLine`}),Be=new class extends x{constructor(){super(...arguments),this.elementClass=`cm-changedLineGutter`}};function Ve(e,t,n,r,i,a){let o=n?e.fromA:e.fromB,s=n?e.toA:e.toB,c=0;if(o!=s){i.add(o,o,Ie),i.add(o,s,n?ze:Re),a&&a.add(o,o,Be);for(let l=t.iterRange(o,s-1),u=o;!l.next().done;){if(l.lineBreak){u++,i.add(u,u,Ie),a&&a.add(u,u,Be);continue}let t=u+l.value.length;if(r)for(;c<e.changes.length;){let r=e.changes[c],a=o+(n?r.fromA:r.fromB),s=o+(n?r.toA:r.toB),l=Math.max(u,a),d=Math.min(t,s);if(l<d&&i.add(l,d,Le),s<t)c++;else break}u=t}}}function He(e){let t=e.state.field(U),{side:n,highlightChanges:r,markGutter:i,overrideChunk:a}=e.state.facet(V),o=n==`a`,s=new T,c=i?new T:null,{from:l,to:u}=e.viewport;for(let n of t){if((o?n.fromA:n.fromB)>=u)break;(o?n.toA:n.toB)>l&&(!a||!a(e.state,n,s,c))&&Ve(n,e.state.doc,o,r,s,c)}return{deco:s.finish(),gutter:c&&c.finish()}}var q=class extends b{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement(`div`);return e.className=`cm-mergeSpacer`,e.style.height=this.height+`px`,e}updateDOM(e){return e.style.height=this.height+`px`,!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},J=O.define({map:(e,t)=>e.map(t)}),Y=g.define({create:()=>c.none,update:(e,t)=>{for(let e of t.effects)if(e.is(J))return e.value;return e.map(t.changes)},provide:e=>d.decorations.from(e)}),X=.01;function Ue(e,t){if(e.size!=t.size)return!1;let n=e.iter(),r=t.iter();for(;n.value;){if(n.from!=r.from||Math.abs(n.value.spec.widget.height-r.value.spec.widget.height)>1)return!1;n.next(),r.next()}return!0}function We(e,t,n){let r=new T,i=new T,a=e.state.field(Y).iter(),o=t.state.field(Y).iter(),s=0,l=0,u=0,d=0,f=e.viewport,p=t.viewport;for(let m=0;;m++){let h=m<n.length?n[m]:null,g=h?h.fromA:e.state.doc.length,_=h?h.fromB:t.state.doc.length;if(s<g){let n=e.lineBlockAt(s).top+u-(t.lineBlockAt(l).top+d);n<-X?(u-=n,r.add(s,s,c.widget({widget:new q(-n),block:!0,side:-1}))):n>X&&(d+=n,i.add(l,l,c.widget({widget:new q(n),block:!0,side:-1})))}if(g>s+1e3&&s<f.from&&g>f.from&&l<p.from&&_>p.from){let e=Math.min(f.from-s,p.from-l);s+=e,l+=e,m--}else if(h)s=h.toA,l=h.toB;else break;for(;a.value&&a.from<s;)u-=a.value.spec.widget.height,a.next();for(;o.value&&o.from<l;)d-=o.value.spec.widget.height,o.next()}for(;a.value;)u-=a.value.spec.widget.height,a.next();for(;o.value;)d-=o.value.spec.widget.height,o.next();let m=e.contentHeight+u-(t.contentHeight+d);m<X?r.add(e.state.doc.length,e.state.doc.length,c.widget({widget:new q(-m),block:!0,side:1})):m>X&&i.add(t.state.doc.length,t.state.doc.length,c.widget({widget:new q(m),block:!0,side:1}));let h=r.finish(),g=i.finish();Ue(h,e.state.field(Y))||e.dispatch({effects:J.of(h)}),Ue(g,t.state.field(Y))||t.dispatch({effects:J.of(g)})}var Z=O.define({map:(e,t)=>t.mapPos(e)}),Ge=class extends b{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement(`div`);return t.className=`cm-collapsedLines`,t.textContent=e.state.phrase(`$ unchanged lines`,this.lines),t.addEventListener(`click`,t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:Z.of(n)});let{side:r,sibling:i}=e.state.facet(V);i&&i().dispatch({effects:Z.of(Ke(n,e.state.field(U),r==`a`))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return`collapsed-unchanged-code`}};function Ke(e,t,n){let r=0,i=0;for(let a=0;;a++){let o=a<t.length?t[a]:null;if(!o||(n?o.fromA:o.fromB)>=e)return i+(e-r);[r,i]=n?[o.toA,o.toB]:[o.toB,o.toA]}}var qe=g.define({create(e){return c.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Z)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>d.decorations.from(e)});function Je({margin:e=3,minSize:t=4}){return qe.init(n=>Ye(n,e,t))}function Ye(e,t,n){let r=new T,i=e.facet(V).side==`a`,a=e.field(U),o=1;for(let s=0;;s++){let l=s<a.length?a[s]:null,u=s?o+t:1,d=l?e.doc.lineAt(i?l.fromA:l.fromB).number-1-t:e.doc.lines,f=d-u+1;if(f>=n&&r.add(e.doc.line(u).from,e.doc.line(d).to,c.replace({widget:new Ge(f),block:!0})),!l)break;o=e.doc.lineAt(Math.min(e.doc.length,i?l.toA:l.toB)).number}return r.finish()}var Xe=d.styleModule.of(new p({".cm-mergeView":{overflowY:`auto`},".cm-mergeViewEditors":{display:`flex`,alignItems:`stretch`},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:`hidden`},".cm-merge-revert":{width:`1.6em`,flexGrow:0,flexShrink:0,position:`relative`},".cm-merge-revert button":{position:`absolute`,display:`block`,width:`100%`,boxSizing:`border-box`,textAlign:`center`,background:`none`,border:`none`,font:`inherit`,cursor:`pointer`}})),Ze=d.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:`auto !important`,overflowY:`visible !important`},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:`rgba(160, 128, 100, .08)`},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:`rgba(100, 160, 128, .08)`},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat`},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat`},"&light.cm-merge-b .cm-changedText":{background:`linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat`},"&dark.cm-merge-b .cm-changedText":{background:`linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat`},"&.cm-merge-b .cm-deletedText":{background:`#ff000033`},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:`none`},".cm-deletedChunk":{paddingLeft:`6px`,"& .cm-chunkButtons":{position:`absolute`,insetInlineEnd:`5px`},"& button":{border:`none`,cursor:`pointer`,color:`white`,margin:`0 2px`,borderRadius:`3px`,"&[name=accept]":{background:`#2a2`},"&[name=reject]":{background:`#d43`}}},".cm-collapsedLines":{padding:`5px 5px 5px 10px`,cursor:`pointer`,"&:before":{content:`"⦚"`,marginInlineEnd:`7px`},"&:after":{content:`"⦚"`,marginInlineStart:`7px`}},"&light .cm-collapsedLines":{color:`#444`,background:`linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)`},"&dark .cm-collapsedLines":{color:`#ddd`,background:`linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)`},".cm-changeGutter":{width:`3px`,paddingLeft:`1px`},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:`#e43`},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:`#fa9`},"&light.cm-merge-b .cm-changedLineGutter":{background:`#2b2`},"&dark.cm-merge-b .cm-changedLineGutter":{background:`#8f8`},".cm-inlineChangedLineGutter":{background:`#75d`}}),Qe=new _,Q=new _,$e=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||Me;let t=[y.low(Ne),Ze,Xe,Y,d.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(J)))&&this.measure()})],n=[V.of({side:`a`,sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(K);let r=C.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],d.editorAttributes.of({class:`cm-merge-a`}),Q.of(n),t]}),i=[V.of({side:`b`,sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(K);let a=C.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],d.editorAttributes.of({class:`cm-merge-b`}),Q.of(i),t]});this.chunks=W.build(r.doc,a.doc,this.diffConf);let o=[U.init(()=>this.chunks),Qe.of(e.collapseUnchanged?Je(e.collapseUnchanged):[])];r=r.update({effects:O.appendConfig.of(o)}).state,a=a.update({effects:O.appendConfig.of(o)}).state,this.dom=document.createElement(`div`),this.dom.className=`cm-mergeView`,this.editorDOM=this.dom.appendChild(document.createElement(`div`)),this.editorDOM.className=`cm-mergeViewEditors`;let s=e.orientation||`a-b`,c=document.createElement(`div`);c.className=`cm-mergeViewEditor`;let l=document.createElement(`div`);l.className=`cm-mergeViewEditor`,this.editorDOM.appendChild(s==`a-b`?c:l),this.editorDOM.appendChild(s==`a-b`?l:c),this.a=new d({state:r,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new d({state:a,parent:l,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls==`b-to-a`,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some(e=>e.docChanged)){let n=e[e.length-1],r=e.reduce((e,t)=>e.compose(t.changes),f.empty(e[0].startState.doc.length));this.chunks=t==this.a?W.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):W.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:H.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:H.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if(`diffConfig`in e&&(this.diffConf=e.diffConfig),`orientation`in e){let t=e.orientation!=`b-a`;if(t!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let e=this.a.dom.parentNode,n=this.b.dom.parentNode;e.remove(),n.remove(),this.editorDOM.insertBefore(t?e:n,this.editorDOM.firstChild),this.editorDOM.appendChild(t?n:e),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent=``)}}if(`revertControls`in e||`renderRevertControl`in e){let t=!!this.revertDOM,n=this.revertToA,r=this.renderRevert;`revertControls`in e&&(t=!!e.revertControls,n=e.revertControls==`b-to-a`),`renderRevertControl`in e&&(r=e.renderRevertControl),this.setupRevertControls(t,n,r)}let t=`highlightChanges`in e,n=`gutter`in e,r=`collapseUnchanged`in e;if(t||n||r){let i=[],a=[];if(t||n){let r=this.a.state.facet(V),o=n?e.gutter!==!1:r.markGutter,s=t?e.highlightChanges!==!1:r.highlightChanges;i.push(Q.reconfigure([V.of({side:`a`,sibling:()=>this.b,highlightChanges:s,markGutter:o}),o?K:[]])),a.push(Q.reconfigure([V.of({side:`b`,sibling:()=>this.a,highlightChanges:s,markGutter:o}),o?K:[]]))}if(r){let t=Qe.reconfigure(e.collapseUnchanged?Je(e.collapseUnchanged):[]);i.push(t),a.push(t)}this.a.dispatch({effects:i}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,t,n){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement(`div`),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener(`mousedown`,e=>this.revertClicked(e)),this.revertDOM.className=`cm-merge-revert`):this.revertDOM&&(this.revertDOM.textContent=``)}scheduleMeasure(){this.measuring<0&&(this.measuring=(this.dom.ownerDocument.defaultView||window).requestAnimationFrame(()=>{this.measuring=-1,this.measure()}))}measure(){We(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,r=this.b.viewport;for(let i=0;i<this.chunks.length;i++){let a=this.chunks[i];if(a.fromA>n.to||a.fromB>r.to)break;if(a.fromA<n.from||a.fromB<r.from)continue;let o=this.a.lineBlockAt(a.fromA).top+`px`;for(;t&&+t.dataset.chunk<i;)t=et(t);t&&t.dataset.chunk==String(i)?(t.style.top!=o&&(t.style.top=o),t=t.nextSibling):e.insertBefore(this.renderRevertButton(o,i),t)}for(;t;)t=et(t)}renderRevertButton(e,t){let n;if(this.renderRevert)n=this.renderRevert();else{n=document.createElement(`button`);let e=this.a.state.phrase(`Revert this chunk`);n.setAttribute(`aria-label`,e),n.setAttribute(`title`,e),n.textContent=this.revertToLeft?`⇜`:`⇝`}return n.style.top=e,n.setAttribute(`data-chunk`,String(t)),n}revertClicked(e){let t=e.target,n;for(;t&&t.parentNode!=this.revertDOM;)t=t.parentNode;if(t&&(n=this.chunks[t.dataset.chunk])){let[t,r,i,a,o,s]=this.revertToA?[this.b,this.a,n.fromB,n.toB,n.fromA,n.toA]:[this.a,this.b,n.fromA,n.toA,n.fromB,n.toB],c=t.state.sliceDoc(i,Math.max(i,a-1));i!=a&&s<=r.state.doc.length&&(c+=t.state.lineBreak),r.dispatch({changes:{from:o,to:Math.min(r.state.doc.length,s),insert:c},userEvent:`revert`}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}};function et(e){let t=e.nextSibling;return e.remove(),t}var $=n();function tt(e){switch(e.split(`.`).pop()?.toLowerCase()??``){case`js`:case`jsx`:return w({jsx:!0});case`ts`:case`tsx`:return w({jsx:!0,typescript:!0});case`py`:return m();case`html`:return E();case`css`:case`scss`:return v();case`json`:return S();case`md`:case`mdx`:return te();default:return null}}function nt({metadata:e}){let t=e?.filePath,n=e?.projectName,s=e?.ref1,c=e?.ref2,u=e?.file1,f=e?.file2,p=!!(u&&f),[m,h]=(0,k.useState)(null),[g,_]=(0,k.useState)(null),[v,y]=(0,k.useState)(!0),[b,x]=(0,k.useState)(null),S=(0,k.useRef)(null),w=(0,k.useRef)(null);(0,k.useEffect)(()=>{if(!n)return;if(y(!0),x(null),u&&f){let e=new URLSearchParams;e.set(`file1`,u),e.set(`file2`,f),a.get(`${i(n)}/files/compare?${e.toString()}`).then(e=>{_(e),y(!1)}).catch(e=>{x(e instanceof Error?e.message:`Failed to compare files`),y(!1)});return}let e;if(t){let r=new URLSearchParams;r.set(`file`,t),s&&r.set(`ref`,s),e=`${i(n)}/git/file-diff?${r.toString()}`}else if(s||c){let t=new URLSearchParams;s&&t.set(`ref1`,s),c&&t.set(`ref2`,c),e=`${i(n)}/git/diff?${t.toString()}`}else e=`${i(n)}/git/diff`;a.get(e).then(e=>{h(e.diff),y(!1)}).catch(e=>{x(e instanceof Error?e.message:`Failed to load diff`),y(!1)})},[t,n,s,c,u,f]);let{original:T,modified:E}=(0,k.useMemo)(()=>p&&g?g:m?rt(m):{original:``,modified:``},[m,p,g]),D=(0,k.useMemo)(()=>{let e=t??f??u;if(!e)return[];let n=tt(e);return n?[n]:[]},[t,u,f]);return(0,k.useEffect)(()=>{let e=S.current;if(!e||v||b||!T&&!E)return;w.current&&=(w.current.destroy(),null),window.innerWidth;let t=[...D,ee,d.editable.of(!1),C.readOnly.of(!0),l(),d.theme({"&":{fontSize:`13px`,fontFamily:`var(--font-mono)`},"& .cm-changedText":{textDecoration:`none !important`,borderBottom:`none !important`,textDecorationLine:`none !important`,backgroundColor:`rgba(16, 185, 129, 0.4) !important`,borderRadius:`2px`},"& .cm-deletedChunk .cm-changedText":{backgroundColor:`rgba(239, 68, 68, 0.4) !important`}})],n=new $e({parent:e,a:{doc:T,extensions:t},b:{doc:E,extensions:t},orientation:`a-b`,revertControls:void 0,highlightChanges:!0,gutter:!0});w.current=n;let r=n.a.dom.querySelector(`.cm-scroller`),i=n.b.dom.querySelector(`.cm-scroller`),a=!1,o=(e,t)=>{a||=(a=!0,t.scrollLeft=e.scrollLeft,!1)},s=()=>r&&i&&o(r,i),c=()=>r&&i&&o(i,r);return r?.addEventListener(`scroll`,s),i?.addEventListener(`scroll`,c),()=>{r?.removeEventListener(`scroll`,s),i?.removeEventListener(`scroll`,c),n.destroy(),w.current=null}},[T,E,D,v,b]),n?v?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,$.jsx)(r,{className:`size-5 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Loading diff...`})]}):b?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-destructive text-sm`,children:b}):!p&&(!m||m.trim()===``)?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,$.jsx)(o,{className:`size-8`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`No changes detected`}),t&&(0,$.jsx)(`p`,{className:`text-xs font-mono`,children:t})]}):(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b text-xs text-muted-foreground`,children:[(0,$.jsx)(o,{className:`size-3.5`}),p?(0,$.jsxs)(`span`,{className:`font-mono truncate`,children:[u,` vs `,f]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`font-mono`,children:t??`Working tree changes`}),(s||c)&&(0,$.jsxs)(`span`,{children:[`(`,s?.slice(0,7)??`HEAD`,` vs `,c?.slice(0,7)??`working tree`,`)`]})]})]}),(0,$.jsx)(`div`,{ref:S,className:`flex-1 overflow-auto touch-pinch-zoom [&_.cm-mergeView]:h-full`,style:{WebkitOverflowScrolling:`touch`}})]}):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`})}function rt(e){let t=e.split(`
1
+ import{i as e,n as t,t as n}from"./jsx-runtime-BnxRlLMJ.js";import{a as r,r as i,t as a}from"./api-client-Bnf9LAt4.js";import{b as o}from"./index-iwjbGjDp.js";import{A as s,E as c,H as l,I as u,O as d,Q as f,Y as p,a as m,at as h,ct as g,et as _,i as v,it as y,j as b,k as x,n as S,nt as C,o as w,ot as T,r as E,rt as D,s as ee,st as O,t as te}from"./dist-CSp7ir0r.js";var k=e(t(),1),A=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}offset(t,n=t){return new e(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}};function j(e,t,n,r,i,a){if(e==r)return[];let o=I(e,t,n,r,i,a),s=L(e,t+o,n,r,i+o,a);t+=o,n-=s,i+=o,a-=s;let c=n-t,l=a-i;if(!c||!l)return[new A(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new A(t,t+o,i,i),new A(t+o+l,n,a,a)]}else if(l>c){let o=r.slice(i,a).indexOf(e.slice(t,n));if(o>-1)return[new A(t,t,i,i+o),new A(n,n,i+o+c,a)]}if(c==1||l==1)return[new A(t,n,i,a)];let u=se(e,t,n,r,i,a);if(u){let[o,s,c]=u;return j(e,t,o,r,i,s).concat(j(e,o+c,n,r,s+c,a))}return ne(e,t,n,r,i,a)}var M=1e9,N=0,P=!1;function ne(e,t,n,r,i,a){let o=n-t,s=a-i;if(M<1e9&&Math.min(o,s)>M*16||N>0&&Date.now()>N)return Math.min(o,s)>M*64?[new A(t,n,i,a)]:ce(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);ie.reset(c),F.reset(c);let l=(n,a)=>e.charCodeAt(t+n)==r.charCodeAt(i+a),u=(t,i)=>e.charCodeAt(n-t-1)==r.charCodeAt(a-i-1),d=(o-s)%2==0?null:F,f=d?null:ie;for(let p=0;p<c;p++){if(p>M||N>0&&!(p&63)&&Date.now()>N)return ce(e,t,n,r,i,a);let m=ie.advance(p,o,s,c,d,!1,l)||F.advance(p,o,s,c,f,!0,u);if(m)return ae(e,t,n,t+m[0],r,i,a,i+m[1])}return[new A(t,n,i,a)]}var re=class{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let e=0;e<this.len;e++)this.vec[e]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,n,r,i,a,o){for(let s=-e+this.start;s<=e-this.end;s+=2){let c=r+s,l=s==-e||s!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,u=l-s;for(;l<t&&u<n&&o(l,u);)l++,u++;if(this.vec[c]=l,l>t)this.end+=2;else if(u>n)this.start+=2;else if(i){let e=r+(t-n)-s;if(e>=0&&e<this.len&&i.vec[e]!=-1)if(a){let n=i.vec[e];if(n>=t-l)return[n,r+n-e]}else{let n=t-i.vec[e];if(l>=n)return[l,u]}}}return null}},ie=new re,F=new re;function ae(e,t,n,r,i,a,o,s){let c=!1;return!B(e,r)&&++r==n&&(c=!0),!B(i,s)&&++s==o&&(c=!0),c?[new A(t,n,a,o)]:j(e,t,r,i,a,s).concat(j(e,r,n,i,s,o))}function oe(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function I(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=oe(n-t,a-i);for(let s=t,c=i;;){let i=s+o,l=c+o;if(i>n||l>a||e.slice(s,i)!=r.slice(c,l)){if(o==1)return s-t-(B(e,s)?0:1);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function L(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=oe(n-t,a-i);for(let s=n,c=a;;){let a=s-o,l=c-o;if(a<t||l<i||e.slice(a,s)!=r.slice(l,c)){if(o==1)return n-s-(B(e,s)?0:1);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function R(e,t,n,r,i,a,o,s){let c=r.slice(i,a),l=null;for(;;){if(l||o<s)return l;for(let s=t+o;;){B(e,s)||s++;let u=s+o;if(B(e,u)||(u+=u==s+1?1:-1),u>=n)break;let d=e.slice(s,u),f=-1;for(;(f=c.indexOf(d,f+1))!=-1;){let o=I(e,u,n,r,i+f+d.length,a),c=L(e,t,s,r,i,i+f),p=d.length+o+c;(!l||l[2]<p)&&(l=[s-c,i+f-c,p])}s=u}if(s<0)return l;o>>=1}}function se(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=se(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:R(e,t,n,r,i,a,Math.floor(o/4),-1)}function ce(e,t,n,r,i,a){P=!0;let o=n-t,s=a-i,c;if(o<s){let s=R(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=R(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new A(t,n,i,a)];let[l,u,d]=c;return j(e,t,l,r,i,u).concat(j(e,l+d,n,r,u+d,a))}function le(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];r.toA>i.fromA-t&&r.toB>i.fromB-t&&(e[n-1]=new A(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function ue(e,t,n){for(;;){le(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=I(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new A(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=L(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new A(a.fromA,a.toA-s,a.fromB,a.toB-s));let c=a.toA-a.fromA,l=a.toB-a.fromB;if(c&&l)continue;let u=a.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:e.length)-a.toA;if(!u||!d)continue;let f=c?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);u<=f.length&&e.slice(a.fromA-u,a.fromA)==f.slice(f.length-u)?(n[i]=new A(a.fromA-u,a.toA-u,a.fromB-u,a.toB-u),r=!0):d<=f.length&&e.slice(a.toA,a.toA+d)==f.slice(0,d)&&(n[i]=new A(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}function de(e,t,n){for(let r=0,i=0;i<e.length;i++){let a=e[i],o=a.toA-a.fromA,s=a.toB-a.fromB;if(o&&s||o>3||s>3){let c=i==e.length-1?t.length:e[i+1].fromA,l=a.fromA-r,u=c-a.toA,d=_e(t,a.fromA,l),f=ge(t,a.toA,u),p=a.fromA-d,m=f-a.toA;if((!o||!s)&&p&&m){let l=Math.max(o,s),[u,h,g]=o?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];l>p&&t.slice(d,a.fromA)==u.slice(g-p,g)?(a=e[i]=new A(d,d+o,a.fromB-p,a.toB-p),d=a.fromA,f=ge(t,a.toA,c-a.toA)):l>m&&t.slice(a.toA,f)==u.slice(h,h+m)&&(a=e[i]=new A(f-o,f,a.fromB+m,a.toB+m),f=a.toA,d=_e(t,a.fromA,a.fromA-r)),p=a.fromA-d,m=f-a.toA}if(p||m)a=e[i]=new A(a.fromA-p,a.toA+m,a.fromB-p,a.toB+m);else if(!o){let t=ye(n,a.fromB,a.toB),r,o=t<0?-1:ve(n,a.toB,a.fromB);t>-1&&(r=t-a.fromB)<=u&&n.slice(a.fromB,t)==n.slice(a.toB,a.toB+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toB-o)<=l&&n.slice(a.fromB-r,a.fromB)==n.slice(o,a.toB)&&(a=e[i]=a.offset(-r))}else if(!s){let n=ye(t,a.fromA,a.toA),r,o=n<0?-1:ve(t,a.toA,a.fromA);n>-1&&(r=n-a.fromA)<=u&&t.slice(a.fromA,n)==t.slice(a.toA,a.toA+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toA-o)<=l&&t.slice(a.fromA-r,a.fromA)==t.slice(o,a.toA)&&(a=e[i]=a.offset(-r))}}r=a.toA}return le(e,3),e}var z;try{z=RegExp(`[\\p{Alphabetic}\\p{Number}]`,`u`)}catch{}function fe(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function pe(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?fe(n)?1:0:z?!be(n)||t==e.length-1?z.test(String.fromCharCode(n))?1:0:z.test(e.slice(t,t+2))?2:0:0}function me(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?fe(n)?1:0:z?!xe(n)||t==1?z.test(String.fromCharCode(n))?1:0:z.test(e.slice(t-2,t))?2:0:0}var he=8;function ge(e,t,n){if(t==e.length||!me(e,t))return t;for(let r=t,i=t+n,a=0;a<he;a++){let t=pe(e,r);if(!t||r+t>i)return r;r+=t}return t}function _e(e,t,n){if(!t||!pe(e,t))return t;for(let r=t,i=t-n,a=0;a<he;a++){let t=me(e,r);if(!t||r-t<i)return r;r-=t}return t}function ve(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function ye(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}var be=e=>e>=55296&&e<=56319,xe=e=>e>=56320&&e<=57343;function B(e,t){return!t||t==e.length||!be(e.charCodeAt(t-1))||!xe(e.charCodeAt(t))}function Se(e,t,n){let r=n?.override;return r?r(e,t):(M=(n?.scanLimit??1e9)>>1,N=n?.timeout?Date.now()+n.timeout:0,P=!1,ue(e,t,j(e,0,e.length,t,0,t.length)))}function Ce(){return!P}function we(e,t,n){return de(Se(e,t,n),e,t)}var V=D.define({combine:e=>e[0]}),H=O.define(),Te=D.define(),U=g.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(H)&&(e=n.value);for(let n of t.state.facet(Te))e=n(e,t);return e}}),W=class e{constructor(e,t,n,r,i,a=!0){this.changes=e,this.fromA=t,this.toA=n,this.fromB=r,this.toB=i,this.precise=a}offset(t,n){return t||n?new e(this.changes,this.fromA+t,this.toA+t,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,t,n){return Oe(we(e.toString(),t.toString(),n),e,t,0,0,Ce())}static updateA(e,t,n,r,i){return je(Ae(e,r,!0,n.length),e,t,n,i)}static updateB(e,t,n,r,i){return je(Ae(e,r,!1,t.length),e,t,n,i)}};function Ee(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.to==e&&a.to==t&&e<n.length&&t<r.length?[e+1,t+1]:[i.from,a.from]}function De(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.from==e&&a.from==t?[e,t]:[i.to+1,a.to+1]}function Oe(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length;s++){let c=e[s],[l,u]=Ee(c.fromA+r,c.fromB+i,t,n),[d,f]=De(c.toA+r,c.toB+i,t,n),p=[c.offset(-l+r,-u+i)];for(;s<e.length-1;){let a=e[s+1],[o,c]=Ee(a.fromA+r,a.fromB+i,t,n);if(o>d+1&&c>f+1)break;p.push(a.offset(-l+r,-u+i)),[d,f]=De(a.toA+r,a.toB+i,t,n),s++}o.push(new W(p,l,Math.max(l,d),u,Math.max(u,f),a))}return o}var G=1e3;function ke(e,t,n,r){let i=0,a=e.length;for(;;){if(i==a){let r=0,a=0;i&&({toA:r,toB:a}=e[i-1]);let o=t-(n?r:a);return[r+o,a+o]}let o=i+a>>1,s=e[o],[c,l]=n?[s.fromA,s.toA]:[s.fromB,s.toB];if(c>t)a=o;else if(l<=t)i=o+1;else return r?[s.fromA,s.fromB]:[s.toA,s.toB]}}function Ae(e,t,n,r){let i=[];return t.iterChangedRanges((a,o,s,c)=>{let l=0,u=n?t.length:r,d=0,f=n?r:t.length;a>G&&([l,d]=ke(e,a-G,n,!0)),o<t.length-G&&([u,f]=ke(e,o+G,n,!1));let p=c-s-(o-a),m,[h,g]=n?[p,0]:[0,p];i.length&&(m=i[i.length-1]).toA>=l?i[i.length-1]={fromA:m.fromA,fromB:m.fromB,toA:u,toB:f,diffA:m.diffA+h,diffB:m.diffB+g}:i.push({fromA:l,toA:u,fromB:d,toB:f,diffA:h,diffB:g})}),i}function je(e,t,n,r,i){if(!e.length)return t;let a=[];for(let o=0,s=0,c=0,l=0;;o++){let u=o==e.length?null:e[o],d=u?u.fromA+s:n.length,f=u?u.fromB+c:r.length;for(;l<t.length;){let e=t[l];if(u&&(e.toA+s>d||e.toB+c>f))break;a.push(e.offset(s,c)),l++}if(!u)break;let p=u.toA+s+u.diffA,m=u.toB+c+u.diffB,h=we(n.sliceString(d,p),r.sliceString(f,m),i);for(let e of Oe(h,n,r,d,f,Ce()))a.push(e);for(s+=u.diffA,c+=u.diffB;l<t.length;){let e=t[l];if(e.fromA+s>p&&e.fromB+c>m)break;l++}}return a}var Me={scanLimit:500},Ne=s.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=He(e))}update(e){(e.docChanged||e.viewportChanged||Pe(e.startState,e.state)||Fe(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=He(e.view))}},{decorations:e=>e.deco}),K=y.low(u({class:`cm-changeGutter`,markers:e=>e.plugin(Ne)?.gutter||h.empty}));function Pe(e,t){return e.field(U,!1)!=t.field(U,!1)}function Fe(e,t){return e.facet(V)!=t.facet(V)}var Ie=c.line({class:`cm-changedLine`}),Le=c.mark({class:`cm-changedText`}),Re=c.mark({tagName:`ins`,class:`cm-insertedLine`}),ze=c.mark({tagName:`del`,class:`cm-deletedLine`}),Be=new class extends x{constructor(){super(...arguments),this.elementClass=`cm-changedLineGutter`}};function Ve(e,t,n,r,i,a){let o=n?e.fromA:e.fromB,s=n?e.toA:e.toB,c=0;if(o!=s){i.add(o,o,Ie),i.add(o,s,n?ze:Re),a&&a.add(o,o,Be);for(let l=t.iterRange(o,s-1),u=o;!l.next().done;){if(l.lineBreak){u++,i.add(u,u,Ie),a&&a.add(u,u,Be);continue}let t=u+l.value.length;if(r)for(;c<e.changes.length;){let r=e.changes[c],a=o+(n?r.fromA:r.fromB),s=o+(n?r.toA:r.toB),l=Math.max(u,a),d=Math.min(t,s);if(l<d&&i.add(l,d,Le),s<t)c++;else break}u=t}}}function He(e){let t=e.state.field(U),{side:n,highlightChanges:r,markGutter:i,overrideChunk:a}=e.state.facet(V),o=n==`a`,s=new T,c=i?new T:null,{from:l,to:u}=e.viewport;for(let n of t){if((o?n.fromA:n.fromB)>=u)break;(o?n.toA:n.toB)>l&&(!a||!a(e.state,n,s,c))&&Ve(n,e.state.doc,o,r,s,c)}return{deco:s.finish(),gutter:c&&c.finish()}}var q=class extends b{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement(`div`);return e.className=`cm-mergeSpacer`,e.style.height=this.height+`px`,e}updateDOM(e){return e.style.height=this.height+`px`,!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},J=O.define({map:(e,t)=>e.map(t)}),Y=g.define({create:()=>c.none,update:(e,t)=>{for(let e of t.effects)if(e.is(J))return e.value;return e.map(t.changes)},provide:e=>d.decorations.from(e)}),X=.01;function Ue(e,t){if(e.size!=t.size)return!1;let n=e.iter(),r=t.iter();for(;n.value;){if(n.from!=r.from||Math.abs(n.value.spec.widget.height-r.value.spec.widget.height)>1)return!1;n.next(),r.next()}return!0}function We(e,t,n){let r=new T,i=new T,a=e.state.field(Y).iter(),o=t.state.field(Y).iter(),s=0,l=0,u=0,d=0,f=e.viewport,p=t.viewport;for(let m=0;;m++){let h=m<n.length?n[m]:null,g=h?h.fromA:e.state.doc.length,_=h?h.fromB:t.state.doc.length;if(s<g){let n=e.lineBlockAt(s).top+u-(t.lineBlockAt(l).top+d);n<-X?(u-=n,r.add(s,s,c.widget({widget:new q(-n),block:!0,side:-1}))):n>X&&(d+=n,i.add(l,l,c.widget({widget:new q(n),block:!0,side:-1})))}if(g>s+1e3&&s<f.from&&g>f.from&&l<p.from&&_>p.from){let e=Math.min(f.from-s,p.from-l);s+=e,l+=e,m--}else if(h)s=h.toA,l=h.toB;else break;for(;a.value&&a.from<s;)u-=a.value.spec.widget.height,a.next();for(;o.value&&o.from<l;)d-=o.value.spec.widget.height,o.next()}for(;a.value;)u-=a.value.spec.widget.height,a.next();for(;o.value;)d-=o.value.spec.widget.height,o.next();let m=e.contentHeight+u-(t.contentHeight+d);m<X?r.add(e.state.doc.length,e.state.doc.length,c.widget({widget:new q(-m),block:!0,side:1})):m>X&&i.add(t.state.doc.length,t.state.doc.length,c.widget({widget:new q(m),block:!0,side:1}));let h=r.finish(),g=i.finish();Ue(h,e.state.field(Y))||e.dispatch({effects:J.of(h)}),Ue(g,t.state.field(Y))||t.dispatch({effects:J.of(g)})}var Z=O.define({map:(e,t)=>t.mapPos(e)}),Ge=class extends b{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement(`div`);return t.className=`cm-collapsedLines`,t.textContent=e.state.phrase(`$ unchanged lines`,this.lines),t.addEventListener(`click`,t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:Z.of(n)});let{side:r,sibling:i}=e.state.facet(V);i&&i().dispatch({effects:Z.of(Ke(n,e.state.field(U),r==`a`))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return`collapsed-unchanged-code`}};function Ke(e,t,n){let r=0,i=0;for(let a=0;;a++){let o=a<t.length?t[a]:null;if(!o||(n?o.fromA:o.fromB)>=e)return i+(e-r);[r,i]=n?[o.toA,o.toB]:[o.toB,o.toA]}}var qe=g.define({create(e){return c.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Z)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>d.decorations.from(e)});function Je({margin:e=3,minSize:t=4}){return qe.init(n=>Ye(n,e,t))}function Ye(e,t,n){let r=new T,i=e.facet(V).side==`a`,a=e.field(U),o=1;for(let s=0;;s++){let l=s<a.length?a[s]:null,u=s?o+t:1,d=l?e.doc.lineAt(i?l.fromA:l.fromB).number-1-t:e.doc.lines,f=d-u+1;if(f>=n&&r.add(e.doc.line(u).from,e.doc.line(d).to,c.replace({widget:new Ge(f),block:!0})),!l)break;o=e.doc.lineAt(Math.min(e.doc.length,i?l.toA:l.toB)).number}return r.finish()}var Xe=d.styleModule.of(new p({".cm-mergeView":{overflowY:`auto`},".cm-mergeViewEditors":{display:`flex`,alignItems:`stretch`},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:`hidden`},".cm-merge-revert":{width:`1.6em`,flexGrow:0,flexShrink:0,position:`relative`},".cm-merge-revert button":{position:`absolute`,display:`block`,width:`100%`,boxSizing:`border-box`,textAlign:`center`,background:`none`,border:`none`,font:`inherit`,cursor:`pointer`}})),Ze=d.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:`auto !important`,overflowY:`visible !important`},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:`rgba(160, 128, 100, .08)`},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:`rgba(100, 160, 128, .08)`},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat`},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat`},"&light.cm-merge-b .cm-changedText":{background:`linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat`},"&dark.cm-merge-b .cm-changedText":{background:`linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat`},"&.cm-merge-b .cm-deletedText":{background:`#ff000033`},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:`none`},".cm-deletedChunk":{paddingLeft:`6px`,"& .cm-chunkButtons":{position:`absolute`,insetInlineEnd:`5px`},"& button":{border:`none`,cursor:`pointer`,color:`white`,margin:`0 2px`,borderRadius:`3px`,"&[name=accept]":{background:`#2a2`},"&[name=reject]":{background:`#d43`}}},".cm-collapsedLines":{padding:`5px 5px 5px 10px`,cursor:`pointer`,"&:before":{content:`"⦚"`,marginInlineEnd:`7px`},"&:after":{content:`"⦚"`,marginInlineStart:`7px`}},"&light .cm-collapsedLines":{color:`#444`,background:`linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)`},"&dark .cm-collapsedLines":{color:`#ddd`,background:`linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)`},".cm-changeGutter":{width:`3px`,paddingLeft:`1px`},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:`#e43`},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:`#fa9`},"&light.cm-merge-b .cm-changedLineGutter":{background:`#2b2`},"&dark.cm-merge-b .cm-changedLineGutter":{background:`#8f8`},".cm-inlineChangedLineGutter":{background:`#75d`}}),Qe=new _,Q=new _,$e=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||Me;let t=[y.low(Ne),Ze,Xe,Y,d.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(J)))&&this.measure()})],n=[V.of({side:`a`,sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(K);let r=C.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],d.editorAttributes.of({class:`cm-merge-a`}),Q.of(n),t]}),i=[V.of({side:`b`,sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(K);let a=C.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],d.editorAttributes.of({class:`cm-merge-b`}),Q.of(i),t]});this.chunks=W.build(r.doc,a.doc,this.diffConf);let o=[U.init(()=>this.chunks),Qe.of(e.collapseUnchanged?Je(e.collapseUnchanged):[])];r=r.update({effects:O.appendConfig.of(o)}).state,a=a.update({effects:O.appendConfig.of(o)}).state,this.dom=document.createElement(`div`),this.dom.className=`cm-mergeView`,this.editorDOM=this.dom.appendChild(document.createElement(`div`)),this.editorDOM.className=`cm-mergeViewEditors`;let s=e.orientation||`a-b`,c=document.createElement(`div`);c.className=`cm-mergeViewEditor`;let l=document.createElement(`div`);l.className=`cm-mergeViewEditor`,this.editorDOM.appendChild(s==`a-b`?c:l),this.editorDOM.appendChild(s==`a-b`?l:c),this.a=new d({state:r,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new d({state:a,parent:l,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls==`b-to-a`,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some(e=>e.docChanged)){let n=e[e.length-1],r=e.reduce((e,t)=>e.compose(t.changes),f.empty(e[0].startState.doc.length));this.chunks=t==this.a?W.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):W.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:H.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:H.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if(`diffConfig`in e&&(this.diffConf=e.diffConfig),`orientation`in e){let t=e.orientation!=`b-a`;if(t!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let e=this.a.dom.parentNode,n=this.b.dom.parentNode;e.remove(),n.remove(),this.editorDOM.insertBefore(t?e:n,this.editorDOM.firstChild),this.editorDOM.appendChild(t?n:e),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent=``)}}if(`revertControls`in e||`renderRevertControl`in e){let t=!!this.revertDOM,n=this.revertToA,r=this.renderRevert;`revertControls`in e&&(t=!!e.revertControls,n=e.revertControls==`b-to-a`),`renderRevertControl`in e&&(r=e.renderRevertControl),this.setupRevertControls(t,n,r)}let t=`highlightChanges`in e,n=`gutter`in e,r=`collapseUnchanged`in e;if(t||n||r){let i=[],a=[];if(t||n){let r=this.a.state.facet(V),o=n?e.gutter!==!1:r.markGutter,s=t?e.highlightChanges!==!1:r.highlightChanges;i.push(Q.reconfigure([V.of({side:`a`,sibling:()=>this.b,highlightChanges:s,markGutter:o}),o?K:[]])),a.push(Q.reconfigure([V.of({side:`b`,sibling:()=>this.a,highlightChanges:s,markGutter:o}),o?K:[]]))}if(r){let t=Qe.reconfigure(e.collapseUnchanged?Je(e.collapseUnchanged):[]);i.push(t),a.push(t)}this.a.dispatch({effects:i}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,t,n){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement(`div`),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener(`mousedown`,e=>this.revertClicked(e)),this.revertDOM.className=`cm-merge-revert`):this.revertDOM&&(this.revertDOM.textContent=``)}scheduleMeasure(){this.measuring<0&&(this.measuring=(this.dom.ownerDocument.defaultView||window).requestAnimationFrame(()=>{this.measuring=-1,this.measure()}))}measure(){We(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,r=this.b.viewport;for(let i=0;i<this.chunks.length;i++){let a=this.chunks[i];if(a.fromA>n.to||a.fromB>r.to)break;if(a.fromA<n.from||a.fromB<r.from)continue;let o=this.a.lineBlockAt(a.fromA).top+`px`;for(;t&&+t.dataset.chunk<i;)t=et(t);t&&t.dataset.chunk==String(i)?(t.style.top!=o&&(t.style.top=o),t=t.nextSibling):e.insertBefore(this.renderRevertButton(o,i),t)}for(;t;)t=et(t)}renderRevertButton(e,t){let n;if(this.renderRevert)n=this.renderRevert();else{n=document.createElement(`button`);let e=this.a.state.phrase(`Revert this chunk`);n.setAttribute(`aria-label`,e),n.setAttribute(`title`,e),n.textContent=this.revertToLeft?`⇜`:`⇝`}return n.style.top=e,n.setAttribute(`data-chunk`,String(t)),n}revertClicked(e){let t=e.target,n;for(;t&&t.parentNode!=this.revertDOM;)t=t.parentNode;if(t&&(n=this.chunks[t.dataset.chunk])){let[t,r,i,a,o,s]=this.revertToA?[this.b,this.a,n.fromB,n.toB,n.fromA,n.toA]:[this.a,this.b,n.fromA,n.toA,n.fromB,n.toB],c=t.state.sliceDoc(i,Math.max(i,a-1));i!=a&&s<=r.state.doc.length&&(c+=t.state.lineBreak),r.dispatch({changes:{from:o,to:Math.min(r.state.doc.length,s),insert:c},userEvent:`revert`}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}};function et(e){let t=e.nextSibling;return e.remove(),t}var $=n();function tt(e){switch(e.split(`.`).pop()?.toLowerCase()??``){case`js`:case`jsx`:return w({jsx:!0});case`ts`:case`tsx`:return w({jsx:!0,typescript:!0});case`py`:return m();case`html`:return E();case`css`:case`scss`:return v();case`json`:return S();case`md`:case`mdx`:return te();default:return null}}function nt({metadata:e}){let t=e?.filePath,n=e?.projectName,s=e?.ref1,c=e?.ref2,u=e?.file1,f=e?.file2,p=!!(u&&f),[m,h]=(0,k.useState)(null),[g,_]=(0,k.useState)(null),[v,y]=(0,k.useState)(!0),[b,x]=(0,k.useState)(null),S=(0,k.useRef)(null),w=(0,k.useRef)(null);(0,k.useEffect)(()=>{if(!n)return;if(y(!0),x(null),u&&f){let e=new URLSearchParams;e.set(`file1`,u),e.set(`file2`,f),a.get(`${i(n)}/files/compare?${e.toString()}`).then(e=>{_(e),y(!1)}).catch(e=>{x(e instanceof Error?e.message:`Failed to compare files`),y(!1)});return}let e;if(t){let r=new URLSearchParams;r.set(`file`,t),s&&r.set(`ref`,s),e=`${i(n)}/git/file-diff?${r.toString()}`}else if(s||c){let t=new URLSearchParams;s&&t.set(`ref1`,s),c&&t.set(`ref2`,c),e=`${i(n)}/git/diff?${t.toString()}`}else e=`${i(n)}/git/diff`;a.get(e).then(e=>{h(e.diff),y(!1)}).catch(e=>{x(e instanceof Error?e.message:`Failed to load diff`),y(!1)})},[t,n,s,c,u,f]);let{original:T,modified:E}=(0,k.useMemo)(()=>p&&g?g:m?rt(m):{original:``,modified:``},[m,p,g]),D=(0,k.useMemo)(()=>{let e=t??f??u;if(!e)return[];let n=tt(e);return n?[n]:[]},[t,u,f]);return(0,k.useEffect)(()=>{let e=S.current;if(!e||v||b||!T&&!E)return;w.current&&=(w.current.destroy(),null),window.innerWidth;let t=[...D,ee,d.editable.of(!1),C.readOnly.of(!0),l(),d.theme({"&":{fontSize:`13px`,fontFamily:`var(--font-mono)`},"& .cm-changedText":{textDecoration:`none !important`,borderBottom:`none !important`,textDecorationLine:`none !important`,backgroundColor:`rgba(16, 185, 129, 0.4) !important`,borderRadius:`2px`},"& .cm-deletedChunk .cm-changedText":{backgroundColor:`rgba(239, 68, 68, 0.4) !important`}})],n=new $e({parent:e,a:{doc:T,extensions:t},b:{doc:E,extensions:t},orientation:`a-b`,revertControls:void 0,highlightChanges:!0,gutter:!0});w.current=n;let r=n.a.dom.querySelector(`.cm-scroller`),i=n.b.dom.querySelector(`.cm-scroller`),a=!1,o=(e,t)=>{a||=(a=!0,t.scrollLeft=e.scrollLeft,!1)},s=()=>r&&i&&o(r,i),c=()=>r&&i&&o(i,r);return r?.addEventListener(`scroll`,s),i?.addEventListener(`scroll`,c),()=>{r?.removeEventListener(`scroll`,s),i?.removeEventListener(`scroll`,c),n.destroy(),w.current=null}},[T,E,D,v,b]),n?v?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,$.jsx)(r,{className:`size-5 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Loading diff...`})]}):b?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-destructive text-sm`,children:b}):!p&&(!m||m.trim()===``)?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,$.jsx)(o,{className:`size-8`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`No changes detected`}),t&&(0,$.jsx)(`p`,{className:`text-xs font-mono`,children:t})]}):(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b text-xs text-muted-foreground`,children:[(0,$.jsx)(o,{className:`size-3.5`}),p?(0,$.jsxs)(`span`,{className:`font-mono truncate`,children:[u,` vs `,f]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`font-mono`,children:t??`Working tree changes`}),(s||c)&&(0,$.jsxs)(`span`,{children:[`(`,s?.slice(0,7)??`HEAD`,` vs `,c?.slice(0,7)??`working tree`,`)`]})]})]}),(0,$.jsx)(`div`,{ref:S,className:`flex-1 overflow-auto touch-pinch-zoom [&_.cm-mergeView]:h-full`,style:{WebkitOverflowScrolling:`touch`}})]}):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`})}function rt(e){let t=e.split(`
2
2
  `),n=[],r=[],i=!1;for(let e of t)if(!(e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`---`)||e.startsWith(`+++`)||e.startsWith(`Binary files`))){if(e.startsWith(`@@`)){i=!0;continue}if(i){if(e.startsWith(`-`))n.push(e.slice(1));else if(e.startsWith(`+`))r.push(e.slice(1));else if(e.startsWith(` `)||e===``){let t=e.startsWith(` `)?e.slice(1):e;n.push(t),r.push(t)}}}return{original:n.join(`
3
3
  `),modified:r.join(`
4
4
  `)}}export{nt as DiffViewer};
@@ -1 +1 @@
1
- import{i as e,n as t,t as n}from"./jsx-runtime-BnxRlLMJ.js";import{t as r}from"./button-BxijdhtM.js";import{t as i}from"./createLucideIcon-Dy1wlrF7.js";import{t as a}from"./arrow-up-from-line-BXL5dtbG.js";import{t as o}from"./external-link-WSiY-639.js";import{a as s,r as c,t as l}from"./api-client-Bnf9LAt4.js";import{t as u}from"./refresh-cw-DtopuYJf.js";import{t as d}from"./trash-2-CHLebaNh.js";import{a as f,i as p,n as m,o as h,t as g}from"./dialog-RczsXsmw.js";import{a as _,c as v,h as y,i as b,o as x,r as ee,s as S,u as te}from"./index-DGSLw2GE.js";var ne=i(`cherry`,[[`path`,{d:`M2 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z`,key:`cvxqlc`}],[`path`,{d:`M12 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z`,key:`1ostrc`}],[`path`,{d:`M7 14c3.22-2.91 4.29-8.75 5-12 1.66 2.38 4.94 9 5 12`,key:`hqx58h`}],[`path`,{d:`M22 9c-4.29 0-7.14-2.33-10-7 5.71 0 10 4.67 10 7Z`,key:`eykp1o`}]]),re=i(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),C=i(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),ie=i(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),ae=i(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),w=i(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),T=e(t(),1),E=n(),D=[`#4fc3f7`,`#81c784`,`#ffb74d`,`#e57373`,`#ba68c8`,`#4dd0e1`,`#aed581`,`#ff8a65`,`#f06292`,`#7986cb`],O=32,k=20,oe=5;function A({metadata:e}){let t=e?.projectName,[n,i]=(0,T.useState)(null),[a,o]=(0,T.useState)(!0),[d,C]=(0,T.useState)(null),[A,j]=(0,T.useState)(!1),[M,N]=(0,T.useState)({type:null}),[P,F]=(0,T.useState)(``),[I,L]=(0,T.useState)(null),[R,z]=(0,T.useState)([]),[ce,B]=(0,T.useState)(!1),{openTab:V}=te(),H=(0,T.useCallback)(async()=>{if(t)try{o(!0),i(await l.get(`${c(t)}/git/graph?max=200`)),C(null)}catch(e){C(e instanceof Error?e.message:`Failed to fetch graph`)}finally{o(!1)}},[t]);(0,T.useEffect)(()=>{H()},[H]);let U=async(e,n)=>{if(t){j(!0);try{await l.post(`${c(t)}${e}`,n),await H()}catch(e){C(e instanceof Error?e.message:`Action failed`)}finally{j(!1)}}},W=e=>U(`/git/checkout`,{ref:e}),le=e=>U(`/git/cherry-pick`,{hash:e}),ue=e=>U(`/git/revert`,{hash:e}),de=e=>U(`/git/merge`,{source:e}),fe=e=>U(`/git/branch/delete`,{name:e}),pe=e=>U(`/git/push`,{branch:e}),G=async(e,t)=>{if(n?.branches.some(t=>t.name===e||t.name.endsWith(`/${e}`))){if(!window.confirm(`Branch "${e}" already exists.\nDelete it and recreate from this commit?`))return;await U(`/git/branch/delete`,{name:e})}await U(`/git/branch/create`,{name:e,from:t})},K=(e,t)=>U(`/git/tag`,{name:e,hash:t}),me=async e=>{if(t)try{let n=await l.get(`${c(t)}/git/pr-url?branch=${encodeURIComponent(e)}`);n.url&&window.open(n.url,`_blank`)}catch{}},q=e=>{navigator.clipboard.writeText(e)},he=async e=>{if(I?.hash===e.hash){L(null);return}L(e),B(!0);try{let n=e.parents[0]??``,r=n?`ref1=${encodeURIComponent(n)}&`:``,i=await l.get(`${c(t)}/git/diff-stat?${r}ref2=${encodeURIComponent(e.hash)}`);z(Array.isArray(i)?i:[])}catch(e){console.error(`diff-stat error:`,e),z([])}finally{B(!1)}},ge=e=>{let n=e.parents[0];V({type:`git-diff`,title:`Diff ${e.abbreviatedHash}`,closable:!0,metadata:{projectName:t,ref1:n??void 0,ref2:e.hash},projectId:t??null})},{laneMap:J,maxLane:_e}=(0,T.useMemo)(()=>{let e=new Map;if(!n)return{laneMap:e,maxLane:0};let t=0,r=new Map;for(let i of n.commits){let n=r.get(i.hash);n===void 0&&(n=t++),e.set(i.hash,n),r.delete(i.hash);for(let e=0;e<i.parents.length;e++){let a=i.parents[e];r.has(a)||r.set(a,e===0?n:t++)}}return{laneMap:e,maxLane:Math.max(t-1,0)}},[n]),Y=n?.branches.find(e=>e.current),ve=(0,T.useMemo)(()=>{let e=new Map;if(!n)return e;for(let t of n.branches){let n=e.get(t.commitHash)??[];n.push({name:t.name,type:`branch`}),e.set(t.commitHash,n)}for(let t of n.commits)for(let n of t.refs)if(n.startsWith(`tag: `)){let r=n.replace(`tag: `,``),i=e.get(t.hash)??[];i.push({name:r,type:`tag`}),e.set(t.hash,i)}return e},[n]),ye=(0,T.useMemo)(()=>{if(!n)return[];let e=[];for(let t=0;t<n.commits.length;t++){let r=n.commits[t],i=J.get(r.hash)??0,a=D[i%D.length];for(let o of r.parents){let s=n.commits.findIndex(e=>e.hash===o);if(s<0)continue;let c=J.get(o)??0,l=D[c%D.length],u=i*k+k/2,d=t*O+O/2,f=c*k+k/2,p=s*O+O/2,m,h=r.parents.indexOf(o)>0;if(u===f)m=`M ${u} ${d} L ${f} ${p}`;else if(h){let e=d+O;m=`M ${u} ${d} C ${u} ${e} ${f} ${d} ${f} ${e} L ${f} ${p}`}else{let e=p-O;m=`M ${u} ${d} L ${u} ${e} C ${u} ${p} ${f} ${e} ${f} ${p}`}let g=r.parents.indexOf(o)===0?a:l;e.push({d:m,color:g})}}return e},[n,J]);(_e+1)*k+k;let X=(n?.commits.length??0)*O,[Z,be]=(0,T.useState)((typeof window<`u`&&window.innerWidth<768?6:10)*k+k),Q=(0,T.useRef)(!1),$=(0,T.useCallback)(e=>{Q.current=!0;let t=Z,n=n=>{if(!Q.current)return;let r=`touches`in n?n.touches[0].clientX:n.clientX;be(Math.max(40,t+r-e))},r=()=>{Q.current=!1,window.removeEventListener(`mousemove`,n),window.removeEventListener(`mouseup`,r),window.removeEventListener(`touchmove`,n),window.removeEventListener(`touchend`,r)};window.addEventListener(`mousemove`,n),window.addEventListener(`mouseup`,r),window.addEventListener(`touchmove`,n,{passive:!1}),window.addEventListener(`touchend`,r)},[Z]),xe=(0,T.useCallback)(e=>{e.preventDefault(),$(e.clientX)},[$]),Se=(0,T.useCallback)(e=>{$(e.touches[0].clientX)},[$]);if(!t)return(0,E.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`});if(a&&!n)return(0,E.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,E.jsx)(s,{className:`size-5 animate-spin`}),(0,E.jsx)(`span`,{className:`text-sm`,children:`Loading git graph...`})]});if(d&&!n)return(0,E.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-destructive text-sm`,children:[(0,E.jsx)(`p`,{children:d}),(0,E.jsx)(r,{variant:`outline`,size:`sm`,onClick:H,children:`Retry`})]});function Ce(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);if(a<30)return`${a}d ago`;let o=Math.floor(a/30);return o<12?`${o}mo ago`:`${Math.floor(o/12)}y ago`}return(0,E.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b`,children:[(0,E.jsxs)(`span`,{className:`text-sm font-medium`,children:[`Git Graph`,Y?` - ${Y.name}`:``]}),(0,E.jsx)(r,{variant:`ghost`,size:`icon-xs`,onClick:H,disabled:A,children:(0,E.jsx)(u,{className:a?`animate-spin`:``})})]}),d&&(0,E.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive bg-destructive/10`,children:d}),(0,E.jsx)(`div`,{className:`flex-1 overflow-y-auto overflow-x-auto md:overflow-x-hidden`,children:(0,E.jsxs)(`div`,{className:`flex min-w-max md:min-w-0`,style:{height:`${X}px`},children:[(0,E.jsxs)(`div`,{className:`sticky left-0 z-10 shrink-0 bg-background`,style:{width:`${Z}px`},children:[(0,E.jsxs)(`svg`,{width:Z,height:X,children:[ye.map((e,t)=>(0,E.jsx)(`path`,{d:e.d,stroke:e.color,strokeWidth:2,fill:`none`},t)),n?.commits.map((e,t)=>{let n=J.get(e.hash)??0,r=n*k+k/2,i=t*O+O/2,a=D[n%D.length];return(0,E.jsx)(`circle`,{cx:r,cy:i,r:oe,fill:a,stroke:`#0f1419`,strokeWidth:2},e.hash)})]}),(0,E.jsx)(`div`,{className:`absolute top-0 right-0 w-3 md:w-2 h-full cursor-col-resize hover:bg-primary/20 flex items-center justify-center bg-primary/10 md:bg-transparent`,onMouseDown:xe,onTouchStart:Se,children:(0,E.jsx)(ie,{className:`size-3 text-muted-foreground md:opacity-0 md:hover:opacity-100`})})]}),(0,E.jsx)(`div`,{className:`flex-1 min-w-[400px]`,children:n?.commits.map((e,t)=>{let n=D[(J.get(e.hash)??0)%D.length],r=ve.get(e.hash)??[],i=r.filter(e=>e.type===`branch`),a=r.filter(e=>e.type===`tag`);return(0,E.jsxs)(b,{children:[(0,E.jsx)(v,{asChild:!0,children:(0,E.jsx)(`div`,{className:`flex items-center hover:bg-muted/50 cursor-pointer text-sm border-b border-border/30 ${I?.hash===e.hash?`bg-primary/10`:``}`,style:{height:`${O}px`},onClick:()=>he(e),children:(0,E.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0 px-2`,children:[(0,E.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground w-14 shrink-0`,children:e.abbreviatedHash}),i.map(e=>(0,E.jsx)(se,{label:e,color:n,currentBranch:Y,onCheckout:W,onMerge:de,onPush:pe,onCreatePr:me,onDelete:fe},`branch-${e.name}`)),a.map(e=>(0,E.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium shrink-0 bg-amber-500/20 text-amber-500 border border-amber-500/30`,children:[(0,E.jsx)(w,{className:`size-2.5`}),e.name]},`tag-${e.name}`)),(0,E.jsx)(`span`,{className:`flex-1 truncate`,children:e.subject}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0 hidden sm:inline`,children:e.authorName}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0 w-14 text-right`,children:Ce(e.authorDate)})]})})}),(0,E.jsxs)(_,{children:[(0,E.jsx)(x,{onClick:()=>W(e.hash),children:`Checkout`}),(0,E.jsxs)(x,{onClick:()=>{N({type:`branch`,hash:e.hash}),F(``)},children:[(0,E.jsx)(y,{className:`size-3`}),`Create Branch...`]}),(0,E.jsx)(S,{}),(0,E.jsxs)(x,{onClick:()=>le(e.hash),children:[(0,E.jsx)(ne,{className:`size-3`}),`Cherry Pick`]}),(0,E.jsxs)(x,{onClick:()=>ue(e.hash),children:[(0,E.jsx)(ae,{className:`size-3`}),`Revert`]}),(0,E.jsxs)(x,{onClick:()=>{N({type:`tag`,hash:e.hash}),F(``)},children:[(0,E.jsx)(w,{className:`size-3`}),`Create Tag...`]}),(0,E.jsx)(S,{}),(0,E.jsx)(x,{onClick:()=>ge(e),children:`View Diff`}),(0,E.jsxs)(x,{onClick:()=>q(e.hash),children:[(0,E.jsx)(re,{className:`size-3`}),`Copy Hash`]})]})]},e.hash)})})]})}),I&&(0,E.jsxs)(`div`,{className:`border-t bg-muted/30 max-h-[40%] overflow-auto`,children:[(0,E.jsxs)(`div`,{className:`px-3 py-2 border-b flex items-center justify-between`,children:[(0,E.jsxs)(`span`,{className:`text-sm font-medium truncate`,children:[I.abbreviatedHash,` — `,I.subject]}),(0,E.jsx)(r,{variant:`ghost`,size:`icon-xs`,onClick:()=>L(null),children:`✕`})]}),(0,E.jsxs)(`div`,{className:`px-3 py-2 text-xs space-y-1`,children:[(0,E.jsxs)(`div`,{className:`flex gap-4`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`Author`}),(0,E.jsxs)(`span`,{children:[I.authorName,` <`,I.authorEmail,`>`]})]}),(0,E.jsxs)(`div`,{className:`flex gap-4`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`Date`}),(0,E.jsx)(`span`,{children:new Date(I.authorDate).toLocaleString()})]}),(0,E.jsxs)(`div`,{className:`flex gap-4`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`Hash`}),(0,E.jsx)(`span`,{className:`font-mono cursor-pointer hover:text-primary`,onClick:()=>q(I.hash),children:I.hash})]}),I.parents.length>0&&(0,E.jsxs)(`div`,{className:`flex gap-4`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`Parents`}),(0,E.jsx)(`span`,{className:`font-mono`,children:I.parents.map(e=>e.slice(0,7)).join(`, `)})]}),I.body&&(0,E.jsx)(`div`,{className:`mt-2 p-2 bg-background rounded text-xs whitespace-pre-wrap`,children:I.body})]}),(0,E.jsxs)(`div`,{className:`px-3 py-1 border-t`,children:[(0,E.jsx)(`div`,{className:`text-xs text-muted-foreground py-1`,children:ce?`Loading files...`:`${R.length} file${R.length===1?``:`s`} changed`}),R.map(e=>(0,E.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5 text-xs hover:bg-muted/50 rounded px-1 cursor-pointer`,onClick:()=>V({type:`git-diff`,title:`Diff ${e.path.split(`/`).pop()}`,closable:!0,metadata:{projectName:t,ref1:I.parents[0]??void 0,ref2:I.hash,filePath:e.path},projectId:t??null}),children:[(0,E.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:e.path}),e.additions>0&&(0,E.jsxs)(`span`,{className:`text-green-500`,children:[`+`,e.additions]}),e.deletions>0&&(0,E.jsxs)(`span`,{className:`text-red-500`,children:[`-`,e.deletions]})]},e.path))]})]}),(0,E.jsx)(g,{open:M.type!==null,onOpenChange:e=>{e||N({type:null})},children:(0,E.jsxs)(m,{children:[(0,E.jsx)(f,{children:(0,E.jsx)(h,{children:M.type===`branch`?`Create Branch`:`Create Tag`})}),(0,E.jsx)(ee,{placeholder:M.type===`branch`?`Branch name`:`Tag name`,value:P,onChange:e=>F(e.target.value),onKeyDown:e=>{e.key===`Enter`&&P.trim()&&(M.type===`branch`?G(P.trim(),M.hash):K(P.trim(),M.hash),N({type:null}))},autoFocus:!0}),(0,E.jsxs)(p,{children:[(0,E.jsx)(r,{variant:`outline`,onClick:()=>N({type:null}),children:`Cancel`}),(0,E.jsx)(r,{disabled:!P.trim(),onClick:()=>{M.type===`branch`?G(P.trim(),M.hash):K(P.trim(),M.hash),N({type:null})},children:`Create`})]})]})})]})}function se({label:e,color:t,currentBranch:n,onCheckout:r,onMerge:i,onPush:s,onCreatePr:c,onDelete:l}){return(0,E.jsxs)(b,{children:[(0,E.jsx)(v,{asChild:!0,children:(0,E.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium shrink-0 cursor-context-menu`,style:{backgroundColor:`${t}30`,color:t,border:`1px solid ${t}50`},children:[(0,E.jsx)(y,{className:`size-2.5`}),e.name]})}),(0,E.jsxs)(_,{children:[(0,E.jsx)(x,{onClick:()=>r(e.name),children:`Checkout`}),(0,E.jsxs)(x,{onClick:()=>i(e.name),disabled:e.name===n?.name,children:[(0,E.jsx)(C,{className:`size-3`}),`Merge into current`]}),(0,E.jsx)(S,{}),(0,E.jsxs)(x,{onClick:()=>s(e.name),children:[(0,E.jsx)(a,{className:`size-3`}),`Push`]}),(0,E.jsxs)(x,{onClick:()=>c(e.name),children:[(0,E.jsx)(o,{className:`size-3`}),`Create PR`]}),(0,E.jsx)(S,{}),(0,E.jsxs)(x,{variant:`destructive`,onClick:()=>l(e.name),disabled:e.name===n?.name,children:[(0,E.jsx)(d,{className:`size-3`}),`Delete`]})]})]})}export{A as GitGraph};
1
+ import{i as e,n as t,t as n}from"./jsx-runtime-BnxRlLMJ.js";import{t as r}from"./button-DxRZgE8F.js";import{t as i}from"./createLucideIcon-Dy1wlrF7.js";import{t as a}from"./arrow-up-from-line-BXL5dtbG.js";import{t as o}from"./external-link-WSiY-639.js";import{a as s,r as c,t as l}from"./api-client-Bnf9LAt4.js";import{t as u}from"./refresh-cw-DtopuYJf.js";import{t as d}from"./trash-2-CHLebaNh.js";import{a as f,i as p,n as m,o as h,t as g}from"./dialog-Db6prp1p.js";import{a as _,c as v,h as y,i as b,o as x,r as ee,s as S,u as te}from"./index-iwjbGjDp.js";var ne=i(`cherry`,[[`path`,{d:`M2 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z`,key:`cvxqlc`}],[`path`,{d:`M12 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z`,key:`1ostrc`}],[`path`,{d:`M7 14c3.22-2.91 4.29-8.75 5-12 1.66 2.38 4.94 9 5 12`,key:`hqx58h`}],[`path`,{d:`M22 9c-4.29 0-7.14-2.33-10-7 5.71 0 10 4.67 10 7Z`,key:`eykp1o`}]]),re=i(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),C=i(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),ie=i(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),ae=i(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),w=i(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),T=e(t(),1),E=n(),D=[`#4fc3f7`,`#81c784`,`#ffb74d`,`#e57373`,`#ba68c8`,`#4dd0e1`,`#aed581`,`#ff8a65`,`#f06292`,`#7986cb`],O=32,k=20,oe=5;function A({metadata:e}){let t=e?.projectName,[n,i]=(0,T.useState)(null),[a,o]=(0,T.useState)(!0),[d,C]=(0,T.useState)(null),[A,j]=(0,T.useState)(!1),[M,N]=(0,T.useState)({type:null}),[P,F]=(0,T.useState)(``),[I,L]=(0,T.useState)(null),[R,z]=(0,T.useState)([]),[ce,B]=(0,T.useState)(!1),{openTab:V}=te(),H=(0,T.useCallback)(async()=>{if(t)try{o(!0),i(await l.get(`${c(t)}/git/graph?max=200`)),C(null)}catch(e){C(e instanceof Error?e.message:`Failed to fetch graph`)}finally{o(!1)}},[t]);(0,T.useEffect)(()=>{H()},[H]);let U=async(e,n)=>{if(t){j(!0);try{await l.post(`${c(t)}${e}`,n),await H()}catch(e){C(e instanceof Error?e.message:`Action failed`)}finally{j(!1)}}},W=e=>U(`/git/checkout`,{ref:e}),le=e=>U(`/git/cherry-pick`,{hash:e}),ue=e=>U(`/git/revert`,{hash:e}),de=e=>U(`/git/merge`,{source:e}),fe=e=>U(`/git/branch/delete`,{name:e}),pe=e=>U(`/git/push`,{branch:e}),G=async(e,t)=>{if(n?.branches.some(t=>t.name===e||t.name.endsWith(`/${e}`))){if(!window.confirm(`Branch "${e}" already exists.\nDelete it and recreate from this commit?`))return;await U(`/git/branch/delete`,{name:e})}await U(`/git/branch/create`,{name:e,from:t})},K=(e,t)=>U(`/git/tag`,{name:e,hash:t}),me=async e=>{if(t)try{let n=await l.get(`${c(t)}/git/pr-url?branch=${encodeURIComponent(e)}`);n.url&&window.open(n.url,`_blank`)}catch{}},q=e=>{navigator.clipboard.writeText(e)},he=async e=>{if(I?.hash===e.hash){L(null);return}L(e),B(!0);try{let n=e.parents[0]??``,r=n?`ref1=${encodeURIComponent(n)}&`:``,i=await l.get(`${c(t)}/git/diff-stat?${r}ref2=${encodeURIComponent(e.hash)}`);z(Array.isArray(i)?i:[])}catch(e){console.error(`diff-stat error:`,e),z([])}finally{B(!1)}},ge=e=>{let n=e.parents[0];V({type:`git-diff`,title:`Diff ${e.abbreviatedHash}`,closable:!0,metadata:{projectName:t,ref1:n??void 0,ref2:e.hash},projectId:t??null})},{laneMap:J,maxLane:_e}=(0,T.useMemo)(()=>{let e=new Map;if(!n)return{laneMap:e,maxLane:0};let t=0,r=new Map;for(let i of n.commits){let n=r.get(i.hash);n===void 0&&(n=t++),e.set(i.hash,n),r.delete(i.hash);for(let e=0;e<i.parents.length;e++){let a=i.parents[e];r.has(a)||r.set(a,e===0?n:t++)}}return{laneMap:e,maxLane:Math.max(t-1,0)}},[n]),Y=n?.branches.find(e=>e.current),ve=(0,T.useMemo)(()=>{let e=new Map;if(!n)return e;for(let t of n.branches){let n=e.get(t.commitHash)??[];n.push({name:t.name,type:`branch`}),e.set(t.commitHash,n)}for(let t of n.commits)for(let n of t.refs)if(n.startsWith(`tag: `)){let r=n.replace(`tag: `,``),i=e.get(t.hash)??[];i.push({name:r,type:`tag`}),e.set(t.hash,i)}return e},[n]),ye=(0,T.useMemo)(()=>{if(!n)return[];let e=[];for(let t=0;t<n.commits.length;t++){let r=n.commits[t],i=J.get(r.hash)??0,a=D[i%D.length];for(let o of r.parents){let s=n.commits.findIndex(e=>e.hash===o);if(s<0)continue;let c=J.get(o)??0,l=D[c%D.length],u=i*k+k/2,d=t*O+O/2,f=c*k+k/2,p=s*O+O/2,m,h=r.parents.indexOf(o)>0;if(u===f)m=`M ${u} ${d} L ${f} ${p}`;else if(h){let e=d+O;m=`M ${u} ${d} C ${u} ${e} ${f} ${d} ${f} ${e} L ${f} ${p}`}else{let e=p-O;m=`M ${u} ${d} L ${u} ${e} C ${u} ${p} ${f} ${e} ${f} ${p}`}let g=r.parents.indexOf(o)===0?a:l;e.push({d:m,color:g})}}return e},[n,J]);(_e+1)*k+k;let X=(n?.commits.length??0)*O,[Z,be]=(0,T.useState)((typeof window<`u`&&window.innerWidth<768?6:10)*k+k),Q=(0,T.useRef)(!1),$=(0,T.useCallback)(e=>{Q.current=!0;let t=Z,n=n=>{if(!Q.current)return;let r=`touches`in n?n.touches[0].clientX:n.clientX;be(Math.max(40,t+r-e))},r=()=>{Q.current=!1,window.removeEventListener(`mousemove`,n),window.removeEventListener(`mouseup`,r),window.removeEventListener(`touchmove`,n),window.removeEventListener(`touchend`,r)};window.addEventListener(`mousemove`,n),window.addEventListener(`mouseup`,r),window.addEventListener(`touchmove`,n,{passive:!1}),window.addEventListener(`touchend`,r)},[Z]),xe=(0,T.useCallback)(e=>{e.preventDefault(),$(e.clientX)},[$]),Se=(0,T.useCallback)(e=>{$(e.touches[0].clientX)},[$]);if(!t)return(0,E.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`});if(a&&!n)return(0,E.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,E.jsx)(s,{className:`size-5 animate-spin`}),(0,E.jsx)(`span`,{className:`text-sm`,children:`Loading git graph...`})]});if(d&&!n)return(0,E.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-destructive text-sm`,children:[(0,E.jsx)(`p`,{children:d}),(0,E.jsx)(r,{variant:`outline`,size:`sm`,onClick:H,children:`Retry`})]});function Ce(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);if(a<30)return`${a}d ago`;let o=Math.floor(a/30);return o<12?`${o}mo ago`:`${Math.floor(o/12)}y ago`}return(0,E.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b`,children:[(0,E.jsxs)(`span`,{className:`text-sm font-medium`,children:[`Git Graph`,Y?` - ${Y.name}`:``]}),(0,E.jsx)(r,{variant:`ghost`,size:`icon-xs`,onClick:H,disabled:A,children:(0,E.jsx)(u,{className:a?`animate-spin`:``})})]}),d&&(0,E.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive bg-destructive/10`,children:d}),(0,E.jsx)(`div`,{className:`flex-1 overflow-y-auto overflow-x-auto md:overflow-x-hidden`,children:(0,E.jsxs)(`div`,{className:`flex min-w-max md:min-w-0`,style:{height:`${X}px`},children:[(0,E.jsxs)(`div`,{className:`sticky left-0 z-10 shrink-0 bg-background`,style:{width:`${Z}px`},children:[(0,E.jsxs)(`svg`,{width:Z,height:X,children:[ye.map((e,t)=>(0,E.jsx)(`path`,{d:e.d,stroke:e.color,strokeWidth:2,fill:`none`},t)),n?.commits.map((e,t)=>{let n=J.get(e.hash)??0,r=n*k+k/2,i=t*O+O/2,a=D[n%D.length];return(0,E.jsx)(`circle`,{cx:r,cy:i,r:oe,fill:a,stroke:`#0f1419`,strokeWidth:2},e.hash)})]}),(0,E.jsx)(`div`,{className:`absolute top-0 right-0 w-3 md:w-2 h-full cursor-col-resize hover:bg-primary/20 flex items-center justify-center bg-primary/10 md:bg-transparent`,onMouseDown:xe,onTouchStart:Se,children:(0,E.jsx)(ie,{className:`size-3 text-muted-foreground md:opacity-0 md:hover:opacity-100`})})]}),(0,E.jsx)(`div`,{className:`flex-1 min-w-[400px]`,children:n?.commits.map((e,t)=>{let n=D[(J.get(e.hash)??0)%D.length],r=ve.get(e.hash)??[],i=r.filter(e=>e.type===`branch`),a=r.filter(e=>e.type===`tag`);return(0,E.jsxs)(b,{children:[(0,E.jsx)(v,{asChild:!0,children:(0,E.jsx)(`div`,{className:`flex items-center hover:bg-muted/50 cursor-pointer text-sm border-b border-border/30 ${I?.hash===e.hash?`bg-primary/10`:``}`,style:{height:`${O}px`},onClick:()=>he(e),children:(0,E.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0 px-2`,children:[(0,E.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground w-14 shrink-0`,children:e.abbreviatedHash}),i.map(e=>(0,E.jsx)(se,{label:e,color:n,currentBranch:Y,onCheckout:W,onMerge:de,onPush:pe,onCreatePr:me,onDelete:fe},`branch-${e.name}`)),a.map(e=>(0,E.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium shrink-0 bg-amber-500/20 text-amber-500 border border-amber-500/30`,children:[(0,E.jsx)(w,{className:`size-2.5`}),e.name]},`tag-${e.name}`)),(0,E.jsx)(`span`,{className:`flex-1 truncate`,children:e.subject}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0 hidden sm:inline`,children:e.authorName}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0 w-14 text-right`,children:Ce(e.authorDate)})]})})}),(0,E.jsxs)(_,{children:[(0,E.jsx)(x,{onClick:()=>W(e.hash),children:`Checkout`}),(0,E.jsxs)(x,{onClick:()=>{N({type:`branch`,hash:e.hash}),F(``)},children:[(0,E.jsx)(y,{className:`size-3`}),`Create Branch...`]}),(0,E.jsx)(S,{}),(0,E.jsxs)(x,{onClick:()=>le(e.hash),children:[(0,E.jsx)(ne,{className:`size-3`}),`Cherry Pick`]}),(0,E.jsxs)(x,{onClick:()=>ue(e.hash),children:[(0,E.jsx)(ae,{className:`size-3`}),`Revert`]}),(0,E.jsxs)(x,{onClick:()=>{N({type:`tag`,hash:e.hash}),F(``)},children:[(0,E.jsx)(w,{className:`size-3`}),`Create Tag...`]}),(0,E.jsx)(S,{}),(0,E.jsx)(x,{onClick:()=>ge(e),children:`View Diff`}),(0,E.jsxs)(x,{onClick:()=>q(e.hash),children:[(0,E.jsx)(re,{className:`size-3`}),`Copy Hash`]})]})]},e.hash)})})]})}),I&&(0,E.jsxs)(`div`,{className:`border-t bg-muted/30 max-h-[40%] overflow-auto`,children:[(0,E.jsxs)(`div`,{className:`px-3 py-2 border-b flex items-center justify-between`,children:[(0,E.jsxs)(`span`,{className:`text-sm font-medium truncate`,children:[I.abbreviatedHash,` — `,I.subject]}),(0,E.jsx)(r,{variant:`ghost`,size:`icon-xs`,onClick:()=>L(null),children:`✕`})]}),(0,E.jsxs)(`div`,{className:`px-3 py-2 text-xs space-y-1`,children:[(0,E.jsxs)(`div`,{className:`flex gap-4`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`Author`}),(0,E.jsxs)(`span`,{children:[I.authorName,` <`,I.authorEmail,`>`]})]}),(0,E.jsxs)(`div`,{className:`flex gap-4`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`Date`}),(0,E.jsx)(`span`,{children:new Date(I.authorDate).toLocaleString()})]}),(0,E.jsxs)(`div`,{className:`flex gap-4`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`Hash`}),(0,E.jsx)(`span`,{className:`font-mono cursor-pointer hover:text-primary`,onClick:()=>q(I.hash),children:I.hash})]}),I.parents.length>0&&(0,E.jsxs)(`div`,{className:`flex gap-4`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`Parents`}),(0,E.jsx)(`span`,{className:`font-mono`,children:I.parents.map(e=>e.slice(0,7)).join(`, `)})]}),I.body&&(0,E.jsx)(`div`,{className:`mt-2 p-2 bg-background rounded text-xs whitespace-pre-wrap`,children:I.body})]}),(0,E.jsxs)(`div`,{className:`px-3 py-1 border-t`,children:[(0,E.jsx)(`div`,{className:`text-xs text-muted-foreground py-1`,children:ce?`Loading files...`:`${R.length} file${R.length===1?``:`s`} changed`}),R.map(e=>(0,E.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5 text-xs hover:bg-muted/50 rounded px-1 cursor-pointer`,onClick:()=>V({type:`git-diff`,title:`Diff ${e.path.split(`/`).pop()}`,closable:!0,metadata:{projectName:t,ref1:I.parents[0]??void 0,ref2:I.hash,filePath:e.path},projectId:t??null}),children:[(0,E.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:e.path}),e.additions>0&&(0,E.jsxs)(`span`,{className:`text-green-500`,children:[`+`,e.additions]}),e.deletions>0&&(0,E.jsxs)(`span`,{className:`text-red-500`,children:[`-`,e.deletions]})]},e.path))]})]}),(0,E.jsx)(g,{open:M.type!==null,onOpenChange:e=>{e||N({type:null})},children:(0,E.jsxs)(m,{children:[(0,E.jsx)(f,{children:(0,E.jsx)(h,{children:M.type===`branch`?`Create Branch`:`Create Tag`})}),(0,E.jsx)(ee,{placeholder:M.type===`branch`?`Branch name`:`Tag name`,value:P,onChange:e=>F(e.target.value),onKeyDown:e=>{e.key===`Enter`&&P.trim()&&(M.type===`branch`?G(P.trim(),M.hash):K(P.trim(),M.hash),N({type:null}))},autoFocus:!0}),(0,E.jsxs)(p,{children:[(0,E.jsx)(r,{variant:`outline`,onClick:()=>N({type:null}),children:`Cancel`}),(0,E.jsx)(r,{disabled:!P.trim(),onClick:()=>{M.type===`branch`?G(P.trim(),M.hash):K(P.trim(),M.hash),N({type:null})},children:`Create`})]})]})})]})}function se({label:e,color:t,currentBranch:n,onCheckout:r,onMerge:i,onPush:s,onCreatePr:c,onDelete:l}){return(0,E.jsxs)(b,{children:[(0,E.jsx)(v,{asChild:!0,children:(0,E.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium shrink-0 cursor-context-menu`,style:{backgroundColor:`${t}30`,color:t,border:`1px solid ${t}50`},children:[(0,E.jsx)(y,{className:`size-2.5`}),e.name]})}),(0,E.jsxs)(_,{children:[(0,E.jsx)(x,{onClick:()=>r(e.name),children:`Checkout`}),(0,E.jsxs)(x,{onClick:()=>i(e.name),disabled:e.name===n?.name,children:[(0,E.jsx)(C,{className:`size-3`}),`Merge into current`]}),(0,E.jsx)(S,{}),(0,E.jsxs)(x,{onClick:()=>s(e.name),children:[(0,E.jsx)(a,{className:`size-3`}),`Push`]}),(0,E.jsxs)(x,{onClick:()=>c(e.name),children:[(0,E.jsx)(o,{className:`size-3`}),`Create PR`]}),(0,E.jsx)(S,{}),(0,E.jsxs)(x,{variant:`destructive`,onClick:()=>l(e.name),disabled:e.name===n?.name,children:[(0,E.jsx)(d,{className:`size-3`}),`Delete`]})]})]})}export{A as GitGraph};
@@ -1 +1 @@
1
- import{i as e,n as t,t as n}from"./jsx-runtime-BnxRlLMJ.js";import{t as r}from"./button-BxijdhtM.js";import{t as i}from"./createLucideIcon-Dy1wlrF7.js";import{t as a}from"./arrow-up-from-line-BXL5dtbG.js";import{a as o,r as s,t as c}from"./api-client-Bnf9LAt4.js";import{t as l}from"./refresh-cw-DtopuYJf.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./dialog-RczsXsmw.js";import{C as g,d as _,p as v,u as y,w as b}from"./index-DGSLw2GE.js";var x=i(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),S=i(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),C=i(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),w=i(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),T=i(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),E=e(t(),1),D=n(),O={M:`text-yellow-500`,A:`text-green-500`,D:`text-red-500`,R:`text-blue-500`,C:`text-purple-500`,"?":`text-gray-400`};function k(e){let t=[];for(let n of e){let e=n.path.split(`/`),r=t;for(let t=0;t<e.length;t++){let i=e[t],a=e.slice(0,t+1).join(`/`),o=t===e.length-1,s=r.find(e=>e.name===i);s||(s={name:i,fullPath:a,file:o?n:void 0,children:[]},r.push(s)),o&&(s.file=n),r=s.children}}return t}function A(e){let t=[];e.file&&t.push(e.file);for(let n of e.children)t.push(...A(n));return t}function j({metadata:e,tabId:t}){let n=e?.projectName,[i,g]=(0,E.useState)(null),[b,T]=(0,E.useState)(!0),[O,k]=(0,E.useState)(null),[A,j]=(0,E.useState)(``),[M,P]=(0,E.useState)(!1),[F,I]=(0,E.useState)(null),{openTab:L,updateTab:R}=y(),z=e?.viewMode===`tree`?`tree`:`flat`,B=n=>{t&&R(t,{metadata:{...e,viewMode:n}})},V=(0,E.useCallback)(async()=>{if(n)try{T(!0),g(await c.get(`${s(n)}/git/status`)),k(null)}catch(e){k(e instanceof Error?e.message:`Failed to fetch status`)}finally{T(!1)}},[n]);(0,E.useEffect)(()=>{V()},[V]);let H=async e=>{if(n){P(!0);try{await c.post(`${s(n)}/git/stage`,{files:e}),await V()}catch(e){k(e instanceof Error?e.message:`Stage failed`)}finally{P(!1)}}},U=async e=>{if(n){P(!0);try{await c.post(`${s(n)}/git/unstage`,{files:e}),await V()}catch(e){k(e instanceof Error?e.message:`Unstage failed`)}finally{P(!1)}}},W=async e=>{if(n){P(!0);try{await c.post(`${s(n)}/git/discard`,{files:e}),await V()}catch(e){k(e instanceof Error?e.message:`Discard failed`)}finally{P(!1)}}},G=async()=>{F&&(await W(F.files),I(null))},K=async()=>{if(!(!n||!A.trim()||!i?.staged.length)){P(!0);try{await c.post(`${s(n)}/git/commit`,{message:A.trim()}),j(``),await V()}catch(e){k(e instanceof Error?e.message:`Commit failed`)}finally{P(!1)}}},q=async()=>{if(n){P(!0);try{await c.post(`${s(n)}/git/push`,{}),await V()}catch(e){k(e instanceof Error?e.message:`Push failed`)}finally{P(!1)}}},J=async()=>{if(n){P(!0);try{await c.post(`${s(n)}/git/pull`,{}),await V()}catch(e){k(e instanceof Error?e.message:`Pull failed`)}finally{P(!1)}}},Y=e=>{L({type:`git-diff`,title:e.path.split(`/`).pop()??e.path,closable:!0,metadata:{projectName:n,filePath:e.path},projectId:n??null})},X=(0,E.useMemo)(()=>[...i?.unstaged??[],...i?.untracked.map(e=>({path:e,status:`?`}))??[]],[i]);return n?b&&!i?(0,D.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,D.jsx)(o,{className:`size-5 animate-spin`}),(0,D.jsx)(`span`,{className:`text-sm`,children:`Loading git status...`})]}):O&&!i?(0,D.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-destructive text-sm`,children:[(0,D.jsx)(`p`,{children:O}),(0,D.jsx)(r,{variant:`outline`,size:`sm`,onClick:V,children:`Retry`})]}):(0,D.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b shrink-0`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium`,children:i?.current?`On: ${i.current}`:`Git Status`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,D.jsx)(r,{variant:z===`flat`?`secondary`:`ghost`,size:`icon-xs`,onClick:()=>B(`flat`),title:`Flat view`,children:(0,D.jsx)(C,{className:`size-3.5`})}),(0,D.jsx)(r,{variant:z===`tree`?`secondary`:`ghost`,size:`icon-xs`,onClick:()=>B(`tree`),title:`Tree view`,children:(0,D.jsx)(S,{className:`size-3.5`})}),(0,D.jsx)(r,{variant:`ghost`,size:`icon-xs`,onClick:V,disabled:M,children:(0,D.jsx)(l,{className:b?`animate-spin`:``})})]})]}),O&&(0,D.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0`,children:O}),(0,D.jsx)(_,{className:`flex-1 overflow-hidden`,children:(0,D.jsxs)(`div`,{className:`p-2 space-y-3 overflow-hidden`,children:[(0,D.jsx)(N,{title:`Staged Changes`,count:i?.staged.length??0,files:i?.staged??[],viewMode:z,actionIcon:(0,D.jsx)(w,{className:`size-3.5`}),actionTitle:`Unstage`,onAction:e=>U([e.path]),onActionAll:i?.staged.length?()=>U(i.staged.map(e=>e.path)):void 0,actionAllLabel:`Unstage All`,onFolderAction:e=>U(e.map(e=>e.path)),onClickFile:Y,disabled:M}),(0,D.jsx)(N,{title:`Changes`,count:X.length,files:X,viewMode:z,actionIcon:(0,D.jsx)(v,{className:`size-3.5`}),actionTitle:`Stage`,onAction:e=>H([e.path]),onActionAll:X.length?()=>H(X.map(e=>e.path)):void 0,actionAllLabel:`Stage All`,onFolderAction:e=>H(e.map(e=>e.path)),onClickFile:Y,disabled:M,showRevert:!0,onRevert:e=>I({label:e.path,files:[e.path]}),onFolderRevert:(e,t)=>I({label:`${t}/ (${e.length} files)`,files:e.map(e=>e.path)})})]})}),(0,D.jsxs)(`div`,{className:`border-t p-2 space-y-2 shrink-0`,children:[(0,D.jsx)(`textarea`,{className:`w-full h-16 px-2 py-1.5 text-sm bg-muted/50 border rounded resize-none focus:outline-none focus:ring-1 focus:ring-ring`,placeholder:`Commit message...`,value:A,onChange:e=>j(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&K()}}),(0,D.jsx)(r,{size:`sm`,className:`w-full`,disabled:M||!A.trim()||!i?.staged.length,onClick:K,children:M?(0,D.jsx)(o,{className:`size-3 animate-spin`}):`Commit (${i?.staged.length??0})`}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsxs)(r,{variant:`outline`,size:`sm`,className:`flex-1`,disabled:M,onClick:q,children:[(0,D.jsx)(a,{className:`size-3`}),`Push`]}),(0,D.jsxs)(r,{variant:`outline`,size:`sm`,className:`flex-1`,disabled:M,onClick:J,children:[(0,D.jsx)(x,{className:`size-3`}),`Pull`]})]})]}),(0,D.jsx)(h,{open:!!F,onOpenChange:e=>!e&&I(null),children:(0,D.jsxs)(f,{showCloseButton:!1,children:[(0,D.jsxs)(u,{children:[(0,D.jsx)(p,{children:`Discard Changes`}),(0,D.jsxs)(m,{children:[`Are you sure you want to discard all changes to`,` `,(0,D.jsx)(`code`,{className:`px-1 py-0.5 rounded bg-muted text-sm font-mono`,children:F?.label}),`? This action cannot be undone.`]})]}),(0,D.jsxs)(d,{children:[(0,D.jsx)(r,{variant:`outline`,onClick:()=>I(null),children:`Cancel`}),(0,D.jsx)(r,{variant:`destructive`,onClick:G,disabled:M,children:M?(0,D.jsx)(o,{className:`size-3 animate-spin`}):`Discard`})]})]})})]}):(0,D.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`})}function M({showRevert:e,onRevert:t,onAction:n,actionIcon:r,actionTitle:i,disabled:a}){return(0,D.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0 ml-1`,children:[e&&t&&(0,D.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-7 rounded border border-border/60 bg-muted/60 text-muted-foreground hover:bg-destructive/15 hover:text-destructive hover:border-destructive/40 active:scale-95 transition-colors`,onClick:e=>{e.stopPropagation(),t()},disabled:a,title:`Discard changes`,children:(0,D.jsx)(T,{className:`size-3.5`})}),(0,D.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-7 rounded border border-border/60 bg-muted/60 text-muted-foreground hover:bg-accent hover:text-accent-foreground active:scale-95 transition-colors`,onClick:e=>{e.stopPropagation(),n()},disabled:a,title:i,children:r})]})}function N({title:e,count:t,files:n,viewMode:i,actionIcon:a,actionTitle:o,onAction:s,onActionAll:c,actionAllLabel:l,onFolderAction:u,onClickFile:d,disabled:f,showRevert:p,onRevert:m,onFolderRevert:h}){return(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,D.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase`,children:[e,` (`,t,`)`]}),c&&t>0&&(0,D.jsx)(r,{variant:`ghost`,size:`xs`,onClick:c,disabled:f,title:l,children:l})]}),n.length===0?(0,D.jsx)(`p`,{className:`text-xs text-muted-foreground px-1`,children:`No changes`}):i===`flat`?(0,D.jsx)(`div`,{className:`divide-y divide-border/40 w-full overflow-hidden`,children:n.map(e=>(0,D.jsx)(P,{file:e,actionIcon:a,actionTitle:o,onAction:s,onClickFile:d,disabled:f,showRevert:p,onRevert:m},e.path))}):(0,D.jsx)(F,{files:n,actionIcon:a,actionTitle:o,onAction:s,onFolderAction:u,onClickFile:d,disabled:f,showRevert:p,onRevert:m,onFolderRevert:h})]})}function P({file:e,actionIcon:t,actionTitle:n,onAction:r,onClickFile:i,disabled:a,showRevert:o,onRevert:s,displayName:c}){return(0,D.jsxs)(`div`,{className:`flex items-center gap-1 hover:bg-muted/50 rounded px-1 py-1 w-full min-w-0`,children:[(0,D.jsx)(`span`,{className:`text-xs font-mono w-4 text-center shrink-0 ${O[e.status]??``}`,children:e.status}),(0,D.jsx)(`button`,{type:`button`,className:`flex-1 text-left text-xs font-mono truncate hover:underline min-w-0`,onClick:()=>i(e),title:e.path,children:c??e.path}),(0,D.jsx)(M,{showRevert:o,onRevert:s?()=>s(e):void 0,onAction:()=>r(e),actionIcon:t,actionTitle:n,disabled:a})]})}function F({files:e,actionIcon:t,actionTitle:n,onAction:r,onFolderAction:i,onClickFile:a,disabled:o,showRevert:s,onRevert:c,onFolderRevert:l}){let u=(0,E.useMemo)(()=>k(e),[e]);return(0,D.jsx)(`div`,{children:u.map((e,d)=>(0,D.jsx)(I,{node:e,depth:0,isLast:d===u.length-1,actionIcon:t,actionTitle:n,onAction:r,onFolderAction:i,onClickFile:a,disabled:o,showRevert:s,onRevert:c,onFolderRevert:l},e.fullPath))})}function I({node:e,depth:t,isLast:n,actionIcon:r,actionTitle:i,onAction:a,onFolderAction:o,onClickFile:s,disabled:c,showRevert:l,onRevert:u,onFolderRevert:d}){let[f,p]=(0,E.useState)(!0),m=e.children.length>0&&!e.file;if(e.file)return(0,D.jsxs)(`div`,{className:`relative overflow-hidden border-b border-border/30`,style:{paddingLeft:t*16},children:[t>0&&(0,D.jsx)(`div`,{className:`absolute top-0 bottom-0 border-l border-border/30`,style:{left:t*16-8}}),(0,D.jsx)(P,{file:e.file,displayName:e.name,actionIcon:r,actionTitle:i,onAction:a,onClickFile:s,disabled:c,showRevert:l,onRevert:u})]});if(m){let m=A(e);return(0,D.jsxs)(`div`,{className:`relative overflow-hidden`,children:[t>0&&(0,D.jsx)(`div`,{className:`absolute top-0 border-l border-border/30`,style:{left:t*16-8,bottom:n?`50%`:0}}),(0,D.jsxs)(`div`,{className:`flex items-center hover:bg-muted/50 rounded py-1 pr-1 border-b border-border/30`,style:{paddingLeft:t*16+4},children:[(0,D.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 flex-1 min-w-0 text-xs font-mono text-muted-foreground`,onClick:()=>p(!f),children:[f?(0,D.jsx)(b,{className:`size-3.5 shrink-0`}):(0,D.jsx)(g,{className:`size-3.5 shrink-0`}),(0,D.jsx)(`span`,{className:`truncate font-semibold`,children:e.name}),(0,D.jsxs)(`span`,{className:`text-[10px] opacity-60 shrink-0`,children:[`(`,m.length,`)`]})]}),(0,D.jsx)(M,{showRevert:l,onRevert:d?()=>d(m,e.fullPath):void 0,onAction:()=>o?.(m),actionIcon:r,actionTitle:`${i} ${e.name}/`,disabled:c})]}),f&&(0,D.jsxs)(`div`,{className:`relative`,children:[(0,D.jsx)(`div`,{className:`absolute top-0 bottom-0 border-l border-border/30`,style:{left:t*16+8}}),e.children.map((n,f)=>(0,D.jsx)(I,{node:n,depth:t+1,isLast:f===e.children.length-1,actionIcon:r,actionTitle:i,onAction:a,onFolderAction:o,onClickFile:s,disabled:c,showRevert:l,onRevert:u,onFolderRevert:d},n.fullPath))]})]})}return null}export{j as GitStatusPanel};
1
+ import{i as e,n as t,t as n}from"./jsx-runtime-BnxRlLMJ.js";import{t as r}from"./button-DxRZgE8F.js";import{t as i}from"./createLucideIcon-Dy1wlrF7.js";import{t as a}from"./arrow-up-from-line-BXL5dtbG.js";import{a as o,r as s,t as c}from"./api-client-Bnf9LAt4.js";import{t as l}from"./refresh-cw-DtopuYJf.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./dialog-Db6prp1p.js";import{C as g,d as _,p as v,u as y,w as b}from"./index-iwjbGjDp.js";var x=i(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),S=i(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),C=i(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),w=i(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),T=i(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),E=e(t(),1),D=n(),O={M:`text-yellow-500`,A:`text-green-500`,D:`text-red-500`,R:`text-blue-500`,C:`text-purple-500`,"?":`text-gray-400`};function k(e){let t=[];for(let n of e){let e=n.path.split(`/`),r=t;for(let t=0;t<e.length;t++){let i=e[t],a=e.slice(0,t+1).join(`/`),o=t===e.length-1,s=r.find(e=>e.name===i);s||(s={name:i,fullPath:a,file:o?n:void 0,children:[]},r.push(s)),o&&(s.file=n),r=s.children}}return t}function A(e){let t=[];e.file&&t.push(e.file);for(let n of e.children)t.push(...A(n));return t}function j({metadata:e,tabId:t}){let n=e?.projectName,[i,g]=(0,E.useState)(null),[b,T]=(0,E.useState)(!0),[O,k]=(0,E.useState)(null),[A,j]=(0,E.useState)(``),[M,P]=(0,E.useState)(!1),[F,I]=(0,E.useState)(null),{openTab:L,updateTab:R}=y(),z=e?.viewMode===`tree`?`tree`:`flat`,B=n=>{t&&R(t,{metadata:{...e,viewMode:n}})},V=(0,E.useCallback)(async()=>{if(n)try{T(!0),g(await c.get(`${s(n)}/git/status`)),k(null)}catch(e){k(e instanceof Error?e.message:`Failed to fetch status`)}finally{T(!1)}},[n]);(0,E.useEffect)(()=>{V()},[V]);let H=async e=>{if(n){P(!0);try{await c.post(`${s(n)}/git/stage`,{files:e}),await V()}catch(e){k(e instanceof Error?e.message:`Stage failed`)}finally{P(!1)}}},U=async e=>{if(n){P(!0);try{await c.post(`${s(n)}/git/unstage`,{files:e}),await V()}catch(e){k(e instanceof Error?e.message:`Unstage failed`)}finally{P(!1)}}},W=async e=>{if(n){P(!0);try{await c.post(`${s(n)}/git/discard`,{files:e}),await V()}catch(e){k(e instanceof Error?e.message:`Discard failed`)}finally{P(!1)}}},G=async()=>{F&&(await W(F.files),I(null))},K=async()=>{if(!(!n||!A.trim()||!i?.staged.length)){P(!0);try{await c.post(`${s(n)}/git/commit`,{message:A.trim()}),j(``),await V()}catch(e){k(e instanceof Error?e.message:`Commit failed`)}finally{P(!1)}}},q=async()=>{if(n){P(!0);try{await c.post(`${s(n)}/git/push`,{}),await V()}catch(e){k(e instanceof Error?e.message:`Push failed`)}finally{P(!1)}}},J=async()=>{if(n){P(!0);try{await c.post(`${s(n)}/git/pull`,{}),await V()}catch(e){k(e instanceof Error?e.message:`Pull failed`)}finally{P(!1)}}},Y=e=>{L({type:`git-diff`,title:e.path.split(`/`).pop()??e.path,closable:!0,metadata:{projectName:n,filePath:e.path},projectId:n??null})},X=(0,E.useMemo)(()=>[...i?.unstaged??[],...i?.untracked.map(e=>({path:e,status:`?`}))??[]],[i]);return n?b&&!i?(0,D.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,D.jsx)(o,{className:`size-5 animate-spin`}),(0,D.jsx)(`span`,{className:`text-sm`,children:`Loading git status...`})]}):O&&!i?(0,D.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-destructive text-sm`,children:[(0,D.jsx)(`p`,{children:O}),(0,D.jsx)(r,{variant:`outline`,size:`sm`,onClick:V,children:`Retry`})]}):(0,D.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b shrink-0`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium`,children:i?.current?`On: ${i.current}`:`Git Status`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,D.jsx)(r,{variant:z===`flat`?`secondary`:`ghost`,size:`icon-xs`,onClick:()=>B(`flat`),title:`Flat view`,children:(0,D.jsx)(C,{className:`size-3.5`})}),(0,D.jsx)(r,{variant:z===`tree`?`secondary`:`ghost`,size:`icon-xs`,onClick:()=>B(`tree`),title:`Tree view`,children:(0,D.jsx)(S,{className:`size-3.5`})}),(0,D.jsx)(r,{variant:`ghost`,size:`icon-xs`,onClick:V,disabled:M,children:(0,D.jsx)(l,{className:b?`animate-spin`:``})})]})]}),O&&(0,D.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0`,children:O}),(0,D.jsx)(_,{className:`flex-1 overflow-hidden`,children:(0,D.jsxs)(`div`,{className:`p-2 space-y-3 overflow-hidden`,children:[(0,D.jsx)(N,{title:`Staged Changes`,count:i?.staged.length??0,files:i?.staged??[],viewMode:z,actionIcon:(0,D.jsx)(w,{className:`size-3.5`}),actionTitle:`Unstage`,onAction:e=>U([e.path]),onActionAll:i?.staged.length?()=>U(i.staged.map(e=>e.path)):void 0,actionAllLabel:`Unstage All`,onFolderAction:e=>U(e.map(e=>e.path)),onClickFile:Y,disabled:M}),(0,D.jsx)(N,{title:`Changes`,count:X.length,files:X,viewMode:z,actionIcon:(0,D.jsx)(v,{className:`size-3.5`}),actionTitle:`Stage`,onAction:e=>H([e.path]),onActionAll:X.length?()=>H(X.map(e=>e.path)):void 0,actionAllLabel:`Stage All`,onFolderAction:e=>H(e.map(e=>e.path)),onClickFile:Y,disabled:M,showRevert:!0,onRevert:e=>I({label:e.path,files:[e.path]}),onFolderRevert:(e,t)=>I({label:`${t}/ (${e.length} files)`,files:e.map(e=>e.path)})})]})}),(0,D.jsxs)(`div`,{className:`border-t p-2 space-y-2 shrink-0`,children:[(0,D.jsx)(`textarea`,{className:`w-full h-16 px-2 py-1.5 text-sm bg-muted/50 border rounded resize-none focus:outline-none focus:ring-1 focus:ring-ring`,placeholder:`Commit message...`,value:A,onChange:e=>j(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&K()}}),(0,D.jsx)(r,{size:`sm`,className:`w-full`,disabled:M||!A.trim()||!i?.staged.length,onClick:K,children:M?(0,D.jsx)(o,{className:`size-3 animate-spin`}):`Commit (${i?.staged.length??0})`}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsxs)(r,{variant:`outline`,size:`sm`,className:`flex-1`,disabled:M,onClick:q,children:[(0,D.jsx)(a,{className:`size-3`}),`Push`]}),(0,D.jsxs)(r,{variant:`outline`,size:`sm`,className:`flex-1`,disabled:M,onClick:J,children:[(0,D.jsx)(x,{className:`size-3`}),`Pull`]})]})]}),(0,D.jsx)(h,{open:!!F,onOpenChange:e=>!e&&I(null),children:(0,D.jsxs)(f,{showCloseButton:!1,children:[(0,D.jsxs)(u,{children:[(0,D.jsx)(p,{children:`Discard Changes`}),(0,D.jsxs)(m,{children:[`Are you sure you want to discard all changes to`,` `,(0,D.jsx)(`code`,{className:`px-1 py-0.5 rounded bg-muted text-sm font-mono`,children:F?.label}),`? This action cannot be undone.`]})]}),(0,D.jsxs)(d,{children:[(0,D.jsx)(r,{variant:`outline`,onClick:()=>I(null),children:`Cancel`}),(0,D.jsx)(r,{variant:`destructive`,onClick:G,disabled:M,children:M?(0,D.jsx)(o,{className:`size-3 animate-spin`}):`Discard`})]})]})})]}):(0,D.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`})}function M({showRevert:e,onRevert:t,onAction:n,actionIcon:r,actionTitle:i,disabled:a}){return(0,D.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0 ml-1`,children:[e&&t&&(0,D.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-7 rounded border border-border/60 bg-muted/60 text-muted-foreground hover:bg-destructive/15 hover:text-destructive hover:border-destructive/40 active:scale-95 transition-colors`,onClick:e=>{e.stopPropagation(),t()},disabled:a,title:`Discard changes`,children:(0,D.jsx)(T,{className:`size-3.5`})}),(0,D.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-7 rounded border border-border/60 bg-muted/60 text-muted-foreground hover:bg-accent hover:text-accent-foreground active:scale-95 transition-colors`,onClick:e=>{e.stopPropagation(),n()},disabled:a,title:i,children:r})]})}function N({title:e,count:t,files:n,viewMode:i,actionIcon:a,actionTitle:o,onAction:s,onActionAll:c,actionAllLabel:l,onFolderAction:u,onClickFile:d,disabled:f,showRevert:p,onRevert:m,onFolderRevert:h}){return(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,D.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase`,children:[e,` (`,t,`)`]}),c&&t>0&&(0,D.jsx)(r,{variant:`ghost`,size:`xs`,onClick:c,disabled:f,title:l,children:l})]}),n.length===0?(0,D.jsx)(`p`,{className:`text-xs text-muted-foreground px-1`,children:`No changes`}):i===`flat`?(0,D.jsx)(`div`,{className:`divide-y divide-border/40 w-full overflow-hidden`,children:n.map(e=>(0,D.jsx)(P,{file:e,actionIcon:a,actionTitle:o,onAction:s,onClickFile:d,disabled:f,showRevert:p,onRevert:m},e.path))}):(0,D.jsx)(F,{files:n,actionIcon:a,actionTitle:o,onAction:s,onFolderAction:u,onClickFile:d,disabled:f,showRevert:p,onRevert:m,onFolderRevert:h})]})}function P({file:e,actionIcon:t,actionTitle:n,onAction:r,onClickFile:i,disabled:a,showRevert:o,onRevert:s,displayName:c}){return(0,D.jsxs)(`div`,{className:`flex items-center gap-1 hover:bg-muted/50 rounded px-1 py-1 w-full min-w-0`,children:[(0,D.jsx)(`span`,{className:`text-xs font-mono w-4 text-center shrink-0 ${O[e.status]??``}`,children:e.status}),(0,D.jsx)(`button`,{type:`button`,className:`flex-1 text-left text-xs font-mono truncate hover:underline min-w-0`,onClick:()=>i(e),title:e.path,children:c??e.path}),(0,D.jsx)(M,{showRevert:o,onRevert:s?()=>s(e):void 0,onAction:()=>r(e),actionIcon:t,actionTitle:n,disabled:a})]})}function F({files:e,actionIcon:t,actionTitle:n,onAction:r,onFolderAction:i,onClickFile:a,disabled:o,showRevert:s,onRevert:c,onFolderRevert:l}){let u=(0,E.useMemo)(()=>k(e),[e]);return(0,D.jsx)(`div`,{children:u.map((e,d)=>(0,D.jsx)(I,{node:e,depth:0,isLast:d===u.length-1,actionIcon:t,actionTitle:n,onAction:r,onFolderAction:i,onClickFile:a,disabled:o,showRevert:s,onRevert:c,onFolderRevert:l},e.fullPath))})}function I({node:e,depth:t,isLast:n,actionIcon:r,actionTitle:i,onAction:a,onFolderAction:o,onClickFile:s,disabled:c,showRevert:l,onRevert:u,onFolderRevert:d}){let[f,p]=(0,E.useState)(!0),m=e.children.length>0&&!e.file;if(e.file)return(0,D.jsxs)(`div`,{className:`relative overflow-hidden border-b border-border/30`,style:{paddingLeft:t*16},children:[t>0&&(0,D.jsx)(`div`,{className:`absolute top-0 bottom-0 border-l border-border/30`,style:{left:t*16-8}}),(0,D.jsx)(P,{file:e.file,displayName:e.name,actionIcon:r,actionTitle:i,onAction:a,onClickFile:s,disabled:c,showRevert:l,onRevert:u})]});if(m){let m=A(e);return(0,D.jsxs)(`div`,{className:`relative overflow-hidden`,children:[t>0&&(0,D.jsx)(`div`,{className:`absolute top-0 border-l border-border/30`,style:{left:t*16-8,bottom:n?`50%`:0}}),(0,D.jsxs)(`div`,{className:`flex items-center hover:bg-muted/50 rounded py-1 pr-1 border-b border-border/30`,style:{paddingLeft:t*16+4},children:[(0,D.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 flex-1 min-w-0 text-xs font-mono text-muted-foreground`,onClick:()=>p(!f),children:[f?(0,D.jsx)(b,{className:`size-3.5 shrink-0`}):(0,D.jsx)(g,{className:`size-3.5 shrink-0`}),(0,D.jsx)(`span`,{className:`truncate font-semibold`,children:e.name}),(0,D.jsxs)(`span`,{className:`text-[10px] opacity-60 shrink-0`,children:[`(`,m.length,`)`]})]}),(0,D.jsx)(M,{showRevert:l,onRevert:d?()=>d(m,e.fullPath):void 0,onAction:()=>o?.(m),actionIcon:r,actionTitle:`${i} ${e.name}/`,disabled:c})]}),f&&(0,D.jsxs)(`div`,{className:`relative`,children:[(0,D.jsx)(`div`,{className:`absolute top-0 bottom-0 border-l border-border/30`,style:{left:t*16+8}}),e.children.map((n,f)=>(0,D.jsx)(I,{node:n,depth:t+1,isLast:f===e.children.length-1,actionIcon:r,actionTitle:i,onAction:a,onFolderAction:o,onClickFile:s,disabled:c,showRevert:l,onRevert:u,onFolderRevert:d},n.fullPath))]})]})}return null}export{j as GitStatusPanel};