You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
21 KiB
JavaScript
1 line
21 KiB
JavaScript
7 months ago
|
(()=>{"use strict";var e={2991:e=>{e.exports=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var o,n,a;if(Array.isArray(t)){if((o=t.length)!=r.length)return!1;for(n=o;0!=n--;)if(!e(t[n],r[n]))return!1;return!0}if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(n of t.entries())if(!r.has(n[0]))return!1;for(n of t.entries())if(!e(n[1],r.get(n[0])))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(n of t.entries())if(!r.has(n[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(r)){if((o=t.length)!=r.length)return!1;for(n=o;0!=n--;)if(t[n]!==r[n])return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((o=(a=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(n=o;0!=n--;)if(!Object.prototype.hasOwnProperty.call(r,a[n]))return!1;for(n=o;0!=n--;){var l=a[n];if(!e(t[l],r[l]))return!1}return!0}return t!=t&&r!=r}}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var a=t[o]={exports:{}};return e[o](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{const e=lodash,t=wp.i18n,o=wp.hooks,n=wp.components,a=wp.blocks,l=wp.element,s=wp.data,i=wp.blockEditor;function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},u.apply(this,arguments)}var p=r(2991),c=r.n(p);const h=wp.compose,m=wp.apiFetch;var _=r.n(m);const d=wp.url,f={};function y({className:e}){return(0,l.createElement)(n.Placeholder,{className:e},(0,t.__)("Block rendered as empty."))}function b({response:e,className:r}){const o=(0,t.sprintf)((0,t.__)("Error loading block: %s"),e.errorMsg);return(0,l.createElement)(n.Placeholder,{className:r},o)}function g({children:e,showLoader:t}){return(0,l.createElement)("div",{style:{position:"relative"}},t&&(0,l.createElement)("div",{style:{position:"absolute",top:"50%",left:"50%",marginTop:"-9px",marginLeft:"-9px"}},(0,l.createElement)(n.Spinner,null)),(0,l.createElement)("div",{style:{opacity:t?"0.3":1}},e))}function w(e){const{attributes:t,block:r,className:o,httpMethod:n="GET",urlQueryArgs:s,skipBlockSupportAttributes:i=!1,EmptyResponsePlaceholder:p=y,ErrorResponsePlaceholder:m=b,LoadingResponsePlaceholder:w=g}=e,k=(0,l.useRef)(!0),[v,S]=(0,l.useState)(!1),C=(0,l.useRef)(),[E,A]=(0,l.useState)(null),O=(0,h.usePrevious)(e),[x,T]=(0,l.useState)(!1);function M(){var e,o;if(!k.current)return;T(!0);let l=t&&(0,a.__experimentalSanitizeBlockAttributes)(r,t);i&&(l=function(e){const{backgroundColor:t,borderColor:r,fontFamily:o,fontSize:n,gradient:a,textColor:l,className:s,...i}=e,{border:u,color:p,elements:c,spacing:h,typography:m,..._}=e?.style||f;return{...i,style:_}}(l));const u="POST"===n,p=u?null:null!==(e=l)&&void 0!==e?e:null,c=function(e,t=null,r={}){return(0,d.addQueryArgs)(`/wp/v2/block-renderer/${e}`,{context:"edit",...null!==t?{attributes:t}:{},...r})}(r,p,s),h=u?{attributes:null!==(o=l)&&void 0!==o?o:null}:null,m=C.current=_()({path:c,data:h,method:u?"POST":"GET"}).then((e=>{k.current&&m===C.current&&e&&A(e.rendered)})).catch((e=>{k.current&&m===C.current&&A({error:!0,errorMsg:e.message})})).finally((()=>{k.current&&m===C.current&&T(!1)}));return m}const P=(0,h.useDebounce)(M,500);(0,l.useEffect)((()=>()=>{k.current=!1}),[]),(0,l.useEffect)((()=>{void 0===O?M():c()(O,e)||P()})),(0,l.useEffect)((()=>{if(!x)return;const e=setTimeout((()=>{S(!0)}),1e3);return()=>clearTimeout(e)}),[x]);const j=!!E,R=""===E,L=E?.error;return x?(0,l.createElement)(w,u({},e,{showLoader:v}),j&&(0,l.createElement)(l.RawHTML,{className:o},E)):R||!j?(0,l.createEl
|