/* * 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 i from"@typo3/core/ajax/ajax-request.js";import{JavaScriptItemProcessor as o}from"@typo3/core/java-script-item-processor.js";import s from"@typo3/backend/notification.js";import c from"@typo3/backend/utility.js";class a{constructor(e){this.objectGroup=null,this.objectGroup=e}newRequest(e){return new i(e)}getEndpoint(e){if(typeof TYPO3.settings.ajaxUrls[e]<"u")return TYPO3.settings.ajaxUrls[e];throw'Undefined endpoint for route "'+e+'"'}send(e,t){const r=e.post(this.createRequestBody(t)).then(async n=>this.processResponse(await n.resolve()));return r.catch(n=>{n instanceof DOMException&&n.name==="AbortError"||s.error("Error "+n.message)}),r}createRequestBody(e){const t={};for(let r=0;rt).map(t=>{const r=document.createElement("link");return r.rel="stylesheet",r.type="text/css",r.href=t,r})),typeof e.inlineData=="object"&&(TYPO3.settings.FormEngineInline=c.mergeDeep(TYPO3.settings.FormEngineInline,e.inlineData)),e.scriptItems instanceof Array&&e.scriptItems.length>0&&new o().processItems(e.scriptItems),e}}export{a as AjaxDispatcher};