import{t as I}from"./themeResolver-BmJyTmjJ.js";import{b as R,z as A,i as y,y as S,C as _,B as T}from"./computeVirtualFileMetrics-DkRR5b75.js";import{fb as b}from"./useAppFontEffects-B53Rb6m7.js";function W(e){return I.hasResolvedThemes(e)}function w(e,t){return R(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}const d=10,g=13;function k(e){const t=[0];for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);(r===d||r===g)&&(r===g&&n+1<e.length&&e.charCodeAt(n+1)===d&&n++,t.push(n+1))}return t}function N(e){const t=k(e);return Array.from({length:t.length},(n,r)=>{const i=t[r],s=t[r+1]??e.length;return e.slice(i,s)})}const P={forcePlainText:!1};function D(e,t,{theme:n=b,tokenizeMaxLineLength:r,useTokenTransformer:i},{forcePlainText:s,startingLine:o,totalLines:a,lines:E}=P){s?(o??=0,a??=1/0):(o=0,a=1/0);const f=o>0||a<1/0,{state:F,transformers:l}=A(i),c=s?"text":e.lang??y(e.name),x=typeof n=="string"?t.getTheme(n).type:void 0,p=S({theme:n,highlighter:t});F.lineInfo=u=>({type:"context",lineIndex:u-1+o,lineNumber:u+o});const C=typeof n=="string"?{lang:c,theme:n,transformers:l,defaultColor:!1,cssVariablePrefix:T("token"),tokenizeMaxLineLength:r,tokenizeTimeLimit:0}:{lang:c,themes:n,transformers:l,defaultColor:!1,cssVariablePrefix:T("token"),tokenizeMaxLineLength:r,tokenizeTimeLimit:0},m=_(t.codeToHast(f?H(E??N(e.contents),o,a):e.contents,C)),h=f?new Array(o):m;return f&&h.push(...m),{code:h,themeStyles:p,baseThemeType:x}}function H(e,t,n){if(e.length===0)return"";const r=Math.min(t+n,e.length);return e.slice(t,r).join("")}function M(e){return(e.lang??y(e.name))==="text"}export{w as a,W as h,M as i,N as l,D as r};
