{"version":3,"file":"index.mjs","sources":["../../../../../../../core/src/utils/index.ts"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid';\n\nimport { OTPMethods, ResponseCommon, User } from '../public';\n\nexport * from './api';\nexport { arrayUtils } from './arrayUtils';\nexport type { Cacheable } from './Cacheable';\nexport * from './checks';\nexport * from './country';\nexport * from './dfp';\nexport type { EnumOrStringLiteral, StringLiteralFromEnum } from './EnumOrStringLiteral';\nexport { loadESModule } from './loadESModule';\nexport * from './logger';\n\nexport const isTestPublicToken = (token: string) => token.includes('public-token-test');\n\n/**\n * Normalizes an es5 promise with a .then(onSuccess, onFailure) signature to\n * the es6 .then().catch() signature\n */\nexport const normalizePromiseLike = <T>(prom: PromiseLike<T>): Promise<T> => {\n  return new Promise<T>((resolve, reject) => {\n    prom.then(resolve, reject);\n  });\n};\n\nexport const createEventId = () => `event-id-${uuidv4()}`;\nexport const createAppSessionId = () => `app-session-id-${uuidv4()}`;\nexport const createPersistentId = () => `persistent-id-${uuidv4()}`;\n\nexport const isPhoneMethod = (selectionMethod: string) =>\n  selectionMethod === OTPMethods.SMS || selectionMethod === OTPMethods.WhatsApp;\nexport const isEmailMethod = (selectionMethod: string) => selectionMethod === OTPMethods.Email;\n\nexport const removeResponseCommon = <T extends ResponseCommon>({\n  request_id,\n\n  status_code,\n  ...rest\n}: T): Omit<T, keyof ResponseCommon> => rest;\n\nexport type WithUser<T> = T & { __user: User & ResponseCommon };\n\nexport const omitUser = <T extends ResponseCommon>(resp: T & { __user: User }): T => {\n  const { __user, ...rest } = resp;\n  return rest as unknown as T;\n};\n\nexport type Values<T extends object> = T[keyof T];\n\n// A simplified version of PartialDeep from type-fest to avoid referencing that package in exported types\ntype Primitive = null | undefined | string | number | boolean | symbol | bigint;\n\ntype _PartialDeep<T> = T extends Primitive\n  ? T //\n  : T extends object\n    ? PartialObjectDeep<T>\n    : unknown;\n\ntype PartialObjectDeep<ObjectType extends object> = {\n  [KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType]>;\n};\n\nexport type PartialDeep<T> = _PartialDeep<T>;\n"],"names":["isTestPublicToken","token","includes","createEventId","uuidv4","createAppSessionId","createPersistentId","removeResponseCommon","request_id","status_code","rest","omitUser","resp","__user"],"mappings":";;MAcaA,iBAAAA,GAAoB,CAACC,QAAkBA,KAAAA,CAAMC,QAAQ,CAAC,mBAAA;MAYtDC,aAAAA,GAAgB,IAAM,CAAC,SAAS,EAAEC;MAClCC,kBAAAA,GAAqB,IAAM,CAAC,eAAe,EAAED;MAC7CE,kBAAAA,GAAqB,IAAM,CAAC,cAAc,EAAEF;AAMlD,MAAMG,oBAAAA,GAAuB,CAA2B,EAC7DC,UAAU,EAEVC,WAAW,EACX,GAAGC,IAAAA,EACD,GAAoCA;AAIjC,MAAMC,WAAW,CAA2BC,IAAAA,GAAAA;AACjD,IAAA,MAAM,EAAEC,MAAM,EAAE,GAAGH,MAAM,GAAGE,IAAAA;IAC5B,OAAOF,IAAAA;AACT;;;;"}