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/plus/pisellReservation/data/reservationRuleProducts.ts
var reservationRuleProducts_exports = {};
__export(reservationRuleProducts_exports, {
  collectLinkProductIdsFromReservationRules: () => collectLinkProductIdsFromReservationRules,
  pickFirstDurationProduct: () => pickFirstDurationProduct
});
module.exports = __toCommonJS(reservationRuleProducts_exports);
function collectLinkProductIdsFromReservationRules(rules) {
  if (!Array.isArray(rules)) return [];
  const ids = [];
  for (const entry of rules) {
    if (!entry || typeof entry !== "object") continue;
    const rec = entry;
    if (rec.type !== "link") continue;
    if (!Array.isArray(rec.value)) continue;
    for (const v of rec.value) {
      const n = Number(v);
      if (Number.isFinite(n) && n > 0) ids.push(Math.floor(n));
    }
  }
  return [...new Set(ids)];
}
function pickFirstDurationProduct(products) {
  var _a;
  if (!Array.isArray(products)) return null;
  for (const product of products) {
    const value = (_a = product == null ? void 0 : product.duration) == null ? void 0 : _a.value;
    const n = Number(value);
    if (Number.isFinite(n) && n > 0) return product;
  }
  return null;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  collectLinkProductIdsFromReservationRules,
  pickFirstDurationProduct
});
