var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
function magicNumbers(magicNumber) {
  const magicNumbers2 = {
    // integer values
    int0: 0,
    int1: 1,
    int2: 2,
    int3: 3,
    int4: 4,
    int5: 5,
    int6: 6,
    int7: 7,
    int16: 16,
    intMinus1: -1,
    // hex values
    hex0x3: 3,
    hex0x8: 8,
    // Keycodes (Leave for backwards compatibility)
    tabCode: 9,
    escCode: 27,
    spaceKeyCode: 32,
    arrowLeftCode: 37,
    arrowUpCode: 38,
    arrowRightCode: 39,
    arrowDownCode: 40
  };
  return Object.freeze(magicNumbers2), magicNumber in magicNumbers2 ? magicNumbers2[magicNumber] : void 0;
}
__name(magicNumbers, "magicNumbers");
function keyEvents(keyEvent) {
  const keyEvents2 = {
    arrowDown: { code: "ArrowDown", key: "ArrowDown", keyCode: 40 },
    arrowLeft: { code: "ArrowLeft", key: "ArrowLeft", keyCode: 37 },
    arrowRight: { code: "ArrowRight", key: "ArrowRight", keyCode: 39 },
    arrowUp: { code: "ArrowUp", key: "ArrowUp", keyCode: 38 },
    escape: { code: "Escape", key: "Escape", keyCode: 27 },
    keyC: { code: "KeyC", key: "c", keyCode: 67 },
    space: { code: "Space", key: " ", keyCode: 32 },
    tab: { code: "Tab", key: "Tab", keyCode: 9 },
    home: { code: "Home", key: "Home", keyCode: 36 },
    end: { code: "End", key: "End", keyCode: 35 }
  };
  return Object.freeze(keyEvents2), keyEvent in keyEvents2 ? keyEvents2[keyEvent] : void 0;
}
__name(keyEvents, "keyEvents");
function isKeyEvent(event, checkEvent) {
  const validKey = event.key && event.key === checkEvent.key && event.key === checkEvent.key, validCode = event.code && checkEvent.code && event.code === checkEvent.code, validKeyCode = event.keyCode && checkEvent.keyCode && event.keyCode === checkEvent.keyCode;
  return validKey || validCode || validKeyCode;
}
__name(isKeyEvent, "isKeyEvent");
function uuidv4() {
  const NUMERIC_0 = magicNumbers("int0"), NUMERIC_16 = magicNumbers("int16"), HEX0x3 = magicNumbers("hex0x3"), HEX0x8 = magicNumbers("hex0x8");
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (uuid) => {
    const rand = Math.random() * NUMERIC_16 | NUMERIC_0;
    return (uuid === "x" ? rand : rand & HEX0x3 | HEX0x8).toString(NUMERIC_16);
  });
}
__name(uuidv4, "uuidv4");
function checkSetElementId(element, defaultElementId = null) {
  let elementId = element.getAttribute("id");
  return elementId || (defaultElementId ? elementId = defaultElementId : elementId = uuidv4()), elementId;
}
__name(checkSetElementId, "checkSetElementId");
const pendingStyleSheets = /* @__PURE__ */ new Map();
function loadStyleSheet(styleSheetSrc) {
  if (document.querySelector(`link[rel="stylesheet"][href="${styleSheetSrc}"]`) !== null)
    return Promise.resolve();
  if (pendingStyleSheets.has(styleSheetSrc))
    return pendingStyleSheets.get(styleSheetSrc);
  const promise = new Promise((resolve, reject) => {
    if (document.querySelector(`link[rel="stylesheet"][href="${styleSheetSrc}"]`) !== null) {
      resolve();
      return;
    }
    const link = document.createElement("link");
    link.rel = "stylesheet", link.href = styleSheetSrc, link.addEventListener("load", () => {
      pendingStyleSheets.delete(styleSheetSrc), resolve();
    }), link.addEventListener("error", () => {
      pendingStyleSheets.delete(styleSheetSrc), reject(new Error(`Failed to load stylesheet: ${styleSheetSrc}`));
    }), document.head.appendChild(link);
  });
  return pendingStyleSheets.set(styleSheetSrc, promise), promise;
}
__name(loadStyleSheet, "loadStyleSheet");
function loadStyleSheets(styleSheetSrcs) {
  return Promise.all(styleSheetSrcs.map((src) => loadStyleSheet(src)));
}
__name(loadStyleSheets, "loadStyleSheets");
function stringToDom(htmlString) {
  return new DOMParser().parseFromString(htmlString, "text/html").body.firstChild;
}
__name(stringToDom, "stringToDom");
export {
  loadStyleSheets as a,
  checkSetElementId as c,
  isKeyEvent as i,
  keyEvents as k,
  loadStyleSheet as l,
  magicNumbers as m,
  stringToDom as s,
  uuidv4 as u
};
//# sourceMappingURL=chunk.dcf-utility.js.map
