UNPKG

@aurigma/ui-framework

Version:

A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.

1 lines 55.7 kB
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[17],{539:function(e,t,n){n.d(t,"a",function(){return i});var o=n(404),r=n(603),i=(Object.defineProperty(s,"iframeApiPromise",{get:function(){return this._iframeApiSubject.pipe(Object(r.a)(1)).toPromise()},enumerable:!1,configurable:!0}),s.loadCCScript=function(e,t){var n,r=this;return"undefined"!=typeof CustomersCanvas||document.body.querySelector("#CcIframeApiScript")?"undefined"!=typeof CustomersCanvas&&this._iframeApiSubject.next(CustomersCanvas):(this._iframeApiSubject=new o.a(1),(n=document.createElement("script")).type="text/javascript",n.id="CcIframeApiScript",n.onload=function(e){CustomersCanvas&&r._iframeApiSubject.next(CustomersCanvas)},n.onerror=function(e){r._iframeApiSubject.error(e)},n.src=e+t,document.body.appendChild(n)),this.iframeApiPromise},s._iframeApiSubject=new o.a(1),s);function s(){}},540:function(e,t,n){n.d(t,"a",function(){return c});var g=n(0),m=n(36),o=n(601),b=n(1),i=n(71),r=n(395),s=n(603),a=n(541),c=(u.prototype._showLockPreloader=function(e,t,n){var r,o;if(e&&t&&e[t]&&e[t].lock&&this.widget){e=Array.isArray(e[t].lock)?e[t].lock:[e[t].lock];try{for(var i=Object(g.k)(e),s=i.next();!s.done;s=i.next()){var a=s.value,c="main"===a?this.widget.auWizard:this.widget.auWizard.scope.$[a]||this.widget.jsonParamsFetcher.scope[a]||this.widget.jsonParamsFetcher.scope.$[a];c&&c.showPreloader(n)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}}},u.prototype.executeActions=function(d,f,h){var r=this,p=(f=f.filter(function(e){var t=!(!0===d[e].executeOnce&&-1!==r._executedActions.indexOf(e)),n=!0;return Array.isArray(d[e].executeOnlyAfter)&&(n=d[e].executeOnlyAfter.reduce(function(e,t){return e=-1===r._executedActions.indexOf(t)?!1:e},!0)),t&&n}),function(l){return Object(g.b)(r,void 0,void 0,function(){var t,n,r,o,i,s,a,c,u;return Object(g.e)(this,function(e){switch(e.label){case 0:if(this.logger.debug(function(){return"Start Execute '".concat(l,"'")}),t=performance.now(),n=Promise.resolve(),i=this._commands[l],r=(Array.isArray(d[l])?d[l][0]:d[l]).message,o=(Array.isArray(d[l])?d[l][0]:d[l]).timeout||10,!i||void 0===i.execute)return[3,8];if(r&&this.widget.showPreloader(!0,r,o),this._showLockPreloader(d,l,!0),n=i.execute(d[l],h[l]),-1===this._executedActions.indexOf(l)&&this._executedActions.push(l),void 0===(o=!(o=d[l].after)&&Array.isArray(d[l])&&(i=d[l].find(function(e){return e.after}))?i.after:o))return[3,4];Object(m.a)(o)||(o=[o]),i=function(e,t,n){return n.indexOf(e)<n.indexOf(t)},s=0,e.label=1;case 1:return s<o.length?(a=o[s],i(l,a,f)?[3,3]:[4,n]):[3,4];case 2:e.sent(),n=p(a),e.label=3;case 3:return s++,[3,1];case 4:return(c=!(c=d[l].onExecuted)&&Array.isArray(d[l])&&(u=d[l].find(function(e){return e.onExecuted}))?u.onExecuted:c)?[4,n]:[3,7];case 5:return e.sent(),[4,b.a.functionWrapperConstructor(c)()];case 6:e.sent(),e.label=7;case 7:return[3,9];case 8:console.warn("Action ".concat(l," is not supported! Double check the config.")),e.label=9;case 9:return[4,n];case 10:return e.sent(),r&&this.widget.showPreloader(!1),this._showLockPreloader(d,l,!1),this.logger.debug(function(){return"Finish Execute '".concat(l,"'")}),u=performance.now(),this.widget.auWizard.telemetry.trackEvent("DE-"+l,u-t),[2,n]}})})}),e=this.getJobReady(this._lastJobKey),t=this._lastJobKey=b.a.guid();return e.then(function(){return r.logger.debug(function(){return"Start actons: ".concat(f)}),b.a.recursiveJobPromise(f,p)}).then(function(){return r._onJobFinish()}).finally(function(){r.logger.debug(function(){return"End actons: ".concat(f)}),r._lastExecutedJobSubject.next(t)})},u.prototype.getJobReady=function(t){return this._lastExecutedJobSubject.pipe(Object(r.a)(function(e){return e===t}),Object(s.a)(1)).toPromise()},u.prototype.getChangedActions=function(n,r){var e=Object.keys(n).filter(function(e){return b.a.isObjectNotEmpty(n[e])}).filter(function(e){return void 0===r[e]||(t=n[e],e=r[e],!(JSON.stringify(t)===JSON.stringify(e)));var t}),t=e.indexOf("actionsErrorToast");return-1!==t&&e.splice(t,1),-1<(e=e.filter(function(e){e=n[e];return Array.isArray(e)?e[0]&&!1!==e[0].autoCompile:!1!==e.autoCompile})).indexOf("initial")?["initial"].concat(Object(o.a)(e,"initial")):e},u);function u(e,t,n,r){void 0===n&&(n=function(){return Promise.resolve()}),this._executedActions=[],this._lastJobKey="init",this._lastExecutedJobSubject=new a.a("init"),this._commands=e,this._onJobFinish=n,this.logger=new i.Category("command-executer_"+t+"_"+b.a.guid()),this.widget=r}},541:function(e,t,n){n.d(t,"a",function(){return o});var r,t=n(26),n=n(127),o=(r=n.a,Object(t.a)(i,r),Object.defineProperty(i.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),i.prototype._subscribe=function(e){var t=r.prototype._subscribe.call(this,e);return t.closed||e.next(this._value),t},i.prototype.getValue=function(){var e=this.hasError,t=this.thrownError,n=this._value;if(e)throw t;return this._throwIfClosed(),n},i.prototype.next=function(e){r.prototype.next.call(this,this._value=e)},i);function i(e){var t=r.call(this)||this;return t._value=e,t}},601:function(e,t,n){var h=n(602),r=n(209);function p(e,t){return!!(null==e?0:e.length)&&-1<Object(r.a)(e,t,0)}function g(e,t,n){for(var r=-1,o=null==e?0:e.length;++r<o;)if(n(t,e[r]))return!0;return!1}var m=n(205),b=n(198),v=n(542);var o=function(e,t,n,r){var o=-1,i=p,s=!0,a=e.length,c=[],u=t.length;if(a){n&&(t=Object(m.a)(t,Object(b.a)(n))),r?(i=g,s=!1):200<=t.length&&(i=v.a,s=!1,t=new h.a(t));e:for(;++o<a;){var l=e[o],d=null==n?l:n(l),l=r||0!==l?l:0;if(s&&d==d){for(var f=u;f--;)if(t[f]===d)continue e;c.push(l)}else i(t,d,r)||c.push(l)}}return c},i=n(207),s=n(203),n=Object(i.a)(function(e,t){return Object(s.a)(e)?o(e,t):[]});t.a=n},603:function(e,t,n){n.d(t,"a",function(){return r});var t=n(161),o=new t.a(function(e){return e.complete()});var i=n(122),s=n(123);function r(r){return r<=0?function(){return o}:Object(i.a)(function(e,t){var n=0;e.subscribe(new s.a(t,function(e){++n<=r&&(t.next(e),r<=n)&&t.complete()}))})}},825:function(e,t){e.exports="<style>\n :host {\n width: 100%;\n height: 100%;\n display: block;\n position: relative;\n }\n\n #editorFrame {\n position: absolute;\n height: 1px;\n min-height: 100%;\n width: 1px;\n min-width: 100%;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n border: none;\n background-color: transparent;\n }\n</style>\n<iframe id='editorFrame' allowfullscreen></iframe>"},925:function(k,e,t){t.r(e),t.d(e,"AuWidgetCanvas",function(){return te}),t.d(e,"widget",function(){return te});var n,v=t(0),e=t(825),r=t(160),z=t(404),B=t(603),o=function(e){Object.assign(this,e)},r=(n=r.c,Object(v.d)(i,n),i.prototype.customersCanvasPublish=function(e){this._customersCanvasSubject.next(e)},Object.defineProperty(i.prototype,"customersCanvasObservable",{get:function(){return this._customersCanvasSubject.asObservable()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"customersCanvasPromise",{get:function(){return this.customersCanvasObservable.pipe(Object(B.a)(1)).toPromise()},enumerable:!1,configurable:!0}),i.prototype.__methodExecuter=function(t){for(var n=this,e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];var o,i,s,a=new RegExp(/^async function\s*\(\s*([^)]*)\s*\)\s*=>\s*/),c=Array.from(arguments),u=(null!==function(t){return Object(v.b)(n,void 0,void 0,function(){return Object(v.e)(this,function(e){return console.log(t),[2]})})}.toString().match(a)&&(c[0]=(o=c[0],i=e,o=o.toString(),(s=o.match(a))&&(s=s[1],o=o.replace(a,"async (".concat(s,") => "))),"\n var execFunc = (".concat(o,");\n var args = ").concat(JSON.stringify(i.map(function(e){return JSON.stringify(e)})),";\n var parseParam = function(params) {\n if (Array.isArray(params)) { \n return params.map(function(x) { return JSON.parse(x); })\n } else {\n return [params];\n }\n }; \n execFunc.apply(null, parseParam(args))"))),null);try{u=arguments.callee.caller}catch(e){u="function"==typeof t?t:void 0}var l=u?u.name:"unknown function";return this.customersCanvasPromise.then(function(e){return e.eval.apply(e,c)}).catch(function(e){if(console.error(e),!l&&u)for(var t in n)if(n.hasOwnProperty(t)&&u===n[t]){l=t;break}throw"Failed to call "+l})},i.prototype.getReady=function(){function e(){var e=spEditor.getCanvasViewer().get_canvas().get_layers().toArray().filter(function(e){return e._visible});return(e=[].concat.apply([],Object(v.j)([],Object(v.h)(e.map(function(e){return e.get_vObjects().toArray().filter(function(e){return e.isVisible()&&!e.get_ready()})})),!1))).map(function(n){return new Promise(function(t){try{n.add_ready(function e(){n.remove_ready(e),t()})}catch(e){t()}})}),Promise.all(e)}var t=this;return this.customersCanvasPromise.then(function(){return t.__methodExecuter(e)}).then(function(){return new Promise(function(e){window.setTimeout(e,100)})})},i.prototype.getCanvasItemModel=function(n){return Object(v.b)(this,void 0,void 0,function(){var t;return Object(v.e)(this,function(e){switch(e.label){case 0:return t=function(e){var t=JSON.parse(e),n=spEditor.productHandler.getAllItems().find(function(e){return e.id===t.id});if(n=n||spEditor.productHandler.getAllItems().find(function(e){return e.name===t.name})){var r={id:n.id,name:n.name};switch(!0){case n instanceof CustomersCanvas.Model.PlaceholderItem&&null!=n.content&&n.content instanceof CustomersCanvas.Model.ImageItem&&!(n.content instanceof CustomersCanvas.Model.BarcodeItem)&&null!=n.content.tags.sourceData:var o=n.parentContainer.parentComponent.parentSurface.name,i=n.getTransformedRectangle(),s=n.content.getTransformedRectangle(),a=Aurigma.GraphicsMill.AjaxControls.VectorObjects.Math,c=a.normalizeAngle(s.Angle-i.Angle),u=s.clone(),l=i.clone(),a=(u.rotateAt(a.normalizeAngle(-u.Angle),l.get_center()),l.Angle=0,spEditor.productHandler.product.getCurrentSurface().getPrintAreas()[0]),a=spEditor.configuration.renderingConfig.getHiResRendering(a),d=n.content;r.tags=angular.copy(d.tags),r.value=d.tags.sourceData.name,r.surfaceName=o,r.placeholderContent={originalUrl:d.tags.sourceData.originalUrl+"?x-cctoken="+spEditor.configuration.tokenId,width:d.source.width,height:d.source.height,placeholderRectangle:i,contentRectangle:s,placeholderRectangleWithoutAngle:l,contentRectangleWithoutPlaceholderAngle:u,contentAngle:c,dpi:a.dpi};break;case n instanceof CustomersCanvas.Model.PlaceholderItem&&n.content&&n.content instanceof CustomersCanvas.Model.ImageItem:o=n.parentContainer.parentComponent.parentSurface.name,r={name:n.name,tags:angular.copy(n.tags),surfaceName:o};break;case n instanceof CustomersCanvas.Model.BaseTextItem&&!!n.text:d=n,i="",s=function(e){return(e/255).toFixed(7)};d.color instanceof Aurigma.GraphicsMill.AjaxControls.VectorObjects.RgbColor?i="rgb(".concat(d.color.R,",").concat(d.color.G,",").concat(d.color.B,",").concat(s(d.color.A),")"):d.color instanceof Aurigma.GraphicsMill.AjaxControls.VectorObjects.CmykColor&&(i="cmyk(".concat(s(d.color.C),",").concat(s(d.color.M),",").concat(s(d.color.Y),",").concat(s(d.color.K),",").concat(s(d.color.A),")")),r={name:n.name,value:d.text,color:i,font:{postScriptName:d.font.postScriptName,size:d.font.size,fauxBold:d.font.fauxBold,fauxItalic:d.font.fauxItalic}}}return n.contentPermissions&&n.contentPermissions.imagePermissions&&(r.contentPermissions={imagePermissions:{allowChangeImage:n.contentPermissions.imagePermissions.allowChangeImage,allowEditImage:n.contentPermissions.imagePermissions.allowEditImage}}),n.placeholderPermissions&&(r.placeholderPermissions={allowEditContent:n.placeholderPermissions.allowEditContent,showHandleButton:n.placeholderPermissions.showHandleButton,showSelectButton:n.placeholderPermissions.showSelectButton}),n.visualizationPermissions&&(r.visualizationPermissions={noPrint:n.visualizationPermissions.noPrint,noShow:n.visualizationPermissions.noShow}),null!==n.locked&&(r.locked=n.locked),r}},[4,this.__methodExecuter(t,JSON.stringify(n))];case 1:return t=e.sent(),this.fireChangeItemEvent(t),[2,new o(t)]}})})},i);function i(){var e=null!==n&&n.apply(this,arguments)||this;return e._customersCanvasSubject=new z.a(1),e}function s(e){this.widget=e}var g,a,U=function(e,t,n){this.definition=e,this.surfaceIndex=t,this.all=n},m=((R=g=g||{}).canvas="canvas",R.config="config",t(37)),b=t(1),F=(a=s,Object(v.d)(c,a),c.prototype.execute=function(o,i){return Object(v.b)(this,void 0,void 0,function(){var f,h,p,t,n,r=this;return Object(v.e)(this,function(e){switch(e.label){case 0:return this.widget.modifiedItem&&this.widget.updateModifiedItem({}),f=function(e){var t="number"==typeof e.sourceSurfaceIndex?spEditor.productHandler.product.getSurfaces()[e.sourceSurfaceIndex]:spEditor.productHandler.product.getCurrentSurface(),n={canvasSourceRectangleSize:{width:t.width,height:t.height}},t=t.getPrintAreas()[0].items,r=t.filter(function(e){return e.parentContainer.name===CustomersCanvas.Configuration.MAIN_CONTAINER_NAME}),o=CustomersCanvas.Configuration.getProductSerializer();return n.rawMainItems=r.map(function(e){return JSON.parse(o.serializeModelComponent(e))}),e.removeBackground||((r=t.filter(function(e){return e.parentContainer.name===CustomersCanvas.Configuration.BG_CONTAINER_NAME})).forEach(function(e){return e.itemPermissions.allowRemoveOnLayoutChange=!1}),n.rawBgItems=r.map(function(e){return JSON.parse(o.serializeModelComponent(e))})),n},h=function(o,i,s){return Object(v.b)(r,void 0,void 0,function(){var t,n,r;return Object(v.e)(this,function(e){switch(e.label){case 0:return(n=function(){return!("number"!=typeof s||(s<0||s>=spEditor.productHandler.product.getSurfaces().length)&&(console.error("deSerializeSurface: surfaceIndex is out of boundaries."),1))}()?spEditor.productHandler.product.getSurfaces()[s]:spEditor.productHandler.product.getCurrentSurface(),n=n.getPrintAreas()[0],n=n.getContainers(),t=n.find(function(e){return e.name===CustomersCanvas.Configuration.MAIN_CONTAINER_NAME}),n=n.find(function(e){return e.name===CustomersCanvas.Configuration.BG_CONTAINER_NAME}),r=function(e,t,n){void 0===n&&(n=[]);var r=CustomersCanvas.Configuration.getProductSerializer(),e=e.map(function(e){return r.productParser.parseItem(e)});t.setItems(n.concat(e)),spEditor.productHandler._subscribeToItemEvents(e)},i.discardChanges)?(r(o.rawMainItems,t),[3,3]):[3,1];case 1:return o.data=o.rawMainItems.concat(o.rawBgItems||[]),[4,spEditor.widgetsController.addLayoutItems(o)];case 2:e.sent(),e.label=3;case 3:return i.removeBackground||r(o.rawBgItems||[],n,n.getItems()||[]),spEditor.productHandler.updateView(),spEditor.productHandler.getProductUpdateEvent().fire(),[2,spEditor.getCanvasViewer().get_canvas().waitWebServiceCalls()]}})})},[4,this.widget.customersCanvasPromise];case 1:return p=e.sent(),t=o.map(function(e,t){return new U(e.data,t,e)}).filter(function(t,e){return m.Maybe.maybe(i).map(function(e){return e[t.surfaceIndex]}).caseOf({just:function(e){return JSON.stringify(t.all)!==JSON.stringify(e)},nothing:function(){return!0}})}),n=function(d){return Object(v.b)(r,void 0,void 0,function(){var t,n,r,o,i,s,a,c,u,l=this;return Object(v.e)(this,function(e){switch(e.label){case 0:switch(d.definition||console.warn("changeLayout: skipping because definition = null"),t=null,typeof(n=d.definition)){case"string":t=n;break;case"object":t={surfaces:[n]};break;default:console.error("changeLayout: Unexpected data type of "+JSON.stringify(n))}return r=b.a.createNodeFromString('<iframe style="position:fixed;top:-1000px;left:-1000px;z-index:0;opacity:0;max-width:0;max-height:0;display:block"></iframe>'),document.body.appendChild(r),i=m.Maybe.maybe(this.widget.params).map(function(e){return e.initial}).map(function(e){return e.editorConfig}),[4,CustomersCanvas.IframeApi.loadEditor(r,t,{initialMode:i.caseOf({just:function(e){return e.initialMode},nothing:function(){return CustomersCanvas.IframeApi.Configuration.ModelMode.Simple}}),restoreProductOnReloadEnabled:!1,preloader:{enabled:!1},rendering:{hiResOutputDpi:300},userId:i.caseOf({just:function(e){return e.userId},nothing:function(){return"default"}})})];case 1:return(o=e.sent(),b.a.isNotNullOrUndefined(d.all.dimesions))?(a=c=s=i=void 0,a=g[d.all.dimesions]===g.config?(i=o,s=p,c=0,d.surfaceIndex):(g.canvas,i=p,s=o,c=d.surfaceIndex,0),[4,this.getSurfaceDimension(i,c)]):[3,4];case 2:return c=e.sent(),[4,this.setSurfaceDimension(s,c,a)];case 3:e.sent(),e.label=4;case 4:return[4,o.eval(f,d.all,d.surfaceIndex)];case 5:return u=e.sent(),[4,p.eval(h,u,d.all,d.surfaceIndex)];case 6:return e.sent(),[4,this.getSurfaceRenderingConfig(o)];case 7:return u=e.sent(),[4,this.setSurfaceRenderingConfig(p,u,d.surfaceIndex)];case 8:return e.sent(),[4,m.Maybe.maybe(d.all).map(function(e){return e.viewerSettings}).caseOf({just:function(e){return l.widget.applyViewerSettings(e)},nothing:function(){return l.widget.customersCanvasPromise}})];case 9:return e.sent(),document.body.removeChild(r),[2]}})})},[4,b.a.recursiveJobPromise(t,n)];case 2:return e.sent(),[4,this.widget.replaceInterpolationPlaceholder()];case 3:return e.sent(),[2,this.widget.getReady()]}})})},c.prototype.getSurfaceDimension=function(t,n){return Object(v.b)(this,void 0,void 0,function(){return Object(v.e)(this,function(e){return[2,t.eval(function(e){var t=spEditor.model.product,n=t.getCurrentSurface();return{width:(n="number"==typeof e?e<0||e>=t.getSurfaces().length?(console.warn("getSurfaceDimensions: surfaceIndex is out of boundaries."),t.getCurrentSurface()):t.getSurfaces()[e]:n).width,height:n.height}},n).catch(function(e){console.log("Sorry for a failure"),console.log(e)})]})})},c.prototype.setSurfaceDimension=function(t,n,r){return Object(v.b)(this,void 0,void 0,function(){return Object(v.e)(this,function(e){return[2,t.eval(function(e){var t=spEditor.model.product,n=t.getCurrentSurface(),t=("number"==typeof r&&((r<0||r>=t.getSurfaces().length)&&console.error("setSurfaceDimensions: surfaceIndex is out of boundaries."),n=t.getSurfaces()[r]),n.getPrintAreas()[0]);n.width=e.width,n.height=e.height,t.bounds.Width=n.width,t.bounds.Height=n.height},n).catch(function(e){console.log("Sorry for a failure"),console.log(e)})]})})},c.prototype.getSurfaceRenderingConfig=function(t,n){return Object(v.b)(this,void 0,void 0,function(){return Object(v.e)(this,function(e){return[2,t.eval(function(e){var t=spEditor.model.product,n=t.getCurrentSurface();"number"==typeof e&&(e<0||e>=t.getSurfaces().length?console.error("getSurfaceRenderingConfig: surfaceIndex is out of boundaries."):n=t.getSurfaces()[e]);t=spEditor.configuration.renderingConfig.perSurfacePartialConfigs[n.name];return Object.assign({},t)},n).catch(function(e){console.log("Sorry for a failure"),console.log(e)})]})})},c.prototype.setSurfaceRenderingConfig=function(t,n,r){return Object(v.b)(this,void 0,void 0,function(){return Object(v.e)(this,function(e){return[2,t.eval(function(e,t){var n=spEditor.model.product,r=n.getCurrentSurface();"number"==typeof t&&(r=t<0||t>=n.getSurfaces().length?(console.warn("setSurfaceRenderingConfig: surfaceIndex is out of boundaries."),n.getCurrentSurface()):n.getSurfaces()[t]);var o=spEditor.configuration.renderingConfig.perSurfacePartialConfigs;if(e.hiResOutput)for(var i in e.hiResOutput)null!=e.hiResOutput[i]&&(o[r.name].hiResOutput[i]=e.hiResOutput[i]);if(e.proofImage)for(var i in e.proofImage)null!=e.proofImage[i]&&(o[r.name].proofImage[i]=e.proofImage[i])},n,r).catch(function(e){console.log("Sorry for a failure"),console.log(e)})]})})},c);function c(){return null!==a&&a.apply(this,arguments)||this}u=s,Object(v.d)(l,u),l.prototype.execute=function(r){return Object(v.b)(this,void 0,void 0,function(){var n,t;return Object(v.e)(this,function(e){switch(e.label){case 0:return[4,this.widget.customersCanvasPromise];case 1:return[4,e.sent().getProduct()];case 2:return n=e.sent(),t=r.data.map(function(e,t){return{mockup:e.mockup,previewMockups:e.previewMockups,surface:n.surfaces[t]}}),[2,n.setMockups(t,r.options)]}})})};var u,W=l;function l(){return null!==u&&u.apply(this,arguments)||this}d=s,Object(v.d)(f,d),f.prototype.execute=function(r){return Object(v.b)(this,void 0,void 0,function(){var t,n=this;return Object(v.e)(this,function(e){switch(e.label){case 0:return[4,this.widget.iframeApiPromise];case 1:return e.sent(),r.editorConfig=r.editorConfig||{},"string"==typeof r.productDefinition&&(r.editorConfig.autoLoadUserInfo=!1,r.editorConfig.userInfo=null,this.widget._stateId=r.productDefinition,this.widget._userId=this.widget.driver.user.id),(t=this.widget.driver.user.data)&&0<Object.keys(t).length&&(r.editorConfig.userInfo=b.a.DeepMerge(r.editorConfig.userInfo||{},t),r.editorConfig.autoLoadUserInfo=!0),[4,this.load(r.productDefinition,r.editorConfig,r.maximizeAssetManager||r.galleryObserverEnable)];case 2:e.sent(),e.label=3;case 3:return e.trys.push([3,5,,6]),[4,this.widget.getReady()];case 4:return e.sent(),[3,6];case 5:return e.sent(),console.error("Failed getReady() on widget canvas"),[3,6];case 6:return[2,m.Maybe.maybe(r).map(function(e){return e.viewerSettings}).caseOf({just:function(e){return n.widget.applyViewerSettings(e)},nothing:function(){return n.widget.customersCanvasPromise}})]}})})},f.prototype.load=function(i,s,a){return Object(v.b)(this,void 0,void 0,function(){var t,n,r,o;return Object(v.e)(this,function(e){switch(e.label){case 0:return t=this,i.surfaces&&Array.isArray(i.surfaces)&&i.surfaces.forEach(function(e){"object"==typeof e&&void 0!==e.width&&void 0!==e.height&&(e.width=Number(e.width),e.height=Number(e.height))}),t.widget.modifiedItem&&t.widget.updateModifiedItem({}),o=this.widget.shadowRoot.querySelector("#editorFrame"),[4,CustomersCanvas.IframeApi.loadEditor(o,i,s)];case 1:n=e.sent(),this.listenBoundsChanges(n),e.label=2;case 2:return e.trys.push([2,4,,5]),[4,n.getProduct()];case 3:return(r=e.sent()).switchTo(r.surfaces[0]),[3,5];case 4:return o=e.sent(),console.error("Load failed with exception: ",o),t.widget.dispatchEvent(new CustomEvent("error",o)),[2];case 5:return t.listenItemChanges(n),t.listenSurfaceChanges(n),t.updateOverallBounds(n),t.widget.customersCanvasPublish(n),t.widget.dispatchEvent(new CustomEvent("ready",{detail:{product:r,customersCanvas:n}})),[4,this.widget.replaceInterpolationPlaceholder()];case 6:return e.sent(),a&&(t.listenModalClose(n),t.listenModalOpen(n),t.listenAssetManagerClose(n),t.listenAssetManagerOpen(n)),t.listenOriginalSize(n),t.listenFullWindow(n),[2]}})})},f.prototype.listenItemChanges=function(n){return Object(v.b)(this,void 0,void 0,function(){var t=this;return Object(v.e)(this,function(e){switch(e.label){case 0:return[4,n.eval(function(){spEditor.productHandler.itemChangedEvent.add(function(e){e={name:e.name,id:e.id};this.spEditor._postMessageServer.notifySubscribers("itemChanged",JSON.stringify(e))})})];case 1:return e.sent(),n.subscribe("itemChanged",function(r){return Object(v.b)(t,void 0,void 0,function(){var t,n;return Object(v.e)(this,function(e){switch(e.label){case 0:return t=JSON.parse(r),[4,this.widget.getCanvasItemModel(t)];case 1:return t=e.sent(),n=new o(t),this.widget.updateModifiedItem(n),[2]}})})}),[2]}})})},f.prototype.listenBoundsChanges=function(e){var t=this;e.subscribe(CustomersCanvas.IframeApi.PostMessage.Events.BoundsNotification,function(e){t.widget.updateOverallBounds(e.overallBounds)})},f.prototype.listenSurfaceChanges=function(e){var t=this;e.subscribe(CustomersCanvas.IframeApi.PostMessage.Events.OnSurfaceChanged,function(e){t.widget.updateCurrentSurfaceName()})},f.prototype.updateOverallBounds=function(e){var t=this;e.eval(function(){return spEditor.injector.get(CustomersCanvas.SimplePolygraphy.IBoundsNotifier.injectName).getOverallBounds()}).then(function(e){return t.widget.updateOverallBounds(e)})},f.prototype.listenOriginalSize=function(e){var t=this;e.subscribe(CustomersCanvas.IframeApi.PostMessage.Events.OriginalSize,function(){t.widget.toggleMaximizeMainPanel(!1)})},f.prototype.listenFullWindow=function(e){var t=this;e.subscribe(CustomersCanvas.IframeApi.PostMessage.Events.FullWindow,function(){t.widget.toggleMaximizeMainPanel(!0)})},f.prototype.listenModalClose=function(e){var t=this;e.subscribe(CustomersCanvas.IframeApi.PostMessage.Events.ModalClose,function(){t.widget.toggleMaximizeMainPanel(!1)})},f.prototype.listenModalOpen=function(e){var t=this;e.subscribe(CustomersCanvas.IframeApi.PostMessage.Events.ModalOpen,function(){t.widget.toggleMaximizeMainPanel(!0)})},f.prototype.listenAssetManagerClose=function(e){var t=this;e.subscribe(CustomersCanvas.IframeApi.PostMessage.Events.AssetManagerClosed,function(){t.widget.toggleMaximizeMainPanel(!1)})},f.prototype.listenAssetManagerOpen=function(e){var t=this;e.subscribe(CustomersCanvas.IframeApi.PostMessage.Events.AssetManagerOpened,function(){t.widget.toggleMaximizeMainPanel(!0)})};var d,H=f;function f(){return null!==d&&d.apply(this,arguments)||this}h=s,Object(v.d)(p,h),p.prototype.execute=function(n){return Object(v.b)(this,void 0,void 0,function(){var t,u=this;return Object(v.e)(this,function(e){switch(e.label){case 0:return[4,this.widget.customersCanvasPromise];case 1:return(t=e.sent(),n.url)?[4,t.eval(function(n){function r(e,t,n){if(!0!==e)return[n];for(var r=[],o=0,i=0;i<t.height;){for(;o<t.width;){var s=n.clone();s.transform.set_translateX(o),s.transform.set_translateY(i),s.locked=!0,r.push(s),o+=n.sourceWidth||n.source.width}o=0,i+=n.sourceHeight||n.source.height}return r}var e=spEditor.productHandler._app.configuration.appDomainUrl,t=spEditor.model.product,o=null,i=(o=null==n.surfaceIndex?t.getCurrentSurface():t.getSurfaces()[n.surfaceIndex]).getPrintAreas()[0],s=i.getContainers().find(function(e){return e.name===CustomersCanvas.Configuration.BG_CONTAINER_NAME}),t=s.getItems()[0],a=t.content;if(!n.url.startsWith("public:")&&!n.url.startsWith("private:"))return a.loadImageFromRemoteUrl(e,n.url).then(function(){this.isVector=!0,this.source&&(this.source.isVector=!0),n.autoResize&&(e=this,o.width=e.sourceRectangle.Width,o.height=e.sourceRectangle.Height,i.bounds.Width=o.width,i.bounds.Height=o.height);var e=r(n.toTile,o,this);s.setItems(e),spEditor.productHandler.updateView()}.bind(t)).catch(function(e){console.log("Sorry for a failure"),console.log(e)});var a=n.url,c=spEditor.configuration.userId||u.widget.userId||"default";Utils.ItemUtils.getImageMetaDataFromFile(e,a,c).then(function(e){var t;(n.url.endsWith(".pdf")||n.url.endsWith(".svg"))&&(e.isVector=!0),n.toTile?((t=this.content||this).sourceRectangle.Width=e.size.width,t.sourceRectangle.Height=e.size.height,t.setData(e),(n.url.endsWith(".pdf")||n.url.endsWith(".svg"))&&t.source&&(t.source.isVector=!0),t=r(n.toTile,o,t),s.setItems(t),spEditor.productHandler.updateView()):spEditor._widgetsController.changeBackground([o],e)}.bind(t)).catch(function(e){console.log("Sorry for a failure"),console.log(e)})},n)]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2,this.widget.getReady()]}})})};var h,V=p;function p(){return null!==h&&h.apply(this,arguments)||this}var C,J=t(36),L=(C=s,Object(v.d)(y,C),y.prototype.execute=function(i){return Object(v.b)(this,void 0,void 0,function(){var t,n,r,o;return Object(v.e)(this,function(e){switch(e.label){case 0:return[4,this.widget.customersCanvasPromise];case 1:return[4,e.sent().getProduct()];case 2:t=e.sent(),Object(J.a)(i)||(i=[i]),n=0,e.label=3;case 3:return n<i.length?(r=i[n],o=t.currentSurface,[4,(o="number"==typeof r.surfaceIndex?t.surfaces[r.surfaceIndex]:o).setPrintAreas([r.data],r.options)]):[3,6];case 4:t=e.sent(),e.label=5;case 5:return n++,[3,3];case 6:return[2,Promise.resolve()]}})})},y);function y(){return null!==C&&C.apply(this,arguments)||this}w=s,Object(v.d)(O,w),O.prototype.execute=function(t){return Object(v.b)(this,void 0,void 0,function(){return Object(v.e)(this,function(e){switch(e.label){case 0:return[4,this.widget.customersCanvasPromise];case 1:return[2,e.sent().eval(function(e){var r=this,o=spEditor.productHandler.product.getSurfaces();e.forEach(function(e){var t,n;e.url&&(n="number"==typeof e.surfaceIndex?o[e.surfaceIndex]:spEditor.productHandler.product.getCurrentSurface(),t=("up"===e.mockup.toLowerCase()?n.mockup.getUpContainers():n.mockup.getDownContainers())[0].getItems()[0])&&(n=r.window.location.href.split("/page/iframe")[0],e={url:e.url},$.ajax({method:"post",async:!1,url:n+"/api/ImagePicker/GetWebImageMeta",contentType:"application/json;charset=UTF-8",data:JSON.stringify(e),success:function(e){e=new CustomersCanvas.Model.ImageMetaData(e);e.size={width:e.size.width||e.width,height:e.size.height||e.height},e.name=t.name,spEditor._widgetsController.setImageData(t,e),spEditor.productHandler.updateView()}}))})},t)]}})})};var w,G=O;function O(){return null!==w&&w.apply(this,arguments)||this}I=s,Object(v.d)(P,I),P.prototype.execute=function(t){return Object(v.b)(this,void 0,void 0,function(){return Object(v.e)(this,function(e){switch(e.label){case 0:return"string"!=typeof t&&void 0!==t.theme||(t={theme:t}),[4,this.widget.customersCanvasPromise];case 1:return[4,e.sent().getProduct()];case 2:return[2,e.sent().applyProductTheme(t.theme)]}})})};var I,q=P;function P(){return null!==I&&I.apply(this,arguments)||this}j=s,Object(v.d)(x,j),x.prototype.execute=function(t){return Object(v.b)(this,void 0,void 0,function(){var u;return Object(v.e)(this,function(e){switch(e.label){case 0:return t&&t instanceof Array?[4,this.widget.customersCanvasPromise]:[3,3];case 1:return[4,e.sent().getProduct()];case 2:u=e.sent(),t.forEach(function(e,t){var n=Object.keys(e),r=Object.values(e),o=n.length,i=u.surfaces[t];if(i)for(var s=0;s<o;s++){var a=n[s],c=i.printAreas[0].getContainer(a);c?c.update(r[s]):console.warn("Container with name ".concat(a," was not found!"))}}),e.label=3;case 3:return[2]}})})};var j,Y=x;function x(){return null!==j&&j.apply(this,arguments)||this}S=s,Object(v.d)(_,S),_.prototype.execute=function(o,i){return Object(v.b)(this,void 0,void 0,function(){var t,n,r=this;return Object(v.e)(this,function(e){switch(e.label){case 0:return b.a.isEmptyObject(o)||b.a.isEmptyObject(o.every)&&b.a.isEmptyObject(o.items)?[2,Promise.resolve()]:[4,this.widget.customersCanvasPromise];case 1:return t=e.sent(),o.items=o.items||{},n=function(e,t){for(var n in e.items){var r=t.items[n],o=e.items[n];JSON.stringify(r)===JSON.stringify(o)&&!0!==o.force&&delete e.items[n]}return e},i&&(o=n(o,i)),n=function(b){return Object(v.b)(r,void 0,void 0,function(){var t,p,g,m,n,r,o,i,s,a,c=this;return Object(v.e)(this,function(e){switch(e.label){case 0:return(t=spEditor.model.product,t=t.getAllItems(),p=[],g=function(a){return Object(v.b)(c,void 0,void 0,function(){var t,n,r,o,i,s=this;return Object(v.e)(this,function(e){switch(e.label){case 0:return(t=function(e){e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return e?{A:255,R:parseInt(e[1],16),G:parseInt(e[2],16),B:parseInt(e[3],16)}:null},i=function(e){var e=Array.from(e.match(/\d+(\.\d+)?%?/g)),r=[];return e.map(function(e,t){var n=e.replace("%",""),n=Number(n);n<=1&&-1===e.indexOf("%")&&(n*=100),r[t]=n}),{C:255*r[0]/100,M:255*r[1]/100,Y:255*r[2]/100,K:255*r[3]/100,A:255*(r[4]||100)/100}},n=function(r){return Object(v.b)(s,void 0,void 0,function(){var t,n;return Object(v.e)(this,function(e){return t=encodeURIComponent(r.toString()),n=window.location.href.split("/page/iframe")[0],n=n+"/api/ColorConvertor/CmykToRgb/"+t+"/id/",[2,Ajax.request({url:n,type:Ajax.RequestType.post,headers:[Ajax.ContentType.json]}).then(function(e){return JSON.parse(e.value).value}).catch(function(e){console.error("failed to get color preview: "+e)})]})})},a.toLowerCase().startsWith("cmyk"))?(i=i(a),r=new Aurigma.GraphicsMill.AjaxControls.VectorObjects.CmykColor(i),o=r,[4,n(r)]):[3,2];case 1:return o.Preview=e.sent(),[2,r];case 2:return i=t(a),[2,new Aurigma.GraphicsMill.AjaxControls.VectorObjects.RgbColor(i)]}})})},i=function(d){return Object(v.b)(c,void 0,void 0,function(){var t,n,r,o,i,s,a,c,u,l;return Object(v.e)(this,function(e){switch(e.label){case 0:if(!(t=d.items.background)||!t.color)return[3,8];n=spEditor.model.product,e.label=1;case 1:e.trys.push([1,6,7,8]),r=Object(v.k)(n.getSurfaces()),o=r.next(),e.label=2;case 2:return o.done?[3,5]:(i=o.value,[4,g(t.color)]);case 3:s=e.sent(),c=i.getBackgroundItem(),a=spEditor.widgetsController;try{a._selectBgColor(c,s)}catch(e){a.selectBgColor(s)}e.label=4;case 4:return o=r.next(),[3,2];case 5:return[3,8];case 6:return c=e.sent(),u={error:c},[3,8];case 7:try{o&&!o.done&&(l=r.return)&&l.call(r)}finally{if(u)throw u.error}return[7];case 8:return[2]}})})},b&&b.items)?[4,i(b)]:[3,2];case 1:e.sent(),e.label=2;case 2:m=function(e){return e.placeholderContent&&e.tags&&e.tags.sourceData&&e.value===e.tags.sourceData.name},n=function(r){var o,t,n,i,s,a,c,u,l,d,f,h;return Object(v.e)(this,function(e){switch(e.label){case 0:return(o=Object(v.a)(Object(v.a)({},b.every),b.items[r.name]),0===Object.keys(o).length)?[2,"continue"]:(r instanceof CustomersCanvas.Model.Item&&(o.visualizationPermissions&&(null!=o.visualizationPermissions.noPrint&&(r.visualizationPermissions.noPrint=o.visualizationPermissions.noPrint),null!=o.visualizationPermissions.noShow)&&(r.visualizationPermissions.noShow=o.visualizationPermissions.noShow),null!=o.locked)&&(r.locked=o.locked),r instanceof CustomersCanvas.Model.PlaceholderItem&&("ImagePlaceholder"===o.type&&(m(o)?(n=CustomersCanvas.Utils.ItemUtils.getImageMetaDataFromUrl(spEditor.configuration.appDomainUrl,o.placeholderContent.originalUrl).then(function(e){r.content=new CustomersCanvas.Model.ImageItem,r.content.setData(e),r.content.updateRectangle(!1,r.contentResizeMode,r),r.content.tags=o.tags,r.isStubContent=!1;var t,e=r.getTransformedRectangle(),n=o.placeholderContent;e.Angle===n.placeholderRectangle.Angle&&e.Width===n.placeholderRectangle.Width&&e.Height===n.placeholderRectangle.Height&&e.CenterX===n.placeholderRectangle.CenterX&&e.CenterY===n.placeholderRectangle.CenterY&&(t=new(e=Aurigma.GraphicsMill.AjaxControls.VectorObjects.Math).RotatedRectangleF(n.placeholderRectangle.CenterX,n.placeholderRectangle.CenterY,n.placeholderRectangle.Width,n.placeholderRectangle.Height,n.placeholderRectangle.Angle),r.setTransformedRectangle(t),t=new e.RotatedRectangleF(n.contentRectangle.CenterX,n.contentRectangle.CenterY,n.contentRectangle.Width,n.contentRectangle.Height,n.contentRectangle.Angle),r.content.setTransformedRectangle(t))}),p.push(n)):r.isStubContent||(r.content=new CustomersCanvas.Model.ImageItem,r.content.setData(r.stubStorageMeta),r.isStubContent=!0),o.contentPermissions&&o.contentPermissions.imagePermissions&&(r.contentPermissions.imagePermissions.allowChangeImage=o.contentPermissions.imagePermissions.allowChangeImage,r.contentPermissions.imagePermissions.allowEditImage=o.contentPermissions.imagePermissions.allowEditImage),o.placeholderPermissions)&&(r.placeholderPermissions.allowEditContent=o.placeholderPermissions.allowEditContent,r.placeholderPermissions.showHandleButton=o.placeholderPermissions.showHandleButton,r.placeholderPermissions.showSelectButton=o.placeholderPermissions.showSelectButton),"BarcodePlaceholder"!==o.type||o.value||r.isStubContent||(r.content.setData(r.stubStorageMeta),r.isStubContent=!0)),r instanceof CustomersCanvas.Model.BaseTextItem?(null!=(t=o.text||o.value)&&(r.text=t),r.placeholders&&0<r.placeholders.length&&(r.placeholders.forEach(function(e){e.value=t}),r.value=t),o.font&&((n=o.font.leading||o.leading)&&(r.leading=n),(a=o.font.bold||o.font.fauxBold)&&(r.font.fauxBold=a),(a=o.font.italic||o.font.fauxItalic)&&(r.font.fauxItalic=a),(a=o.font.family||o.font.postScriptName)&&(r.font.postScriptName=a),o.font.size&&(r.font.size=o.font.size),o.font.underline&&(r.underline=o.font.underline),a=o.color||o.font.color)?(i=r,[4,g(a)]):[3,2]):[3,3]);case 1:i.color=e.sent(),e.label=2;case 2:!0===o.locked&&(r.textPermissions.allowChangeText=!1,r.textPermissions.allowChangeTextBIU=!1),r instanceof CustomersCanvas.Model.PlainTextItem&&(u=o.position||o.location)&&(d=l=0,r.alignment=CustomersCanvas.Model.BaseTextItem.TextAlignment.Left,l=(u=u||{x:0,y:0}).x||r.baselineLocation.X,d=u.y||r.baselineLocation.Y,r.baselineLocation=new Aurigma.GraphicsMill.AjaxControls.VectorObjects.Math.PointF(l,d)),(r instanceof CustomersCanvas.Model.BoundedTextItem||r instanceof CustomersCanvas.Model.AutoScaledTextItem)&&((u=o.position||o.location)||o.size)&&(h=f=d=l=0,l=(u=u||{x:0,y:0}).x||r.textRectangle.Left,d=u.y||r.textRectangle.Top,o.size||(o.size={width:0,height:0}),f=o.size.width||r.textRectangle.Width,h=o.size.height||r.textRectangle.Height,r.textRectangle.Width=f,r.textRectangle.Height=h,r.textRectangle.Left=l,r.textRectangle.Top=d),e.label=3;case 3:return r.type!==CustomersCanvas.Model.ShapeItem.type?[3,6]:(s=r,(a=o.color||o.fillColor)?(c=s,[4,g(a)]):[3,5]);case 4:c.fillColor=e.sent(),e.label=5;case 5:((u=o.position||o.location)||o.size)&&(h=f=d=l=0,l=(u=u||{x:0,y:0}).x||s.sourceRectangle.Left,d=u.y||s.sourceRectangle.Top,o.size||(o.size={width:0,height:0}),f=o.size.width||s.sourceRectangle.Width,h=o.size.height||s.sourceRectangle.Height,s.sourcePath=Aurigma.GraphicsMill.AjaxControls.VectorObjects.Math.Path.rectangle(l,d,f,h)),e.label=6;case 6:return[2]}})},e.label=3;case 3:e.trys.push([3,8,9,10]),r=Object(v.k)(t),o=r.next(),e.label=4;case 4:return o.done?[3,7]:(i=o.value,[5,n(i)]);case 5:e.sent(),e.label=6;case 6:return o=r.next(),[3,4];case 7:return[3,10];case 8:return s=e.sent(),s={error:s},[3,10];case 9:try{o&&!o.done&&(a=r.return)&&a.call(r)}finally{if(s)throw s.error}return[7];case 10:return[2,Promise.all(p).then(function(){return spEditor.productHandler.updateView(),spEditor.getCanvasViewer().get_canvas().waitWebServiceCalls()})]}})})},b.a.isEmptyObject(o.items),[4,this.widget.__methodExecuter(n,o)];case 2:return e.sent(),[4,this.applyUserInfo(t,o)];case 3:return(e.sent(),n=function(d){return Object(v.b)(r,void 0,void 0,function(){var t,n,r,o,i,s,a,c,u,l=this;return Object(v.e)(this,function(e){switch(e.label){case 0:t=function(r,o,i){return Object(v.b)(l,void 0,void 0,function(){var t,n;return Object(v.e)(this,function(e){return null==r||null==r.effect?[2,Promise.resolve()]:(t=window.location.href.split("/page/iframe")[0],t=t+"/api/ImageEditor/ProcessImage/",t=CustomersCanvas.Utils.urlCombine(t,i.storageId),n=new Aurigma.GraphicsMill.AjaxControls.VectorObjects.Effects.FiltersEffect(0,0,0,0,"grayscale"===r.effect.toLowerCase(),"sepia"===r.effect.toLowerCase()),n={effects:[n]},[2,Ajax.request({url:t,type:Ajax.RequestType.post,headers:[Ajax.ContentType.json],data:JSON.stringify(n)}).then(function(e){e=JSON.parse(e.value);o.setData(e)}).catch(function(e){console.error(e),console.error("Failed to apply effect "+e)})])})})},n=spEditor.model.product,n=n.getAllItems(),e.label=1;case 1:e.trys.push([1,6,7,8]),r=Object(v.k)(n),o=r.next(),e.label=2;case 2:return o.done?[3,5]:(a=o.value,!(i=d.items[a.name])||!i.effect||(s=null,a instanceof CustomersCanvas.Model.ImageItem&&(s=a),null===(s=a instanceof CustomersCanvas.Model.PlaceholderItem&&null!=a.content&&a.content.type==CustomersCanvas.Model.ImageItem.type?a.content:s))?[3,4]:[4,t(i,s,s.getImageMetaData())]);case 3:e.sent(),e.label=4;case 4:return o=r.next(),[3,2];case 5:return[3,8];case 6:return a=e.sent(),c={error:a},[3,8];case 7:try{o&&!o.done&&(u=r.return)&&u.call(r)}finally{if(c)throw c.error}return[7];case 8:return[2]}})})},o&&o.items)?[4,this.widget.__methodExecuter(n,o)]:[3,5];case 4:e.sent(),e.label=5;case 5:return[2,Promise.resolve()]}})})},_.prototype.applyUserInfo=function(l,d){return Object(v.b)(this,void 0,void 0,function(){var t,n,r,o,i,s,a,c,u=this;return Object(v.e)(this,function(e){t=function(e){return!!e.placeholderContent&&e.tags&&e.tags.sourceData&&e.value===e.tags.sourceData.name},n={};try{for(r=Object(v.k)(Object.keys(d.items)),o=r.next();!o.done;o=r.next())i=o.value,!(s=d.items[i]).value&&"Text"!==s.type&&"InString"!==s.type&&!s.image||"ImagePlaceholder"===s.type&&t(s)||("BarcodePlaceholder"===s.type?s.barcodeSubType&&"None"!==s.barcodeSubType?"Url"===s.barcodeSubType?n[i]={barcodeFormat:s.barcodeFormat,barcodeSubType:s.barcodeSubType,url:s.value}:"Phone"===s.barcodeSubType&&(n[i]={barcodeFormat:s.barcodeFormat,barcodeSubType:s.barcodeSubType,phone:s.value}):n[i]={barcodeFormat:s.barcodeFormat,barcodeValue:s.value}:n[i]=s.value||s.image)}catch(e){a={error:e}}finally{try{o&&!o.done&&(c=r.return)&&c.call(r)}finally{if(a)throw a.error}}return b.a.isEmptyObject(n)?[2,Promise.resolve()]:[2,l.loadUserInfo(n).then(function(){return u.widget.__methodExecuter(function(t){var e=spEditor.productHandler.getAllItems().filter(function(e){return-1!==t.indexOf(e.name)});spEditor.productHandler.updateItems(e)},Object.keys(n))}).catch(function(e){u.widget.showToast("Error: Invalid data"),console.log(e)})]})})};var S,X=_;function _(){return null!==S&&S.apply(this,arguments)||this}A=s,Object(v.d)(E,A),E.prototype.execute=function(t){return Object(v.b)(this,void 0,void 0,function(){return Object(v.e)(this,function(e){switch(e.label){case 0:return[4,this.widget.customersCanvasPromise];case 1:return[2,e.sent().eval(function(e){var t;void 0!==e.zoom&&spEditor.getCanvasViewer().set_zoom(e.zoom),void 0!==e.zoomMode&&(t=Aurigma.GraphicsMill.ZoomMode[e.zoomMode],spEditor.getCanvasViewer().set_zoomMode(void 0!==t?t:1)),void 0!==e.scrollPosition&&spEditor.getCanvasViewer().set_scrollingPosition(e.scrollPosition)},t)]}})})};var A,K=E;function E(){return null!==A&&A.apply(this,arguments)||this}var M,Z=t(539),R=t(2),Q=t(17),ee=t(540),N=t(537),D=t(598),te=(M=r,Object(v.d)(T,M),Object.defineProperty(T.prototype,"violationWarningData",{get:function(){return this._violationWarningData},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"boundsData",{get:function(){return this._boundsData},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"currentSurfaceName",{get:function(){return this._currentSurfaceName},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"proofImageUrls",{get:function(){return this._proofImageUrls},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"hiResUrls",{get:function(){return this._hiResUrls},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"stateId",{get:function(){return this._stateId},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"userId",{get:function(){return this._userId},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"userChanges",{get:function(){return this._userChanges},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"allItems",{get:function(){return this._allItems},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"variableData",{get:function(){return this._variableData},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"depositPhotos",{get:function(){return this._depositPhotos},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"tags",{get:function(){return this._tags},enumerable:!1,configurable:!0}),T.prototype.updateParams=function(e){var t;void 0!==e.initial&&(e.initial.editorConfig||(e.initial.editorConfig={}),e.initial.editorConfig.defaultLanguage=this.driver.config.language||"en",this.driver)&&(this._initialOrder=this._initialOrder||Object(N.a)(this.driver.orders.current),(t=this.driver.user.id)&&(e.initial.editorConfig.userId=t),(t=this.driver.user.tokenId)&&(e.initial.editorConfig.tokenId=t),(t=((t=this.auWizard.scopeInternal.widgetsData)&&t[this.name]?t[this.name]:this._initialOrder.data).stateId)&&""!==t&&(e.initial.productDefinition=t),e.initial.editorConfig.preloader={enabled:!1}),this.onChange=e.onChange?b.a.functionWrapperConstructor(e.onChange):function(){}},T.prototype.exportWidgetData=function(t){return Object(v.b)(this,void 0,void 0,function(){return Object(v.e)(this,function(e){switch(e.label){case 0:return!0!==t?[3,2]:[4,this.saveProduct()];case 1:e.sent(),e.label=2;case 2:return[2,{stateId:this._stateId}]}})})},T.prototype.restoreWidgetFromData=function(n,r){return void 0===r&&(r=!1),Object(v.b)(this,void 0,void 0,function(){var t;return Object(v.e)(this,function(e){switch(e.label){case 0:return!0!==r?[3,2]:((t=Object.assign({},(this.params||{}).initial||{})).productDefinition=n.stateId,[4,this.commands.initial.execute(t)]);case 1:e.sent(),e.label=2;case 2:return[2]}})})},T.prototype.updateParamsAsync=function(s){return Object(v.b)(this,void 0,void 0,function(){var t,n,r,o,i;return Object(v.e)(this,function(e){switch(e.label){case 0:return[4,M.prototype.updateParamsAsync.call(this,s)];case 1:if(e.sent(),0===(t=this._commandExecuter.getChangedActions(s,this._currentParams)).length)return[2,!1];-1!==t.indexOf("initial")&&(r=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,n=b.a.isNotNullOrUndefined(this._stateId)&&""!==this._stateId,(r=b.a.isNotNullOrUndefined(s.initial.productDefinition)&&s.initial.productDefinition.toString().match(r))&&(this._isRestoring=!0),n||r)&&(t=["initial"]),this.actionsFinished=!1,this._isRestoring||this.emitChange(),n=t&&1===t.length&&-1!==t.indexOf("initial"),this.showPreloader(!0,this.getPreloaderMessage(s,n)),this._currentParams=Object(N.a)(s),e.label=2;case 2:return e.trys.push([2,5,6,7]),this._isRestoring&&!n?[3,4]:[4,this._commandExecuter.executeActions(s,t,this._lastParams)];case 3:e.sent(),e.label=4;case 4:return[3,7];case 5:return r=e.sent(),this.params.actionsErrorToast&&!0===this.params.actionsErrorToast.show&&(o="widgets.canvas.actions.error",(i=this.localize(o))===o&&(i="Something went wrong. Send the website support team information about your browser and steps to reproduce the problem."),this.showToast(i,this.params.actionsErrorToast.duration)),this.logger.error(function(){return"Failed to perform an action on Customer's Canvas. "},r),[3,7];case 6:return this.resetPreloaderState(),this._lastParams=Object(N.a)(this._currentParams),this.actionsFinished=!0,this._isRestoring&&(this.getInitialParamsResolved(),this._isRestoring=!1),[7];case 7:return[2]}})})},T.prototype.forceUpdateCanvas=function(){return this.__methodExecuter(function(){spEditor.productHandler.getAllItems().map(function(e){return e.correspondingVObject}).forEach(function(e){return e.update()})})},T.prototype.connectedCallback=function(){var e=this;M.prototype.connectedCallback.call(this),this._commandExecuter=new ee.a(this.commands,this.uniqWidgetName,function(){return e.forceUpdateCanvas()},this),this.baseUrl=b.a.ensureEndsWith(this.driver.settings.customersCanvasBaseUrl,"/"),this.showPreloader(!0),this.iframeApiPromise=Z.a.loadCCScript(this.baseUrl,this.CC_SCRIPT_RELATIVE_PATH),this.iframeApiPromise.then(function(){e.showPreloader(!1),CustomersCanvas.IframeApi.editorUrl=e.baseUrl})},T.prototype.switchSurfaceTo=function(t){return this.customersCanvasPromise.then(function(e){return e.getProduct().then(function(e){return e.switchTo(e.surfaces[t])})})},T.prototype.removeSurface=function(r){return Object(v.b)(this,void 0,void 0,function(){var t,n;return Object(v.e)(this,function(e){switch(e.label){case 0:return[4,this.customersCanvasPromise];case 1:return[4,e.sent().getProduct()];case 2:return(t=e.sent(),r<0||r>t.surfaces.length-1)?(console.error("Invalid surface index: ".concat(r)),[2,t]):(n=t.surfaces[r],[4,t.removeSurface(n)]);case 3:return[2,e.sent()]}})})},T.prototype.addSurface=function(t,n){return Object(v.b)(this,void 0,void 0,function(){return Object(v.e)(this,function(e){switch(e.label){case 0:return[4,this.customersCanvasPromise];case 1:return[4,e.sent().getProduct()];case 2:return[4,e.sent().addSurface(t,n)];case 3:return[2,e.sent()]}})})},T.prototype.addSurfaces=function(t,n){return Object(v.b)(this,void 0,void 0,function(){return Object(v.e)(this,function(e){switch(e.label){case 0:return[4,this.customersCanvasPromise];case 1:return[4,e.sent().getProduct()];case 2:return[4,e.sent().addSurfaces(t,n)];case 3:return[2,e.sent()]}})})},T.prototype.updateSurfaces=function(n,r){return Object(v.b)(this,void 0,void 0,function(){var t;return Object(v.e)(this,function(e){switch(e.label){case 0:return[4,this.customersCanvasPromise];case 1:return[4,e.sent().getProduct()];case 2:switch(t=e.sent(),n.toLowerCase()){case"remove":return[3,3];case"add":return[3,5]}return[3,7];case 3:return[4,this.removeSurface(r)];case 4:return t=e.sent(),[3,7];case 5:return[4,this.addSurface(r)];case 6:return t=e.sent(),[3,7];case 7:return[2,t]}})})},T.prototype.fireChangeItemEvent=function(e){this.onChange(e)},T.prototype.updateModifiedItem=function(e){Object(D.a)(this.modifiedItem,e)||(this.modifiedItem=e,this.emitChange({modifiedItem:this.modifiedItem},!1))},T.prototype.updateOverallBounds=function(e){Object(D.a)(this.overallBounds,e)||(this.overallBounds=e,this.emitChange({overallBounds:this.overallBounds},!1))},T.prototype.updateCurrentSurfaceName=function(){var t=this;this.__methodExecuter(function(){return spEditor.model.product.getCurrentSurface().name}).then(function(e){return t._currentSurfaceName=e})},T.prototype.applyViewerSettings=function(t){return Object(v.b)(this,void 0,void 0,function(){return Object(v.e)(this,function(e){return[2,this.commands.setViewerSettings.execute(t)]})})},T.prototype.getProofImages=function(n,r){return void 0===n&&(n=800),void 0===r&&(r=800),Object(v.b)(this,void 0,void 0,function(){var t;return Object(v.e)(this,function(e){switch(e.label){case 0:return[4,this.customersCanvasPromise];case 1:return[4,e.sent().getProofImages({maxWidth:n,maxHeight:r})];case 2:return t=e.sent(),this._proofImageUrls=t.proofImageUrls.map(function(e){return e.map(function(e){return e})}),this.emitChange({urls:this.proofImageUrls},!1),[2,t.proofImageUrls.map(function(e){return e[0]})]}})})},T.prototype.getHiResImages=function(n,r,o,i){return void 0===n&&(n=800),void 0===r&&(r=800),Object(v.b)(this,void 0,void 0,function(){var t;return Object(v.e)(this,function(e){switch(e.label){case 0:return[4,this.customersCanva