var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/plus/pisellSalesManagement/hooks/perspectiveUtils.ts
var perspectiveUtils_exports = {};
__export(perspectiveUtils_exports, {
  Tag: () => Tag,
  buildDateTime: () => buildDateTime,
  formatAmount: () => formatAmount,
  formatDateTime: () => formatDateTime,
  formatPhone: () => formatPhone,
  getDisplayLines: () => getDisplayLines,
  normalizeList: () => normalizeList,
  parseJson: () => parseJson,
  textStyles: () => textStyles
});
module.exports = __toCommonJS(perspectiveUtils_exports);
var import_dayjs = __toESM(require("dayjs"));
var import_antd = require("antd");
var Tag = import_antd.Tag;
var formatAmount = (value, currencySymbol) => {
  const num = Number(value || 0);
  const symbol = currencySymbol || "$";
  return `${symbol}${num.toLocaleString(void 0, {
    minimumFractionDigits: 2,
    maximumFractionDigits: 2
  })}`;
};
var getDisplayLines = (items) => {
  return items.filter((item) => item != null && item !== "");
};
var textStyles = {
  text: { fontSize: 12, color: "#475467", lineHeight: "18px" }
};
var formatDateTime = (value) => {
  if (!value) return "";
  const parsed = (0, import_dayjs.default)(value);
  if (!parsed.isValid()) return value;
  return parsed.format("HH:mm ddd, D MMM");
};
var buildDateTime = (date, time) => {
  if (date && time) return `${date} ${time}`;
  return date || time || "";
};
var normalizeList = (value) => {
  if (Array.isArray(value)) return value;
  if (value == null) return [];
  return [value];
};
var parseJson = (value) => {
  if (typeof value !== "string") return value;
  try {
    return JSON.parse(value);
  } catch {
    return value;
  }
};
var formatPhone = (value, countryCallingCode) => {
  if (value == null || value === "") return "";
  if (typeof value === "string" || typeof value === "number") {
    const text = String(value).trim();
    if (!text) return "";
    const code = countryCallingCode != null && countryCallingCode !== "" ? String(countryCallingCode).trim() : "";
    if (code && !text.startsWith("+") && !text.startsWith(code)) {
      const normalizedCode = code.startsWith("+") ? code : `+${code}`;
      return `${normalizedCode} ${text}`;
    }
    return text;
  }
  if (typeof value === "object") {
    const phoneValue = (value == null ? void 0 : value.phone) || (value == null ? void 0 : value.number);
    const code = (value == null ? void 0 : value.country_calling_code) || (value == null ? void 0 : value.countryCallingCode);
    return formatPhone(phoneValue, code ?? countryCallingCode);
  }
  return "";
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Tag,
  buildDateTime,
  formatAmount,
  formatDateTime,
  formatPhone,
  getDisplayLines,
  normalizeList,
  parseJson,
  textStyles
});
