@ikas/bp-storefront 2.9.1 → 2.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/analytics/analytics-functions/addToCart.js +1 -1
  2. package/dist/analytics/analytics-functions/completeRegistration.js +1 -1
  3. package/dist/analytics/analytics-functions/contactForm.js +1 -1
  4. package/dist/analytics/analytics-functions/createEmailSubscription.js +1 -1
  5. package/dist/analytics/analytics-functions/customerLogin.js +1 -1
  6. package/dist/analytics/analytics-functions/pageView.js +1 -1
  7. package/dist/analytics/analytics-functions/productView.js +1 -1
  8. package/dist/analytics/ikas/analytics.js +1 -1
  9. package/dist/analytics/openai/addToCart.d.ts +2 -0
  10. package/dist/analytics/openai/addToCart.js +1 -0
  11. package/dist/analytics/openai/completeRegistration.d.ts +1 -0
  12. package/dist/analytics/openai/completeRegistration.js +1 -0
  13. package/dist/analytics/openai/contactForm.d.ts +1 -0
  14. package/dist/analytics/openai/contactForm.js +1 -0
  15. package/dist/analytics/openai/initAdvancedMatching.d.ts +12 -0
  16. package/dist/analytics/openai/initAdvancedMatching.js +1 -0
  17. package/dist/analytics/openai/pageView.d.ts +1 -0
  18. package/dist/analytics/openai/pageView.js +1 -0
  19. package/dist/analytics/openai/productView.d.ts +2 -0
  20. package/dist/analytics/openai/productView.js +1 -0
  21. package/dist/analytics/openai/utils.d.ts +26 -0
  22. package/dist/analytics/openai/utils.js +1 -0
  23. package/dist/analytics/utils.d.ts +1 -0
  24. package/dist/analytics/utils.js +1 -1
  25. package/dist/functions/models/product-list/index.js +1 -1
  26. package/dist/functions/stores/cart/index.js +1 -1
  27. package/dist/storefront-config/src/index.d.ts +2 -0
  28. package/dist/storefront-models/src/models/storefront/index.d.ts +1 -0
  29. package/dist/utils/helper.d.ts +1 -0
  30. package/dist/utils/helper.js +1 -1
  31. package/package.json +1 -1
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as a}from'./../../ext/tslib/tslib.es6.mjs.js';import{notifySubscribers as e}from"../events.js";import{hasTiktokPixel as r,hasGoogleAnalytics as s,hasGoogleTagManager as o,canTrack as n,hasFacebookPixel as i}from"../utils.js";function d(d,c,l,u,m){return t(this,void 0,void 0,function(){var t;return a(this,function(a){switch(a.label){case 0:return a.trys.push([0,11,,12]),n()?(e({type:"ADD_TO_CART",data:{item:d,quantity:c,cart:u}}),i()?[4,import("../facebook/addToCart.js")]:[3,2]):[2];case 1:(0,a.sent().fbp_addToCart)(d,l),a.label=2;case 2:return o()?[4,import("../google-tag-manager/addToCart.js")]:[3,4];case 3:(0,a.sent().gtm_addToCart)(d,c,m),a.label=4;case 4:return[4,import("../ikas/analytics.js")];case 5:return[4,(0,a.sent().iks_addToCart)(d,u,l)];case 6:return a.sent(),s()?[4,import("../google-analytics/addToCart.js")]:[3,8];case 7:(0,a.sent().ga_addToCart)(d,c),a.label=8;case 8:return r()?[4,import("../tiktok/addToCart.js")]:[3,10];case 9:(0,a.sent().tik_addToCart)(d,c),a.label=10;case 10:return[3,12];case 11:return t=a.sent(),console.error(t),[3,12];case 12:return[2]}})})}export{d as anl_addToCart};
1
+ import{__awaiter as t,__generator as a}from'./../../ext/tslib/tslib.es6.mjs.js';import{notifySubscribers as e}from"../events.js";import{hasOpenAiPixel as r,hasTiktokPixel as s,hasGoogleAnalytics as o,hasGoogleTagManager as n,canTrack as i,hasFacebookPixel as d}from"../utils.js";function c(c,l,u,m,p){return t(this,void 0,void 0,function(){var t;return a(this,function(a){switch(a.label){case 0:return a.trys.push([0,13,,14]),i()?(e({type:"ADD_TO_CART",data:{item:c,quantity:l,cart:m}}),d()?[4,import("../facebook/addToCart.js")]:[3,2]):[2];case 1:(0,a.sent().fbp_addToCart)(c,u),a.label=2;case 2:return n()?[4,import("../google-tag-manager/addToCart.js")]:[3,4];case 3:(0,a.sent().gtm_addToCart)(c,l,p),a.label=4;case 4:return[4,import("../ikas/analytics.js")];case 5:return[4,(0,a.sent().iks_addToCart)(c,m,u)];case 6:return a.sent(),o()?[4,import("../google-analytics/addToCart.js")]:[3,8];case 7:(0,a.sent().ga_addToCart)(c,l),a.label=8;case 8:return s()?[4,import("../tiktok/addToCart.js")]:[3,10];case 9:(0,a.sent().tik_addToCart)(c,l),a.label=10;case 10:return r()?[4,import("../openai/addToCart.js")]:[3,12];case 11:(0,a.sent().oai_addToCart)(c,l,u),a.label=12;case 12:return[3,14];case 13:return t=a.sent(),console.error(t),[3,14];case 14:return[2]}})})}export{c as anl_addToCart};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign as s}from'./../../ext/tslib/tslib.es6.mjs.js';import{notifySubscribers as i}from"../events.js";import{hasTiktokPixel as a,hasGoogleTagManager as r,hasFacebookPixel as n,canTrack as o}from"../utils.js";function c(c,m){return t(this,void 0,void 0,function(){var t,l;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,11,,12]),o()?(i({type:"CUSTOMER_REGISTER",data:s({email:c.email,firstName:c.firstName,lastName:c.lastName,notificationsAccepted:c.subscriptionStatus},m?{attributes:c.attributes}:{})}),n()?[4,import("../facebook/initAdvancedMatching.js")]:[3,2]):[2];case 1:(0,e.sent().fbp_initAdvancedMatching)({em:c.email,fn:c.firstName,ln:c.lastName,ph:c.phone,external_id:c.id}),e.label=2;case 2:return t=Date.now().toString(),m?[3,8]:n()?[4,import("../facebook/completeRegistration.js")]:[3,4];case 3:(0,e.sent().fbp_completeRegistration)(t),e.label=4;case 4:return r()?[4,import("../google-tag-manager/completeRegistration.js")]:[3,6];case 5:(0,e.sent().gtm_completeRegistration)(c),e.label=6;case 6:return a()?[4,import("../tiktok/completeRegistration.js")]:[3,8];case 7:(0,e.sent().tik_completeRegistration)(),e.label=8;case 8:return[4,import("../ikas/analytics.js")];case 9:return[4,(0,e.sent().iks_customerRegister)(t)];case 10:return e.sent(),[3,12];case 11:return l=e.sent(),console.error(l),[3,12];case 12:return[2]}})})}export{c as anl_completeRegistration};
1
+ import{__awaiter as e,__generator as t,__assign as i}from'./../../ext/tslib/tslib.es6.mjs.js';import{notifySubscribers as s}from"../events.js";import{hasOpenAiPixel as a,hasTiktokPixel as n,hasGoogleTagManager as r,hasFacebookPixel as o,canTrack as c}from"../utils.js";function l(l,m){return e(this,void 0,void 0,function(){var e,p,u;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,15,,16]),c()?(s({type:"CUSTOMER_REGISTER",data:i({email:l.email,firstName:l.firstName,lastName:l.lastName,notificationsAccepted:l.subscriptionStatus},m?{attributes:l.attributes}:{})}),e={em:l.email,fn:l.firstName,ln:l.lastName,ph:l.phone,external_id:l.id},o()?[4,import("../facebook/initAdvancedMatching.js")]:[3,2]):[2];case 1:(0,t.sent().fbp_initAdvancedMatching)(e),t.label=2;case 2:return a()?[4,import("../openai/initAdvancedMatching.js")]:[3,4];case 3:(0,t.sent().oai_initAdvancedMatching)(e),t.label=4;case 4:return p=Date.now().toString(),m?[3,12]:o()?[4,import("../facebook/completeRegistration.js")]:[3,6];case 5:(0,t.sent().fbp_completeRegistration)(p),t.label=6;case 6:return r()?[4,import("../google-tag-manager/completeRegistration.js")]:[3,8];case 7:(0,t.sent().gtm_completeRegistration)(l),t.label=8;case 8:return n()?[4,import("../tiktok/completeRegistration.js")]:[3,10];case 9:(0,t.sent().tik_completeRegistration)(),t.label=10;case 10:return a()?[4,import("../openai/completeRegistration.js")]:[3,12];case 11:(0,t.sent().oai_completeRegistration)(p),t.label=12;case 12:return[4,import("../ikas/analytics.js")];case 13:return[4,(0,t.sent().iks_customerRegister)(p)];case 14:return t.sent(),[3,16];case 15:return u=t.sent(),console.error(u),[3,16];case 16:return[2]}})})}export{l as anl_completeRegistration};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as r}from'./../../ext/tslib/tslib.es6.mjs.js';import{notifySubscribers as e}from"../events.js";import{hasTiktokPixel as o,canTrack as s,hasFacebookPixel as n}from"../utils.js";function c(c){return t(this,void 0,void 0,function(){var t,a;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,7,,8]),s()?(t=Date.now().toString(),e({type:"CONTACT_FORM",data:{form:c}}),n()?[4,import("../facebook/contactForm.js")]:[3,2]):[2];case 1:(0,r.sent().fbp_contactForm)(t),r.label=2;case 2:return o()?[4,import("../tiktok/contactForm.js")]:[3,4];case 3:(0,r.sent().tik_contactForm)(),r.label=4;case 4:return[4,import("../ikas/analytics.js")];case 5:return[4,(0,r.sent().iks_contactForm)(t)];case 6:return r.sent(),[3,8];case 7:return a=r.sent(),console.error(a),[3,8];case 8:return[2]}})})}export{c as anl_contactForm};
1
+ import{__awaiter as t,__generator as r}from'./../../ext/tslib/tslib.es6.mjs.js';import{notifySubscribers as e}from"../events.js";import{hasOpenAiPixel as o,hasTiktokPixel as s,canTrack as n,hasFacebookPixel as a}from"../utils.js";function c(c){return t(this,void 0,void 0,function(){var t,i;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,9,,10]),n()?(t=Date.now().toString(),e({type:"CONTACT_FORM",data:{form:c}}),a()?[4,import("../facebook/contactForm.js")]:[3,2]):[2];case 1:(0,r.sent().fbp_contactForm)(t),r.label=2;case 2:return s()?[4,import("../tiktok/contactForm.js")]:[3,4];case 3:(0,r.sent().tik_contactForm)(),r.label=4;case 4:return o()?[4,import("../openai/contactForm.js")]:[3,6];case 5:(0,r.sent().oai_contactForm)(t),r.label=6;case 6:return[4,import("../ikas/analytics.js")];case 7:return[4,(0,r.sent().iks_contactForm)(t)];case 8:return r.sent(),[3,10];case 9:return i=r.sent(),console.error(i),[3,10];case 10:return[2]}})})}export{c as anl_contactForm};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.mjs.js';import{notifySubscribers as r}from"../events.js";import{canTrack as s,hasFacebookPixel as n}from"../utils.js";function i(i){return t(this,void 0,void 0,function(){var t;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),s()?(r({type:"EMAIL_SUBSCRIPTION",data:{email:i}}),n()?[4,import("../facebook/initAdvancedMatching.js")]:[3,2]):[2];case 1:(0,e.sent().fbp_initAdvancedMatching)({em:i}),e.label=2;case 2:return[3,4];case 3:return t=e.sent(),console.error(t),[3,4];case 4:return[2]}})})}export{i as anl_createEmailSubscription};
1
+ import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.mjs.js';import{notifySubscribers as n}from"../events.js";import{hasOpenAiPixel as i,canTrack as r,hasFacebookPixel as s}from"../utils.js";function a(a){return e(this,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,5,,6]),r()?(n({type:"EMAIL_SUBSCRIPTION",data:{email:a}}),s()?[4,import("../facebook/initAdvancedMatching.js")]:[3,2]):[2];case 1:(0,t.sent().fbp_initAdvancedMatching)({em:a}),t.label=2;case 2:return i()?[4,import("../openai/initAdvancedMatching.js")]:[3,4];case 3:(0,t.sent().oai_initAdvancedMatching)({em:a}),t.label=4;case 4:return[3,6];case 5:return e=t.sent(),console.error(e),[3,6];case 6:return[2]}})})}export{a as anl_createEmailSubscription};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.mjs.js';import{notifySubscribers as s}from"../events.js";import{hasGoogleTagManager as r,hasFacebookPixel as n,canTrack as i}from"../utils.js";import{getCustomerInfo as o}from"./helpers.js";function a(){return e(this,void 0,void 0,function(){var e,a;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,8,,9]),i()?[4,o()]:[2];case 1:return(e=t.sent())&&e.email?(s({type:"CUSTOMER_LOGIN",data:{customer:e}}),n()?[4,import("../facebook/initAdvancedMatching.js")]:[3,3]):[2];case 2:(0,t.sent().fbp_initAdvancedMatching)({em:e.email,fn:e.firstName,ln:e.lastName,ph:e.phone,external_id:e.id}),t.label=3;case 3:return r()?[4,import("../google-tag-manager/customerLogin.js")]:[3,5];case 4:(0,t.sent().gtm_customerLogin)(e),t.label=5;case 5:return[4,import("../ikas/analytics.js")];case 6:return[4,(0,t.sent().iks_customerLogin)()];case 7:return t.sent(),[3,9];case 8:return a=t.sent(),console.error(a),[3,9];case 9:return[2]}})})}export{a as anl_customerLogin};
1
+ import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.mjs.js';import{notifySubscribers as s}from"../events.js";import{hasGoogleTagManager as n,hasOpenAiPixel as r,hasFacebookPixel as i,canTrack as a}from"../utils.js";import{getCustomerInfo as o}from"./helpers.js";function c(){return e(this,void 0,void 0,function(){var e,c,m;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,10,,11]),a()?[4,o()]:[2];case 1:return(e=t.sent())&&e.email?(s({type:"CUSTOMER_LOGIN",data:{customer:e}}),c={em:e.email,fn:e.firstName,ln:e.lastName,ph:e.phone,external_id:e.id},i()?[4,import("../facebook/initAdvancedMatching.js")]:[3,3]):[2];case 2:(0,t.sent().fbp_initAdvancedMatching)(c),t.label=3;case 3:return r()?[4,import("../openai/initAdvancedMatching.js")]:[3,5];case 4:(0,t.sent().oai_initAdvancedMatching)(c),t.label=5;case 5:return n()?[4,import("../google-tag-manager/customerLogin.js")]:[3,7];case 6:(0,t.sent().gtm_customerLogin)(e),t.label=7;case 7:return[4,import("../ikas/analytics.js")];case 8:return[4,(0,t.sent().iks_customerLogin)()];case 9:return t.sent(),[3,11];case 10:return m=t.sent(),console.error(m),[3,11];case 11:return[2]}})})}export{c as anl_customerLogin};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.mjs.js';import{notifySubscribers as s}from"../events.js";import{hasTiktokPixel as r,hasFacebookPixel as a,hasGoogleTagManager as n,canTrack as i}from"../utils.js";import{getCustomerInfo as o}from"./helpers.js";function c(c){return e(this,void 0,void 0,function(){var e,p,u,l;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,12,,13]),i()?[4,import("../ikas/analytics.js")]:[2];case 1:return[4,(0,t.sent().iks_checkJourneyId)()];case 2:return t.sent(),e=window.location.href,[4,o()];case 3:return p=t.sent(),u=Date.now().toString(),s({type:"PAGE_VIEW",data:{url:e,pageType:c,customer:p}}),n()?[4,import("../google-tag-manager/pageView.js")]:[3,5];case 4:(0,t.sent().gtm_pageView)(e),t.label=5;case 5:return a()?[4,import("../facebook/pageView.js")]:[3,7];case 6:(0,t.sent().fbp_pageView)(u),t.label=7;case 7:return[4,import("../ikas/analytics.js")];case 8:return[4,(0,t.sent().iks_pageView)(c,u)];case 9:return t.sent(),r()?[4,import("../tiktok/pageView.js")]:[3,11];case 10:(0,t.sent().tik_pageView)(e),t.label=11;case 11:return[3,13];case 12:return l=t.sent(),console.error(l),[3,13];case 13:return[2]}})})}export{c as anl_pageView};
1
+ import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.mjs.js';import{notifySubscribers as s}from"../events.js";import{hasOpenAiPixel as r,hasTiktokPixel as a,hasFacebookPixel as i,hasGoogleTagManager as n,canTrack as o}from"../utils.js";import{getCustomerInfo as c}from"./helpers.js";function p(p){return e(this,void 0,void 0,function(){var e,u,l,m;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,14,,15]),o()?[4,import("../ikas/analytics.js")]:[2];case 1:return[4,(0,t.sent().iks_checkJourneyId)()];case 2:return t.sent(),e=window.location.href,[4,c()];case 3:return u=t.sent(),l=Date.now().toString(),s({type:"PAGE_VIEW",data:{url:e,pageType:p,customer:u}}),n()?[4,import("../google-tag-manager/pageView.js")]:[3,5];case 4:(0,t.sent().gtm_pageView)(e),t.label=5;case 5:return i()?[4,import("../facebook/pageView.js")]:[3,7];case 6:(0,t.sent().fbp_pageView)(l),t.label=7;case 7:return[4,import("../ikas/analytics.js")];case 8:return[4,(0,t.sent().iks_pageView)(p,l)];case 9:return t.sent(),a()?[4,import("../tiktok/pageView.js")]:[3,11];case 10:(0,t.sent().tik_pageView)(e),t.label=11;case 11:return r()?[4,import("../openai/pageView.js")]:[3,13];case 12:(0,t.sent().oai_pageView)(l),t.label=13;case 13:return[3,15];case 14:return m=t.sent(),console.error(m),[3,15];case 15:return[2]}})})}export{p as anl_pageView};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.mjs.js';import{notifySubscribers as r}from"../events.js";import{hasTiktokPixel as s,hasGoogleAnalytics as o,hasGoogleTagManager as i,canTrack as a,hasFacebookPixel as n}from"../utils.js";function c(c){return t(this,void 0,void 0,function(){var t,u;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,11,,12]),a()?(t=Date.now().toString(),r({type:"PRODUCT_VIEW",data:{productDetail:c}}),n()?[4,import("../facebook/productView.js")]:[3,2]):[2];case 1:(0,e.sent().fbp_productView)(c,t),e.label=2;case 2:return i()?[4,import("../google-tag-manager/productView.js")]:[3,4];case 3:(0,e.sent().gtm_productView)(c),e.label=4;case 4:return[4,import("../ikas/analytics.js")];case 5:return[4,(0,e.sent().iks_productView)(c,t)];case 6:return e.sent(),o()?[4,import("../google-analytics/productView.js")]:[3,8];case 7:(0,e.sent().ga_productView)(c),e.label=8;case 8:return s()?[4,import("../tiktok/productView.js")]:[3,10];case 9:(0,e.sent().tik_productView)(c),e.label=10;case 10:return[3,12];case 11:return u=e.sent(),console.error(u),[3,12];case 12:return[2]}})})}export{c as anl_productView};
1
+ import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.mjs.js';import{notifySubscribers as r}from"../events.js";import{hasOpenAiPixel as s,hasTiktokPixel as o,hasGoogleAnalytics as i,hasGoogleTagManager as a,canTrack as c,hasFacebookPixel as n}from"../utils.js";function u(u){return e(this,void 0,void 0,function(){var e,p;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,13,,14]),c()?(e=Date.now().toString(),r({type:"PRODUCT_VIEW",data:{productDetail:u}}),n()?[4,import("../facebook/productView.js")]:[3,2]):[2];case 1:(0,t.sent().fbp_productView)(u,e),t.label=2;case 2:return a()?[4,import("../google-tag-manager/productView.js")]:[3,4];case 3:(0,t.sent().gtm_productView)(u),t.label=4;case 4:return[4,import("../ikas/analytics.js")];case 5:return[4,(0,t.sent().iks_productView)(u,e)];case 6:return t.sent(),i()?[4,import("../google-analytics/productView.js")]:[3,8];case 7:(0,t.sent().ga_productView)(u),t.label=8;case 8:return o()?[4,import("../tiktok/productView.js")]:[3,10];case 9:(0,t.sent().tik_productView)(u),t.label=10;case 10:return s()?[4,import("../openai/productView.js")]:[3,12];case 11:(0,t.sent().oai_productView)(u,e),t.label=12;case 12:return[3,14];case 13:return p=t.sent(),console.error(p),[3,14];case 14:return[2]}})})}export{u as anl_productView};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign as n}from'./../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as r}from"../../packages/storefront-config/src/index.js";import{getSelectedProductVariant as i}from"../../functions/models/product/index.js";import{getCookieValue as s}from"../../utils/helper.js";import"../../router/index.js";import"../../stores/cart/index.js";import{getCategoryPath as o}from"../../functions/models/category/index.js";import{customerStore as c}from"../../stores/customer/index.js";import'./../../ext/uuid/dist/esm-browser/stringify.js';import'./../../ext/uuid/dist/esm-browser/v3.js';import'./../../ext/uuid/dist/esm-browser/native.js';import'./../../ext/uuid/dist/esm-browser/v5.js';import"../../i18n/index.js";import'./../../ext/mobx/dist/mobx.esm.js';import"../../functions/models/product-list/index.js";import{getProductVariantPrice as u,getProductVariantFinalPrice as d}from"../../functions/models/product/variant/index.js";import'./../../ext/lodash/_isFlattenable.js';import'./../../ext/lodash/sortBy.js';import{baseStore as a}from"../../stores/base/index.js";import{waitForCustomerStoreInit as l}from"../../functions/stores/customer/index.js";import"../analytics.js";import'./../../ext/animejs/lib/anime.esm.js';import"../../packages/storefront-api-client/src/utils/api.js";import'./../../ext/isomorphic-fetch/fetch-npm-node.js';import"../../packages/storefront-api/src/index.js";import"../../theme/styles/index.js";import'./../../ext/preact/dist/preact.mjs.js';import'./../../ext/preact/hooks/dist/hooks.mjs.js';import"../../utils/fetch.js";import"../../packages/storefront-models/src/models/merchant-settings/index.js";var E,O;!function(t){t[t.SESSION_START=1]="SESSION_START",t[t.PAGE_VIEW=2]="PAGE_VIEW",t[t.PRODUCT_VIEW=3]="PRODUCT_VIEW",t[t.ADD_TO_CART=4]="ADD_TO_CART",t[t.VIEW_CART=5]="VIEW_CART",t[t.ORDER_SUCCESS=6]="ORDER_SUCCESS",t[t.BEGIN_CHECKOUT=7]="BEGIN_CHECKOUT",t[t.CHECKOUT_STEP=8]="CHECKOUT_STEP",t[t.CUSTOMER_REGISTER=9]="CUSTOMER_REGISTER",t[t.CUSTOMER_VISIT=10]="CUSTOMER_VISIT",t[t.CUSTOMER_LOGIN=11]="CUSTOMER_LOGIN",t[t.BRAND_VIEW=12]="BRAND_VIEW",t[t.CATEGORY_VIEW=13]="CATEGORY_VIEW",t[t.POPUP_VIEW=14]="POPUP_VIEW",t[t.SEARCH=15]="SEARCH",t[t.FAVORITE_PRODUCT=16]="FAVORITE_PRODUCT",t[t.CONTACT_FORM=17]="CONTACT_FORM",t[t.CONTACT_FORM_BACKEND=205]="CONTACT_FORM_BACKEND"}(E||(E={})),function(t){t[t.INDEX=1]="INDEX",t[t.CATEGORY=2]="CATEGORY",t[t.BRAND=3]="BRAND",t[t.PRODUCT=4]="PRODUCT",t[t.CUSTOM=5]="CUSTOM",t[t.ACCOUNT=6]="ACCOUNT",t[t.ADDRESSES=7]="ADDRESSES",t[t.ORDERS=8]="ORDERS",t[t.ORDER_DETAIL=9]="ORDER_DETAIL",t[t.LOGIN=10]="LOGIN",t[t.REGISTER=11]="REGISTER",t[t.FORGOT_PASSWORD=12]="FORGOT_PASSWORD",t[t.RECOVER_PASSWORD=13]="RECOVER_PASSWORD",t[t.CART=14]="CART",t[t.FAVORITE_PRODUCTS=15]="FAVORITE_PRODUCTS",t[t.SEARCH=16]="SEARCH",t[t.NOT_FOUND=17]="NOT_FOUND",t[t.BLOG=18]="BLOG",t[t.BLOG_INDEX=19]="BLOG_INDEX",t[t.BLOG_CATEGORY=20]="BLOG_CATEGORY",t[t.CHECKOUT=21]="CHECKOUT"}(O||(O={}));var R=import.meta.env.VITE_PUBLIC_ANALYTICS_URL?"".concat(import.meta.env.VITE_PUBLIC_ANALYTICS_URL,"/sendEventV2"):"https://0.myikas.com/sendEventV2",_=function(){function t(){}return t.SESSION_ID_KEY="ikas_session_id",t.VISITOR_ID_KEY="ikas_visitor_id",t.JOURNEY_ID_KEY="ikas_journey_id",t.EXPIRY_LENGTH=18e5,t}();function f(r,i){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,M([{id:i,t:E.PAGE_VIEW,ts:Date.now(),d:n(n({},W()),{pt:B(r)})}])];case 1:return t.sent(),[2]}})})}function T(r,s){return t(this,void 0,void 0,function(){var t,c,a,l;return e(this,function(e){switch(e.label){case 0:return t=[],c=[],r.categories&&r.categories.length>0&&o(r.categories[0]).map(function(e){t.push(e.name),c.push(e.id)}),a=i(r),l=u(a),[4,M([{id:s,t:E.PRODUCT_VIEW,ts:Date.now(),d:n(n({},W()),{d:n({pr:n({id:r.id,vid:a.id,cp:t,cid:c,n:r.name,pr:d(a)},(null==l?void 0:l.currency)?{c:null==l?void 0:l.currency}:{})},r.brand?{br:{id:r.brand.id}}:{})})}])];case 1:return e.sent(),[2]}})})}function I(r,i,s){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,M([{id:s,t:E.ADD_TO_CART,ts:Date.now(),d:n(n({},W()),{d:{crt:{id:i.id,c:i.currencyCode,pr:i.totalFinalPrice,il:K(i)},crtItm:H(r)}})}])];case 1:return t.sent(),[2]}})})}function m(r,i){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,M([{id:i,t:E.VIEW_CART,ts:Date.now(),d:n(n({},W()),{d:{crt:{id:r.id,c:r.currencyCode,pr:r.totalFinalPrice,il:K(r)}}})}])];case 1:return t.sent(),[2]}})})}function v(r,i){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,M([{id:i,t:E.ORDER_SUCCESS,ts:Date.now(),d:n(n({},W()),{d:{chk:{id:r.id,s:"success",p:r.totalFinalPrice,c:r.currencyCode,il:K(r)}}})}])];case 1:return t.sent(),[4,y()];case 2:return t.sent(),[2]}})})}function C(r,i){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,M([{id:i,t:E.BEGIN_CHECKOUT,ts:Date.now(),d:n(n({},W()),{d:{chk:{id:r.id,p:r.totalFinalPrice,c:r.currencyCode,il:K(r)}}})}])];case 1:return t.sent(),[2]}})})}function S(r,i){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,M([{t:E.CHECKOUT_STEP,ts:Date.now(),d:n(n({},W()),{d:{chk:{id:r.id,s:i,p:r.totalFinalPrice,c:r.currencyCode,il:K(r)}}})}])];case 1:return t.sent(),[2]}})})}function h(r){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,M([{id:r,t:E.CUSTOMER_REGISTER,ts:Date.now(),d:n(n({},W()),{d:{cst:F()}})}])];case 1:return t.sent(),[2]}})})}function D(){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,M([{t:E.CUSTOMER_LOGIN,ts:Date.now(),d:n(n({},W()),{d:{cst:F()}})}])];case 1:return t.sent(),[2]}})})}function p(){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,M([{t:E.CUSTOMER_VISIT,ts:Date.now(),d:n(n({},W()),{d:{cst:F()}})}])];case 1:return t.sent(),[2]}})})}function A(r){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,M([{t:E.BRAND_VIEW,ts:Date.now(),d:n(n({},W()),{d:{cst:F(),br:{id:r.id}}})}])];case 1:return t.sent(),[2]}})})}function N(r,i,s){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,M([{id:s,t:E.CATEGORY_VIEW,ts:Date.now(),d:n(n({},W()),{d:{cst:F(),ctg:{id:r.id,cp:i}}})}])];case 1:return t.sent(),[2]}})})}function U(r){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,M([{t:E.POPUP_VIEW,ts:Date.now(),d:n(n({},W()),{d:{cst:F()},m:{sfpid:r}})}])];case 1:return t.sent(),[2]}})})}function P(r,i,s){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,M([{id:i,t:E.SEARCH,ts:Date.now(),d:n(n({},W()),{d:{src:n({s:r},s?{r:s}:{})}})}])];case 1:return t.sent(),[2]}})})}function x(r){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,M([{id:r,t:E.CONTACT_FORM,ts:Date.now(),d:n({},W())}])];case 1:return t.sent(),[2]}})})}function w(r,i){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,M([{id:i,t:E.FAVORITE_PRODUCT,ts:Date.now(),d:n(n({},W()),{d:{pr:{id:r}}})}])];case 1:return t.sent(),[2]}})})}function G(){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return localStorage.removeItem(_.JOURNEY_ID_KEY),_.journeyId=void 0,[4,b()];case 1:return t.sent(),[2]}})})}function b(){return t(this,void 0,void 0,function(){var t,n;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),(t=localStorage.getItem(_.JOURNEY_ID_KEY))?(_.journeyId=t,[3,3]):[3,1];case 1:return[4,V()];case 2:e.sent(),e.label=3;case 3:return r.init({journeyId:_.journeyId||""}),[3,5];case 4:return n=e.sent(),console.error(n),[3,5];case 5:return[2]}})})}function j(){return t(this,void 0,void 0,function(){return e(this,function(t){return[2,"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})]})})}function y(){return t(this,void 0,void 0,function(){var t,n,r;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),r={},[4,j()];case 1:return r.id=e.sent(),r.expiry=Date.now()+_.EXPIRY_LENGTH,t=r,localStorage.setItem(_.SESSION_ID_KEY,JSON.stringify(t)),_.sessionId=t.id,[4,L()];case 2:return e.sent(),[3,4];case 3:return n=e.sent(),console.error(n),[3,4];case 4:return[2]}})})}function V(){return t(this,void 0,void 0,function(){var t;return e(this,function(e){switch(e.label){case 0:return[4,j()];case 1:return t=e.sent(),localStorage.setItem(_.JOURNEY_ID_KEY,t),_.journeyId=t,[2]}})})}function g(){return t(this,void 0,void 0,function(){var t,n,i;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,7,,8]),(t=localStorage.getItem(_.SESSION_ID_KEY))?(n=JSON.parse(t)).expiry<Date.now()||n.id.length<=13?[4,y()]:[3,2]:[3,4];case 1:return e.sent(),[3,3];case 2:_.sessionId=n.id,e.label=3;case 3:return[3,6];case 4:return[4,y()];case 5:e.sent(),e.label=6;case 6:return r.init({sessionId:_.sessionId||""}),[3,8];case 7:return i=e.sent(),console.error(i),[3,8];case 8:return[2]}})})}function L(){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,M([{t:E.SESSION_START,ts:Date.now(),d:n({},W())}])];case 1:return t.sent(),[2]}})})}function Y(){return t(this,void 0,void 0,function(){var t,n,i;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),(t=localStorage.getItem(_.VISITOR_ID_KEY))&&t.length>13?(_.visitorId=t,[3,3]):[3,1];case 1:return n=_,[4,j()];case 2:n.visitorId=e.sent(),localStorage.setItem(_.VISITOR_ID_KEY,_.visitorId),e.label=3;case 3:return r.init({visitorId:_.visitorId}),[3,5];case 4:return i=e.sent(),console.error(i),[3,5];case 5:return[2]}})})}function B(t){switch(t){case"INDEX":return O.INDEX;case"CATEGORY":return O.CATEGORY;case"BRAND":return O.BRAND;case"PRODUCT":return O.PRODUCT;case"CUSTOM":return O.CUSTOM;case"ACCOUNT":return O.ACCOUNT;case"ADDRESSES":return O.ADDRESSES;case"ORDERS":return O.ORDERS;case"ORDER_DETAIL":return O.ORDER_DETAIL;case"LOGIN":return O.LOGIN;case"REGISTER":return O.REGISTER;case"FORGOT_PASSWORD":return O.FORGOT_PASSWORD;case"RECOVER_PASSWORD":return O.RECOVER_PASSWORD;case"CART":return O.CART;case"FAVORITE_PRODUCTS":return O.FAVORITE_PRODUCTS;case"SEARCH":return O.SEARCH;case"NOT_FOUND":return O.NOT_FOUND;case"BLOG":return O.BLOG;case"BLOG_INDEX":return O.BLOG_INDEX;case"BLOG_CATEGORY":return O.BLOG_CATEGORY;case"CHECKOUT":return O.CHECKOUT}}function F(){var t=c.customer;return{id:(null==t?void 0:t.id)||void 0,e:(null==t?void 0:t.email)||void 0,c:c._customerConsentGranted}}function W(){return{u:window.location.href,r:document.referrer,pt:a.currentPageType?B(a.currentPageType):void 0,m:{fbp:s("_fbp"),fbc:s("_fbc")}}}function K(t){return t.orderLineItems.map(function(t){return n(n(n(n({},t.variant.productId?{pid:t.variant.productId}:{}),t.variant.id?{vid:t.variant.id}:{}),{c:t.quantity}),t.finalPrice?{p:t.finalPrice}:{})})}function H(t){return n(n(n(n({},t.variant.productId?{pid:t.variant.productId}:{}),t.variant.id?{vid:t.variant.id}:{}),{c:t.quantity}),t.finalPrice?{p:t.finalPrice}:{})}function M(i){return t(this,void 0,void 0,function(){var t,s,o,u,d,a,E,O,f,T,I,m;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,6,,7]),[4,l(c)];case 1:return e.sent(),[4,g()];case 2:return e.sent(),[4,Y()];case 3:return e.sent(),[4,b()];case 4:return e.sent(),t={e:i,scid:r.salesChannelId,sfid:r.storefrontId,sid:_.sessionId,jid:_.journeyId,vid:_.visitorId,sfrid:r.storefrontRoutingId||"",ud:n(n(n(n({id:null===(u=c.customer)||void 0===u?void 0:u.id},(null===(d=c.customer)||void 0===d?void 0:d.email)?{em:null===(a=c.customer)||void 0===a?void 0:a.email}:{}),(null===(E=c.customer)||void 0===E?void 0:E.phone)?{ph:null===(O=c.customer)||void 0===O?void 0:O.phone}:{}),(null===(f=c.customer)||void 0===f?void 0:f.lastName)?{ln:null===(T=c.customer)||void 0===T?void 0:T.lastName}:{}),(null===(I=c.customer)||void 0===I?void 0:I.firstName)?{fn:null===(m=c.customer)||void 0===m?void 0:m.firstName}:{}),v:3},s=JSON.stringify(t),[4,fetch(R,{method:"POST",body:s,headers:{"Content-Type":"application/json","x-api-key":r.apiKey},keepalive:s.length<3e4})];case 5:return e.sent(),[3,7];case 6:return o=e.sent(),console.error(o),[3,7];case 7:return[2]}})})}export{_ as default,I as iks_addToCart,w as iks_addToWishlist,C as iks_beginCheckout,b as iks_checkJourneyId,S as iks_checkoutStep,x as iks_contactForm,D as iks_customerLogin,h as iks_customerRegister,p as iks_customerVisit,f as iks_pageView,T as iks_productView,v as iks_purchase,G as iks_refreshJourneyId,P as iks_search,A as iks_viewBrand,m as iks_viewCart,N as iks_viewCategory,U as iks_viewPopup};
1
+ import{__awaiter as t,__generator as e,__assign as n}from'./../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as r}from"../../packages/storefront-config/src/index.js";import{getSelectedProductVariant as i}from"../../functions/models/product/index.js";import{getCookieValue as s,getOpenAiAttributionMetadata as o}from"../../utils/helper.js";import"../../router/index.js";import"../../stores/cart/index.js";import{getCategoryPath as c}from"../../functions/models/category/index.js";import{customerStore as u}from"../../stores/customer/index.js";import'./../../ext/uuid/dist/esm-browser/stringify.js';import'./../../ext/uuid/dist/esm-browser/v3.js';import'./../../ext/uuid/dist/esm-browser/native.js';import'./../../ext/uuid/dist/esm-browser/v5.js';import"../../i18n/index.js";import'./../../ext/mobx/dist/mobx.esm.js';import"../../functions/models/product-list/index.js";import{getProductVariantPrice as d,getProductVariantFinalPrice as a}from"../../functions/models/product/variant/index.js";import'./../../ext/lodash/_isFlattenable.js';import'./../../ext/lodash/sortBy.js';import{baseStore as l}from"../../stores/base/index.js";import{waitForCustomerStoreInit as E}from"../../functions/stores/customer/index.js";import"../analytics.js";import'./../../ext/animejs/lib/anime.esm.js';import"../../packages/storefront-api-client/src/utils/api.js";import'./../../ext/isomorphic-fetch/fetch-npm-node.js';import"../../packages/storefront-api/src/index.js";import"../../theme/styles/index.js";import'./../../ext/preact/dist/preact.mjs.js';import'./../../ext/preact/hooks/dist/hooks.mjs.js';import"../../utils/fetch.js";import"../../packages/storefront-models/src/models/merchant-settings/index.js";var O,R;!function(t){t[t.SESSION_START=1]="SESSION_START",t[t.PAGE_VIEW=2]="PAGE_VIEW",t[t.PRODUCT_VIEW=3]="PRODUCT_VIEW",t[t.ADD_TO_CART=4]="ADD_TO_CART",t[t.VIEW_CART=5]="VIEW_CART",t[t.ORDER_SUCCESS=6]="ORDER_SUCCESS",t[t.BEGIN_CHECKOUT=7]="BEGIN_CHECKOUT",t[t.CHECKOUT_STEP=8]="CHECKOUT_STEP",t[t.CUSTOMER_REGISTER=9]="CUSTOMER_REGISTER",t[t.CUSTOMER_VISIT=10]="CUSTOMER_VISIT",t[t.CUSTOMER_LOGIN=11]="CUSTOMER_LOGIN",t[t.BRAND_VIEW=12]="BRAND_VIEW",t[t.CATEGORY_VIEW=13]="CATEGORY_VIEW",t[t.POPUP_VIEW=14]="POPUP_VIEW",t[t.SEARCH=15]="SEARCH",t[t.FAVORITE_PRODUCT=16]="FAVORITE_PRODUCT",t[t.CONTACT_FORM=17]="CONTACT_FORM",t[t.CONTACT_FORM_BACKEND=205]="CONTACT_FORM_BACKEND"}(O||(O={})),function(t){t[t.INDEX=1]="INDEX",t[t.CATEGORY=2]="CATEGORY",t[t.BRAND=3]="BRAND",t[t.PRODUCT=4]="PRODUCT",t[t.CUSTOM=5]="CUSTOM",t[t.ACCOUNT=6]="ACCOUNT",t[t.ADDRESSES=7]="ADDRESSES",t[t.ORDERS=8]="ORDERS",t[t.ORDER_DETAIL=9]="ORDER_DETAIL",t[t.LOGIN=10]="LOGIN",t[t.REGISTER=11]="REGISTER",t[t.FORGOT_PASSWORD=12]="FORGOT_PASSWORD",t[t.RECOVER_PASSWORD=13]="RECOVER_PASSWORD",t[t.CART=14]="CART",t[t.FAVORITE_PRODUCTS=15]="FAVORITE_PRODUCTS",t[t.SEARCH=16]="SEARCH",t[t.NOT_FOUND=17]="NOT_FOUND",t[t.BLOG=18]="BLOG",t[t.BLOG_INDEX=19]="BLOG_INDEX",t[t.BLOG_CATEGORY=20]="BLOG_CATEGORY",t[t.CHECKOUT=21]="CHECKOUT"}(R||(R={}));var _=import.meta.env.VITE_PUBLIC_ANALYTICS_URL?"".concat(import.meta.env.VITE_PUBLIC_ANALYTICS_URL,"/sendEventV2"):"https://0.myikas.com/sendEventV2",f=function(){function t(){}return t.SESSION_ID_KEY="ikas_session_id",t.VISITOR_ID_KEY="ikas_visitor_id",t.JOURNEY_ID_KEY="ikas_journey_id",t.EXPIRY_LENGTH=18e5,t}();function T(r,i){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,k([{id:i,t:O.PAGE_VIEW,ts:Date.now(),d:n(n({},K()),{pt:F(r)})}])];case 1:return t.sent(),[2]}})})}function I(r,s){return t(this,void 0,void 0,function(){var t,o,u,l;return e(this,function(e){switch(e.label){case 0:return t=[],o=[],r.categories&&r.categories.length>0&&c(r.categories[0]).map(function(e){t.push(e.name),o.push(e.id)}),u=i(r),l=d(u),[4,k([{id:s,t:O.PRODUCT_VIEW,ts:Date.now(),d:n(n({},K()),{d:n({pr:n({id:r.id,vid:u.id,cp:t,cid:o,n:r.name,pr:a(u)},(null==l?void 0:l.currency)?{c:null==l?void 0:l.currency}:{})},r.brand?{br:{id:r.brand.id}}:{})})}])];case 1:return e.sent(),[2]}})})}function m(r,i,s){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,k([{id:s,t:O.ADD_TO_CART,ts:Date.now(),d:n(n({},K()),{d:{crt:{id:i.id,c:i.currencyCode,pr:i.totalFinalPrice,il:H(i)},crtItm:M(r)}})}])];case 1:return t.sent(),[2]}})})}function v(r,i){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,k([{id:i,t:O.VIEW_CART,ts:Date.now(),d:n(n({},K()),{d:{crt:{id:r.id,c:r.currencyCode,pr:r.totalFinalPrice,il:H(r)}}})}])];case 1:return t.sent(),[2]}})})}function C(r,i){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,k([{id:i,t:O.ORDER_SUCCESS,ts:Date.now(),d:n(n({},K()),{d:{chk:{id:r.id,s:"success",p:r.totalFinalPrice,c:r.currencyCode,il:H(r)}}})}])];case 1:return t.sent(),[4,V()];case 2:return t.sent(),[2]}})})}function S(r,i){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,k([{id:i,t:O.BEGIN_CHECKOUT,ts:Date.now(),d:n(n({},K()),{d:{chk:{id:r.id,p:r.totalFinalPrice,c:r.currencyCode,il:H(r)}}})}])];case 1:return t.sent(),[2]}})})}function h(r,i){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,k([{t:O.CHECKOUT_STEP,ts:Date.now(),d:n(n({},K()),{d:{chk:{id:r.id,s:i,p:r.totalFinalPrice,c:r.currencyCode,il:H(r)}}})}])];case 1:return t.sent(),[2]}})})}function D(r){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,k([{id:r,t:O.CUSTOMER_REGISTER,ts:Date.now(),d:n(n({},K()),{d:{cst:W()}})}])];case 1:return t.sent(),[2]}})})}function p(){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,k([{t:O.CUSTOMER_LOGIN,ts:Date.now(),d:n(n({},K()),{d:{cst:W()}})}])];case 1:return t.sent(),[2]}})})}function A(){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,k([{t:O.CUSTOMER_VISIT,ts:Date.now(),d:n(n({},K()),{d:{cst:W()}})}])];case 1:return t.sent(),[2]}})})}function N(r){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,k([{t:O.BRAND_VIEW,ts:Date.now(),d:n(n({},K()),{d:{cst:W(),br:{id:r.id}}})}])];case 1:return t.sent(),[2]}})})}function U(r,i,s){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,k([{id:s,t:O.CATEGORY_VIEW,ts:Date.now(),d:n(n({},K()),{d:{cst:W(),ctg:{id:r.id,cp:i}}})}])];case 1:return t.sent(),[2]}})})}function P(r){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,k([{t:O.POPUP_VIEW,ts:Date.now(),d:n(n({},K()),{d:{cst:W()},m:{sfpid:r}})}])];case 1:return t.sent(),[2]}})})}function x(r,i,s){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,k([{id:i,t:O.SEARCH,ts:Date.now(),d:n(n({},K()),{d:{src:n({s:r},s?{r:s}:{})}})}])];case 1:return t.sent(),[2]}})})}function w(r){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,k([{id:r,t:O.CONTACT_FORM,ts:Date.now(),d:n({},K())}])];case 1:return t.sent(),[2]}})})}function G(r,i){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,k([{id:i,t:O.FAVORITE_PRODUCT,ts:Date.now(),d:n(n({},K()),{d:{pr:{id:r}}})}])];case 1:return t.sent(),[2]}})})}function b(){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return localStorage.removeItem(f.JOURNEY_ID_KEY),f.journeyId=void 0,[4,j()];case 1:return t.sent(),[2]}})})}function j(){return t(this,void 0,void 0,function(){var t,n;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),(t=localStorage.getItem(f.JOURNEY_ID_KEY))?(f.journeyId=t,[3,3]):[3,1];case 1:return[4,g()];case 2:e.sent(),e.label=3;case 3:return r.init({journeyId:f.journeyId||""}),[3,5];case 4:return n=e.sent(),console.error(n),[3,5];case 5:return[2]}})})}function y(){return t(this,void 0,void 0,function(){return e(this,function(t){return[2,"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})]})})}function V(){return t(this,void 0,void 0,function(){var t,n,r;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),r={},[4,y()];case 1:return r.id=e.sent(),r.expiry=Date.now()+f.EXPIRY_LENGTH,t=r,localStorage.setItem(f.SESSION_ID_KEY,JSON.stringify(t)),f.sessionId=t.id,[4,Y()];case 2:return e.sent(),[3,4];case 3:return n=e.sent(),console.error(n),[3,4];case 4:return[2]}})})}function g(){return t(this,void 0,void 0,function(){var t;return e(this,function(e){switch(e.label){case 0:return[4,y()];case 1:return t=e.sent(),localStorage.setItem(f.JOURNEY_ID_KEY,t),f.journeyId=t,[2]}})})}function L(){return t(this,void 0,void 0,function(){var t,n,i;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,7,,8]),(t=localStorage.getItem(f.SESSION_ID_KEY))?(n=JSON.parse(t)).expiry<Date.now()||n.id.length<=13?[4,V()]:[3,2]:[3,4];case 1:return e.sent(),[3,3];case 2:f.sessionId=n.id,e.label=3;case 3:return[3,6];case 4:return[4,V()];case 5:e.sent(),e.label=6;case 6:return r.init({sessionId:f.sessionId||""}),[3,8];case 7:return i=e.sent(),console.error(i),[3,8];case 8:return[2]}})})}function Y(){return t(this,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,k([{t:O.SESSION_START,ts:Date.now(),d:n({},K())}])];case 1:return t.sent(),[2]}})})}function B(){return t(this,void 0,void 0,function(){var t,n,i;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),(t=localStorage.getItem(f.VISITOR_ID_KEY))&&t.length>13?(f.visitorId=t,[3,3]):[3,1];case 1:return n=f,[4,y()];case 2:n.visitorId=e.sent(),localStorage.setItem(f.VISITOR_ID_KEY,f.visitorId),e.label=3;case 3:return r.init({visitorId:f.visitorId}),[3,5];case 4:return i=e.sent(),console.error(i),[3,5];case 5:return[2]}})})}function F(t){switch(t){case"INDEX":return R.INDEX;case"CATEGORY":return R.CATEGORY;case"BRAND":return R.BRAND;case"PRODUCT":return R.PRODUCT;case"CUSTOM":return R.CUSTOM;case"ACCOUNT":return R.ACCOUNT;case"ADDRESSES":return R.ADDRESSES;case"ORDERS":return R.ORDERS;case"ORDER_DETAIL":return R.ORDER_DETAIL;case"LOGIN":return R.LOGIN;case"REGISTER":return R.REGISTER;case"FORGOT_PASSWORD":return R.FORGOT_PASSWORD;case"RECOVER_PASSWORD":return R.RECOVER_PASSWORD;case"CART":return R.CART;case"FAVORITE_PRODUCTS":return R.FAVORITE_PRODUCTS;case"SEARCH":return R.SEARCH;case"NOT_FOUND":return R.NOT_FOUND;case"BLOG":return R.BLOG;case"BLOG_INDEX":return R.BLOG_INDEX;case"BLOG_CATEGORY":return R.BLOG_CATEGORY;case"CHECKOUT":return R.CHECKOUT}}function W(){var t=u.customer;return{id:(null==t?void 0:t.id)||void 0,e:(null==t?void 0:t.email)||void 0,c:u._customerConsentGranted}}function K(){return{u:window.location.href,r:document.referrer,pt:l.currentPageType?F(l.currentPageType):void 0,m:n({fbp:s("_fbp"),fbc:s("_fbc")},o())}}function H(t){return t.orderLineItems.map(function(t){return n(n(n(n({},t.variant.productId?{pid:t.variant.productId}:{}),t.variant.id?{vid:t.variant.id}:{}),{c:t.quantity}),t.finalPrice?{p:t.finalPrice}:{})})}function M(t){return n(n(n(n({},t.variant.productId?{pid:t.variant.productId}:{}),t.variant.id?{vid:t.variant.id}:{}),{c:t.quantity}),t.finalPrice?{p:t.finalPrice}:{})}function k(i){return t(this,void 0,void 0,function(){var t,s,o,c,d,a,l,O,R,T,I,m;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,6,,7]),[4,E(u)];case 1:return e.sent(),[4,L()];case 2:return e.sent(),[4,B()];case 3:return e.sent(),[4,j()];case 4:return e.sent(),t={e:i,scid:r.salesChannelId,sfid:r.storefrontId,sid:f.sessionId,jid:f.journeyId,vid:f.visitorId,sfrid:r.storefrontRoutingId||"",ud:n(n(n(n({id:null===(c=u.customer)||void 0===c?void 0:c.id},(null===(d=u.customer)||void 0===d?void 0:d.email)?{em:null===(a=u.customer)||void 0===a?void 0:a.email}:{}),(null===(l=u.customer)||void 0===l?void 0:l.phone)?{ph:null===(O=u.customer)||void 0===O?void 0:O.phone}:{}),(null===(R=u.customer)||void 0===R?void 0:R.lastName)?{ln:null===(T=u.customer)||void 0===T?void 0:T.lastName}:{}),(null===(I=u.customer)||void 0===I?void 0:I.firstName)?{fn:null===(m=u.customer)||void 0===m?void 0:m.firstName}:{}),v:3},s=JSON.stringify(t),[4,fetch(_,{method:"POST",body:s,headers:{"Content-Type":"application/json","x-api-key":r.apiKey},keepalive:s.length<3e4})];case 5:return e.sent(),[3,7];case 6:return o=e.sent(),console.error(o),[3,7];case 7:return[2]}})})}export{f as default,m as iks_addToCart,G as iks_addToWishlist,S as iks_beginCheckout,j as iks_checkJourneyId,h as iks_checkoutStep,w as iks_contactForm,p as iks_customerLogin,D as iks_customerRegister,A as iks_customerVisit,T as iks_pageView,I as iks_productView,C as iks_purchase,b as iks_refreshJourneyId,x as iks_search,N as iks_viewBrand,v as iks_viewCart,U as iks_viewCategory,P as iks_viewPopup};
@@ -0,0 +1,2 @@
1
+ import { IkasOrderLineItem } from "../../storefront-models/src";
2
+ export declare function oai_addToCart(item: IkasOrderLineItem, quantity: number, eventId: string): void;
@@ -0,0 +1 @@
1
+ import{__assign as t}from'./../../ext/tslib/tslib.es6.mjs.js';import{extractCartItemData as o}from"../utils.js";import{hasOpenAi as r,measure as s,toOpenAiMoney as e,cartItemToOpenAiContent as i}from"./utils.js";function c(c,m,n){if(r())try{var d=o(c,m);s("items_added",t(t({type:"contents"},e(d.price*m,d.currency||void 0)),{contents:[i(d)]}),n)}catch(t){console.error(t)}}export{c as oai_addToCart};
@@ -0,0 +1 @@
1
+ export declare function oai_completeRegistration(eventId: string): void;
@@ -0,0 +1 @@
1
+ import{hasOpenAi as t,measure as o}from"./utils.js";function r(r){if(t())try{o("registration_completed",{type:"customer_action"},r)}catch(t){console.error(t)}}export{r as oai_completeRegistration};
@@ -0,0 +1 @@
1
+ export declare function oai_contactForm(eventId: string): void;
@@ -0,0 +1 @@
1
+ import{hasOpenAi as t,measure as o}from"./utils.js";function r(r){if(t())try{o("lead_created",{type:"customer_action"},r)}catch(t){console.error(t)}}export{r as oai_contactForm};
@@ -0,0 +1,12 @@
1
+ export type AdvancedMatchingUserData = {
2
+ em?: string | null;
3
+ fn?: string | null;
4
+ ln?: string | null;
5
+ ph?: string | null;
6
+ external_id?: string | null;
7
+ ct?: string | null;
8
+ st?: string | null;
9
+ zp?: string | null;
10
+ country?: string | null;
11
+ };
12
+ export declare function oai_initAdvancedMatching(userData: AdvancedMatchingUserData): Promise<void> | undefined;
@@ -0,0 +1 @@
1
+ import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as r}from"../../packages/storefront-config/src/index.js";import{hasOpenAi as n,chainAdvancedMatching as i,oaiq as o}from"./utils.js";function s(s){var l=r.openAiPixelId;if(n()&&l)return i(function(){return function(r,n){return t(this,void 0,void 0,function(){var t,i,s,l,d,m,h;return e(this,function(e){switch(e.label){case 0:return[4,Promise.all([p(u(n.em)),p(a(n.ph)),p(c(n.external_id)),p(f(n.fn)),p(f(n.ln))])];case 1:return t=e.sent(),i=t[0],s=t[1],l=t[2],d=t[3],m=t[4],h={},i&&(h.email_sha256=i),s&&(h.phone_number_sha256=s),l&&(h.external_id_sha256=l),d&&(h.first_name_sha256=d),m&&(h.last_name_sha256=m),n.country&&(h.country=n.country.toUpperCase().trim()),n.ct&&(h.city=n.ct.trim()),n.st&&(h.region=n.st.trim()),n.zp&&(h.postal_code=n.zp.trim()),o()&&Object.keys(h).length>0&&o()("init",{pixelId:r,user:h}),[2]}})})}(l,s)})}function u(t){return t?t.trim().toLowerCase():""}function a(t){if(!t)return"";var e=t.replace(/\D/g,"").replace(/^0+/,"");return/^\d{8,15}$/.test(e)?e:""}function c(t){return t?t.trim():""}function f(t){return t?t.toLowerCase().replace(/[\s!-/:-@[-`{-~]/g,""):""}var l=new Map;function p(r){if(!r)return Promise.resolve(void 0);var n=l.get(r);return n||(n=function(r){return t(this,void 0,void 0,function(){var t;return e(this,function(e){switch(e.label){case 0:if("undefined"==typeof crypto||!crypto.subtle||"undefined"==typeof TextEncoder)return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,crypto.subtle.digest("SHA-256",(new TextEncoder).encode(r))];case 2:return t=e.sent(),[2,Array.from(new Uint8Array(t)).map(function(t){return t.toString(16).padStart(2,"0")}).join("")];case 3:return e.sent(),[2];case 4:return[2]}})})}(r),l.set(r,n)),n}export{s as oai_initAdvancedMatching};
@@ -0,0 +1 @@
1
+ export declare function oai_pageView(eventId: string): void;
@@ -0,0 +1 @@
1
+ import{hasOpenAi as t,measure as e}from"./utils.js";function o(o){if(t())try{e("page_viewed",{type:"contents"},o)}catch(t){console.error(t)}}export{o as oai_pageView};
@@ -0,0 +1,2 @@
1
+ import { IkasProduct } from "../../storefront-models/src";
2
+ export declare function oai_productView(productDetail: IkasProduct, eventId: string): void;
@@ -0,0 +1 @@
1
+ import{__assign as t}from'./../../ext/tslib/tslib.es6.mjs.js';import{extractProductData as e}from"../utils.js";import{hasOpenAi as o,toOpenAiMoney as n,measure as r}from"./utils.js";function i(i,s){if(o())try{var c=e(i),m=n(c.price,c.currency);r("contents_viewed",t(t({type:"contents"},m),{contents:[t({id:c.variantId,name:c.name,content_type:"product",quantity:1},m)]}),s)}catch(t){console.error(t)}}export{i as oai_productView};
@@ -0,0 +1,26 @@
1
+ import { CommonCartItemData } from "../utils";
2
+ export type OpenAiEventName = "page_viewed" | "contents_viewed" | "items_added" | "registration_completed" | "lead_created";
3
+ export type OpenAiMoney = {
4
+ amount?: number;
5
+ currency?: string;
6
+ };
7
+ export type OpenAiContent = OpenAiMoney & {
8
+ id: string;
9
+ name?: string;
10
+ content_type: "product" | "page";
11
+ quantity?: number;
12
+ };
13
+ export type OpenAiContentsData = OpenAiMoney & {
14
+ type: "contents";
15
+ contents?: OpenAiContent[];
16
+ };
17
+ export type OpenAiCustomerActionData = OpenAiMoney & {
18
+ type: "customer_action";
19
+ };
20
+ export type OpenAiEventData = OpenAiContentsData | OpenAiCustomerActionData;
21
+ export declare const oaiq: () => any;
22
+ export declare const hasOpenAi: () => any;
23
+ export declare function chainAdvancedMatching(task: () => Promise<void>): Promise<void>;
24
+ export declare function measure(eventName: OpenAiEventName, data: OpenAiEventData, eventId?: string): void;
25
+ export declare function cartItemToOpenAiContent(item: CommonCartItemData): OpenAiContent;
26
+ export declare function toOpenAiMoney(value: number | null | undefined, currency: string | undefined): OpenAiMoney;
@@ -0,0 +1 @@
1
+ import{__assign as n}from'./../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as r}from"../../packages/storefront-config/src/index.js";import{canTrack as t}from"../utils.js";var e=function(){return window.oaiq},o=function(){return t()&&r.openAiPixelId&&e()},i=Promise.resolve();function u(n){return i=i.then(n).catch(function(n){return console.error(n)})}function c(n,r,t){i.then(function(){o()&&e()("measure",n,r,t?{event_id:t}:{})}).catch(function(n){return console.error(n)})}function a(r){return n({id:r.variantId,name:r.name,content_type:"product",quantity:r.quantity},s(r.price,r.currency||void 0))}function s(n,r){var t=function(n,r){var t;try{if("number"!=typeof n||isNaN(n)||!r)return;var e=m.get(r);return void 0===e&&(e=null!==(t=new Intl.NumberFormat("en",{style:"currency",currency:r}).resolvedOptions().maximumFractionDigits)&&void 0!==t?t:2,m.set(r,e)),Math.round(n*Math.pow(10,e))}catch(n){return}}(n,r);return void 0!==t&&r?{amount:t,currency:r}:{}}var m=new Map;export{a as cartItemToOpenAiContent,u as chainAdvancedMatching,o as hasOpenAi,c as measure,e as oaiq,s as toOpenAiMoney};
@@ -4,6 +4,7 @@ export declare const hasFacebookPixel: () => boolean;
4
4
  export declare const hasGoogleAnalytics: () => boolean;
5
5
  export declare const hasGoogleTagManager: () => boolean;
6
6
  export declare const hasTiktokPixel: () => boolean;
7
+ export declare const hasOpenAiPixel: () => boolean;
7
8
  export interface CommonProductData {
8
9
  id: string;
9
10
  variantId: string;
@@ -1 +1 @@
1
- import{IkasStorefrontConfig as i}from"../packages/storefront-config/src/index.js";import{getSelectedProductVariant as e}from"../functions/models/product/index.js";import{isServer as o}from"../utils/helper.js";import"../router/index.js";import"../stores/cart/index.js";import{getCategoryPath as r}from"../functions/models/category/index.js";import"../stores/customer/index.js";import'./../ext/uuid/dist/esm-browser/stringify.js';import'./../ext/uuid/dist/esm-browser/v3.js';import'./../ext/uuid/dist/esm-browser/native.js';import'./../ext/uuid/dist/esm-browser/v5.js';import"../i18n/index.js";import'./../ext/mobx/dist/mobx.esm.js';import{getDefaultSrc as t}from"../functions/models/image/index.js";import"../functions/models/product-list/index.js";import{getProductVariantMainImage as n,getProductVariantPrice as s,getProductVariantFinalPrice as a,getProductVariantSellPrice as d,getProductVariantDiscountPrice as m}from"../functions/models/product/variant/index.js";import'./../ext/lodash/_isFlattenable.js';import'./../ext/lodash/sortBy.js';import"../stores/base/index.js";import"../packages/storefront-api-client/src/utils/api.js";import'./../ext/isomorphic-fetch/fetch-npm-node.js';import"./analytics.js";import'./../ext/animejs/lib/anime.esm.js';import"../packages/storefront-api/src/index.js";import"../theme/styles/index.js";import'./../ext/preact/dist/preact.mjs.js';import'./../ext/preact/hooks/dist/hooks.mjs.js';import"../utils/fetch.js";import"../packages/storefront-models/src/models/merchant-settings/index.js";var u=function(){return!o()&&!i.isEditor},c=function(){return u()&&!!i.fbpId&&!!window.fbq},l=function(){return u()&&!!window.gtag},p=function(){return u()&&!!window.dataLayer},v=function(){return u()&&!!i.tiktokPixelId&&!!window.ttq};function f(i,o){var u,c,l,p,v=e(i),f=i.categories.length>0?r(i.categories[0]).map(function(i){return i.name}):[],j=null===(u=n(v))||void 0===u?void 0:u.image,g=s(v);return{id:i.id,variantId:v.id,name:i.name,price:null!==(c=a(v))&&void 0!==c?c:0,currency:(null==g?void 0:g.currency)||"TRY",categoryPath:f,categoryString:f.join(" > "),brand:(null===(l=i.brand)||void 0===l?void 0:l.name)||"",variant:v.variantValues.map(function(i){return i.name}).join(" / "),barcode:null===(p=v.barcodeList)||void 0===p?void 0:p[0],image:j?t(j):"",sellPrice:d(v)||void 0,discountPrice:m(v)}}function j(i,e,o){var r,t,n,s,a,d=[];if(null===(r=null==o?void 0:o.categories)||void 0===r?void 0:r.length)(m=o.categories[0]).categoryPath&&m.categoryPath.forEach(function(i){return d.push(i)}),d.push(m.name);else if(null===(t=i.variant.categories)||void 0===t?void 0:t.length){var m;(m=i.variant.categories[0]).categoryPath&&m.categoryPath.forEach(function(i){return d.push(i.name)}),d.push(m.name)}return{id:i.variant.productId||"",variantId:i.variant.id||"",name:i.variant.name,price:i.finalPrice||0,quantity:null!=e?e:i.quantity,currency:i.currencyCode||"",categoryPath:d,categoryString:d.join(" > "),brand:(null===(n=null==o?void 0:o.brand)||void 0===n?void 0:n.name)||(null===(s=i.variant.brand)||void 0===s?void 0:s.name)||"",variant:(null===(a=i.variant.variantValues)||void 0===a?void 0:a.map(function(i){return i.variantValueName}).join(" / "))||""}}function g(i){var e;return{items:i.orderLineItems.map(function(i){return j(i)}),totalPrice:"totalFinalPrice"in i?i.totalFinalPrice:i.totalPrice,currency:i.currencyCode||(null===(e=i.orderLineItems[0])||void 0===e?void 0:e.currencyCode)||"TRY",itemCount:i.orderLineItems.length}}export{u as canTrack,g as extractCartData,j as extractCartItemData,f as extractProductData,c as hasFacebookPixel,l as hasGoogleAnalytics,p as hasGoogleTagManager,v as hasTiktokPixel};
1
+ import{IkasStorefrontConfig as i}from"../packages/storefront-config/src/index.js";import{getSelectedProductVariant as e}from"../functions/models/product/index.js";import{isServer as o}from"../utils/helper.js";import"../router/index.js";import"../stores/cart/index.js";import{getCategoryPath as r}from"../functions/models/category/index.js";import"../stores/customer/index.js";import'./../ext/uuid/dist/esm-browser/stringify.js';import'./../ext/uuid/dist/esm-browser/v3.js';import'./../ext/uuid/dist/esm-browser/native.js';import'./../ext/uuid/dist/esm-browser/v5.js';import"../i18n/index.js";import'./../ext/mobx/dist/mobx.esm.js';import{getDefaultSrc as t}from"../functions/models/image/index.js";import"../functions/models/product-list/index.js";import{getProductVariantMainImage as n,getProductVariantPrice as s,getProductVariantFinalPrice as a,getProductVariantSellPrice as d,getProductVariantDiscountPrice as m}from"../functions/models/product/variant/index.js";import'./../ext/lodash/_isFlattenable.js';import'./../ext/lodash/sortBy.js';import"../stores/base/index.js";import"../packages/storefront-api-client/src/utils/api.js";import'./../ext/isomorphic-fetch/fetch-npm-node.js';import"./analytics.js";import'./../ext/animejs/lib/anime.esm.js';import"../packages/storefront-api/src/index.js";import"../theme/styles/index.js";import'./../ext/preact/dist/preact.mjs.js';import'./../ext/preact/hooks/dist/hooks.mjs.js';import"../utils/fetch.js";import"../packages/storefront-models/src/models/merchant-settings/index.js";var u=function(){return!o()&&!i.isEditor},c=function(){return u()&&!!i.fbpId&&!!window.fbq},l=function(){return u()&&!!window.gtag},p=function(){return u()&&!!window.dataLayer},v=function(){return u()&&!!i.tiktokPixelId&&!!window.ttq},f=function(){return u()&&!!i.openAiPixelId&&!!window.oaiq};function j(i,o){var u,c,l,p,v=e(i),f=i.categories.length>0?r(i.categories[0]).map(function(i){return i.name}):[],j=null===(u=n(v))||void 0===u?void 0:u.image,g=s(v);return{id:i.id,variantId:v.id,name:i.name,price:null!==(c=a(v))&&void 0!==c?c:0,currency:(null==g?void 0:g.currency)||"TRY",categoryPath:f,categoryString:f.join(" > "),brand:(null===(l=i.brand)||void 0===l?void 0:l.name)||"",variant:v.variantValues.map(function(i){return i.name}).join(" / "),barcode:null===(p=v.barcodeList)||void 0===p?void 0:p[0],image:j?t(j):"",sellPrice:d(v)||void 0,discountPrice:m(v)}}function g(i,e,o){var r,t,n,s,a,d=[];if(null===(r=null==o?void 0:o.categories)||void 0===r?void 0:r.length)(m=o.categories[0]).categoryPath&&m.categoryPath.forEach(function(i){return d.push(i)}),d.push(m.name);else if(null===(t=i.variant.categories)||void 0===t?void 0:t.length){var m;(m=i.variant.categories[0]).categoryPath&&m.categoryPath.forEach(function(i){return d.push(i.name)}),d.push(m.name)}return{id:i.variant.productId||"",variantId:i.variant.id||"",name:i.variant.name,price:i.finalPrice||0,quantity:null!=e?e:i.quantity,currency:i.currencyCode||"",categoryPath:d,categoryString:d.join(" > "),brand:(null===(n=null==o?void 0:o.brand)||void 0===n?void 0:n.name)||(null===(s=i.variant.brand)||void 0===s?void 0:s.name)||"",variant:(null===(a=i.variant.variantValues)||void 0===a?void 0:a.map(function(i){return i.variantValueName}).join(" / "))||""}}function h(i){var e;return{items:i.orderLineItems.map(function(i){return g(i)}),totalPrice:"totalFinalPrice"in i?i.totalFinalPrice:i.totalPrice,currency:i.currencyCode||(null===(e=i.orderLineItems[0])||void 0===e?void 0:e.currencyCode)||"TRY",itemCount:i.orderLineItems.length}}export{u as canTrack,h as extractCartData,g as extractCartItemData,j as extractProductData,c as hasFacebookPixel,l as hasGoogleAnalytics,p as hasGoogleTagManager,f as hasOpenAiPixel,v as hasTiktokPixel};
@@ -1 +1 @@
1
- import{__assign as e,__awaiter as t,__generator as r}from'./../../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as n}from"../../../packages/storefront-config/src/index.js";import i from'./../../../ext/lodash/cloneDeep.js';import{I18n as a}from"../../../i18n/index.js";import{Router as o,withRoutePrefix as s}from"../../../router/index.js";import{customerStore as u}from"../../../stores/customer/index.js";import{isClient as d,isBackNavigation as l,getQueryParams as c,debounce as f,stringToSlug as v,stringifyQueryParams as p}from"../../../utils/helper.js";import{setSavedLastViewedProductsResponse as g,getLastViewedProducts as I,waitForCustomerStoreInit as E}from"../../stores/customer/index.js";import{getIkasFilterCategorySlug as C,getIkasFilterCategoryHref as S}from"../filter-category/index.js";import{getFilterValueList as A,clearFilter as y,selectFilterValue as T,onNumberRangeFilterOptionClick as R,getFilterKeyList as D,applyQueryParamForFilter as h,initIkasProductFilter as _,isCustomValueFilter as m}from"../product/filter/index.js";import{getProductVariantPrice as b,hasProductVariantStock as N}from"../product/variant/index.js";var L;function O(t){var r=e({data:[],limit:10,page:1,count:0,isInitialized:!1,isLoading:!1,type:"ALL",sort:"DEFAULT",searchKeyword:"",pageType:"CATEGORY",category:null,brand:null,productListPropValue:{id:"",productIds:[],initialLimit:10,productListType:"ALL"}},t);return function(e){var t;if((null===(t=e.pageSpecificData)||void 0===t?void 0:t.orderType)&&["ALL"].includes(e.type))switch(e.pageSpecificData.orderType){case"HIGHEST_DISCOUNT_RATIO":e.sort="DECRASING_DISCOUNT";break;case"LOWEST_DISCOUNT_RATIO":e.sort="INCREASING_DISCOUNT";break;case"HIGHEST_PRICE":e.sort="DECREASING_PRICE";break;case"LOWEST_PRICE":e.sort="INCREASING_PRICE";break;case"NEWEST":e.sort="LAST_ADDED";break;case"OLDEST":e.sort="FIRST_ADDED";break;case"MANUALLY":e.sort="FEATURED"}}(r),z(r),J(r),r}function P(e){var t;if(d()&&(!l()||!o.isFromBFCache)){!function(e){var t=c(),r=null==t?void 0:t.get("page");if(r){var n=parseInt(r);isNaN(n)||(e.page=n,e.infiniteScrollPage=n)}}(e);if(["CATEGORY","BRAND","SEARCH"].includes(e.pageType)&&location.search&&U(e)&&((null===(t=e.productListPropValue)||void 0===t?void 0:t.usePageFilter)||"SEARCH"===e.type))le(e,c(),e.page>1);else e.page>1?le(e,void 0,!0):k(e)?le(e):Re(e)}}function G(e,t){t!==e.searchKeyword&&(e.searchKeyword=t,_e(e),me(e))}function U(e){return"ALL"===e.type||"CATEGORY"===e.type}function V(e){var t,r;return(null===(t=e.filters)||void 0===t?void 0:t.some(function(e){return!!A(e).length}))||!!e.searchKeyword||"CATEGORY"!==e.pageType&&(!!e.filterCategoryId||!!(null===(r=e.filterCategories)||void 0===r?void 0:r.some(function(e){return e.isSelected})))}function w(e){return"STATIC"===e.type}function F(e){return"DISCOUNTED"===e.type}function j(e){return"RECOMMENDED"===e.type}function k(e){return"LAST_VIEWED"===e.type}function x(e){return"RELATED_PRODUCTS"===e.type}function H(e){return"VIEWED_TOGETHER"===e.type}function W(e){return"PURCHASED_TOGETHER"===e.type}function K(e){return"SEARCH"===e.type}function B(e){return!(w(e)||F(e)||j(e)||!e.minPage)&&e.minPage>1}function Y(e){return!(w(e)||F(e)||j(e))&&e.page*e.limit<e.count}function Z(e){var t;return(null===(t=e.filterCategories)||void 0===t?void 0:t.filter(function(e){return 0!==e.resultCount}))||[]}function M(e){var t;return!!e.searchKeyword||!!(null===(t=e.filters)||void 0===t?void 0:t.some(function(e){return!!A(e).length}))}function q(e){var t;return"MANUALLY"===(null===(t=e.pageSpecificData)||void 0===t?void 0:t.orderType)&&["ALL","CATEGORY"].includes(e.type)}function z(e){var t=V(e);e.data.forEach(function(e){return e.isFiltered=t||!1})}function J(e){var t=w(e);e.data.forEach(function(e){return e.isFiltered=t||!1})}function X(e){e._enableSuggestions=!0}function Q(e){var t={};return e.categoryId&&(t.categoryId=e.categoryId),e.brandId&&(t.brandId=e.brandId),Object.keys(t).length?s("/search?suggestion=".concat(encodeURIComponent(JSON.stringify(t)))):s("/search")}function $(i,a,o,s){return t(this,void 0,void 0,function(){var t,u,d,l,f,v,p,g,I,E,C,S,y,T,R,D;return r(this,function(r){switch(r.label){case 0:return t=[],u=[],null===(S=i.filters)||void 0===S||S.forEach(function(e){var r=A(e);r.length&&t.push({id:e.id,type:e.type,displayType:e.displayType,valueList:r}),e.isFacetFilter&&u.push({id:e.id,type:e.type,displayType:e.displayType})}),d=c(),(l=null==d?void 0:d.get("suggestion"))&&(f=JSON.parse(decodeURIComponent(l)),(v=f.brandId)&&((p=null===(y=i.filters)||void 0===y?void 0:y.find(function(e){return"brand"===e.id&&"BRAND"===e.type}))&&(g=null===(T=p.values)||void 0===T?void 0:T.find(function(e){return e.id===v}))&&h(p,g.name),t.push({id:"brand",type:"BRAND",displayType:"BOX",valueList:[v]})),f.categoryId&&(i.filterCategoryId=f.categoryId),i.searchKeyword=f.term),I=null===(R=i.filterCategories)||void 0===R?void 0:R.filter(function(e){return e.isSelected}).map(function(e){return e.id}),E=function(e){var t,r;switch(e.sort){case"INCREASING_PRICE":t="ASC",r="PRICE";break;case"DECREASING_PRICE":t="DESC",r="PRICE";break;case"FIRST_ADDED":t="ASC",r="CREATED_AT";break;case"LAST_ADDED":t="DESC",r="CREATED_AT";break;case"INCREASING_DISCOUNT":t="ASC",r="DISCOUNT_RATIO";break;case"DECRASING_DISCOUNT":t="DESC",r="DISCOUNT_RATIO";break;case"FEATURED":if(K(e))return;t="ASC",r="MANUAL_SORT";break;case"DEFAULT":t=void 0,r=void 0;break;case"AVERAGE_RATING":t="DESC",r="AVERAGE_RATING";break;case"REVIEW_COUNT":t="DESC",r="REVIEW_COUNT";break;case"SALE_COUNT":t="DESC",r="SALE_COUNT";break;case"A_Z":t="ASC",r="NAME";break;case"Z_A":t="DESC",r="NAME"}if(t&&r)return{direction:t,type:r}}(i),j(i)&&i.recommendedProductData?[4,import("../../api/product/index.js")]:[3,3];case 1:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,brandIds:i.recommendedProductData.brandIds,categoryIds:i.recommendedProductData.categoryIds,locale:n.getCurrentLocale()})];case 2:case 5:case 8:case 11:case 14:return[2,r.sent()];case 3:return x(i)&&i.relatedProductData?[4,import("../../api/product/index.js")]:[3,6];case 4:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,productId:i.relatedProductData.productId,brandIds:i.relatedProductData.brandIds,categoryIds:i.relatedProductData.categoryIds,locale:n.getCurrentLocale()})];case 6:return H(i)&&i.viewedTogetherProductData?[4,import("../../api/product/index.js")]:[3,9];case 7:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,method:"VIEWED_TOGETHER",productIds:i.viewedTogetherProductData.productIds,locale:n.getCurrentLocale()})];case 9:return W(i)&&i.purchasedTogetherProductData?[4,import("../../api/product/index.js")]:[3,12];case 10:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,method:"PURCHASED_TOGETHER",productIds:i.purchasedTogetherProductData.productIds,locale:n.getCurrentLocale()})];case 12:return C={input:e(e(e(e({page:a,perPage:o},i._enableSuggestions?{enableSuggestions:i._enableSuggestions}:{}),{productIdList:w(i)?null===(D=i.productListPropValue.productIds)||void 0===D?void 0:D.map(function(e){return e.productId}):s,filterList:t,facetList:u}),i.baseCategoryIdList?{baseCategoryIdList:i.baseCategoryIdList}:{}),{brandId:"BRAND"===i.pageType&&"SEARCH"!==i.type?i.filterBrandId:void 0,categoryIdList:I&&I.length?I:i.filterCategoryId?[i.filterCategoryId]:void 0,priceListId:n.priceListId,salesChannelId:n.salesChannelId,query:i.searchKeyword,order:E?[E]:[],showStockOption:n.stockPreference||"SHOW_ALL"})},[4,import("../../api/product/index.js")];case 13:return[4,(0,r.sent().apiSearchProducts)(C,i.excludedFields||[])]}})})}function ee(e){return t(this,void 0,void 0,function(){var t,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:return[4,import("../../api/product/index.js")];case 1:return[4,(0,r.sent().apiGetProductFilterData)({categoryId:e.filterCategoryId?e.filterCategoryId:void 0,locale:n.getCurrentLocale()})];case 2:return t=r.sent(),e.filters=null===(a=null==t?void 0:t.data)||void 0===a?void 0:a.filters.map(function(e){return _(e)}),e.filterCategories=null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.categories,ye(e),e.disabledSortTypes=null===(s=t.data)||void 0===s?void 0:s.disabledSortTypes,"CATEGORY"!==e.pageType&&e.filterCategoryId&&(i=null===(u=e.filterCategories)||void 0===u?void 0:u.find(function(t){return t.id===e.filterCategoryId}))&&(i.isSelected=!0),e.filters&&e.filters.sort(function(e,t){return e.order>t.order?1:-1}),[2]}})})}function te(e){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return[4,le(e)];case 1:return t=r.sent(),["CATEGORY","BRAND","SEARCH"].includes(e.pageType)?(t&&ne(e),[2]):[2]}})})}function re(e){var t,r,n,i={};if(null===(t=e.filters)||void 0===t||t.forEach(function(e){var t=D(e);t.length&&(i[v(e.name)]=t)}),e.searchKeyword&&(i.s=e.searchKeyword),e.sort&&(i.o=be[e.sort]),e.baseCategoryIdList&&(i.bc=e.baseCategoryIdList),e.suggestionCategoryId&&(i.suggestionCategoryId=e.suggestionCategoryId),e.infiniteScrollPage?i.page=e.infiniteScrollPage:i.page=e.page,"CATEGORY"!==e.pageType){var a=null===(r=e.filterCategories)||void 0===r?void 0:r.filter(function(e){return e.isSelected});if(!!(null==a?void 0:a.length))i.c=null==a?void 0:a.map(function(e){return C(e)});else if(e.filterCategoryId){var o=null===(n=e.filterCategories)||void 0===n?void 0:n.find(function(t){return t.id===e.filterCategoryId}),s=o?C(o):void 0;s&&(i.c=s)}}return p(i,{arrayFormat:"comma"})}function ne(e){if(d()&&!K(e)&&!n.isEditor){var t=re(e),r=s("".concat(location.pathname).concat(t?"?"+t:""));o.navigate(r,!0)}}function ie(e){var t,r;null===(t=e.filters)||void 0===t||t.forEach(function(e){return y(e)}),e.searchKeyword="","CATEGORY"!==e.pageType&&(e.filterCategoryId=void 0),null===(r=e.filterCategories)||void 0===r||r.forEach(function(e){return e.isSelected=!1}),te(e)}function ae(e,t){y(t),te(e)}function oe(e,t,r){T(t,r),te(e)}function se(e,t,r){R(t,r),te(e)}function ue(e){var t,r=null===(t=e.filters)||void 0===t?void 0:t.filter(function(e){var t;return null===(t=e.values)||void 0===t?void 0:t.some(function(e){return e.isSelected})});return null==r?void 0:r.map(function(e){var t,r;return e.numberRange?{filter:e,values:[e.numberRange.from+"-"+e.numberRange.to],commaSeperatedValues:e.numberRange.from+"-"+e.numberRange.to}:e.numberRangeListOptions?{filter:e,values:e.numberRangeListOptions.filter(function(e){return e.isSelected}).map(function(e){return e.from+"-"+e.to}),commaSeperatedValues:e.numberRangeListOptions.filter(function(e){return e.isSelected}).map(function(e){return e.from+"-"+e.to}).join(",")}:{filter:e,values:(null===(t=e.values)||void 0===t?void 0:t.filter(function(e){return e.isSelected}).map(function(e){return e.name}))||[],commaSeperatedValues:(null===(r=e.values)||void 0===r?void 0:r.filter(function(e){return e.isSelected}).map(function(e){return e.name}).join(","))||""}})}function de(e){return e.variants[0]}function le(e,n,a){return t(this,void 0,void 0,function(){var t,o,s,l,c,f,v,p,S,A,y,T,R,D,_,b,L;return r(this,function(r){switch(r.label){case 0:e.isLoading=!0,t=Date.now(),e.fetchRequestTime=t,r.label=1;case 1:return r.trys.push([1,14,15,16]),o=a?e.page:1,s=e.limit,!U(e)||e.filters?[3,3]:[4,ee(e)];case 2:r.sent(),r.label=3;case 3:return function(e,t){var r;try{null==t||t.forEach(function(t,r){var n,i=null===(n=e.filters)||void 0===n?void 0:n.find(function(e){return e.key===r});i&&h(i,t)});var n=null==t?void 0:t.get("s");n&&(e.searchKeyword=n);var i=null==t?void 0:t.get("o");if(i){var a=parseInt(i),o=Object.entries(be).find(function(e){return e[1]===a});o&&(e.sort=o[0])}if("CATEGORY"!==e.pageType){var s=null==t?void 0:t.get("c"),u=null==s?void 0:s.split(",");u&&u.length&&(null===(r=e.filterCategories)||void 0===r||r.forEach(function(e){e.isSelected=u.some(function(t){return t===C(e)})}))}if("SEARCH"===e.pageType){var d=null==t?void 0:t.get("bc"),l=null==d?void 0:d.split(",");l&&(e.baseCategoryIdList=l);var c=null==t?void 0:t.get("suggestion");if(c){var f=JSON.parse(decodeURIComponent(c)).categoryId;f&&(e.suggestionCategoryId=f)}var v=null==t?void 0:t.get("suggestionCategoryId");v&&(e.suggestionCategoryId=v,e.filterCategoryId=v)}}catch(e){console.log(e)}}(e,n),[4,fe(e)];case 4:return r.sent(),K(e)&&!M(e)?(e.data=[],e.page=1,e.minPage=1,e.count=0,e.isInitialized=!0,[2,!0]):(l=void 0,c=!1,w(e)?(o=void 0,s=200,[3,10]):[3,5]);case 5:return F(e)||j(e)?(o=1,s=10,[3,10]):[3,6];case 6:return k(e)?d()?[4,E(u)]:[3,9]:[3,10];case 7:return r.sent(),[4,I(u)];case 8:return(f=r.sent())&&f.length?(l=f.map(function(e){return e.productId}),c=u.useLastViewedProductResponse,[3,10]):[2];case 9:return[2];case 10:return c?(p=u._savedLastViewedProductsResponse,[3,13]):[3,11];case 11:return[4,$(e,o||1,s||10,l)];case 12:p=r.sent(),r.label=13;case 13:return(v=p)&&e.fetchRequestTime===t?(S=[],!c&&k(e)&&g(u,v),w(e)||k(e)?(A=w(e),y=A?e.productListPropValue.productIds:u._lastViewedProducts,S=(null==y?void 0:y.map(function(e){var t,r,n=null===(r=null===(t=v.data)||void 0===t?void 0:t.data)||void 0===r?void 0:r.find(function(t){return t.id===e.productId}),i=null==n?void 0:n.variants.find(function(t){return t.id===e.variantId});if((null==i?void 0:i.isActive)&&N(i)||(i=null==n?void 0:n.variants.find(function(e){return e.isActive&&N(e)}),A&&!i&&(i=(null==n?void 0:n.variants.find(function(e){return e.isActive}))||(null==n?void 0:n.variants[0]))),n&&i)return n.selectedVariantValues=i.variantValues,n}).filter(function(e){return!!e}))||[]):S=(null===(D=null===(R=v.data)||void 0===R?void 0:R.data)||void 0===D?void 0:D.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}))||[],null===(_=e.filters)||void 0===_||_.forEach(function(e){var t,r;if(void 0===e.isCollapsed){var n=!1;(!1===(null===(t=e.settings)||void 0===t?void 0:t.showCollapsedOnMobile)&&d()&&window.innerWidth<768||!1===(null===(r=e.settings)||void 0===r?void 0:r.showCollapsedOnDesktop))&&(n=!0),e.isCollapsed=!n}}),function(e,t){var r,n,a=i(e);null===(r=a.filters)||void 0===r||r.forEach(function(e){var r,n,i,a=null==t?void 0:t.find(function(t){return t.id===e.id});a?null===(r=e.values)||void 0===r||r.forEach(function(t){var r=a.values.find(function(e){return e.id===t.id});r?t.resultCount=r.count:m(e)?t.resultCount=null:t.resultCount=0}):m(e)?null===(n=e.values)||void 0===n||n.forEach(function(e){return e.resultCount=null}):null===(i=e.values)||void 0===i||i.forEach(function(e){return e.resultCount=0})});var o=null==t?void 0:t.find(function(e){return"category"===e.id});o&&(null===(n=a.filterCategories)||void 0===n||n.forEach(function(e){var t=o.values.find(function(t){return t.id===e.id});e.resultCount=t?t.count:0})),e.filters=a.filters,e.filterCategories=a.filterCategories,ye(e)}(e,null===(b=v.data)||void 0===b?void 0:b.facets),e.data=S,e.count=(null===(L=v.data)||void 0===L?void 0:L.count)||0,e.isInitialized=!0,e.page=o||1,e.minPage=e.page,v.data&&"suggestions"in v.data&&(e.suggestions=v.data.suggestions),z(e),J(e),a||(e.infiniteScrollPage=null),Re(e),[2,!0]):[2];case 14:return T=r.sent(),console.log(T),[3,16];case 15:return t===e.fetchRequestTime&&(e.isLoading=!1),[7];case 16:return[2]}})})}function ce(e){e.isCollapsed=!e.isCollapsed}function fe(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s,u,d,l,c;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,13,,14]),e.productListPropValue.category?[4,import("../../api/category/index.js")]:[3,3];case 1:return[4,(0,r.sent().apiListCategory)({id:{eq:e.productListPropValue.category}})];case 2:return t=r.sent(),e.category=(null===(o=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===o?void 0:o[0])||null,[3,7];case 3:return e.productListPropValue.usePageFilter&&"CATEGORY"===e.pageType&&e.pageSpecificData?(e.category=e.pageSpecificData,[3,7]):[3,4];case 4:return e.filterCategoryId?[4,import("../../api/category/index.js")]:[3,7];case 5:return[4,(0,r.sent().apiListCategory)({id:{eq:e.filterCategoryId}})];case 6:t=r.sent(),e.category=(null===(u=null===(s=t.data)||void 0===s?void 0:s.data)||void 0===u?void 0:u[0])||null,r.label=7;case 7:return e.productListPropValue.usePageFilter&&"BRAND"===e.pageType&&e.pageSpecificData?(e.brand=e.pageSpecificData,[3,12]):[3,8];case 8:return e.filterBrandId?e.filterBrandId!==(null===(d=e.pageSpecificData)||void 0===d?void 0:d.id)?[3,9]:(e.brand=e.pageSpecificData,[3,12]):[3,12];case 9:return[4,import("../../api/brand/index.js")];case 10:return[4,(0,r.sent().apiListProductBrand)({id:{eq:e.filterBrandId}})];case 11:n=r.sent(),e.brand=(null===(c=null===(l=n.data)||void 0===l?void 0:l.data)||void 0===c?void 0:c[0])||null,r.label=12;case 12:return[3,14];case 13:return i=r.sent(),console.error(i),[3,14];case 14:return[2]}})})}function ve(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:if(w(e)||F(e)||j(e)||x(e)||H(e)||W(e)||k(e)||e.isLoading||!B(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),t=e.minPage-1,[4,$(e,t,e.limit)];case 2:return(n=r.sent())?(i=null===(s=null===(o=n.data)||void 0===o?void 0:o.data)||void 0===s?void 0:s.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=(null==i?void 0:i.concat(e.data))||e.data,e.count=(null===(u=n.data)||void 0===u?void 0:u.count)||e.count,e.minPage=t,z(e),J(e),ne(e),[3,5]):[2];case 3:return a=r.sent(),console.log(a),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function pe(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s;return r(this,function(r){switch(r.label){case 0:if(w(e)||F(e)||j(e)||x(e)||H(e)||W(e)||k(e)||e.isLoading||!Y(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,$(e,e.page+1,e.limit)];case 2:return(t=r.sent())?(n=null===(o=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===o?void 0:o.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=e.data.concat(n||[]),e.count=(null===(s=t.data)||void 0===s?void 0:s.count)||e.count,e.page=e.page+1,z(e),J(e),ne(e),[3,5]):[2];case 3:return i=r.sent(),console.log(i),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function ge(e,n){return t(this,void 0,void 0,function(){var t,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:if(e.isLoading||w(e)||F(e)||j(e)||k(e)||x(e)||H(e)||W(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,$(e,n,e.limit)];case 2:return(t=r.sent())?(i=null===(s=null===(o=t.data)||void 0===o?void 0:o.data)||void 0===s?void 0:s.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=i||[],e.count=(null===(u=t.data)||void 0===u?void 0:u.count)||0,e.page=n,e.minPage=n,z(e),J(e),ne(e),[3,5]):[2];case 3:return a=r.sent(),console.log(a),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function Ie(e,n){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.sort=n,[4,le(e)];case 1:return t.sent()&&ne(e),[2]}})})}function Ee(e){return Ce(e,e.sort)}function Ce(e,t){switch(t){case"INCREASING_PRICE":return a.translate("sort_type.increasing_price");case"DECREASING_PRICE":return a.translate("sort_type.decreasing_price");case"LAST_ADDED":return a.translate("sort_type.last_added");case"FIRST_ADDED":return a.translate("sort_type.first_added");case"INCREASING_DISCOUNT":return a.translate("sort_type.increasing_discount");case"DECRASING_DISCOUNT":return a.translate("sort_type.decreasing_discount");case"FEATURED":return a.translate("sort_type.featured");case"DEFAULT":return a.translate("sort_type.default");case"AVERAGE_RATING":return a.translate("sort_type.average_rating");case"REVIEW_COUNT":return a.translate("sort_type.review_count");case"SALE_COUNT":return a.translate("sort_type.sale_count");case"A_Z":return a.translate("sort_type.a_z");case"Z_A":return a.translate("sort_type.z_a")}}function Se(e){var t,r,n,i,a,o,s,u;if(!e)return[];var d=[];return(null===(t=e.disabledSortTypes)||void 0===t?void 0:t.includes("NAME"))||(d.push({label:Ce(0,"A_Z"),value:"A_Z",isSelected:"A_Z"===e.sort}),d.push({label:Ce(0,"Z_A"),value:"Z_A",isSelected:"Z_A"===e.sort})),(null===(r=e.disabledSortTypes)||void 0===r?void 0:r.includes("PRICE"))||(d.push({label:Ce(0,"INCREASING_PRICE"),value:"INCREASING_PRICE",isSelected:"INCREASING_PRICE"===e.sort}),d.push({label:Ce(0,"DECREASING_PRICE"),value:"DECREASING_PRICE",isSelected:"DECREASING_PRICE"===e.sort})),(null===(n=e.disabledSortTypes)||void 0===n?void 0:n.includes("CREATED_AT"))||(d.push({label:Ce(0,"LAST_ADDED"),value:"LAST_ADDED",isSelected:"LAST_ADDED"===e.sort}),d.push({label:Ce(0,"FIRST_ADDED"),value:"FIRST_ADDED",isSelected:"FIRST_ADDED"===e.sort})),(null===(i=e.disabledSortTypes)||void 0===i?void 0:i.includes("DISCOUNT_RATIO"))||(d.push({label:Ce(0,"INCREASING_DISCOUNT"),value:"INCREASING_DISCOUNT",isSelected:"INCREASING_DISCOUNT"===e.sort}),d.push({label:Ce(0,"DECRASING_DISCOUNT"),value:"DECRASING_DISCOUNT",isSelected:"DECRASING_DISCOUNT"===e.sort})),(null===(a=e.disabledSortTypes)||void 0===a?void 0:a.includes("MANUAL_SORT"))||d.push({label:Ce(0,"FEATURED"),value:"FEATURED",isSelected:"FEATURED"===e.sort}),(null===(o=e.disabledSortTypes)||void 0===o?void 0:o.includes("AVERAGE_RATING"))||d.push({label:Ce(0,"AVERAGE_RATING"),value:"AVERAGE_RATING",isSelected:"AVERAGE_RATING"===e.sort}),(null===(s=e.disabledSortTypes)||void 0===s?void 0:s.includes("REVIEW_COUNT"))||d.push({label:Ce(0,"REVIEW_COUNT"),value:"REVIEW_COUNT",isSelected:"REVIEW_COUNT"===e.sort}),(null===(u=e.disabledSortTypes)||void 0===u?void 0:u.includes("SALE_COUNT"))||d.push({label:Ce(0,"SALE_COUNT"),value:"SALE_COUNT",isSelected:"SALE_COUNT"===e.sort}),d}function Ae(e,i,a){return t(this,void 0,void 0,function(){var t,s,u;return r(this,function(r){switch(r.label){case 0:return a?(null===(u=e.filterCategories)||void 0===u||u.forEach(function(e){e.id===i.id&&(e.isSelected=!e.isSelected)}),[4,te(e)]):[3,2];case 1:return r.sent(),[3,3];case 2:n.isEditor||(t=re(e),s=S(i)+(t?"?"+t:""),o.navigate(s)),r.label=3;case 3:return[2]}})})}function ye(e){var t;null===(t=e.filterCategories)||void 0===t||t.forEach(function(e){e.image=e.imageId?{id:e.imageId,isVideo:!1}:null})}function Te(e,t){if(e.infiniteScrollPage!==t){e.infiniteScrollPage=t;var r=re(e);o.navigate("".concat(location.pathname).concat(r?"?"+r:""),!0)}}function Re(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.searchKeyword&&e.data.length?[4,import("../../../analytics/analytics-functions/viewSearchResults.js")]:[3,2];case 1:return(0,t.sent().anl_viewSearchResults)(e.searchKeyword,e.data),[3,4];case 2:return e.data.length&&"ALL"===e.type?[4,import("../../../analytics/analytics-functions/viewListing.js")]:[3,4];case 3:(0,t.sent().anl_viewListing)(e.data),t.label=4;case 4:return[2]}})})}function De(e){var t=e.data[0];if(!t)return n.getDefaultCurrencyCode()||"";var r=de(t),i=b(r);return(null==i?void 0:i.currency)||n.getDefaultCurrencyCode()||""}function he(e){var t=e.data[0];if(!t)return n.getDefaultCurrencySymbol()||"";var r=de(t),i=b(r);return(null==i?void 0:i.currencySymbol)||n.getDefaultCurrencySymbol()||""}var _e=f(function(e){te(e)},500),me=f(function(e){return t(void 0,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,import("../../../analytics/analytics-functions/search.js")];case 1:return(0,t.sent().anl_search)(e.searchKeyword),[2]}})})},1e3),be=((L={}).INCREASING_PRICE=1,L.DECREASING_PRICE=2,L.LAST_ADDED=3,L.FIRST_ADDED=4,L.INCREASING_DISCOUNT=5,L.DECRASING_DISCOUNT=6,L.FEATURED=7,L.DEFAULT=8,L.AVERAGE_RATING=9,L.REVIEW_COUNT=10,L.SALE_COUNT=11,L.A_Z=12,L.Z_A=13,L);export{ae as clearProductListFilter,ie as clearProductListFilters,X as enableProductListSuggestions,De as getProductListCurrencyCode,he as getProductListCurrencySymbol,Z as getProductListFilterCategories,le as getProductListInitialData,pe as getProductListNextPage,ge as getProductListPage,ve as getProductListPrevPage,Se as getProductListSortOptions,Ee as getProductListSortTypeTranslation,Q as getProductListSuggestionHref,ue as getSelectedFilterValues,oe as handleFilterValueClick,se as handleNumberRangeOptionClick,M as hasProductListAppliedFilters,q as hasProductListFeaturedSortEnabled,Y as hasProductListNextPage,B as hasProductListPrevPage,O as initProductList,ye as initProductListFilterCategories,P as initProductListOnBrowser,F as isProductListDiscounted,U as isProductListFilterable,V as isProductListFiltered,k as isProductListLastViewed,W as isProductListPurchasedTogether,j as isProductListRecommended,x as isProductListRelatedProducts,K as isProductListSearch,w as isProductListStatic,H as isProductListViewedTogether,Ae as onFilterCategoryClick,ce as productListToggleFilterCollapsed,G as searchProductList,z as setProductListIsFilteredForProducts,J as setProductListIsStaticForProducts,Te as setProductListVisiblePage,Ie as setSortType,Ce as translateProductListSortType};
1
+ import{__assign as e,__awaiter as t,__generator as r}from'./../../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as n}from"../../../packages/storefront-config/src/index.js";import i from'./../../../ext/lodash/cloneDeep.js';import{I18n as a}from"../../../i18n/index.js";import{Router as o,withRoutePrefix as s}from"../../../router/index.js";import{customerStore as u}from"../../../stores/customer/index.js";import{isClient as d,isBackNavigation as l,getQueryParams as c,debounce as f,stringToSlug as v,stringifyQueryParams as p}from"../../../utils/helper.js";import{setSavedLastViewedProductsResponse as g,getLastViewedProducts as E,waitForCustomerStoreInit as I}from"../../stores/customer/index.js";import{getIkasFilterCategorySlug as C,getIkasFilterCategoryHref as S}from"../filter-category/index.js";import{getFilterValueList as A,clearFilter as y,selectFilterValue as T,onNumberRangeFilterOptionClick as R,getFilterKeyList as D,applyQueryParamForFilter as h,initIkasProductFilter as _,isCustomValueFilter as m}from"../product/filter/index.js";import{getProductVariantPrice as b,hasProductVariantStock as N}from"../product/variant/index.js";var L;function O(t){var r=e({data:[],limit:10,page:1,count:0,isInitialized:!1,isLoading:!1,type:"ALL",sort:"DEFAULT",searchKeyword:"",pageType:"CATEGORY",category:null,brand:null,productListPropValue:{id:"",productIds:[],initialLimit:10,productListType:"ALL"}},t);return function(e){var t;if((null===(t=e.pageSpecificData)||void 0===t?void 0:t.orderType)&&["ALL"].includes(e.type))switch(e.pageSpecificData.orderType){case"BEST_SELLER":e.sort="SALE_COUNT";break;case"HIGHEST_DISCOUNT_RATIO":e.sort="DECRASING_DISCOUNT";break;case"LOWEST_DISCOUNT_RATIO":e.sort="INCREASING_DISCOUNT";break;case"HIGHEST_PRICE":e.sort="DECREASING_PRICE";break;case"LOWEST_PRICE":e.sort="INCREASING_PRICE";break;case"NEWEST":e.sort="LAST_ADDED";break;case"OLDEST":e.sort="FIRST_ADDED";break;case"MANUALLY":e.sort="FEATURED"}}(r),z(r),J(r),r}function P(e){var t;if(d()&&(!l()||!o.isFromBFCache)){!function(e){var t=c(),r=null==t?void 0:t.get("page");if(r){var n=parseInt(r);isNaN(n)||(e.page=n,e.infiniteScrollPage=n)}}(e);if(["CATEGORY","BRAND","SEARCH"].includes(e.pageType)&&location.search&&U(e)&&((null===(t=e.productListPropValue)||void 0===t?void 0:t.usePageFilter)||"SEARCH"===e.type))le(e,c(),e.page>1);else e.page>1?le(e,void 0,!0):k(e)?le(e):Re(e)}}function G(e,t){t!==e.searchKeyword&&(e.searchKeyword=t,_e(e),me(e))}function U(e){return"ALL"===e.type||"CATEGORY"===e.type}function V(e){var t,r;return(null===(t=e.filters)||void 0===t?void 0:t.some(function(e){return!!A(e).length}))||!!e.searchKeyword||"CATEGORY"!==e.pageType&&(!!e.filterCategoryId||!!(null===(r=e.filterCategories)||void 0===r?void 0:r.some(function(e){return e.isSelected})))}function w(e){return"STATIC"===e.type}function F(e){return"DISCOUNTED"===e.type}function j(e){return"RECOMMENDED"===e.type}function k(e){return"LAST_VIEWED"===e.type}function x(e){return"RELATED_PRODUCTS"===e.type}function H(e){return"VIEWED_TOGETHER"===e.type}function W(e){return"PURCHASED_TOGETHER"===e.type}function B(e){return"SEARCH"===e.type}function K(e){return!(w(e)||F(e)||j(e)||!e.minPage)&&e.minPage>1}function Y(e){return!(w(e)||F(e)||j(e))&&e.page*e.limit<e.count}function Z(e){var t;return(null===(t=e.filterCategories)||void 0===t?void 0:t.filter(function(e){return 0!==e.resultCount}))||[]}function M(e){var t;return!!e.searchKeyword||!!(null===(t=e.filters)||void 0===t?void 0:t.some(function(e){return!!A(e).length}))}function q(e){var t;return"MANUALLY"===(null===(t=e.pageSpecificData)||void 0===t?void 0:t.orderType)&&["ALL","CATEGORY"].includes(e.type)}function z(e){var t=V(e);e.data.forEach(function(e){return e.isFiltered=t||!1})}function J(e){var t=w(e);e.data.forEach(function(e){return e.isFiltered=t||!1})}function X(e){e._enableSuggestions=!0}function Q(e){var t={};return e.categoryId&&(t.categoryId=e.categoryId),e.brandId&&(t.brandId=e.brandId),Object.keys(t).length?s("/search?suggestion=".concat(encodeURIComponent(JSON.stringify(t)))):s("/search")}function $(i,a,o,s){return t(this,void 0,void 0,function(){var t,u,d,l,f,v,p,g,E,I,C,S,y,T,R,D;return r(this,function(r){switch(r.label){case 0:return t=[],u=[],null===(S=i.filters)||void 0===S||S.forEach(function(e){var r=A(e);r.length&&t.push({id:e.id,type:e.type,displayType:e.displayType,valueList:r}),e.isFacetFilter&&u.push({id:e.id,type:e.type,displayType:e.displayType})}),d=c(),(l=null==d?void 0:d.get("suggestion"))&&(f=JSON.parse(decodeURIComponent(l)),(v=f.brandId)&&((p=null===(y=i.filters)||void 0===y?void 0:y.find(function(e){return"brand"===e.id&&"BRAND"===e.type}))&&(g=null===(T=p.values)||void 0===T?void 0:T.find(function(e){return e.id===v}))&&h(p,g.name),t.push({id:"brand",type:"BRAND",displayType:"BOX",valueList:[v]})),f.categoryId&&(i.filterCategoryId=f.categoryId),i.searchKeyword=f.term),E=null===(R=i.filterCategories)||void 0===R?void 0:R.filter(function(e){return e.isSelected}).map(function(e){return e.id}),I=function(e){var t,r;switch(e.sort){case"INCREASING_PRICE":t="ASC",r="PRICE";break;case"DECREASING_PRICE":t="DESC",r="PRICE";break;case"FIRST_ADDED":t="ASC",r="CREATED_AT";break;case"LAST_ADDED":t="DESC",r="CREATED_AT";break;case"INCREASING_DISCOUNT":t="ASC",r="DISCOUNT_RATIO";break;case"DECRASING_DISCOUNT":t="DESC",r="DISCOUNT_RATIO";break;case"FEATURED":if(B(e))return;t="ASC",r="MANUAL_SORT";break;case"DEFAULT":t=void 0,r=void 0;break;case"AVERAGE_RATING":t="DESC",r="AVERAGE_RATING";break;case"REVIEW_COUNT":t="DESC",r="REVIEW_COUNT";break;case"SALE_COUNT":t="DESC",r="SALE_COUNT";break;case"A_Z":t="ASC",r="NAME";break;case"Z_A":t="DESC",r="NAME"}if(t&&r)return{direction:t,type:r}}(i),j(i)&&i.recommendedProductData?[4,import("../../api/product/index.js")]:[3,3];case 1:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,brandIds:i.recommendedProductData.brandIds,categoryIds:i.recommendedProductData.categoryIds,locale:n.getCurrentLocale()})];case 2:case 5:case 8:case 11:case 14:return[2,r.sent()];case 3:return x(i)&&i.relatedProductData?[4,import("../../api/product/index.js")]:[3,6];case 4:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,productId:i.relatedProductData.productId,brandIds:i.relatedProductData.brandIds,categoryIds:i.relatedProductData.categoryIds,locale:n.getCurrentLocale()})];case 6:return H(i)&&i.viewedTogetherProductData?[4,import("../../api/product/index.js")]:[3,9];case 7:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,method:"VIEWED_TOGETHER",productIds:i.viewedTogetherProductData.productIds,locale:n.getCurrentLocale()})];case 9:return W(i)&&i.purchasedTogetherProductData?[4,import("../../api/product/index.js")]:[3,12];case 10:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,method:"PURCHASED_TOGETHER",productIds:i.purchasedTogetherProductData.productIds,locale:n.getCurrentLocale()})];case 12:return C={input:e(e(e(e({page:a,perPage:o},i._enableSuggestions?{enableSuggestions:i._enableSuggestions}:{}),{productIdList:w(i)?null===(D=i.productListPropValue.productIds)||void 0===D?void 0:D.map(function(e){return e.productId}):s,filterList:t,facetList:u}),i.baseCategoryIdList?{baseCategoryIdList:i.baseCategoryIdList}:{}),{brandId:"BRAND"===i.pageType&&"SEARCH"!==i.type?i.filterBrandId:void 0,categoryIdList:E&&E.length?E:i.filterCategoryId?[i.filterCategoryId]:void 0,priceListId:n.priceListId,salesChannelId:n.salesChannelId,query:i.searchKeyword,order:I?[I]:[],showStockOption:n.stockPreference||"SHOW_ALL"})},[4,import("../../api/product/index.js")];case 13:return[4,(0,r.sent().apiSearchProducts)(C,i.excludedFields||[])]}})})}function ee(e){return t(this,void 0,void 0,function(){var t,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:return[4,import("../../api/product/index.js")];case 1:return[4,(0,r.sent().apiGetProductFilterData)({categoryId:e.filterCategoryId?e.filterCategoryId:void 0,locale:n.getCurrentLocale()})];case 2:return t=r.sent(),e.filters=null===(a=null==t?void 0:t.data)||void 0===a?void 0:a.filters.map(function(e){return _(e)}),e.filterCategories=null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.categories,ye(e),e.disabledSortTypes=null===(s=t.data)||void 0===s?void 0:s.disabledSortTypes,"CATEGORY"!==e.pageType&&e.filterCategoryId&&(i=null===(u=e.filterCategories)||void 0===u?void 0:u.find(function(t){return t.id===e.filterCategoryId}))&&(i.isSelected=!0),e.filters&&e.filters.sort(function(e,t){return e.order>t.order?1:-1}),[2]}})})}function te(e){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return[4,le(e)];case 1:return t=r.sent(),["CATEGORY","BRAND","SEARCH"].includes(e.pageType)?(t&&ne(e),[2]):[2]}})})}function re(e){var t,r,n,i={};if(null===(t=e.filters)||void 0===t||t.forEach(function(e){var t=D(e);t.length&&(i[v(e.name)]=t)}),e.searchKeyword&&(i.s=e.searchKeyword),e.sort&&(i.o=be[e.sort]),e.baseCategoryIdList&&(i.bc=e.baseCategoryIdList),e.suggestionCategoryId&&(i.suggestionCategoryId=e.suggestionCategoryId),e.infiniteScrollPage?i.page=e.infiniteScrollPage:i.page=e.page,"CATEGORY"!==e.pageType){var a=null===(r=e.filterCategories)||void 0===r?void 0:r.filter(function(e){return e.isSelected});if(!!(null==a?void 0:a.length))i.c=null==a?void 0:a.map(function(e){return C(e)});else if(e.filterCategoryId){var o=null===(n=e.filterCategories)||void 0===n?void 0:n.find(function(t){return t.id===e.filterCategoryId}),s=o?C(o):void 0;s&&(i.c=s)}}return p(i,{arrayFormat:"comma"})}function ne(e){if(d()&&!B(e)&&!n.isEditor){var t=re(e),r=s("".concat(location.pathname).concat(t?"?"+t:""));o.navigate(r,!0)}}function ie(e){var t,r;null===(t=e.filters)||void 0===t||t.forEach(function(e){return y(e)}),e.searchKeyword="","CATEGORY"!==e.pageType&&(e.filterCategoryId=void 0),null===(r=e.filterCategories)||void 0===r||r.forEach(function(e){return e.isSelected=!1}),te(e)}function ae(e,t){y(t),te(e)}function oe(e,t,r){T(t,r),te(e)}function se(e,t,r){R(t,r),te(e)}function ue(e){var t,r=null===(t=e.filters)||void 0===t?void 0:t.filter(function(e){var t;return null===(t=e.values)||void 0===t?void 0:t.some(function(e){return e.isSelected})});return null==r?void 0:r.map(function(e){var t,r;return e.numberRange?{filter:e,values:[e.numberRange.from+"-"+e.numberRange.to],commaSeperatedValues:e.numberRange.from+"-"+e.numberRange.to}:e.numberRangeListOptions?{filter:e,values:e.numberRangeListOptions.filter(function(e){return e.isSelected}).map(function(e){return e.from+"-"+e.to}),commaSeperatedValues:e.numberRangeListOptions.filter(function(e){return e.isSelected}).map(function(e){return e.from+"-"+e.to}).join(",")}:{filter:e,values:(null===(t=e.values)||void 0===t?void 0:t.filter(function(e){return e.isSelected}).map(function(e){return e.name}))||[],commaSeperatedValues:(null===(r=e.values)||void 0===r?void 0:r.filter(function(e){return e.isSelected}).map(function(e){return e.name}).join(","))||""}})}function de(e){return e.variants[0]}function le(e,n,a){return t(this,void 0,void 0,function(){var t,o,s,l,c,f,v,p,S,A,y,T,R,D,_,b,L;return r(this,function(r){switch(r.label){case 0:e.isLoading=!0,t=Date.now(),e.fetchRequestTime=t,r.label=1;case 1:return r.trys.push([1,14,15,16]),o=a?e.page:1,s=e.limit,!U(e)||e.filters?[3,3]:[4,ee(e)];case 2:r.sent(),r.label=3;case 3:return function(e,t){var r;try{null==t||t.forEach(function(t,r){var n,i=null===(n=e.filters)||void 0===n?void 0:n.find(function(e){return e.key===r});i&&h(i,t)});var n=null==t?void 0:t.get("s");n&&(e.searchKeyword=n);var i=null==t?void 0:t.get("o");if(i){var a=parseInt(i),o=Object.entries(be).find(function(e){return e[1]===a});o&&(e.sort=o[0])}if("CATEGORY"!==e.pageType){var s=null==t?void 0:t.get("c"),u=null==s?void 0:s.split(",");u&&u.length&&(null===(r=e.filterCategories)||void 0===r||r.forEach(function(e){e.isSelected=u.some(function(t){return t===C(e)})}))}if("SEARCH"===e.pageType){var d=null==t?void 0:t.get("bc"),l=null==d?void 0:d.split(",");l&&(e.baseCategoryIdList=l);var c=null==t?void 0:t.get("suggestion");if(c){var f=JSON.parse(decodeURIComponent(c)).categoryId;f&&(e.suggestionCategoryId=f)}var v=null==t?void 0:t.get("suggestionCategoryId");v&&(e.suggestionCategoryId=v,e.filterCategoryId=v)}}catch(e){console.log(e)}}(e,n),[4,fe(e)];case 4:return r.sent(),B(e)&&!M(e)?(e.data=[],e.page=1,e.minPage=1,e.count=0,e.isInitialized=!0,[2,!0]):(l=void 0,c=!1,w(e)?(o=void 0,s=200,[3,10]):[3,5]);case 5:return F(e)||j(e)?(o=1,s=10,[3,10]):[3,6];case 6:return k(e)?d()?[4,I(u)]:[3,9]:[3,10];case 7:return r.sent(),[4,E(u)];case 8:return(f=r.sent())&&f.length?(l=f.map(function(e){return e.productId}),c=u.useLastViewedProductResponse,[3,10]):[2];case 9:return[2];case 10:return c?(p=u._savedLastViewedProductsResponse,[3,13]):[3,11];case 11:return[4,$(e,o||1,s||10,l)];case 12:p=r.sent(),r.label=13;case 13:return(v=p)&&e.fetchRequestTime===t?(S=[],!c&&k(e)&&g(u,v),w(e)||k(e)?(A=w(e),y=A?e.productListPropValue.productIds:u._lastViewedProducts,S=(null==y?void 0:y.map(function(e){var t,r,n=null===(r=null===(t=v.data)||void 0===t?void 0:t.data)||void 0===r?void 0:r.find(function(t){return t.id===e.productId}),i=null==n?void 0:n.variants.find(function(t){return t.id===e.variantId});if((null==i?void 0:i.isActive)&&N(i)||(i=null==n?void 0:n.variants.find(function(e){return e.isActive&&N(e)}),A&&!i&&(i=(null==n?void 0:n.variants.find(function(e){return e.isActive}))||(null==n?void 0:n.variants[0]))),n&&i)return n.selectedVariantValues=i.variantValues,n}).filter(function(e){return!!e}))||[]):S=(null===(D=null===(R=v.data)||void 0===R?void 0:R.data)||void 0===D?void 0:D.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}))||[],null===(_=e.filters)||void 0===_||_.forEach(function(e){var t,r;if(void 0===e.isCollapsed){var n=!1;(!1===(null===(t=e.settings)||void 0===t?void 0:t.showCollapsedOnMobile)&&d()&&window.innerWidth<768||!1===(null===(r=e.settings)||void 0===r?void 0:r.showCollapsedOnDesktop))&&(n=!0),e.isCollapsed=!n}}),function(e,t){var r,n,a=i(e);null===(r=a.filters)||void 0===r||r.forEach(function(e){var r,n,i,a=null==t?void 0:t.find(function(t){return t.id===e.id});a?null===(r=e.values)||void 0===r||r.forEach(function(t){var r=a.values.find(function(e){return e.id===t.id});r?t.resultCount=r.count:m(e)?t.resultCount=null:t.resultCount=0}):m(e)?null===(n=e.values)||void 0===n||n.forEach(function(e){return e.resultCount=null}):null===(i=e.values)||void 0===i||i.forEach(function(e){return e.resultCount=0})});var o=null==t?void 0:t.find(function(e){return"category"===e.id});o&&(null===(n=a.filterCategories)||void 0===n||n.forEach(function(e){var t=o.values.find(function(t){return t.id===e.id});e.resultCount=t?t.count:0})),e.filters=a.filters,e.filterCategories=a.filterCategories,ye(e)}(e,null===(b=v.data)||void 0===b?void 0:b.facets),e.data=S,e.count=(null===(L=v.data)||void 0===L?void 0:L.count)||0,e.isInitialized=!0,e.page=o||1,e.minPage=e.page,v.data&&"suggestions"in v.data&&(e.suggestions=v.data.suggestions),z(e),J(e),a||(e.infiniteScrollPage=null),Re(e),[2,!0]):[2];case 14:return T=r.sent(),console.log(T),[3,16];case 15:return t===e.fetchRequestTime&&(e.isLoading=!1),[7];case 16:return[2]}})})}function ce(e){e.isCollapsed=!e.isCollapsed}function fe(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s,u,d,l,c;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,13,,14]),e.productListPropValue.category?[4,import("../../api/category/index.js")]:[3,3];case 1:return[4,(0,r.sent().apiListCategory)({id:{eq:e.productListPropValue.category}})];case 2:return t=r.sent(),e.category=(null===(o=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===o?void 0:o[0])||null,[3,7];case 3:return e.productListPropValue.usePageFilter&&"CATEGORY"===e.pageType&&e.pageSpecificData?(e.category=e.pageSpecificData,[3,7]):[3,4];case 4:return e.filterCategoryId?[4,import("../../api/category/index.js")]:[3,7];case 5:return[4,(0,r.sent().apiListCategory)({id:{eq:e.filterCategoryId}})];case 6:t=r.sent(),e.category=(null===(u=null===(s=t.data)||void 0===s?void 0:s.data)||void 0===u?void 0:u[0])||null,r.label=7;case 7:return e.productListPropValue.usePageFilter&&"BRAND"===e.pageType&&e.pageSpecificData?(e.brand=e.pageSpecificData,[3,12]):[3,8];case 8:return e.filterBrandId?e.filterBrandId!==(null===(d=e.pageSpecificData)||void 0===d?void 0:d.id)?[3,9]:(e.brand=e.pageSpecificData,[3,12]):[3,12];case 9:return[4,import("../../api/brand/index.js")];case 10:return[4,(0,r.sent().apiListProductBrand)({id:{eq:e.filterBrandId}})];case 11:n=r.sent(),e.brand=(null===(c=null===(l=n.data)||void 0===l?void 0:l.data)||void 0===c?void 0:c[0])||null,r.label=12;case 12:return[3,14];case 13:return i=r.sent(),console.error(i),[3,14];case 14:return[2]}})})}function ve(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:if(w(e)||F(e)||j(e)||x(e)||H(e)||W(e)||k(e)||e.isLoading||!K(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),t=e.minPage-1,[4,$(e,t,e.limit)];case 2:return(n=r.sent())?(i=null===(s=null===(o=n.data)||void 0===o?void 0:o.data)||void 0===s?void 0:s.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=(null==i?void 0:i.concat(e.data))||e.data,e.count=(null===(u=n.data)||void 0===u?void 0:u.count)||e.count,e.minPage=t,z(e),J(e),ne(e),[3,5]):[2];case 3:return a=r.sent(),console.log(a),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function pe(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s;return r(this,function(r){switch(r.label){case 0:if(w(e)||F(e)||j(e)||x(e)||H(e)||W(e)||k(e)||e.isLoading||!Y(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,$(e,e.page+1,e.limit)];case 2:return(t=r.sent())?(n=null===(o=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===o?void 0:o.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=e.data.concat(n||[]),e.count=(null===(s=t.data)||void 0===s?void 0:s.count)||e.count,e.page=e.page+1,z(e),J(e),ne(e),[3,5]):[2];case 3:return i=r.sent(),console.log(i),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function ge(e,n){return t(this,void 0,void 0,function(){var t,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:if(e.isLoading||w(e)||F(e)||j(e)||k(e)||x(e)||H(e)||W(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,$(e,n,e.limit)];case 2:return(t=r.sent())?(i=null===(s=null===(o=t.data)||void 0===o?void 0:o.data)||void 0===s?void 0:s.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=i||[],e.count=(null===(u=t.data)||void 0===u?void 0:u.count)||0,e.page=n,e.minPage=n,z(e),J(e),ne(e),[3,5]):[2];case 3:return a=r.sent(),console.log(a),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function Ee(e,n){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.sort=n,[4,le(e)];case 1:return t.sent()&&ne(e),[2]}})})}function Ie(e){return Ce(e,e.sort)}function Ce(e,t){switch(t){case"INCREASING_PRICE":return a.translate("sort_type.increasing_price");case"DECREASING_PRICE":return a.translate("sort_type.decreasing_price");case"LAST_ADDED":return a.translate("sort_type.last_added");case"FIRST_ADDED":return a.translate("sort_type.first_added");case"INCREASING_DISCOUNT":return a.translate("sort_type.increasing_discount");case"DECRASING_DISCOUNT":return a.translate("sort_type.decreasing_discount");case"FEATURED":return a.translate("sort_type.featured");case"DEFAULT":return a.translate("sort_type.default");case"AVERAGE_RATING":return a.translate("sort_type.average_rating");case"REVIEW_COUNT":return a.translate("sort_type.review_count");case"SALE_COUNT":return a.translate("sort_type.sale_count");case"A_Z":return a.translate("sort_type.a_z");case"Z_A":return a.translate("sort_type.z_a")}}function Se(e){var t,r,n,i,a,o,s,u;if(!e)return[];var d=[];return(null===(t=e.disabledSortTypes)||void 0===t?void 0:t.includes("NAME"))||(d.push({label:Ce(0,"A_Z"),value:"A_Z",isSelected:"A_Z"===e.sort}),d.push({label:Ce(0,"Z_A"),value:"Z_A",isSelected:"Z_A"===e.sort})),(null===(r=e.disabledSortTypes)||void 0===r?void 0:r.includes("PRICE"))||(d.push({label:Ce(0,"INCREASING_PRICE"),value:"INCREASING_PRICE",isSelected:"INCREASING_PRICE"===e.sort}),d.push({label:Ce(0,"DECREASING_PRICE"),value:"DECREASING_PRICE",isSelected:"DECREASING_PRICE"===e.sort})),(null===(n=e.disabledSortTypes)||void 0===n?void 0:n.includes("CREATED_AT"))||(d.push({label:Ce(0,"LAST_ADDED"),value:"LAST_ADDED",isSelected:"LAST_ADDED"===e.sort}),d.push({label:Ce(0,"FIRST_ADDED"),value:"FIRST_ADDED",isSelected:"FIRST_ADDED"===e.sort})),(null===(i=e.disabledSortTypes)||void 0===i?void 0:i.includes("DISCOUNT_RATIO"))||(d.push({label:Ce(0,"INCREASING_DISCOUNT"),value:"INCREASING_DISCOUNT",isSelected:"INCREASING_DISCOUNT"===e.sort}),d.push({label:Ce(0,"DECRASING_DISCOUNT"),value:"DECRASING_DISCOUNT",isSelected:"DECRASING_DISCOUNT"===e.sort})),(null===(a=e.disabledSortTypes)||void 0===a?void 0:a.includes("MANUAL_SORT"))||d.push({label:Ce(0,"FEATURED"),value:"FEATURED",isSelected:"FEATURED"===e.sort}),(null===(o=e.disabledSortTypes)||void 0===o?void 0:o.includes("AVERAGE_RATING"))||d.push({label:Ce(0,"AVERAGE_RATING"),value:"AVERAGE_RATING",isSelected:"AVERAGE_RATING"===e.sort}),(null===(s=e.disabledSortTypes)||void 0===s?void 0:s.includes("REVIEW_COUNT"))||d.push({label:Ce(0,"REVIEW_COUNT"),value:"REVIEW_COUNT",isSelected:"REVIEW_COUNT"===e.sort}),(null===(u=e.disabledSortTypes)||void 0===u?void 0:u.includes("SALE_COUNT"))||d.push({label:Ce(0,"SALE_COUNT"),value:"SALE_COUNT",isSelected:"SALE_COUNT"===e.sort}),d}function Ae(e,i,a){return t(this,void 0,void 0,function(){var t,s,u;return r(this,function(r){switch(r.label){case 0:return a?(null===(u=e.filterCategories)||void 0===u||u.forEach(function(e){e.id===i.id&&(e.isSelected=!e.isSelected)}),[4,te(e)]):[3,2];case 1:return r.sent(),[3,3];case 2:n.isEditor||(t=re(e),s=S(i)+(t?"?"+t:""),o.navigate(s)),r.label=3;case 3:return[2]}})})}function ye(e){var t;null===(t=e.filterCategories)||void 0===t||t.forEach(function(e){e.image=e.imageId?{id:e.imageId,isVideo:!1}:null})}function Te(e,t){if(e.infiniteScrollPage!==t){e.infiniteScrollPage=t;var r=re(e);o.navigate("".concat(location.pathname).concat(r?"?"+r:""),!0)}}function Re(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.searchKeyword&&e.data.length?[4,import("../../../analytics/analytics-functions/viewSearchResults.js")]:[3,2];case 1:return(0,t.sent().anl_viewSearchResults)(e.searchKeyword,e.data),[3,4];case 2:return e.data.length&&"ALL"===e.type?[4,import("../../../analytics/analytics-functions/viewListing.js")]:[3,4];case 3:(0,t.sent().anl_viewListing)(e.data),t.label=4;case 4:return[2]}})})}function De(e){var t=e.data[0];if(!t)return n.getDefaultCurrencyCode()||"";var r=de(t),i=b(r);return(null==i?void 0:i.currency)||n.getDefaultCurrencyCode()||""}function he(e){var t=e.data[0];if(!t)return n.getDefaultCurrencySymbol()||"";var r=de(t),i=b(r);return(null==i?void 0:i.currencySymbol)||n.getDefaultCurrencySymbol()||""}var _e=f(function(e){te(e)},500),me=f(function(e){return t(void 0,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,import("../../../analytics/analytics-functions/search.js")];case 1:return(0,t.sent().anl_search)(e.searchKeyword),[2]}})})},1e3),be=((L={}).INCREASING_PRICE=1,L.DECREASING_PRICE=2,L.LAST_ADDED=3,L.FIRST_ADDED=4,L.INCREASING_DISCOUNT=5,L.DECRASING_DISCOUNT=6,L.FEATURED=7,L.DEFAULT=8,L.AVERAGE_RATING=9,L.REVIEW_COUNT=10,L.SALE_COUNT=11,L.A_Z=12,L.Z_A=13,L);export{ae as clearProductListFilter,ie as clearProductListFilters,X as enableProductListSuggestions,De as getProductListCurrencyCode,he as getProductListCurrencySymbol,Z as getProductListFilterCategories,le as getProductListInitialData,pe as getProductListNextPage,ge as getProductListPage,ve as getProductListPrevPage,Se as getProductListSortOptions,Ie as getProductListSortTypeTranslation,Q as getProductListSuggestionHref,ue as getSelectedFilterValues,oe as handleFilterValueClick,se as handleNumberRangeOptionClick,M as hasProductListAppliedFilters,q as hasProductListFeaturedSortEnabled,Y as hasProductListNextPage,K as hasProductListPrevPage,O as initProductList,ye as initProductListFilterCategories,P as initProductListOnBrowser,F as isProductListDiscounted,U as isProductListFilterable,V as isProductListFiltered,k as isProductListLastViewed,W as isProductListPurchasedTogether,j as isProductListRecommended,x as isProductListRelatedProducts,B as isProductListSearch,w as isProductListStatic,H as isProductListViewedTogether,Ae as onFilterCategoryClick,ce as productListToggleFilterCollapsed,G as searchProductList,z as setProductListIsFilteredForProducts,J as setProductListIsStaticForProducts,Te as setProductListVisiblePage,Ee as setSortType,Ce as translateProductListSortType};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as n}from'./../../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as r}from"../../../packages/storefront-config/src/index.js";import{CART_LS_KEY as e,cartStore as i}from"../../../stores/cart/index.js";import{customerStore as a}from"../../../stores/customer/index.js";import{getCookieValue as o}from"../../../utils/helper.js";import{getIkasOrderDistinctItemCount as s}from"../../models/order/index.js";import{getSelectedProductVariant as u,hasProductValidOptionValues as c}from"../../models/product/index.js";import{isProductOfferAccepted as d}from"../../models/product/campaign-offer/index.js";import{initProductOptionSetValues as l}from"../../models/product/option-set/index.js";import{hasProductVariantStock as f}from"../../models/product/variant/index.js";import{waitForCustomerStoreInit as v}from"../customer/index.js";function p(t){var n,e=null===(n=t.cart)||void 0===n?void 0:n.id;if(e){var i=r.getCurrentRouting();return"".concat((null==i?void 0:i.path)?"/".concat(i.path):"","/checkout?id=").concat(e,"&step=info")}return""}function m(a,s){return t(this,arguments,void 0,function(t,a,s,d){var v,p,m,h,g,b,y,C,S,L,j,w,x,P,T,q,E;return void 0===s&&(s=1),n(this,function(n){switch(n.label){case 0:v=null!==(w=null==d?void 0:d.isPayWithIkas)&&void 0!==w&&w,n.label=1;case 1:return n.trys.push([1,10,,11]),v||!a.productOptionSetId||a.productOptionSet?c(a)?f(t)||t.sellIfOutOfStock?(p=void 0,v?[3,3]:[4,F()]):[2,{success:!1,validationError:"INSUFFICIENT_STOCK"}]:[2,{success:!1,validationError:"INVALID_PRODUCT_OPTION_VALUES"}]:[2,{success:!1,validationError:"INVALID_PRODUCT_OPTION_VALUES"}];case 2:if(n.sent(),i.cart&&(p=_(i.cart,t,a))){if(a.productOptionSet&&l(a.productOptionSet),!t.bundleSettings)return[2,I(p,p.quantity+s,a.offers,a)];if(!O())return[2,I(p,p.quantity+s,a.offers,a)]}n.label=3;case 3:return m=Q(a),h=s,(null==(g=null===(x=a.salesChannels)||void 0===x?void 0:x.find(function(t){return t.id===r.salesChannelId}))?void 0:g.minQuantityPerCart)&&s<g.minQuantityPerCart&&(h=g.minQuantityPerCart),(null==g?void 0:g.maxQuantityPerCart)&&s>g.maxQuantityPerCart&&(h=g.maxQuantityPerCart),b=v?null:(null===(P=i.cart)||void 0===P?void 0:P.id)||localStorage.getItem(e),[4,import("../../api/cart/index.js")];case 4:return[4,(0,n.sent().apiAddItemToCart)({input:{cartId:b,item:{id:null!==(T=null==p?void 0:p.id)&&void 0!==T?T:null,quantity:null!==(q=null==p?void 0:p.quantity)&&void 0!==q?q:h,variant:{id:t.id,name:a.name,bundleProducts:null===(E=t.bundleSettings)||void 0===E?void 0:E.products.map(function(t){var n;return{id:t.id,productId:(null===(n=t.product)||void 0===n?void 0:n.id)||"",variantId:t.product?u(t.product).id:"",quantity:t.quantity}})}},acceptedOffers:A(a.offers),options:m.length?m:null,priceListId:r.priceListId||null,salesChannelId:r.salesChannelId,storefrontThemeId:r.storefrontThemeId,metadata:{_fbp:o("_fbp"),_fbc:o("_fbc"),_ga:o("_ga")}}})];case 5:return y=n.sent(),v?[3,7]:y.isSuccess&&y.data?[4,k(y.data)]:[3,7];case 6:n.sent(),n.label=7;case 7:return(C=v?y.data:i.cart)?(S="".concat(C.id,"-").concat(C.updatedAt),(L=C.orderLineItems.find(function(n){return n.variant.id===t.id}))?[4,import("../../../analytics/analytics-functions/addToCart.js")]:[3,9]):[3,9];case 8:(0,n.sent().anl_addToCart)(L,s,S,C,a),n.label=9;case 9:return a.productOptionSet&&l(a.productOptionSet),[2,{success:y.isSuccess,response:y}];case 10:return j=n.sent(),console.log(j),[2,{success:!1}];case 11:return[2]}})})}function h(r){return t(this,arguments,void 0,function(t,r){return void 0===r&&(r=1),n(this,function(n){switch(n.label){case 0:return[4,m(u(t),t,r)];case 1:return[2,n.sent()]}})})}function I(e,a,s,u){return t(this,void 0,void 0,function(){var t,c,d,l,f,v;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,10,,11]),[4,F()];case 1:return n.sent(),[4,import("../../api/cart/index.js")];case 2:return[4,(0,n.sent().apiAddItemToCart)({input:{cartId:(null===(f=i.cart)||void 0===f?void 0:f.id)||null,item:{id:e.id,quantity:a,variant:{id:e.variant.id,name:e.variant.name,bundleProducts:null===(v=e.variant.bundleProducts)||void 0===v?void 0:v.map(function(t){return{id:t.id,productId:t.variant.productId||"",variantId:t.variant.id||"",quantity:t.quantity}})}},acceptedOffers:s?A(s):void 0,options:U(e),priceListId:r.priceListId||null,salesChannelId:r.salesChannelId,storefrontThemeId:r.storefrontThemeId,metadata:{_fbp:o("_fbp"),_fbc:o("_fbc"),_ga:o("_ga")}}})];case 3:return(t=n.sent()).isSuccess&&t.data?[4,k(t.data)]:[3,5];case 4:n.sent(),n.label=5;case 5:return i.cart?(c="".concat(i.cart.id,"-").concat(i.cart.updatedAt),(d=e.quantity)>a?[4,import("../../../analytics/analytics-functions/removeFromCart.js")]:[3,7]):[3,9];case 6:return(0,n.sent().anl_removeFromCart)(e,d-a,i.cart),[3,9];case 7:return[4,import("../../../analytics/analytics-functions/addToCart.js")];case 8:(0,n.sent().anl_addToCart)(e,a-d,c,i.cart,u),n.label=9;case 9:return T(i),[2,{success:t.isSuccess,response:t}];case 10:return l=n.sent(),console.log(l),[2,{success:!1}];case 11:return[2]}})})}function g(r,e,i,a,o){return t(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,I(e,i,a,o)];case 1:return[2,t.sent()]}})})}function b(t,n){for(var r=0,e=(null==t?void 0:t.orderAdjustments)||[];r<e.length;r++)for(var i=0,a=e[r].appliedOrderLines||[];i<a.length;i++){var o=a[i];if(o.orderLineId===n.id)return o.isAutoCreated||!1}return!1}function y(r){return t(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,I(r,0)];case 1:return[2,t.sent()]}})})}function C(t){localStorage.removeItem(e),t.cart=null}function S(r){return t(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,new Promise(function(t){var n=setInterval(function(){r.isCartInitialLoadFinished&&(clearInterval(n),t(null))},100)})];case 1:return[2,t.sent()]}})})}function O(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("editLineID")||""}function _(t,n,r){var e;if(!r.productOptionSetId&&!n.bundleSettings)return t.orderLineItems.find(function(t){return t.variant.id===n.id});if(n.bundleSettings){var i=O();if(i)if(h=t.orderLineItems.find(function(t){return t.id===i}))return h}var a=t.orderLineItems.filter(function(t){return t.variant.id===n.id})||[];if(r.productOptionSetId)for(var o=Q(r),s=a.filter(function(t){var n;return(null===(n=t.options)||void 0===n?void 0:n.length)===o.length})||[],u=0,c=s;u<c.length;u++){if((h=c[u]).options){for(var d=!0,l=function(t){var n=t.values.map(function(t){return t.value}),r=null===(e=o.find(function(n){return n.productOptionId===t.productOptionId}))||void 0===e?void 0:e.values;if(!(d=d&&n.length===(null==r?void 0:r.length)&&n.every(function(t){return null==r?void 0:r.includes(t)})))return"break"},f=0,v=h.options;f<v.length;f++){if("break"===l(v[f]))break}if(d){if(!n.bundleSettings)return h;if(j(n,h))return h}}}else if(n.bundleSettings)for(var p=0,m=a;p<m.length;p++){var h=m[p];if(j(n,h))return h}}function L(t,n){return _(t,u(n),n)}function j(t,n){var r,e=null===(r=t.bundleSettings)||void 0===r?void 0:r.products,i=n.variant.bundleProducts;return!!e&&((null==e?void 0:e.length)===(null==i?void 0:i.length)&&(null==e?void 0:e.every(function(t){return!!(null==i?void 0:i.find(function(n){return n.id===t.id&&n.quantity===t.quantity&&t.product&&n.variant.id===u(t.product).id}))})))}function w(r,e){return t(this,void 0,void 0,function(){var t;return n(this,function(n){switch(n.label){case 0:return[4,import("../../api/cart/index.js")];case 1:return[4,(0,n.sent().apiSaveCartCouponCode)({cartId:r.id,couponCode:e})];case 2:return(t=n.sent()).isSuccess&&t.data&&(i.cart=t.data),[2,{success:t.isSuccess,response:t}]}})})}function x(r){return t(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,w(r,null)];case 1:return[2,t.sent()]}})})}function P(r,e){return t(this,void 0,void 0,function(){var t;return n(this,function(n){switch(n.label){case 0:return[4,import("../../api/cart/index.js")];case 1:return[4,(0,n.sent().apiRemoveGiftCardFromCart)({cartId:r.id,giftCardId:e})];case 2:return(t=n.sent()).isSuccess&&t.data&&(i.cart=t.data),[2,{success:t.isSuccess,response:t}]}})})}function T(t){t.cart&&0===s(t.cart)&&C(t)}function q(){return t(this,void 0,void 0,function(){var t,r,o,s,u,c;return n(this,function(n){switch(n.label){case 0:if(!("undefined"!=typeof localStorage))return[2];n.label=1;case 1:return n.trys.push([1,8,9,10]),i.isCartLoading=!0,[4,v(a)];case 2:return n.sent(),t=null===(u=a.customer)||void 0===u?void 0:u.id,(r=(null===(c=i.cart)||void 0===c?void 0:c.id)||localStorage.getItem(e))||t?[4,import("../../api/cart/index.js")]:[2];case 3:return[4,(0,n.sent().apiGetCartById)({id:r})];case 4:return(o=n.sent()).isSuccess&&o.data?[4,k(o.data)]:[3,6];case 5:return n.sent(),[3,7];case 6:if(o.isCancelled||o.isNetworkError)return[2];C(i),n.label=7;case 7:return[3,10];case 8:return s=n.sent(),console.log(s),[3,10];case 9:return i.isCartLoading=!1,i.isCartInitialLoadFinished=!0,[7];case 10:return[2]}})})}function A(t){var n=t.filter(function(t){return t.isSelected&&!d(t)}).map(function(t){return{campaignOfferId:t.campaignOfferId,campaignOfferProductId:t.campaignOfferProductId,productId:t.product.id,quantity:t.quantity,variantId:u(t.product).id}})||[];return n.length?n:void 0}function E(e,i){return t(this,arguments,void 0,function(t,e,i){var a,o,s,c,d,l,f,v,p,h,I,g,b,y,C;return void 0===i&&(i=1),n(this,function(t){switch(t.label){case 0:return t.trys.push([0,4,,5]),a=r.salesChannelId,o=r.storefrontThemeId,a&&o?(s=u(e))?[4,m(s,e,i,{isPayWithIkas:!0})]:[2,{success:!1,error:"No variant selected"}]:[2,{success:!1,error:"Missing storefront configuration"}];case 1:return(c=t.sent()).success&&(null===(p=null===(v=c.response)||void 0===v?void 0:v.data)||void 0===p?void 0:p.id)?(d=c.response.data.id,[4,import("../../api/cart/index.js")]):[2,{success:!1,error:(null===(g=null===(I=null===(h=c.response)||void 0===h?void 0:h.graphQLErrors)||void 0===I?void 0:I[0])||void 0===g?void 0:g.message)||"Failed to create cart"}];case 2:return[4,(0,t.sent().apiCreatePayWithIkasSessionUrl)({cartId:d})];case 3:return!(l=t.sent()).data||(null===(b=l.graphQLErrors)||void 0===b?void 0:b.length)?[2,{success:!1,error:(null===(C=null===(y=l.graphQLErrors)||void 0===y?void 0:y[0])||void 0===C?void 0:C.message)||"Failed to create Pay with ikas session"}]:[2,{success:!0,payUrl:l.data.payUrl,expiresAt:l.data.expiresAt}];case 4:return f=t.sent(),console.log("error",f),[2,{success:!1,error:f instanceof Error?f.message:"Unknown error occurred"}];case 5:return[2]}})})}function k(r){return t(this,void 0,void 0,function(){return n(this,function(t){return localStorage.setItem(e,r.id),i.cart=r,[2]})})}function F(){return t(this,void 0,void 0,function(){var t;return n(this,function(n){switch(n.label){case 0:return t=localStorage.getItem(e),!i.cart||t?[3,1]:(C(i),[3,3]);case 1:return i.cart||!t?[3,3]:[4,q()];case 2:n.sent(),n.label=3;case 3:return[2]}})})}function U(t){if(t&&t.options){for(var n=[],r=0,e=t.options;r<e.length;r++){var i=e[r],a={productOptionId:i.productOptionId,productOptionsSetId:i.productOptionsSetId,values:i.values.map(function(t){return t.value})};n.push(a)}return n}return null}function Q(t){var n,r=[],e=new Set,i=function(t){var n;e.has(t.id)||(e.add(t.id),t.values.length&&r.push({productOptionId:t.id,productOptionsSetId:t.productOptionSetId,values:t.values}),null===(n=t.childOptions)||void 0===n||n.forEach(i))};return null===(n=t.productOptionSet)||void 0===n||n.options.filter(function(t){return!t.requiredOptionId}).forEach(i),r}function N(e){return t(this,void 0,void 0,function(){var t,a,s,u,c,d,l,f,v,p,m;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,10,,11]),[4,F()];case 1:return n.sent(),t=e.itemId?null===(v=i.cart)||void 0===v?void 0:v.orderLineItems.find(function(t){return t.id===e.itemId}):null,[4,import("../../api/cart/index.js")];case 2:return[4,(0,n.sent().apiAddItemToCart)({input:{cartId:(null===(p=i.cart)||void 0===p?void 0:p.id)||null,item:{id:e.itemId||null,quantity:e.quantity,variant:{id:e.variantId}},priceListId:r.priceListId||null,salesChannelId:r.salesChannelId,storefrontThemeId:r.storefrontThemeId,metadata:{_fbp:o("_fbp"),_fbc:o("_fbc"),_ga:o("_ga")}}})];case 3:return(a=n.sent()).isSuccess&&a.data?(e.itemId||(s=(null===(m=i.cart)||void 0===m?void 0:m.orderLineItems.map(function(t){return t.id}))||[],u=a.data.orderLineItems.map(function(t){return t.id}),(c=u.find(function(t){return!s.includes(t)}))&&(t=a.data.orderLineItems.find(function(t){return t.id===c}))),[4,k(a.data)]):[3,5];case 4:n.sent(),n.label=5;case 5:return i.cart&&t?(d="".concat(i.cart.id,"-").concat(i.cart.updatedAt),(l=e.quantity)>e.quantity?[4,import("../../../analytics/analytics-functions/removeFromCart.js")]:[3,7]):[3,9];case 6:return(0,n.sent().anl_removeFromCart)(t,l-e.quantity,i.cart),[3,9];case 7:return[4,import("../../../analytics/analytics-functions/addToCart.js")];case 8:(0,n.sent().anl_addToCart)(t,e.quantity-l,d,i.cart),n.label=9;case 9:return T(i),[2,{success:a.isSuccess,response:a}];case 10:return f=n.sent(),console.log(f),[2,{success:!1}];case 11:return[2]}})})}function D(t){var n;return!!t.cart&&(null===(n=t.cart.orderLineItems)||void 0===n?void 0:n.length)>0}export{m as addItemToCart,h as addSelectedtedVariantToCart,g as changeCartItemQuantity,I as changeItemQuantity,E as createPayWithIkasSession,_ as findExistingCartItem,L as findExistingCartItemWithProduct,A as getAcceptedOffers,q as getCart,p as getCheckoutUrlFromCartStore,D as hasCart,b as isOrderLineItemAutoCreated,C as removeCart,x as removeCouponCode,P as removeGiftCardLine,y as removeItem,w as saveCouponCode,k as setCart,S as waitForCartStoreInit,N as windowAddToCart};
1
+ import{__awaiter as t,__generator as n,__assign as r}from'./../../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as e}from"../../../packages/storefront-config/src/index.js";import{CART_LS_KEY as i,cartStore as a}from"../../../stores/cart/index.js";import{customerStore as o}from"../../../stores/customer/index.js";import{getCookieValue as s,getOpenAiAttributionMetadata as u}from"../../../utils/helper.js";import{getIkasOrderDistinctItemCount as c}from"../../models/order/index.js";import{getSelectedProductVariant as d,hasProductValidOptionValues as l}from"../../models/product/index.js";import{isProductOfferAccepted as f}from"../../models/product/campaign-offer/index.js";import{initProductOptionSetValues as v}from"../../models/product/option-set/index.js";import{hasProductVariantStock as p}from"../../models/product/variant/index.js";import{waitForCustomerStoreInit as m}from"../customer/index.js";function h(t){var n,r=null===(n=t.cart)||void 0===n?void 0:n.id;if(r){var i=e.getCurrentRouting();return"".concat((null==i?void 0:i.path)?"/".concat(i.path):"","/checkout?id=").concat(r,"&step=info")}return""}function I(o,c){return t(this,arguments,void 0,function(t,o,c,f){var m,h,I,g,y,C,S,O,_,w,x,P,T,q,A,E,F;return void 0===c&&(c=1),n(this,function(n){switch(n.label){case 0:m=null!==(P=null==f?void 0:f.isPayWithIkas)&&void 0!==P&&P,n.label=1;case 1:return n.trys.push([1,10,,11]),m||!o.productOptionSetId||o.productOptionSet?l(o)?p(t)||t.sellIfOutOfStock?(h=void 0,m?[3,3]:[4,Q()]):[2,{success:!1,validationError:"INSUFFICIENT_STOCK"}]:[2,{success:!1,validationError:"INVALID_PRODUCT_OPTION_VALUES"}]:[2,{success:!1,validationError:"INVALID_PRODUCT_OPTION_VALUES"}];case 2:if(n.sent(),a.cart&&(h=j(a.cart,t,o))){if(o.productOptionSet&&v(o.productOptionSet),!t.bundleSettings)return[2,b(h,h.quantity+c,o.offers,o)];if(!L())return[2,b(h,h.quantity+c,o.offers,o)]}n.label=3;case 3:return I=D(o),g=c,(null==(y=null===(T=o.salesChannels)||void 0===T?void 0:T.find(function(t){return t.id===e.salesChannelId}))?void 0:y.minQuantityPerCart)&&c<y.minQuantityPerCart&&(g=y.minQuantityPerCart),(null==y?void 0:y.maxQuantityPerCart)&&c>y.maxQuantityPerCart&&(g=y.maxQuantityPerCart),C=m?null:(null===(q=a.cart)||void 0===q?void 0:q.id)||localStorage.getItem(i),[4,import("../../api/cart/index.js")];case 4:return[4,(0,n.sent().apiAddItemToCart)({input:{cartId:C,item:{id:null!==(A=null==h?void 0:h.id)&&void 0!==A?A:null,quantity:null!==(E=null==h?void 0:h.quantity)&&void 0!==E?E:g,variant:{id:t.id,name:o.name,bundleProducts:null===(F=t.bundleSettings)||void 0===F?void 0:F.products.map(function(t){var n;return{id:t.id,productId:(null===(n=t.product)||void 0===n?void 0:n.id)||"",variantId:t.product?d(t.product).id:"",quantity:t.quantity}})}},acceptedOffers:k(o.offers),options:I.length?I:null,priceListId:e.priceListId||null,salesChannelId:e.salesChannelId,storefrontThemeId:e.storefrontThemeId,metadata:r({_fbp:s("_fbp"),_fbc:s("_fbc"),_ga:s("_ga")},u())}})];case 5:return S=n.sent(),m?[3,7]:S.isSuccess&&S.data?[4,U(S.data)]:[3,7];case 6:n.sent(),n.label=7;case 7:return(O=m?S.data:a.cart)?(_="".concat(O.id,"-").concat(O.updatedAt),(w=O.orderLineItems.find(function(n){return n.variant.id===t.id}))?[4,import("../../../analytics/analytics-functions/addToCart.js")]:[3,9]):[3,9];case 8:(0,n.sent().anl_addToCart)(w,c,_,O,o),n.label=9;case 9:return o.productOptionSet&&v(o.productOptionSet),[2,{success:S.isSuccess,response:S}];case 10:return x=n.sent(),console.log(x),[2,{success:!1}];case 11:return[2]}})})}function g(r){return t(this,arguments,void 0,function(t,r){return void 0===r&&(r=1),n(this,function(n){switch(n.label){case 0:return[4,I(d(t),t,r)];case 1:return[2,n.sent()]}})})}function b(i,o,c,d){return t(this,void 0,void 0,function(){var t,l,f,v,p,m;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,10,,11]),[4,Q()];case 1:return n.sent(),[4,import("../../api/cart/index.js")];case 2:return[4,(0,n.sent().apiAddItemToCart)({input:{cartId:(null===(p=a.cart)||void 0===p?void 0:p.id)||null,item:{id:i.id,quantity:o,variant:{id:i.variant.id,name:i.variant.name,bundleProducts:null===(m=i.variant.bundleProducts)||void 0===m?void 0:m.map(function(t){return{id:t.id,productId:t.variant.productId||"",variantId:t.variant.id||"",quantity:t.quantity}})}},acceptedOffers:c?k(c):void 0,options:N(i),priceListId:e.priceListId||null,salesChannelId:e.salesChannelId,storefrontThemeId:e.storefrontThemeId,metadata:r({_fbp:s("_fbp"),_fbc:s("_fbc"),_ga:s("_ga")},u())}})];case 3:return(t=n.sent()).isSuccess&&t.data?[4,U(t.data)]:[3,5];case 4:n.sent(),n.label=5;case 5:return a.cart?(l="".concat(a.cart.id,"-").concat(a.cart.updatedAt),(f=i.quantity)>o?[4,import("../../../analytics/analytics-functions/removeFromCart.js")]:[3,7]):[3,9];case 6:return(0,n.sent().anl_removeFromCart)(i,f-o,a.cart),[3,9];case 7:return[4,import("../../../analytics/analytics-functions/addToCart.js")];case 8:(0,n.sent().anl_addToCart)(i,o-f,l,a.cart,d),n.label=9;case 9:return A(a),[2,{success:t.isSuccess,response:t}];case 10:return v=n.sent(),console.log(v),[2,{success:!1}];case 11:return[2]}})})}function y(r,e,i,a,o){return t(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,b(e,i,a,o)];case 1:return[2,t.sent()]}})})}function C(t,n){for(var r=0,e=(null==t?void 0:t.orderAdjustments)||[];r<e.length;r++)for(var i=0,a=e[r].appliedOrderLines||[];i<a.length;i++){var o=a[i];if(o.orderLineId===n.id)return o.isAutoCreated||!1}return!1}function S(r){return t(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,b(r,0)];case 1:return[2,t.sent()]}})})}function O(t){localStorage.removeItem(i),t.cart=null}function _(r){return t(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,new Promise(function(t){var n=setInterval(function(){r.isCartInitialLoadFinished&&(clearInterval(n),t(null))},100)})];case 1:return[2,t.sent()]}})})}function L(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("editLineID")||""}function j(t,n,r){var e;if(!r.productOptionSetId&&!n.bundleSettings)return t.orderLineItems.find(function(t){return t.variant.id===n.id});if(n.bundleSettings){var i=L();if(i)if(h=t.orderLineItems.find(function(t){return t.id===i}))return h}var a=t.orderLineItems.filter(function(t){return t.variant.id===n.id})||[];if(r.productOptionSetId)for(var o=D(r),s=a.filter(function(t){var n;return(null===(n=t.options)||void 0===n?void 0:n.length)===o.length})||[],u=0,c=s;u<c.length;u++){if((h=c[u]).options){for(var d=!0,l=function(t){var n=t.values.map(function(t){return t.value}),r=null===(e=o.find(function(n){return n.productOptionId===t.productOptionId}))||void 0===e?void 0:e.values;if(!(d=d&&n.length===(null==r?void 0:r.length)&&n.every(function(t){return null==r?void 0:r.includes(t)})))return"break"},f=0,v=h.options;f<v.length;f++){if("break"===l(v[f]))break}if(d){if(!n.bundleSettings)return h;if(x(n,h))return h}}}else if(n.bundleSettings)for(var p=0,m=a;p<m.length;p++){var h=m[p];if(x(n,h))return h}}function w(t,n){return j(t,d(n),n)}function x(t,n){var r,e=null===(r=t.bundleSettings)||void 0===r?void 0:r.products,i=n.variant.bundleProducts;return!!e&&((null==e?void 0:e.length)===(null==i?void 0:i.length)&&(null==e?void 0:e.every(function(t){return!!(null==i?void 0:i.find(function(n){return n.id===t.id&&n.quantity===t.quantity&&t.product&&n.variant.id===d(t.product).id}))})))}function P(r,e){return t(this,void 0,void 0,function(){var t;return n(this,function(n){switch(n.label){case 0:return[4,import("../../api/cart/index.js")];case 1:return[4,(0,n.sent().apiSaveCartCouponCode)({cartId:r.id,couponCode:e})];case 2:return(t=n.sent()).isSuccess&&t.data&&(a.cart=t.data),[2,{success:t.isSuccess,response:t}]}})})}function T(r){return t(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,P(r,null)];case 1:return[2,t.sent()]}})})}function q(r,e){return t(this,void 0,void 0,function(){var t;return n(this,function(n){switch(n.label){case 0:return[4,import("../../api/cart/index.js")];case 1:return[4,(0,n.sent().apiRemoveGiftCardFromCart)({cartId:r.id,giftCardId:e})];case 2:return(t=n.sent()).isSuccess&&t.data&&(a.cart=t.data),[2,{success:t.isSuccess,response:t}]}})})}function A(t){t.cart&&0===c(t.cart)&&O(t)}function E(){return t(this,void 0,void 0,function(){var t,r,e,s,u,c;return n(this,function(n){switch(n.label){case 0:if(!("undefined"!=typeof localStorage))return[2];n.label=1;case 1:return n.trys.push([1,8,9,10]),a.isCartLoading=!0,[4,m(o)];case 2:return n.sent(),t=null===(u=o.customer)||void 0===u?void 0:u.id,(r=(null===(c=a.cart)||void 0===c?void 0:c.id)||localStorage.getItem(i))||t?[4,import("../../api/cart/index.js")]:[2];case 3:return[4,(0,n.sent().apiGetCartById)({id:r})];case 4:return(e=n.sent()).isSuccess&&e.data?[4,U(e.data)]:[3,6];case 5:return n.sent(),[3,7];case 6:if(e.isCancelled||e.isNetworkError)return[2];O(a),n.label=7;case 7:return[3,10];case 8:return s=n.sent(),console.log(s),[3,10];case 9:return a.isCartLoading=!1,a.isCartInitialLoadFinished=!0,[7];case 10:return[2]}})})}function k(t){var n=t.filter(function(t){return t.isSelected&&!f(t)}).map(function(t){return{campaignOfferId:t.campaignOfferId,campaignOfferProductId:t.campaignOfferProductId,productId:t.product.id,quantity:t.quantity,variantId:d(t.product).id}})||[];return n.length?n:void 0}function F(r,i){return t(this,arguments,void 0,function(t,r,i){var a,o,s,u,c,l,f,v,p,m,h,g,b,y,C;return void 0===i&&(i=1),n(this,function(t){switch(t.label){case 0:return t.trys.push([0,4,,5]),a=e.salesChannelId,o=e.storefrontThemeId,a&&o?(s=d(r))?[4,I(s,r,i,{isPayWithIkas:!0})]:[2,{success:!1,error:"No variant selected"}]:[2,{success:!1,error:"Missing storefront configuration"}];case 1:return(u=t.sent()).success&&(null===(p=null===(v=u.response)||void 0===v?void 0:v.data)||void 0===p?void 0:p.id)?(c=u.response.data.id,[4,import("../../api/cart/index.js")]):[2,{success:!1,error:(null===(g=null===(h=null===(m=u.response)||void 0===m?void 0:m.graphQLErrors)||void 0===h?void 0:h[0])||void 0===g?void 0:g.message)||"Failed to create cart"}];case 2:return[4,(0,t.sent().apiCreatePayWithIkasSessionUrl)({cartId:c})];case 3:return!(l=t.sent()).data||(null===(b=l.graphQLErrors)||void 0===b?void 0:b.length)?[2,{success:!1,error:(null===(C=null===(y=l.graphQLErrors)||void 0===y?void 0:y[0])||void 0===C?void 0:C.message)||"Failed to create Pay with ikas session"}]:[2,{success:!0,payUrl:l.data.payUrl,expiresAt:l.data.expiresAt}];case 4:return f=t.sent(),console.log("error",f),[2,{success:!1,error:f instanceof Error?f.message:"Unknown error occurred"}];case 5:return[2]}})})}function U(r){return t(this,void 0,void 0,function(){return n(this,function(t){return localStorage.setItem(i,r.id),a.cart=r,[2]})})}function Q(){return t(this,void 0,void 0,function(){var t;return n(this,function(n){switch(n.label){case 0:return t=localStorage.getItem(i),!a.cart||t?[3,1]:(O(a),[3,3]);case 1:return a.cart||!t?[3,3]:[4,E()];case 2:n.sent(),n.label=3;case 3:return[2]}})})}function N(t){if(t&&t.options){for(var n=[],r=0,e=t.options;r<e.length;r++){var i=e[r],a={productOptionId:i.productOptionId,productOptionsSetId:i.productOptionsSetId,values:i.values.map(function(t){return t.value})};n.push(a)}return n}return null}function D(t){var n,r=[],e=new Set,i=function(t){var n;e.has(t.id)||(e.add(t.id),t.values.length&&r.push({productOptionId:t.id,productOptionsSetId:t.productOptionSetId,values:t.values}),null===(n=t.childOptions)||void 0===n||n.forEach(i))};return null===(n=t.productOptionSet)||void 0===n||n.options.filter(function(t){return!t.requiredOptionId}).forEach(i),r}function R(i){return t(this,void 0,void 0,function(){var t,o,c,d,l,f,v,p,m,h,I;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,10,,11]),[4,Q()];case 1:return n.sent(),t=i.itemId?null===(m=a.cart)||void 0===m?void 0:m.orderLineItems.find(function(t){return t.id===i.itemId}):null,[4,import("../../api/cart/index.js")];case 2:return[4,(0,n.sent().apiAddItemToCart)({input:{cartId:(null===(h=a.cart)||void 0===h?void 0:h.id)||null,item:{id:i.itemId||null,quantity:i.quantity,variant:{id:i.variantId}},priceListId:e.priceListId||null,salesChannelId:e.salesChannelId,storefrontThemeId:e.storefrontThemeId,metadata:r({_fbp:s("_fbp"),_fbc:s("_fbc"),_ga:s("_ga")},u())}})];case 3:return(o=n.sent()).isSuccess&&o.data?(i.itemId||(c=(null===(I=a.cart)||void 0===I?void 0:I.orderLineItems.map(function(t){return t.id}))||[],d=o.data.orderLineItems.map(function(t){return t.id}),(l=d.find(function(t){return!c.includes(t)}))&&(t=o.data.orderLineItems.find(function(t){return t.id===l}))),[4,U(o.data)]):[3,5];case 4:n.sent(),n.label=5;case 5:return a.cart&&t?(f="".concat(a.cart.id,"-").concat(a.cart.updatedAt),(v=i.quantity)>i.quantity?[4,import("../../../analytics/analytics-functions/removeFromCart.js")]:[3,7]):[3,9];case 6:return(0,n.sent().anl_removeFromCart)(t,v-i.quantity,a.cart),[3,9];case 7:return[4,import("../../../analytics/analytics-functions/addToCart.js")];case 8:(0,n.sent().anl_addToCart)(t,i.quantity-v,f,a.cart),n.label=9;case 9:return A(a),[2,{success:o.isSuccess,response:o}];case 10:return p=n.sent(),console.log(p),[2,{success:!1}];case 11:return[2]}})})}function V(t){var n;return!!t.cart&&(null===(n=t.cart.orderLineItems)||void 0===n?void 0:n.length)>0}export{I as addItemToCart,g as addSelectedtedVariantToCart,y as changeCartItemQuantity,b as changeItemQuantity,F as createPayWithIkasSession,j as findExistingCartItem,w as findExistingCartItemWithProduct,k as getAcceptedOffers,E as getCart,h as getCheckoutUrlFromCartStore,V as hasCart,C as isOrderLineItemAutoCreated,O as removeCart,T as removeCouponCode,q as removeGiftCardLine,S as removeItem,P as saveCouponCode,U as setCart,_ as waitForCartStoreInit,R as windowAddToCart};
@@ -27,6 +27,7 @@ export declare class IkasStorefrontConfig {
27
27
  static universalAnalyticsId?: string;
28
28
  static pickUpStockLocationIds?: string[] | null;
29
29
  static tiktokPixelId?: string;
30
+ static openAiPixelId?: string;
30
31
  static stockPreference?: IkasThemeStockPreference;
31
32
  static translations: Record<string, any>;
32
33
  static themeGlobals: ThemeGlobals;
@@ -101,6 +102,7 @@ export type IkasStorefrontConfigParams = {
101
102
  universalAnalyticsId?: string;
102
103
  pickUpStockLocationIds?: string[] | null;
103
104
  tiktokPixelId?: string;
105
+ openAiPixelId?: string;
104
106
  stockPreference?: IkasThemeStockPreference;
105
107
  translations: Record<string, any>;
106
108
  themeGlobals: ThemeGlobals;
@@ -20,6 +20,7 @@ export type IkasStorefront = {
20
20
  analytics4Id: string | null;
21
21
  universalAnalyticsId: string | null;
22
22
  tiktokPixelId: string | null;
23
+ openAiPixelId?: string | null;
23
24
  token: string | null;
24
25
  type: IkasStorefrontType;
25
26
  metaTemplates: IkasStorefontMetaTemplates[] | null;
@@ -7,6 +7,7 @@ export declare function capitalize(value: string): string;
7
7
  export declare function tryForEach(items: any[], callback: (item: any, index: number) => void, printErrors?: boolean): void;
8
8
  export declare function formatDate(date: Date): string;
9
9
  export declare function getCookieValue(cookieName: string): string | null;
10
+ export declare function getOpenAiAttributionMetadata(): Record<string, string>;
10
11
  export declare function isClient(): boolean;
11
12
  export declare function isServer(): boolean;
12
13
  export declare function getQueryParams(): URLSearchParams | undefined;
@@ -1 +1 @@
1
- import{__spreadArray as r}from'./../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as n}from"../packages/storefront-config/src/index.js";import{reaction as t}from'./../ext/mobx/dist/mobx.esm.js';var e=function(r){return/^\+?\d+$/.test(r)},o=function(r){r=(r=r.replace(/^\s+|\s+$/g,"")).toLocaleLowerCase("tr-TR");for(var n="àáäâèéëêìíïîıòóöôùúüûñçşğ·/_,:;",t=0;t<31;t++)r=r.replace(new RegExp(n.charAt(t),"g"),"aaaaeeeeiiiiioooouuuuncsg------".charAt(t));return r=r.replace(/[^a-z0-9 -]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-")},a=function(r){return!(r.length>320)&&/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(r)};function i(r){return!!new Intl.DateTimeFormat(r,{hour:"numeric"}).format(0).match(/\s/)}function u(r,n,t){void 0===t&&(t=!1),r.forEach(function(r,e){try{n(r,e)}catch(r){t&&console.error(r)}})}function c(r){var t={year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",hour12:!1},e=n.getCurrentLocale();return"undefined"!=typeof navigator?t.hour12=i(navigator.language):t.hour12=i(e),new Intl.DateTimeFormat(e,t).format(r)}function f(r){var n=document.cookie.split(";").find(function(n){return n.trim().startsWith("".concat(r,"="))});return n?n.split("=")[1]:null}function s(){return"undefined"!=typeof window}function l(){return!s()}function m(){if(s())return new URLSearchParams(location.search)}function p(){return!!s()&&(performance.getEntriesByType?"back_forward"===performance.getEntriesByType("navigation")[0].type:performance.navigation.type===performance.navigation.TYPE_BACK_FORWARD)}function g(r,n){void 0===n&&(n={arrayFormat:"comma"});for(var t=[],e=function(r,e){if(null==e)return"continue";Array.isArray(e)?"comma"===n.arrayFormat&&e.length>0?t.push("".concat(r,"=").concat(e.join(","))):e.forEach(function(n){return t.push("".concat(r,"=").concat(n))}):t.push("".concat(r,"=").concat(e))},o=0,a=Object.entries(r);o<a.length;o++){var i=a[o];e(i[0],i[1])}return t.length>0?"".concat(t.join("&")):""}function h(r){return null==r?r:JSON.parse(JSON.stringify(r))}function y(r,n){if(!r||!Array.isArray(r))return{};for(var t={},e=0,o=r;e<o.length;e++){var a=o[e],i=void 0;t[i=String("string"==typeof n?a[n]:"function"==typeof n?n(a):a)]||(t[i]=[]),t[i].push(a)}return t}function v(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return n&&Array.isArray(n)?(0===t.length&&(t=[function(r){return r}]),r([],n,!0).sort(function(r,n){for(var e=0,o=t;e<o.length;e++){var a=o[e],i=void 0,u=void 0;if("string"==typeof a?(i=r[a],u=n[a]):"function"==typeof a?(i=a(r),u=a(n)):(i=r,u=n),null!=i||null!=u){if(null==i)return 1;if(null==u)return-1;if(i<u)return-1;if(i>u)return 1}}return 0})):[]}function d(r,n){var t;return function(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];clearTimeout(t),t=setTimeout(function(){return r.apply(void 0,e)},n)}}function A(r,n){return t(r,n)}export{h as cloneDeep,d as debounce,c as formatDate,f as getCookieValue,m as getQueryParams,y as groupBy,p as isBackNavigation,s as isClient,l as isServer,A as reaction,v as sortBy,o as stringToSlug,g as stringifyQueryParams,u as tryForEach,a as validateEmail,e as validatePhoneNumber};
1
+ import{__spreadArray as r,__assign as n}from'./../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as t}from"../packages/storefront-config/src/index.js";import{reaction as e}from'./../ext/mobx/dist/mobx.esm.js';var o=function(r){return/^\+?\d+$/.test(r)},a=function(r){r=(r=r.replace(/^\s+|\s+$/g,"")).toLocaleLowerCase("tr-TR");for(var n="àáäâèéëêìíïîıòóöôùúüûñçşğ·/_,:;",t=0;t<31;t++)r=r.replace(new RegExp(n.charAt(t),"g"),"aaaaeeeeiiiiioooouuuuncsg------".charAt(t));return r=r.replace(/[^a-z0-9 -]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-")},i=function(r){return!(r.length>320)&&/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(r)};function u(r){return!!new Intl.DateTimeFormat(r,{hour:"numeric"}).format(0).match(/\s/)}function c(r,n,t){void 0===t&&(t=!1),r.forEach(function(r,e){try{n(r,e)}catch(r){t&&console.error(r)}})}function f(r){var n={year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",hour12:!1},e=t.getCurrentLocale();return"undefined"!=typeof navigator?n.hour12=u(navigator.language):n.hour12=u(e),new Intl.DateTimeFormat(e,n).format(r)}function s(r){var n=document.cookie.split(";").find(function(n){return n.trim().startsWith("".concat(r,"="))});return n?n.split("=")[1]:null}function l(){var r=s("__oppref"),t=s("__obref");return n(n({},r?{oppref:r}:{}),t?{obref:t}:{})}function m(){return"undefined"!=typeof window}function p(){return!m()}function g(){if(m())return new URLSearchParams(location.search)}function h(){return!!m()&&(performance.getEntriesByType?"back_forward"===performance.getEntriesByType("navigation")[0].type:performance.navigation.type===performance.navigation.TYPE_BACK_FORWARD)}function v(r,n){void 0===n&&(n={arrayFormat:"comma"});for(var t=[],e=function(r,e){if(null==e)return"continue";Array.isArray(e)?"comma"===n.arrayFormat&&e.length>0?t.push("".concat(r,"=").concat(e.join(","))):e.forEach(function(n){return t.push("".concat(r,"=").concat(n))}):t.push("".concat(r,"=").concat(e))},o=0,a=Object.entries(r);o<a.length;o++){var i=a[o];e(i[0],i[1])}return t.length>0?"".concat(t.join("&")):""}function y(r){return null==r?r:JSON.parse(JSON.stringify(r))}function d(r,n){if(!r||!Array.isArray(r))return{};for(var t={},e=0,o=r;e<o.length;e++){var a=o[e],i=void 0;t[i=String("string"==typeof n?a[n]:"function"==typeof n?n(a):a)]||(t[i]=[]),t[i].push(a)}return t}function A(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return n&&Array.isArray(n)?(0===t.length&&(t=[function(r){return r}]),r([],n,!0).sort(function(r,n){for(var e=0,o=t;e<o.length;e++){var a=o[e],i=void 0,u=void 0;if("string"==typeof a?(i=r[a],u=n[a]):"function"==typeof a?(i=a(r),u=a(n)):(i=r,u=n),null!=i||null!=u){if(null==i)return 1;if(null==u)return-1;if(i<u)return-1;if(i>u)return 1}}return 0})):[]}function _(r,n){var t;return function(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];clearTimeout(t),t=setTimeout(function(){return r.apply(void 0,e)},n)}}function b(r,n){return e(r,n)}export{y as cloneDeep,_ as debounce,f as formatDate,s as getCookieValue,l as getOpenAiAttributionMetadata,g as getQueryParams,d as groupBy,h as isBackNavigation,m as isClient,p as isServer,b as reaction,A as sortBy,a as stringToSlug,v as stringifyQueryParams,c as tryForEach,i as validateEmail,o as validatePhoneNumber};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/bp-storefront",
3
- "version": "2.9.1",
3
+ "version": "2.9.2",
4
4
  "description": "A framework for the ikas blueprint storefronts.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",