/*
 * 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!
 */
import"bootstrap";import{AbstractInteractableModule as f}from"@typo3/install/module/abstract-interactable-module.js";import S from"@typo3/backend/modal.js";import y from"@typo3/backend/notification.js";import d from"@typo3/core/ajax/ajax-request.js";import{InfoBox as l}from"@typo3/install/renderable/info-box.js";import p from"@typo3/install/renderable/severity.js";import u from"@typo3/install/router.js";import g from"@typo3/core/event/regular-event.js";var r;(function(a){a.outputContainer=".t3js-folderStructure-output",a.errorContainer=".t3js-folderStructure-errors",a.errorList=".t3js-folderStructure-errors-list",a.errorFixTrigger=".t3js-folderStructure-errors-fix",a.okContainer=".t3js-folderStructure-ok",a.okList=".t3js-folderStructure-ok-list",a.permissionContainer=".t3js-folderStructure-permissions"})(r||(r={}));class c extends f{static removeLoadingMessage(e){e.querySelector("typo3-backend-progress-bar").remove()}initialize(e){super.initialize(e),this.loadModuleFrameAgnostic("@typo3/install/renderable/info-box.js").then(()=>{this.getStatus()}),new g("click",s=>{s.preventDefault(),this.fix()}).delegateTo(e,r.errorFixTrigger)}getStatus(){const e=this.getModalBody();new d(u.getUrl("folderStructureGetStatus")).get({cache:"no-cache"}).then(async s=>{const t=await s.resolve();e.innerHTML=t.html,S.setButtons(t.buttons),t.success===!0&&Array.isArray(t.errorStatus)&&(t.errorStatus.length>0?(e.querySelector(r.errorContainer).style.display="block",e.querySelector(r.errorList).innerHTML="",t.errorStatus.forEach(i=>{e.querySelector(r.errorList).appendChild(l.create(i.severity,i.title,i.message))})):e.querySelector(r.errorContainer).style.display="none"),t.success===!0&&Array.isArray(t.okStatus)&&(t.okStatus.length>0?(e.querySelector(r.okContainer).style.display="block",e.querySelector(r.okList).innerHTML="",t.okStatus.forEach(i=>{e.querySelector(r.okList).appendChild(l.create(i.severity,i.title,i.message))})):e.querySelector(r.okContainer).style.display="none");let o=t.folderStructureFilePermissionStatus;const n=e.querySelector(r.permissionContainer);n.replaceChildren(l.create(o.severity,o.title,o.message)),o=t.folderStructureDirectoryPermissionStatus,n.appendChild(l.create(o.severity,o.title,o.message))},s=>{u.handleAjaxError(s,e)})}fix(){this.setModalButtonsState(!1);const e=this.getModalBody(),s=this.findInModal(r.outputContainer);this.renderProgressBar(s),new d(u.getUrl("folderStructureFix")).get({cache:"no-cache"}).then(async t=>{const o=await t.resolve();c.removeLoadingMessage(s),o.success===!0&&Array.isArray(o.fixedStatus)?(o.fixedStatus.length>0?o.fixedStatus.forEach(n=>{s.append(l.create(n.severity,n.title,n.message))}):s.append(l.create(p.warning,"Nothing fixed")),this.getStatus()):y.error("Something went wrong","The request was not processed successfully. Please check the browser's console and TYPO3's log.")},t=>{u.handleAjaxError(t,e)}).finally(()=>{this.setModalButtonsState(!0)})}}var h=new c;export{h as default};
