")}return c.actions.unshift(f),t})),t}return(0,f.default)(Module,t),(0,i.default)(Module,[{key:"onElementorInit",value:function onElementorInit(){var t=this;elementor.hooks.addFilter("views/add-section/behaviors",this.registerAiLayoutBehavior),elementor.hooks.addFilter("elements/container/contextMenuGroups",this.registerVariationsContextMenu),elementor.hooks.addFilter("elementor/editor/template-library/template/behaviors",this.registerLibraryActionButtonBehavior),elementor.hooks.addFilter("elementor/editor/template-library/template/action-button",this.filterLibraryActionButtonTemplate,11),$e.commands.register("library","generate-ai-variation",(function(n){return t.applyTemplate(n)}))}},{key:"applyTemplate",value:function applyTemplate(t){window.postMessage({type:"library/attach:start"}),$e.components.get("library").downloadTemplate(t,(function(n){var o=t.model;window.postMessage({type:"library/attach",json:n.content[0],html:'
'),label:"".concat(o.get("template_id")," - ").concat(o.get("title")),source:b.ELEMENTOR_LIBRARY_SOURCE},window.location.origin)}))}},{key:"registerLibraryActionButtonBehavior",value:function registerLibraryActionButtonBehavior(t){return t.applyAiTemplate={behaviorClass:_.default},t}},{key:"registerAiLayoutBehavior",value:function registerAiLayoutBehavior(t){return t.ai={behaviorClass:h.default,context:{documentType:window.elementor.documents.getCurrent().config.type}},t}},{key:"filterLibraryActionButtonTemplate",value:function filterLibraryActionButtonTemplate(t){var n=$e.components.get("library").manager.modalConfig;return"#tmpl-elementor-template-library-insert-button"!==t||"library/templates/blocks"!==$e.routes.current.library?t:t=w===n.mode?"#tmpl-elementor-template-library-apply-ai-button":"#tmpl-elementor-template-library-insert-and-ai-variations-buttons"}}])}(elementorModules.editor.utils.Module))})()})();