/*
 * This file is part of the TYPO3 CMS project.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */
define(["require","exports","../Enum/Viewport/ScaffoldIdentifier","./AbstractContainer","../Event/TriggerRequest"],(function(t,e,n,i,o){"use strict";class a extends i.AbstractContainer{constructor(t){super(t),this.switcher=null,this.activeComponentId="",this.parent=document.querySelector(n.ScaffoldIdentifierEnum.scaffold),this.container=document.querySelector(n.ScaffoldIdentifierEnum.contentNavigation),this.switcher=document.querySelector(n.ScaffoldIdentifierEnum.contentNavigationSwitcher)}showComponent(e){if(this.show(e),e===this.activeComponentId)return;if(""!==this.activeComponentId){let t=this.container.querySelector("#navigationComponent-"+this.activeComponentId.replace(/[/]/g,"_"));t&&(t.style.display="none")}const n="navigationComponent-"+e.replace(/[/]/g,"_");if(1===this.container.querySelectorAll('[data-component="'+e+'"]').length)return this.show(e),void(this.activeComponentId=e);t([e],t=>{if("string"==typeof t.navigationComponentName){const i=t.navigationComponentName,o=document.createElement(i);o.setAttribute("id",n),o.classList.add("scaffold-content-navigation-component"),o.dataset.component=e,this.container.append(o)}else{this.container.insertAdjacentHTML("beforeend",'<div class="scaffold-content-navigation-component" data-component="'+e+'" id="'+n+'"></div>');Object.values(t)[0].initialize("#"+n)}this.show(e),this.activeComponentId=e})}hide(t){this.parent.classList.remove("scaffold-content-navigation-expanded"),this.parent.classList.remove("scaffold-content-navigation-available"),t&&this.switcher&&(this.switcher.style.display="none")}show(t){if(this.container.querySelectorAll(n.ScaffoldIdentifierEnum.contentNavigationDataComponent).forEach(t=>t.style.display="none"),void 0!==typeof t){this.parent.classList.add("scaffold-content-navigation-expanded"),this.parent.classList.add("scaffold-content-navigation-available");const e=this.container.querySelector('[data-component="'+t+'"]');e&&(e.style.display=null)}this.switcher&&(this.switcher.style.display=null)}setUrl(t,e){const n=this.consumerScope.invoke(new o("typo3.setUrl",e));return n.then(()=>{this.parent.classList.add("scaffold-content-navigation-expanded");const e=this.getIFrameElement();e&&e.setAttribute("src",t)}),n}getUrl(){const t=this.getIFrameElement();return t?t.getAttribute("src"):""}refresh(){const t=this.getIFrameElement();if(t)return t.contentWindow.location.reload()}getIFrameElement(){return this.container.querySelector(n.ScaffoldIdentifierEnum.contentNavigationIframe)}}return a}));