{$layout "layout_popup"}

<!-- <h3>添加DNS服务商账号</h3> -->
<form class="ui form" data-tea-action="$" data-tea-success="success">
	<csrf-token></csrf-token>
	<table class="ui table definition selectable">
		<tr>
			<td class="title">账号说明 *</td>
			<td>
				<input type="text" name="name" maxlength="50" ref="focus"/>
				<p class="comment">用来方便区分不同的账号。</p>
			</td>
		</tr>
		<tr>
			<td>服务商厂家 *</td>
			<td>
                <b-select
                    name="type"
                    v-model="type"
                    @change="changeType"
                    auto-width
                    :options="[
                        ...types.map(type => ({
                            label: type.name,
                            value: type.code,
                        }))
                    ]"
                ></b-select>

				<!-- <select class="ui dropdown auto-width" name="type" v-model="type" @change="changeType">
					<option v-for="type in types" :value="type.code">{{type.name}}</option>
				</select> -->
                <p class="comment" v-if="typeDescription.length > 0">{{typeDescription}} 系统会保留原有域名下的域名解析，请放心使用。<span v-if="!teaIsPlus">购买商业版可获得更多厂商支持。</span></p>
			</td>
		</tr>
		<tr v-show="type.length > 0">
			<td colspan="2">API参数</td>
		</tr>

		<!-- DNSPod -->
		<tbody v-if="type == 'dnspod'">
            <tr>
                <td>密钥类型 *</td>
                <td>
                    <b-select
                        name="paramDNSPodAPIType"
                        v-model="paramDNSPodAPIType"
                        auto-width
                        :options="[
                            {label: '腾讯云API密钥', value: 'tencentDNS'},
                            {label: 'DNSPod Token', value: 'dnsPodToken'},
                        ]"
                    ></b-select>

                    <!-- <select class="ui dropdown auto-width" name="paramDNSPodAPIType" v-model="paramDNSPodAPIType">
                        <option value="tencentDNS">腾讯云API密钥</option>
                        <option value="dnsPodToken">DNSPod Token</option>
                    </select> -->
                </td>
            </tr>
            <tr v-show="paramDNSPodAPIType == 'tencentDNS'">
                <td>SecretId *</td>
                <td>
                    <input type="text" name="paramDNSPodAccessKeyId" maxlength="100"/>
                    <p class="comment">在DNSPod控制台“账号中心--API密钥”中获取。</p>
                </td>
            </tr>
            <tr v-show="paramDNSPodAPIType == 'tencentDNS'">
                <td>SecretKey *</td>
                <td>
                    <input type="text" name="paramDNSPodAccessKeySecret" maxlength="100"/>
                    <p class="comment">在DNSPod控制台“账号中心--API密钥”中获取。<mask-warning></mask-warning></p>
                </td>
            </tr>
			<tr v-show="paramDNSPodAPIType == 'dnsPodToken'">
				<td>密钥ID *</td>
				<td>
					<input type="text" name="paramDNSPodId" maxlength="100" spellcheck="false"/>
                    <p class="comment">在DNSPod控制台“账号中心--API密钥--DNSPod Token”中获取。</p>
				</td>
			</tr>
			<tr v-show="paramDNSPodAPIType == 'dnsPodToken'">
				<td>密钥Token *</td>
				<td>
					<input type="text" name="paramDNSPodToken" maxlength="100" spellcheck="false"/>
                    <p class="comment">在DNSPod控制台“账号中心--API密钥--DNSPod Token”中获取。<mask-warning></mask-warning></p>
				</td>
			</tr>
            <tr v-if="paramDNSPodAPIType == 'dnsPodToken'">
                <td>区域</td>
                <td>
                    <b-select
                        name="paramDNSPodRegion"
                        auto-width
                        v-model="paramDNSPodRegion"
                        :options="[
                            {label: '中国站', value: ''},
                            {label: '国际站', value: 'international'},
                        ]"
                    ></b-select>

                    <!-- <select class="ui dropdown auto-width" name="paramDNSPodRegion">
                        <option value="">中国站</option>
                        <option value="international">国际站</option>
                    </select> -->
                </td>
            </tr>
		</tbody>

		<!-- AliDNS -->
		<tbody v-if="type == 'alidns'">
			<tr>
				<td>AccessKeyId *</td>
				<td>
					<input type="text" name="paramAliDNSAccessKeyId" maxlength="100" spellcheck="false"/>
					<p class="comment">登录阿里云控制台 -- 在"访问控制"中创建和获取。</p>
				</td>
			</tr>
			<tr>
				<td>AccessKeySecret *</td>
				<td>
					<input type="text" name="paramAliDNSAccessKeySecret" maxlength="100" spellcheck="false"/>
					<p class="comment">登录阿里云控制台 -- 在"访问控制"中创建和获取。<mask-warning></mask-warning></p>
				</td>
			</tr>
            <tr>
                <td>区域ID<optional-label></optional-label></td>
                <td>
                    <input type="text" name="paramAliDNSRegionId" maxlength="100" spellcheck="false"/>
                    <p class="comment">阿里云产品所在区域代号，通常不需要填写。</p>
                </td>
            </tr>
		</tbody>

        <!-- 华为云 -->
        <tbody v-if="type == 'huaweiDNS'">
            <tr>
                <td>AccessKeyId *</td>
                <td>
                    <input type="text" name="paramHuaweiAccessKeyId" maxlength="100" spellcheck="false"/>
                    <p class="comment">登录华为云控制台 -- 在"我的凭证 -- 访问密钥"中创建和获取。</p>
                </td>
            </tr>
            <tr>
                <td>AccessKeySecret *</td>
                <td>
                    <input type="text" name="paramHuaweiAccessKeySecret" maxlength="100" spellcheck="false"/>
                    <p class="comment">登录华为云控制台 -- 在"我的凭证 -- 访问密钥"中创建和获取。<mask-warning></mask-warning></p>
                </td>
            </tr>
            <tr>
                <td>终端节点</td>
                <td>
                    <input type="text" name="paramHuaweiEndpoint" maxlength="100" spellcheck="false"/>
                    <p class="comment">选填项。可以填写终端节点（Endpoint）区域代号或者域名，参考 <a href="https://developer.huaweicloud.com/endpoint?DNS" target="_blank">https://developer.huaweicloud.com/endpoint?DNS</a>（如果此链接失效，请到华为云开发者中心自行查找）。</p>
                </td>
            </tr>
        </tbody>

        <!-- CloudFlare -->
        <tbody v-if="type == 'cloudFlare'">
            <tr>
                <td>API密钥 *</td>
                <td>
                    <input type="text" name="paramCloudFlareAPIKey" maxlength="100" spellcheck="false"/>
                    <p class="comment">在个人资料中的"API令牌"--"API密钥"--"Global API Key"中获取。<mask-warning></mask-warning></p>
                </td>
            </tr>
            <tr>
                <td>账号邮箱 *</td>
                <td>
                    <input type="text" name="paramCloudFlareEmail" maxlength="100" spellcheck="false"/>
                    <p class="comment">登录账号使用的邮箱。</p>
                </td>
            </tr>
        </tbody>

        <!-- GoDaddy -->
        <tbody v-if="type == 'godaddy'">
            <tr>
                <td>Key *</td>
                <td>
                    <input type="text" name="paramGoDaddyKey" maxlength="100" spellcheck="false"/>
                    <p class="comment">可以在GoDaddy<a href="https://developer.godaddy.com/keys" target="_blank">开发者中心</a>创建，创建时Environment选择Production。</p>
                </td>
            </tr>
            <tr>
                <td>Secret *</td>
                <td>
                    <input type="text" name="paramGoDaddySecret" maxlength="100" spellcheck="false"/>
                    <p class="comment"><mask-warning></mask-warning></p>
                </td>
            </tr>
        </tbody>

        <!-- ClouDNS -->
        <tbody v-if="type == 'cloudns'">
            <tr>
                <td>用户认证ID<em>（auth-id）</em></td>
                <td>
                    <input type="text" name="paramClouDNSAuthId" maxlength="20" spellcheck="false"/>
                    <p class="comment">和子用户认证ID二选一。可以在ClouDNS<a href="https://www.cloudns.net/api-settings/" target="_blank">API设置页面</a>添加。</p>
                </td>
            </tr>
            <tr>
                <td>子用户认证ID<em>（sub-auth-id）</em></td>
                <td>
                    <input type="text" name="paramClouDNSSubAuthId" maxlength="20" spellcheck="false"/>
                    <p class="comment">和用户认证ID二选一。可以在ClouDNS<a href="https://www.cloudns.net/api-settings/" target="_blank">API设置页面</a>添加。</p>
                </td>
            </tr>
            <tr>
                <td>认证密码 *<em>（auth-password）</em></td>
                <td>
                    <input type="password" name="paramClouDNSAuthPassword" maxlength="100" spellcheck="false"/>
                    <p class="comment">用户或者子用户的认证密码。<mask-warning></mask-warning></p>
                </td>
            </tr>
        </tbody>

        <!-- DNS.COM -->
        <tbody v-if="type == 'dnscom'">
            <tr>
                <td>API Key *</td>
                <td>
                    <input type="text" name="paramDNSComKey" maxlength="100" spellcheck="false"/>
                    <p class="comment">在DNS.COM控制台账号中心--API设置中创建和查看。</p>
                </td>
            </tr>
            <tr>
                <td>API Secret *</td>
                <td>
                    <input type="text" name="paramDNSComSecret" maxlength="100" spellcheck="false"/>
                    <p class="comment">在DNS.COM控制台账号中心--API设置中创建和查看。<mask-warning></mask-warning></p>
                </td>
            </tr>
        </tbody>

        <!-- DNS.LA -->
        <tbody v-if="type == 'dnsla'">
            <tr>
                <td>API ID *</td>
                <td>
                    <input type="text" name="paramDNSLaAPIId" maxlength="100"/>
                    <p class="comment">在DNS.LA控制台--账户信息中查看。</p>
                </td>
            </tr>
            <tr>
                <td>API密钥 *</td>
                <td>
                    <input type="text" name="paramDNSLaSecret" maxlength="100" spellcheck="false"/>
                    <p class="comment">在DNS.LA控制台--账户信息中查看。<mask-warning></mask-warning></p>
                </td>
            </tr>
        </tbody>

        <!-- VolcEngine -->
        <tbody v-if="type == 'volcEngine'">
            <tr>
                <td>Access Key ID *</td>
                <td>
                    <input type="text" name="paramVolcEngineAccessKeyId" maxlength="100" spellcheck="false"/>
                    <p class="comment">在火山引擎“访问控制--API访问密钥”中获取。</p>
                </td>
            </tr>
            <tr>
                <td>Secret Access Key *</td>
                <td>
                    <input type="text" name="paramVolcEngineAccessKeySecret" maxlength="100" spellcheck="false"/>
                    <p class="comment"><mask-warning></mask-warning></p>
                </td>
            </tr>
        </tbody>

        <!-- Amazon Route 53 -->
        <tbody v-if="type == 'amazonRoute53'">
            <tr>
                <td>Access Key ID *</td>
                <td>
                    <input type="text" name="paramAmazonRoute53AccessKeyId" maxlength="100" spellcheck="false"/>
                </td>
            </tr>
            <tr>
                <td>Secret Access Key *</td>
                <td>
                    <input type="text" name="paramAmazonRoute53AccessKeySecret" maxlength="100" spellcheck="false"/>
                    <p class="comment"><mask-warning></mask-warning></p>
                </td>
            </tr>
            <tr>
                <td>API区域</td>
                <td>
                    <input type="text" name="paramAmazonRoute53Region" maxlength="100"  spellcheck="false"/>
                    <p class="comment">通常不需要填写。</p>
                </td>
            </tr>
        </tbody>

        <!-- Microsoft Azure DNS -->
        <tbody v-if="type == 'azureDNS'">
            <tr>
                <td>订阅ID <br/><em>(Subscription ID)</em> *</td>
                <td>
                    <input type="text" name="paramAzureDNSSubscriptionId" maxlength="100" spellcheck="false"/>
                    <p class="comment">可以在订阅（Subscriptions）服务中查看。</p>
                </td>
            </tr>
            <tr>
                <td>目录(租户) ID <br/><em>(Directory Tenant ID)</em> *</td>
                <td>
                    <input type="text" name="paramAzureDNSTenantId" maxlength="100" spellcheck="false"/>
                    <p class="comment">可以在应用注册（App registrations）中对应应用概述（Overview）中查看。</p>
                </td>
            </tr>
            <tr>
                <td>应用程序(客户端) ID <br/><em>(Client ID)</em> *</td>
                <td><input type="text" name="paramAzureDNSClientId" maxlength="100" spellcheck="false"/>
                    <p class="comment">需要在应用注册（App registrations）中新注册应用程序获得。</p>
                </td>
            </tr>
            <tr>
                <td>客户端密码值 <br/><em>(Client Secret Value)</em> *</td>
                <td><input type="text" name="paramAzureDNSClientSecret" maxlength="100" spellcheck="false"/>
                    <p class="comment">可以在应用注册（App registrations）中对应应用的“证书和密码（Certificates &amp; secrets）”--“客户端密码（Client secrets）”中创建和查看。<mask-warning></mask-warning></p>
                </td>
            </tr>
            <tr>
                <td>资源组 <br/><em>(Resource Group Name)</em> *</td>
                <td>
                    <input type="text" name="paramAzureDNSResourceGroupName" maxlength="100" spellcheck="false"/>
                    <p class="comment">权限设置帮助：你需要在对应资源组（Resource group）-- 访问控制（Access control (IAM)）-- 角色分配（Role assignments）中添加一个角色分配（Role assignment），其中作业职能角色（Job function roles）为"DNS 区域参与者(DNS Zone Contributor)"，成员（Members）为应用注册（App registrations）中的应用程序（application）（有时需要在选择成员（select members）界面搜索应用程序（application）名称才能看到）。</p>
                </td>
            </tr>
        </tbody>

        <!-- bunny.net -->
        <tbody v-if="type == 'bunnyNet'">
            <tr>
                <td>API密钥 *</td>
                <td>
                    <input type="text" name="paramBunnyNetAPIKey" maxlength="100" spellcheck="false"/>
                    <p class="comment">在“Edit account details" -- "API Key"中获取。<mask-warning></mask-warning></p>
                </td>
            </tr>
        </tbody>

        <!-- EdgeDNS -->
        <tbody v-if="type == 'localEdgeDNS'">
            <tr>
                <td>选择域名服务集群 *</td>
                <td>
                    <b-select
                        name="paramLocalEdgeDNSClusterId"
                        v-model="paramLocalEdgeDNSClusterId"
                        auto-width
                        :options="[
                            {label: '[选择域名服务集群]', value: '0'},
                            ...nsClusters.map(cluster => ({
                                label: cluster.name,
                                value: cluster.id,
                            }))
                        ]"
                    ></b-select>

                    <!-- <select class="ui dropdown auto-width" name="paramLocalEdgeDNSClusterId">
                        <option value="0">[选择域名服务集群]</option>
                        <option v-for="cluster in nsClusters" :value="cluster.id">{{cluster.name}}</option>
                    </select> -->
                </td>
            </tr>
        </tbody>

        <!-- EdgeDNS API -->
        <tbody v-if="type == 'edgeDNSAPI'">
            <tr>
                <td>API地址 *</td>
                <td>
                    <input type="text" name="paramEdgeDNSAPIHost" maxlength="100"/>
                </td>
            </tr>
            <tr>
                <td>AccessKey类型 *</td>
                <td>
                    <b-select
                        name="paramEdgeDNSAPIRole"
                        auto-width
                        v-model="paramEdgeDNSAPIRole"
                        :options="[
                            {label: '平台用户', value: 'user'},
                            {label: '管理员', value: 'admin'},
                        ]"
                    ></b-select>

                    <!-- <select class="ui dropdown auto-width" name="paramEdgeDNSAPIRole">
                        <option value="user">平台用户</option>
                        <option value="admin">管理员</option>
                    </select> -->
                </td>
            </tr>
            <tr>
                <td>AccessKey ID *</td>
                <td>
                    <input type="text" name="paramEdgeDNSAPIAccessKeyId" maxlength="64"/>
                </td>
            </tr>
            <tr>
                <td>AccessKey密钥 *</td>
                <td>
                    <input type="text" name="paramEdgeDNSAPIAccessKeySecret" maxlength="64"/>
                    <p class="comment"><mask-warning></mask-warning></p>
                </td>
            </tr>
        </tbody>

        <!-- 自定义HTTP-->
        <tbody v-if="type == 'customHTTP'">
            <tr>
                <td>HTTP URL *</td>
                <td>
                    <input type="text" name="paramCustomHTTPURL" maxlength="200"/>
                    <p class="comment">HTTP URL完整地址，DNS所有操作都会以POST的方式转发到此地址。</p>
                </td>
            </tr>
            <tr>
                <td>私钥 *</td>
                <td>
                    <input type="text" name="paramCustomHTTPSecret" maxlength="64" v-model="paramCustomHTTPSecret"/>
                    <p class="comment">通讯用的私钥，转发请求时会在Header中加入相关信息，方便开发者校验请求是否合法。</p>
                </td>
            </tr>
        </tbody>

        <!-- 更多选项 -->
        <tr>
            <td colspan="2"><more-options-indicator></more-options-indicator></td>
        </tr>

        <tbody v-show="moreOptionsVisible">
            <tr>
                <td>最小TTL</td>
                <td>
                    <div class="ui right labeled input">
                        <input type="text" name="minTTL" size="4" maxlength="6" style="width: 6em"/>
                        <span class="ui label">秒</span>
                    </div>
                    <p class="comment">生成的DNS时可以使用的最小TTL，请根据你选择的服务商和你在服务商中的账号等级进行填写；不填写或者0表示默认。</p>
                </td>
            </tr>
        </tbody>
	</table>

	<submit-btn></submit-btn>
</form>