var deferredET3,remove_option_code=minerva_configurator_vars.remove_option_code,not_available_option_code=minerva_configurator_vars.not_available_option_code,dummy_surface_code=remove_option_code.substr(0,remove_option_code.length-1),undoSelectedColors={},deferredET3Output={},pms_code=minerva_configurator_vars.pms_code,matches=minerva_configurator_vars.matches,constraints=minerva_configurator_vars.constraints,exceptionsType1=minerva_configurator_vars.exceptions_type1,exceptionsType2=minerva_configurator_vars.exceptions_type2,exceptionsType3=minerva_configurator_vars.exceptions_type3,exceptionsType4=minerva_configurator_vars.exceptions_type4,exceptionsType5=minerva_configurator_vars.exceptions_type5;function updateComponentsSurfaces(t,e,a){var o=is_defined(a)&&""!=a?a.split(","):[];getComponentCtxByDataAttribute([{dataAttribute:"component-type",attributeValue:"primary",dataRelation:"!="}]).each(function(a,r){var i=jQuery(r),n=i.data("component-type"),c=i.data("component-id"),s=(i.data("component-slug"),matches[t][c]);getComponentSurfacesCtx(i).each(function(t,e){var a=jQuery(e);checkSurfaceCompatibility(s,i,a)}),"optional"!=n?(resetActiveColor(i),setNewColor(e,o,i,null),jQuery('.color-message p[data-asset-color-code!="'+e+'"]',i).removeClass("active"),jQuery('.color-message p[data-asset-color-code="'+e+'"]',i).addClass("active")):"false"==getActiveSurfaceCtx(i).attr("data-visible")&&(resetActiveColor(i),setOptionalNewColor(o,i)),MixAndMatch(t,i),showColorLegend(i)})}function checkSurfaceCompatibility(t,e,a){e.data("component-type");var o=a.data("surface-code"),r=a.closest(".variant-item"),i=a.closest(".surface-wrapper");if(t.indexOf(o.toString())>=0)a.attr("data-visible","true").show(),i.show();else{if(r.length>0)0==getSurfaceCtxByDataAttribute([{dataAttribute:"visible",attributeValue:"true",dataRelation:"="}],!1,r).length&&i.hide();else i.hide();a.attr("data-visible","false").hide()}}function resetActiveColor(t){getActiveColorCtx(t).removeClass("active"),getActiveSurfaceCtx(t).removeClass("active")}function setActiveColor(t){t.length>1&&(t=jQuery(t[0])),resetActiveColor(getComponentCtx(t)),t.addClass("active"),getSurfaceCtx(t).addClass("active")}function setNewColor(t,e,a,o){a.data("component-slug");var r=getColorCtxByDataAttribute([{dataAttribute:"asset-color-code",attributeValue:t,dataRelation:"="}],a);r.length>0?setActiveColor(r):setAlternativeColor(e,a,null)}function setOptionalNewColor(t,e){(setAlternativeColor(t,e,null),0==getSurfaceCtxByDataAttribute([{dataAttribute:"visible",attributeValue:"true",dataRelation:"="}],!0,e).length)&&getColorCtxByDataAttribute([{dataAttribute:"color-code",attributeValue:dummy_surface_code,dataRelation:"^="}],e).each(function(t,e){if("true"==getSurfaceCtx(e).attr("data-visible"))return setActiveColor(jQuery(e)),!1})}function setAlternativeColor(t,e,a){var o,r=e.data("component-slug");t.length>0&&jQuery.each(t,function(t,i){var n;if(i.indexOf("|")>-1){var c=i.split("|")[0];if(n=i.split("|")[1],r!=c)return}else n=i;if(n.indexOf("_")>-1){if(null==a?(a=getSurfaceCtxByDataAttribute([{dataAttribute:"surface-code",attributeValue:n.split("_")[0],dataRelation:"="}],!1,e),o=a.length>0):o=n.split("_")[0]==a.data("surface-code").toString(),o){a.addClass("active"),getColorCtxByDataAttribute([{dataAttribute:"asset-color-code",attributeValue:n.split("_")[1],dataRelation:"*="}],a).addClass("active");var s=getPrimaryComponentCtx(),l=getActiveColorCtx(s);return getActiveColorCtx(a).attr("data-asset-color-code",l.attr("data-asset-color-code")).attr("data-original-title",l.attr("data-original-title")).css("background-color",l.css("background-color")).removeClass("btn-pms"),!1}}else{var d=getColorCtxByDataAttribute([{dataAttribute:"asset-color-code",attributeValue:n,dataRelation:"="}],e);if(d.length>0)return setActiveColor(d),!1}})}function showColorLegend(t){var e=getSurfaceCtxByDataAttribute([{dataAttribute:"visible",attributeValue:"true",dataRelation:"="}],!1,t),a=!1;e.each(function(t,e){var o=jQuery(e),r=getColorCtx(o),i=!0;return r.each(function(t,e){if(jQuery(e).hasClass("novelty"))return a=!0,i=!1,!1}),i}),a?jQuery(".color-legend",t).show():jQuery(".color-legend",t).hide()}function MixAndMatch(t,e){var a=e.data("component-id"),o=getActiveSurfaceCtx(e);constraints[t][a].indexOf("mm")>=0?(getColorCtx(o,!1).hide(),getColorCtx(o,!0).show()):getColorCtx(o).show()}function ET1(t,e){is_defined(t)||(t=!1);var a=getPrimaryComponentCtx(),o=a.data("component-id"),r=getActiveSurfaceCtx(a),i=r.data("surface-code"),n=getActiveColorCtx(r),c=n.data("asset-color-code"),s=n.data("alternative-color"),l=getComponentCtx(e),d=l.data("component-id");jQuery.each(exceptionsType1,function(e,a){var r=e,n=getComponentCtxByDataAttribute([{dataAttribute:"component-id",attributeValue:r,dataRelation:"="}]),u=getActiveSurfaceCtx(n),p=u.data("surface-code");jQuery.each(a,function(e,a){var n=a.ms,C=a.sc,v=a.ss,f=a.message,m=getComponentCtxByDataAttribute([{dataAttribute:"component-id",attributeValue:C,dataRelation:"="}]);if(n.indexOf(p.toString())>=0){t||d!=r||showComponentOptionsMessage(l,f),t||d!=o||resetComponentOptionsMessage();var g=arrayIntersect([matches[i][C],v]);getComponentSurfacesCtx(m).each(function(t,e){var a=jQuery(e);a.data("surface-code");checkSurfaceCompatibility(g,m,a)});var y=[],b=getColorCtx(u,!0),h=b.data("asset-color-code"),A=b.data("alternative-color");y.push(h),""!=A&&jQuery.merge(y,A.split(",")),y.push(c),""!=s&&jQuery.merge(y,s.split(",")),setAlternativeColor(y,m,null);var x=getSurfaceCtxByDataAttribute([{dataAttribute:"visible",attributeValue:"true",dataRelation:"="}],!0,m);0==x.length&&(x=jQuery(getSurfaceCtxByDataAttribute([{dataAttribute:"visible",attributeValue:"true",dataRelation:"="}],!1,m)[0]),resetActiveColor(m),setActiveColor(jQuery(getColorCtx(x)[0])))}})})}function ET2(t,e){is_defined(t)||(t=!1);var a=getPrimaryComponentCtx(),o=a.data("component-id"),r=getActiveSurfaceCtx(a),i=getActiveColorCtx(r).data("asset-color-code"),n=getComponentCtx(e).data("component-id");jQuery.each(exceptionsType2,function(e,a){var r=e,c=getComponentCtxByDataAttribute([{dataAttribute:"component-id",attributeValue:r,dataRelation:"="}]),s=getActiveSurfaceCtx(c).data("surface-code");jQuery.each(a,function(e,a){var c=a.ms,l=a.sc,d=a.mm,u=a.message,p=getComponentCtxByDataAttribute([{dataAttribute:"component-id",attributeValue:l,dataRelation:"="}]),C=getActiveSurfaceCtx(p);c.indexOf(s.toString())>=0&&("mm"==d?(t||n!=r||showComponentOptionsMessage(u),getActiveColorCtx(C).removeClass("active"),getColorCtxByDataAttribute([{dataAttribute:"asset-color-code",attributeValue:i,dataRelation:"!="}],C).hide(),getColorCtxByDataAttribute([{dataAttribute:"asset-color-code",attributeValue:i,dataRelation:"="}],C).show().addClass("active")):(t||n!=r||showComponentOptionsMessage(u),getColorCtx(C).show()),t||n!=o||resetComponentOptionsMessage())})})}function ET3(t){deferredET3=jQuery.Deferred();var e,a=t.attr("data-asset-color-code"),o=[],r=!1;if(jQuery.each(exceptionsType3,function(t,e){o.push(t)}),jQuery.each(o,function(t,a){if(a==colorCode||colorCode.indexOf(a)>-1)return r=!0,e=a,!1}),r){var i=exceptionsType3[e].action,n=getColorPaletteCtx(t).attr("data-palette-id"),c=getSurfaceCtx(t),s=c.attr("data-surface-id"),l=c.attr("data-surface-code"),d=(p=getComponentCtx(t)).attr("id");switch(i){case"message":getComponentsCtx().each(function(t,e){var o=jQuery(e);getComponentSurfacesCtx(o).each(function(t,e){var o=jQuery(e);o.attr("data-surface-code")==l&&getColorCtx(o).each(function(t,e){var r=jQuery(e).attr("data-asset-color-code");if(r==a){var i=jQuery(".color-message",o);if(0==jQuery('p[data-asset-color-code="'+r+'"]',i).length){var n=jQuery('

'+exceptionsType3[r].message+"

");i.append(n)}}})})});var u=jQuery(".color-message",c);jQuery('p[data-asset-color-code!="'+colorCode+'"]',u).removeClass("active"),jQuery('p[data-asset-color-code="'+colorCode+'"]',u).addClass("active"),deferredET3.resolve();break;case"function":switch(exceptionsType3[e].function){case"show_pms_colors":ShowPMSColors(d,s,n,a,deferredET3);break;default:deferredET3.resolve()}break;default:return!1}}else{var p=getComponentCtx(t);jQuery(".color-message p",p).removeClass("active"),deferredET3Output={},deferredET3.resolve()}return deferredET3.promise()}function ET4(){jQuery.each(exceptionsType4,function(t,e){var a=getComponentCtxByDataAttribute([{dataAttribute:"component-id",attributeValue:t,dataRelation:"="}]),o=getActiveSurfaceCtx(a).data("surface-code");jQuery.each(e,function(t,e){if(e.ms.indexOf(o.toString())>=0){var a=e.function,r=e.function_args.split(",");switch(a){case"move_print_area":jQuery.each(r,function(t,e){var a=e.split("|"),o=a[0],r=parseFloat(a[1]);MovePrintArea(o,r)})}}})})}function ShowPMSColors(t,e,a,o,r){var i={panelWrapperId:t,surfaceWrapperId:e,colorsWrapperId:a,colorCode:o};jQuery("#pms").attr("data-object",JSON.stringify(i)),pms_code!=o&&(jQuery(".pms-list li.active").removeClass("active"),jQuery('.pms-list li .selection span[data-asset-color-code="'+o+'"]').closest("li").addClass("active")),jQuery("#pms").modal("show"),jQuery(".pms-list .selection span").tooltip()}function saveSelectedColor(t,e,a,o,r,i){undoSelectedColors[t]={surfaceWrapperId:e,surfaceCode:a,colorsWrapperId:o,colorCode:r,alternativeColorCode:i}}function updatePrintAreas(){getComponentsCtx().each(function(t,e){var a=jQuery(e),o=(a.data("component-type"),a.data("component-id")),r=getActiveSurfaceCtx(a),i=r.data("surface-code"),n=getActiveColorCtx(r),c=(n.data("asset-color-code"),n.data("alternative-color"),getPrimaryComponentCtx());updateComponentPrintAreas(o,i,getActiveSurfaceCtx(c).data("surface-code"))})}function updateComponentPrintAreas(t,e,a){var o=jQuery(".selectpicker.nav-pills-printareas-tab-dropdown",getImprintMainCtx());if(0==printAreasAdvancedSettings.length){if(getPrintAreaTabCtxByDataAttribute([{dataAttribute:"component-id",attributeValue:t,dataRelation:"="}]).each(function(t,o){var r=jQuery(o).data("surface-codes");is_defined(r)&&(r=r.split(","),showHideElement(jQuery(o),e,a,r))}),o.length>0)getPrintAreaTabDropdownCtxByDataAttribute([{dataAttribute:"component-id",attributeValue:t,dataRelation:"="}]).each(function(t,o){var r=jQuery(o).data("surface-codes");is_defined(r)&&(r=r.split(","),enableDisableElement(jQuery(o),e,a,r))});jQuery('.pen-preview .print-area[data-component-id="'+t+'"]').each(function(t,o){var r=jQuery(o).data("surface-codes");is_defined(r)&&(r=r.split(","),jQuery.inArray(e,r)>-1||jQuery.inArray(a,r)>-1?jQuery(o).attr("data-visible",!0).show():jQuery(o).attr("data-visible",!1).hide())})}else jQuery.each(printAreasAdvancedSettings,function(t,e){var a=!0,r=getPrintAreaTabCtxByDataAttribute([{dataAttribute:"area-id",attributeValue:t,dataRelation:"="}]);if(o.length>0)var i=getPrintAreaTabDropdownCtxByDataAttribute([{dataAttribute:"area-id",attributeValue:t,dataRelation:"="}]);jQuery.each(e,function(t,e){var o=getComponentCtxByDataAttribute([{dataAttribute:"component-id",attributeValue:t,dataRelation:"="}]),r=getActiveSurfaceCtx(o).attr("data-surface-code");e=e.split(","),-1==jQuery.inArray(r,e)&&(a=!1)}),a?(r.attr("data-visible",!0).show(),o.length>0&&i.attr("data-visible",!0).prop("disabled",!1),jQuery('.pen-preview .print-area[data-area-id="'+t+'"]').attr("data-visible",!0).show()):(r.attr("data-visible",!1).hide(),o.length>0&&i.attr("data-visible",!1).prop("disabled",!0),jQuery('.pen-preview .print-area[data-area-id="'+t+'"]').attr("data-visible",!1).hide())});var r=getActivePrintAreaTabCtx(),i=r.data("area-id");r.length>0&&"false"==r.attr("data-visible")?getPrintAreaTabCtxByDataAttribute([{dataAttribute:"visible",attributeValue:"true",dataRelation:"="}]).first().trigger("click"):r.trigger("click"),o.length>0&&(o.selectpicker("refresh"),o.selectpicker(printAreasSelectPickerOptions),updatePrintAreasCompleted()),jQuery('.pen-preview .print-area[data-area-id="'+i+'"]').addClass("active")}function showHideElement(t,e,a,o){jQuery.inArray(e,o)>-1||jQuery.inArray(a,o)>-1&&-1==e.indexOf(dummy_surface_code)?t.attr("data-visible",!0).show():t.attr("data-visible",!1).hide()}function enableDisableElement(t,e,a,o){jQuery.inArray(e,o)>-1||jQuery.inArray(a,o)>-1&&-1==e.indexOf(dummy_surface_code)?t.attr("data-visible",!0).prop("disabled",!1):t.attr("data-visible",!1).prop("disabled",!0)}function updatePrintAreasCompleted(){var t=jQuery(".selectpicker.nav-pills-printareas-tab-dropdown",getImprintMainCtx());if(t.length>0){if(null==t.selectpicker("val")){var e=getPrintAreaFirstAvailableOptionCtx();t.selectpicker("val",e.attr("value"))}t.selectpicker("refresh"),t.selectpicker(printAreasSelectPickerOptions),t.trigger("change")}}function updateWritingSystemOptions(){var t=getRefillOptionsCtx(),e=getSelectedRefillCtx(t).data("refill-id");getRefillCtx(0,t).each(function(a,o){var r=getRefillContainerCtx(jQuery(o),"parent"),i=jQuery(o).data("refill-id"),n=getInkColorOptionsCtx(t,i),c=getRefillDiameterOptionsCtx(t),s=0;i==e?r.addClass("active"):r.removeClass("active"),n.each(function(t,e){var a=jQuery(e);a.data("refill-id")==i&&(s=getActiveInkColorCtx(a).data("option"))}),c.each(function(t,e){var a=jQuery(e);a.data("refill-id")==i&&(getRefillDiameterOptionCtx(s,"!=",a).hide(),getRefillDiameterOptionCtx(s,"=",a).show())})})}function writingSystemAdvancedSettings(t,e){if(refillsAdvancedSettings.length>0&&is_defined(refillsAdvancedSettings[t])){var a=refillsAdvancedSettings[t],o=getRefillOptionsCtx();jQuery.each(a,function(t,a){if(jQuery.inArray(e,a.surfaces)>-1){var r=a.refill_id,i=a.refill_color,n=a.refill_diameter,c=getRefillCtx(r),s=getInkColorCtxByDataAttribute(r,i),l=s.data("option"),d=getRefillDiameterOptionCtx(l,"=",getRefillDiameterOptionsCtx(o,r)),u=getRefillDiameterCtx(n,d);c.trigger("click"),s.trigger("click"),u.trigger("click")}})}}function updateTextColorPalette(){var t=getPrintAreaTabsCtx();jQuery(".ancestor-tab",t).each(function(t,e){var a=jQuery(e),o=a.data("component-id"),r=getComponentCtxByDataAttribute([{dataAttribute:"component-id",attributeValue:o,dataRelation:"="}]),i=getActiveSurfaceCtx(r).data("surface-code");getPrintAreaTabCtxByAttribute([{attributeType:"id",attributeValue:"text-",dataRelation:"^="}],a).each(function(t,e){var a=jQuery(e);jQuery(".colors-list",a).each(function(t,e){var o=jQuery(e),r=o.data("surface-codes").split(","),n=jQuery("li.active",o),c=jQuery(".selection span",n),s=c.attr("data-color-hexcode"),l=is_defined(c.attr("data-original-title"))?c.attr("data-original-title"):c.attr("title");jQuery.inArray(i,r)>-1?(o.attr("data-visible",!0),jQuery(".font-color",a).attr("data-color-hexcode",s).attr("data-color-label",l)):o.attr("data-visible",!1)})})})}function removeOptionHandler(){getComponentCtxByDataAttribute([{dataAttribute:"component-type",attributeValue:"optional",dataRelation:"="}]).each(function(t,e){var a=jQuery(e),o=getActiveSurfaceCtx(a).data("surface-code"),r=getRemoveOptionSwitch(a),i=getComponentSurfacesCtx(a,!0);remove_option_code!=o||r.prop("checked")||(r.prop("checked",!0),jQuery.each(i,function(t,e){jQuery(e).hasClass("not-available-surface")||jQuery(e).addClass("disabled")})),remove_option_code!=o&&r.prop("checked",!1)})}function reorderComponentsOptions(){var t=getPrimaryComponentCtx(),e=getComponentSurfacesCtx(t),a=getComponentCtxByDataAttribute([{dataAttribute:"component-type",attributeValue:"primary",dataRelation:"!="}]);1==e.length&&e.closest(".surface-wrapper").removeClass("col-lg-6"),a.each(function(t,e){var a=jQuery(e),o=getSurfaceCtxByDataAttribute([{dataAttribute:"visible",attributeValue:"true",dataRelation:"="},{dataAttribute:"surface-code",attributeValue:remove_option_code,dataRelation:"!="}],!1,a);o.length>1?o.each(function(t,e){jQuery(e).closest(".surface-wrapper").addClass("col-lg-6")}):o.each(function(t,e){jQuery(e).closest(".surface-wrapper").removeClass("col-lg-6")})});(a=getComponentCtxByDataAttribute([{dataAttribute:"component-type",attributeValue:"null",dataRelation:"!="},{dataAttribute:"remove-option",attributeValue:"false",dataRelation:"="}])).each(function(t,e){var a=jQuery(e),o=getSurfaceCtxByDataAttribute([{dataAttribute:"visible",attributeValue:"true",dataRelation:"="}],!1,a);jQuery(".last",o).removeClass("last"),(o=o.length%2==0?jQuery(o.slice(-2)):jQuery(o[o.length-1])).each(function(t,e){jQuery(e).closest(".surface-wrapper").addClass("last")})});var o=getRefillContainerCtx();jQuery(".last",o).removeClass("last"),(o=o.length%2==0?jQuery(o.slice(-2)):jQuery(o[o.length-1])).each(function(t,e){jQuery(e).closest(".writing-system-wrapper").addClass("last")})}function showComponentOptionsMessage(t,e){jQuery(".warning-message-container",t).html(e)}function resetComponentOptionsMessage(){jQuery(".warning-message-container").html("")}function closeActivePanel(){jQuery(".component-options.active").hasClass("refill-options")&&jQuery(".refill-options .options-content").animate({scrollLeft:0},245),jQuery(".component-options.active").removeClass("active"),jQuery(".component-selector.active").removeClass("active"),jQuery(".component-selector.disabled").removeClass("disabled"),jQuery(".component-options-backdrop").fadeOut(200)}function openPanel(t){var e=t.closest(".config-controls"),a=t.data("component-slug");t.addClass("active"),e.addClass("active"),jQuery(".component-selector:not(.active)",e).addClass("disabled"),jQuery(".component-options-backdrop").fadeIn(200),getComponentCtxByDataAttribute([{dataAttribute:"component-slug",attributeValue:a,dataRelation:"="}],!1).addClass("active")}function updateQRCodes(){var t=getPrintAreaTabsCtx();jQuery(".ancestor-tab",t).each(function(t,e){var a=jQuery(e),o=a.data("component-id"),r=getComponentCtxByDataAttribute([{dataAttribute:"component-id",attributeValue:o,dataRelation:"="}]),i=getActiveSurfaceCtx(r).data("surface-code");getPrintAreaTabCtxByAttribute([{attributeType:"id",attributeValue:"qrcode-",dataRelation:"^="}],a).each(function(t,e){var a=jQuery(e);jQuery(".qrcodes-grid .item",a).each(function(t,e){var a=jQuery(e),o=a.data("surface-codes").split(",");jQuery.inArray(i,o)>-1?a.attr("data-visible",!1).hide():a.attr("data-visible",!0).show()})})})}jQuery(document).ready(function(t){t("body").on("click",".surface-container .colors-list .color-item",function(e){var a=jQuery(this),o=getComponentCtx(a),r=getActiveSurfaceCtx(o),i=getActiveColorCtx(r),n=getColorPaletteCtx(i);saveSelectedColor(o.attr("id"),r.data("surface-id"),r.data("surface-code"),n.data("palette-id"),i.attr("data-asset-color-code"),i.attr("data-alternative-color")),resetActiveColor(o);var c=getSurfaceCtx(a).data("surface-code"),s=a;setActiveColor(a);var l=s.attr("data-asset-color-code"),d=s.attr("data-alternative-color"),u=s.data("component-type"),p=s.data("component-id"),C=getPrimaryComponentCtx(),v=getActiveSurfaceCtx(C).data("surface-code");jQuery.when(ET3(s)).done(function(){t.isEmptyObject(deferredET3Output)||(c=deferredET3Output.surfaceCode,l=deferredET3Output.colorCode,d=deferredET3Output.alternativeColor),"primary"==u&&updateComponentsSurfaces(c,l,d);var e=t.map(exceptionsType1,function(t,e){return parseInt(e)});("primary"==u||t.inArray(p,e)>-1)&&ET1(!1,s),e=t.map(exceptionsType2,function(t,e){return parseInt(e)}),("primary"==u||t.inArray(p,e)>-1)&&ET2(!1,s),e=t.map(exceptionsType4,function(t,e){return parseInt(e)}),t.inArray(p,e)>-1&&ET4(),removeOptionHandler(),reorderComponentsOptions(),writingSystemAdvancedSettings(p,c),updateComponentPrintAreas(p,c,v),getComponentCtxByDataAttribute([{dataAttribute:"component-id",attributeValue:p,dataRelation:"!="},{dataAttribute:"component-type",attributeValue:"primary",dataRelation:"!="}]).each(function(e,a){var o=t(a);updateComponentPrintAreas(o.data("component-id"),getActiveSurfaceCtx(o).data("surface-code"),v)}),updatePrintAreasCompleted(),updateTextColorPalette(),updateQRCodes(),refreshPreview(),updateConfigurationRecap(),closeActivePanel(o)})}),t("body").on("change",'input[name="refill"]',function(t){updateWritingSystemOptions(),refreshPreview(),updateConfigurationRecap()}),t("body").on("click",".ink-colors-list li",function(e){var a=t(this),o=getInkColorCtx(a);getActiveInkColorCtx(o).removeClass("active"),a.addClass("active"),updateWritingSystemOptions(),updateConfigurationRecap()}),t("body").on("change",'input[name^="diameter-"]',function(t){updateConfigurationRecap()}),t("body").on("click",".refill-colors-list li",function(e){var a=t(this),o=getRefillColorCtx(a);getActiveRefillColorCtx(o).removeClass("active"),a.addClass("active"),refreshPreview(),updateConfigurationRecap()}),t("body").on("change",".remove-option-switch",function(e){var a=t(this),o=getSurfaceCtx(a),r=getComponentCtx(a),i=getSurfaceCtxByDataAttribute([{dataAttribute:"surface-code",attributeValue:"XXX",dataRelation:"!="}],!1,r);a.prop("checked")&&!o.hasClass("active")&&t(getColorCtx(o)[0]).trigger("click"),a.prop("checked")?jQuery.each(i,function(t,e){jQuery(e).hasClass("not-available-surface")||jQuery(e).addClass("disabled")}):i.removeClass("disabled")}),t(".component-options-backdrop").on("click",function(){closeActivePanel(getActiveComponentCtx())}),t(".component-options .close-panel").on("click",function(){closeActivePanel()}),t("button.component-selector").on("click",function(){var e=t(this);e.hasClass("disabled")||e.hasClass("active")?e.hasClass("active")?closeActivePanel():(closeActivePanel(),openPanel(e)):openPanel(e)}),t(".config-controls button.component-selector").hover(function(){t(this).hasClass("disabled")||t('.config-controls button.component-selector[data-component-id!="'+t(this).data("component-id")+'"]').addClass("disabled")},function(){t(this).hasClass("active")||t(this).hasClass("disabled")||t('.config-controls button.component-selector[data-component-id!="'+t(this).data("component-id")+'"]').removeClass("disabled")}),t("#pms #search").hideseek(),t("#pms").on("show.bs.modal",function(e){t(".pms-list li.active").removeClass("active");var a=t(".tab-pane-c.active").attr("id"),o=(undoSelectedColors[a].colorCode,undoSelectedColors[a].surfaceCode,t(".tab-pane-c.active .surface-item.active").data("surface-code"),t(".tab-pane-c.active .surface-item.active .colors-list li.active .selection span").attr("data-asset-color-code"));o!=pms_code&&t('.pms-list li .selection span[data-asset-color-code="'+o+'"]').closest("li").addClass("active")}),t("body").on("click","ul.pms-list li",function(e){var a=JSON.parse(t("#pms").attr("data-object")),o=a.panelWrapperId,r=a.surfaceWrapperId,i=a.colorsWrapperId,n=a.colorCode,c=t('.tab-pane-c[id="'+o+'"]'),s=t('.surface-item[data-surface-id="'+r+'"]',c),l=t('.colors-list[data-palette-id="'+i+'"]',s),d=t('span[data-asset-color-code="'+n+'"]',l).closest("li"),u=t(this),p=t(".selection span",u).attr("data-asset-color-code"),C=t(".selection span",u).attr("data-original-title"),v=t(".selection span",u).css("background-color");t(".pms-list li.active").removeClass("active"),u.addClass("active"),t(".selection span",d).attr("data-asset-color-code",p),t(".selection span",d).attr("title",C).attr("data-original-title",C),t(".selection span",d).css("background-color",v),d.removeClass("btn-pms"),deferredET3Output={surfaceCode:s.attr("data-surface-code"),color:p,alternativeColor:t(".selection span",d).attr("data-alternative-color")},t("#pms").modal("hide")}),t("#pms").on("hide.bs.modal",function(e){if(0==t(".pms-list li.active").length){var a=t(".tab-pane-c.active"),o=a.attr("id"),r=undoSelectedColors[o].surfaceWrapperId,i=t('.surface-item[data-surface-id="'+r+'"]',a);t(".colors-list li.active",a).removeClass("active"),t(".surface-item.active",a).removeClass("active"),i.addClass("active");var n=undoSelectedColors[o].colorsWrapperId,c=t('.colors-list[data-palette-id="'+n+'"]',i),s=undoSelectedColors[o].colorCode;t('[data-asset-color-code="'+s+'"]',c).closest("li").addClass("active"),deferredET3Output={surfaceCode:undoSelectedColors[o].surfaceCode,color:undoSelectedColors[o].colorCode,alternativeColor:undoSelectedColors[o].alternativeColorCode}}else t(".pms-list li.active").removeClass("active")}),t("#pms").on("hidden.bs.modal",function(t){deferredET3.resolve()})});