!function(e){formintorjs.define(["admin/settings/setting"],function(e){return e.extend({className:"wpmudev-browse",events:{"click .wpmudev-open_media":"add_image","click .wpmudev-url--clear":"clear_image"},get_field_html:function(){return this.options.hasPreview?this.options.disableBrowse?'<div class="wpmudev-browse--preview"><button class="wpmudev-preview--image wpmudev-open_media"><span class="wpmudev-get_image" style="background-image: url('+this.get_saved_value()+');"></span></button><div class="wpmudev-preview--url"><input class="wpmudev-url--input" type="url" value="'+this.get_saved_value()+'" placeholder="'+Forminator.l10n.options.placeholder_image_alt+'" /><button class="wpmudev-url--clear">'+Forminator.l10n.options.clear+"</button></div></div>":this.options.previewOnly?'<div class="wpmudev-browse--preview"><button class="wpmudev-preview--image wpmudev-open_media"><span class="wpmudev-get_image" style="background-image: url('+this.get_saved_value()+');"></span></button></div>':'<div class="wpmudev-browse--preview"><div class="wpmudev-preview--image wpmudev-open_media"><div class="wpmudev-get_image" style="background-image: url('+this.get_saved_value()+');"></div></div><div class="wpmudev-preview--url"><input class="wpmudev-url--input" type="url" value="'+this.get_saved_value()+'" placeholder="'+Forminator.l10n.options.placeholder_image+'" /><button class="wpmudev-url--clear">'+Forminator.l10n.options.clear+'</button></div></div><button class="wpmudev-browse--action wpmudev-open_media">'+Forminator.l10n.options.browse+"</button>":'<div class="wpmudev-browse--preview"><div class="wpmudev-preview--url"><input class="wpmudev-url--input" type="url" value="'+this.get_saved_value()+'" placeholder="'+Forminator.l10n.options.placeholder_image+'" /><button class="wpmudev-url--clear">'+Forminator.l10n.options.clear+'</button></div></div><button class="wpmudev-browse--action wpmudev-open_media">'+Forminator.l10n.options.browse+"</button>"},add_image:function(e){e.preventDefault();var i=this,t=this.$el.find(".wpmudev-url--input"),a=wp.media({title:this.options.popup_label,button:{text:this.options.popup_button_label},multiple:!1}).on("select",function(){var e,s=a.state().get("selection").first().toJSON();if(s&&s.url){if(i.options.hasPreview){var l=i.$el.find(".wpmudev-browse--preview"),u=i.$el.find(".wpmudev-get_image");l.addClass("wpmudev-has_image"),u.css("background-image","url({url})".replace("{url}",s.url))}e=_.isUndefined(i.options.imageSize)?s.url:"thumbnail"===i.options.imageSize?s.sizes.thumbnail.url:"medium"===i.options.imageSize?s.sizes.medium.url:"large"===i.options.imageSize?s.sizes.large.url:s.sizes.full.url,t.val("{url}".replace("{url}",e)),i.save_value(e)}});a.open()},clear_image:function(e){e.preventDefault(),this.save_value(""),this.render()}})})}(jQuery);