kanna-code 0.25.0 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -582,7 +582,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
582
582
|
*
|
|
583
583
|
* This source code is licensed under the ISC license.
|
|
584
584
|
* See the LICENSE file in the root directory of this source tree.
|
|
585
|
-
*/const TU=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Tl=Te("x",TU),ch="data-focus-fallback-ignore",t5="data-allow-focus-retain",Wm="kanna:restore-chat-input-focus",mw="data-chat-input",Gm="data-chat-selection-zone";function el(e,t){return!!(e!=null&&e.closest(`[${t}]`))}function n5(e){var n;const t=e;return t!=null&&t.matches?t.matches("input:not([type='checkbox']):not([type='radio']):not([type='button']):not([type='submit']):not([type='reset']), textarea, select")||t.isContentEditable||((n=t.getAttribute)==null?void 0:n.call(t,"role"))==="textbox"?!0:el(e,t5):!1}function AU(e){const t=e;return t!=null&&t.matches?n5(e)||(t.tabIndex??-1)>=0||t.matches("button, a[href], summary")?!0:el(e,t5):!1}function WR(e){return!!e.querySelector(`[${ch}][data-state='open']`)}function NU(e){return e?!e.isCollapsed&&e.toString().trim().length>0:!1}function MU(e,t){if(!e)return!1;const n=Array.from(t.querySelectorAll(`textarea[${mw}]`)).filter(a=>!a.disabled);if(n.length===0)return!1;const r=n.indexOf(e),i=r>=0?(r+1)%n.length:0,s=n[i];return s?(s.focus({preventScroll:!0}),!0):!1}function GR(e){const{activeElement:t,fallback:n,hasActiveOverlay:r}=e;if(!n||n.disabled||r||t===n)return"none";if(e.trigger==="escape")return e.defaultPrevented||el(t,mw)||e.canCancel?"none":"escape-focus";const{pointerStartTarget:i,pointerEndTarget:s,root:a,hasActiveSelection:l}=e,u=s??i;return!a||!u||!a.contains(u)||el(u,ch)||el(t,ch)||l&&(el(i,Gm)||el(u,Gm))||n5(t)?"none":t&&t===u?"restore":AU(t)?"none":"restore"}const qg=j$,LU=z$,r5=b.forwardRef(({className:e,...t},n)=>m.jsx(FD,{ref:n,className:Ce("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));r5.displayName=FD.displayName;const DU={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg"},zh=b.forwardRef(({className:e,children:t,size:n="md",...r},i)=>m.jsxs(LU,{children:[m.jsx(r5,{}),m.jsxs(UD,{ref:i,[ch]:"",onCloseAutoFocus:s=>{var a;s.preventDefault(),window.dispatchEvent(new Event(Wm)),(a=r.onCloseAutoFocus)==null||a.call(r,s)},className:Ce("fixed left-1/2 top-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-background shadow-xl duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]","max-h-[85vh] flex flex-col",DU[n],e),...r,children:[t,m.jsxs($$,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[m.jsx(Tl,{className:"h-4 w-4"}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));zh.displayName=UD.displayName;function OU({className:e,...t}){return m.jsx("div",{className:Ce("shrink-0 flex flex-col space-y-1.5 p-4 border-b border-border",e),...t})}function Kg({className:e,...t}){return m.jsx(B$,{className:Ce("text-lg font-medium leading-none tracking-tight",e),...t})}function gw({className:e,...t}){return m.jsx(H$,{className:Ce("text-sm text-muted-foreground",e),...t})}function Yg({className:e,...t}){return m.jsx("div",{className:Ce("flex-1 min-h-0 overflow-y-auto px-4 pb-4 pt-3.5",e),...t})}function Xg({className:e,...t}){return m.jsx("div",{className:Ce("shrink-0 flex justify-end gap-2 border-t border-border bg-background p-2 rounded-b-xl",e),...t})}function PU({className:e,...t}){return m.jsx("button",{className:Ce("touch-manipulation inline-flex items-center justify-center whitespace-nowrap cursor-pointer text-sm font-medium transition-colors","rounded-full h-9 px-4","hover:bg-accent dark:hover:bg-card hover:text-accent-foreground text-muted-foreground","disabled:pointer-events-none disabled:text-muted-foreground/50",e),...t})}const bs=b.forwardRef(({className:e,type:t,...n},r)=>m.jsx("input",{ref:r,type:t,className:Ce("flex w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...n}));bs.displayName="Input";const i5=b.createContext(null);function IU({children:e}){const[t,n]=b.useState(null),[r,i]=b.useState(""),s=b.useRef(null);b.useEffect(()=>{(t==null?void 0:t.kind)==="prompt"&&(i(t.options.initialValue??""),setTimeout(()=>{var _,y;(_=s.current)==null||_.focus(),(y=s.current)==null||y.select()},0))},[t]);const a=b.useCallback(()=>{n(null),i("")},[]),l=b.useCallback(()=>{t&&(t.kind==="confirm"?t.resolve(!1):t.kind==="prompt"?t.resolve(null):t.resolve(),a())},[a,t]),u=b.useCallback(()=>{t&&(t.kind==="confirm"?t.resolve(!0):t.kind==="prompt"?t.resolve(r.trim()||null):t.resolve(),a())},[a,t,r]),d=b.useCallback(_=>new Promise(y=>{n({kind:"confirm",options:_,resolve:y})}),[]),p=b.useCallback(_=>new Promise(y=>{n({kind:"prompt",options:_,resolve:y})}),[]),f=b.useCallback(_=>new Promise(y=>{n({kind:"alert",options:_,resolve:y})}),[]),v=b.useMemo(()=>({confirm:d,prompt:p,alert:f}),[f,d,p]);return m.jsxs(i5.Provider,{value:v,children:[e,m.jsx(qg,{open:t!==null,onOpenChange:_=>{_||!t||l()},children:m.jsx(zh,{size:"sm",onKeyDown:_=>{_.key!=="Enter"||_.shiftKey||!t||t.kind!=="confirm"||(_.preventDefault(),u())},children:t?m.jsxs(m.Fragment,{children:[m.jsxs(Yg,{className:"space-y-4",children:[m.jsx(Kg,{children:t.options.title}),t.options.description?m.jsx(gw,{children:t.options.description}):null,t.kind==="prompt"?m.jsx(bs,{ref:s,type:"text",value:r,onChange:_=>i(_.target.value),onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),u())},placeholder:t.options.placeholder}):null]}),m.jsxs(Xg,{children:[m.jsx(nt,{variant:"ghost",size:"sm",onClick:l,className:t.kind==="alert"?"hidden":void 0,children:"cancelLabel"in t.options?t.options.cancelLabel??"Cancel":"Cancel"}),m.jsx(nt,{variant:t.kind==="confirm"?t.options.confirmVariant??"default":"secondary",size:"sm",onClick:u,disabled:t.kind==="prompt"&&!r.trim(),children:t.kind==="alert"?t.options.closeLabel??"OK":"confirmLabel"in t.options?t.options.confirmLabel??"Confirm":"Confirm"})]})]}):null})})]})}function s5(){const e=b.useContext(i5);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const jU=["top","right","bottom","left"],ga=Math.min,oi=Math.max,qm=Math.round,Tp=Math.floor,ks=e=>({x:e,y:e}),zU={left:"right",right:"left",bottom:"top",top:"bottom"};function Yy(e,t,n){return oi(e,ga(t,n))}function fo(e,t){return typeof e=="function"?e(t):e}function po(e){return e.split("-")[0]}function fu(e){return e.split("-")[1]}function vw(e){return e==="x"?"y":"x"}function _w(e){return e==="y"?"height":"width"}function ys(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function bw(e){return vw(ys(e))}function BU(e,t,n){n===void 0&&(n=!1);const r=fu(e),i=bw(e),s=_w(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Km(a)),[a,Km(a)]}function HU(e){const t=Km(e);return[Xy(e),t,Xy(t)]}function Xy(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const qR=["left","right"],KR=["right","left"],$U=["top","bottom"],FU=["bottom","top"];function UU(e,t,n){switch(e){case"top":case"bottom":return n?t?KR:qR:t?qR:KR;case"left":case"right":return t?$U:FU;default:return[]}}function VU(e,t,n,r){const i=fu(e);let s=UU(po(e),n==="start",r);return i&&(s=s.map(a=>a+"-"+i),t&&(s=s.concat(s.map(Xy)))),s}function Km(e){const t=po(e);return zU[t]+e.slice(t.length)}function WU(e){return{top:0,right:0,bottom:0,left:0,...e}}function o5(e){return typeof e!="number"?WU(e):{top:e,right:e,bottom:e,left:e}}function Ym(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function YR(e,t,n){let{reference:r,floating:i}=e;const s=ys(t),a=bw(t),l=_w(a),u=po(t),d=s==="y",p=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,v=r[l]/2-i[l]/2;let _;switch(u){case"top":_={x:p,y:r.y-i.height};break;case"bottom":_={x:p,y:r.y+r.height};break;case"right":_={x:r.x+r.width,y:f};break;case"left":_={x:r.x-i.width,y:f};break;default:_={x:r.x,y:r.y}}switch(fu(t)){case"start":_[a]-=v*(n&&d?-1:1);break;case"end":_[a]+=v*(n&&d?-1:1);break}return _}async function GU(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:a,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:p="viewport",elementContext:f="floating",altBoundary:v=!1,padding:_=0}=fo(t,e),y=o5(_),k=l[v?f==="floating"?"reference":"floating":f],C=Ym(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(k)))==null||n?k:k.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:p,strategy:u})),E=f==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,R=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),T=await(s.isElement==null?void 0:s.isElement(R))?await(s.getScale==null?void 0:s.getScale(R))||{x:1,y:1}:{x:1,y:1},N=Ym(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:E,offsetParent:R,strategy:u}):E);return{top:(C.top-N.top+y.top)/T.y,bottom:(N.bottom-C.bottom+y.bottom)/T.y,left:(C.left-N.left+y.left)/T.x,right:(N.right-C.right+y.right)/T.x}}const qU=50,KU=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:GU},u=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:p,y:f}=YR(d,r,u),v=r,_=0;const y={};for(let w=0;w<s.length;w++){const k=s[w];if(!k)continue;const{name:C,fn:E}=k,{x:R,y:T,data:N,reset:M}=await E({x:p,y:f,initialPlacement:r,placement:v,strategy:i,middlewareData:y,rects:d,platform:l,elements:{reference:e,floating:t}});p=R??p,f=T??f,y[C]={...y[C],...N},M&&_<qU&&(_++,typeof M=="object"&&(M.placement&&(v=M.placement),M.rects&&(d=M.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:i}):M.rects),{x:p,y:f}=YR(d,v,u)),w=-1)}return{x:p,y:f,placement:v,strategy:i,middlewareData:y}},YU=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:a,elements:l,middlewareData:u}=t,{element:d,padding:p=0}=fo(e,t)||{};if(d==null)return{};const f=o5(p),v={x:n,y:r},_=bw(i),y=_w(_),w=await a.getDimensions(d),k=_==="y",C=k?"top":"left",E=k?"bottom":"right",R=k?"clientHeight":"clientWidth",T=s.reference[y]+s.reference[_]-v[_]-s.floating[y],N=v[_]-s.reference[_],M=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let L=M?M[R]:0;(!L||!await(a.isElement==null?void 0:a.isElement(M)))&&(L=l.floating[R]||s.floating[y]);const O=T/2-N/2,$=L/2-w[y]/2-1,I=ga(f[C],$),B=ga(f[E],$),j=I,V=L-w[y]-B,F=L/2-w[y]/2+O,W=Yy(j,F,V),P=!u.arrow&&fu(i)!=null&&F!==W&&s.reference[y]/2-(F<j?I:B)-w[y]/2<0,K=P?F<j?F-j:F-V:0;return{[_]:v[_]+K,data:{[_]:W,centerOffset:F-W-K,...P&&{alignmentOffset:K}},reset:P}}}),XU=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:a,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:p=!0,crossAxis:f=!0,fallbackPlacements:v,fallbackStrategy:_="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:w=!0,...k}=fo(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const C=po(i),E=ys(l),R=po(l)===l,T=await(u.isRTL==null?void 0:u.isRTL(d.floating)),N=v||(R||!w?[Km(l)]:HU(l)),M=y!=="none";!v&&M&&N.push(...VU(l,w,y,T));const L=[l,...N],O=await u.detectOverflow(t,k),$=[];let I=((r=s.flip)==null?void 0:r.overflows)||[];if(p&&$.push(O[C]),f){const F=BU(i,a,T);$.push(O[F[0]],O[F[1]])}if(I=[...I,{placement:i,overflows:$}],!$.every(F=>F<=0)){var B,j;const F=(((B=s.flip)==null?void 0:B.index)||0)+1,W=L[F];if(W&&(!(f==="alignment"?E!==ys(W):!1)||I.every(U=>ys(U.placement)===E?U.overflows[0]>0:!0)))return{data:{index:F,overflows:I},reset:{placement:W}};let P=(j=I.filter(K=>K.overflows[0]<=0).sort((K,U)=>K.overflows[1]-U.overflows[1])[0])==null?void 0:j.placement;if(!P)switch(_){case"bestFit":{var V;const K=(V=I.filter(U=>{if(M){const X=ys(U.placement);return X===E||X==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(X=>X>0).reduce((X,D)=>X+D,0)]).sort((U,X)=>U[1]-X[1])[0])==null?void 0:V[0];K&&(P=K);break}case"initialPlacement":P=l;break}if(i!==P)return{reset:{placement:P}}}return{}}}};function XR(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function QR(e){return jU.some(t=>e[t]>=0)}const QU=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=fo(e,t);switch(i){case"referenceHidden":{const a=await r.detectOverflow(t,{...s,elementContext:"reference"}),l=XR(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:QR(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),l=XR(a,n.floating);return{data:{escapedOffsets:l,escaped:QR(l)}}}default:return{}}}}},a5=new Set(["left","top"]);async function ZU(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=po(n),l=fu(n),u=ys(n)==="y",d=a5.has(a)?-1:1,p=s&&u?-1:1,f=fo(t,e);let{mainAxis:v,crossAxis:_,alignmentAxis:y}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof y=="number"&&(_=l==="end"?y*-1:y),u?{x:_*p,y:v*d}:{x:v*d,y:_*p}}const JU=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:a,middlewareData:l}=t,u=await ZU(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:s+u.y,data:{...u,placement:a}}}}},eV=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:u={fn:C=>{let{x:E,y:R}=C;return{x:E,y:R}}},...d}=fo(e,t),p={x:n,y:r},f=await s.detectOverflow(t,d),v=ys(po(i)),_=vw(v);let y=p[_],w=p[v];if(a){const C=_==="y"?"top":"left",E=_==="y"?"bottom":"right",R=y+f[C],T=y-f[E];y=Yy(R,y,T)}if(l){const C=v==="y"?"top":"left",E=v==="y"?"bottom":"right",R=w+f[C],T=w-f[E];w=Yy(R,w,T)}const k=u.fn({...t,[_]:y,[v]:w});return{...k,data:{x:k.x-n,y:k.y-r,enabled:{[_]:a,[v]:l}}}}}},tV=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:a}=t,{offset:l=0,mainAxis:u=!0,crossAxis:d=!0}=fo(e,t),p={x:n,y:r},f=ys(i),v=vw(f);let _=p[v],y=p[f];const w=fo(l,t),k=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(u){const R=v==="y"?"height":"width",T=s.reference[v]-s.floating[R]+k.mainAxis,N=s.reference[v]+s.reference[R]-k.mainAxis;_<T?_=T:_>N&&(_=N)}if(d){var C,E;const R=v==="y"?"width":"height",T=a5.has(po(i)),N=s.reference[f]-s.floating[R]+(T&&((C=a.offset)==null?void 0:C[f])||0)+(T?0:k.crossAxis),M=s.reference[f]+s.reference[R]+(T?0:((E=a.offset)==null?void 0:E[f])||0)-(T?k.crossAxis:0);y<N?y=N:y>M&&(y=M)}return{[v]:_,[f]:y}}}},nV=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:a,elements:l}=t,{apply:u=()=>{},...d}=fo(e,t),p=await a.detectOverflow(t,d),f=po(i),v=fu(i),_=ys(i)==="y",{width:y,height:w}=s.floating;let k,C;f==="top"||f==="bottom"?(k=f,C=v===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(C=f,k=v==="end"?"top":"bottom");const E=w-p.top-p.bottom,R=y-p.left-p.right,T=ga(w-p[k],E),N=ga(y-p[C],R),M=!t.middlewareData.shift;let L=T,O=N;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(O=R),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(L=E),M&&!v){const I=oi(p.left,0),B=oi(p.right,0),j=oi(p.top,0),V=oi(p.bottom,0);_?O=y-2*(I!==0||B!==0?I+B:oi(p.left,p.right)):L=w-2*(j!==0||V!==0?j+V:oi(p.top,p.bottom))}await u({...t,availableWidth:O,availableHeight:L});const $=await a.getDimensions(l.floating);return y!==$.width||w!==$.height?{reset:{rects:!0}}:{}}}};function Qg(){return typeof window<"u"}function pu(e){return l5(e)?(e.nodeName||"").toLowerCase():"#document"}function ai(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ns(e){var t;return(t=(l5(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function l5(e){return Qg()?e instanceof Node||e instanceof ai(e).Node:!1}function ts(e){return Qg()?e instanceof Element||e instanceof ai(e).Element:!1}function _o(e){return Qg()?e instanceof HTMLElement||e instanceof ai(e).HTMLElement:!1}function ZR(e){return!Qg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ai(e).ShadowRoot}function Bh(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=ns(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function rV(e){return/^(table|td|th)$/.test(pu(e))}function Zg(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const iV=/transform|translate|scale|rotate|perspective|filter/,sV=/paint|layout|strict|content/,Wa=e=>!!e&&e!=="none";let m0;function yw(e){const t=ts(e)?ns(e):e;return Wa(t.transform)||Wa(t.translate)||Wa(t.scale)||Wa(t.rotate)||Wa(t.perspective)||!xw()&&(Wa(t.backdropFilter)||Wa(t.filter))||iV.test(t.willChange||"")||sV.test(t.contain||"")}function oV(e){let t=va(e);for(;_o(t)&&!Zc(t);){if(yw(t))return t;if(Zg(t))return null;t=va(t)}return null}function xw(){return m0==null&&(m0=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),m0}function Zc(e){return/^(html|body|#document)$/.test(pu(e))}function ns(e){return ai(e).getComputedStyle(e)}function Jg(e){return ts(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function va(e){if(pu(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ZR(e)&&e.host||Ns(e);return ZR(t)?t.host:t}function c5(e){const t=va(e);return Zc(t)?e.ownerDocument?e.ownerDocument.body:e.body:_o(t)&&Bh(t)?t:c5(t)}function uh(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=c5(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),a=ai(i);if(s){const l=Qy(a);return t.concat(a,a.visualViewport||[],Bh(i)?i:[],l&&n?uh(l):[])}else return t.concat(i,uh(i,[],n))}function Qy(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function u5(e){const t=ns(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=_o(e),s=i?e.offsetWidth:n,a=i?e.offsetHeight:r,l=qm(n)!==s||qm(r)!==a;return l&&(n=s,r=a),{width:n,height:r,$:l}}function ww(e){return ts(e)?e:e.contextElement}function Uc(e){const t=ww(e);if(!_o(t))return ks(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=u5(t);let a=(s?qm(n.width):n.width)/r,l=(s?qm(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const aV=ks(0);function d5(e){const t=ai(e);return!xw()||!t.visualViewport?aV:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function lV(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ai(e)?!1:t}function ml(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=ww(e);let a=ks(1);t&&(r?ts(r)&&(a=Uc(r)):a=Uc(e));const l=lV(s,n,r)?d5(s):ks(0);let u=(i.left+l.x)/a.x,d=(i.top+l.y)/a.y,p=i.width/a.x,f=i.height/a.y;if(s){const v=ai(s),_=r&&ts(r)?ai(r):r;let y=v,w=Qy(y);for(;w&&r&&_!==y;){const k=Uc(w),C=w.getBoundingClientRect(),E=ns(w),R=C.left+(w.clientLeft+parseFloat(E.paddingLeft))*k.x,T=C.top+(w.clientTop+parseFloat(E.paddingTop))*k.y;u*=k.x,d*=k.y,p*=k.x,f*=k.y,u+=R,d+=T,y=ai(w),w=Qy(y)}}return Ym({width:p,height:f,x:u,y:d})}function ev(e,t){const n=Jg(e).scrollLeft;return t?t.left+n:ml(Ns(e)).left+n}function h5(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ev(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function cV(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",a=Ns(r),l=t?Zg(t.floating):!1;if(r===a||l&&s)return n;let u={scrollLeft:0,scrollTop:0},d=ks(1);const p=ks(0),f=_o(r);if((f||!f&&!s)&&((pu(r)!=="body"||Bh(a))&&(u=Jg(r)),f)){const _=ml(r);d=Uc(r),p.x=_.x+r.clientLeft,p.y=_.y+r.clientTop}const v=a&&!f&&!s?h5(a,u):ks(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+p.x+v.x,y:n.y*d.y-u.scrollTop*d.y+p.y+v.y}}function uV(e){return Array.from(e.getClientRects())}function dV(e){const t=Ns(e),n=Jg(e),r=e.ownerDocument.body,i=oi(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=oi(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+ev(e);const l=-n.scrollTop;return ns(r).direction==="rtl"&&(a+=oi(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:a,y:l}}const JR=25;function hV(e,t){const n=ai(e),r=Ns(e),i=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,l=0,u=0;if(i){s=i.width,a=i.height;const p=xw();(!p||p&&t==="fixed")&&(l=i.offsetLeft,u=i.offsetTop)}const d=ev(r);if(d<=0){const p=r.ownerDocument,f=p.body,v=getComputedStyle(f),_=p.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,y=Math.abs(r.clientWidth-f.clientWidth-_);y<=JR&&(s-=y)}else d<=JR&&(s+=d);return{width:s,height:a,x:l,y:u}}function fV(e,t){const n=ml(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=_o(e)?Uc(e):ks(1),a=e.clientWidth*s.x,l=e.clientHeight*s.y,u=i*s.x,d=r*s.y;return{width:a,height:l,x:u,y:d}}function eT(e,t,n){let r;if(t==="viewport")r=hV(e,n);else if(t==="document")r=dV(Ns(e));else if(ts(t))r=fV(t,n);else{const i=d5(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Ym(r)}function f5(e,t){const n=va(e);return n===t||!ts(n)||Zc(n)?!1:ns(n).position==="fixed"||f5(n,t)}function pV(e,t){const n=t.get(e);if(n)return n;let r=uh(e,[],!1).filter(l=>ts(l)&&pu(l)!=="body"),i=null;const s=ns(e).position==="fixed";let a=s?va(e):e;for(;ts(a)&&!Zc(a);){const l=ns(a),u=yw(a);!u&&l.position==="fixed"&&(i=null),(s?!u&&!i:!u&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Bh(a)&&!u&&f5(e,a))?r=r.filter(p=>p!==a):i=l,a=va(a)}return t.set(e,r),r}function mV(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?Zg(t)?[]:pV(t,this._c):[].concat(n),r],l=eT(t,a[0],i);let u=l.top,d=l.right,p=l.bottom,f=l.left;for(let v=1;v<a.length;v++){const _=eT(t,a[v],i);u=oi(_.top,u),d=ga(_.right,d),p=ga(_.bottom,p),f=oi(_.left,f)}return{width:d-f,height:p-u,x:f,y:u}}function gV(e){const{width:t,height:n}=u5(e);return{width:t,height:n}}function vV(e,t,n){const r=_o(t),i=Ns(t),s=n==="fixed",a=ml(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const u=ks(0);function d(){u.x=ev(i)}if(r||!r&&!s)if((pu(t)!=="body"||Bh(i))&&(l=Jg(t)),r){const _=ml(t,!0,s,t);u.x=_.x+t.clientLeft,u.y=_.y+t.clientTop}else i&&d();s&&!r&&i&&d();const p=i&&!r&&!s?h5(i,l):ks(0),f=a.left+l.scrollLeft-u.x-p.x,v=a.top+l.scrollTop-u.y-p.y;return{x:f,y:v,width:a.width,height:a.height}}function g0(e){return ns(e).position==="static"}function tT(e,t){if(!_o(e)||ns(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ns(e)===n&&(n=n.ownerDocument.body),n}function p5(e,t){const n=ai(e);if(Zg(e))return n;if(!_o(e)){let i=va(e);for(;i&&!Zc(i);){if(ts(i)&&!g0(i))return i;i=va(i)}return n}let r=tT(e,t);for(;r&&rV(r)&&g0(r);)r=tT(r,t);return r&&Zc(r)&&g0(r)&&!yw(r)?n:r||oV(e)||n}const _V=async function(e){const t=this.getOffsetParent||p5,n=this.getDimensions,r=await n(e.floating);return{reference:vV(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function bV(e){return ns(e).direction==="rtl"}const yV={convertOffsetParentRelativeRectToViewportRelativeRect:cV,getDocumentElement:Ns,getClippingRect:mV,getOffsetParent:p5,getElementRects:_V,getClientRects:uV,getDimensions:gV,getScale:Uc,isElement:ts,isRTL:bV};function m5(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function xV(e,t){let n=null,r;const i=Ns(e);function s(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),s();const d=e.getBoundingClientRect(),{left:p,top:f,width:v,height:_}=d;if(l||t(),!v||!_)return;const y=Tp(f),w=Tp(i.clientWidth-(p+v)),k=Tp(i.clientHeight-(f+_)),C=Tp(p),R={rootMargin:-y+"px "+-w+"px "+-k+"px "+-C+"px",threshold:oi(0,ga(1,u))||1};let T=!0;function N(M){const L=M[0].intersectionRatio;if(L!==u){if(!T)return a();L?a(!1,L):r=setTimeout(()=>{a(!1,1e-7)},1e3)}L===1&&!m5(d,e.getBoundingClientRect())&&a(),T=!1}try{n=new IntersectionObserver(N,{...R,root:i.ownerDocument})}catch{n=new IntersectionObserver(N,R)}n.observe(e)}return a(!0),s}function wV(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=ww(e),p=i||s?[...d?uh(d):[],...t?uh(t):[]]:[];p.forEach(C=>{i&&C.addEventListener("scroll",n,{passive:!0}),s&&C.addEventListener("resize",n)});const f=d&&l?xV(d,n):null;let v=-1,_=null;a&&(_=new ResizeObserver(C=>{let[E]=C;E&&E.target===d&&_&&t&&(_.unobserve(t),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var R;(R=_)==null||R.observe(t)})),n()}),d&&!u&&_.observe(d),t&&_.observe(t));let y,w=u?ml(e):null;u&&k();function k(){const C=ml(e);w&&!m5(w,C)&&n(),w=C,y=requestAnimationFrame(k)}return n(),()=>{var C;p.forEach(E=>{i&&E.removeEventListener("scroll",n),s&&E.removeEventListener("resize",n)}),f==null||f(),(C=_)==null||C.disconnect(),_=null,u&&cancelAnimationFrame(y)}}const SV=JU,CV=eV,kV=XU,EV=nV,RV=QU,nT=YU,TV=tV,AV=(e,t,n)=>{const r=new Map,i={platform:yV,...n},s={...i.platform,_c:r};return KU(e,t,{...i,platform:s})};var NV=typeof document<"u",MV=function(){},ym=NV?b.useLayoutEffect:MV;function Xm(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Xm(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!Xm(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function g5(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function rT(e,t){const n=g5(e);return Math.round(t*n)/n}function v0(e){const t=b.useRef(e);return ym(()=>{t.current=e}),t}function LV(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:a}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[p,f]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[v,_]=b.useState(r);Xm(v,r)||_(r);const[y,w]=b.useState(null),[k,C]=b.useState(null),E=b.useCallback(U=>{U!==M.current&&(M.current=U,w(U))},[]),R=b.useCallback(U=>{U!==L.current&&(L.current=U,C(U))},[]),T=s||y,N=a||k,M=b.useRef(null),L=b.useRef(null),O=b.useRef(p),$=u!=null,I=v0(u),B=v0(i),j=v0(d),V=b.useCallback(()=>{if(!M.current||!L.current)return;const U={placement:t,strategy:n,middleware:v};B.current&&(U.platform=B.current),AV(M.current,L.current,U).then(X=>{const D={...X,isPositioned:j.current!==!1};F.current&&!Xm(O.current,D)&&(O.current=D,Xi.flushSync(()=>{f(D)}))})},[v,t,n,B,j]);ym(()=>{d===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,f(U=>({...U,isPositioned:!1})))},[d]);const F=b.useRef(!1);ym(()=>(F.current=!0,()=>{F.current=!1}),[]),ym(()=>{if(T&&(M.current=T),N&&(L.current=N),T&&N){if(I.current)return I.current(T,N,V);V()}},[T,N,V,I,$]);const W=b.useMemo(()=>({reference:M,floating:L,setReference:E,setFloating:R}),[E,R]),P=b.useMemo(()=>({reference:T,floating:N}),[T,N]),K=b.useMemo(()=>{const U={position:n,left:0,top:0};if(!P.floating)return U;const X=rT(P.floating,p.x),D=rT(P.floating,p.y);return l?{...U,transform:"translate("+X+"px, "+D+"px)",...g5(P.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:X,top:D}},[n,l,P.floating,p.x,p.y]);return b.useMemo(()=>({...p,update:V,refs:W,elements:P,floatingStyles:K}),[p,V,W,P,K])}const DV=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?nT({element:r.current,padding:i}).fn(n):{}:r?nT({element:r,padding:i}).fn(n):{}}}},OV=(e,t)=>{const n=SV(e);return{name:n.name,fn:n.fn,options:[e,t]}},PV=(e,t)=>{const n=CV(e);return{name:n.name,fn:n.fn,options:[e,t]}},IV=(e,t)=>({fn:TV(e).fn,options:[e,t]}),jV=(e,t)=>{const n=kV(e);return{name:n.name,fn:n.fn,options:[e,t]}},zV=(e,t)=>{const n=EV(e);return{name:n.name,fn:n.fn,options:[e,t]}},BV=(e,t)=>{const n=RV(e);return{name:n.name,fn:n.fn,options:[e,t]}},HV=(e,t)=>{const n=DV(e);return{name:n.name,fn:n.fn,options:[e,t]}};var $V="Arrow",v5=b.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return m.jsx(xt.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});v5.displayName=$V;var FV=v5;function UV(e){const[t,n]=b.useState(void 0);return Sr(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let a,l;if("borderBoxSize"in s){const u=s.borderBoxSize,d=Array.isArray(u)?u[0]:u;a=d.inlineSize,l=d.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Sw="Popper",[_5,xa]=vo(Sw),[VV,b5]=_5(Sw),y5=e=>{const{__scopePopper:t,children:n}=e,[r,i]=b.useState(null);return m.jsx(VV,{scope:t,anchor:r,onAnchorChange:i,children:n})};y5.displayName=Sw;var x5="PopperAnchor",w5=b.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=b5(x5,n),a=b.useRef(null),l=zt(t,a),u=b.useRef(null);return b.useEffect(()=>{const d=u.current;u.current=(r==null?void 0:r.current)||a.current,d!==u.current&&s.onAnchorChange(u.current)}),r?null:m.jsx(xt.div,{...i,ref:l})});w5.displayName=x5;var Cw="PopperContent",[WV,GV]=_5(Cw),S5=b.forwardRef((e,t)=>{var de,be,re,ge,pe,Ee;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:p=0,sticky:f="partial",hideWhenDetached:v=!1,updatePositionStrategy:_="optimized",onPlaced:y,...w}=e,k=b5(Cw,n),[C,E]=b.useState(null),R=zt(t,Re=>E(Re)),[T,N]=b.useState(null),M=UV(T),L=(M==null?void 0:M.width)??0,O=(M==null?void 0:M.height)??0,$=r+(s!=="center"?"-"+s:""),I=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},B=Array.isArray(d)?d:[d],j=B.length>0,V={padding:I,boundary:B.filter(KV),altBoundary:j},{refs:F,floatingStyles:W,placement:P,isPositioned:K,middlewareData:U}=LV({strategy:"fixed",placement:$,whileElementsMounted:(...Re)=>wV(...Re,{animationFrame:_==="always"}),elements:{reference:k.anchor},middleware:[OV({mainAxis:i+O,alignmentAxis:a}),u&&PV({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?IV():void 0,...V}),u&&jV({...V}),zV({...V,apply:({elements:Re,rects:Fe,availableWidth:it,availableHeight:Ct})=>{const{width:Mt,height:nn}=Fe.reference,ut=Re.floating.style;ut.setProperty("--radix-popper-available-width",`${it}px`),ut.setProperty("--radix-popper-available-height",`${Ct}px`),ut.setProperty("--radix-popper-anchor-width",`${Mt}px`),ut.setProperty("--radix-popper-anchor-height",`${nn}px`)}}),T&&HV({element:T,padding:l}),YV({arrowWidth:L,arrowHeight:O}),v&&BV({strategy:"referenceHidden",...V})]}),[X,D]=E5(P),G=es(y);Sr(()=>{K&&(G==null||G())},[K,G]);const Z=(de=U.arrow)==null?void 0:de.x,z=(be=U.arrow)==null?void 0:be.y,oe=((re=U.arrow)==null?void 0:re.centerOffset)!==0,[ue,ne]=b.useState();return Sr(()=>{C&&ne(window.getComputedStyle(C).zIndex)},[C]),m.jsx("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:K?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ue,"--radix-popper-transform-origin":[(ge=U.transformOrigin)==null?void 0:ge.x,(pe=U.transformOrigin)==null?void 0:pe.y].join(" "),...((Ee=U.hide)==null?void 0:Ee.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(WV,{scope:n,placedSide:X,onArrowChange:N,arrowX:Z,arrowY:z,shouldHideArrow:oe,children:m.jsx(xt.div,{"data-side":X,"data-align":D,...w,ref:R,style:{...w.style,animation:K?void 0:"none"}})})})});S5.displayName=Cw;var C5="PopperArrow",qV={top:"bottom",right:"left",bottom:"top",left:"right"},k5=b.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=GV(C5,r),a=qV[s.placedSide];return m.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:m.jsx(FV,{...i,ref:n,style:{...i.style,display:"block"}})})});k5.displayName=C5;function KV(e){return e!==null}var YV=e=>({name:"transformOrigin",options:e,fn(t){var k,C,E;const{placement:n,rects:r,middlewareData:i}=t,a=((k=i.arrow)==null?void 0:k.centerOffset)!==0,l=a?0:e.arrowWidth,u=a?0:e.arrowHeight,[d,p]=E5(n),f={start:"0%",center:"50%",end:"100%"}[p],v=(((C=i.arrow)==null?void 0:C.x)??0)+l/2,_=(((E=i.arrow)==null?void 0:E.y)??0)+u/2;let y="",w="";return d==="bottom"?(y=a?f:`${v}px`,w=`${-u}px`):d==="top"?(y=a?f:`${v}px`,w=`${r.floating.height+u}px`):d==="right"?(y=`${-u}px`,w=a?f:`${_}px`):d==="left"&&(y=`${r.floating.width+u}px`,w=a?f:`${_}px`),{data:{x:y,y:w}}}});function E5(e){const[t,n="center"]=e.split("-");return[t,n]}var tv=y5,Hh=w5,nv=S5,rv=k5,R5=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),XV="VisuallyHidden",T5=b.forwardRef((e,t)=>m.jsx(xt.span,{...e,ref:t,style:{...R5,...e.style}}));T5.displayName=XV;var QV=T5,[iv]=vo("Tooltip",[xa]),sv=xa(),A5="TooltipProvider",ZV=700,Zy="tooltip.open",[JV,kw]=iv(A5),N5=e=>{const{__scopeTooltip:t,delayDuration:n=ZV,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,a=b.useRef(!0),l=b.useRef(!1),u=b.useRef(0);return b.useEffect(()=>{const d=u.current;return()=>window.clearTimeout(d)},[]),m.jsx(JV,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:b.useCallback(()=>{window.clearTimeout(u.current),a.current=!1},[]),onClose:b.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:b.useCallback(d=>{l.current=d},[]),disableHoverableContent:i,children:s})};N5.displayName=A5;var dh="Tooltip",[eW,$h]=iv(dh),M5=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:a,delayDuration:l}=e,u=kw(dh,e.__scopeTooltip),d=sv(t),[p,f]=b.useState(null),v=co(),_=b.useRef(0),y=a??u.disableHoverableContent,w=l??u.delayDuration,k=b.useRef(!1),[C,E]=Qc({prop:r,defaultProp:i??!1,onChange:L=>{L?(u.onOpen(),document.dispatchEvent(new CustomEvent(Zy))):u.onClose(),s==null||s(L)},caller:dh}),R=b.useMemo(()=>C?k.current?"delayed-open":"instant-open":"closed",[C]),T=b.useCallback(()=>{window.clearTimeout(_.current),_.current=0,k.current=!1,E(!0)},[E]),N=b.useCallback(()=>{window.clearTimeout(_.current),_.current=0,E(!1)},[E]),M=b.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{k.current=!0,E(!0),_.current=0},w)},[w,E]);return b.useEffect(()=>()=>{_.current&&(window.clearTimeout(_.current),_.current=0)},[]),m.jsx(tv,{...d,children:m.jsx(eW,{scope:t,contentId:v,open:C,stateAttribute:R,trigger:p,onTriggerChange:f,onTriggerEnter:b.useCallback(()=>{u.isOpenDelayedRef.current?M():T()},[u.isOpenDelayedRef,M,T]),onTriggerLeave:b.useCallback(()=>{y?N():(window.clearTimeout(_.current),_.current=0)},[N,y]),onOpen:T,onClose:N,disableHoverableContent:y,children:n})})};M5.displayName=dh;var Jy="TooltipTrigger",L5=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=$h(Jy,n),s=kw(Jy,n),a=sv(n),l=b.useRef(null),u=zt(t,l,i.onTriggerChange),d=b.useRef(!1),p=b.useRef(!1),f=b.useCallback(()=>d.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),m.jsx(Hh,{asChild:!0,...a,children:m.jsx(xt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:u,onPointerMove:Be(e.onPointerMove,v=>{v.pointerType!=="touch"&&!p.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),p.current=!0)}),onPointerLeave:Be(e.onPointerLeave,()=>{i.onTriggerLeave(),p.current=!1}),onPointerDown:Be(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Be(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:Be(e.onBlur,i.onClose),onClick:Be(e.onClick,i.onClose)})})});L5.displayName=Jy;var Ew="TooltipPortal",[tW,nW]=iv(Ew,{forceMount:void 0}),D5=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=$h(Ew,t);return m.jsx(tW,{scope:t,forceMount:n,children:m.jsx(Ii,{present:n||s.open,children:m.jsx(hu,{asChild:!0,container:i,children:r})})})};D5.displayName=Ew;var Jc="TooltipContent",O5=b.forwardRef((e,t)=>{const n=nW(Jc,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,a=$h(Jc,e.__scopeTooltip);return m.jsx(Ii,{present:r||a.open,children:a.disableHoverableContent?m.jsx(P5,{side:i,...s,ref:t}):m.jsx(rW,{side:i,...s,ref:t})})}),rW=b.forwardRef((e,t)=>{const n=$h(Jc,e.__scopeTooltip),r=kw(Jc,e.__scopeTooltip),i=b.useRef(null),s=zt(t,i),[a,l]=b.useState(null),{trigger:u,onClose:d}=n,p=i.current,{onPointerInTransitChange:f}=r,v=b.useCallback(()=>{l(null),f(!1)},[f]),_=b.useCallback((y,w)=>{const k=y.currentTarget,C={x:y.clientX,y:y.clientY},E=lW(C,k.getBoundingClientRect()),R=cW(C,E),T=uW(w.getBoundingClientRect()),N=hW([...R,...T]);l(N),f(!0)},[f]);return b.useEffect(()=>()=>v(),[v]),b.useEffect(()=>{if(u&&p){const y=k=>_(k,p),w=k=>_(k,u);return u.addEventListener("pointerleave",y),p.addEventListener("pointerleave",w),()=>{u.removeEventListener("pointerleave",y),p.removeEventListener("pointerleave",w)}}},[u,p,_,v]),b.useEffect(()=>{if(a){const y=w=>{const k=w.target,C={x:w.clientX,y:w.clientY},E=(u==null?void 0:u.contains(k))||(p==null?void 0:p.contains(k)),R=!dW(C,a);E?v():R&&(v(),d())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[u,p,a,d,v]),m.jsx(P5,{...e,ref:s})}),[iW,sW]=iv(dh,{isInside:!1}),oW=_H("TooltipContent"),P5=b.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:a,...l}=e,u=$h(Jc,n),d=sv(n),{onClose:p}=u;return b.useEffect(()=>(document.addEventListener(Zy,p),()=>document.removeEventListener(Zy,p)),[p]),b.useEffect(()=>{if(u.trigger){const f=v=>{const _=v.target;_!=null&&_.contains(u.trigger)&&p()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[u.trigger,p]),m.jsx(du,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:f=>f.preventDefault(),onDismiss:p,children:m.jsxs(nv,{"data-state":u.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[m.jsx(oW,{children:r}),m.jsx(iW,{scope:n,isInside:!0,children:m.jsx(QV,{id:u.contentId,role:"tooltip",children:i||r})})]})})});O5.displayName=Jc;var I5="TooltipArrow",aW=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=sv(n);return sW(I5,n).isInside?null:m.jsx(rv,{...i,...r,ref:t})});aW.displayName=I5;function lW(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function cW(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function uW(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function dW(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const l=t[s],u=t[a],d=l.x,p=l.y,f=u.x,v=u.y;p>r!=v>r&&n<(f-d)*(r-p)/(v-p)+d&&(i=!i)}return i}function hW(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),fW(t)}function fW(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var pW=N5,j5=M5,z5=L5,B5=D5,Rw=O5;function H5({className:e,...t}){return m.jsx("kbd",{className:Ce("pointer-events-none inline-flex h-5 min-w-5 items-center justify-center rounded border border-border/60 bg-muted/50 px-1.5 font-mono text-[11px] font-medium text-current select-none",e),...t})}function mW({className:e,...t}){return m.jsx("span",{className:Ce("inline-flex items-center gap-0.5",e),...t})}const gW="z-50 overflow-hidden rounded-md border border-border backdrop-blur-md p-0.5 text-[11px] font-medium text-card-foreground shadow-sm animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",vW=pW,gl=j5,vl=z5,_a=b.forwardRef(({className:e,sideOffset:t=4,...n},r)=>m.jsx(B5,{children:m.jsx(Rw,{ref:r,sideOffset:t,className:Ce("z-50 overflow-hidden rounded-md bg-card text-card-foreground border border-border px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));_a.displayName=Rw.displayName;const Pd=j5,Id=z5;function $5(e){return e.toUpperCase()}function _W(e){const t=e.split("+");return m.jsx(mW,{children:t.map((n,r)=>m.jsx(H5,{children:$5(n)},`${n}-${r}`))})}const Pc=b.forwardRef(({className:e,sideOffset:t=4,children:n,shortcut:r,...i},s)=>{const a=r===void 0?null:Array.isArray(r)?r[0]??null:r;return m.jsx(B5,{children:m.jsx(Rw,{ref:s,sideOffset:t,className:Ce(gW,e),...i,children:a?_W(a):m.jsx("span",{children:typeof n=="string"?$5(n):n})})})});Pc.displayName="HotkeyTooltipContent";const bW="0.25.0",yW={version:bW},Pn="Kanna",iT="kanna",xW=".kanna",wW=".kanna-dev",SW="KANNA_RUNTIME_PROFILE",Tw=`kanna/${yW.version}`,CW="[kanna]",kW=`~/${Pn}`;function ov(){var t;return(t=globalThis.process)==null?void 0:t.env}function EW(e=ov()){var t;return((t=e==null?void 0:e[SW])==null?void 0:t.trim().toLowerCase())==="dev"?"dev":"prod"}function RW(e=ov()){return EW(e)==="dev"?wW:xW}function TW(e=ov()){return`~/${RW(e)}`}function AW(e=ov()){return`${TW(e)}/keybindings.json`}function Ap(e){return e?`${iT} ${e}`:iT}const sT=e=>{let t;const n=new Set,r=(d,p)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const v=t;t=p??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(_=>_(t,v))}},i=()=>t,l={setState:r,getState:i,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d))},u=t=e(r,i,l);return l},NW=(e=>e?sT(e):sT),MW=e=>e;function LW(e,t=MW){const n=tn.useSyncExternalStore(e.subscribe,tn.useCallback(()=>t(e.getState()),[e,t]),tn.useCallback(()=>t(e.getInitialState()),[e,t]));return tn.useDebugValue(n),n}const DW=e=>{const t=NW(e),n=r=>LW(t,r);return Object.assign(n,t),n},wa=(e=>DW);function OW(e,t){let n;try{n=e()}catch{return}return{getItem:i=>{var s;const a=u=>u===null?null:JSON.parse(u,void 0),l=(s=n.getItem(i))!=null?s:null;return l instanceof Promise?l.then(a):a(l)},setItem:(i,s)=>n.setItem(i,JSON.stringify(s,void 0)),removeItem:i=>n.removeItem(i)}}const ex=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return ex(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return ex(r)(n)}}}},PW=(e,t)=>(n,r,i)=>{let s={storage:OW(()=>window.localStorage),partialize:k=>k,version:0,merge:(k,C)=>({...C,...k}),...t},a=!1,l=0;const u=new Set,d=new Set;let p=s.storage;if(!p)return e((...k)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...k)},r,i);const f=()=>{const k=s.partialize({...r()});return p.setItem(s.name,{state:k,version:s.version})},v=i.setState;i.setState=(k,C)=>(v(k,C),f());const _=e((...k)=>(n(...k),f()),r,i);i.getInitialState=()=>_;let y;const w=()=>{var k,C;if(!p)return;const E=++l;a=!1,u.forEach(T=>{var N;return T((N=r())!=null?N:_)});const R=((C=s.onRehydrateStorage)==null?void 0:C.call(s,(k=r())!=null?k:_))||void 0;return ex(p.getItem.bind(p))(s.name).then(T=>{if(T)if(typeof T.version=="number"&&T.version!==s.version){if(s.migrate){const N=s.migrate(T.state,T.version);return N instanceof Promise?N.then(M=>[!0,M]):[!0,N]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,T.state];return[!1,void 0]}).then(T=>{var N;if(E!==l)return;const[M,L]=T;if(y=s.merge(L,(N=r())!=null?N:_),n(y,!0),M)return f()}).then(()=>{E===l&&(R==null||R(y,void 0),y=r(),a=!0,d.forEach(T=>T(y)))}).catch(T=>{E===l&&(R==null||R(void 0,T))})};return i.persist={setOptions:k=>{s={...s,...k},k.storage&&(p=k.storage)},clearStorage:()=>{p==null||p.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>w(),hasHydrated:()=>a,onHydrate:k=>(u.add(k),()=>{u.delete(k)}),onFinishHydration:k=>(d.add(k),()=>{d.delete(k)})},s.skipHydration||w(),y||_},Sa=PW,F5="always",U5="funk",IW=[{value:"blow",label:"Blow"},{value:"bottle",label:"Bottle"},{value:"frog",label:"Frog"},{value:"funk",label:"Funk"},{value:"glass",label:"Glass"},{value:"ping",label:"Ping"},{value:"pop",label:"Pop"},{value:"purr",label:"Purr"},{value:"tink",label:"Tink"}];function oT(e){switch(e){case"never":case"unfocused":case"always":return e;default:return F5}}function aT(e){switch(e){case"blow":case"bottle":case"frog":case"funk":case"glass":case"ping":case"pop":case"purr":case"tink":return e;default:return U5}}const Ic=wa()(Sa(e=>({chatSoundPreference:F5,chatSoundId:U5,setChatSoundPreference:t=>e({chatSoundPreference:oT(t)}),setChatSoundId:t=>e({chatSoundId:aT(t)})}),{name:"chat-sound-preferences",version:2,migrate:e=>{const t=e;return{chatSoundPreference:oT(t==null?void 0:t.chatSoundPreference),chatSoundId:aT(t==null?void 0:t.chatSoundId)}}})),jW={blow:"/chat-sounds/Blow.mp3",bottle:"/chat-sounds/Bottle.mp3",frog:"/chat-sounds/Frog.mp3",funk:"/chat-sounds/Funk.mp3",glass:"/chat-sounds/Glass.mp3",ping:"/chat-sounds/Ping.mp3",pop:"/chat-sounds/Pop.mp3",purr:"/chat-sounds/Purr.mp3",tink:"/chat-sounds/Tink.mp3"};function zW(e=document){return e.visibilityState!=="visible"||!e.hasFocus()}function BW(e){const t=new Audio(jW[e]);return t.preload="auto",t.play()}async function tx(e,t){if(t<=0)return;const n=Array.from({length:t},(r,i)=>new Promise(s=>{window.setTimeout(()=>{BW(e).catch(()=>{}).finally(()=>s())},i*90)}));await Promise.all(n)}function HW(e,t=document){return e==="never"?!1:e==="always"?!0:zW(t)}function $W(e){return e.projectGroups.reduce((t,n)=>t+n.chats.reduce((r,i)=>r+(i.unread?1:0)+(i.status==="waiting_for_user"?1:0),0),0)}function lT(e){let t=0;const n=new Set;for(const r of e.projectGroups)for(const i of r.chats)i.unread&&(t+=1),i.status==="waiting_for_user"&&n.add(i.chatId);return{unreadCount:t,waitingChatIds:n}}function FW(e,t){if(!e)return 0;const n=lT(e),r=lT(t),i=Math.max(0,r.unreadCount-n.unreadCount);let s=0;for(const a of r.waitingChatIds)n.waitingChatIds.has(a)||(s+=1);return i+s}const mu=({children:e,className:t,shimmerWidth:n=100,animate:r=!0,...i})=>m.jsx("span",{style:{"--shiny-width":`${Math.min(n,100)}px`},className:Ce("mx-auto max-w-md text-foreground/50",r?["animate-shiny-text [background-size:var(--shiny-width)_100%] bg-clip-text [background-position:0_0] bg-no-repeat [transition:background-position_1s_cubic-bezier(.6,.6,0,1)_infinite]","bg-gradient-to-r from-transparent via-black/80 via-50% to-transparent dark:via-white/80"]:["text-neutral"],t),...i,children:e});function nx(e){return e.split(/[\s_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const UW=[/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(['"])([\s\S]*)\1$/,/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(.+)$/,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(.+)$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(.+)$/i];function VW(e){const t=e.trim();for(const n of UW){const r=t.match(n);if(!r)continue;const i=(r[2]??r[1]??"").trim();if(i)return i}return t}function V5(e){return e.split("/").pop()||e}function WW(e,t){if(e===void 0)return null;const n=Math.max(0,t-e),r=6e4,i=60*r,s=24*i,a=7*s;return n<r?"now":n<i?`${Math.floor(n/r)}m`:n<s?`${Math.floor(n/i)}h`:n<a?`${Math.floor(n/s)}d`:`${Math.floor(n/a)}w`}const GW=new Set(["starting","running"]);function qW({chat:e,activeChatId:t,nowMs:n,shortcutHint:r=null,showShortcutHint:i=!1,onSelectChat:s,onDeleteChat:a}){const l=WW(e.lastMessageAt,n),u=i&&r?r:l,d=i&&!!r,p=cH(e.chatId);return m.jsxs("div",{"data-chat-id":p,className:Ce("group flex items-center gap-2 pl-2.5 pr-0.5 py-0.5 rounded-lg cursor-pointer border-border/0 hover:border-border hover:bg-muted/20 active:scale-[0.985] border transition-all",t===p?"bg-muted hover:bg-muted border-border":"border-border/0 dark:hover:border-slate-400/10 "),onClick:()=>s(e.chatId),children:[GW.has(e.status)?m.jsx(bn,{className:"size-3.5 flex-shrink-0 animate-spin text-muted-foreground"}):e.status==="waiting_for_user"?m.jsx("div",{className:"relative ",children:m.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[m.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-blue-400/80 animate-ping"}),m.jsx("div",{className:" rounded-full z-0 size-2.5 bg-blue-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):e.unread?m.jsx("div",{className:"relative ",children:m.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[m.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-emerald-400/80 animate-ping"}),m.jsx("div",{className:" rounded-full z-0 size-2.5 bg-emerald-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):null,m.jsx("span",{className:"text-sm truncate flex-1 translate-y-[-0.5px]",children:e.status!=="idle"&&e.status!=="waiting_for_user"?m.jsx(mu,{animate:e.status==="running",shimmerWidth:Math.max(20,e.title.length*3),children:e.title}):e.title}),m.jsxs("div",{className:"relative h-7 w-7 mr-[2px] shrink-0",children:[u?d?m.jsx("span",{className:"hidden md:flex absolute inset-0 items-center justify-end pr-0.5 text-[11px] text-foreground transition-opacity group-hover:opacity-0",children:m.jsx(H5,{className:"h-4 min-w-4 rounded-sm border-border/50 bg-transparent px-1 text-[10px]",children:r})}):m.jsx("span",{className:"hidden md:flex absolute inset-0 items-center justify-end pr-1 text-[11px] text-muted-foreground opacity-50 transition-opacity group-hover:opacity-0",children:u}):null,m.jsx(nt,{variant:"ghost",size:"icon",className:Ce("absolute inset-0 h-7 w-7 opacity-100 cursor-pointer rounded-sm hover:!bg-transparent !border-0",u?"md:opacity-0 md:group-hover:opacity-100":"opacity-100 md:opacity-0 md:group-hover:opacity-100"),onClick:f=>{f.stopPropagation(),a(e.chatId)},title:"Delete chat",children:m.jsx(K$,{className:"size-3.5"})})]})]},e._id)}const KW=b.memo(qW);function YW(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return b.useMemo(()=>r=>{t.forEach(i=>i(r))},t)}const av=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function gu(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Aw(e){return"nodeType"in e}function Gr(e){var t,n;return e?gu(e)?e:Aw(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Nw(e){const{Document:t}=Gr(e);return e instanceof t}function Fh(e){return gu(e)?!1:e instanceof Gr(e).HTMLElement}function W5(e){return e instanceof Gr(e).SVGElement}function vu(e){return e?gu(e)?e.document:Aw(e)?Nw(e)?e:Fh(e)||W5(e)?e.ownerDocument:document:document:document}const Ts=av?b.useLayoutEffect:b.useEffect;function Mw(e){const t=b.useRef(e);return Ts(()=>{t.current=e}),b.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return t.current==null?void 0:t.current(...r)},[])}function XW(){const e=b.useRef(null),t=b.useCallback((r,i)=>{e.current=setInterval(r,i)},[]),n=b.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function hh(e,t){t===void 0&&(t=[e]);const n=b.useRef(e);return Ts(()=>{n.current!==e&&(n.current=e)},t),n}function Uh(e,t){const n=b.useRef();return b.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Qm(e){const t=Mw(e),n=b.useRef(null),r=b.useCallback(i=>{i!==n.current&&(t==null||t(i,n.current)),n.current=i},[]);return[n,r]}function rx(e){const t=b.useRef();return b.useEffect(()=>{t.current=e},[e]),t.current}let _0={};function Vh(e,t){return b.useMemo(()=>{if(t)return t;const n=_0[e]==null?0:_0[e]+1;return _0[e]=n,e+"-"+n},[e,t])}function G5(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((s,a)=>{const l=Object.entries(a);for(const[u,d]of l){const p=s[u];p!=null&&(s[u]=p+e*d)}return s},{...t})}}const Vc=G5(1),Zm=G5(-1);function QW(e){return"clientX"in e&&"clientY"in e}function Lw(e){if(!e)return!1;const{KeyboardEvent:t}=Gr(e.target);return t&&e instanceof t}function ZW(e){if(!e)return!1;const{TouchEvent:t}=Gr(e.target);return t&&e instanceof t}function ix(e){if(ZW(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return QW(e)?{x:e.clientX,y:e.clientY}:null}const fh=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[fh.Translate.toString(e),fh.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),cT="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function JW(e){return e.matches(cT)?e:e.querySelector(cT)}const eG={display:"none"};function tG(e){let{id:t,value:n}=e;return tn.createElement("div",{id:t,style:eG},n)}function nG(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return tn.createElement("div",{id:t,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function rG(){const[e,t]=b.useState("");return{announce:b.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const q5=b.createContext(null);function iG(e){const t=b.useContext(q5);b.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function sG(){const[e]=b.useState(()=>new Set),t=b.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[b.useCallback(r=>{let{type:i,event:s}=r;e.forEach(a=>{var l;return(l=a[i])==null?void 0:l.call(a,s)})},[e]),t]}const oG={draggable:`
|
|
585
|
+
*/const TU=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Tl=Te("x",TU),ch="data-focus-fallback-ignore",t5="data-allow-focus-retain",Wm="kanna:restore-chat-input-focus",mw="data-chat-input",Gm="data-chat-selection-zone";function el(e,t){return!!(e!=null&&e.closest(`[${t}]`))}function n5(e){var n;const t=e;return t!=null&&t.matches?t.matches("input:not([type='checkbox']):not([type='radio']):not([type='button']):not([type='submit']):not([type='reset']), textarea, select")||t.isContentEditable||((n=t.getAttribute)==null?void 0:n.call(t,"role"))==="textbox"?!0:el(e,t5):!1}function AU(e){const t=e;return t!=null&&t.matches?n5(e)||(t.tabIndex??-1)>=0||t.matches("button, a[href], summary")?!0:el(e,t5):!1}function WR(e){return!!e.querySelector(`[${ch}][data-state='open']`)}function NU(e){return e?!e.isCollapsed&&e.toString().trim().length>0:!1}function MU(e,t){if(!e)return!1;const n=Array.from(t.querySelectorAll(`textarea[${mw}]`)).filter(a=>!a.disabled);if(n.length===0)return!1;const r=n.indexOf(e),i=r>=0?(r+1)%n.length:0,s=n[i];return s?(s.focus({preventScroll:!0}),!0):!1}function GR(e){const{activeElement:t,fallback:n,hasActiveOverlay:r}=e;if(!n||n.disabled||r||t===n)return"none";if(e.trigger==="escape")return e.defaultPrevented||el(t,mw)||e.canCancel?"none":"escape-focus";const{pointerStartTarget:i,pointerEndTarget:s,root:a,hasActiveSelection:l}=e,u=s??i;return!a||!u||!a.contains(u)||el(u,ch)||el(t,ch)||l&&(el(i,Gm)||el(u,Gm))||n5(t)?"none":t&&t===u?"restore":AU(t)?"none":"restore"}const qg=j$,LU=z$,r5=b.forwardRef(({className:e,...t},n)=>m.jsx(FD,{ref:n,className:Ce("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));r5.displayName=FD.displayName;const DU={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg"},zh=b.forwardRef(({className:e,children:t,size:n="md",...r},i)=>m.jsxs(LU,{children:[m.jsx(r5,{}),m.jsxs(UD,{ref:i,[ch]:"",onCloseAutoFocus:s=>{var a;s.preventDefault(),window.dispatchEvent(new Event(Wm)),(a=r.onCloseAutoFocus)==null||a.call(r,s)},className:Ce("fixed left-1/2 top-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-background shadow-xl duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]","max-h-[85vh] flex flex-col",DU[n],e),...r,children:[t,m.jsxs($$,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[m.jsx(Tl,{className:"h-4 w-4"}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));zh.displayName=UD.displayName;function OU({className:e,...t}){return m.jsx("div",{className:Ce("shrink-0 flex flex-col space-y-1.5 p-4 border-b border-border",e),...t})}function Kg({className:e,...t}){return m.jsx(B$,{className:Ce("text-lg font-medium leading-none tracking-tight",e),...t})}function gw({className:e,...t}){return m.jsx(H$,{className:Ce("text-sm text-muted-foreground",e),...t})}function Yg({className:e,...t}){return m.jsx("div",{className:Ce("flex-1 min-h-0 overflow-y-auto px-4 pb-4 pt-3.5",e),...t})}function Xg({className:e,...t}){return m.jsx("div",{className:Ce("shrink-0 flex justify-end gap-2 border-t border-border bg-background p-2 rounded-b-xl",e),...t})}function PU({className:e,...t}){return m.jsx("button",{className:Ce("touch-manipulation inline-flex items-center justify-center whitespace-nowrap cursor-pointer text-sm font-medium transition-colors","rounded-full h-9 px-4","hover:bg-accent dark:hover:bg-card hover:text-accent-foreground text-muted-foreground","disabled:pointer-events-none disabled:text-muted-foreground/50",e),...t})}const bs=b.forwardRef(({className:e,type:t,...n},r)=>m.jsx("input",{ref:r,type:t,className:Ce("flex w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...n}));bs.displayName="Input";const i5=b.createContext(null);function IU({children:e}){const[t,n]=b.useState(null),[r,i]=b.useState(""),s=b.useRef(null);b.useEffect(()=>{(t==null?void 0:t.kind)==="prompt"&&(i(t.options.initialValue??""),setTimeout(()=>{var _,y;(_=s.current)==null||_.focus(),(y=s.current)==null||y.select()},0))},[t]);const a=b.useCallback(()=>{n(null),i("")},[]),l=b.useCallback(()=>{t&&(t.kind==="confirm"?t.resolve(!1):t.kind==="prompt"?t.resolve(null):t.resolve(),a())},[a,t]),u=b.useCallback(()=>{t&&(t.kind==="confirm"?t.resolve(!0):t.kind==="prompt"?t.resolve(r.trim()||null):t.resolve(),a())},[a,t,r]),d=b.useCallback(_=>new Promise(y=>{n({kind:"confirm",options:_,resolve:y})}),[]),p=b.useCallback(_=>new Promise(y=>{n({kind:"prompt",options:_,resolve:y})}),[]),f=b.useCallback(_=>new Promise(y=>{n({kind:"alert",options:_,resolve:y})}),[]),v=b.useMemo(()=>({confirm:d,prompt:p,alert:f}),[f,d,p]);return m.jsxs(i5.Provider,{value:v,children:[e,m.jsx(qg,{open:t!==null,onOpenChange:_=>{_||!t||l()},children:m.jsx(zh,{size:"sm",onKeyDown:_=>{_.key!=="Enter"||_.shiftKey||!t||t.kind!=="confirm"||(_.preventDefault(),u())},children:t?m.jsxs(m.Fragment,{children:[m.jsxs(Yg,{className:"space-y-4",children:[m.jsx(Kg,{children:t.options.title}),t.options.description?m.jsx(gw,{children:t.options.description}):null,t.kind==="prompt"?m.jsx(bs,{ref:s,type:"text",value:r,onChange:_=>i(_.target.value),onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),u())},placeholder:t.options.placeholder}):null]}),m.jsxs(Xg,{children:[m.jsx(nt,{variant:"ghost",size:"sm",onClick:l,className:t.kind==="alert"?"hidden":void 0,children:"cancelLabel"in t.options?t.options.cancelLabel??"Cancel":"Cancel"}),m.jsx(nt,{variant:t.kind==="confirm"?t.options.confirmVariant??"default":"secondary",size:"sm",onClick:u,disabled:t.kind==="prompt"&&!r.trim(),children:t.kind==="alert"?t.options.closeLabel??"OK":"confirmLabel"in t.options?t.options.confirmLabel??"Confirm":"Confirm"})]})]}):null})})]})}function s5(){const e=b.useContext(i5);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const jU=["top","right","bottom","left"],ga=Math.min,oi=Math.max,qm=Math.round,Tp=Math.floor,ks=e=>({x:e,y:e}),zU={left:"right",right:"left",bottom:"top",top:"bottom"};function Yy(e,t,n){return oi(e,ga(t,n))}function fo(e,t){return typeof e=="function"?e(t):e}function po(e){return e.split("-")[0]}function fu(e){return e.split("-")[1]}function vw(e){return e==="x"?"y":"x"}function _w(e){return e==="y"?"height":"width"}function ys(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function bw(e){return vw(ys(e))}function BU(e,t,n){n===void 0&&(n=!1);const r=fu(e),i=bw(e),s=_w(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Km(a)),[a,Km(a)]}function HU(e){const t=Km(e);return[Xy(e),t,Xy(t)]}function Xy(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const qR=["left","right"],KR=["right","left"],$U=["top","bottom"],FU=["bottom","top"];function UU(e,t,n){switch(e){case"top":case"bottom":return n?t?KR:qR:t?qR:KR;case"left":case"right":return t?$U:FU;default:return[]}}function VU(e,t,n,r){const i=fu(e);let s=UU(po(e),n==="start",r);return i&&(s=s.map(a=>a+"-"+i),t&&(s=s.concat(s.map(Xy)))),s}function Km(e){const t=po(e);return zU[t]+e.slice(t.length)}function WU(e){return{top:0,right:0,bottom:0,left:0,...e}}function o5(e){return typeof e!="number"?WU(e):{top:e,right:e,bottom:e,left:e}}function Ym(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function YR(e,t,n){let{reference:r,floating:i}=e;const s=ys(t),a=bw(t),l=_w(a),u=po(t),d=s==="y",p=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,v=r[l]/2-i[l]/2;let _;switch(u){case"top":_={x:p,y:r.y-i.height};break;case"bottom":_={x:p,y:r.y+r.height};break;case"right":_={x:r.x+r.width,y:f};break;case"left":_={x:r.x-i.width,y:f};break;default:_={x:r.x,y:r.y}}switch(fu(t)){case"start":_[a]-=v*(n&&d?-1:1);break;case"end":_[a]+=v*(n&&d?-1:1);break}return _}async function GU(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:a,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:p="viewport",elementContext:f="floating",altBoundary:v=!1,padding:_=0}=fo(t,e),y=o5(_),k=l[v?f==="floating"?"reference":"floating":f],C=Ym(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(k)))==null||n?k:k.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:p,strategy:u})),E=f==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,R=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),T=await(s.isElement==null?void 0:s.isElement(R))?await(s.getScale==null?void 0:s.getScale(R))||{x:1,y:1}:{x:1,y:1},N=Ym(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:E,offsetParent:R,strategy:u}):E);return{top:(C.top-N.top+y.top)/T.y,bottom:(N.bottom-C.bottom+y.bottom)/T.y,left:(C.left-N.left+y.left)/T.x,right:(N.right-C.right+y.right)/T.x}}const qU=50,KU=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:GU},u=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:p,y:f}=YR(d,r,u),v=r,_=0;const y={};for(let w=0;w<s.length;w++){const k=s[w];if(!k)continue;const{name:C,fn:E}=k,{x:R,y:T,data:N,reset:M}=await E({x:p,y:f,initialPlacement:r,placement:v,strategy:i,middlewareData:y,rects:d,platform:l,elements:{reference:e,floating:t}});p=R??p,f=T??f,y[C]={...y[C],...N},M&&_<qU&&(_++,typeof M=="object"&&(M.placement&&(v=M.placement),M.rects&&(d=M.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:i}):M.rects),{x:p,y:f}=YR(d,v,u)),w=-1)}return{x:p,y:f,placement:v,strategy:i,middlewareData:y}},YU=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:a,elements:l,middlewareData:u}=t,{element:d,padding:p=0}=fo(e,t)||{};if(d==null)return{};const f=o5(p),v={x:n,y:r},_=bw(i),y=_w(_),w=await a.getDimensions(d),k=_==="y",C=k?"top":"left",E=k?"bottom":"right",R=k?"clientHeight":"clientWidth",T=s.reference[y]+s.reference[_]-v[_]-s.floating[y],N=v[_]-s.reference[_],M=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let L=M?M[R]:0;(!L||!await(a.isElement==null?void 0:a.isElement(M)))&&(L=l.floating[R]||s.floating[y]);const O=T/2-N/2,$=L/2-w[y]/2-1,I=ga(f[C],$),B=ga(f[E],$),j=I,V=L-w[y]-B,F=L/2-w[y]/2+O,W=Yy(j,F,V),P=!u.arrow&&fu(i)!=null&&F!==W&&s.reference[y]/2-(F<j?I:B)-w[y]/2<0,K=P?F<j?F-j:F-V:0;return{[_]:v[_]+K,data:{[_]:W,centerOffset:F-W-K,...P&&{alignmentOffset:K}},reset:P}}}),XU=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:a,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:p=!0,crossAxis:f=!0,fallbackPlacements:v,fallbackStrategy:_="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:w=!0,...k}=fo(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const C=po(i),E=ys(l),R=po(l)===l,T=await(u.isRTL==null?void 0:u.isRTL(d.floating)),N=v||(R||!w?[Km(l)]:HU(l)),M=y!=="none";!v&&M&&N.push(...VU(l,w,y,T));const L=[l,...N],O=await u.detectOverflow(t,k),$=[];let I=((r=s.flip)==null?void 0:r.overflows)||[];if(p&&$.push(O[C]),f){const F=BU(i,a,T);$.push(O[F[0]],O[F[1]])}if(I=[...I,{placement:i,overflows:$}],!$.every(F=>F<=0)){var B,j;const F=(((B=s.flip)==null?void 0:B.index)||0)+1,W=L[F];if(W&&(!(f==="alignment"?E!==ys(W):!1)||I.every(U=>ys(U.placement)===E?U.overflows[0]>0:!0)))return{data:{index:F,overflows:I},reset:{placement:W}};let P=(j=I.filter(K=>K.overflows[0]<=0).sort((K,U)=>K.overflows[1]-U.overflows[1])[0])==null?void 0:j.placement;if(!P)switch(_){case"bestFit":{var V;const K=(V=I.filter(U=>{if(M){const X=ys(U.placement);return X===E||X==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(X=>X>0).reduce((X,D)=>X+D,0)]).sort((U,X)=>U[1]-X[1])[0])==null?void 0:V[0];K&&(P=K);break}case"initialPlacement":P=l;break}if(i!==P)return{reset:{placement:P}}}return{}}}};function XR(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function QR(e){return jU.some(t=>e[t]>=0)}const QU=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=fo(e,t);switch(i){case"referenceHidden":{const a=await r.detectOverflow(t,{...s,elementContext:"reference"}),l=XR(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:QR(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),l=XR(a,n.floating);return{data:{escapedOffsets:l,escaped:QR(l)}}}default:return{}}}}},a5=new Set(["left","top"]);async function ZU(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=po(n),l=fu(n),u=ys(n)==="y",d=a5.has(a)?-1:1,p=s&&u?-1:1,f=fo(t,e);let{mainAxis:v,crossAxis:_,alignmentAxis:y}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof y=="number"&&(_=l==="end"?y*-1:y),u?{x:_*p,y:v*d}:{x:v*d,y:_*p}}const JU=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:a,middlewareData:l}=t,u=await ZU(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:s+u.y,data:{...u,placement:a}}}}},eV=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:u={fn:C=>{let{x:E,y:R}=C;return{x:E,y:R}}},...d}=fo(e,t),p={x:n,y:r},f=await s.detectOverflow(t,d),v=ys(po(i)),_=vw(v);let y=p[_],w=p[v];if(a){const C=_==="y"?"top":"left",E=_==="y"?"bottom":"right",R=y+f[C],T=y-f[E];y=Yy(R,y,T)}if(l){const C=v==="y"?"top":"left",E=v==="y"?"bottom":"right",R=w+f[C],T=w-f[E];w=Yy(R,w,T)}const k=u.fn({...t,[_]:y,[v]:w});return{...k,data:{x:k.x-n,y:k.y-r,enabled:{[_]:a,[v]:l}}}}}},tV=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:a}=t,{offset:l=0,mainAxis:u=!0,crossAxis:d=!0}=fo(e,t),p={x:n,y:r},f=ys(i),v=vw(f);let _=p[v],y=p[f];const w=fo(l,t),k=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(u){const R=v==="y"?"height":"width",T=s.reference[v]-s.floating[R]+k.mainAxis,N=s.reference[v]+s.reference[R]-k.mainAxis;_<T?_=T:_>N&&(_=N)}if(d){var C,E;const R=v==="y"?"width":"height",T=a5.has(po(i)),N=s.reference[f]-s.floating[R]+(T&&((C=a.offset)==null?void 0:C[f])||0)+(T?0:k.crossAxis),M=s.reference[f]+s.reference[R]+(T?0:((E=a.offset)==null?void 0:E[f])||0)-(T?k.crossAxis:0);y<N?y=N:y>M&&(y=M)}return{[v]:_,[f]:y}}}},nV=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:a,elements:l}=t,{apply:u=()=>{},...d}=fo(e,t),p=await a.detectOverflow(t,d),f=po(i),v=fu(i),_=ys(i)==="y",{width:y,height:w}=s.floating;let k,C;f==="top"||f==="bottom"?(k=f,C=v===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(C=f,k=v==="end"?"top":"bottom");const E=w-p.top-p.bottom,R=y-p.left-p.right,T=ga(w-p[k],E),N=ga(y-p[C],R),M=!t.middlewareData.shift;let L=T,O=N;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(O=R),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(L=E),M&&!v){const I=oi(p.left,0),B=oi(p.right,0),j=oi(p.top,0),V=oi(p.bottom,0);_?O=y-2*(I!==0||B!==0?I+B:oi(p.left,p.right)):L=w-2*(j!==0||V!==0?j+V:oi(p.top,p.bottom))}await u({...t,availableWidth:O,availableHeight:L});const $=await a.getDimensions(l.floating);return y!==$.width||w!==$.height?{reset:{rects:!0}}:{}}}};function Qg(){return typeof window<"u"}function pu(e){return l5(e)?(e.nodeName||"").toLowerCase():"#document"}function ai(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ns(e){var t;return(t=(l5(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function l5(e){return Qg()?e instanceof Node||e instanceof ai(e).Node:!1}function ts(e){return Qg()?e instanceof Element||e instanceof ai(e).Element:!1}function _o(e){return Qg()?e instanceof HTMLElement||e instanceof ai(e).HTMLElement:!1}function ZR(e){return!Qg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ai(e).ShadowRoot}function Bh(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=ns(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function rV(e){return/^(table|td|th)$/.test(pu(e))}function Zg(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const iV=/transform|translate|scale|rotate|perspective|filter/,sV=/paint|layout|strict|content/,Wa=e=>!!e&&e!=="none";let m0;function yw(e){const t=ts(e)?ns(e):e;return Wa(t.transform)||Wa(t.translate)||Wa(t.scale)||Wa(t.rotate)||Wa(t.perspective)||!xw()&&(Wa(t.backdropFilter)||Wa(t.filter))||iV.test(t.willChange||"")||sV.test(t.contain||"")}function oV(e){let t=va(e);for(;_o(t)&&!Zc(t);){if(yw(t))return t;if(Zg(t))return null;t=va(t)}return null}function xw(){return m0==null&&(m0=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),m0}function Zc(e){return/^(html|body|#document)$/.test(pu(e))}function ns(e){return ai(e).getComputedStyle(e)}function Jg(e){return ts(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function va(e){if(pu(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ZR(e)&&e.host||Ns(e);return ZR(t)?t.host:t}function c5(e){const t=va(e);return Zc(t)?e.ownerDocument?e.ownerDocument.body:e.body:_o(t)&&Bh(t)?t:c5(t)}function uh(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=c5(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),a=ai(i);if(s){const l=Qy(a);return t.concat(a,a.visualViewport||[],Bh(i)?i:[],l&&n?uh(l):[])}else return t.concat(i,uh(i,[],n))}function Qy(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function u5(e){const t=ns(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=_o(e),s=i?e.offsetWidth:n,a=i?e.offsetHeight:r,l=qm(n)!==s||qm(r)!==a;return l&&(n=s,r=a),{width:n,height:r,$:l}}function ww(e){return ts(e)?e:e.contextElement}function Uc(e){const t=ww(e);if(!_o(t))return ks(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=u5(t);let a=(s?qm(n.width):n.width)/r,l=(s?qm(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const aV=ks(0);function d5(e){const t=ai(e);return!xw()||!t.visualViewport?aV:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function lV(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ai(e)?!1:t}function ml(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=ww(e);let a=ks(1);t&&(r?ts(r)&&(a=Uc(r)):a=Uc(e));const l=lV(s,n,r)?d5(s):ks(0);let u=(i.left+l.x)/a.x,d=(i.top+l.y)/a.y,p=i.width/a.x,f=i.height/a.y;if(s){const v=ai(s),_=r&&ts(r)?ai(r):r;let y=v,w=Qy(y);for(;w&&r&&_!==y;){const k=Uc(w),C=w.getBoundingClientRect(),E=ns(w),R=C.left+(w.clientLeft+parseFloat(E.paddingLeft))*k.x,T=C.top+(w.clientTop+parseFloat(E.paddingTop))*k.y;u*=k.x,d*=k.y,p*=k.x,f*=k.y,u+=R,d+=T,y=ai(w),w=Qy(y)}}return Ym({width:p,height:f,x:u,y:d})}function ev(e,t){const n=Jg(e).scrollLeft;return t?t.left+n:ml(Ns(e)).left+n}function h5(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ev(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function cV(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",a=Ns(r),l=t?Zg(t.floating):!1;if(r===a||l&&s)return n;let u={scrollLeft:0,scrollTop:0},d=ks(1);const p=ks(0),f=_o(r);if((f||!f&&!s)&&((pu(r)!=="body"||Bh(a))&&(u=Jg(r)),f)){const _=ml(r);d=Uc(r),p.x=_.x+r.clientLeft,p.y=_.y+r.clientTop}const v=a&&!f&&!s?h5(a,u):ks(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+p.x+v.x,y:n.y*d.y-u.scrollTop*d.y+p.y+v.y}}function uV(e){return Array.from(e.getClientRects())}function dV(e){const t=Ns(e),n=Jg(e),r=e.ownerDocument.body,i=oi(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=oi(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+ev(e);const l=-n.scrollTop;return ns(r).direction==="rtl"&&(a+=oi(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:a,y:l}}const JR=25;function hV(e,t){const n=ai(e),r=Ns(e),i=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,l=0,u=0;if(i){s=i.width,a=i.height;const p=xw();(!p||p&&t==="fixed")&&(l=i.offsetLeft,u=i.offsetTop)}const d=ev(r);if(d<=0){const p=r.ownerDocument,f=p.body,v=getComputedStyle(f),_=p.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,y=Math.abs(r.clientWidth-f.clientWidth-_);y<=JR&&(s-=y)}else d<=JR&&(s+=d);return{width:s,height:a,x:l,y:u}}function fV(e,t){const n=ml(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=_o(e)?Uc(e):ks(1),a=e.clientWidth*s.x,l=e.clientHeight*s.y,u=i*s.x,d=r*s.y;return{width:a,height:l,x:u,y:d}}function eT(e,t,n){let r;if(t==="viewport")r=hV(e,n);else if(t==="document")r=dV(Ns(e));else if(ts(t))r=fV(t,n);else{const i=d5(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Ym(r)}function f5(e,t){const n=va(e);return n===t||!ts(n)||Zc(n)?!1:ns(n).position==="fixed"||f5(n,t)}function pV(e,t){const n=t.get(e);if(n)return n;let r=uh(e,[],!1).filter(l=>ts(l)&&pu(l)!=="body"),i=null;const s=ns(e).position==="fixed";let a=s?va(e):e;for(;ts(a)&&!Zc(a);){const l=ns(a),u=yw(a);!u&&l.position==="fixed"&&(i=null),(s?!u&&!i:!u&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Bh(a)&&!u&&f5(e,a))?r=r.filter(p=>p!==a):i=l,a=va(a)}return t.set(e,r),r}function mV(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?Zg(t)?[]:pV(t,this._c):[].concat(n),r],l=eT(t,a[0],i);let u=l.top,d=l.right,p=l.bottom,f=l.left;for(let v=1;v<a.length;v++){const _=eT(t,a[v],i);u=oi(_.top,u),d=ga(_.right,d),p=ga(_.bottom,p),f=oi(_.left,f)}return{width:d-f,height:p-u,x:f,y:u}}function gV(e){const{width:t,height:n}=u5(e);return{width:t,height:n}}function vV(e,t,n){const r=_o(t),i=Ns(t),s=n==="fixed",a=ml(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const u=ks(0);function d(){u.x=ev(i)}if(r||!r&&!s)if((pu(t)!=="body"||Bh(i))&&(l=Jg(t)),r){const _=ml(t,!0,s,t);u.x=_.x+t.clientLeft,u.y=_.y+t.clientTop}else i&&d();s&&!r&&i&&d();const p=i&&!r&&!s?h5(i,l):ks(0),f=a.left+l.scrollLeft-u.x-p.x,v=a.top+l.scrollTop-u.y-p.y;return{x:f,y:v,width:a.width,height:a.height}}function g0(e){return ns(e).position==="static"}function tT(e,t){if(!_o(e)||ns(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ns(e)===n&&(n=n.ownerDocument.body),n}function p5(e,t){const n=ai(e);if(Zg(e))return n;if(!_o(e)){let i=va(e);for(;i&&!Zc(i);){if(ts(i)&&!g0(i))return i;i=va(i)}return n}let r=tT(e,t);for(;r&&rV(r)&&g0(r);)r=tT(r,t);return r&&Zc(r)&&g0(r)&&!yw(r)?n:r||oV(e)||n}const _V=async function(e){const t=this.getOffsetParent||p5,n=this.getDimensions,r=await n(e.floating);return{reference:vV(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function bV(e){return ns(e).direction==="rtl"}const yV={convertOffsetParentRelativeRectToViewportRelativeRect:cV,getDocumentElement:Ns,getClippingRect:mV,getOffsetParent:p5,getElementRects:_V,getClientRects:uV,getDimensions:gV,getScale:Uc,isElement:ts,isRTL:bV};function m5(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function xV(e,t){let n=null,r;const i=Ns(e);function s(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),s();const d=e.getBoundingClientRect(),{left:p,top:f,width:v,height:_}=d;if(l||t(),!v||!_)return;const y=Tp(f),w=Tp(i.clientWidth-(p+v)),k=Tp(i.clientHeight-(f+_)),C=Tp(p),R={rootMargin:-y+"px "+-w+"px "+-k+"px "+-C+"px",threshold:oi(0,ga(1,u))||1};let T=!0;function N(M){const L=M[0].intersectionRatio;if(L!==u){if(!T)return a();L?a(!1,L):r=setTimeout(()=>{a(!1,1e-7)},1e3)}L===1&&!m5(d,e.getBoundingClientRect())&&a(),T=!1}try{n=new IntersectionObserver(N,{...R,root:i.ownerDocument})}catch{n=new IntersectionObserver(N,R)}n.observe(e)}return a(!0),s}function wV(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=ww(e),p=i||s?[...d?uh(d):[],...t?uh(t):[]]:[];p.forEach(C=>{i&&C.addEventListener("scroll",n,{passive:!0}),s&&C.addEventListener("resize",n)});const f=d&&l?xV(d,n):null;let v=-1,_=null;a&&(_=new ResizeObserver(C=>{let[E]=C;E&&E.target===d&&_&&t&&(_.unobserve(t),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var R;(R=_)==null||R.observe(t)})),n()}),d&&!u&&_.observe(d),t&&_.observe(t));let y,w=u?ml(e):null;u&&k();function k(){const C=ml(e);w&&!m5(w,C)&&n(),w=C,y=requestAnimationFrame(k)}return n(),()=>{var C;p.forEach(E=>{i&&E.removeEventListener("scroll",n),s&&E.removeEventListener("resize",n)}),f==null||f(),(C=_)==null||C.disconnect(),_=null,u&&cancelAnimationFrame(y)}}const SV=JU,CV=eV,kV=XU,EV=nV,RV=QU,nT=YU,TV=tV,AV=(e,t,n)=>{const r=new Map,i={platform:yV,...n},s={...i.platform,_c:r};return KU(e,t,{...i,platform:s})};var NV=typeof document<"u",MV=function(){},ym=NV?b.useLayoutEffect:MV;function Xm(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Xm(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!Xm(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function g5(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function rT(e,t){const n=g5(e);return Math.round(t*n)/n}function v0(e){const t=b.useRef(e);return ym(()=>{t.current=e}),t}function LV(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:a}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[p,f]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[v,_]=b.useState(r);Xm(v,r)||_(r);const[y,w]=b.useState(null),[k,C]=b.useState(null),E=b.useCallback(U=>{U!==M.current&&(M.current=U,w(U))},[]),R=b.useCallback(U=>{U!==L.current&&(L.current=U,C(U))},[]),T=s||y,N=a||k,M=b.useRef(null),L=b.useRef(null),O=b.useRef(p),$=u!=null,I=v0(u),B=v0(i),j=v0(d),V=b.useCallback(()=>{if(!M.current||!L.current)return;const U={placement:t,strategy:n,middleware:v};B.current&&(U.platform=B.current),AV(M.current,L.current,U).then(X=>{const D={...X,isPositioned:j.current!==!1};F.current&&!Xm(O.current,D)&&(O.current=D,Xi.flushSync(()=>{f(D)}))})},[v,t,n,B,j]);ym(()=>{d===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,f(U=>({...U,isPositioned:!1})))},[d]);const F=b.useRef(!1);ym(()=>(F.current=!0,()=>{F.current=!1}),[]),ym(()=>{if(T&&(M.current=T),N&&(L.current=N),T&&N){if(I.current)return I.current(T,N,V);V()}},[T,N,V,I,$]);const W=b.useMemo(()=>({reference:M,floating:L,setReference:E,setFloating:R}),[E,R]),P=b.useMemo(()=>({reference:T,floating:N}),[T,N]),K=b.useMemo(()=>{const U={position:n,left:0,top:0};if(!P.floating)return U;const X=rT(P.floating,p.x),D=rT(P.floating,p.y);return l?{...U,transform:"translate("+X+"px, "+D+"px)",...g5(P.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:X,top:D}},[n,l,P.floating,p.x,p.y]);return b.useMemo(()=>({...p,update:V,refs:W,elements:P,floatingStyles:K}),[p,V,W,P,K])}const DV=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?nT({element:r.current,padding:i}).fn(n):{}:r?nT({element:r,padding:i}).fn(n):{}}}},OV=(e,t)=>{const n=SV(e);return{name:n.name,fn:n.fn,options:[e,t]}},PV=(e,t)=>{const n=CV(e);return{name:n.name,fn:n.fn,options:[e,t]}},IV=(e,t)=>({fn:TV(e).fn,options:[e,t]}),jV=(e,t)=>{const n=kV(e);return{name:n.name,fn:n.fn,options:[e,t]}},zV=(e,t)=>{const n=EV(e);return{name:n.name,fn:n.fn,options:[e,t]}},BV=(e,t)=>{const n=RV(e);return{name:n.name,fn:n.fn,options:[e,t]}},HV=(e,t)=>{const n=DV(e);return{name:n.name,fn:n.fn,options:[e,t]}};var $V="Arrow",v5=b.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return m.jsx(xt.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});v5.displayName=$V;var FV=v5;function UV(e){const[t,n]=b.useState(void 0);return Sr(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let a,l;if("borderBoxSize"in s){const u=s.borderBoxSize,d=Array.isArray(u)?u[0]:u;a=d.inlineSize,l=d.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Sw="Popper",[_5,xa]=vo(Sw),[VV,b5]=_5(Sw),y5=e=>{const{__scopePopper:t,children:n}=e,[r,i]=b.useState(null);return m.jsx(VV,{scope:t,anchor:r,onAnchorChange:i,children:n})};y5.displayName=Sw;var x5="PopperAnchor",w5=b.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=b5(x5,n),a=b.useRef(null),l=zt(t,a),u=b.useRef(null);return b.useEffect(()=>{const d=u.current;u.current=(r==null?void 0:r.current)||a.current,d!==u.current&&s.onAnchorChange(u.current)}),r?null:m.jsx(xt.div,{...i,ref:l})});w5.displayName=x5;var Cw="PopperContent",[WV,GV]=_5(Cw),S5=b.forwardRef((e,t)=>{var de,be,re,ge,pe,Ee;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:p=0,sticky:f="partial",hideWhenDetached:v=!1,updatePositionStrategy:_="optimized",onPlaced:y,...w}=e,k=b5(Cw,n),[C,E]=b.useState(null),R=zt(t,Re=>E(Re)),[T,N]=b.useState(null),M=UV(T),L=(M==null?void 0:M.width)??0,O=(M==null?void 0:M.height)??0,$=r+(s!=="center"?"-"+s:""),I=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},B=Array.isArray(d)?d:[d],j=B.length>0,V={padding:I,boundary:B.filter(KV),altBoundary:j},{refs:F,floatingStyles:W,placement:P,isPositioned:K,middlewareData:U}=LV({strategy:"fixed",placement:$,whileElementsMounted:(...Re)=>wV(...Re,{animationFrame:_==="always"}),elements:{reference:k.anchor},middleware:[OV({mainAxis:i+O,alignmentAxis:a}),u&&PV({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?IV():void 0,...V}),u&&jV({...V}),zV({...V,apply:({elements:Re,rects:Fe,availableWidth:it,availableHeight:Ct})=>{const{width:Mt,height:nn}=Fe.reference,ut=Re.floating.style;ut.setProperty("--radix-popper-available-width",`${it}px`),ut.setProperty("--radix-popper-available-height",`${Ct}px`),ut.setProperty("--radix-popper-anchor-width",`${Mt}px`),ut.setProperty("--radix-popper-anchor-height",`${nn}px`)}}),T&&HV({element:T,padding:l}),YV({arrowWidth:L,arrowHeight:O}),v&&BV({strategy:"referenceHidden",...V})]}),[X,D]=E5(P),G=es(y);Sr(()=>{K&&(G==null||G())},[K,G]);const Z=(de=U.arrow)==null?void 0:de.x,z=(be=U.arrow)==null?void 0:be.y,oe=((re=U.arrow)==null?void 0:re.centerOffset)!==0,[ue,ne]=b.useState();return Sr(()=>{C&&ne(window.getComputedStyle(C).zIndex)},[C]),m.jsx("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:K?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ue,"--radix-popper-transform-origin":[(ge=U.transformOrigin)==null?void 0:ge.x,(pe=U.transformOrigin)==null?void 0:pe.y].join(" "),...((Ee=U.hide)==null?void 0:Ee.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(WV,{scope:n,placedSide:X,onArrowChange:N,arrowX:Z,arrowY:z,shouldHideArrow:oe,children:m.jsx(xt.div,{"data-side":X,"data-align":D,...w,ref:R,style:{...w.style,animation:K?void 0:"none"}})})})});S5.displayName=Cw;var C5="PopperArrow",qV={top:"bottom",right:"left",bottom:"top",left:"right"},k5=b.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=GV(C5,r),a=qV[s.placedSide];return m.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:m.jsx(FV,{...i,ref:n,style:{...i.style,display:"block"}})})});k5.displayName=C5;function KV(e){return e!==null}var YV=e=>({name:"transformOrigin",options:e,fn(t){var k,C,E;const{placement:n,rects:r,middlewareData:i}=t,a=((k=i.arrow)==null?void 0:k.centerOffset)!==0,l=a?0:e.arrowWidth,u=a?0:e.arrowHeight,[d,p]=E5(n),f={start:"0%",center:"50%",end:"100%"}[p],v=(((C=i.arrow)==null?void 0:C.x)??0)+l/2,_=(((E=i.arrow)==null?void 0:E.y)??0)+u/2;let y="",w="";return d==="bottom"?(y=a?f:`${v}px`,w=`${-u}px`):d==="top"?(y=a?f:`${v}px`,w=`${r.floating.height+u}px`):d==="right"?(y=`${-u}px`,w=a?f:`${_}px`):d==="left"&&(y=`${r.floating.width+u}px`,w=a?f:`${_}px`),{data:{x:y,y:w}}}});function E5(e){const[t,n="center"]=e.split("-");return[t,n]}var tv=y5,Hh=w5,nv=S5,rv=k5,R5=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),XV="VisuallyHidden",T5=b.forwardRef((e,t)=>m.jsx(xt.span,{...e,ref:t,style:{...R5,...e.style}}));T5.displayName=XV;var QV=T5,[iv]=vo("Tooltip",[xa]),sv=xa(),A5="TooltipProvider",ZV=700,Zy="tooltip.open",[JV,kw]=iv(A5),N5=e=>{const{__scopeTooltip:t,delayDuration:n=ZV,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,a=b.useRef(!0),l=b.useRef(!1),u=b.useRef(0);return b.useEffect(()=>{const d=u.current;return()=>window.clearTimeout(d)},[]),m.jsx(JV,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:b.useCallback(()=>{window.clearTimeout(u.current),a.current=!1},[]),onClose:b.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:b.useCallback(d=>{l.current=d},[]),disableHoverableContent:i,children:s})};N5.displayName=A5;var dh="Tooltip",[eW,$h]=iv(dh),M5=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:a,delayDuration:l}=e,u=kw(dh,e.__scopeTooltip),d=sv(t),[p,f]=b.useState(null),v=co(),_=b.useRef(0),y=a??u.disableHoverableContent,w=l??u.delayDuration,k=b.useRef(!1),[C,E]=Qc({prop:r,defaultProp:i??!1,onChange:L=>{L?(u.onOpen(),document.dispatchEvent(new CustomEvent(Zy))):u.onClose(),s==null||s(L)},caller:dh}),R=b.useMemo(()=>C?k.current?"delayed-open":"instant-open":"closed",[C]),T=b.useCallback(()=>{window.clearTimeout(_.current),_.current=0,k.current=!1,E(!0)},[E]),N=b.useCallback(()=>{window.clearTimeout(_.current),_.current=0,E(!1)},[E]),M=b.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{k.current=!0,E(!0),_.current=0},w)},[w,E]);return b.useEffect(()=>()=>{_.current&&(window.clearTimeout(_.current),_.current=0)},[]),m.jsx(tv,{...d,children:m.jsx(eW,{scope:t,contentId:v,open:C,stateAttribute:R,trigger:p,onTriggerChange:f,onTriggerEnter:b.useCallback(()=>{u.isOpenDelayedRef.current?M():T()},[u.isOpenDelayedRef,M,T]),onTriggerLeave:b.useCallback(()=>{y?N():(window.clearTimeout(_.current),_.current=0)},[N,y]),onOpen:T,onClose:N,disableHoverableContent:y,children:n})})};M5.displayName=dh;var Jy="TooltipTrigger",L5=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=$h(Jy,n),s=kw(Jy,n),a=sv(n),l=b.useRef(null),u=zt(t,l,i.onTriggerChange),d=b.useRef(!1),p=b.useRef(!1),f=b.useCallback(()=>d.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),m.jsx(Hh,{asChild:!0,...a,children:m.jsx(xt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:u,onPointerMove:Be(e.onPointerMove,v=>{v.pointerType!=="touch"&&!p.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),p.current=!0)}),onPointerLeave:Be(e.onPointerLeave,()=>{i.onTriggerLeave(),p.current=!1}),onPointerDown:Be(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Be(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:Be(e.onBlur,i.onClose),onClick:Be(e.onClick,i.onClose)})})});L5.displayName=Jy;var Ew="TooltipPortal",[tW,nW]=iv(Ew,{forceMount:void 0}),D5=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=$h(Ew,t);return m.jsx(tW,{scope:t,forceMount:n,children:m.jsx(Ii,{present:n||s.open,children:m.jsx(hu,{asChild:!0,container:i,children:r})})})};D5.displayName=Ew;var Jc="TooltipContent",O5=b.forwardRef((e,t)=>{const n=nW(Jc,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,a=$h(Jc,e.__scopeTooltip);return m.jsx(Ii,{present:r||a.open,children:a.disableHoverableContent?m.jsx(P5,{side:i,...s,ref:t}):m.jsx(rW,{side:i,...s,ref:t})})}),rW=b.forwardRef((e,t)=>{const n=$h(Jc,e.__scopeTooltip),r=kw(Jc,e.__scopeTooltip),i=b.useRef(null),s=zt(t,i),[a,l]=b.useState(null),{trigger:u,onClose:d}=n,p=i.current,{onPointerInTransitChange:f}=r,v=b.useCallback(()=>{l(null),f(!1)},[f]),_=b.useCallback((y,w)=>{const k=y.currentTarget,C={x:y.clientX,y:y.clientY},E=lW(C,k.getBoundingClientRect()),R=cW(C,E),T=uW(w.getBoundingClientRect()),N=hW([...R,...T]);l(N),f(!0)},[f]);return b.useEffect(()=>()=>v(),[v]),b.useEffect(()=>{if(u&&p){const y=k=>_(k,p),w=k=>_(k,u);return u.addEventListener("pointerleave",y),p.addEventListener("pointerleave",w),()=>{u.removeEventListener("pointerleave",y),p.removeEventListener("pointerleave",w)}}},[u,p,_,v]),b.useEffect(()=>{if(a){const y=w=>{const k=w.target,C={x:w.clientX,y:w.clientY},E=(u==null?void 0:u.contains(k))||(p==null?void 0:p.contains(k)),R=!dW(C,a);E?v():R&&(v(),d())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[u,p,a,d,v]),m.jsx(P5,{...e,ref:s})}),[iW,sW]=iv(dh,{isInside:!1}),oW=_H("TooltipContent"),P5=b.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:a,...l}=e,u=$h(Jc,n),d=sv(n),{onClose:p}=u;return b.useEffect(()=>(document.addEventListener(Zy,p),()=>document.removeEventListener(Zy,p)),[p]),b.useEffect(()=>{if(u.trigger){const f=v=>{const _=v.target;_!=null&&_.contains(u.trigger)&&p()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[u.trigger,p]),m.jsx(du,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:f=>f.preventDefault(),onDismiss:p,children:m.jsxs(nv,{"data-state":u.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[m.jsx(oW,{children:r}),m.jsx(iW,{scope:n,isInside:!0,children:m.jsx(QV,{id:u.contentId,role:"tooltip",children:i||r})})]})})});O5.displayName=Jc;var I5="TooltipArrow",aW=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=sv(n);return sW(I5,n).isInside?null:m.jsx(rv,{...i,...r,ref:t})});aW.displayName=I5;function lW(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function cW(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function uW(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function dW(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const l=t[s],u=t[a],d=l.x,p=l.y,f=u.x,v=u.y;p>r!=v>r&&n<(f-d)*(r-p)/(v-p)+d&&(i=!i)}return i}function hW(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),fW(t)}function fW(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var pW=N5,j5=M5,z5=L5,B5=D5,Rw=O5;function H5({className:e,...t}){return m.jsx("kbd",{className:Ce("pointer-events-none inline-flex h-5 min-w-5 items-center justify-center rounded border border-border/60 bg-muted/50 px-1.5 font-mono text-[11px] font-medium text-current select-none",e),...t})}function mW({className:e,...t}){return m.jsx("span",{className:Ce("inline-flex items-center gap-0.5",e),...t})}const gW="z-50 overflow-hidden rounded-md border border-border backdrop-blur-md p-0.5 text-[11px] font-medium text-card-foreground shadow-sm animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",vW=pW,gl=j5,vl=z5,_a=b.forwardRef(({className:e,sideOffset:t=4,...n},r)=>m.jsx(B5,{children:m.jsx(Rw,{ref:r,sideOffset:t,className:Ce("z-50 overflow-hidden rounded-md bg-card text-card-foreground border border-border px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));_a.displayName=Rw.displayName;const Pd=j5,Id=z5;function $5(e){return e.toUpperCase()}function _W(e){const t=e.split("+");return m.jsx(mW,{children:t.map((n,r)=>m.jsx(H5,{children:$5(n)},`${n}-${r}`))})}const Pc=b.forwardRef(({className:e,sideOffset:t=4,children:n,shortcut:r,...i},s)=>{const a=r===void 0?null:Array.isArray(r)?r[0]??null:r;return m.jsx(B5,{children:m.jsx(Rw,{ref:s,sideOffset:t,className:Ce(gW,e),...i,children:a?_W(a):m.jsx("span",{children:typeof n=="string"?$5(n):n})})})});Pc.displayName="HotkeyTooltipContent";const bW="0.25.1",yW={version:bW},Pn="Kanna",iT="kanna",xW=".kanna",wW=".kanna-dev",SW="KANNA_RUNTIME_PROFILE",Tw=`kanna/${yW.version}`,CW="[kanna]",kW=`~/${Pn}`;function ov(){var t;return(t=globalThis.process)==null?void 0:t.env}function EW(e=ov()){var t;return((t=e==null?void 0:e[SW])==null?void 0:t.trim().toLowerCase())==="dev"?"dev":"prod"}function RW(e=ov()){return EW(e)==="dev"?wW:xW}function TW(e=ov()){return`~/${RW(e)}`}function AW(e=ov()){return`${TW(e)}/keybindings.json`}function Ap(e){return e?`${iT} ${e}`:iT}const sT=e=>{let t;const n=new Set,r=(d,p)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const v=t;t=p??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(_=>_(t,v))}},i=()=>t,l={setState:r,getState:i,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d))},u=t=e(r,i,l);return l},NW=(e=>e?sT(e):sT),MW=e=>e;function LW(e,t=MW){const n=tn.useSyncExternalStore(e.subscribe,tn.useCallback(()=>t(e.getState()),[e,t]),tn.useCallback(()=>t(e.getInitialState()),[e,t]));return tn.useDebugValue(n),n}const DW=e=>{const t=NW(e),n=r=>LW(t,r);return Object.assign(n,t),n},wa=(e=>DW);function OW(e,t){let n;try{n=e()}catch{return}return{getItem:i=>{var s;const a=u=>u===null?null:JSON.parse(u,void 0),l=(s=n.getItem(i))!=null?s:null;return l instanceof Promise?l.then(a):a(l)},setItem:(i,s)=>n.setItem(i,JSON.stringify(s,void 0)),removeItem:i=>n.removeItem(i)}}const ex=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return ex(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return ex(r)(n)}}}},PW=(e,t)=>(n,r,i)=>{let s={storage:OW(()=>window.localStorage),partialize:k=>k,version:0,merge:(k,C)=>({...C,...k}),...t},a=!1,l=0;const u=new Set,d=new Set;let p=s.storage;if(!p)return e((...k)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...k)},r,i);const f=()=>{const k=s.partialize({...r()});return p.setItem(s.name,{state:k,version:s.version})},v=i.setState;i.setState=(k,C)=>(v(k,C),f());const _=e((...k)=>(n(...k),f()),r,i);i.getInitialState=()=>_;let y;const w=()=>{var k,C;if(!p)return;const E=++l;a=!1,u.forEach(T=>{var N;return T((N=r())!=null?N:_)});const R=((C=s.onRehydrateStorage)==null?void 0:C.call(s,(k=r())!=null?k:_))||void 0;return ex(p.getItem.bind(p))(s.name).then(T=>{if(T)if(typeof T.version=="number"&&T.version!==s.version){if(s.migrate){const N=s.migrate(T.state,T.version);return N instanceof Promise?N.then(M=>[!0,M]):[!0,N]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,T.state];return[!1,void 0]}).then(T=>{var N;if(E!==l)return;const[M,L]=T;if(y=s.merge(L,(N=r())!=null?N:_),n(y,!0),M)return f()}).then(()=>{E===l&&(R==null||R(y,void 0),y=r(),a=!0,d.forEach(T=>T(y)))}).catch(T=>{E===l&&(R==null||R(void 0,T))})};return i.persist={setOptions:k=>{s={...s,...k},k.storage&&(p=k.storage)},clearStorage:()=>{p==null||p.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>w(),hasHydrated:()=>a,onHydrate:k=>(u.add(k),()=>{u.delete(k)}),onFinishHydration:k=>(d.add(k),()=>{d.delete(k)})},s.skipHydration||w(),y||_},Sa=PW,F5="always",U5="funk",IW=[{value:"blow",label:"Blow"},{value:"bottle",label:"Bottle"},{value:"frog",label:"Frog"},{value:"funk",label:"Funk"},{value:"glass",label:"Glass"},{value:"ping",label:"Ping"},{value:"pop",label:"Pop"},{value:"purr",label:"Purr"},{value:"tink",label:"Tink"}];function oT(e){switch(e){case"never":case"unfocused":case"always":return e;default:return F5}}function aT(e){switch(e){case"blow":case"bottle":case"frog":case"funk":case"glass":case"ping":case"pop":case"purr":case"tink":return e;default:return U5}}const Ic=wa()(Sa(e=>({chatSoundPreference:F5,chatSoundId:U5,setChatSoundPreference:t=>e({chatSoundPreference:oT(t)}),setChatSoundId:t=>e({chatSoundId:aT(t)})}),{name:"chat-sound-preferences",version:2,migrate:e=>{const t=e;return{chatSoundPreference:oT(t==null?void 0:t.chatSoundPreference),chatSoundId:aT(t==null?void 0:t.chatSoundId)}}})),jW={blow:"/chat-sounds/Blow.mp3",bottle:"/chat-sounds/Bottle.mp3",frog:"/chat-sounds/Frog.mp3",funk:"/chat-sounds/Funk.mp3",glass:"/chat-sounds/Glass.mp3",ping:"/chat-sounds/Ping.mp3",pop:"/chat-sounds/Pop.mp3",purr:"/chat-sounds/Purr.mp3",tink:"/chat-sounds/Tink.mp3"};function zW(e=document){return e.visibilityState!=="visible"||!e.hasFocus()}function BW(e){const t=new Audio(jW[e]);return t.preload="auto",t.play()}async function tx(e,t){if(t<=0)return;const n=Array.from({length:t},(r,i)=>new Promise(s=>{window.setTimeout(()=>{BW(e).catch(()=>{}).finally(()=>s())},i*90)}));await Promise.all(n)}function HW(e,t=document){return e==="never"?!1:e==="always"?!0:zW(t)}function $W(e){return e.projectGroups.reduce((t,n)=>t+n.chats.reduce((r,i)=>r+(i.unread?1:0)+(i.status==="waiting_for_user"?1:0),0),0)}function lT(e){let t=0;const n=new Set;for(const r of e.projectGroups)for(const i of r.chats)i.unread&&(t+=1),i.status==="waiting_for_user"&&n.add(i.chatId);return{unreadCount:t,waitingChatIds:n}}function FW(e,t){if(!e)return 0;const n=lT(e),r=lT(t),i=Math.max(0,r.unreadCount-n.unreadCount);let s=0;for(const a of r.waitingChatIds)n.waitingChatIds.has(a)||(s+=1);return i+s}const mu=({children:e,className:t,shimmerWidth:n=100,animate:r=!0,...i})=>m.jsx("span",{style:{"--shiny-width":`${Math.min(n,100)}px`},className:Ce("mx-auto max-w-md text-foreground/50",r?["animate-shiny-text [background-size:var(--shiny-width)_100%] bg-clip-text [background-position:0_0] bg-no-repeat [transition:background-position_1s_cubic-bezier(.6,.6,0,1)_infinite]","bg-gradient-to-r from-transparent via-black/80 via-50% to-transparent dark:via-white/80"]:["text-neutral"],t),...i,children:e});function nx(e){return e.split(/[\s_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const UW=[/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(['"])([\s\S]*)\1$/,/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(.+)$/,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(.+)$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(.+)$/i];function VW(e){const t=e.trim();for(const n of UW){const r=t.match(n);if(!r)continue;const i=(r[2]??r[1]??"").trim();if(i)return i}return t}function V5(e){return e.split("/").pop()||e}function WW(e,t){if(e===void 0)return null;const n=Math.max(0,t-e),r=6e4,i=60*r,s=24*i,a=7*s;return n<r?"now":n<i?`${Math.floor(n/r)}m`:n<s?`${Math.floor(n/i)}h`:n<a?`${Math.floor(n/s)}d`:`${Math.floor(n/a)}w`}const GW=new Set(["starting","running"]);function qW({chat:e,activeChatId:t,nowMs:n,shortcutHint:r=null,showShortcutHint:i=!1,onSelectChat:s,onDeleteChat:a}){const l=WW(e.lastMessageAt,n),u=i&&r?r:l,d=i&&!!r,p=cH(e.chatId);return m.jsxs("div",{"data-chat-id":p,className:Ce("group flex items-center gap-2 pl-2.5 pr-0.5 py-0.5 rounded-lg cursor-pointer border-border/0 hover:border-border hover:bg-muted/20 active:scale-[0.985] border transition-all",t===p?"bg-muted hover:bg-muted border-border":"border-border/0 dark:hover:border-slate-400/10 "),onClick:()=>s(e.chatId),children:[GW.has(e.status)?m.jsx(bn,{className:"size-3.5 flex-shrink-0 animate-spin text-muted-foreground"}):e.status==="waiting_for_user"?m.jsx("div",{className:"relative ",children:m.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[m.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-blue-400/80 animate-ping"}),m.jsx("div",{className:" rounded-full z-0 size-2.5 bg-blue-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):e.unread?m.jsx("div",{className:"relative ",children:m.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[m.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-emerald-400/80 animate-ping"}),m.jsx("div",{className:" rounded-full z-0 size-2.5 bg-emerald-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):null,m.jsx("span",{className:"text-sm truncate flex-1 translate-y-[-0.5px]",children:e.status!=="idle"&&e.status!=="waiting_for_user"?m.jsx(mu,{animate:e.status==="running",shimmerWidth:Math.max(20,e.title.length*3),children:e.title}):e.title}),m.jsxs("div",{className:"relative h-7 w-7 mr-[2px] shrink-0",children:[u?d?m.jsx("span",{className:"hidden md:flex absolute inset-0 items-center justify-end pr-0.5 text-[11px] text-foreground transition-opacity group-hover:opacity-0",children:m.jsx(H5,{className:"h-4 min-w-4 rounded-sm border-border/50 bg-transparent px-1 text-[10px]",children:r})}):m.jsx("span",{className:"hidden md:flex absolute inset-0 items-center justify-end pr-1 text-[11px] text-muted-foreground opacity-50 transition-opacity group-hover:opacity-0",children:u}):null,m.jsx(nt,{variant:"ghost",size:"icon",className:Ce("absolute inset-0 h-7 w-7 opacity-100 cursor-pointer rounded-sm hover:!bg-transparent !border-0",u?"md:opacity-0 md:group-hover:opacity-100":"opacity-100 md:opacity-0 md:group-hover:opacity-100"),onClick:f=>{f.stopPropagation(),a(e.chatId)},title:"Delete chat",children:m.jsx(K$,{className:"size-3.5"})})]})]},e._id)}const KW=b.memo(qW);function YW(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return b.useMemo(()=>r=>{t.forEach(i=>i(r))},t)}const av=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function gu(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Aw(e){return"nodeType"in e}function Gr(e){var t,n;return e?gu(e)?e:Aw(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Nw(e){const{Document:t}=Gr(e);return e instanceof t}function Fh(e){return gu(e)?!1:e instanceof Gr(e).HTMLElement}function W5(e){return e instanceof Gr(e).SVGElement}function vu(e){return e?gu(e)?e.document:Aw(e)?Nw(e)?e:Fh(e)||W5(e)?e.ownerDocument:document:document:document}const Ts=av?b.useLayoutEffect:b.useEffect;function Mw(e){const t=b.useRef(e);return Ts(()=>{t.current=e}),b.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return t.current==null?void 0:t.current(...r)},[])}function XW(){const e=b.useRef(null),t=b.useCallback((r,i)=>{e.current=setInterval(r,i)},[]),n=b.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function hh(e,t){t===void 0&&(t=[e]);const n=b.useRef(e);return Ts(()=>{n.current!==e&&(n.current=e)},t),n}function Uh(e,t){const n=b.useRef();return b.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Qm(e){const t=Mw(e),n=b.useRef(null),r=b.useCallback(i=>{i!==n.current&&(t==null||t(i,n.current)),n.current=i},[]);return[n,r]}function rx(e){const t=b.useRef();return b.useEffect(()=>{t.current=e},[e]),t.current}let _0={};function Vh(e,t){return b.useMemo(()=>{if(t)return t;const n=_0[e]==null?0:_0[e]+1;return _0[e]=n,e+"-"+n},[e,t])}function G5(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((s,a)=>{const l=Object.entries(a);for(const[u,d]of l){const p=s[u];p!=null&&(s[u]=p+e*d)}return s},{...t})}}const Vc=G5(1),Zm=G5(-1);function QW(e){return"clientX"in e&&"clientY"in e}function Lw(e){if(!e)return!1;const{KeyboardEvent:t}=Gr(e.target);return t&&e instanceof t}function ZW(e){if(!e)return!1;const{TouchEvent:t}=Gr(e.target);return t&&e instanceof t}function ix(e){if(ZW(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return QW(e)?{x:e.clientX,y:e.clientY}:null}const fh=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[fh.Translate.toString(e),fh.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),cT="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function JW(e){return e.matches(cT)?e:e.querySelector(cT)}const eG={display:"none"};function tG(e){let{id:t,value:n}=e;return tn.createElement("div",{id:t,style:eG},n)}function nG(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return tn.createElement("div",{id:t,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function rG(){const[e,t]=b.useState("");return{announce:b.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const q5=b.createContext(null);function iG(e){const t=b.useContext(q5);b.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function sG(){const[e]=b.useState(()=>new Set),t=b.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[b.useCallback(r=>{let{type:i,event:s}=r;e.forEach(a=>{var l;return(l=a[i])==null?void 0:l.call(a,s)})},[e]),t]}const oG={draggable:`
|
|
586
586
|
To pick up a draggable item, press the space bar.
|
|
587
587
|
While dragging, use the arrow keys to move the item.
|
|
588
588
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
@@ -2487,7 +2487,7 @@ XID_Start XIDS`.split(/\s/).map(e=>[Nv(e),e])),Lae=new Map([["s",Gn(383)],[Gn(38
|
|
|
2487
2487
|
}`}function hy({code:e,pre:t,columnType:n,rowSpan:r,containerSize:i=!1}={}){return e==null&&(e=document.createElement("code"),e.setAttribute("data-code",""),n!=null&&e.setAttribute(`data-${n}`,""),t==null||t.appendChild(e)),r!=null?e.style.setProperty("grid-row",`span ${r}`):e.style.removeProperty("grid-row"),i?e.setAttribute("data-container-size",""):e.removeAttribute("data-container-size"),e}function Tce({shadowRoot:e,currentNode:t,themeCSS:n}){if(n.trim()===""){t==null||t.remove();return}return t??(t=Ace()),t.textContent=n,t.parentNode!==e&&e.appendChild(t),t}function Ace(){const e=document.createElement("style");return e.setAttribute(F3,""),e}function Nce(e,t){if(t==null)return;const n=e.shadowRoot??e.attachShadow({mode:"open"});n.innerHTML===""&&(n.innerHTML=t)}function Mce(e,{type:t,diffIndicators:n,disableBackground:r,disableLineNumbers:i,overflow:s,split:a,totalLines:l,customProperties:u}){if(u!=null)for(const d in u){const p=u[d];p!=null&&e.setAttribute(d,`${p}`)}switch(t==="diff"?(e.setAttribute("data-diff",""),e.removeAttribute("data-file")):(e.setAttribute("data-file",""),e.removeAttribute("data-diff")),n){case"bars":case"classic":e.setAttribute("data-indicators",n);break;case"none":e.removeAttribute("data-indicators");break}return i?e.setAttribute("data-disable-line-numbers",""):e.removeAttribute("data-disable-line-numbers"),r?e.removeAttribute("data-background"):e.setAttribute("data-background",""),t==="diff"?e.setAttribute("data-diff-type",a?"split":"single"):e.removeAttribute("data-diff-type"),e.setAttribute("data-overflow",s),e.tabIndex=0,e.style.setProperty("--diffs-min-number-column-width-default",`${`${l}`.length}ch`),e}if(typeof HTMLElement<"u"&&customElements.get(dg)==null){let e;class t extends HTMLElement{constructor(){if(super(),this.shadowRoot!=null)return;const r=this.attachShadow({mode:"open"});e==null&&(e=new CSSStyleSheet,e.replaceSync(kce)),r.adoptedStyleSheets=[e]}}customElements.define(dg,t)}const Lce=!0;function ON(e,t,n){if(e===t||e==null||t==null)return e===t;const r=new Set(n),i=Object.keys(e),s=new Set(Object.keys(t));for(const a of i)if(s.delete(a),!r.has(a)&&(!(a in t)||e[a]!==t[a]))return!1;for(const a of Array.from(s))if(!r.has(a))return!1;return!0}function Dce(e,t){const n=(e==null?void 0:e.theme)??xs,r=(t==null?void 0:t.theme)??xs,i=PN(e),s=PN(t);return QI(n,r)&&ON(e,t,["theme","parseDiffOptions"])&&ON(i,s)}function PN(e){if(e!=null&&"parseDiffOptions"in e)return e.parseDiffOptions}function Oce({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function Pce(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:Ice(n,e.startContentIndex)}}function Ice(e,t){let n=e.unifiedLineStart;for(let r=0;r<t;r++){const i=e.hunkContent[r];n+=i.type==="context"?i.lines:i.deletions+i.additions}return n}function jce({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderMetadata:i,renderAnnotation:s,renderGutterUtility:a,renderHoverUtility:l,renderMergeConflictUtility:u,lineAnnotations:d,getHoveredLine:p,getInstance:f}){const v=a??l,_=n==null?void 0:n(e),y=r==null?void 0:r(e),w=i==null?void 0:i(e);return m.jsxs(m.Fragment,{children:[_!=null?m.jsx("div",{slot:TS,children:_}):m.jsxs(m.Fragment,{children:[y!=null&&m.jsx("div",{slot:ES,children:y}),w!=null&&m.jsx("div",{slot:RS,children:w})]}),s!=null&&(d==null?void 0:d.map((k,C)=>m.jsx("div",{slot:xh(k),children:s(k)},C))),t!=null&&u!=null&&f!=null&&t.map(k=>{if(k==null)return;const C=zce(k,e);return m.jsx("div",{slot:C,style:gre,children:u(k,f)},C)}),v!=null&&m.jsx("div",{slot:"gutter-utility-slot",style:mre,children:v(p)})]})}function zce(e,t){const n=Pce(e,t);return n!=null?Oce({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}var Bce=class{constructor(){Y(this,"isDeletionsScrolling",!1);Y(this,"isAdditionsScrolling",!1);Y(this,"timeoutId",-1);Y(this,"codeDeletions");Y(this,"codeAdditions");Y(this,"enabled",!1);Y(this,"handleDeletionsScroll",()=>{var e,t;this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),(t=this.codeAdditions)==null||t.scrollTo({left:(e=this.codeDeletions)==null?void 0:e.scrollLeft}))});Y(this,"handleAdditionsScroll",()=>{var e,t;this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),(t=this.codeDeletions)==null||t.scrollTo({left:(e=this.codeAdditions)==null?void 0:e.scrollLeft}))})}cleanUp(){var e,t;this.enabled&&((e=this.codeDeletions)==null||e.removeEventListener("scroll",this.handleDeletionsScroll),(t=this.codeAdditions)==null||t.removeEventListener("scroll",this.handleAdditionsScroll),clearTimeout(this.timeoutId),this.codeDeletions=void 0,this.codeAdditions=void 0,this.enabled=!1)}setup(e,t,n){var r,i;if(t==null||n==null)for(const s of e.children??[])s instanceof HTMLElement&&("deletions"in s.dataset?t=s:"additions"in s.dataset&&(n=s));if(n==null||t==null){this.cleanUp();return}this.codeDeletions!==t&&((r=this.codeDeletions)==null||r.removeEventListener("scroll",this.handleDeletionsScroll),this.codeDeletions=t,t.addEventListener("scroll",this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==n&&((i=this.codeAdditions)==null||i.removeEventListener("scroll",this.handleAdditionsScroll),this.codeAdditions=n,n.addEventListener("scroll",this.handleAdditionsScroll,{passive:!0})),this.enabled=!0}};function Kp(e){return ft({tagName:"div",properties:{"data-content-buffer":"","data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function Yp(e){return ft({tagName:"div",children:[ft({tagName:"span",children:[mo("No newline at end of file")]})],properties:{"data-no-newline":"","data-line-type":e,"data-column-content":""}})}function fy(e){return ft({tagName:"div",children:[Sg({name:e==="both"?"diffs-icon-expand-all":"diffs-icon-expand",properties:{"data-icon":""}})],properties:{"data-expand-button":"","data-expand-both":e==="both"?"":void 0,"data-expand-up":e==="up"?"":void 0,"data-expand-down":e==="down"?"":void 0}})}function kc({type:e,content:t,expandIndex:n,chunked:r=!1,slotName:i,isFirstHunk:s,isLastHunk:a}){const l=[];if(e==="metadata"&&t!=null&&l.push(ft({tagName:"div",children:[mo(t)],properties:{"data-separator-wrapper":""}})),(e==="line-info"||e==="line-info-basic")&&t!=null){const u=[];n!=null&&(r?(s||u.push(fy("up")),a||u.push(fy("down"))):u.push(fy(!s&&!a?"both":s?"down":"up"))),u.push(ft({tagName:"div",children:[ft({tagName:"span",children:[mo(t)],properties:{"data-unmodified-lines":""}})],properties:{"data-separator-content":""}})),l.push(ft({tagName:"div",children:u,properties:{"data-separator-wrapper":"","data-separator-multi-button":u.length>2?"":void 0}}))}return e==="custom"&&i!=null&&l.push(ft({tagName:"slot",properties:{name:i}})),ft({tagName:"div",children:l,properties:{"data-separator":l.length===0?"simple":e,"data-expand-index":n,"data-separator-first":s?"":void 0,"data-separator-last":a?"":void 0}})}function Hce(e,t){return`hunk-separator-${e}-${t}`}function $ce(e){const t=e.at(-1);return t==null?0:Math.max(t.additionStart+t.additionCount,t.deletionStart+t.deletionCount)}function Fce(e){return e.startingLine===0&&e.totalLines===1/0&&e.bufferBefore===0&&e.bufferAfter===0}let Uce=-1;var Vce=class{constructor(e={theme:xs},t,n){Y(this,"__id",`diff-hunks-renderer:${++Uce}`);Y(this,"highlighter");Y(this,"diff");Y(this,"expandedHunks",new Map);Y(this,"deletionAnnotations",{});Y(this,"additionAnnotations",{});Y(this,"computedLang","text");Y(this,"renderCache");this.options=e,this.onRenderUpdate=t,this.workerManager=n,(n==null?void 0:n.isWorkingPool())!==!0&&(this.highlighter=dy(e.theme??xs)?yle():void 0)}cleanUp(){var e;this.highlighter=void 0,this.diff=void 0,this.renderCache=void 0,(e=this.workerManager)==null||e.cleanUpPendingTasks(this),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){var e;this.highlighter=void 0,this.diff=void 0,this.renderCache=void 0,(e=this.workerManager)==null||e.cleanUpPendingTasks(this)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}expandHunk(e,t,n=this.getOptionsWithDefaults().expansionLineCount){var i;const r={...this.expandedHunks.get(e)??{fromStart:0,fromEnd:0}};(t==="up"||t==="both")&&(r.fromStart+=n),(t==="down"||t==="both")&&(r.fromEnd+=n),((i=this.renderCache)==null?void 0:i.highlighted)!==!0&&(this.renderCache=void 0),this.expandedHunks.set(e,r)}getExpandedHunk(e){return this.expandedHunks.get(e)??kre}getExpandedHunksMap(){return this.expandedHunks}setLineAnnotations(e){this.additionAnnotations={},this.deletionAnnotations={};for(const t of e){const n=(()=>{switch(t.side){case"deletions":return this.deletionAnnotations;case"additions":return this.additionAnnotations}})(),r=n[t.lineNumber]??[];n[t.lineNumber]=r,r.push(t)}}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e}}getSplitLineDecoration({side:e,type:t}){return t!=="change"?{gutterLineType:t}:{gutterLineType:e==="deletions"?"change-deletion":"change-addition"}}createAnnotationElement(e){return cce(e)}getOptionsWithDefaults(){var R;const{diffIndicators:e="bars",diffStyle:t="split",disableBackground:n=!1,disableFileHeader:r=!1,disableLineNumbers:i=!1,disableVirtualizationBuffers:s=!1,collapsed:a=!1,expandUnchanged:l=!1,collapsedContextThreshold:u=Gc,expansionLineCount:d=100,hunkSeparators:p="line-info",lineDiffType:f="word-alt",maxLineDiffLength:v=1e3,overflow:_="scroll",theme:y=xs,headerRenderMode:w="default",tokenizeMaxLineLength:k=1e3,useTokenTransformer:C=!1,useCSSClasses:E=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:n,disableFileHeader:r,disableLineNumbers:i,disableVirtualizationBuffers:s,collapsed:a,expandUnchanged:l,collapsedContextThreshold:u,expansionLineCount:d,hunkSeparators:p,lineDiffType:f,maxLineDiffLength:v,overflow:_,theme:((R=this.workerManager)==null?void 0:R.getDiffRenderOptions().theme)??y,headerRenderMode:w,tokenizeMaxLineLength:k,useTokenTransformer:C,useCSSClasses:E}}async initializeHighlighter(){return this.highlighter=await ble(vce(this.computedLang,this.options)),this.highlighter}hydrate(e){var r,i;if(e==null)return;this.diff=e;const{options:t}=this.getRenderOptions(e);let n=(r=this.workerManager)==null?void 0:r.getDiffResultCache(e);n!=null&&!cy(t,n.options)&&(n=void 0),this.renderCache??(this.renderCache={diff:e,highlighted:!Lle(e),options:t,result:n==null?void 0:n.result,renderRange:void 0}),((i=this.workerManager)==null?void 0:i.isWorkingPool())===!0&&this.renderCache.result==null&&this.workerManager.highlightDiffAST(this,this.diff)}getRenderOptions(e){const t=(()=>{var l;if(((l=this.workerManager)==null?void 0:l.isWorkingPool())===!0)return this.workerManager.getDiffRenderOptions();const{theme:r,tokenizeMaxLineLength:i,lineDiffType:s,maxLineDiffLength:a}=this.getOptionsWithDefaults();return{theme:r,useTokenTransformer:_ce(this.options),tokenizeMaxLineLength:i,lineDiffType:s,maxLineDiffLength:a}})();this.getOptionsWithDefaults();const{renderCache:n}=this;return(n==null?void 0:n.result)==null?{options:t,forceRender:!0}:e!==n.diff||!cy(t,n.options)?{options:t,forceRender:!0}:{options:t,forceRender:!1}}renderDiff(e=(n=>(n=this.renderCache)==null?void 0:n.diff)(),t=MA){var u,d;if(e==null)return;const{expandUnchanged:r=!1,collapsedContextThreshold:i}=this.getOptionsWithDefaults(),s=(u=this.workerManager)==null?void 0:u.getDiffResultCache(e);s!=null&&this.renderCache==null&&(this.renderCache={diff:e,highlighted:!0,renderRange:void 0,...s});const{options:a,forceRender:l}=this.getRenderOptions(e);if(this.renderCache??(this.renderCache={diff:e,highlighted:!1,options:a,result:void 0,renderRange:void 0}),((d=this.workerManager)==null?void 0:d.isWorkingPool())===!0)(this.renderCache.result==null||!this.renderCache.highlighted&&(e!==this.renderCache.diff||!JI(this.renderCache.renderRange,t)))&&(this.renderCache.diff=e,this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,Fce(t)||r?!0:this.expandedHunks,i),this.renderCache.renderRange=t),t.totalLines>0&&(!this.renderCache.highlighted||l)&&this.workerManager.highlightDiffAST(this,e);else{this.computedLang=e.lang??ru(e.name);const p=this.highlighter!=null&&dy(a.theme),f=this.highlighter!=null&&LN(this.computedLang);if(this.highlighter!=null&&p&&(l||!this.renderCache.highlighted&&f||this.renderCache.result==null)){const{result:v,options:_}=this.renderDiffWithHighlighter(e,this.highlighter,!f);this.renderCache={diff:e,options:_,highlighted:f,result:v,renderRange:void 0}}(!p||!f)&&this.asyncHighlight(e).then(({result:v,options:_})=>{this.onHighlightSuccess(e,v,_)})}return this.renderCache.result!=null?this.processDiffResult(this.renderCache.diff,t,this.renderCache.result):void 0}async asyncRender(e,t=MA){const{result:n}=await this.asyncHighlight(e);return this.processDiffResult(e,t,n)}createPreElement(e,t,n){const{diffIndicators:r,disableBackground:i,disableLineNumbers:s,overflow:a}=this.getOptionsWithDefaults();return mce({type:"diff",diffIndicators:r,disableBackground:i,disableLineNumbers:s,overflow:a,split:e,totalLines:t,customProperties:n})}async asyncHighlight(e){this.computedLang=e.lang??ru(e.name);const t=this.highlighter!=null&&dy(this.options.theme??xs),n=this.highlighter!=null&&LN(this.computedLang);return(this.highlighter==null||!t||!n)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,this.highlighter)}renderDiffWithHighlighter(e,t,n=!1){const{options:r}=this.getRenderOptions(e),{collapsedContextThreshold:i}=this.getOptionsWithDefaults();return{result:Yle(e,t,r,{forcePlainText:n,expandedHunks:n?!0:void 0,collapsedContextThreshold:i}),options:r}}onHighlightSuccess(e,t,n){var i;if(this.renderCache==null)return;const r=!this.renderCache.highlighted||!cy(this.renderCache.options,n)||this.renderCache.diff!==e;this.renderCache={diff:e,options:n,highlighted:!0,result:t,renderRange:void 0},r&&((i=this.onRenderUpdate)==null||i.call(this))}onHighlightError(e){console.error(e)}processDiffResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){const{diffStyle:s,disableFileHeader:a,expandUnchanged:l,expansionLineCount:u,collapsedContextThreshold:d,hunkSeparators:p}=this.getOptionsWithDefaults();this.diff=e;const f=s==="unified";let v=[],_=[],y=[];const w=[],{additionLines:k,deletionLines:C}=n,E={rowCount:0,hunkSeparators:p,additionsContentAST:v,deletionsContentAST:_,unifiedContentAST:y,unifiedGutterAST:Wp(),deletionsGutterAST:Wp(),additionsGutterAST:Wp(),expansionLineCount:u,hunkData:w,incrementRowCount(V=1){E.rowCount+=V},pushToGutter(V,F){switch(V){case"unified":E.unifiedGutterAST.children.push(F);break;case"deletions":E.deletionsGutterAST.children.push(F);break;case"additions":E.additionsGutterAST.children.push(F);break}}},R=Wce(e),T={size:0,side:void 0,increment(){this.size+=1},flush(){if(s!=="unified"){if(this.size<=0||this.side==null){this.side=void 0,this.size=0;return}this.side==="additions"?(E.pushToGutter("additions",Gi(void 0,"buffer",this.size)),v==null||v.push(Kp(this.size))):(E.pushToGutter("deletions",Gi(void 0,"buffer",this.size)),_==null||_.push(Kp(this.size))),this.size=0,this.side=void 0}}},N=(V,F,W,P,K)=>{E.pushToGutter(V,Sle(F,W,P,K))};function M(V){T.flush(),s==="unified"?py("unified",V,E):(py("deletions",V,E),py("additions",V,E))}Cg({diff:e,diffStyle:s,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:l?!0:this.expandedHunks,collapsedContextThreshold:d,callback:({hunkIndex:V,hunk:F,collapsedBefore:W,collapsedAfter:P,additionLine:K,deletionLine:U,type:X})=>{var ne,de;const D=U!=null?U.splitLineIndex:K.splitLineIndex,G=K!=null?K.unifiedLineIndex:U.unifiedLineIndex;s==="split"&&X!=="change"&&T.flush(),W>0&&M({hunkIndex:V,collapsedLines:W,rangeSize:Math.max((F==null?void 0:F.collapsedBefore)??0,0),hunkSpecs:F==null?void 0:F.hunkSpecs,isFirstHunk:V===0,isLastHunk:!1,isExpandable:!e.isPartial});const Z=s==="unified"?G:D,z={type:X,hunkIndex:V,lineIndex:Z,unifiedLineIndex:G,splitLineIndex:D,deletionLine:U,additionLine:K};if(s==="unified"){const be=(ne=this.getUnifiedInjectedRowsForLine)==null?void 0:ne.call(this,z);(be==null?void 0:be.before)!=null&&jN(be.before,E);let re=U!=null?C[U.lineIndex]:void 0,ge=K!=null?k[K.lineIndex]:void 0;if(re==null&&ge==null){const Re="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(Re,{file:e.name}),new Error(Re)}const pe=X==="change"?K!=null?"change-addition":"change-deletion":X,Ee=this.getUnifiedLineDecoration({type:X,lineType:pe,additionLineIndex:K==null?void 0:K.lineIndex,deletionLineIndex:U==null?void 0:U.lineIndex});N("unified",Ee.gutterLineType,K!=null?K.lineNumber:U.lineNumber,`${G},${D}`,Ee.gutterProperties),ge!=null?ge=Xp(ge,Ee.contentProperties):re!=null&&(re=Xp(re,Ee.contentProperties)),BN({diffStyle:"unified",type:X,deletionLine:re,additionLine:ge,unifiedSpan:this.getAnnotations("unified",U==null?void 0:U.lineNumber,K==null?void 0:K.lineNumber,V,Z),createAnnotationElement:Re=>this.createAnnotationElement(Re),context:E}),(be==null?void 0:be.after)!=null&&jN(be.after,E)}else{const be=(de=this.getSplitInjectedRowsForLine)==null?void 0:de.call(this,z);(be==null?void 0:be.before)!=null&&zN(be.before,E,T);let re=U!=null?C[U.lineIndex]:void 0,ge=K!=null?k[K.lineIndex]:void 0;const pe=this.getSplitLineDecoration({side:"deletions",type:X,lineIndex:U==null?void 0:U.lineIndex}),Ee=this.getSplitLineDecoration({side:"additions",type:X,lineIndex:K==null?void 0:K.lineIndex});if(re==null&&ge==null){const it="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(it,{file:e.name}),new Error(it)}const Re=(()=>{if(X==="change"){if(ge==null)return"additions";if(re==null)return"deletions"}})();if(Re!=null){if(T.side!=null&&T.side!==Re)throw new Error("DiffHunksRenderer.processDiffResult: iterateOverDiff, invalid pending splits");T.side=Re,T.increment()}const Fe=this.getAnnotations("split",U==null?void 0:U.lineNumber,K==null?void 0:K.lineNumber,V,Z);if(Fe!=null&&T.size>0&&T.flush(),U!=null){const it=Xp(re,pe.contentProperties);N("deletions",pe.gutterLineType,U.lineNumber,`${U.unifiedLineIndex},${D}`,pe.gutterProperties),it!=null&&(re=it)}if(K!=null){const it=Xp(ge,Ee.contentProperties);N("additions",Ee.gutterLineType,K.lineNumber,`${K.unifiedLineIndex},${D}`,Ee.gutterProperties),it!=null&&(ge=it)}BN({diffStyle:"split",type:X,additionLine:ge,deletionLine:re,...Fe,createAnnotationElement:it=>this.createAnnotationElement(it),context:E}),(be==null?void 0:be.after)!=null&&zN(be.after,E,T)}const oe=(U==null?void 0:U.noEOFCR)??!1,ue=(K==null?void 0:K.noEOFCR)??!1;if(ue||oe){if(oe){const be=X==="context"||X==="context-expanded"?X:"change-deletion";s==="unified"?(E.unifiedContentAST.push(Yp(be)),E.pushToGutter("unified",Gi(be,"metadata",1))):(E.deletionsContentAST.push(Yp(be)),E.pushToGutter("deletions",Gi(be,"metadata",1)),ue||(E.pushToGutter("additions",Gi(void 0,"buffer",1)),E.additionsContentAST.push(Kp(1))))}if(ue){const be=X==="context"||X==="context-expanded"?X:"change-addition";s==="unified"?(E.unifiedContentAST.push(Yp(be)),E.pushToGutter("unified",Gi(be,"metadata",1))):(E.additionsContentAST.push(Yp(be)),E.pushToGutter("additions",Gi(be,"metadata",1)),oe||(E.pushToGutter("deletions",Gi(void 0,"buffer",1)),E.deletionsContentAST.push(Kp(1))))}E.incrementRowCount(1)}P>0&&p!=="simple"&&M({hunkIndex:X==="context-expanded"?V:V+1,collapsedLines:P,rangeSize:R,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:!e.isPartial}),E.incrementRowCount(1)}}),s==="split"&&T.flush();const L=Math.max($ce(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),O=t.bufferBefore>0||t.bufferAfter>0,$=!f&&e.type!=="deleted",I=!f&&e.type!=="new",B=E.rowCount>0||O;v=$&&B?v:void 0,_=I&&B?_:void 0,y=f&&B?y:void 0;const j=this.createPreElement(_!=null&&v!=null,L);return{unifiedGutterAST:f&&B?E.unifiedGutterAST.children:void 0,unifiedContentAST:y,deletionsGutterAST:I&&B?E.deletionsGutterAST.children:void 0,deletionsContentAST:_,additionsGutterAST:$&&B?E.additionsGutterAST.children:void 0,additionsContentAST:v,hunkData:w,preNode:j,themeStyles:r,baseThemeType:i,headerElement:a?void 0:this.renderHeader(this.diff),totalLines:L,rowCount:E.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:""}}renderCodeAST(e,t){const n=e==="unified"?t.unifiedGutterAST:e==="deletions"?t.deletionsGutterAST:t.additionsGutterAST,r=e==="unified"?t.unifiedContentAST:e==="deletions"?t.deletionsContentAST:t.additionsContentAST;if(n==null||r==null)return;const i=Wp(n);return i.properties.style=`grid-row: span ${t.rowCount}`,[i,uce(r,t.rowCount)]}renderFullAST(e,t=[]){const n=this.getOptionsWithDefaults().hunkSeparators==="line-info",r=this.renderCodeAST("unified",e);if(r!=null)return t.push(ft({tagName:"code",children:r,properties:{"data-code":"","data-container-size":n?"":void 0,"data-unified":""}})),{...e.preNode,children:t};const i=this.renderCodeAST("deletions",e);i!=null&&t.push(ft({tagName:"code",children:i,properties:{"data-code":"","data-container-size":n?"":void 0,"data-deletions":""}}));const s=this.renderCodeAST("additions",e);return s!=null&&t.push(ft({tagName:"code",children:s,properties:{"data-code":"","data-container-size":n?"":void 0,"data-additions":""}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return Kc(this.renderFullAST(e,t))}renderPartialHTML(e,t){return t==null?Kc(e):Kc(ft({tagName:"code",children:e,properties:{"data-code":"","data-container-size":this.getOptionsWithDefaults().hunkSeparators==="line-info"?"":void 0,[`data-${t}`]:""}}))}getAnnotations(e,t,n,r,i){const s={type:"annotation",hunkIndex:r,lineIndex:i,annotations:[]};if(t!=null)for(const l of this.deletionAnnotations[t]??[])s.annotations.push(xh(l));const a={type:"annotation",hunkIndex:r,lineIndex:i,annotations:[]};if(n!=null)for(const l of this.additionAnnotations[n]??[])(e==="unified"?s:a).annotations.push(xh(l));if(e==="unified")return s.annotations.length>0?s:void 0;if(!(a.annotations.length===0&&s.annotations.length===0))return{deletionSpan:s,additionSpan:a}}renderHeader(e){const{headerRenderMode:t}=this.getOptionsWithDefaults();return hce({fileOrDiff:e,mode:t})}};function IN(e){return`${e} unmodified line${e>1?"s":""}`}function jN(e,t){for(const n of e)t.unifiedContentAST.push(n.content),t.pushToGutter("unified",n.gutter),t.incrementRowCount(1)}function zN(e,t,n){for(const{deletion:r,addition:i}of e){if(r==null&&i==null)continue;const s=r!=null&&i!=null?void 0:r==null?"deletions":"additions";(s==null||n.side!==s)&&n.flush(),r!=null&&(t.deletionsContentAST.push(r.content),t.pushToGutter("deletions",r.gutter)),i!=null&&(t.additionsContentAST.push(i.content),t.pushToGutter("additions",i.gutter)),s!=null&&(n.side=s,n.increment()),t.incrementRowCount(1)}}function BN({diffStyle:e,type:t,deletionLine:n,additionLine:r,unifiedSpan:i,deletionSpan:s,additionSpan:a,createAnnotationElement:l,context:u}){let d=!1;if(e==="unified"){if(r!=null?u.unifiedContentAST.push(r):n!=null&&u.unifiedContentAST.push(n),i!=null){const p=t==="change"?n!=null?"change-deletion":"change-addition":t;u.unifiedContentAST.push(l(i)),u.pushToGutter("unified",Gi(p,"annotation",1)),d=!0}}else if(e==="split"){if(n!=null&&u.deletionsContentAST.push(n),r!=null&&u.additionsContentAST.push(r),s!=null){const p=t==="change"?n!=null?"change-deletion":"context":t;u.deletionsContentAST.push(l(s)),u.pushToGutter("deletions",Gi(p,"annotation",1)),d=!0}if(a!=null){const p=t==="change"?r!=null?"change-addition":"context":t;u.additionsContentAST.push(l(a)),u.pushToGutter("additions",Gi(p,"annotation",1)),d=!0}}d&&u.incrementRowCount(1)}function py(e,{hunkIndex:t,collapsedLines:n,rangeSize:r,hunkSpecs:i,isFirstHunk:s,isLastHunk:a,isExpandable:l},u){if(n<=0)return;const d=e==="unified"?u.unifiedContentAST:e==="deletions"?u.deletionsContentAST:u.additionsContentAST;if(u.hunkSeparators==="metadata"){i!=null&&(u.pushToGutter(e,kc({type:"metadata",content:i,isFirstHunk:s,isLastHunk:a})),d.push(kc({type:"metadata",content:i,isFirstHunk:s,isLastHunk:a})),e!=="additions"&&u.incrementRowCount(1));return}if(u.hunkSeparators==="simple"){t>0&&(u.pushToGutter(e,kc({type:"simple",isFirstHunk:s,isLastHunk:!1})),d.push(kc({type:"simple",isFirstHunk:s,isLastHunk:!1})),e!=="additions"&&u.incrementRowCount(1));return}const p=Hce(e,t),f=r>u.expansionLineCount,v=l?t:void 0;u.pushToGutter(e,kc({type:u.hunkSeparators,content:IN(n),expandIndex:v,chunked:f,slotName:p,isFirstHunk:s,isLastHunk:a})),d.push(kc({type:u.hunkSeparators,content:IN(n),expandIndex:v,chunked:f,slotName:p,isFirstHunk:s,isLastHunk:a})),e!=="additions"&&u.incrementRowCount(1),u.hunkData.push({slotName:p,hunkIndex:t,lines:n,type:e,expandable:l?{up:!s,down:!a,chunked:f}:void 0})}function Xp(e,t){return e==null||e.type!=="element"||t==null?e:{...e,properties:{...e.properties,...t}}}function Wce(e){const t=e.hunks.at(-1);if(t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return 0;const n=e.additionLines.length-(t.additionLineIndex+t.additionCount),r=e.deletionLines.length-(t.deletionLineIndex+t.deletionCount);if(n!==r)throw new Error(`DiffHunksRenderer.processDiffResult: trailing context mismatch (additions=${n}, deletions=${r}) for ${e.name}`);return Math.min(n,r)}function Gce(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function qce(e,t){var n,r,i,s,a,l;return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.type===t.type&&((n=e.expandable)==null?void 0:n.chunked)===((r=t.expandable)==null?void 0:r.chunked)&&((i=e.expandable)==null?void 0:i.up)===((s=t.expandable)==null?void 0:s.up)&&((a=e.expandable)==null?void 0:a.down)===((l=t.expandable)==null?void 0:l.down)}function Kce(e){const t=e[0];if(t!=="+"&&t!=="-"&&t!==" "&&t!=="\\"){console.error(`parseLineType: Invalid firstChar: "${t}", full line: "${e}"`);return}const n=e.substring(1);return{line:n===""?`
|
|
2488
2488
|
`:n,type:t===" "?"context":t==="\\"?"metadata":t==="+"?"addition":"deletion"}}function Yce(e,t,n=!1){const r=Cm.test(e),i=e.split(r?Cm:NA);let s;const a=[];for(const l of i){if(r&&!Cm.test(l)){if(s==null)s=l;else{if(n)throw Error("parsePatchContent: unknown file blob");console.error("parsePatchContent: unknown file blob:",l)}continue}else if(!r&&!NA.test(l)){if(s==null)s=l;else{if(n)throw Error("parsePatchContent: unknown file blob");console.error("parsePatchContent: unknown file blob:",l)}continue}const u=tj(l,{cacheKey:void 0,isGitDiff:r,throwOnError:n});u!=null&&a.push(u)}return{patchMetadata:s,files:a}}function tj(e,{cacheKey:t,isGitDiff:n=Cm.test(e),oldFile:r,newFile:i,throwOnError:s=!1}={}){let a=0;const l=e.split(_re);let u;const d=r==null||i==null;let p=0,f=0;for(const v of l){const _=v.split(V0),y=_.shift();if(y==null){if(s)throw Error("parsePatchContent: invalid hunk");console.error("parsePatchContent: invalid hunk",v);continue}const w=y.match(bre);let k=0,C=0;if(w==null||u==null){if(u!=null){if(s)throw Error("parsePatchContent: Invalid hunk");console.error("parsePatchContent: Invalid hunk",v);continue}u={name:"",type:"change",hunks:[],splitLineCount:0,unifiedLineCount:0,isPartial:d,additionLines:!d&&r!=null&&i!=null?i.contents.split(V0):[],deletionLines:!d&&r!=null&&i!=null?r.contents.split(V0):[],cacheKey:t},u.additionLines.length===1&&(i==null?void 0:i.contents)===""&&(u.additionLines.length=0),u.deletionLines.length===1&&(r==null?void 0:r.contents)===""&&(u.deletionLines.length=0),_.unshift(y);for(const L of _){const O=L.match(n?xre:yre);if(L.startsWith("diff --git")){const[,,$,,I]=L.trim().match(wre)??[];u.name=I.trim(),$!==I&&(u.prevName=$.trim())}else if(O!=null){const[,$,I]=O;$==="---"&&I!=="/dev/null"?(u.prevName=I.trim(),u.name=I.trim()):$==="+++"&&I!=="/dev/null"&&(u.name=I.trim())}else if(n){if(L.startsWith("new mode ")&&(u.mode=L.replace("new mode","").trim()),L.startsWith("old mode ")&&(u.prevMode=L.replace("old mode","").trim()),L.startsWith("new file mode")&&(u.type="new",u.mode=L.replace("new file mode","").trim()),L.startsWith("deleted file mode")&&(u.type="deleted",u.mode=L.replace("deleted file mode","").trim()),L.startsWith("similarity index")&&(L.startsWith("similarity index 100%")?u.type="rename-pure":u.type="rename-changed"),L.startsWith("index ")){const[,$,I,B]=L.trim().match(Sre)??[];$!=null&&(u.prevObjectId=$),I!=null&&(u.newObjectId=I),B!=null&&(u.mode=B)}L.startsWith("rename from ")&&(u.prevName=L.replace("rename from ","").trim()),L.startsWith("rename to ")&&(u.name=L.replace("rename to ","").trim())}}continue}let E,R;for(;_.length>0&&(_[_.length-1]===`
|
|
2489
2489
|
`||_[_.length-1]==="\r"||_[_.length-1]===`\r
|
|
2490
|
-
`||_[_.length-1]==="");)_.pop();const T=parseInt(w[3]),N=parseInt(w[1]);p=d?p:N-1,f=d?f:T-1;const M={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:parseInt(w[4]??"1"),additionStart:T,additionLines:k,deletionCount:parseInt(w[2]??"1"),deletionStart:N,deletionLines:C,deletionLineIndex:p,additionLineIndex:f,hunkContent:[],hunkContext:w[5],hunkSpecs:y,noEOFCRAdditions:!1,noEOFCRDeletions:!1};if(isNaN(M.additionCount)||isNaN(M.deletionCount)||isNaN(M.additionStart)||isNaN(M.deletionStart)){if(s)throw Error("parsePatchContent: invalid hunk metadata");console.error("parsePatchContent: invalid hunk metadata",M);continue}for(const L of _){const O=Kce(L);if(O==null){console.error("processFile: invalid rawLine:",L);continue}const{type:$,line:I}=O;if($==="addition")(E==null||E.type!=="change")&&(E=my("change",p,f),M.hunkContent.push(E)),f++,d&&u.additionLines.push(I),E.additions++,k++,R="addition";else if($==="deletion")(E==null||E.type!=="change")&&(E=my("change",p,f),M.hunkContent.push(E)),p++,d&&u.deletionLines.push(I),E.deletions++,C++,R="deletion";else if($==="context")(E==null||E.type!=="context")&&(E=my("context",p,f),M.hunkContent.push(E)),f++,p++,d&&(u.deletionLines.push(I),u.additionLines.push(I)),E.lines++,R="context";else if($==="metadata"&&E!=null){if(E.type==="context"?(M.noEOFCRAdditions=!0,M.noEOFCRDeletions=!0):R==="deletion"?M.noEOFCRDeletions=!0:R==="addition"&&(M.noEOFCRAdditions=!0),d&&(R==="addition"||R==="context")){const B=u.additionLines.length-1;B>=0&&(u.additionLines[B]=iu(u.additionLines[B]))}if(d&&(R==="deletion"||R==="context")){const B=u.deletionLines.length-1;B>=0&&(u.deletionLines[B]=iu(u.deletionLines[B]))}}}M.additionLines=k,M.deletionLines=C,M.collapsedBefore=Math.max(M.additionStart-1-a,0),u.hunks.push(M),a=M.additionStart+M.additionCount-1;for(const L of M.hunkContent)L.type==="context"?(M.splitLineCount+=L.lines,M.unifiedLineCount+=L.lines):(M.splitLineCount+=Math.max(L.additions,L.deletions),M.unifiedLineCount+=L.deletions+L.additions);M.splitLineStart=u.splitLineCount+M.collapsedBefore,M.unifiedLineStart=u.unifiedLineCount+M.collapsedBefore,u.splitLineCount+=M.collapsedBefore+M.splitLineCount,u.unifiedLineCount+=M.collapsedBefore+M.unifiedLineCount}if(u!=null){if(u.hunks.length>0&&!d&&u.additionLines.length>0&&u.deletionLines.length>0){const v=u.hunks[u.hunks.length-1],_=v.additionStart+v.additionCount-1,y=u.additionLines.length,w=Math.max(y-_,0);u.splitLineCount+=w,u.unifiedLineCount+=w}return n||(u.prevName!=null&&u.name!==u.prevName?u.hunks.length>0?u.type="rename-changed":u.type="rename-pure":i!=null&&i.contents===""?u.type="deleted":r!=null&&r.contents===""&&(u.type="new")),u.type!=="rename-pure"&&u.type!=="rename-changed"&&(u.prevName=void 0),u}}function Xce(e,t,n=!1){const r=[];for(const i of e.split(vre))try{r.push(Yce(i,t!=null?`${t}-${r.length}`:void 0,n))}catch(s){if(n)throw s;console.error(s)}return r}function my(e,t,n){return e==="change"?{type:"change",additions:0,deletions:0,additionLineIndex:n,deletionLineIndex:t}:{type:"context",lines:0,additionLineIndex:n,deletionLineIndex:t}}function Yx(e,t,n,r=!1){const i=tj(Gle(e.name,t.name,e.contents,t.contents,e.header,t.header,n),{cacheKey:(()=>{if(e.cacheKey!=null&&t.cacheKey!=null)return`${e.cacheKey}:${t.cacheKey}`})(),oldFile:e,newFile:t,throwOnError:r});if(i==null)throw new Error("parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?");return t.lang!=null&&(i.lang=t.lang),i}let Qce=-1;var $y,nj=($y=class{constructor(e={theme:xs},t,n=!1){Y(this,"__id",`file-diff:${++Qce}`);Y(this,"fileContainer");Y(this,"spriteSVG");Y(this,"pre");Y(this,"codeUnified");Y(this,"codeDeletions");Y(this,"codeAdditions");Y(this,"bufferBefore");Y(this,"bufferAfter");Y(this,"themeCSSStyle");Y(this,"appliedThemeCSS");Y(this,"unsafeCSSStyle");Y(this,"appliedUnsafeCSS");Y(this,"gutterUtilityContent");Y(this,"headerElement");Y(this,"headerPrefix");Y(this,"headerMetadata");Y(this,"headerCustom");Y(this,"separatorCache",new Map);Y(this,"errorWrapper");Y(this,"placeHolder");Y(this,"hunksRenderer");Y(this,"resizeManager");Y(this,"scrollSyncManager");Y(this,"interactionManager");Y(this,"annotationCache",new Map);Y(this,"lineAnnotations",[]);Y(this,"deletionFile");Y(this,"additionFile");Y(this,"fileDiff");Y(this,"renderRange");Y(this,"appliedPreAttributes");Y(this,"lastRenderedHeaderHTML");Y(this,"lastRowCount");Y(this,"enabled",!0);Y(this,"handleHighlightRender",()=>{this.rerender()});Y(this,"getLineIndex",(e,t="additions")=>{if(this.fileDiff==null)return;const n=this.fileDiff.hunks.at(-1);let r,i;e:for(const s of this.fileDiff.hunks){let a=t==="deletions"?s.deletionStart:s.additionStart;const l=t==="deletions"?s.deletionCount:s.additionCount;let u=s.splitLineStart,d=s.unifiedLineStart;if(e<a){const p=a-e;r=Math.max(d-p,0),i=Math.max(u-p,0);break e}if(e>=a+l){if(s===n){const p=e-(a+l);r=d+s.unifiedLineCount+p,i=u+s.splitLineCount+p;break e}continue}for(const p of s.hunkContent)if(p.type==="context")if(e<a+p.lines){const f=e-a;i=u+f,r=d+f;break e}else a+=p.lines,u+=p.lines,d+=p.lines;else{const f=t==="deletions"?p.deletions:p.additions;if(e<a+f){const v=e-a;r=d+(t==="additions"?p.deletions:0)+v,i=u+v;break e}else a+=f,u+=Math.max(p.deletions,p.additions),d+=p.deletions+p.additions}break e}if(!(r==null||i==null))return[r,i]});Y(this,"getHoveredLine",()=>this.interactionManager.getHoveredLine());Y(this,"handleExpandHunk",(e,t,n)=>{this.expandHunk(e,t,n)});Y(this,"expandHunk",(e,t,n)=>{this.hunksRenderer.expandHunk(e,t,n),this.rerender()});var r;this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new lce,this.scrollSyncManager=new Bce,this.interactionManager=new rce("diff",RN(e,typeof e.hunkSeparators=="function"||(e.hunkSeparators??"line-info")==="line-info"||e.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex)),(r=this.workerManager)==null||r.subscribeToThemeChanges(this),this.enabled=!0}getHunksRendererOptions(e){return{...e,headerRenderMode:e.renderCustomHeader!=null?"custom":"default",hunkSeparators:typeof e.hunkSeparators=="function"?"custom":e.hunkSeparators}}createHunksRenderer(e){return new Vce(this.getHunksRendererOptions(e),this.handleHighlightRender,this.workerManager)}setOptions(e){e!=null&&(this.options=e,this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.interactionManager.setOptions(RN(e,typeof e.hunkSeparators=="function"||(e.hunkSeparators??"line-info")==="line-info"||e.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex)))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??"system")!==e&&(this.mergeOptions({themeType:e}),!(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)&&this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType))}setLineAnnotations(e){this.lineAnnotations=e}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators=="function")}setSelectedLines(e){this.interactionManager.setSelection(e)}cleanUp(e=!1){var t,n,r;this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),(t=this.workerManager)==null||t.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||(n=this.fileContainer)==null||n.remove(),((r=this.fileContainer)==null?void 0:r.shadowRoot)!=null&&(this.fileContainer.shadowRoot.innerHTML=""),this.fileContainer=void 0,this.pre!=null&&(this.pre.innerHTML="",this.pre=void 0),this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore=void 0,this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.enabled=!1}virtualizedSetup(){var e;this.enabled=!0,(e=this.workerManager)==null||e.subscribeToThemeChanges(this)}hydrate(e){const{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,lineAnnotations:i,oldFile:s,newFile:a,fileDiff:l}=e;this.hydrateElements(t,n),this.pre==null&&this.headerElement==null?this.render({...e,preventEmit:!0}):this.hydrationSetup({fileDiff:l,oldFile:s,newFile:a,lineAnnotations:i}),r||this.emitPostRender()}hydrateElements(e,t){var n;Nce(e,t);for(const r of((n=e.shadowRoot)==null?void 0:n.children)??[]){if(r instanceof SVGElement){this.spriteSVG=r;continue}if(r instanceof HTMLElement){if(r instanceof HTMLPreElement){this.pre=r;for(const i of r.children)!(i instanceof HTMLElement)||i.tagName.toLowerCase()!=="code"||("deletions"in i.dataset&&(this.codeDeletions=i),"additions"in i.dataset&&(this.codeAdditions=i),"unified"in i.dataset&&(this.codeUnified=i));continue}if("diffsHeader"in r.dataset){this.headerElement=r;continue}if(r instanceof HTMLStyleElement&&r.hasAttribute(F3)){this.themeCSSStyle=r;continue}if(r instanceof HTMLStyleElement&&r.hasAttribute(U3)){this.unsafeCSSStyle=r,this.appliedUnsafeCSS=r.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),(this.pre!=null||this.headerElement!=null)&&(this.fileContainer=e)}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:r}){const{diffStyle:i="split",overflow:s="scroll"}=this.options;this.lineAnnotations=r??this.lineAnnotations,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!=null&&n!=null?Yx(t,n,this.options.parseDiffOptions):void 0),this.pre!=null&&(this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,s==="wrap"),s==="scroll"&&i==="split"&&this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions))}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({forceRender:!0,renderRange:this.renderRange})}render({oldFile:e,newFile:t,fileDiff:n,forceRender:r=!1,preventEmit:i=!1,lineAnnotations:s,fileContainer:a,containerWrapper:l,renderRange:u}){var T;if(!this.enabled)throw new Error("FileDiff.render: attempting to call render after cleaned up");const{collapsed:d=!1}=this.options,p=d?void 0:u,f=e!=null&&t!=null&&(!yN(e,this.deletionFile)||!yN(t,this.additionFile));let v=n!=null&&n!==this.fileDiff;const _=s!=null&&(s.length>0||this.lineAnnotations.length>0)?s!==this.lineAnnotations:!1;if(!d&&JI(p,this.renderRange)&&!r&&!_&&(n!=null&&n===this.fileDiff||n==null&&!f))return!1;const{renderRange:y}=this;if(this.renderRange=p,this.deletionFile=e,this.additionFile=t,n!=null?this.fileDiff=n:e!=null&&t!=null&&f&&(v=!0,this.fileDiff=Yx(e,t,this.options.parseDiffOptions)),s!=null&&this.setLineAnnotations(s),this.fileDiff==null)return!1;this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.hunksRenderer.setLineAnnotations(this.lineAnnotations);const{diffStyle:w="split",disableErrorHandling:k=!1,disableFileHeader:C=!1,overflow:E="scroll",themeType:R="system"}=this.options;if(C&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),a=this.getOrCreateFileContainer(a,l),d){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const N=this.hunksRenderer.renderDiff(this.fileDiff,Ere);N!=null&&this.applyThemeState(a,N.themeStyles,R,N.baseThemeType),(N==null?void 0:N.headerElement)!=null&&this.applyHeaderToDOM(N.headerElement,a),this.renderSeparators([]),this.injectUnsafeCSS()}catch(N){if(k)throw N;console.error(N),N instanceof Error&&this.applyErrorToDOM(N,a)}return i||this.emitPostRender(),!0}try{const N=this.getOrCreatePreNode(a);if(!(this.canPartiallyRender(r,_,f||v)&&this.applyPartialRender({previousRenderRange:y,renderRange:p}))){const M=this.hunksRenderer.renderDiff(this.fileDiff,p);if(M==null)return((T=this.workerManager)==null?void 0:T.isInitialized())===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(a,M.themeStyles,R,M.baseThemeType),M.headerElement!=null&&this.applyHeaderToDOM(M.headerElement,a),M.additionsContentAST!=null||M.deletionsContentAST!=null||M.unifiedContentAST!=null?this.applyHunksToDOM(N,M):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(M.hunkData)}this.applyBuffers(N,p),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.interactionManager.setup(N),this.resizeManager.setup(N,E==="wrap"),E==="scroll"&&w==="split"?this.scrollSyncManager.setup(N,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp()}catch(N){if(k)throw N;console.error(N),N instanceof Error&&this.applyErrorToDOM(N,a)}return i||this.emitPostRender(),!0}emitPostRender(){var e,t;this.fileContainer!=null&&((t=(e=this.options).onPostRender)==null||t.call(e,this.fileContainer,this))}removeRenderedCode(){var e,t,n,r,i,s;this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),(e=this.bufferBefore)==null||e.remove(),this.bufferBefore=void 0,(t=this.bufferAfter)==null||t.remove(),this.bufferAfter=void 0,(n=this.codeUnified)==null||n.remove(),this.codeUnified=void 0,(r=this.codeDeletions)==null||r.remove(),this.codeDeletions=void 0,(i=this.codeAdditions)==null||i.remove(),this.codeAdditions=void 0,(s=this.pre)==null||s.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){var e;for(const{element:t}of this.separatorCache.values())t.remove();this.separatorCache.clear();for(const{element:t}of this.annotationCache.values())t.remove();this.annotationCache.clear(),(e=this.gutterUtilityContent)==null||e.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.cleanChildNodes(),this.placeHolder==null){const t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}cleanChildNodes(){var e,t,n,r,i,s,a,l,u,d,p,f,v,_,y;this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),(e=this.bufferAfter)==null||e.remove(),(t=this.bufferBefore)==null||t.remove(),(n=this.codeAdditions)==null||n.remove(),(r=this.codeDeletions)==null||r.remove(),(i=this.codeUnified)==null||i.remove(),(s=this.errorWrapper)==null||s.remove(),(a=this.headerElement)==null||a.remove(),(l=this.gutterUtilityContent)==null||l.remove(),(u=this.headerPrefix)==null||u.remove(),(d=this.headerMetadata)==null||d.remove(),(p=this.headerCustom)==null||p.remove(),(f=this.pre)==null||f.remove(),(v=this.spriteSVG)==null||v.remove(),(_=this.themeCSSStyle)==null||_.remove(),(y=this.unsafeCSSStyle)==null||y.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.gutterUtilityContent=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0}renderSeparators(e){const{hunkSeparators:t}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof t!="function"){for(const{element:r}of this.separatorCache.values())r.remove();this.separatorCache.clear();return}const n=new Map(this.separatorCache);for(const r of e){const i=r.slotName;let s=this.separatorCache.get(i);if(s==null||!qce(r,s.hunkData)){s==null||s.element.remove();const a=document.createElement("div");a.style.display="contents",a.slot=r.slotName;const l=t(r,this);l!=null&&a.appendChild(l),this.fileContainer.appendChild(a),s={element:a,hunkData:r},this.separatorCache.set(i,s)}n.delete(i)}for(const[r,{element:i}]of n.entries())this.separatorCache.delete(r),i.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(const{element:n}of this.annotationCache.values())n.remove();this.annotationCache.clear();return}const e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(const[n,r]of this.lineAnnotations.entries()){const i=`${n}-${xh(r)}`;let s=this.annotationCache.get(i);if(s==null||!Gce(r,s.annotation)){s==null||s.element.remove();const a=t(r);if(a==null)continue;s={element:wce(xh(r)),annotation:r},s.element.appendChild(a),this.fileContainer.appendChild(s.element),this.annotationCache.set(i,s)}e.delete(i)}for(const[n,{element:r}]of e.entries())this.annotationCache.delete(n),r.remove()}renderGutterUtility(){var r,i;const e=this.options.renderGutterUtility??this.options.renderHoverUtility;if(this.fileContainer==null||e==null){(r=this.gutterUtilityContent)==null||r.remove(),this.gutterUtilityContent=void 0;return}const t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){(i=this.gutterUtilityContent)==null||i.remove(),this.gutterUtilityContent=void 0;return}const n=Sce();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){var r;const n=this.fileContainer;if(this.fileContainer=e??this.fileContainer??document.createElement(dg),n!=null&&n!==this.fileContainer&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),this.spriteSVG==null){const i=document.createElement("div");i.innerHTML=bce;const s=i.firstChild;s instanceof SVGElement&&(this.spriteSVG=s,(r=this.fileContainer.shadowRoot)==null||r.appendChild(this.spriteSVG))}return this.fileContainer}getFileContainer(){return this.fileContainer}getOrCreatePreNode(e){var n;const t=e.shadowRoot??e.attachShadow({mode:"open"});return this.pre==null?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(t.appendChild(this.pre),this.appliedPreAttributes=void 0),(n=this.placeHolder)==null||n.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(const t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute("data-unified")?this.codeUnified=t:t.hasAttribute("data-deletions")?this.codeDeletions=t:t.hasAttribute("data-additions")&&(this.codeAdditions=t))}applyHeaderToDOM(e,t){var d,p,f,v,_,y;this.cleanupErrorWrapper(),(d=this.placeHolder)==null||d.remove(),this.placeHolder=void 0;const{fileDiff:n}=this,r=Kc(e);if(r!==this.lastRenderedHeaderHTML){const w=document.createElement("div");w.innerHTML=r;const k=w.firstElementChild;if(!(k instanceof HTMLElement))return;this.headerElement!=null?(p=t.shadowRoot)==null||p.replaceChild(k,this.headerElement):(f=t.shadowRoot)==null||f.prepend(k),this.headerElement=k,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged||n==null)return;const{renderCustomHeader:i,renderHeaderPrefix:s,renderHeaderMetadata:a}=this.options;if(i!=null){const w=i(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,TS,w),(v=this.headerPrefix)==null||v.remove(),(_=this.headerMetadata)==null||_.remove(),this.headerPrefix=void 0,this.headerMetadata=void 0;return}const l=(s==null?void 0:s(n))??void 0,u=(a==null?void 0:a(n))??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,ES,l),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,RS,u),(y=this.headerCustom)==null||y.remove(),this.headerCustom=void 0}clearHeaderSlots(){var e,t,n;(e=this.headerPrefix)==null||e.remove(),(t=this.headerMetadata)==null||t.remove(),(n=this.headerCustom)==null||n.remove(),this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t==null||t.remove();return}const i=t??this.createHeaderSlotElement(n);return t==null&&e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){const t=document.createElement("div");return t.slot=e,t}injectUnsafeCSS(){var n,r;const{unsafeCSS:e}=this.options,t=(n=this.fileContainer)==null?void 0:n.shadowRoot;if(t!=null){if(e==null||e===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}((r=this.unsafeCSSStyle)==null?void 0:r.parentNode)===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??(this.unsafeCSSStyle=Cce()),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=Ece(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){var a,l;const i=e.shadowRoot??e.attachShadow({mode:"open"}),s=r??n;((a=this.themeCSSStyle)==null?void 0:a.parentNode)===i&&((l=this.appliedThemeCSS)==null?void 0:l.themeStyles)===t&&this.appliedThemeCSS.themeType===s||(this.themeCSSStyle=Tce({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:Rce(t,s)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{themeStyles:t,themeType:s,baseThemeType:r}:void 0)}applyHunksToDOM(e,t){var p,f,v,_,y,w,k,C,E;const{overflow:n="scroll"}=this.options,r=(this.options.hunkSeparators??"line-info")==="line-info",i=n==="wrap"?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let s=!1;const a=[],l=this.hunksRenderer.renderCodeAST("unified",t),u=this.hunksRenderer.renderCodeAST("deletions",t),d=this.hunksRenderer.renderCodeAST("additions",t);l!=null?(s=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,(p=this.codeDeletions)==null||p.remove(),this.codeDeletions=void 0,(f=this.codeAdditions)==null||f.remove(),this.codeAdditions=void 0,this.codeUnified=hy({code:this.codeUnified,columnType:"unified",rowSpan:i,containerSize:r}),this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(l),a.push(this.codeUnified)):u!=null||d!=null?(u!=null?(s=this.codeDeletions==null||this.codeUnified!=null,(v=this.codeUnified)==null||v.remove(),this.codeUnified=void 0,this.codeDeletions=hy({code:this.codeDeletions,columnType:"deletions",rowSpan:i,containerSize:r}),this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(u),a.push(this.codeDeletions)):((_=this.codeDeletions)==null||_.remove(),this.codeDeletions=void 0),d!=null?(s=s||this.codeAdditions==null||this.codeUnified!=null,(y=this.codeUnified)==null||y.remove(),this.codeUnified=void 0,this.codeAdditions=hy({code:this.codeAdditions,columnType:"additions",rowSpan:i,containerSize:r}),this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(d),a.push(this.codeAdditions)):((w=this.codeAdditions)==null||w.remove(),this.codeAdditions=void 0)):((k=this.codeUnified)==null||k.remove(),this.codeUnified=void 0,(C=this.codeDeletions)==null||C.remove(),this.codeDeletions=void 0,(E=this.codeAdditions)==null||E.remove(),this.codeAdditions=void 0),a.length===0?e.textContent="":s&&e.replaceChildren(...a),this.lastRowCount=t.rowCount}applyPartialRender({previousRenderRange:e,renderRange:t}){const{pre:n,codeUnified:r,codeAdditions:i,codeDeletions:s,options:{diffStyle:a="split"}}=this;if(n==null||e==null||t==null||!Number.isFinite(e.totalLines)||!Number.isFinite(t.totalLines)||this.lastRowCount==null)return!1;const l=this.getCodeColumns(a,r,s,i);if(l==null)return!1;const u=e.startingLine,d=t.startingLine,p=u+e.totalLines,f=d+t.totalLines,v=Math.max(u,d),_=Math.min(p,f);if(_<=v)return!1;const y=Math.max(0,v-u),w=Math.max(0,p-_),k=this.trimColumns({columns:l,trimStart:y,trimEnd:w,previousStart:u,overlapStart:v,overlapEnd:_,diffStyle:a});if(k<0)throw new Error("applyPartialRender: failed to trim to overlap");if(this.lastRowCount<k)throw new Error("applyPartialRender: trimmed beyond DOM row count");let C=this.lastRowCount-k;const E=(M,L)=>{if(!(L<=0||this.fileDiff==null))return this.hunksRenderer.renderDiff(this.fileDiff,{startingLine:M,totalLines:L,bufferBefore:0,bufferAfter:0})},R=E(d,Math.max(v-d,0));if(R==null&&d<v)return!1;const T=E(_,Math.max(f-_,0));if(T==null&&f>_)return!1;const N=(M,L)=>{if(M!=null){if(a==="unified"&&!Array.isArray(l))this.insertPartialHTML(a,l,M,L);else if(a==="split"&&Array.isArray(l))this.insertPartialHTML(a,l,M,L);else throw new Error("FileDiff.applyPartialRender.applyChunk: invalid chunk application");C+=M.rowCount}};return this.cleanupErrorWrapper(),N(R,"afterbegin"),N(T,"beforeend"),this.lastRowCount!==C&&(this.applyRowSpan(a,l,C),this.lastRowCount=C),!0}insertPartialHTML(e,t,n,r){if(e==="unified"&&!Array.isArray(t)){const i=this.hunksRenderer.renderCodeAST("unified",n);this.renderPartialColumn(t,i,r)}else if(e==="split"&&Array.isArray(t)){const i=this.hunksRenderer.renderCodeAST("deletions",n),s=this.hunksRenderer.renderCodeAST("additions",n);this.renderPartialColumn(t[0],i,r),this.renderPartialColumn(t[1],s,r)}else throw new Error("FileDiff.insertPartialHTML: Invalid argument composition")}renderPartialColumn(e,t,n){if(e==null||t==null)return;const r=HN(t[0]),i=HN(t[1]);if(r==null||i==null)throw new Error("FileDiff.insertPartialHTML: Unexpected AST structure");const s=i.at(0);n==="beforeend"&&(s==null?void 0:s.type)==="element"&&typeof s.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(s.properties["data-buffer-size"],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);const a=i.at(-1);n==="afterbegin"&&(a==null?void 0:a.type)==="element"&&typeof a.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(a.properties["data-buffer-size"],e.content.children[0],e.gutter.children[0],r,i,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,s){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;const a=this.getBufferSize(t.dataset);a!=null&&(s?(r.shift(),i.shift()):(r.pop(),i.pop()),this.updateBufferSize(t,a+e),this.updateBufferSize(n,a+e))}applyRowSpan(e,t,n){const r=i=>{i!=null&&(i.gutter.style.setProperty("grid-row",`span ${n}`),i.content.style.setProperty("grid-row",`span ${n}`))};if(e==="unified"&&!Array.isArray(t))r(t);else if(e==="split"&&Array.isArray(t))r(t[0]),r(t[1]);else throw new Error("dun fuuuuked up")}trimColumnRows(e,t,n){let r=0,i=0,s=0,a=!1;const l=n>=0;if(e==null)return 0;const u=Array.from(e.content.children),d=Array.from(e.gutter.children);if(u.length!==d.length)throw new Error("FileDiff.trimColumnRows: columns do not match");for(;s<u.length&&!(t<=0&&!l&&!a);){const p=d[s],f=u[s];if(s++,!(p instanceof HTMLElement)||!(f instanceof HTMLElement))throw console.error({gutterElement:p,contentElement:f}),new Error("FileDiff.trimColumnRows: invalid row elements");if(a&&(a=!1,p.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in f.dataset||p.dataset.gutterBuffer==="metadata"&&"noNewline"in f.dataset)){p.remove(),f.remove(),i++;continue}if("lineIndex"in p.dataset&&"lineIndex"in f.dataset){(t>0||l&&r>=n)&&(p.remove(),f.remove(),t>0&&(t--,t===0&&(a=!0)),i++),r++;continue}if("separator"in p.dataset&&"separator"in f.dataset){(t>0||l&&r>=n)&&(p.remove(),f.remove(),i++);continue}if(p.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in f.dataset){(t>0||l&&r>=n)&&(p.remove(),f.remove(),i++);continue}if(p.dataset.gutterBuffer==="metadata"&&"noNewline"in f.dataset){(t>0||l&&r>=n)&&(p.remove(),f.remove(),i++);continue}if(p.dataset.gutterBuffer==="buffer"&&"contentBuffer"in f.dataset){const v=this.getBufferSize(f.dataset);if(v==null)throw new Error("FileDiff.trimColumnRows: invalid element");if(t>0){const _=Math.min(t,v),y=v-_;y>0?(this.updateBufferSize(p,y),this.updateBufferSize(f,y),i+=_):(p.remove(),f.remove(),i+=v),t-=_}else if(l){const _=r,y=r+v-1;if(n<=_)p.remove(),f.remove(),i+=v;else if(n<=y){const w=y-n+1,k=v-w;this.updateBufferSize(p,k),this.updateBufferSize(f,k),i+=w}}r+=v;continue}throw console.error({gutterElement:p,contentElement:f}),new Error("FileDiff.trimColumnRows: unknown row elements")}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:s,trimStart:a}){const l=Math.max(0,r-i),u=n-i;if(u<0)throw new Error("FileDiff.trimColumns: overlap ends before previous");const d=a>0,p=s>0;if(!d&&!p)return 0;const f=d?l:0,v=p?u:-1;if(t==="unified"&&!Array.isArray(e))return this.trimColumnRows(e,f,v);if(t==="split"&&Array.isArray(e)){const _=this.trimColumnRows(e[0],f,v),y=this.trimColumnRows(e[1],f,v);if(e[0]!=null&&e[1]!=null&&_!==y)throw new Error("FileDiff.trimColumns: split columns out of sync");return e[0]!=null?_:y}else throw console.error({diffStyle:t,columns:e}),new Error("FileDiff.trimColumns: Invalid columns for diffType")}getBufferSize(e){const t=Number.parseInt((e==null?void 0:e.bufferSize)??"",10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty("grid-row",`span ${t}`),e.style.setProperty("min-height",`calc(${t} * 1lh)`)}getCodeColumns(e,t,n,r){function i(s){if(s==null)return;const a=s.children[0],l=s.children[1];if(!(!(a instanceof HTMLElement)||!(l instanceof HTMLElement)||a.dataset.gutter==null||l.dataset.content==null))return{gutter:a,content:l}}if(e==="unified")return i(t);{const s=i(n),a=i(r);return s!=null||a!=null?[s,a]:void 0}}applyBuffers(e,t){const{disableVirtualizationBuffers:n=!1}=this.options;if(n||t==null){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:r},i){const{diffIndicators:s="bars",disableBackground:a=!1,disableLineNumbers:l=!1,overflow:u="scroll",diffStyle:d="split"}=this.options,p={type:"diff",diffIndicators:s,disableBackground:a,disableLineNumbers:l,overflow:u,split:d==="unified"?!1:t!=null&&n!=null,totalLines:r,customProperties:i};yce(p,this.appliedPreAttributes)||(Mce(e,p),this.appliedPreAttributes=p)}applyErrorToDOM(e,t){this.cleanupErrorWrapper();const n=this.getOrCreatePreNode(t);n.innerHTML="",n.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const r=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??(this.errorWrapper=document.createElement("div")),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.innerHTML="",r.appendChild(this.errorWrapper);const i=document.createElement("div");i.dataset.errorMessage="",i.innerText=e.message,this.errorWrapper.appendChild(i);const s=document.createElement("pre");s.dataset.errorStack="",s.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(s)}cleanupErrorWrapper(){var e;(e=this.errorWrapper)==null||e.remove(),this.errorWrapper=void 0}},Y($y,"LoadedCustomComponent",Lce),$y);function HN(e){if(!(e==null||e.type!=="element"))return e.children??[]}function Zce(e,t){const n={...Cre,...t};return n.hunkSeparatorHeight=Jce(e,t==null?void 0:t.hunkSeparatorHeight),n}function Jce(e,t){if(t!=null)return t;switch(e){case"simple":return 4;case"metadata":case"line-info":case"line-info-basic":case"custom":return 32}}let eue=-1;var tue=class extends nj{constructor(t,n,r,i,s=!1){super(t,i,s);Y(this,"__id",`little-virtualized-file-diff:${++eue}`);Y(this,"top");Y(this,"height",0);Y(this,"metrics");Y(this,"heightCache",new Map);Y(this,"isVisible",!1);Y(this,"virtualizer");Y(this,"onRender",t=>this.fileContainer==null?!1:(t&&(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer)),this.render()));Y(this,"expandHunk",(t,n,r)=>{this.hunksRenderer.expandHunk(t,n,r),this.computeApproximateSize(),this.renderRange=void 0,this.virtualizer.instanceChanged(this)});const{hunkSeparators:a="line-info"}=this.options;this.virtualizer=n,this.metrics=Zce(typeof a=="function"?"custom":a,r)}getLineHeight(t,n=!1){const r=this.heightCache.get(t);if(r!=null)return r;const i=n?2:1;return this.metrics.lineHeight*i}setOptions(t){if(t==null)return;const n=this.options.diffStyle,r=this.options.overflow,i=this.options.collapsed;super.setOptions(t),(n!==this.options.diffStyle||r!==this.options.overflow||i!==this.options.collapsed)&&(this.heightCache.clear(),this.computeApproximateSize(),this.renderRange=void 0),this.virtualizer.instanceChanged(this)}reconcileHeights(){const{overflow:t="scroll"}=this.options;if(this.fileContainer!=null&&(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer)),this.fileContainer==null||this.fileDiff==null){this.height=0;return}if(t==="scroll"&&this.lineAnnotations.length===0&&!this.virtualizer.config.resizeDebugging)return;const n=this.getDiffStyle();let r=!1;const i=n==="split"?[this.codeDeletions,this.codeAdditions]:[this.codeUnified];for(const s of i){if(s==null)continue;const a=s.children[1];if(a instanceof HTMLElement)for(const l of a.children){if(!(l instanceof HTMLElement))continue;const u=l.dataset.lineIndex;if(u==null)continue;const d=rue(u,n);let p=l.getBoundingClientRect().height,f=!1;l.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in l.nextElementSibling.dataset||"noNewline"in l.nextElementSibling.dataset)&&("noNewline"in l.nextElementSibling.dataset&&(f=!0),p+=l.nextElementSibling.getBoundingClientRect().height);const v=this.getLineHeight(d,f);p!==v&&(r=!0,p===this.metrics.lineHeight*(f?2:1)?this.heightCache.delete(d):this.heightCache.set(d,p))}}(r||this.virtualizer.config.resizeDebugging)&&this.computeApproximateSize()}cleanUp(){this.fileContainer!=null&&this.virtualizer.disconnect(this.fileContainer),super.cleanUp()}setVisibility(t){this.fileContainer!=null&&(this.renderRange=void 0,t&&!this.isVisible?(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer),this.isVisible=!0):!t&&this.isVisible&&(this.isVisible=!1,this.rerender()))}computeApproximateSize(){const t=this.height===0;if(this.height=0,this.fileDiff==null)return;const{disableFileHeader:n=!1,expandUnchanged:r=!1,collapsed:i=!1,collapsedContextThreshold:s=Gc,hunkSeparators:a="line-info"}=this.options,{diffHeaderHeight:l,fileGap:u,hunkSeparatorHeight:d}=this.metrics,p=this.getDiffStyle(),f=a!=="simple"&&a!=="metadata"&&a!=="line-info-basic"?u:0;if(n?a!=="simple"&&a!=="metadata"&&(this.height+=u):this.height+=l,!i&&(Cg({diff:this.fileDiff,diffStyle:p,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:s,callback:({hunkIndex:v,collapsedBefore:_,collapsedAfter:y,deletionLine:w,additionLine:k})=>{const C=k!=null?k.splitLineIndex:w.splitLineIndex,E=k!=null?k.unifiedLineIndex:w.unifiedLineIndex,R=((k==null?void 0:k.noEOFCR)??!1)||((w==null?void 0:w.noEOFCR)??!1);_>0&&(v>0&&(this.height+=f),this.height+=d+f),this.height+=this.getLineHeight(p==="split"?C:E,R),y>0&&a!=="simple"&&(this.height+=f+d)}}),this.fileDiff.hunks.length>0&&(this.height+=u),this.fileContainer!=null&&this.virtualizer.config.resizeDebugging&&!t)){const v=this.fileContainer.getBoundingClientRect();v.height!==this.height?console.log("VirtualizedFileDiff.computeApproximateSize: computed height doesnt match",{name:this.fileDiff.name,elementHeight:v.height,computedHeight:this.height}):console.log("VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT")}}render({fileContainer:t,oldFile:n,newFile:r,fileDiff:i,...s}={}){const a=this.fileContainer==null;if(this.fileDiff??(this.fileDiff=i??(n!=null&&r!=null?Yx(n,r,this.options.parseDiffOptions):void 0)),t=this.getOrCreateFileContainer(t),this.fileDiff==null)return console.error("VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data"),!1;if(a?(this.computeApproximateSize(),this.virtualizer.connect(t,this),this.top??(this.top=this.virtualizer.getOffsetInScrollContainer(t)),this.isVisible=this.virtualizer.isInstanceVisible(this.top,this.height)):this.top??(this.top=this.virtualizer.getOffsetInScrollContainer(t)),!this.isVisible)return this.renderPlaceholder(this.height);const l=this.virtualizer.getWindowSpecs(),u=this.computeRenderRangeFromWindow(this.fileDiff,this.top,l);return super.render({fileDiff:this.fileDiff,fileContainer:t,renderRange:u,oldFile:n,newFile:r,...s})}getDiffStyle(){return this.options.diffStyle??"split"}getExpandedRegion(t,n,r){if(r<=0||t)return{fromStart:0,fromEnd:0,collapsedLines:Math.max(r,0),renderAll:!1};const{expandUnchanged:i=!1,collapsedContextThreshold:s=Gc}=this.options;if(i||r<=s)return{fromStart:r,fromEnd:0,collapsedLines:0,renderAll:!0};const a=this.hunksRenderer.getExpandedHunk(n),l=Math.min(Math.max(a.fromStart,0),r),u=Math.min(Math.max(a.fromEnd,0),r),d=l+u,p=d>=r;return{fromStart:l,fromEnd:u,collapsedLines:Math.max(r-d,0),renderAll:p}}getExpandedLineCount(t,n){let r=0;if(t.isPartial){for(const s of t.hunks)r+=n==="split"?s.splitLineCount:s.unifiedLineCount;return r}for(const[s,a]of t.hunks.entries()){const l=n==="split"?a.splitLineCount:a.unifiedLineCount;r+=l;const u=Math.max(a.collapsedBefore,0),{fromStart:d,fromEnd:p,renderAll:f}=this.getExpandedRegion(t.isPartial,s,u);u>0&&(r+=f?u:d+p)}const i=t.hunks.at(-1);if(i!=null&&nue(t)){const s=t.additionLines.length-(i.additionLineIndex+i.additionCount),a=t.deletionLines.length-(i.deletionLineIndex+i.deletionCount);if(i!=null&&s!==a)throw new Error(`VirtualizedFileDiff: trailing context mismatch (additions=${s}, deletions=${a}) for ${t.name}`);const l=Math.min(s,a);if(i!=null&&l>0){const{fromStart:u,renderAll:d}=this.getExpandedRegion(t.isPartial,t.hunks.length,l);r+=d?l:u}}return r}computeRenderRangeFromWindow(t,n,{top:r,bottom:i}){const{disableFileHeader:s=!1,expandUnchanged:a=!1,collapsedContextThreshold:l=Gc,hunkSeparators:u="line-info"}=this.options,{diffHeaderHeight:d,fileGap:p,hunkLineCount:f,hunkSeparatorHeight:v,lineHeight:_}=this.metrics,y=this.getDiffStyle(),w=this.height,k=this.getExpandedLineCount(t,y),C=s?p:d;if(n<r-w||n>i)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:w-C-p};if(k<=f||t.hunks.length===0)return{startingLine:0,totalLines:f,bufferBefore:0,bufferAfter:0};const E=Math.ceil(Math.max(i-r,0)/_),R=Math.ceil(E/f)*f+f,T=R/f,N=T,M=[],L=(r+i)/2,O=u==="simple"||u==="metadata"||u==="line-info-basic"?0:p;let $=n+C,I=0,B,j,V;if(Cg({diff:t,diffStyle:y,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:l,callback:({hunkIndex:Z,collapsedBefore:z,collapsedAfter:oe,deletionLine:ue,additionLine:ne})=>{const de=ne!=null?ne.splitLineIndex:ue.splitLineIndex,be=ne!=null?ne.unifiedLineIndex:ue.unifiedLineIndex,re=((ne==null?void 0:ne.noEOFCR)??!1)||((ue==null?void 0:ue.noEOFCR)??!1);let ge=z>0?v+O+(Z>0?O:0):0;Z===0&&u==="simple"&&(ge=0),$+=ge;const pe=I%f===0;if(pe&&(M.push($-(n+C+ge)),V!=null)){if(V<=0)return!0;V--}const Ee=this.getLineHeight(y==="split"?de:be,re),Re=Math.floor(I/f);return $>r-Ee&&$<i&&(B??(B=Re)),j==null&&$+Ee>L&&(j=Re),V==null&&$>=i&&pe&&(V=N),I++,$+=Ee,oe>0&&u!=="simple"&&($+=v+O),!1}}),B==null)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:w-C-p};const F=M.length;j??(j=B);const W=Math.round(j-T/2),P=Math.max(0,F-T),K=Math.max(0,Math.min(W,P)),U=K*f,X=W<0?R+W*f:R,D=M[K]??0,G=K+X/f;return{startingLine:U,totalLines:X,bufferBefore:D,bufferAfter:G<M.length?w-C-M[G]-p:w-($-n)-p}}};function nue(e){const t=e.hunks.at(-1);return t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0?!1:t.additionLineIndex+t.additionCount<e.additionLines.length||t.deletionLineIndex+t.deletionCount<e.deletionLines.length}function rue(e,t){const[n,r]=e.split(",").map(Number);return t==="split"?r:n}const iue=typeof window>"u"?b.useEffect:b.useLayoutEffect;function sue({fileDiff:e,options:t,lineAnnotations:n,selectedLines:r,prerenderedHTML:i,metrics:s,hasGutterRenderUtility:a,hasCustomHeader:l,disableWorkerPool:u}){const d=Are(),p=b.useContext(Jle),f=b.useRef(null),v=ece(_=>{if(_!=null){if(f.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");d!=null?f.current=new tue(gy({hasCustomHeader:l,hasGutterRenderUtility:a,options:t}),d,s,u?void 0:p,!0):f.current=new nj(gy({hasCustomHeader:l,hasGutterRenderUtility:a,options:t}),u?void 0:p,!0),f.current.hydrate({fileDiff:e,fileContainer:_,lineAnnotations:n,prerenderedHTML:i})}else{if(f.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");f.current.cleanUp(),f.current=null}});return iue(()=>{const{current:_}=f;if(_==null)return;const y=gy({hasCustomHeader:l,hasGutterRenderUtility:a,options:t}),w=!Dce(_.options,y);_.setOptions(y),_.render({forceRender:w,fileDiff:e,lineAnnotations:n}),r!==void 0&&_.setSelectedLines(r)}),{ref:v,getHoveredLine:b.useCallback(()=>{var _;return(_=f.current)==null?void 0:_.getHoveredLine()},[])}}function gy({options:e,hasCustomHeader:t,hasGutterRenderUtility:n}){return n||t?{...e,renderCustomHeader:t?AA:void 0,renderGutterUtility:n?AA:void 0}:e}function oue(e){const t=Xce(e);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=t[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function aue({patch:e,options:t,metrics:n,lineAnnotations:r,selectedLines:i,className:s,style:a,prerenderedHTML:l,renderAnnotation:u,renderCustomHeader:d,renderHeaderPrefix:p,renderHeaderMetadata:f,renderGutterUtility:v,renderHoverUtility:_,disableWorkerPool:y=!1}){const w=lue(e),{ref:k,getHoveredLine:C}=sue({fileDiff:w,options:t,metrics:n,lineAnnotations:r,selectedLines:i,prerenderedHTML:l,hasGutterRenderUtility:v!=null||_!=null,hasCustomHeader:d!=null,disableWorkerPool:y});return m.jsx(dg,{ref:k,className:s,style:a,children:Rre(jce({fileDiff:w,renderCustomHeader:d,renderHeaderPrefix:p,renderHeaderMetadata:f,renderAnnotation:u,lineAnnotations:r,renderGutterUtility:v,renderHoverUtility:_,getHoveredLine:C}),l)})}function lue(e){return b.useMemo(()=>oue(e),[e])}function cue({rootRef:e,disabled:t=!1}){const n=b.useRef(null),[r,i]=b.useState(!1);return b.useEffect(()=>{if(t){i(!1);return}const s=e.current,a=n.current;if(!s||!a)return;const l=new IntersectionObserver(([u])=>{i(u.intersectionRatio<1)},{root:s,threshold:[1]});return l.observe(a),()=>l.disconnect()},[t,e]),{sentinelRef:n,isStuck:r}}const Qp=wa()(Sa(e=>({checkedPathsByProjectId:{},reconcileProject:(t,n)=>e(r=>{const i=r.checkedPathsByProjectId[t]??{},s=Object.fromEntries(n.map(a=>[a,i[a]??!0]));return Object.keys(i).length===Object.keys(s).length&&Object.entries(s).every(([a,l])=>i[a]===l)?r:{checkedPathsByProjectId:{...r.checkedPathsByProjectId,[t]:s}}}),setChecked:(t,n,r)=>e(i=>({checkedPathsByProjectId:{...i.checkedPathsByProjectId,[t]:{...i.checkedPathsByProjectId[t]??{},[n]:r}}})),setAllChecked:(t,n,r)=>e(i=>({checkedPathsByProjectId:{...i.checkedPathsByProjectId,[t]:{...i.checkedPathsByProjectId[t]??{},...Object.fromEntries(n.map(s=>[s,r]))}}}))}),{name:"diff-commit-selections",version:2})),kg=20,rj=30,uue=370;function ij(e){return Number.isFinite(e)?Math.max(kg,e):rj}function due(){return{isVisible:!1,size:kg}}function Td(){return{viewMode:"history",collapsedPaths:{},summary:"",description:""}}function vy(e,t){return e[t]??due()}function hue(e){return!e||typeof e!="object"?{projects:{},projectUi:{}}:{projects:Object.fromEntries(Object.entries(e.projects??{}).map(([r,i])=>[r,{isVisible:!1,size:ij(i.size??rj)}])),projectUi:{}}}const si=wa()(Sa(e=>({projects:{},projectUi:{},toggleVisibility:t=>e(n=>({projects:{...n.projects,[t]:{...vy(n.projects,t),isVisible:!vy(n.projects,t).isVisible}}})),setSize:(t,n)=>e(r=>({projects:{...r.projects,[t]:{...vy(r.projects,t),size:ij(n)}}})),reconcileCollapsedPaths:(t,n)=>e(r=>{const i=r.projectUi[t]??Td(),s=Object.fromEntries(n.map(a=>[a,i.collapsedPaths[a]??!0]));return Object.keys(i.collapsedPaths).length===Object.keys(s).length&&Object.entries(s).every(([a,l])=>i.collapsedPaths[a]===l)?r:{projectUi:{...r.projectUi,[t]:{...i,collapsedPaths:s}}}}),toggleCollapsedPath:(t,n)=>e(r=>{const i=r.projectUi[t]??Td();return{projectUi:{...r.projectUi,[t]:{...i,collapsedPaths:{...i.collapsedPaths,[n]:!(i.collapsedPaths[n]??!0)}}}}}),setViewMode:(t,n)=>e(r=>{const i=r.projectUi[t]??Td();return i.viewMode===n?r:{projectUi:{...r.projectUi,[t]:{...i,viewMode:n}}}}),setCommitDraft:(t,n)=>e(r=>{const i=r.projectUi[t]??Td();return i.summary===n.summary&&i.description===n.description?r:{projectUi:{...r.projectUi,[t]:{...i,summary:n.summary,description:n.description}}}}),clearCommitDraft:t=>e(n=>{const r=n.projectUi[t]??Td();return!r.summary&&!r.description?n:{projectUi:{...n.projectUi,[t]:{...r,summary:"",description:""}}}}),clearProject:t=>e(n=>{const{[t]:r,...i}=n.projects,{[t]:s,...a}=n.projectUi;return{projects:i,projectUi:a}})}),{name:"right-sidebar-layouts",version:3,migrate:hue})),fue={isVisible:!1,size:33},pue={sm:"text-sm px-2.5 py-1",md:"text-sm px-3 py-1.5"};function Dv({value:e,onValueChange:t,options:n,size:r="md",className:i,optionClassName:s}){return m.jsx("div",{className:Ce("inline-flex items-center rounded-lg border border-border p-[3px] ",i),children:n.map(a=>{const l=a.value===e,u=a.icon,d=u?b.isValidElement(u)?u:(()=>{const f=u;return m.jsx(f,{className:r==="sm"?"h-3.5 w-3.5":"h-4 w-4"})})():null,p=m.jsxs("button",{type:"button",onClick:()=>t(a.value),disabled:a.disabled,"aria-pressed":l,className:Ce("rounded-[4px] border transition-colors",u?"grid grid-cols-[auto_auto] items-center gap-2":"inline-flex items-center",pue[r],l?"bg-white dark:bg-muted text-slate-900 dark:text-slate-200 border-slate-300 dark:border-white/10 bg-slate-200 ":"border-transparent text-slate-800 hover:text-slate-900 dark:text-muted-foreground dark:hover:text-foreground",a.disabled&&"opacity-50 pointer-events-none",s),children:[d,m.jsx("span",{children:a.label})]},a.value);return a.tooltip?m.jsxs(gl,{children:[m.jsx(vl,{asChild:!0,children:p}),m.jsx(_a,{children:a.tooltip})]},a.value):p})})}const Zp={};function mue(e,t){return!e||!t.mimeType||typeof t.size!="number"||t.changeType==="deleted"||!t.mimeType.startsWith("image/")&&t.mimeType!=="application/pdf"?null:{id:`diff:${t.path}`,kind:t.mimeType.startsWith("image/")?"image":"file",displayName:t.path.split("/").pop()??t.path,absolutePath:t.path,relativePath:t.path,contentUrl:`/api/projects/${e}/files/${encodeURIComponent(t.path)}/content`,mimeType:t.mimeType,size:t.size}}function gue(e){return e.isUntracked}function _y(e){return m.jsxs(gl,{delayDuration:0,children:[m.jsx(vl,{asChild:!0,children:m.jsx("button",{type:"button","aria-label":e.label,title:e.label,onClick:e.onClick,className:Ce("flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",e.active&&"bg-accent text-foreground"),children:e.children})}),m.jsx(_a,{children:e.label})]})}function sj({checked:e,mixed:t=!1,label:n,className:r,onClick:i}){return m.jsx("button",{type:"button","aria-label":n??(e?"Exclude file from commit":"Include file in commit"),"aria-checked":t?"mixed":e,"aria-pressed":t?"mixed":e,onClick:s=>{s.stopPropagation(),i()},className:Ce("flex size-4.5 shrink-0 items-center justify-center rounded border transition-colors",e||t?"border-foreground bg-foreground text-background":"border-border bg-background text-transparent",r),children:t?m.jsx(jF,{className:"h-3 w-3",strokeWidth:3}):e?m.jsx(Rs,{className:"h-3 w-3",strokeWidth:3}):null})}function US(e){const t=Date.parse(e);if(!Number.isFinite(t))return"";const n=Date.now()-t,r=6e4,i=60*r,s=24*i,a=7*s,l=30*s,u=365*s;return n<r?"just now":n<i?`${Math.round(n/r)}m ago`:n<s?`${Math.round(n/i)}hr ago`:n<a?`${Math.round(n/s)}d ago`:n<l?`${Math.round(n/a)}wk ago`:n<u?`${Math.round(n/l)}mo ago`:`${Math.round(n/u)}yr ago`}function vue(e){return e?`Last fetched ${US(e)}`:"No local fetch recorded"}function _ue({entry:e,isPendingPush:t=!1}){const n=US(e.authoredAt),r=!!e.githubUrl;return m.jsxs("button",{type:"button",disabled:!r,onClick:()=>{!e.githubUrl||typeof window>"u"||window.open(e.githubUrl,"_blank","noopener,noreferrer")},className:Ce("flex w-full items-start gap-3 rounded-lg border border-border bg-background px-3 py-2 text-left transition-colors",r?"hover:bg-accent":"cursor-default opacity-60"),children:[m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:e.summary}),e.description?m.jsx("div",{className:"mt-1 line-clamp-2 whitespace-pre-wrap text-xs text-muted-foreground",children:e.description}):null,m.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-1 text-xs text-muted-foreground",children:[e.authorName?m.jsx("span",{className:"truncate",children:e.authorName}):null,e.authorName&&n?m.jsx("span",{"aria-hidden":"true",children:"•"}):null,n?m.jsx("span",{children:n}):null]})]}),e.tags.length>0?m.jsxs("div",{className:"flex shrink-0 flex-wrap justify-end gap-1",children:[e.tags.map(i=>m.jsx("span",{className:"inline-flex items-center rounded-full border border-border px-2 py-0.5 text-[11px] text-muted-foreground",children:i},i)),t?m.jsx("span",{className:"inline-flex items-center rounded-full border border-border px-2 py-0.5 text-[11px] text-muted-foreground",children:m.jsx(qy,{className:"size-3"})}):null]}):t?m.jsx("div",{className:"flex shrink-0 flex-wrap justify-end gap-1",children:m.jsx("span",{className:"inline-flex items-center rounded-full border border-border px-2 py-0.5 text-[11px] text-muted-foreground",children:m.jsx(qy,{className:"size-3"})})}):null]})}function $N(e){switch(e.kind){case"local":return 0;case"pull_request":return 1;case"remote":default:return 2}}function bue(e){const t=new Map;for(const n of e){const r=t.get(n.name);(!r||$N(n)<$N(r))&&t.set(n.name,n)}return t}function yue(e,t){const n=bue([...e.local,...e.pullRequests,...e.remote]);t&&n.delete(t);const r=new Set,i=e.defaultBranchName?n.get(e.defaultBranchName):void 0;i&&r.add(i.name);const s=e.recent.map(l=>n.get(l.name)??l).filter(l=>!!l&&!r.has(l.name));for(const l of s)r.add(l.name);const a=[...n.values()].filter(l=>!r.has(l.name)).sort((l,u)=>l.displayName.localeCompare(u.displayName));return{defaultBranch:i,recent:s,other:a}}function oj({value:e,onChange:t,placeholder:n,disabled:r,trailingAction:i}){return m.jsxs("div",{className:"relative",children:[m.jsx(_m,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),m.jsx(bs,{value:e,onChange:s=>t(s.target.value),placeholder:n,className:Ce("h-9 pl-7 text-sm",i?"pr-14":void 0),disabled:r}),i?m.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2",children:i}):null]})}function ol({title:e,entries:t,emptyLabel:n,selectedName:r,disabled:i,stickyTitle:s=!1,onSelect:a}){return t.length===0&&!n?null:m.jsxs("div",{className:"space-y-1",children:[m.jsx("div",{className:Ce("px-1 py-1 text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",s&&"sticky top-0 z-10 bg-background"),children:e}),t.length===0?m.jsx("div",{className:"px-1 py-1 text-xs text-muted-foreground",children:n}):t.map(l=>{const u=r===l.name;return m.jsxs("button",{type:"button",disabled:i,onClick:()=>a(l),className:Ce("flex w-full items-start gap-2 rounded-lg px-2 py-2 text-left transition-colors disabled:opacity-60",u?"bg-accent text-foreground":"hover:bg-accent"),children:[l.kind==="pull_request"?m.jsx(YD,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}):m.jsx(Xd,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("div",{className:"flex w-full items-center gap-3",children:[m.jsx("div",{className:"min-w-0 flex-1 overflow-hidden whitespace-nowrap text-sm text-foreground",children:l.displayName}),l.updatedAt?m.jsx("div",{className:"ml-auto shrink-0 text-right text-[11px] text-muted-foreground",children:US(l.updatedAt)}):null]}),l.kind==="pull_request"&&l.description||l.headLabel?m.jsx("div",{className:"truncate text-xs text-muted-foreground",children:l.kind==="pull_request"?l.description??l.headLabel??l.name:l.headLabel??void 0}):null]})]},l.id)})]})}function xue({open:e,onOpenChange:t,branchList:n,currentBranchName:r,onPreviewMergeBranch:i,onMergeBranch:s}){const[a,l]=b.useState(""),[u,d]=b.useState(null),[p,f]=b.useState(null),[v,_]=b.useState(null),[y,w]=b.useState(!1),[k,C]=b.useState(!1),E=b.useMemo(()=>n?yue(n,r):{defaultBranch:void 0,recent:[],other:[]},[n,r]),R=a.trim().toLowerCase(),T=b.useCallback(B=>R?[B.displayName,B.name,B.description,B.prTitle,B.headLabel].some(j=>j==null?void 0:j.toLowerCase().includes(R)):!0,[R]),N=E.defaultBranch&&T(E.defaultBranch)?E.defaultBranch:void 0,M=E.recent.filter(T),L=E.other.filter(T),O=b.useMemo(()=>u?[E.defaultBranch,...E.recent,...E.other].find(B=>B!==void 0&&B.name===u)??null:null,[E.defaultBranch,E.other,E.recent,u]);b.useEffect(()=>{e||(l(""),d(null),f(null),_(null),w(!1),C(!1))},[e]),b.useEffect(()=>{if(!e||!O){f(null),_(null),w(!1);return}let B=!1;return f(null),_(null),w(!0),i(O).then(j=>{B||f(j)}).catch(j=>{B||_(j instanceof Error?j.message:String(j))}).finally(()=>{B||w(!1)}),()=>{B=!0}},[i,e,O]);const $=!O||!p||y||k||p.status!=="mergeable";async function I(){if(!(!O||$)){C(!0);try{const B=await s(O);B!=null&&B.ok&&t(!1)}finally{C(!1)}}}return m.jsx(qg,{open:e,onOpenChange:t,children:m.jsxs(zh,{size:"sm",className:"max-w-[min(92vw,475px)]",children:[m.jsxs(Yg,{className:"flex min-h-0 flex-col gap-4 px-4 pb-4 pt-4",children:[m.jsxs("div",{className:"space-y-1",children:[m.jsxs(Kg,{children:["Merge into ",r??"current branch"]}),m.jsx(gw,{children:"Choose a branch to continue."})]}),m.jsx(oj,{value:a,onChange:l,placeholder:"Search branches"}),m.jsxs("div",{className:"max-h-[375px] space-y-3 overflow-y-auto pr-1",children:[m.jsx(ol,{title:"Default Branch",entries:N?[N]:[],emptyLabel:"No default branch available.",selectedName:u,onSelect:B=>d(B.name)}),m.jsx(ol,{title:"Recent Branches",entries:M,emptyLabel:"No recent branches.",selectedName:u,onSelect:B=>d(B.name)}),m.jsx(ol,{title:"Other Branches",entries:L,emptyLabel:"No other branches match this search.",selectedName:u,onSelect:B=>d(B.name)})]}),m.jsx("div",{className:"px-2",children:O?y?m.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[m.jsx(bn,{className:"size-3.5 animate-spin"}),m.jsx("span",{children:"Checking merge preview…"})]}):v?m.jsx("div",{className:"text-sm text-destructive",children:v}):p?m.jsxs("div",{className:"flex items-start gap-2",children:[p.status==="up_to_date"?m.jsx(Rs,{className:"mt-0.5 size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400"}):p.status==="conflicts"?m.jsx(VR,{className:"mt-0.5 size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}):p.status==="mergeable"?m.jsx(KD,{className:"mt-0.5 size-3.5 shrink-0 text-muted-foreground"}):m.jsx(VR,{className:"mt-0.5 size-3.5 shrink-0 text-destructive"}),m.jsxs("div",{className:"min-w-0 space-y-1",children:[m.jsx("div",{className:"text-sm font-medium text-foreground",children:p.message}),p.detail?m.jsx("div",{className:"line-clamp-2 whitespace-pre-wrap text-xs text-muted-foreground",children:p.detail}):null]})]}):m.jsx("div",{className:"text-sm text-muted-foreground",children:"Preview unavailable."}):m.jsx("div",{className:"text-sm text-muted-foreground",children:"Select a branch to preview the merge."})})]}),m.jsx(Xg,{children:m.jsxs("div",{className:"flex min-w-0 w-full items-center justify-end gap-2",children:[m.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>t(!1),children:"Cancel"}),m.jsx(nt,{className:"max-w-full min-w-0",size:"sm",disabled:$,onClick:()=>void I(),children:k?m.jsxs(m.Fragment,{children:[m.jsx(bn,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Merging…"]}):m.jsx("span",{className:"block max-w-full truncate",children:"Merge"})})]})})]})})}function wue({currentBranchName:e,onListBranches:t,onPreviewMergeBranch:n,onMergeBranch:r,onCheckoutBranch:i,onCreateBranch:s}){const[a,l]=b.useState(!1),[u,d]=b.useState(!1),[p,f]=b.useState(!1),[v,_]=b.useState(!1),[y,w]=b.useState(""),[k,C]=b.useState("branches"),[E,R]=b.useState(null),[T,N]=b.useState(null);b.useEffect(()=>{a&&(f(!0),N(null),t().then(U=>R(U)).catch(U=>{N(U instanceof Error?U.message:String(U))}).finally(()=>{f(!1)}))},[t,a]);const M=y.trim().toLowerCase(),L=U=>U.filter(X=>M?[X.displayName,X.name,X.description,X.prTitle,X.headLabel].some(D=>D==null?void 0:D.toLowerCase().includes(M)):!0),O=(E==null?void 0:E.currentBranchName)??e,$=new Set(((E==null?void 0:E.pullRequests)??[]).map(U=>U.headRefName??U.name)),I=L((E==null?void 0:E.recent)??[]).filter(U=>U.name!==O),B=L((E==null?void 0:E.local)??[]).filter(U=>U.name!==O),j=L((E==null?void 0:E.remote)??[]).filter(U=>U.name!==O&&!$.has(U.name)),V=L((E==null?void 0:E.pullRequests)??[]).filter(U=>U.name!==O),F=(E==null?void 0:E.pullRequests.length)??0;async function W(U){_(!0);try{await i(U),l(!1),w(""),C("branches")}finally{_(!1)}}async function P(){_(!0);try{await s(),l(!1),w(""),C("branches")}finally{_(!1)}}function K(){l(!1),d(!0)}return m.jsxs(vP,{open:a,onOpenChange:l,children:[m.jsx(_P,{asChild:!0,children:m.jsxs("button",{type:"button",className:"flex min-w-0 max-w-full items-center gap-1 rounded-md px-1.5 py-1 text-sm transition-colors hover:bg-accent hover:text-foreground","aria-label":"Open branch switcher",children:[m.jsx(Xd,{className:"h-3.5 w-3.5 shrink-0"}),m.jsx("span",{className:"truncate",children:e??"Detached HEAD"}),m.jsx(jh,{className:"h-3.5 w-3.5 shrink-0"})]})}),m.jsx(nS,{align:"start",className:"w-[320px] p-2",children:m.jsxs("div",{className:"space-y-2",children:[m.jsx(oj,{value:y,onChange:w,placeholder:k==="pull_requests"?"Search pull requests":"Search branches",disabled:p||v,trailingAction:m.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>void P(),disabled:p||v,className:"h-7 px-2 text-xs hover:!bg-transparent hover:!border-border/0",children:"+ New"})}),m.jsx(Dv,{value:k,onValueChange:U=>C(U),size:"sm",className:"w-full",optionClassName:"flex-1 justify-center",options:[{value:"branches",label:"Branches"},{value:"pull_requests",label:`Open PRs ${F}`}]}),m.jsx("div",{className:"max-h-[420px] overflow-y-auto pr-1.5 -mr-[8px]",children:p?m.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[m.jsx(bn,{className:"h-4 w-4 animate-spin"}),m.jsx("span",{children:"Loading branches…"})]}):T?m.jsx("div",{className:"rounded-lg border border-border px-3 py-2 text-sm text-muted-foreground",children:T}):k==="pull_requests"?m.jsx(ol,{title:"Open PRs",entries:V,emptyLabel:(E==null?void 0:E.pullRequestsStatus)==="error"?E.pullRequestsError??"Could not load pull requests.":(E==null?void 0:E.pullRequestsStatus)==="unavailable"?"Pull requests unavailable for this repository.":"No open pull requests.",disabled:v,stickyTitle:!0,onSelect:U=>{W(U)}}):m.jsxs("div",{className:"space-y-3",children:[m.jsx(ol,{title:"Recent",entries:I,emptyLabel:"No recent branches.",disabled:v,stickyTitle:!0,onSelect:U=>{W(U)}}),m.jsx(ol,{title:"Local",entries:B,emptyLabel:"No local branches.",disabled:v,stickyTitle:!0,onSelect:U=>{W(U)}}),m.jsx(ol,{title:"Remote",entries:j,emptyLabel:"No remote branches.",disabled:v,stickyTitle:!0,onSelect:U=>{W(U)}})]})}),O?m.jsx(nt,{variant:"default",size:"sm",disabled:p||v||!!T,onClick:K,className:"h-9 w-full justify-center rounded-lg px-3 text-sm",children:m.jsxs("span",{className:"block max-w-full truncate",children:[m.jsx(bF,{className:"mr-1.5 inline h-3.5 w-3.5 shrink-0"}),"Merge branch into ",O,"..."]})}):null]})}),m.jsx(xue,{open:u,onOpenChange:d,branchList:E,currentBranchName:O,onPreviewMergeBranch:n,onMergeBranch:r})]})}function Sue({file:e,rootRef:t,projectId:n,isCollapsed:r,isChecked:i,editorLabel:s,diffRenderMode:a,wrapLines:l,onToggleCollapsed:u,onToggleChecked:d,fileActions:p,patch:f,patchError:v,isPatchLoading:_,onLoadPatch:y}){const w=gue(e),[k,C]=b.useState(null),E=b.useRef(null),{sentinelRef:R,isStuck:T}=cue({rootRef:t,disabled:r}),N=b.useMemo(()=>mue(n,e),[e,n]);function M($){if(mv($).openInNewTab){typeof window<"u"&&window.open(new URL($.contentUrl,window.location.origin).toString(),"_blank","noopener,noreferrer");return}C($.id)}function L($){var B;$.preventDefault(),$.stopPropagation();const I=$.currentTarget.getBoundingClientRect();(B=E.current)==null||B.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:I.left+I.width/2,clientY:I.bottom,view:window}))}function O(){if(!r){u();return}if(N||f!==void 0){u();return}_||y(e.path).then(()=>{u()}).catch(()=>{})}return m.jsxs(Yw,{children:[m.jsx(Xw,{asChild:!0,children:m.jsxs("div",{ref:E,className:"relative rounded-lg border border-border bg-background",children:[r?null:m.jsx("div",{ref:R,className:"pointer-events-none absolute inset-x-0 top-0 h-px","aria-hidden":"true"}),m.jsxs("div",{role:"button",tabIndex:0,onClick:O,onKeyDown:$=>{$.key!=="Enter"&&$.key!==" "||($.preventDefault(),O())},className:Ce("group/header sticky top-0 z-20 flex cursor-pointer items-center justify-between gap-3 bg-background pl-[7px] pr-2.5 py-1.5 text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",!r&&!T&&"rounded-t-[calc(theme(borderRadius.lg)-1px)]",r&&"rounded-[calc(theme(borderRadius.lg)-1px)]",!r&&"border-b border-border/50"),children:[m.jsxs("div",{className:"flex min-w-0 items-center",children:[m.jsx(sj,{checked:i,onClick:d}),m.jsx("div",{className:"min-w-0 truncate select-none ml-2 mr-1",children:e.path})]}),m.jsxs("div",{className:"flex shrink-0 items-center gap-2 select-none",children:[m.jsxs("span",{className:"whitespace-nowrap text-xs font-mono",children:[e.additions>0?m.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["+",e.additions]}):null,e.deletions>0?m.jsxs("span",{className:e.additions>0?"ml-2 text-red-600 dark:text-red-400":"text-red-600 dark:text-red-400",children:["-",e.deletions]}):null]}),m.jsx("button",{type:"button","aria-label":`Open actions for ${e.path}`,onClick:L,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:m.jsx(z9,{className:"h-3.5 w-3.5 shrink-0"})}),_&&r&&!N?m.jsx(bn,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):r?m.jsx(jh,{className:"h-3.5 w-3.5 shrink-0"}):m.jsx(WD,{className:"h-3.5 w-3.5 shrink-0"})]})]}),r?null:m.jsx("div",{className:"kanna-diff-patch overflow-hidden rounded-b-[calc(theme(borderRadius.lg)-1px)] pb-[1px]",children:N?m.jsx("div",{className:"flex justify-center p-3",children:N.kind==="image"?m.jsx(rS,{attachment:N,onClick:()=>M(N)}):m.jsx(iS,{attachment:N,onClick:()=>M(N)})}):_?m.jsxs("div",{className:"flex items-center justify-center px-3 py-8 text-sm text-muted-foreground",children:[m.jsx(bn,{className:"mr-2 h-4 w-4 animate-spin"}),"Loading diff..."]}):v?m.jsx("div",{className:"px-3 py-4 text-sm text-destructive",children:v}):f!==void 0?m.jsx(aue,{patch:f,options:{diffStyle:a,disableFileHeader:!0,disableBackground:!1,overflow:l?"wrap":"scroll",lineDiffType:"word",diffIndicators:"classic"}}):m.jsx("div",{className:"px-3 py-4 text-sm text-muted-foreground",children:"Diff unavailable."})}),m.jsx(kS,{attachment:N&&k===N.id?N:null,onOpenChange:$=>!$&&C(null)})]},e.path)}),m.jsxs(hv,{children:[m.jsxs(Ki,{onSelect:$=>{$.stopPropagation(),p.onOpenFile(e.path)},children:[m.jsx(Gg,{className:"h-3.5 w-3.5"}),m.jsxs("span",{className:"text-xs font-medium",children:["Open in ",s]})]}),m.jsxs(Ki,{onSelect:$=>{$.stopPropagation(),p.onDiscardFile(e.path)},className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[m.jsx(e5,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Discard Changes"})]}),m.jsxs(Ki,{disabled:!w,onSelect:$=>{$.stopPropagation(),w&&p.onIgnoreFile(e.path)},children:[m.jsx(s9,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Ignore File"})]}),m.jsx(QO,{}),m.jsxs(Ki,{onSelect:$=>{$.stopPropagation(),p.onCopyFilePath(e.path)},children:[m.jsx(pl,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Copy File Path"})]}),m.jsxs(Ki,{onSelect:$=>{$.stopPropagation(),p.onCopyRelativePath(e.path)},children:[m.jsx(pl,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Copy Relative Path"})]})]})]})}function Cue({projectId:e,diffs:t,editorLabel:n,diffRenderMode:r,wrapLines:i,onOpenFile:s,onDiscardFile:a,onIgnoreFile:l,onCopyFilePath:u,onCopyRelativePath:d,onListBranches:p,onPreviewMergeBranch:f,onMergeBranch:v,onCheckoutBranch:_,onCreateBranch:y,onGenerateCommitMessage:w,onCommit:k,onSyncWithRemote:C,onLoadPatch:E,onDiffRenderModeChange:R,onWrapLinesChange:T,onClose:N}){var Dt;const M=b.useMemo(()=>({onOpenFile:s,onDiscardFile:a,onIgnoreFile:l,onCopyFilePath:u,onCopyRelativePath:d}),[s,a,l,u,d]),L=t.files.length>0,[O,$]=b.useState(!1),[I,B]=b.useState(null),[j,V]=b.useState(!1),[F,W]=b.useState({}),[P,K]=b.useState({}),[U,X]=b.useState({}),D=b.useRef(null),G=b.useRef({}),Z=b.useMemo(()=>t.files.map(xe=>xe.path),[t.files]),z=b.useMemo(()=>Z.join("\0"),[Z]),oe=si(xe=>{var Ye;return e?((Ye=xe.projectUi[e])==null?void 0:Ye.viewMode)??(L?"changes":"history"):L?"changes":"history"}),ue=si(xe=>{var Ye;return e?((Ye=xe.projectUi[e])==null?void 0:Ye.collapsedPaths)??Zp:Zp}),ne=si(xe=>{var Ye;return e?((Ye=xe.projectUi[e])==null?void 0:Ye.summary)??"":""}),de=si(xe=>{var Ye;return e?((Ye=xe.projectUi[e])==null?void 0:Ye.description)??"":""}),be=si(xe=>xe.reconcileCollapsedPaths),re=si(xe=>xe.toggleCollapsedPath),ge=si(xe=>xe.setViewMode),pe=si(xe=>xe.setCommitDraft),Ee=si(xe=>xe.clearCommitDraft),Re=Qp(xe=>e?xe.checkedPathsByProjectId[e]??Zp:Zp),Fe=Qp(xe=>xe.reconcileProject),it=Qp(xe=>xe.setChecked),Ct=Qp(xe=>xe.setAllChecked),Mt=b.useRef(L);b.useEffect(()=>{e&&be(e,Z)},[Z,z,e,be]),b.useEffect(()=>{const xe=Object.fromEntries(t.files.map(Xe=>[Xe.path,Xe.patchDigest])),Ye=Xe=>G.current[Xe]===xe[Xe];W(Xe=>Object.fromEntries(Object.entries(Xe).filter(([Et])=>Z.includes(Et)&&Ye(Et)))),K(Xe=>Object.fromEntries(Object.entries(Xe).filter(([Et])=>Z.includes(Et)&&Ye(Et)))),X(Xe=>Object.fromEntries(Object.entries(Xe).filter(([Et])=>Z.includes(Et)&&Ye(Et)))),G.current=xe},[t.files,Z,z]),b.useEffect(()=>{e&&Fe(e,Z)},[Z,z,e,Fe]),b.useEffect(()=>{if(!e)return;if(Mt.current!==L){ge(e,L?"changes":"history"),Mt.current=L;return}Mt.current=L},[L,e,ge]);const nn=b.useMemo(()=>t.files.filter(xe=>Re[xe.path]??!0).map(xe=>xe.path),[Re,t.files]),ut=nn.length,Me=t.files.length>0&&ut===t.files.length,Ge=ut>0&&ut<t.files.length,qe=ne.trim(),Pe=qe.length>0,Oe=I!==null,Qt=O||Oe,me=((Dt=t.branchHistory)==null?void 0:Dt.entries)??[],ke=t.behindCount??0,ze=t.aheadCount??0,Ne=t.hasUpstream===!0,ee=t.hasUpstream===!1&&!!t.branchName,et=t.branchName?t.branchName.split("/").map(xe=>encodeURIComponent(xe)).join("/"):null,Ut=ee?"publish":ke>0?"pull":"fetch",Bt=t.originRepoSlug&&et?`https://github.com/${t.originRepoSlug}/compare/${et}?expand=1`:null,Lt=!!(Ne&&Bt&&t.branchName&&t.branchName!==t.defaultBranchName),At=t.status==="ready"&&ut>0&&!Qt,tt=t.status==="ready"&&ut>0&&Pe&&!Qt,ce="commit_and_push",He=t.branchName??"current branch";async function Ht(xe){if(tt){B(xe);try{const Ye=await k({paths:nn,summary:qe,description:de.trim(),mode:xe});(Ye!=null&&Ye.ok||Ye!=null&&Ye.localCommitCreated)&&e&&Ee(e)}finally{B(null)}}}async function Zt(){if(At){$(!0);try{const xe=await w({paths:nn});e&&pe(e,{summary:xe.subject,description:xe.body})}finally{$(!1)}}}function rn(xe){if(!(!(xe.metaKey||xe.ctrlKey)||xe.key!=="Enter")){if(xe.preventDefault(),Pe){Ht(ce);return}Zt()}}async function gt(xe=Ut){if(!(t.status!=="ready"||j)){V(!0);try{await C(xe)}finally{V(!1)}}}const kt=b.useCallback(async xe=>{var Ye;if(F[xe]!==void 0||U[xe])return F[xe]??"";X(Xe=>({...Xe,[xe]:!0})),K(Xe=>{if(!(xe in Xe))return Xe;const{[xe]:Et,...Jt}=Xe;return Jt});try{const Xe=await E(xe);W(Jt=>({...Jt,[xe]:Xe}));const Et=(Ye=t.files.find(Jt=>Jt.path===xe))==null?void 0:Ye.patchDigest;return Et&&(G.current={...G.current,[xe]:Et}),Xe}catch(Xe){const Et=Xe instanceof Error?Xe.message:String(Xe);throw K(Jt=>({...Jt,[xe]:Et})),Xe}finally{X(Xe=>{const{[xe]:Et,...Jt}=Xe;return Jt})}},[t.files,U,E,F]);return m.jsx("div",{className:"h-full min-h-0 border-l border-border bg-background md:min-w-[370px]",children:m.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[m.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pl-2.5 pr-3 py-2",children:[m.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:m.jsx(wue,{currentBranchName:t.branchName,onListBranches:p,onPreviewMergeBranch:f,onMergeBranch:v,onCheckoutBranch:_,onCreateBranch:y})}),t.status==="ready"?Ut==="publish"?m.jsxs(nt,{variant:"ghost",size:"sm",onClick:()=>void gt(),disabled:j,className:"h-7 gap-1.5 px-2 text-xs hover:!bg-transparent hover:!border-border/0",children:[j?m.jsx(bn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(bm,{className:"h-3.5 w-3.5"}),m.jsx("span",{children:"Publish Branch"})]}):m.jsxs("div",{className:"flex items-center gap-1",children:[Ut==="fetch"?m.jsxs(gl,{delayDuration:0,children:[m.jsx(vl,{asChild:!0,children:m.jsxs(nt,{variant:"ghost",size:"sm",onClick:()=>void gt(),disabled:j,className:"h-7 gap-1.5 px-2 text-xs hover:!bg-transparent hover:!border-border/0",children:[j?m.jsx(bn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(JD,{className:"h-3.5 w-3.5"}),m.jsx("span",{children:"Fetch"})]})}),m.jsx(_a,{children:vue(t.lastFetchedAt)})]}):m.jsxs(nt,{variant:"ghost",size:"sm",onClick:()=>void gt(),disabled:j,className:"h-7 gap-1.5 px-2 text-xs hover:!bg-transparent hover:!border-border/0",children:[j?m.jsx(bn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(I9,{className:"h-3.5 w-3.5"}),m.jsx("span",{children:"Pull"}),m.jsx("span",{className:"inline-flex min-w-4 items-center justify-center rounded-full bg-muted px-1 text-[10px] text-muted-foreground",children:ke})]}),Ne&&ze>0?m.jsxs(nt,{variant:"default",size:"sm",onClick:()=>void gt("push"),disabled:j,className:"h-7 gap-1.5 px-2 text-xs",children:[j?m.jsx(bn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(bm,{className:"h-3.5 w-3.5"}),m.jsx("span",{children:"Push"}),m.jsx("span",{className:"inline-flex min-w-4 items-center justify-center rounded-full bg-primary-foreground/15 px-1 text-[10px] text-primary-foreground",children:ze})]}):null,Lt&&Bt?m.jsxs(nt,{variant:"ghost",size:"sm",onClick:()=>{typeof window>"u"||window.open(Bt,"_blank","noopener,noreferrer")},className:"h-7 gap-1.5 px-2 text-xs hover:!bg-transparent hover:!border-border/0",children:[m.jsx(YD,{className:"h-3.5 w-3.5"}),m.jsx("span",{children:"PR"})]}):null]}):null]}),m.jsxs("div",{className:"relative min-h-0 flex-1",children:[m.jsx("div",{className:"sticky top-0 z-30 pl-[14px] pr-[12px] pt-[6px] bg-gradient-to-b from-background to-transparent",children:m.jsx("div",{className:"relative h-[40px] flex min-w-0 items-center justify-center gap-[13px]",children:m.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-between gap-[13px] relative",children:[oe==="changes"?m.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground/70",children:[m.jsx(sj,{checked:Me,mixed:Ge,label:Ge?"Select all files for commit":Me?"Unselect all files from commit":"Select all files for commit",onClick:()=>{!e||t.files.length===0||Ct(e,Z,Ge?!0:!Me)}}),m.jsxs("span",{children:[ut," files"]})]}):m.jsx("div",{}),m.jsx("div",{className:"pointer-events-none absolute left-1/2 -translate-x-1/2 top-1/2 -translate-y-1/2",children:m.jsx("div",{className:"pointer-events-auto",children:m.jsx(Dv,{value:oe,onValueChange:xe=>{e&&ge(e,xe)},size:"sm",optionClassName:"flex-1 justify-center",options:[{value:"changes",label:"Changes"},{value:"history",label:"History"}]})})}),oe==="changes"?m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx(_y,{label:"Unified diff",active:r==="unified",onClick:()=>R("unified"),children:m.jsx(ZF,{className:"h-4 w-4"})}),m.jsx(_y,{label:"Side-by-side diff",active:r==="split",onClick:()=>R("split"),children:m.jsx(A9,{className:"h-4 w-4"})}),m.jsx(_y,{label:i?"Disable word wrap":"Enable word wrap",active:i,onClick:()=>T(!i),children:m.jsx(xU,{className:"h-4 w-4"})})]}):m.jsx("div",{})]})})}),m.jsx("div",{ref:D,className:"h-full overflow-y-auto [scrollbar-gutter:stable]",children:t.status==="no_repo"?m.jsx("div",{className:"flex h-full items-center justify-center px-6 py-3 text-center",children:m.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a git repo to view current file diffs."})}):oe==="history"?me.length===0?m.jsx("div",{className:"flex h-full items-center justify-center px-6 py-3 text-center",children:m.jsxs("p",{className:"text-sm text-muted-foreground",children:["No recent commits on ",t.branchName??"this branch","."]})}):m.jsx("div",{className:"space-y-1.5 p-1.5",children:me.map((xe,Ye)=>m.jsx(_ue,{entry:xe,isPendingPush:Ye<ze},xe.sha))}):t.files.length===0?m.jsx("div",{className:"flex h-full items-center justify-center px-6 py-3 text-center",children:m.jsx("p",{className:"text-sm text-muted-foreground",children:"No file changes."})}):m.jsx("div",{className:"space-y-1.5 p-1.5 pb-72",children:t.files.map(xe=>{const Ye=ue[xe.path]??!0,Xe=Re[xe.path]??!0;return m.jsx(Sue,{file:xe,rootRef:D,projectId:e,isCollapsed:Ye,isChecked:Xe,editorLabel:n,diffRenderMode:r,wrapLines:i,onToggleCollapsed:()=>{e&&re(e,xe.path)},onToggleChecked:()=>{e&&it(e,xe.path,!Xe)},fileActions:M,patch:F[xe.path],patchError:P[xe.path],isPatchLoading:!!U[xe.path],onLoadPatch:kt},xe.path)})})}),oe==="changes"?m.jsxs("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-30 p-3 pt-14 overflow-y-auto [scrollbar-gutter:stable]",children:[m.jsx("div",{className:"absolute inset-x-0 bottom-0 top-0 bg-gradient-to-t from-background to-transparent"}),m.jsx("div",{className:"pointer-events-auto relative mx-auto max-w-[550px]",children:m.jsxs("div",{className:"space-y-0 rounded-xl bg-background",children:[m.jsx(bs,{value:ne,onChange:xe=>{e&&pe(e,{summary:xe.target.value,description:de})},onKeyDown:rn,placeholder:"Commit message (override)",className:"rounded-t-xl rounded-b-none px-3",disabled:Qt||t.status!=="ready"}),m.jsx(Jw,{value:de,onChange:xe=>{e&&pe(e,{summary:ne,description:xe.target.value})},onKeyDown:rn,placeholder:"Description",rows:3,className:"-mt-px rounded-t-none rounded-b-xl px-3 outline-none focus:outline-none focus-visible:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:border-border mb-2",disabled:Qt||t.status!=="ready"}),m.jsxs(Yw,{children:[m.jsx(Xw,{asChild:!0,children:m.jsx(nt,{type:"button",className:"-mt-px w-full rounded-xl",disabled:Pe?!tt:!At,onClick:()=>{if(Pe){Ht(ce);return}Zt()},children:m.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[Pe?Oe?m.jsx(bn,{strokeWidth:2.5,className:"size-3 shrink-0 animate-spin"}):t.hasUpstream?m.jsx(bm,{strokeWidth:2.5,className:"size-3 shrink-0"}):m.jsx(KD,{strokeWidth:2.5,className:"size-3 shrink-0"}):O?m.jsx(bn,{strokeWidth:2.5,className:"size-3 shrink-0 animate-spin"}):m.jsx(WF,{strokeWidth:2.5,className:"size-3 shrink-0"}),m.jsx("span",{className:"min-w-0 truncate text-left",children:Pe?Oe?I==="commit_only"?"Committing...":"Committing & Pushing...":t.hasUpstream?m.jsxs(m.Fragment,{children:["Commit & push to ",m.jsx(Xd,{strokeWidth:2.5,className:"mr-[4.5px] ml-0.5 inline size-3 "}),He]}):m.jsxs(m.Fragment,{children:["Commit & publish ",m.jsx(Xd,{strokeWidth:2.5,className:"mr-[4.5px] ml-0.5 inline size-3 "}),He]}):O?"Generating...":m.jsxs(m.Fragment,{children:["Generate message for ",m.jsx(Xd,{strokeWidth:2.5,className:"mr-[4.5px] ml-0.5 inline size-3 "}),He]})})]})})}),t.hasUpstream?m.jsx(hv,{children:m.jsx(Ki,{disabled:!Pe||!tt,onSelect:xe=>{xe.stopPropagation(),Ht("commit_only")},children:"Commit Only"})}):null]})]})})]}):null]})]})})}const kue=b.memo(Cue);function Eue(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function Rue(e,t){const n=getComputedStyle(e.ownerDocument.body),r=parseFloat(n.fontSize);return t*r}function Tue(e){return e/100*window.innerHeight}function Aue(e){return e/100*window.innerWidth}function Nue(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function Bd({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=Nue(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=Rue(t,i);break}case"em":{r=Eue(t,i);break}case"vh":{r=Tue(i);break}case"vw":{r=Aue(i);break}}return r}function Wr(e){return parseFloat(e.toFixed(3))}function su({group:e}){const{orientation:t,panels:n}=e;return n.reduce((r,i)=>(r+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,r),0)}function Xx(e){const{panels:t}=e,n=su({group:e});return n===0?t.map(r=>({groupResizeBehavior:r.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:r.panelConstraints.disabled,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:s}=r;let a=0;if(s.collapsedSize!==void 0){const p=Bd({groupSize:n,panelElement:i,styleProp:s.collapsedSize});a=Wr(p/n*100)}let l;if(s.defaultSize!==void 0){const p=Bd({groupSize:n,panelElement:i,styleProp:s.defaultSize});l=Wr(p/n*100)}let u=0;if(s.minSize!==void 0){const p=Bd({groupSize:n,panelElement:i,styleProp:s.minSize});u=Wr(p/n*100)}let d=100;if(s.maxSize!==void 0){const p=Bd({groupSize:n,panelElement:i,styleProp:s.maxSize});d=Wr(p/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:a,collapsible:s.collapsible===!0,defaultSize:l,disabled:s.disabled,minSize:u,maxSize:d,panelId:r.id}})}function Kt(e,t="Assertion error"){if(!e)throw Error(t)}function Qx(e,t){return Array.from(t).sort(e==="horizontal"?Mue:Lue)}function Mue(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function Lue(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function aj(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function lj(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function Due({orientation:e,rects:t,targetRect:n}){const r={x:n.x+n.width/2,y:n.y+n.height/2};let i,s=Number.MAX_VALUE;for(const a of t){const{x:l,y:u}=lj(r,a),d=e==="horizontal"?l:u;d<s&&(s=d,i=a)}return Kt(i,"No rect found"),i}let Jp;function Oue(){return Jp===void 0&&(typeof matchMedia=="function"?Jp=!!matchMedia("(pointer:coarse)").matches:Jp=!1),Jp}function cj(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=Qx(n,Array.from(t.children).filter(aj).map(y=>({element:y}))).map(({element:y})=>y),a=[];let l=!1,u=!1,d=-1,p=-1,f=0,v,_=[];{let y=-1;for(const w of s)w.hasAttribute("data-panel")&&(y++,w.ariaDisabled===null&&(f++,d===-1&&(d=y),p=y))}if(f>1){let y=-1;for(const w of s)if(w.hasAttribute("data-panel")){y++;const k=r.find(C=>C.element===w);if(k){if(v){const C=v.element.getBoundingClientRect(),E=w.getBoundingClientRect();let R;if(u){const T=n==="horizontal"?new DOMRect(C.right,C.top,0,C.height):new DOMRect(C.left,C.bottom,C.width,0),N=n==="horizontal"?new DOMRect(E.left,E.top,0,E.height):new DOMRect(E.left,E.top,E.width,0);switch(_.length){case 0:{R=[T,N];break}case 1:{const M=_[0],L=Due({orientation:n,rects:[C,E],targetRect:M.element.getBoundingClientRect()});R=[M,L===C?N:T];break}default:{R=_;break}}}else _.length?R=_:R=[n==="horizontal"?new DOMRect(C.right,E.top,E.left-C.right,E.height):new DOMRect(E.left,C.bottom,E.width,E.top-C.bottom)];for(const T of R){let N="width"in T?T:T.element.getBoundingClientRect();const M=Oue()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(N.width<M){const O=M-N.width;N=new DOMRect(N.x-O/2,N.y,N.width+O,N.height)}if(N.height<M){const O=M-N.height;N=new DOMRect(N.x,N.y-O/2,N.width,N.height+O)}const L=y<=d||y>p;!l&&!L&&a.push({group:e,groupSize:su({group:e}),panels:[v,k],separator:"width"in T?void 0:T,rect:N}),l=!1}}u=!1,v=k,_=[]}}else if(w.hasAttribute("data-separator")){w.ariaDisabled!==null&&(l=!0);const k=i.find(C=>C.element===w);k?_.push(k):(v=void 0,_=[])}else u=!0}return a}var ua,EL;let uj=(EL=class{constructor(){Ko(this,ua,{})}addListener(t,n){const r=$n(this,ua)[t];return r===void 0?$n(this,ua)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=$n(this,ua)[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,s=null;const a=Array.from(r);for(let l=0;l<a.length;l++){const u=a[l];try{u.call(null,n)}catch(d){s===null&&(i=!0,s=d)}}if(i)throw s}}removeAllListeners(){yi(this,ua,{})}removeListener(t,n){const r=$n(this,ua)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}},ua=new WeakMap,EL),ws=new Map;const dj=new uj;function Pue(e){ws=new Map(ws),ws.delete(e)}function FN(e,t){for(const[n]of ws)if(n.id===e)return n}function fa(e,t){for(const[n,r]of ws)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Ll(){return ws}function VS(e,t){return dj.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function go(e,t){const n=ws.get(e);ws=new Map(ws),ws.set(e,t),dj.emit("groupChange",{group:e,prev:n,next:t})}function Iue(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const a=lj(n,s.rect);switch(e){case"horizontal":{a.x<=i.x&&(r=s,i=a);break}case"vertical":{a.y<=i.y&&(r=s,i=a);break}}}return r?{distance:i,hitRegion:r}:void 0}function jue(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function zue(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:WN(e),b:WN(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();Kt(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:VN(UN(n.a)),b:VN(UN(n.b))};if(i.a===i.b){const s=r.childNodes,a={a:n.a.at(-1),b:n.b.at(-1)};let l=s.length;for(;l--;){const u=s[l];if(u===a.a)return 1;if(u===a.b)return-1}}return Math.sign(i.a-i.b)}const Bue=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Hue(e){const t=getComputedStyle(hj(e)??e).display;return t==="flex"||t==="inline-flex"}function $ue(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Hue(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||Bue.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function UN(e){let t=e.length;for(;t--;){const n=e[t];if(Kt(n,"Missing node"),$ue(n))return n}return null}function VN(e){return e&&Number(getComputedStyle(e).zIndex)||0}function WN(e){const t=[];for(;e;)t.push(e),e=hj(e);return t}function hj(e){const{parentNode:t}=e;return jue(t)?t.host:t}function Fue(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Uue({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!aj(n)||n.contains(e)||e.contains(n))return!0;if(zue(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Fue(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function WS(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=cj(i),a=Iue(i.orientation,s,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Uue({groupElement:i.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Vue(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Ar(e,t,n=0){return Math.abs(Wr(e)-Wr(t))<=n}function gs(e,t){return Ar(e,t)?0:e>t?1:-1}function zc({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){const{collapsedSize:i=0,collapsible:s,disabled:a,maxSize:l=100,minSize:u=0}=t;if(a&&!e)return n;if(gs(r,u)<0)if(s){const d=(i+u)/2;gs(r,d)<0?r=i:r=u}else r=u;return r=Math.min(l,r),r=Wr(r),r}function Th({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(Ar(e,0))return t;const a=s==="imperative-api",l=Object.values(t),u=Object.values(i),d=[...l],[p,f]=r;Kt(p!=null,"Invalid first pivot index"),Kt(f!=null,"Invalid second pivot index");let v=0;switch(s){case"keyboard":{{const w=e<0?f:p,k=n[w];Kt(k,`Panel constraints not found for index ${w}`);const{collapsedSize:C=0,collapsible:E,minSize:R=0}=k;if(E){const T=l[w];if(Kt(T!=null,`Previous layout not found for panel index ${w}`),Ar(T,C)){const N=R-T;gs(N,Math.abs(e))>0&&(e=e<0?0-N:N)}}}{const w=e<0?p:f,k=n[w];Kt(k,`No panel constraints found for index ${w}`);const{collapsedSize:C=0,collapsible:E,minSize:R=0}=k;if(E){const T=l[w];if(Kt(T!=null,`Previous layout not found for panel index ${w}`),Ar(T,R)){const N=T-C;gs(N,Math.abs(e))>0&&(e=e<0?0-N:N)}}}break}default:{const w=e<0?f:p,k=n[w];Kt(k,`Panel constraints not found for index ${w}`);const C=l[w],{collapsible:E,collapsedSize:R,minSize:T}=k;if(E&&gs(C,T)<0)if(e>0){const N=T-R,M=N/2,L=C+e;gs(L,T)<0&&(e=gs(e,M)<=0?0:N)}else{const N=T-R,M=100-N/2,L=C-e;gs(L,T)<0&&(e=gs(100+e,M)>0?0:-N)}break}}{const w=e<0?1:-1;let k=e<0?f:p,C=0;for(;;){const R=l[k];Kt(R!=null,`Previous layout not found for panel index ${k}`);const T=zc({overrideDisabledPanels:a,panelConstraints:n[k],prevSize:R,size:100})-R;if(C+=T,k+=w,k<0||k>=n.length)break}const E=Math.min(Math.abs(e),Math.abs(C));e=e<0?0-E:E}{let w=e<0?p:f;for(;w>=0&&w<n.length;){const k=Math.abs(e)-Math.abs(v),C=l[w];Kt(C!=null,`Previous layout not found for panel index ${w}`);const E=C-k,R=zc({overrideDisabledPanels:a,panelConstraints:n[w],prevSize:C,size:E});if(!Ar(C,R)&&(v+=C-R,d[w]=R,v.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?w--:w++}}if(Vue(u,d))return i;{const w=e<0?f:p,k=l[w];Kt(k!=null,`Previous layout not found for panel index ${w}`);const C=k+v,E=zc({overrideDisabledPanels:a,panelConstraints:n[w],prevSize:k,size:C});if(d[w]=E,!Ar(E,C)){let R=C-E,T=e<0?f:p;for(;T>=0&&T<n.length;){const N=d[T];Kt(N!=null,`Previous layout not found for panel index ${T}`);const M=N+R,L=zc({overrideDisabledPanels:a,panelConstraints:n[T],prevSize:N,size:M});if(Ar(N,L)||(R-=L-N,d[T]=L),Ar(R,0))break;e>0?T--:T++}}}const _=Object.values(d).reduce((w,k)=>k+w,0);if(!Ar(_,100,.1))return i;const y=Object.keys(i);return d.reduce((w,k,C)=>(w[y[C]]=k,w),{})}function yl(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||gs(e[n],t[n])!==0)return!1;return!0}function xl({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((l,u)=>l+u,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(l=>`${l}%`).join(", ")}`);if(!Ar(i,100)&&r.length>0)for(let l=0;l<t.length;l++){const u=r[l];Kt(u!=null,`No layout data found for index ${l}`);const d=100/i*u;r[l]=d}let s=0;for(let l=0;l<t.length;l++){const u=n[l];Kt(u!=null,`No layout data found for index ${l}`);const d=r[l];Kt(d!=null,`No layout data found for index ${l}`);const p=zc({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:u,size:d});d!=p&&(s+=d-p,r[l]=p)}if(!Ar(s,0))for(let l=0;l<t.length;l++){const u=r[l];Kt(u!=null,`No layout data found for index ${l}`);const d=u+s,p=zc({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:u,size:d});if(u!==p&&(s-=p-u,r[l]=p,Ar(s,0)))break}const a=Object.keys(e);return r.reduce((l,u,d)=>(l[a[d]]=u,l),{})}function fj({groupId:e,panelId:t}){const n=()=>{const l=Ll();for(const[u,{defaultLayoutDeferred:d,derivedPanelConstraints:p,layout:f,groupSize:v,separatorToPanels:_}]of l)if(u.id===e)return{defaultLayoutDeferred:d,derivedPanelConstraints:p,group:u,groupSize:v,layout:f,separatorToPanels:_};throw Error(`Group ${e} not found`)},r=()=>{const l=n().derivedPanelConstraints.find(u=>u.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const l=n().group.panels.find(u=>u.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const l=n().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},a=l=>{const u=s();if(l===u)return;const{defaultLayoutDeferred:d,derivedPanelConstraints:p,group:f,groupSize:v,layout:_,separatorToPanels:y}=n(),w=f.panels.findIndex(R=>R.id===t),k=w===f.panels.length-1,C=Th({delta:k?u-l:l-u,initialLayout:_,panelConstraints:p,pivotIndices:k?[w-1,w]:[w,w+1],prevLayout:_,trigger:"imperative-api"}),E=xl({layout:C,panelConstraints:p});yl(_,E)||go(f,{defaultLayoutDeferred:d,derivedPanelConstraints:p,groupSize:v,layout:E,separatorToPanels:y})};return{collapse:()=>{const{collapsible:l,collapsedSize:u}=r(),{mutableValues:d}=i(),p=s();l&&p!==u&&(d.expandToSize=p,a(u))},expand:()=>{const{collapsible:l,collapsedSize:u,minSize:d}=r(),{mutableValues:p}=i(),f=s();if(l&&f===u){let v=p.expandToSize??d;v===0&&(v=1),a(v)}},getSize:()=>{const{group:l}=n(),u=s(),{element:d}=i(),p=l.orientation==="horizontal"?d.offsetWidth:d.offsetHeight;return{asPercentage:u,inPixels:p}},isCollapsed:()=>{const{collapsible:l,collapsedSize:u}=r(),d=s();return l&&Ar(u,d)},resize:l=>{const{group:u}=n(),{element:d}=i(),p=su({group:u}),f=Bd({groupSize:p,panelElement:d,styleProp:l}),v=Wr(f/p*100);a(v)}}}function GN(e){if(e.defaultPrevented)return;const t=Ll();WS(e,t).forEach(n=>{if(n.separator){const r=n.panels.find(i=>i.panelConstraints.defaultSize!==void 0);if(r){const i=r.panelConstraints.defaultSize,s=fj({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function Nm(e){const t=Ll();for(const[n]of t)if(n.separators.some(r=>r.element===e))return n;throw Error("Could not find parent Group for separator element")}function pj({groupId:e}){const t=()=>{const n=Ll();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:s,groupSize:a,layout:l,separatorToPanels:u}=t(),d=xl({layout:n,panelConstraints:i});return r?l:(yl(l,d)||go(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:a,layout:d,separatorToPanels:u}),d)}}}function Ka(e,t){const n=Nm(e),r=fa(n.id,!0),i=n.separators.find(p=>p.element===e);Kt(i,"Matching separator not found");const s=r.separatorToPanels.get(i);Kt(s,"Matching panels not found");const a=s.map(p=>n.panels.indexOf(p)),l=pj({groupId:n.id}).getLayout(),u=Th({delta:t,initialLayout:l,panelConstraints:r.derivedPanelConstraints,pivotIndices:a,prevLayout:l,trigger:"keyboard"}),d=xl({layout:u,panelConstraints:r.derivedPanelConstraints});yl(l,d)||go(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:d,separatorToPanels:r.separatorToPanels})}function qN(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=Nm(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Ka(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Ka(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Ka(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Ka(t,-5);break}case"End":{e.preventDefault(),Ka(t,100);break}case"Enter":{e.preventDefault();const r=Nm(t),i=fa(r.id,!0),{derivedPanelConstraints:s,layout:a,separatorToPanels:l}=i,u=r.separators.find(v=>v.element===t);Kt(u,"Matching separator not found");const d=l.get(u);Kt(d,"Matching panels not found");const p=d[0],f=s.find(v=>v.panelId===p.id);if(Kt(f,"Panel metadata not found"),f.collapsible){const v=a[p.id],_=f.collapsedSize===v?r.mutableState.expandedPanelSizes[p.id]??f.minSize:f.collapsedSize;Ka(t,_-v)}break}case"F6":{e.preventDefault();const r=Nm(t).separators.map(a=>a.element),i=Array.from(r).findIndex(a=>a===e.currentTarget);Kt(i!==null,"Index not found");const s=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[s].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Ka(t,-100);break}}}let Yc={cursorFlags:0,state:"inactive"};const GS=new uj;function wl(){return Yc}function Wue(e){return GS.addListener("change",e)}function Gue(e){const t=Yc,n={...Yc};n.cursorFlags=e,Yc=n,GS.emit("change",{prev:t,next:n})}function Xc(e){const t=Yc;Yc=e,GS.emit("change",{prev:t,next:e})}function KN(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Ll(),n=WS(e,t),r=new Map;let i=!1;n.forEach(s=>{s.separator&&(i||(i=!0,s.separator.element.focus({preventScroll:!0})));const a=t.get(s.group);a&&r.set(s.group,a.layout)}),Xc({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}const que=e=>e,by=()=>{},mj=1,gj=2,vj=4,_j=8,YN=3,XN=12;let em;function QN(){return em===void 0&&(em=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(em=!0)),em}function Kue({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(!(r===0&&i===0)){switch(n){case"active":{if(e&&QN()){const s=(e&mj)!==0,a=(e&gj)!==0,l=(e&vj)!==0,u=(e&_j)!==0;if(s)return l?"se-resize":u?"ne-resize":"e-resize";if(a)return l?"sw-resize":u?"nw-resize":"w-resize";if(l)return"s-resize";if(u)return"n-resize"}break}}return QN()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const ZN=new WeakMap;function qS(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=ZN.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));const r=wl();switch(r.state){case"active":case"hover":{const i=Kue({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(a=>a.group),state:r.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}ZN.set(e,{prevStyle:t,styleSheet:n})}function bj({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:a}){let l=0;n.forEach(d=>{const{group:p,groupSize:f}=d,{orientation:v,panels:_}=p,{disableCursor:y}=p.mutableState;let w=0;s?v==="horizontal"?w=(t.clientX-s.x)/f*100:w=(t.clientY-s.y)/f*100:v==="horizontal"?w=t.clientX<0?-100:100:w=t.clientY<0?-100:100;const k=r.get(p),C=i.get(p);if(!k||!C)return;const{defaultLayoutDeferred:E,derivedPanelConstraints:R,groupSize:T,layout:N,separatorToPanels:M}=C;if(R&&N&&M){const L=Th({delta:w,initialLayout:k,panelConstraints:R,pivotIndices:d.panels.map(O=>_.indexOf(O)),prevLayout:N,trigger:"mouse-or-touch"});if(yl(L,N)){if(w!==0&&!y)switch(v){case"horizontal":{l|=w<0?mj:gj;break}case"vertical":{l|=w<0?vj:_j;break}}}else go(d.group,{defaultLayoutDeferred:E,derivedPanelConstraints:R,groupSize:T,layout:L,separatorToPanels:M})}});let u=0;t.movementX===0?u|=a&YN:u|=l&YN,t.movementY===0?u|=a&XN:u|=l&XN,Gue(u),qS(e)}function JN(e){const t=Ll(),n=wl();switch(n.state){case"active":bj({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function eM(e){if(e.defaultPrevented)return;const t=wl(),n=Ll();switch(t.state){case"active":{if(e.buttons===0){Xc({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(r=>{const i=fa(r.group.id,!0);go(r.group,i)});return}bj({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const r=WS(e,n);r.length===0?t.state!=="inactive"&&Xc({cursorFlags:0,state:"inactive"}):Xc({cursorFlags:0,hitRegions:r,state:"hover"}),qS(e.currentTarget);break}}}function tM(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(wl().state){case"hover":Xc({cursorFlags:0,state:"inactive"})}}function nM(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=wl();switch(t.state){case"active":Xc({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(qS(e.currentTarget),t.hitRegions.forEach(n=>{const r=fa(n.group.id,!0);go(n.group,r)}),e.preventDefault())}}function rM(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const a=Wr(s.defaultSize);n+=a,r[s.panelId]=a}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=Wr((100-n)/i);for(const a of e)a.defaultSize===void 0&&(r[a.panelId]=s)}return r}function Yue(e,t,n){if(!n[0])return;const r=e.panels.find(u=>u.element===t);if(!r||!r.onResize)return;const i=su({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,a=r.mutableValues.prevSize,l={asPercentage:Wr(s/i*100),inPixels:s};r.mutableValues.prevSize=l,r.onResize(l,r.id,a)}function Xue(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function Que({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,s=0,a=!1;const l=new Map,u=[];for(const f of e.panels){const v=r[f.id]??0;switch(f.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{a=!0;const _=v/100*n,y=Wr(_/t*100);l.set(f.id,y),i+=y;break}case"preserve-relative-size":default:{u.push(f.id),s+=v;break}}}if(!a||u.length===0)return r;const d=100-i,p={...r};if(l.forEach((f,v)=>{p[v]=f}),s>0)for(const f of u){const v=r[f]??0;p[f]=Wr(v/s*d)}else{const f=Wr(d/u.length);for(const v of u)p[v]=f}return p}function Zue(e,t){const n=e.map(i=>i.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(!r.includes(i))return!1;return!0}const Ec=new Map;function Jue(e){let t=!0;Kt(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(y=>{for(const w of y){const{borderBoxSize:k,target:C}=w;if(C===e.element){if(t){const E=su({group:e});if(E===0)return;const R=fa(e.id);if(!R)return;const T=Xx(e),N=R.defaultLayoutDeferred?rM(T):R.layout,M=Que({group:e,nextGroupSize:E,prevGroupSize:R.groupSize,prevLayout:N}),L=xl({layout:M,panelConstraints:T});if(!R.defaultLayoutDeferred&&yl(R.layout,L)&&Xue(R.derivedPanelConstraints,T)&&R.groupSize===E)return;go(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:T,groupSize:E,layout:L,separatorToPanels:R.separatorToPanels})}}else Yue(e,C,k)}});s.observe(e.element),e.panels.forEach(y=>{Kt(!r.has(y.id),`Panel ids must be unique; id "${y.id}" was used more than once`),r.add(y.id),y.onResize&&s.observe(y.element)});const a=su({group:e}),l=Xx(e),u=e.panels.map(({id:y})=>y).join(",");let d=e.mutableState.defaultLayout;d&&(Zue(e.panels,d)||(d=void 0));const p=e.mutableState.layouts[u]??d??rM(l),f=xl({layout:p,panelConstraints:l}),v=e.element.ownerDocument;Ec.set(v,(Ec.get(v)??0)+1);const _=new Map;return cj(e).forEach(y=>{y.separator&&_.set(y.separator,y.panels)}),go(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:l,groupSize:a,layout:f,separatorToPanels:_}),e.separators.forEach(y=>{Kt(!i.has(y.id),`Separator ids must be unique; id "${y.id}" was used more than once`),i.add(y.id),y.element.addEventListener("keydown",qN)}),Ec.get(v)===1&&(v.addEventListener("dblclick",GN,!0),v.addEventListener("pointerdown",KN,!0),v.addEventListener("pointerleave",JN),v.addEventListener("pointermove",eM),v.addEventListener("pointerout",tM),v.addEventListener("pointerup",nM,!0)),function(){t=!1,Ec.set(v,Math.max(0,(Ec.get(v)??0)-1)),Pue(e),e.separators.forEach(y=>{y.element.removeEventListener("keydown",qN)}),Ec.get(v)||(v.removeEventListener("dblclick",GN,!0),v.removeEventListener("pointerdown",KN,!0),v.removeEventListener("pointerleave",JN),v.removeEventListener("pointermove",eM),v.removeEventListener("pointerout",tM),v.removeEventListener("pointerup",nM,!0)),s.disconnect()}}function ede(){const[e,t]=b.useState({}),n=b.useCallback(()=>t({}),[]);return[e,n]}function KS(e){const t=b.useId();return`${e??t}`}const Dl=typeof window<"u"?b.useLayoutEffect:b.useEffect;function oh(e){const t=b.useRef(e);return Dl(()=>{t.current=e},[e]),b.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function YS(...e){return oh(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function XS(e){const t=b.useRef({...e});return Dl(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const yj=b.createContext(null);function tde(e,t){const n=b.useRef({getLayout:()=>({}),setLayout:que});b.useImperativeHandle(t,()=>n.current,[]),Dl(()=>{Object.assign(n.current,pj({groupId:e}))})}function xj({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:s,groupRef:a,id:l,onLayoutChange:u,onLayoutChanged:d,orientation:p="horizontal",resizeTargetMinimumSize:f={coarse:20,fine:10},style:v,..._}){const y=b.useRef({onLayoutChange:{},onLayoutChanged:{}}),w=oh(B=>{yl(y.current.onLayoutChange,B)||(y.current.onLayoutChange=B,u==null||u(B))}),k=oh(B=>{yl(y.current.onLayoutChanged,B)||(y.current.onLayoutChanged=B,d==null||d(B))}),C=KS(l),E=b.useRef(null),[R,T]=ede(),N=b.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:f,separators:[]}),M=YS(E,s);tde(C,a);const L=oh((B,j)=>{const V=wl(),F=FN(B),W=fa(B);if(W){let P=!1;switch(V.state){case"active":{P=V.hitRegions.some(K=>K.group===F);break}}return{flexGrow:W.layout[j]??1,pointerEvents:P?"none":void 0}}return{flexGrow:(n==null?void 0:n[j])??1}}),O=XS({defaultLayout:n,disableCursor:r}),$=b.useMemo(()=>({get disableCursor(){return!!O.disableCursor},getPanelStyles:L,id:C,orientation:p,registerPanel:B=>{const j=N.current;return j.panels=Qx(p,[...j.panels,B]),T(),()=>{j.panels=j.panels.filter(V=>V!==B),T()}},registerSeparator:B=>{const j=N.current;return j.separators=Qx(p,[...j.separators,B]),T(),()=>{j.separators=j.separators.filter(V=>V!==B),T()}},togglePanelDisabled:(B,j)=>{const V=N.current.panels.find(P=>P.id===B);V&&(V.panelConstraints.disabled=j);const F=FN(C),W=fa(C);F&&W&&go(F,{...W,derivedPanelConstraints:Xx(F)})},toggleSeparatorDisabled:(B,j)=>{const V=N.current.separators.find(F=>F.id===B);V&&(V.disabled=j)}}),[L,C,T,p,O]),I=b.useRef(null);return Dl(()=>{const B=E.current;if(B===null)return;const j=N.current;let V;if(O.defaultLayout!==void 0&&Object.keys(O.defaultLayout).length===j.panels.length){V={};for(const D of j.panels){const G=O.defaultLayout[D.id];G!==void 0&&(V[D.id]=G)}}const F={disabled:!!i,element:B,id:C,mutableState:{defaultLayout:V,disableCursor:!!O.disableCursor,expandedPanelSizes:N.current.lastExpandedPanelSizes,layouts:N.current.layouts},orientation:p,panels:j.panels,resizeTargetMinimumSize:j.resizeTargetMinimumSize,separators:j.separators};I.current=F;const W=Jue(F),{defaultLayoutDeferred:P,derivedPanelConstraints:K,layout:U}=fa(F.id,!0);!P&&K.length>0&&(w(U),k(U));const X=VS(C,D=>{const{defaultLayoutDeferred:G,derivedPanelConstraints:Z,layout:z}=D.next;if(G||Z.length===0)return;const oe=F.panels.map(({id:ne})=>ne).join(",");F.mutableState.layouts[oe]=z,Z.forEach(ne=>{if(ne.collapsible){const{layout:de}=D.prev??{};if(de){const be=Ar(ne.collapsedSize,z[ne.panelId]),re=Ar(ne.collapsedSize,de[ne.panelId]);be&&!re&&(F.mutableState.expandedPanelSizes[ne.panelId]=de[ne.panelId])}}});const ue=wl().state!=="active";w(z),ue&&k(z)});return()=>{I.current=null,W(),X()}},[i,C,k,w,p,R,O]),b.useEffect(()=>{const B=I.current;B&&(B.mutableState.defaultLayout=n,B.mutableState.disableCursor=!!r)}),m.jsx(yj.Provider,{value:$,children:m.jsx("div",{..._,className:t,"data-group":!0,"data-testid":C,id:C,ref:M,style:{height:"100%",width:"100%",overflow:"hidden",...v,display:"flex",flexDirection:p==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:p==="horizontal"?"pan-y":"pan-x"},children:e})})}xj.displayName="Group";function QS(){const e=b.useContext(yj);return Kt(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function nde(e,t){const{id:n}=QS(),r=b.useRef({collapse:by,expand:by,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:by});b.useImperativeHandle(t,()=>r.current,[]),Dl(()=>{Object.assign(r.current,fj({groupId:n,panelId:e}))})}function wj({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,disabled:s,elementRef:a,groupResizeBehavior:l="preserve-relative-size",id:u,maxSize:d="100%",minSize:p="0%",onResize:f,panelRef:v,style:_,...y}){const w=!!u,k=KS(u),C=XS({disabled:s}),E=b.useRef(null),R=YS(E,a),{getPanelStyles:T,id:N,orientation:M,registerPanel:L,togglePanelDisabled:O}=QS(),$=f!==null,I=oh((j,V,F)=>{f==null||f(j,u,F)});Dl(()=>{const j=E.current;if(j!==null){const V={element:j,id:k,idIsStable:w,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:$?I:void 0,panelConstraints:{groupResizeBehavior:l,collapsedSize:n,collapsible:r,defaultSize:i,disabled:C.disabled,maxSize:d,minSize:p}};return L(V)}},[l,n,r,i,$,k,w,d,p,I,L,C]),b.useEffect(()=>{O(k,!!s)},[s,k,O]),nde(k,v);const B=b.useSyncExternalStore(j=>VS(N,j),()=>JSON.stringify(T(N,k)),()=>JSON.stringify(T(N,k)));return m.jsx("div",{...y,"aria-disabled":s||void 0,"data-panel":!0,"data-testid":k,id:k,ref:R,style:{...rde,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...JSON.parse(B)},children:m.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",..._,touchAction:M==="horizontal"?"pan-y":"pan-x"},children:e})})}wj.displayName="Panel";const rde={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function ide({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,s;const a=e[n],l=t.find(u=>u.panelId===n);if(l){const u=l.maxSize,d=l.collapsible?l.collapsedSize:l.minSize,p=[r,r+1];s=xl({layout:Th({delta:d-a,initialLayout:e,panelConstraints:t,pivotIndices:p,prevLayout:e}),panelConstraints:t})[n],i=xl({layout:Th({delta:u-a,initialLayout:e,panelConstraints:t,pivotIndices:p,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:a}}function Sj({children:e,className:t,disabled:n,elementRef:r,id:i,style:s,...a}){const l=KS(i),u=XS({disabled:n}),[d,p]=b.useState({}),[f,v]=b.useState("inactive"),_=b.useRef(null),y=YS(_,r),{disableCursor:w,id:k,orientation:C,registerSeparator:E,toggleSeparatorDisabled:R}=QS(),T=C==="horizontal"?"vertical":"horizontal";Dl(()=>{const M=_.current;if(M!==null){const L={disabled:u.disabled,element:M,id:l},O=E(L),$=Wue(B=>{v(B.next.state!=="inactive"&&B.next.hitRegions.some(j=>j.separator===L)?B.next.state:"inactive")}),I=VS(k,B=>{const{derivedPanelConstraints:j,layout:V,separatorToPanels:F}=B.next,W=F.get(L);if(W){const P=W[0],K=W.indexOf(P);p(ide({layout:V,panelConstraints:j,panelId:P.id,panelIndex:K}))}});return()=>{$(),I(),O()}}},[k,l,E,u]),b.useEffect(()=>{R(l,!!n)},[n,l,R]);let N;return n&&!w&&(N="not-allowed"),m.jsx("div",{...a,"aria-controls":d.valueControls,"aria-disabled":n||void 0,"aria-orientation":T,"aria-valuemax":d.valueMax,"aria-valuemin":d.valueMin,"aria-valuenow":d.valueNow,children:e,className:t,"data-separator":n?"disabled":f,"data-testid":l,id:l,ref:y,role:"separator",style:{flexBasis:"auto",cursor:N,...s,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}Sj.displayName="Separator";const Mm=({className:e,...t})=>m.jsx(xj,{className:Ce("flex h-full w-full",e),...t}),Qa=e=>m.jsx(wj,{...e}),Lm=({withHandle:e,orientation:t,disabled:n,className:r,...i})=>m.jsx(Sj,{disabled:n,className:Ce("relative flex items-center justify-center bg-transparent focus-visible:outline-none",t==="vertical"?"h-2 w-full -my-1 cursor-row-resize":"h-full w-2 -mx-1 cursor-col-resize",e&&(t==="vertical"?"before:absolute before:inset-x-0 before:top-1/2 before:h-0.5 before:-translate-y-1/2 before:bg-border":"before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:bg-border"),r),...i,children:m.jsx("span",{className:"sr-only",children:t==="vertical"?"Resize rows":"Resize columns"})});/**
|
|
2490
|
+
`||_[_.length-1]==="");)_.pop();const T=parseInt(w[3]),N=parseInt(w[1]);p=d?p:N-1,f=d?f:T-1;const M={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:parseInt(w[4]??"1"),additionStart:T,additionLines:k,deletionCount:parseInt(w[2]??"1"),deletionStart:N,deletionLines:C,deletionLineIndex:p,additionLineIndex:f,hunkContent:[],hunkContext:w[5],hunkSpecs:y,noEOFCRAdditions:!1,noEOFCRDeletions:!1};if(isNaN(M.additionCount)||isNaN(M.deletionCount)||isNaN(M.additionStart)||isNaN(M.deletionStart)){if(s)throw Error("parsePatchContent: invalid hunk metadata");console.error("parsePatchContent: invalid hunk metadata",M);continue}for(const L of _){const O=Kce(L);if(O==null){console.error("processFile: invalid rawLine:",L);continue}const{type:$,line:I}=O;if($==="addition")(E==null||E.type!=="change")&&(E=my("change",p,f),M.hunkContent.push(E)),f++,d&&u.additionLines.push(I),E.additions++,k++,R="addition";else if($==="deletion")(E==null||E.type!=="change")&&(E=my("change",p,f),M.hunkContent.push(E)),p++,d&&u.deletionLines.push(I),E.deletions++,C++,R="deletion";else if($==="context")(E==null||E.type!=="context")&&(E=my("context",p,f),M.hunkContent.push(E)),f++,p++,d&&(u.deletionLines.push(I),u.additionLines.push(I)),E.lines++,R="context";else if($==="metadata"&&E!=null){if(E.type==="context"?(M.noEOFCRAdditions=!0,M.noEOFCRDeletions=!0):R==="deletion"?M.noEOFCRDeletions=!0:R==="addition"&&(M.noEOFCRAdditions=!0),d&&(R==="addition"||R==="context")){const B=u.additionLines.length-1;B>=0&&(u.additionLines[B]=iu(u.additionLines[B]))}if(d&&(R==="deletion"||R==="context")){const B=u.deletionLines.length-1;B>=0&&(u.deletionLines[B]=iu(u.deletionLines[B]))}}}M.additionLines=k,M.deletionLines=C,M.collapsedBefore=Math.max(M.additionStart-1-a,0),u.hunks.push(M),a=M.additionStart+M.additionCount-1;for(const L of M.hunkContent)L.type==="context"?(M.splitLineCount+=L.lines,M.unifiedLineCount+=L.lines):(M.splitLineCount+=Math.max(L.additions,L.deletions),M.unifiedLineCount+=L.deletions+L.additions);M.splitLineStart=u.splitLineCount+M.collapsedBefore,M.unifiedLineStart=u.unifiedLineCount+M.collapsedBefore,u.splitLineCount+=M.collapsedBefore+M.splitLineCount,u.unifiedLineCount+=M.collapsedBefore+M.unifiedLineCount}if(u!=null){if(u.hunks.length>0&&!d&&u.additionLines.length>0&&u.deletionLines.length>0){const v=u.hunks[u.hunks.length-1],_=v.additionStart+v.additionCount-1,y=u.additionLines.length,w=Math.max(y-_,0);u.splitLineCount+=w,u.unifiedLineCount+=w}return n||(u.prevName!=null&&u.name!==u.prevName?u.hunks.length>0?u.type="rename-changed":u.type="rename-pure":i!=null&&i.contents===""?u.type="deleted":r!=null&&r.contents===""&&(u.type="new")),u.type!=="rename-pure"&&u.type!=="rename-changed"&&(u.prevName=void 0),u}}function Xce(e,t,n=!1){const r=[];for(const i of e.split(vre))try{r.push(Yce(i,t!=null?`${t}-${r.length}`:void 0,n))}catch(s){if(n)throw s;console.error(s)}return r}function my(e,t,n){return e==="change"?{type:"change",additions:0,deletions:0,additionLineIndex:n,deletionLineIndex:t}:{type:"context",lines:0,additionLineIndex:n,deletionLineIndex:t}}function Yx(e,t,n,r=!1){const i=tj(Gle(e.name,t.name,e.contents,t.contents,e.header,t.header,n),{cacheKey:(()=>{if(e.cacheKey!=null&&t.cacheKey!=null)return`${e.cacheKey}:${t.cacheKey}`})(),oldFile:e,newFile:t,throwOnError:r});if(i==null)throw new Error("parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?");return t.lang!=null&&(i.lang=t.lang),i}let Qce=-1;var $y,nj=($y=class{constructor(e={theme:xs},t,n=!1){Y(this,"__id",`file-diff:${++Qce}`);Y(this,"fileContainer");Y(this,"spriteSVG");Y(this,"pre");Y(this,"codeUnified");Y(this,"codeDeletions");Y(this,"codeAdditions");Y(this,"bufferBefore");Y(this,"bufferAfter");Y(this,"themeCSSStyle");Y(this,"appliedThemeCSS");Y(this,"unsafeCSSStyle");Y(this,"appliedUnsafeCSS");Y(this,"gutterUtilityContent");Y(this,"headerElement");Y(this,"headerPrefix");Y(this,"headerMetadata");Y(this,"headerCustom");Y(this,"separatorCache",new Map);Y(this,"errorWrapper");Y(this,"placeHolder");Y(this,"hunksRenderer");Y(this,"resizeManager");Y(this,"scrollSyncManager");Y(this,"interactionManager");Y(this,"annotationCache",new Map);Y(this,"lineAnnotations",[]);Y(this,"deletionFile");Y(this,"additionFile");Y(this,"fileDiff");Y(this,"renderRange");Y(this,"appliedPreAttributes");Y(this,"lastRenderedHeaderHTML");Y(this,"lastRowCount");Y(this,"enabled",!0);Y(this,"handleHighlightRender",()=>{this.rerender()});Y(this,"getLineIndex",(e,t="additions")=>{if(this.fileDiff==null)return;const n=this.fileDiff.hunks.at(-1);let r,i;e:for(const s of this.fileDiff.hunks){let a=t==="deletions"?s.deletionStart:s.additionStart;const l=t==="deletions"?s.deletionCount:s.additionCount;let u=s.splitLineStart,d=s.unifiedLineStart;if(e<a){const p=a-e;r=Math.max(d-p,0),i=Math.max(u-p,0);break e}if(e>=a+l){if(s===n){const p=e-(a+l);r=d+s.unifiedLineCount+p,i=u+s.splitLineCount+p;break e}continue}for(const p of s.hunkContent)if(p.type==="context")if(e<a+p.lines){const f=e-a;i=u+f,r=d+f;break e}else a+=p.lines,u+=p.lines,d+=p.lines;else{const f=t==="deletions"?p.deletions:p.additions;if(e<a+f){const v=e-a;r=d+(t==="additions"?p.deletions:0)+v,i=u+v;break e}else a+=f,u+=Math.max(p.deletions,p.additions),d+=p.deletions+p.additions}break e}if(!(r==null||i==null))return[r,i]});Y(this,"getHoveredLine",()=>this.interactionManager.getHoveredLine());Y(this,"handleExpandHunk",(e,t,n)=>{this.expandHunk(e,t,n)});Y(this,"expandHunk",(e,t,n)=>{this.hunksRenderer.expandHunk(e,t,n),this.rerender()});var r;this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new lce,this.scrollSyncManager=new Bce,this.interactionManager=new rce("diff",RN(e,typeof e.hunkSeparators=="function"||(e.hunkSeparators??"line-info")==="line-info"||e.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex)),(r=this.workerManager)==null||r.subscribeToThemeChanges(this),this.enabled=!0}getHunksRendererOptions(e){return{...e,headerRenderMode:e.renderCustomHeader!=null?"custom":"default",hunkSeparators:typeof e.hunkSeparators=="function"?"custom":e.hunkSeparators}}createHunksRenderer(e){return new Vce(this.getHunksRendererOptions(e),this.handleHighlightRender,this.workerManager)}setOptions(e){e!=null&&(this.options=e,this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.interactionManager.setOptions(RN(e,typeof e.hunkSeparators=="function"||(e.hunkSeparators??"line-info")==="line-info"||e.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex)))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??"system")!==e&&(this.mergeOptions({themeType:e}),!(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)&&this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType))}setLineAnnotations(e){this.lineAnnotations=e}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators=="function")}setSelectedLines(e){this.interactionManager.setSelection(e)}cleanUp(e=!1){var t,n,r;this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),(t=this.workerManager)==null||t.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||(n=this.fileContainer)==null||n.remove(),((r=this.fileContainer)==null?void 0:r.shadowRoot)!=null&&(this.fileContainer.shadowRoot.innerHTML=""),this.fileContainer=void 0,this.pre!=null&&(this.pre.innerHTML="",this.pre=void 0),this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore=void 0,this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.enabled=!1}virtualizedSetup(){var e;this.enabled=!0,(e=this.workerManager)==null||e.subscribeToThemeChanges(this)}hydrate(e){const{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,lineAnnotations:i,oldFile:s,newFile:a,fileDiff:l}=e;this.hydrateElements(t,n),this.pre==null&&this.headerElement==null?this.render({...e,preventEmit:!0}):this.hydrationSetup({fileDiff:l,oldFile:s,newFile:a,lineAnnotations:i}),r||this.emitPostRender()}hydrateElements(e,t){var n;Nce(e,t);for(const r of((n=e.shadowRoot)==null?void 0:n.children)??[]){if(r instanceof SVGElement){this.spriteSVG=r;continue}if(r instanceof HTMLElement){if(r instanceof HTMLPreElement){this.pre=r;for(const i of r.children)!(i instanceof HTMLElement)||i.tagName.toLowerCase()!=="code"||("deletions"in i.dataset&&(this.codeDeletions=i),"additions"in i.dataset&&(this.codeAdditions=i),"unified"in i.dataset&&(this.codeUnified=i));continue}if("diffsHeader"in r.dataset){this.headerElement=r;continue}if(r instanceof HTMLStyleElement&&r.hasAttribute(F3)){this.themeCSSStyle=r;continue}if(r instanceof HTMLStyleElement&&r.hasAttribute(U3)){this.unsafeCSSStyle=r,this.appliedUnsafeCSS=r.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),(this.pre!=null||this.headerElement!=null)&&(this.fileContainer=e)}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:r}){const{diffStyle:i="split",overflow:s="scroll"}=this.options;this.lineAnnotations=r??this.lineAnnotations,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!=null&&n!=null?Yx(t,n,this.options.parseDiffOptions):void 0),this.pre!=null&&(this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,s==="wrap"),s==="scroll"&&i==="split"&&this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions))}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({forceRender:!0,renderRange:this.renderRange})}render({oldFile:e,newFile:t,fileDiff:n,forceRender:r=!1,preventEmit:i=!1,lineAnnotations:s,fileContainer:a,containerWrapper:l,renderRange:u}){var T;if(!this.enabled)throw new Error("FileDiff.render: attempting to call render after cleaned up");const{collapsed:d=!1}=this.options,p=d?void 0:u,f=e!=null&&t!=null&&(!yN(e,this.deletionFile)||!yN(t,this.additionFile));let v=n!=null&&n!==this.fileDiff;const _=s!=null&&(s.length>0||this.lineAnnotations.length>0)?s!==this.lineAnnotations:!1;if(!d&&JI(p,this.renderRange)&&!r&&!_&&(n!=null&&n===this.fileDiff||n==null&&!f))return!1;const{renderRange:y}=this;if(this.renderRange=p,this.deletionFile=e,this.additionFile=t,n!=null?this.fileDiff=n:e!=null&&t!=null&&f&&(v=!0,this.fileDiff=Yx(e,t,this.options.parseDiffOptions)),s!=null&&this.setLineAnnotations(s),this.fileDiff==null)return!1;this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.hunksRenderer.setLineAnnotations(this.lineAnnotations);const{diffStyle:w="split",disableErrorHandling:k=!1,disableFileHeader:C=!1,overflow:E="scroll",themeType:R="system"}=this.options;if(C&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),a=this.getOrCreateFileContainer(a,l),d){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const N=this.hunksRenderer.renderDiff(this.fileDiff,Ere);N!=null&&this.applyThemeState(a,N.themeStyles,R,N.baseThemeType),(N==null?void 0:N.headerElement)!=null&&this.applyHeaderToDOM(N.headerElement,a),this.renderSeparators([]),this.injectUnsafeCSS()}catch(N){if(k)throw N;console.error(N),N instanceof Error&&this.applyErrorToDOM(N,a)}return i||this.emitPostRender(),!0}try{const N=this.getOrCreatePreNode(a);if(!(this.canPartiallyRender(r,_,f||v)&&this.applyPartialRender({previousRenderRange:y,renderRange:p}))){const M=this.hunksRenderer.renderDiff(this.fileDiff,p);if(M==null)return((T=this.workerManager)==null?void 0:T.isInitialized())===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(a,M.themeStyles,R,M.baseThemeType),M.headerElement!=null&&this.applyHeaderToDOM(M.headerElement,a),M.additionsContentAST!=null||M.deletionsContentAST!=null||M.unifiedContentAST!=null?this.applyHunksToDOM(N,M):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(M.hunkData)}this.applyBuffers(N,p),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.interactionManager.setup(N),this.resizeManager.setup(N,E==="wrap"),E==="scroll"&&w==="split"?this.scrollSyncManager.setup(N,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp()}catch(N){if(k)throw N;console.error(N),N instanceof Error&&this.applyErrorToDOM(N,a)}return i||this.emitPostRender(),!0}emitPostRender(){var e,t;this.fileContainer!=null&&((t=(e=this.options).onPostRender)==null||t.call(e,this.fileContainer,this))}removeRenderedCode(){var e,t,n,r,i,s;this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),(e=this.bufferBefore)==null||e.remove(),this.bufferBefore=void 0,(t=this.bufferAfter)==null||t.remove(),this.bufferAfter=void 0,(n=this.codeUnified)==null||n.remove(),this.codeUnified=void 0,(r=this.codeDeletions)==null||r.remove(),this.codeDeletions=void 0,(i=this.codeAdditions)==null||i.remove(),this.codeAdditions=void 0,(s=this.pre)==null||s.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){var e;for(const{element:t}of this.separatorCache.values())t.remove();this.separatorCache.clear();for(const{element:t}of this.annotationCache.values())t.remove();this.annotationCache.clear(),(e=this.gutterUtilityContent)==null||e.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.cleanChildNodes(),this.placeHolder==null){const t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}cleanChildNodes(){var e,t,n,r,i,s,a,l,u,d,p,f,v,_,y;this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),(e=this.bufferAfter)==null||e.remove(),(t=this.bufferBefore)==null||t.remove(),(n=this.codeAdditions)==null||n.remove(),(r=this.codeDeletions)==null||r.remove(),(i=this.codeUnified)==null||i.remove(),(s=this.errorWrapper)==null||s.remove(),(a=this.headerElement)==null||a.remove(),(l=this.gutterUtilityContent)==null||l.remove(),(u=this.headerPrefix)==null||u.remove(),(d=this.headerMetadata)==null||d.remove(),(p=this.headerCustom)==null||p.remove(),(f=this.pre)==null||f.remove(),(v=this.spriteSVG)==null||v.remove(),(_=this.themeCSSStyle)==null||_.remove(),(y=this.unsafeCSSStyle)==null||y.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.gutterUtilityContent=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0}renderSeparators(e){const{hunkSeparators:t}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof t!="function"){for(const{element:r}of this.separatorCache.values())r.remove();this.separatorCache.clear();return}const n=new Map(this.separatorCache);for(const r of e){const i=r.slotName;let s=this.separatorCache.get(i);if(s==null||!qce(r,s.hunkData)){s==null||s.element.remove();const a=document.createElement("div");a.style.display="contents",a.slot=r.slotName;const l=t(r,this);l!=null&&a.appendChild(l),this.fileContainer.appendChild(a),s={element:a,hunkData:r},this.separatorCache.set(i,s)}n.delete(i)}for(const[r,{element:i}]of n.entries())this.separatorCache.delete(r),i.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(const{element:n}of this.annotationCache.values())n.remove();this.annotationCache.clear();return}const e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(const[n,r]of this.lineAnnotations.entries()){const i=`${n}-${xh(r)}`;let s=this.annotationCache.get(i);if(s==null||!Gce(r,s.annotation)){s==null||s.element.remove();const a=t(r);if(a==null)continue;s={element:wce(xh(r)),annotation:r},s.element.appendChild(a),this.fileContainer.appendChild(s.element),this.annotationCache.set(i,s)}e.delete(i)}for(const[n,{element:r}]of e.entries())this.annotationCache.delete(n),r.remove()}renderGutterUtility(){var r,i;const e=this.options.renderGutterUtility??this.options.renderHoverUtility;if(this.fileContainer==null||e==null){(r=this.gutterUtilityContent)==null||r.remove(),this.gutterUtilityContent=void 0;return}const t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){(i=this.gutterUtilityContent)==null||i.remove(),this.gutterUtilityContent=void 0;return}const n=Sce();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){var r;const n=this.fileContainer;if(this.fileContainer=e??this.fileContainer??document.createElement(dg),n!=null&&n!==this.fileContainer&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),this.spriteSVG==null){const i=document.createElement("div");i.innerHTML=bce;const s=i.firstChild;s instanceof SVGElement&&(this.spriteSVG=s,(r=this.fileContainer.shadowRoot)==null||r.appendChild(this.spriteSVG))}return this.fileContainer}getFileContainer(){return this.fileContainer}getOrCreatePreNode(e){var n;const t=e.shadowRoot??e.attachShadow({mode:"open"});return this.pre==null?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(t.appendChild(this.pre),this.appliedPreAttributes=void 0),(n=this.placeHolder)==null||n.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(const t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute("data-unified")?this.codeUnified=t:t.hasAttribute("data-deletions")?this.codeDeletions=t:t.hasAttribute("data-additions")&&(this.codeAdditions=t))}applyHeaderToDOM(e,t){var d,p,f,v,_,y;this.cleanupErrorWrapper(),(d=this.placeHolder)==null||d.remove(),this.placeHolder=void 0;const{fileDiff:n}=this,r=Kc(e);if(r!==this.lastRenderedHeaderHTML){const w=document.createElement("div");w.innerHTML=r;const k=w.firstElementChild;if(!(k instanceof HTMLElement))return;this.headerElement!=null?(p=t.shadowRoot)==null||p.replaceChild(k,this.headerElement):(f=t.shadowRoot)==null||f.prepend(k),this.headerElement=k,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged||n==null)return;const{renderCustomHeader:i,renderHeaderPrefix:s,renderHeaderMetadata:a}=this.options;if(i!=null){const w=i(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,TS,w),(v=this.headerPrefix)==null||v.remove(),(_=this.headerMetadata)==null||_.remove(),this.headerPrefix=void 0,this.headerMetadata=void 0;return}const l=(s==null?void 0:s(n))??void 0,u=(a==null?void 0:a(n))??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,ES,l),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,RS,u),(y=this.headerCustom)==null||y.remove(),this.headerCustom=void 0}clearHeaderSlots(){var e,t,n;(e=this.headerPrefix)==null||e.remove(),(t=this.headerMetadata)==null||t.remove(),(n=this.headerCustom)==null||n.remove(),this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t==null||t.remove();return}const i=t??this.createHeaderSlotElement(n);return t==null&&e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){const t=document.createElement("div");return t.slot=e,t}injectUnsafeCSS(){var n,r;const{unsafeCSS:e}=this.options,t=(n=this.fileContainer)==null?void 0:n.shadowRoot;if(t!=null){if(e==null||e===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}((r=this.unsafeCSSStyle)==null?void 0:r.parentNode)===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??(this.unsafeCSSStyle=Cce()),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=Ece(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){var a,l;const i=e.shadowRoot??e.attachShadow({mode:"open"}),s=r??n;((a=this.themeCSSStyle)==null?void 0:a.parentNode)===i&&((l=this.appliedThemeCSS)==null?void 0:l.themeStyles)===t&&this.appliedThemeCSS.themeType===s||(this.themeCSSStyle=Tce({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:Rce(t,s)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{themeStyles:t,themeType:s,baseThemeType:r}:void 0)}applyHunksToDOM(e,t){var p,f,v,_,y,w,k,C,E;const{overflow:n="scroll"}=this.options,r=(this.options.hunkSeparators??"line-info")==="line-info",i=n==="wrap"?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let s=!1;const a=[],l=this.hunksRenderer.renderCodeAST("unified",t),u=this.hunksRenderer.renderCodeAST("deletions",t),d=this.hunksRenderer.renderCodeAST("additions",t);l!=null?(s=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,(p=this.codeDeletions)==null||p.remove(),this.codeDeletions=void 0,(f=this.codeAdditions)==null||f.remove(),this.codeAdditions=void 0,this.codeUnified=hy({code:this.codeUnified,columnType:"unified",rowSpan:i,containerSize:r}),this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(l),a.push(this.codeUnified)):u!=null||d!=null?(u!=null?(s=this.codeDeletions==null||this.codeUnified!=null,(v=this.codeUnified)==null||v.remove(),this.codeUnified=void 0,this.codeDeletions=hy({code:this.codeDeletions,columnType:"deletions",rowSpan:i,containerSize:r}),this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(u),a.push(this.codeDeletions)):((_=this.codeDeletions)==null||_.remove(),this.codeDeletions=void 0),d!=null?(s=s||this.codeAdditions==null||this.codeUnified!=null,(y=this.codeUnified)==null||y.remove(),this.codeUnified=void 0,this.codeAdditions=hy({code:this.codeAdditions,columnType:"additions",rowSpan:i,containerSize:r}),this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(d),a.push(this.codeAdditions)):((w=this.codeAdditions)==null||w.remove(),this.codeAdditions=void 0)):((k=this.codeUnified)==null||k.remove(),this.codeUnified=void 0,(C=this.codeDeletions)==null||C.remove(),this.codeDeletions=void 0,(E=this.codeAdditions)==null||E.remove(),this.codeAdditions=void 0),a.length===0?e.textContent="":s&&e.replaceChildren(...a),this.lastRowCount=t.rowCount}applyPartialRender({previousRenderRange:e,renderRange:t}){const{pre:n,codeUnified:r,codeAdditions:i,codeDeletions:s,options:{diffStyle:a="split"}}=this;if(n==null||e==null||t==null||!Number.isFinite(e.totalLines)||!Number.isFinite(t.totalLines)||this.lastRowCount==null)return!1;const l=this.getCodeColumns(a,r,s,i);if(l==null)return!1;const u=e.startingLine,d=t.startingLine,p=u+e.totalLines,f=d+t.totalLines,v=Math.max(u,d),_=Math.min(p,f);if(_<=v)return!1;const y=Math.max(0,v-u),w=Math.max(0,p-_),k=this.trimColumns({columns:l,trimStart:y,trimEnd:w,previousStart:u,overlapStart:v,overlapEnd:_,diffStyle:a});if(k<0)throw new Error("applyPartialRender: failed to trim to overlap");if(this.lastRowCount<k)throw new Error("applyPartialRender: trimmed beyond DOM row count");let C=this.lastRowCount-k;const E=(M,L)=>{if(!(L<=0||this.fileDiff==null))return this.hunksRenderer.renderDiff(this.fileDiff,{startingLine:M,totalLines:L,bufferBefore:0,bufferAfter:0})},R=E(d,Math.max(v-d,0));if(R==null&&d<v)return!1;const T=E(_,Math.max(f-_,0));if(T==null&&f>_)return!1;const N=(M,L)=>{if(M!=null){if(a==="unified"&&!Array.isArray(l))this.insertPartialHTML(a,l,M,L);else if(a==="split"&&Array.isArray(l))this.insertPartialHTML(a,l,M,L);else throw new Error("FileDiff.applyPartialRender.applyChunk: invalid chunk application");C+=M.rowCount}};return this.cleanupErrorWrapper(),N(R,"afterbegin"),N(T,"beforeend"),this.lastRowCount!==C&&(this.applyRowSpan(a,l,C),this.lastRowCount=C),!0}insertPartialHTML(e,t,n,r){if(e==="unified"&&!Array.isArray(t)){const i=this.hunksRenderer.renderCodeAST("unified",n);this.renderPartialColumn(t,i,r)}else if(e==="split"&&Array.isArray(t)){const i=this.hunksRenderer.renderCodeAST("deletions",n),s=this.hunksRenderer.renderCodeAST("additions",n);this.renderPartialColumn(t[0],i,r),this.renderPartialColumn(t[1],s,r)}else throw new Error("FileDiff.insertPartialHTML: Invalid argument composition")}renderPartialColumn(e,t,n){if(e==null||t==null)return;const r=HN(t[0]),i=HN(t[1]);if(r==null||i==null)throw new Error("FileDiff.insertPartialHTML: Unexpected AST structure");const s=i.at(0);n==="beforeend"&&(s==null?void 0:s.type)==="element"&&typeof s.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(s.properties["data-buffer-size"],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);const a=i.at(-1);n==="afterbegin"&&(a==null?void 0:a.type)==="element"&&typeof a.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(a.properties["data-buffer-size"],e.content.children[0],e.gutter.children[0],r,i,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,s){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;const a=this.getBufferSize(t.dataset);a!=null&&(s?(r.shift(),i.shift()):(r.pop(),i.pop()),this.updateBufferSize(t,a+e),this.updateBufferSize(n,a+e))}applyRowSpan(e,t,n){const r=i=>{i!=null&&(i.gutter.style.setProperty("grid-row",`span ${n}`),i.content.style.setProperty("grid-row",`span ${n}`))};if(e==="unified"&&!Array.isArray(t))r(t);else if(e==="split"&&Array.isArray(t))r(t[0]),r(t[1]);else throw new Error("dun fuuuuked up")}trimColumnRows(e,t,n){let r=0,i=0,s=0,a=!1;const l=n>=0;if(e==null)return 0;const u=Array.from(e.content.children),d=Array.from(e.gutter.children);if(u.length!==d.length)throw new Error("FileDiff.trimColumnRows: columns do not match");for(;s<u.length&&!(t<=0&&!l&&!a);){const p=d[s],f=u[s];if(s++,!(p instanceof HTMLElement)||!(f instanceof HTMLElement))throw console.error({gutterElement:p,contentElement:f}),new Error("FileDiff.trimColumnRows: invalid row elements");if(a&&(a=!1,p.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in f.dataset||p.dataset.gutterBuffer==="metadata"&&"noNewline"in f.dataset)){p.remove(),f.remove(),i++;continue}if("lineIndex"in p.dataset&&"lineIndex"in f.dataset){(t>0||l&&r>=n)&&(p.remove(),f.remove(),t>0&&(t--,t===0&&(a=!0)),i++),r++;continue}if("separator"in p.dataset&&"separator"in f.dataset){(t>0||l&&r>=n)&&(p.remove(),f.remove(),i++);continue}if(p.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in f.dataset){(t>0||l&&r>=n)&&(p.remove(),f.remove(),i++);continue}if(p.dataset.gutterBuffer==="metadata"&&"noNewline"in f.dataset){(t>0||l&&r>=n)&&(p.remove(),f.remove(),i++);continue}if(p.dataset.gutterBuffer==="buffer"&&"contentBuffer"in f.dataset){const v=this.getBufferSize(f.dataset);if(v==null)throw new Error("FileDiff.trimColumnRows: invalid element");if(t>0){const _=Math.min(t,v),y=v-_;y>0?(this.updateBufferSize(p,y),this.updateBufferSize(f,y),i+=_):(p.remove(),f.remove(),i+=v),t-=_}else if(l){const _=r,y=r+v-1;if(n<=_)p.remove(),f.remove(),i+=v;else if(n<=y){const w=y-n+1,k=v-w;this.updateBufferSize(p,k),this.updateBufferSize(f,k),i+=w}}r+=v;continue}throw console.error({gutterElement:p,contentElement:f}),new Error("FileDiff.trimColumnRows: unknown row elements")}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:s,trimStart:a}){const l=Math.max(0,r-i),u=n-i;if(u<0)throw new Error("FileDiff.trimColumns: overlap ends before previous");const d=a>0,p=s>0;if(!d&&!p)return 0;const f=d?l:0,v=p?u:-1;if(t==="unified"&&!Array.isArray(e))return this.trimColumnRows(e,f,v);if(t==="split"&&Array.isArray(e)){const _=this.trimColumnRows(e[0],f,v),y=this.trimColumnRows(e[1],f,v);if(e[0]!=null&&e[1]!=null&&_!==y)throw new Error("FileDiff.trimColumns: split columns out of sync");return e[0]!=null?_:y}else throw console.error({diffStyle:t,columns:e}),new Error("FileDiff.trimColumns: Invalid columns for diffType")}getBufferSize(e){const t=Number.parseInt((e==null?void 0:e.bufferSize)??"",10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty("grid-row",`span ${t}`),e.style.setProperty("min-height",`calc(${t} * 1lh)`)}getCodeColumns(e,t,n,r){function i(s){if(s==null)return;const a=s.children[0],l=s.children[1];if(!(!(a instanceof HTMLElement)||!(l instanceof HTMLElement)||a.dataset.gutter==null||l.dataset.content==null))return{gutter:a,content:l}}if(e==="unified")return i(t);{const s=i(n),a=i(r);return s!=null||a!=null?[s,a]:void 0}}applyBuffers(e,t){const{disableVirtualizationBuffers:n=!1}=this.options;if(n||t==null){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:r},i){const{diffIndicators:s="bars",disableBackground:a=!1,disableLineNumbers:l=!1,overflow:u="scroll",diffStyle:d="split"}=this.options,p={type:"diff",diffIndicators:s,disableBackground:a,disableLineNumbers:l,overflow:u,split:d==="unified"?!1:t!=null&&n!=null,totalLines:r,customProperties:i};yce(p,this.appliedPreAttributes)||(Mce(e,p),this.appliedPreAttributes=p)}applyErrorToDOM(e,t){this.cleanupErrorWrapper();const n=this.getOrCreatePreNode(t);n.innerHTML="",n.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const r=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??(this.errorWrapper=document.createElement("div")),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.innerHTML="",r.appendChild(this.errorWrapper);const i=document.createElement("div");i.dataset.errorMessage="",i.innerText=e.message,this.errorWrapper.appendChild(i);const s=document.createElement("pre");s.dataset.errorStack="",s.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(s)}cleanupErrorWrapper(){var e;(e=this.errorWrapper)==null||e.remove(),this.errorWrapper=void 0}},Y($y,"LoadedCustomComponent",Lce),$y);function HN(e){if(!(e==null||e.type!=="element"))return e.children??[]}function Zce(e,t){const n={...Cre,...t};return n.hunkSeparatorHeight=Jce(e,t==null?void 0:t.hunkSeparatorHeight),n}function Jce(e,t){if(t!=null)return t;switch(e){case"simple":return 4;case"metadata":case"line-info":case"line-info-basic":case"custom":return 32}}let eue=-1;var tue=class extends nj{constructor(t,n,r,i,s=!1){super(t,i,s);Y(this,"__id",`little-virtualized-file-diff:${++eue}`);Y(this,"top");Y(this,"height",0);Y(this,"metrics");Y(this,"heightCache",new Map);Y(this,"isVisible",!1);Y(this,"virtualizer");Y(this,"onRender",t=>this.fileContainer==null?!1:(t&&(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer)),this.render()));Y(this,"expandHunk",(t,n,r)=>{this.hunksRenderer.expandHunk(t,n,r),this.computeApproximateSize(),this.renderRange=void 0,this.virtualizer.instanceChanged(this)});const{hunkSeparators:a="line-info"}=this.options;this.virtualizer=n,this.metrics=Zce(typeof a=="function"?"custom":a,r)}getLineHeight(t,n=!1){const r=this.heightCache.get(t);if(r!=null)return r;const i=n?2:1;return this.metrics.lineHeight*i}setOptions(t){if(t==null)return;const n=this.options.diffStyle,r=this.options.overflow,i=this.options.collapsed;super.setOptions(t),(n!==this.options.diffStyle||r!==this.options.overflow||i!==this.options.collapsed)&&(this.heightCache.clear(),this.computeApproximateSize(),this.renderRange=void 0),this.virtualizer.instanceChanged(this)}reconcileHeights(){const{overflow:t="scroll"}=this.options;if(this.fileContainer!=null&&(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer)),this.fileContainer==null||this.fileDiff==null){this.height=0;return}if(t==="scroll"&&this.lineAnnotations.length===0&&!this.virtualizer.config.resizeDebugging)return;const n=this.getDiffStyle();let r=!1;const i=n==="split"?[this.codeDeletions,this.codeAdditions]:[this.codeUnified];for(const s of i){if(s==null)continue;const a=s.children[1];if(a instanceof HTMLElement)for(const l of a.children){if(!(l instanceof HTMLElement))continue;const u=l.dataset.lineIndex;if(u==null)continue;const d=rue(u,n);let p=l.getBoundingClientRect().height,f=!1;l.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in l.nextElementSibling.dataset||"noNewline"in l.nextElementSibling.dataset)&&("noNewline"in l.nextElementSibling.dataset&&(f=!0),p+=l.nextElementSibling.getBoundingClientRect().height);const v=this.getLineHeight(d,f);p!==v&&(r=!0,p===this.metrics.lineHeight*(f?2:1)?this.heightCache.delete(d):this.heightCache.set(d,p))}}(r||this.virtualizer.config.resizeDebugging)&&this.computeApproximateSize()}cleanUp(){this.fileContainer!=null&&this.virtualizer.disconnect(this.fileContainer),super.cleanUp()}setVisibility(t){this.fileContainer!=null&&(this.renderRange=void 0,t&&!this.isVisible?(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer),this.isVisible=!0):!t&&this.isVisible&&(this.isVisible=!1,this.rerender()))}computeApproximateSize(){const t=this.height===0;if(this.height=0,this.fileDiff==null)return;const{disableFileHeader:n=!1,expandUnchanged:r=!1,collapsed:i=!1,collapsedContextThreshold:s=Gc,hunkSeparators:a="line-info"}=this.options,{diffHeaderHeight:l,fileGap:u,hunkSeparatorHeight:d}=this.metrics,p=this.getDiffStyle(),f=a!=="simple"&&a!=="metadata"&&a!=="line-info-basic"?u:0;if(n?a!=="simple"&&a!=="metadata"&&(this.height+=u):this.height+=l,!i&&(Cg({diff:this.fileDiff,diffStyle:p,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:s,callback:({hunkIndex:v,collapsedBefore:_,collapsedAfter:y,deletionLine:w,additionLine:k})=>{const C=k!=null?k.splitLineIndex:w.splitLineIndex,E=k!=null?k.unifiedLineIndex:w.unifiedLineIndex,R=((k==null?void 0:k.noEOFCR)??!1)||((w==null?void 0:w.noEOFCR)??!1);_>0&&(v>0&&(this.height+=f),this.height+=d+f),this.height+=this.getLineHeight(p==="split"?C:E,R),y>0&&a!=="simple"&&(this.height+=f+d)}}),this.fileDiff.hunks.length>0&&(this.height+=u),this.fileContainer!=null&&this.virtualizer.config.resizeDebugging&&!t)){const v=this.fileContainer.getBoundingClientRect();v.height!==this.height?console.log("VirtualizedFileDiff.computeApproximateSize: computed height doesnt match",{name:this.fileDiff.name,elementHeight:v.height,computedHeight:this.height}):console.log("VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT")}}render({fileContainer:t,oldFile:n,newFile:r,fileDiff:i,...s}={}){const a=this.fileContainer==null;if(this.fileDiff??(this.fileDiff=i??(n!=null&&r!=null?Yx(n,r,this.options.parseDiffOptions):void 0)),t=this.getOrCreateFileContainer(t),this.fileDiff==null)return console.error("VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data"),!1;if(a?(this.computeApproximateSize(),this.virtualizer.connect(t,this),this.top??(this.top=this.virtualizer.getOffsetInScrollContainer(t)),this.isVisible=this.virtualizer.isInstanceVisible(this.top,this.height)):this.top??(this.top=this.virtualizer.getOffsetInScrollContainer(t)),!this.isVisible)return this.renderPlaceholder(this.height);const l=this.virtualizer.getWindowSpecs(),u=this.computeRenderRangeFromWindow(this.fileDiff,this.top,l);return super.render({fileDiff:this.fileDiff,fileContainer:t,renderRange:u,oldFile:n,newFile:r,...s})}getDiffStyle(){return this.options.diffStyle??"split"}getExpandedRegion(t,n,r){if(r<=0||t)return{fromStart:0,fromEnd:0,collapsedLines:Math.max(r,0),renderAll:!1};const{expandUnchanged:i=!1,collapsedContextThreshold:s=Gc}=this.options;if(i||r<=s)return{fromStart:r,fromEnd:0,collapsedLines:0,renderAll:!0};const a=this.hunksRenderer.getExpandedHunk(n),l=Math.min(Math.max(a.fromStart,0),r),u=Math.min(Math.max(a.fromEnd,0),r),d=l+u,p=d>=r;return{fromStart:l,fromEnd:u,collapsedLines:Math.max(r-d,0),renderAll:p}}getExpandedLineCount(t,n){let r=0;if(t.isPartial){for(const s of t.hunks)r+=n==="split"?s.splitLineCount:s.unifiedLineCount;return r}for(const[s,a]of t.hunks.entries()){const l=n==="split"?a.splitLineCount:a.unifiedLineCount;r+=l;const u=Math.max(a.collapsedBefore,0),{fromStart:d,fromEnd:p,renderAll:f}=this.getExpandedRegion(t.isPartial,s,u);u>0&&(r+=f?u:d+p)}const i=t.hunks.at(-1);if(i!=null&&nue(t)){const s=t.additionLines.length-(i.additionLineIndex+i.additionCount),a=t.deletionLines.length-(i.deletionLineIndex+i.deletionCount);if(i!=null&&s!==a)throw new Error(`VirtualizedFileDiff: trailing context mismatch (additions=${s}, deletions=${a}) for ${t.name}`);const l=Math.min(s,a);if(i!=null&&l>0){const{fromStart:u,renderAll:d}=this.getExpandedRegion(t.isPartial,t.hunks.length,l);r+=d?l:u}}return r}computeRenderRangeFromWindow(t,n,{top:r,bottom:i}){const{disableFileHeader:s=!1,expandUnchanged:a=!1,collapsedContextThreshold:l=Gc,hunkSeparators:u="line-info"}=this.options,{diffHeaderHeight:d,fileGap:p,hunkLineCount:f,hunkSeparatorHeight:v,lineHeight:_}=this.metrics,y=this.getDiffStyle(),w=this.height,k=this.getExpandedLineCount(t,y),C=s?p:d;if(n<r-w||n>i)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:w-C-p};if(k<=f||t.hunks.length===0)return{startingLine:0,totalLines:f,bufferBefore:0,bufferAfter:0};const E=Math.ceil(Math.max(i-r,0)/_),R=Math.ceil(E/f)*f+f,T=R/f,N=T,M=[],L=(r+i)/2,O=u==="simple"||u==="metadata"||u==="line-info-basic"?0:p;let $=n+C,I=0,B,j,V;if(Cg({diff:t,diffStyle:y,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:l,callback:({hunkIndex:Z,collapsedBefore:z,collapsedAfter:oe,deletionLine:ue,additionLine:ne})=>{const de=ne!=null?ne.splitLineIndex:ue.splitLineIndex,be=ne!=null?ne.unifiedLineIndex:ue.unifiedLineIndex,re=((ne==null?void 0:ne.noEOFCR)??!1)||((ue==null?void 0:ue.noEOFCR)??!1);let ge=z>0?v+O+(Z>0?O:0):0;Z===0&&u==="simple"&&(ge=0),$+=ge;const pe=I%f===0;if(pe&&(M.push($-(n+C+ge)),V!=null)){if(V<=0)return!0;V--}const Ee=this.getLineHeight(y==="split"?de:be,re),Re=Math.floor(I/f);return $>r-Ee&&$<i&&(B??(B=Re)),j==null&&$+Ee>L&&(j=Re),V==null&&$>=i&&pe&&(V=N),I++,$+=Ee,oe>0&&u!=="simple"&&($+=v+O),!1}}),B==null)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:w-C-p};const F=M.length;j??(j=B);const W=Math.round(j-T/2),P=Math.max(0,F-T),K=Math.max(0,Math.min(W,P)),U=K*f,X=W<0?R+W*f:R,D=M[K]??0,G=K+X/f;return{startingLine:U,totalLines:X,bufferBefore:D,bufferAfter:G<M.length?w-C-M[G]-p:w-($-n)-p}}};function nue(e){const t=e.hunks.at(-1);return t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0?!1:t.additionLineIndex+t.additionCount<e.additionLines.length||t.deletionLineIndex+t.deletionCount<e.deletionLines.length}function rue(e,t){const[n,r]=e.split(",").map(Number);return t==="split"?r:n}const iue=typeof window>"u"?b.useEffect:b.useLayoutEffect;function sue({fileDiff:e,options:t,lineAnnotations:n,selectedLines:r,prerenderedHTML:i,metrics:s,hasGutterRenderUtility:a,hasCustomHeader:l,disableWorkerPool:u}){const d=Are(),p=b.useContext(Jle),f=b.useRef(null),v=ece(_=>{if(_!=null){if(f.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");d!=null?f.current=new tue(gy({hasCustomHeader:l,hasGutterRenderUtility:a,options:t}),d,s,u?void 0:p,!0):f.current=new nj(gy({hasCustomHeader:l,hasGutterRenderUtility:a,options:t}),u?void 0:p,!0),f.current.hydrate({fileDiff:e,fileContainer:_,lineAnnotations:n,prerenderedHTML:i})}else{if(f.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");f.current.cleanUp(),f.current=null}});return iue(()=>{const{current:_}=f;if(_==null)return;const y=gy({hasCustomHeader:l,hasGutterRenderUtility:a,options:t}),w=!Dce(_.options,y);_.setOptions(y),_.render({forceRender:w,fileDiff:e,lineAnnotations:n}),r!==void 0&&_.setSelectedLines(r)}),{ref:v,getHoveredLine:b.useCallback(()=>{var _;return(_=f.current)==null?void 0:_.getHoveredLine()},[])}}function gy({options:e,hasCustomHeader:t,hasGutterRenderUtility:n}){return n||t?{...e,renderCustomHeader:t?AA:void 0,renderGutterUtility:n?AA:void 0}:e}function oue(e){const t=Xce(e);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=t[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function aue({patch:e,options:t,metrics:n,lineAnnotations:r,selectedLines:i,className:s,style:a,prerenderedHTML:l,renderAnnotation:u,renderCustomHeader:d,renderHeaderPrefix:p,renderHeaderMetadata:f,renderGutterUtility:v,renderHoverUtility:_,disableWorkerPool:y=!1}){const w=lue(e),{ref:k,getHoveredLine:C}=sue({fileDiff:w,options:t,metrics:n,lineAnnotations:r,selectedLines:i,prerenderedHTML:l,hasGutterRenderUtility:v!=null||_!=null,hasCustomHeader:d!=null,disableWorkerPool:y});return m.jsx(dg,{ref:k,className:s,style:a,children:Rre(jce({fileDiff:w,renderCustomHeader:d,renderHeaderPrefix:p,renderHeaderMetadata:f,renderAnnotation:u,lineAnnotations:r,renderGutterUtility:v,renderHoverUtility:_,getHoveredLine:C}),l)})}function lue(e){return b.useMemo(()=>oue(e),[e])}function cue({rootRef:e,disabled:t=!1}){const n=b.useRef(null),[r,i]=b.useState(!1);return b.useEffect(()=>{if(t){i(!1);return}const s=e.current,a=n.current;if(!s||!a)return;const l=new IntersectionObserver(([u])=>{i(u.intersectionRatio<1)},{root:s,threshold:[1]});return l.observe(a),()=>l.disconnect()},[t,e]),{sentinelRef:n,isStuck:r}}const Qp=wa()(Sa(e=>({checkedPathsByProjectId:{},reconcileProject:(t,n)=>e(r=>{const i=r.checkedPathsByProjectId[t]??{},s=Object.fromEntries(n.map(a=>[a,i[a]??!0]));return Object.keys(i).length===Object.keys(s).length&&Object.entries(s).every(([a,l])=>i[a]===l)?r:{checkedPathsByProjectId:{...r.checkedPathsByProjectId,[t]:s}}}),setChecked:(t,n,r)=>e(i=>({checkedPathsByProjectId:{...i.checkedPathsByProjectId,[t]:{...i.checkedPathsByProjectId[t]??{},[n]:r}}})),setAllChecked:(t,n,r)=>e(i=>({checkedPathsByProjectId:{...i.checkedPathsByProjectId,[t]:{...i.checkedPathsByProjectId[t]??{},...Object.fromEntries(n.map(s=>[s,r]))}}}))}),{name:"diff-commit-selections",version:2})),kg=20,rj=30,uue=370;function ij(e){return Number.isFinite(e)?Math.max(kg,e):rj}function due(){return{isVisible:!1,size:kg}}function Td(){return{viewMode:"history",collapsedPaths:{},summary:"",description:""}}function vy(e,t){return e[t]??due()}function hue(e){return!e||typeof e!="object"?{projects:{},projectUi:{}}:{projects:Object.fromEntries(Object.entries(e.projects??{}).map(([r,i])=>[r,{isVisible:!1,size:ij(i.size??rj)}])),projectUi:{}}}const si=wa()(Sa(e=>({projects:{},projectUi:{},toggleVisibility:t=>e(n=>({projects:{...n.projects,[t]:{...vy(n.projects,t),isVisible:!vy(n.projects,t).isVisible}}})),setSize:(t,n)=>e(r=>({projects:{...r.projects,[t]:{...vy(r.projects,t),size:ij(n)}}})),reconcileCollapsedPaths:(t,n)=>e(r=>{const i=r.projectUi[t]??Td(),s=Object.fromEntries(n.map(a=>[a,i.collapsedPaths[a]??!0]));return Object.keys(i.collapsedPaths).length===Object.keys(s).length&&Object.entries(s).every(([a,l])=>i.collapsedPaths[a]===l)?r:{projectUi:{...r.projectUi,[t]:{...i,collapsedPaths:s}}}}),toggleCollapsedPath:(t,n)=>e(r=>{const i=r.projectUi[t]??Td();return{projectUi:{...r.projectUi,[t]:{...i,collapsedPaths:{...i.collapsedPaths,[n]:!(i.collapsedPaths[n]??!0)}}}}}),setViewMode:(t,n)=>e(r=>{const i=r.projectUi[t]??Td();return i.viewMode===n?r:{projectUi:{...r.projectUi,[t]:{...i,viewMode:n}}}}),setCommitDraft:(t,n)=>e(r=>{const i=r.projectUi[t]??Td();return i.summary===n.summary&&i.description===n.description?r:{projectUi:{...r.projectUi,[t]:{...i,summary:n.summary,description:n.description}}}}),clearCommitDraft:t=>e(n=>{const r=n.projectUi[t]??Td();return!r.summary&&!r.description?n:{projectUi:{...n.projectUi,[t]:{...r,summary:"",description:""}}}}),clearProject:t=>e(n=>{const{[t]:r,...i}=n.projects,{[t]:s,...a}=n.projectUi;return{projects:i,projectUi:a}})}),{name:"right-sidebar-layouts",version:3,migrate:hue})),fue={isVisible:!1,size:33},pue={sm:"text-sm px-2.5 py-1",md:"text-sm px-3 py-1.5"};function Dv({value:e,onValueChange:t,options:n,size:r="md",className:i,optionClassName:s}){return m.jsx("div",{className:Ce("inline-flex items-center rounded-lg border border-border p-[3px] ",i),children:n.map(a=>{const l=a.value===e,u=a.icon,d=u?b.isValidElement(u)?u:(()=>{const f=u;return m.jsx(f,{className:r==="sm"?"h-3.5 w-3.5":"h-4 w-4"})})():null,p=m.jsxs("button",{type:"button",onClick:()=>t(a.value),disabled:a.disabled,"aria-pressed":l,className:Ce("rounded-[4px] border transition-colors",u?"grid grid-cols-[auto_auto] items-center gap-2":"inline-flex items-center",pue[r],l?"bg-white dark:bg-muted text-slate-900 dark:text-slate-200 border-slate-300 dark:border-white/10 bg-slate-200 ":"border-transparent text-slate-800 hover:text-slate-900 dark:text-muted-foreground dark:hover:text-foreground",a.disabled&&"opacity-50 pointer-events-none",s),children:[d,m.jsx("span",{children:a.label})]},a.value);return a.tooltip?m.jsxs(gl,{children:[m.jsx(vl,{asChild:!0,children:p}),m.jsx(_a,{children:a.tooltip})]},a.value):p})})}const Zp={};function mue(e,t){return!e||!t.mimeType||typeof t.size!="number"||t.changeType==="deleted"||!t.mimeType.startsWith("image/")&&t.mimeType!=="application/pdf"?null:{id:`diff:${t.path}`,kind:t.mimeType.startsWith("image/")?"image":"file",displayName:t.path.split("/").pop()??t.path,absolutePath:t.path,relativePath:t.path,contentUrl:`/api/projects/${e}/files/${encodeURIComponent(t.path)}/content`,mimeType:t.mimeType,size:t.size}}function gue(e){return e.isUntracked}function _y(e){return m.jsxs(gl,{delayDuration:0,children:[m.jsx(vl,{asChild:!0,children:m.jsx("button",{type:"button","aria-label":e.label,title:e.label,onClick:e.onClick,className:Ce("flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",e.active&&"bg-accent text-foreground"),children:e.children})}),m.jsx(_a,{children:e.label})]})}function sj({checked:e,mixed:t=!1,label:n,className:r,onClick:i}){return m.jsx("button",{type:"button","aria-label":n??(e?"Exclude file from commit":"Include file in commit"),"aria-checked":t?"mixed":e,"aria-pressed":t?"mixed":e,onClick:s=>{s.stopPropagation(),i()},className:Ce("flex size-4.5 shrink-0 items-center justify-center rounded border transition-colors",e||t?"border-foreground bg-foreground text-background":"border-border bg-background text-transparent",r),children:t?m.jsx(jF,{className:"h-3 w-3",strokeWidth:3}):e?m.jsx(Rs,{className:"h-3 w-3",strokeWidth:3}):null})}function US(e){const t=Date.parse(e);if(!Number.isFinite(t))return"";const n=Date.now()-t,r=6e4,i=60*r,s=24*i,a=7*s,l=30*s,u=365*s;return n<r?"just now":n<i?`${Math.round(n/r)}m ago`:n<s?`${Math.round(n/i)}hr ago`:n<a?`${Math.round(n/s)}d ago`:n<l?`${Math.round(n/a)}wk ago`:n<u?`${Math.round(n/l)}mo ago`:`${Math.round(n/u)}yr ago`}function vue(e){return e?`Last fetched ${US(e)}`:"No local fetch recorded"}function _ue({entry:e,isPendingPush:t=!1}){const n=US(e.authoredAt),r=!!e.githubUrl;return m.jsxs("button",{type:"button",disabled:!r,onClick:()=>{!e.githubUrl||typeof window>"u"||window.open(e.githubUrl,"_blank","noopener,noreferrer")},className:Ce("flex w-full items-start gap-3 rounded-lg border border-border bg-background pl-3 pr-2 py-2 text-left transition-colors",r?"hover:bg-accent":"cursor-default opacity-60"),children:[m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:e.summary}),e.description?m.jsx("div",{className:"mt-1 line-clamp-2 whitespace-pre-wrap text-xs text-muted-foreground",children:e.description}):null,m.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-1 text-xs text-muted-foreground",children:[e.authorName?m.jsx("span",{className:"truncate",children:e.authorName}):null,e.authorName&&n?m.jsx("span",{"aria-hidden":"true",children:"•"}):null,n?m.jsx("span",{children:n}):null]})]}),e.tags.length>0?m.jsxs("div",{className:"flex shrink-0 flex-wrap justify-end gap-1",children:[e.tags.map(i=>m.jsx("span",{className:"inline-flex items-center rounded-sm border border-text-muted-foreground px-2 py-0.5 text-[11px] text-muted-foreground",children:i},i)),t?m.jsx("span",{className:"inline-flex items-center rounded-sm border border-text-muted-foreground px-2 py-0.5 text-[11px] text-muted-foreground",children:m.jsx(qy,{className:"size-3"})}):null]}):t?m.jsx("div",{className:"flex shrink-0 flex-wrap justify-end gap-1",children:m.jsx("span",{className:"inline-flex items-center rounded-sm border border-text-muted-foreground px-2 py-0.5 text-[11px] text-muted-foreground",children:m.jsx(qy,{className:"size-3"})})}):null]})}function $N(e){switch(e.kind){case"local":return 0;case"pull_request":return 1;case"remote":default:return 2}}function bue(e){const t=new Map;for(const n of e){const r=t.get(n.name);(!r||$N(n)<$N(r))&&t.set(n.name,n)}return t}function yue(e,t){const n=bue([...e.local,...e.pullRequests,...e.remote]);t&&n.delete(t);const r=new Set,i=e.defaultBranchName?n.get(e.defaultBranchName):void 0;i&&r.add(i.name);const s=e.recent.map(l=>n.get(l.name)??l).filter(l=>!!l&&!r.has(l.name));for(const l of s)r.add(l.name);const a=[...n.values()].filter(l=>!r.has(l.name)).sort((l,u)=>l.displayName.localeCompare(u.displayName));return{defaultBranch:i,recent:s,other:a}}function oj({value:e,onChange:t,placeholder:n,disabled:r,trailingAction:i}){return m.jsxs("div",{className:"relative",children:[m.jsx(_m,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),m.jsx(bs,{value:e,onChange:s=>t(s.target.value),placeholder:n,className:Ce("h-9 pl-7 text-sm",i?"pr-14":void 0),disabled:r}),i?m.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2",children:i}):null]})}function ol({title:e,entries:t,emptyLabel:n,selectedName:r,disabled:i,stickyTitle:s=!1,onSelect:a}){return t.length===0&&!n?null:m.jsxs("div",{className:"space-y-1",children:[m.jsx("div",{className:Ce("px-1 py-1 text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",s&&"sticky top-0 z-10 bg-background"),children:e}),t.length===0?m.jsx("div",{className:"px-1 py-1 text-xs text-muted-foreground",children:n}):t.map(l=>{const u=r===l.name;return m.jsxs("button",{type:"button",disabled:i,onClick:()=>a(l),className:Ce("flex w-full items-start gap-2 rounded-lg px-2 py-2 text-left transition-colors disabled:opacity-60",u?"bg-accent text-foreground":"hover:bg-accent"),children:[l.kind==="pull_request"?m.jsx(YD,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}):m.jsx(Xd,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("div",{className:"flex w-full items-center gap-3",children:[m.jsx("div",{className:"min-w-0 flex-1 overflow-hidden whitespace-nowrap text-sm text-foreground",children:l.displayName}),l.updatedAt?m.jsx("div",{className:"ml-auto shrink-0 text-right text-[11px] text-muted-foreground",children:US(l.updatedAt)}):null]}),l.kind==="pull_request"&&l.description||l.headLabel?m.jsx("div",{className:"truncate text-xs text-muted-foreground",children:l.kind==="pull_request"?l.description??l.headLabel??l.name:l.headLabel??void 0}):null]})]},l.id)})]})}function xue({open:e,onOpenChange:t,branchList:n,currentBranchName:r,onPreviewMergeBranch:i,onMergeBranch:s}){const[a,l]=b.useState(""),[u,d]=b.useState(null),[p,f]=b.useState(null),[v,_]=b.useState(null),[y,w]=b.useState(!1),[k,C]=b.useState(!1),E=b.useMemo(()=>n?yue(n,r):{defaultBranch:void 0,recent:[],other:[]},[n,r]),R=a.trim().toLowerCase(),T=b.useCallback(B=>R?[B.displayName,B.name,B.description,B.prTitle,B.headLabel].some(j=>j==null?void 0:j.toLowerCase().includes(R)):!0,[R]),N=E.defaultBranch&&T(E.defaultBranch)?E.defaultBranch:void 0,M=E.recent.filter(T),L=E.other.filter(T),O=b.useMemo(()=>u?[E.defaultBranch,...E.recent,...E.other].find(B=>B!==void 0&&B.name===u)??null:null,[E.defaultBranch,E.other,E.recent,u]);b.useEffect(()=>{e||(l(""),d(null),f(null),_(null),w(!1),C(!1))},[e]),b.useEffect(()=>{if(!e||!O){f(null),_(null),w(!1);return}let B=!1;return f(null),_(null),w(!0),i(O).then(j=>{B||f(j)}).catch(j=>{B||_(j instanceof Error?j.message:String(j))}).finally(()=>{B||w(!1)}),()=>{B=!0}},[i,e,O]);const $=!O||!p||y||k||p.status!=="mergeable";async function I(){if(!(!O||$)){C(!0);try{const B=await s(O);B!=null&&B.ok&&t(!1)}finally{C(!1)}}}return m.jsx(qg,{open:e,onOpenChange:t,children:m.jsxs(zh,{size:"sm",className:"max-w-[min(92vw,475px)]",children:[m.jsxs(Yg,{className:"flex min-h-0 flex-col gap-3 px-4 pb-4 pt-4",children:[m.jsxs("div",{className:"space-y-1",children:[m.jsxs(Kg,{children:["Merge into ",r??"current branch"]}),m.jsx(gw,{children:"Choose a branch to continue."})]}),m.jsx(oj,{value:a,onChange:l,placeholder:"Search branches"}),m.jsxs("div",{className:"max-h-[375px] space-y-3 overflow-y-auto pr-1",children:[m.jsx(ol,{title:"Default Branch",entries:N?[N]:[],emptyLabel:"No default branch available.",selectedName:u,onSelect:B=>d(B.name)}),m.jsx(ol,{title:"Recent Branches",entries:M,emptyLabel:"No recent branches.",selectedName:u,onSelect:B=>d(B.name)}),m.jsx(ol,{title:"Other Branches",entries:L,emptyLabel:"No other branches match this search.",selectedName:u,onSelect:B=>d(B.name)})]}),m.jsx("div",{className:"px-2",children:O?y?m.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[m.jsx(bn,{className:"size-3.5 animate-spin"}),m.jsx("span",{children:"Checking merge preview…"})]}):v?m.jsx("div",{className:"text-sm text-destructive",children:v}):p?m.jsxs("div",{className:"flex items-start gap-2",children:[p.status==="up_to_date"?m.jsx(Rs,{className:"mt-1 size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400"}):p.status==="conflicts"?m.jsx(VR,{className:"mt-1 size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}):p.status==="mergeable"?m.jsx(KD,{className:"mt-1 size-3.5 shrink-0 text-muted-foreground"}):m.jsx(VR,{className:"mt-1 size-3.5 shrink-0 text-destructive"}),m.jsxs("div",{className:"min-w-0 space-y-1",children:[m.jsx("div",{className:"text-sm font-medium text-foreground",children:p.message}),p.detail?m.jsx("div",{className:"line-clamp-2 whitespace-pre-wrap text-xs text-muted-foreground",children:p.detail}):null]})]}):m.jsx("div",{className:"text-sm text-muted-foreground",children:"Preview unavailable."}):m.jsx("div",{className:"text-sm text-muted-foreground",children:"Select a branch to preview the merge."})})]}),m.jsx(Xg,{children:m.jsxs("div",{className:"flex min-w-0 w-full items-center justify-end gap-2",children:[m.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>t(!1),children:"Cancel"}),m.jsx(nt,{className:"max-w-full min-w-0",size:"sm",disabled:$,onClick:()=>void I(),children:k?m.jsxs(m.Fragment,{children:[m.jsx(bn,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Merging…"]}):m.jsx("span",{className:"block max-w-full truncate",children:"Merge"})})]})})]})})}function wue({currentBranchName:e,onListBranches:t,onPreviewMergeBranch:n,onMergeBranch:r,onCheckoutBranch:i,onCreateBranch:s}){const[a,l]=b.useState(!1),[u,d]=b.useState(!1),[p,f]=b.useState(!1),[v,_]=b.useState(!1),[y,w]=b.useState(""),[k,C]=b.useState("branches"),[E,R]=b.useState(null),[T,N]=b.useState(null);b.useEffect(()=>{a&&(f(!0),N(null),t().then(U=>R(U)).catch(U=>{N(U instanceof Error?U.message:String(U))}).finally(()=>{f(!1)}))},[t,a]);const M=y.trim().toLowerCase(),L=U=>U.filter(X=>M?[X.displayName,X.name,X.description,X.prTitle,X.headLabel].some(D=>D==null?void 0:D.toLowerCase().includes(M)):!0),O=(E==null?void 0:E.currentBranchName)??e,$=new Set(((E==null?void 0:E.pullRequests)??[]).map(U=>U.headRefName??U.name)),I=L((E==null?void 0:E.recent)??[]).filter(U=>U.name!==O),B=L((E==null?void 0:E.local)??[]).filter(U=>U.name!==O),j=L((E==null?void 0:E.remote)??[]).filter(U=>U.name!==O&&!$.has(U.name)),V=L((E==null?void 0:E.pullRequests)??[]).filter(U=>U.name!==O),F=(E==null?void 0:E.pullRequests.length)??0;async function W(U){_(!0);try{await i(U),l(!1),w(""),C("branches")}finally{_(!1)}}async function P(){_(!0);try{await s(),l(!1),w(""),C("branches")}finally{_(!1)}}function K(){l(!1),d(!0)}return m.jsxs(vP,{open:a,onOpenChange:l,children:[m.jsx(_P,{asChild:!0,children:m.jsxs("button",{type:"button",className:"flex min-w-0 max-w-full items-center gap-1 rounded-md px-1.5 py-1 text-sm transition-colors hover:bg-accent hover:text-foreground","aria-label":"Open branch switcher",children:[m.jsx(Xd,{className:"h-3.5 w-3.5 shrink-0"}),m.jsx("span",{className:"truncate",children:e??"Detached HEAD"}),m.jsx(jh,{className:"h-3.5 w-3.5 shrink-0"})]})}),m.jsx(nS,{align:"start",className:"w-[320px] p-2",children:m.jsxs("div",{className:"space-y-2",children:[m.jsx(oj,{value:y,onChange:w,placeholder:k==="pull_requests"?"Search pull requests":"Search branches",disabled:p||v,trailingAction:m.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>void P(),disabled:p||v,className:"h-7 px-2 text-xs hover:!bg-transparent hover:!border-border/0",children:"+ New"})}),m.jsx(Dv,{value:k,onValueChange:U=>C(U),size:"sm",className:"w-full",optionClassName:"flex-1 justify-center",options:[{value:"branches",label:"Branches"},{value:"pull_requests",label:`Open PRs ${F}`}]}),m.jsx("div",{className:"max-h-[420px] overflow-y-auto pr-1.5 -mr-[8px]",children:p?m.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[m.jsx(bn,{className:"h-4 w-4 animate-spin"}),m.jsx("span",{children:"Loading branches…"})]}):T?m.jsx("div",{className:"rounded-lg border border-border px-3 py-2 text-sm text-muted-foreground",children:T}):k==="pull_requests"?m.jsx(ol,{title:"Open PRs",entries:V,emptyLabel:(E==null?void 0:E.pullRequestsStatus)==="error"?E.pullRequestsError??"Could not load pull requests.":(E==null?void 0:E.pullRequestsStatus)==="unavailable"?"Pull requests unavailable for this repository.":"No open pull requests.",disabled:v,stickyTitle:!0,onSelect:U=>{W(U)}}):m.jsxs("div",{className:"space-y-3",children:[m.jsx(ol,{title:"Recent",entries:I,emptyLabel:"No recent branches.",disabled:v,stickyTitle:!0,onSelect:U=>{W(U)}}),m.jsx(ol,{title:"Local",entries:B,emptyLabel:"No local branches.",disabled:v,stickyTitle:!0,onSelect:U=>{W(U)}}),m.jsx(ol,{title:"Remote",entries:j,emptyLabel:"No remote branches.",disabled:v,stickyTitle:!0,onSelect:U=>{W(U)}})]})}),O?m.jsx(nt,{variant:"default",size:"sm",disabled:p||v||!!T,onClick:K,className:"h-9 w-full justify-center rounded-lg px-3 text-sm",children:m.jsxs("span",{className:"block max-w-full truncate",children:[m.jsx(bF,{className:"mr-1.5 inline h-3.5 w-3.5 shrink-0"}),"Merge branch into ",O,"..."]})}):null]})}),m.jsx(xue,{open:u,onOpenChange:d,branchList:E,currentBranchName:O,onPreviewMergeBranch:n,onMergeBranch:r})]})}function Sue({file:e,rootRef:t,projectId:n,isCollapsed:r,isChecked:i,editorLabel:s,diffRenderMode:a,wrapLines:l,onToggleCollapsed:u,onToggleChecked:d,fileActions:p,patch:f,patchError:v,isPatchLoading:_,onLoadPatch:y}){const w=gue(e),[k,C]=b.useState(null),E=b.useRef(null),{sentinelRef:R,isStuck:T}=cue({rootRef:t,disabled:r}),N=b.useMemo(()=>mue(n,e),[e,n]);function M($){if(mv($).openInNewTab){typeof window<"u"&&window.open(new URL($.contentUrl,window.location.origin).toString(),"_blank","noopener,noreferrer");return}C($.id)}function L($){var B;$.preventDefault(),$.stopPropagation();const I=$.currentTarget.getBoundingClientRect();(B=E.current)==null||B.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:I.left+I.width/2,clientY:I.bottom,view:window}))}function O(){if(!r){u();return}if(N||f!==void 0){u();return}_||y(e.path).then(()=>{u()}).catch(()=>{})}return m.jsxs(Yw,{children:[m.jsx(Xw,{asChild:!0,children:m.jsxs("div",{ref:E,className:"relative rounded-lg border border-border bg-background",children:[r?null:m.jsx("div",{ref:R,className:"pointer-events-none absolute inset-x-0 top-0 h-px","aria-hidden":"true"}),m.jsxs("div",{role:"button",tabIndex:0,onClick:O,onKeyDown:$=>{$.key!=="Enter"&&$.key!==" "||($.preventDefault(),O())},className:Ce("group/header sticky top-0 z-20 flex cursor-pointer items-center justify-between gap-3 bg-background pl-[7px] pr-2.5 py-1.5 text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",!r&&!T&&"rounded-t-[calc(theme(borderRadius.lg)-1px)]",r&&"rounded-[calc(theme(borderRadius.lg)-1px)]",!r&&"border-b border-border/50"),children:[m.jsxs("div",{className:"flex min-w-0 items-center",children:[m.jsx(sj,{checked:i,onClick:d}),m.jsx("div",{className:"min-w-0 truncate select-none ml-2 mr-1",children:e.path})]}),m.jsxs("div",{className:"flex shrink-0 items-center gap-2 select-none",children:[m.jsxs("span",{className:"whitespace-nowrap text-xs font-mono",children:[e.additions>0?m.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["+",e.additions]}):null,e.deletions>0?m.jsxs("span",{className:e.additions>0?"ml-2 text-red-600 dark:text-red-400":"text-red-600 dark:text-red-400",children:["-",e.deletions]}):null]}),m.jsx("button",{type:"button","aria-label":`Open actions for ${e.path}`,onClick:L,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:m.jsx(z9,{className:"h-3.5 w-3.5 shrink-0"})}),_&&r&&!N?m.jsx(bn,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):r?m.jsx(jh,{className:"h-3.5 w-3.5 shrink-0"}):m.jsx(WD,{className:"h-3.5 w-3.5 shrink-0"})]})]}),r?null:m.jsx("div",{className:"kanna-diff-patch overflow-hidden rounded-b-[calc(theme(borderRadius.lg)-1px)] pb-[1px]",children:N?m.jsx("div",{className:"flex justify-center p-3",children:N.kind==="image"?m.jsx(rS,{attachment:N,onClick:()=>M(N)}):m.jsx(iS,{attachment:N,onClick:()=>M(N)})}):_?m.jsxs("div",{className:"flex items-center justify-center px-3 py-8 text-sm text-muted-foreground",children:[m.jsx(bn,{className:"mr-2 h-4 w-4 animate-spin"}),"Loading diff..."]}):v?m.jsx("div",{className:"px-3 py-4 text-sm text-destructive",children:v}):f!==void 0?m.jsx(aue,{patch:f,options:{diffStyle:a,disableFileHeader:!0,disableBackground:!1,overflow:l?"wrap":"scroll",lineDiffType:"word",diffIndicators:"classic"}}):m.jsx("div",{className:"px-3 py-4 text-sm text-muted-foreground",children:"Diff unavailable."})}),m.jsx(kS,{attachment:N&&k===N.id?N:null,onOpenChange:$=>!$&&C(null)})]},e.path)}),m.jsxs(hv,{children:[m.jsxs(Ki,{onSelect:$=>{$.stopPropagation(),p.onOpenFile(e.path)},children:[m.jsx(Gg,{className:"h-3.5 w-3.5"}),m.jsxs("span",{className:"text-xs font-medium",children:["Open in ",s]})]}),m.jsxs(Ki,{onSelect:$=>{$.stopPropagation(),p.onDiscardFile(e.path)},className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[m.jsx(e5,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Discard Changes"})]}),m.jsxs(Ki,{disabled:!w,onSelect:$=>{$.stopPropagation(),w&&p.onIgnoreFile(e.path)},children:[m.jsx(s9,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Ignore File"})]}),m.jsx(QO,{}),m.jsxs(Ki,{onSelect:$=>{$.stopPropagation(),p.onCopyFilePath(e.path)},children:[m.jsx(pl,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Copy File Path"})]}),m.jsxs(Ki,{onSelect:$=>{$.stopPropagation(),p.onCopyRelativePath(e.path)},children:[m.jsx(pl,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Copy Relative Path"})]})]})]})}function Cue({projectId:e,diffs:t,editorLabel:n,diffRenderMode:r,wrapLines:i,onOpenFile:s,onDiscardFile:a,onIgnoreFile:l,onCopyFilePath:u,onCopyRelativePath:d,onListBranches:p,onPreviewMergeBranch:f,onMergeBranch:v,onCheckoutBranch:_,onCreateBranch:y,onGenerateCommitMessage:w,onCommit:k,onSyncWithRemote:C,onLoadPatch:E,onDiffRenderModeChange:R,onWrapLinesChange:T,onClose:N}){var Dt;const M=b.useMemo(()=>({onOpenFile:s,onDiscardFile:a,onIgnoreFile:l,onCopyFilePath:u,onCopyRelativePath:d}),[s,a,l,u,d]),L=t.files.length>0,[O,$]=b.useState(!1),[I,B]=b.useState(null),[j,V]=b.useState(!1),[F,W]=b.useState({}),[P,K]=b.useState({}),[U,X]=b.useState({}),D=b.useRef(null),G=b.useRef({}),Z=b.useMemo(()=>t.files.map(xe=>xe.path),[t.files]),z=b.useMemo(()=>Z.join("\0"),[Z]),oe=si(xe=>{var Ye;return e?((Ye=xe.projectUi[e])==null?void 0:Ye.viewMode)??(L?"changes":"history"):L?"changes":"history"}),ue=si(xe=>{var Ye;return e?((Ye=xe.projectUi[e])==null?void 0:Ye.collapsedPaths)??Zp:Zp}),ne=si(xe=>{var Ye;return e?((Ye=xe.projectUi[e])==null?void 0:Ye.summary)??"":""}),de=si(xe=>{var Ye;return e?((Ye=xe.projectUi[e])==null?void 0:Ye.description)??"":""}),be=si(xe=>xe.reconcileCollapsedPaths),re=si(xe=>xe.toggleCollapsedPath),ge=si(xe=>xe.setViewMode),pe=si(xe=>xe.setCommitDraft),Ee=si(xe=>xe.clearCommitDraft),Re=Qp(xe=>e?xe.checkedPathsByProjectId[e]??Zp:Zp),Fe=Qp(xe=>xe.reconcileProject),it=Qp(xe=>xe.setChecked),Ct=Qp(xe=>xe.setAllChecked),Mt=b.useRef(L);b.useEffect(()=>{e&&be(e,Z)},[Z,z,e,be]),b.useEffect(()=>{const xe=Object.fromEntries(t.files.map(Xe=>[Xe.path,Xe.patchDigest])),Ye=Xe=>G.current[Xe]===xe[Xe];W(Xe=>Object.fromEntries(Object.entries(Xe).filter(([Et])=>Z.includes(Et)&&Ye(Et)))),K(Xe=>Object.fromEntries(Object.entries(Xe).filter(([Et])=>Z.includes(Et)&&Ye(Et)))),X(Xe=>Object.fromEntries(Object.entries(Xe).filter(([Et])=>Z.includes(Et)&&Ye(Et)))),G.current=xe},[t.files,Z,z]),b.useEffect(()=>{e&&Fe(e,Z)},[Z,z,e,Fe]),b.useEffect(()=>{if(!e)return;if(Mt.current!==L){ge(e,L?"changes":"history"),Mt.current=L;return}Mt.current=L},[L,e,ge]);const nn=b.useMemo(()=>t.files.filter(xe=>Re[xe.path]??!0).map(xe=>xe.path),[Re,t.files]),ut=nn.length,Me=t.files.length>0&&ut===t.files.length,Ge=ut>0&&ut<t.files.length,qe=ne.trim(),Pe=qe.length>0,Oe=I!==null,Qt=O||Oe,me=((Dt=t.branchHistory)==null?void 0:Dt.entries)??[],ke=t.behindCount??0,ze=t.aheadCount??0,Ne=t.hasUpstream===!0,ee=t.hasUpstream===!1&&!!t.branchName,et=t.branchName?t.branchName.split("/").map(xe=>encodeURIComponent(xe)).join("/"):null,Ut=ee?"publish":ke>0?"pull":"fetch",Bt=t.originRepoSlug&&et?`https://github.com/${t.originRepoSlug}/compare/${et}?expand=1`:null,Lt=!!(Ne&&Bt&&t.branchName&&t.branchName!==t.defaultBranchName),At=t.status==="ready"&&ut>0&&!Qt,tt=t.status==="ready"&&ut>0&&Pe&&!Qt,ce="commit_and_push",He=t.branchName??"current branch";async function Ht(xe){if(tt){B(xe);try{const Ye=await k({paths:nn,summary:qe,description:de.trim(),mode:xe});(Ye!=null&&Ye.ok||Ye!=null&&Ye.localCommitCreated)&&e&&Ee(e)}finally{B(null)}}}async function Zt(){if(At){$(!0);try{const xe=await w({paths:nn});e&&pe(e,{summary:xe.subject,description:xe.body})}finally{$(!1)}}}function rn(xe){if(!(!(xe.metaKey||xe.ctrlKey)||xe.key!=="Enter")){if(xe.preventDefault(),Pe){Ht(ce);return}Zt()}}async function gt(xe=Ut){if(!(t.status!=="ready"||j)){V(!0);try{await C(xe)}finally{V(!1)}}}const kt=b.useCallback(async xe=>{var Ye;if(F[xe]!==void 0||U[xe])return F[xe]??"";X(Xe=>({...Xe,[xe]:!0})),K(Xe=>{if(!(xe in Xe))return Xe;const{[xe]:Et,...Jt}=Xe;return Jt});try{const Xe=await E(xe);W(Jt=>({...Jt,[xe]:Xe}));const Et=(Ye=t.files.find(Jt=>Jt.path===xe))==null?void 0:Ye.patchDigest;return Et&&(G.current={...G.current,[xe]:Et}),Xe}catch(Xe){const Et=Xe instanceof Error?Xe.message:String(Xe);throw K(Jt=>({...Jt,[xe]:Et})),Xe}finally{X(Xe=>{const{[xe]:Et,...Jt}=Xe;return Jt})}},[t.files,U,E,F]);return m.jsx("div",{className:"h-full min-h-0 border-l border-border bg-background md:min-w-[370px]",children:m.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[m.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pl-2.5 pr-3 py-2",children:[m.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:m.jsx(wue,{currentBranchName:t.branchName,onListBranches:p,onPreviewMergeBranch:f,onMergeBranch:v,onCheckoutBranch:_,onCreateBranch:y})}),t.status==="ready"?Ut==="publish"?m.jsxs(nt,{variant:"ghost",size:"sm",onClick:()=>void gt(),disabled:j,className:"h-7 gap-1.5 px-2 text-xs hover:!bg-transparent hover:!border-border/0",children:[j?m.jsx(bn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(bm,{className:"h-3.5 w-3.5"}),m.jsx("span",{children:"Publish Branch"})]}):m.jsxs("div",{className:"flex items-center gap-1",children:[Ut==="fetch"?m.jsxs(gl,{delayDuration:0,children:[m.jsx(vl,{asChild:!0,children:m.jsxs(nt,{variant:"ghost",size:"sm",onClick:()=>void gt(),disabled:j,className:"h-7 gap-1.5 px-2 text-xs hover:!bg-transparent hover:!border-border/0",children:[j?m.jsx(bn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(JD,{className:"h-3.5 w-3.5"}),m.jsx("span",{children:"Fetch"})]})}),m.jsx(_a,{children:vue(t.lastFetchedAt)})]}):m.jsxs(nt,{variant:"ghost",size:"sm",onClick:()=>void gt(),disabled:j,className:"h-7 gap-1.5 px-2 text-xs hover:!bg-transparent hover:!border-border/0",children:[j?m.jsx(bn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(I9,{className:"h-3.5 w-3.5"}),m.jsx("span",{children:"Pull"}),m.jsx("span",{className:"inline-flex min-w-4 items-center justify-center rounded-full bg-muted px-1 text-[10px] text-muted-foreground",children:ke})]}),Ne&&ze>0?m.jsxs(nt,{variant:"default",size:"sm",onClick:()=>void gt("push"),disabled:j,className:"h-7 gap-1.5 px-2 text-xs",children:[j?m.jsx(bn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(bm,{className:"h-3.5 w-3.5"}),m.jsx("span",{children:"Push"}),m.jsx("span",{className:"inline-flex min-w-4 items-center justify-center rounded-full bg-primary-foreground/15 px-1 text-[10px] text-primary-foreground",children:ze})]}):null,Lt&&Bt?m.jsxs(nt,{variant:"ghost",size:"sm",onClick:()=>{typeof window>"u"||window.open(Bt,"_blank","noopener,noreferrer")},className:"h-7 gap-1.5 px-2 text-xs hover:!bg-transparent hover:!border-border/0",children:[m.jsx(YD,{className:"h-3.5 w-3.5"}),m.jsx("span",{children:"PR"})]}):null]}):null]}),m.jsxs("div",{className:"relative min-h-0 flex-1",children:[m.jsx("div",{className:"sticky top-0 z-30 pl-[14px] pr-[12px] pt-[6px] bg-gradient-to-b from-background to-transparent",children:m.jsx("div",{className:"relative h-[40px] flex min-w-0 items-center justify-center gap-[13px]",children:m.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-between gap-[13px] relative",children:[oe==="changes"?m.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground/70",children:[m.jsx(sj,{checked:Me,mixed:Ge,label:Ge?"Select all files for commit":Me?"Unselect all files from commit":"Select all files for commit",onClick:()=>{!e||t.files.length===0||Ct(e,Z,Ge?!0:!Me)}}),m.jsxs("span",{children:[ut," files"]})]}):m.jsx("div",{}),m.jsx("div",{className:"pointer-events-none absolute left-1/2 -translate-x-1/2 top-1/2 -translate-y-1/2",children:m.jsx("div",{className:"pointer-events-auto",children:m.jsx(Dv,{value:oe,onValueChange:xe=>{e&&ge(e,xe)},size:"sm",optionClassName:"flex-1 justify-center",options:[{value:"changes",label:"Changes"},{value:"history",label:"History"}]})})}),oe==="changes"?m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx(_y,{label:"Unified diff",active:r==="unified",onClick:()=>R("unified"),children:m.jsx(ZF,{className:"h-4 w-4"})}),m.jsx(_y,{label:"Side-by-side diff",active:r==="split",onClick:()=>R("split"),children:m.jsx(A9,{className:"h-4 w-4"})}),m.jsx(_y,{label:i?"Disable word wrap":"Enable word wrap",active:i,onClick:()=>T(!i),children:m.jsx(xU,{className:"h-4 w-4"})})]}):m.jsx("div",{})]})})}),m.jsx("div",{ref:D,className:"h-full overflow-y-auto [scrollbar-gutter:stable]",children:t.status==="no_repo"?m.jsx("div",{className:"flex h-full items-center justify-center px-6 py-3 text-center",children:m.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a git repo to view current file diffs."})}):oe==="history"?me.length===0?m.jsx("div",{className:"flex h-full items-center justify-center px-6 py-3 text-center",children:m.jsxs("p",{className:"text-sm text-muted-foreground",children:["No recent commits on ",t.branchName??"this branch","."]})}):m.jsx("div",{className:"space-y-1.5 p-1.5",children:me.map((xe,Ye)=>m.jsx(_ue,{entry:xe,isPendingPush:Ye<ze},xe.sha))}):t.files.length===0?m.jsx("div",{className:"flex h-full items-center justify-center px-6 py-3 text-center",children:m.jsx("p",{className:"text-sm text-muted-foreground",children:"No file changes."})}):m.jsx("div",{className:"space-y-1.5 p-1.5 pb-72",children:t.files.map(xe=>{const Ye=ue[xe.path]??!0,Xe=Re[xe.path]??!0;return m.jsx(Sue,{file:xe,rootRef:D,projectId:e,isCollapsed:Ye,isChecked:Xe,editorLabel:n,diffRenderMode:r,wrapLines:i,onToggleCollapsed:()=>{e&&re(e,xe.path)},onToggleChecked:()=>{e&&it(e,xe.path,!Xe)},fileActions:M,patch:F[xe.path],patchError:P[xe.path],isPatchLoading:!!U[xe.path],onLoadPatch:kt},xe.path)})})}),oe==="changes"?m.jsxs("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-30 p-3 pt-14 overflow-y-auto [scrollbar-gutter:stable]",children:[m.jsx("div",{className:"absolute inset-x-0 bottom-0 top-0 bg-gradient-to-t from-background to-transparent"}),m.jsx("div",{className:"pointer-events-auto relative mx-auto max-w-[550px]",children:m.jsxs("div",{className:"space-y-0 rounded-xl bg-background",children:[m.jsx(bs,{value:ne,onChange:xe=>{e&&pe(e,{summary:xe.target.value,description:de})},onKeyDown:rn,placeholder:"Commit message (override)",className:"rounded-t-xl rounded-b-none px-3",disabled:Qt||t.status!=="ready"}),m.jsx(Jw,{value:de,onChange:xe=>{e&&pe(e,{summary:ne,description:xe.target.value})},onKeyDown:rn,placeholder:"Description",rows:3,className:"-mt-px rounded-t-none rounded-b-xl px-3 outline-none focus:outline-none focus-visible:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:border-border mb-2",disabled:Qt||t.status!=="ready"}),m.jsxs(Yw,{children:[m.jsx(Xw,{asChild:!0,children:m.jsx(nt,{type:"button",className:"-mt-px w-full rounded-xl",disabled:Pe?!tt:!At,onClick:()=>{if(Pe){Ht(ce);return}Zt()},children:m.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[Pe?Oe?m.jsx(bn,{strokeWidth:2.5,className:"size-3 shrink-0 animate-spin"}):t.hasUpstream?m.jsx(bm,{strokeWidth:2.5,className:"size-3 shrink-0"}):m.jsx(KD,{strokeWidth:2.5,className:"size-3 shrink-0"}):O?m.jsx(bn,{strokeWidth:2.5,className:"size-3 shrink-0 animate-spin"}):m.jsx(WF,{strokeWidth:2.5,className:"size-3 shrink-0"}),m.jsx("span",{className:"min-w-0 truncate text-left",children:Pe?Oe?I==="commit_only"?"Committing...":"Committing & Pushing...":t.hasUpstream?m.jsxs(m.Fragment,{children:["Commit & push to ",m.jsx(Xd,{strokeWidth:2.5,className:"mr-[4.5px] ml-0.5 inline size-3 "}),He]}):m.jsxs(m.Fragment,{children:["Commit & publish ",m.jsx(Xd,{strokeWidth:2.5,className:"mr-[4.5px] ml-0.5 inline size-3 "}),He]}):O?"Generating...":m.jsxs(m.Fragment,{children:["Generate message for ",m.jsx(Xd,{strokeWidth:2.5,className:"mr-[4.5px] ml-0.5 inline size-3 "}),He]})})]})})}),t.hasUpstream?m.jsx(hv,{children:m.jsx(Ki,{disabled:!Pe||!tt,onSelect:xe=>{xe.stopPropagation(),Ht("commit_only")},children:"Commit Only"})}):null]})]})})]}):null]})]})})}const kue=b.memo(Cue);function Eue(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function Rue(e,t){const n=getComputedStyle(e.ownerDocument.body),r=parseFloat(n.fontSize);return t*r}function Tue(e){return e/100*window.innerHeight}function Aue(e){return e/100*window.innerWidth}function Nue(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function Bd({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=Nue(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=Rue(t,i);break}case"em":{r=Eue(t,i);break}case"vh":{r=Tue(i);break}case"vw":{r=Aue(i);break}}return r}function Wr(e){return parseFloat(e.toFixed(3))}function su({group:e}){const{orientation:t,panels:n}=e;return n.reduce((r,i)=>(r+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,r),0)}function Xx(e){const{panels:t}=e,n=su({group:e});return n===0?t.map(r=>({groupResizeBehavior:r.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:r.panelConstraints.disabled,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:s}=r;let a=0;if(s.collapsedSize!==void 0){const p=Bd({groupSize:n,panelElement:i,styleProp:s.collapsedSize});a=Wr(p/n*100)}let l;if(s.defaultSize!==void 0){const p=Bd({groupSize:n,panelElement:i,styleProp:s.defaultSize});l=Wr(p/n*100)}let u=0;if(s.minSize!==void 0){const p=Bd({groupSize:n,panelElement:i,styleProp:s.minSize});u=Wr(p/n*100)}let d=100;if(s.maxSize!==void 0){const p=Bd({groupSize:n,panelElement:i,styleProp:s.maxSize});d=Wr(p/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:a,collapsible:s.collapsible===!0,defaultSize:l,disabled:s.disabled,minSize:u,maxSize:d,panelId:r.id}})}function Kt(e,t="Assertion error"){if(!e)throw Error(t)}function Qx(e,t){return Array.from(t).sort(e==="horizontal"?Mue:Lue)}function Mue(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function Lue(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function aj(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function lj(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function Due({orientation:e,rects:t,targetRect:n}){const r={x:n.x+n.width/2,y:n.y+n.height/2};let i,s=Number.MAX_VALUE;for(const a of t){const{x:l,y:u}=lj(r,a),d=e==="horizontal"?l:u;d<s&&(s=d,i=a)}return Kt(i,"No rect found"),i}let Jp;function Oue(){return Jp===void 0&&(typeof matchMedia=="function"?Jp=!!matchMedia("(pointer:coarse)").matches:Jp=!1),Jp}function cj(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=Qx(n,Array.from(t.children).filter(aj).map(y=>({element:y}))).map(({element:y})=>y),a=[];let l=!1,u=!1,d=-1,p=-1,f=0,v,_=[];{let y=-1;for(const w of s)w.hasAttribute("data-panel")&&(y++,w.ariaDisabled===null&&(f++,d===-1&&(d=y),p=y))}if(f>1){let y=-1;for(const w of s)if(w.hasAttribute("data-panel")){y++;const k=r.find(C=>C.element===w);if(k){if(v){const C=v.element.getBoundingClientRect(),E=w.getBoundingClientRect();let R;if(u){const T=n==="horizontal"?new DOMRect(C.right,C.top,0,C.height):new DOMRect(C.left,C.bottom,C.width,0),N=n==="horizontal"?new DOMRect(E.left,E.top,0,E.height):new DOMRect(E.left,E.top,E.width,0);switch(_.length){case 0:{R=[T,N];break}case 1:{const M=_[0],L=Due({orientation:n,rects:[C,E],targetRect:M.element.getBoundingClientRect()});R=[M,L===C?N:T];break}default:{R=_;break}}}else _.length?R=_:R=[n==="horizontal"?new DOMRect(C.right,E.top,E.left-C.right,E.height):new DOMRect(E.left,C.bottom,E.width,E.top-C.bottom)];for(const T of R){let N="width"in T?T:T.element.getBoundingClientRect();const M=Oue()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(N.width<M){const O=M-N.width;N=new DOMRect(N.x-O/2,N.y,N.width+O,N.height)}if(N.height<M){const O=M-N.height;N=new DOMRect(N.x,N.y-O/2,N.width,N.height+O)}const L=y<=d||y>p;!l&&!L&&a.push({group:e,groupSize:su({group:e}),panels:[v,k],separator:"width"in T?void 0:T,rect:N}),l=!1}}u=!1,v=k,_=[]}}else if(w.hasAttribute("data-separator")){w.ariaDisabled!==null&&(l=!0);const k=i.find(C=>C.element===w);k?_.push(k):(v=void 0,_=[])}else u=!0}return a}var ua,EL;let uj=(EL=class{constructor(){Ko(this,ua,{})}addListener(t,n){const r=$n(this,ua)[t];return r===void 0?$n(this,ua)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=$n(this,ua)[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,s=null;const a=Array.from(r);for(let l=0;l<a.length;l++){const u=a[l];try{u.call(null,n)}catch(d){s===null&&(i=!0,s=d)}}if(i)throw s}}removeAllListeners(){yi(this,ua,{})}removeListener(t,n){const r=$n(this,ua)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}},ua=new WeakMap,EL),ws=new Map;const dj=new uj;function Pue(e){ws=new Map(ws),ws.delete(e)}function FN(e,t){for(const[n]of ws)if(n.id===e)return n}function fa(e,t){for(const[n,r]of ws)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Ll(){return ws}function VS(e,t){return dj.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function go(e,t){const n=ws.get(e);ws=new Map(ws),ws.set(e,t),dj.emit("groupChange",{group:e,prev:n,next:t})}function Iue(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const a=lj(n,s.rect);switch(e){case"horizontal":{a.x<=i.x&&(r=s,i=a);break}case"vertical":{a.y<=i.y&&(r=s,i=a);break}}}return r?{distance:i,hitRegion:r}:void 0}function jue(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function zue(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:WN(e),b:WN(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();Kt(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:VN(UN(n.a)),b:VN(UN(n.b))};if(i.a===i.b){const s=r.childNodes,a={a:n.a.at(-1),b:n.b.at(-1)};let l=s.length;for(;l--;){const u=s[l];if(u===a.a)return 1;if(u===a.b)return-1}}return Math.sign(i.a-i.b)}const Bue=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Hue(e){const t=getComputedStyle(hj(e)??e).display;return t==="flex"||t==="inline-flex"}function $ue(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Hue(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||Bue.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function UN(e){let t=e.length;for(;t--;){const n=e[t];if(Kt(n,"Missing node"),$ue(n))return n}return null}function VN(e){return e&&Number(getComputedStyle(e).zIndex)||0}function WN(e){const t=[];for(;e;)t.push(e),e=hj(e);return t}function hj(e){const{parentNode:t}=e;return jue(t)?t.host:t}function Fue(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Uue({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!aj(n)||n.contains(e)||e.contains(n))return!0;if(zue(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Fue(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function WS(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=cj(i),a=Iue(i.orientation,s,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Uue({groupElement:i.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Vue(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Ar(e,t,n=0){return Math.abs(Wr(e)-Wr(t))<=n}function gs(e,t){return Ar(e,t)?0:e>t?1:-1}function zc({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){const{collapsedSize:i=0,collapsible:s,disabled:a,maxSize:l=100,minSize:u=0}=t;if(a&&!e)return n;if(gs(r,u)<0)if(s){const d=(i+u)/2;gs(r,d)<0?r=i:r=u}else r=u;return r=Math.min(l,r),r=Wr(r),r}function Th({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(Ar(e,0))return t;const a=s==="imperative-api",l=Object.values(t),u=Object.values(i),d=[...l],[p,f]=r;Kt(p!=null,"Invalid first pivot index"),Kt(f!=null,"Invalid second pivot index");let v=0;switch(s){case"keyboard":{{const w=e<0?f:p,k=n[w];Kt(k,`Panel constraints not found for index ${w}`);const{collapsedSize:C=0,collapsible:E,minSize:R=0}=k;if(E){const T=l[w];if(Kt(T!=null,`Previous layout not found for panel index ${w}`),Ar(T,C)){const N=R-T;gs(N,Math.abs(e))>0&&(e=e<0?0-N:N)}}}{const w=e<0?p:f,k=n[w];Kt(k,`No panel constraints found for index ${w}`);const{collapsedSize:C=0,collapsible:E,minSize:R=0}=k;if(E){const T=l[w];if(Kt(T!=null,`Previous layout not found for panel index ${w}`),Ar(T,R)){const N=T-C;gs(N,Math.abs(e))>0&&(e=e<0?0-N:N)}}}break}default:{const w=e<0?f:p,k=n[w];Kt(k,`Panel constraints not found for index ${w}`);const C=l[w],{collapsible:E,collapsedSize:R,minSize:T}=k;if(E&&gs(C,T)<0)if(e>0){const N=T-R,M=N/2,L=C+e;gs(L,T)<0&&(e=gs(e,M)<=0?0:N)}else{const N=T-R,M=100-N/2,L=C-e;gs(L,T)<0&&(e=gs(100+e,M)>0?0:-N)}break}}{const w=e<0?1:-1;let k=e<0?f:p,C=0;for(;;){const R=l[k];Kt(R!=null,`Previous layout not found for panel index ${k}`);const T=zc({overrideDisabledPanels:a,panelConstraints:n[k],prevSize:R,size:100})-R;if(C+=T,k+=w,k<0||k>=n.length)break}const E=Math.min(Math.abs(e),Math.abs(C));e=e<0?0-E:E}{let w=e<0?p:f;for(;w>=0&&w<n.length;){const k=Math.abs(e)-Math.abs(v),C=l[w];Kt(C!=null,`Previous layout not found for panel index ${w}`);const E=C-k,R=zc({overrideDisabledPanels:a,panelConstraints:n[w],prevSize:C,size:E});if(!Ar(C,R)&&(v+=C-R,d[w]=R,v.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?w--:w++}}if(Vue(u,d))return i;{const w=e<0?f:p,k=l[w];Kt(k!=null,`Previous layout not found for panel index ${w}`);const C=k+v,E=zc({overrideDisabledPanels:a,panelConstraints:n[w],prevSize:k,size:C});if(d[w]=E,!Ar(E,C)){let R=C-E,T=e<0?f:p;for(;T>=0&&T<n.length;){const N=d[T];Kt(N!=null,`Previous layout not found for panel index ${T}`);const M=N+R,L=zc({overrideDisabledPanels:a,panelConstraints:n[T],prevSize:N,size:M});if(Ar(N,L)||(R-=L-N,d[T]=L),Ar(R,0))break;e>0?T--:T++}}}const _=Object.values(d).reduce((w,k)=>k+w,0);if(!Ar(_,100,.1))return i;const y=Object.keys(i);return d.reduce((w,k,C)=>(w[y[C]]=k,w),{})}function yl(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||gs(e[n],t[n])!==0)return!1;return!0}function xl({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((l,u)=>l+u,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(l=>`${l}%`).join(", ")}`);if(!Ar(i,100)&&r.length>0)for(let l=0;l<t.length;l++){const u=r[l];Kt(u!=null,`No layout data found for index ${l}`);const d=100/i*u;r[l]=d}let s=0;for(let l=0;l<t.length;l++){const u=n[l];Kt(u!=null,`No layout data found for index ${l}`);const d=r[l];Kt(d!=null,`No layout data found for index ${l}`);const p=zc({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:u,size:d});d!=p&&(s+=d-p,r[l]=p)}if(!Ar(s,0))for(let l=0;l<t.length;l++){const u=r[l];Kt(u!=null,`No layout data found for index ${l}`);const d=u+s,p=zc({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:u,size:d});if(u!==p&&(s-=p-u,r[l]=p,Ar(s,0)))break}const a=Object.keys(e);return r.reduce((l,u,d)=>(l[a[d]]=u,l),{})}function fj({groupId:e,panelId:t}){const n=()=>{const l=Ll();for(const[u,{defaultLayoutDeferred:d,derivedPanelConstraints:p,layout:f,groupSize:v,separatorToPanels:_}]of l)if(u.id===e)return{defaultLayoutDeferred:d,derivedPanelConstraints:p,group:u,groupSize:v,layout:f,separatorToPanels:_};throw Error(`Group ${e} not found`)},r=()=>{const l=n().derivedPanelConstraints.find(u=>u.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const l=n().group.panels.find(u=>u.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const l=n().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},a=l=>{const u=s();if(l===u)return;const{defaultLayoutDeferred:d,derivedPanelConstraints:p,group:f,groupSize:v,layout:_,separatorToPanels:y}=n(),w=f.panels.findIndex(R=>R.id===t),k=w===f.panels.length-1,C=Th({delta:k?u-l:l-u,initialLayout:_,panelConstraints:p,pivotIndices:k?[w-1,w]:[w,w+1],prevLayout:_,trigger:"imperative-api"}),E=xl({layout:C,panelConstraints:p});yl(_,E)||go(f,{defaultLayoutDeferred:d,derivedPanelConstraints:p,groupSize:v,layout:E,separatorToPanels:y})};return{collapse:()=>{const{collapsible:l,collapsedSize:u}=r(),{mutableValues:d}=i(),p=s();l&&p!==u&&(d.expandToSize=p,a(u))},expand:()=>{const{collapsible:l,collapsedSize:u,minSize:d}=r(),{mutableValues:p}=i(),f=s();if(l&&f===u){let v=p.expandToSize??d;v===0&&(v=1),a(v)}},getSize:()=>{const{group:l}=n(),u=s(),{element:d}=i(),p=l.orientation==="horizontal"?d.offsetWidth:d.offsetHeight;return{asPercentage:u,inPixels:p}},isCollapsed:()=>{const{collapsible:l,collapsedSize:u}=r(),d=s();return l&&Ar(u,d)},resize:l=>{const{group:u}=n(),{element:d}=i(),p=su({group:u}),f=Bd({groupSize:p,panelElement:d,styleProp:l}),v=Wr(f/p*100);a(v)}}}function GN(e){if(e.defaultPrevented)return;const t=Ll();WS(e,t).forEach(n=>{if(n.separator){const r=n.panels.find(i=>i.panelConstraints.defaultSize!==void 0);if(r){const i=r.panelConstraints.defaultSize,s=fj({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function Nm(e){const t=Ll();for(const[n]of t)if(n.separators.some(r=>r.element===e))return n;throw Error("Could not find parent Group for separator element")}function pj({groupId:e}){const t=()=>{const n=Ll();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:s,groupSize:a,layout:l,separatorToPanels:u}=t(),d=xl({layout:n,panelConstraints:i});return r?l:(yl(l,d)||go(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:a,layout:d,separatorToPanels:u}),d)}}}function Ka(e,t){const n=Nm(e),r=fa(n.id,!0),i=n.separators.find(p=>p.element===e);Kt(i,"Matching separator not found");const s=r.separatorToPanels.get(i);Kt(s,"Matching panels not found");const a=s.map(p=>n.panels.indexOf(p)),l=pj({groupId:n.id}).getLayout(),u=Th({delta:t,initialLayout:l,panelConstraints:r.derivedPanelConstraints,pivotIndices:a,prevLayout:l,trigger:"keyboard"}),d=xl({layout:u,panelConstraints:r.derivedPanelConstraints});yl(l,d)||go(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:d,separatorToPanels:r.separatorToPanels})}function qN(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=Nm(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Ka(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Ka(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Ka(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Ka(t,-5);break}case"End":{e.preventDefault(),Ka(t,100);break}case"Enter":{e.preventDefault();const r=Nm(t),i=fa(r.id,!0),{derivedPanelConstraints:s,layout:a,separatorToPanels:l}=i,u=r.separators.find(v=>v.element===t);Kt(u,"Matching separator not found");const d=l.get(u);Kt(d,"Matching panels not found");const p=d[0],f=s.find(v=>v.panelId===p.id);if(Kt(f,"Panel metadata not found"),f.collapsible){const v=a[p.id],_=f.collapsedSize===v?r.mutableState.expandedPanelSizes[p.id]??f.minSize:f.collapsedSize;Ka(t,_-v)}break}case"F6":{e.preventDefault();const r=Nm(t).separators.map(a=>a.element),i=Array.from(r).findIndex(a=>a===e.currentTarget);Kt(i!==null,"Index not found");const s=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[s].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Ka(t,-100);break}}}let Yc={cursorFlags:0,state:"inactive"};const GS=new uj;function wl(){return Yc}function Wue(e){return GS.addListener("change",e)}function Gue(e){const t=Yc,n={...Yc};n.cursorFlags=e,Yc=n,GS.emit("change",{prev:t,next:n})}function Xc(e){const t=Yc;Yc=e,GS.emit("change",{prev:t,next:e})}function KN(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Ll(),n=WS(e,t),r=new Map;let i=!1;n.forEach(s=>{s.separator&&(i||(i=!0,s.separator.element.focus({preventScroll:!0})));const a=t.get(s.group);a&&r.set(s.group,a.layout)}),Xc({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}const que=e=>e,by=()=>{},mj=1,gj=2,vj=4,_j=8,YN=3,XN=12;let em;function QN(){return em===void 0&&(em=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(em=!0)),em}function Kue({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(!(r===0&&i===0)){switch(n){case"active":{if(e&&QN()){const s=(e&mj)!==0,a=(e&gj)!==0,l=(e&vj)!==0,u=(e&_j)!==0;if(s)return l?"se-resize":u?"ne-resize":"e-resize";if(a)return l?"sw-resize":u?"nw-resize":"w-resize";if(l)return"s-resize";if(u)return"n-resize"}break}}return QN()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const ZN=new WeakMap;function qS(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=ZN.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));const r=wl();switch(r.state){case"active":case"hover":{const i=Kue({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(a=>a.group),state:r.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}ZN.set(e,{prevStyle:t,styleSheet:n})}function bj({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:a}){let l=0;n.forEach(d=>{const{group:p,groupSize:f}=d,{orientation:v,panels:_}=p,{disableCursor:y}=p.mutableState;let w=0;s?v==="horizontal"?w=(t.clientX-s.x)/f*100:w=(t.clientY-s.y)/f*100:v==="horizontal"?w=t.clientX<0?-100:100:w=t.clientY<0?-100:100;const k=r.get(p),C=i.get(p);if(!k||!C)return;const{defaultLayoutDeferred:E,derivedPanelConstraints:R,groupSize:T,layout:N,separatorToPanels:M}=C;if(R&&N&&M){const L=Th({delta:w,initialLayout:k,panelConstraints:R,pivotIndices:d.panels.map(O=>_.indexOf(O)),prevLayout:N,trigger:"mouse-or-touch"});if(yl(L,N)){if(w!==0&&!y)switch(v){case"horizontal":{l|=w<0?mj:gj;break}case"vertical":{l|=w<0?vj:_j;break}}}else go(d.group,{defaultLayoutDeferred:E,derivedPanelConstraints:R,groupSize:T,layout:L,separatorToPanels:M})}});let u=0;t.movementX===0?u|=a&YN:u|=l&YN,t.movementY===0?u|=a&XN:u|=l&XN,Gue(u),qS(e)}function JN(e){const t=Ll(),n=wl();switch(n.state){case"active":bj({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function eM(e){if(e.defaultPrevented)return;const t=wl(),n=Ll();switch(t.state){case"active":{if(e.buttons===0){Xc({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(r=>{const i=fa(r.group.id,!0);go(r.group,i)});return}bj({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const r=WS(e,n);r.length===0?t.state!=="inactive"&&Xc({cursorFlags:0,state:"inactive"}):Xc({cursorFlags:0,hitRegions:r,state:"hover"}),qS(e.currentTarget);break}}}function tM(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(wl().state){case"hover":Xc({cursorFlags:0,state:"inactive"})}}function nM(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=wl();switch(t.state){case"active":Xc({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(qS(e.currentTarget),t.hitRegions.forEach(n=>{const r=fa(n.group.id,!0);go(n.group,r)}),e.preventDefault())}}function rM(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const a=Wr(s.defaultSize);n+=a,r[s.panelId]=a}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=Wr((100-n)/i);for(const a of e)a.defaultSize===void 0&&(r[a.panelId]=s)}return r}function Yue(e,t,n){if(!n[0])return;const r=e.panels.find(u=>u.element===t);if(!r||!r.onResize)return;const i=su({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,a=r.mutableValues.prevSize,l={asPercentage:Wr(s/i*100),inPixels:s};r.mutableValues.prevSize=l,r.onResize(l,r.id,a)}function Xue(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function Que({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,s=0,a=!1;const l=new Map,u=[];for(const f of e.panels){const v=r[f.id]??0;switch(f.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{a=!0;const _=v/100*n,y=Wr(_/t*100);l.set(f.id,y),i+=y;break}case"preserve-relative-size":default:{u.push(f.id),s+=v;break}}}if(!a||u.length===0)return r;const d=100-i,p={...r};if(l.forEach((f,v)=>{p[v]=f}),s>0)for(const f of u){const v=r[f]??0;p[f]=Wr(v/s*d)}else{const f=Wr(d/u.length);for(const v of u)p[v]=f}return p}function Zue(e,t){const n=e.map(i=>i.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(!r.includes(i))return!1;return!0}const Ec=new Map;function Jue(e){let t=!0;Kt(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(y=>{for(const w of y){const{borderBoxSize:k,target:C}=w;if(C===e.element){if(t){const E=su({group:e});if(E===0)return;const R=fa(e.id);if(!R)return;const T=Xx(e),N=R.defaultLayoutDeferred?rM(T):R.layout,M=Que({group:e,nextGroupSize:E,prevGroupSize:R.groupSize,prevLayout:N}),L=xl({layout:M,panelConstraints:T});if(!R.defaultLayoutDeferred&&yl(R.layout,L)&&Xue(R.derivedPanelConstraints,T)&&R.groupSize===E)return;go(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:T,groupSize:E,layout:L,separatorToPanels:R.separatorToPanels})}}else Yue(e,C,k)}});s.observe(e.element),e.panels.forEach(y=>{Kt(!r.has(y.id),`Panel ids must be unique; id "${y.id}" was used more than once`),r.add(y.id),y.onResize&&s.observe(y.element)});const a=su({group:e}),l=Xx(e),u=e.panels.map(({id:y})=>y).join(",");let d=e.mutableState.defaultLayout;d&&(Zue(e.panels,d)||(d=void 0));const p=e.mutableState.layouts[u]??d??rM(l),f=xl({layout:p,panelConstraints:l}),v=e.element.ownerDocument;Ec.set(v,(Ec.get(v)??0)+1);const _=new Map;return cj(e).forEach(y=>{y.separator&&_.set(y.separator,y.panels)}),go(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:l,groupSize:a,layout:f,separatorToPanels:_}),e.separators.forEach(y=>{Kt(!i.has(y.id),`Separator ids must be unique; id "${y.id}" was used more than once`),i.add(y.id),y.element.addEventListener("keydown",qN)}),Ec.get(v)===1&&(v.addEventListener("dblclick",GN,!0),v.addEventListener("pointerdown",KN,!0),v.addEventListener("pointerleave",JN),v.addEventListener("pointermove",eM),v.addEventListener("pointerout",tM),v.addEventListener("pointerup",nM,!0)),function(){t=!1,Ec.set(v,Math.max(0,(Ec.get(v)??0)-1)),Pue(e),e.separators.forEach(y=>{y.element.removeEventListener("keydown",qN)}),Ec.get(v)||(v.removeEventListener("dblclick",GN,!0),v.removeEventListener("pointerdown",KN,!0),v.removeEventListener("pointerleave",JN),v.removeEventListener("pointermove",eM),v.removeEventListener("pointerout",tM),v.removeEventListener("pointerup",nM,!0)),s.disconnect()}}function ede(){const[e,t]=b.useState({}),n=b.useCallback(()=>t({}),[]);return[e,n]}function KS(e){const t=b.useId();return`${e??t}`}const Dl=typeof window<"u"?b.useLayoutEffect:b.useEffect;function oh(e){const t=b.useRef(e);return Dl(()=>{t.current=e},[e]),b.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function YS(...e){return oh(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function XS(e){const t=b.useRef({...e});return Dl(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const yj=b.createContext(null);function tde(e,t){const n=b.useRef({getLayout:()=>({}),setLayout:que});b.useImperativeHandle(t,()=>n.current,[]),Dl(()=>{Object.assign(n.current,pj({groupId:e}))})}function xj({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:s,groupRef:a,id:l,onLayoutChange:u,onLayoutChanged:d,orientation:p="horizontal",resizeTargetMinimumSize:f={coarse:20,fine:10},style:v,..._}){const y=b.useRef({onLayoutChange:{},onLayoutChanged:{}}),w=oh(B=>{yl(y.current.onLayoutChange,B)||(y.current.onLayoutChange=B,u==null||u(B))}),k=oh(B=>{yl(y.current.onLayoutChanged,B)||(y.current.onLayoutChanged=B,d==null||d(B))}),C=KS(l),E=b.useRef(null),[R,T]=ede(),N=b.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:f,separators:[]}),M=YS(E,s);tde(C,a);const L=oh((B,j)=>{const V=wl(),F=FN(B),W=fa(B);if(W){let P=!1;switch(V.state){case"active":{P=V.hitRegions.some(K=>K.group===F);break}}return{flexGrow:W.layout[j]??1,pointerEvents:P?"none":void 0}}return{flexGrow:(n==null?void 0:n[j])??1}}),O=XS({defaultLayout:n,disableCursor:r}),$=b.useMemo(()=>({get disableCursor(){return!!O.disableCursor},getPanelStyles:L,id:C,orientation:p,registerPanel:B=>{const j=N.current;return j.panels=Qx(p,[...j.panels,B]),T(),()=>{j.panels=j.panels.filter(V=>V!==B),T()}},registerSeparator:B=>{const j=N.current;return j.separators=Qx(p,[...j.separators,B]),T(),()=>{j.separators=j.separators.filter(V=>V!==B),T()}},togglePanelDisabled:(B,j)=>{const V=N.current.panels.find(P=>P.id===B);V&&(V.panelConstraints.disabled=j);const F=FN(C),W=fa(C);F&&W&&go(F,{...W,derivedPanelConstraints:Xx(F)})},toggleSeparatorDisabled:(B,j)=>{const V=N.current.separators.find(F=>F.id===B);V&&(V.disabled=j)}}),[L,C,T,p,O]),I=b.useRef(null);return Dl(()=>{const B=E.current;if(B===null)return;const j=N.current;let V;if(O.defaultLayout!==void 0&&Object.keys(O.defaultLayout).length===j.panels.length){V={};for(const D of j.panels){const G=O.defaultLayout[D.id];G!==void 0&&(V[D.id]=G)}}const F={disabled:!!i,element:B,id:C,mutableState:{defaultLayout:V,disableCursor:!!O.disableCursor,expandedPanelSizes:N.current.lastExpandedPanelSizes,layouts:N.current.layouts},orientation:p,panels:j.panels,resizeTargetMinimumSize:j.resizeTargetMinimumSize,separators:j.separators};I.current=F;const W=Jue(F),{defaultLayoutDeferred:P,derivedPanelConstraints:K,layout:U}=fa(F.id,!0);!P&&K.length>0&&(w(U),k(U));const X=VS(C,D=>{const{defaultLayoutDeferred:G,derivedPanelConstraints:Z,layout:z}=D.next;if(G||Z.length===0)return;const oe=F.panels.map(({id:ne})=>ne).join(",");F.mutableState.layouts[oe]=z,Z.forEach(ne=>{if(ne.collapsible){const{layout:de}=D.prev??{};if(de){const be=Ar(ne.collapsedSize,z[ne.panelId]),re=Ar(ne.collapsedSize,de[ne.panelId]);be&&!re&&(F.mutableState.expandedPanelSizes[ne.panelId]=de[ne.panelId])}}});const ue=wl().state!=="active";w(z),ue&&k(z)});return()=>{I.current=null,W(),X()}},[i,C,k,w,p,R,O]),b.useEffect(()=>{const B=I.current;B&&(B.mutableState.defaultLayout=n,B.mutableState.disableCursor=!!r)}),m.jsx(yj.Provider,{value:$,children:m.jsx("div",{..._,className:t,"data-group":!0,"data-testid":C,id:C,ref:M,style:{height:"100%",width:"100%",overflow:"hidden",...v,display:"flex",flexDirection:p==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:p==="horizontal"?"pan-y":"pan-x"},children:e})})}xj.displayName="Group";function QS(){const e=b.useContext(yj);return Kt(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function nde(e,t){const{id:n}=QS(),r=b.useRef({collapse:by,expand:by,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:by});b.useImperativeHandle(t,()=>r.current,[]),Dl(()=>{Object.assign(r.current,fj({groupId:n,panelId:e}))})}function wj({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,disabled:s,elementRef:a,groupResizeBehavior:l="preserve-relative-size",id:u,maxSize:d="100%",minSize:p="0%",onResize:f,panelRef:v,style:_,...y}){const w=!!u,k=KS(u),C=XS({disabled:s}),E=b.useRef(null),R=YS(E,a),{getPanelStyles:T,id:N,orientation:M,registerPanel:L,togglePanelDisabled:O}=QS(),$=f!==null,I=oh((j,V,F)=>{f==null||f(j,u,F)});Dl(()=>{const j=E.current;if(j!==null){const V={element:j,id:k,idIsStable:w,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:$?I:void 0,panelConstraints:{groupResizeBehavior:l,collapsedSize:n,collapsible:r,defaultSize:i,disabled:C.disabled,maxSize:d,minSize:p}};return L(V)}},[l,n,r,i,$,k,w,d,p,I,L,C]),b.useEffect(()=>{O(k,!!s)},[s,k,O]),nde(k,v);const B=b.useSyncExternalStore(j=>VS(N,j),()=>JSON.stringify(T(N,k)),()=>JSON.stringify(T(N,k)));return m.jsx("div",{...y,"aria-disabled":s||void 0,"data-panel":!0,"data-testid":k,id:k,ref:R,style:{...rde,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...JSON.parse(B)},children:m.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",..._,touchAction:M==="horizontal"?"pan-y":"pan-x"},children:e})})}wj.displayName="Panel";const rde={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function ide({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,s;const a=e[n],l=t.find(u=>u.panelId===n);if(l){const u=l.maxSize,d=l.collapsible?l.collapsedSize:l.minSize,p=[r,r+1];s=xl({layout:Th({delta:d-a,initialLayout:e,panelConstraints:t,pivotIndices:p,prevLayout:e}),panelConstraints:t})[n],i=xl({layout:Th({delta:u-a,initialLayout:e,panelConstraints:t,pivotIndices:p,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:a}}function Sj({children:e,className:t,disabled:n,elementRef:r,id:i,style:s,...a}){const l=KS(i),u=XS({disabled:n}),[d,p]=b.useState({}),[f,v]=b.useState("inactive"),_=b.useRef(null),y=YS(_,r),{disableCursor:w,id:k,orientation:C,registerSeparator:E,toggleSeparatorDisabled:R}=QS(),T=C==="horizontal"?"vertical":"horizontal";Dl(()=>{const M=_.current;if(M!==null){const L={disabled:u.disabled,element:M,id:l},O=E(L),$=Wue(B=>{v(B.next.state!=="inactive"&&B.next.hitRegions.some(j=>j.separator===L)?B.next.state:"inactive")}),I=VS(k,B=>{const{derivedPanelConstraints:j,layout:V,separatorToPanels:F}=B.next,W=F.get(L);if(W){const P=W[0],K=W.indexOf(P);p(ide({layout:V,panelConstraints:j,panelId:P.id,panelIndex:K}))}});return()=>{$(),I(),O()}}},[k,l,E,u]),b.useEffect(()=>{R(l,!!n)},[n,l,R]);let N;return n&&!w&&(N="not-allowed"),m.jsx("div",{...a,"aria-controls":d.valueControls,"aria-disabled":n||void 0,"aria-orientation":T,"aria-valuemax":d.valueMax,"aria-valuemin":d.valueMin,"aria-valuenow":d.valueNow,children:e,className:t,"data-separator":n?"disabled":f,"data-testid":l,id:l,ref:y,role:"separator",style:{flexBasis:"auto",cursor:N,...s,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}Sj.displayName="Separator";const Mm=({className:e,...t})=>m.jsx(xj,{className:Ce("flex h-full w-full",e),...t}),Qa=e=>m.jsx(wj,{...e}),Lm=({withHandle:e,orientation:t,disabled:n,className:r,...i})=>m.jsx(Sj,{disabled:n,className:Ce("relative flex items-center justify-center bg-transparent focus-visible:outline-none",t==="vertical"?"h-2 w-full -my-1 cursor-row-resize":"h-full w-2 -mx-1 cursor-col-resize",e&&(t==="vertical"?"before:absolute before:inset-x-0 before:top-1/2 before:h-0.5 before:-translate-y-1/2 before:bg-border":"before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:bg-border"),r),...i,children:m.jsx("span",{className:"sr-only",children:t==="vertical"?"Resize rows":"Resize columns"})});/**
|
|
2491
2491
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
2492
2492
|
* @license MIT
|
|
2493
2493
|
*
|
package/dist/client/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
7
7
|
<title>Kanna</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-Cr8ogroL.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-Hy4LEj8j.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|