(()=>{"use strict";var t={n:e=>{var i=e&&e.__esModule?()=>e.default:()=>e;return t.d(i,{a:i}),i},d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const e=window.wp.hooks,i=window.wp.element,s=window.wp.apiFetch;var r=t.n(s);const o=window.ReactJSXRuntime,n={"core/image":"id","core/video":"id","core/audio":"id","core/file":"id","core/media-text":"mediaId","core/cover":"id"};async function a(t){if(!t)return{};const e=await r()({path:`/wp/v2/media/${t}`});return e&&e.data?Object.keys(e.data).reduce((t,i)=>(t[`data-${i.toLowerCase().replace(/[^a-z0-9]/g,"-")}`]=e.data[i],t),{}):{}}function d(t,e){if(!t||!t.props)return;const{type:i,props:s}=t;("img"===i||"video"===i||"audio"===i||s.style&&s.style.backgroundImage)&&(t.props={...s,...e});const{children:r}=s;if(r&&r.length)for(const t of r)d(t,e);else d(r,e)}function c(t,e=d){return function(i){const s=i&&i.attributes&&i.attributes.mediaAttrs||{},r=t(i);return e(r,s),r}}function p(t,e){if(!t||!t.props)return;const{type:i,props:s}=t;if(("img"===i||"video"===i)&&s["data-id"]){const i=e[s["data-id"]]||{};t.props={...s,...i}}const{children:r}=s;if(r&&r.length)for(const t of r)p(t,e);else p(r,e)}(0,e.addFilter)("blocks.registerBlockType","drupal-gutenberg.media-attributes",(t,e)=>{if(n[e]){t.attributes.mediaAttrs={type:"object",default:{}};const s=n[e];t.edit=function(t,e="id"){return class extends i.Component{componentDidMount(){this.mediaId=this.props.attributes&&this.props.attributes[e]}async componentDidUpdate(){const t=this.props.attributes&&this.props.attributes[e];if(t!==this.mediaId){this.mediaId=t;const e=await a(this.mediaId);this.props.setAttributes({mediaAttrs:e})}}render(){return(0,o.jsx)(t,{...this.props})}}}(t.edit,s),t.save=c(t.save)}var s;return"core/gallery"===e&&(t.attributes.mediaAttrs={type:"object",default:{}},t.edit=(s=t.edit,class extends i.Component{componentDidMount(){const{attributes:t}=this.props;this.ids=t&&t.ids&&t.ids.toString()}async componentDidUpdate(){const{attributes:t}=this.props,e=t&&t.ids&&t.ids.toString();if(e!==this.ids){this.ids=e;const{ids:i,mediaAttrs:s}=t,r={};for(const t of i)t&&(r[t]=s[t]||await a(t));this.props.setAttributes({mediaAttrs:r})}}render(){return(0,o.jsx)(s,{...this.props})}}),t.save=c(t.save,p)),t})})();