@ikas/bp-storefront 1.4.0-beta.13 → 1.4.0-beta.130
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.
- package/dist/analytics/analytics-functions/helpers.js +1 -1
- package/dist/analytics/analytics.js +1 -1
- package/dist/analytics/google-tag-manager/productView.js +1 -1
- package/dist/analytics/google-tag-manager/viewCategory.js +1 -1
- package/dist/analytics/ikas/analytics.js +1 -1
- package/dist/analytics/utils.js +1 -1
- package/dist/ext/lodash/flatten.js +1 -0
- package/dist/functions/api/cart/index.js +1 -1
- package/dist/functions/models/category/index.js +1 -1
- package/dist/functions/models/image/index.d.ts +65 -20
- package/dist/functions/models/image/index.js +1 -1
- package/dist/functions/models/product/variant/index.d.ts +72 -6
- package/dist/functions/models/product/variant/index.js +1 -1
- package/dist/functions/models/product-list/index.js +1 -1
- package/dist/functions/models/validator/account-info/index.js +1 -1
- package/dist/functions/models/validator/address/index.d.ts +70 -2
- package/dist/functions/models/validator/contact-form/index.js +1 -1
- package/dist/functions/models/validator/coupon-code-form/index.js +1 -1
- package/dist/functions/models/validator/customer-review/index.js +1 -1
- package/dist/functions/models/validator/forgot-password/index.js +1 -1
- package/dist/functions/models/validator/login/index.js +1 -1
- package/dist/functions/models/validator/newsletter-subscription/index.js +1 -1
- package/dist/functions/models/validator/order-tracking/index.js +1 -1
- package/dist/functions/models/validator/recover-password/index.js +1 -1
- package/dist/functions/models/validator/register/index.js +1 -1
- package/dist/functions/models/validator/sms-login/index.js +1 -1
- package/dist/functions/models/validator/verify-phone-number/index.js +1 -1
- package/dist/functions/stores/base/index.d.ts +38 -1
- package/dist/functions/stores/base/index.js +1 -1
- package/dist/functions/stores/cart/index.js +1 -1
- package/dist/functions/stores/customer/index.d.ts +29 -23
- package/dist/functions/stores/customer/index.js +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/packages/storefront-config/src/index.js +1 -1
- package/dist/packages/storefront-config/src/theme-globals.js +1 -0
- package/dist/storefront-config/src/index.d.ts +4 -0
- package/dist/storefront-config/src/theme-globals.d.ts +305 -0
- package/dist/storefront-models/src/index.d.ts +1 -0
- package/dist/storefront-models/src/models/blueprint/prop-value/color.d.ts +2 -0
- package/dist/storefront-models/src/models/blueprint/prop-value/index.d.ts +2 -0
- package/dist/storefront-models/src/models/blueprint/prop-value/svg-list.d.ts +3 -0
- package/dist/storefront-models/src/models/blueprint/prop-value/svg.d.ts +3 -0
- package/dist/storefront-models/src/models/product/campaign/data/index.d.ts +2 -0
- package/dist/storefront-models/src/models/product/campaign/filter/index.d.ts +1 -1
- package/dist/storefront-models/src/models/product/campaign/product-tiered-discount/index.d.ts +13 -0
- package/dist/storefront-models/src/models/product/variant/index.d.ts +17 -0
- package/dist/theme/settings/index.d.ts +48 -0
- package/dist/theme/settings/index.js +1 -0
- package/dist/utils/component-renderer.d.ts +2 -1
- package/dist/utils/component-renderer.js +1 -1
- package/dist/utils/pay-with-ikas.d.ts +552 -0
- package/dist/utils/pay-with-ikas.js +1 -0
- package/dist/utils/svg.d.ts +15 -0
- package/dist/utils/svg.js +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as s,__generator as o,__assign as t}from'./../../ext/tslib/tslib.es6.mjs.js';import{getCustomerBasicInfo as e}from"../../functions/models/customer/index.js";import"../../packages/storefront-config/src/index.js";import'./../../ext/lodash/sortBy.js';import"../../stores/base/index.js";import"../../stores/cart/index.js";import{customerStore as r}from"../../stores/customer/index.js";import'./../../ext/mobx/dist/mobx.esm.js';import"../../i18n/index.js";import"../../router/index.js";import{waitForCustomerStoreInit as n}from"../../functions/stores/customer/index.js";function i(){return s(this,void 0,void 0,function(){var s;return o(this,function(o){switch(o.label){case 0:return[4,n(r)];case 1:return o.sent(),(s=r.customer)?[2,t(t({},e(s)),{consentGranted:r._customerConsentGranted})]:[2,null]}})})}export{i as getCustomerInfo};
|
|
1
|
+
import{__awaiter as s,__generator as o,__assign as t}from'./../../ext/tslib/tslib.es6.mjs.js';import{getCustomerBasicInfo as e}from"../../functions/models/customer/index.js";import"../../packages/storefront-config/src/index.js";import'./../../ext/lodash/_isFlattenable.js';import'./../../ext/lodash/sortBy.js';import"../../stores/base/index.js";import"../../stores/cart/index.js";import{customerStore as r}from"../../stores/customer/index.js";import'./../../ext/mobx/dist/mobx.esm.js';import"../../i18n/index.js";import"../../router/index.js";import{waitForCustomerStoreInit as n}from"../../functions/stores/customer/index.js";function i(){return s(this,void 0,void 0,function(){var s;return o(this,function(o){switch(o.label){case 0:return[4,n(r)];case 1:return o.sent(),(s=r.customer)?[2,t(t({},e(s)),{consentGranted:r._customerConsentGranted})]:[2,null]}})})}export{i as getCustomerInfo};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../packages/storefront-config/src/index.js";import'./../ext/mobx/dist/mobx.esm.js';import'./../ext/lodash/sortBy.js';import"../router/index.js";import"../stores/cart/index.js";import"../stores/customer/index.js";import"../packages/storefront-api-client/src/utils/api.js";import'./../ext/isomorphic-fetch/fetch-npm-node.js';import"../stores/base/index.js";import"../i18n/index.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";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"../functions/models/product-list/index.js";var s=function(){function s(){}return s.subscribers=[],s}();export{s as Analytics};
|
|
1
|
+
import"../packages/storefront-config/src/index.js";import'./../ext/mobx/dist/mobx.esm.js';import'./../ext/lodash/sortBy.js';import"../router/index.js";import"../stores/cart/index.js";import"../stores/customer/index.js";import"../packages/storefront-api-client/src/utils/api.js";import'./../ext/isomorphic-fetch/fetch-npm-node.js';import"../stores/base/index.js";import"../i18n/index.js";import'./../ext/lodash/_isFlattenable.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";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"../functions/models/product-list/index.js";var s=function(){function s(){}return s.subscribers=[],s}();export{s as Analytics};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getProductHref as s}from"../../functions/models/product/index.js";import"../../packages/storefront-config/src/index.js";import'./../../ext/mobx/dist/mobx.esm.js';import"../../router/index.js";import"../../stores/cart/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"../../functions/models/product-list/index.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";import{extractProductData as e}from"../utils.js";import{dataLayer as o,formatGTMItem as t}from"./utils.js";function i(i){if(o())try{var r=e(i),m={event:"view_item-GTM",ecommerce:{items:[t(r)],extraParams:{parent_id:i.id,currency:r.currency,url:"https://".concat(window.location.hostname).concat(s(i)),item_image:r.image||"",barcode:r.barcode||"",sellPrice:r.sellPrice,discountPrice:r.discountPrice}}};return window.dataLayer.push(m),m}catch(s){console.error(s)}}export{i as gtm_productView};
|
|
1
|
+
import{getProductHref as s}from"../../functions/models/product/index.js";import"../../packages/storefront-config/src/index.js";import'./../../ext/mobx/dist/mobx.esm.js';import"../../router/index.js";import"../../stores/cart/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"../../functions/models/product-list/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";import{extractProductData as e}from"../utils.js";import{dataLayer as o,formatGTMItem as t}from"./utils.js";function i(i){if(o())try{var r=e(i),m={event:"view_item-GTM",ecommerce:{items:[t(r)],extraParams:{parent_id:i.id,currency:r.currency,url:"https://".concat(window.location.hostname).concat(s(i)),item_image:r.image||"",barcode:r.barcode||"",sellPrice:r.sellPrice,discountPrice:r.discountPrice}}};return window.dataLayer.push(m),m}catch(s){console.error(s)}}export{i as gtm_productView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../../packages/storefront-config/src/index.js";import'./../../ext/lodash/sortBy.js';import'./../../ext/mobx/dist/mobx.esm.js';import"../../router/index.js";import"../../stores/cart/index.js";import"../../stores/customer/index.js";import"../../packages/storefront-api-client/src/utils/api.js";import'./../../ext/isomorphic-fetch/fetch-npm-node.js';import"../../stores/base/index.js";import"../../i18n/index.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";import{getIkasCategoryHref as s}from"../../functions/models/category/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"../../functions/models/product-list/index.js";import{dataLayer as e}from"./utils.js";function o(o,t){if(e())try{var i={event:"view_category-GTM",ecommerce:{category:[{id:o.id,name:o.name,metaData:o.metaData,href:s(o),image:o.image,path:t}]}};return window.dataLayer.push(i),i}catch(s){console.error(s)}}export{o as gtm_viewCategory};
|
|
1
|
+
import"../../packages/storefront-config/src/index.js";import'./../../ext/lodash/sortBy.js';import'./../../ext/mobx/dist/mobx.esm.js';import"../../router/index.js";import"../../stores/cart/index.js";import"../../stores/customer/index.js";import"../../packages/storefront-api-client/src/utils/api.js";import'./../../ext/isomorphic-fetch/fetch-npm-node.js';import"../../stores/base/index.js";import"../../i18n/index.js";import'./../../ext/lodash/_isFlattenable.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";import{getIkasCategoryHref as s}from"../../functions/models/category/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"../../functions/models/product-list/index.js";import{dataLayer as e}from"./utils.js";function o(o,t){if(e())try{var i={event:"view_category-GTM",ecommerce:{category:[{id:o.id,name:o.name,metaData:o.metaData,href:s(o),image:o.image,path:t}]}};return window.dataLayer.push(i),i}catch(s){console.error(s)}}export{o as gtm_viewCategory};
|
|
@@ -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/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",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 _(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({},F()),{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({},F()),{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({},F()),{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({},F()),{d:{crt:{id:r.id,c:r.currencyCode,pr:r.totalFinalPrice,il:K(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,M([{id:i,t:E.ORDER_SUCCESS,ts:Date.now(),d:n(n({},F()),{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 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.BEGIN_CHECKOUT,ts:Date.now(),d:n(n({},F()),{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({},F()),{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({},F()),{d:{cst:W()}})}])];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({},F()),{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,M([{t:E.CUSTOMER_VISIT,ts:Date.now(),d:n(n({},F()),{d:{cst:W()}})}])];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({},F()),{d:{cst:W(),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({},F()),{d:{cst:W(),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({},F()),{d:{cst:W()},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({},F()),{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({},F())}])];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({},F()),{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(f.JOURNEY_ID_KEY),f.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(f.JOURNEY_ID_KEY))?(f.journeyId=t,[3,3]):[3,1];case 1:return[4,V()];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 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()+f.EXPIRY_LENGTH,t=r,localStorage.setItem(f.SESSION_ID_KEY,JSON.stringify(t)),f.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(f.JOURNEY_ID_KEY,t),f.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(f.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:f.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:f.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({},F())}])];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(f.VISITOR_ID_KEY))&&t.length>13?(f.visitorId=t,[3,3]):[3,1];case 1:return n=f,[4,j()];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 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 W(){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 F(){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,_,T,I;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:f.sessionId,jid:f.journeyId,vid:f.visitorId,sfrid:r.storefrontRoutingId||"",ud:n(n(n(n({id:null===(o=c.customer)||void 0===o?void 0:o.id},(null===(u=c.customer)||void 0===u?void 0:u.email)?{em:null===(d=c.customer)||void 0===d?void 0:d.email}:{}),(null===(a=c.customer)||void 0===a?void 0:a.phone)?{ph:null===(E=c.customer)||void 0===E?void 0:E.phone}:{}),(null===(O=c.customer)||void 0===O?void 0:O.lastName)?{ln:null===(_=c.customer)||void 0===_?void 0:_.lastName}:{}),(null===(T=c.customer)||void 0===T?void 0:T.firstName)?{fn:null===(I=c.customer)||void 0===I?void 0:I.firstName}:{}),v:3},[4,fetch(R,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json","x-api-key":r.apiKey}})];case 5:return e.sent(),[3,7];case 6:return s=e.sent(),console.error(s),[3,7];case 7:return[2]}})})}export{f as default,I as iks_addToCart,w as iks_addToWishlist,v 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,_ as iks_pageView,T as iks_productView,C 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}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 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.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 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.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;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===(o=c.customer)||void 0===o?void 0:o.id},(null===(u=c.customer)||void 0===u?void 0:u.email)?{em:null===(d=c.customer)||void 0===d?void 0:d.email}:{}),(null===(a=c.customer)||void 0===a?void 0:a.phone)?{ph:null===(E=c.customer)||void 0===E?void 0:E.phone}:{}),(null===(O=c.customer)||void 0===O?void 0:O.lastName)?{ln:null===(f=c.customer)||void 0===f?void 0:f.lastName}:{}),(null===(T=c.customer)||void 0===T?void 0:T.firstName)?{fn:null===(I=c.customer)||void 0===I?void 0:I.firstName}:{}),v:3},[4,fetch(R,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json","x-api-key":r.apiKey}})];case 5:return e.sent(),[3,7];case 6:return s=e.sent(),console.error(s),[3,7];case 7:return[2]}})})}export{_ as default,I as iks_addToCart,w as iks_addToWishlist,v 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,C 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};
|
package/dist/analytics/utils.js
CHANGED
|
@@ -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
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"./_baseFlatten.js";var r=t;var a=function(t){return(null==t?0:t.length)?r(t,1):[]};export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as r,__assign as t}from'./../../../ext/tslib/tslib.es6.mjs.js';import{APIResponse as s}from"../../../packages/storefront-api-client/src/utils/api.js";import'./../../../ext/isomorphic-fetch/fetch-npm-node.js';import{IkasStorefrontConfig as i}from"../../../packages/storefront-config/src/index.js";import"../../../analytics/analytics.js";import'./../../../ext/mobx/dist/mobx.esm.js';import'./../../../ext/animejs/lib/anime.esm.js';import"../../../packages/storefront-api/src/index.js";import{initIkasCampaignOffer as n}from"../../models/product/campaign-offer/init.js";import"../../../stores/customer/index.js";import"../../../i18n/index.js";import'./../../../ext/lodash/sortBy.js';import"../../../router/index.js";import"../../../stores/cart/index.js";import"../../../stores/base/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{initIkasOrder as d}from"../../models/order/index.js";import"../../models/product-list/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";function o(e){return t(t({},d(e)),{cancelReason:null})}function a(t){return e(this,void 0,void 0,function(){var e,d,a;return r(this,function(r){switch(r.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/getCartById.js")];case 1:return[4,(0,r.sent().getCartById)(t,["merchantId","orderLineItems.variant.tagIds","billingAddress.region.createdAt","billingAddress.region.deleted","billingAddress.region.updatedAt","shippingAddress.region.createdAt","shippingAddress.region.deleted","shippingAddress.region.updatedAt","currencyRates","abandonedCartFlows"])];case 2:return e=r.sent(),d=e.data?o(e.data):null,null===(a=null==d?void 0:d.campaignOffers)||void 0===a||a.forEach(function(e){e.campaignOffer&&n(e.campaignOffer,i.getCurrentLocale())}),[2,new s(d||null,e.graphQLErrors,e.errorCodes)]}})})}function p(t){return e(this,void 0,void 0,function(){var e,i;return r(this,function(r){switch(r.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/mutations/saveCart.js")];case 1:return[4,(0,r.sent().saveCart)(t,["merchantId","orderLineItems.variant.tagIds","billingAddress.region.createdAt","billingAddress.region.deleted","billingAddress.region.updatedAt","shippingAddress.region.createdAt","shippingAddress.region.deleted","shippingAddress.region.updatedAt","currencyRates","abandonedCartFlows"])];case 2:return e=r.sent(),i=e.data?o(e.data):null,[2,new s(i||null,e.graphQLErrors)]}})})}function
|
|
1
|
+
import{__awaiter as e,__generator as r,__assign as t}from'./../../../ext/tslib/tslib.es6.mjs.js';import{APIResponse as s}from"../../../packages/storefront-api-client/src/utils/api.js";import'./../../../ext/isomorphic-fetch/fetch-npm-node.js';import{IkasStorefrontConfig as i}from"../../../packages/storefront-config/src/index.js";import"../../../analytics/analytics.js";import'./../../../ext/mobx/dist/mobx.esm.js';import'./../../../ext/animejs/lib/anime.esm.js';import"../../../packages/storefront-api/src/index.js";import{initIkasCampaignOffer as n}from"../../models/product/campaign-offer/init.js";import"../../../stores/customer/index.js";import"../../../i18n/index.js";import'./../../../ext/lodash/sortBy.js';import"../../../router/index.js";import"../../../stores/cart/index.js";import"../../../stores/base/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{initIkasOrder as d}from"../../models/order/index.js";import"../../models/product-list/index.js";import'./../../../ext/lodash/_isFlattenable.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";function o(e){return t(t({},d(e)),{cancelReason:null})}function a(t){return e(this,void 0,void 0,function(){var e,d,a;return r(this,function(r){switch(r.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/queries/getCartById.js")];case 1:return[4,(0,r.sent().getCartById)(t,["merchantId","orderLineItems.variant.tagIds","billingAddress.region.createdAt","billingAddress.region.deleted","billingAddress.region.updatedAt","shippingAddress.region.createdAt","shippingAddress.region.deleted","shippingAddress.region.updatedAt","currencyRates","abandonedCartFlows"])];case 2:return e=r.sent(),d=e.data?o(e.data):null,null===(a=null==d?void 0:d.campaignOffers)||void 0===a||a.forEach(function(e){e.campaignOffer&&n(e.campaignOffer,i.getCurrentLocale())}),[2,new s(d||null,e.graphQLErrors,e.errorCodes)]}})})}function p(t){return e(this,void 0,void 0,function(){var e,i;return r(this,function(r){switch(r.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/mutations/saveCart.js")];case 1:return[4,(0,r.sent().saveCart)(t,["merchantId","orderLineItems.variant.tagIds","billingAddress.region.createdAt","billingAddress.region.deleted","billingAddress.region.updatedAt","shippingAddress.region.createdAt","shippingAddress.region.deleted","shippingAddress.region.updatedAt","currencyRates","abandonedCartFlows"])];case 2:return e=r.sent(),i=e.data?o(e.data):null,[2,new s(i||null,e.graphQLErrors)]}})})}function l(t){return e(this,void 0,void 0,function(){var e;return r(this,function(r){switch(r.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/mutations/createPayWithIkasSessionUrl.js")];case 1:return[4,(0,r.sent().createPayWithIkasSessionUrl)(t)];case 2:return e=r.sent(),[2,new s(e.data,e.graphQLErrors)]}})})}function u(t){return e(this,void 0,void 0,function(){var e,i;return r(this,function(r){switch(r.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/mutations/saveCartCouponCode.js")];case 1:return[4,(0,r.sent().saveCartCouponCode)(t,["merchantId","orderLineItems.variant.tagIds","billingAddress.region.createdAt","billingAddress.region.deleted","billingAddress.region.updatedAt","shippingAddress.region.createdAt","shippingAddress.region.deleted","shippingAddress.region.updatedAt","currencyRates","abandonedCartFlows"])];case 2:return e=r.sent(),i=e.data?o(e.data):null,[2,new s(i||null,e.graphQLErrors)]}})})}function c(t){return e(this,void 0,void 0,function(){var e,i;return r(this,function(r){switch(r.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/mutations/addItemToCart.js")];case 1:return[4,(0,r.sent().addItemToCart)(t,["merchantId","orderLineItems.variant.tagIds","billingAddress.region.createdAt","billingAddress.region.deleted","billingAddress.region.updatedAt","shippingAddress.region.createdAt","shippingAddress.region.deleted","shippingAddress.region.updatedAt","currencyRates","abandonedCartFlows"])];case 2:return e=r.sent(),i=e.data?o(e.data):null,[2,new s(i||null,e.graphQLErrors)]}})})}function m(t){return e(this,void 0,void 0,function(){var e,i;return r(this,function(r){switch(r.label){case 0:return[4,import("../../../packages/storefront-api/src/__api/mutations/updateCartCampaignOffer.js")];case 1:return[4,(0,r.sent().updateCartCampaignOffer)(t,["merchantId","orderLineItems.variant.tagIds","billingAddress.region.createdAt","billingAddress.region.deleted","billingAddress.region.updatedAt","shippingAddress.region.createdAt","shippingAddress.region.deleted","shippingAddress.region.updatedAt","currencyRates","abandonedCartFlows"])];case 2:return e=r.sent(),i=e.data?o(e.data):null,[2,new s(i||null,e.graphQLErrors)]}})})}export{c as apiAddItemToCart,l as apiCreatePayWithIkasSessionUrl,a as apiGetCartById,p as apiSaveCart,u as apiSaveCartCouponCode,m as apiUpdateCartCampaignOffer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{withRoutePrefix as t}from"../../../router/index.js";function e(e){var a;return(null===(a=e.metaData)||void 0===a?void 0:a.slug)?t("/".concat(e.metaData.slug)):""}function a(t){var e={id:t.id,createdAt:t.createdAt,updatedAt:t.updatedAt,deleted:t.deleted,metaData:t.metaData,description:t.description,imageId:t.imageId,name:t.name};return t.categoryPathItems.some(function(t){return t.id===e.id})?t.categoryPathItems:t.categoryPathItems.concat(e)}export{a as getCategoryPath,e as getIkasCategoryHref};
|
|
1
|
+
import{withRoutePrefix as t}from"../../../router/index.js";function e(e){var a;return(null===(a=e.metaData)||void 0===a?void 0:a.slug)?t("/".concat(e.metaData.slug)):""}function a(t){if(!t)return[];var e={id:t.id,createdAt:t.createdAt,updatedAt:t.updatedAt,deleted:t.deleted,metaData:t.metaData,description:t.description,imageId:t.imageId,name:t.name};return t.categoryPathItems.some(function(t){return t.id===e.id})?t.categoryPathItems:t.categoryPathItems.concat(e)}export{a as getCategoryPath,e as getIkasCategoryHref};
|
|
@@ -1,62 +1,97 @@
|
|
|
1
1
|
import { IkasImage } from "../../../storefront-models/src";
|
|
2
2
|
/**
|
|
3
|
-
* Returns the default source URL for an image at 1080px resolution.
|
|
3
|
+
* Returns the default source URL for an image OR video at 1080px resolution.
|
|
4
|
+
*
|
|
5
|
+
* Product media items (IkasProductImage) can be videos. ALWAYS check `item.isVideo`
|
|
6
|
+
* and render a `<video src={getDefaultSrc(item)}>` instead of an `<img>` when it is true.
|
|
7
|
+
* Never assume every media item is an image.
|
|
4
8
|
*
|
|
5
9
|
* @ai-category Image
|
|
6
10
|
* @ai-related getThumbnailSrc, getSrc, createMediaSrcset
|
|
7
11
|
*
|
|
8
12
|
* @param image - The image object to generate the default source URL for.
|
|
9
|
-
* @returns The CDN URL string for the image at 1080px size.
|
|
13
|
+
* @returns The CDN URL string for the image or video at 1080px size.
|
|
10
14
|
*
|
|
11
15
|
* @example
|
|
12
16
|
* ```typescript
|
|
13
|
-
* import { getDefaultSrc } from "@ikas/bp-storefront";
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
+
* import { getDefaultSrc, createMediaSrcset } from "@ikas/bp-storefront";
|
|
18
|
+
*
|
|
19
|
+
* // Product images can be videos — ALWAYS branch on isVideo when mapping media:
|
|
20
|
+
* {product.images.map((item, i) =>
|
|
21
|
+
* item.isVideo ? (
|
|
22
|
+
* <video key={i} src={getDefaultSrc(item)} muted playsInline preload="metadata">
|
|
23
|
+
* <track kind="captions" />
|
|
24
|
+
* </video>
|
|
25
|
+
* ) : (
|
|
26
|
+
* <img key={i} src={getDefaultSrc(item)} srcSet={createMediaSrcset(item)} alt={`Product ${i + 1}`} />
|
|
27
|
+
* )
|
|
28
|
+
* )}
|
|
17
29
|
* ```
|
|
18
30
|
*/
|
|
19
31
|
export declare function getDefaultSrc(image: IkasImage): string;
|
|
20
32
|
/**
|
|
21
|
-
* Returns the thumbnail source URL for an image at 180px resolution.
|
|
33
|
+
* Returns the thumbnail source URL for an image OR video at 180px resolution.
|
|
34
|
+
*
|
|
35
|
+
* When mapping over product media (IkasProductImage[]), some items are videos:
|
|
36
|
+
* check `item.isVideo` and render a `<video>` thumbnail (typically with a play
|
|
37
|
+
* overlay) instead of an `<img>` when it is true.
|
|
22
38
|
*
|
|
23
39
|
* @ai-category Image
|
|
24
40
|
* @ai-related getDefaultSrc, getSrc, createMediaSrcset
|
|
25
41
|
*
|
|
26
42
|
* @param image - The image object to generate the thumbnail source URL for.
|
|
27
|
-
* @returns The CDN URL string for the image at 180px size.
|
|
43
|
+
* @returns The CDN URL string for the image or video at 180px size.
|
|
28
44
|
*
|
|
29
45
|
* @example
|
|
30
46
|
* ```typescript
|
|
31
|
-
* import { getThumbnailSrc } from "@ikas/bp-storefront";
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
47
|
+
* import { getThumbnailSrc, getDefaultSrc } from "@ikas/bp-storefront";
|
|
48
|
+
*
|
|
49
|
+
* // Thumbnail rail — branch on isVideo per item:
|
|
50
|
+
* {product.images.map((item, i) =>
|
|
51
|
+
* item.isVideo ? (
|
|
52
|
+
* <video key={i} src={getDefaultSrc(item)} muted preload="metadata">
|
|
53
|
+
* <track kind="captions" />
|
|
54
|
+
* </video>
|
|
55
|
+
* ) : (
|
|
56
|
+
* <img key={i} src={getThumbnailSrc(item)} sizes="112px" alt={`Thumb ${i + 1}`} />
|
|
57
|
+
* )
|
|
58
|
+
* )}
|
|
35
59
|
* ```
|
|
36
60
|
*/
|
|
37
61
|
export declare function getThumbnailSrc(image: IkasImage): string;
|
|
38
62
|
/**
|
|
39
63
|
* Generates the full CDN source URL for an image or video at the specified size, handling both legacy path-based and merchant-scoped ID formats.
|
|
40
64
|
*
|
|
65
|
+
* NOTE: For videos (`image.isVideo === true`) the `size` argument is IGNORED — the original .mp4 is always returned.
|
|
66
|
+
* So `getSrc(item, 240)` and `getDefaultSrc(item)` produce the identical URL for a video. PREFER `getDefaultSrc(item)`
|
|
67
|
+
* for video `src` (no size param) — do NOT pass an arbitrary size like `getSrc(item, 240)`, it is misleading.
|
|
68
|
+
*
|
|
41
69
|
* @ai-category Image
|
|
42
70
|
* @ai-related getDefaultSrc, getThumbnailSrc, createMediaSrcset
|
|
43
71
|
*
|
|
44
72
|
* @param image - The image object containing the id, fileName, and isVideo flag.
|
|
45
|
-
* @param size - The desired image width in pixels for
|
|
73
|
+
* @param size - The desired image width in pixels. Ignored for videos.
|
|
46
74
|
* @returns The full CDN URL string for the image or video.
|
|
47
75
|
*
|
|
48
76
|
* @example
|
|
49
77
|
* ```typescript
|
|
50
|
-
* import { getSrc } from "@ikas/bp-storefront";
|
|
78
|
+
* import { getSrc, getDefaultSrc } from "@ikas/bp-storefront";
|
|
51
79
|
*
|
|
52
80
|
* const src = getSrc(image, 640);
|
|
53
81
|
* console.log(src); // "https://cdn.example.com/images/.../640/image.webp"
|
|
82
|
+
*
|
|
83
|
+
* // For a video, use getDefaultSrc (size is ignored anyway):
|
|
84
|
+
* <video src={getDefaultSrc(item)} muted playsInline preload="metadata" />
|
|
54
85
|
* ```
|
|
55
86
|
*/
|
|
56
87
|
export declare function getSrc(image: IkasImage, size: number): string;
|
|
57
88
|
/**
|
|
58
89
|
* Generates a complete responsive `srcset` string for an image across all standard sizes (180–3840px).
|
|
59
90
|
*
|
|
91
|
+
* srcset applies to `<img>` only — video media (`item.isVideo === true`) has no srcset
|
|
92
|
+
* and must be rendered with `<video src={getDefaultSrc(item)}>`. When mapping product
|
|
93
|
+
* images, branch on `item.isVideo` first, then only use createMediaSrcset on the image branch.
|
|
94
|
+
*
|
|
60
95
|
* @ai-category Image
|
|
61
96
|
* @ai-related getDefaultSrc, getThumbnailSrc, getSrc
|
|
62
97
|
*
|
|
@@ -67,12 +102,22 @@ export declare function getSrc(image: IkasImage, size: number): string;
|
|
|
67
102
|
* ```typescript
|
|
68
103
|
* import { createMediaSrcset, getDefaultSrc } from "@ikas/bp-storefront";
|
|
69
104
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
105
|
+
* // Product images can be videos — ALWAYS branch on isVideo when mapping media:
|
|
106
|
+
* {product.images.map((item, i) =>
|
|
107
|
+
* item.isVideo ? (
|
|
108
|
+
* <video key={i} src={getDefaultSrc(item)} muted playsInline preload="metadata">
|
|
109
|
+
* <track kind="captions" />
|
|
110
|
+
* </video>
|
|
111
|
+
* ) : (
|
|
112
|
+
* <img
|
|
113
|
+
* key={i}
|
|
114
|
+
* src={getDefaultSrc(item)}
|
|
115
|
+
* srcSet={createMediaSrcset(item)}
|
|
116
|
+
* sizes="(max-width: 768px) 100vw, 50vw"
|
|
117
|
+
* alt={`Product ${i + 1}`}
|
|
118
|
+
* />
|
|
119
|
+
* )
|
|
120
|
+
* )}
|
|
76
121
|
* ```
|
|
77
122
|
*/
|
|
78
123
|
export declare function createMediaSrcset(image?: IkasImage | null): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IkasStorefrontConfig as c}from"../../../packages/storefront-config/src/index.js";function n(c){return
|
|
1
|
+
import{IkasStorefrontConfig as c}from"../../../packages/storefront-config/src/index.js";function n(c){return o(c,1080)}function i(c){return o(c,180)}function o(n,i){var o;if(!(null==n?void 0:n.id))return"";var a=c.cdnUrl,t=c.videoCdnUrl;if(n.id.includes("/"))return n.isVideo?"".concat(t,"videos/").concat(n.id,"/original.mp4"):n.fileName?"".concat(a,"images/").concat(n.id,"/").concat(i,"/").concat(n.fileName,".webp"):"".concat(a,"images/").concat(n.id,"/image_").concat(i,".webp");var e=null===(o=c.merchantSettings)||void 0===o?void 0:o.merchantId;return n.isVideo?"".concat(t,"videos/").concat(e,"/").concat(n.id,"/original.mp4"):n.fileName?"".concat(a,"images/").concat(e,"/").concat(n.id,"/").concat(i,"/").concat(n.fileName,".webp"):"".concat(a,"images/").concat(e,"/").concat(n.id,"/image_").concat(i,".webp")}var a=[180,360,420,540,640,720,800,900,1080,1296,1350,1512,1728,1950,2560,3840];function t(c){return(null==c?void 0:c.id)?a.map(function(n){return"".concat(o(c,n)," ").concat(n,"w")}).join(", "):""}export{t as createMediaSrcset,n as getDefaultSrc,o as getSrc,i as getThumbnailSrc};
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { BackInStockNotificationForm, IkasAppliedCampaignAmount, IkasProductAttributeMap, IkasProductPrice, IkasProductVariant } from "../../../../storefront-models/src";
|
|
1
|
+
import { BackInStockNotificationForm, IkasAppliedCampaignAmount, IkasProductAttributeMap, IkasProductPrice, IkasProductVariant, IkasTieredDiscountProduct } from "../../../../storefront-models/src";
|
|
2
2
|
/**
|
|
3
|
-
* Get the main/primary
|
|
3
|
+
* Get the main/primary media item for a product variant.
|
|
4
|
+
*
|
|
5
|
+
* The returned IkasProductImage may be a video (`isVideo === true`) — branch on it
|
|
6
|
+
* and render `<video>` instead of `<img>`.
|
|
4
7
|
*
|
|
5
8
|
* @ai-category ProductDetail, ProductList
|
|
6
9
|
* @ai-related getSelectedProductVariant
|
|
7
10
|
*
|
|
8
11
|
* @param variant - The product variant
|
|
9
|
-
* @returns The first IkasProductImage of the variant, or undefined if no images.
|
|
12
|
+
* @returns The first IkasProductImage of the variant, or undefined if no images. Check `.isVideo` to decide between `<video>` and `<img>`, and access `.image` to get the IkasImage for CDN helpers.
|
|
10
13
|
*
|
|
11
14
|
* @example
|
|
12
15
|
* ```typescript
|
|
13
|
-
* import { getProductVariantMainImage, getSelectedProductVariant, getDefaultSrc } from "@ikas/bp-storefront";
|
|
16
|
+
* import { getProductVariantMainImage, getSelectedProductVariant, getDefaultSrc, createMediaSrcset } from "@ikas/bp-storefront";
|
|
14
17
|
* import { IkasProduct } from "@ikas/bp-storefront";
|
|
15
18
|
*
|
|
16
19
|
* function ProductImage({ product }: { product: IkasProduct }) {
|
|
@@ -22,7 +25,14 @@ import { BackInStockNotificationForm, IkasAppliedCampaignAmount, IkasProductAttr
|
|
|
22
25
|
* return <div className="no-image">No image available</div>;
|
|
23
26
|
* }
|
|
24
27
|
*
|
|
25
|
-
*
|
|
28
|
+
* // Media can be a video — branch on isVideo:
|
|
29
|
+
* return productImage.isVideo ? (
|
|
30
|
+
* <video src={getDefaultSrc(image)} muted playsInline loop>
|
|
31
|
+
* <track kind="captions" />
|
|
32
|
+
* </video>
|
|
33
|
+
* ) : (
|
|
34
|
+
* <img src={getDefaultSrc(image)} srcSet={createMediaSrcset(image)} alt={product.name} />
|
|
35
|
+
* );
|
|
26
36
|
* }
|
|
27
37
|
* ```
|
|
28
38
|
*/
|
|
@@ -328,11 +338,19 @@ export declare function getProductVariantFormattedBuyPrice(variant: IkasProductV
|
|
|
328
338
|
/**
|
|
329
339
|
* Get the applied campaign discount amount details for a product variant, including type and formatted value.
|
|
330
340
|
*
|
|
341
|
+
* How the discount value is interpreted depends on `campaign.type`:
|
|
342
|
+
* - `"FIXED_AMOUNT"` → the value is an absolute money amount, returned in `formattedPrice` (e.g. "$10.00"); `discountPercentage` stays null.
|
|
343
|
+
* - `"RATIO"` → the value is a percentage, returned in `discountPercentage` (e.g. "10" for 10% off); `formattedPrice` stays null.
|
|
344
|
+
*
|
|
345
|
+
* Both fixed and tiered campaigns are supported. For a tiered-discount campaign
|
|
346
|
+
* (`campaign.fixedDiscount` is null and the discount lives in `campaign.tieredDiscount.rules`),
|
|
347
|
+
* the first tier's amount (`campaign.tieredDiscount.rules[0].amount`) is used, matching the storefront runtime.
|
|
348
|
+
*
|
|
331
349
|
* @ai-category Pricing, ProductVariant
|
|
332
350
|
* @ai-related getProductVariantCampaignPrice, getProductVariantFormattedCampaignPrice, hasProductVariantDiscount
|
|
333
351
|
*
|
|
334
352
|
* @param variant - The product variant to check for applied campaigns
|
|
335
|
-
* @returns An object
|
|
353
|
+
* @returns An object `{ type, formattedPrice, discountPercentage }` — `formattedPrice` is set for FIXED_AMOUNT campaigns, `discountPercentage` for RATIO campaigns (fixed and tiered alike); the other field stays null. Returns null if no campaign is applied.
|
|
336
354
|
*
|
|
337
355
|
* @example
|
|
338
356
|
* ```typescript
|
|
@@ -700,6 +718,54 @@ export declare function getProductVariantFormattedSellPriceWithCampaignOffers(va
|
|
|
700
718
|
* ```
|
|
701
719
|
*/
|
|
702
720
|
export declare function getProductVariantCampaignOffersDiscountPercentage(variant: IkasProductVariant): number;
|
|
721
|
+
/**
|
|
722
|
+
* Get the tiered-discount breakdown for a product variant, one entry per discount tier.
|
|
723
|
+
*
|
|
724
|
+
* A tiered discount defines multiple quantity tiers (`campaign.tieredDiscount.rules`), each with its own
|
|
725
|
+
* amount and quantity range. This resolves every tier against the variant's price and returns the
|
|
726
|
+
* per-tier sell/final prices (both raw numbers and formatted strings), matching the storefront runtime.
|
|
727
|
+
*
|
|
728
|
+
* The discount `amount` is interpreted by `campaign.type`: `"RATIO"` treats it as a percentage,
|
|
729
|
+
* `"FIXED_AMOUNT"` as an absolute money amount subtracted from the tier total.
|
|
730
|
+
*
|
|
731
|
+
* `lineItemQuantityRange.min`/`max` are normalized numbers where `0` means "unbounded". In particular
|
|
732
|
+
* `max === 0` marks an open-ended top tier (e.g. "6+" with no upper limit) — render it as "min+" rather
|
|
733
|
+
* than "min–max", and never treat `max` as a real quantity when it is `0`.
|
|
734
|
+
*
|
|
735
|
+
* Returns an empty array when the variant has no tiered-discount campaign, when a
|
|
736
|
+
* `PRODUCT_AND_VARIANT` filter excludes this variant, or when no tier defines a quantity range.
|
|
737
|
+
*
|
|
738
|
+
* @ai-category Pricing, ProductVariant
|
|
739
|
+
* @ai-related getProductVariantAppliedCampaignAmount, getProductVariantCampaignOffersDiscountPercentage, getProductVariantFinalPrice
|
|
740
|
+
*
|
|
741
|
+
* @param variant - The product variant to resolve tiered discounts for
|
|
742
|
+
* @returns An array of tier objects (`amount`, `lineItemQuantityRange`, `type`, sell/final prices with their formatted variants, `salesChannelIds`), or an empty array if no tiered discount applies
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
* ```typescript
|
|
746
|
+
* import { getProductVariantTieredDiscountProducts, getSelectedProductVariant } from "@ikas/bp-storefront";
|
|
747
|
+
* import { IkasProduct } from "@ikas/bp-storefront";
|
|
748
|
+
*
|
|
749
|
+
* function TieredDiscountTable({ product }: { product: IkasProduct }) {
|
|
750
|
+
* const variant = getSelectedProductVariant(product);
|
|
751
|
+
* const tiers = getProductVariantTieredDiscountProducts(variant);
|
|
752
|
+
*
|
|
753
|
+
* if (!tiers.length) return null;
|
|
754
|
+
*
|
|
755
|
+
* return (
|
|
756
|
+
* <ul>
|
|
757
|
+
* {tiers.map((tier, i) => (
|
|
758
|
+
* <li key={i}>
|
|
759
|
+
* Buy {tier.lineItemQuantityRange.min}+ → {tier.formattedFinalPriceWithQuantity}{" "}
|
|
760
|
+
* <s>{tier.formattedSellPriceWithQuantity}</s>
|
|
761
|
+
* </li>
|
|
762
|
+
* ))}
|
|
763
|
+
* </ul>
|
|
764
|
+
* );
|
|
765
|
+
* }
|
|
766
|
+
* ```
|
|
767
|
+
*/
|
|
768
|
+
export declare function getProductVariantTieredDiscountProducts(variant: IkasProductVariant): IkasTieredDiscountProduct[];
|
|
703
769
|
/**
|
|
704
770
|
* Check if the back-in-stock notification feature is enabled for the storefront.
|
|
705
771
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as r,__generator as n}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as i}from"../../../../packages/storefront-config/src/index.js";import{customerStore as t}from"../../../../stores/customer/index.js";import{formatCurrency as e}from"../../../../utils/currency.js";import{groupBy as u}from"../../../../utils/helper.js";import{initBackInStockNotificationForm as o}from"../../validator/back-in-stock-notification/index.js";import{getBundleProductFinalPriceWithQuantity as c,getBundleProductSellPriceWithQuantity as d,getSelectedProductVariant as l}from"../index.js";import{isProductOfferAccepted as a}from"../campaign-offer/index.js";import{getProductFromStore as s}from"../init.js";import{getIkasProductPriceFinalPrice as v}from"./price/index.js";function f(r){var n;return(null===(n=r.images)||void 0===n?void 0:n.length)?r.images[0]:void 0}function m(r){return r.stock>0||r.sellIfOutOfStock}function p(r){var n,i=u(r.attributes,"productAttributeId");return(null===(n=r.attributes)||void 0===n?void 0:n.map(function(r){var n=r.productAttributeId;if(n){var t=i[n];return(null==t?void 0:t.length)&&t[0].productAttribute?{attribute:t[0].productAttribute,values:t}:void 0}}).filter(function(r){return!!r}))||[]}function y(r){var n,i,e=t.customer,u=null==e?void 0:e.priceListRules,o=s(r.id),c=function(n){var i,t,e,u;if("CATEGORY"===n.type)return c=null===(i=n.valueList)||void 0===i?void 0:i.some(function(r){return null==o?void 0:o.categories.find(function(n){return n.id===r})});if("PRODUCT"===n.type)return c=null===(t=n.valueList)||void 0===t?void 0:t.some(function(n){return r.id===n});if("PRODUCT_BRAND"===n.type){var c=null===(e=n.valueList)||void 0===e?void 0:e.some(function(r){var n;return(null===(n=null==o?void 0:o.brand)||void 0===n?void 0:n.id)===r});return c}if("PRODUCT_TAG"===n.type){c=null===(u=n.valueList)||void 0===u?void 0:u.some(function(r){var n;return null===(n=null==o?void 0:o.tags)||void 0===n?void 0:n.find(function(n){return n.id===r})});return c}};if(u){for(var d=0,l=u;d<l.length;d++){var a=l[d];if(a.shouldMatchAllFilters?null===(n=a.filters)||void 0===n?void 0:n.every(c):null===(i=a.filters)||void 0===i?void 0:i.some(c))return a}return null}return null}function b(r){var n,e;if(i.isB2BStorefront()){var u=t.customer;if(null==u?void 0:u.priceListId){var o=null===(n=r.prices)||void 0===n?void 0:n.find(function(r){return r.priceListId===u.priceListId});if(o)return o}}return null===(e=r.prices)||void 0===e?void 0:e.find(function(r){return i.priceListId?r.priceListId===i.priceListId:null===r.priceListId})}function I(r){return!!r.bundleSettings}function S(r){var n,e;if(i.isB2BStorefront()){var u=t.customer;if(null==u?void 0:u.priceListId){var o=null===(n=r.baseBundlePrices)||void 0===n?void 0:n.find(function(r){return r.priceListId===u.priceListId});if(o)return o}}return(null===(e=r.baseBundlePrices)||void 0===e?void 0:e.find(function(r){return i.priceListId?r.priceListId===i.priceListId:null===r.priceListId}))||b(r)}function g(r){var n=0;if(r.bundleSettings&&r.bundleSettings.products.every(function(r){return!!r.product})){var i=S(r);n=v(i)+r.bundleSettings.products.reduce(function(r,n){return r+(n.addToBundleBasePrice?c(n):0)},0)}else n=v(b(r));var t=y(r);if(!t)return n;switch(t.valueType){case"DISCOUNT_RATE":return n*((100-t.value)/100);case"DISCOUNT_AMOUNT":return n-t.value;case"FIXED_PRICE":return t.value;default:return n}}function k(r){var n=b(r);return e(g(r),n.currency||"",n.currencySymbol||"")}function P(r){return r.bundleSettings&&r.bundleSettings.products.every(function(r){return!!r.product})?S(r).sellPrice+r.bundleSettings.products.reduce(function(r,n){return r+(n.addToBundleBasePrice?d(n):0)},0):b(r).sellPrice}function L(r){var n=b(r);return e(P(r),n.currency||"",n.currencySymbol||"")}function B(r){var n=b(r);return e(b(r).buyPrice||0,n.currency||"",n.currencySymbol||"")}function R(r){var n,i,t,u,o,c,d=s(r.id),l=b(r);if(!(null===(n=l.campaignPrice)||void 0===n?void 0:n.campaignId))return null;var a=(null===(t=null===(i=null==d?void 0:d.campaigns)||void 0===i?void 0:i.find(function(r){var n;return r.campaign.id===(null===(n=l.campaignPrice)||void 0===n?void 0:n.campaignId)}))||void 0===t?void 0:t.campaign)||null;if(!a)return null;var v={type:a.type,formattedPrice:null,discountPercentage:null};return"FIXED_AMOUNT"===a.type&&(v.formattedPrice=e((null===(u=a.fixedDiscount)||void 0===u?void 0:u.amount)||0,l.currency||"",l.currencySymbol||"")),"RATIO"===a.type&&(v.discountPercentage=(null===(c=null===(o=a.fixedDiscount)||void 0===o?void 0:o.amount)||void 0===c?void 0:c.toString())||null),v}function T(r){var n;return(null===(n=b(r).campaignPrice)||void 0===n?void 0:n.campaignPrice)||null}function A(r){var n=b(r);return e(T(r)||0,n.currency||"",n.currencySymbol||"")}function j(r){var n=g(r);return n===P(r)?null:n}function x(r){var n=b(r);return e(j(r)||0,n.currency||"",n.currencySymbol||"")}function _(r){return null!==j(r)}function h(r){var n=b(r);return e(F(r),n.currency||"",n.currencySymbol||"")}function F(r){var n=g(r),i=P(r);return _(r)?i-n:0}function O(r){return(100-100*g(r)/P(r)).toFixed(0)}function D(r){var n,i=g(r),t=s(r.id);return i+((null===(n=null==t?void 0:t.offers)||void 0===n?void 0:n.filter(function(r){return r.isSelected&&!a(r)}).reduce(function(r,n){return r+g(l(n.product))},0))||0)}function U(r){var n=D(r),i=b(r);return e(n,i.currency||"",i.currencySymbol||"")}function C(r){var n,i=P(r),t=s(r.id);return i+((null===(n=null==t?void 0:t.offers)||void 0===n?void 0:n.filter(function(r){return r.isSelected&&!a(r)}).reduce(function(r,n){return r+P(l(n.product))},0))||0)}function E(r){var n=C(r),i=b(r);return e(n,i.currency||"",i.currencySymbol||"")}function N(r){var n=D(r),i=C(r);return n!==i?Number((100-100*n/i).toFixed(0)):0}function q(r){return i.isBackInStockEnabled()}function M(r){return i.isCustomerLoginRequiredForBackInStock()}function w(i,t){return r(this,void 0,void 0,function(){var r,e;return n(this,function(n){switch(n.label){case 0:case 3:return[4,import("../../../api/product/index.js")];case 1:return[4,(0,n.sent().apiListProductBackInStockRemind)({email:{eq:t},productId:{eq:i.productId},variantId:{eq:i.id}})];case 2:return(r=n.sent())&&(null===(e=r.data)||void 0===e?void 0:e.length)?(i.isBackInStockReminderSaved=!0,[2,!1]):[3,3];case 4:return[4,(0,n.sent().apiSaveProductBackInStockRemind)({input:{email:t,productId:i.productId,variantId:i.id}})];case 5:return n.sent().isSuccess?(i.isBackInStockReminderSaved=!0,[2,!0]):(i.isBackInStockReminderSaved=!1,[2,!1]);case 6:return[2]}})})}function G(r){var n,i,t=s(r.id);if(!t)return"0";var u=b(r);if(u.unitPrice&&t.baseUnit){var o=t.baseUnit.baseAmount,c=(null===(i=null===(n=t.baseUnit)||void 0===n?void 0:n.unit)||void 0===i?void 0:i.name)||"";return"".concat(e(u.unitPrice,u.currency||"",u.currencySymbol||"")," / ").concat(o&&1!==o?o:"").concat(c)}}function X(r){return t._backInStockForms[r.id]||(t._backInStockForms[r.id]={},o(t._backInStockForms[r.id],r)),t._backInStockForms[r.id]}function Y(r){delete t._backInStockForms[r.id]}export{Y as clearProductVariantBackInStockForm,p as getGroupedAttributeValuesForVariant,R as getProductVariantAppliedCampaignAmount,y as getProductVariantB2bPriceRule,X as getProductVariantBackInStockForm,S as getProductVariantBundlePrice,N as getProductVariantCampaignOffersDiscountPercentage,T as getProductVariantCampaignPrice,F as getProductVariantDiscountAmount,O as getProductVariantDiscountPercentage,j as getProductVariantDiscountPrice,g as getProductVariantFinalPrice,D as getProductVariantFinalPriceWithCampaignOffers,B as getProductVariantFormattedBuyPrice,A as getProductVariantFormattedCampaignPrice,h as getProductVariantFormattedDiscountAmount,x as getProductVariantFormattedDiscountPrice,k as getProductVariantFormattedFinalPrice,U as getProductVariantFormattedFinalPriceWithCampaignOffers,L as getProductVariantFormattedSellPrice,E as getProductVariantFormattedSellPriceWithCampaignOffers,M as getProductVariantIsBackInStockCustomerLoginRequired,q as getProductVariantIsBackInStockEnabled,f as getProductVariantMainImage,b as getProductVariantPrice,P as getProductVariantSellPrice,C as getProductVariantSellPriceWithCampaignOffers,G as getProductVariantUnitPriceText,I as hasBundleSettings,_ as hasProductVariantDiscount,m as hasProductVariantStock,w as saveProductVariantBackInStockReminder};
|
|
1
|
+
import{__awaiter as n,__generator as r}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as i}from"../../../../packages/storefront-config/src/index.js";import{customerStore as t}from"../../../../stores/customer/index.js";import{formatCurrency as e}from"../../../../utils/currency.js";import{groupBy as u}from"../../../../utils/helper.js";import{initBackInStockNotificationForm as o}from"../../validator/back-in-stock-notification/index.js";import{getBundleProductFinalPriceWithQuantity as c,getBundleProductSellPriceWithQuantity as l,getSelectedProductVariant as d}from"../index.js";import{isProductOfferAccepted as a}from"../campaign-offer/index.js";import{getProductFromStore as v}from"../init.js";import{getIkasProductPriceFinalPrice as s}from"./price/index.js";function f(n){var r;return(null===(r=n.images)||void 0===r?void 0:r.length)?n.images[0]:void 0}function m(n){return n.stock>0||n.sellIfOutOfStock}function p(n){var r,i=u(n.attributes,"productAttributeId");return(null===(r=n.attributes)||void 0===r?void 0:r.map(function(n){var r=n.productAttributeId;if(r){var t=i[r];return(null==t?void 0:t.length)&&t[0].productAttribute?{attribute:t[0].productAttribute,values:t}:void 0}}).filter(function(n){return!!n}))||[]}function y(n){var r,i,e=t.customer,u=null==e?void 0:e.priceListRules,o=v(n.id),c=function(r){var i,t,e,u;if("CATEGORY"===r.type)return c=null===(i=r.valueList)||void 0===i?void 0:i.some(function(n){return null==o?void 0:o.categories.find(function(r){return r.id===n})});if("PRODUCT"===r.type)return c=null===(t=r.valueList)||void 0===t?void 0:t.some(function(r){return n.id===r});if("PRODUCT_BRAND"===r.type){var c=null===(e=r.valueList)||void 0===e?void 0:e.some(function(n){var r;return(null===(r=null==o?void 0:o.brand)||void 0===r?void 0:r.id)===n});return c}if("PRODUCT_TAG"===r.type){c=null===(u=r.valueList)||void 0===u?void 0:u.some(function(n){var r;return null===(r=null==o?void 0:o.tags)||void 0===r?void 0:r.find(function(r){return r.id===n})});return c}};if(u){for(var l=0,d=u;l<d.length;l++){var a=d[l];if(a.shouldMatchAllFilters?null===(r=a.filters)||void 0===r?void 0:r.every(c):null===(i=a.filters)||void 0===i?void 0:i.some(c))return a}return null}return null}function I(n){var r,e;if(i.isB2BStorefront()){var u=t.customer;if(null==u?void 0:u.priceListId){var o=null===(r=n.prices)||void 0===r?void 0:r.find(function(n){return n.priceListId===u.priceListId});if(o)return o}}return null===(e=n.prices)||void 0===e?void 0:e.find(function(n){return i.priceListId?n.priceListId===i.priceListId:null===n.priceListId})}function S(n){return!!n.bundleSettings}function b(n){var r,e;if(i.isB2BStorefront()){var u=t.customer;if(null==u?void 0:u.priceListId){var o=null===(r=n.baseBundlePrices)||void 0===r?void 0:r.find(function(n){return n.priceListId===u.priceListId});if(o)return o}}return(null===(e=n.baseBundlePrices)||void 0===e?void 0:e.find(function(n){return i.priceListId?n.priceListId===i.priceListId:null===n.priceListId}))||I(n)}function g(n){var r=0;if(n.bundleSettings&&n.bundleSettings.products.every(function(n){return!!n.product})){var i=b(n);r=s(i)+n.bundleSettings.products.reduce(function(n,r){return n+(r.addToBundleBasePrice?c(r):0)},0)}else r=s(I(n));var t=y(n);if(!t)return r;switch(t.valueType){case"DISCOUNT_RATE":return r*((100-t.value)/100);case"DISCOUNT_AMOUNT":return r-t.value;case"FIXED_PRICE":return t.value;default:return r}}function P(n){var r=I(n);return e(g(n),r.currency||"",r.currencySymbol||"")}function k(n){return n.bundleSettings&&n.bundleSettings.products.every(function(n){return!!n.product})?b(n).sellPrice+n.bundleSettings.products.reduce(function(n,r){return n+(r.addToBundleBasePrice?l(r):0)},0):I(n).sellPrice}function R(n){var r=I(n);return e(k(n),r.currency||"",r.currencySymbol||"")}function L(n){var r=I(n);return e(I(n).buyPrice||0,r.currency||"",r.currencySymbol||"")}function D(n){var r,i,t,u,o,c,l,d,a,s,f,m,p=v(n.id),y=I(n);if(!(null===(r=y.campaignPrice)||void 0===r?void 0:r.campaignId))return null;var S=(null===(t=null===(i=null==p?void 0:p.campaigns)||void 0===i?void 0:i.find(function(n){var r;return n.campaign.id===(null===(r=y.campaignPrice)||void 0===r?void 0:r.campaignId)}))||void 0===t?void 0:t.campaign)||null;if(!S)return null;var b={type:S.type,formattedPrice:null,discountPercentage:null},g=(null==S?void 0:S.tieredDiscount)&&(null===(u=null==S?void 0:S.tieredDiscount)||void 0===u?void 0:u.rules)&&(null===(c=null===(o=null==S?void 0:S.tieredDiscount)||void 0===o?void 0:o.rules)||void 0===c?void 0:c.length)>0&&(null===(a=null===(d=null===(l=null==S?void 0:S.tieredDiscount)||void 0===l?void 0:l.rules)||void 0===d?void 0:d[0])||void 0===a?void 0:a.amount);return"FIXED_AMOUNT"===S.type&&(b.formattedPrice=e(S.fixedDiscount?(null===(s=S.fixedDiscount)||void 0===s?void 0:s.amount)||0:g||0,y.currency||"",y.currencySymbol||"")),"RATIO"===S.type&&(b.discountPercentage=S.fixedDiscount?(null===(m=null===(f=S.fixedDiscount)||void 0===f?void 0:f.amount)||void 0===m?void 0:m.toString())||null:g?g.toString():null),b}function h(n){var r;return(null===(r=I(n).campaignPrice)||void 0===r?void 0:r.campaignPrice)||null}function A(n){var r=I(n);return e(h(n)||0,r.currency||"",r.currencySymbol||"")}function B(n){var r=g(n);return r===k(n)?null:r}function T(n){var r=I(n);return e(B(n)||0,r.currency||"",r.currencySymbol||"")}function x(n){return null!==B(n)}function _(n){var r=I(n);return e(F(n),r.currency||"",r.currencySymbol||"")}function F(n){var r=g(n),i=k(n);return x(n)?i-r:0}function O(n){return(100-100*g(n)/k(n)).toFixed(0)}function j(n){var r,i=g(n),t=v(n.id);return i+((null===(r=null==t?void 0:t.offers)||void 0===r?void 0:r.filter(function(n){return n.isSelected&&!a(n)}).reduce(function(n,r){return n+g(d(r.product))},0))||0)}function C(n){var r=j(n),i=I(n);return e(r,i.currency||"",i.currencySymbol||"")}function U(n){var r,i=k(n),t=v(n.id);return i+((null===(r=null==t?void 0:t.offers)||void 0===r?void 0:r.filter(function(n){return n.isSelected&&!a(n)}).reduce(function(n,r){return n+k(d(r.product))},0))||0)}function Q(n){var r=U(n),i=I(n);return e(r,i.currency||"",i.currencySymbol||"")}function E(n){var r=j(n),i=U(n);return r!==i?Number((100-100*r/i).toFixed(0)):0}function N(n){var r,i,t,u=v(n.id),o=I(n),c=null===(i=null===(r=null==u?void 0:u.campaigns)||void 0===r?void 0:r.find(function(n){return!!n.campaign.tieredDiscount}))||void 0===i?void 0:i.campaign,l=null==c?void 0:c.tieredDiscount;if(!c||!l)return[];var d=null===(t=l.filters)||void 0===t?void 0:t.find(function(n){return"PRODUCT_AND_VARIANT"===n.type});if(d&&!d.idList.map(function(n){return n.replace("p:","").replace("v:","")}).some(function(r){return n.id===r||n.productId===r}))return[];if(l.rules.every(function(n){return!n.lineItemQuantityRange}))return[];var a=k(n),s=g(n);return l.rules.map(function(n){var r,i,t,u,l="SELL_PRICE"===c.applicablePrice?a:s,d=l*((null===(r=n.lineItemQuantityRange)||void 0===r?void 0:r.min)||1),v="RATIO"===c.type?l-l*(n.amount||1)/100:l,f=v*((null===(i=n.lineItemQuantityRange)||void 0===i?void 0:i.min)||1)-("FIXED_AMOUNT"===c.type&&n.amount||0);return{amount:n.amount,lineItemQuantityRange:{min:(null===(t=n.lineItemQuantityRange)||void 0===t?void 0:t.min)||0,max:(null===(u=n.lineItemQuantityRange)||void 0===u?void 0:u.max)||0},type:c.type,sellPrice:l,finalPrice:v,sellPriceWithQuantity:d,finalPriceWithQuantity:f,formattedSellPrice:e(l,o.currency||"",o.currencySymbol||""),formattedSellPriceWithQuantity:e(d,o.currency||"",o.currencySymbol||""),formattedFinalPrice:e(v,o.currency||"",o.currencySymbol||""),formattedFinalPriceWithQuantity:e(f,o.currency||"",o.currencySymbol||""),salesChannelIds:c.salesChannelIds}})}function q(n){return i.isBackInStockEnabled()}function M(n){return i.isCustomerLoginRequiredForBackInStock()}function W(i,t){return n(this,void 0,void 0,function(){var n,e;return r(this,function(r){switch(r.label){case 0:case 3:return[4,import("../../../api/product/index.js")];case 1:return[4,(0,r.sent().apiListProductBackInStockRemind)({email:{eq:t},productId:{eq:i.productId},variantId:{eq:i.id}})];case 2:return(n=r.sent())&&(null===(e=n.data)||void 0===e?void 0:e.length)?(i.isBackInStockReminderSaved=!0,[2,!1]):[3,3];case 4:return[4,(0,r.sent().apiSaveProductBackInStockRemind)({input:{email:t,productId:i.productId,variantId:i.id}})];case 5:return r.sent().isSuccess?(i.isBackInStockReminderSaved=!0,[2,!0]):(i.isBackInStockReminderSaved=!1,[2,!1]);case 6:return[2]}})})}function X(n){var r,i,t=v(n.id);if(!t)return"0";var u=I(n);if(u.unitPrice&&t.baseUnit){var o=t.baseUnit.baseAmount,c=(null===(i=null===(r=t.baseUnit)||void 0===r?void 0:r.unit)||void 0===i?void 0:i.name)||"";return"".concat(e(u.unitPrice,u.currency||"",u.currencySymbol||"")," / ").concat(o&&1!==o?o:"").concat(c)}}function w(n){return t._backInStockForms[n.id]||(t._backInStockForms[n.id]={},o(t._backInStockForms[n.id],n)),t._backInStockForms[n.id]}function G(n){delete t._backInStockForms[n.id]}export{G as clearProductVariantBackInStockForm,p as getGroupedAttributeValuesForVariant,D as getProductVariantAppliedCampaignAmount,y as getProductVariantB2bPriceRule,w as getProductVariantBackInStockForm,b as getProductVariantBundlePrice,E as getProductVariantCampaignOffersDiscountPercentage,h as getProductVariantCampaignPrice,F as getProductVariantDiscountAmount,O as getProductVariantDiscountPercentage,B as getProductVariantDiscountPrice,g as getProductVariantFinalPrice,j as getProductVariantFinalPriceWithCampaignOffers,L as getProductVariantFormattedBuyPrice,A as getProductVariantFormattedCampaignPrice,_ as getProductVariantFormattedDiscountAmount,T as getProductVariantFormattedDiscountPrice,P as getProductVariantFormattedFinalPrice,C as getProductVariantFormattedFinalPriceWithCampaignOffers,R as getProductVariantFormattedSellPrice,Q as getProductVariantFormattedSellPriceWithCampaignOffers,M as getProductVariantIsBackInStockCustomerLoginRequired,q as getProductVariantIsBackInStockEnabled,f as getProductVariantMainImage,I as getProductVariantPrice,k as getProductVariantSellPrice,U as getProductVariantSellPriceWithCampaignOffers,N as getProductVariantTieredDiscountProducts,X as getProductVariantUnitPriceText,S as hasBundleSettings,x as hasProductVariantDiscount,m as hasProductVariantStock,W as saveProductVariantBackInStockReminder};
|