@sitecore-feaas/clientside 0.1.44 → 0.1.45
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/build/ui/react.js +7 -1
- package/build/ui/react.js.map +1 -1
- package/dist/browser/react.cjs +4 -4
- package/dist/browser/react.cjs.map +3 -3
- package/dist/browser/react.esm.js +4 -4
- package/dist/browser/react.esm.js.map +1 -1
- package/dist/node/react.cjs +3 -3
- package/dist/node/react.cjs.map +3 -3
- package/dist/node/react.esm.js +3 -3
- package/dist/node/react.esm.js.map +3 -3
- package/package.json +1 -1
- package/react.cjs +4 -4
- package/react.cjs.map +3 -3
- package/react.js +4 -4
- package/react.js.map +3 -3
- package/src/ui/react.tsx +7 -1
- package/test/FEAASComponent.react.test.tsx +30 -4
- package/types/tsbuildinfo_ui +1 -1
- package/types/ui/react.d.ts.map +1 -1
package/dist/node/react.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var Pt=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});function _(t,e=r=>{}){var r;let i=()=>{var o,n;let s=new Promise((l,d)=>{o=h=>{t==null||t(h),l(h)},n=d});var a=Object.assign(s,{resolve:o,reject:n,restart:i,first:r});return r=a,a.catch(e),a};return i()}var Tt=typeof HTMLElement=="undefined"?typeof windowJSDOM!="undefined"?windowJSDOM.HTMLElement:class{}:HTMLElement,b=class extends Tt{getProps(e){return{}}constructor(){super(),this.defaultProps={},this.connected=!1,this.refs={},this.descendants=[],this.whenLoaded=_(e=>{this.payload=e}),this.whenRendered=_(()=>this.initialized=!0,()=>cancelAnimationFrame(this.nextRender)),this.addEventListener("feaasMount",this),this.addEventListener("feaasUnmount",this)}getRoot(){return this}attributeChangedCallback(e,r,i){this.set()}connectedCallback(){this.mount()}disconnectedCallback(){this.unmount()}mount(){try{let e=this.getParent();if(e&&!e.connected||this.connected)return;this.connected=!0,this.log("FEAAS: Mount",this.tagName,this),this.dispatchEvent(new Event("feaasMount",{bubbles:!0,composed:!0})),this.getElements().map(r=>{var i;return(i=r.mount)===null||i===void 0?void 0:i.call(r)}),this.set()}catch(e){this.onError(e)}}log(...e){console.log(...e)}unmount(){this.connected&&(this.log("FEAAS: Unmount",this),this.dispatchEvent(new Event("feaasUnmount",{bubbles:!0,composed:!0})),this.connected=!1)}getParent(e=!0){for(var r=this;r=r.parentElement||(r.parentNode instanceof ShadowRoot?r.parentNode.host:null);)if(!e||r.tagName.startsWith("FEAAS-"))return r}getElements(e=this.getRoot(),r=!0){return Array.from(e.querySelectorAll("*")).map(i=>[!r||i.tagName.startsWith("FEAAS-")?i:null,i.shadowRoot?this.getElements(i.shadowRoot,r):null]).flat().filter(Boolean)}handleEvent(e){let r=e.composedPath()[0];switch(e.type){case"feaasMount":r!=this&&this.nestedCallback(r);break;case"feaasUnmount":r!=this&&this.unnestedCallback(r);break}}unnestedCallback(e){let r=this.descendants.indexOf(e);r!=-1&&(this.log("FEAAS: Unnest",this,e),this.descendants.splice(r,-1),this.refs[e.getComponentName()]=null,e.refs.parent==this&&(e.refs.parent=null),e.refs.top==this&&(e.refs.top=e.refs.parent))}nestedCallback(e){var r,i;if(this.descendants.indexOf(e)==-1&&(this.descendants.push(e),this.log("FEAAS: Nest",this,e),this.refs[e.getComponentName()]=e,e.refs.top=this,(r=e.refs).parent||(r.parent=this),e.render))for(var n=e.refs.parent;n;n=n.refs.parent)n.render&&((i=e.refs).parentReact||(i.parentReact=n),e.refs.topReact=n)}getComponentName(){return this.tagName.replace("FEAAS-","").toLowerCase()}isReadyToLoad(){return this.payload===void 0&&this.getAttribute("hidden")==null}onError(e,r="uncaught",i=!1){let o=new CustomEvent("feaasError",{bubbles:!0,composed:!0,detail:e});if(this.dispatchEvent(o),this.whenLoaded.reject(e),!o.defaultPrevented&&!i){this.whenRendered.reject(e);try{this.unmount()}catch(n){}return!0}return!1}shouldUpdateOnLoad(){return!0}async advance(){try{if(this.payload===void 0){if(!this.isReadyToLoad())return;this.payload=null,this.dispatchEvent(new Event("feaasLoad",{bubbles:!0,composed:!0}));let e=await this.load().catch(r=>{throw this.payload=void 0,r});if(this.whenLoaded.resolve(e),this.onLoad)return}else if(this.payload==null)return;this.flush(),this.whenRendered.resolve(this)}catch(e){this.onError(e)}}flush(){var e,r;let i=(r=(e=this.payload)===null||e===void 0?void 0:e.ReactDOM)===null||r===void 0?void 0:r.flushSync;i?i(()=>this.update()):this.update()}load(){return Promise.resolve(null)}update(){var e,r,i;if(this.payload==null||!this.render)return;let{React:o,ReactDOM:n,ReactDOMClient:s}=this.payload||{};if(!o)throw new Error(`${this.tagName}: React is not present in payload`);if(!n)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())):n.render(this.getReactElement(),this.getReactRootElement()):this.forceUpdateReact?(e=this.forceUpdateReact)===null||e===void 0||e.call(this):(i=(r=this.refs.topReact).forceUpdateReact)===null||i===void 0||i.call(r)}invokeReactRendering(){let{React:e,ReactDOM:r}=this.payload||{};if(!this.connected)return null;let i=this.descendants.filter(o=>o.refs.parentReact==this&&o.payload).map((o,n)=>this.getReactElement(o));return this.render({...this.props,children:i},this.payload)}getReactErrorBoundary(e=this,r=e.tagName){if(this.reactErrorBoundary)return this.reactErrorBoundary;let{React:i,ReactDOM:o}=e.payload||{};return this.reactErrorBoundary||(this.reactErrorBoundary=class extends i.Component{constructor(){super(...arguments),this.state={error:null}}static getDerivedStateFromError(s){return{error:s}}componentDidCatch(s,a){console.error(`FEAAS: ${e.tagName} Error:`,s,a),e.onError(s,"react")}render(){if(!this.state.error)return this.props.children}})}getReactElement(e=this,r){let{React:i,ReactDOM:o}=e.payload||{},n=this.getReactErrorBoundary(),s=this.getReactWrapper(e);return i.createElement(n,{key:e.tagName+"-"+e.getUID(),slot:e.getAttribute("slot")},i.createElement(s,null))}getReactWrapper(e=this,r=e.tagName){if(e.reactWrapper)return e.reactWrapper;let{React:i,ReactDOM:o}=e.payload||{};return e.reactWrapper=n=>{if(e.render){let[s,a]=i.useReducer(l=>l+1,0);return e.forceUpdateReact=a,o.createPortal(i.createElement(i.Fragment,null,e.invokeReactRendering()),e.getReactRootElement())}else return e.update()},Object.assign(e.reactWrapper,{key:e.tagName+"-"+e.getUID(),displayName:r}),e.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(e){try{this.scheduleRender(),this.overrides={...this.overrides,...e},this.props={...this.getProps(),...this.overrides};for(var r in this.props){let i=this.props[r],o=r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();i==null||i===this.defaultProps[r]?this.removeAttribute(o):(typeof i=="string"||typeof i=="number"||typeof i=="boolean")&&this.getAttribute(o)!=String(i)&&this.setAttribute(o,String(i))}}catch(i){this.whenRendered.reject(i),this.onError(i,"set")}return this}import(e){return import( /*@vite-ignore*/ /* webpackIgnore: true */ e)}scheduleRender(){this.nextRender==null&&(this.whenRendered=this.whenRendered.restart()),cancelAnimationFrame(this.nextRender),this.nextRender=requestAnimationFrame(()=>{this.nextRender=null,this.advance().catch(e=>{})})}formatURL(e,r){return typeof e=="string"&&e.match(/^\/[^\/]/)?r+e:e}getContextAttribute(e,r=this){for(var i=this;i=i.parentElement||(i.parentNode instanceof ShadowRoot?i.parentNode.host:null);)if(i.getAttribute(e)!=null)return i.getAttribute(e);return this.getAttribute(e)}static register(e,r){r==null&&(r=typeof window!="undefined"?window:null),r&&!r.customElements.get(e)&&r.customElements.define(e,this)}};var P=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(([e,r])=>({React:e,ReactDOM:r}))}render({},{React:e}){return e.createElement(e.Fragment,null)}},Q=class extends P{constructor(){super(...arguments),this.useShadowRoot=!0}getProps(){return{counter:parseFloat(this.getAttribute("counter"))}}render({counter:e},{React:r}){let[i,o]=r.useState(0);return r.useEffect(()=>{o(n=>n+1)},[e]),r.createElement(r.Fragment,null,r.createElement("p",null,"Rendering attribute: ",e),r.createElement("p",null,"Triggered updates: ",i))}};Q.observedAttributes=["counter"];import Mt from"vm";var{hasOwnProperty:A}=Object.prototype;function k(t,e){return t=t.slice(),t.push(e),t}function X(t,e){return e=e.slice(),e.unshift(t),e}var tt=class extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}};function p(t,e,r,i,o){if(!(this instanceof p))try{return new p(t,e,r,i,o)}catch(s){if(!s.avoidNew)throw s;return s.value}typeof t=="string"&&(o=i,i=r,r=e,e=t,t=null);let n=t&&typeof t=="object";if(t=t||{},this.json=t.json||r,this.path=t.path||e,this.resultType=t.resultType||"value",this.flatten=t.flatten||!1,this.wrap=A.call(t,"wrap")?t.wrap:!0,this.sandbox=t.sandbox||{},this.preventEval=t.preventEval||!1,this.parent=t.parent||null,this.parentProperty=t.parentProperty||null,this.callback=t.callback||i||null,this.otherTypeCallback=t.otherTypeCallback||o||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},t.autostart!==!1){let s={path:n?t.path:e};n?"json"in t&&(s.json=t.json):s.json=r;let a=this.evaluate(s);if(!a||typeof a!="object")throw new tt(a);return a}}p.prototype.evaluate=function(t,e,r,i){let o=this.parent,n=this.parentProperty,{flatten:s,wrap:a}=this;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=i||this.otherTypeCallback,e=e||this.json,t=t||this.path,t&&typeof t=="object"&&!Array.isArray(t)){if(!t.path&&t.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!A.call(t,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:e}=t),s=A.call(t,"flatten")?t.flatten:s,this.currResultType=A.call(t,"resultType")?t.resultType:this.currResultType,this.currSandbox=A.call(t,"sandbox")?t.sandbox:this.currSandbox,a=A.call(t,"wrap")?t.wrap:a,this.currPreventEval=A.call(t,"preventEval")?t.preventEval:this.currPreventEval,r=A.call(t,"callback")?t.callback:r,this.currOtherTypeCallback=A.call(t,"otherTypeCallback")?t.otherTypeCallback:this.currOtherTypeCallback,o=A.call(t,"parent")?t.parent:o,n=A.call(t,"parentProperty")?t.parentProperty:n,t=t.path}if(o=o||null,n=n||null,Array.isArray(t)&&(t=p.toPathString(t)),!t&&t!==""||!e)return;let l=p.toPathArray(t);l[0]==="$"&&l.length>1&&l.shift(),this._hasParentSelector=null;let d=this._trace(l,e,["$"],o,n,r).filter(function(h){return h&&!h.isParentSelector});return d.length?!a&&d.length===1&&!d[0].hasArrExpr?this._getPreferredOutput(d[0]):d.reduce((h,f)=>{let u=this._getPreferredOutput(f);return s&&Array.isArray(u)?h=h.concat(u):h.push(u),h},[]):a?[]:void 0};p.prototype._getPreferredOutput=function(t){let e=this.currResultType;switch(e){case"all":{let r=Array.isArray(t.path)?t.path:p.toPathArray(t.path);return t.pointer=p.toPointer(r),t.path=typeof t.path=="string"?t.path:p.toPathString(t.path),t}case"value":case"parent":case"parentProperty":return t[e];case"path":return p.toPathString(t[e]);case"pointer":return p.toPointer(t.path);default:throw new TypeError("Unknown result type")}};p.prototype._handleCallback=function(t,e,r){if(e){let i=this._getPreferredOutput(t);t.path=typeof t.path=="string"?t.path:p.toPathString(t.path),e(i,r,t)}};p.prototype._trace=function(t,e,r,i,o,n,s,a){let l;if(!t.length)return l={path:r,value:e,parent:i,parentProperty:o,hasArrExpr:s},this._handleCallback(l,n,"value"),l;let d=t[0],h=t.slice(1),f=[];function u(c){Array.isArray(c)?c.forEach(m=>{f.push(m)}):f.push(c)}if((typeof d!="string"||a)&&e&&A.call(e,d))u(this._trace(h,e[d],k(r,d),e,d,n,s));else if(d==="*")this._walk(e,c=>{u(this._trace(h,e[c],k(r,c),e,c,n,!0,!0))});else if(d==="..")u(this._trace(h,e,r,i,o,n,s)),this._walk(e,c=>{typeof e[c]=="object"&&u(this._trace(t.slice(),e[c],k(r,c),e,c,n,!0))});else{if(d==="^")return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:h,isParentSelector:!0};if(d==="~")return l={path:k(r,d),value:o,parent:i,parentProperty:null},this._handleCallback(l,n,"property"),l;if(d==="$")u(this._trace(h,e,r,null,null,n,s));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(d))u(this._slice(d,h,e,r,i,o,n));else if(d.indexOf("?(")===0){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");let c=d.replace(/^\?\((.*?)\)$/u,"$1");this._walk(e,m=>{this._eval(c,e[m],m,r,i,o)&&u(this._trace(h,e[m],k(r,m),e,m,n,!0))})}else if(d[0]==="("){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");u(this._trace(X(this._eval(d,e,r[r.length-1],r.slice(0,-1),i,o),h),e,r,i,o,n,s))}else if(d[0]==="@"){let c=!1,m=d.slice(1,-2);switch(m){case"scalar":(!e||!["object","function"].includes(typeof e))&&(c=!0);break;case"boolean":case"string":case"undefined":case"function":typeof e===m&&(c=!0);break;case"integer":Number.isFinite(e)&&!(e%1)&&(c=!0);break;case"number":Number.isFinite(e)&&(c=!0);break;case"nonFinite":typeof e=="number"&&!Number.isFinite(e)&&(c=!0);break;case"object":e&&typeof e===m&&(c=!0);break;case"array":Array.isArray(e)&&(c=!0);break;case"other":c=this.currOtherTypeCallback(e,r,i,o);break;case"null":e===null&&(c=!0);break;default:throw new TypeError("Unknown value type "+m)}if(c)return l={path:r,value:e,parent:i,parentProperty:o},this._handleCallback(l,n,"value"),l}else if(d[0]==="`"&&e&&A.call(e,d.slice(1))){let c=d.slice(1);u(this._trace(h,e[c],k(r,c),e,c,n,s,!0))}else if(d.includes(",")){let c=d.split(",");for(let m of c)u(this._trace(X(m,h),e,r,i,o,n,!0))}else!a&&e&&A.call(e,d)&&u(this._trace(h,e[d],k(r,d),e,d,n,s,!0))}if(this._hasParentSelector)for(let c=0;c<f.length;c++){let m=f[c];if(m&&m.isParentSelector){let E=this._trace(m.expr,e,m.path,i,o,n,s);if(Array.isArray(E)){f[c]=E[0];let S=E.length;for(let v=1;v<S;v++)c++,f.splice(c,0,E[v])}else f[c]=E}}return f};p.prototype._walk=function(t,e){if(Array.isArray(t)){let r=t.length;for(let i=0;i<r;i++)e(i)}else t&&typeof t=="object"&&Object.keys(t).forEach(r=>{e(r)})};p.prototype._slice=function(t,e,r,i,o,n,s){if(!Array.isArray(r))return;let a=r.length,l=t.split(":"),d=l[2]&&Number.parseInt(l[2])||1,h=l[0]&&Number.parseInt(l[0])||0,f=l[1]&&Number.parseInt(l[1])||a;h=h<0?Math.max(0,h+a):Math.min(a,h),f=f<0?Math.max(0,f+a):Math.min(a,f);let u=[];for(let c=h;c<f;c+=d)this._trace(X(c,e),r,i,o,n,s,!0).forEach(E=>{u.push(E)});return u};p.prototype._eval=function(t,e,r,i,o,n){this.currSandbox._$_parentProperty=n,this.currSandbox._$_parent=o,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=e;let s=t.includes("@path");s&&(this.currSandbox._$_path=p.toPathString(i.concat([r])));let a="script:"+t;if(!p.cache[a]){let l=t.replace(/@parentProperty/gu,"_$_parentProperty").replace(/@parent/gu,"_$_parent").replace(/@property/gu,"_$_property").replace(/@root/gu,"_$_root").replace(/@([.\s)[])/gu,"_$_v$1");s&&(l=l.replace(/@path/gu,"_$_path")),p.cache[a]=new this.vm.Script(l)}try{return p.cache[a].runInNewContext(this.currSandbox)}catch(l){throw new Error("jsonPath: "+l.message+": "+t)}};p.cache={};p.toPathString=function(t){let e=t,r=e.length,i="$";for(let o=1;o<r;o++)/^(~|\^|@.*?\(\))$/u.test(e[o])||(i+=/^[0-9*]+$/u.test(e[o])?"["+e[o]+"]":"['"+e[o]+"']");return i};p.toPointer=function(t){let e=t,r=e.length,i="";for(let o=1;o<r;o++)/^(~|\^|@.*?\(\))$/u.test(e[o])||(i+="/"+e[o].toString().replace(/~/gu,"~0").replace(/\//gu,"~1"));return i};p.toPathArray=function(t){let{cache:e}=p;if(e[t])return e[t].concat();let r=[],o=t.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replace(/[['](\??\(.*?\))[\]']/gu,function(n,s){return"[#"+(r.push(s)-1)+"]"}).replace(/\[['"]([^'\]]*)['"]\]/gu,function(n,s){return"['"+s.replace(/\./gu,"%@%").replace(/~/gu,"%%@@%%")+"']"}).replace(/~/gu,";~;").replace(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replace(/%@%/gu,".").replace(/%%@@%%/gu,"~").replace(/(?:;)?(\^+)(?:;)?/gu,function(n,s){return";"+s.split("").join(";")+";"}).replace(/;;;|;;/gu,";..;").replace(/;$|'?\]|'$/gu,"").split(";").map(function(n){let s=n.match(/#(\d+)/u);return!s||!s[1]?n:r[s[1]]});return e[t]=o,e[t].concat()};p.prototype.vm=Mt;function Ot(t){return t.replace(/(\[[^\]\[]+\]|\.\*)$/g,"")}function pt(t){return Ot(t)+".*"}function rt(t,e,r=!1,i=t){var o=e;let n=Object.keys(t).sort((a,l)=>l.length-a.length);for(let a of n)if(e.startsWith(a)){if(a==e){if(r)return t[a];continue}o=e.substring(a.length+1),i=t[a];break}var s=p({path:o,json:i});return Array.isArray(s)&&(s==null?void 0:s.length)==0&&(s=[o.replace(/^.*?\./,"_."),o.replace(/^.*?\./,""),o.replace(/^([^.]+).*?\.\$\./,"$1."),o.replace(/^.*?\.\$\./,"_."),o.replace(/^.*?\.\$\./,""),o.replace(/^[^.]+$/,"_")].filter((a,l,d)=>d.indexOf(a)===l).reduce((a,l)=>a.length>0?a:p({path:l,json:i}),[])),r&&Array.isArray(s)?s[0]:s}function et(t,e={},r){return r?`<${r}${Object.entries(e).map(([i,o])=>o!=null&&` ${i}="${o}"`).filter(Boolean).join("")}>${D(t)}</${r}>`.replace(/^<([a-z0-9][^>]*)><\/[^>]+>$/,"<$1 />"):D(t)}function D(t){var e;if(Array.isArray(t))return t.map(D).join(`
|
|
2
|
-
`).trim();if(typeof t=="string")return t;if(t==null)return"";switch(t.type){case"heading":let{level:r,...i}=t.attrs;return et(t.content,i,"h"+r);case"text":return(t.marks||[]).reduce((o,n)=>et(o,n.attrs,{link:"a",bold:"strong",italic:"em",strike:"s",underline:"u"}[n.type]),(e=t.text)===null||e===void 0?void 0:e.replace(/\s+/," "));default:return et(t.content||t.text,t.attrs,{bulletList:"ul",orderedList:"ol",listItem:"li",horizontalRule:"hr",paragraph:"p",codeBlock:"code",blockquote:"blockquote"}[t.type])}}function Lt(t){let e=new t.ownerDocument.defaultView.MutationObserver(r=>{r.forEach(i=>{let o=i.target,n=o.getAttribute("data-embed-src");n&&I(o,n),i.addedNodes&&i.addedNodes.forEach(s=>{s.nodeType==1&&Dt(s,!1)})})});return e.observe(t,{attributes:!0,subtree:!0,childList:!0}),e}function Dt(t,e=!0){let r=t.querySelectorAll("[data-embed-src]");for(var i=0;i<r.length;i++){let o=r[i];I(o,o.getAttribute("data-embed-src"))}if(e)return Lt(t)}function I(t,e){for(var r=t;r;r=r.parentElement)if(!r.parentElement){let o=r.querySelectorAll("script");for(var i=0;i<o.length;i++)if(o[i].getAttribute("src")==e)return!0;r.tagName=="HTML"&&(r=r.querySelector("head")||r);let n=r.ownerDocument.createElement("script");n.type="module",n.src=e,r.appendChild(n);break}}function mt(t){let e=t.getAttribute("data-path-scope");for(var r=0,i=t;i=i.previousElementSibling;)i.getAttribute("data-path-scope")==e&&r++;return r}function $t(t,e,r){let i=t.getAttribute("data-path-scope");if(i==null)return;var o=mt(t);if(o!=0)return;let n=t.parentElement;if(n!=null){e==0?t.setAttribute("hidden","hidden"):t.getAttribute("hidden")!=null&&t.removeAttribute("hidden");for(var s=o+1,a=t,l=t;l=l.nextElementSibling;)l.getAttribute("data-path-scope")==i&&(s++,a=l);for(var d=s;d<e;d++)n.insertBefore(a.cloneNode(!0),a.nextElementSibling);for(var d=Math.max(1,e);d<s;d++)a=a.previousElementSibling,n.removeChild(a.nextElementSibling)}}function $(t,e,r,i){var o;if(t){var n=t;(r==null?void 0:r.type)=="doc"&&Array.isArray(r.content)&&(r=D(r)),i!=null&&i.processValue&&(r=i==null?void 0:i.processValue(t,e,r));var s=e.replace("data-path-","");if(e=="data-path-src")n=t.tagName=="IMG"?t:t.querySelector("img, video");else if(e=="data-path-href")n=t.querySelector("a")||t.closest("a");else if(e=="data-path-alt")n=t.querySelector("img, picture");else if(e=="data-path-hidden")r=r?null:!0;else if(e=="data-path"||e=="data-embed-html"||e=="html")s="innerHTML";else if(e=="data-embed-src")I(t,r);else if(e=="data-path-attributes"){let f=((o=t.getAttribute("data-attributes-keys"))===null||o===void 0?void 0:o.split(",").filter(Boolean))||[];if(!Array.isArray(r))for(var a in r){var l=r[a];$(t,a,typeof l=="object"&&l?JSON.stringify(l):l,i)}for(var d=0;d<f.length;d++)(r==null||!(f[d]in r))&&$(t,f[d],null,i);$(t,"data-attributes-keys",Object.keys(r||{}).join(","));return}if(typeof r=="boolean"&&(r=r?"":null),!!n){var h=String(t.getAttribute("data-path-placeholder")||n[s]);r!=null?s=="innerHTML"?n.innerHTML!=r&&(n.innerHTML=r):n.getAttribute(s)!=r&&n.setAttribute(s,r):s=="innerHTML"?n.innerHTML=h:n.removeAttribute(s)}}}var ft=["data-attributes-keys","data-path-attributes","data-path-scope"];function x(t,e,r,i){var o,n,s;let a=t;if(i||(e=((o=r==null?void 0:r.processData)===null||o===void 0?void 0:o.call(r,a,e))||e),a.nodeType==1){let h=a.getAttribute("data-path-scope");if(h){let u=mt(a),c=rt(e,h,!1)||[];u==0&&$t(a,((n=r==null?void 0:r.shouldRepeat)===null||n===void 0?void 0:n.call(r,a,c))===!1?1:c.length,r),e={...e,[pt(h)]:c[u]}}let f=Array.prototype.slice.call(a.attributes).sort((u,c)=>ft.indexOf(u.name)-ft.indexOf(c.name));for(var l=0;l<f.length;l++){let{name:u,value:c}=f[l];u.startsWith("data-path")&&u!="data-path-scope"&&$(a,u,rt(e,c,!0),r),u=="data-embed-src"&&$(a,u,a.getAttribute(u),r)}}for(var l=0,d;d=a.childNodes[l++];)yt(d)&&x(d,e,r,!0);return i||(s=r==null?void 0:r.onRender)===null||s===void 0||s.call(r,a,e),a}function yt(t){return t.nodeType==1}function N(t,e,r,i){var o;let n=((o=i==null?void 0:i.processTemplate)===null||o===void 0?void 0:o.call(i,t,e,r))||e;if(t.innerHTML=n,t.classList.add("-feaas"),(t.closest(".component.feaas")||t).className.includes("-theme--"))for(var a=0,l;l=t.childNodes[a++];)yt(l)&&(l.className=l.className.replace(/(\s|^)-theme--[^\s]+\s*/g,"$1"));return x(t,r,i)}function gt(t,e,r,i=!1){var o;let n=((o=r==null?void 0:r.processTemplate)===null||o===void 0?void 0:o.call(r,null,t,e))||t;if(typeof document=="undefined"||i){let{parseHTML:s}=Pt("linkedom"),{document:a}=s(n);return x(a,e,r).toString()}else{let s=document.createElement("div");return s.innerHTML=n,x(s,e,r),s.innerHTML}}var bt=["initial","check","updated"],B={};function ge(){B={}}async function vt(t,e,r,i,o=B){return T({url:t,options:e,validator:r,callback:i,cache:o}).then(j).then(n=>n.response)}function Nt(t,e=!1){let r=String(t).replace("?head","");var i=B[r];return!i&&!e&&(i=B[r]={phase:null,initial:_(),check:_(),updated:_(),final:_()}),i}async function T({url:t,options:e,validator:r,callback:i,cache:o},n="initial"){let s=new Date;if(o!=null){var a=Nt(t);if(bt.indexOf(a.phase)>=bt.indexOf(n))var l=a[n];else a.phase=n}let d=await(l||fetch(t,e));if(!l&&a&&(d.ok?a[n].resolve(d):a[n].reject(new Error("Fetch failed"))),!d.ok)throw new Error("Fetch failed");if((r==null?void 0:r(d))===!1)throw new Error("Response is not valid");let h=new Date(d.headers.get("date"))<s||l&&n=="initial"&&(a.phase=="updated"||a.phase=="check");return await(i==null?void 0:i(d,n,h)),{url:t,options:e,isCached:h,response:d,validator:r,callback:i,cache:o}}async function j(t){let{url:e,isCached:r,options:i,validator:o,response:n,cache:s}=t;if(r){let{response:a}=await T({url:e+"?head",options:{...i,method:"HEAD",cache:"no-cache"},validator:o,cache:s},"check");if(a.headers.get("last-modified")!=n.headers.get("last-modified"))return it(t)}return t}async function it(t){return T({...t,options:{...t.options,cache:"reload"}},"updated")}var R="https://feaas.blob.core.windows.net";function W(t){let e=t.match(/^(?:(.*?)\/components)?\/?([^\/]+)\/([^\/]+)(?:\/([^\/]+)(?:\/(published|staged|saved|\d+)(?:\.html?)?)?)?$/);if(e){var[,r,i,o,n,s]=e;return{cdn:r,library:i,component:o,version:n,revision:s}}}function Ae(t){if(!t||!t.library||!t.component)throw new Error("Component requires `library` and `component` properties");return`${t.cdn&&t.cdn!=R?`${t.cdn}/components`:""}/${t.library}/${t.component}/${!t.version||t.version=="responsive"&&(!t.revision||t.revision=="published")?"":t.version}/${!t.revision||t.revision=="published"?"":t.revision}`.replace(/(^\/|\/$|\/\/)(?!.+\/components\/)/g,"")}function Ee(t){return`${t.cdn&&t.cdn!=R?`${t.cdn}/styles/`:""}${t.library}/${!t.revision||t.revision=="published"?"":t.revision}`.replace(/\/$|\/\/(?!.+\/styles\/)/g,"")}function ot(t){let e=t.match(/^(?:(.*?)\/styles\/)?([^\/]+)(?:\/(published|staged|saved|\d+)(?:.css)?)?$/);if(e){var[,r,i,o]=e;return{cdn:r,library:i,revision:o}}else{let n=W(t);if(n){var{cdn:r,library:i,revision:o}=n;return o!=null&&o.match(/\d/)&&(o=void 0),{cdn:r,library:i,revision:o}}}}function At(t){return typeof t=="string"&&(t={src:t}),"src"in t&&(t={...W(t.src)}),`${t.cdn||t.hostname||R}/components/${t.library}/${t.component}/${t.version}/${t.revision||"published"}.html`}function H(t){return typeof t=="string"&&(t={src:t}),"src"in t&&(t={...ot(t.src)}),`${t.cdn||t.hostname||R}/styles/${t.library}/${t.revision||"published"}.css`}async function F(t,e,r=!1){let i=a=>a.headers.get("x-ms-meta-versionDeletedAt")==null,o=a=>a.clone().text().then(e),n=await Promise.all([t.instance&&T({options:{headers:{Accept:"text/html"},credentials:"omit"},url:At({...t,version:t.instance}),validator:i}).catch(a=>a),T({url:At(t),validator:i}).catch(a=>a)]),s=n.find(a=>a&&"isCached"in a&&a);if(!s||s instanceof Error)throw n.find(l=>l&&l instanceof Error)||new Error("Can not fetch component");return n[0]==s&&console.log("Using fork!",n),await o(s.response),r?s:j({...s,callback:o}).catch(a=>{if(n[0]==s&&(it({...s,callback:null,validator:null}),console.log("Fork was deleted"),!(n[1]instanceof Error)))return o(n[1].response),j({...n[1],callback:o});throw a})}async function Ce(t){typeof t=="string"&&(t={src:t});var e;let{response:r}=await F(t,i=>{e=i},!0);return{...t,template:e,lastModified:r.headers.get("last-modified")}}async function nt(t,e){return typeof t=="string"&&(t={src:t}),vt(H(t),{headers:{Accept:"text/css"},credentials:"omit"},r=>r.headers.get("x-ms-meta-deletedAt")==null,(r,i)=>r.clone().text().then(o=>e(o,i)))}function Re(t,e){return Ft(t,e||(e=document.createElement("style"))),e}function Ft(t,e){return e||(e=document.createElement("style")),nt(t,(r,i)=>{e.textContent=r}).then(()=>e)}function st(t,e){var r=Ut(t);if(!r)var i=It(t);return nt(t,(o,n)=>{i&&(i.textContent=o),e==null||e(o,n)}).then(()=>r||i)}function Et(t){return new Promise((e,r)=>{st(t,e).catch(r)})}function Ut(t){return document.head.querySelector(`style[data-href="${H(t)}"]`)}function It(t){let e=H(t),r=document.createElement("style");return r.setAttribute("data-href",e),document.head.appendChild(r),r}function Pe(t,e){let r=document.createElement("div");r.innerHTML=t;let i=document.createDocumentFragment();for(;r.firstChild;)i.appendChild(r.firstChild);return x(i,e),r}function Te(t,e){return Bt(t,e||(e=document.createElement("div"))),e}async function Bt(t,e){return e||(e=document.createElement("div")),e.childNodes.length?x(e,t.data,t):"template"in t?N(e,t.template,t.data,t):F(t,r=>N(e,r,t.data,t)).then(()=>e)}function jt(t=this){var e,r,i,o,n,s,a,l;let d,h=t.getAttribute("src");if(h){let v=W(h);if(!v)throw new Error(`Could not parse FEAAS Component source: ${h}`);var{cdn:f,library:u,component:c,version:m,revision:E}=v}let S=t.getAttribute("data");if(S!=null&&S!="")try{d=typeof S=="string"?JSON.parse(S):{}}catch(v){}return{data:d||{},cdn:(r=(e=t.getContextAttribute("cdn"))!==null&&e!==void 0?e:f)!==null&&r!==void 0?r:R,library:(i=t.getAttribute("library"))!==null&&i!==void 0?i:u,component:(o=t.getAttribute("component"))!==null&&o!==void 0?o:c,version:(s=(n=t.getAttribute("version"))!==null&&n!==void 0?n:m)!==null&&s!==void 0?s:"responsive",revision:(l=(a=t.getAttribute("revision"))!==null&&a!==void 0?a:E)!==null&&l!==void 0?l:"published",hostname:t.getAttribute("hostname"),template:t.getAttribute("template"),instance:t.getAttribute("instance"),editable:t.getAttribute("editable")!=null,suspended:t.getAttribute("suspended")!=null,lastModified:t.getAttribute("last-modified"),withStylesheet:t.getAttribute("with-stylesheet")!="false"}}var z=class extends b{setData(e){this.set({data:e})}getProps(){return jt(this)}attributeChangedCallback(e,r,i){r!==i&&((e=="library"||e=="component"||e=="revision"||e=="version")&&(this.payload=void 0),this.needsRefresh=!0,super.attributeChangedCallback(e,r,i))}getEditor(){var e;return(e=document.querySelector("feaas-context"))===null||e===void 0?void 0:e.refs.editor}constructor(){super(),this.defaultProps={cdn:R,revision:"published",version:"responsive",withStylesheet:!0,editable:!1,suspended:!1},this.onLoad=e=>{this.payload=e,this.advance()},this.addEventListener("click",()=>{this.props.editable&&this.edit()})}edit(){let e=this.getEditor();if(e!=null&&e.setTarget(this))return e.open(),!0}getOriginal(){let e=this.getAttribute("data-path-scope");if(e){for(var r=this;(r=r.previousElementSibling)&&r.getAttribute("data-path-scope")==e;)var i=r;return i}}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null&&this.props.component!=null&&this.props.version!=null}async load(){if(!this.getOriginal()){if(this.props.withStylesheet)var e=Et({...this.props,revision:"published"}).then(()=>{e=null,this.payload&&this.onLoad(this.payload)});return Promise.all([e,F(this.props,r=>{this.payload=r,e||this.onLoad(r)})]).then(()=>this.payload)}}update(){if(Array.from(this.children).filter(e=>e.tagName!="BR").length>0&&!this.needsRefresh)x(this,this.props.data);else{if(this.needsRefresh=!0,this.getOriginal())return;N(this,this.payload,this.props.data)}}};z.observedAttributes=["library","component","version","revision","hostname","cdn","template","data","instance","editable","with-stylesheet"];z.register("feaas-component");function Wt(t=this){return{opacity:t!=null&&t.getAttribute("opacity")?parseFloat(t==null?void 0:t.getAttribute("opacity")):1,hidden:(t==null?void 0:t.getAttribute("hidden"))!=null}}var V=class extends b{constructor(){super(...arguments),this.defaultProps={hidden:!1}}getProps(){return Wt(this)}attributeChangedCallback(e,r,i){if(r!==i)return e=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),i?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all")),super.attributeChangedCallback(e,r,i)}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 Pt=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});function _(t,e=r=>{}){var r;let i=()=>{var o,n;let s=new Promise((l,d)=>{o=h=>{t==null||t(h),l(h)},n=d});var a=Object.assign(s,{resolve:o,reject:n,restart:i,first:r});return r=a,a.catch(e),a};return i()}var Tt=typeof HTMLElement=="undefined"?typeof windowJSDOM!="undefined"?windowJSDOM.HTMLElement:class{}:HTMLElement,b=class extends Tt{getProps(e){return{}}constructor(){super(),this.defaultProps={},this.connected=!1,this.refs={},this.descendants=[],this.whenLoaded=_(e=>{this.payload=e}),this.whenRendered=_(()=>this.initialized=!0,()=>cancelAnimationFrame(this.nextRender)),this.addEventListener("feaasMount",this),this.addEventListener("feaasUnmount",this)}getRoot(){return this}attributeChangedCallback(e,r,i){this.set()}connectedCallback(){this.mount()}disconnectedCallback(){this.unmount()}mount(){try{let e=this.getParent();if(e&&!e.connected||this.connected)return;this.connected=!0,this.log("FEAAS: Mount",this.tagName,this),this.dispatchEvent(new Event("feaasMount",{bubbles:!0,composed:!0})),this.getElements().map(r=>{var i;return(i=r.mount)===null||i===void 0?void 0:i.call(r)}),this.set()}catch(e){this.onError(e)}}log(...e){console.log(...e)}unmount(){this.connected&&(this.log("FEAAS: Unmount",this),this.dispatchEvent(new Event("feaasUnmount",{bubbles:!0,composed:!0})),this.connected=!1)}getParent(e=!0){for(var r=this;r=r.parentElement||(r.parentNode instanceof ShadowRoot?r.parentNode.host:null);)if(!e||r.tagName.startsWith("FEAAS-"))return r}getElements(e=this.getRoot(),r=!0){return Array.from(e.querySelectorAll("*")).map(i=>[!r||i.tagName.startsWith("FEAAS-")?i:null,i.shadowRoot?this.getElements(i.shadowRoot,r):null]).flat().filter(Boolean)}handleEvent(e){let r=e.composedPath()[0];switch(e.type){case"feaasMount":r!=this&&this.nestedCallback(r);break;case"feaasUnmount":r!=this&&this.unnestedCallback(r);break}}unnestedCallback(e){let r=this.descendants.indexOf(e);r!=-1&&(this.log("FEAAS: Unnest",this,e),this.descendants.splice(r,-1),this.refs[e.getComponentName()]=null,e.refs.parent==this&&(e.refs.parent=null),e.refs.top==this&&(e.refs.top=e.refs.parent))}nestedCallback(e){var r,i;if(this.descendants.indexOf(e)==-1&&(this.descendants.push(e),this.log("FEAAS: Nest",this,e),this.refs[e.getComponentName()]=e,e.refs.top=this,(r=e.refs).parent||(r.parent=this),e.render))for(var n=e.refs.parent;n;n=n.refs.parent)n.render&&((i=e.refs).parentReact||(i.parentReact=n),e.refs.topReact=n)}getComponentName(){return this.tagName.replace("FEAAS-","").toLowerCase()}isReadyToLoad(){return this.payload===void 0&&this.getAttribute("hidden")==null}onError(e,r="uncaught",i=!1){let o=new CustomEvent("feaasError",{bubbles:!0,composed:!0,detail:e});if(this.dispatchEvent(o),this.whenLoaded.reject(e),!o.defaultPrevented&&!i){this.whenRendered.reject(e);try{this.unmount()}catch(n){}return!0}return!1}shouldUpdateOnLoad(){return!0}async advance(){try{if(this.payload===void 0){if(!this.isReadyToLoad())return;this.payload=null,this.dispatchEvent(new Event("feaasLoad",{bubbles:!0,composed:!0}));let e=await this.load().catch(r=>{throw this.payload=void 0,r});if(this.whenLoaded.resolve(e),this.onLoad)return}else if(this.payload==null)return;this.flush(),this.whenRendered.resolve(this)}catch(e){this.onError(e)}}flush(){var e,r;let i=(r=(e=this.payload)===null||e===void 0?void 0:e.ReactDOM)===null||r===void 0?void 0:r.flushSync;i?i(()=>this.update()):this.update()}load(){return Promise.resolve(null)}update(){var e,r,i;if(this.payload==null||!this.render)return;let{React:o,ReactDOM:n,ReactDOMClient:s}=this.payload||{};if(!o)throw new Error(`${this.tagName}: React is not present in payload`);if(!n)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())):n.render(this.getReactElement(),this.getReactRootElement()):this.forceUpdateReact?(e=this.forceUpdateReact)===null||e===void 0||e.call(this):(i=(r=this.refs.topReact).forceUpdateReact)===null||i===void 0||i.call(r)}invokeReactRendering(){let{React:e,ReactDOM:r}=this.payload||{};if(!this.connected)return null;let i=this.descendants.filter(o=>o.refs.parentReact==this&&o.payload).map((o,n)=>this.getReactElement(o));return this.render({...this.props,children:i},this.payload)}getReactErrorBoundary(e=this,r=e.tagName){if(this.reactErrorBoundary)return this.reactErrorBoundary;let{React:i,ReactDOM:o}=e.payload||{};return this.reactErrorBoundary||(this.reactErrorBoundary=class extends i.Component{constructor(){super(...arguments),this.state={error:null}}static getDerivedStateFromError(s){return{error:s}}componentDidCatch(s,a){console.error(`FEAAS: ${e.tagName} Error:`,s,a),e.onError(s,"react")}render(){if(!this.state.error)return this.props.children}})}getReactElement(e=this,r){let{React:i,ReactDOM:o}=e.payload||{},n=this.getReactErrorBoundary(),s=this.getReactWrapper(e);return i.createElement(n,{key:e.tagName+"-"+e.getUID(),slot:e.getAttribute("slot")},i.createElement(s,null))}getReactWrapper(e=this,r=e.tagName){if(e.reactWrapper)return e.reactWrapper;let{React:i,ReactDOM:o}=e.payload||{};return e.reactWrapper=n=>{if(e.render){let[s,a]=i.useReducer(l=>l+1,0);return e.forceUpdateReact=a,o.createPortal(i.createElement(i.Fragment,null,e.invokeReactRendering()),e.getReactRootElement())}else return e.update()},Object.assign(e.reactWrapper,{key:e.tagName+"-"+e.getUID(),displayName:r}),e.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(e){try{this.scheduleRender(),this.overrides={...this.overrides,...e},this.props={...this.getProps(),...this.overrides};for(var r in this.props){let i=this.props[r],o=r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();i==null||i===this.defaultProps[r]?this.removeAttribute(o):(typeof i=="string"||typeof i=="number"||typeof i=="boolean")&&this.getAttribute(o)!=String(i)&&this.setAttribute(o,String(i))}}catch(i){this.whenRendered.reject(i),this.onError(i,"set")}return this}import(e){return import( /*@vite-ignore*/ /* webpackIgnore: true */ e)}scheduleRender(){this.nextRender==null&&(this.whenRendered=this.whenRendered.restart()),cancelAnimationFrame(this.nextRender),this.nextRender=requestAnimationFrame(()=>{this.nextRender=null,this.advance().catch(e=>{})})}formatURL(e,r){return typeof e=="string"&&e.match(/^\/[^\/]/)?r+e:e}getContextAttribute(e,r=this){for(var i=this;i=i.parentElement||(i.parentNode instanceof ShadowRoot?i.parentNode.host:null);)if(i.getAttribute(e)!=null)return i.getAttribute(e);return this.getAttribute(e)}static register(e,r){r==null&&(r=typeof window!="undefined"?window:null),r&&!r.customElements.get(e)&&r.customElements.define(e,this)}};var P=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(([e,r])=>({React:e,ReactDOM:r}))}render({},{React:e}){return e.createElement(e.Fragment,null)}},Q=class extends P{constructor(){super(...arguments),this.useShadowRoot=!0}getProps(){return{counter:parseFloat(this.getAttribute("counter"))}}render({counter:e},{React:r}){let[i,o]=r.useState(0);return r.useEffect(()=>{o(n=>n+1)},[e]),r.createElement(r.Fragment,null,r.createElement("p",null,"Rendering attribute: ",e),r.createElement("p",null,"Triggered updates: ",i))}};Q.observedAttributes=["counter"];import Mt from"vm";var{hasOwnProperty:A}=Object.prototype;function k(t,e){return t=t.slice(),t.push(e),t}function X(t,e){return e=e.slice(),e.unshift(t),e}var tt=class extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}};function p(t,e,r,i,o){if(!(this instanceof p))try{return new p(t,e,r,i,o)}catch(s){if(!s.avoidNew)throw s;return s.value}typeof t=="string"&&(o=i,i=r,r=e,e=t,t=null);let n=t&&typeof t=="object";if(t=t||{},this.json=t.json||r,this.path=t.path||e,this.resultType=t.resultType||"value",this.flatten=t.flatten||!1,this.wrap=A.call(t,"wrap")?t.wrap:!0,this.sandbox=t.sandbox||{},this.preventEval=t.preventEval||!1,this.parent=t.parent||null,this.parentProperty=t.parentProperty||null,this.callback=t.callback||i||null,this.otherTypeCallback=t.otherTypeCallback||o||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},t.autostart!==!1){let s={path:n?t.path:e};n?"json"in t&&(s.json=t.json):s.json=r;let a=this.evaluate(s);if(!a||typeof a!="object")throw new tt(a);return a}}p.prototype.evaluate=function(t,e,r,i){let o=this.parent,n=this.parentProperty,{flatten:s,wrap:a}=this;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=i||this.otherTypeCallback,e=e||this.json,t=t||this.path,t&&typeof t=="object"&&!Array.isArray(t)){if(!t.path&&t.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!A.call(t,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:e}=t),s=A.call(t,"flatten")?t.flatten:s,this.currResultType=A.call(t,"resultType")?t.resultType:this.currResultType,this.currSandbox=A.call(t,"sandbox")?t.sandbox:this.currSandbox,a=A.call(t,"wrap")?t.wrap:a,this.currPreventEval=A.call(t,"preventEval")?t.preventEval:this.currPreventEval,r=A.call(t,"callback")?t.callback:r,this.currOtherTypeCallback=A.call(t,"otherTypeCallback")?t.otherTypeCallback:this.currOtherTypeCallback,o=A.call(t,"parent")?t.parent:o,n=A.call(t,"parentProperty")?t.parentProperty:n,t=t.path}if(o=o||null,n=n||null,Array.isArray(t)&&(t=p.toPathString(t)),!t&&t!==""||!e)return;let l=p.toPathArray(t);l[0]==="$"&&l.length>1&&l.shift(),this._hasParentSelector=null;let d=this._trace(l,e,["$"],o,n,r).filter(function(h){return h&&!h.isParentSelector});return d.length?!a&&d.length===1&&!d[0].hasArrExpr?this._getPreferredOutput(d[0]):d.reduce((h,f)=>{let u=this._getPreferredOutput(f);return s&&Array.isArray(u)?h=h.concat(u):h.push(u),h},[]):a?[]:void 0};p.prototype._getPreferredOutput=function(t){let e=this.currResultType;switch(e){case"all":{let r=Array.isArray(t.path)?t.path:p.toPathArray(t.path);return t.pointer=p.toPointer(r),t.path=typeof t.path=="string"?t.path:p.toPathString(t.path),t}case"value":case"parent":case"parentProperty":return t[e];case"path":return p.toPathString(t[e]);case"pointer":return p.toPointer(t.path);default:throw new TypeError("Unknown result type")}};p.prototype._handleCallback=function(t,e,r){if(e){let i=this._getPreferredOutput(t);t.path=typeof t.path=="string"?t.path:p.toPathString(t.path),e(i,r,t)}};p.prototype._trace=function(t,e,r,i,o,n,s,a){let l;if(!t.length)return l={path:r,value:e,parent:i,parentProperty:o,hasArrExpr:s},this._handleCallback(l,n,"value"),l;let d=t[0],h=t.slice(1),f=[];function u(c){Array.isArray(c)?c.forEach(m=>{f.push(m)}):f.push(c)}if((typeof d!="string"||a)&&e&&A.call(e,d))u(this._trace(h,e[d],k(r,d),e,d,n,s));else if(d==="*")this._walk(e,c=>{u(this._trace(h,e[c],k(r,c),e,c,n,!0,!0))});else if(d==="..")u(this._trace(h,e,r,i,o,n,s)),this._walk(e,c=>{typeof e[c]=="object"&&u(this._trace(t.slice(),e[c],k(r,c),e,c,n,!0))});else{if(d==="^")return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:h,isParentSelector:!0};if(d==="~")return l={path:k(r,d),value:o,parent:i,parentProperty:null},this._handleCallback(l,n,"property"),l;if(d==="$")u(this._trace(h,e,r,null,null,n,s));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(d))u(this._slice(d,h,e,r,i,o,n));else if(d.indexOf("?(")===0){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");let c=d.replace(/^\?\((.*?)\)$/u,"$1");this._walk(e,m=>{this._eval(c,e[m],m,r,i,o)&&u(this._trace(h,e[m],k(r,m),e,m,n,!0))})}else if(d[0]==="("){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");u(this._trace(X(this._eval(d,e,r[r.length-1],r.slice(0,-1),i,o),h),e,r,i,o,n,s))}else if(d[0]==="@"){let c=!1,m=d.slice(1,-2);switch(m){case"scalar":(!e||!["object","function"].includes(typeof e))&&(c=!0);break;case"boolean":case"string":case"undefined":case"function":typeof e===m&&(c=!0);break;case"integer":Number.isFinite(e)&&!(e%1)&&(c=!0);break;case"number":Number.isFinite(e)&&(c=!0);break;case"nonFinite":typeof e=="number"&&!Number.isFinite(e)&&(c=!0);break;case"object":e&&typeof e===m&&(c=!0);break;case"array":Array.isArray(e)&&(c=!0);break;case"other":c=this.currOtherTypeCallback(e,r,i,o);break;case"null":e===null&&(c=!0);break;default:throw new TypeError("Unknown value type "+m)}if(c)return l={path:r,value:e,parent:i,parentProperty:o},this._handleCallback(l,n,"value"),l}else if(d[0]==="`"&&e&&A.call(e,d.slice(1))){let c=d.slice(1);u(this._trace(h,e[c],k(r,c),e,c,n,s,!0))}else if(d.includes(",")){let c=d.split(",");for(let m of c)u(this._trace(X(m,h),e,r,i,o,n,!0))}else!a&&e&&A.call(e,d)&&u(this._trace(h,e[d],k(r,d),e,d,n,s,!0))}if(this._hasParentSelector)for(let c=0;c<f.length;c++){let m=f[c];if(m&&m.isParentSelector){let E=this._trace(m.expr,e,m.path,i,o,n,s);if(Array.isArray(E)){f[c]=E[0];let S=E.length;for(let v=1;v<S;v++)c++,f.splice(c,0,E[v])}else f[c]=E}}return f};p.prototype._walk=function(t,e){if(Array.isArray(t)){let r=t.length;for(let i=0;i<r;i++)e(i)}else t&&typeof t=="object"&&Object.keys(t).forEach(r=>{e(r)})};p.prototype._slice=function(t,e,r,i,o,n,s){if(!Array.isArray(r))return;let a=r.length,l=t.split(":"),d=l[2]&&Number.parseInt(l[2])||1,h=l[0]&&Number.parseInt(l[0])||0,f=l[1]&&Number.parseInt(l[1])||a;h=h<0?Math.max(0,h+a):Math.min(a,h),f=f<0?Math.max(0,f+a):Math.min(a,f);let u=[];for(let c=h;c<f;c+=d)this._trace(X(c,e),r,i,o,n,s,!0).forEach(E=>{u.push(E)});return u};p.prototype._eval=function(t,e,r,i,o,n){this.currSandbox._$_parentProperty=n,this.currSandbox._$_parent=o,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=e;let s=t.includes("@path");s&&(this.currSandbox._$_path=p.toPathString(i.concat([r])));let a="script:"+t;if(!p.cache[a]){let l=t.replace(/@parentProperty/gu,"_$_parentProperty").replace(/@parent/gu,"_$_parent").replace(/@property/gu,"_$_property").replace(/@root/gu,"_$_root").replace(/@([.\s)[])/gu,"_$_v$1");s&&(l=l.replace(/@path/gu,"_$_path")),p.cache[a]=new this.vm.Script(l)}try{return p.cache[a].runInNewContext(this.currSandbox)}catch(l){throw new Error("jsonPath: "+l.message+": "+t)}};p.cache={};p.toPathString=function(t){let e=t,r=e.length,i="$";for(let o=1;o<r;o++)/^(~|\^|@.*?\(\))$/u.test(e[o])||(i+=/^[0-9*]+$/u.test(e[o])?"["+e[o]+"]":"['"+e[o]+"']");return i};p.toPointer=function(t){let e=t,r=e.length,i="";for(let o=1;o<r;o++)/^(~|\^|@.*?\(\))$/u.test(e[o])||(i+="/"+e[o].toString().replace(/~/gu,"~0").replace(/\//gu,"~1"));return i};p.toPathArray=function(t){let{cache:e}=p;if(e[t])return e[t].concat();let r=[],o=t.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replace(/[['](\??\(.*?\))[\]']/gu,function(n,s){return"[#"+(r.push(s)-1)+"]"}).replace(/\[['"]([^'\]]*)['"]\]/gu,function(n,s){return"['"+s.replace(/\./gu,"%@%").replace(/~/gu,"%%@@%%")+"']"}).replace(/~/gu,";~;").replace(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replace(/%@%/gu,".").replace(/%%@@%%/gu,"~").replace(/(?:;)?(\^+)(?:;)?/gu,function(n,s){return";"+s.split("").join(";")+";"}).replace(/;;;|;;/gu,";..;").replace(/;$|'?\]|'$/gu,"").split(";").map(function(n){let s=n.match(/#(\d+)/u);return!s||!s[1]?n:r[s[1]]});return e[t]=o,e[t].concat()};p.prototype.vm=Mt;function Ot(t){return t.replace(/(\[[^\]\[]+\]|\.\*)$/g,"")}function pt(t){return Ot(t)+".*"}function rt(t,e,r=!1,i=t){var o=e;let n=Object.keys(t).sort((a,l)=>l.length-a.length);for(let a of n)if(e.startsWith(a)){if(a==e){if(r)return t[a];continue}o=e.substring(a.length+1),i=t[a];break}var s=p({path:o,json:i});return Array.isArray(s)&&(s==null?void 0:s.length)==0&&(s=[o.replace(/^.*?\./,"_."),o.replace(/^.*?\./,""),o.replace(/^([^.]+).*?\.\$\./,"$1."),o.replace(/^.*?\.\$\./,"_."),o.replace(/^.*?\.\$\./,""),o.replace(/^[^.]+$/,"_")].filter((a,l,d)=>d.indexOf(a)===l).reduce((a,l)=>a.length>0?a:p({path:l,json:i}),[])),r&&Array.isArray(s)?s[0]:s}function et(t,e={},r){return r?`<${r}${Object.entries(e).map(([i,o])=>o!=null&&` ${i}="${o}"`).filter(Boolean).join("")}>${$(t)}</${r}>`.replace(/^<([a-z0-9][^>]*)><\/[^>]+>$/,"<$1 />"):$(t)}function $(t){var e;if(Array.isArray(t))return t.map($).join(`
|
|
2
|
+
`).trim();if(typeof t=="string")return t;if(t==null)return"";switch(t.type){case"heading":let{level:r,...i}=t.attrs;return et(t.content,i,"h"+r);case"text":return(t.marks||[]).reduce((o,n)=>et(o,n.attrs,{link:"a",bold:"strong",italic:"em",strike:"s",underline:"u"}[n.type]),(e=t.text)===null||e===void 0?void 0:e.replace(/\s+/," "));default:return et(t.content||t.text,t.attrs,{bulletList:"ul",orderedList:"ol",listItem:"li",horizontalRule:"hr",paragraph:"p",codeBlock:"code",blockquote:"blockquote"}[t.type])}}function Lt(t){let e=new t.ownerDocument.defaultView.MutationObserver(r=>{r.forEach(i=>{let o=i.target,n=o.getAttribute("data-embed-src");n&&B(o,n),i.addedNodes&&i.addedNodes.forEach(s=>{s.nodeType==1&&Dt(s,!1)})})});return e.observe(t,{attributes:!0,subtree:!0,childList:!0}),e}function Dt(t,e=!0){let r=t.querySelectorAll("[data-embed-src]");for(var i=0;i<r.length;i++){let o=r[i];B(o,o.getAttribute("data-embed-src"))}if(e)return Lt(t)}function B(t,e){for(var r=t;r;r=r.parentElement)if(!r.parentElement){let o=r.querySelectorAll("script");for(var i=0;i<o.length;i++)if(o[i].getAttribute("src")==e)return!0;r.tagName=="HTML"&&(r=r.querySelector("head")||r);let n=r.ownerDocument.createElement("script");n.type="module",n.src=e,r.appendChild(n);break}}function mt(t){let e=t.getAttribute("data-path-scope");for(var r=0,i=t;i=i.previousElementSibling;)i.getAttribute("data-path-scope")==e&&r++;return r}function $t(t,e,r){let i=t.getAttribute("data-path-scope");if(i==null)return;var o=mt(t);if(o!=0)return;let n=t.parentElement;if(n!=null){e==0?t.setAttribute("hidden","hidden"):t.getAttribute("hidden")!=null&&t.removeAttribute("hidden");for(var s=o+1,a=t,l=t;l=l.nextElementSibling;)l.getAttribute("data-path-scope")==i&&(s++,a=l);for(var d=s;d<e;d++)n.insertBefore(a.cloneNode(!0),a.nextElementSibling);for(var d=Math.max(1,e);d<s;d++)a=a.previousElementSibling,n.removeChild(a.nextElementSibling)}}function N(t,e,r,i){var o;if(t){var n=t;(r==null?void 0:r.type)=="doc"&&Array.isArray(r.content)&&(r=$(r)),i!=null&&i.processValue&&(r=i==null?void 0:i.processValue(t,e,r));var s=e.replace("data-path-","");if(e=="data-path-src")n=t.tagName=="IMG"?t:t.querySelector("img, video");else if(e=="data-path-href")n=t.querySelector("a")||t.closest("a");else if(e=="data-path-alt")n=t.querySelector("img, picture");else if(e=="data-path-hidden")r=r?null:!0;else if(e=="data-path"||e=="data-embed-html"||e=="html")s="innerHTML";else if(e=="data-embed-src")B(t,r);else if(e=="data-path-attributes"){let f=((o=t.getAttribute("data-attributes-keys"))===null||o===void 0?void 0:o.split(",").filter(Boolean))||[];if(!Array.isArray(r))for(var a in r){var l=r[a];N(t,a,typeof l=="object"&&l?JSON.stringify(l):l,i)}for(var d=0;d<f.length;d++)(r==null||!(f[d]in r))&&N(t,f[d],null,i);N(t,"data-attributes-keys",Object.keys(r||{}).join(","));return}if(typeof r=="boolean"&&(r=r?"":null),!!n){var h=String(t.getAttribute("data-path-placeholder")||n[s]);r!=null?s=="innerHTML"?n.innerHTML!=r&&(n.innerHTML=r):n.getAttribute(s)!=r&&n.setAttribute(s,r):s=="innerHTML"?n.innerHTML=h:n.removeAttribute(s)}}}var ft=["data-attributes-keys","data-path-attributes","data-path-scope"];function x(t,e,r,i){var o,n,s;let a=t;if(i||(e=((o=r==null?void 0:r.processData)===null||o===void 0?void 0:o.call(r,a,e))||e),a.nodeType==1){let h=a.getAttribute("data-path-scope");if(h){let u=mt(a),c=rt(e,h,!1)||[];u==0&&$t(a,((n=r==null?void 0:r.shouldRepeat)===null||n===void 0?void 0:n.call(r,a,c))===!1?1:c.length,r),e={...e,[pt(h)]:c[u]}}let f=Array.prototype.slice.call(a.attributes).sort((u,c)=>ft.indexOf(u.name)-ft.indexOf(c.name));for(var l=0;l<f.length;l++){let{name:u,value:c}=f[l];u.startsWith("data-path")&&u!="data-path-scope"&&N(a,u,rt(e,c,!0),r),u=="data-embed-src"&&N(a,u,a.getAttribute(u),r)}}for(var l=0,d;d=a.childNodes[l++];)yt(d)&&x(d,e,r,!0);return i||(s=r==null?void 0:r.onRender)===null||s===void 0||s.call(r,a,e),a}function yt(t){return t.nodeType==1}function F(t,e,r,i){var o;let n=((o=i==null?void 0:i.processTemplate)===null||o===void 0?void 0:o.call(i,t,e,r))||e;if(t.innerHTML=n,t.classList.add("-feaas"),(t.closest(".component.feaas")||t).className.includes("-theme--"))for(var a=0,l;l=t.childNodes[a++];)yt(l)&&(l.className=l.className.replace(/(\s|^)-theme--[^\s]+\s*/g,"$1"));return x(t,r,i)}function gt(t,e,r,i=!1){var o;let n=((o=r==null?void 0:r.processTemplate)===null||o===void 0?void 0:o.call(r,null,t,e))||t;if(typeof document=="undefined"||i){let{parseHTML:s}=Pt("linkedom"),{document:a}=s(n);return x(a,e,r).toString()}else{let s=document.createElement("div");return s.innerHTML=n,x(s,e,r),s.innerHTML}}var bt=["initial","check","updated"],j={};function ge(){j={}}async function vt(t,e,r,i,o=j){return T({url:t,options:e,validator:r,callback:i,cache:o}).then(W).then(n=>n.response)}function Nt(t,e=!1){let r=String(t).replace("?head","");var i=j[r];return!i&&!e&&(i=j[r]={phase:null,initial:_(),check:_(),updated:_(),final:_()}),i}async function T({url:t,options:e,validator:r,callback:i,cache:o},n="initial"){let s=new Date;if(o!=null){var a=Nt(t);if(bt.indexOf(a.phase)>=bt.indexOf(n))var l=a[n];else a.phase=n}let d=await(l||fetch(t,e));if(!l&&a&&(d.ok?a[n].resolve(d):a[n].reject(new Error("Fetch failed"))),!d.ok)throw new Error("Fetch failed");if((r==null?void 0:r(d))===!1)throw new Error("Response is not valid");let h=new Date(d.headers.get("date"))<s||l&&n=="initial"&&(a.phase=="updated"||a.phase=="check");return await(i==null?void 0:i(d,n,h)),{url:t,options:e,isCached:h,response:d,validator:r,callback:i,cache:o}}async function W(t){let{url:e,isCached:r,options:i,validator:o,response:n,cache:s}=t;if(r){let{response:a}=await T({url:e+"?head",options:{...i,method:"HEAD",cache:"no-cache"},validator:o,cache:s},"check");if(a.headers.get("last-modified")!=n.headers.get("last-modified"))return it(t)}return t}async function it(t){return T({...t,options:{...t.options,cache:"reload"}},"updated")}var R="https://feaas.blob.core.windows.net";function M(t){let e=t.match(/^(?:(.*?)\/components)?\/?([^\/]+)\/([^\/]+)(?:\/([^\/]+)(?:\/(published|staged|saved|\d+)(?:\.html?)?)?)?$/);if(e){var[,r,i,o,n,s]=e;return{cdn:r,library:i,component:o,version:n,revision:s}}}function Ae(t){if(!t||!t.library||!t.component)throw new Error("Component requires `library` and `component` properties");return`${t.cdn&&t.cdn!=R?`${t.cdn}/components`:""}/${t.library}/${t.component}/${!t.version||t.version=="responsive"&&(!t.revision||t.revision=="published")?"":t.version}/${!t.revision||t.revision=="published"?"":t.revision}`.replace(/(^\/|\/$|\/\/)(?!.+\/components\/)/g,"")}function Ee(t){return`${t.cdn&&t.cdn!=R?`${t.cdn}/styles/`:""}${t.library}/${!t.revision||t.revision=="published"?"":t.revision}`.replace(/\/$|\/\/(?!.+\/styles\/)/g,"")}function ot(t){let e=t.match(/^(?:(.*?)\/styles\/)?([^\/]+)(?:\/(published|staged|saved|\d+)(?:.css)?)?$/);if(e){var[,r,i,o]=e;return{cdn:r,library:i,revision:o}}else{let n=M(t);if(n){var{cdn:r,library:i,revision:o}=n;return o!=null&&o.match(/\d/)&&(o=void 0),{cdn:r,library:i,revision:o}}}}function At(t){return typeof t=="string"&&(t={src:t}),"src"in t&&(t={...M(t.src)}),`${t.cdn||t.hostname||R}/components/${t.library}/${t.component}/${t.version}/${t.revision||"published"}.html`}function H(t){return typeof t=="string"&&(t={src:t}),"src"in t&&(t={...ot(t.src)}),`${t.cdn||t.hostname||R}/styles/${t.library}/${t.revision||"published"}.css`}async function U(t,e,r=!1){let i=a=>a.headers.get("x-ms-meta-versionDeletedAt")==null,o=a=>a.clone().text().then(e),n=await Promise.all([t.instance&&T({options:{headers:{Accept:"text/html"},credentials:"omit"},url:At({...t,version:t.instance}),validator:i}).catch(a=>a),T({url:At(t),validator:i}).catch(a=>a)]),s=n.find(a=>a&&"isCached"in a&&a);if(!s||s instanceof Error)throw n.find(l=>l&&l instanceof Error)||new Error("Can not fetch component");return n[0]==s&&console.log("Using fork!",n),await o(s.response),r?s:W({...s,callback:o}).catch(a=>{if(n[0]==s&&(it({...s,callback:null,validator:null}),console.log("Fork was deleted"),!(n[1]instanceof Error)))return o(n[1].response),W({...n[1],callback:o});throw a})}async function Ce(t){typeof t=="string"&&(t={src:t});var e;let{response:r}=await U(t,i=>{e=i},!0);return{...t,template:e,lastModified:r.headers.get("last-modified")}}async function nt(t,e){return typeof t=="string"&&(t={src:t}),vt(H(t),{headers:{Accept:"text/css"},credentials:"omit"},r=>r.headers.get("x-ms-meta-deletedAt")==null,(r,i)=>r.clone().text().then(o=>e(o,i)))}function Re(t,e){return Ft(t,e||(e=document.createElement("style"))),e}function Ft(t,e){return e||(e=document.createElement("style")),nt(t,(r,i)=>{e.textContent=r}).then(()=>e)}function st(t,e){var r=Ut(t);if(!r)var i=It(t);return nt(t,(o,n)=>{i&&(i.textContent=o),e==null||e(o,n)}).then(()=>r||i)}function Et(t){return new Promise((e,r)=>{st(t,e).catch(r)})}function Ut(t){return document.head.querySelector(`style[data-href="${H(t)}"]`)}function It(t){let e=H(t),r=document.createElement("style");return r.setAttribute("data-href",e),document.head.appendChild(r),r}function Pe(t,e){let r=document.createElement("div");r.innerHTML=t;let i=document.createDocumentFragment();for(;r.firstChild;)i.appendChild(r.firstChild);return x(i,e),r}function Te(t,e){return Bt(t,e||(e=document.createElement("div"))),e}async function Bt(t,e){return e||(e=document.createElement("div")),e.childNodes.length?x(e,t.data,t):"template"in t?F(e,t.template,t.data,t):U(t,r=>F(e,r,t.data,t)).then(()=>e)}function jt(t=this){var e,r,i,o,n,s,a,l;let d,h=t.getAttribute("src");if(h){let v=M(h);if(!v)throw new Error(`Could not parse FEAAS Component source: ${h}`);var{cdn:f,library:u,component:c,version:m,revision:E}=v}let S=t.getAttribute("data");if(S!=null&&S!="")try{d=typeof S=="string"?JSON.parse(S):{}}catch(v){}return{data:d||{},cdn:(r=(e=t.getContextAttribute("cdn"))!==null&&e!==void 0?e:f)!==null&&r!==void 0?r:R,library:(i=t.getAttribute("library"))!==null&&i!==void 0?i:u,component:(o=t.getAttribute("component"))!==null&&o!==void 0?o:c,version:(s=(n=t.getAttribute("version"))!==null&&n!==void 0?n:m)!==null&&s!==void 0?s:"responsive",revision:(l=(a=t.getAttribute("revision"))!==null&&a!==void 0?a:E)!==null&&l!==void 0?l:"published",hostname:t.getAttribute("hostname"),template:t.getAttribute("template"),instance:t.getAttribute("instance"),editable:t.getAttribute("editable")!=null,suspended:t.getAttribute("suspended")!=null,lastModified:t.getAttribute("last-modified"),withStylesheet:t.getAttribute("with-stylesheet")!="false"}}var z=class extends b{setData(e){this.set({data:e})}getProps(){return jt(this)}attributeChangedCallback(e,r,i){r!==i&&((e=="library"||e=="component"||e=="revision"||e=="version")&&(this.payload=void 0),this.needsRefresh=!0,super.attributeChangedCallback(e,r,i))}getEditor(){var e;return(e=document.querySelector("feaas-context"))===null||e===void 0?void 0:e.refs.editor}constructor(){super(),this.defaultProps={cdn:R,revision:"published",version:"responsive",withStylesheet:!0,editable:!1,suspended:!1},this.onLoad=e=>{this.payload=e,this.advance()},this.addEventListener("click",()=>{this.props.editable&&this.edit()})}edit(){let e=this.getEditor();if(e!=null&&e.setTarget(this))return e.open(),!0}getOriginal(){let e=this.getAttribute("data-path-scope");if(e){for(var r=this;(r=r.previousElementSibling)&&r.getAttribute("data-path-scope")==e;)var i=r;return i}}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null&&this.props.component!=null&&this.props.version!=null}async load(){if(!this.getOriginal()){if(this.props.withStylesheet)var e=Et({...this.props,revision:"published"}).then(()=>{e=null,this.payload&&this.onLoad(this.payload)});return Promise.all([e,U(this.props,r=>{this.payload=r,e||this.onLoad(r)})]).then(()=>this.payload)}}update(){if(Array.from(this.children).filter(e=>e.tagName!="BR").length>0&&!this.needsRefresh)x(this,this.props.data);else{if(this.needsRefresh=!0,this.getOriginal())return;F(this,this.payload,this.props.data)}}};z.observedAttributes=["library","component","version","revision","hostname","cdn","template","data","instance","editable","with-stylesheet"];z.register("feaas-component");function Wt(t=this){return{opacity:t!=null&&t.getAttribute("opacity")?parseFloat(t==null?void 0:t.getAttribute("opacity")):1,hidden:(t==null?void 0:t.getAttribute("hidden"))!=null}}var V=class extends b{constructor(){super(...arguments),this.defaultProps={hidden:!1}}getProps(){return Wt(this)}attributeChangedCallback(e,r,i){if(r!==i)return e=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),i?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all")),super.attributeChangedCallback(e,r,i)}connectedCallback(){this.payload=null,super.connectedCallback(),this.attributeChangedCallback("hidden",this.getAttribute("hidden"),this.getAttribute("hidden")),this.stylesheet=document.createElement("style"),this.stylesheet.textContent=`
|
|
3
3
|
#loader {
|
|
4
4
|
position: absolute;
|
|
5
5
|
top: 0;
|
|
@@ -63,5 +63,5 @@ var Pt=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(
|
|
|
63
63
|
style="animation: 1.5s linear 0s infinite normal none running loader-circular-track"
|
|
64
64
|
></circle>
|
|
65
65
|
</svg>
|
|
66
|
-
</div>`,this.getRoot().appendChild(this.stylesheet),this.getRoot().appendChild(this.loader)}update(){this.loader.style.opacity=String(this.props.opacity)}};V.observedAttributes=["hidden","opacity"];V.register("feaas-loader");function Ht(t=this){var e,r,i,o;let n=t.getAttribute("src");if(n)var{cdn:s,library:a,revision:l}=ot(n);return{library:t==null?void 0:t.getContextAttribute("library"),revision:(r=(e=t==null?void 0:t.getAttribute("revision"))!==null&&e!==void 0?e:l)!==null&&r!==void 0?r:"published",cdn:(o=(i=t==null?void 0:t.getContextAttribute("cdn"))!==null&&i!==void 0?i:t==null?void 0:t.getContextAttribute("hostname"))!==null&&o!==void 0?o:R}}var at=class extends b{constructor(){super(...arguments),this.onLoad=e=>{this.payload=e,this.advance()}}getProps(){return Ht(this)}isReadyToLoad(){return this.props.library!=null&&this.props.revision!=null&&this.props.cdn!=null}load(){return st(this.props,this.onLoad)}};at.register("feaas-stylesheet");var lt;typeof window!="undefined"&&(window.FEAASElement=P,(lt=window.FEAASLoading)!==null&<!==void 0||(window.FEAASLoading=Promise.resolve()));function zt(t){let e=[];if(t){let r=t.ownerDocument.defaultView,i,o;for(;r!==window.top;){i=r.parent;for(let n=0;n<i.frames.length;n++)if(i.frames[n]===r){for(let s of i.document.getElementsByTagName("iframe"))if(s.contentWindow===r){o=s.getBoundingClientRect();let a=s.contentWindow.getComputedStyle(s);e.push({left:o.left+parseInt(a.borderLeftWidth),top:o.top+parseInt(a.borderTopWidth)})}r=i;break}}}return e.reduce((r,i)=>({left:r.left+i.left,top:r.top+i.top}),{left:0,top:0})}function Vt(t=this){var e;return{context:HTMLElement,frontend:t==null?void 0:t.getContextAttribute("frontend"),src:(e=t==null?void 0:t.getAttribute("src"))!==null&&e!==void 0?e:"/editor.js",library:t==null?void 0:t.getAttribute("library"),component:t==null?void 0:t.getAttribute("component"),version:t==null?void 0:t.getAttribute("version"),instance:t==null?void 0:t.getAttribute("instance"),forked:t==null?void 0:t.getAttribute("forked"),revision:(t==null?void 0:t.getAttribute("revision"))||"saved",hidden:(t==null?void 0:t.getAttribute("hidden"))!=null,for:t==null?void 0:t.getAttribute("for"),state:(t==null?void 0:t.getAttribute("state"))||"idle",changed:(t==null?void 0:t.getAttribute("changed"))!=null}}var q=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=(e,r={component:e.getAttribute("component"),version:e.getAttribute("version"),revision:e.getAttribute("revision"),instance:e.getAttribute("instance")})=>{if(!this.closing&&(!this.target||e==null))return this.set(r),this.target=e,!0},this.onChromeMeasureElement=(e,r=e.getBoundingClientRect())=>e.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=e=>{e.memoized.focusable&&(this.framePoint=zt(e.memoized.focusable)),this.chrome&&(this.wrapperRect=this.chrome.positionable.getBoundingClientRect(),this.bodyRect=this.chrome.positionable.ownerDocument.body.parentElement.getBoundingClientRect())},this.onMeasure=()=>{},this.onPosition=({focusable:e,root:r})=>{!this.chrome||this.props.hidden||(e?(this.chrome.wrapper.style.width=e.width+16*2+"px",this.chrome.wrapper.style.height=e.height+16*1+64+"px",this.chrome.wrapper.style.left=e.left-16+"px",this.chrome.wrapper.style.top=e.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=e=>{var r;switch((r=e.data)===null||r===void 0?void 0:r.type){case"feaasEdit":let i=this.getPlaceholder();this.setTarget(i.editable,e.data)&&(this.loader=i.loader,document.body.appendChild(i.clipper),this.editedUID=e.data.id,this.setPlaceholder(),this.open());break;case"feaasMeasurements":this.measurements=e.data.measurements,this.props.hidden||this.setPlaceholder();break}},this.onContentChange=()=>{this.setAttribute("changed","changed"),requestAnimationFrame(()=>{this.setIframeComponentContent()})},this.onClose=()=>{var e;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"),!((e=this.target)===null||e===void 0)&&e.parentNode&&(this.target.outerHTML=this.target.outerHTML),this.setTarget(null,{component:null,version:null,instance:null,revision:null}),this.setEditorContext({isFocused:!1})},this.onVersionStateChange=(e,r)=>{this.versionContext=e,this.setVersionContext=r},this.onEditorStateChange=(e,r)=>{this.editorContext=e,this.setEditorContext=r,e.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 Vt(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(e){this.iframe=e}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 e=this.iframe.clientWidth,r=this.iframe.clientHeight,i=this.iframe.getBoundingClientRect(),o=this.getPlaceholder(),n=document.body.getBoundingClientRect(),s=this.measurements[this.editedUID];s&&(Object.assign(o.clipper.style,{position:"absolute",top:i.top+this.iframe.clientTop-n.top+"px",left:i.left+this.iframe.clientLeft-n.left+"px",width:e+"px",height:r+"px",pointerEvents:"none",zIndex:1,overflow:"hidden"}),Object.assign(o.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(o.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(e,r,i){r!==i&&(e=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),i?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all")),super.attributeChangedCallback(e,r,i))}open(){clearTimeout(this.closing),this.removeAttribute("hidden"),this.removeAttribute("changed"),this.setLoadingState()}shouldFork(e){return e.forkOriginId==null&&this.props.instance!=null}cleanup(){var e;this.placeholder&&((e=this.placeholder.clipper)===null||e===void 0||e.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(e){console.log("Editor is not ready")}setEditorContext(e){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:e,component:r,version:i,instance:o},{Editor:n,VersionStatusList:s,VersionStatusButton:a,Version:l,VersionMenu:d,EditorUIUndo:h,EditorUIMode:f,React:{useEffect:u,useMemo:c,useState:m,useContext:E},Chakra:{HStack:S,Box:v,Button:dt,MenuItem:ct},Chrome:Ct,ReactDOM:Yt,useSDK:wt,useSlots:xt,useModelObserver:Rt,ConfirmationContext:St,VersionContext:Zt}){if(!this.payload)return;let{React:y}=this.payload,{sdk:U}=wt(),[g,ht]=m(),{setConfirm:G}=E(St),M=o||i,_t=U.library;g&&(this.component=g),u(()=>{if(this.props.hidden)return;let w=_t.components.getItem(r).clone();return w.versions.search({ids:[i,o].filter(Boolean),componentIds:[r]}).then(Y=>{w.versions.setItems(Y);let C=w.findVersion(o,["staged","published"]),L=w.findVersion(i,["staged","published"]);if(C)C.deletedAt?(C.getDraft().changeAndNotify(L.toProperties()).restore(),console.error("FEAAS Editor: Restoring fork")):(console.error("FEAAS Editor: Pre-forked"),this.setAttribute("forked",C.id));else if(this.removeAttribute("forked"),this.shouldFork(L)){console.error("FEAAS Editor: Forking");let Z=L.fork(o).id;this.setAttribute("instance",Z)}else console.error("FEAAS Editor: Regular");ht(w)}),()=>{this.closing=setTimeout(()=>{this.closing=null,this.cleanup(),ht(null)},400)}},[i,this.props.hidden]);let ut=Rt(g==null?void 0:g.versions,[]).filter(w=>w.id==M),O=ut[0];O&&!this.props.hidden&&(this.version=O),u(()=>(this.unfork=()=>{G({title:"Reverting component customizations",button:"Discard",body:"Are you sure to reset component to its original state? All changes will be lost.",action:()=>{let w=g.findVersion(i,["staged","published"]);g.findVersion(o).unstage().unpublish().changeAndNotify(w.toProperties()),g.saveVersions(!1),this.setVersionContext({needsWrite:!0}),this.removeAttribute("forked"),requestAnimationFrame(this.onClose)}})},this.discard=()=>{this.props.changed&&(g.findVersion(M).revert(),g.saveVersions(!1),this.setVersionContext({needsWrite:!0}))},this.close=()=>{G({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=()=>{G({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:()=>{g.findVersion(M).commitData({view:this.editorContext.editor.getData({rootName:M}),model:""}).stage().publish(),this.removeAttribute("changed"),this.setAttribute("forked",M),g.saveVersions(!1)}})},()=>{delete this.unfork,delete this.discard,delete this.save,delete this.editorContext,delete this.versionContext,delete this.setEditorContext,delete this.setVersionContext}),[g]);let kt=c(()=>this.target,[g]);return c(()=>g&&xt(e,({picker:w,children:Y})=>y.createElement(v,{ref:C=>{this.chrome=C?{positionable:C,wrapper:C.querySelector(".editor-chrome"),absolute:this.querySelector(".ui.overlays")}:null}},y.createElement(v,{className:"editor-wrapper",position:"absolute",left:0,top:0},y.createElement(n,{datasources:U.datasources,sdk:U,library:U.library,component:g,versions:ut,context:{isAutosaveEnabled:!1,onChromeMeasure:this.onMeasure,onChromeBeforeMeasure:this.onBeforeMeasure,onChromeMeasureElement:this.onChromeMeasureElement,onChromePosition:this.onPosition,onContentChange:this.onContentChange}},{exports:this.onEditorStateChange,after:Y,chrome:({editor:C})=>C&&y.createElement(Ct,null),children:({isArchivedDisplayed:C,editor:L,status:Z})=>y.createElement(v,{position:"absolute",left:0,top:0,className:"editor-chrome",p:4,boxShadow:"2xl",pointerEvents:"none",opacity:0,transition:"opacity 0.3s"},y.createElement(v,{left:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),y.createElement(v,{right:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),y.createElement(v,{top:0,height:"16",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),y.createElement(v,{bottom:0,height:"4",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),O&&y.createElement(l,{version:O,node:kt,ignoreBreakpoints:!0,deps:[this.props.forked,this.props.changed]},{exports:this.onVersionStateChange,left:y.createElement(S,{justifyContent:"space-between"},y.createElement(h,{size:"sm",editor:Z=="ready"?L:null}),y.createElement(f,{size:"sm"})),middle:(Qt,Xt)=>[!1],right:y.createElement(y.Fragment,null,y.createElement(dt,{variant:"secondary",size:"sm",onClick:this.close},"Close"),y.createElement(dt,{variant:"primary",size:"sm",onClick:this.save,isDisabled:!this.props.changed},this.props.changed?this.props.forked?"Save":"Save customization":"Up to date"),y.createElement(d,{isDisabled:!this.props.forked&&!this.props.changed},y.createElement(ct,{onClick:this.unfork,isDisabled:!this.props.forked},"Unfork"),y.createElement(ct,{onClick:this.discard,isDisabled:!this.props.changed},"Discard")))}))})))),[O,this.props.forked,this.props.changed])}isReadyToLoad(){return this.props.component!=null&&this.props.version!=null&&!this.props.hidden}};q.observedAttributes=["library","component","version","revision","hidden","state","changed","forked"];q.register("feaas-editor");function qt(t=this){var e,r;return{part:(t==null?void 0:t.getAttribute("part"))||"picker",slot:(t==null?void 0:t.getAttribute("part"))||"picker",mode:t==null?void 0:t.getAttribute("mode"),placeholder:(t==null?void 0:t.getAttribute("placeholder"))||"No theme",frontend:(e=t==null?void 0:t.getContextAttribute("frontend"))!==null&&e!==void 0?e:"https://components.sitecorecloud.io",src:(r=t==null?void 0:t.getAttribute("src"))!==null&&r!==void 0?r:"/picker.js",hidden:(t==null?void 0:t.getAttribute("hidden"))!=null,variant:t==null?void 0:t.getAttribute("variant"),context:void 0,onClose:void 0,onContextAttributeSet:void 0}}var J=class extends b{constructor(){super(...arguments),this.defaultProps={hidden:!1}}getProps(){return qt(this)}load(){return this.import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}render({placeholder:e,context:r,mode:i,children:o,variant:n},{Picker:s,React:a,ReactDOM:l}){return a.createElement(s,{placeholder:e,mode:i||void 0,onClose:this.props.onClose,onContextAttributeSet:this.props.onContextAttributeSet,context:r,variant:n},o)}};J.observedAttributes=["library","mode","frontend","src","hidden","variant"];J.register("feaas-picker");function Jt(t=this){var e,r,i,o;return{library:t==null?void 0:t.getAttribute("library"),src:(e=t==null?void 0:t.getAttribute("src"))!==null&&e!==void 0?e:"/context.js",frontend:(r=t==null?void 0:t.getAttribute("frontend"))!==null&&r!==void 0?r:"https://components.sitecoreclud.io",backend:(i=t==null?void 0:t.getAttribute("backend"))!==null&&i!==void 0?i:"https://components-api.sitecoreclud.io",cdn:(o=t==null?void 0:t.getAttribute("cdn"))!==null&&o!==void 0?o:"https://feaascompontsapiprod.blob.core.windows.net",auth:null,isolate:(t==null?void 0:t.getAttribute("isolate"))==null||(t==null?void 0:t.getAttribute("isolate"))=="true"}}var K=class extends b{constructor(){super(...arguments),this.defaultProps={isolate:!0},this.onStatusChange=e=>{e=="ready"&&this.dispatchEvent(new Event("feaasReady",{bubbles:!0,composed:!0}))}}getProps(){return Jt(this)}load(){return this.import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}isReadyToLoad(){return console.log("Is ready?",this.props,super.isReadyToLoad()&&this.props.library!=null),super.isReadyToLoad()&&this.props.library!=null}getTheme(e){return e}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(){Array.from(this.children).forEach(e=>{this.getRoot().appendChild(e)}),super.connectedCallback()}render({children:e,library:r},{AppContext:i,Chakra:{Button:o,Tooltip:n},React:s}){let a={containerRef:{current:this.getRoot()}};return n.defaultProps={hasArrow:!0,placement:"top",portalProps:a},s.createElement(i,{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:{cssVarsRoot:":host",resetCSS:!0,toastOptions:{portalProps:a}}},e)}};K.observedAttributes=["library","component","version","revision","hostname","template"];K.register("feaas-context");import Kt from"react";function Gt({data:t,...e}){if("template"in e)var r=gt(e.template,t||{});return Kt.createElement("feaas-component",{...e,template:null,data:typeof t=="string"?t:t?JSON.stringify(t):null,dangerouslySetInnerHTML:{__html:r||""}})}var yr=Gt;export{b as Base,yr as Component,jt as ComponentProps,R as DEFAULT_CDN_URL,b as FEAASBase,z as FEAASComponent,jt as FEAASComponentsProps,K as FEAASContext,Jt as FEAASContextProps,q as FEAASEditor,Vt as FEAASEditorProps,Gt as FEAASEmbed,V as FEAASLoader,Wt as FEAASLoaderProps,J as FEAASPicker,qt as FEAASPickerProps,at as FEAASStylesheet,Ht as FEAASStylesheetProps,p as JSONPath,V as Loader,Q as MyComponent,at as Stylesheet,Dt as autoloadScripts,Ot as cleanCollectionBit,ge as clearFetchCache,It as createStylesheet,vt as fetchAndRevalidate,F as fetchAndRevalidateComponent,nt as fetchAndRevalidateStylesheet,it as fetchBypassingCache,B as fetchCache,Ce as fetchComponent,j as fetchToValidateCache,T as fetchWithCacheAwareness,Ut as findStylesheet,Ae as getComponentSource,At as getComponentURL,Nt as getFetchCache,zt as getFramePosition,Ee as getStylesheetSource,H as getStylesheetURL,I as loadScript,st as loadStylesheet,Et as loadStylesheetAllowStale,pt as normalizeCollectionScope,Lt as observeDOMElement,W as parseComponentSource,ot as parseStylesheetSource,rt as queryScopes,Te as renderComponent,Pe as renderComponentElement,Bt as renderComponentPromise,N as renderDOMContent,x as renderDOMElement,gt as renderHTMLContent,Re as renderStylesheet,Ft as renderStylesheetPromise,D as serializeCH1RichText,$ as setDOMAttribute};
|
|
66
|
+
</div>`,this.getRoot().appendChild(this.stylesheet),this.getRoot().appendChild(this.loader)}update(){this.loader.style.opacity=String(this.props.opacity)}};V.observedAttributes=["hidden","opacity"];V.register("feaas-loader");function Ht(t=this){var e,r,i,o;let n=t.getAttribute("src");if(n)var{cdn:s,library:a,revision:l}=ot(n);return{library:t==null?void 0:t.getContextAttribute("library"),revision:(r=(e=t==null?void 0:t.getAttribute("revision"))!==null&&e!==void 0?e:l)!==null&&r!==void 0?r:"published",cdn:(o=(i=t==null?void 0:t.getContextAttribute("cdn"))!==null&&i!==void 0?i:t==null?void 0:t.getContextAttribute("hostname"))!==null&&o!==void 0?o:R}}var at=class extends b{constructor(){super(...arguments),this.onLoad=e=>{this.payload=e,this.advance()}}getProps(){return Ht(this)}isReadyToLoad(){return this.props.library!=null&&this.props.revision!=null&&this.props.cdn!=null}load(){return st(this.props,this.onLoad)}};at.register("feaas-stylesheet");var lt;typeof window!="undefined"&&(window.FEAASElement=P,(lt=window.FEAASLoading)!==null&<!==void 0||(window.FEAASLoading=Promise.resolve()));function zt(t){let e=[];if(t){let r=t.ownerDocument.defaultView,i,o;for(;r!==window.top;){i=r.parent;for(let n=0;n<i.frames.length;n++)if(i.frames[n]===r){for(let s of i.document.getElementsByTagName("iframe"))if(s.contentWindow===r){o=s.getBoundingClientRect();let a=s.contentWindow.getComputedStyle(s);e.push({left:o.left+parseInt(a.borderLeftWidth),top:o.top+parseInt(a.borderTopWidth)})}r=i;break}}}return e.reduce((r,i)=>({left:r.left+i.left,top:r.top+i.top}),{left:0,top:0})}function Vt(t=this){var e;return{context:HTMLElement,frontend:t==null?void 0:t.getContextAttribute("frontend"),src:(e=t==null?void 0:t.getAttribute("src"))!==null&&e!==void 0?e:"/editor.js",library:t==null?void 0:t.getAttribute("library"),component:t==null?void 0:t.getAttribute("component"),version:t==null?void 0:t.getAttribute("version"),instance:t==null?void 0:t.getAttribute("instance"),forked:t==null?void 0:t.getAttribute("forked"),revision:(t==null?void 0:t.getAttribute("revision"))||"saved",hidden:(t==null?void 0:t.getAttribute("hidden"))!=null,for:t==null?void 0:t.getAttribute("for"),state:(t==null?void 0:t.getAttribute("state"))||"idle",changed:(t==null?void 0:t.getAttribute("changed"))!=null}}var q=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=(e,r={component:e.getAttribute("component"),version:e.getAttribute("version"),revision:e.getAttribute("revision"),instance:e.getAttribute("instance")})=>{if(!this.closing&&(!this.target||e==null))return this.set(r),this.target=e,!0},this.onChromeMeasureElement=(e,r=e.getBoundingClientRect())=>e.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=e=>{e.memoized.focusable&&(this.framePoint=zt(e.memoized.focusable)),this.chrome&&(this.wrapperRect=this.chrome.positionable.getBoundingClientRect(),this.bodyRect=this.chrome.positionable.ownerDocument.body.parentElement.getBoundingClientRect())},this.onMeasure=()=>{},this.onPosition=({focusable:e,root:r})=>{!this.chrome||this.props.hidden||(e?(this.chrome.wrapper.style.width=e.width+16*2+"px",this.chrome.wrapper.style.height=e.height+16*1+64+"px",this.chrome.wrapper.style.left=e.left-16+"px",this.chrome.wrapper.style.top=e.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=e=>{var r;switch((r=e.data)===null||r===void 0?void 0:r.type){case"feaasEdit":let i=this.getPlaceholder();this.setTarget(i.editable,e.data)&&(this.loader=i.loader,document.body.appendChild(i.clipper),this.editedUID=e.data.id,this.setPlaceholder(),this.open());break;case"feaasMeasurements":this.measurements=e.data.measurements,this.props.hidden||this.setPlaceholder();break}},this.onContentChange=()=>{this.setAttribute("changed","changed"),requestAnimationFrame(()=>{this.setIframeComponentContent()})},this.onClose=()=>{var e;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"),!((e=this.target)===null||e===void 0)&&e.parentNode&&(this.target.outerHTML=this.target.outerHTML),this.setTarget(null,{component:null,version:null,instance:null,revision:null}),this.setEditorContext({isFocused:!1})},this.onVersionStateChange=(e,r)=>{this.versionContext=e,this.setVersionContext=r},this.onEditorStateChange=(e,r)=>{this.editorContext=e,this.setEditorContext=r,e.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 Vt(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(e){this.iframe=e}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 e=this.iframe.clientWidth,r=this.iframe.clientHeight,i=this.iframe.getBoundingClientRect(),o=this.getPlaceholder(),n=document.body.getBoundingClientRect(),s=this.measurements[this.editedUID];s&&(Object.assign(o.clipper.style,{position:"absolute",top:i.top+this.iframe.clientTop-n.top+"px",left:i.left+this.iframe.clientLeft-n.left+"px",width:e+"px",height:r+"px",pointerEvents:"none",zIndex:1,overflow:"hidden"}),Object.assign(o.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(o.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(e,r,i){r!==i&&(e=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),i?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all")),super.attributeChangedCallback(e,r,i))}open(){clearTimeout(this.closing),this.removeAttribute("hidden"),this.removeAttribute("changed"),this.setLoadingState()}shouldFork(e){return e.forkOriginId==null&&this.props.instance!=null}cleanup(){var e;this.placeholder&&((e=this.placeholder.clipper)===null||e===void 0||e.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(e){console.log("Editor is not ready")}setEditorContext(e){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:e,component:r,version:i,instance:o},{Editor:n,VersionStatusList:s,VersionStatusButton:a,Version:l,VersionMenu:d,EditorUIUndo:h,EditorUIMode:f,React:{useEffect:u,useMemo:c,useState:m,useContext:E},Chakra:{HStack:S,Box:v,Button:dt,MenuItem:ct},Chrome:Ct,ReactDOM:Yt,useSDK:wt,useSlots:xt,useModelObserver:Rt,ConfirmationContext:St,VersionContext:Zt}){if(!this.payload)return;let{React:y}=this.payload,{sdk:I}=wt(),[g,ht]=m(),{setConfirm:G}=E(St),O=o||i,_t=I.library;g&&(this.component=g),u(()=>{if(this.props.hidden)return;let w=_t.components.getItem(r).clone();return w.versions.search({ids:[i,o].filter(Boolean),componentIds:[r]}).then(Y=>{w.versions.setItems(Y);let C=w.findVersion(o,["staged","published"]),D=w.findVersion(i,["staged","published"]);if(C)C.deletedAt?(C.getDraft().changeAndNotify(D.toProperties()).restore(),console.error("FEAAS Editor: Restoring fork")):(console.error("FEAAS Editor: Pre-forked"),this.setAttribute("forked",C.id));else if(this.removeAttribute("forked"),this.shouldFork(D)){console.error("FEAAS Editor: Forking");let Z=D.fork(o).id;this.setAttribute("instance",Z)}else console.error("FEAAS Editor: Regular");ht(w)}),()=>{this.closing=setTimeout(()=>{this.closing=null,this.cleanup(),ht(null)},400)}},[i,this.props.hidden]);let ut=Rt(g==null?void 0:g.versions,[]).filter(w=>w.id==O),L=ut[0];L&&!this.props.hidden&&(this.version=L),u(()=>(this.unfork=()=>{G({title:"Reverting component customizations",button:"Discard",body:"Are you sure to reset component to its original state? All changes will be lost.",action:()=>{let w=g.findVersion(i,["staged","published"]);g.findVersion(o).unstage().unpublish().changeAndNotify(w.toProperties()),g.saveVersions(!1),this.setVersionContext({needsWrite:!0}),this.removeAttribute("forked"),requestAnimationFrame(this.onClose)}})},this.discard=()=>{this.props.changed&&(g.findVersion(O).revert(),g.saveVersions(!1),this.setVersionContext({needsWrite:!0}))},this.close=()=>{G({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=()=>{G({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:()=>{g.findVersion(O).commitData({view:this.editorContext.editor.getData({rootName:O}),model:""}).stage().publish(),this.removeAttribute("changed"),this.setAttribute("forked",O),g.saveVersions(!1)}})},()=>{delete this.unfork,delete this.discard,delete this.save,delete this.editorContext,delete this.versionContext,delete this.setEditorContext,delete this.setVersionContext}),[g]);let kt=c(()=>this.target,[g]);return c(()=>g&&xt(e,({picker:w,children:Y})=>y.createElement(v,{ref:C=>{this.chrome=C?{positionable:C,wrapper:C.querySelector(".editor-chrome"),absolute:this.querySelector(".ui.overlays")}:null}},y.createElement(v,{className:"editor-wrapper",position:"absolute",left:0,top:0},y.createElement(n,{datasources:I.datasources,sdk:I,library:I.library,component:g,versions:ut,context:{isAutosaveEnabled:!1,onChromeMeasure:this.onMeasure,onChromeBeforeMeasure:this.onBeforeMeasure,onChromeMeasureElement:this.onChromeMeasureElement,onChromePosition:this.onPosition,onContentChange:this.onContentChange}},{exports:this.onEditorStateChange,after:Y,chrome:({editor:C})=>C&&y.createElement(Ct,null),children:({isArchivedDisplayed:C,editor:D,status:Z})=>y.createElement(v,{position:"absolute",left:0,top:0,className:"editor-chrome",p:4,boxShadow:"2xl",pointerEvents:"none",opacity:0,transition:"opacity 0.3s"},y.createElement(v,{left:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),y.createElement(v,{right:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),y.createElement(v,{top:0,height:"16",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),y.createElement(v,{bottom:0,height:"4",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),L&&y.createElement(l,{version:L,node:kt,ignoreBreakpoints:!0,deps:[this.props.forked,this.props.changed]},{exports:this.onVersionStateChange,left:y.createElement(S,{justifyContent:"space-between"},y.createElement(h,{size:"sm",editor:Z=="ready"?D:null}),y.createElement(f,{size:"sm"})),middle:(Qt,Xt)=>[!1],right:y.createElement(y.Fragment,null,y.createElement(dt,{variant:"secondary",size:"sm",onClick:this.close},"Close"),y.createElement(dt,{variant:"primary",size:"sm",onClick:this.save,isDisabled:!this.props.changed},this.props.changed?this.props.forked?"Save":"Save customization":"Up to date"),y.createElement(d,{isDisabled:!this.props.forked&&!this.props.changed},y.createElement(ct,{onClick:this.unfork,isDisabled:!this.props.forked},"Unfork"),y.createElement(ct,{onClick:this.discard,isDisabled:!this.props.changed},"Discard")))}))})))),[L,this.props.forked,this.props.changed])}isReadyToLoad(){return this.props.component!=null&&this.props.version!=null&&!this.props.hidden}};q.observedAttributes=["library","component","version","revision","hidden","state","changed","forked"];q.register("feaas-editor");function qt(t=this){var e,r;return{part:(t==null?void 0:t.getAttribute("part"))||"picker",slot:(t==null?void 0:t.getAttribute("part"))||"picker",mode:t==null?void 0:t.getAttribute("mode"),placeholder:(t==null?void 0:t.getAttribute("placeholder"))||"No theme",frontend:(e=t==null?void 0:t.getContextAttribute("frontend"))!==null&&e!==void 0?e:"https://components.sitecorecloud.io",src:(r=t==null?void 0:t.getAttribute("src"))!==null&&r!==void 0?r:"/picker.js",hidden:(t==null?void 0:t.getAttribute("hidden"))!=null,variant:t==null?void 0:t.getAttribute("variant"),context:void 0,onClose:void 0,onContextAttributeSet:void 0}}var J=class extends b{constructor(){super(...arguments),this.defaultProps={hidden:!1}}getProps(){return qt(this)}load(){return this.import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}render({placeholder:e,context:r,mode:i,children:o,variant:n},{Picker:s,React:a,ReactDOM:l}){return a.createElement(s,{placeholder:e,mode:i||void 0,onClose:this.props.onClose,onContextAttributeSet:this.props.onContextAttributeSet,context:r,variant:n},o)}};J.observedAttributes=["library","mode","frontend","src","hidden","variant"];J.register("feaas-picker");function Jt(t=this){var e,r,i,o;return{library:t==null?void 0:t.getAttribute("library"),src:(e=t==null?void 0:t.getAttribute("src"))!==null&&e!==void 0?e:"/context.js",frontend:(r=t==null?void 0:t.getAttribute("frontend"))!==null&&r!==void 0?r:"https://components.sitecoreclud.io",backend:(i=t==null?void 0:t.getAttribute("backend"))!==null&&i!==void 0?i:"https://components-api.sitecoreclud.io",cdn:(o=t==null?void 0:t.getAttribute("cdn"))!==null&&o!==void 0?o:"https://feaascompontsapiprod.blob.core.windows.net",auth:null,isolate:(t==null?void 0:t.getAttribute("isolate"))==null||(t==null?void 0:t.getAttribute("isolate"))=="true"}}var K=class extends b{constructor(){super(...arguments),this.defaultProps={isolate:!0},this.onStatusChange=e=>{e=="ready"&&this.dispatchEvent(new Event("feaasReady",{bubbles:!0,composed:!0}))}}getProps(){return Jt(this)}load(){return this.import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}isReadyToLoad(){return console.log("Is ready?",this.props,super.isReadyToLoad()&&this.props.library!=null),super.isReadyToLoad()&&this.props.library!=null}getTheme(e){return e}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(){Array.from(this.children).forEach(e=>{this.getRoot().appendChild(e)}),super.connectedCallback()}render({children:e,library:r},{AppContext:i,Chakra:{Button:o,Tooltip:n},React:s}){let a={containerRef:{current:this.getRoot()}};return n.defaultProps={hasArrow:!0,placement:"top",portalProps:a},s.createElement(i,{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:{cssVarsRoot:":host",resetCSS:!0,toastOptions:{portalProps:a}}},e)}};K.observedAttributes=["library","component","version","revision","hostname","template"];K.register("feaas-context");import Kt from"react";function Gt({data:t,...e}){if("template"in e)var r=gt(e.template,t||{});return"src"in e&&(e={...M(e.src),...e}),Kt.createElement("feaas-component",{...e,template:null,data:typeof t=="string"?t:t?JSON.stringify(t):null,dangerouslySetInnerHTML:{__html:r||""}})}var yr=Gt;export{b as Base,yr as Component,jt as ComponentProps,R as DEFAULT_CDN_URL,b as FEAASBase,z as FEAASComponent,jt as FEAASComponentsProps,K as FEAASContext,Jt as FEAASContextProps,q as FEAASEditor,Vt as FEAASEditorProps,Gt as FEAASEmbed,V as FEAASLoader,Wt as FEAASLoaderProps,J as FEAASPicker,qt as FEAASPickerProps,at as FEAASStylesheet,Ht as FEAASStylesheetProps,p as JSONPath,V as Loader,Q as MyComponent,at as Stylesheet,Dt as autoloadScripts,Ot as cleanCollectionBit,ge as clearFetchCache,It as createStylesheet,vt as fetchAndRevalidate,U as fetchAndRevalidateComponent,nt as fetchAndRevalidateStylesheet,it as fetchBypassingCache,j as fetchCache,Ce as fetchComponent,W as fetchToValidateCache,T as fetchWithCacheAwareness,Ut as findStylesheet,Ae as getComponentSource,At as getComponentURL,Nt as getFetchCache,zt as getFramePosition,Ee as getStylesheetSource,H as getStylesheetURL,B as loadScript,st as loadStylesheet,Et as loadStylesheetAllowStale,pt as normalizeCollectionScope,Lt as observeDOMElement,M as parseComponentSource,ot as parseStylesheetSource,rt as queryScopes,Te as renderComponent,Pe as renderComponentElement,Bt as renderComponentPromise,F as renderDOMContent,x as renderDOMElement,gt as renderHTMLContent,Re as renderStylesheet,Ft as renderStylesheetPromise,$ as serializeCH1RichText,N as setDOMAttribute};
|
|
67
67
|
//# sourceMappingURL=react.esm.js.map
|