@ripwords/myinvois-client 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["r","e","t","s","l","a","i","b","m","Headers","AbortController","r","nodeFetch","http","https","Headers$1","AbortController$1","clientId: string","clientSecret: string","environment: 'sandbox' | 'production'","path: string","options: Parameters<typeof ofetch>[1]","tin: string","nric: string"],"sources":["../../node_modules/node-fetch-native/dist/index.mjs","../../node_modules/destr/dist/index.mjs","../../node_modules/ufo/dist/index.mjs","../../node_modules/ofetch/dist/shared/ofetch.03887fc3.mjs","../../node_modules/ofetch/dist/node.mjs","../../src/utils/MyInvoisClient.ts"],"sourcesContent":["import{fetch as e,Blob as t,File as s,FormData as l,Headers as a,Request as i,Response as b,AbortController as m}from\"./node.mjs\";export{AbortError,FetchError,blobFrom,blobFromSync,fileFrom,fileFromSync,isRedirect}from\"./node.mjs\";import\"node:http\";import\"node:https\";import\"node:zlib\";import\"node:stream\";import\"node:buffer\";import\"node:util\";import\"./shared/node-fetch-native.DfbY2q-x.mjs\";import\"node:url\";import\"node:net\";import\"node:fs\";import\"node:path\";const o=!!globalThis.process?.env?.FORCE_NODE_FETCH,r=!o&&globalThis.fetch||e,p=!o&&globalThis.Blob||t,F=!o&&globalThis.File||s,h=!o&&globalThis.FormData||l,n=!o&&globalThis.Headers||a,c=!o&&globalThis.Request||i,R=!o&&globalThis.Response||b,T=!o&&globalThis.AbortController||m;export{T as AbortController,p as Blob,F as File,h as FormData,n as Headers,c as Request,R as Response,r as default,r as fetch};\n","const suspectProtoRx = /\"(?:_|\\\\u0{2}5[Ff]){2}(?:p|\\\\u0{2}70)(?:r|\\\\u0{2}72)(?:o|\\\\u0{2}6[Ff])(?:t|\\\\u0{2}74)(?:o|\\\\u0{2}6[Ff])(?:_|\\\\u0{2}5[Ff]){2}\"\\s*:/;\nconst suspectConstructorRx = /\"(?:c|\\\\u0063)(?:o|\\\\u006[Ff])(?:n|\\\\u006[Ee])(?:s|\\\\u0073)(?:t|\\\\u0074)(?:r|\\\\u0072)(?:u|\\\\u0075)(?:c|\\\\u0063)(?:t|\\\\u0074)(?:o|\\\\u006[Ff])(?:r|\\\\u0072)\"\\s*:/;\nconst JsonSigRx = /^\\s*[\"[{]|^\\s*-?\\d{1,16}(\\.\\d{1,17})?([Ee][+-]?\\d+)?\\s*$/;\nfunction jsonParseTransform(key, value) {\n if (key === \"__proto__\" || key === \"constructor\" && value && typeof value === \"object\" && \"prototype\" in value) {\n warnKeyDropped(key);\n return;\n }\n return value;\n}\nfunction warnKeyDropped(key) {\n console.warn(`[destr] Dropping \"${key}\" key to prevent prototype pollution.`);\n}\nfunction destr(value, options = {}) {\n if (typeof value !== \"string\") {\n return value;\n }\n if (value[0] === '\"' && value[value.length - 1] === '\"' && value.indexOf(\"\\\\\") === -1) {\n return value.slice(1, -1);\n }\n const _value = value.trim();\n if (_value.length <= 9) {\n switch (_value.toLowerCase()) {\n case \"true\": {\n return true;\n }\n case \"false\": {\n return false;\n }\n case \"undefined\": {\n return void 0;\n }\n case \"null\": {\n return null;\n }\n case \"nan\": {\n return Number.NaN;\n }\n case \"infinity\": {\n return Number.POSITIVE_INFINITY;\n }\n case \"-infinity\": {\n return Number.NEGATIVE_INFINITY;\n }\n }\n }\n if (!JsonSigRx.test(value)) {\n if (options.strict) {\n throw new SyntaxError(\"[destr] Invalid JSON\");\n }\n return value;\n }\n try {\n if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {\n if (options.strict) {\n throw new Error(\"[destr] Possible prototype pollution\");\n }\n return JSON.parse(value, jsonParseTransform);\n }\n return JSON.parse(value);\n } catch (error) {\n if (options.strict) {\n throw error;\n }\n return value;\n }\n}\nfunction safeDestr(value, options = {}) {\n return destr(value, { ...options, strict: true });\n}\n\nexport { destr as default, destr, safeDestr };\n","const n = /[^\\0-\\x7E]/;\nconst t = /[\\x2E\\u3002\\uFF0E\\uFF61]/g;\nconst o = {\n overflow: \"Overflow Error\",\n \"not-basic\": \"Illegal Input\",\n \"invalid-input\": \"Invalid Input\"\n};\nconst e = Math.floor;\nconst r = String.fromCharCode;\nfunction s(n2) {\n throw new RangeError(o[n2]);\n}\nconst c = function(n2, t2) {\n return n2 + 22 + 75 * (n2 < 26) - ((t2 != 0) << 5);\n};\nconst u = function(n2, t2, o2) {\n let r2 = 0;\n for (n2 = o2 ? e(n2 / 700) : n2 >> 1, n2 += e(n2 / t2); n2 > 455; r2 += 36) {\n n2 = e(n2 / 35);\n }\n return e(r2 + 36 * n2 / (n2 + 38));\n};\nfunction toASCII(o2) {\n return function(n2, o3) {\n const e2 = n2.split(\"@\");\n let r2 = \"\";\n e2.length > 1 && (r2 = e2[0] + \"@\", n2 = e2[1]);\n const s2 = function(n3, t2) {\n const o4 = [];\n let e3 = n3.length;\n for (; e3--; ) {\n o4[e3] = t2(n3[e3]);\n }\n return o4;\n }((n2 = n2.replace(t, \".\")).split(\".\"), o3).join(\".\");\n return r2 + s2;\n }(o2, function(t2) {\n return n.test(t2) ? \"xn--\" + function(n2) {\n const t3 = [];\n const o3 = (n2 = function(n3) {\n const t4 = [];\n let o4 = 0;\n const e2 = n3.length;\n for (; o4 < e2; ) {\n const r2 = n3.charCodeAt(o4++);\n if (r2 >= 55296 && r2 <= 56319 && o4 < e2) {\n const e3 = n3.charCodeAt(o4++);\n (64512 & e3) == 56320 ? t4.push(((1023 & r2) << 10) + (1023 & e3) + 65536) : (t4.push(r2), o4--);\n } else {\n t4.push(r2);\n }\n }\n return t4;\n }(n2)).length;\n let f = 128;\n let i = 0;\n let l = 72;\n for (const o4 of n2) {\n o4 < 128 && t3.push(r(o4));\n }\n const h = t3.length;\n let p = h;\n for (h && t3.push(\"-\"); p < o3; ) {\n let o4 = 2147483647;\n for (const t4 of n2) {\n t4 >= f && t4 < o4 && (o4 = t4);\n }\n const a = p + 1;\n o4 - f > e((2147483647 - i) / a) && s(\"overflow\"), i += (o4 - f) * a, f = o4;\n for (const o5 of n2) {\n if (o5 < f && ++i > 2147483647 && s(\"overflow\"), o5 == f) {\n let n3 = i;\n for (let o6 = 36; ; o6 += 36) {\n const s2 = o6 <= l ? 1 : o6 >= l + 26 ? 26 : o6 - l;\n if (n3 < s2) {\n break;\n }\n const u2 = n3 - s2;\n const f2 = 36 - s2;\n t3.push(r(c(s2 + u2 % f2, 0))), n3 = e(u2 / f2);\n }\n t3.push(r(c(n3, 0))), l = u(i, a, p == h), i = 0, ++p;\n }\n }\n ++i, ++f;\n }\n return t3.join(\"\");\n }(t2) : t2;\n });\n}\n\nconst HASH_RE = /#/g;\nconst AMPERSAND_RE = /&/g;\nconst SLASH_RE = /\\//g;\nconst EQUAL_RE = /=/g;\nconst IM_RE = /\\?/g;\nconst PLUS_RE = /\\+/g;\nconst ENC_CARET_RE = /%5e/gi;\nconst ENC_BACKTICK_RE = /%60/gi;\nconst ENC_CURLY_OPEN_RE = /%7b/gi;\nconst ENC_PIPE_RE = /%7c/gi;\nconst ENC_CURLY_CLOSE_RE = /%7d/gi;\nconst ENC_SPACE_RE = /%20/gi;\nconst ENC_SLASH_RE = /%2f/gi;\nconst ENC_ENC_SLASH_RE = /%252f/gi;\nfunction encode(text) {\n return encodeURI(\"\" + text).replace(ENC_PIPE_RE, \"|\");\n}\nfunction encodeHash(text) {\n return encode(text).replace(ENC_CURLY_OPEN_RE, \"{\").replace(ENC_CURLY_CLOSE_RE, \"}\").replace(ENC_CARET_RE, \"^\");\n}\nfunction encodeQueryValue(input) {\n return encode(typeof input === \"string\" ? input : JSON.stringify(input)).replace(PLUS_RE, \"%2B\").replace(ENC_SPACE_RE, \"+\").replace(HASH_RE, \"%23\").replace(AMPERSAND_RE, \"%26\").replace(ENC_BACKTICK_RE, \"`\").replace(ENC_CARET_RE, \"^\").replace(SLASH_RE, \"%2F\");\n}\nfunction encodeQueryKey(text) {\n return encodeQueryValue(text).replace(EQUAL_RE, \"%3D\");\n}\nfunction encodePath(text) {\n return encode(text).replace(HASH_RE, \"%23\").replace(IM_RE, \"%3F\").replace(ENC_ENC_SLASH_RE, \"%2F\").replace(AMPERSAND_RE, \"%26\").replace(PLUS_RE, \"%2B\");\n}\nfunction encodeParam(text) {\n return encodePath(text).replace(SLASH_RE, \"%2F\");\n}\nfunction decode(text = \"\") {\n try {\n return decodeURIComponent(\"\" + text);\n } catch {\n return \"\" + text;\n }\n}\nfunction decodePath(text) {\n return decode(text.replace(ENC_SLASH_RE, \"%252F\"));\n}\nfunction decodeQueryKey(text) {\n return decode(text.replace(PLUS_RE, \" \"));\n}\nfunction decodeQueryValue(text) {\n return decode(text.replace(PLUS_RE, \" \"));\n}\nfunction encodeHost(name = \"\") {\n return toASCII(name);\n}\n\nfunction parseQuery(parametersString = \"\") {\n const object = /* @__PURE__ */ Object.create(null);\n if (parametersString[0] === \"?\") {\n parametersString = parametersString.slice(1);\n }\n for (const parameter of parametersString.split(\"&\")) {\n const s = parameter.match(/([^=]+)=?(.*)/) || [];\n if (s.length < 2) {\n continue;\n }\n const key = decodeQueryKey(s[1]);\n if (key === \"__proto__\" || key === \"constructor\") {\n continue;\n }\n const value = decodeQueryValue(s[2] || \"\");\n if (object[key] === void 0) {\n object[key] = value;\n } else if (Array.isArray(object[key])) {\n object[key].push(value);\n } else {\n object[key] = [object[key], value];\n }\n }\n return object;\n}\nfunction encodeQueryItem(key, value) {\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n value = String(value);\n }\n if (!value) {\n return encodeQueryKey(key);\n }\n if (Array.isArray(value)) {\n return value.map(\n (_value) => `${encodeQueryKey(key)}=${encodeQueryValue(_value)}`\n ).join(\"&\");\n }\n return `${encodeQueryKey(key)}=${encodeQueryValue(value)}`;\n}\nfunction stringifyQuery(query) {\n return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem(k, query[k])).filter(Boolean).join(\"&\");\n}\n\nconst PROTOCOL_STRICT_REGEX = /^[\\s\\w\\0+.-]{2,}:([/\\\\]{1,2})/;\nconst PROTOCOL_REGEX = /^[\\s\\w\\0+.-]{2,}:([/\\\\]{2})?/;\nconst PROTOCOL_RELATIVE_REGEX = /^([/\\\\]\\s*){2,}[^/\\\\]/;\nconst PROTOCOL_SCRIPT_RE = /^[\\s\\0]*(blob|data|javascript|vbscript):$/i;\nconst TRAILING_SLASH_RE = /\\/$|\\/\\?|\\/#/;\nconst JOIN_LEADING_SLASH_RE = /^\\.?\\//;\nfunction isRelative(inputString) {\n return [\"./\", \"../\"].some((string_) => inputString.startsWith(string_));\n}\nfunction hasProtocol(inputString, opts = {}) {\n if (typeof opts === \"boolean\") {\n opts = { acceptRelative: opts };\n }\n if (opts.strict) {\n return PROTOCOL_STRICT_REGEX.test(inputString);\n }\n return PROTOCOL_REGEX.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX.test(inputString) : false);\n}\nfunction isScriptProtocol(protocol) {\n return !!protocol && PROTOCOL_SCRIPT_RE.test(protocol);\n}\nfunction hasTrailingSlash(input = \"\", respectQueryAndFragment) {\n if (!respectQueryAndFragment) {\n return input.endsWith(\"/\");\n }\n return TRAILING_SLASH_RE.test(input);\n}\nfunction withoutTrailingSlash(input = \"\", respectQueryAndFragment) {\n if (!respectQueryAndFragment) {\n return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || \"/\";\n }\n if (!hasTrailingSlash(input, true)) {\n return input || \"/\";\n }\n let path = input;\n let fragment = \"\";\n const fragmentIndex = input.indexOf(\"#\");\n if (fragmentIndex !== -1) {\n path = input.slice(0, fragmentIndex);\n fragment = input.slice(fragmentIndex);\n }\n const [s0, ...s] = path.split(\"?\");\n const cleanPath = s0.endsWith(\"/\") ? s0.slice(0, -1) : s0;\n return (cleanPath || \"/\") + (s.length > 0 ? `?${s.join(\"?\")}` : \"\") + fragment;\n}\nfunction withTrailingSlash(input = \"\", respectQueryAndFragment) {\n if (!respectQueryAndFragment) {\n return input.endsWith(\"/\") ? input : input + \"/\";\n }\n if (hasTrailingSlash(input, true)) {\n return input || \"/\";\n }\n let path = input;\n let fragment = \"\";\n const fragmentIndex = input.indexOf(\"#\");\n if (fragmentIndex !== -1) {\n path = input.slice(0, fragmentIndex);\n fragment = input.slice(fragmentIndex);\n if (!path) {\n return fragment;\n }\n }\n const [s0, ...s] = path.split(\"?\");\n return s0 + \"/\" + (s.length > 0 ? `?${s.join(\"?\")}` : \"\") + fragment;\n}\nfunction hasLeadingSlash(input = \"\") {\n return input.startsWith(\"/\");\n}\nfunction withoutLeadingSlash(input = \"\") {\n return (hasLeadingSlash(input) ? input.slice(1) : input) || \"/\";\n}\nfunction withLeadingSlash(input = \"\") {\n return hasLeadingSlash(input) ? input : \"/\" + input;\n}\nfunction cleanDoubleSlashes(input = \"\") {\n return input.split(\"://\").map((string_) => string_.replace(/\\/{2,}/g, \"/\")).join(\"://\");\n}\nfunction withBase(input, base) {\n if (isEmptyURL(base) || hasProtocol(input)) {\n return input;\n }\n const _base = withoutTrailingSlash(base);\n if (input.startsWith(_base)) {\n return input;\n }\n return joinURL(_base, input);\n}\nfunction withoutBase(input, base) {\n if (isEmptyURL(base)) {\n return input;\n }\n const _base = withoutTrailingSlash(base);\n if (!input.startsWith(_base)) {\n return input;\n }\n const trimmed = input.slice(_base.length);\n return trimmed[0] === \"/\" ? trimmed : \"/\" + trimmed;\n}\nfunction withQuery(input, query) {\n const parsed = parseURL(input);\n const mergedQuery = { ...parseQuery(parsed.search), ...query };\n parsed.search = stringifyQuery(mergedQuery);\n return stringifyParsedURL(parsed);\n}\nfunction filterQuery(input, predicate) {\n if (!input.includes(\"?\")) {\n return input;\n }\n const parsed = parseURL(input);\n const query = parseQuery(parsed.search);\n const filteredQuery = Object.fromEntries(\n Object.entries(query).filter(([key, value]) => predicate(key, value))\n );\n parsed.search = stringifyQuery(filteredQuery);\n return stringifyParsedURL(parsed);\n}\nfunction getQuery(input) {\n return parseQuery(parseURL(input).search);\n}\nfunction isEmptyURL(url) {\n return !url || url === \"/\";\n}\nfunction isNonEmptyURL(url) {\n return url && url !== \"/\";\n}\nfunction joinURL(base, ...input) {\n let url = base || \"\";\n for (const segment of input.filter((url2) => isNonEmptyURL(url2))) {\n if (url) {\n const _segment = segment.replace(JOIN_LEADING_SLASH_RE, \"\");\n url = withTrailingSlash(url) + _segment;\n } else {\n url = segment;\n }\n }\n return url;\n}\nfunction joinRelativeURL(..._input) {\n const JOIN_SEGMENT_SPLIT_RE = /\\/(?!\\/)/;\n const input = _input.filter(Boolean);\n const segments = [];\n let segmentsDepth = 0;\n for (const i of input) {\n if (!i || i === \"/\") {\n continue;\n }\n for (const [sindex, s] of i.split(JOIN_SEGMENT_SPLIT_RE).entries()) {\n if (!s || s === \".\") {\n continue;\n }\n if (s === \"..\") {\n if (segments.length === 1 && hasProtocol(segments[0])) {\n continue;\n }\n segments.pop();\n segmentsDepth--;\n continue;\n }\n if (sindex === 1 && segments[segments.length - 1]?.endsWith(\":/\")) {\n segments[segments.length - 1] += \"/\" + s;\n continue;\n }\n segments.push(s);\n segmentsDepth++;\n }\n }\n let url = segments.join(\"/\");\n if (segmentsDepth >= 0) {\n if (input[0]?.startsWith(\"/\") && !url.startsWith(\"/\")) {\n url = \"/\" + url;\n } else if (input[0]?.startsWith(\"./\") && !url.startsWith(\"./\")) {\n url = \"./\" + url;\n }\n } else {\n url = \"../\".repeat(-1 * segmentsDepth) + url;\n }\n if (input[input.length - 1]?.endsWith(\"/\") && !url.endsWith(\"/\")) {\n url += \"/\";\n }\n return url;\n}\nfunction withHttp(input) {\n return withProtocol(input, \"http://\");\n}\nfunction withHttps(input) {\n return withProtocol(input, \"https://\");\n}\nfunction withoutProtocol(input) {\n return withProtocol(input, \"\");\n}\nfunction withProtocol(input, protocol) {\n let match = input.match(PROTOCOL_REGEX);\n if (!match) {\n match = input.match(/^\\/{2,}/);\n }\n if (!match) {\n return protocol + input;\n }\n return protocol + input.slice(match[0].length);\n}\nfunction normalizeURL(input) {\n const parsed = parseURL(input);\n parsed.pathname = encodePath(decodePath(parsed.pathname));\n parsed.hash = encodeHash(decode(parsed.hash));\n parsed.host = encodeHost(decode(parsed.host));\n parsed.search = stringifyQuery(parseQuery(parsed.search));\n return stringifyParsedURL(parsed);\n}\nfunction resolveURL(base = \"\", ...inputs) {\n if (typeof base !== \"string\") {\n throw new TypeError(\n `URL input should be string received ${typeof base} (${base})`\n );\n }\n const filteredInputs = inputs.filter((input) => isNonEmptyURL(input));\n if (filteredInputs.length === 0) {\n return base;\n }\n const url = parseURL(base);\n for (const inputSegment of filteredInputs) {\n const urlSegment = parseURL(inputSegment);\n if (urlSegment.pathname) {\n url.pathname = withTrailingSlash(url.pathname) + withoutLeadingSlash(urlSegment.pathname);\n }\n if (urlSegment.hash && urlSegment.hash !== \"#\") {\n url.hash = urlSegment.hash;\n }\n if (urlSegment.search && urlSegment.search !== \"?\") {\n if (url.search && url.search !== \"?\") {\n const queryString = stringifyQuery({\n ...parseQuery(url.search),\n ...parseQuery(urlSegment.search)\n });\n url.search = queryString.length > 0 ? \"?\" + queryString : \"\";\n } else {\n url.search = urlSegment.search;\n }\n }\n }\n return stringifyParsedURL(url);\n}\nfunction isSamePath(p1, p2) {\n return decode(withoutTrailingSlash(p1)) === decode(withoutTrailingSlash(p2));\n}\nfunction isEqual(a, b, options = {}) {\n if (!options.trailingSlash) {\n a = withTrailingSlash(a);\n b = withTrailingSlash(b);\n }\n if (!options.leadingSlash) {\n a = withLeadingSlash(a);\n b = withLeadingSlash(b);\n }\n if (!options.encoding) {\n a = decode(a);\n b = decode(b);\n }\n return a === b;\n}\nfunction withFragment(input, hash) {\n if (!hash || hash === \"#\") {\n return input;\n }\n const parsed = parseURL(input);\n parsed.hash = hash === \"\" ? \"\" : \"#\" + encodeHash(hash);\n return stringifyParsedURL(parsed);\n}\nfunction withoutFragment(input) {\n return stringifyParsedURL({ ...parseURL(input), hash: \"\" });\n}\nfunction withoutHost(input) {\n const parsed = parseURL(input);\n return (parsed.pathname || \"/\") + parsed.search + parsed.hash;\n}\n\nconst protocolRelative = Symbol.for(\"ufo:protocolRelative\");\nfunction parseURL(input = \"\", defaultProto) {\n const _specialProtoMatch = input.match(\n /^[\\s\\0]*(blob:|data:|javascript:|vbscript:)(.*)/i\n );\n if (_specialProtoMatch) {\n const [, _proto, _pathname = \"\"] = _specialProtoMatch;\n return {\n protocol: _proto.toLowerCase(),\n pathname: _pathname,\n href: _proto + _pathname,\n auth: \"\",\n host: \"\",\n search: \"\",\n hash: \"\"\n };\n }\n if (!hasProtocol(input, { acceptRelative: true })) {\n return defaultProto ? parseURL(defaultProto + input) : parsePath(input);\n }\n const [, protocol = \"\", auth, hostAndPath = \"\"] = input.replace(/\\\\/g, \"/\").match(/^[\\s\\0]*([\\w+.-]{2,}:)?\\/\\/([^/@]+@)?(.*)/) || [];\n let [, host = \"\", path = \"\"] = hostAndPath.match(/([^#/?]*)(.*)?/) || [];\n if (protocol === \"file:\") {\n path = path.replace(/\\/(?=[A-Za-z]:)/, \"\");\n }\n const { pathname, search, hash } = parsePath(path);\n return {\n protocol: protocol.toLowerCase(),\n auth: auth ? auth.slice(0, Math.max(0, auth.length - 1)) : \"\",\n host,\n pathname,\n search,\n hash,\n [protocolRelative]: !protocol\n };\n}\nfunction parsePath(input = \"\") {\n const [pathname = \"\", search = \"\", hash = \"\"] = (input.match(/([^#?]*)(\\?[^#]*)?(#.*)?/) || []).splice(1);\n return {\n pathname,\n search,\n hash\n };\n}\nfunction parseAuth(input = \"\") {\n const [username, password] = input.split(\":\");\n return {\n username: decode(username),\n password: decode(password)\n };\n}\nfunction parseHost(input = \"\") {\n const [hostname, port] = (input.match(/([^/:]*):?(\\d+)?/) || []).splice(1);\n return {\n hostname: decode(hostname),\n port\n };\n}\nfunction stringifyParsedURL(parsed) {\n const pathname = parsed.pathname || \"\";\n const search = parsed.search ? (parsed.search.startsWith(\"?\") ? \"\" : \"?\") + parsed.search : \"\";\n const hash = parsed.hash || \"\";\n const auth = parsed.auth ? parsed.auth + \"@\" : \"\";\n const host = parsed.host || \"\";\n const proto = parsed.protocol || parsed[protocolRelative] ? (parsed.protocol || \"\") + \"//\" : \"\";\n return proto + auth + host + pathname + search + hash;\n}\nconst FILENAME_STRICT_REGEX = /\\/([^/]+\\.[^/]+)$/;\nconst FILENAME_REGEX = /\\/([^/]+)$/;\nfunction parseFilename(input = \"\", opts) {\n const { pathname } = parseURL(input);\n const matches = opts?.strict ? pathname.match(FILENAME_STRICT_REGEX) : pathname.match(FILENAME_REGEX);\n return matches ? matches[1] : void 0;\n}\n\nclass $URL {\n protocol;\n host;\n auth;\n pathname;\n query = {};\n hash;\n constructor(input = \"\") {\n if (typeof input !== \"string\") {\n throw new TypeError(\n `URL input should be string received ${typeof input} (${input})`\n );\n }\n const parsed = parseURL(input);\n this.protocol = decode(parsed.protocol);\n this.host = decode(parsed.host);\n this.auth = decode(parsed.auth);\n this.pathname = decodePath(parsed.pathname);\n this.query = parseQuery(parsed.search);\n this.hash = decode(parsed.hash);\n }\n get hostname() {\n return parseHost(this.host).hostname;\n }\n get port() {\n return parseHost(this.host).port || \"\";\n }\n get username() {\n return parseAuth(this.auth).username;\n }\n get password() {\n return parseAuth(this.auth).password || \"\";\n }\n get hasProtocol() {\n return this.protocol.length;\n }\n get isAbsolute() {\n return this.hasProtocol || this.pathname[0] === \"/\";\n }\n get search() {\n const q = stringifyQuery(this.query);\n return q.length > 0 ? \"?\" + q : \"\";\n }\n get searchParams() {\n const p = new URLSearchParams();\n for (const name in this.query) {\n const value = this.query[name];\n if (Array.isArray(value)) {\n for (const v of value) {\n p.append(name, v);\n }\n } else {\n p.append(\n name,\n typeof value === \"string\" ? value : JSON.stringify(value)\n );\n }\n }\n return p;\n }\n get origin() {\n return (this.protocol ? this.protocol + \"//\" : \"\") + encodeHost(this.host);\n }\n get fullpath() {\n return encodePath(this.pathname) + this.search + encodeHash(this.hash);\n }\n get encodedAuth() {\n if (!this.auth) {\n return \"\";\n }\n const { username, password } = parseAuth(this.auth);\n return encodeURIComponent(username) + (password ? \":\" + encodeURIComponent(password) : \"\");\n }\n get href() {\n const auth = this.encodedAuth;\n const originWithAuth = (this.protocol ? this.protocol + \"//\" : \"\") + (auth ? auth + \"@\" : \"\") + encodeHost(this.host);\n return this.hasProtocol && this.isAbsolute ? originWithAuth + this.fullpath : this.fullpath;\n }\n append(url) {\n if (url.hasProtocol) {\n throw new Error(\"Cannot append a URL with protocol\");\n }\n Object.assign(this.query, url.query);\n if (url.pathname) {\n this.pathname = withTrailingSlash(this.pathname) + withoutLeadingSlash(url.pathname);\n }\n if (url.hash) {\n this.hash = url.hash;\n }\n }\n toJSON() {\n return this.href;\n }\n toString() {\n return this.href;\n }\n}\nfunction createURL(input) {\n return new $URL(input);\n}\n\nexport { $URL, cleanDoubleSlashes, createURL, decode, decodePath, decodeQueryKey, decodeQueryValue, encode, encodeHash, encodeHost, encodeParam, encodePath, encodeQueryItem, encodeQueryKey, encodeQueryValue, filterQuery, getQuery, hasLeadingSlash, hasProtocol, hasTrailingSlash, isEmptyURL, isEqual, isNonEmptyURL, isRelative, isSamePath, isScriptProtocol, joinRelativeURL, joinURL, normalizeURL, parseAuth, parseFilename, parseHost, parsePath, parseQuery, parseURL, resolveURL, stringifyParsedURL, stringifyQuery, withBase, withFragment, withHttp, withHttps, withLeadingSlash, withProtocol, withQuery, withTrailingSlash, withoutBase, withoutFragment, withoutHost, withoutLeadingSlash, withoutProtocol, withoutTrailingSlash };\n","import destr from 'destr';\nimport { withBase, withQuery } from 'ufo';\n\nclass FetchError extends Error {\n constructor(message, opts) {\n super(message, opts);\n this.name = \"FetchError\";\n if (opts?.cause && !this.cause) {\n this.cause = opts.cause;\n }\n }\n}\nfunction createFetchError(ctx) {\n const errorMessage = ctx.error?.message || ctx.error?.toString() || \"\";\n const method = ctx.request?.method || ctx.options?.method || \"GET\";\n const url = ctx.request?.url || String(ctx.request) || \"/\";\n const requestStr = `[${method}] ${JSON.stringify(url)}`;\n const statusStr = ctx.response ? `${ctx.response.status} ${ctx.response.statusText}` : \"<no response>\";\n const message = `${requestStr}: ${statusStr}${errorMessage ? ` ${errorMessage}` : \"\"}`;\n const fetchError = new FetchError(\n message,\n ctx.error ? { cause: ctx.error } : void 0\n );\n for (const key of [\"request\", \"options\", \"response\"]) {\n Object.defineProperty(fetchError, key, {\n get() {\n return ctx[key];\n }\n });\n }\n for (const [key, refKey] of [\n [\"data\", \"_data\"],\n [\"status\", \"status\"],\n [\"statusCode\", \"status\"],\n [\"statusText\", \"statusText\"],\n [\"statusMessage\", \"statusText\"]\n ]) {\n Object.defineProperty(fetchError, key, {\n get() {\n return ctx.response && ctx.response[refKey];\n }\n });\n }\n return fetchError;\n}\n\nconst payloadMethods = new Set(\n Object.freeze([\"PATCH\", \"POST\", \"PUT\", \"DELETE\"])\n);\nfunction isPayloadMethod(method = \"GET\") {\n return payloadMethods.has(method.toUpperCase());\n}\nfunction isJSONSerializable(value) {\n if (value === void 0) {\n return false;\n }\n const t = typeof value;\n if (t === \"string\" || t === \"number\" || t === \"boolean\" || t === null) {\n return true;\n }\n if (t !== \"object\") {\n return false;\n }\n if (Array.isArray(value)) {\n return true;\n }\n if (value.buffer) {\n return false;\n }\n return value.constructor && value.constructor.name === \"Object\" || typeof value.toJSON === \"function\";\n}\nconst textTypes = /* @__PURE__ */ new Set([\n \"image/svg\",\n \"application/xml\",\n \"application/xhtml\",\n \"application/html\"\n]);\nconst JSON_RE = /^application\\/(?:[\\w!#$%&*.^`~-]*\\+)?json(;.+)?$/i;\nfunction detectResponseType(_contentType = \"\") {\n if (!_contentType) {\n return \"json\";\n }\n const contentType = _contentType.split(\";\").shift() || \"\";\n if (JSON_RE.test(contentType)) {\n return \"json\";\n }\n if (textTypes.has(contentType) || contentType.startsWith(\"text/\")) {\n return \"text\";\n }\n return \"blob\";\n}\nfunction resolveFetchOptions(request, input, defaults, Headers) {\n const headers = mergeHeaders(\n input?.headers ?? request?.headers,\n defaults?.headers,\n Headers\n );\n let query;\n if (defaults?.query || defaults?.params || input?.params || input?.query) {\n query = {\n ...defaults?.params,\n ...defaults?.query,\n ...input?.params,\n ...input?.query\n };\n }\n return {\n ...defaults,\n ...input,\n query,\n params: query,\n headers\n };\n}\nfunction mergeHeaders(input, defaults, Headers) {\n if (!defaults) {\n return new Headers(input);\n }\n const headers = new Headers(defaults);\n if (input) {\n for (const [key, value] of Symbol.iterator in input || Array.isArray(input) ? input : new Headers(input)) {\n headers.set(key, value);\n }\n }\n return headers;\n}\nasync function callHooks(context, hooks) {\n if (hooks) {\n if (Array.isArray(hooks)) {\n for (const hook of hooks) {\n await hook(context);\n }\n } else {\n await hooks(context);\n }\n }\n}\n\nconst retryStatusCodes = /* @__PURE__ */ new Set([\n 408,\n // Request Timeout\n 409,\n // Conflict\n 425,\n // Too Early (Experimental)\n 429,\n // Too Many Requests\n 500,\n // Internal Server Error\n 502,\n // Bad Gateway\n 503,\n // Service Unavailable\n 504\n // Gateway Timeout\n]);\nconst nullBodyResponses = /* @__PURE__ */ new Set([101, 204, 205, 304]);\nfunction createFetch(globalOptions = {}) {\n const {\n fetch = globalThis.fetch,\n Headers = globalThis.Headers,\n AbortController = globalThis.AbortController\n } = globalOptions;\n async function onError(context) {\n const isAbort = context.error && context.error.name === \"AbortError\" && !context.options.timeout || false;\n if (context.options.retry !== false && !isAbort) {\n let retries;\n if (typeof context.options.retry === \"number\") {\n retries = context.options.retry;\n } else {\n retries = isPayloadMethod(context.options.method) ? 0 : 1;\n }\n const responseCode = context.response && context.response.status || 500;\n if (retries > 0 && (Array.isArray(context.options.retryStatusCodes) ? context.options.retryStatusCodes.includes(responseCode) : retryStatusCodes.has(responseCode))) {\n const retryDelay = typeof context.options.retryDelay === \"function\" ? context.options.retryDelay(context) : context.options.retryDelay || 0;\n if (retryDelay > 0) {\n await new Promise((resolve) => setTimeout(resolve, retryDelay));\n }\n return $fetchRaw(context.request, {\n ...context.options,\n retry: retries - 1\n });\n }\n }\n const error = createFetchError(context);\n if (Error.captureStackTrace) {\n Error.captureStackTrace(error, $fetchRaw);\n }\n throw error;\n }\n const $fetchRaw = async function $fetchRaw2(_request, _options = {}) {\n const context = {\n request: _request,\n options: resolveFetchOptions(\n _request,\n _options,\n globalOptions.defaults,\n Headers\n ),\n response: void 0,\n error: void 0\n };\n if (context.options.method) {\n context.options.method = context.options.method.toUpperCase();\n }\n if (context.options.onRequest) {\n await callHooks(context, context.options.onRequest);\n }\n if (typeof context.request === \"string\") {\n if (context.options.baseURL) {\n context.request = withBase(context.request, context.options.baseURL);\n }\n if (context.options.query) {\n context.request = withQuery(context.request, context.options.query);\n delete context.options.query;\n }\n if (\"query\" in context.options) {\n delete context.options.query;\n }\n if (\"params\" in context.options) {\n delete context.options.params;\n }\n }\n if (context.options.body && isPayloadMethod(context.options.method)) {\n if (isJSONSerializable(context.options.body)) {\n context.options.body = typeof context.options.body === \"string\" ? context.options.body : JSON.stringify(context.options.body);\n context.options.headers = new Headers(context.options.headers || {});\n if (!context.options.headers.has(\"content-type\")) {\n context.options.headers.set(\"content-type\", \"application/json\");\n }\n if (!context.options.headers.has(\"accept\")) {\n context.options.headers.set(\"accept\", \"application/json\");\n }\n } else if (\n // ReadableStream Body\n \"pipeTo\" in context.options.body && typeof context.options.body.pipeTo === \"function\" || // Node.js Stream Body\n typeof context.options.body.pipe === \"function\"\n ) {\n if (!(\"duplex\" in context.options)) {\n context.options.duplex = \"half\";\n }\n }\n }\n let abortTimeout;\n if (!context.options.signal && context.options.timeout) {\n const controller = new AbortController();\n abortTimeout = setTimeout(() => {\n const error = new Error(\n \"[TimeoutError]: The operation was aborted due to timeout\"\n );\n error.name = \"TimeoutError\";\n error.code = 23;\n controller.abort(error);\n }, context.options.timeout);\n context.options.signal = controller.signal;\n }\n try {\n context.response = await fetch(\n context.request,\n context.options\n );\n } catch (error) {\n context.error = error;\n if (context.options.onRequestError) {\n await callHooks(\n context,\n context.options.onRequestError\n );\n }\n return await onError(context);\n } finally {\n if (abortTimeout) {\n clearTimeout(abortTimeout);\n }\n }\n const hasBody = (context.response.body || // https://github.com/unjs/ofetch/issues/324\n // https://github.com/unjs/ofetch/issues/294\n // https://github.com/JakeChampion/fetch/issues/1454\n context.response._bodyInit) && !nullBodyResponses.has(context.response.status) && context.options.method !== \"HEAD\";\n if (hasBody) {\n const responseType = (context.options.parseResponse ? \"json\" : context.options.responseType) || detectResponseType(context.response.headers.get(\"content-type\") || \"\");\n switch (responseType) {\n case \"json\": {\n const data = await context.response.text();\n const parseFunction = context.options.parseResponse || destr;\n context.response._data = parseFunction(data);\n break;\n }\n case \"stream\": {\n context.response._data = context.response.body || context.response._bodyInit;\n break;\n }\n default: {\n context.response._data = await context.response[responseType]();\n }\n }\n }\n if (context.options.onResponse) {\n await callHooks(\n context,\n context.options.onResponse\n );\n }\n if (!context.options.ignoreResponseError && context.response.status >= 400 && context.response.status < 600) {\n if (context.options.onResponseError) {\n await callHooks(\n context,\n context.options.onResponseError\n );\n }\n return await onError(context);\n }\n return context.response;\n };\n const $fetch = async function $fetch2(request, options) {\n const r = await $fetchRaw(request, options);\n return r._data;\n };\n $fetch.raw = $fetchRaw;\n $fetch.native = (...args) => fetch(...args);\n $fetch.create = (defaultOptions = {}, customGlobalOptions = {}) => createFetch({\n ...globalOptions,\n ...customGlobalOptions,\n defaults: {\n ...globalOptions.defaults,\n ...customGlobalOptions.defaults,\n ...defaultOptions\n }\n });\n return $fetch;\n}\n\nexport { FetchError as F, createFetchError as a, createFetch as c };\n","import http from 'node:http';\nimport https from 'node:https';\nimport nodeFetch, { Headers as Headers$1, AbortController as AbortController$1 } from 'node-fetch-native';\nimport { c as createFetch } from './shared/ofetch.03887fc3.mjs';\nexport { F as FetchError, a as createFetchError } from './shared/ofetch.03887fc3.mjs';\nimport 'destr';\nimport 'ufo';\n\nfunction createNodeFetch() {\n const useKeepAlive = JSON.parse(process.env.FETCH_KEEP_ALIVE || \"false\");\n if (!useKeepAlive) {\n return nodeFetch;\n }\n const agentOptions = { keepAlive: true };\n const httpAgent = new http.Agent(agentOptions);\n const httpsAgent = new https.Agent(agentOptions);\n const nodeFetchOptions = {\n agent(parsedURL) {\n return parsedURL.protocol === \"http:\" ? httpAgent : httpsAgent;\n }\n };\n return function nodeFetchWithKeepAlive(input, init) {\n return nodeFetch(input, { ...nodeFetchOptions, ...init });\n };\n}\nconst fetch = globalThis.fetch ? (...args) => globalThis.fetch(...args) : createNodeFetch();\nconst Headers = globalThis.Headers || Headers$1;\nconst AbortController = globalThis.AbortController || AbortController$1;\nconst ofetch = createFetch({ fetch, Headers, AbortController });\nconst $fetch = ofetch;\n\nexport { $fetch, AbortController, Headers, createFetch, createNodeFetch, fetch, ofetch };\n","import { ofetch } from 'ofetch/node'\n\ninterface TokenResponse {\n access_token: string\n expires_in: number\n}\n\nexport class MyInvoisClient {\n private readonly baseUrl: string\n private readonly clientId: string\n private readonly clientSecret: string\n private token = ''\n private tokenExpiration: Date | undefined\n\n constructor(\n clientId: string,\n clientSecret: string,\n environment: 'sandbox' | 'production',\n ) {\n this.clientId = clientId\n this.clientSecret = clientSecret\n\n if (environment === 'sandbox') {\n this.baseUrl = 'https://preprod-mytax.hasil.gov.my'\n } else {\n this.baseUrl = 'https://mytax.hasil.gov.my'\n }\n }\n\n private async refreshToken() {\n const tokenResponse = await ofetch<TokenResponse>(\n `${this.baseUrl}/connect/token`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: {\n grant_type: 'client_credentials',\n client_id: this.clientId,\n client_secret: this.clientSecret,\n scope: 'InvoicingAPI',\n },\n },\n )\n\n this.token = tokenResponse.access_token\n this.tokenExpiration = new Date(\n Date.now() + tokenResponse.expires_in * 1000,\n )\n }\n\n private async getToken() {\n if (!this.tokenExpiration || this.tokenExpiration < new Date()) {\n await this.refreshToken()\n }\n\n return this.token\n }\n\n private async fetch<T>(\n path: string,\n options: Parameters<typeof ofetch>[1] = {},\n ) {\n const token = await this.getToken()\n\n return ofetch<T>(`${this.baseUrl}${path}`, {\n ...options,\n headers: { ...options.headers, Authorization: `Bearer ${token}` },\n responseType: 'json',\n })\n }\n\n /**\n * Validates a TIN against a NRIC\n *\n * @param tin\n * @param nric\n * @returns\n */\n async verifyTin(tin: string, nric: string) {\n try {\n await this.fetch<void>(\n `/api/v1.0/taxpayer/validate/${tin}?idType=NRIC&idValue=${nric}`,\n {\n method: 'GET',\n },\n )\n\n return true\n } catch {\n return false\n }\n }\n}\n"],"x_google_ignoreList":[0,1,2,3,4],"mappings":";;;;;;;;;;;;;;AAA4c,MAAM,MAAI,WAAW,SAAS,KAAK,kBAAiBA,OAAG,KAAG,WAAW,SAAOC,iBAAE,KAAG,KAAG,WAAW,QAAMC,iBAAE,KAAG,KAAG,WAAW,QAAMC,iBAAE,KAAG,KAAG,WAAW,YAAUC,iBAAE,KAAG,KAAG,WAAW,WAASC,iBAAE,KAAG,KAAG,WAAW,WAASC,iBAAE,KAAG,KAAG,WAAW,YAAUC,gBAAE,KAAG,KAAG,WAAW,mBAAiBC;;;;ACAhuB,MAAM,iBAAiB;AACvB,MAAM,uBAAuB;AAC7B,MAAM,YAAY;AAClB,SAAS,mBAAmB,KAAK,OAAO;AACtC,KAAI,QAAQ,eAAe,QAAQ,iBAAiB,gBAAgB,UAAU,YAAY,eAAe,OAAO;AAC9G,iBAAe,IAAI;AACnB;CACD;AACD,QAAO;AACR;AACD,SAAS,eAAe,KAAK;AAC3B,SAAQ,MAAM,oBAAoB,IAAI,uCAAuC;AAC9E;AACD,SAAS,MAAM,OAAO,UAAU,CAAE,GAAE;AAClC,YAAW,UAAU,SACnB,QAAO;AAET,KAAI,MAAM,OAAO,QAAO,MAAM,MAAM,SAAS,OAAO,QAAO,MAAM,QAAQ,KAAK,KAAK,GACjF,QAAO,MAAM,MAAM,GAAG,GAAG;CAE3B,MAAM,SAAS,MAAM,MAAM;AAC3B,KAAI,OAAO,UAAU,EACnB,SAAQ,OAAO,aAAa,EAA5B;EACE,KAAK,OACH,QAAO;EAET,KAAK,QACH,QAAO;EAET,KAAK,YACH,aAAY;EAEd,KAAK,OACH,QAAO;EAET,KAAK,MAC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tD,MAAM,SAAS,YAAY;CAAE;CAAO;CAAS;AAAiB,EAAC;;;;ICrBlD,iBAAN,MAAqB;CAC1B,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAQ,QAAQ;CAChB,AAAQ;CAER,YACEC,UACAC,cACAC,aACA;AACA,OAAK,WAAW;AAChB,OAAK,eAAe;AAEpB,MAAI,gBAAgB,UAClB,MAAK,UAAU;MAEf,MAAK,UAAU;CAElB;CAED,MAAc,eAAe;EAC3B,MAAM,gBAAgB,MAAM,QACzB,EAAE,KAAK,QAAQ,iBAChB;GACE,QAAQ;GACR,SAAS,EACP,gBAAgB,oCACjB;GACD,MAAM;IACJ,YAAY;IACZ,WAAW,KAAK;IAChB,eAAe,KAAK;IACpB,OAAO;GACR;EACF,EACF;AAED,OAAK,QAAQ,cAAc;AAC3B,OAAK,kBAAkB,IAAI,KACzB,KAAK,KAAK,GAAG,cAAc,aAAa;CAE3C;CAED,MAAc,WAAW;AACvB,OAAK,KAAK,mBAAmB,KAAK,kBAAkB,IAAI,OACtD,OAAM,KAAK,cAAc;AAG3B,SAAO,KAAK;CACb;CAED,MAAc,MACZC,MACAC,UAAwC,CAAE,GAC1C;EACA,MAAM,QAAQ,MAAM,KAAK,UAAU;AAEnC,SAAO,QAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,GAAG;GACzC,GAAG;GACH,SAAS;IAAE,GAAG,QAAQ;IAAS,gBAAgB,SAAS,MAAM;GAAG;GACjE,cAAc;EACf,EAAC;CACH;;;;;;;;CASD,MAAM,UAAUC,KAAaC,MAAc;AACzC,MAAI;AACF,SAAM,KAAK,OACR,8BAA8B,IAAI,uBAAuB,KAAK,GAC/D,EACE,QAAQ,MACT,EACF;AAED,UAAO;EACR,QAAO;AACN,UAAO;EACR;CACF;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["clientId: string","clientSecret: string","environment: 'sandbox' | 'production'","tokenResponse: TokenResponse","path: string","options: Parameters<typeof fetch>[1]","tin: string","nric: string"],"sources":["../../src/utils/MyInvoisClient.ts"],"sourcesContent":["interface TokenResponse {\n access_token: string\n expires_in: number\n}\n\nexport class MyInvoisClient {\n private readonly baseUrl: string\n private readonly clientId: string\n private readonly clientSecret: string\n private token = ''\n private tokenExpiration: Date | undefined\n\n constructor(\n clientId: string,\n clientSecret: string,\n environment: 'sandbox' | 'production',\n ) {\n this.clientId = clientId\n this.clientSecret = clientSecret\n\n if (environment === 'sandbox') {\n this.baseUrl = 'https://preprod-api.myinvois.hasil.gov.my'\n } else {\n this.baseUrl = 'https://api.myinvois.hasil.gov.my'\n }\n }\n\n private async refreshToken() {\n try {\n const response = await fetch(`${this.baseUrl}/connect/token`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: new URLSearchParams({\n grant_type: 'client_credentials',\n client_id: this.clientId,\n client_secret: this.clientSecret,\n scope: 'InvoicingAPI',\n }),\n })\n\n const tokenResponse: TokenResponse = await response.json()\n\n this.token = tokenResponse.access_token\n this.tokenExpiration = new Date(\n Date.now() + tokenResponse.expires_in * 1000,\n )\n } catch (error) {\n console.error(error)\n }\n }\n\n private async getToken() {\n if (!this.tokenExpiration || this.tokenExpiration < new Date()) {\n await this.refreshToken()\n }\n\n return this.token\n }\n\n private async fetch(path: string, options: Parameters<typeof fetch>[1] = {}) {\n const token = await this.getToken()\n\n return fetch(`${this.baseUrl}${path}`, {\n ...options,\n headers: { ...options.headers, Authorization: `Bearer ${token}` },\n })\n }\n\n /**\n * Validates a TIN against a NRIC\n *\n * @param tin\n * @param nric\n * @returns\n */\n async verifyTin(tin: string, nric: string) {\n try {\n const response = await this.fetch(\n `/api/v1.0/taxpayer/validate/${tin}?idType=NRIC&idValue=${nric}`,\n {\n method: 'GET',\n },\n )\n\n if (response.status === 200) {\n return true\n }\n\n return false\n } catch (error) {\n console.error(error)\n return false\n }\n }\n}\n"],"mappings":";;;IAKa,iBAAN,MAAqB;CAC1B,AAAiB;CACjB,AAAiB;CACjB,AAAiB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