(()=>{var e="[data-bulk-action-checkbox]",t="[data-bulk-action-select-all-checkbox]",c="[data-bulk-action-footer]",n="[data-bulk-action-num-objects]",o="[data-bulk-action-num-objects-in-listing]",a={checkedObjects:new Set,numObjects:0,selectAllInListing:!1,shouldShowAllInListingText:!0};function r(e){return wagtailConfig.STRINGS.BULK_ACTIONS[wagtailConfig.BULK_ACTION_ITEM_TYPE]?wagtailConfig.STRINGS.BULK_ACTIONS[wagtailConfig.BULK_ACTION_ITEM_TYPE][e]:wagtailConfig.STRINGS.BULK_ACTIONS.ITEM[e]}function d(n){document.querySelectorAll(t).forEach((function(e){e.checked=n.target.checked}));var o=new Event("change");document.querySelectorAll(e).forEach((function(e){e.checked!==n.target.checked&&(e.checked=n.target.checked,n.target.checked?e.dispatchEvent(o):e.classList.remove("show"))})),n.target.checked||(a.checkedObjects.clear(),document.querySelector(c).classList.add("hidden"))}function l(d){a.selectAllInListing&&(a.selectAllInListing=!1);var l=a.checkedObjects.size;d.target.checked?a.checkedObjects.add(Number(d.target.dataset.objectId)):(document.querySelectorAll(t).forEach((function(e){e.checked=!1})),a.checkedObjects.delete(Number(d.target.dataset.objectId)));var i=a.checkedObjects.size;if(0===i?(document.querySelector(c).classList.add("hidden"),document.querySelectorAll(e).forEach((function(e){return e.classList.remove("show")}))):1===i&&0===l&&(document.querySelectorAll(e).forEach((function(e){e.classList.add("show")})),document.querySelector(c).classList.remove("hidden")),i===a.numObjects?(document.querySelectorAll(t).forEach((function(e){e.checked=!0})),a.shouldShowAllInListingText&&document.querySelector(o).classList.remove("u-hidden")):a.shouldShowAllInListingText&&document.querySelector(o).classList.add("u-hidden"),i>0){var u;u=1===i?r("SINGULAR"):i===a.numObjects?r("ALL").replace("{0}",i):r("PLURAL").replace("{0}",i),document.querySelector(n).textContent=u}}function i(e){e.preventDefault(),a.selectAllInListing=!0,document.querySelector(n).textContent="".concat(r("ALL_IN_LISTING"),"."),document.querySelector(o).classList.add("u-hidden")}function u(e){e.preventDefault();var t=e.target.getAttribute("href"),c=new URLSearchParams(window.location.search);if(a.selectAllInListing){c.append("id","all");var n=document.querySelector("[data-bulk-action-parent-id]");if(n){var o=n.dataset.bulkActionParentId;c.append("childOf",o)}}else a.checkedObjects.forEach((function(e){c.append("id",e)}));window.location.href="".concat(t,"&").concat(c.toString())}document.addEventListener("DOMContentLoaded",(function(){var n=new Event("change");document.querySelectorAll(e).forEach((function(e){a.numObjects++,e.addEventListener("change",l)})),document.querySelectorAll(t).forEach((function(e){e.addEventListener("change",d)})),document.querySelectorAll("".concat(c," .bulk-action-btn")).forEach((function(e){return e.addEventListener("click",u)}));var r=document.querySelector(o);r?r.addEventListener("click",i):a.shouldShowAllInListingText=!1,document.querySelectorAll(e).forEach((function(e){e.checked&&e.dispatchEvent(n)}))})),window.headerSearch&&document.querySelector(window.headerSearch.termInput).addEventListener("search-success",(function(){document.querySelectorAll(t).forEach((function(e){e.checked=!1})),document.querySelector(c).classList.add("hidden"),document.querySelectorAll(t).forEach((function(e){e.removeEventListener("change",d),e.addEventListener("change",d)})),a.checkedObjects.clear(),a.numObjects=0,document.querySelectorAll(e).forEach((function(e){a.numObjects++,e.addEventListener("change",l)}))}))})();