2019-09-19 11:19:18 -04:00
this [ "wp" ] = this [ "wp" ] || { } ; this [ "wp" ] [ "serverSideRender" ] =
/******/ ( function ( modules ) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = { } ;
/******/
/******/ // The require function
/******/ function _ _webpack _require _ _ ( moduleId ) {
/******/
/******/ // Check if module is in cache
/******/ if ( installedModules [ moduleId ] ) {
/******/ return installedModules [ moduleId ] . exports ;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules [ moduleId ] = {
/******/ i : moduleId ,
/******/ l : false ,
/******/ exports : { }
/******/ } ;
/******/
/******/ // Execute the module function
/******/ modules [ moduleId ] . call ( module . exports , module , module . exports , _ _webpack _require _ _ ) ;
/******/
/******/ // Flag the module as loaded
/******/ module . l = true ;
/******/
/******/ // Return the exports of the module
/******/ return module . exports ;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ _ _webpack _require _ _ . m = modules ;
/******/
/******/ // expose the module cache
/******/ _ _webpack _require _ _ . c = installedModules ;
/******/
/******/ // define getter function for harmony exports
/******/ _ _webpack _require _ _ . d = function ( exports , name , getter ) {
/******/ if ( ! _ _webpack _require _ _ . o ( exports , name ) ) {
/******/ Object . defineProperty ( exports , name , { enumerable : true , get : getter } ) ;
/******/ }
/******/ } ;
/******/
/******/ // define __esModule on exports
/******/ _ _webpack _require _ _ . r = function ( exports ) {
/******/ if ( typeof Symbol !== 'undefined' && Symbol . toStringTag ) {
/******/ Object . defineProperty ( exports , Symbol . toStringTag , { value : 'Module' } ) ;
/******/ }
/******/ Object . defineProperty ( exports , '__esModule' , { value : true } ) ;
/******/ } ;
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ _ _webpack _require _ _ . t = function ( value , mode ) {
/******/ if ( mode & 1 ) value = _ _webpack _require _ _ ( value ) ;
/******/ if ( mode & 8 ) return value ;
/******/ if ( ( mode & 4 ) && typeof value === 'object' && value && value . _ _esModule ) return value ;
/******/ var ns = Object . create ( null ) ;
/******/ _ _webpack _require _ _ . r ( ns ) ;
/******/ Object . defineProperty ( ns , 'default' , { enumerable : true , value : value } ) ;
/******/ if ( mode & 2 && typeof value != 'string' ) for ( var key in value ) _ _webpack _require _ _ . d ( ns , key , function ( key ) { return value [ key ] ; } . bind ( null , key ) ) ;
/******/ return ns ;
/******/ } ;
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ _ _webpack _require _ _ . n = function ( module ) {
/******/ var getter = module && module . _ _esModule ?
/******/ function getDefault ( ) { return module [ 'default' ] ; } :
/******/ function getModuleExports ( ) { return module ; } ;
/******/ _ _webpack _require _ _ . d ( getter , 'a' , getter ) ;
/******/ return getter ;
/******/ } ;
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ _ _webpack _require _ _ . o = function ( object , property ) { return Object . prototype . hasOwnProperty . call ( object , property ) ; } ;
/******/
/******/ // __webpack_public_path__
/******/ _ _webpack _require _ _ . p = "" ;
/******/
/******/
/******/ // Load entry module and return exports
2021-05-20 08:20:04 -04:00
/******/ return _ _webpack _require _ _ ( _ _webpack _require _ _ . s = "4dqW" ) ;
2019-09-19 11:19:18 -04:00
/******/ } )
/************************************************************************/
/******/ ( {
2021-05-20 08:20:04 -04:00
/***/ "1ZqX" :
2021-05-19 11:09:27 -04:00
/***/ ( function ( module , exports ) {
2020-02-06 16:03:31 -05:00
2021-05-19 11:09:27 -04:00
( function ( ) { module . exports = window [ "wp" ] [ "data" ] ; } ( ) ) ;
2020-02-06 16:03:31 -05:00
/***/ } ) ,
2021-05-20 08:20:04 -04:00
/***/ "4dqW" :
2019-09-19 11:19:18 -04:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
2020-06-29 07:50:29 -04:00
// ESM COMPAT FLAG
2019-09-19 11:19:18 -04:00
_ _webpack _require _ _ . r ( _ _webpack _exports _ _ ) ;
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
2021-05-20 08:20:04 -04:00
var esm _extends = _ _webpack _require _ _ ( "wx14" ) ;
2019-09-19 11:19:18 -04:00
2021-01-27 21:04:13 -05:00
// EXTERNAL MODULE: external ["wp","element"]
2021-05-20 08:20:04 -04:00
var external _wp _element _ = _ _webpack _require _ _ ( "GRId" ) ;
2019-09-19 11:19:18 -04:00
2021-01-27 21:04:13 -05:00
// EXTERNAL MODULE: external ["wp","data"]
2021-05-20 08:20:04 -04:00
var external _wp _data _ = _ _webpack _require _ _ ( "1ZqX" ) ;
2019-09-19 11:19:18 -04:00
2021-01-27 21:04:13 -05:00
// EXTERNAL MODULE: external ["wp","deprecated"]
2021-05-20 08:20:04 -04:00
var external _wp _deprecated _ = _ _webpack _require _ _ ( "NMb1" ) ;
2021-01-27 21:04:13 -05:00
var external _wp _deprecated _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _wp _deprecated _ ) ;
2019-09-19 11:19:18 -04:00
2021-01-27 21:04:13 -05:00
// EXTERNAL MODULE: external "lodash"
2021-05-20 08:20:04 -04:00
var external _lodash _ = _ _webpack _require _ _ ( "YLtl" ) ;
2019-09-19 11:19:18 -04:00
2021-04-15 11:19:43 -04:00
// EXTERNAL MODULE: external ["wp","compose"]
2021-05-20 08:20:04 -04:00
var external _wp _compose _ = _ _webpack _require _ _ ( "K9lf" ) ;
2021-04-15 11:19:43 -04:00
2021-01-27 21:04:13 -05:00
// EXTERNAL MODULE: external ["wp","i18n"]
2021-05-20 08:20:04 -04:00
var external _wp _i18n _ = _ _webpack _require _ _ ( "l3Sj" ) ;
2019-09-19 11:19:18 -04:00
2021-01-27 21:04:13 -05:00
// EXTERNAL MODULE: external ["wp","apiFetch"]
2021-05-20 08:20:04 -04:00
var external _wp _apiFetch _ = _ _webpack _require _ _ ( "ywyh" ) ;
2021-01-27 21:04:13 -05:00
var external _wp _apiFetch _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _wp _apiFetch _ ) ;
2019-09-19 11:19:18 -04:00
2021-01-27 21:04:13 -05:00
// EXTERNAL MODULE: external ["wp","url"]
2021-05-20 08:20:04 -04:00
var external _wp _url _ = _ _webpack _require _ _ ( "Mmq9" ) ;
2019-09-19 11:19:18 -04:00
2021-01-27 21:04:13 -05:00
// EXTERNAL MODULE: external ["wp","components"]
2021-05-20 08:20:04 -04:00
var external _wp _components _ = _ _webpack _require _ _ ( "tI+e" ) ;
2019-09-19 11:19:18 -04:00
2021-04-15 11:19:43 -04:00
// EXTERNAL MODULE: external ["wp","blocks"]
2021-05-20 08:20:04 -04:00
var external _wp _blocks _ = _ _webpack _require _ _ ( "HSyU" ) ;
2019-09-19 11:19:18 -04:00
2021-04-15 11:19:43 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/server-side-render/build-module/server-side-render.js
2019-09-19 11:19:18 -04:00
/ * *
* External dependencies
* /
/ * *
* WordPress dependencies
* /
2021-04-15 11:19:43 -04:00
2021-05-19 11:09:27 -04:00
function rendererPath ( block , attributes = null , urlQueryArgs = { } ) {
return Object ( external _wp _url _ [ "addQueryArgs" ] ) ( ` /wp/v2/block-renderer/ ${ block } ` , {
context : 'edit' ,
... ( null !== attributes ? {
attributes
} : { } ) ,
... urlQueryArgs
} ) ;
2019-09-19 11:19:18 -04:00
}
2020-06-26 09:33:47 -04:00
2021-05-19 11:09:27 -04:00
function DefaultEmptyResponsePlaceholder ( {
className
} ) {
2021-04-15 11:19:43 -04:00
return Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Placeholder" ] , {
className : className
} , Object ( external _wp _i18n _ [ "__" ] ) ( 'Block rendered as empty.' ) ) ;
}
2019-09-19 11:19:18 -04:00
2021-05-19 11:09:27 -04:00
function DefaultErrorResponsePlaceholder ( {
response ,
className
} ) {
const errorMessage = Object ( external _wp _i18n _ [ "sprintf" ] ) ( // translators: %s: error message describing the problem
2021-04-15 11:19:43 -04:00
Object ( external _wp _i18n _ [ "__" ] ) ( 'Error loading block: %s' ) , response . errorMsg ) ;
return Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Placeholder" ] , {
className : className
} , errorMessage ) ;
}
2019-09-19 11:19:18 -04:00
2021-05-19 11:09:27 -04:00
function DefaultLoadingResponsePlaceholder ( {
className
} ) {
2021-04-15 11:19:43 -04:00
return Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Placeholder" ] , {
className : className
} , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Spinner" ] , null ) ) ;
}
2019-09-19 11:19:18 -04:00
2021-04-15 11:19:43 -04:00
function ServerSideRender ( props ) {
2021-05-19 11:09:27 -04:00
const {
attributes ,
block ,
className ,
httpMethod = 'GET' ,
urlQueryArgs ,
EmptyResponsePlaceholder = DefaultEmptyResponsePlaceholder ,
ErrorResponsePlaceholder = DefaultErrorResponsePlaceholder ,
LoadingResponsePlaceholder = DefaultLoadingResponsePlaceholder
} = props ;
const isMountedRef = Object ( external _wp _element _ [ "useRef" ] ) ( true ) ;
const fetchRequestRef = Object ( external _wp _element _ [ "useRef" ] ) ( ) ;
const [ response , setResponse ] = Object ( external _wp _element _ [ "useState" ] ) ( null ) ;
const prevProps = Object ( external _wp _compose _ [ "usePrevious" ] ) ( props ) ;
2021-04-15 11:19:43 -04:00
function fetchData ( ) {
if ( ! isMountedRef . current ) {
return ;
2019-09-19 11:19:18 -04:00
}
2021-04-15 11:19:43 -04:00
if ( null !== response ) {
setResponse ( null ) ;
2019-09-19 11:19:18 -04:00
}
2021-05-19 11:09:27 -04:00
const sanitizedAttributes = attributes && Object ( external _wp _blocks _ [ "__experimentalSanitizeBlockAttributes" ] ) ( block , attributes ) ; // If httpMethod is 'POST', send the attributes in the request body instead of the URL.
2021-04-15 11:19:43 -04:00
// This allows sending a larger attributes object than in a GET request, where the attributes are in the URL.
2021-05-19 11:09:27 -04:00
const isPostRequest = 'POST' === httpMethod ;
const urlAttributes = isPostRequest ? null : sanitizedAttributes !== null && sanitizedAttributes !== void 0 ? sanitizedAttributes : null ;
const path = rendererPath ( block , urlAttributes , urlQueryArgs ) ;
const data = isPostRequest ? {
2021-04-15 11:19:43 -04:00
attributes : sanitizedAttributes !== null && sanitizedAttributes !== void 0 ? sanitizedAttributes : null
} : null ; // Store the latest fetch request so that when we process it, we can
// check if it is the current request, to avoid race conditions on slow networks.
2021-05-19 11:09:27 -04:00
const fetchRequest = fetchRequestRef . current = external _wp _apiFetch _default ( ) ( {
path ,
data ,
2021-04-15 11:19:43 -04:00
method : isPostRequest ? 'POST' : 'GET'
2021-05-19 11:09:27 -04:00
} ) . then ( fetchResponse => {
2021-04-15 11:19:43 -04:00
if ( isMountedRef . current && fetchRequest === fetchRequestRef . current && fetchResponse ) {
setResponse ( fetchResponse . rendered ) ;
2019-09-19 11:19:18 -04:00
}
2021-05-19 11:09:27 -04:00
} ) . catch ( error => {
2021-04-15 11:19:43 -04:00
if ( isMountedRef . current && fetchRequest === fetchRequestRef . current ) {
setResponse ( {
error : true ,
errorMsg : error . message
2019-09-19 11:19:18 -04:00
} ) ;
}
2021-04-15 11:19:43 -04:00
} ) ;
return fetchRequest ;
}
2019-09-19 11:19:18 -04:00
2021-05-19 11:09:27 -04:00
const debouncedFetchData = Object ( external _wp _compose _ [ "useDebounce" ] ) ( fetchData , 500 ) ; // When the component unmounts, set isMountedRef to false. This will
2021-04-15 11:19:43 -04:00
// let the async fetch callbacks know when to stop.
2019-09-19 11:19:18 -04:00
2021-05-19 11:09:27 -04:00
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => ( ) => {
isMountedRef . current = false ;
2021-04-15 11:19:43 -04:00
} , [ ] ) ;
2021-05-19 11:09:27 -04:00
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => {
2021-04-15 11:19:43 -04:00
// Don't debounce the first fetch. This ensures that the first render
// shows data as soon as possible
if ( prevProps === undefined ) {
fetchData ( ) ;
} else if ( ! Object ( external _lodash _ [ "isEqual" ] ) ( prevProps , props ) ) {
debouncedFetchData ( ) ;
2019-09-19 11:19:18 -04:00
}
2021-04-15 11:19:43 -04:00
} ) ;
if ( response === '' ) {
return Object ( external _wp _element _ [ "createElement" ] ) ( EmptyResponsePlaceholder , props ) ;
} else if ( ! response ) {
return Object ( external _wp _element _ [ "createElement" ] ) ( LoadingResponsePlaceholder , props ) ;
} else if ( response . error ) {
return Object ( external _wp _element _ [ "createElement" ] ) ( ErrorResponsePlaceholder , Object ( esm _extends [ "a" /* default */ ] ) ( {
response : response
} , props ) ) ;
2019-09-19 11:19:18 -04:00
}
2021-04-15 11:19:43 -04:00
return Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _element _ [ "RawHTML" ] , {
className : className
} , response ) ;
}
2019-09-19 11:19:18 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/server-side-render/build-module/index.js
/ * *
* WordPress dependencies
* /
/ * *
* Internal dependencies
* /
/ * *
* Constants
* /
2021-05-19 11:09:27 -04:00
const EMPTY _OBJECT = { } ;
const ExportedServerSideRender = Object ( external _wp _data _ [ "withSelect" ] ) ( select => {
const coreEditorSelect = select ( 'core/editor' ) ;
2019-09-19 11:19:18 -04:00
if ( coreEditorSelect ) {
2021-05-19 11:09:27 -04:00
const currentPostId = coreEditorSelect . getCurrentPostId ( ) ; // For templates and template parts we use a custom ID format.
2021-04-15 11:19:43 -04:00
// Since they aren't real posts, we don't want to use their ID
// for server-side rendering. Since they use a string based ID,
// we can assume real post IDs are numbers.
2019-09-19 11:19:18 -04:00
2021-05-21 06:14:23 -04:00
if ( currentPostId && typeof currentPostId === 'number' ) {
2019-09-19 11:19:18 -04:00
return {
2021-05-19 11:09:27 -04:00
currentPostId
2019-09-19 11:19:18 -04:00
} ;
}
}
return EMPTY _OBJECT ;
2021-05-19 11:09:27 -04:00
} ) ( ( {
urlQueryArgs = EMPTY _OBJECT ,
currentPostId ,
... props
} ) => {
const newUrlQueryArgs = Object ( external _wp _element _ [ "useMemo" ] ) ( ( ) => {
2019-09-19 11:19:18 -04:00
if ( ! currentPostId ) {
return urlQueryArgs ;
}
2021-05-19 11:09:27 -04:00
return {
post _id : currentPostId ,
... urlQueryArgs
} ;
2019-09-19 11:19:18 -04:00
} , [ currentPostId , urlQueryArgs ] ) ;
2021-04-15 11:19:43 -04:00
return Object ( external _wp _element _ [ "createElement" ] ) ( ServerSideRender , Object ( esm _extends [ "a" /* default */ ] ) ( {
2019-09-19 11:19:18 -04:00
urlQueryArgs : newUrlQueryArgs
} , props ) ) ;
} ) ;
if ( window && window . wp && window . wp . components ) {
2021-05-19 11:09:27 -04:00
window . wp . components . ServerSideRender = Object ( external _wp _element _ [ "forwardRef" ] ) ( ( props , ref ) => {
2021-01-27 21:04:13 -05:00
external _wp _deprecated _default ( ) ( 'wp.components.ServerSideRender' , {
2021-04-15 11:19:43 -04:00
since : '5.3' ,
2019-09-19 11:19:18 -04:00
alternative : 'wp.serverSideRender'
} ) ;
2021-01-27 21:04:13 -05:00
return Object ( external _wp _element _ [ "createElement" ] ) ( ExportedServerSideRender , Object ( esm _extends [ "a" /* default */ ] ) ( { } , props , {
2019-09-19 11:19:18 -04:00
ref : ref
} ) ) ;
} ) ;
}
/* harmony default export */ var build _module = _ _webpack _exports _ _ [ "default" ] = ( ExportedServerSideRender ) ;
2019-10-15 11:37:08 -04:00
/***/ } ) ,
2021-05-20 08:20:04 -04:00
/***/ "GRId" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "element" ] ; } ( ) ) ;
/***/ } ) ,
/***/ "HSyU" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "blocks" ] ; } ( ) ) ;
/***/ } ) ,
/***/ "K9lf" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "compose" ] ; } ( ) ) ;
/***/ } ) ,
/***/ "Mmq9" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "url" ] ; } ( ) ) ;
/***/ } ) ,
/***/ "NMb1" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "deprecated" ] ; } ( ) ) ;
/***/ } ) ,
/***/ "YLtl" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "lodash" ] ; } ( ) ) ;
/***/ } ) ,
/***/ "l3Sj" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "i18n" ] ; } ( ) ) ;
/***/ } ) ,
/***/ "tI+e" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "components" ] ; } ( ) ) ;
/***/ } ) ,
/***/ "wx14" :
2020-01-22 17:06:21 -05:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
2020-06-26 09:33:47 -04:00
/* harmony export (binding) */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "a" , function ( ) { return _extends ; } ) ;
function _extends ( ) {
_extends = Object . assign || function ( target ) {
for ( var i = 1 ; i < arguments . length ; i ++ ) {
var source = arguments [ i ] ;
2020-01-22 17:06:21 -05:00
2020-06-26 09:33:47 -04:00
for ( var key in source ) {
if ( Object . prototype . hasOwnProperty . call ( source , key ) ) {
target [ key ] = source [ key ] ;
}
}
}
return target ;
} ;
return _extends . apply ( this , arguments ) ;
2020-01-22 17:06:21 -05:00
}
2021-04-15 11:19:43 -04:00
/***/ } ) ,
2021-05-20 08:20:04 -04:00
/***/ "ywyh" :
2021-04-15 11:19:43 -04:00
/***/ ( function ( module , exports ) {
2021-05-20 08:20:04 -04:00
( function ( ) { module . exports = window [ "wp" ] [ "apiFetch" ] ; } ( ) ) ;
2021-04-15 11:19:43 -04:00
2019-09-19 11:19:18 -04:00
/***/ } )
/******/ } ) [ "default" ] ;