!function(e){formintorjs.define(["admin/settings/multi-setting","admin/models/autofill-model","admin/models/autofills-collection","text!tpl/appearance.html"],function(t,i,l,a){return t.extend({multiple:!0,events:{"change .forminator-fields-autofill .forminator-autofill-provider":"update_autofill","change .forminator-fields-autofill .forminator-autofill-is-editable":"update_autofill","click .forminator-fields-autofill .wpmudev-action--text, .forminator-fields-autofill .wpmudev-toggle-field":"toggle_field"},className:"wpmudev-option",render:function(){this.$el.html(""),this.$el.append(this.build_autofill()),this.trigger("rendered",this.get_value()),this.on_render()},get_saved_value:function(){return this.model.get(this.name)},get_fields_with_autofill:function(){var e=Forminator.Utils.get_fields(this.model.get("wrappers"),[]),t=this.get_saved_value(),i=[];return _.each(e,function(e,l){var a=e.field_type,o=Forminator.Utils.get_field_autofill_providers(a),n=e.field_slug;if(_.has(o,n)&&!_.isUndefined(o[n].values)&&!_.isEmpty(o[n].values)){var d={element_id:"",provider:"",is_editable:"no"},r=t.findWhere({element_id:e.element_id}),s=!1;_.isUndefined(r)||_.isEmpty(r)||(d={element_id:r.get("element_id"),provider:r.get("provider"),is_editable:r.get("is_editable")},s=!0),e.selected_provider=d,e.is_active=s,e.autofill_providers=o[n].values,i.push(e)}}),i},build_autofill:function(){var t=this.get_fields_with_autofill(),i=this.model.get(this.name);return Forminator.Utils.template(e(a).find("#appearance-autofills-tpl").html())({fields_with_autofill:t,fields_autofill:i})},update_autofill:function(){var t=this,a=new l;this.$el.find(".forminator-autofill-provider").each(function(){var l=e(this),o=l.val();if(o){var n=l.data("element"),d=t.$el.find('.forminator-autofill-is-editable[data-element="'+n+'"]'),r=e(d).val();a.add(new i({element_id:n,provider:o,is_editable:r}),{silent:!0})}}),this.save_value(a),this.trigger("updated",a)},on_render:function(){},toggle_field:function(t){t.preventDefault();var i=e(t.target),l=i.closest(".wpmudev-multiname");e(l).toggleClass("wpmudev-is_active")}})})}(jQuery);