'use strict';(function(b,m,a,d){function r(){if(k[0].classList.contains("post-php")){const c=m.getElementById("post-lock-dialog");null===c||c.classList.contains("hidden")||Themify.LoadAsync(d.builder_url+"/js/editor/themify-ticks.js",function(){const e=TB_Ticks.init(d.ticks,window);k[0].classList.contains("tb_restriction")?e.show():e.ticks()},null,null,function(){return"undefined"!==typeof TB_Ticks})}if("function"===typeof window.icl_copy_from_original){function c(e,f){b.ajax({url:ajaxurl,type:"POST",
data:{action:"themify_builder_icl_copy_from_original",source_page_id:f,source_page_lang:e},success:function(h){if("-1"!=h){let l;try{l=b.parseJSON(h)||{}}catch(q){l={}}a.Forms.reLoad(l,d.post_ID)}}})}b.ajaxPrefilter(function(e,f,h){if(f.data&&"string"===typeof f.data&&f.data.includes("icl_ajx_action=copy_from_original")){const l=e.success,q=new URLSearchParams(f.data);e.success=function(t){const n=b("#tb_canvas_block");n.length&&n.hide().appendTo("body");l(t);n.length&&b('#editor [data-type="themify-builder/canvas"]').empty().append(n.show());
c(q.get("lang"),q.get("trid"))}}})}Themify.LoadAsync(d.builder_url+"/js/editor/themify-constructor.js",function(){ThemifyConstructor.getForms(a.render)},null,null,function(){return"undefined"!==typeof ThemifyConstructor})}const k=b("body");let g=!!d.is_gutenberg_editor,p=!1;if(0<b("#page-builder.themify_write_panel").length)g=!1,k[0].classList.remove("themify-gutenberg-editor");else if(!g)return;a.redirectFrontend=!1;a.toolbarCallback=function(){a.undoManager.btnUndo=a.toolbar.el.getElementsByClassName("tb_undo_btn")[0];
a.undoManager.btnRedo=a.toolbar.el.getElementsByClassName("tb_redo_btn")[0];a.undoManager.compactBtn=a.toolbar.el.getElementsByClassName("tb_compact_undo")[0];Themify.trigger("tf_toolbar_callback");Themify.body.triggerHandler("tf_toolbar_callback")};a.render=function(){var c=m.getElementById("tb_canvas_block");if(g&&!c)Themify.on("tb_canvas_loaded",a.render,!0);else{k[0].insertAdjacentHTML("afterbegin",'<div class="tb_fixed_scroll" id="tb_fixed_bottom_scroll"></div>');k.append(b("<div/>",{id:"tb_alert"}));
0===d.builder_data.length&&(d.builder_data={});g&&(c.innerHTML="",c.appendChild(m.getElementById("tmpl-builder_admin_canvas_block").content));ThemifyBuilderCommon.setToolbar();a.toolbar=new a.Views.Toolbar({el:"#tb_toolbar"});a.toolbar.render();a.toolbarCallback();a.Instances.Builder[0]=new a.Views.Builder({el:"#tb_row_wrapper",collection:new a.Collections.Rows(d.builder_data)});a.Instances.Builder[0].render();a.toolbar.pageBreakModule.countModules();var e=function(h){b(".themify_builder").find("input[required]").removeAttr("required");
p||(p=!0,g||(this.classList.remove("disabled"),h.preventDefault()),a.Utils.saveBuilder(function(){a.undoManager.reset();p=!1;if(g)b("button.editor-post-publish-button__button").one("click",e);else this.classList.remove("disabled"),this.click()}.bind(this)))};c=b('<a href="#" id="tb_switch_frontend_button" class="button tb_switch_frontend">'+d.i18n.switchToFrontendLabel+"</a>");var f=b(".themify-wp-editor-holder");b("input#publish,input#save-post,button.editor-post-publish-button__button").one("click",
e);f.length?c=f.find("a"):c.appendTo("#postdivrich #wp-content-media-buttons");c.on("click",function(h){h.preventDefault();b("#tb_switch_frontend").trigger("click")});b('input[name*="builder_switch_frontend"]').closest(".themify_field_row").remove();a.Instances.Builder[a.builderIndex].$el.triggerHandler("tb_init");sessionStorage.getItem("focusBackendEditor")&&(a._backendBuilderFocus(),sessionStorage.removeItem("focusBackendEditor"));ThemifyStyles.init(ThemifyConstructor.data,ThemifyConstructor.breakpointsReverse,
d.post_ID)}};a._backendSwitchFrontend=function(c){b("#builder_switch_frontend_noncename").val("ok");p=!0;"publish"===b("#original_post_status").val()?g?(b(".editor-post-publish-button").length?b(".editor-post-publish-button").trigger("click"):b(".editor-post-publish-panel__toggle").trigger("click"),a.redirectFrontend=c,b("#tb_switch_frontend").trigger("click.frontend-btn")):b("#publish").trigger("click"):g?(b(".editor-post-save-draft").trigger("click"),a.redirectFrontend=c):b("#save-post").trigger("click")};
a._backendBuilderFocus=function(){b("#page-buildert").trigger("click");g?a.Utils.scrollToDropped(a.toolbar.el):a.Utils.scrollTo(a.toolbar.$el.offset().top-b("#wpadminbar").height())};"complete"===m.readyState?r():window.addEventListener("load",r,{once:!0,passive:!0})})(jQuery,document,tb_app,themifyBuilder);
