/*!
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}from"../../common/dist/index.js";let e=0;class a{constructor(t,a,i,r){this.name=t,this.set=a,this.base=i,this.modified=r,this.id=e++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i="string"==typeof t?t:"?";if(t instanceof a&&(e=t),null==e?void 0:e.base)throw new Error("Can not derive from a modified tag");let r=new a(i,[],null,[]);if(r.set.push(r),e)for(let a of e.set)r.set.push(a);return r}static defineModifier(t){let e=new r(t);return t=>t.modified.indexOf(e)>-1?t:r.get(t.base||t,t.modified.concat(e).sort((t,e)=>t.id-e.id))}}let i=0;class r{constructor(t){this.name=t,this.instances=[],this.id=i++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(a=>{return a.base==t&&(i=e,r=a.modified,i.length==r.length&&i.every((t,e)=>t==r[e]));var i,r});if(i)return i;let o=[],n=new a(t.name,o,t,e);for(let a of e)a.instances.push(n);let s=function(t){let e=[[]];for(let a=0;a<t.length;a++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(t[a]));return e.sort((t,e)=>e.length-t.length)}(e);for(let a of t.set)if(!a.modified.length)for(let t of s)o.push(r.get(a,t));return n}}function o(t){let e=/* @__PURE__ */Object.create(null);for(let a in t){let i=t[a];Array.isArray(i)||(i=[i]);for(let t of a.split(" "))if(t){let a=[],r=2,o=t;for(let e=0;;){if("..."==o&&e>0&&e+3==t.length){r=1;break}let i=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!i)throw new RangeError("Invalid path: "+t);if(a.push("*"==i[0]?"":'"'==i[0][0]?JSON.parse(i[0]):i[0]),e+=i[0].length,e==t.length)break;let n=t[e++];if(e==t.length&&"!"==n){r=0;break}if("/"!=n)throw new RangeError("Invalid path: "+t);o=t.slice(e)}let n=a.length-1,l=a[n];if(!l)throw new RangeError("Invalid path: "+t);let c=new s(i,r,n>0?a.slice(0,n):null);e[l]=c.sort(e[l])}}return n.add(e)}const n=new t({combine(t,e){let a,i,r;for(;t||e;){if(!t||e&&t.depth>=e.depth?(r=e,e=e.next):(r=t,t=t.next),a&&a.mode==r.mode&&!r.context&&!a.context)continue;let o=new s(r.tags,r.mode,r.context);a?a.next=o:i=o,a=o}return i}});class s{constructor(t,e,a,i){this.tags=t,this.mode=e,this.context=a,this.next=i}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}function l(t,e){let a=/* @__PURE__ */Object.create(null);for(let o of t)if(Array.isArray(o.tag))for(let t of o.tag)a[t.id]=o.class;else a[o.tag.id]=o.class;let{scope:i,all:r=null}=e||{};return{style:t=>{let e=r;for(let i of t)for(let t of i.set){let i=a[t.id];if(i){e=e?e+" "+i:i;break}}return e},scope:i}}function c(t,e,a,i=0,r=t.length){let o=new h(i,Array.isArray(e)?e:[e],a);o.highlightRange(t.cursor(),i,r,"",o.highlighters),o.flush(r)}s.empty=new s([],2,null);class h{constructor(t,e,a){this.at=t,this.highlighters=e,this.span=a,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(e,a,i,r,o){let{type:n,from:l,to:c}=e;if(l>=i||c<=a)return;n.isTop&&(o=this.highlighters.filter(t=>!t.scope||t.scope(n)));let h=r,g=f(e)||s.empty,d=function(t,e){let a=null;for(let i of t){let t=i.style(e);t&&(a=a?a+" "+t:t)}return a}(o,g.tags);if(d&&(h&&(h+=" "),h+=d,1==g.mode&&(r+=(r?" ":"")+d)),this.startSpan(Math.max(a,l),h),g.opaque)return;let m=e.tree&&e.tree.prop(t.mounted);if(m&&m.overlay){let t=e.node.enter(m.overlay[0].from+l,1),n=this.highlighters.filter(t=>!t.scope||t.scope(m.tree.type)),s=e.firstChild();for(let f=0,g=l;;f++){let d=f<m.overlay.length?m.overlay[f]:null,p=d?d.from+l:c,u=Math.max(a,g),k=Math.min(i,p);if(u<k&&s)for(;e.from<k&&(this.highlightRange(e,u,k,r,o),this.startSpan(Math.min(k,e.to),h),!(e.to>=p)&&e.nextSibling()););if(!d||p>i)break;g=d.to+l,g>a&&(this.highlightRange(t.cursor(),Math.max(a,d.from+l),Math.min(i,g),"",n),this.startSpan(Math.min(i,g),h))}s&&e.parent()}else if(e.firstChild()){m&&(r="");do{if(!(e.to<=a)){if(e.from>=i)break;this.highlightRange(e,a,i,r,o),this.startSpan(Math.min(i,e.to),h)}}while(e.nextSibling());e.parent()}}}function f(t){let e=t.type.prop(n);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const g=a.define,d=g(),m=g(),p=g(m),u=g(m),k=g(),b=g(k),y=g(k),N=g(),x=g(N),w=g(),v=g(),M=g(),O=g(M),S=g(),R={comment:d,lineComment:g(d),blockComment:g(d),docComment:g(d),name:m,variableName:g(m),typeName:p,tagName:g(p),propertyName:u,attributeName:g(u),className:g(m),labelName:g(m),namespace:g(m),macroName:g(m),literal:k,string:b,docString:g(b),character:g(b),attributeValue:g(b),number:y,integer:g(y),float:g(y),bool:g(k),regexp:g(k),escape:g(k),color:g(k),url:g(k),keyword:w,self:g(w),null:g(w),atom:g(w),unit:g(w),modifier:g(w),operatorKeyword:g(w),controlKeyword:g(w),definitionKeyword:g(w),moduleKeyword:g(w),operator:v,derefOperator:g(v),arithmeticOperator:g(v),logicOperator:g(v),bitwiseOperator:g(v),compareOperator:g(v),updateOperator:g(v),definitionOperator:g(v),typeOperator:g(v),controlOperator:g(v),punctuation:M,separator:g(M),bracket:O,angleBracket:g(O),squareBracket:g(O),paren:g(O),brace:g(O),content:N,heading:x,heading1:g(x),heading2:g(x),heading3:g(x),heading4:g(x),heading5:g(x),heading6:g(x),contentSeparator:g(N),list:g(N),quote:g(N),emphasis:g(N),strong:g(N),link:g(N),monospace:g(N),strikethrough:g(N),inserted:g(),deleted:g(),changed:g(),invalid:g(),meta:S,documentMeta:g(S),annotation:g(S),processingInstruction:g(S),definition:a.defineModifier("definition"),constant:a.defineModifier("constant"),function:a.defineModifier("function"),standard:a.defineModifier("standard"),local:a.defineModifier("local"),special:a.defineModifier("special")};for(let C in R){let t=R[C];t instanceof a&&(t.name=C)}l([{tag:R.link,class:"tok-link"},{tag:R.heading,class:"tok-heading"},{tag:R.emphasis,class:"tok-emphasis"},{tag:R.strong,class:"tok-strong"},{tag:R.keyword,class:"tok-keyword"},{tag:R.atom,class:"tok-atom"},{tag:R.bool,class:"tok-bool"},{tag:R.url,class:"tok-url"},{tag:R.labelName,class:"tok-labelName"},{tag:R.inserted,class:"tok-inserted"},{tag:R.deleted,class:"tok-deleted"},{tag:R.literal,class:"tok-literal"},{tag:R.string,class:"tok-string"},{tag:R.number,class:"tok-number"},{tag:[R.regexp,R.escape,R.special(R.string)],class:"tok-string2"},{tag:R.variableName,class:"tok-variableName"},{tag:R.local(R.variableName),class:"tok-variableName tok-local"},{tag:R.definition(R.variableName),class:"tok-variableName tok-definition"},{tag:R.special(R.variableName),class:"tok-variableName2"},{tag:R.definition(R.propertyName),class:"tok-propertyName tok-definition"},{tag:R.typeName,class:"tok-typeName"},{tag:R.namespace,class:"tok-namespace"},{tag:R.className,class:"tok-className"},{tag:R.macroName,class:"tok-macroName"},{tag:R.propertyName,class:"tok-propertyName"},{tag:R.operator,class:"tok-operator"},{tag:R.comment,class:"tok-comment"},{tag:R.meta,class:"tok-meta"},{tag:R.invalid,class:"tok-invalid"},{tag:R.punctuation,class:"tok-punctuation"}]);export{a as Tag,f as getStyleTags,c as highlightTree,o as styleTags,l as tagHighlighter,R as tags};