@i14ks/ccv 0.7.2 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/bundle/ccv.mjs +32 -12
  2. package/package.json +1 -1
  3. package/web/assets/{codemirror-CT_I9W8V.js → codemirror-CVvP6QQT.js} +1 -1
  4. package/web/assets/{index-orsieMzN.js → index-B0rzOjTL.js} +1 -1
  5. package/web/assets/{index-DK3fr1-H.js → index-B3dv9BC8.js} +1 -1
  6. package/web/assets/{index-C7BowCu_.js → index-B6uiazpS.js} +1 -1
  7. package/web/assets/{index-BsWsF3Fl.js → index-BLhSyH7z.js} +1 -1
  8. package/web/assets/{index-BXGO38V0.js → index-BanFfa7t.js} +1 -1
  9. package/web/assets/{index-BJxrsvYI.js → index-BqbJNxEr.js} +1 -1
  10. package/web/assets/{index-DZONC7G0.js → index-C8oP-mil.js} +1 -1
  11. package/web/assets/index-CLOINL5U.js +132 -0
  12. package/web/assets/{index-BfEIguB2.js → index-CY7q3Ck1.js} +1 -1
  13. package/web/assets/{index-NSr-7K-t.js → index-Cp0MuKrW.js} +1 -1
  14. package/web/assets/{index-C37A4Z6a.js → index-CtMm0L-o.js} +1 -1
  15. package/web/assets/{index-BUPafoiW.js → index-D0hI9vYs.js} +1 -1
  16. package/web/assets/{index-D6dXU68i.js → index-D7QJyPiW.js} +1 -1
  17. package/web/assets/{index-BypqjF8L.js → index-DA4Vv71z.js} +1 -1
  18. package/web/assets/index-DDcm1yfV.css +1 -0
  19. package/web/assets/{index-CGu7N9dH.js → index-DF-nqlZE.js} +1 -1
  20. package/web/assets/{index-BhbDxjJk.js → index-DPvZ-hhz.js} +1 -1
  21. package/web/assets/{index-C73L6h-_.js → index-DbdZObbo.js} +1 -1
  22. package/web/assets/{index-DQd5QKK5.js → index-DcacXtlQ.js} +1 -1
  23. package/web/assets/{index-BWCkRrtJ.js → index-DyhSCR-0.js} +1 -1
  24. package/web/assets/{index-Ds7Lfmpa.js → index-NKG2aix5.js} +1 -1
  25. package/web/index.html +2 -2
  26. package/web/assets/index-DecijLh5.css +0 -1
  27. package/web/assets/index-P6iAB9yV.js +0 -134
@@ -1 +1 @@
1
- import{EditorSelection as h,Text as ke,findClusterBreak as T,StateField as tt,Transaction as K,Facet as Ae,Annotation as Be,combineConfig as nt,StateEffect as Se,ChangeSet as rt,ChangeDesc as ot,countColumn as ee,CharCategory as D}from"./index-BHot-lnj.js";import{E as O,o as lt}from"./index-891wE-Rj.js";import{I as Ce,g as De,c as G,e as te,m as E,h as j,j as st}from"./index-BhbDxjJk.js";import{N as Q}from"./index-P6iAB9yV.js";const ct=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=ne(e.state,n.from);return r.line?it(e):r.block?ft(e):!1};function L(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let l=e(t,n);return l?(r(n.update(l)),!0):!1}}const it=L(re,0),An=L(re,1),Bn=L(re,2),ut=L(V,0),Sn=L(V,1),Cn=L(V,2),ft=L((e,t)=>V(e,t,ht(t)),0);function ne(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const v=50;function at(e,{open:t,close:n},r,l){let o=e.sliceDoc(r-v,r),s=e.sliceDoc(l,l+v),c=/\s*$/.exec(o)[0].length,i=/^\s*/.exec(s)[0].length,f=o.length-c;if(o.slice(f-t.length,f)==t&&s.slice(i,i+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:l+i,margin:i&&1}};let u,a;l-r<=2*v?u=a=e.sliceDoc(r,l):(u=e.sliceDoc(r,r+v),a=e.sliceDoc(l-v,l));let d=/^\s*/.exec(u)[0].length,B=/\s*$/.exec(a)[0].length,k=a.length-B-n.length;return u.slice(d,d+t.length)==t&&a.slice(k,k+n.length)==n?{open:{pos:r+d+t.length,margin:/\s/.test(u.charAt(d+t.length))?1:0},close:{pos:l-B-n.length,margin:/\s/.test(a.charAt(k-1))?1:0}}:null}function ht(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),l=n.to<=r.to?r:e.doc.lineAt(n.to);l.from>r.from&&l.from==n.to&&(l=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let o=t.length-1;o>=0&&t[o].to>r.from?t[o].to=l.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:l.to})}return t}function V(e,t,n=t.selection.ranges){let r=n.map(o=>ne(t,o.from).block);if(!r.every(o=>o))return null;let l=n.map((o,s)=>at(t,r[s],o.from,o.to));if(e!=2&&!l.every(o=>o))return{changes:t.changes(n.map((o,s)=>l[s]?[]:[{from:o.from,insert:r[s].open+" "},{from:o.to,insert:" "+r[s].close}]))};if(e!=1&&l.some(o=>o)){let o=[];for(let s=0,c;s<l.length;s++)if(c=l[s]){let i=r[s],{open:f,close:u}=c;o.push({from:f.pos-i.open.length,to:f.pos+f.margin},{from:u.pos-u.margin,to:u.pos+i.close.length})}return{changes:o}}return null}function re(e,t,n=t.selection.ranges){let r=[],l=-1;e:for(let{from:o,to:s}of n){let c=r.length,i=1e9,f;for(let u=o;u<=s;){let a=t.doc.lineAt(u);if(f==null&&(f=ne(t,a.from).line,!f))continue e;if(a.from>l&&(o==s||s>a.from)){l=a.from;let d=/^\s*/.exec(a.text)[0].length,B=d==a.length,k=a.text.slice(d,d+f.length)==f?d:-1;d<a.text.length&&d<i&&(i=d),r.push({line:a,comment:k,token:f,indent:d,empty:B,single:!1})}u=a.to+1}if(i<1e9)for(let u=c;u<r.length;u++)r[u].indent<r[u].line.text.length&&(r[u].indent=i);r.length==c+1&&(r[c].single=!0)}if(e!=2&&r.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:c,token:i,indent:f,empty:u,single:a}of r)(a||!u)&&o.push({from:c.from+f,insert:i+" "});let s=t.changes(o);return{changes:s,selection:t.selection.map(s,1)}}else if(e!=1&&r.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:c,token:i}of r)if(c>=0){let f=s.from+c,u=f+i.length;s.text[u-s.from]==" "&&u++,o.push({from:f,to:u})}return{changes:o}}return null}const X=Be.define(),dt=Be.define(),mt=Ae.define(),xe=Ae.define({combine(e){return nt(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,n)=>(r,l)=>t(r,l)||n(r,l)})}}),N=tt.define({create(){return C.empty},update(e,t){let n=t.state.facet(xe),r=t.annotation(X);if(r){let i=g.fromTransaction(t,r.selection),f=r.side,u=f==0?e.undone:e.done;return i?u=U(u,u.length,n.minDepth,i):u=Ee(u,t.startState.selection),new C(f==0?r.rest:u,f==0?u:r.rest)}let l=t.annotation(dt);if((l=="full"||l=="before")&&(e=e.isolate()),t.annotation(K.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=g.fromTransaction(t),s=t.annotation(K.time),c=t.annotation(K.userEvent);return o?e=e.addChanges(o,s,c,n,t):t.selection&&(e=e.addSelection(t.startState.selection,s,c,n.newGroupDelay)),(l=="full"||l=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new C(e.done.map(g.fromJSON),e.undone.map(g.fromJSON))}});function Dn(e={}){return[N,xe.of(e),O.domEventHandlers({beforeinput(t,n){let r=t.inputType=="historyUndo"?Le:t.inputType=="historyRedo"?Y:null;return r?(t.preventDefault(),r(n)):!1}})]}const xn=N;function P(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let l=n.field(N,!1);if(!l)return!1;let o=l.pop(e,n,t);return o?(r(o),!0):!1}}const Le=P(0,!1),Y=P(1,!1),pt=P(0,!0),gt=P(1,!0);function Me(e){return function(t){let n=t.field(N,!1);if(!n)return 0;let r=e==0?n.done:n.undone;return r.length-(r.length&&!r[0].changes?1:0)}}const Ln=Me(0),Mn=Me(1);class g{constructor(t,n,r,l,o){this.changes=t,this.effects=n,this.mapped=r,this.startSelection=l,this.selectionsAfter=o}setSelAfter(t){return new g(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,n,r;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(l=>l.toJSON())}}static fromJSON(t){return new g(t.changes&&rt.fromJSON(t.changes),[],t.mapped&&ot.fromJSON(t.mapped),t.startSelection&&h.fromJSON(t.startSelection),t.selectionsAfter.map(h.fromJSON))}static fromTransaction(t,n){let r=A;for(let l of t.startState.facet(mt)){let o=l(t);o.length&&(r=r.concat(o))}return!r.length&&t.changes.empty?null:new g(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,A)}static selection(t){return new g(void 0,A,void 0,void 0,t)}}function U(e,t,n,r){let l=t+1>n+20?t-n-1:0,o=e.slice(l,t);return o.push(r),o}function yt(e,t){let n=[],r=!1;return e.iterChangedRanges((l,o)=>n.push(l,o)),t.iterChangedRanges((l,o,s,c)=>{for(let i=0;i<n.length;){let f=n[i++],u=n[i++];c>=f&&s<=u&&(r=!0)}}),r}function kt(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function be(e,t){return e.length?t.length?e.concat(t):e:t}const A=[],At=200;function Ee(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-At));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),U(e,e.length-1,1e9,n.setSelAfter(r)))}else return[g.selection([t])]}function Bt(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 $(e,t){if(!e.length)return e;let n=e.length,r=A;for(;n;){let l=St(e[n-1],t,r);if(l.changes&&!l.changes.empty||l.effects.length){let o=e.slice(0,n);return o[n-1]=l,o}else t=l.mapped,n--,r=l.selectionsAfter}return r.length?[g.selection(r)]:A}function St(e,t,n){let r=be(e.selectionsAfter.length?e.selectionsAfter.map(c=>c.map(t)):A,n);if(!e.changes)return g.selection(r);let l=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new g(l,Se.mapEffects(e.effects,t),s,e.startSelection.map(o),r)}const Ct=/^(input\.type|delete)($|\.)/;class C{constructor(t,n,r=0,l=void 0){this.done=t,this.undone=n,this.prevTime=r,this.prevUserEvent=l}isolate(){return this.prevTime?new C(this.done,this.undone):this}addChanges(t,n,r,l,o){let s=this.done,c=s[s.length-1];return c&&c.changes&&!c.changes.empty&&t.changes&&(!r||Ct.test(r))&&(!c.selectionsAfter.length&&n-this.prevTime<l.newGroupDelay&&l.joinToEvent(o,yt(c.changes,t.changes))||r=="input.type.compose")?s=U(s,s.length-1,l.minDepth,new g(t.changes.compose(c.changes),be(Se.mapEffects(t.effects,c.changes),c.effects),c.mapped,c.startSelection,A)):s=U(s,s.length,l.minDepth,t),new C(s,A,n,r)}addSelection(t,n,r,l){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:A;return o.length>0&&n-this.prevTime<l&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&kt(o[o.length-1],t)?this:new C(Ee(this.done,t),this.undone,n,r)}addMapping(t){return new C($(this.done,t),$(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,n,r){let l=t==0?this.done:this.undone;if(l.length==0)return null;let o=l[l.length-1],s=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):n.selection);if(r&&o.selectionsAfter.length)return n.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:X.of({side:t,rest:Bt(l),selection:s}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let c=l.length==1?A:l.slice(0,l.length-1);return o.mapped&&(c=$(c,o.mapped)),n.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:X.of({side:t,rest:c,selection:s}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}C.empty=new C(A,A);const bn=[{key:"Mod-z",run:Le,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Y,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Y,preventDefault:!0},{key:"Mod-u",run:pt,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:gt,preventDefault:!0}];function I(e,t){return h.create(e.ranges.map(t),e.mainIndex)}function S(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function y({state:e,dispatch:t},n){let r=I(e.selection,n);return r.eq(e.selection,!0)?!1:(t(S(e,r)),!0)}function M(e,t){return h.cursor(t?e.to:e.from)}function J(e,t){return y(e,n=>n.empty?e.moveByChar(n,t):M(n,t))}function m(e){return e.textDirectionAt(e.state.selection.main.head)==lt.LTR}const Te=e=>J(e,!m(e)),Oe=e=>J(e,m(e)),En=e=>J(e,!0),Tn=e=>J(e,!1);function oe(e,t,n){let r=t.head,l=e.doc.lineAt(r);return r==(n?l.to:l.from)?r=n?Math.min(e.doc.length,l.to+1):Math.max(0,l.from-1):r=l.from+T(l.text,r-l.from,n),h.cursor(r,n?-1:1)}function Ie(e,t){return y(e,n=>n.empty?oe(e.state,n,t):M(n,t))}const On=e=>Ie(e,!0),In=e=>Ie(e,!1);function w(e,t){return y(e,n=>n.empty?e.moveByGroup(n,t):M(n,t))}const Dt=e=>w(e,!m(e)),xt=e=>w(e,m(e)),vn=e=>w(e,!0),Rn=e=>w(e,!1);function le(e,t,n){let r=e.state.charCategorizer(t),l=r(n),o=l!=D.Space;return s=>{let c=r(s);return c!=D.Space?o&&c==l:(o=!1,!0)}}const Fn=e=>y(e,t=>t.empty?e.moveByChar(t,!0,n=>le(e,t.head,n)):M(t,!0)),ue=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function ve(e,t,n){let r=e.state.charCategorizer(t.from),l=D.Space,o=t.from,s=0,c=!1,i=!1,f=!1,u=d=>{if(c)return!1;o+=n?d.length:-d.length;let B=r(d),k;if(B==D.Word&&d.charCodeAt(0)<128&&/[\W_]/.test(d)&&(B=-1),l==D.Space&&(l=B),l!=B)return!1;if(l==D.Word)if(d.toLowerCase()==d){if(!n&&i)return!1;f=!0}else if(f){if(n)return!1;c=!0}else{if(i&&n&&r(k=e.state.sliceDoc(o,o+1))==D.Word&&k.toLowerCase()==k)return!1;i=!0}return s++,!0},a=e.moveByChar(t,n,d=>(u(d),u));if(ue&&l==D.Word&&a.from==t.from+s*(n?1:-1)){let d=Math.min(t.head,a.head),B=Math.max(t.head,a.head),k=e.state.sliceDoc(d,B);if(k.length>1&&/[\u4E00-\uffff]/.test(k)){let R=Array.from(ue.segment(k));if(R.length>1)return n?h.cursor(t.head+R[1].index,-1):h.cursor(a.head+R[R.length-1].index,1)}}return a}function Re(e,t){return y(e,n=>n.empty?ve(e,n,t):M(n,t))}const Gn=e=>Re(e,!0),Un=e=>Re(e,!1);function Lt(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 z(e,t,n){let r=te(e).resolveInner(t.head),l=n?Q.closedBy:Q.openedBy;for(let i=t.head;;){let f=n?r.childAfter(i):r.childBefore(i);if(!f)break;Lt(e,f,l)?r=f:i=n?f.to:f.from}let o=r.type.prop(l),s,c;return o&&(s=n?E(e,r.from,1):E(e,r.to,-1))&&s.matched?c=n?s.end.to:s.end.from:c=n?r.to:r.from,h.cursor(c,n?-1:1)}const Mt=e=>y(e,t=>z(e.state,t,!m(e))),bt=e=>y(e,t=>z(e.state,t,m(e)));function Fe(e,t){return y(e,n=>{if(!n.empty)return M(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}const Ge=e=>Fe(e,!1),Ue=e=>Fe(e,!0);function Ve(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,l;if(t){for(let o of e.state.facet(O.scrollMargins)){let s=o(e);s!=null&&s.top&&(n=Math.max(s==null?void 0:s.top,n)),s!=null&&s.bottom&&(r=Math.max(s==null?void 0:s.bottom,r))}l=e.scrollDOM.clientHeight-n-r}else l=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,l-5)}}function Ne(e,t){let n=Ve(e),{state:r}=e,l=I(r.selection,s=>s.empty?e.moveVertically(s,t,n.height):M(s,t));if(l.eq(r.selection))return!1;let o;if(n.selfScroll){let s=e.coordsAtPos(r.selection.main.head),c=e.scrollDOM.getBoundingClientRect(),i=c.top+n.marginTop,f=c.bottom-n.marginBottom;s&&s.top>i&&s.bottom<f&&(o=O.scrollIntoView(l.main.head,{y:"start",yMargin:s.top-i}))}return e.dispatch(S(r,l),{effects:o}),!0}const fe=e=>Ne(e,!1),Z=e=>Ne(e,!0);function x(e,t,n){let r=e.lineBlockAt(t.head),l=e.moveToLineBoundary(t,n);if(l.head==t.head&&l.head!=(n?r.to:r.from)&&(l=e.moveToLineBoundary(t,n,!1)),!n&&l.head==r.from&&r.length){let o=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&t.head!=r.from+o&&(l=h.cursor(r.from+o))}return l}const Et=e=>y(e,t=>x(e,t,!0)),Tt=e=>y(e,t=>x(e,t,!1)),Ot=e=>y(e,t=>x(e,t,!m(e))),It=e=>y(e,t=>x(e,t,m(e))),vt=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).from,1)),Rt=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).to,-1));function Pe(e,t,n){let r=!1,l=I(e.selection,o=>{let s=E(e,o.head,-1)||E(e,o.head,1)||o.head>0&&E(e,o.head-1,1)||o.head<e.doc.length&&E(e,o.head+1,-1);if(!s||!s.end)return o;r=!0;let c=s.start.from==o.head?s.end.to:s.end.from;return n?h.range(o.anchor,c):h.cursor(c)});return r?(t(S(e,l)),!0):!1}const Ft=({state:e,dispatch:t})=>Pe(e,t,!1),Vn=({state:e,dispatch:t})=>Pe(e,t,!0);function p(e,t,n){let r=I(e.state.selection,l=>{l.undirectional&&l.head>=l.anchor!=t&&(l=h.range(l.head,l.anchor));let o=n(l);return h.range(l.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return r.eq(e.state.selection)?!1:(e.dispatch(S(e.state,r)),!0)}function W(e,t){return p(e,t,n=>e.moveByChar(n,t))}const Je=e=>W(e,!m(e)),we=e=>W(e,m(e)),Nn=e=>W(e,!0),Pn=e=>W(e,!1),Jn=e=>p(e,!0,t=>oe(e.state,t,!0)),wn=e=>p(e,!1,t=>oe(e.state,t,!1));function H(e,t){return p(e,t,n=>e.moveByGroup(n,t))}const Gt=e=>H(e,!m(e)),Ut=e=>H(e,m(e)),zn=e=>H(e,!0),Wn=e=>H(e,!1),Hn=e=>p(e,!0,t=>e.moveByChar(t,!0,n=>le(e,t.head,n)));function ze(e,t){return p(e,t,n=>ve(e,n,t))}const qn=e=>ze(e,!0),Kn=e=>ze(e,!1),Vt=e=>{let t=!m(e);return p(e,t,n=>z(e.state,n,t))},Nt=e=>{let t=m(e);return p(e,t,n=>z(e.state,n,t))};function We(e,t){return p(e,t,n=>e.moveVertically(n,t))}const He=e=>We(e,!1),qe=e=>We(e,!0);function Ke(e,t){return p(e,t,n=>e.moveVertically(n,t,Ve(e).height))}const ae=e=>Ke(e,!1),he=e=>Ke(e,!0),Pt=e=>p(e,!0,t=>x(e,t,!0)),Jt=e=>p(e,!1,t=>x(e,t,!1)),wt=e=>{let t=!m(e);return p(e,t,n=>x(e,n,t))},zt=e=>{let t=m(e);return p(e,t,n=>x(e,n,t))},Wt=e=>p(e,!1,t=>h.cursor(e.lineBlockAt(t.head).from)),Ht=e=>p(e,!0,t=>h.cursor(e.lineBlockAt(t.head).to)),de=({state:e,dispatch:t})=>(t(S(e,{anchor:0})),!0),me=({state:e,dispatch:t})=>(t(S(e,{anchor:e.doc.length})),!0),pe=({state:e,dispatch:t})=>(t(S(e,{anchor:e.selection.main.anchor,head:0})),!0),ge=({state:e,dispatch:t})=>(t(S(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),qt=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),Kt=({state:e,dispatch:t})=>{let n=q(e).map(({from:r,to:l})=>h.range(r,Math.min(l+1,e.doc.length)));return t(e.update({selection:h.create(n),userEvent:"select"})),!0},$t=({state:e,dispatch:t})=>{let n=I(e.selection,r=>{let l=te(e),o=l.resolveStack(r.from,1);if(r.empty){let s=l.resolveStack(r.from,-1);s.node.from>=o.node.from&&s.node.to<=o.node.to&&(o=s)}for(let s=o;s;s=s.next){let{node:c}=s;if((c.from<r.from&&c.to>=r.to||c.to>r.to&&c.from<=r.from)&&s.next)return h.range(c.to,c.from)}return r});return n.eq(e.selection)?!1:(t(S(e,n)),!0)};function $e(e,t){let{state:n}=e,r=n.selection,l=n.selection.ranges.slice();for(let o of n.selection.ranges){let s=n.doc.lineAt(o.head);if(t?s.to<e.state.doc.length:s.from>0)for(let c=o;;){let i=e.moveVertically(c,t);if(i.head<s.from||i.head>s.to){l.some(f=>f.head==i.head)||l.push(i);break}else{if(i.head==c.head)break;c=i}}}return l.length==r.ranges.length?!1:(e.dispatch(S(n,h.create(l,l.length-1))),!0)}const jt=e=>$e(e,!1),Qt=e=>$e(e,!0),Xt=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=h.create([n.main]):n.main.empty||(r=h.create([h.cursor(n.main.head)])),r?(t(S(e,r)),!0):!1};function b(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,l=r.changeByRange(o=>{let{from:s,to:c}=o;if(s==c){let i=t(o);i<s?(n="delete.backward",i=F(e,i,!1)):i>s&&(n="delete.forward",i=F(e,i,!0)),s=Math.min(s,i),c=Math.max(c,i)}else s=F(e,s,!1),c=F(e,c,!0);return s==c?{range:o}:{changes:{from:s,to:c},range:h.cursor(s,s<o.head?-1:1)}});return l.changes.empty?!1:(e.dispatch(r.update(l,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?O.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function F(e,t,n){if(e instanceof O)for(let r of e.state.facet(O.atomicRanges).map(l=>l(e)))r.between(t,t,(l,o)=>{l<t&&o>t&&(t=n?o:l)});return t}const se=(e,t,n)=>b(e,r=>{let l=r.from,{state:o}=e,s=o.doc.lineAt(l),c,i;if(n&&!t&&l>s.from&&l<s.from+200&&!/[^ \t]/.test(c=s.text.slice(0,l-s.from))){if(c[c.length-1]==" ")return l-1;let f=ee(c,o.tabSize),u=f%j(o)||j(o);for(let a=0;a<u&&c[c.length-1-a]==" ";a++)l--;i=l}else i=T(s.text,l-s.from,t,t)+s.from,i==l&&s.number!=(t?o.doc.lines:1)?i+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(s.text.slice(i-s.from,l-s.from))&&(i=T(s.text,i-s.from,!1,!1)+s.from);return i}),_=e=>se(e,!1,!0),$n=e=>se(e,!1,!1),je=e=>se(e,!0,!1),Qe=(e,t)=>b(e,n=>{let r=n.head,{state:l}=e,o=l.doc.lineAt(r),s=l.charCategorizer(r);for(let c=null;;){if(r==(t?o.to:o.from)){r==n.head&&o.number!=(t?l.doc.lines:1)&&(r+=t?1:-1);break}let i=T(o.text,r-o.from,t)+o.from,f=o.text.slice(Math.min(r,i)-o.from,Math.max(r,i)-o.from),u=s(f);if(c!=null&&u!=c)break;(f!=" "||r!=n.head)&&(c=u),r=i}return r}),Xe=e=>Qe(e,!1),Yt=e=>Qe(e,!0),jn=e=>b(e,t=>e.moveByChar(t,!0,n=>le(e,t.head,n)).head),Zt=e=>b(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Qn=e=>b(e,t=>{let n=e.lineBlockAt(t.head).from;return t.head>n?n:Math.max(0,t.head-1)}),_t=e=>b(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),en=e=>b(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Xn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=[];for(let r=0,l="",o=e.doc.iter();;){if(o.next(),o.lineBreak||o.done){let s=l.search(/\s+$/);if(s>-1&&n.push({from:r-(l.length-s),to:r}),o.done)break;l=""}else l=o.value;r+=o.value.length}return n.length?(t(e.update({changes:n,userEvent:"delete"})),!0):!1},tn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:ke.of(["",""])},range:h.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},nn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>{if(!r.empty||r.from==0||r.from==e.doc.length)return{range:r};let l=r.from,o=e.doc.lineAt(l),s=l==o.from?l-1:T(o.text,l-o.from,!1)+o.from,c=l==o.to?l+1:T(o.text,l-o.from,!0)+o.from;return{changes:{from:s,to:c,insert:e.doc.slice(l,c).append(e.doc.slice(s,l))},range:h.cursor(c)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function q(e){let t=[],n=-1;for(let r of e.selection.ranges){let l=e.doc.lineAt(r.from),o=e.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=e.doc.lineAt(r.to-1)),n>=l.number){let s=t[t.length-1];s.to=o.to,s.ranges.push(r)}else t.push({from:l.from,to:o.to,ranges:[r]});n=o.number+1}return t}function Ye(e,t,n){if(e.readOnly)return!1;let r=[],l=[];for(let o of q(e)){if(n?o.to==e.doc.length:o.from==0)continue;let s=e.doc.lineAt(n?o.to+1:o.from-1),c=s.length+1;if(n){r.push({from:o.to,to:s.to},{from:o.from,insert:s.text+e.lineBreak});for(let i of o.ranges)l.push(h.range(Math.min(e.doc.length,i.anchor+c),Math.min(e.doc.length,i.head+c)))}else{r.push({from:s.from,to:o.from},{from:o.to,insert:e.lineBreak+s.text});for(let i of o.ranges)l.push(h.range(i.anchor-c,i.head-c))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:h.create(l,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}const rn=({state:e,dispatch:t})=>Ye(e,t,!1),on=({state:e,dispatch:t})=>Ye(e,t,!0);function Ze(e,t,n){if(e.readOnly)return!1;let r=[];for(let o of q(e))n?r.push({from:o.from,insert:e.doc.slice(o.from,o.to)+e.lineBreak}):r.push({from:o.to,insert:e.lineBreak+e.doc.slice(o.from,o.to)});let l=e.changes(r);return t(e.update({changes:l,selection:e.selection.map(l,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const ln=({state:e,dispatch:t})=>Ze(e,t,!1),sn=({state:e,dispatch:t})=>Ze(e,t,!0),cn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(q(t).map(({from:l,to:o})=>(l>0?l--:o<t.doc.length&&o++,{from:l,to:o}))),r=I(t.selection,l=>{let o;if(e.lineWrapping){let s=e.lineBlockAt(l.head),c=e.coordsAtPos(l.head,l.assoc||1);c&&(o=s.bottom+e.documentTop-c.bottom+e.defaultLineHeight/2)}return e.moveVertically(l,!0,o)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0},Yn=({state:e,dispatch:t})=>(t(e.update(e.replaceSelection(e.lineBreak),{scrollIntoView:!0,userEvent:"input"})),!0),Zn=({state:e,dispatch:t})=>(t(e.update(e.changeByRange(n=>{let r=/^\s*/.exec(e.doc.lineAt(n.from).text)[0];return{changes:{from:n.from,to:n.to,insert:e.lineBreak+r},range:h.cursor(n.from+r.length+1)}}),{scrollIntoView:!0,userEvent:"input"})),!0);function un(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=te(e).resolveInner(t),r=n.childBefore(t),l=n.childAfter(t),o;return r&&l&&r.to<=t&&l.from>=t&&(o=r.type.prop(Q.closedBy))&&o.indexOf(l.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(l.from).from&&!/\S/.test(e.sliceDoc(r.to,l.from))?{from:r.to,to:l.from}:null}const ye=_e(!1),fn=_e(!0);function _e(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(l=>{let{from:o,to:s}=l,c=t.doc.lineAt(o),i=!e&&o==s&&un(t,o);e&&(o=s=(s<=c.to?c:t.doc.lineAt(s)).to);let f=new Ce(t,{simulateBreak:o,simulateDoubleBreak:!!i}),u=De(f,o);for(u==null&&(u=ee(/^\s*/.exec(t.doc.lineAt(o).text)[0],t.tabSize));s<c.to&&/\s/.test(c.text[s-c.from]);)s++;i?{from:o,to:s}=i:o>c.from&&o<c.from+100&&!/\S/.test(c.text.slice(0,o))&&(o=c.from);let a=["",G(t,u)];return i&&a.push(G(t,f.lineIndent(c.from,-1))),{changes:{from:o,to:s,insert:ke.of(a)},range:h.cursor(o+1+a[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function ce(e,t){let n=-1;return e.changeByRange(r=>{let l=[];for(let s=r.from;s<=r.to;){let c=e.doc.lineAt(s);c.number>n&&(r.empty||r.to>c.from)&&(t(c,l,r),n=c.number),s=c.to+1}let o=e.changes(l);return{changes:l,range:h.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const an=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Ce(e,{overrideIndentation:o=>{let s=n[o];return s??-1}}),l=ce(e,(o,s,c)=>{let i=De(r,o.from);if(i==null)return;/\S/.test(o.text)||(i=0);let f=/^\s*/.exec(o.text)[0],u=G(e,i);(f!=u||c.from<o.from+f.length)&&(n[o.from]=i,s.push({from:o.from,to:o.from+f.length,insert:u}))});return l.changes.empty||t(e.update(l,{userEvent:"indent"})),!0},ie=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(ce(e,(n,r)=>{r.push({from:n.from,insert:e.facet(st)})}),{userEvent:"input.indent"})),!0),et=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(ce(e,(n,r)=>{let l=/^\s*/.exec(n.text)[0];if(!l)return;let o=ee(l,e.tabSize),s=0,c=G(e,Math.max(0,o-j(e)));for(;s<l.length&&s<c.length&&l.charCodeAt(s)==c.charCodeAt(s);)s++;r.push({from:n.from+s,to:n.from+l.length,insert:c.slice(s)})}),{userEvent:"delete.dedent"})),!0),hn=e=>(e.setTabFocusMode(),!0),_n=e=>(e.setTabFocusMode(2e3),!0),er=({state:e,dispatch:t})=>e.selection.ranges.some(n=>!n.empty)?ie({state:e,dispatch:t}):(t(e.update(e.replaceSelection(" "),{scrollIntoView:!0,userEvent:"input"})),!0),dn=[{key:"Ctrl-b",run:Te,shift:Je,preventDefault:!0},{key:"Ctrl-f",run:Oe,shift:we},{key:"Ctrl-p",run:Ge,shift:He},{key:"Ctrl-n",run:Ue,shift:qe},{key:"Ctrl-a",run:vt,shift:Wt},{key:"Ctrl-e",run:Rt,shift:Ht},{key:"Ctrl-d",run:je},{key:"Ctrl-h",run:_},{key:"Ctrl-k",run:Zt},{key:"Ctrl-Alt-h",run:Xe},{key:"Ctrl-o",run:tn},{key:"Ctrl-t",run:nn},{key:"Ctrl-v",run:Z}],mn=[{key:"ArrowLeft",run:Te,shift:Je,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Dt,shift:Gt,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Ot,shift:wt,preventDefault:!0},{key:"ArrowRight",run:Oe,shift:we,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:xt,shift:Ut,preventDefault:!0},{mac:"Cmd-ArrowRight",run:It,shift:zt,preventDefault:!0},{key:"ArrowUp",run:Ge,shift:He,preventDefault:!0},{mac:"Cmd-ArrowUp",run:de,shift:pe},{mac:"Ctrl-ArrowUp",run:fe,shift:ae},{key:"ArrowDown",run:Ue,shift:qe,preventDefault:!0},{mac:"Cmd-ArrowDown",run:me,shift:ge},{mac:"Ctrl-ArrowDown",run:Z,shift:he},{key:"PageUp",run:fe,shift:ae},{key:"PageDown",run:Z,shift:he},{key:"Home",run:Tt,shift:Jt,preventDefault:!0},{key:"Mod-Home",run:de,shift:pe},{key:"End",run:Et,shift:Pt,preventDefault:!0},{key:"Mod-End",run:me,shift:ge},{key:"Enter",run:ye,shift:ye},{key:"Mod-a",run:qt},{key:"Backspace",run:_,shift:_,preventDefault:!0},{key:"Delete",run:je,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Xe,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Yt,preventDefault:!0},{mac:"Mod-Backspace",run:_t,preventDefault:!0},{mac:"Mod-Delete",run:en,preventDefault:!0}].concat(dn.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),tr=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Mt,shift:Vt},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:bt,shift:Nt},{key:"Alt-ArrowUp",run:rn},{key:"Shift-Alt-ArrowUp",run:ln},{key:"Alt-ArrowDown",run:on},{key:"Shift-Alt-ArrowDown",run:sn},{key:"Mod-Alt-ArrowUp",run:jt},{key:"Mod-Alt-ArrowDown",run:Qt},{key:"Escape",run:Xt},{key:"Mod-Enter",run:fn},{key:"Alt-l",mac:"Ctrl-l",run:Kt},{key:"Mod-i",run:$t,preventDefault:!0},{key:"Mod-[",run:et},{key:"Mod-]",run:ie},{key:"Mod-Alt-\\",run:an},{key:"Shift-Mod-k",run:cn},{key:"Shift-Mod-\\",run:Ft},{key:"Mod-/",run:ct},{key:"Alt-A",run:ut},{key:"Ctrl-m",mac:"Shift-Alt-m",run:hn}].concat(mn),nr={key:"Tab",run:ie,shift:et};export{jt as addCursorAbove,Qt as addCursorBelow,Sn as blockComment,Cn as blockUncomment,sn as copyLineDown,ln as copyLineUp,Tn as cursorCharBackward,In as cursorCharBackwardLogical,En as cursorCharForward,On as cursorCharForwardLogical,Te as cursorCharLeft,Oe as cursorCharRight,me as cursorDocEnd,de as cursorDocStart,Rn as cursorGroupBackward,vn as cursorGroupForward,Fn as cursorGroupForwardWin,Dt as cursorGroupLeft,xt as cursorGroupRight,Tt as cursorLineBoundaryBackward,Et as cursorLineBoundaryForward,Ot as cursorLineBoundaryLeft,It as cursorLineBoundaryRight,Ue as cursorLineDown,Rt as cursorLineEnd,vt as cursorLineStart,Ge as cursorLineUp,Ft as cursorMatchingBracket,Z as cursorPageDown,fe as cursorPageUp,Un as cursorSubwordBackward,Gn as cursorSubwordForward,Mt as cursorSyntaxLeft,bt as cursorSyntaxRight,tr as defaultKeymap,_ as deleteCharBackward,$n as deleteCharBackwardStrict,je as deleteCharForward,Xe as deleteGroupBackward,Yt as deleteGroupForward,jn as deleteGroupForwardWin,cn as deleteLine,_t as deleteLineBoundaryBackward,en as deleteLineBoundaryForward,Zt as deleteToLineEnd,Qn as deleteToLineStart,Xn as deleteTrailingWhitespace,dn as emacsStyleKeymap,Dn as history,xn as historyField,bn as historyKeymap,et as indentLess,ie as indentMore,an as indentSelection,nr as indentWithTab,fn as insertBlankLine,Yn as insertNewline,ye as insertNewlineAndIndent,Zn as insertNewlineKeepIndent,er as insertTab,mt as invertedEffects,dt as isolateHistory,An as lineComment,Bn as lineUncomment,on as moveLineDown,rn as moveLineUp,Y as redo,Mn as redoDepth,gt as redoSelection,qt as selectAll,Pn as selectCharBackward,wn as selectCharBackwardLogical,Nn as selectCharForward,Jn as selectCharForwardLogical,Je as selectCharLeft,we as selectCharRight,ge as selectDocEnd,pe as selectDocStart,Wn as selectGroupBackward,zn as selectGroupForward,Hn as selectGroupForwardWin,Gt as selectGroupLeft,Ut as selectGroupRight,Kt as selectLine,Jt as selectLineBoundaryBackward,Pt as selectLineBoundaryForward,wt as selectLineBoundaryLeft,zt as selectLineBoundaryRight,qe as selectLineDown,Ht as selectLineEnd,Wt as selectLineStart,He as selectLineUp,Vn as selectMatchingBracket,he as selectPageDown,ae as selectPageUp,$t as selectParentSyntax,Kn as selectSubwordBackward,qn as selectSubwordForward,Vt as selectSyntaxLeft,Nt as selectSyntaxRight,Xt as simplifySelection,tn as splitLine,mn as standardKeymap,_n as temporarilySetTabFocusMode,ut as toggleBlockComment,ft as toggleBlockCommentByLine,ct as toggleComment,it as toggleLineComment,hn as toggleTabFocusMode,nn as transposeChars,Le as undo,Ln as undoDepth,pt as undoSelection};
1
+ import{EditorSelection as h,Text as ke,findClusterBreak as T,StateField as tt,Transaction as K,Facet as Ae,Annotation as Be,combineConfig as nt,StateEffect as Se,ChangeSet as rt,ChangeDesc as ot,countColumn as ee,CharCategory as D}from"./index-BHot-lnj.js";import{E as O,o as lt}from"./index-891wE-Rj.js";import{I as Ce,g as De,c as G,e as te,m as E,h as j,j as st}from"./index-DPvZ-hhz.js";import{N as Q}from"./index-CLOINL5U.js";const ct=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=ne(e.state,n.from);return r.line?it(e):r.block?ft(e):!1};function L(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let l=e(t,n);return l?(r(n.update(l)),!0):!1}}const it=L(re,0),An=L(re,1),Bn=L(re,2),ut=L(V,0),Sn=L(V,1),Cn=L(V,2),ft=L((e,t)=>V(e,t,ht(t)),0);function ne(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const v=50;function at(e,{open:t,close:n},r,l){let o=e.sliceDoc(r-v,r),s=e.sliceDoc(l,l+v),c=/\s*$/.exec(o)[0].length,i=/^\s*/.exec(s)[0].length,f=o.length-c;if(o.slice(f-t.length,f)==t&&s.slice(i,i+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:l+i,margin:i&&1}};let u,a;l-r<=2*v?u=a=e.sliceDoc(r,l):(u=e.sliceDoc(r,r+v),a=e.sliceDoc(l-v,l));let d=/^\s*/.exec(u)[0].length,B=/\s*$/.exec(a)[0].length,k=a.length-B-n.length;return u.slice(d,d+t.length)==t&&a.slice(k,k+n.length)==n?{open:{pos:r+d+t.length,margin:/\s/.test(u.charAt(d+t.length))?1:0},close:{pos:l-B-n.length,margin:/\s/.test(a.charAt(k-1))?1:0}}:null}function ht(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),l=n.to<=r.to?r:e.doc.lineAt(n.to);l.from>r.from&&l.from==n.to&&(l=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let o=t.length-1;o>=0&&t[o].to>r.from?t[o].to=l.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:l.to})}return t}function V(e,t,n=t.selection.ranges){let r=n.map(o=>ne(t,o.from).block);if(!r.every(o=>o))return null;let l=n.map((o,s)=>at(t,r[s],o.from,o.to));if(e!=2&&!l.every(o=>o))return{changes:t.changes(n.map((o,s)=>l[s]?[]:[{from:o.from,insert:r[s].open+" "},{from:o.to,insert:" "+r[s].close}]))};if(e!=1&&l.some(o=>o)){let o=[];for(let s=0,c;s<l.length;s++)if(c=l[s]){let i=r[s],{open:f,close:u}=c;o.push({from:f.pos-i.open.length,to:f.pos+f.margin},{from:u.pos-u.margin,to:u.pos+i.close.length})}return{changes:o}}return null}function re(e,t,n=t.selection.ranges){let r=[],l=-1;e:for(let{from:o,to:s}of n){let c=r.length,i=1e9,f;for(let u=o;u<=s;){let a=t.doc.lineAt(u);if(f==null&&(f=ne(t,a.from).line,!f))continue e;if(a.from>l&&(o==s||s>a.from)){l=a.from;let d=/^\s*/.exec(a.text)[0].length,B=d==a.length,k=a.text.slice(d,d+f.length)==f?d:-1;d<a.text.length&&d<i&&(i=d),r.push({line:a,comment:k,token:f,indent:d,empty:B,single:!1})}u=a.to+1}if(i<1e9)for(let u=c;u<r.length;u++)r[u].indent<r[u].line.text.length&&(r[u].indent=i);r.length==c+1&&(r[c].single=!0)}if(e!=2&&r.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:c,token:i,indent:f,empty:u,single:a}of r)(a||!u)&&o.push({from:c.from+f,insert:i+" "});let s=t.changes(o);return{changes:s,selection:t.selection.map(s,1)}}else if(e!=1&&r.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:c,token:i}of r)if(c>=0){let f=s.from+c,u=f+i.length;s.text[u-s.from]==" "&&u++,o.push({from:f,to:u})}return{changes:o}}return null}const X=Be.define(),dt=Be.define(),mt=Ae.define(),xe=Ae.define({combine(e){return nt(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,n)=>(r,l)=>t(r,l)||n(r,l)})}}),N=tt.define({create(){return C.empty},update(e,t){let n=t.state.facet(xe),r=t.annotation(X);if(r){let i=g.fromTransaction(t,r.selection),f=r.side,u=f==0?e.undone:e.done;return i?u=U(u,u.length,n.minDepth,i):u=Ee(u,t.startState.selection),new C(f==0?r.rest:u,f==0?u:r.rest)}let l=t.annotation(dt);if((l=="full"||l=="before")&&(e=e.isolate()),t.annotation(K.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=g.fromTransaction(t),s=t.annotation(K.time),c=t.annotation(K.userEvent);return o?e=e.addChanges(o,s,c,n,t):t.selection&&(e=e.addSelection(t.startState.selection,s,c,n.newGroupDelay)),(l=="full"||l=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new C(e.done.map(g.fromJSON),e.undone.map(g.fromJSON))}});function Dn(e={}){return[N,xe.of(e),O.domEventHandlers({beforeinput(t,n){let r=t.inputType=="historyUndo"?Le:t.inputType=="historyRedo"?Y:null;return r?(t.preventDefault(),r(n)):!1}})]}const xn=N;function P(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let l=n.field(N,!1);if(!l)return!1;let o=l.pop(e,n,t);return o?(r(o),!0):!1}}const Le=P(0,!1),Y=P(1,!1),pt=P(0,!0),gt=P(1,!0);function Me(e){return function(t){let n=t.field(N,!1);if(!n)return 0;let r=e==0?n.done:n.undone;return r.length-(r.length&&!r[0].changes?1:0)}}const Ln=Me(0),Mn=Me(1);class g{constructor(t,n,r,l,o){this.changes=t,this.effects=n,this.mapped=r,this.startSelection=l,this.selectionsAfter=o}setSelAfter(t){return new g(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,n,r;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(l=>l.toJSON())}}static fromJSON(t){return new g(t.changes&&rt.fromJSON(t.changes),[],t.mapped&&ot.fromJSON(t.mapped),t.startSelection&&h.fromJSON(t.startSelection),t.selectionsAfter.map(h.fromJSON))}static fromTransaction(t,n){let r=A;for(let l of t.startState.facet(mt)){let o=l(t);o.length&&(r=r.concat(o))}return!r.length&&t.changes.empty?null:new g(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,A)}static selection(t){return new g(void 0,A,void 0,void 0,t)}}function U(e,t,n,r){let l=t+1>n+20?t-n-1:0,o=e.slice(l,t);return o.push(r),o}function yt(e,t){let n=[],r=!1;return e.iterChangedRanges((l,o)=>n.push(l,o)),t.iterChangedRanges((l,o,s,c)=>{for(let i=0;i<n.length;){let f=n[i++],u=n[i++];c>=f&&s<=u&&(r=!0)}}),r}function kt(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function be(e,t){return e.length?t.length?e.concat(t):e:t}const A=[],At=200;function Ee(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-At));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),U(e,e.length-1,1e9,n.setSelAfter(r)))}else return[g.selection([t])]}function Bt(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 $(e,t){if(!e.length)return e;let n=e.length,r=A;for(;n;){let l=St(e[n-1],t,r);if(l.changes&&!l.changes.empty||l.effects.length){let o=e.slice(0,n);return o[n-1]=l,o}else t=l.mapped,n--,r=l.selectionsAfter}return r.length?[g.selection(r)]:A}function St(e,t,n){let r=be(e.selectionsAfter.length?e.selectionsAfter.map(c=>c.map(t)):A,n);if(!e.changes)return g.selection(r);let l=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new g(l,Se.mapEffects(e.effects,t),s,e.startSelection.map(o),r)}const Ct=/^(input\.type|delete)($|\.)/;class C{constructor(t,n,r=0,l=void 0){this.done=t,this.undone=n,this.prevTime=r,this.prevUserEvent=l}isolate(){return this.prevTime?new C(this.done,this.undone):this}addChanges(t,n,r,l,o){let s=this.done,c=s[s.length-1];return c&&c.changes&&!c.changes.empty&&t.changes&&(!r||Ct.test(r))&&(!c.selectionsAfter.length&&n-this.prevTime<l.newGroupDelay&&l.joinToEvent(o,yt(c.changes,t.changes))||r=="input.type.compose")?s=U(s,s.length-1,l.minDepth,new g(t.changes.compose(c.changes),be(Se.mapEffects(t.effects,c.changes),c.effects),c.mapped,c.startSelection,A)):s=U(s,s.length,l.minDepth,t),new C(s,A,n,r)}addSelection(t,n,r,l){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:A;return o.length>0&&n-this.prevTime<l&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&kt(o[o.length-1],t)?this:new C(Ee(this.done,t),this.undone,n,r)}addMapping(t){return new C($(this.done,t),$(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,n,r){let l=t==0?this.done:this.undone;if(l.length==0)return null;let o=l[l.length-1],s=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):n.selection);if(r&&o.selectionsAfter.length)return n.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:X.of({side:t,rest:Bt(l),selection:s}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let c=l.length==1?A:l.slice(0,l.length-1);return o.mapped&&(c=$(c,o.mapped)),n.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:X.of({side:t,rest:c,selection:s}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}C.empty=new C(A,A);const bn=[{key:"Mod-z",run:Le,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Y,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Y,preventDefault:!0},{key:"Mod-u",run:pt,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:gt,preventDefault:!0}];function I(e,t){return h.create(e.ranges.map(t),e.mainIndex)}function S(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function y({state:e,dispatch:t},n){let r=I(e.selection,n);return r.eq(e.selection,!0)?!1:(t(S(e,r)),!0)}function M(e,t){return h.cursor(t?e.to:e.from)}function J(e,t){return y(e,n=>n.empty?e.moveByChar(n,t):M(n,t))}function m(e){return e.textDirectionAt(e.state.selection.main.head)==lt.LTR}const Te=e=>J(e,!m(e)),Oe=e=>J(e,m(e)),En=e=>J(e,!0),Tn=e=>J(e,!1);function oe(e,t,n){let r=t.head,l=e.doc.lineAt(r);return r==(n?l.to:l.from)?r=n?Math.min(e.doc.length,l.to+1):Math.max(0,l.from-1):r=l.from+T(l.text,r-l.from,n),h.cursor(r,n?-1:1)}function Ie(e,t){return y(e,n=>n.empty?oe(e.state,n,t):M(n,t))}const On=e=>Ie(e,!0),In=e=>Ie(e,!1);function w(e,t){return y(e,n=>n.empty?e.moveByGroup(n,t):M(n,t))}const Dt=e=>w(e,!m(e)),xt=e=>w(e,m(e)),vn=e=>w(e,!0),Rn=e=>w(e,!1);function le(e,t,n){let r=e.state.charCategorizer(t),l=r(n),o=l!=D.Space;return s=>{let c=r(s);return c!=D.Space?o&&c==l:(o=!1,!0)}}const Fn=e=>y(e,t=>t.empty?e.moveByChar(t,!0,n=>le(e,t.head,n)):M(t,!0)),ue=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function ve(e,t,n){let r=e.state.charCategorizer(t.from),l=D.Space,o=t.from,s=0,c=!1,i=!1,f=!1,u=d=>{if(c)return!1;o+=n?d.length:-d.length;let B=r(d),k;if(B==D.Word&&d.charCodeAt(0)<128&&/[\W_]/.test(d)&&(B=-1),l==D.Space&&(l=B),l!=B)return!1;if(l==D.Word)if(d.toLowerCase()==d){if(!n&&i)return!1;f=!0}else if(f){if(n)return!1;c=!0}else{if(i&&n&&r(k=e.state.sliceDoc(o,o+1))==D.Word&&k.toLowerCase()==k)return!1;i=!0}return s++,!0},a=e.moveByChar(t,n,d=>(u(d),u));if(ue&&l==D.Word&&a.from==t.from+s*(n?1:-1)){let d=Math.min(t.head,a.head),B=Math.max(t.head,a.head),k=e.state.sliceDoc(d,B);if(k.length>1&&/[\u4E00-\uffff]/.test(k)){let R=Array.from(ue.segment(k));if(R.length>1)return n?h.cursor(t.head+R[1].index,-1):h.cursor(a.head+R[R.length-1].index,1)}}return a}function Re(e,t){return y(e,n=>n.empty?ve(e,n,t):M(n,t))}const Gn=e=>Re(e,!0),Un=e=>Re(e,!1);function Lt(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 z(e,t,n){let r=te(e).resolveInner(t.head),l=n?Q.closedBy:Q.openedBy;for(let i=t.head;;){let f=n?r.childAfter(i):r.childBefore(i);if(!f)break;Lt(e,f,l)?r=f:i=n?f.to:f.from}let o=r.type.prop(l),s,c;return o&&(s=n?E(e,r.from,1):E(e,r.to,-1))&&s.matched?c=n?s.end.to:s.end.from:c=n?r.to:r.from,h.cursor(c,n?-1:1)}const Mt=e=>y(e,t=>z(e.state,t,!m(e))),bt=e=>y(e,t=>z(e.state,t,m(e)));function Fe(e,t){return y(e,n=>{if(!n.empty)return M(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}const Ge=e=>Fe(e,!1),Ue=e=>Fe(e,!0);function Ve(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,l;if(t){for(let o of e.state.facet(O.scrollMargins)){let s=o(e);s!=null&&s.top&&(n=Math.max(s==null?void 0:s.top,n)),s!=null&&s.bottom&&(r=Math.max(s==null?void 0:s.bottom,r))}l=e.scrollDOM.clientHeight-n-r}else l=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,l-5)}}function Ne(e,t){let n=Ve(e),{state:r}=e,l=I(r.selection,s=>s.empty?e.moveVertically(s,t,n.height):M(s,t));if(l.eq(r.selection))return!1;let o;if(n.selfScroll){let s=e.coordsAtPos(r.selection.main.head),c=e.scrollDOM.getBoundingClientRect(),i=c.top+n.marginTop,f=c.bottom-n.marginBottom;s&&s.top>i&&s.bottom<f&&(o=O.scrollIntoView(l.main.head,{y:"start",yMargin:s.top-i}))}return e.dispatch(S(r,l),{effects:o}),!0}const fe=e=>Ne(e,!1),Z=e=>Ne(e,!0);function x(e,t,n){let r=e.lineBlockAt(t.head),l=e.moveToLineBoundary(t,n);if(l.head==t.head&&l.head!=(n?r.to:r.from)&&(l=e.moveToLineBoundary(t,n,!1)),!n&&l.head==r.from&&r.length){let o=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&t.head!=r.from+o&&(l=h.cursor(r.from+o))}return l}const Et=e=>y(e,t=>x(e,t,!0)),Tt=e=>y(e,t=>x(e,t,!1)),Ot=e=>y(e,t=>x(e,t,!m(e))),It=e=>y(e,t=>x(e,t,m(e))),vt=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).from,1)),Rt=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).to,-1));function Pe(e,t,n){let r=!1,l=I(e.selection,o=>{let s=E(e,o.head,-1)||E(e,o.head,1)||o.head>0&&E(e,o.head-1,1)||o.head<e.doc.length&&E(e,o.head+1,-1);if(!s||!s.end)return o;r=!0;let c=s.start.from==o.head?s.end.to:s.end.from;return n?h.range(o.anchor,c):h.cursor(c)});return r?(t(S(e,l)),!0):!1}const Ft=({state:e,dispatch:t})=>Pe(e,t,!1),Vn=({state:e,dispatch:t})=>Pe(e,t,!0);function p(e,t,n){let r=I(e.state.selection,l=>{l.undirectional&&l.head>=l.anchor!=t&&(l=h.range(l.head,l.anchor));let o=n(l);return h.range(l.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return r.eq(e.state.selection)?!1:(e.dispatch(S(e.state,r)),!0)}function W(e,t){return p(e,t,n=>e.moveByChar(n,t))}const Je=e=>W(e,!m(e)),we=e=>W(e,m(e)),Nn=e=>W(e,!0),Pn=e=>W(e,!1),Jn=e=>p(e,!0,t=>oe(e.state,t,!0)),wn=e=>p(e,!1,t=>oe(e.state,t,!1));function H(e,t){return p(e,t,n=>e.moveByGroup(n,t))}const Gt=e=>H(e,!m(e)),Ut=e=>H(e,m(e)),zn=e=>H(e,!0),Wn=e=>H(e,!1),Hn=e=>p(e,!0,t=>e.moveByChar(t,!0,n=>le(e,t.head,n)));function ze(e,t){return p(e,t,n=>ve(e,n,t))}const qn=e=>ze(e,!0),Kn=e=>ze(e,!1),Vt=e=>{let t=!m(e);return p(e,t,n=>z(e.state,n,t))},Nt=e=>{let t=m(e);return p(e,t,n=>z(e.state,n,t))};function We(e,t){return p(e,t,n=>e.moveVertically(n,t))}const He=e=>We(e,!1),qe=e=>We(e,!0);function Ke(e,t){return p(e,t,n=>e.moveVertically(n,t,Ve(e).height))}const ae=e=>Ke(e,!1),he=e=>Ke(e,!0),Pt=e=>p(e,!0,t=>x(e,t,!0)),Jt=e=>p(e,!1,t=>x(e,t,!1)),wt=e=>{let t=!m(e);return p(e,t,n=>x(e,n,t))},zt=e=>{let t=m(e);return p(e,t,n=>x(e,n,t))},Wt=e=>p(e,!1,t=>h.cursor(e.lineBlockAt(t.head).from)),Ht=e=>p(e,!0,t=>h.cursor(e.lineBlockAt(t.head).to)),de=({state:e,dispatch:t})=>(t(S(e,{anchor:0})),!0),me=({state:e,dispatch:t})=>(t(S(e,{anchor:e.doc.length})),!0),pe=({state:e,dispatch:t})=>(t(S(e,{anchor:e.selection.main.anchor,head:0})),!0),ge=({state:e,dispatch:t})=>(t(S(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),qt=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),Kt=({state:e,dispatch:t})=>{let n=q(e).map(({from:r,to:l})=>h.range(r,Math.min(l+1,e.doc.length)));return t(e.update({selection:h.create(n),userEvent:"select"})),!0},$t=({state:e,dispatch:t})=>{let n=I(e.selection,r=>{let l=te(e),o=l.resolveStack(r.from,1);if(r.empty){let s=l.resolveStack(r.from,-1);s.node.from>=o.node.from&&s.node.to<=o.node.to&&(o=s)}for(let s=o;s;s=s.next){let{node:c}=s;if((c.from<r.from&&c.to>=r.to||c.to>r.to&&c.from<=r.from)&&s.next)return h.range(c.to,c.from)}return r});return n.eq(e.selection)?!1:(t(S(e,n)),!0)};function $e(e,t){let{state:n}=e,r=n.selection,l=n.selection.ranges.slice();for(let o of n.selection.ranges){let s=n.doc.lineAt(o.head);if(t?s.to<e.state.doc.length:s.from>0)for(let c=o;;){let i=e.moveVertically(c,t);if(i.head<s.from||i.head>s.to){l.some(f=>f.head==i.head)||l.push(i);break}else{if(i.head==c.head)break;c=i}}}return l.length==r.ranges.length?!1:(e.dispatch(S(n,h.create(l,l.length-1))),!0)}const jt=e=>$e(e,!1),Qt=e=>$e(e,!0),Xt=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=h.create([n.main]):n.main.empty||(r=h.create([h.cursor(n.main.head)])),r?(t(S(e,r)),!0):!1};function b(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,l=r.changeByRange(o=>{let{from:s,to:c}=o;if(s==c){let i=t(o);i<s?(n="delete.backward",i=F(e,i,!1)):i>s&&(n="delete.forward",i=F(e,i,!0)),s=Math.min(s,i),c=Math.max(c,i)}else s=F(e,s,!1),c=F(e,c,!0);return s==c?{range:o}:{changes:{from:s,to:c},range:h.cursor(s,s<o.head?-1:1)}});return l.changes.empty?!1:(e.dispatch(r.update(l,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?O.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function F(e,t,n){if(e instanceof O)for(let r of e.state.facet(O.atomicRanges).map(l=>l(e)))r.between(t,t,(l,o)=>{l<t&&o>t&&(t=n?o:l)});return t}const se=(e,t,n)=>b(e,r=>{let l=r.from,{state:o}=e,s=o.doc.lineAt(l),c,i;if(n&&!t&&l>s.from&&l<s.from+200&&!/[^ \t]/.test(c=s.text.slice(0,l-s.from))){if(c[c.length-1]==" ")return l-1;let f=ee(c,o.tabSize),u=f%j(o)||j(o);for(let a=0;a<u&&c[c.length-1-a]==" ";a++)l--;i=l}else i=T(s.text,l-s.from,t,t)+s.from,i==l&&s.number!=(t?o.doc.lines:1)?i+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(s.text.slice(i-s.from,l-s.from))&&(i=T(s.text,i-s.from,!1,!1)+s.from);return i}),_=e=>se(e,!1,!0),$n=e=>se(e,!1,!1),je=e=>se(e,!0,!1),Qe=(e,t)=>b(e,n=>{let r=n.head,{state:l}=e,o=l.doc.lineAt(r),s=l.charCategorizer(r);for(let c=null;;){if(r==(t?o.to:o.from)){r==n.head&&o.number!=(t?l.doc.lines:1)&&(r+=t?1:-1);break}let i=T(o.text,r-o.from,t)+o.from,f=o.text.slice(Math.min(r,i)-o.from,Math.max(r,i)-o.from),u=s(f);if(c!=null&&u!=c)break;(f!=" "||r!=n.head)&&(c=u),r=i}return r}),Xe=e=>Qe(e,!1),Yt=e=>Qe(e,!0),jn=e=>b(e,t=>e.moveByChar(t,!0,n=>le(e,t.head,n)).head),Zt=e=>b(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Qn=e=>b(e,t=>{let n=e.lineBlockAt(t.head).from;return t.head>n?n:Math.max(0,t.head-1)}),_t=e=>b(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),en=e=>b(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Xn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=[];for(let r=0,l="",o=e.doc.iter();;){if(o.next(),o.lineBreak||o.done){let s=l.search(/\s+$/);if(s>-1&&n.push({from:r-(l.length-s),to:r}),o.done)break;l=""}else l=o.value;r+=o.value.length}return n.length?(t(e.update({changes:n,userEvent:"delete"})),!0):!1},tn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:ke.of(["",""])},range:h.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},nn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>{if(!r.empty||r.from==0||r.from==e.doc.length)return{range:r};let l=r.from,o=e.doc.lineAt(l),s=l==o.from?l-1:T(o.text,l-o.from,!1)+o.from,c=l==o.to?l+1:T(o.text,l-o.from,!0)+o.from;return{changes:{from:s,to:c,insert:e.doc.slice(l,c).append(e.doc.slice(s,l))},range:h.cursor(c)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function q(e){let t=[],n=-1;for(let r of e.selection.ranges){let l=e.doc.lineAt(r.from),o=e.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=e.doc.lineAt(r.to-1)),n>=l.number){let s=t[t.length-1];s.to=o.to,s.ranges.push(r)}else t.push({from:l.from,to:o.to,ranges:[r]});n=o.number+1}return t}function Ye(e,t,n){if(e.readOnly)return!1;let r=[],l=[];for(let o of q(e)){if(n?o.to==e.doc.length:o.from==0)continue;let s=e.doc.lineAt(n?o.to+1:o.from-1),c=s.length+1;if(n){r.push({from:o.to,to:s.to},{from:o.from,insert:s.text+e.lineBreak});for(let i of o.ranges)l.push(h.range(Math.min(e.doc.length,i.anchor+c),Math.min(e.doc.length,i.head+c)))}else{r.push({from:s.from,to:o.from},{from:o.to,insert:e.lineBreak+s.text});for(let i of o.ranges)l.push(h.range(i.anchor-c,i.head-c))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:h.create(l,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}const rn=({state:e,dispatch:t})=>Ye(e,t,!1),on=({state:e,dispatch:t})=>Ye(e,t,!0);function Ze(e,t,n){if(e.readOnly)return!1;let r=[];for(let o of q(e))n?r.push({from:o.from,insert:e.doc.slice(o.from,o.to)+e.lineBreak}):r.push({from:o.to,insert:e.lineBreak+e.doc.slice(o.from,o.to)});let l=e.changes(r);return t(e.update({changes:l,selection:e.selection.map(l,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const ln=({state:e,dispatch:t})=>Ze(e,t,!1),sn=({state:e,dispatch:t})=>Ze(e,t,!0),cn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(q(t).map(({from:l,to:o})=>(l>0?l--:o<t.doc.length&&o++,{from:l,to:o}))),r=I(t.selection,l=>{let o;if(e.lineWrapping){let s=e.lineBlockAt(l.head),c=e.coordsAtPos(l.head,l.assoc||1);c&&(o=s.bottom+e.documentTop-c.bottom+e.defaultLineHeight/2)}return e.moveVertically(l,!0,o)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0},Yn=({state:e,dispatch:t})=>(t(e.update(e.replaceSelection(e.lineBreak),{scrollIntoView:!0,userEvent:"input"})),!0),Zn=({state:e,dispatch:t})=>(t(e.update(e.changeByRange(n=>{let r=/^\s*/.exec(e.doc.lineAt(n.from).text)[0];return{changes:{from:n.from,to:n.to,insert:e.lineBreak+r},range:h.cursor(n.from+r.length+1)}}),{scrollIntoView:!0,userEvent:"input"})),!0);function un(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=te(e).resolveInner(t),r=n.childBefore(t),l=n.childAfter(t),o;return r&&l&&r.to<=t&&l.from>=t&&(o=r.type.prop(Q.closedBy))&&o.indexOf(l.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(l.from).from&&!/\S/.test(e.sliceDoc(r.to,l.from))?{from:r.to,to:l.from}:null}const ye=_e(!1),fn=_e(!0);function _e(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(l=>{let{from:o,to:s}=l,c=t.doc.lineAt(o),i=!e&&o==s&&un(t,o);e&&(o=s=(s<=c.to?c:t.doc.lineAt(s)).to);let f=new Ce(t,{simulateBreak:o,simulateDoubleBreak:!!i}),u=De(f,o);for(u==null&&(u=ee(/^\s*/.exec(t.doc.lineAt(o).text)[0],t.tabSize));s<c.to&&/\s/.test(c.text[s-c.from]);)s++;i?{from:o,to:s}=i:o>c.from&&o<c.from+100&&!/\S/.test(c.text.slice(0,o))&&(o=c.from);let a=["",G(t,u)];return i&&a.push(G(t,f.lineIndent(c.from,-1))),{changes:{from:o,to:s,insert:ke.of(a)},range:h.cursor(o+1+a[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function ce(e,t){let n=-1;return e.changeByRange(r=>{let l=[];for(let s=r.from;s<=r.to;){let c=e.doc.lineAt(s);c.number>n&&(r.empty||r.to>c.from)&&(t(c,l,r),n=c.number),s=c.to+1}let o=e.changes(l);return{changes:l,range:h.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const an=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Ce(e,{overrideIndentation:o=>{let s=n[o];return s??-1}}),l=ce(e,(o,s,c)=>{let i=De(r,o.from);if(i==null)return;/\S/.test(o.text)||(i=0);let f=/^\s*/.exec(o.text)[0],u=G(e,i);(f!=u||c.from<o.from+f.length)&&(n[o.from]=i,s.push({from:o.from,to:o.from+f.length,insert:u}))});return l.changes.empty||t(e.update(l,{userEvent:"indent"})),!0},ie=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(ce(e,(n,r)=>{r.push({from:n.from,insert:e.facet(st)})}),{userEvent:"input.indent"})),!0),et=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(ce(e,(n,r)=>{let l=/^\s*/.exec(n.text)[0];if(!l)return;let o=ee(l,e.tabSize),s=0,c=G(e,Math.max(0,o-j(e)));for(;s<l.length&&s<c.length&&l.charCodeAt(s)==c.charCodeAt(s);)s++;r.push({from:n.from+s,to:n.from+l.length,insert:c.slice(s)})}),{userEvent:"delete.dedent"})),!0),hn=e=>(e.setTabFocusMode(),!0),_n=e=>(e.setTabFocusMode(2e3),!0),er=({state:e,dispatch:t})=>e.selection.ranges.some(n=>!n.empty)?ie({state:e,dispatch:t}):(t(e.update(e.replaceSelection(" "),{scrollIntoView:!0,userEvent:"input"})),!0),dn=[{key:"Ctrl-b",run:Te,shift:Je,preventDefault:!0},{key:"Ctrl-f",run:Oe,shift:we},{key:"Ctrl-p",run:Ge,shift:He},{key:"Ctrl-n",run:Ue,shift:qe},{key:"Ctrl-a",run:vt,shift:Wt},{key:"Ctrl-e",run:Rt,shift:Ht},{key:"Ctrl-d",run:je},{key:"Ctrl-h",run:_},{key:"Ctrl-k",run:Zt},{key:"Ctrl-Alt-h",run:Xe},{key:"Ctrl-o",run:tn},{key:"Ctrl-t",run:nn},{key:"Ctrl-v",run:Z}],mn=[{key:"ArrowLeft",run:Te,shift:Je,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Dt,shift:Gt,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Ot,shift:wt,preventDefault:!0},{key:"ArrowRight",run:Oe,shift:we,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:xt,shift:Ut,preventDefault:!0},{mac:"Cmd-ArrowRight",run:It,shift:zt,preventDefault:!0},{key:"ArrowUp",run:Ge,shift:He,preventDefault:!0},{mac:"Cmd-ArrowUp",run:de,shift:pe},{mac:"Ctrl-ArrowUp",run:fe,shift:ae},{key:"ArrowDown",run:Ue,shift:qe,preventDefault:!0},{mac:"Cmd-ArrowDown",run:me,shift:ge},{mac:"Ctrl-ArrowDown",run:Z,shift:he},{key:"PageUp",run:fe,shift:ae},{key:"PageDown",run:Z,shift:he},{key:"Home",run:Tt,shift:Jt,preventDefault:!0},{key:"Mod-Home",run:de,shift:pe},{key:"End",run:Et,shift:Pt,preventDefault:!0},{key:"Mod-End",run:me,shift:ge},{key:"Enter",run:ye,shift:ye},{key:"Mod-a",run:qt},{key:"Backspace",run:_,shift:_,preventDefault:!0},{key:"Delete",run:je,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Xe,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Yt,preventDefault:!0},{mac:"Mod-Backspace",run:_t,preventDefault:!0},{mac:"Mod-Delete",run:en,preventDefault:!0}].concat(dn.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),tr=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Mt,shift:Vt},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:bt,shift:Nt},{key:"Alt-ArrowUp",run:rn},{key:"Shift-Alt-ArrowUp",run:ln},{key:"Alt-ArrowDown",run:on},{key:"Shift-Alt-ArrowDown",run:sn},{key:"Mod-Alt-ArrowUp",run:jt},{key:"Mod-Alt-ArrowDown",run:Qt},{key:"Escape",run:Xt},{key:"Mod-Enter",run:fn},{key:"Alt-l",mac:"Ctrl-l",run:Kt},{key:"Mod-i",run:$t,preventDefault:!0},{key:"Mod-[",run:et},{key:"Mod-]",run:ie},{key:"Mod-Alt-\\",run:an},{key:"Shift-Mod-k",run:cn},{key:"Shift-Mod-\\",run:Ft},{key:"Mod-/",run:ct},{key:"Alt-A",run:ut},{key:"Ctrl-m",mac:"Shift-Alt-m",run:hn}].concat(mn),nr={key:"Tab",run:ie,shift:et};export{jt as addCursorAbove,Qt as addCursorBelow,Sn as blockComment,Cn as blockUncomment,sn as copyLineDown,ln as copyLineUp,Tn as cursorCharBackward,In as cursorCharBackwardLogical,En as cursorCharForward,On as cursorCharForwardLogical,Te as cursorCharLeft,Oe as cursorCharRight,me as cursorDocEnd,de as cursorDocStart,Rn as cursorGroupBackward,vn as cursorGroupForward,Fn as cursorGroupForwardWin,Dt as cursorGroupLeft,xt as cursorGroupRight,Tt as cursorLineBoundaryBackward,Et as cursorLineBoundaryForward,Ot as cursorLineBoundaryLeft,It as cursorLineBoundaryRight,Ue as cursorLineDown,Rt as cursorLineEnd,vt as cursorLineStart,Ge as cursorLineUp,Ft as cursorMatchingBracket,Z as cursorPageDown,fe as cursorPageUp,Un as cursorSubwordBackward,Gn as cursorSubwordForward,Mt as cursorSyntaxLeft,bt as cursorSyntaxRight,tr as defaultKeymap,_ as deleteCharBackward,$n as deleteCharBackwardStrict,je as deleteCharForward,Xe as deleteGroupBackward,Yt as deleteGroupForward,jn as deleteGroupForwardWin,cn as deleteLine,_t as deleteLineBoundaryBackward,en as deleteLineBoundaryForward,Zt as deleteToLineEnd,Qn as deleteToLineStart,Xn as deleteTrailingWhitespace,dn as emacsStyleKeymap,Dn as history,xn as historyField,bn as historyKeymap,et as indentLess,ie as indentMore,an as indentSelection,nr as indentWithTab,fn as insertBlankLine,Yn as insertNewline,ye as insertNewlineAndIndent,Zn as insertNewlineKeepIndent,er as insertTab,mt as invertedEffects,dt as isolateHistory,An as lineComment,Bn as lineUncomment,on as moveLineDown,rn as moveLineUp,Y as redo,Mn as redoDepth,gt as redoSelection,qt as selectAll,Pn as selectCharBackward,wn as selectCharBackwardLogical,Nn as selectCharForward,Jn as selectCharForwardLogical,Je as selectCharLeft,we as selectCharRight,ge as selectDocEnd,pe as selectDocStart,Wn as selectGroupBackward,zn as selectGroupForward,Hn as selectGroupForwardWin,Gt as selectGroupLeft,Ut as selectGroupRight,Kt as selectLine,Jt as selectLineBoundaryBackward,Pt as selectLineBoundaryForward,wt as selectLineBoundaryLeft,zt as selectLineBoundaryRight,qe as selectLineDown,Ht as selectLineEnd,Wt as selectLineStart,He as selectLineUp,Vn as selectMatchingBracket,he as selectPageDown,ae as selectPageUp,$t as selectParentSyntax,Kn as selectSubwordBackward,qn as selectSubwordForward,Vt as selectSyntaxLeft,Nt as selectSyntaxRight,Xt as simplifySelection,tn as splitLine,mn as standardKeymap,_n as temporarilySetTabFocusMode,ut as toggleBlockComment,ft as toggleBlockCommentByLine,ct as toggleComment,it as toggleLineComment,hn as toggleTabFocusMode,nn as transposeChars,Le as undo,Ln as undoDepth,pt as undoSelection};
@@ -1,2 +1,2 @@
1
- import{L as M,k as H,l as J,n as ee,o as te,e as ae}from"./index-BhbDxjJk.js";import{s as re,t as o}from"./index-P6iAB9yV.js";import{E as ne,L as oe}from"./index-BypqjF8L.js";import{i as le,e as se}from"./index-orsieMzN.js";import"./index-BHot-lnj.js";import"./index-891wE-Rj.js";const ie=36,R=1,ce=2,k=3,S=4,fe=5,de=6,Oe=7,me=8,ue=9,he=10,ke=11,Qe=12,ge=13,ve=14,xe=15,be=16,pe=17,q=18,Ce=19,$=20,A=21,L=22,Se=23,Pe=24;function y(t){return t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57}function ye(t){return t>=48&&t<=57||t>=97&&t<=102||t>=65&&t<=70}function h(t,e,r){for(let a=!1;;){if(t.next<0)return;if(t.next==e&&!a){t.advance();return}a=r&&!a&&t.next==92,t.advance()}}function we(t,e){e:for(;;){if(t.next<0)return;if(t.next==36){t.advance();for(let r=0;r<e.length;r++){if(t.next!=e.charCodeAt(r))continue e;t.advance()}if(t.next==36){t.advance();return}}else t.advance()}}function Te(t,e){let r="[{<(".indexOf(String.fromCharCode(e)),a=r<0?e:"]}>)".charCodeAt(r);for(;;){if(t.next<0)return;if(t.next==a&&t.peek(1)==39){t.advance(2);return}t.advance()}}function w(t,e){for(;!(t.next!=95&&!y(t.next));)e!=null&&(e+=String.fromCharCode(t.next)),t.advance();return e}function Ue(t){if(t.next==39||t.next==34||t.next==96){let e=t.next;t.advance(),h(t,e,!1)}else w(t)}function Z(t,e){for(;t.next==48||t.next==49;)t.advance();e&&t.next==e&&t.advance()}function D(t,e){for(;;){if(t.next==46){if(e)break;e=!0}else if(t.next<48||t.next>57)break;t.advance()}if(t.next==69||t.next==101)for(t.advance(),(t.next==43||t.next==45)&&t.advance();t.next>=48&&t.next<=57;)t.advance()}function j(t){for(;!(t.next<0||t.next==10);)t.advance()}function u(t,e){for(let r=0;r<e.length;r++)if(e.charCodeAt(r)==t)return!0;return!1}const P=` \r
1
+ import{L as M,k as H,l as J,n as ee,o as te,e as ae}from"./index-DPvZ-hhz.js";import{s as re,t as o}from"./index-CLOINL5U.js";import{E as ne,L as oe}from"./index-DA4Vv71z.js";import{i as le,e as se}from"./index-B0rzOjTL.js";import"./index-BHot-lnj.js";import"./index-891wE-Rj.js";const ie=36,R=1,ce=2,k=3,S=4,fe=5,de=6,Oe=7,me=8,ue=9,he=10,ke=11,Qe=12,ge=13,ve=14,xe=15,be=16,pe=17,q=18,Ce=19,$=20,A=21,L=22,Se=23,Pe=24;function y(t){return t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57}function ye(t){return t>=48&&t<=57||t>=97&&t<=102||t>=65&&t<=70}function h(t,e,r){for(let a=!1;;){if(t.next<0)return;if(t.next==e&&!a){t.advance();return}a=r&&!a&&t.next==92,t.advance()}}function we(t,e){e:for(;;){if(t.next<0)return;if(t.next==36){t.advance();for(let r=0;r<e.length;r++){if(t.next!=e.charCodeAt(r))continue e;t.advance()}if(t.next==36){t.advance();return}}else t.advance()}}function Te(t,e){let r="[{<(".indexOf(String.fromCharCode(e)),a=r<0?e:"]}>)".charCodeAt(r);for(;;){if(t.next<0)return;if(t.next==a&&t.peek(1)==39){t.advance(2);return}t.advance()}}function w(t,e){for(;!(t.next!=95&&!y(t.next));)e!=null&&(e+=String.fromCharCode(t.next)),t.advance();return e}function Ue(t){if(t.next==39||t.next==34||t.next==96){let e=t.next;t.advance(),h(t,e,!1)}else w(t)}function Z(t,e){for(;t.next==48||t.next==49;)t.advance();e&&t.next==e&&t.advance()}function D(t,e){for(;;){if(t.next==46){if(e)break;e=!0}else if(t.next<48||t.next>57)break;t.advance()}if(t.next==69||t.next==101)for(t.advance(),(t.next==43||t.next==45)&&t.advance();t.next>=48&&t.next<=57;)t.advance()}function j(t){for(;!(t.next<0||t.next==10);)t.advance()}function u(t,e){for(let r=0;r<e.length;r++)if(e.charCodeAt(r)==t)return!0;return!1}const P=` \r
2
2
  `;function V(t,e,r){let a=Object.create(null);a.true=a.false=fe,a.null=a.unknown=de;for(let n of t.split(" "))n&&(a[n]=$);for(let n of e.split(" "))n&&(a[n]=A);for(let n of(r||"").split(" "))n&&(a[n]=Pe);return a}const Be="array binary bit boolean char character clob date decimal double float int integer interval large national nchar nclob numeric object precision real smallint time timestamp varchar varying ",Xe="absolute action add after all allocate alter and any are as asc assertion at authorization before begin between both breadth by call cascade cascaded case cast catalog check close collate collation column commit condition connect connection constraint constraints constructor continue corresponding count create cross cube current current_date current_default_transform_group current_transform_group_for_type current_path current_role current_time current_timestamp current_user cursor cycle data day deallocate declare default deferrable deferred delete depth deref desc describe descriptor deterministic diagnostics disconnect distinct do domain drop dynamic each else elseif end end-exec equals escape except exception exec execute exists exit external fetch first for foreign found from free full function general get global go goto grant group grouping handle having hold hour identity if immediate in indicator initially inner inout input insert intersect into is isolation join key language last lateral leading leave left level like limit local localtime localtimestamp locator loop map match method minute modifies module month names natural nesting new next no none not of old on only open option or order ordinality out outer output overlaps pad parameter partial path prepare preserve primary prior privileges procedure public read reads recursive redo ref references referencing relative release repeat resignal restrict result return returns revoke right role rollback rollup routine row rows savepoint schema scroll search second section select session session_user set sets signal similar size some space specific specifictype sql sqlexception sqlstate sqlwarning start state static system_user table temporary then timezone_hour timezone_minute to trailing transaction translation treat trigger under undo union unique unnest until update usage user using value values view when whenever where while with without work write year zone ",T={backslashEscapes:!1,hashComments:!1,spaceAfterDashes:!1,slashComments:!1,doubleQuotedStrings:!1,doubleDollarQuotedStrings:!1,unquotedBitLiterals:!1,treatBitsAsBytes:!1,charSetCasts:!1,plsqlQuotingMechanism:!1,operatorChars:"*+-%<>!=&|~^/",specialVar:"?",identifierQuotes:'"',caseInsensitiveIdentifiers:!1,words:V(Xe,Be)};function Ie(t,e,r,a){let n={};for(let l in T)n[l]=(t.hasOwnProperty(l)?t:T)[l];return e&&(n.words=V(e,r||"",a)),n}function W(t){return new ne(e=>{var r;let{next:a}=e;if(e.advance(),u(a,P)){for(;u(e.next,P);)e.advance();e.acceptToken(ie)}else if(a==36&&t.doubleDollarQuotedStrings){let n=w(e,"");e.next==36&&(e.advance(),we(e,n),e.acceptToken(k))}else if(a==39||a==34&&t.doubleQuotedStrings)h(e,a,t.backslashEscapes),e.acceptToken(k);else if(a==35&&t.hashComments||a==47&&e.next==47&&t.slashComments)j(e),e.acceptToken(R);else if(a==45&&e.next==45&&(!t.spaceAfterDashes||e.peek(1)==32))j(e),e.acceptToken(R);else if(a==47&&e.next==42){e.advance();for(let n=1;;){let l=e.next;if(e.next<0)break;if(e.advance(),l==42&&e.next==47){if(n--,e.advance(),!n)break}else l==47&&e.next==42&&(n++,e.advance())}e.acceptToken(ce)}else if((a==101||a==69)&&e.next==39)e.advance(),h(e,39,!0),e.acceptToken(k);else if((a==110||a==78)&&e.next==39&&t.charSetCasts)e.advance(),h(e,39,t.backslashEscapes),e.acceptToken(k);else if(a==95&&t.charSetCasts)for(let n=0;;n++){if(e.next==39&&n>1){e.advance(),h(e,39,t.backslashEscapes),e.acceptToken(k);break}if(!y(e.next))break;e.advance()}else if(t.plsqlQuotingMechanism&&(a==113||a==81)&&e.next==39&&e.peek(1)>0&&!u(e.peek(1),P)){let n=e.peek(1);e.advance(2),Te(e,n),e.acceptToken(k)}else if(u(a,t.identifierQuotes)){const n=a==91?93:a;h(e,n,!1),e.acceptToken(Ce)}else if(a==40)e.acceptToken(Oe);else if(a==41)e.acceptToken(me);else if(a==123)e.acceptToken(ue);else if(a==125)e.acceptToken(he);else if(a==91)e.acceptToken(ke);else if(a==93)e.acceptToken(Qe);else if(a==59)e.acceptToken(ge);else if(t.unquotedBitLiterals&&a==48&&e.next==98)e.advance(),Z(e),e.acceptToken(L);else if((a==98||a==66)&&(e.next==39||e.next==34)){const n=e.next;e.advance(),t.treatBitsAsBytes?(h(e,n,t.backslashEscapes),e.acceptToken(Se)):(Z(e,n),e.acceptToken(L))}else if(a==48&&(e.next==120||e.next==88)||(a==120||a==88)&&e.next==39){let n=e.next==39;for(e.advance();ye(e.next);)e.advance();n&&e.next==39&&e.advance(),e.acceptToken(S)}else if(a==46&&e.next>=48&&e.next<=57)D(e,!0),e.acceptToken(S);else if(a==46)e.acceptToken(ve);else if(a>=48&&a<=57)D(e,!1),e.acceptToken(S);else if(u(a,t.operatorChars)){for(;u(e.next,t.operatorChars);)e.advance();e.acceptToken(xe)}else if(u(a,t.specialVar))e.next==a&&e.advance(),Ue(e),e.acceptToken(pe);else if(a==58||a==44)e.acceptToken(be);else if(y(a)){let n=w(e,String.fromCharCode(a));e.acceptToken(e.next==46||e.peek(-n.length-1)==46?q:(r=t.words[n.toLowerCase()])!==null&&r!==void 0?r:q)}})}const F=W(T),_e=oe.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:"⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement",maxTerm:38,nodeProps:[["isolate",-4,1,2,3,19,""]],skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:"RORO",tokenizers:[0,F],topRules:{Script:[0,25]},tokenPrec:0});function U(t){let e=t.cursor().moveTo(t.from,-1);for(;/Comment/.test(e.name);)e.moveTo(e.from,-1);return e.node}function v(t,e){let r=t.sliceString(e.from,e.to),a=/^([`'"\[])(.*)([`'"\]])$/.exec(r);return a?a[2]:r}function p(t){return t&&(t.name=="Identifier"||t.name=="QuotedIdentifier")}function Re(t,e){if(e.name=="CompositeIdentifier"){let r=[];for(let a=e.firstChild;a;a=a.nextSibling)p(a)&&r.push(v(t,a));return r}return[v(t,e)]}function N(t,e){for(let r=[];;){if(!e||e.name!=".")return r;let a=U(e);if(!p(a))return r;r.unshift(v(t,a)),e=U(a)}}function qe(t,e){let r=ae(t).resolveInner(e,-1),a=Ze(t.doc,r);return r.name=="Identifier"||r.name=="QuotedIdentifier"||r.name=="Keyword"?{from:r.from,quoted:r.name=="QuotedIdentifier"?t.doc.sliceString(r.from,r.from+1):null,parents:N(t.doc,U(r)),aliases:a}:r.name=="."?{from:e,quoted:null,parents:N(t.doc,r),aliases:a}:{from:e,quoted:null,parents:[],empty:!0,aliases:a}}const Le=new Set("where group having order union intersect except all distinct limit offset fetch for".split(" "));function Ze(t,e){let r;for(let n=e;!r;n=n.parent){if(!n)return null;n.name=="Statement"&&(r=n)}let a=null;for(let n=r.firstChild,l=!1,c=null;n;n=n.nextSibling){let i=n.name=="Keyword"?t.sliceString(n.from,n.to).toLowerCase():null,s=null;if(!l)l=i=="from";else if(i=="as"&&c&&p(n.nextSibling))s=v(t,n.nextSibling);else{if(i&&Le.has(i))break;c&&p(n)&&(s=v(t,n))}s&&(a||(a=Object.create(null)),a[s]=Re(t,c)),c=/Identifier$/.test(n.name)?n:null}return a}function De(t,e,r){return r.map(a=>({...a,label:a.label[0]==t?a.label:t+a.label+e,apply:void 0}))}const je=/^\w*$/,Ne=/^[`'"\[]?\w*[`'"\]]?$/;function z(t){return t.self&&typeof t.self.label=="string"}class B{constructor(e,r){this.idQuote=e,this.idCaseInsensitive=r,this.list=[],this.children=void 0}child(e){let r=this.children||(this.children=Object.create(null)),a=r[e];return a||(e&&!this.list.some(n=>n.label==e)&&this.list.push(E(e,"type",this.idQuote,this.idCaseInsensitive)),r[e]=new B(this.idQuote,this.idCaseInsensitive))}maybeChild(e){return this.children?this.children[e]:null}addCompletion(e){let r=this.list.findIndex(a=>a.label==e.label);r>-1?this.list[r]=e:this.list.push(e)}addCompletions(e){for(let r of e)this.addCompletion(typeof r=="string"?E(r,"property",this.idQuote,this.idCaseInsensitive):r)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):z(e)?this.addNamespace(e.children):this.addNamespaceObject(e)}addNamespaceObject(e){for(let r of Object.keys(e)){let a=e[r],n=null,l=r.replace(/\\?\./g,i=>i=="."?"\0":i).split("\0"),c=this;z(a)&&(n=a.self,a=a.children);for(let i=0;i<l.length;i++)n&&i==l.length-1&&c.addCompletion(n),c=c.child(l[i].replace(/\\\./g,"."));c.addNamespace(a)}}}function E(t,e,r,a){return new RegExp("^[a-z_][a-z_\\d]*$",a?"i":"").test(t)?{label:t,type:e}:{label:t,type:e,apply:r+t+K(r)}}function K(t){return t==="["?"]":t}function ze(t,e,r,a,n,l){var c;let i=((c=l==null?void 0:l.spec.identifierQuotes)===null||c===void 0?void 0:c[0])||'"',s=new B(i,!!(l!=null&&l.spec.caseInsensitiveIdentifiers)),d=n?s.child(n):null;return s.addNamespace(t),e&&(d||s).addCompletions(e),r&&s.addCompletions(r),d&&s.addCompletions(d.list),a&&s.addCompletions((d||s).child(a).list),O=>{let{parents:Q,from:I,quoted:_,empty:G,aliases:x}=qe(O.state,O.pos);if(G&&!O.explicit)return null;x&&Q.length==1&&(Q=x[Q[0]]||Q);let f=s;for(let m of Q){for(;!f.children||!f.children[m];)if(f==s&&d)f=d;else if(f==d&&a)f=f.child(a);else return null;let g=f.maybeChild(m);if(!g)return null;f=g}let b=f.list;if(f==s&&x&&(b=b.concat(Object.keys(x).map(m=>({label:m,type:"constant"})))),_){let m=_[0],g=K(m),Y=O.state.sliceDoc(O.pos,O.pos+1)==g;return{from:I,to:Y?O.pos+1:void 0,options:De(m,g,b),validFor:Ne}}else return{from:I,options:b,validFor:je}}}function Ee(t){return t==A?"type":t==$?"keyword":"variable"}function $e(t,e,r){let a=Object.keys(t).map(n=>r(e?n.toUpperCase():n,Ee(t[n])));return le(["QuotedIdentifier","String","LineComment","BlockComment","."],se(a))}let Ae=_e.configure({props:[J.add({Statement:ee()}),te.add({Statement(t,e){return{from:Math.min(t.from+100,e.doc.lineAt(t.from).to),to:t.to}},BlockComment(t){return{from:t.from+2,to:t.to-2}}}),re({Keyword:o.keyword,Type:o.typeName,Builtin:o.standard(o.name),Bits:o.number,Bytes:o.string,Bool:o.bool,Null:o.null,Number:o.number,String:o.string,Identifier:o.name,QuotedIdentifier:o.special(o.string),SpecialVar:o.special(o.name),LineComment:o.lineComment,BlockComment:o.blockComment,Operator:o.operator,"Semi Punctuation":o.punctuation,"( )":o.paren,"{ }":o.brace,"[ ]":o.squareBracket})]});class C{constructor(e,r,a){this.dialect=e,this.language=r,this.spec=a}get extension(){return this.language.extension}configureLanguage(e,r){return new C(this.dialect,this.language.configure(e,r),this.spec)}static define(e){let r=Ie(e,e.keywords,e.types,e.builtin),a=H.define({name:"sql",parser:Ae.configure({tokenizers:[{from:F,to:W(r)}]}),languageData:{commentTokens:{line:"--",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]}}});return new C(r,a,e)}}function Ve(t,e){return{label:t,type:e,boost:-1}}function We(t,e=!1,r){return $e(t.dialect.words,e,r||Ve)}function Fe(t){return t.schema?ze(t.schema,t.tables,t.schemas,t.defaultTable,t.defaultSchema,t.dialect||X):()=>null}function Ke(t){return t.schema?(t.dialect||X).language.data.of({autocomplete:Fe(t)}):[]}function tt(t={}){let e=t.dialect||X;return new M(e.language,[Ke(t),e.language.data.of({autocomplete:We(e,t.upperCaseKeywords,t.keywordCompletion)})])}const X=C.define({});export{C as SQLDialect,X as StandardSQL,We as keywordCompletionSource,Fe as schemaCompletionSource,tt as sql};