@uiw/react-codemirror 4.5.2 → 4.7.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.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see codemirror.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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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 B{constructor(t,e){this.from=t,this.to=e}}class N{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]}}}N.closedBy=new N({deserialize:t=>t.split(" ")}),N.openedBy=new N({deserialize:t=>t.split(" ")}),N.group=new N({deserialize:t=>t.split(" ")}),N.contextHash=new N({perNode:!0}),N.lookAhead=new N({perNode:!0}),N.mounted=new N({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(N.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(N.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(N.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(N.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=[N.contextHash,u];s=s?[t].concat(s):[t]}if(i>25){let t=[N.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(N.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(N.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 N({perNode:!0});const tt=new N;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(N.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 B(t.from,t.to))):[new B(0,0)]:[new B(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,B=t.indentWithTab,N=void 0===B||B,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(N&&$.unshift(j.keymap.of([xt])),I&&(Array.isArray(o.basicSetup)&&o.basicSetup.map((function(t){return t.value&&Array.isArray(t.value)&&(t.value=t.value.map((function(t){if("Mod-f"!==t.key)return t})).filter(Boolean)),t})),$.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)}}return function(){L&&D(void 0)}}),[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,N,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,{default:()=>p,useCodeMirror:()=>i.U});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),B=(0,r.useRef)(null),N=(0,i.U)({container:B.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=N.state,I=N.view,M=N.container,W=N.setContainer;if((0,r.useImperativeHandle)(o,(function(){return{editor:M,state:T,view:I}}),[M,T,I]),(0,r.useEffect)((function(){W(B.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:B,className:"".concat(z).concat(h?" ".concat(h):"")},E))}));d.displayName="CodeMirror";const p=d})(),l})()}));
2
+ !function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("react"),require("@codemirror/basic-setup"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):"function"===typeof define&&define.amd?define(["react",,,,],t):"object"===typeof exports?exports["@uiw/codemirror"]=t(require("react"),require("@codemirror/basic-setup"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):e["@uiw/codemirror"]=t(e.React,e.CM["@codemirror/basic-setup"],e.CM["@codemirror/state"],e.CM["@codemirror/theme-one-dark"],e.CM["@codemirror/view"])}(self,((e,t,r,n,i)=>(()=>{"use strict";var s={963:(e,t,r)=>{function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,s=[],o=!0,l=!1;try{for(r=r.call(e);!(o=(n=r.next()).done)&&(s.push(n.value),!t||s.length!==t);o=!0);}catch(a){l=!0,i=a}finally{try{o||null==r.return||r.return()}finally{if(l)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"===typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}(e,t)||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(t,{U:()=>tt});var s=r(787),o=r(573),l=r(242),a=r(105);const h=1024;let u=0;class f{constructor(e,t){this.from=e,this.to=t}}class c{constructor(e={}){this.id=u++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=p.match(e)),t=>{let r=e(t);return void 0===r?null:[this,r]}}}c.closedBy=new c({deserialize:e=>e.split(" ")}),c.openedBy=new c({deserialize:e=>e.split(" ")}),c.group=new c({deserialize:e=>e.split(" ")}),c.contextHash=new c({perNode:!0}),c.lookAhead=new c({perNode:!0}),c.mounted=new c({perNode:!0});const d=Object.create(null);class p{constructor(e,t,r,n=0){this.name=e,this.props=t,this.id=r,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):d,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),n=new p(e.name||"",t,e.id,r);if(e.props)for(let i of e.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");t[i[0].id]=i[1]}return n}prop(e){return this.props[e.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(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(c.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let r in e)for(let n of r.split(" "))t[n]=e[r];return e=>{for(let r=e.prop(c.group),n=-1;n<(r?r.length:0);n++){let i=t[n<0?e.name:r[n]];if(i)return i}}}}p.none=new p("",Object.create(null),0,8);const g=new WeakMap,m=new WeakMap;var y;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"}(y||(y={}));class b{constructor(e,t,r,n,i){if(this.type=e,this.children=t,this.positions=r,this.length=n,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=this.prop(c.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let r of this.children){let e=r.toString();e&&(t&&(t+=","),t+=e)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new E(this.topNode,e)}cursorAt(e,t=0,r=0){let n=g.get(this)||this.topNode,i=new E(n);return i.moveTo(e,t),g.set(this,i._tree),i}get topNode(){return new O(this,0,0,null)}resolve(e,t=0){let r=S(g.get(this)||this.topNode,e,t,!1);return g.set(this,r),r}resolveInner(e,t=0){let r=S(m.get(this)||this.topNode,e,t,!0);return m.set(this,r),r}iterate(e){let{enter:t,leave:r,from:n=0,to:i=this.length}=e;for(let s=this.cursor((e.mode||0)|y.IncludeAnonymous);;){let e=!1;if(s.from<=i&&s.to>=n&&(s.type.isAnonymous||!1!==t(s))){if(s.firstChild())continue;e=!0}for(;e&&r&&!s.type.isAnonymous&&r(s),!s.nextSibling();){if(!s.parent())return;e=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:I(p.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,r)=>new b(this.type,e,t,r,this.propValues)),e.makeTree||((e,t,r)=>new b(p.none,e,t,r)))}static build(e){return function(e){var t;let{buffer:r,nodeSet:n,maxBufferLength:i=h,reused:s=[],minRepeatType:o=n.types.length}=e,l=Array.isArray(r)?new v(r,r.length):r,a=n.types,u=0,f=0;function d(e,t,r,h,c){let{id:b,start:v,end:k,size:S}=l,O=f;for(;S<0;){if(l.next(),-1==S){let t=s[b];return r.push(t),void h.push(v-e)}if(-3==S)return void(u=b);if(-4==S)return void(f=b);throw new RangeError(`Unrecognized record size: ${S}`)}let A,C,N=a[b],_=v-e;if(k-v<=i&&(C=y(l.pos-t,c))){let t=new Uint16Array(C.size-C.skip),r=l.pos-C.size,i=t.length;for(;l.pos>r;)i=x(C.start,t,i);A=new w(t,k-C.start,n),_=C.start-e}else{let e=l.pos-S;l.next();let t=[],r=[],n=b>=o?b:-1,s=0,a=k;for(;l.pos>e;)n>=0&&l.id==n&&l.size>=0?(l.end<=a-i&&(g(t,r,v,s,l.end,a,n,O),s=t.length,a=l.end),l.next()):d(v,e,t,r,n);if(n>=0&&s>0&&s<t.length&&g(t,r,v,s,v,a,n,O),t.reverse(),r.reverse(),n>-1&&s>0){let e=p(N);A=I(N,t,r,0,t.length,0,k-v,e,e)}else A=m(N,t,r,k-v,O-k)}r.push(A),h.push(_)}function p(e){return(t,r,n)=>{let i,s,o=0,l=t.length-1;if(l>=0&&(i=t[l])instanceof b){if(!l&&i.type==e&&i.length==n)return i;(s=i.prop(c.lookAhead))&&(o=r[l]+i.length+s)}return m(e,t,r,n,o)}}function g(e,t,r,i,s,o,l,a){let h=[],u=[];for(;e.length>i;)h.push(e.pop()),u.push(t.pop()+r-s);e.push(m(n.types[l],h,u,o-s,a-o)),t.push(s-r)}function m(e,t,r,n,i=0,s){if(u){let e=[c.contextHash,u];s=s?[e].concat(s):[e]}if(i>25){let e=[c.lookAhead,i];s=s?[e].concat(s):[e]}return new b(e,t,r,n,s)}function y(e,t){let r=l.fork(),n=0,s=0,a=0,h=r.end-i,u={size:0,start:0,skip:0};e:for(let i=r.pos-e;r.pos>i;){let e=r.size;if(r.id==t&&e>=0){u.size=n,u.start=s,u.skip=a,a+=4,n+=4,r.next();continue}let l=r.pos-e;if(e<0||l<i||r.start<h)break;let f=r.id>=o?4:0,c=r.start;for(r.next();r.pos>l;){if(r.size<0){if(-3!=r.size)break e;f+=4}else r.id>=o&&(f+=4);r.next()}s=c,n+=e,a+=f}return(t<0||n==e)&&(u.size=n,u.start=s,u.skip=a),u.size>4?u:void 0}function x(e,t,r){let{id:n,start:i,end:s,size:a}=l;if(l.next(),a>=0&&n<o){let o=r;if(a>4){let n=l.pos-(a-4);for(;l.pos>n;)r=x(e,t,r)}t[--r]=o,t[--r]=s-e,t[--r]=i-e,t[--r]=n}else-3==a?u=n:-4==a&&(f=n);return r}let k=[],S=[];for(;l.pos>0;)d(e.start||0,e.bufferStart||0,k,S,-1);let O=null!==(t=e.length)&&void 0!==t?t:k.length?S[0]+k[0].length:0;return new b(a[e.topID],k.reverse(),S.reverse(),O)}(e)}}b.empty=new b(p.none,[],[],0);class v{constructor(e,t){this.buffer=e,this.index=t}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 v(this.buffer,this.index)}}class w{constructor(e,t,r){this.buffer=e,this.length=t,this.set=r}get type(){return p.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],r=this.buffer[e+3],n=this.set.types[t],i=n.name;if(/\W/.test(i)&&!n.isError&&(i=JSON.stringify(i)),r==(e+=4))return i;let s=[];for(;e<r;)s.push(this.childString(e)),e=this.buffer[e+3];return i+"("+s.join(",")+")"}findChild(e,t,r,n,i){let{buffer:s}=this,o=-1;for(let l=e;l!=t&&!(x(i,n,s[l+1],s[l+2])&&(o=l,r>0));l=s[l+3]);return o}slice(e,t,r,n){let i=this.buffer,s=new Uint16Array(t-e);for(let o=e,l=0;o<t;)s[l++]=i[o++],s[l++]=i[o++]-r,s[l++]=i[o++]-r,s[l++]=i[o++]-e;return new w(s,n-r,this.set)}}function x(e,t,r,n){switch(e){case-2:return r<t;case-1:return n>=t&&r<t;case 0:return r<t&&n>t;case 1:return r<=t&&n>t;case 2:return n>t;case 4:return!0}}function k(e,t){let r=e.childBefore(t);for(;r;){let t=r.lastChild;if(!t||t.to!=r.to)break;t.type.isError&&t.from==t.to?(e=r,r=t.prevSibling):r=t}return e}function S(e,t,r,n){for(var i;e.from==e.to||(r<1?e.from>=t:e.from>t)||(r>-1?e.to<=t:e.to<t);){let t=!n&&e instanceof O&&e.index<0?null:e.parent;if(!t)return e;e=t}let s=n?0:y.IgnoreOverlays;if(n)for(let o=e,l=o.parent;l;o=l,l=o.parent)o instanceof O&&o.index<0&&(null===(i=l.enter(t,r,s))||void 0===i?void 0:i.from)!=o.from&&(e=l);for(;;){let n=e.enter(t,r,s);if(!n)return e;e=n}}class O{constructor(e,t,r,n){this._tree=e,this.from=t,this.index=r,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,r,n,i=0){for(let s=this;;){for(let{children:o,positions:l}=s._tree,a=t>0?o.length:-1;e!=a;e+=t){let a=o[e],h=l[e]+s.from;if(x(n,r,h,h+a.length))if(a instanceof w){if(i&y.ExcludeBuffers)continue;let o=a.findChild(0,a.buffer.length,t,r-h,n);if(o>-1)return new _(new N(s,a,e,h),null,o)}else if(i&y.IncludeAnonymous||!a.type.isAnonymous||P(a)){let o;if(!(i&y.IgnoreMounts)&&a.props&&(o=a.prop(c.mounted))&&!o.overlay)return new O(o.tree,h,e,s);let l=new O(a,h,e,s);return i&y.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(t<0?a.children.length-1:0,t,r,n)}}if(i&y.IncludeAnonymous||!s.type.isAnonymous)return null;if(e=s.index>=0?s.index+t:t<0?-1:s._parent._tree.children.length,s=s._parent,!s)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,r=0){let n;if(!(r&y.IgnoreOverlays)&&(n=this._tree.prop(c.mounted))&&n.overlay){let r=e-this.from;for(let{from:e,to:i}of n.overlay)if((t>0?e<=r:e<r)&&(t<0?i>=r:i>r))return new O(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}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}cursor(e=0){return new E(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return S(this,e,t,!1)}resolveInner(e,t=0){return S(this,e,t,!0)}enterUnfinishedNodesBefore(e){return k(this,e)}getChild(e,t=null,r=null){let n=A(this,e,t,r);return n.length?n[0]:null}getChildren(e,t=null,r=null){return A(this,e,t,r)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return C(this,e)}}function A(e,t,r,n){let i=e.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(t)&&s.push(i.node),!i.nextSibling())return null==n?s:[]}}function C(e,t,r=t.length-1){for(let n=e.parent;r>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(t[r]&&t[r]!=n.name)return!1;r--}}return!0}class N{constructor(e,t,r,n){this.parent=e,this.buffer=t,this.index=r,this.start=n}}class _{constructor(e,t,r){this.context=e,this._parent=t,this.index=r,this.type=e.buffer.set.types[e.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(e,t,r){let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-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(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,r=0){if(r&y.ExcludeBuffers)return null;let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new _(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new _(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new _(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new E(this,e)}get tree(){return null}toTree(){let e=[],t=[],{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];e.push(r.slice(n,i,s,o)),t.push(0)}return new b(this.type,e,t,this.to-this.from)}resolve(e,t=0){return S(this,e,t,!1)}resolveInner(e,t=0){return S(this,e,t,!0)}enterUnfinishedNodesBefore(e){return k(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,r=null){let n=A(this,e,t,r);return n.length?n[0]:null}getChildren(e,t=null,r=null){return A(this,e,t,r)}get node(){return this}matchContext(e){return C(this,e)}}class E{constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof O)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}get name(){return this.type.name}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:r,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=r+n.buffer[e+1],this.to=r+n.buffer[e+2],!0}yield(e){return!!e&&(e instanceof O?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,r,this.mode));let{buffer:n}=this.buffer,i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-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(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,r=this.mode){return this.buffer?!(r&y.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&y.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&y.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,r=this.stack.length-1;if(e<0){let e=r<0?0:this.stack[r]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(r<0?t.buffer.length:t.buffer[this.stack[r]+3]))return this.yieldBuf(e)}return r<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,r,{buffer:n}=this;if(n){if(e>0){if(this.index<n.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(n.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:r}=n)}else({index:t,_parent:r}=this._tree);for(;r;({index:t,_parent:r}=r))if(t>-1)for(let n=t+e,i=e<0?-1:r._tree.children.length;n!=i;n+=e){let e=r._tree.children[n];if(this.mode&y.IncludeAnonymous||e instanceof w||!e.type.isAnonymous||P(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,r=0;if(e&&e.context==this.buffer)e:for(let n=this.index,i=this.stack.length;i>=0;){for(let s=e;s;s=s._parent)if(s.index==n){if(n==this.index)return s;t=s,r=i+1;break e}n=this.stack[--i]}for(let n=r;n<this.stack.length;n++)t=new _(this.buffer,t,this.stack[n]);return this.bufferNode=new _(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let r=0;;){let n=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){r++;continue}this.type.isAnonymous||(n=!0)}for(;n&&t&&t(this),n=this.type.isAnonymous,!this.nextSibling();){if(!r)return;this.parent(),r--,n=!0}}}matchContext(e){if(!this.buffer)return C(this.node,e);let{buffer:t}=this.buffer,{types:r}=t.set;for(let n=e.length-1,i=this.stack.length-1;n>=0;i--){if(i<0)return C(this.node,e,n);let s=r[t.buffer[this.stack[i]]];if(!s.isAnonymous){if(e[n]&&e[n]!=s.name)return!1;n--}}return!0}}function P(e){return e.children.some((e=>e instanceof w||!e.type.isAnonymous||P(e)))}const T=new WeakMap;function j(e,t){if(!e.isAnonymous||t instanceof w||t.type!=e)return 1;let r=T.get(t);if(null==r){r=1;for(let n of t.children){if(n.type!=e||!(n instanceof b)){r=1;break}r+=j(e,n)}T.set(t,r)}return r}function I(e,t,r,n,i,s,o,l,a){let h=0;for(let d=n;d<i;d++)h+=j(e,t[d]);let u=Math.ceil(1.5*h/8),f=[],c=[];return function t(r,n,i,o,l){for(let h=i;h<o;){let i=h,d=n[h],p=j(e,r[h]);for(h++;h<o;h++){let t=j(e,r[h]);if(p+t>=u)break;p+=t}if(h==i+1){if(p>u){let e=r[i];t(e.children,e.positions,0,e.children.length,n[i]+l);continue}f.push(r[i])}else{let t=n[h-1]+r[h-1].length-d;f.push(I(e,r,n,i,h,d,t,null,a))}c.push(d+l-s)}}(t,r,n,i,0),(l||a)(f,c,o)}class B{constructor(e,t,r,n,i=!1,s=!1){this.from=e,this.to=t,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(e,t=[],r=!1){let n=[new B(0,e.length,e,0,!1,r)];for(let i of t)i.to>e.length&&n.push(i);return n}static applyChanges(e,t,r=128){if(!t.length)return e;let n=[],i=1,s=e.length?e[0]:null;for(let o=0,l=0,a=0;;o++){let h=o<t.length?t[o]:null,u=h?h.fromA:1e9;if(u-l>=r)for(;s&&s.from<u;){let t=s;if(l>=t.from||u<=t.to||a){let e=Math.max(t.from,l)-a,r=Math.min(t.to,u)-a;t=e>=r?null:new B(e,r,t.tree,t.offset+a,o>0,!!h)}if(t&&n.push(t),s.to>u)break;s=i<e.length?e[i++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}return n}}class M{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new c({perNode:!0});let W=0;class R{constructor(e,t,r){this.set=e,this.base=t,this.modified=r,this.id=W++}static define(e){if(null===e||void 0===e?void 0:e.base)throw new Error("Can not derive from a modified tag");let t=new R([],null,[]);if(t.set.push(t),e)for(let r of e.set)t.set.push(r);return t}static defineModifier(){let e=new D;return t=>t.modified.indexOf(e)>-1?t:D.get(t.base||t,t.modified.concat(e).sort(((e,t)=>e.id-t.id)))}}let z=0;class D{constructor(){this.instances=[],this.id=z++}static get(e,t){if(!t.length)return e;let r=t[0].instances.find((r=>{return r.base==e&&(n=t,i=r.modified,n.length==i.length&&n.every(((e,t)=>e==i[t])));var n,i}));if(r)return r;let n=[],i=new R(n,e,t);for(let o of t)o.instances.push(i);let s=L(t);for(let o of e.set)for(let e of s)n.push(D.get(o,e));return i}}function L(e){let t=[e];for(let r=0;r<e.length;r++)for(let n of L(e.slice(0,r).concat(e.slice(r+1))))t.push(n);return t}function U(e){let t=Object.create(null);for(let r in e){let n=e[r];Array.isArray(n)||(n=[n]);for(let e of r.split(" "))if(e){let r=[],i=2,s=e;for(let t=0;;){if("..."==s&&t>0&&t+3==e.length){i=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!n)throw new RangeError("Invalid path: "+e);if(r.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),t+=n[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&"!"==o){i=0;break}if("/"!=o)throw new RangeError("Invalid path: "+e);s=e.slice(t)}let o=r.length-1,l=r[o];if(!l)throw new RangeError("Invalid path: "+e);let a=new V(n,i,o>0?r.slice(0,o):null);t[l]=a.sort(t[l])}}return q.add(t)}const q=new c;class V{constructor(e,t,r,n){this.tags=e,this.mode=t,this.context=r,this.next=n}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function H(e,t){let r=Object.create(null);for(let s of e)if(Array.isArray(s.tag))for(let e of s.tag)r[e.id]=s.class;else r[s.tag.id]=s.class;let{scope:n,all:i=null}=t||{};return{style:e=>{let t=i;for(let n of e)for(let e of n.set){let n=r[e.id];if(n){t=t?t+" "+n:n;break}}return t},scope:n}}const J=R.define,F=J(),$=J(),Z=J($),K=J($),Y=J(),G=J(Y),Q=J(Y),X=J(),ee=J(X),te=J(),re=J(),ne=J(),ie=J(ne),se=J(),oe={comment:F,lineComment:J(F),blockComment:J(F),docComment:J(F),name:$,variableName:J($),typeName:Z,tagName:J(Z),propertyName:K,attributeName:J(K),className:J($),labelName:J($),namespace:J($),macroName:J($),literal:Y,string:G,docString:J(G),character:J(G),attributeValue:J(G),number:Q,integer:J(Q),float:J(Q),bool:J(Y),regexp:J(Y),escape:J(Y),color:J(Y),url:J(Y),keyword:te,self:J(te),null:J(te),atom:J(te),unit:J(te),modifier:J(te),operatorKeyword:J(te),controlKeyword:J(te),definitionKeyword:J(te),moduleKeyword:J(te),operator:re,derefOperator:J(re),arithmeticOperator:J(re),logicOperator:J(re),bitwiseOperator:J(re),compareOperator:J(re),updateOperator:J(re),definitionOperator:J(re),typeOperator:J(re),controlOperator:J(re),punctuation:ne,separator:J(ne),bracket:ie,angleBracket:J(ie),squareBracket:J(ie),paren:J(ie),brace:J(ie),content:X,heading:ee,heading1:J(ee),heading2:J(ee),heading3:J(ee),heading4:J(ee),heading5:J(ee),heading6:J(ee),contentSeparator:J(X),list:J(X),quote:J(X),emphasis:J(X),strong:J(X),link:J(X),monospace:J(X),strikethrough:J(X),inserted:J(),deleted:J(),changed:J(),invalid:J(),meta:se,documentMeta:J(se),annotation:J(se),processingInstruction:J(se),definition:R.defineModifier(),constant:R.defineModifier(),function:R.defineModifier(),standard:R.defineModifier(),local:R.defineModifier(),special:R.defineModifier()},le=(H([{tag:oe.link,class:"tok-link"},{tag:oe.heading,class:"tok-heading"},{tag:oe.emphasis,class:"tok-emphasis"},{tag:oe.strong,class:"tok-strong"},{tag:oe.keyword,class:"tok-keyword"},{tag:oe.atom,class:"tok-atom"},{tag:oe.bool,class:"tok-bool"},{tag:oe.url,class:"tok-url"},{tag:oe.labelName,class:"tok-labelName"},{tag:oe.inserted,class:"tok-inserted"},{tag:oe.deleted,class:"tok-deleted"},{tag:oe.literal,class:"tok-literal"},{tag:oe.string,class:"tok-string"},{tag:oe.number,class:"tok-number"},{tag:[oe.regexp,oe.escape,oe.special(oe.string)],class:"tok-string2"},{tag:oe.variableName,class:"tok-variableName"},{tag:oe.local(oe.variableName),class:"tok-variableName tok-local"},{tag:oe.definition(oe.variableName),class:"tok-variableName tok-definition"},{tag:oe.special(oe.variableName),class:"tok-variableName2"},{tag:oe.definition(oe.propertyName),class:"tok-propertyName tok-definition"},{tag:oe.typeName,class:"tok-typeName"},{tag:oe.namespace,class:"tok-namespace"},{tag:oe.className,class:"tok-className"},{tag:oe.macroName,class:"tok-macroName"},{tag:oe.propertyName,class:"tok-propertyName"},{tag:oe.operator,class:"tok-operator"},{tag:oe.comment,class:"tok-comment"},{tag:oe.meta,class:"tok-meta"},{tag:oe.invalid,class:"tok-invalid"},{tag:oe.punctuation,class:"tok-punctuation"}]),"undefined"==typeof Symbol?"__\u037c":Symbol.for("\u037c")),ae="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),he="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class ue{constructor(e,t){this.rules=[];let{finish:r}=t||{};function n(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,s,o){let l=[],a=/^@(\w+)\b/.exec(e[0]),h=a&&"keyframes"==a[1];if(a&&null==t)return s.push(e[0]+";");for(let r in t){let o=t[r];if(/&/.test(r))i(r.split(/,\s*/).map((t=>e.map((e=>t.replace(/&/,e))))).reduce(((e,t)=>e.concat(t))),o,s);else if(o&&"object"==typeof o){if(!a)throw new RangeError("The value of a property ("+r+") should be a primitive value.");i(n(r),o,l,h)}else null!=o&&l.push(r.replace(/_.*/,"").replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))+": "+o+";")}(l.length||h)&&s.push((!r||a||o?e:e.map(r)).join(", ")+" {"+l.join(" ")+"}")}for(let s in e)i(n(s),e[s],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=he[le]||1;return he[le]=e+1,"\u037c"+e.toString(36)}static mount(e,t){(e[ae]||new ce(e)).mount(Array.isArray(t)?t:[t])}}let fe=null;class ce{constructor(e){if(!e.head&&e.adoptedStyleSheets&&"undefined"!=typeof CSSStyleSheet){if(fe)return e.adoptedStyleSheets=[fe.sheet].concat(e.adoptedStyleSheets),e[ae]=fe;this.sheet=new CSSStyleSheet,e.adoptedStyleSheets=[this.sheet].concat(e.adoptedStyleSheets),this}else{this.styleTag=(e.ownerDocument||e).createElement("style");let t=e.head||e;t.insertBefore(this.styleTag,t.firstChild)}this.modules=[],e[ae]=this}mount(e){let t=this.sheet,r=0,n=0;for(let i=0;i<e.length;i++){let s=e[i],o=this.modules.indexOf(s);if(o<n&&o>-1&&(this.modules.splice(o,1),-1),-1==o){if(this.modules.splice(n++,0,s),t)for(let e=0;e<s.rules.length;e++)t.insertRule(s.rules[e],r++)}else{for(;n<o;)this.modules[n++].rules.length;s.rules.length}}if(!t){let e="";for(let t=0;t<this.modules.length;t++)this.modules[t].getRules()+"\n";this.styleTag.textContent=e}}}var de;const pe=new c;class ge{constructor(e,t,r=[]){this.data=e,l.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(l.EditorState.prototype,"tree",{get(){return ye(this)}}),this.parser=t,this.extension=[Ce.of(this),l.EditorState.languageData.of(((e,t,r)=>e.facet(me(e,t,r))))].concat(r)}isActiveAt(e,t,r=-1){return me(e,t,r)==this.data}findRegions(e){let t=e.facet(Ce);if((null===t||void 0===t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let r=[],n=(e,t)=>{if(e.prop(pe)==this.data)return void r.push({from:t,to:t+e.length});let i=e.prop(c.mounted);if(i){if(i.tree.prop(pe)==this.data){if(i.overlay)for(let e of i.overlay)r.push({from:e.from+t,to:e.to+t});else r.push({from:t,to:t+e.length});return}if(i.overlay){let e=r.length;if(n(i.tree,i.overlay[0].from+t),r.length>e)return}}for(let r=0;r<e.children.length;r++){let i=e.children[r];i instanceof b&&n(i,e.positions[r]+t)}};return n(ye(e),0),r}get allowsNesting(){return!0}}function me(e,t,r){let n=e.facet(Ce);if(!n)return null;let i=n.data;if(n.allowsNesting)for(let s=ye(e).topNode;s;s=s.enter(t,r,y.ExcludeBuffers))i=s.type.prop(pe)||i;return i}ge.setState=l.StateEffect.define();function ye(e){let t=e.field(ge.state,!1);return t?t.tree:b.empty}class be{constructor(e,t=e.length){this.doc=e,this.length=t,this.cursorPos=0,this.string="",this.cursor=e.iter()}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let r=this.cursorPos-this.string.length;return e<r||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-r,t-r)}}let ve=null;class we{constructor(e,t,r=[],n,i,s,o,l){this.parser=e,this.state=t,this.fragments=r,this.tree=n,this.treeLen=i,this.viewport=s,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}startParse(){return this.parser.startParse(new be(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=b.empty&&this.isDone(null!==t&&void 0!==t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var r;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(B.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(r=this.parse.stoppedAt)&&void 0!==r?r:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!==t&&void 0!==t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}}))}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext((()=>{for(;!(t=this.parse.advance()););})),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(B.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=ve;ve=this;try{return e()}finally{ve=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=xe(e,t.from,t.to);return e}changes(e,t){let{fragments:r,tree:n,treeLen:i,viewport:s,skipped:o}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges(((e,r,n,i)=>t.push({fromA:e,toA:r,fromB:n,toB:i}))),r=B.applyChanges(r,t),n=b.empty,i=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){o=[];for(let t of this.skipped){let r=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);r<n&&o.push({from:r,to:n})}}}return new we(this.parser,t,r,n,i,s,o,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:t,to:n}=this.skipped[r];t<e.to&&n>e.from&&(this.fragments=xe(this.fragments,t,n),this.skipped.splice(r--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends class{startParse(e,t,r){return"string"==typeof e&&(e=new M(e)),r=r?r.length?r.map((e=>new f(e.from,e.to))):[new f(0,0)]:[new f(0,e.length)],this.createParse(e,t||[],r)}parse(e,t,r){let n=this.startParse(e,t,r);for(;;){let e=n.advance();if(e)return e}}}{createParse(t,r,n){let i=n[0].from,s=n[n.length-1].to;return{parsedPos:i,advance(){let t=ve;if(t){for(let e of n)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=s,new b(p.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return ve}}function xe(e,t,r){return B.applyChanges(e,[{fromA:t,toA:r,fromB:t,toB:r}])}class ke{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,r)||t.takeTree(),new ke(t)}static init(e){let t=Math.min(3e3,e.doc.length),r=new we(e.facet(Ce).parser,e,[],b.empty,0,{from:0,to:t},[],null);return r.work(20,t)||r.takeTree(),new ke(r)}}ge.state=l.StateField.define({create:ke.init,update(e,t){for(let r of t.effects)if(r.is(ge.setState))return r.value;return t.startState.facet(Ce)!=t.state.facet(Ce)?ke.init(t.state):e.apply(t)}});let Se=e=>{let t=setTimeout((()=>e()),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(Se=e=>{let t=-1,r=setTimeout((()=>{t=requestIdleCallback(e,{timeout:400})}),100);return()=>t<0?clearTimeout(r):cancelIdleCallback(t)});const Oe="undefined"!=typeof navigator&&(null===(de=navigator.scheduling)||void 0===de?void 0:de.isInputPending)?()=>navigator.scheduling.isInputPending():null,Ae=a.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(ge.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(ge.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=Se(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:n}}=this.view,i=r.field(ge.state);if(i.tree==i.context.tree&&i.context.isDone(n+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,e&&!Oe?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<n&&r.doc.length>n+1e3,l=i.context.work((()=>Oe&&Oe()||Date.now()>s),n+(o?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:ge.setState.of(new ke(i.context))})),this.chunkBudget>0&&(!l||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then((()=>this.scheduleWork())).catch((e=>(0,a.logException)(this.view.state,e))).then((()=>this.workScheduled--)),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ce=l.Facet.define({combine:e=>e.length?e[0]:null,enables:[ge.state,Ae]});const Ne=l.Facet.define({combine:e=>{if(!e.length)return" ";if(!/^(?: +|\t+)$/.test(e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return e[0]}});function _e(e){let t=e.facet(Ne);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function Ee(e,t){let r="",n=e.tabSize;if(9==e.facet(Ne).charCodeAt(0))for(;t>=n;)r+="\t",t-=n;for(let i=0;i<t;i++)r+=" ";return r}class Pe{constructor(e,t){let r;function n(e){let t=ue.newName();return(r||Object.create(null))["."+t]=e,t}const i=t.scope;this.scope=i instanceof ge?e=>e.prop(pe)==i.data:i?e=>e==i:void 0,this.style=H(e.map((e=>({tag:e.tag,class:e.class||n(Object.assign({},e,{tag:null}))}))),{all:"string"==typeof t.all?t.all:t.all?n(t.all):void 0}).style,this.module=r?new ue(r):null,this.themeType=t.themeType}static define(e,t){return new Pe(e,t||{})}}oe.meta,oe.link,oe.heading,oe.emphasis,oe.strong,oe.strikethrough,oe.keyword,oe.atom,oe.bool,oe.url,oe.contentSeparator,oe.labelName,oe.literal,oe.inserted,oe.string,oe.deleted,oe.regexp,oe.escape,oe.string,oe.variableName,oe.variableName,oe.typeName,oe.namespace,oe.className,oe.variableName,oe.macroName,oe.propertyName,oe.comment,oe.invalid;const Te=Object.create(null),je=[p.none],Ie=[],Be=Object.create(null);for(let[rt,nt]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","typeName"],["attribute","propertyName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Be[rt]=We(Te,nt);function Me(e,t){Ie.indexOf(e)>-1||(Ie.push(e),console.warn(t))}function We(e,t){let r=null;for(let s of t.split(".")){let t=e[s]||oe[s];t?"function"==typeof t?r?r=t(r):Me(s,`Modifier ${s} used at start of tag`):r?Me(s,`Tag ${s} used as modifier`):r=t:Me(s,`Unknown highlighting tag ${s}`)}if(!r)return 0;let n=t.replace(/ /g,"_"),i=p.define({id:je.length,name:n,props:[U({[n]:r})]});return je.push(i),i.id}const Re=l.Annotation.define(),ze=l.Facet.define();class De{constructor(e,t,r,n,i){this.changes=e,this.effects=t,this.mapped=r,this.startSelection=n,this.selectionsAfter=i}setSelAfter(e){return new De(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,r;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(r=this.startSelection)||void 0===r?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map((e=>e.toJSON()))}}static fromJSON(e){return new De(e.changes&&l.ChangeSet.fromJSON(e.changes),[],e.mapped&&l.ChangeDesc.fromJSON(e.mapped),e.startSelection&&l.EditorSelection.fromJSON(e.startSelection),e.selectionsAfter.map(l.EditorSelection.fromJSON))}static fromTransaction(e,t){let r=qe;for(let n of e.startState.facet(ze)){let t=n(e);t.length&&(r=r.concat(t))}return!r.length&&e.changes.empty?null:new De(e.changes.invert(e.startState.doc),r,void 0,t||e.startState.selection,qe)}static selection(e){return new De(void 0,qe,void 0,void 0,e)}}function Le(e,t,r,n){let i=t+1>r+20?t-r-1:0,s=e.slice(i,t);return s.push(n),s}function Ue(e,t){return e.length?t.length?e.concat(t):e:t}const qe=[];function Ve(e,t){if(e.length){let r=e[e.length-1],n=r.selectionsAfter.slice(Math.max(0,r.selectionsAfter.length-200));return n.length&&n[n.length-1].eq(t)?e:(n.push(t),Le(e,e.length-1,1e9,r.setSelAfter(n)))}return[De.selection([t])]}function He(e){let t=e[e.length-1],r=e.slice();return r[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),r}function Je(e,t){if(!e.length)return e;let r=e.length,n=qe;for(;r;){let i=Fe(e[r-1],t,n);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,r);return t[r-1]=i,t}t=i.mapped,r--,n=i.selectionsAfter}return n.length?[De.selection(n)]:qe}function Fe(e,t,r){let n=Ue(e.selectionsAfter.length?e.selectionsAfter.map((e=>e.map(t))):qe,r);if(!e.changes)return De.selection(n);let i=e.changes.map(t),s=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(s):s;return new De(i,l.StateEffect.mapEffects(e.effects,t),o,e.startSelection.map(s),n)}const $e=/^(input\.type|delete)($|\.)/;class Ze{constructor(e,t,r=0,n){this.done=e,this.undone=t,this.prevTime=r,this.prevUserEvent=n}isolate(){return this.prevTime?new Ze(this.done,this.undone):this}addChanges(e,t,r,n,i){let s=this.done,o=s[s.length-1];return s=o&&o.changes&&!o.changes.empty&&e.changes&&(!r||$e.test(r))&&(!o.selectionsAfter.length&&t-this.prevTime<n&&function(e,t){let r=[],n=!1;return e.iterChangedRanges(((e,t)=>r.push(e,t))),t.iterChangedRanges(((e,t,i,s)=>{for(let o=0;o<r.length;){let e=r[o++],t=r[o++];s>=e&&i<=t&&(n=!0)}})),n}(o.changes,e.changes)||"input.type.compose"==r)?Le(s,s.length-1,i,new De(e.changes.compose(o.changes),Ue(e.effects,o.effects),o.mapped,o.startSelection,qe)):Le(s,s.length,i,e),new Ze(s,qe,t,r)}addSelection(e,t,r,n){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:qe;return i.length>0&&t-this.prevTime<n&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&(s=i[i.length-1],o=e,s.ranges.length==o.ranges.length&&0===s.ranges.filter(((e,t)=>e.empty!=o.ranges[t].empty)).length)?this:new Ze(Ve(this.done,e),this.undone,t,r);var s,o}addMapping(e){return new Ze(Je(this.done,e),Je(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,r){let n=0==e?this.done:this.undone;if(0==n.length)return null;let i=n[n.length-1];if(r&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Re.of({side:e,rest:He(n)}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let r=1==n.length?qe:n.slice(0,n.length-1);return i.mapped&&(r=Je(r,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Re.of({side:e,rest:r}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}Ze.empty=new Ze(qe,qe);function Ke(e,t){let r=-1;return e.changeByRange((n=>{let i=[];for(let o=n.from;o<=n.to;){let s=e.doc.lineAt(o);s.number>r&&(n.empty||n.to>s.from)&&(t(s,i,n),r=s.number),o=s.to+1}let s=e.changes(i);return{changes:i,range:l.EditorSelection.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}}))}const Ye=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Ke(e,((t,r)=>{r.push({from:t.from,insert:e.facet(Ne)})})),{userEvent:"input.indent"})),!0),Ge=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Ke(e,((t,r)=>{let n=/^\s*/.exec(t.text)[0];if(!n)return;let i=(0,l.countColumn)(n,e.tabSize),s=0,o=Ee(e,Math.max(0,i-_e(e)));for(;s<n.length&&s<o.length&&n.charCodeAt(s)==o.charCodeAt(s);)s++;r.push({from:t.from+s,to:t.from+n.length,insert:o.slice(s)})})),{userEvent:"delete.dedent"})),!0),Qe={key:"Tab",run:Ye,shift:Ge};var Xe=r(362),et=a.EditorView.theme({"&":{backgroundColor:"#fff"}},{dark:!1});function tt(e){var t=e.value,r=e.selection,n=e.onChange,h=e.onUpdate,u=e.extensions,f=void 0===u?[]:u,c=e.autoFocus,d=e.theme,p=void 0===d?"light":d,g=e.height,m=void 0===g?"":g,y=e.minHeight,b=void 0===y?"":y,v=e.maxHeight,w=void 0===v?"":v,x=e.placeholder,k=void 0===x?"":x,S=e.width,O=void 0===S?"":S,A=e.minWidth,C=void 0===A?"":A,N=e.maxWidth,_=void 0===N?"":N,E=e.editable,P=void 0===E||E,T=e.readOnly,j=void 0!==T&&T,I=e.indentWithTab,B=void 0===I||I,M=e.basicSetup,W=void 0===M||M,R=e.root,z=i((0,s.useState)(e.container),2),D=z[0],L=z[1],U=i((0,s.useState)(),2),q=U[0],V=U[1],H=i((0,s.useState)(),2),J=H[0],F=H[1],$=a.EditorView.theme({"&":{height:m,minHeight:b,maxHeight:w,width:O,minWidth:C,maxWidth:_}}),Z=[a.EditorView.updateListener.of((function(e){if(e.docChanged&&"function"===typeof n){var t=e.state.doc.toString();n(t,e)}})),$];switch(B&&Z.unshift(a.keymap.of([Qe])),W&&Z.unshift(o.basicSetup),k&&Z.unshift((0,a.placeholder)(k)),p){case"light":Z.push(et);break;case"dark":Z.push(Xe.oneDark);break;default:Z.push(p)}return!1===P&&Z.push(a.EditorView.editable.of(!1)),j&&Z.push(l.EditorState.readOnly.of(!0)),h&&"function"===typeof h&&Z.push(a.EditorView.updateListener.of(h)),Z=Z.concat(f),(0,s.useEffect)((function(){if(D&&!J){var e=l.EditorState.create({doc:t,selection:r,extensions:Z});if(F(e),!q){var n=new a.EditorView({state:e,parent:D,root:R});V(n)}}return function(){q&&V(void 0)}}),[D,J]),(0,s.useEffect)((function(){return function(){q&&(q.destroy(),V(void 0))}}),[q]),(0,s.useEffect)((function(){c&&q&&q.focus()}),[c,q]),(0,s.useEffect)((function(){var e=q?q.state.doc.toString():"";q&&t!==e&&q.dispatch({changes:{from:0,to:e.length,insert:t||""}})}),[t,q]),(0,s.useEffect)((function(){q&&q.dispatch({effects:l.StateEffect.reconfigure.of(Z)})}),[p,f,m,b,w,O,k,C,_,P,B,W]),{state:J,setState:F,view:q,setView:V,container:D,setContainer:L}}},638:(e,t,r)=>{var n=r(787),i=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function h(e,t,r){var n,s={},h=null,u=null;for(n in void 0!==r&&(h=""+r),void 0!==t.key&&(h=""+t.key),void 0!==t.ref&&(u=t.ref),t)o.call(t,n)&&!a.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:i,type:e,key:h,ref:u,props:s,_owner:l.current}}t.jsx=h},724:(e,t,r)=>{e.exports=r(638)},787:t=>{t.exports=e},573:e=>{e.exports=t},242:e=>{e.exports=r},362:e=>{e.exports=n},105:e=>{e.exports=i},683:(e,t,r)=>{function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}r.d(t,{Z:()=>s})},925:(e,t,r)=>{function n(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},s=Object.keys(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}r.d(t,{Z:()=>n})}},o={};function l(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return s[e](r,r.exports,l),r.exports}l.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return l.d(t,{a:t}),t},l.d=(e,t)=>{for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{l.r(a),l.d(a,{default:()=>p,useCodeMirror:()=>i.U});var e=l(683),t=l(925),r=l(787),n=l.n(r),i=l(963),s=l(724),o=l(105),h={};for(const l in o)"default"!==l&&(h[l]=()=>o[l]);l.d(a,h);var u=l(573);h={};for(const l in u)"default"!==l&&(h[l]=()=>u[l]);l.d(a,h);var f=l(242);h={};for(const l in f)"default"!==l&&(h[l]=()=>f[l]);l.d(a,h);var c=["className","value","selection","extensions","onChange","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root"],d=n().forwardRef((function(n,o){var l=n.className,a=n.value,h=void 0===a?"":a,u=n.selection,f=n.extensions,d=void 0===f?[]:f,p=n.onChange,g=n.onUpdate,m=n.autoFocus,y=n.theme,b=void 0===y?"light":y,v=n.height,w=n.minHeight,x=n.maxHeight,k=n.width,S=n.minWidth,O=n.maxWidth,A=n.basicSetup,C=n.placeholder,N=n.indentWithTab,_=n.editable,E=n.readOnly,P=n.root,T=(0,t.Z)(n,c),j=(0,r.useRef)(null),I=(0,i.U)({container:j.current,root:P,value:h,autoFocus:m,theme:b,height:v,minHeight:w,maxHeight:x,width:k,minWidth:S,maxWidth:O,basicSetup:A,placeholder:C,indentWithTab:N,editable:_,readOnly:E,selection:u,onChange:p,onUpdate:g,extensions:d}),B=I.state,M=I.view,W=I.container,R=I.setContainer;if((0,r.useImperativeHandle)(o,(function(){return{editor:W,state:B,view:M}}),[W,B,M]),(0,r.useEffect)((function(){R(j.current)}),[]),"string"!==typeof h)throw new Error("value must be typeof string but got ".concat(typeof h));var z="string"===typeof b?"cm-theme-".concat(b):"cm-theme";return(0,s.jsx)("div",(0,e.Z)({ref:j,className:"".concat(z).concat(l?" ".concat(l):"")},T))}));d.displayName="CodeMirror";const p=d})(),a})()));
@@ -1,10 +1,5 @@
1
- /*
2
- object-assign
3
- (c) Sindre Sorhus
4
- @license MIT
5
- */
6
-
7
- /** @license React v17.0.2
1
+ /**
2
+ * @license React
8
3
  * react-jsx-runtime.production.min.js
9
4
  *
10
5
  * Copyright (c) Facebook, Inc. and its affiliates.
package/esm/index.d.ts CHANGED
@@ -33,6 +33,7 @@ export interface ReactCodeMirrorProps extends Omit<EditorStateConfig, 'doc' | 'e
33
33
  * @default true
34
34
  */
35
35
  editable?: boolean;
36
+ readOnly?: boolean;
36
37
  /**
37
38
  * Whether to optional basicSetup by default
38
39
  * @default true
package/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
- var _excluded = ["className", "value", "selection", "extensions", "onChange", "onUpdate", "autoFocus", "theme", "height", "minHeight", "maxHeight", "width", "minWidth", "maxWidth", "basicSetup", "placeholder", "indentWithTab", "editable", "root"];
3
+ var _excluded = ["className", "value", "selection", "extensions", "onChange", "onUpdate", "autoFocus", "theme", "height", "minHeight", "maxHeight", "width", "minWidth", "maxWidth", "basicSetup", "placeholder", "indentWithTab", "editable", "readOnly", "root"];
4
4
  import React, { useEffect, useRef, useImperativeHandle } from 'react';
5
5
  import { useCodeMirror } from './useCodeMirror';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -28,6 +28,7 @@ var ReactCodeMirror = /*#__PURE__*/React.forwardRef((props, ref) => {
28
28
  placeholder,
29
29
  indentWithTab,
30
30
  editable,
31
+ readOnly,
31
32
  root
32
33
  } = props,
33
34
  other = _objectWithoutPropertiesLoose(props, _excluded);
@@ -54,6 +55,7 @@ var ReactCodeMirror = /*#__PURE__*/React.forwardRef((props, ref) => {
54
55
  placeholder,
55
56
  indentWithTab,
56
57
  editable,
58
+ readOnly,
57
59
  selection,
58
60
  onChange,
59
61
  onUpdate,
package/esm/index.js.map CHANGED
@@ -31,6 +31,7 @@
31
31
  "placeholder",
32
32
  "indentWithTab",
33
33
  "editable",
34
+ "readOnly",
34
35
  "root",
35
36
  "other",
36
37
  "editor",
@@ -43,8 +44,8 @@
43
44
  "defaultClassNames",
44
45
  "displayName"
45
46
  ],
46
- "mappings": ";;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,mBAAnC,QAA8D,OAA9D;AAGA,SAASC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EAAEG,SAAV;AAAqBF,IAAAA,KAArB;AAA4BC,IAAAA;AAA5B,GAAP,CAAN,EAAkD,CAACC,SAAD,EAAYF,KAAZ,EAAmBC,IAAnB,CAAlD,CAAnB;AACA/B,EAAAA,SAAS,CAAC,MAAM;AACdiC,IAAAA,YAAY,CAACJ,MAAM,CAACK,OAAR,CAAZ,CADc,CAEd;AACD,GAHQ,EAGN,EAHM,CAAT,CAhDiG,CAqDjG;;AACA,MAAI,OAAOzB,KAAP,KAAiB,QAArB,EAA+B;AAC7B,UAAM,IAAI0B,KAAJ,0CAAiD,OAAO1B,KAAxD,CAAN;AACD;;AAED,MAAM2B,iBAAiB,GAAG,OAAOrB,KAAP,KAAiB,QAAjB,iBAAwCA,KAAxC,GAAkD,UAA5E;AACA,sBAAO;AAAK,IAAA,GAAG,EAAEc,MAAV;AAAkB,IAAA,SAAS,OAAKO,iBAAL,IAAyB5B,SAAS,SAAOA,SAAP,GAAqB,EAAvD;AAA3B,KAA4FoB,KAA5F,EAAP;AACD,CA5DuB,CAAxB;AA8DAxB,eAAe,CAACiC,WAAhB,GAA8B,YAA9B;AAEA,eAAejC,eAAf",
47
48
  "sourcesContent": [
48
- "import React, { useEffect, useRef, useImperativeHandle } from 'react';\nimport { EditorState, EditorStateConfig, Extension } from '@codemirror/state';\nimport { EditorView, ViewUpdate } from '@codemirror/view';\nimport { useCodeMirror } from './useCodeMirror';\n\nexport * from '@codemirror/view';\nexport * from '@codemirror/basic-setup';\nexport * from '@codemirror/state';\nexport * from './useCodeMirror';\n\nexport interface ReactCodeMirrorProps\n extends Omit<EditorStateConfig, 'doc' | 'extensions'>,\n Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'placeholder'> {\n /** value of the auto created model in the editor. */\n value?: string;\n height?: string;\n minHeight?: string;\n maxHeight?: string;\n width?: string;\n minWidth?: string;\n maxWidth?: string;\n /** focus on the editor. */\n autoFocus?: boolean;\n /** Enables a placeholder—a piece of example content to show when the editor is empty. */\n placeholder?: string | HTMLElement;\n /**\n * `light` / `dark` / `Extension` Defaults to `light`.\n * @default light\n */\n theme?: 'light' | 'dark' | Extension;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n basicSetup?: boolean;\n /**\n * This disables editing of the editor content by the user.\n * @default true\n */\n editable?: boolean;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n indentWithTab?: boolean;\n /** Fired whenever a change occurs to the document. */\n onChange?(value: string, viewUpdate: ViewUpdate): void;\n /** Fired whenever a change occurs to the document. There is a certain difference with `onChange`. */\n onUpdate?(viewUpdate: ViewUpdate): void;\n /**\n * Extension values can be [provided](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions) when creating a state to attach various kinds of configuration and behavior information.\n * They can either be built-in extension-providing objects,\n * such as [state fields](https://codemirror.net/6/docs/ref/#state.StateField) or [facet providers](https://codemirror.net/6/docs/ref/#state.Facet.of),\n * or objects with an extension in its `extension` property. Extensions can be nested in arrays arbitrarily deep—they will be flattened when processed.\n */\n extensions?: Extension[];\n /**\n * If the view is going to be mounted in a shadow root or document other than the one held by the global variable document (the default), you should pass it here.\n * Originally from the [config of EditorView](https://codemirror.net/6/docs/ref/#view.EditorView.constructor%5Econfig.root)\n */\n root?: ShadowRoot | Document;\n}\n\nexport interface ReactCodeMirrorRef {\n editor?: HTMLDivElement | null;\n state?: EditorState;\n view?: EditorView;\n}\n\nconst ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProps>((props, ref) => {\n const {\n className,\n value = '',\n selection,\n extensions = [],\n onChange,\n onUpdate,\n autoFocus,\n theme = 'light',\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n root,\n ...other\n } = props;\n const editor = useRef<HTMLDivElement>(null);\n const { state, view, container, setContainer } = useCodeMirror({\n container: editor.current,\n root,\n value,\n autoFocus,\n theme,\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n selection,\n onChange,\n onUpdate,\n extensions,\n });\n useImperativeHandle(ref, () => ({ editor: container, state, view }), [container, state, view]);\n useEffect(() => {\n setContainer(editor.current);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // check type of value\n if (typeof value !== 'string') {\n throw new Error(`value must be typeof string but got ${typeof value}`);\n }\n\n const defaultClassNames = typeof theme === 'string' ? `cm-theme-${theme}` : 'cm-theme';\n return <div ref={editor} className={`${defaultClassNames}${className ? ` ${className}` : ''}`} {...other}></div>;\n});\n\nReactCodeMirror.displayName = 'CodeMirror';\n\nexport default ReactCodeMirror;\n"
49
+ "import React, { useEffect, useRef, useImperativeHandle } from 'react';\nimport { EditorState, EditorStateConfig, Extension } from '@codemirror/state';\nimport { EditorView, ViewUpdate } from '@codemirror/view';\nimport { useCodeMirror } from './useCodeMirror';\n\nexport * from '@codemirror/view';\nexport * from '@codemirror/basic-setup';\nexport * from '@codemirror/state';\nexport * from './useCodeMirror';\n\nexport interface ReactCodeMirrorProps\n extends Omit<EditorStateConfig, 'doc' | 'extensions'>,\n Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'placeholder'> {\n /** value of the auto created model in the editor. */\n value?: string;\n height?: string;\n minHeight?: string;\n maxHeight?: string;\n width?: string;\n minWidth?: string;\n maxWidth?: string;\n /** focus on the editor. */\n autoFocus?: boolean;\n /** Enables a placeholder—a piece of example content to show when the editor is empty. */\n placeholder?: string | HTMLElement;\n /**\n * `light` / `dark` / `Extension` Defaults to `light`.\n * @default light\n */\n theme?: 'light' | 'dark' | Extension;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n basicSetup?: boolean;\n /**\n * This disables editing of the editor content by the user.\n * @default true\n */\n editable?: boolean;\n readOnly?: boolean;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n indentWithTab?: boolean;\n /** Fired whenever a change occurs to the document. */\n onChange?(value: string, viewUpdate: ViewUpdate): void;\n /** Fired whenever a change occurs to the document. There is a certain difference with `onChange`. */\n onUpdate?(viewUpdate: ViewUpdate): void;\n /**\n * Extension values can be [provided](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions) when creating a state to attach various kinds of configuration and behavior information.\n * They can either be built-in extension-providing objects,\n * such as [state fields](https://codemirror.net/6/docs/ref/#state.StateField) or [facet providers](https://codemirror.net/6/docs/ref/#state.Facet.of),\n * or objects with an extension in its `extension` property. Extensions can be nested in arrays arbitrarily deep—they will be flattened when processed.\n */\n extensions?: Extension[];\n /**\n * If the view is going to be mounted in a shadow root or document other than the one held by the global variable document (the default), you should pass it here.\n * Originally from the [config of EditorView](https://codemirror.net/6/docs/ref/#view.EditorView.constructor%5Econfig.root)\n */\n root?: ShadowRoot | Document;\n}\n\nexport interface ReactCodeMirrorRef {\n editor?: HTMLDivElement | null;\n state?: EditorState;\n view?: EditorView;\n}\n\nconst ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProps>((props, ref) => {\n const {\n className,\n value = '',\n selection,\n extensions = [],\n onChange,\n onUpdate,\n autoFocus,\n theme = 'light',\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n readOnly,\n root,\n ...other\n } = props;\n const editor = useRef<HTMLDivElement>(null);\n const { state, view, container, setContainer } = useCodeMirror({\n container: editor.current,\n root,\n value,\n autoFocus,\n theme,\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n readOnly,\n selection,\n onChange,\n onUpdate,\n extensions,\n });\n useImperativeHandle(ref, () => ({ editor: container, state, view }), [container, state, view]);\n useEffect(() => {\n setContainer(editor.current);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // check type of value\n if (typeof value !== 'string') {\n throw new Error(`value must be typeof string but got ${typeof value}`);\n }\n\n const defaultClassNames = typeof theme === 'string' ? `cm-theme-${theme}` : 'cm-theme';\n return <div ref={editor} className={`${defaultClassNames}${className ? ` ${className}` : ''}`} {...other}></div>;\n});\n\nReactCodeMirror.displayName = 'CodeMirror';\n\nexport default ReactCodeMirror;\n"
49
50
  ]
50
51
  }
@@ -22,6 +22,7 @@ export function useCodeMirror(props) {
22
22
  minWidth = '',
23
23
  maxWidth = '',
24
24
  editable = true,
25
+ readOnly = false,
25
26
  indentWithTab: defaultIndentWithTab = true,
26
27
  basicSetup: defaultBasicSetup = true,
27
28
  root
@@ -55,27 +56,6 @@ export function useCodeMirror(props) {
55
56
  }
56
57
 
57
58
  if (defaultBasicSetup) {
58
- if (Array.isArray(basicSetup)) {
59
- /**
60
- * 🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧
61
- * This is not a solution.
62
- * https://github.com/uiwjs/react-codemirror/issues/280
63
- */
64
- basicSetup.map(item => {
65
- if (item.value && Array.isArray(item.value)) {
66
- item.value = item.value.map(keymap => {
67
- if ('Mod-f' === keymap.key) {
68
- return undefined;
69
- }
70
-
71
- return keymap;
72
- }).filter(Boolean);
73
- }
74
-
75
- return item;
76
- });
77
- }
78
-
79
59
  getExtensions.unshift(basicSetup);
80
60
  }
81
61
 
@@ -101,6 +81,10 @@ export function useCodeMirror(props) {
101
81
  getExtensions.push(EditorView.editable.of(false));
102
82
  }
103
83
 
84
+ if (readOnly) {
85
+ getExtensions.push(EditorState.readOnly.of(true));
86
+ }
87
+
104
88
  if (onUpdate && typeof onUpdate === 'function') {
105
89
  getExtensions.push(EditorView.updateListener.of(onUpdate));
106
90
  }
@@ -32,6 +32,7 @@
32
32
  "minWidth",
33
33
  "maxWidth",
34
34
  "editable",
35
+ "readOnly",
35
36
  "defaultIndentWithTab",
36
37
  "defaultBasicSetup",
37
38
  "root",
@@ -50,20 +51,13 @@
50
51
  "toString",
51
52
  "getExtensions",
52
53
  "unshift",
53
- "Array",
54
- "isArray",
55
- "map",
56
- "item",
57
- "key",
58
- "undefined",
59
- "filter",
60
- "Boolean",
61
54
  "push",
62
55
  "concat",
63
56
  "stateCurrent",
64
57
  "create",
65
58
  "viewCurrent",
66
59
  "parent",
60
+ "undefined",
67
61
  "destroy",
68
62
  "focus",
69
63
  "currentValue",
@@ -76,8 +70,8 @@
76
70
  "effects",
77
71
  "reconfigure"
78
72
  ],
79
- "mappings": "AAAA,SAASA,SAAT,EAAoBC,QAApB,QAAoC,OAApC;AACA,SAASC,UAAT,QAA2B,yBAA3B;AACA,SAASC,WAAT,EAAsBC,WAAtB,QAAyC,mBAAzC;AACA,SAASC,aAAT,QAA8B,sBAA9B;AACA,SAASC,UAAT,EAAqBC,MAArB,EAAyCC,WAAzC,QAA4D,kBAA5D;AACA,SAASC,OAAT,QAAwB,4BAAxB;AAEA,SAASC,uBAAT,QAAwC,eAAxC;AAMA,OAAO,SAASC,aAAT,CAAuBC,KAAvB,EAA6C;AAClD,MAAM;AACJC,IAAAA,KADI;AAEJC,IAAAA,SAFI;AAGJC,IAAAA,QAHI;AAIJC,IAAAA,QAJI;AAKJC,IAAAA,UAAU,GAAG,EALT;AAMJC,IAAAA,SANI;AAOJC,IAAAA,KAAK,GAAG,OAPJ;AAQJC,IAAAA,MAAM,GAAG,EARL;AASJC,IAAAA,SAAS,GAAG,EATR;AAUJC,IAAAA,SAAS,GAAG,EAVR;AAWJd,IAAAA,WAAW,EAAEe,cAAc,GAAG,EAX1B;AAYJC,IAAAA,KAAK,GAAG,EAZJ;AAaJC,IAAAA,QAAQ,GAAG,EAbP;AAcJC,IAAAA,QAAQ,GAAG,EAdP;AAeJC,IAAAA,QAAQ,GAAG,IAfP;AAgBJtB,IAAAA,aAAa,EAAEuB,oBAAoB,GAAG,IAhBlC;AAiBJ1B,IAAAA,UAAU,EAAE2B,iBAAiB,GAAG,IAjB5B;AAkBJC,IAAAA;AAlBI,MAmBFlB,KAnBJ;AAoBA,MAAM,CAACmB,SAAD,EAA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I;AAArD;AADG,OAAd;AAGD;AACF,GAPQ,EAON,CAACA,KAAD,EAAQqB,IAAR,CAPM,CAAT;AASAlC,EAAAA,SAAS,CAAC,MAAM;AACd,QAAIkC,IAAJ,EAAU;AACRA,MAAAA,IAAI,CAACuB,QAAL,CAAc;AAAEM,QAAAA,OAAO,EAAE3D,WAAW,CAAC4D,WAAZ,CAAwBxB,EAAxB,CAA2BK,aAA3B;AAAX,OAAd;AACD,KAHa,CAId;;AACD,GALQ,EAKN,CACD1B,KADC,EAEDF,UAFC,EAGDG,MAHC,EAIDC,SAJC,EAKDC,SALC,EAMDE,KANC,EAODD,cAPC,EAQDE,QARC,EASDC,QATC,EAUDC,QAVC,EAWDE,oBAXC,EAYDC,iBAZC,CALM,CAAT;AAoBA,SAAO;AAAEM,IAAAA,KAAF;AAASC,IAAAA,QAAT;AAAmBH,IAAAA,IAAnB;AAAyBC,IAAAA,OAAzB;AAAkCH,IAAAA,SAAlC;AAA6CC,IAAAA;AAA7C,GAAP;AACD",
80
74
  "sourcesContent": [
81
- "import { useEffect, useState } from 'react';\nimport { basicSetup } from '@codemirror/basic-setup';\nimport { EditorState, StateEffect } from '@codemirror/state';\nimport { indentWithTab } from '@codemirror/commands';\nimport { EditorView, keymap, ViewUpdate, placeholder } from '@codemirror/view';\nimport { oneDark } from '@codemirror/theme-one-dark';\nimport { ReactCodeMirrorProps } from './';\nimport { defaultLightThemeOption } from './theme/light';\n\nexport interface UseCodeMirror extends ReactCodeMirrorProps {\n container?: HTMLDivElement | null;\n}\n\nexport function useCodeMirror(props: UseCodeMirror) {\n const {\n value,\n selection,\n onChange,\n onUpdate,\n extensions = [],\n autoFocus,\n theme = 'light',\n height = '',\n minHeight = '',\n maxHeight = '',\n placeholder: placeholderStr = '',\n width = '',\n minWidth = '',\n maxWidth = '',\n editable = true,\n indentWithTab: defaultIndentWithTab = true,\n basicSetup: defaultBasicSetup = true,\n root,\n } = props;\n const [container, setContainer] = useState(props.container);\n const [view, setView] = useState<EditorView>();\n const [state, setState] = useState<EditorState>();\n const defaultThemeOption = EditorView.theme({\n '&': {\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n },\n });\n const updateListener = EditorView.updateListener.of((vu: ViewUpdate) => {\n if (vu.docChanged && typeof onChange === 'function') {\n const doc = vu.state.doc;\n const value = doc.toString();\n onChange(value, vu);\n }\n });\n let getExtensions = [updateListener, defaultThemeOption];\n if (defaultIndentWithTab) {\n getExtensions.unshift(keymap.of([indentWithTab]));\n }\n if (defaultBasicSetup) {\n if (Array.isArray(basicSetup)) {\n /**\n * 🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧\n * This is not a solution.\n * https://github.com/uiwjs/react-codemirror/issues/280\n */\n basicSetup.map((item) => {\n if (item.value && Array.isArray(item.value)) {\n item.value = item.value\n .map((keymap: any) => {\n if ('Mod-f' === keymap.key) {\n return undefined;\n }\n return keymap;\n })\n .filter(Boolean);\n }\n return item;\n });\n }\n getExtensions.unshift(basicSetup);\n }\n\n if (placeholderStr) {\n getExtensions.unshift(placeholder(placeholderStr));\n }\n\n switch (theme) {\n case 'light':\n getExtensions.push(defaultLightThemeOption);\n break;\n case 'dark':\n getExtensions.push(oneDark);\n break;\n default:\n getExtensions.push(theme);\n break;\n }\n\n if (editable === false) {\n getExtensions.push(EditorView.editable.of(false));\n }\n\n if (onUpdate && typeof onUpdate === 'function') {\n getExtensions.push(EditorView.updateListener.of(onUpdate));\n }\n getExtensions = getExtensions.concat(extensions);\n\n useEffect(() => {\n if (container && !state) {\n const stateCurrent = EditorState.create({\n doc: value,\n selection,\n extensions: getExtensions,\n });\n setState(stateCurrent);\n if (!view) {\n const viewCurrent = new EditorView({\n state: stateCurrent,\n parent: container,\n root,\n });\n setView(viewCurrent);\n }\n }\n return () => {\n if (view) {\n setView(undefined);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [container, state]);\n\n useEffect(\n () => () => {\n if (view) {\n view.destroy();\n setView(undefined);\n }\n },\n [view],\n );\n\n useEffect(() => {\n if (autoFocus && view) {\n view.focus();\n }\n }, [autoFocus, view]);\n\n useEffect(() => {\n const currentValue = view ? view.state.doc.toString() : '';\n if (view && value !== currentValue) {\n view.dispatch({\n changes: { from: 0, to: currentValue.length, insert: value || '' },\n });\n }\n }, [value, view]);\n\n useEffect(() => {\n if (view) {\n view.dispatch({ effects: StateEffect.reconfigure.of(getExtensions) });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n theme,\n extensions,\n height,\n minHeight,\n maxHeight,\n width,\n placeholderStr,\n minWidth,\n maxWidth,\n editable,\n defaultIndentWithTab,\n defaultBasicSetup,\n ]);\n\n return { state, setState, view, setView, container, setContainer };\n}\n"
75
+ "import { useEffect, useState } from 'react';\nimport { basicSetup } from '@codemirror/basic-setup';\nimport { EditorState, StateEffect } from '@codemirror/state';\nimport { indentWithTab } from '@codemirror/commands';\nimport { EditorView, keymap, ViewUpdate, placeholder } from '@codemirror/view';\nimport { oneDark } from '@codemirror/theme-one-dark';\nimport { ReactCodeMirrorProps } from './';\nimport { defaultLightThemeOption } from './theme/light';\n\nexport interface UseCodeMirror extends ReactCodeMirrorProps {\n container?: HTMLDivElement | null;\n}\n\nexport function useCodeMirror(props: UseCodeMirror) {\n const {\n value,\n selection,\n onChange,\n onUpdate,\n extensions = [],\n autoFocus,\n theme = 'light',\n height = '',\n minHeight = '',\n maxHeight = '',\n placeholder: placeholderStr = '',\n width = '',\n minWidth = '',\n maxWidth = '',\n editable = true,\n readOnly = false,\n indentWithTab: defaultIndentWithTab = true,\n basicSetup: defaultBasicSetup = true,\n root,\n } = props;\n const [container, setContainer] = useState(props.container);\n const [view, setView] = useState<EditorView>();\n const [state, setState] = useState<EditorState>();\n const defaultThemeOption = EditorView.theme({\n '&': {\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n },\n });\n const updateListener = EditorView.updateListener.of((vu: ViewUpdate) => {\n if (vu.docChanged && typeof onChange === 'function') {\n const doc = vu.state.doc;\n const value = doc.toString();\n onChange(value, vu);\n }\n });\n let getExtensions = [updateListener, defaultThemeOption];\n if (defaultIndentWithTab) {\n getExtensions.unshift(keymap.of([indentWithTab]));\n }\n if (defaultBasicSetup) {\n getExtensions.unshift(basicSetup);\n }\n\n if (placeholderStr) {\n getExtensions.unshift(placeholder(placeholderStr));\n }\n\n switch (theme) {\n case 'light':\n getExtensions.push(defaultLightThemeOption);\n break;\n case 'dark':\n getExtensions.push(oneDark);\n break;\n default:\n getExtensions.push(theme);\n break;\n }\n\n if (editable === false) {\n getExtensions.push(EditorView.editable.of(false));\n }\n if (readOnly) {\n getExtensions.push(EditorState.readOnly.of(true));\n }\n\n if (onUpdate && typeof onUpdate === 'function') {\n getExtensions.push(EditorView.updateListener.of(onUpdate));\n }\n getExtensions = getExtensions.concat(extensions);\n\n useEffect(() => {\n if (container && !state) {\n const stateCurrent = EditorState.create({\n doc: value,\n selection,\n extensions: getExtensions,\n });\n setState(stateCurrent);\n if (!view) {\n const viewCurrent = new EditorView({\n state: stateCurrent,\n parent: container,\n root,\n });\n setView(viewCurrent);\n }\n }\n return () => {\n if (view) {\n setView(undefined);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [container, state]);\n\n useEffect(\n () => () => {\n if (view) {\n view.destroy();\n setView(undefined);\n }\n },\n [view],\n );\n\n useEffect(() => {\n if (autoFocus && view) {\n view.focus();\n }\n }, [autoFocus, view]);\n\n useEffect(() => {\n const currentValue = view ? view.state.doc.toString() : '';\n if (view && value !== currentValue) {\n view.dispatch({\n changes: { from: 0, to: currentValue.length, insert: value || '' },\n });\n }\n }, [value, view]);\n\n useEffect(() => {\n if (view) {\n view.dispatch({ effects: StateEffect.reconfigure.of(getExtensions) });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n theme,\n extensions,\n height,\n minHeight,\n maxHeight,\n width,\n placeholderStr,\n minWidth,\n maxWidth,\n editable,\n defaultIndentWithTab,\n defaultBasicSetup,\n ]);\n\n return { state, setState, view, setView, container, setContainer };\n}\n"
82
76
  ]
83
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-codemirror",
3
- "version": "4.5.2",
3
+ "version": "4.7.0",
4
4
  "description": "CodeMirror component for React.",
5
5
  "homepage": "https://uiwjs.github.io/react-codemirror",
6
6
  "main": "cjs/index.js",
@@ -61,47 +61,48 @@
61
61
  "react-dom": ">=16.8.0"
62
62
  },
63
63
  "dependencies": {
64
- "@babel/runtime": "^7.17.2",
65
- "@codemirror/basic-setup": "^0.19.1",
66
- "@codemirror/state": "^0.19.9",
67
- "@codemirror/theme-one-dark": "^0.19.1",
68
- "@codemirror/view": "^0.19.45"
64
+ "@babel/runtime": ">=7.11.0",
65
+ "@codemirror/basic-setup": "^0.20.0",
66
+ "@codemirror/state": "^0.20.0",
67
+ "@codemirror/theme-one-dark": "^0.20.0",
68
+ "@codemirror/view": "^0.20.0"
69
69
  },
70
70
  "devDependencies": {
71
- "@codemirror/lang-cpp": "~0.19.1",
72
- "@codemirror/lang-html": "~0.19.4",
73
- "@codemirror/lang-java": "~0.19.1",
74
- "@codemirror/lang-javascript": "~0.19.7",
75
- "@codemirror/lang-json": "~0.19.2",
76
- "@codemirror/lang-lezer": "~0.19.1",
77
- "@codemirror/lang-markdown": "~0.19.6",
78
- "@codemirror/lang-php": "~0.19.1",
79
- "@codemirror/lang-python": "~0.19.4",
80
- "@codemirror/lang-rust": "~0.19.1",
81
- "@codemirror/lang-sql": "~0.19.4",
82
- "@codemirror/lang-xml": "~0.19.2",
83
- "@codemirror/legacy-modes": "~0.19.0",
71
+ "@codemirror/lang-cpp": "~0.20.0",
72
+ "@codemirror/lang-html": "~0.20.0",
73
+ "@codemirror/lang-java": "~0.20.0",
74
+ "@codemirror/lang-javascript": "~0.20.0",
75
+ "@codemirror/lang-json": "~0.20.0",
76
+ "@codemirror/lang-lezer": "~0.20.0",
77
+ "@codemirror/lang-markdown": "~0.20.0",
78
+ "@codemirror/lang-php": "~0.20.0",
79
+ "@codemirror/lang-python": "~0.20.0",
80
+ "@codemirror/lang-rust": "~0.20.0",
81
+ "@codemirror/lang-sql": "~0.20.0",
82
+ "@codemirror/lang-xml": "~0.20.0",
83
+ "@codemirror/legacy-modes": "~0.20.0",
84
84
  "@codemirror/stream-parser": "~0.19.6",
85
85
  "@kkt/less-modules": "~7.1.1",
86
86
  "@kkt/ncc": "~1.0.8",
87
87
  "@kkt/raw-modules": "~7.1.1",
88
88
  "@kkt/scope-plugin-options": "~7.1.1",
89
- "@types/react": "~17.0.39",
90
- "@types/react-dom": "~17.0.11",
91
- "@types/react-test-renderer": "~17.0.1",
92
- "@uiw/react-github-corners": "~1.5.3",
93
- "@uiw/react-markdown-preview": "~4.0.3",
94
- "@uiw/react-shields": "~1.1.2",
89
+ "@testing-library/react": "^13.0.0",
90
+ "@types/react": "~18.0.1",
91
+ "@types/react-dom": "~18.0.0",
92
+ "@types/react-test-renderer": "~18.0.0",
93
+ "@uiw/react-github-corners": "~1.5.14",
94
+ "@uiw/react-markdown-preview": "~4.0.5",
95
+ "@uiw/react-shields": "~1.1.3",
95
96
  "@uiw/reset.css": "~1.0.5",
96
97
  "@wcj/dark-mode": "~1.0.12",
97
98
  "code-example": "~3.3.1",
98
99
  "husky": "~7.0.4",
99
100
  "kkt": "~7.1.5",
100
- "lint-staged": "~12.3.4",
101
- "prettier": "~2.5.1",
102
- "react": "~17.0.2",
103
- "react-dom": "~17.0.2",
104
- "react-test-renderer": "~17.0.2",
101
+ "lint-staged": "~12.4.0",
102
+ "prettier": "~2.6.0",
103
+ "react": "~18.0.0",
104
+ "react-dom": "~18.0.0",
105
+ "react-test-renderer": "~18.0.0",
105
106
  "tsbb": "~3.7.0"
106
107
  },
107
108
  "browserslist": {
package/src/index.tsx CHANGED
@@ -38,6 +38,7 @@ export interface ReactCodeMirrorProps
38
38
  * @default true
39
39
  */
40
40
  editable?: boolean;
41
+ readOnly?: boolean;
41
42
  /**
42
43
  * Whether to optional basicSetup by default
43
44
  * @default true
@@ -87,6 +88,7 @@ const ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProp
87
88
  placeholder,
88
89
  indentWithTab,
89
90
  editable,
91
+ readOnly,
90
92
  root,
91
93
  ...other
92
94
  } = props;
@@ -107,6 +109,7 @@ const ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProp
107
109
  placeholder,
108
110
  indentWithTab,
109
111
  editable,
112
+ readOnly,
110
113
  selection,
111
114
  onChange,
112
115
  onUpdate,
@@ -28,6 +28,7 @@ export function useCodeMirror(props: UseCodeMirror) {
28
28
  minWidth = '',
29
29
  maxWidth = '',
30
30
  editable = true,
31
+ readOnly = false,
31
32
  indentWithTab: defaultIndentWithTab = true,
32
33
  basicSetup: defaultBasicSetup = true,
33
34
  root,
@@ -57,26 +58,6 @@ export function useCodeMirror(props: UseCodeMirror) {
57
58
  getExtensions.unshift(keymap.of([indentWithTab]));
58
59
  }
59
60
  if (defaultBasicSetup) {
60
- if (Array.isArray(basicSetup)) {
61
- /**
62
- * 🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧
63
- * This is not a solution.
64
- * https://github.com/uiwjs/react-codemirror/issues/280
65
- */
66
- basicSetup.map((item) => {
67
- if (item.value && Array.isArray(item.value)) {
68
- item.value = item.value
69
- .map((keymap: any) => {
70
- if ('Mod-f' === keymap.key) {
71
- return undefined;
72
- }
73
- return keymap;
74
- })
75
- .filter(Boolean);
76
- }
77
- return item;
78
- });
79
- }
80
61
  getExtensions.unshift(basicSetup);
81
62
  }
82
63
 
@@ -99,6 +80,9 @@ export function useCodeMirror(props: UseCodeMirror) {
99
80
  if (editable === false) {
100
81
  getExtensions.push(EditorView.editable.of(false));
101
82
  }
83
+ if (readOnly) {
84
+ getExtensions.push(EditorState.readOnly.of(true));
85
+ }
102
86
 
103
87
  if (onUpdate && typeof onUpdate === 'function') {
104
88
  getExtensions.push(EditorView.updateListener.of(onUpdate));