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