p3x-redis-ui-material
Version:
💿 The p3x-redis-ui-material web interface that connects to the p3x-redis-ui-server via http and socket.io
1 lines • 23.1 kB
JavaScript
;(self.webpackChunkp3x_redis_ui_material=self.webpackChunkp3x_redis_ui_material||[]).push([[3180],{380(e,t,n){n.d(t,{defaultKeymap:()=>Ve,history:()=>A,historyKeymap:()=>R});var r=n(41762),o=n(43599),l=n(22828),s=n(80919);function i(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let o=e(t,n);return!!o&&(r(n.update(o)),!0)}}const a=i(m,0),c=i(h,0),f=i(((e,t)=>h(e,t,function(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),o=n.to<=r.to?r:e.doc.lineAt(n.to);o.from>r.from&&o.from==n.to&&(o=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let l=t.length-1;l>=0&&t[l].to>r.from?t[l].to=o.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:o.to})}return t}(t))),0);function u(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}function h(e,t,n=t.selection.ranges){let r=n.map((e=>u(t,e.from).block));if(!r.every((e=>e)))return null;let o=n.map(((e,n)=>function(e,{open:t,close:n},r,o){let l,s,i=e.sliceDoc(r-50,r),a=e.sliceDoc(o,o+50),c=/\s*$/.exec(i)[0].length,f=/^\s*/.exec(a)[0].length,u=i.length-c;if(i.slice(u-t.length,u)==t&&a.slice(f,f+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:o+f,margin:f&&1}};o-r<=100?l=s=e.sliceDoc(r,o):(l=e.sliceDoc(r,r+50),s=e.sliceDoc(o-50,o));let h=/^\s*/.exec(l)[0].length,m=/\s*$/.exec(s)[0].length,d=s.length-m-n.length;return l.slice(h,h+t.length)==t&&s.slice(d,d+n.length)==n?{open:{pos:r+h+t.length,margin:/\s/.test(l.charAt(h+t.length))?1:0},close:{pos:o-m-n.length,margin:/\s/.test(s.charAt(d-1))?1:0}}:null}(t,r[n],e.from,e.to)));if(2!=e&&!o.every((e=>e)))return{changes:t.changes(n.map(((e,t)=>o[t]?[]:[{from:e.from,insert:r[t].open+" "},{from:e.to,insert:" "+r[t].close}])))};if(1!=e&&o.some((e=>e))){let e=[];for(let t,n=0;n<o.length;n++)if(t=o[n]){let o=r[n],{open:l,close:s}=t;e.push({from:l.pos-o.open.length,to:l.pos+l.margin},{from:s.pos-s.margin,to:s.pos+o.close.length})}return{changes:e}}return null}function m(e,t,n=t.selection.ranges){let r=[],o=-1;e:for(let{from:e,to:l}of n){let n,s=r.length,i=1e9;for(let s=e;s<=l;){let a=t.doc.lineAt(s);if(null==n&&(n=u(t,a.from).line,!n))continue e;if(a.from>o&&(e==l||l>a.from)){o=a.from;let e=/^\s*/.exec(a.text)[0].length,t=e==a.length,l=a.text.slice(e,e+n.length)==n?e:-1;e<a.text.length&&e<i&&(i=e),r.push({line:a,comment:l,token:n,indent:e,empty:t,single:!1})}s=a.to+1}if(i<1e9)for(let e=s;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=i);r.length==s+1&&(r[s].single=!0)}if(2!=e&&r.some((e=>e.comment<0&&(!e.empty||e.single)))){let e=[];for(let{line:t,token:n,indent:o,empty:l,single:s}of r)!s&&l||e.push({from:t.from+o,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&r.some((e=>e.comment>=0))){let e=[];for(let{line:t,comment:n,token:o}of r)if(n>=0){let r=t.from+n,l=r+o.length;" "==t.text[l-t.from]&&l++,e.push({from:r,to:l})}return{changes:e}}return null}const d=r.YH.define(),p=r.YH.define(),g=r.sj.define(),y=r.sj.define({combine:e=>(0,r.QR)(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)})}),v=r.sU.define({create:()=>I.empty,update(e,t){let n=t.state.facet(y),o=t.annotation(d);if(o){let r=M.fromTransaction(t,o.selection),l=o.side,s=0==l?e.undone:e.done;return s=r?x(s,s.length,n.minDepth,r):C(s,t.startState.selection),new I(0==l?o.rest:s,0==l?s:o.rest)}let l=t.annotation(p);if("full"!=l&&"before"!=l||(e=e.isolate()),!1===t.annotation(r.ZX.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let s=M.fromTransaction(t),i=t.annotation(r.ZX.time),a=t.annotation(r.ZX.userEvent);return s?e=e.addChanges(s,i,a,n,t):t.selection&&(e=e.addSelection(t.startState.selection,i,a,n.newGroupDelay)),"full"!=l&&"after"!=l||(e=e.isolate()),e},toJSON:e=>({done:e.done.map((e=>e.toJSON())),undone:e.undone.map((e=>e.toJSON()))}),fromJSON:e=>new I(e.done.map(M.fromJSON),e.undone.map(M.fromJSON))});function A(e={}){return[v,y.of(e),o.EditorView.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?w:"historyRedo"==e.inputType?D:null;return!!n&&(e.preventDefault(),n(t))}})]}function k(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let o=n.field(v,!1);if(!o)return!1;let l=o.pop(e,n,t);return!!l&&(r(l),!0)}}const w=k(0,!1),D=k(1,!1),O=k(0,!0),S=k(1,!0);class M{constructor(e,t,n,r,o){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=o}setSelAfter(e){return new M(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map((e=>e.toJSON()))}}static fromJSON(e){return new M(e.changes&&r.VR.fromJSON(e.changes),[],e.mapped&&r.Gu.fromJSON(e.mapped),e.startSelection&&r.OF.fromJSON(e.startSelection),e.selectionsAfter.map(r.OF.fromJSON))}static fromTransaction(e,t){let n=B;for(let t of e.startState.facet(g)){let r=t(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new M(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,B)}static selection(e){return new M(void 0,B,void 0,void 0,e)}}function x(e,t,n,r){let o=t+1>n+20?t-n-1:0,l=e.slice(o,t);return l.push(r),l}function E(e,t){return e.length?t.length?e.concat(t):e:t}const B=[];function C(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),x(e,e.length-1,1e9,n.setSelAfter(r)))}return[M.selection([t])]}function b(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 F(e,t){if(!e.length)return e;let n=e.length,r=B;for(;n;){let o=T(e[n-1],t,r);if(o.changes&&!o.changes.empty||o.effects.length){let t=e.slice(0,n);return t[n-1]=o,t}t=o.mapped,n--,r=o.selectionsAfter}return r.length?[M.selection(r)]:B}function T(e,t,n){let o=E(e.selectionsAfter.length?e.selectionsAfter.map((e=>e.map(t))):B,n);if(!e.changes)return M.selection(o);let l=e.changes.map(t),s=t.mapDesc(e.changes,!0),i=e.mapped?e.mapped.composeDesc(s):s;return new M(l,r.Pe.mapEffects(e.effects,t),i,e.startSelection.map(s),o)}const V=/^(input\.type|delete)($|\.)/;class I{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 I(this.done,this.undone):this}addChanges(e,t,n,o,l){let s=this.done,i=s[s.length-1];return s=i&&i.changes&&!i.changes.empty&&e.changes&&(!n||V.test(n))&&(!i.selectionsAfter.length&&t-this.prevTime<o.newGroupDelay&&o.joinToEvent(l,function(e,t){let n=[],r=!1;return e.iterChangedRanges(((e,t)=>n.push(e,t))),t.iterChangedRanges(((e,t,o,l)=>{for(let e=0;e<n.length;){let t=n[e++],s=n[e++];l>=t&&o<=s&&(r=!0)}})),r}(i.changes,e.changes))||"input.type.compose"==n)?x(s,s.length-1,o.minDepth,new M(e.changes.compose(i.changes),E(r.Pe.mapEffects(e.effects,i.changes),i.effects),i.mapped,i.startSelection,B)):x(s,s.length,o.minDepth,e),new I(s,B,t,n)}addSelection(e,t,n,r){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:B;return o.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(l=o[o.length-1],s=e,l.ranges.length==s.ranges.length&&0===l.ranges.filter(((e,t)=>e.empty!=s.ranges[t].empty)).length)?this:new I(C(this.done,e),this.undone,t,n);var l,s}addMapping(e){return new I(F(this.done,e),F(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=0==e?this.done:this.undone;if(0==r.length)return null;let o=r[r.length-1],l=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):t.selection);if(n&&o.selectionsAfter.length)return t.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:d.of({side:e,rest:b(r),selection:l}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let n=1==r.length?B:r.slice(0,r.length-1);return o.mapped&&(n=F(n,o.mapped)),t.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:d.of({side:e,rest:n,selection:l}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}I.empty=new I(B,B);const R=[{key:"Mod-z",run:w,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:O,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:S,preventDefault:!0}];function U(e,t){return r.OF.create(e.ranges.map(t),e.mainIndex)}function J(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function N({state:e,dispatch:t},n){let r=U(e.selection,n);return!r.eq(e.selection,!0)&&(t(J(e,r)),!0)}function L(e,t){return r.OF.cursor(t?e.to:e.from)}function j(e,t){return N(e,(n=>n.empty?e.moveByChar(n,t):L(n,t)))}function z(e){return e.textDirectionAt(e.state.selection.main.head)==o.OP.LTR}const H=e=>j(e,!z(e)),K=e=>j(e,z(e));function P(e,t){return N(e,(n=>n.empty?e.moveByGroup(n,t):L(n,t)))}"undefined"!=typeof Intl&&Intl.Segmenter;function _(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 G(e,t,n){let o,i,a=(0,l.mv)(e).resolveInner(t.head),c=n?s.uY.closedBy:s.uY.openedBy;for(let r=t.head;;){let t=n?a.childAfter(r):a.childBefore(r);if(!t)break;_(e,t,c)?a=t:r=n?t.to:t.from}return i=a.type.prop(c)&&(o=n?(0,l.jU)(e,a.from,1):(0,l.jU)(e,a.to,-1))&&o.matched?n?o.end.to:o.end.from:n?a.to:a.from,r.OF.cursor(i,n?-1:1)}function Y(e,t){return N(e,(n=>{if(!n.empty)return L(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)}))}const $=e=>Y(e,!1),q=e=>Y(e,!0);function X(e){let t,n=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,l=0;if(n){for(let t of e.state.facet(o.EditorView.scrollMargins)){let n=t(e);(null==n?void 0:n.top)&&(r=Math.max(null==n?void 0:n.top,r)),(null==n?void 0:n.bottom)&&(l=Math.max(null==n?void 0:n.bottom,l))}t=e.scrollDOM.clientHeight-r-l}else t=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:l,selfScroll:n,height:Math.max(e.defaultLineHeight,t-5)}}function Z(e,t){let n,r=X(e),{state:l}=e,s=U(l.selection,(n=>n.empty?e.moveVertically(n,t,r.height):L(n,t)));if(s.eq(l.selection))return!1;if(r.selfScroll){let t=e.coordsAtPos(l.selection.main.head),i=e.scrollDOM.getBoundingClientRect(),a=i.top+r.marginTop,c=i.bottom-r.marginBottom;t&&t.top>a&&t.bottom<c&&(n=o.EditorView.scrollIntoView(s.main.head,{y:"start",yMargin:t.top-a}))}return e.dispatch(J(l,s),{effects:n}),!0}const Q=e=>Z(e,!1),W=e=>Z(e,!0);function ee(e,t,n){let o=e.lineBlockAt(t.head),l=e.moveToLineBoundary(t,n);if(l.head==t.head&&l.head!=(n?o.to:o.from)&&(l=e.moveToLineBoundary(t,n,!1)),!n&&l.head==o.from&&o.length){let n=/^\s*/.exec(e.state.sliceDoc(o.from,Math.min(o.from+100,o.to)))[0].length;n&&t.head!=o.from+n&&(l=r.OF.cursor(o.from+n))}return l}function te(e,t,n){let o=!1,s=U(e.selection,(t=>{let s=(0,l.jU)(e,t.head,-1)||(0,l.jU)(e,t.head,1)||t.head>0&&(0,l.jU)(e,t.head-1,1)||t.head<e.doc.length&&(0,l.jU)(e,t.head+1,-1);if(!s||!s.end)return t;o=!0;let i=s.start.from==t.head?s.end.to:s.end.from;return n?r.OF.range(t.anchor,i):r.OF.cursor(i)}));return!!o&&(t(J(e,s)),!0)}function ne(e,t){let n=U(e.state.selection,(e=>{let n=t(e);return r.OF.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)}));return!n.eq(e.state.selection)&&(e.dispatch(J(e.state,n)),!0)}function re(e,t){return ne(e,(n=>e.moveByChar(n,t)))}const oe=e=>re(e,!z(e)),le=e=>re(e,z(e));function se(e,t){return ne(e,(n=>e.moveByGroup(n,t)))}function ie(e,t){return ne(e,(n=>e.moveVertically(n,t)))}const ae=e=>ie(e,!1),ce=e=>ie(e,!0);function fe(e,t){return ne(e,(n=>e.moveVertically(n,t,X(e).height)))}const ue=e=>fe(e,!1),he=e=>fe(e,!0),me=({state:e,dispatch:t})=>(t(J(e,{anchor:0})),!0),de=({state:e,dispatch:t})=>(t(J(e,{anchor:e.doc.length})),!0),pe=({state:e,dispatch:t})=>(t(J(e,{anchor:e.selection.main.anchor,head:0})),!0),ge=({state:e,dispatch:t})=>(t(J(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function ye(e,t){let{state:n}=e,o=n.selection,l=n.selection.ranges.slice();for(let r of n.selection.ranges){let o=n.doc.lineAt(r.head);if(t?o.to<e.state.doc.length:o.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<o.from||r.head>o.to){l.some((e=>e.head==r.head))||l.push(r);break}if(r.head==n.head)break;n=r}}return l.length!=o.ranges.length&&(e.dispatch(J(n,r.OF.create(l,l.length-1))),!0)}function ve(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:l}=e,s=l.changeByRange((o=>{let{from:l,to:s}=o;if(l==s){let r=t(o);r<l?(n="delete.backward",r=Ae(e,r,!1)):r>l&&(n="delete.forward",r=Ae(e,r,!0)),l=Math.min(l,r),s=Math.max(s,r)}else l=Ae(e,l,!1),s=Ae(e,s,!0);return l==s?{range:o}:{changes:{from:l,to:s},range:r.OF.cursor(l,l<o.head?-1:1)}}));return!s.changes.empty&&(e.dispatch(l.update(s,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?o.EditorView.announce.of(l.phrase("Selection deleted")):void 0})),!0)}function Ae(e,t,n){if(e instanceof o.EditorView)for(let r of e.state.facet(o.EditorView.atomicRanges).map((t=>t(e))))r.between(t,t,((e,r)=>{e<t&&r>t&&(t=n?r:e)}));return t}const ke=(e,t,n)=>ve(e,(o=>{let s,i,a=o.from,{state:c}=e,f=c.doc.lineAt(a);if(n&&!t&&a>f.from&&a<f.from+200&&!/[^ \t]/.test(s=f.text.slice(0,a-f.from))){if("\t"==s[s.length-1])return a-1;let e=(0,r.y$)(s,c.tabSize)%(0,l.tp)(c)||(0,l.tp)(c);for(let t=0;t<e&&" "==s[s.length-1-t];t++)a--;i=a}else i=(0,r.zK)(f.text,a-f.from,t,t)+f.from,i==a&&f.number!=(t?c.doc.lines:1)?i+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(f.text.slice(i-f.from,a-f.from))&&(i=(0,r.zK)(f.text,i-f.from,!1,!1)+f.from);return i})),we=e=>ke(e,!1,!0),De=e=>ke(e,!0,!1),Oe=(e,t)=>ve(e,(n=>{let o=n.head,{state:l}=e,s=l.doc.lineAt(o),i=l.charCategorizer(o);for(let e=null;;){if(o==(t?s.to:s.from)){o==n.head&&s.number!=(t?l.doc.lines:1)&&(o+=t?1:-1);break}let a=(0,r.zK)(s.text,o-s.from,t)+s.from,c=s.text.slice(Math.min(o,a)-s.from,Math.max(o,a)-s.from),f=i(c);if(null!=e&&f!=e)break;" "==c&&o==n.head||(e=f),o=a}return o})),Se=e=>Oe(e,!1);function Me(e){let t=[],n=-1;for(let r of e.selection.ranges){let o=e.doc.lineAt(r.from),l=e.doc.lineAt(r.to);if(r.empty||r.to!=l.from||(l=e.doc.lineAt(r.to-1)),n>=o.number){let e=t[t.length-1];e.to=l.to,e.ranges.push(r)}else t.push({from:o.from,to:l.to,ranges:[r]});n=l.number+1}return t}function xe(e,t,n){if(e.readOnly)return!1;let o=[],l=[];for(let t of Me(e)){if(n?t.to==e.doc.length:0==t.from)continue;let s=e.doc.lineAt(n?t.to+1:t.from-1),i=s.length+1;if(n){o.push({from:t.to,to:s.to},{from:t.from,insert:s.text+e.lineBreak});for(let n of t.ranges)l.push(r.OF.range(Math.min(e.doc.length,n.anchor+i),Math.min(e.doc.length,n.head+i)))}else{o.push({from:s.from,to:t.from},{from:t.to,insert:e.lineBreak+s.text});for(let e of t.ranges)l.push(r.OF.range(e.anchor-i,e.head-i))}}return!!o.length&&(t(e.update({changes:o,scrollIntoView:!0,selection:r.OF.create(l,e.selection.mainIndex),userEvent:"move.line"})),!0)}function Ee(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Me(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 o=e.changes(r);return t(e.update({changes:o,selection:e.selection.map(o,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Be=Ce(!1);function Ce(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let o=t.changeByRange((n=>{let{from:o,to:i}=n,a=t.doc.lineAt(o),c=!e&&o==i&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n,r=(0,l.mv)(e).resolveInner(t),o=r.childBefore(t),i=r.childAfter(t);return o&&i&&o.to<=t&&i.from>=t&&(n=o.type.prop(s.uY.closedBy))&&n.indexOf(i.name)>-1&&e.doc.lineAt(o.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(o.to,i.from))?{from:o.to,to:i.from}:null}(t,o);e&&(o=i=(i<=a.to?a:t.doc.lineAt(i)).to);let f=new l.KB(t,{simulateBreak:o,simulateDoubleBreak:!!c}),u=(0,l._v)(f,o);for(null==u&&(u=(0,r.y$)(/^\s*/.exec(t.doc.lineAt(o).text)[0],t.tabSize));i<a.to&&/\s/.test(a.text[i-a.from]);)i++;c?({from:o,to:i}=c):o>a.from&&o<a.from+100&&!/\S/.test(a.text.slice(0,o))&&(o=a.from);let h=["",(0,l.EI)(t,u)];return c&&h.push((0,l.EI)(t,f.lineIndent(a.from,-1))),{changes:{from:o,to:i,insert:r.EY.of(h)},range:r.OF.cursor(o+1+h[1].length)}}));return n(t.update(o,{scrollIntoView:!0,userEvent:"input"})),!0}}function be(e,t){let n=-1;return e.changeByRange((o=>{let l=[];for(let r=o.from;r<=o.to;){let s=e.doc.lineAt(r);s.number>n&&(o.empty||o.to>s.from)&&(t(s,l,o),n=s.number),r=s.to+1}let s=e.changes(l);return{changes:l,range:r.OF.range(s.mapPos(o.anchor,1),s.mapPos(o.head,1))}}))}const Fe=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(be(e,((t,n)=>{n.push({from:t.from,insert:e.facet(l.Xt)})})),{userEvent:"input.indent"})),!0),Te=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(be(e,((t,n)=>{let o=/^\s*/.exec(t.text)[0];if(!o)return;let s=(0,r.y$)(o,e.tabSize),i=0,a=(0,l.EI)(e,Math.max(0,s-(0,l.tp)(e)));for(;i<o.length&&i<a.length&&o.charCodeAt(i)==a.charCodeAt(i);)i++;n.push({from:t.from+i,to:t.from+o.length,insert:a.slice(i)})})),{userEvent:"delete.dedent"})),!0),Ve=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>N(e,(t=>G(e.state,t,!z(e)))),shift:e=>ne(e,(t=>G(e.state,t,!z(e))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>N(e,(t=>G(e.state,t,z(e)))),shift:e=>ne(e,(t=>G(e.state,t,z(e))))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>xe(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>Ee(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>xe(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>Ee(e,t,!0)},{key:"Mod-Alt-ArrowUp",run:e=>ye(e,!1)},{key:"Mod-Alt-ArrowDown",run:e=>ye(e,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,o=null;return n.ranges.length>1?o=r.OF.create([n.main]):n.main.empty||(o=r.OF.create([r.OF.cursor(n.main.head)])),!!o&&(t(J(e,o)),!0)}},{key:"Mod-Enter",run:Ce(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=Me(e).map((({from:t,to:n})=>r.OF.range(t,Math.min(n+1,e.doc.length))));return t(e.update({selection:r.OF.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=U(e.selection,(t=>{let n=(0,l.mv)(e),o=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=o.node.from&&e.node.to<=o.node.to&&(o=e)}for(let e=o;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 r.OF.range(n.to,n.from)}return t}));return!n.eq(e.selection)&&(t(J(e,n)),!0)},preventDefault:!0},{key:"Mod-[",run:Te},{key:"Mod-]",run:Fe},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new l.KB(e,{overrideIndentation:e=>{let t=n[e];return t??-1}}),o=be(e,((t,o,s)=>{let i=(0,l._v)(r,t.from);if(null==i)return;/\S/.test(t.text)||(i=0);let a=/^\s*/.exec(t.text)[0],c=(0,l.EI)(e,i);(a!=c||s.from<t.from+a.length)&&(n[t.from]=i,o.push({from:t.from,to:t.from+a.length,insert:c}))}));return o.changes.empty||t(e.update(o,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Me(t).map((({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n})))),r=U(t.selection,(t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),o=e.coordsAtPos(t.head,t.assoc||1);o&&(n=r.bottom+e.documentTop-o.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}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>te(e,t,!1)},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=u(e.state,n.from);return r.line?a(e):!!r.block&&f(e)}},{key:"Alt-A",run:c},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:H,shift:oe,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>P(e,!z(e)),shift:e=>se(e,!z(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>N(e,(t=>ee(e,t,!z(e)))),shift:e=>ne(e,(t=>ee(e,t,!z(e)))),preventDefault:!0},{key:"ArrowRight",run:K,shift:le,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>P(e,z(e)),shift:e=>se(e,z(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>N(e,(t=>ee(e,t,z(e)))),shift:e=>ne(e,(t=>ee(e,t,z(e)))),preventDefault:!0},{key:"ArrowUp",run:$,shift:ae,preventDefault:!0},{mac:"Cmd-ArrowUp",run:me,shift:pe},{mac:"Ctrl-ArrowUp",run:Q,shift:ue},{key:"ArrowDown",run:q,shift:ce,preventDefault:!0},{mac:"Cmd-ArrowDown",run:de,shift:ge},{mac:"Ctrl-ArrowDown",run:W,shift:he},{key:"PageUp",run:Q,shift:ue},{key:"PageDown",run:W,shift:he},{key:"Home",run:e=>N(e,(t=>ee(e,t,!1))),shift:e=>ne(e,(t=>ee(e,t,!1))),preventDefault:!0},{key:"Mod-Home",run:me,shift:pe},{key:"End",run:e=>N(e,(t=>ee(e,t,!0))),shift:e=>ne(e,(t=>ee(e,t,!0))),preventDefault:!0},{key:"Mod-End",run:de,shift:ge},{key:"Enter",run:Be,shift:Be},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:we,shift:we,preventDefault:!0},{key:"Delete",run:De,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Se,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>Oe(e,!0),preventDefault:!0},{mac:"Mod-Backspace",run:e=>ve(e,(t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)})),preventDefault:!0},{mac:"Mod-Delete",run:e=>ve(e,(t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})),preventDefault:!0}].concat([{key:"Ctrl-b",run:H,shift:oe,preventDefault:!0},{key:"Ctrl-f",run:K,shift:le},{key:"Ctrl-p",run:$,shift:ae},{key:"Ctrl-n",run:q,shift:ce},{key:"Ctrl-a",run:e=>N(e,(t=>r.OF.cursor(e.lineBlockAt(t.head).from,1))),shift:e=>ne(e,(t=>r.OF.cursor(e.lineBlockAt(t.head).from)))},{key:"Ctrl-e",run:e=>N(e,(t=>r.OF.cursor(e.lineBlockAt(t.head).to,-1))),shift:e=>ne(e,(t=>r.OF.cursor(e.lineBlockAt(t.head).to)))},{key:"Ctrl-d",run:De},{key:"Ctrl-h",run:we},{key:"Ctrl-k",run:e=>ve(e,(t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}))},{key:"Ctrl-Alt-h",run:Se},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:r.EY.of(["",""])},range:r.OF.cursor(e.from)})));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,o=e.doc.lineAt(n),l=n==o.from?n-1:(0,r.zK)(o.text,n-o.from,!1)+o.from,s=n==o.to?n+1:(0,r.zK)(o.text,n-o.from,!0)+o.from;return{changes:{from:l,to:s,insert:e.doc.slice(n,s).append(e.doc.slice(l,n))},range:r.OF.cursor(s)}}));return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:W}].map((e=>({mac:e.key,run:e.run,shift:e.shift})))))}}]);