(function(e){e(function(){e.fn.wpColorPicker&&e(".kutby-color-picker").wpColorPicker();var n,o=window.kutbyAdmin&&kutbyAdmin.i18n||{};e(document).on("click",".kutby-media-field__select",function(i){i.preventDefault();var t=e(this).closest(".kutby-media-field"),a=t.find(".kutby-media-field__input"),u=t.find(".kutby-media-field__preview"),l=t.find(".kutby-media-field__remove");if(n){n.open();return}n=wp.media({title:o.selectImage||"اختيار صورة",button:{text:o.useImage||"استخدام هذه الصورة"},multiple:!1}),n.on("select",function(){var d=n.state().get("selection").first().toJSON();a.val(d.id);var r=d.sizes&&d.sizes.medium?d.sizes.medium.url:d.url;u.html('<img src="'+r+'" alt="" />'),l.prop("hidden",!1),t.find(".kutby-media-field__select").text(o.change||"تعديل")}),n.open()}),e(document).on("click",".kutby-media-field__remove",function(i){i.preventDefault();var t=e(this).closest(".kutby-media-field");t.find(".kutby-media-field__input").val(""),t.find(".kutby-media-field__preview").empty(),t.find(".kutby-media-field__select").text(o.select||"اختيار صورة"),e(this).prop("hidden",!0)}),e(document).on("click",".kutby-notice__dismiss",function(i){i.preventDefault(),e(this).closest("[data-kutby-notice]").remove()}),e(document).on("animationend",".kutby-notice.is-autohide",function(){e(this).remove()}),e(document).on("click","[data-kutby-dropdown] .kutby-ui-dropdown__trigger",function(i){i.preventDefault();var t=e(this).closest("[data-kutby-dropdown]");t.toggleClass("is-open"),t.find(".kutby-ui-dropdown__menu").prop("hidden",!t.hasClass("is-open"))}),e(document).on("click","[data-kutby-modal-close]",function(i){i.preventDefault(),e(this).closest("[data-kutby-modal]").removeClass("is-open").attr("hidden",!0)}),e(document).on("click",'#kutby-open-demo-modal, [data-action="open-modal"]',function(i){i.preventDefault();var t=e("#kutby-demo-modal");t.length&&t.removeAttr("hidden").addClass("is-open")})})})(jQuery);
