@ikas/storefront 6.1.0-beta.325 → 6.1.0-beta.327
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e}from'./../../ext/tslib/tslib.es6.js';import*as t from"react";import{observer as o}from"mobx-react-lite";import i from"next/head.js";import{useRouter as a}from"next/router";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasThemeJsonPageType as r}from"@ikas/storefront-models";import"mobx";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-form-data-input/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/order-transaction-with-prices/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../models/data/storefront-popup/index.js";import{IkasIndexPageSeoSetting as n}from"../../models/data/storefront/index-page-seo-setting/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductList as s}from"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import{IkasStorefrontConfig as d}from"@ikas/storefront-config";import"../../analytics/analytics.js";import"../../analytics/head/index.js";import"./index.js";import"next/image.js";import"@ikas/storefront-model-functions";import"../link/index.js";import"../page-editor/loader/style.module.scss.js";import"../google-captcha/index.js";import"../paypal-express-checkout/index.js";import{IkasBaseStore as l}from"../../store/base.js";import"../../pages/home.js";import"../../pages/_slug_/index.js";import"../../pages/pages/_slug_.js";import"../../pages/checkout.js";import"../../pages/account/index.js";import"../../pages/account/addresses.js";import"../../pages/account/orders/index.js";import"../../pages/account/orders/_id_.js";import"../../pages/account/login.js";import"../../pages/account/register.js";import"../../pages/account/forgot-password.js";import"../../pages/account/recover-password.js";import"../../pages/cart.js";import"../../pages/editor.js";import"../../pages/account/favorite-products.js";import"../../pages/search.js";import"next/error.js";import"../../pages/blog/index.js";import"../../pages/blog/_slug_.js";import"../../pages/raffle/_slug_.js";import"../../pages/raffle/index.js";import"../../pages/account/raffles.js";import"../../pages/account/activate.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import"lodash/get";var c=o((function(o){var s,c,g,v,f,h,j,x=o.pageType,y=o.pageTitle,b=o.pageDescription,T=o.canonicals,C=o.disableIndex,D=o.pageSpecificData,L=o.merchantSettings,O=o.addOgpMetas,w=o.productReviewSummary,k=o.pageComponentPropValues,P=a(),R="undefined"!=typeof window,E="local"===process.env.NEXT_PUBLIC_ENV,I=P.asPath.split(/[?#]/)[0].replace("/",""),S=(I="/"===I.charAt(I.length-1)?I.slice(0,-1):I).startsWith("pages/"),_=x===r.BLOG,V=d.getCurrentRouting(),A=((null===(s=d.getMerchantSettings())||void 0===s?void 0:s.defaultLocale)||"tr")===(null==V?void 0:V.locale),M=!!D&&x===r.PRODUCT,N=!!D&&x===r.CATEGORY,B=!!D&&x===r.BRAND,G=M||N||B,U=null;(M||B||N)&&(U=D);var F=null===(c=null==U?void 0:U.translations)||void 0===c?void 0:c.find((function(e){return e.locale===(null==V?void 0:V.locale)})),Y=(null==V?void 0:V.path)?"/"+V.path:"",H=E?"http://localhost:3333":"https://"+d.getDomain(),z=null===(g=d.getIndexPageSeoSettings())||void 0===g?void 0:g.find((function(e){return e.locale===d.getCurrentLocale()})),X=z?new n(z):null;t.useEffect((function(){document.documentElement.lang=d.getCurrentLocale()}),[x,D]);var W=t.useMemo((function(){if(D&&D.href)return"".concat(H).concat(D.href)}),[D]),J=t.useMemo((function(){if(D&&D.href){var e=D.href;return Y?"".concat(H).concat(Y).concat(e):"".concat(H).concat(e)}}),[D]),q=t.useMemo((function(){var e,t,o,i=[];if(O){if(i.push({property:"og:type",content:"website"}),i.push({property:"og:site_name",content:(null==X?void 0:X.pageTitle)||"https://"+d.getDomain()}),y&&i.push({property:"og:title",content:y}),b&&i.push({property:"og:description",content:b}),x===r.INDEX){var a=null,n=null;!y&&(null==X?void 0:X.pageTitle)&&(a=X.pageTitle),!b&&(null==X?void 0:X.description)&&(n=X.description),(s=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===x})))&&(a=u(D,x,s.titleTemplate||""),n=u(D,x,s.descriptionTemplate||"")),a&&i.push({property:"og:title",content:a}),n&&i.push({property:"og:description",content:n})}if(x===r.PRODUCT||x===r.CATEGORY||x===r.BRAND){var s,l=null,c=null;if((s=null===(t=d.getMetaTemplates())||void 0===t?void 0:t.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===x})))&&(l=u(D,x,s.titleTemplate||""),c=u(D,x,s.descriptionTemplate||"")),!y){var p=l||G&&A&&(null==U?void 0:U.name)||G&&!A&&(null==F?void 0:F.name);p&&i.push({property:"og:title",content:p})}if(!b){var m=c||G&&!A&&(null==F?void 0:F.description);m&&i.push({property:"og:description",content:m})}}i.push({property:"og:url",content:J||(R?window.location.href:"")||"https://".concat(d.getDomain())});var g=null;if(D&&x===r.PRODUCT){var v=D.selectedVariant.mainImage;(null==v?void 0:v.image)&&(g={property:"og:image",content:v.image.src.replace(".webp",".jpg")})}if(D&&x===r.CATEGORY){var f=D;f.image&&(g={property:"og:image",content:f.image.src.replace(".webp",".jpg")})}if(D&&x===r.BRAND){var h=D;h.image&&(g={property:"og:image",content:h.image.src.replace(".webp",".jpg")})}if(D&&x===r.BLOG_CATEGORY){var j=D;j.image&&(g={property:"og:image",content:j.image.src.replace(".webp",".jpg")})}if(D&&x===r.BLOG){var T=D;T.image&&(g={property:"og:image",content:T.image.src.replace(".webp",".jpg")})}!g&&(null==X?void 0:X.icon)&&(g={property:"og:image",content:null===(o=null==X?void 0:X.icon)||void 0===o?void 0:o.src.replace(".webp",".jpg")}),!g&&(null==L?void 0:L.logo)&&(g={property:"og:image",content:L.logo.src.replace(".webp",".jpg")}),g&&i.push(g)}return i}),[y,D,W,b,L,O,L]),K=t.useMemo((function(){var t=[],o=(null==X?void 0:X.pageTitle)||(null==L?void 0:L.merchantName)||"";if(L){var i={"@context":"https://schema.org","@type":"Website",url:"https://"+d.getDomain()},a=function(t){var o,i,a,r,n,s,l=(null==t?void 0:t.logo)?t.logo.src:void 0;return{"@context":"https://schema.org","@type":"Store",name:null==t?void 0:t.merchantName,logo:l,image:l,url:"https://"+d.getDomain(),telephone:null==t?void 0:t.phone,address:e(e({"@type":"PostalAddress",streetAddress:null===(o=t.address)||void 0===o?void 0:o.addressLine1,addressLocality:null===(a=null===(i=t.address)||void 0===i?void 0:i.city)||void 0===a?void 0:a.name},t.address&&t.address.state&&{addressRegion:t.address.state.code}),{postalCode:null===(r=t.address)||void 0===r?void 0:r.postalCode,addressCountry:null===(s=null===(n=t.address)||void 0===n?void 0:n.country)||void 0===s?void 0:s.code})}}(L);t.push(i),t.push(a)}if(D&&x===r.PRODUCT){var n=D,s=function(t,o){var i,a,n,s,l,c;try{var p=["c7d934c7-2d44-43c3-b023-de7aa93fe435"],m=null===(i=d.getMerchantSettings())||void 0===i?void 0:i.merchantId,g=d.getCurrentRouting(),v=null==g?void 0:g.path,f=function(e){return v?"https://".concat(d.getDomain(),"/").concat(v).concat(e):"https://".concat(d.getDomain()).concat(e)},h=t.selectedVariant,j=null,x=null===(a=d.getMetaTemplates())||void 0===a?void 0:a.find((function(e){return e.locale===d.getCurrentLocale()&&r.PRODUCT}));return x&&(j=u(t,r.PRODUCT,x.descriptionTemplate||"")),e(e({"@context":"https://schema.org/","@type":"Product",name:t.name,description:(null===(n=t.metaData)||void 0===n?void 0:n.description)||j,image:null===(s=h.images)||void 0===s?void 0:s.map((function(e){return e.image?e.image.src:""})),productId:h.id,sku:h.sku,mpn:(null===(l=h.barcodeList)||void 0===l?void 0:l.length)?h.barcodeList[0]:"",brand:{"@type":"Brand",name:null===(c=t.brand)||void 0===c?void 0:c.name}},o&&{aggregateRating:{"@type":"AggregateRating",ratingValue:o.averageStar,reviewCount:o.totalReview}}),p.some((function(e){return e!==m}))?{offers:t.variants.map((function(e){var o;return{"@type":"Offer",url:f(t.productHref+"?vid="+e.id),priceCurrency:e.price.currency||"TRY",price:(null!==(o=e.campaignPrice)&&void 0!==o?o:e.price.finalPrice).toFixed(2),priceValidUntil:"",itemCondition:"https://schema.org/NewCondition",availability:e.stock>0||e.sellIfOutOfStock?"https://schema.org/InStock":"https://schema.org/OutOfStock"}}))}:{})}catch(e){}}(n,w||null);if(s&&t.push(s),n.categories.length)(c=p(n.categories[0],o,n))&&t.push(c)}if(D&&x===r.CATEGORY){var l=function(e){var t,o;try{var i=d.getCurrentRouting(),a=null==i?void 0:i.path,r=function(e){return a?"https://".concat(d.getDomain(),"/").concat(a).concat(e):"https://".concat(d.getDomain()).concat(e)};return{"@context":"http://schema.org","@type":"CollectionPage",url:r(e.href),name:null===(t=e.metaData)||void 0===t?void 0:t.pageTitle,description:null===(o=e.metaData)||void 0===o?void 0:o.description,image:e.image?e.image.src:void 0}}catch(e){}}(D),c=p(D,o),g=m(k);l&&t.push(l),c&&t.push(c),g&&t.push(g)}D&&x===r.BRAND&&((g=m(k))&&t.push(g));if(D&&x===r.BLOG){var v=function(t){var o;try{var i="https://".concat(d.getDomain()).concat(t.href),a="".concat(t.writer.firstName," ").concat(t.writer.lastName),r=(new DOMParser).parseFromString(t.blogContent.content,"text/html").body.textContent;return e(e({"@context":"https://schema.org","@type":"BlogPosting",headline:t.title,image:null===(o=t.image)||void 0===o?void 0:o.src},t.category&&{genre:t.category.name}),{url:i,datePublished:new Date(t.createdAt).toISOString(),dateCreated:new Date(t.createdAt).toISOString(),dateModified:new Date(t.updatedAt).toISOString(),description:t.shortDescription,articleBody:r,author:{"@type":"Person",name:a}})}catch(e){}}(D);v&&t.push(v)}return t}),[D,L]),Q=t.useMemo((function(){var e,t=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===x}));return t?u(D,x,t.titleTemplate||""):null}),[x,D]),Z=t.useMemo((function(){var e,t=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===x}));return t?u(D,x,t.descriptionTemplate||""):null}),[x,D]),$=t.useMemo((function(){return!d.getFavicon()&&(null==X?void 0:X.favIcon)?X.favIcon:null}),[]),ee=[];d.getRoutings().forEach((function(e){var t;(null===(t=e.countryCodes)||void 0===t?void 0:t.length)?e.countryCodes.forEach((function(t){ee.push({routing:e,hrefLang:e.locale+"-"+t})})):ee.push({routing:e,hrefLang:e.locale})}));var te=function(e){var t,o,i,a,r,n=D,s=null===(o=null===(t=null==n?void 0:n.metaData)||void 0===t?void 0:t.translations)||void 0===o?void 0:o.find((function(t){return t.locale===e.locale}));if(s&&(null==s?void 0:s.slug))return s.slug;var d=ee.find((function(e){return!e.routing.path}));return d&&(null===(r=null===(a=null===(i=null==n?void 0:n.metaData)||void 0===i?void 0:i.translations)||void 0===a?void 0:a.find((function(e){return e.locale===d.routing.locale})))||void 0===r?void 0:r.slug)||""},oe=null===(v=ee.find((function(e){return!e.routing.path})))||void 0===v?void 0:v.routing.locale,ie=(null===(j=null===(h=null===(f=null==D?void 0:D.metaData)||void 0===f?void 0:f.translations)||void 0===h?void 0:h.find((function(e){return e.locale===oe})))||void 0===j?void 0:j.slug)||"",ae=l.getInstance();return t.createElement(i,null,t.createElement("title",null,y||Q||(G?A?(null==U?void 0:U.name)||"":(null==F?void 0:F.name)||"":(null==X?void 0:X.pageTitle)||"")),t.createElement("meta",{name:"description",content:b||Z||(G?(null==F?void 0:F.description)||"":(null==X?void 0:X.description)||"")}),ee.length>1&&!S&&!_&&t.createElement(t.Fragment,null,ee.filter((function(e){return!S||e.routing.id===(null==V?void 0:V.id)})).map((function(e){return t.createElement("link",{key:e.routing.id+e.hrefLang,rel:"alternate",hrefLang:e.hrefLang,href:"".concat(H+(e.routing.path?"/"+e.routing.path:""),"/").concat(te(e.routing))})})),t.createElement("link",{rel:"alternate",hrefLang:"x-default",href:"".concat(H).concat(oe?"/".concat(ie):"".concat(Y,"/").concat(I))})),!!C&&t.createElement("meta",{name:"robots",content:"noindex"}),!!O&&q.map((function(e,o){return t.createElement("meta",{key:"".concat(e.content,"-").concat(o),property:e.property,content:e.content})})),!!T&&T.map((function(e,o){return t.createElement("link",{key:o+"url",rel:"canonical",href:"".concat(H).concat(Y).concat(e)})})),$&&t.createElement("link",{rel:"shortcut icon",href:"".concat(process.env.NEXT_PUBLIC_CDN_URL,"images/").concat($,"/image_180.webp"),type:"image/webp"}),!T&&ae.currentPageType!==r.NOT_FOUND&&t.createElement("link",{rel:"canonical",href:"".concat(H).concat(Y,"/").concat(I)}),!!K.length&&K.map((function(e,o){return t.createElement("script",{key:o,type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(e)}})})))}));function p(e,t,o){try{var i=l.getInstance(),a=d.getCurrentRouting(),n=null==a?void 0:a.path,s=function(e){return n?"https://".concat(d.getDomain(),"/").concat(n).concat(e):"https://".concat(d.getDomain()).concat(e)},c=[{"@type":"ListItem",position:1,name:t,item:"https://".concat(d.getDomain())}];return(c=c.concat(e.categoryPathItems.map((function(e,t){return{"@type":"ListItem",position:t+2,name:e.name,item:s(e.href)}})))).push({"@type":"ListItem",position:c.length+1,name:e.name,item:s(e.href)}),i.currentPageType===r.PRODUCT&&o&&c.push({"@type":"ListItem",position:c.length+1,name:o.name,item:s(o.productHref)}),{"@context":"http://schema.org","@type":"BreadcrumbList",itemListElement:c}}catch(e){}}function m(e){try{var t=d.getCurrentRouting(),o=null==t?void 0:t.path;if(e){var i=(e.filter((function(e){return!e.component.isHeader&&!e.component.isFooter}))||[]).find((function(e){return Object.values(e.propValues).find((function(e){var t;return e instanceof s&&(null===(t=e._productListPropValue)||void 0===t?void 0:t.usePageFilter)}))}));if(i){var a=Object.values(i.propValues).find((function(e){var t;return e instanceof s&&(null===(t=e._productListPropValue)||void 0===t?void 0:t.usePageFilter)}));if(a)return{"@context":"http://schema.org","@type":"ItemList",itemListElement:(a.data||[]).slice(0,10).map((function(e,t){var i,a,r,n;return{"@type":"ListItem",position:t+1,item:{"@type":"Product",name:e.name,image:(null===(a=null===(i=e.selectedVariant.mainImage)||void 0===i?void 0:i.image)||void 0===a?void 0:a.src)||"",offers:{"@type":"Offer",url:(n=e.href,o?"https://".concat(d.getDomain(),"/").concat(o).concat(n):"https://".concat(d.getDomain()).concat(n)),priceCurrency:e.selectedVariant.price.currency||"TRY",price:(null!==(r=e.selectedVariant.campaignPrice)&&void 0!==r?r:e.selectedVariant.finalPrice).toFixed(2),availability:e.selectedVariant.stock>0||e.selectedVariant.sellIfOutOfStock?"https://schema.org/InStock":"https://schema.org/OutOfStock"}}}}))}}}}catch(e){}}function u(e,t,o){var i,a,n=o;try{switch(t){case r.PRODUCT:var s=e,d=s.name,l=(null===(i=s.brand)||void 0===i?void 0:i.name)||"",c=s.selectedVariant.sku||"",p=(null===(a=s.selectedVariant.barcodeList)||void 0===a?void 0:a.length)?s.selectedVariant.barcodeList[0]:"",m=s.selectedVariant.campaignPrice?s.selectedVariant.formattedCampaignPrice:s.selectedVariant.formattedFinalPrice;n.includes("{{name}}")&&(n=g(n,"{{name}}",d)),n.includes("{{brand}}")&&(n=g(n,"{{brand}}",l)),n.includes("{{sku}}")&&(n=g(n,"{{sku}}",c)),n.includes("{{barcode}}")&&(n=g(n,"{{barcode}}",p)),n.includes("{{price}}")&&(n=g(n,"{{price}}",m.toString()));break;case r.BRAND:case r.CATEGORY:case r.BLOG_CATEGORY:var u=e.name||"";n.includes("{{name}}")&&(n=g(n,"{{name}}",u));break;case r.BLOG:var v=e.title;n.includes("{{name}}")&&(n=g(n,"{{name}}",v))}}catch(e){}return n.trimEnd()}function g(e,t,o){var i=new RegExp(t,"g");return e.replace(i,o)}export{c as IkasPageHead};
|
|
1
|
+
import{__assign as e}from'./../../ext/tslib/tslib.es6.js';import*as t from"react";import{observer as o}from"mobx-react-lite";import i from"next/head.js";import{useRouter as a}from"next/router";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasThemeJsonPageType as r}from"@ikas/storefront-models";import"mobx";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-form-data-input/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/order-transaction-with-prices/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../models/data/storefront-popup/index.js";import{IkasIndexPageSeoSetting as n}from"../../models/data/storefront/index-page-seo-setting/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductList as s}from"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import{IkasStorefrontConfig as d}from"@ikas/storefront-config";import"../../analytics/analytics.js";import"../../analytics/head/index.js";import"./index.js";import"next/image.js";import"@ikas/storefront-model-functions";import"../link/index.js";import"../page-editor/loader/style.module.scss.js";import"../google-captcha/index.js";import"../paypal-express-checkout/index.js";import{IkasBaseStore as l}from"../../store/base.js";import"../../pages/home.js";import"../../pages/_slug_/index.js";import"../../pages/pages/_slug_.js";import"../../pages/checkout.js";import"../../pages/account/index.js";import"../../pages/account/addresses.js";import"../../pages/account/orders/index.js";import"../../pages/account/orders/_id_.js";import"../../pages/account/login.js";import"../../pages/account/register.js";import"../../pages/account/forgot-password.js";import"../../pages/account/recover-password.js";import"../../pages/cart.js";import"../../pages/editor.js";import"../../pages/account/favorite-products.js";import"../../pages/search.js";import"next/error.js";import"../../pages/blog/index.js";import"../../pages/blog/_slug_.js";import"../../pages/raffle/_slug_.js";import"../../pages/raffle/index.js";import"../../pages/account/raffles.js";import"../../pages/account/activate.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import"lodash/get";var c=o((function(o){var s,c,g,v,f,h,j,x=o.pageType,y=o.pageTitle,b=o.pageDescription,T=o.canonicals,C=o.disableIndex,D=o.pageSpecificData,L=o.merchantSettings,O=o.addOgpMetas,w=o.productReviewSummary,k=o.pageComponentPropValues,P=a(),R="undefined"!=typeof window,E="local"===process.env.NEXT_PUBLIC_ENV,I=P.asPath.split(/[?#]/)[0].replace("/",""),S=(I="/"===I.charAt(I.length-1)?I.slice(0,-1):I).startsWith("pages/"),_=x===r.BLOG,V=d.getCurrentRouting(),A=((null===(s=d.getMerchantSettings())||void 0===s?void 0:s.defaultLocale)||"tr")===(null==V?void 0:V.locale),M=!!D&&x===r.PRODUCT,N=!!D&&x===r.CATEGORY,B=!!D&&x===r.BRAND,G=M||N||B,U=null;(M||B||N)&&(U=D);var F=null===(c=null==U?void 0:U.translations)||void 0===c?void 0:c.find((function(e){return e.locale===(null==V?void 0:V.locale)})),Y=(null==V?void 0:V.path)?"/"+V.path:"",H=E?"http://localhost:3333":"https://"+d.getDomain(),z=null===(g=d.getIndexPageSeoSettings())||void 0===g?void 0:g.find((function(e){return e.locale===d.getCurrentLocale()})),X=z?new n(z):null;t.useEffect((function(){document.documentElement.lang=d.getCurrentLocale()}),[x,D]);var W=t.useMemo((function(){if(D&&D.href)return"".concat(H).concat(D.href)}),[D]),J=t.useMemo((function(){if(D&&D.href){var e=D.href;return Y?"".concat(H).concat(Y).concat(e):"".concat(H).concat(e)}}),[D]),q=t.useMemo((function(){var e,t,o,i=[];if(O){if(i.push({property:"og:type",content:"website"}),i.push({property:"og:site_name",content:(null==X?void 0:X.pageTitle)||"https://"+d.getDomain()}),y&&i.push({property:"og:title",content:y}),b&&i.push({property:"og:description",content:b}),x===r.INDEX){var a=null,n=null;!y&&(null==X?void 0:X.pageTitle)&&(a=X.pageTitle),!b&&(null==X?void 0:X.description)&&(n=X.description),(s=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===x})))&&(a=u(D,x,s.titleTemplate||""),n=u(D,x,s.descriptionTemplate||"")),a&&i.push({property:"og:title",content:a}),n&&i.push({property:"og:description",content:n})}if(x===r.PRODUCT||x===r.CATEGORY||x===r.BRAND){var s,l=null,c=null;if((s=null===(t=d.getMetaTemplates())||void 0===t?void 0:t.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===x})))&&(l=u(D,x,s.titleTemplate||""),c=u(D,x,s.descriptionTemplate||"")),!y){var p=l||G&&A&&(null==U?void 0:U.name)||G&&!A&&(null==F?void 0:F.name);p&&i.push({property:"og:title",content:p})}if(!b){var m=c||G&&!A&&(null==F?void 0:F.description);m&&i.push({property:"og:description",content:m})}}i.push({property:"og:url",content:J||(R?window.location.href:"")||"https://".concat(d.getDomain())});var g=null;if(D&&x===r.PRODUCT){var v=D.selectedVariant.mainImage;(null==v?void 0:v.image)&&(g={property:"og:image",content:v.image.src.replace(".webp",".jpg")})}if(D&&x===r.CATEGORY){var f=D;f.image&&(g={property:"og:image",content:f.image.src.replace(".webp",".jpg")})}if(D&&x===r.BRAND){var h=D;h.image&&(g={property:"og:image",content:h.image.src.replace(".webp",".jpg")})}if(D&&x===r.BLOG_CATEGORY){var j=D;j.image&&(g={property:"og:image",content:j.image.src.replace(".webp",".jpg")})}if(D&&x===r.BLOG){var T=D;T.image&&(g={property:"og:image",content:T.image.src.replace(".webp",".jpg")})}!g&&(null==X?void 0:X.icon)&&(g={property:"og:image",content:null===(o=null==X?void 0:X.icon)||void 0===o?void 0:o.src.replace(".webp",".jpg")}),!g&&(null==L?void 0:L.logo)&&(g={property:"og:image",content:L.logo.src.replace(".webp",".jpg")}),g&&i.push(g)}return i}),[y,D,W,b,L,O,L]),K=t.useMemo((function(){var t=[],o=(null==X?void 0:X.pageTitle)||(null==L?void 0:L.merchantName)||"";if(L){var i={"@context":"https://schema.org","@type":"Website",url:"https://"+d.getDomain()},a=function(t){var o,i,a,r,n,s,l=(null==t?void 0:t.logo)?t.logo.src:void 0;return{"@context":"https://schema.org","@type":"Store",name:null==t?void 0:t.merchantName,logo:l,image:l,url:"https://"+d.getDomain(),telephone:null==t?void 0:t.phone,address:e(e({"@type":"PostalAddress",streetAddress:null===(o=t.address)||void 0===o?void 0:o.addressLine1,addressLocality:null===(a=null===(i=t.address)||void 0===i?void 0:i.city)||void 0===a?void 0:a.name},t.address&&t.address.state&&{addressRegion:t.address.state.code}),{postalCode:null===(r=t.address)||void 0===r?void 0:r.postalCode,addressCountry:null===(s=null===(n=t.address)||void 0===n?void 0:n.country)||void 0===s?void 0:s.code})}}(L);t.push(i),t.push(a)}if(D&&x===r.PRODUCT){var n=D,s=function(t,o){var i,a,n,s,l,c;try{var p=["c7d934c7-2d44-43c3-b023-de7aa93fe435"],m=null===(i=d.getMerchantSettings())||void 0===i?void 0:i.merchantId,g=d.getCurrentRouting(),v=null==g?void 0:g.path,f=function(e){return v?"https://".concat(d.getDomain(),"/").concat(v).concat(e):"https://".concat(d.getDomain()).concat(e)},h=t.selectedVariant,j=null,x=null===(a=d.getMetaTemplates())||void 0===a?void 0:a.find((function(e){return e.locale===d.getCurrentLocale()&&r.PRODUCT}));return x&&(j=u(t,r.PRODUCT,x.descriptionTemplate||"")),e(e({"@context":"https://schema.org/","@type":"Product",name:t.name,description:(null===(n=t.metaData)||void 0===n?void 0:n.description)||j,image:null===(s=h.images)||void 0===s?void 0:s.map((function(e){return e.image?e.image.src:""})),productId:h.id,sku:h.sku,mpn:(null===(l=h.barcodeList)||void 0===l?void 0:l.length)?h.barcodeList[0]:"",brand:{"@type":"Brand",name:null===(c=t.brand)||void 0===c?void 0:c.name}},o&&{aggregateRating:{"@type":"AggregateRating",ratingValue:o.averageStar,reviewCount:o.totalReview}}),p.some((function(e){return e!==m}))?{offers:t.variants.map((function(e){var o;return{"@type":"Offer",url:f(t.productHref+"?vid="+e.id),priceCurrency:e.price.currency||"TRY",price:(null!==(o=e.campaignPrice)&&void 0!==o?o:e.price.finalPrice).toFixed(2),priceValidUntil:"",itemCondition:"https://schema.org/NewCondition",availability:e.stock>0||e.sellIfOutOfStock?"https://schema.org/InStock":"https://schema.org/OutOfStock"}}))}:{})}catch(e){}}(n,w||null);if(s&&t.push(s),n.categories.length)(c=p(n.categories[0],o,n))&&t.push(c)}if(D&&x===r.CATEGORY){var l=function(e){var t,o;try{var i=d.getCurrentRouting(),a=null==i?void 0:i.path,r=function(e){return a?"https://".concat(d.getDomain(),"/").concat(a).concat(e):"https://".concat(d.getDomain()).concat(e)};return{"@context":"http://schema.org","@type":"CollectionPage",url:r(e.href),name:null===(t=e.metaData)||void 0===t?void 0:t.pageTitle,description:null===(o=e.metaData)||void 0===o?void 0:o.description,image:e.image?e.image.src:void 0}}catch(e){}}(D),c=p(D,o),g=m(k);l&&t.push(l),c&&t.push(c),g&&t.push(g)}D&&x===r.BRAND&&((g=m(k))&&t.push(g));if(D&&x===r.BLOG){var v=function(t){var o;try{var i="https://".concat(d.getDomain()).concat(t.href),a="".concat(t.writer.firstName," ").concat(t.writer.lastName),r=(new DOMParser).parseFromString(t.blogContent.content,"text/html").body.textContent;return e(e({"@context":"https://schema.org","@type":"BlogPosting",headline:t.title,image:null===(o=t.image)||void 0===o?void 0:o.src},t.category&&{genre:t.category.name}),{url:i,datePublished:new Date(t.createdAt).toISOString(),dateCreated:new Date(t.createdAt).toISOString(),dateModified:new Date(t.updatedAt).toISOString(),description:t.shortDescription,articleBody:r,author:{"@type":"Person",name:a}})}catch(e){}}(D);v&&t.push(v)}return t}),[D,L]),Q=t.useMemo((function(){var e,t=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===x}));return t?u(D,x,t.titleTemplate||""):null}),[x,D]),Z=t.useMemo((function(){var e,t=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===x}));return t?u(D,x,t.descriptionTemplate||""):null}),[x,D]),$=t.useMemo((function(){return!d.getFavicon()&&(null==X?void 0:X.favIcon)?X.favIcon:null}),[]),ee=[];d.getRoutings().forEach((function(e){var t;(null===(t=e.countryCodes)||void 0===t?void 0:t.length)?e.countryCodes.forEach((function(t){ee.push({routing:e,hrefLang:e.locale+"-"+t})})):ee.push({routing:e,hrefLang:e.locale})}));var te=function(e){var t,o,i,a,r,n,s=D,d=null===(o=null===(t=null==s?void 0:s.metaData)||void 0===t?void 0:t.translations)||void 0===o?void 0:o.find((function(t){return t.locale===e.locale}));if(d&&(null==d?void 0:d.slug))return d.slug;var l=ee.find((function(e){return!e.routing.path}));return l?(null===(r=null===(a=null===(i=null==s?void 0:s.metaData)||void 0===i?void 0:i.translations)||void 0===a?void 0:a.find((function(e){return e.locale===l.routing.locale})))||void 0===r?void 0:r.slug)||"":(null===(n=null==s?void 0:s.metaData)||void 0===n?void 0:n.slug)||""},oe=null===(v=ee.find((function(e){return!e.routing.path})))||void 0===v?void 0:v.routing.locale,ie=(null===(j=null===(h=null===(f=null==D?void 0:D.metaData)||void 0===f?void 0:f.translations)||void 0===h?void 0:h.find((function(e){return e.locale===oe})))||void 0===j?void 0:j.slug)||"",ae=l.getInstance();return t.createElement(i,null,t.createElement("title",null,y||Q||(G?A?(null==U?void 0:U.name)||"":(null==F?void 0:F.name)||"":(null==X?void 0:X.pageTitle)||"")),t.createElement("meta",{name:"description",content:b||Z||(G?(null==F?void 0:F.description)||"":(null==X?void 0:X.description)||"")}),ee.length>1&&!S&&!_&&t.createElement(t.Fragment,null,ee.filter((function(e){return!S||e.routing.id===(null==V?void 0:V.id)})).map((function(e){return t.createElement("link",{key:e.routing.id+e.hrefLang,rel:"alternate",hrefLang:e.hrefLang,href:"".concat(H+(e.routing.path?"/"+e.routing.path:""),"/").concat(te(e.routing))})})),t.createElement("link",{rel:"alternate",hrefLang:"x-default",href:"".concat(H).concat(oe?"/".concat(ie):"".concat(Y,"/").concat(I))})),!!C&&t.createElement("meta",{name:"robots",content:"noindex"}),!!O&&q.map((function(e,o){return t.createElement("meta",{key:"".concat(e.content,"-").concat(o),property:e.property,content:e.content})})),!!T&&T.map((function(e,o){return t.createElement("link",{key:o+"url",rel:"canonical",href:"".concat(H).concat(Y).concat(e)})})),$&&t.createElement("link",{rel:"shortcut icon",href:"".concat(process.env.NEXT_PUBLIC_CDN_URL,"images/").concat($,"/image_180.webp"),type:"image/webp"}),!T&&ae.currentPageType!==r.NOT_FOUND&&t.createElement("link",{rel:"canonical",href:"".concat(H).concat(Y,"/").concat(I)}),!!K.length&&K.map((function(e,o){return t.createElement("script",{key:o,type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(e)}})})))}));function p(e,t,o){try{var i=l.getInstance(),a=d.getCurrentRouting(),n=null==a?void 0:a.path,s=function(e){return n?"https://".concat(d.getDomain(),"/").concat(n).concat(e):"https://".concat(d.getDomain()).concat(e)},c=[{"@type":"ListItem",position:1,name:t,item:"https://".concat(d.getDomain())}];return(c=c.concat(e.categoryPathItems.map((function(e,t){return{"@type":"ListItem",position:t+2,name:e.name,item:s(e.href)}})))).push({"@type":"ListItem",position:c.length+1,name:e.name,item:s(e.href)}),i.currentPageType===r.PRODUCT&&o&&c.push({"@type":"ListItem",position:c.length+1,name:o.name,item:s(o.productHref)}),{"@context":"http://schema.org","@type":"BreadcrumbList",itemListElement:c}}catch(e){}}function m(e){try{var t=d.getCurrentRouting(),o=null==t?void 0:t.path;if(e){var i=(e.filter((function(e){return!e.component.isHeader&&!e.component.isFooter}))||[]).find((function(e){return Object.values(e.propValues).find((function(e){var t;return e instanceof s&&(null===(t=e._productListPropValue)||void 0===t?void 0:t.usePageFilter)}))}));if(i){var a=Object.values(i.propValues).find((function(e){var t;return e instanceof s&&(null===(t=e._productListPropValue)||void 0===t?void 0:t.usePageFilter)}));if(a)return{"@context":"http://schema.org","@type":"ItemList",itemListElement:(a.data||[]).slice(0,10).map((function(e,t){var i,a,r,n;return{"@type":"ListItem",position:t+1,item:{"@type":"Product",name:e.name,image:(null===(a=null===(i=e.selectedVariant.mainImage)||void 0===i?void 0:i.image)||void 0===a?void 0:a.src)||"",offers:{"@type":"Offer",url:(n=e.href,o?"https://".concat(d.getDomain(),"/").concat(o).concat(n):"https://".concat(d.getDomain()).concat(n)),priceCurrency:e.selectedVariant.price.currency||"TRY",price:(null!==(r=e.selectedVariant.campaignPrice)&&void 0!==r?r:e.selectedVariant.finalPrice).toFixed(2),availability:e.selectedVariant.stock>0||e.selectedVariant.sellIfOutOfStock?"https://schema.org/InStock":"https://schema.org/OutOfStock"}}}}))}}}}catch(e){}}function u(e,t,o){var i,a,n=o;try{switch(t){case r.PRODUCT:var s=e,d=s.name,l=(null===(i=s.brand)||void 0===i?void 0:i.name)||"",c=s.selectedVariant.sku||"",p=(null===(a=s.selectedVariant.barcodeList)||void 0===a?void 0:a.length)?s.selectedVariant.barcodeList[0]:"",m=s.selectedVariant.campaignPrice?s.selectedVariant.formattedCampaignPrice:s.selectedVariant.formattedFinalPrice;n.includes("{{name}}")&&(n=g(n,"{{name}}",d)),n.includes("{{brand}}")&&(n=g(n,"{{brand}}",l)),n.includes("{{sku}}")&&(n=g(n,"{{sku}}",c)),n.includes("{{barcode}}")&&(n=g(n,"{{barcode}}",p)),n.includes("{{price}}")&&(n=g(n,"{{price}}",m.toString()));break;case r.BRAND:case r.CATEGORY:case r.BLOG_CATEGORY:var u=e.name||"";n.includes("{{name}}")&&(n=g(n,"{{name}}",u));break;case r.BLOG:var v=e.title;n.includes("{{name}}")&&(n=g(n,"{{name}}",v))}}catch(e){}return n.trimEnd()}function g(e,t,o){var i=new RegExp(t,"g");return e.replace(i,o)}export{c as IkasPageHead};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as n}from'./../../../ext/tslib/tslib.es6.js';import*as r from"react";import{reaction as o}from"mobx";import{listStorefrontPopup as i,SortByDirectionEnum as a}from"@ikas/storefront-api";import{IkasStorefrontConfig as u}from"@ikas/storefront-config";import{Analytics as s}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import{IkasBaseStore as c}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import d from"../../../store/product/index.js";import{POPUP_CONTEXT_UPDATE_EVENT as l}from'./../../../ext/@ikas/popup-script-injector/dist/popup-script-injector.es.js';import{resolveStoreUrl as p,resolveCartUrl as f}from"./common.js";var m=function(n){return t(void 0,void 0,void 0,(function(){var r,o,i,a,l,m,
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as n}from'./../../../ext/tslib/tslib.es6.js';import*as r from"react";import{reaction as o}from"mobx";import{listStorefrontPopup as i,SortByDirectionEnum as a}from"@ikas/storefront-api";import{IkasStorefrontConfig as u}from"@ikas/storefront-config";import{Analytics as s}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import{IkasBaseStore as c}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import d from"../../../store/product/index.js";import{POPUP_CONTEXT_UPDATE_EVENT as l}from'./../../../ext/@ikas/popup-script-injector/dist/popup-script-injector.es.js';import{resolveStoreUrl as p,resolveCartUrl as f}from"./common.js";var m=function(n){return t(void 0,void 0,void 0,(function(){var r,o,i,a,l,m,I,w,S,P,y,C,k,b,j,L;return e(this,(function(E){switch(E.label){case 0:return r={popups:n,cartUrl:""},[4,function(){return new Promise((function(t){var e=setInterval((function(){var n=u.getSessionId();n&&(clearInterval(e),t(n))}),100)}))}()];case 1:return E.sent(),(o=u.getSessionId())&&(r.sessionId=o),(i=u.getCdnUrl())&&(r.cdnUrl=i),(a=null===(b=u.getMerchantSettings())||void 0===b?void 0:b.merchantId)&&(r.merchantId=a),(l=p())&&(r.storeUrl=l),(m=f())&&(r.cartUrl=m),(I=u.getCustomerToken())&&(r.customerToken=I),(w=u.getCurrentLocale())&&(r.locale=w),(S=null===(L=null===(j=u.getCurrentRouting())||void 0===j?void 0:j.countryCodes)||void 0===L?void 0:L[0])&&(r.countryCode=S),(P=u.getPriceListId())&&(r.priceListId=P),(y=u.getSalesChannelId())&&(r.salesChannelId=y),T=c.getInstance().customerStore.customer,(C=T?g(T):null)&&(r.customer=C),D=c.getInstance().cartStore.cart,(k=D?h(D):null)&&(r.cart=k),r.services=function(){var n=this,r=c.getInstance();return{searchProducts:function(r){return t(n,void 0,void 0,(function(){var t,n,o;return e(this,(function(e){switch(e.label){case 0:return[4,d.searchProducts(v(r))];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(o=null===(n=t.data)||void 0===n?void 0:n.data)||void 0===o?void 0:o.length)?[2,t.data.data]:[2,[]]}}))}))},addItemToCart:function(o){var i=o.product,a=o.variant,u=o.quantity;return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,r.cartStore.addItem(a,i,null!=u?u:1)];case 1:return[2,{success:!!(null==(t=e.sent())?void 0:t.success)}]}}))}))},saveCustomerFormData:function(o){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,r.customerStore.saveCustomerFormData({email:o.email,firstName:o.firstName,lastName:o.lastName,birthDate:o.birthDate||"",phone:o.phone||"",storefrontPopupId:o.popupId,subscriptions:o.subscriptions})];case 1:return t.sent(),[2]}}))}))},getLastViewedProducts:function(){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){return"function"==typeof(t=r.customerStore).getLastViewedProducts?[2,t.getLastViewedProducts()]:[2,[]]}))}))},formatVariantSellPrice:function(t){return t.formattedSellPrice||""},formatVariantDiscountPrice:function(t){return t.formattedDiscountPrice||null},hasVariantDiscount:function(t){return!!t.hasDiscount},getVariantDiscountPercentage:function(t){var e=t.discountPercentage;return null==e?null:"number"==typeof e?e.toString():e},redirectToProduct:function(t){return!!t.url&&(window.location.href=t.url,!0)},viewPopup:function(t){s.viewStorefrontPopup(t)}}}(),[2,r]}var D,T}))}))};function v(t){var e,n,r,o,i,s=null===(e=t.order)||void 0===e?void 0:e.map((function(t){return{direction:"ASC"===t.direction?a.ASC:a.DESC,type:t.type}}));return{input:{page:null!==(n=t.page)&&void 0!==n?n:1,perPage:null!==(r=t.perPage)&&void 0!==r?r:10,order:s,productIdList:t.productIdList,categoryIdList:t.categoryIdList,priceListId:null!==(o=t.priceListId)&&void 0!==o?o:u.getPriceListId(),salesChannelId:null!==(i=t.salesChannelId)&&void 0!==i?i:u.getSalesChannelId()}}}function g(t){return{email:t.email,firstName:t.firstName,lastName:t.lastName,birthDate:t.birthDate,phone:t.phone,gender:t.gender?String(t.gender):null,customerGroupIds:t.customerGroupIds||[],customerSegmentIds:t.customerSegmentIds||[],subscriptionStatus:t.subscriptionStatus?String(t.subscriptionStatus):null}}function h(t){var e,n,r=[],o=new Set,i=new Set,a=new Set,u=new Set,s=new Set,c=new Set;return t.items.forEach((function(t){var e,n,s,d=t.variant,l=(null==d?void 0:d.productId)||null,p=(null==d?void 0:d.id)||null,f=(null===(e=null==d?void 0:d.brand)||void 0===e?void 0:e.id)||null,m=(null===(n=null==d?void 0:d.categories)||void 0===n?void 0:n.map((function(t){return t.id})).filter(Boolean))||[];r.push({productId:l,variantId:p,brandId:f,categoryIds:m,quantity:t.quantity,finalPrice:t.finalPrice}),l&&o.add(l),p&&i.add(p),f&&a.add(f),m.forEach((function(t){return t&&u.add(t)})),(null===(s=t.discount)||void 0===s?void 0:s.campaignOfferId)&&c.add(t.discount.campaignOfferId)})),null===(e=t.campaignOffers)||void 0===e||e.forEach((function(t){t.campaignOfferId&&c.add(t.campaignOfferId)})),null===(n=t.orderAdjustments)||void 0===n||n.forEach((function(t){t.campaignId&&s.add(t.campaignId)})),{totalPrice:t.totalPrice,totalFinalPrice:t.totalFinalPrice,itemCount:t.itemCount,itemQuantity:t.itemQuantity,currencyCode:t.currencyCode||null,lines:r,productIds:Array.from(o),variantIds:Array.from(i),brandIds:Array.from(a),categoryIds:Array.from(u),appliedCampaignIds:Array.from(s),appliedCampaignOfferIds:Array.from(c),couponCode:t.couponCode||null}}function I(t){"undefined"!=typeof window&&(window.ikasPopupConfig&&(void 0!==t.customer&&(window.ikasPopupConfig.customer=t.customer),void 0!==t.cart&&(window.ikasPopupConfig.cart=t.cart),void 0!==t.customerToken&&(window.ikasPopupConfig.customerToken=t.customerToken||void 0)),"function"!=typeof window.updateIkasPopupContext?window.dispatchEvent(new CustomEvent(l,{detail:t})):window.updateIkasPopupContext(t))}function w(a){var s=this;a.router;var d=a.pageSpecificDataId,l=a.pageType;r.useEffect((function(){if("undefined"!=typeof window&&"undefined"!=typeof document){var r,a=!1,d=[],l=function(t,e){if(function(t){t.setAttribute("data-ikas-popup-widget","true"),!t.dataset.ikasPopupWidgetUrl&&t.src&&(t.dataset.ikasPopupWidgetUrl=t.src)}(t),"true"===t.dataset.ikasPopupWidgetLoaded)return e(),function(){};var n=function(){t.dataset.ikasPopupWidgetLoaded="true",e()},r=function(e){console.error("[@ikas/storefront] Failed to load popup widget script",t.src,e)};return t.addEventListener("load",n,{once:!0}),t.addEventListener("error",r,{once:!0}),function(){t.removeEventListener("load",n),t.removeEventListener("error",r)}},p=function(t){var e=window.location.href.includes("http://localhost:3333/")?"http://localhost:9000/popup-script-injector.iife.js":"/sf/assets/popup/popup-script-injector.iife.js";if(e){var n=function(){a||function(t){if("function"==typeof window.startIkasPopupWidget)try{window.startIkasPopupWidget(t)}catch(t){console.error("[@ikas/storefront] Failed to start popup widget",t)}}(t)},o=document.querySelector('script[data-ikas-popup-widget="true"]');if(o)r=l(o,n);else{var i=document.createElement("script");i.src=e,i.defer=!0,r=l(i,n),document.body.appendChild(i)}}},f=function(t){var e=window.location.href.includes("http://localhost:3333/")?"http://localhost:9000/style.css":"/sf/assets/popup/style.css";if(e&&!document.querySelector('link[href="'.concat(e,'"]'))){var n=document.createElement("link");n.rel="stylesheet",n.href=e,n.setAttribute("data-ikas-popup-widget","true");n.addEventListener("error",(function(t){console.error("[@ikas/storefront] Failed to load popup widget CSS",e,t)}),{once:!0}),document.head.appendChild(n)}};return t(s,void 0,void 0,(function(){var r,l,v;return e(this,(function(w){switch(w.label){case 0:return r=u.getStorefrontPopups()||[],[4,(C=r,t(s,void 0,void 0,(function(){var t,r,o,a,u;return e(this,(function(e){switch(e.label){case 0:if(!(t=C.map((function(t){return t.id})).filter(Boolean)).length)return[2,C];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,i({idList:t})];case 2:return(null==(r=e.sent())?void 0:r.isSuccess)&&(null===(u=r.data)||void 0===u?void 0:u.length)?(o=r.data,[2,C.map((function(t){var e=o.find((function(e){return e.id===t.id}));return e?n(n({},e),{isFilteredOnServerSide:t.isFilteredOnServerSide}):t}))]):[3,4];case 3:return a=e.sent(),console.error("[@ikas/storefront] Failed to fetch popup details",a),[3,4];case 4:return[2,C]}}))})))];case 1:return l=w.sent(),a?[2]:[4,m(l)];case 2:return v=w.sent(),window.ikasPopupConfig=v,p(v),f(),S=c.getInstance(),P=o((function(){var t=S.customerStore.customer;return t?{email:t.email,gender:t.gender,groupIds:(t.customerGroupIds||[]).join(","),segmentIds:(t.customerSegmentIds||[]).join(","),subscriptionStatus:t.subscriptionStatus}:null}),(function(){var t=S.customerStore.customer;I({customer:t?g(t):null,customerToken:u.getCustomerToken()||null})})),y=o((function(){var t=S.cartStore.cart;return t?{total:t.totalFinalPrice,itemCount:t.itemCount,quantity:t.itemQuantity,productSignature:t.items.map((function(t){var e,n;return"".concat((null===(e=t.variant)||void 0===e?void 0:e.productId)||"",":").concat((null===(n=t.variant)||void 0===n?void 0:n.id)||"",":").concat(t.quantity)})).join("|"),campaignSignature:(t.orderAdjustments||[]).map((function(t){return t.campaignId||""})).join("|"),couponCode:t.couponCode}:null}),(function(){var t=S.cartStore.cart;I({cart:t?h(t):null})})),d.push(P,y),[2]}var S,P,y,C}))})),function(){a=!0,null==r||r(),d.forEach((function(t){return t()})),d=[],"function"==typeof window.destroyIkasPopupWidget&&window.destroyIkasPopupWidget()}}}),[d,l])}export{w as usePopupWidget};
|