"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);

// src/utils/index.ts
var utils_exports = {};
__export(utils_exports, {
  changeCSS: () => changeCSS,
  delay: () => delay,
  excludeControls: () => excludeControls,
  filterUndefinedProps: () => filterUndefinedProps,
  filterUnsetValues: () => filterUnsetValues,
  getSpacingValue: () => getSpacingValue,
  mergeRefs: () => mergeRefs,
  sizeClasses: () => sizeClasses,
  sizeOptions: () => sizeOptions,
  spaceDelimitedList: () => spaceDelimitedList,
  supportsDialog: () => supportsDialog
});
module.exports = __toCommonJS(utils_exports);

// src/utils/changeCSS.ts
var CSS_LINK_ID = "sb-theme";
var changeCSS = (cssUrl) => {
  const theme = document.getElementById(CSS_LINK_ID);
  if (theme) {
    theme.setAttribute("href", cssUrl);
  } else {
    const link = document.createElement("link");
    link.setAttribute("type", "text/css");
    link.setAttribute("rel", "stylesheet");
    link.setAttribute("href", cssUrl);
    link.setAttribute("id", CSS_LINK_ID);
    document.head.appendChild(link);
  }
};

// src/utils/delay.ts
function delay(ms, { signal } = {}) {
  return new Promise((resolve, reject) => {
    const timeout = setTimeout(resolve, ms);
    if (signal) {
      signal.addEventListener("abort", () => {
        clearTimeout(timeout);
        reject(new DOMException("Aborted", "AbortError"));
      });
    }
  });
}

// src/utils/excludeControls.ts
var excludeControls = (...args) => args.reduce(
  (prev, acc) => ({ ...prev, [acc]: { table: { disable: true } } }),
  {}
);

// src/utils/filterUndefinedProps.ts
var filterUndefinedProps = (props) => {
  const filteredProps = {};
  Object.keys(props).forEach((key) => {
    if (props[key] !== void 0) {
      filteredProps[key] = props[key];
    }
  });
  return filteredProps;
};

// src/utils/filterUnsetValues.ts
var filterUnsetValues = (props) => {
  const filtered = {};
  Object.keys(props).forEach((key) => {
    const value = props[key];
    if (value !== void 0 && value !== null && value !== "") {
      filtered[key] = value;
    }
  });
  return filtered;
};

// src/utils/getSpacingValue.ts
var getSpacingValue = (padding) => {
  if (typeof padding === "string") {
    return `var(--size-${padding})`;
  }
  if (typeof padding === "number") {
    return `${padding}px`;
  }
  return void 0;
};

// src/utils/mergeRefs.ts
function mergeRefs(refs) {
  return (value) => {
    refs.forEach((ref) => {
      if (typeof ref === "function") {
        ref(value);
      } else if (ref != null) {
        ref.current = value;
      }
    });
  };
}

// src/utils/polyfill-tests.ts
var supportsDialog = () => typeof HTMLDialogElement === "function";

// src/utils/sizeClasses.ts
var sizeClasses = (size) => {
  if (!size) {
    return {};
  }
  return {
    "--is-xxs": size === "xxs",
    "--is-xs": size === "xs",
    "--is-sm": size === "sm",
    "--is-md": size === "md",
    "--is-lg": size === "lg",
    "--is-xl": size === "xl",
    "--is-xxl": size === "xxl"
  };
};

// src/utils/sizeOptions.ts
var sizeOptions = [
  "",
  "xxs",
  "xs",
  "sm",
  "md",
  "lg",
  "xl",
  "xxl"
];

// src/utils/spaceDelimitedList.ts
function spaceDelimitedList(list) {
  return list.filter(Boolean).join(" ") || void 0;
}
//# sourceMappingURL=index.js.map
