{ "version": 3, "sources": ["../javascripts/selectors/item-retailer.ts"], "sourcesContent": ["import { createSelector } from '@reduxjs/toolkit';\nimport type { WaykeQueryLocation } from '../@types/WaykeLocation';\nimport { parsers } from '../helpers';\nimport type { RootState } from '../reducers';\nimport { getPhoneParams, location as locationUtil } from '../utils';\nimport { type GetGeoLocation, getGeoLocation, getQueryFilter } from '../utils/reselectors';\nimport { getItem, getItemCentralStorageBranches } from './item';\nimport { getRetailerDocument, getRetailerPromos } from './retailer';\ninterface GetItemRetailerContactOptions {\n avatarUrl?: string | null;\n displayName?: string | null;\n id?: string | null;\n telephone?: {\n e164?: string | undefined;\n national?: string | undefined;\n international?: string | undefined;\n } | null;\n title?: string | null;\n email?: string | null;\n}\n\nexport const getItemRetailerContactOptions = createSelector(\n [getItem, getRetailerDocument],\n (item, retailer): GetItemRetailerContactOptions | null => {\n if (!item) return null;\n\n const c1 = item?.contactOptions;\n const c2 = retailer?.defaultContactOptions;\n\n return {\n avatarUrl: c1?.avatarUrl || c2?.avatarUrl,\n displayName: c1?.displayName || c2?.displayName,\n id: c1?.id || c2?.id,\n telephone: parsers.parsePhoneNumber(\n c1?.telephone ||\n c2?.telephone ||\n (retailer && retailer.telephoneNumber ? retailer.telephoneNumber : null),\n ),\n title: c1?.title || c2?.title,\n email: c1?.email || c2?.email,\n };\n },\n);\n\nexport const getItemRetailerPhoneParams = createSelector(\n [getItem, getRetailerDocument],\n (item, retailer): ((params: any) => void) => {\n return getPhoneParams.bind(null, item, retailer);\n },\n);\n\ntype GetLocation = WaykeQueryLocation | GetGeoLocation;\n\nexport const getLocation = createSelector(\n [getQueryFilter, getGeoLocation],\n (queryFilter, geoLocation): GetLocation | null => {\n if (queryFilter.hasSpatial()) {\n return queryFilter.getSpatial();\n } else if (geoLocation) {\n return geoLocation;\n }\n return null;\n },\n);\n\nexport const getItemCentralStorageBranchesLocationSorted = (state: RootState) => {\n const branches = getItemCentralStorageBranches(state);\n const location = getLocation(state);\n if (branches) {\n return branches\n .map((x) => {\n return {\n ...x,\n distance: location\n ? locationUtil.getDistance(\n location.lat,\n location.lng,\n x.position.location.lat,\n x.position.location.lon,\n )\n : null,\n };\n })\n .sort((a, b) => (a.distance || 0) - (b.distance || 0));\n }\n return null;\n};\n\nexport const getPromos = (state: RootState) => {\n return getRetailerPromos(state);\n};\n"], "mappings": "+QAqBO,IAAMA,EAAgCC,EAC3C,CAACC,EAASC,CAAmB,EAC7B,CAACC,EAAMC,IAAmD,CACxD,GAAI,CAACD,EAAM,OAAO,KAElB,IAAME,EAAKF,GAAM,eACXG,EAAKF,GAAU,sBAErB,MAAO,CACL,UAAWC,GAAI,WAAaC,GAAI,UAChC,YAAaD,GAAI,aAAeC,GAAI,YACpC,GAAID,GAAI,IAAMC,GAAI,GAClB,UAAWC,EAAQ,iBACjBF,GAAI,WACFC,GAAI,YACHF,GAAYA,EAAS,gBAAkBA,EAAS,gBAAkB,KACvE,EACA,MAAOC,GAAI,OAASC,GAAI,MACxB,MAAOD,GAAI,OAASC,GAAI,KAC1B,CACF,CACF,EAEaE,EAA6BR,EACxC,CAACC,EAASC,CAAmB,EAC7B,CAACC,EAAMC,IACEK,EAAe,KAAK,KAAMN,EAAMC,CAAQ,CAEnD,EAIaM,EAAcV,EACzB,CAACW,EAAgBC,CAAc,EAC/B,CAACC,EAAaC,IACRD,EAAY,WAAW,EAClBA,EAAY,WAAW,EACrBC,GAGJ,IAEX,EAEaC,EAA+CC,GAAqB,CAC/E,IAAMC,EAAWC,EAA8BF,CAAK,EAC9CG,EAAWT,EAAYM,CAAK,EAClC,OAAIC,EACKA,EACJ,IAAKG,IACG,CACL,GAAGA,EACH,SAAUD,EACNE,EAAa,YACXF,EAAS,IACTA,EAAS,IACTC,EAAE,SAAS,SAAS,IACpBA,EAAE,SAAS,SAAS,GACtB,EACA,IACN,EACD,EACA,KAAK,CAACE,EAAGC,KAAOD,EAAE,UAAY,IAAMC,EAAE,UAAY,EAAE,EAElD,IACT,EAEaC,EAAaR,GACjBS,EAAkBT,CAAK", "names": ["getItemRetailerContactOptions", "createSelector", "getItem", "getRetailerDocument", "item", "retailer", "c1", "c2", "parsers_exports", "getItemRetailerPhoneParams", "get_phone_params_default", "getLocation", "getQueryFilter", "getGeoLocation", "queryFilter", "geoLocation", "getItemCentralStorageBranchesLocationSorted", "state", "branches", "getItemCentralStorageBranches", "location", "x", "location_exports", "a", "b", "getPromos", "getRetailerPromos"] }