@ikas/storefront 2.0.32 → 2.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/build/_virtual/index.js_commonjs-proxy3.js +1 -1
  2. package/build/_virtual/index.js_commonjs-proxy4.js +1 -1
  3. package/build/analytics/analytics.js +1 -1
  4. package/build/analytics/googleTagManager.js +1 -1
  5. package/build/analytics/ikas.js +1 -1
  6. package/build/api/brand/index.js +1 -1
  7. package/build/api/category/index.js +1 -1
  8. package/build/api/checkout/index.js +1 -1
  9. package/build/api/customer/__generated__/createOrderRefundRequest.d.ts +1 -1
  10. package/build/api/customer/index.js +1 -1
  11. package/build/api/customer-review/index.js +1 -1
  12. package/build/api/customer-review-summary/__generated__/listCustomerReviewSummary.d.ts +56 -0
  13. package/build/api/customer-review-summary/index.d.ts +22 -0
  14. package/build/api/customer-review-summary/index.js +1 -0
  15. package/build/api/favorite-product/index.js +1 -1
  16. package/build/api/html-meta-data/index.js +1 -1
  17. package/build/api/index.d.ts +1 -0
  18. package/build/api/merchant/index.js +1 -1
  19. package/build/api/product-search/index.js +1 -1
  20. package/build/components/checkout/components/address-form/model.js +1 -1
  21. package/build/components/checkout/components/cart-summary/cart-item/index.js +1 -1
  22. package/build/components/checkout/components/credit-card-form/index.js +1 -1
  23. package/build/components/checkout/components/customer-addresses/model.js +1 -1
  24. package/build/components/checkout/index.js +1 -1
  25. package/build/components/checkout/model.js +1 -1
  26. package/build/components/checkout/steps/step-success/index.js +1 -1
  27. package/build/components/page/head.js +1 -1
  28. package/build/components/page/index.js +1 -1
  29. package/build/components/page-editor/ThemeComponentEditor.js +1 -1
  30. package/build/components/page-editor/model.js +1 -1
  31. package/build/ikas.js +7 -7
  32. package/build/index.js +1 -1
  33. package/build/models/data/customer-review-summary/index.d.ts +16 -0
  34. package/build/models/data/customer-review-summary/index.js +1 -0
  35. package/build/models/data/index.d.ts +1 -0
  36. package/build/models/data/product/variant/index.js +1 -1
  37. package/build/models/data/storefront/theme-localization/index.js +1 -1
  38. package/build/models/theme/page/component/prop-value/product-list.js +1 -1
  39. package/build/models/ui/blog-category-list/index.js +1 -1
  40. package/build/models/ui/blog-list/index.js +1 -1
  41. package/build/models/ui/brand-list/index.js +1 -1
  42. package/build/models/ui/category-list/index.js +1 -1
  43. package/build/models/ui/customer-review-list/index.js +1 -1
  44. package/build/models/ui/customer-review-summary-list/index.d.ts +43 -0
  45. package/build/models/ui/customer-review-summary-list/index.js +1 -0
  46. package/build/models/ui/index.d.ts +1 -0
  47. package/build/models/ui/product-detail/index.d.ts +2 -1
  48. package/build/models/ui/product-detail/index.js +1 -1
  49. package/build/models/ui/product-list/index.js +1 -1
  50. package/build/models/ui/raffle-list/index.js +1 -1
  51. package/build/models/ui/validator/form/address.js +1 -1
  52. package/build/pages/404.js +1 -1
  53. package/build/pages/_slug_/index.js +1 -1
  54. package/build/pages/account/addresses.js +1 -1
  55. package/build/pages/account/favorite-products.js +1 -1
  56. package/build/pages/account/forgot-password.js +1 -1
  57. package/build/pages/account/index.js +1 -1
  58. package/build/pages/account/login.js +1 -1
  59. package/build/pages/account/orders/_id_.js +1 -1
  60. package/build/pages/account/orders/index.js +1 -1
  61. package/build/pages/account/raffles.js +1 -1
  62. package/build/pages/account/recover-password.js +1 -1
  63. package/build/pages/account/register.js +1 -1
  64. package/build/pages/blog/_slug_.js +1 -1
  65. package/build/pages/blog/index.js +1 -1
  66. package/build/pages/cart.js +1 -1
  67. package/build/pages/checkout.js +1 -1
  68. package/build/pages/home.js +1 -1
  69. package/build/pages/pages/_slug_.js +1 -1
  70. package/build/pages/raffle/_slug_.js +1 -1
  71. package/build/pages/raffle/index.js +1 -1
  72. package/build/pages/search.js +1 -1
  73. package/build/providers/helpers/raffles.js +1 -1
  74. package/build/providers/page-data-get.js +1 -1
  75. package/build/providers/page-data-init.js +1 -1
  76. package/build/providers/page-data-next.js +1 -1
  77. package/build/providers/placeholders.js +1 -1
  78. package/build/providers/prop-value/attribute-list.js +1 -1
  79. package/build/providers/prop-value/attribute.js +1 -1
  80. package/build/providers/prop-value/blog-category-list.js +1 -1
  81. package/build/providers/prop-value/blog-category.js +1 -1
  82. package/build/providers/prop-value/blog-list.js +1 -1
  83. package/build/providers/prop-value/blog.js +1 -1
  84. package/build/providers/prop-value/brand-list.js +1 -1
  85. package/build/providers/prop-value/brand.js +1 -1
  86. package/build/providers/prop-value/category-list.js +1 -1
  87. package/build/providers/prop-value/category.js +1 -1
  88. package/build/providers/prop-value/custom.js +1 -1
  89. package/build/providers/prop-value/image-list.js +1 -1
  90. package/build/providers/prop-value/image.js +1 -1
  91. package/build/providers/prop-value/link.js +1 -1
  92. package/build/providers/prop-value/product-detail.js +1 -1
  93. package/build/providers/prop-value/product-list.js +1 -1
  94. package/build/providers/prop-value/raffle-list.js +1 -1
  95. package/build/providers/prop-value/raffle.js +1 -1
  96. package/build/scripts/generators/types/index.js +1 -1
  97. package/build/store/base.js +1 -1
  98. package/build/store/cart.js +1 -1
  99. package/build/store/customer.js +1 -1
  100. package/package.json +1 -1
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as i}from"mobx-react-lite";import{useRouter as r}from"next/router.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"mobx";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as a}from"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductDetail as s}from"../../models/ui/product-detail/index.js";import"../../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/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/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{IkasThemeSettings as n}from"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{Analytics as d}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasPageDataInit as m}from"../../providers/page-data-init.js";import{ThemeComponent as p}from"./ThemeComponent.js";import{IkasPageHead as l}from"./head.js";import{IkasStorefrontConfig as u}from"../../storefront/index.js";import{initIkasEvents as c}from"../../analytics/events.js";var f=i((function(i){var p=i.propValuesStr,f=i.pageType,x=i.pageTitle,g=i.pageDescription,v=i.pageSpecificDataStr,h=i.settingsStr,S=i.merchantSettingsStr,w=i.configJson,y=i.reInitOnBrowser,b=i.addOgpMetas,C=i.components,E=r();u.initWithJson(w,E),u.currentPageComponents=C;var O=u.store;O.currentPageType=f;var T=o.useState(!1),V=T[0],D=T[1],P=o.useState(new n(JSON.parse(h)))[0],J=o.useMemo((function(){return m.setPageSpecificData(v,f,V),m.initPropValues(p,E,h,!0,V)}),[V,p,f,h,v]);o.useEffect((function(){y&&D("undefined"!=typeof window),O.cartStore.getCart(),O.checkLocalization(),c()}),[]),o.useEffect((function(){var e=function(){u.store.customerStore.routeChangeInit()};return E.events.on("routeChangeStart",e),function(){E.events.off("routeChangeStart",e)}}),[]),o.useEffect((function(){!function(o,i,r){e(this,void 0,void 0,(function(){var e,n,p,l,c;return t(this,(function(t){switch(t.label){case 0:d.pageView(o),t.label=1;case 1:return t.trys.push([1,4,,5]),o===a.PRODUCT&&(e=JSON.parse(i),n=new s(e.product,e.selectedVariantValues),"undefined"!=typeof window&&m._initProductDetailOnBrowser(n),d.productView(n),u.store.customerStore.onProductView(n.product.id,n.selectedVariant.id)),o===a.CATEGORY&&(p=JSON.parse(i),l=p.path.map((function(e){return e.name})).join(" > "),l=p.path.length>0?l+" > "+p.name:p.name,d.viewCategory(l,p)),o!==a.CART?[3,3]:[4,r.cartStore.waitUntilInitialized()];case 2:t.sent(),d.viewCart(r.cartStore.cart),t.label=3;case 3:return[3,5];case 4:return c=t.sent(),console.error(c),[3,5];case 5:return[2]}}))}))}(f,v,O)}),[f,v,J]);var k=o.useMemo((function(){var e=J.find((function(e){return e.component.isHeader})),t=J.find((function(e){return e.component.isFooter})),i=J.filter((function(e){return!e.component.isHeader&&!e.component.isFooter}))||[];return o.createElement("div",{style:{position:"relative",minHeight:"100vh",display:"flex",flexDirection:"column",justifyContent:"space-between"}},o.createElement("div",null,e&&j(e,P,-1),i.map((function(e,t){return j(e,P,t)}))),t&&j(t,P,-1))}),[J,P]);return o.createElement(o.Fragment,null,o.createElement(l,{pageType:f,pageTitle:x,pageDescription:g,pageSpecificDataStr:v,merchantSettingsStr:S,addOgpMetas:b}),k)})),j=function(e,t,i){return o.createElement(p,{key:e.pageComponent.id,index:i,pageComponentPropValue:e,settings:t})};export{f as IkasPage,j as renderComponent};
1
+ import{__awaiter as e,__generator as t}from'../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as i}from"mobx-react-lite";import{useRouter as r}from"next/router.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"mobx";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as a}from"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductDetail as s}from"../../models/ui/product-detail/index.js";import"../../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/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{IkasThemeSettings as n}from"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{Analytics as m}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasPageDataInit as d}from"../../providers/page-data-init.js";import{ThemeComponent as p}from"./ThemeComponent.js";import{IkasPageHead as l}from"./head.js";import{IkasStorefrontConfig as u}from"../../storefront/index.js";import{initIkasEvents as c}from"../../analytics/events.js";var f=i((function(i){var p=i.propValuesStr,f=i.pageType,x=i.pageTitle,g=i.pageDescription,v=i.pageSpecificDataStr,h=i.settingsStr,S=i.merchantSettingsStr,w=i.configJson,y=i.reInitOnBrowser,b=i.addOgpMetas,C=i.components,E=r();u.initWithJson(w,E),u.currentPageComponents=C;var O=u.store;O.currentPageType=f;var T=o.useState(!1),V=T[0],D=T[1],P=o.useState(new n(JSON.parse(h)))[0],J=o.useMemo((function(){return d.setPageSpecificData(v,f,V),d.initPropValues(p,E,h,!0,V)}),[V,p,f,h,v]);o.useEffect((function(){y&&D("undefined"!=typeof window),O.cartStore.getCart(),O.checkLocalization(),c()}),[]),o.useEffect((function(){var e=function(){u.store.customerStore.routeChangeInit()};return E.events.on("routeChangeStart",e),function(){E.events.off("routeChangeStart",e)}}),[]),o.useEffect((function(){!function(o,i,r){e(this,void 0,void 0,(function(){var e,n,p,l,c;return t(this,(function(t){switch(t.label){case 0:m.pageView(o),t.label=1;case 1:return t.trys.push([1,4,,5]),o===a.PRODUCT&&(e=JSON.parse(i),n=new s(e.product,e.selectedVariantValues),"undefined"!=typeof window&&d._initProductDetailOnBrowser(n),m.productView(n),u.store.customerStore.onProductView(n.product.id,n.selectedVariant.id)),o===a.CATEGORY&&(p=JSON.parse(i),l=p.path.map((function(e){return e.name})).join(" > "),l=p.path.length>0?l+" > "+p.name:p.name,m.viewCategory(l,p)),o!==a.CART?[3,3]:[4,r.cartStore.waitUntilInitialized()];case 2:t.sent(),m.viewCart(r.cartStore.cart),t.label=3;case 3:return[3,5];case 4:return c=t.sent(),console.error(c),[3,5];case 5:return[2]}}))}))}(f,v,O)}),[f,v,J]);var k=o.useMemo((function(){var e=J.find((function(e){return e.component.isHeader})),t=J.find((function(e){return e.component.isFooter})),i=J.filter((function(e){return!e.component.isHeader&&!e.component.isFooter}))||[];return o.createElement("div",{style:{position:"relative",minHeight:"100vh",display:"flex",flexDirection:"column",justifyContent:"space-between"}},o.createElement("div",null,e&&j(e,P,-1),i.map((function(e,t){return j(e,P,t)}))),t&&j(t,P,-1))}),[J,P]);return o.createElement(o.Fragment,null,o.createElement(l,{pageType:f,pageTitle:x,pageDescription:g,pageSpecificDataStr:v,merchantSettingsStr:S,addOgpMetas:b}),k)})),j=function(e,t,i){return o.createElement(p,{key:e.pageComponent.id,index:i,pageComponentPropValue:e,settings:t})};export{f as IkasPage,j as renderComponent};
@@ -1 +1 @@
1
- import{__extends as e,__assign as o}from'../../ext/tslib/tslib.es6.js';import*as t from"react";import r from"./error/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import{IkasCheckout as i}from"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import{IkasOrderLineItem as n}from"../../models/data/order/line-item/index.js";import{makeObservable as a,computed as p}from"mobx";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as s}from"../../models/theme/page/index.js";import{IkasThemeComponentPropType as m}from"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../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/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/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"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{IkasStorefrontConfig as d}from"../../storefront/index.js";import{IkasCheckoutSettings as l}from"../../models/data/checkout-settings/index.js";import u from"../checkout/index.js";import{IkasCart as c}from"../../models/data/cart/index.js";import{IkasPageDataInit as f}from"../../providers/page-data-init.js";import{Observer as v}from"mobx-react-lite";var j=function(j){function g(e){var o=j.call(this,e)||this;return o.state={hasError:!1},o.onMouseEnter=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onMouseOver(r.id)},o.onMouseLeave=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onMouseLeave(r.id)},o.onClick=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onClick(r.id)},o.ref=t.createRef(),a(o,{pageComponentPropValue:p,propValues:p,isSelected:p,isHovered:p,hasNullValue:p,rendered:p,Component:p}),o}return e(g,j),g.prototype.componentDidMount=function(){var e=this.props,o=e.vm,t=e.pageComponent;o.setComponentRef(this.ref.current,t)},g.prototype.componentDidUpdate=function(){var e=this.props,o=e.vm,t=e.pageComponent;o.setComponentRef(this.ref.current,t)},g.getDerivedStateFromError=function(e){return console.error(e),{hasError:!0}},Object.defineProperty(g.prototype,"pageComponentPropValue",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.pageDataProvider.pageComponentPropValues.find((function(e){return e.pageComponent.id===t.id}))},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"propValues",{get:function(){var e,t,r=this.props.vm,a=null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.propValues;(null===(t=r.page)||void 0===t?void 0:t.type)===s.CHECKOUT&&(a={checkout:new i({cart:new c({items:[new n({currencyCode:"TRY",finalPrice:100,finalPriceWithQuantity:100,price:100,priceWithQuantity:100,quantity:1})]})}),checkoutSettings:new l,merchantSettings:null,customizationProps:o({},a),returnPolicy:"",privacyPolicy:"",termsOfService:""});return a},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"isSelected",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.selectedPageComponentId===t.id},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"isHovered",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.hoveredPageComponentId===t.id},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"hasNullValue",{get:function(){var e,o=this;return!!(null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.component.props.some((function(e){var t;if(e.isRequired){var r=(o.propValues||{})[e.name],i=null===(t=o.pageComponentPropValue)||void 0===t?void 0:t.component.props.find((function(o){return o.id===e.requiredPropId}));if(i){var n=(o.propValues||{})[i.name];if(i.type===m.BOOLEAN&&!n||i.type===m.CUSTOM&&n!==e.requiredEnumOptionValue)return!1}return null===r||null==r}})))},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"rendered",{get:function(){var e,i,n=this.Component,a=this.props.vm,p=d.store;return this.hasNullValue||this.state.hasError?t.createElement(r,{name:null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.component.displayName}):t.createElement(n,o({},this.propValues,{store:p,settings:null===(i=a.theme)||void 0===i?void 0:i.settings,pageSpecificData:f.pageSpecificData}))},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"Component",{get:function(){var e,o=this.props,t=o.vm,r=o.pageComponent,i=d.currentPageComponents;if(!i)return null;var n=i[r.componentId];return(null===(e=t.page)||void 0===e?void 0:e.type)===s.CHECKOUT&&(n=u),n},enumerable:!1,configurable:!0}),g.prototype.render=function(){var e=this;return t.createElement(v,null,(function(){var o;return e.state.hasError?t.createElement("div",{ref:e.ref,style:{position:"relative"},onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,onClick:e.onClick},t.createElement(r,{name:null===(o=e.pageComponentPropValue)||void 0===o?void 0:o.component.displayName}),";"):d.currentPageComponents?t.createElement("div",{ref:e.ref,style:{position:"relative"},onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave},e.rendered):(console.error("Components for the page not found."),null)}))},g}(t.Component);export{j as ThemeEditorComponent};
1
+ import{__extends as e,__assign as o}from'../../ext/tslib/tslib.es6.js';import*as t from"react";import r from"./error/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import{IkasCheckout as i}from"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import{makeObservable as n,computed as a}from"mobx";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import{IkasOrderLineItem as s}from"../../models/data/order/line-item/index.js";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as p}from"../../models/theme/page/index.js";import{IkasThemeComponentPropType as m}from"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../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/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"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{IkasStorefrontConfig as d}from"../../storefront/index.js";import{IkasCheckoutSettings as l}from"../../models/data/checkout-settings/index.js";import u from"../checkout/index.js";import{IkasCart as c}from"../../models/data/cart/index.js";import{IkasPageDataInit as f}from"../../providers/page-data-init.js";import{Observer as v}from"mobx-react-lite";var j=function(j){function g(e){var o=j.call(this,e)||this;return o.state={hasError:!1},o.onMouseEnter=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onMouseOver(r.id)},o.onMouseLeave=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onMouseLeave(r.id)},o.onClick=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onClick(r.id)},o.ref=t.createRef(),n(o,{pageComponentPropValue:a,propValues:a,isSelected:a,isHovered:a,hasNullValue:a,rendered:a,Component:a}),o}return e(g,j),g.prototype.componentDidMount=function(){var e=this.props,o=e.vm,t=e.pageComponent;o.setComponentRef(this.ref.current,t)},g.prototype.componentDidUpdate=function(){var e=this.props,o=e.vm,t=e.pageComponent;o.setComponentRef(this.ref.current,t)},g.getDerivedStateFromError=function(e){return console.error(e),{hasError:!0}},Object.defineProperty(g.prototype,"pageComponentPropValue",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.pageDataProvider.pageComponentPropValues.find((function(e){return e.pageComponent.id===t.id}))},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"propValues",{get:function(){var e,t,r=this.props.vm,n=null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.propValues;(null===(t=r.page)||void 0===t?void 0:t.type)===p.CHECKOUT&&(n={checkout:new i({cart:new c({items:[new s({currencyCode:"TRY",finalPrice:100,finalPriceWithQuantity:100,price:100,priceWithQuantity:100,quantity:1})]})}),checkoutSettings:new l,merchantSettings:null,customizationProps:o({},n),returnPolicy:"",privacyPolicy:"",termsOfService:""});return n},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"isSelected",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.selectedPageComponentId===t.id},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"isHovered",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.hoveredPageComponentId===t.id},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"hasNullValue",{get:function(){var e,o=this;return!!(null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.component.props.some((function(e){var t;if(e.isRequired){var r=(o.propValues||{})[e.name],i=null===(t=o.pageComponentPropValue)||void 0===t?void 0:t.component.props.find((function(o){return o.id===e.requiredPropId}));if(i){var n=(o.propValues||{})[i.name];if(i.type===m.BOOLEAN&&!n||i.type===m.CUSTOM&&n!==e.requiredEnumOptionValue)return!1}return null===r||null==r}})))},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"rendered",{get:function(){var e,i,n=this.Component,a=this.props.vm,s=d.store;return this.hasNullValue||this.state.hasError?t.createElement(r,{name:null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.component.displayName}):t.createElement(n,o({},this.propValues,{store:s,settings:null===(i=a.theme)||void 0===i?void 0:i.settings,pageSpecificData:f.pageSpecificData}))},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"Component",{get:function(){var e,o=this.props,t=o.vm,r=o.pageComponent,i=d.currentPageComponents;if(!i)return null;var n=i[r.componentId];return(null===(e=t.page)||void 0===e?void 0:e.type)===p.CHECKOUT&&(n=u),n},enumerable:!1,configurable:!0}),g.prototype.render=function(){var e=this;return t.createElement(v,null,(function(){var o;return e.state.hasError?t.createElement("div",{ref:e.ref,style:{position:"relative"},onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,onClick:e.onClick},t.createElement(r,{name:null===(o=e.pageComponentPropValue)||void 0===o?void 0:o.component.displayName}),";"):d.currentPageComponents?t.createElement("div",{ref:e.ref,style:{position:"relative"},onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave},e.rendered):(console.error("Components for the page not found."),null)}))},g}(t.Component);export{j as ThemeEditorComponent};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'../../ext/tslib/tslib.es6.js';import{reaction as i,makeAutoObservable as n,runInAction as o}from"mobx";import{IkasBlogMetadataTargetType as a}from"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import{IkasHTMLMetaDataTargetType as r}from"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import{IkasTheme as s}from"../../models/theme/theme.js";import{IkasThemePageType as d}from"../../models/theme/page/index.js";import{IkasThemePageComponent as p}from"../../models/theme/page/component/index.js";import{IkasThemeComponent as u}from"../../models/theme/component/index.js";import{IkasThemeComponentPropType as c}from"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../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/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/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{IkasThemeSettings as l}from"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{IkasPageDataProvider as m}from"../../providers/page-data-get.js";import{IkasPageDataInit as h}from"../../providers/page-data-init.js";import{IkasBlogAPI as g}from"../../api/blog/index.js";import"../../api/brand/index.js";import"../../api/cart/index.js";import"../../api/category/index.js";import"../../api/checkout/index.js";import"../../api/city/index.js";import"../../api/country/index.js";import"../../api/customer/index.js";import"../../api/customer-review/index.js";import"../../api/district/index.js";import{IkasHTMLMetaDataAPI as f}from"../../api/html-meta-data/index.js";import"../../api/merchant/index.js";import{IkasProductSearchAPI as E}from"../../api/product-search/index.js";import{apollo as P}from"../../api/apollo.js";import"../../api/favorite-product/index.js";import"../../api/contact-form/index.js";import"../../api/state/index.js";import"../../api/product-option-set/index.js";import{IkasRaffleAPI as O}from"../../api/raffle/index.js";import"../../api/back-in-stock-reminder/index.js";import"../../api/product-campaign/index.js";import{IkasStorefrontConfig as v}from"../../storefront/index.js";import{IkasStorefront as T}from"../../models/data/storefront/index.js";import C from'../../ext/uuid/dist/esm-browser/v4.js';var _,D=function(){function D(i){var E=this;this.theme=null,this.page=null,this.selectedPageComponentId=null,this.hoveredPageComponentId=null,this.componentRefs={},this.isLoading=!1,this.updateId="",this.locale="en",this.pageParams={},this.apiKey=null,this.pageDataProvider=null,this.startMessaging=function(){window.addEventListener("message",E.onMessage,!1),E.sendMessage(_.FRAME_DID_LOAD,"2.0.20"),E.createLoadingListener()},this.onMessage=function(i){return e(E,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:switch(e=i.data.type,n=i.data.data,e){case _.UPDATE_FRAME_DATA:return[3,1];case _.UPDATE_THEME_JSON:return[3,3];case _.UPDATE_PROP_VALUE:return[3,5];case _.UPDATE_PAGE_PARAMS:return[3,7];case _.UPDATE_PAGE_COMPONENT_ORDER:return[3,9];case _.ADD_COMPONENT:return[3,11];case _.DELETE_COMPONENT:return[3,12];case _.UPDATE_COMPONENT:return[3,13];case _.ADD_PAGE_COMPONENT:return[3,14];case _.DELETE_PAGE_COMPONENT:return[3,16];case _.SET_SELECTED_COMPONENT:return[3,17];case _.SET_HOVERED_COMPONENT:return[3,18];case _.SCROLL_TO_COMPONENT:return[3,19];case _.EDITOR_RELOAD:return[3,20];case _.UPDATE_THEME_SETTINGS:return[3,21]}return[3,22];case 1:return[4,this.handleUpdateFrameData(n)];case 2:case 4:case 6:case 8:case 10:case 15:return t.sent(),[3,23];case 3:return[4,this.handleUpdateThemeJson(n)];case 5:return[4,this.handleUpdatePropValue(n)];case 7:return[4,this.handleUpdatePageParams(n)];case 9:return[4,this.handleUpdatePageComponentOrder(n)];case 11:return this.handleAddNewComponent(n),[3,23];case 12:return this.handleDeleteComponent(n),[3,23];case 13:return this.handleUpdateComponent(n),[3,23];case 14:return[4,this.handleAddNewPageComponent(n)];case 16:return this.handleDeletePageComponent(n),[3,23];case 17:return this.handleSetSelectedComponent(n),[3,23];case 18:return this.handleSetHoveredComponent(n),[3,23];case 19:return this.handleScrollToComponent(n),[3,23];case 20:return this.handleEditorReload(),[3,23];case 21:return this.updateThemeSettings(n),[3,23];case 22:return[3,23];case 23:return[2]}}))}))},this.onClick=function(e){E.sendMessage(_.COMPONENT_CLICK,{componentId:e})},this.onMouseOver=function(e){E.sendMessage(_.COMPONENT_MOUSE_OVER,{componentId:e})},this.onMouseLeave=function(e){E.sendMessage(_.COMPONENT_MOUSE_LEAVE,{componentId:e})},this.onPageChange=function(i){return e(E,void 0,void 0,(function(){var e,n,s,p,u,c,l,m,h,E=this;return t(this,(function(t){switch(t.label){case 0:return e=i.slice(1),n=e.split("?"),e=n[0],s=n[1],this.pageParams={},i.startsWith("/account/orders/")?p=d.ORDER_DETAIL:i.startsWith("/account/orders")?p=d.ORDERS:i.startsWith("/account/addresses")?p=d.ADDRESSES:i.startsWith("/account/favorite-products")?p=d.FAVORITE_PRODUCTS:i.startsWith("/account/forgot-password")?p=d.FORGOT_PASSWORD:i.startsWith("/account/login")?p=d.LOGIN:i.startsWith("/account/raffles")?p=d.RAFFLE_ACCOUNT:i.startsWith("/account/recover-password")?p=d.RECOVER_PASSWORD:i.startsWith("/account/register")?p=d.REGISTER:i.startsWith("/account")?p=d.ACCOUNT:i.startsWith("/blog/")?p=d.BLOG:i.startsWith("/blog")?p=d.BLOG_INDEX:i.startsWith("/pages")?(p=d.CUSTOM,this.pageParams={slug:e.split("/")[1]}):p=i.startsWith("/raffle/")?d.RAFFLE_DETAIL:i.startsWith("/raffle")?d.RAFFLE:i.startsWith("/404")?d.NOT_FOUND:i.startsWith("/cart")?d.CART:i.startsWith("/checkout")?d.CHECKOUT:"/"===i?d.INDEX:i.startsWith("/search")?d.SEARCH:d.PRODUCT,p!==d.PRODUCT?[3,6]:[4,f.listHTMLMetaData(e)];case 1:return(c=t.sent()).length?(l=c[0]).targetType!==r.PRODUCT?[3,3]:[4,this.getVariantIdFromParams(l.targetId,s)]:[3,5];case 2:return u=t.sent(),this.pageParams={productId:l.targetId,variantId:u,slug:e},[3,4];case 3:if(l.targetType===r.CATEGORY)p=d.CATEGORY,this.pageParams={categoryId:l.targetId,slug:e};else{if(l.targetType!==r.BRAND)return[2];p=d.BRAND,this.pageParams={brandId:l.targetId,slug:e}}t.label=4;case 4:return[3,6];case 5:return[2];case 6:return p!==d.BLOG?[3,8]:[4,g.listBlogMetaData(e)];case 7:if(!(c=t.sent()).length)return[2];if((l=c[0]).targetType===a.BLOG)this.pageParams={blogId:l.targetId,slug:e};else{if(l.targetType!==a.BLOG_CATEGORY)return[2];p=d.BLOG_CATEGORY,this.pageParams={blogCategoryId:l.targetId,slug:e}}t.label=8;case 8:return p!==d.RAFFLE_DETAIL?[3,10]:[4,O.listRaffleMetaData(e)];case 9:if(!(c=t.sent()).length)return[2];l=c[0],this.pageParams={raffleId:l.targetId,slug:e},t.label=10;case 10:return this.isLoading=!0,[4,this.getPagePropValues(this.theme,p,this.pageParams)];case 11:return m=t.sent(),o((function(){var e,t;v.store.currentPageType=p,E.pageDataProvider=m,p===d.CUSTOM?E.page=null===(e=E.theme)||void 0===e?void 0:e.pages.find((function(e){return e.type===p&&e.slug===E.pageParams.slug})):E.page=null===(t=E.theme)||void 0===t?void 0:t.pages.find((function(e){return e.type===p})),requestAnimationFrame((function(){document.body.scrollTop=0,document.scrollingElement&&(document.scrollingElement.scrollTop=0)}))})),this.sendMessage(_.EDITOR_PAGE_CHANGE,{pageType:p,pageParams:this.pageParams,pageSpecificData:(null===(h=this.pageDataProvider)||void 0===h?void 0:h.pageSpecificData)||null}),this.isLoading=!1,[2]}}))}))},this.onLoadingChange=function(){E.sendMessage(_.EDITOR_LOADING_CHANGE,{isLoading:E.isLoading})},this.sendMessage=function(e,t){window.parent.postMessage({type:e,data:JSON.parse(JSON.stringify(t))},"*")},this.getPagePropValues=function(i,n,o){return e(E,void 0,void 0,(function(){var e,a,r;return t(this,(function(t){switch(t.label){case 0:return e=new m(i,o,n),(o.blogId||o.blogCategoryId)&&(e.possiblePageTypes=[d.BLOG,d.BLOG_CATEGORY]),o.raffleId&&(e.possiblePageTypes=[d.RAFFLE_DETAIL]),[4,e.getPageData()];case 1:return t.sent(),e.pageSpecificData?(h.setPageSpecificData(JSON.stringify(e.pageSpecificData),n,!0),n===d.PRODUCT&&h.pageSpecificData&&(a=h.pageSpecificData,(r=a.product.variants.find((function(e){return e.id===o.variantId})))&&(a.selectedVariantValues=r.variantValues))):h.pageSpecificData=void 0,e.pageComponentPropValues=h.initPropValues(JSON.stringify(e.pageComponentPropValues),this.router,JSON.stringify(i.settings),!1),[2,e]}}))}))},this.setComponentRef=function(e,t){E.componentRefs[t.id]=e},this.isScrolledIntoView=function(e){var t=e.getBoundingClientRect(),i=t.top,n=t.bottom;return i<window.innerHeight&&n>=0&&n<window.innerHeight&&i>0},this.handleUpdateFrameData=function(i){return e(E,void 0,void 0,(function(){var e,n,o,a,r,d=this;return t(this,(function(t){switch(t.label){case 0:return this.theme=new s(i.theme),this.page=this.theme.pages.find((function(e){return e.id===i.selectedPage.id})),this.pageParams=i.pageParams,this.apiKey=i.apiKey,this.locale=i.locale||"en",this.translations=i.translations||void 0,this.page?((e=i.storefront)&&(n=new T(e),o=n.routings.find((function(e){return e.locale===d.locale})),v.storefrontId=n.id,v.storefrontRoutingId=null==o?void 0:o.id,n.mainStorefrontThemeId&&(v.storefrontThemeId=n.mainStorefrontThemeId),n.salesChannelId&&(v.salesChannelId=n.salesChannelId),(null==o?void 0:o.priceListId)?v.priceListId=o.priceListId:v.priceListId=void 0,v.routings=n.routings,v.stockPreference=this.theme.settings.stockPreference),this.translations&&(v.translations=this.translations),v.isEditor=!0,P.createApolloClient(this.apiKey||void 0),window.editorApiKey=i.apiKey,a=C(),this.updateId=a,this.isLoading=!0,[4,this.getPagePropValues(this.theme,this.page.type,this.pageParams||{})]):[2];case 1:return r=t.sent(),this.updateId===a&&(this.pageDataProvider=r,this.isLoading=!1),[2]}}))}))},this.handleUpdateThemeJson=function(i){return e(E,void 0,void 0,(function(){return t(this,(function(e){return this.theme=new s(i.theme),[2]}))}))},this.handleUpdatePropValue=function(i){return e(E,void 0,void 0,(function(){var e,n,a,r,s,d,p,u,l=this;return t(this,(function(t){switch(t.label){case 0:return e=i.propName,n=i.value,(a=null===(p=null===(d=this.selectedComponent)||void 0===d?void 0:d.props)||void 0===p?void 0:p.find((function(t){return t.name===e})))&&this.selectedPageComponent?(r=null===(u=this.pageDataProvider)||void 0===u?void 0:u.pageComponentPropValues.find((function(e){return e.pageComponent.id===l.selectedPageComponentId})),this.selectedPageComponent.propValues[e]=n,this.pageDataProvider?[4,this.pageDataProvider.getPageComponentPropValue(this.selectedPageComponent,a)]:[2]):[2];case 1:return s=t.sent(),[4,this.pageDataProvider.setLinkSlugs()];case 2:return t.sent(),o((function(){r&&(r.propValues[e]=s,a.type===c.CUSTOM?h.initCustomDataPropValue(a,s,r,l.router,l.theme.settings,!0):a.type===c.COMPONENT?h.initComponentPropValue(a,s,r,l.router,l.theme.settings,!0):a.type===c.COMPONENT_LIST?h.initComponentListPropValue(a,s,r,l.router,l.theme.settings,!0):a.type===c.PRODUCT_DETAIL?h.initProductDetailPropValue(a,s,r,l.router):a.type===c.CATEGORY?h.initCategoryPropValue(a,s,r):a.type===c.BRAND?h.initBrandPropValue(a,s,r):a.type===c.BLOG?h.initBlogPropValue(a,s,r):a.type===c.BLOG_CATEGORY?h.initBlogCategoryPropValue(a,s,r):a.type===c.RAFFLE?h.initRafflePropValue(a,s,r):a.type!==c.LINK&&a.type!==c.LIST_OF_LINK||h.initLinkPropValue(a,s,r))})),[2]}}))}))},this.handleUpdatePageParams=function(i){return e(E,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageParams=i.pageParams,this.isLoading=!0,[4,this.getPagePropValues(this.theme,this.page.type,this.pageParams||{})];case 1:return e=t.sent(),this.pageDataProvider=e,this.isLoading=!1,[2]}}))}))},this.handleUpdatePageComponentOrder=function(i){return e(E,void 0,void 0,(function(){return t(this,(function(e){return this.specification?this.specification.components=i.pageComponents.map((function(e){return new p(e)})):this.page.components=i.pageComponents.map((function(e){return new p(e)})),[2]}))}))},this.handleAddNewComponent=function(e){var t,i=new u(e.component);null===(t=E.theme)||void 0===t||t.components.push(i)},this.handleDeleteComponent=function(e){var t,i;(null===(t=E.theme)||void 0===t?void 0:t.components)&&(E.theme.components=E.theme.components.filter((function(t){return t.id!==e.componentId})));var n=E.pageComponents.filter((function(t){return t.componentId!==e.componentId}))||[];E.specification&&E.specification.components&&(E.specification.components=n),!E.specification&&(null===(i=E.page)||void 0===i?void 0:i.components)&&(E.page.components=n)},this.handleUpdateComponent=function(e){var t=E.theme.components.findIndex((function(t){return t.id===e.component.id}));-1!==t&&(E.theme.components[t]=new u(e.component))},this.handleAddNewPageComponent=function(i){return e(E,void 0,void 0,(function(){var e,n,a=this;return t(this,(function(t){switch(t.label){case 0:return e=new p(i.pageComponent),this.pageComponents.some((function(t){return t.id===e.id}))?[2]:[4,this.pageDataProvider.getPageComponentPropValues(e)];case 1:return n=t.sent(),o((function(){n.component.props.filter((function(e){return e.type===c.CUSTOM})).forEach((function(e){h.initCustomDataPropValue(e,n.propValues[e.name],n,a.router,a.theme.settings,!0)})),a.pageDataProvider.pageComponentPropValues.push(n),a.pageComponents.push(e)})),[2]}}))}))},this.handleDeletePageComponent=function(e){E.specification?E.specification.components=E.pageComponents.filter((function(t){return t.id!==e.pageComponentId})):E.page.components=E.pageComponents.filter((function(t){return t.id!==e.pageComponentId}))},this.handleSetSelectedComponent=function(e){E.selectedPageComponentId=e.componentId},this.handleSetHoveredComponent=function(e){E.hoveredPageComponentId=e.componentId},this.handleScrollToComponent=function(e){var t=e.componentId,i=E.componentRefs[t];i&&(E.isScrolledIntoView(i)||window.scrollTo({top:i.offsetTop,behavior:"smooth"}))},this.handleEditorReload=function(){window.location.reload()},this.updateThemeSettings=function(e){var t=e.settings;E.theme&&(E.theme.settings=new l(t))},this.router=i,n(this),this.startMessaging()}return Object.defineProperty(D.prototype,"specification",{get:function(){var e,t,i,n,o,a,r,s=this,p=this.page;return(null==p?void 0:p.type)===d.PRODUCT&&(r=null===(e=p.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=s.pageParams)||void 0===t?void 0:t.productId)}))),(null==p?void 0:p.type)===d.CATEGORY&&(r=null===(t=p.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=s.pageParams)||void 0===t?void 0:t.categoryId)}))),(null==p?void 0:p.type)===d.BRAND&&(r=null===(i=p.specifications)||void 0===i?void 0:i.find((function(e){var t;return e.id===(null===(t=s.pageParams)||void 0===t?void 0:t.brandId)}))),(null==p?void 0:p.type)===d.BLOG&&(r=null===(n=p.specifications)||void 0===n?void 0:n.find((function(e){var t;return e.id===(null===(t=s.pageParams)||void 0===t?void 0:t.blogId)}))),(null==p?void 0:p.type)===d.BLOG_CATEGORY&&(r=null===(o=p.specifications)||void 0===o?void 0:o.find((function(e){var t;return e.id===(null===(t=s.pageParams)||void 0===t?void 0:t.blogCategoryId)}))),(null==p?void 0:p.type)===d.RAFFLE_DETAIL&&(r=null===(a=p.specifications)||void 0===a?void 0:a.find((function(e){var t;return e.id===(null===(t=s.pageParams)||void 0===t?void 0:t.raffleId)}))),r},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"selectedPageComponent",{get:function(){var e=this;return this.pageComponents.find((function(t){return t.id===e.selectedPageComponentId}))},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"selectedComponent",{get:function(){var e,t=this;return null===(e=this.theme)||void 0===e?void 0:e.components.find((function(e){var i;return e.id===(null===(i=t.selectedPageComponent)||void 0===i?void 0:i.componentId)}))},enumerable:!1,configurable:!0}),D.prototype.createLoadingListener=function(){var e=this;i((function(){return e.isLoading}),(function(){e.onLoadingChange()}))},D.prototype.getVariantIdFromParams=function(i,n){return e(this,void 0,void 0,(function(){var e,o,a,r,s,d,p;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=new URLSearchParams("?"+n),[4,E.searchProducts({productIdList:[i],priceListId:v.priceListId,salesChannelId:v.salesChannelId})];case 1:return(null==(o=t.sent())?void 0:o.data.length)?(a=o.data[0],r=a.variantTypes.map((function(e){return e.variantType.slug})),s=[],r.forEach((function(t,i){var n=a.variantTypes[i],o=e.get(t);if(o){var r=n.variantType.values.find((function(e){return e.slug===o}));r&&s.push(r)}})),(d=a.variants.find((function(e){return e.variantValues.every((function(e){return s.some((function(t){return t.id===e.id}))}))})))?[2,d.id]:[3,3]):[2];case 2:return p=t.sent(),console.error(p),[3,3];case 3:return[2]}}))}))},D}();!function(e){e.FRAME_DID_LOAD="FRAME_DID_LOAD",e.UPDATE_FRAME_DATA="UPDATE_FRAME_DATA",e.UPDATE_THEME_JSON="UPDATE_THEME_JSON",e.UPDATE_PROP_VALUE="UPDATE_PROP_VALUE",e.UPDATE_PAGE_PARAMS="UPDATE_PAGE_PARAMS",e.UPDATE_PAGE_COMPONENT_ORDER="UPDATE_PAGE_COMPONENT_ORDER",e.ADD_COMPONENT="ADD_COMPONENT",e.DELETE_COMPONENT="DELETE_COMPONENT",e.UPDATE_COMPONENT="UPDATE_COMPONENT",e.ADD_PAGE_COMPONENT="ADD_PAGE_COMPONENT",e.DELETE_PAGE_COMPONENT="DELETE_PAGE_COMPONENT",e.COMPONENT_MOUSE_OVER="COMPONENT_MOUSE_OVER",e.COMPONENT_MOUSE_LEAVE="COMPONENT_MOUSE_LEAVE",e.COMPONENT_CLICK="COMPONENT_CLICK",e.SET_SELECTED_COMPONENT="SET_SELECTED_COMPONENT",e.SET_HOVERED_COMPONENT="SET_HOVERED_COMPONENT",e.SCROLL_TO_COMPONENT="SCROLL_TO_COMPONENT",e.UPDATE_THEME_SETTINGS="UPDATE_THEME_SETTINGS",e.EDITOR_PAGE_CHANGE="EDITOR_PAGE_CHANGE",e.EDITOR_LOADING_CHANGE="EDITOR_LOADING_CHANGE",e.EDITOR_RELOAD="EDITOR_RELOAD"}(_||(_={}));export{_ as BridgeMessageType,D as default};
1
+ import{__awaiter as e,__generator as t}from'../../ext/tslib/tslib.es6.js';import{reaction as i,makeAutoObservable as n,runInAction as o}from"mobx";import{IkasBlogMetadataTargetType as a}from"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import{IkasHTMLMetaDataTargetType as r}from"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import{IkasTheme as s}from"../../models/theme/theme.js";import{IkasThemePageType as d}from"../../models/theme/page/index.js";import{IkasThemePageComponent as p}from"../../models/theme/page/component/index.js";import{IkasThemeComponent as u}from"../../models/theme/component/index.js";import{IkasThemeComponentPropType as c}from"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../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/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{IkasThemeSettings as l}from"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{IkasPageDataProvider as m}from"../../providers/page-data-get.js";import{IkasPageDataInit as h}from"../../providers/page-data-init.js";import{IkasBlogAPI as g}from"../../api/blog/index.js";import"../../api/brand/index.js";import"../../api/cart/index.js";import"../../api/category/index.js";import"../../api/checkout/index.js";import"../../api/city/index.js";import"../../api/country/index.js";import"../../api/customer/index.js";import"../../api/customer-review/index.js";import"../../api/customer-review-summary/index.js";import"../../api/district/index.js";import{IkasHTMLMetaDataAPI as f}from"../../api/html-meta-data/index.js";import"../../api/merchant/index.js";import{IkasProductSearchAPI as E}from"../../api/product-search/index.js";import{apollo as P}from"../../api/apollo.js";import"../../api/favorite-product/index.js";import"../../api/contact-form/index.js";import"../../api/state/index.js";import"../../api/product-option-set/index.js";import{IkasRaffleAPI as O}from"../../api/raffle/index.js";import"../../api/back-in-stock-reminder/index.js";import"../../api/product-campaign/index.js";import{IkasStorefrontConfig as v}from"../../storefront/index.js";import{IkasStorefront as T}from"../../models/data/storefront/index.js";import C from'../../ext/uuid/dist/esm-browser/v4.js';var _,D=function(){function D(i){var E=this;this.theme=null,this.page=null,this.selectedPageComponentId=null,this.hoveredPageComponentId=null,this.componentRefs={},this.isLoading=!1,this.updateId="",this.locale="en",this.pageParams={},this.apiKey=null,this.pageDataProvider=null,this.startMessaging=function(){window.addEventListener("message",E.onMessage,!1),E.sendMessage(_.FRAME_DID_LOAD,"2.0.20"),E.createLoadingListener()},this.onMessage=function(i){return e(E,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:switch(e=i.data.type,n=i.data.data,e){case _.UPDATE_FRAME_DATA:return[3,1];case _.UPDATE_THEME_JSON:return[3,3];case _.UPDATE_PROP_VALUE:return[3,5];case _.UPDATE_PAGE_PARAMS:return[3,7];case _.UPDATE_PAGE_COMPONENT_ORDER:return[3,9];case _.ADD_COMPONENT:return[3,11];case _.DELETE_COMPONENT:return[3,12];case _.UPDATE_COMPONENT:return[3,13];case _.ADD_PAGE_COMPONENT:return[3,14];case _.DELETE_PAGE_COMPONENT:return[3,16];case _.SET_SELECTED_COMPONENT:return[3,17];case _.SET_HOVERED_COMPONENT:return[3,18];case _.SCROLL_TO_COMPONENT:return[3,19];case _.EDITOR_RELOAD:return[3,20];case _.UPDATE_THEME_SETTINGS:return[3,21]}return[3,22];case 1:return[4,this.handleUpdateFrameData(n)];case 2:case 4:case 6:case 8:case 10:case 15:return t.sent(),[3,23];case 3:return[4,this.handleUpdateThemeJson(n)];case 5:return[4,this.handleUpdatePropValue(n)];case 7:return[4,this.handleUpdatePageParams(n)];case 9:return[4,this.handleUpdatePageComponentOrder(n)];case 11:return this.handleAddNewComponent(n),[3,23];case 12:return this.handleDeleteComponent(n),[3,23];case 13:return this.handleUpdateComponent(n),[3,23];case 14:return[4,this.handleAddNewPageComponent(n)];case 16:return this.handleDeletePageComponent(n),[3,23];case 17:return this.handleSetSelectedComponent(n),[3,23];case 18:return this.handleSetHoveredComponent(n),[3,23];case 19:return this.handleScrollToComponent(n),[3,23];case 20:return this.handleEditorReload(),[3,23];case 21:return this.updateThemeSettings(n),[3,23];case 22:return[3,23];case 23:return[2]}}))}))},this.onClick=function(e){E.sendMessage(_.COMPONENT_CLICK,{componentId:e})},this.onMouseOver=function(e){E.sendMessage(_.COMPONENT_MOUSE_OVER,{componentId:e})},this.onMouseLeave=function(e){E.sendMessage(_.COMPONENT_MOUSE_LEAVE,{componentId:e})},this.onPageChange=function(i){return e(E,void 0,void 0,(function(){var e,n,s,p,u,c,l,m,h,E=this;return t(this,(function(t){switch(t.label){case 0:return e=i.slice(1),n=e.split("?"),e=n[0],s=n[1],this.pageParams={},i.startsWith("/account/orders/")?p=d.ORDER_DETAIL:i.startsWith("/account/orders")?p=d.ORDERS:i.startsWith("/account/addresses")?p=d.ADDRESSES:i.startsWith("/account/favorite-products")?p=d.FAVORITE_PRODUCTS:i.startsWith("/account/forgot-password")?p=d.FORGOT_PASSWORD:i.startsWith("/account/login")?p=d.LOGIN:i.startsWith("/account/raffles")?p=d.RAFFLE_ACCOUNT:i.startsWith("/account/recover-password")?p=d.RECOVER_PASSWORD:i.startsWith("/account/register")?p=d.REGISTER:i.startsWith("/account")?p=d.ACCOUNT:i.startsWith("/blog/")?p=d.BLOG:i.startsWith("/blog")?p=d.BLOG_INDEX:i.startsWith("/pages")?(p=d.CUSTOM,this.pageParams={slug:e.split("/")[1]}):p=i.startsWith("/raffle/")?d.RAFFLE_DETAIL:i.startsWith("/raffle")?d.RAFFLE:i.startsWith("/404")?d.NOT_FOUND:i.startsWith("/cart")?d.CART:i.startsWith("/checkout")?d.CHECKOUT:"/"===i?d.INDEX:i.startsWith("/search")?d.SEARCH:d.PRODUCT,p!==d.PRODUCT?[3,6]:[4,f.listHTMLMetaData(e)];case 1:return(c=t.sent()).length?(l=c[0]).targetType!==r.PRODUCT?[3,3]:[4,this.getVariantIdFromParams(l.targetId,s)]:[3,5];case 2:return u=t.sent(),this.pageParams={productId:l.targetId,variantId:u,slug:e},[3,4];case 3:if(l.targetType===r.CATEGORY)p=d.CATEGORY,this.pageParams={categoryId:l.targetId,slug:e};else{if(l.targetType!==r.BRAND)return[2];p=d.BRAND,this.pageParams={brandId:l.targetId,slug:e}}t.label=4;case 4:return[3,6];case 5:return[2];case 6:return p!==d.BLOG?[3,8]:[4,g.listBlogMetaData(e)];case 7:if(!(c=t.sent()).length)return[2];if((l=c[0]).targetType===a.BLOG)this.pageParams={blogId:l.targetId,slug:e};else{if(l.targetType!==a.BLOG_CATEGORY)return[2];p=d.BLOG_CATEGORY,this.pageParams={blogCategoryId:l.targetId,slug:e}}t.label=8;case 8:return p!==d.RAFFLE_DETAIL?[3,10]:[4,O.listRaffleMetaData(e)];case 9:if(!(c=t.sent()).length)return[2];l=c[0],this.pageParams={raffleId:l.targetId,slug:e},t.label=10;case 10:return this.isLoading=!0,[4,this.getPagePropValues(this.theme,p,this.pageParams)];case 11:return m=t.sent(),o((function(){var e,t;v.store.currentPageType=p,E.pageDataProvider=m,p===d.CUSTOM?E.page=null===(e=E.theme)||void 0===e?void 0:e.pages.find((function(e){return e.type===p&&e.slug===E.pageParams.slug})):E.page=null===(t=E.theme)||void 0===t?void 0:t.pages.find((function(e){return e.type===p})),requestAnimationFrame((function(){document.body.scrollTop=0,document.scrollingElement&&(document.scrollingElement.scrollTop=0)}))})),this.sendMessage(_.EDITOR_PAGE_CHANGE,{pageType:p,pageParams:this.pageParams,pageSpecificData:(null===(h=this.pageDataProvider)||void 0===h?void 0:h.pageSpecificData)||null}),this.isLoading=!1,[2]}}))}))},this.onLoadingChange=function(){E.sendMessage(_.EDITOR_LOADING_CHANGE,{isLoading:E.isLoading})},this.sendMessage=function(e,t){window.parent.postMessage({type:e,data:JSON.parse(JSON.stringify(t))},"*")},this.getPagePropValues=function(i,n,o){return e(E,void 0,void 0,(function(){var e,a,r;return t(this,(function(t){switch(t.label){case 0:return e=new m(i,o,n),(o.blogId||o.blogCategoryId)&&(e.possiblePageTypes=[d.BLOG,d.BLOG_CATEGORY]),o.raffleId&&(e.possiblePageTypes=[d.RAFFLE_DETAIL]),[4,e.getPageData()];case 1:return t.sent(),e.pageSpecificData?(h.setPageSpecificData(JSON.stringify(e.pageSpecificData),n,!0),n===d.PRODUCT&&h.pageSpecificData&&(a=h.pageSpecificData,(r=a.product.variants.find((function(e){return e.id===o.variantId})))&&(a.selectedVariantValues=r.variantValues))):h.pageSpecificData=void 0,e.pageComponentPropValues=h.initPropValues(JSON.stringify(e.pageComponentPropValues),this.router,JSON.stringify(i.settings),!1),[2,e]}}))}))},this.setComponentRef=function(e,t){E.componentRefs[t.id]=e},this.isScrolledIntoView=function(e){var t=e.getBoundingClientRect(),i=t.top,n=t.bottom;return i<window.innerHeight&&n>=0&&n<window.innerHeight&&i>0},this.handleUpdateFrameData=function(i){return e(E,void 0,void 0,(function(){var e,n,o,a,r,d=this;return t(this,(function(t){switch(t.label){case 0:return this.theme=new s(i.theme),this.page=this.theme.pages.find((function(e){return e.id===i.selectedPage.id})),this.pageParams=i.pageParams,this.apiKey=i.apiKey,this.locale=i.locale||"en",this.translations=i.translations||void 0,this.page?((e=i.storefront)&&(n=new T(e),o=n.routings.find((function(e){return e.locale===d.locale})),v.storefrontId=n.id,v.storefrontRoutingId=null==o?void 0:o.id,n.mainStorefrontThemeId&&(v.storefrontThemeId=n.mainStorefrontThemeId),n.salesChannelId&&(v.salesChannelId=n.salesChannelId),(null==o?void 0:o.priceListId)?v.priceListId=o.priceListId:v.priceListId=void 0,v.routings=n.routings,v.stockPreference=this.theme.settings.stockPreference),this.translations&&(v.translations=this.translations),v.isEditor=!0,P.createApolloClient(this.apiKey||void 0),window.editorApiKey=i.apiKey,a=C(),this.updateId=a,this.isLoading=!0,[4,this.getPagePropValues(this.theme,this.page.type,this.pageParams||{})]):[2];case 1:return r=t.sent(),this.updateId===a&&(this.pageDataProvider=r,this.isLoading=!1),[2]}}))}))},this.handleUpdateThemeJson=function(i){return e(E,void 0,void 0,(function(){return t(this,(function(e){return this.theme=new s(i.theme),[2]}))}))},this.handleUpdatePropValue=function(i){return e(E,void 0,void 0,(function(){var e,n,a,r,s,d,p,u,l=this;return t(this,(function(t){switch(t.label){case 0:return e=i.propName,n=i.value,(a=null===(p=null===(d=this.selectedComponent)||void 0===d?void 0:d.props)||void 0===p?void 0:p.find((function(t){return t.name===e})))&&this.selectedPageComponent?(r=null===(u=this.pageDataProvider)||void 0===u?void 0:u.pageComponentPropValues.find((function(e){return e.pageComponent.id===l.selectedPageComponentId})),this.selectedPageComponent.propValues[e]=n,this.pageDataProvider?[4,this.pageDataProvider.getPageComponentPropValue(this.selectedPageComponent,a)]:[2]):[2];case 1:return s=t.sent(),[4,this.pageDataProvider.setLinkSlugs()];case 2:return t.sent(),o((function(){r&&(r.propValues[e]=s,a.type===c.CUSTOM?h.initCustomDataPropValue(a,s,r,l.router,l.theme.settings,!0):a.type===c.COMPONENT?h.initComponentPropValue(a,s,r,l.router,l.theme.settings,!0):a.type===c.COMPONENT_LIST?h.initComponentListPropValue(a,s,r,l.router,l.theme.settings,!0):a.type===c.PRODUCT_DETAIL?h.initProductDetailPropValue(a,s,r,l.router):a.type===c.CATEGORY?h.initCategoryPropValue(a,s,r):a.type===c.BRAND?h.initBrandPropValue(a,s,r):a.type===c.BLOG?h.initBlogPropValue(a,s,r):a.type===c.BLOG_CATEGORY?h.initBlogCategoryPropValue(a,s,r):a.type===c.RAFFLE?h.initRafflePropValue(a,s,r):a.type!==c.LINK&&a.type!==c.LIST_OF_LINK||h.initLinkPropValue(a,s,r))})),[2]}}))}))},this.handleUpdatePageParams=function(i){return e(E,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageParams=i.pageParams,this.isLoading=!0,[4,this.getPagePropValues(this.theme,this.page.type,this.pageParams||{})];case 1:return e=t.sent(),this.pageDataProvider=e,this.isLoading=!1,[2]}}))}))},this.handleUpdatePageComponentOrder=function(i){return e(E,void 0,void 0,(function(){return t(this,(function(e){return this.specification?this.specification.components=i.pageComponents.map((function(e){return new p(e)})):this.page.components=i.pageComponents.map((function(e){return new p(e)})),[2]}))}))},this.handleAddNewComponent=function(e){var t,i=new u(e.component);null===(t=E.theme)||void 0===t||t.components.push(i)},this.handleDeleteComponent=function(e){var t,i;(null===(t=E.theme)||void 0===t?void 0:t.components)&&(E.theme.components=E.theme.components.filter((function(t){return t.id!==e.componentId})));var n=E.pageComponents.filter((function(t){return t.componentId!==e.componentId}))||[];E.specification&&E.specification.components&&(E.specification.components=n),!E.specification&&(null===(i=E.page)||void 0===i?void 0:i.components)&&(E.page.components=n)},this.handleUpdateComponent=function(e){var t=E.theme.components.findIndex((function(t){return t.id===e.component.id}));-1!==t&&(E.theme.components[t]=new u(e.component))},this.handleAddNewPageComponent=function(i){return e(E,void 0,void 0,(function(){var e,n,a=this;return t(this,(function(t){switch(t.label){case 0:return e=new p(i.pageComponent),this.pageComponents.some((function(t){return t.id===e.id}))?[2]:[4,this.pageDataProvider.getPageComponentPropValues(e)];case 1:return n=t.sent(),o((function(){n.component.props.filter((function(e){return e.type===c.CUSTOM})).forEach((function(e){h.initCustomDataPropValue(e,n.propValues[e.name],n,a.router,a.theme.settings,!0)})),a.pageDataProvider.pageComponentPropValues.push(n),a.pageComponents.push(e)})),[2]}}))}))},this.handleDeletePageComponent=function(e){E.specification?E.specification.components=E.pageComponents.filter((function(t){return t.id!==e.pageComponentId})):E.page.components=E.pageComponents.filter((function(t){return t.id!==e.pageComponentId}))},this.handleSetSelectedComponent=function(e){E.selectedPageComponentId=e.componentId},this.handleSetHoveredComponent=function(e){E.hoveredPageComponentId=e.componentId},this.handleScrollToComponent=function(e){var t=e.componentId,i=E.componentRefs[t];i&&(E.isScrolledIntoView(i)||window.scrollTo({top:i.offsetTop,behavior:"smooth"}))},this.handleEditorReload=function(){window.location.reload()},this.updateThemeSettings=function(e){var t=e.settings;E.theme&&(E.theme.settings=new l(t))},this.router=i,n(this),this.startMessaging()}return Object.defineProperty(D.prototype,"specification",{get:function(){var e,t,i,n,o,a,r,s=this,p=this.page;return(null==p?void 0:p.type)===d.PRODUCT&&(r=null===(e=p.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=s.pageParams)||void 0===t?void 0:t.productId)}))),(null==p?void 0:p.type)===d.CATEGORY&&(r=null===(t=p.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=s.pageParams)||void 0===t?void 0:t.categoryId)}))),(null==p?void 0:p.type)===d.BRAND&&(r=null===(i=p.specifications)||void 0===i?void 0:i.find((function(e){var t;return e.id===(null===(t=s.pageParams)||void 0===t?void 0:t.brandId)}))),(null==p?void 0:p.type)===d.BLOG&&(r=null===(n=p.specifications)||void 0===n?void 0:n.find((function(e){var t;return e.id===(null===(t=s.pageParams)||void 0===t?void 0:t.blogId)}))),(null==p?void 0:p.type)===d.BLOG_CATEGORY&&(r=null===(o=p.specifications)||void 0===o?void 0:o.find((function(e){var t;return e.id===(null===(t=s.pageParams)||void 0===t?void 0:t.blogCategoryId)}))),(null==p?void 0:p.type)===d.RAFFLE_DETAIL&&(r=null===(a=p.specifications)||void 0===a?void 0:a.find((function(e){var t;return e.id===(null===(t=s.pageParams)||void 0===t?void 0:t.raffleId)}))),r},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"selectedPageComponent",{get:function(){var e=this;return this.pageComponents.find((function(t){return t.id===e.selectedPageComponentId}))},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"selectedComponent",{get:function(){var e,t=this;return null===(e=this.theme)||void 0===e?void 0:e.components.find((function(e){var i;return e.id===(null===(i=t.selectedPageComponent)||void 0===i?void 0:i.componentId)}))},enumerable:!1,configurable:!0}),D.prototype.createLoadingListener=function(){var e=this;i((function(){return e.isLoading}),(function(){e.onLoadingChange()}))},D.prototype.getVariantIdFromParams=function(i,n){return e(this,void 0,void 0,(function(){var e,o,a,r,s,d,p;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=new URLSearchParams("?"+n),[4,E.searchProducts({productIdList:[i],priceListId:v.priceListId,salesChannelId:v.salesChannelId})];case 1:return(null==(o=t.sent())?void 0:o.data.length)?(a=o.data[0],r=a.variantTypes.map((function(e){return e.variantType.slug})),s=[],r.forEach((function(t,i){var n=a.variantTypes[i],o=e.get(t);if(o){var r=n.variantType.values.find((function(e){return e.slug===o}));r&&s.push(r)}})),(d=a.variants.find((function(e){return e.variantValues.every((function(e){return s.some((function(t){return t.id===e.id}))}))})))?[2,d.id]:[3,3]):[2];case 2:return p=t.sent(),console.error(p),[3,3];case 3:return[2]}}))}))},D}();!function(e){e.FRAME_DID_LOAD="FRAME_DID_LOAD",e.UPDATE_FRAME_DATA="UPDATE_FRAME_DATA",e.UPDATE_THEME_JSON="UPDATE_THEME_JSON",e.UPDATE_PROP_VALUE="UPDATE_PROP_VALUE",e.UPDATE_PAGE_PARAMS="UPDATE_PAGE_PARAMS",e.UPDATE_PAGE_COMPONENT_ORDER="UPDATE_PAGE_COMPONENT_ORDER",e.ADD_COMPONENT="ADD_COMPONENT",e.DELETE_COMPONENT="DELETE_COMPONENT",e.UPDATE_COMPONENT="UPDATE_COMPONENT",e.ADD_PAGE_COMPONENT="ADD_PAGE_COMPONENT",e.DELETE_PAGE_COMPONENT="DELETE_PAGE_COMPONENT",e.COMPONENT_MOUSE_OVER="COMPONENT_MOUSE_OVER",e.COMPONENT_MOUSE_LEAVE="COMPONENT_MOUSE_LEAVE",e.COMPONENT_CLICK="COMPONENT_CLICK",e.SET_SELECTED_COMPONENT="SET_SELECTED_COMPONENT",e.SET_HOVERED_COMPONENT="SET_HOVERED_COMPONENT",e.SCROLL_TO_COMPONENT="SCROLL_TO_COMPONENT",e.UPDATE_THEME_SETTINGS="UPDATE_THEME_SETTINGS",e.EDITOR_PAGE_CHANGE="EDITOR_PAGE_CHANGE",e.EDITOR_LOADING_CHANGE="EDITOR_LOADING_CHANGE",e.EDITOR_RELOAD="EDITOR_RELOAD"}(_||(_={}));export{_ as BridgeMessageType,D as default};