var printTimeMap = {};
export function printReceipt(_ref) {
  var _logger$addLog;
  var nativePrint = _ref.nativePrint,
    orderId = _ref.orderId,
    machineCodePrintInfo = _ref.machineCodePrintInfo,
    smallTicketData = _ref.smallTicketData,
    machineCodePrintInfoV2 = _ref.machineCodePrintInfoV2,
    logger = _ref.logger,
    _ref$dedupeWindowMs = _ref.dedupeWindowMs,
    dedupeWindowMs = _ref$dedupeWindowMs === void 0 ? 2000 : _ref$dedupeWindowMs;
  var key = String(orderId);
  var now = Date.now();
  var lastPrintTime = printTimeMap[key] || 0;
  if (now - lastPrintTime < dedupeWindowMs) return false;
  printTimeMap[key] = now;
  var params = {
    type: '99',
    data: {
      order_id: orderId,
      machine_code_print_info: machineCodePrintInfo,
      small_ticket_data: smallTicketData,
      machine_code_print_info_v2: machineCodePrintInfoV2
    }
  };
  logger === null || logger === void 0 || (_logger$addLog = logger.addLog) === null || _logger$addLog === void 0 || _logger$addLog.call(logger, {
    type: 'info',
    title: 'printReceipt',
    metadata: {
      params: params
    }
  });
  nativePrint(params, function (res) {
    var _logger$addLog2;
    logger === null || logger === void 0 || (_logger$addLog2 = logger.addLog) === null || _logger$addLog2 === void 0 || _logger$addLog2.call(logger, {
      type: 'info',
      title: 'printReceipt_result',
      metadata: {
        res: res
      }
    });
  });
  return true;
}