// Shared constants used by both Chrome extension and Electron app.
// UMD-style: exports to module.exports (Node) or root.NP.constants (browser).
(function (root) {
  // Local-dev override (Electron main process only): NOVAPOST_BE_URL env var
  // points BC at a non-prod backend. Browser context has no process.env so
  // falls through to the hardcoded prod URL.
  var beOverride = (typeof process !== 'undefined' && process.env && process.env.NOVAPOST_BE_URL) || '';
  var api = {
    API_BASE: beOverride || 'https://novapost-api.biatec.cz/api/v1',
    WIDGET_URL: 'https://novapost-widget.biatec.cz/nova-post/widget.js',
    WIDGET_DOMAIN: 'novapost-widget.biatec.cz',
    DASHBOARD_URL: 'https://dashboard.biatec.cz/',
    NOVA_POST_KEYWORDS: ['nova post'],
    // Branch detection MUST require our full structured marker —
    // "Nova Post: <name>, <address> [NP:<id>]" — NOT a bare "[NP:id]". The
    // leading "Nova Post:" string is what identifies our marker, so arbitrary
    // customer text (e.g. a "ring the bell" note, or a stray bracketed token)
    // can never be misread as a branch order. Same format old and new, so
    // detection is backward compatible.
    NP_BRANCH_RE: /Nova Post:[^[\]]*\[NP:([^\]]+)\]/i,
    NP_REMARK_RE: /Nova Post:\s*(.+?)\s*\[NP:/,
    // Shoptet order status codes used by BC. Negative codes (-1..-4) are
    // Shoptet system defaults present on every shop. Positive codes are
    // merchant-customizable — apply with capability check + 'no-change' fallback.
    STATUS_PROCESSING: -2,           // Vyřizuje se (system default)
    STATUS_COMPLETED: -3,            // Vyřízena (system default; webhook 'Received')
    STATUS_CANCELLED: -4,            // Stornována (system default; webhook 'Deleted')
    STATUS_PACKING: 32,              // Balení a Expedice (merchant; BC sets at create)
    STATUS_SHIPPED: 2,               // Odeslaná (merchant; webhook 'LoadingCourier')
    STATUS_UNDELIVERED: 35           // Nedoručená (merchant; webhook 'Returned/Refused/Utilization')
  };
  if (typeof module !== 'undefined' && module.exports) module.exports = api;
  else { root.NP = root.NP || {}; root.NP.constants = api; }
})(typeof self !== 'undefined' ? self : this);
