var __awaiter=this&&this.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r["throw"](e))}catch(e){o(e)}}function c(e){e.done?n(e.value):i(e.value).then(a,s)}c((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(t){return c([e,t])}}function c(a){if(r)throw new TypeError("Generator is already executing.");while(n)try{if(r=1,i&&(o=a[0]&2?i["return"]:a[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;i=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1];o=a;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(a);break}if(o[2])n.ops.pop();n.trys.pop();continue}a=t.call(e,n)}catch(e){a=[6,e];i=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,h,H as Host}from"./index-67f7ec52.js";import{b as fromNullable,n as none,c as isSome,s as some}from"./index-6869168f.js";import{b as benefitsApi}from"./benefits.api-806ca0bc.js";import{b as benefitsEventTrackingService}from"./event-tracking.service-8d44e7ac.js";import"./api-client-a68152b8.js";import"./index-8f0ba0c8.js";import"./datorama-akita-d2413fd0.js";import"./scheduleArray-b9669898.js";import"./delay-d08c267f.js";import"./filter-aeb65cac.js";var BenefitsService=function(){function e(){}e.prototype.getViewPageState=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,benefitsApi.getBenefitsAsync()]}))}))};e.prototype.getShopifyUrl=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:e=fromNullable;return[4,benefitsApi.getShopifyUrl()];case 1:return[2,e.apply(void 0,[t.sent().redirectUrl])]}}))}))};return e}();var benefitsService=new BenefitsService;var BenefitsPage=function(){function e(e){registerInstance(this,e);this.shopifyUrl=none;this.urlRefreshHandle=none}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:e=this;return[4,benefitsService.getViewPageState()];case 1:e.state=t.sent();return[2]}}))}))};e.prototype.componentDidLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:e=this;return[4,benefitsService.getShopifyUrl()];case 1:e.shopifyUrl=t.sent();this.setupShopifyUrlRefresh();return[4,benefitsEventTrackingService.trackPageViewedAsync({pageId:"viewBenefits"})];case 2:t.sent();return[2]}}))}))};e.prototype.disconnectedCallback=function(){if(isSome(this.urlRefreshHandle)){window.clearInterval(this.urlRefreshHandle.value)}};e.prototype.render=function(){return h(Host,{class:"w-100 mb-4"},h("ap-ben-ui-container",{class:"mt-4 d-none"},h("div",{class:"row"},h("div",{class:"col-12"},h("ap-ben-hero-banner",{shopifyUrl:this.shopifyUrl}))),h("div",{class:"row"},h("div",{class:"col-12"},h("ap-ben-promoted-benefits",{benefits:this.state.promotedBenefits}))),h("div",{class:"row"},h("div",{class:"col-12"},h("ap-ben-benefits-list",{benefits:this.state.availableBenefits})))))};e.prototype.setupShopifyUrlRefresh=function(){var e=this;var t=2*60*1e3;this.urlRefreshHandle=some(window.setInterval((function(){return __awaiter(e,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:e=this;return[4,benefitsService.getShopifyUrl()];case 1:e.shopifyUrl=t.sent();return[2]}}))}))}),t))};return e}();export{BenefitsPage as ap_ben_benefits_page};