"use strict";function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _regeneratorRuntime(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_regeneratorRuntime=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",i=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,o){var a=t&&t.prototype instanceof p?t:p,i=Object.create(a.prototype),c=new I(o||[]);return n(i,"_invoke",{value:k(e,r,c)}),i}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var d={};function p(){}function h(){}function f(){}var m={};s(m,a,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(T([])));v&&v!==t&&r.call(v,a)&&(m=v);var g=f.prototype=p.prototype=Object.create(m);function b(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function o(n,a,i,c){var s=l(e[n],e,a);if("throw"!==s.type){var u=s.arg,d=u.value;return d&&"object"==_typeof(d)&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){o("next",e,i,c)}),(function(e){o("throw",e,i,c)})):t.resolve(d).then((function(e){u.value=e,i(u)}),(function(e){return o("throw",e,i,c)}))}c(s.arg)}var a;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){o(e,r,t,n)}))}return a=a?a.then(n,n):n()}})}function k(e,t,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return x()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=L(i,r);if(c){if(c===d)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=l(e,t,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===d)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}function L(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,L(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var o=l(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,d;var a=o.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function T(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:x}}function x(){return{value:void 0,done:!0}}return h.prototype=f,n(g,"constructor",{value:f,configurable:!0}),n(f,"constructor",{value:h,configurable:!0}),h.displayName=s(f,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,s(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),s(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new w(u(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),s(g,c,"Generator"),s(g,a,(function(){return this})),s(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=T,I.prototype={constructor:I,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,d):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},e}function asyncGeneratorStep(e,t,r,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void r(e)}c.done?t(s):Promise.resolve(s).then(n,o)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){asyncGeneratorStep(a,n,o,i,c,"next",e)}function c(e){asyncGeneratorStep(a,n,o,i,c,"throw",e)}i(void 0)}))}}var basketViewModel=function(e){var t={resources:ko.observable(e)};return t.ready=ko.observable(!1),t.busy=ko.observable(),t.basketItems=ko.observableArray([]),t.itemsInBasket=ko.observable(),t.promotionalMessage=ko.observable(),t.summaryMessage=ko.observable(),t.nextClickHandler=function(e){var r=document.querySelector("#basket-menu");r&&(e.target===r||r.contains(e.target)||(r.classList.remove("open"),document.body.removeEventListener("click",t.nextClickHandler)))},t.addToBasket=function(e,r){return new Promise((function(n,o){if(e.isValid()){e.enabled(!1),t.busy(!0);var a=r.currentTarget,i=JSON.stringify({productId:e.productId,quantity:e.quantity(),basketLineTypeId:e.basketLineTypeId,productPageId:ko.unwrap(e.productPageId),basketCountry:getSiteCountry(),priceListId:getPriceListId()});console.trace("calling addToBasket with",i),fetch("/api/basket/addToBasket",{method:"POST",headers:window.fetchHeaders,cache:"no-store",credentials:"same-origin",body:i}).then(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(r){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e.enabled(!0),t.next=3,window.handleFetchResponse(r,i);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()).then((function(r){if(console.trace("addToBasket returned",r),t.itemsInBasket(r.totalDisplayQuantity),a){a.parentElement.parentElement.querySelector(".basket-message")&&a.parentElement.parentElement.removeChild(a.parentElement.parentElement.querySelector(".basket-message"));var o=a.parentElement.parentElement.querySelector(".back-in-stock-wrapper");o&&a.parentElement.parentElement.removeChild(o),a.parentElement.parentElement.insertAdjacentHTML("beforeend",'<span class="basket-message">'.concat(r.basketLineText,"</span>")),o&&a.parentElement.parentElement.appendChild(o)}document.body.addEventListener("click",t.nextClickHandler),t.refreshBasket(),"function"==typeof window.gTagAddToCart&&window.gTagAddToCart(e,e.quantity()),"function"==typeof fbq&&fbq("track","AddToCart",{content_ids:[e.productId.toString()],content_type:"product",value:Number(r.price),currency:r.currency}),n()})).catch((function(e){t.busy(!1),window.catchFetchErrors(e),o()}))}else o()}))},t.refreshBasket=function(){if(!window.hasOwnProperty("quickOrderingViewModel")){t.busy(!0);var e=document.querySelector("#basket-menu");e&&e.classList.add("open")}fetch("/api/basket/refreshBasket",{method:"POST",headers:window.fetchHeaders,cache:"no-store",credentials:"same-origin",body:JSON.stringify(getMasterDefinition())}).then(window.handleFetchResponse).then((function(e){t.basketItems(e.basketItems),t.promotionalMessage(e.promotionalMessage),t.summaryMessage(e.summaryMessage),t.itemsInBasket(e.summaryTotal),t.busy(!1),window.hasOwnProperty("basketMaintenanceModel")&&window.basketMaintenanceModel.updateBasket(null,!0)})).catch((function(e){t.busy(!1),window.catchFetchErrors(e)}))},t.toggleScrapbook=function(e,r){console.trace(e,r);var n=r.currentTarget,o=JSON.stringify({imageId:e.ImageID,productPageId:e.ProductPageID,countryId:getCountryId(),languageId:getLanguageId()});fetch("/api/member/toggleScrapbook",{method:"POST",headers:window.fetchHeaders,cache:"no-store",credentials:"same-origin",body:o}).then(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,window.handleFetchResponse(t,o);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).then((function(e){console.trace("toggleScrapbook returned",e,n),t.scrapbookPopover(e.addition,n)})).catch(window.catchFetchErrors)},t.preventPop=function(e){e.preventDefault()},t.scrapbookPopover=function(e,r){r.removeEventListener("show.bs.popover",t.preventPop);var n=bootstrap.Popover.getInstance(r);(n&&n.dispose(),e)?(new bootstrap.Popover(r,{trigger:"focus",boundary:r.parentElement,container:r.parentElement,html:!0,placement:"bottom",content:document.querySelector("#add-to-scrapbook-content").innerHTML,template:document.querySelector("#toggle-scrapbook-template").innerHTML}).show(),r.addEventListener("show.bs.popover",t.preventPop),r.classList.add("transitioning"),setTimeout((function(){r.querySelector(".bi").classList.add("bi-bookmark-heart"),r.querySelector(".bi").classList.remove("bi-bookmark-plus")}),300),setTimeout((function(){r.classList.remove("transitioning")}),600)):(new bootstrap.Popover(r,{trigger:"focus",boundary:r.parentElement,container:r.parentElement,html:!0,placement:"bottom",content:document.querySelector("#removed-from-scrapbook-content").innerHTML,template:document.querySelector("#toggle-scrapbook-template").innerHTML}).show(),r.addEventListener("show.bs.popover",t.preventPop),r.classList.add("transitioning"),setTimeout((function(){r.querySelector(".bi").classList.remove("bi-bookmark-heart"),r.querySelector(".bi").classList.add("bi-bookmark-plus")}),300),setTimeout((function(){r.classList.remove("transitioning")}),600))},t.showBasketSummary=function(){var e=document.querySelector("#basket-menu");e&&(0==t.basketItems().length?t.refreshBasket():e.classList.add("open"))},t.hideBasketSummary=function(){var e=document.querySelector("#basket-menu");null!=e&&e.classList.remove("open")},t.backInStockReminder=function(e){var t;fetch("/api/member/createBackInStockReminder",{method:"POST",headers:window.fetchHeaders,cache:"no-store",credentials:"same-origin",body:JSON.stringify({productId:null!==(t=e.ProductID)&&void 0!==t?t:e.productId,countryId:getCountryId(),languageId:getLanguageId()})}).then(window.handleFetchResponse).then((function(e){e.success?window.showBackInStockSuccess():e.mustLogin?window.showBackInStockLogin():showError()})).catch(window.catchFetchErrors)},t};window.basketModel=basketViewModel(getPrefetchedResources()),document.querySelector("#navbar-basket")&&(ko.cleanNode(document.querySelector("#navbar-basket")),ko.applyBindings(window.basketModel,document.querySelector("#navbar-basket"))),document.querySelector("#basket-menu")&&(ko.cleanNode(document.querySelector("#basket-menu")),ko.applyBindings(window.basketModel,document.querySelector("#basket-menu"))),document.querySelector("#basket-menu-item")&&(ko.cleanNode(document.querySelector("#basket-menu-item")),ko.applyBindings(window.basketModel,document.querySelector("#basket-menu-item"))),"function"==typeof window.onBasketLoad&&window.onBasketLoad();
///*# sourceMappingURL=https://www.designersguild.com/js/dist/models/common/basket.min.js.map */
;
"use strict";var searchBoxViewModel=function(e,r){var t={};return t.busy=ko.observable(!1),t.holdBusy=ko.observable(!1),t.availableProductTypes=ko.observableArray([]),t.productType=ko.observable(r),t.searchTerm=ko.observable(e).extend({rateLimit:{method:"notifyWhenChangesStop",timeout:300}}),t.productSearchForm=document.querySelector("#product-search-form"),t.productSearchInput=document.querySelector("#product-search-control"),t.productSearchInput.addEventListener("click",(function(e){e.stopPropagation()})),t.productSearchContentElement=document.querySelector("#product-search-content"),t.dropdownToggleElement=document.querySelector("#predictive-search-hints"),t.productSearchFormElement=document.querySelector("#product-search-form"),t.logoSearchContainerElement=document.querySelector("#logo-search-container"),t.dropdownElement=document.querySelector("#predictive-search-hints-dropdown"),t.dropdownToggleElement.addEventListener("hide.bs.dropdown",(function(){t.productSearchFormElement.classList.remove("predicting"),t.logoSearchContainerElement&&t.logoSearchContainerElement.classList.remove("predicting")}),!1),t.dropdownToggleElement.addEventListener("show.bs.dropdown",(function(){window.lazyImages()}),!1),t.predictiveSearchProductTypes=ko.observableArray([]),t.predictiveSearchBrands=ko.observableArray([]),t.predictiveSearchCollections=ko.observableArray([]),t.predictiveSearchDesigns=ko.observableArray([]),t.predictiveSearchDiscontinueds=ko.observableArray([]),t.predictiveSearchProducts=ko.observableArray([]),t.predictiveSearchResults=ko.observableArray([]),t.busy.subscribe((function(e){console.log("search.js busy subscribe hit",e),e?(t.productSearchForm.classList.add("busy"),t.productSearchContentElement.classList.add("busy")):(t.productSearchForm.classList.remove("busy"),t.productSearchContentElement.classList.remove("busy"))})),t.showDropdown=function(){t.productSearchFormElement.classList.add("open"),t.productSearchFormElement.classList.add("predicting"),t.logoSearchContainerElement&&t.logoSearchContainerElement.classList.add("predicting"),bootstrap.Dropdown.getOrCreateInstance(t.dropdownToggleElement).show(),window.lazyImages()},t.hideDropdown=function(){t.productSearchFormElement.classList.remove("open"),t.productSearchFormElement.classList.remove("predicting"),t.logoSearchContainerElement&&t.logoSearchContainerElement.classList.remove("predicting"),bootstrap.Dropdown.getOrCreateInstance(t.dropdownToggleElement).hide()},t.productType.subscribe((function(e){console.log("search.js productType subscribe hit",e),e&&76==window.getContentId()&&window.elementPercentInViewport(document.querySelector("#search-overlay"))>0&&document.querySelector("#product-search-control").focus()})),t.searchTerm.subscribe((function(e){t.holdBusy()||e&&e.length>3&&(t.busy(!0),fetch("/api/search/getPredictiveSearch",{method:"POST",headers:window.fetchHeaders,cache:"no-store",credentials:"same-origin",body:JSON.stringify({productType:t.productType(),searchTerm:t.searchTerm(),siteCountry:getSiteCountry(),countryId:getCountryId(),languageId:getLanguageId()})}).then(window.handleFetchResponse).then((function(e){e.error||(t.predictiveSearchResults(e.predictiveSearchResults.results),t.predictiveSearchProductTypes(e.predictiveSearchHints.productTypes),t.predictiveSearchBrands(e.predictiveSearchHints.brands),t.predictiveSearchCollections(e.predictiveSearchHints.collections),t.predictiveSearchDesigns(e.predictiveSearchHints.designs),t.predictiveSearchDiscontinueds(e.predictiveSearchHints.discontinueds),t.predictiveSearchProducts(e.predictiveSearchHints.products),t.anyPredictiveHints()&&(t.showDropdown(),t.productSearchContentElement.classList.add("open"))),t.holdBusy()||t.busy(!1)})).catch((function(e){t.holdBusy()||t.busy(!1),window.catchFetchErrors(e)})))})),t.brandsIndexOffset=ko.computed((function(){return t.predictiveSearchProductTypes().length}),t),t.collectionsIndexOffset=ko.computed((function(){return t.brandsIndexOffset()+t.predictiveSearchBrands().length}),t),t.designsIndexOffset=ko.computed((function(){return t.collectionsIndexOffset()+t.predictiveSearchCollections().length}),t),t.resultsIndexOffset=ko.computed((function(){return t.designsIndexOffset()+t.predictiveSearchDesigns().length}),t),t.productsIndexOffset=ko.computed((function(){return t.resultsIndexOffset()+t.predictiveSearchResults().length}),t),t.anyPredictiveHints=function(){return t.predictiveSearchResults().length>0||t.predictiveSearchProductTypes().length>0||t.predictiveSearchBrands().length>0||t.predictiveSearchCollections().length>0||t.predictiveSearchDesigns().length>0||t.predictiveSearchDiscontinueds().length>0||t.predictiveSearchProducts().length>0},t.clearPredictiveResults=function(){t.predictiveSearchResults([]),t.predictiveSearchProductTypes([]),t.predictiveSearchBrands([]),t.predictiveSearchCollections([]),t.predictiveSearchDesigns([]),t.predictiveSearchDiscontinueds([]),t.predictiveSearchProducts([])},t.focusFirstDropdownItem=function(){if(t.anyPredictiveHints()){t.showDropdown();var e=t.dropdownElement.querySelector("ul:first-of-type li:first-child a");e&&e.focus()}},t.useResult=function(e){t.formSubmit(),document.querySelector("#product-search-control").value=e.Keyword,t.searchTerm(e.Keyword),window.setTimeout((function(){t.submit()}),0)},t.submit=function(){if(""===t.productType()&&!t.searchTerm())return t.searchTerm.DOMElement.classList.remove("shake"),window.setTimeout((function(){t.searchTerm.DOMElement.classList.add("shake"),window.setTimeout((function(){t.searchTerm.DOMElement.classList.remove("shake")}),300)}),0),!1;document.querySelector("#product-search-form").submit()},t.formSubmit=function(e,r){return""!==t.productType()||t.searchTerm()?(t.busy(!0),t.holdBusy(!0),!0):(t.searchTerm.DOMElement.classList.remove("shake"),window.setTimeout((function(){t.searchTerm.DOMElement.classList.add("shake"),window.setTimeout((function(){t.searchTerm.DOMElement.classList.remove("shake")}),300)}),0),!1)},t};if(document.querySelector("#product-search-content")){window.searchBoxModel=searchBoxViewModel("function"==typeof window.getSearchTerm?window.getSearchTerm():void 0,"function"==typeof window.getProductType?window.getProductType():void 0),ko.applyBindings(window.searchBoxModel,document.querySelector("#product-search-content")),ko.applyBindings(window.searchBoxModel,document.querySelector("#predictive-search-hints-dropdown"));var ready=new Event("searchBoxReady");document.querySelector("body").dispatchEvent(ready)}
///*# sourceMappingURL=https://www.designersguild.com/js/dist/models/common/search.min.js.map */
;
