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