{"version":3,"sources":["/home/runner/work/promptparse/promptparse/dist/chunk-IM6PE5C7.mjs","../src/utils/checksum.ts","../src/lib/tlv.ts","../src/generate/promptpay/BillPayment.ts","../src/lib/BOTBarcode.ts","../src/generate/promptpay/AnyID.ts"],"names":["__defProp","Object","defineProperty","__defNormalProp","obj","key","value","enumerable","configurable","writable","__export","target","all","name","get","__publicField","TABLE","encodeUtf8","message","bytes","i","length","code","charCodeAt","low","push","crc16xmodem","data","crc","b","n","decode","payload","chars","Array","from","tags","idx","id","slice","join","len","test","Number","encode","tag","subTags","checksum","upperCase","sum","toString","toUpperCase","toLowerCase","withCrcTag","crcTagId","tlvTags","tagId","subTagId","find","t","s","billPayment","billerId","amount","ref1","ref2","ref3","tag30","toFixed","BOTBarcode","_BOTBarcode","amountStr","String","toQrTag30","fromString","startsWith","split","parseInt","ProxyType","anyId","type","replace","tag29"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAIA,YAAYC,OAAOC,cAAc;AACrC,IAAIC,kBAAkB,yBAACC,KAAKC,KAAKC;WAAUD,OAAOD,MAAMJ,UAAUI,KAAKC,KAAK;QAAEE,YAAY;QAAMC,cAAc;QAAMC,UAAU;QAAMH,OAAAA;IAAM,KAAKF,GAAG,CAACC,IAAI,GAAGC;;AAC1J,IAAII,WAAW,kBAACC,QAAQC;IACtB,IAAK,IAAIC,QAAQD,IACfZ,UAAUW,QAAQE,MAAM;QAAEC,KAAKF,GAAG,CAACC,KAAK;QAAEN,YAAY;IAAK;AAC/D;AACA,IAAIQ,gBAAgB,uBAACX,KAAKC,KAAKC;WAAUH,gBAAgBC,KAAK,CAAA,OAAOC,oCAAP,SAAOA,IAAE,MAAM,WAAWA,MAAM,KAAKA,KAAKC;;AAExG,wBAAwB;ACLxB,IAAMU,QAAQ;IACZ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAChE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OAAA,CAAQ,MAAM;YAElE;;;;;AJiaF,kCAAkC;AKrc3B,IAAKU,YAAL,aAAA,GAAA,SAAKA;IAEVA,UAAAA,CAAA,SAAA,GAAS;IAGTA,UAAAA,CAAA,QAAA,GAAQ;IAGRA,UAAAA,CAAA,YAAA,GAAY;IAGZA,UAAAA,CAAA,UAAA,GAAU;IAXA,OAAAA;AAAA,EAAAA,aAAA,CAAA;AA8BL,SAASC,MAAM,KAAuB;QAArBC,OAAF,MAAEA,MAAMrE,SAAR,MAAQA,QAAQoD,SAAhB,MAAgBA;IACpC,IAAIiB,QAAQ,UAAU;QACpBrE,SAAA,AAAU,CAAA,kBAAkBA,OAAOsE,OAAA,CAAQ,MAAM,KAAI,EAAG1C,KAAA,CAAM,CAAA;IAChE;IAEA,IAAM2C,QAAQtC,OAAO;QACnBC,IAAI,MAAM;QACVA,IAAIiC,SAAA,CAAUE,KAAI,EAAGrE;KACtB;IAED,IAAMqB,UAAU;QACda,IAAI,MAAM;QACVA,IAAI,MAAM,CAACkB,SAAS,OAAO;QAC3BlB,IAAI,MAAMqC;QACVrC,IAAI,MAAM;QACVA,IAAI,MAAM;KACZ;IAEA,IAAIkB,QAAQ;QACV/B,QAAQP,IAAA,CAAKoB,IAAI,MAAMF,OAAOoB,QAAQK,OAAA,CAAQ;IAChD;IAEA,OAAOf,WAAWT,OAAOZ,UAAU;AACrC;AL6aA,SACEtB,QAAQ,EACRK,aAAa,EACbgB,MAAM,EACNa,MAAM,EACNG,QAAQ,EACRM,UAAU,EACVvC,GAAG,EACH+B,GAAG,EACHgB,WAAW,EACXQ,UAAU,EACVS,SAAS,EACTC,KAAK,GACL","sourcesContent":["var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __export = (target, all) => {\n  for (var name in all)\n    __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\n\n// src/utils/checksum.ts\nvar TABLE = [\n  0,\n  4129,\n  8258,\n  12387,\n  16516,\n  20645,\n  24774,\n  28903,\n  33032,\n  37161,\n  41290,\n  45419,\n  49548,\n  53677,\n  57806,\n  61935,\n  4657,\n  528,\n  12915,\n  8786,\n  21173,\n  17044,\n  29431,\n  25302,\n  37689,\n  33560,\n  45947,\n  41818,\n  54205,\n  50076,\n  62463,\n  58334,\n  9314,\n  13379,\n  1056,\n  5121,\n  25830,\n  29895,\n  17572,\n  21637,\n  42346,\n  46411,\n  34088,\n  38153,\n  58862,\n  62927,\n  50604,\n  54669,\n  13907,\n  9842,\n  5649,\n  1584,\n  30423,\n  26358,\n  22165,\n  18100,\n  46939,\n  42874,\n  38681,\n  34616,\n  63455,\n  59390,\n  55197,\n  51132,\n  18628,\n  22757,\n  26758,\n  30887,\n  2112,\n  6241,\n  10242,\n  14371,\n  51660,\n  55789,\n  59790,\n  63919,\n  35144,\n  39273,\n  43274,\n  47403,\n  23285,\n  19156,\n  31415,\n  27286,\n  6769,\n  2640,\n  14899,\n  10770,\n  56317,\n  52188,\n  64447,\n  60318,\n  39801,\n  35672,\n  47931,\n  43802,\n  27814,\n  31879,\n  19684,\n  23749,\n  11298,\n  15363,\n  3168,\n  7233,\n  60846,\n  64911,\n  52716,\n  56781,\n  44330,\n  48395,\n  36200,\n  40265,\n  32407,\n  28342,\n  24277,\n  20212,\n  15891,\n  11826,\n  7761,\n  3696,\n  65439,\n  61374,\n  57309,\n  53244,\n  48923,\n  44858,\n  40793,\n  36728,\n  37256,\n  33193,\n  45514,\n  41451,\n  53516,\n  49453,\n  61774,\n  57711,\n  4224,\n  161,\n  12482,\n  8419,\n  20484,\n  16421,\n  28742,\n  24679,\n  33721,\n  37784,\n  41979,\n  46042,\n  49981,\n  54044,\n  58239,\n  62302,\n  689,\n  4752,\n  8947,\n  13010,\n  16949,\n  21012,\n  25207,\n  29270,\n  46570,\n  42443,\n  38312,\n  34185,\n  62830,\n  58703,\n  54572,\n  50445,\n  13538,\n  9411,\n  5280,\n  1153,\n  29798,\n  25671,\n  21540,\n  17413,\n  42971,\n  47098,\n  34713,\n  38840,\n  59231,\n  63358,\n  50973,\n  55100,\n  9939,\n  14066,\n  1681,\n  5808,\n  26199,\n  30326,\n  17941,\n  22068,\n  55628,\n  51565,\n  63758,\n  59695,\n  39368,\n  35305,\n  47498,\n  43435,\n  22596,\n  18533,\n  30726,\n  26663,\n  6336,\n  2273,\n  14466,\n  10403,\n  52093,\n  56156,\n  60223,\n  64286,\n  35833,\n  39896,\n  43963,\n  48026,\n  19061,\n  23124,\n  27191,\n  31254,\n  2801,\n  6864,\n  10931,\n  14994,\n  64814,\n  60687,\n  56684,\n  52557,\n  48554,\n  44427,\n  40424,\n  36297,\n  31782,\n  27655,\n  23652,\n  19525,\n  15522,\n  11395,\n  7392,\n  3265,\n  61215,\n  65342,\n  53085,\n  57212,\n  44955,\n  49082,\n  36825,\n  40952,\n  28183,\n  32310,\n  20053,\n  24180,\n  11923,\n  16050,\n  3793,\n  7920\n];\nfunction encodeUtf8(message) {\n  const bytes = [];\n  for (let i = 0; i < message.length; i++) {\n    let code = message.charCodeAt(i);\n    if (code >= 55296 && code <= 56319 && i + 1 < message.length) {\n      const low = message.charCodeAt(i + 1);\n      if (low >= 56320 && low <= 57343) {\n        code = 65536 + (code - 55296 << 10) + (low - 56320);\n        i++;\n      }\n    }\n    if (code >= 55296 && code <= 57343) {\n      code = 65533;\n    }\n    if (code < 128) {\n      bytes.push(code);\n    } else if (code < 2048) {\n      bytes.push(192 | code >> 6, 128 | code & 63);\n    } else if (code < 65536) {\n      bytes.push(\n        224 | code >> 12,\n        128 | code >> 6 & 63,\n        128 | code & 63\n      );\n    } else {\n      bytes.push(\n        240 | code >> 18,\n        128 | code >> 12 & 63,\n        128 | code >> 6 & 63,\n        128 | code & 63\n      );\n    }\n  }\n  return bytes;\n}\nfunction crc16xmodem(data, crc = 0) {\n  const bytes = typeof data === \"string\" ? encodeUtf8(data) : data;\n  for (const b of bytes) {\n    const n = (b ^ crc >> 8) & 255;\n    crc = TABLE[n] ^ crc << 8;\n  }\n  return (crc ^ 0) & 65535;\n}\n\n// src/lib/tlv.ts\nfunction decode(payload) {\n  const chars = Array.from(payload);\n  const tags = [];\n  let idx = 0;\n  while (idx < chars.length) {\n    const id = chars.slice(idx, idx + 2).join(\"\");\n    const len = chars.slice(idx + 2, idx + 4).join(\"\");\n    if (!/^\\d{2}$/.test(id) || !/^\\d{2}$/.test(len)) {\n      return [];\n    }\n    const length = Number(len);\n    if (length < 1 || idx + 4 + length > chars.length) {\n      return [];\n    }\n    const value = chars.slice(idx + 4, idx + 4 + length).join(\"\");\n    tags.push({ id, length, value });\n    idx += length + 4;\n  }\n  return tags;\n}\nfunction encode(tags) {\n  let payload = \"\";\n  for (const tag2 of tags) {\n    payload += tag2.id;\n    payload += (\"00\" + tag2.length).slice(-2);\n    if (tag2.subTags) {\n      payload += encode(tag2.subTags);\n      continue;\n    }\n    payload += tag2.value;\n  }\n  return payload;\n}\nfunction checksum(payload, upperCase = true) {\n  let sum = crc16xmodem(payload, 65535).toString(16);\n  sum = upperCase ? sum.toUpperCase() : sum.toLowerCase();\n  sum = (\"0000\" + sum).slice(-4);\n  return sum;\n}\nfunction withCrcTag(payload, crcTagId, upperCase = true) {\n  payload += (\"00\" + crcTagId).slice(-2);\n  payload += \"04\";\n  payload += checksum(payload, upperCase);\n  return payload;\n}\nfunction get(tlvTags, tagId, subTagId) {\n  const tag2 = tlvTags.find((t) => t.id == tagId);\n  if (subTagId) {\n    return tag2?.subTags?.find((s) => s.id == subTagId);\n  }\n  return tag2;\n}\nfunction tag(tagId, value) {\n  return {\n    id: tagId,\n    length: Array.from(value).length,\n    value\n  };\n}\n\n// src/generate/promptpay/BillPayment.ts\nfunction billPayment({\n  billerId,\n  amount,\n  ref1,\n  ref2,\n  ref3\n}) {\n  const tag30 = [\n    tag(\"00\", \"A000000677010112\"),\n    tag(\"01\", billerId),\n    tag(\"02\", ref1)\n  ];\n  if (ref2) {\n    tag30.push(tag(\"03\", ref2));\n  }\n  const payload = [\n    tag(\"00\", \"01\"),\n    tag(\"01\", !amount ? \"11\" : \"12\"),\n    tag(\"30\", encode(tag30)),\n    tag(\"53\", \"764\"),\n    tag(\"58\", \"TH\")\n  ];\n  if (amount) {\n    payload.push(tag(\"54\", Number(amount).toFixed(2)));\n  }\n  if (ref3) {\n    payload.push(tag(\"62\", encode([tag(\"07\", ref3)])));\n  }\n  return withCrcTag(encode(payload), \"63\");\n}\n\n// src/lib/BOTBarcode.ts\nvar BOTBarcode = class _BOTBarcode {\n  constructor(billerId, ref1, ref2 = null, amount = null) {\n    __publicField(this, \"billerId\");\n    __publicField(this, \"ref1\");\n    __publicField(this, \"ref2\");\n    __publicField(this, \"amount\");\n    this.billerId = billerId;\n    this.ref1 = ref1;\n    this.ref2 = ref2;\n    this.amount = amount;\n  }\n  static fromString(payload) {\n    if (!payload.startsWith(\"|\")) {\n      return null;\n    }\n    const data = payload.slice(1).split(\"\\r\", 4);\n    if (data.length != 4) {\n      return null;\n    }\n    const [billerId, ref1, ref2, amount] = data;\n    return new _BOTBarcode(\n      billerId,\n      ref1,\n      ref2.length > 0 ? ref2 : null,\n      amount != \"0\" ? Number((parseInt(amount) / 100).toFixed(2)) : null\n    );\n  }\n  toString() {\n    const { billerId, ref1, ref2, amount } = this;\n    const amountStr = amount ? String(Number(amount.toFixed(2)) * 100) : \"0\";\n    return `|${billerId}\\r${ref1}\\r${ref2 ?? \"\"}\\r${amountStr}`;\n  }\n  /**\n   * Converts BOT Barcode to PromptPay QR Tag 30 (Bill Payment)\n   *\n   * This method works for some biller, depends on destination bank\n   *\n   * @returns QR Code payload\n   */\n  toQrTag30() {\n    const { billerId, ref1, ref2, amount } = this;\n    return billPayment({\n      billerId,\n      ref1,\n      ref2: ref2 ?? void 0,\n      amount: amount ?? void 0\n    });\n  }\n};\n\n// src/generate/promptpay/AnyID.ts\nvar ProxyType = /* @__PURE__ */ ((ProxyType2) => {\n  ProxyType2[\"MSISDN\"] = \"01\";\n  ProxyType2[\"NATID\"] = \"02\";\n  ProxyType2[\"EWALLETID\"] = \"03\";\n  ProxyType2[\"BANKACC\"] = \"04\";\n  return ProxyType2;\n})(ProxyType || {});\nfunction anyId({ type, target, amount }) {\n  if (type == \"MSISDN\") {\n    target = (\"0000000000000\" + target.replace(/^0/, \"66\")).slice(-13);\n  }\n  const tag29 = encode([\n    tag(\"00\", \"A000000677010111\"),\n    tag(ProxyType[type], target)\n  ]);\n  const payload = [\n    tag(\"00\", \"01\"),\n    tag(\"01\", !amount ? \"11\" : \"12\"),\n    tag(\"29\", tag29),\n    tag(\"53\", \"764\"),\n    tag(\"58\", \"TH\")\n  ];\n  if (amount) {\n    payload.push(tag(\"54\", Number(amount).toFixed(2)));\n  }\n  return withCrcTag(encode(payload), \"63\");\n}\n\nexport {\n  __export,\n  __publicField,\n  decode,\n  encode,\n  checksum,\n  withCrcTag,\n  get,\n  tag,\n  billPayment,\n  BOTBarcode,\n  ProxyType,\n  anyId\n};\n","// CRC-16-CCITT\t(XMODEM)\n\n// Polynomial = 0x1021\nconst TABLE = [\n  0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108,\n  0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210,\n  0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b,\n  0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401,\n  0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee,\n  0xf5cf, 0xc5ac, 0xd58d, 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6,\n  0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d,\n  0xc7bc, 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,\n  0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 0x5af5,\n  0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc,\n  0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 0x6ca6, 0x7c87, 0x4ce4,\n  0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 0xedae, 0xfd8f, 0xcdec, 0xddcd,\n  0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13,\n  0x2e32, 0x1e51, 0x0e70, 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a,\n  0x9f59, 0x8f78, 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e,\n  0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,\n  0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 0x02b1,\n  0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 0xb5ea, 0xa5cb,\n  0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 0x34e2, 0x24c3, 0x14a0,\n  0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8,\n  0xe75f, 0xf77e, 0xc71d, 0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657,\n  0x7676, 0x4615, 0x5634, 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9,\n  0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882,\n  0x28a3, 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,\n  0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 0xfd2e,\n  0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07,\n  0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 0xef1f, 0xff3e, 0xcf5d,\n  0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74,\n  0x2e93, 0x3eb2, 0x0ed1, 0x1ef0,\n]\n\n/**\n * Encode string into an array of `UTF-8` bytes\n *\n * This method is equivalent to:\n *\n * `[...Buffer.from(message, 'utf8')]`\n *\n * @param message - Message\n * @returns Array of UTF-8 bytes\n */\nfunction encodeUtf8(message: string) {\n  const bytes: number[] = []\n\n  for (let i = 0; i < message.length; i++) {\n    let code = message.charCodeAt(i)\n\n    if (code >= 0xd800 && code <= 0xdbff && i + 1 < message.length) {\n      const low = message.charCodeAt(i + 1)\n      if (low >= 0xdc00 && low <= 0xdfff) {\n        code = 0x10000 + ((code - 0xd800) << 10) + (low - 0xdc00)\n        i++\n      }\n    }\n\n    if (code >= 0xd800 && code <= 0xdfff) {\n      code = 0xfffd\n    }\n\n    if (code < 0x80) {\n      bytes.push(code)\n    } else if (code < 0x800) {\n      bytes.push(0xc0 | (code >> 6), 0x80 | (code & 0x3f))\n    } else if (code < 0x10000) {\n      bytes.push(\n        0xe0 | (code >> 12),\n        0x80 | ((code >> 6) & 0x3f),\n        0x80 | (code & 0x3f),\n      )\n    } else {\n      bytes.push(\n        0xf0 | (code >> 18),\n        0x80 | ((code >> 12) & 0x3f),\n        0x80 | ((code >> 6) & 0x3f),\n        0x80 | (code & 0x3f),\n      )\n    }\n  }\n\n  return bytes\n}\n\n/**\n * Calculate CRC-16/XMODEM checksum of provided data\n *\n * Non-ASCII characters are encoded as `UTF-8` bytes before calculation\n *\n * @param data - Any string, or an array of bytes\n * @param crc - Initial CRC value\n * @returns CRC Checksum as number\n */\nexport function crc16xmodem(data: string | number[], crc = 0x0) {\n  const bytes = typeof data === 'string' ? encodeUtf8(data) : data\n\n  for (const b of bytes) {\n    const n = (b ^ (crc >> 8)) & 0xff\n    crc = TABLE[n] ^ (crc << 8)\n  }\n\n  return (crc ^ 0) & 0xffff\n}\n","import { crc16xmodem } from '@/utils/checksum'\n\nexport interface TLVTag {\n  /** Tag ID */\n  id: string\n\n  /** Tag Value */\n  value: string\n\n  /** Sub Tags */\n  subTags?: TLVTag[]\n\n  /** Tag Length */\n  length: number\n}\n\n/**\n * Decode TLV string into array of TLV Tags\n *\n * Lengths are counted in Unicode characters (code points), as defined in\n * EMVCo Merchant-Presented QR Specification v1.1, section 4.4.\n *\n * @param payload - TLV string\n * @returns Array of TLV Tags, or an empty array if the string is malformed\n */\nexport function decode(payload: string) {\n  const chars = Array.from(payload)\n  const tags: TLVTag[] = []\n\n  let idx = 0\n  while (idx < chars.length) {\n    const id = chars.slice(idx, idx + 2).join('')\n    const len = chars.slice(idx + 2, idx + 4).join('')\n    if (!/^\\d{2}$/.test(id) || !/^\\d{2}$/.test(len)) {\n      return []\n    }\n\n    const length = Number(len)\n    if (length < 1 || idx + 4 + length > chars.length) {\n      return []\n    }\n\n    const value = chars.slice(idx + 4, idx + 4 + length).join('')\n    tags.push({ id, length, value })\n    idx += length + 4\n  }\n\n  return tags\n}\n\n/**\n * Encode TLV Tags array into TLV string\n *\n * @param tags - Array of TLV Tags\n * @returns TLV string\n */\nexport function encode(tags: TLVTag[]) {\n  let payload = ''\n\n  for (const tag of tags) {\n    payload += tag.id\n    payload += ('00' + tag.length).slice(-2)\n\n    if (tag.subTags) {\n      payload += encode(tag.subTags)\n      continue\n    }\n\n    payload += tag.value\n  }\n\n  return payload\n}\n\n/**\n * Generate CRC Checksum for provided string\n *\n * @param payload - Any string\n * @param upperCase - Return CRC Checksum as uppercase string\n * @returns CRC Checksum\n */\nexport function checksum(payload: string, upperCase = true) {\n  let sum = crc16xmodem(payload, 0xffff).toString(16)\n  sum = upperCase ? sum.toUpperCase() : sum.toLowerCase()\n  sum = ('0000' + sum).slice(-4)\n  return sum\n}\n\n/**\n * Get TLV string combined with CRC Tag\n *\n * @param payload - TLV string (without CRC Tag)\n * @param crcTagId - CRC Tag ID\n * @param upperCase - Return CRC Checksum as uppercase string\n * @returns TLV string + CRC Tag ID + CRC Length + CRC Checksum\n */\nexport function withCrcTag(\n  payload: string,\n  crcTagId: string,\n  upperCase = true,\n) {\n  payload += ('00' + crcTagId).slice(-2)\n  payload += '04'\n  payload += checksum(payload, upperCase)\n  return payload\n}\n\n/**\n * Get Tag or Sub-tag by Tag ID in array of TLV Tags\n *\n * @param tlvTags - Array of TLV Tags\n * @param tagId - Target Tag ID\n * @param subTagId - Target Sub-tag ID\n * @returns Instance of Target Tag/Sub-tag\n */\nexport function get(tlvTags: TLVTag[], tagId: string, subTagId?: string) {\n  const tag = tlvTags.find((t) => t.id == tagId)\n\n  if (subTagId) {\n    return tag?.subTags?.find((s) => s.id == subTagId)\n  }\n\n  return tag\n}\n\n/**\n * Create new TLV Tag\n *\n * @param tagId - Tag ID\n * @param value - Tag Value\n * @returns TLV Tag\n */\nexport function tag(tagId: string, value: string): TLVTag {\n  return {\n    id: tagId,\n    length: Array.from(value).length,\n    value,\n  }\n}\n","import { encode, tag, withCrcTag } from '@/lib/tlv'\n\nexport interface BillPaymentConfig {\n  /** Biller ID (National ID or Tax ID + Suffix) */\n  billerId: string\n\n  /** Transaction amount */\n  amount?: number\n\n  /** Reference 1 */\n  ref1: string\n\n  /** Reference 2 */\n  ref2?: string\n\n  /** (Undocumented) Reference 3 */\n  ref3?: string\n}\n\n/**\n * Generate PromptPay Bill Payment (Tag 30) QR Code\n *\n * @returns QR Code Payload\n */\nexport function billPayment({\n  billerId,\n  amount,\n  ref1,\n  ref2,\n  ref3,\n}: BillPaymentConfig) {\n  const tag30 = [\n    tag('00', 'A000000677010112'),\n    tag('01', billerId),\n    tag('02', ref1),\n  ]\n\n  if (ref2) {\n    tag30.push(tag('03', ref2))\n  }\n\n  const payload = [\n    tag('00', '01'),\n    tag('01', !amount ? '11' : '12'),\n    tag('30', encode(tag30)),\n    tag('53', '764'),\n    tag('58', 'TH'),\n  ]\n\n  if (amount) {\n    payload.push(tag('54', Number(amount).toFixed(2)))\n  }\n\n  if (ref3) {\n    payload.push(tag('62', encode([tag('07', ref3)])))\n  }\n\n  return withCrcTag(encode(payload), '63')\n}\n","import { billPayment } from '@/generate/promptpay/BillPayment'\n\nexport class BOTBarcode {\n  public billerId: string\n  public ref1: string\n  public ref2: string | null\n  public amount: number | null\n\n  constructor(\n    billerId: string,\n    ref1: string,\n    ref2: string | null = null,\n    amount: number | null = null,\n  ) {\n    this.billerId = billerId\n    this.ref1 = ref1\n    this.ref2 = ref2\n    this.amount = amount\n  }\n\n  static fromString(payload: string) {\n    if (!payload.startsWith('|')) {\n      return null\n    }\n\n    const data = payload.slice(1).split('\\r', 4)\n    if (data.length != 4) {\n      return null\n    }\n\n    const [billerId, ref1, ref2, amount] = data\n\n    return new BOTBarcode(\n      billerId,\n      ref1,\n      ref2.length > 0 ? ref2 : null,\n      amount != '0' ? Number((parseInt(amount) / 100).toFixed(2)) : null,\n    )\n  }\n\n  toString() {\n    const { billerId, ref1, ref2, amount } = this\n    const amountStr = amount ? String(Number(amount.toFixed(2)) * 100) : '0'\n    return `|${billerId}\\r${ref1}\\r${ref2 ?? ''}\\r${amountStr}`\n  }\n\n  /**\n   * Converts BOT Barcode to PromptPay QR Tag 30 (Bill Payment)\n   *\n   * This method works for some biller, depends on destination bank\n   *\n   * @returns QR Code payload\n   */\n  toQrTag30() {\n    const { billerId, ref1, ref2, amount } = this\n    return billPayment({\n      billerId,\n      ref1,\n      ref2: ref2 ?? undefined,\n      amount: amount ?? undefined,\n    })\n  }\n}\n","import { encode, tag, withCrcTag } from '@/lib/tlv'\n\nexport enum ProxyType {\n  /** Mobile number */\n  MSISDN = '01',\n\n  /** National ID or Tax ID */\n  NATID = '02',\n\n  /** E-Wallet ID */\n  EWALLETID = '03',\n\n  /** Bank Account (Reserved) */\n  BANKACC = '04',\n}\n\nexport interface AnyIDConfig {\n  /** Proxy type */\n  type: keyof typeof ProxyType\n\n  /** Recipient number */\n  target: string\n\n  /** Transaction amount */\n  amount?: number\n}\n\n/**\n * Generate PromptPay AnyID (Tag 29) QR Code\n *\n * @returns QR Code Payload\n */\nexport function anyId({ type, target, amount }: AnyIDConfig) {\n  if (type == 'MSISDN') {\n    target = ('0000000000000' + target.replace(/^0/, '66')).slice(-13)\n  }\n\n  const tag29 = encode([\n    tag('00', 'A000000677010111'),\n    tag(ProxyType[type], target),\n  ])\n\n  const payload = [\n    tag('00', '01'),\n    tag('01', !amount ? '11' : '12'),\n    tag('29', tag29),\n    tag('53', '764'),\n    tag('58', 'TH'),\n  ]\n\n  if (amount) {\n    payload.push(tag('54', Number(amount).toFixed(2)))\n  }\n\n  return withCrcTag(encode(payload), '63')\n}\n"]}