import * as r from "monaco-editor";
const g = {
  // 关键字
  keywords: [
    "present",
    "rule",
    "start",
    "content",
    "end",
    "for",
    "in",
    "slide",
    "dynamic",
    "text",
    "name",
    "attrs",
    "behavior",
    "transition"
  ],
  // 类型关键字
  typeKeywords: ["quiz", "survey", "form", "assessment"],
  // 操作符
  operators: [":", "{", "}", "+", "."],
  // 符号
  symbols: /[=><!~?:&|+\-*\/\^%]+/,
  // 转义序列
  escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  // 数字
  digits: /\d+(_+\d+)*/,
  // 空白字符
  tokenizer: {
    root: [
      // 标识符和关键字
      [
        /[a-z_$][\w$]*/,
        {
          cases: {
            "@keywords": "keyword",
            "@typeKeywords": "type",
            "@default": "identifier"
          }
        }
      ],
      // 大写标识符（通常用于常量）
      [/[A-Z][\w\$]*/, "type.identifier"],
      // 空白字符
      { include: "@whitespace" },
      // 数字
      [/@digits/, "number"],
      // 字符串：双引号
      [/"([^"\\]|\\.)*$/, "string.invalid"],
      // 未闭合的字符串
      [/"/, { token: "string.quote", bracket: "@open", next: "@string_double" }],
      // 字符串：单引号
      [/'([^'\\]|\\.)*$/, "string.invalid"],
      // 未闭合的字符串
      [/'/, { token: "string.quote", bracket: "@open", next: "@string_single" }],
      // 分隔符和括号
      [/[{}()\[\]]/, "@brackets"],
      [/[;,.]/, "delimiter"],
      // 操作符
      [
        /@symbols/,
        {
          cases: {
            "@operators": "operator",
            "@default": ""
          }
        }
      ]
    ],
    // 双引号字符串
    string_double: [
      [/[^\\"]+/, "string"],
      [/@escapes/, "string.escape"],
      [/\\./, "string.escape.invalid"],
      [/"/, { token: "string.quote", bracket: "@close", next: "@pop" }]
    ],
    // 单引号字符串
    string_single: [
      [/[^\\']+/, "string"],
      [/@escapes/, "string.escape"],
      [/\\./, "string.escape.invalid"],
      [/'/, { token: "string.quote", bracket: "@close", next: "@pop" }]
    ],
    // 空白字符和注释
    whitespace: [
      [/[ \t\r\n]+/, "white"],
      [/\/\*/, "comment", "@comment"],
      [/\/\/.*$/, "comment"]
    ],
    // 多行注释
    comment: [
      [/[^/*]+/, "comment"],
      [/\/\*/, "comment", "@push"],
      [/\*\//, "comment", "@pop"],
      [/[/*]/, "comment"]
    ]
  }
};
function f() {
  r.languages.register({ id: "slide-dsl" }), r.languages.setMonarchTokensProvider("slide-dsl", g);
}
function k(e) {
  return new Worker(
    "/assets/editor.worker-CTc8sTc-.js",
    {
      name: e?.name
    }
  );
}
function w(e) {
  return new Worker(
    "/assets/json.worker-7a93y_WU.js",
    {
      name: e?.name
    }
  );
}
function W(e) {
  return new Worker(
    "/assets/css.worker-DkZpTr4B.js",
    {
      name: e?.name
    }
  );
}
function y(e) {
  return new Worker(
    "/assets/html.worker-DV998UIK.js",
    {
      name: e?.name
    }
  );
}
function h(e) {
  return new Worker(
    "/assets/ts.worker-CMaZf52j.js",
    {
      name: e?.name
    }
  );
}
function b(e, n) {
  switch (n) {
    case "json":
      return new w();
    case "css":
    case "scss":
    case "less":
      return new W();
    case "html":
    case "handlebars":
    case "razor":
      return new y();
    case "typescript":
    case "javascript":
      return new h();
    default:
      return new k();
  }
}
function v() {
  self.MonacoEnvironment || (self.MonacoEnvironment = {
    getWorker: function(e, n) {
      return b(e, n);
    }
  });
}
function $(e, n = {}) {
  v(), r.languages.getLanguages().find((s) => s.id === "slide-dsl") || f();
  const {
    value: o = "",
    theme: i = "vs-dark",
    fontSize: c = 14,
    lineNumbers: u = "on",
    minimap: d = { enabled: !0 },
    wordWrap: l = "on",
    readOnly: m = !1,
    automaticLayout: p = !0,
    onChange: a
  } = n, t = r.editor.create(e, {
    value: o,
    language: "slide-dsl",
    theme: i,
    fontSize: c,
    lineNumbers: u,
    minimap: d,
    wordWrap: l,
    readOnly: m,
    automaticLayout: p,
    scrollBeyondLastLine: !1,
    renderWhitespace: "selection",
    formatOnPaste: !1,
    formatOnType: !1
  });
  return a && t.onDidChangeModelContent(() => {
    const s = t.getValue();
    a(s);
  }), t;
}
function j(e, n) {
  e.getValue() !== n && e.setValue(n);
}
function L(e, n) {
  r.editor.setTheme(n);
}
export {
  v as configureMonacoWorkers,
  $ as createSlideDSLEditor,
  f as registerSlideDSLLanguage,
  L as setEditorTheme,
  g as slideDSLMonarchDefinition,
  j as updateEditorValue
};
//# sourceMappingURL=index.mjs.map
