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/components/bigSale/components/BookingDataPanel/BookingList/utils.ts
var utils_exports = {};
__export(utils_exports, {
  formatShowList: () => formatShowList,
  getBookingType: () => getBookingType
});
module.exports = __toCommonJS(utils_exports);
var import_dayjs = __toESM(require("dayjs"));
var formatShowList = (list, options) => {
  const { search, listSelectType, sort } = options;
  let showList = [];
  list.forEach((item) => {
    var _a, _b, _c, _d, _e, _f;
    let searchMatched = true;
    let typeMatched = true;
    if (search) {
      searchMatched = JSON.stringify(item).includes(search);
    }
    if (listSelectType) {
      if (listSelectType === "all") {
        typeMatched = true;
      } else if (listSelectType === "notStarted") {
        typeMatched = ["new", "confirmed", "arrived"].includes(
          item.appointment_status
        );
      } else if (listSelectType === "started") {
        typeMatched = ["started"].includes(item.appointment_status);
      } else if (listSelectType === "finished") {
        typeMatched = ["completed"].includes(item.appointment_status);
      } else if (listSelectType === "canceled") {
        typeMatched = ["cancelled"].includes(item.appointment_status);
      }
    }
    if (searchMatched && typeMatched) {
      showList.push({
        ...item,
        startDateTime: `${item.start_date} ${item.start_time}`,
        endDateTime: `${item.end_date} ${item.end_time}`,
        total_amount: (_a = item == null ? void 0 : item.order) == null ? void 0 : _a.total_amount,
        customer: ((_d = (_c = (_b = item == null ? void 0 : item.order) == null ? void 0 : _b.customer) == null ? void 0 : _c.display_name) == null ? void 0 : _d.trim()) || (((_f = (_e = item == null ? void 0 : item.order) == null ? void 0 : _e.customer) == null ? void 0 : _f.nickname) || "").trim()
      });
    }
  });
  if (sort) {
    const [key, order] = sort.split(":");
    showList = showList.sort((a, b) => {
      let valueA;
      let valueB;
      if (["startDateTime", "created_at"].includes(key)) {
        valueA = (0, import_dayjs.default)(a[key]);
        valueB = (0, import_dayjs.default)(b[key]);
      } else {
        valueA = a[key];
        valueB = b[key];
      }
      if (order === "asc") {
        if (valueA < valueB) return -1;
        if (valueA > valueB) return 1;
      } else {
        if (valueA > valueB) return -1;
        if (valueA < valueB) return 1;
      }
      return 0;
    });
  }
  return showList;
};
var getBookingType = (record) => {
  if (record.parent_id > 0 && record.item_type !== "recurring_booking") {
    return "pisell2";
  }
  return "pisell1";
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  formatShowList,
  getBookingType
});
