!function(i){var t=acf.Field.extend({type:"repeater",wait:"",events:{'click a[data-event="add-row"]':"onClickAdd",'click a[data-event="remove-row"]':"onClickRemove",'click a[data-event="collapse-row"]':"onClickCollapse",showField:"onShow",unloadField:"onUnload",mouseover:"onHover",unloadField:"onUnload"},$control:function(){return this.$(".acf-repeater:first")},$table:function(){return this.$("table:first")},$tbody:function(){return this.$("tbody:first")},$rows:function(){return this.$("tbody:first > tr").not(".acf-clone")},$row:function(t){return this.$("tbody:first > tr:eq("+t+")")},$clone:function(){return this.$("tbody:first > tr.acf-clone")},$actions:function(){return this.$(".acf-actions:last")},$button:function(){return this.$(".acf-actions:last .button")},getValue:function(){return this.$rows().length},allowRemove:function(){var t=parseInt(this.get("min"));return!t||tthis.val()},addSortable:function(a){1!=this.get("max")&&this.$tbody().sortable({items:"> tr",handle:"> td.order",forceHelperSize:!0,forcePlaceholderSize:!0,scroll:!0,stop:function(t,e){a.render()},update:function(t,e){a.$input().trigger("change")}})},addCollapsed:function(){var e=a.load(this.get("key"));if(!e)return!1;this.$rows().each(function(t){-1 .order > span").html(t+1)}),0==this.val()?this.$control().addClass("-empty"):this.$control().removeClass("-empty"),this.allowAdd()?this.$button().removeClass("disabled"):this.$button().addClass("disabled")},validateAdd:function(){if(this.allowAdd())return!0;var t=this.get("max"),e=acf.__("Maximum rows reached ({max} rows)");return e=e.replace("{max}",t),this.showNotice({text:e,type:"warning"}),!1},onClickAdd:function(t,e){if(!this.validateAdd())return!1;e.hasClass("acf-icon")?this.add({before:e.closest(".acf-row")}):this.add()},add:function(a){if(!this.allowAdd())return!1;a=acf.parseArgs(a,{before:!1});var t=acf.duplicate({target:this.$clone(),append:this.proxy(function(t,e){a.before?a.before.before(e):t.before(e),e.removeClass("acf-clone"),acf.enable(e,this.cid),this.render()})});return this.$input().trigger("change"),t},validateRemove:function(){if(this.allowRemove())return!0;var t=this.get("min"),e=acf.__("Minimum rows reached ({min} rows)");return e=e.replace("{min}",t),this.showNotice({text:e,type:"warning"}),!1},onClickRemove:function(t,e){var a=e.closest(".acf-row");a.addClass("-hover");var i=acf.newTooltip({confirmRemove:!0,target:e,context:this,confirm:function(){this.remove(a)},cancel:function(){a.removeClass("-hover")}})},remove:function(t){var e=this;acf.remove({target:t,endHeight:0,complete:function(){e.$input().trigger("change"),e.render()}})},isCollapsed:function(t){return t.hasClass("-collapsed")},collapse:function(t){t.addClass("-collapsed"),acf.doAction("hide",t,"collapse")},expand:function(t){t.removeClass("-collapsed"),acf.doAction("show",t,"collapse")},onClickCollapse:function(t,e){var a=e.closest(".acf-row"),i=this.isCollapsed(a);t.shiftKey&&(a=this.$rows()),i?this.expand(a):this.collapse(a)},onShow:function(t,e,a){var i=acf.getFields({is:":visible",parent:this.$el});acf.doAction("show_fields",i)},onUnload:function(){var e=[];this.$rows().each(function(t){i(this).hasClass("-collapsed")&&e.push(t)}),e=e.length?e:null,a.save(this.get("key"),e)},onHover:function(){this.addSortable(this),this.off("mouseover")}});acf.registerFieldType(t),acf.registerConditionForFieldType("hasValue","repeater"),acf.registerConditionForFieldType("hasNoValue","repeater"),acf.registerConditionForFieldType("lessThan","repeater"),acf.registerConditionForFieldType("greaterThan","repeater");var a=new acf.Model({name:"this.collapsedRows",key:function(t,e){var a=this.get(t+e)||0;return a++,this.set(t+e,a,!0),1 .values")},$layouts:function(){return this.$(".acf-flexible-content:first > .values > .layout")},$layout:function(t){return this.$(".acf-flexible-content:first > .values > .layout:eq("+t+")")},$clonesWrap:function(){return this.$(".acf-flexible-content:first > .clones")},$clones:function(){return this.$(".acf-flexible-content:first > .clones > .layout")},$clone:function(t){return this.$('.acf-flexible-content:first > .clones > .layout[data-layout="'+t+'"]')},$actions:function(){return this.$(".acf-actions:last")},$button:function(){return this.$(".acf-actions:last .button")},$popup:function(){return this.$(".tmpl-popup:last")},getPopupHTML:function(){var t=this.$popup().html(),e=c(t),a=this.$layouts(),r=function(t){return a.filter(function(){return c(this).data("layout")===t}).length};return e.find("[data-layout]").each(function(){var t=c(this),e=t.data("min")||0,a=t.data("max")||0,i=t.data("layout")||"",n=r(i);if(a&&a<=n)t.addClass("disabled");else if(e&&n'+o+"")}}),t=e.outerHTML()},getValue:function(){return this.$layouts().length},allowRemove:function(){var t=parseInt(this.get("min"));return!t||tthis.val()},isFull:function(){var t=parseInt(this.get("max"));return t&&this.val()>=t},addSortable:function(a){1!=this.get("max")&&this.$layoutsWrap().sortable({items:"> .layout",handle:"> .acf-fc-layout-handle",forceHelperSize:!0,forcePlaceholderSize:!0,scroll:!0,stop:function(t,e){a.render()},update:function(t,e){a.$input().trigger("change")}})},addCollapsed:function(){var e=a.load(this.get("key"));if(!e)return!1;this.$layouts().each(function(t){-1','','
','
','',"
",'
',"
",'
','',"
",""].join(""),i=s(a);if(this.$collection().append(i),"prepend"===this.get("insert")){var n=this.$attachments().eq(e);n.length&&n.before(i)}this.renderAttachment(t),this.render(),this.$input().trigger("change")}},validateAttachment:function(t){if((t=acf.parseArgs(t,{id:"",url:"",alt:"",title:"",filename:"",type:"image"})).attributes){t=t.attributes;var e=acf.isget(t,"sizes","medium","url");null!==e&&(t.url=e)}return t},renderAttachment:function(t){t=this.validateAttachment(t);var e=this.$attachment(t.id);"image"==t.type?e.find(".filename").remove():(t.url=acf.isget(t,"thumb","src"),e.find(".filename").text(t.filename)),t.url||(t.url=acf.get("mimeTypeIcon"),e.addClass("-icon")),e.find("img").attr({src:t.url,alt:t.alt,title:t.title}),acf.val(e.find("input"),t.id)},editAttachment:function(t){var e=acf.newMediaPopup({mode:"edit",title:acf.__("Edit Image"),button:acf.__("Update Image"),attachment:t,field:this.get("key"),select:s.proxy(function(t,e){this.renderAttachment(t)},this)})},onClickEdit:function(t,e){var a=e.data("id");a&&this.editAttachment(a)},removeAttachment:function(t){this.closeSidebar(),this.$attachment(t).remove(),this.render(),this.$input().trigger("change")},onClickRemove:function(t,e){t.preventDefault(),t.stopPropagation();var a=e.data("id");a&&this.removeAttachment(a)},selectAttachment:function(a){var t=this.$attachment(a);if(!t.hasClass("active")){var e=this.proxy(function(){this.$side().find(":focus").trigger("blur"),this.$active().removeClass("active"),t.addClass("active"),this.openSidebar(),i()}),i=this.proxy(function(){var t={action:"acf/fields/gallery/get_attachment",field_key:this.get("key"),id:a};this.has("xhr")&&this.get("xhr").abort(),acf.showLoading(this.$sideData());var e=s.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(t),type:"post",dataType:"html",cache:!1,success:n});this.set("xhr",e)}),n=this.proxy(function(t){if(t){var e=this.$sideData();e.html(t),e.find(".compat-field-acf-form-data").remove(),e.find("> table.form-table > tbody").append(e.find("> .compat-attachment-fields > tbody > tr")),acf.doAction("append",e)}});e()}},onClickSelect:function(t,e){var a=e.data("id");a&&this.selectAttachment(a)},onClickClose:function(t,e){this.closeSidebar()},onChangeSort:function(t,e){var a=e.val();if(a){var i=[];this.$attachments().each(function(){i.push(s(this).data("id"))});var n=this.proxy(function(){var t={action:"acf/fields/gallery/get_sort_order",field_key:this.get("key"),ids:i,sort:a},e=s.ajax({url:acf.get("ajaxurl"),dataType:"json",type:"post",cache:!1,data:acf.prepareForAjax(t),success:o})}),o=this.proxy(function(t){acf.isAjaxSuccess(t)&&(t.data.reverse(),t.data.map(function(t){this.$collection().prepend(this.$attachment(t))},this))});n()}},onUpdate:function(t,e){var a=this.$(".acf-gallery-update");if(!a.hasClass("disabled")){var i=acf.serialize(this.$sideData());a.addClass("disabled"),a.before(' '),i.action="acf/fields/gallery/update_attachment",s.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(i),type:"post",dataType:"json",complete:function(){a.removeClass("disabled"),a.prev(".acf-loading").remove()}})}},onHover:function(){this.addSortable(this),this.off("mouseover")}});acf.registerFieldType(t),acf.registerConditionForFieldType("hasValue","gallery"),acf.registerConditionForFieldType("hasNoValue","gallery"),acf.registerConditionForFieldType("selectionLessThan","gallery"),acf.registerConditionForFieldType("selectionGreaterThan","gallery")}(jQuery);