@ikas/storefront 6.1.0-beta.337 → 6.1.0-beta.338

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 t}from'./../../ext/tslib/tslib.es6.js';import*as e 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 n}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 r}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,v,f,h,j,x,y=o.pageType,b=o.pageTitle,L=o.pageDescription,D=o.canonicals,T=o.disableIndex,C=o.pageSpecificData,O=o.merchantSettings,w=o.addOgpMetas,k=o.productReviewSummary,R=o.pageComponentPropValues,P=a(),E="undefined"!=typeof window,I="local"===process.env.NEXT_PUBLIC_ENV,_=P.asPath.split(/[?#]/)[0].replace("/",""),S=(_="/"===_.charAt(_.length-1)?_.slice(0,-1):_).startsWith("pages/"),V=y===n.BLOG,B=d.getCurrentRouting(),A=((null===(s=d.getMerchantSettings())||void 0===s?void 0:s.defaultLocale)||"tr")===(null==B?void 0:B.locale),M=!!C&&y===n.PRODUCT,N=!!C&&y===n.CATEGORY,G=!!C&&y===n.BRAND,U=M||N||G,F=null;(M||G||N)&&(F=C);var Y=null===(c=null==F?void 0:F.translations)||void 0===c?void 0:c.find((function(t){return t.locale===(null==B?void 0:B.locale)})),H=(null==B?void 0:B.path)?"/"+B.path:"",X=I?"http://localhost:3333":"https://"+d.getDomain(),z=null===(v=d.getIndexPageSeoSettings())||void 0===v?void 0:v.find((function(t){return t.locale===d.getCurrentLocale()})),W=z?new r(z):null;e.useEffect((function(){document.documentElement.lang=d.getCurrentLocale()}),[y,C]);var J=e.useMemo((function(){if(C&&C.href)return"".concat(X).concat(C.href)}),[C]),q=e.useMemo((function(){if(C&&C.href){var t=C.href;return H?"".concat(X).concat(H).concat(t):"".concat(X).concat(t)}}),[C]),K=e.useMemo((function(){var t,e,o,i=[];if(w){if(i.push({property:"og:type",content:"website"}),i.push({property:"og:site_name",content:(null==W?void 0:W.pageTitle)||"https://"+d.getDomain()}),b&&i.push({property:"og:title",content:b}),L&&i.push({property:"og:description",content:L}),y===n.INDEX){var a=null,r=null;!b&&(null==W?void 0:W.pageTitle)&&(a=W.pageTitle),!L&&(null==W?void 0:W.description)&&(r=W.description),(s=null===(t=d.getMetaTemplates())||void 0===t?void 0:t.find((function(t){return t.locale===d.getCurrentLocale()&&t.pageType===y})))&&(a=g(C,y,s.titleTemplate||""),r=g(C,y,s.descriptionTemplate||"")),a&&i.push({property:"og:title",content:a}),r&&i.push({property:"og:description",content:r})}if(y===n.PRODUCT||y===n.CATEGORY||y===n.BRAND){var s,l=null,c=null;if((s=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(t){return t.locale===d.getCurrentLocale()&&t.pageType===y})))&&(l=g(C,y,s.titleTemplate||""),c=g(C,y,s.descriptionTemplate||"")),!b){var m=l||U&&A&&(null==F?void 0:F.name)||U&&!A&&(null==Y?void 0:Y.name);m&&i.push({property:"og:title",content:m})}if(!L){var p=c||U&&!A&&(null==Y?void 0:Y.description);p&&i.push({property:"og:description",content:p})}}i.push({property:"og:url",content:q||(E?window.location.href:"")||"https://".concat(d.getDomain())});var u=null;if(C&&y===n.PRODUCT){var v=C.selectedVariant.mainImage;(null==v?void 0:v.image)&&(u={property:"og:image",content:v.image.src.replace(".webp",".jpg")})}if(C&&y===n.CATEGORY){var f=C;f.image&&(u={property:"og:image",content:f.image.src.replace(".webp",".jpg")})}if(C&&y===n.BRAND){var h=C;h.image&&(u={property:"og:image",content:h.image.src.replace(".webp",".jpg")})}if(C&&y===n.BLOG_CATEGORY){var j=C;j.image&&(u={property:"og:image",content:j.image.src.replace(".webp",".jpg")})}if(C&&y===n.BLOG){var x=C;x.image&&(u={property:"og:image",content:x.image.src.replace(".webp",".jpg")})}!u&&(null==W?void 0:W.icon)&&(u={property:"og:image",content:null===(o=null==W?void 0:W.icon)||void 0===o?void 0:o.src.replace(".webp",".jpg")}),!u&&(null==O?void 0:O.logo)&&(u={property:"og:image",content:O.logo.src.replace(".webp",".jpg")}),u&&i.push(u)}return i}),[b,C,J,L,O,w,O]),Q=e.useMemo((function(){var e=[],o=(null==W?void 0:W.pageTitle)||(null==O?void 0:O.merchantName)||"";if(O){var i={"@context":"https://schema.org","@type":"Website",url:"https://"+d.getDomain()},a=function(e){var o,i,a,n,r,s,l=(null==e?void 0:e.logo)?e.logo.src:void 0;return{"@context":"https://schema.org","@type":"Store",name:null==e?void 0:e.merchantName,logo:l,image:l,url:"https://"+d.getDomain(),telephone:null==e?void 0:e.phone,address:t(t({"@type":"PostalAddress",streetAddress:null===(o=e.address)||void 0===o?void 0:o.addressLine1,addressLocality:null===(a=null===(i=e.address)||void 0===i?void 0:i.city)||void 0===a?void 0:a.name},e.address&&e.address.state&&{addressRegion:e.address.state.code}),{postalCode:null===(n=e.address)||void 0===n?void 0:n.postalCode,addressCountry:null===(s=null===(r=e.address)||void 0===r?void 0:r.country)||void 0===s?void 0:s.code})}}(O);e.push(i),e.push(a)}if(C&&y===n.PRODUCT){var r=C,s=function(e,o){var i,a,r,s,l,c;try{var m=["c7d934c7-2d44-43c3-b023-de7aa93fe435"],p=null===(i=d.getMerchantSettings())||void 0===i?void 0:i.merchantId,u=d.getCurrentRouting(),v=null==u?void 0:u.path,f=function(t){return v?"https://".concat(d.getDomain(),"/").concat(v).concat(t):"https://".concat(d.getDomain()).concat(t)},h=e.selectedVariant,j=null,x=null===(a=d.getMetaTemplates())||void 0===a?void 0:a.find((function(t){return t.locale===d.getCurrentLocale()&&n.PRODUCT}));return x&&(j=g(e,n.PRODUCT,x.descriptionTemplate||"")),t(t({"@context":"https://schema.org/","@type":"Product",name:e.name,description:(null===(r=e.metaData)||void 0===r?void 0:r.description)||j,image:null===(s=h.images)||void 0===s?void 0:s.map((function(t){return t.image?t.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=e.brand)||void 0===c?void 0:c.name}},o&&{aggregateRating:{"@type":"AggregateRating",ratingValue:o.averageStar,reviewCount:o.totalReview}}),m.some((function(t){return t!==p}))?{offers:e.variants.map((function(t){var o;return{"@type":"Offer",url:f(e.productHref+"?vid="+t.id),priceCurrency:t.price.currency||"TRY",price:(null!==(o=t.campaignPrice)&&void 0!==o?o:t.price.finalPrice).toFixed(2),priceValidUntil:"",itemCondition:"https://schema.org/NewCondition",availability:t.stock>0||t.sellIfOutOfStock?"https://schema.org/InStock":"https://schema.org/OutOfStock"}}))}:{})}catch(t){}}(r,k||null);if(s&&e.push(s),r.categories.length)(c=m(r.categories[0],o,r))&&e.push(c)}if(C&&y===n.CATEGORY){var l=function(t){var e,o;try{var i=d.getCurrentRouting(),a=null==i?void 0:i.path,n=function(t){return a?"https://".concat(d.getDomain(),"/").concat(a).concat(t):"https://".concat(d.getDomain()).concat(t)};return{"@context":"http://schema.org","@type":"CollectionPage",url:n(t.href),name:null===(e=t.metaData)||void 0===e?void 0:e.pageTitle,description:null===(o=t.metaData)||void 0===o?void 0:o.description,image:t.image?t.image.src:void 0}}catch(t){}}(C),c=m(C,o),v=p(R);l&&e.push(l),c&&e.push(c),v&&e.push(v)}C&&y===n.BRAND&&((v=p(R))&&e.push(v));var f=function(t,e){if(console.log("pageType",t),t===n.BLOG_INDEX&&e)return e;return"Blog"}(y,b);C&&y===n.BLOG_CATEGORY&&((j=u(o,f,C))&&e.push(j));if(C&&y===n.BLOG){var h=function(e){var o;try{var i="https://".concat(d.getDomain()).concat(e.href),a="".concat(e.writer.firstName," ").concat(e.writer.lastName),n=(new DOMParser).parseFromString(e.blogContent.content,"text/html").body.textContent;return t(t({"@context":"https://schema.org","@type":"BlogPosting",headline:e.title,image:null===(o=e.image)||void 0===o?void 0:o.src},e.category&&{genre:e.category.name}),{url:i,datePublished:new Date(e.createdAt).toISOString(),dateCreated:new Date(e.createdAt).toISOString(),dateModified:new Date(e.updatedAt).toISOString(),description:e.shortDescription,articleBody:n,author:{"@type":"Person",name:a}})}catch(t){}}(C),j=u(o,f,void 0,C);h&&e.push(h),j&&e.push(j)}return e}),[C,O]),Z=e.useMemo((function(){var t,e=null===(t=d.getMetaTemplates())||void 0===t?void 0:t.find((function(t){return t.locale===d.getCurrentLocale()&&t.pageType===y}));return e?g(C,y,e.titleTemplate||""):null}),[y,C]),$=e.useMemo((function(){var t,e=null===(t=d.getMetaTemplates())||void 0===t?void 0:t.find((function(t){return t.locale===d.getCurrentLocale()&&t.pageType===y}));return e?g(C,y,e.descriptionTemplate||""):null}),[y,C]),tt=e.useMemo((function(){return!d.getFavicon()&&(null==W?void 0:W.favIcon)?W.favIcon:null}),[]),et=[];d.getRoutings().forEach((function(t){var e;(null===(e=t.countryCodes)||void 0===e?void 0:e.length)?t.countryCodes.forEach((function(e){et.push({routing:t,hrefLang:t.locale+"-"+e})})):et.push({routing:t,hrefLang:t.locale})}));var ot=function(t){var e,o,i,a,n,r,s,l,c,m=C,p=null===(o=null===(e=null==m?void 0:m.metaData)||void 0===e?void 0:e.translations)||void 0===o?void 0:o.find((function(e){return e.locale===t.locale}));if(p&&(null==p?void 0:p.slug))return p.slug;var u=null===(i=d.getMerchantSettings())||void 0===i?void 0:i.defaultLocale,g=et.find((function(t){return!t.routing.path}));return g?(null===(r=null===(n=null===(a=null==m?void 0:m.metaData)||void 0===a?void 0:a.translations)||void 0===n?void 0:n.find((function(t){return t.locale===g.routing.locale})))||void 0===r?void 0:r.slug)||"":(null===(c=null===(l=null===(s=null==m?void 0:m.metaData)||void 0===s?void 0:s.translations)||void 0===l?void 0:l.find((function(t){return t.locale===u})))||void 0===c?void 0:c.slug)||""},it=null===(f=et.find((function(t){return!t.routing.path})))||void 0===f?void 0:f.routing.locale,at=(null===(x=null===(j=null===(h=null==C?void 0:C.metaData)||void 0===h?void 0:h.translations)||void 0===j?void 0:j.find((function(t){return t.locale===it})))||void 0===x?void 0:x.slug)||"",nt=l.getInstance();return e.createElement(i,null,e.createElement("title",null,b||Z||(U?A?(null==F?void 0:F.name)||"":(null==Y?void 0:Y.name)||"":(null==W?void 0:W.pageTitle)||"")),e.createElement("meta",{name:"description",content:L||$||(U?(null==Y?void 0:Y.description)||"":(null==W?void 0:W.description)||"")}),et.length>1&&!S&&!V&&e.createElement(e.Fragment,null,et.filter((function(t){return!S||t.routing.id===(null==B?void 0:B.id)})).map((function(t){return e.createElement("link",{key:t.routing.id+t.hrefLang,rel:"alternate",hrefLang:t.hrefLang,href:"".concat(X+(t.routing.path?"/"+t.routing.path:""),"/").concat(ot(t.routing))})})),e.createElement("link",{rel:"alternate",hrefLang:"x-default",href:"".concat(X).concat(it?"/".concat(at):"".concat(H,"/").concat(_))})),!!T&&e.createElement("meta",{name:"robots",content:"noindex"}),!!w&&K.map((function(t,o){return e.createElement("meta",{key:"".concat(t.content,"-").concat(o),property:t.property,content:t.content})})),!!D&&D.map((function(t,o){return e.createElement("link",{key:o+"url",rel:"canonical",href:"".concat(X).concat(H).concat(t)})})),tt&&e.createElement("link",{rel:"shortcut icon",href:"".concat(process.env.NEXT_PUBLIC_CDN_URL,"images/").concat(tt,"/image_180.webp"),type:"image/webp"}),!D&&nt.currentPageType!==n.NOT_FOUND&&e.createElement("link",{rel:"canonical",href:"".concat(X).concat(H,"/").concat(_)}),!!Q.length&&Q.map((function(t,o){return e.createElement("script",{key:o,type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(t)}})})))}));function m(t,e,o){try{var i=l.getInstance(),a=d.getCurrentRouting(),r=null==a?void 0:a.path,s=function(t){return r?"https://".concat(d.getDomain(),"/").concat(r).concat(t):"https://".concat(d.getDomain()).concat(t)},c=[{"@type":"ListItem",position:1,name:e,item:"https://".concat(d.getDomain())}];return(c=c.concat(t.categoryPathItems.map((function(t,e){return{"@type":"ListItem",position:e+2,name:t.name,item:s(t.href)}})))).push({"@type":"ListItem",position:c.length+1,name:t.name,item:s(t.href)}),i.currentPageType===n.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(t){}}function p(t){try{var e=d.getCurrentRouting(),o=null==e?void 0:e.path;if(t){var i=(t.filter((function(t){return!t.component.isHeader&&!t.component.isFooter}))||[]).find((function(t){return Object.values(t.propValues).find((function(t){var e;return t instanceof s&&(null===(e=t._productListPropValue)||void 0===e?void 0:e.usePageFilter)}))}));if(i){var a=Object.values(i.propValues).find((function(t){var e;return t instanceof s&&(null===(e=t._productListPropValue)||void 0===e?void 0:e.usePageFilter)}));if(a)return{"@context":"http://schema.org","@type":"ItemList",itemListElement:(a.data||[]).slice(0,10).map((function(t,e){var i,a,n,r;return{"@type":"ListItem",position:e+1,item:{"@type":"Product",name:t.name,image:(null===(a=null===(i=t.selectedVariant.mainImage)||void 0===i?void 0:i.image)||void 0===a?void 0:a.src)||"",offers:{"@type":"Offer",url:(r=t.href,o?"https://".concat(d.getDomain(),"/").concat(o).concat(r):"https://".concat(d.getDomain()).concat(r)),priceCurrency:t.selectedVariant.price.currency||"TRY",price:(null!==(n=t.selectedVariant.campaignPrice)&&void 0!==n?n:t.selectedVariant.finalPrice).toFixed(2),availability:t.selectedVariant.stock>0||t.selectedVariant.sellIfOutOfStock?"https://schema.org/InStock":"https://schema.org/OutOfStock"}}}}))}}}}catch(t){}}function u(t,e,o,i){var a,n;try{var r=d.getCurrentRouting(),s=null==r?void 0:r.path,l=function(t){return s?"https://".concat(d.getDomain(),"/").concat(s).concat(t):"https://".concat(d.getDomain()).concat(t)},c=[{"@type":"ListItem",position:1,name:t,item:"https://".concat(d.getDomain())},{"@type":"ListItem",position:2,name:e,item:l("/blog")}],m=o||(null==i?void 0:i.category);return(null===(a=null==m?void 0:m.metadata)||void 0===a?void 0:a.slug)&&c.push({"@type":"ListItem",position:c.length+1,name:m.name,item:l(m.href)}),(null===(n=null==i?void 0:i.metadata)||void 0===n?void 0:n.slug)&&c.push({"@type":"ListItem",position:c.length+1,name:i.title,item:l(i.href)}),{"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:c}}catch(t){}}function g(t,e,o){var i,a,r=o;try{switch(e){case n.PRODUCT:var s=t,d=s.name,l=(null===(i=s.brand)||void 0===i?void 0:i.name)||"",c=s.selectedVariant.sku||"",m=(null===(a=s.selectedVariant.barcodeList)||void 0===a?void 0:a.length)?s.selectedVariant.barcodeList[0]:"",p=s.selectedVariant.campaignPrice?s.selectedVariant.formattedCampaignPrice:s.selectedVariant.formattedFinalPrice;r.includes("{{name}}")&&(r=v(r,"{{name}}",d)),r.includes("{{brand}}")&&(r=v(r,"{{brand}}",l)),r.includes("{{sku}}")&&(r=v(r,"{{sku}}",c)),r.includes("{{barcode}}")&&(r=v(r,"{{barcode}}",m)),r.includes("{{price}}")&&(r=v(r,"{{price}}",p.toString()));break;case n.BRAND:case n.CATEGORY:case n.BLOG_CATEGORY:var u=t.name||"";r.includes("{{name}}")&&(r=v(r,"{{name}}",u));break;case n.BLOG:var g=t.title;r.includes("{{name}}")&&(r=v(r,"{{name}}",g))}}catch(t){}return r.trimEnd()}function v(t,e,o){var i=new RegExp(e,"g");return t.replace(i,o)}export{c as IkasPageHead};
1
+ import{__assign as t}from'./../../ext/tslib/tslib.es6.js';import*as e 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 n}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 r}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,v,f,h,j,x,y=o.pageType,b=o.pageTitle,L=o.pageDescription,D=o.canonicals,C=o.disableIndex,T=o.pageSpecificData,O=o.merchantSettings,w=o.addOgpMetas,k=o.productReviewSummary,R=o.pageComponentPropValues,P=a(),E="undefined"!=typeof window,I="local"===process.env.NEXT_PUBLIC_ENV,_=P.asPath.split(/[?#]/)[0].replace("/",""),S=(_="/"===_.charAt(_.length-1)?_.slice(0,-1):_).startsWith("pages/"),V=y===n.BLOG,B=d.getCurrentRouting(),A=((null===(s=d.getMerchantSettings())||void 0===s?void 0:s.defaultLocale)||"tr")===(null==B?void 0:B.locale),M=!!T&&y===n.PRODUCT,N=!!T&&y===n.CATEGORY,G=!!T&&y===n.BRAND,U=M||N||G,F=null;(M||G||N)&&(F=T);var Y=null===(c=null==F?void 0:F.translations)||void 0===c?void 0:c.find((function(t){return t.locale===(null==B?void 0:B.locale)})),H=(null==B?void 0:B.path)?"/"+B.path:"",X=I?"http://localhost:3333":"https://"+d.getDomain(),z=null===(v=d.getIndexPageSeoSettings())||void 0===v?void 0:v.find((function(t){return t.locale===d.getCurrentLocale()})),W=z?new r(z):null;e.useEffect((function(){document.documentElement.lang=d.getCurrentLocale()}),[y,T]);var J=e.useMemo((function(){if(T&&T.href)return"".concat(X).concat(T.href)}),[T]),q=e.useMemo((function(){if(T&&T.href){var t=T.href;return H?"".concat(X).concat(H).concat(t):"".concat(X).concat(t)}}),[T]),K=e.useMemo((function(){var t,e,o,i=[];if(w){if(i.push({property:"og:type",content:"website"}),i.push({property:"og:site_name",content:(null==W?void 0:W.pageTitle)||"https://"+d.getDomain()}),b&&i.push({property:"og:title",content:b}),L&&i.push({property:"og:description",content:L}),y===n.INDEX){var a=null,r=null;!b&&(null==W?void 0:W.pageTitle)&&(a=W.pageTitle),!L&&(null==W?void 0:W.description)&&(r=W.description),(s=null===(t=d.getMetaTemplates())||void 0===t?void 0:t.find((function(t){return t.locale===d.getCurrentLocale()&&t.pageType===y})))&&(a=g(T,y,s.titleTemplate||""),r=g(T,y,s.descriptionTemplate||"")),a&&i.push({property:"og:title",content:a}),r&&i.push({property:"og:description",content:r})}if(y===n.PRODUCT||y===n.CATEGORY||y===n.BRAND){var s,l=null,c=null;if((s=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(t){return t.locale===d.getCurrentLocale()&&t.pageType===y})))&&(l=g(T,y,s.titleTemplate||""),c=g(T,y,s.descriptionTemplate||"")),!b){var m=l||U&&A&&(null==F?void 0:F.name)||U&&!A&&(null==Y?void 0:Y.name);m&&i.push({property:"og:title",content:m})}if(!L){var p=c||U&&!A&&(null==Y?void 0:Y.description);p&&i.push({property:"og:description",content:p})}}i.push({property:"og:url",content:q||(E?window.location.href:"")||"https://".concat(d.getDomain())});var u=null;if(T&&y===n.PRODUCT){var v=T.selectedVariant.mainImage;(null==v?void 0:v.image)&&(u={property:"og:image",content:v.image.src.replace(".webp",".jpg")})}if(T&&y===n.CATEGORY){var f=T;f.image&&(u={property:"og:image",content:f.image.src.replace(".webp",".jpg")})}if(T&&y===n.BRAND){var h=T;h.image&&(u={property:"og:image",content:h.image.src.replace(".webp",".jpg")})}if(T&&y===n.BLOG_CATEGORY){var j=T;j.image&&(u={property:"og:image",content:j.image.src.replace(".webp",".jpg")})}if(T&&y===n.BLOG){var x=T;x.image&&(u={property:"og:image",content:x.image.src.replace(".webp",".jpg")})}!u&&(null==W?void 0:W.icon)&&(u={property:"og:image",content:null===(o=null==W?void 0:W.icon)||void 0===o?void 0:o.src.replace(".webp",".jpg")}),!u&&(null==O?void 0:O.logo)&&(u={property:"og:image",content:O.logo.src.replace(".webp",".jpg")}),u&&i.push(u)}return i}),[b,T,J,L,O,w,O]),Q=e.useMemo((function(){var e=[],o=(null==W?void 0:W.pageTitle)||(null==O?void 0:O.merchantName)||"";if(O){var i={"@context":"https://schema.org","@type":"Website",url:"https://"+d.getDomain()},a=function(e){var o,i,a,n,r,s,l=(null==e?void 0:e.logo)?e.logo.src:void 0;return{"@context":"https://schema.org","@type":"Store",name:null==e?void 0:e.merchantName,logo:l,image:l,url:"https://"+d.getDomain(),telephone:null==e?void 0:e.phone,address:t(t({"@type":"PostalAddress",streetAddress:null===(o=e.address)||void 0===o?void 0:o.addressLine1,addressLocality:null===(a=null===(i=e.address)||void 0===i?void 0:i.city)||void 0===a?void 0:a.name},e.address&&e.address.state&&{addressRegion:e.address.state.code}),{postalCode:null===(n=e.address)||void 0===n?void 0:n.postalCode,addressCountry:null===(s=null===(r=e.address)||void 0===r?void 0:r.country)||void 0===s?void 0:s.code})}}(O);e.push(i),e.push(a)}if(T&&y===n.PRODUCT){var r=T,s=function(e,o){var i,a,r,s,l,c;try{var m=["c7d934c7-2d44-43c3-b023-de7aa93fe435"],p=null===(i=d.getMerchantSettings())||void 0===i?void 0:i.merchantId,u=d.getCurrentRouting(),v=null==u?void 0:u.path,f=function(t){return v?"https://".concat(d.getDomain(),"/").concat(v).concat(t):"https://".concat(d.getDomain()).concat(t)},h=e.selectedVariant,j=null,x=null===(a=d.getMetaTemplates())||void 0===a?void 0:a.find((function(t){return t.locale===d.getCurrentLocale()&&n.PRODUCT}));return x&&(j=g(e,n.PRODUCT,x.descriptionTemplate||"")),t(t({"@context":"https://schema.org/","@type":"Product",name:e.name,description:(null===(r=e.metaData)||void 0===r?void 0:r.description)||j,image:null===(s=h.images)||void 0===s?void 0:s.map((function(t){return t.image?t.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=e.brand)||void 0===c?void 0:c.name}},o&&{aggregateRating:{"@type":"AggregateRating",ratingValue:o.averageStar,reviewCount:o.totalReview}}),m.some((function(t){return t!==p}))?{offers:e.variants.map((function(t){var o;return{"@type":"Offer",url:f(e.productHref+"?vid="+t.id),priceCurrency:t.price.currency||"TRY",price:(null!==(o=t.campaignPrice)&&void 0!==o?o:t.price.finalPrice).toFixed(2),priceValidUntil:"",itemCondition:"https://schema.org/NewCondition",availability:t.stock>0||t.sellIfOutOfStock?"https://schema.org/InStock":"https://schema.org/OutOfStock"}}))}:{})}catch(t){}}(r,k||null);if(s&&e.push(s),r.categories.length)(c=m(r.categories[0],o,r))&&e.push(c)}if(T&&y===n.CATEGORY){var l=function(t){var e,o;try{var i=d.getCurrentRouting(),a=null==i?void 0:i.path,n=function(t){return a?"https://".concat(d.getDomain(),"/").concat(a).concat(t):"https://".concat(d.getDomain()).concat(t)};return{"@context":"http://schema.org","@type":"CollectionPage",url:n(t.href),name:null===(e=t.metaData)||void 0===e?void 0:e.pageTitle,description:null===(o=t.metaData)||void 0===o?void 0:o.description,image:t.image?t.image.src:void 0}}catch(t){}}(T),c=m(T,o),v=p(R);l&&e.push(l),c&&e.push(c),v&&e.push(v)}T&&y===n.BRAND&&((v=p(R))&&e.push(v));var f=function(t,e){if(t===n.BLOG_INDEX&&e)return e;return"Blog"}(y,b);T&&y===n.BLOG_CATEGORY&&((j=u(o,f,T))&&e.push(j));if(T&&y===n.BLOG){var h=function(e){var o;try{var i="https://".concat(d.getDomain()).concat(e.href),a="".concat(e.writer.firstName," ").concat(e.writer.lastName),n=(new DOMParser).parseFromString(e.blogContent.content,"text/html").body.textContent;return t(t({"@context":"https://schema.org","@type":"BlogPosting",headline:e.title,image:null===(o=e.image)||void 0===o?void 0:o.src},e.category&&{genre:e.category.name}),{url:i,datePublished:new Date(e.createdAt).toISOString(),dateCreated:new Date(e.createdAt).toISOString(),dateModified:new Date(e.updatedAt).toISOString(),description:e.shortDescription,articleBody:n,author:{"@type":"Person",name:a}})}catch(t){}}(T),j=u(o,f,void 0,T);h&&e.push(h),j&&e.push(j)}return e}),[T,O]),Z=e.useMemo((function(){var t,e=null===(t=d.getMetaTemplates())||void 0===t?void 0:t.find((function(t){return t.locale===d.getCurrentLocale()&&t.pageType===y}));return e?g(T,y,e.titleTemplate||""):null}),[y,T]),$=e.useMemo((function(){var t,e=null===(t=d.getMetaTemplates())||void 0===t?void 0:t.find((function(t){return t.locale===d.getCurrentLocale()&&t.pageType===y}));return e?g(T,y,e.descriptionTemplate||""):null}),[y,T]),tt=e.useMemo((function(){return!d.getFavicon()&&(null==W?void 0:W.favIcon)?W.favIcon:null}),[]),et=[];d.getRoutings().forEach((function(t){var e;(null===(e=t.countryCodes)||void 0===e?void 0:e.length)?t.countryCodes.forEach((function(e){et.push({routing:t,hrefLang:t.locale+"-"+e})})):et.push({routing:t,hrefLang:t.locale})}));var ot=function(t){var e,o,i,a,n,r,s,l,c,m=T,p=null===(o=null===(e=null==m?void 0:m.metaData)||void 0===e?void 0:e.translations)||void 0===o?void 0:o.find((function(e){return e.locale===t.locale}));if(p&&(null==p?void 0:p.slug))return p.slug;var u=null===(i=d.getMerchantSettings())||void 0===i?void 0:i.defaultLocale,g=et.find((function(t){return!t.routing.path}));return g?(null===(r=null===(n=null===(a=null==m?void 0:m.metaData)||void 0===a?void 0:a.translations)||void 0===n?void 0:n.find((function(t){return t.locale===g.routing.locale})))||void 0===r?void 0:r.slug)||"":(null===(c=null===(l=null===(s=null==m?void 0:m.metaData)||void 0===s?void 0:s.translations)||void 0===l?void 0:l.find((function(t){return t.locale===u})))||void 0===c?void 0:c.slug)||""},it=null===(f=et.find((function(t){return!t.routing.path})))||void 0===f?void 0:f.routing.locale,at=(null===(x=null===(j=null===(h=null==T?void 0:T.metaData)||void 0===h?void 0:h.translations)||void 0===j?void 0:j.find((function(t){return t.locale===it})))||void 0===x?void 0:x.slug)||"",nt=l.getInstance();return e.createElement(i,null,e.createElement("title",null,b||Z||(U?A?(null==F?void 0:F.name)||"":(null==Y?void 0:Y.name)||"":(null==W?void 0:W.pageTitle)||"")),e.createElement("meta",{name:"description",content:L||$||(U?(null==Y?void 0:Y.description)||"":(null==W?void 0:W.description)||"")}),et.length>1&&!S&&!V&&e.createElement(e.Fragment,null,et.filter((function(t){return!S||t.routing.id===(null==B?void 0:B.id)})).map((function(t){return e.createElement("link",{key:t.routing.id+t.hrefLang,rel:"alternate",hrefLang:t.hrefLang,href:"".concat(X+(t.routing.path?"/"+t.routing.path:""),"/").concat(ot(t.routing))})})),e.createElement("link",{rel:"alternate",hrefLang:"x-default",href:"".concat(X).concat(it?"/".concat(at):"".concat(H,"/").concat(_))})),!!C&&e.createElement("meta",{name:"robots",content:"noindex"}),!!w&&K.map((function(t,o){return e.createElement("meta",{key:"".concat(t.content,"-").concat(o),property:t.property,content:t.content})})),!!D&&D.map((function(t,o){return e.createElement("link",{key:o+"url",rel:"canonical",href:"".concat(X).concat(H).concat(t)})})),tt&&e.createElement("link",{rel:"shortcut icon",href:"".concat(process.env.NEXT_PUBLIC_CDN_URL,"images/").concat(tt,"/image_180.webp"),type:"image/webp"}),!D&&nt.currentPageType!==n.NOT_FOUND&&e.createElement("link",{rel:"canonical",href:"".concat(X).concat(H,"/").concat(_)}),!!Q.length&&Q.map((function(t,o){return e.createElement("script",{key:o,type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(t)}})})))}));function m(t,e,o){try{var i=l.getInstance(),a=d.getCurrentRouting(),r=null==a?void 0:a.path,s=function(t){return r?"https://".concat(d.getDomain(),"/").concat(r).concat(t):"https://".concat(d.getDomain()).concat(t)},c=[{"@type":"ListItem",position:1,name:e,item:"https://".concat(d.getDomain())}];return(c=c.concat(t.categoryPathItems.map((function(t,e){return{"@type":"ListItem",position:e+2,name:t.name,item:s(t.href)}})))).push({"@type":"ListItem",position:c.length+1,name:t.name,item:s(t.href)}),i.currentPageType===n.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(t){}}function p(t){try{var e=d.getCurrentRouting(),o=null==e?void 0:e.path;if(t){var i=(t.filter((function(t){return!t.component.isHeader&&!t.component.isFooter}))||[]).find((function(t){return Object.values(t.propValues).find((function(t){var e;return t instanceof s&&(null===(e=t._productListPropValue)||void 0===e?void 0:e.usePageFilter)}))}));if(i){var a=Object.values(i.propValues).find((function(t){var e;return t instanceof s&&(null===(e=t._productListPropValue)||void 0===e?void 0:e.usePageFilter)}));if(a)return{"@context":"http://schema.org","@type":"ItemList",itemListElement:(a.data||[]).slice(0,10).map((function(t,e){var i,a,n,r;return{"@type":"ListItem",position:e+1,item:{"@type":"Product",name:t.name,image:(null===(a=null===(i=t.selectedVariant.mainImage)||void 0===i?void 0:i.image)||void 0===a?void 0:a.src)||"",offers:{"@type":"Offer",url:(r=t.href,o?"https://".concat(d.getDomain(),"/").concat(o).concat(r):"https://".concat(d.getDomain()).concat(r)),priceCurrency:t.selectedVariant.price.currency||"TRY",price:(null!==(n=t.selectedVariant.campaignPrice)&&void 0!==n?n:t.selectedVariant.finalPrice).toFixed(2),availability:t.selectedVariant.stock>0||t.selectedVariant.sellIfOutOfStock?"https://schema.org/InStock":"https://schema.org/OutOfStock"}}}}))}}}}catch(t){}}function u(t,e,o,i){var a,n;try{var r=d.getCurrentRouting(),s=null==r?void 0:r.path,l=function(t){return s?"https://".concat(d.getDomain(),"/").concat(s).concat(t):"https://".concat(d.getDomain()).concat(t)},c=[{"@type":"ListItem",position:1,name:t,item:"https://".concat(d.getDomain())},{"@type":"ListItem",position:2,name:e,item:l("/blog")}],m=o||(null==i?void 0:i.category);return(null===(a=null==m?void 0:m.metadata)||void 0===a?void 0:a.slug)&&c.push({"@type":"ListItem",position:c.length+1,name:m.name,item:l(m.href)}),(null===(n=null==i?void 0:i.metadata)||void 0===n?void 0:n.slug)&&c.push({"@type":"ListItem",position:c.length+1,name:i.title,item:l(i.href)}),{"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:c}}catch(t){}}function g(t,e,o){var i,a,r=o;try{switch(e){case n.PRODUCT:var s=t,d=s.name,l=(null===(i=s.brand)||void 0===i?void 0:i.name)||"",c=s.selectedVariant.sku||"",m=(null===(a=s.selectedVariant.barcodeList)||void 0===a?void 0:a.length)?s.selectedVariant.barcodeList[0]:"",p=s.selectedVariant.campaignPrice?s.selectedVariant.formattedCampaignPrice:s.selectedVariant.formattedFinalPrice;r.includes("{{name}}")&&(r=v(r,"{{name}}",d)),r.includes("{{brand}}")&&(r=v(r,"{{brand}}",l)),r.includes("{{sku}}")&&(r=v(r,"{{sku}}",c)),r.includes("{{barcode}}")&&(r=v(r,"{{barcode}}",m)),r.includes("{{price}}")&&(r=v(r,"{{price}}",p.toString()));break;case n.BRAND:case n.CATEGORY:case n.BLOG_CATEGORY:var u=t.name||"";r.includes("{{name}}")&&(r=v(r,"{{name}}",u));break;case n.BLOG:var g=t.title;r.includes("{{name}}")&&(r=v(r,"{{name}}",g))}}catch(t){}return r.trimEnd()}function v(t,e,o){var i=new RegExp(e,"g");return t.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,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||null,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};
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,h,I,S,y,P,C,k,b,L,E;return e(this,(function(j){switch(j.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 j.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),(h=u.getCustomerToken())&&(r.customerToken=h),(I=u.getCurrentLocale())&&(r.locale=I),(S=null===(E=null===(L=u.getCurrentRouting())||void 0===L?void 0:L.countryCodes)||void 0===E?void 0:E[0])&&(r.countryCode=S),(y=u.getPriceListId())&&(r.priceListId=y),(P=u.getSalesChannelId())&&(r.salesChannelId=P),D=c.getInstance().customerStore.customer,(C=D?g(D):null)&&(r.customer=C),T=c.getInstance().cartStore.cart,(k=T?w(T):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||null,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 T,D}))}))};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 w(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 h(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 I(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,d,l=!1,p=[],f=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)}},v=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(){l||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=f(o,n);else{var i=document.createElement("script");i.src=e,i.defer=!0,r=f(i,n),document.body.appendChild(i)}}},I=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)}},S=function(){return t(s,void 0,void 0,(function(){var r,a,d;return e(this,(function(f){switch(f.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 a=f.sent(),l?[2]:[4,m(a)];case 2:return d=f.sent(),window.ikasPopupConfig=d,v(d),I(),S=c.getInstance(),y=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;h({customer:t?g(t):null,customerToken:u.getCustomerToken()||null})})),P=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;h({cart:t?w(t):null})})),p.push(y,P),[2]}var S,y,P,C}))}))},y=function(){if(!l){var t=window.requestIdleCallback;if("function"==typeof t){var e=t((function(){l||S()}),{timeout:3e3});d=function(){var t,n;return null===(n=(t=window).cancelIdleCallback)||void 0===n?void 0:n.call(t,e)}}else{var n=window.setTimeout((function(){l||S()}),2e3);d=function(){return window.clearTimeout(n)}}}};return function(){if("complete"!==document.readyState){var t=function(){null==a||a(),a=void 0,y()};window.addEventListener("load",t,{once:!0}),a=function(){return window.removeEventListener("load",t)}}else y()}(),function(){l=!0,null==a||a(),null==d||d(),null==r||r(),p.forEach((function(t){return t()})),p=[],"function"==typeof window.destroyIkasPopupWidget&&window.destroyIkasPopupWidget()}}}),[d,l])}export{I as usePopupWidget};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "6.1.0-beta.337",
3
+ "version": "6.1.0-beta.338",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -23,11 +23,11 @@
23
23
  "swiper": "11.0.6"
24
24
  },
25
25
  "devDependencies": {
26
- "@ikas/storefront-api": "^6.1.0-beta.337",
27
- "@ikas/storefront-config": "^6.1.0-beta.337",
28
- "@ikas/storefront-model-functions": "^6.1.0-beta.337",
29
- "@ikas/storefront-models": "^6.1.0-beta.337",
30
- "@ikas/storefront-providers": "^6.1.0-beta.337",
26
+ "@ikas/storefront-api": "^6.1.0-beta.338",
27
+ "@ikas/storefront-config": "^6.1.0-beta.338",
28
+ "@ikas/storefront-model-functions": "^6.1.0-beta.338",
29
+ "@ikas/storefront-models": "^6.1.0-beta.338",
30
+ "@ikas/storefront-providers": "^6.1.0-beta.338",
31
31
  "@ikas/localized-address": "1.0.0-beta.6",
32
32
  "@adyen/adyen-web": "^5.57.0",
33
33
  "@rollup/plugin-commonjs": "^22.0.0",
@@ -62,11 +62,11 @@
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@ikas/localized-address": "1.0.0-beta.6",
65
- "@ikas/storefront-api": "^6.1.0-beta.337",
66
- "@ikas/storefront-config": "^6.1.0-beta.337",
67
- "@ikas/storefront-model-functions": "^6.1.0-beta.337",
68
- "@ikas/storefront-models": "^6.1.0-beta.337",
69
- "@ikas/storefront-providers": "^6.1.0-beta.337",
65
+ "@ikas/storefront-api": "^6.1.0-beta.338",
66
+ "@ikas/storefront-config": "^6.1.0-beta.338",
67
+ "@ikas/storefront-model-functions": "^6.1.0-beta.338",
68
+ "@ikas/storefront-models": "^6.1.0-beta.338",
69
+ "@ikas/storefront-providers": "^6.1.0-beta.338",
70
70
  "mobx": "^6.1.3",
71
71
  "mobx-react-lite": "^3.1.5",
72
72
  "next": "12.2.0",