"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var window_exports = {};
__export(window_exports, {
  getAssetPath: () => getAssetPath,
  getCurrentBreakpoint: () => getCurrentBreakpoint,
  getViewportSize: () => getViewportSize,
  getWindow: () => getWindow
});
module.exports = __toCommonJS(window_exports);
var import_pui_theme = require("@elliemae/pui-theme");
const getWindow = () => {
  try {
    window.parent.document;
    return window.parent;
  } catch (err) {
    return window;
  }
};
const getViewportSize = () => ({
  width: Math.max(
    document.documentElement.clientWidth || 0,
    window.innerWidth || 0
  ),
  height: Math.max(
    document.documentElement.clientHeight || 0,
    window.innerHeight || 0
  )
});
const convertBreakpointToNumber = (breakpoint) => Number(breakpoint?.replace("px", ""));
const getCurrentBreakpoint = () => {
  const { width } = getViewportSize();
  const { breakpoints } = (0, import_pui_theme.getDefaultTheme)();
  if (width <= convertBreakpointToNumber(breakpoints.small)) return "small";
  if (width <= convertBreakpointToNumber(breakpoints.medium)) return "medium";
  if (width <= convertBreakpointToNumber(breakpoints.xsmall)) return "xsmall";
  return "large";
};
const getAssetPath = () => {
  const assetPath = window?.emui?._ASSET_PATH || "latest/";
  if (!window.emui?.version) return assetPath;
  const majorMinorVersion = window.emui?.version.match(/^(?:\d+\.\d+)*/g);
  return majorMinorVersion && majorMinorVersion[0] ? assetPath.replace("latest/", `${majorMinorVersion[0]}/`) : assetPath;
};
