@sitecore-feaas/clientside 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/build/components/FEAASComponent.js +8 -4
- package/build/components/FEAASComponent.js.map +1 -1
- package/build/components/FEAASElement.js +18 -4
- package/build/components/FEAASElement.js.map +1 -1
- package/build/dom/rendering.js +1 -1
- package/build/dom/rendering.js.map +1 -1
- package/build/headless.js +4 -5
- package/build/headless.js.map +1 -1
- package/build/ui/FEAASExternal.js +8 -0
- package/build/ui/FEAASExternal.js.map +1 -1
- package/build/ui/FEAASPicker.js +10 -1
- package/build/ui/FEAASPicker.js.map +1 -1
- package/build/ui/react.js +18 -10
- package/build/ui/react.js.map +1 -1
- package/build/{dom → utils}/data.js +3 -0
- package/build/utils/data.js.map +1 -0
- package/build/utils/datapath.js +6 -2
- package/build/utils/datapath.js.map +1 -1
- package/build/utils/settings.js +154 -52
- package/build/utils/settings.js.map +1 -1
- package/dist/browser/headless.cjs +6 -6
- package/dist/browser/headless.cjs.map +4 -4
- package/dist/browser/headless.esm.js +6 -6
- package/dist/browser/headless.esm.js.map +1 -1
- package/dist/browser/index.cjs +7 -7
- package/dist/browser/index.cjs.map +4 -4
- package/dist/browser/index.esm.js +7 -7
- package/dist/browser/index.esm.js.map +1 -1
- package/dist/browser/react.cjs +6 -6
- package/dist/browser/react.cjs.map +4 -4
- package/dist/browser/react.esm.js +6 -6
- package/dist/browser/react.esm.js.map +1 -1
- package/dist/node/headless.cjs +4 -4
- package/dist/node/headless.cjs.map +4 -4
- package/dist/node/headless.esm.js +4 -4
- package/dist/node/headless.esm.js.map +4 -4
- package/dist/node/index.cjs +6 -6
- package/dist/node/index.cjs.map +4 -4
- package/dist/node/index.esm.js +6 -6
- package/dist/node/index.esm.js.map +4 -4
- package/dist/node/react.cjs +5 -5
- package/dist/node/react.cjs.map +4 -4
- package/dist/node/react.esm.js +5 -5
- package/dist/node/react.esm.js.map +4 -4
- package/headless.cjs +4 -4
- package/headless.cjs.map +4 -4
- package/headless.js +4 -4
- package/headless.js.map +4 -4
- package/package.json +1 -1
- package/react.cjs +6 -6
- package/react.cjs.map +4 -4
- package/react.js +6 -6
- package/react.js.map +4 -4
- package/src/components/FEAASComponent.tsx +11 -5
- package/src/components/FEAASElement.tsx +18 -3
- package/src/dom/component.ts +2 -2
- package/src/dom/html.ts +2 -2
- package/src/dom/rendering.ts +9 -7
- package/src/headless.ts +5 -5
- package/src/ui/FEAASExternal.tsx +10 -0
- package/src/ui/FEAASPicker.tsx +10 -2
- package/src/ui/react.tsx +24 -11
- package/src/{dom → utils}/data.ts +3 -1
- package/src/utils/datapath.ts +7 -2
- package/src/utils/settings.ts +184 -53
- package/test/FEAASComponentData.test.tsx +56 -52
- package/test/ServerComponent.test.tsx +14 -3
- package/test/cdn.ts +1 -1
- package/test/datasettings.test.ts +248 -0
- package/test/{extras.ts → extras.test.ts} +1 -1
- package/test/fetch.ts +2 -2
- package/types/components/FEAASComponent.d.ts +7 -4
- package/types/components/FEAASComponent.d.ts.map +1 -1
- package/types/components/FEAASElement.d.ts +1 -0
- package/types/components/FEAASElement.d.ts.map +1 -1
- package/types/dom/component.d.ts +2 -2
- package/types/dom/component.d.ts.map +1 -1
- package/types/dom/html.d.ts +2 -2
- package/types/dom/html.d.ts.map +1 -1
- package/types/dom/rendering.d.ts +8 -7
- package/types/dom/rendering.d.ts.map +1 -1
- package/types/headless.d.ts +5 -5
- package/types/headless.d.ts.map +1 -1
- package/types/tsbuildinfo +1 -1
- package/types/ui/FEAASExternal.d.ts +4 -0
- package/types/ui/FEAASExternal.d.ts.map +1 -1
- package/types/ui/FEAASPicker.d.ts +3 -3
- package/types/ui/FEAASPicker.d.ts.map +1 -1
- package/types/ui/react.d.ts +7 -5
- package/types/ui/react.d.ts.map +1 -1
- package/types/ui/tsbuildinfo +1 -1
- package/types/{dom → utils}/data.d.ts +1 -1
- package/types/utils/data.d.ts.map +1 -0
- package/types/utils/datapath.d.ts +1 -0
- package/types/utils/datapath.d.ts.map +1 -1
- package/types/utils/settings.d.ts +85 -9
- package/types/utils/settings.d.ts.map +1 -1
- package/build/dom/data.js.map +0 -1
- package/build/utils/fetch.js +0 -40
- package/build/utils/fetch.js.map +0 -1
- package/src/utils/fetch.ts +0 -60
- package/test/cjs/tsconfig.json +0 -9
- package/test/fetch-data.ts +0 -55
- package/test/settings.test.ts +0 -78
- package/types/dom/data.d.ts.map +0 -1
- package/types/utils/fetch.d.ts +0 -9
- package/types/utils/fetch.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var Be=Object.defineProperty;var V=(e,t)=>{for(var r in t)Be(e,r,{get:t[r],enumerable:!0})};var zt={};V(zt,{Component:()=>dt,ComponentProps:()=>Ce,Context:()=>W,ControlledPromise:()=>S,DEFAULT_CDN_URL:()=>D,DOM:()=>wt,DataSettings:()=>Ft,Datapath:()=>gt,Datascope:()=>vt,Element:()=>b,FEAASComponent:()=>dt,FEAASComponentsProps:()=>Ce,FEAASContext:()=>W,FEAASContextProps:()=>Me,FEAASEditor:()=>ut,FEAASEditorProps:()=>Ne,FEAASElement:()=>b,FEAASLoader:()=>ct,FEAASLoaderProps:()=>xe,FEAASPicker:()=>ht,FEAASPickerProps:()=>Te,FEAASStylesheet:()=>_t,FEAASStylesheetProps:()=>Se,InvalidResponse:()=>Et,JSONPath:()=>f,Loader:()=>ct,MyComponent:()=>mt,Picker:()=>ht,Stylesheet:()=>_t,Thumbnail:()=>kt,autoloadScripts:()=>se,cleanCollectionBit:()=>nt,clearFetchCache:()=>or,createStylesheet:()=>we,fetchAndRevalidate:()=>ot,fetchAndRevalidateComponent:()=>q,fetchAndRevalidateStylesheet:()=>xt,fetchBypassingCache:()=>At,fetchCache:()=>it,fetchComponent:()=>It,fetchData:()=>lt,fetchToValidateCache:()=>st,fetchWithCacheAwareness:()=>I,findStylesheet:()=>ge,getComponentSource:()=>sr,getComponentURL:()=>at,getFetchCache:()=>ye,getFramePosition:()=>Oe,getHumanizedLabel:()=>ce,getLastPathBit:()=>ue,getQualifier:()=>de,getStylesheetSource:()=>ar,getStylesheetURL:()=>B,isDataSettings:()=>Rt,loadScript:()=>rt,loadStylesheet:()=>St,loadStylesheetAllowStale:()=>Ut,normalizeCollectionScope:()=>bt,observeDOMElement:()=>oe,parseComponentSource:()=>U,parseLimit:()=>ae,parseRange:()=>le,parseStylesheetSource:()=>Ct,queryScopes:()=>et,renderComponent:()=>Bt,renderComponentElement:()=>dr,renderComponentPromise:()=>Ee,renderDOMContent:()=>j,renderDOMElement:()=>R,renderHTMLContent:()=>me,renderStylesheet:()=>lr,renderStylesheetPromise:()=>be,serializeCH1RichText:()=>M,setDOMAttribute:()=>$});function S(e,t=r=>{}){var r;let n=()=>{var i,o;let s=new Promise((l,c)=>{i=d=>{e==null||e(d),l(d)},o=c});var a=Object.assign(s,{resolve:i,reject:o,restart:n,first:r});return r=a,a.catch(t),a};return n()}var We=typeof HTMLElement=="undefined"?typeof windowJSDOM!="undefined"?windowJSDOM.HTMLElement:class{}:HTMLElement,b=class extends We{getProps(t){return{}}constructor(){super(),this.defaultProps={},this.connected=!1,this.refs={},this.descendants=[],this.whenLoaded=S(t=>{this.payload=t}),this.whenRendered=S(()=>this.initialized=!0,()=>cancelAnimationFrame(this.nextRender)),this.addEventListener("feaasMount",this),this.addEventListener("feaasUnmount",this)}getRoot(){return this}attributeChangedCallback(t,r,n){this.set()}connectedCallback(){this.mount()}disconnectedCallback(){this.unmount()}mount(){try{let t=this.getParent();if(t&&!t.connected||this.connected)return;this.connected=!0,this.log("FEAAS: Mount",this.tagName,this),this.dispatchEventIndirectly(new Event("feaasMount",{bubbles:!0,composed:!0})),this.getElements().map(r=>{var n;return(n=r.mount)===null||n===void 0?void 0:n.call(r)}),this.set()}catch(t){this.onError(t)}}dispatchEventIndirectly(t){this.dispatchEvent(t);let r=this.getParent();r&&!r.contains(this)&&(Object.defineProperty(t,"target",{value:this,writable:!1}),Object.defineProperty(t,"composedPath",{value:()=>[this],writable:!1}),r.handleEvent(t))}log(...t){typeof process!="undefined"&&process.env.TESTING||console.log(...t)}unmount(){this.connected&&(this.log("FEAAS: Unmount",this),this.dispatchEventIndirectly(new Event("feaasUnmount",{bubbles:!0,composed:!0})),this.connected=!1)}getParent(t=!0){for(var r=this;r=r.parentElement||(r.parentNode instanceof ShadowRoot?r.parentNode.host:null);)if(!t||r.tagName.startsWith("FEAAS-"))return r;if(this.tagName!="FEAAS-CONTEXT")return document.querySelector("feaas-context")}getElements(t=this.getRoot(),r=!0){return Array.from(t.querySelectorAll("*")).map(n=>[!r||n.tagName.startsWith("FEAAS-")?n:null,n.shadowRoot?this.getElements(n.shadowRoot,r):null]).flat().filter(Boolean)}handleEvent(t){let r=t.composedPath()[0];switch(t.type){case"feaasMount":r!=this&&this.nestedCallback(r);break;case"feaasUnmount":r!=this&&this.unnestedCallback(r);break}}unnestedCallback(t){let r=this.descendants.indexOf(t);r!=-1&&(this.log("FEAAS: Unnest",this,t),this.descendants.splice(r,1),this.refs[t.getComponentName()]=null,t.refs.parent==this&&(t.refs.parent=null),t.refs.top==this&&(t.refs.top=t.refs.parent))}nestedCallback(t){var r,n;if(this.descendants.indexOf(t)==-1&&(this.descendants.push(t),this.log("FEAAS: Nest",this,t),this.refs[t.getComponentName()]=t,t.refs.top=this,(r=t.refs).parent||(r.parent=this),t.render))for(var o=t.refs.parent;o;o=o.refs.parent)o.render&&((n=t.refs).parentReact||(n.parentReact=o),t.refs.topReact=o)}getComponentName(){return this.tagName.replace("FEAAS-","").toLowerCase()}isReadyToLoad(){return this.payload===void 0&&this.getAttribute("hidden")==null}onError(t,r="uncaught",n=!1){let i=new CustomEvent("feaasError",{bubbles:!0,composed:!0,detail:t});if(this.dispatchEventIndirectly(i),this.whenLoaded.reject(t),!i.defaultPrevented&&!n){this.whenRendered.reject(t);try{this.unmount()}catch(o){}return!0}return!1}shouldUpdateOnLoad(){return!0}async advance(){try{if(this.payload===void 0){if(!this.isReadyToLoad())return;this.payload=null,this.dispatchEventIndirectly(new Event("feaasLoad",{bubbles:!0,composed:!0}));let t=await this.load().catch(r=>{throw this.payload=void 0,r});if(this.whenLoaded.resolve(t),this.onLoad)return}else if(this.payload==null)return;this.flush(),this.whenRendered.resolve(this)}catch(t){this.onError(t)}}flush(){var t,r;if(!this.connected)return;let n=(r=(t=this.payload)===null||t===void 0?void 0:t.ReactDOM)===null||r===void 0?void 0:r.flushSync;n?n(()=>this.update()):this.update()}load(){return Promise.resolve(null)}update(){var t,r,n;if(this.payload==null||!this.render)return;let{React:i,ReactDOM:o,ReactDOMClient:s}=this.payload||{};if(!i)throw new Error(`${this.tagName}: React is not present in payload`);if(!o)throw new Error(`${this.tagName}: ReactDOM is not present in payload`);!this.refs.topReact&&!this.forceUpdateReact?s?(this.reactRoot||(this.reactRoot=s.createRoot(this.getReactRootElement())),this.reactRoot.render(this.getReactElement())):o.render(this.getReactElement(),this.getReactRootElement()):this.forceUpdateReact?(t=this.forceUpdateReact)===null||t===void 0||t.call(this):(n=(r=this.refs.topReact).forceUpdateReact)===null||n===void 0||n.call(r)}invokeReactRendering(){let{React:t,ReactDOM:r}=this.payload||{};if(!this.connected)return null;let n=this.descendants.filter(i=>i.refs.parentReact==this&&i.payload).map((i,o)=>this.getReactElement(i));return this.render({...this.props,children:n},this.payload)}getReactErrorBoundary(t=this,r=t.tagName){if(this.reactErrorBoundary)return this.reactErrorBoundary;let{React:n,ReactDOM:i}=t.payload||{};return this.reactErrorBoundary||(this.reactErrorBoundary=class extends n.Component{constructor(){super(...arguments),this.state={error:null}}static getDerivedStateFromError(s){return{error:s}}componentDidCatch(s,a){console.error(`FEAAS: ${t.tagName} Error:`,s,a),t.onError(s,"react")}render(){if(!this.state.error)return this.props.children}})}getReactElement(t=this,r){let{React:n,ReactDOM:i}=t.payload||{},o=this.getReactErrorBoundary(),s=this.getReactWrapper(t);return n.createElement(o,{key:t.tagName+"-"+t.getUID(),slot:t.getAttribute("slot")},n.createElement(s,null))}getReactWrapper(t=this,r=t.tagName){if(t.reactWrapper)return t.reactWrapper;let{React:n,ReactDOM:i}=t.payload||{};return t.reactWrapper=o=>{if(t.render){let[s,a]=n.useReducer(l=>l+1,0);return t.forceUpdateReact=a,i.createPortal(n.createElement(n.Fragment,null,t.invokeReactRendering()),t.getReactRootElement())}else return t.update()},Object.assign(t.reactWrapper,{key:t.tagName+"-"+t.getUID(),displayName:r}),t.reactWrapper}getUID(){return this.uid||(this.uid=String(Math.random()))}getShadowRoot(){return this.shadowRoot||this.attachShadow({mode:"open"}),this.shadowRoot}getReactRootElement(){return this.useShadowRoot?this.getShadowRoot():this.getRoot()}set(t){try{this.scheduleRender(),this.overrides={...this.overrides,...t},this.props={...this.getProps(),...this.overrides};for(var r in this.props){let n=this.props[r],i=r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();n==null||n===this.defaultProps[r]?this.removeAttribute(i):(typeof n=="string"||typeof n=="number"||typeof n=="boolean")&&this.getAttribute(i)!=String(n)&&this.setAttribute(i,String(n))}}catch(n){this.whenRendered.reject(n),this.onError(n,"set")}return this}import(t){return import( /*@vite-ignore*/ /* webpackIgnore: true */ t)}scheduleRender(){this.nextRender==null&&(this.whenRendered=this.whenRendered.restart()),cancelAnimationFrame(this.nextRender),this.nextRender=requestAnimationFrame(()=>{this.nextRender=null,this.advance().catch(t=>{})})}formatURL(t,r){return typeof t=="string"&&t.match(/^\/[^\/]/)?r+t:t}getContextAttribute(t,r=this){for(var n=this;n=n.parentElement||(n.parentNode instanceof ShadowRoot?n.parentNode.host:null);)if(n.getAttribute(t)!=null)return n.getAttribute(t);return this.getAttribute(t)}static register(t,r){r==null&&(r=typeof window!="undefined"?window:null),r&&!r.customElements.get(t)&&r.customElements.define(t,this)}};var J=class extends b{load(){return Promise.all([import( /*@vite-ignore*/ /* webpackIgnore: true */ "https://cdn.skypack.dev/react"),import( /*@vite-ignore*/ /* webpackIgnore: true */ "https://cdn.skypack.dev/react-dom")]).then(([t,r])=>({React:t,ReactDOM:r}))}render({},{React:t}){return t.createElement(t.Fragment,null)}},mt=class extends J{constructor(){super(...arguments),this.useShadowRoot=!0}getProps(){return{counter:parseFloat(this.getAttribute("counter"))}}render({counter:t},{React:r}){let[n,i]=r.useState(0);return r.useEffect(()=>{i(o=>o+1)},[t]),r.createElement(r.Fragment,null,r.createElement("p",null,"Rendering attribute: ",t),r.createElement("p",null,"Triggered updates: ",n))}};mt.observedAttributes=["counter"];var wt={};V(wt,{renderDOMContent:()=>j,renderDOMElement:()=>R,renderHTMLContent:()=>me,setDOMAttribute:()=>$});var vt={};V(vt,{JSONPath:()=>f,queryScopes:()=>et,serializeCH1RichText:()=>M});function k(e){return k=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},k(e)}function Qt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Zt(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function te(e,t,r){return t&&Zt(e.prototype,t),r&&Zt(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function He(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&tt(e,t)}function Q(e){return Q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Q(e)}function tt(e,t){return tt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},tt(e,t)}function ee(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Z(e,t,r){return ee()?Z=Reflect.construct.bind():Z=function(i,o,s){var a=[null];a.push.apply(a,o);var l=Function.bind.apply(i,a),c=new l;return s&&tt(c,s.prototype),c},Z.apply(null,arguments)}function ze(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function Tt(e){var t=typeof Map=="function"?new Map:void 0;return Tt=function(n){if(n===null||!ze(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(n))return t.get(n);t.set(n,i)}function i(){return Z(n,arguments,Q(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),tt(i,n)},Tt(e)}function Ve(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Je(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ve(e)}function qe(e){var t=ee();return function(){var n=Q(e),i;if(t){var o=Q(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return Je(this,i)}}function Ke(e){return Ge(e)||Xe(e)||re(e)||Ye()}function Ge(e){if(Array.isArray(e))return Mt(e)}function Xe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function re(e,t){if(e){if(typeof e=="string")return Mt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Mt(e,t)}}function Mt(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Ye(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function
|
|
3
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,a;return{s:function(){r=r.call(e)},n:function(){var l=r.next();return o=l.done,l},e:function(l){s=!0,a=l},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(s)throw a}}}}var x=Object.prototype.hasOwnProperty;function T(e,t){return e=e.slice(),e.push(t),e}function Lt(e,t){return t=t.slice(),t.unshift(e),t}var Qe=function(e){He(r,e);var t=qe(r);function r(n){var i;return Qt(this,r),i=t.call(this,'JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),i.avoidNew=!0,i.value=n,i.name="NewError",i}return te(r)}(Tt(Error));function f(e,t,r,n,i){if(!(this instanceof f))try{return new f(e,t,r,n,i)}catch(l){if(!l.avoidNew)throw l;return l.value}typeof e=="string"&&(i=n,n=r,r=t,t=e,e=null);var o=e&&k(e)==="object";if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=x.call(e,"wrap")?e.wrap:!0,this.sandbox=e.sandbox||{},this.preventEval=e.preventEval||!1,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||n||null,this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},e.autostart!==!1){var s={path:o?e.path:t};o?"json"in e&&(s.json=e.json):s.json=r;var a=this.evaluate(s);if(!a||k(a)!=="object")throw new Qe(a);return a}}f.prototype.evaluate=function(e,t,r,n){var i=this,o=this.parent,s=this.parentProperty,a=this.flatten,l=this.wrap;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=n||this.otherTypeCallback,t=t||this.json,e=e||this.path,e&&k(e)==="object"&&!Array.isArray(e)){if(!e.path&&e.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!x.call(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');var c=e;t=c.json,a=x.call(e,"flatten")?e.flatten:a,this.currResultType=x.call(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=x.call(e,"sandbox")?e.sandbox:this.currSandbox,l=x.call(e,"wrap")?e.wrap:l,this.currPreventEval=x.call(e,"preventEval")?e.preventEval:this.currPreventEval,r=x.call(e,"callback")?e.callback:r,this.currOtherTypeCallback=x.call(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,o=x.call(e,"parent")?e.parent:o,s=x.call(e,"parentProperty")?e.parentProperty:s,e=e.path}if(o=o||null,s=s||null,Array.isArray(e)&&(e=f.toPathString(e)),!(!e&&e!==""||!t)){var d=f.toPathArray(e);d[0]==="$"&&d.length>1&&d.shift(),this._hasParentSelector=null;var h=this._trace(d,t,["$"],o,s,r).filter(function(u){return u&&!u.isParentSelector});return h.length?!l&&h.length===1&&!h[0].hasArrExpr?this._getPreferredOutput(h[0]):h.reduce(function(u,p){var C=i._getPreferredOutput(p);return a&&Array.isArray(C)?u=u.concat(C):u.push(C),u},[]):l?[]:void 0}};f.prototype._getPreferredOutput=function(e){var t=this.currResultType;switch(t){case"all":{var r=Array.isArray(e.path)?e.path:f.toPathArray(e.path);return e.pointer=f.toPointer(r),e.path=typeof e.path=="string"?e.path:f.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return f.toPathString(e[t]);case"pointer":return f.toPointer(e.path);default:throw new TypeError("Unknown result type")}};f.prototype._handleCallback=function(e,t,r){if(t){var n=this._getPreferredOutput(e);e.path=typeof e.path=="string"?e.path:f.toPathString(e.path),t(n,r,e)}};f.prototype._trace=function(e,t,r,n,i,o,s,a){var l=this,c;if(!e.length)return c={path:r,value:t,parent:n,parentProperty:i,hasArrExpr:s},this._handleCallback(c,o,"value"),c;var d=e[0],h=e.slice(1),u=[];function p(y){Array.isArray(y)?y.forEach(function(v){u.push(v)}):u.push(y)}if((typeof d!="string"||a)&&t&&x.call(t,d))p(this._trace(h,t[d],T(r,d),t,d,o,s));else if(d==="*")this._walk(t,function(y){p(l._trace(h,t[y],T(r,y),t,y,o,!0,!0))});else if(d==="..")p(this._trace(h,t,r,n,i,o,s)),this._walk(t,function(y){k(t[y])==="object"&&p(l._trace(e.slice(),t[y],T(r,y),t,y,o,!0))});else{if(d==="^")return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:h,isParentSelector:!0};if(d==="~")return c={path:T(r,d),value:i,parent:n,parentProperty:null},this._handleCallback(c,o,"property"),c;if(d==="$")p(this._trace(h,t,r,null,null,o,s));else if(/^(\x2D?[0-9]*):(\x2D?[0-9]*):?([0-9]*)$/.test(d))p(this._slice(d,h,t,r,n,i,o));else if(d.indexOf("?(")===0){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");var C=d.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/,"$1");this._walk(t,function(y){l._eval(C,t[y],y,r,n,i)&&p(l._trace(h,t[y],T(r,y),t,y,o,!0))})}else if(d[0]==="("){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");p(this._trace(Lt(this._eval(d,t,r[r.length-1],r.slice(0,-1),n,i),h),t,r,n,i,o,s))}else if(d[0]==="@"){var m=!1,w=d.slice(1,-2);switch(w){case"scalar":(!t||!["object","function"].includes(k(t)))&&(m=!0);break;case"boolean":case"string":case"undefined":case"function":k(t)===w&&(m=!0);break;case"integer":Number.isFinite(t)&&!(t%1)&&(m=!0);break;case"number":Number.isFinite(t)&&(m=!0);break;case"nonFinite":typeof t=="number"&&!Number.isFinite(t)&&(m=!0);break;case"object":t&&k(t)===w&&(m=!0);break;case"array":Array.isArray(t)&&(m=!0);break;case"other":m=this.currOtherTypeCallback(t,r,n,i);break;case"null":t===null&&(m=!0);break;default:throw new TypeError("Unknown value type "+w)}if(m)return c={path:r,value:t,parent:n,parentProperty:i},this._handleCallback(c,o,"value"),c}else if(d[0]==="`"&&t&&x.call(t,d.slice(1))){var E=d.slice(1);p(this._trace(h,t[E],T(r,E),t,E,o,s,!0))}else if(d.includes(",")){var pt=d.split(","),O=Ze(pt),ft;try{for(O.s();!(ft=O.n()).done;){var qt=ft.value;p(this._trace(Lt(qt,h),t,r,n,i,o,!0))}}catch(y){O.e(y)}finally{O.f()}}else!a&&t&&x.call(t,d)&&p(this._trace(h,t[d],T(r,d),t,d,o,s,!0))}if(this._hasParentSelector)for(var P=0;P<u.length;P++){var z=u[P];if(z&&z.isParentSelector){var N=this._trace(z.expr,t,z.path,n,i,o,s);if(Array.isArray(N)){u[P]=N[0];for(var Dt=N.length,K=1;K<Dt;K++)P++,u.splice(P,0,N[K])}else u[P]=N}}return u};f.prototype._walk=function(e,t){if(Array.isArray(e))for(var r=e.length,n=0;n<r;n++)t(n);else e&&k(e)==="object"&&Object.keys(e).forEach(function(i){t(i)})};f.prototype._slice=function(e,t,r,n,i,o,s){if(Array.isArray(r)){var a=r.length,l=e.split(":"),c=l[2]&&Number.parseInt(l[2])||1,d=l[0]&&Number.parseInt(l[0])||0,h=l[1]&&Number.parseInt(l[1])||a;d=d<0?Math.max(0,d+a):Math.min(a,d),h=h<0?Math.max(0,h+a):Math.min(a,h);for(var u=[],p=d;p<h;p+=c){var C=this._trace(Lt(p,t),r,n,i,o,s,!0);C.forEach(function(m){u.push(m)})}return u}};f.prototype._eval=function(e,t,r,n,i,o){this.currSandbox._$_parentProperty=o,this.currSandbox._$_parent=i,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;var s=e.includes("@path");s&&(this.currSandbox._$_path=f.toPathString(n.concat([r])));var a="script:"+e;if(!f.cache[a]){var l=e.replace(/@parentProperty/g,"_$_parentProperty").replace(/@parent/g,"_$_parent").replace(/@property/g,"_$_property").replace(/@root/g,"_$_root").replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g,"_$_v$1");s&&(l=l.replace(/@path/g,"_$_path")),f.cache[a]=new this.vm.Script(l)}try{return f.cache[a].runInNewContext(this.currSandbox)}catch(c){throw new Error("jsonPath: "+c.message+": "+e)}};f.cache={};f.toPathString=function(e){for(var t=e,r=t.length,n="$",i=1;i<r;i++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(t[i])||(n+=/^[\*0-9]+$/.test(t[i])?"["+t[i]+"]":"['"+t[i]+"']");return n};f.toPointer=function(e){for(var t=e,r=t.length,n="",i=1;i<r;i++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(t[i])||(n+="/"+t[i].toString().replace(/~/g,"~0").replace(/\//g,"~1"));return n};f.toPathArray=function(e){var t=f.cache;if(t[e])return t[e].concat();var r=[],n=e.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g,";$&;").replace(/['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))['\]]/g,function(o,s){return"[#"+(r.push(s)-1)+"]"}).replace(/\[["']((?:(?!['\]])[\s\S])*)["']\]/g,function(o,s){return"['"+s.replace(/\./g,"%@%").replace(/~/g,"%%@@%%")+"']"}).replace(/~/g,";~;").replace(/["']?\.["']?(?!(?:(?!\[)[\s\S])*\])|\[["']?/g,";").replace(/%@%/g,".").replace(/%%@@%%/g,"~").replace(/(?:;)?(\^+)(?:;)?/g,function(o,s){return";"+s.split("").join(";")+";"}).replace(/;;;|;;/g,";..;").replace(/;$|'?\]|'$/g,""),i=n.split(";").map(function(o){var s=o.match(/#([0-9]+)/);return!s||!s[1]?o:r[s[1]]});return t[e]=i,t[e].concat()};var tr=function(t,r,n){for(var i=t.length,o=0;o<i;o++){var s=t[o];n(s)&&r.push(t.splice(o--,1)[0])}},er=function(){function e(t){Qt(this,e),this.code=t}return te(e,[{key:"runInNewContext",value:function(r){var n=this.code,i=Object.keys(r),o=[];tr(i,o,function(d){return typeof r[d]=="function"});var s=i.map(function(d,h){return r[d]}),a=o.reduce(function(d,h){var u=r[h].toString();return/function/.test(u)||(u="function "+u),"var "+h+"="+u+";"+d},"");n=a+n,!/(["'])use strict\1/.test(n)&&!i.includes("arguments")&&(n="var arguments = undefined;"+n),n=n.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/,"");var l=n.lastIndexOf(";"),c=l>-1?n.slice(0,l+1)+" return "+n.slice(l+1):" return "+n;return Z(Function,i.concat([c])).apply(void 0,Ke(s))}}]),e}();f.prototype.vm={Script:er};function et(e,t,r=!1,n=e){var i=t;let o=Object.keys(e).sort((a,l)=>l.length-a.length);for(let a of o)if(t.startsWith(a)){if(a==t){if(r)return e[a];continue}i=t.substring(a.length+1),n=e[a];break}var s=f({path:i,json:n});return Array.isArray(s)&&(s==null?void 0:s.length)==0&&(s=[i.replace(/^.*?\./,"_."),i.replace(/^.*?\./,""),i.replace(/^([^.]+).*?\.\$\./,"$1."),i.replace(/^.*?\.\$\./,"_."),i.replace(/^.*?\.\$\./,""),i.replace(/^[^.]+$/,"_")].filter((a,l,c)=>c.indexOf(a)===l).reduce((a,l)=>a.length>0?a:f({path:l,json:n}),[])),r&&Array.isArray(s)?s[0]:s}function $t(e,t={},r){return r?`<${r}${Object.entries(t).map(([n,i])=>i!=null&&` ${n}="${i}"`).filter(Boolean).join("")}>${M(e)}</${r}>`.replace(/^<([a-z0-9][^>]*)><\/[^>]+>$/,"<$1 />"):M(e)}function M(e){var t;if(Array.isArray(e))return e.map(M).join(`
|
|
4
|
-
`).trim();if(typeof e=="string")return e;if(e==null)return"";switch(e.type){case"heading":let{level:r,...n}=e.attrs;return $t(e.content,n,"h"+r);case"text":return(e.marks||[]).reduce((i,o)=>$t(i,o.attrs,{link:"a",bold:"strong",italic:"em",strike:"s",underline:"u"}[o.type]),(t=e.text)===null||t===void 0?void 0:t.replace(/\s+/," "));default:return $t(e.content||e.text,e.attrs,{bulletList:"ul",orderedList:"ol",listItem:"li",horizontalRule:"hr",paragraph:"p",codeBlock:"code",blockquote:"blockquote"}[e.type])}}var L=class{constructor(t,r=1,n){this.ownerDocument={createElement(i){return new L(i)}},this.nodeName=t,this.nodeType=r,this.textContent=n,this.attributes=[],this.childNodes=[]}setAttribute(t,r){let n=this.attributes.find(i=>i.name===t);n?n.value=r:this.attributes.push({name:t,value:r})}getAttribute(t){let r=this.attributes.find(n=>n.name===t);return r?r.value:void 0}insertBefore(t,r){if(t.parentNode=this,r===null)this.childNodes.push(t);else{let n=this.childNodes.indexOf(r);n!==-1&&this.childNodes.splice(n,0,t)}}removeAttribute(t){let r=this.attributes.findIndex(n=>n.name===t);r!==-1&&this.attributes.splice(r,1)}appendChild(t){t.parentNode=this,this.childNodes.push(t)}get tagName(){var t;return(t=this.nodeName)===null||t===void 0?void 0:t.toUpperCase()}get localName(){var t;return(t=this.nodeName)===null||t===void 0?void 0:t.toLowerCase()}get innerHTML(){return jt(this.childNodes)}set innerHTML(t){this.childNodes=yt(String(t!=null?t:""))}get outerHTML(){return jt([this])}get children(){return this.childNodes.filter(t=>t.nodeType==1)}closest(t){let r=this;for(;r;){if(ne(t,r))return r;r=r.parentNode}return null}querySelectorAll(t){let r=t.split(/\s*,\s*/),n=[],i=o=>{for(let s of r)if(ne(s,o)){n.push(o);break}for(let s of o.childNodes)i(s)};for(let o of this.childNodes)i(o);return n}querySelector(t){return this.querySelectorAll(t)[0]}findSibling(t,r){if(!this.parentNode)return null;let n=this.parentNode.childNodes,i=n.indexOf(this);if(i===-1)return null;for(let o=i+t;o>=0&&o<n.length;o+=t){let s=n[o];if(!r||s.nodeType===1)return s}return null}removeChild(t){let r=this.childNodes.indexOf(t);if(r!==-1)return this.childNodes.splice(r,1),t.parentNode=void 0,t}get previousSibling(){return this.findSibling(-1)}get nextSibling(){return this.findSibling(1)}get previousElementSibling(){return this.findSibling(-1,!0)}get nextElementSibling(){return this.findSibling(1,!0)}cloneNode(t=!1){let r=new L(this.nodeName,this.nodeType);if(r.attributes=JSON.parse(JSON.stringify(this.attributes)),this.textContent&&(r.textContent=this.textContent),t)for(let n of this.childNodes){let i=n.cloneNode(!0);r.appendChild(i)}return r}get parentElement(){var t;return((t=this.parentNode)===null||t===void 0?void 0:t.nodeType)==1?this.parentNode:null}};function ne(e,t){let r=e.match(/([.#]?[\w-]+|\[([\w-]+)(="([^"]*)")?\])/g);if(!r)return!1;for(let n of r)if(n.startsWith("#")){if(t.getAttribute("id")!==n.slice(1))return!1}else if(n.startsWith(".")){if(!(t.getAttribute("class")||"").split(" ").includes(n.slice(1)))return!1}else if(n.startsWith("[")){let i=n.match(/^\[([\w-]+)(="([^"]*)")?\]$/);if(i){let o=i[1],s=i[3],a=t.getAttribute(o);if(typeof s=="undefined"){if(a===void 0)return!1}else if(a!==s)return!1}else return!1}else if(t.nodeName!==n)return!1;return!0}function yt(e){var t;let r=[],n=[];for(;e;){let i=e.match(/^<([\w-]+)(\s[^>]*)?>/),o=e.match(/^<\/([\w-]+)>/);if(i){let s=i[1],l=((t=(i[2]||"").match(/([\w-]+)(="([^"]*)")?/g))===null||t===void 0?void 0:t.map(d=>{let[h,u,,p]=d.match(/([\w-]+)(="([^"]*)")?/);return{name:u,value:nr(p||"")}}))||[],c=new L(s,1);if(c.attributes=l,n.length>0){let d=n[n.length-1];d.childNodes.push(c),c.parentNode=d}else r.push(c);n.push(c),e=e.slice(i[0].length)}else if(o)n.pop(),e=e.slice(o[0].length);else{let s=e.indexOf("<"),a=e.slice(0,s!==-1?s:void 0),l=new L("#text",3);if(l.textContent=a,n.length>0){let c=n[n.length-1];c.childNodes.push(l),l.parentNode=c}else r.push(l);e=e.slice(a.length)}}return r}function rr(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function nr(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'")}function jt(e){return e.map(t=>{if(t.nodeType===3)return t.textContent||"";let{nodeName:r,attributes:n}=t,i=n.map(({name:s,value:a})=>` ${s}="${rr(String(a))}"`).join(""),o=jt(t.childNodes);return["img","input","br"].includes(r)?`<${r}${i} />`:`<${r}${i}>${o}</${r}>`}).join("")}function ie(e,t,r){var n;let i=((n=r==null?void 0:r.processTemplate)===null||n===void 0?void 0:n.call(r,null,e,t))||e,o=yt(i);return R(o[0],t,r).outerHTML}function oe(e){let t=new e.ownerDocument.defaultView.MutationObserver(r=>{r.forEach(n=>{let i=n.target,o=i.getAttribute("data-embed-src");o&&rt(i,o),n.addedNodes&&n.addedNodes.forEach(s=>{s.nodeType==1&&se(s,!1)})})});return t.observe(e,{attributes:!0,subtree:!0,childList:!0}),t}function se(e,t=!0){let r=e.querySelectorAll("[data-embed-src]");for(var n=0;n<r.length;n++){let i=r[n];rt(i,i.getAttribute("data-embed-src"))}if(t)return oe(e)}function rt(e,t){for(var r=e;r;r=r.parentElement)if(!r.parentElement){let i=r.querySelectorAll("script");for(var n=0;n<i.length;n++)if(i[n].getAttribute("src")==t)return!0;r.tagName=="HTML"&&(r=r.querySelector("head")||r);let o=r.ownerDocument.createElement("script");o.setAttribute("type","module"),o.setAttribute("src",t),r.appendChild(o);break}}var gt={};V(gt,{cleanCollectionBit:()=>nt,getHumanizedLabel:()=>ce,getLastPathBit:()=>ue,getQualifier:()=>de,normalizeCollectionScope:()=>bt,parseLimit:()=>ae,parseRange:()=>le});var ae=e=>{var t;let r=parseInt((t=e==null?void 0:e.match(/\[0:(\d+)\]/))===null||t===void 0?void 0:t[1],10);return!isNaN(r)&&r>0?String(r):null},le=e=>{var t;let r=(t=e==null?void 0:e.match(/\[([^\]]+)\]/))===null||t===void 0?void 0:t[1].split(/\s*,\s*/g).filter(Boolean).map(n=>{if(n.match(/^-?\d+$/))return n;let i=n.match(/^(\d+):(\d+)$/);return i&&parseInt(i[1],10)<parseInt(i[2],10)?i[1]+"-"+i[2]:null});return r!=null&&r.every(Boolean)?r.join(","):null},de=e=>{var t;return(t=e==null?void 0:e.match(/(\.\*|\[[^\]]+\])$/))===null||t===void 0?void 0:t[0]};function nt(e){return e.replace(/(\[[^\]\[]+\]|\.\*)$/g,"")}function bt(e){return nt(e)+".*"}function ce(e,t=2){var r=nt(e).split(/]\.|\.\*\./g).pop().split(/\./g).slice(-3);return r=r.filter(n=>isNaN(parseInt(n))),r.map(n=>n.charAt(0).toUpperCase()+n.slice(1)).slice(-t).join(" ")}function ue(e){return nt(e).split(".").pop()}function pe(e){let t=e.getAttribute("data-path-scope");for(var r=0,n=e;n=n.previousElementSibling;)n.getAttribute("data-path-scope")==t&&r++;return r}function ir(e,t,r){let n=e.getAttribute("data-path-scope");if(n==null)return;var i=pe(e);if(i!=0)return;let o=e.parentNode;if(o!=null){t==0?e.setAttribute("hidden","hidden"):e.getAttribute("hidden")!=null&&e.removeAttribute("hidden");for(var s=i+1,a=e,l=e;l=l.nextElementSibling;)l.getAttribute("data-path-scope")==n&&(s++,a=l);for(var c=s;c<t;c++)o.insertBefore(a.cloneNode(!0),a.nextElementSibling);for(var c=Math.max(1,t);c<s;c++)a=a.previousElementSibling,o.removeChild(a.nextElementSibling)}}function $(e,t,r,n){var i,o;if(e){var s=e;(r==null?void 0:r.type)=="doc"&&Array.isArray(r.content)&&(r=M(r)),n!=null&&n.processValue&&(r=n==null?void 0:n.processValue(e,t,r));var a=t.replace("data-path-","");if(t=="data-path-src"){let u=Array.from(e.children).find(p=>p.localName=="picture")||e;s=e.localName=="img"?e:u.querySelector("img, video")}else if(t=="data-path-href")s=e.querySelector("a")||e.closest("a");else if(t=="data-path-alt")s=(Array.from(e.children).find(p=>p.localName=="picture")||e).querySelector("img, picture");else if(t=="data-path-hidden")r=r?null:!0;else if(t=="data-path"||t=="data-embed-html"||t=="html")a="innerHTML";else if(t=="data-embed-src")rt(e,r);else if(t=="data-path-attributes"){let u=((i=e.getAttribute("data-attributes-keys"))===null||i===void 0?void 0:i.split(",").filter(Boolean))||[];if(!Array.isArray(r))for(var l in r){var c=r[l];$(e,l,typeof c=="object"&&c?JSON.stringify(c):c,n)}for(var d=0;d<u.length;d++)(r==null||!(u[d]in r))&&$(e,u[d],null,n);$(e,"data-attributes-keys",Object.keys(r||{}).join(","));return}if(typeof r=="boolean"&&(r=r?"":null),!!s){var h=String((o=e.getAttribute("data-path-placeholder")||s[a])!==null&&o!==void 0?o:s.getAttribute(a));r!=null?a=="innerHTML"?s.innerHTML!=r&&(s.innerHTML=r):s.getAttribute(a)!=r&&s.setAttribute(a,r):a=="innerHTML"?s.innerHTML=h:s.removeAttribute(a)}}}var he=["data-attributes-keys","data-path-attributes","data-path-scope"];function R(e,t,r,n){var i,o,s;let a=e;if(n||(t=((i=r==null?void 0:r.processData)===null||i===void 0?void 0:i.call(r,a,t))||t),a.nodeType==1){let d=a.getAttribute("data-path-scope");if(d){let u=pe(a),p=et(t,d,!1)||[];u==0&&ir(a,((o=r==null?void 0:r.shouldRepeat)===null||o===void 0?void 0:o.call(r,a,p))===!1?1:p.length,r),t={...t,[bt(d)]:p[u]}}let h=Array.prototype.slice.call(a.attributes).sort((u,p)=>he.indexOf(u.name)-he.indexOf(p.name));for(var l=0;l<h.length;l++){let{name:u,value:p}=h[l];u.startsWith("data-path")&&u!="data-path-scope"&&$(a,u,et(t,p,!0),r),u=="data-embed-src"&&$(a,u,a.getAttribute(u),r)}}for(var l=0,c;c=a.childNodes[l++];)fe(c)&&R(c,t,r,!0);return n||(s=r==null?void 0:r.onRender)===null||s===void 0||s.call(r,a,t),a}function fe(e){return e.nodeType==1}function j(e,t,r,n){var i;let o=((i=n==null?void 0:n.processTemplate)===null||i===void 0?void 0:i.call(n,e,t,r))||t;if(e.innerHTML=o,e.classList.add("-feaas"),(e.closest(".component.feaas")||e).className.includes("-theme--"))for(var a=0,l;l=e.childNodes[a++];)fe(l)&&(l.className=l.className.replace(/(\s|^)-theme--[^\s]+\s*/g,"$1"));return R(e,r,n)}function me(e,t,r,n=!1){var i;let o=((i=r==null?void 0:r.processTemplate)===null||i===void 0?void 0:i.call(r,null,e,t))||e;if(typeof document=="undefined"||n){let s=yt(o);return R(s[0],t,r).outerHTML}else{let s=document.createElement("div");return s.innerHTML=o,R(s,t,r),s.innerHTML}}var ve=["initial","check","updated"],it={};function or(){it={}}async function ot(e,t,r,n,i=it){return I({url:e,options:t,validator:r,callback:n,cache:i}).then(st).then(o=>o.response)}function ye(e,t=!1){let r=String(e).replace("?head","");var n=it[r];return!n&&!t&&(n=it[r]={phase:null,initial:S(),check:S(),updated:S(),final:S()}),n}var Et=class extends Error{};async function I({url:e,options:t,validator:r,callback:n,cache:i},o="initial"){let s=new Date;if(i!=null){var a=ye(e);if(ve.indexOf(a.phase)>=ve.indexOf(o))var l=a[o];else a.phase=o}let c=await(l||fetch(e,t));if(!l&&a&&(c.ok?a[o].resolve(c):a[o].reject(new Error("Fetch failed"))),!c.ok)throw new Error("Fetch failed");let d=new Date(c.headers.get("date"))<s||l&&o=="initial"&&(a.phase=="updated"||a.phase=="check");if((r==null?void 0:r(c,d))===!1)throw new Et("Response is not valid");return await(n==null?void 0:n(c,o,d)),{url:e,options:t,isCached:d,response:c,validator:r,callback:n,cache:i}}async function st(e){let{url:t,isCached:r,options:n,validator:i,response:o,cache:s}=e;if(r){let{response:a}=await I({url:t+"?head",options:{...n,method:"HEAD",cache:"no-cache"},validator:i,cache:s},"check");if(a.headers.get("last-modified")!=o.headers.get("last-modified"))return At(e)}return e}async function At(e){return I({...e,options:{...e.options,cache:"reload"}},"updated")}var D="https://feaas.blob.core.windows.net";function U(e){let t=e.match(/^(?:(.*?)\/components)?\/?([^\/]+)\/([^\/]+)(?:\/([^\/]+)(?:\/(published|staged|saved|\d+)(?:\.html?)?)?)?$/);if(t){var[,r,n,i,o,s]=t;return{cdn:r,library:n,component:i,version:o,revision:s}}}function sr(e){if(!e||!e.library||!e.component)throw new Error("Component requires `library` and `component` properties");return`${e.cdn&&e.cdn!=D?`${e.cdn}/components`:""}/${e.library}/${e.component}/${!e.version||e.version=="responsive"&&(!e.revision||e.revision=="published")?"":e.version}/${!e.revision||e.revision=="published"?"":e.revision}`.replace(/(^\/|\/$|\/\/)(?!.+\/components\/)/g,"")}function ar(e){return`${e.cdn&&e.cdn!=D?`${e.cdn}/styles/`:""}${e.library}/${!e.revision||e.revision=="published"?"":e.revision}`.replace(/\/$|\/\/(?!.+\/styles\/)/g,"")}function Ct(e){let t=e.match(/^(?:(.*?)\/styles\/)?([^\/]+)(?:\/(published|staged|saved|\d+)(?:.css)?)?$/);if(t){var[,r,n,i]=t;return{cdn:r,library:n,revision:i}}else{let o=U(e);if(o){var{cdn:r,library:n,revision:i}=o;return i!=null&&i.match(/\d/)&&(i=void 0),{cdn:r,library:n,revision:i}}}}function at(e){return typeof e=="string"&&(e={src:e}),"src"in e&&(e={...U(e.src)}),`${e.cdn||e.hostname||D}/components/${e.library}/${e.component}/${e.version}/${e.revision||"published"}.html`}function B(e){return typeof e=="string"&&(e={src:e}),"src"in e&&(e={...Ct(e.src)}),`${e.cdn||e.hostname||D}/styles/${e.library}/${e.revision||"published"}.css`}async function q(e,t,r=!1){let n=a=>a.headers.get("x-ms-meta-versionDeletedAt")==null,i=a=>a.clone().text().then(t),o=await Promise.all([e.instance&&I({options:{headers:{Accept:"text/html"},credentials:"omit"},url:at({...e,version:e.instance}),validator:n}).catch(a=>a),I({url:at(e),validator:n}).catch(a=>a)]),s=o.find(a=>a&&"isCached"in a&&a);if(!s||s instanceof Error)throw o.find(l=>l&&l instanceof Error)||new Error("Can not fetch component");return o[0]==s&&console.log("Using fork!",o),await i(s.response),r?s:st({...s,callback:i}).catch(a=>{if(o[0]==s&&(At({...s,callback:null,validator:null}),console.log("Fork was deleted"),!(o[1]instanceof Error)))return i(o[1].response),st({...o[1],callback:i});throw a})}async function It(e){typeof e=="string"&&(e={src:e});var t;let{response:r}=await q(e,n=>{t=n},!0);return{...e,template:t,lastModified:r.headers.get("last-modified")}}async function xt(e,t){return typeof e=="string"&&(e={src:e}),ot(B(e),{headers:{Accept:"text/css"},credentials:"omit"},r=>r.headers.get("x-ms-meta-deletedAt")==null,(r,n)=>r.clone().text().then(i=>t(i,n)))}function lr(e,t){return be(e,t||(t=document.createElement("style"))),t}function be(e,t){return t||(t=document.createElement("style")),xt(e,(r,n)=>{t.textContent=r}).then(()=>t)}function St(e,t){var r=ge(e);if(!r)var n=we(e);return xt(e,(i,o)=>{n&&(n.textContent=i),t==null||t(i,o)}).then(()=>r||n)}function Ut(e){return new Promise((t,r)=>{St(e,t).catch(r)})}function ge(e){return document.head.querySelector(`style[data-href="${B(e)}"]`)}function we(e){let t=B(e),r=document.createElement("style");return r.setAttribute("data-href",t),document.head.appendChild(r),r}function dr(e,t){let r=document.createElement("div");r.innerHTML=e;let n=document.createDocumentFragment();for(;r.firstChild;)n.appendChild(r.firstChild);return R(n,t),r}function Bt(e,t){return Ee(e,t||(t=document.createElement("div"))),t}async function Ee(e,t){return t||(t=document.createElement("div")),t.childNodes.length?R(t,e.data,e):"template"in e?j(t,e.template,e.data,e):q(e,r=>j(t,r,e.data,e)).then(()=>t)}var Rt=e=>{if(typeof e.url!="string")return!1;for(var t in e)if(!(t=="body"||t=="params"||t=="headers"||t=="url"||t==="method"||t=="jsonpath"&&typeof e[t]=="string"))return!1;return!0},Ae=async e=>{try{let t=await fetch(e.url,e);return t?await t.json():{}}catch(t){return{}}};async function lt(e){if(!e)return e;if(Rt(e))return Ae(e);let t=Object.keys(e),r=await Promise.all(t.map(n=>Rt(e[n])?Ae(e[n]):null).filter(Boolean));return t.reduce((n,i)=>({...n,[i]:Rt(e[i])?r.shift():e[i]}),{})}function Ce(e){var t,r,n,i,o,s,a,l;let c,d=e.getAttribute("src");if(d){let E=U(d);if(!E)throw new Error(`Could not parse FEAAS Component source: ${d}`);var{cdn:h,library:u,component:p,version:C,revision:m}=E}let w=e.getAttribute("data");if(w!=null&&w!="")try{c=typeof w=="string"?JSON.parse(w):{}}catch(E){console.error(E)}return{data:c||{},cdn:(r=(t=e.getContextAttribute("cdn"))!==null&&t!==void 0?t:h)!==null&&r!==void 0?r:D,library:(n=e.getAttribute("library"))!==null&&n!==void 0?n:u,component:(i=e.getAttribute("component"))!==null&&i!==void 0?i:p,version:(s=(o=e.getAttribute("version"))!==null&&o!==void 0?o:C)!==null&&s!==void 0?s:"responsive",revision:(l=(a=e.getAttribute("revision"))!==null&&a!==void 0?a:m)!==null&&l!==void 0?l:"published",hostname:e.getAttribute("hostname"),template:e.getAttribute("template"),instance:e.getAttribute("instance"),editable:e.getAttribute("editable")!=null,suspended:e.getAttribute("suspended")!=null,lastModified:e.getAttribute("last-modified"),withStylesheet:e.getAttribute("with-stylesheet")!="false"}}var dt=class extends b{setData(t){this.set({data:t})}getProps(){return Ce(this)}attributeChangedCallback(t,r,n){r!==n&&((t=="library"||t=="component"||t=="revision"||t=="version")&&(this.payload=void 0),this.needsRefresh=!0,super.attributeChangedCallback(t,r,n),t==="data"&&this.fetchData())}async fetchData(){this.readyData=void 0,this.whenDataReady=this.whenDataReady.restart();let t=await lt(this.props.data),r=this.alreadyRendered;await this.whenDataReady.resolve(t),r&&this.advance()}getEditor(){var t;return(t=document.querySelector("feaas-context"))===null||t===void 0?void 0:t.refs.editor}constructor(){super(),this.readyData={},this.whenDataReady=S(t=>this.readyData=t,t=>this.onError(t)),this.defaultProps={cdn:D,revision:"published",version:"responsive",withStylesheet:!0,editable:!1,suspended:!1},this.onLoad=t=>{this.payload=t,this.advance()},this.getAttribute("data")||this.whenDataReady.resolve({}),this.addEventListener("click",()=>{this.props.editable&&this.edit()})}edit(){let t=this.getEditor();if(t!=null&&t.setTarget(this))return t.open(),!0}getOriginal(){let t=this.getAttribute("data-path-scope");if(t){for(var r=this;(r=r.previousElementSibling)&&r.getAttribute("data-path-scope")==t;)var n=r;return n}}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null&&this.props.component!=null&&this.props.version!=null}async load(){if(this.getOriginal())return;let t=()=>{this.payload&&(r||this.readyData&&this.onLoad(this.payload))};if(this.props.withStylesheet)var r=Ut({...this.props,revision:"published"}).then(()=>{r=null,t()});return Promise.all([r,this.whenDataReady.then(()=>t()),q(this.props,n=>{this.payload=n,t()})]).then(()=>this.payload)}flush(){this.readyData&&super.flush()}update(){if(this.alreadyRendered=!0,Array.from(this.children).filter(t=>t.tagName!="BR").length>0&&!this.needsRefresh)R(this,this.readyData);else{if(this.needsRefresh=!0,this.getOriginal())return;j(this,this.payload,this.readyData)}}};dt.observedAttributes=["library","component","version","revision","hostname","cdn","template","data","instance","editable","with-stylesheet"];dt.register("feaas-component");function xe(e){return{opacity:e!=null&&e.getAttribute("opacity")?parseFloat(e==null?void 0:e.getAttribute("opacity")):1,hidden:(e==null?void 0:e.getAttribute("hidden"))!=null}}var ct=class extends b{constructor(){super(...arguments),this.defaultProps={hidden:!1}}getProps(){return xe(this)}attributeChangedCallback(t,r,n){if(r!==n)return t=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),n?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all")),super.attributeChangedCallback(t,r,n)}connectedCallback(){this.payload=null,super.connectedCallback(),this.attributeChangedCallback("hidden",this.getAttribute("hidden"),this.getAttribute("hidden")),this.stylesheet=document.createElement("style"),this.stylesheet.textContent=`
|
|
1
|
+
var He=Object.defineProperty;var Q=(e,t)=>{for(var r in t)He(e,r,{get:t[r],enumerable:!0})};var Jt={};Q(Jt,{Component:()=>ct,ComponentProps:()=>Re,Context:()=>z,ControlledPromise:()=>R,DEFAULT_CDN_URL:()=>O,DOM:()=>At,DataPath:()=>wt,DataScope:()=>gt,DataSettings:()=>x,Element:()=>A,FEAASComponent:()=>ct,FEAASComponentsProps:()=>Re,FEAASContext:()=>z,FEAASContextProps:()=>$e,FEAASEditor:()=>ht,FEAASEditorProps:()=>Me,FEAASElement:()=>A,FEAASLoader:()=>ut,FEAASLoaderProps:()=>_e,FEAASPicker:()=>ft,FEAASPickerProps:()=>Le,FEAASStylesheet:()=>kt,FEAASStylesheetProps:()=>ke,InvalidResponse:()=>Et,JSONPath:()=>p,Loader:()=>ut,MyComponent:()=>mt,Picker:()=>ft,Stylesheet:()=>kt,Thumbnail:()=>Dt,adjustNumbers:()=>he,autoloadScripts:()=>le,cleanCollectionBit:()=>ot,clearFetchCache:()=>ar,createStylesheet:()=>Ce,fetchAndRevalidate:()=>at,fetchAndRevalidateComponent:()=>K,fetchAndRevalidateStylesheet:()=>St,fetchBypassingCache:()=>Ct,fetchCache:()=>st,fetchComponent:()=>It,fetchData:()=>Ht,fetchToValidateCache:()=>lt,fetchWithCacheAwareness:()=>B,findStylesheet:()=>Ee,getComponentSource:()=>lr,getComponentURL:()=>dt,getFetchCache:()=>we,getFramePosition:()=>Te,getHumanizedLabel:()=>fe,getLastPathBit:()=>pe,getQualifier:()=>ue,getStylesheetSource:()=>dr,getStylesheetURL:()=>H,loadScript:()=>it,loadStylesheet:()=>Rt,loadStylesheetAllowStale:()=>Ut,normalizeCollectionScope:()=>bt,observeDOMElement:()=>ae,parseComponentSource:()=>W,parseLimit:()=>de,parseRange:()=>ce,parseStylesheetSource:()=>xt,queryObject:()=>vt,queryScopes:()=>nt,renderComponent:()=>Bt,renderComponentElement:()=>ur,renderComponentPromise:()=>xe,renderDOMContent:()=>U,renderDOMElement:()=>_,renderHTMLContent:()=>ye,renderStylesheet:()=>cr,renderStylesheetPromise:()=>Ae,serializeCH1RichText:()=>$,setDOMAttribute:()=>I});function R(e,t=r=>{}){var r;let n=()=>{var i,o;let s=new Promise((l,c)=>{i=d=>{e==null||e(d),l(d)},o=c});var a=Object.assign(s,{resolve:i,reject:o,restart:n,first:r});return r=a,a.catch(t),a};return n()}var ze=typeof HTMLElement=="undefined"?typeof windowJSDOM!="undefined"?windowJSDOM.HTMLElement:class{}:HTMLElement,A=class extends ze{getProps(t){return{}}constructor(){super(),this.defaultProps={},this.connected=!1,this.refs={},this.descendants=[],this.whenLoaded=R(t=>{this.payload=t}),this.whenRendered=R(()=>this.initialized=!0,()=>cancelAnimationFrame(this.nextRender)),this.addEventListener("feaasMount",this),this.addEventListener("feaasUnmount",this)}getRoot(){return this}attributeChangedCallback(t,r,n){this.set()}connectedCallback(){this.mount()}disconnectedCallback(){this.unmount()}mount(){try{let t=this.getParent();if(t&&!t.connected||this.connected)return;this.connected=!0,this.log("FEAAS: Mount",this.tagName,this),this.dispatchEventIndirectly(new Event("feaasMount",{bubbles:!0,composed:!0})),this.getElements().map(r=>{var n;return(n=r.mount)===null||n===void 0?void 0:n.call(r)}),this.set()}catch(t){this.onError(t)}}dispatchEventIndirectly(t){this.dispatchEvent(t);let r=this.getParent();r&&!r.contains(this)&&(Object.defineProperty(t,"target",{value:this,writable:!1}),Object.defineProperty(t,"composedPath",{value:()=>[this],writable:!1}),r.handleEvent(t))}isJSONAttribute(t){return!1}log(...t){typeof process!="undefined"&&process.env.TESTING||console.log(...t)}unmount(){this.connected&&(this.log("FEAAS: Unmount",this),this.dispatchEventIndirectly(new Event("feaasUnmount",{bubbles:!0,composed:!0})),this.connected=!1)}getParent(t=!0){for(var r=this;r=r.parentElement||(r.parentNode instanceof ShadowRoot?r.parentNode.host:null);)if(!t||r.tagName.startsWith("FEAAS-"))return r;if(this.tagName!="FEAAS-CONTEXT")return document.querySelector("feaas-context")}getElements(t=this.getRoot(),r=!0){return Array.from(t.querySelectorAll("*")).map(n=>[!r||n.tagName.startsWith("FEAAS-")?n:null,n.shadowRoot?this.getElements(n.shadowRoot,r):null]).flat().filter(Boolean)}handleEvent(t){let r=t.composedPath()[0];switch(t.type){case"feaasMount":r!=this&&this.nestedCallback(r);break;case"feaasUnmount":r!=this&&this.unnestedCallback(r);break}}unnestedCallback(t){let r=this.descendants.indexOf(t);r!=-1&&(this.log("FEAAS: Unnest",this,t),this.descendants.splice(r,1),this.refs[t.getComponentName()]=null,t.refs.parent==this&&(t.refs.parent=null),t.refs.top==this&&(t.refs.top=t.refs.parent))}nestedCallback(t){var r,n;if(this.descendants.indexOf(t)==-1&&(this.descendants.push(t),this.log("FEAAS: Nest",this,t),this.refs[t.getComponentName()]=t,t.refs.top=this,(r=t.refs).parent||(r.parent=this),t.render))for(var o=t.refs.parent;o;o=o.refs.parent)o.render&&((n=t.refs).parentReact||(n.parentReact=o),t.refs.topReact=o)}getComponentName(){return this.tagName.replace("FEAAS-","").toLowerCase()}isReadyToLoad(){return this.payload===void 0&&this.getAttribute("hidden")==null}onError(t,r="uncaught",n=!1){let i=new CustomEvent("feaasError",{bubbles:!0,composed:!0,detail:t});if(this.dispatchEventIndirectly(i),this.whenLoaded.reject(t),!i.defaultPrevented&&!n){this.whenRendered.reject(t);try{this.unmount()}catch(o){}return!0}return!1}shouldUpdateOnLoad(){return!0}async advance(){try{if(this.payload===void 0){if(!this.isReadyToLoad())return;this.payload=null,this.dispatchEventIndirectly(new Event("feaasLoad",{bubbles:!0,composed:!0}));let t=await this.load().catch(r=>{throw this.payload=void 0,r});if(this.whenLoaded.resolve(t),this.onLoad)return}else if(this.payload==null)return;this.flush(),this.whenRendered.resolve(this)}catch(t){this.onError(t)}}flush(){var t,r;if(!this.connected)return;let n=(r=(t=this.payload)===null||t===void 0?void 0:t.ReactDOM)===null||r===void 0?void 0:r.flushSync;n?n(()=>this.update()):this.update()}load(){return Promise.resolve(null)}update(){var t,r,n;if(this.payload==null||!this.render)return;let{React:i,ReactDOM:o,ReactDOMClient:s}=this.payload||{};if(!i)throw new Error(`${this.tagName}: React is not present in payload`);if(!o)throw new Error(`${this.tagName}: ReactDOM is not present in payload`);!this.refs.topReact&&!this.forceUpdateReact?s?(this.reactRoot||(this.reactRoot=s.createRoot(this.getReactRootElement())),this.reactRoot.render(this.getReactElement())):o.render(this.getReactElement(),this.getReactRootElement()):this.forceUpdateReact?(t=this.forceUpdateReact)===null||t===void 0||t.call(this):(n=(r=this.refs.topReact).forceUpdateReact)===null||n===void 0||n.call(r)}invokeReactRendering(){let{React:t,ReactDOM:r}=this.payload||{};if(!this.connected)return null;let n=this.descendants.filter(i=>i.refs.parentReact==this&&i.payload).map((i,o)=>this.getReactElement(i));return this.render({...this.props,children:n},this.payload)}getReactErrorBoundary(t=this,r=t.tagName){if(this.reactErrorBoundary)return this.reactErrorBoundary;let{React:n,ReactDOM:i}=t.payload||{};return this.reactErrorBoundary||(this.reactErrorBoundary=class extends n.Component{constructor(){super(...arguments),this.state={error:null}}static getDerivedStateFromError(s){return{error:s}}componentDidCatch(s,a){console.error(`FEAAS: ${t.tagName} Error:`,s,a),t.onError(s,"react")}render(){if(!this.state.error)return this.props.children}})}getReactElement(t=this,r){let{React:n,ReactDOM:i}=t.payload||{},o=this.getReactErrorBoundary(),s=this.getReactWrapper(t);return n.createElement(o,{key:t.tagName+"-"+t.getUID(),slot:t.getAttribute("slot")},n.createElement(s,null))}getReactWrapper(t=this,r=t.tagName){if(t.reactWrapper)return t.reactWrapper;let{React:n,ReactDOM:i}=t.payload||{};return t.reactWrapper=o=>{if(t.render){let[s,a]=n.useReducer(l=>l+1,0);return t.forceUpdateReact=a,i.createPortal(n.createElement(n.Fragment,null,t.invokeReactRendering()),t.getReactRootElement())}else return t.update()},Object.assign(t.reactWrapper,{key:t.tagName+"-"+t.getUID(),displayName:r}),t.reactWrapper}getUID(){return this.uid||(this.uid=String(Math.random()))}getShadowRoot(){return this.shadowRoot||this.attachShadow({mode:"open"}),this.shadowRoot}getReactRootElement(){return this.useShadowRoot?this.getShadowRoot():this.getRoot()}set(t){try{this.scheduleRender(),this.overrides={...this.overrides,...t},this.props={...this.getProps(),...this.overrides};for(var r in this.props){let i=this.isJSONAttribute(r),o=this.props[r],s=i?JSON.stringify(o):String(o),a=this.defaultProps[r],l=i?JSON.stringify(a):String(a),c=r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),d=this.getAttribute(c);try{var n=i?JSON.stringify(JSON.parse(d)):d}catch(h){var n=null}o==null||s===l?this.removeAttribute(c):(typeof o=="string"||typeof o=="number"||typeof o=="boolean"||i)&&n!=s&&this.setAttribute(c,s)}}catch(i){this.whenRendered.reject(i),this.onError(i,"set")}return this}import(t){return import( /*@vite-ignore*/ /* webpackIgnore: true */ t)}scheduleRender(){this.nextRender==null&&(this.whenRendered=this.whenRendered.restart()),cancelAnimationFrame(this.nextRender),this.nextRender=requestAnimationFrame(()=>{this.nextRender=null,this.advance().catch(t=>{})})}formatURL(t,r){return typeof t=="string"&&t.match(/^\/[^\/]/)?r+t:t}getContextAttribute(t,r=this){for(var n=this;n=n.parentElement||(n.parentNode instanceof ShadowRoot?n.parentNode.host:null);)if(n.getAttribute(t)!=null)return n.getAttribute(t);return this.getAttribute(t)}static register(t,r){r==null&&(r=typeof window!="undefined"?window:null),r&&!r.customElements.get(t)&&r.customElements.define(t,this)}};var q=class extends A{load(){return Promise.all([import( /*@vite-ignore*/ /* webpackIgnore: true */ "https://cdn.skypack.dev/react"),import( /*@vite-ignore*/ /* webpackIgnore: true */ "https://cdn.skypack.dev/react-dom")]).then(([t,r])=>({React:t,ReactDOM:r}))}render({},{React:t}){return t.createElement(t.Fragment,null)}},mt=class extends q{constructor(){super(...arguments),this.useShadowRoot=!0}getProps(){return{counter:parseFloat(this.getAttribute("counter"))}}render({counter:t},{React:r}){let[n,i]=r.useState(0);return r.useEffect(()=>{i(o=>o+1)},[t]),r.createElement(r.Fragment,null,r.createElement("p",null,"Rendering attribute: ",t),r.createElement("p",null,"Triggered updates: ",n))}};mt.observedAttributes=["counter"];var At={};Q(At,{renderDOMContent:()=>U,renderDOMElement:()=>_,renderHTMLContent:()=>ye,setDOMAttribute:()=>I});var gt={};Q(gt,{JSONPath:()=>p,queryObject:()=>vt,queryScopes:()=>nt,serializeCH1RichText:()=>$});function F(e){return F=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},F(e)}function ee(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function te(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function re(e,t,r){return t&&te(e.prototype,t),r&&te(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ve(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&rt(e,t)}function et(e){return et=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},et(e)}function rt(e,t){return rt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},rt(e,t)}function ne(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function tt(e,t,r){return ne()?tt=Reflect.construct.bind():tt=function(i,o,s){var a=[null];a.push.apply(a,o);var l=Function.bind.apply(i,a),c=new l;return s&&rt(c,s.prototype),c},tt.apply(null,arguments)}function Je(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function Tt(e){var t=typeof Map=="function"?new Map:void 0;return Tt=function(n){if(n===null||!Je(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(n))return t.get(n);t.set(n,i)}function i(){return tt(n,arguments,et(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),rt(i,n)},Tt(e)}function qe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ke(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return qe(e)}function Ge(e){var t=ne();return function(){var n=et(e),i;if(t){var o=et(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return Ke(this,i)}}function Xe(e){return Ye(e)||Ze(e)||ie(e)||Qe()}function Ye(e){if(Array.isArray(e))return Mt(e)}function Ze(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function ie(e,t){if(e){if(typeof e=="string")return Mt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Mt(e,t)}}function Mt(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Qe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tr(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=ie(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,a;return{s:function(){r=r.call(e)},n:function(){var l=r.next();return o=l.done,l},e:function(l){s=!0,a=l},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(s)throw a}}}}var S=Object.prototype.hasOwnProperty;function L(e,t){return e=e.slice(),e.push(t),e}function Lt(e,t){return t=t.slice(),t.unshift(e),t}var er=function(e){Ve(r,e);var t=Ge(r);function r(n){var i;return ee(this,r),i=t.call(this,'JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),i.avoidNew=!0,i.value=n,i.name="NewError",i}return re(r)}(Tt(Error));function p(e,t,r,n,i){if(!(this instanceof p))try{return new p(e,t,r,n,i)}catch(l){if(!l.avoidNew)throw l;return l.value}typeof e=="string"&&(i=n,n=r,r=t,t=e,e=null);var o=e&&F(e)==="object";if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=S.call(e,"wrap")?e.wrap:!0,this.sandbox=e.sandbox||{},this.preventEval=e.preventEval||!1,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||n||null,this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},e.autostart!==!1){var s={path:o?e.path:t};o?"json"in e&&(s.json=e.json):s.json=r;var a=this.evaluate(s);if(!a||F(a)!=="object")throw new er(a);return a}}p.prototype.evaluate=function(e,t,r,n){var i=this,o=this.parent,s=this.parentProperty,a=this.flatten,l=this.wrap;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=n||this.otherTypeCallback,t=t||this.json,e=e||this.path,e&&F(e)==="object"&&!Array.isArray(e)){if(!e.path&&e.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!S.call(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');var c=e;t=c.json,a=S.call(e,"flatten")?e.flatten:a,this.currResultType=S.call(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=S.call(e,"sandbox")?e.sandbox:this.currSandbox,l=S.call(e,"wrap")?e.wrap:l,this.currPreventEval=S.call(e,"preventEval")?e.preventEval:this.currPreventEval,r=S.call(e,"callback")?e.callback:r,this.currOtherTypeCallback=S.call(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,o=S.call(e,"parent")?e.parent:o,s=S.call(e,"parentProperty")?e.parentProperty:s,e=e.path}if(o=o||null,s=s||null,Array.isArray(e)&&(e=p.toPathString(e)),!(!e&&e!==""||!t)){var d=p.toPathArray(e);d[0]==="$"&&d.length>1&&d.shift(),this._hasParentSelector=null;var h=this._trace(d,t,["$"],o,s,r).filter(function(u){return u&&!u.isParentSelector});return h.length?!l&&h.length===1&&!h[0].hasArrExpr?this._getPreferredOutput(h[0]):h.reduce(function(u,f){var E=i._getPreferredOutput(f);return a&&Array.isArray(E)?u=u.concat(E):u.push(E),u},[]):l?[]:void 0}};p.prototype._getPreferredOutput=function(e){var t=this.currResultType;switch(t){case"all":{var r=Array.isArray(e.path)?e.path:p.toPathArray(e.path);return e.pointer=p.toPointer(r),e.path=typeof e.path=="string"?e.path:p.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return p.toPathString(e[t]);case"pointer":return p.toPointer(e.path);default:throw new TypeError("Unknown result type")}};p.prototype._handleCallback=function(e,t,r){if(t){var n=this._getPreferredOutput(e);e.path=typeof e.path=="string"?e.path:p.toPathString(e.path),t(n,r,e)}};p.prototype._trace=function(e,t,r,n,i,o,s,a){var l=this,c;if(!e.length)return c={path:r,value:t,parent:n,parentProperty:i,hasArrExpr:s},this._handleCallback(c,o,"value"),c;var d=e[0],h=e.slice(1),u=[];function f(b){Array.isArray(b)?b.forEach(function(g){u.push(g)}):u.push(b)}if((typeof d!="string"||a)&&t&&S.call(t,d))f(this._trace(h,t[d],L(r,d),t,d,o,s));else if(d==="*")this._walk(t,function(b){f(l._trace(h,t[b],L(r,b),t,b,o,!0,!0))});else if(d==="..")f(this._trace(h,t,r,n,i,o,s)),this._walk(t,function(b){F(t[b])==="object"&&f(l._trace(e.slice(),t[b],L(r,b),t,b,o,!0))});else{if(d==="^")return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:h,isParentSelector:!0};if(d==="~")return c={path:L(r,d),value:i,parent:n,parentProperty:null},this._handleCallback(c,o,"property"),c;if(d==="$")f(this._trace(h,t,r,null,null,o,s));else if(/^(\x2D?[0-9]*):(\x2D?[0-9]*):?([0-9]*)$/.test(d))f(this._slice(d,h,t,r,n,i,o));else if(d.indexOf("?(")===0){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");var E=d.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/,"$1");this._walk(t,function(b){l._eval(E,t[b],b,r,n,i)&&f(l._trace(h,t[b],L(r,b),t,b,o,!0))})}else if(d[0]==="("){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(Lt(this._eval(d,t,r[r.length-1],r.slice(0,-1),n,i),h),t,r,n,i,o,s))}else if(d[0]==="@"){var v=!1,m=d.slice(1,-2);switch(m){case"scalar":(!t||!["object","function"].includes(F(t)))&&(v=!0);break;case"boolean":case"string":case"undefined":case"function":F(t)===m&&(v=!0);break;case"integer":Number.isFinite(t)&&!(t%1)&&(v=!0);break;case"number":Number.isFinite(t)&&(v=!0);break;case"nonFinite":typeof t=="number"&&!Number.isFinite(t)&&(v=!0);break;case"object":t&&F(t)===m&&(v=!0);break;case"array":Array.isArray(t)&&(v=!0);break;case"other":v=this.currOtherTypeCallback(t,r,n,i);break;case"null":t===null&&(v=!0);break;default:throw new TypeError("Unknown value type "+m)}if(v)return c={path:r,value:t,parent:n,parentProperty:i},this._handleCallback(c,o,"value"),c}else if(d[0]==="`"&&t&&S.call(t,d.slice(1))){var w=d.slice(1);f(this._trace(h,t[w],L(r,w),t,w,o,s,!0))}else if(d.includes(",")){var N=d.split(","),T=tr(N),pt;try{for(T.s();!(pt=T.n()).done;){var Gt=pt.value;f(this._trace(Lt(Gt,h),t,r,n,i,o,!0))}}catch(b){T.e(b)}finally{T.f()}}else!a&&t&&S.call(t,d)&&f(this._trace(h,t[d],L(r,d),t,d,o,s,!0))}if(this._hasParentSelector)for(var P=0;P<u.length;P++){var J=u[P];if(J&&J.isParentSelector){var M=this._trace(J.expr,t,J.path,n,i,o,s);if(Array.isArray(M)){u[P]=M[0];for(var Ft=M.length,G=1;G<Ft;G++)P++,u.splice(P,0,M[G])}else u[P]=M}}return u};p.prototype._walk=function(e,t){if(Array.isArray(e))for(var r=e.length,n=0;n<r;n++)t(n);else e&&F(e)==="object"&&Object.keys(e).forEach(function(i){t(i)})};p.prototype._slice=function(e,t,r,n,i,o,s){if(Array.isArray(r)){var a=r.length,l=e.split(":"),c=l[2]&&Number.parseInt(l[2])||1,d=l[0]&&Number.parseInt(l[0])||0,h=l[1]&&Number.parseInt(l[1])||a;d=d<0?Math.max(0,d+a):Math.min(a,d),h=h<0?Math.max(0,h+a):Math.min(a,h);for(var u=[],f=d;f<h;f+=c){var E=this._trace(Lt(f,t),r,n,i,o,s,!0);E.forEach(function(v){u.push(v)})}return u}};p.prototype._eval=function(e,t,r,n,i,o){this.currSandbox._$_parentProperty=o,this.currSandbox._$_parent=i,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;var s=e.includes("@path");s&&(this.currSandbox._$_path=p.toPathString(n.concat([r])));var a="script:"+e;if(!p.cache[a]){var l=e.replace(/@parentProperty/g,"_$_parentProperty").replace(/@parent/g,"_$_parent").replace(/@property/g,"_$_property").replace(/@root/g,"_$_root").replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g,"_$_v$1");s&&(l=l.replace(/@path/g,"_$_path")),p.cache[a]=new this.vm.Script(l)}try{return p.cache[a].runInNewContext(this.currSandbox)}catch(c){throw new Error("jsonPath: "+c.message+": "+e)}};p.cache={};p.toPathString=function(e){for(var t=e,r=t.length,n="$",i=1;i<r;i++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(t[i])||(n+=/^[\*0-9]+$/.test(t[i])?"["+t[i]+"]":"['"+t[i]+"']");return n};p.toPointer=function(e){for(var t=e,r=t.length,n="",i=1;i<r;i++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(t[i])||(n+="/"+t[i].toString().replace(/~/g,"~0").replace(/\//g,"~1"));return n};p.toPathArray=function(e){var t=p.cache;if(t[e])return t[e].concat();var r=[],n=e.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g,";$&;").replace(/['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))['\]]/g,function(o,s){return"[#"+(r.push(s)-1)+"]"}).replace(/\[["']((?:(?!['\]])[\s\S])*)["']\]/g,function(o,s){return"['"+s.replace(/\./g,"%@%").replace(/~/g,"%%@@%%")+"']"}).replace(/~/g,";~;").replace(/["']?\.["']?(?!(?:(?!\[)[\s\S])*\])|\[["']?/g,";").replace(/%@%/g,".").replace(/%%@@%%/g,"~").replace(/(?:;)?(\^+)(?:;)?/g,function(o,s){return";"+s.split("").join(";")+";"}).replace(/;;;|;;/g,";..;").replace(/;$|'?\]|'$/g,""),i=n.split(";").map(function(o){var s=o.match(/#([0-9]+)/);return!s||!s[1]?o:r[s[1]]});return t[e]=i,t[e].concat()};var rr=function(t,r,n){for(var i=t.length,o=0;o<i;o++){var s=t[o];n(s)&&r.push(t.splice(o--,1)[0])}},nr=function(){function e(t){ee(this,e),this.code=t}return re(e,[{key:"runInNewContext",value:function(r){var n=this.code,i=Object.keys(r),o=[];rr(i,o,function(d){return typeof r[d]=="function"});var s=i.map(function(d,h){return r[d]}),a=o.reduce(function(d,h){var u=r[h].toString();return/function/.test(u)||(u="function "+u),"var "+h+"="+u+";"+d},"");n=a+n,!/(["'])use strict\1/.test(n)&&!i.includes("arguments")&&(n="var arguments = undefined;"+n),n=n.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/,"");var l=n.lastIndexOf(";"),c=l>-1?n.slice(0,l+1)+" return "+n.slice(l+1):" return "+n;return tt(Function,i.concat([c])).apply(void 0,Xe(s))}}]),e}();p.prototype.vm={Script:nr};function vt(e,t){return p({path:t,json:e})}function nt(e,t,r=!1,n=e){var i=t;let o=Object.keys(e).sort((a,l)=>l.length-a.length);for(let a of o)if(t.startsWith(a)){if(a==t){if(r)return e[a];continue}i=t.substring(a.length+1),n=e[a];break}var s=p({path:i,json:n});return Array.isArray(s)&&(s==null?void 0:s.length)==0&&(s=[i.replace(/^.*?\./,"_."),i.replace(/^.*?\./,""),i.replace(/^([^.]+).*?\.\$\./,"$1."),i.replace(/^.*?\.\$\./,"_."),i.replace(/^.*?\.\$\./,""),i.replace(/^[^.]+$/,"_")].filter((a,l,c)=>c.indexOf(a)===l).reduce((a,l)=>a.length>0?a:p({path:l,json:n}),[])),r&&Array.isArray(s)?s[0]:s}function $t(e,t={},r){return r?`<${r}${Object.entries(t).map(([n,i])=>i!=null&&` ${n}="${i}"`).filter(Boolean).join("")}>${$(e)}</${r}>`.replace(/^<([a-z0-9][^>]*)><\/[^>]+>$/,"<$1 />"):$(e)}function $(e){var t;if(Array.isArray(e))return e.map($).join(`
|
|
4
|
+
`).trim();if(typeof e=="string")return e;if(e==null)return"";switch(e.type){case"heading":let{level:r,...n}=e.attrs;return $t(e.content,n,"h"+r);case"text":return(e.marks||[]).reduce((i,o)=>$t(i,o.attrs,{link:"a",bold:"strong",italic:"em",strike:"s",underline:"u"}[o.type]),(t=e.text)===null||t===void 0?void 0:t.replace(/\s+/," "));default:return $t(e.content||e.text,e.attrs,{bulletList:"ul",orderedList:"ol",listItem:"li",horizontalRule:"hr",paragraph:"p",codeBlock:"code",blockquote:"blockquote"}[e.type])}}var j=class{constructor(t,r=1,n){this.ownerDocument={createElement(i){return new j(i)}},this.nodeName=t,this.nodeType=r,this.textContent=n,this.attributes=[],this.childNodes=[]}setAttribute(t,r){let n=this.attributes.find(i=>i.name===t);n?n.value=r:this.attributes.push({name:t,value:r})}getAttribute(t){let r=this.attributes.find(n=>n.name===t);return r?r.value:void 0}insertBefore(t,r){if(t.parentNode=this,r===null)this.childNodes.push(t);else{let n=this.childNodes.indexOf(r);n!==-1&&this.childNodes.splice(n,0,t)}}removeAttribute(t){let r=this.attributes.findIndex(n=>n.name===t);r!==-1&&this.attributes.splice(r,1)}appendChild(t){t.parentNode=this,this.childNodes.push(t)}get tagName(){var t;return(t=this.nodeName)===null||t===void 0?void 0:t.toUpperCase()}get localName(){var t;return(t=this.nodeName)===null||t===void 0?void 0:t.toLowerCase()}get innerHTML(){return jt(this.childNodes)}set innerHTML(t){this.childNodes=yt(String(t!=null?t:""))}get outerHTML(){return jt([this])}get children(){return this.childNodes.filter(t=>t.nodeType==1)}closest(t){let r=this;for(;r;){if(oe(t,r))return r;r=r.parentNode}return null}querySelectorAll(t){let r=t.split(/\s*,\s*/),n=[],i=o=>{for(let s of r)if(oe(s,o)){n.push(o);break}for(let s of o.childNodes)i(s)};for(let o of this.childNodes)i(o);return n}querySelector(t){return this.querySelectorAll(t)[0]}findSibling(t,r){if(!this.parentNode)return null;let n=this.parentNode.childNodes,i=n.indexOf(this);if(i===-1)return null;for(let o=i+t;o>=0&&o<n.length;o+=t){let s=n[o];if(!r||s.nodeType===1)return s}return null}removeChild(t){let r=this.childNodes.indexOf(t);if(r!==-1)return this.childNodes.splice(r,1),t.parentNode=void 0,t}get previousSibling(){return this.findSibling(-1)}get nextSibling(){return this.findSibling(1)}get previousElementSibling(){return this.findSibling(-1,!0)}get nextElementSibling(){return this.findSibling(1,!0)}cloneNode(t=!1){let r=new j(this.nodeName,this.nodeType);if(r.attributes=JSON.parse(JSON.stringify(this.attributes)),this.textContent&&(r.textContent=this.textContent),t)for(let n of this.childNodes){let i=n.cloneNode(!0);r.appendChild(i)}return r}get parentElement(){var t;return((t=this.parentNode)===null||t===void 0?void 0:t.nodeType)==1?this.parentNode:null}};function oe(e,t){let r=e.match(/([.#]?[\w-]+|\[([\w-]+)(="([^"]*)")?\])/g);if(!r)return!1;for(let n of r)if(n.startsWith("#")){if(t.getAttribute("id")!==n.slice(1))return!1}else if(n.startsWith(".")){if(!(t.getAttribute("class")||"").split(" ").includes(n.slice(1)))return!1}else if(n.startsWith("[")){let i=n.match(/^\[([\w-]+)(="([^"]*)")?\]$/);if(i){let o=i[1],s=i[3],a=t.getAttribute(o);if(typeof s=="undefined"){if(a===void 0)return!1}else if(a!==s)return!1}else return!1}else if(t.nodeName!==n)return!1;return!0}function yt(e){var t;let r=[],n=[];for(;e;){let i=e.match(/^<([\w-]+)(\s[^>]*)?>/),o=e.match(/^<\/([\w-]+)>/);if(i){let s=i[1],l=((t=(i[2]||"").match(/([\w-]+)(="([^"]*)")?/g))===null||t===void 0?void 0:t.map(d=>{let[h,u,,f]=d.match(/([\w-]+)(="([^"]*)")?/);return{name:u,value:or(f||"")}}))||[],c=new j(s,1);if(c.attributes=l,n.length>0){let d=n[n.length-1];d.childNodes.push(c),c.parentNode=d}else r.push(c);n.push(c),e=e.slice(i[0].length)}else if(o)n.pop(),e=e.slice(o[0].length);else{let s=e.indexOf("<"),a=e.slice(0,s!==-1?s:void 0),l=new j("#text",3);if(l.textContent=a,n.length>0){let c=n[n.length-1];c.childNodes.push(l),l.parentNode=c}else r.push(l);e=e.slice(a.length)}}return r}function ir(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function or(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'")}function jt(e){return e.map(t=>{if(t.nodeType===3)return t.textContent||"";let{nodeName:r,attributes:n}=t,i=n.map(({name:s,value:a})=>` ${s}="${ir(String(a))}"`).join(""),o=jt(t.childNodes);return["img","input","br"].includes(r)?`<${r}${i} />`:`<${r}${i}>${o}</${r}>`}).join("")}function se(e,t,r){var n;let i=((n=r==null?void 0:r.processTemplate)===null||n===void 0?void 0:n.call(r,null,e,t))||e,o=yt(i);return _(o[0],t,r).outerHTML}function ae(e){let t=new e.ownerDocument.defaultView.MutationObserver(r=>{r.forEach(n=>{let i=n.target,o=i.getAttribute("data-embed-src");o&&it(i,o),n.addedNodes&&n.addedNodes.forEach(s=>{s.nodeType==1&&le(s,!1)})})});return t.observe(e,{attributes:!0,subtree:!0,childList:!0}),t}function le(e,t=!0){let r=e.querySelectorAll("[data-embed-src]");for(var n=0;n<r.length;n++){let i=r[n];it(i,i.getAttribute("data-embed-src"))}if(t)return ae(e)}function it(e,t){for(var r=e;r;r=r.parentElement)if(!r.parentElement){let i=r.querySelectorAll("script");for(var n=0;n<i.length;n++)if(i[n].getAttribute("src")==t)return!0;r.tagName=="HTML"&&(r=r.querySelector("head")||r);let o=r.ownerDocument.createElement("script");o.setAttribute("type","module"),o.setAttribute("src",t),r.appendChild(o);break}}var wt={};Q(wt,{adjustNumbers:()=>he,cleanCollectionBit:()=>ot,getHumanizedLabel:()=>fe,getLastPathBit:()=>pe,getQualifier:()=>ue,normalizeCollectionScope:()=>bt,parseLimit:()=>de,parseRange:()=>ce});var de=e=>{var t;let r=parseInt((t=e==null?void 0:e.match(/\[0:(\d+)\]/))===null||t===void 0?void 0:t[1],10);return!isNaN(r)&&r>0?String(r):null},ce=e=>{var t;let r=(t=e==null?void 0:e.match(/\[([^\]]+)\]/))===null||t===void 0?void 0:t[1].split(/\s*,\s*/g).filter(Boolean).map(n=>{if(n.match(/^-?\d+$/))return n;let i=n.match(/^(\d+):(\d+)$/);return i&&parseInt(i[1],10)<parseInt(i[2],10)?i[1]+"-"+i[2]:null});return r!=null&&r.every(Boolean)?r.join(","):null},ue=e=>{var t;return(t=e==null?void 0:e.match(/(\.\*|\[[^\]]*\])$/))===null||t===void 0?void 0:t[0]};function ot(e){return e.replace(/(\.?\[[^\]\[]*\]|\.\*)$/g,"")}function bt(e){return ot(e)+".*"}function he(e,t){return e==null?void 0:e.replace(/(.|^)(\d+)/g,(r,n,i)=>n+(n==":"?i:String(parseInt(i)+t)))}function fe(e,t=2){var r=ot(e).split(/]\.|\.\*\./g).pop().split(/\./g).slice(-3);return r=r.filter(n=>isNaN(parseInt(n))),r.map(n=>n.charAt(0).toUpperCase()+n.slice(1)).slice(-t).join(" ")}function pe(e){return ot(e).split(".").pop()}function ve(e){let t=e.getAttribute("data-path-scope");for(var r=0,n=e;n=n.previousElementSibling;)n.getAttribute("data-path-scope")==t&&r++;return r}function sr(e,t,r){let n=e.getAttribute("data-path-scope");if(n==null)return;var i=ve(e);if(i!=0)return;let o=e.parentNode;if(o!=null){t==0?e.setAttribute("hidden","hidden"):e.getAttribute("hidden")!=null&&e.removeAttribute("hidden");for(var s=i+1,a=e,l=e;l=l.nextElementSibling;)l.getAttribute("data-path-scope")==n&&(s++,a=l);for(var c=s;c<t;c++)o.insertBefore(a.cloneNode(!0),a.nextElementSibling);for(var c=Math.max(1,t);c<s;c++)a=a.previousElementSibling,o.removeChild(a.nextElementSibling)}}function I(e,t,r,n){var i,o;if(e){var s=e;(r==null?void 0:r.type)=="doc"&&Array.isArray(r.content)&&(r=$(r)),n!=null&&n.processValue&&(r=n==null?void 0:n.processValue(e,t,r));var a=t.replace("data-path-","");if(t=="data-path-src"){let u=Array.from(e.children).find(f=>f.localName=="picture")||e;s=e.localName=="img"?e:u.querySelector("img, video")}else if(t=="data-path-href")s=e.querySelector("a")||e.closest("a");else if(t=="data-path-alt")s=(Array.from(e.children).find(f=>f.localName=="picture")||e).querySelector("img, picture");else if(t=="data-path-hidden")r=r?null:!0;else if(t=="data-path"||t=="data-embed-html"||t=="html")a="innerHTML";else if(t=="data-embed-src")it(e,r);else if(t=="data-path-attributes"){let u=((i=e.getAttribute("data-attributes-keys"))===null||i===void 0?void 0:i.split(",").filter(Boolean))||[];if(!Array.isArray(r))for(var l in r){var c=r[l];I(e,l,typeof c=="object"&&c?JSON.stringify(c):c,n)}for(var d=0;d<u.length;d++)(r==null||!(u[d]in r))&&I(e,u[d],null,n);I(e,"data-attributes-keys",Object.keys(r||{}).join(","));return}if(typeof r=="boolean"&&(r=r?"":null),!!s){var h=String((o=e.getAttribute("data-path-placeholder")||s[a])!==null&&o!==void 0?o:s.getAttribute(a));r!=null?a=="innerHTML"?s.innerHTML!=r&&(s.innerHTML=r):s.getAttribute(a)!=r&&s.setAttribute(a,r):a=="innerHTML"?s.innerHTML=h:s.removeAttribute(a)}}}var me=["data-attributes-keys","data-path-attributes","data-path-scope"];function _(e,t,r,n){var i,o,s;let a=e;if(n||(t=((i=r==null?void 0:r.processData)===null||i===void 0?void 0:i.call(r,a,t))||t),a.nodeType==1){let d=a.getAttribute("data-path-scope");if(d){let u=ve(a),f=nt(t,d,!1)||[];u==0&&sr(a,((o=r==null?void 0:r.shouldRepeat)===null||o===void 0?void 0:o.call(r,a,f))===!1?1:f.length,r),t={...t,[bt(d)]:f[u]}}let h=Array.prototype.slice.call(a.attributes).sort((u,f)=>me.indexOf(u.name)-me.indexOf(f.name));for(var l=0;l<h.length;l++){let{name:u,value:f}=h[l];u.startsWith("data-path")&&u!="data-path-scope"&&I(a,u,nt(t,f,!0),r),u=="data-embed-src"&&I(a,u,a.getAttribute(u),r)}}for(var l=0,c;c=a.childNodes[l++];)ge(c)&&_(c,t,r,!0);return n||(s=r==null?void 0:r.onRender)===null||s===void 0||s.call(r,a,t),a}function ge(e){return e.nodeType==1}function U(e,t,r,n){var i;let o=((i=n==null?void 0:n.processTemplate)===null||i===void 0?void 0:i.call(n,e,t,r))||t;if(e.innerHTML=o,e.classList.add("-feaas"),(e.closest(".component.feaas")||e).className.includes("-theme--"))for(var a=0,l;l=e.childNodes[a++];)ge(l)&&(l.className=l.className.replace(/(\s|^)-theme--[^\s]+\s*/g,"$1"));return _(e,r,n)}function ye(e,t,r,n=!1){var i;let o=((i=r==null?void 0:r.processTemplate)===null||i===void 0?void 0:i.call(r,null,e,t))||e;if(typeof document=="undefined"||n){let s=yt(o);return _(s[0],t,r).outerHTML}else{let s=document.createElement("div");return s.innerHTML=o,_(s,t,r),s.innerHTML}}var be=["initial","check","updated"],st={};function ar(){st={}}async function at(e,t,r,n,i=st){return B({url:e,options:t,validator:r,callback:n,cache:i}).then(lt).then(o=>o.response)}function we(e,t=!1){let r=String(e).replace("?head","");var n=st[r];return!n&&!t&&(n=st[r]={phase:null,initial:R(),check:R(),updated:R(),final:R()}),n}var Et=class extends Error{};async function B({url:e,options:t,validator:r,callback:n,cache:i},o="initial"){let s=new Date;if(i!=null){var a=we(e);if(be.indexOf(a.phase)>=be.indexOf(o))var l=a[o];else a.phase=o}let c=await(l||fetch(e,t));if(!l&&a&&(c.ok?a[o].resolve(c):a[o].reject(new Error("Fetch failed"))),!c.ok)throw new Error("Fetch failed");let d=new Date(c.headers.get("date"))<s||l&&o=="initial"&&(a.phase=="updated"||a.phase=="check");if((r==null?void 0:r(c,d))===!1)throw new Et("Response is not valid");return await(n==null?void 0:n(c,o,d)),{url:e,options:t,isCached:d,response:c,validator:r,callback:n,cache:i}}async function lt(e){let{url:t,isCached:r,options:n,validator:i,response:o,cache:s}=e;if(r){let{response:a}=await B({url:t+"?head",options:{...n,method:"HEAD",cache:"no-cache"},validator:i,cache:s},"check");if(a.headers.get("last-modified")!=o.headers.get("last-modified"))return Ct(e)}return e}async function Ct(e){return B({...e,options:{...e.options,cache:"reload"}},"updated")}var O="https://feaas.blob.core.windows.net";function W(e){let t=e.match(/^(?:(.*?)\/components)?\/?([^\/]+)\/([^\/]+)(?:\/([^\/]+)(?:\/(published|staged|saved|\d+)(?:\.html?)?)?)?$/);if(t){var[,r,n,i,o,s]=t;return{cdn:r,library:n,component:i,version:o,revision:s}}}function lr(e){if(!e||!e.library||!e.component)throw new Error("Component requires `library` and `component` properties");return`${e.cdn&&e.cdn!=O?`${e.cdn}/components`:""}/${e.library}/${e.component}/${!e.version||e.version=="responsive"&&(!e.revision||e.revision=="published")?"":e.version}/${!e.revision||e.revision=="published"?"":e.revision}`.replace(/(^\/|\/$|\/\/)(?!.+\/components\/)/g,"")}function dr(e){return`${e.cdn&&e.cdn!=O?`${e.cdn}/styles/`:""}${e.library}/${!e.revision||e.revision=="published"?"":e.revision}`.replace(/\/$|\/\/(?!.+\/styles\/)/g,"")}function xt(e){let t=e.match(/^(?:(.*?)\/styles\/)?([^\/]+)(?:\/(published|staged|saved|\d+)(?:.css)?)?$/);if(t){var[,r,n,i]=t;return{cdn:r,library:n,revision:i}}else{let o=W(e);if(o){var{cdn:r,library:n,revision:i}=o;return i!=null&&i.match(/\d/)&&(i=void 0),{cdn:r,library:n,revision:i}}}}function dt(e){return typeof e=="string"&&(e={src:e}),"src"in e&&(e={...W(e.src)}),`${e.cdn||e.hostname||O}/components/${e.library}/${e.component}/${e.version}/${e.revision||"published"}.html`}function H(e){return typeof e=="string"&&(e={src:e}),"src"in e&&(e={...xt(e.src)}),`${e.cdn||e.hostname||O}/styles/${e.library}/${e.revision||"published"}.css`}async function K(e,t,r=!1){let n=a=>a.headers.get("x-ms-meta-versionDeletedAt")==null,i=a=>a.clone().text().then(t),o=await Promise.all([e.instance&&B({options:{headers:{Accept:"text/html"},credentials:"omit"},url:dt({...e,version:e.instance}),validator:n}).catch(a=>a),B({url:dt(e),validator:n}).catch(a=>a)]),s=o.find(a=>a&&"isCached"in a&&a);if(!s||s instanceof Error)throw o.find(l=>l&&l instanceof Error)||new Error("Can not fetch component");return o[0]==s&&console.log("Using fork!",o),await i(s.response),r?s:lt({...s,callback:i}).catch(a=>{if(o[0]==s&&(Ct({...s,callback:null,validator:null}),console.log("Fork was deleted"),!(o[1]instanceof Error)))return i(o[1].response),lt({...o[1],callback:i});throw a})}async function It(e){typeof e=="string"&&(e={src:e});var t;let{response:r}=await K(e,n=>{t=n},!0);return{...e,template:t,lastModified:r.headers.get("last-modified")}}async function St(e,t){return typeof e=="string"&&(e={src:e}),at(H(e),{headers:{Accept:"text/css"},credentials:"omit"},r=>r.headers.get("x-ms-meta-deletedAt")==null,(r,n)=>r.clone().text().then(i=>t(i,n)))}function cr(e,t){return Ae(e,t||(t=document.createElement("style"))),t}function Ae(e,t){return t||(t=document.createElement("style")),St(e,(r,n)=>{t.textContent=r}).then(()=>t)}function Rt(e,t){var r=Ee(e);if(!r)var n=Ce(e);return St(e,(i,o)=>{n&&(n.textContent=i),t==null||t(i,o)}).then(()=>r||n)}function Ut(e){return new Promise((t,r)=>{Rt(e,t).catch(r)})}function Ee(e){return document.head.querySelector(`style[data-href="${H(e)}"]`)}function Ce(e){let t=H(e),r=document.createElement("style");return r.setAttribute("data-href",t),document.head.appendChild(r),r}function ur(e,t){let r=document.createElement("div");r.innerHTML=e;let n=document.createDocumentFragment();for(;r.firstChild;)n.appendChild(r.firstChild);return _(n,t),r}function Bt(e,t){return xe(e,t||(t=document.createElement("div"))),t}async function xe(e,t){return t||(t=document.createElement("div")),t.childNodes.length?_(t,e.data,e):"template"in e?U(t,e.template,e.data,e):K(e,r=>U(t,r,e.data,e)).then(()=>t)}function hr(e){let{params:t,method:r,headers:n,body:i,url:o}=x(e);var s={url:o},a={...n};return n["Content-Type"]==="application/json"&&delete a["Content-Type"],n.Accept==="application/json"&&delete a.Accept,Object.keys(a).length>0&&(s.headers=a),r!=="GET"&&(s.method=r),r==="GET"||r==="HEAD"||Object.keys(i).length===0||(s.body=i),Object.keys(t).length>0&&(s={...s,params:t}),s}var _t=e=>{if(typeof e.url!="string")return!1;for(var t in e)if(!(t=="body"||t=="params"||t=="headers"||t=="url"||t==="method"||t=="jsonpath"&&typeof e[t]=="string"))return!1;return!0};function Se(e){let{url:t,headers:r,params:n,method:i,body:o}=x(e),s,a=r["Content-Type"];i!="GET"&&i!="HEAD"&&(a==="application/json"&&(s=JSON.stringify(o)),a==="multipart/form-data"&&(s=Object.keys(o).reduce((c,d)=>(c.append(d,o[d]),c),new FormData)),a==="application/x-www-form-urlencoded"&&(s=new URLSearchParams(o)));let l=Object.keys(n).length?`?${new URLSearchParams(n)}`:"";return[`${t}${l}`,{headers:r,body:s,method:i}]}function x(e){let t={};for(let r in(e==null?void 0:e.headers)||{})if(e.headers.hasOwnProperty(r)){let n=r.replace(/^[a-z]|\-[a-z]/g,i=>i.toUpperCase());t[n]=e.headers[r]}return t.Accept||(t.Accept="application/json"),{params:(e==null?void 0:e.params)||{},headers:t,jsonpath:String((e==null?void 0:e.jsonpath)||"$"),method:((e==null?void 0:e.method)||"GET").toUpperCase(),body:(e==null?void 0:e.body)||{},url:String((e==null?void 0:e.url)||"")}}var Wt=async e=>{try{let[t,r]=Se(e),i=await(await x.fetchImplementation(t,{...r,method:r.method.toLowerCase()})).json();return e.jsonpath&&e.jsonpath!="$"?vt(i,e.jsonpath):i}catch(t){return{}}};async function Ht(e){if(!e)return e;if(_t(e))return Wt(e);let t=Object.keys(e),r=await Promise.all(t.map(n=>_t(e[n])?Wt(e[n]):null).filter(Boolean));return t.reduce((n,i)=>({...n,[i]:_t(e[i])?r.shift():e[i]}),{})}x.clean=hr;x.toFetchArguments=Se;x.fetchOne=Wt;x.fetch=Ht;x.isDataSettings=_t;x.fetchImplementation=(...e)=>fetch(...e);function Re(e){var t,r,n,i,o,s,a,l;let c,d=e.getAttribute("src");if(d){let w=W(d);if(!w)throw new Error(`Could not parse FEAAS Component source: ${d}`);var{cdn:h,library:u,component:f,version:E,revision:v}=w}let m=e.getAttribute("data");if(m!=null&&m!="")try{c=typeof m=="string"?JSON.parse(m):{}}catch(w){console.error(w)}return{data:c||{},cdn:(r=(t=e.getContextAttribute("cdn"))!==null&&t!==void 0?t:h)!==null&&r!==void 0?r:O,library:(n=e.getAttribute("library"))!==null&&n!==void 0?n:u,component:(i=e.getAttribute("component"))!==null&&i!==void 0?i:f,version:(s=(o=e.getAttribute("version"))!==null&&o!==void 0?o:E)!==null&&s!==void 0?s:"responsive",revision:(l=(a=e.getAttribute("revision"))!==null&&a!==void 0?a:v)!==null&&l!==void 0?l:"published",hostname:e.getAttribute("hostname"),template:e.getAttribute("template"),instance:e.getAttribute("instance"),editable:e.getAttribute("editable")!=null,suspended:e.getAttribute("suspended")!=null,lastModified:e.getAttribute("last-modified"),withStylesheet:e.getAttribute("with-stylesheet")!="false"}}var ct=class extends A{setData(t){this.set({data:t})}getProps(){return Re(this)}isJSONAttribute(t){return t=="data"}attributeChangedCallback(t,r,n){r!==n&&((t=="library"||t=="component"||t=="revision"||t=="version")&&(this.payload=void 0),this.needsRefresh=!0,super.attributeChangedCallback(t,r,n),t==="data"&&this.fetchData())}async fetchData(){this.readyData=void 0,this.whenDataReady=this.whenDataReady.restart();let t=await x.fetch(this.props.data),r=this.alreadyRendered;await this.whenDataReady.resolve(t),r&&this.advance()}getEditor(){var t;return(t=document.querySelector("feaas-context"))===null||t===void 0?void 0:t.refs.editor}constructor(){super(),this.readyData={},this.whenDataReady=R(t=>this.readyData=t,t=>this.onError(t)),this.defaultProps={cdn:O,revision:"published",version:"responsive",withStylesheet:!0,editable:!1,suspended:!1,data:{}},this.onLoad=t=>{this.payload=t,this.advance()},this.getAttribute("data")||this.whenDataReady.resolve({}),this.addEventListener("click",()=>{this.props.editable&&this.edit()})}edit(){let t=this.getEditor();if(t!=null&&t.setTarget(this))return t.open(),!0}getOriginal(){let t=this.getAttribute("data-path-scope");if(t){for(var r=this;(r=r.previousElementSibling)&&r.getAttribute("data-path-scope")==t;)var n=r;return n}}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null&&this.props.component!=null&&this.props.version!=null}async load(){if(this.getOriginal())return;let t=()=>{this.payload&&(r||this.readyData&&this.onLoad(this.payload))};if(this.props.withStylesheet)var r=Ut({...this.props,revision:"published"}).then(()=>{r=null,t()});return Promise.all([r,this.whenDataReady.then(()=>t()),K(this.props,n=>{this.payload=n,t()})]).then(()=>this.payload)}flush(){this.readyData&&super.flush()}update(){if(this.alreadyRendered=!0,Array.from(this.children).filter(t=>t.tagName!="BR").length>0&&!this.needsRefresh)_(this,this.readyData);else{if(this.needsRefresh=!0,this.getOriginal())return;U(this,this.payload,this.readyData)}}};ct.observedAttributes=["library","component","version","revision","hostname","cdn","template","data","instance","editable","with-stylesheet"];ct.register("feaas-component");function _e(e){return{opacity:e!=null&&e.getAttribute("opacity")?parseFloat(e==null?void 0:e.getAttribute("opacity")):1,hidden:(e==null?void 0:e.getAttribute("hidden"))!=null}}var ut=class extends A{constructor(){super(...arguments),this.defaultProps={hidden:!1}}getProps(){return _e(this)}attributeChangedCallback(t,r,n){if(r!==n)return t=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),n?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all")),super.attributeChangedCallback(t,r,n)}connectedCallback(){this.payload=null,super.connectedCallback(),this.attributeChangedCallback("hidden",this.getAttribute("hidden"),this.getAttribute("hidden")),this.stylesheet=document.createElement("style"),this.stylesheet.textContent=`
|
|
5
5
|
#loader {
|
|
6
6
|
position: absolute;
|
|
7
7
|
top: 0;
|
|
@@ -65,10 +65,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
65
65
|
style="animation: 1.5s linear 0s infinite normal none running loader-circular-track"
|
|
66
66
|
></circle>
|
|
67
67
|
</svg>
|
|
68
|
-
</div>`,this.getRoot().appendChild(this.stylesheet),this.getRoot().appendChild(this.loader)}update(){this.loader.style.opacity=String(this.props.opacity)}};
|
|
68
|
+
</div>`,this.getRoot().appendChild(this.stylesheet),this.getRoot().appendChild(this.loader)}update(){this.loader.style.opacity=String(this.props.opacity)}};ut.observedAttributes=["hidden","opacity"];ut.register("feaas-loader");function ke(e){var t,r,n,i;let o=e.getAttribute("src");if(o)var{cdn:s,library:a,revision:l}=xt(o);return{library:e==null?void 0:e.getContextAttribute("library"),revision:(r=(t=e==null?void 0:e.getAttribute("revision"))!==null&&t!==void 0?t:l)!==null&&r!==void 0?r:"published",cdn:(i=(n=e==null?void 0:e.getContextAttribute("cdn"))!==null&&n!==void 0?n:e==null?void 0:e.getContextAttribute("hostname"))!==null&&i!==void 0?i:O}}var kt=class extends A{constructor(){super(...arguments),this.onLoad=t=>{this.payload=t,this.advance()}}getProps(){return ke(this)}isReadyToLoad(){return this.props.library!=null&&this.props.revision!=null&&this.props.cdn!=null}load(){return Rt(this.props,this.onLoad)}};kt.register("feaas-stylesheet");var Dt={};Q(Dt,{convertBase64toBlob:()=>De,generate:()=>Ne,get:()=>fr,getVersionForThumbnail:()=>Fe,load:()=>Oe,responseToImage:()=>zt,upload:()=>Pe});var De=e=>fetch(e).then(t=>t.blob()),zt=e=>e.blob().then(t=>new Promise((r,n)=>{let i=new Image;i.onerror=n,i.onload=()=>{r(i)},i.src=URL.createObjectURL(t)}));async function Fe(e){return e.versions.length||await e.versions.fetch(),e.getVersionForWidth(800)}async function fr(e,t,r){try{if(!e.isNew)return await Oe(e,t,r)}catch(i){e.sdk.log(`FEAAS: Thumbnail ${e.id}, version: ${(t==null?void 0:t.id)||"responsive"}, status: generating ${status}, reason: ${i}`)}let n=await Ne(e,t);return r==null||r(n,!1),n&&!e.isNew&&De(n.src).then(i=>Pe(e,t,i)),n}async function Oe(e,t,r){let n=t?t.getThumbnailURL():e.getThumbnailURL(),i=e.library.stylesheet,o=new Date(Math.max(Number(e.modifiedAt),Number(i.modifiedAt)));e.sdk.log(`FEAAS: Thumbnail ${e.id}/${(t==null?void 0:t.id)||"responsive"}, loading`);var s;return await at(n,{},(a,l)=>{let c=Math.abs(Number(new Date(a.headers.get("x-ms-meta-componentRenderedAt")))-Number(o))<2e3;return l&&!c&&zt(a).then(d=>{s=d,r(d,l)}),c},(a,l,c)=>{e.sdk.log(`FEAAS: Thumbnail ${e.id}/${(t==null?void 0:t.id)||"responsive"}, status: ${l}`),zt(a).then(d=>{s=d,r(d,c)})},null),s}async function Ne(e,t){let r=t||(e.isNew?null:await Fe(e));if(!r||r.isViewEmpty())return null;let{stylesheet:n,datasources:i}=e.library;return await pr(r.classList,n.getBreakpointForWidth(800,r.getBreakpoints()),r.view,i.reduce((s,a)=>Object.assign(s,{[a.id]:a.sample}),{}),n.css,e.sdk)}function pr(e,t,r,n,i,o){let s=document.createElement("iframe");return s.style.position="absolute",s.style.top="-2000px",s.style.left="-2000px",s.style.width=t.props.minWidth+"px",s.style.height="720px",s.style.zIndex="100011",document.body.appendChild(s),new Promise((a,l)=>{let c=document.createElement("script");c.onerror=l,c.src=o.frontend+"/assets/html2canvas.js",c.onload=()=>{var f;(((f=s.contentWindow.document.fonts)===null||f===void 0?void 0:f.ready)||Promise.resolve()).then(function(){return s.contentWindow.html2canvas(u,{scale:Math.max(1.1,1e3/Math.min(1401,Math.max(320,t.props.minWidth))),width:Math.min(1401,Math.max(320,t.props.minWidth)),height:Math.max(1,Math.min(2e3,u.offsetHeight)),windowWidth:t.props.minWidth+"px",windowHeight:1e3,proxy:o.backend+"/proxy/media",backgroundColor:"#ffffff"}).then(E=>{let v=E.toDataURL("image/jpeg",.6);s.parentElement.removeChild(s);let m=new Image;m.onload=()=>{a(m)},m.onerror=l,m.src=v})})},s.contentWindow.document.head.appendChild(c);let d=s.contentWindow.document.createElement("style");d.textContent=`
|
|
69
69
|
${i}
|
|
70
70
|
body, html { padding: 0; margin: 0; overflow: hidden }
|
|
71
71
|
`;let h=s.contentWindow.document.createElement("style");h.textContent=`
|
|
72
72
|
body, html { padding: 0; margin: 0; overflow: hidden }
|
|
73
|
-
`,s.contentWindow.document.head.appendChild(d),s.contentWindow.document.head.appendChild(h);let u=Bt({template:r,data:n});u.classList.add(...e,"-feaas--preview","-emulate--"+t.details.slug),s.contentWindow.document.body.appendChild(u)})}async function Pe(e,t,r){let n=t?t.getThumbnailURL():e.getThumbnailURL(),i=new Date(Math.max(Number(e.modifiedAt),Number(e.library.stylesheet.modifiedAt)));try{await e.sdk.uploadBlob("thumbnails",n.split(/\/thumbnails\//)[1],r,{headers:{"x-ms-blob-content-type":"image/jpg","x-ms-blob-cache-control":"public,max-age=31536000,immutable","x-ms-meta-versionId":t?t.id:null,"x-ms-meta-versionRevision":t?t.revision.toString():null,"x-ms-meta-componentId":e.id,"x-ms-meta-componentRenderedAt":i.toUTCString(),"x-ms-meta-componentModifiedAt":e.modifiedAt.toUTCString(),"x-ms-meta-componentCreatedAt":e.createdAt.toUTCString(),"x-ms-meta-modifiedAt":e.modifiedAt.toUTCString()}}),fetch(n,{cache:"no-cache"}).then(()=>{e.sdk.log("FEAAS: Thumbnail uploaded",n)})}catch(o){e.sdk.log("FEAAS: Thumbnail failed to upload",n,o)}return n}var Ht;typeof window!="undefined"&&(window.FEAASReactElement=J,(Ht=window.FEAASLoading)!==null&&Ht!==void 0||(window.FEAASLoading=Promise.resolve()));function Oe(e){let t=[];if(e){let r=e.ownerDocument.defaultView,n,i;for(;r!==window.top;){n=r.parent;for(let o=0;o<n.frames.length;o++)if(n.frames[o]===r){for(let s of n.document.getElementsByTagName("iframe"))if(s.contentWindow===r){i=s.getBoundingClientRect();let a=s.contentWindow.getComputedStyle(s);t.push({left:i.left+parseInt(a.borderLeftWidth),top:i.top+parseInt(a.borderTopWidth)})}r=n;break}}}return t.reduce((r,n)=>({left:r.left+n.left,top:r.top+n.top}),{left:0,top:0})}function Ne(e){var t;return{context:HTMLElement,frontend:e==null?void 0:e.getContextAttribute("frontend"),src:(t=e==null?void 0:e.getAttribute("src"))!==null&&t!==void 0?t:"/editor.js",library:e==null?void 0:e.getAttribute("library"),component:e==null?void 0:e.getAttribute("component"),version:e==null?void 0:e.getAttribute("version"),instance:e==null?void 0:e.getAttribute("instance"),forked:e==null?void 0:e.getAttribute("forked"),revision:(e==null?void 0:e.getAttribute("revision"))||"saved",hidden:(e==null?void 0:e.getAttribute("hidden"))!=null,for:e==null?void 0:e.getAttribute("for"),state:(e==null?void 0:e.getAttribute("state"))||"idle",changed:(e==null?void 0:e.getAttribute("changed"))!=null}}var ut=class extends b{constructor(){super(...arguments),this.framePoint={top:0,left:0},this.wrapperRect={top:0,left:0,width:0,height:0},this.bodyRect={top:0,left:0,width:0,height:0},this.defaultProps={hidden:!1},this.setTarget=(t,r={component:t.getAttribute("component"),version:t.getAttribute("version"),revision:t.getAttribute("revision"),instance:t.getAttribute("instance")})=>{if(!this.closing&&(!this.target||t==null))return this.set(r),this.target=t,!0},this.onChromeMeasureElement=(t,r=t.getBoundingClientRect())=>t.ownerDocument==document?{left:r.left-this.bodyRect.left,top:r.top-this.bodyRect.top,width:r.width,height:r.height}:{left:r.left+this.framePoint.left-this.bodyRect.left,top:r.top+this.framePoint.top-this.bodyRect.top,width:r.width,height:r.height},this.onBeforeMeasure=t=>{t.memoized.focusable&&(this.framePoint=Oe(t.memoized.focusable)),this.chrome&&(this.wrapperRect=this.chrome.positionable.getBoundingClientRect(),this.bodyRect=this.chrome.positionable.ownerDocument.body.parentElement.getBoundingClientRect())},this.onMeasure=()=>{},this.onPosition=({focusable:t,root:r})=>{!this.chrome||this.props.hidden||(t?(this.chrome.wrapper.style.width=t.width+16*2+"px",this.chrome.wrapper.style.height=t.height+16*1+64+"px",this.chrome.wrapper.style.left=t.left-16+"px",this.chrome.wrapper.style.top=t.top-64+"px",this.chrome.wrapper.style.opacity="1",this.chrome.absolute=this.querySelector(".ui.overlays"),this.chrome.absolute&&(this.chrome.absolute.style.left=r.left+"px",this.chrome.absolute.style.top=r.top+"px")):(this.chrome.wrapper.style.opacity="0",this.chrome.wrapper.style.left="-1000px",this.chrome.wrapper.style.top="-1000px"))},this.onWindowMessage=t=>{var r;switch((r=t.data)===null||r===void 0?void 0:r.type){case"feaasEdit":let n=this.getPlaceholder();this.setTarget(n.editable,t.data)&&(this.loader=n.loader,document.body.appendChild(n.clipper),this.editedUID=t.data.id,this.setPlaceholder(),this.open());break;case"feaasMeasurements":this.measurements=t.data.measurements,this.props.hidden||this.setPlaceholder();break}},this.onContentChange=()=>{this.setAttribute("changed","changed"),requestAnimationFrame(()=>{this.setIframeComponentContent()})},this.onClose=()=>{var t;this.setAttribute("hidden","hidden"),this.placeholder&&(this.placeholder.positionable.style.opacity="0",this.placeholder.positionable.style.pointerEvents="none"),this.chrome&&(this.chrome.wrapper.style.opacity="0"),!((t=this.target)===null||t===void 0)&&t.parentNode&&(this.target.outerHTML=this.target.outerHTML),this.setTarget(null,{component:null,version:null,instance:null,revision:null}),this.setEditorContext({isFocused:!1})},this.onVersionStateChange=(t,r)=>{this.versionContext=t,this.setVersionContext=r},this.onEditorStateChange=(t,r)=>{this.editorContext=t,this.setEditorContext=r,t.editor&&this.props.state=="loading"&&!this.props.hidden&&(this.setAttribute("state","ready"),this.ownerDocument.fonts.ready.then(()=>setTimeout(()=>{this.setReadyState(),this.setIframeComponentContent()},100)))}}getProps(){return Ne(this)}getReactRootElement(){return this.reactRootElement||(this.reactRootElement=document.createElement("div"),this.getRoot().appendChild(this.reactRootElement)),this.reactRootElement}showLoader(){this.loader||(this.loader=document.createElement("feaas-loader"),this.loader.setAttribute("opacity","0.6"),this.loader.style.zIndex="1000",this.target.appendChild(this.loader),this.target.tagName=="FEAAS-COMPONENT"&&(this.target.style.position="relative"))}hideLoader(){this.loader&&(this.loader.setAttribute("hidden","hidden"),this.target.tagName=="FEAAS-COMPONENT"&&(this.target.style.position="relative",this.target.style.position=""))}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}connectedCallback(){super.connectedCallback(),window.addEventListener("message",this.onWindowMessage)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("message",this.onWindowMessage)}setIframe(t){this.iframe=t}setIframeComponentContent(){this.placeholder&&this.iframe&&this.placeholder.editable.innerHTML&&this.iframe.contentWindow.postMessage({type:"feaasUpdate",id:this.editedUID,content:this.placeholder.editable.innerHTML})}setPlaceholder(){if(!this.iframe)return;let t=this.iframe.clientWidth,r=this.iframe.clientHeight,n=this.iframe.getBoundingClientRect(),i=this.getPlaceholder(),o=document.body.getBoundingClientRect(),s=this.measurements[this.editedUID];s&&(Object.assign(i.clipper.style,{position:"absolute",top:n.top+this.iframe.clientTop-o.top+"px",left:n.left+this.iframe.clientLeft-o.left+"px",width:t+"px",height:r+"px",pointerEvents:"none",zIndex:1,overflow:"hidden"}),Object.assign(i.positionable.style,{position:"absolute",top:s.top+"px",left:s.left+"px",width:s.width+"px",zIndex:2,transition:"opacity 0.4s",pointerEvents:this.props.hidden?"none":"all"}),Object.assign(i.loader.style,{position:"absolute",top:s.top+"px",left:s.left+"px",width:s.width+"px",height:s.height+"px",filter:"opacity(0.6)",zIndex:3,pointerEvents:"none"}),document.dispatchEvent(new Event("feaasRefresh",{bubbles:!0})))}getPlaceholder(){return this.placeholder?this.placeholder:(this.placeholder={clipper:document.createElement("div"),positionable:document.createElement("div"),editable:Object.assign(document.createElement("div"),{className:"-feaas"}),loader:document.createElement("feaas-loader")},this.placeholder.clipper.appendChild(this.placeholder.positionable),this.placeholder.positionable.appendChild(this.placeholder.editable),this.placeholder.clipper.appendChild(this.placeholder.loader),this.placeholder)}attributeChangedCallback(t,r,n){r!==n&&(t=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),n?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all")),super.attributeChangedCallback(t,r,n))}open(){clearTimeout(this.closing),this.removeAttribute("hidden"),this.removeAttribute("changed"),this.setLoadingState()}shouldFork(t){return t.forkOriginId==null&&this.props.instance!=null}cleanup(){var t;this.placeholder&&((t=this.placeholder.clipper)===null||t===void 0||t.remove(),this.placeholder=null)}close(){console.log("Editor is not ready")}unfork(){console.log("Editor is not ready")}discard(){console.log("Editor is not ready")}save(){console.log("Editor is not ready")}setVersionContext(t){console.log("Editor is not ready")}setEditorContext(t){console.log("Editor is not ready")}setLoadingState(){this.showLoader(),this.setAttribute("state","loading")}setReadyState(){this.hideLoader(),this.setEditorContext({activeVersionId:this.component.versions[0].id}),this.setAttribute("state","ready")}render({children:t,component:r,version:n,instance:i},{Editor:o,VersionStatusList:s,VersionStatusButton:a,Version:l,VersionMenu:c,EditorUIUndo:d,EditorUIMode:h,React:{useEffect:u,useMemo:p,useState:C,useContext:m},Chakra:{HStack:w,Box:E,Button:pt,MenuItem:O},Chrome:ft,ReactDOM:qt,useSDK:P,useLibrary:z,useSlots:N,useModelObserver:Dt,ConfirmationContext:K,VersionContext:y}){if(!this.payload)return;let{React:v}=this.payload,Kt=P(),Gt=z(),[A,Xt]=C(),{setConfirm:Pt}=m(K),G=i||n;A&&(this.component=A),u(()=>{if(this.props.hidden)return;let F=Gt.components.getItem(r).clone();return F.versions.search({ids:[n,i].filter(Boolean),componentIds:[r]}).then(Ot=>{F.versions.setItems(Ot);let _=F.findVersion(i,["staged","published"]),Y=F.findVersion(n,["staged","published"]);if(_)_.deletedAt?(_.getDraft().changeAndNotify(Y.toProperties()).restore(),console.error("FEAAS Editor: Restoring fork")):(console.error("FEAAS Editor: Pre-forked"),this.setAttribute("forked",_.id));else if(this.removeAttribute("forked"),this.shouldFork(Y)){console.error("FEAAS Editor: Forking");let Nt=Y.fork(i).id;this.setAttribute("instance",Nt)}else console.error("FEAAS Editor: Regular");Xt(F)}),()=>{this.closing=setTimeout(()=>{this.closing=null,this.cleanup(),Xt(null)},400)}},[n,this.props.hidden]);let Yt=Dt(A==null?void 0:A.versions,[]).filter(F=>F.id==G),X=Yt[0];X&&!this.props.hidden&&(this.version=X),u(()=>(this.unfork=()=>{Pt({title:"Reverting component customizations",button:"Discard",body:"Are you sure to reset component to its original state? All changes will be lost.",action:()=>{let F=A.findVersion(n,["staged","published"]);A.findVersion(i).unstage().unpublish().changeAndNotify(F.toProperties()),A.saveVersions(!1),this.setVersionContext({needsWrite:!0}),this.removeAttribute("forked"),requestAnimationFrame(this.onClose)}})},this.discard=()=>{this.props.changed&&(A.findVersion(G).revert(),A.saveVersions(!1),this.setVersionContext({needsWrite:!0}))},this.close=()=>{Pt({title:"Component has unsaved changes",button:"Discard",body:"Are you sure to close editor and discard changes?",bypass:!this.props.changed,action:()=>{this.discard(),requestAnimationFrame(this.onClose)}})},this.save=()=>{Pt({bypass:!!this.props.forked,title:"Customizing component",button:"Save",body:"Changes to the component will only be visible on that page. Changes to component done in Component Builder will not be reflected here. It will be possible to revert the customization.",action:()=>{A.findVersion(G).commitData({view:this.editorContext.editor.getData({rootName:G}),model:""}).stage().publish(),this.removeAttribute("changed"),this.setAttribute("forked",G),A.saveVersions(!1)}})},()=>{delete this.unfork,delete this.discard,delete this.save,delete this.editorContext,delete this.versionContext,delete this.setEditorContext,delete this.setVersionContext}),[A]);let Ue=p(()=>this.target,[A]);return p(()=>A&&N(t,({picker:F,children:Ot})=>v.createElement(E,{ref:_=>{this.chrome=_?{positionable:_,wrapper:_.querySelector(".editor-chrome"),absolute:this.querySelector(".ui.overlays")}:null}},v.createElement(E,{className:"editor-wrapper",position:"absolute",left:0,top:0},v.createElement(o,{datasources:Kt.datasources,sdk:Kt,library:Gt,component:A,versions:Yt,context:{isAutosaveEnabled:!1,onChromeMeasure:this.onMeasure,onChromeBeforeMeasure:this.onBeforeMeasure,onChromeMeasureElement:this.onChromeMeasureElement,onChromePosition:this.onPosition,onContentChange:this.onContentChange}},{exports:this.onEditorStateChange,after:Ot,chrome:({editor:_})=>_&&v.createElement(ft,null),children:({isArchivedDisplayed:_,editor:Y,status:Nt})=>v.createElement(E,{position:"absolute",left:0,top:0,className:"editor-chrome",p:4,boxShadow:"2xl",pointerEvents:"none",opacity:0,transition:"opacity 0.3s"},v.createElement(E,{left:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),v.createElement(E,{right:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),v.createElement(E,{top:0,height:"16",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),v.createElement(E,{bottom:0,height:"4",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),X&&v.createElement(l,{version:X,node:Ue,ignoreBreakpoints:!0,deps:[this.props.forked,this.props.changed]},{exports:this.onVersionStateChange,left:v.createElement(w,{justifyContent:"space-between"},v.createElement(d,{size:"sm",editor:Nt=="ready"?Y:null}),v.createElement(h,{size:"sm"})),middle:(wr,Er)=>[!1],right:v.createElement(v.Fragment,null,v.createElement(pt,{variant:"secondary",size:"sm",onClick:this.close},"Close"),v.createElement(pt,{variant:"primary",size:"sm",onClick:this.save,isDisabled:!this.props.changed},this.props.changed?this.props.forked?"Save":"Save customization":"Up to date"),v.createElement(c,{isDisabled:!this.props.forked&&!this.props.changed},v.createElement(O,{onClick:this.unfork,isDisabled:!this.props.forked},"Unfork"),v.createElement(O,{onClick:this.discard,isDisabled:!this.props.changed},"Discard")))}))})))),[X,this.props.forked,this.props.changed])}isReadyToLoad(){return this.props.component!=null&&this.props.version!=null&&!this.props.hidden}};ut.observedAttributes=["library","component","version","revision","hidden","state","changed","forked"];ut.register("feaas-editor");function Te(e){var t,r;return{part:(e==null?void 0:e.getAttribute("part"))||"picker",slot:(e==null?void 0:e.getAttribute("part"))||"picker",mode:e==null?void 0:e.getAttribute("mode"),placeholder:(e==null?void 0:e.getAttribute("placeholder"))||"No theme",frontend:(t=e==null?void 0:e.getContextAttribute("frontend"))!==null&&t!==void 0?t:"https://components.sitecorecloud.io",src:(r=e==null?void 0:e.getAttribute("src"))!==null&&r!==void 0?r:"/picker.js",hidden:(e==null?void 0:e.getAttribute("hidden"))!=null,variant:e==null?void 0:e.getAttribute("variant"),context:void 0,onClose:void 0,setAttribute:void 0,getAttribute:void 0}}var ht=class extends b{constructor(){super(...arguments),this.defaultProps={hidden:!1}}getProps(){return Te(this)}load(){return this.import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}connectedCallback(){this.setAttribute("feaas-role","ui"),super.connectedCallback()}render({placeholder:t,context:r,mode:n,children:i,variant:o},{Picker:s,React:a,useLibrary:l}){let[c,d]=a.useReducer(m=>m+1,0),h=l("collections"),u=l("components"),p=l("stylesheet.styles"),C=u.find(m=>m.id==(r==null?void 0:r.getAttribute("component")));return a.createElement(s,{rules:p,collections:h,themeContext:r,placeholder:t,component:C,versionId:r.getAttribute("version"),mode:n||"component",setAttribute:(m,w,E)=>{this.props.setAttribute(m,w,E),d()},context:r,variant:o,onModeChange:m=>{this.set({mode:m})}},i)}};ht.observedAttributes=["library","mode","frontend","src","hidden","variant"];ht.register("feaas-picker");function Me(e){var t,r,n,i,o;return{library:e==null?void 0:e.getAttribute("library"),src:(t=e==null?void 0:e.getAttribute("src"))!==null&&t!==void 0?t:"/context.js",environment:(r=e==null?void 0:e.getAttribute("environment"))!==null&&r!==void 0?r:void 0,frontend:(n=e==null?void 0:e.getAttribute("frontend"))!==null&&n!==void 0?n:"https://components.sitecorecloud.io",backend:(i=e==null?void 0:e.getAttribute("backend"))!==null&&i!==void 0?i:"https://components.sitecorecloud.io/api",cdn:(o=e==null?void 0:e.getAttribute("cdn"))!==null&&o!==void 0?o:"https://feaas.blob.core.windows.net",auth:null,isolate:(e==null?void 0:e.getAttribute("isolate"))==null||(e==null?void 0:e.getAttribute("isolate"))=="true"}}var W=class extends b{constructor(){super(...arguments),this.defaultProps={isolate:!0},this.onStatusChange=(t,r)=>{t=="ready"&&(this.whenSDKReady.resolve(r),this.dispatchEvent(new CustomEvent("feaasReady",{bubbles:!0,composed:!0,detail:r})))},this.whenSDKReady=S(t=>{this.sdk=t})}getProps(){return Me(this)}load(){return this.import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null}getTheme(t){return t}getRoot(){return this.getAttribute("isolate")==="false"?this:this.shadowRoot||this.attachShadow({mode:"open"})}getReactRootElement(){return this.reactRootElement||(this.reactRootElement=document.createElement("div"),this.getRoot().appendChild(this.reactRootElement)),this.reactRootElement}connectedCallback(){this.setAttribute("feaas-role","ui"),Array.from(this.children).forEach(t=>{this.getRoot().appendChild(t)}),document.addEventListener("feaasMount",this),document.addEventListener("feaasUnmount",this),super.connectedCallback()}disconnectedCallback(){document.removeEventListener("feaasMount",this),document.removeEventListener("feaasUnmount",this),super.disconnectedCallback()}render({children:t,library:r},{AppContext:n,Chakra:{Button:i,Tooltip:o},React:s}){let a={containerRef:{current:this.getRoot()}};return o.defaultProps={hasArrow:!0,placement:"top",portalProps:a},s.createElement(n,{environment:this.props.environment,backend:this.props.backend,libraryId:this.props.library,container:this.getRoot(),auth:this.props.auth,getTheme:this.getTheme,onStatusChange:this.onStatusChange,modalProps:{portalProps:a},chakraProps:{resetScope:':where([feaas-role="ui"])',cssVarsRoot:":host",resetCSS:!0,toastOptions:{portalProps:a}}},t)}};W.observedAttributes=["library","component","version","revision","hostname","template"];W.register("feaas-context");W.prototype.clientside=zt;import H from"react";import Le from"react";import fr from"react-dom";function Vt(e){let t=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;return e.replace(t,function(r){return"-"+r.toLowerCase()})}function Jt(e){let t=/-[a-z\u00E0-\u00F6\u00F8-\u00FE]/g;return e.replace(t,function(r){return r.slice(1).toUpperCase()})}var mr=e=>Object.keys(e).reduce((t,r)=>{if(e[r].title)t[r]=e[r];else{let n=r.split("-").map(i=>i.charAt(0).toUpperCase()+i.slice(1).toLowerCase()).join(" ");t[r]={...e[r],title:n}}return t},{}),$e=(e={})=>Object.keys(e).reduce((t,r)=>(t[Vt(r)]=e[r],t),{}),vr=e=>{if(!e)return;if(!e.properties)return e;let t,r;return t=$e(e.properties),r=(e.required||[]).map(i=>Vt(i)),t=mr(t),{...e,properties:t,required:r,title:void 0}},yr=(e,t)=>{if(!e||!t)return;let r;return r=$e(e),Object.keys(t).filter(i=>/(integer|number)/.test(t[i].type)).forEach(i=>{r[i]?r[i]["ui:widget"]||(r[i]["ui:widget"]="updown"):r[i]={"ui:widget":"updown"}}),r},br=(e,t,r)=>{var n;switch((n=r==null?void 0:r[e])===null||n===void 0?void 0:n.type){case"string":return t;case"object":return JSON.parse(t);case"array":return JSON.parse(t);case"number":return+t;case"integer":return+t;case"boolean":return t==="true";default:return t}};function gr(e){var t;let r=e.getAttributeNames(),n=e.getAttribute("data-external-id"),i=(t=g.registered[n])===null||t===void 0?void 0:t.schema;return r.reduce((s,a)=>{if(!a.startsWith("data-attribute")&&!["class","id","contenteditable"].includes(a)){let l=e.getAttribute(a);return{...s,[Jt(a)]:br(Jt(a),l,i==null?void 0:i.properties)}}else return s},{})}var g=class extends b{load(){return Promise.resolve({React:Le,ReactDOM:fr})}render(t,{React:r}){var n;let{dataExternalId:i}=t,o=(n=g.registered[i])===null||n===void 0?void 0:n.component;return o||console.warn("FEAASExternal: The component you requested is not registered"),r.createElement(r.Fragment,null,o&&r.createElement(o,{...t}))}getProps(){return gr(this)}static registerComponent(t,r){if(!r.name)throw new Error("Could not register external component. Please make sure you provide a name in the options");let n=r.name,{thumbnail:i,group:o,ui:s,...a}=r,l={...a,type:"object"};g.registered[n]={component:t,name:n,schema:l,uiSchema:s,thumbnail:i,group:o,title:(l==null?void 0:l.title)||n},g.setRegistrationCallback()}static setRegistrationCallback(){clearTimeout(g.registrationCallback),g.registrationCallback=setTimeout(()=>{var t;if(typeof window!="undefined"){let r=Object.keys(g.registered).map(n=>{var i;return{...g.registered[n],name:n,schema:vr(g.registered[n].schema),uiSchema:yr(g.registered[n].uiSchema,(i=g.registered[n].schema)===null||i===void 0?void 0:i.properties)}});(t=window.parent)===null||t===void 0||t.postMessage(JSON.stringify({action:"register-components",data:r}),"*")}},30)}static Preview(t){var r;let n=(t==null?void 0:t.src)||(typeof window!="undefined"?(r=window.location.search.match(/feaasSrc=([^&]+)/))===null||r===void 0?void 0:r[1]:null);return n?Le.createElement(je,{src:n,...t}):null}};g.registered={};g.register("feaas-external");g.setRegistrationCallback();var qn=g.registerComponent;var Qn=async e=>{let t=await lt((e==null?void 0:e.data)||{}),r={...e};if(("src"in r||"component"in r)&&(r==null?void 0:r.template)==null){let n=await It(r);r.template=n.template}return Ie({...r,data:t})};function Ie({data:e,...t}){let r="",n=null;return"template"in t&&t.template&&(r=ie(t.template,e||{})),"src"in t&&(t={...U(t.src),...t}),H.createElement(H.Fragment,null,"preload"in t&&n===!0&&"src"in t&&H.createElement(H.Fragment,null,H.createElement("link",{rel:"preload",as:"fetch",href:at(t.src),crossOrigin:"anonymous"}),H.createElement("link",{rel:"preload",as:"style",href:B(t.src),crossOrigin:"anonymous"})),H.createElement("feaas-component",{...t,template:null,data:typeof e=="string"?e:e?JSON.stringify(e):null,dangerouslySetInnerHTML:{__html:r||""}}))}var je=Ie;export{je as Component,Ce as ComponentProps,W as Context,S as ControlledPromise,D as DEFAULT_CDN_URL,wt as DOM,Ft as DataSettings,gt as Datapath,vt as Datascope,b as Element,g as External,dt as FEAASComponent,Ce as FEAASComponentsProps,W as FEAASContext,Me as FEAASContextProps,ut as FEAASEditor,Ne as FEAASEditorProps,b as FEAASElement,Ie as FEAASEmbed,ct as FEAASLoader,xe as FEAASLoaderProps,ht as FEAASPicker,Te as FEAASPickerProps,_t as FEAASStylesheet,Se as FEAASStylesheetProps,Et as InvalidResponse,f as JSONPath,ct as Loader,mt as MyComponent,ht as Picker,Qn as ServerComponent,_t as Stylesheet,kt as Thumbnail,se as autoloadScripts,nt as cleanCollectionBit,or as clearFetchCache,we as createStylesheet,ot as fetchAndRevalidate,q as fetchAndRevalidateComponent,xt as fetchAndRevalidateStylesheet,At as fetchBypassingCache,it as fetchCache,It as fetchComponent,lt as fetchData,st as fetchToValidateCache,I as fetchWithCacheAwareness,ge as findStylesheet,sr as getComponentSource,at as getComponentURL,ye as getFetchCache,Oe as getFramePosition,ce as getHumanizedLabel,ue as getLastPathBit,de as getQualifier,ar as getStylesheetSource,B as getStylesheetURL,Rt as isDataSettings,rt as loadScript,St as loadStylesheet,Ut as loadStylesheetAllowStale,bt as normalizeCollectionScope,oe as observeDOMElement,U as parseComponentSource,ae as parseLimit,le as parseRange,Ct as parseStylesheetSource,et as queryScopes,Bt as renderComponent,dr as renderComponentElement,Ee as renderComponentPromise,j as renderDOMContent,R as renderDOMElement,ie as renderHTMLContent,lr as renderStylesheet,be as renderStylesheetPromise,M as serializeCH1RichText,$ as setDOMAttribute};
|
|
73
|
+
`,s.contentWindow.document.head.appendChild(d),s.contentWindow.document.head.appendChild(h);let u=Bt({template:r,data:n});u.classList.add(...e,"-feaas--preview","-emulate--"+t.details.slug),s.contentWindow.document.body.appendChild(u)})}async function Pe(e,t,r){let n=t?t.getThumbnailURL():e.getThumbnailURL(),i=new Date(Math.max(Number(e.modifiedAt),Number(e.library.stylesheet.modifiedAt)));try{await e.sdk.uploadBlob("thumbnails",n.split(/\/thumbnails\//)[1],r,{headers:{"x-ms-blob-content-type":"image/jpg","x-ms-blob-cache-control":"public,max-age=31536000,immutable","x-ms-meta-versionId":t?t.id:null,"x-ms-meta-versionRevision":t?t.revision.toString():null,"x-ms-meta-componentId":e.id,"x-ms-meta-componentRenderedAt":i.toUTCString(),"x-ms-meta-componentModifiedAt":e.modifiedAt.toUTCString(),"x-ms-meta-componentCreatedAt":e.createdAt.toUTCString(),"x-ms-meta-modifiedAt":e.modifiedAt.toUTCString()}}),fetch(n,{cache:"no-cache"}).then(()=>{e.sdk.log("FEAAS: Thumbnail uploaded",n)})}catch(o){e.sdk.log("FEAAS: Thumbnail failed to upload",n,o)}return n}var Vt;typeof window!="undefined"&&(window.FEAASReactElement=q,(Vt=window.FEAASLoading)!==null&&Vt!==void 0||(window.FEAASLoading=Promise.resolve()));function Te(e){let t=[];if(e){let r=e.ownerDocument.defaultView,n,i;for(;r!==window.top;){n=r.parent;for(let o=0;o<n.frames.length;o++)if(n.frames[o]===r){for(let s of n.document.getElementsByTagName("iframe"))if(s.contentWindow===r){i=s.getBoundingClientRect();let a=s.contentWindow.getComputedStyle(s);t.push({left:i.left+parseInt(a.borderLeftWidth),top:i.top+parseInt(a.borderTopWidth)})}r=n;break}}}return t.reduce((r,n)=>({left:r.left+n.left,top:r.top+n.top}),{left:0,top:0})}function Me(e){var t;return{context:HTMLElement,frontend:e==null?void 0:e.getContextAttribute("frontend"),src:(t=e==null?void 0:e.getAttribute("src"))!==null&&t!==void 0?t:"/editor.js",library:e==null?void 0:e.getAttribute("library"),component:e==null?void 0:e.getAttribute("component"),version:e==null?void 0:e.getAttribute("version"),instance:e==null?void 0:e.getAttribute("instance"),forked:e==null?void 0:e.getAttribute("forked"),revision:(e==null?void 0:e.getAttribute("revision"))||"saved",hidden:(e==null?void 0:e.getAttribute("hidden"))!=null,for:e==null?void 0:e.getAttribute("for"),state:(e==null?void 0:e.getAttribute("state"))||"idle",changed:(e==null?void 0:e.getAttribute("changed"))!=null}}var ht=class extends A{constructor(){super(...arguments),this.framePoint={top:0,left:0},this.wrapperRect={top:0,left:0,width:0,height:0},this.bodyRect={top:0,left:0,width:0,height:0},this.defaultProps={hidden:!1},this.setTarget=(t,r={component:t.getAttribute("component"),version:t.getAttribute("version"),revision:t.getAttribute("revision"),instance:t.getAttribute("instance")})=>{if(!this.closing&&(!this.target||t==null))return this.set(r),this.target=t,!0},this.onChromeMeasureElement=(t,r=t.getBoundingClientRect())=>t.ownerDocument==document?{left:r.left-this.bodyRect.left,top:r.top-this.bodyRect.top,width:r.width,height:r.height}:{left:r.left+this.framePoint.left-this.bodyRect.left,top:r.top+this.framePoint.top-this.bodyRect.top,width:r.width,height:r.height},this.onBeforeMeasure=t=>{t.memoized.focusable&&(this.framePoint=Te(t.memoized.focusable)),this.chrome&&(this.wrapperRect=this.chrome.positionable.getBoundingClientRect(),this.bodyRect=this.chrome.positionable.ownerDocument.body.parentElement.getBoundingClientRect())},this.onMeasure=()=>{},this.onPosition=({focusable:t,root:r})=>{!this.chrome||this.props.hidden||(t?(this.chrome.wrapper.style.width=t.width+16*2+"px",this.chrome.wrapper.style.height=t.height+16*1+64+"px",this.chrome.wrapper.style.left=t.left-16+"px",this.chrome.wrapper.style.top=t.top-64+"px",this.chrome.wrapper.style.opacity="1",this.chrome.absolute=this.querySelector(".ui.overlays"),this.chrome.absolute&&(this.chrome.absolute.style.left=r.left+"px",this.chrome.absolute.style.top=r.top+"px")):(this.chrome.wrapper.style.opacity="0",this.chrome.wrapper.style.left="-1000px",this.chrome.wrapper.style.top="-1000px"))},this.onWindowMessage=t=>{var r;switch((r=t.data)===null||r===void 0?void 0:r.type){case"feaasEdit":let n=this.getPlaceholder();this.setTarget(n.editable,t.data)&&(this.loader=n.loader,document.body.appendChild(n.clipper),this.editedUID=t.data.id,this.setPlaceholder(),this.open());break;case"feaasMeasurements":this.measurements=t.data.measurements,this.props.hidden||this.setPlaceholder();break}},this.onContentChange=()=>{this.setAttribute("changed","changed"),requestAnimationFrame(()=>{this.setIframeComponentContent()})},this.onClose=()=>{var t;this.setAttribute("hidden","hidden"),this.placeholder&&(this.placeholder.positionable.style.opacity="0",this.placeholder.positionable.style.pointerEvents="none"),this.chrome&&(this.chrome.wrapper.style.opacity="0"),!((t=this.target)===null||t===void 0)&&t.parentNode&&(this.target.outerHTML=this.target.outerHTML),this.setTarget(null,{component:null,version:null,instance:null,revision:null}),this.setEditorContext({isFocused:!1})},this.onVersionStateChange=(t,r)=>{this.versionContext=t,this.setVersionContext=r},this.onEditorStateChange=(t,r)=>{this.editorContext=t,this.setEditorContext=r,t.editor&&this.props.state=="loading"&&!this.props.hidden&&(this.setAttribute("state","ready"),this.ownerDocument.fonts.ready.then(()=>setTimeout(()=>{this.setReadyState(),this.setIframeComponentContent()},100)))}}getProps(){return Me(this)}getReactRootElement(){return this.reactRootElement||(this.reactRootElement=document.createElement("div"),this.getRoot().appendChild(this.reactRootElement)),this.reactRootElement}showLoader(){this.loader||(this.loader=document.createElement("feaas-loader"),this.loader.setAttribute("opacity","0.6"),this.loader.style.zIndex="1000",this.target.appendChild(this.loader),this.target.tagName=="FEAAS-COMPONENT"&&(this.target.style.position="relative"))}hideLoader(){this.loader&&(this.loader.setAttribute("hidden","hidden"),this.target.tagName=="FEAAS-COMPONENT"&&(this.target.style.position="relative",this.target.style.position=""))}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}connectedCallback(){super.connectedCallback(),window.addEventListener("message",this.onWindowMessage)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("message",this.onWindowMessage)}setIframe(t){this.iframe=t}setIframeComponentContent(){this.placeholder&&this.iframe&&this.placeholder.editable.innerHTML&&this.iframe.contentWindow.postMessage({type:"feaasUpdate",id:this.editedUID,content:this.placeholder.editable.innerHTML})}setPlaceholder(){if(!this.iframe)return;let t=this.iframe.clientWidth,r=this.iframe.clientHeight,n=this.iframe.getBoundingClientRect(),i=this.getPlaceholder(),o=document.body.getBoundingClientRect(),s=this.measurements[this.editedUID];s&&(Object.assign(i.clipper.style,{position:"absolute",top:n.top+this.iframe.clientTop-o.top+"px",left:n.left+this.iframe.clientLeft-o.left+"px",width:t+"px",height:r+"px",pointerEvents:"none",zIndex:1,overflow:"hidden"}),Object.assign(i.positionable.style,{position:"absolute",top:s.top+"px",left:s.left+"px",width:s.width+"px",zIndex:2,transition:"opacity 0.4s",pointerEvents:this.props.hidden?"none":"all"}),Object.assign(i.loader.style,{position:"absolute",top:s.top+"px",left:s.left+"px",width:s.width+"px",height:s.height+"px",filter:"opacity(0.6)",zIndex:3,pointerEvents:"none"}),document.dispatchEvent(new Event("feaasRefresh",{bubbles:!0})))}getPlaceholder(){return this.placeholder?this.placeholder:(this.placeholder={clipper:document.createElement("div"),positionable:document.createElement("div"),editable:Object.assign(document.createElement("div"),{className:"-feaas"}),loader:document.createElement("feaas-loader")},this.placeholder.clipper.appendChild(this.placeholder.positionable),this.placeholder.positionable.appendChild(this.placeholder.editable),this.placeholder.clipper.appendChild(this.placeholder.loader),this.placeholder)}attributeChangedCallback(t,r,n){r!==n&&(t=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),n?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all")),super.attributeChangedCallback(t,r,n))}open(){clearTimeout(this.closing),this.removeAttribute("hidden"),this.removeAttribute("changed"),this.setLoadingState()}shouldFork(t){return t.forkOriginId==null&&this.props.instance!=null}cleanup(){var t;this.placeholder&&((t=this.placeholder.clipper)===null||t===void 0||t.remove(),this.placeholder=null)}close(){console.log("Editor is not ready")}unfork(){console.log("Editor is not ready")}discard(){console.log("Editor is not ready")}save(){console.log("Editor is not ready")}setVersionContext(t){console.log("Editor is not ready")}setEditorContext(t){console.log("Editor is not ready")}setLoadingState(){this.showLoader(),this.setAttribute("state","loading")}setReadyState(){this.hideLoader(),this.setEditorContext({activeVersionId:this.component.versions[0].id}),this.setAttribute("state","ready")}render({children:t,component:r,version:n,instance:i},{Editor:o,VersionStatusList:s,VersionStatusButton:a,Version:l,VersionMenu:c,EditorUIUndo:d,EditorUIMode:h,React:{useEffect:u,useMemo:f,useState:E,useContext:v},Chakra:{HStack:m,Box:w,Button:N,MenuItem:T},Chrome:pt,ReactDOM:Gt,useSDK:P,useLibrary:J,useSlots:M,useModelObserver:Ft,ConfirmationContext:G,VersionContext:b}){if(!this.payload)return;let{React:g}=this.payload,Xt=P(),Yt=J(),[C,Zt]=E(),{setConfirm:Ot}=v(G),X=i||n;C&&(this.component=C),u(()=>{if(this.props.hidden)return;let D=Yt.components.getItem(r).clone();return D.versions.search({ids:[n,i].filter(Boolean),componentIds:[r]}).then(Nt=>{D.versions.setItems(Nt);let k=D.findVersion(i,["staged","published"]),Z=D.findVersion(n,["staged","published"]);if(k)k.deletedAt?(k.getDraft().changeAndNotify(Z.toProperties()).restore(),console.error("FEAAS Editor: Restoring fork")):(console.error("FEAAS Editor: Pre-forked"),this.setAttribute("forked",k.id));else if(this.removeAttribute("forked"),this.shouldFork(Z)){console.error("FEAAS Editor: Forking");let Pt=Z.fork(i).id;this.setAttribute("instance",Pt)}else console.error("FEAAS Editor: Regular");Zt(D)}),()=>{this.closing=setTimeout(()=>{this.closing=null,this.cleanup(),Zt(null)},400)}},[n,this.props.hidden]);let Qt=Ft(C==null?void 0:C.versions,[]).filter(D=>D.id==X),Y=Qt[0];Y&&!this.props.hidden&&(this.version=Y),u(()=>(this.unfork=()=>{Ot({title:"Reverting component customizations",button:"Discard",body:"Are you sure to reset component to its original state? All changes will be lost.",action:()=>{let D=C.findVersion(n,["staged","published"]);C.findVersion(i).unstage().unpublish().changeAndNotify(D.toProperties()),C.saveVersions(!1),this.setVersionContext({needsWrite:!0}),this.removeAttribute("forked"),requestAnimationFrame(this.onClose)}})},this.discard=()=>{this.props.changed&&(C.findVersion(X).revert(),C.saveVersions(!1),this.setVersionContext({needsWrite:!0}))},this.close=()=>{Ot({title:"Component has unsaved changes",button:"Discard",body:"Are you sure to close editor and discard changes?",bypass:!this.props.changed,action:()=>{this.discard(),requestAnimationFrame(this.onClose)}})},this.save=()=>{Ot({bypass:!!this.props.forked,title:"Customizing component",button:"Save",body:"Changes to the component will only be visible on that page. Changes to component done in Component Builder will not be reflected here. It will be possible to revert the customization.",action:()=>{C.findVersion(X).commitData({view:this.editorContext.editor.getData({rootName:X}),model:""}).stage().publish(),this.removeAttribute("changed"),this.setAttribute("forked",X),C.saveVersions(!1)}})},()=>{delete this.unfork,delete this.discard,delete this.save,delete this.editorContext,delete this.versionContext,delete this.setEditorContext,delete this.setVersionContext}),[C]);let We=f(()=>this.target,[C]);return f(()=>C&&M(t,({picker:D,children:Nt})=>g.createElement(w,{ref:k=>{this.chrome=k?{positionable:k,wrapper:k.querySelector(".editor-chrome"),absolute:this.querySelector(".ui.overlays")}:null}},g.createElement(w,{className:"editor-wrapper",position:"absolute",left:0,top:0},g.createElement(o,{datasources:Xt.datasources,sdk:Xt,library:Yt,component:C,versions:Qt,context:{isAutosaveEnabled:!1,onChromeMeasure:this.onMeasure,onChromeBeforeMeasure:this.onBeforeMeasure,onChromeMeasureElement:this.onChromeMeasureElement,onChromePosition:this.onPosition,onContentChange:this.onContentChange}},{exports:this.onEditorStateChange,after:Nt,chrome:({editor:k})=>k&&g.createElement(pt,null),children:({isArchivedDisplayed:k,editor:Z,status:Pt})=>g.createElement(w,{position:"absolute",left:0,top:0,className:"editor-chrome",p:4,boxShadow:"2xl",pointerEvents:"none",opacity:0,transition:"opacity 0.3s"},g.createElement(w,{left:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),g.createElement(w,{right:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),g.createElement(w,{top:0,height:"16",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),g.createElement(w,{bottom:0,height:"4",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),Y&&g.createElement(l,{version:Y,node:We,ignoreBreakpoints:!0,deps:[this.props.forked,this.props.changed]},{exports:this.onVersionStateChange,left:g.createElement(m,{justifyContent:"space-between"},g.createElement(d,{size:"sm",editor:Pt=="ready"?Z:null}),g.createElement(h,{size:"sm"})),middle:(xr,Sr)=>[!1],right:g.createElement(g.Fragment,null,g.createElement(N,{variant:"secondary",size:"sm",onClick:this.close},"Close"),g.createElement(N,{variant:"primary",size:"sm",onClick:this.save,isDisabled:!this.props.changed},this.props.changed?this.props.forked?"Save":"Save customization":"Up to date"),g.createElement(c,{isDisabled:!this.props.forked&&!this.props.changed},g.createElement(T,{onClick:this.unfork,isDisabled:!this.props.forked},"Unfork"),g.createElement(T,{onClick:this.discard,isDisabled:!this.props.changed},"Discard")))}))})))),[Y,this.props.forked,this.props.changed])}isReadyToLoad(){return this.props.component!=null&&this.props.version!=null&&!this.props.hidden}};ht.observedAttributes=["library","component","version","revision","hidden","state","changed","forked"];ht.register("feaas-editor");function Le(e){var t,r;return{part:(e==null?void 0:e.getAttribute("part"))||"picker",slot:(e==null?void 0:e.getAttribute("part"))||"picker",mode:e==null?void 0:e.getAttribute("mode"),placeholder:(e==null?void 0:e.getAttribute("placeholder"))||"No theme",frontend:(t=e==null?void 0:e.getContextAttribute("frontend"))!==null&&t!==void 0?t:"https://components.sitecorecloud.io",src:(r=e==null?void 0:e.getAttribute("src"))!==null&&r!==void 0?r:"/picker.js",hidden:(e==null?void 0:e.getAttribute("hidden"))!=null,variant:e==null?void 0:e.getAttribute("variant"),context:void 0,onClose:void 0,setAttribute:void 0,getAttribute:void 0}}var ft=class extends A{constructor(){super(...arguments),this.defaultProps={hidden:!1}}getProps(){return Le(this)}load(){return this.import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}connectedCallback(){this.setAttribute("feaas-role","ui"),super.connectedCallback()}render({placeholder:t,context:r,mode:n,children:i,variant:o},{Picker:s,React:a,useLibrary:l}){let[c,d]=a.useReducer(m=>m+1,0),h=l("collections"),u=l("components"),f=l("stylesheet.styles"),E=u.find(m=>m.id==(r==null?void 0:r.getAttribute("component")));var v=r==null?void 0:r.getAttribute("data");if(v)try{v=JSON.parse(v)}catch(m){}return a.createElement(s,{rules:f,collections:h,themeContext:r,placeholder:t,component:E,data:v,versionId:r==null?void 0:r.getAttribute("version"),mode:n||(E?"component":null),setAttribute:(m,w,N)=>{w=="data"&&N&&(N=JSON.stringify(N)),this.props.setAttribute(m,w,N),d()},context:r,variant:o,onModeChange:m=>{this.set({mode:m})}},i)}};ft.observedAttributes=["library","mode","frontend","src","hidden","variant"];ft.register("feaas-picker");function $e(e){var t,r,n,i,o;return{library:e==null?void 0:e.getAttribute("library"),src:(t=e==null?void 0:e.getAttribute("src"))!==null&&t!==void 0?t:"/context.js",environment:(r=e==null?void 0:e.getAttribute("environment"))!==null&&r!==void 0?r:void 0,frontend:(n=e==null?void 0:e.getAttribute("frontend"))!==null&&n!==void 0?n:"https://components.sitecorecloud.io",backend:(i=e==null?void 0:e.getAttribute("backend"))!==null&&i!==void 0?i:"https://components.sitecorecloud.io/api",cdn:(o=e==null?void 0:e.getAttribute("cdn"))!==null&&o!==void 0?o:"https://feaas.blob.core.windows.net",auth:null,isolate:(e==null?void 0:e.getAttribute("isolate"))==null||(e==null?void 0:e.getAttribute("isolate"))=="true"}}var z=class extends A{constructor(){super(...arguments),this.defaultProps={isolate:!0},this.onStatusChange=(t,r)=>{t=="ready"&&(this.whenSDKReady.resolve(r),this.dispatchEvent(new CustomEvent("feaasReady",{bubbles:!0,composed:!0,detail:r})))},this.whenSDKReady=R(t=>{this.sdk=t})}getProps(){return $e(this)}load(){return this.import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null}getTheme(t){return t}getRoot(){return this.getAttribute("isolate")==="false"?this:this.shadowRoot||this.attachShadow({mode:"open"})}getReactRootElement(){return this.reactRootElement||(this.reactRootElement=document.createElement("div"),this.getRoot().appendChild(this.reactRootElement)),this.reactRootElement}connectedCallback(){this.setAttribute("feaas-role","ui"),Array.from(this.children).forEach(t=>{this.getRoot().appendChild(t)}),document.addEventListener("feaasMount",this),document.addEventListener("feaasUnmount",this),super.connectedCallback()}disconnectedCallback(){document.removeEventListener("feaasMount",this),document.removeEventListener("feaasUnmount",this),super.disconnectedCallback()}render({children:t,library:r},{AppContext:n,Chakra:{Button:i,Tooltip:o},React:s}){let a={containerRef:{current:this.getRoot()}};return o.defaultProps={hasArrow:!0,placement:"top",portalProps:a},s.createElement(n,{environment:this.props.environment,backend:this.props.backend,libraryId:this.props.library,container:this.getRoot(),auth:this.props.auth,getTheme:this.getTheme,onStatusChange:this.onStatusChange,modalProps:{portalProps:a},chakraProps:{resetScope:':where([feaas-role="ui"])',cssVarsRoot:":host",resetCSS:!0,toastOptions:{portalProps:a}}},t)}};z.observedAttributes=["library","component","version","revision","hostname","template"];z.register("feaas-context");z.prototype.clientside=Jt;import V from"react";import je from"react";import mr from"react-dom";function qt(e){let t=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;return e.replace(t,function(r){return"-"+r.toLowerCase()})}function Kt(e){let t=/-[a-z\u00E0-\u00F6\u00F8-\u00FE]/g;return e.replace(t,function(r){return r.slice(1).toUpperCase()})}var vr=e=>Object.keys(e).reduce((t,r)=>{if(e[r].title)t[r]=e[r];else{let n=r.split("-").map(i=>i.charAt(0).toUpperCase()+i.slice(1).toLowerCase()).join(" ");t[r]={...e[r],title:n}}return t},{}),Ie=(e={})=>Object.keys(e).reduce((t,r)=>(t[qt(r)]=e[r],t),{}),gr=e=>{if(!e)return;if(!e.properties)return e;let t,r;return t=Ie(e.properties),r=(e.required||[]).map(i=>qt(i)),t=vr(t),{...e,properties:t,required:r,title:void 0}},yr=(e,t)=>{if(!e||!t)return;let r;return r=Ie(e),Object.keys(t).filter(i=>/(integer|number)/.test(t[i].type)).forEach(i=>{r[i]?r[i]["ui:widget"]||(r[i]["ui:widget"]="updown"):r[i]={"ui:widget":"updown"}}),r},br=(e,t,r)=>{var n;switch((n=r==null?void 0:r[e])===null||n===void 0?void 0:n.type){case"string":return t;case"object":return JSON.parse(t);case"array":return JSON.parse(t);case"number":return+t;case"integer":return+t;case"boolean":return t==="true";default:return t}};function wr(e){var t;let r=e.getAttributeNames(),n=e.getAttribute("data-external-id"),i=(t=y.registered[n])===null||t===void 0?void 0:t.schema;return r.reduce((s,a)=>{if(!a.startsWith("data-attribute")&&!["class","id","contenteditable"].includes(a)){let l=e.getAttribute(a);return{...s,[Kt(a)]:br(Kt(a),l,i==null?void 0:i.properties)}}else return s},{})}var y=class extends A{load(){return Promise.resolve({React:je,ReactDOM:mr})}render(t,{React:r}){var n;let{dataExternalId:i}=t,o=(n=y.registered[i])===null||n===void 0?void 0:n.component;return o||console.warn("FEAASExternal: The component you requested is not registered"),r.createElement(r.Fragment,null,o&&r.createElement(o,{...t}))}getProps(){return wr(this)}static registerComponent(t,r){if(!r.name)throw new Error("Could not register external component. Please make sure you provide a name in the options");let n=r.name,{thumbnail:i,group:o,ui:s,...a}=r,l={...a,type:"object"};y.registered[n]={component:t,name:n,schema:l,uiSchema:s,thumbnail:i,group:o,title:(l==null?void 0:l.title)||n},y.setRegistrationCallback()}static setRegistrationCallback(){clearTimeout(y.registrationCallback),y.registrationCallback=setTimeout(()=>{var t;if(typeof window!="undefined"){let r=Object.keys(y.registered).map(n=>{var i;return{...y.registered[n],name:n,schema:gr(y.registered[n].schema),uiSchema:yr(y.registered[n].uiSchema,(i=y.registered[n].schema)===null||i===void 0?void 0:i.properties)}});(t=window.parent)===null||t===void 0||t.postMessage(JSON.stringify({action:"register-components",data:r}),"*")}},30)}static Preview(t){var r;let n=(t==null?void 0:t.src)||(typeof window!="undefined"?(r=window.location.search.match(/feaasSrc=([^&]+)/))===null||r===void 0?void 0:r[1]:null);return n?je.createElement(Ue,{src:n,...t}):null}static linkComponents(t){return()=>t.map(r=>null)}static getComponent(t){return y.registered[t]}};y.registered={};y.register("feaas-external");y.setRegistrationCallback();var Ar=y.registerComponent,Er=y.linkComponents,Cr=y.getComponent;var ni=async e=>{let t=await x.fetch((e==null?void 0:e.data)||{}),r={...e};if(("src"in e||"component"in e)&&(e==null?void 0:e.template)==null){let n=await It(e);r.template=n.template,r.lastModified=n.lastModified}return Be({...r,data:t})};function Be({data:e,...t}){let r="",n=null;return"template"in t&&t.template&&(r=se(t.template,e||{})),"src"in t?t={...W(t.src),...t}:"template"in t||t.version||(t={...t,version:"responsive"}),V.createElement(V.Fragment,null,"preload"in t&&n===!0&&"src"in t&&V.createElement(V.Fragment,null,V.createElement("link",{rel:"preload",as:"fetch",href:dt(t.src),crossOrigin:"anonymous"}),V.createElement("link",{rel:"preload",as:"style",href:H(t.src),crossOrigin:"anonymous"})),V.createElement("feaas-component",{...t,suppressHydrationWarning:!0,template:null,data:typeof e=="string"?e:e?JSON.stringify(e):null,dangerouslySetInnerHTML:{__html:r||""}}))}var Ue=Be;export{Ue as Component,Re as ComponentProps,z as Context,R as ControlledPromise,O as DEFAULT_CDN_URL,At as DOM,wt as DataPath,gt as DataScope,x as DataSettings,A as Element,y as External,ct as FEAASComponent,Re as FEAASComponentsProps,z as FEAASContext,$e as FEAASContextProps,ht as FEAASEditor,Me as FEAASEditorProps,A as FEAASElement,ut as FEAASLoader,_e as FEAASLoaderProps,ft as FEAASPicker,Le as FEAASPickerProps,Be as FEAASReactComponent,kt as FEAASStylesheet,ke as FEAASStylesheetProps,Et as InvalidResponse,p as JSONPath,ut as Loader,mt as MyComponent,ft as Picker,ni as ServerComponent,kt as Stylesheet,Dt as Thumbnail,he as adjustNumbers,le as autoloadScripts,ot as cleanCollectionBit,ar as clearFetchCache,Ce as createStylesheet,at as fetchAndRevalidate,K as fetchAndRevalidateComponent,St as fetchAndRevalidateStylesheet,Ct as fetchBypassingCache,st as fetchCache,It as fetchComponent,Ht as fetchData,lt as fetchToValidateCache,B as fetchWithCacheAwareness,Ee as findStylesheet,Cr as getComponent,lr as getComponentSource,dt as getComponentURL,we as getFetchCache,Te as getFramePosition,fe as getHumanizedLabel,pe as getLastPathBit,ue as getQualifier,dr as getStylesheetSource,H as getStylesheetURL,Er as linkComponents,it as loadScript,Rt as loadStylesheet,Ut as loadStylesheetAllowStale,bt as normalizeCollectionScope,ae as observeDOMElement,W as parseComponentSource,de as parseLimit,ce as parseRange,xt as parseStylesheetSource,vt as queryObject,nt as queryScopes,Ar as registerComponent,Bt as renderComponent,ur as renderComponentElement,xe as renderComponentPromise,U as renderDOMContent,_ as renderDOMElement,se as renderHTMLContent,cr as renderStylesheet,Ae as renderStylesheetPromise,$ as serializeCH1RichText,I as setDOMAttribute};
|
|
74
74
|
//# sourceMappingURL=react.esm.js.map
|