| 1 |
this.wp=this.wp||{},this.wp.serverSideRender=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=200)}({0:function(t,e){!function(){t.exports=this.wp.element}()},1:function(t,e){!function(){t.exports=this.wp.i18n}()},10:function(t,e,n){"use strict";function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function o(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}n.d(e,"a",function(){return o})},11:function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}n.d(e,"a",function(){return r})},12:function(t,e,n){"use strict";n.d(e,"a",function(){return u});var r=n(32),o=n(5);function u(t,e){return!e||"object"!==Object(r.a)(e)&&"function"!=typeof e?Object(o.a)(t):e}},13:function(t,e,n){"use strict";function r(t,e){return(r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r(t,e)}n.d(e,"a",function(){return o})},14:function(t,e,n){"use strict";function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}n.d(e,"a",function(){return r})},15:function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}n.d(e,"a",function(){return r})},18:function(t,e,n){"use strict";function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}n.d(e,"a",function(){return r})},2:function(t,e){!function(){t.exports=this.lodash}()},200:function(t,e,n){"use strict";n.r(e);var r=n(18),o=n(8),u=n(21),c=n(0),i=n(4),s=n(11),f=n(10),a=n(12),l=n(14),p=n(13),b=n(2),y=n(1),h=n(35),d=n.n(h),O=n(25),m=n(3);var j=function(t){function e(t){var n;return Object(s.a)(this,e),(n=Object(a.a)(this,Object(l.a)(e).call(this,t))).state={response:null},n}return Object(p.a)(e,t),Object(f.a)(e,[{key:"componentDidMount",value:function(){this.isStillMounted=!0,this.fetch(this.props),this.fetch=Object(b.debounce)(this.fetch,500)}},{key:"componentWillUnmount",value:function(){this.isStillMounted=!1}},{key:"componentDidUpdate",value:function(t){Object(b.isEqual)(t,this.props)||this.fetch(this.props)}},{key:"fetch",value:function(t){var e=this;if(this.isStillMounted){null!==this.state.response&&this.setState({response:null});var n=t.block,r=t.attributes,u=void 0===r?null:r,c=t.urlQueryArgs,i=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Object(O.addQueryArgs)("/wp/v2/block-renderer/".concat(t),Object(o.a)({context:"edit"},null!==e?{attributes:e}:{},n))}(n,u,void 0===c?{}:c),s=this.currentFetchRequest=d()({path:i}).then(function(t){e.isStillMounted&&s===e.currentFetchRequest&&t&&e.setState({response:t.rendered})}).catch(function(t){e.isStillMounted&&s===e.currentFetchRequest&&e.setState({response:{error:!0,errorMsg:t.message}})});return s}}},{key:"render",value:function(){var t=this.state.response,e=this.props.className;if(""===t)return Object(c.createElement)(m.Placeholder,{className:e},Object(y.__)("Block rendered as empty."));if(!t)return Object(c.createElement)(m.Placeholder,{className:e},Object(c.createElement)(m.Spinner,null));if(t.error){var n=Object(y.sprintf)(Object(y.__)("Error loading block: %s"),t.errorMsg);return Object(c.createElement)(m.Placeholder,{className:e},n)}return Object(c.createElement)(c.RawHTML,{key:"html",className:e},t)}}]),e}(c.Component),v={};e.default=Object(i.withSelect)(function(t){var e=t("core/editor");if(e){var n=e.getCurrentPostId();if(n)return{currentPostId:n}}return v})(function(t){var e=t.urlQueryArgs,n=void 0===e?v:e,i=t.currentPostId,s=Object(u.a)(t,["urlQueryArgs","currentPostId"]),f=Object(c.useMemo)(function(){return i?Object(o.a)({post_id:i},n):n},[i,n]);return Object(c.createElement)(j,Object(r.a)({urlQueryArgs:f},s))})},21:function(t,e,n){"use strict";function r(t,e){if(null==t)return{};var n,r,o=function(t,e){if(null==t)return{};var n,r,o={},u=Object.keys(t);for(r=0;r<u.length;r++)n=u[r],e.indexOf(n)>=0||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(t);for(r=0;r<u.length;r++)n=u[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}n.d(e,"a",function(){return r})},25:function(t,e){!function(){t.exports=this.wp.url}()},3:function(t,e){!function(){t.exports=this.wp.components}()},32:function(t,e,n){"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t){return(o="function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?function(t){return r(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":r(t)})(t)}n.d(e,"a",function(){return o})},35:function(t,e){!function(){t.exports=this.wp.apiFetch}()},4:function(t,e){!function(){t.exports=this.wp.data}()},5:function(t,e,n){"use strict";function r(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}n.d(e,"a",function(){return r})},8:function(t,e,n){"use strict";n.d(e,"a",function(){return o});var r=n(15);function o(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),o.forEach(function(e){Object(r.a)(t,e,n[e])})}return t}}}).default; |