p3x-redis-ui-material
Version:
💿 P3X Redis UI triple frontend — Angular + React/MUI + Vue/Vuetify with 54 languages, 7 themes, Socket.IO, desktop notifications, and full feature parity
1 lines • 22.9 kB
JavaScript
import{S as e,a as t,b as n,g as r,h as i,m as a,n as o,p as s,r as c,s as l,t as u,y as d}from"./dist-CXQINIyJ.js";import{n as f,r as p}from"./dist-BKX20y_2.js";import{f as m,g as h,l as g,m as _,n as v,p as ee,u as y,x as b}from"./dist-C6Eila4Y.js";var te=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=S(e.state,n.from);return r.line?ne(e):r.block?ie(e):!1};function x(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 ne=x(se,0),re=x(w,0),ie=x((e,t)=>w(e,t,oe(t)),0);function S(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var C=50;function ae(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-C,r),o=e.sliceDoc(i,i+C),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*C?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+C),d=e.sliceDoc(i-C,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))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function oe(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 w(e,t,n=t.selection.ranges){let r=n.map(e=>S(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>ae(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 se(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=S(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 T=u.define(),ce=u.define(),le=l.define(),ue=l.define({combine(e){return d(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)})}}),de=a.define({create(){return P.empty},update(e,t){let n=t.state.facet(ue),i=t.annotation(T);if(i){let r=O.fromTransaction(t,i.selection),a=i.side,o=a==0?e.undone:e.done;return o=r?k(o,o.length,n.minDepth,r):M(o,t.startState.selection),new P(a==0?i.rest:o,a==0?o:i.rest)}let a=t.annotation(ce);if((a==`full`||a==`before`)&&(e=e.isolate()),t.annotation(r.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=O.fromTransaction(t),s=t.annotation(r.time),c=t.annotation(r.userEvent);return o?e=e.addChanges(o,s,c,n,t):t.selection&&(e=e.addSelection(t.startState.selection,s,c,n.newGroupDelay)),(a==`full`||a==`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 P(e.done.map(O.fromJSON),e.undone.map(O.fromJSON))}});function fe(e={}){return[de,ue.of(e),p.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?pe:e.inputType==`historyRedo`?D:null;return n?(e.preventDefault(),n(t)):!1}})]}function E(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(de,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var pe=E(0,!1),D=E(1,!1),me=E(0,!0),he=E(1,!0),O=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(n){return new e(n.changes&&c.fromJSON(n.changes),[],n.mapped&&o.fromJSON(n.mapped),n.startSelection&&t.fromJSON(n.startSelection),n.selectionsAfter.map(t.fromJSON))}static fromTransaction(t,n){let r=j;for(let e of t.startState.facet(le)){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,j)}static selection(t){return new e(void 0,j,void 0,void 0,t)}};function k(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 ge(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 _e(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function A(e,t){return e.length?t.length?e.concat(t):e:t}var j=[],ve=200;function M(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-ve));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),k(e,e.length-1,1e9,n.setSelAfter(r)))}else return[O.selection([t])]}function ye(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 N(e,t){if(!e.length)return e;let n=e.length,r=j;for(;n;){let i=be(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?[O.selection(r)]:j}function be(e,t,n){let r=A(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):j,n);if(!e.changes)return O.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new O(i,s.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var xe=/^(input\.type|delete)($|\.)/,P=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,c=o[o.length-1];return o=c&&c.changes&&!c.changes.empty&&t.changes&&(!r||xe.test(r))&&(!c.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,ge(c.changes,t.changes))||r==`input.type.compose`)?k(o,o.length-1,i.minDepth,new O(t.changes.compose(c.changes),A(s.mapEffects(t.effects,c.changes),c.effects),c.mapped,c.startSelection,j)):k(o,o.length,i.minDepth,t),new e(o,j,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:j;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&_e(a[a.length-1],t)?this:new e(M(this.done,t),this.undone,n,r)}addMapping(t){return new e(N(this.done,t),N(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:T.of({side:e,rest:ye(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?j:r.slice(0,r.length-1);return i.mapped&&(n=N(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:T.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};P.empty=new P(j,j);var Se=[{key:`Mod-z`,run:pe,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:D,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:D,preventDefault:!0},{key:`Mod-u`,run:me,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:he,preventDefault:!0}];function F(e,n){return t.create(e.ranges.map(n),e.mainIndex)}function I(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function L({state:e,dispatch:t},n){let r=F(e.selection,n);return r.eq(e.selection,!0)?!1:(t(I(e,r)),!0)}function R(e,n){return t.cursor(n?e.to:e.from)}function z(e,t){return L(e,n=>n.empty?e.moveByChar(n,t):R(n,t))}function B(e){return e.textDirectionAt(e.state.selection.main.head)==f.LTR}var V=e=>z(e,!B(e)),H=e=>z(e,B(e));function U(e,t){return L(e,n=>n.empty?e.moveByGroup(n,t):R(n,t))}var Ce=e=>U(e,!B(e)),we=e=>U(e,B(e));typeof Intl<`u`&&Intl.Segmenter;function Te(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 W(e,n,r){let i=h(e).resolveInner(n.head),a=r?b.closedBy:b.openedBy;for(let t=n.head;;){let n=r?i.childAfter(t):i.childBefore(t);if(!n)break;Te(e,n,a)?i=n:t=r?n.to:n.from}let o=i.type.prop(a),s,c;return c=o&&(s=r?_(e,i.from,1):_(e,i.to,-1))&&s.matched?r?s.end.to:s.end.from:r?i.to:i.from,t.cursor(c,r?-1:1)}var Ee=e=>L(e,t=>W(e.state,t,!B(e))),De=e=>L(e,t=>W(e.state,t,B(e)));function Oe(e,t){return L(e,n=>{if(!n.empty)return R(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var ke=e=>Oe(e,!1),Ae=e=>Oe(e,!0);function G(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(p.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 je(e,t){let n=G(e),{state:r}=e,i=F(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):R(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=p.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(I(r,i),{effects:a}),!0}var Me=e=>je(e,!1),K=e=>je(e,!0);function q(e,n,r){let i=e.lineBlockAt(n.head),a=e.moveToLineBoundary(n,r);if(a.head==n.head&&a.head!=(r?i.to:i.from)&&(a=e.moveToLineBoundary(n,r,!1)),!r&&a.head==i.from&&i.length){let r=/^\s*/.exec(e.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&n.head!=i.from+r&&(a=t.cursor(i.from+r))}return a}var Ne=e=>L(e,t=>q(e,t,!0)),Pe=e=>L(e,t=>q(e,t,!1)),Fe=e=>L(e,t=>q(e,t,!B(e))),Ie=e=>L(e,t=>q(e,t,B(e))),Le=e=>L(e,n=>t.cursor(e.lineBlockAt(n.head).from,1)),Re=e=>L(e,n=>t.cursor(e.lineBlockAt(n.head).to,-1));function ze(e,n,r){let i=!1,a=F(e.selection,n=>{let a=_(e,n.head,-1)||_(e,n.head,1)||n.head>0&&_(e,n.head-1,1)||n.head<e.doc.length&&_(e,n.head+1,-1);if(!a||!a.end)return n;i=!0;let o=a.start.from==n.head?a.end.to:a.end.from;return r?t.range(n.anchor,o):t.cursor(o)});return i?(n(I(e,a)),!0):!1}var Be=({state:e,dispatch:t})=>ze(e,t,!1);function J(e,n){let r=F(e.state.selection,e=>{let r=n(e);return t.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return r.eq(e.state.selection)?!1:(e.dispatch(I(e.state,r)),!0)}function Ve(e,t){return J(e,n=>e.moveByChar(n,t))}var He=e=>Ve(e,!B(e)),Ue=e=>Ve(e,B(e));function We(e,t){return J(e,n=>e.moveByGroup(n,t))}var Ge=e=>We(e,!B(e)),Ke=e=>We(e,B(e)),qe=e=>J(e,t=>W(e.state,t,!B(e))),Je=e=>J(e,t=>W(e.state,t,B(e)));function Ye(e,t){return J(e,n=>e.moveVertically(n,t))}var Xe=e=>Ye(e,!1),Ze=e=>Ye(e,!0);function Qe(e,t){return J(e,n=>e.moveVertically(n,t,G(e).height))}var $e=e=>Qe(e,!1),et=e=>Qe(e,!0),tt=e=>J(e,t=>q(e,t,!0)),nt=e=>J(e,t=>q(e,t,!1)),rt=e=>J(e,t=>q(e,t,!B(e))),it=e=>J(e,t=>q(e,t,B(e))),at=e=>J(e,n=>t.cursor(e.lineBlockAt(n.head).from)),ot=e=>J(e,n=>t.cursor(e.lineBlockAt(n.head).to)),st=({state:e,dispatch:t})=>(t(I(e,{anchor:0})),!0),ct=({state:e,dispatch:t})=>(t(I(e,{anchor:e.doc.length})),!0),lt=({state:e,dispatch:t})=>(t(I(e,{anchor:e.selection.main.anchor,head:0})),!0),ut=({state:e,dispatch:t})=>(t(I(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),dt=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),ft=({state:e,dispatch:n})=>{let r=Q(e).map(({from:n,to:r})=>t.range(n,Math.min(r+1,e.doc.length)));return n(e.update({selection:t.create(r),userEvent:`select`})),!0},pt=({state:e,dispatch:n})=>{let r=F(e.selection,n=>{let r=h(e),i=r.resolveStack(n.from,1);if(n.empty){let e=r.resolveStack(n.from,-1);e.node.from>=i.node.from&&e.node.to<=i.node.to&&(i=e)}for(let e=i;e;e=e.next){let{node:r}=e;if((r.from<n.from&&r.to>=n.to||r.to>n.to&&r.from<=n.from)&&e.next)return t.range(r.to,r.from)}return n});return r.eq(e.selection)?!1:(n(I(e,r)),!0)};function mt(e,n){let{state:r}=e,i=r.selection,a=r.selection.ranges.slice();for(let t of r.selection.ranges){let i=r.doc.lineAt(t.head);if(n?i.to<e.state.doc.length:i.from>0)for(let r=t;;){let t=e.moveVertically(r,n);if(t.head<i.from||t.head>i.to){a.some(e=>e.head==t.head)||a.push(t);break}else if(t.head==r.head)break;else r=t}}return a.length==i.ranges.length?!1:(e.dispatch(I(r,t.create(a,a.length-1))),!0)}var ht=e=>mt(e,!1),gt=e=>mt(e,!0),_t=({state:e,dispatch:n})=>{let r=e.selection,i=null;return r.ranges.length>1?i=t.create([r.main]):r.main.empty||(i=t.create([t.cursor(r.main.head)])),i?(n(I(e,i)),!0):!1};function Y(e,n){if(e.state.readOnly)return!1;let r=`delete.selection`,{state:i}=e,a=i.changeByRange(i=>{let{from:a,to:o}=i;if(a==o){let t=n(i);t<a?(r=`delete.backward`,t=X(e,t,!1)):t>a&&(r=`delete.forward`,t=X(e,t,!0)),a=Math.min(a,t),o=Math.max(o,t)}else a=X(e,a,!1),o=X(e,o,!0);return a==o?{range:i}:{changes:{from:a,to:o},range:t.cursor(a,a<i.head?-1:1)}});return a.changes.empty?!1:(e.dispatch(i.update(a,{scrollIntoView:!0,userEvent:r,effects:r==`delete.selection`?p.announce.of(i.phrase(`Selection deleted`)):void 0})),!0)}function X(e,t,n){if(e instanceof p)for(let r of e.state.facet(p.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var vt=(t,r,i)=>Y(t,a=>{let o=a.from,{state:s}=t,c=s.doc.lineAt(o),l,u;if(i&&!r&&o>c.from&&o<c.from+200&&!/[^ \t]/.test(l=c.text.slice(0,o-c.from))){if(l[l.length-1]==` `)return o-1;let e=n(l,s.tabSize)%g(s)||g(s);for(let t=0;t<e&&l[l.length-1-t]==` `;t++)o--;u=o}else u=e(c.text,o-c.from,r,r)+c.from,u==o&&c.number!=(r?s.doc.lines:1)?u+=r?1:-1:!r&&/[\ufe00-\ufe0f]/.test(c.text.slice(u-c.from,o-c.from))&&(u=e(c.text,u-c.from,!1,!1)+c.from);return u}),Z=e=>vt(e,!1,!0),yt=e=>vt(e,!0,!1),bt=(t,n)=>Y(t,r=>{let i=r.head,{state:a}=t,o=a.doc.lineAt(i),s=a.charCategorizer(i);for(let t=null;;){if(i==(n?o.to:o.from)){i==r.head&&o.number!=(n?a.doc.lines:1)&&(i+=n?1:-1);break}let c=e(o.text,i-o.from,n)+o.from,l=o.text.slice(Math.min(i,c)-o.from,Math.max(i,c)-o.from),u=s(l);if(t!=null&&u!=t)break;(l!=` `||i!=r.head)&&(t=u),i=c}return i}),xt=e=>bt(e,!1),St=e=>bt(e,!0),Ct=e=>Y(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),wt=e=>Y(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Tt=e=>Y(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Et=({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:i.of([``,``])},range:t.cursor(e.from)}));return n(e.update(r,{scrollIntoView:!0,userEvent:`input`})),!0},Dt=({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=n.changeByRange(r=>{if(!r.empty||r.from==0||r.from==n.doc.length)return{range:r};let i=r.from,a=n.doc.lineAt(i),o=i==a.from?i-1:e(a.text,i-a.from,!1)+a.from,s=i==a.to?i+1:e(a.text,i-a.from,!0)+a.from;return{changes:{from:o,to:s,insert:n.doc.slice(i,s).append(n.doc.slice(o,i))},range:t.cursor(s)}});return i.changes.empty?!1:(r(n.update(i,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Q(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 Ot(e,n,r){if(e.readOnly)return!1;let i=[],a=[];for(let n of Q(e)){if(r?n.to==e.doc.length:n.from==0)continue;let o=e.doc.lineAt(r?n.to+1:n.from-1),s=o.length+1;if(r){i.push({from:n.to,to:o.to},{from:n.from,insert:o.text+e.lineBreak});for(let r of n.ranges)a.push(t.range(Math.min(e.doc.length,r.anchor+s),Math.min(e.doc.length,r.head+s)))}else{i.push({from:o.from,to:n.from},{from:n.to,insert:e.lineBreak+o.text});for(let e of n.ranges)a.push(t.range(e.anchor-s,e.head-s))}}return i.length?(n(e.update({changes:i,scrollIntoView:!0,selection:t.create(a,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var kt=({state:e,dispatch:t})=>Ot(e,t,!1),At=({state:e,dispatch:t})=>Ot(e,t,!0);function jt(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Q(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 Mt=({state:e,dispatch:t})=>jt(e,t,!1),Nt=({state:e,dispatch:t})=>jt(e,t,!0),Pt=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Q(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=F(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 Ft(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=h(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(b.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 It=Rt(!1),Lt=Rt(!0);function Rt(e){return({state:r,dispatch:a})=>{if(r.readOnly)return!1;let o=r.changeByRange(a=>{let{from:o,to:s}=a,c=r.doc.lineAt(o),l=!e&&o==s&&Ft(r,o);e&&(o=s=(s<=c.to?c:r.doc.lineAt(s)).to);let u=new v(r,{simulateBreak:o,simulateDoubleBreak:!!l}),d=y(u,o);for(d??=n(/^\s*/.exec(r.doc.lineAt(o).text)[0],r.tabSize);s<c.to&&/\s/.test(c.text[s-c.from]);)s++;l?{from:o,to:s}=l:o>c.from&&o<c.from+100&&!/\S/.test(c.text.slice(0,o))&&(o=c.from);let f=[``,m(r,d)];return l&&f.push(m(r,u.lineIndent(c.from,-1))),{changes:{from:o,to:s,insert:i.of(f)},range:t.cursor(o+1+f[1].length)}});return a(r.update(o,{scrollIntoView:!0,userEvent:`input`})),!0}}function $(e,n){let r=-1;return e.changeByRange(i=>{let a=[];for(let t=i.from;t<=i.to;){let o=e.doc.lineAt(t);o.number>r&&(i.empty||i.to>o.from)&&(n(o,a,i),r=o.number),t=o.to+1}let o=e.changes(a);return{changes:a,range:t.range(o.mapPos(i.anchor,1),o.mapPos(i.head,1))}})}var zt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new v(e,{overrideIndentation:e=>n[e]??-1}),i=$(e,(t,i,a)=>{let o=y(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=m(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},Bt=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update($(e,(t,n)=>{n.push({from:t.from,insert:e.facet(ee)})}),{userEvent:`input.indent`})),!0),Vt=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update($(e,(t,r)=>{let i=/^\s*/.exec(t.text)[0];if(!i)return;let a=n(i,e.tabSize),o=0,s=m(e,Math.max(0,a-g(e)));for(;o<i.length&&o<s.length&&i.charCodeAt(o)==s.charCodeAt(o);)o++;r.push({from:t.from+o,to:t.from+i.length,insert:s.slice(o)})}),{userEvent:`delete.dedent`})),!0),Ht=e=>(e.setTabFocusMode(),!0),Ut=[{key:`Ctrl-b`,run:V,shift:He,preventDefault:!0},{key:`Ctrl-f`,run:H,shift:Ue},{key:`Ctrl-p`,run:ke,shift:Xe},{key:`Ctrl-n`,run:Ae,shift:Ze},{key:`Ctrl-a`,run:Le,shift:at},{key:`Ctrl-e`,run:Re,shift:ot},{key:`Ctrl-d`,run:yt},{key:`Ctrl-h`,run:Z},{key:`Ctrl-k`,run:Ct},{key:`Ctrl-Alt-h`,run:xt},{key:`Ctrl-o`,run:Et},{key:`Ctrl-t`,run:Dt},{key:`Ctrl-v`,run:K}],Wt=[{key:`ArrowLeft`,run:V,shift:He,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Ce,shift:Ge,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Fe,shift:rt,preventDefault:!0},{key:`ArrowRight`,run:H,shift:Ue,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:we,shift:Ke,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Ie,shift:it,preventDefault:!0},{key:`ArrowUp`,run:ke,shift:Xe,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:st,shift:lt},{mac:`Ctrl-ArrowUp`,run:Me,shift:$e},{key:`ArrowDown`,run:Ae,shift:Ze,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:ct,shift:ut},{mac:`Ctrl-ArrowDown`,run:K,shift:et},{key:`PageUp`,run:Me,shift:$e},{key:`PageDown`,run:K,shift:et},{key:`Home`,run:Pe,shift:nt,preventDefault:!0},{key:`Mod-Home`,run:st,shift:lt},{key:`End`,run:Ne,shift:tt,preventDefault:!0},{key:`Mod-End`,run:ct,shift:ut},{key:`Enter`,run:It,shift:It},{key:`Mod-a`,run:dt},{key:`Backspace`,run:Z,shift:Z,preventDefault:!0},{key:`Delete`,run:yt,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:xt,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:St,preventDefault:!0},{mac:`Mod-Backspace`,run:wt,preventDefault:!0},{mac:`Mod-Delete`,run:Tt,preventDefault:!0}].concat(Ut.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Gt=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Ee,shift:qe},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:De,shift:Je},{key:`Alt-ArrowUp`,run:kt},{key:`Shift-Alt-ArrowUp`,run:Mt},{key:`Alt-ArrowDown`,run:At},{key:`Shift-Alt-ArrowDown`,run:Nt},{key:`Mod-Alt-ArrowUp`,run:ht},{key:`Mod-Alt-ArrowDown`,run:gt},{key:`Escape`,run:_t},{key:`Mod-Enter`,run:Lt},{key:`Alt-l`,mac:`Ctrl-l`,run:ft},{key:`Mod-i`,run:pt,preventDefault:!0},{key:`Mod-[`,run:Vt},{key:`Mod-]`,run:Bt},{key:`Mod-Alt-\\`,run:zt},{key:`Shift-Mod-k`,run:Pt},{key:`Shift-Mod-\\`,run:Be},{key:`Mod-/`,run:te},{key:`Alt-A`,run:re},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Ht}].concat(Wt);export{Gt as defaultKeymap,fe as history,Se as historyKeymap};