@aurigma/ui-framework
Version:
A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.
1 lines • 26 kB
JavaScript
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[40],{488:function(t,e,i){"use strict";i.d(e,"a",(function(){return n})),i.d(e,"b",(function(){return r}));var n=function(t){t&&(this.id=t.id,this.productVersionId=t.productVersionId,this.productId=t.productId,this.tenantId=t.tenantId,this.storefrontProductVariantId=t.storefrontProductVariantId,this.options=t.productVariantOptions.map((function(t){return new r(t)})),this.price=t.price)},r=function(t){t&&(this.productOptionId=t.productOptionId,this.productOptionValueId=t.productOptionValueId,this.productOptionType=t.productOptionType,this.productOptionTraits=t.productOptionTraits,this.productOptionTitle=t.productOptionTitle,this.productOptionValueTitle=t.productOptionValueTitle)}},541:function(t,e,i){"use strict";i.d(e,"a",(function(){return r}));var n=i(26),r=function(t){function e(e){var i=t.call(this)||this;return i._value=e,i}return Object(n.a)(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(e){var i=t.prototype._subscribe.call(this,e);return!i.closed&&e.next(this._value),i},e.prototype.getValue=function(){var t=this,e=t.hasError,i=t.thrownError,n=t._value;if(e)throw i;return this._throwIfClosed(),n},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(i(127).a)},595:function(t,e,i){"use strict";i.d(e,"a",(function(){return o}));var n=i(535),r=i(488),o=function(t){var e,i,o,u,c;if(t){this.id="".concat(t.productVariantId,":").concat(t.designId),this.productVariantId=t.productVariantId,this.productVersionId=t.productVersionId,this.productId=t.productId,this.sku=t.storefrontProductVariantId,this.designId=t.designId,this.designName=t.designName,this.designGroup=t.designGroup;var a=null!==(e=t.productVariantOptions)&&void 0!==e?e:[];this.options=a.map((function(t){return new r.b(t)}));var d=null!==(i=t.productVariantResources)&&void 0!==i?i:[];this.resources=d.map((function(t){return new s(t)}));var l=d.find((function(t){return t.type===n.d.Preview})),p=d.find((function(t){return t.type===n.d.EditorModel}));this.previewUrl=null!==(o=null==l?void 0:l.url)&&void 0!==o?o:"",this.designResourceId=null!==(u=null==p?void 0:p.resourceId)&&void 0!==u?u:"",this.previewResourceId=null!==(c=null==l?void 0:l.resourceId)&&void 0!==c?c:"",this.price=t.price}},s=function(t){t&&(this.resourceId=t.resourceId,this.name=t.name,this.url=t.url,this.type=t.type,this.resourcePreview=t.resourcePreview)}},603:function(t,e,i){"use strict";i.d(e,"a",(function(){return s}));var n=new(i(161).a)((function(t){return t.complete()})),r=i(122),o=i(123);function s(t){return t<=0?function(){return n}:Object(r.a)((function(e,i){var n=0;e.subscribe(new o.a(i,(function(e){++n<=t&&(i.next(e),t<=n&&i.complete())})))}))}},927:function(t,e,i){"use strict";i.r(e),i.d(e,"AuWidgetProductInformationAJAX",(function(){return T})),i.d(e,"widget",(function(){return T}));var n=i(0),r=i(535),o=i(2),s=i(403),u=i(1),c=i(541),a=i(147),d=Object(a.a)((function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}})),l=i(395),p=i(603),h=i(122),f=i(123);function v(){return new d}var b,g,m,y=i(216);!function(t){t.Preselect="Preselect",t.Filter="Filter"}(b||(b={})),function(t){t[t.Template=1]="Template",t[t.OptionBasedProduct=2]="OptionBasedProduct"}(g||(g={})),function(t){t[t.Custom=0]="Custom",t[t.ShopifyLegacy=1]="ShopifyLegacy",t[t.DocketManager=2]="DocketManager",t[t.Auth0Saml=3]="Auth0Saml",t[t.NopCommerce=4]="NopCommerce",t[t.WooCommerce=5]="WooCommerce",t[t.Magento=6]="Magento",t[t.BigCommerce=7]="BigCommerce",t[t.Shopify=8]="Shopify",t[t.ShopifyCustom=9]="ShopifyCustom"}(m||(m={}));var O=i(160),_=function(t){var e,i,n;this.values=[],this.selected=[],t&&(this.id=t.id,this.name=t.title,this.isMultiSelect=!!(null===(e=t.traits)||void 0===e?void 0:e.includes("AllowsMultiselect")),this.values=t.productOptionValues.map((function(t){return new I(t)})),this.image=t.image,this.description=t.description,this.tooltip=t.tooltip,this.appearanceDataItems=null===(i=t.appearanceData)||void 0===i?void 0:i.items,this.type=function(t,e){if(e)return"checkbox";switch(t){case r.b.Radio:return"radio";case r.b.Chips:return"chips";case r.b.Dropdown:return"dropdown";case r.b.ColorGrid:return"color-grid";case r.b.ColorList:return"color-list";case r.b.ImageGrid:return"image-grid";case r.b.ImageList:return"image-list";default:return console.warn("Option type ".concat(t," is not supported")),"radio"}}(null===(n=t.appearanceData)||void 0===n?void 0:n.type,this.isMultiSelect),this.selected=this.isMultiSelect?this.values.filter((function(t){return t.isDefault})):[this.values.find((function(t){return t.isDefault}))])},I=function(t){var e;this.disabled=!1,this.isDefault=!1,t&&(this.id=t.id,this.name=t.title,this.additionalText=t.description,this.color=t.colors[0]||null,this.imageUrl=(null===(e=t.image)||void 0===e?void 0:e.url)||null,this.isDefault=t.isDefault)},k=function(){},j=function(t){var e;this.enabled=!1,t&&(this.enabled=null!==(e=t.enabled)&&void 0!==e&&e,this.skip=t.skip,this.take=t.take,this.productFilterId=t.productFilterId)},V=function(t){this.onError=function(t){},this.onSuccess=function(t){},t&&(this.onError=t.onError,this.onSuccess=t.onSuccess)},w=function(){function t(t){var e,i,n,r,o,s,u,c,a;this.settings={mockups:new j,designs:new j,variants:new j},this.eventsCallbacks={options:new V,mockups:new V,designs:new V,variants:new V},this.productId=null==t?void 0:t.productId,this.productVersionId=null==t?void 0:t.productVersionId,this.productLinkId=null==t?void 0:t.productLinkId,this.options=null!==(e=null==t?void 0:t.options)&&void 0!==e?e:{},this.choices=null!==(i=null==t?void 0:t.choices)&&void 0!==i?i:void 0,this.currentSku=null==t?void 0:t.currentSku,this.settings.mockups=new j(null===(n=null==t?void 0:t.settings)||void 0===n?void 0:n.mockups),this.settings.designs=new j(null===(r=null==t?void 0:t.settings)||void 0===r?void 0:r.designs),this.settings.variants=new j(null===(o=null==t?void 0:t.settings)||void 0===o?void 0:o.variants),this.eventsCallbacks.designs=new V(null===(s=null==t?void 0:t.eventsCallbacks)||void 0===s?void 0:s.designs),this.eventsCallbacks.mockups=new V(null===(u=null==t?void 0:t.eventsCallbacks)||void 0===u?void 0:u.mockups),this.eventsCallbacks.options=new V(null===(c=null==t?void 0:t.eventsCallbacks)||void 0===c?void 0:c.options),this.eventsCallbacks.variants=new V(null===(a=null==t?void 0:t.eventsCallbacks)||void 0===a?void 0:a.variants)}return t.prototype.getOptionValue=function(t){return this.options[t]},t}(),S=i(595),C=i(488),P=function(t){t&&(this.productVariantId=t.productVariantId,this.productVersionId=t.productVersionId,this.productId=t.productId,this.tenantId=t.productVersionId,this.sku=t.storefrontProductVariantId,this.mockupId=t.mockupId,this.mockupName=t.mockupName,this.mockupType=t.mockupType,this.surfaceIndex=t.surfaceIndex,this.surfaceUsageType=t.surfaceUsageType,this.options=t.productVariantOptions.map((function(t){return new C.b(t)})))},A=function(t){t&&(this.id=t.productId,this.versionId=t.productVersionId,this.linkId=t.productLinkId,this.name=t.name,this.description=t.description,this.customFields=t.customFields,this.tags=t.tags)},T=function(t){function e(){var e=t.call(this)||this;return e._priceIsFetching=!1,e._output=new k,e._filteredOutput=null,e._isRestored=!1,e._optionsAreLoaded=new c.a(!1),e._productInfo=null,e._productApiClientConfig=e._createProductApiClientConfig(),e._productsApi=new r.e(e._productApiClientConfig,e.backOfficeUrl),e._productsReferenceApi=new r.c(e._productApiClientConfig,e.backOfficeUrl),e}return Object(n.d)(e,t),Object.defineProperty(e.prototype,"productInfo",{get:function(){return this._productInfo},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selectionStrategy",{get:function(){var t;return null===(t=this.auWizard.driver.backOffice.optionBasedProductInfo)||void 0===t?void 0:t.selectionStrategy},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selectedVariantSku",{get:function(){var t;return null===(t=this.auWizard.driver.backOffice.optionBasedProductInfo)||void 0===t?void 0:t.selectedVariantSku},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isPreselectSelectionStrategy",{get:function(){return this.selectionStrategy===b.Preselect},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"driverChoices",{get:function(){var t;return(null===(t=this.auWizard.driver.backOffice.optionBasedProductInfo)||void 0===t?void 0:t.choices)||null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"priceIsFetching",{get:function(){return this._priceIsFetching},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this.name in this.auWizard.scopeInternal.widgetsData?this._isRestored?this._output.options:[]:this._output.options},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"variants",{get:function(){var t;return this._params.choices?null===(t=this._filteredOutput)||void 0===t?void 0:t.variants:this._output.variants},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"designs",{get:function(){var t;return this._params.choices?null===(t=this._filteredOutput)||void 0===t?void 0:t.designs:this._output.designs},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mockups",{get:function(){var t;return this._params.choices?null===(t=this._filteredOutput)||void 0===t?void 0:t.mockups:this._output.mockups},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backOfficeUrl",{get:function(){return u.a.removeTrailingSlash(this.auWizard.driver.backOffice.backOfficeUrl)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tenantId",{get:function(){return this.auWizard.driver.backOffice.tenantId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"token",{get:function(){return this.auWizard.driver.backOffice.token},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"storefrontId",{get:function(){return this.auWizard.driver.backOffice.storefrontId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"reference",{get:function(){return this.auWizard.driver.backOffice.externalProductId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"storefrontUserId",{get:function(){return this.auWizard.driver.user.id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currencyCode",{get:function(){return this.auWizard.driver.settings.currency},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"quantity",{get:function(){return this.auWizard.driver.orders.current.quantity},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"productLinkId",{get:function(){var t;return this._params.productLinkId?this._params.productLinkId:null===(t=this.auWizard.driver.backOffice.optionBasedProductInfo)||void 0===t?void 0:t.productLinkId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"productId",{get:function(){var t;return this._params.productId?this._params.productId:null===(t=this.auWizard.driver.backOffice.optionBasedProductInfo)||void 0===t?void 0:t.productId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"productVersionId",{get:function(){var t;return this._params.productVersionId?this._params.productVersionId:null===(t=this.auWizard.driver.backOffice.optionBasedProductInfo)||void 0===t?void 0:t.productVersionId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"costDetails",{get:function(){return this._costDetails},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"price",{get:function(){var t;return this._costDetails?null===(t=this._costDetails)||void 0===t?void 0:t.productCost:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"variantsSettings",{get:function(){return this._params.settings.variants},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mockupsSettings",{get:function(){return this._params.settings.mockups},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"designsSettings",{get:function(){return this._params.settings.designs},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentChoices",{get:function(){return this._getChoices(this._output.options)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"variantsHashMap",{get:function(){var t=this._output.variants.map((function(t){var e={};return t.options.forEach((function(t){e[t.productOptionId]=[t.productOptionValueId]})),e}));return 0==t.length&&console.warn("There are no available variants"),t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"summary",{get:function(){var t;if((null===(t=this.options)||void 0===t?void 0:t.length)>0){var e=[];return this.options.forEach((function(t){var i={};i.name=t.name,i.value=t.selected.map((function(t){return t.name})),e.push(i)})),e}return[]},enumerable:!1,configurable:!0}),e.prototype.getProductVariants=function(t,e){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(i){return[2,this._productsApi.getProductVariants(t,+this.productVersionId,e.skip,e.take,null,e.productFilterId,!0,this.isPreselectSelectionStrategy?null:this.selectedVariantSku,this.tenantId)]}))}))},e.prototype.getDesignVariants=function(t,e){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(i){switch(i.label){case 0:return[4,this._productsApi.getProductVariantDesigns(t,+this.productVersionId,null,null,null,null,e.skip,e.take,null,e.productFilterId,!0,this.isPreselectSelectionStrategy?null:this.selectedVariantSku,this.tenantId)];case 1:return[2,i.sent()]}}))}))},e.prototype.getMockupVariants=function(t,e){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(i){switch(i.label){case 0:return[4,this._productsApi.getProductVariantMockups(t,+this.productVersionId,null,null,null,null,e.skip,e.take,null,e.productFilterId,!0,this.isPreselectSelectionStrategy?null:this.selectedVariantSku,this.tenantId)];case 1:return[2,i.sent()]}}))}))},e.prototype.updateParams=function(t){},e.prototype.updateParamsAsync=function(t){var e,i;return Object(n.b)(this,void 0,void 0,(function(){var r,o,s,u,c,a,d;return Object(n.e)(this,(function(n){switch(n.label){case 0:return this._params?[3,5]:(this._params=new w(t),this.productId?[4,this._getOptionsAndVariantsSimultaneously()]:[3,2]);case 1:return u=n.sent(),[3,4];case 2:return[4,this._getOptionsAndVariants()];case 3:u=n.sent(),n.label=4;case 4:o=(r=u).options,s=r.variants,o=this._selectAvailableVariant(o,s),o=this._disableUnavailableOptions(o,s),this._output.options=o,this.emitChange({options:this._output.options},!1),this._output.variants=s,this.emitChange({variants:this._output.variants},!1),this._optionsAreLoaded.next(!0),n.label=5;case 5:if(this.auWizard._isRestoring)return[2];if(t.choices&&!Array.isArray(t.choices)&&this._isNewChoices(t.choices)){if(c=null===(e=Object.keys(t.choices))||void 0===e?void 0:e.length,a=this.variantsHashMap[0],d=null===(i=Object.keys(a))||void 0===i?void 0:i.length,c!=d)return console.warn("The number of choices is not equal to the number of options."),[2];this._selectValuesBy(t.choices),this.emitChange({filterOutput:this._filteredOutput,options:this._output.options},!1,!0)}return t.currentSku&&t.currentSku!==this._params.currentSku?(this._cancelTokenSource&&this._cancelTokenSource.cancel("Operation canceled"),[4,this.getPrice(t.currentSku)]):[3,7];case 6:n.sent(),n.label=7;case 7:return[2]}}))}))},e.prototype.connectedCallback=function(){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(e){return t.prototype.connectedCallback.call(this),[2]}))}))},e.prototype.disconnectedCallback=function(){t.prototype.disconnectedCallback.call(this)},e.prototype.exportWidgetData=function(t){var e,i;return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(t){return[2,(null===(e=this._params)||void 0===e?void 0:e.choices)?{choices:null===(i=this._params)||void 0===i?void 0:i.choices}:null]}))}))},e.prototype.restoreWidgetFromData=function(t,e){return Object(n.b)(this,void 0,void 0,(function(){var e=this;return Object(n.e)(this,(function(i){return t&&this._optionsAreLoaded.pipe(function(t,e){var i=arguments.length>=2;return function(n){return n.pipe(t?Object(l.a)((function(e,i){return t(e,i,n)})):y.a,Object(p.a)(1),i?function(t){return Object(h.a)((function(e,i){var n=!1;e.subscribe(new f.a(i,(function(t){n=!0,i.next(t)}),(function(){n||i.next(t),i.complete()})))}))}(e):(void 0===(r=function(){return new d})&&(r=v),Object(h.a)((function(t,e){var i=!1;t.subscribe(new f.a(e,(function(t){i=!0,e.next(t)}),(function(){return i?e.complete():e.error(r())})))}))));var r}}((function(t){return!0===t}))).subscribe((function(){var i=null==t?void 0:t.choices;e._params.choices=i,e._selectValuesBy(i),e._isRestored=!0,e.emitChange({filterOutput:e._filteredOutput,options:e._output.options},!1,!0)})),[2]}))}))},e.prototype.getPrice=function(t){return Object(n.b)(this,void 0,void 0,(function(){var e,i=this;return Object(n.e)(this,(function(n){switch(n.label){case 0:return t?u.a.isEmptyString(this.reference)||u.a.isEmptyString(this.storefrontId)?[3,2]:(e=s.a.CancelToken,this._cancelTokenSource=e.source(),this._params.currentSku=t,this._priceIsFetching=!0,[4,this._productsReferenceApi.getProductCostDetails(this.reference,t,this.storefrontId,null,this.currencyCode,this.quantity,this.tenantId,this._cancelTokenSource.token).then((function(t){i._costDetails=t,i._priceIsFetching=!1,i.emitChange({costDetails:i._costDetails},!1)})).catch((function(t){"Operation canceled"!==t.message&&console.error(t.message)}))]):[2,null];case 1:return n.sent(),[3,3];case 2:return console.warn("To get current item price you need reference and storefrontId"),[2,null];case 3:return[2]}}))}))},e.prototype.filterModel=function(t,e){return Object.values(t).forEach((function(t){if(Array.isArray(t)){if(t.length<1)return;e=e.filter((function(e){var i;return null===(i=e.options)||void 0===i?void 0:i.some((function(e){return t.includes(e.productOptionValueId)}))}))}else e=e.filter((function(e){var i;return null===(i=e.options)||void 0===i?void 0:i.some((function(e){return t===e.productOptionValueId}))}))})),e},e.prototype.filterVariants=function(t){t&&this._output&&(this._filteredOutput=Object.assign({},this._output),this._filteredOutput.designs&&(this._filteredOutput.designs=this.filterModel(t,this._filteredOutput.designs)),this._filteredOutput.mockups&&(this._filteredOutput.mockups=this.filterModel(t,this._filteredOutput.mockups)),this._filteredOutput.variants&&(this._filteredOutput.variants=this.filterModel(t,this._filteredOutput.variants)))},e.prototype._createProductApiClientConfig=function(){var t=new r.a;return t.apiUrl=this.backOfficeUrl,t.setAuthorizationToken(this.token),t},e.prototype._getChoices=function(t){var e={};return t.forEach((function(t){e[t.id]=t.selected.map((function(t){return t.id}))})),e},e.prototype._selectValuesBy=function(t){this.filterVariants(t),this._params.choices=t;var e=this._applyChoices(this._output.options,t);this._output.options=this._disableUnavailableOptions(e,this._output.variants)},e.prototype._getOptionsAndVariants=function(){return Object(n.b)(this,void 0,void 0,(function(){var t,e;return Object(n.e)(this,(function(i){switch(i.label){case 0:return[4,this._getOptions()];case 1:return t=i.sent(),[4,this._getVariants()];case 2:return e=i.sent(),[2,{options:t,variants:e}]}}))}))},e.prototype._getOptionsAndVariantsSimultaneously=function(){return Object(n.b)(this,void 0,void 0,(function(){var t,e,i;return Object(n.e)(this,(function(r){switch(r.label){case 0:return[4,Promise.all([this._getOptions(),this._getVariants()])];case 1:return t=n.h.apply(void 0,[r.sent(),2]),e=t[0],i=t[1],[2,{options:e,variants:i}]}}))}))},e.prototype._selectAvailableVariant=function(t,e){if(this._isSelectedVariantAvailable(t,e))return t;var i=this._getVariantsHashMap(e)[0];return t.map((function(t){var e=[t.values.find((function(e){return e.id===i[t.id][0]})).id];return t.selected=t.isMultiSelect?t.values.filter((function(t){return null==e?void 0:e.some((function(e){return e===t.id}))})):[t.values.find((function(t){return null==e?void 0:e.includes(t.id)}))],t}))},e.prototype._isSelectedVariantAvailable=function(t,e){var i=this._getChoices(t);return this._getVariantsHashMap(e).some((function(t){return JSON.stringify(t)===JSON.stringify(i)}))},e.prototype._disableUnavailableOptions=function(t,e){var i,r,o,s=this;if(this._getAllVariantsCount(t)===(null==e?void 0:e.length))return t;var u=this._getChoices(t),c=this._getVariantsHashMap(e),a=[];if(1===(null===(o=Object.keys(u))||void 0===o?void 0:o.length))a.push.apply(a,Object(n.j)([],Object(n.h)(c),!1));else{var d=function(t,e){var i=c.filter((function(i){return i[t][0]==e[0]&&s._getDifferentOptionsCount(i,u)<=1}));a.push.apply(a,Object(n.j)([],Object(n.h)(i),!1))};try{for(var l=Object(n.k)(Object.entries(u)),p=l.next();!p.done;p=l.next()){var h=Object(n.h)(p.value,2);d(h[0],h[1])}}catch(f){i={error:f}}finally{try{p&&!p.done&&(r=l.return)&&r.call(l)}finally{if(i)throw i.error}}}return t.map((function(t){return t.values.map((function(e){var i=a.some((function(i){return i[t.id][0]===e.id}));return e.disabled=!i,e})),t}))},e.prototype._getAllVariantsCount=function(t){return t.reduce((function(t,e){return t*e.values.length}),1)},e.prototype._getDifferentOptionsCount=function(t,e){var i,r,o=0;try{for(var s=Object(n.k)(Object.entries(t)),u=s.next();!u.done;u=s.next()){var c=Object(n.h)(u.value,2),a=c[0],d=c[1],l=e[a];Array.isArray(l)?l[0]!=d[0]&&o++:l!=d[0]&&o++}}catch(p){i={error:p}}finally{try{u&&!u.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o},e.prototype._applyChoices=function(t,e){return t.map((function(t){var i=e[null==t?void 0:t.id];return t.selected=t.isMultiSelect?t.values.filter((function(t){return null==i?void 0:i.some((function(e){return e===t.id}))})):[t.values.find((function(t){return null==i?void 0:i.includes(t.id)}))],t}))},e.prototype._getVariantsHashMap=function(t){var e=t.map((function(t){var e={};return t.options.forEach((function(t){e[t.productOptionId]=[t.productOptionValueId]})),e}));return 0==e.length&&console.warn("There are no available variants"),e},e.prototype._getProductSummary=function(){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(t){if(u.a.isEmptyString(this.reference)||u.a.isEmptyString(this.storefrontId)){if(null!=this.productId)return[2,this._productsApi.getProductSummary(Number.isFinite(Number(this.productId))?Number(this.productId):null,Number.isFinite(Number(this.productVersionId))?Number(this.productVersionId):null,Number.isFinite(Number(this.productLinkId))?Number(this.productLinkId):null,null,this.selectedVariantSku,this.tenantId)];throw new Error("There is not enough data to initialize. Use the following data combinations for initialization: productReferenceId and storefrontId or productId.")}return[2,this._productsReferenceApi.getProductSummary(this.reference,Number.isFinite(Number(this.storefrontId))?Number(this.storefrontId):null,null,this.selectedVariantSku,this.tenantId)]}))}))},e.prototype._getOptions=function(){var t;return Object(n.b)(this,void 0,void 0,(function(){var e,i,r;return Object(n.e)(this,(function(n){switch(n.label){case 0:e=[],n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._getProductSummary()];case 2:return i=n.sent(),this._productInfo=new A(i),e=null===(t=i.options)||void 0===t?void 0:t.map((function(t){return new _(t)})),this.driverChoices&&(e=this._applyChoices(e,this.driverChoices)),this._params.eventsCallbacks.options.onSuccess(e),[3,4];case 3:return r=n.sent(),this._params.eventsCallbacks.options.onError(r),[3,4];case 4:return[2,e]}}))}))},e.prototype._getVariants=function(){return Object(n.b)(this,void 0,void 0,(function(){var t,e,i,r=this;return Object(n.e)(this,(function(n){switch(n.label){case 0:t=[],n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.getProductVariants(+this.productId,this.variantsSettings)];case 2:return e=n.sent(),t=e.items.map((function(t){return new C.a(t)})),this._params.eventsCallbacks.variants.onSuccess(t),(u.a.isNullOrUndefined(t)||0==(null==t?void 0:t.length))&&this.selectedVariantSku&&console.warn("There are no product variants with this SKU: ".concat(this.selectedVariantSku)),[3,4];case 3:return i=n.sent(),this._params.eventsCallbacks.variants.onError(null==i?void 0:i.message),[3,4];case 4:return this.designsSettings.enabled&&this.getDesignVariants(+this.productId,this.designsSettings).then((function(t){r._output.designs=t.items.map((function(t){return new S.a(t)})),r._params.eventsCallbacks.designs.onSuccess(r._output.designs),!r._filteredOutput.designs&&r._params.choices&&(r._filteredOutput.designs=r.filterModel(r._params.choices,r._output.designs)),r.emitChange({designs:r._output.designs},!1)})).catch((function(t){return r._params.eventsCallbacks.designs.onError(t)})),this.mockupsSettings.enabled&&this.getMockupVariants(+this.productId,this.mockupsSettings).then((function(t){r._output.mockups=t.items.map((function(t){return new P(t)})),r._params.eventsCallbacks.mockups.onSuccess(r._output.mockups),!r._filteredOutput.mockups&&r._params.choices&&(r._filteredOutput.mockups=r.filterModel(r._params.choices,r._output.mockups)),r.emitChange({mockups:r._output.mockups},!1)})).catch((function(t){return r._params.eventsCallbacks.mockups.onError(t)})),[2,t]}}))}))},e.prototype._isNewChoices=function(t){var e;return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(i){return[2,JSON.stringify(t)!==JSON.stringify(null===(e=this._params)||void 0===e?void 0:e.choices)]}))}))},Object(n.c)([Object(o.a)("au-widget-pim-ajax"),Object(n.g)("design:paramtypes",[])],e)}(O.a)}}]);