import { jsxs as _, jsx as w } from "react/jsx-runtime";
import G, { useEffect as J, createContext as ge, useState as z, useRef as re, useContext as ue, memo as Re } from "react";
import { loader as xe, useMonaco as we, Editor as Fe } from "@monaco-editor/react";
import { getNodeInfo as Le, DesignerRequestVerb as ke, lspSubject as We, LspActions as X, hasAttributesString as de, FileFolderType as oe, SourceCodeDescriptor as je, HTTP_HANDLERS_TAB_PATH as Ee } from "@ws-ui/shared";
import { MonacoLanguageClient as Ze } from "monaco-languageclient";
import { mergeServices as Xe, initServices as Ke } from "monaco-languageclient/vscode/services";
import Be, { initUserConfiguration as De } from "@codingame/monaco-vscode-configuration-service-override";
import Te from "@codingame/monaco-vscode-languages-service-override";
import Oe from "@codingame/monaco-vscode-textmate-service-override";
import "@codingame/monaco-vscode-theme-defaults-default-extension";
import Ge from "@codingame/monaco-vscode-editor-service-override";
import Me from "@codingame/monaco-vscode-theme-service-override";
import { registerFileSystemOverlay as Je } from "@codingame/monaco-vscode-files-service-override";
import { FileSystemProviderCapabilities as se, FileType as Pe } from "vscode/vscode/vs/platform/files/common/files";
import { Emitter as ae } from "vscode/vscode/vs/base/common/event";
import { Logger as Ve } from "monaco-languageclient/tools";
import { CloseAction as Ye, ErrorAction as He } from "vscode-languageclient";
import * as a from "monaco-editor";
import { Selection as _e, KeyMod as T, KeyCode as O, editor as Ie, Range as ze, Uri as $e, CancellationTokenSource as Ue } from "monaco-editor";
import { WebSocketMessageReader as qe, WebSocketMessageWriter as Qe, toSocket as et } from "vscode-ws-jsonrpc";
import { DocumentDiagnosticRequest as tt, TextDocumentSaveReason as nt, WillSaveTextDocumentNotification as it, DidSaveTextDocumentNotification as ot, WillCreateFilesRequest as rt, WillRenameFilesRequest as st, WillDeleteFilesRequest as at, DidCreateFilesNotification as lt, DidRenameFilesNotification as ct, DidDeleteFilesNotification as gt, SemanticTokensRegistrationType as ut } from "vscode-languageserver-protocol";
import { StandaloneServices as dt, ICodeEditorService as It } from "vscode/services";
import { KeybindingsRegistry as ne } from "vscode/monaco";
import "@codingame/monaco-vscode-standalone-languages";
import "@codingame/monaco-vscode-standalone-html-language-features";
import "@codingame/monaco-vscode-standalone-css-language-features";
import "@codingame/monaco-vscode-standalone-json-language-features";
import "@codingame/monaco-vscode-standalone-typescript-language-features";
import "@codingame/monaco-vscode-css-default-extension";
import "@codingame/monaco-vscode-json-default-extension";
import "@codingame/monaco-vscode-html-default-extension";
import "@codingame/monaco-vscode-javascript-default-extension";
import { registerExtension as Ct } from "vscode/extensions";
const mt = () => Be(), ft = () => Ge(
  () => Promise.resolve(void 0)
), pt = () => {
  const t = Me(), e = t.themeService.ctor.prototype;
  return e.defineTheme = () => {
  }, t;
}, At = `{
  "workbench.colorTheme": "Default Dark+",
  "workbench.iconTheme": "vs-seti",
  "editor.autoClosingBrackets": "languageDefined",
  "editor.autoClosingQuotes": "languageDefined",
  "editor.scrollBeyondLastLine": true,
  "editor.mouseWheelZoom": true,
  "editor.wordBasedSuggestions": false,
  "editor.acceptSuggestionOnEnter": "on",
  "editor.foldingHighlight": false,
  "editor.bracketPairColorization.enabled": false,
  "editor.fontSize": 12,
  "files.autoSave": "off",
  "editor.experimental.asyncTokenization": true,
  "editor.semanticHighlighting.enabled": true,
  "workbench.colorCustomizations": {
    "editor.background": "#313131"
  },
  "editor.semanticTokenColorCustomizations": {
    "[Default Light+]": {
      "enabled": true,
      "rules": {
        "*:4d": {
          "foreground": "#000000",
          "bold": false,
          "italic": false,
          "underline": false,
          "strikethrough": false
        },
        "method:4d": { "foreground": "#000088", "bold": true, "italic": true },
        "method.defaultLibrary:4d": {
          "foreground": "#068c00",
          "italic": false
        },
        "method.plugin:4d": { "foreground": "#000000" },
        "property:4d": { "foreground": "#a0806b" },
        "function:4d": { "foreground": "#5f8e5e", "italic": true },
        "parameter:4d": { "foreground": "#000b76", "bold": true },
        "variable.interprocess:4d": { "foreground": "#ff0088" },
        "variable.process:4d": { "foreground": "#0000ff" },
        "variable.local:4d": { "foreground": "#0031ff" },
        "keyword:4d": { "foreground": "#034d00", "bold": true },
        "table:4d": { "foreground": "#532300" },
        "field:4d": { "foreground": "#323232" },
        "comment:4d": { "foreground": "#535353" },
        "type:4d": { "foreground": "#068c00", "bold": true },
        "constant:4d": { "foreground": "#4d004d", "underline": true },
        "string:4d": { "foreground": "#000000" },
        "error:4d": { "foreground": "#ff0000", "bold": true, "italic": true }
      }
    },
    "[Default Dark+]": {
      "enabled": true,
      "rules": {
        "*:4d": {
          "foreground": "#FFFFFF",
          "bold": false,
          "italic": false,
          "underline": false,
          "strikethrough": false
        },
        "method:4d": { "foreground": "#1B79F3", "bold": true, "italic": true },
        "method.defaultLibrary:4d": {
          "foreground": "#59BB00",
          "italic": false
        },
        "method.plugin:4d": { "foreground": "#BFBFBF" },
        "property:4d": { "foreground": "#A0806B" },
        "function:4d": { "foreground": "#4EC36E", "italic": true },
        "parameter:4d": { "foreground": "#0C70FF", "bold": true },
        "variable.interprocess:4d": { "foreground": "#FF0088" },
        "variable.process:4d": { "foreground": "#53B0EB" },
        "variable.local:4d": { "foreground": "#18B3F1" },
        "keyword:4d": { "foreground": "#D0D0D0", "bold": true },
        "table:4d": { "foreground": "#CF5600" },
        "field:4d": { "foreground": "#9C6765" },
        "comment:4d": { "foreground": "#8F8F8F" },
        "type:4d": { "foreground": "#068C00", "bold": true },
        "constant:4d": { "foreground": "#FA647F", "underline": true },
        "string:4d": { "foreground": "#FFFFFF" },
        "error:4d": { "foreground": "#ff0000", "bold": true, "italic": true }
      }
    }
  }
}
`;
class bt {
  constructor() {
    this._onDidChangeCapabilities = new ae(), this.onDidChangeCapabilities = this._onDidChangeCapabilities.event, this._onDidChangeFile = new ae(), this.onDidChangeFile = this._onDidChangeFile.event, this.capabilities = se.FileReadWrite | se.FileOpenReadWriteClose, this.files = /* @__PURE__ */ new Map();
  }
  // --- stat()
  async stat(e) {
    const n = this.files.get(e.fsPath), i = Date.now();
    return {
      type: Pe.File,
      ctime: 0,
      mtime: i,
      size: n ? n.byteLength : 0
    };
  }
  // --- mkdir()
  async mkdir(e) {
  }
  // --- readdir()
  async readdir(e) {
    return [];
  }
  // --- readFile()
  async readFile(e) {
    const i = e.toString().split("/"), o = i.length, [r, s] = i.slice(o - 2), I = await Le({
      verb: ke.GET_INFO,
      path: `${r}/${s}`,
      content: !0,
      as: "text"
    }), C = new TextEncoder().encode(I.content);
    return this.files.set(e.fsPath, C), C;
  }
  // --- writeFile()
  async writeFile(e, n) {
    const i = e.toString();
    this.files.set(i, n), this._onDidChangeFile.fire([
      { type: 1, resource: e }
      // FileChangeType.Updated
    ]);
  }
  // --- delete()
  async delete(e) {
    const n = e.toString();
    this.files.delete(n);
  }
  // --- rename()
  async rename(e, n) {
    const i = e.toString(), o = n.toString(), r = this.files.get(i);
    r && (this.files.set(o, r), this.files.delete(i));
  }
  // --- watch()
  watch(e, n) {
    return { dispose() {
    } };
  }
}
const ht = () => De(At), vt = async (t) => {
  var o;
  const e = t.serviceConfig ?? {};
  e.debugLogging = ((o = t.logger) == null ? void 0 : o.isEnabled()) === !0 && (e.debugLogging === !0 || t.logger.isDebugEnabled() === !0), await ht(), e.userServices = e.userServices ?? {};
  const n = e.userServices.configurationService ?? void 0, i = e.workspaceConfig ?? void 0;
  if (n === void 0) {
    if (i)
      throw new Error(
        "You provided a workspaceConfig without using the configurationServiceOverride"
      );
    const r = {
      // @see https://github.com/CodinGame/monaco-vscode-api#monaco-standalone-services
      ...mt(),
      ...pt(),
      ...Oe(),
      ...Te(),
      ...ft()
    };
    Xe(r, e.userServices);
  }
  return Je(1, new bt()), e;
};
class St extends qe {
  constructor(e, n) {
    super(e), this.onMessage = n;
  }
  readMessage(e) {
    this.onMessage && this.onMessage();
    const [, n] = e.split(`\r
\r
`);
    if (this.state === "initial")
      this.events.splice(0, 0, { message: n });
    else if (this.state === "listening") {
      const i = JSON.parse(n);
      this.callback(i);
    }
  }
}
class yt extends Qe {
  constructor(e, n) {
    super(e), this.onSend = n;
  }
  async write(e) {
    try {
      const n = JSON.stringify(e);
      this.socket.send(n), this.onSend && this.onSend();
    } catch (n) {
      this.errorCount++, this.fireError(n, e, this.errorCount);
    }
  }
}
function E(t, e = !0) {
  const n = `/PACKAGE/Project/Sources/${t}`;
  return e ? `file://${n}` : n;
}
function Ce(t, e = 0) {
  setTimeout(t, e);
}
function Nt(t, e) {
  const n = new _e(
    e.startLineNumber,
    e.startColumn,
    e.endLineNumber || e.startLineNumber,
    e.endColumn || e.startColumn
  );
  Ce(() => {
    t.setSelection(n), t.revealRangeInCenter(n), t.focus();
  });
}
function Rt(t, e, n = 0) {
  n > 0 && (e = n + e), Ce(() => {
    t.setPosition({ lineNumber: e, column: 1 }), t.revealLineInCenter(e), t.focus();
  });
}
function On(t, e, n) {
  const o = t.getModel();
  if (o && e) {
    const r = o.getLineCount();
    for (let s = 1; s <= r; s++) {
      const I = o.getLineContent(s);
      if (new RegExp(`(?:Function|function) ${n}`).test(I))
        return s;
    }
  }
  return 0;
}
const xt = (t) => {
  const e = t == null ? void 0 : t.getLanguageId();
  return e && ["css", "scss", "less"].includes(e);
}, wt = {
  provideCompletionItems: async (t, e) => {
    const n = t.getWordUntilPosition(e);
    return {
      suggestions: [
        {
          label: "var",
          kind: a.languages.CompletionItemKind.Snippet,
          range: new a.Range(
            e.lineNumber,
            n.startColumn,
            e.lineNumber,
            n.endColumn
          ),
          insertText: ["var ${1:var_name} : ${2:var_type}"].join(`
`),
          insertTextRules: a.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "While",
          kind: a.languages.CompletionItemKind.Snippet,
          range: new a.Range(
            e.lineNumber,
            n.startColumn,
            e.lineNumber,
            n.endColumn
          ),
          insertText: [
            "While(${1:expression})",
            "	${2:body}",
            "End while"
          ].join(`
`),
          insertTextRules: a.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "Case of",
          kind: a.languages.CompletionItemKind.Snippet,
          range: new a.Range(
            e.lineNumber,
            n.startColumn,
            e.lineNumber,
            n.endColumn
          ),
          insertText: [
            "Case of",
            "	:(${1:boolean_expression})",
            "		${2:body}",
            "End case"
          ].join(`
`),
          insertTextRules: a.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "Else",
          kind: a.languages.CompletionItemKind.Snippet,
          range: new a.Range(
            e.lineNumber,
            n.startColumn,
            e.lineNumber,
            n.endColumn
          ),
          insertText: ["Else", "	"].join(`
`),
          insertTextRules: a.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "If",
          kind: a.languages.CompletionItemKind.Snippet,
          range: new a.Range(
            e.lineNumber,
            n.startColumn,
            e.lineNumber,
            n.endColumn
          ),
          insertText: ["If (${1:expression})", "	${5:body}", "End if"].join(
            `
`
          ),
          insertTextRules: a.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "For",
          kind: a.languages.CompletionItemKind.Snippet,
          range: new a.Range(
            e.lineNumber,
            n.startColumn,
            e.lineNumber,
            n.endColumn
          ),
          insertText: [
            "For(${1:counter};${2:start};${3:end}${4:;increment})",
            "	${5:body}",
            "End for"
          ].join(`
`),
          insertTextRules: a.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "Function",
          kind: a.languages.CompletionItemKind.Snippet,
          range: new a.Range(
            e.lineNumber,
            n.startColumn,
            e.lineNumber,
            n.endColumn
          ),
          insertText: [
            "Function ${1:function_name}(${2:params}) -> ${3:var_name} : ${4:var_type}",
            "	${5:body}"
          ].join(`
`),
          insertTextRules: a.languages.CompletionItemInsertTextRule.InsertAsSnippet
        }
      ]
    };
  }
}, Ft = {
  provideCompletionItems: async (t, e) => {
    const n = t.getWordUntilPosition(e);
    return {
      suggestions: [
        {
          label: "var",
          kind: a.languages.CompletionItemKind.Snippet,
          range: new a.Range(
            e.lineNumber,
            n.startColumn,
            e.lineNumber,
            n.endColumn
          ),
          insertText: ["var ${1:var_name} : ${2:var_type}"].join(`
`),
          insertTextRules: a.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "while",
          kind: a.languages.CompletionItemKind.Snippet,
          range: new a.Range(
            e.lineNumber,
            n.startColumn,
            e.lineNumber,
            n.endColumn
          ),
          insertText: ["while(${1:expression})", "	${2:body}", "end"].join(
            `
`
          ),
          insertTextRules: a.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "switch",
          kind: a.languages.CompletionItemKind.Snippet,
          range: new a.Range(
            e.lineNumber,
            n.startColumn,
            e.lineNumber,
            n.endColumn
          ),
          insertText: [
            "switch",
            "	:(${1:boolean_expression})",
            "		${2:body}",
            "end"
          ].join(`
`),
          insertTextRules: a.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "else",
          kind: a.languages.CompletionItemKind.Snippet,
          range: new a.Range(
            e.lineNumber,
            n.startColumn,
            e.lineNumber,
            n.endColumn
          ),
          insertText: ["else", "	"].join(`
`),
          insertTextRules: a.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "if",
          kind: a.languages.CompletionItemKind.Snippet,
          range: new a.Range(
            e.lineNumber,
            n.startColumn,
            e.lineNumber,
            n.endColumn
          ),
          insertText: ["if (${1:expression})", "	${5:body}", "end"].join(
            `
`
          ),
          insertTextRules: a.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "for",
          kind: a.languages.CompletionItemKind.Snippet,
          range: new a.Range(
            e.lineNumber,
            n.startColumn,
            e.lineNumber,
            n.endColumn
          ),
          insertText: [
            "for(${1:counter},${2:start},${3:end}${4:,increment})",
            "	${5:body}",
            "end"
          ].join(`
`),
          insertTextRules: a.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "function",
          kind: a.languages.CompletionItemKind.Snippet,
          range: new a.Range(
            e.lineNumber,
            n.startColumn,
            e.lineNumber,
            n.endColumn
          ),
          insertText: [
            "function ${1:function_name}(${2:params}) -> ${3:var_name} : ${4:var_type}",
            "	${5:body}"
          ].join(`
`),
          insertTextRules: a.languages.CompletionItemInsertTextRule.InsertAsSnippet
        }
      ]
    };
  }
}, Lt = [
  // zoom in
  {
    keybinding: T.CtrlCmd | O.NumpadAdd,
    command: "editor.action.fontZoomIn"
  },
  {
    keybinding: T.CtrlCmd | O.Equal,
    command: "editor.action.fontZoomIn"
  },
  // zoom out
  {
    keybinding: T.CtrlCmd | O.NumpadSubtract,
    command: "editor.action.fontZoomOut"
  },
  {
    keybinding: T.CtrlCmd | O.Minus,
    command: "editor.action.fontZoomOut"
  },
  // zoom reset
  {
    keybinding: T.CtrlCmd | O.Numpad0,
    command: "editor.action.fontZoomReset"
  },
  {
    keybinding: T.CtrlCmd | O.Digit0,
    command: "editor.action.fontZoomReset"
  },
  // go to definition
  {
    keybinding: T.CtrlCmd | O.F12,
    command: "editor.action.revealDefinition"
  }
], kt = ({ defaultZoom: t }) => (J(() => {
  t !== void 0 && Ie.EditorZoom.setZoomLevel(t);
}, []), null);
xe.config({
  monaco: a
  // paths: {
  //   vs: import.meta.env.VITE_MONACO_EDITOR_CDN,
  // },
});
var H = /* @__PURE__ */ ((t) => (t[t.NotSet = -1] = "NotSet", t[t.None = 0] = "None", t[t.Italic = 1] = "Italic", t[t.Bold = 2] = "Bold", t[t.Underline = 4] = "Underline", t[t.Strikethrough = 8] = "Strikethrough", t))(H || {}), me = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.DefaultForeground = 1] = "DefaultForeground", t[t.DefaultBackground = 2] = "DefaultBackground", t))(me || {}), fe = /* @__PURE__ */ ((t) => (t[t.Other = 0] = "Other", t[t.Comment = 1] = "Comment", t[t.String = 2] = "String", t[t.RegEx = 3] = "RegEx", t))(fe || {});
class V {
  static getLanguageId(e) {
    return (e & 255) >>> 0;
  }
  static getTokenType(e) {
    return (e & 768) >>> 8;
  }
  static containsBalancedBrackets(e) {
    return (e & 1024) !== 0;
  }
  static getFontStyle(e) {
    return (e & 30720) >>> 11;
  }
  static getForeground(e) {
    return (e & 16744448) >>> 15;
  }
  static getBackground(e) {
    return (e & 4278190080) >>> 24;
  }
  static getClassNameFromMetadata(e) {
    let i = "mtk" + this.getForeground(e);
    const o = this.getFontStyle(e);
    return o & 1 && (i += " mtki"), o & 2 && (i += " mtkb"), o & 4 && (i += " mtku"), o & 8 && (i += " mtks"), i;
  }
  static getInlineStyleFromMetadata(e, n) {
    const i = this.getForeground(e), o = this.getFontStyle(e);
    let r = `color: ${n[i]};`;
    o & 1 && (r += "font-style: italic;"), o & 2 && (r += "font-weight: bold;");
    let s = "";
    return o & 4 && (s += " underline"), o & 8 && (s += " line-through"), s && (r += `text-decoration:${s};`), r;
  }
  static getPresentationFromMetadata(e) {
    const n = this.getForeground(e), i = this.getFontStyle(e);
    return {
      foreground: n,
      italic: !!(i & 1),
      bold: !!(i & 2),
      underline: !!(i & 4),
      strikethrough: !!(i & 8)
    };
  }
}
function Wt(t, e, n, i) {
  const o = n.tokens.data, r = t.getLanguageId();
  let s = 0, I = 0;
  const C = i.lineNumber - 1, v = i.column - 1;
  for (let f = 0; f < o.length; f += 5) {
    const A = o[f], p = o[f + 1], F = o[f + 2], x = o[f + 3], S = o[f + 4], y = s + A, h = A === 0 ? I + p : p;
    if (C === y && h <= v && v < h + F) {
      const c = n.legend.tokenTypes[x] || "not in legend (ignored)", L = [];
      let l = S;
      for (let P = 0; l > 0 && P < n.legend.tokenModifiers.length; P++)
        l & 1 && L.push(n.legend.tokenModifiers[P]), l = l >> 1;
      l > 0 && L.push("not in legend (ignored)");
      const g = new ze(
        y + 1,
        h + 1,
        y + 1,
        h + 1 + F
      ), N = {}, k = e.getColorTheme().tokenColorMap, b = e.getColorTheme().getTokenStyleMetadata(
        c,
        L,
        r,
        !0,
        N
      );
      let $;
      return b && ($ = {
        languageId: void 0,
        tokenType: fe.Other,
        bold: b == null ? void 0 : b.bold,
        italic: b == null ? void 0 : b.italic,
        underline: b == null ? void 0 : b.underline,
        strikethrough: b == null ? void 0 : b.strikethrough,
        foreground: k[(b == null ? void 0 : b.foreground) || me.None],
        background: void 0
      }), { type: c, modifiers: L, range: g, metadata: $, definitions: N };
    }
    s = y, I = h;
  }
  return null;
}
function jt(t, e, n) {
  let i = null;
  for (let o = 1; o < n; o++)
    i = e.tokenizeLine(
      t.getLineContent(o),
      i
    ).ruleStack;
  return i;
}
function Et(t, e, n) {
  const i = t.getColorTheme().tokenColorMap, o = V.getLanguageId(n), r = V.getTokenType(n), s = V.getFontStyle(n), I = V.getForeground(n), C = V.getBackground(n);
  return {
    languageId: e.languageIdCodec.decodeLanguageId(o),
    tokenType: r,
    bold: s & H.Bold ? !0 : void 0,
    italic: s & H.Italic ? !0 : void 0,
    underline: s & H.Underline ? !0 : void 0,
    strikethrough: s & H.Strikethrough ? !0 : void 0,
    foreground: i[I],
    background: i[C]
  };
}
function Zt(t, e, n) {
  const i = n.lineNumber, o = t, r = o._tokenizationTextModelPart.grammarTokens._tokenizer.tokenizationSupport._actual._grammar, s = jt(t, r, i), I = r.tokenizeLine(
    t.getLineContent(i),
    s
  ), C = r.tokenizeLine2(
    t.getLineContent(i),
    s
  );
  let v = 0;
  for (let A = I.tokens.length - 1; A >= 0; A--) {
    const p = I.tokens[A];
    if (n.column - 1 >= p.startIndex) {
      v = A;
      break;
    }
  }
  let f = 0;
  for (let A = C.tokens.length >>> 1; A >= 0; A--)
    if (n.column - 1 >= C.tokens[A << 1]) {
      f = A;
      break;
    }
  return {
    token: I.tokens[v],
    metadata: Et(
      e,
      o._languageService,
      C.tokens[(f << 1) + 1]
    )
  };
}
const pe = ge(void 0), Gn = ({
  children: t,
  url: e,
  qodly: n,
  defaultZoom: i,
  openHandler: o,
  language: r = "4d",
  defaultInited: s = !1
}) => {
  const I = we(), [C, v] = z(s), [f, A] = z(null), p = re(), F = re(0);
  J(() => {
    e && I && x();
  }, [e, I]);
  const x = async () => {
    if (!I) return;
    const m = new Ve({
      enabled: process.env.NODE_ENV === "development",
      debugEnabled: process.env.NODE_ENV === "development"
    }), u = await vt({
      logger: m
    });
    await Ke({
      caller: "Qodly Code Editor",
      logger: m,
      serviceConfig: u
    }), o && dt.get(It).registerCodeEditorOpenHandler(o), I.languages.registerCompletionItemProvider(
      r,
      n ? Ft : wt
    );
    const d = ne.getDefaultKeybindings.bind(ne);
    ne.getDefaultKeybindings = () => d().filter(
      (j) => ![
        "workbench.action.files.saveAs",
        "workbench.action.files.save"
      ].includes(j.command)
    ), Ie.addKeybindingRules(Lt), I.languages.registerFoldingRangeProvider(r, {
      provideFoldingRanges: function(R) {
        const j = [], Z = /\\\s*$/;
        for (let W = 1, M = R.getLineCount(); W <= M; W++) {
          const U = R.getLineContent(W);
          if (Z.exec(U)) {
            let B = W + 1;
            for (; B <= M; ) {
              const te = R.getLineContent(B);
              if (Z.exec(te) == null)
                break;
              B++;
            }
            B > W && (j.push({
              start: W,
              end: B,
              kind: I.languages.FoldingRangeKind.Region
            }), W = B);
          }
        }
        return j;
      }
    }), S();
  }, S = () => {
    A(null);
    let m;
    try {
      m = new WebSocket(localStorage.LSP_SERVER || e);
    } catch {
      A(new Event("INVALID_URL"));
      return;
    }
    m.onopen = y, m.onclose = h, m.onerror = c, F.current = 0;
  }, y = async function() {
    const m = et(this), u = new St(m), d = new yt(m), R = new Ze({
      name: "4D Language Client",
      clientOptions: {
        workspaceFolder: {
          uri: $e.parse("file:///PACKAGE")
        },
        // use a language id as a document selector
        documentSelector: [{ scheme: "file", language: r }],
        // disable the default error handler
        errorHandler: {
          error: () => ({ action: He.Continue }),
          closed: () => ({ action: Ye.DoNotRestart })
        }
      },
      // create a language client connection from the JSON RPC connection on demand
      connectionProvider: {
        get: () => Promise.resolve({
          reader: u,
          writer: d
        })
      }
    });
    p.current = R;
    const j = R.sendRequest.bind(R);
    p.current.sendRequest = function(Z, W, M) {
      return typeof Z == "object" && Z.method === "textDocument/diagnostic" && /file:\/\/\/PACKAGE\/Project\/Sources\/Methods\/__Debugger_.*/.test(
        W.textDocument.uri
      ) ? Promise.resolve() : j(Z, W, M);
    }, u.onClose(() => {
      R.stop(), F.current < 3 ? setTimeout(() => {
        F.current++, S();
      }, 1e3) : A(new Event("WEBSOCKET_CLOSED"));
    }), R.needsStart() && await R.start(), v(!0);
  }, h = () => {
  }, c = (m) => {
    A(m);
  };
  J(() => {
    const m = We.subscribe(({ action: u, payload: d }) => {
      switch (u) {
        case X.WILL_SAVE:
          k(d.filePath);
          break;
        case X.DID_SAVE:
          K(d.filePath, d.content);
          break;
        case X.WILL_CREATE:
          b(d.filePath);
          break;
        case X.DID_CREATE:
          Se(d.filePath);
          break;
        case X.WILL_RENAME:
          $(d.oldPath, d.newPath);
          break;
        case X.DID_RENAME:
          ye(d.oldPath, d.newPath);
          break;
        case X.WILL_DELETE:
          P(d.filePath);
          break;
        case X.DID_DELETE:
          Ne(d.filePath);
          break;
        case X.DIAGNOSTIC_REFRESH:
          N(d.filePath);
          break;
      }
    });
    return () => m.unsubscribe();
  }, []);
  const L = (m) => {
    var u, d;
    return (d = (u = p.current) == null ? void 0 : u._features) == null ? void 0 : d.find(
      (R) => {
        var j;
        return ((j = R._registrationType) == null ? void 0 : j.method) === m;
      }
    );
  }, l = (m) => {
    const u = [], d = L(m);
    if (d)
      for (const [, R] of d._registrations)
        R.provider && u.push(R.provider);
    return u;
  }, g = async (m, u, d) => {
    var j, Z, W;
    const R = l(
      ut.method
    );
    if (R[0]) {
      const M = new Ue(), U = await Promise.resolve(
        R[0].full.provideDocumentSemanticTokens(
          u,
          M.token
        )
      ), ee = m, B = U ? Wt(
        u,
        ee._themeService,
        {
          tokens: U,
          legend: (W = (Z = (j = p.current) == null ? void 0 : j._capabilities) == null ? void 0 : Z.semanticTokensProvider) == null ? void 0 : W.legend
        },
        d
      ) : null, te = Zt(
        u,
        ee._themeService,
        d
      );
      return {
        semanticTokenInfo: B,
        textmateTokenInfo: te
      };
    }
    return null;
  }, N = (m) => {
    if (p.current) {
      const u = l(
        tt.method
      );
      for (const d of u)
        d.onDidChangeDiagnosticsEmitter.fire();
    }
  }, k = (m, u = nt.Manual) => {
    var d;
    (d = p.current) == null || d.sendNotification(it.type, {
      textDocument: {
        uri: E(m)
      },
      reason: u
    });
  }, K = (m, u) => {
    var d;
    (d = p.current) == null || d.sendNotification(ot.type, {
      textDocument: {
        uri: E(m)
      },
      text: u
    });
  }, b = (m) => {
    var u;
    (u = p.current) == null || u.sendRequest(rt.type, {
      files: [
        {
          uri: E(m)
        }
      ]
    });
  }, $ = (m, u) => {
    var d;
    (d = p.current) == null || d.sendRequest(st.type, {
      files: [
        {
          oldUri: E(m),
          newUri: E(u)
        }
      ]
    });
  }, P = (m) => {
    var u;
    (u = p.current) == null || u.sendRequest(at.type, {
      files: [
        {
          uri: E(m)
        }
      ]
    });
  }, Se = (m) => {
    var u;
    (u = p.current) == null || u.sendNotification(lt.type, {
      files: [
        {
          uri: E(m)
        }
      ]
    });
  }, ye = (m, u) => {
    var d;
    (d = p.current) == null || d.sendNotification(ct.type, {
      files: [
        {
          oldUri: E(m),
          newUri: E(u)
        }
      ]
    });
  }, Ne = (m) => {
    var u;
    (u = p.current) == null || u.sendNotification(gt.type, {
      files: [
        {
          uri: E(m)
        }
      ]
    });
  };
  return /* @__PURE__ */ _(
    pe.Provider,
    {
      value: {
        inited: C || !!f,
        clientRef: p,
        lastError: f,
        reload: S,
        getTokenAtPosition: g
      },
      children: [
        t,
        /* @__PURE__ */ w(kt, { defaultZoom: i })
      ]
    }
  );
};
function Mn() {
  const t = ue(pe);
  if (t === void 0)
    throw new Error("useLSP must be used within an LSPContext");
  return t;
}
const Ae = ge(
  void 0
), Jn = Re(({ children: t }) => {
  const [e, n] = z(null);
  return /* @__PURE__ */ w(
    Ae.Provider,
    {
      value: {
        editor: e,
        setEditor: n
      },
      children: t
    }
  );
});
function Xt() {
  const t = ue(Ae), e = z(null);
  if (t === void 0) {
    const [n, i] = e;
    return {
      editor: n,
      setEditor: i
    };
  }
  return t;
}
const Kt = {
  provideCompletionItems: (t, e) => {
    const n = t.getWordUntilPosition(e);
    return {
      suggestions: [
        {
          label: "device:xs",
          kind: a.languages.CompletionItemKind.Snippet,
          documentation: "Media query for phone device",
          range: new a.Range(
            e.lineNumber,
            n.startColumn,
            e.lineNumber,
            n.endColumn
          ),
          insertText: [
            "@media screen and (max-width: ${1:365px}) {",
            "  self {",
            "    ${2:background-color}:${3:red};",
            "  }",
            "}"
          ].join(`
`),
          insertTextRules: a.languages.CompletionItemInsertTextRule.InsertAsSnippet
        }
      ]
    };
  }
}, Bt = "#/definitions/Condition", Dt = { Base: { type: "object", properties: { id: { type: "string" }, name: { type: "string" } }, required: ["id"] }, Condition: { oneOf: [{ $ref: "#/definitions/Datasource" }, { $ref: "#/definitions/Privilege" }, { $ref: "#/definitions/Combination" }, { $ref: "#/definitions/CurrentState" }, { $ref: "#/definitions/ParentState" }, { $ref: "#/definitions/Reference" }] }, Datasource: { allOf: [{ $ref: "#/definitions/Base" }], properties: { type: { const: "datasource" }, path: { type: "string" }, value: { type: ["number", "string", "boolean", "object", "array", "null"] }, valueType: { enum: ["datasource", "hardCoded"] }, dataType: { enum: ["string", "number", "date", "boolean", "array", "object"] }, op: { enum: ["eq", "neq", "regex", "in", "nin", "gt", "gte", "lt", "lte"] } }, required: ["name", "type", "path", "value", "op"] }, Privilege: { allOf: [{ $ref: "#/definitions/Base" }], properties: { type: { const: "privilege" }, value: { type: "string" }, valueType: { enum: ["datasource", "hardCoded"] }, op: { enum: ["eq", "neq", "regex"] } }, required: ["name", "type", "value", "op"] }, Combination: { allOf: [{ $ref: "#/definitions/Base" }], properties: { type: { const: "combination" }, op: { enum: ["and", "or"] }, conditions: { type: "array", items: { $ref: "#/definitions/Condition" } } }, required: ["type", "conditions", "op"] }, CurrentState: { allOf: [{ $ref: "#/definitions/Base" }], properties: { type: { const: "currentState" }, value: { type: "string" }, valueType: { enum: ["datasource", "hardCoded"] }, dataType: { enum: ["string", "number", "date", "boolean", "array", "object"] }, op: { enum: ["eq", "neq", "regex"] } }, required: ["name", "type", "value", "op"] }, ParentState: { allOf: [{ $ref: "#/definitions/Base" }], properties: { type: { const: "parentState" }, value: { type: "string" }, valueType: { enum: ["datasource", "hardCoded"] }, dataType: { enum: ["string", "number", "date", "boolean", "array", "object"] }, op: { enum: ["eq", "neq", "regex"] } }, required: ["name", "type", "value", "op"] }, Reference: { allOf: [{ $ref: "#/definitions/Base" }], properties: { type: { const: "reference" }, ref: { type: "string" } }, required: ["type", "ref"] } }, Tt = {
  $ref: Bt,
  definitions: Dt
}, Ot = "array", Gt = { type: "object", properties: { class: { type: "string" }, method: { type: "string" }, regexPattern: { type: "string" }, verbs: { type: "string" } } }, Mt = {
  type: Ot,
  items: Gt
};
function Jt(t, e) {
  const n = document.createElement("style");
  n.dataset.id = e, n.textContent = t, document.head.append(n);
}
function Pt(t) {
  return Array.from(document.styleSheets).find(
    (e) => e.ownerNode.getAttribute("data-id") === t
  );
}
function Vt(t, e) {
  const n = [];
  let i = [];
  const o = [], r = (l, g, N, k) => {
    n.push({
      startLineNumber: l,
      endLineNumber: N,
      startColumn: g,
      endColumn: k
    }), v(), C();
  }, s = (l) => {
    o.indexOf(l) < 0 && o.push(l);
  }, I = (l) => {
    const g = o.indexOf(l);
    g < 0 || o.splice(g, 1);
  }, C = () => {
    for (const l of o)
      try {
        l(i);
      } catch (g) {
        console.error(g);
      }
  }, v = () => {
    const l = t.getModel();
    l && (i = Ht(
      n.map((g) => [
        l.getOffsetAt({
          lineNumber: g.startLineNumber,
          column: g.startColumn
        }),
        l.getOffsetAt({
          lineNumber: g.endLineNumber,
          column: g.endColumn
        })
      ]),
      /*mergeJoins*/
      !0
    ), i.length > 0 && (i[0][0] <= 0 && (i[0][0] = Number.NEGATIVE_INFINITY), i[i.length - 1][1] >= l.getValueLength() && (i[i.length - 1][1] = Number.POSITIVE_INFINITY)));
  }, f = (l) => {
    const g = {
      isDeletion: !1,
      isAddition: !1,
      isReplacement: !1
    };
    return l.text === "" ? g.isDeletion = !0 : l.range.startLineNumber === l.range.endLineNumber && l.range.startColumn === l.range.endColumn ? g.isAddition = !0 : g.isReplacement = !0, g;
  }, A = t.onDidChangeModel((l) => {
    v(), c();
  }), p = t.onDidChangeModelContent((l) => {
    if (!l.isUndoing)
      for (const g of l.changes) {
        const N = f(g);
        if (N.isReplacement || N.isDeletion || N.isAddition) {
          const k = n.some(
            (b) => g.range.startLineNumber >= b.startLineNumber && g.range.endLineNumber <= b.endLineNumber && g.range.startColumn >= b.startColumn && g.range.endColumn <= b.endColumn
          ), K = !k && e && g.range.startLineNumber === 1 && g.range.startColumn === 1 && !de(g.text);
          if (k || K) {
            const b = t.getModel();
            if (b) {
              b.undo();
              return;
            }
          }
        }
      }
  }), F = () => {
    A.dispose(), p.dispose();
  };
  let x = [], S = `
    .idoc-readonly-mark {
      cursor: not-allowed;
      z-index: 1;
    }
  `;
  if (S) {
    const l = "monaco-read-only";
    Pt(l) || Jt(S, l), S = null;
  }
  const y = () => {
    s(c), c();
  }, h = () => {
    I(c), x = t.deltaDecorations(x, []);
  }, c = () => {
    const l = t.getModel();
    l && (x = t.deltaDecorations(
      x,
      i.map(L(l))
    ));
  }, L = (l) => (g) => {
    const N = l.getPositionAt(g[0]), k = l.getPositionAt(g[1]);
    return {
      range: new a.Range(
        N.lineNumber,
        N.column,
        k.lineNumber,
        k.column
      ),
      options: {
        className: "idoc-readonly-mark"
      }
    };
  };
  return {
    get buffer() {
      return i;
    },
    exclude: r,
    attach: s,
    detach: I,
    dispose: F,
    show: y,
    hide: h
  };
}
function Yt(t, e, n) {
  let i = !1;
  const o = (h) => h[1] < h[0] ? (i = !0, [[h[1], h[0]]]) : [[...h]], r = (h) => i ? h.map((c) => c[1] > c[0] ? I(c) : c).reverse() : h;
  let s;
  const I = (h) => (s = h[1], h[1] = h[0], h[0] = s, h), C = o(t);
  let v, f, A, p, F, x, S, y;
  A = C[0];
  for (f of e)
    for (S = f[0], y = f[1], p = 0; p < C.length; p++) {
      if (A = C[p], F = A[0], x = A[1], F < S)
        x < S ? v = [A] : x <= y ? v = [[F, S - 1]] : v = [
          [F, S - 1],
          [y + 1, x]
        ];
      else if (F <= y)
        if (S === Number.NEGATIVE_INFINITY) {
          const h = y + 1;
          v = n === 0 ? [] : [[h, x > h ? x : h]];
        } else y === Number.POSITIVE_INFINITY ? v = n === 0 ? [] : [[S - 1, S - 1]] : x <= y ? v = n < 0 ? [[S - 1, S - 1]] : n > 0 ? [[y + 1, y + 1]] : [] : v = [[y + 1, x]];
      else
        v = [A];
      if (C.splice(p, 1, ...v), C.length === 1 && C[0][1] < S) return r(C);
    }
  return r(C);
}
function Ht(t, e) {
  if (t.length < 2) return t;
  const n = [];
  let i = null, o, r;
  t = t.map(
    (s) => (s[1] < s[0] && (o = s[1], s[1] = s[0], s[1] = o), s)
  ).sort((s, I) => s[0] - I[0]), n.push(t[0]);
  for (let s = 1; s < t.length; s++)
    i = n[n.length - 1], r = t[s], i[1] === r[0] && !e || (i[1] === r[0] - 1 && e ? (i[1] = r[1], n.splice(n.length - 1, 1, i)) : i[1] < r[0] ? n.push(r) : i[1] < r[1] && (i[1] = r[1], n.splice(n.length - 1, 1, i)));
  return n;
}
function Y(t, e) {
  return e.bind(t);
}
class _t {
  constructor(e, n) {
    var i;
    this.disposables = [], this.prefer = 1, this.lastPrefer = 1, this.onCursor = Y(
      this,
      function(o) {
        if (o.source === "api") return;
        const r = this.getApprovedSelections();
        r.length !== 0 && this.editor.setSelections(r);
      }
    ), this.onRectangleSelectionStart = Y(this, function({ event: o }) {
      o.middleButton && (this.lastPrefer = this.prefer, this.prefer = 0, window.addEventListener("pointerup", this.onRectangleSelectionStop));
    }), this.onRectangleSelectionStop = Y(this, function() {
      this.prefer = this.lastPrefer, window.removeEventListener("pointerup", this.onRectangleSelectionStop);
    }), this.onKey = Y(this, function(o) {
      const r = o.keyCode, s = a.KeyCode;
      if (o.altKey || s.F1 <= r && r <= s.F19 || o.ctrlKey && r !== s.Backspace) return;
      if (r === s.UpArrow || r === s.LeftArrow || r === s.Home || r === s.PageUp) {
        this.prefer = -1;
        return;
      }
      if (r === s.DownArrow || r === s.RightArrow || r === s.End || r === s.PageDown) {
        this.prefer = 1;
        return;
      }
      const I = this.getSelections(), C = this.intervals.buffer;
      let v;
      if (r === s.Delete)
        v = (f) => f[0] === f[1] && C.find((A) => f[1] + 1 === A[0]) != null;
      else if (r === s.Backspace)
        v = (f) => f[0] === f[1] && C.find((A) => A[1] + 1 === f[0]) != null;
      else
        return;
      I.findIndex(v) !== -1 && (o.stopPropagation(), o.preventDefault());
    }), this.getOffsetAt = Y(this, function(o) {
      let r;
      for (let s = 0; s < this.intervals.buffer.length; s++)
        if (r = this.intervals.buffer[s], o <= r[1])
          return r[0] - o < o - r[1] ? r[0] : r[1];
    }), this.editor = e, this.intervals = Vt(e, n), (i = this.editor.getModel()) == null || i.setEOL(a.editor.EndOfLineSequence.LF);
  }
  enable() {
    this.disposables.push(
      this.editor.onDidChangeCursorPosition(this.onCursor),
      this.editor.onKeyDown(this.onKey),
      this.editor.onMouseDown(this.onRectangleSelectionStart)
    ), this.intervals.show();
  }
  dispose() {
    for (const e of this.disposables) e.dispose();
    this.disposables.splice(0);
  }
  exclude(e, n, i, o) {
    arguments.length === 1 ? this.intervals.exclude(e, 0, e, Number.MAX_SAFE_INTEGER) : this.intervals.exclude(e, n, i, o);
  }
  getApprovedSelections() {
    const e = this.editor.getModel();
    return this.getSelections().map(
      (i) => Yt(
        i,
        this.intervals.buffer,
        this.prefer
      )
    ).flat().map((i) => {
      const o = e.getPositionAt(i[0]), r = e.getPositionAt(i[1]);
      return new a.Selection(
        o.lineNumber,
        o.column,
        r.lineNumber,
        r.column
      );
    });
  }
  getSelections() {
    const e = this.editor.getModel();
    return (this.editor.getSelections() || []).map((n) => [
      e.getOffsetAt({
        lineNumber: n.selectionStartLineNumber,
        column: n.selectionStartColumn
      }),
      e.getOffsetAt({
        lineNumber: n.positionLineNumber,
        column: n.positionColumn
      })
    ]);
  }
}
const zt = {
  provideDocumentFormattingEdits(t, e) {
    const n = t.getValue();
    try {
      const i = $t(n, e.tabSize, e.insertSpaces);
      return [
        {
          range: t.getFullModelRange(),
          text: i
        }
      ];
    } catch {
      return [];
    }
  }
};
function $t(t, e = 2, n = !0) {
  const i = n ? " ".repeat(e) : "	";
  let o = t.replace(/\s+/g, " ").trim();
  return o = o.replace(/\{/g, ` {
` + i).replace(/\}/g, `
}
`).replace(/;/g, `;
` + i).replace(/,/g, `,
` + i), o = o.replace(/\s*\{\s*/g, ` {
` + i).replace(/\s*\}\s*/g, `
}
`).replace(/\s*;\s*/g, `;
` + i).replace(/\s*:\s*/g, ": "), o = o.split(`
`).map((r) => r.trim() === "}" ? "}" : r.trimEnd()).filter((r, s, I) => !(r === "" && I[s + 1] === "")).join(`
`).trim(), o;
}
const Ut = {
  provideDocumentFormattingEdits(t, e) {
    const n = t.getValue();
    try {
      const i = qt(n, e.tabSize);
      return [
        {
          range: t.getFullModelRange(),
          text: i
        }
      ];
    } catch {
      return [];
    }
  }
};
function qt(t, e = 2) {
  const n = JSON.parse(t);
  return JSON.stringify(n, null, e);
}
const Qt = new RegExp("^[	s]+(exposed|Function)", "i"), en = ({
  lineNumber: t,
  editor: e,
  type: n,
  source: i
}) => {
  var v;
  const o = n === oe.METHOD || n === oe.DEBUGGER && ((v = i == null ? void 0 : i.codeDescriptorInfo) == null ? void 0 : v.type) === je.METHOD;
  if (t === 1)
    return o ? "" : "1";
  const r = e == null ? void 0 : e.getModel(), s = (r == null ? void 0 : r.getLinesContent()) || [], I = Array(s.length).fill("-");
  let C = o ? 0 : 1;
  for (let f = 1; f < s.length; f++)
    (f === 1 ? "" : s[f - 1]).endsWith("\\") || (C += 1, I[f] = C.toString());
  return I[t - 1];
}, le = () => /* @__PURE__ */ w("div", { className: "absolute inset-0 animate-pulse", children: /* @__PURE__ */ w("div", { className: "w-full space-y-4 px-4 py-1", children: /* @__PURE__ */ _("div", { className: "space-y-2", children: [
  /* @__PURE__ */ w("div", { className: "h-3 w-3/4 rounded bg-grey-200" }),
  /* @__PURE__ */ w("div", { className: "h-3 rounded bg-grey-200" }),
  /* @__PURE__ */ w("div", { className: "h-3 w-5/6 rounded bg-grey-200" }),
  /* @__PURE__ */ w("div", { className: "h-3 rounded bg-grey-200" }),
  /* @__PURE__ */ w("div", { className: "h-3 rounded bg-grey-200" })
] }) }) }), ie = ["fd-dark"], q = {
  css: [],
  json: []
}, Pn = ({
  path: t,
  initialValue: e,
  type: n,
  language: i,
  onChange: o,
  options: r = {},
  extra: s = {},
  lspProps: I,
  theme: C = ie[0],
  ...v
}) => {
  const { initialLineInfo: f, initialSelectionInfo: A } = s, { editor: p, setEditor: F } = Xt(), { inited: x } = I;
  function S(c) {
    i === "css" && c.languages.css && (c.languages.registerCompletionItemProvider("css", Kt), c.languages.css.cssDefaults.setModeConfiguration({
      ...c.languages.css.cssDefaults.modeConfiguration,
      documentFormattingEdits: !1,
      documentRangeFormattingEdits: !1
    }), q.css.forEach((L) => L.dispose()), q.css.push(
      c.languages.registerDocumentFormattingEditProvider(
        "css",
        zt
      )
    )), i === "json" && c.languages.json && (c.languages.json.jsonDefaults.setDiagnosticsOptions({
      validate: !0,
      schemas: [
        {
          uri: "condition-schema.json",
          fileMatch: ["*.condition.json"],
          schema: Tt
        },
        {
          uri: "handlers-schema.json",
          fileMatch: [Ee],
          schema: Mt
        }
      ]
    }), c.languages.json.jsonDefaults.setModeConfiguration({
      ...c.languages.json.jsonDefaults.modeConfiguration,
      documentFormattingEdits: !1,
      documentRangeFormattingEdits: !1
    }), q.json.forEach((L) => L.dispose()), q.json.push(
      c.languages.registerDocumentFormattingEditProvider(
        "json",
        Ut
      )
    ));
  }
  function y(c, L) {
    F(c);
    const l = c.getModel();
    if (l && (l.updateOptions({ insertSpaces: !1 }), c.onKeyUp(() => {
      var N;
      const g = (N = c.getPosition()) == null ? void 0 : N.lineNumber;
      if (g) {
        const k = l.getLineFirstNonWhitespaceColumn(g), K = l.getLineLength(g), b = l.getLineContent(g);
        Qt.test(b) && c.executeEdits("edit-handler", [
          {
            range: new L.Range(
              g,
              0,
              g,
              K
            ),
            text: b.substr(
              k - 1,
              K - k
            )
          }
        ]);
      }
    })), xt(l)) {
      const g = [
        "editor.action.revealDefinition",
        "editor.action.goToReferences",
        "submenuitem.EditorContextPeek"
      ], N = c.getContribution(
        "editor.contrib.contextmenu"
      ), k = N._getMenuActions;
      N._getMenuActions = function() {
        return k.apply(N, arguments).filter(function(b) {
          return !g.includes(b.id);
        });
      };
    }
    if (n === oe.METHOD && de(e)) {
      const g = new _t(c, !0);
      g.exclude(1, 1, 1, Number.POSITIVE_INFINITY), g.enable();
    }
  }
  J(() => {
    if (!p) return;
    const { line: c, offset: L } = f || {};
    c && Rt(p, c, L);
  }, [f, p]), J(() => {
    if (!p) return;
    const { selection: c } = A || {};
    c && Nt(p, c);
  }, [A, p]);
  const h = (c) => ie.includes(c) ? c : ie[0];
  return x ? /* @__PURE__ */ w(
    Fe,
    {
      options: {
        readOnly: !0,
        fontSize: 12,
        "semanticHighlighting.enabled": !0,
        padding: { top: 10 },
        lineNumbers: i === "4d" ? (c) => en({
          lineNumber: c,
          editor: p,
          type: n,
          source: s == null ? void 0 : s.source
        }) : void 0,
        scrollBeyondLastLine: !1,
        ...r
      },
      path: E(t),
      value: e,
      theme: h(C),
      onChange: (c) => o && o(c || ""),
      language: i,
      beforeMount: S,
      onMount: y,
      loading: /* @__PURE__ */ w(le, {}),
      ...v
    }
  ) : /* @__PURE__ */ w("div", { className: "relative flex-1 w-full", children: /* @__PURE__ */ w(le, {}) });
};
var be = {
  color: void 0,
  size: void 0,
  className: void 0,
  style: void 0,
  attr: void 0
}, ce = G.createContext && G.createContext(be), D = function() {
  return D = Object.assign || function(t) {
    for (var e, n = 1, i = arguments.length; n < i; n++) {
      e = arguments[n];
      for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
    return t;
  }, D.apply(this, arguments);
}, tn = function(t, e) {
  var n = {};
  for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
  if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var o = 0, i = Object.getOwnPropertySymbols(t); o < i.length; o++)
    e.indexOf(i[o]) < 0 && Object.prototype.propertyIsEnumerable.call(t, i[o]) && (n[i[o]] = t[i[o]]);
  return n;
};
function he(t) {
  return t && t.map(function(e, n) {
    return G.createElement(e.tag, D({
      key: n
    }, e.attr), he(e.child));
  });
}
function ve(t) {
  return function(e) {
    return G.createElement(nn, D({
      attr: D({}, t.attr)
    }, e), he(t.child));
  };
}
function nn(t) {
  var e = function(n) {
    var i = t.attr, o = t.size, r = t.title, s = tn(t, ["attr", "size", "title"]), I = o || n.size || "1em", C;
    return n.className && (C = n.className), t.className && (C = (C ? C + " " : "") + t.className), G.createElement("svg", D({
      stroke: "currentColor",
      fill: "currentColor",
      strokeWidth: "0"
    }, n.attr, i, s, {
      className: C,
      style: D(D({
        color: t.color || n.color
      }, n.style), t.style),
      height: I,
      width: I,
      xmlns: "http://www.w3.org/2000/svg"
    }), r && G.createElement("title", null, r), t.children);
  };
  return ce !== void 0 ? G.createElement(ce.Consumer, null, function(n) {
    return e(n);
  }) : e(be);
}
function on(t) {
  return ve({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 10.5858L9.17157 7.75736L7.75736 9.17157L10.5858 12L7.75736 14.8284L9.17157 16.2426L12 13.4142L14.8284 16.2426L16.2426 14.8284L13.4142 12L16.2426 9.17157L14.8284 7.75736L12 10.5858Z" } }] })(t);
}
function rn(t) {
  return ve({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M449.07 399.08L278.64 82.58c-12.08-22.44-44.26-22.44-56.35 0L51.87 399.08A32 32 0 0080 446.25h340.89a32 32 0 0028.18-47.17zm-198.6-1.83a20 20 0 1120-20 20 20 0 01-20 20zm21.72-201.15l-5.74 122a16 16 0 01-32 0l-5.74-121.95a21.73 21.73 0 0121.5-22.69h.21a21.74 21.74 0 0121.73 22.7z" } }] })(t);
}
const Vn = ({
  lspProps: { lastError: t, reload: e }
}) => {
  const [n, i] = z(!1), o = () => {
    e();
  }, r = () => {
    i(!1);
  };
  return J(() => {
    i(!!t);
  }, [t]), n ? /* @__PURE__ */ _("div", { className: "flex items-center border-b border-fd-gray-darker bg-grey-800 px-2 py-1.5 text-xs text-grey-50", children: [
    /* @__PURE__ */ _("span", { className: "flex flex-1 justify-center gap-1", children: [
      /* @__PURE__ */ w(rn, { className: "h-4 w-4 text-yellow-600" }),
      /* @__PURE__ */ _("span", { children: [
        "LSP not loaded.",
        " ",
        /* @__PURE__ */ w(
          "button",
          {
            className: "text-primary-dark underline",
            onClick: o,
            children: "Reload?"
          }
        )
      ] })
    ] }),
    /* @__PURE__ */ w("button", { className: "focus:outline-none", children: /* @__PURE__ */ w(
      on,
      {
        className: "h-4 w-4 text-white",
        onClick: r
      }
    ) })
  ] }) : null;
}, sn = {
  name: "4d",
  displayName: "%displayName%",
  description: "%description%",
  version: "1.0.0",
  publisher: "vscode",
  engines: { vscode: "0.10.x" },
  categories: ["Programming Languages"],
  contributes: {
    languages: [
      {
        id: "4d",
        aliases: ["4D", "4d"],
        extensions: [".4dm", ".4qs"],
        configuration: "./language-configuration.json"
      }
    ],
    grammars: [
      {
        language: "4d",
        scopeName: "source.4dm",
        path: "./syntaxes/4d.tmLanguage.json"
      }
    ]
  }
}, { registerFileUrl: Q, whenReady: Yn } = Ct(sn, void 0, {
  system: !0
});
Q(
  "./syntaxes/4d.tmLanguage.json",
  new URL("data:application/json;base64,ewogICJuYW1lIjogIjREIiwKICAic2NvcGVOYW1lIjogInNvdXJjZS40ZG0iLAogICJwYXR0ZXJucyI6IFsKICAgIHsKICAgICAgImluY2x1ZGUiOiAiI3N0YXRlbWVudHMiCiAgICB9CiAgXSwKICAicmVwb3NpdG9yeSI6IHsKICAgICJzdGF0ZW1lbnRzIjogewogICAgICAicGF0dGVybnMiOiBbCiAgICAgICAgewogICAgICAgICAgImluY2x1ZGUiOiAiI2NvbW1lbnQiCiAgICAgICAgfQogICAgICBdCiAgICB9LAogICAgImNvbW1lbnQiOiB7CiAgICAgICJwYXR0ZXJucyI6IFsKICAgICAgICB7CiAgICAgICAgICAibmFtZSI6ICJjb21tZW50LmJsb2NrLjRkIiwKICAgICAgICAgICJiZWdpbiI6ICIoL1xcKikoPzpcXHMqKChAKWludGVybmFsKSg/PVxcc3woXFwqLykpKT8iLAogICAgICAgICAgImJlZ2luQ2FwdHVyZXMiOiB7CiAgICAgICAgICAgICIxIjogewogICAgICAgICAgICAgICJuYW1lIjogInB1bmN0dWF0aW9uLmRlZmluaXRpb24uY29tbWVudC40ZCIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgIjIiOiB7CiAgICAgICAgICAgICAgIm5hbWUiOiAic3RvcmFnZS50eXBlLmludGVybmFsZGVjbGFyYXRpb24uNGQiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgICIzIjogewogICAgICAgICAgICAgICJuYW1lIjogInB1bmN0dWF0aW9uLmRlY29yYXRvci5pbnRlcm5hbGRlY2xhcmF0aW9uLjRkIgogICAgICAgICAgICB9CiAgICAgICAgICB9LAogICAgICAgICAgImVuZCI6ICJcXCovIiwKICAgICAgICAgICJlbmRDYXB0dXJlcyI6IHsKICAgICAgICAgICAgIjAiOiB7CiAgICAgICAgICAgICAgIm5hbWUiOiAicHVuY3R1YXRpb24uZGVmaW5pdGlvbi5jb21tZW50LjRkIgogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICAiYmVnaW4iOiAiKF5bIFxcdF0rKT8oKC8vKSg/OlxccyooKEApaW50ZXJuYWwpKD89XFxzfCQpKT8pIiwKICAgICAgICAgICJiZWdpbkNhcHR1cmVzIjogewogICAgICAgICAgICAiMSI6IHsKICAgICAgICAgICAgICAibmFtZSI6ICJwdW5jdHVhdGlvbi53aGl0ZXNwYWNlLmNvbW1lbnQubGVhZGluZy40ZCIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgIjIiOiB7CiAgICAgICAgICAgICAgIm5hbWUiOiAiY29tbWVudC5saW5lLmRvdWJsZS1zbGFzaC40ZCIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgIjMiOiB7CiAgICAgICAgICAgICAgIm5hbWUiOiAicHVuY3R1YXRpb24uZGVmaW5pdGlvbi5jb21tZW50LjRkIgogICAgICAgICAgICB9LAogICAgICAgICAgICAiNCI6IHsKICAgICAgICAgICAgICAibmFtZSI6ICJzdG9yYWdlLnR5cGUuaW50ZXJuYWxkZWNsYXJhdGlvbi40ZCIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgIjUiOiB7CiAgICAgICAgICAgICAgIm5hbWUiOiAicHVuY3R1YXRpb24uZGVjb3JhdG9yLmludGVybmFsZGVjbGFyYXRpb24uNGQiCiAgICAgICAgICAgIH0KICAgICAgICAgIH0sCiAgICAgICAgICAiZW5kIjogIig/PSQpIiwKICAgICAgICAgICJjb250ZW50TmFtZSI6ICJjb21tZW50LmxpbmUuZG91YmxlLXNsYXNoLjRkIgogICAgICAgIH0KICAgICAgXQogICAgfQogIH0KfQo=", import.meta.url).toString(),
  { mimeType: "application/json", size: 1592 }
);
Q(
  "./language-configuration.json",
  new URL("data:application/json;base64,ewogICJjb21tZW50cyI6IHsKICAgICJsaW5lQ29tbWVudCI6ICIvLyIsCiAgICAiYmxvY2tDb21tZW50IjogWyIvKioiLCAiKiovIl0KICB9LAogIC8vIHN5bWJvbHMgdXNlZCBhcyBicmFja2V0cwogICJicmFja2V0cyI6IFsKICAgIFsieyIsICJ9Il0sCiAgICBbIigiLCAiKSJdLAogICAgWyJbIiwgIl0iXQogIF0sCiAgLy8gc3ltYm9scyB0aGF0IGFyZSBhdXRvIGNsb3NlZCB3aGVuIHR5cGluZwogIC8vIHN5bWJvbHMgdGhhdCB0aGF0IGNhbiBiZSB1c2VkIHRvIHN1cnJvdW5kIGEgc2VsZWN0aW9uCiAgInN1cnJvdW5kaW5nUGFpcnMiOiBbCiAgICBbInsiLCAifSJdLAogICAgWyJbIiwgIl0iXSwKICAgIFsiKCIsICIpIl0sCiAgICBbIlwiIiwgIlwiIl0sCiAgICBbIiciLCAiJyJdCiAgXSwKICAiYXV0b0Nsb3NpbmdQYWlycyI6IFsKICAgIHsKICAgICAgIm9wZW4iOiAiKCIsCiAgICAgICJjbG9zZSI6ICIpIgogICAgfSwKICAgIHsgIm9wZW4iOiAieyIsICJjbG9zZSI6ICJ9IiB9LAogICAgeyAib3BlbiI6ICJbIiwgImNsb3NlIjogIl0iIH0sCiAgICB7ICJvcGVuIjogIiciLCAiY2xvc2UiOiAiJyIsICJub3RJbiI6IFsic3RyaW5nIiwgImNvbW1lbnQiXSB9LAogICAgeyAib3BlbiI6ICJcIiIsICJjbG9zZSI6ICJcIiIsICJub3RJbiI6IFsic3RyaW5nIl0gfSwKICAgIHsgIm9wZW4iOiAiYCIsICJjbG9zZSI6ICJgIiwgIm5vdEluIjogWyJzdHJpbmciLCAiY29tbWVudCJdIH0sCiAgICB7ICJvcGVuIjogIi8qKiIsICJjbG9zZSI6ICIgKiovIiwgIm5vdEluIjogWyJzdHJpbmciXSB9CiAgXSwKICAiYXV0b0Nsb3NlQmVmb3JlIjogIjs6Liw9fV0pPmAgXG5cdCIsCiAgIndvcmRQYXR0ZXJuIjogIigtP1xcZCpcXC5cXGRcXHcqKXwoW15cXGBcXH5cXCFcXEBcXCNcXCVcXF5cXCZcXCpcXChcXClcXC1cXD1cXCtcXFtcXHtcXF1cXH1cXFxcXFx8XFw7XFw6XFwnXFxcIlxcLFxcLlxcPFxcPlxcL1xcP1xcclxcblxcdFxcZlxcdiBdKyl8KD88PVthLXpBLVpdKSA/KD89W2EtekEtWl0pIiwKICAiaW5kZW50YXRpb25SdWxlcyI6IHsKICAgICJpbmNyZWFzZUluZGVudFBhdHRlcm4iOiB7CiAgICAgICJwYXR0ZXJuIjogIiheKD8hW15cXHNdKSpcXHMqKGNsYXNzIGNvbnN0cnVjdG9yKSl8KF4oPyFbXlxcc10pKlxccyooZXhwb3NlZHxsb2NhbHxcXHMqKXsxfVxccypmdW5jdGlvbnsxfVxccypcXHcpfCheKD8hW15cXHNdKSpcXHMqKElmfEVsc2V8Rm9yfEZvciBlYWNofFdoaWxlfEJlZ2luIFNRTHxDYXNlIG9mfFVzZXxSZXBlYXR8OiAqXFwoLiopKS4qJCIsCiAgICAgICJmbGFncyI6ICJpIgogICAgfSwKICAgICJkZWNyZWFzZUluZGVudFBhdHRlcm4iOiB7CiAgICAgICJwYXR0ZXJuIjogIiheKD8hW15cXHNdKSpcXHMqKGV4cG9zZWR8bG9jYWx8XFxzKil7MX1cXHMqZnVuY3Rpb257MX1cXHMqXFx3KXwoRW5kIElmfEVuZCBGb3J8RWxzZXxFbmQgZm9yIGVhY2h8RW5kIFdoaWxlfEVuZCBTUUx8RW5kIGNhc2V8RW5kIHVzZXxVbnRpbHw6ICpcXCguKikuKiQiLAogICAgICAiZmxhZ3MiOiAiaSIKICAgIH0KICB9LAogICJvbkVudGVyUnVsZXMiOiBbCiAgICB7CiAgICAgICJiZWZvcmVUZXh0IjogewogICAgICAgICJwYXR0ZXJuIjogIl5leHBvc2VkIiwKICAgICAgICAiZmxhZ3MiOiAiaSIKICAgICAgfSwKICAgICAgImFjdGlvbiI6IHsgImluZGVudCI6ICJpbmRlbnQiLCAiaW5kZW50QWN0aW9uIjogMSB9CiAgICB9CiAgXQp9Cg==", import.meta.url).toString(),
  { mimeType: "application/json", size: 1723 }
);
Q(
  "package.json",
  new URL("data:application/json;base64,ewogICJuYW1lIjogIjRkIiwKICAiZGlzcGxheU5hbWUiOiAiJWRpc3BsYXlOYW1lJSIsCiAgImRlc2NyaXB0aW9uIjogIiVkZXNjcmlwdGlvbiUiLAogICJ2ZXJzaW9uIjogIjEuMC4wIiwKICAicHVibGlzaGVyIjogInZzY29kZSIsCiAgImxpY2Vuc2UiOiAiTUlUIiwKICAiZW5naW5lcyI6IHsKICAgICJ2c2NvZGUiOiAiMC4xMC54IgogIH0sCiAgInNjcmlwdHMiOiB7CiAgICAidXBkYXRlLWdyYW1tYXIiOiAibm9kZSAuLi9ub2RlX21vZHVsZXMvdnNjb2RlLWdyYW1tYXItdXBkYXRlci9iaW4gbWljcm9zb2Z0L3ZzY29kZS00ZCBncmFtbWFycy80ZC5jc29uIC4vc3ludGF4ZXMvNGQudG1MYW5ndWFnZS5qc29uIgogIH0sCiAgImNhdGVnb3JpZXMiOiBbCiAgICAiUHJvZ3JhbW1pbmcgTGFuZ3VhZ2VzIgogIF0sCiAgImNvbnRyaWJ1dGVzIjogewogICAgImxhbmd1YWdlcyI6IFsKICAgICAgewogICAgICAgICJpZCI6ICI0ZCIsCiAgICAgICAgImFsaWFzZXMiOiBbCiAgICAgICAgICAiNEQiLAogICAgICAgICAgIjRkIgogICAgICAgIF0sCiAgICAgICAgImV4dGVuc2lvbnMiOiBbCiAgICAgICAgICAiLjRkbSIsCiAgICAgICAgICAiLjRxcyIKICAgICAgICBdLAogICAgICAgICJjb25maWd1cmF0aW9uIjogIi4vbGFuZ3VhZ2UtY29uZmlndXJhdGlvbi5qc29uIgogICAgICB9CiAgICBdLAogICAgImdyYW1tYXJzIjogWwogICAgICB7CiAgICAgICAgImxhbmd1YWdlIjogIjRkIiwKICAgICAgICAic2NvcGVOYW1lIjogInNvdXJjZS40ZG0iLAogICAgICAgICJwYXRoIjogIi4vc3ludGF4ZXMvNGQudG1MYW5ndWFnZS5qc29uIgogICAgICB9CiAgICBdCiAgfSwKICAicmVwb3NpdG9yeSI6IHsKICAgICJ0eXBlIjogImdpdCIsCiAgICAidXJsIjogImh0dHBzOi8vZ2l0aHViLmNvbS9taWNyb3NvZnQvdnNjb2RlLmdpdCIKICB9Cn0K", import.meta.url).toString(),
  { mimeType: "application/json", size: 1006 }
);
Q(
  "package.nls.json",
  new URL("data:application/json;base64,ewogICJkaXNwbGF5TmFtZSI6ICI0RCBMYW5ndWFnZSBCYXNpY3MiLAogICJkZXNjcmlwdGlvbiI6ICJQcm92aWRlcyBzeW50YXggaGlnaGxpZ2h0aW5nIGFuZCBicmFja2V0IG1hdGNoaW5nIGZvciA0RE0gYW5kIDRRUyBmaWxlcy4iCn0K", import.meta.url).toString(),
  { mimeType: "application/json", size: 135 }
);
export {
  Vn as Alerts,
  Pn as CodeEditor,
  Jn as CodeEditorProvider,
  en as FdLineNumbers,
  Gn as LSPProvider,
  ie as SUPPORTED_THEMES,
  Ce as _await,
  vt as configureServices,
  E as getFileSystemPath,
  On as getFunctionOffset,
  ht as initMonacoUserConfiguration,
  xt as isCssModel,
  Rt as jumpToLine,
  Nt as jumpToSelection,
  Xt as useCodeEditor,
  Mn as useLSP
};
//# sourceMappingURL=index.es.js.map
