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/components/pisellTimeRangeDisplay/utils/formatDuration.ts
var formatDuration_exports = {};
__export(formatDuration_exports, {
  formatDuration: () => formatDuration
});
module.exports = __toCommonJS(formatDuration_exports);
function isChineseLocale(locale) {
  if (!locale) return false;
  const n = locale.toLowerCase();
  return n.startsWith("zh");
}
function formatDuration(ms, showSeconds = false, locale) {
  if (!Number.isFinite(ms) || ms < 0) {
    return isChineseLocale(locale) ? "0分钟" : "0m";
  }
  const d = Math.floor(ms / 864e5);
  const h = Math.floor(ms % 864e5 / 36e5);
  const m = Math.floor(ms % 36e5 / 6e4);
  const s = Math.floor(ms % 6e4 / 1e3);
  const useZh = isChineseLocale(locale);
  const units = useZh ? { d: "天", h: "时", m: "分钟", s: "秒" } : { d: "d", h: "h", m: "m", s: "s" };
  const parts = [];
  if (d > 0) parts.push(`${d}${units.d}`);
  if (h > 0) parts.push(`${h}${units.h}`);
  if (m > 0) parts.push(`${m}${units.m}`);
  if (showSeconds || parts.length === 0 && s >= 0) {
    parts.push(`${s}${units.s}`);
  }
  return parts.length > 0 ? parts.join("") : useZh ? "0分钟" : "0m";
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  formatDuration
});
