{"version":3,"file":"destinations-DDr-moiI.js","sources":["../../../../scripts/services/api/destinations.ts"],"sourcesContent":["import { DestinationsSearchResponse } from \"interfaces/responses/destination-responses\";\r\nimport { DestinationDetails } from \"interfaces/destination\";\r\nimport { getJSON } from \"services/api/request-manager\";\r\nimport { cobrandLink } from \"virtuoso-shared-web-ui\";\r\n\r\n/**\r\n * Calls the destination endpoint and returns an object with the name, child destinations and product tile info\r\n * @param destination\r\n */\r\nexport function getDestinationInfo(destination: string): Promise<DestinationDetails> {\r\n    // eslint-disable-next-line prefer-const -- although it's not reassigned, variable contents is changed below\r\n    let dest: DestinationDetails = {\r\n        advisorTile: undefined,\r\n        boundingBox: undefined,\r\n        childDestinations: [],\r\n        cruiseTile: undefined,\r\n        hotelTile: undefined,\r\n        name: \"\",\r\n        tourTile: undefined\r\n    };\r\n\r\n    return new Promise((resolve, reject) => {\r\n        getJSON(`/travel/api/search/destinations${destination}`).then((result: DestinationsSearchResponse) => {\r\n            if (result.titleDisplayName) {\r\n                dest.name = result.titleDisplayName;\r\n\r\n                // Content tiles\r\n                dest.advisorTile = {\r\n                    count: result.advisorTile.count,\r\n                    selectedFacets: result.advisorTile.selectedFacets\r\n                };\r\n                dest.cruiseTile = {\r\n                    count: result.cruiseTile.count,\r\n                    selectedFacets: result.cruiseTile.selectedFacets\r\n                };\r\n                dest.hotelTile = {\r\n                    count: result.propertyTile.count,\r\n                    selectedFacets: result.propertyTile.selectedFacets\r\n                };\r\n                dest.tourTile = {\r\n                    count: result.tourTile.count,\r\n                    selectedFacets: result.tourTile.selectedFacets\r\n                };\r\n\r\n                if (result.boundingBox) {\r\n                    dest.boundingBox = result.boundingBox;\r\n                }\r\n\r\n                if (result.featuredLocations) {\r\n                    // Child destinations, they are returned in weighted order so we don't need to re-sort them\r\n                    Object.keys(result.featuredLocations).forEach((childName: string) => {\r\n                        if (childName !== \"\") {\r\n                            dest.childDestinations.push({\r\n                                name: childName,\r\n                                url: cobrandLink(\"/travel\" + result.featuredLocations[childName].url)\r\n                            });\r\n                        }\r\n                    });\r\n                }\r\n\r\n                resolve(dest);\r\n            } else {\r\n                reject(Error(\"No destination displayName\"));\r\n            }\r\n\r\n        }).catch(() => {\r\n            console.error(\"Could not retrieve destination\");\r\n            reject(Error(\"Could not retrieve destination\"));\r\n        });\r\n\r\n    });\r\n\r\n}\r\n\r\n\r\n/**\r\n * Calls the destinationregion endpoint and returns an object with the name, child destinations and product tile info\r\n * @param destinationRegion\r\n */\r\nexport function getDestinationRegionInfo(destinationRegion: string): Promise<DestinationDetails> {\r\n    // eslint-disable-next-line prefer-const -- although it's not reassigned, variable contents is changed below\r\n    let dest: DestinationDetails = {\r\n        advisorTile: undefined,\r\n        boundingBox: undefined,\r\n        childDestinations: [],\r\n        cruiseTile: undefined,\r\n        hotelTile: undefined,\r\n        name: \"\",\r\n        tourTile: undefined\r\n    };\r\n\r\n    return new Promise((resolve, reject) => {\r\n        getJSON(`/travel/api/search/destinationRegion${destinationRegion}`).then((result: DestinationsSearchResponse) => {\r\n            if (result.titleDisplayName) {\r\n                dest.name = result.titleDisplayName;\r\n\r\n                // Content tiles\r\n                dest.advisorTile = {\r\n                    count: result.advisorTile.count,\r\n                    selectedFacets: result.advisorTile.selectedFacets\r\n                };\r\n                dest.cruiseTile = {\r\n                    count: result.cruiseTile.count,\r\n                    selectedFacets: result.cruiseTile.selectedFacets\r\n                };\r\n                dest.hotelTile = {\r\n                    count: result.propertyTile.count,\r\n                    selectedFacets: result.propertyTile.selectedFacets\r\n                };\r\n                dest.tourTile = {\r\n                    count: result.tourTile.count,\r\n                    selectedFacets: result.tourTile.selectedFacets\r\n                };\r\n\r\n                if (result.boundingBox) {\r\n                    dest.boundingBox = result.boundingBox;\r\n                }\r\n\r\n                if (result.featuredLocations) {\r\n                    // Child destinations, they are returned in weighted order so we don't need to re-sort them\r\n                    Object.keys(result.featuredLocations).forEach((childName: string) => {\r\n                        if (childName !== \"\") {\r\n                            dest.childDestinations.push({\r\n                                name: childName,\r\n                                url: cobrandLink(\"/travel\" + result.featuredLocations[childName].url)\r\n                            });\r\n                        }\r\n                    });\r\n                }\r\n\r\n                resolve(dest);\r\n            } else {\r\n                reject(Error(\"no destination region displayname\"));\r\n            }\r\n\r\n        }).catch(() => {\r\n            console.error(\"Could not retrieve destination\");\r\n            reject(Error(\"Could not retrieve destination\"));\r\n        });\r\n\r\n    });\r\n\r\n}"],"names":["getDestinationInfo","destination","dest","resolve","reject","getJSON","result","childName","cobrandLink","getDestinationRegionInfo","destinationRegion"],"mappings":"oDASO,SAASA,EAAmBC,EAAkD,CAEjF,IAAIC,EAA2B,CAC3B,YAAa,OACb,YAAa,OACb,kBAAmB,CAAC,EACpB,WAAY,OACZ,UAAW,OACX,KAAM,GACN,SAAU,MAAA,EAGd,OAAO,IAAI,QAAQ,CAACC,EAASC,IAAW,CACpCC,EAAQ,kCAAkCJ,CAAW,EAAE,EAAE,KAAMK,GAAuC,CAC9FA,EAAO,kBACPJ,EAAK,KAAOI,EAAO,iBAGnBJ,EAAK,YAAc,CACf,MAAOI,EAAO,YAAY,MAC1B,eAAgBA,EAAO,YAAY,cAAA,EAEvCJ,EAAK,WAAa,CACd,MAAOI,EAAO,WAAW,MACzB,eAAgBA,EAAO,WAAW,cAAA,EAEtCJ,EAAK,UAAY,CACb,MAAOI,EAAO,aAAa,MAC3B,eAAgBA,EAAO,aAAa,cAAA,EAExCJ,EAAK,SAAW,CACZ,MAAOI,EAAO,SAAS,MACvB,eAAgBA,EAAO,SAAS,cAAA,EAGhCA,EAAO,cACPJ,EAAK,YAAcI,EAAO,aAG1BA,EAAO,mBAEP,OAAO,KAAKA,EAAO,iBAAiB,EAAE,QAASC,GAAsB,CAC7DA,IAAc,IACdL,EAAK,kBAAkB,KAAK,CACxB,KAAMK,EACN,IAAKC,EAAY,UAAYF,EAAO,kBAAkBC,CAAS,EAAE,GAAG,CAAA,CACvE,CACL,CACH,EAGLJ,EAAQD,CAAI,GAELE,EAAA,MAAM,4BAA4B,CAAC,CA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