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