var Se = Object.defineProperty;
var ye = (n, e, t) => e in n ? Se(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
var F = (n, e, t) => (ye(n, typeof e != "symbol" ? e + "" : e, t), t);
import { jsxs as J, jsx as w, Fragment as Ne } from "react/jsx-runtime";
import T, { useEffect as M, createContext as re, useState as _, useRef as ne, useContext as se, memo as Re } from "react";
import { loader as xe, useMonaco as we, Editor as ke } from "@monaco-editor/react";
import { lspSubject as Le, LspActions as X, hasAttributesString as le, HTTP_HANDLERS_PATH as We, FileFolderType as Fe } from "@ws-ui/shared";
import { MonacoLanguageClient as Ze } from "monaco-languageclient";
import { mergeServices as je, initServices as Xe } from "monaco-languageclient/vscode/services";
import Ee, { initUserConfiguration as Ke } from "@codingame/monaco-vscode-configuration-service-override";
import Be from "@codingame/monaco-vscode-languages-service-override";
import Te from "@codingame/monaco-vscode-textmate-service-override";
import "@codingame/monaco-vscode-theme-defaults-default-extension";
import Oe from "@codingame/monaco-vscode-editor-service-override";
import De from "@codingame/monaco-vscode-theme-service-override";
import * as s from "monaco-editor";
import { Selection as Ge, KeyMod as D, KeyCode as G, editor as ae, Range as Je, Uri as Me, CancellationTokenSource as Pe } from "monaco-editor";
import { Logger as Ve } from "monaco-languageclient/tools";
import { ErrorAction as Ye, CloseAction as He } from "vscode-languageclient";
import { WebSocketMessageReader as ze, WebSocketMessageWriter as _e, toSocket as $e } from "vscode-ws-jsonrpc";
import { DocumentDiagnosticRequest as Ue, WillSaveTextDocumentNotification as qe, TextDocumentSaveReason as Qe, DidSaveTextDocumentNotification as et, WillCreateFilesRequest as tt, WillRenameFilesRequest as nt, WillDeleteFilesRequest as it, DidCreateFilesNotification as ot, DidRenameFilesNotification as rt, DidDeleteFilesNotification as st, SemanticTokensRegistrationType as lt } from "vscode-languageserver-protocol";
import { StandaloneServices as at, ICodeEditorService as gt } from "vscode/services";
import { KeybindingsRegistry as q } 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 ut = () => Ee(), dt = () => Oe(
  () => Promise.resolve(void 0)
), It = () => {
  const n = De(), e = n.themeService.ctor.prototype;
  return e.defineTheme = () => {
  }, n;
}, Ct = `{
  "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 }
      }
    }
  }
}
`, mt = () => Ke(Ct), ft = async (n) => {
  var o;
  const e = n.serviceConfig ?? {};
  e.debugLogging = ((o = n.logger) == null ? void 0 : o.isEnabled()) === !0 && (e.debugLogging === !0 || n.logger.isDebugEnabled() === !0), await mt(), e.userServices = e.userServices ?? {};
  const t = e.userServices.configurationService ?? void 0, i = e.workspaceConfig ?? void 0;
  if (t === void 0) {
    if (i)
      throw new Error(
        "You provided a workspaceConfig without using the configurationServiceOverride"
      );
    const l = {
      // @see https://github.com/CodinGame/monaco-vscode-api#monaco-standalone-services
      ...ut(),
      ...It(),
      ...Te(),
      ...Be(),
      ...dt()
    };
    je(l, e.userServices);
  }
  return i || (e.workspaceConfig = {
    workspaceProvider: {
      trusted: !0,
      workspace: {
        workspaceUri: s.Uri.file("/workspace")
      },
      async open() {
        return !1;
      }
    }
  }), e;
};
class At extends ze {
  constructor(t, i) {
    super(t);
    F(this, "onMessage");
    this.onMessage = i;
  }
  readMessage(t) {
    this.onMessage && this.onMessage();
    const [, i] = t.split(`\r
\r
`);
    if (this.state === "initial")
      this.events.splice(0, 0, { message: i });
    else if (this.state === "listening") {
      const o = JSON.parse(i);
      this.callback(o);
    }
  }
}
class pt extends _e {
  constructor(t, i) {
    super(t);
    F(this, "onSend");
    this.onSend = i;
  }
  async write(t) {
    try {
      const i = JSON.stringify(t);
      this.socket.send(i), this.onSend && this.onSend();
    } catch (i) {
      this.errorCount++, this.fireError(i, t, this.errorCount);
    }
  }
}
function j(n, e = !0) {
  const t = `/PACKAGE/Project/Sources/${n}`;
  return e ? `file://${t}` : t;
}
function ge(n, e = 0) {
  setTimeout(n, e);
}
function bt(n, e) {
  const t = new Ge(
    e.startLineNumber,
    e.startColumn,
    e.endLineNumber || e.startLineNumber,
    e.endColumn || e.startColumn
  );
  ge(() => {
    n.setSelection(t), n.revealRangeInCenter(t), n.focus();
  });
}
function ht(n, e, t = 0) {
  t > 0 && (e = t + e), ge(() => {
    n.setPosition({ lineNumber: e, column: 1 }), n.revealLineInCenter(e), n.focus();
  });
}
function wn(n, e, t) {
  const o = n.getModel();
  if (o && e) {
    const l = o.getLineCount();
    for (let r = 1; r <= l; r++) {
      const I = o.getLineContent(r);
      if (new RegExp(`(?:Function|function) ${t}`).test(I))
        return r;
    }
  }
  return 0;
}
const vt = {
  provideCompletionItems: async (n, e) => {
    const t = n.getWordUntilPosition(e);
    return {
      suggestions: [
        {
          label: "var",
          kind: s.languages.CompletionItemKind.Snippet,
          range: new s.Range(
            e.lineNumber,
            t.startColumn,
            e.lineNumber,
            t.endColumn
          ),
          insertText: ["var ${1:var_name} : ${2:var_type}"].join(`
`),
          insertTextRules: s.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "While",
          kind: s.languages.CompletionItemKind.Snippet,
          range: new s.Range(
            e.lineNumber,
            t.startColumn,
            e.lineNumber,
            t.endColumn
          ),
          insertText: [
            "While(${1:expression})",
            "	${2:body}",
            "End while"
          ].join(`
`),
          insertTextRules: s.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "Case of",
          kind: s.languages.CompletionItemKind.Snippet,
          range: new s.Range(
            e.lineNumber,
            t.startColumn,
            e.lineNumber,
            t.endColumn
          ),
          insertText: [
            "Case of",
            "	:(${1:boolean_expression})",
            "		${2:body}",
            "End case"
          ].join(`
`),
          insertTextRules: s.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "Else",
          kind: s.languages.CompletionItemKind.Snippet,
          range: new s.Range(
            e.lineNumber,
            t.startColumn,
            e.lineNumber,
            t.endColumn
          ),
          insertText: ["Else", "	"].join(`
`),
          insertTextRules: s.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "If",
          kind: s.languages.CompletionItemKind.Snippet,
          range: new s.Range(
            e.lineNumber,
            t.startColumn,
            e.lineNumber,
            t.endColumn
          ),
          insertText: ["If (${1:expression})", "	${5:body}", "End if"].join(
            `
`
          ),
          insertTextRules: s.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "For",
          kind: s.languages.CompletionItemKind.Snippet,
          range: new s.Range(
            e.lineNumber,
            t.startColumn,
            e.lineNumber,
            t.endColumn
          ),
          insertText: [
            "For(${1:counter};${2:start};${3:end}${4:;increment})",
            "	${5:body}",
            "End for"
          ].join(`
`),
          insertTextRules: s.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "Function",
          kind: s.languages.CompletionItemKind.Snippet,
          range: new s.Range(
            e.lineNumber,
            t.startColumn,
            e.lineNumber,
            t.endColumn
          ),
          insertText: [
            "Function ${1:function_name}(${2:params}) -> ${3:var_name} : ${4:var_type}",
            "	${5:body}"
          ].join(`
`),
          insertTextRules: s.languages.CompletionItemInsertTextRule.InsertAsSnippet
        }
      ]
    };
  }
}, St = {
  provideCompletionItems: async (n, e) => {
    const t = n.getWordUntilPosition(e);
    return {
      suggestions: [
        {
          label: "var",
          kind: s.languages.CompletionItemKind.Snippet,
          range: new s.Range(
            e.lineNumber,
            t.startColumn,
            e.lineNumber,
            t.endColumn
          ),
          insertText: ["var ${1:var_name} : ${2:var_type}"].join(`
`),
          insertTextRules: s.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "while",
          kind: s.languages.CompletionItemKind.Snippet,
          range: new s.Range(
            e.lineNumber,
            t.startColumn,
            e.lineNumber,
            t.endColumn
          ),
          insertText: ["while(${1:expression})", "	${2:body}", "end"].join(
            `
`
          ),
          insertTextRules: s.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "switch",
          kind: s.languages.CompletionItemKind.Snippet,
          range: new s.Range(
            e.lineNumber,
            t.startColumn,
            e.lineNumber,
            t.endColumn
          ),
          insertText: [
            "switch",
            "	:(${1:boolean_expression})",
            "		${2:body}",
            "end"
          ].join(`
`),
          insertTextRules: s.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "else",
          kind: s.languages.CompletionItemKind.Snippet,
          range: new s.Range(
            e.lineNumber,
            t.startColumn,
            e.lineNumber,
            t.endColumn
          ),
          insertText: ["else", "	"].join(`
`),
          insertTextRules: s.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "if",
          kind: s.languages.CompletionItemKind.Snippet,
          range: new s.Range(
            e.lineNumber,
            t.startColumn,
            e.lineNumber,
            t.endColumn
          ),
          insertText: ["if (${1:expression})", "	${5:body}", "end"].join(
            `
`
          ),
          insertTextRules: s.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "for",
          kind: s.languages.CompletionItemKind.Snippet,
          range: new s.Range(
            e.lineNumber,
            t.startColumn,
            e.lineNumber,
            t.endColumn
          ),
          insertText: [
            "for(${1:counter},${2:start},${3:end}${4:,increment})",
            "	${5:body}",
            "end"
          ].join(`
`),
          insertTextRules: s.languages.CompletionItemInsertTextRule.InsertAsSnippet
        },
        {
          label: "function",
          kind: s.languages.CompletionItemKind.Snippet,
          range: new s.Range(
            e.lineNumber,
            t.startColumn,
            e.lineNumber,
            t.endColumn
          ),
          insertText: [
            "function ${1:function_name}(${2:params}) -> ${3:var_name} : ${4:var_type}",
            "	${5:body}"
          ].join(`
`),
          insertTextRules: s.languages.CompletionItemInsertTextRule.InsertAsSnippet
        }
      ]
    };
  }
}, yt = [
  // zoom in
  {
    keybinding: D.CtrlCmd | G.NumpadAdd,
    command: "editor.action.fontZoomIn"
  },
  {
    keybinding: D.CtrlCmd | G.Equal,
    command: "editor.action.fontZoomIn"
  },
  // zoom out
  {
    keybinding: D.CtrlCmd | G.NumpadSubtract,
    command: "editor.action.fontZoomOut"
  },
  {
    keybinding: D.CtrlCmd | G.Minus,
    command: "editor.action.fontZoomOut"
  },
  // zoom reset
  {
    keybinding: D.CtrlCmd | G.Numpad0,
    command: "editor.action.fontZoomReset"
  },
  {
    keybinding: D.CtrlCmd | G.Digit0,
    command: "editor.action.fontZoomReset"
  }
], Nt = ({ defaultZoom: n }) => (M(() => {
  n !== void 0 && ae.EditorZoom.setZoomLevel(n);
}, []), null);
({}).VITE_DISABLE_MONACO_LOADER || xe.config({
  monaco: s
  // paths: {
  //   vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.41.0/min/vs",
  // },
});
var z = /* @__PURE__ */ ((n) => (n[n.NotSet = -1] = "NotSet", n[n.None = 0] = "None", n[n.Italic = 1] = "Italic", n[n.Bold = 2] = "Bold", n[n.Underline = 4] = "Underline", n[n.Strikethrough = 8] = "Strikethrough", n))(z || {}), ce = /* @__PURE__ */ ((n) => (n[n.None = 0] = "None", n[n.DefaultForeground = 1] = "DefaultForeground", n[n.DefaultBackground = 2] = "DefaultBackground", n))(ce || {}), ue = /* @__PURE__ */ ((n) => (n[n.Other = 0] = "Other", n[n.Comment = 1] = "Comment", n[n.String = 2] = "String", n[n.RegEx = 3] = "RegEx", n))(ue || {});
class Y {
  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, t) {
    const i = this.getForeground(e), o = this.getFontStyle(e);
    let l = `color: ${t[i]};`;
    o & 1 && (l += "font-style: italic;"), o & 2 && (l += "font-weight: bold;");
    let r = "";
    return o & 4 && (r += " underline"), o & 8 && (r += " line-through"), r && (l += `text-decoration:${r};`), l;
  }
  static getPresentationFromMetadata(e) {
    const t = this.getForeground(e), i = this.getFontStyle(e);
    return {
      foreground: t,
      italic: !!(i & 1),
      bold: !!(i & 2),
      underline: !!(i & 4),
      strikethrough: !!(i & 8)
    };
  }
}
function Rt(n, e, t, i) {
  const o = t.tokens.data, l = n.getLanguageId();
  let r = 0, I = 0;
  const C = i.lineNumber - 1, S = i.column - 1;
  for (let y = 0; y < o.length; y += 5) {
    const p = o[y], m = o[y + 1], N = o[y + 2], x = o[y + 3], h = o[y + 4], R = r + p, f = p === 0 ? I + m : m;
    if (C === R && f <= S && S < f + N) {
      const k = t.legend.tokenTypes[x] || "not in legend (ignored)", A = [];
      let a = h;
      for (let P = 0; a > 0 && P < t.legend.tokenModifiers.length; P++)
        a & 1 && A.push(t.legend.tokenModifiers[P]), a = a >> 1;
      a > 0 && A.push("not in legend (ignored)");
      const u = new Je(
        R + 1,
        f + 1,
        R + 1,
        f + 1 + N
      ), v = {}, L = e.getColorTheme().tokenColorMap, b = e.getColorTheme().getTokenStyleMetadata(
        k,
        A,
        l,
        !0,
        v
      );
      let B;
      return b && (B = {
        languageId: void 0,
        tokenType: ue.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: L[(b == null ? void 0 : b.foreground) || ce.None],
        background: void 0
      }), { type: k, modifiers: A, range: u, metadata: B, definitions: v };
    }
    r = R, I = f;
  }
  return null;
}
function xt(n, e, t) {
  let i = null;
  for (let o = 1; o < t; o++)
    i = e.tokenizeLine(
      n.getLineContent(o),
      i
    ).ruleStack;
  return i;
}
function wt(n, e, t) {
  const i = n.getColorTheme().tokenColorMap, o = Y.getLanguageId(t), l = Y.getTokenType(t), r = Y.getFontStyle(t), I = Y.getForeground(t), C = Y.getBackground(t);
  return {
    languageId: e.languageIdCodec.decodeLanguageId(o),
    tokenType: l,
    bold: r & z.Bold ? !0 : void 0,
    italic: r & z.Italic ? !0 : void 0,
    underline: r & z.Underline ? !0 : void 0,
    strikethrough: r & z.Strikethrough ? !0 : void 0,
    foreground: i[I],
    background: i[C]
  };
}
function kt(n, e, t) {
  const i = t.lineNumber, o = n, l = o._tokenizationTextModelPart.grammarTokens._tokenizer.tokenizationSupport._actual._grammar, r = xt(n, l, i), I = l.tokenizeLine(
    n.getLineContent(i),
    r
  ), C = l.tokenizeLine2(
    n.getLineContent(i),
    r
  );
  let S = 0;
  for (let p = I.tokens.length - 1; p >= 0; p--) {
    const m = I.tokens[p];
    if (t.column - 1 >= m.startIndex) {
      S = p;
      break;
    }
  }
  let y = 0;
  for (let p = C.tokens.length >>> 1; p >= 0; p--)
    if (t.column - 1 >= C.tokens[p << 1]) {
      y = p;
      break;
    }
  return {
    token: I.tokens[S],
    metadata: wt(
      e,
      o._languageService,
      C.tokens[(y << 1) + 1]
    )
  };
}
const de = re(void 0), kn = ({
  children: n,
  url: e,
  qodly: t,
  defaultZoom: i,
  openHandler: o,
  language: l = "4d",
  defaultInited: r = !1
}) => {
  const I = we(), [C, S] = _(r), [y, p] = _(null), m = ne(), N = ne(0);
  M(() => {
    e && I && x();
  }, [e, I]);
  const x = async () => {
    if (!I)
      return;
    const d = new Ve({
      enabled: process.env.NODE_ENV === "development",
      debugEnabled: process.env.NODE_ENV === "development"
    }), g = await ft({
      logger: d
    });
    await Xe({
      caller: "Qodly Code Editor",
      logger: d,
      serviceConfig: g
    }), o && at.get(gt).registerCodeEditorOpenHandler(o), I.languages.registerCompletionItemProvider(
      l,
      t ? St : vt
    );
    const c = q.getDefaultKeybindings.bind(q);
    q.getDefaultKeybindings = () => c().filter(
      (Z) => ![
        "workbench.action.files.saveAs",
        "workbench.action.files.save"
      ].includes(Z.command)
    ), ae.addKeybindingRules(yt), h();
  }, h = () => {
    p(null);
    let d;
    try {
      d = new WebSocket(localStorage.LSP_SERVER || e);
    } catch {
      p(new Event("INVALID_URL"));
      return;
    }
    d.onopen = R, d.onclose = f, d.onerror = k, N.current = 0;
  }, R = async function() {
    const d = $e(this), g = new At(d), c = new pt(d), W = new Ze({
      name: "4D Language Client",
      clientOptions: {
        workspaceFolder: {
          uri: Me.parse("file:///PACKAGE")
        },
        // use a language id as a document selector
        documentSelector: [{ scheme: "file", language: l }],
        // disable the default error handler
        errorHandler: {
          error: () => ({ action: Ye.Continue }),
          closed: () => ({ action: He.DoNotRestart })
        }
      },
      // create a language client connection from the JSON RPC connection on demand
      connectionProvider: {
        get: () => Promise.resolve({
          reader: g,
          writer: c
        })
      }
    });
    m.current = W;
    const Z = W.sendRequest.bind(W);
    m.current.sendRequest = function(O, V, U) {
      return typeof O == "object" && O.method === "textDocument/diagnostic" && /file:\/\/\/PACKAGE\/Project\/Sources\/Methods\/__Debugger_.*/.test(
        V.textDocument.uri
      ) ? Promise.resolve() : Z(O, V, U);
    }, g.onClose(() => {
      W.stop(), N.current < 3 ? setTimeout(() => {
        N.current++, h();
      }, 1e3) : p(new Event("WEBSOCKET_CLOSED"));
    }), W.needsStart() && await W.start(), S(!0);
  }, f = () => {
  }, k = (d) => {
    p(d);
  };
  M(() => {
    const d = Le.subscribe(({ action: g, payload: c }) => {
      switch (g) {
        case X.WILL_SAVE:
          L(c.filePath);
          break;
        case X.DID_SAVE:
          K(c.filePath, c.content);
          break;
        case X.WILL_CREATE:
          b(c.filePath);
          break;
        case X.DID_CREATE:
          Ae(c.filePath);
          break;
        case X.WILL_RENAME:
          B(c.oldPath, c.newPath);
          break;
        case X.DID_RENAME:
          pe(c.oldPath, c.newPath);
          break;
        case X.WILL_DELETE:
          P(c.filePath);
          break;
        case X.DID_DELETE:
          be(c.filePath);
          break;
        case X.DIAGNOSTIC_REFRESH:
          v(c.filePath);
          break;
      }
    });
    return () => d.unsubscribe();
  }, []);
  const A = (d) => {
    var g, c;
    return (c = (g = m.current) == null ? void 0 : g._features) == null ? void 0 : c.find(
      (W) => {
        var Z;
        return ((Z = W._registrationType) == null ? void 0 : Z.method) === d;
      }
    );
  }, a = (d) => {
    const g = [], c = A(d);
    if (c)
      for (const [W, Z] of c._registrations)
        Z.provider && g.push(Z.provider);
    return g;
  }, u = async (d, g, c) => {
    var Z, O, V;
    const W = a(
      lt.method
    );
    if (W[0]) {
      const U = new Pe(), ee = await Promise.resolve(
        W[0].full.provideDocumentSemanticTokens(
          g,
          U.token
        )
      ), te = d, he = ee ? Rt(
        g,
        te._themeService,
        {
          tokens: ee,
          legend: (V = (O = (Z = m.current) == null ? void 0 : Z._capabilities) == null ? void 0 : O.semanticTokensProvider) == null ? void 0 : V.legend
        },
        c
      ) : null, ve = kt(
        g,
        te._themeService,
        c
      );
      return {
        semanticTokenInfo: he,
        textmateTokenInfo: ve
      };
    }
    return null;
  }, v = (d) => {
    if (m.current) {
      const g = a(
        Ue.method
      );
      for (const c of g)
        c.onDidChangeDiagnosticsEmitter.fire();
    }
  }, L = (d, g = Qe.Manual) => {
    var c;
    (c = m.current) == null || c.sendNotification(qe.type, {
      textDocument: {
        uri: j(d)
      },
      reason: g
    });
  }, K = (d, g) => {
    var c;
    (c = m.current) == null || c.sendNotification(et.type, {
      textDocument: {
        uri: j(d)
      },
      text: g
    });
  }, b = (d) => {
    var g;
    (g = m.current) == null || g.sendRequest(tt.type, {
      files: [
        {
          uri: j(d)
        }
      ]
    });
  }, B = (d, g) => {
    var c;
    (c = m.current) == null || c.sendRequest(nt.type, {
      files: [
        {
          oldUri: j(d),
          newUri: j(g)
        }
      ]
    });
  }, P = (d) => {
    var g;
    (g = m.current) == null || g.sendRequest(it.type, {
      files: [
        {
          uri: j(d)
        }
      ]
    });
  }, Ae = (d) => {
    var g;
    (g = m.current) == null || g.sendNotification(ot.type, {
      files: [
        {
          uri: j(d)
        }
      ]
    });
  }, pe = (d, g) => {
    var c;
    (c = m.current) == null || c.sendNotification(rt.type, {
      files: [
        {
          oldUri: j(d),
          newUri: j(g)
        }
      ]
    });
  }, be = (d) => {
    var g;
    (g = m.current) == null || g.sendNotification(st.type, {
      files: [
        {
          uri: j(d)
        }
      ]
    });
  };
  return /* @__PURE__ */ J(
    de.Provider,
    {
      value: {
        inited: C || !!y,
        clientRef: m,
        lastError: y,
        reload: h,
        getTokenAtPosition: u
      },
      children: [
        n,
        /* @__PURE__ */ w(Nt, { defaultZoom: i })
      ]
    }
  );
};
function Ln() {
  const n = se(de);
  if (n === void 0)
    throw new Error("useLSP must be used within an LSPContext");
  return n;
}
const Ie = re(
  void 0
), Wn = Re(({ children: n }) => {
  const [e, t] = _(null);
  return /* @__PURE__ */ w(
    Ie.Provider,
    {
      value: {
        editor: e,
        setEditor: t
      },
      children: n
    }
  );
});
function Lt() {
  const n = se(Ie), e = _(null);
  if (n === void 0) {
    const [t, i] = e;
    return {
      editor: t,
      setEditor: i
    };
  }
  return n;
}
var Ce = {
  color: void 0,
  size: void 0,
  className: void 0,
  style: void 0,
  attr: void 0
}, ie = T.createContext && T.createContext(Ce), E = globalThis && globalThis.__assign || function() {
  return E = Object.assign || function(n) {
    for (var e, t = 1, i = arguments.length; t < i; t++) {
      e = arguments[t];
      for (var o in e)
        Object.prototype.hasOwnProperty.call(e, o) && (n[o] = e[o]);
    }
    return n;
  }, E.apply(this, arguments);
}, Wt = globalThis && globalThis.__rest || function(n, e) {
  var t = {};
  for (var i in n)
    Object.prototype.hasOwnProperty.call(n, i) && e.indexOf(i) < 0 && (t[i] = n[i]);
  if (n != null && typeof Object.getOwnPropertySymbols == "function")
    for (var o = 0, i = Object.getOwnPropertySymbols(n); o < i.length; o++)
      e.indexOf(i[o]) < 0 && Object.prototype.propertyIsEnumerable.call(n, i[o]) && (t[i[o]] = n[i[o]]);
  return t;
};
function me(n) {
  return n && n.map(function(e, t) {
    return T.createElement(e.tag, E({
      key: t
    }, e.attr), me(e.child));
  });
}
function fe(n) {
  return function(e) {
    return T.createElement(Ft, E({
      attr: E({}, n.attr)
    }, e), me(n.child));
  };
}
function Ft(n) {
  var e = function(t) {
    var i = n.attr, o = n.size, l = n.title, r = Wt(n, ["attr", "size", "title"]), I = o || t.size || "1em", C;
    return t.className && (C = t.className), n.className && (C = (C ? C + " " : "") + n.className), T.createElement("svg", E({
      stroke: "currentColor",
      fill: "currentColor",
      strokeWidth: "0"
    }, t.attr, i, r, {
      className: C,
      style: E(E({
        color: n.color || t.color
      }, t.style), n.style),
      height: I,
      width: I,
      xmlns: "http://www.w3.org/2000/svg"
    }), l && T.createElement("title", null, l), n.children);
  };
  return ie !== void 0 ? T.createElement(ie.Consumer, null, function(t) {
    return e(t);
  }) : e(Ce);
}
function Zt(n) {
  return fe({ tag: "svg", 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" } }] })(n);
}
function jt(n) {
  return fe({ tag: "svg", 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" } }] })(n);
}
const Xt = ({
  lspProps: { lastError: n, reload: e }
}) => {
  const [t, i] = _(!1), o = () => {
    e();
  }, l = () => {
    i(!1);
  };
  return M(() => {
    i(!!n);
  }, [n]), t ? /* @__PURE__ */ J("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__ */ J("span", { className: "flex flex-1 justify-center gap-1", children: [
      /* @__PURE__ */ w(jt, { className: "h-4 w-4 text-yellow-600" }),
      /* @__PURE__ */ J("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(
      Zt,
      {
        className: "h-4 w-4 text-white",
        onClick: l
      }
    ) })
  ] }) : null;
}, Et = {
  provideCompletionItems: (n, e) => {
    const t = n.getWordUntilPosition(e);
    return {
      suggestions: [
        {
          label: "device:xs",
          kind: s.languages.CompletionItemKind.Snippet,
          documentation: "Media query for phone device",
          range: new s.Range(
            e.lineNumber,
            t.startColumn,
            e.lineNumber,
            t.endColumn
          ),
          insertText: [
            "@media screen and (max-width: ${1:365px}) {",
            "  self {",
            "    ${2:background-color}:${3:red};",
            "  }",
            "}"
          ].join(`
`),
          insertTextRules: s.languages.CompletionItemInsertTextRule.InsertAsSnippet
        }
      ]
    };
  }
}, Kt = "#/definitions/Condition", Bt = {
  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: Kt,
  definitions: Bt
}, Ot = "array", Dt = {
  type: "object",
  properties: {
    class: {
      type: "string"
    },
    method: {
      type: "string"
    },
    regexPattern: {
      type: "string"
    },
    verbs: {
      type: "string"
    }
  }
}, Gt = {
  type: Ot,
  items: Dt
};
function Jt(n, e) {
  const t = document.createElement("style");
  t.dataset.id = e, t.textContent = n, document.head.append(t);
}
function Mt(n) {
  return Array.from(document.styleSheets).find(
    (e) => e.ownerNode.getAttribute("data-id") === n
  );
}
function Pt(n, e) {
  const t = [];
  let i = [];
  const o = [], l = (a, u, v, L) => {
    t.push({
      startLineNumber: a,
      endLineNumber: v,
      startColumn: u,
      endColumn: L
    }), S(), C();
  }, r = (a) => {
    o.indexOf(a) < 0 && o.push(a);
  }, I = (a) => {
    const u = o.indexOf(a);
    u < 0 || o.splice(u, 1);
  }, C = () => {
    for (const a of o)
      try {
        a(i);
      } catch (u) {
        console.error(u);
      }
  }, S = () => {
    const a = n.getModel();
    a && (i = Yt(
      t.map((u) => [
        a.getOffsetAt({
          lineNumber: u.startLineNumber,
          column: u.startColumn
        }),
        a.getOffsetAt({
          lineNumber: u.endLineNumber,
          column: u.endColumn
        })
      ]),
      /*mergeJoins*/
      !0
    ), i.length > 0 && (i[0][0] <= 0 && (i[0][0] = Number.NEGATIVE_INFINITY), i[i.length - 1][1] >= a.getValueLength() && (i[i.length - 1][1] = Number.POSITIVE_INFINITY)));
  }, y = (a) => {
    const u = {
      isDeletion: !1,
      isAddition: !1,
      isReplacement: !1
    };
    return a.text === "" ? u.isDeletion = !0 : a.range.startLineNumber === a.range.endLineNumber && a.range.startColumn === a.range.endColumn ? u.isAddition = !0 : u.isReplacement = !0, u;
  }, p = n.onDidChangeModel((a) => {
    S(), k();
  }), m = n.onDidChangeModelContent((a) => {
    if (!a.isUndoing)
      for (const u of a.changes) {
        const v = y(u);
        if (v.isReplacement || v.isDeletion || v.isAddition) {
          const L = t.some(
            (b) => u.range.startLineNumber >= b.startLineNumber && u.range.endLineNumber <= b.endLineNumber && u.range.startColumn >= b.startColumn && u.range.endColumn <= b.endColumn
          ), K = !L && e && u.range.startLineNumber === 1 && u.range.startColumn === 1 && !le(u.text);
          if (L || K) {
            const b = n.getModel();
            if (b) {
              b.undo();
              return;
            }
          }
        }
      }
  }), N = () => {
    p.dispose(), m.dispose();
  };
  let x = [], h = `
    .idoc-readonly-mark {
      cursor: not-allowed;
      z-index: 1;
    }
  `;
  if (h) {
    const a = "monaco-read-only";
    Mt(a) || Jt(h, a), h = null;
  }
  const R = () => {
    r(k), k();
  }, f = () => {
    I(k), x = n.deltaDecorations(x, []);
  }, k = () => {
    const a = n.getModel();
    a && (x = n.deltaDecorations(
      x,
      i.map(A(a))
    ));
  }, A = (a) => (u) => {
    const v = a.getPositionAt(u[0]), L = a.getPositionAt(u[1]);
    return {
      range: new s.Range(
        v.lineNumber,
        v.column,
        L.lineNumber,
        L.column
      ),
      options: {
        className: "idoc-readonly-mark"
      }
    };
  };
  return {
    get buffer() {
      return i;
    },
    exclude: l,
    attach: r,
    detach: I,
    dispose: N,
    show: R,
    hide: f
  };
}
function Vt(n, e, t) {
  let i = !1;
  const o = (f) => f[1] < f[0] ? (i = !0, [[f[1], f[0]]]) : [[...f]], l = (f) => i ? f.map((k) => k[1] > k[0] ? I(k) : k).reverse() : f;
  let r;
  const I = (f) => (r = f[1], f[1] = f[0], f[0] = r, f), C = o(n);
  let S, y, p, m, N, x, h, R;
  p = C[0];
  for (y of e)
    for (h = y[0], R = y[1], m = 0; m < C.length; m++) {
      if (p = C[m], N = p[0], x = p[1], N < h)
        x < h ? S = [p] : x <= R ? S = [[N, h - 1]] : S = [
          [N, h - 1],
          [R + 1, x]
        ];
      else if (N <= R)
        if (h === Number.NEGATIVE_INFINITY) {
          const f = R + 1;
          S = t === 0 ? [] : [[f, x > f ? x : f]];
        } else
          R === Number.POSITIVE_INFINITY ? S = t === 0 ? [] : [[h - 1, h - 1]] : x <= R ? S = t < 0 ? [[h - 1, h - 1]] : t > 0 ? [[R + 1, R + 1]] : [] : S = [[R + 1, x]];
      else
        S = [p];
      if (C.splice(m, 1, ...S), C.length === 1 && C[0][1] < h)
        return l(C);
    }
  return l(C);
}
function Yt(n, e) {
  if (n.length < 2)
    return n;
  const t = [];
  let i = null, o, l;
  n = n.map(
    (r) => (r[1] < r[0] && (o = r[1], r[1] = r[0], r[1] = o), r)
  ).sort((r, I) => r[0] - I[0]), t.push(n[0]);
  for (let r = 1; r < n.length; r++)
    i = t[t.length - 1], l = n[r], i[1] === l[0] && !e ? t.push(l) : i[1] === l[0] - 1 && e ? (i[1] = l[1], t.splice(t.length - 1, 1, i)) : i[1] < l[0] ? t.push(l) : i[1] < l[1] && (i[1] = l[1], t.splice(t.length - 1, 1, i));
  return t;
}
function H(n, e) {
  return e.bind(n);
}
class Ht {
  constructor(e, t) {
    F(this, "editor");
    F(this, "intervals");
    F(this, "disposables", []);
    /**
     * Flag for `excludeIntervals`
     */
    F(this, "prefer", 1);
    F(this, "lastPrefer", 1);
    /**
     * Linked to ICodeEditor.onDidChangeCursorPosition event.
     */
    F(this, "onCursor", H(
      this,
      function(e) {
        if (e.source === "api")
          return;
        const t = this.getApprovedSelections();
        t.length !== 0 && this.editor.setSelections(t);
      }
    ));
    F(this, "onRectangleSelectionStart", H(this, function({ event: e }) {
      e.middleButton && (this.lastPrefer = this.prefer, this.prefer = 0, window.addEventListener("pointerup", this.onRectangleSelectionStop));
    }));
    F(this, "onRectangleSelectionStop", H(this, function() {
      this.prefer = this.lastPrefer, window.removeEventListener("pointerup", this.onRectangleSelectionStop);
    }));
    /**
     * Linked to ICodeEditor.onKeyDown event.
     */
    F(this, "onKey", H(this, function(e) {
      const t = e.keyCode, i = s.KeyCode;
      if (e.altKey || i.F1 <= t && t <= i.F19 || e.ctrlKey && t !== i.Backspace)
        return;
      if (t === i.UpArrow || t === i.LeftArrow || t === i.Home || t === i.PageUp) {
        this.prefer = -1;
        return;
      }
      if (t === i.DownArrow || t === i.RightArrow || t === i.End || t === i.PageDown) {
        this.prefer = 1;
        return;
      }
      const o = this.getSelections(), l = this.intervals.buffer;
      let r;
      if (t === i.Delete)
        r = (I) => I[0] === I[1] && l.find((C) => I[1] + 1 === C[0]) != null;
      else if (t === i.Backspace)
        r = (I) => I[0] === I[1] && l.find((C) => C[1] + 1 === I[0]) != null;
      else
        return;
      o.findIndex(r) !== -1 && (e.stopPropagation(), e.preventDefault());
    }));
    F(this, "getOffsetAt", H(this, function(e) {
      let t;
      for (let i = 0; i < this.intervals.buffer.length; i++)
        if (t = this.intervals.buffer[i], e <= t[1])
          return t[0] - e < e - t[1] ? t[0] : t[1];
    }));
    var i;
    this.editor = e, this.intervals = Pt(e, t), (i = this.editor.getModel()) == null || i.setEOL(s.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, t, i, o) {
    arguments.length === 1 ? this.intervals.exclude(e, 0, e, Number.MAX_SAFE_INTEGER) : this.intervals.exclude(e, t, i, o);
  }
  getApprovedSelections() {
    const e = this.editor.getModel();
    return this.getSelections().map(
      (i) => Vt(
        i,
        this.intervals.buffer,
        this.prefer
      )
    ).flat().map((i) => {
      const o = e.getPositionAt(i[0]), l = e.getPositionAt(i[1]);
      return new s.Selection(
        o.lineNumber,
        o.column,
        l.lineNumber,
        l.column
      );
    });
  }
  getSelections() {
    const e = this.editor.getModel();
    return (this.editor.getSelections() || []).map((t) => [
      e.getOffsetAt({
        lineNumber: t.selectionStartLineNumber,
        column: t.selectionStartColumn
      }),
      e.getOffsetAt({
        lineNumber: t.positionLineNumber,
        column: t.positionColumn
      })
    ]);
  }
}
const zt = new RegExp("^[	s]+(exposed|Function)", "i"), oe = () => /* @__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__ */ J("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" })
] }) }) }), Q = ["fd-dark"], Fn = ({
  path: n,
  initialValue: e,
  type: t,
  language: i,
  onChange: o,
  options: l = {},
  extra: r = {},
  showAlerts: I = !1,
  lspProps: C,
  theme: S = Q[0],
  ...y
}) => {
  const { initialLineInfo: p, initialSelectionInfo: m } = r, { editor: N, setEditor: x } = Lt(), { inited: h } = C;
  function R(A) {
    i === "css" && A.languages.registerCompletionItemProvider("css", Et), i === "json" && A.languages.json && A.languages.json.jsonDefaults.setDiagnosticsOptions({
      validate: !0,
      schemas: [
        {
          uri: "condition-schema.json",
          fileMatch: ["*.condition.json"],
          schema: Tt
        },
        {
          uri: "handlers-schema.json",
          fileMatch: [We],
          schema: Gt
        }
      ]
    });
  }
  function f(A, a) {
    x(A);
    const u = A.getModel();
    if (u && (u.updateOptions({ insertSpaces: !1 }), A.onKeyUp(() => {
      var L;
      const v = (L = A.getPosition()) == null ? void 0 : L.lineNumber;
      if (v) {
        const K = u.getLineFirstNonWhitespaceColumn(v), b = u.getLineLength(v), B = u.getLineContent(v);
        zt.test(B) && A.executeEdits("edit-handler", [
          {
            range: new a.Range(
              v,
              0,
              v,
              b
            ),
            text: B.substr(
              K - 1,
              b - K
            )
          }
        ]);
      }
    })), t === Fe.METHOD && le(e)) {
      const v = new Ht(A, !0);
      v.exclude(1, 1, 1, Number.POSITIVE_INFINITY), v.enable();
    }
  }
  M(() => {
    if (!N)
      return;
    const { line: A, offset: a } = p || {};
    A && ht(N, A, a);
  }, [p, N]), M(() => {
    if (!N)
      return;
    const { selection: A } = m || {};
    A && bt(N, A);
  }, [m, N]);
  const k = (A) => Q.includes(A) ? A : Q[0];
  return h ? /* @__PURE__ */ J(Ne, { children: [
    I ? /* @__PURE__ */ w(Xt, { lspProps: C }) : null,
    /* @__PURE__ */ w(
      ke,
      {
        options: {
          readOnly: !0,
          fontSize: 12,
          "semanticHighlighting.enabled": !0,
          padding: { top: 10 },
          ...l
        },
        path: j(n),
        value: e,
        theme: k(S),
        onChange: (A) => o && o(A || ""),
        language: i,
        beforeMount: R,
        onMount: f,
        loading: /* @__PURE__ */ w(oe, {}),
        ...y
      }
    )
  ] }) : /* @__PURE__ */ w(oe, {});
}, _t = {
  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: $, whenReady: Zn } = ct(_t, void 0, {
  system: !0
});
$(
  "./syntaxes/4d.tmLanguage.json",
  new URL("data:application/json;base64,ewogICJuYW1lIjogIjREIiwKICAic2NvcGVOYW1lIjogInNvdXJjZS40ZG0iLAogICJwYXR0ZXJucyI6IFsKICAgIHsKICAgICAgImluY2x1ZGUiOiAiI3N0YXRlbWVudHMiCiAgICB9CiAgXSwKICAicmVwb3NpdG9yeSI6IHsKICAgICJzdGF0ZW1lbnRzIjogewogICAgICAicGF0dGVybnMiOiBbCiAgICAgICAgewogICAgICAgICAgImluY2x1ZGUiOiAiI2NvbW1lbnQiCiAgICAgICAgfQogICAgICBdCiAgICB9LAogICAgImNvbW1lbnQiOiB7CiAgICAgICJwYXR0ZXJucyI6IFsKICAgICAgICB7CiAgICAgICAgICAibmFtZSI6ICJjb21tZW50LmJsb2NrLjRkIiwKICAgICAgICAgICJiZWdpbiI6ICIoL1xcKikoPzpcXHMqKChAKWludGVybmFsKSg/PVxcc3woXFwqLykpKT8iLAogICAgICAgICAgImJlZ2luQ2FwdHVyZXMiOiB7CiAgICAgICAgICAgICIxIjogewogICAgICAgICAgICAgICJuYW1lIjogInB1bmN0dWF0aW9uLmRlZmluaXRpb24uY29tbWVudC40ZCIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgIjIiOiB7CiAgICAgICAgICAgICAgIm5hbWUiOiAic3RvcmFnZS50eXBlLmludGVybmFsZGVjbGFyYXRpb24uNGQiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgICIzIjogewogICAgICAgICAgICAgICJuYW1lIjogInB1bmN0dWF0aW9uLmRlY29yYXRvci5pbnRlcm5hbGRlY2xhcmF0aW9uLjRkIgogICAgICAgICAgICB9CiAgICAgICAgICB9LAogICAgICAgICAgImVuZCI6ICJcXCovIiwKICAgICAgICAgICJlbmRDYXB0dXJlcyI6IHsKICAgICAgICAgICAgIjAiOiB7CiAgICAgICAgICAgICAgIm5hbWUiOiAicHVuY3R1YXRpb24uZGVmaW5pdGlvbi5jb21tZW50LjRkIgogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICAiYmVnaW4iOiAiKF5bIFxcdF0rKT8oKC8vKSg/OlxccyooKEApaW50ZXJuYWwpKD89XFxzfCQpKT8pIiwKICAgICAgICAgICJiZWdpbkNhcHR1cmVzIjogewogICAgICAgICAgICAiMSI6IHsKICAgICAgICAgICAgICAibmFtZSI6ICJwdW5jdHVhdGlvbi53aGl0ZXNwYWNlLmNvbW1lbnQubGVhZGluZy40ZCIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgIjIiOiB7CiAgICAgICAgICAgICAgIm5hbWUiOiAiY29tbWVudC5saW5lLmRvdWJsZS1zbGFzaC40ZCIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgIjMiOiB7CiAgICAgICAgICAgICAgIm5hbWUiOiAicHVuY3R1YXRpb24uZGVmaW5pdGlvbi5jb21tZW50LjRkIgogICAgICAgICAgICB9LAogICAgICAgICAgICAiNCI6IHsKICAgICAgICAgICAgICAibmFtZSI6ICJzdG9yYWdlLnR5cGUuaW50ZXJuYWxkZWNsYXJhdGlvbi40ZCIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgIjUiOiB7CiAgICAgICAgICAgICAgIm5hbWUiOiAicHVuY3R1YXRpb24uZGVjb3JhdG9yLmludGVybmFsZGVjbGFyYXRpb24uNGQiCiAgICAgICAgICAgIH0KICAgICAgICAgIH0sCiAgICAgICAgICAiZW5kIjogIig/PSQpIiwKICAgICAgICAgICJjb250ZW50TmFtZSI6ICJjb21tZW50LmxpbmUuZG91YmxlLXNsYXNoLjRkIgogICAgICAgIH0KICAgICAgXQogICAgfQogIH0KfQo=", self.location).toString(),
  { mimeType: "application/json", size: 1592 }
);
$(
  "./language-configuration.json",
  new URL("data:application/json;base64,ewogICJjb21tZW50cyI6IHsKICAgICJsaW5lQ29tbWVudCI6ICIvLyIsCiAgICAiYmxvY2tDb21tZW50IjogWyIvKioiLCAiKiovIl0KICB9LAogIC8vIHN5bWJvbHMgdXNlZCBhcyBicmFja2V0cwogICJicmFja2V0cyI6IFsKICAgIFsieyIsICJ9Il0sCiAgICBbIigiLCAiKSJdLAogICAgWyJbIiwgIl0iXQogIF0sCiAgLy8gc3ltYm9scyB0aGF0IGFyZSBhdXRvIGNsb3NlZCB3aGVuIHR5cGluZwogIC8vIHN5bWJvbHMgdGhhdCB0aGF0IGNhbiBiZSB1c2VkIHRvIHN1cnJvdW5kIGEgc2VsZWN0aW9uCiAgInN1cnJvdW5kaW5nUGFpcnMiOiBbCiAgICBbInsiLCAifSJdLAogICAgWyJbIiwgIl0iXSwKICAgIFsiKCIsICIpIl0sCiAgICBbIlwiIiwgIlwiIl0sCiAgICBbIiciLCAiJyJdCiAgXSwKICAiYXV0b0Nsb3NpbmdQYWlycyI6IFsKICAgIHsKICAgICAgIm9wZW4iOiAiKCIsCiAgICAgICJjbG9zZSI6ICIpIgogICAgfSwKICAgIHsgIm9wZW4iOiAieyIsICJjbG9zZSI6ICJ9IiB9LAogICAgeyAib3BlbiI6ICJbIiwgImNsb3NlIjogIl0iIH0sCiAgICB7ICJvcGVuIjogIiciLCAiY2xvc2UiOiAiJyIsICJub3RJbiI6IFsic3RyaW5nIiwgImNvbW1lbnQiXSB9LAogICAgeyAib3BlbiI6ICJcIiIsICJjbG9zZSI6ICJcIiIsICJub3RJbiI6IFsic3RyaW5nIl0gfSwKICAgIHsgIm9wZW4iOiAiYCIsICJjbG9zZSI6ICJgIiwgIm5vdEluIjogWyJzdHJpbmciLCAiY29tbWVudCJdIH0sCiAgICB7ICJvcGVuIjogIi8qKiIsICJjbG9zZSI6ICIgKiovIiwgIm5vdEluIjogWyJzdHJpbmciXSB9CiAgXSwKICAiYXV0b0Nsb3NlQmVmb3JlIjogIjs6Liw9fV0pPmAgXG5cdCIsCiAgIndvcmRQYXR0ZXJuIjogIigtP1xcZCpcXC5cXGRcXHcqKXwoW15cXGBcXH5cXCFcXEBcXCNcXCVcXF5cXCZcXCpcXChcXClcXC1cXD1cXCtcXFtcXHtcXF1cXH1cXFxcXFx8XFw7XFw6XFwnXFxcIlxcLFxcLlxcPFxcPlxcL1xcP1xcclxcblxcdFxcZlxcdiBdKyl8KD88PVthLXpBLVpdKSA/KD89W2EtekEtWl0pIiwKICAiaW5kZW50YXRpb25SdWxlcyI6IHsKICAgICJpbmNyZWFzZUluZGVudFBhdHRlcm4iOiB7CiAgICAgICJwYXR0ZXJuIjogIiheKD8hW15cXHNdKSpcXHMqKGNsYXNzIGNvbnN0cnVjdG9yKSl8KF4oPyFbXlxcc10pKlxccyooZXhwb3NlZHxsb2NhbHxcXHMqKXsxfVxccypmdW5jdGlvbnsxfVxccypcXHcpfCheKD8hW15cXHNdKSpcXHMqKElmfEVsc2V8Rm9yfEZvciBlYWNofFdoaWxlfEJlZ2luIFNRTHxDYXNlIG9mfFVzZXxSZXBlYXR8OiAqXFwoLiopKS4qJCIsCiAgICAgICJmbGFncyI6ICJpIgogICAgfSwKICAgICJkZWNyZWFzZUluZGVudFBhdHRlcm4iOiB7CiAgICAgICJwYXR0ZXJuIjogIiheKD8hW15cXHNdKSpcXHMqKGV4cG9zZWR8bG9jYWx8XFxzKil7MX1cXHMqZnVuY3Rpb257MX1cXHMqXFx3KXwoRW5kIElmfEVuZCBGb3J8RWxzZXxFbmQgZm9yIGVhY2h8RW5kIFdoaWxlfEVuZCBTUUx8RW5kIGNhc2V8RW5kIHVzZXxVbnRpbHw6ICpcXCguKikuKiQiLAogICAgICAiZmxhZ3MiOiAiaSIKICAgIH0KICB9LAogICJvbkVudGVyUnVsZXMiOiBbCiAgICB7CiAgICAgICJiZWZvcmVUZXh0IjogewogICAgICAgICJwYXR0ZXJuIjogIl5leHBvc2VkIiwKICAgICAgICAiZmxhZ3MiOiAiaSIKICAgICAgfSwKICAgICAgImFjdGlvbiI6IHsgImluZGVudCI6ICJpbmRlbnQiLCAiaW5kZW50QWN0aW9uIjogMSB9CiAgICB9CiAgXQp9Cg==", self.location).toString(),
  { mimeType: "application/json", size: 1723 }
);
$(
  "package.json",
  new URL("data:application/json;base64,ewogICJuYW1lIjogIjRkIiwKICAiZGlzcGxheU5hbWUiOiAiJWRpc3BsYXlOYW1lJSIsCiAgImRlc2NyaXB0aW9uIjogIiVkZXNjcmlwdGlvbiUiLAogICJ2ZXJzaW9uIjogIjEuMC4wIiwKICAicHVibGlzaGVyIjogInZzY29kZSIsCiAgImxpY2Vuc2UiOiAiTUlUIiwKICAiZW5naW5lcyI6IHsKICAgICJ2c2NvZGUiOiAiMC4xMC54IgogIH0sCiAgInNjcmlwdHMiOiB7CiAgICAidXBkYXRlLWdyYW1tYXIiOiAibm9kZSAuLi9ub2RlX21vZHVsZXMvdnNjb2RlLWdyYW1tYXItdXBkYXRlci9iaW4gbWljcm9zb2Z0L3ZzY29kZS00ZCBncmFtbWFycy80ZC5jc29uIC4vc3ludGF4ZXMvNGQudG1MYW5ndWFnZS5qc29uIgogIH0sCiAgImNhdGVnb3JpZXMiOiBbCiAgICAiUHJvZ3JhbW1pbmcgTGFuZ3VhZ2VzIgogIF0sCiAgImNvbnRyaWJ1dGVzIjogewogICAgImxhbmd1YWdlcyI6IFsKICAgICAgewogICAgICAgICJpZCI6ICI0ZCIsCiAgICAgICAgImFsaWFzZXMiOiBbCiAgICAgICAgICAiNEQiLAogICAgICAgICAgIjRkIgogICAgICAgIF0sCiAgICAgICAgImV4dGVuc2lvbnMiOiBbCiAgICAgICAgICAiLjRkbSIsCiAgICAgICAgICAiLjRxcyIKICAgICAgICBdLAogICAgICAgICJjb25maWd1cmF0aW9uIjogIi4vbGFuZ3VhZ2UtY29uZmlndXJhdGlvbi5qc29uIgogICAgICB9CiAgICBdLAogICAgImdyYW1tYXJzIjogWwogICAgICB7CiAgICAgICAgImxhbmd1YWdlIjogIjRkIiwKICAgICAgICAic2NvcGVOYW1lIjogInNvdXJjZS40ZG0iLAogICAgICAgICJwYXRoIjogIi4vc3ludGF4ZXMvNGQudG1MYW5ndWFnZS5qc29uIgogICAgICB9CiAgICBdCiAgfSwKICAicmVwb3NpdG9yeSI6IHsKICAgICJ0eXBlIjogImdpdCIsCiAgICAidXJsIjogImh0dHBzOi8vZ2l0aHViLmNvbS9taWNyb3NvZnQvdnNjb2RlLmdpdCIKICB9Cn0K", self.location).toString(),
  { mimeType: "application/json", size: 1006 }
);
$(
  "package.nls.json",
  new URL("data:application/json;base64,ewogICJkaXNwbGF5TmFtZSI6ICI0RCBMYW5ndWFnZSBCYXNpY3MiLAogICJkZXNjcmlwdGlvbiI6ICJQcm92aWRlcyBzeW50YXggaGlnaGxpZ2h0aW5nIGFuZCBicmFja2V0IG1hdGNoaW5nIGZvciA0RE0gYW5kIDRRUyBmaWxlcy4iCn0K", self.location).toString(),
  { mimeType: "application/json", size: 135 }
);
export {
  Xt as Alerts,
  Fn as CodeEditor,
  Wn as CodeEditorProvider,
  kn as LSPProvider,
  Q as SUPPORTED_THEMES,
  ge as _await,
  ft as configureServices,
  j as getFileSystemPath,
  wn as getFunctionOffset,
  mt as initMonacoUserConfiguration,
  ht as jumpToLine,
  bt as jumpToSelection,
  Lt as useCodeEditor,
  Ln as useLSP
};
//# sourceMappingURL=index.es.js.map
