/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
import{NodeProp as t,Tree as e,IterMode as r,TreeFragment as n,Parser as o,NodeType as s}from"../../../@lezer/common/dist/index.js";import{Facet as i,Prec as l,EditorState as a,RangeSetBuilder as c,RangeSet as h,StateField as u,StateEffect as f,combineConfig as d,countColumn as p}from"../../state/dist/index.js";import{EditorView as m,ViewPlugin as g,Decoration as k,gutter as v,GutterMarker as w,logException as x,WidgetType as y,Direction as b}from"../../view/dist/index.js";import{tagHighlighter as A,highlightTree as S,tags as C,styleTags as T}from"../../../@lezer/highlight/dist/index.js";import{StyleModule as D}from"../../../style-mod/src/style-mod.js";var O;const B=/* @__PURE__ */new t;function P(t){return i.define({combine:t?e=>e.concat(t):void 0})}const N=/* @__PURE__ */new t;class I{constructor(t,e,r=[],n=""){this.data=t,this.name=n,a.prototype.hasOwnProperty("tree")||Object.defineProperty(a.prototype,"tree",{get(){return L(this)}}),this.parser=e,this.extension=[J.of(this),a.languageData.of((t,e,r)=>{let n=M(t,e,r),o=n.type.prop(B);if(!o)return[];let s=t.facet(o),i=n.type.prop(N);if(i){let o=n.resolve(e-n.from,r);for(let e of i)if(e.test(o,t)){let r=t.facet(e.facet);return"replace"==e.type?r:r.concat(s)}}return s})].concat(r)}isActiveAt(t,e,r=-1){return M(t,e,r).type.prop(B)==this.data}findRegions(r){let n=r.facet(J);if((null==n?void 0:n.data)==this.data)return[{from:0,to:r.doc.length}];if(!n||!n.allowsNesting)return[];let o=[],s=(r,n)=>{if(r.prop(B)==this.data)return void o.push({from:n,to:n+r.length});let i=r.prop(t.mounted);if(i){if(i.tree.prop(B)==this.data){if(i.overlay)for(let t of i.overlay)o.push({from:t.from+n,to:t.to+n});else o.push({from:n,to:n+r.length});return}if(i.overlay){let t=o.length;if(s(i.tree,i.overlay[0].from+n),o.length>t)return}}for(let t=0;t<r.children.length;t++){let o=r.children[t];o instanceof e&&s(o,r.positions[t]+n)}};return s(L(r),0),o}get allowsNesting(){return!0}}function M(t,e,n){let o=t.facet(J),s=L(t).topNode;if(!o||o.allowsNesting)for(let i=s;i;i=i.enter(e,n,r.ExcludeBuffers|r.EnterBracketed))i.type.isTop&&(s=i);return s}I.setState=/* @__PURE__ */f.define();class E extends I{constructor(t,e,r){super(t,e,[],r),this.parser=e}static define(t){let e=P(t.languageData);return new E(e,t.parser.configure({props:[B.add(t=>t.isTop?e:void 0)]}),t.name)}configure(t,e){return new E(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function L(t){let r=t.field(I.state,!1);return r?r.tree:e.empty}class j{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}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 R=null;class W{constructor(t,e,r=[],n,o,s,i,l){this.parser=t,this.state=e,this.fragments=r,this.tree=n,this.treeLen=o,this.viewport=s,this.skipped=i,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,r,n){return new W(t,r,[],e.empty,0,n,[],null)}startParse(){return this.parser.startParse(new j(this.state.doc),this.fragments)}work(t,r){return null!=r&&r>=this.state.doc.length&&(r=void 0),this.tree!=e.empty&&this.isDone(null!=r?r:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var e;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=r&&(null==this.parse.stoppedAt||this.parse.stoppedAt>r)&&r<this.state.doc.length&&this.parse.stopAt(r);;){let o=this.parse.advance();if(o){if(this.fragments=this.withoutTempSkipped(n.addTree(o,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(e=this.parse.stoppedAt)&&void 0!==e?e:this.state.doc.length,this.tree=o,this.parse=null,!(this.treeLen<(null!=r?r:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())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(n.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=R;R=this;try{return t()}finally{R=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=F(t,e.from,e.to);return t}changes(t,r){let{fragments:o,tree:s,treeLen:i,viewport:l,skipped:a}=this;if(this.takeTree(),!t.empty){let r=[];if(t.iterChangedRanges((t,e,n,o)=>r.push({fromA:t,toA:e,fromB:n,toB:o})),o=n.applyChanges(o,r),s=e.empty,i=0,l={from:t.mapPos(l.from,-1),to:t.mapPos(l.to,1)},this.skipped.length){a=[];for(let e of this.skipped){let r=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);r<n&&a.push({from:r,to:n})}}}return new W(this.parser,r,o,s,i,l,a,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=F(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 o{createParse(r,n,o){let i=o[0].from,l=o[o.length-1].to;return{parsedPos:i,advance(){let r=R;if(r){for(let t of o)r.tempSkipped.push(t);t&&(r.scheduleOn=r.scheduleOn?Promise.all([r.scheduleOn,t]):t)}return this.parsedPos=l,new e(s.none,[],[],l-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 R}}function F(t,e,r){return n.applyChanges(t,[{fromA:e,toA:r,fromB:e,toB:r}])}class ${constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)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 $(e)}static init(t){let e=Math.min(3e3,t.doc.length),r=W.create(t.facet(J).parser,t,{from:0,to:e});return r.work(20,e)||r.takeTree(),new $(r)}}I.state=/* @__PURE__ */u.define({create:$.init,update(t,e){for(let r of e.effects)if(r.is(I.setState))return r.value;return e.startState.facet(J)!=e.state.facet(J)?$.init(e.state):t.apply(e)}});let U=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(U=t=>{let e=-1,r=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(r):cancelIdleCallback(e)});const q="undefined"!=typeof navigator&&(null===(O=navigator.scheduling)||void 0===O?void 0:O.isInputPending)?()=>navigator.scheduling.isInputPending():null,z=/* @__PURE__ */g.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(I.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(I.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=U(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,o=r.field(I.state);if(o.tree==o.context.tree&&o.context.isDone(n+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,t&&!q?Math.max(25,t.timeRemaining()-5):1e9),i=o.context.treeLen<n&&r.doc.length>n+1e3,l=o.context.work(()=>q&&q()||Date.now()>s,n+(i?0:1e5));this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:I.setState.of(new $(o.context))})),this.chunkBudget>0&&(!l||i)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(t=>x(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()}}}),J=/* @__PURE__ */i.define({combine:t=>t.length?t[0]:null,enables:t=>[I.state,z,m.contentAttributes.compute([t],e=>{let r=e.facet(t);return r&&r.name?{"data-language":r.name}:{}})]});class H{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}const V=/* @__PURE__ */i.define(),G=/* @__PURE__ */i.define({combine:t=>{if(!t.length)return"  ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function _(t){let e=t.facet(G);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function K(t,e){let r="",n=t.tabSize,o=t.facet(G)[0];if("\t"==o){for(;e>=n;)r+="\t",e-=n;o=" "}for(let s=0;s<e;s++)r+=o;return r}function Q(t,e){t instanceof a&&(t=new X(t));for(let n of t.state.facet(V)){let r=n(t,e);if(void 0!==r)return r}let r=L(t.state);return r.length>=e?function(t,e,r){let n=e.resolveStack(r),o=e.resolveInner(r,-1).resolve(r,0).enterUnfinishedNodesBefore(r);if(o!=n.node){let t=[];for(let e=o;e&&!(e.from<n.node.from||e.to>n.node.to||e.from==n.node.from&&e.type==n.node.type);e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)n={node:t[e],next:n}}return Z(n,t,r)}(t,r,e):null}class X{constructor(t,e={}){this.state=t,this.options=e,this.unit=_(t)}lineAt(t,e=1){let r=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:o}=this.options;return null!=n&&n>=r.from&&n<=r.to?o&&n==t?{text:"",from:t}:(e<0?n<t:n<=t)?{text:r.text.slice(n-r.from),from:n}:{text:r.text.slice(0,n-r.from),from:r.from}:r}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:r,from:n}=this.lineAt(t,e);return r.slice(t-n,Math.min(r.length,t+100-n))}column(t,e=1){let{text:r,from:n}=this.lineAt(t,e),o=this.countColumn(r,t-n),s=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return s>-1&&(o+=s-this.countColumn(r,r.search(/\S|$/))),o}countColumn(t,e=t.length){return p(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:r,from:n}=this.lineAt(t,e),o=this.options.overrideIndentation;if(o){let t=o(n);if(t>-1)return t}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Y=/* @__PURE__ */new t;function Z(t,e,r){for(let n=t;n;n=n.next){let t=tt(n.node);if(t)return t(rt.create(e,r,n))}return 0}function tt(e){let r=e.type.prop(Y);if(r)return r;let n,o=e.firstChild;if(o&&(n=o.type.prop(t.closedBy))){let t=e.lastChild,r=t&&n.indexOf(t.name)>-1;return e=>st(e,!0,1,void 0,r&&!function(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?et:null}function et(){return 0}class rt extends X{constructor(t,e,r){super(t.state,t.options),this.base=t,this.pos=e,this.context=r}get node(){return this.context.node}static create(t,e,r){return new rt(t,e,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(e.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(nt(r,t))break;e=this.state.doc.lineAt(r.from)}return this.lineIndent(e.from)}continue(){return Z(this.context.next,this.base,this.pos)}}function nt(t,e){for(let r=e;r;r=r.parent)if(t==r)return!0;return!1}function ot({closing:t,align:e=!0,units:r=1}){return n=>st(n,e,r,t)}function st(t,e,r,n,o){let s=t.textAfter,i=s.match(/^\s*/)[0].length,l=n&&s.slice(i,i+n.length)==n||o==t.pos+i,a=e?function(t){let e=t.node,r=e.childAfter(e.from),n=e.lastChild;if(!r)return null;let o=t.options.simulateBreak,s=t.state.doc.lineAt(r.from),i=null==o||o<=s.from?s.to:Math.min(s.to,o);for(let l=r.to;;){let t=e.childAfter(l);if(!t||t==n)return null;if(!t.type.isSkipped){if(t.from>=i)return null;let e=/^ */.exec(s.text.slice(r.to-s.from))[0].length;return{from:r.from,to:r.to+e}}l=t.to}}(t):null;return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*r)}const it=t=>t.baseIndent;function lt({except:t,units:e=1}={}){return r=>{let n=t&&t.test(r.textAfter);return r.baseIndent+(n?0:e*r.unit)}}function at(){return a.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let r=t.newDoc,{head:n}=t.newSelection.main,o=r.lineAt(n);if(n>o.from+200)return t;let s=r.sliceString(o.from,n);if(!e.some(t=>t.test(s)))return t;let{state:i}=t,l=-1,a=[];for(let{head:c}of i.selection.ranges){let t=i.doc.lineAt(c);if(t.from==l)continue;l=t.from;let e=Q(i,t.from);if(null==e)continue;let r=/^\s*/.exec(t.text)[0],n=K(i,e);r!=n&&a.push({from:t.from,to:t.from+r.length,insert:n})}return a.length?[t,{changes:a,sequential:!0}]:t})}const ct=/* @__PURE__ */i.define(),ht=/* @__PURE__ */new t;function ut(t){let e=t.firstChild,r=t.lastChild;return e&&e.to<r.from?{from:e.to,to:r.type.isError?t.to:r.from}:null}function ft(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function dt(t,e,r){for(let n of t.facet(ct)){let o=n(t,e,r);if(o)return o}return function(t,e,r){let n=L(t);if(n.length<r)return null;let o=null;for(let s=n.resolveStack(r,1);s;s=s.next){let i=s.node;if(i.to<=r||i.from>r)continue;if(o&&i.from<e)break;let l=i.type.prop(ht);if(l&&(i.to<n.length-50||n.length==t.doc.length||!ft(i))){let n=l(i,t);n&&n.from<=r&&n.from>=e&&n.to>r&&(o=n)}}return o}(t,e,r)}function pt(t,e){let r=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);return r>=n?void 0:{from:r,to:n}}const mt=/* @__PURE__ */f.define({map:pt}),gt=/* @__PURE__ */f.define({map:pt});function kt(t){let e=[];for(let{head:r}of t.state.selection.ranges)e.some(t=>t.from<=r&&t.to>=r)||e.push(t.lineBlockAt(r));return e}const vt=/* @__PURE__ */u.define({create:()=>k.none,update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((e,r)=>t=wt(t,e,r)),t=t.map(e.changes);for(let r of e.effects)if(r.is(mt)&&!yt(t,r.value.from,r.value.to)){let{preparePlaceholder:n}=e.state.facet(Pt),o=n?k.replace({widget:new Et(n(e.state,r.value))}):Mt;t=t.update({add:[o.range(r.value.from,r.value.to)]})}else r.is(gt)&&(t=t.update({filter:(t,e)=>r.value.from!=t||r.value.to!=e,filterFrom:r.value.from,filterTo:r.value.to}));return e.selection&&(t=wt(t,e.selection.main.head)),t},provide:t=>m.decorations.from(t),toJSON(t,e){let r=[];return t.between(0,e.doc.length,(t,e)=>{r.push(t,e)}),r},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let r=0;r<t.length;){let n=t[r++],o=t[r++];if("number"!=typeof n||"number"!=typeof o)throw new RangeError("Invalid JSON for fold state");e.push(Mt.range(n,o))}return k.set(e,!0)}});function wt(t,e,r=e){let n=!1;return t.between(e,r,(t,o)=>{t<r&&o>e&&(n=!0)}),n?t.update({filterFrom:e,filterTo:r,filter:(t,n)=>t>=r||n<=e}):t}function xt(t,e,r){var n;let o=null;return null===(n=t.field(vt,!1))||void 0===n||n.between(e,r,(t,e)=>{(!o||o.from>t)&&(o={from:t,to:e})}),o}function yt(t,e,r){let n=!1;return t.between(e,e,(t,o)=>{t==e&&o==r&&(n=!0)}),n}function bt(t,e){return t.field(vt,!1)?e:e.concat(f.appendConfig.of(Nt()))}const At=t=>{for(let e of kt(t)){let r=dt(t.state,e.from,e.to);if(r)return t.dispatch({effects:bt(t.state,[mt.of(r),Ct(t,r)])}),!0}return!1},St=t=>{if(!t.state.field(vt,!1))return!1;let e=[];for(let r of kt(t)){let n=xt(t.state,r.from,r.to);n&&e.push(gt.of(n),Ct(t,n,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function Ct(t,e,r=!0){let n=t.state.doc.lineAt(e.from).number,o=t.state.doc.lineAt(e.to).number;return m.announce.of(`${t.state.phrase(r?"Folded lines":"Unfolded lines")} ${n} ${t.state.phrase("to")} ${o}.`)}const Tt=t=>{let{state:e}=t,r=[];for(let n=0;n<e.doc.length;){let o=t.lineBlockAt(n),s=dt(e,o.from,o.to);s&&r.push(mt.of(s)),n=(s?t.lineBlockAt(s.to):o).to+1}return r.length&&t.dispatch({effects:bt(t.state,r)}),!!r.length},Dt=t=>{let e=t.state.field(vt,!1);if(!e||!e.size)return!1;let r=[];return e.between(0,t.state.doc.length,(t,e)=>{r.push(gt.of({from:t,to:e}))}),t.dispatch({effects:r}),!0},Ot=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:At},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:St},{key:"Ctrl-Alt-[",run:Tt},{key:"Ctrl-Alt-]",run:Dt}],Bt={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Pt=/* @__PURE__ */i.define({combine:t=>d(t,Bt)});function Nt(t){return[vt,Wt]}function It(t,e){let{state:r}=t,n=r.facet(Pt),o=e=>{let r=t.lineBlockAt(t.posAtDOM(e.target)),n=xt(t.state,r.from,r.to);n&&t.dispatch({effects:gt.of(n)}),e.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(t,o,e);let s=document.createElement("span");return s.textContent=n.placeholderText,s.setAttribute("aria-label",r.phrase("folded code")),s.title=r.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=o,s}const Mt=/* @__PURE__ */k.replace({widget:/* @__PURE__ */new class extends y{toDOM(t){return It(t,null)}}});class Et extends y{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return It(t,this.value)}}const Lt={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class jt extends w{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function Rt(t={}){let e={...Lt,...t},r=new jt(e,!0),n=new jt(e,!1),o=g.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(J)!=t.state.facet(J)||t.startState.field(vt,!1)!=t.state.field(vt,!1)||L(t.startState)!=L(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new c;for(let o of t.viewportLineBlocks){let s=xt(t.state,o.from,o.to)?n:dt(t.state,o.from,o.to)?r:null;s&&e.add(o.from,o.from,s)}return e.finish()}}),{domEventHandlers:s}=e;return[o,v({class:"cm-foldGutter",markers(t){var e;return(null===(e=t.plugin(o))||void 0===e?void 0:e.markers)||h.empty},initialSpacer:()=>new jt(e,!1),domEventHandlers:{...s,click:(t,e,r)=>{if(s.click&&s.click(t,e,r))return!0;let n=xt(t.state,e.from,e.to);if(n)return t.dispatch({effects:gt.of(n)}),!0;let o=dt(t.state,e.from,e.to);return!!o&&(t.dispatch({effects:mt.of(o)}),!0)}}}),Nt()]}const Wt=/* @__PURE__ */m.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Ft{constructor(t,e){let r;function n(t){let e=D.newName();return(r||(r=/* @__PURE__ */Object.create(null)))["."+e]=t,e}this.specs=t;const o="string"==typeof e.all?e.all:e.all?n(e.all):void 0,s=e.scope;this.scope=s instanceof I?t=>t.prop(B)==s.data:s?t=>t==s:void 0,this.style=A(t.map(t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))})),{all:o}).style,this.module=r?new D(r):null,this.themeType=e.themeType}static define(t,e){return new Ft(t,e||{})}}const $t=/* @__PURE__ */i.define(),Ut=/* @__PURE__ */i.define({combine:t=>t.length?[t[0]]:null});function qt(t){let e=t.facet($t);return e.length?e:t.facet(Ut)}function zt(t,e){let r,n=[Ht];return t instanceof Ft&&(t.module&&n.push(m.styleModule.of(t.module)),r=t.themeType),(null==e?void 0:e.fallback)?n.push(Ut.of(t)):r?n.push($t.computeN([m.darkTheme],e=>e.facet(m.darkTheme)==("dark"==r)?[t]:[])):n.push($t.of(t)),n}class Jt{constructor(t){this.markCache=/* @__PURE__ */Object.create(null),this.tree=L(t.state),this.decorations=this.buildDeco(t,qt(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=L(t.state),r=qt(t.state),n=r!=qt(t.startState),{viewport:o}=t.view,s=t.changes.mapPos(this.decoratedTo,1);e.length<o.to&&!n&&e.type==this.tree.type&&s>=o.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=s):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,r),this.decoratedTo=o.to)}buildDeco(t,e){if(!e||!this.tree.length)return k.none;let r=new c;for(let{from:n,to:o}of t.visibleRanges)S(this.tree,e,(t,e,n)=>{r.add(t,e,this.markCache[n]||(this.markCache[n]=k.mark({class:n})))},n,o);return r.finish()}}const Ht=/* @__PURE__ */l.high(/* @__PURE__ */g.fromClass(Jt,{decorations:t=>t.decorations})),Vt=/* @__PURE__ */Ft.define([{tag:C.meta,color:"#404740"},{tag:C.link,textDecoration:"underline"},{tag:C.heading,textDecoration:"underline",fontWeight:"bold"},{tag:C.emphasis,fontStyle:"italic"},{tag:C.strong,fontWeight:"bold"},{tag:C.strikethrough,textDecoration:"line-through"},{tag:C.keyword,color:"#708"},{tag:[C.atom,C.bool,C.url,C.contentSeparator,C.labelName],color:"#219"},{tag:[C.literal,C.inserted],color:"#164"},{tag:[C.string,C.deleted],color:"#a11"},{tag:[C.regexp,C.escape,/* @__PURE__ */C.special(C.string)],color:"#e40"},{tag:/* @__PURE__ */C.definition(C.variableName),color:"#00f"},{tag:/* @__PURE__ */C.local(C.variableName),color:"#30a"},{tag:[C.typeName,C.namespace],color:"#085"},{tag:C.className,color:"#167"},{tag:[/* @__PURE__ */C.special(C.variableName),C.macroName],color:"#256"},{tag:/* @__PURE__ */C.definition(C.propertyName),color:"#00c"},{tag:C.comment,color:"#940"},{tag:C.invalid,color:"#f00"}]),Gt=/* @__PURE__ */m.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),_t="()[]{}",Kt=/* @__PURE__ */i.define({combine:t=>d(t,{afterCursor:!0,brackets:_t,maxScanDistance:1e4,renderMatch:Yt})}),Qt=/* @__PURE__ */k.mark({class:"cm-matchingBracket"}),Xt=/* @__PURE__ */k.mark({class:"cm-nonmatchingBracket"});function Yt(t){let e=[],r=t.matched?Qt:Xt;return e.push(r.range(t.start.from,t.start.to)),t.end&&e.push(r.range(t.end.from,t.end.to)),e}function Zt(t){let e=[],r=t.facet(Kt);for(let n of t.selection.ranges){if(!n.empty)continue;let o=se(t,n.head,-1,r)||n.head>0&&se(t,n.head-1,1,r)||r.afterCursor&&(se(t,n.head,1,r)||n.head<t.doc.length&&se(t,n.head+1,-1,r));o&&(e=e.concat(r.renderMatch(o,t)))}return k.set(e,!0)}const te=[/* @__PURE__ */g.fromClass(class{constructor(t){this.paused=!1,this.decorations=Zt(t.state)}update(t){(t.docChanged||t.selectionSet||this.paused)&&(t.view.composing?(this.decorations=this.decorations.map(t.changes),this.paused=!0):(this.decorations=Zt(t.state),this.paused=!1))}},{decorations:t=>t.decorations}),Gt];function ee(t={}){return[Kt.of(t),te]}const re=/* @__PURE__ */new t;function ne(e,r,n){let o=e.prop(r<0?t.openedBy:t.closedBy);if(o)return o;if(1==e.name.length){let t=n.indexOf(e.name);if(t>-1&&t%2==(r<0?1:0))return[n[t+r]]}return null}function oe(t){let e=t.type.prop(re);return e?e(t.node):t}function se(t,e,r,n={}){let o=n.maxScanDistance||1e4,s=n.brackets||_t,i=L(t),l=i.resolveInner(e,r);for(let a=l;a;a=a.parent){let n=ne(a.type,r,s);if(n&&a.from<a.to){let o=oe(a);if(o&&(r>0?e>=o.from&&e<o.to:e>o.from&&e<=o.to))return ie(t,e,r,a,o,n,s)}}return function(t,e,r,n,o,s,i){let l=r<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),a=i.indexOf(l);if(a<0||a%2==0!=r>0)return null;let c={from:r<0?e-1:e,to:r>0?e+1:e},h=t.doc.iterRange(e,r>0?t.doc.length:0),u=0;for(let f=0;!h.next().done&&f<=s;){let t=h.value;r<0&&(f+=t.length);let s=e+f*r;for(let e=r>0?0:t.length-1,l=r>0?t.length:-1;e!=l;e+=r){let l=i.indexOf(t[e]);if(!(l<0||n.resolveInner(s+e,1).type!=o))if(l%2==0==r>0)u++;else{if(1==u)return{start:c,end:{from:s+e,to:s+e+1},matched:l>>1==a>>1};u--}}r>0&&(f+=t.length)}return h.done?{start:c,matched:!1}:null}(t,e,r,i,l.type,o,s)}function ie(t,e,r,n,o,s,i){let l=n.parent,a={from:o.from,to:o.to},c=0,h=null==l?void 0:l.cursor();if(h&&(r<0?h.childBefore(n.from):h.childAfter(n.to)))do{if(r<0?h.to<=n.from:h.from>=n.to){if(0==c&&s.indexOf(h.type.name)>-1&&h.from<h.to){let t=oe(h);return{start:a,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}if(ne(h.type,r,i))c++;else if(ne(h.type,-r,i)){if(0==c){let t=oe(h);return{start:a,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}c--}}}while(r<0?h.prevSibling():h.nextSibling());return{start:a,matched:!1}}const le=/* @__PURE__ */Object.create(null),ae=[s.none],ce=[],he=/* @__PURE__ */Object.create(null),ue=/* @__PURE__ */Object.create(null);for(let[pe,me]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])ue[pe]=/* @__PURE__ */de(le,me);function fe(t,e){ce.indexOf(t)>-1||(ce.push(t),console.warn(e))}function de(t,e){let r=[];for(let s of e.split(" ")){let e=[];for(let r of s.split(".")){let n=t[r]||C[r];n?"function"==typeof n?e.length?e=e.map(n):fe(r,`Modifier ${r} used at start of tag`):e.length?fe(r,`Tag ${r} used as modifier`):e=Array.isArray(n)?n:[n]:fe(r,`Unknown highlighting tag ${r}`)}for(let t of e)r.push(t)}if(!r.length)return 0;let n=e.replace(/ /g,"_"),o=n+" "+r.map(t=>t.id),i=he[o];if(i)return i.id;let l=he[o]=s.define({id:ae.length,name:n,props:[T({[n]:r})]});return ae.push(l),l.id}b.RTL,b.LTR;export{j as DocInput,Ft as HighlightStyle,X as IndentContext,E as LRLanguage,I as Language,H as LanguageSupport,W as ParseContext,rt as TreeIndentContext,ee as bracketMatching,re as bracketMatchingHandle,Nt as codeFolding,lt as continuedIndent,Vt as defaultHighlightStyle,P as defineLanguageFacet,ot as delimitedIndent,it as flatIndent,Tt as foldAll,At as foldCode,mt as foldEffect,Rt as foldGutter,ut as foldInside,Ot as foldKeymap,ht as foldNodeProp,ct as foldService,vt as foldState,dt as foldable,_ as getIndentUnit,Q as getIndentation,Y as indentNodeProp,at as indentOnInput,V as indentService,K as indentString,G as indentUnit,J as language,B as languageDataProp,se as matchBrackets,N as sublanguageProp,zt as syntaxHighlighting,L as syntaxTree,Dt as unfoldAll,St as unfoldCode,gt as unfoldEffect};