!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("wp"));else if("function"==typeof define&&define.amd)define(["wp"],e);else{var r="object"==typeof exports?e(require("wp")):e(t.wp);for(var o in r)("object"==typeof exports?exports:t)[o]=r[o]}}(window,function(t){return function(t){var e={};function r(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,o){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(o,n,function(e){return t[e]}.bind(null,n));return o},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([function(e,r){e.exports=t},function(t,e,r){"use strict";r.r(e);var o=r(0);const{Component:n}=o.element;async function i(t){const e=t&&await Object(o.apiFetch)({path:`/wp/v2/media/${t}`});return e&&e.data?Object.keys(e.data).reduce((t,r)=>(t[`data-${r.toLowerCase().replace(/[^a-z0-9]/g,"-")}`]=e.data[r],t),{}):{}}function s(t,e=function t(e,r){if(!e||!e.props)return;const{type:o,props:n}=e;("img"===o||"video"===o||n.style&&n.style.backgroundImage)&&(e.props={...n,...r});const{children:i}=n;if(i&&i.length)for(const e of i)t(e,r);else t(i,r)}){return function(r){const o=r&&r.attributes&&r.attributes.mediaAttrs||{},n=t(r);return e(n,o),n}}const{Component:a}=o.element;function c(t,e){if(!t||!t.props)return;const{type:r,props:o}=t;if(("img"===r||"video"===r)&&o["data-id"]){const r=e[o["data-id"]]||{};t.props={...o,...r}}const{children:n}=o;if(n&&n.length)for(const t of n)c(t,e);else c(n,e)}o.hooks.addFilter("blocks.registerBlockType","g-js.media.register",(t,e)=>{if("core/image"===e||"core/video"===e||"core/media-text"===e||"core/cover"===e){t.attributes.mediaAttrs={type:"object",default:{}};const r="core/media-text"===e?"mediaId":"id";t.edit=function(t,e="id"){return class extends n{componentDidMount(){this.id=this.props.attributes&&this.props.attributes[e]}async componentDidUpdate(){const t=this.props.attributes&&this.props.attributes[e];if(t!==this.id){this.id=t;const e=await i(this.id);this.props.setAttributes({mediaAttrs:e})}}render(){return React.createElement(t,this.props)}}}(t.edit,r),t.save=s(t.save)}return"core/gallery"===e&&(t.attributes.mediaAttrs={type:"object",default:{}},t.edit=function(t){return class extends a{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:r,mediaAttrs:o}=t,n={};for(const t of r)t&&(n[t]=o[t]||await i(t));this.props.setAttributes({mediaAttrs:n})}}render(){return React.createElement(t,this.props)}}}(t.edit),t.save=s(t.save,c)),t})}])});