{"version":3,"file":"J0gE97s0.js","sources":["../../../../app.config.ts","../../../app.config.mjs","../../../../node_modules/.pnpm/nuxt@3.15.4_@parcel+watcher@2.5.1_@types+node@22.13.10_db0@0.3.1_encoding@0.1.13_eslint_efda240d11188e381a3c0162d69e826f/node_modules/nuxt/dist/app/config.js","../../../../composables/api/services.ts"],"sourcesContent":["export default defineAppConfig({\n useMockData: false,\n});\n","\nimport { updateAppConfig } from '#app/config'\nimport { defuFn } from 'defu'\n\nconst inlineConfig = {\n \"nuxt\": {}\n}\n\n// Vite - webpack is handled directly in #app/config\nif (import.meta.hot) {\n import.meta.hot.accept((newModule) => {\n updateAppConfig(newModule.default)\n })\n}\n\nimport cfg0 from \"/codebuild/output/src919036332/src/gx-booking/app.config.ts\"\n\nexport default /*@__PURE__*/ defuFn(cfg0, inlineConfig)\n","import { reactive } from \"vue\";\nimport { klona } from \"klona\";\nimport { useNuxtApp } from \"./nuxt.js\";\nimport __appConfig from \"#build/app.config.mjs\";\nexport const _getAppConfig = () => __appConfig;\nfunction isPojoOrArray(val) {\n return Array.isArray(val) || !!val && typeof val === \"object\" && val.constructor?.name === \"Object\";\n}\nfunction deepDelete(obj, newObj) {\n for (const key in obj) {\n const val = newObj[key];\n if (!(key in newObj)) {\n delete obj[key];\n }\n if (isPojoOrArray(val)) {\n deepDelete(obj[key], newObj[key]);\n }\n }\n}\nfunction deepAssign(obj, newObj) {\n for (const key in newObj) {\n const val = newObj[key];\n if (isPojoOrArray(val)) {\n const defaultVal = Array.isArray(val) ? [] : {};\n obj[key] = obj[key] || defaultVal;\n deepAssign(obj[key], val);\n } else {\n obj[key] = val;\n }\n }\n}\nexport function useAppConfig() {\n const nuxtApp = useNuxtApp();\n if (!nuxtApp._appConfig) {\n nuxtApp._appConfig = import.meta.server ? klona(__appConfig) : reactive(__appConfig);\n }\n return nuxtApp._appConfig;\n}\nexport function updateAppConfig(appConfig) {\n const _appConfig = useAppConfig();\n deepAssign(_appConfig, appConfig);\n}\nif (import.meta.dev) {\n const applyHMR = (newConfig) => {\n const appConfig = useAppConfig();\n if (newConfig && appConfig) {\n deepAssign(appConfig, newConfig);\n deepDelete(appConfig, newConfig);\n }\n };\n if (import.meta.hot) {\n import.meta.hot.accept((newModule) => {\n const newConfig = newModule?._getAppConfig();\n applyHMR(newConfig);\n });\n }\n if (import.meta.webpackHot) {\n import.meta.webpackHot.accept(\"#build/app.config.mjs\", () => {\n applyHMR(__appConfig);\n });\n }\n}\n","import convertToSlug from '~/utility/convertToSlug';\nimport type { IServiceApi, IServiceApiResponse, IServiceResponse, IService, TServiceType, TServiceStatus, TServicePriceType, TServiceGroupType, IServiceApiSingleResponse, IServiceSingle, IServiceImage } from '~/types/services';\n\n/**\n * Retrieves a paginated list of services.\n *\n * @param {number} areaId - The Area Id to load Services for.\n * @param {number} categoryId - The Category Id to load Services for.\n * @returns {Promise} - A promise that resolves to a list of services.\n */\nexport async function getServices (areaId: number, categoryId: number): Promise {\n const appConfig = useAppConfig();\n let response: IServiceApiResponse;\n\n if (appConfig.useMockData) {\n response = await $fetch('/mock/service/paginate.json');\n } else {\n response = await useAPI(`/v1/area/${areaId}/category/${categoryId}/service`, {\n method: 'GET',\n }, true);\n }\n\n return {\n data: response.data.map((service: IServiceResponse) => formatService(service)),\n meta: response.meta\n };\n}\n\n/**\n * Retrieves a paginated list of services.\n *\n * @param {number} accountContextId - The Account Context Id to load Services for.\n * @param {number} categoryId - The Category Id to load Services for.\n * @returns {Promise} - A promise that resolves to a list of services.\n */\nexport async function getServicesByAccountContextId (accountContextId: number, categoryId: number): Promise {\n const response = await useAPI(`/v1/account-context/${accountContextId}/category/${categoryId}/service`, {\n method: 'GET',\n }, true);\n\n return {\n data: response.data.map((service: IServiceResponse) => formatService(service)),\n meta: response.meta\n };\n}\n\nexport async function getService (areaId: number, serviceId: number): Promise {\n const appConfig = useAppConfig();\n let response: IServiceApiSingleResponse;\n\n if (appConfig.useMockData) {\n response = await $fetch('/mock/service/paginate.json');\n } else {\n response = await useAPI(`/v1/area/${areaId}/service/${serviceId}`, {\n method: 'GET',\n });\n }\n\n return formatService(response.data);\n}\n\nexport async function getServiceByAccountContextId (accountContextId: number, serviceId: number): Promise {\n const response = await useAPI(`/v1/account-context/${accountContextId}/service/${serviceId}`, {\n method: 'GET',\n });\n\n return formatService(response.data);\n}\n\ninterface IPriceInfo {\n totalCost: number;\n totalDiscount: number;\n totalWithoutDiscount: number;\n code?: {\n success: boolean;\n code: string;\n message: string\n } | {\n type: 'percentage' | 'fixed';\n totalDiscount: number;\n discountPercentage: number | null;\n };\n}\n\nexport function getPriceByAccountContextId (accountContextId: number, serviceId: number, adults: number, children: number, sessionLength: number, promoCode?: string | null): Promise {\n return getPrice(undefined, accountContextId, serviceId, adults, children, sessionLength, promoCode);\n}\n\nexport function getPriceByAreaId (areaId: number, serviceId: number, adults: number, children: number, sessionLength: number, promoCode?: string | null): Promise {\n return getPrice(areaId, undefined, serviceId, adults, children, sessionLength, promoCode);\n}\n\nasync function getPrice (areaId: number | undefined, accountContextId: number | undefined, serviceId: number, adults: number, children: number, sessionLength: number, promoCode?: string | null): Promise {\n const response = await useAPI<{ data: { totalPrice: number; totalDiscount: number; totalWithoutDiscount: number; code: { success: boolean; code: string; message: string } | { type: 'percentage' | 'fixed'; discountPercentage: number; }; }}>('/v1/service/price', {\n method: 'POST',\n body: JSON.stringify({\n areaId,\n contextId: accountContextId,\n serviceId,\n adults,\n children,\n sessionLength,\n code: promoCode,\n }),\n });\n\n let code;\n\n if (response.data.code) {\n if ('success' in response.data.code && response.data.code.success === false) {\n code = {\n success: false,\n code: response.data.code.code,\n message: response.data.code.message,\n };\n } else if ('type' in response.data.code) {\n code = {\n type: response.data.code.type,\n totalDiscount: response.data.totalDiscount,\n discountPercentage: response.data.code.discountPercentage || null,\n };\n }\n }\n\n return {\n totalCost: Number(response.data.totalPrice),\n totalDiscount: Number(response.data.totalDiscount),\n totalWithoutDiscount: Number(response.data.totalWithoutDiscount),\n code,\n } as IPriceInfo;\n}\n\n/**\n * Formats a single Service response from the server into a front end object\n * @param {IServiceResponse} service A response object received from the API\n * @returns {IService}\n */\nexport function formatService (service: IServiceResponse): IService {\n // format images and sort so cover image is first\n let images = (service.images || []).map(image => formatImage(image)).sort(a => a.isCover ? -1 : 1);\n let coverImage = images.find(image => image.isCover) || images[0];\n\n // if we've loaded a single service based on area & category then we get a single coverImageUrl which we turn into a single image in the same format\n // as when we retrieve a single Service\n if (service.coverImageUrl) {\n images = [\n {\n id: 0,\n isCover: true,\n url: service.coverImageUrl,\n },\n ];\n coverImage = images[0];\n }\n\n // if we still don't have a cover image then we use a default one and add it to the images array too\n if (!coverImage) {\n images.push({ url: '/layout/service-images/one-webp.webp', isCover: true, id: 0 });\n coverImage = images[0];\n }\n\n return {\n ...service,\n images,\n coverImage,\n price: Number(service.price),\n payout: Number(service.payout),\n type: service.type as TServiceType,\n status: service.status as TServiceStatus,\n priceType: service.priceType as TServicePriceType,\n groupType: service.groupType as TServiceGroupType,\n modality: {\n id: service.modality.id,\n name: service.modality.name,\n },\n locations: (service.locations || []),\n savedCustomUserLocations: (service.savedCustomUserLocations || []),\n locationType: service.locationType as IService['locationType'],\n maxGuests: service.maxGuests,\n category: service.category\n ? {\n id: service.category.id,\n name: service.category.name,\n slug: convertToSlug(service.category),\n }\n : undefined,\n area: service.area\n ? {\n id: service.area.id,\n name: service.area.name,\n slug: convertToSlug(service.area),\n }\n : undefined,\n slug: convertToSlug(service),\n serviceInfo: (service.serviceInfo || []).map(info => ({\n ...info,\n })).sort((a, b) => a.displayOrder - b.displayOrder),\n };\n}\n\nexport function formatImage (image: IServiceImage): IServiceImage {\n return {\n id: image.id,\n isCover: image.isCover,\n url: image.url,\n };\n}\n"],"names":["cfg0","defineAppConfig","inlineConfig","__appConfig","defuFn","useAppConfig","nuxtApp","useNuxtApp","reactive","getServices","areaId","categoryId","appConfig","response","useAPI","service","formatService","getServicesByAccountContextId","accountContextId","getService","serviceId","getServiceByAccountContextId","getPriceByAccountContextId","adults","children","sessionLength","promoCode","getPrice","getPriceByAreaId","code","images","image","formatImage","coverImage","convertToSlug","info","b"],"mappings":"kGAAA,MAAAA,EAAeC,EAAgB,CAC3B,YAAa,EACjB,CAAC,ECEKC,EAAe,CACnB,KAAQ,CAAA,CACV,EAWAC,EAA6BC,EAAOJ,EAAME,CAAY,ECc/C,SAASG,GAAe,CAC7B,MAAMC,EAAUC,EAAW,EACvB,OAACD,EAAQ,aACXA,EAAQ,WAAuDE,EAASL,CAAW,GAE9EG,EAAQ,UACjB,CC3BsB,eAAAG,EAAaC,EAAgBC,EAA0C,CACzF,MAAMC,EAAYP,EAAa,EAC3B,IAAAQ,EAEJ,OAAID,EAAU,YACCC,EAAA,MAAM,OAAO,6BAA6B,EAErDA,EAAW,MAAMC,EAA4B,YAAYJ,CAAM,aAAaC,CAAU,WAAY,CAC9F,OAAQ,OACT,EAAI,EAGJ,CACH,KAAME,EAAS,KAAK,IAAKE,GAA8BC,EAAcD,CAAO,CAAC,EAC7E,KAAMF,EAAS,IACnB,CACJ,CASsB,eAAAI,EAA+BC,EAA0BP,EAA0C,CACrH,MAAME,EAAW,MAAMC,EAA4B,uBAAuBI,CAAgB,aAAaP,CAAU,WAAY,CACzH,OAAQ,OACT,EAAI,EAEA,MAAA,CACH,KAAME,EAAS,KAAK,IAAKE,GAA8BC,EAAcD,CAAO,CAAC,EAC7E,KAAMF,EAAS,IACnB,CACJ,CAEsB,eAAAM,EAAYT,EAAgBU,EAAsC,CACpF,MAAMR,EAAYP,EAAa,EAC3B,IAAAQ,EAEJ,OAAID,EAAU,YACCC,EAAA,MAAM,OAAO,6BAA6B,EAErDA,EAAW,MAAMC,EAAkC,YAAYJ,CAAM,YAAYU,CAAS,GAAI,CAC1F,OAAQ,KAAA,CACX,EAGEJ,EAAcH,EAAS,IAAI,CACtC,CAEsB,eAAAQ,EAA8BH,EAA0BE,EAAsC,CAChH,MAAMP,EAAW,MAAMC,EAAkC,uBAAuBI,CAAgB,YAAYE,CAAS,GAA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