"use strict";!function(e,t){e(t);elementor.on("panel:init",(function(){var t;(t=e("#ele-btl-styles-editor-dark")).length||(t=e("<link>",{id:"ele-btl-styles-editor-dark",rel:"stylesheet",href:EleBTLLocalized.dark_stylesheet_url})),elementor.settings.editorPreferences.model.on("change:ui_theme",(function(l,i){if("light"===i)return t.remove(),void e("<link>",{id:"ele-btl-styles",rel:"stylesheet",href:EleBTLLocalized.light_stylesheet_url}).appendTo(elementorCommon.elements.$body);t.attr("media","auto"===i?"(prefers-color-scheme: dark)":"").appendTo(elementorCommon.elements.$body)}))})),e(document).on("click",'a[id*="ele-btl-insert-media_"]',(function(t){t.preventDefault();let l=e(this),i=wp.media({title:"Add the Template preview",button:{text:"Insert"},multiple:!1});i.open(),i.on("select",(function(){let t=l.data("elebtlid");if(void 0===t)return;let n=i.state().get("selection").first().toJSON();e("a#ele-btl-insert-media_"+t+" > img").css("opacity",0),e("a#ele-btl-insert-media_"+t+" > span").addClass("btl-spinner"),e.post(ajaxurl,{post_id:t,thumbnail_id:n.id,action:"ele_btl_set_featured_image",nonce:EleBTLLocalized.nonce},(function(l){"ele-btl-ok"===l&&(e("a#ele-btl-insert-media_"+t).closest(".ele-btl-media-wrapper").removeClass("default"),e("a#ele-btl-insert-media_"+t+" > span").removeClass("btl-spinner"),e("a#ele-btl-insert-media_"+t+" > img").attr("src",n.url).css("opacity",1))}))}))})),e(document).on("click",'em[id*="ele-btl-delete-media_"]',(function(t){t.preventDefault();let l=e(this),i=l.data("elebtlid");void 0!==i&&(e("a#ele-btl-insert-media_"+i+" > img").css("opacity",0),e("a#ele-btl-insert-media_"+i+" > span").addClass("btl-spinner"),e.post(ajaxurl,{post_id:i,action:"ele_btl_delete_featured_image",nonce:EleBTLLocalized.nonce},(function(t){"ele-btl-ok"===t&&(e("a#ele-btl-insert-media_"+i+" > span").removeClass("btl-spinner"),l.remove(),e("a#ele-btl-insert-media_"+i+" > img").attr("src",EleBTLLocalized.dummy_url).css("opacity",1))})))}))}(jQuery,window);