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cA,cAAcC,UAAUC,OAAO,wBAC1DN,EAAaI,cAAcA,cAAcC,UAAUC,OAAO,aAC1DN,EAAaI,cAAcC,UAAUC,OAAO,UAC3BN,EAAaI,cAAcA,cAAcG,SAAS,GACxDF,UAAUC,OAAO,SAChC,CACA,MAAOE,GACHC,QAAQC,IAAIF,EAChB,CACJ,MA1BIxC,EAAM2C,aA2Bd,IACKC,OAAM,SAAUC,GACjBJ,QAAQI,MAAMA,GACd7C,EAAM2C,aACV,GAER,MAEI5D,KAAK4D,aAEb,EACA9D,EAAee,UAAU+C,YAAc,WAEnC,IAAIX,EAAejD,KAAKkB,KAAKE,cAAc,iBAC3C6B,EAAaI,cAAcC,UAAUC,OAAO,mBAC5CN,EAAaI,cAAcC,UAAUS,IAAI,kBACzCd,EAAaM,QACjB,EAEOzD,CACX,CAhKmC,GAkKnC,W","sources":["webpack:///./modules/drr-card/index.ts"],"sourcesContent":["var DrrCardHandler = /** @class */ (function () {\n function DrrCardHandler(props) {\n this.items = [];\n this.hwtCardId = props.hwtCardId;\n this.locationId = props.locationId;\n this.locationType = props.locationType;\n this.departureDate = props.departureDate;\n this.departureDateType = props.departureDateType;\n this.departurePoints = props.departurePoints;\n this.boards = props.boards;\n this.ratings = props.ratings;\n this.duration = props.duration;\n this.price = props.price;\n this.init();\n }\n DrrCardHandler.prototype.init = function () {\n var _this = this;\n var _a;\n var locationString;\n var tripType;\n this.card = document.querySelector(\"#\".concat(this.hwtCardId));\n switch (this.locationType) {\n case \"Destination\":\n locationString = \"destinations\";\n tripType = \"0\";\n break;\n case \"Region\":\n locationString = \"regions\";\n tripType = \"0\";\n break;\n case \"Resort\":\n locationString = \"resorts\";\n tripType = \"0\";\n break;\n case \"Accommodation\":\n locationString = \"accommodation_id\";\n tripType = \"0\";\n break;\n case \"City Destination\":\n locationString = \"destinations\";\n tripType = \"1\";\n break;\n case \"City Region\":\n locationString = \"regions\";\n tripType = \"1\";\n break;\n case \"City Resort\":\n locationString = \"resorts\";\n tripType = \"1\";\n break;\n case \"City Accommodation\":\n locationString = \"accommodation_id\";\n tripType = \"1\";\n break;\n default:\n locationString = \"\";\n break;\n }\n var myHeaders = new Headers();\n myHeaders.append(\"Content-Type\", \"application/json\");\n var requestOptions = {\n method: \"GET\",\n headers: myHeaders,\n };\n // create querystring base with mandatory filters\n if (this.locationId) {\n var queryString = new URLSearchParams({\n \"locationType\": locationString,\n \"locationID\": (_a = this.locationId) === null || _a === void 0 ? void 0 : _a.toString()\n });\n // if filters have been given values, append their respective query to the querystring\n if (this.departureDate != \"unset\") {\n queryString.append(\"departureDate\", this.departureDate);\n }\n if (this.departureDateType != \"unset\") {\n queryString.append(\"departureDateType\", this.departureDateType);\n }\n // cast departurePoints to an array, iterate through array to create query for querystring\n if (this.departurePoints != \"unset\" && this.departurePoints != undefined) {\n var departurePoints = this.departurePoints.split(\",\");\n var count_1 = 0;\n var points_1 = \"\";\n departurePoints.forEach(function (point) {\n points_1 += \"\".concat(count_1 > 0 ? \",\" : \"\", \"\\\\\\\"\").concat(point, \"\\\\\\\"\");\n count_1++;\n });\n queryString.append(\"departurePoints\", \"[\".concat(points_1, \"]\"));\n }\n if (this.boards != \"unset\") {\n queryString.append(\"boards\", this.boards);\n }\n if (this.ratings != \"unset\") {\n queryString.append(\"ratings\", this.ratings);\n }\n if (this.duration != \"unset\") {\n queryString.append(\"duration\", this.duration);\n }\n if (typeof tripType != 'undefined' && tripType != null) {\n queryString.append(\"tripType\", tripType);\n }\n else {\n queryString.append(\"tripType\", \"0\");\n }\n // Add a check from the client side to stop any requests with missing data hitting the server\n if (locationString && tripType) {\n // get offers by using our own intermediatary API route to hide our API key.\n fetch(\"/umbraco/api/hwt/getprice?\".concat(queryString.toString()), requestOptions)\n .then(function (response) { return response.text(); })\n .then(function (result) {\n // Get the result of the GraphQL query\n var jsonResult = JSON.parse(result)[\"data\"][\"offers\"][\"result\"];\n // remove carousel if no results\n if (!jsonResult[0][\"price_per_person\"] || _this.locationId == undefined || _this.locationId == null) {\n _this.removePrice();\n }\n else {\n // Create list of indexes to remove from the carousel - this means only having to call \"remove()\" once\n var indexesToRemove = [];\n if (jsonResult.length < _this.items.length) {\n for (var i = jsonResult.length; i < _this.items.length; i++) {\n indexesToRemove.push(i);\n }\n }\n try {\n ///////////////////////////////////////\n // REPLACE SKELETON WITH API CONTENT //\n ///////////////////////////////////////\n // get and populate price element\n var priceElement = _this.card.querySelector('#cardPrice');\n priceElement.innerText = \"\".concat(Math.round(jsonResult[0][\"price_per_person\"]));\n priceElement.parentElement.parentElement.classList.remove(\"skeleton-pulse-price\");\n priceElement.parentElement.parentElement.classList.remove(\"flex-grow\");\n priceElement.parentElement.classList.remove(\"hidden\");\n var sisterText = priceElement.parentElement.parentElement.children[0];\n sisterText.classList.remove(\"hidden\");\n }\n catch (e) {\n console.log(e);\n }\n }\n })\n .catch(function (error) {\n console.error(error);\n _this.removePrice();\n });\n }\n }\n else {\n this.removePrice();\n }\n };\n DrrCardHandler.prototype.removePrice = function () {\n // get and populate price element\n var priceElement = this.card.querySelector('#priceElement');\n priceElement.parentElement.classList.remove(\"justify-between\");\n priceElement.parentElement.classList.add(\"justify-center\");\n priceElement.remove();\n };\n ;\n return DrrCardHandler;\n}());\nexport { DrrCardHandler };\nexport default DrrCardHandler;\n"],"names":["DrrCardHandler","props","this","items","hwtCardId","locationId","locationType","departureDate","departureDateType","departurePoints","boards","ratings","duration","price","init","prototype","_a","locationString","tripType","_this","card","document","querySelector","concat","myHeaders","Headers","append","requestOptions","method","headers","queryString","URLSearchParams","toString","undefined","split","count_1","points_1","forEach","point","fetch","then","response","text","result","jsonResult","JSON","parse","indexesToRemove","length","i","push","priceElement","innerText","Math","round","parentElement","classList","remove","children","e","console","log","removePrice","catch","error","add"],"sourceRoot":""}