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/model/strategy/adapter/itemRule/examples.ts
var examples_exports = {};
__export(examples_exports, {
  HOTPOT_BASE_PICK_ONE_STRATEGY: () => HOTPOT_BASE_PICK_ONE_STRATEGY,
  HOTPOT_BASE_REQUIRED_STRATEGY: () => HOTPOT_BASE_REQUIRED_STRATEGY,
  MAX_BUNS_PER_TABLE_STRATEGY: () => MAX_BUNS_PER_TABLE_STRATEGY,
  MIN_CONDIMENT_PER_PERSON_STRATEGY: () => MIN_CONDIMENT_PER_PERSON_STRATEGY,
  quickUseItemRuleEvaluator: () => quickUseItemRuleEvaluator,
  runItemRuleEvaluatorDemo: () => runItemRuleEvaluatorDemo
});
module.exports = __toCommonJS(examples_exports);
var import_evaluator = require("./evaluator");
var import_type = require("./type");
var MIN_CONDIMENT_PER_PERSON_STRATEGY = {
  metadata: {
    id: "RULE_MIN_CONDIMENT_PER_PERSON",
    name: {
      "zh-CN": "每人至少一份小料",
      en: "Min 1 Condiment per person"
    },
    type: "item_rule",
    description: {
      "zh-CN": "火锅小料数量不少于成人人数，自动添加",
      en: "Condiment count must be at least adult pax, auto-added to cart"
    }
  },
  conditions: {
    operator: "and",
    rules: [],
    actionIds: ["quantity_check_condiment", "prefill_condiment"]
  },
  actions: [
    {
      id: "quantity_check_condiment",
      type: import_type.ITEM_RULE_ACTION_TYPES.QUANTITY_CHECK,
      value: null,
      target: "cart",
      priority: 10,
      config: {
        targetType: "product",
        targets: [{ product_id: 10001 }, { product_id: 10002 }],
        quantityRules: [
          { comparison: "minimum", source: "total_pax" }
        ],
        scope: "first_submission_only",
        validationMessage: {
          "zh-CN": "小料至少需要 {min} 份（每位成人一份）",
          en: "Condiment requires at least {min} items (one per adult)"
        }
      }
    },
    {
      id: "prefill_condiment",
      type: import_type.ITEM_RULE_ACTION_TYPES.PREFILL_CART,
      value: null,
      target: "cart",
      priority: 5,
      config: {
        products: [
          {
            product_id: 10001,
            quantityFrom: "total_pax"
          }
        ]
      }
    }
  ]
};
var MAX_BUNS_PER_TABLE_STRATEGY = {
  metadata: {
    id: "RULE_MAX_BUNS_PER_TABLE",
    name: {
      "zh-CN": "每桌限量供应3份包子",
      en: "3 Buns limit per table"
    },
    type: "item_rule",
    description: {
      "zh-CN": "肉包和菜包合计每桌不超过3份，含加单累计",
      en: "Max 3 buns per table (pork + veggie combined, cumulative)"
    }
  },
  conditions: {
    operator: "and",
    rules: [],
    actionIds: ["quantity_check_buns"]
  },
  actions: [
    {
      id: "quantity_check_buns",
      type: import_type.ITEM_RULE_ACTION_TYPES.QUANTITY_CHECK,
      value: null,
      target: "cart",
      priority: 10,
      config: {
        targetType: "product",
        targets: [
          { product_id: 20001 },
          { product_id: 20002 }
        ],
        quantityRules: [
          { comparison: "maximum", source: "fixed", value: 3 }
        ],
        scope: "cumulative",
        validationMessage: {
          "zh-CN": "包子每桌限量 {max} 份（含加单累计）",
          en: "Buns are limited to {max} per table (cumulative)"
        }
      }
    }
  ]
};
var HOTPOT_BASE_REQUIRED_STRATEGY = {
  metadata: {
    id: "RULE_HOTPOT_BASE_REQUIRED",
    name: {
      "zh-CN": "锅底必选",
      en: "Hotpot base required"
    },
    type: "item_rule",
    description: {
      "zh-CN": "堂食必须选择一个锅底",
      en: "Hotpot base is mandatory for dine-in"
    }
  },
  conditions: {
    operator: "and",
    rules: [
      {
        type: "operator",
        dimension: "context",
        field: "serviceType",
        operator: "=",
        value: "dine-in"
      }
    ],
    actionIds: ["quantity_check_base", "prefill_base"]
  },
  actions: [
    {
      id: "quantity_check_base",
      type: import_type.ITEM_RULE_ACTION_TYPES.QUANTITY_CHECK,
      value: null,
      target: "cart",
      priority: 10,
      config: {
        targetType: "product",
        targets: [{ product_id: 30001 }],
        quantityRules: [
          { comparison: "exact", source: "fixed", value: 1 }
        ],
        scope: "first_submission_only",
        validationMessage: {
          "zh-CN": "请选择 {exact} 个锅底",
          en: "Please select exactly {exact} hotpot base"
        }
      }
    },
    {
      id: "prefill_base",
      type: import_type.ITEM_RULE_ACTION_TYPES.PREFILL_CART,
      value: null,
      target: "cart",
      priority: 5,
      config: {
        products: [
          {
            product_id: 30001,
            quantityFrom: "fixed",
            quantity: 1
          }
        ]
      }
    }
  ]
};
var HOTPOT_BASE_PICK_ONE_STRATEGY = {
  metadata: {
    id: "RULE_HOTPOT_BASE_PICK_ONE",
    name: {
      "zh-CN": "锅底必选（四选一）",
      en: "Hotpot base required (pick any)"
    },
    type: "item_rule",
    description: {
      "zh-CN": "4 款锅底任选至少 1 份",
      en: "Pick at least 1 hotpot base from the available options"
    }
  },
  conditions: {
    operator: "and",
    rules: [],
    actionIds: ["quantity_check_hotpot_base_group"]
  },
  actions: [
    {
      id: "quantity_check_hotpot_base_group",
      type: import_type.ITEM_RULE_ACTION_TYPES.QUANTITY_CHECK,
      value: null,
      target: "cart",
      priority: 10,
      config: {
        targetType: "product",
        targets: [
          { product_id: 30001 },
          { product_id: 30002 },
          { product_id: 30003 },
          { product_id: 30004 }
        ],
        quantityRules: [
          { comparison: "minimum", source: "fixed", value: 1 }
        ],
        scope: "first_submission_only",
        validationMessage: {
          "zh-CN": "请至少选择 {min} 款锅底",
          en: "Please select at least {min} hotpot base"
        }
      }
    }
  ]
};
function quickUseItemRuleEvaluator() {
  const evaluator = new import_evaluator.ItemRuleEvaluator();
  evaluator.setStrategyConfigs([
    MIN_CONDIMENT_PER_PERSON_STRATEGY,
    MAX_BUNS_PER_TABLE_STRATEGY,
    HOTPOT_BASE_REQUIRED_STRATEGY
  ]);
  const businessData = {
    pax: { total: 3, adult: 3, child: 0 },
    serviceType: "dine-in",
    cartItems: [
      { product_id: 10001, quantity: 1 },
      { product_id: 20001, quantity: 2 },
      { product_id: 20002, quantity: 1 }
    ],
    historicalItems: [{ product_id: 20001, quantity: 1 }],
    submissionIndex: 0
  };
  return {
    configCount: evaluator.getStrategyConfigs().length,
    evaluation: evaluator.evaluate(businessData),
    quantityLimits: evaluator.getQuantityLimits(businessData),
    validation: evaluator.validateCart(businessData),
    prefillItems: evaluator.getPrefillItems(businessData)
  };
}
function runItemRuleEvaluatorDemo() {
  const evaluator = new import_evaluator.ItemRuleEvaluator();
  evaluator.setStrategyConfigs([
    MIN_CONDIMENT_PER_PERSON_STRATEGY
    // MAX_BUNS_PER_TABLE_STRATEGY,
    // HOTPOT_BASE_REQUIRED_STRATEGY,
  ]);
  const firstSubmissionData = {
    pax: { total: 4, adult: 3, child: 1 },
    serviceType: "dine-in",
    submissionIndex: 0,
    cartItems: [
      { product_id: 10001, quantity: 3 }
      // { product_id: 20001, quantity: 2 },
      // { product_id: 20002, quantity: 1 },
    ],
    historicalItems: [{ product_id: 20001, quantity: 1 }]
  };
  const additionalSubmissionData = {
    ...firstSubmissionData,
    submissionIndex: 1
  };
  const firstEvaluation = evaluator.evaluate(firstSubmissionData);
  const additionalEvaluation = evaluator.evaluate(additionalSubmissionData);
  const quantityLimits = evaluator.getQuantityLimits(firstSubmissionData);
  const validateResult = evaluator.validateCart(firstSubmissionData);
  const prefillItems = evaluator.getPrefillItems(firstSubmissionData);
  const baseOnlyEvaluation = evaluator.evaluate({
    ...firstSubmissionData,
    strategyConfigs: [HOTPOT_BASE_REQUIRED_STRATEGY]
  });
  return {
    // configuredRuleIds: evaluator
    //   .getStrategyConfigs()
    //   .map((config) => config.metadata.id),
    firstEvaluation,
    // additionalEvaluation,
    // quantityLimits,
    validateResult,
    prefillItems
    // baseOnlyEvaluation,
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  HOTPOT_BASE_PICK_ONE_STRATEGY,
  HOTPOT_BASE_REQUIRED_STRATEGY,
  MAX_BUNS_PER_TABLE_STRATEGY,
  MIN_CONDIMENT_PER_PERSON_STRATEGY,
  quickUseItemRuleEvaluator,
  runItemRuleEvaluatorDemo
});
