@uiw/react-codemirror 4.4.3 → 4.5.0

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.
@@ -0,0 +1,2 @@
1
+ /*! For license information please see index.min.js.LICENSE.txt */
2
+ !function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e(require("react"),require("@codemirror/basic-setup"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):"function"===typeof define&&define.amd?define(["react",,,,],e):"object"===typeof exports?exports["@uiw/codemirror"]=e(require("react"),require("@codemirror/basic-setup"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):t["@uiw/codemirror"]=e(t.React,t.CM["@codemirror/basic-setup"],t.CM["@codemirror/state"],t.CM["@codemirror/theme-one-dark"],t.CM["@codemirror/view"])}(self,(function(t,e,r,n,i){return(()=>{"use strict";var s={497:(t,e,r)=>{function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function i(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!==typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,s=[],o=!0,h=!1;try{for(r=r.call(t);!(o=(n=r.next()).done)&&(s.push(n.value),!e||s.length!==e);o=!0);}catch(l){h=!0,i=l}finally{try{o||null==r.return||r.return()}finally{if(h)throw i}}return s}}(t,e)||function(t,e){if(t){if("string"===typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}r.d(e,{U:()=>vt});var s=r(787),o=r(573),h=r(242);let l="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((t=>t?parseInt(t,36):1));for(let kt=1;kt<l.length;kt++)l[kt]+=l[kt-1];function u(t){for(let e=1;e<l.length;e+=2)if(l[e]>t)return l[e-1]<=t;return!1}function f(t){return t>=127462&&t<=127487}function a(t,e,r=!0,n=!0){return(r?c:d)(t,e,n)}function c(t,e,r){if(e==t.length)return e;e&&p(t.charCodeAt(e))&&g(t.charCodeAt(e-1))&&e--;let n=m(t,e);for(e+=b(n);e<t.length;){let i=m(t,e);if(8205==n||8205==i||r&&u(i))e+=b(i),n=i;else{if(!f(i))break;{let r=0,n=e-2;for(;n>=0&&f(m(t,n));)r++,n-=2;if(r%2==0)break;e+=2}}}return e}function d(t,e,r){for(;e>0;){let n=c(t,e-2,r);if(n<e)return n;e--}return 0}function p(t){return t>=56320&&t<57344}function g(t){return t>=55296&&t<56320}function m(t,e){let r=t.charCodeAt(e);if(!g(r)||e+1==t.length)return r;let n=t.charCodeAt(e+1);return p(n)?n-56320+(r-55296<<10)+65536:r}function b(t){return t<65536?1:2}function x(t,e,r=t.length){let n=0;for(let i=0;i<r;)9==t.charCodeAt(i)?(n+=e-n%e,i++):(n++,i=a(t,i));return n}class y{constructor(){}lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,r){let n=[];return this.decompose(0,t,n,2),r.length&&r.decompose(0,r.length,n,3),this.decompose(e,this.length,n,1),v.from(n,this.length-(e-t)+r.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){let r=[];return this.decompose(t,e,r,0),v.from(r,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),r=this.length-this.scanIdentical(t,-1),n=new C(this),i=new C(t);for(let s=e,o=e;;){if(n.next(s),i.next(s),s=0,n.lineBreak!=i.lineBreak||n.done!=i.done||n.value!=i.value)return!1;if(o+=n.value.length,n.done||o>=r)return!0}}iter(t=1){return new C(this,t)}iterRange(t,e=this.length){return new O(this,t,e)}iterLines(t,e){let r;if(null==t)r=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;r=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new _(r)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new w(t):v.from(w.split(t,[])):y.empty}}class w extends y{constructor(t,e=function(t){let e=-1;for(let r of t)e+=r.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,r,n){for(let i=0;;i++){let s=this.text[i],o=n+s.length;if((e?r:o)>=t)return new A(n,o,r,s);n=o+1,r++}}decompose(t,e,r,n){let i=t<=0&&e>=this.length?this:new w(S(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=r.pop(),e=k(i.text,t.text.slice(),0,i.length);if(e.length<=32)r.push(new w(e,t.length+i.length));else{let t=e.length>>1;r.push(new w(e.slice(0,t)),new w(e.slice(t)))}}else r.push(i)}replace(t,e,r){if(!(r instanceof w))return super.replace(t,e,r);let n=k(this.text,k(r.text,S(this.text,0,t)),e),i=this.length+r.length-(e-t);return n.length<=32?new w(n,i):v.from(w.split(n,[]),i)}sliceString(t,e=this.length,r="\n"){let n="";for(let i=0,s=0;i<=e&&s<this.text.length;s++){let o=this.text[s],h=i+o.length;i>t&&s&&(n+=r),t<h&&e>i&&(n+=o.slice(Math.max(0,t-i),e-i)),i=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let r=[],n=-1;for(let i of t)r.push(i),n+=i.length+1,32==r.length&&(e.push(new w(r,n)),r=[],n=-1);return n>-1&&e.push(new w(r,n)),e}}class v extends y{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let r of t)this.lines+=r.lines}lineInner(t,e,r,n){for(let i=0;;i++){let s=this.children[i],o=n+s.length,h=r+s.lines-1;if((e?h:o)>=t)return s.lineInner(t,e,r,n);n=o+1,r=h+1}}decompose(t,e,r,n){for(let i=0,s=0;s<=e&&i<this.children.length;i++){let o=this.children[i],h=s+o.length;if(t<=h&&e>=s){let i=n&((s<=t?1:0)|(h>=e?2:0));s>=t&&h<=e&&!i?r.push(o):o.decompose(t-s,e-s,r,i)}s=h+1}}replace(t,e,r){if(r.lines<this.lines)for(let n=0,i=0;n<this.children.length;n++){let s=this.children[n],o=i+s.length;if(t>=i&&e<=o){let h=s.replace(t-i,e-i,r),l=this.lines-s.lines+h.lines;if(h.lines<l>>4&&h.lines>l>>6){let i=this.children.slice();return i[n]=h,new v(i,this.length-(e-t)+r.length)}return super.replace(i,o,h)}i=o+1}return super.replace(t,e,r)}sliceString(t,e=this.length,r="\n"){let n="";for(let i=0,s=0;i<this.children.length&&s<=e;i++){let o=this.children[i],h=s+o.length;s>t&&i&&(n+=r),t<h&&e>s&&(n+=o.sliceString(t-s,e-s,r)),s=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof v))return 0;let r=0,[n,i,s,o]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,i+=e){if(n==s||i==o)return r;let h=this.children[n],l=t.children[i];if(h!=l)return r+h.scanIdentical(l,e);r+=h.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let r=0;for(let c of t)r+=c.lines;if(r<32){let r=[];for(let e of t)e.flatten(r);return new w(r,e)}let n=Math.max(32,r>>5),i=n<<1,s=n>>1,o=[],h=0,l=-1,u=[];function f(t){let e;if(t.lines>i&&t instanceof v)for(let r of t.children)f(r);else t.lines>s&&(h>s||!h)?(a(),o.push(t)):t instanceof w&&h&&(e=u[u.length-1])instanceof w&&t.lines+e.lines<=32?(h+=t.lines,l+=t.length+1,u[u.length-1]=new w(e.text.concat(t.text),e.length+1+t.length)):(h+t.lines>n&&a(),h+=t.lines,l+=t.length+1,u.push(t))}function a(){0!=h&&(o.push(1==u.length?u[0]:v.from(u,l)),l=-1,h=u.length=0)}for(let c of t)f(c);return a(),1==o.length?o[0]:new v(o,e)}}function k(t,e,r=0,n=1e9){for(let i=0,s=0,o=!0;s<t.length&&i<=n;s++){let h=t[s],l=i+h.length;l>=r&&(l>n&&(h=h.slice(0,n-i)),i<r&&(h=h.slice(r-i)),o?(e[e.length-1]+=h,o=!1):e.push(h)),i=l+1}return e}function S(t,e,r){return k(t,[""],e,r)}y.empty=new w([""],0);class C{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof w?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,n=this.nodes[r],i=this.offsets[r],s=i>>1,o=n instanceof w?n.text.length:n.children.length;if(s==(e>0?o:0)){if(0==r)return this.done=!0,this.value="",this;e>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&i)==(e>0?0:1)){if(this.offsets[r]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof w){let i=n.text[s+(e<0?-1:0)];if(this.offsets[r]+=e,i.length>Math.max(0,t))return this.value=0==t?i:e>0?i.slice(t):i.slice(0,i.length-t),this;t-=i.length}else{let i=n.children[s+(e<0?-1:0)];t>i.length?(t-=i.length,this.offsets[r]+=e):(e<0&&this.offsets[r]--,this.nodes.push(i),this.offsets.push(e>0?1:(i instanceof w?i.text.length:i.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class O{constructor(t,e,r){this.value="",this.done=!1,this.cursor=new C(t,e>r?-1:1),this.pos=e>r?t.length:0,this.from=Math.min(e,r),this.to=Math.max(e,r)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let r=e<0?this.pos-this.from:this.to-this.pos;t>r&&(t=r),r-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=r?n:e<0?n.slice(n.length-r):n.slice(0,r),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class _{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:r,value:n}=this.inner.next(t);return e?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(y.prototype[Symbol.iterator]=function(){return this.iter()},C.prototype[Symbol.iterator]=O.prototype[Symbol.iterator]=_.prototype[Symbol.iterator]=function(){return this});class A{constructor(t,e,r,n){this.from=t,this.to=e,this.number=r,this.text=n}get length(){return this.to-this.from}}var j=r(105);const P=1024;let E=0;class N{constructor(t,e){this.from=t,this.to=e}}class B{constructor(t={}){this.id=E++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=I.match(t)),e=>{let r=t(e);return void 0===r?null:[this,r]}}}B.closedBy=new B({deserialize:t=>t.split(" ")}),B.openedBy=new B({deserialize:t=>t.split(" ")}),B.group=new B({deserialize:t=>t.split(" ")}),B.contextHash=new B({perNode:!0}),B.lookAhead=new B({perNode:!0}),B.mounted=new B({perNode:!0});const T=Object.create(null);class I{constructor(t,e,r,n=0){this.name=t,this.props=e,this.id=r,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):T,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new I(t.name||"",e,t.id,r);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}return n}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(B.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let r in t)for(let n of r.split(" "))e[n]=t[r];return t=>{for(let r=t.prop(B.group),n=-1;n<(r?r.length:0);n++){let i=e[n<0?t.name:r[n]];if(i)return i}}}}I.none=new I("",Object.create(null),0,8);const M=new WeakMap,W=new WeakMap;class z{constructor(t,e,r,n,i){if(this.type=t,this.children=e,this.positions=r,this.length=n,this.props=null,i&&i.length){this.props=Object.create(null);for(let[t,e]of i)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=this.prop(B.mounted);if(t&&!t.overlay)return t.tree.toString();let e="";for(let r of this.children){let t=r.toString();t&&(e&&(e+=","),e+=t)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t,e=0){let r=null!=t&&M.get(this)||this.topNode,n=new J(r);return null!=t&&(n.moveTo(t,e),M.set(this,n._tree)),n}fullCursor(){return new J(this.topNode,1)}get topNode(){return new H(this,0,0,null)}resolve(t,e=0){let r=U(M.get(this)||this.topNode,t,e,!1);return M.set(this,r),r}resolveInner(t,e=0){let r=U(W.get(this)||this.topNode,t,e,!0);return W.set(this,r),r}iterate(t){let{enter:e,leave:r,from:n=0,to:i=this.length}=t;for(let s=this.cursor(),o=()=>s.node;;){let t=!1;if(s.from<=i&&s.to>=n&&(s.type.isAnonymous||!1!==e(s.type,s.from,s.to,o))){if(s.firstChild())continue;s.type.isAnonymous||(t=!0)}for(;t&&r&&r(s.type,s.from,s.to,o),t=s.type.isAnonymous,!s.nextSibling();){if(!s.parent())return;t=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:K(I.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,r)=>new z(this.type,t,e,r,this.propValues)),t.makeTree||((t,e,r)=>new z(I.none,t,e,r)))}static build(t){return function(t){var e;let{buffer:r,nodeSet:n,maxBufferLength:i=P,reused:s=[],minRepeatType:o=n.types.length}=t,h=Array.isArray(r)?new q(r,r.length):r,l=n.types,u=0,f=0;function a(t,e,r,b,x){let{id:y,start:w,end:v,size:k}=h,S=f;for(;k<0;){if(h.next(),-1==k){let e=s[y];return r.push(e),void b.push(w-t)}if(-3==k)return void(u=y);if(-4==k)return void(f=y);throw new RangeError(`Unrecognized record size: ${k}`)}let C,O,_=l[y],A=w-t;if(v-w<=i&&(O=g(h.pos-e,x))){let e=new Uint16Array(O.size-O.skip),r=h.pos-O.size,i=e.length;for(;h.pos>r;)i=m(O.start,e,i);C=new R(e,v-O.start,n),A=O.start-t}else{let t=h.pos-k;h.next();let e=[],r=[],n=y>=o?y:-1,s=0,l=v;for(;h.pos>t;)n>=0&&h.id==n&&h.size>=0?(h.end<=l-i&&(d(e,r,w,s,h.end,l,n,S),s=e.length,l=h.end),h.next()):a(w,t,e,r,n);if(n>=0&&s>0&&s<e.length&&d(e,r,w,s,w,l,n,S),e.reverse(),r.reverse(),n>-1&&s>0){let t=c(_);C=K(_,e,r,0,e.length,0,v-w,t,t)}else C=p(_,e,r,v-w,S-v)}r.push(C),b.push(A)}function c(t){return(e,r,n)=>{let i,s,o=0,h=e.length-1;if(h>=0&&(i=e[h])instanceof z){if(!h&&i.type==t&&i.length==n)return i;(s=i.prop(B.lookAhead))&&(o=r[h]+i.length+s)}return p(t,e,r,n,o)}}function d(t,e,r,i,s,o,h,l){let u=[],f=[];for(;t.length>i;)u.push(t.pop()),f.push(e.pop()+r-s);t.push(p(n.types[h],u,f,o-s,l-o)),e.push(s-r)}function p(t,e,r,n,i=0,s){if(u){let t=[B.contextHash,u];s=s?[t].concat(s):[t]}if(i>25){let t=[B.lookAhead,i];s=s?[t].concat(s):[t]}return new z(t,e,r,n,s)}function g(t,e){let r=h.fork(),n=0,s=0,l=0,u=r.end-i,f={size:0,start:0,skip:0};t:for(let i=r.pos-t;r.pos>i;){let t=r.size;if(r.id==e&&t>=0){f.size=n,f.start=s,f.skip=l,l+=4,n+=4,r.next();continue}let h=r.pos-t;if(t<0||h<i||r.start<u)break;let a=r.id>=o?4:0,c=r.start;for(r.next();r.pos>h;){if(r.size<0){if(-3!=r.size)break t;a+=4}else r.id>=o&&(a+=4);r.next()}s=c,n+=t,l+=a}return(e<0||n==t)&&(f.size=n,f.start=s,f.skip=l),f.size>4?f:void 0}function m(t,e,r){let{id:n,start:i,end:s,size:l}=h;if(h.next(),l>=0&&n<o){let o=r;if(l>4){let n=h.pos-(l-4);for(;h.pos>n;)r=m(t,e,r)}e[--r]=o,e[--r]=s-t,e[--r]=i-t,e[--r]=n}else-3==l?u=n:-4==l&&(f=n);return r}let b=[],x=[];for(;h.pos>0;)a(t.start||0,t.bufferStart||0,b,x,-1);let y=null!==(e=t.length)&&void 0!==e?e:b.length?x[0]+b[0].length:0;return new z(l[t.topID],b.reverse(),x.reverse(),y)}(t)}}z.empty=new z(I.none,[],[],0);class q{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new q(this.buffer,this.index)}}class R{constructor(t,e,r){this.buffer=t,this.length=e,this.set=r}get type(){return I.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],r=this.buffer[t+3],n=this.set.types[e],i=n.name;if(/\W/.test(i)&&!n.isError&&(i=JSON.stringify(i)),r==(t+=4))return i;let s=[];for(;t<r;)s.push(this.childString(t)),t=this.buffer[t+3];return i+"("+s.join(",")+")"}findChild(t,e,r,n,i){let{buffer:s}=this,o=-1;for(let h=t;h!=e&&!(L(i,n,s[h+1],s[h+2])&&(o=h,r>0));h=s[h+3]);return o}slice(t,e,r,n){let i=this.buffer,s=new Uint16Array(e-t);for(let o=t,h=0;o<e;)s[h++]=i[o++],s[h++]=i[o++]-r,s[h++]=i[o++]-r,s[h++]=i[o++]-t;return new R(s,n-r,this.set)}}function L(t,e,r,n){switch(t){case-2:return r<e;case-1:return n>=e&&r<e;case 0:return r<e&&n>e;case 1:return r<=e&&n>e;case 2:return n>e;case 4:return!0}}function D(t,e){let r=t.childBefore(e);for(;r;){let e=r.lastChild;if(!e||e.to!=r.to)break;e.type.isError&&e.from==e.to?(t=r,r=e.prevSibling):r=e}return t}function U(t,e,r,n){for(var i;t.from==t.to||(r<1?t.from>=e:t.from>e)||(r>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof H&&t.index<0?null:t.parent;if(!e)return t;t=e}if(n)for(let s=t,o=s.parent;o;s=o,o=s.parent)s instanceof H&&s.index<0&&(null===(i=o.enter(e,r,!0))||void 0===i?void 0:i.from)!=s.from&&(t=o);for(;;){let i=t.enter(e,r,n);if(!i)return t;t=i}}class H{constructor(t,e,r,n){this.node=t,this._from=e,this.index=r,this._parent=n}get type(){return this.node.type}get name(){return this.node.type.name}get from(){return this._from}get to(){return this._from+this.node.length}nextChild(t,e,r,n,i=0){for(let s=this;;){for(let{children:o,positions:h}=s.node,l=e>0?o.length:-1;t!=l;t+=e){let l=o[t],u=h[t]+s._from;if(L(n,r,u,u+l.length))if(l instanceof R){if(2&i)continue;let o=l.findChild(0,l.buffer.length,e,r-u,n);if(o>-1)return new $(new F(s,l,t,u),null,o)}else if(1&i||!l.type.isAnonymous||Z(l)){let o;if(!(1&i)&&l.props&&(o=l.prop(B.mounted))&&!o.overlay)return new H(o.tree,u,t,s);let h=new H(l,u,t,s);return 1&i||!h.type.isAnonymous?h:h.nextChild(e<0?l.children.length-1:0,e,r,n)}}if(1&i||!s.type.isAnonymous)return null;if(t=s.index>=0?s.index+e:e<0?-1:s._parent.node.children.length,s=s._parent,!s)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this.node.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this.node.children.length-1,-1,t,-2)}enter(t,e,r=!0,n=!0){let i;if(r&&(i=this.node.prop(B.mounted))&&i.overlay){let r=t-this.from;for(let{from:t,to:n}of i.overlay)if((e>0?t<=r:t<r)&&(e<0?n>=r:n>r))return new H(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,n?0:2)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get cursor(){return new J(this)}get tree(){return this.node}toTree(){return this.node}resolve(t,e=0){return U(this,t,e,!1)}resolveInner(t,e=0){return U(this,t,e,!0)}enterUnfinishedNodesBefore(t){return D(this,t)}getChild(t,e=null,r=null){let n=V(this,t,e,r);return n.length?n[0]:null}getChildren(t,e=null,r=null){return V(this,t,e,r)}toString(){return this.node.toString()}}function V(t,e,r,n){let i=t.cursor,s=[];if(!i.firstChild())return s;if(null!=r)for(;!i.type.is(r);)if(!i.nextSibling())return s;for(;;){if(null!=n&&i.type.is(n))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return null==n?s:[]}}class F{constructor(t,e,r,n){this.parent=t,this.buffer=e,this.index=r,this.start=n}}class ${constructor(t,e,r){this.context=t,this._parent=e,this.index=r,this.type=t.buffer.set.types[t.buffer.buffer[r]]}get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}child(t,e,r){let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,r);return i<0?null:new $(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,r,n=!0){if(!n)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new $(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new $(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new $(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get cursor(){return new J(this)}get tree(){return null}toTree(){let t=[],e=[],{buffer:r}=this.context,n=this.index+4,i=r.buffer[this.index+3];if(i>n){let s=r.buffer[this.index+1],o=r.buffer[this.index+2];t.push(r.slice(n,i,s,o)),e.push(0)}return new z(this.type,t,e,this.to-this.from)}resolve(t,e=0){return U(this,t,e,!1)}resolveInner(t,e=0){return U(this,t,e,!0)}enterUnfinishedNodesBefore(t){return D(this,t)}toString(){return this.context.buffer.childString(this.index)}getChild(t,e=null,r=null){let n=V(this,t,e,r);return n.length?n[0]:null}getChildren(t,e=null,r=null){return V(this,t,e,r)}}class J{constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof H)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}get name(){return this.type.name}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:r,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=r+n.buffer[t+1],this.to=r+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof H?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,r){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree.node.children.length-1:0,t,e,r,this.mode));let{buffer:n}=this.buffer,i=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,r);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,r=!0,n=!0){return this.buffer?!!n&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,r&&!(1&this.mode),n))}parent(){if(!this.buffer)return this.yieldNode(1&this.mode?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=1&this.mode?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,r=this.stack.length-1;if(t<0){let t=r<0?0:this.stack[r]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(r<0?e.buffer.length:e.buffer[this.stack[r]+3]))return this.yieldBuf(t)}return r<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,r,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:r}=n)}else({index:e,_parent:r}=this._tree);for(;r;({index:e,_parent:r}=r))if(e>-1)for(let n=e+t,i=t<0?-1:r.node.children.length;n!=i;n+=t){let t=r.node.children[n];if(1&this.mode||t instanceof R||!t.type.isAnonymous||Z(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,r=0;if(t&&t.context==this.buffer)t:for(let n=this.index,i=this.stack.length;i>=0;){for(let s=t;s;s=s._parent)if(s.index==n){if(n==this.index)return s;e=s,r=i+1;break t}n=this.stack[--i]}for(let n=r;n<this.stack.length;n++)e=new $(this.buffer,e,this.stack[n]);return this.bufferNode=new $(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree.node}}function Z(t){return t.children.some((t=>t instanceof R||!t.type.isAnonymous||Z(t)))}const Y=new WeakMap;function G(t,e){if(!t.isAnonymous||e instanceof R||e.type!=t)return 1;let r=Y.get(e);if(null==r){r=1;for(let n of e.children){if(n.type!=t||!(n instanceof z)){r=1;break}r+=G(t,n)}Y.set(e,r)}return r}function K(t,e,r,n,i,s,o,h,l){let u=0;for(let d=n;d<i;d++)u+=G(t,e[d]);let f=Math.ceil(1.5*u/8),a=[],c=[];return function e(r,n,i,o,h){for(let u=i;u<o;){let i=u,d=n[u],p=G(t,r[u]);for(u++;u<o;u++){let e=G(t,r[u]);if(p+e>=f)break;p+=e}if(u==i+1){if(p>f){let t=r[i];e(t.children,t.positions,0,t.children.length,n[i]+h);continue}a.push(r[i])}else{let e=n[u-1]+r[u-1].length-d;a.push(K(t,r,n,i,u,d,e,null,l))}c.push(d+h-s)}}(e,r,n,i,0),(h||l)(a,c,o)}class Q{constructor(t,e,r,n,i=!1,s=!1){this.from=t,this.to=e,this.tree=r,this.offset=n,this.open=(i?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],r=!1){let n=[new Q(0,t.length,t,0,!1,r)];for(let i of e)i.to>t.length&&n.push(i);return n}static applyChanges(t,e,r=128){if(!e.length)return t;let n=[],i=1,s=t.length?t[0]:null;for(let o=0,h=0,l=0;;o++){let u=o<e.length?e[o]:null,f=u?u.fromA:1e9;if(f-h>=r)for(;s&&s.from<f;){let e=s;if(h>=e.from||f<=e.to||l){let t=Math.max(e.from,h)-l,r=Math.min(e.to,f)-l;e=t>=r?null:new Q(t,r,e.tree,e.offset+l,o>0,!!u)}if(e&&n.push(e),s.to>f)break;s=i<t.length?t[i++]:null}if(!u)break;h=u.toA,l=u.toA-u.toB}return n}}class X{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new B({perNode:!0});const tt=new B;class et{constructor(t,e,r,n=[]){this.data=t,this.topNode=r,h.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(h.EditorState.prototype,"tree",{get(){return nt(this)}}),this.parser=e,this.extension=[at.of(this),h.EditorState.languageData.of(((t,e,r)=>t.facet(rt(t,e,r))))].concat(n)}isActiveAt(t,e,r=-1){return rt(t,e,r)==this.data}findRegions(t){let e=t.facet(at);if((null===e||void 0===e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let r=[],n=(t,e)=>{if(t.prop(tt)==this.data)return void r.push({from:e,to:e+t.length});let i=t.prop(B.mounted);if(i){if(i.tree.prop(tt)==this.data){if(i.overlay)for(let t of i.overlay)r.push({from:t.from+e,to:t.to+e});else r.push({from:e,to:e+t.length});return}if(i.overlay){let t=r.length;if(n(i.tree,i.overlay[0].from+e),r.length>t)return}}for(let r=0;r<t.children.length;r++){let i=t.children[r];i instanceof z&&n(i,t.positions[r]+e)}};return n(nt(t),0),r}get allowsNesting(){return!0}}function rt(t,e,r){let n=t.facet(at);if(!n)return null;let i=n.data;if(n.allowsNesting)for(let s=nt(t).topNode;s;s=s.enter(e,r,!0,!1))i=s.type.prop(tt)||i;return i}et.setState=h.StateEffect.define();function nt(t){let e=t.field(et.state,!1);return e?e.tree:z.empty}class it{constructor(t,e=t.length){this.doc=t,this.length=e,this.cursorPos=0,this.string="",this.cursor=t.iter()}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let r=this.cursorPos-this.string.length;return t<r||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-r,e-r)}}let st=null;class ot{constructor(t,e,r=[],n,i,s,o,h){this.parser=t,this.state=e,this.fragments=r,this.tree=n,this.treeLen=i,this.viewport=s,this.skipped=o,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}startParse(){return this.parser.startParse(new it(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=z.empty&&this.isDone(null!==e&&void 0!==e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var r;let n=Date.now()+t;for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let t=this.parse.advance();if(t){if(this.fragments=this.withoutTempSkipped(Q.addTree(t,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(r=this.parse.stoppedAt)&&void 0!==r?r:this.state.doc.length,this.tree=t,this.parse=null,!(this.treeLen<(null!==e&&void 0!==e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(Date.now()>n)return!1}}))}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext((()=>{for(;!(e=this.parse.advance()););})),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(Q.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=st;st=this;try{return t()}finally{st=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=ht(t,e.from,e.to);return t}changes(t,e){let{fragments:r,tree:n,treeLen:i,viewport:s,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges(((t,r,n,i)=>e.push({fromA:t,toA:r,fromB:n,toB:i}))),r=Q.applyChanges(r,e),n=z.empty,i=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){o=[];for(let e of this.skipped){let r=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);r<n&&o.push({from:r,to:n})}}}return new ot(this.parser,e,r,n,i,s,o,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:e,to:n}=this.skipped[r];e<t.to&&n>t.from&&(this.fragments=ht(this.fragments,e,n),this.skipped.splice(r--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends class{startParse(t,e,r){return"string"==typeof t&&(t=new X(t)),r=r?r.length?r.map((t=>new N(t.from,t.to))):[new N(0,0)]:[new N(0,t.length)],this.createParse(t,e||[],r)}parse(t,e,r){let n=this.startParse(t,e,r);for(;;){let t=n.advance();if(t)return t}}}{createParse(e,r,n){let i=n[0].from,s=n[n.length-1].to;return{parsedPos:i,advance(){let e=st;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=s,new z(I.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return st}}function ht(t,e,r){return Q.applyChanges(t,[{fromA:e,toA:r,fromB:e,toB:r}])}class lt{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged)return this;let e=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,r)||e.takeTree(),new lt(e)}static init(t){let e=Math.min(3e3,t.doc.length),r=new ot(t.facet(at).parser,t,[],z.empty,0,{from:0,to:e},[],null);return r.work(20,e)||r.takeTree(),new lt(r)}}et.state=h.StateField.define({create:lt.init,update(t,e){for(let r of e.effects)if(r.is(et.setState))return r.value;return e.startState.facet(at)!=e.state.facet(at)?lt.init(e.state):t.apply(e)}});let ut=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(ut=t=>{let e=-1,r=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(r):cancelIdleCallback(e)});const ft=j.ViewPlugin.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(et.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),t.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(et.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=ut(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:n}}=this.view,i=r.field(et.state);if(i.tree==i.context.tree&&i.context.isDone(n+1e5))return;let s=Math.min(this.chunkBudget,100,t?Math.max(25,t.timeRemaining()-5):1e9),o=i.context.treeLen<n&&r.doc.length>n+1e3,h=i.context.work(s,n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(h||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:et.setState.of(new lt(i.context))})),this.chunkBudget>0&&(!h||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>(0,j.logException)(this.view.state,t))).then((()=>this.workScheduled--)),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return this.working||this.workScheduled>0}},{eventHandlers:{focus(){this.scheduleWork()}}}),at=h.Facet.define({combine:t=>t.length?t[0]:null,enables:[et.state,ft]});const ct=h.Facet.define({combine:t=>{if(!t.length)return" ";if(!/^(?: +|\t+)$/.test(t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return t[0]}});function dt(t){let e=t.facet(ct);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function pt(t,e){let r="",n=t.tabSize;if(9==t.facet(ct).charCodeAt(0))for(;e>=n;)r+="\t",e-=n;for(let i=0;i<e;i++)r+=" ";return r}function gt(t,e){let r=-1;return t.changeByRange((n=>{let i=[];for(let o=n.from;o<=n.to;){let s=t.doc.lineAt(o);s.number>r&&(n.empty||n.to>s.from)&&(e(s,i,n),r=s.number),o=s.to+1}let s=t.changes(i);return{changes:i,range:h.EditorSelection.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}}))}const mt=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(gt(t,((e,r)=>{r.push({from:e.from,insert:t.facet(ct)})})),{userEvent:"input.indent"})),!0),bt=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(gt(t,((e,r)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let i=x(n,t.tabSize),s=0,o=pt(t,Math.max(0,i-dt(t)));for(;s<n.length&&s<o.length&&n.charCodeAt(s)==o.charCodeAt(s);)s++;r.push({from:e.from+s,to:e.from+n.length,insert:o.slice(s)})})),{userEvent:"delete.dedent"})),!0),xt={key:"Tab",run:mt,shift:bt};var yt=r(362),wt=j.EditorView.theme({"&":{backgroundColor:"#fff"}},{dark:!1});function vt(t){var e=t.value,r=t.selection,n=t.onChange,l=t.onUpdate,u=t.extensions,f=void 0===u?[]:u,a=t.autoFocus,c=t.theme,d=void 0===c?"light":c,p=t.height,g=void 0===p?"":p,m=t.minHeight,b=void 0===m?"":m,x=t.maxHeight,y=void 0===x?"":x,w=t.placeholder,v=void 0===w?"":w,k=t.width,S=void 0===k?"":k,C=t.minWidth,O=void 0===C?"":C,_=t.maxWidth,A=void 0===_?"":_,P=t.editable,E=void 0===P||P,N=t.indentWithTab,B=void 0===N||N,T=t.basicSetup,I=void 0===T||T,M=t.root,W=i((0,s.useState)(t.container),2),z=W[0],q=W[1],R=i((0,s.useState)(),2),L=R[0],D=R[1],U=i((0,s.useState)(),2),H=U[0],V=U[1],F=j.EditorView.theme({"&":{height:g,minHeight:b,maxHeight:y,width:S,minWidth:O,maxWidth:A}}),$=[j.EditorView.updateListener.of((function(t){if(t.docChanged&&"function"===typeof n){var e=t.state.doc.toString();n(e,t)}})),F];switch(B&&$.unshift(j.keymap.of([xt])),I&&$.unshift(o.basicSetup),v&&$.unshift((0,j.placeholder)(v)),d){case"light":$.push(wt);break;case"dark":$.push(yt.oneDark);break;default:$.push(d)}return!1===E&&$.push(j.EditorView.editable.of(!1)),l&&"function"===typeof l&&$.push(j.EditorView.updateListener.of(l)),$=$.concat(f),(0,s.useEffect)((function(){if(z&&!H){var t=h.EditorState.create({doc:e,selection:r,extensions:$});if(V(t),!L){var n=new j.EditorView({state:t,parent:z,root:M});D(n)}}}),[z,H]),(0,s.useEffect)((function(){return function(){L&&(L.destroy(),D(void 0))}}),[L]),(0,s.useEffect)((function(){a&&L&&L.focus()}),[a,L]),(0,s.useEffect)((function(){var t=L?L.state.doc.toString():"";L&&e!==t&&L.dispatch({changes:{from:0,to:t.length,insert:e||""}})}),[e,L]),(0,s.useEffect)((function(){L&&L.dispatch({effects:h.StateEffect.reconfigure.of($)})}),[d,f,g,b,y,S,v,O,A,E,B,I]),{state:H,setState:V,view:L,setView:D,container:z,setContainer:q}}},323:t=>{var e=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}t.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map((function(t){return e[t]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(t){n[t]=t})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(i){return!1}}()?Object.assign:function(t,s){for(var o,h,l=i(t),u=1;u<arguments.length;u++){for(var f in o=Object(arguments[u]))r.call(o,f)&&(l[f]=o[f]);if(e){h=e(o);for(var a=0;a<h.length;a++)n.call(o,h[a])&&(l[h[a]]=o[h[a]])}}return l}},638:(t,e,r)=>{r(323);var n=r(787),i=60103;if(60107,"function"===typeof Symbol&&Symbol.for){var s=Symbol.for;i=s("react.element"),s("react.fragment")}var o=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,h=Object.prototype.hasOwnProperty,l={key:!0,ref:!0,__self:!0,__source:!0};function u(t,e,r){var n,s={},u=null,f=null;for(n in void 0!==r&&(u=""+r),void 0!==e.key&&(u=""+e.key),void 0!==e.ref&&(f=e.ref),e)h.call(e,n)&&!l.hasOwnProperty(n)&&(s[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps)void 0===s[n]&&(s[n]=e[n]);return{$$typeof:i,type:t,key:u,ref:f,props:s,_owner:o.current}}e.jsx=u},724:(t,e,r)=>{t.exports=r(638)},787:e=>{e.exports=t},573:t=>{t.exports=e},242:t=>{t.exports=r},362:t=>{t.exports=n},105:t=>{t.exports=i},683:(t,e,r)=>{function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}r.d(e,{Z:()=>s})},925:(t,e,r)=>{function n(t,e){if(null==t)return{};var r,n,i=function(t,e){if(null==t)return{};var r,n,i={},s=Object.keys(t);for(n=0;n<s.length;n++)r=s[n],e.indexOf(r)>=0||(i[r]=t[r]);return i}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(n=0;n<s.length;n++)r=s[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(i[r]=t[r])}return i}r.d(e,{Z:()=>n})}},o={};function h(t){var e=o[t];if(void 0!==e)return e.exports;var r=o[t]={exports:{}};return s[t](r,r.exports,h),r.exports}h.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return h.d(e,{a:e}),e},h.d=(t,e)=>{for(var r in e)h.o(e,r)&&!h.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},h.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),h.r=t=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var l={};return(()=>{h.r(l),h.d(l,{useCodeMirror:()=>i.U,default:()=>p});var t=h(683),e=h(925),r=h(787),n=h.n(r),i=h(497),s=h(724),o=h(105),u={};for(const h in o)"default"!==h&&(u[h]=()=>o[h]);h.d(l,u);var f=h(573);u={};for(const h in f)"default"!==h&&(u[h]=()=>f[h]);h.d(l,u);var a=h(242);u={};for(const h in a)"default"!==h&&(u[h]=()=>a[h]);h.d(l,u);var c=["className","value","selection","extensions","onChange","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","root"],d=n().forwardRef((function(n,o){var h=n.className,l=n.value,u=void 0===l?"":l,f=n.selection,a=n.extensions,d=void 0===a?[]:a,p=n.onChange,g=n.onUpdate,m=n.autoFocus,b=n.theme,x=void 0===b?"light":b,y=n.height,w=n.minHeight,v=n.maxHeight,k=n.width,S=n.minWidth,C=n.maxWidth,O=n.basicSetup,_=n.placeholder,A=n.indentWithTab,j=n.editable,P=n.root,E=(0,e.Z)(n,c),N=(0,r.useRef)(null),B=(0,i.U)({container:N.current,root:P,value:u,autoFocus:m,theme:x,height:y,minHeight:w,maxHeight:v,width:k,minWidth:S,maxWidth:C,basicSetup:O,placeholder:_,indentWithTab:A,editable:j,selection:f,onChange:p,onUpdate:g,extensions:d}),T=B.state,I=B.view,M=B.container,W=B.setContainer;if((0,r.useImperativeHandle)(o,(function(){return{editor:M,state:T,view:I}}),[M,T,I]),(0,r.useEffect)((function(){W(N.current)}),[]),"string"!==typeof u)throw new Error("value must be typeof string but got ".concat(typeof u));var z="string"===typeof x?"cm-theme-".concat(x):"cm-theme";return(0,s.jsx)("div",(0,t.Z)({ref:N,className:"".concat(z).concat(h?" ".concat(h):"")},E))}));d.displayName="CodeMirror";const p=d})(),l})()}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-codemirror",
3
- "version": "4.4.3",
3
+ "version": "4.5.0",
4
4
  "description": "CodeMirror component for React.",
5
5
  "homepage": "https://uiwjs.github.io/react-codemirror",
6
6
  "main": "cjs/index.js",
@@ -13,8 +13,8 @@
13
13
  "prepare": "husky install && npm run build",
14
14
  "watch": "tsbb watch",
15
15
  "build": "tsbb build",
16
- "bundle": "kkt build --bundle",
17
- "bundle:min": "kkt build --bundle --mini --no-emptyDir",
16
+ "bundle": "ncc build src/index.tsx --target web",
17
+ "bundle:min": "ncc build src/index.tsx --target web --minify",
18
18
  "test": "tsbb test --env=jsdom",
19
19
  "coverage": "tsbb test --coverage --bail",
20
20
  "doc": "kkt build --app-src ./website",
@@ -61,18 +61,18 @@
61
61
  "react-dom": ">=16.8.0"
62
62
  },
63
63
  "dependencies": {
64
- "@babel/runtime": "^7.16.3",
65
- "@codemirror/basic-setup": "^0.19.0",
66
- "@codemirror/state": "^0.19.5",
64
+ "@babel/runtime": "^7.17.2",
65
+ "@codemirror/basic-setup": "^0.19.1",
66
+ "@codemirror/state": "^0.19.9",
67
67
  "@codemirror/theme-one-dark": "^0.19.1",
68
- "@codemirror/view": "^0.19.15"
68
+ "@codemirror/view": "^0.19.45"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@codemirror/lang-cpp": "0.19.1",
72
72
  "@codemirror/lang-html": "0.19.4",
73
73
  "@codemirror/lang-java": "0.19.1",
74
74
  "@codemirror/lang-javascript": "0.19.7",
75
- "@codemirror/lang-json": "0.19.1",
75
+ "@codemirror/lang-json": "0.19.2",
76
76
  "@codemirror/lang-lezer": "0.19.1",
77
77
  "@codemirror/lang-markdown": "0.19.6",
78
78
  "@codemirror/lang-php": "0.19.1",
@@ -81,12 +81,12 @@
81
81
  "@codemirror/lang-sql": "0.19.4",
82
82
  "@codemirror/lang-xml": "0.19.2",
83
83
  "@codemirror/legacy-modes": "0.19.0",
84
- "@codemirror/stream-parser": "0.19.5",
85
- "@kkt/less-modules": "7.1.0",
86
- "@kkt/raw-modules": "7.1.0",
87
- "@kkt/react-library": "7.1.0",
88
- "@kkt/scope-plugin-options": "7.1.0",
89
- "@types/react": "17.0.38",
84
+ "@codemirror/stream-parser": "0.19.6",
85
+ "@kkt/less-modules": "7.1.1",
86
+ "@kkt/ncc": "1.0.5",
87
+ "@kkt/raw-modules": "7.1.1",
88
+ "@kkt/scope-plugin-options": "7.1.1",
89
+ "@types/react": "17.0.39",
90
90
  "@types/react-dom": "17.0.11",
91
91
  "@types/react-test-renderer": "17.0.1",
92
92
  "@uiw/react-github-corners": "1.5.3",
@@ -95,13 +95,13 @@
95
95
  "@uiw/reset.css": "1.0.5",
96
96
  "code-example": "3.3.1",
97
97
  "husky": "7.0.4",
98
- "kkt": "7.1.0",
98
+ "kkt": "7.1.5",
99
99
  "lint-staged": "12.3.4",
100
100
  "prettier": "2.5.1",
101
101
  "react": "17.0.2",
102
102
  "react-dom": "17.0.2",
103
103
  "react-test-renderer": "17.0.2",
104
- "tsbb": "3.5.6"
104
+ "tsbb": "3.7.0"
105
105
  },
106
106
  "browserslist": {
107
107
  "production": [