@kong-ui-public/monaco-editor 0.25.4-pr.3248.33ec9c8e1.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,16 +7,32 @@ A kong UI Monaco Editor wrapper for Vue 3 with syntax highlighting powered by Sh
7
7
  - [Usage](#usage)
8
8
  - [Install](#install)
9
9
  - [Register](#register)
10
- - [MonacoEditor Component](#monacoeditor-component)
11
- - [Props](#props)
12
- - [v-model](#v-model)
13
- - [Slots](#slots)
14
- - [Usage Example](#usage-example)
15
- - [MonacoEditorStatusOverlay Component](#monacoeditorstatusoverlay-component)
16
- - [Props](#props-1)
17
- - [Usage Example](#usage-example-1)
18
- - [useMonacoEditor Composable](#usemonacoeditor-composable)
19
- - [Vite Plugin](#vite-plugin)
10
+ - [MonacoEditor Component](#monacoeditor-component)
11
+ - [Props](#props)
12
+ - [Events](#events)
13
+ - [v-model](#v-model)
14
+ - [Slots](#slots)
15
+ - [Usage Example](#usage-example)
16
+ - [MonacoDiffEditor Component](#monacodiffeditor-component)
17
+ - [Props](#props-1)
18
+ - [Events](#events-1)
19
+ - [Slots](#slots-1)
20
+ - [Usage Example](#usage-example-1)
21
+ - [MonacoEditorStatusOverlay Component](#monacoeditorstatusoverlay-component)
22
+ - [Props](#props-2)
23
+ - [Usage Example](#usage-example-2)
24
+ - [useMonacoEditor Composable](#usemonacoeditor-composable)
25
+ - [Editor States](#editor-states)
26
+ - [Example with Custom Actions](#example-with-custom-actions)
27
+ - [Example with Keyboard Commands](#example-with-keyboard-commands)
28
+ - [useMonacoDiffEditor Composable](#usemonacodiffeditor-composable)
29
+ - [Vite Plugin](#vite-plugin)
30
+ - [API Reference](#api-reference)
31
+ - [Exported Components](#exported-components)
32
+ - [Exported Composables](#exported-composables)
33
+ - [Common Monaco Commands](#common-monaco-commands)
34
+ - [Quick Reference: Toolbar Configuration](#quick-reference-toolbar-configuration)
35
+ - [Tips \& Best Practices](#tips--best-practices)
20
36
 
21
37
  ## Features
22
38
 
@@ -32,6 +48,7 @@ A kong UI Monaco Editor wrapper for Vue 3 with syntax highlighting powered by Sh
32
48
  - Loading and empty states with customizable slots
33
49
  - Composable API for advanced use cases
34
50
  - Vite plugin for optimized builds
51
+ - Read-only, inline (unified) diff view via `MonacoDiffEditor`
35
52
 
36
53
  ## Requirements
37
54
 
@@ -548,6 +565,136 @@ const isDark = ref(false)
548
565
  </style>
549
566
  ```
550
567
 
568
+ ## MonacoDiffEditor Component
569
+
570
+ Renders Monaco's inline diff view - the original and modified content in a single column, with red/green line markers - styled with Kong design tokens. This component is a diff **viewer**, not an editable comparison tool.
571
+
572
+ ### Props
573
+
574
+ #### `original`
575
+
576
+ - type: `string`
577
+ - required: `true`
578
+
579
+ The original content shown in the diff. An empty string (`original=""`) is valid and diffs against "everything is new" - only `undefined` is not accepted, since the prop is required.
580
+
581
+ #### `modified`
582
+
583
+ - type: `string`
584
+ - required: `true`
585
+
586
+ The modified content shown in the diff.
587
+
588
+ #### `appearance`
589
+
590
+ - type: `'embedded' | 'standalone'`
591
+ - required: `false`
592
+ - default: `'embedded'`
593
+
594
+ Same meaning as [`MonacoEditor`'s `appearance` prop](#appearance).
595
+
596
+ #### `theme`
597
+
598
+ - type: `'light' | 'dark'`
599
+ - required: `false`
600
+ - default: `'light'`
601
+
602
+ The theme of the diff editor instance.
603
+
604
+ > [!NOTE]
605
+ > Monaco's standalone theme is a **global**, page-wide setting. If a `MonacoEditor` and a `MonacoDiffEditor` with different `theme` values are both mounted, whichever is created last wins. Force a remount on theme changes with `:key`, the same way the existing `MonacoEditor` consumers in this repo do (`:key="activeColorMode"`).
606
+
607
+ #### `language`
608
+
609
+ - type: `string`
610
+ - required: `false`
611
+ - default: `'markdown'`
612
+
613
+ The programming language for syntax highlighting, applied to both sides.
614
+
615
+ #### `options`
616
+
617
+ - type: `Partial<editor.IStandaloneDiffEditorConstructionOptions>`
618
+ - required: `false`
619
+ - default: `undefined`
620
+
621
+ Additional Monaco diff editor options. See [Monaco's diff editor options](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IDiffEditorBaseOptions.html) for the full list. Notable defaults set by this component:
622
+
623
+ | Option | Default | Notes |
624
+ | --- | --- | --- |
625
+ | `renderSideBySide` | `false` | The inline/unified view. Pass `true` to opt into Monaco's default side-by-side view instead. |
626
+ | `readOnly` | `true` | Both sides are read-only. |
627
+ | `ignoreTrimWhitespace` | `false` | Monaco's own default is `true`, which silently hides whitespace-only changes. |
628
+ | `renderIndicators` | `true` | The `+`/`-` gutter glyphs. |
629
+ | `renderOverviewRuler` | `false` | Monaco's diff overview ruler paints from its **theme colours directly to a canvas** - it cannot be restyled with the `--vscode-*` CSS variables this package uses elsewhere, so it is disabled by default rather than shown in the wrong palette. |
630
+ | `renderGutterMenu` | `false` | The hunk/revert menu - out of scope for a read-only viewer. |
631
+ | `diffCodeLens` | `false` | Monaco's own default. See the warning below. |
632
+
633
+ > [!WARNING]
634
+ > Code lenses are disabled inside a diff editor unless you explicitly pass `options: { diffCodeLens: true }`. This means this package's own code lens providers (`collectCodeLensProviders`, etc.) render nothing when registered against a `MonacoDiffEditor`'s models.
635
+
636
+ #### `loading`
637
+
638
+ - type: `boolean`
639
+ - required: `false`
640
+ - default: `false`
641
+
642
+ Same meaning as [`MonacoEditor`'s `loading` prop](#loading).
643
+
644
+ #### `showLoadingState`
645
+
646
+ - type: `boolean`
647
+ - required: `false`
648
+ - default: `true`
649
+
650
+ Controls whether the loading state overlay is rendered.
651
+
652
+ ### Events
653
+
654
+ #### `ready`
655
+
656
+ Emitted when the Monaco diff editor instance has finished initializing.
657
+
658
+ **Payload:**
659
+
660
+ - `diffEditor`: The Monaco `IStandaloneDiffEditor` instance. Use `diffEditor.getOriginalEditor()` / `diffEditor.getModifiedEditor()` to reach either side's `IStandaloneCodeEditor`, or `diffEditor.goToDiff('next' | 'previous')` / `diffEditor.onDidUpdateDiff` / `diffEditor.getLineChanges()` to build custom diff navigation - there is no built-in next/previous change control in this release.
661
+
662
+ ### Slots
663
+
664
+ #### `state-loading`
665
+
666
+ Slot for customizing the loading state overlay. Receives `isLoading` as a slot prop. See [`MonacoEditor`'s `state-loading` slot](#state-loading) for the same pattern.
667
+
668
+ ### Usage Example
669
+
670
+ ```vue
671
+ <template>
672
+ <div class="diff-wrapper">
673
+ <MonacoDiffEditor
674
+ :original="deployedConfig"
675
+ :modified="pendingConfig"
676
+ language="yaml"
677
+ appearance="standalone"
678
+ />
679
+ </div>
680
+ </template>
681
+
682
+ <script setup lang="ts">
683
+ import { ref } from 'vue'
684
+ import { MonacoDiffEditor } from '@kong-ui-public/monaco-editor'
685
+
686
+ const deployedConfig = ref('name: my-service\nversion: 1.0.0\n')
687
+ const pendingConfig = ref('name: my-service\nversion: 1.1.0\n')
688
+ </script>
689
+
690
+ <style scoped>
691
+ .diff-wrapper {
692
+ height: 500px;
693
+ width: 100%;
694
+ }
695
+ </style>
696
+ ```
697
+
551
698
  ## MonacoEditorStatusOverlay Component
552
699
 
553
700
  The `MonacoEditorStatusOverlay` component displays a centered overlay message within the Monaco Editor, typically used for status messages like loading, empty states, or error messages.
@@ -769,6 +916,39 @@ function showSearchWidget() {
769
916
  }
770
917
  ```
771
918
 
919
+ ## useMonacoDiffEditor Composable
920
+
921
+ For advanced use cases, you can use the `useMonacoDiffEditor` composable directly. It returns a smaller surface than `useMonacoEditor`, as read-only:
922
+
923
+ ```typescript
924
+ import { ref } from 'vue'
925
+ import { useMonacoDiffEditor } from '@kong-ui-public/monaco-editor'
926
+
927
+ const editorRef = ref<HTMLElement | null>(null)
928
+ const originalRef = ref('name: my-service\nversion: 1.0.0\n')
929
+ const modifiedRef = ref('name: my-service\nversion: 1.1.0\n')
930
+
931
+ const monacoDiffEditor = useMonacoDiffEditor(editorRef, {
932
+ language: 'yaml',
933
+ original: originalRef,
934
+ modified: modifiedRef,
935
+ theme: 'light',
936
+ })
937
+
938
+ // Access editor states
939
+ console.log(monacoDiffEditor.editorStates.currentLanguage) // e.g. 'yaml'
940
+
941
+ // Access diff editor methods
942
+ monacoDiffEditor.setLanguage('json')
943
+
944
+ // Diff navigation and change detection are not wrapped by this composable -
945
+ // reach for the underlying Monaco API via the exposed `diffEditor` ref instead
946
+ monacoDiffEditor.diffEditor.value?.goToDiff('next')
947
+ monacoDiffEditor.diffEditor.value?.onDidUpdateDiff(() => {
948
+ console.log(monacoDiffEditor.diffEditor.value?.getLineChanges())
949
+ })
950
+ ```
951
+
772
952
  ## Vite Plugin
773
953
 
774
954
  This package includes a Vite plugin for optimized builds. The plugin reduces bundle size by allowing you to selectively include only the languages and features you need.
@@ -800,6 +980,7 @@ For more details on configuration options, see the [Vite Plugin README](https://
800
980
  ```typescript
801
981
  import {
802
982
  MonacoEditor, // Main editor component
983
+ MonacoDiffEditor, // Read-only, inline diff viewer component
803
984
  MonacoEditorStatusOverlay, // Status overlay component for loading/empty states
804
985
  } from '@kong-ui-public/monaco-editor'
805
986
  ```
@@ -809,6 +990,7 @@ import {
809
990
  ```typescript
810
991
  import {
811
992
  useMonacoEditor, // Core editor composable
993
+ useMonacoDiffEditor, // Core diff editor composable
812
994
  } from '@kong-ui-public/monaco-editor'
813
995
  ```
814
996
 
@@ -1,13 +1,15 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),S=require("@kong/icons"),M=require("monaco-editor"),re=require("@shikijs/monaco"),U=require("shiki"),q=require("@kong-ui-public/i18n"),R=require("./code-lenses-Dix-b7XA.cjs"),J=require("./singletons.cjs.js");function ae(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>t[n]})}}return r.default=t,Object.freeze(r)}const N=ae(M),ie="'JetBrains Mono', Consolas, monospace",le="12px",se="500",ce="20px",de="8px",W=Object.freeze({autoClosingQuotes:"always",automaticLayout:!0,bracketPairColorization:{enabled:!0},hideCursorInOverviewRuler:!0,fontFamily:ie,fontSize:Number(le.replace("px","")),fontWeight:se,lineHeight:Number(ce.replace("px","")),formatOnPaste:!0,formatOnType:!0,padding:{top:0,bottom:0},lineNumbersMinChars:3,minimap:{enabled:!1},stickyScroll:{enabled:!0},suggest:{showWords:!1},quickSuggestions:!0,suggestOnTriggerCharacters:!0,wordBasedSuggestions:"off",overviewRulerLanes:0,renderWhitespace:"boundary",scrollBeyondLastLine:!1,roundedSelection:!1,wordWrapColumn:120,colorDecorators:!0,folding:!0,fixedOverflowWidgets:!0,tabSize:2,detectIndentation:!1,insertSpaces:!0,trimAutoWhitespace:!0,wordWrap:"bounded",find:{addExtraSpaceOnTop:!1}}),H={command:M.KeyMod.CtrlCmd,cmd:M.KeyMod.CtrlCmd,ctrl:M.KeyMod.CtrlCmd,ctrlcmd:M.KeyMod.CtrlCmd,shift:M.KeyMod.Shift,alt:M.KeyMod.Alt,option:M.KeyMod.Alt,win:M.KeyMod.WinCtrl,meta:M.KeyMod.WinCtrl},ue={enter:"Enter",esc:"Escape",escape:"Escape",space:"Space",tab:"Tab",backspace:"Backspace",delete:"Delete",insert:"Insert",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown",up:"UpArrow",down:"DownArrow",left:"LeftArrow",right:"RightArrow",arrowup:"UpArrow",arrowdown:"DownArrow",arrowleft:"LeftArrow",arrowright:"RightArrow"};function me(t){if(!t?.length)return;let r=0,n;for(const o of t){const s=o.toLowerCase();if(H[s]){r|=H[s];continue}if(/^f\d+$/.test(s)){n=M.KeyCode[`F${s.slice(1)}`];continue}if(/^[a-z]$/.test(s)){n=M.KeyCode[`Key${s.toUpperCase()}`];continue}if(/^\d$/.test(s)){n=M.KeyCode[`Digit${s}`];continue}const i=ue[s];i&&(n=M.KeyCode[i])}return n!==void 0?r|n:void 0}function P(t,r){if(r){if(typeof t.action=="function")t.action(r);else if(typeof t.action=="string"){const n=t.action,o=r.editor.value?.getAction(n);o?o.run():r.triggerKeyboardCommand(n)}}}const ge=new Set(["markdown","mdc"]),fe=[{detect:/^(\s*)- \[[ x]\] /,nextPrefix:t=>`${t[1]}- [ ] `,emptyItem:/^(\s*)- \[[ x]\] $/},{detect:/^(\s*)([-*+]) /,nextPrefix:t=>`${t[1]}${t[2]} `,emptyItem:/^(\s*)[-*+] $/},{detect:/^(\s*)(\d+)\. /,nextPrefix:t=>`${t[1]}${Number(t[2])+1}. `,emptyItem:/^(\s*)\d+\. $/}];function be(t){return t.addAction({id:"editor.action.listContinuation",label:"Continue List on Enter",keybindings:[M.KeyCode.Enter],precondition:"editorTextFocus && !editorReadonly && !suggestWidgetVisible && !renameInputVisible && !inSnippetMode && !quickFixWidgetVisible",run:r=>{const n=r.getModel(),o=r.getSelection();if(!n||!o||!o.isEmpty()||!ge.has(n.getLanguageId())){r.trigger("listContinuation","type",{text:`
2
- `});return}const s=o.startLineNumber,i=n.getLineContent(s);for(const a of fe){const d=i.match(a.detect);if(!d)continue;if(a.emptyItem.test(i)){r.executeEdits("listContinuation",[{range:{startLineNumber:s,startColumn:1,endLineNumber:s,endColumn:i.length+1},text:""}]);return}const c=a.nextPrefix(d);if(c!==void 0){const u=o.startColumn;r.executeEdits("listContinuation",[{range:{startLineNumber:s,startColumn:u,endLineNumber:s,endColumn:u},text:`
3
- ${c}`}]);const f=s+1,l=c.length+1;r.setPosition({lineNumber:f,column:l}),r.revealLine(f);return}}r.trigger("listContinuation","type",{text:`
4
- `})}})}function pe(t,r){return e.getCurrentScope()?(e.onScopeDispose(t,r),!0):!1}const he=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const O=()=>{};function Ce(t,r){function n(...o){return new Promise((s,i)=>{Promise.resolve(t(()=>r.apply(this,o),{fn:r,thisArg:this,args:o})).then(s).catch(i)})}return"cancel"in t&&Object.assign(n,{cancel:t.cancel,flush:t.flush,isPending:t.isPending}),n}function ve(t,r={}){let n,o,s=O,i=O;const a=e.shallowRef(!1),d=f=>{clearTimeout(f),s(),s=O};let c;return Object.assign(f=>{const l=e.toValue(t),b=e.toValue(r.maxWait);return n&&d(n),l<=0||b!==void 0&&b<=0?(o&&(d(o),o=void 0),a.value=!1,Promise.resolve(f())):(a.value=!0,new Promise((m,g)=>{s=r.rejectOnCancel?g:m,i=m,c=f,b&&!o&&(o=setTimeout(()=>{n&&d(n),o=void 0,a.value=!1,m(c())},b)),n=setTimeout(()=>{o&&d(o),o=void 0,a.value=!1,m(f())},l)}))},{cancel:()=>{n&&(d(n),n=void 0),o&&(d(o),o=void 0),a.value=!1,i=O},flush:()=>{if(a.value){n&&(clearTimeout(n),n=void 0),o&&(clearTimeout(o),o=void 0),a.value=!1;const f=i;s=O,i=O,f(c())}},isPending:e.shallowReadonly(a)})}function ye(t){return Array.isArray(t)?t:[t]}function ke(t){return e.getCurrentInstance()}function Le(t,r=200,n={}){return Ce(ve(r,n),t)}function xe(t,r=!0,n){ke()?e.onMounted(t,n):r?t():e.nextTick(t)}const Q=he?window:void 0;function T(t){var r;const n=e.toValue(t);return(r=n?.$el)!==null&&r!==void 0?r:n}function we(){const t=e.shallowRef(!1),r=e.getCurrentInstance();return r&&e.onMounted(()=>{t.value=!0},r),t}function Se(t){const r=we();return e.computed(()=>(r.value,!!t()))}function Me(t,r,n={}){const{window:o=Q,...s}=n;let i;const a=Se(()=>o&&"ResizeObserver"in o),d=()=>{i&&(i.disconnect(),i=void 0)},c=e.watch(e.computed(()=>{const f=e.toValue(t);return Array.isArray(f)?f.map(l=>T(l)):[T(f)]}),f=>{if(d(),a.value&&o){i=new ResizeObserver(r);for(const l of f)l&&i.observe(l,s)}},{immediate:!0,flush:"post"}),u=()=>{d(),c()};return pe(u),{isSupported:a,stop:u}}function D(t,r={width:0,height:0},n={}){const{window:o=Q,box:s="content-box"}=n,i=e.computed(()=>{var l;return(l=T(t))===null||l===void 0||(l=l.namespaceURI)===null||l===void 0?void 0:l.includes("svg")}),a=e.shallowRef(r.width),d=e.shallowRef(r.height),{stop:c}=Me(t,([l])=>{const b=s==="border-box"?l.borderBoxSize:s==="content-box"?l.contentBoxSize:l.devicePixelContentBoxSize;if(o&&i.value){const m=T(t);if(m){const g=m.getBoundingClientRect();a.value=g.width,d.value=g.height}}else if(b){const m=ye(b);a.value=m.reduce((g,{inlineSize:C})=>g+C,0),d.value=m.reduce((g,{blockSize:C})=>g+C,0)}else a.value=l.contentRect.width,d.value=l.contentRect.height},n);xe(()=>{const l=T(t);if(l&&"offsetWidth"in l)if(s==="content-box"&&o){const b=o.getComputedStyle(l),m=Number.parseFloat(b.paddingLeft)+Number.parseFloat(b.paddingRight),g=Number.parseFloat(b.paddingTop)+Number.parseFloat(b.paddingBottom),C=Number.parseFloat(b.borderLeftWidth)+Number.parseFloat(b.borderRightWidth),h=Number.parseFloat(b.borderTopWidth)+Number.parseFloat(b.borderBottomWidth);a.value=l.offsetWidth-m-C,d.value=l.offsetHeight-g-h}else a.value=l.offsetWidth,d.value=l.offsetHeight;else l&&(a.value=r.width,d.value=r.height)});const u=e.watch(()=>T(t),l=>{a.value=l?r.width:0,d.value=l?r.height:0});function f(){c(),u()}return{width:a,height:d,stop:f}}const ee=e.ref(!1);let _=null;async function Ie(){return _||(_=(async()=>{try{(N.json?.jsonDefaults||N.languages.json?.jsonDefaults)?.setModeConfiguration({tokens:!1});const r=await U.getSingletonHighlighter({themes:Object.values(U.bundledThemes),langs:Object.values(U.bundledLanguages)});r.getLoadedLanguages().forEach(n=>{N.languages.register({id:n})}),re.shikiToMonaco(r,N),ee.value=!0}catch(t){throw _=null,t}})(),_)}function te(t,r){const n=e.shallowRef();let o,s=!1,i=!1;const a=e.reactive({editorStatus:"loading",searchBoxIsRevealed:!1,hasContent:!1,theme:r.theme||"light",currentLanguage:r.language||"",readOnly:r.readOnly||!1}),d=h=>{!s||!n.value||n.value.setValue(h)},c=h=>n.value?.updateOptions({readOnly:h}),u=()=>n.value?.focus(),f=h=>{const p=n.value?.getModel();p&&N.editor.setModelLanguage(p,h)},l=h=>{try{if(!n.value||!h)return;n.value.focus(),n.value.trigger("keyboard",h,null)}catch(p){console.error(`useMonacoEditor: Failed to trigger command: ${h}`,p)}},b=()=>{try{if(!n.value)return;if(a.searchBoxIsRevealed)return n.value.getContribution("editor.contrib.findController")?.closeFindWidget();l("actions.find")}catch(h){console.error("useMonacoEditor: Failed to close findController.",h)}},m=Le(()=>N.editor.remeasureFonts(),200),g=h=>{!n.value||!h?.length||h.forEach(p=>{if(!(!p.id||!p.action))try{const L={id:p.id,label:p.label||p.id,keybindings:p.keybindings?[me(p.keybindings)].filter(x=>x!==void 0):void 0,contextMenuGroupId:p.showInContextMenu?p.contextMenuGroupId||"basic":void 0,contextMenuOrder:p.contextMenuOrder??1.5,run:x=>{if(typeof p.action=="function")p.action({editor:n,editorStates:a,setContent:d,setReadOnly:c,focus:u,setLanguage:f,remeasureFonts:m,toggleSearchWidget:b,triggerKeyboardCommand:l,registerActions:g});else if(typeof p.action=="string"){const v=x.getAction(p.action);v?v.run():l(p.action)}}};n.value?.addAction(L)}catch(L){console.error(`useMonacoEditor: Failed to register action: ${p.id}`,L)}})};return Ie(),e.watch([ee,()=>e.toValue(t)],([h,p],[,L])=>{const x=e.toValue(p),v=e.toValue(L);if(!(x instanceof HTMLElement)||!h){s=!1;return}if(!(s&&v===x)){if(o)o.setValue(r.code.value);else{const y=N.Uri.parse(`inmemory://model/${r.language}-${crypto.randomUUID()}`);o=N.editor.createModel(r.code.value,r.language,y)}n.value=N.editor.create(x,{...W,readOnly:r.readOnly||!1,language:r.language,theme:a.theme==="light"?"catppuccin-latte":"material-theme-darker",model:o,editContext:!1,...r.monacoOptions}),s=!0,a.editorStatus="ready",a.hasContent=!!r.code.value,a.currentLanguage=o.getLanguageId(),a.readOnly=!!n.value.getOption(N.editor.EditorOption.readOnly),o.onDidChangeLanguage(y=>{a.currentLanguage=y.newLanguage}),n.value.onDidChangeConfiguration(y=>{y.hasChanged(N.editor.EditorOption.readOnly)&&(a.readOnly=!!n.value.getOption(N.editor.EditorOption.readOnly))}),n.value.onDidChangeModelContent(()=>{if(i)return;const y=n.value.getValue();a.hasContent=!!y.length,r.code.value=y}),r.actions?.length&&g(r.actions),be(n.value),r.onReady?.(n.value),m();try{const E=n.value.getContribution("editor.contrib.findController")?.getState();E?.onFindReplaceStateChange(()=>{a.searchBoxIsRevealed=E.isRevealed})}catch(y){console.error("useMonacoEditor: Failed to get the state of findController",y)}e.onWatcherCleanup(()=>{n.value?.dispose()})}},{immediate:!0,flush:"post"}),e.watch(r.code,h=>{if(!n.value||!o||!s)return;const p=o.getValue();h!==p&&(i=!0,n.value.executeEdits("external",[{range:o.getFullModelRange(),text:h}]),n.value.pushUndoStop(),a.hasContent=!!h.length,i=!1)}),e.onMounted(m),e.onActivated(m),e.onBeforeUnmount(()=>{if(!n.value)return;const h=n.value.getModel();n.value.dispose(),h&&h.dispose()}),{editor:n,editorStates:a,setContent:d,setReadOnly:c,focus:u,setLanguage:f,remeasureFonts:m,registerActions:g,toggleSearchWidget:b,triggerKeyboardCommand:l}}const Ne={labels:{action_search:"Search",action_bold:"Bold",action_italic:"Italic",action_strikethrough:"Strikethrough",action_inline_code:"Code",action_link:"Link",action_image:"Image",action_unordered_list:"Unordered list",action_ordered_list:"Ordered list",action_task_list:"Task list",action_codeblock:"Code block",action_blockquote:"Blockquote",action_table:"Table",action_search_label:"Search document",action_format:"Format",action_format_label:"Format document",action_fullscreen:"Full Screen",action_fullscreen_label:"Toggle full screen mode",action_more:"More",key:"Key: {key}"},messages:{empty_message:"The editor is currently empty. Start typing to add content.",empty_message_readonly:"The editor is currently empty.",empty_title:"No content available",loading_message:"Please wait while the {type} content is loaded.",loading_title:"{type} editor"}},Ee={editor:Ne};function K(){const t=q.createI18n("en-us",Ee);return{i18n:t,i18nT:q.i18nTComponent(t)}}const Be=e.defineComponent({__name:"MonacoEditorStatusOverlay",props:{title:{},message:{},icon:{}},setup(t){return(r,n)=>{const o=e.resolveComponent("KEmptyState");return e.openBlock(),e.createBlock(o,{class:"monaco-editor-status-overlay",message:t.message,title:t.title},e.createSlots({_:2},[t.icon?{name:"icon",fn:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.icon),{decorative:""}))]),key:"0"}:void 0]),1032,["message","title"])}}}),G=(t,r)=>{const n=t.__vccOpts||t;for(const[o,s]of r)n[o]=s;return n},z=G(Be,[["__scopeId","data-v-062eadb5"]]),Oe={key:0,class:"keys"},Te=["aria-label","data-testid","textContent"],Re=e.defineComponent({__name:"ToolbarActionButton",props:{item:{},active:{type:Boolean,default:!0},placement:{default:"bottom-end"}},setup(t){const{i18n:r}=K(),n=e.computed(()=>!!t.item.keybindings?.length),o=e.ref(!1),s=d=>{const c=d.toLowerCase();return{command:o.value?"Command":"Ctrl",cmd:o.value?"Command":"Ctrl",ctrl:"Ctrl",control:"Ctrl",shift:"Shift",option:o.value?"Option":"Alt",opt:o.value?"Option":"Alt",alt:"Alt"}[c]||d.toUpperCase()},i=d=>["command","cmd","ctrl","control","shift","option","opt","alt"].includes(d.toLowerCase()),a=d=>{const c=d.toLowerCase();return["command","cmd","ctrl","control"].includes(c)?"meta-key":c==="shift"?"shift-key":["option","opt","alt"].includes(c)?"option-key":""};return e.onMounted(()=>{o.value=/Mac|iPhone|iPod|iPad/i.test(navigator?.platform)||/macOS|Mac|iPhone|iPod|iPad/i.test(navigator?.userAgentData?.platform)}),(d,c)=>{const u=e.resolveComponent("KButton"),f=e.resolveComponent("KTooltip");return e.openBlock(),e.createBlock(f,{"data-testid":`editor-toolbar-mdc-action-${t.item.id}-tooltip`,placement:t.placement},e.createSlots({default:e.withCtx(()=>[e.createVNode(u,{appearance:"none","aria-label":t.item.ariaLabel||t.item.label,class:"toolbar-action-button","data-testid":`editor-toolbar-mdc-action-${t.item.id}-button`,disabled:!t.active,icon:"",onClick:t.item.action},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.item.icon),{decorative:""}))]),_:1},8,["aria-label","data-testid","disabled","onClick"])]),_:2},[t.item.label?{name:"content",fn:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["shortcut-text",{"has-keys":n.value}])},e.toDisplayString(t.item.label),3),n.value?(e.openBlock(),e.createElementBlock("div",Oe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.item.keybindings,l=>(e.openBlock(),e.createElementBlock("kbd",{key:l,"aria-label":e.unref(r).t("editor.labels.key",{key:s(l)}),class:e.normalizeClass([{mac:o.value},a(l)]),"data-testid":`editor-toolbar-mdc-${i(l)?a(l):`${l.toLowerCase()}-key`}`,textContent:e.toDisplayString(i(l)?"":l)},null,10,Te))),128))])):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1032,["data-testid","placement"])}}}),V=G(Re,[["__scopeId","data-v-c588b09b"]]);function A(t,r){return n=>{const o=n.editor.value;if(!o)return;const s=o.getSelection(),i=o.getModel();if(!s||!i)return;const a=t.length,d=s.isEmpty(),c=s.startLineNumber,u=s.startColumn,f=s.endLineNumber,l=s.endColumn;if(!d){const L=i.getValueInRange(s),x={startLineNumber:c,startColumn:Math.max(1,u-a),endLineNumber:c,endColumn:u},v={startLineNumber:f,startColumn:l,endLineNumber:f,endColumn:l+a};i.getValueInRange(x)===t&&i.getValueInRange(v)===t?(o.executeEdits(r,[{range:v,text:""},{range:x,text:""}]),o.setSelection({startLineNumber:c,startColumn:u-a,endLineNumber:f,endColumn:l-a})):(o.executeEdits(r,[{range:s,text:`${t}${L}${t}`}]),o.setSelection({startLineNumber:c,startColumn:u+a,endLineNumber:f,endColumn:l+a})),o.focus();return}const b=i.getLineContent(c),m=b.slice(0,u-1),g=b.slice(u-1),C=m.lastIndexOf(t),h=g.indexOf(t);if(C!==-1&&h!==-1){const L=C+1,x=u+h,v={startLineNumber:c,startColumn:L,endLineNumber:c,endColumn:L+a},y={startLineNumber:c,startColumn:x,endLineNumber:c,endColumn:x+a};o.executeEdits(r,[{range:y,text:""},{range:v,text:""}]),o.setPosition({lineNumber:c,column:u-a})}else o.executeEdits(r,[{range:s,text:`${t}${t}`}]),o.setPosition({lineNumber:c,column:u+a});o.focus()}}function Y(t,r,n,o){return s=>{const i=s.editor.value;if(!i)return;const a=i.getSelection(),d=i.getModel();if(!a||!d)return;const c=t.length,u=r.length,f=a.isEmpty(),l=a.startLineNumber,b=a.startColumn,m=a.endLineNumber,g=a.endColumn;if(!f){const h=d.getValueInRange(a);if(l===m){const v=d.getLineContent(l),y=v.substring(0,b-1),E=v.substring(g-1);if(y.endsWith("](")&&E.startsWith(")")){const B=y.length-2,w=v.substring(0,B),I=w.lastIndexOf(t);if(I!==-1){const k=w.substring(I+c),$=I+1,oe=g+1;i.executeEdits(n,[{range:{startLineNumber:l,startColumn:$,endLineNumber:l,endColumn:oe},text:k}]),k?i.setSelection({startLineNumber:l,startColumn:$,endLineNumber:l,endColumn:$+k.length}):i.setPosition({lineNumber:l,column:$}),i.focus();return}}}const p={startLineNumber:l,startColumn:Math.max(1,b-c),endLineNumber:l,endColumn:b},L={startLineNumber:m,startColumn:g,endLineNumber:m,endColumn:g+u};if(d.getValueInRange(p)===t&&d.getValueInRange(L)===r){const v={startLineNumber:l,startColumn:b-c,endLineNumber:m,endColumn:g+u};i.executeEdits(n,[{range:v,text:""}]),i.setPosition({lineNumber:l,column:b-c})}else{i.executeEdits(n,[{range:a,text:`${t}${h}${r}`}]);const v=r.indexOf(o);if(v!==-1&&o&&l===m){const y=g+c+v;i.setSelection({startLineNumber:m,startColumn:y,endLineNumber:m,endColumn:y+o.length})}else i.setSelection({startLineNumber:l,startColumn:b+c,endLineNumber:m,endColumn:g+c})}i.focus();return}const C=n;i.executeEdits(n,[{range:a,text:`${t}${C}${r}`}]),i.setSelection({startLineNumber:l,startColumn:b+c,endLineNumber:l,endColumn:b+c+C.length}),i.focus()}}function F(t,r,n){const o=typeof t=="string"?()=>t:t,s=n??(typeof t=="string"?new RegExp(`^${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}`):null);return i=>{const a=i.editor.value;if(!a)return;const d=a.getSelection(),c=a.getModel();if(!d||!c)return;const u=d.startLineNumber,f=d.endLineNumber,l=[];for(let g=u;g<=f;g++)l.push(c.getLineContent(g));const b=l.every(g=>s?s.test(g):/^\d+\.\s/.test(g)||g.startsWith(o(1))),m=[];if(b)for(let g=l.length-1;g>=0;g--){const C=u+g,h=l[g];let p=0;if(s){const L=h.match(s);L&&(p=L[0].length)}else{const L=o(g+1);h.startsWith(L)&&(p=L.length)}p>0&&m.push({range:{startLineNumber:C,startColumn:1,endLineNumber:C,endColumn:1+p},text:""})}else for(let g=l.length-1;g>=0;g--){const C=u+g,h=l[g];if(!(s?s.test(h):h.startsWith(o(g+1)))){const L=o(g+1);m.push({range:{startLineNumber:C,startColumn:1,endLineNumber:C,endColumn:1},text:L})}}m.length>0&&a.executeEdits(r,m),a.focus()}}function _e(t){return r=>{const n=r.editor.value;if(!n)return;const o=n.getSelection(),s=n.getModel();if(!o||!s)return;const i=o.startLineNumber,a=o.endLineNumber,d=o.isEmpty();if(!ne(s,i,a)){for(let c=i;c<=a;c++)if(s.getLineContent(c).includes("```"))return;if(d){const u=s.getValueInRange({startLineNumber:i,startColumn:1,endLineNumber:i,endColumn:o.startColumn}).trim().length>0,f=u?`
5
- `:"";n.executeEdits(t,[{range:o,text:`${f}\`\`\`markdown
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),x=require("@kong/icons"),E=require("monaco-editor"),Ce=require("@shikijs/monaco"),H=require("shiki"),J=require("@kong-ui-public/i18n"),A=require("./code-lenses-Dix-b7XA.cjs"),le=require("./singletons.cjs.js");function ve(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(o,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return o.default=t,Object.freeze(o)}const S=ve(E),ye="'JetBrains Mono', Consolas, monospace",ke="12px",Le="500",we="20px",se="8px",B=Object.freeze({autoClosingQuotes:"always",automaticLayout:!0,bracketPairColorization:{enabled:!0},hideCursorInOverviewRuler:!0,fontFamily:ye,fontSize:Number(ke.replace("px","")),fontWeight:Le,lineHeight:Number(we.replace("px","")),formatOnPaste:!0,formatOnType:!0,padding:{top:0,bottom:0},lineNumbersMinChars:3,minimap:{enabled:!1},stickyScroll:{enabled:!0},suggest:{showWords:!1},quickSuggestions:!0,suggestOnTriggerCharacters:!0,wordBasedSuggestions:"off",overviewRulerLanes:0,renderWhitespace:"boundary",scrollBeyondLastLine:!1,roundedSelection:!1,wordWrapColumn:120,colorDecorators:!0,folding:!0,fixedOverflowWidgets:!0,tabSize:2,detectIndentation:!1,insertSpaces:!0,trimAutoWhitespace:!0,wordWrap:"bounded",find:{addExtraSpaceOnTop:!1}}),xe=Object.freeze({...B,renderSideBySide:!1,enableSplitViewResizing:!1,renderIndicators:!0,ignoreTrimWhitespace:!1,diffAlgorithm:"advanced",renderOverviewRuler:!1,renderGutterMenu:!1,renderMarginRevertIcon:!1,diffCodeLens:!1,diffWordWrap:"inherit",hideUnchangedRegions:{enabled:!1},experimental:{showMoves:!1,useTrueInlineView:!1},readOnly:!0,originalEditable:!1,formatOnPaste:!1,formatOnType:!1,quickSuggestions:!1,suggestOnTriggerCharacters:!1,autoClosingQuotes:"never",stickyScroll:{enabled:!1}}),ee={command:E.KeyMod.CtrlCmd,cmd:E.KeyMod.CtrlCmd,ctrl:E.KeyMod.CtrlCmd,ctrlcmd:E.KeyMod.CtrlCmd,shift:E.KeyMod.Shift,alt:E.KeyMod.Alt,option:E.KeyMod.Alt,win:E.KeyMod.WinCtrl,meta:E.KeyMod.WinCtrl},Me={enter:"Enter",esc:"Escape",escape:"Escape",space:"Space",tab:"Tab",backspace:"Backspace",delete:"Delete",insert:"Insert",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown",up:"UpArrow",down:"DownArrow",left:"LeftArrow",right:"RightArrow",arrowup:"UpArrow",arrowdown:"DownArrow",arrowleft:"LeftArrow",arrowright:"RightArrow"};function Se(t){if(!t?.length)return;let o=0,n;for(const r of t){const s=r.toLowerCase();if(ee[s]){o|=ee[s];continue}if(/^f\d+$/.test(s)){n=E.KeyCode[`F${s.slice(1)}`];continue}if(/^[a-z]$/.test(s)){n=E.KeyCode[`Key${s.toUpperCase()}`];continue}if(/^\d$/.test(s)){n=E.KeyCode[`Digit${s}`];continue}const l=Me[s];l&&(n=E.KeyCode[l])}return n!==void 0?o|n:void 0}function K(t,o){if(o){if(typeof t.action=="function")t.action(o);else if(typeof t.action=="string"){const n=t.action,r=o.editor.value?.getAction(n);r?r.run():o.triggerKeyboardCommand(n)}}}const Ee=new Set(["markdown","mdc"]),Ie=[{detect:/^(\s*)- \[[ x]\] /,nextPrefix:t=>`${t[1]}- [ ] `,emptyItem:/^(\s*)- \[[ x]\] $/},{detect:/^(\s*)([-*+]) /,nextPrefix:t=>`${t[1]}${t[2]} `,emptyItem:/^(\s*)[-*+] $/},{detect:/^(\s*)(\d+)\. /,nextPrefix:t=>`${t[1]}${Number(t[2])+1}. `,emptyItem:/^(\s*)\d+\. $/}];function Ne(t){return t.addAction({id:"editor.action.listContinuation",label:"Continue List on Enter",keybindings:[E.KeyCode.Enter],precondition:"editorTextFocus && !editorReadonly && !suggestWidgetVisible && !renameInputVisible && !inSnippetMode && !quickFixWidgetVisible",run:o=>{const n=o.getModel(),r=o.getSelection();if(!n||!r||!r.isEmpty()||!Ee.has(n.getLanguageId())){o.trigger("listContinuation","type",{text:`
2
+ `});return}const s=r.startLineNumber,l=n.getLineContent(s);for(const i of Ie){const d=l.match(i.detect);if(!d)continue;if(i.emptyItem.test(l)){o.executeEdits("listContinuation",[{range:{startLineNumber:s,startColumn:1,endLineNumber:s,endColumn:l.length+1},text:""}]);return}const c=i.nextPrefix(d);if(c!==void 0){const u=r.startColumn;o.executeEdits("listContinuation",[{range:{startLineNumber:s,startColumn:u,endLineNumber:s,endColumn:u},text:`
3
+ ${c}`}]);const f=s+1,a=c.length+1;o.setPosition({lineNumber:f,column:a}),o.revealLine(f);return}}o.trigger("listContinuation","type",{text:`
4
+ `})}})}function Be(t,o){return e.getCurrentScope()?(e.onScopeDispose(t,o),!0):!1}const Oe=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const T=()=>{};function Te(t,o){function n(...r){return new Promise((s,l)=>{Promise.resolve(t(()=>o.apply(this,r),{fn:o,thisArg:this,args:r})).then(s).catch(l)})}return"cancel"in t&&Object.assign(n,{cancel:t.cancel,flush:t.flush,isPending:t.isPending}),n}function Re(t,o={}){let n,r,s=T,l=T;const i=e.shallowRef(!1),d=f=>{clearTimeout(f),s(),s=T};let c;return Object.assign(f=>{const a=e.toValue(t),p=e.toValue(o.maxWait);return n&&d(n),a<=0||p!==void 0&&p<=0?(r&&(d(r),r=void 0),i.value=!1,Promise.resolve(f())):(i.value=!0,new Promise((m,g)=>{s=o.rejectOnCancel?g:m,l=m,c=f,p&&!r&&(r=setTimeout(()=>{n&&d(n),r=void 0,i.value=!1,m(c())},p)),n=setTimeout(()=>{r&&d(r),r=void 0,i.value=!1,m(f())},a)}))},{cancel:()=>{n&&(d(n),n=void 0),r&&(d(r),r=void 0),i.value=!1,l=T},flush:()=>{if(i.value){n&&(clearTimeout(n),n=void 0),r&&(clearTimeout(r),r=void 0),i.value=!1;const f=l;s=T,l=T,f(c())}},isPending:e.shallowReadonly(i)})}function De(t){return Array.isArray(t)?t:[t]}function Ae(t){return e.getCurrentInstance()}function ce(t,o=200,n={}){return Te(Re(o,n),t)}function $e(t,o=!0,n){Ae()?e.onMounted(t,n):o?t():e.nextTick(t)}const de=Oe?window:void 0;function R(t){var o;const n=e.toValue(t);return(o=n?.$el)!==null&&o!==void 0?o:n}function Ve(){const t=e.shallowRef(!1),o=e.getCurrentInstance();return o&&e.onMounted(()=>{t.value=!0},o),t}function We(t){const o=Ve();return e.computed(()=>(o.value,!!t()))}function _e(t,o,n={}){const{window:r=de,...s}=n;let l;const i=We(()=>r&&"ResizeObserver"in r),d=()=>{l&&(l.disconnect(),l=void 0)},c=e.watch(e.computed(()=>{const f=e.toValue(t);return Array.isArray(f)?f.map(a=>R(a)):[R(f)]}),f=>{if(d(),i.value&&r){l=new ResizeObserver(o);for(const a of f)a&&l.observe(a,s)}},{immediate:!0,flush:"post"}),u=()=>{d(),c()};return Be(u),{isSupported:i,stop:u}}function U(t,o={width:0,height:0},n={}){const{window:r=de,box:s="content-box"}=n,l=e.computed(()=>{var a;return(a=R(t))===null||a===void 0||(a=a.namespaceURI)===null||a===void 0?void 0:a.includes("svg")}),i=e.shallowRef(o.width),d=e.shallowRef(o.height),{stop:c}=_e(t,([a])=>{const p=s==="border-box"?a.borderBoxSize:s==="content-box"?a.contentBoxSize:a.devicePixelContentBoxSize;if(r&&l.value){const m=R(t);if(m){const g=m.getBoundingClientRect();i.value=g.width,d.value=g.height}}else if(p){const m=De(p);i.value=m.reduce((g,{inlineSize:C})=>g+C,0),d.value=m.reduce((g,{blockSize:C})=>g+C,0)}else i.value=a.contentRect.width,d.value=a.contentRect.height},n);$e(()=>{const a=R(t);if(a&&"offsetWidth"in a)if(s==="content-box"&&r){const p=r.getComputedStyle(a),m=Number.parseFloat(p.paddingLeft)+Number.parseFloat(p.paddingRight),g=Number.parseFloat(p.paddingTop)+Number.parseFloat(p.paddingBottom),C=Number.parseFloat(p.borderLeftWidth)+Number.parseFloat(p.borderRightWidth),b=Number.parseFloat(p.borderTopWidth)+Number.parseFloat(p.borderBottomWidth);i.value=a.offsetWidth-m-C,d.value=a.offsetHeight-g-b}else i.value=a.offsetWidth,d.value=a.offsetHeight;else a&&(i.value=o.width,d.value=o.height)});const u=e.watch(()=>R(t),a=>{i.value=a?o.width:0,d.value=a?o.height:0});function f(){c(),u()}return{width:i,height:d,stop:f}}const Q=e.ref(!1);let $=null;async function ue(){return $||($=(async()=>{try{(S.json?.jsonDefaults||S.languages.json?.jsonDefaults)?.setModeConfiguration({tokens:!1});const o=await H.getSingletonHighlighter({themes:Object.values(H.bundledThemes),langs:Object.values(H.bundledLanguages)});o.getLoadedLanguages().forEach(n=>{S.languages.register({id:n})}),Ce.shikiToMonaco(o,S),Q.value=!0}catch(t){throw $=null,t}})(),$)}function me(t){return t==="light"?"catppuccin-latte":"material-theme-darker"}function Z(t,o,n,r){if(t)return t.setValue(o),t;const s=r?`${r}/${n}`:n,l=S.Uri.parse(`inmemory://model/${s}-${crypto.randomUUID()}`);return S.editor.createModel(o,n,l)}function ge(t,o){const n=e.shallowRef();let r,s=!1,l=!1;const i=e.reactive({editorStatus:"loading",searchBoxIsRevealed:!1,hasContent:!1,theme:o.theme||"light",currentLanguage:o.language||"",readOnly:o.readOnly||!1}),d=b=>{!s||!n.value||n.value.setValue(b)},c=b=>n.value?.updateOptions({readOnly:b}),u=()=>n.value?.focus(),f=b=>{const h=n.value?.getModel();h&&S.editor.setModelLanguage(h,b)},a=b=>{try{if(!n.value||!b)return;n.value.focus(),n.value.trigger("keyboard",b,null)}catch(h){console.error(`useMonacoEditor: Failed to trigger command: ${b}`,h)}},p=()=>{try{if(!n.value)return;if(i.searchBoxIsRevealed)return n.value.getContribution("editor.contrib.findController")?.closeFindWidget();a("actions.find")}catch(b){console.error("useMonacoEditor: Failed to close findController.",b)}},m=ce(()=>S.editor.remeasureFonts(),200),g=b=>{!n.value||!b?.length||b.forEach(h=>{if(!(!h.id||!h.action))try{const k={id:h.id,label:h.label||h.id,keybindings:h.keybindings?[Se(h.keybindings)].filter(w=>w!==void 0):void 0,contextMenuGroupId:h.showInContextMenu?h.contextMenuGroupId||"basic":void 0,contextMenuOrder:h.contextMenuOrder??1.5,run:w=>{if(typeof h.action=="function")h.action({editor:n,editorStates:i,setContent:d,setReadOnly:c,focus:u,setLanguage:f,remeasureFonts:m,toggleSearchWidget:p,triggerKeyboardCommand:a,registerActions:g});else if(typeof h.action=="string"){const v=w.getAction(h.action);v?v.run():a(h.action)}}};n.value?.addAction(k)}catch(k){console.error(`useMonacoEditor: Failed to register action: ${h.id}`,k)}})};return ue(),e.watch([Q,()=>e.toValue(t)],([b,h],[,k])=>{const w=e.toValue(h),v=e.toValue(k);if(!(w instanceof HTMLElement)||!b){s=!1;return}if(!(s&&v===w)){r=Z(r,o.code.value,o.language),n.value=S.editor.create(w,{...B,readOnly:o.readOnly||!1,language:o.language,theme:me(i.theme),model:r,editContext:!1,...o.monacoOptions}),s=!0,i.editorStatus="ready",i.hasContent=!!o.code.value,i.currentLanguage=r.getLanguageId(),i.readOnly=!!n.value.getOption(S.editor.EditorOption.readOnly),r.onDidChangeLanguage(L=>{i.currentLanguage=L.newLanguage}),n.value.onDidChangeConfiguration(L=>{L.hasChanged(S.editor.EditorOption.readOnly)&&(i.readOnly=!!n.value.getOption(S.editor.EditorOption.readOnly))}),n.value.onDidChangeModelContent(()=>{if(l)return;const L=n.value.getValue();i.hasContent=!!L.length,o.code.value=L}),o.actions?.length&&g(o.actions),Ne(n.value),o.onReady?.(n.value),m();try{const N=n.value.getContribution("editor.contrib.findController")?.getState();N?.onFindReplaceStateChange(()=>{i.searchBoxIsRevealed=N.isRevealed})}catch(L){console.error("useMonacoEditor: Failed to get the state of findController",L)}e.onWatcherCleanup(()=>{n.value?.dispose()})}},{immediate:!0,flush:"post"}),e.watch(o.code,b=>{if(!n.value||!r||!s)return;const h=r.getValue();b!==h&&(l=!0,n.value.executeEdits("external",[{range:r.getFullModelRange(),text:b}]),n.value.pushUndoStop(),i.hasContent=!!b.length,l=!1)}),e.onMounted(m),e.onActivated(m),e.onBeforeUnmount(()=>{if(!n.value)return;const b=n.value.getModel();n.value.dispose(),b&&b.dispose()}),{editor:n,editorStates:i,setContent:d,setReadOnly:c,focus:u,setLanguage:f,remeasureFonts:m,registerActions:g,toggleSearchWidget:p,triggerKeyboardCommand:a}}const Pe={labels:{action_search:"Search",action_bold:"Bold",action_italic:"Italic",action_strikethrough:"Strikethrough",action_inline_code:"Code",action_link:"Link",action_image:"Image",action_unordered_list:"Unordered list",action_ordered_list:"Ordered list",action_task_list:"Task list",action_codeblock:"Code block",action_blockquote:"Blockquote",action_table:"Table",action_search_label:"Search document",action_format:"Format",action_format_label:"Format document",action_fullscreen:"Full Screen",action_fullscreen_label:"Toggle full screen mode",action_more:"More",key:"Key: {key}"},messages:{empty_message:"The editor is currently empty. Start typing to add content.",empty_message_readonly:"The editor is currently empty.",empty_title:"No content available",loading_message:"Please wait while the {type} content is loaded.",loading_title:"{type} editor"}},Fe={editor:Pe};function _(){const t=J.createI18n("en-us",Fe);return{i18n:t,i18nT:J.i18nTComponent(t)}}const Ke=e.defineComponent({__name:"MonacoEditorStatusOverlay",props:{title:{},message:{},icon:{}},setup(t){return(o,n)=>{const r=e.resolveComponent("KEmptyState");return e.openBlock(),e.createBlock(r,{class:"monaco-editor-status-overlay",message:t.message,title:t.title},e.createSlots({_:2},[t.icon?{name:"icon",fn:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.icon),{decorative:""}))]),key:"0"}:void 0]),1032,["message","title"])}}}),P=(t,o)=>{const n=t.__vccOpts||t;for(const[r,s]of o)n[r]=s;return n},z=P(Ke,[["__scopeId","data-v-062eadb5"]]),Ue={key:0,class:"keys"},Ge=["aria-label","data-testid","textContent"],je=e.defineComponent({__name:"ToolbarActionButton",props:{item:{},active:{type:Boolean,default:!0},placement:{default:"bottom-end"}},setup(t){const{i18n:o}=_(),n=e.computed(()=>!!t.item.keybindings?.length),r=e.ref(!1),s=d=>{const c=d.toLowerCase();return{command:r.value?"Command":"Ctrl",cmd:r.value?"Command":"Ctrl",ctrl:"Ctrl",control:"Ctrl",shift:"Shift",option:r.value?"Option":"Alt",opt:r.value?"Option":"Alt",alt:"Alt"}[c]||d.toUpperCase()},l=d=>["command","cmd","ctrl","control","shift","option","opt","alt"].includes(d.toLowerCase()),i=d=>{const c=d.toLowerCase();return["command","cmd","ctrl","control"].includes(c)?"meta-key":c==="shift"?"shift-key":["option","opt","alt"].includes(c)?"option-key":""};return e.onMounted(()=>{r.value=/Mac|iPhone|iPod|iPad/i.test(navigator?.platform)||/macOS|Mac|iPhone|iPod|iPad/i.test(navigator?.userAgentData?.platform)}),(d,c)=>{const u=e.resolveComponent("KButton"),f=e.resolveComponent("KTooltip");return e.openBlock(),e.createBlock(f,{"data-testid":`editor-toolbar-mdc-action-${t.item.id}-tooltip`,placement:t.placement},e.createSlots({default:e.withCtx(()=>[e.createVNode(u,{appearance:"none","aria-label":t.item.ariaLabel||t.item.label,class:"toolbar-action-button","data-testid":`editor-toolbar-mdc-action-${t.item.id}-button`,disabled:!t.active,icon:"",onClick:t.item.action},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.item.icon),{decorative:""}))]),_:1},8,["aria-label","data-testid","disabled","onClick"])]),_:2},[t.item.label?{name:"content",fn:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["shortcut-text",{"has-keys":n.value}])},e.toDisplayString(t.item.label),3),n.value?(e.openBlock(),e.createElementBlock("div",Ue,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.item.keybindings,a=>(e.openBlock(),e.createElementBlock("kbd",{key:a,"aria-label":e.unref(o).t("editor.labels.key",{key:s(a)}),class:e.normalizeClass([{mac:r.value},i(a)]),"data-testid":`editor-toolbar-mdc-${l(a)?i(a):`${a.toLowerCase()}-key`}`,textContent:e.toDisplayString(l(a)?"":a)},null,10,Ge))),128))])):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1032,["data-testid","placement"])}}}),G=P(je,[["__scopeId","data-v-c588b09b"]]);function W(t,o){return n=>{const r=n.editor.value;if(!r)return;const s=r.getSelection(),l=r.getModel();if(!s||!l)return;const i=t.length,d=s.isEmpty(),c=s.startLineNumber,u=s.startColumn,f=s.endLineNumber,a=s.endColumn;if(!d){const k=l.getValueInRange(s),w={startLineNumber:c,startColumn:Math.max(1,u-i),endLineNumber:c,endColumn:u},v={startLineNumber:f,startColumn:a,endLineNumber:f,endColumn:a+i};l.getValueInRange(w)===t&&l.getValueInRange(v)===t?(r.executeEdits(o,[{range:v,text:""},{range:w,text:""}]),r.setSelection({startLineNumber:c,startColumn:u-i,endLineNumber:f,endColumn:a-i})):(r.executeEdits(o,[{range:s,text:`${t}${k}${t}`}]),r.setSelection({startLineNumber:c,startColumn:u+i,endLineNumber:f,endColumn:a+i})),r.focus();return}const p=l.getLineContent(c),m=p.slice(0,u-1),g=p.slice(u-1),C=m.lastIndexOf(t),b=g.indexOf(t);if(C!==-1&&b!==-1){const k=C+1,w=u+b,v={startLineNumber:c,startColumn:k,endLineNumber:c,endColumn:k+i},L={startLineNumber:c,startColumn:w,endLineNumber:c,endColumn:w+i};r.executeEdits(o,[{range:L,text:""},{range:v,text:""}]),r.setPosition({lineNumber:c,column:u-i})}else r.executeEdits(o,[{range:s,text:`${t}${t}`}]),r.setPosition({lineNumber:c,column:u+i});r.focus()}}function te(t,o,n,r){return s=>{const l=s.editor.value;if(!l)return;const i=l.getSelection(),d=l.getModel();if(!i||!d)return;const c=t.length,u=o.length,f=i.isEmpty(),a=i.startLineNumber,p=i.startColumn,m=i.endLineNumber,g=i.endColumn;if(!f){const b=d.getValueInRange(i);if(a===m){const v=d.getLineContent(a),L=v.substring(0,p-1),N=v.substring(g-1);if(L.endsWith("](")&&N.startsWith(")")){const O=L.length-2,M=v.substring(0,O),I=M.lastIndexOf(t);if(I!==-1){const y=M.substring(I+c),F=I+1,be=g+1;l.executeEdits(n,[{range:{startLineNumber:a,startColumn:F,endLineNumber:a,endColumn:be},text:y}]),y?l.setSelection({startLineNumber:a,startColumn:F,endLineNumber:a,endColumn:F+y.length}):l.setPosition({lineNumber:a,column:F}),l.focus();return}}}const h={startLineNumber:a,startColumn:Math.max(1,p-c),endLineNumber:a,endColumn:p},k={startLineNumber:m,startColumn:g,endLineNumber:m,endColumn:g+u};if(d.getValueInRange(h)===t&&d.getValueInRange(k)===o){const v={startLineNumber:a,startColumn:p-c,endLineNumber:m,endColumn:g+u};l.executeEdits(n,[{range:v,text:""}]),l.setPosition({lineNumber:a,column:p-c})}else{l.executeEdits(n,[{range:i,text:`${t}${b}${o}`}]);const v=o.indexOf(r);if(v!==-1&&r&&a===m){const L=g+c+v;l.setSelection({startLineNumber:m,startColumn:L,endLineNumber:m,endColumn:L+r.length})}else l.setSelection({startLineNumber:a,startColumn:p+c,endLineNumber:m,endColumn:g+c})}l.focus();return}const C=n;l.executeEdits(n,[{range:i,text:`${t}${C}${o}`}]),l.setSelection({startLineNumber:a,startColumn:p+c,endLineNumber:a,endColumn:p+c+C.length}),l.focus()}}function j(t,o,n){const r=typeof t=="string"?()=>t:t,s=n??(typeof t=="string"?new RegExp(`^${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}`):null);return l=>{const i=l.editor.value;if(!i)return;const d=i.getSelection(),c=i.getModel();if(!d||!c)return;const u=d.startLineNumber,f=d.endLineNumber,a=[];for(let g=u;g<=f;g++)a.push(c.getLineContent(g));const p=a.every(g=>s?s.test(g):/^\d+\.\s/.test(g)||g.startsWith(r(1))),m=[];if(p)for(let g=a.length-1;g>=0;g--){const C=u+g,b=a[g];let h=0;if(s){const k=b.match(s);k&&(h=k[0].length)}else{const k=r(g+1);b.startsWith(k)&&(h=k.length)}h>0&&m.push({range:{startLineNumber:C,startColumn:1,endLineNumber:C,endColumn:1+h},text:""})}else for(let g=a.length-1;g>=0;g--){const C=u+g,b=a[g];if(!(s?s.test(b):b.startsWith(r(g+1)))){const k=r(g+1);m.push({range:{startLineNumber:C,startColumn:1,endLineNumber:C,endColumn:1},text:k})}}m.length>0&&i.executeEdits(o,m),i.focus()}}function ze(t){return o=>{const n=o.editor.value;if(!n)return;const r=n.getSelection(),s=n.getModel();if(!r||!s)return;const l=r.startLineNumber,i=r.endLineNumber,d=r.isEmpty();if(!fe(s,l,i)){for(let c=l;c<=i;c++)if(s.getLineContent(c).includes("```"))return;if(d){const u=s.getValueInRange({startLineNumber:l,startColumn:1,endLineNumber:l,endColumn:r.startColumn}).trim().length>0,f=u?`
5
+ `:"";n.executeEdits(t,[{range:r,text:`${f}\`\`\`markdown
6
6
 
7
- \`\`\``}]);const l=u?i+1:i;n.setSelection({startLineNumber:l,startColumn:4,endLineNumber:l,endColumn:12})}else{const c=i>1?s.getLineContent(i-1):"",u=a<s.getLineCount()?s.getLineContent(a+1):"";if(c.trimEnd().startsWith("```")&&u.trimEnd()==="```")n.executeEdits(t,[{range:{startLineNumber:a+1,startColumn:1,endLineNumber:a+1,endColumn:s.getLineContent(a+1).length+1},text:null},{range:{startLineNumber:i-1,startColumn:1,endLineNumber:i-1,endColumn:s.getLineContent(i-1).length+1},text:null}]),n.setSelection({startLineNumber:i-1,startColumn:1,endLineNumber:a-1,endColumn:s.getLineContent(a-1).length+1});else{const l=s.getValueInRange(o),m=s.getValueInRange({startLineNumber:i,startColumn:1,endLineNumber:i,endColumn:o.startColumn}).trim().length>0,g=m?`
8
- `:"";n.executeEdits(t,[{range:o,text:`${g}\`\`\`markdown
9
- ${l}
10
- \`\`\``}]);const C=m?i+1:i;n.setSelection({startLineNumber:C,startColumn:4,endLineNumber:C,endColumn:12})}}n.focus()}}}function Ae(t){return r=>{const n=r.editor.value;if(!n)return;const o=n.getSelection(),s=n.getModel();if(!o||!s)return;const i=o.startLineNumber,a=o.endLineNumber;if(ne(s,i,a))return;const d=["| Header | Header | Header |","| ------ | ------ | ------ |","| Cell | Cell | Cell |","| Cell | Cell | Cell |"].join(`
11
- `);n.executeEdits(t,[{range:o,text:d+`
12
- `}]);const c=i+4;n.setPosition({lineNumber:c,column:1}),n.focus()}}function ne(t,r,n){let o=0,s=0;for(let i=r-1;i>=1;i--)t.getLineContent(i).trimEnd().startsWith("```")&&(s++,s%2===1&&(o=i));if(o===0)return!1;for(let i=n+1;i<=t.getLineCount();i++)if(t.getLineContent(i).trimEnd().startsWith("```"))return!0;return!1}const $e={format:{id:"editor.action.format",icon:S.CleaningIcon,label:"editor.labels.action_format",action:"editor.action.formatDocument",keybindings:["Shift","Alt","F"],placement:"left",order:1,group:1,showInContextMenu:!0,contextMenuGroupId:"formatting",contextMenuOrder:1},bold:{id:"editor.action.bold",icon:S.BoldIcon,label:"editor.labels.action_bold",action:A("**","bold"),keybindings:["Command","B"],placement:"left",group:2,order:1,showInContextMenu:!0,contextMenuGroupId:"formatting",contextMenuOrder:2,languages:["markdown","mdc"]},italic:{id:"editor.action.italic",icon:S.ItalicIcon,label:"editor.labels.action_italic",action:A("_","italic"),keybindings:["Command","I"],placement:"left",group:2,order:2,showInContextMenu:!0,contextMenuGroupId:"formatting",contextMenuOrder:3,languages:["markdown","mdc"]},strikethrough:{id:"editor.action.strikethrough",icon:S.StrikethroughIcon,label:"editor.labels.action_strikethrough",action:A("~~","strikethrough"),keybindings:["Command","Shift","X"],placement:"left",group:2,order:3,showInContextMenu:!0,contextMenuGroupId:"formatting",contextMenuOrder:4,languages:["markdown","mdc"]}},Pe={inlineCode:{id:"editor.action.inlineCode",icon:S.CodeIcon,label:"editor.labels.action_inline_code",action:A("`","inlineCode"),keybindings:["Command","E"],placement:"left",group:3,order:1,showInContextMenu:!0,contextMenuGroupId:"insert",contextMenuOrder:1,languages:["markdown","mdc"]},link:{id:"editor.action.link",icon:S.LinkIcon,label:"editor.labels.action_link",action:Y("[","](url)","link","url"),keybindings:["Command","K"],placement:"left",group:3,order:2,showInContextMenu:!0,contextMenuGroupId:"insert",contextMenuOrder:2,languages:["markdown","mdc"]},image:{id:"editor.action.image",icon:S.ImageIcon,label:"editor.labels.action_image",action:Y("![","](url)","image","url"),keybindings:["Command","Shift","I"],placement:"left",group:3,order:3,showInContextMenu:!0,contextMenuGroupId:"insert",contextMenuOrder:3,languages:["markdown","mdc"]}},De={unorderedList:{id:"editor.action.unorderedList",icon:S.ListUnorderedIcon,label:"editor.labels.action_unordered_list",action:F("- ","unorderedList"),keybindings:[],placement:"left",group:4,order:1,showInContextMenu:!0,contextMenuGroupId:"list",contextMenuOrder:1,languages:["markdown","mdc"]},orderedList:{id:"editor.action.orderedList",icon:S.ListOrderedIcon,label:"editor.labels.action_ordered_list",action:F(t=>`${t}. `,"orderedList",/^\d+\.\s/),keybindings:[],placement:"left",group:4,order:2,showInContextMenu:!0,contextMenuGroupId:"list",contextMenuOrder:2,languages:["markdown","mdc"]},taskList:{id:"editor.action.taskList",icon:S.TasklistIcon,label:"editor.labels.action_task_list",action:F("- [ ] ","taskList"),keybindings:[],placement:"left",group:4,order:3,showInContextMenu:!0,contextMenuGroupId:"list",contextMenuOrder:3,languages:["markdown","mdc"]}},Ve={codeblock:{id:"editor.action.codeblock",icon:S.CodeblockIcon,label:"editor.labels.action_codeblock",action:_e("codeblock"),keybindings:[],placement:"left",group:5,order:1,showInContextMenu:!0,contextMenuGroupId:"block",contextMenuOrder:1,languages:["markdown","mdc"]},blockquote:{id:"editor.action.blockquote",icon:S.BlockquoteIcon,label:"editor.labels.action_blockquote",action:F("> ","blockquote"),keybindings:[],placement:"left",group:5,order:2,showInContextMenu:!0,contextMenuGroupId:"block",contextMenuOrder:2,languages:["markdown","mdc"]},table:{id:"editor.action.table",icon:S.TableIcon,label:"editor.labels.action_table",action:Ae("table"),keybindings:[],placement:"left",group:5,order:3,showInContextMenu:!0,contextMenuGroupId:"block",contextMenuOrder:3,languages:["markdown","mdc"]}},We={search:{id:"editor.action.find",icon:S.SearchIcon,label:"editor.labels.action_search",action:t=>t.toggleSearchWidget(),keybindings:["Command","F"],placement:"right",order:10,group:2,showInContextMenu:!0,contextMenuGroupId:"navigation",contextMenuOrder:1}},Fe={fullScreen:{id:"editor.action.fullScreen",icon:S.ExpandIcon,label:"editor.labels.action_fullscreen",action:t=>t.editor.value?.getContainerDomNode().requestFullscreen(),keybindings:["Ctrl","F11"],placement:"right",order:20,group:2,showInContextMenu:!0,contextMenuGroupId:"view",contextMenuOrder:1}},X={...$e,...Pe,...De,...Ve,...We,...Fe},Z="left",j=100,Ke="default";function Ge(t,r){const{i18n:n}=K(),o=t&&typeof t=="object"?t.actions??{}:{},s=e.computed(()=>{const a=[],d=e.unref(r);for(const[c,u]of Object.entries(X)){const f=o[c];f!==!1&&(u.languages&&d&&!u.languages.includes(d)||a.push({...u,label:n.t(u.label),...typeof f=="object"?f:{}}))}for(const[c,u]of Object.entries(o)){if(c in X||u===!1||u==null)continue;const f={id:c,label:typeof u=="object"&&u.label?u.label:c,placement:Z,order:j},l=typeof u=="object"?{...f,...u}:f;l.icon&&l.action&&a.push(l)}return a});function i(a){const d=new Map;return s.value.filter(c=>(c.placement??Z)===a).sort((c,u)=>(c.order??j)-(u.order??j)).forEach(c=>{const u=String(c.group??Ke);d.has(u)||d.set(u,[]),d.get(u).push(c)}),Array.from(d.values())}return{commands:s,leftGroups:e.computed(()=>i("left")),centerGroups:e.computed(()=>i("center")),rightGroups:e.computed(()=>i("right"))}}const Ue={class:"monaco-editor-ui-toolbar-action-group","data-testid":"toolbar-overflow-group"},je=5,ze=e.defineComponent({__name:"MonacoEditorToolbar",props:{editor:{default:null},settings:{type:[Boolean,Object]}},setup(t){const{i18n:r}=K(),n=e.useTemplateRef("toolbarEl"),o=e.useTemplateRef("leftSlotEl"),s=e.useTemplateRef("centerSlotEl"),i=e.useTemplateRef("rightSlotEl"),a=D(n),d=D(o),c=D(s),u=D(i),f=e.computed(()=>t.editor?.editorStates.currentLanguage??""),{commands:l,leftGroups:b,centerGroups:m,rightGroups:g}=Ge(t.settings,f),C=e.shallowRef([]),h=e.ref(0),p=[],L=e.computed(()=>b.value.slice(C.value.length).flatMap((v,y)=>v.map((E,B)=>({...E,hasDivider:y>0&&B===0}))));e.watch(b,v=>{C.value=[...v],p.length=0},{immediate:!0});function x(){const v=n.value?.getBoundingClientRect().width??0;if(v===0)return;const y=o.value?.getBoundingClientRect().width??0,E=s.value?.getBoundingClientRect().width??0,B=i.value?.getBoundingClientRect().width??0,w=y+E+B+50;v<w&&C.value.length>0?(p.push(w),C.value=C.value.slice(0,-1),h.value++,e.nextTick(x)):p.length>0&&C.value.length<b.value.length&&v>p[p.length-1]+je&&(p.pop(),C.value=[...C.value,b.value[C.value.length]],e.nextTick(x))}return e.watch(()=>t.editor?.editorStates.editorStatus,v=>{v==="ready"&&t.editor&&l.value.length>0&&t.editor.registerActions(l.value)},{immediate:!0}),e.watch([a.width,d.width,c.width,u.width],x),e.onMounted(async()=>await e.nextTick(x)),(v,y)=>{const E=e.resolveComponent("KDropdownItem"),B=e.resolveComponent("KDropdown");return e.openBlock(),e.createElementBlock("div",{ref_key:"toolbarEl",ref:n,class:"monaco-editor-ui-toolbar","data-testid":"monaco-editor-toolbar"},[e.createElementVNode("div",{ref_key:"leftSlotEl",ref:o,class:"monaco-editor-ui-toolbar-left","data-testid":"monaco-editor-toolbar-left"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C.value,(w,I)=>(e.openBlock(),e.createElementBlock("div",{key:I,class:"monaco-editor-ui-toolbar-action-group"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w,k=>(e.openBlock(),e.createBlock(V,{key:k.id,active:t.editor?.editorStates.editorStatus==="ready",item:{id:k.id,label:k.label,icon:k.icon,keybindings:k.keybindings,action:()=>e.unref(P)(k,t.editor)},placement:I===0?"bottom-start":"bottom"},null,8,["active","item","placement"]))),128))]))),128)),e.withDirectives(e.createElementVNode("div",Ue,[(e.openBlock(),e.createBlock(B,{key:h.value,class:e.normalizeClass({"is-disabled":t.editor?.editorStates.editorStatus!=="ready"})},{items:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(L.value,w=>(e.openBlock(),e.createBlock(E,{key:w.id,"data-testid":`overflow-item-${w.id}`,"has-divider":w.hasDivider,onClick:I=>e.unref(P)(w,t.editor)},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(w.icon),{decorative:""})),e.createTextVNode(" "+e.toDisplayString(w.label),1)]),_:2},1032,["data-testid","has-divider","onClick"]))),128))]),default:e.withCtx(()=>[e.createVNode(V,{active:t.editor?.editorStates.editorStatus==="ready",item:{id:"more",label:e.unref(r).t("editor.labels.action_more"),icon:e.unref(S.MoreIcon)},placement:"bottom"},null,8,["active","item"])]),_:1},8,["class"]))],512),[[e.vShow,L.value.length]]),e.renderSlot(v.$slots,"toolbar-left",{},void 0,!0)],512),e.createElementVNode("div",{ref_key:"centerSlotEl",ref:s,class:"monaco-editor-ui-toolbar-center","data-testid":"monaco-editor-toolbar-center"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(m),(w,I)=>(e.openBlock(),e.createElementBlock("div",{key:I,class:"monaco-editor-ui-toolbar-action-group"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w,k=>(e.openBlock(),e.createBlock(V,{key:k.id,active:t.editor?.editorStates.editorStatus==="ready",item:{id:k.id,label:k.label,icon:k.icon,keybindings:k.keybindings,action:()=>e.unref(P)(k,t.editor)},placement:"bottom"},null,8,["active","item"]))),128))]))),128)),e.renderSlot(v.$slots,"toolbar-center",{},void 0,!0)],512),e.createElementVNode("div",{ref_key:"rightSlotEl",ref:i,class:"monaco-editor-ui-toolbar-right","data-testid":"monaco-editor-toolbar-right"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),(w,I)=>(e.openBlock(),e.createElementBlock("div",{key:I,class:"monaco-editor-ui-toolbar-action-group"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w,k=>(e.openBlock(),e.createBlock(V,{key:k.id,active:t.editor?.editorStates.editorStatus==="ready",item:{id:k.id,label:k.label,icon:k.icon,keybindings:k.keybindings,action:()=>e.unref(P)(k,t.editor)},placement:I===e.unref(g).length-1?"bottom-end":"bottom"},null,8,["active","item","placement"]))),128))]))),128)),e.renderSlot(v.$slots,"toolbar-right",{},void 0,!0)],512)],512)}}}),qe=G(ze,[["__scopeId","data-v-b6dd2107"]]),He=e.defineComponent({__name:"MonacoEditor",props:e.mergeModels({appearance:{default:"embedded"},theme:{default:"light"},language:{default:"markdown"},toolbar:{type:[Boolean,Object],default:!1},loading:{type:Boolean,default:!1},options:{default:()=>{}},showLoadingState:{type:Boolean,default:!0},showEmptyState:{type:Boolean,default:!0}},{modelValue:{type:String,required:!0},modelModifiers:{}}),emits:e.mergeModels(["ready"],["update:modelValue"]),setup(t,{expose:r,emit:n}){const o=parseInt(de,10),s=n,i=e.useModel(t,"modelValue"),{i18n:a}=K(),d=e.useTemplateRef("editorRef"),c=e.computed(()=>t.theme==="dark"?"dark":"light"),u=e.computed(()=>{if(t.appearance==="standalone"){const m=String(i.value.split(`
13
- `).length).length;return{...t.options,padding:{top:o,bottom:o},lineNumbersMinChars:Math.max(W.lineNumbersMinChars,m)+2}}return{padding:{...W.padding},lineNumbersMinChars:W.lineNumbersMinChars,...t.options}}),f=te(d,{language:t.language,code:i,theme:c.value,monacoOptions:u.value,onReady:m=>{s("ready",m)}}),l=e.computed(()=>t.loading||f.editorStates.editorStatus==="loading"),b=e.computed(()=>!l.value&&f.editorStates.editorStatus==="ready"&&!f.editorStates.hasContent);return r({monacoEditor:f}),e.watch(()=>t.language,(m,g)=>{m!==g&&f.setLanguage(m)}),e.watch([f.editor,u],([m,g])=>{m&&g&&m.updateOptions(g)},{deep:!0}),(m,g)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["monaco-editor-container",[t.appearance,c.value,{loading:l.value}]]),"data-testid":"monaco-editor-container"},[t.toolbar?(e.openBlock(),e.createBlock(qe,{key:0,editor:e.unref(f),settings:t.toolbar},e.createSlots({_:2},[m.$slots["toolbar-left"]?{name:"toolbar-left",fn:e.withCtx(()=>[e.renderSlot(m.$slots,"toolbar-left",{},void 0,!0)]),key:"0"}:void 0,m.$slots["toolbar-center"]?{name:"toolbar-center",fn:e.withCtx(()=>[e.renderSlot(m.$slots,"toolbar-center",{},void 0,!0)]),key:"1"}:void 0,m.$slots["toolbar-right"]?{name:"toolbar-right",fn:e.withCtx(()=>[e.renderSlot(m.$slots,"toolbar-right",{},void 0,!0)]),key:"2"}:void 0]),1032,["editor","settings"])):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"editorRef",ref:d,class:"monaco-editor-target","data-testid":"monaco-editor-target"},null,512),t.showLoadingState?e.renderSlot(m.$slots,"state-loading",{isLoading:l.value},()=>[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[l.value?(e.openBlock(),e.createBlock(z,{key:0,"data-testid":"monaco-editor-status-overlay-loading",icon:e.unref(S.ProgressIcon),message:e.unref(a).t("editor.messages.loading_message",{type:t.language}),title:e.unref(a).t("editor.messages.loading_title",{type:t.language})},null,8,["icon","message","title"])):e.createCommentVNode("",!0)]),_:1})],!0,1):e.createCommentVNode("",!0),t.showEmptyState?e.renderSlot(m.$slots,"state-empty",{isEmpty:b.value},()=>[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[b.value?(e.openBlock(),e.createBlock(z,{key:0,"data-testid":"monaco-editor-status-overlay-empty",icon:e.unref(S.CodeblockIcon),message:e.unref(f).editorStates.readOnly?e.unref(a).t("editor.messages.empty_message_readonly"):e.unref(a).t("editor.messages.empty_message"),title:e.unref(a).t("editor.messages.empty_title")},null,8,["icon","message","title"])):e.createCommentVNode("",!0)]),_:1})],!0,2):e.createCommentVNode("",!0)],2))}}),Ye=G(He,[["__scopeId","data-v-f3a56901"]]);function Xe(t){return async r=>(await Promise.all(t.map(o=>o(r)))).flat()}const Ze=/^Invalid input:\s*/;function Je(t){return t.replace(Ze,"")||t}function Qe(t){return r=>{const n=t.safeParse(r);return n.success?[]:n.error.issues.map(o=>({message:Je(o.message),path:o.path,code:o.code}))}}exports.collectCodeLensProviders=R.collectCodeLensProviders;exports.collectCodeLenses=R.collectCodeLenses;exports.createCopyUUIDCodeLens=R.createCopyUUIDCodeLens;exports.createCopyValueCodeLens=R.createCopyValueCodeLens;exports.emptyCodeLensList=R.emptyCodeLensList;exports.uuidRe=R.uuidRe;exports.getModelContext=J.getModelContext;exports.invalidateModelContexts=J.invalidateModelContexts;exports.MonacoEditor=Ye;exports.MonacoEditorStatusOverlay=z;exports.collectValidators=Xe;exports.createWrapAction=A;exports.createZodValidator=Qe;exports.useMonacoEditor=te;
7
+ \`\`\``}]);const a=u?l+1:l;n.setSelection({startLineNumber:a,startColumn:4,endLineNumber:a,endColumn:12})}else{const c=l>1?s.getLineContent(l-1):"",u=i<s.getLineCount()?s.getLineContent(i+1):"";if(c.trimEnd().startsWith("```")&&u.trimEnd()==="```")n.executeEdits(t,[{range:{startLineNumber:i+1,startColumn:1,endLineNumber:i+1,endColumn:s.getLineContent(i+1).length+1},text:null},{range:{startLineNumber:l-1,startColumn:1,endLineNumber:l-1,endColumn:s.getLineContent(l-1).length+1},text:null}]),n.setSelection({startLineNumber:l-1,startColumn:1,endLineNumber:i-1,endColumn:s.getLineContent(i-1).length+1});else{const a=s.getValueInRange(r),m=s.getValueInRange({startLineNumber:l,startColumn:1,endLineNumber:l,endColumn:r.startColumn}).trim().length>0,g=m?`
8
+ `:"";n.executeEdits(t,[{range:r,text:`${g}\`\`\`markdown
9
+ ${a}
10
+ \`\`\``}]);const C=m?l+1:l;n.setSelection({startLineNumber:C,startColumn:4,endLineNumber:C,endColumn:12})}}n.focus()}}}function qe(t){return o=>{const n=o.editor.value;if(!n)return;const r=n.getSelection(),s=n.getModel();if(!r||!s)return;const l=r.startLineNumber,i=r.endLineNumber;if(fe(s,l,i))return;const d=["| Header | Header | Header |","| ------ | ------ | ------ |","| Cell | Cell | Cell |","| Cell | Cell | Cell |"].join(`
11
+ `);n.executeEdits(t,[{range:r,text:d+`
12
+ `}]);const c=l+4;n.setPosition({lineNumber:c,column:1}),n.focus()}}function fe(t,o,n){let r=0,s=0;for(let l=o-1;l>=1;l--)t.getLineContent(l).trimEnd().startsWith("```")&&(s++,s%2===1&&(r=l));if(r===0)return!1;for(let l=n+1;l<=t.getLineCount();l++)if(t.getLineContent(l).trimEnd().startsWith("```"))return!0;return!1}const He={format:{id:"editor.action.format",icon:x.CleaningIcon,label:"editor.labels.action_format",action:"editor.action.formatDocument",keybindings:["Shift","Alt","F"],placement:"left",order:1,group:1,showInContextMenu:!0,contextMenuGroupId:"formatting",contextMenuOrder:1},bold:{id:"editor.action.bold",icon:x.BoldIcon,label:"editor.labels.action_bold",action:W("**","bold"),keybindings:["Command","B"],placement:"left",group:2,order:1,showInContextMenu:!0,contextMenuGroupId:"formatting",contextMenuOrder:2,languages:["markdown","mdc"]},italic:{id:"editor.action.italic",icon:x.ItalicIcon,label:"editor.labels.action_italic",action:W("_","italic"),keybindings:["Command","I"],placement:"left",group:2,order:2,showInContextMenu:!0,contextMenuGroupId:"formatting",contextMenuOrder:3,languages:["markdown","mdc"]},strikethrough:{id:"editor.action.strikethrough",icon:x.StrikethroughIcon,label:"editor.labels.action_strikethrough",action:W("~~","strikethrough"),keybindings:["Command","Shift","X"],placement:"left",group:2,order:3,showInContextMenu:!0,contextMenuGroupId:"formatting",contextMenuOrder:4,languages:["markdown","mdc"]}},Ye={inlineCode:{id:"editor.action.inlineCode",icon:x.CodeIcon,label:"editor.labels.action_inline_code",action:W("`","inlineCode"),keybindings:["Command","E"],placement:"left",group:3,order:1,showInContextMenu:!0,contextMenuGroupId:"insert",contextMenuOrder:1,languages:["markdown","mdc"]},link:{id:"editor.action.link",icon:x.LinkIcon,label:"editor.labels.action_link",action:te("[","](url)","link","url"),keybindings:["Command","K"],placement:"left",group:3,order:2,showInContextMenu:!0,contextMenuGroupId:"insert",contextMenuOrder:2,languages:["markdown","mdc"]},image:{id:"editor.action.image",icon:x.ImageIcon,label:"editor.labels.action_image",action:te("![","](url)","image","url"),keybindings:["Command","Shift","I"],placement:"left",group:3,order:3,showInContextMenu:!0,contextMenuGroupId:"insert",contextMenuOrder:3,languages:["markdown","mdc"]}},Xe={unorderedList:{id:"editor.action.unorderedList",icon:x.ListUnorderedIcon,label:"editor.labels.action_unordered_list",action:j("- ","unorderedList"),keybindings:[],placement:"left",group:4,order:1,showInContextMenu:!0,contextMenuGroupId:"list",contextMenuOrder:1,languages:["markdown","mdc"]},orderedList:{id:"editor.action.orderedList",icon:x.ListOrderedIcon,label:"editor.labels.action_ordered_list",action:j(t=>`${t}. `,"orderedList",/^\d+\.\s/),keybindings:[],placement:"left",group:4,order:2,showInContextMenu:!0,contextMenuGroupId:"list",contextMenuOrder:2,languages:["markdown","mdc"]},taskList:{id:"editor.action.taskList",icon:x.TasklistIcon,label:"editor.labels.action_task_list",action:j("- [ ] ","taskList"),keybindings:[],placement:"left",group:4,order:3,showInContextMenu:!0,contextMenuGroupId:"list",contextMenuOrder:3,languages:["markdown","mdc"]}},Ze={codeblock:{id:"editor.action.codeblock",icon:x.CodeblockIcon,label:"editor.labels.action_codeblock",action:ze("codeblock"),keybindings:[],placement:"left",group:5,order:1,showInContextMenu:!0,contextMenuGroupId:"block",contextMenuOrder:1,languages:["markdown","mdc"]},blockquote:{id:"editor.action.blockquote",icon:x.BlockquoteIcon,label:"editor.labels.action_blockquote",action:j("> ","blockquote"),keybindings:[],placement:"left",group:5,order:2,showInContextMenu:!0,contextMenuGroupId:"block",contextMenuOrder:2,languages:["markdown","mdc"]},table:{id:"editor.action.table",icon:x.TableIcon,label:"editor.labels.action_table",action:qe("table"),keybindings:[],placement:"left",group:5,order:3,showInContextMenu:!0,contextMenuGroupId:"block",contextMenuOrder:3,languages:["markdown","mdc"]}},Qe={search:{id:"editor.action.find",icon:x.SearchIcon,label:"editor.labels.action_search",action:t=>t.toggleSearchWidget(),keybindings:["Command","F"],placement:"right",order:10,group:2,showInContextMenu:!0,contextMenuGroupId:"navigation",contextMenuOrder:1}},Je={fullScreen:{id:"editor.action.fullScreen",icon:x.ExpandIcon,label:"editor.labels.action_fullscreen",action:t=>t.editor.value?.getContainerDomNode().requestFullscreen(),keybindings:["Ctrl","F11"],placement:"right",order:20,group:2,showInContextMenu:!0,contextMenuGroupId:"view",contextMenuOrder:1}},ne={...He,...Ye,...Xe,...Ze,...Qe,...Je},oe="left",Y=100,et="default";function tt(t,o){const{i18n:n}=_(),r=t&&typeof t=="object"?t.actions??{}:{},s=e.computed(()=>{const i=[],d=e.unref(o);for(const[c,u]of Object.entries(ne)){const f=r[c];f!==!1&&(u.languages&&d&&!u.languages.includes(d)||i.push({...u,label:n.t(u.label),...typeof f=="object"?f:{}}))}for(const[c,u]of Object.entries(r)){if(c in ne||u===!1||u==null)continue;const f={id:c,label:typeof u=="object"&&u.label?u.label:c,placement:oe,order:Y},a=typeof u=="object"?{...f,...u}:f;a.icon&&a.action&&i.push(a)}return i});function l(i){const d=new Map;return s.value.filter(c=>(c.placement??oe)===i).sort((c,u)=>(c.order??Y)-(u.order??Y)).forEach(c=>{const u=String(c.group??et);d.has(u)||d.set(u,[]),d.get(u).push(c)}),Array.from(d.values())}return{commands:s,leftGroups:e.computed(()=>l("left")),centerGroups:e.computed(()=>l("center")),rightGroups:e.computed(()=>l("right"))}}const nt={class:"monaco-editor-ui-toolbar-action-group","data-testid":"toolbar-overflow-group"},ot=5,rt=e.defineComponent({__name:"MonacoEditorToolbar",props:{editor:{default:null},settings:{type:[Boolean,Object]}},setup(t){const{i18n:o}=_(),n=e.useTemplateRef("toolbarEl"),r=e.useTemplateRef("leftSlotEl"),s=e.useTemplateRef("centerSlotEl"),l=e.useTemplateRef("rightSlotEl"),i=U(n),d=U(r),c=U(s),u=U(l),f=e.computed(()=>t.editor?.editorStates.currentLanguage??""),{commands:a,leftGroups:p,centerGroups:m,rightGroups:g}=tt(t.settings,f),C=e.shallowRef([]),b=e.ref(0),h=[],k=e.computed(()=>p.value.slice(C.value.length).flatMap((v,L)=>v.map((N,O)=>({...N,hasDivider:L>0&&O===0}))));e.watch(p,v=>{C.value=[...v],h.length=0},{immediate:!0});function w(){const v=n.value?.getBoundingClientRect().width??0;if(v===0)return;const L=r.value?.getBoundingClientRect().width??0,N=s.value?.getBoundingClientRect().width??0,O=l.value?.getBoundingClientRect().width??0,M=L+N+O+50;v<M&&C.value.length>0?(h.push(M),C.value=C.value.slice(0,-1),b.value++,e.nextTick(w)):h.length>0&&C.value.length<p.value.length&&v>h[h.length-1]+ot&&(h.pop(),C.value=[...C.value,p.value[C.value.length]],e.nextTick(w))}return e.watch(()=>t.editor?.editorStates.editorStatus,v=>{v==="ready"&&t.editor&&a.value.length>0&&t.editor.registerActions(a.value)},{immediate:!0}),e.watch([i.width,d.width,c.width,u.width],w),e.onMounted(async()=>await e.nextTick(w)),(v,L)=>{const N=e.resolveComponent("KDropdownItem"),O=e.resolveComponent("KDropdown");return e.openBlock(),e.createElementBlock("div",{ref_key:"toolbarEl",ref:n,class:"monaco-editor-ui-toolbar","data-testid":"monaco-editor-toolbar"},[e.createElementVNode("div",{ref_key:"leftSlotEl",ref:r,class:"monaco-editor-ui-toolbar-left","data-testid":"monaco-editor-toolbar-left"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C.value,(M,I)=>(e.openBlock(),e.createElementBlock("div",{key:I,class:"monaco-editor-ui-toolbar-action-group"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M,y=>(e.openBlock(),e.createBlock(G,{key:y.id,active:t.editor?.editorStates.editorStatus==="ready",item:{id:y.id,label:y.label,icon:y.icon,keybindings:y.keybindings,action:()=>e.unref(K)(y,t.editor)},placement:I===0?"bottom-start":"bottom"},null,8,["active","item","placement"]))),128))]))),128)),e.withDirectives(e.createElementVNode("div",nt,[(e.openBlock(),e.createBlock(O,{key:b.value,class:e.normalizeClass({"is-disabled":t.editor?.editorStates.editorStatus!=="ready"})},{items:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.value,M=>(e.openBlock(),e.createBlock(N,{key:M.id,"data-testid":`overflow-item-${M.id}`,"has-divider":M.hasDivider,onClick:I=>e.unref(K)(M,t.editor)},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(M.icon),{decorative:""})),e.createTextVNode(" "+e.toDisplayString(M.label),1)]),_:2},1032,["data-testid","has-divider","onClick"]))),128))]),default:e.withCtx(()=>[e.createVNode(G,{active:t.editor?.editorStates.editorStatus==="ready",item:{id:"more",label:e.unref(o).t("editor.labels.action_more"),icon:e.unref(x.MoreIcon)},placement:"bottom"},null,8,["active","item"])]),_:1},8,["class"]))],512),[[e.vShow,k.value.length]]),e.renderSlot(v.$slots,"toolbar-left",{},void 0,!0)],512),e.createElementVNode("div",{ref_key:"centerSlotEl",ref:s,class:"monaco-editor-ui-toolbar-center","data-testid":"monaco-editor-toolbar-center"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(m),(M,I)=>(e.openBlock(),e.createElementBlock("div",{key:I,class:"monaco-editor-ui-toolbar-action-group"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M,y=>(e.openBlock(),e.createBlock(G,{key:y.id,active:t.editor?.editorStates.editorStatus==="ready",item:{id:y.id,label:y.label,icon:y.icon,keybindings:y.keybindings,action:()=>e.unref(K)(y,t.editor)},placement:"bottom"},null,8,["active","item"]))),128))]))),128)),e.renderSlot(v.$slots,"toolbar-center",{},void 0,!0)],512),e.createElementVNode("div",{ref_key:"rightSlotEl",ref:l,class:"monaco-editor-ui-toolbar-right","data-testid":"monaco-editor-toolbar-right"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),(M,I)=>(e.openBlock(),e.createElementBlock("div",{key:I,class:"monaco-editor-ui-toolbar-action-group"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M,y=>(e.openBlock(),e.createBlock(G,{key:y.id,active:t.editor?.editorStates.editorStatus==="ready",item:{id:y.id,label:y.label,icon:y.icon,keybindings:y.keybindings,action:()=>e.unref(K)(y,t.editor)},placement:I===e.unref(g).length-1?"bottom-end":"bottom"},null,8,["active","item","placement"]))),128))]))),128)),e.renderSlot(v.$slots,"toolbar-right",{},void 0,!0)],512)],512)}}}),at=P(rt,[["__scopeId","data-v-b6dd2107"]]),it=e.defineComponent({__name:"MonacoEditor",props:e.mergeModels({appearance:{default:"embedded"},theme:{default:"light"},language:{default:"markdown"},toolbar:{type:[Boolean,Object],default:!1},loading:{type:Boolean,default:!1},options:{default:()=>{}},showLoadingState:{type:Boolean,default:!0},showEmptyState:{type:Boolean,default:!0}},{modelValue:{type:String,required:!0},modelModifiers:{}}),emits:e.mergeModels(["ready"],["update:modelValue"]),setup(t,{expose:o,emit:n}){const r=parseInt(se,10),s=n,l=e.useModel(t,"modelValue"),{i18n:i}=_(),d=e.useTemplateRef("editorRef"),c=e.computed(()=>t.theme==="dark"?"dark":"light"),u=e.computed(()=>{if(t.appearance==="standalone"){const m=String(l.value.split(`
13
+ `).length).length;return{...t.options,padding:{top:r,bottom:r},lineNumbersMinChars:Math.max(B.lineNumbersMinChars,m)+2}}return{padding:{...B.padding},lineNumbersMinChars:B.lineNumbersMinChars,...t.options}}),f=ge(d,{language:t.language,code:l,theme:c.value,monacoOptions:u.value,onReady:m=>{s("ready",m)}}),a=e.computed(()=>t.loading||f.editorStates.editorStatus==="loading"),p=e.computed(()=>!a.value&&f.editorStates.editorStatus==="ready"&&!f.editorStates.hasContent);return o({monacoEditor:f}),e.watch(()=>t.language,(m,g)=>{m!==g&&f.setLanguage(m)}),e.watch([f.editor,u],([m,g])=>{m&&g&&m.updateOptions(g)},{deep:!0}),(m,g)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["monaco-editor-container",[t.appearance,c.value,{loading:a.value}]]),"data-testid":"monaco-editor-container"},[t.toolbar?(e.openBlock(),e.createBlock(at,{key:0,editor:e.unref(f),settings:t.toolbar},e.createSlots({_:2},[m.$slots["toolbar-left"]?{name:"toolbar-left",fn:e.withCtx(()=>[e.renderSlot(m.$slots,"toolbar-left",{},void 0,!0)]),key:"0"}:void 0,m.$slots["toolbar-center"]?{name:"toolbar-center",fn:e.withCtx(()=>[e.renderSlot(m.$slots,"toolbar-center",{},void 0,!0)]),key:"1"}:void 0,m.$slots["toolbar-right"]?{name:"toolbar-right",fn:e.withCtx(()=>[e.renderSlot(m.$slots,"toolbar-right",{},void 0,!0)]),key:"2"}:void 0]),1032,["editor","settings"])):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"editorRef",ref:d,class:"monaco-editor-target","data-testid":"monaco-editor-target"},null,512),t.showLoadingState?e.renderSlot(m.$slots,"state-loading",{isLoading:a.value},()=>[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[a.value?(e.openBlock(),e.createBlock(z,{key:0,"data-testid":"monaco-editor-status-overlay-loading",icon:e.unref(x.ProgressIcon),message:e.unref(i).t("editor.messages.loading_message",{type:t.language}),title:e.unref(i).t("editor.messages.loading_title",{type:t.language})},null,8,["icon","message","title"])):e.createCommentVNode("",!0)]),_:1})],!0,1):e.createCommentVNode("",!0),t.showEmptyState?e.renderSlot(m.$slots,"state-empty",{isEmpty:p.value},()=>[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(z,{key:0,"data-testid":"monaco-editor-status-overlay-empty",icon:e.unref(x.CodeblockIcon),message:e.unref(f).editorStates.readOnly?e.unref(i).t("editor.messages.empty_message_readonly"):e.unref(i).t("editor.messages.empty_message"),title:e.unref(i).t("editor.messages.empty_title")},null,8,["icon","message","title"])):e.createCommentVNode("",!0)]),_:1})],!0,2):e.createCommentVNode("",!0)],2))}}),lt=P(it,[["__scopeId","data-v-f3a56901"]]),q="[monaco-editor] [lifecycle]",D=new WeakMap,V=new Map,X=new WeakMap;function st(t){let o=D.get(t.source);if(!o){let n;switch(t.type){case"editor":n=t.source.onDidDispose(()=>ie(t.source));break;case"model":n=t.source.onWillDispose(()=>ie(t.source));break;default:throw new Error(`${q} Unknown scope: ${t}`)}o={disposables:new Set,scopeListener:n},D.set(t.source,o)}return o}function pe(t){const o=D.get(t);o&&(o.scopeListener.dispose(),D.delete(t))}function re(t,o){st(o).disposables.add(t)}function ae(t,o){const n=D.get(o.source);n&&(n.disposables.delete(t),n.disposables.size===0&&pe(o.source))}function ct(t){const o=[];if(t.forEach(n=>{try{n.dispose()}catch(r){o.push(r)}}),o.length)throw new AggregateError(o,`${q} One or more disposables threw while being disposed.`)}function dt(t,o){let n=t,r=V.get(n);if(!r){const i=X.get(t);i&&(n=i,r=V.get(i))}if(r)return r.scope?.type===o?.type&&r.scope?.source===o?.source||(console.warn(`${q} Re-scoping a tracked disposable from`,r.scope,"to",o,".","The scope usually should not change after being tracked. This may sometimes indicate a programming error."),r.scope&&ae(r.decorated,r.scope),o?(re(r.decorated,o),r.scope=o):r.scope=void 0),r.decorated;const s=n.dispose,l={dispose:()=>{const i=V.get(n);if(i)return i.scope&&ae(l,i.scope),V.delete(n),X.delete(l),s.call(n)}};return V.set(n,{decorated:l,scope:o}),X.set(l,n),o&&re(l,o),l}function ut(t,o){return dt(o,{type:"model",source:t})}function ie(t){const o=D.get(t);if(o){try{ct(Array.from(o.disposables))}catch(n){console.warn(`${q} Encountered errors while disposing scoped disposables:`,n,", Source:",t)}pe(t)}}function he(t,o){const n=e.shallowRef();let r,s,l,i=!1;const d=e.reactive({editorStatus:"loading",searchBoxIsRevealed:!1,hasContent:!1,theme:o.theme||"light",currentLanguage:o.language||"",readOnly:!0}),c=a=>{for(const p of[r,s])p&&S.editor.setModelLanguage(p,a)},u=ce(()=>S.editor.remeasureFonts(),200);return ue(),e.watch([Q,()=>e.toValue(t)],([a,p],[,m])=>{const g=e.toValue(p),C=e.toValue(m);if(!(g instanceof HTMLElement)||!a){i=!1;return}if(i&&C===g)return;r=Z(r,e.toValue(o.original),o.language,"diff-original"),s=Z(s,e.toValue(o.modified),o.language,"diff-modified");const b=me(d.theme);S.editor.setTheme(b),n.value=S.editor.createDiffEditor(g,{...xe,theme:b,editContext:!1,...o.monacoOptions}),n.value.setModel({original:r,modified:s}),i=!0,d.editorStatus="ready",d.hasContent=!!e.toValue(o.modified),d.currentLanguage=s.getLanguageId(),l?.dispose(),l=ut(s,s.onDidChangeLanguage(h=>{d.currentLanguage=h.newLanguage})),o.onReady?.(n.value),u(),e.onWatcherCleanup(()=>{n.value?.setModel(null),n.value?.dispose()})},{immediate:!0,flush:"post"}),e.watch(()=>e.toValue(o.original),a=>{!r||!i||a!==r.getValue()&&r.setValue(a)}),e.watch(()=>e.toValue(o.modified),a=>{!s||!i||a!==s.getValue()&&(s.setValue(a),d.hasContent=!!a.length)}),e.onMounted(u),e.onActivated(u),e.onBeforeUnmount(()=>{n.value?.setModel(null),n.value?.dispose(),r?.dispose(),s?.dispose(),r=void 0,s=void 0}),{diffEditor:n,editorStates:d,setLanguage:c,remeasureFonts:u}}const mt=e.defineComponent({__name:"MonacoDiffEditor",props:{original:{},modified:{},appearance:{default:"embedded"},theme:{default:"light"},language:{default:"markdown"},options:{default:()=>{}},loading:{type:Boolean,default:!1},showLoadingState:{type:Boolean,default:!0}},emits:["ready"],setup(t,{expose:o,emit:n}){const r=parseInt(se,10),s=n,{i18n:l}=_(),i=e.useTemplateRef("editorRef"),d=e.computed(()=>t.theme==="dark"?"dark":"light"),c=e.computed(()=>{if(t.appearance==="standalone"){const a=t.original.split(`
14
+ `).length,p=t.modified.split(`
15
+ `).length,m=String(Math.max(a,p)).length;return{...t.options,padding:{top:r,bottom:r},lineNumbersMinChars:Math.max(B.lineNumbersMinChars,m)+2}}return{padding:{...B.padding},lineNumbersMinChars:B.lineNumbersMinChars,...t.options}}),u=he(i,{language:t.language,original:()=>t.original,modified:()=>t.modified,theme:d.value,monacoOptions:c.value,onReady:a=>{s("ready",a)}}),f=e.computed(()=>t.loading||u.editorStates.editorStatus==="loading");return o({monacoDiffEditor:u}),e.watch(()=>t.language,(a,p)=>{a!==p&&u.setLanguage(a)}),e.watch([u.diffEditor,c],([a,p])=>{a&&p&&a.updateOptions(p)},{deep:!0}),(a,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["monaco-diff-editor-container",[t.appearance,d.value,{loading:f.value}]]),"data-testid":"monaco-diff-editor-container"},[e.createElementVNode("div",{ref_key:"editorRef",ref:i,class:"monaco-diff-editor-target","data-testid":"monaco-diff-editor-target"},null,512),t.showLoadingState?e.renderSlot(a.$slots,"state-loading",{isLoading:f.value},()=>[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[f.value?(e.openBlock(),e.createBlock(z,{key:0,"data-testid":"monaco-diff-editor-status-overlay-loading",icon:e.unref(x.ProgressIcon),message:e.unref(l).t("editor.messages.loading_message",{type:t.language}),title:e.unref(l).t("editor.messages.loading_title",{type:t.language})},null,8,["icon","message","title"])):e.createCommentVNode("",!0)]),_:1})],!0,0):e.createCommentVNode("",!0)],2))}}),gt=P(mt,[["__scopeId","data-v-26462125"]]);function ft(t){return async o=>(await Promise.all(t.map(r=>r(o)))).flat()}const pt=/^Invalid input:\s*/;function ht(t){return t.replace(pt,"")||t}function bt(t){return o=>{const n=t.safeParse(o);return n.success?[]:n.error.issues.map(r=>({message:ht(r.message),path:r.path,code:r.code}))}}exports.collectCodeLensProviders=A.collectCodeLensProviders;exports.collectCodeLenses=A.collectCodeLenses;exports.createCopyUUIDCodeLens=A.createCopyUUIDCodeLens;exports.createCopyValueCodeLens=A.createCopyValueCodeLens;exports.emptyCodeLensList=A.emptyCodeLensList;exports.uuidRe=A.uuidRe;exports.getModelContext=le.getModelContext;exports.invalidateModelContexts=le.invalidateModelContexts;exports.MonacoDiffEditor=gt;exports.MonacoEditor=lt;exports.MonacoEditorStatusOverlay=z;exports.collectValidators=ft;exports.createWrapAction=W;exports.createZodValidator=bt;exports.useMonacoDiffEditor=he;exports.useMonacoEditor=ge;