// src/utils/defaultTestId.ts
import { camelCase } from "change-case";
function defaultTestId(label) {
  return camelCase(label.replace(":", ""));
}

// src/utils/useTestIds.tsx
function useTestIds(props, defaultPrefix) {
  const prefix = props["data-testid"] || // Pass defaultPrefix through defaultTestId to allow `useTestIds(..., label)` usage
  (defaultPrefix ? defaultTestId(defaultPrefix) : void 0);
  const rootId = { "data-testid": prefix };
  return newMethodMissingProxy(rootId, (key) => {
    key = key.replace(":", "");
    return { "data-testid": prefix ? `${prefix}_${key}` : key };
  });
}
function newMethodMissingProxy(object, methodMissing) {
  return new Proxy(object, {
    get(object2, property) {
      if (Reflect.has(object2, property)) {
        return Reflect.get(object2, property);
      } else if (property === "then") {
        return void 0;
      } else {
        return methodMissing(String(property));
      }
    }
  });
}

// src/utils/inlineStyles.ts
function isInlineStyleValue(value) {
  return typeof value === "string" || typeof value === "number";
}
function setInlineStyles(el, styles) {
  Object.entries(styles).forEach(([prop, value]) => {
    if (!isInlineStyleValue(value)) return;
    if (prop.startsWith("--")) {
      el.style.setProperty(prop, String(value));
    } else {
      el.style[prop] = String(value);
    }
  });
}
function clearInlineStyles(el, styles) {
  Object.entries(styles).forEach(([prop, value]) => {
    if (!isInlineStyleValue(value)) return;
    if (prop.startsWith("--")) {
      el.style.removeProperty(prop);
    } else {
      el.style[prop] = "";
    }
  });
}

// src/utils/index.ts
function fail(message) {
  throw new Error(message || "Failed");
}
function toToggleState(isSelected, onChange) {
  return {
    isSelected,
    defaultSelected: false,
    setSelected: onChange,
    toggle: () => onChange(!isSelected)
  };
}
function maybeCall(callback, ...args) {
  return callback && callback(...args);
}
function safeKeys(instance) {
  return Object.getOwnPropertyNames(instance);
}
var omitKey = (key, { [key]: _, ...obj }) => obj;
var noop = (..._) => {
};
function safeEntries(obj) {
  return Object.entries(obj);
}
var EmptyRef = class {
  get current() {
    throw new Error("BeamProvider is missing");
  }
  set current(_) {
    throw new Error("BeamProvider is missing");
  }
};
var isAbsoluteUrl = (url) => /^(http(s?)):\/\//i.test(url);
function isPromise(obj) {
  return typeof obj === "object" && "then" in obj && typeof obj.then === "function";
}
function isFunction(f) {
  return typeof f === "function";
}
function isDefined(param) {
  return param !== null && param !== void 0;
}
function pluralize(count, noun, pluralNoun) {
  if ((Array.isArray(count) ? count.length : count) === 1) return noun;
  return pluralNoun || `${noun}s`;
}

export {
  setInlineStyles,
  clearInlineStyles,
  defaultTestId,
  useTestIds,
  newMethodMissingProxy,
  fail,
  toToggleState,
  maybeCall,
  safeKeys,
  omitKey,
  noop,
  safeEntries,
  EmptyRef,
  isAbsoluteUrl,
  isPromise,
  isFunction,
  isDefined,
  pluralize
};
//# sourceMappingURL=chunk-ZPT2ZR5B.js.map