@hienlh/ppm 0.2.17 → 0.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ppm +0 -0
- package/dist/web/assets/{button-CQ5h5gxS.js → button-CvHWF07y.js} +1 -1
- package/dist/web/assets/{chat-tab-DGDxIbGD.js → chat-tab-Cbc-uzKV.js} +4 -4
- package/dist/web/assets/{code-editor-CYWA87cs.js → code-editor-B9e5P-DN.js} +1 -1
- package/dist/web/assets/{dialog-CCBmXo6-.js → dialog-Cn5zGuid.js} +1 -1
- package/dist/web/assets/diff-viewer-B0iMQ1Qf.js +4 -0
- package/dist/web/assets/git-graph-D3ls9-HA.js +1 -0
- package/dist/web/assets/{git-status-panel-D50lP9Ru.js → git-status-panel-UB0AyOdX.js} +1 -1
- package/dist/web/assets/index-BdUoflYx.css +2 -0
- package/dist/web/assets/index-DLIV9ojh.js +17 -0
- package/dist/web/assets/{project-list-Ha_JrM9s.js → project-list-D6oBUMd8.js} +1 -1
- package/dist/web/assets/settings-tab-DmTDAK9n.js +1 -0
- package/dist/web/assets/{terminal-tab-Cg4Pm_3X.js → terminal-tab-DlRo-KzS.js} +1 -1
- package/dist/web/index.html +7 -8
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/src/providers/claude-agent-sdk.ts +1 -2
- package/src/server/ws/chat.ts +211 -94
- package/src/web/app.tsx +4 -11
- package/src/web/components/layout/draggable-tab.tsx +58 -0
- package/src/web/components/layout/editor-panel.tsx +64 -0
- package/src/web/components/layout/mobile-nav.tsx +99 -55
- package/src/web/components/layout/panel-layout.tsx +71 -0
- package/src/web/components/layout/sidebar.tsx +29 -6
- package/src/web/components/layout/split-drop-overlay.tsx +111 -0
- package/src/web/components/layout/tab-bar.tsx +60 -68
- package/src/web/hooks/use-chat.ts +31 -2
- package/src/web/hooks/use-global-keybindings.ts +8 -0
- package/src/web/hooks/use-tab-drag.ts +109 -0
- package/src/web/stores/panel-store.ts +383 -0
- package/src/web/stores/panel-utils.ts +116 -0
- package/src/web/stores/settings-store.ts +25 -17
- package/src/web/stores/tab-store.ts +32 -152
- package/dist/web/assets/diff-viewer-CX7iJZTM.js +0 -4
- package/dist/web/assets/dist-CYANqO1g.js +0 -1
- package/dist/web/assets/git-graph-BPt8qfBw.js +0 -1
- package/dist/web/assets/index-DBaFu6Af.js +0 -12
- package/dist/web/assets/index-Jhl6F2vS.css +0 -2
- package/dist/web/assets/settings-tab-C5SlVPjG.js +0 -1
- /package/dist/web/assets/{api-client-tgjN9Mx8.js → api-client-B_eCZViO.js} +0 -0
- /package/dist/web/assets/{dist-0XHv8Vwc.js → dist-B6sG2GPc.js} +0 -0
- /package/dist/web/assets/{dist-BeHIxUn0.js → dist-CBiGQxfr.js} +0 -0
- /package/dist/web/assets/{utils-D6me7KDg.js → utils-61GRB9Cb.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,n as t,r as n,t as r}from"./jsx-runtime-BFALxl05.js";import{n as i,t as a}from"./marked.esm-Cv8mjgnt.js";import{t as o}from"./external-link-C6Y-D528.js";import{n as s,r as c,t as l}from"./api-client-tgjN9Mx8.js";import{b as u,f as d}from"./index-DBaFu6Af.js";import{$ as f,A as p,B as m,C as h,D as g,E as _,F as v,G as y,H as b,J as x,K as S,L as C,M as w,N as T,O as E,P as D,Q as O,R as k,S as A,T as j,U as ee,V as M,W as te,X as ne,Z as re,_ as ie,a as ae,b as oe,c as se,ct as ce,d as le,dt as ue,f as de,ft as fe,g as pe,gt as me,h as he,ht as N,i as ge,it as _e,j as ve,l as ye,lt as be,m as xe,mt as Se,n as Ce,nt as we,o as Te,ot as Ee,p as De,pt as Oe,q as ke,r as Ae,rt as je,s as Me,st as P,t as Ne,tt as F,u as Pe,ut as Fe,v as Ie,w as Le,x as Re,y as ze,z as Be}from"./dist-BeHIxUn0.js";var Ve=t(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),He=t(`file-exclamation-point`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),I=e(n());function Ue(){return Ue=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ue.apply(null,arguments)}function We(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Ge=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Xe(e.state,n.from);return r.line?qe(e):r.block?Ye(e):!1};function Ke(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var qe=Ke(tt,0),Je=Ke(et,0),Ye=Ke((e,t)=>et(e,t,$e(t)),0);function Xe(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var Ze=50;function Qe(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-Ze,r),o=e.sliceDoc(i,i+Ze),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*Ze?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+Ze),d=e.sliceDoc(i-Ze,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:/\s/.test(u.charAt(f+t.length))?1:0},close:{pos:i-p-n.length,margin:/\s/.test(d.charAt(m-1))?1:0}}:null}function $e(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function et(e,t,n=t.selection.ranges){let r=n.map(e=>Xe(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Qe(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function tt(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=Xe(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var nt=ne.define(),rt=ne.define(),it=je.define(),at=je.define({combine(e){return Oe(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),ot=ce.define({create(){return Ct.empty},update(e,t){let n=t.state.facet(at),r=t.annotation(nt);if(r){let i=L.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?pt(o,o.length,n.minDepth,i):vt(o,t.startState.selection),new Ct(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(rt);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(Fe.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=L.fromTransaction(t),o=t.annotation(Fe.time),s=t.annotation(Fe.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new Ct(e.done.map(L.fromJSON),e.undone.map(L.fromJSON))}});function st(e={}){return[ot,at.of(e),E.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?lt:e.inputType==`historyRedo`?ut:null;return n?(e.preventDefault(),n(t)):!1}})]}function ct(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(ot,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var lt=ct(0,!1),ut=ct(1,!1),dt=ct(0,!0),ft=ct(1,!0),L=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&O.fromJSON(t.changes),[],t.mapped&&re.fromJSON(t.mapped),t.startSelection&&F.fromJSON(t.startSelection),t.selectionsAfter.map(F.fromJSON))}static fromTransaction(t,n){let r=R;for(let e of t.startState.facet(it)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,R)}static selection(t){return new e(void 0,R,void 0,void 0,t)}};function pt(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function mt(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function ht(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function gt(e,t){return e.length?t.length?e.concat(t):e:t}var R=[],_t=200;function vt(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-_t));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),pt(e,e.length-1,1e9,n.setSelAfter(r)))}else return[L.selection([t])]}function yt(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function bt(e,t){if(!e.length)return e;let n=e.length,r=R;for(;n;){let i=xt(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[L.selection(r)]:R}function xt(e,t,n){let r=gt(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):R,n);if(!e.changes)return L.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new L(i,P.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var St=/^(input\.type|delete)($|\.)/,Ct=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||St.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,mt(s.changes,t.changes))||r==`input.type.compose`)?pt(o,o.length-1,i.minDepth,new L(t.changes.compose(s.changes),gt(P.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,R)):pt(o,o.length,i.minDepth,t),new e(o,R,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:R;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&ht(a[a.length-1],t)?this:new e(vt(this.done,t),this.undone,n,r)}addMapping(t){return new e(bt(this.done,t),bt(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:nt.of({side:e,rest:yt(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?R:r.slice(0,r.length-1);return i.mapped&&(n=bt(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:nt.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};Ct.empty=new Ct(R,R);var wt=[{key:`Mod-z`,run:lt,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:ut,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:ut,preventDefault:!0},{key:`Mod-u`,run:dt,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:ft,preventDefault:!0}];function z(e,t){return F.create(e.ranges.map(t),e.mainIndex)}function B(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function V({state:e,dispatch:t},n){let r=z(e.selection,n);return r.eq(e.selection,!0)?!1:(t(B(e,r)),!0)}function Tt(e,t){return F.cursor(t?e.to:e.from)}function Et(e,t){return V(e,n=>n.empty?e.moveByChar(n,t):Tt(n,t))}function H(e){return e.textDirectionAt(e.state.selection.main.head)==g.LTR}var Dt=e=>Et(e,!H(e)),Ot=e=>Et(e,H(e));function kt(e,t){return V(e,n=>n.empty?e.moveByGroup(n,t):Tt(n,t))}var At=e=>kt(e,!H(e)),jt=e=>kt(e,H(e));typeof Intl<`u`&&Intl.Segmenter&&new Intl.Segmenter(void 0,{granularity:`word`});function Mt(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Nt(e,t,n){let r=Le(e).resolveInner(t.head),i=n?j.closedBy:j.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Mt(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?A(e,r.from,1):A(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,F.cursor(s,n?-1:1)}var Pt=e=>V(e,t=>Nt(e.state,t,!H(e))),Ft=e=>V(e,t=>Nt(e.state,t,H(e)));function It(e,t){return V(e,n=>{if(!n.empty)return Tt(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Lt=e=>It(e,!1),Rt=e=>It(e,!0);function zt(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(E.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function Bt(e,t){let n=zt(e),{state:r}=e,i=z(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):Tt(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=E.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(B(r,i),{effects:a}),!0}var Vt=e=>Bt(e,!1),Ht=e=>Bt(e,!0);function U(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=F.cursor(r.from+n))}return i}var Ut=e=>V(e,t=>U(e,t,!0)),Wt=e=>V(e,t=>U(e,t,!1)),Gt=e=>V(e,t=>U(e,t,!H(e))),Kt=e=>V(e,t=>U(e,t,H(e))),qt=e=>V(e,t=>F.cursor(e.lineBlockAt(t.head).from,1)),Jt=e=>V(e,t=>F.cursor(e.lineBlockAt(t.head).to,-1));function Yt(e,t,n){let r=!1,i=z(e.selection,t=>{let i=A(e,t.head,-1)||A(e,t.head,1)||t.head>0&&A(e,t.head-1,1)||t.head<e.doc.length&&A(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?F.range(t.anchor,a):F.cursor(a)});return r?(t(B(e,i)),!0):!1}var Xt=({state:e,dispatch:t})=>Yt(e,t,!1);function W(e,t){let n=z(e.state.selection,e=>{let n=t(e);return F.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(B(e.state,n)),!0)}function Zt(e,t){return W(e,n=>e.moveByChar(n,t))}var Qt=e=>Zt(e,!H(e)),$t=e=>Zt(e,H(e));function en(e,t){return W(e,n=>e.moveByGroup(n,t))}var tn=e=>en(e,!H(e)),nn=e=>en(e,H(e)),rn=e=>W(e,t=>Nt(e.state,t,!H(e))),an=e=>W(e,t=>Nt(e.state,t,H(e)));function on(e,t){return W(e,n=>e.moveVertically(n,t))}var sn=e=>on(e,!1),cn=e=>on(e,!0);function ln(e,t){return W(e,n=>e.moveVertically(n,t,zt(e).height))}var un=e=>ln(e,!1),dn=e=>ln(e,!0),fn=e=>W(e,t=>U(e,t,!0)),pn=e=>W(e,t=>U(e,t,!1)),mn=e=>W(e,t=>U(e,t,!H(e))),hn=e=>W(e,t=>U(e,t,H(e))),gn=e=>W(e,t=>F.cursor(e.lineBlockAt(t.head).from)),_n=e=>W(e,t=>F.cursor(e.lineBlockAt(t.head).to)),vn=({state:e,dispatch:t})=>(t(B(e,{anchor:0})),!0),yn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.doc.length})),!0),bn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:0})),!0),xn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Sn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Cn=({state:e,dispatch:t})=>{let n=Hn(e).map(({from:t,to:n})=>F.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:F.create(n),userEvent:`select`})),!0},wn=({state:e,dispatch:t})=>{let n=z(e.selection,t=>{let n=Le(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return F.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(B(e,n)),!0)};function Tn(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(B(n,F.create(i,i.length-1))),!0)}var En=e=>Tn(e,!1),Dn=e=>Tn(e,!0),On=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=F.create([n.main]):n.main.empty||(r=F.create([F.cursor(n.main.head)])),r?(t(B(e,r)),!0):!1};function kn(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=An(e,o,!1)):o>i&&(n=`delete.forward`,o=An(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=An(e,i,!1),a=An(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:F.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?E.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function An(e,t,n){if(e instanceof E)for(let r of e.state.facet(E.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var jn=(e,t,n)=>kn(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=Se(s,a.tabSize)%ie(a)||ie(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=N(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=N(o.text,c-o.from,!1,!1)+o.from);return c}),Mn=e=>jn(e,!1,!0),Nn=e=>jn(e,!0,!1),Pn=(e,t)=>kn(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=N(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),Fn=e=>Pn(e,!1),In=e=>Pn(e,!0),Ln=e=>kn(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Rn=e=>kn(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),zn=e=>kn(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Bn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:be.of([``,``])},range:F.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Vn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:N(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:N(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:F.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Hn(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Un(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Hn(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(F.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(F.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:F.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var Wn=({state:e,dispatch:t})=>Un(e,t,!1),Gn=({state:e,dispatch:t})=>Un(e,t,!0);function Kn(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Hn(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var qn=({state:e,dispatch:t})=>Kn(e,t,!1),Jn=({state:e,dispatch:t})=>Kn(e,t,!0),Yn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Hn(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=z(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function Xn(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=Le(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(j.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var Zn=$n(!1),Qn=$n(!0);function $n(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&Xn(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new de(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=Ie(s,r);for(c??=Se(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,oe(t,c)];return o&&l.push(oe(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:be.of(l)},range:F.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function er(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:F.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var tr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new de(e,{overrideIndentation:e=>n[e]??-1}),i=er(e,(t,i,a)=>{let o=Ie(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=oe(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},nr=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(er(e,(t,n)=>{n.push({from:t.from,insert:e.facet(Re)})}),{userEvent:`input.indent`})),!0),rr=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(er(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Se(r,e.tabSize),a=0,o=oe(e,Math.max(0,i-ie(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),ir=e=>(e.setTabFocusMode(),!0),ar=[{key:`Ctrl-b`,run:Dt,shift:Qt,preventDefault:!0},{key:`Ctrl-f`,run:Ot,shift:$t},{key:`Ctrl-p`,run:Lt,shift:sn},{key:`Ctrl-n`,run:Rt,shift:cn},{key:`Ctrl-a`,run:qt,shift:gn},{key:`Ctrl-e`,run:Jt,shift:_n},{key:`Ctrl-d`,run:Nn},{key:`Ctrl-h`,run:Mn},{key:`Ctrl-k`,run:Ln},{key:`Ctrl-Alt-h`,run:Fn},{key:`Ctrl-o`,run:Bn},{key:`Ctrl-t`,run:Vn},{key:`Ctrl-v`,run:Ht}],or=[{key:`ArrowLeft`,run:Dt,shift:Qt,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:At,shift:tn,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Gt,shift:mn,preventDefault:!0},{key:`ArrowRight`,run:Ot,shift:$t,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:jt,shift:nn,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Kt,shift:hn,preventDefault:!0},{key:`ArrowUp`,run:Lt,shift:sn,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:vn,shift:bn},{mac:`Ctrl-ArrowUp`,run:Vt,shift:un},{key:`ArrowDown`,run:Rt,shift:cn,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:yn,shift:xn},{mac:`Ctrl-ArrowDown`,run:Ht,shift:dn},{key:`PageUp`,run:Vt,shift:un},{key:`PageDown`,run:Ht,shift:dn},{key:`Home`,run:Wt,shift:pn,preventDefault:!0},{key:`Mod-Home`,run:vn,shift:bn},{key:`End`,run:Ut,shift:fn,preventDefault:!0},{key:`Mod-End`,run:yn,shift:xn},{key:`Enter`,run:Zn,shift:Zn},{key:`Mod-a`,run:Sn},{key:`Backspace`,run:Mn,shift:Mn,preventDefault:!0},{key:`Delete`,run:Nn,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Fn,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:In,preventDefault:!0},{mac:`Mod-Backspace`,run:Rn,preventDefault:!0},{mac:`Mod-Delete`,run:zn,preventDefault:!0}].concat(ar.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),sr=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Pt,shift:rn},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Ft,shift:an},{key:`Alt-ArrowUp`,run:Wn},{key:`Shift-Alt-ArrowUp`,run:qn},{key:`Alt-ArrowDown`,run:Gn},{key:`Shift-Alt-ArrowDown`,run:Jn},{key:`Mod-Alt-ArrowUp`,run:En},{key:`Mod-Alt-ArrowDown`,run:Dn},{key:`Escape`,run:On},{key:`Mod-Enter`,run:Qn},{key:`Alt-l`,mac:`Ctrl-l`,run:Cn},{key:`Mod-i`,run:wn,preventDefault:!0},{key:`Mod-[`,run:rr},{key:`Mod-]`,run:nr},{key:`Mod-Alt-\\`,run:tr},{key:`Shift-Mod-k`,run:Yn},{key:`Shift-Mod-\\`,run:Xt},{key:`Mod-/`,run:Ge},{key:`Alt-A`,run:Je},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:ir}].concat(or),cr={key:`Tab`,run:nr,shift:rr},lr=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,G=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(lr(e)):lr,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return ue(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=me(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=fe(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(G.prototype[Symbol.iterator]=function(){return this});var ur={from:-1,to:-1,match:/.*/.exec(``)},dr=`gm`+(/x/.unicode==null?``:`u`),fr=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=ur,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new hr(e,t,n,r,i);this.re=new RegExp(t,dr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=_r(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=_r(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},pr=new WeakMap,mr=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=pr.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return pr.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),pr.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},hr=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=ur,this.matchPos=_r(e,r),this.re=new RegExp(t,dr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=mr.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=_r(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=mr.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(fr.prototype[Symbol.iterator]=hr.prototype[Symbol.iterator]=function(){return this});function gr(e){try{return new RegExp(e,dr),!0}catch{return!1}}function _r(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var vr=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=S(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=F.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,E.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},yr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},br=je.define({combine(e){return Oe(e,yr,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function xr(e){let t=[Dr,Er];return e&&t.push(br.of(e)),t}var Sr=_.mark({class:`cm-selectionMatch`}),Cr=_.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function wr(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=f.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=f.Word)}function Tr(e,t,n,r){return e(t.sliceDoc(n,n+1))==f.Word&&e(t.sliceDoc(r-1,r))==f.Word}var Er=p.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(br),{state:n}=e,r=n.selection;if(r.ranges.length>1)return _.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return _.none;let e=n.wordAt(i.head);if(!e)return _.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return _.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(wr(o,n,i.from,i.to)&&Tr(o,n,i.from,i.to)))return _.none}else if(a=n.sliceDoc(i.from,i.to),!a)return _.none}let s=[];for(let r of e.visibleRanges){let e=new G(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||wr(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(Cr.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Sr.range(r,a)),s.length>t.maxMatches))return _.none}}return _.set(s)}},{decorations:e=>e.decorations}),Dr=E.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Or=({state:e,dispatch:t})=>{let{selection:n}=e,r=F.create(n.ranges.map(t=>e.wordAt(t.head)||F.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function kr(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new G(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new G(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Ar=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Or({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=kr(e,r);return i?(t(e.update({selection:e.selection.addRange(F.range(i.from,i.to),!1),effects:E.scrollIntoView(i.to)})),!0):!1},K=je.define({combine(e){return Oe(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new si(e),scrollToMatch:e=>E.scrollIntoView(e)})}}),jr=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||gr(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
|
|
1
|
+
import{a as e,n as t,r as n,t as r}from"./jsx-runtime-BFALxl05.js";import{n as i,t as a}from"./marked.esm-Cv8mjgnt.js";import{t as o}from"./external-link-C6Y-D528.js";import{n as s,r as c,t as l}from"./api-client-B_eCZViO.js";import{D as u,f as d}from"./index-DLIV9ojh.js";import{$ as f,A as p,B as m,C as h,D as g,E as _,F as v,G as y,H as b,J as x,K as S,L as C,M as w,N as T,O as E,P as D,Q as O,R as k,S as A,T as j,U as ee,V as M,W as te,X as ne,Z as re,_ as ie,a as ae,b as oe,c as se,ct as ce,d as le,dt as ue,f as de,ft as fe,g as pe,gt as me,h as he,ht as N,i as ge,it as _e,j as ve,l as ye,lt as be,m as xe,mt as Se,n as Ce,nt as we,o as Te,ot as Ee,p as De,pt as Oe,q as ke,r as Ae,rt as je,s as Me,st as P,t as Ne,tt as F,u as Pe,ut as Fe,v as Ie,w as Le,x as Re,y as ze,z as Be}from"./dist-CBiGQxfr.js";var Ve=t(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),He=t(`file-exclamation-point`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),I=e(n());function Ue(){return Ue=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ue.apply(null,arguments)}function We(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Ge=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Xe(e.state,n.from);return r.line?qe(e):r.block?Ye(e):!1};function Ke(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var qe=Ke(tt,0),Je=Ke(et,0),Ye=Ke((e,t)=>et(e,t,$e(t)),0);function Xe(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var Ze=50;function Qe(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-Ze,r),o=e.sliceDoc(i,i+Ze),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*Ze?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+Ze),d=e.sliceDoc(i-Ze,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:/\s/.test(u.charAt(f+t.length))?1:0},close:{pos:i-p-n.length,margin:/\s/.test(d.charAt(m-1))?1:0}}:null}function $e(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function et(e,t,n=t.selection.ranges){let r=n.map(e=>Xe(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Qe(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function tt(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=Xe(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var nt=ne.define(),rt=ne.define(),it=je.define(),at=je.define({combine(e){return Oe(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),ot=ce.define({create(){return Ct.empty},update(e,t){let n=t.state.facet(at),r=t.annotation(nt);if(r){let i=L.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?pt(o,o.length,n.minDepth,i):vt(o,t.startState.selection),new Ct(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(rt);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(Fe.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=L.fromTransaction(t),o=t.annotation(Fe.time),s=t.annotation(Fe.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new Ct(e.done.map(L.fromJSON),e.undone.map(L.fromJSON))}});function st(e={}){return[ot,at.of(e),E.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?lt:e.inputType==`historyRedo`?ut:null;return n?(e.preventDefault(),n(t)):!1}})]}function ct(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(ot,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var lt=ct(0,!1),ut=ct(1,!1),dt=ct(0,!0),ft=ct(1,!0),L=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&O.fromJSON(t.changes),[],t.mapped&&re.fromJSON(t.mapped),t.startSelection&&F.fromJSON(t.startSelection),t.selectionsAfter.map(F.fromJSON))}static fromTransaction(t,n){let r=R;for(let e of t.startState.facet(it)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,R)}static selection(t){return new e(void 0,R,void 0,void 0,t)}};function pt(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function mt(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function ht(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function gt(e,t){return e.length?t.length?e.concat(t):e:t}var R=[],_t=200;function vt(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-_t));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),pt(e,e.length-1,1e9,n.setSelAfter(r)))}else return[L.selection([t])]}function yt(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function bt(e,t){if(!e.length)return e;let n=e.length,r=R;for(;n;){let i=xt(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[L.selection(r)]:R}function xt(e,t,n){let r=gt(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):R,n);if(!e.changes)return L.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new L(i,P.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var St=/^(input\.type|delete)($|\.)/,Ct=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||St.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,mt(s.changes,t.changes))||r==`input.type.compose`)?pt(o,o.length-1,i.minDepth,new L(t.changes.compose(s.changes),gt(P.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,R)):pt(o,o.length,i.minDepth,t),new e(o,R,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:R;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&ht(a[a.length-1],t)?this:new e(vt(this.done,t),this.undone,n,r)}addMapping(t){return new e(bt(this.done,t),bt(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:nt.of({side:e,rest:yt(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?R:r.slice(0,r.length-1);return i.mapped&&(n=bt(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:nt.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};Ct.empty=new Ct(R,R);var wt=[{key:`Mod-z`,run:lt,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:ut,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:ut,preventDefault:!0},{key:`Mod-u`,run:dt,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:ft,preventDefault:!0}];function z(e,t){return F.create(e.ranges.map(t),e.mainIndex)}function B(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function V({state:e,dispatch:t},n){let r=z(e.selection,n);return r.eq(e.selection,!0)?!1:(t(B(e,r)),!0)}function Tt(e,t){return F.cursor(t?e.to:e.from)}function Et(e,t){return V(e,n=>n.empty?e.moveByChar(n,t):Tt(n,t))}function H(e){return e.textDirectionAt(e.state.selection.main.head)==g.LTR}var Dt=e=>Et(e,!H(e)),Ot=e=>Et(e,H(e));function kt(e,t){return V(e,n=>n.empty?e.moveByGroup(n,t):Tt(n,t))}var At=e=>kt(e,!H(e)),jt=e=>kt(e,H(e));typeof Intl<`u`&&Intl.Segmenter&&new Intl.Segmenter(void 0,{granularity:`word`});function Mt(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Nt(e,t,n){let r=Le(e).resolveInner(t.head),i=n?j.closedBy:j.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Mt(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?A(e,r.from,1):A(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,F.cursor(s,n?-1:1)}var Pt=e=>V(e,t=>Nt(e.state,t,!H(e))),Ft=e=>V(e,t=>Nt(e.state,t,H(e)));function It(e,t){return V(e,n=>{if(!n.empty)return Tt(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Lt=e=>It(e,!1),Rt=e=>It(e,!0);function zt(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(E.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function Bt(e,t){let n=zt(e),{state:r}=e,i=z(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):Tt(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=E.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(B(r,i),{effects:a}),!0}var Vt=e=>Bt(e,!1),Ht=e=>Bt(e,!0);function U(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=F.cursor(r.from+n))}return i}var Ut=e=>V(e,t=>U(e,t,!0)),Wt=e=>V(e,t=>U(e,t,!1)),Gt=e=>V(e,t=>U(e,t,!H(e))),Kt=e=>V(e,t=>U(e,t,H(e))),qt=e=>V(e,t=>F.cursor(e.lineBlockAt(t.head).from,1)),Jt=e=>V(e,t=>F.cursor(e.lineBlockAt(t.head).to,-1));function Yt(e,t,n){let r=!1,i=z(e.selection,t=>{let i=A(e,t.head,-1)||A(e,t.head,1)||t.head>0&&A(e,t.head-1,1)||t.head<e.doc.length&&A(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?F.range(t.anchor,a):F.cursor(a)});return r?(t(B(e,i)),!0):!1}var Xt=({state:e,dispatch:t})=>Yt(e,t,!1);function W(e,t){let n=z(e.state.selection,e=>{let n=t(e);return F.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(B(e.state,n)),!0)}function Zt(e,t){return W(e,n=>e.moveByChar(n,t))}var Qt=e=>Zt(e,!H(e)),$t=e=>Zt(e,H(e));function en(e,t){return W(e,n=>e.moveByGroup(n,t))}var tn=e=>en(e,!H(e)),nn=e=>en(e,H(e)),rn=e=>W(e,t=>Nt(e.state,t,!H(e))),an=e=>W(e,t=>Nt(e.state,t,H(e)));function on(e,t){return W(e,n=>e.moveVertically(n,t))}var sn=e=>on(e,!1),cn=e=>on(e,!0);function ln(e,t){return W(e,n=>e.moveVertically(n,t,zt(e).height))}var un=e=>ln(e,!1),dn=e=>ln(e,!0),fn=e=>W(e,t=>U(e,t,!0)),pn=e=>W(e,t=>U(e,t,!1)),mn=e=>W(e,t=>U(e,t,!H(e))),hn=e=>W(e,t=>U(e,t,H(e))),gn=e=>W(e,t=>F.cursor(e.lineBlockAt(t.head).from)),_n=e=>W(e,t=>F.cursor(e.lineBlockAt(t.head).to)),vn=({state:e,dispatch:t})=>(t(B(e,{anchor:0})),!0),yn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.doc.length})),!0),bn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:0})),!0),xn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Sn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Cn=({state:e,dispatch:t})=>{let n=Hn(e).map(({from:t,to:n})=>F.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:F.create(n),userEvent:`select`})),!0},wn=({state:e,dispatch:t})=>{let n=z(e.selection,t=>{let n=Le(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return F.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(B(e,n)),!0)};function Tn(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(B(n,F.create(i,i.length-1))),!0)}var En=e=>Tn(e,!1),Dn=e=>Tn(e,!0),On=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=F.create([n.main]):n.main.empty||(r=F.create([F.cursor(n.main.head)])),r?(t(B(e,r)),!0):!1};function kn(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=An(e,o,!1)):o>i&&(n=`delete.forward`,o=An(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=An(e,i,!1),a=An(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:F.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?E.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function An(e,t,n){if(e instanceof E)for(let r of e.state.facet(E.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var jn=(e,t,n)=>kn(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=Se(s,a.tabSize)%ie(a)||ie(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=N(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=N(o.text,c-o.from,!1,!1)+o.from);return c}),Mn=e=>jn(e,!1,!0),Nn=e=>jn(e,!0,!1),Pn=(e,t)=>kn(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=N(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),Fn=e=>Pn(e,!1),In=e=>Pn(e,!0),Ln=e=>kn(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Rn=e=>kn(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),zn=e=>kn(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Bn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:be.of([``,``])},range:F.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Vn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:N(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:N(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:F.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Hn(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Un(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Hn(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(F.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(F.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:F.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var Wn=({state:e,dispatch:t})=>Un(e,t,!1),Gn=({state:e,dispatch:t})=>Un(e,t,!0);function Kn(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Hn(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var qn=({state:e,dispatch:t})=>Kn(e,t,!1),Jn=({state:e,dispatch:t})=>Kn(e,t,!0),Yn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Hn(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=z(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function Xn(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=Le(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(j.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var Zn=$n(!1),Qn=$n(!0);function $n(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&Xn(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new de(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=Ie(s,r);for(c??=Se(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,oe(t,c)];return o&&l.push(oe(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:be.of(l)},range:F.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function er(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:F.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var tr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new de(e,{overrideIndentation:e=>n[e]??-1}),i=er(e,(t,i,a)=>{let o=Ie(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=oe(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},nr=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(er(e,(t,n)=>{n.push({from:t.from,insert:e.facet(Re)})}),{userEvent:`input.indent`})),!0),rr=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(er(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Se(r,e.tabSize),a=0,o=oe(e,Math.max(0,i-ie(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),ir=e=>(e.setTabFocusMode(),!0),ar=[{key:`Ctrl-b`,run:Dt,shift:Qt,preventDefault:!0},{key:`Ctrl-f`,run:Ot,shift:$t},{key:`Ctrl-p`,run:Lt,shift:sn},{key:`Ctrl-n`,run:Rt,shift:cn},{key:`Ctrl-a`,run:qt,shift:gn},{key:`Ctrl-e`,run:Jt,shift:_n},{key:`Ctrl-d`,run:Nn},{key:`Ctrl-h`,run:Mn},{key:`Ctrl-k`,run:Ln},{key:`Ctrl-Alt-h`,run:Fn},{key:`Ctrl-o`,run:Bn},{key:`Ctrl-t`,run:Vn},{key:`Ctrl-v`,run:Ht}],or=[{key:`ArrowLeft`,run:Dt,shift:Qt,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:At,shift:tn,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Gt,shift:mn,preventDefault:!0},{key:`ArrowRight`,run:Ot,shift:$t,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:jt,shift:nn,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Kt,shift:hn,preventDefault:!0},{key:`ArrowUp`,run:Lt,shift:sn,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:vn,shift:bn},{mac:`Ctrl-ArrowUp`,run:Vt,shift:un},{key:`ArrowDown`,run:Rt,shift:cn,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:yn,shift:xn},{mac:`Ctrl-ArrowDown`,run:Ht,shift:dn},{key:`PageUp`,run:Vt,shift:un},{key:`PageDown`,run:Ht,shift:dn},{key:`Home`,run:Wt,shift:pn,preventDefault:!0},{key:`Mod-Home`,run:vn,shift:bn},{key:`End`,run:Ut,shift:fn,preventDefault:!0},{key:`Mod-End`,run:yn,shift:xn},{key:`Enter`,run:Zn,shift:Zn},{key:`Mod-a`,run:Sn},{key:`Backspace`,run:Mn,shift:Mn,preventDefault:!0},{key:`Delete`,run:Nn,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Fn,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:In,preventDefault:!0},{mac:`Mod-Backspace`,run:Rn,preventDefault:!0},{mac:`Mod-Delete`,run:zn,preventDefault:!0}].concat(ar.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),sr=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Pt,shift:rn},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Ft,shift:an},{key:`Alt-ArrowUp`,run:Wn},{key:`Shift-Alt-ArrowUp`,run:qn},{key:`Alt-ArrowDown`,run:Gn},{key:`Shift-Alt-ArrowDown`,run:Jn},{key:`Mod-Alt-ArrowUp`,run:En},{key:`Mod-Alt-ArrowDown`,run:Dn},{key:`Escape`,run:On},{key:`Mod-Enter`,run:Qn},{key:`Alt-l`,mac:`Ctrl-l`,run:Cn},{key:`Mod-i`,run:wn,preventDefault:!0},{key:`Mod-[`,run:rr},{key:`Mod-]`,run:nr},{key:`Mod-Alt-\\`,run:tr},{key:`Shift-Mod-k`,run:Yn},{key:`Shift-Mod-\\`,run:Xt},{key:`Mod-/`,run:Ge},{key:`Alt-A`,run:Je},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:ir}].concat(or),cr={key:`Tab`,run:nr,shift:rr},lr=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,G=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(lr(e)):lr,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return ue(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=me(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=fe(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(G.prototype[Symbol.iterator]=function(){return this});var ur={from:-1,to:-1,match:/.*/.exec(``)},dr=`gm`+(/x/.unicode==null?``:`u`),fr=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=ur,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new hr(e,t,n,r,i);this.re=new RegExp(t,dr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=_r(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=_r(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},pr=new WeakMap,mr=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=pr.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return pr.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),pr.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},hr=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=ur,this.matchPos=_r(e,r),this.re=new RegExp(t,dr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=mr.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=_r(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=mr.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(fr.prototype[Symbol.iterator]=hr.prototype[Symbol.iterator]=function(){return this});function gr(e){try{return new RegExp(e,dr),!0}catch{return!1}}function _r(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var vr=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=S(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=F.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,E.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},yr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},br=je.define({combine(e){return Oe(e,yr,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function xr(e){let t=[Dr,Er];return e&&t.push(br.of(e)),t}var Sr=_.mark({class:`cm-selectionMatch`}),Cr=_.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function wr(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=f.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=f.Word)}function Tr(e,t,n,r){return e(t.sliceDoc(n,n+1))==f.Word&&e(t.sliceDoc(r-1,r))==f.Word}var Er=p.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(br),{state:n}=e,r=n.selection;if(r.ranges.length>1)return _.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return _.none;let e=n.wordAt(i.head);if(!e)return _.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return _.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(wr(o,n,i.from,i.to)&&Tr(o,n,i.from,i.to)))return _.none}else if(a=n.sliceDoc(i.from,i.to),!a)return _.none}let s=[];for(let r of e.visibleRanges){let e=new G(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||wr(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(Cr.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Sr.range(r,a)),s.length>t.maxMatches))return _.none}}return _.set(s)}},{decorations:e=>e.decorations}),Dr=E.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Or=({state:e,dispatch:t})=>{let{selection:n}=e,r=F.create(n.ranges.map(t=>e.wordAt(t.head)||F.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function kr(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new G(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new G(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Ar=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Or({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=kr(e,r);return i?(t(e.update({selection:e.selection.addRange(F.range(i.from,i.to),!1),effects:E.scrollIntoView(i.to)})),!0):!1},K=je.define({combine(e){return Oe(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new si(e),scrollToMatch:e=>E.scrollIntoView(e)})}}),jr=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||gr(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
|
|
2
2
|
`:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Br(this):new Fr(this)}getCursor(e,t=0,n){let r=e.doc?e:we.create({doc:e});return n??=r.doc.length,this.regexp?J(this,r,t,n):q(this,r,t,n)}},Mr=class{constructor(e){this.spec=e}};function Nr(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function q(e,t,n,r){let i;return e.wholeWord&&(i=Pr(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=Nr(e.test,t,i)),new G(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function Pr(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(Lr(i,n-a))!=f.Word||t(Rr(i,n-a))!=f.Word)&&(t(Rr(i,r-a))!=f.Word||t(Lr(i,r-a))!=f.Word))}var Fr=class extends Mr{constructor(e){super(e)}nextMatch(e,t,n){let r=q(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=q(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=q(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=q(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=q(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function Ir(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function J(e,t,n,r){let i;return e.wholeWord&&(i=zr(t.charCategorizer(t.selection.main.head))),e.test&&(i=Ir(e.test,t,i)),new fr(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function Lr(e,t){return e.slice(N(e,t,!1),t)}function Rr(e,t){return e.slice(t,N(e,t))}function zr(e){return(t,n,r)=>!r[0].length||(e(Lr(r.input,r.index))!=f.Word||e(Rr(r.input,r.index))!=f.Word)&&(e(Rr(r.input,r.index+r[0].length))!=f.Word||e(Lr(r.input,r.index+r[0].length))!=f.Word)}var Br=class extends Mr{nextMatch(e,t,n){let r=J(this.spec,e,n,e.doc.length).next();return r.done&&(r=J(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=J(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=J(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=J(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},Vr=P.define(),Hr=P.define(),Y=ce.define({create(e){return new Ur(ti(e).create(),null)},update(e,t){for(let n of t.effects)n.is(Vr)?e=new Ur(n.value.create(),e.panel):n.is(Hr)&&(e=new Ur(e.query,n.value?ei:null));return e},provide:e=>ke.from(e,e=>e.panel)}),Ur=class{constructor(e,t){this.query=e,this.panel=t}},Wr=_.mark({class:`cm-searchMatch`}),Gr=_.mark({class:`cm-searchMatch cm-searchMatch-selected`}),Kr=p.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(Y))}update(e){let t=e.state.field(Y);(t!=e.startState.field(Y)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return _.none;let{view:n}=this,r=new Ee;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?Gr:Wr)})}return r.finish()}},{decorations:e=>e.decorations});function qr(e){return t=>{let n=t.state.field(Y,!1);return n&&n.query.spec.valid?e(t,n):ii(t)}}var Jr=qr((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=F.single(r.from,r.to),a=e.state.facet(K);return e.dispatch({selection:i,effects:[ui(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),ri(e),!0}),Yr=qr((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=F.single(i.from,i.to),o=e.state.facet(K);return e.dispatch({selection:a,effects:[ui(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),ri(e),!0}),Xr=qr((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:F.create(n.map(e=>F.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),Zr=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new G(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(F.range(t.value.from,t.value.to))}return t(e.update({selection:F.create(a,o),userEvent:`select.search.matches`})),!0},Qr=qr((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(E.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=F.single(o.from,o.to).map(d),u.push(ui(e,o)),u.push(n.facet(K).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),$r=qr((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:E.announce.of(r),userEvent:`input.replace.all`}),!0});function ei(e){return e.state.facet(K).createPanel(e)}function ti(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(K);return new jr({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function ni(e){let t=v(e,ei);return t&&t.dom.querySelector(`[main-field]`)}function ri(e){let t=ni(e);t&&t==e.root.activeElement&&t.select()}var ii=e=>{let t=e.state.field(Y,!1);if(t&&t.panel){let n=ni(e);if(n&&n!=e.root.activeElement){let r=ti(e.state,t.query.spec);r.valid&&e.dispatch({effects:Vr.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[Hr.of(!0),t?Vr.of(ti(e.state,t.query.spec)):P.appendConfig.of(fi)]});return!0},ai=e=>{let t=e.state.field(Y,!1);if(!t||!t.panel)return!1;let n=v(e,ei);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:Hr.of(!1)}),!0},oi=[{key:`Mod-f`,run:ii,scope:`editor search-panel`},{key:`F3`,run:Jr,shift:Yr,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:Jr,shift:Yr,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:ai,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:Zr},{key:`Mod-Alt-g`,run:vr},{key:`Mod-d`,run:Ar,preventDefault:!0}],si=class{constructor(e){this.view=e;let t=this.query=e.state.field(Y).query.spec;this.commit=this.commit.bind(this),this.searchField=x(`input`,{value:t.search,placeholder:X(e,`Find`),"aria-label":X(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=x(`input`,{value:t.replace,placeholder:X(e,`Replace`),"aria-label":X(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=x(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=x(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=x(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return x(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=x(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>Jr(e),[X(e,`next`)]),n(`prev`,()=>Yr(e),[X(e,`previous`)]),n(`select`,()=>Xr(e),[X(e,`all`)]),x(`label`,null,[this.caseField,X(e,`match case`)]),x(`label`,null,[this.reField,X(e,`regexp`)]),x(`label`,null,[this.wordField,X(e,`by word`)]),...e.state.readOnly?[]:[x(`br`),this.replaceField,n(`replace`,()=>Qr(e),[X(e,`replace`)]),n(`replaceAll`,()=>$r(e),[X(e,`replace all`)])],x(`button`,{name:`close`,onclick:()=>ai(e),"aria-label":X(e,`close`),type:`button`},[`×`])])}commit(){let e=new jr({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Vr.of(e)}))}keydown(e){y(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Yr:Jr)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Qr(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(Vr)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(K).top}};function X(e,t){return e.state.phrase(t)}var ci=30,li=/[\s\.,:;?!]/;function ui(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-ci),o=Math.min(i,n+ci),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<ci;e++)if(!li.test(s[e+1])&&li.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-ci;e--)if(!li.test(s[e-1])&&li.test(s[e])){s=s.slice(0,e);break}}return E.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var di=E.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),fi=[Y,_e.low(Kr),di],pi=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},mi=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Ei).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Ee,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=Li(s);if(i)o.add(n,n,_.widget({widget:new Ai(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,_.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,Z(f))}};function Z(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new pi(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new pi(r.from,n,r.diagnostic)}),r}function hi(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Ei).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(_i))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function gi(e,t){return e.field(Q,!1)?t:t.concat(P.appendConfig.of(Ri))}var _i=P.define(),vi=P.define(),yi=P.define(),Q=ce.define({create(){return new mi(_.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=Z(n,e.selected.diagnostic,i)||Z(n,null,i)}!n.size&&i&&t.state.facet(Ei).autoPanel&&(i=null),e=new mi(n,i,r)}for(let n of t.effects)if(n.is(_i)){let r=t.state.facet(Ei).autoPanel?n.value.length?Mi.open:null:e.panel;e=mi.init(n.value,r,t.state)}else n.is(vi)?e=new mi(e.diagnostics,n.value?Mi.open:null,e.selected):n.is(yi)&&(e=new mi(e.diagnostics,e.panel,n.value));return e},provide:e=>[ke.from(e,e=>e.panel),E.decorations.from(e,e=>e.diagnostics)]}),bi=_.mark({class:`cm-lintRange cm-lintRange-active`});function xi(e,t,n){let{diagnostics:r}=e.state.field(Q),i,a=-1,o=-1;r.between(t-(n<0?1:0),t+(n>0?1:0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(Ei).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:Si(e,i)}}}:null}function Si(e,t){return x(`ul`,{class:`cm-tooltip-lint`},t.map(t=>ki(e,t,!1)))}var Ci=e=>{let t=e.state.field(Q,!1);(!t||!t.panel)&&e.dispatch({effects:gi(e.state,[vi.of(!0)])});let n=v(e,Mi.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},wi=e=>{let t=e.state.field(Q,!1);return!t||!t.panel?!1:(e.dispatch({effects:vi.of(!1)}),!0)},Ti=[{key:`Mod-Shift-m`,run:Ci,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(Q,!1);if(!t)return!1;let n=e.state.selection.main,r=Z(t.diagnostics,null,n.to+1);return!r&&(r=Z(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],Ei=je.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...Oe(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Di,tooltipFilter:Di,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function Di(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function Oi(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function ki(e,t,n){let r=n?Oi(t.actions):[];return x(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},x(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=Z(e.state.field(Q).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),x(`u`,s.slice(c,c+1)),s.slice(c+1)];return x(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&x(`div`,{class:`cm-diagnosticSource`},t.source))}var Ai=class extends ve{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return x(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},ji=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=ki(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},Mi=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)wi(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=Oi(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=Z(this.view.state.field(Q).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=x(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=x(`div`,{class:`cm-panel-lint`},this.list,x(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>wi(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(Q).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Q),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new ji(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new ji(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=Z(this.view.state.field(Q).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:yi.of(t)})}static open(t){return new e(t)}};function Ni(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function Pi(e){return Ni(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var Fi=E.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:Pi(`#d11`)},".cm-lintRange-warning":{backgroundImage:Pi(`orange`)},".cm-lintRange-info":{backgroundImage:Pi(`#999`)},".cm-lintRange-hint":{backgroundImage:Pi(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function Ii(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function Li(e){let t=`hint`,n=1;for(let r of e){let e=Ii(r.severity);e>n&&(n=e,t=r.severity)}return t}var Ri=[Q,E.decorations.compute([Q],e=>{let{selected:t,panel:n}=e.field(Q);return!t||!n||t.from==t.to?_.none:_.set([bi.range(t.from,t.to)])}),m(xi,{hideOn:hi}),Fi],zi=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(Pe)),e.defaultKeymap!==!1&&(n=n.concat(sr)),e.searchKeymap!==!1&&(n=n.concat(oi)),e.historyKeymap!==!1&&(n=n.concat(wt)),e.foldKeymap!==!1&&(n=n.concat(pe)),e.completionKeymap!==!1&&(n=n.concat(le)),e.lintKeymap!==!1&&(n=n.concat(Ti));var r=[];return e.lineNumbers!==!1&&r.push(b()),e.highlightActiveLineGutter!==!1&&r.push(k()),e.highlightSpecialChars!==!1&&r.push(Be()),e.history!==!1&&r.push(st()),e.foldGutter!==!1&&r.push(he()),e.drawSelection!==!1&&r.push(T()),e.dropCursor!==!1&&r.push(D()),e.allowMultipleSelections!==!1&&r.push(we.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&r.push(ze()),e.syntaxHighlighting!==!1&&r.push(h(xe,{fallback:!0})),e.bracketMatching!==!1&&r.push(De()),e.closeBrackets!==!1&&r.push(ye()),e.autocompletion!==!1&&r.push(se()),e.rectangularSelection!==!1&&r.push(te()),t!==!1&&r.push(w()),e.highlightActiveLine!==!1&&r.push(C()),e.highlightSelectionMatches!==!1&&r.push(xr()),e.tabSize&&typeof e.tabSize==`number`&&r.push(Re.of(` `.repeat(e.tabSize))),r.concat([M.of(n.flat())]).filter(Boolean)},Bi=E.theme({"&":{backgroundColor:`#fff`}},{dark:!1}),Vi=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:r=!1,theme:i=`light`,placeholder:a=``,basicSetup:o=!0}=e,s=[];switch(t&&s.unshift(M.of([cr])),o&&(typeof o==`boolean`?s.unshift(zi()):s.unshift(zi(o))),a&&s.unshift(ee(a)),i){case`light`:s.push(Bi);break;case`dark`:s.push(Me);break;case`none`:break;default:s.push(i);break}return n===!1&&s.push(E.editable.of(!1)),r&&s.push(we.readOnly.of(!0)),[...s]},Hi=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)}),Ui=class{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){console.error(`TimeoutLatch callback error:`,e)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}},Wi=class{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}},Gi=null,Ki=()=>typeof window>`u`?new Wi:(Gi||=new Wi,Gi),qi=ne.define(),Ji=200,Yi=[];function Xi(e){var{value:t,selection:n,onChange:r,onStatistics:i,onCreateEditor:a,onUpdate:o,extensions:s=Yi,autoFocus:c,theme:l=`light`,height:u=null,minHeight:d=null,maxHeight:f=null,width:p=null,minWidth:m=null,maxWidth:h=null,placeholder:g=``,editable:_=!0,readOnly:v=!1,indentWithTab:y=!0,basicSetup:b=!0,root:x,initialState:S}=e,[C,w]=(0,I.useState)(),[T,D]=(0,I.useState)(),[O,k]=(0,I.useState)(),A=(0,I.useState)(()=>({current:null}))[0],j=(0,I.useState)(()=>({current:null}))[0],ee=E.theme({"&":{height:u,minHeight:d,maxHeight:f,width:p,minWidth:m,maxWidth:h},"& .cm-scroller":{height:`100% !important`}}),M=[E.updateListener.of(e=>{e.docChanged&&typeof r==`function`&&!e.transactions.some(e=>e.annotation(qi))&&(A.current?A.current.reset():(A.current=new Ui(()=>{if(j.current){var e=j.current;j.current=null,e()}A.current=null},Ji),Ki().add(A.current)),r(e.state.doc.toString(),e)),i&&i(Hi(e))}),ee,...Vi({theme:l,editable:_,readOnly:v,placeholder:g,indentWithTab:y,basicSetup:b})];return o&&typeof o==`function`&&M.push(E.updateListener.of(o)),M=M.concat(s),(0,I.useLayoutEffect)(()=>{if(C&&!O){var e={doc:t,selection:n,extensions:M},r=S?we.fromJSON(S.json,e,S.fields):we.create(e);if(k(r),!T){var i=new E({state:r,parent:C,root:x});D(i),a&&a(i,r)}}return()=>{T&&(k(void 0),D(void 0))}},[C,O]),(0,I.useEffect)(()=>{e.container&&w(e.container)},[e.container]),(0,I.useEffect)(()=>()=>{T&&(T.destroy(),D(void 0)),A.current&&=(A.current.cancel(),null)},[T]),(0,I.useEffect)(()=>{c&&T&&T.focus()},[c,T]),(0,I.useEffect)(()=>{T&&T.dispatch({effects:P.reconfigure.of(M)})},[l,s,u,d,f,p,m,h,g,_,v,y,b,r,o]),(0,I.useEffect)(()=>{if(t!==void 0){var e=T?T.state.doc.toString():``;if(T&&t!==e){var n=A.current&&!A.current.isDone,r=()=>{T&&t!==T.state.doc.toString()&&T.dispatch({changes:{from:0,to:T.state.doc.toString().length,insert:t||``},annotations:[qi.of(!0)]})};n?j.current=r:r()}}},[t,T]),{state:O,setState:k,view:T,setView:D,container:C,setContainer:w}}var $=r(),Zi=[`className`,`value`,`selection`,`extensions`,`onChange`,`onStatistics`,`onCreateEditor`,`onUpdate`,`autoFocus`,`theme`,`height`,`minHeight`,`maxHeight`,`width`,`minWidth`,`maxWidth`,`basicSetup`,`placeholder`,`indentWithTab`,`editable`,`readOnly`,`root`,`initialState`],Qi=(0,I.forwardRef)((e,t)=>{var{className:n,value:r=``,selection:i,extensions:a=[],onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,autoFocus:u,theme:d=`light`,height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_,basicSetup:v,placeholder:y,indentWithTab:b,editable:x,readOnly:S,root:C,initialState:w}=e,T=We(e,Zi),E=(0,I.useRef)(null),{state:D,view:O,container:k,setContainer:A}=Xi({root:C,value:r,autoFocus:u,theme:d,height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_,basicSetup:v,placeholder:y,indentWithTab:b,editable:x,readOnly:S,selection:i,onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,extensions:a,initialState:w});(0,I.useImperativeHandle)(t,()=>({editor:E.current,state:D,view:O}),[E,k,D,O]);var j=(0,I.useCallback)(e=>{E.current=e,A(e)},[A]);if(typeof r!=`string`)throw Error(`value must be typeof string but got `+typeof r);return(0,$.jsx)(`div`,Ue({ref:j,className:(typeof d==`string`?`cm-theme-`+d:`cm-theme`)+(n?` `+n:``)},T))});Qi.displayName=`CodeMirror`;var $i=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`ico`]),ea=`pdf`;function ta(e){return e.split(`.`).pop()?.toLowerCase()??``}function na(e){switch(ta(e)){case`js`:case`jsx`:return Te({jsx:!0});case`ts`:case`tsx`:return Te({jsx:!0,typescript:!0});case`py`:return ae();case`html`:return Ae();case`css`:case`scss`:return ge();case`json`:return Ce();case`md`:case`mdx`:return Ne();default:return null}}function ra({metadata:e,tabId:t}){let n=e?.filePath,r=e?.projectName,[a,o]=(0,I.useState)(null),[s,f]=(0,I.useState)(`utf-8`),[p,m]=(0,I.useState)(!0),[h,g]=(0,I.useState)(null),[_,v]=(0,I.useState)(!1),y=(0,I.useRef)(null),b=(0,I.useRef)(``),{tabs:x,updateTab:S}=d(),C=x.find(e=>e.id===t),w=n?ta(n):``,T=$i.has(w),E=w===ea,D=w===`md`||w===`mdx`,[O,k]=(0,I.useState)(`preview`);(0,I.useEffect)(()=>{if(!(!n||!r)){if(T||E){m(!1);return}return m(!0),g(null),l.get(`${c(r)}/files/read?path=${encodeURIComponent(n)}`).then(e=>{o(e.content),f(e.encoding),b.current=e.content,m(!1)}).catch(e=>{g(e instanceof Error?e.message:`Failed to load file`),m(!1)}),()=>{y.current&&clearTimeout(y.current)}}},[n,r,T,E]),(0,I.useEffect)(()=>{if(!C)return;let e=n?.split(`/`).pop()??`Untitled`,t=_?`${e} \u25CF`:e;C.title!==t&&S(C.id,{title:t})},[_]);let A=(0,I.useCallback)(async e=>{if(!(!n||!r))try{await l.put(`${c(r)}/files/write`,{path:n,content:e}),v(!1)}catch{}},[n,r]);function j(e){o(e),b.current=e,v(!0),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{A(b.current)},1e3)}if(!n||!r)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:`No file selected.`});if(p)return(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-text-secondary`,children:[(0,$.jsx)(u,{className:`size-5 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Loading file...`})]});if(h)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-error text-sm`,children:h});if(T)return(0,$.jsx)(aa,{filePath:n,projectName:r});if(E)return(0,$.jsx)(oa,{filePath:n,projectName:r});if(s===`base64`)return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,$.jsx)(He,{className:`size-10 text-text-subtle`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`This file is a binary format and cannot be displayed.`}),(0,$.jsx)(`p`,{className:`text-xs text-text-subtle`,children:n})]});let ee=[],M=na(n);M&&ee.push(M);let te=D?(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1 border-border shrink-0 bg-background`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>k(`edit`),className:`flex items-center gap-1 px-2 py-1 rounded text-xs transition-colors ${O===`edit`?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,$.jsx)(i,{className:`size-3`}),`Edit`]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>k(`preview`),className:`flex items-center gap-1 px-2 py-1 rounded text-xs transition-colors ${O===`preview`?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,$.jsx)(Ve,{className:`size-3`}),`Preview`]})]}):null;return(0,$.jsxs)(`div`,{className:`flex flex-col h-full w-full overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`hidden md:block border-b`,children:te}),D&&O===`preview`?(0,$.jsx)(ia,{content:a??``}):(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:(0,$.jsx)(Qi,{value:a??``,onChange:j,extensions:ee,theme:Me,height:`100%`,style:{height:`100%`,fontSize:`13px`,fontFamily:`var(--font-mono)`},basicSetup:{lineNumbers:!0,foldGutter:!0,autocompletion:!0,bracketMatching:!0,closeBrackets:!0,highlightActiveLine:!0,indentOnInput:!0}})}),(0,$.jsx)(`div`,{className:`md:hidden border-t`,children:te})]})}function ia({content:e}){return(0,$.jsx)(`div`,{className:`flex-1 overflow-auto p-4 markdown-content prose-sm`,dangerouslySetInnerHTML:{__html:(0,I.useMemo)(()=>{try{return a.parse(e,{gfm:!0,breaks:!0})}catch{return e}},[e])}})}function aa({filePath:e,projectName:t}){let[n,r]=(0,I.useState)(null),[i,a]=(0,I.useState)(!1);return(0,I.useEffect)(()=>{let n,i=`${c(t)}/files/raw?path=${encodeURIComponent(e)}`,o=s();return fetch(i,{headers:o?{Authorization:`Bearer ${o}`}:{}}).then(e=>{if(!e.ok)throw Error(`Failed`);return e.blob()}).then(e=>{let t=URL.createObjectURL(e);n=t,r(t)}).catch(()=>a(!0)),()=>{n&&URL.revokeObjectURL(n)}},[e,t]),i?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,$.jsx)(He,{className:`size-10 text-text-subtle`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Failed to load image.`})]}):n?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full p-4 bg-surface overflow-auto`,children:(0,$.jsx)(`img`,{src:n,alt:e,className:`max-w-full max-h-full object-contain`})}):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsx)(u,{className:`size-5 animate-spin text-text-subtle`})})}function oa({filePath:e,projectName:t}){let[n,r]=(0,I.useState)(null),[i,a]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let n,i=`${c(t)}/files/raw?path=${encodeURIComponent(e)}`,o=s();return fetch(i,{headers:o?{Authorization:`Bearer ${o}`}:{}}).then(e=>{if(!e.ok)throw Error(`Failed`);return e.blob()}).then(e=>{let t=URL.createObjectURL(new Blob([e],{type:`application/pdf`}));n=t,r(t)}).catch(()=>a(!0)),()=>{n&&URL.revokeObjectURL(n)}},[e,t]);let l=(0,I.useCallback)(()=>{n&&window.open(n,`_blank`)},[n]);return i?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,$.jsx)(He,{className:`size-10 text-text-subtle`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Failed to load PDF.`})]}):n?(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,$.jsx)(`span`,{className:`text-xs text-text-secondary truncate`,children:e}),(0,$.jsxs)(`button`,{onClick:l,className:`flex items-center gap-1 text-xs text-text-secondary hover:text-text-primary transition-colors`,children:[(0,$.jsx)(o,{className:`size-3`}),`Open in new tab`]})]}),(0,$.jsx)(`iframe`,{src:n,title:e,className:`flex-1 w-full border-none`})]}):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsx)(u,{className:`size-5 animate-spin text-text-subtle`})})}export{ra as CodeEditor};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,r as t,t as n}from"./jsx-runtime-BFALxl05.js";import{_ as r,a as i,b as a,d as o,f as s,h as c,i as l,l as u,m as d,n as ee,o as f,p,r as te,s as ne,t as m,u as h}from"./button-
|
|
1
|
+
import{a as e,r as t,t as n}from"./jsx-runtime-BFALxl05.js";import{_ as r,a as i,b as a,d as o,f as s,h as c,i as l,l as u,m as d,n as ee,o as f,p,r as te,s as ne,t as m,u as h}from"./button-CvHWF07y.js";import{t as re}from"./x-Bpqyw40Y.js";import{t as g}from"./utils-61GRB9Cb.js";var _=e(t(),1);function ie(e,t){return _.useReducer((e,n)=>t[e][n]??e,e)}var v=e=>{let{present:t,children:n}=e,r=y(t),i=typeof n==`function`?n({present:r.isPresent}):_.Children.only(n),o=a(r.ref,x(i));return typeof n==`function`||r.isPresent?_.cloneElement(i,{ref:o}):null};v.displayName=`Presence`;function y(e){let[t,n]=_.useState(),r=_.useRef(null),i=_.useRef(e),a=_.useRef(`none`),[s,c]=ie(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return _.useEffect(()=>{let e=b(r.current);a.current=s===`mounted`?e:`none`},[s]),o(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=b(t);e?c(`MOUNT`):o===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),o(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=b(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},s=e=>{e.target===t&&(a.current=b(r.current))};return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:_.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function b(e){return e?.animationName||`none`}function x(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var S=n(),C=`Dialog`,[w,ae]=d(C),[T,E]=w(C),D=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=_.useRef(null),c=_.useRef(null),[l,d]=h({prop:r,defaultProp:i??!1,onChange:a,caller:C});return(0,S.jsx)(T,{scope:t,triggerRef:s,contentRef:c,contentId:u(),titleId:u(),descriptionId:u(),open:l,onOpenChange:d,onOpenToggle:_.useCallback(()=>d(e=>!e),[d]),modal:o,children:n})};D.displayName=C;var O=`DialogTrigger`,k=_.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=E(O,n),o=a(t,i.triggerRef);return(0,S.jsx)(c.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Y(i.open),...r,ref:o,onClick:s(e.onClick,i.onOpenToggle)})});k.displayName=O;var A=`DialogPortal`,[j,M]=w(A,{forceMount:void 0}),N=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:a}=e,o=E(A,t);return(0,S.jsx)(j,{scope:t,forceMount:n,children:_.Children.map(r,e=>(0,S.jsx)(v,{present:n||o.open,children:(0,S.jsx)(i,{asChild:!0,container:a,children:e})}))})};N.displayName=A;var P=`DialogOverlay`,F=_.forwardRef((e,t)=>{let n=M(P,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=E(P,e.__scopeDialog);return a.modal?(0,S.jsx)(v,{present:r||a.open,children:(0,S.jsx)(L,{...i,ref:t})}):null});F.displayName=P;var I=r(`DialogOverlay.RemoveScroll`),L=_.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=E(P,n);return(0,S.jsx)(te,{as:I,allowPinchZoom:!0,shards:[i.contentRef],children:(0,S.jsx)(c.div,{"data-state":Y(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),R=`DialogContent`,z=_.forwardRef((e,t)=>{let n=M(R,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=E(R,e.__scopeDialog);return(0,S.jsx)(v,{present:r||a.open,children:a.modal?(0,S.jsx)(B,{...i,ref:t}):(0,S.jsx)(V,{...i,ref:t})})});z.displayName=R;var B=_.forwardRef((e,t)=>{let n=E(R,e.__scopeDialog),r=_.useRef(null),i=a(t,n.contentRef,r);return _.useEffect(()=>{let e=r.current;if(e)return ee(e)},[]),(0,S.jsx)(H,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:s(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:s(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:s(e.onFocusOutside,e=>e.preventDefault())})}),V=_.forwardRef((e,t)=>{let n=E(R,e.__scopeDialog),r=_.useRef(!1),i=_.useRef(!1);return(0,S.jsx)(H,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),H=_.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...s}=e,c=E(R,n),u=_.useRef(null),d=a(t,u);return l(),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(f,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:(0,S.jsx)(ne,{role:`dialog`,id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Y(c.open),...s,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(se,{titleId:c.titleId}),(0,S.jsx)(le,{contentRef:u,descriptionId:c.descriptionId})]})]})}),U=`DialogTitle`,W=_.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=E(U,n);return(0,S.jsx)(c.h2,{id:i.titleId,...r,ref:t})});W.displayName=U;var G=`DialogDescription`,K=_.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=E(G,n);return(0,S.jsx)(c.p,{id:i.descriptionId,...r,ref:t})});K.displayName=G;var q=`DialogClose`,J=_.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=E(q,n);return(0,S.jsx)(c.button,{type:`button`,...r,ref:t,onClick:s(e.onClick,()=>i.onOpenChange(!1))})});J.displayName=q;function Y(e){return e?`open`:`closed`}var X=`DialogTitleWarning`,[oe,Z]=p(X,{contentName:R,titleName:U,docsSlug:`dialog`}),se=({titleId:e})=>{let t=Z(X),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
2
2
|
|
|
3
3
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
4
4
|
|
|
@@ -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-B_eCZViO.js";import{D as s,P as c,T as l}from"./index-DLIV9ojh.js";import{A as u,E as d,H as f,I as p,O as m,Q as h,Y as g,a as _,at as v,ct as y,et as ee,i as b,it as x,j as S,k as C,n as w,nt as T,o as E,ot as D,r as O,rt as k,s as te,st as A,t as j}from"./dist-CBiGQxfr.js";var ne=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`}]]),M=e(n(),1),N=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 P(e,t,n,r,i,a){if(e==r)return[];let o=L(e,t,n,r,i,a),s=R(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 N(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new N(t,t+o,i,i),new N(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 N(t,t,i,i+o),new N(n,n,i+o+c,a)]}if(c==1||l==1)return[new N(t,n,i,a)];let u=ue(e,t,n,r,i,a);if(u){let[o,s,c]=u;return P(e,t,o,r,i,s).concat(P(e,o+c,n,r,s+c,a))}return ie(e,t,n,r,i,a)}var F=1e9,I=0,re=!1;function ie(e,t,n,r,i,a){let o=n-t,s=a-i;if(F<1e9&&Math.min(o,s)>F*16||I>0&&Date.now()>I)return Math.min(o,s)>F*64?[new N(t,n,i,a)]:de(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);oe.reset(c),se.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:se,f=d?null:oe;for(let p=0;p<c;p++){if(p>F||I>0&&!(p&63)&&Date.now()>I)return de(e,t,n,r,i,a);let m=oe.advance(p,o,s,c,d,!1,l)||se.advance(p,o,s,c,f,!0,u);if(m)return ce(e,t,n,t+m[0],r,i,a,i+m[1])}return[new N(t,n,i,a)]}var ae=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}},oe=new ae,se=new ae;function ce(e,t,n,r,i,a,o,s){let c=!1;return!V(e,r)&&++r==n&&(c=!0),!V(i,s)&&++s==o&&(c=!0),c?[new N(t,n,a,o)]:P(e,t,r,i,a,s).concat(P(e,r,n,i,s,o))}function le(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function L(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=le(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-(V(e,s)?0:1);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function R(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=le(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-(V(e,s)?0:1);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function z(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;;){V(e,s)||s++;let u=s+o;if(V(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=L(e,u,n,r,i+f+d.length,a),c=R(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 ue(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=ue(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:z(e,t,n,r,i,a,Math.floor(o/4),-1)}function de(e,t,n,r,i,a){re=!0;let o=n-t,s=a-i,c;if(o<s){let s=z(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=z(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new N(t,n,i,a)];let[l,u,d]=c;return P(e,t,l,r,i,u).concat(P(e,l+d,n,r,u+d,a))}function fe(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 N(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function pe(e,t,n){for(;;){fe(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=L(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new N(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=R(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new N(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 N(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 N(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}function me(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=be(t,a.fromA,l),f=ye(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 N(d,d+o,a.fromB-p,a.toB-p),d=a.fromA,f=ye(t,a.toA,c-a.toA)):l>m&&t.slice(a.toA,f)==u.slice(h,h+m)&&(a=e[i]=new N(f-o,f,a.fromB+m,a.toB+m),f=a.toA,d=be(t,a.fromA,a.fromA-r)),p=a.fromA-d,m=f-a.toA}if(p||m)a=e[i]=new N(a.fromA-p,a.toA+m,a.fromB-p,a.toB+m);else if(!o){let t=Se(n,a.fromB,a.toB),r,o=t<0?-1:xe(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=Se(t,a.fromA,a.toA),r,o=n<0?-1:xe(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 fe(e,3),e}var B;try{B=RegExp(`[\\p{Alphabetic}\\p{Number}]`,`u`)}catch{}function he(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function ge(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?he(n)?1:0:B?!Ce(n)||t==e.length-1?B.test(String.fromCharCode(n))?1:0:B.test(e.slice(t,t+2))?2:0:0}function _e(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?he(n)?1:0:B?!we(n)||t==1?B.test(String.fromCharCode(n))?1:0:B.test(e.slice(t-2,t))?2:0:0}var ve=8;function ye(e,t,n){if(t==e.length||!_e(e,t))return t;for(let r=t,i=t+n,a=0;a<ve;a++){let t=ge(e,r);if(!t||r+t>i)return r;r+=t}return t}function be(e,t,n){if(!t||!ge(e,t))return t;for(let r=t,i=t-n,a=0;a<ve;a++){let t=_e(e,r);if(!t||r-t<i)return r;r-=t}return t}function xe(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function Se(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}var Ce=e=>e>=55296&&e<=56319,we=e=>e>=56320&&e<=57343;function V(e,t){return!t||t==e.length||!Ce(e.charCodeAt(t-1))||!we(e.charCodeAt(t))}function Te(e,t,n){let r=n?.override;return r?r(e,t):(F=(n?.scanLimit??1e9)>>1,I=n?.timeout?Date.now()+n.timeout:0,re=!1,pe(e,t,P(e,0,e.length,t,0,t.length)))}function Ee(){return!re}function De(e,t,n){return me(Te(e,t,n),e,t)}var H=k.define({combine:e=>e[0]}),U=A.define(),Oe=k.define(),W=y.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(U)&&(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(De(e.toString(),t.toString(),n),e,t,0,0,Ee())}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=De(n.sliceString(d,p),r.sliceString(f,m),i);for(let e of je(h,n,r,d,f,Ee()))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=u.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=x.low(p({class:`cm-changeGutter`,markers:e=>e.plugin(Ie)?.gutter||v.empty}));function Le(e,t){return e.field(W,!1)!=t.field(W,!1)}function Re(e,t){return e.facet(H)!=t.facet(H)}var ze=d.line({class:`cm-changedLine`}),Be=d.mark({class:`cm-changedText`}),Ve=d.mark({tagName:`ins`,class:`cm-insertedLine`}),He=d.mark({tagName:`del`,class:`cm-deletedLine`}),Ue=new class extends C{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(H),o=n==`a`,s=new D,c=i?new D: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 S{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=A.define({map:(e,t)=>e.map(t)}),X=y.define({create:()=>d.none,update:(e,t)=>{for(let e of t.effects)if(e.is(Y))return e.value;return e.map(t.changes)},provide:e=>m.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 D,i=new D,a=e.state.field(X).iter(),o=t.state.field(X).iter(),s=0,c=0,l=0,u=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+u);n<-Z?(l-=n,r.add(s,s,d.widget({widget:new J(-n),block:!0,side:-1}))):n>Z&&(u+=n,i.add(c,c,d.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;)u-=o.value.spec.widget.height,o.next()}for(;a.value;)l-=a.value.spec.widget.height,a.next();for(;o.value;)u-=o.value.spec.widget.height,o.next();let m=e.contentHeight+l-(t.contentHeight+u);m<Z?r.add(e.state.doc.length,e.state.doc.length,d.widget({widget:new J(-m),block:!0,side:1})):m>Z&&i.add(t.state.doc.length,t.state.doc.length,d.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=A.define({map:(e,t)=>t.mapPos(e)}),Ye=class extends S{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(H);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=y.define({create(e){return d.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=>m.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 D,i=e.facet(H).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,u=c?e.doc.lineAt(i?c.fromA:c.fromB).number-1-t:e.doc.lines,f=u-l+1;if(f>=n&&r.add(e.doc.line(l).from,e.doc.line(u).to,d.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=m.styleModule.of(new g({".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=m.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=[x.low(Ie),tt,et,X,m.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(Y)))&&this.measure()})],n=[H.of({side:`a`,sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(q);let r=T.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],m.editorAttributes.of({class:`cm-merge-a`}),Q.of(n),t]}),i=[H.of({side:`b`,sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(q);let a=T.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],m.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:A.appendConfig.of(o)}).state,a=a.update({effects:A.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 m({state:r,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new m({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),h.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:U.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:U.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(H),o=n?e.gutter!==!1:r.markGutter,s=t?e.highlightChanges!==!1:r.highlightChanges;i.push(Q.reconfigure([H.of({side:`a`,sibling:()=>this.b,highlightChanges:s,markGutter:o}),o?q:[]])),a.push(Q.reconfigure([H.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 E({jsx:!0});case`ts`:case`tsx`:return E({jsx:!0,typescript:!0});case`py`:return _();case`html`:return O();case`css`:case`scss`:return b();case`json`:return w();case`md`:case`mdx`:return j();default:return null}}function ot({metadata:e}){let t=e?.filePath,n=e?.projectName,r=e?.ref1,u=e?.ref2,d=e?.file1,p=e?.file2,h=e?.original,g=e?.modified,_=h!=null||g!=null,v=!!(d&&p),[y,ee]=(0,M.useState)(null),[b,x]=(0,M.useState)(null),[S,C]=(0,M.useState)(!_),[w,E]=(0,M.useState)(null),[D,O]=(0,M.useState)(`both`),k=(0,M.useRef)(null),A=(0,M.useRef)(null);(0,M.useEffect)(()=>{if(_||!n)return;if(C(!0),E(null),d&&p){let e=new URLSearchParams;e.set(`file1`,d),e.set(`file2`,p),o.get(`${a(n)}/files/compare?${e.toString()}`).then(e=>{x(e),C(!1)}).catch(e=>{E(e instanceof Error?e.message:`Failed to compare files`),C(!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||u){let t=new URLSearchParams;r&&t.set(`ref1`,r),u&&t.set(`ref2`,u),e=`${a(n)}/git/diff?${t.toString()}`}else e=`${a(n)}/git/diff`;o.get(e).then(e=>{ee(e.diff),C(!1)}).catch(e=>{E(e instanceof Error?e.message:`Failed to load diff`),C(!1)})},[t,n,r,u,d,p]);let{original:j,modified:N}=(0,M.useMemo)(()=>_?{original:h??``,modified:g??``}:v&&b?b:y?st(y):{original:``,modified:``},[y,_,h,g,v,b]),P=(0,M.useMemo)(()=>{let e=t??p??d;if(!e)return[];let n=at(e);return n?[n]:[]},[t,d,p]);if((0,M.useEffect)(()=>{let e=k.current;if(!e||S||w||!j&&!N)return;A.current&&=(A.current.destroy(),null),window.innerWidth;let t=[...P,te,m.editable.of(!1),T.readOnly.of(!0),f(),m.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:j,extensions:t},b:{doc:N,extensions:t},orientation:`a-b`,revertControls:void 0,highlightChanges:!0,gutter:!0});A.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(),A.current=null}},[j,N,P,S,w]),(0,M.useEffect)(()=>{let e=A.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=k.current?.querySelector(`.cm-mergeViewGutter`);t&&(t.style.display=D===`right`?`none`:``,t.style.flex=D===`left`?`1`:``),n&&(n.style.display=D===`left`?`none`:``,n.style.flex=D===`right`?`1`:``),r&&(r.style.display=D===`both`?``:`none`)},[D,j,N]),!n&&!_)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`});if(S)return(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,$.jsx)(s,{className:`size-5 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Loading diff...`})]});if(w)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-destructive text-sm`,children:w});if(!_&&!v&&(!y||y.trim()===``)&&!j&&!N)return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,$.jsx)(c,{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 F=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>O(D===`left`?`both`:`left`),className:`p-1 rounded hover:bg-muted transition-colors ${D===`left`?`bg-muted text-foreground`:``}`,title:`Expand original`,children:(0,$.jsx)(l,{className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>O(`both`),className:`p-1 rounded hover:bg-muted transition-colors ${D===`both`?`bg-muted text-foreground`:``}`,title:`Side by side`,children:(0,$.jsx)(i,{className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>O(D===`right`?`both`:`right`),className:`p-1 rounded hover:bg-muted transition-colors ${D===`right`?`bg-muted text-foreground`:``}`,title:`Expand modified`,children:(0,$.jsx)(ne,{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)(c,{className:`size-3.5`}),v?(0,$.jsxs)(`span`,{className:`font-mono truncate flex-1`,children:[d,` vs `,p]}):(0,$.jsxs)(`span`,{className:`flex-1 truncate`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:t??`Working tree changes`}),(r||u)&&(0,$.jsxs)(`span`,{children:[` (`,r?.slice(0,7)??`HEAD`,` vs `,u?.slice(0,7)??`working tree`,`)`]})]}),(0,$.jsx)(`div`,{className:`hidden md:block`,children:F})]}),(0,$.jsx)(`div`,{ref:k,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:F})]})}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};
|
|
@@ -0,0 +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-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-Cn5zGuid.js";import{r as h,t as g}from"./api-client-B_eCZViO.js";import{D as ee,O as te,a as ne,c as _,f as re,k as v,l as y,o as b,s as x,u as S}from"./index-DLIV9ojh.js";var ie=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`}]]),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}=re(),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)(te,{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)(S,{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)(x,{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)(v,{className:`size-3`}),`Create Branch...`]}),(0,E.jsx)(y,{}),(0,E.jsxs)(_,{onClick:()=>le(e.hash),children:[(0,E.jsx)(ie,{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)(S,{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)(v,{className:`size-2.5`}),e.name]})}),(0,E.jsxs)(x,{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-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{A as h,T as g,b as _,f as v,k as y,p as b,v as x}from"./index-DBaFu6Af.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,y]=(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}=v(),z=e?.viewMode===`tree`?`tree`:`flat`,B=n=>{t&&R(t,{metadata:{...e,viewMode:n}})},V=(0,D.useCallback)(async()=>{if(n)try{y(!0),h(await m.get(`${p(n)}/git/status`)),k(null)}catch(e){k(e instanceof Error?e.message:`Failed to fetch status`)}finally{y(!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)(_,{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)(b,{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)(x,{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)(_,{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)(_,{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)(g,{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),g=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(g){let g=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)(y,{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:[`(`,g.length,`)`]})]}),(0,O.jsx)(N,{showRevert:u,onRevert:f?()=>f(g,e.fullPath):void 0,onAction:()=>o?.(g),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-CvHWF07y.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-Cn5zGuid.js";import{r as p,t as m}from"./api-client-B_eCZViO.js";import{D as h,L as g,N as _,R as v,f as y,p as b,w as x}from"./index-DLIV9ojh.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,g]=(0,D.useState)(null),[_,v]=(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}=y(),z=e?.viewMode===`tree`?`tree`:`flat`,B=n=>{t&&R(t,{metadata:{...e,viewMode:n}})},V=(0,D.useCallback)(async()=>{if(n)try{v(!0),g(await m.get(`${p(n)}/git/status`)),k(null)}catch(e){k(e instanceof Error?e.message:`Failed to fetch status`)}finally{v(!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?_&&!r?(0,O.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,O.jsx)(h,{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:_?`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)(b,{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)(x,{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)(h,{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)(h,{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),h=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(h){let h=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)(v,{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:[`(`,h.length,`)`]})]}),(0,O.jsx)(N,{showRevert:u,onRevert:f?()=>f(h,e.fullPath):void 0,onAction:()=>o?.(h),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};
|