{ "version": 3, "sources": ["../../../src/ts/utils/fetch.ts", "../../../src/ts/utils/constants.ts", "../../../src/ts/utils/general.ts"], "sourcesContent": ["export interface Alert {\n type: \"danger\" | \"warning\" | \"info\" | \"success\";\n message: string;\n}\n\nexport interface InData {\n Data?: T;\n Feedback?: Alert;\n}\n\n// Returns [inData, statusCode]\nexport function request(path: string, params: RequestInit): Promise<[InData, number]> {\n return fetch(path, params)\n .then(async (response) => {\n const statusCode = response.status;\n return response\n .json()\n .catch((err) => {\n console.error(response);\n console.error(err);\n return [undefined, statusCode];\n })\n .then((inData) => [inData as InData, statusCode])\n .catch((err) => {\n console.error(response);\n console.error(err);\n return [undefined, statusCode];\n });\n })\n .catch((err) => {\n console.error(err);\n return [undefined, 500];\n }) as Promise<[InData, number]>;\n}\n\nexport function nonJsonRequest(path: string, params: RequestInit): Promise<[string, number]> {\n return fetch(path, params)\n .then(async (response) => {\n const statusCode = response.status;\n return response\n .text()\n .catch((err) => {\n console.error(response);\n console.error(err);\n return [undefined, statusCode];\n })\n .then((inData) => [inData, statusCode])\n .catch((err) => {\n console.error(response);\n console.error(err);\n return [undefined, statusCode];\n });\n })\n .catch((err) => {\n console.error(err);\n return [undefined, 500];\n }) as Promise<[string, number]>;\n}\n", "export const HTTP_STATUS_CODES: Record = {\n 200: \"OK\",\n 201: \"Created\",\n 202: \"Accepted\",\n 203: \"Non-Authoritative Information\",\n 204: \"No Content\",\n 205: \"Reset Content\",\n 206: \"Partial Content\",\n 300: \"Multiple Choices\",\n 301: \"Moved Permanently\",\n 302: \"Found\",\n 303: \"See Other\",\n 304: \"Not Modified\",\n 305: \"Use Proxy\",\n 307: \"Temporary Redirect\",\n 400: \"Bad Request\",\n 401: \"Unauthorized\",\n 402: \"Payment Required\",\n 403: \"Forbidden\",\n 404: \"Not Found\",\n 405: \"Method Not Allowed\",\n 406: \"Not Acceptable\",\n 407: \"Proxy Authentication Required\",\n 408: \"Request Timeout\",\n 409: \"Conflict\",\n 410: \"Gone\",\n 411: \"Length Required\",\n 412: \"Precondition Failed\",\n 413: \"Request Entity Too Large\",\n 414: \"Request-URI Too Long\",\n 415: \"Unsupported Media Type\",\n 416: \"Requested Range Not Satisfiable\",\n 417: \"Expectation Failed\",\n 500: \"Internal Server Error\",\n 501: \"Not Implemented\",\n 502: \"Bad Gateway\",\n 503: \"Service Unavailable\",\n 504: \"Gateway Timeout\",\n 505: \"HTTP Version Not Supported\",\n};\n", "export function isEmpty(str: string): boolean {\n return str.trim().length === 0;\n}\n\nexport function headingsToParagraphs(text: string): string {\n for (let level = 1; level <= 6; level++) {\n text = text.replaceAll(``, `

`);\n text = text.replaceAll(``, \"

\");\n }\n\n return text;\n}\n\nexport function isStatusSuccessful(statusCode: number): boolean {\n if (statusCode >= 200 && statusCode <= 299) {\n return true;\n }\n\n return false;\n}\n\nexport function boolStrToYesNo(b: string): string {\n if (b === \"true\") {\n return \"yes\";\n }\n if (b === \"false\") {\n return \"no\";\n }\n console.error(`Could not interpret \"${b}\".`);\n return \"\";\n}\n\nexport function bytesToSize(bytes: number): string {\n const units = ['byte', 'kilobyte', 'megabyte', 'gigabyte', 'terabyte'];\n\n const navigatorLocal = navigator.languages && navigator.languages.length >= 0 ? navigator.languages[0] : 'en-US'\n const unitIndex = Math.max(0, Math.min(Math.floor(Math.log(bytes) / Math.log(1000)), units.length - 1));\n\n return Intl.NumberFormat(navigatorLocal, {\n style: 'unit',\n unit: units[unitIndex]\n }).format(bytes / (1000 ** unitIndex))\n}\n"], "mappings": "wCAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EAAA,YAAAC,IAWO,SAASA,EAAWC,EAAcC,EAAmD,CAC1F,OAAO,MAAMD,EAAMC,CAAM,EACtB,KAAK,MAAOC,GAAa,CACxB,IAAMC,EAAaD,EAAS,OAC5B,OAAOA,EACJ,KAAK,EACL,MAAOE,IACN,QAAQ,MAAMF,CAAQ,EACtB,QAAQ,MAAME,CAAG,EACV,CAAC,OAAWD,CAAU,EAC9B,E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AAA,oBAAAE,EAAA,gBAAAC,EAAA,yBAAAC,EAAA,YAAAC,EAAA,uBAAAC,IAAO,SAASD,EAAQE,EAAsB,CAC5C,OAAOA,EAAI,KAAK,EAAE,SAAW,CAC/B,CAEO,SAASH,EAAqBI,EAAsB,CACzD,QAASC,EAAQ,EAAGA,GAAS,EAAGA,IAC9BD,EAAOA,EAAK,WAAW,KAAKC,CAAK,IAAK,cAAcA,CAAK,IAAI,EAC7DD,EAAOA,EAAK,WAAW,MAAMC,CAAK,IAAK,MAAM,EAG/C,OAAOD,CACT,CAEO,SAASF,EAAmBI,EAA6B,CAC9D,OAAIA,GAAc,KAAOA,GAAc,GAKzC,CAEO,SAASR,EAAeS,EAAmB,CAChD,OAAIA,IAAM,OACD,MAELA,IAAM,QACD,MAET,QAAQ,MAAM,wBAAwBA,CAAC,IAAI,EACpC,GACT,CAEO,SAASR,EAAYS,EAAuB,CACjD,IAAMC,EAAQ,CAAC,OAAQ,WAAY,WAAY,WAAY,UAAU,EAE/DC,EAAiB,UAAU,WAAa,UAAU,UAAU,QAAU,EAAI,UAAU,UAAU,CAAC,EAAI,QACnGC,EAAY,KAAK,IAAI,EAAG,KAAK,IAAI,KAAK,MAAM,KAAK,IAAIH,CAAK,EAAI,KAAK,IAAI,GAAI,CAAC,EAAGC,EAAM,OAAS,CAAC,CAAC,EAEtG,OAAO,KAAK,aAAaC,EAAgB,CACvC,MAAO,OACP,KAAMD,EAAME,CAAS,CACvB,CAAC,EAAE,OAAOH,EAAS,KAAQG,CAAU,CACvC", "names": ["fetch_exports", "__export", "nonJsonRequest", "request", "path", "params", "response", "statusCode", "err", "inData", "constants_exports", "__export", "HTTP_STATUS_CODES", "general_exports", "__export", "boolStrToYesNo", "bytesToSize", "headingsToParagraphs", "isEmpty", "isStatusSuccessful", "str", "text", "level", "statusCode", "b", "bytes", "units", "navigatorLocal", "unitIndex"] }