@kekonic/diagrams-studio 1.0.0-rc.10

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.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +47 -0
  3. package/dist/browser/assets/SourceEditor-CVJmi6AX.js +23 -0
  4. package/dist/browser/assets/codicon-DF1abBS2.ttf +0 -0
  5. package/dist/browser/assets/dist-gV3Je5I4.js +52 -0
  6. package/dist/browser/assets/editor-bEjdOiDy.css +1 -0
  7. package/dist/browser/assets/editor.api-Cj6q1WDf.js +430 -0
  8. package/dist/browser/assets/editor.worker-BmdWdrHZ.js +33 -0
  9. package/dist/browser/assets/elk-B5tw4IVJ.js +25 -0
  10. package/dist/browser/assets/format-B3CctFKU.js +479 -0
  11. package/dist/browser/assets/format-BCE_sElR.css +1 -0
  12. package/dist/browser/assets/github-dark-C-LZuMrd.js +1 -0
  13. package/dist/browser/assets/github-light-EUqPIrTm.js +1 -0
  14. package/dist/browser/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  15. package/dist/browser/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  16. package/dist/browser/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  17. package/dist/browser/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  18. package/dist/browser/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
  19. package/dist/browser/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
  20. package/dist/browser/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
  21. package/dist/browser/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
  22. package/dist/browser/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
  23. package/dist/browser/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
  24. package/dist/browser/assets/index-CWVmUaAY.css +1 -0
  25. package/dist/browser/assets/index-KMDzz6hs.js +3092 -0
  26. package/dist/browser/assets/inter-latin-500-normal-BL9OpVg8.woff +0 -0
  27. package/dist/browser/assets/inter-latin-500-normal-DPWUe_Rm.js +1 -0
  28. package/dist/browser/assets/kekonic-diagrams-symbol-DLqXST9D.svg +38 -0
  29. package/dist/browser/assets/language-jwV6PbsO.js +11 -0
  30. package/dist/browser/assets/monaco-features-BReLWANr.js +28 -0
  31. package/dist/browser/assets/monaco-features-CRQ1X1Hr.css +1 -0
  32. package/dist/browser/assets/rolldown-runtime-COiEfhsA.js +1 -0
  33. package/dist/browser/assets/wasm-BnjxR4X6.js +1 -0
  34. package/dist/browser/favicon.svg +38 -0
  35. package/dist/browser/index.html +17 -0
  36. package/dist/index.d.mts +185 -0
  37. package/dist/index.mjs +465 -0
  38. package/dist/index.mjs.map +1 -0
  39. package/package.json +71 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kekonic
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # @kekonic/diagrams-studio
2
+
3
+ Browser-safe synchronization primitives and the canonical KDiagram authoring interface. The
4
+ private development host launches this same Studio source tree; it is not a second application.
5
+
6
+ Studio provides the complete authoring experience: the split editor and live preview, diagnostics,
7
+ source-backed diagram settings, view controls, formatting, export, and responsive shell. Direction,
8
+ density, group layout, edge routing, and crossing changes made in the sidebar update the KDiagram
9
+ document itself so the DSL remains the source of truth. Clicking a rendered node reveals its source
10
+ declaration without interfering with drag-to-pan. Studio consumes the public KDiagram chrome token
11
+ contract, including sharp geometry, light/dark modes, typography, and focus treatment.
12
+
13
+ Most users should launch the supported authoring host through the CLI:
14
+
15
+ ```bash
16
+ kdiagrams studio architecture.kdiagram
17
+ ```
18
+
19
+ The same application is hosted at <https://diagrams.kekonic.com/studio/>. Standalone Studio can
20
+ open `.kdiagram` files through the browser, save changes back through the File System Access API
21
+ when supported, and fall back to ordinary uploads/downloads elsewhere. It keeps a recovery draft in
22
+ local browser storage. Source saves remain distinct from SVG export.
23
+
24
+ The Share dialog produces an editable hosted-Studio link, a diagram-only iframe, web-component code
25
+ for applications that install KDiagram, and copyable SVG markup. Shared links encode source in the
26
+ URL fragment, so the document is not sent to the static web host or included in HTTP referrers.
27
+
28
+ The package API is for integrations that need the same versioned document, render, selection,
29
+ viewport, presentation, export, and save protocol without depending on a particular editor or
30
+ transport.
31
+
32
+ ## Hosting the browser app
33
+
34
+ `dist/browser` is a relative-base production build, so it can be mounted at `/studio/`, nested
35
+ under a documentation site, or served from another subpath without rebuilding asset URLs. Studio
36
+ resolves its optional connection routes relative to that mount point. Without a CLI session token,
37
+ it opens in local example mode.
38
+
39
+ The default `<meta name="kdiagram-icon-api">` points to `./__kdiagram/icons`, the bounded endpoint
40
+ provided by the KDiagram CLI and development server. A different host can either implement the same
41
+ Iconify-compatible subset route or replace the meta value with its icon API base URL. If that URL is
42
+ cross-origin, the host must explicitly permit it in `connect-src`; Studio does not silently widen a
43
+ site's CSP.
44
+
45
+ The documentation host deliberately configures Iconify's public API because a static deployment
46
+ cannot resolve arbitrary user-selected collections on demand. CLI-launched Studio continues using
47
+ the bounded local endpoint and works without that external service.
@@ -0,0 +1,23 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-CWVmUaAY.css","./format-BCE_sElR.css","./monaco-features-CRQ1X1Hr.css","./editor-bEjdOiDy.css"])))=>i.map(i=>d[i]);
2
+ import{i as e,n as t}from"./rolldown-runtime-COiEfhsA.js";import{H as n,P as r,S as i,U as a,tt as o}from"./index-KMDzz6hs.js";var s=e(o(),1);function c(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function l(e){if(Array.isArray(e))return e}function u(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function d(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function f(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
3
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function m(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?p(Object(n),!0).forEach(function(t){u(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function h(e,t){if(e==null)return{};var n,r,i=g(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function g(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function _(e,t){return l(e)||d(e,t)||te(e,t)||f()}function ee(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function v(e){var t=ee(e,`string`);return typeof t==`symbol`?t:t+``}function te(e,t){if(e){if(typeof e==`string`)return c(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(e,t):void 0}}function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function x(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?b(Object(n),!0).forEach(function(t){y(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):b(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function S(){var e=[...arguments];return function(t){return e.reduceRight(function(e,t){return t(e)},t)}}function C(e){return function t(){var n=this,r=[...arguments];return r.length>=e.length?e.apply(this,r):function(){var e=[...arguments];return t.apply(n,[].concat(r,e))}}}function w(e){return{}.toString.call(e).includes(`Object`)}function T(e){return!Object.keys(e).length}function E(e){return typeof e==`function`}function ne(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function re(e,t){return w(t)||D(`changeType`),Object.keys(t).some(function(t){return!ne(e,t)})&&D(`changeField`),t}function ie(e){E(e)||D(`selectorType`)}function ae(e){E(e)||w(e)||D(`handlerType`),w(e)&&Object.values(e).some(function(e){return!E(e)})&&D(`handlersType`)}function oe(e){e||D(`initialIsRequired`),w(e)||D(`initialType`),T(e)&&D(`initialContent`)}function se(e,t){throw Error(e[t]||e.default)}var D=C(se)({initialIsRequired:`initial state is required`,initialType:`initial state should be an object`,initialContent:`initial state shouldn't be an empty object`,handlerType:`handler should be an object or a function`,handlersType:`all handlers should be a functions`,selectorType:`selector should be a function`,changeType:`provided value of changes should be an object`,changeField:`it seams you want to change a field in the state which is not specified in the "initial" state`,default:"an unknown error accured in `state-local` package"}),O={changes:re,selector:ie,handler:ae,initial:oe};function ce(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};O.initial(e),O.handler(t);var n={current:e},r=C(de)(n,t),i=C(ue)(n),a=C(O.changes)(e),o=C(le)(n);function s(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(e){return e};return O.selector(e),e(n.current)}function c(e){S(r,i,a,o)(e)}return[s,c]}function le(e,t){return E(t)?t(e.current):t}function ue(e,t){return e.current=x(x({},e.current),t),t}function de(e,t,n){return E(t)?t(e.current):Object.keys(n).forEach(function(n){return t[n]?.call(t,e.current[n])}),n}var fe={create:ce},pe={paths:{vs:`https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs`}};function me(e){return function t(){var n=this,r=[...arguments];return r.length>=e.length?e.apply(this,r):function(){var e=[...arguments];return t.apply(n,[].concat(r,e))}}}function he(e){return{}.toString.call(e).includes(`Object`)}function ge(e){return e||be(`configIsRequired`),he(e)||be(`configType`),e.urls?(_e(),{paths:{vs:e.urls.monacoBase}}):e}function _e(){console.warn(ye.deprecation)}function ve(e,t){throw Error(e[t]||e.default)}var ye={configIsRequired:`the configuration object is required`,configType:`the configuration object should be an object`,default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
4
+ You are using deprecated way of configuration.
5
+
6
+ Instead of using
7
+ monaco.config({ urls: { monacoBase: '...' } })
8
+ use
9
+ monaco.config({ paths: { vs: '...' } })
10
+
11
+ For more please check the link https://github.com/suren-atoyan/monaco-loader#config
12
+ `},be=me(ve)(ye),xe={config:ge},Se=function(){var e=[...arguments];return function(t){return e.reduceRight(function(e,t){return t(e)},t)}};function Ce(e,t){return Object.keys(t).forEach(function(n){t[n]instanceof Object&&e[n]&&Object.assign(t[n],Ce(e[n],t[n]))}),m(m({},e),t)}var we={type:`cancelation`,msg:`operation is manually canceled`};function Te(e){var t=!1,n=new Promise(function(n,r){e.then(function(e){return t?r(we):n(e)}),e.catch(r)});return n.cancel=function(){return t=!0},n}var Ee=[`monaco`],De=_(fe.create({config:pe,isInitialized:!1,resolve:null,reject:null,monaco:null}),2),k=De[0],Oe=De[1];function ke(e){var t=xe.config(e),n=t.monaco,r=h(t,Ee);Oe(function(e){return{config:Ce(e.config,r),monaco:n}})}function Ae(){var e=k(function(e){return{monaco:e.monaco,isInitialized:e.isInitialized,resolve:e.resolve}});if(!e.isInitialized){if(Oe({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Te(Le);if(window.monaco&&window.monaco.editor)return Fe(window.monaco),e.resolve(window.monaco),Te(Le);Se(je,Ne)(Pe)}return Te(Le)}function je(e){return document.body.appendChild(e)}function Me(e){var t=document.createElement(`script`);return e&&(t.src=e),t}function Ne(e){var t=k(function(e){return{config:e.config,reject:e.reject}}),n=Me(`${t.config.paths.vs}/loader.js`);return n.onload=function(){return e()},n.onerror=t.reject,n}function Pe(){var e=k(function(e){return{config:e.config,resolve:e.resolve,reject:e.reject}}),t=window.require;t.config(e.config),t([`vs/editor/editor.main`],function(t){var n=t.m||t;Fe(n),e.resolve(n)},function(t){e.reject(t)})}function Fe(e){k().monaco||Oe({monaco:e})}function Ie(){return k(function(e){return e.monaco})}var Le=new Promise(function(e,t){return Oe({resolve:e,reject:t})}),Re={config:ke,init:Ae,__getMonacoInstance:Ie},ze={wrapper:{display:`flex`,position:`relative`,textAlign:`initial`},fullWidth:{width:`100%`},hide:{display:`none`}},Be={container:{display:`flex`,height:`100%`,width:`100%`,justifyContent:`center`,alignItems:`center`}};function Ve({children:e}){return s.createElement(`div`,{style:Be.container},e)}var He=Ve;function Ue({width:e,height:t,isEditorReady:n,loading:r,_ref:i,className:a,wrapperProps:o}){return s.createElement(`section`,{style:{...ze.wrapper,width:e,height:t},...o},!n&&s.createElement(He,null,r),s.createElement(`div`,{ref:i,style:{...ze.fullWidth,...!n&&ze.hide},className:a}))}var We=(0,s.memo)(Ue);function Ge(e){(0,s.useEffect)(e,[])}var Ke=Ge;function qe(e,t,n=!0){let r=(0,s.useRef)(!0);(0,s.useEffect)(r.current||!n?()=>{r.current=!1}:e,t)}var A=qe;function j(){}function M(e,t,n,r){return Je(e,r)||Ye(e,t,n,r)}function Je(e,t){return e.editor.getModel(Xe(e,t))}function Ye(e,t,n,r){return e.editor.createModel(t,n,r?Xe(e,r):void 0)}function Xe(e,t){return e.Uri.parse(t)}function Ze({original:e,modified:t,language:n,originalLanguage:r,modifiedLanguage:i,originalModelPath:a,modifiedModelPath:o,keepCurrentOriginalModel:c=!1,keepCurrentModifiedModel:l=!1,theme:u=`light`,loading:d=`Loading...`,options:f={},height:p=`100%`,width:m=`100%`,className:h,wrapperProps:g={},beforeMount:_=j,onMount:ee=j}){let[v,te]=(0,s.useState)(!1),[y,b]=(0,s.useState)(!0),x=(0,s.useRef)(null),S=(0,s.useRef)(null),C=(0,s.useRef)(null),w=(0,s.useRef)(ee),T=(0,s.useRef)(_),E=(0,s.useRef)(!1);Ke(()=>{let e=Re.init();return e.then(e=>(S.current=e)&&b(!1)).catch(e=>e?.type!==`cancelation`&&console.error(`Monaco initialization: error:`,e)),()=>x.current?ie():e.cancel()}),A(()=>{if(x.current&&S.current){let t=x.current.getOriginalEditor(),i=M(S.current,e||``,r||n||`text`,a||``);i!==t.getModel()&&t.setModel(i)}},[a],v),A(()=>{if(x.current&&S.current){let e=x.current.getModifiedEditor(),r=M(S.current,t||``,i||n||`text`,o||``);r!==e.getModel()&&e.setModel(r)}},[o],v),A(()=>{let e=x.current.getModifiedEditor();e.getOption(S.current.editor.EditorOption.readOnly)?e.setValue(t||``):t!==e.getValue()&&(e.executeEdits(``,[{range:e.getModel().getFullModelRange(),text:t||``,forceMoveMarkers:!0}]),e.pushUndoStop())},[t],v),A(()=>{x.current?.getModel()?.original.setValue(e||``)},[e],v),A(()=>{let{original:e,modified:t}=x.current.getModel();S.current.editor.setModelLanguage(e,r||n||`text`),S.current.editor.setModelLanguage(t,i||n||`text`)},[n,r,i],v),A(()=>{S.current?.editor.setTheme(u)},[u],v),A(()=>{x.current?.updateOptions(f)},[f],v);let ne=(0,s.useCallback)(()=>{if(!S.current)return;T.current(S.current);let s=M(S.current,e||``,r||n||`text`,a||``),c=M(S.current,t||``,i||n||`text`,o||``);x.current?.setModel({original:s,modified:c})},[n,t,i,e,r,a,o]),re=(0,s.useCallback)(()=>{!E.current&&C.current&&(x.current=S.current.editor.createDiffEditor(C.current,{automaticLayout:!0,...f}),ne(),S.current?.editor.setTheme(u),te(!0),E.current=!0)},[f,u,ne]);(0,s.useEffect)(()=>{v&&w.current(x.current,S.current)},[v]),(0,s.useEffect)(()=>{!y&&!v&&re()},[y,v,re]);function ie(){let e=x.current?.getModel();c||e?.original?.dispose(),l||e?.modified?.dispose(),x.current?.dispose()}return s.createElement(We,{width:m,height:p,isEditorReady:v,loading:d,_ref:C,className:h,wrapperProps:g})}(0,s.memo)(Ze);function Qe(e){let t=(0,s.useRef)();return(0,s.useEffect)(()=>{t.current=e},[e]),t.current}var $e=Qe,et=new Map;function tt({defaultValue:e,defaultLanguage:t,defaultPath:n,value:r,language:i,path:a,theme:o=`light`,line:c,loading:l=`Loading...`,options:u={},overrideServices:d={},saveViewState:f=!0,keepCurrentModel:p=!1,width:m=`100%`,height:h=`100%`,className:g,wrapperProps:_={},beforeMount:ee=j,onMount:v=j,onChange:te,onValidate:y=j}){let[b,x]=(0,s.useState)(!1),[S,C]=(0,s.useState)(!0),w=(0,s.useRef)(null),T=(0,s.useRef)(null),E=(0,s.useRef)(null),ne=(0,s.useRef)(v),re=(0,s.useRef)(ee),ie=(0,s.useRef)(),ae=(0,s.useRef)(r),oe=$e(a),se=(0,s.useRef)(!1),D=(0,s.useRef)(!1);Ke(()=>{let e=Re.init();return e.then(e=>(w.current=e)&&C(!1)).catch(e=>e?.type!==`cancelation`&&console.error(`Monaco initialization: error:`,e)),()=>T.current?ce():e.cancel()}),A(()=>{let o=M(w.current,e||r||``,t||i||``,a||n||``);o!==T.current?.getModel()&&(f&&et.set(oe,T.current?.saveViewState()),T.current?.setModel(o),f&&T.current?.restoreViewState(et.get(a)))},[a],b),A(()=>{T.current?.updateOptions(u)},[u],b),A(()=>{!T.current||r===void 0||(T.current.getOption(w.current.editor.EditorOption.readOnly)?T.current.setValue(r):r!==T.current.getValue()&&(D.current=!0,T.current.executeEdits(``,[{range:T.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),T.current.pushUndoStop(),D.current=!1))},[r],b),A(()=>{let e=T.current?.getModel();e&&i&&w.current?.editor.setModelLanguage(e,i)},[i],b),A(()=>{c!==void 0&&T.current?.revealLine(c)},[c],b),A(()=>{w.current?.editor.setTheme(o)},[o],b);let O=(0,s.useCallback)(()=>{if(E.current&&w.current&&!se.current){re.current(w.current);let s=a||n,l=M(w.current,r||e||``,t||i||``,s||``);T.current=w.current?.editor.create(E.current,{model:l,automaticLayout:!0,...u},d),f&&T.current.restoreViewState(et.get(s)),w.current.editor.setTheme(o),c!==void 0&&T.current.revealLine(c),x(!0),se.current=!0}},[e,t,n,r,i,a,u,d,f,o,c]);(0,s.useEffect)(()=>{b&&ne.current(T.current,w.current)},[b]),(0,s.useEffect)(()=>{!S&&!b&&O()},[S,b,O]),ae.current=r,(0,s.useEffect)(()=>{b&&te&&(ie.current?.dispose(),ie.current=T.current?.onDidChangeModelContent(e=>{D.current||te(T.current.getValue(),e)}))},[b,te]),(0,s.useEffect)(()=>{if(b){let e=w.current.editor.onDidChangeMarkers(e=>{let t=T.current.getModel()?.uri;if(t&&e.find(e=>e.path===t.path)){let e=w.current.editor.getModelMarkers({resource:t});y?.(e)}});return()=>{e?.dispose()}}return()=>{}},[b,y]);function ce(){ie.current?.dispose(),p?f&&et.set(a,T.current.saveViewState()):T.current.getModel()?.dispose(),T.current.dispose()}return s.createElement(We,{width:m,height:h,isEditorReady:b,loading:l,_ref:E,className:g,wrapperProps:_})}var nt=(0,s.memo)(tt);function rt(e){return it(e)}function it(e){return Array.isArray(e)?at(e):e instanceof RegExp?e:typeof e==`object`?ot(e):e}function at(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=it(e[n]);return t}function ot(e){let t={};for(let n in e)t[n]=it(e[n]);return t}function st(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function ct(e){let t=~e.lastIndexOf(`/`)||~e.lastIndexOf(`\\`);return t===0?e:~t===e.length-1?ct(e.substring(0,e.length-1)):e.substr(~t+1)}var lt=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,ut=class{static hasCaptures(e){return e!==null&&(lt.lastIndex=0,lt.test(e))}static replaceCaptures(e,t,n){return e.replace(lt,(e,r,i,a)=>{let o=n[parseInt(r||i,10)];if(o){let e=t.substring(o.start,o.end);for(;e[0]===`.`;)e=e.substring(1);switch(a){case`downcase`:return e.toLowerCase();case`upcase`:return e.toUpperCase();default:return e}}else return e})}};function dt(e,t){return e<t?-1:+(e>t)}function ft(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=dt(e[r],t[r]);if(n!==0)return n}return 0}return n-r}function pt(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function mt(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,`\\$&`)}var ht=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},gt=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(xt(e),t)}static createFromParsedTheme(e,t){return Ct(e,t)}_cachedMatchRoot=new ht(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>vt(e.parent,t.parentScopes));return n?new bt(n.fontStyle,n.foreground,n.background):null}},_t=class e{constructor(e,t){this.parent=e,this.scopeName=t}static push(t,n){for(let r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(` `)}extends(e){return this===e||this.parent!==null&&this.parent.extends(e)}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function vt(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===`>`){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!yt(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function yt(e,t){return t===e||e.startsWith(t)&&e[t.length]===`.`}var bt=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function xt(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,i=t.length;e<i;e++){let i=t[e];if(!i.settings)continue;let a;if(typeof i.scope==`string`){let e=i.scope;e=e.replace(/^[,]+/,``),e=e.replace(/[,]+$/,``),a=e.split(`,`)}else a=Array.isArray(i.scope)?i.scope:[``];let o=-1;if(typeof i.settings.fontStyle==`string`){o=0;let e=i.settings.fontStyle.split(` `);for(let t=0,n=e.length;t<n;t++)switch(e[t]){case`italic`:o|=1;break;case`bold`:o|=2;break;case`underline`:o|=4;break;case`strikethrough`:o|=8}}let s=null;typeof i.settings.foreground==`string`&&pt(i.settings.foreground)&&(s=i.settings.foreground);let c=null;typeof i.settings.background==`string`&&pt(i.settings.background)&&(c=i.settings.background);for(let t=0,i=a.length;t<i;t++){let i=a[t].trim().split(` `),l=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new St(l,u,e,o,s,c)}}return n}var St=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}},N=(e=>(e[e.NotSet=-1]=`NotSet`,e[e.None=0]=`None`,e[e.Italic=1]=`Italic`,e[e.Bold=2]=`Bold`,e[e.Underline=4]=`Underline`,e[e.Strikethrough=8]=`Strikethrough`,e))(N||{});function Ct(e,t){e.sort((e,t)=>{let n=dt(e.scope,t.scope);return n!==0||(n=ft(e.parentScopes,t.parentScopes),n!==0)?n:e.index-t.index});let n=0,r=`#000000`,i=`#ffffff`;for(;e.length>=1&&e[0].scope===``;){let t=e.shift();t.fontStyle!==-1&&(n=t.fontStyle),t.foreground!==null&&(r=t.foreground),t.background!==null&&(i=t.background)}let a=new wt(t),o=new bt(n,a.getId(r),a.getId(i)),s=new Dt(new Et(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];s.insert(0,n.scope,n.parentScopes,n.fontStyle,a.getId(n.foreground),a.getId(n.background))}return new gt(a,o,s)}var wt=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},Tt=Object.freeze([]),Et=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,i){this.scopeDepth=e,this.parentScopes=t||Tt,this.fontStyle=n,this.foreground=r,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log(`how did this happen?`):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),n!==0&&(this.foreground=n),r!==0&&(this.background=r)}},Dt=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;e.parentScopes[n]===`>`&&n++,t.parentScopes[r]===`>`&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){let i=t.parentScopes[r].length-e.parentScopes[n].length;if(i!==0)return i;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(t!==``){let e=t.indexOf(`.`),n,r;if(e===-1?(n=t,r=``):(n=t.substring(0,e),r=t.substring(e+1)),this._children.hasOwnProperty(n))return this._children[n].match(r)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,i,a,o){if(n===``){this._doInsertHere(t,r,i,a,o);return}let s=n.indexOf(`.`),c,l;s===-1?(c=n,l=``):(c=n.substring(0,s),l=n.substring(s+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new e(this._mainRule.clone(),Et.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,i,a,o)}_doInsertHere(e,t,n,r,i){if(t===null)this._mainRule.acceptOverwrite(e,n,r,i);else{for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let o=this._rulesWithParentScopes[a];if(ft(o.parentScopes,t)===0){o.acceptOverwrite(e,n,r,i);return}}n===-1&&(n=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new Et(e,t,n,r,i))}}},P=class e{static toBinaryStr(e){return e.toString(2).padStart(32,`0`)}static print(t){let n=e.getLanguageId(t),r=e.getTokenType(t),i=e.getFontStyle(t),a=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return!!(e&1024)}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(t,n,r,i,a,o,s){let c=e.getLanguageId(t),l=e.getTokenType(t),u=+!!e.containsBalancedBrackets(t),d=e.getFontStyle(t),f=e.getForeground(t),p=e.getBackground(t);return n!==0&&(c=n),r!==8&&(l=kt(r)),i!==null&&(u=+!!i),a!==-1&&(d=a),o!==0&&(f=o),s!==0&&(p=s),(c|0|l<<8|u<<10|d<<11|f<<15|p<<24)>>>0}};function Ot(e){return e}function kt(e){return e}function At(e,t){let n=[],r=Mt(e),i=r.next();for(;i!==null;){let e=0;if(i.length===2&&i.charAt(1)===`:`){switch(i.charAt(0)){case`R`:e=1;break;case`L`:e=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let t=o();if(n.push({matcher:t,priority:e}),i!==`,`)break;i=r.next()}return n;function a(){if(i===`-`){i=r.next();let e=a();return t=>!!e&&!e(t)}if(i===`(`){i=r.next();let e=s();return i===`)`&&(i=r.next()),e}if(jt(i)){let e=[];do e.push(i),i=r.next();while(jt(i));return n=>t(e,n)}return null}function o(){let e=[],t=a();for(;t;)e.push(t),t=a();return t=>e.every(e=>e(t))}function s(){let e=[],t=o();for(;t&&(e.push(t),i===`|`||i===`,`);){do i=r.next();while(i===`|`||i===`,`);t=o()}return t=>e.some(e=>e(t))}}function jt(e){return!!e&&!!e.match(/[\w\.:]+/)}function Mt(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function Nt(e){typeof e.dispose==`function`&&e.dispose()}var Pt=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},Ft=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},It=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Lt=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Pt(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new It;for(let n of e)Rt(n,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof Pt){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function Rt(e,t,n,r){let i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=n.lookup(t);e instanceof Pt?Bt({baseGrammar:a,selfGrammar:i},r):zt(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);let o=n.injections(e.scopeName);if(o)for(let e of o)r.add(new Pt(e))}function zt(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];Vt([r],t,n)}}function Bt(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Vt(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Vt(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Vt(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let e=r.repository?st({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&Vt(r.patterns,{...t,repository:e},n);let i=r.include;if(!i)continue;let a=qt(i);switch(a.kind){case 0:Bt({...t,selfGrammar:t.baseGrammar},n);break;case 1:Bt(t,n);break;case 2:zt(a.ruleName,{...t,repository:e},n);break;case 3:case 4:let r=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){let i={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};a.kind===4?zt(a.ruleName,i,n):Bt(i,n)}else a.kind===4?n.add(new Ft(a.scopeName,a.ruleName)):n.add(new Pt(a.scopeName))}}}var Ht=class{kind=0},Ut=class{kind=1},Wt=class{constructor(e){this.ruleName=e}kind=2},Gt=class{constructor(e){this.scopeName=e}kind=3},Kt=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function qt(e){if(e===`$base`)return new Ht;if(e===`$self`)return new Ut;let t=e.indexOf(`#`);return t===-1?new Gt(e):t===0?new Wt(e.substring(1)):new Kt(e.substring(0,t),e.substring(t+1))}var Jt=/\\(\d+)/,Yt=/\\(\d+)/g,Xt=-1,Zt=-2;function Qt(e){return e}function $t(e){return e}var en=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=ut.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=ut.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${ct(this.$location.filename)}:${this.$location.line}`:`unknown`;return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:ut.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:ut.replaceCaptures(this._contentName,e,t)}},tn=class extends en{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error(`Not supported!`)}compile(e,t){throw Error(`Not supported!`)}compileAG(e,t,n,r){throw Error(`Not supported!`)}},nn=class extends en{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new cn(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new ln,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},rn=class extends en{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new ln,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},an=class extends en{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r),this._begin=new cn(i,this.id),this.beginCaptures=a,this._end=new cn(o||`￿`,-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new ln;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},on=class extends en{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r),this._begin=new cn(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new cn(o,Zt),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null),this._cachedCompiledWhilePatterns&&=(this._cachedCompiledWhilePatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new ln;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new ln,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||`￿`),this._cachedCompiledWhilePatterns}},sn=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new tn(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new nn(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(t.begin===void 0){t.repository&&(r=st({},r,t.repository));let i=t.patterns;return i===void 0&&t.include&&(i=[{include:t.include}]),new rn(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new on(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new an(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(let e in t){if(e===`$vscodeTextmateLocation`)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if(a===`$vscodeTextmateLocation`)continue;let o=parseInt(a,10),s=0;t[a].patterns&&(s=e.getCompiledRuleId(t[a],n,r)),i[o]=e.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,s)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,o=t.length;a<o;a++){let o=t[a],s=-1;if(o.include){let t=qt(o.include);switch(t.kind){case 0:case 1:s=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let i=r[t.ruleName];i&&(s=e.getCompiledRuleId(i,n,r));break;case 3:case 4:let a=t.scopeName,c=t.kind===4?t.ruleName:null,l=n.getExternalGrammar(a,r);if(l){if(c){let t=l.repository[c];t&&(s=e.getCompiledRuleId(t,n,l.repository))}else s=e.getCompiledRuleId(l.repository.$self,n,l.repository)}}}else s=e.getCompiledRuleId(o,n,r);if(s!==-1){let e=n.getRule(s),t=!1;if((e instanceof rn||e instanceof an||e instanceof on)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},cn=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e==`string`){let t=e.length,n=0,r=[],i=!1;for(let a=0;a<t;a++)if(e.charAt(a)===`\\`&&a+1<t){let t=e.charAt(a+1);t===`z`?(r.push(e.substring(n,a)),r.push(`$(?!\\n)(?<!\\n)`),n=a+2):(t===`A`||t===`G`)&&(i=!0),a++}this.hasAnchor=i,n===0?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(``))}else this.hasAnchor=!1,this.source=e;this._anchorCache=this.hasAnchor?this._buildAnchorCache():null,this.ruleId=t,this.hasBackReferences=typeof this.source==`string`&&Jt.test(this.source)}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let n=t.map(t=>e.substring(t.start,t.end));return Yt.lastIndex=0,this.source.replace(Yt,(e,t)=>mt(n[parseInt(t,10)]||``))}_buildAnchorCache(){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let e=[],t=[],n=[],r=[],i,a,o,s;for(i=0,a=this.source.length;i<a;i++)o=this.source.charAt(i),e[i]=o,t[i]=o,n[i]=o,r[i]=o,o===`\\`&&i+1<a&&(s=this.source.charAt(i+1),s===`A`?(e[i+1]=`￿`,t[i+1]=`￿`,n[i+1]=`A`,r[i+1]=`A`):s===`G`?(e[i+1]=`￿`,t[i+1]=`G`,n[i+1]=`￿`,r[i+1]=`G`):(e[i+1]=s,t[i+1]=s,n[i+1]=s,r[i+1]=s),i++);return{A0_G0:e.join(``),A0_G1:t.join(``),A1_G0:n.join(``),A1_G1:r.join(``)}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!=`string`?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},ln=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&=(this._cached.dispose(),null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new un(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){return new un(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},un=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose==`function`&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(` - `+this.rules[t]+`: `+this.regExps[t]);return e.join(`
13
+ `)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},dn=class{constructor(e,t){this.languageId=e,this.tokenType=t}},fn=class e{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new dn(e,8),this._embeddedLanguagesMatcher=new pn(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?e._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new dn(0,0);_getBasicScopeAttributes=new ht(e=>new dn(this._scopeToLanguage(e),this._toStandardTokenType(e)));_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(t){let n=t.match(e.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case`comment`:return 1;case`string`:return 2;case`regex`:return 3;case`meta.embedded`:return 0}throw Error(`Unexpected match for standard token type!`)}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},pn=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([e,t])=>mt(e));t.sort(),t.reverse(),this.scopesRegExp=RegExp(`^((${t.join(`)|(`)}))($|\\.)`,``)}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}};typeof process<`u`&&{}.VSCODE_TEXTMATE_DEBUG;var mn=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function hn(e,t,n,r,i,a,o,s){let c=t.content.length,l=!1,u=-1;if(o){let o=gn(e,t,n,r,i,a);i=o.stack,r=o.linePos,n=o.isFirstLine,u=o.anchorPosition}let d=Date.now();for(;!l;){if(s!==0&&Date.now()-d>s)return new mn(i,!0);f()}return new mn(i,!1);function f(){let o=_n(e,t,n,r,i,u);if(!o){a.produce(i,c),l=!0;return}let s=o.captureIndices,d=o.matchedRuleId,f=s&&s.length>0?s[0].end>r:!1;if(d===Xt){let o=i.getRule(e);a.produce(i,s[0].start),i=i.withContentNameScopesList(i.nameScopesList),Sn(e,t,n,i,a,o.endCaptures,s),a.produce(i,s[0].end);let d=i;if(i=i.parent,u=d.getAnchorPos(),!f&&d.getEnterPos()===r){i=d,a.produce(i,c),l=!0;return}}else{let o=e.getRule(d);a.produce(i,s[0].start);let p=i,m=o.getName(t.content,s),h=i.contentNameScopesList.pushAttributed(m,e);if(i=i.push(d,r,u,s[0].end===c,null,h,h),o instanceof an){let r=o;Sn(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.endHasBackReferences&&(i=i.withEndRule(r.getEndWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(o instanceof on){let r=o;Sn(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.whileHasBackReferences&&(i=i.withEndRule(r.getWhileWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(Sn(e,t,n,i,a,o.captures,s),a.produce(i,s[0].end),i=i.pop(),!f){i=i.safePop(),a.produce(i,c),l=!0;return}}s[0].end>r&&(r=s[0].end,n=!1)}}function gn(e,t,n,r,i,a){let o=i.beginRuleCapturedEOL?0:-1,s=[];for(let t=i;t;t=t.pop()){let n=t.getRule(e);n instanceof on&&s.push({rule:n,stack:t})}for(let c=s.pop();c;c=s.pop()){let{ruleScanner:s,findOptions:l}=xn(c.rule,e,c.stack.endRule,n,r===o),u=s.findNextMatchSync(t,r,l);if(u){if(u.ruleId!==Zt){i=c.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(a.produce(c.stack,u.captureIndices[0].start),Sn(e,t,n,c.stack,a,c.rule.whileCaptures,u.captureIndices),a.produce(c.stack,u.captureIndices[0].end),o=u.captureIndices[0].end,u.captureIndices[0].end>r&&(r=u.captureIndices[0].end,n=!1))}else{i=c.stack.pop();break}}return{stack:i,linePos:r,anchorPosition:o,isFirstLine:n}}function _n(e,t,n,r,i,a){let o=vn(e,t,n,r,i,a),s=e.getInjections();if(s.length===0)return o;let c=yn(s,e,t,n,r,i,a);if(!c)return o;if(!o)return c;let l=o.captureIndices[0].start,u=c.captureIndices[0].start;return u<l||c.priorityMatch&&u===l?c:o}function vn(e,t,n,r,i,a){let{ruleScanner:o,findOptions:s}=bn(i.getRule(e),e,i.endRule,n,r===a),c=o.findNextMatchSync(t,r,s);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function yn(e,t,n,r,i,a,o){let s=Number.MAX_VALUE,c=null,l,u=0,d=a.contentNameScopesList.getScopeNames();for(let a=0,f=e.length;a<f;a++){let f=e[a];if(!f.matcher(d))continue;let{ruleScanner:p,findOptions:m}=bn(t.getRule(f.ruleId),t,null,r,i===o),h=p.findNextMatchSync(n,i,m);if(!h)continue;let g=h.captureIndices[0].start;if(!(g>=s)&&(s=g,c=h.captureIndices,l=h.ruleId,u=f.priority,s===i))break}return c?{priorityMatch:u===-1,captureIndices:c,matchedRuleId:l}:null}function bn(e,t,n,r,i){return{ruleScanner:e.compileAG(t,n,r,i),findOptions:0}}function xn(e,t,n,r,i){return{ruleScanner:e.compileWhileAG(t,n,r,i),findOptions:0}}function Sn(e,t,n,r,i,a,o){if(a.length===0)return;let s=t.content,c=Math.min(a.length,o.length),l=[],u=o[0].end;for(let t=0;t<c;t++){let c=a[t];if(c===null)continue;let d=o[t];if(d.length===0)continue;if(d.start>u)break;for(;l.length>0&&l[l.length-1].endPos<=d.start;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?i.produceFromScopes(l[l.length-1].scopes,d.start):i.produce(r,d.start),c.retokenizeCapturedWithRuleId){let t=c.getName(s,o),a=r.contentNameScopesList.pushAttributed(t,e),l=c.getContentName(s,o),u=a.pushAttributed(l,e),f=r.push(c.retokenizeCapturedWithRuleId,d.start,-1,!1,null,a,u),p=e.createOnigString(s.substring(0,d.end));hn(e,p,n&&d.start===0,d.start,f,i,!1,0),Nt(p);continue}let f=c.getName(s,o);if(f!==null){let t=(l.length>0?l[l.length-1].scopes:r.contentNameScopesList).pushAttributed(f,e);l.push(new Cn(t,d.end))}}for(;l.length>0;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var Cn=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function wn(e,t,n,r,i,a,o,s){return new On(e,t,n,r,i,a,o,s)}function Tn(e,t,n,r,i){let a=At(t,En),o=sn.getCompiledRuleId(n,r,i.repository);for(let n of a)e.push({debugSelector:t,matcher:n.matcher,ruleId:o,grammar:i,priority:n.priority})}function En(e,t){if(t.length<e.length)return!1;let n=0;return e.every(e=>{for(let r=n;r<t.length;r++)if(Dn(t[r],e))return n=r+1,!0;return!1})}function Dn(e,t){if(!e)return!1;if(e===t)return!0;let n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]===`.`}var On=class{constructor(e,t,n,r,i,a,o,s){if(this._rootScopeName=e,this.balancedBracketSelectors=a,this._onigLib=s,this._basicScopeAttributesProvider=new fn(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=kn(t,null),this._injections=null,this._tokenTypeMatchers=[],i)for(let e of Object.keys(i)){let t=At(e,En);for(let n of t)this._tokenTypeMatchers.push({matcher:n.matcher,type:i[e]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:e=>e===this._rootScopeName?this._grammar:this.getExternalGrammar(e),injections:e=>this._grammarRepository.injections(e)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){let e=r.injections;if(e)for(let n in e)Tn(t,n,e[n],this,r);let i=this._grammarRepository.injections(n);i&&i.forEach(e=>{let n=this.getExternalGrammar(e);if(n){let e=n.injectionSelector;e&&Tn(t,e,n,this,n)}})}return t.sort((e,t)=>e.priority-t.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,n=e(Qt(t));return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[$t(e)]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=kn(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){let r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){let r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=sn.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!t||t===jn.NULL){i=!0;let e=this._basicScopeAttributesProvider.getDefaultAttributes(),n=this.themeProvider.getDefaults(),r=P.set(0,e.languageId,e.tokenType,null,n.fontStyle,n.foregroundId,n.backgroundId),a=this.getRule(this._rootId).getName(null,null),o;o=a?An.createRootAndLookUpScopeName(a,r,this):An.createRoot(`unknown`,r),t=new jn(null,this._rootId,-1,-1,!1,null,o,o)}else i=!1,t.reset();e+=`
14
+ `;let a=this.createOnigString(e),o=a.content.length,s=new Nn(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=hn(this,a,i,0,t,s,!0,r);return Nt(a),{lineLength:o,lineTokens:s,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function kn(e,t){return e=rt(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var An=class e{constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}static fromExtension(t,n){let r=t,i=t?.scopePath??null;for(let t of n)i=_t.push(i,t.scopeNames),r=new e(r,i,t.encodedTokenAttributes);return r}static createRoot(t,n){return new e(null,new _t(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let i=r.getMetadataForScope(t),a=new _t(null,t),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(n,i,o);return new e(null,a,s)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(` `)}equals(t){return e.equals(this,t)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(1)}static mergeAttributes(e,t,n){let r=-1,i=0,a=0;return n!==null&&(r=n.fontStyle,i=n.foregroundId,a=n.backgroundId),P.set(e,t.languageId,t.tokenType,null,r,i,a)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(` `)===-1)return e._pushAttributed(this,t,n);let r=t.split(/ /g),i=this;for(let t of r)i=e._pushAttributed(i,t,n);return i}static _pushAttributed(t,n,r){let i=r.getMetadataForScope(n),a=t.scopePath.push(n),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(t.tokenAttributes,i,o);return new e(t,a,s)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}},jn=class e{constructor(e,t,n,r,i,a,o,s){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=i,this.endRule=a,this.nameScopesList=o,this.contentNameScopesList=s,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t!==null&&e._equals(this,t)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?An.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(1)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,i,a,o,s){return new e(this,t,n,r,i,a,o,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){let e=[];return this._writeString(e,0),`[`+e.join(`,`)+`]`}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:$t(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=An.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,Qt(n.ruleId),n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,An.fromExtension(r,n.contentNameScopesList))}},Mn=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>e===`*`?(this.allowAny=!0,[]):At(e,En).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>At(e,En).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},Nn=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let t=e?.getScopeNames()??[];for(let e of this._tokenTypeOverrides)e.matcher(t)&&(n=P.set(n,0,Ot(e.type),null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(t))}if(r&&(n=P.set(n,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)n[e]=this._binaryTokens[e];return n}},Pn=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,i){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,wn(e,a,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},Fn=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new Pn(gt.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(gt.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new Mn(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,i){let a=new Lt(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(e=>this._loadSingleGrammar(e.scopeName)),a.processQueue();return this._grammarForScopeName(e,t,n,r,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections==`function`?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,i=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,i)}},In=jn.NULL,Ln=class e{_ruleStack;constructor(e){this._ruleStack=e}get ruleStack(){return this._ruleStack}clone(){return new e(this._ruleStack)}equals(t){return!(!t||!(t instanceof e)||t!==this||t._ruleStack!==this._ruleStack)}};function Rn(e){if(Array.isArray(e)&&(e=e[0]),e)return e=(e.charCodeAt(0)===35?e.slice(1):e).toLowerCase(),(e.length===3||e.length===4)&&(e=e.split(``).map(e=>e+e).join(``)),e}var zn=/[\s,]+/;function Bn(e){let t=`rules`in e?e.rules:void 0;if(!t){t=[];let n=e.settings||e.tokenColors;for(let{scope:e,settings:{foreground:r,background:i,fontStyle:a}={}}of n){if(!r&&!i&&!a)continue;let n=Array.isArray(e)?e:e?[e]:[],o=Gn(a),s=Rn(r),c=Rn(i);t.push(...n.map(e=>({token:e,foreground:s,background:c,fontStyle:o})))}}let n=Object.fromEntries(Object.entries(e.colors||{}).map(([e,t])=>[e,`#${Rn(t)}`]));return{base:e.type===`light`?`vs`:`vs-dark`,inherit:!1,colors:n,rules:t}}function Vn(e,t,n={}){let r=new Map,i=e.getLoadedThemes();for(let n of i){let i=Bn(e.getTheme(n));r.set(n,i),t.editor.defineTheme(n,i)}let a=[],o=new Map,s=t.editor.setTheme.bind(t.editor);t.editor.setTheme=t=>{let n=e.setTheme(t),i=r.get(t);a.length=n.colorMap.length;for(let e=0;e<n.colorMap.length;e++)a[e]=n.colorMap[e];o.clear(),i?.rules.forEach(e=>{let t=Rn(e.foreground);if(!t)return;let n=Kn(t,Gn(e.fontStyle));o.has(n)||o.set(n,e.token)}),s(t)};let c=t.editor.create;t.editor.create=(e,n,r)=>(n?.theme&&t.editor.setTheme(n.theme),c(e,n,r)),t.editor.setTheme(i[0]);function l(e,t){let n=Kn(e,Hn(t));return o.get(n)}let{tokenizeMaxLineLength:u=2e4,tokenizeTimeLimit:d=500}=n,f=new Set(t.languages.getLanguages().map(e=>e.id));for(let n of e.getLoadedLanguages())f.has(n)&&t.languages.setTokensProvider(n,{getInitialState(){return new Ln(In)},tokenize(t,r){if(t.length>=u)return{endState:r,tokens:[{startIndex:0,scopes:``}]};let i=e.getLanguage(n).tokenizeLine2(t,r.ruleStack,d);i.stoppedEarly&&console.warn(`Time limit reached when tokenizing line: ${t.substring(0,100)}`);let o=i.tokens.length/2,s=[];for(let e=0;e<o;e++){let t=i.tokens[2*e],n=i.tokens[2*e+1],r=P.getForeground(n),o=Rn(a[r]||``),c=P.getFontStyle(n),u=o&&l(o,c)||``;s.push({startIndex:t,scopes:u})}return{endState:new Ln(i.ruleStack),tokens:s}}})}function Hn(e){if(e<=N.None)return``;let t=[];return e&N.Italic&&t.push(`italic`),e&N.Bold&&t.push(`bold`),e&N.Underline&&t.push(`underline`),e&N.Strikethrough&&t.push(`strikethrough`),t.join(` `)}var Un=[`italic`,`bold`,`underline`,`strikethrough`],Wn={"line-through":`strikethrough`};function Gn(e){if(!e)return``;let t=new Set(e.split(zn).map(e=>e.trim().toLowerCase()).map(e=>Wn[e]||e).filter(Boolean));return Un.filter(e=>t.has(e)).join(` `)}function Kn(e,t){return t?`${e}|${t}`:e}var F=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function qn(e,t){let n=typeof e==`string`?{}:{...e.colorReplacements},r=typeof e==`string`?e:e.name;for(let[e,i]of Object.entries(t?.colorReplacements||{}))typeof i==`string`?n[e]=i:e===r&&Object.assign(n,i);return n}function I(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function Jn(e){return Array.isArray(e)?e:[e]}async function Yn(e){return Promise.resolve(typeof e==`function`?e():e).then(e=>e.default||e)}function Xn(e){return!e||[`plaintext`,`txt`,`text`,`plain`].includes(e)}function Zn(e){return e===`ansi`||Xn(e)}function Qn(e){return e===`none`}function $n(e){return Qn(e)}var er=/(\r?\n)/g;function tr(e,t=!1){if(e.length===0)return[[``,0]];let n=e.split(er),r=0,i=[];for(let e=0;e<n.length;e+=2){let a=t?n[e]+(n[e+1]||``):n[e];i.push([a,r]),r+=n[e].length,r+=n[e+1]?.length||0}return i}var nr={light:`#333333`,dark:`#bbbbbb`},rr={light:`#fffffe`,dark:`#1e1e1e`},ir=`__shiki_resolved`;function ar(e){if(e?.[ir])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||=`dark`,t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){let e=t.settings?t.settings.find(e=>!e.name&&!e.scope):void 0;e?.settings?.foreground&&(r=e.settings.foreground),e?.settings?.background&&(n=e.settings.background),!r&&t?.colors?.[`editor.foreground`]&&(r=t.colors[`editor.foreground`]),!n&&t?.colors?.[`editor.background`]&&(n=t.colors[`editor.background`]),r||=t.type===`light`?nr.light:nr.dark,n||=t.type===`light`?rr.light:rr.dark,t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0,a=new Map;function o(e){if(a.has(e))return a.get(e);i+=1;let n=`#${i.toString(16).padStart(8,`0`).toLowerCase()}`;return t.colorReplacements?.[`#${n}`]?o(e):(a.set(e,n),n)}t.settings=t.settings.map(e=>{let n=e.settings?.foreground&&!e.settings.foreground.startsWith(`#`),r=e.settings?.background&&!e.settings.background.startsWith(`#`);if(!n&&!r)return e;let i={...e,settings:{...e.settings}};if(n){let n=o(e.settings.foreground);t.colorReplacements[n]=e.settings.foreground,i.settings.foreground=n}if(r){let n=o(e.settings.background);t.colorReplacements[n]=e.settings.background,i.settings.background=n}return i});for(let e of Object.keys(t.colors||{}))if((e===`editor.foreground`||e===`editor.background`||e.startsWith(`terminal.ansi`))&&!t.colors[e]?.startsWith(`#`)){let n=o(t.colors[e]);t.colorReplacements[n]=t.colors[e],t.colors[e]=n}return Object.defineProperty(t,ir,{enumerable:!1,writable:!1,value:!0}),t}async function or(e){return[...new Set((await Promise.all(e.filter(e=>!Zn(e)).map(async e=>await Yn(e).then(e=>Array.isArray(e)?e:[e])))).flat())]}async function sr(e){return(await Promise.all(e.map(async e=>$n(e)?null:ar(await Yn(e))))).filter(e=>!!e)}function cr(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new F(`Circular alias \`${[...n].join(` -> `)} -> ${e}\``);n.add(e)}}return e}var lr=class extends Fn{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(e=>this.loadTheme(e)),this.loadLanguages(this._langs)}getTheme(e){return typeof e==`string`?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=ar(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||=[...this._resolvedThemes.keys()],this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=gt.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=cr(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(t=>t.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||[`*`],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(t=>{this._alias[t]=e.name}),this._loadedLanguagesCache=null,t.size)for(let e of t)this._syncRegistry?._grammars?.get(e.scopeName)?.dispose(),this._resolvedGrammars.delete(e.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(e.scopeName),this._syncRegistry?._grammars?.delete(e.scopeName),this.loadLanguage(this._langMap.get(e.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let t of e)this.resolveEmbeddedLanguages(t);let t=[...this._langGraph.entries()],n=t.filter(([e,t])=>!t);if(n.length){let e=t.filter(([e,t])=>t?(t.embeddedLanguages||t.embeddedLangs)?.some(e=>n.map(([e])=>e).includes(e)):!1).filter(e=>!n.includes(e));throw new F(`Missing languages ${n.map(([e])=>`\`${e}\``).join(`, `)}, required by ${e.map(([e])=>`\`${e}\``).join(`, `)}`)}for(let[e,n]of t)this._resolver.addLanguage(n);for(let[e,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])],this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let e of t)this._langGraph.set(e,this._langMap.get(e))}},ur=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:t=>e.createScanner(t),createOnigString:t=>e.createString(t)},t.forEach(e=>this.addLanguage(e))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).includes(e.scopeName)||this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split(`.`),n=[];for(let e=1;e<=t.length;e++){let r=t.slice(0,e).join(`.`);n=[...n,...this._injections.get(r)||[]]}return n}},L=0;function dr(e){L+=1,e.warnings!==!1&&L>=10&&L%10==0&&console.warn(`[Shiki] ${L} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new F("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(ar),i=new lr(new ur(e.engine,n),r,n,e.langAlias),a;function o(t){return cr(t,e.langAlias)}function s(e){g();let t=i.getGrammar(typeof e==`string`?e:e.name);if(!t)throw new F(`Language \`${e}\` not found, you may need to load it first`);return t}function c(e){if(e===`none`)return{bg:``,fg:``,name:`none`,settings:[],type:`dark`};g();let t=i.getTheme(e);if(!t)throw new F(`Theme \`${e}\` not found, you may need to load it first`);return t}function l(e){g();let t=c(e);return a!==e&&(i.setTheme(t),a=e),{theme:t,colorMap:i.getColorMap()}}function u(){return g(),i.getLoadedThemes()}function d(){return g(),i.getLoadedLanguages()}function f(...e){g(),i.loadLanguages(e.flat(1))}async function p(...e){return f(await or(e))}function m(...e){g();for(let t of e.flat(1))i.loadTheme(t)}async function h(...e){return g(),m(await sr(e))}function g(){if(t)throw new F(`Shiki instance has been disposed`)}function _(){t||(t=!0,i.dispose(),--L)}return{setTheme:l,getTheme:c,getLanguage:s,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:o,loadLanguage:p,loadLanguageSync:f,loadTheme:h,loadThemeSync:m,dispose:_,[Symbol.dispose]:_}}async function fr(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([sr(e.themes||[]),or(e.langs||[]),e.engine]);return dr({...e,themes:t,langs:n,engine:r})}var pr=new WeakMap;function mr(e,t){pr.set(e,t)}function R(e){return pr.get(e)}var hr=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new e(Object.fromEntries(Jn(n).map(e=>[e,In])),t)}constructor(...e){if(e.length===2){let[t,n]=e;this.lang=n,this._stacks=t}else{let[t,n,r]=e;this.lang=n,this._stacks={[r]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return gr(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function gr(e){let t=[],n=new Set;function r(e){if(n.has(e))return;n.add(e);let i=e?.nameScopesList?.scopeName;i&&t.push(i),e.parent&&r(e.parent)}return r(e),t}function _r(e,t){if(!(e instanceof hr))throw new F(`Invalid grammar state`);return e.getInternalStack(t)}var vr=/,/,yr=/ /;function br(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(Xn(e.resolveLangAlias(n.lang||`text`))||Qn(r))return tr(t).map(e=>[{content:e[0],offset:e[1]}]);let{theme:i,colorMap:a}=e.setTheme(r),o=e.getLanguage(n.lang||`text`);if(n.grammarState){if(n.grammarState.lang!==o.name)throw new F(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(i.name))throw new F(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return Sr(t,o,i,a,n)}function xr(...e){if(e.length===2)return R(e[1]);let[t,n,r={}]=e,{lang:i=`text`,theme:a=t.getLoadedThemes()[0]}=r;if(Xn(i)||Qn(a))throw new F(`Plain language does not have grammar state`);if(i===`ansi`)throw new F(`ANSI language does not have grammar state`);let{theme:o,colorMap:s}=t.setTheme(a),c=t.getLanguage(i);return new hr(Cr(n,c,o,s,r).stateStack,c.name,o.name)}function Sr(e,t,n,r,i){let a=Cr(e,t,n,r,i),o=new hr(a.stateStack,t.name,n.name);return mr(a.tokens,o),a.tokens}function Cr(e,t,n,r,i){let a=qn(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:s=500,includeExplanation:c=!1}=i,l=tr(e),u=i.grammarState?_r(i.grammarState,n.name)??In:i.grammarContextCode==null?In:Cr(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack,d=[],f=[];for(let e=0,i=l.length;e<i;e++){let[i,p]=l[e];if(i===``){d=[],f.push([]);continue}if(o>0&&i.length>=o){d=[],f.push([{content:i,offset:p,color:``,fontStyle:0}]);continue}let m,h,g;c&&c!==`tokenType`&&(m=t.tokenizeLine(i,u,s),h=m.tokens,g=0);let _=t.tokenizeLine2(i,u,s),ee=_.tokens.length/2;for(let e=0;e<ee;e++){let t=_.tokens[2*e],o=e+1<ee?_.tokens[2*e+2]:i.length;if(t===o)continue;let s=_.tokens[2*e+1],l=I(r[P.getForeground(s)],a),u=P.getFontStyle(s),f={content:i.substring(t,o),offset:p+t,color:l,fontStyle:u};if(c===`tokenType`)f.type=P.getTokenType(s);else if(c){let e=[];if(c!==`scopeName`)for(let t of n.settings){let n;switch(typeof t.scope){case`string`:n=t.scope.split(vr).map(e=>e.trim());break;case`object`:n=t.scope;break;default:continue}e.push({settings:t,selectors:n.map(e=>e.split(yr))})}f.explanation=[];let r=0;for(;t+r<o;){let t=h[g],n=i.substring(t.startIndex,t.endIndex);r+=n.length,f.explanation.push({content:n,scopes:c===`scopeName`?wr(t.scopes):Tr(e,t.scopes)}),g+=1}}d.push(f)}f.push(d),d=[],u=_.ruleStack}return{tokens:f,stateStack:u}}function wr(e){return e.map(e=>({scopeName:e}))}function Tr(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];n[r]={scopeName:i,themeMatches:Or(e,i,t.slice(0,r))}}return n}function Er(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]===`.`}function Dr(e,t,n){if(!Er(e.at(-1),t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)Er(e[r],n[i])&&--r,--i;return r===-1}function Or(e,t,n){let r=[];for(let{selectors:i,settings:a}of e)for(let e of i)if(Dr(e,t,n)){r.push(a);break}return r}function kr(e,t,n,r=br){let i=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})),a=i.map(i=>{let a=r(e,t,{...n,theme:i.theme});return{tokens:a,state:R(a),theme:typeof i.theme==`string`?i.theme:i.theme.name}}),o=Ar(...a.map(e=>e.tokens)),s=o[0].map((e,t)=>e.map((e,r)=>{let a={content:e.content,variants:{},offset:e.offset};return`includeExplanation`in n&&n.includeExplanation&&(a.explanation=e.explanation),o.forEach((e,n)=>{let{content:o,explanation:s,offset:c,...l}=e[t][r];a.variants[i[n].color]=l}),a})),c=a[0].state?new hr(Object.fromEntries(a.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),a[0].state.lang):void 0;return c&&mr(s,c),s}function Ar(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let i=e.map(e=>e[r]),a=t.map(()=>[]);t.forEach((e,t)=>e.push(a[t]));let o=i.map(()=>0),s=i.map(e=>e[0]);for(;s.every(e=>e);){let e=Math.min(...s.map(e=>e.content.length));for(let t=0;t<n;t++){let n=s[t];n.content.length===e?(a[t].push(n),o[t]+=1,s[t]=i[t][o[t]]):(a[t].push({...n,content:n.content.slice(0,e)}),s[t]={...n,content:n.content.slice(e),offset:n.offset+e})}}}return t}var jr=[`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`command`,`embed`,`frame`,`hr`,`image`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`],z=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};z.prototype.normal={},z.prototype.property={},z.prototype.space=void 0;function Mr(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new z(n,r,t)}function Nr(e){return e.toLowerCase()}var B=class{constructor(e,t){this.attribute=t,this.property=e}};B.prototype.attribute=``,B.prototype.booleanish=!1,B.prototype.boolean=!1,B.prototype.commaOrSpaceSeparated=!1,B.prototype.commaSeparated=!1,B.prototype.defined=!1,B.prototype.mustUseProperty=!1,B.prototype.number=!1,B.prototype.overloadedBoolean=!1,B.prototype.property=``,B.prototype.spaceSeparated=!1,B.prototype.space=void 0;var Pr=t({boolean:()=>V,booleanish:()=>H,commaOrSpaceSeparated:()=>K,commaSeparated:()=>G,number:()=>U,overloadedBoolean:()=>Ir,spaceSeparated:()=>W}),Fr=0,V=q(),H=q(),Ir=q(),U=q(),W=q(),G=q(),K=q();function q(){return 2**++Fr}var Lr=Object.keys(Pr),Rr=class extends B{constructor(e,t,n,r){let i=-1;if(super(e,t),zr(this,`space`,r),typeof n==`number`)for(;++i<Lr.length;){let e=Lr[i];zr(this,Lr[i],(n&Pr[e])===Pr[e])}}};Rr.prototype.defined=!0;function zr(e,t,n){n&&(e[t]=n)}function J(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Rr(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Nr(r)]=r,n[Nr(a.attribute)]=r}return new z(t,n,e.space)}var Br=J({properties:{ariaActiveDescendant:null,ariaAtomic:H,ariaAutoComplete:null,ariaBusy:H,ariaChecked:H,ariaColCount:U,ariaColIndex:U,ariaColSpan:U,ariaControls:W,ariaCurrent:null,ariaDescribedBy:W,ariaDetails:null,ariaDisabled:H,ariaDropEffect:W,ariaErrorMessage:null,ariaExpanded:H,ariaFlowTo:W,ariaGrabbed:H,ariaHasPopup:null,ariaHidden:H,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:W,ariaLevel:U,ariaLive:null,ariaModal:H,ariaMultiLine:H,ariaMultiSelectable:H,ariaOrientation:null,ariaOwns:W,ariaPlaceholder:null,ariaPosInSet:U,ariaPressed:H,ariaReadOnly:H,ariaRelevant:null,ariaRequired:H,ariaRoleDescription:W,ariaRowCount:U,ariaRowIndex:U,ariaRowSpan:U,ariaSelected:H,ariaSetSize:U,ariaSort:null,ariaValueMax:U,ariaValueMin:U,ariaValueNow:U,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function Vr(e,t){return t in e?e[t]:t}function Hr(e,t){return Vr(e,t.toLowerCase())}var Ur=J({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:G,acceptCharset:W,accessKey:W,action:null,allow:null,allowFullScreen:V,allowPaymentRequest:V,allowUserMedia:V,alpha:V,alt:null,as:null,async:V,autoCapitalize:null,autoComplete:W,autoFocus:V,autoPlay:V,blocking:W,capture:null,charSet:null,checked:V,cite:null,className:W,closedBy:null,colorSpace:null,cols:U,colSpan:U,command:null,commandFor:null,content:null,contentEditable:H,controls:V,controlsList:W,coords:U|G,crossOrigin:null,data:null,dateTime:null,decoding:null,default:V,defer:V,dir:null,dirName:null,disabled:V,download:Ir,draggable:H,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:V,formTarget:null,headers:W,height:U,hidden:Ir,high:U,href:null,hrefLang:null,htmlFor:W,httpEquiv:W,id:null,imageSizes:null,imageSrcSet:null,inert:V,inputMode:null,integrity:null,is:null,isMap:V,itemId:null,itemProp:W,itemRef:W,itemScope:V,itemType:W,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:V,low:U,manifest:null,max:null,maxLength:U,media:null,method:null,min:null,minLength:U,multiple:V,muted:V,name:null,nonce:null,noModule:V,noValidate:V,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:V,optimum:U,pattern:null,ping:W,placeholder:null,playsInline:V,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:V,referrerPolicy:null,rel:W,required:V,reversed:V,rows:U,rowSpan:U,sandbox:W,scope:null,scoped:V,seamless:V,selected:V,shadowRootClonable:V,shadowRootCustomElementRegistry:V,shadowRootDelegatesFocus:V,shadowRootMode:null,shadowRootSerializable:V,shape:null,size:U,sizes:null,slot:null,span:U,spellCheck:H,src:null,srcDoc:null,srcLang:null,srcSet:null,start:U,step:null,style:null,tabIndex:U,target:null,title:null,translate:null,type:null,typeMustMatch:V,useMap:null,value:H,width:U,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:W,axis:null,background:null,bgColor:null,border:U,borderColor:null,bottomMargin:U,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:V,declare:V,event:null,face:null,frame:null,frameBorder:null,hSpace:U,leftMargin:U,link:null,longDesc:null,lowSrc:null,marginHeight:U,marginWidth:U,noResize:V,noHref:V,noShade:V,noWrap:V,object:null,profile:null,prompt:null,rev:null,rightMargin:U,rules:null,scheme:null,scrolling:H,standby:null,summary:null,text:null,topMargin:U,valueType:null,version:null,vAlign:null,vLink:null,vSpace:U,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:V,disablePictureInPicture:V,disableRemotePlayback:V,exportParts:G,part:W,prefix:null,property:null,results:U,security:null,unselectable:null},space:`html`,transform:Hr}),Wr=J({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:K,accentHeight:U,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:U,amplitude:U,arabicForm:null,ascent:U,attributeName:null,attributeType:null,azimuth:U,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:U,by:null,calcMode:null,capHeight:U,className:W,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:U,diffuseConstant:U,direction:null,display:null,dur:null,divisor:U,dominantBaseline:null,download:V,dx:null,dy:null,edgeMode:null,editable:null,elevation:U,enableBackground:null,end:null,event:null,exponent:U,externalResourcesRequired:null,fill:null,fillOpacity:U,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:G,g2:G,glyphName:G,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:U,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:U,horizOriginX:U,horizOriginY:U,id:null,ideographic:U,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:U,k:U,k1:U,k2:U,k3:U,k4:U,kernelMatrix:K,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:U,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:U,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:U,overlineThickness:U,paintOrder:null,panose1:null,path:null,pathLength:U,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:W,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:U,pointsAtY:U,pointsAtZ:U,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:K,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:K,rev:K,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:K,requiredFeatures:K,requiredFonts:K,requiredFormats:K,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:U,specularExponent:U,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:U,strikethroughThickness:U,string:null,stroke:null,strokeDashArray:K,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:U,strokeOpacity:U,strokeWidth:null,style:null,surfaceScale:U,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:K,tabIndex:U,tableValues:null,target:null,targetX:U,targetY:U,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:K,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:U,underlineThickness:U,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:U,values:null,vAlphabetic:U,vMathematical:U,vectorEffect:null,vHanging:U,vIdeographic:U,version:null,vertAdvY:U,vertOriginX:U,vertOriginY:U,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:U,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:Vr}),Gr=J({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),Kr=J({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Hr}),qr=J({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Jr=/[A-Z]/g,Yr=/-[a-z]/g,Xr=/^data[-\w.:]+$/i;function Zr(e,t){let n=Nr(t),r=t,i=B;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Xr.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Yr,$r);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Yr.test(e)){let n=e.replace(Jr,Qr);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Rr}return new i(r,t)}function Qr(e){return`-`+e.toLowerCase()}function $r(e){return e.charAt(1).toUpperCase()}var ei=Mr([Br,Ur,Gr,Kr,qr],`html`),ti=Mr([Br,Wr,Gr,Kr,qr],`svg`),ni={}.hasOwnProperty;function ri(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&ni.call(t,e)){let n=String(t[e]);i=ni.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var ii=/["&'<>`]/g,ai=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,oi=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,si=/[|\\{}()[\]^$+*?.]/g,ci=new WeakMap;function li(e,t){return e=e.replace(t.subset?ui(t.subset):ii,r),t.subset||t.escapeOnly?e:e.replace(ai,n).replace(oi,r);function n(e,n,r){return t.format((e.charCodeAt(0)-55296)*1024+e.charCodeAt(1)-56320+65536,r.charCodeAt(n+2),t)}function r(e,n,r){return t.format(e.charCodeAt(0),r.charCodeAt(n+1),t)}}function ui(e){let t=ci.get(e);return t||(t=di(e),ci.set(e,t)),t}function di(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(si,`\\$&`));return RegExp(`(?:`+t.join(`|`)+`)`,`g`)}var fi=/[\dA-Fa-f]/;function pi(e,t,n){let r=`&#x`+e.toString(16).toUpperCase();return n&&t&&!fi.test(String.fromCharCode(t))?r:r+`;`}var mi=/\d/;function hi(e,t,n){let r=`&#`+String(e);return n&&t&&!mi.test(String.fromCharCode(t))?r:r+`;`}var gi=`AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml`.split(`.`),_i={nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:`­`,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`〈`,rang:`〉`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,quot:`"`,amp:`&`,lt:`<`,gt:`>`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:`‌`,zwj:`‍`,lrm:`‎`,rlm:`‏`,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`,euro:`€`},vi=[`cent`,`copy`,`divide`,`gt`,`lt`,`not`,`para`,`times`],yi={}.hasOwnProperty,bi={},xi;for(xi in _i)yi.call(_i,xi)&&(bi[_i[xi]]=xi);var Si=/[^\dA-Za-z]/;function Ci(e,t,n,r){let i=String.fromCharCode(e);if(yi.call(bi,i)){let e=bi[i],a=`&`+e;return n&&gi.includes(e)&&!vi.includes(e)&&(!r||t&&t!==61&&Si.test(String.fromCharCode(t)))?a:a+`;`}return``}function wi(e,t,n){let r=pi(e,t,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=Ci(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){let i=hi(e,t,n.omitOptionalSemicolons);i.length<r.length&&(r=i)}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function Y(e,t){return li(e,Object.assign({format:wi},t))}var Ti=/^>|^->|<!--|-->|--!>|<!-$/g,Ei=[`>`],Di=[`<`,`>`];function Oi(e,t,n,r){return r.settings.bogusComments?`<?`+Y(e.value,Object.assign({},r.settings.characterReferences,{subset:Ei}))+`>`:`<!--`+e.value.replace(Ti,i)+`-->`;function i(e){return Y(e,Object.assign({},r.settings.characterReferences,{subset:Di}))}}function ki(e,t,n,r){return`<!`+(r.settings.upperDoctype?`DOCTYPE`:`doctype`)+(r.settings.tightDoctype?``:` `)+`html>`}function Ai(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function ji(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}function Mi(e){return e.join(` `).trim()}var Ni=/[ \t\n\f\r]/g;function Pi(e){return typeof e==`object`?e.type===`text`&&Fi(e.value):Fi(e)}function Fi(e){return e.replace(Ni,``)===``}var X=Ri(1),Ii=Ri(-1),Li=[];function Ri(e){return t;function t(t,n,r){let i=t?t.children:Li,a=(n||0)+e,o=i[a];if(!r)for(;o&&Pi(o);)a+=e,o=i[a];return o}}var zi={}.hasOwnProperty;function Bi(e){return t;function t(t,n,r){return zi.call(e,t.tagName)&&e[t.tagName](t,n,r)}}var Vi=Bi({body:Wi,caption:Hi,colgroup:Hi,dd:Ji,dt:qi,head:Hi,html:Ui,li:Ki,optgroup:Xi,option:Zi,p:Gi,rp:Yi,rt:Yi,tbody:$i,td:na,tfoot:ea,th:na,thead:Qi,tr:ta});function Hi(e,t,n){let r=X(n,t,!0);return!r||r.type!==`comment`&&!(r.type===`text`&&Pi(r.value.charAt(0)))}function Ui(e,t,n){let r=X(n,t);return!r||r.type!==`comment`}function Wi(e,t,n){let r=X(n,t);return!r||r.type!==`comment`}function Gi(e,t,n){let r=X(n,t);return r?r.type===`element`&&(r.tagName===`address`||r.tagName===`article`||r.tagName===`aside`||r.tagName===`blockquote`||r.tagName===`details`||r.tagName===`div`||r.tagName===`dl`||r.tagName===`fieldset`||r.tagName===`figcaption`||r.tagName===`figure`||r.tagName===`footer`||r.tagName===`form`||r.tagName===`h1`||r.tagName===`h2`||r.tagName===`h3`||r.tagName===`h4`||r.tagName===`h5`||r.tagName===`h6`||r.tagName===`header`||r.tagName===`hgroup`||r.tagName===`hr`||r.tagName===`main`||r.tagName===`menu`||r.tagName===`nav`||r.tagName===`ol`||r.tagName===`p`||r.tagName===`pre`||r.tagName===`section`||r.tagName===`table`||r.tagName===`ul`):!n||n.type!==`element`||n.tagName!==`a`&&n.tagName!==`audio`&&n.tagName!==`del`&&n.tagName!==`ins`&&n.tagName!==`map`&&n.tagName!==`noscript`&&n.tagName!==`video`}function Ki(e,t,n){let r=X(n,t);return!r||r.type===`element`&&r.tagName===`li`}function qi(e,t,n){let r=X(n,t);return!(!r||r.type!==`element`||r.tagName!==`dt`&&r.tagName!==`dd`)}function Ji(e,t,n){let r=X(n,t);return!r||r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`)}function Yi(e,t,n){let r=X(n,t);return!r||r.type===`element`&&(r.tagName===`rp`||r.tagName===`rt`)}function Xi(e,t,n){let r=X(n,t);return!r||r.type===`element`&&r.tagName===`optgroup`}function Zi(e,t,n){let r=X(n,t);return!r||r.type===`element`&&(r.tagName===`option`||r.tagName===`optgroup`)}function Qi(e,t,n){let r=X(n,t);return!(!r||r.type!==`element`||r.tagName!==`tbody`&&r.tagName!==`tfoot`)}function $i(e,t,n){let r=X(n,t);return!r||r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`)}function ea(e,t,n){return!X(n,t)}function ta(e,t,n){let r=X(n,t);return!r||r.type===`element`&&r.tagName===`tr`}function na(e,t,n){let r=X(n,t);return!r||r.type===`element`&&(r.tagName===`td`||r.tagName===`th`)}var ra=Bi({body:oa,colgroup:sa,head:aa,html:ia,tbody:ca});function ia(e){let t=X(e,-1);return!t||t.type!==`comment`}function aa(e){let t=new Set;for(let n of e.children)if(n.type===`element`&&(n.tagName===`base`||n.tagName===`title`)){if(t.has(n.tagName))return!1;t.add(n.tagName)}let n=e.children[0];return!n||n.type===`element`}function oa(e){let t=X(e,-1,!0);return!t||t.type!==`comment`&&!(t.type===`text`&&Pi(t.value.charAt(0)))&&(t.type!==`element`||t.tagName!==`meta`&&t.tagName!==`link`&&t.tagName!==`script`&&t.tagName!==`style`&&t.tagName!==`template`)}function sa(e,t,n){let r=Ii(n,t),i=X(e,-1,!0);return n&&r&&r.type===`element`&&r.tagName===`colgroup`&&Vi(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`col`)}function ca(e,t,n){let r=Ii(n,t),i=X(e,-1);return n&&r&&r.type===`element`&&(r.tagName===`thead`||r.tagName===`tbody`)&&Vi(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`tr`)}var la={name:[[`
15
+ \f\r &/=>`.split(``),`
16
+ \f\r "&'/=>\``.split(``)],[`\0
17
+ \f\r "&'/<=>`.split(``),`\0
18
+ \f\r "&'/<=>\``.split(``)]],unquoted:[[`
19
+ \f\r &>`.split(``),`\0
20
+ \f\r "&'<=>\``.split(``)],[`\0
21
+ \f\r "&'<=>\``.split(``),`\0
22
+ \f\r "&'<=>\``.split(``)]],single:[[`&'`.split(``),`"&'\``.split(``)],[`\0&'`.split(``),`\0"&'\``.split(``)]],double:[[`"&`.split(``),`"&'\``.split(``)],[`\0"&`.split(``),`\0"&'\``.split(``)]]};function ua(e,t,n,r){let i=r.schema,a=i.space!==`svg`&&r.settings.omitOptionalTags,o=i.space===`svg`?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),s=[],c;i.space===`html`&&e.tagName===`svg`&&(r.schema=ti);let l=da(r,e.properties),u=r.all(i.space===`html`&&e.tagName===`template`?e.content:e);return r.schema=i,u&&(o=!1),(l||!a||!ra(e,t,n))&&(s.push(`<`,e.tagName,l?` `+l:``),o&&(i.space===`svg`||r.settings.closeSelfClosing)&&(c=l.charAt(l.length-1),(!r.settings.tightSelfClosing||c===`/`||c&&c!==`"`&&c!==`'`)&&s.push(` `),s.push(`/`)),s.push(`>`)),s.push(u),!o&&(!a||!Vi(e,t,n))&&s.push(`</`+e.tagName+`>`),s.join(``)}function da(e,t){let n=[],r=-1,i;if(t){for(i in t)if(t[i]!==null&&t[i]!==void 0){let r=fa(e,i,t[i]);r&&n.push(r)}}for(;++r<n.length;){let t=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&t!==`"`&&t!==`'`&&(n[r]+=` `)}return n.join(``)}function fa(e,t,n){let r=Zr(e.schema,t),i=e.settings.allowParseErrors&&e.schema.space===`html`?0:1,a=+!e.settings.allowDangerousCharacters,o=e.quote,s;if(r.overloadedBoolean&&(n===r.attribute||n===``)?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!=`string`||n===r.attribute||n===``)&&(n=!!n),n==null||n===!1||typeof n==`number`&&Number.isNaN(n))return``;let c=Y(r.attribute,Object.assign({},e.settings.characterReferences,{subset:la.name[i][a]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?ji:Mi)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?c:(e.settings.preferUnquoted&&(s=Y(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:la.unquoted[i][a]}))),s!==n&&(e.settings.quoteSmart&&Ai(n,o)>Ai(n,e.alternative)&&(o=e.alternative),s=o+Y(n,Object.assign({},e.settings.characterReferences,{subset:(o===`'`?la.single:la.double)[i][a],attribute:!0}))+o),c+(s&&`=`+s))}var pa=[`<`,`&`];function ma(e,t,n,r){return n&&n.type===`element`&&(n.tagName===`script`||n.tagName===`style`)?e.value:Y(e.value,Object.assign({},r.settings.characterReferences,{subset:pa}))}function ha(e,t,n,r){return r.settings.allowDangerousHtml?e.value:ma(e,t,n,r)}function ga(e,t,n,r){return r.all(e)}var _a=ri(`type`,{invalid:va,unknown:ya,handlers:{comment:Oi,doctype:ki,element:ua,raw:ha,root:ga,text:ma}});function va(e){throw Error("Expected node, not `"+e+"`")}function ya(e){throw Error("Cannot compile unknown node `"+e.type+"`")}var ba={},xa={},Sa=[];function Ca(e,t){let n=t||ba,r=n.quote||`"`,i=r===`"`?`'`:`"`;if(r!==`"`&&r!==`'`)throw Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:wa,all:Ta,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||jr,characterReferences:n.characterReferences||xa,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space===`svg`?ti:ei,quote:r,alternative:i}.one(Array.isArray(e)?{type:`root`,children:e}:e,void 0,void 0)}function wa(e,t,n){return _a(e,t,n,this)}function Ta(e){let t=[],n=e&&e.children||Sa,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join(``)}var Ea=/\s+/g;function Da(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class==`string`&&(e.properties.class=e.properties.class.split(Ea)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(Ea);for(let t of n)t&&!e.properties.class.includes(t)&&e.properties.class.push(t);return e}function Oa(e){let t=tr(e,!0).map(([e])=>e);function n(n){if(n===e.length)return{line:t.length-1,character:t.at(-1).length};let r=n,i=0;for(let e of t){if(r<e.length)break;r-=e.length,i++}return{line:i,character:r}}function r(e,n){let r=0;for(let n=0;n<e;n++)r+=t[n].length;return r+=n,r}return{lines:t,indexToPos:n,posToIndex:r}}var ka=[`color`,`background-color`];function Aa(e,t){let n=0,r=[];for(let i of t)i>n&&r.push({...e,content:e.content.slice(n,i),offset:e.offset+n}),n=i;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function ja(e,t){let n=0,r=e.length;for(;n<r;){let i=n+(r-n>>1);e[i]<=t?n=i+1:r=i}return n}function Ma(e,t){let n=[...t instanceof Set?t:new Set(t)].sort((e,t)=>e-t);return n.length?e.map(e=>e.flatMap(e=>{let t=e.offset+e.content.length,r=ja(n,e.offset),i=r;for(;i<n.length&&n[i]<t;)i++;if(r===i)return e;let a=n.slice(r,i);for(let t=0;t<a.length;t++)a[t]-=e.offset;return Aa(e,a)})):e}function Na(e,t,n,r,i=`css-vars`){let a={content:e.content,explanation:e.explanation,offset:e.offset},o=t.map(t=>Pa(e.variants[t])),s=new Set(o.flatMap(e=>Object.keys(e))),c={},l=(e,r)=>{let i=r===`color`?``:r===`background-color`?`-bg`:`-${r}`;return n+t[e]+(r===`color`?``:i)};return o.forEach((e,n)=>{for(let a of s){let s=e[a]||`inherit`;if(n===0&&r&&ka.includes(a)){if(r===`light-dark()`&&o.length>1){let e=t.findIndex(e=>e===`light`),r=t.findIndex(e=>e===`dark`);if(e===-1||r===-1)throw new F('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let u=o[e][a]||`inherit`,d=o[r][a]||`inherit`;c[a]=`light-dark(${u}, ${d})`,i===`css-vars`&&(c[l(n,a)]=s)}else c[a]=s}else i===`css-vars`&&(c[l(n,a)]=s)}}),a.htmlStyle=c,a}function Pa(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t[`background-color`]=e.bgColor),e.fontStyle){e.fontStyle&N.Italic&&(t[`font-style`]=`italic`),e.fontStyle&N.Bold&&(t[`font-weight`]=`bold`);let n=[];e.fontStyle&N.Underline&&n.push(`underline`),e.fontStyle&N.Strikethrough&&n.push(`line-through`),n.length&&(t[`text-decoration`]=n.join(` `))}return t}function Fa(e){return typeof e==`string`?e:Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function Ia(){let e=new WeakMap;function t(t){if(!e.has(t.meta)){let n=Oa(t.source);function r(e){if(typeof e==`number`){if(e<0||e>t.source.length)throw new F(`Invalid decoration offset: ${e}. Code length: ${t.source.length}`);return{...n.indexToPos(e),offset:e}}{let t=n.lines[e.line];if(t===void 0)throw new F(`Invalid decoration position ${JSON.stringify(e)}. Lines length: ${n.lines.length}`);let r=e.character;if(r<0&&(r=t.length+r),r<0||r>t.length)throw new F(`Invalid decoration position ${JSON.stringify(e)}. Line ${e.line} length: ${t.length}`);return{...e,character:r,offset:n.posToIndex(e.line,r)}}}let i=(t.options.decorations||[]).map(e=>({...e,start:r(e.start),end:r(e.end)}));La(i),e.set(t.meta,{decorations:i,converter:n,source:t.source})}return e.get(t.meta)}return{name:`shiki:decorations`,tokens(e){if(this.options.decorations?.length)return Ma(e,t(this).decorations.flatMap(e=>[e.start.offset,e.end.offset]))},code(e){if(!this.options.decorations?.length)return;let n=t(this),r=[...e.children].filter(e=>e.type===`element`&&e.tagName===`span`);if(r.length!==n.converter.lines.length)throw new F(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${n.converter.lines.length}). Failed to apply decorations.`);function i(e,t,n,i){let a=r[e],s=``,c=-1,l=-1;if(t===0&&(c=0),n===0&&(l=0),n===1/0&&(l=a.children.length),c===-1||l===-1)for(let e=0;e<a.children.length;e++)s+=Ra(a.children[e]),c===-1&&s.length===t&&(c=e+1),l===-1&&s.length===n&&(l=e+1);if(c===-1)throw new F(`Failed to find start index for decoration ${JSON.stringify(i.start)}`);if(l===-1)throw new F(`Failed to find end index for decoration ${JSON.stringify(i.end)}`);let u=a.children.slice(c,l);if(!i.alwaysWrap&&u.length===a.children.length)o(a,i,`line`);else if(!i.alwaysWrap&&u.length===1&&u[0].type===`element`)o(u[0],i,`token`);else{let e={type:`element`,tagName:`span`,properties:{},children:u};o(e,i,`wrapper`),a.children.splice(c,u.length,e)}}function a(e,t){r[e]=o(r[e],t,`line`)}function o(e,t,n){let r=t.properties||{},i=t.transform||(e=>e);return e.tagName=t.tagName||`span`,e.properties={...e.properties,...r,class:e.properties.class},t.properties?.class&&Da(e,t.properties.class),e=i(e,n)||e,e}let s=[],c=n.decorations.sort((e,t)=>t.start.offset-e.start.offset||e.end.offset-t.end.offset);for(let e of c){let{start:t,end:n}=e;if(t.line===n.line)i(t.line,t.character,n.character,e);else if(t.line<n.line){i(t.line,t.character,1/0,e);for(let r=t.line+1;r<n.line;r++)s.unshift(()=>a(r,e));i(n.line,0,n.character,e)}}s.forEach(e=>e())}}}function La(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new F(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let t=e[r],i=n.start.offset<=t.start.offset&&t.start.offset<n.end.offset,a=n.start.offset<t.end.offset&&t.end.offset<=n.end.offset,o=t.start.offset<=n.start.offset&&n.start.offset<t.end.offset,s=t.start.offset<n.end.offset&&n.end.offset<=t.end.offset;if(i||a||o||s){if(i&&a||o&&s||o&&n.start.offset===n.end.offset||a&&t.start.offset===t.end.offset)continue;throw new F(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(t.start)} intersect.`)}}}}function Ra(e){return e.type===`text`?e.value:e.type===`element`?e.children.map(Ra).join(``):``}var za=[Ia()];function Ba(e){let t=Va(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...za]}function Va(e){let t=[],n=[],r=[];for(let i of e)switch(i.enforce){case`pre`:t.push(i);break;case`post`:n.push(i);break;default:r.push(i)}return{pre:t,post:n,normal:r}}var Z=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],Ha={1:`bold`,2:`dim`,3:`italic`,4:`underline`,7:`reverse`,8:`hidden`,9:`strikethrough`};function Ua(e,t){let n=e.indexOf(`\x1B`,t);if(n!==-1&&e[n+1]===`[`){let t=e.indexOf(`m`,n);if(t!==-1)return{sequence:e.substring(n+2,t).split(`;`),startPosition:n,position:t+1}}return{position:e.length}}function Wa(e){let t=e.shift();if(t===`2`){let t=e.splice(0,3).map(e=>Number.parseInt(e));return t.length!==3||t.some(e=>Number.isNaN(e))?void 0:{type:`rgb`,rgb:t}}if(t===`5`){let t=e.shift();if(t)return{type:`table`,index:Number(t)}}}function Ga(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r)){if(r===0)t.push({type:`resetAll`});else if(r<=9)Ha[r]&&t.push({type:`setDecoration`,value:Ha[r]});else if(r<=29){let e=Ha[r-20];e&&(t.push({type:`resetDecoration`,value:e}),e===`dim`&&t.push({type:`resetDecoration`,value:`bold`}))}else if(r<=37)t.push({type:`setForegroundColor`,value:{type:`named`,name:Z[r-30]}});else if(r===38){let n=Wa(e);n&&t.push({type:`setForegroundColor`,value:n})}else if(r===39)t.push({type:`resetForegroundColor`});else if(r<=47)t.push({type:`setBackgroundColor`,value:{type:`named`,name:Z[r-40]}});else if(r===48){let n=Wa(e);n&&t.push({type:`setBackgroundColor`,value:n})}else r===49?t.push({type:`resetBackgroundColor`}):r===53?t.push({type:`setDecoration`,value:`overline`}):r===55?t.push({type:`resetDecoration`,value:`overline`}):r>=90&&r<=97?t.push({type:`setForegroundColor`,value:{type:`named`,name:Z[r-90+8]}}):r>=100&&r<=107&&t.push({type:`setBackgroundColor`,value:{type:`named`,name:Z[r-100+8]}})}}return t}function Ka(){let e=null,t=null,n=new Set;return{parse(r){let i=[],a=0;do{let o=Ua(r,a),s=o.sequence?r.substring(a,o.startPosition):r.substring(a);if(s.length>0&&i.push({value:s,foreground:e,background:t,decorations:new Set(n)}),o.sequence){let r=Ga(o.sequence);for(let i of r)i.type===`resetAll`?(e=null,t=null,n.clear()):i.type===`resetForegroundColor`?e=null:i.type===`resetBackgroundColor`?t=null:i.type===`resetDecoration`&&n.delete(i.value);for(let i of r)i.type===`setForegroundColor`?e=i.value:i.type===`setBackgroundColor`?t=i.value:i.type===`setDecoration`&&n.add(i.value)}a=o.position}while(a<r.length);return i}}}var qa={black:`#000000`,red:`#bb0000`,green:`#00bb00`,yellow:`#bbbb00`,blue:`#0000bb`,magenta:`#ff00ff`,cyan:`#00bbbb`,white:`#eeeeee`,brightBlack:`#555555`,brightRed:`#ff5555`,brightGreen:`#00ff00`,brightYellow:`#ffff55`,brightBlue:`#5555ff`,brightMagenta:`#ff55ff`,brightCyan:`#55ffff`,brightWhite:`#ffffff`};function Ja(e=qa){function t(t){return e[t]}function n(e){return`#${e.map(e=>Math.max(0,Math.min(e,255)).toString(16).padStart(2,`0`)).join(``)}`}let r;function i(){if(r)return r;r=[];for(let e=0;e<Z.length;e++)r.push(t(Z[e]));let e=[0,95,135,175,215,255];for(let t=0;t<6;t++)for(let i=0;i<6;i++)for(let a=0;a<6;a++)r.push(n([e[t],e[i],e[a]]));let i=8;for(let e=0;e<24;e++,i+=10)r.push(n([i,i,i]));return r}function a(e){return i()[e]}function o(e){switch(e.type){case`named`:return t(e.name);case`rgb`:return n(e.rgb);case`table`:return a(e.index)}}return{value:o}}var Ya=/#([0-9a-f]{3,8})/i,Xa=/var\((--[\w-]+-ansi-[\w-]+)\)/,Za={black:`#000000`,red:`#cd3131`,green:`#0DBC79`,yellow:`#E5E510`,blue:`#2472C8`,magenta:`#BC3FBC`,cyan:`#11A8CD`,white:`#E5E5E5`,brightBlack:`#666666`,brightRed:`#F14C4C`,brightGreen:`#23D18B`,brightYellow:`#F5F543`,brightBlue:`#3B8EEA`,brightMagenta:`#D670D6`,brightCyan:`#29B8DB`,brightWhite:`#FFFFFF`};function Qa(e,t,n){let r=qn(e,n),i=tr(t),a=Ja(Object.fromEntries(Z.map(t=>{let n=`terminal.ansi${t[0].toUpperCase()}${t.substring(1)}`;return[t,e.colors?.[n]||Za[t]]}))),o=Ka();return i.map(t=>o.parse(t[0]).map(n=>{let i,o;n.decorations.has(`reverse`)?(i=n.background?a.value(n.background):e.bg,o=n.foreground?a.value(n.foreground):e.fg):(i=n.foreground?a.value(n.foreground):e.fg,o=n.background?a.value(n.background):void 0),i=I(i,r),o=I(o,r),n.decorations.has(`dim`)&&(i=$a(i));let s=N.None;return n.decorations.has(`bold`)&&(s|=N.Bold),n.decorations.has(`italic`)&&(s|=N.Italic),n.decorations.has(`underline`)&&(s|=N.Underline),n.decorations.has(`strikethrough`)&&(s|=N.Strikethrough),{content:n.value,offset:t[1],color:i,bgColor:o,fontStyle:s}}))}function $a(e){let t=e.match(Ya);if(t){let e=t[1];if(e.length===8){let t=Math.round(Number.parseInt(e.slice(6,8),16)/2).toString(16).padStart(2,`0`);return`#${e.slice(0,6)}${t}`}if(e.length===6)return`#${e}80`;if(e.length===4){let t=e[0],n=e[1],r=e[2],i=e[3];return`#${t}${t}${n}${n}${r}${r}${Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,`0`)}`}if(e.length===3){let t=e[0],n=e[1],r=e[2];return`#${t}${t}${n}${n}${r}${r}80`}}let n=e.match(Xa);return n?`var(${n[1]}-dim)`:e}function eo(e,t,n={}){let r=e.resolveLangAlias(n.lang||`text`),{theme:i=e.getLoadedThemes()[0]}=n;if(!Xn(r)&&!Qn(i)&&r===`ansi`){let{theme:r}=e.setTheme(i);return Qa(r,t,n)}return br(e,t,n)}function to(e,t,n){let r,i,a,o,s,c;if(`themes`in n){let{defaultColor:l=`light`,cssVariablePrefix:u=`--shiki-`,colorsRendering:d=`css-vars`}=n,f=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})).sort((e,t)=>e.color===l?-1:+(t.color===l));if(f.length===0)throw new F("`themes` option must not be empty");let p=kr(e,t,n,eo);if(c=R(p),l&&l!==`light-dark()`&&!f.some(e=>e.color===l))throw new F(`\`themes\` option must contain the defaultColor key \`${l}\``);let m=f.map(t=>e.getTheme(t.theme)),h=f.map(e=>e.color);a=p.map(e=>e.map(e=>Na(e,h,u,l,d))),c&&mr(a,c);let g=f.map(e=>qn(e.theme,n));i=no(f,m,g,u,l,`fg`,d),r=no(f,m,g,u,l,`bg`,d),o=`shiki-themes ${m.map(e=>e.name).join(` `)}`,s=l?void 0:[i,r].join(`;`)}else if(`theme`in n){let s=qn(n.theme,n);a=eo(e,t,n);let l=e.getTheme(n.theme);r=I(l.bg,s),i=I(l.fg,s),o=l.name,c=R(a)}else throw new F("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:i,bg:r,themeName:o,rootStyle:s,grammarState:c}}function no(e,t,n,r,i,a,o){return e.map((s,c)=>{let l=I(t[c][a],n[c])||`inherit`,u=`${r+s.color}${a===`bg`?`-bg`:``}:${l}`;if(c===0&&i){if(i===`light-dark()`&&e.length>1){let r=e.findIndex(e=>e.color===`light`),i=e.findIndex(e=>e.color===`dark`);if(r===-1||i===-1)throw new F('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${I(t[r][a],n[r])||`inherit`}, ${I(t[i][a],n[i])||`inherit`});${u}`}return l}return o===`css-vars`?u:null}).filter(e=>!!e).join(`;`)}var ro=/^\s+$/,io=/^(\s*)(.*?)(\s*)$/;function ao(e,t,n,r={meta:{},options:n,codeToHast:(t,n)=>ao(e,t,n),codeToTokens:(t,n)=>to(e,t,n)}){let i=t;for(let e of Ba(n))i=e.preprocess?.call(r,i,n)||i;let{tokens:a,fg:o,bg:s,themeName:c,rootStyle:l,grammarState:u}=to(e,i,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:f=!1}=n;d===!0?a=so(a):d===`never`&&(a=co(a)),f&&(a=lo(a));let p={...r,get source(){return i}};for(let e of Ba(n))a=e.tokens?.call(p,a)||a;return oo(a,{...n,fg:o,bg:s,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??l},p,u)}function oo(e,t,n,r=R(e)){let i=Ba(t),a=[],o={type:`root`,children:[]},{structure:s=`classic`,tabindex:c=`0`}=t,l={class:`shiki ${t.themeName||``}`};t.rootStyle!==!1&&(l.style=t.rootStyle==null?`background-color:${t.bg};color:${t.fg}`:t.rootStyle),c!==!1&&c!=null&&(l.tabindex=c.toString());for(let[e,n]of Object.entries(t.meta||{}))e.startsWith(`_`)||(l[e]=n);let u={type:`element`,tagName:`pre`,properties:l,children:[],data:t.data},d={type:`element`,tagName:`code`,properties:{},children:a},f=[],p={...n,structure:s,addClassToHast:Da,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return o},get pre(){return u},get code(){return d},get lines(){return f}};if(e.forEach((e,t)=>{t&&(s===`inline`?o.children.push({type:`element`,tagName:`br`,properties:{},children:[]}):s===`classic`&&a.push({type:`text`,value:`
23
+ `}));let n={type:`element`,tagName:`span`,properties:{class:`line`},children:[]},r=0;for(let a of e){let e={type:`element`,tagName:`span`,properties:{...a.htmlAttrs},children:[{type:`text`,value:a.content}]},c=Fa(a.htmlStyle||Pa(a));c&&(e.properties.style=c);for(let o of i)e=o?.span?.call(p,e,t+1,r,n,a)||e;s===`inline`?o.children.push(e):s===`classic`&&n.children.push(e),r+=a.content.length}if(s===`classic`){for(let e of i)n=e?.line?.call(p,n,t+1)||n;f.push(n),a.push(n)}else s===`inline`&&f.push(n)}),s===`classic`){for(let e of i)d=e?.code?.call(p,d)||d;u.children.push(d);for(let e of i)u=e?.pre?.call(p,u)||u;o.children.push(u)}else if(s===`inline`){let e=[],t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]};for(let n of o.children)n.type===`element`&&n.tagName===`br`?(e.push(t),t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]}):(n.type===`element`||n.type===`text`)&&t.children.push(n);e.push(t);let n={type:`element`,tagName:`code`,properties:{},children:e};for(let e of i)n=e?.code?.call(p,n)||n;o.children=[];for(let e=0;e<n.children.length;e++){e>0&&o.children.push({type:`element`,tagName:`br`,properties:{},children:[]});let t=n.children[e];t.type===`element`&&o.children.push(...t.children)}}let m=o;for(let e of i)m=e?.root?.call(p,m)||m;return r&&mr(m,r),m}function so(e){return e.map(e=>{let t=[],n=``,r;return e.forEach((i,a)=>{let o=!(i.fontStyle&&(i.fontStyle&N.Underline||i.fontStyle&N.Strikethrough));o&&ro.test(i.content)&&e[a+1]?(r===void 0&&(r=i.offset),n+=i.content):n?(o?t.push({...i,offset:r,content:n+i.content}):t.push({content:n,offset:r},i),r=void 0,n=``):t.push(i)}),t})}function co(e){return e.map(e=>e.flatMap(e=>{if(ro.test(e.content))return e;let t=e.content.match(io);if(!t)return e;let[,n,r,i]=t;if(!n&&!i)return e;let a=[{...e,offset:e.offset+n.length,content:r}];return n&&a.unshift({content:n,offset:e.offset}),i&&a.push({content:i,offset:e.offset+n.length+r.length}),a}))}function lo(e){return e.map(e=>{let t=[];for(let n of e){if(t.length===0){t.push({...n});continue}let e=t.at(-1),r=Fa(e.htmlStyle||Pa(e)),i=Fa(n.htmlStyle||Pa(n)),a=e.fontStyle&&(e.fontStyle&N.Underline||e.fontStyle&N.Strikethrough),o=n.fontStyle&&(n.fontStyle&N.Underline||n.fontStyle&N.Strikethrough);!a&&!o&&r===i?e.content+=n.content:t.push({...n})}return t})}var uo=Ca;function fo(e,t,n){let r={meta:{},options:n,codeToHast:(t,n)=>ao(e,t,n),codeToTokens:(t,n)=>to(e,t,n)},i=uo(ao(e,t,n,r));for(let e of Ba(n))i=e.postprocess?.call(r,i,n)||i;return i}async function po(e){let t=await fr(e);return{getLastGrammarState:(...e)=>xr(t,...e),codeToTokensBase:(e,n)=>eo(t,e,n),codeToTokensWithThemes:(e,n)=>kr(t,e,n),codeToTokens:(e,n)=>to(t,e,n),codeToHast:(e,n)=>ao(t,e,n),codeToHtml:(e,n)=>fo(t,e,n),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}var mo=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function ho(){return 2147483648}function go(){return typeof performance<`u`?performance.now():Date.now()}var _o=(e,t)=>e+(t-e%t)%t;async function vo(e){let t,n,r={};function i(e){n=e,r.HEAPU8=new Uint8Array(e),r.HEAPU32=new Uint32Array(e)}function a(e,t,n){r.HEAPU8.copyWithin(e,t,t+n)}function o(e){try{return t.grow(e-n.byteLength+65535>>>16),i(t.buffer),1}catch{}}function s(e){let t=r.HEAPU8.length;e>>>=0;let n=ho();if(e>n)return!1;for(let r=1;r<=4;r*=2){let i=t*(1+.2/r);if(i=Math.min(i,e+100663296),o(Math.min(n,_o(Math.max(e,i),65536))))return!0}return!1}let c=typeof TextDecoder<`u`?new TextDecoder(`utf8`):void 0;function l(e,t,n=1024){let r=t+n,i=t;for(;e[i]&&!(i>=r);)++i;if(i-t>16&&e.buffer&&c)return c.decode(e.subarray(t,i));let a=``;for(;t<i;){let n=e[t++];if(!(n&128)){a+=String.fromCharCode(n);continue}let r=e[t++]&63;if((n&224)==192){a+=String.fromCharCode((n&31)<<6|r);continue}let i=e[t++]&63;if(n=(n&240)==224?(n&15)<<12|r<<6|i:(n&7)<<18|r<<12|i<<6|e[t++]&63,n<65536)a+=String.fromCharCode(n);else{let e=n-65536;a+=String.fromCharCode(55296|e>>10,56320|e&1023)}}return a}function u(e,t){return e?l(r.HEAPU8,e,t):``}let d={emscripten_get_now:go,emscripten_memcpy_big:a,emscripten_resize_heap:s,fd_write:()=>0};async function f(){let n=await e({env:d,wasi_snapshot_preview1:d});t=n.memory,i(t.buffer),Object.assign(r,n),r.UTF8ToString=u}return await f(),r}var yo=Object.defineProperty,bo=(e,t,n)=>t in e?yo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Q=(e,t,n)=>bo(e,typeof t==`symbol`?t:t+``,n),$=null;function xo(e){throw new mo(e.UTF8ToString(e.getLastOnigError()))}var So=class e{constructor(t){Q(this,`utf16Length`),Q(this,`utf8Length`),Q(this,`utf16Value`),Q(this,`utf8Value`),Q(this,`utf16OffsetToUtf8`),Q(this,`utf8OffsetToUtf16`);let n=t.length,r=e._utf8ByteLength(t),i=r!==n,a=i?new Uint32Array(n+1):null;i&&(a[n]=r);let o=i?new Uint32Array(r+1):null;i&&(o[r]=n);let s=new Uint8Array(r),c=0;for(let e=0;e<n;e++){let r=t.charCodeAt(e),l=r,u=!1;if(r>=55296&&r<=56319&&e+1<n){let n=t.charCodeAt(e+1);n>=56320&&n<=57343&&(l=(r-55296<<10)+65536|n-56320,u=!0)}i&&(a[e]=c,u&&(a[e+1]=c),l<=127?o[c+0]=e:l<=2047?(o[c+0]=e,o[c+1]=e):l<=65535?(o[c+0]=e,o[c+1]=e,o[c+2]=e):(o[c+0]=e,o[c+1]=e,o[c+2]=e,o[c+3]=e)),l<=127?s[c++]=l:l<=2047?(s[c++]=192|(l&1984)>>>6,s[c++]=128|(l&63)>>>0):l<=65535?(s[c++]=224|(l&61440)>>>12,s[c++]=128|(l&4032)>>>6,s[c++]=128|(l&63)>>>0):(s[c++]=240|(l&1835008)>>>18,s[c++]=128|(l&258048)>>>12,s[c++]=128|(l&4032)>>>6,s[c++]=128|(l&63)>>>0),u&&e++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=s,this.utf16OffsetToUtf8=a,this.utf8OffsetToUtf16=o}static _utf8ByteLength(e){let t=0;for(let n=0,r=e.length;n<r;n++){let i=e.charCodeAt(n),a=i,o=!1;if(i>=55296&&i<=56319&&n+1<r){let t=e.charCodeAt(n+1);t>=56320&&t<=57343&&(a=(i-55296<<10)+65536|t-56320,o=!0)}t+=a<=127?1:a<=2047?2:a<=65535?3:4,o&&n++}return t}createString(e){let t=e.omalloc(this.utf8Length);return e.HEAPU8.set(this.utf8Value,t),t}},Co=class e{constructor(t){if(Q(this,`id`,++e.LAST_ID),Q(this,`_onigBinding`),Q(this,`content`),Q(this,`utf16Length`),Q(this,`utf8Length`),Q(this,`utf16OffsetToUtf8`),Q(this,`utf8OffsetToUtf16`),Q(this,`ptr`),!$)throw new mo(`Must invoke loadWasm first.`);this._onigBinding=$,this.content=t;let n=new So(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!e._sharedPtrInUse?(e._sharedPtr||=$.omalloc(1e4),e._sharedPtrInUse=!0,$.HEAPU8.set(n.utf8Value,e._sharedPtr),this.ptr=e._sharedPtr):this.ptr=n.createString($)}convertUtf8OffsetToUtf16(e){return this.utf8OffsetToUtf16?e<0?0:e>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[e]:e}convertUtf16OffsetToUtf8(e){return this.utf16OffsetToUtf8?e<0?0:e>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[e]:e}dispose(){this.ptr===e._sharedPtr?e._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};Q(Co,`LAST_ID`,0),Q(Co,`_sharedPtr`,0),Q(Co,`_sharedPtrInUse`,!1);var wo=Co,To=class{constructor(e){if(Q(this,`_onigBinding`),Q(this,`_ptr`),!$)throw new mo(`Must invoke loadWasm first.`);let t=[],n=[];for(let r=0,i=e.length;r<i;r++){let i=new So(e[r]);t[r]=i.createString($),n[r]=i.utf8Length}let r=$.omalloc(4*e.length);$.HEAPU32.set(t,r/4);let i=$.omalloc(4*e.length);$.HEAPU32.set(n,i/4);let a=$.createOnigScanner(r,i,e.length);for(let n=0,r=e.length;n<r;n++)$.ofree(t[n]);$.ofree(i),$.ofree(r),a===0&&xo($),this._onigBinding=$,this._ptr=a}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(e,t,n){let r=0;if(typeof n==`number`&&(r=n),typeof e==`string`){e=new wo(e);let n=this._findNextMatchSync(e,t,!1,r);return e.dispose(),n}return this._findNextMatchSync(e,t,!1,r)}_findNextMatchSync(e,t,n,r){let i=this._onigBinding,a=i.findNextOnigScannerMatch(this._ptr,e.id,e.ptr,e.utf8Length,e.convertUtf16OffsetToUtf8(t),r);if(a===0)return null;let o=i.HEAPU32,s=a/4,c=o[s++],l=o[s++],u=[];for(let t=0;t<l;t++){let n=e.convertUtf8OffsetToUtf16(o[s++]),r=e.convertUtf8OffsetToUtf16(o[s++]);u[t]={start:n,end:r,length:r-n}}return{index:c,captureIndices:u}}};function Eo(e){return typeof e.instantiator==`function`}function Do(e){return typeof e.default==`function`}function Oo(e){return e.data!==void 0}function ko(e){return typeof Response<`u`&&e instanceof Response}function Ao(e){return typeof ArrayBuffer<`u`&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<`u`&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||typeof Uint32Array<`u`&&e instanceof Uint32Array}var jo;function Mo(e){if(jo)return jo;async function t(){$=await vo(async t=>{let n=e;return n=await n,typeof n==`function`&&(n=await n(t)),typeof n==`function`&&(n=await n(t)),Eo(n)?n=await n.instantiator(t):Do(n)?n=await n.default(t):(Oo(n)&&(n=n.data),ko(n)?n=typeof WebAssembly.instantiateStreaming==`function`?await Po(n)(t):await Fo(n)(t):Ao(n)||n instanceof WebAssembly.Module?n=await No(n)(t):`default`in n&&n.default instanceof WebAssembly.Module&&(n=await No(n.default)(t))),`instance`in n&&(n=n.instance),`exports`in n&&(n=n.exports),n})}return jo=t(),jo}function No(e){return t=>WebAssembly.instantiate(e,t)}function Po(e){return t=>WebAssembly.instantiateStreaming(e,t)}function Fo(e){return async t=>{let n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}async function Io(e){return e&&await Mo(e),{createScanner(e){return new To(e.map(e=>typeof e==`string`?e:e.source))},createString(e){return new wo(e)}}}function Lo(){return r.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`)}var Ro=[`kdiagram`,`model`,`view`,`include`,`exclude`,`direction`,`density`,`group`,`boundary`,`zone`,`swimlane`,`database`,`layout`,`edges`,`style`,`render`,`presentation`,`is`,`for`,`edge`,`svg`,`as`],zo=[`dim`,`activate`,`pulse`,`flow`,`wait`,`loop`],Bo=`activate.deactivate.create.destroy.note.autonumber.alt.alternate.else.otherwise.opt.optional.loop.par.parallel.and.also.critical.break.section.box.divider.over.left.right.of`.split(`.`),Vo=[...i].map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)),Ho=`LR.RL.TD.BT.TB.down.right.true.false.compact.normal.spacious.flat.compound.auto.straight.balanced.basic.metro.rounded.orthogonal.bezier.jumps.smart.gap.gaps.none.tight.wide.on.off.high.low.yes.no.dark.light.pack.stack.flow.row.grid.stretch.start.middle.end.begin.center.target.source`.split(`.`),Uo=[`PK`,`FK`,`UK`,`NN`,`PRIMARY`,`FOREIGN`,`UNIQUE`,`NOTNULL`,`NOT_NULL`],Wo=`uuid.text.int.integer.bigint.smallint.bool.boolean.real.float.double.numeric.decimal.money.date.time.timestamp.timestamptz.timetz.json.jsonb.bytea.blob.varchar.char.serial.bigserial`.split(`.`),Go=`(${Lo().replace(/\|--$/,`|--(?![A-Za-z0-9_-])`)})`,Ko=Vo.join(`|`),qo=Ho.join(`|`),Jo=zo.join(`|`),Yo={name:`kdiagram`,scopeName:`source.kdiagram`,aliases:[`fm`],patterns:[{include:`#comments`},{include:`#diagram-header`},{include:`#sequence-block`},{include:`#animation-block`},{include:`#columns-block`},{include:`#strings`},{include:`#operators`},{include:`#properties`},{include:`#keywords`},{include:`#kinds`},{include:`#column-flags`},{include:`#atoms`},{include:`#direction-atoms`},{include:`#numbers`},{include:`#colors`},{include:`#punctuation`}],repository:{comments:{patterns:[{name:`comment.line.double-slash.kdiagram`,match:`//.*$`},{name:`comment.block.kdiagram`,begin:`/\\*`,end:`\\*/`}]},"diagram-header":{name:`meta.diagram.kdiagram`,begin:`\\b(diagram|state|model)\\b`,end:`(?=\\{)|$`,beginCaptures:{0:{name:`keyword.control.kdiagram`}},patterns:[{include:`#strings`}]},"sequence-block":{name:`meta.sequence.kdiagram`,begin:`(\\bsequence\\b)(?:\\s+("(?:\\\\.|[^"\\\\])*"))?\\s*(\\{)`,beginCaptures:{1:{name:`keyword.control.kdiagram`},2:{name:`string.quoted.double.kdiagram`},3:{name:`punctuation.kdiagram`}},end:`\\}`,endCaptures:{0:{name:`punctuation.kdiagram`}},patterns:[{include:`#comments`},{include:`#animation-block`},{include:`#strings`},{include:`#operators`},{include:`#sequence-keywords`},{include:`#properties`},{include:`#keywords`},{include:`#kinds`},{include:`#atoms`},{include:`#numbers`},{include:`#punctuation`}]},"sequence-keywords":{name:`keyword.control.kdiagram`,match:`\\b(${Bo.join(`|`)})\\b`},"animation-block":{name:`meta.animation.kdiagram`,begin:`(\\banimation\\b)(?:\\s+("(?:\\\\.|[^"\\\\])*"))?\\s*(\\{)`,beginCaptures:{1:{name:`keyword.control.kdiagram`},2:{name:`string.quoted.double.kdiagram`},3:{name:`punctuation.kdiagram`}},end:`\\}`,endCaptures:{0:{name:`punctuation.kdiagram`}},patterns:[{include:`#comments`},{include:`#strings`},{include:`#operators`},{include:`#animation-parallel`},{include:`#animation-cues`},{include:`#keywords`},{include:`#numbers`},{include:`#punctuation`}]},"animation-parallel":{name:`meta.animation.parallel.kdiagram`,begin:`(\\bparallel\\b)\\s*(\\{)`,beginCaptures:{1:{name:`keyword.control.kdiagram`},2:{name:`punctuation.kdiagram`}},end:`\\}`,endCaptures:{0:{name:`punctuation.kdiagram`}},patterns:[{include:`#comments`},{include:`#strings`},{include:`#operators`},{include:`#animation-cues`},{include:`#keywords`},{include:`#numbers`},{include:`#punctuation`}]},"animation-cues":{name:`keyword.control.kdiagram`,match:`\\b(${Jo})\\b`},"columns-block":{name:`meta.columns.kdiagram`,begin:`\\bcolumns\\b\\s*:?\\s*\\{`,end:`\\}`,beginCaptures:{0:{name:`keyword.control.kdiagram`}},patterns:[{include:`#comments`},{name:`meta.column.definition.kdiagram`,begin:`\\b([A-Za-z_][\\w-]*)\\s*(:)`,end:`(?=//)|$`,beginCaptures:{1:{name:`variable.other.property.kdiagram`},2:{name:`punctuation.separator.key-value.kdiagram`}},patterns:[{include:`#operators`},{include:`#column-flags`},{include:`#sql-types`},{include:`#strings`},{name:`variable.other.column-ref.kdiagram`,match:`\\b[A-Za-z_][\\w-]*(?=\\.[A-Za-z_])`},{name:`variable.other.column-ref.kdiagram`,match:`(?<=\\.)[A-Za-z_][\\w-]*`}]},{include:`#punctuation`}]},strings:{name:`string.quoted.double.kdiagram`,begin:`"`,end:`"`,patterns:[{name:`constant.character.escape.kdiagram`,match:`\\\\.`}]},operators:{name:`keyword.operator.kdiagram`,match:Go},keywords:{name:`keyword.control.kdiagram`,match:`\\b(${Ro.join(`|`)})\\b`},kinds:{name:`entity.name.type.kdiagram`,match:`(?<=:)\\s*(${Ko})\\b`},"column-flags":{name:`constant.language.constraint.kdiagram`,match:`\\b(${Uo.join(`|`)})\\b`},"sql-types":{name:`storage.type.kdiagram`,match:`\\b(${Wo.join(`|`)})\\b`},atoms:{name:`constant.language.kdiagram`,match:`(?<=:)\\s*(${qo})\\b`},"direction-atoms":{name:`constant.language.kdiagram`,match:`(?<=\\b(?:direction|density)\\s+)(${qo})\\b`},properties:{name:`variable.other.property.kdiagram`,match:`(?:--[a-zA-Z_][\\w-]*|\\b[a-zA-Z_][\\w-]*)(?=\\s*:)`},numbers:{name:`constant.numeric.kdiagram`,match:`\\b\\d+(\\.\\d+)?(?:ms|s)?\\b`},colors:{name:`constant.other.color.kdiagram`,match:`#[0-9a-fA-F]{3}(?:[0-9a-fA-F]{5}|[0-9a-fA-F]{3}|[0-9a-fA-F])?\\b`},punctuation:{name:`punctuation.kdiagram`,match:`[{}()\\[\\];,*]`}}};[...r];var Xo=`kdiagram`,Zo=`github-dark`,Qo=`github-light`,$o=null;function es(){return $o||=(async()=>{await n(()=>import(`./monaco-features-BReLWANr.js`),__vite__mapDeps([0,1,2]),import.meta.url);let e=await n(()=>import(`./editor.api-Cj6q1WDf.js`),__vite__mapDeps([0,1,3]),import.meta.url);Re.config({monaco:e});let t=await Re.init(),r=await po({themes:[n(()=>import(`./github-dark-C-LZuMrd.js`).then(e=>e.default),[],import.meta.url),n(()=>import(`./github-light-EUqPIrTm.js`).then(e=>e.default),[],import.meta.url)],langs:[Yo],engine:Io(n(()=>import(`./wasm-BnjxR4X6.js`),[],import.meta.url))});return t.languages.register({id:Xo,aliases:[`fm`,`KDiagram`],extensions:[`.kdiagram`,`.fm`]}),t.languages.setLanguageConfiguration(Xo,{comments:{lineComment:`//`,blockComment:[`/*`,`*/`]},brackets:[[`{`,`}`],[`[`,`]`],[`(`,`)`]],autoClosingPairs:[{open:`{`,close:`}`},{open:`[`,close:`]`},{open:`(`,close:`)`},{open:`"`,close:`"`}],surroundingPairs:[{open:`{`,close:`}`},{open:`[`,close:`]`},{open:`(`,close:`)`},{open:`"`,close:`"`}]}),Vn(r,t),t})(),$o}var ts=a();function ns({value:e,onChange:t,themeMode:r,revealRange:i}){let[a,o]=(0,s.useState)(!1),c=(0,s.useRef)(null),l=(0,s.useRef)(null);return(0,s.useEffect)(()=>{let e=!1;return es().then(()=>{e||o(!0)}),()=>{e=!0,c.current?.dispose()}},[]),(0,s.useEffect)(()=>{let e=l.current;if(!e||!i)return;let{range:t}=i,n={startLineNumber:t.start.line,startColumn:t.start.column,endLineNumber:t.end.line,endColumn:Math.max(t.end.column,t.start.column+1)};e.setSelection(n),e.revealRangeInCenter(n),e.focus()},[i]),(0,ts.jsx)(`div`,{className:`source-editor-host`,"data-editor-theme":r,children:a?(0,ts.jsx)(nt,{value:e,language:Xo,theme:r===`dark`?Zo:Qo,onMount:(e,t)=>{l.current=e;let r=e.getModel();r&&n(async()=>{let{installKDiagramLanguage:e}=await import(`./language-jwV6PbsO.js`);return{installKDiagramLanguage:e}},__vite__mapDeps([0]),import.meta.url).then(({installKDiagramLanguage:e})=>{r.isDisposed()||(c.current?.dispose(),c.current=e(t,r))})},onChange:e=>t(e??``),height:`100%`,options:{fontFamily:`var(--font-mono), ui-monospace, monospace`,fontSize:13,lineHeight:20,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:`on`,automaticLayout:!0,tabSize:2,renderLineHighlight:`line`,padding:{top:12,bottom:12},folding:!0,glyphMargin:!1,overviewRulerLanes:0,hideCursorInOverviewRuler:!0,overviewRulerBorder:!1,scrollbar:{verticalScrollbarSize:10,horizontalScrollbarSize:10}},loading:(0,ts.jsx)(`div`,{className:`source-editor-loading`,children:`Loading editor…`})}):(0,ts.jsx)(`div`,{className:`source-editor-loading`,children:`Loading editor…`})})}export{ns as SourceEditor};