[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /******/ var __webpack_modules__ = ({ 2 3 /***/ 622: 4 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 5 6 /* harmony export */ __webpack_require__.d(__webpack_exports__, { 7 /* harmony export */ Ob: () => (/* binding */ E), 8 /* harmony export */ Qv: () => (/* binding */ D), 9 /* harmony export */ XX: () => (/* binding */ B), 10 /* harmony export */ fF: () => (/* binding */ l), 11 /* harmony export */ h: () => (/* binding */ _), 12 /* harmony export */ q6: () => (/* binding */ G), 13 /* harmony export */ uA: () => (/* binding */ k), 14 /* harmony export */ zO: () => (/* binding */ t) 15 /* harmony export */ }); 16 /* unused harmony exports Fragment, createElement, createRef, toChildArray */ 17 var n,l,u,t,i,o,r,f,e,c,s,a,h={},v=[],p=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,y=Array.isArray;function d(n,l){for(var u in l)n[u]=l[u];return n}function w(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function _(l,u,t){var i,o,r,f={};for(r in u)"key"==r?i=u[r]:"ref"==r?o=u[r]:f[r]=u[r];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):t),"function"==typeof l&&null!=l.defaultProps)for(r in l.defaultProps)void 0===f[r]&&(f[r]=l.defaultProps[r]);return g(l,f,i,o,null)}function g(n,t,i,o,r){var f={type:n,props:t,key:i,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++u:r,__i:-1,__u:0};return null==r&&null!=l.vnode&&l.vnode(f),f}function m(){return{current:null}}function b(n){return n.children}function k(n,l){this.props=n,this.context=l}function x(n,l){if(null==l)return n.__?x(n.__,n.__i+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return"function"==typeof n.type?x(n):null}function C(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return C(n)}}function S(n){(!n.__d&&(n.__d=!0)&&i.push(n)&&!M.__r++||o!==l.debounceRendering)&&((o=l.debounceRendering)||r)(M)}function M(){var n,u,t,o,r,e,c,s;for(i.sort(f);n=i.shift();)n.__d&&(u=i.length,o=void 0,e=(r=(t=n).__v).__e,c=[],s=[],t.__P&&((o=d({},r)).__v=r.__v+1,l.vnode&&l.vnode(o),O(t.__P,o,r,t.__n,t.__P.namespaceURI,32&r.__u?[e]:null,c,null==e?x(r):e,!!(32&r.__u),s),o.__v=r.__v,o.__.__k[o.__i]=o,j(c,o,s),o.__e!=e&&C(o)),i.length>u&&i.sort(f));M.__r=0}function P(n,l,u,t,i,o,r,f,e,c,s){var a,p,y,d,w,_=t&&t.__k||v,g=l.length;for(u.__d=e,$(u,l,_),e=u.__d,a=0;a<g;a++)null!=(y=u.__k[a])&&(p=-1===y.__i?h:_[y.__i]||h,y.__i=a,O(n,y,p,i,o,r,f,e,c,s),d=y.__e,y.ref&&p.ref!=y.ref&&(p.ref&&N(p.ref,null,y),s.push(y.ref,y.__c||d,y)),null==w&&null!=d&&(w=d),65536&y.__u||p.__k===y.__k?e=I(y,e,n):"function"==typeof y.type&&void 0!==y.__d?e=y.__d:d&&(e=d.nextSibling),y.__d=void 0,y.__u&=-196609);u.__d=e,u.__e=w}function $(n,l,u){var t,i,o,r,f,e=l.length,c=u.length,s=c,a=0;for(n.__k=[],t=0;t<e;t++)null!=(i=l[t])&&"boolean"!=typeof i&&"function"!=typeof i?(r=t+a,(i=n.__k[t]="string"==typeof i||"number"==typeof i||"bigint"==typeof i||i.constructor==String?g(null,i,null,null,null):y(i)?g(b,{children:i},null,null,null):void 0===i.constructor&&i.__b>0?g(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i).__=n,i.__b=n.__b+1,o=null,-1!==(f=i.__i=L(i,u,r,s))&&(s--,(o=u[f])&&(o.__u|=131072)),null==o||null===o.__v?(-1==f&&a--,"function"!=typeof i.type&&(i.__u|=65536)):f!==r&&(f==r-1?a--:f==r+1?a++:(f>r?a--:a++,i.__u|=65536))):i=n.__k[t]=null;if(s)for(t=0;t<c;t++)null!=(o=u[t])&&0==(131072&o.__u)&&(o.__e==n.__d&&(n.__d=x(o)),V(o,o))}function I(n,l,u){var t,i;if("function"==typeof n.type){for(t=n.__k,i=0;t&&i<t.length;i++)t[i]&&(t[i].__=n,l=I(t[i],l,u));return l}n.__e!=l&&(l&&n.type&&!u.contains(l)&&(l=x(n)),u.insertBefore(n.__e,l||null),l=n.__e);do{l=l&&l.nextSibling}while(null!=l&&8===l.nodeType);return l}function H(n,l){return l=l||[],null==n||"boolean"==typeof n||(y(n)?n.some(function(n){H(n,l)}):l.push(n)),l}function L(n,l,u,t){var i=n.key,o=n.type,r=u-1,f=u+1,e=l[u];if(null===e||e&&i==e.key&&o===e.type&&0==(131072&e.__u))return u;if(t>(null!=e&&0==(131072&e.__u)?1:0))for(;r>=0||f<l.length;){if(r>=0){if((e=l[r])&&0==(131072&e.__u)&&i==e.key&&o===e.type)return r;r--}if(f<l.length){if((e=l[f])&&0==(131072&e.__u)&&i==e.key&&o===e.type)return f;f++}}return-1}function T(n,l,u){"-"===l[0]?n.setProperty(l,null==u?"":u):n[l]=null==u?"":"number"!=typeof u||p.test(l)?u:u+"px"}function A(n,l,u,t,i){var o;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else{if("string"==typeof t&&(n.style.cssText=t=""),t)for(l in t)u&&l in u||T(n.style,l,"");if(u)for(l in u)t&&u[l]===t[l]||T(n.style,l,u[l])}else if("o"===l[0]&&"n"===l[1])o=l!==(l=l.replace(/(PointerCapture)$|Capture$/i,"$1")),l=l.toLowerCase()in n||"onFocusOut"===l||"onFocusIn"===l?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?t?u.u=t.u:(u.u=e,n.addEventListener(l,o?s:c,o)):n.removeEventListener(l,o?s:c,o);else{if("http://www.w3.org/2000/svg"==i)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=l&&"height"!=l&&"href"!=l&&"list"!=l&&"form"!=l&&"tabIndex"!=l&&"download"!=l&&"rowSpan"!=l&&"colSpan"!=l&&"role"!=l&&"popover"!=l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null==u||!1===u&&"-"!==l[4]?n.removeAttribute(l):n.setAttribute(l,"popover"==l&&1==u?"":u))}}function F(n){return function(u){if(this.l){var t=this.l[u.type+n];if(null==u.t)u.t=e++;else if(u.t<t.u)return;return t(l.event?l.event(u):u)}}}function O(n,u,t,i,o,r,f,e,c,s){var a,h,v,p,w,_,g,m,x,C,S,M,$,I,H,L,T=u.type;if(void 0!==u.constructor)return null;128&t.__u&&(c=!!(32&t.__u),r=[e=u.__e=t.__e]),(a=l.__b)&&a(u);n:if("function"==typeof T)try{if(m=u.props,x="prototype"in T&&T.prototype.render,C=(a=T.contextType)&&i[a.__c],S=a?C?C.props.value:a.__:i,t.__c?g=(h=u.__c=t.__c).__=h.__E:(x?u.__c=h=new T(m,S):(u.__c=h=new k(m,S),h.constructor=T,h.render=q),C&&C.sub(h),h.props=m,h.state||(h.state={}),h.context=S,h.__n=i,v=h.__d=!0,h.__h=[],h._sb=[]),x&&null==h.__s&&(h.__s=h.state),x&&null!=T.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=d({},h.__s)),d(h.__s,T.getDerivedStateFromProps(m,h.__s))),p=h.props,w=h.state,h.__v=u,v)x&&null==T.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),x&&null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(x&&null==T.getDerivedStateFromProps&&m!==p&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(m,S),!h.__e&&(null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(m,h.__s,S)||u.__v===t.__v)){for(u.__v!==t.__v&&(h.props=m,h.state=h.__s,h.__d=!1),u.__e=t.__e,u.__k=t.__k,u.__k.some(function(n){n&&(n.__=u)}),M=0;M<h._sb.length;M++)h.__h.push(h._sb[M]);h._sb=[],h.__h.length&&f.push(h);break n}null!=h.componentWillUpdate&&h.componentWillUpdate(m,h.__s,S),x&&null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(p,w,_)})}if(h.context=S,h.props=m,h.__P=n,h.__e=!1,$=l.__r,I=0,x){for(h.state=h.__s,h.__d=!1,$&&$(u),a=h.render(h.props,h.state,h.context),H=0;H<h._sb.length;H++)h.__h.push(h._sb[H]);h._sb=[]}else do{h.__d=!1,$&&$(u),a=h.render(h.props,h.state,h.context),h.state=h.__s}while(h.__d&&++I<25);h.state=h.__s,null!=h.getChildContext&&(i=d(d({},i),h.getChildContext())),x&&!v&&null!=h.getSnapshotBeforeUpdate&&(_=h.getSnapshotBeforeUpdate(p,w)),P(n,y(L=null!=a&&a.type===b&&null==a.key?a.props.children:a)?L:[L],u,t,i,o,r,f,e,c,s),h.base=u.__e,u.__u&=-161,h.__h.length&&f.push(h),g&&(h.__E=h.__=null)}catch(n){if(u.__v=null,c||null!=r){for(u.__u|=c?160:128;e&&8===e.nodeType&&e.nextSibling;)e=e.nextSibling;r[r.indexOf(e)]=null,u.__e=e}else u.__e=t.__e,u.__k=t.__k;l.__e(n,u,t)}else null==r&&u.__v===t.__v?(u.__k=t.__k,u.__e=t.__e):u.__e=z(t.__e,u,t,i,o,r,f,c,s);(a=l.diffed)&&a(u)}function j(n,u,t){u.__d=void 0;for(var i=0;i<t.length;i++)N(t[i],t[++i],t[++i]);l.__c&&l.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u)})}catch(n){l.__e(n,u.__v)}})}function z(u,t,i,o,r,f,e,c,s){var a,v,p,d,_,g,m,b=i.props,k=t.props,C=t.type;if("svg"===C?r="http://www.w3.org/2000/svg":"math"===C?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),null!=f)for(a=0;a<f.length;a++)if((_=f[a])&&"setAttribute"in _==!!C&&(C?_.localName===C:3===_.nodeType)){u=_,f[a]=null;break}if(null==u){if(null===C)return document.createTextNode(k);u=document.createElementNS(r,C,k.is&&k),c&&(l.__m&&l.__m(t,f),c=!1),f=null}if(null===C)b===k||c&&u.data===k||(u.data=k);else{if(f=f&&n.call(u.childNodes),b=i.props||h,!c&&null!=f)for(b={},a=0;a<u.attributes.length;a++)b[(_=u.attributes[a]).name]=_.value;for(a in b)if(_=b[a],"children"==a);else if("dangerouslySetInnerHTML"==a)p=_;else if(!(a in k)){if("value"==a&&"defaultValue"in k||"checked"==a&&"defaultChecked"in k)continue;A(u,a,null,_,r)}for(a in k)_=k[a],"children"==a?d=_:"dangerouslySetInnerHTML"==a?v=_:"value"==a?g=_:"checked"==a?m=_:c&&"function"!=typeof _||b[a]===_||A(u,a,_,b[a],r);if(v)c||p&&(v.__html===p.__html||v.__html===u.innerHTML)||(u.innerHTML=v.__html),t.__k=[];else if(p&&(u.innerHTML=""),P(u,y(d)?d:[d],t,i,o,"foreignObject"===C?"http://www.w3.org/1999/xhtml":r,f,e,f?f[0]:i.__k&&x(i,0),c,s),null!=f)for(a=f.length;a--;)w(f[a]);c||(a="value","progress"===C&&null==g?u.removeAttribute("value"):void 0!==g&&(g!==u[a]||"progress"===C&&!g||"option"===C&&g!==b[a])&&A(u,a,g,b[a],r),a="checked",void 0!==m&&m!==u[a]&&A(u,a,m,b[a],r))}return u}function N(n,u,t){try{if("function"==typeof n){var i="function"==typeof n.__u;i&&n.__u(),i&&null==u||(n.__u=n(u))}else n.current=u}catch(n){l.__e(n,t)}}function V(n,u,t){var i,o;if(l.unmount&&l.unmount(n),(i=n.ref)&&(i.current&&i.current!==n.__e||N(i,null,u)),null!=(i=n.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(n){l.__e(n,u)}i.base=i.__P=null}if(i=n.__k)for(o=0;o<i.length;o++)i[o]&&V(i[o],u,t||"function"!=typeof n.type);t||w(n.__e),n.__c=n.__=n.__e=n.__d=void 0}function q(n,l,u){return this.constructor(n,u)}function B(u,t,i){var o,r,f,e;l.__&&l.__(u,t),r=(o="function"==typeof i)?null:i&&i.__k||t.__k,f=[],e=[],O(t,u=(!o&&i||t).__k=_(b,null,[u]),r||h,h,t.namespaceURI,!o&&i?[i]:r?null:t.firstChild?n.call(t.childNodes):null,f,!o&&i?i:r?r.__e:t.firstChild,o,e),j(f,u,e)}function D(n,l){B(n,l,D)}function E(l,u,t){var i,o,r,f,e=d({},l.props);for(r in l.type&&l.type.defaultProps&&(f=l.type.defaultProps),u)"key"==r?i=u[r]:"ref"==r?o=u[r]:e[r]=void 0===u[r]&&void 0!==f?f[r]:u[r];return arguments.length>2&&(e.children=arguments.length>3?n.call(arguments,2):t),g(l.type,e,i||l.key,o||l.ref,null)}function G(n,l){var u={__c:l="__cC"+a++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,t;return this.getChildContext||(u=new Set,(t={})[l]=this,this.getChildContext=function(){return t},this.componentWillUnmount=function(){u=null},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.forEach(function(n){n.__e=!0,S(n)})},this.sub=function(n){u.add(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u&&u.delete(n),l&&l.call(n)}}),n.children}};return u.Provider.__=u.Consumer.contextType=u}n=v.slice,l={__e:function(n,l,u,t){for(var i,o,r;l=l.__;)if((i=l.__c)&&!i.__)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(n)),r=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(n,t||{}),r=i.__d),r)return i.__E=i}catch(l){n=l}throw n}},u=0,t=function(n){return null!=n&&null==n.constructor},k.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=d({},this.state),"function"==typeof n&&(n=n(d({},u),this.props)),n&&d(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),S(this))},k.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),S(this))},k.prototype.render=b,i=[],r="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,f=function(n,l){return n.__v.__b-l.__v.__b},M.__r=0,e=0,c=F(!1),s=F(!0),a=0; 18 19 20 /***/ }) 21 22 /******/ }); 23 /************************************************************************/ 24 /******/ // The module cache 25 /******/ var __webpack_module_cache__ = {}; 26 /******/ 27 /******/ // The require function 28 /******/ function __webpack_require__(moduleId) { 29 /******/ // Check if module is in cache 30 /******/ var cachedModule = __webpack_module_cache__[moduleId]; 31 /******/ if (cachedModule !== undefined) { 32 /******/ return cachedModule.exports; 33 /******/ } 34 /******/ // Create a new module (and put it into the cache) 35 /******/ var module = __webpack_module_cache__[moduleId] = { 36 /******/ // no module.id needed 37 /******/ // no module.loaded needed 38 /******/ exports: {} 39 /******/ }; 40 /******/ 41 /******/ // Execute the module function 42 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 43 /******/ 44 /******/ // Return the exports of the module 45 /******/ return module.exports; 46 /******/ } 47 /******/ 48 /************************************************************************/ 49 /******/ /* webpack/runtime/define property getters */ 50 /******/ (() => { 51 /******/ // define getter functions for harmony exports 52 /******/ __webpack_require__.d = (exports, definition) => { 53 /******/ for(var key in definition) { 54 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 55 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 56 /******/ } 57 /******/ } 58 /******/ }; 59 /******/ })(); 60 /******/ 61 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 62 /******/ (() => { 63 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 64 /******/ })(); 65 /******/ 66 /************************************************************************/ 67 var __webpack_exports__ = {}; 68 69 // EXPORTS 70 __webpack_require__.d(__webpack_exports__, { 71 zj: () => (/* reexport */ getConfig), 72 SD: () => (/* reexport */ getContext), 73 V6: () => (/* reexport */ getElement), 74 $K: () => (/* reexport */ getServerContext), 75 vT: () => (/* reexport */ getServerState), 76 jb: () => (/* binding */ privateApis), 77 yT: () => (/* reexport */ splitTask), 78 M_: () => (/* reexport */ store), 79 hb: () => (/* reexport */ useCallback), 80 vJ: () => (/* reexport */ useEffect), 81 ip: () => (/* reexport */ useInit), 82 Nf: () => (/* reexport */ useLayoutEffect), 83 Kr: () => (/* reexport */ useMemo), 84 li: () => (/* reexport */ A), 85 J0: () => (/* reexport */ h), 86 FH: () => (/* reexport */ useWatch), 87 v4: () => (/* reexport */ withScope) 88 }); 89 90 // EXTERNAL MODULE: ./node_modules/preact/dist/preact.module.js 91 var preact_module = __webpack_require__(622); 92 ;// ./node_modules/preact/hooks/dist/hooks.module.js 93 var hooks_module_t,r,hooks_module_u,i,hooks_module_o=0,hooks_module_f=[],hooks_module_c=preact_module/* options */.fF,e=hooks_module_c.__b,a=hooks_module_c.__r,v=hooks_module_c.diffed,l=hooks_module_c.__c,m=hooks_module_c.unmount,s=hooks_module_c.__;function d(n,t){hooks_module_c.__h&&hooks_module_c.__h(r,n,hooks_module_o||t),hooks_module_o=0;var u=r.__H||(r.__H={__:[],__h:[]});return n>=u.__.length&&u.__.push({}),u.__[n]}function h(n){return hooks_module_o=1,p(D,n)}function p(n,u,i){var o=d(hooks_module_t++,2);if(o.t=n,!o.__c&&(o.__=[i?i(u):D(void 0,u),function(n){var t=o.__N?o.__N[0]:o.__[0],r=o.t(t,n);t!==r&&(o.__N=[r,o.__[1]],o.__c.setState({}))}],o.__c=r,!r.u)){var f=function(n,t,r){if(!o.__c.__H)return!0;var u=o.__c.__H.__.filter(function(n){return!!n.__c});if(u.every(function(n){return!n.__N}))return!c||c.call(this,n,t,r);var i=!1;return u.forEach(function(n){if(n.__N){var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(i=!0)}}),!(!i&&o.__c.props===n)&&(!c||c.call(this,n,t,r))};r.u=!0;var c=r.shouldComponentUpdate,e=r.componentWillUpdate;r.componentWillUpdate=function(n,t,r){if(this.__e){var u=c;c=void 0,f(n,t,r),c=u}e&&e.call(this,n,t,r)},r.shouldComponentUpdate=f}return o.__N||o.__}function y(n,u){var i=d(hooks_module_t++,3);!hooks_module_c.__s&&C(i.__H,u)&&(i.__=n,i.i=u,r.__H.__h.push(i))}function _(n,u){var i=d(hooks_module_t++,4);!hooks_module_c.__s&&C(i.__H,u)&&(i.__=n,i.i=u,r.__h.push(i))}function A(n){return hooks_module_o=5,T(function(){return{current:n}},[])}function F(n,t,r){hooks_module_o=6,_(function(){return"function"==typeof n?(n(t()),function(){return n(null)}):n?(n.current=t(),function(){return n.current=null}):void 0},null==r?r:r.concat(n))}function T(n,r){var u=d(hooks_module_t++,7);return C(u.__H,r)&&(u.__=n(),u.__H=r,u.__h=n),u.__}function q(n,t){return hooks_module_o=8,T(function(){return n},t)}function x(n){var u=r.context[n.__c],i=d(hooks_module_t++,9);return i.c=n,u?(null==i.__&&(i.__=!0,u.sub(r)),u.props.value):n.__}function P(n,t){hooks_module_c.useDebugValue&&hooks_module_c.useDebugValue(t?t(n):n)}function b(n){var u=d(hooks_module_t++,10),i=h();return u.__=n,r.componentDidCatch||(r.componentDidCatch=function(n,t){u.__&&u.__(n,t),i[1](n)}),[i[0],function(){i[1](void 0)}]}function g(){var n=d(hooks_module_t++,11);if(!n.__){for(var u=r.__v;null!==u&&!u.__m&&null!==u.__;)u=u.__;var i=u.__m||(u.__m=[0,0]);n.__="P"+i[0]+"-"+i[1]++}return n.__}function j(){for(var n;n=hooks_module_f.shift();)if(n.__P&&n.__H)try{n.__H.__h.forEach(z),n.__H.__h.forEach(B),n.__H.__h=[]}catch(t){n.__H.__h=[],hooks_module_c.__e(t,n.__v)}}hooks_module_c.__b=function(n){r=null,e&&e(n)},hooks_module_c.__=function(n,t){n&&t.__k&&t.__k.__m&&(n.__m=t.__k.__m),s&&s(n,t)},hooks_module_c.__r=function(n){a&&a(n),hooks_module_t=0;var i=(r=n.__c).__H;i&&(hooks_module_u===r?(i.__h=[],r.__h=[],i.__.forEach(function(n){n.__N&&(n.__=n.__N),n.i=n.__N=void 0})):(i.__h.forEach(z),i.__h.forEach(B),i.__h=[],hooks_module_t=0)),hooks_module_u=r},hooks_module_c.diffed=function(n){v&&v(n);var t=n.__c;t&&t.__H&&(t.__H.__h.length&&(1!==hooks_module_f.push(t)&&i===hooks_module_c.requestAnimationFrame||((i=hooks_module_c.requestAnimationFrame)||w)(j)),t.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.i=void 0})),hooks_module_u=r=null},hooks_module_c.__c=function(n,t){t.some(function(n){try{n.__h.forEach(z),n.__h=n.__h.filter(function(n){return!n.__||B(n)})}catch(r){t.some(function(n){n.__h&&(n.__h=[])}),t=[],hooks_module_c.__e(r,n.__v)}}),l&&l(n,t)},hooks_module_c.unmount=function(n){m&&m(n);var t,r=n.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{z(n)}catch(n){t=n}}),r.__H=void 0,t&&hooks_module_c.__e(t,r.__v))};var k="function"==typeof requestAnimationFrame;function w(n){var t,r=function(){clearTimeout(u),k&&cancelAnimationFrame(t),setTimeout(n)},u=setTimeout(r,100);k&&(t=requestAnimationFrame(r))}function z(n){var t=r,u=n.__c;"function"==typeof u&&(n.__c=void 0,u()),r=t}function B(n){var t=r;n.__c=n.__(),r=t}function C(n,t){return!n||n.length!==t.length||t.some(function(t,r){return t!==n[r]})}function D(n,t){return"function"==typeof t?t(n):t} 94 95 ;// ./node_modules/@preact/signals-core/dist/signals-core.module.js 96 var signals_core_module_i=Symbol.for("preact-signals");function signals_core_module_t(){if(!(signals_core_module_s>1)){var i,t=!1;while(void 0!==signals_core_module_h){var r=signals_core_module_h;signals_core_module_h=void 0;signals_core_module_f++;while(void 0!==r){var o=r.o;r.o=void 0;r.f&=-3;if(!(8&r.f)&&signals_core_module_c(r))try{r.c()}catch(r){if(!t){i=r;t=!0}}r=o}}signals_core_module_f=0;signals_core_module_s--;if(t)throw i}else signals_core_module_s--}function signals_core_module_r(i){if(signals_core_module_s>0)return i();signals_core_module_s++;try{return i()}finally{signals_core_module_t()}}var signals_core_module_o=void 0;function n(i){var t=signals_core_module_o;signals_core_module_o=void 0;try{return i()}finally{signals_core_module_o=t}}var signals_core_module_h=void 0,signals_core_module_s=0,signals_core_module_f=0,signals_core_module_v=0;function signals_core_module_e(i){if(void 0!==signals_core_module_o){var t=i.n;if(void 0===t||t.t!==signals_core_module_o){t={i:0,S:i,p:signals_core_module_o.s,n:void 0,t:signals_core_module_o,e:void 0,x:void 0,r:t};if(void 0!==signals_core_module_o.s)signals_core_module_o.s.n=t;signals_core_module_o.s=t;i.n=t;if(32&signals_core_module_o.f)i.S(t);return t}else if(-1===t.i){t.i=0;if(void 0!==t.n){t.n.p=t.p;if(void 0!==t.p)t.p.n=t.n;t.p=signals_core_module_o.s;t.n=void 0;signals_core_module_o.s.n=t;signals_core_module_o.s=t}return t}}}function signals_core_module_u(i){this.v=i;this.i=0;this.n=void 0;this.t=void 0}signals_core_module_u.prototype.brand=signals_core_module_i;signals_core_module_u.prototype.h=function(){return!0};signals_core_module_u.prototype.S=function(i){if(this.t!==i&&void 0===i.e){i.x=this.t;if(void 0!==this.t)this.t.e=i;this.t=i}};signals_core_module_u.prototype.U=function(i){if(void 0!==this.t){var t=i.e,r=i.x;if(void 0!==t){t.x=r;i.e=void 0}if(void 0!==r){r.e=t;i.x=void 0}if(i===this.t)this.t=r}};signals_core_module_u.prototype.subscribe=function(i){var t=this;return E(function(){var r=t.value,n=signals_core_module_o;signals_core_module_o=void 0;try{i(r)}finally{signals_core_module_o=n}})};signals_core_module_u.prototype.valueOf=function(){return this.value};signals_core_module_u.prototype.toString=function(){return this.value+""};signals_core_module_u.prototype.toJSON=function(){return this.value};signals_core_module_u.prototype.peek=function(){var i=signals_core_module_o;signals_core_module_o=void 0;try{return this.value}finally{signals_core_module_o=i}};Object.defineProperty(signals_core_module_u.prototype,"value",{get:function(){var i=signals_core_module_e(this);if(void 0!==i)i.i=this.i;return this.v},set:function(i){if(i!==this.v){if(signals_core_module_f>100)throw new Error("Cycle detected");this.v=i;this.i++;signals_core_module_v++;signals_core_module_s++;try{for(var r=this.t;void 0!==r;r=r.x)r.t.N()}finally{signals_core_module_t()}}}});function signals_core_module_d(i){return new signals_core_module_u(i)}function signals_core_module_c(i){for(var t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function signals_core_module_a(i){for(var t=i.s;void 0!==t;t=t.n){var r=t.S.n;if(void 0!==r)t.r=r;t.S.n=t;t.i=-1;if(void 0===t.n){i.s=t;break}}}function signals_core_module_l(i){var t=i.s,r=void 0;while(void 0!==t){var o=t.p;if(-1===t.i){t.S.U(t);if(void 0!==o)o.n=t.n;if(void 0!==t.n)t.n.p=o}else r=t;t.S.n=t.r;if(void 0!==t.r)t.r=void 0;t=o}i.s=r}function signals_core_module_y(i){signals_core_module_u.call(this,void 0);this.x=i;this.s=void 0;this.g=signals_core_module_v-1;this.f=4}(signals_core_module_y.prototype=new signals_core_module_u).h=function(){this.f&=-3;if(1&this.f)return!1;if(32==(36&this.f))return!0;this.f&=-5;if(this.g===signals_core_module_v)return!0;this.g=signals_core_module_v;this.f|=1;if(this.i>0&&!signals_core_module_c(this)){this.f&=-2;return!0}var i=signals_core_module_o;try{signals_core_module_a(this);signals_core_module_o=this;var t=this.x();if(16&this.f||this.v!==t||0===this.i){this.v=t;this.f&=-17;this.i++}}catch(i){this.v=i;this.f|=16;this.i++}signals_core_module_o=i;signals_core_module_l(this);this.f&=-2;return!0};signals_core_module_y.prototype.S=function(i){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}signals_core_module_u.prototype.S.call(this,i)};signals_core_module_y.prototype.U=function(i){if(void 0!==this.t){signals_core_module_u.prototype.U.call(this,i);if(void 0===this.t){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}}};signals_core_module_y.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var i=this.t;void 0!==i;i=i.x)i.t.N()}};Object.defineProperty(signals_core_module_y.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var i=signals_core_module_e(this);this.h();if(void 0!==i)i.i=this.i;if(16&this.f)throw this.v;return this.v}});function signals_core_module_w(i){return new signals_core_module_y(i)}function signals_core_module_(i){var r=i.u;i.u=void 0;if("function"==typeof r){signals_core_module_s++;var n=signals_core_module_o;signals_core_module_o=void 0;try{r()}catch(t){i.f&=-2;i.f|=8;signals_core_module_g(i);throw t}finally{signals_core_module_o=n;signals_core_module_t()}}}function signals_core_module_g(i){for(var t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;signals_core_module_(i)}function signals_core_module_p(i){if(signals_core_module_o!==this)throw new Error("Out-of-order effect");signals_core_module_l(this);signals_core_module_o=i;this.f&=-2;if(8&this.f)signals_core_module_g(this);signals_core_module_t()}function signals_core_module_b(i){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=32}signals_core_module_b.prototype.c=function(){var i=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();if("function"==typeof t)this.u=t}finally{i()}};signals_core_module_b.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1;this.f&=-9;signals_core_module_(this);signals_core_module_a(this);signals_core_module_s++;var i=signals_core_module_o;signals_core_module_o=this;return signals_core_module_p.bind(this,i)};signals_core_module_b.prototype.N=function(){if(!(2&this.f)){this.f|=2;this.o=signals_core_module_h;signals_core_module_h=this}};signals_core_module_b.prototype.d=function(){this.f|=8;if(!(1&this.f))signals_core_module_g(this)};function E(i){var t=new signals_core_module_b(i);try{t.c()}catch(i){t.d();throw i}return t.d.bind(t)} 97 ;// ./node_modules/@preact/signals/dist/signals.module.js 98 var signals_module_v,signals_module_s;function signals_module_l(n,i){preact_module/* options */.fF[n]=i.bind(null,preact_module/* options */.fF[n]||function(){})}function signals_module_d(n){if(signals_module_s)signals_module_s();signals_module_s=n&&n.S()}function signals_module_p(n){var r=this,f=n.data,o=useSignal(f);o.value=f;var e=T(function(){var n=r.__v;while(n=n.__)if(n.__c){n.__c.__$f|=4;break}r.__$u.c=function(){var n;if(!(0,preact_module/* isValidElement */.zO)(e.peek())&&3===(null==(n=r.base)?void 0:n.nodeType))r.base.data=e.peek();else{r.__$f|=1;r.setState({})}};return signals_core_module_w(function(){var n=o.value.value;return 0===n?0:!0===n?"":n||""})},[]);return e.value}signals_module_p.displayName="_st";Object.defineProperties(signals_core_module_u.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:signals_module_p},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});signals_module_l("__b",function(n,r){if("string"==typeof r.type){var i,t=r.props;for(var f in t)if("children"!==f){var o=t[f];if(o instanceof signals_core_module_u){if(!i)r.__np=i={};i[f]=o;t[f]=o.peek()}}}n(r)});signals_module_l("__r",function(n,r){signals_module_d();var i,t=r.__c;if(t){t.__$f&=-2;if(void 0===(i=t.__$u))t.__$u=i=function(n){var r;E(function(){r=this});r.c=function(){t.__$f|=1;t.setState({})};return r}()}signals_module_v=t;signals_module_d(i);n(r)});signals_module_l("__e",function(n,r,i,t){signals_module_d();signals_module_v=void 0;n(r,i,t)});signals_module_l("diffed",function(n,r){signals_module_d();signals_module_v=void 0;var i;if("string"==typeof r.type&&(i=r.__e)){var t=r.__np,f=r.props;if(t){var o=i.U;if(o)for(var e in o){var u=o[e];if(void 0!==u&&!(e in t)){u.d();o[e]=void 0}}else i.U=o={};for(var a in t){var c=o[a],s=t[a];if(void 0===c){c=signals_module_(i,a,s,f);o[a]=c}else c.o(s,f)}}}n(r)});function signals_module_(n,r,i,t){var f=r in n&&void 0===n.ownerSVGElement,o=signals_core_module_d(i);return{o:function(n,r){o.value=n;t=r},d:E(function(){var i=o.value.value;if(t[r]!==i){t[r]=i;if(f)n[r]=i;else if(i)n.setAttribute(r,i);else n.removeAttribute(r)}})}}signals_module_l("unmount",function(n,r){if("string"==typeof r.type){var i=r.__e;if(i){var t=i.U;if(t){i.U=void 0;for(var f in t){var o=t[f];if(o)o.d()}}}}else{var e=r.__c;if(e){var u=e.__$u;if(u){e.__$u=void 0;u.d()}}}n(r)});signals_module_l("__h",function(n,r,i,t){if(t<3||9===t)r.__$f|=2;n(r,i,t)});preact_module/* Component */.uA.prototype.shouldComponentUpdate=function(n,r){var i=this.__$u;if(!(i&&void 0!==i.s||4&this.__$f))return!0;if(3&this.__$f)return!0;for(var t in r)return!0;for(var f in n)if("__source"!==f&&n[f]!==this.props[f])return!0;for(var o in this.props)if(!(o in n))return!0;return!1};function useSignal(n){return T(function(){return signals_core_module_d(n)},[])}function useComputed(n){var r=f(n);r.current=n;signals_module_v.__$f|=4;return t(function(){return u(function(){return r.current()})},[])}function useSignalEffect(n){var r=f(n);r.current=n;o(function(){return c(function(){return r.current()})},[])} 99 ;// ./node_modules/@wordpress/interactivity/build-module/namespaces.js 100 const namespaceStack = []; 101 const getNamespace = () => namespaceStack.slice(-1)[0]; 102 const setNamespace = namespace => { 103 namespaceStack.push(namespace); 104 }; 105 const resetNamespace = () => { 106 namespaceStack.pop(); 107 }; 108 109 ;// ./node_modules/@wordpress/interactivity/build-module/scopes.js 110 /** 111 * External dependencies 112 */ 113 114 /** 115 * Internal dependencies 116 */ 117 118 // Store stacks for the current scope and the default namespaces and export APIs 119 // to interact with them. 120 const scopeStack = []; 121 const getScope = () => scopeStack.slice(-1)[0]; 122 const setScope = scope => { 123 scopeStack.push(scope); 124 }; 125 const resetScope = () => { 126 scopeStack.pop(); 127 }; 128 129 // Wrap the element props to prevent modifications. 130 const immutableMap = new WeakMap(); 131 const immutableError = () => { 132 throw new Error('Please use `data-wp-bind` to modify the attributes of an element.'); 133 }; 134 const immutableHandlers = { 135 get(target, key, receiver) { 136 const value = Reflect.get(target, key, receiver); 137 return !!value && typeof value === 'object' ? deepImmutable(value) : value; 138 }, 139 set: immutableError, 140 deleteProperty: immutableError 141 }; 142 const deepImmutable = target => { 143 if (!immutableMap.has(target)) { 144 immutableMap.set(target, new Proxy(target, immutableHandlers)); 145 } 146 return immutableMap.get(target); 147 }; 148 149 /** 150 * Retrieves the context inherited by the element evaluating a function from the 151 * store. The returned value depends on the element and the namespace where the 152 * function calling `getContext()` exists. 153 * 154 * @param namespace Store namespace. By default, the namespace where the calling 155 * function exists is used. 156 * @return The context content. 157 */ 158 const getContext = namespace => { 159 const scope = getScope(); 160 if (true) { 161 if (!scope) { 162 throw Error('Cannot call `getContext()` when there is no scope. If you are using an async function, please consider using a generator instead. If you are using some sort of async callbacks, like `setTimeout`, please wrap the callback with `withScope(callback)`.'); 163 } 164 } 165 return scope.context[namespace || getNamespace()]; 166 }; 167 168 /** 169 * Retrieves a representation of the element where a function from the store 170 * is being evalutated. Such representation is read-only, and contains a 171 * reference to the DOM element, its props and a local reactive state. 172 * 173 * @return Element representation. 174 */ 175 const getElement = () => { 176 const scope = getScope(); 177 if (true) { 178 if (!scope) { 179 throw Error('Cannot call `getElement()` when there is no scope. If you are using an async function, please consider using a generator instead. If you are using some sort of async callbacks, like `setTimeout`, please wrap the callback with `withScope(callback)`.'); 180 } 181 } 182 const { 183 ref, 184 attributes 185 } = scope; 186 return Object.freeze({ 187 ref: ref.current, 188 attributes: deepImmutable(attributes) 189 }); 190 }; 191 192 /** 193 * Retrieves the part of the inherited context defined and updated from the 194 * server. 195 * 196 * The object returned is read-only, and includes the context defined in PHP 197 * with `wp_interactivity_data_wp_context()`, including the corresponding 198 * inherited properties. When `actions.navigate()` is called, this object is 199 * updated to reflect the changes in the new visited page, without affecting the 200 * context returned by `getContext()`. Directives can subscribe to those changes 201 * to update the context if needed. 202 * 203 * @example 204 * ```js 205 * store('...', { 206 * callbacks: { 207 * updateServerContext() { 208 * const context = getContext(); 209 * const serverContext = getServerContext(); 210 * // Override some property with the new value that came from the server. 211 * context.overridableProp = serverContext.overridableProp; 212 * }, 213 * }, 214 * }); 215 * ``` 216 * 217 * @param namespace Store namespace. By default, the namespace where the calling 218 * function exists is used. 219 * @return The server context content. 220 */ 221 const getServerContext = namespace => { 222 const scope = getScope(); 223 if (true) { 224 if (!scope) { 225 throw Error('Cannot call `getServerContext()` when there is no scope. If you are using an async function, please consider using a generator instead. If you are using some sort of async callbacks, like `setTimeout`, please wrap the callback with `withScope(callback)`.'); 226 } 227 } 228 return scope.serverContext[namespace || getNamespace()]; 229 }; 230 231 ;// ./node_modules/@wordpress/interactivity/build-module/utils.js 232 /** 233 * External dependencies 234 */ 235 236 237 238 /** 239 * Internal dependencies 240 */ 241 242 243 /** 244 * Executes a callback function after the next frame is rendered. 245 * 246 * @param callback The callback function to be executed. 247 * @return A promise that resolves after the callback function is executed. 248 */ 249 const afterNextFrame = callback => { 250 return new Promise(resolve => { 251 const done = () => { 252 clearTimeout(timeout); 253 window.cancelAnimationFrame(raf); 254 setTimeout(() => { 255 callback(); 256 resolve(); 257 }); 258 }; 259 const timeout = setTimeout(done, 100); 260 const raf = window.requestAnimationFrame(done); 261 }); 262 }; 263 264 /** 265 * Returns a promise that resolves after yielding to main. 266 * 267 * @return Promise 268 */ 269 const splitTask = () => { 270 return new Promise(resolve => { 271 // TODO: Use scheduler.yield() when available. 272 setTimeout(resolve, 0); 273 }); 274 }; 275 276 /** 277 * Creates a Flusher object that can be used to flush computed values and notify listeners. 278 * 279 * Using the mangled properties: 280 * this.c: this._callback 281 * this.x: this._compute 282 * https://github.com/preactjs/signals/blob/main/mangle.json 283 * 284 * @param compute The function that computes the value to be flushed. 285 * @param notify The function that notifies listeners when the value is flushed. 286 * @return The Flusher object with `flush` and `dispose` properties. 287 */ 288 function createFlusher(compute, notify) { 289 let flush = () => undefined; 290 const dispose = E(function () { 291 flush = this.c.bind(this); 292 this.x = compute; 293 this.c = notify; 294 return compute(); 295 }); 296 return { 297 flush, 298 dispose 299 }; 300 } 301 302 /** 303 * Custom hook that executes a callback function whenever a signal is triggered. 304 * Version of `useSignalEffect` with a `useEffect`-like execution. This hook 305 * implementation comes from this PR, but we added short-cirtuiting to avoid 306 * infinite loops: https://github.com/preactjs/signals/pull/290 307 * 308 * @param callback The callback function to be executed. 309 */ 310 function utils_useSignalEffect(callback) { 311 y(() => { 312 let eff = null; 313 let isExecuting = false; 314 const notify = async () => { 315 if (eff && !isExecuting) { 316 isExecuting = true; 317 await afterNextFrame(eff.flush); 318 isExecuting = false; 319 } 320 }; 321 eff = createFlusher(callback, notify); 322 return eff.dispose; 323 }, []); 324 } 325 326 /** 327 * Returns the passed function wrapped with the current scope so it is 328 * accessible whenever the function runs. This is primarily to make the scope 329 * available inside hook callbacks. 330 * 331 * Asyncronous functions should use generators that yield promises instead of awaiting them. 332 * See the documentation for details: https://developer.wordpress.org/block-editor/reference-guides/packages/packages-interactivity/packages-interactivity-api-reference/#the-store 333 * 334 * @param func The passed function. 335 * @return The wrapped function. 336 */ 337 338 function withScope(func) { 339 const scope = getScope(); 340 const ns = getNamespace(); 341 if (func?.constructor?.name === 'GeneratorFunction') { 342 return async (...args) => { 343 const gen = func(...args); 344 let value; 345 let it; 346 while (true) { 347 setNamespace(ns); 348 setScope(scope); 349 try { 350 it = gen.next(value); 351 } finally { 352 resetScope(); 353 resetNamespace(); 354 } 355 try { 356 value = await it.value; 357 } catch (e) { 358 setNamespace(ns); 359 setScope(scope); 360 gen.throw(e); 361 } finally { 362 resetScope(); 363 resetNamespace(); 364 } 365 if (it.done) { 366 break; 367 } 368 } 369 return value; 370 }; 371 } 372 return (...args) => { 373 setNamespace(ns); 374 setScope(scope); 375 try { 376 return func(...args); 377 } finally { 378 resetNamespace(); 379 resetScope(); 380 } 381 }; 382 } 383 384 /** 385 * Accepts a function that contains imperative code which runs whenever any of 386 * the accessed _reactive_ properties (e.g., values from the global state or the 387 * context) is modified. 388 * 389 * This hook makes the element's scope available so functions like 390 * `getElement()` and `getContext()` can be used inside the passed callback. 391 * 392 * @param callback The hook callback. 393 */ 394 function useWatch(callback) { 395 utils_useSignalEffect(withScope(callback)); 396 } 397 398 /** 399 * Accepts a function that contains imperative code which runs only after the 400 * element's first render, mainly useful for intialization logic. 401 * 402 * This hook makes the element's scope available so functions like 403 * `getElement()` and `getContext()` can be used inside the passed callback. 404 * 405 * @param callback The hook callback. 406 */ 407 function useInit(callback) { 408 y(withScope(callback), []); 409 } 410 411 /** 412 * Accepts a function that contains imperative, possibly effectful code. The 413 * effects run after browser paint, without blocking it. 414 * 415 * This hook is equivalent to Preact's `useEffect` and makes the element's scope 416 * available so functions like `getElement()` and `getContext()` can be used 417 * inside the passed callback. 418 * 419 * @param callback Imperative function that can return a cleanup 420 * function. 421 * @param inputs If present, effect will only activate if the 422 * values in the list change (using `===`). 423 */ 424 function useEffect(callback, inputs) { 425 y(withScope(callback), inputs); 426 } 427 428 /** 429 * Accepts a function that contains imperative, possibly effectful code. Use 430 * this to read layout from the DOM and synchronously re-render. 431 * 432 * This hook is equivalent to Preact's `useLayoutEffect` and makes the element's 433 * scope available so functions like `getElement()` and `getContext()` can be 434 * used inside the passed callback. 435 * 436 * @param callback Imperative function that can return a cleanup 437 * function. 438 * @param inputs If present, effect will only activate if the 439 * values in the list change (using `===`). 440 */ 441 function useLayoutEffect(callback, inputs) { 442 _(withScope(callback), inputs); 443 } 444 445 /** 446 * Returns a memoized version of the callback that only changes if one of the 447 * inputs has changed (using `===`). 448 * 449 * This hook is equivalent to Preact's `useCallback` and makes the element's 450 * scope available so functions like `getElement()` and `getContext()` can be 451 * used inside the passed callback. 452 * 453 * @param callback Callback function. 454 * @param inputs If present, the callback will only be updated if the 455 * values in the list change (using `===`). 456 * 457 * @return The callback function. 458 */ 459 function useCallback(callback, inputs) { 460 return q(withScope(callback), inputs); 461 } 462 463 /** 464 * Pass a factory function and an array of inputs. `useMemo` will only recompute 465 * the memoized value when one of the inputs has changed. 466 * 467 * This hook is equivalent to Preact's `useMemo` and makes the element's scope 468 * available so functions like `getElement()` and `getContext()` can be used 469 * inside the passed factory function. 470 * 471 * @param factory Factory function that returns that value for memoization. 472 * @param inputs If present, the factory will only be run to recompute if 473 * the values in the list change (using `===`). 474 * 475 * @return The memoized value. 476 */ 477 function useMemo(factory, inputs) { 478 return T(withScope(factory), inputs); 479 } 480 481 /** 482 * Creates a root fragment by replacing a node or an array of nodes in a parent element. 483 * For wrapperless hydration. 484 * See https://gist.github.com/developit/f4c67a2ede71dc2fab7f357f39cff28c 485 * 486 * @param parent The parent element where the nodes will be replaced. 487 * @param replaceNode The node or array of nodes to replace in the parent element. 488 * @return The created root fragment. 489 */ 490 const createRootFragment = (parent, replaceNode) => { 491 replaceNode = [].concat(replaceNode); 492 const sibling = replaceNode[replaceNode.length - 1].nextSibling; 493 function insert(child, root) { 494 parent.insertBefore(child, root || sibling); 495 } 496 return parent.__k = { 497 nodeType: 1, 498 parentNode: parent, 499 firstChild: replaceNode[0], 500 childNodes: replaceNode, 501 insertBefore: insert, 502 appendChild: insert, 503 removeChild(c) { 504 parent.removeChild(c); 505 } 506 }; 507 }; 508 509 /** 510 * Transforms a kebab-case string to camelCase. 511 * 512 * @param str The kebab-case string to transform to camelCase. 513 * @return The transformed camelCase string. 514 */ 515 function kebabToCamelCase(str) { 516 return str.replace(/^-+|-+$/g, '').toLowerCase().replace(/-([a-z])/g, function (_match, group1) { 517 return group1.toUpperCase(); 518 }); 519 } 520 const logged = new Set(); 521 522 /** 523 * Shows a warning with `message` if environment is not `production`. 524 * 525 * Based on the `@wordpress/warning` package. 526 * 527 * @param message Message to show in the warning. 528 */ 529 const warn = message => { 530 if (true) { 531 if (logged.has(message)) { 532 return; 533 } 534 535 // eslint-disable-next-line no-console 536 console.warn(message); 537 538 // Throwing an error and catching it immediately to improve debugging 539 // A consumer can use 'pause on caught exceptions' 540 try { 541 throw Error(message); 542 } catch (e) { 543 // Do nothing. 544 } 545 logged.add(message); 546 } 547 }; 548 549 /** 550 * Checks if the passed `candidate` is a plain object with just the `Object` 551 * prototype. 552 * 553 * @param candidate The item to check. 554 * @return Whether `candidate` is a plain object. 555 */ 556 const isPlainObject = candidate => Boolean(candidate && typeof candidate === 'object' && candidate.constructor === Object); 557 558 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/registry.js 559 /** 560 * Proxies for each object. 561 */ 562 const objToProxy = new WeakMap(); 563 const proxyToObj = new WeakMap(); 564 565 /** 566 * Namespaces for each created proxy. 567 */ 568 const proxyToNs = new WeakMap(); 569 570 /** 571 * Object types that can be proxied. 572 */ 573 const supported = new Set([Object, Array]); 574 575 /** 576 * Returns a proxy to the passed object with the given handlers, assigning the 577 * specified namespace to it. If a proxy for the passed object was created 578 * before, that proxy is returned. 579 * 580 * @param namespace The namespace that will be associated to this proxy. 581 * @param obj The object to proxify. 582 * @param handlers Handlers that the proxy will use. 583 * 584 * @throws Error if the object cannot be proxified. Use {@link shouldProxy} to 585 * check if a proxy can be created for a specific object. 586 * 587 * @return The created proxy. 588 */ 589 const createProxy = (namespace, obj, handlers) => { 590 if (!shouldProxy(obj)) { 591 throw Error('This object cannot be proxified.'); 592 } 593 if (!objToProxy.has(obj)) { 594 const proxy = new Proxy(obj, handlers); 595 objToProxy.set(obj, proxy); 596 proxyToObj.set(proxy, obj); 597 proxyToNs.set(proxy, namespace); 598 } 599 return objToProxy.get(obj); 600 }; 601 602 /** 603 * Returns the proxy for the given object. If there is no associated proxy, the 604 * function returns `undefined`. 605 * 606 * @param obj Object from which to know the proxy. 607 * @return Associated proxy or `undefined`. 608 */ 609 const getProxyFromObject = obj => objToProxy.get(obj); 610 611 /** 612 * Gets the namespace associated with the given proxy. 613 * 614 * Proxies have a namespace assigned upon creation. See {@link createProxy}. 615 * 616 * @param proxy Proxy. 617 * @return Namespace. 618 */ 619 const getNamespaceFromProxy = proxy => proxyToNs.get(proxy); 620 621 /** 622 * Checks if a given object can be proxied. 623 * 624 * @param candidate Object to know whether it can be proxied. 625 * @return True if the passed instance can be proxied. 626 */ 627 const shouldProxy = candidate => { 628 if (typeof candidate !== 'object' || candidate === null) { 629 return false; 630 } 631 return !proxyToNs.has(candidate) && supported.has(candidate.constructor); 632 }; 633 634 /** 635 * Returns the target object for the passed proxy. If the passed object is not a registered proxy, the 636 * function returns `undefined`. 637 * 638 * @param proxy Proxy from which to know the target. 639 * @return The target object or `undefined`. 640 */ 641 const getObjectFromProxy = proxy => proxyToObj.get(proxy); 642 643 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/signals.js 644 /** 645 * External dependencies 646 */ 647 648 649 /** 650 * Internal dependencies 651 */ 652 653 654 655 656 657 /** 658 * Identifier for property computeds not associated to any scope. 659 */ 660 const NO_SCOPE = {}; 661 662 /** 663 * Structure that manages reactivity for a property in a state object. It uses 664 * signals to keep track of property value or getter modifications. 665 */ 666 class PropSignal { 667 /** 668 * Proxy that holds the property this PropSignal is associated with. 669 */ 670 671 /** 672 * Relation of computeds by scope. These computeds are read-only signals 673 * that depend on whether the property is a value or a getter and, 674 * therefore, can return different values depending on the scope in which 675 * the getter is accessed. 676 */ 677 678 /** 679 * Signal with the value assigned to the related property. 680 */ 681 682 /** 683 * Signal with the getter assigned to the related property. 684 */ 685 686 /** 687 * Structure that manages reactivity for a property in a state object, using 688 * signals to keep track of property value or getter modifications. 689 * 690 * @param owner Proxy that holds the property this instance is associated 691 * with. 692 */ 693 constructor(owner) { 694 this.owner = owner; 695 this.computedsByScope = new WeakMap(); 696 } 697 698 /** 699 * Changes the internal value. If a getter was set before, it is set to 700 * `undefined`. 701 * 702 * @param value New value. 703 */ 704 setValue(value) { 705 this.update({ 706 value 707 }); 708 } 709 710 /** 711 * Changes the internal getter. If a value was set before, it is set to 712 * `undefined`. 713 * 714 * @param getter New getter. 715 */ 716 setGetter(getter) { 717 this.update({ 718 get: getter 719 }); 720 } 721 722 /** 723 * Returns the computed that holds the result of evaluating the prop in the 724 * current scope. 725 * 726 * These computeds are read-only signals that depend on whether the property 727 * is a value or a getter and, therefore, can return different values 728 * depending on the scope in which the getter is accessed. 729 * 730 * @return Computed that depends on the scope. 731 */ 732 getComputed() { 733 const scope = getScope() || NO_SCOPE; 734 if (!this.valueSignal && !this.getterSignal) { 735 this.update({}); 736 } 737 if (!this.computedsByScope.has(scope)) { 738 const callback = () => { 739 const getter = this.getterSignal?.value; 740 return getter ? getter.call(this.owner) : this.valueSignal?.value; 741 }; 742 setNamespace(getNamespaceFromProxy(this.owner)); 743 this.computedsByScope.set(scope, signals_core_module_w(withScope(callback))); 744 resetNamespace(); 745 } 746 return this.computedsByScope.get(scope); 747 } 748 749 /** 750 * Update the internal signals for the value and the getter of the 751 * corresponding prop. 752 * 753 * @param param0 754 * @param param0.get New getter. 755 * @param param0.value New value. 756 */ 757 update({ 758 get, 759 value 760 }) { 761 if (!this.valueSignal) { 762 this.valueSignal = signals_core_module_d(value); 763 this.getterSignal = signals_core_module_d(get); 764 } else if (value !== this.valueSignal.peek() || get !== this.getterSignal.peek()) { 765 signals_core_module_r(() => { 766 this.valueSignal.value = value; 767 this.getterSignal.value = get; 768 }); 769 } 770 } 771 } 772 773 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/state.js 774 /** 775 * External dependencies 776 */ 777 778 779 /** 780 * Internal dependencies 781 */ 782 783 784 785 786 787 /** 788 * Set of built-in symbols. 789 */ 790 const wellKnownSymbols = new Set(Object.getOwnPropertyNames(Symbol).map(key => Symbol[key]).filter(value => typeof value === 'symbol')); 791 792 /** 793 * Relates each proxy with a map of {@link PropSignal} instances, representing 794 * the proxy's accessed properties. 795 */ 796 const proxyToProps = new WeakMap(); 797 798 /** 799 * Checks wether a {@link PropSignal | `PropSignal`} instance exists for the 800 * given property in the passed proxy. 801 * 802 * @param proxy Proxy of a state object or array. 803 * @param key The property key. 804 * @return `true` when it exists; false otherwise. 805 */ 806 const hasPropSignal = (proxy, key) => proxyToProps.has(proxy) && proxyToProps.get(proxy).has(key); 807 const readOnlyProxies = new WeakSet(); 808 809 /** 810 * Returns the {@link PropSignal | `PropSignal`} instance associated with the 811 * specified prop in the passed proxy. 812 * 813 * The `PropSignal` instance is generated if it doesn't exist yet, using the 814 * `initial` parameter to initialize the internal signals. 815 * 816 * @param proxy Proxy of a state object or array. 817 * @param key The property key. 818 * @param initial Initial data for the `PropSignal` instance. 819 * @return The `PropSignal` instance. 820 */ 821 const getPropSignal = (proxy, key, initial) => { 822 if (!proxyToProps.has(proxy)) { 823 proxyToProps.set(proxy, new Map()); 824 } 825 key = typeof key === 'number' ? `$key}` : key; 826 const props = proxyToProps.get(proxy); 827 if (!props.has(key)) { 828 const ns = getNamespaceFromProxy(proxy); 829 const prop = new PropSignal(proxy); 830 props.set(key, prop); 831 if (initial) { 832 const { 833 get, 834 value 835 } = initial; 836 if (get) { 837 prop.setGetter(get); 838 } else { 839 const readOnly = readOnlyProxies.has(proxy); 840 prop.setValue(shouldProxy(value) ? proxifyState(ns, value, { 841 readOnly 842 }) : value); 843 } 844 } 845 } 846 return props.get(key); 847 }; 848 849 /** 850 * Relates each proxied object (i.e., the original object) with a signal that 851 * tracks changes in the number of properties. 852 */ 853 const objToIterable = new WeakMap(); 854 855 /** 856 * When this flag is `true`, it avoids any signal subscription, overriding state 857 * props' "reactive" behavior. 858 */ 859 let peeking = false; 860 861 /** 862 * Handlers for reactive objects and arrays in the state. 863 */ 864 const stateHandlers = { 865 get(target, key, receiver) { 866 /* 867 * The property should not be reactive for the following cases: 868 * 1. While using the `peek` function to read the property. 869 * 2. The property exists but comes from the Object or Array prototypes. 870 * 3. The property key is a known symbol. 871 */ 872 if (peeking || !target.hasOwnProperty(key) && key in target || typeof key === 'symbol' && wellKnownSymbols.has(key)) { 873 return Reflect.get(target, key, receiver); 874 } 875 876 // At this point, the property should be reactive. 877 const desc = Object.getOwnPropertyDescriptor(target, key); 878 const prop = getPropSignal(receiver, key, desc); 879 const result = prop.getComputed().value; 880 881 /* 882 * Check if the property is a synchronous function. If it is, set the 883 * default namespace. Synchronous functions always run in the proper scope, 884 * which is set by the Directives component. 885 */ 886 if (typeof result === 'function') { 887 const ns = getNamespaceFromProxy(receiver); 888 return (...args) => { 889 setNamespace(ns); 890 try { 891 return result.call(receiver, ...args); 892 } finally { 893 resetNamespace(); 894 } 895 }; 896 } 897 return result; 898 }, 899 set(target, key, value, receiver) { 900 if (readOnlyProxies.has(receiver)) { 901 return false; 902 } 903 setNamespace(getNamespaceFromProxy(receiver)); 904 try { 905 return Reflect.set(target, key, value, receiver); 906 } finally { 907 resetNamespace(); 908 } 909 }, 910 defineProperty(target, key, desc) { 911 if (readOnlyProxies.has(getProxyFromObject(target))) { 912 return false; 913 } 914 const isNew = !(key in target); 915 const result = Reflect.defineProperty(target, key, desc); 916 if (result) { 917 const receiver = getProxyFromObject(target); 918 const prop = getPropSignal(receiver, key); 919 const { 920 get, 921 value 922 } = desc; 923 if (get) { 924 prop.setGetter(get); 925 } else { 926 const ns = getNamespaceFromProxy(receiver); 927 prop.setValue(shouldProxy(value) ? proxifyState(ns, value) : value); 928 } 929 if (isNew && objToIterable.has(target)) { 930 objToIterable.get(target).value++; 931 } 932 933 /* 934 * Modify the `length` property value only if the related 935 * `PropSignal` exists, which means that there are subscriptions to 936 * this property. 937 */ 938 if (Array.isArray(target) && proxyToProps.get(receiver)?.has('length')) { 939 const length = getPropSignal(receiver, 'length'); 940 length.setValue(target.length); 941 } 942 } 943 return result; 944 }, 945 deleteProperty(target, key) { 946 if (readOnlyProxies.has(getProxyFromObject(target))) { 947 return false; 948 } 949 const result = Reflect.deleteProperty(target, key); 950 if (result) { 951 const prop = getPropSignal(getProxyFromObject(target), key); 952 prop.setValue(undefined); 953 if (objToIterable.has(target)) { 954 objToIterable.get(target).value++; 955 } 956 } 957 return result; 958 }, 959 ownKeys(target) { 960 if (!objToIterable.has(target)) { 961 objToIterable.set(target, signals_core_module_d(0)); 962 } 963 /* 964 *This subscribes to the signal while preventing the minifier from 965 * deleting this line in production. 966 */ 967 objToIterable._ = objToIterable.get(target).value; 968 return Reflect.ownKeys(target); 969 } 970 }; 971 972 /** 973 * Returns the proxy associated with the given state object, creating it if it 974 * does not exist. 975 * 976 * @param namespace The namespace that will be associated to this proxy. 977 * @param obj The object to proxify. 978 * @param options Options. 979 * @param options.readOnly Read-only. 980 * 981 * @throws Error if the object cannot be proxified. Use {@link shouldProxy} to 982 * check if a proxy can be created for a specific object. 983 * 984 * @return The associated proxy. 985 */ 986 const proxifyState = (namespace, obj, options) => { 987 const proxy = createProxy(namespace, obj, stateHandlers); 988 if (options?.readOnly) { 989 readOnlyProxies.add(proxy); 990 } 991 return proxy; 992 }; 993 994 /** 995 * Reads the value of the specified property without subscribing to it. 996 * 997 * @param obj The object to read the property from. 998 * @param key The property key. 999 * @return The property value. 1000 */ 1001 const peek = (obj, key) => { 1002 peeking = true; 1003 try { 1004 return obj[key]; 1005 } finally { 1006 peeking = false; 1007 } 1008 }; 1009 1010 /** 1011 * Internal recursive implementation for {@link deepMerge | `deepMerge`}. 1012 * 1013 * @param target The target object. 1014 * @param source The source object containing new values and props. 1015 * @param override Whether existing props should be overwritten or not (`true` 1016 * by default). 1017 */ 1018 const deepMergeRecursive = (target, source, override = true) => { 1019 if (!(isPlainObject(target) && isPlainObject(source))) { 1020 return; 1021 } 1022 let hasNewKeys = false; 1023 for (const key in source) { 1024 const isNew = !(key in target); 1025 hasNewKeys = hasNewKeys || isNew; 1026 const desc = Object.getOwnPropertyDescriptor(source, key); 1027 const proxy = getProxyFromObject(target); 1028 const propSignal = !!proxy && hasPropSignal(proxy, key) && getPropSignal(proxy, key); 1029 if (typeof desc.get === 'function' || typeof desc.set === 'function') { 1030 if (override || isNew) { 1031 Object.defineProperty(target, key, { 1032 ...desc, 1033 configurable: true, 1034 enumerable: true 1035 }); 1036 if (desc.get && propSignal) { 1037 propSignal.setGetter(desc.get); 1038 } 1039 } 1040 } else if (isPlainObject(source[key])) { 1041 if (isNew || override && !isPlainObject(target[key])) { 1042 target[key] = {}; 1043 if (propSignal) { 1044 const ns = getNamespaceFromProxy(proxy); 1045 propSignal.setValue(proxifyState(ns, target[key])); 1046 } 1047 } 1048 if (isPlainObject(target[key])) { 1049 deepMergeRecursive(target[key], source[key], override); 1050 } 1051 } else if (override || isNew) { 1052 Object.defineProperty(target, key, desc); 1053 if (propSignal) { 1054 const { 1055 value 1056 } = desc; 1057 const ns = getNamespaceFromProxy(proxy); 1058 propSignal.setValue(shouldProxy(value) ? proxifyState(ns, value) : value); 1059 } 1060 } 1061 } 1062 if (hasNewKeys && objToIterable.has(target)) { 1063 objToIterable.get(target).value++; 1064 } 1065 }; 1066 1067 /** 1068 * Recursively update prop values inside the passed `target` and nested plain 1069 * objects, using the values present in `source`. References to plain objects 1070 * are kept, only updating props containing primitives or arrays. Arrays are 1071 * replaced instead of merged or concatenated. 1072 * 1073 * If the `override` parameter is set to `false`, then all values in `target` 1074 * are preserved, and only new properties from `source` are added. 1075 * 1076 * @param target The target object. 1077 * @param source The source object containing new values and props. 1078 * @param override Whether existing props should be overwritten or not (`true` 1079 * by default). 1080 */ 1081 const deepMerge = (target, source, override = true) => signals_core_module_r(() => deepMergeRecursive(getObjectFromProxy(target) || target, source, override)); 1082 1083 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/store.js 1084 /** 1085 * Internal dependencies 1086 */ 1087 1088 /** 1089 * External dependencies 1090 */ 1091 1092 1093 1094 /** 1095 * Identifies the store proxies handling the root objects of each store. 1096 */ 1097 const storeRoots = new WeakSet(); 1098 1099 /** 1100 * Handlers for store proxies. 1101 */ 1102 const storeHandlers = { 1103 get: (target, key, receiver) => { 1104 const result = Reflect.get(target, key); 1105 const ns = getNamespaceFromProxy(receiver); 1106 1107 /* 1108 * Check if the proxy is the store root and no key with that name exist. In 1109 * that case, return an empty object for the requested key. 1110 */ 1111 if (typeof result === 'undefined' && storeRoots.has(receiver)) { 1112 const obj = {}; 1113 Reflect.set(target, key, obj); 1114 return proxifyStore(ns, obj, false); 1115 } 1116 1117 /* 1118 * Check if the property is a function. If it is, add the store 1119 * namespace to the stack and wrap the function with the current scope. 1120 * The `withScope` util handles both synchronous functions and generator 1121 * functions. 1122 */ 1123 if (typeof result === 'function') { 1124 setNamespace(ns); 1125 const scoped = withScope(result); 1126 resetNamespace(); 1127 return scoped; 1128 } 1129 1130 // Check if the property is an object. If it is, proxyify it. 1131 if (isPlainObject(result) && shouldProxy(result)) { 1132 return proxifyStore(ns, result, false); 1133 } 1134 return result; 1135 } 1136 }; 1137 1138 /** 1139 * Returns the proxy associated with the given store object, creating it if it 1140 * does not exist. 1141 * 1142 * @param namespace The namespace that will be associated to this proxy. 1143 * @param obj The object to proxify. 1144 * 1145 * @param isRoot Whether the passed object is the store root object. 1146 * @throws Error if the object cannot be proxified. Use {@link shouldProxy} to 1147 * check if a proxy can be created for a specific object. 1148 * 1149 * @return The associated proxy. 1150 */ 1151 const proxifyStore = (namespace, obj, isRoot = true) => { 1152 const proxy = createProxy(namespace, obj, storeHandlers); 1153 if (proxy && isRoot) { 1154 storeRoots.add(proxy); 1155 } 1156 return proxy; 1157 }; 1158 1159 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/context.js 1160 const contextObjectToProxy = new WeakMap(); 1161 const contextObjectToFallback = new WeakMap(); 1162 const contextProxies = new WeakSet(); 1163 const descriptor = Reflect.getOwnPropertyDescriptor; 1164 1165 // TODO: Use the proxy registry to avoid multiple proxies on the same object. 1166 const contextHandlers = { 1167 get: (target, key) => { 1168 const fallback = contextObjectToFallback.get(target); 1169 // Always subscribe to prop changes in the current context. 1170 const currentProp = target[key]; 1171 1172 /* 1173 * Return the value from `target` if it exists, or from `fallback` 1174 * otherwise. This way, in the case the property doesn't exist either in 1175 * `target` or `fallback`, it also subscribes to changes in the parent 1176 * context. 1177 */ 1178 return key in target ? currentProp : fallback[key]; 1179 }, 1180 set: (target, key, value) => { 1181 const fallback = contextObjectToFallback.get(target); 1182 1183 // If the property exists in the current context, modify it. Otherwise, 1184 // add it to the current context. 1185 const obj = key in target || !(key in fallback) ? target : fallback; 1186 obj[key] = value; 1187 return true; 1188 }, 1189 ownKeys: target => [...new Set([...Object.keys(contextObjectToFallback.get(target)), ...Object.keys(target)])], 1190 getOwnPropertyDescriptor: (target, key) => descriptor(target, key) || descriptor(contextObjectToFallback.get(target), key) 1191 }; 1192 1193 /** 1194 * Wrap a context object with a proxy to reproduce the context stack. The proxy 1195 * uses the passed `inherited` context as a fallback to look up for properties 1196 * that don't exist in the given context. Also, updated properties are modified 1197 * where they are defined, or added to the main context when they don't exist. 1198 * 1199 * @param current Current context. 1200 * @param inherited Inherited context, used as fallback. 1201 * 1202 * @return The wrapped context object. 1203 */ 1204 const proxifyContext = (current, inherited = {}) => { 1205 if (contextProxies.has(current)) { 1206 throw Error('This object cannot be proxified.'); 1207 } 1208 // Update the fallback object reference when it changes. 1209 contextObjectToFallback.set(current, inherited); 1210 if (!contextObjectToProxy.has(current)) { 1211 const proxy = new Proxy(current, contextHandlers); 1212 contextObjectToProxy.set(current, proxy); 1213 contextProxies.add(proxy); 1214 } 1215 return contextObjectToProxy.get(current); 1216 }; 1217 1218 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/index.js 1219 /** 1220 * Internal dependencies 1221 */ 1222 1223 1224 1225 1226 ;// ./node_modules/@wordpress/interactivity/build-module/store.js 1227 /** 1228 * Internal dependencies 1229 */ 1230 1231 /** 1232 * External dependencies 1233 */ 1234 1235 1236 const stores = new Map(); 1237 const rawStores = new Map(); 1238 const storeLocks = new Map(); 1239 const storeConfigs = new Map(); 1240 const serverStates = new Map(); 1241 1242 /** 1243 * Get the defined config for the store with the passed namespace. 1244 * 1245 * @param namespace Store's namespace from which to retrieve the config. 1246 * @return Defined config for the given namespace. 1247 */ 1248 const getConfig = namespace => storeConfigs.get(namespace || getNamespace()) || {}; 1249 1250 /** 1251 * Get the part of the state defined and updated from the server. 1252 * 1253 * The object returned is read-only, and includes the state defined in PHP with 1254 * `wp_interactivity_state()`. When using `actions.navigate()`, this object is 1255 * updated to reflect the changes in its properites, without affecting the state 1256 * returned by `store()`. Directives can subscribe to those changes to update 1257 * the state if needed. 1258 * 1259 * @example 1260 * ```js 1261 * const { state } = store('myStore', { 1262 * callbacks: { 1263 * updateServerState() { 1264 * const serverState = getServerState(); 1265 * // Override some property with the new value that came from the server. 1266 * state.overridableProp = serverState.overridableProp; 1267 * }, 1268 * }, 1269 * }); 1270 * ``` 1271 * 1272 * @param namespace Store's namespace from which to retrieve the server state. 1273 * @return The server state for the given namespace. 1274 */ 1275 const getServerState = namespace => { 1276 const ns = namespace || getNamespace(); 1277 if (!serverStates.has(ns)) { 1278 serverStates.set(ns, proxifyState(ns, {}, { 1279 readOnly: true 1280 })); 1281 } 1282 return serverStates.get(ns); 1283 }; 1284 const universalUnlock = 'I acknowledge that using a private store means my plugin will inevitably break on the next store release.'; 1285 1286 /** 1287 * Extends the Interactivity API global store adding the passed properties to 1288 * the given namespace. It also returns stable references to the namespace 1289 * content. 1290 * 1291 * These props typically consist of `state`, which is the reactive part of the 1292 * store ― which means that any directive referencing a state property will be 1293 * re-rendered anytime it changes ― and function properties like `actions` and 1294 * `callbacks`, mostly used for event handlers. These props can then be 1295 * referenced by any directive to make the HTML interactive. 1296 * 1297 * @example 1298 * ```js 1299 * const { state } = store( 'counter', { 1300 * state: { 1301 * value: 0, 1302 * get double() { return state.value * 2; }, 1303 * }, 1304 * actions: { 1305 * increment() { 1306 * state.value += 1; 1307 * }, 1308 * }, 1309 * } ); 1310 * ``` 1311 * 1312 * The code from the example above allows blocks to subscribe and interact with 1313 * the store by using directives in the HTML, e.g.: 1314 * 1315 * ```html 1316 * <div data-wp-interactive="counter"> 1317 * <button 1318 * data-wp-text="state.double" 1319 * data-wp-on--click="actions.increment" 1320 * > 1321 * 0 1322 * </button> 1323 * </div> 1324 * ``` 1325 * @param namespace The store namespace to interact with. 1326 * @param storePart Properties to add to the store namespace. 1327 * @param options Options for the given namespace. 1328 * 1329 * @return A reference to the namespace content. 1330 */ 1331 1332 function store(namespace, { 1333 state = {}, 1334 ...block 1335 } = {}, { 1336 lock = false 1337 } = {}) { 1338 if (!stores.has(namespace)) { 1339 // Lock the store if the passed lock is different from the universal 1340 // unlock. Once the lock is set (either false, true, or a given string), 1341 // it cannot change. 1342 if (lock !== universalUnlock) { 1343 storeLocks.set(namespace, lock); 1344 } 1345 const rawStore = { 1346 state: proxifyState(namespace, isPlainObject(state) ? state : {}), 1347 ...block 1348 }; 1349 const proxifiedStore = proxifyStore(namespace, rawStore); 1350 rawStores.set(namespace, rawStore); 1351 stores.set(namespace, proxifiedStore); 1352 } else { 1353 // Lock the store if it wasn't locked yet and the passed lock is 1354 // different from the universal unlock. If no lock is given, the store 1355 // will be public and won't accept any lock from now on. 1356 if (lock !== universalUnlock && !storeLocks.has(namespace)) { 1357 storeLocks.set(namespace, lock); 1358 } else { 1359 const storeLock = storeLocks.get(namespace); 1360 const isLockValid = lock === universalUnlock || lock !== true && lock === storeLock; 1361 if (!isLockValid) { 1362 if (!storeLock) { 1363 throw Error('Cannot lock a public store'); 1364 } else { 1365 throw Error('Cannot unlock a private store with an invalid lock code'); 1366 } 1367 } 1368 } 1369 const target = rawStores.get(namespace); 1370 deepMerge(target, block); 1371 deepMerge(target.state, state); 1372 } 1373 return stores.get(namespace); 1374 } 1375 const parseServerData = (dom = document) => { 1376 var _dom$getElementById; 1377 const jsonDataScriptTag = // Preferred Script Module data passing form 1378 (_dom$getElementById = dom.getElementById('wp-script-module-data-@wordpress/interactivity')) !== null && _dom$getElementById !== void 0 ? _dom$getElementById : 1379 // Legacy form 1380 dom.getElementById('wp-interactivity-data'); 1381 if (jsonDataScriptTag?.textContent) { 1382 try { 1383 return JSON.parse(jsonDataScriptTag.textContent); 1384 } catch {} 1385 } 1386 return {}; 1387 }; 1388 const populateServerData = data => { 1389 if (isPlainObject(data?.state)) { 1390 Object.entries(data.state).forEach(([namespace, state]) => { 1391 const st = store(namespace, {}, { 1392 lock: universalUnlock 1393 }); 1394 deepMerge(st.state, state, false); 1395 deepMerge(getServerState(namespace), state); 1396 }); 1397 } 1398 if (isPlainObject(data?.config)) { 1399 Object.entries(data.config).forEach(([namespace, config]) => { 1400 storeConfigs.set(namespace, config); 1401 }); 1402 } 1403 }; 1404 1405 // Parse and populate the initial state and config. 1406 const data = parseServerData(); 1407 populateServerData(data); 1408 1409 ;// ./node_modules/@wordpress/interactivity/build-module/hooks.js 1410 // eslint-disable-next-line eslint-comments/disable-enable-pair 1411 /* eslint-disable react-hooks/exhaustive-deps */ 1412 1413 /** 1414 * External dependencies 1415 */ 1416 1417 1418 /** 1419 * Internal dependencies 1420 */ 1421 1422 1423 1424 function isNonDefaultDirectiveSuffix(entry) { 1425 return entry.suffix !== null; 1426 } 1427 function isDefaultDirectiveSuffix(entry) { 1428 return entry.suffix === null; 1429 } 1430 // Main context. 1431 const context = (0,preact_module/* createContext */.q6)({ 1432 client: {}, 1433 server: {} 1434 }); 1435 1436 // WordPress Directives. 1437 const directiveCallbacks = {}; 1438 const directivePriorities = {}; 1439 1440 /** 1441 * Register a new directive type in the Interactivity API runtime. 1442 * 1443 * @example 1444 * ```js 1445 * directive( 1446 * 'alert', // Name without the `data-wp-` prefix. 1447 * ( { directives: { alert }, element, evaluate } ) => { 1448 * const defaultEntry = alert.find( isDefaultDirectiveSuffix ); 1449 * element.props.onclick = () => { alert( evaluate( defaultEntry ) ); } 1450 * } 1451 * ) 1452 * ``` 1453 * 1454 * The previous code registers a custom directive type for displaying an alert 1455 * message whenever an element using it is clicked. The message text is obtained 1456 * from the store under the inherited namespace, using `evaluate`. 1457 * 1458 * When the HTML is processed by the Interactivity API, any element containing 1459 * the `data-wp-alert` directive will have the `onclick` event handler, e.g., 1460 * 1461 * ```html 1462 * <div data-wp-interactive="messages"> 1463 * <button data-wp-alert="state.alert">Click me!</button> 1464 * </div> 1465 * ``` 1466 * Note that, in the previous example, the directive callback gets the path 1467 * value (`state.alert`) from the directive entry with suffix `null`. A 1468 * custom suffix can also be specified by appending `--` to the directive 1469 * attribute, followed by the suffix, like in the following HTML snippet: 1470 * 1471 * ```html 1472 * <div data-wp-interactive="myblock"> 1473 * <button 1474 * data-wp-color--text="state.text" 1475 * data-wp-color--background="state.background" 1476 * >Click me!</button> 1477 * </div> 1478 * ``` 1479 * 1480 * This could be an hypothetical implementation of the custom directive used in 1481 * the snippet above. 1482 * 1483 * @example 1484 * ```js 1485 * directive( 1486 * 'color', // Name without prefix and suffix. 1487 * ( { directives: { color: colors }, ref, evaluate } ) => 1488 * colors.forEach( ( color ) => { 1489 * if ( color.suffix = 'text' ) { 1490 * ref.style.setProperty( 1491 * 'color', 1492 * evaluate( color.text ) 1493 * ); 1494 * } 1495 * if ( color.suffix = 'background' ) { 1496 * ref.style.setProperty( 1497 * 'background-color', 1498 * evaluate( color.background ) 1499 * ); 1500 * } 1501 * } ); 1502 * } 1503 * ) 1504 * ``` 1505 * 1506 * @param name Directive name, without the `data-wp-` prefix. 1507 * @param callback Function that runs the directive logic. 1508 * @param options Options object. 1509 * @param options.priority Option to control the directive execution order. The 1510 * lesser, the highest priority. Default is `10`. 1511 */ 1512 const directive = (name, callback, { 1513 priority = 10 1514 } = {}) => { 1515 directiveCallbacks[name] = callback; 1516 directivePriorities[name] = priority; 1517 }; 1518 1519 // Resolve the path to some property of the store object. 1520 const resolve = (path, namespace) => { 1521 if (!namespace) { 1522 warn(`Namespace missing for "$path}". The value for that path won't be resolved.`); 1523 return; 1524 } 1525 let resolvedStore = stores.get(namespace); 1526 if (typeof resolvedStore === 'undefined') { 1527 resolvedStore = store(namespace, undefined, { 1528 lock: universalUnlock 1529 }); 1530 } 1531 const current = { 1532 ...resolvedStore, 1533 context: getScope().context[namespace] 1534 }; 1535 try { 1536 // TODO: Support lazy/dynamically initialized stores 1537 return path.split('.').reduce((acc, key) => acc[key], current); 1538 } catch (e) {} 1539 }; 1540 1541 // Generate the evaluate function. 1542 const getEvaluate = ({ 1543 scope 1544 }) => (entry, ...args) => { 1545 let { 1546 value: path, 1547 namespace 1548 } = entry; 1549 if (typeof path !== 'string') { 1550 throw new Error('The `value` prop should be a string path'); 1551 } 1552 // If path starts with !, remove it and save a flag. 1553 const hasNegationOperator = path[0] === '!' && !!(path = path.slice(1)); 1554 setScope(scope); 1555 const value = resolve(path, namespace); 1556 const result = typeof value === 'function' ? value(...args) : value; 1557 resetScope(); 1558 return hasNegationOperator ? !result : result; 1559 }; 1560 1561 // Separate directives by priority. The resulting array contains objects 1562 // of directives grouped by same priority, and sorted in ascending order. 1563 const getPriorityLevels = directives => { 1564 const byPriority = Object.keys(directives).reduce((obj, name) => { 1565 if (directiveCallbacks[name]) { 1566 const priority = directivePriorities[name]; 1567 (obj[priority] = obj[priority] || []).push(name); 1568 } 1569 return obj; 1570 }, {}); 1571 return Object.entries(byPriority).sort(([p1], [p2]) => parseInt(p1) - parseInt(p2)).map(([, arr]) => arr); 1572 }; 1573 1574 // Component that wraps each priority level of directives of an element. 1575 const Directives = ({ 1576 directives, 1577 priorityLevels: [currentPriorityLevel, ...nextPriorityLevels], 1578 element, 1579 originalProps, 1580 previousScope 1581 }) => { 1582 // Initialize the scope of this element. These scopes are different per each 1583 // level because each level has a different context, but they share the same 1584 // element ref, state and props. 1585 const scope = A({}).current; 1586 scope.evaluate = q(getEvaluate({ 1587 scope 1588 }), []); 1589 const { 1590 client, 1591 server 1592 } = x(context); 1593 scope.context = client; 1594 scope.serverContext = server; 1595 /* eslint-disable react-hooks/rules-of-hooks */ 1596 scope.ref = previousScope?.ref || A(null); 1597 /* eslint-enable react-hooks/rules-of-hooks */ 1598 1599 // Create a fresh copy of the vnode element and add the props to the scope, 1600 // named as attributes (HTML Attributes). 1601 element = (0,preact_module/* cloneElement */.Ob)(element, { 1602 ref: scope.ref 1603 }); 1604 scope.attributes = element.props; 1605 1606 // Recursively render the wrapper for the next priority level. 1607 const children = nextPriorityLevels.length > 0 ? (0,preact_module.h)(Directives, { 1608 directives, 1609 priorityLevels: nextPriorityLevels, 1610 element, 1611 originalProps, 1612 previousScope: scope 1613 }) : element; 1614 const props = { 1615 ...originalProps, 1616 children 1617 }; 1618 const directiveArgs = { 1619 directives, 1620 props, 1621 element, 1622 context, 1623 evaluate: scope.evaluate 1624 }; 1625 setScope(scope); 1626 for (const directiveName of currentPriorityLevel) { 1627 const wrapper = directiveCallbacks[directiveName]?.(directiveArgs); 1628 if (wrapper !== undefined) { 1629 props.children = wrapper; 1630 } 1631 } 1632 resetScope(); 1633 return props.children; 1634 }; 1635 1636 // Preact Options Hook called each time a vnode is created. 1637 const old = preact_module/* options */.fF.vnode; 1638 preact_module/* options */.fF.vnode = vnode => { 1639 if (vnode.props.__directives) { 1640 const props = vnode.props; 1641 const directives = props.__directives; 1642 if (directives.key) { 1643 vnode.key = directives.key.find(isDefaultDirectiveSuffix).value; 1644 } 1645 delete props.__directives; 1646 const priorityLevels = getPriorityLevels(directives); 1647 if (priorityLevels.length > 0) { 1648 vnode.props = { 1649 directives, 1650 priorityLevels, 1651 originalProps: props, 1652 type: vnode.type, 1653 element: (0,preact_module.h)(vnode.type, props), 1654 top: true 1655 }; 1656 vnode.type = Directives; 1657 } 1658 } 1659 if (old) { 1660 old(vnode); 1661 } 1662 }; 1663 1664 ;// ./node_modules/@wordpress/interactivity/build-module/directives.js 1665 // eslint-disable-next-line eslint-comments/disable-enable-pair 1666 /* eslint-disable react-hooks/exhaustive-deps */ 1667 1668 /** 1669 * External dependencies 1670 */ 1671 1672 1673 1674 /** 1675 * Internal dependencies 1676 */ 1677 1678 1679 1680 1681 1682 /** 1683 * Recursively clone the passed object. 1684 * 1685 * @param source Source object. 1686 * @return Cloned object. 1687 */ 1688 function deepClone(source) { 1689 if (isPlainObject(source)) { 1690 return Object.fromEntries(Object.entries(source).map(([key, value]) => [key, deepClone(value)])); 1691 } 1692 if (Array.isArray(source)) { 1693 return source.map(i => deepClone(i)); 1694 } 1695 return source; 1696 } 1697 const newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g; 1698 const ruleClean = /\/\*[^]*?\*\/| +/g; 1699 const ruleNewline = /\n+/g; 1700 const empty = ' '; 1701 1702 /** 1703 * Convert a css style string into a object. 1704 * 1705 * Made by Cristian Bote (@cristianbote) for Goober. 1706 * https://unpkg.com/browse/goober@2.1.13/src/core/astish.js 1707 * 1708 * @param val CSS string. 1709 * @return CSS object. 1710 */ 1711 const cssStringToObject = val => { 1712 const tree = [{}]; 1713 let block, left; 1714 while (block = newRule.exec(val.replace(ruleClean, ''))) { 1715 if (block[4]) { 1716 tree.shift(); 1717 } else if (block[3]) { 1718 left = block[3].replace(ruleNewline, empty).trim(); 1719 tree.unshift(tree[0][left] = tree[0][left] || {}); 1720 } else { 1721 tree[0][block[1]] = block[2].replace(ruleNewline, empty).trim(); 1722 } 1723 } 1724 return tree[0]; 1725 }; 1726 1727 /** 1728 * Creates a directive that adds an event listener to the global window or 1729 * document object. 1730 * 1731 * @param type 'window' or 'document' 1732 */ 1733 const getGlobalEventDirective = type => { 1734 return ({ 1735 directives, 1736 evaluate 1737 }) => { 1738 directives[`on-$type}`].filter(isNonDefaultDirectiveSuffix).forEach(entry => { 1739 const eventName = entry.suffix.split('--', 1)[0]; 1740 useInit(() => { 1741 const cb = event => evaluate(entry, event); 1742 const globalVar = type === 'window' ? window : document; 1743 globalVar.addEventListener(eventName, cb); 1744 return () => globalVar.removeEventListener(eventName, cb); 1745 }); 1746 }); 1747 }; 1748 }; 1749 1750 /** 1751 * Creates a directive that adds an async event listener to the global window or 1752 * document object. 1753 * 1754 * @param type 'window' or 'document' 1755 */ 1756 const getGlobalAsyncEventDirective = type => { 1757 return ({ 1758 directives, 1759 evaluate 1760 }) => { 1761 directives[`on-async-$type}`].filter(isNonDefaultDirectiveSuffix).forEach(entry => { 1762 const eventName = entry.suffix.split('--', 1)[0]; 1763 useInit(() => { 1764 const cb = async event => { 1765 await splitTask(); 1766 evaluate(entry, event); 1767 }; 1768 const globalVar = type === 'window' ? window : document; 1769 globalVar.addEventListener(eventName, cb, { 1770 passive: true 1771 }); 1772 return () => globalVar.removeEventListener(eventName, cb); 1773 }); 1774 }); 1775 }; 1776 }; 1777 /* harmony default export */ const directives = (() => { 1778 // data-wp-context 1779 directive('context', ({ 1780 directives: { 1781 context 1782 }, 1783 props: { 1784 children 1785 }, 1786 context: inheritedContext 1787 }) => { 1788 const { 1789 Provider 1790 } = inheritedContext; 1791 const defaultEntry = context.find(isDefaultDirectiveSuffix); 1792 const { 1793 client: inheritedClient, 1794 server: inheritedServer 1795 } = x(inheritedContext); 1796 const ns = defaultEntry.namespace; 1797 const client = A(proxifyState(ns, {})); 1798 const server = A(proxifyState(ns, {}, { 1799 readOnly: true 1800 })); 1801 1802 // No change should be made if `defaultEntry` does not exist. 1803 const contextStack = T(() => { 1804 const result = { 1805 client: { 1806 ...inheritedClient 1807 }, 1808 server: { 1809 ...inheritedServer 1810 } 1811 }; 1812 if (defaultEntry) { 1813 const { 1814 namespace, 1815 value 1816 } = defaultEntry; 1817 // Check that the value is a JSON object. Send a console warning if not. 1818 if (!isPlainObject(value)) { 1819 warn(`The value of data-wp-context in "$namespace}" store must be a valid stringified JSON object.`); 1820 } 1821 deepMerge(client.current, deepClone(value), false); 1822 deepMerge(server.current, deepClone(value)); 1823 result.client[namespace] = proxifyContext(client.current, inheritedClient[namespace]); 1824 result.server[namespace] = proxifyContext(server.current, inheritedServer[namespace]); 1825 } 1826 return result; 1827 }, [defaultEntry, inheritedClient, inheritedServer]); 1828 return (0,preact_module.h)(Provider, { 1829 value: contextStack 1830 }, children); 1831 }, { 1832 priority: 5 1833 }); 1834 1835 // data-wp-watch--[name] 1836 directive('watch', ({ 1837 directives: { 1838 watch 1839 }, 1840 evaluate 1841 }) => { 1842 watch.forEach(entry => { 1843 useWatch(() => { 1844 let start; 1845 if (false) {} 1846 const result = evaluate(entry); 1847 if (false) {} 1848 return result; 1849 }); 1850 }); 1851 }); 1852 1853 // data-wp-init--[name] 1854 directive('init', ({ 1855 directives: { 1856 init 1857 }, 1858 evaluate 1859 }) => { 1860 init.forEach(entry => { 1861 // TODO: Replace with useEffect to prevent unneeded scopes. 1862 useInit(() => { 1863 let start; 1864 if (false) {} 1865 const result = evaluate(entry); 1866 if (false) {} 1867 return result; 1868 }); 1869 }); 1870 }); 1871 1872 // data-wp-on--[event] 1873 directive('on', ({ 1874 directives: { 1875 on 1876 }, 1877 element, 1878 evaluate 1879 }) => { 1880 const events = new Map(); 1881 on.filter(isNonDefaultDirectiveSuffix).forEach(entry => { 1882 const event = entry.suffix.split('--')[0]; 1883 if (!events.has(event)) { 1884 events.set(event, new Set()); 1885 } 1886 events.get(event).add(entry); 1887 }); 1888 events.forEach((entries, eventType) => { 1889 const existingHandler = element.props[`on$eventType}`]; 1890 element.props[`on$eventType}`] = event => { 1891 entries.forEach(entry => { 1892 if (existingHandler) { 1893 existingHandler(event); 1894 } 1895 let start; 1896 if (false) {} 1897 evaluate(entry, event); 1898 if (false) {} 1899 }); 1900 }; 1901 }); 1902 }); 1903 1904 // data-wp-on-async--[event] 1905 directive('on-async', ({ 1906 directives: { 1907 'on-async': onAsync 1908 }, 1909 element, 1910 evaluate 1911 }) => { 1912 const events = new Map(); 1913 onAsync.filter(isNonDefaultDirectiveSuffix).forEach(entry => { 1914 const event = entry.suffix.split('--')[0]; 1915 if (!events.has(event)) { 1916 events.set(event, new Set()); 1917 } 1918 events.get(event).add(entry); 1919 }); 1920 events.forEach((entries, eventType) => { 1921 const existingHandler = element.props[`on$eventType}`]; 1922 element.props[`on$eventType}`] = event => { 1923 if (existingHandler) { 1924 existingHandler(event); 1925 } 1926 entries.forEach(async entry => { 1927 await splitTask(); 1928 evaluate(entry, event); 1929 }); 1930 }; 1931 }); 1932 }); 1933 1934 // data-wp-on-window--[event] 1935 directive('on-window', getGlobalEventDirective('window')); 1936 // data-wp-on-document--[event] 1937 directive('on-document', getGlobalEventDirective('document')); 1938 1939 // data-wp-on-async-window--[event] 1940 directive('on-async-window', getGlobalAsyncEventDirective('window')); 1941 // data-wp-on-async-document--[event] 1942 directive('on-async-document', getGlobalAsyncEventDirective('document')); 1943 1944 // data-wp-class--[classname] 1945 directive('class', ({ 1946 directives: { 1947 class: classNames 1948 }, 1949 element, 1950 evaluate 1951 }) => { 1952 classNames.filter(isNonDefaultDirectiveSuffix).forEach(entry => { 1953 const className = entry.suffix; 1954 const result = evaluate(entry); 1955 const currentClass = element.props.class || ''; 1956 const classFinder = new RegExp(`(^|\\s)$className}(\\s|$)`, 'g'); 1957 if (!result) { 1958 element.props.class = currentClass.replace(classFinder, ' ').trim(); 1959 } else if (!classFinder.test(currentClass)) { 1960 element.props.class = currentClass ? `$currentClass} $className}` : className; 1961 } 1962 useInit(() => { 1963 /* 1964 * This seems necessary because Preact doesn't change the class 1965 * names on the hydration, so we have to do it manually. It doesn't 1966 * need deps because it only needs to do it the first time. 1967 */ 1968 if (!result) { 1969 element.ref.current.classList.remove(className); 1970 } else { 1971 element.ref.current.classList.add(className); 1972 } 1973 }); 1974 }); 1975 }); 1976 1977 // data-wp-style--[style-prop] 1978 directive('style', ({ 1979 directives: { 1980 style 1981 }, 1982 element, 1983 evaluate 1984 }) => { 1985 style.filter(isNonDefaultDirectiveSuffix).forEach(entry => { 1986 const styleProp = entry.suffix; 1987 const result = evaluate(entry); 1988 element.props.style = element.props.style || {}; 1989 if (typeof element.props.style === 'string') { 1990 element.props.style = cssStringToObject(element.props.style); 1991 } 1992 if (!result) { 1993 delete element.props.style[styleProp]; 1994 } else { 1995 element.props.style[styleProp] = result; 1996 } 1997 useInit(() => { 1998 /* 1999 * This seems necessary because Preact doesn't change the styles on 2000 * the hydration, so we have to do it manually. It doesn't need deps 2001 * because it only needs to do it the first time. 2002 */ 2003 if (!result) { 2004 element.ref.current.style.removeProperty(styleProp); 2005 } else { 2006 element.ref.current.style[styleProp] = result; 2007 } 2008 }); 2009 }); 2010 }); 2011 2012 // data-wp-bind--[attribute] 2013 directive('bind', ({ 2014 directives: { 2015 bind 2016 }, 2017 element, 2018 evaluate 2019 }) => { 2020 bind.filter(isNonDefaultDirectiveSuffix).forEach(entry => { 2021 const attribute = entry.suffix; 2022 const result = evaluate(entry); 2023 element.props[attribute] = result; 2024 2025 /* 2026 * This is necessary because Preact doesn't change the attributes on the 2027 * hydration, so we have to do it manually. It only needs to do it the 2028 * first time. After that, Preact will handle the changes. 2029 */ 2030 useInit(() => { 2031 const el = element.ref.current; 2032 2033 /* 2034 * We set the value directly to the corresponding HTMLElement instance 2035 * property excluding the following special cases. We follow Preact's 2036 * logic: https://github.com/preactjs/preact/blob/ea49f7a0f9d1ff2c98c0bdd66aa0cbc583055246/src/diff/props.js#L110-L129 2037 */ 2038 if (attribute === 'style') { 2039 if (typeof result === 'string') { 2040 el.style.cssText = result; 2041 } 2042 return; 2043 } else if (attribute !== 'width' && attribute !== 'height' && attribute !== 'href' && attribute !== 'list' && attribute !== 'form' && 2044 /* 2045 * The value for `tabindex` follows the parsing rules for an 2046 * integer. If that fails, or if the attribute isn't present, then 2047 * the browsers should "follow platform conventions to determine if 2048 * the element should be considered as a focusable area", 2049 * practically meaning that most elements get a default of `-1` (not 2050 * focusable), but several also get a default of `0` (focusable in 2051 * order after all elements with a positive `tabindex` value). 2052 * 2053 * @see https://html.spec.whatwg.org/#tabindex-value 2054 */ 2055 attribute !== 'tabIndex' && attribute !== 'download' && attribute !== 'rowSpan' && attribute !== 'colSpan' && attribute !== 'role' && attribute in el) { 2056 try { 2057 el[attribute] = result === null || result === undefined ? '' : result; 2058 return; 2059 } catch (err) {} 2060 } 2061 /* 2062 * aria- and data- attributes have no boolean representation. 2063 * A `false` value is different from the attribute not being 2064 * present, so we can't remove it. 2065 * We follow Preact's logic: https://github.com/preactjs/preact/blob/ea49f7a0f9d1ff2c98c0bdd66aa0cbc583055246/src/diff/props.js#L131C24-L136 2066 */ 2067 if (result !== null && result !== undefined && (result !== false || attribute[4] === '-')) { 2068 el.setAttribute(attribute, result); 2069 } else { 2070 el.removeAttribute(attribute); 2071 } 2072 }); 2073 }); 2074 }); 2075 2076 // data-wp-ignore 2077 directive('ignore', ({ 2078 element: { 2079 type: Type, 2080 props: { 2081 innerHTML, 2082 ...rest 2083 } 2084 } 2085 }) => { 2086 // Preserve the initial inner HTML. 2087 const cached = T(() => innerHTML, []); 2088 return (0,preact_module.h)(Type, { 2089 dangerouslySetInnerHTML: { 2090 __html: cached 2091 }, 2092 ...rest 2093 }); 2094 }); 2095 2096 // data-wp-text 2097 directive('text', ({ 2098 directives: { 2099 text 2100 }, 2101 element, 2102 evaluate 2103 }) => { 2104 const entry = text.find(isDefaultDirectiveSuffix); 2105 if (!entry) { 2106 element.props.children = null; 2107 return; 2108 } 2109 try { 2110 const result = evaluate(entry); 2111 element.props.children = typeof result === 'object' ? null : result.toString(); 2112 } catch (e) { 2113 element.props.children = null; 2114 } 2115 }); 2116 2117 // data-wp-run 2118 directive('run', ({ 2119 directives: { 2120 run 2121 }, 2122 evaluate 2123 }) => { 2124 run.forEach(entry => evaluate(entry)); 2125 }); 2126 2127 // data-wp-each--[item] 2128 directive('each', ({ 2129 directives: { 2130 each, 2131 'each-key': eachKey 2132 }, 2133 context: inheritedContext, 2134 element, 2135 evaluate 2136 }) => { 2137 if (element.type !== 'template') { 2138 return; 2139 } 2140 const { 2141 Provider 2142 } = inheritedContext; 2143 const inheritedValue = x(inheritedContext); 2144 const [entry] = each; 2145 const { 2146 namespace 2147 } = entry; 2148 const list = evaluate(entry); 2149 const itemProp = isNonDefaultDirectiveSuffix(entry) ? kebabToCamelCase(entry.suffix) : 'item'; 2150 return list.map(item => { 2151 const itemContext = proxifyContext(proxifyState(namespace, {}), inheritedValue.client[namespace]); 2152 const mergedContext = { 2153 client: { 2154 ...inheritedValue.client, 2155 [namespace]: itemContext 2156 }, 2157 server: { 2158 ...inheritedValue.server 2159 } 2160 }; 2161 2162 // Set the item after proxifying the context. 2163 mergedContext.client[namespace][itemProp] = item; 2164 const scope = { 2165 ...getScope(), 2166 context: mergedContext.client, 2167 serverContext: mergedContext.server 2168 }; 2169 const key = eachKey ? getEvaluate({ 2170 scope 2171 })(eachKey[0]) : item; 2172 return (0,preact_module.h)(Provider, { 2173 value: mergedContext, 2174 key 2175 }, element.props.content); 2176 }); 2177 }, { 2178 priority: 20 2179 }); 2180 directive('each-child', () => null, { 2181 priority: 1 2182 }); 2183 }); 2184 2185 ;// ./node_modules/@wordpress/interactivity/build-module/constants.js 2186 const directivePrefix = 'wp'; 2187 2188 ;// ./node_modules/@wordpress/interactivity/build-module/vdom.js 2189 /** 2190 * External dependencies 2191 */ 2192 2193 /** 2194 * Internal dependencies 2195 */ 2196 2197 2198 const ignoreAttr = `data-$directivePrefix}-ignore`; 2199 const islandAttr = `data-$directivePrefix}-interactive`; 2200 const fullPrefix = `data-$directivePrefix}-`; 2201 const namespaces = []; 2202 const currentNamespace = () => { 2203 var _namespaces; 2204 return (_namespaces = namespaces[namespaces.length - 1]) !== null && _namespaces !== void 0 ? _namespaces : null; 2205 }; 2206 const isObject = item => Boolean(item && typeof item === 'object' && item.constructor === Object); 2207 2208 // Regular expression for directive parsing. 2209 const directiveParser = new RegExp(`^data-$directivePrefix}-` + 2210 // ${p} must be a prefix string, like 'wp'. 2211 // Match alphanumeric characters including hyphen-separated 2212 // segments. It excludes underscore intentionally to prevent confusion. 2213 // E.g., "custom-directive". 2214 '([a-z0-9]+(?:-[a-z0-9]+)*)' + 2215 // (Optional) Match '--' followed by any alphanumeric charachters. It 2216 // excludes underscore intentionally to prevent confusion, but it can 2217 // contain multiple hyphens. E.g., "--custom-prefix--with-more-info". 2218 '(?:--([a-z0-9_-]+))?$', 'i' // Case insensitive. 2219 ); 2220 2221 // Regular expression for reference parsing. It can contain a namespace before 2222 // the reference, separated by `::`, like `some-namespace::state.somePath`. 2223 // Namespaces can contain any alphanumeric characters, hyphens, underscores or 2224 // forward slashes. References don't have any restrictions. 2225 const nsPathRegExp = /^([\w_\/-]+)::(.+)$/; 2226 const hydratedIslands = new WeakSet(); 2227 2228 /** 2229 * Recursive function that transforms a DOM tree into vDOM. 2230 * 2231 * @param root The root element or node to start traversing on. 2232 * @return The resulting vDOM tree. 2233 */ 2234 function toVdom(root) { 2235 const treeWalker = document.createTreeWalker(root, 205 // TEXT + CDATA_SECTION + COMMENT + PROCESSING_INSTRUCTION + ELEMENT 2236 ); 2237 function walk(node) { 2238 const { 2239 nodeType 2240 } = node; 2241 2242 // TEXT_NODE (3) 2243 if (nodeType === 3) { 2244 return [node.data]; 2245 } 2246 2247 // CDATA_SECTION_NODE (4) 2248 if (nodeType === 4) { 2249 var _nodeValue; 2250 const next = treeWalker.nextSibling(); 2251 node.replaceWith(new window.Text((_nodeValue = node.nodeValue) !== null && _nodeValue !== void 0 ? _nodeValue : '')); 2252 return [node.nodeValue, next]; 2253 } 2254 2255 // COMMENT_NODE (8) || PROCESSING_INSTRUCTION_NODE (7) 2256 if (nodeType === 8 || nodeType === 7) { 2257 const next = treeWalker.nextSibling(); 2258 node.remove(); 2259 return [null, next]; 2260 } 2261 const elementNode = node; 2262 const { 2263 attributes 2264 } = elementNode; 2265 const localName = elementNode.localName; 2266 const props = {}; 2267 const children = []; 2268 const directives = []; 2269 let ignore = false; 2270 let island = false; 2271 for (let i = 0; i < attributes.length; i++) { 2272 const attributeName = attributes[i].name; 2273 const attributeValue = attributes[i].value; 2274 if (attributeName[fullPrefix.length] && attributeName.slice(0, fullPrefix.length) === fullPrefix) { 2275 if (attributeName === ignoreAttr) { 2276 ignore = true; 2277 } else { 2278 var _regexResult$, _regexResult$2; 2279 const regexResult = nsPathRegExp.exec(attributeValue); 2280 const namespace = (_regexResult$ = regexResult?.[1]) !== null && _regexResult$ !== void 0 ? _regexResult$ : null; 2281 let value = (_regexResult$2 = regexResult?.[2]) !== null && _regexResult$2 !== void 0 ? _regexResult$2 : attributeValue; 2282 try { 2283 const parsedValue = JSON.parse(value); 2284 value = isObject(parsedValue) ? parsedValue : value; 2285 } catch {} 2286 if (attributeName === islandAttr) { 2287 island = true; 2288 const islandNamespace = 2289 // eslint-disable-next-line no-nested-ternary 2290 typeof value === 'string' ? value : typeof value?.namespace === 'string' ? value.namespace : null; 2291 namespaces.push(islandNamespace); 2292 } else { 2293 directives.push([attributeName, namespace, value]); 2294 } 2295 } 2296 } else if (attributeName === 'ref') { 2297 continue; 2298 } 2299 props[attributeName] = attributeValue; 2300 } 2301 if (ignore && !island) { 2302 return [(0,preact_module.h)(localName, { 2303 ...props, 2304 innerHTML: elementNode.innerHTML, 2305 __directives: { 2306 ignore: true 2307 } 2308 })]; 2309 } 2310 if (island) { 2311 hydratedIslands.add(elementNode); 2312 } 2313 if (directives.length) { 2314 props.__directives = directives.reduce((obj, [name, ns, value]) => { 2315 const directiveMatch = directiveParser.exec(name); 2316 if (directiveMatch === null) { 2317 warn(`Found malformed directive name: $name}.`); 2318 return obj; 2319 } 2320 const prefix = directiveMatch[1] || ''; 2321 const suffix = directiveMatch[2] || null; 2322 obj[prefix] = obj[prefix] || []; 2323 obj[prefix].push({ 2324 namespace: ns !== null && ns !== void 0 ? ns : currentNamespace(), 2325 value: value, 2326 suffix 2327 }); 2328 return obj; 2329 }, {}); 2330 } 2331 2332 // @ts-expect-error Fixed in upcoming preact release https://github.com/preactjs/preact/pull/4334 2333 if (localName === 'template') { 2334 props.content = [...elementNode.content.childNodes].map(childNode => toVdom(childNode)); 2335 } else { 2336 let child = treeWalker.firstChild(); 2337 if (child) { 2338 while (child) { 2339 const [vnode, nextChild] = walk(child); 2340 if (vnode) { 2341 children.push(vnode); 2342 } 2343 child = nextChild || treeWalker.nextSibling(); 2344 } 2345 treeWalker.parentNode(); 2346 } 2347 } 2348 2349 // Restore previous namespace. 2350 if (island) { 2351 namespaces.pop(); 2352 } 2353 return [(0,preact_module.h)(localName, props, children)]; 2354 } 2355 return walk(treeWalker.currentNode); 2356 } 2357 2358 ;// ./node_modules/@wordpress/interactivity/build-module/init.js 2359 /** 2360 * External dependencies 2361 */ 2362 2363 /** 2364 * Internal dependencies 2365 */ 2366 2367 2368 2369 2370 // Keep the same root fragment for each interactive region node. 2371 const regionRootFragments = new WeakMap(); 2372 const getRegionRootFragment = region => { 2373 if (!region.parentElement) { 2374 throw Error('The passed region should be an element with a parent.'); 2375 } 2376 if (!regionRootFragments.has(region)) { 2377 regionRootFragments.set(region, createRootFragment(region.parentElement, region)); 2378 } 2379 return regionRootFragments.get(region); 2380 }; 2381 2382 // Initial vDOM regions associated with its DOM element. 2383 const initialVdom = new WeakMap(); 2384 2385 // Initialize the router with the initial DOM. 2386 const init = async () => { 2387 const nodes = document.querySelectorAll(`[data-$directivePrefix}-interactive]`); 2388 for (const node of nodes) { 2389 if (!hydratedIslands.has(node)) { 2390 await splitTask(); 2391 const fragment = getRegionRootFragment(node); 2392 const vdom = toVdom(node); 2393 initialVdom.set(node, vdom); 2394 await splitTask(); 2395 (0,preact_module/* hydrate */.Qv)(vdom, fragment); 2396 } 2397 } 2398 }; 2399 2400 ;// ./node_modules/@wordpress/interactivity/build-module/index.js 2401 /** 2402 * External dependencies 2403 */ 2404 2405 2406 2407 /** 2408 * Internal dependencies 2409 */ 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 const requiredConsent = 'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.'; 2423 const privateApis = lock => { 2424 if (lock === requiredConsent) { 2425 return { 2426 directivePrefix: directivePrefix, 2427 getRegionRootFragment: getRegionRootFragment, 2428 initialVdom: initialVdom, 2429 toVdom: toVdom, 2430 directive: directive, 2431 getNamespace: getNamespace, 2432 h: preact_module.h, 2433 cloneElement: preact_module/* cloneElement */.Ob, 2434 render: preact_module/* render */.XX, 2435 proxifyState: proxifyState, 2436 parseServerData: parseServerData, 2437 populateServerData: populateServerData, 2438 batch: signals_core_module_r 2439 }; 2440 } 2441 throw new Error('Forbidden access.'); 2442 }; 2443 directives(); 2444 init(); 2445 2446 var __webpack_exports__getConfig = __webpack_exports__.zj; 2447 var __webpack_exports__getContext = __webpack_exports__.SD; 2448 var __webpack_exports__getElement = __webpack_exports__.V6; 2449 var __webpack_exports__getServerContext = __webpack_exports__.$K; 2450 var __webpack_exports__getServerState = __webpack_exports__.vT; 2451 var __webpack_exports__privateApis = __webpack_exports__.jb; 2452 var __webpack_exports__splitTask = __webpack_exports__.yT; 2453 var __webpack_exports__store = __webpack_exports__.M_; 2454 var __webpack_exports__useCallback = __webpack_exports__.hb; 2455 var __webpack_exports__useEffect = __webpack_exports__.vJ; 2456 var __webpack_exports__useInit = __webpack_exports__.ip; 2457 var __webpack_exports__useLayoutEffect = __webpack_exports__.Nf; 2458 var __webpack_exports__useMemo = __webpack_exports__.Kr; 2459 var __webpack_exports__useRef = __webpack_exports__.li; 2460 var __webpack_exports__useState = __webpack_exports__.J0; 2461 var __webpack_exports__useWatch = __webpack_exports__.FH; 2462 var __webpack_exports__withScope = __webpack_exports__.v4; 2463 export { __webpack_exports__getConfig as getConfig, __webpack_exports__getContext as getContext, __webpack_exports__getElement as getElement, __webpack_exports__getServerContext as getServerContext, __webpack_exports__getServerState as getServerState, __webpack_exports__privateApis as privateApis, __webpack_exports__splitTask as splitTask, __webpack_exports__store as store, __webpack_exports__useCallback as useCallback, __webpack_exports__useEffect as useEffect, __webpack_exports__useInit as useInit, __webpack_exports__useLayoutEffect as useLayoutEffect, __webpack_exports__useMemo as useMemo, __webpack_exports__useRef as useRef, __webpack_exports__useState as useState, __webpack_exports__useWatch as useWatch, __webpack_exports__withScope as withScope };
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Dec 21 08:20:01 2024 | Cross-referenced by PHPXref |