import f from "@arcgis/core/request.js";
import "monaco-editor";
import { StandaloneServices as w } from "monaco-editor/esm/vs/editor/standalone/browser/standaloneServices.js";
import "monaco-editor/esm/vs/editor/standalone/common/standaloneTheme.js";
import { IHoverService as m } from "monaco-editor/esm/vs/platform/hover/browser/hover.js";
import "monaco-editor/esm/vs/editor/common/languages/supports/tokenization.js";
import "monaco-editor/esm/vs/base/browser/dom.js";
import "monaco-editor/esm/vs/editor/browser/editorDom.js";
import "monaco-editor/esm/vs/editor/browser/controller/mouseTarget.js";
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
v5.0.0-next.128 */
function g() {
  return !!window.MonacoEnvironment?.getWorker;
}
let i = "";
const k = /* @__PURE__ */ new Map(), a = !1;
async function c(t, e, r) {
  if (r)
    return e ? e() : new Worker(t);
  const o = window.location.origin;
  if (new URL(t, window.location.href).origin !== o) {
    const n = await f(t, { responseType: "text" });
    return new Worker(URL.createObjectURL(new Blob([n.data], { type: "text/javascript" })), {
      type: "module"
    });
  }
  return new Worker(t, {
    type: "module"
  });
}
function b(t) {
  if (g())
    return;
  j(), i = t;
  const e = `${i}/code-editor`, r = {
    arcade: `${e}/arcade.worker.js`,
    "arcgis-sql-expression": `${e}/sql-expr.worker.js`,
    html: `${e}/html.worker.js`,
    css: `${e}/css.worker.js`,
    typescript: `${e}/ts.worker.js`,
    json: `${e}/json.worker.js`,
    default: `${e}/editor.worker.js`
  }, o = {
    arcade: {
      url: r.arcade
    },
    "arcgis-sql-expression": {
      url: r["arcgis-sql-expression"]
    },
    html: {
      url: r.html
    },
    css: {
      url: r.css
    },
    typescript: {
      url: r.typescript
    },
    javascript: {
      url: r.typescript
    },
    json: {
      url: r.json
    },
    default: {
      url: r.default
    }
  };
  window.MonacoEnvironment = {
    getWorker: async (p, n) => {
      const s = k.get(n);
      if (s)
        return await c(s, void 0, a);
      const { url: u, localWorker: d } = o[n] || o.default;
      return await c(u, d, a);
    }
  };
}
let l = !1;
function j() {
  l || (w.get(m), l = !0);
}
async function E() {
  return (await v()).getArcadeDiagnosticService();
}
async function v() {
  return await import("./arcade-mode.js");
}
export {
  v as a,
  E as g,
  b as s
};
