{"version":3,"file":"index.cjs","sources":["webpack://@thai-qr-payment/render/./src/card.ts","webpack://@thai-qr-payment/render/./src/index.ts","webpack://@thai-qr-payment/render/./src/matrix-svg.ts"],"sourcesContent":["/**\n * Card composer: Thai QR Payment header + PromptPay sub-mark + QR\n * matrix + centre-overlay icon. Layout + sizing follows the official\n * BOT/TBA Thai QR Payment brand guideline:\n *\n *   - Card aspect 7.4 cm × 10.5 cm (0.7048) — portrait-ish\n *   - Navy `#00427A` (\"TQR Maximum Blue\", brand book §4)\n *   - Header band ~75 % of card width, ~3.5 : 1 aspect\n *   - PromptPay sub-mark *left-aligned* under the header (narrow strip)\n *   - QR ~85 % of card width, centred\n *   - Centre-overlay icon ~10 % of QR (ECC-H recovers the obscured modules)\n *\n *   ┌──────────────────────────┐\n *   │     ▓ THAI QR PAYMENT ▓  │  navy band, tight content crop\n *   │   ⎡Pmt⎤                  │  left-aligned narrow sub-mark\n *   ├──────────────────────────┤\n *   │   ▓▓▓▓▓▓▓▓▓▓▓▓▓        │\n *   │   ▓▓▓▓▓ ┌┐ ▓▓▓▓▓        │\n *   │   ▓▓▓▓▓ └┘ ▓▓▓▓▓        │  small icon overlay (~10%)\n *   │   ▓▓▓▓▓▓▓▓▓▓▓▓▓        │\n *   ├──────────────────────────┤\n *   │ optional merchant name   │\n *   │ optional amount label    │\n *   └──────────────────────────┘\n *\n * Theme rules:\n *   - `theme: 'color'` (default) → Thai_QR_Payment_Logo-01 + PromptPay2 (navy)\n *   - `theme: 'silhouette'`      → silhouette variant + PromptPay1 (black/white)\n *\n * Default PromptPay variant is `PromptPay2` (color theme) because the\n * brand book pairs the navy header with the navy PromptPay sub-mark.\n * Callers can override with `promptpayLogo` to pick `PromptPay1` (the\n * monochrome rounded-border variant) regardless of theme.\n */\n\nimport { COLOR_LOGOS, SILHOUETTE_LOGOS } from '@thai-qr-payment/assets';\nimport type { QRMatrix } from '@thai-qr-payment/qr';\nimport { escapeXmlAttribute, matrixToPath } from './matrix-svg.js';\n\nexport type CardTheme = 'color' | 'silhouette';\n\nexport interface CardOptions {\n  /** Brand artwork flavor. `color` keeps full fidelity, `silhouette` is monochrome. */\n  theme?: CardTheme;\n  /**\n   * Render the caption block (merchant name + amount) below the QR.\n   * Defaults to `false` — opt in explicitly, then supply the text via\n   * `merchantName` / `amountLabel`.\n   */\n  showCaption?: boolean;\n  /** Optional amount label rendered below the QR. Requires `showCaption`. */\n  amountLabel?: string;\n  /** Optional merchant name rendered below the QR (above the amount). Requires `showCaption`. */\n  merchantName?: string;\n  /** Background colour of the entire card. */\n  background?: string;\n  /** Foreground / accent colour for text + silhouette artwork. */\n  accent?: string;\n  /** QR module fill colour. Defaults to `#000000` for max scanner contrast. */\n  qrColor?: string;\n  /** Override the Thai QR Payment header logo by registry name. */\n  headerLogo?: keyof typeof COLOR_LOGOS;\n  /** Override the PromptPay sub-mark by registry name. */\n  promptpayLogo?: keyof typeof COLOR_LOGOS;\n  /**\n   * Overlay the Thai QR Payment icon at the centre of the QR matrix.\n   * Defaults to `true` for `theme: 'color'`, `false` for `'silhouette'`.\n   * Always pair with `encodeQR({ errorCorrectionLevel: 'Q' | 'H' })`\n   * so the obscured modules are recoverable.\n   */\n  centerOverlay?: boolean;\n}\n\n// Canvas 600 × 800 (3 : 4). Mirrors kittinan's 1000×1200 5:6 plus 80 px\n// of footer room for optional merchant + amount labels.\nconst CANVAS = { width: 600, height: 800 } as const;\n\n// Header band — full canvas width, ~6:1 aspect (BOT/TBA reference).\n// Acts as a solid navy strip; the logo sits centred inside with\n// generous padding rather than filling the band edge-to-edge.\nconst HEADER_BAND = { x: 0, y: 0, width: 600, height: 110 } as const;\n\n// Logo placement inside the header band — 40 % of canvas width,\n// centred horizontally with vertical padding.\nconst HEADER_LOGO = { x: 195, y: 15, width: 210, height: 80 } as const;\n\n// PromptPay sub-mark — centred under the header. PromptPay2 native\n// aspect 384 : 130 ≈ 2.95 : 1; we scale to 260 × 88 for a chunky\n// readable mark matching the brand reference.\nconst PROMPTPAY_BAND = { x: 170, y: 140, width: 260, height: 88 } as const;\n\n// QR frame — 500 × 500 (83 % of canvas width, larger than v6 to\n// match the brand reference's QR-dominant layout).\nconst QR_FRAME = { x: 50, y: 250, width: 500, height: 500 } as const;\nconst QR_INSET = 14;\nconst QR_BAND = {\n  x: QR_FRAME.x + QR_INSET,\n  y: QR_FRAME.y + QR_INSET,\n  width: QR_FRAME.width - QR_INSET * 2,\n  height: QR_FRAME.height - QR_INSET * 2,\n} as const;\n\n// Tight content bbox of `Thai_QR_Payment_Logo-01.svg`. The raw asset\n// is 913 × 376 with ~90 px of empty navy padding top/bottom and ~80 px\n// each side. Cropping to the actual icon+wordmark bbox yields the\n// brand-guide aspect (~3.55 : 1) and removes the floating-in-empty-navy\n// look the previous full-viewBox render produced.\nconst HEADER_VIEWBOX_CROP = '88 75 750 210';\n\n// Icon-only viewBox for the centre overlay. The icon glyph lives at\n// roughly x = 88..318 of the original 0..913 viewBox; we keep the full\n// vertical extent so the navy bg paints the centre overlay square.\nconst ICON_WIDTH = 325;\nconst ICON_HEIGHT = 376;\nconst ICON_VIEWBOX = `0 0 ${ICON_WIDTH} ${ICON_HEIGHT}`;\n/** White breathing room between the centre logo and the QR modules. */\nconst OVERLAY_PAD = 4;\n\n/** Strip the outer `<svg …>…</svg>` wrapper so the contents can be reused inside a `<symbol>`. */\nfunction unwrapSvg(svg: string): { viewBox: string; inner: string } {\n  const viewBoxMatch = svg.match(/viewBox=\"([^\"]+)\"/);\n  let viewBox = viewBoxMatch?.[1];\n  if (viewBox == null) {\n    // Asset has no explicit viewBox — derive from width/height. Many\n    // hand-authored / Illustrator-exported SVGs omit the viewBox and\n    // rely on width/height alone; without this fallback the symbol\n    // defaults to \"0 0 100 100\" and the artwork renders 0.5-px tall.\n    const widthMatch = svg.match(/<svg[^>]*\\swidth=\"([\\d.]+)\"/);\n    const heightMatch = svg.match(/<svg[^>]*\\sheight=\"([\\d.]+)\"/);\n    if (widthMatch != null && heightMatch != null) {\n      viewBox = `0 0 ${widthMatch[1]} ${heightMatch[1]}`;\n    } else {\n      viewBox = '0 0 100 100';\n    }\n  }\n  // Some assets (vtracer output) ship with leading `<?xml ... ?>`\n  // and/or `<!-- Generator ... -->` comments before the `<svg>`. Strip\n  // each pattern greedily so the outer `<svg>` always anchors at the\n  // start of the string before we drop it.\n  const inner = svg\n    .replace(/^\\s*<\\?xml[^?]*\\?>\\s*/i, '')\n    .replace(/^\\s*<!--[\\s\\S]*?-->\\s*/g, '')\n    .replace(/^\\s*<svg\\b[^>]*>/i, '')\n    .replace(/<\\/svg>\\s*$/i, '');\n  return { viewBox, inner };\n}\n\nfunction defineSymbol(id: string, svg: string, viewBoxOverride?: string): string {\n  const { viewBox, inner } = unwrapSvg(svg);\n  const vb = viewBoxOverride ?? viewBox;\n  return `<symbol id=\"${id}\" viewBox=\"${escapeXmlAttribute(vb)}\">${inner}</symbol>`;\n}\n\n// SILHOUETTE_LOGOS is a strict subset of COLOR_LOGOS (only marks for\n// which we shipped a `.silhouette.svg` are registered there). When the\n// caller asks for a colour-only mark (e.g. PromptPay2) under the\n// silhouette theme, fall back to the colour version rather than\n// erroring at the type level.\ntype AnyLogoName = keyof typeof COLOR_LOGOS;\nconst SILHOUETTE_LOOKUP = SILHOUETTE_LOGOS as Record<AnyLogoName, string | undefined>;\n\nfunction pickHeaderLogo(theme: CardTheme, override?: AnyLogoName): string {\n  const name = override ?? 'Thai_QR_Payment_Logo-01';\n  if (theme === 'silhouette') {\n    return SILHOUETTE_LOOKUP[name] ?? COLOR_LOGOS[name];\n  }\n  return COLOR_LOGOS[name];\n}\n\nfunction pickPromptpayLogo(theme: CardTheme, override?: AnyLogoName): string {\n  // Default differs by theme:\n  //   color      → PromptPay2 (navy bg, pairs with navy header)\n  //   silhouette → PromptPay1 (mono w/ rounded border)\n  const fallback: AnyLogoName = theme === 'silhouette' ? 'PromptPay1' : 'PromptPay2';\n  const name = override ?? fallback;\n  if (theme === 'silhouette') {\n    return SILHOUETTE_LOOKUP[name] ?? COLOR_LOGOS[name];\n  }\n  return COLOR_LOGOS[name];\n}\n\n/** Compose the full Thai QR Payment card SVG. */\nexport function renderCard(matrix: QRMatrix, options: CardOptions = {}): string {\n  const theme: CardTheme = options.theme ?? 'color';\n  const bg = options.background ?? '#ffffff';\n  const accent = options.accent ?? '#00427A';\n  const qrColor = options.qrColor ?? '#000000';\n  const headerSvg = pickHeaderLogo(theme, options.headerLogo);\n  const promptpaySvg = pickPromptpayLogo(theme, options.promptpayLogo);\n  const overlay = options.centerOverlay ?? theme === 'color';\n\n  const matrixPath = matrixToPath(matrix);\n  const modulePx = QR_BAND.width / matrix.size;\n  const qrTransform = `translate(${QR_BAND.x} ${QR_BAND.y}) scale(${modulePx})`;\n\n  // Centre overlay: navy mini-logo (icon-only crop of the header\n  // artwork) inside a small white pad with rounded corners. 16 % of\n  // the QR width — small enough that ECC-H recovers the obscured\n  // modules cleanly.\n  // The icon is taller than it is wide, and `xMidYMid meet` letterboxes it\n  // inside its box — so a square box would leave the side gaps ~2× the top\n  // and bottom ones. Give the box the icon's own aspect ratio instead: the\n  // glyph draws at exactly the same size, and the white pad around it is\n  // then uniform on all four sides.\n  const overlayHeight = QR_BAND.width * 0.16;\n  const overlayWidth = overlayHeight * (ICON_WIDTH / ICON_HEIGHT);\n  const overlayX = QR_BAND.x + (QR_BAND.width - overlayWidth) / 2;\n  const overlayY = QR_BAND.y + (QR_BAND.height - overlayHeight) / 2;\n  const overlayMarkup = overlay\n    ? [\n        `<rect x=\"${overlayX - OVERLAY_PAD}\" y=\"${overlayY - OVERLAY_PAD}\" width=\"${overlayWidth + OVERLAY_PAD * 2}\" height=\"${overlayHeight + OVERLAY_PAD * 2}\" fill=\"#ffffff\" rx=\"4\"/>`,\n        `<use href=\"#tqp-icon\" xlink:href=\"#tqp-icon\" x=\"${overlayX}\" y=\"${overlayY}\" width=\"${overlayWidth}\" height=\"${overlayHeight}\" preserveAspectRatio=\"xMidYMid meet\"/>`,\n      ].join('')\n    : '';\n\n  // Caption is opt-in: supplying the text alone is not enough, so a card\n  // built from a payload that happens to carry a merchant name stays clean\n  // unless the caller asks for it.\n  const showCaption = options.showCaption ?? false;\n  const labelBaseY = QR_FRAME.y + QR_FRAME.height + 38;\n  const merchantText =\n    showCaption && options.merchantName != null\n      ? `<text x=\"${CANVAS.width / 2}\" y=\"${labelBaseY}\" text-anchor=\"middle\" font-family=\"Inter, system-ui, sans-serif\" font-size=\"22\" font-weight=\"600\" fill=\"${escapeXmlAttribute(accent)}\">${escapeXmlAttribute(options.merchantName)}</text>`\n      : '';\n\n  const amountY = options.merchantName != null ? labelBaseY + 36 : labelBaseY + 6;\n  const amountText =\n    showCaption && options.amountLabel != null\n      ? `<text x=\"${CANVAS.width / 2}\" y=\"${amountY}\" text-anchor=\"middle\" font-family=\"Inter, system-ui, sans-serif\" font-size=\"30\" font-weight=\"700\" fill=\"${escapeXmlAttribute(accent)}\">${escapeXmlAttribute(options.amountLabel)}</text>`\n      : '';\n\n  return [\n    `<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" `,\n    `viewBox=\"0 0 ${CANVAS.width} ${CANVAS.height}\" shape-rendering=\"crispEdges\">`,\n    `<defs>`,\n    // Tight content-bbox crop so the header band renders flush — no\n    // empty navy padding around the icon+wordmark.\n    defineSymbol('tqp-header', headerSvg, HEADER_VIEWBOX_CROP),\n    defineSymbol('tqp-icon', headerSvg, ICON_VIEWBOX),\n    defineSymbol('tqp-promptpay', promptpaySvg),\n    `</defs>`,\n    `<rect width=\"${CANVAS.width}\" height=\"${CANVAS.height}\" fill=\"${escapeXmlAttribute(bg)}\" rx=\"20\"/>`,\n    // Solid navy strip — full canvas width, no rounded corners on\n    // bottom (overlaps the rounded card bg's top corners only).\n    `<path d=\"M0 ${HEADER_BAND.height} V20 a20 20 0 0 1 20 -20 H${CANVAS.width - 20} a20 20 0 0 1 20 20 V${HEADER_BAND.height} Z\" fill=\"${escapeXmlAttribute(theme === 'silhouette' ? accent : '#00427A')}\"/>`,\n    // Logo centred inside the strip with `meet` so it never overflows\n    // and never gets cropped. Tight-crop viewBox keeps the icon+text\n    // tight together; the strip provides the navy padding around them.\n    `<use href=\"#tqp-header\" xlink:href=\"#tqp-header\" x=\"${HEADER_LOGO.x}\" y=\"${HEADER_LOGO.y}\" width=\"${HEADER_LOGO.width}\" height=\"${HEADER_LOGO.height}\" preserveAspectRatio=\"xMidYMid meet\"/>`,\n    `<use href=\"#tqp-promptpay\" xlink:href=\"#tqp-promptpay\" x=\"${PROMPTPAY_BAND.x}\" y=\"${PROMPTPAY_BAND.y}\" width=\"${PROMPTPAY_BAND.width}\" height=\"${PROMPTPAY_BAND.height}\" preserveAspectRatio=\"xMidYMid meet\"/>`,\n    // White QR frame keeps the matrix readable even with a themed bg.\n    `<rect x=\"${QR_FRAME.x}\" y=\"${QR_FRAME.y}\" width=\"${QR_FRAME.width}\" height=\"${QR_FRAME.height}\" fill=\"#ffffff\" rx=\"6\"/>`,\n    `<g transform=\"${qrTransform}\"><path d=\"${matrixPath}\" fill=\"${escapeXmlAttribute(qrColor)}\"/></g>`,\n    overlayMarkup,\n    merchantText,\n    amountText,\n    `</svg>`,\n  ].join('');\n}\n","/**\n * `@thai-qr-payment/render` — high-level SVG renderer.\n *\n * Combines `@thai-qr-payment/payload`, `@thai-qr-payment/qr`, and\n * `@thai-qr-payment/assets` into one entry-point: pass merchant +\n * amount, get an SVG card.\n */\n\nimport { payloadFor, type PromptPayRecipientType } from '@thai-qr-payment/payload';\nimport { encodeQR, type ErrorCorrectionLevel } from '@thai-qr-payment/qr';\nimport { renderCard, type CardOptions } from './card.js';\nimport { renderQRSvg, type QRSvgOptions } from './matrix-svg.js';\n\nexport { renderCard } from './card.js';\nexport { renderQRSvg, matrixToPath } from './matrix-svg.js';\nexport type { CardOptions, CardTheme } from './card.js';\nexport type { QRSvgOptions } from './matrix-svg.js';\n\nexport interface RenderInput {\n  recipient: string;\n  amount?: number;\n  recipientType?: PromptPayRecipientType;\n  fromSatang?: boolean;\n  /** QR error-correction level. `H` gives the best margin for logo overlays. */\n  errorCorrectionLevel?: ErrorCorrectionLevel;\n}\n\n/**\n * One-shot helper: build payload → encode QR → render Thai QR Payment card.\n * Returns the SVG string ready to ship.\n */\nexport function renderThaiQRPayment(input: RenderInput & Omit<CardOptions, never>): string {\n  const wire = payloadFor({\n    recipient: input.recipient,\n    amount: input.amount,\n    type: input.recipientType,\n    fromSatang: input.fromSatang,\n  });\n  // The default card layout overlays the Thai QR Payment icon on the\n  // QR centre, which obscures ~3 % of the modules. Default ECC up to\n  // 'H' so scanners can recover the lost data; callers can still\n  // explicitly pass a weaker level.\n  const ecc = input.errorCorrectionLevel ?? 'H';\n  const matrix = encodeQR(wire, { errorCorrectionLevel: ecc });\n  return renderCard(matrix, input);\n}\n\n/**\n * One-shot helper for callers that want only the QR (no header card).\n * Useful when wrapping the QR in your own design system.\n */\nexport function renderThaiQRPaymentMatrix(input: RenderInput & QRSvgOptions): string {\n  const wire = payloadFor({\n    recipient: input.recipient,\n    amount: input.amount,\n    type: input.recipientType,\n    fromSatang: input.fromSatang,\n  });\n  const matrix = encodeQR(wire, {\n    errorCorrectionLevel: input.errorCorrectionLevel ?? 'M',\n  });\n  return renderQRSvg(matrix, input);\n}\n","/**\n * Compact SVG <path> serialisation of a QR module matrix.\n *\n * Emits one move + horizontal-run command per dark stretch on each\n * row. Gzip likes the repetition; for a typical 25-30-module Thai QR\n * Payment payload the path is 1-2 KB before compression.\n */\n\nimport type { QRMatrix } from '@thai-qr-payment/qr';\n\n/** Build a path-data string covering every dark module in the matrix. */\nexport function matrixToPath(matrix: QRMatrix): string {\n  const segments: string[] = [];\n  for (let y = 0; y < matrix.size; y += 1) {\n    const row = matrix.modules[y];\n    if (!row) continue;\n    let x = 0;\n    while (x < row.length) {\n      if (!row[x]) {\n        x += 1;\n        continue;\n      }\n      let runEnd = x;\n      while (runEnd < row.length && row[runEnd]) runEnd += 1;\n      const runLen = runEnd - x;\n      // Single-row rectangle: M x y h<runLen> v1 h-<runLen> z\n      segments.push(`M${x} ${y}h${runLen}v1h-${runLen}z`);\n      x = runEnd;\n    }\n  }\n  return segments.join('');\n}\n\nexport interface QRSvgOptions {\n  /** Output width in user units (px by default). Defaults to module count. */\n  size?: number;\n  /** Quiet-zone width in modules. EMVCo recommends 4. */\n  quietZone?: number;\n  /** Dark module colour. Defaults to `#000`. */\n  foreground?: string;\n  /** Background colour (set to `transparent` to omit). Defaults to `#fff`. */\n  background?: string;\n  /** Additional attributes added verbatim to the root `<svg>` element. */\n  rootAttributes?: Record<string, string>;\n}\n\n/** Render a QR matrix to a self-contained `<svg>` string. */\nexport function renderQRSvg(matrix: QRMatrix, options: QRSvgOptions = {}): string {\n  const quietZone = toSafeUint(options.quietZone, 4);\n  const fg = options.foreground ?? '#000';\n  const bg = options.background ?? '#fff';\n  const total = toSafeUint(matrix.size, 0) + quietZone * 2;\n  const size = toSafeUint(options.size, total);\n  const path = matrixToPath(matrix);\n\n  const extra = options.rootAttributes\n    ? ' ' +\n      Object.entries(options.rootAttributes)\n        .map(([k, v]) => `${k}=\"${escapeXmlAttribute(v)}\"`)\n        .join(' ')\n    : '';\n\n  return (\n    `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${total} ${total}\" ` +\n    `width=\"${size}\" height=\"${size}\" shape-rendering=\"crispEdges\"${extra}>` +\n    (bg === 'transparent'\n      ? ''\n      : `<rect width=\"${total}\" height=\"${total}\" fill=\"${escapeXmlAttribute(bg)}\"/>`) +\n    `<g transform=\"translate(${quietZone} ${quietZone})\">` +\n    `<path d=\"${path}\" fill=\"${escapeXmlAttribute(fg)}\"/>` +\n    `</g></svg>`\n  );\n}\n\nfunction toSafeUint(value: unknown, fallback: number): number {\n  const n = Number(value);\n  return Number.isFinite(n) && n >= 0 ? Math.floor(n) : fallback;\n}\n\nfunction escapeXmlAttribute(value: string): string {\n  return value.replace(/[&<>\"']/g, (c) => {\n    switch (c) {\n      case '&':\n        return '&amp;';\n      case '<':\n        return '&lt;';\n      case '>':\n        return '&gt;';\n      case '\"':\n        return '&quot;';\n      case \"'\":\n        return '&apos;';\n    }\n    return c;\n  });\n}\n\nexport { escapeXmlAttribute };\n"],"names":["renderCard","QR_FRAME","unwrapSvg","svg","viewBoxMatch","viewBox","widthMatch","heightMatch","inner","defineSymbol","id","viewBoxOverride","_matrixsvg","SILHOUETTE_LOOKUP","_assets","pickHeaderLogo","theme","override","name","pickPromptpayLogo","matrix","options","bg","accent","qrColor","headerSvg","promptpaySvg","overlay","matrixPath","modulePx","QR_BAND","qrTransform","overlayHeight","overlayWidth","overlayX","overlayY","overlayMarkup","OVERLAY_PAD","showCaption","merchantText","amountY","labelBaseY","amountText","_card","renderThaiQRPayment","renderThaiQRPaymentMatrix","input","wire","_payload","ecc","_qr","matrixToPath","segments","y","row","x","runEnd","runLen","renderQRSvg","quietZone","toSafeUint","fg","total","size","path","extra","Object","k","v","escapeXmlAttribute","value","fallback","n","Number","Math","c"],"mappings":"0EAsLgBA,C,oCAAAA,U,YAnJ8B,K,IAEG,OA2D5CC,KACAA,MACIA,MACCA,IAoBV,SAASC,UAAUC,CAAW,EAC5B,IAAMC,EAAeD,EAAI,KAAK,CAAC,qBAC3BE,EAAUD,GAAc,CAAC,EAAE,CAC/B,GAAIC,AAAW,MAAXA,EAAiB,CAKnB,IAAMC,EAAaH,EAAI,KAAK,CAAC,+BACvBI,EAAcJ,EAAI,KAAK,CAAC,gCAE5BE,EADEC,AAAc,MAAdA,GAAsBC,AAAe,MAAfA,EACd,CAAC,IAAI,EAAED,CAAU,CAAC,EAAE,CAAC,CAAC,EAAEC,CAAW,CAAC,EAAE,CAAC,CAAC,CAExC,aAEd,CAUA,MAAO,CAAEF,QAAAA,EAASG,MALJL,EACX,OAAO,CAAC,yBAA0B,IAClC,OAAO,CAAC,0BAA2B,IACnC,OAAO,CAAC,oBAAqB,IAC7B,OAAO,CAAC,eAAgB,GACH,CAC1B,CAEA,SAASM,aAAa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