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/checkout/printReceipt.ts
var printReceipt_exports = {};
__export(printReceipt_exports, {
  printReceipt: () => printReceipt
});
module.exports = __toCommonJS(printReceipt_exports);
var printTimeMap = {};
function printReceipt({
  nativePrint,
  orderId,
  machineCodePrintInfo,
  smallTicketData,
  machineCodePrintInfoV2,
  logger,
  dedupeWindowMs = 2e3
}) {
  var _a;
  const key = String(orderId);
  const now = Date.now();
  const lastPrintTime = printTimeMap[key] || 0;
  if (now - lastPrintTime < dedupeWindowMs) return false;
  printTimeMap[key] = now;
  const params = {
    type: "99",
    data: {
      order_id: orderId,
      machine_code_print_info: machineCodePrintInfo,
      small_ticket_data: smallTicketData,
      machine_code_print_info_v2: machineCodePrintInfoV2
    }
  };
  (_a = logger == null ? void 0 : logger.addLog) == null ? void 0 : _a.call(logger, {
    type: "info",
    title: "printReceipt",
    metadata: { params }
  });
  nativePrint(params, (res) => {
    var _a2;
    (_a2 = logger == null ? void 0 : logger.addLog) == null ? void 0 : _a2.call(logger, {
      type: "info",
      title: "printReceipt_result",
      metadata: { res }
    });
  });
  return true;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  printReceipt
});
