@sitecore-feaas/clientside 0.6.3-alpha.13 → 0.6.3-alpha.14

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.
@@ -72,5 +72,5 @@ var Be=Object.defineProperty;var nt=(t,e)=>{for(var r in e)Be(t,r,{get:e[r],enum
72
72
  `;let f=s.contentWindow.document.createElement("style");f.textContent=`
73
73
  body, html { padding: 0; margin: 0; overflow: hidden }
74
74
  `,s.contentWindow.document.head.appendChild(c),s.contentWindow.document.head.appendChild(f);let h=Jt({template:r,data:n},null,!1);h.classList.add(...t,"-feaas--preview","-emulate--"+e.details.slug),s.contentWindow.document.body.appendChild(h)})}async function ke(t,e,r){let n=e?e.getThumbnailURL():t.getThumbnailURL(),i=new Date(Math.max(Number(t.modifiedAt),Number(t.library.stylesheet.modifiedAt)));try{await t.sdk.uploadBlob("thumbnails",n.split(/\/thumbnails\//)[1],r,{headers:{"x-ms-blob-content-type":"image/jpg","x-ms-blob-cache-control":"public,max-age=31536000,immutable","x-ms-meta-versionId":e?e.id:null,"x-ms-meta-versionRevision":e?e.revision.toString():null,"x-ms-meta-componentId":t.id,"x-ms-meta-componentRenderedAt":i.toUTCString(),"x-ms-meta-componentModifiedAt":t.modifiedAt.toUTCString(),"x-ms-meta-componentCreatedAt":t.createdAt.toUTCString(),"x-ms-meta-modifiedAt":t.modifiedAt.toUTCString()}}),fetch(n,{cache:"no-cache"}).then(()=>{t.sdk.log("FEAAS: Thumbnail uploaded",n)})}catch(o){t.sdk.log("FEAAS: Thumbnail failed to upload",n,o)}return n}import{registerDatasource as ir,registerComponent as or,getComponent as sr,customizeDataSettings as ar}from"@sitecore/byoc";var qt;typeof window!="undefined"&&(window.FEAASReactElement=K,(qt=window.FEAASLoading)!==null&&qt!==void 0||(window.FEAASLoading=Promise.resolve()));function Oe(t){let e=[];if(t){let r=t.ownerDocument.defaultView,n,i;for(;r!==window.top;){n=r.parent;for(let o=0;o<n.frames.length;o++)if(n.frames[o]===r){for(let s of n.document.getElementsByTagName("iframe"))if(s.contentWindow===r){i=s.getBoundingClientRect();let a=s.contentWindow.getComputedStyle(s);e.push({left:i.left+parseInt(a.borderLeftWidth),top:i.top+parseInt(a.borderTopWidth)})}r=n;break}}}return e.reduce((r,n)=>({left:r.left+n.left,top:r.top+n.top}),{left:0,top:0})}function Te(t){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 pt=class extends C{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=Oe(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 n=this.getPlaceholder();this.setTarget(n.editable,e.data)&&(this.loader=n.loader,document.body.appendChild(n.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 Te(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,n=this.iframe.getBoundingClientRect(),i=this.getPlaceholder(),o=document.body.getBoundingClientRect(),s=this.measurements[this.editedUID];s&&(Object.assign(i.clipper.style,{position:"absolute",top:n.top+this.iframe.clientTop-o.top+"px",left:n.left+this.iframe.clientLeft-o.left+"px",width:e+"px",height:r+"px",pointerEvents:"none",zIndex:1,overflow:"hidden"}),Object.assign(i.positionable.style,{position:"absolute",top:s.top+"px",left:s.left+"px",width:s.width+"px",zIndex:2,transition:"opacity 0.4s",pointerEvents:this.props.hidden?"none":"all"}),Object.assign(i.loader.style,{position:"absolute",top:s.top+"px",left:s.left+"px",width:s.width+"px",height:s.height+"px",filter:"opacity(0.6)",zIndex:3,pointerEvents:"none"}),document.dispatchEvent(new Event("feaasRefresh",{bubbles:!0})))}getPlaceholder(){return this.placeholder?this.placeholder:(this.placeholder={clipper:document.createElement("div"),positionable:document.createElement("div"),editable:Object.assign(document.createElement("div"),{className:"-feaas"}),loader:document.createElement("feaas-loader")},this.placeholder.clipper.appendChild(this.placeholder.positionable),this.placeholder.positionable.appendChild(this.placeholder.editable),this.placeholder.clipper.appendChild(this.placeholder.loader),this.placeholder)}attributeChangedCallback(e,r,n){r!==n&&(e=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),n?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all")),super.attributeChangedCallback(e,r,n))}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:n,instance:i},{Editor:o,VersionStatusList:s,VersionStatusButton:a,Version:l,VersionMenu:d,EditorUIUndo:c,EditorUIMode:f,React:{useEffect:h,useMemo:u,useState:p,useContext:g},Chakra:{HStack:v,Box:y,Button:k,MenuItem:mt},Chrome:kt,ReactDOM:Xt,useSDK:Ot,useLibrary:Tt,useSlots:L,useModelObserver:Pt,ConfirmationContext:Mt,VersionContext:Q}){if(!this.payload)return;let{React:b}=this.payload,gt=Ot(),Z=Tt(),[A,P]=p(),{setConfirm:$}=g(Mt),tt=i||n;A&&(this.component=A),h(()=>{if(this.props.hidden)return;let w=Z.components.getItem(r).clone();return w.versions.search({ids:[n,i].filter(Boolean),componentIds:[r]}).then(I=>{w.versions.setItems(I);let O=w.findVersion(i,["staged","published"]),rt=w.findVersion(n,["staged","published"]);if(O)O.deletedAt?(O.getDraft().changeAndNotify(rt.toProperties()).restore(),console.error("FEAAS Editor: Restoring fork")):(console.error("FEAAS Editor: Pre-forked"),this.setAttribute("forked",O.id));else if(this.removeAttribute("forked"),this.shouldFork(rt)){console.error("FEAAS Editor: Forking");let Dt=rt.fork(i).id;this.setAttribute("instance",Dt)}else console.error("FEAAS Editor: Regular");P(w)}),()=>{this.closing=setTimeout(()=>{this.closing=null,this.cleanup(),P(null)},400)}},[n,this.props.hidden]);let Qt=Pt(A==null?void 0:A.versions,[]).filter(w=>w.id==tt),et=Qt[0];et&&!this.props.hidden&&(this.version=et),h(()=>(this.unfork=()=>{$({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=A.findVersion(n,["staged","published"]);A.findVersion(i).unstage().unpublish().changeAndNotify(w.toProperties()),A.saveVersions(!1),this.setVersionContext({needsWrite:!0}),this.removeAttribute("forked"),requestAnimationFrame(this.onClose)}})},this.discard=()=>{this.props.changed&&(A.findVersion(tt).revert(),A.saveVersions(!1),this.setVersionContext({needsWrite:!0}))},this.close=()=>{$({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=()=>{$({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:()=>{var w,I;(I=(w=A.findVersion(tt).commitData({view:this.editorContext.editor.getData({rootName:tt}),model:""}))===null||w===void 0?void 0:w.stage())===null||I===void 0||I.publish(),this.removeAttribute("changed"),this.setAttribute("forked",tt),A.saveVersions(!1)}})},()=>{delete this.unfork,delete this.discard,delete this.save,delete this.editorContext,delete this.versionContext,delete this.setEditorContext,delete this.setVersionContext}),[A]);let Ie=u(()=>this.target,[A]);return u(()=>A&&L(e,({picker:w,children:I})=>b.createElement(y,{ref:O=>{this.chrome=O?{positionable:O,wrapper:O.querySelector(".editor-chrome"),absolute:this.querySelector(".ui.overlays")}:null}},b.createElement(y,{className:"editor-wrapper",position:"absolute",left:0,top:0},b.createElement(o,{datasources:gt.datasources,sdk:gt,library:Z,component:A,versions:Qt,context:{isAutosaveEnabled:!1,onChromeMeasure:this.onMeasure,onChromeBeforeMeasure:this.onBeforeMeasure,onChromeMeasureElement:this.onChromeMeasureElement,onChromePosition:this.onPosition,onContentChange:this.onContentChange}},{exports:this.onEditorStateChange,after:I,chrome:({editor:O})=>O&&b.createElement(kt,null),children:({isArchivedDisplayed:O,editor:rt,status:Dt})=>b.createElement(y,{position:"absolute",left:0,top:0,className:"editor-chrome",p:4,boxShadow:"2xl",pointerEvents:"none",opacity:0,transition:"opacity 0.3s"},b.createElement(y,{left:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),b.createElement(y,{right:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),b.createElement(y,{top:0,height:"16",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),b.createElement(y,{bottom:0,height:"4",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),et&&b.createElement(l,{version:et,node:Ie,ignoreBreakpoints:!0,deps:[this.props.forked,this.props.changed]},{exports:this.onVersionStateChange,left:b.createElement(v,{justifyContent:"space-between"},b.createElement(c,{size:"sm",editor:Dt=="ready"?rt:null}),b.createElement(f,{size:"sm"})),middle:(pr,fr)=>[!1],right:b.createElement(b.Fragment,null,b.createElement(k,{variant:"secondary",size:"sm",onClick:this.close},"Close"),b.createElement(k,{variant:"primary",size:"sm",onClick:this.save,isDisabled:!this.props.changed},this.props.changed?this.props.forked?"Save":"Save customization":"Up to date"),b.createElement(d,{isDisabled:!this.props.forked&&!this.props.changed},b.createElement(mt,{onClick:this.unfork,isDisabled:!this.props.forked},"Unfork"),b.createElement(mt,{onClick:this.discard,isDisabled:!this.props.changed},"Discard")))}))})))),[et,this.props.forked,this.props.changed])}isReadyToLoad(){return this.props.component!=null&&this.props.version!=null&&!this.props.hidden}};pt.observedAttributes=["library","component","version","revision","hidden","state","changed","forked"];pt.register("feaas-editor");function Pe(t){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"),dialog:t==null?void 0:t.getAttribute("dialog"),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,setAttribute:void 0,getAttribute:void 0}}var ft=class extends C{constructor(){super(...arguments),this.defaultProps={hidden:!1}}getProps(){return Pe(this)}load(){return this.import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}connectedCallback(){this.setAttribute("feaas-role","ui"),super.connectedCallback()}render({placeholder:e,context:r,mode:n,dialog:i,children:o,variant:s},{Picker:a,React:l,useContext:d,EnvironmentContext:c,useLibrary:f,useSDK:h,BYOC:u}){var p,g,v;let[y,k]=l.useReducer(A=>A+1,0),mt=h(),kt=d(c),Xt=f("collections"),Ot=f("components"),Tt=h("datasources"),L=f(),Pt=((g=(p=L==null?void 0:L.stylesheets)===null||p===void 0?void 0:p.first)===null||g===void 0?void 0:g.rules)||((v=L==null?void 0:L.stylesheet)===null||v===void 0?void 0:v.styles),Mt=h("renderingHost.expandedComponents");var Q=r==null?void 0:r.getAttribute("data");if(Q)try{Q=JSON.parse(Q)}catch(A){}if(r)var b=mt.ExternalComponent.getDefinition(r),gt=b&&!b.getConfiguration(r),Z=(b==null?void 0:b.type)=="feaas"?Ot.find(A=>A.id==r.getAttribute("component")):u==null?void 0:u.getComponent(String(r.getAttribute("data-external-id")));return l.createElement(a,{cdn:kt.cdn,rules:Pt,collections:Xt,themeContext:r,placeholder:e,embed:Z,externalComponents:Mt,datasources:Tt,data:Q,versionId:r==null?void 0:r.getAttribute("version"),mode:n||(gt?"library":Z?"context":null),setAttribute:(A,P,$)=>{P=="data"&&$&&($=JSON.stringify($)),this.props.setAttribute(A,P,$),k()},getAttribute:(A,P)=>r==null?void 0:r.getAttribute(P),dialog:i,context:r,variant:s,onModeChange:(A,P)=>{this.set({mode:A,dialog:P})}},o)}};ft.observedAttributes=["library","mode","frontend","src","hidden","variant","dialog"];ft.register("feaas-picker");function Me(t){var e,r,n,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",environment:(r=t==null?void 0:t.getAttribute("environment"))!==null&&r!==void 0?r:void 0,frontend:(n=t==null?void 0:t.getAttribute("frontend"))!==null&&n!==void 0?n:"https://components.sitecorecloud.io",backend:(i=t==null?void 0:t.getAttribute("backend"))!==null&&i!==void 0?i:"https://components.sitecorecloud.io/api",cdn:(o=t==null?void 0:t.getAttribute("cdn"))!==null&&o!==void 0?o:"https://feaas.blob.core.windows.net",auth:null,isolate:(t==null?void 0:t.getAttribute("isolate"))==null||(t==null?void 0:t.getAttribute("isolate"))=="true"}}var Y=class extends C{constructor(){super(...arguments),this.defaultProps={isolate:!0},this.onStatusChange=(e,r)=>{e=="ready"&&(this.whenSDKReady.resolve(r),this.dispatchEvent(new CustomEvent("feaasReady",{bubbles:!0,composed:!0,detail:r})))},this.whenSDKReady=N(e=>{this.sdk=e})}getProps(){return Me(this)}load(){return this.import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null}getTheme(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(){this.setAttribute("feaas-role","ui"),Array.from(this.children).forEach(e=>{this.getRoot().appendChild(e)}),document.addEventListener("feaasMount",this),document.addEventListener("feaasUnmount",this),super.connectedCallback()}disconnectedCallback(){document.removeEventListener("feaasMount",this),document.removeEventListener("feaasUnmount",this),super.disconnectedCallback()}getPortalRoot(){return this.getRoot()}render({children:e,library:r},{AppContext:n,Chakra:{Button:i,Tooltip:o},React:s}){let a={containerRef:{current:this.getPortalRoot()}};return o.defaultProps={hasArrow:!0,placement:"top",portalProps:a},s.createElement(n,{environment:this.props.environment,backend:this.props.backend,libraryId:this.props.library,container:this.getRoot(),auth:this.props.auth,getTheme:this.getTheme,onStatusChange:this.onStatusChange,modalProps:{portalProps:a},chakraProps:{resetScope:':where([feaas-role="ui"])',cssVarsRoot:":host",resetCSS:!0,toastOptions:{portalProps:a}}},e)}};Y.observedAttributes=["library","component","version","revision","hostname","template"];Y.register("feaas-context");Y.prototype.clientside=Gt;import*as _ from"@sitecore/byoc";import De from"react";import lr from"react-dom";var Le=_.getMergedComponentProperties;function dr(t){let e=_.objectKeysToCamelCase(Array.from(t.attributes).reduce((r,{name:n,value:i})=>(n=="data-external-id"&&(n="component-name"),Object.assign(r,{[n]:i})),{}));return Le(e).merged}var M=class extends C{load(){return Promise.all([import( /*@vite-ignore*/ /* webpackIgnore: true */ "https://cdn.skypack.dev/react-dom/client")]).then(([e])=>({React:De,ReactDOM:lr,ReactDOMClient:e}))}connectedCallback(){this._setAttribute||(this._setAttribute=this.setAttribute,this.setAttribute=function(e,r){let n=this.getAttribute(r);this._setAttribute(e,r),this.attributeChangedCallback(e,n,r)}),super.connectedCallback()}update(){var e;if(!(!(!((e=_.getComponent(this.getComponentName()))===null||e===void 0)&&e.component)&&this.getAttribute("hydrate")=="false"))return super.update()}render(e,{React:r}){var n;let i=(n=_.getComponent(this.getComponentName()))===null||n===void 0?void 0:n.component;return i||console.warn(`FEAASExternal: \`${this.getComponentName()}\` is not registered`),r.createElement(r.Fragment,null,i&&r.createElement(i,{componentName:this.getComponentName(),...e}))}getComponentName(){return this.getAttribute("data-external-id")}getProps(){return dr(this)}static Preview(e){var r;let n=(e==null?void 0:e.src)||(typeof window!="undefined"?(r=window.location.search.match(/feaasSrc=([^&]+)/))===null||r===void 0?void 0:r[1]:null);return n?De.createElement($e,{src:n,...e}):null}static linkComponents(e){return()=>e.map(r=>null)}};M.registered=_.registered;M.registerComponent=_.registerComponent;M.setRegistrationCallback=_.setRegistrationCallback;M.getComponent=_.getComponent;M.register("feaas-external");var{linkComponents:cr}=M;var Kt={};function Gn(t,e){Kt[t]=e}function Fe(t){return t==null||t===!0?["template","stylesheet","data"]:[].concat(t||[])}var ur=t=>("src"in t&&(t=j(t.src)),D.createElement("link",{rel:"stylesheet",href:Ht(t)})),hr=async({data:t,fetch:e,...r})=>{let n=await E.fetch(t||{});e=Fe(e!=null?e:["stylesheet"]);let i={...r};if(("src"in r||"component"in r)&&(r==null?void 0:r.template)==null){let o=await zt(r);i.template=o.template,i.lastModified=o.lastModified}else(r==null?void 0:r.template)==null&&!e.includes("template")&&e.push("template");return Ue({...i,data:t,fetch:e,fetchedData:n})};function Ue({data:t,lastModified:e,fetchedData:r,renderNode:n,...i}){console.log("=== FEAASReactComponent",t,i);let o=null,s;"template"in i&&i.template&&(s=It(i.template,r||t||{}).map((d,c)=>je(d,(f,h)=>{if(n){let p=n==null?void 0:n(f,h);if(p!=null&&"type"in p)return[p.type,p.props];h={...h,...p}}if(Kt[f.localName])return[Kt[f.localName],h];if(f.localName=="feaas-external"){let p={};for(var u in h){let g=u=="data-external-id"?"componentName":x.toCamelCase(u);p[g]=h[u]}return[x.Component,p]}},c))),"src"in i&&(i={...V(i.src),...i});let a=Fe(i.fetch),l=a.includes("data")?t:a.includes("template")?r||t:null;return console.log("htmlnode to react",s),D.createElement(D.Fragment,null,"preload"in i&&o===!0&&"src"in i&&D.createElement(D.Fragment,null,D.createElement("link",{rel:"preload",as:"fetch",href:ct(i.src),crossOrigin:"anonymous"}),D.createElement("link",{rel:"preload",as:"style",href:J(i.src),crossOrigin:"anonymous"})),D.createElement("feaas-component",{class:"-feaas",...i,"last-modified":e?String(e):null,fetch:i.fetch==null?i.fetch:[].concat(i.fetch).join(" "),suppressHydrationWarning:!0,template:null,data:typeof l=="string"?l:l?JSON.stringify(l):null},s))}function je(t,e,r){var n;if(t.nodeType===3)return t.textContent;let i=Array.from(t.childNodes).map((c,f)=>je(c,e,f)),o={};for(let c=0;c<t.attributes.length;c++){let{name:f,value:h}=t.attributes[c];f=="style"?o[f]=String(h||"").trim().split(/\s*;\s*/).reduce((u,p)=>{let[g,v]=p.split(":");return{...u,[x.toCamelCase(g)]:v}},{}):f=="class"?o.className=h:o[f]=h}let s=e==null?void 0:e(t,o),a=(s==null?void 0:s[0])||t.nodeName.toLowerCase();a=="style"&&(o.dangerouslySetInnerHTML={__html:i.join(`
75
- `)});let l=Object.assign({key:r,suppressHydrationWarning:!0},(s==null?void 0:s[1])||o);console.log("attributes",o),console.log("react attributes",l);let d=((n=s==null?void 0:s[1])===null||n===void 0?void 0:n.children)||i;return D.createElement(a,l,["img","br","input","style"].includes(a)?null:d)}var Kn=x.enableNextClientsideComponents,Xn=x.setContextProperties,Qn=x.Bundle,Zn=x.Component,ti=x.RegularComponent,ei=x.NextComponent,$e=Ue,ri=hr,ni=ur;export{$e as Component,Ee as ComponentProps,Y as Context,N as ControlledPromise,T as DEFAULT_CDN_URL,At as DOM,bt as DataPath,vt as DataScope,E as DataSettings,C as Element,M as External,Zn as ExternalComponent,Qn as ExternalComponentBundle,ut as FEAASComponent,Ee as FEAASComponentsProps,Y as FEAASContext,Me as FEAASContextProps,pt as FEAASEditor,Te as FEAASEditorProps,C as FEAASElement,Le as FEAASExternalPropsObject,ht as FEAASLoader,xe as FEAASLoaderProps,ft as FEAASPicker,Pe as FEAASPickerProps,Ue as FEAASReactComponent,hr as FEAASReactServerComponent,ur as FEAASReactStylesheet,_t as FEAASStylesheet,we as FEAASStylesheetProps,je as HTMLNodeToReact,xt as InvalidResponse,m as JSONPath,ht as Loader,Et as MyComponent,ei as NextExternalComponent,ft as Picker,ti as ReactExternalComponent,ri as ServerComponent,ni as Stylesheet,Nt as Thumbnail,me as WebComponent,ie as adjustNumbers,te as autoloadScripts,st as cleanCollectionBit,Xe as clearFetchCache,Ae as createStylesheet,ar as customizeDataSettings,Kn as enableNextClientsideComponents,lt as fetchAndRevalidate,X as fetchAndRevalidateComponent,St as fetchAndRevalidateStylesheet,wt as fetchBypassingCache,at as fetchCache,zt as fetchComponent,Wt as fetchData,dt as fetchToValidateCache,z as fetchWithCacheAwareness,be as findStylesheet,sr as getComponent,Qe as getComponentSource,ct as getComponentURL,ve as getFetchCache,Oe as getFramePosition,oe as getHumanizedLabel,se as getLastPathBit,ne as getQualifier,Ht as getStylesheetSource,J as getStylesheetURL,cr as linkComponents,ot as loadScript,Rt as loadStylesheet,Vt as loadStylesheetAllowStale,yt as normalizeCollectionScope,Fe as normalizeFetchAttribute,Zt as observeDOMElement,V as parseComponentSource,ee as parseLimit,re as parseRange,j as parseStylesheetSource,q as queryObject,Ut as queryObjectRaw,it as queryScopes,or as registerComponent,ir as registerDatasource,Jt as renderComponent,er as renderComponentElement,Ce as renderComponentPromise,H as renderDOMContent,R as renderDOMElement,Ye as renderHTMLContent,Ze as renderStylesheet,ye as renderStylesheetPromise,W as serializeCH1RichText,Xn as setContextProperties,F as setDOMAttribute,Gn as setElementImplementation};
75
+ `)});let l=Object.assign({key:r,suppressHydrationWarning:!0},(s==null?void 0:s[1])||o);console.log(t,t.attributes),console.log("attributes",o),console.log("react attributes",l),console.log("-----------------");let d=((n=s==null?void 0:s[1])===null||n===void 0?void 0:n.children)||i;return D.createElement(a,l,["img","br","input","style"].includes(a)?null:d)}var Kn=x.enableNextClientsideComponents,Xn=x.setContextProperties,Qn=x.Bundle,Zn=x.Component,ti=x.RegularComponent,ei=x.NextComponent,$e=Ue,ri=hr,ni=ur;export{$e as Component,Ee as ComponentProps,Y as Context,N as ControlledPromise,T as DEFAULT_CDN_URL,At as DOM,bt as DataPath,vt as DataScope,E as DataSettings,C as Element,M as External,Zn as ExternalComponent,Qn as ExternalComponentBundle,ut as FEAASComponent,Ee as FEAASComponentsProps,Y as FEAASContext,Me as FEAASContextProps,pt as FEAASEditor,Te as FEAASEditorProps,C as FEAASElement,Le as FEAASExternalPropsObject,ht as FEAASLoader,xe as FEAASLoaderProps,ft as FEAASPicker,Pe as FEAASPickerProps,Ue as FEAASReactComponent,hr as FEAASReactServerComponent,ur as FEAASReactStylesheet,_t as FEAASStylesheet,we as FEAASStylesheetProps,je as HTMLNodeToReact,xt as InvalidResponse,m as JSONPath,ht as Loader,Et as MyComponent,ei as NextExternalComponent,ft as Picker,ti as ReactExternalComponent,ri as ServerComponent,ni as Stylesheet,Nt as Thumbnail,me as WebComponent,ie as adjustNumbers,te as autoloadScripts,st as cleanCollectionBit,Xe as clearFetchCache,Ae as createStylesheet,ar as customizeDataSettings,Kn as enableNextClientsideComponents,lt as fetchAndRevalidate,X as fetchAndRevalidateComponent,St as fetchAndRevalidateStylesheet,wt as fetchBypassingCache,at as fetchCache,zt as fetchComponent,Wt as fetchData,dt as fetchToValidateCache,z as fetchWithCacheAwareness,be as findStylesheet,sr as getComponent,Qe as getComponentSource,ct as getComponentURL,ve as getFetchCache,Oe as getFramePosition,oe as getHumanizedLabel,se as getLastPathBit,ne as getQualifier,Ht as getStylesheetSource,J as getStylesheetURL,cr as linkComponents,ot as loadScript,Rt as loadStylesheet,Vt as loadStylesheetAllowStale,yt as normalizeCollectionScope,Fe as normalizeFetchAttribute,Zt as observeDOMElement,V as parseComponentSource,ee as parseLimit,re as parseRange,j as parseStylesheetSource,q as queryObject,Ut as queryObjectRaw,it as queryScopes,or as registerComponent,ir as registerDatasource,Jt as renderComponent,er as renderComponentElement,Ce as renderComponentPromise,H as renderDOMContent,R as renderDOMElement,Ye as renderHTMLContent,Ze as renderStylesheet,ye as renderStylesheetPromise,W as serializeCH1RichText,Xn as setContextProperties,F as setDOMAttribute,Gn as setElementImplementation};
76
76
  //# sourceMappingURL=react.esm.js.map