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