(()=>{"use strict";const e=window.wp.data,t=jQuery;function c(e){const t=/\[([a-z0-9_]*)]/gm,c={};return e.forEach(e=>{let l;const o=[];for(;null!==(l=t.exec(e.name));)l.index===t.lastIndex&&(t.lastIndex+=1),l.forEach((e,t)=>{1===t&&"override"!==e&&o.push(e)});!function(e,t,c){for(let l=0,o=t.length;l<o;++l)e=e[t[l]]=l===o-1?c:e[t[l]]||{}}(c,o,e.value)}),c}Drupal.behaviors.gutenbergBlockSettings={attach(l){l.elements&&"gutenberg-block-settings"===l.id&&(Array.from(l.elements).filter(e=>"op"===e.name)[0].onclick=()=>{document.querySelectorAll(`#${l.id} [data-autocomplete-path]`).forEach(e=>{e.value=function(e){const t=/.+\s\(([^\)]+)\)/gi.exec(e);return t?t[1]:null}(e.value)});let o=t(l).serializeArray();o=o.filter(e=>e.name.match(/^settings/i)),l.querySelectorAll("input[type=checkbox]").forEach(e=>{e.checked?(o=o.filter(t=>t.name!==e.name),o=o.concat({name:e.name,value:e.value})):o=o.concat({name:e.name,value:0})}),t("#drupal-modal").dialog("close");const a=(0,e.select)("core/block-editor").getSelectedBlock(),n=(0,e.select)("core/block-editor").getSelectedBlockClientId(),r={...a.attributes,settings:c(o)};return(0,e.dispatch)("core/block-editor").updateBlockAttributes(n,r),!1})}}})();