| @@ -1,3 +1,214 @@ | ||
| 1 | -/*! For license information please see locations.js.LICENSE.txt */ | |
| 2 | -!function(){"use strict";var e={"./packages/packages/libs/locations/src/components/error-boundary.tsx":function(e,n,t){t.r(n),t.d(n,{default:function(){return ErrorBoundary}});var r=t("react");class ErrorBoundary extends r.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}},"./packages/packages/libs/locations/src/components/injected-component-wrapper.tsx":function(e,n,t){t.r(n),t.d(n,{default:function(){return InjectedComponentWrapper}});var r=t("react"),c=t("./packages/packages/libs/locations/src/components/error-boundary.tsx");function InjectedComponentWrapper({children:e}){return r.createElement(c.default,{fallback:null},r.createElement(r.Suspense,{fallback:null},e))}},"./packages/packages/libs/locations/src/create-location.tsx":function(e,n,t){t.r(n),t.d(n,{createLocation:function(){return createLocation}});var r=t("react"),c=t("./packages/packages/libs/locations/src/injections.tsx");function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)({}).hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},_extends.apply(null,arguments)}function createLocation(){const e=new Map,n=(0,c.createGetInjections)(e),t=(0,c.createUseInjections)(n),o=function createSlot(e){return n=>{const t=e();return r.createElement(r.Fragment,null,t.map(({id:e,component:t})=>r.createElement(t,_extends({},n,{key:e}))))}}(t),a=function createInject(e){return({component:n,id:t,options:r={}})=>{!e.has(t)||r?.overwrite?e.set(t,{id:t,component:(0,c.wrapInjectedComponent)(n),priority:r.priority??c.DEFAULT_PRIORITY}):console.warn(`An injection with the id "${t}" already exists. Did you mean to use "options.overwrite"?`)}}(e);return c.flushInjectionsFns.push(()=>e.clear()),{inject:a,getInjections:n,useInjections:t,Slot:o}}},"./packages/packages/libs/locations/src/create-replaceable-location.tsx":function(e,n,t){t.r(n),t.d(n,{createReplaceableLocation:function(){return createReplaceableLocation}});var r=t("react"),c=t("./packages/packages/libs/locations/src/injections.tsx");function createReplaceableLocation(){const e=new Map,n=(0,c.createGetInjections)(e),t=(0,c.createUseInjections)(n),o=function createReplaceable(e){return n=>{const t=e(),{component:c}=t.find(({condition:e})=>e?.(n))??{};return c?r.createElement(c,n):n.children}}(t),a=function createRegister(e){return({component:n,id:t,condition:r=()=>!0,options:o={}})=>{e.set(t,{id:t,component:(0,c.wrapInjectedComponent)(n),condition:r,priority:o.priority??c.DEFAULT_PRIORITY})}}(e);return c.flushInjectionsFns.push(()=>e.clear()),{getInjections:n,useInjections:t,inject:a,Slot:o}}},"./packages/packages/libs/locations/src/injections.tsx":function(e,n,t){t.r(n),t.d(n,{DEFAULT_PRIORITY:function(){return o},createGetInjections:function(){return createGetInjections},createUseInjections:function(){return createUseInjections},flushAllInjections:function(){return flushAllInjections},flushInjectionsFns:function(){return a},wrapInjectedComponent:function(){return wrapInjectedComponent}});var r=t("react"),c=t("./packages/packages/libs/locations/src/components/injected-component-wrapper.tsx");const o=10,a=[];function flushAllInjections(){a.forEach(e=>e())}function createGetInjections(e){return()=>[...e.values()].sort((e,n)=>e.priority-n.priority)}function createUseInjections(e){return()=>(0,r.useMemo)(()=>e(),[])}function wrapInjectedComponent(e){return n=>r.createElement(c.default,null,r.createElement(e,n))}},"./packages/packages/libs/locations/src/types.ts":function(e,n,t){t.r(n)},react:function(e){e.exports=window.React}},n={};function __webpack_require__(t){var r=n[t];if(void 0!==r)return r.exports;var c=n[t]={exports:{}};return e[t](c,c.exports,__webpack_require__),c.exports}__webpack_require__.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return __webpack_require__.d(n,{a:n}),n},__webpack_require__.d=function(e,n){for(var t in n)__webpack_require__.o(n,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:n[t]})},__webpack_require__.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};!function(){__webpack_require__.r(t),__webpack_require__.d(t,{__flushAllInjections:function(){return r.flushAllInjections},createLocation:function(){return e.createLocation},createReplaceableLocation:function(){return n.createReplaceableLocation}});__webpack_require__("./packages/packages/libs/locations/src/types.ts");var e=__webpack_require__("./packages/packages/libs/locations/src/create-location.tsx"),n=__webpack_require__("./packages/packages/libs/locations/src/create-replaceable-location.tsx"),r=__webpack_require__("./packages/packages/libs/locations/src/injections.tsx")}(),(window.elementorV2=window.elementorV2||{}).locations=t}(),window.elementorV2.locations?.init?.(); | |
| 1 | +(function(react) { | |
| 2 | + | |
| 3 | +//#region \0rolldown/runtime.js | |
| 4 | + var __create = Object.create; | |
| 5 | + var __defProp$1 = Object.defineProperty; | |
| 6 | + var __name = (target, value) => __defProp$1(target, "name", { | |
| 7 | + value, | |
| 8 | + configurable: true | |
| 9 | + }); | |
| 10 | + var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | |
| 11 | + var __getOwnPropNames = Object.getOwnPropertyNames; | |
| 12 | + var __getProtoOf = Object.getPrototypeOf; | |
| 13 | + var __hasOwnProp = Object.prototype.hasOwnProperty; | |
| 14 | + var __exportAll = (all, no_symbols) => { | |
| 15 | + let target = {}; | |
| 16 | + for (var name in all) { | |
| 17 | + __defProp$1(target, name, { | |
| 18 | + get: all[name], | |
| 19 | + enumerable: true | |
| 20 | + }); | |
| 21 | + } | |
| 22 | + if (!no_symbols) { | |
| 23 | + __defProp$1(target, Symbol.toStringTag, { value: "Module" }); | |
| 24 | + } | |
| 25 | + return target; | |
| 26 | + }; | |
| 27 | + var __copyProps = (to, from, except, desc) => { | |
| 28 | + if (from && typeof from === "object" || typeof from === "function") { | |
| 29 | + for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { | |
| 30 | + key = keys[i]; | |
| 31 | + if (!__hasOwnProp.call(to, key) && key !== except) { | |
| 32 | + __defProp$1(to, key, { | |
| 33 | + get: ((k) => from[k]).bind(null, key), | |
| 34 | + enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable | |
| 35 | + }); | |
| 36 | + } | |
| 37 | + } | |
| 38 | + } | |
| 39 | + return to; | |
| 40 | + }; | |
| 41 | + var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp$1(target, "default", { | |
| 42 | + value: mod, | |
| 43 | + enumerable: true | |
| 44 | + }) : target, mod)); | |
| 45 | + | |
| 46 | +//#endregion | |
| 47 | +react = __toESM(react); | |
| 48 | + | |
| 49 | +//#region packages/packages/libs/locations/src/components/error-boundary.tsx | |
| 50 | + var __defProp = Object.defineProperty; | |
| 51 | + var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { | |
| 52 | + enumerable: true, | |
| 53 | + configurable: true, | |
| 54 | + writable: true, | |
| 55 | + value | |
| 56 | + }) : obj[key] = value; | |
| 57 | + var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | |
| 58 | + var ErrorBoundary = class extends react.Component { | |
| 59 | + constructor() { | |
| 60 | + super(...arguments); | |
| 61 | + __publicField(this, "state", { hasError: false }); | |
| 62 | + } | |
| 63 | + static getDerivedStateFromError() { | |
| 64 | + return { hasError: true }; | |
| 65 | + } | |
| 66 | + render() { | |
| 67 | + if (this.state.hasError) return this.props.fallback; | |
| 68 | + return this.props.children; | |
| 69 | + } | |
| 70 | + }; | |
| 71 | + | |
| 72 | +//#endregion | |
| 73 | +//#region packages/packages/libs/locations/src/components/injected-component-wrapper.tsx | |
| 74 | + function InjectedComponentWrapper({ children }) { | |
| 75 | + return /* @__PURE__ */ react.createElement(ErrorBoundary, { fallback: null }, /* @__PURE__ */ react.createElement(react.Suspense, { fallback: null }, children)); | |
| 76 | + } | |
| 77 | + | |
| 78 | +//#endregion | |
| 79 | +//#region packages/packages/libs/locations/src/injections.tsx | |
| 80 | + var flushInjectionsFns = []; | |
| 81 | + function flushAllInjections() { | |
| 82 | + flushInjectionsFns.forEach((flush) => flush()); | |
| 83 | + } | |
| 84 | + function registerFlushInjections(flush) { | |
| 85 | + flushInjectionsFns.push(flush); | |
| 86 | + } | |
| 87 | + function createSubscription() { | |
| 88 | + const listeners = /* @__PURE__ */ new Set(); | |
| 89 | + return { | |
| 90 | + subscribe: (listener) => { | |
| 91 | + listeners.add(listener); | |
| 92 | + return () => listeners.delete(listener); | |
| 93 | + }, | |
| 94 | + notify: () => listeners.forEach((listener) => listener()) | |
| 95 | + }; | |
| 96 | + } | |
| 97 | + function createGetInjections(injections) { | |
| 98 | + return () => [...injections.values()].sort((a, b) => a.priority - b.priority); | |
| 99 | + } | |
| 100 | + function createUseInjections(getInjections, subscribe) { | |
| 101 | + let snapshot = null; | |
| 102 | + subscribe(() => { | |
| 103 | + snapshot = null; | |
| 104 | + }); | |
| 105 | + const getSnapshot = () => { | |
| 106 | + if (!snapshot) snapshot = getInjections(); | |
| 107 | + return snapshot; | |
| 108 | + }; | |
| 109 | + return () => (0, react.useSyncExternalStore)(subscribe, getSnapshot); | |
| 110 | + } | |
| 111 | + function wrapInjectedComponent(Component) { | |
| 112 | + return (props) => /* @__PURE__ */ react.createElement(InjectedComponentWrapper, null, /* @__PURE__ */ react.createElement(Component, { ...props })); | |
| 113 | + } | |
| 114 | + | |
| 115 | +//#endregion | |
| 116 | +//#region packages/packages/libs/locations/src/create-location.tsx | |
| 117 | + function createLocation() { | |
| 118 | + const injections = /* @__PURE__ */ new Map(); | |
| 119 | + const { subscribe, notify } = createSubscription(); | |
| 120 | + const getInjections = createGetInjections(injections); | |
| 121 | + const useInjections = createUseInjections(getInjections, subscribe); | |
| 122 | + const Slot = createSlot(useInjections); | |
| 123 | + const inject = createInject(injections, notify); | |
| 124 | + flushInjectionsFns.push(() => { | |
| 125 | + injections.clear(); | |
| 126 | + notify(); | |
| 127 | + }); | |
| 128 | + return { | |
| 129 | + inject, | |
| 130 | + getInjections, | |
| 131 | + useInjections, | |
| 132 | + Slot | |
| 133 | + }; | |
| 134 | + } | |
| 135 | + function createSlot(useInjections) { | |
| 136 | + return (props) => { | |
| 137 | + const injections = useInjections(); | |
| 138 | + return /* @__PURE__ */ react.createElement(react.Fragment, null, injections.map(({ id, component: Component }) => /* @__PURE__ */ react.createElement(Component, { | |
| 139 | + ...props, | |
| 140 | + key: id | |
| 141 | + }))); | |
| 142 | + }; | |
| 143 | + } | |
| 144 | + function createInject(injections, notify) { | |
| 145 | + return ({ component, id, options = {} }) => { | |
| 146 | + if (injections.has(id) && !options?.overwrite) { | |
| 147 | + console.warn(`An injection with the id "${id}" already exists. Did you mean to use "options.overwrite"?`); | |
| 148 | + return; | |
| 149 | + } | |
| 150 | + injections.set(id, { | |
| 151 | + id, | |
| 152 | + component: wrapInjectedComponent(component), | |
| 153 | + priority: options.priority ?? 10 | |
| 154 | + }); | |
| 155 | + notify(); | |
| 156 | + }; | |
| 157 | + } | |
| 158 | + | |
| 159 | +//#endregion | |
| 160 | +//#region packages/packages/libs/locations/src/create-replaceable-location.tsx | |
| 161 | + function createReplaceableLocation() { | |
| 162 | + const injections = /* @__PURE__ */ new Map(); | |
| 163 | + const { subscribe, notify } = createSubscription(); | |
| 164 | + const getInjections = createGetInjections(injections); | |
| 165 | + const useInjections = createUseInjections(getInjections, subscribe); | |
| 166 | + const Slot = createReplaceable(useInjections); | |
| 167 | + const inject = createRegister(injections, notify); | |
| 168 | + flushInjectionsFns.push(() => { | |
| 169 | + injections.clear(); | |
| 170 | + notify(); | |
| 171 | + }); | |
| 172 | + return { | |
| 173 | + getInjections, | |
| 174 | + useInjections, | |
| 175 | + inject, | |
| 176 | + Slot | |
| 177 | + }; | |
| 178 | + } | |
| 179 | + function createReplaceable(useInjections) { | |
| 180 | + return (props) => { | |
| 181 | + const { component: Component } = useInjections().find(({ condition }) => condition?.(props)) ?? {}; | |
| 182 | + if (!Component) return props.children; | |
| 183 | + return /* @__PURE__ */ react.createElement(Component, { ...props }); | |
| 184 | + }; | |
| 185 | + } | |
| 186 | + function createRegister(injections, notify) { | |
| 187 | + return ({ component, id, condition = () => true, options = {} }) => { | |
| 188 | + injections.set(id, { | |
| 189 | + id, | |
| 190 | + component: wrapInjectedComponent(component), | |
| 191 | + condition, | |
| 192 | + priority: options.priority ?? 10 | |
| 193 | + }); | |
| 194 | + notify(); | |
| 195 | + }; | |
| 196 | + } | |
| 197 | + | |
| 198 | +//#endregion | |
| 199 | +//#region packages/packages/libs/locations/src/index.ts | |
| 200 | + var src_exports = /* @__PURE__ */ __exportAll({ | |
| 201 | + __flushAllInjections: () => flushAllInjections, | |
| 202 | + __registerFlushInjections: () => registerFlushInjections, | |
| 203 | + createLocation: () => createLocation, | |
| 204 | + createReplaceableLocation: () => createReplaceableLocation | |
| 205 | + }); | |
| 206 | + | |
| 207 | +//#endregion | |
| 208 | +//#region \0elementor-package-library-entry | |
| 209 | + (window.elementorV2 = window.elementorV2 || {}).locations = src_exports; | |
| 210 | + | |
| 211 | +//#endregion | |
| 212 | +})(React); | |
| 213 | +window.elementorV2.locations?.init?.(); | |
| 3 | 214 | //# sourceMappingURL=locations.js.map |