<script setup>
// Copyright 2024 FlexCDN root@flexcdn.cn. All rights reserved. Official site: https://flexcdn.cn .

import PopupLayout from "@/layouts/PopupLayout.vue";
import ctxRef from "@/utils/ctx_ref.js"
import Context from "./updatePopup.js"
import TInputText from "@/components/ui/TInputText.vue";
import SubmitButton from "@/components/form/SubmitButton.vue";
import PostForm from "@/components/form/PostForm.vue";
import DefinitionTable from "@/components/common/DefinitionTable.vue";

const ctx = ctxRef(new Context())

</script>

<template>
	<PopupLayout>
		<header>修改账号</header>
		<PostForm action="$" @success="ctx.success">
			<input type="hidden" name="accountId" :value="ctx.account.id"/>
			<input type="hidden" name="providerCode" :value="ctx.account.providerCode"/>
			<DefinitionTable>
				<tbody>
				<tr>
					<td>账号名称 *</td>
					<td>
						<TInputText name="name" maxlength="50" autofocus v-model="ctx.account.name" :tabindex="1" class="w-full"/>
					</td>
				</tr>
				<tr>
					<td class="title">服务商 *</td>
					<td>
						<span v-if="ctx.account.provider != null">{{ctx.account.provider.name}}</span>
						<span v-else class="disabled">服务商已失效</span>
						<p class="comment" v-if="ctx.account.provider != null" v-html="ctx.account.provider.description"></p>
					</td>
				</tr>
				</tbody>
				<tbody v-show="ctx.account.provider != null && ctx.account.provider.requireEAB">
				<tr>
					<td>EAB Kid *</td>
					<td>
						<TInputText name="eabKid" maxlength="100" v-model="ctx.account.eabKid" tabindex="3" class="w-full"/>
						<p class="comment" v-if="ctx.account.provider != null" v-html="ctx.account.provider.eabDescription"></p>
					</td>
				</tr>
				<tr>
					<td>EAB HMAC Key *</td>
					<td>
						<TInputText name="eabKey" maxlength="300" v-model="ctx.account.eabKey" :tabindex="4" class="w-full"/>
					</td>
				</tr>
				</tbody>
			</DefinitionTable>
			<SubmitButton></SubmitButton>
		</PostForm>
	</PopupLayout>
</template>

<style lang="postcss" scoped>
</style>