@hienlh/ppm 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/web/assets/{button-CvHWF07y.js → button-CQ5h5gxS.js} +1 -1
  2. package/dist/web/assets/chat-tab-CHIOhm-1.js +6 -0
  3. package/dist/web/assets/{code-editor-CR2IVNDR.js → code-editor-B-8Dsxki.js} +1 -1
  4. package/dist/web/assets/columns-2-DsiY76NQ.js +1 -0
  5. package/dist/web/assets/{dialog-f3IZM-6v.js → dialog-CCBmXo6-.js} +1 -1
  6. package/dist/web/assets/diff-viewer-C9hDywg8.js +4 -0
  7. package/dist/web/assets/{dist-CCBctnax.js → dist-CYANqO1g.js} +1 -1
  8. package/dist/web/assets/{git-graph-Wf8D6KJN.js → git-graph-Bz4nzX8N.js} +1 -1
  9. package/dist/web/assets/{git-status-panel-DQquGn-I.js → git-status-panel-CBvstTNY.js} +1 -1
  10. package/dist/web/assets/{index-Bqv1oZyQ.js → index-VKvV157O.js} +3 -3
  11. package/dist/web/assets/index-VXI-SRG0.css +2 -0
  12. package/dist/web/assets/{project-list-jCqtYamF.js → project-list-xPdlDxNk.js} +1 -1
  13. package/dist/web/assets/{settings-tab-BLAG-sJx.js → settings-tab-C6xPexZC.js} +1 -1
  14. package/dist/web/assets/{terminal-tab-CyjhG4Ao.js → terminal-tab-Cg4Pm_3X.js} +1 -1
  15. package/dist/web/index.html +10 -10
  16. package/dist/web/sw.js +1 -1
  17. package/package.json +1 -1
  18. package/src/web/components/chat/message-input.tsx +2 -2
  19. package/src/web/components/chat/message-list.tsx +15 -3
  20. package/src/web/components/chat/tool-cards.tsx +22 -9
  21. package/src/web/components/editor/diff-viewer.tsx +9 -4
  22. package/dist/web/assets/chat-tab-jQIJwYgi.js +0 -6
  23. package/dist/web/assets/diff-viewer-DSyaISig.js +0 -4
  24. package/dist/web/assets/index-CGDMk8DE.css +0 -2
  25. /package/dist/web/assets/{api-client-B_eCZViO.js → api-client-tgjN9Mx8.js} +0 -0
  26. /package/dist/web/assets/{copy-B-kLwqzg.js → copy-D_Q54D-v.js} +0 -0
  27. /package/dist/web/assets/{dist-B6sG2GPc.js → dist-0XHv8Vwc.js} +0 -0
  28. /package/dist/web/assets/{dist-CBiGQxfr.js → dist-BeHIxUn0.js} +0 -0
  29. /package/dist/web/assets/{external-link-Dim3NH6h.js → external-link-C6Y-D528.js} +0 -0
  30. /package/dist/web/assets/{react-gOPBns57.js → react-C32bf_ch.js} +0 -0
  31. /package/dist/web/assets/{refresh-cw-DJSjl6Ev.js → refresh-cw-S6I91MHO.js} +0 -0
  32. /package/dist/web/assets/{trash-2-CjahwKg8.js → trash-2-Dc17nbCE.js} +0 -0
  33. /package/dist/web/assets/{utils-61GRB9Cb.js → utils-D6me7KDg.js} +0 -0
  34. /package/dist/web/assets/{x-BxhOxZ5p.js → x-Bpqyw40Y.js} +0 -0
@@ -0,0 +1,4 @@
1
+ import{a as e,n as t,r as n,t as r}from"./jsx-runtime-BFALxl05.js";import{t as i}from"./columns-2-DsiY76NQ.js";import{r as a,t as o}from"./api-client-tgjN9Mx8.js";import{C as s,_ as c}from"./index-VKvV157O.js";import{A as l,E as u,H as d,I as f,O as p,Q as m,Y as h,a as g,at as _,ct as v,et as ee,i as y,it as b,j as x,k as S,n as C,nt as te,o as w,ot as T,r as E,rt as D,s as ne,st as O,t as k}from"./dist-BeHIxUn0.js";var re=t(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),ie=t(`panel-right-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),A=e(n(),1),j=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}offset(t,n=t){return new e(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}};function M(e,t,n,r,i,a){if(e==r)return[];let o=R(e,t,n,r,i,a),s=z(e,t+o,n,r,i+o,a);t+=o,n-=s,i+=o,a-=s;let c=n-t,l=a-i;if(!c||!l)return[new j(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new j(t,t+o,i,i),new j(t+o+l,n,a,a)]}else if(l>c){let o=r.slice(i,a).indexOf(e.slice(t,n));if(o>-1)return[new j(t,t,i,i+o),new j(n,n,i+o+c,a)]}if(c==1||l==1)return[new j(t,n,i,a)];let u=le(e,t,n,r,i,a);if(u){let[o,s,c]=u;return M(e,t,o,r,i,s).concat(M(e,o+c,n,r,s+c,a))}return ae(e,t,n,r,i,a)}var N=1e9,P=0,F=!1;function ae(e,t,n,r,i,a){let o=n-t,s=a-i;if(N<1e9&&Math.min(o,s)>N*16||P>0&&Date.now()>P)return Math.min(o,s)>N*64?[new j(t,n,i,a)]:ue(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);I.reset(c),L.reset(c);let l=(n,a)=>e.charCodeAt(t+n)==r.charCodeAt(i+a),u=(t,i)=>e.charCodeAt(n-t-1)==r.charCodeAt(a-i-1),d=(o-s)%2==0?null:L,f=d?null:I;for(let p=0;p<c;p++){if(p>N||P>0&&!(p&63)&&Date.now()>P)return ue(e,t,n,r,i,a);let m=I.advance(p,o,s,c,d,!1,l)||L.advance(p,o,s,c,f,!0,u);if(m)return se(e,t,n,t+m[0],r,i,a,i+m[1])}return[new j(t,n,i,a)]}var oe=class{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let e=0;e<this.len;e++)this.vec[e]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,n,r,i,a,o){for(let s=-e+this.start;s<=e-this.end;s+=2){let c=r+s,l=s==-e||s!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,u=l-s;for(;l<t&&u<n&&o(l,u);)l++,u++;if(this.vec[c]=l,l>t)this.end+=2;else if(u>n)this.start+=2;else if(i){let e=r+(t-n)-s;if(e>=0&&e<this.len&&i.vec[e]!=-1)if(a){let n=i.vec[e];if(n>=t-l)return[n,r+n-e]}else{let n=t-i.vec[e];if(l>=n)return[l,u]}}}return null}},I=new oe,L=new oe;function se(e,t,n,r,i,a,o,s){let c=!1;return!H(e,r)&&++r==n&&(c=!0),!H(i,s)&&++s==o&&(c=!0),c?[new j(t,n,a,o)]:M(e,t,r,i,a,s).concat(M(e,r,n,i,s,o))}function ce(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function R(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=ce(n-t,a-i);for(let s=t,c=i;;){let i=s+o,l=c+o;if(i>n||l>a||e.slice(s,i)!=r.slice(c,l)){if(o==1)return s-t-(H(e,s)?0:1);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function z(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=ce(n-t,a-i);for(let s=n,c=a;;){let a=s-o,l=c-o;if(a<t||l<i||e.slice(a,s)!=r.slice(l,c)){if(o==1)return n-s-(H(e,s)?0:1);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function B(e,t,n,r,i,a,o,s){let c=r.slice(i,a),l=null;for(;;){if(l||o<s)return l;for(let s=t+o;;){H(e,s)||s++;let u=s+o;if(H(e,u)||(u+=u==s+1?1:-1),u>=n)break;let d=e.slice(s,u),f=-1;for(;(f=c.indexOf(d,f+1))!=-1;){let o=R(e,u,n,r,i+f+d.length,a),c=z(e,t,s,r,i,i+f),p=d.length+o+c;(!l||l[2]<p)&&(l=[s-c,i+f-c,p])}s=u}if(s<0)return l;o>>=1}}function le(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=le(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:B(e,t,n,r,i,a,Math.floor(o/4),-1)}function ue(e,t,n,r,i,a){F=!0;let o=n-t,s=a-i,c;if(o<s){let s=B(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=B(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new j(t,n,i,a)];let[l,u,d]=c;return M(e,t,l,r,i,u).concat(M(e,l+d,n,r,u+d,a))}function de(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];r.toA>i.fromA-t&&r.toB>i.fromB-t&&(e[n-1]=new j(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function fe(e,t,n){for(;;){de(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=R(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new j(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=z(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new j(a.fromA,a.toA-s,a.fromB,a.toB-s));let c=a.toA-a.fromA,l=a.toB-a.fromB;if(c&&l)continue;let u=a.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:e.length)-a.toA;if(!u||!d)continue;let f=c?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);u<=f.length&&e.slice(a.fromA-u,a.fromA)==f.slice(f.length-u)?(n[i]=new j(a.fromA-u,a.toA-u,a.fromB-u,a.toB-u),r=!0):d<=f.length&&e.slice(a.toA,a.toA+d)==f.slice(0,d)&&(n[i]=new j(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}function pe(e,t,n){for(let r=0,i=0;i<e.length;i++){let a=e[i],o=a.toA-a.fromA,s=a.toB-a.fromB;if(o&&s||o>3||s>3){let c=i==e.length-1?t.length:e[i+1].fromA,l=a.fromA-r,u=c-a.toA,d=ye(t,a.fromA,l),f=ve(t,a.toA,u),p=a.fromA-d,m=f-a.toA;if((!o||!s)&&p&&m){let l=Math.max(o,s),[u,h,g]=o?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];l>p&&t.slice(d,a.fromA)==u.slice(g-p,g)?(a=e[i]=new j(d,d+o,a.fromB-p,a.toB-p),d=a.fromA,f=ve(t,a.toA,c-a.toA)):l>m&&t.slice(a.toA,f)==u.slice(h,h+m)&&(a=e[i]=new j(f-o,f,a.fromB+m,a.toB+m),f=a.toA,d=ye(t,a.fromA,a.fromA-r)),p=a.fromA-d,m=f-a.toA}if(p||m)a=e[i]=new j(a.fromA-p,a.toA+m,a.fromB-p,a.toB+m);else if(!o){let t=xe(n,a.fromB,a.toB),r,o=t<0?-1:be(n,a.toB,a.fromB);t>-1&&(r=t-a.fromB)<=u&&n.slice(a.fromB,t)==n.slice(a.toB,a.toB+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toB-o)<=l&&n.slice(a.fromB-r,a.fromB)==n.slice(o,a.toB)&&(a=e[i]=a.offset(-r))}else if(!s){let n=xe(t,a.fromA,a.toA),r,o=n<0?-1:be(t,a.toA,a.fromA);n>-1&&(r=n-a.fromA)<=u&&t.slice(a.fromA,n)==t.slice(a.toA,a.toA+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toA-o)<=l&&t.slice(a.fromA-r,a.fromA)==t.slice(o,a.toA)&&(a=e[i]=a.offset(-r))}}r=a.toA}return de(e,3),e}var V;try{V=RegExp(`[\\p{Alphabetic}\\p{Number}]`,`u`)}catch{}function me(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function he(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?me(n)?1:0:V?!Se(n)||t==e.length-1?V.test(String.fromCharCode(n))?1:0:V.test(e.slice(t,t+2))?2:0:0}function ge(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?me(n)?1:0:V?!Ce(n)||t==1?V.test(String.fromCharCode(n))?1:0:V.test(e.slice(t-2,t))?2:0:0}var _e=8;function ve(e,t,n){if(t==e.length||!ge(e,t))return t;for(let r=t,i=t+n,a=0;a<_e;a++){let t=he(e,r);if(!t||r+t>i)return r;r+=t}return t}function ye(e,t,n){if(!t||!he(e,t))return t;for(let r=t,i=t-n,a=0;a<_e;a++){let t=ge(e,r);if(!t||r-t<i)return r;r-=t}return t}function be(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function xe(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}var Se=e=>e>=55296&&e<=56319,Ce=e=>e>=56320&&e<=57343;function H(e,t){return!t||t==e.length||!Se(e.charCodeAt(t-1))||!Ce(e.charCodeAt(t))}function we(e,t,n){let r=n?.override;return r?r(e,t):(N=(n?.scanLimit??1e9)>>1,P=n?.timeout?Date.now()+n.timeout:0,F=!1,fe(e,t,M(e,0,e.length,t,0,t.length)))}function Te(){return!F}function Ee(e,t,n){return pe(we(e,t,n),e,t)}var U=D.define({combine:e=>e[0]}),De=O.define(),Oe=D.define(),W=v.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(De)&&(e=n.value);for(let n of t.state.facet(Oe))e=n(e,t);return e}}),G=class e{constructor(e,t,n,r,i,a=!0){this.changes=e,this.fromA=t,this.toA=n,this.fromB=r,this.toB=i,this.precise=a}offset(t,n){return t||n?new e(this.changes,this.fromA+t,this.toA+t,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,t,n){return je(Ee(e.toString(),t.toString(),n),e,t,0,0,Te())}static updateA(e,t,n,r,i){return Pe(Ne(e,r,!0,n.length),e,t,n,i)}static updateB(e,t,n,r,i){return Pe(Ne(e,r,!1,t.length),e,t,n,i)}};function ke(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.to==e&&a.to==t&&e<n.length&&t<r.length?[e+1,t+1]:[i.from,a.from]}function Ae(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.from==e&&a.from==t?[e,t]:[i.to+1,a.to+1]}function je(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length;s++){let c=e[s],[l,u]=ke(c.fromA+r,c.fromB+i,t,n),[d,f]=Ae(c.toA+r,c.toB+i,t,n),p=[c.offset(-l+r,-u+i)];for(;s<e.length-1;){let a=e[s+1],[o,c]=ke(a.fromA+r,a.fromB+i,t,n);if(o>d+1&&c>f+1)break;p.push(a.offset(-l+r,-u+i)),[d,f]=Ae(a.toA+r,a.toB+i,t,n),s++}o.push(new G(p,l,Math.max(l,d),u,Math.max(u,f),a))}return o}var K=1e3;function Me(e,t,n,r){let i=0,a=e.length;for(;;){if(i==a){let r=0,a=0;i&&({toA:r,toB:a}=e[i-1]);let o=t-(n?r:a);return[r+o,a+o]}let o=i+a>>1,s=e[o],[c,l]=n?[s.fromA,s.toA]:[s.fromB,s.toB];if(c>t)a=o;else if(l<=t)i=o+1;else return r?[s.fromA,s.fromB]:[s.toA,s.toB]}}function Ne(e,t,n,r){let i=[];return t.iterChangedRanges((a,o,s,c)=>{let l=0,u=n?t.length:r,d=0,f=n?r:t.length;a>K&&([l,d]=Me(e,a-K,n,!0)),o<t.length-K&&([u,f]=Me(e,o+K,n,!1));let p=c-s-(o-a),m,[h,g]=n?[p,0]:[0,p];i.length&&(m=i[i.length-1]).toA>=l?i[i.length-1]={fromA:m.fromA,fromB:m.fromB,toA:u,toB:f,diffA:m.diffA+h,diffB:m.diffB+g}:i.push({fromA:l,toA:u,fromB:d,toB:f,diffA:h,diffB:g})}),i}function Pe(e,t,n,r,i){if(!e.length)return t;let a=[];for(let o=0,s=0,c=0,l=0;;o++){let u=o==e.length?null:e[o],d=u?u.fromA+s:n.length,f=u?u.fromB+c:r.length;for(;l<t.length;){let e=t[l];if(u&&(e.toA+s>d||e.toB+c>f))break;a.push(e.offset(s,c)),l++}if(!u)break;let p=u.toA+s+u.diffA,m=u.toB+c+u.diffB,h=Ee(n.sliceString(d,p),r.sliceString(f,m),i);for(let e of je(h,n,r,d,f,Te()))a.push(e);for(s+=u.diffA,c+=u.diffB;l<t.length;){let e=t[l];if(e.fromA+s>p&&e.fromB+c>m)break;l++}}return a}var Fe={scanLimit:500},Ie=l.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=Ge(e))}update(e){(e.docChanged||e.viewportChanged||Le(e.startState,e.state)||Re(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=Ge(e.view))}},{decorations:e=>e.deco}),q=b.low(f({class:`cm-changeGutter`,markers:e=>e.plugin(Ie)?.gutter||_.empty}));function Le(e,t){return e.field(W,!1)!=t.field(W,!1)}function Re(e,t){return e.facet(U)!=t.facet(U)}var ze=u.line({class:`cm-changedLine`}),Be=u.mark({class:`cm-changedText`}),Ve=u.mark({tagName:`ins`,class:`cm-insertedLine`}),He=u.mark({tagName:`del`,class:`cm-deletedLine`}),Ue=new class extends S{constructor(){super(...arguments),this.elementClass=`cm-changedLineGutter`}};function We(e,t,n,r,i,a){let o=n?e.fromA:e.fromB,s=n?e.toA:e.toB,c=0;if(o!=s){i.add(o,o,ze),i.add(o,s,n?He:Ve),a&&a.add(o,o,Ue);for(let l=t.iterRange(o,s-1),u=o;!l.next().done;){if(l.lineBreak){u++,i.add(u,u,ze),a&&a.add(u,u,Ue);continue}let t=u+l.value.length;if(r)for(;c<e.changes.length;){let r=e.changes[c],a=o+(n?r.fromA:r.fromB),s=o+(n?r.toA:r.toB),l=Math.max(u,a),d=Math.min(t,s);if(l<d&&i.add(l,d,Be),s<t)c++;else break}u=t}}}function Ge(e){let t=e.state.field(W),{side:n,highlightChanges:r,markGutter:i,overrideChunk:a}=e.state.facet(U),o=n==`a`,s=new T,c=i?new T:null,{from:l,to:u}=e.viewport;for(let n of t){if((o?n.fromA:n.fromB)>=u)break;(o?n.toA:n.toB)>l&&(!a||!a(e.state,n,s,c))&&We(n,e.state.doc,o,r,s,c)}return{deco:s.finish(),gutter:c&&c.finish()}}var J=class extends x{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement(`div`);return e.className=`cm-mergeSpacer`,e.style.height=this.height+`px`,e}updateDOM(e){return e.style.height=this.height+`px`,!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},Y=O.define({map:(e,t)=>e.map(t)}),X=v.define({create:()=>u.none,update:(e,t)=>{for(let e of t.effects)if(e.is(Y))return e.value;return e.map(t.changes)},provide:e=>p.decorations.from(e)}),Z=.01;function Ke(e,t){if(e.size!=t.size)return!1;let n=e.iter(),r=t.iter();for(;n.value;){if(n.from!=r.from||Math.abs(n.value.spec.widget.height-r.value.spec.widget.height)>1)return!1;n.next(),r.next()}return!0}function qe(e,t,n){let r=new T,i=new T,a=e.state.field(X).iter(),o=t.state.field(X).iter(),s=0,c=0,l=0,d=0,f=e.viewport,p=t.viewport;for(let m=0;;m++){let h=m<n.length?n[m]:null,g=h?h.fromA:e.state.doc.length,_=h?h.fromB:t.state.doc.length;if(s<g){let n=e.lineBlockAt(s).top+l-(t.lineBlockAt(c).top+d);n<-Z?(l-=n,r.add(s,s,u.widget({widget:new J(-n),block:!0,side:-1}))):n>Z&&(d+=n,i.add(c,c,u.widget({widget:new J(n),block:!0,side:-1})))}if(g>s+1e3&&s<f.from&&g>f.from&&c<p.from&&_>p.from){let e=Math.min(f.from-s,p.from-c);s+=e,c+=e,m--}else if(h)s=h.toA,c=h.toB;else break;for(;a.value&&a.from<s;)l-=a.value.spec.widget.height,a.next();for(;o.value&&o.from<c;)d-=o.value.spec.widget.height,o.next()}for(;a.value;)l-=a.value.spec.widget.height,a.next();for(;o.value;)d-=o.value.spec.widget.height,o.next();let m=e.contentHeight+l-(t.contentHeight+d);m<Z?r.add(e.state.doc.length,e.state.doc.length,u.widget({widget:new J(-m),block:!0,side:1})):m>Z&&i.add(t.state.doc.length,t.state.doc.length,u.widget({widget:new J(m),block:!0,side:1}));let h=r.finish(),g=i.finish();Ke(h,e.state.field(X))||e.dispatch({effects:Y.of(h)}),Ke(g,t.state.field(X))||t.dispatch({effects:Y.of(g)})}var Je=O.define({map:(e,t)=>t.mapPos(e)}),Ye=class extends x{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement(`div`);return t.className=`cm-collapsedLines`,t.textContent=e.state.phrase(`$ unchanged lines`,this.lines),t.addEventListener(`click`,t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:Je.of(n)});let{side:r,sibling:i}=e.state.facet(U);i&&i().dispatch({effects:Je.of(Xe(n,e.state.field(W),r==`a`))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return`collapsed-unchanged-code`}};function Xe(e,t,n){let r=0,i=0;for(let a=0;;a++){let o=a<t.length?t[a]:null;if(!o||(n?o.fromA:o.fromB)>=e)return i+(e-r);[r,i]=n?[o.toA,o.toB]:[o.toB,o.toA]}}var Ze=v.define({create(e){return u.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Je)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>p.decorations.from(e)});function Qe({margin:e=3,minSize:t=4}){return Ze.init(n=>$e(n,e,t))}function $e(e,t,n){let r=new T,i=e.facet(U).side==`a`,a=e.field(W),o=1;for(let s=0;;s++){let c=s<a.length?a[s]:null,l=s?o+t:1,d=c?e.doc.lineAt(i?c.fromA:c.fromB).number-1-t:e.doc.lines,f=d-l+1;if(f>=n&&r.add(e.doc.line(l).from,e.doc.line(d).to,u.replace({widget:new Ye(f),block:!0})),!c)break;o=e.doc.lineAt(Math.min(e.doc.length,i?c.toA:c.toB)).number}return r.finish()}var et=p.styleModule.of(new h({".cm-mergeView":{overflowY:`auto`},".cm-mergeViewEditors":{display:`flex`,alignItems:`stretch`},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:`hidden`},".cm-merge-revert":{width:`1.6em`,flexGrow:0,flexShrink:0,position:`relative`},".cm-merge-revert button":{position:`absolute`,display:`block`,width:`100%`,boxSizing:`border-box`,textAlign:`center`,background:`none`,border:`none`,font:`inherit`,cursor:`pointer`}})),tt=p.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:`auto !important`,overflowY:`visible !important`},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:`rgba(160, 128, 100, .08)`},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:`rgba(100, 160, 128, .08)`},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat`},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat`},"&light.cm-merge-b .cm-changedText":{background:`linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat`},"&dark.cm-merge-b .cm-changedText":{background:`linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat`},"&.cm-merge-b .cm-deletedText":{background:`#ff000033`},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:`none`},".cm-deletedChunk":{paddingLeft:`6px`,"& .cm-chunkButtons":{position:`absolute`,insetInlineEnd:`5px`},"& button":{border:`none`,cursor:`pointer`,color:`white`,margin:`0 2px`,borderRadius:`3px`,"&[name=accept]":{background:`#2a2`},"&[name=reject]":{background:`#d43`}}},".cm-collapsedLines":{padding:`5px 5px 5px 10px`,cursor:`pointer`,"&:before":{content:`"⦚"`,marginInlineEnd:`7px`},"&:after":{content:`"⦚"`,marginInlineStart:`7px`}},"&light .cm-collapsedLines":{color:`#444`,background:`linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)`},"&dark .cm-collapsedLines":{color:`#ddd`,background:`linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)`},".cm-changeGutter":{width:`3px`,paddingLeft:`1px`},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:`#e43`},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:`#fa9`},"&light.cm-merge-b .cm-changedLineGutter":{background:`#2b2`},"&dark.cm-merge-b .cm-changedLineGutter":{background:`#8f8`},".cm-inlineChangedLineGutter":{background:`#75d`}}),nt=new ee,Q=new ee,rt=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||Fe;let t=[b.low(Ie),tt,et,X,p.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(Y)))&&this.measure()})],n=[U.of({side:`a`,sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(q);let r=te.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],p.editorAttributes.of({class:`cm-merge-a`}),Q.of(n),t]}),i=[U.of({side:`b`,sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(q);let a=te.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],p.editorAttributes.of({class:`cm-merge-b`}),Q.of(i),t]});this.chunks=G.build(r.doc,a.doc,this.diffConf);let o=[W.init(()=>this.chunks),nt.of(e.collapseUnchanged?Qe(e.collapseUnchanged):[])];r=r.update({effects:O.appendConfig.of(o)}).state,a=a.update({effects:O.appendConfig.of(o)}).state,this.dom=document.createElement(`div`),this.dom.className=`cm-mergeView`,this.editorDOM=this.dom.appendChild(document.createElement(`div`)),this.editorDOM.className=`cm-mergeViewEditors`;let s=e.orientation||`a-b`,c=document.createElement(`div`);c.className=`cm-mergeViewEditor`;let l=document.createElement(`div`);l.className=`cm-mergeViewEditor`,this.editorDOM.appendChild(s==`a-b`?c:l),this.editorDOM.appendChild(s==`a-b`?l:c),this.a=new p({state:r,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new p({state:a,parent:l,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls==`b-to-a`,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some(e=>e.docChanged)){let n=e[e.length-1],r=e.reduce((e,t)=>e.compose(t.changes),m.empty(e[0].startState.doc.length));this.chunks=t==this.a?G.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):G.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:De.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:De.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if(`diffConfig`in e&&(this.diffConf=e.diffConfig),`orientation`in e){let t=e.orientation!=`b-a`;if(t!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let e=this.a.dom.parentNode,n=this.b.dom.parentNode;e.remove(),n.remove(),this.editorDOM.insertBefore(t?e:n,this.editorDOM.firstChild),this.editorDOM.appendChild(t?n:e),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent=``)}}if(`revertControls`in e||`renderRevertControl`in e){let t=!!this.revertDOM,n=this.revertToA,r=this.renderRevert;`revertControls`in e&&(t=!!e.revertControls,n=e.revertControls==`b-to-a`),`renderRevertControl`in e&&(r=e.renderRevertControl),this.setupRevertControls(t,n,r)}let t=`highlightChanges`in e,n=`gutter`in e,r=`collapseUnchanged`in e;if(t||n||r){let i=[],a=[];if(t||n){let r=this.a.state.facet(U),o=n?e.gutter!==!1:r.markGutter,s=t?e.highlightChanges!==!1:r.highlightChanges;i.push(Q.reconfigure([U.of({side:`a`,sibling:()=>this.b,highlightChanges:s,markGutter:o}),o?q:[]])),a.push(Q.reconfigure([U.of({side:`b`,sibling:()=>this.a,highlightChanges:s,markGutter:o}),o?q:[]]))}if(r){let t=nt.reconfigure(e.collapseUnchanged?Qe(e.collapseUnchanged):[]);i.push(t),a.push(t)}this.a.dispatch({effects:i}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,t,n){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement(`div`),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener(`mousedown`,e=>this.revertClicked(e)),this.revertDOM.className=`cm-merge-revert`):this.revertDOM&&(this.revertDOM.textContent=``)}scheduleMeasure(){this.measuring<0&&(this.measuring=(this.dom.ownerDocument.defaultView||window).requestAnimationFrame(()=>{this.measuring=-1,this.measure()}))}measure(){qe(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,r=this.b.viewport;for(let i=0;i<this.chunks.length;i++){let a=this.chunks[i];if(a.fromA>n.to||a.fromB>r.to)break;if(a.fromA<n.from||a.fromB<r.from)continue;let o=this.a.lineBlockAt(a.fromA).top+`px`;for(;t&&+t.dataset.chunk<i;)t=it(t);t&&t.dataset.chunk==String(i)?(t.style.top!=o&&(t.style.top=o),t=t.nextSibling):e.insertBefore(this.renderRevertButton(o,i),t)}for(;t;)t=it(t)}renderRevertButton(e,t){let n;if(this.renderRevert)n=this.renderRevert();else{n=document.createElement(`button`);let e=this.a.state.phrase(`Revert this chunk`);n.setAttribute(`aria-label`,e),n.setAttribute(`title`,e),n.textContent=this.revertToLeft?`⇜`:`⇝`}return n.style.top=e,n.setAttribute(`data-chunk`,String(t)),n}revertClicked(e){let t=e.target,n;for(;t&&t.parentNode!=this.revertDOM;)t=t.parentNode;if(t&&(n=this.chunks[t.dataset.chunk])){let[t,r,i,a,o,s]=this.revertToA?[this.b,this.a,n.fromB,n.toB,n.fromA,n.toA]:[this.a,this.b,n.fromA,n.toA,n.fromB,n.toB],c=t.state.sliceDoc(i,Math.max(i,a-1));i!=a&&s<=r.state.doc.length&&(c+=t.state.lineBreak),r.dispatch({changes:{from:o,to:Math.min(r.state.doc.length,s),insert:c},userEvent:`revert`}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}};function it(e){let t=e.nextSibling;return e.remove(),t}var $=r();function at(e){switch(e.split(`.`).pop()?.toLowerCase()??``){case`js`:case`jsx`:return w({jsx:!0});case`ts`:case`tsx`:return w({jsx:!0,typescript:!0});case`py`:return g();case`html`:return E();case`css`:case`scss`:return y();case`json`:return C();case`md`:case`mdx`:return k();default:return null}}function ot({metadata:e}){let t=e?.filePath,n=e?.projectName,r=e?.ref1,l=e?.ref2,u=e?.file1,f=e?.file2,m=e?.original,h=e?.modified,g=m!=null||h!=null,_=!!(u&&f),[v,ee]=(0,A.useState)(null),[y,b]=(0,A.useState)(null),[x,S]=(0,A.useState)(!g),[C,w]=(0,A.useState)(null),[T,E]=(0,A.useState)(`both`),D=(0,A.useRef)(null),O=(0,A.useRef)(null);(0,A.useEffect)(()=>{if(g||!n)return;if(S(!0),w(null),u&&f){let e=new URLSearchParams;e.set(`file1`,u),e.set(`file2`,f),o.get(`${a(n)}/files/compare?${e.toString()}`).then(e=>{b(e),S(!1)}).catch(e=>{w(e instanceof Error?e.message:`Failed to compare files`),S(!1)});return}let e;if(t){let i=new URLSearchParams;i.set(`file`,t),r&&i.set(`ref`,r),e=`${a(n)}/git/file-diff?${i.toString()}`}else if(r||l){let t=new URLSearchParams;r&&t.set(`ref1`,r),l&&t.set(`ref2`,l),e=`${a(n)}/git/diff?${t.toString()}`}else e=`${a(n)}/git/diff`;o.get(e).then(e=>{ee(e.diff),S(!1)}).catch(e=>{w(e instanceof Error?e.message:`Failed to load diff`),S(!1)})},[t,n,r,l,u,f]);let{original:k,modified:j}=(0,A.useMemo)(()=>g?{original:m??``,modified:h??``}:_&&y?y:v?st(v):{original:``,modified:``},[v,g,m,h,_,y]),M=(0,A.useMemo)(()=>{let e=t??f??u;if(!e)return[];let n=at(e);return n?[n]:[]},[t,u,f]);if((0,A.useEffect)(()=>{let e=D.current;if(!e||x||C||!k&&!j)return;O.current&&=(O.current.destroy(),null),window.innerWidth;let t=[...M,ne,p.editable.of(!1),te.readOnly.of(!0),d(),p.theme({"&":{fontSize:`13px`,fontFamily:`var(--font-mono)`},"& .cm-changedText":{textDecoration:`none !important`,borderBottom:`none !important`,textDecorationLine:`none !important`,backgroundColor:`rgba(16, 185, 129, 0.4) !important`,borderRadius:`2px`},"& .cm-deletedChunk .cm-changedText":{backgroundColor:`rgba(239, 68, 68, 0.4) !important`}})],n=new rt({parent:e,a:{doc:k,extensions:t},b:{doc:j,extensions:t},orientation:`a-b`,revertControls:void 0,highlightChanges:!0,gutter:!0});O.current=n;let r=n.a.dom.querySelector(`.cm-scroller`),i=n.b.dom.querySelector(`.cm-scroller`),a=!1,o=(e,t)=>{a||=(a=!0,t.scrollLeft=e.scrollLeft,!1)},s=()=>r&&i&&o(r,i),c=()=>r&&i&&o(i,r);return r?.addEventListener(`scroll`,s),i?.addEventListener(`scroll`,c),()=>{r?.removeEventListener(`scroll`,s),i?.removeEventListener(`scroll`,c),n.destroy(),O.current=null}},[k,j,M,x,C]),(0,A.useEffect)(()=>{let e=O.current;if(!e)return;let t=e.a.dom.closest(`.cm-mergeViewEditor`)??e.a.dom.parentElement,n=e.b.dom.closest(`.cm-mergeViewEditor`)??e.b.dom.parentElement,r=D.current?.querySelector(`.cm-mergeViewGutter`);t&&(t.style.display=T===`right`?`none`:``,t.style.flex=T===`left`?`1`:``),n&&(n.style.display=T===`left`?`none`:``,n.style.flex=T===`right`?`1`:``),r&&(r.style.display=T===`both`?``:`none`)},[T,k,j]),!n&&!g)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`});if(x)return(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,$.jsx)(c,{className:`size-5 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Loading diff...`})]});if(C)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-destructive text-sm`,children:C});if(!g&&!_&&(!v||v.trim()===``)&&!k&&!j)return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,$.jsx)(s,{className:`size-8`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`No changes detected`}),t&&(0,$.jsx)(`p`,{className:`text-xs font-mono`,children:t})]});let N=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>E(T===`left`?`both`:`left`),className:`p-1 rounded hover:bg-muted transition-colors ${T===`left`?`bg-muted text-foreground`:``}`,title:`Expand original`,children:(0,$.jsx)(re,{className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>E(`both`),className:`p-1 rounded hover:bg-muted transition-colors ${T===`both`?`bg-muted text-foreground`:``}`,title:`Side by side`,children:(0,$.jsx)(i,{className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>E(T===`right`?`both`:`right`),className:`p-1 rounded hover:bg-muted transition-colors ${T===`right`?`bg-muted text-foreground`:``}`,title:`Expand modified`,children:(0,$.jsx)(ie,{className:`size-3.5`})})]});return(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b text-xs text-muted-foreground`,children:[(0,$.jsx)(s,{className:`size-3.5`}),_?(0,$.jsxs)(`span`,{className:`font-mono truncate flex-1`,children:[u,` vs `,f]}):(0,$.jsxs)(`span`,{className:`flex-1 truncate`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:t??`Working tree changes`}),(r||l)&&(0,$.jsxs)(`span`,{children:[` (`,r?.slice(0,7)??`HEAD`,` vs `,l?.slice(0,7)??`working tree`,`)`]})]}),(0,$.jsx)(`div`,{className:`hidden md:block`,children:N})]}),(0,$.jsx)(`div`,{ref:D,className:`flex-1 overflow-auto touch-pinch-zoom [&_.cm-mergeView]:h-full`,style:{WebkitOverflowScrolling:`touch`}}),(0,$.jsx)(`div`,{className:`md:hidden flex justify-center border-t py-1 bg-background shrink-0`,children:N})]})}function st(e){let t=e.split(`
2
+ `),n=[],r=[],i=!1;for(let e of t)if(!(e.startsWith(`diff --git`)||e.startsWith(`diff --no-index`)||e.startsWith(`index `)||e.startsWith(`new file`)||e.startsWith(`deleted file`)||e.startsWith(`old mode`)||e.startsWith(`new mode`)||e.startsWith(`---`)||e.startsWith(`+++`)||e.startsWith(`Binary files`)||e.startsWith(`\\ No newline`))){if(e.startsWith(`@@`)){i=!0;continue}if(i){if(e.startsWith(`-`))n.push(e.slice(1));else if(e.startsWith(`+`))r.push(e.slice(1));else if(e.startsWith(` `)||e===``){let t=e.startsWith(` `)?e.slice(1):e;n.push(t),r.push(t)}}}return{original:n.join(`
3
+ `),modified:r.join(`
4
+ `)}}export{ot as DiffViewer};
@@ -1 +1 @@
1
- import{a as e,r as t,t as n}from"./jsx-runtime-BFALxl05.js";import{_ as r,b as i,c as a,d as o,h as s,m as c,x as l}from"./button-CvHWF07y.js";var u=e(t(),1),d=n();function f(e){let t=e+`CollectionProvider`,[n,a]=c(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),l=e=>{let{scope:t,children:n}=e,r=u.useRef(null),i=u.useRef(new Map).current;return(0,d.jsx)(o,{scope:t,itemMap:i,collectionRef:r,children:n})};l.displayName=t;let f=e+`CollectionSlot`,p=r(f),m=u.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,d.jsx)(p,{ref:i(t,s(f,n).collectionRef),children:r})});m.displayName=f;let h=e+`CollectionItemSlot`,g=`data-radix-collection-item`,_=r(h),v=u.forwardRef((e,t)=>{let{scope:n,children:r,...a}=e,o=u.useRef(null),c=i(t,o),l=s(h,n);return u.useEffect(()=>(l.itemMap.set(o,{ref:o,...a}),()=>void l.itemMap.delete(o))),(0,d.jsx)(_,{[g]:``,ref:c,children:r})});v.displayName=h;function y(t){let n=s(e+`CollectionConsumer`,t);return u.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${g}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:l,Slot:m,ItemSlot:v},y,a]}function p(e){let[t,n]=u.useState(void 0);return o(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var m=[`top`,`right`,`bottom`,`left`],h=Math.min,g=Math.max,_=Math.round,v=Math.floor,y=e=>({x:e,y:e}),b={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function x(e,t,n){return g(e,h(t,n))}function S(e,t){return typeof e==`function`?e(t):e}function C(e){return e.split(`-`)[0]}function w(e){return e.split(`-`)[1]}function T(e){return e===`x`?`y`:`x`}function E(e){return e===`y`?`height`:`width`}function D(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function O(e){return T(D(e))}function k(e,t,n){n===void 0&&(n=!1);let r=w(e),i=O(e),a=E(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=L(o)),[o,L(o)]}function A(e){let t=L(e);return[j(e),t,j(t)]}function j(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var M=[`left`,`right`],N=[`right`,`left`],P=[`top`,`bottom`],ee=[`bottom`,`top`];function F(e,t,n){switch(e){case`top`:case`bottom`:return n?t?N:M:t?M:N;case`left`:case`right`:return t?P:ee;default:return[]}}function I(e,t,n,r){let i=w(e),a=F(C(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(j)))),a}function L(e){let t=C(e);return b[t]+e.slice(t.length)}function R(e){return{top:0,right:0,bottom:0,left:0,...e}}function z(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:R(e)}function B(e){let{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 te(e,t,n){let{reference:r,floating:i}=e,a=D(t),o=O(t),s=E(o),c=C(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(w(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function ne(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=S(t,e),p=z(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=B(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=B(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var re=50,ie=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:ne},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=te(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<re&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=te(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},ae=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=S(e,t)||{};if(l==null)return{};let d=z(u),f={x:n,y:r},p=O(i),m=E(p),g=await o.getDimensions(l),_=p===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,C=a.reference[m]+a.reference[p]-f[p]-a.floating[m],T=f[p]-a.reference[p],D=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),k=D?D[b]:0;(!k||!await(o.isElement==null?void 0:o.isElement(D)))&&(k=s.floating[b]||a.floating[m]);let A=C/2-T/2,j=k/2-g[m]/2-1,M=h(d[v],j),N=h(d[y],j),P=M,ee=k-g[m]-N,F=k/2-g[m]/2+A,I=x(P,F,ee),L=!c.arrow&&w(i)!=null&&F!==I&&a.reference[m]/2-(F<P?M:N)-g[m]/2<0,R=L?F<P?F-P:F-ee:0;return{[p]:f[p]+R,data:{[p]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),oe=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=S(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=C(r),_=D(o),v=C(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[L(o)]:A(o)),x=p!==`none`;!d&&x&&b.push(...I(o,m,p,y));let w=[o,...b],T=await s.detectOverflow(t,h),E=[],O=i.flip?.overflows||[];if(l&&E.push(T[g]),u){let e=k(r,a,y);E.push(T[e[0]],T[e[1]])}if(O=[...O,{placement:r,overflows:E}],!E.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=w[e];if(t&&(!(u===`alignment`&&_!==D(t))||O.every(e=>D(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:O},reset:{placement:t}};let n=O.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=O.filter(e=>{if(x){let t=D(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function se(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ce(e){return m.some(t=>e[t]>=0)}var le=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=S(e,t);switch(i){case`referenceHidden`:{let e=se(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:ce(e)}}}case`escaped`:{let e=se(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:ce(e)}}}default:return{}}}}},ue=new Set([`left`,`top`]);async function de(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=C(n),s=w(n),c=D(n)===`y`,l=ue.has(o)?-1:1,u=a&&c?-1:1,d=S(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var fe=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await de(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},pe=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=S(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=D(C(i)),p=T(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=x(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=x(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},me=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=S(e,t),u={x:n,y:r},d=D(i),f=T(d),p=u[f],m=u[d],h=S(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=ue.has(C(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},he=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=S(e,t),u=await o.detectOverflow(t,l),d=C(i),f=w(i),p=D(i)===`y`,{width:m,height:_}=a.floating,v,y;d===`top`||d===`bottom`?(v=d,y=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(y=d,v=f===`end`?`top`:`bottom`);let b=_-u.top-u.bottom,x=m-u.left-u.right,T=h(_-u[v],b),E=h(m-u[y],x),O=!t.middlewareData.shift,k=T,A=E;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=b),O&&!f){let e=g(u.left,0),t=g(u.right,0),n=g(u.top,0),r=g(u.bottom,0);p?A=m-2*(e!==0||t!==0?e+t:g(u.left,u.right)):k=_-2*(n!==0||r!==0?n+r:g(u.top,u.bottom))}await c({...t,availableWidth:A,availableHeight:k});let j=await o.getDimensions(s.floating);return m!==j.width||_!==j.height?{reset:{rects:!0}}:{}}}};function ge(){return typeof window<`u`}function V(e){return _e(e)?(e.nodeName||``).toLowerCase():`#document`}function H(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function U(e){return((_e(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function _e(e){return ge()?e instanceof Node||e instanceof H(e).Node:!1}function W(e){return ge()?e instanceof Element||e instanceof H(e).Element:!1}function G(e){return ge()?e instanceof HTMLElement||e instanceof H(e).HTMLElement:!1}function ve(e){return!ge()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof H(e).ShadowRoot}function K(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Y(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function ye(e){return/^(table|td|th)$/.test(V(e))}function be(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var xe=/transform|translate|scale|rotate|perspective|filter/,Se=/paint|layout|strict|content/,q=e=>!!e&&e!==`none`,Ce;function we(e){let t=W(e)?Y(e):e;return q(t.transform)||q(t.translate)||q(t.scale)||q(t.rotate)||q(t.perspective)||!Ee()&&(q(t.backdropFilter)||q(t.filter))||xe.test(t.willChange||``)||Se.test(t.contain||``)}function Te(e){let t=X(e);for(;G(t)&&!J(t);){if(we(t))return t;if(be(t))return null;t=X(t)}return null}function Ee(){return Ce??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Ce}function J(e){return/^(html|body|#document)$/.test(V(e))}function Y(e){return H(e).getComputedStyle(e)}function De(e){return W(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function X(e){if(V(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ve(e)&&e.host||U(e);return ve(t)?t.host:t}function Oe(e){let t=X(e);return J(t)?e.ownerDocument?e.ownerDocument.body:e.body:G(t)&&K(t)?t:Oe(t)}function Z(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Oe(e),i=r===e.ownerDocument?.body,a=H(r);if(i){let e=ke(a);return t.concat(a,a.visualViewport||[],K(r)?r:[],e&&n?Z(e):[])}else return t.concat(r,Z(r,[],n))}function ke(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ae(e){let t=Y(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=G(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=_(n)!==a||_(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function je(e){return W(e)?e:e.contextElement}function Q(e){let t=je(e);if(!G(t))return y(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Ae(t),o=(a?_(n.width):n.width)/r,s=(a?_(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Me=y(0);function Ne(e){let t=H(e);return!Ee()||!t.visualViewport?Me:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Pe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==H(e)?!1:t}function $(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=je(e),o=y(1);t&&(r?W(r)&&(o=Q(r)):o=Q(e));let s=Pe(a,n,r)?Ne(a):y(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=H(a),t=r&&W(r)?H(r):r,n=e,i=ke(n);for(;i&&r&&t!==n;){let e=Q(i),t=i.getBoundingClientRect(),r=Y(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=H(i),i=ke(n)}}return B({width:u,height:d,x:c,y:l})}function Fe(e,t){let n=De(e).scrollLeft;return t?t.left+n:$(U(e)).left+n}function Ie(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Fe(e,n),y:n.top+t.scrollTop}}function Le(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=U(r),s=t?be(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=y(1),u=y(0),d=G(r);if((d||!d&&!a)&&((V(r)!==`body`||K(o))&&(c=De(r)),d)){let e=$(r);l=Q(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Ie(o,c):y(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Re(e){return Array.from(e.getClientRects())}function ze(e){let t=U(e),n=De(e),r=e.ownerDocument.body,i=g(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=g(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Fe(e),s=-n.scrollTop;return Y(r).direction===`rtl`&&(o+=g(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Be=25;function Ve(e,t){let n=H(e),r=U(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Ee();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Fe(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Be&&(a-=o)}else l<=Be&&(a+=l);return{width:a,height:o,x:s,y:c}}function He(e,t){let n=$(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=G(e)?Q(e):y(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Ue(e,t,n){let r;if(t===`viewport`)r=Ve(e,n);else if(t===`document`)r=ze(U(e));else if(W(t))r=He(t,n);else{let n=Ne(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return B(r)}function We(e,t){let n=X(e);return n===t||!W(n)||J(n)?!1:Y(n).position===`fixed`||We(n,t)}function Ge(e,t){let n=t.get(e);if(n)return n;let r=Z(e,[],!1).filter(e=>W(e)&&V(e)!==`body`),i=null,a=Y(e).position===`fixed`,o=a?X(e):e;for(;W(o)&&!J(o);){let t=Y(o),n=we(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||K(o)&&!n&&We(e,o))?r=r.filter(e=>e!==o):i=t,o=X(o)}return t.set(e,r),r}function Ke(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?be(t)?[]:Ge(t,this._c):[].concat(n),r],o=Ue(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Ue(t,a[e],i);s=g(n.top,s),c=h(n.right,c),l=h(n.bottom,l),u=g(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function qe(e){let{width:t,height:n}=Ae(e);return{width:t,height:n}}function Je(e,t,n){let r=G(t),i=U(t),a=n===`fixed`,o=$(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=y(0);function l(){c.x=Fe(i)}if(r||!r&&!a)if((V(t)!==`body`||K(i))&&(s=De(t)),r){let e=$(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?Ie(i,s):y(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function Ye(e){return Y(e).position===`static`}function Xe(e,t){if(!G(e)||Y(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return U(e)===n&&(n=n.ownerDocument.body),n}function Ze(e,t){let n=H(e);if(be(e))return n;if(!G(e)){let t=X(e);for(;t&&!J(t);){if(W(t)&&!Ye(t))return t;t=X(t)}return n}let r=Xe(e,t);for(;r&&ye(r)&&Ye(r);)r=Xe(r,t);return r&&J(r)&&Ye(r)&&!we(r)?n:r||Te(e)||n}var Qe=async function(e){let t=this.getOffsetParent||Ze,n=this.getDimensions,r=await n(e.floating);return{reference:Je(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function $e(e){return Y(e).direction===`rtl`}var et={convertOffsetParentRelativeRectToViewportRelativeRect:Le,getDocumentElement:U,getClippingRect:Ke,getOffsetParent:Ze,getElementRects:Qe,getClientRects:Re,getDimensions:qe,getScale:Q,isElement:W,isRTL:$e};function tt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function nt(e,t){let n=null,r,i=U(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=v(d),_=v(i.clientWidth-(u+f)),y=v(i.clientHeight-(d+p)),b=v(u),x={rootMargin:-m+`px `+-_+`px `+-y+`px `+-b+`px`,threshold:g(0,h(1,c))||1},S=!0;function C(t){let n=t[0].intersectionRatio;if(n!==c){if(!S)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!tt(l,e.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(C,{...x,root:i.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(e)}return o(!0),a}function rt(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=je(e),u=i||a?[...l?Z(l):[],...t?Z(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?nt(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?$(e):null;c&&g();function g(){let t=$(e);h&&!tt(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var it=fe,at=pe,ot=oe,st=he,ct=le,lt=ae,ut=me,dt=(e,t,n)=>{let r=new Map,i={platform:et,...n},a={...i.platform,_c:r};return ie(e,t,{...i,platform:a})},ft=e(l(),1),pt=typeof document<`u`?u.useLayoutEffect:function(){};function mt(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(!mt(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;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!mt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function ht(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gt(e,t){let n=ht(e);return Math.round(t*n)/n}function _t(e){let t=u.useRef(e);return pt(()=>{t.current=e}),t}function vt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[d,f]=u.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=u.useState(r);mt(p,r)||m(r);let[h,g]=u.useState(null),[_,v]=u.useState(null),y=u.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=u.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=u.useRef(null),w=u.useRef(null),T=u.useRef(d),E=c!=null,D=_t(c),O=_t(i),k=_t(l),A=u.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:p};O.current&&(e.platform=O.current),dt(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!mt(T.current,t)&&(T.current=t,ft.flushSync(()=>{f(t)}))})},[p,t,n,O,k]);pt(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[l]);let j=u.useRef(!1);pt(()=>(j.current=!0,()=>{j.current=!1}),[]),pt(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=u.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=u.useMemo(()=>({reference:x,floating:S}),[x,S]),P=u.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=gt(N.floating,d.x),r=gt(N.floating,d.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...ht(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,d.x,d.y]);return u.useMemo(()=>({...d,update:A,refs:M,elements:N,floatingStyles:P}),[d,A,M,N,P])}var yt=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:lt({element:r.current,padding:i}).fn(n):r?lt({element:r,padding:i}).fn(n):{}}}},bt=(e,t)=>{let n=it(e);return{name:n.name,fn:n.fn,options:[e,t]}},xt=(e,t)=>{let n=at(e);return{name:n.name,fn:n.fn,options:[e,t]}},St=(e,t)=>({fn:ut(e).fn,options:[e,t]}),Ct=(e,t)=>{let n=ot(e);return{name:n.name,fn:n.fn,options:[e,t]}},wt=(e,t)=>{let n=st(e);return{name:n.name,fn:n.fn,options:[e,t]}},Tt=(e,t)=>{let n=ct(e);return{name:n.name,fn:n.fn,options:[e,t]}},Et=(e,t)=>{let n=yt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dt=`Arrow`,Ot=u.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,d.jsx)(s.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,d.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Ot.displayName=Dt;var kt=Ot,At=`Popper`,[jt,Mt]=c(At),[Nt,Pt]=jt(At),Ft=e=>{let{__scopePopper:t,children:n}=e,[r,i]=u.useState(null);return(0,d.jsx)(Nt,{scope:t,anchor:r,onAnchorChange:i,children:n})};Ft.displayName=At;var It=`PopperAnchor`,Lt=u.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...a}=e,o=Pt(It,n),c=u.useRef(null),l=i(t,c),f=u.useRef(null);return u.useEffect(()=>{let e=f.current;f.current=r?.current||c.current,e!==f.current&&o.onAnchorChange(f.current)}),r?null:(0,d.jsx)(s.div,{...a,ref:l})});Lt.displayName=It;var Rt=`PopperContent`,[zt,Bt]=jt(Rt),Vt=u.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:c=0,align:l=`center`,alignOffset:f=0,arrowPadding:m=0,avoidCollisions:h=!0,collisionBoundary:g=[],collisionPadding:_=0,sticky:v=`partial`,hideWhenDetached:y=!1,updatePositionStrategy:b=`optimized`,onPlaced:x,...S}=e,C=Pt(Rt,n),[w,T]=u.useState(null),E=i(t,e=>T(e)),[D,O]=u.useState(null),k=p(D),A=k?.width??0,j=k?.height??0,M=r+(l===`center`?``:`-`+l),N=typeof _==`number`?_:{top:0,right:0,bottom:0,left:0,..._},P=Array.isArray(g)?g:[g],ee=P.length>0,F={padding:N,boundary:P.filter(Gt),altBoundary:ee},{refs:I,floatingStyles:L,placement:R,isPositioned:z,middlewareData:B}=vt({strategy:`fixed`,placement:M,whileElementsMounted:(...e)=>rt(...e,{animationFrame:b===`always`}),elements:{reference:C.anchor},middleware:[bt({mainAxis:c+j,alignmentAxis:f}),h&&xt({mainAxis:!0,crossAxis:!1,limiter:v===`partial`?St():void 0,...F}),h&&Ct({...F}),wt({...F,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),D&&Et({element:D,padding:m}),Kt({arrowWidth:A,arrowHeight:j}),y&&Tt({strategy:`referenceHidden`,...F})]}),[te,ne]=qt(R),re=a(x);o(()=>{z&&re?.()},[z,re]);let ie=B.arrow?.x,ae=B.arrow?.y,oe=B.arrow?.centerOffset!==0,[se,ce]=u.useState();return o(()=>{w&&ce(window.getComputedStyle(w).zIndex)},[w]),(0,d.jsx)(`div`,{ref:I.setFloating,"data-radix-popper-content-wrapper":``,style:{...L,transform:z?L.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:se,"--radix-popper-transform-origin":[B.transformOrigin?.x,B.transformOrigin?.y].join(` `),...B.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,d.jsx)(zt,{scope:n,placedSide:te,onArrowChange:O,arrowX:ie,arrowY:ae,shouldHideArrow:oe,children:(0,d.jsx)(s.div,{"data-side":te,"data-align":ne,...S,ref:E,style:{...S.style,animation:z?void 0:`none`}})})})});Vt.displayName=Rt;var Ht=`PopperArrow`,Ut={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Wt=u.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Bt(Ht,n),a=Ut[i.placedSide];return(0,d.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,d.jsx)(kt,{...r,ref:t,style:{...r.style,display:`block`}})})});Wt.displayName=Ht;function Gt(e){return e!==null}var Kt=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=qt(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function qt(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Jt=Ft,Yt=Lt,Xt=Vt,Zt=Wt;export{Mt as a,Jt as i,Zt as n,f as o,Xt as r,Yt as t};
1
+ import{a as e,r as t,t as n}from"./jsx-runtime-BFALxl05.js";import{_ as r,b as i,c as a,d as o,h as s,m as c,x as l}from"./button-CQ5h5gxS.js";var u=e(t(),1),d=n();function f(e){let t=e+`CollectionProvider`,[n,a]=c(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),l=e=>{let{scope:t,children:n}=e,r=u.useRef(null),i=u.useRef(new Map).current;return(0,d.jsx)(o,{scope:t,itemMap:i,collectionRef:r,children:n})};l.displayName=t;let f=e+`CollectionSlot`,p=r(f),m=u.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,d.jsx)(p,{ref:i(t,s(f,n).collectionRef),children:r})});m.displayName=f;let h=e+`CollectionItemSlot`,g=`data-radix-collection-item`,_=r(h),v=u.forwardRef((e,t)=>{let{scope:n,children:r,...a}=e,o=u.useRef(null),c=i(t,o),l=s(h,n);return u.useEffect(()=>(l.itemMap.set(o,{ref:o,...a}),()=>void l.itemMap.delete(o))),(0,d.jsx)(_,{[g]:``,ref:c,children:r})});v.displayName=h;function y(t){let n=s(e+`CollectionConsumer`,t);return u.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${g}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:l,Slot:m,ItemSlot:v},y,a]}function p(e){let[t,n]=u.useState(void 0);return o(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var m=[`top`,`right`,`bottom`,`left`],h=Math.min,g=Math.max,_=Math.round,v=Math.floor,y=e=>({x:e,y:e}),b={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function x(e,t,n){return g(e,h(t,n))}function S(e,t){return typeof e==`function`?e(t):e}function C(e){return e.split(`-`)[0]}function w(e){return e.split(`-`)[1]}function T(e){return e===`x`?`y`:`x`}function E(e){return e===`y`?`height`:`width`}function D(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function O(e){return T(D(e))}function k(e,t,n){n===void 0&&(n=!1);let r=w(e),i=O(e),a=E(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=L(o)),[o,L(o)]}function A(e){let t=L(e);return[j(e),t,j(t)]}function j(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var M=[`left`,`right`],N=[`right`,`left`],P=[`top`,`bottom`],ee=[`bottom`,`top`];function F(e,t,n){switch(e){case`top`:case`bottom`:return n?t?N:M:t?M:N;case`left`:case`right`:return t?P:ee;default:return[]}}function I(e,t,n,r){let i=w(e),a=F(C(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(j)))),a}function L(e){let t=C(e);return b[t]+e.slice(t.length)}function R(e){return{top:0,right:0,bottom:0,left:0,...e}}function z(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:R(e)}function B(e){let{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 te(e,t,n){let{reference:r,floating:i}=e,a=D(t),o=O(t),s=E(o),c=C(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(w(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function ne(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=S(t,e),p=z(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=B(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=B(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var re=50,ie=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:ne},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=te(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<re&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=te(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},ae=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=S(e,t)||{};if(l==null)return{};let d=z(u),f={x:n,y:r},p=O(i),m=E(p),g=await o.getDimensions(l),_=p===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,C=a.reference[m]+a.reference[p]-f[p]-a.floating[m],T=f[p]-a.reference[p],D=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),k=D?D[b]:0;(!k||!await(o.isElement==null?void 0:o.isElement(D)))&&(k=s.floating[b]||a.floating[m]);let A=C/2-T/2,j=k/2-g[m]/2-1,M=h(d[v],j),N=h(d[y],j),P=M,ee=k-g[m]-N,F=k/2-g[m]/2+A,I=x(P,F,ee),L=!c.arrow&&w(i)!=null&&F!==I&&a.reference[m]/2-(F<P?M:N)-g[m]/2<0,R=L?F<P?F-P:F-ee:0;return{[p]:f[p]+R,data:{[p]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),oe=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=S(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=C(r),_=D(o),v=C(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[L(o)]:A(o)),x=p!==`none`;!d&&x&&b.push(...I(o,m,p,y));let w=[o,...b],T=await s.detectOverflow(t,h),E=[],O=i.flip?.overflows||[];if(l&&E.push(T[g]),u){let e=k(r,a,y);E.push(T[e[0]],T[e[1]])}if(O=[...O,{placement:r,overflows:E}],!E.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=w[e];if(t&&(!(u===`alignment`&&_!==D(t))||O.every(e=>D(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:O},reset:{placement:t}};let n=O.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=O.filter(e=>{if(x){let t=D(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function se(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ce(e){return m.some(t=>e[t]>=0)}var le=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=S(e,t);switch(i){case`referenceHidden`:{let e=se(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:ce(e)}}}case`escaped`:{let e=se(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:ce(e)}}}default:return{}}}}},ue=new Set([`left`,`top`]);async function de(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=C(n),s=w(n),c=D(n)===`y`,l=ue.has(o)?-1:1,u=a&&c?-1:1,d=S(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var fe=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await de(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},pe=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=S(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=D(C(i)),p=T(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=x(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=x(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},me=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=S(e,t),u={x:n,y:r},d=D(i),f=T(d),p=u[f],m=u[d],h=S(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=ue.has(C(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},he=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=S(e,t),u=await o.detectOverflow(t,l),d=C(i),f=w(i),p=D(i)===`y`,{width:m,height:_}=a.floating,v,y;d===`top`||d===`bottom`?(v=d,y=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(y=d,v=f===`end`?`top`:`bottom`);let b=_-u.top-u.bottom,x=m-u.left-u.right,T=h(_-u[v],b),E=h(m-u[y],x),O=!t.middlewareData.shift,k=T,A=E;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=b),O&&!f){let e=g(u.left,0),t=g(u.right,0),n=g(u.top,0),r=g(u.bottom,0);p?A=m-2*(e!==0||t!==0?e+t:g(u.left,u.right)):k=_-2*(n!==0||r!==0?n+r:g(u.top,u.bottom))}await c({...t,availableWidth:A,availableHeight:k});let j=await o.getDimensions(s.floating);return m!==j.width||_!==j.height?{reset:{rects:!0}}:{}}}};function ge(){return typeof window<`u`}function V(e){return _e(e)?(e.nodeName||``).toLowerCase():`#document`}function H(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function U(e){return((_e(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function _e(e){return ge()?e instanceof Node||e instanceof H(e).Node:!1}function W(e){return ge()?e instanceof Element||e instanceof H(e).Element:!1}function G(e){return ge()?e instanceof HTMLElement||e instanceof H(e).HTMLElement:!1}function ve(e){return!ge()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof H(e).ShadowRoot}function K(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Y(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function ye(e){return/^(table|td|th)$/.test(V(e))}function be(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var xe=/transform|translate|scale|rotate|perspective|filter/,Se=/paint|layout|strict|content/,q=e=>!!e&&e!==`none`,Ce;function we(e){let t=W(e)?Y(e):e;return q(t.transform)||q(t.translate)||q(t.scale)||q(t.rotate)||q(t.perspective)||!Ee()&&(q(t.backdropFilter)||q(t.filter))||xe.test(t.willChange||``)||Se.test(t.contain||``)}function Te(e){let t=X(e);for(;G(t)&&!J(t);){if(we(t))return t;if(be(t))return null;t=X(t)}return null}function Ee(){return Ce??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Ce}function J(e){return/^(html|body|#document)$/.test(V(e))}function Y(e){return H(e).getComputedStyle(e)}function De(e){return W(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function X(e){if(V(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ve(e)&&e.host||U(e);return ve(t)?t.host:t}function Oe(e){let t=X(e);return J(t)?e.ownerDocument?e.ownerDocument.body:e.body:G(t)&&K(t)?t:Oe(t)}function Z(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Oe(e),i=r===e.ownerDocument?.body,a=H(r);if(i){let e=ke(a);return t.concat(a,a.visualViewport||[],K(r)?r:[],e&&n?Z(e):[])}else return t.concat(r,Z(r,[],n))}function ke(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ae(e){let t=Y(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=G(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=_(n)!==a||_(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function je(e){return W(e)?e:e.contextElement}function Q(e){let t=je(e);if(!G(t))return y(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Ae(t),o=(a?_(n.width):n.width)/r,s=(a?_(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Me=y(0);function Ne(e){let t=H(e);return!Ee()||!t.visualViewport?Me:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Pe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==H(e)?!1:t}function $(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=je(e),o=y(1);t&&(r?W(r)&&(o=Q(r)):o=Q(e));let s=Pe(a,n,r)?Ne(a):y(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=H(a),t=r&&W(r)?H(r):r,n=e,i=ke(n);for(;i&&r&&t!==n;){let e=Q(i),t=i.getBoundingClientRect(),r=Y(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=H(i),i=ke(n)}}return B({width:u,height:d,x:c,y:l})}function Fe(e,t){let n=De(e).scrollLeft;return t?t.left+n:$(U(e)).left+n}function Ie(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Fe(e,n),y:n.top+t.scrollTop}}function Le(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=U(r),s=t?be(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=y(1),u=y(0),d=G(r);if((d||!d&&!a)&&((V(r)!==`body`||K(o))&&(c=De(r)),d)){let e=$(r);l=Q(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Ie(o,c):y(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Re(e){return Array.from(e.getClientRects())}function ze(e){let t=U(e),n=De(e),r=e.ownerDocument.body,i=g(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=g(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Fe(e),s=-n.scrollTop;return Y(r).direction===`rtl`&&(o+=g(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Be=25;function Ve(e,t){let n=H(e),r=U(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Ee();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Fe(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Be&&(a-=o)}else l<=Be&&(a+=l);return{width:a,height:o,x:s,y:c}}function He(e,t){let n=$(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=G(e)?Q(e):y(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Ue(e,t,n){let r;if(t===`viewport`)r=Ve(e,n);else if(t===`document`)r=ze(U(e));else if(W(t))r=He(t,n);else{let n=Ne(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return B(r)}function We(e,t){let n=X(e);return n===t||!W(n)||J(n)?!1:Y(n).position===`fixed`||We(n,t)}function Ge(e,t){let n=t.get(e);if(n)return n;let r=Z(e,[],!1).filter(e=>W(e)&&V(e)!==`body`),i=null,a=Y(e).position===`fixed`,o=a?X(e):e;for(;W(o)&&!J(o);){let t=Y(o),n=we(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||K(o)&&!n&&We(e,o))?r=r.filter(e=>e!==o):i=t,o=X(o)}return t.set(e,r),r}function Ke(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?be(t)?[]:Ge(t,this._c):[].concat(n),r],o=Ue(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Ue(t,a[e],i);s=g(n.top,s),c=h(n.right,c),l=h(n.bottom,l),u=g(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function qe(e){let{width:t,height:n}=Ae(e);return{width:t,height:n}}function Je(e,t,n){let r=G(t),i=U(t),a=n===`fixed`,o=$(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=y(0);function l(){c.x=Fe(i)}if(r||!r&&!a)if((V(t)!==`body`||K(i))&&(s=De(t)),r){let e=$(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?Ie(i,s):y(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function Ye(e){return Y(e).position===`static`}function Xe(e,t){if(!G(e)||Y(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return U(e)===n&&(n=n.ownerDocument.body),n}function Ze(e,t){let n=H(e);if(be(e))return n;if(!G(e)){let t=X(e);for(;t&&!J(t);){if(W(t)&&!Ye(t))return t;t=X(t)}return n}let r=Xe(e,t);for(;r&&ye(r)&&Ye(r);)r=Xe(r,t);return r&&J(r)&&Ye(r)&&!we(r)?n:r||Te(e)||n}var Qe=async function(e){let t=this.getOffsetParent||Ze,n=this.getDimensions,r=await n(e.floating);return{reference:Je(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function $e(e){return Y(e).direction===`rtl`}var et={convertOffsetParentRelativeRectToViewportRelativeRect:Le,getDocumentElement:U,getClippingRect:Ke,getOffsetParent:Ze,getElementRects:Qe,getClientRects:Re,getDimensions:qe,getScale:Q,isElement:W,isRTL:$e};function tt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function nt(e,t){let n=null,r,i=U(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=v(d),_=v(i.clientWidth-(u+f)),y=v(i.clientHeight-(d+p)),b=v(u),x={rootMargin:-m+`px `+-_+`px `+-y+`px `+-b+`px`,threshold:g(0,h(1,c))||1},S=!0;function C(t){let n=t[0].intersectionRatio;if(n!==c){if(!S)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!tt(l,e.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(C,{...x,root:i.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(e)}return o(!0),a}function rt(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=je(e),u=i||a?[...l?Z(l):[],...t?Z(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?nt(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?$(e):null;c&&g();function g(){let t=$(e);h&&!tt(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var it=fe,at=pe,ot=oe,st=he,ct=le,lt=ae,ut=me,dt=(e,t,n)=>{let r=new Map,i={platform:et,...n},a={...i.platform,_c:r};return ie(e,t,{...i,platform:a})},ft=e(l(),1),pt=typeof document<`u`?u.useLayoutEffect:function(){};function mt(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(!mt(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;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!mt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function ht(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gt(e,t){let n=ht(e);return Math.round(t*n)/n}function _t(e){let t=u.useRef(e);return pt(()=>{t.current=e}),t}function vt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[d,f]=u.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=u.useState(r);mt(p,r)||m(r);let[h,g]=u.useState(null),[_,v]=u.useState(null),y=u.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=u.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=u.useRef(null),w=u.useRef(null),T=u.useRef(d),E=c!=null,D=_t(c),O=_t(i),k=_t(l),A=u.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:p};O.current&&(e.platform=O.current),dt(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!mt(T.current,t)&&(T.current=t,ft.flushSync(()=>{f(t)}))})},[p,t,n,O,k]);pt(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[l]);let j=u.useRef(!1);pt(()=>(j.current=!0,()=>{j.current=!1}),[]),pt(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=u.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=u.useMemo(()=>({reference:x,floating:S}),[x,S]),P=u.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=gt(N.floating,d.x),r=gt(N.floating,d.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...ht(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,d.x,d.y]);return u.useMemo(()=>({...d,update:A,refs:M,elements:N,floatingStyles:P}),[d,A,M,N,P])}var yt=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:lt({element:r.current,padding:i}).fn(n):r?lt({element:r,padding:i}).fn(n):{}}}},bt=(e,t)=>{let n=it(e);return{name:n.name,fn:n.fn,options:[e,t]}},xt=(e,t)=>{let n=at(e);return{name:n.name,fn:n.fn,options:[e,t]}},St=(e,t)=>({fn:ut(e).fn,options:[e,t]}),Ct=(e,t)=>{let n=ot(e);return{name:n.name,fn:n.fn,options:[e,t]}},wt=(e,t)=>{let n=st(e);return{name:n.name,fn:n.fn,options:[e,t]}},Tt=(e,t)=>{let n=ct(e);return{name:n.name,fn:n.fn,options:[e,t]}},Et=(e,t)=>{let n=yt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dt=`Arrow`,Ot=u.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,d.jsx)(s.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,d.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Ot.displayName=Dt;var kt=Ot,At=`Popper`,[jt,Mt]=c(At),[Nt,Pt]=jt(At),Ft=e=>{let{__scopePopper:t,children:n}=e,[r,i]=u.useState(null);return(0,d.jsx)(Nt,{scope:t,anchor:r,onAnchorChange:i,children:n})};Ft.displayName=At;var It=`PopperAnchor`,Lt=u.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...a}=e,o=Pt(It,n),c=u.useRef(null),l=i(t,c),f=u.useRef(null);return u.useEffect(()=>{let e=f.current;f.current=r?.current||c.current,e!==f.current&&o.onAnchorChange(f.current)}),r?null:(0,d.jsx)(s.div,{...a,ref:l})});Lt.displayName=It;var Rt=`PopperContent`,[zt,Bt]=jt(Rt),Vt=u.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:c=0,align:l=`center`,alignOffset:f=0,arrowPadding:m=0,avoidCollisions:h=!0,collisionBoundary:g=[],collisionPadding:_=0,sticky:v=`partial`,hideWhenDetached:y=!1,updatePositionStrategy:b=`optimized`,onPlaced:x,...S}=e,C=Pt(Rt,n),[w,T]=u.useState(null),E=i(t,e=>T(e)),[D,O]=u.useState(null),k=p(D),A=k?.width??0,j=k?.height??0,M=r+(l===`center`?``:`-`+l),N=typeof _==`number`?_:{top:0,right:0,bottom:0,left:0,..._},P=Array.isArray(g)?g:[g],ee=P.length>0,F={padding:N,boundary:P.filter(Gt),altBoundary:ee},{refs:I,floatingStyles:L,placement:R,isPositioned:z,middlewareData:B}=vt({strategy:`fixed`,placement:M,whileElementsMounted:(...e)=>rt(...e,{animationFrame:b===`always`}),elements:{reference:C.anchor},middleware:[bt({mainAxis:c+j,alignmentAxis:f}),h&&xt({mainAxis:!0,crossAxis:!1,limiter:v===`partial`?St():void 0,...F}),h&&Ct({...F}),wt({...F,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),D&&Et({element:D,padding:m}),Kt({arrowWidth:A,arrowHeight:j}),y&&Tt({strategy:`referenceHidden`,...F})]}),[te,ne]=qt(R),re=a(x);o(()=>{z&&re?.()},[z,re]);let ie=B.arrow?.x,ae=B.arrow?.y,oe=B.arrow?.centerOffset!==0,[se,ce]=u.useState();return o(()=>{w&&ce(window.getComputedStyle(w).zIndex)},[w]),(0,d.jsx)(`div`,{ref:I.setFloating,"data-radix-popper-content-wrapper":``,style:{...L,transform:z?L.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:se,"--radix-popper-transform-origin":[B.transformOrigin?.x,B.transformOrigin?.y].join(` `),...B.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,d.jsx)(zt,{scope:n,placedSide:te,onArrowChange:O,arrowX:ie,arrowY:ae,shouldHideArrow:oe,children:(0,d.jsx)(s.div,{"data-side":te,"data-align":ne,...S,ref:E,style:{...S.style,animation:z?void 0:`none`}})})})});Vt.displayName=Rt;var Ht=`PopperArrow`,Ut={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Wt=u.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Bt(Ht,n),a=Ut[i.placedSide];return(0,d.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,d.jsx)(kt,{...r,ref:t,style:{...r.style,display:`block`}})})});Wt.displayName=Ht;function Gt(e){return e!==null}var Kt=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=qt(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function qt(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Jt=Ft,Yt=Lt,Xt=Vt,Zt=Wt;export{Mt as a,Jt as i,Zt as n,f as o,Xt as r,Yt as t};
@@ -1 +1 @@
1
- import{a as e,n as t,r as n,t as r}from"./jsx-runtime-BFALxl05.js";import{t as i}from"./button-CvHWF07y.js";import{t as a}from"./arrow-up-from-line-DjfWTP75.js";import{t as o}from"./copy-B-kLwqzg.js";import{t as s}from"./external-link-Dim3NH6h.js";import{t as c}from"./refresh-cw-DJSjl6Ev.js";import{t as l}from"./trash-2-CjahwKg8.js";import{a as u,i as d,n as f,o as p,t as m}from"./dialog-f3IZM-6v.js";import{r as h,t as g}from"./api-client-B_eCZViO.js";import{_ as ee,a as _,i as v,l as te,n as ne,o as y,r as b,s as x,v as S}from"./index-Bqv1oZyQ.js";var re=t(`cherry`,[[`path`,{d:`M2 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z`,key:`cvxqlc`}],[`path`,{d:`M12 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z`,key:`1ostrc`}],[`path`,{d:`M7 14c3.22-2.91 4.29-8.75 5-12 1.66 2.38 4.94 9 5 12`,key:`hqx58h`}],[`path`,{d:`M22 9c-4.29 0-7.14-2.33-10-7 5.71 0 10 4.67 10 7Z`,key:`eykp1o`}]]),C=t(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),ie=t(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),ae=t(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),w=t(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),T=e(n(),1),E=r(),D=[`#4fc3f7`,`#81c784`,`#ffb74d`,`#e57373`,`#ba68c8`,`#4dd0e1`,`#aed581`,`#ff8a65`,`#f06292`,`#7986cb`],O=32,k=20,oe=5;function A({metadata:e}){let t=e?.projectName,[n,r]=(0,T.useState)(null),[a,s]=(0,T.useState)(!0),[l,C]=(0,T.useState)(null),[A,j]=(0,T.useState)(!1),[M,N]=(0,T.useState)({type:null}),[P,F]=(0,T.useState)(``),[I,L]=(0,T.useState)(null),[R,z]=(0,T.useState)([]),[ce,B]=(0,T.useState)(!1),{openTab:V}=te(),H=(0,T.useCallback)(async()=>{if(t)try{s(!0),r(await g.get(`${h(t)}/git/graph?max=200`)),C(null)}catch(e){C(e instanceof Error?e.message:`Failed to fetch graph`)}finally{s(!1)}},[t]);(0,T.useEffect)(()=>{H();let e=setInterval(H,1e4);return()=>clearInterval(e)},[H]);let U=async(e,n)=>{if(t){j(!0);try{await g.post(`${h(t)}${e}`,n),await H()}catch(e){C(e instanceof Error?e.message:`Action failed`)}finally{j(!1)}}},W=e=>U(`/git/checkout`,{ref:e}),le=e=>U(`/git/cherry-pick`,{hash:e}),ue=e=>U(`/git/revert`,{hash:e}),de=e=>U(`/git/merge`,{source:e}),fe=e=>U(`/git/branch/delete`,{name:e}),pe=e=>U(`/git/push`,{branch:e}),G=async(e,t)=>{if(n?.branches.some(t=>t.name===e||t.name.endsWith(`/${e}`))){if(!window.confirm(`Branch "${e}" already exists.\nDelete it and recreate from this commit?`))return;await U(`/git/branch/delete`,{name:e})}await U(`/git/branch/create`,{name:e,from:t})},K=(e,t)=>U(`/git/tag`,{name:e,hash:t}),me=async e=>{if(t)try{let n=await g.get(`${h(t)}/git/pr-url?branch=${encodeURIComponent(e)}`);n.url&&window.open(n.url,`_blank`)}catch{}},q=e=>{navigator.clipboard.writeText(e)},he=async e=>{if(I?.hash===e.hash){L(null);return}L(e),B(!0);try{let n=e.parents[0]??``,r=n?`ref1=${encodeURIComponent(n)}&`:``,i=await g.get(`${h(t)}/git/diff-stat?${r}ref2=${encodeURIComponent(e.hash)}`);z(Array.isArray(i)?i:[])}catch(e){console.error(`diff-stat error:`,e),z([])}finally{B(!1)}},ge=e=>{let n=e.parents[0];V({type:`git-diff`,title:`Diff ${e.abbreviatedHash}`,closable:!0,metadata:{projectName:t,ref1:n??void 0,ref2:e.hash},projectId:t??null})},{laneMap:J,maxLane:_e}=(0,T.useMemo)(()=>{let e=new Map;if(!n)return{laneMap:e,maxLane:0};let t=0,r=new Map;for(let i of n.commits){let n=r.get(i.hash);n===void 0&&(n=t++),e.set(i.hash,n),r.delete(i.hash);for(let e=0;e<i.parents.length;e++){let a=i.parents[e];r.has(a)||r.set(a,e===0?n:t++)}}return{laneMap:e,maxLane:Math.max(t-1,0)}},[n]),Y=n?.branches.find(e=>e.current),ve=(0,T.useMemo)(()=>{let e=new Map;if(!n)return e;for(let t of n.branches){let n=e.get(t.commitHash)??[];n.push({name:t.name,type:`branch`}),e.set(t.commitHash,n)}for(let t of n.commits)for(let n of t.refs)if(n.startsWith(`tag: `)){let r=n.replace(`tag: `,``),i=e.get(t.hash)??[];i.push({name:r,type:`tag`}),e.set(t.hash,i)}return e},[n]),ye=(0,T.useMemo)(()=>{if(!n)return[];let e=[];for(let t=0;t<n.commits.length;t++){let r=n.commits[t],i=J.get(r.hash)??0,a=D[i%D.length];for(let o of r.parents){let s=n.commits.findIndex(e=>e.hash===o);if(s<0)continue;let c=J.get(o)??0,l=D[c%D.length],u=i*k+k/2,d=t*O+O/2,f=c*k+k/2,p=s*O+O/2,m,h=r.parents.indexOf(o)>0;if(u===f)m=`M ${u} ${d} L ${f} ${p}`;else if(h){let e=d+O;m=`M ${u} ${d} C ${u} ${e} ${f} ${d} ${f} ${e} L ${f} ${p}`}else{let e=p-O;m=`M ${u} ${d} L ${u} ${e} C ${u} ${p} ${f} ${e} ${f} ${p}`}let g=r.parents.indexOf(o)===0?a:l;e.push({d:m,color:g})}}return e},[n,J]);(_e+1)*k+k;let X=(n?.commits.length??0)*O,[Z,be]=(0,T.useState)((typeof window<`u`&&window.innerWidth<768?6:10)*k+k),Q=(0,T.useRef)(!1),$=(0,T.useCallback)(e=>{Q.current=!0;let t=Z,n=n=>{if(!Q.current)return;let r=`touches`in n?n.touches[0].clientX:n.clientX;be(Math.max(40,t+r-e))},r=()=>{Q.current=!1,window.removeEventListener(`mousemove`,n),window.removeEventListener(`mouseup`,r),window.removeEventListener(`touchmove`,n),window.removeEventListener(`touchend`,r)};window.addEventListener(`mousemove`,n),window.addEventListener(`mouseup`,r),window.addEventListener(`touchmove`,n,{passive:!1}),window.addEventListener(`touchend`,r)},[Z]),xe=(0,T.useCallback)(e=>{e.preventDefault(),$(e.clientX)},[$]),Se=(0,T.useCallback)(e=>{$(e.touches[0].clientX)},[$]);if(!t)return(0,E.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`});if(a&&!n)return(0,E.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,E.jsx)(ee,{className:`size-5 animate-spin`}),(0,E.jsx)(`span`,{className:`text-sm`,children:`Loading git graph...`})]});if(l&&!n)return(0,E.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-destructive text-sm`,children:[(0,E.jsx)(`p`,{children:l}),(0,E.jsx)(i,{variant:`outline`,size:`sm`,onClick:H,children:`Retry`})]});function Ce(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);if(a<30)return`${a}d ago`;let o=Math.floor(a/30);return o<12?`${o}mo ago`:`${Math.floor(o/12)}y ago`}return(0,E.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b`,children:[(0,E.jsxs)(`span`,{className:`text-sm font-medium`,children:[`Git Graph`,Y?` - ${Y.name}`:``]}),(0,E.jsx)(i,{variant:`ghost`,size:`icon-xs`,onClick:H,disabled:A,children:(0,E.jsx)(c,{className:a?`animate-spin`:``})})]}),l&&(0,E.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive bg-destructive/10`,children:l}),(0,E.jsx)(`div`,{className:`flex-1 overflow-y-auto overflow-x-auto md:overflow-x-hidden`,children:(0,E.jsxs)(`div`,{className:`flex min-w-max md:min-w-0`,style:{height:`${X}px`},children:[(0,E.jsxs)(`div`,{className:`sticky left-0 z-10 shrink-0 bg-background`,style:{width:`${Z}px`},children:[(0,E.jsxs)(`svg`,{width:Z,height:X,children:[ye.map((e,t)=>(0,E.jsx)(`path`,{d:e.d,stroke:e.color,strokeWidth:2,fill:`none`},t)),n?.commits.map((e,t)=>{let n=J.get(e.hash)??0,r=n*k+k/2,i=t*O+O/2,a=D[n%D.length];return(0,E.jsx)(`circle`,{cx:r,cy:i,r:oe,fill:a,stroke:`#0f1419`,strokeWidth:2},e.hash)})]}),(0,E.jsx)(`div`,{className:`absolute top-0 right-0 w-3 md:w-2 h-full cursor-col-resize hover:bg-primary/20 flex items-center justify-center bg-primary/10 md:bg-transparent`,onMouseDown:xe,onTouchStart:Se,children:(0,E.jsx)(ie,{className:`size-3 text-muted-foreground md:opacity-0 md:hover:opacity-100`})})]}),(0,E.jsx)(`div`,{className:`flex-1 min-w-[400px]`,children:n?.commits.map((e,t)=>{let n=D[(J.get(e.hash)??0)%D.length],r=ve.get(e.hash)??[],i=r.filter(e=>e.type===`branch`),a=r.filter(e=>e.type===`tag`);return(0,E.jsxs)(b,{children:[(0,E.jsx)(x,{asChild:!0,children:(0,E.jsx)(`div`,{className:`flex items-center hover:bg-muted/50 cursor-pointer text-sm border-b border-border/30 ${I?.hash===e.hash?`bg-primary/10`:``}`,style:{height:`${O}px`},onClick:()=>he(e),children:(0,E.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0 px-2`,children:[(0,E.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground w-14 shrink-0`,children:e.abbreviatedHash}),i.map(e=>(0,E.jsx)(se,{label:e,color:n,currentBranch:Y,onCheckout:W,onMerge:de,onPush:pe,onCreatePr:me,onDelete:fe},`branch-${e.name}`)),a.map(e=>(0,E.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium shrink-0 bg-amber-500/20 text-amber-500 border border-amber-500/30`,children:[(0,E.jsx)(w,{className:`size-2.5`}),e.name]},`tag-${e.name}`)),(0,E.jsx)(`span`,{className:`flex-1 truncate`,children:e.subject}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0 hidden sm:inline`,children:e.authorName}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0 w-14 text-right`,children:Ce(e.authorDate)})]})})}),(0,E.jsxs)(v,{children:[(0,E.jsx)(_,{onClick:()=>W(e.hash),children:`Checkout`}),(0,E.jsxs)(_,{onClick:()=>{N({type:`branch`,hash:e.hash}),F(``)},children:[(0,E.jsx)(S,{className:`size-3`}),`Create Branch...`]}),(0,E.jsx)(y,{}),(0,E.jsxs)(_,{onClick:()=>le(e.hash),children:[(0,E.jsx)(re,{className:`size-3`}),`Cherry Pick`]}),(0,E.jsxs)(_,{onClick:()=>ue(e.hash),children:[(0,E.jsx)(ae,{className:`size-3`}),`Revert`]}),(0,E.jsxs)(_,{onClick:()=>{N({type:`tag`,hash:e.hash}),F(``)},children:[(0,E.jsx)(w,{className:`size-3`}),`Create Tag...`]}),(0,E.jsx)(y,{}),(0,E.jsx)(_,{onClick:()=>ge(e),children:`View Diff`}),(0,E.jsxs)(_,{onClick:()=>q(e.hash),children:[(0,E.jsx)(o,{className:`size-3`}),`Copy Hash`]})]})]},e.hash)})})]})}),I&&(0,E.jsxs)(`div`,{className:`border-t bg-muted/30 max-h-[40%] overflow-auto`,children:[(0,E.jsxs)(`div`,{className:`px-3 py-2 border-b flex items-center justify-between`,children:[(0,E.jsxs)(`span`,{className:`text-sm font-medium truncate`,children:[I.abbreviatedHash,` — `,I.subject]}),(0,E.jsx)(i,{variant:`ghost`,size:`icon-xs`,onClick:()=>L(null),children:`✕`})]}),(0,E.jsxs)(`div`,{className:`px-3 py-2 text-xs space-y-1`,children:[(0,E.jsxs)(`div`,{className:`flex gap-4`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`Author`}),(0,E.jsxs)(`span`,{children:[I.authorName,` <`,I.authorEmail,`>`]})]}),(0,E.jsxs)(`div`,{className:`flex gap-4`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`Date`}),(0,E.jsx)(`span`,{children:new Date(I.authorDate).toLocaleString()})]}),(0,E.jsxs)(`div`,{className:`flex gap-4`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`Hash`}),(0,E.jsx)(`span`,{className:`font-mono cursor-pointer hover:text-primary`,onClick:()=>q(I.hash),children:I.hash})]}),I.parents.length>0&&(0,E.jsxs)(`div`,{className:`flex gap-4`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`Parents`}),(0,E.jsx)(`span`,{className:`font-mono`,children:I.parents.map(e=>e.slice(0,7)).join(`, `)})]}),I.body&&(0,E.jsx)(`div`,{className:`mt-2 p-2 bg-background rounded text-xs whitespace-pre-wrap`,children:I.body})]}),(0,E.jsxs)(`div`,{className:`px-3 py-1 border-t`,children:[(0,E.jsx)(`div`,{className:`text-xs text-muted-foreground py-1`,children:ce?`Loading files...`:`${R.length} file${R.length===1?``:`s`} changed`}),R.map(e=>(0,E.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5 text-xs hover:bg-muted/50 rounded px-1 cursor-pointer`,onClick:()=>V({type:`git-diff`,title:`Diff ${e.path.split(`/`).pop()}`,closable:!0,metadata:{projectName:t,ref1:I.parents[0]??void 0,ref2:I.hash,filePath:e.path},projectId:t??null}),children:[(0,E.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:e.path}),e.additions>0&&(0,E.jsxs)(`span`,{className:`text-green-500`,children:[`+`,e.additions]}),e.deletions>0&&(0,E.jsxs)(`span`,{className:`text-red-500`,children:[`-`,e.deletions]})]},e.path))]})]}),(0,E.jsx)(m,{open:M.type!==null,onOpenChange:e=>{e||N({type:null})},children:(0,E.jsxs)(f,{children:[(0,E.jsx)(u,{children:(0,E.jsx)(p,{children:M.type===`branch`?`Create Branch`:`Create Tag`})}),(0,E.jsx)(ne,{placeholder:M.type===`branch`?`Branch name`:`Tag name`,value:P,onChange:e=>F(e.target.value),onKeyDown:e=>{e.key===`Enter`&&P.trim()&&(M.type===`branch`?G(P.trim(),M.hash):K(P.trim(),M.hash),N({type:null}))},autoFocus:!0}),(0,E.jsxs)(d,{children:[(0,E.jsx)(i,{variant:`outline`,onClick:()=>N({type:null}),children:`Cancel`}),(0,E.jsx)(i,{disabled:!P.trim(),onClick:()=>{M.type===`branch`?G(P.trim(),M.hash):K(P.trim(),M.hash),N({type:null})},children:`Create`})]})]})})]})}function se({label:e,color:t,currentBranch:n,onCheckout:r,onMerge:i,onPush:o,onCreatePr:c,onDelete:u}){return(0,E.jsxs)(b,{children:[(0,E.jsx)(x,{asChild:!0,children:(0,E.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium shrink-0 cursor-context-menu`,style:{backgroundColor:`${t}30`,color:t,border:`1px solid ${t}50`},children:[(0,E.jsx)(S,{className:`size-2.5`}),e.name]})}),(0,E.jsxs)(v,{children:[(0,E.jsx)(_,{onClick:()=>r(e.name),children:`Checkout`}),(0,E.jsxs)(_,{onClick:()=>i(e.name),disabled:e.name===n?.name,children:[(0,E.jsx)(C,{className:`size-3`}),`Merge into current`]}),(0,E.jsx)(y,{}),(0,E.jsxs)(_,{onClick:()=>o(e.name),children:[(0,E.jsx)(a,{className:`size-3`}),`Push`]}),(0,E.jsxs)(_,{onClick:()=>c(e.name),children:[(0,E.jsx)(s,{className:`size-3`}),`Create PR`]}),(0,E.jsx)(y,{}),(0,E.jsxs)(_,{variant:`destructive`,onClick:()=>u(e.name),disabled:e.name===n?.name,children:[(0,E.jsx)(l,{className:`size-3`}),`Delete`]})]})]})}export{A as GitGraph};
1
+ import{a as e,n as t,r as n,t as r}from"./jsx-runtime-BFALxl05.js";import{t as i}from"./button-CQ5h5gxS.js";import{t as a}from"./arrow-up-from-line-DjfWTP75.js";import{t as o}from"./copy-D_Q54D-v.js";import{t as s}from"./external-link-C6Y-D528.js";import{t as c}from"./refresh-cw-S6I91MHO.js";import{t as l}from"./trash-2-Dc17nbCE.js";import{a as u,i as d,n as f,o as p,t as m}from"./dialog-CCBmXo6-.js";import{r as h,t as g}from"./api-client-tgjN9Mx8.js";import{_ as ee,a as _,i as v,l as te,n as ne,o as y,r as b,s as x,v as S}from"./index-VKvV157O.js";var re=t(`cherry`,[[`path`,{d:`M2 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z`,key:`cvxqlc`}],[`path`,{d:`M12 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z`,key:`1ostrc`}],[`path`,{d:`M7 14c3.22-2.91 4.29-8.75 5-12 1.66 2.38 4.94 9 5 12`,key:`hqx58h`}],[`path`,{d:`M22 9c-4.29 0-7.14-2.33-10-7 5.71 0 10 4.67 10 7Z`,key:`eykp1o`}]]),C=t(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),ie=t(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),ae=t(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),w=t(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),T=e(n(),1),E=r(),D=[`#4fc3f7`,`#81c784`,`#ffb74d`,`#e57373`,`#ba68c8`,`#4dd0e1`,`#aed581`,`#ff8a65`,`#f06292`,`#7986cb`],O=32,k=20,oe=5;function A({metadata:e}){let t=e?.projectName,[n,r]=(0,T.useState)(null),[a,s]=(0,T.useState)(!0),[l,C]=(0,T.useState)(null),[A,j]=(0,T.useState)(!1),[M,N]=(0,T.useState)({type:null}),[P,F]=(0,T.useState)(``),[I,L]=(0,T.useState)(null),[R,z]=(0,T.useState)([]),[ce,B]=(0,T.useState)(!1),{openTab:V}=te(),H=(0,T.useCallback)(async()=>{if(t)try{s(!0),r(await g.get(`${h(t)}/git/graph?max=200`)),C(null)}catch(e){C(e instanceof Error?e.message:`Failed to fetch graph`)}finally{s(!1)}},[t]);(0,T.useEffect)(()=>{H();let e=setInterval(H,1e4);return()=>clearInterval(e)},[H]);let U=async(e,n)=>{if(t){j(!0);try{await g.post(`${h(t)}${e}`,n),await H()}catch(e){C(e instanceof Error?e.message:`Action failed`)}finally{j(!1)}}},W=e=>U(`/git/checkout`,{ref:e}),le=e=>U(`/git/cherry-pick`,{hash:e}),ue=e=>U(`/git/revert`,{hash:e}),de=e=>U(`/git/merge`,{source:e}),fe=e=>U(`/git/branch/delete`,{name:e}),pe=e=>U(`/git/push`,{branch:e}),G=async(e,t)=>{if(n?.branches.some(t=>t.name===e||t.name.endsWith(`/${e}`))){if(!window.confirm(`Branch "${e}" already exists.\nDelete it and recreate from this commit?`))return;await U(`/git/branch/delete`,{name:e})}await U(`/git/branch/create`,{name:e,from:t})},K=(e,t)=>U(`/git/tag`,{name:e,hash:t}),me=async e=>{if(t)try{let n=await g.get(`${h(t)}/git/pr-url?branch=${encodeURIComponent(e)}`);n.url&&window.open(n.url,`_blank`)}catch{}},q=e=>{navigator.clipboard.writeText(e)},he=async e=>{if(I?.hash===e.hash){L(null);return}L(e),B(!0);try{let n=e.parents[0]??``,r=n?`ref1=${encodeURIComponent(n)}&`:``,i=await g.get(`${h(t)}/git/diff-stat?${r}ref2=${encodeURIComponent(e.hash)}`);z(Array.isArray(i)?i:[])}catch(e){console.error(`diff-stat error:`,e),z([])}finally{B(!1)}},ge=e=>{let n=e.parents[0];V({type:`git-diff`,title:`Diff ${e.abbreviatedHash}`,closable:!0,metadata:{projectName:t,ref1:n??void 0,ref2:e.hash},projectId:t??null})},{laneMap:J,maxLane:_e}=(0,T.useMemo)(()=>{let e=new Map;if(!n)return{laneMap:e,maxLane:0};let t=0,r=new Map;for(let i of n.commits){let n=r.get(i.hash);n===void 0&&(n=t++),e.set(i.hash,n),r.delete(i.hash);for(let e=0;e<i.parents.length;e++){let a=i.parents[e];r.has(a)||r.set(a,e===0?n:t++)}}return{laneMap:e,maxLane:Math.max(t-1,0)}},[n]),Y=n?.branches.find(e=>e.current),ve=(0,T.useMemo)(()=>{let e=new Map;if(!n)return e;for(let t of n.branches){let n=e.get(t.commitHash)??[];n.push({name:t.name,type:`branch`}),e.set(t.commitHash,n)}for(let t of n.commits)for(let n of t.refs)if(n.startsWith(`tag: `)){let r=n.replace(`tag: `,``),i=e.get(t.hash)??[];i.push({name:r,type:`tag`}),e.set(t.hash,i)}return e},[n]),ye=(0,T.useMemo)(()=>{if(!n)return[];let e=[];for(let t=0;t<n.commits.length;t++){let r=n.commits[t],i=J.get(r.hash)??0,a=D[i%D.length];for(let o of r.parents){let s=n.commits.findIndex(e=>e.hash===o);if(s<0)continue;let c=J.get(o)??0,l=D[c%D.length],u=i*k+k/2,d=t*O+O/2,f=c*k+k/2,p=s*O+O/2,m,h=r.parents.indexOf(o)>0;if(u===f)m=`M ${u} ${d} L ${f} ${p}`;else if(h){let e=d+O;m=`M ${u} ${d} C ${u} ${e} ${f} ${d} ${f} ${e} L ${f} ${p}`}else{let e=p-O;m=`M ${u} ${d} L ${u} ${e} C ${u} ${p} ${f} ${e} ${f} ${p}`}let g=r.parents.indexOf(o)===0?a:l;e.push({d:m,color:g})}}return e},[n,J]);(_e+1)*k+k;let X=(n?.commits.length??0)*O,[Z,be]=(0,T.useState)((typeof window<`u`&&window.innerWidth<768?6:10)*k+k),Q=(0,T.useRef)(!1),$=(0,T.useCallback)(e=>{Q.current=!0;let t=Z,n=n=>{if(!Q.current)return;let r=`touches`in n?n.touches[0].clientX:n.clientX;be(Math.max(40,t+r-e))},r=()=>{Q.current=!1,window.removeEventListener(`mousemove`,n),window.removeEventListener(`mouseup`,r),window.removeEventListener(`touchmove`,n),window.removeEventListener(`touchend`,r)};window.addEventListener(`mousemove`,n),window.addEventListener(`mouseup`,r),window.addEventListener(`touchmove`,n,{passive:!1}),window.addEventListener(`touchend`,r)},[Z]),xe=(0,T.useCallback)(e=>{e.preventDefault(),$(e.clientX)},[$]),Se=(0,T.useCallback)(e=>{$(e.touches[0].clientX)},[$]);if(!t)return(0,E.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`});if(a&&!n)return(0,E.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,E.jsx)(ee,{className:`size-5 animate-spin`}),(0,E.jsx)(`span`,{className:`text-sm`,children:`Loading git graph...`})]});if(l&&!n)return(0,E.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-destructive text-sm`,children:[(0,E.jsx)(`p`,{children:l}),(0,E.jsx)(i,{variant:`outline`,size:`sm`,onClick:H,children:`Retry`})]});function Ce(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);if(a<30)return`${a}d ago`;let o=Math.floor(a/30);return o<12?`${o}mo ago`:`${Math.floor(o/12)}y ago`}return(0,E.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b`,children:[(0,E.jsxs)(`span`,{className:`text-sm font-medium`,children:[`Git Graph`,Y?` - ${Y.name}`:``]}),(0,E.jsx)(i,{variant:`ghost`,size:`icon-xs`,onClick:H,disabled:A,children:(0,E.jsx)(c,{className:a?`animate-spin`:``})})]}),l&&(0,E.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive bg-destructive/10`,children:l}),(0,E.jsx)(`div`,{className:`flex-1 overflow-y-auto overflow-x-auto md:overflow-x-hidden`,children:(0,E.jsxs)(`div`,{className:`flex min-w-max md:min-w-0`,style:{height:`${X}px`},children:[(0,E.jsxs)(`div`,{className:`sticky left-0 z-10 shrink-0 bg-background`,style:{width:`${Z}px`},children:[(0,E.jsxs)(`svg`,{width:Z,height:X,children:[ye.map((e,t)=>(0,E.jsx)(`path`,{d:e.d,stroke:e.color,strokeWidth:2,fill:`none`},t)),n?.commits.map((e,t)=>{let n=J.get(e.hash)??0,r=n*k+k/2,i=t*O+O/2,a=D[n%D.length];return(0,E.jsx)(`circle`,{cx:r,cy:i,r:oe,fill:a,stroke:`#0f1419`,strokeWidth:2},e.hash)})]}),(0,E.jsx)(`div`,{className:`absolute top-0 right-0 w-3 md:w-2 h-full cursor-col-resize hover:bg-primary/20 flex items-center justify-center bg-primary/10 md:bg-transparent`,onMouseDown:xe,onTouchStart:Se,children:(0,E.jsx)(ie,{className:`size-3 text-muted-foreground md:opacity-0 md:hover:opacity-100`})})]}),(0,E.jsx)(`div`,{className:`flex-1 min-w-[400px]`,children:n?.commits.map((e,t)=>{let n=D[(J.get(e.hash)??0)%D.length],r=ve.get(e.hash)??[],i=r.filter(e=>e.type===`branch`),a=r.filter(e=>e.type===`tag`);return(0,E.jsxs)(b,{children:[(0,E.jsx)(x,{asChild:!0,children:(0,E.jsx)(`div`,{className:`flex items-center hover:bg-muted/50 cursor-pointer text-sm border-b border-border/30 ${I?.hash===e.hash?`bg-primary/10`:``}`,style:{height:`${O}px`},onClick:()=>he(e),children:(0,E.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0 px-2`,children:[(0,E.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground w-14 shrink-0`,children:e.abbreviatedHash}),i.map(e=>(0,E.jsx)(se,{label:e,color:n,currentBranch:Y,onCheckout:W,onMerge:de,onPush:pe,onCreatePr:me,onDelete:fe},`branch-${e.name}`)),a.map(e=>(0,E.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium shrink-0 bg-amber-500/20 text-amber-500 border border-amber-500/30`,children:[(0,E.jsx)(w,{className:`size-2.5`}),e.name]},`tag-${e.name}`)),(0,E.jsx)(`span`,{className:`flex-1 truncate`,children:e.subject}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0 hidden sm:inline`,children:e.authorName}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0 w-14 text-right`,children:Ce(e.authorDate)})]})})}),(0,E.jsxs)(v,{children:[(0,E.jsx)(_,{onClick:()=>W(e.hash),children:`Checkout`}),(0,E.jsxs)(_,{onClick:()=>{N({type:`branch`,hash:e.hash}),F(``)},children:[(0,E.jsx)(S,{className:`size-3`}),`Create Branch...`]}),(0,E.jsx)(y,{}),(0,E.jsxs)(_,{onClick:()=>le(e.hash),children:[(0,E.jsx)(re,{className:`size-3`}),`Cherry Pick`]}),(0,E.jsxs)(_,{onClick:()=>ue(e.hash),children:[(0,E.jsx)(ae,{className:`size-3`}),`Revert`]}),(0,E.jsxs)(_,{onClick:()=>{N({type:`tag`,hash:e.hash}),F(``)},children:[(0,E.jsx)(w,{className:`size-3`}),`Create Tag...`]}),(0,E.jsx)(y,{}),(0,E.jsx)(_,{onClick:()=>ge(e),children:`View Diff`}),(0,E.jsxs)(_,{onClick:()=>q(e.hash),children:[(0,E.jsx)(o,{className:`size-3`}),`Copy Hash`]})]})]},e.hash)})})]})}),I&&(0,E.jsxs)(`div`,{className:`border-t bg-muted/30 max-h-[40%] overflow-auto`,children:[(0,E.jsxs)(`div`,{className:`px-3 py-2 border-b flex items-center justify-between`,children:[(0,E.jsxs)(`span`,{className:`text-sm font-medium truncate`,children:[I.abbreviatedHash,` — `,I.subject]}),(0,E.jsx)(i,{variant:`ghost`,size:`icon-xs`,onClick:()=>L(null),children:`✕`})]}),(0,E.jsxs)(`div`,{className:`px-3 py-2 text-xs space-y-1`,children:[(0,E.jsxs)(`div`,{className:`flex gap-4`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`Author`}),(0,E.jsxs)(`span`,{children:[I.authorName,` <`,I.authorEmail,`>`]})]}),(0,E.jsxs)(`div`,{className:`flex gap-4`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`Date`}),(0,E.jsx)(`span`,{children:new Date(I.authorDate).toLocaleString()})]}),(0,E.jsxs)(`div`,{className:`flex gap-4`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`Hash`}),(0,E.jsx)(`span`,{className:`font-mono cursor-pointer hover:text-primary`,onClick:()=>q(I.hash),children:I.hash})]}),I.parents.length>0&&(0,E.jsxs)(`div`,{className:`flex gap-4`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`Parents`}),(0,E.jsx)(`span`,{className:`font-mono`,children:I.parents.map(e=>e.slice(0,7)).join(`, `)})]}),I.body&&(0,E.jsx)(`div`,{className:`mt-2 p-2 bg-background rounded text-xs whitespace-pre-wrap`,children:I.body})]}),(0,E.jsxs)(`div`,{className:`px-3 py-1 border-t`,children:[(0,E.jsx)(`div`,{className:`text-xs text-muted-foreground py-1`,children:ce?`Loading files...`:`${R.length} file${R.length===1?``:`s`} changed`}),R.map(e=>(0,E.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5 text-xs hover:bg-muted/50 rounded px-1 cursor-pointer`,onClick:()=>V({type:`git-diff`,title:`Diff ${e.path.split(`/`).pop()}`,closable:!0,metadata:{projectName:t,ref1:I.parents[0]??void 0,ref2:I.hash,filePath:e.path},projectId:t??null}),children:[(0,E.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:e.path}),e.additions>0&&(0,E.jsxs)(`span`,{className:`text-green-500`,children:[`+`,e.additions]}),e.deletions>0&&(0,E.jsxs)(`span`,{className:`text-red-500`,children:[`-`,e.deletions]})]},e.path))]})]}),(0,E.jsx)(m,{open:M.type!==null,onOpenChange:e=>{e||N({type:null})},children:(0,E.jsxs)(f,{children:[(0,E.jsx)(u,{children:(0,E.jsx)(p,{children:M.type===`branch`?`Create Branch`:`Create Tag`})}),(0,E.jsx)(ne,{placeholder:M.type===`branch`?`Branch name`:`Tag name`,value:P,onChange:e=>F(e.target.value),onKeyDown:e=>{e.key===`Enter`&&P.trim()&&(M.type===`branch`?G(P.trim(),M.hash):K(P.trim(),M.hash),N({type:null}))},autoFocus:!0}),(0,E.jsxs)(d,{children:[(0,E.jsx)(i,{variant:`outline`,onClick:()=>N({type:null}),children:`Cancel`}),(0,E.jsx)(i,{disabled:!P.trim(),onClick:()=>{M.type===`branch`?G(P.trim(),M.hash):K(P.trim(),M.hash),N({type:null})},children:`Create`})]})]})})]})}function se({label:e,color:t,currentBranch:n,onCheckout:r,onMerge:i,onPush:o,onCreatePr:c,onDelete:u}){return(0,E.jsxs)(b,{children:[(0,E.jsx)(x,{asChild:!0,children:(0,E.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium shrink-0 cursor-context-menu`,style:{backgroundColor:`${t}30`,color:t,border:`1px solid ${t}50`},children:[(0,E.jsx)(S,{className:`size-2.5`}),e.name]})}),(0,E.jsxs)(v,{children:[(0,E.jsx)(_,{onClick:()=>r(e.name),children:`Checkout`}),(0,E.jsxs)(_,{onClick:()=>i(e.name),disabled:e.name===n?.name,children:[(0,E.jsx)(C,{className:`size-3`}),`Merge into current`]}),(0,E.jsx)(y,{}),(0,E.jsxs)(_,{onClick:()=>o(e.name),children:[(0,E.jsx)(a,{className:`size-3`}),`Push`]}),(0,E.jsxs)(_,{onClick:()=>c(e.name),children:[(0,E.jsx)(s,{className:`size-3`}),`Create PR`]}),(0,E.jsx)(y,{}),(0,E.jsxs)(_,{variant:`destructive`,onClick:()=>u(e.name),disabled:e.name===n?.name,children:[(0,E.jsx)(l,{className:`size-3`}),`Delete`]})]})]})}export{A as GitGraph};
@@ -1 +1 @@
1
- import{a as e,n as t,r as n,t as r}from"./jsx-runtime-BFALxl05.js";import{t as i}from"./button-CvHWF07y.js";import{t as a}from"./arrow-up-from-line-DjfWTP75.js";import{t as o}from"./refresh-cw-DJSjl6Ev.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./dialog-f3IZM-6v.js";import{r as p,t as m}from"./api-client-B_eCZViO.js";import{D as h,E as g,S as _,_ as v,h as y,l as b,u as x}from"./index-Bqv1oZyQ.js";var S=t(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),C=t(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),w=t(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),T=t(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),E=t(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),D=e(n(),1),O=r(),k={M:`text-yellow-500`,A:`text-green-500`,D:`text-red-500`,R:`text-blue-500`,C:`text-purple-500`,"?":`text-gray-400`};function A(e){let t=[];for(let n of e){let e=n.path.split(`/`),r=t;for(let t=0;t<e.length;t++){let i=e[t],a=e.slice(0,t+1).join(`/`),o=t===e.length-1,s=r.find(e=>e.name===i);s||(s={name:i,fullPath:a,file:o?n:void 0,children:[]},r.push(s)),o&&(s.file=n),r=s.children}}return t}function j(e){let t=[];e.file&&t.push(e.file);for(let n of e.children)t.push(...j(n));return t}function M({metadata:e,tabId:t}){let n=e?.projectName,[r,h]=(0,D.useState)(null),[g,_]=(0,D.useState)(!0),[E,k]=(0,D.useState)(null),[A,j]=(0,D.useState)(``),[M,N]=(0,D.useState)(!1),[F,I]=(0,D.useState)(null),{openTab:L,updateTab:R}=b(),z=e?.viewMode===`tree`?`tree`:`flat`,B=n=>{t&&R(t,{metadata:{...e,viewMode:n}})},V=(0,D.useCallback)(async()=>{if(n)try{_(!0),h(await m.get(`${p(n)}/git/status`)),k(null)}catch(e){k(e instanceof Error?e.message:`Failed to fetch status`)}finally{_(!1)}},[n]);(0,D.useEffect)(()=>{V();let e=setInterval(V,5e3);return()=>clearInterval(e)},[V]);let H=async e=>{if(n){N(!0);try{await m.post(`${p(n)}/git/stage`,{files:e}),await V()}catch(e){k(e instanceof Error?e.message:`Stage failed`)}finally{N(!1)}}},U=async e=>{if(n){N(!0);try{await m.post(`${p(n)}/git/unstage`,{files:e}),await V()}catch(e){k(e instanceof Error?e.message:`Unstage failed`)}finally{N(!1)}}},W=async e=>{if(n){N(!0);try{await m.post(`${p(n)}/git/discard`,{files:e}),await V()}catch(e){k(e instanceof Error?e.message:`Discard failed`)}finally{N(!1)}}},G=async()=>{F&&(await W(F.files),I(null))},K=async()=>{if(!(!n||!A.trim()||!r?.staged.length)){N(!0);try{await m.post(`${p(n)}/git/commit`,{message:A.trim()}),j(``),await V()}catch(e){k(e instanceof Error?e.message:`Commit failed`)}finally{N(!1)}}},q=async()=>{if(n){N(!0);try{await m.post(`${p(n)}/git/push`,{}),await V()}catch(e){k(e instanceof Error?e.message:`Push failed`)}finally{N(!1)}}},J=async()=>{if(n){N(!0);try{await m.post(`${p(n)}/git/pull`,{}),await V()}catch(e){k(e instanceof Error?e.message:`Pull failed`)}finally{N(!1)}}},Y=e=>{L({type:`git-diff`,title:e.path.split(`/`).pop()??e.path,closable:!0,metadata:{projectName:n,filePath:e.path},projectId:n??null})},X=e=>{L({type:`editor`,title:e.path.split(`/`).pop()??e.path,closable:!0,metadata:{projectName:n,filePath:e.path},projectId:n??null})},Z=(0,D.useMemo)(()=>[...r?.unstaged??[],...r?.untracked.map(e=>({path:e,status:`?`}))??[]],[r]);return n?g&&!r?(0,O.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,O.jsx)(v,{className:`size-5 animate-spin`}),(0,O.jsx)(`span`,{className:`text-sm`,children:`Loading git status...`})]}):E&&!r?(0,O.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-destructive text-sm`,children:[(0,O.jsx)(`p`,{children:E}),(0,O.jsx)(i,{variant:`outline`,size:`sm`,onClick:V,children:`Retry`})]}):(0,O.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b shrink-0`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium`,children:r?.current?`On: ${r.current}`:`Git Status`}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(i,{variant:z===`flat`?`secondary`:`ghost`,size:`icon-xs`,onClick:()=>B(`flat`),title:`Flat view`,children:(0,O.jsx)(w,{className:`size-3.5`})}),(0,O.jsx)(i,{variant:z===`tree`?`secondary`:`ghost`,size:`icon-xs`,onClick:()=>B(`tree`),title:`Tree view`,children:(0,O.jsx)(C,{className:`size-3.5`})}),(0,O.jsx)(i,{variant:`ghost`,size:`icon-xs`,onClick:V,disabled:M,children:(0,O.jsx)(o,{className:g?`animate-spin`:``})})]})]}),E&&(0,O.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0`,children:E}),(0,O.jsx)(x,{className:`flex-1 overflow-hidden`,children:(0,O.jsxs)(`div`,{className:`p-2 space-y-3 overflow-hidden`,children:[(0,O.jsx)(P,{title:`Staged Changes`,count:r?.staged.length??0,files:r?.staged??[],viewMode:z,actionIcon:(0,O.jsx)(T,{className:`size-3.5`}),actionTitle:`Unstage`,onAction:e=>U([e.path]),onActionAll:r?.staged.length?()=>U(r.staged.map(e=>e.path)):void 0,actionAllLabel:`Unstage All`,onFolderAction:e=>U(e.map(e=>e.path)),onClickFile:Y,onOpenFile:X,disabled:M}),(0,O.jsx)(P,{title:`Changes`,count:Z.length,files:Z,viewMode:z,actionIcon:(0,O.jsx)(y,{className:`size-3.5`}),actionTitle:`Stage`,onAction:e=>H([e.path]),onActionAll:Z.length?()=>H(Z.map(e=>e.path)):void 0,actionAllLabel:`Stage All`,onFolderAction:e=>H(e.map(e=>e.path)),onClickFile:Y,onOpenFile:X,disabled:M,showRevert:!0,onRevert:e=>I({label:e.path,files:[e.path]}),onFolderRevert:(e,t)=>I({label:`${t}/ (${e.length} files)`,files:e.map(e=>e.path)})})]})}),(0,O.jsxs)(`div`,{className:`border-t p-2 space-y-2 shrink-0`,children:[(0,O.jsx)(`textarea`,{className:`w-full h-16 px-3 py-2 text-base md:text-sm text-foreground bg-surface border border-border rounded-lg resize-none focus:outline-none focus:border-ring placeholder:text-muted-foreground`,placeholder:`Commit message...`,value:A,onChange:e=>j(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&K()}}),(0,O.jsx)(i,{size:`sm`,className:`w-full`,disabled:M||!A.trim()||!r?.staged.length,onClick:K,children:M?(0,O.jsx)(v,{className:`size-3 animate-spin`}):`Commit (${r?.staged.length??0})`}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsxs)(i,{variant:`outline`,size:`sm`,className:`flex-1`,disabled:M,onClick:q,children:[(0,O.jsx)(a,{className:`size-3`}),`Push`]}),(0,O.jsxs)(i,{variant:`outline`,size:`sm`,className:`flex-1`,disabled:M,onClick:J,children:[(0,O.jsx)(S,{className:`size-3`}),`Pull`]})]})]}),(0,O.jsx)(f,{open:!!F,onOpenChange:e=>!e&&I(null),children:(0,O.jsxs)(l,{showCloseButton:!1,children:[(0,O.jsxs)(s,{children:[(0,O.jsx)(u,{children:`Discard Changes`}),(0,O.jsxs)(d,{children:[`Are you sure you want to discard all changes to`,` `,(0,O.jsx)(`code`,{className:`px-1 py-0.5 rounded bg-muted text-sm font-mono`,children:F?.label}),`? This action cannot be undone.`]})]}),(0,O.jsxs)(c,{children:[(0,O.jsx)(i,{variant:`outline`,onClick:()=>I(null),children:`Cancel`}),(0,O.jsx)(i,{variant:`destructive`,onClick:G,disabled:M,children:M?(0,O.jsx)(v,{className:`size-3 animate-spin`}):`Discard`})]})]})})]}):(0,O.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`})}function N({showRevert:e,onRevert:t,onAction:n,onOpenFile:r,actionIcon:i,actionTitle:a,disabled:o}){return(0,O.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0 ml-1`,children:[r&&(0,O.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-7 rounded border border-border/60 bg-muted/60 text-muted-foreground hover:bg-primary/15 hover:text-primary hover:border-primary/40 active:scale-95 transition-colors`,onClick:e=>{e.stopPropagation(),r()},disabled:o,title:`Open file`,children:(0,O.jsx)(_,{className:`size-3.5`})}),e&&t&&(0,O.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-7 rounded border border-border/60 bg-muted/60 text-muted-foreground hover:bg-destructive/15 hover:text-destructive hover:border-destructive/40 active:scale-95 transition-colors`,onClick:e=>{e.stopPropagation(),t()},disabled:o,title:`Discard changes`,children:(0,O.jsx)(E,{className:`size-3.5`})}),(0,O.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-7 rounded border border-border/60 bg-muted/60 text-muted-foreground hover:bg-accent hover:text-accent-foreground active:scale-95 transition-colors`,onClick:e=>{e.stopPropagation(),n()},disabled:o,title:a,children:i})]})}function P({title:e,count:t,files:n,viewMode:r,actionIcon:a,actionTitle:o,onAction:s,onActionAll:c,actionAllLabel:l,onFolderAction:u,onClickFile:d,onOpenFile:f,disabled:p,showRevert:m,onRevert:h,onFolderRevert:g}){return(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,O.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase`,children:[e,` (`,t,`)`]}),c&&t>0&&(0,O.jsx)(i,{variant:`ghost`,size:`xs`,onClick:c,disabled:p,title:l,children:l})]}),n.length===0?(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground px-1`,children:`No changes`}):r===`flat`?(0,O.jsx)(`div`,{className:`divide-y divide-border/40 w-full overflow-hidden`,children:n.map(e=>(0,O.jsx)(F,{file:e,actionIcon:a,actionTitle:o,onAction:s,onClickFile:d,onOpenFile:f,disabled:p,showRevert:m,onRevert:h},e.path))}):(0,O.jsx)(I,{files:n,actionIcon:a,actionTitle:o,onAction:s,onFolderAction:u,onClickFile:d,onOpenFile:f,disabled:p,showRevert:m,onRevert:h,onFolderRevert:g})]})}function F({file:e,actionIcon:t,actionTitle:n,onAction:r,onClickFile:i,onOpenFile:a,disabled:o,showRevert:s,onRevert:c,displayName:l}){return(0,O.jsxs)(`div`,{className:`flex items-center gap-1 hover:bg-muted/50 rounded px-1 py-1 w-full min-w-0`,children:[(0,O.jsx)(`span`,{className:`text-xs font-mono w-4 text-center shrink-0 ${k[e.status]??``}`,children:e.status}),(0,O.jsx)(`button`,{type:`button`,className:`flex-1 text-left text-xs font-mono truncate hover:underline min-w-0`,onClick:()=>i(e),title:e.path,children:l??e.path}),(0,O.jsx)(N,{showRevert:s,onRevert:c?()=>c(e):void 0,onOpenFile:a?()=>a(e):void 0,onAction:()=>r(e),actionIcon:t,actionTitle:n,disabled:o})]})}function I({files:e,actionIcon:t,actionTitle:n,onAction:r,onFolderAction:i,onClickFile:a,onOpenFile:o,disabled:s,showRevert:c,onRevert:l,onFolderRevert:u}){let d=(0,D.useMemo)(()=>A(e),[e]);return(0,O.jsx)(`div`,{children:d.map((e,f)=>(0,O.jsx)(L,{node:e,depth:0,isLast:f===d.length-1,actionIcon:t,actionTitle:n,onAction:r,onFolderAction:i,onClickFile:a,onOpenFile:o,disabled:s,showRevert:c,onRevert:l,onFolderRevert:u},e.fullPath))})}function L({node:e,depth:t,isLast:n,actionIcon:r,actionTitle:i,onAction:a,onFolderAction:o,onClickFile:s,onOpenFile:c,disabled:l,showRevert:u,onRevert:d,onFolderRevert:f}){let[p,m]=(0,D.useState)(!0),_=e.children.length>0&&!e.file;if(e.file)return(0,O.jsxs)(`div`,{className:`relative overflow-hidden border-b border-border/30`,style:{paddingLeft:t*16},children:[t>0&&(0,O.jsx)(`div`,{className:`absolute top-0 bottom-0 border-l border-border/30`,style:{left:t*16-8}}),(0,O.jsx)(F,{file:e.file,displayName:e.name,actionIcon:r,actionTitle:i,onAction:a,onClickFile:s,onOpenFile:c,disabled:l,showRevert:u,onRevert:d})]});if(_){let _=j(e);return(0,O.jsxs)(`div`,{className:`relative overflow-hidden`,children:[t>0&&(0,O.jsx)(`div`,{className:`absolute top-0 border-l border-border/30`,style:{left:t*16-8,bottom:n?`50%`:0}}),(0,O.jsxs)(`div`,{className:`flex items-center hover:bg-muted/50 rounded py-1 pr-1 border-b border-border/30`,style:{paddingLeft:t*16+4},children:[(0,O.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 flex-1 min-w-0 text-xs font-mono text-muted-foreground`,onClick:()=>m(!p),children:[p?(0,O.jsx)(h,{className:`size-3.5 shrink-0`}):(0,O.jsx)(g,{className:`size-3.5 shrink-0`}),(0,O.jsx)(`span`,{className:`truncate font-semibold`,children:e.name}),(0,O.jsxs)(`span`,{className:`text-[10px] opacity-60 shrink-0`,children:[`(`,_.length,`)`]})]}),(0,O.jsx)(N,{showRevert:u,onRevert:f?()=>f(_,e.fullPath):void 0,onAction:()=>o?.(_),actionIcon:r,actionTitle:`${i} ${e.name}/`,disabled:l})]}),p&&(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(`div`,{className:`absolute top-0 bottom-0 border-l border-border/30`,style:{left:t*16+8}}),e.children.map((n,p)=>(0,O.jsx)(L,{node:n,depth:t+1,isLast:p===e.children.length-1,actionIcon:r,actionTitle:i,onAction:a,onFolderAction:o,onClickFile:s,onOpenFile:c,disabled:l,showRevert:u,onRevert:d,onFolderRevert:f},n.fullPath))]})]})}return null}export{M as GitStatusPanel};
1
+ import{a as e,n as t,r as n,t as r}from"./jsx-runtime-BFALxl05.js";import{t as i}from"./button-CQ5h5gxS.js";import{t as a}from"./arrow-up-from-line-DjfWTP75.js";import{t as o}from"./refresh-cw-S6I91MHO.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./dialog-CCBmXo6-.js";import{r as p,t as m}from"./api-client-tgjN9Mx8.js";import{D as h,E as g,S as _,_ as v,h as y,l as b,u as x}from"./index-VKvV157O.js";var S=t(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),C=t(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),w=t(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),T=t(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),E=t(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),D=e(n(),1),O=r(),k={M:`text-yellow-500`,A:`text-green-500`,D:`text-red-500`,R:`text-blue-500`,C:`text-purple-500`,"?":`text-gray-400`};function A(e){let t=[];for(let n of e){let e=n.path.split(`/`),r=t;for(let t=0;t<e.length;t++){let i=e[t],a=e.slice(0,t+1).join(`/`),o=t===e.length-1,s=r.find(e=>e.name===i);s||(s={name:i,fullPath:a,file:o?n:void 0,children:[]},r.push(s)),o&&(s.file=n),r=s.children}}return t}function j(e){let t=[];e.file&&t.push(e.file);for(let n of e.children)t.push(...j(n));return t}function M({metadata:e,tabId:t}){let n=e?.projectName,[r,h]=(0,D.useState)(null),[g,_]=(0,D.useState)(!0),[E,k]=(0,D.useState)(null),[A,j]=(0,D.useState)(``),[M,N]=(0,D.useState)(!1),[F,I]=(0,D.useState)(null),{openTab:L,updateTab:R}=b(),z=e?.viewMode===`tree`?`tree`:`flat`,B=n=>{t&&R(t,{metadata:{...e,viewMode:n}})},V=(0,D.useCallback)(async()=>{if(n)try{_(!0),h(await m.get(`${p(n)}/git/status`)),k(null)}catch(e){k(e instanceof Error?e.message:`Failed to fetch status`)}finally{_(!1)}},[n]);(0,D.useEffect)(()=>{V();let e=setInterval(V,5e3);return()=>clearInterval(e)},[V]);let H=async e=>{if(n){N(!0);try{await m.post(`${p(n)}/git/stage`,{files:e}),await V()}catch(e){k(e instanceof Error?e.message:`Stage failed`)}finally{N(!1)}}},U=async e=>{if(n){N(!0);try{await m.post(`${p(n)}/git/unstage`,{files:e}),await V()}catch(e){k(e instanceof Error?e.message:`Unstage failed`)}finally{N(!1)}}},W=async e=>{if(n){N(!0);try{await m.post(`${p(n)}/git/discard`,{files:e}),await V()}catch(e){k(e instanceof Error?e.message:`Discard failed`)}finally{N(!1)}}},G=async()=>{F&&(await W(F.files),I(null))},K=async()=>{if(!(!n||!A.trim()||!r?.staged.length)){N(!0);try{await m.post(`${p(n)}/git/commit`,{message:A.trim()}),j(``),await V()}catch(e){k(e instanceof Error?e.message:`Commit failed`)}finally{N(!1)}}},q=async()=>{if(n){N(!0);try{await m.post(`${p(n)}/git/push`,{}),await V()}catch(e){k(e instanceof Error?e.message:`Push failed`)}finally{N(!1)}}},J=async()=>{if(n){N(!0);try{await m.post(`${p(n)}/git/pull`,{}),await V()}catch(e){k(e instanceof Error?e.message:`Pull failed`)}finally{N(!1)}}},Y=e=>{L({type:`git-diff`,title:e.path.split(`/`).pop()??e.path,closable:!0,metadata:{projectName:n,filePath:e.path},projectId:n??null})},X=e=>{L({type:`editor`,title:e.path.split(`/`).pop()??e.path,closable:!0,metadata:{projectName:n,filePath:e.path},projectId:n??null})},Z=(0,D.useMemo)(()=>[...r?.unstaged??[],...r?.untracked.map(e=>({path:e,status:`?`}))??[]],[r]);return n?g&&!r?(0,O.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,O.jsx)(v,{className:`size-5 animate-spin`}),(0,O.jsx)(`span`,{className:`text-sm`,children:`Loading git status...`})]}):E&&!r?(0,O.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-destructive text-sm`,children:[(0,O.jsx)(`p`,{children:E}),(0,O.jsx)(i,{variant:`outline`,size:`sm`,onClick:V,children:`Retry`})]}):(0,O.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b shrink-0`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium`,children:r?.current?`On: ${r.current}`:`Git Status`}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(i,{variant:z===`flat`?`secondary`:`ghost`,size:`icon-xs`,onClick:()=>B(`flat`),title:`Flat view`,children:(0,O.jsx)(w,{className:`size-3.5`})}),(0,O.jsx)(i,{variant:z===`tree`?`secondary`:`ghost`,size:`icon-xs`,onClick:()=>B(`tree`),title:`Tree view`,children:(0,O.jsx)(C,{className:`size-3.5`})}),(0,O.jsx)(i,{variant:`ghost`,size:`icon-xs`,onClick:V,disabled:M,children:(0,O.jsx)(o,{className:g?`animate-spin`:``})})]})]}),E&&(0,O.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0`,children:E}),(0,O.jsx)(x,{className:`flex-1 overflow-hidden`,children:(0,O.jsxs)(`div`,{className:`p-2 space-y-3 overflow-hidden`,children:[(0,O.jsx)(P,{title:`Staged Changes`,count:r?.staged.length??0,files:r?.staged??[],viewMode:z,actionIcon:(0,O.jsx)(T,{className:`size-3.5`}),actionTitle:`Unstage`,onAction:e=>U([e.path]),onActionAll:r?.staged.length?()=>U(r.staged.map(e=>e.path)):void 0,actionAllLabel:`Unstage All`,onFolderAction:e=>U(e.map(e=>e.path)),onClickFile:Y,onOpenFile:X,disabled:M}),(0,O.jsx)(P,{title:`Changes`,count:Z.length,files:Z,viewMode:z,actionIcon:(0,O.jsx)(y,{className:`size-3.5`}),actionTitle:`Stage`,onAction:e=>H([e.path]),onActionAll:Z.length?()=>H(Z.map(e=>e.path)):void 0,actionAllLabel:`Stage All`,onFolderAction:e=>H(e.map(e=>e.path)),onClickFile:Y,onOpenFile:X,disabled:M,showRevert:!0,onRevert:e=>I({label:e.path,files:[e.path]}),onFolderRevert:(e,t)=>I({label:`${t}/ (${e.length} files)`,files:e.map(e=>e.path)})})]})}),(0,O.jsxs)(`div`,{className:`border-t p-2 space-y-2 shrink-0`,children:[(0,O.jsx)(`textarea`,{className:`w-full h-16 px-3 py-2 text-base md:text-sm text-foreground bg-surface border border-border rounded-lg resize-none focus:outline-none focus:border-ring placeholder:text-muted-foreground`,placeholder:`Commit message...`,value:A,onChange:e=>j(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&K()}}),(0,O.jsx)(i,{size:`sm`,className:`w-full`,disabled:M||!A.trim()||!r?.staged.length,onClick:K,children:M?(0,O.jsx)(v,{className:`size-3 animate-spin`}):`Commit (${r?.staged.length??0})`}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsxs)(i,{variant:`outline`,size:`sm`,className:`flex-1`,disabled:M,onClick:q,children:[(0,O.jsx)(a,{className:`size-3`}),`Push`]}),(0,O.jsxs)(i,{variant:`outline`,size:`sm`,className:`flex-1`,disabled:M,onClick:J,children:[(0,O.jsx)(S,{className:`size-3`}),`Pull`]})]})]}),(0,O.jsx)(f,{open:!!F,onOpenChange:e=>!e&&I(null),children:(0,O.jsxs)(l,{showCloseButton:!1,children:[(0,O.jsxs)(s,{children:[(0,O.jsx)(u,{children:`Discard Changes`}),(0,O.jsxs)(d,{children:[`Are you sure you want to discard all changes to`,` `,(0,O.jsx)(`code`,{className:`px-1 py-0.5 rounded bg-muted text-sm font-mono`,children:F?.label}),`? This action cannot be undone.`]})]}),(0,O.jsxs)(c,{children:[(0,O.jsx)(i,{variant:`outline`,onClick:()=>I(null),children:`Cancel`}),(0,O.jsx)(i,{variant:`destructive`,onClick:G,disabled:M,children:M?(0,O.jsx)(v,{className:`size-3 animate-spin`}):`Discard`})]})]})})]}):(0,O.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`})}function N({showRevert:e,onRevert:t,onAction:n,onOpenFile:r,actionIcon:i,actionTitle:a,disabled:o}){return(0,O.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0 ml-1`,children:[r&&(0,O.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-7 rounded border border-border/60 bg-muted/60 text-muted-foreground hover:bg-primary/15 hover:text-primary hover:border-primary/40 active:scale-95 transition-colors`,onClick:e=>{e.stopPropagation(),r()},disabled:o,title:`Open file`,children:(0,O.jsx)(_,{className:`size-3.5`})}),e&&t&&(0,O.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-7 rounded border border-border/60 bg-muted/60 text-muted-foreground hover:bg-destructive/15 hover:text-destructive hover:border-destructive/40 active:scale-95 transition-colors`,onClick:e=>{e.stopPropagation(),t()},disabled:o,title:`Discard changes`,children:(0,O.jsx)(E,{className:`size-3.5`})}),(0,O.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-7 rounded border border-border/60 bg-muted/60 text-muted-foreground hover:bg-accent hover:text-accent-foreground active:scale-95 transition-colors`,onClick:e=>{e.stopPropagation(),n()},disabled:o,title:a,children:i})]})}function P({title:e,count:t,files:n,viewMode:r,actionIcon:a,actionTitle:o,onAction:s,onActionAll:c,actionAllLabel:l,onFolderAction:u,onClickFile:d,onOpenFile:f,disabled:p,showRevert:m,onRevert:h,onFolderRevert:g}){return(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,O.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase`,children:[e,` (`,t,`)`]}),c&&t>0&&(0,O.jsx)(i,{variant:`ghost`,size:`xs`,onClick:c,disabled:p,title:l,children:l})]}),n.length===0?(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground px-1`,children:`No changes`}):r===`flat`?(0,O.jsx)(`div`,{className:`divide-y divide-border/40 w-full overflow-hidden`,children:n.map(e=>(0,O.jsx)(F,{file:e,actionIcon:a,actionTitle:o,onAction:s,onClickFile:d,onOpenFile:f,disabled:p,showRevert:m,onRevert:h},e.path))}):(0,O.jsx)(I,{files:n,actionIcon:a,actionTitle:o,onAction:s,onFolderAction:u,onClickFile:d,onOpenFile:f,disabled:p,showRevert:m,onRevert:h,onFolderRevert:g})]})}function F({file:e,actionIcon:t,actionTitle:n,onAction:r,onClickFile:i,onOpenFile:a,disabled:o,showRevert:s,onRevert:c,displayName:l}){return(0,O.jsxs)(`div`,{className:`flex items-center gap-1 hover:bg-muted/50 rounded px-1 py-1 w-full min-w-0`,children:[(0,O.jsx)(`span`,{className:`text-xs font-mono w-4 text-center shrink-0 ${k[e.status]??``}`,children:e.status}),(0,O.jsx)(`button`,{type:`button`,className:`flex-1 text-left text-xs font-mono truncate hover:underline min-w-0`,onClick:()=>i(e),title:e.path,children:l??e.path}),(0,O.jsx)(N,{showRevert:s,onRevert:c?()=>c(e):void 0,onOpenFile:a?()=>a(e):void 0,onAction:()=>r(e),actionIcon:t,actionTitle:n,disabled:o})]})}function I({files:e,actionIcon:t,actionTitle:n,onAction:r,onFolderAction:i,onClickFile:a,onOpenFile:o,disabled:s,showRevert:c,onRevert:l,onFolderRevert:u}){let d=(0,D.useMemo)(()=>A(e),[e]);return(0,O.jsx)(`div`,{children:d.map((e,f)=>(0,O.jsx)(L,{node:e,depth:0,isLast:f===d.length-1,actionIcon:t,actionTitle:n,onAction:r,onFolderAction:i,onClickFile:a,onOpenFile:o,disabled:s,showRevert:c,onRevert:l,onFolderRevert:u},e.fullPath))})}function L({node:e,depth:t,isLast:n,actionIcon:r,actionTitle:i,onAction:a,onFolderAction:o,onClickFile:s,onOpenFile:c,disabled:l,showRevert:u,onRevert:d,onFolderRevert:f}){let[p,m]=(0,D.useState)(!0),_=e.children.length>0&&!e.file;if(e.file)return(0,O.jsxs)(`div`,{className:`relative overflow-hidden border-b border-border/30`,style:{paddingLeft:t*16},children:[t>0&&(0,O.jsx)(`div`,{className:`absolute top-0 bottom-0 border-l border-border/30`,style:{left:t*16-8}}),(0,O.jsx)(F,{file:e.file,displayName:e.name,actionIcon:r,actionTitle:i,onAction:a,onClickFile:s,onOpenFile:c,disabled:l,showRevert:u,onRevert:d})]});if(_){let _=j(e);return(0,O.jsxs)(`div`,{className:`relative overflow-hidden`,children:[t>0&&(0,O.jsx)(`div`,{className:`absolute top-0 border-l border-border/30`,style:{left:t*16-8,bottom:n?`50%`:0}}),(0,O.jsxs)(`div`,{className:`flex items-center hover:bg-muted/50 rounded py-1 pr-1 border-b border-border/30`,style:{paddingLeft:t*16+4},children:[(0,O.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 flex-1 min-w-0 text-xs font-mono text-muted-foreground`,onClick:()=>m(!p),children:[p?(0,O.jsx)(h,{className:`size-3.5 shrink-0`}):(0,O.jsx)(g,{className:`size-3.5 shrink-0`}),(0,O.jsx)(`span`,{className:`truncate font-semibold`,children:e.name}),(0,O.jsxs)(`span`,{className:`text-[10px] opacity-60 shrink-0`,children:[`(`,_.length,`)`]})]}),(0,O.jsx)(N,{showRevert:u,onRevert:f?()=>f(_,e.fullPath):void 0,onAction:()=>o?.(_),actionIcon:r,actionTitle:`${i} ${e.name}/`,disabled:l})]}),p&&(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(`div`,{className:`absolute top-0 bottom-0 border-l border-border/30`,style:{left:t*16+8}}),e.children.map((n,p)=>(0,O.jsx)(L,{node:n,depth:t+1,isLast:p===e.children.length-1,actionIcon:r,actionTitle:i,onAction:a,onFolderAction:o,onClickFile:s,onOpenFile:c,disabled:l,showRevert:u,onRevert:d,onFolderRevert:f},n.fullPath))]})]})}return null}export{M as GitStatusPanel};