text: /**
   * Copyright 2018 The Pennsylvania State University
   * @license Apache-2.0, see License.md for full text.
   */
  import{store as e}from"./haxcms-site-store.js";class HAXCMSEditorBuilder extends HTMLElement{static get tag(){return"haxcms-editor-builder"}constructor(){super(),this.applyContext(),window.addEventListener("haxcms-site-editor-loaded",this.editorLoaded.bind(this))}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.dispatchEvent(new CustomEvent("haxcms-editor-builder-ready",{bubbles:!0,composed:!0,cancelable:!1,detail:this}))}disconnectedCallback(){window.removeEventListener("haxcms-site-editor-loaded",this.editorLoaded.bind(this)),super.disconnectedCallback&&super.disconnectedCallback()}getContext(){let e="";return e="undefined"!=typeof DatArchive?"beaker":!0===window.__haxCMSContextPublished?"published":!0===window.__haxCMSContextNode?"nodejs":!0===window.__haxCMSContextDemo?"demo":"php",e}editorLoaded(t){e.cmsSiteEditor.haxCmsSiteEditorUIElement||(import("./haxcms-site-editor-ui.js"),e.cmsSiteEditor.haxCmsSiteEditorUIElement=document.createElement("haxcms-site-editor-ui"),document.body.appendChild(e.cmsSiteEditor.haxCmsSiteEditorUIElement),setTimeout(()=>{e.cmsSiteEditor.haxCmsSiteEditorUIElement.painting=!1},5))}pathFromUrl(e){return e.substring(0,e.lastIndexOf("/")+1)}applyContext(t=null){if(!this.__appliedContext){if(this.__appliedContext=!0,null==t&&(t=this.getContext()),"php"===t||"nodejs"===t){let e=document.createElement("script");window.appSettings&&window.appSettings.connectionSettings?e.src=window.appSettings.connectionSettings:e.src="../../system/api/connectionSettings",fetch(e.src).then(t=>{404!=t.status&&document.documentElement.appendChild(e)})}if("published"!==t){const i=this.pathFromUrl(decodeURIComponent(import.meta.url));e.cmsSiteEditorBackend.tag=`haxcms-backend-${t}`,import(`${i}backends/${e.cmsSiteEditorBackend.tag}.js`).then(t=>{e.cmsSiteEditorBackend.instance||(e.cmsSiteEditorBackend.instance=document.createElement(e.cmsSiteEditorBackend.tag),document.body.append(e.cmsSiteEditorBackend.instance))})}}}}window.customElements.define(HAXCMSEditorBuilder.tag,HAXCMSEditorBuilder);export{HAXCMSEditorBuilder};