var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
import { l, a, s, u } from "../chunks/chunk.dcf-utility.js?v=6.1.1";
function toAbs(link, baseUrl) {
  try {
    return new URL(link, baseUrl).toString();
  } catch (error) {
    return console.error(error), null;
  }
}
__name(toAbs, "toAbs");
function setCookie(name, value, seconds, path, domain, samesite, secure) {
  let expires = "";
  if (seconds) {
    const date = /* @__PURE__ */ new Date();
    date.setTime(date.getTime() + seconds * 1e3), expires = `;expires=${date.toUTCString()}`;
  }
  path ? path.charAt(0) !== "/" && (path = toAbs(path, window.location.pathname)) : path = "/", domain || (domain = ".unl.edu"), samesite || (samesite = "lax");
  let cookieString = `${name}=${value}${expires};path=${path};domain=${domain};samesite=${samesite}`;
  (secure || !secure && samesite.toLowerCase() === "none") && (cookieString = `${cookieString};secure`), document.cookie = cookieString;
}
__name(setCookie, "setCookie");
function getCookie(name) {
  const nameEQ = `${name}=`, allCookies = document.cookie.split(";");
  for (let index = 0; index < allCookies.length; index++) {
    const currentCookie = allCookies[index].trimStart();
    if (currentCookie.indexOf(nameEQ) === 0)
      return currentCookie.substring(nameEQ.length, currentCookie.length);
  }
  return null;
}
__name(getCookie, "getCookie");
function getSessionStorage(key) {
  return sessionStorage.getItem(key);
}
__name(getSessionStorage, "getSessionStorage");
function setSessionStorage(key, value) {
  sessionStorage.setItem(key, value);
}
__name(setSessionStorage, "setSessionStorage");
function removeSessionStorage(key) {
  sessionStorage.removeItem(key);
}
__name(removeSessionStorage, "removeSessionStorage");
function isValidHttpUrl(stringToCheck) {
  let url;
  try {
    url = new URL(stringToCheck);
  } catch {
    return !1;
  }
  return url.protocol === "http:" || url.protocol === "https:";
}
__name(isValidHttpUrl, "isValidHttpUrl");
function isValidateEmail(email) {
  return email.match(
    /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
  );
}
__name(isValidateEmail, "isValidateEmail");
function loadJS(jsSrc, module = !1) {
  return new Promise((resolve, reject) => {
    if (document.querySelector(`script[src="${jsSrc}"]`) !== null) {
      resolve();
      return;
    }
    const newScript = document.createElement("script");
    newScript.src = jsSrc, module && newScript.setAttribute("type", "module"), newScript.addEventListener("load", () => {
      resolve();
    }), newScript.addEventListener("error", () => {
      reject(new Error(`Failed to load script: ${jsSrc}`));
    }), document.head.appendChild(newScript);
  });
}
__name(loadJS, "loadJS");
function wrapInner(parent, wrapper) {
  if (typeof wrapper == "string") {
    const temp = document.createElement("div");
    temp.innerHTML = wrapper, wrapper = temp.firstElementChild;
  }
  for (; parent.firstChild; )
    wrapper.appendChild(parent.firstChild);
  parent.appendChild(wrapper);
}
__name(wrapInner, "wrapInner");
function getClassInstance(elementID) {
  return new Promise((resolve) => {
    if (elementID in window.UNL.classes) {
      resolve(window.UNL.classes[elementID]);
      return;
    }
    document.getElementById(elementID).addEventListener("UNLClassReady", () => {
      resolve(window.UNL.classes[elementID]);
    });
  });
}
__name(getClassInstance, "getClassInstance");
function trackablePromise(promise) {
  const state = { pending: !0, value: null };
  return promise.then((value) => {
    state.pending = !1, state.value = value;
  }), state;
}
__name(trackablePromise, "trackablePromise");
export {
  getClassInstance,
  getCookie,
  getSessionStorage,
  isValidHttpUrl,
  isValidateEmail,
  loadJS,
  l as loadStyleSheet,
  a as loadStyleSheets,
  removeSessionStorage,
  setCookie,
  setSessionStorage,
  s as stringToDom,
  toAbs,
  trackablePromise,
  u as uuidv4,
  wrapInner
};
//# sourceMappingURL=unl-utility.js.map
