/* * 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{html as r}from"lit";import{live as c}from"lit/directives/live.js";import{Task as d,TaskStatus as h}from"@lit/task";import u from"@typo3/core/ajax/ajax-request.js";import i from"~labels/backend.wizards.localization";class p{constructor(e){this.context=e,this.key="handler",this.title=i.get("step.handler_selection.title"),this.autoAdvance=!0,this.hasDispatchedAutoAdvance=!1,this.selectedHandler=null,this.task=new d(this.context.wizard,{task:async([t,a,n,s,l])=>{if(n==null||s==null||l==null)return[];try{return await(await new u(TYPO3.settings.ajaxUrls.wizard_localization_get_handlers).withQueryArguments({recordType:t,recordUid:a,sourceLanguage:n,targetLanguage:s,mode:l}).get()).resolve()}catch(o){return console.warn("Failed to fetch handlers:",o),[]}},args:()=>[this.context.recordType,this.context.recordUid,this.context.getStoreData("sourceLanguage"),this.context.getStoreData("targetLanguage"),this.context.getStoreData("localizationMode")],autoRun:!1})}isComplete(){return this.getValue()!==null}render(){return this.task.status===h.INITIAL&&this.task.run(),this.task.render({complete:e=>{if(this.getValue()==null){const a=this.context.getStoreData("localizationHandler");a!=null&&this.setValue(a)}let t=!1;return this.getValue()==null&&e.length>0&&(this.setValue(e[0].identifier),e.length===1&&(t=!0)),t&&!this.hasDispatchedAutoAdvance?(this.hasDispatchedAutoAdvance=!0,this.context.dispatchAutoAdvance(),this.context.wizard.renderLoader()):e.length===0?r`
${i.get("step.handler_selection.no_handlers")}
${i.get("step.handler_selection.description")}